53 lines
528 KiB
JavaScript
53 lines
528 KiB
JavaScript
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const a of l)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function s(l){const a={};return l.integrity&&(a.integrity=l.integrity),l.referrerPolicy&&(a.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?a.credentials="include":l.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(l){if(l.ep)return;l.ep=!0;const a=s(l);fetch(l.href,a)}})();var Ou={exports:{}},$a={},Nu={exports:{}},ue={};/**
|
||
* @license React
|
||
* react.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/var Sl=Symbol.for("react.element"),Pg=Symbol.for("react.portal"),Ag=Symbol.for("react.fragment"),Rg=Symbol.for("react.strict_mode"),Dg=Symbol.for("react.profiler"),Lg=Symbol.for("react.provider"),Og=Symbol.for("react.context"),Ng=Symbol.for("react.forward_ref"),Wg=Symbol.for("react.suspense"),Bg=Symbol.for("react.memo"),$g=Symbol.for("react.lazy"),dc=Symbol.iterator;function Ug(e){return e===null||typeof e!="object"?null:(e=dc&&e[dc]||e["@@iterator"],typeof e=="function"?e:null)}var Wu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Bu=Object.assign,$u={};function _r(e,t,s){this.props=e,this.context=t,this.refs=$u,this.updater=s||Wu}_r.prototype.isReactComponent={};_r.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};_r.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Uu(){}Uu.prototype=_r.prototype;function Bo(e,t,s){this.props=e,this.context=t,this.refs=$u,this.updater=s||Wu}var $o=Bo.prototype=new Uu;$o.constructor=Bo;Bu($o,_r.prototype);$o.isPureReactComponent=!0;var cc=Array.isArray,Fu=Object.prototype.hasOwnProperty,Uo={current:null},Mu={key:!0,ref:!0,__self:!0,__source:!0};function Hu(e,t,s){var r,l={},a=null,i=null;if(t!=null)for(r in t.ref!==void 0&&(i=t.ref),t.key!==void 0&&(a=""+t.key),t)Fu.call(t,r)&&!Mu.hasOwnProperty(r)&&(l[r]=t[r]);var c=arguments.length-2;if(c===1)l.children=s;else if(1<c){for(var d=Array(c),f=0;f<c;f++)d[f]=arguments[f+2];l.children=d}if(e&&e.defaultProps)for(r in c=e.defaultProps,c)l[r]===void 0&&(l[r]=c[r]);return{$$typeof:Sl,type:e,key:a,ref:i,props:l,_owner:Uo.current}}function Fg(e,t){return{$$typeof:Sl,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Fo(e){return typeof e=="object"&&e!==null&&e.$$typeof===Sl}function Mg(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(s){return t[s]})}var uc=/\/+/g;function hi(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Mg(""+e.key):t.toString(36)}function ta(e,t,s,r,l){var a=typeof e;(a==="undefined"||a==="boolean")&&(e=null);var i=!1;if(e===null)i=!0;else switch(a){case"string":case"number":i=!0;break;case"object":switch(e.$$typeof){case Sl:case Pg:i=!0}}if(i)return i=e,l=l(i),e=r===""?"."+hi(i,0):r,cc(l)?(s="",e!=null&&(s=e.replace(uc,"$&/")+"/"),ta(l,t,s,"",function(f){return f})):l!=null&&(Fo(l)&&(l=Fg(l,s+(!l.key||i&&i.key===l.key?"":(""+l.key).replace(uc,"$&/")+"/")+e)),t.push(l)),1;if(i=0,r=r===""?".":r+":",cc(e))for(var c=0;c<e.length;c++){a=e[c];var d=r+hi(a,c);i+=ta(a,t,s,d,l)}else if(d=Ug(e),typeof d=="function")for(e=d.call(e),c=0;!(a=e.next()).done;)a=a.value,d=r+hi(a,c++),i+=ta(a,t,s,d,l);else if(a==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return i}function Rl(e,t,s){if(e==null)return e;var r=[],l=0;return ta(e,r,"","",function(a){return t.call(s,a,l++)}),r}function Hg(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(s){(e._status===0||e._status===-1)&&(e._status=1,e._result=s)},function(s){(e._status===0||e._status===-1)&&(e._status=2,e._result=s)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var yt={current:null},na={transition:null},Gg={ReactCurrentDispatcher:yt,ReactCurrentBatchConfig:na,ReactCurrentOwner:Uo};function Gu(){throw Error("act(...) is not supported in production builds of React.")}ue.Children={map:Rl,forEach:function(e,t,s){Rl(e,function(){t.apply(this,arguments)},s)},count:function(e){var t=0;return Rl(e,function(){t++}),t},toArray:function(e){return Rl(e,function(t){return t})||[]},only:function(e){if(!Fo(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ue.Component=_r;ue.Fragment=Ag;ue.Profiler=Dg;ue.PureComponent=Bo;ue.StrictMode=Rg;ue.Suspense=Wg;ue.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Gg;ue.act=Gu;ue.cloneElement=function(e,t,s){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=Bu({},e.props),l=e.key,a=e.ref,i=e._owner;if(t!=null){if(t.ref!==void 0&&(a=t.ref,i=Uo.current),t.key!==void 0&&(l=""+t.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(d in t)Fu.call(t,d)&&!Mu.hasOwnProperty(d)&&(r[d]=t[d]===void 0&&c!==void 0?c[d]:t[d])}var d=arguments.length-2;if(d===1)r.children=s;else if(1<d){c=Array(d);for(var f=0;f<d;f++)c[f]=arguments[f+2];r.children=c}return{$$typeof:Sl,type:e.type,key:l,ref:a,props:r,_owner:i}};ue.createContext=function(e){return e={$$typeof:Og,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Lg,_context:e},e.Consumer=e};ue.createElement=Hu;ue.createFactory=function(e){var t=Hu.bind(null,e);return t.type=e,t};ue.createRef=function(){return{current:null}};ue.forwardRef=function(e){return{$$typeof:Ng,render:e}};ue.isValidElement=Fo;ue.lazy=function(e){return{$$typeof:$g,_payload:{_status:-1,_result:e},_init:Hg}};ue.memo=function(e,t){return{$$typeof:Bg,type:e,compare:t===void 0?null:t}};ue.startTransition=function(e){var t=na.transition;na.transition={};try{e()}finally{na.transition=t}};ue.unstable_act=Gu;ue.useCallback=function(e,t){return yt.current.useCallback(e,t)};ue.useContext=function(e){return yt.current.useContext(e)};ue.useDebugValue=function(){};ue.useDeferredValue=function(e){return yt.current.useDeferredValue(e)};ue.useEffect=function(e,t){return yt.current.useEffect(e,t)};ue.useId=function(){return yt.current.useId()};ue.useImperativeHandle=function(e,t,s){return yt.current.useImperativeHandle(e,t,s)};ue.useInsertionEffect=function(e,t){return yt.current.useInsertionEffect(e,t)};ue.useLayoutEffect=function(e,t){return yt.current.useLayoutEffect(e,t)};ue.useMemo=function(e,t){return yt.current.useMemo(e,t)};ue.useReducer=function(e,t,s){return yt.current.useReducer(e,t,s)};ue.useRef=function(e){return yt.current.useRef(e)};ue.useState=function(e){return yt.current.useState(e)};ue.useSyncExternalStore=function(e,t,s){return yt.current.useSyncExternalStore(e,t,s)};ue.useTransition=function(){return yt.current.useTransition()};ue.version="18.3.1";Nu.exports=ue;var w=Nu.exports;/**
|
||
* @license React
|
||
* react-jsx-runtime.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/var Kg=w,Qg=Symbol.for("react.element"),Yg=Symbol.for("react.fragment"),Xg=Object.prototype.hasOwnProperty,qg=Kg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Jg={key:!0,ref:!0,__self:!0,__source:!0};function Ku(e,t,s){var r,l={},a=null,i=null;s!==void 0&&(a=""+s),t.key!==void 0&&(a=""+t.key),t.ref!==void 0&&(i=t.ref);for(r in t)Xg.call(t,r)&&!Jg.hasOwnProperty(r)&&(l[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)l[r]===void 0&&(l[r]=t[r]);return{$$typeof:Qg,type:e,key:a,ref:i,props:l,_owner:qg.current}}$a.Fragment=Yg;$a.jsx=Ku;$a.jsxs=Ku;Ou.exports=$a;var n=Ou.exports,Qu={exports:{}},Rt={},Yu={exports:{}},Xu={};/**
|
||
* @license React
|
||
* scheduler.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/(function(e){function t(A,K){var Y=A.length;A.push(K);e:for(;0<Y;){var ee=Y-1>>>1,V=A[ee];if(0<l(V,K))A[ee]=K,A[Y]=V,Y=ee;else break e}}function s(A){return A.length===0?null:A[0]}function r(A){if(A.length===0)return null;var K=A[0],Y=A.pop();if(Y!==K){A[0]=Y;e:for(var ee=0,V=A.length,ze=V>>>1;ee<ze;){var $e=2*(ee+1)-1,Oe=A[$e],ge=$e+1,Je=A[ge];if(0>l(Oe,Y))ge<V&&0>l(Je,Oe)?(A[ee]=Je,A[ge]=Y,ee=ge):(A[ee]=Oe,A[$e]=Y,ee=$e);else if(ge<V&&0>l(Je,Y))A[ee]=Je,A[ge]=Y,ee=ge;else break e}}return K}function l(A,K){var Y=A.sortIndex-K.sortIndex;return Y!==0?Y:A.id-K.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var i=Date,c=i.now();e.unstable_now=function(){return i.now()-c}}var d=[],f=[],v=1,p=null,u=3,m=!1,j=!1,h=!1,S=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function o(A){for(var K=s(f);K!==null;){if(K.callback===null)r(f);else if(K.startTime<=A)r(f),K.sortIndex=K.expirationTime,t(d,K);else break;K=s(f)}}function y(A){if(h=!1,o(A),!j)if(s(d)!==null)j=!0,B(_);else{var K=s(f);K!==null&&M(y,K.startTime-A)}}function _(A,K){j=!1,h&&(h=!1,g(k),k=-1),m=!0;var Y=u;try{for(o(K),p=s(d);p!==null&&(!(p.expirationTime>K)||A&&!Z());){var ee=p.callback;if(typeof ee=="function"){p.callback=null,u=p.priorityLevel;var V=ee(p.expirationTime<=K);K=e.unstable_now(),typeof V=="function"?p.callback=V:p===s(d)&&r(d),o(K)}else r(d);p=s(d)}if(p!==null)var ze=!0;else{var $e=s(f);$e!==null&&M(y,$e.startTime-K),ze=!1}return ze}finally{p=null,u=Y,m=!1}}var C=!1,P=null,k=-1,R=5,$=-1;function Z(){return!(e.unstable_now()-$<R)}function de(){if(P!==null){var A=e.unstable_now();$=A;var K=!0;try{K=P(!0,A)}finally{K?D():(C=!1,P=null)}}else C=!1}var D;if(typeof x=="function")D=function(){x(de)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,E=T.port2;T.port1.onmessage=de,D=function(){E.postMessage(null)}}else D=function(){S(de,0)};function B(A){P=A,C||(C=!0,D())}function M(A,K){k=S(function(){A(e.unstable_now())},K)}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(A){A.callback=null},e.unstable_continueExecution=function(){j||m||(j=!0,B(_))},e.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return u},e.unstable_getFirstCallbackNode=function(){return s(d)},e.unstable_next=function(A){switch(u){case 1:case 2:case 3:var K=3;break;default:K=u}var Y=u;u=K;try{return A()}finally{u=Y}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(A,K){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var Y=u;u=A;try{return K()}finally{u=Y}},e.unstable_scheduleCallback=function(A,K,Y){var ee=e.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0<Y?ee+Y:ee):Y=ee,A){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=Y+V,A={id:v++,callback:K,priorityLevel:A,startTime:Y,expirationTime:V,sortIndex:-1},Y>ee?(A.sortIndex=Y,t(f,A),s(d)===null&&A===s(f)&&(h?(g(k),k=-1):h=!0,M(y,Y-ee))):(A.sortIndex=V,t(d,A),j||m||(j=!0,B(_))),A},e.unstable_shouldYield=Z,e.unstable_wrapCallback=function(A){var K=u;return function(){var Y=u;u=K;try{return A.apply(this,arguments)}finally{u=Y}}}})(Xu);Yu.exports=Xu;var Zg=Yu.exports;/**
|
||
* @license React
|
||
* react-dom.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/var Vg=w,At=Zg;function G(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,s=1;s<arguments.length;s++)t+="&args[]="+encodeURIComponent(arguments[s]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var qu=new Set,rl={};function Cs(e,t){gr(e,t),gr(e+"Capture",t)}function gr(e,t){for(rl[e]=t,e=0;e<t.length;e++)qu.add(t[e])}var Sn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Mi=Object.prototype.hasOwnProperty,ex=/^[: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]*$/,pc={},fc={};function tx(e){return Mi.call(fc,e)?!0:Mi.call(pc,e)?!1:ex.test(e)?fc[e]=!0:(pc[e]=!0,!1)}function nx(e,t,s,r){if(s!==null&&s.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:s!==null?!s.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function sx(e,t,s,r){if(t===null||typeof t>"u"||nx(e,t,s,r))return!0;if(r)return!1;if(s!==null)switch(s.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function vt(e,t,s,r,l,a,i){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=s,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=i}var ot={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ot[e]=new vt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];ot[t]=new vt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ot[e]=new vt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ot[e]=new vt(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){ot[e]=new vt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ot[e]=new vt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ot[e]=new vt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ot[e]=new vt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ot[e]=new vt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Mo=/[\-:]([a-z])/g;function Ho(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Mo,Ho);ot[t]=new vt(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Mo,Ho);ot[t]=new vt(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Mo,Ho);ot[t]=new vt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ot[e]=new vt(e,1,!1,e.toLowerCase(),null,!1,!1)});ot.xlinkHref=new vt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ot[e]=new vt(e,1,!1,e.toLowerCase(),null,!0,!0)});function Go(e,t,s,r){var l=ot.hasOwnProperty(t)?ot[t]:null;(l!==null?l.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(sx(t,s,l,r)&&(s=null),r||l===null?tx(t)&&(s===null?e.removeAttribute(t):e.setAttribute(t,""+s)):l.mustUseProperty?e[l.propertyName]=s===null?l.type===3?!1:"":s:(t=l.attributeName,r=l.attributeNamespace,s===null?e.removeAttribute(t):(l=l.type,s=l===3||l===4&&s===!0?"":""+s,r?e.setAttributeNS(r,t,s):e.setAttribute(t,s))))}var Cn=Vg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Dl=Symbol.for("react.element"),qs=Symbol.for("react.portal"),Js=Symbol.for("react.fragment"),Ko=Symbol.for("react.strict_mode"),Hi=Symbol.for("react.profiler"),Ju=Symbol.for("react.provider"),Zu=Symbol.for("react.context"),Qo=Symbol.for("react.forward_ref"),Gi=Symbol.for("react.suspense"),Ki=Symbol.for("react.suspense_list"),Yo=Symbol.for("react.memo"),Pn=Symbol.for("react.lazy"),Vu=Symbol.for("react.offscreen"),hc=Symbol.iterator;function Ar(e){return e===null||typeof e!="object"?null:(e=hc&&e[hc]||e["@@iterator"],typeof e=="function"?e:null)}var Le=Object.assign,gi;function Hr(e){if(gi===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);gi=t&&t[1]||""}return`
|
||
`+gi+e}var xi=!1;function mi(e,t){if(!e||xi)return"";xi=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(f){var r=f}Reflect.construct(e,[],t)}else{try{t.call()}catch(f){r=f}e.call(t.prototype)}else{try{throw Error()}catch(f){r=f}e()}}catch(f){if(f&&r&&typeof f.stack=="string"){for(var l=f.stack.split(`
|
||
`),a=r.stack.split(`
|
||
`),i=l.length-1,c=a.length-1;1<=i&&0<=c&&l[i]!==a[c];)c--;for(;1<=i&&0<=c;i--,c--)if(l[i]!==a[c]){if(i!==1||c!==1)do if(i--,c--,0>c||l[i]!==a[c]){var d=`
|
||
`+l[i].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),d}while(1<=i&&0<=c);break}}}finally{xi=!1,Error.prepareStackTrace=s}return(e=e?e.displayName||e.name:"")?Hr(e):""}function rx(e){switch(e.tag){case 5:return Hr(e.type);case 16:return Hr("Lazy");case 13:return Hr("Suspense");case 19:return Hr("SuspenseList");case 0:case 2:case 15:return e=mi(e.type,!1),e;case 11:return e=mi(e.type.render,!1),e;case 1:return e=mi(e.type,!0),e;default:return""}}function Qi(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Js:return"Fragment";case qs:return"Portal";case Hi:return"Profiler";case Ko:return"StrictMode";case Gi:return"Suspense";case Ki:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Zu:return(e.displayName||"Context")+".Consumer";case Ju:return(e._context.displayName||"Context")+".Provider";case Qo:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Yo:return t=e.displayName||null,t!==null?t:Qi(e.type)||"Memo";case Pn:t=e._payload,e=e._init;try{return Qi(e(t))}catch{}}return null}function lx(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Qi(t);case 8:return t===Ko?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Qn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ep(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ax(e){var t=ep(e)?"checked":"value",s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var l=s.get,a=s.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(i){r=""+i,a.call(this,i)}}),Object.defineProperty(e,t,{enumerable:s.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ll(e){e._valueTracker||(e._valueTracker=ax(e))}function tp(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),r="";return e&&(r=ep(e)?e.checked?"true":"false":e.value),e=r,e!==s?(t.setValue(e),!0):!1}function ha(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Yi(e,t){var s=t.checked;return Le({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:s??e._wrapperState.initialChecked})}function gc(e,t){var s=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;s=Qn(t.value!=null?t.value:s),e._wrapperState={initialChecked:r,initialValue:s,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function np(e,t){t=t.checked,t!=null&&Go(e,"checked",t,!1)}function Xi(e,t){np(e,t);var s=Qn(t.value),r=t.type;if(s!=null)r==="number"?(s===0&&e.value===""||e.value!=s)&&(e.value=""+s):e.value!==""+s&&(e.value=""+s);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?qi(e,t.type,s):t.hasOwnProperty("defaultValue")&&qi(e,t.type,Qn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function xc(e,t,s){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,s||t===e.value||(e.value=t),e.defaultValue=t}s=e.name,s!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,s!==""&&(e.name=s)}function qi(e,t,s){(t!=="number"||ha(e.ownerDocument)!==e)&&(s==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+s&&(e.defaultValue=""+s))}var Gr=Array.isArray;function dr(e,t,s,r){if(e=e.options,t){t={};for(var l=0;l<s.length;l++)t["$"+s[l]]=!0;for(s=0;s<e.length;s++)l=t.hasOwnProperty("$"+e[s].value),e[s].selected!==l&&(e[s].selected=l),l&&r&&(e[s].defaultSelected=!0)}else{for(s=""+Qn(s),t=null,l=0;l<e.length;l++){if(e[l].value===s){e[l].selected=!0,r&&(e[l].defaultSelected=!0);return}t!==null||e[l].disabled||(t=e[l])}t!==null&&(t.selected=!0)}}function Ji(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(G(91));return Le({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function mc(e,t){var s=t.value;if(s==null){if(s=t.children,t=t.defaultValue,s!=null){if(t!=null)throw Error(G(92));if(Gr(s)){if(1<s.length)throw Error(G(93));s=s[0]}t=s}t==null&&(t=""),s=t}e._wrapperState={initialValue:Qn(s)}}function sp(e,t){var s=Qn(t.value),r=Qn(t.defaultValue);s!=null&&(s=""+s,s!==e.value&&(e.value=s),t.defaultValue==null&&e.defaultValue!==s&&(e.defaultValue=s)),r!=null&&(e.defaultValue=""+r)}function yc(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function rp(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Zi(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?rp(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Ol,lp=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,s,r,l){MSApp.execUnsafeLocalFunction(function(){return e(t,s,r,l)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Ol=Ol||document.createElement("div"),Ol.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Ol.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function ll(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var Xr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ix=["Webkit","ms","Moz","O"];Object.keys(Xr).forEach(function(e){ix.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Xr[t]=Xr[e]})});function ap(e,t,s){return t==null||typeof t=="boolean"||t===""?"":s||typeof t!="number"||t===0||Xr.hasOwnProperty(e)&&Xr[e]?(""+t).trim():t+"px"}function ip(e,t){e=e.style;for(var s in t)if(t.hasOwnProperty(s)){var r=s.indexOf("--")===0,l=ap(s,t[s],r);s==="float"&&(s="cssFloat"),r?e.setProperty(s,l):e[s]=l}}var ox=Le({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Vi(e,t){if(t){if(ox[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(G(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(G(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(G(61))}if(t.style!=null&&typeof t.style!="object")throw Error(G(62))}}function eo(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var to=null;function Xo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var no=null,cr=null,ur=null;function vc(e){if(e=kl(e)){if(typeof no!="function")throw Error(G(280));var t=e.stateNode;t&&(t=Ga(t),no(e.stateNode,e.type,t))}}function op(e){cr?ur?ur.push(e):ur=[e]:cr=e}function dp(){if(cr){var e=cr,t=ur;if(ur=cr=null,vc(e),t)for(e=0;e<t.length;e++)vc(t[e])}}function cp(e,t){return e(t)}function up(){}var yi=!1;function pp(e,t,s){if(yi)return e(t,s);yi=!0;try{return cp(e,t,s)}finally{yi=!1,(cr!==null||ur!==null)&&(up(),dp())}}function al(e,t){var s=e.stateNode;if(s===null)return null;var r=Ga(s);if(r===null)return null;s=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(G(231,t,typeof s));return s}var so=!1;if(Sn)try{var Rr={};Object.defineProperty(Rr,"passive",{get:function(){so=!0}}),window.addEventListener("test",Rr,Rr),window.removeEventListener("test",Rr,Rr)}catch{so=!1}function dx(e,t,s,r,l,a,i,c,d){var f=Array.prototype.slice.call(arguments,3);try{t.apply(s,f)}catch(v){this.onError(v)}}var qr=!1,ga=null,xa=!1,ro=null,cx={onError:function(e){qr=!0,ga=e}};function ux(e,t,s,r,l,a,i,c,d){qr=!1,ga=null,dx.apply(cx,arguments)}function px(e,t,s,r,l,a,i,c,d){if(ux.apply(this,arguments),qr){if(qr){var f=ga;qr=!1,ga=null}else throw Error(G(198));xa||(xa=!0,ro=f)}}function zs(e){var t=e,s=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(s=t.return),e=t.return;while(e)}return t.tag===3?s:null}function fp(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function jc(e){if(zs(e)!==e)throw Error(G(188))}function fx(e){var t=e.alternate;if(!t){if(t=zs(e),t===null)throw Error(G(188));return t!==e?null:e}for(var s=e,r=t;;){var l=s.return;if(l===null)break;var a=l.alternate;if(a===null){if(r=l.return,r!==null){s=r;continue}break}if(l.child===a.child){for(a=l.child;a;){if(a===s)return jc(l),e;if(a===r)return jc(l),t;a=a.sibling}throw Error(G(188))}if(s.return!==r.return)s=l,r=a;else{for(var i=!1,c=l.child;c;){if(c===s){i=!0,s=l,r=a;break}if(c===r){i=!0,r=l,s=a;break}c=c.sibling}if(!i){for(c=a.child;c;){if(c===s){i=!0,s=a,r=l;break}if(c===r){i=!0,r=a,s=l;break}c=c.sibling}if(!i)throw Error(G(189))}}if(s.alternate!==r)throw Error(G(190))}if(s.tag!==3)throw Error(G(188));return s.stateNode.current===s?e:t}function hp(e){return e=fx(e),e!==null?gp(e):null}function gp(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=gp(e);if(t!==null)return t;e=e.sibling}return null}var xp=At.unstable_scheduleCallback,bc=At.unstable_cancelCallback,hx=At.unstable_shouldYield,gx=At.unstable_requestPaint,He=At.unstable_now,xx=At.unstable_getCurrentPriorityLevel,qo=At.unstable_ImmediatePriority,mp=At.unstable_UserBlockingPriority,ma=At.unstable_NormalPriority,mx=At.unstable_LowPriority,yp=At.unstable_IdlePriority,Ua=null,an=null;function yx(e){if(an&&typeof an.onCommitFiberRoot=="function")try{an.onCommitFiberRoot(Ua,e,void 0,(e.current.flags&128)===128)}catch{}}var Yt=Math.clz32?Math.clz32:bx,vx=Math.log,jx=Math.LN2;function bx(e){return e>>>=0,e===0?32:31-(vx(e)/jx|0)|0}var Nl=64,Wl=4194304;function Kr(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function ya(e,t){var s=e.pendingLanes;if(s===0)return 0;var r=0,l=e.suspendedLanes,a=e.pingedLanes,i=s&268435455;if(i!==0){var c=i&~l;c!==0?r=Kr(c):(a&=i,a!==0&&(r=Kr(a)))}else i=s&~l,i!==0?r=Kr(i):a!==0&&(r=Kr(a));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,a=t&-t,l>=a||l===16&&(a&4194240)!==0))return t;if(r&4&&(r|=s&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)s=31-Yt(t),l=1<<s,r|=e[s],t&=~l;return r}function Sx(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function wx(e,t){for(var s=e.suspendedLanes,r=e.pingedLanes,l=e.expirationTimes,a=e.pendingLanes;0<a;){var i=31-Yt(a),c=1<<i,d=l[i];d===-1?(!(c&s)||c&r)&&(l[i]=Sx(c,t)):d<=t&&(e.expiredLanes|=c),a&=~c}}function lo(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function vp(){var e=Nl;return Nl<<=1,!(Nl&4194240)&&(Nl=64),e}function vi(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function wl(e,t,s){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Yt(t),e[t]=s}function _x(e,t){var s=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<s;){var l=31-Yt(s),a=1<<l;t[l]=0,r[l]=-1,e[l]=-1,s&=~a}}function Jo(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var r=31-Yt(s),l=1<<r;l&t|e[r]&t&&(e[r]|=t),s&=~l}}var ye=0;function jp(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var bp,Zo,Sp,wp,_p,ao=!1,Bl=[],Bn=null,$n=null,Un=null,il=new Map,ol=new Map,Rn=[],kx="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 submit".split(" ");function Sc(e,t){switch(e){case"focusin":case"focusout":Bn=null;break;case"dragenter":case"dragleave":$n=null;break;case"mouseover":case"mouseout":Un=null;break;case"pointerover":case"pointerout":il.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":ol.delete(t.pointerId)}}function Dr(e,t,s,r,l,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:s,eventSystemFlags:r,nativeEvent:a,targetContainers:[l]},t!==null&&(t=kl(t),t!==null&&Zo(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,l!==null&&t.indexOf(l)===-1&&t.push(l),e)}function Cx(e,t,s,r,l){switch(t){case"focusin":return Bn=Dr(Bn,e,t,s,r,l),!0;case"dragenter":return $n=Dr($n,e,t,s,r,l),!0;case"mouseover":return Un=Dr(Un,e,t,s,r,l),!0;case"pointerover":var a=l.pointerId;return il.set(a,Dr(il.get(a)||null,e,t,s,r,l)),!0;case"gotpointercapture":return a=l.pointerId,ol.set(a,Dr(ol.get(a)||null,e,t,s,r,l)),!0}return!1}function kp(e){var t=gs(e.target);if(t!==null){var s=zs(t);if(s!==null){if(t=s.tag,t===13){if(t=fp(s),t!==null){e.blockedOn=t,_p(e.priority,function(){Sp(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function sa(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=io(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(s===null){s=e.nativeEvent;var r=new s.constructor(s.type,s);to=r,s.target.dispatchEvent(r),to=null}else return t=kl(s),t!==null&&Zo(t),e.blockedOn=s,!1;t.shift()}return!0}function wc(e,t,s){sa(e)&&s.delete(t)}function zx(){ao=!1,Bn!==null&&sa(Bn)&&(Bn=null),$n!==null&&sa($n)&&($n=null),Un!==null&&sa(Un)&&(Un=null),il.forEach(wc),ol.forEach(wc)}function Lr(e,t){e.blockedOn===t&&(e.blockedOn=null,ao||(ao=!0,At.unstable_scheduleCallback(At.unstable_NormalPriority,zx)))}function dl(e){function t(l){return Lr(l,e)}if(0<Bl.length){Lr(Bl[0],e);for(var s=1;s<Bl.length;s++){var r=Bl[s];r.blockedOn===e&&(r.blockedOn=null)}}for(Bn!==null&&Lr(Bn,e),$n!==null&&Lr($n,e),Un!==null&&Lr(Un,e),il.forEach(t),ol.forEach(t),s=0;s<Rn.length;s++)r=Rn[s],r.blockedOn===e&&(r.blockedOn=null);for(;0<Rn.length&&(s=Rn[0],s.blockedOn===null);)kp(s),s.blockedOn===null&&Rn.shift()}var pr=Cn.ReactCurrentBatchConfig,va=!0;function Tx(e,t,s,r){var l=ye,a=pr.transition;pr.transition=null;try{ye=1,Vo(e,t,s,r)}finally{ye=l,pr.transition=a}}function Ix(e,t,s,r){var l=ye,a=pr.transition;pr.transition=null;try{ye=4,Vo(e,t,s,r)}finally{ye=l,pr.transition=a}}function Vo(e,t,s,r){if(va){var l=io(e,t,s,r);if(l===null)Ii(e,t,r,ja,s),Sc(e,r);else if(Cx(l,e,t,s,r))r.stopPropagation();else if(Sc(e,r),t&4&&-1<kx.indexOf(e)){for(;l!==null;){var a=kl(l);if(a!==null&&bp(a),a=io(e,t,s,r),a===null&&Ii(e,t,r,ja,s),a===l)break;l=a}l!==null&&r.stopPropagation()}else Ii(e,t,r,null,s)}}var ja=null;function io(e,t,s,r){if(ja=null,e=Xo(r),e=gs(e),e!==null)if(t=zs(e),t===null)e=null;else if(s=t.tag,s===13){if(e=fp(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return ja=e,null}function Cp(e){switch(e){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"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 1;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"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(xx()){case qo:return 1;case mp:return 4;case ma:case mx:return 16;case yp:return 536870912;default:return 16}default:return 16}}var Ln=null,ed=null,ra=null;function zp(){if(ra)return ra;var e,t=ed,s=t.length,r,l="value"in Ln?Ln.value:Ln.textContent,a=l.length;for(e=0;e<s&&t[e]===l[e];e++);var i=s-e;for(r=1;r<=i&&t[s-r]===l[a-r];r++);return ra=l.slice(e,1<r?1-r:void 0)}function la(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function $l(){return!0}function _c(){return!1}function Dt(e){function t(s,r,l,a,i){this._reactName=s,this._targetInst=l,this.type=r,this.nativeEvent=a,this.target=i,this.currentTarget=null;for(var c in e)e.hasOwnProperty(c)&&(s=e[c],this[c]=s?s(a):a[c]);return this.isDefaultPrevented=(a.defaultPrevented!=null?a.defaultPrevented:a.returnValue===!1)?$l:_c,this.isPropagationStopped=_c,this}return Le(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=$l)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=$l)},persist:function(){},isPersistent:$l}),t}var kr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},td=Dt(kr),_l=Le({},kr,{view:0,detail:0}),Ex=Dt(_l),ji,bi,Or,Fa=Le({},_l,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:nd,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Or&&(Or&&e.type==="mousemove"?(ji=e.screenX-Or.screenX,bi=e.screenY-Or.screenY):bi=ji=0,Or=e),ji)},movementY:function(e){return"movementY"in e?e.movementY:bi}}),kc=Dt(Fa),Px=Le({},Fa,{dataTransfer:0}),Ax=Dt(Px),Rx=Le({},_l,{relatedTarget:0}),Si=Dt(Rx),Dx=Le({},kr,{animationName:0,elapsedTime:0,pseudoElement:0}),Lx=Dt(Dx),Ox=Le({},kr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Nx=Dt(Ox),Wx=Le({},kr,{data:0}),Cc=Dt(Wx),Bx={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},$x={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"},Ux={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Fx(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Ux[e])?!!t[e]:!1}function nd(){return Fx}var Mx=Le({},_l,{key:function(e){if(e.key){var t=Bx[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=la(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?$x[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:nd,charCode:function(e){return e.type==="keypress"?la(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?la(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Hx=Dt(Mx),Gx=Le({},Fa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),zc=Dt(Gx),Kx=Le({},_l,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:nd}),Qx=Dt(Kx),Yx=Le({},kr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Xx=Dt(Yx),qx=Le({},Fa,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Jx=Dt(qx),Zx=[9,13,27,32],sd=Sn&&"CompositionEvent"in window,Jr=null;Sn&&"documentMode"in document&&(Jr=document.documentMode);var Vx=Sn&&"TextEvent"in window&&!Jr,Tp=Sn&&(!sd||Jr&&8<Jr&&11>=Jr),Tc=" ",Ic=!1;function Ip(e,t){switch(e){case"keyup":return Zx.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ep(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Zs=!1;function em(e,t){switch(e){case"compositionend":return Ep(t);case"keypress":return t.which!==32?null:(Ic=!0,Tc);case"textInput":return e=t.data,e===Tc&&Ic?null:e;default:return null}}function tm(e,t){if(Zs)return e==="compositionend"||!sd&&Ip(e,t)?(e=zp(),ra=ed=Ln=null,Zs=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Tp&&t.locale!=="ko"?null:t.data;default:return null}}var nm={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 Ec(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!nm[e.type]:t==="textarea"}function Pp(e,t,s,r){op(r),t=ba(t,"onChange"),0<t.length&&(s=new td("onChange","change",null,s,r),e.push({event:s,listeners:t}))}var Zr=null,cl=null;function sm(e){Fp(e,0)}function Ma(e){var t=tr(e);if(tp(t))return e}function rm(e,t){if(e==="change")return t}var Ap=!1;if(Sn){var wi;if(Sn){var _i="oninput"in document;if(!_i){var Pc=document.createElement("div");Pc.setAttribute("oninput","return;"),_i=typeof Pc.oninput=="function"}wi=_i}else wi=!1;Ap=wi&&(!document.documentMode||9<document.documentMode)}function Ac(){Zr&&(Zr.detachEvent("onpropertychange",Rp),cl=Zr=null)}function Rp(e){if(e.propertyName==="value"&&Ma(cl)){var t=[];Pp(t,cl,e,Xo(e)),pp(sm,t)}}function lm(e,t,s){e==="focusin"?(Ac(),Zr=t,cl=s,Zr.attachEvent("onpropertychange",Rp)):e==="focusout"&&Ac()}function am(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Ma(cl)}function im(e,t){if(e==="click")return Ma(t)}function om(e,t){if(e==="input"||e==="change")return Ma(t)}function dm(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var qt=typeof Object.is=="function"?Object.is:dm;function ul(e,t){if(qt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),r=Object.keys(t);if(s.length!==r.length)return!1;for(r=0;r<s.length;r++){var l=s[r];if(!Mi.call(t,l)||!qt(e[l],t[l]))return!1}return!0}function Rc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Dc(e,t){var s=Rc(e);e=0;for(var r;s;){if(s.nodeType===3){if(r=e+s.textContent.length,e<=t&&r>=t)return{node:s,offset:t-e};e=r}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=Rc(s)}}function Dp(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Dp(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Lp(){for(var e=window,t=ha();t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=ha(e.document)}return t}function rd(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function cm(e){var t=Lp(),s=e.focusedElem,r=e.selectionRange;if(t!==s&&s&&s.ownerDocument&&Dp(s.ownerDocument.documentElement,s)){if(r!==null&&rd(s)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in s)s.selectionStart=t,s.selectionEnd=Math.min(e,s.value.length);else if(e=(t=s.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=s.textContent.length,a=Math.min(r.start,l);r=r.end===void 0?a:Math.min(r.end,l),!e.extend&&a>r&&(l=r,r=a,a=l),l=Dc(s,a);var i=Dc(s,r);l&&i&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.offset),e.addRange(t)))}}for(t=[],e=s;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;s<t.length;s++)e=t[s],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var um=Sn&&"documentMode"in document&&11>=document.documentMode,Vs=null,oo=null,Vr=null,co=!1;function Lc(e,t,s){var r=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;co||Vs==null||Vs!==ha(r)||(r=Vs,"selectionStart"in r&&rd(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Vr&&ul(Vr,r)||(Vr=r,r=ba(oo,"onSelect"),0<r.length&&(t=new td("onSelect","select",null,t,s),e.push({event:t,listeners:r}),t.target=Vs)))}function Ul(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var er={animationend:Ul("Animation","AnimationEnd"),animationiteration:Ul("Animation","AnimationIteration"),animationstart:Ul("Animation","AnimationStart"),transitionend:Ul("Transition","TransitionEnd")},ki={},Op={};Sn&&(Op=document.createElement("div").style,"AnimationEvent"in window||(delete er.animationend.animation,delete er.animationiteration.animation,delete er.animationstart.animation),"TransitionEvent"in window||delete er.transitionend.transition);function Ha(e){if(ki[e])return ki[e];if(!er[e])return e;var t=er[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in Op)return ki[e]=t[s];return e}var Np=Ha("animationend"),Wp=Ha("animationiteration"),Bp=Ha("animationstart"),$p=Ha("transitionend"),Up=new Map,Oc="abort auxClick 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(" ");function qn(e,t){Up.set(e,t),Cs(t,[e])}for(var Ci=0;Ci<Oc.length;Ci++){var zi=Oc[Ci],pm=zi.toLowerCase(),fm=zi[0].toUpperCase()+zi.slice(1);qn(pm,"on"+fm)}qn(Np,"onAnimationEnd");qn(Wp,"onAnimationIteration");qn(Bp,"onAnimationStart");qn("dblclick","onDoubleClick");qn("focusin","onFocus");qn("focusout","onBlur");qn($p,"onTransitionEnd");gr("onMouseEnter",["mouseout","mouseover"]);gr("onMouseLeave",["mouseout","mouseover"]);gr("onPointerEnter",["pointerout","pointerover"]);gr("onPointerLeave",["pointerout","pointerover"]);Cs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Cs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Cs("onBeforeInput",["compositionend","keypress","textInput","paste"]);Cs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Cs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Cs("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Qr="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(" "),hm=new Set("cancel close invalid load scroll toggle".split(" ").concat(Qr));function Nc(e,t,s){var r=e.type||"unknown-event";e.currentTarget=s,px(r,t,void 0,e),e.currentTarget=null}function Fp(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var r=e[s],l=r.event;r=r.listeners;e:{var a=void 0;if(t)for(var i=r.length-1;0<=i;i--){var c=r[i],d=c.instance,f=c.currentTarget;if(c=c.listener,d!==a&&l.isPropagationStopped())break e;Nc(l,c,f),a=d}else for(i=0;i<r.length;i++){if(c=r[i],d=c.instance,f=c.currentTarget,c=c.listener,d!==a&&l.isPropagationStopped())break e;Nc(l,c,f),a=d}}}if(xa)throw e=ro,xa=!1,ro=null,e}function _e(e,t){var s=t[go];s===void 0&&(s=t[go]=new Set);var r=e+"__bubble";s.has(r)||(Mp(t,e,2,!1),s.add(r))}function Ti(e,t,s){var r=0;t&&(r|=4),Mp(s,e,r,t)}var Fl="_reactListening"+Math.random().toString(36).slice(2);function pl(e){if(!e[Fl]){e[Fl]=!0,qu.forEach(function(s){s!=="selectionchange"&&(hm.has(s)||Ti(s,!1,e),Ti(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Fl]||(t[Fl]=!0,Ti("selectionchange",!1,t))}}function Mp(e,t,s,r){switch(Cp(t)){case 1:var l=Tx;break;case 4:l=Ix;break;default:l=Vo}s=l.bind(null,t,s,e),l=void 0,!so||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(l=!0),r?l!==void 0?e.addEventListener(t,s,{capture:!0,passive:l}):e.addEventListener(t,s,!0):l!==void 0?e.addEventListener(t,s,{passive:l}):e.addEventListener(t,s,!1)}function Ii(e,t,s,r,l){var a=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var i=r.tag;if(i===3||i===4){var c=r.stateNode.containerInfo;if(c===l||c.nodeType===8&&c.parentNode===l)break;if(i===4)for(i=r.return;i!==null;){var d=i.tag;if((d===3||d===4)&&(d=i.stateNode.containerInfo,d===l||d.nodeType===8&&d.parentNode===l))return;i=i.return}for(;c!==null;){if(i=gs(c),i===null)return;if(d=i.tag,d===5||d===6){r=a=i;continue e}c=c.parentNode}}r=r.return}pp(function(){var f=a,v=Xo(s),p=[];e:{var u=Up.get(e);if(u!==void 0){var m=td,j=e;switch(e){case"keypress":if(la(s)===0)break e;case"keydown":case"keyup":m=Hx;break;case"focusin":j="focus",m=Si;break;case"focusout":j="blur",m=Si;break;case"beforeblur":case"afterblur":m=Si;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":m=kc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=Ax;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=Qx;break;case Np:case Wp:case Bp:m=Lx;break;case $p:m=Xx;break;case"scroll":m=Ex;break;case"wheel":m=Jx;break;case"copy":case"cut":case"paste":m=Nx;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=zc}var h=(t&4)!==0,S=!h&&e==="scroll",g=h?u!==null?u+"Capture":null:u;h=[];for(var x=f,o;x!==null;){o=x;var y=o.stateNode;if(o.tag===5&&y!==null&&(o=y,g!==null&&(y=al(x,g),y!=null&&h.push(fl(x,y,o)))),S)break;x=x.return}0<h.length&&(u=new m(u,j,null,s,v),p.push({event:u,listeners:h}))}}if(!(t&7)){e:{if(u=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",u&&s!==to&&(j=s.relatedTarget||s.fromElement)&&(gs(j)||j[wn]))break e;if((m||u)&&(u=v.window===v?v:(u=v.ownerDocument)?u.defaultView||u.parentWindow:window,m?(j=s.relatedTarget||s.toElement,m=f,j=j?gs(j):null,j!==null&&(S=zs(j),j!==S||j.tag!==5&&j.tag!==6)&&(j=null)):(m=null,j=f),m!==j)){if(h=kc,y="onMouseLeave",g="onMouseEnter",x="mouse",(e==="pointerout"||e==="pointerover")&&(h=zc,y="onPointerLeave",g="onPointerEnter",x="pointer"),S=m==null?u:tr(m),o=j==null?u:tr(j),u=new h(y,x+"leave",m,s,v),u.target=S,u.relatedTarget=o,y=null,gs(v)===f&&(h=new h(g,x+"enter",j,s,v),h.target=o,h.relatedTarget=S,y=h),S=y,m&&j)t:{for(h=m,g=j,x=0,o=h;o;o=$s(o))x++;for(o=0,y=g;y;y=$s(y))o++;for(;0<x-o;)h=$s(h),x--;for(;0<o-x;)g=$s(g),o--;for(;x--;){if(h===g||g!==null&&h===g.alternate)break t;h=$s(h),g=$s(g)}h=null}else h=null;m!==null&&Wc(p,u,m,h,!1),j!==null&&S!==null&&Wc(p,S,j,h,!0)}}e:{if(u=f?tr(f):window,m=u.nodeName&&u.nodeName.toLowerCase(),m==="select"||m==="input"&&u.type==="file")var _=rm;else if(Ec(u))if(Ap)_=om;else{_=am;var C=lm}else(m=u.nodeName)&&m.toLowerCase()==="input"&&(u.type==="checkbox"||u.type==="radio")&&(_=im);if(_&&(_=_(e,f))){Pp(p,_,s,v);break e}C&&C(e,u,f),e==="focusout"&&(C=u._wrapperState)&&C.controlled&&u.type==="number"&&qi(u,"number",u.value)}switch(C=f?tr(f):window,e){case"focusin":(Ec(C)||C.contentEditable==="true")&&(Vs=C,oo=f,Vr=null);break;case"focusout":Vr=oo=Vs=null;break;case"mousedown":co=!0;break;case"contextmenu":case"mouseup":case"dragend":co=!1,Lc(p,s,v);break;case"selectionchange":if(um)break;case"keydown":case"keyup":Lc(p,s,v)}var P;if(sd)e:{switch(e){case"compositionstart":var k="onCompositionStart";break e;case"compositionend":k="onCompositionEnd";break e;case"compositionupdate":k="onCompositionUpdate";break e}k=void 0}else Zs?Ip(e,s)&&(k="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(k="onCompositionStart");k&&(Tp&&s.locale!=="ko"&&(Zs||k!=="onCompositionStart"?k==="onCompositionEnd"&&Zs&&(P=zp()):(Ln=v,ed="value"in Ln?Ln.value:Ln.textContent,Zs=!0)),C=ba(f,k),0<C.length&&(k=new Cc(k,e,null,s,v),p.push({event:k,listeners:C}),P?k.data=P:(P=Ep(s),P!==null&&(k.data=P)))),(P=Vx?em(e,s):tm(e,s))&&(f=ba(f,"onBeforeInput"),0<f.length&&(v=new Cc("onBeforeInput","beforeinput",null,s,v),p.push({event:v,listeners:f}),v.data=P))}Fp(p,t)})}function fl(e,t,s){return{instance:e,listener:t,currentTarget:s}}function ba(e,t){for(var s=t+"Capture",r=[];e!==null;){var l=e,a=l.stateNode;l.tag===5&&a!==null&&(l=a,a=al(e,s),a!=null&&r.unshift(fl(e,a,l)),a=al(e,t),a!=null&&r.push(fl(e,a,l))),e=e.return}return r}function $s(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Wc(e,t,s,r,l){for(var a=t._reactName,i=[];s!==null&&s!==r;){var c=s,d=c.alternate,f=c.stateNode;if(d!==null&&d===r)break;c.tag===5&&f!==null&&(c=f,l?(d=al(s,a),d!=null&&i.unshift(fl(s,d,c))):l||(d=al(s,a),d!=null&&i.push(fl(s,d,c)))),s=s.return}i.length!==0&&e.push({event:t,listeners:i})}var gm=/\r\n?/g,xm=/\u0000|\uFFFD/g;function Bc(e){return(typeof e=="string"?e:""+e).replace(gm,`
|
||
`).replace(xm,"")}function Ml(e,t,s){if(t=Bc(t),Bc(e)!==t&&s)throw Error(G(425))}function Sa(){}var uo=null,po=null;function fo(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var ho=typeof setTimeout=="function"?setTimeout:void 0,mm=typeof clearTimeout=="function"?clearTimeout:void 0,$c=typeof Promise=="function"?Promise:void 0,ym=typeof queueMicrotask=="function"?queueMicrotask:typeof $c<"u"?function(e){return $c.resolve(null).then(e).catch(vm)}:ho;function vm(e){setTimeout(function(){throw e})}function Ei(e,t){var s=t,r=0;do{var l=s.nextSibling;if(e.removeChild(s),l&&l.nodeType===8)if(s=l.data,s==="/$"){if(r===0){e.removeChild(l),dl(t);return}r--}else s!=="$"&&s!=="$?"&&s!=="$!"||r++;s=l}while(s);dl(t)}function Fn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function Uc(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"){if(t===0)return e;t--}else s==="/$"&&t++}e=e.previousSibling}return null}var Cr=Math.random().toString(36).slice(2),ln="__reactFiber$"+Cr,hl="__reactProps$"+Cr,wn="__reactContainer$"+Cr,go="__reactEvents$"+Cr,jm="__reactListeners$"+Cr,bm="__reactHandles$"+Cr;function gs(e){var t=e[ln];if(t)return t;for(var s=e.parentNode;s;){if(t=s[wn]||s[ln]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=Uc(e);e!==null;){if(s=e[ln])return s;e=Uc(e)}return t}e=s,s=e.parentNode}return null}function kl(e){return e=e[ln]||e[wn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function tr(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(G(33))}function Ga(e){return e[hl]||null}var xo=[],nr=-1;function Jn(e){return{current:e}}function ke(e){0>nr||(e.current=xo[nr],xo[nr]=null,nr--)}function Se(e,t){nr++,xo[nr]=e.current,e.current=t}var Yn={},ft=Jn(Yn),wt=Jn(!1),js=Yn;function xr(e,t){var s=e.type.contextTypes;if(!s)return Yn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},a;for(a in s)l[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function _t(e){return e=e.childContextTypes,e!=null}function wa(){ke(wt),ke(ft)}function Fc(e,t,s){if(ft.current!==Yn)throw Error(G(168));Se(ft,t),Se(wt,s)}function Hp(e,t,s){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return s;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(G(108,lx(e)||"Unknown",l));return Le({},s,r)}function _a(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Yn,js=ft.current,Se(ft,e),Se(wt,wt.current),!0}function Mc(e,t,s){var r=e.stateNode;if(!r)throw Error(G(169));s?(e=Hp(e,t,js),r.__reactInternalMemoizedMergedChildContext=e,ke(wt),ke(ft),Se(ft,e)):ke(wt),Se(wt,s)}var yn=null,Ka=!1,Pi=!1;function Gp(e){yn===null?yn=[e]:yn.push(e)}function Sm(e){Ka=!0,Gp(e)}function Zn(){if(!Pi&&yn!==null){Pi=!0;var e=0,t=ye;try{var s=yn;for(ye=1;e<s.length;e++){var r=s[e];do r=r(!0);while(r!==null)}yn=null,Ka=!1}catch(l){throw yn!==null&&(yn=yn.slice(e+1)),xp(qo,Zn),l}finally{ye=t,Pi=!1}}return null}var sr=[],rr=0,ka=null,Ca=0,Lt=[],Ot=0,bs=null,vn=1,jn="";function fs(e,t){sr[rr++]=Ca,sr[rr++]=ka,ka=e,Ca=t}function Kp(e,t,s){Lt[Ot++]=vn,Lt[Ot++]=jn,Lt[Ot++]=bs,bs=e;var r=vn;e=jn;var l=32-Yt(r)-1;r&=~(1<<l),s+=1;var a=32-Yt(t)+l;if(30<a){var i=l-l%5;a=(r&(1<<i)-1).toString(32),r>>=i,l-=i,vn=1<<32-Yt(t)+l|s<<l|r,jn=a+e}else vn=1<<a|s<<l|r,jn=e}function ld(e){e.return!==null&&(fs(e,1),Kp(e,1,0))}function ad(e){for(;e===ka;)ka=sr[--rr],sr[rr]=null,Ca=sr[--rr],sr[rr]=null;for(;e===bs;)bs=Lt[--Ot],Lt[Ot]=null,jn=Lt[--Ot],Lt[Ot]=null,vn=Lt[--Ot],Lt[Ot]=null}var Pt=null,Et=null,Pe=!1,Kt=null;function Qp(e,t){var s=Nt(5,null,null,0);s.elementType="DELETED",s.stateNode=t,s.return=e,t=e.deletions,t===null?(e.deletions=[s],e.flags|=16):t.push(s)}function Hc(e,t){switch(e.tag){case 5:var s=e.type;return t=t.nodeType!==1||s.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,Pt=e,Et=Fn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,Pt=e,Et=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(s=bs!==null?{id:vn,overflow:jn}:null,e.memoizedState={dehydrated:t,treeContext:s,retryLane:1073741824},s=Nt(18,null,null,0),s.stateNode=t,s.return=e,e.child=s,Pt=e,Et=null,!0):!1;default:return!1}}function mo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function yo(e){if(Pe){var t=Et;if(t){var s=t;if(!Hc(e,t)){if(mo(e))throw Error(G(418));t=Fn(s.nextSibling);var r=Pt;t&&Hc(e,t)?Qp(r,s):(e.flags=e.flags&-4097|2,Pe=!1,Pt=e)}}else{if(mo(e))throw Error(G(418));e.flags=e.flags&-4097|2,Pe=!1,Pt=e}}}function Gc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Pt=e}function Hl(e){if(e!==Pt)return!1;if(!Pe)return Gc(e),Pe=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!fo(e.type,e.memoizedProps)),t&&(t=Et)){if(mo(e))throw Yp(),Error(G(418));for(;t;)Qp(e,t),t=Fn(t.nextSibling)}if(Gc(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(G(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"){if(t===0){Et=Fn(e.nextSibling);break e}t--}else s!=="$"&&s!=="$!"&&s!=="$?"||t++}e=e.nextSibling}Et=null}}else Et=Pt?Fn(e.stateNode.nextSibling):null;return!0}function Yp(){for(var e=Et;e;)e=Fn(e.nextSibling)}function mr(){Et=Pt=null,Pe=!1}function id(e){Kt===null?Kt=[e]:Kt.push(e)}var wm=Cn.ReactCurrentBatchConfig;function Nr(e,t,s){if(e=s.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(s._owner){if(s=s._owner,s){if(s.tag!==1)throw Error(G(309));var r=s.stateNode}if(!r)throw Error(G(147,e));var l=r,a=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===a?t.ref:(t=function(i){var c=l.refs;i===null?delete c[a]:c[a]=i},t._stringRef=a,t)}if(typeof e!="string")throw Error(G(284));if(!s._owner)throw Error(G(290,e))}return e}function Gl(e,t){throw e=Object.prototype.toString.call(t),Error(G(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Kc(e){var t=e._init;return t(e._payload)}function Xp(e){function t(g,x){if(e){var o=g.deletions;o===null?(g.deletions=[x],g.flags|=16):o.push(x)}}function s(g,x){if(!e)return null;for(;x!==null;)t(g,x),x=x.sibling;return null}function r(g,x){for(g=new Map;x!==null;)x.key!==null?g.set(x.key,x):g.set(x.index,x),x=x.sibling;return g}function l(g,x){return g=Kn(g,x),g.index=0,g.sibling=null,g}function a(g,x,o){return g.index=o,e?(o=g.alternate,o!==null?(o=o.index,o<x?(g.flags|=2,x):o):(g.flags|=2,x)):(g.flags|=1048576,x)}function i(g){return e&&g.alternate===null&&(g.flags|=2),g}function c(g,x,o,y){return x===null||x.tag!==6?(x=Wi(o,g.mode,y),x.return=g,x):(x=l(x,o),x.return=g,x)}function d(g,x,o,y){var _=o.type;return _===Js?v(g,x,o.props.children,y,o.key):x!==null&&(x.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===Pn&&Kc(_)===x.type)?(y=l(x,o.props),y.ref=Nr(g,x,o),y.return=g,y):(y=pa(o.type,o.key,o.props,null,g.mode,y),y.ref=Nr(g,x,o),y.return=g,y)}function f(g,x,o,y){return x===null||x.tag!==4||x.stateNode.containerInfo!==o.containerInfo||x.stateNode.implementation!==o.implementation?(x=Bi(o,g.mode,y),x.return=g,x):(x=l(x,o.children||[]),x.return=g,x)}function v(g,x,o,y,_){return x===null||x.tag!==7?(x=vs(o,g.mode,y,_),x.return=g,x):(x=l(x,o),x.return=g,x)}function p(g,x,o){if(typeof x=="string"&&x!==""||typeof x=="number")return x=Wi(""+x,g.mode,o),x.return=g,x;if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Dl:return o=pa(x.type,x.key,x.props,null,g.mode,o),o.ref=Nr(g,null,x),o.return=g,o;case qs:return x=Bi(x,g.mode,o),x.return=g,x;case Pn:var y=x._init;return p(g,y(x._payload),o)}if(Gr(x)||Ar(x))return x=vs(x,g.mode,o,null),x.return=g,x;Gl(g,x)}return null}function u(g,x,o,y){var _=x!==null?x.key:null;if(typeof o=="string"&&o!==""||typeof o=="number")return _!==null?null:c(g,x,""+o,y);if(typeof o=="object"&&o!==null){switch(o.$$typeof){case Dl:return o.key===_?d(g,x,o,y):null;case qs:return o.key===_?f(g,x,o,y):null;case Pn:return _=o._init,u(g,x,_(o._payload),y)}if(Gr(o)||Ar(o))return _!==null?null:v(g,x,o,y,null);Gl(g,o)}return null}function m(g,x,o,y,_){if(typeof y=="string"&&y!==""||typeof y=="number")return g=g.get(o)||null,c(x,g,""+y,_);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Dl:return g=g.get(y.key===null?o:y.key)||null,d(x,g,y,_);case qs:return g=g.get(y.key===null?o:y.key)||null,f(x,g,y,_);case Pn:var C=y._init;return m(g,x,o,C(y._payload),_)}if(Gr(y)||Ar(y))return g=g.get(o)||null,v(x,g,y,_,null);Gl(x,y)}return null}function j(g,x,o,y){for(var _=null,C=null,P=x,k=x=0,R=null;P!==null&&k<o.length;k++){P.index>k?(R=P,P=null):R=P.sibling;var $=u(g,P,o[k],y);if($===null){P===null&&(P=R);break}e&&P&&$.alternate===null&&t(g,P),x=a($,x,k),C===null?_=$:C.sibling=$,C=$,P=R}if(k===o.length)return s(g,P),Pe&&fs(g,k),_;if(P===null){for(;k<o.length;k++)P=p(g,o[k],y),P!==null&&(x=a(P,x,k),C===null?_=P:C.sibling=P,C=P);return Pe&&fs(g,k),_}for(P=r(g,P);k<o.length;k++)R=m(P,g,k,o[k],y),R!==null&&(e&&R.alternate!==null&&P.delete(R.key===null?k:R.key),x=a(R,x,k),C===null?_=R:C.sibling=R,C=R);return e&&P.forEach(function(Z){return t(g,Z)}),Pe&&fs(g,k),_}function h(g,x,o,y){var _=Ar(o);if(typeof _!="function")throw Error(G(150));if(o=_.call(o),o==null)throw Error(G(151));for(var C=_=null,P=x,k=x=0,R=null,$=o.next();P!==null&&!$.done;k++,$=o.next()){P.index>k?(R=P,P=null):R=P.sibling;var Z=u(g,P,$.value,y);if(Z===null){P===null&&(P=R);break}e&&P&&Z.alternate===null&&t(g,P),x=a(Z,x,k),C===null?_=Z:C.sibling=Z,C=Z,P=R}if($.done)return s(g,P),Pe&&fs(g,k),_;if(P===null){for(;!$.done;k++,$=o.next())$=p(g,$.value,y),$!==null&&(x=a($,x,k),C===null?_=$:C.sibling=$,C=$);return Pe&&fs(g,k),_}for(P=r(g,P);!$.done;k++,$=o.next())$=m(P,g,k,$.value,y),$!==null&&(e&&$.alternate!==null&&P.delete($.key===null?k:$.key),x=a($,x,k),C===null?_=$:C.sibling=$,C=$);return e&&P.forEach(function(de){return t(g,de)}),Pe&&fs(g,k),_}function S(g,x,o,y){if(typeof o=="object"&&o!==null&&o.type===Js&&o.key===null&&(o=o.props.children),typeof o=="object"&&o!==null){switch(o.$$typeof){case Dl:e:{for(var _=o.key,C=x;C!==null;){if(C.key===_){if(_=o.type,_===Js){if(C.tag===7){s(g,C.sibling),x=l(C,o.props.children),x.return=g,g=x;break e}}else if(C.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===Pn&&Kc(_)===C.type){s(g,C.sibling),x=l(C,o.props),x.ref=Nr(g,C,o),x.return=g,g=x;break e}s(g,C);break}else t(g,C);C=C.sibling}o.type===Js?(x=vs(o.props.children,g.mode,y,o.key),x.return=g,g=x):(y=pa(o.type,o.key,o.props,null,g.mode,y),y.ref=Nr(g,x,o),y.return=g,g=y)}return i(g);case qs:e:{for(C=o.key;x!==null;){if(x.key===C)if(x.tag===4&&x.stateNode.containerInfo===o.containerInfo&&x.stateNode.implementation===o.implementation){s(g,x.sibling),x=l(x,o.children||[]),x.return=g,g=x;break e}else{s(g,x);break}else t(g,x);x=x.sibling}x=Bi(o,g.mode,y),x.return=g,g=x}return i(g);case Pn:return C=o._init,S(g,x,C(o._payload),y)}if(Gr(o))return j(g,x,o,y);if(Ar(o))return h(g,x,o,y);Gl(g,o)}return typeof o=="string"&&o!==""||typeof o=="number"?(o=""+o,x!==null&&x.tag===6?(s(g,x.sibling),x=l(x,o),x.return=g,g=x):(s(g,x),x=Wi(o,g.mode,y),x.return=g,g=x),i(g)):s(g,x)}return S}var yr=Xp(!0),qp=Xp(!1),za=Jn(null),Ta=null,lr=null,od=null;function dd(){od=lr=Ta=null}function cd(e){var t=za.current;ke(za),e._currentValue=t}function vo(e,t,s){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===s)break;e=e.return}}function fr(e,t){Ta=e,od=lr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(St=!0),e.firstContext=null)}function Bt(e){var t=e._currentValue;if(od!==e)if(e={context:e,memoizedValue:t,next:null},lr===null){if(Ta===null)throw Error(G(308));lr=e,Ta.dependencies={lanes:0,firstContext:e}}else lr=lr.next=e;return t}var xs=null;function ud(e){xs===null?xs=[e]:xs.push(e)}function Jp(e,t,s,r){var l=t.interleaved;return l===null?(s.next=s,ud(t)):(s.next=l.next,l.next=s),t.interleaved=s,_n(e,r)}function _n(e,t){e.lanes|=t;var s=e.alternate;for(s!==null&&(s.lanes|=t),s=e,e=e.return;e!==null;)e.childLanes|=t,s=e.alternate,s!==null&&(s.childLanes|=t),s=e,e=e.return;return s.tag===3?s.stateNode:null}var An=!1;function pd(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Zp(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function bn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Mn(e,t,s){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,he&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,_n(e,s)}return l=r.interleaved,l===null?(t.next=t,ud(r)):(t.next=l.next,l.next=t),r.interleaved=t,_n(e,s)}function aa(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,s|=r,t.lanes=s,Jo(e,s)}}function Qc(e,t){var s=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,s===r)){var l=null,a=null;if(s=s.firstBaseUpdate,s!==null){do{var i={eventTime:s.eventTime,lane:s.lane,tag:s.tag,payload:s.payload,callback:s.callback,next:null};a===null?l=a=i:a=a.next=i,s=s.next}while(s!==null);a===null?l=a=t:a=a.next=t}else l=a=t;s={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}function Ia(e,t,s,r){var l=e.updateQueue;An=!1;var a=l.firstBaseUpdate,i=l.lastBaseUpdate,c=l.shared.pending;if(c!==null){l.shared.pending=null;var d=c,f=d.next;d.next=null,i===null?a=f:i.next=f,i=d;var v=e.alternate;v!==null&&(v=v.updateQueue,c=v.lastBaseUpdate,c!==i&&(c===null?v.firstBaseUpdate=f:c.next=f,v.lastBaseUpdate=d))}if(a!==null){var p=l.baseState;i=0,v=f=d=null,c=a;do{var u=c.lane,m=c.eventTime;if((r&u)===u){v!==null&&(v=v.next={eventTime:m,lane:0,tag:c.tag,payload:c.payload,callback:c.callback,next:null});e:{var j=e,h=c;switch(u=t,m=s,h.tag){case 1:if(j=h.payload,typeof j=="function"){p=j.call(m,p,u);break e}p=j;break e;case 3:j.flags=j.flags&-65537|128;case 0:if(j=h.payload,u=typeof j=="function"?j.call(m,p,u):j,u==null)break e;p=Le({},p,u);break e;case 2:An=!0}}c.callback!==null&&c.lane!==0&&(e.flags|=64,u=l.effects,u===null?l.effects=[c]:u.push(c))}else m={eventTime:m,lane:u,tag:c.tag,payload:c.payload,callback:c.callback,next:null},v===null?(f=v=m,d=p):v=v.next=m,i|=u;if(c=c.next,c===null){if(c=l.shared.pending,c===null)break;u=c,c=u.next,u.next=null,l.lastBaseUpdate=u,l.shared.pending=null}}while(!0);if(v===null&&(d=p),l.baseState=d,l.firstBaseUpdate=f,l.lastBaseUpdate=v,t=l.shared.interleaved,t!==null){l=t;do i|=l.lane,l=l.next;while(l!==t)}else a===null&&(l.shared.lanes=0);ws|=i,e.lanes=i,e.memoizedState=p}}function Yc(e,t,s){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],l=r.callback;if(l!==null){if(r.callback=null,r=s,typeof l!="function")throw Error(G(191,l));l.call(r)}}}var Cl={},on=Jn(Cl),gl=Jn(Cl),xl=Jn(Cl);function ms(e){if(e===Cl)throw Error(G(174));return e}function fd(e,t){switch(Se(xl,t),Se(gl,e),Se(on,Cl),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Zi(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Zi(t,e)}ke(on),Se(on,t)}function vr(){ke(on),ke(gl),ke(xl)}function Vp(e){ms(xl.current);var t=ms(on.current),s=Zi(t,e.type);t!==s&&(Se(gl,e),Se(on,s))}function hd(e){gl.current===e&&(ke(on),ke(gl))}var Re=Jn(0);function Ea(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||s.data==="$?"||s.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Ai=[];function gd(){for(var e=0;e<Ai.length;e++)Ai[e]._workInProgressVersionPrimary=null;Ai.length=0}var ia=Cn.ReactCurrentDispatcher,Ri=Cn.ReactCurrentBatchConfig,Ss=0,De=null,et=null,st=null,Pa=!1,el=!1,ml=0,_m=0;function ct(){throw Error(G(321))}function xd(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!qt(e[s],t[s]))return!1;return!0}function md(e,t,s,r,l,a){if(Ss=a,De=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,ia.current=e===null||e.memoizedState===null?Tm:Im,e=s(r,l),el){a=0;do{if(el=!1,ml=0,25<=a)throw Error(G(301));a+=1,st=et=null,t.updateQueue=null,ia.current=Em,e=s(r,l)}while(el)}if(ia.current=Aa,t=et!==null&&et.next!==null,Ss=0,st=et=De=null,Pa=!1,t)throw Error(G(300));return e}function yd(){var e=ml!==0;return ml=0,e}function rn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return st===null?De.memoizedState=st=e:st=st.next=e,st}function $t(){if(et===null){var e=De.alternate;e=e!==null?e.memoizedState:null}else e=et.next;var t=st===null?De.memoizedState:st.next;if(t!==null)st=t,et=e;else{if(e===null)throw Error(G(310));et=e,e={memoizedState:et.memoizedState,baseState:et.baseState,baseQueue:et.baseQueue,queue:et.queue,next:null},st===null?De.memoizedState=st=e:st=st.next=e}return st}function yl(e,t){return typeof t=="function"?t(e):t}function Di(e){var t=$t(),s=t.queue;if(s===null)throw Error(G(311));s.lastRenderedReducer=e;var r=et,l=r.baseQueue,a=s.pending;if(a!==null){if(l!==null){var i=l.next;l.next=a.next,a.next=i}r.baseQueue=l=a,s.pending=null}if(l!==null){a=l.next,r=r.baseState;var c=i=null,d=null,f=a;do{var v=f.lane;if((Ss&v)===v)d!==null&&(d=d.next={lane:0,action:f.action,hasEagerState:f.hasEagerState,eagerState:f.eagerState,next:null}),r=f.hasEagerState?f.eagerState:e(r,f.action);else{var p={lane:v,action:f.action,hasEagerState:f.hasEagerState,eagerState:f.eagerState,next:null};d===null?(c=d=p,i=r):d=d.next=p,De.lanes|=v,ws|=v}f=f.next}while(f!==null&&f!==a);d===null?i=r:d.next=c,qt(r,t.memoizedState)||(St=!0),t.memoizedState=r,t.baseState=i,t.baseQueue=d,s.lastRenderedState=r}if(e=s.interleaved,e!==null){l=e;do a=l.lane,De.lanes|=a,ws|=a,l=l.next;while(l!==e)}else l===null&&(s.lanes=0);return[t.memoizedState,s.dispatch]}function Li(e){var t=$t(),s=t.queue;if(s===null)throw Error(G(311));s.lastRenderedReducer=e;var r=s.dispatch,l=s.pending,a=t.memoizedState;if(l!==null){s.pending=null;var i=l=l.next;do a=e(a,i.action),i=i.next;while(i!==l);qt(a,t.memoizedState)||(St=!0),t.memoizedState=a,t.baseQueue===null&&(t.baseState=a),s.lastRenderedState=a}return[a,r]}function ef(){}function tf(e,t){var s=De,r=$t(),l=t(),a=!qt(r.memoizedState,l);if(a&&(r.memoizedState=l,St=!0),r=r.queue,vd(rf.bind(null,s,r,e),[e]),r.getSnapshot!==t||a||st!==null&&st.memoizedState.tag&1){if(s.flags|=2048,vl(9,sf.bind(null,s,r,l,t),void 0,null),rt===null)throw Error(G(349));Ss&30||nf(s,t,l)}return l}function nf(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=De.updateQueue,t===null?(t={lastEffect:null,stores:null},De.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function sf(e,t,s,r){t.value=s,t.getSnapshot=r,lf(t)&&af(e)}function rf(e,t,s){return s(function(){lf(t)&&af(e)})}function lf(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!qt(e,s)}catch{return!0}}function af(e){var t=_n(e,1);t!==null&&Xt(t,e,1,-1)}function Xc(e){var t=rn();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:yl,lastRenderedState:e},t.queue=e,e=e.dispatch=zm.bind(null,De,e),[t.memoizedState,e]}function vl(e,t,s,r){return e={tag:e,create:t,destroy:s,deps:r,next:null},t=De.updateQueue,t===null?(t={lastEffect:null,stores:null},De.updateQueue=t,t.lastEffect=e.next=e):(s=t.lastEffect,s===null?t.lastEffect=e.next=e:(r=s.next,s.next=e,e.next=r,t.lastEffect=e)),e}function of(){return $t().memoizedState}function oa(e,t,s,r){var l=rn();De.flags|=e,l.memoizedState=vl(1|t,s,void 0,r===void 0?null:r)}function Qa(e,t,s,r){var l=$t();r=r===void 0?null:r;var a=void 0;if(et!==null){var i=et.memoizedState;if(a=i.destroy,r!==null&&xd(r,i.deps)){l.memoizedState=vl(t,s,a,r);return}}De.flags|=e,l.memoizedState=vl(1|t,s,a,r)}function qc(e,t){return oa(8390656,8,e,t)}function vd(e,t){return Qa(2048,8,e,t)}function df(e,t){return Qa(4,2,e,t)}function cf(e,t){return Qa(4,4,e,t)}function uf(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function pf(e,t,s){return s=s!=null?s.concat([e]):null,Qa(4,4,uf.bind(null,t,e),s)}function jd(){}function ff(e,t){var s=$t();t=t===void 0?null:t;var r=s.memoizedState;return r!==null&&t!==null&&xd(t,r[1])?r[0]:(s.memoizedState=[e,t],e)}function hf(e,t){var s=$t();t=t===void 0?null:t;var r=s.memoizedState;return r!==null&&t!==null&&xd(t,r[1])?r[0]:(e=e(),s.memoizedState=[e,t],e)}function gf(e,t,s){return Ss&21?(qt(s,t)||(s=vp(),De.lanes|=s,ws|=s,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,St=!0),e.memoizedState=s)}function km(e,t){var s=ye;ye=s!==0&&4>s?s:4,e(!0);var r=Ri.transition;Ri.transition={};try{e(!1),t()}finally{ye=s,Ri.transition=r}}function xf(){return $t().memoizedState}function Cm(e,t,s){var r=Gn(e);if(s={lane:r,action:s,hasEagerState:!1,eagerState:null,next:null},mf(e))yf(t,s);else if(s=Jp(e,t,s,r),s!==null){var l=mt();Xt(s,e,r,l),vf(s,t,r)}}function zm(e,t,s){var r=Gn(e),l={lane:r,action:s,hasEagerState:!1,eagerState:null,next:null};if(mf(e))yf(t,l);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var i=t.lastRenderedState,c=a(i,s);if(l.hasEagerState=!0,l.eagerState=c,qt(c,i)){var d=t.interleaved;d===null?(l.next=l,ud(t)):(l.next=d.next,d.next=l),t.interleaved=l;return}}catch{}finally{}s=Jp(e,t,l,r),s!==null&&(l=mt(),Xt(s,e,r,l),vf(s,t,r))}}function mf(e){var t=e.alternate;return e===De||t!==null&&t===De}function yf(e,t){el=Pa=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function vf(e,t,s){if(s&4194240){var r=t.lanes;r&=e.pendingLanes,s|=r,t.lanes=s,Jo(e,s)}}var Aa={readContext:Bt,useCallback:ct,useContext:ct,useEffect:ct,useImperativeHandle:ct,useInsertionEffect:ct,useLayoutEffect:ct,useMemo:ct,useReducer:ct,useRef:ct,useState:ct,useDebugValue:ct,useDeferredValue:ct,useTransition:ct,useMutableSource:ct,useSyncExternalStore:ct,useId:ct,unstable_isNewReconciler:!1},Tm={readContext:Bt,useCallback:function(e,t){return rn().memoizedState=[e,t===void 0?null:t],e},useContext:Bt,useEffect:qc,useImperativeHandle:function(e,t,s){return s=s!=null?s.concat([e]):null,oa(4194308,4,uf.bind(null,t,e),s)},useLayoutEffect:function(e,t){return oa(4194308,4,e,t)},useInsertionEffect:function(e,t){return oa(4,2,e,t)},useMemo:function(e,t){var s=rn();return t=t===void 0?null:t,e=e(),s.memoizedState=[e,t],e},useReducer:function(e,t,s){var r=rn();return t=s!==void 0?s(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Cm.bind(null,De,e),[r.memoizedState,e]},useRef:function(e){var t=rn();return e={current:e},t.memoizedState=e},useState:Xc,useDebugValue:jd,useDeferredValue:function(e){return rn().memoizedState=e},useTransition:function(){var e=Xc(!1),t=e[0];return e=km.bind(null,e[1]),rn().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,s){var r=De,l=rn();if(Pe){if(s===void 0)throw Error(G(407));s=s()}else{if(s=t(),rt===null)throw Error(G(349));Ss&30||nf(r,t,s)}l.memoizedState=s;var a={value:s,getSnapshot:t};return l.queue=a,qc(rf.bind(null,r,a,e),[e]),r.flags|=2048,vl(9,sf.bind(null,r,a,s,t),void 0,null),s},useId:function(){var e=rn(),t=rt.identifierPrefix;if(Pe){var s=jn,r=vn;s=(r&~(1<<32-Yt(r)-1)).toString(32)+s,t=":"+t+"R"+s,s=ml++,0<s&&(t+="H"+s.toString(32)),t+=":"}else s=_m++,t=":"+t+"r"+s.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Im={readContext:Bt,useCallback:ff,useContext:Bt,useEffect:vd,useImperativeHandle:pf,useInsertionEffect:df,useLayoutEffect:cf,useMemo:hf,useReducer:Di,useRef:of,useState:function(){return Di(yl)},useDebugValue:jd,useDeferredValue:function(e){var t=$t();return gf(t,et.memoizedState,e)},useTransition:function(){var e=Di(yl)[0],t=$t().memoizedState;return[e,t]},useMutableSource:ef,useSyncExternalStore:tf,useId:xf,unstable_isNewReconciler:!1},Em={readContext:Bt,useCallback:ff,useContext:Bt,useEffect:vd,useImperativeHandle:pf,useInsertionEffect:df,useLayoutEffect:cf,useMemo:hf,useReducer:Li,useRef:of,useState:function(){return Li(yl)},useDebugValue:jd,useDeferredValue:function(e){var t=$t();return et===null?t.memoizedState=e:gf(t,et.memoizedState,e)},useTransition:function(){var e=Li(yl)[0],t=$t().memoizedState;return[e,t]},useMutableSource:ef,useSyncExternalStore:tf,useId:xf,unstable_isNewReconciler:!1};function Ht(e,t){if(e&&e.defaultProps){t=Le({},t),e=e.defaultProps;for(var s in e)t[s]===void 0&&(t[s]=e[s]);return t}return t}function jo(e,t,s,r){t=e.memoizedState,s=s(r,t),s=s==null?t:Le({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var Ya={isMounted:function(e){return(e=e._reactInternals)?zs(e)===e:!1},enqueueSetState:function(e,t,s){e=e._reactInternals;var r=mt(),l=Gn(e),a=bn(r,l);a.payload=t,s!=null&&(a.callback=s),t=Mn(e,a,l),t!==null&&(Xt(t,e,l,r),aa(t,e,l))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var r=mt(),l=Gn(e),a=bn(r,l);a.tag=1,a.payload=t,s!=null&&(a.callback=s),t=Mn(e,a,l),t!==null&&(Xt(t,e,l,r),aa(t,e,l))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=mt(),r=Gn(e),l=bn(s,r);l.tag=2,t!=null&&(l.callback=t),t=Mn(e,l,r),t!==null&&(Xt(t,e,r,s),aa(t,e,r))}};function Jc(e,t,s,r,l,a,i){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,a,i):t.prototype&&t.prototype.isPureReactComponent?!ul(s,r)||!ul(l,a):!0}function jf(e,t,s){var r=!1,l=Yn,a=t.contextType;return typeof a=="object"&&a!==null?a=Bt(a):(l=_t(t)?js:ft.current,r=t.contextTypes,a=(r=r!=null)?xr(e,l):Yn),t=new t(s,a),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ya,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=l,e.__reactInternalMemoizedMaskedChildContext=a),t}function Zc(e,t,s,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,r),t.state!==e&&Ya.enqueueReplaceState(t,t.state,null)}function bo(e,t,s,r){var l=e.stateNode;l.props=s,l.state=e.memoizedState,l.refs={},pd(e);var a=t.contextType;typeof a=="object"&&a!==null?l.context=Bt(a):(a=_t(t)?js:ft.current,l.context=xr(e,a)),l.state=e.memoizedState,a=t.getDerivedStateFromProps,typeof a=="function"&&(jo(e,t,a,s),l.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof l.getSnapshotBeforeUpdate=="function"||typeof l.UNSAFE_componentWillMount!="function"&&typeof l.componentWillMount!="function"||(t=l.state,typeof l.componentWillMount=="function"&&l.componentWillMount(),typeof l.UNSAFE_componentWillMount=="function"&&l.UNSAFE_componentWillMount(),t!==l.state&&Ya.enqueueReplaceState(l,l.state,null),Ia(e,s,l,r),l.state=e.memoizedState),typeof l.componentDidMount=="function"&&(e.flags|=4194308)}function jr(e,t){try{var s="",r=t;do s+=rx(r),r=r.return;while(r);var l=s}catch(a){l=`
|
||
Error generating stack: `+a.message+`
|
||
`+a.stack}return{value:e,source:t,stack:l,digest:null}}function Oi(e,t,s){return{value:e,source:null,stack:s??null,digest:t??null}}function So(e,t){try{console.error(t.value)}catch(s){setTimeout(function(){throw s})}}var Pm=typeof WeakMap=="function"?WeakMap:Map;function bf(e,t,s){s=bn(-1,s),s.tag=3,s.payload={element:null};var r=t.value;return s.callback=function(){Da||(Da=!0,Ao=r),So(e,t)},s}function Sf(e,t,s){s=bn(-1,s),s.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var l=t.value;s.payload=function(){return r(l)},s.callback=function(){So(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch=="function"&&(s.callback=function(){So(e,t),typeof r!="function"&&(Hn===null?Hn=new Set([this]):Hn.add(this));var i=t.stack;this.componentDidCatch(t.value,{componentStack:i!==null?i:""})}),s}function Vc(e,t,s){var r=e.pingCache;if(r===null){r=e.pingCache=new Pm;var l=new Set;r.set(t,l)}else l=r.get(t),l===void 0&&(l=new Set,r.set(t,l));l.has(s)||(l.add(s),e=Gm.bind(null,e,t,s),t.then(e,e))}function eu(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function tu(e,t,s,r,l){return e.mode&1?(e.flags|=65536,e.lanes=l,e):(e===t?e.flags|=65536:(e.flags|=128,s.flags|=131072,s.flags&=-52805,s.tag===1&&(s.alternate===null?s.tag=17:(t=bn(-1,1),t.tag=2,Mn(s,t,1))),s.lanes|=1),e)}var Am=Cn.ReactCurrentOwner,St=!1;function xt(e,t,s,r){t.child=e===null?qp(t,null,s,r):yr(t,e.child,s,r)}function nu(e,t,s,r,l){s=s.render;var a=t.ref;return fr(t,l),r=md(e,t,s,r,a,l),s=yd(),e!==null&&!St?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,kn(e,t,l)):(Pe&&s&&ld(t),t.flags|=1,xt(e,t,r,l),t.child)}function su(e,t,s,r,l){if(e===null){var a=s.type;return typeof a=="function"&&!Td(a)&&a.defaultProps===void 0&&s.compare===null&&s.defaultProps===void 0?(t.tag=15,t.type=a,wf(e,t,a,r,l)):(e=pa(s.type,null,r,t,t.mode,l),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!(e.lanes&l)){var i=a.memoizedProps;if(s=s.compare,s=s!==null?s:ul,s(i,r)&&e.ref===t.ref)return kn(e,t,l)}return t.flags|=1,e=Kn(a,r),e.ref=t.ref,e.return=t,t.child=e}function wf(e,t,s,r,l){if(e!==null){var a=e.memoizedProps;if(ul(a,r)&&e.ref===t.ref)if(St=!1,t.pendingProps=r=a,(e.lanes&l)!==0)e.flags&131072&&(St=!0);else return t.lanes=e.lanes,kn(e,t,l)}return wo(e,t,s,r,l)}function _f(e,t,s){var r=t.pendingProps,l=r.children,a=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Se(ir,It),It|=s;else{if(!(s&1073741824))return e=a!==null?a.baseLanes|s:s,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Se(ir,It),It|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a!==null?a.baseLanes:s,Se(ir,It),It|=r}else a!==null?(r=a.baseLanes|s,t.memoizedState=null):r=s,Se(ir,It),It|=r;return xt(e,t,l,s),t.child}function kf(e,t){var s=t.ref;(e===null&&s!==null||e!==null&&e.ref!==s)&&(t.flags|=512,t.flags|=2097152)}function wo(e,t,s,r,l){var a=_t(s)?js:ft.current;return a=xr(t,a),fr(t,l),s=md(e,t,s,r,a,l),r=yd(),e!==null&&!St?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,kn(e,t,l)):(Pe&&r&&ld(t),t.flags|=1,xt(e,t,s,l),t.child)}function ru(e,t,s,r,l){if(_t(s)){var a=!0;_a(t)}else a=!1;if(fr(t,l),t.stateNode===null)da(e,t),jf(t,s,r),bo(t,s,r,l),r=!0;else if(e===null){var i=t.stateNode,c=t.memoizedProps;i.props=c;var d=i.context,f=s.contextType;typeof f=="object"&&f!==null?f=Bt(f):(f=_t(s)?js:ft.current,f=xr(t,f));var v=s.getDerivedStateFromProps,p=typeof v=="function"||typeof i.getSnapshotBeforeUpdate=="function";p||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(c!==r||d!==f)&&Zc(t,i,r,f),An=!1;var u=t.memoizedState;i.state=u,Ia(t,r,i,l),d=t.memoizedState,c!==r||u!==d||wt.current||An?(typeof v=="function"&&(jo(t,s,v,r),d=t.memoizedState),(c=An||Jc(t,s,c,r,u,d,f))?(p||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount()),typeof i.componentDidMount=="function"&&(t.flags|=4194308)):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=d),i.props=r,i.state=d,i.context=f,r=c):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,Zp(e,t),c=t.memoizedProps,f=t.type===t.elementType?c:Ht(t.type,c),i.props=f,p=t.pendingProps,u=i.context,d=s.contextType,typeof d=="object"&&d!==null?d=Bt(d):(d=_t(s)?js:ft.current,d=xr(t,d));var m=s.getDerivedStateFromProps;(v=typeof m=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(c!==p||u!==d)&&Zc(t,i,r,d),An=!1,u=t.memoizedState,i.state=u,Ia(t,r,i,l);var j=t.memoizedState;c!==p||u!==j||wt.current||An?(typeof m=="function"&&(jo(t,s,m,r),j=t.memoizedState),(f=An||Jc(t,s,f,r,u,j,d)||!1)?(v||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(r,j,d),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(r,j,d)),typeof i.componentDidUpdate=="function"&&(t.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof i.componentDidUpdate!="function"||c===e.memoizedProps&&u===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||c===e.memoizedProps&&u===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=j),i.props=r,i.state=j,i.context=d,r=f):(typeof i.componentDidUpdate!="function"||c===e.memoizedProps&&u===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||c===e.memoizedProps&&u===e.memoizedState||(t.flags|=1024),r=!1)}return _o(e,t,s,r,a,l)}function _o(e,t,s,r,l,a){kf(e,t);var i=(t.flags&128)!==0;if(!r&&!i)return l&&Mc(t,s,!1),kn(e,t,a);r=t.stateNode,Am.current=t;var c=i&&typeof s.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&i?(t.child=yr(t,e.child,null,a),t.child=yr(t,null,c,a)):xt(e,t,c,a),t.memoizedState=r.state,l&&Mc(t,s,!0),t.child}function Cf(e){var t=e.stateNode;t.pendingContext?Fc(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Fc(e,t.context,!1),fd(e,t.containerInfo)}function lu(e,t,s,r,l){return mr(),id(l),t.flags|=256,xt(e,t,s,r),t.child}var ko={dehydrated:null,treeContext:null,retryLane:0};function Co(e){return{baseLanes:e,cachePool:null,transitions:null}}function zf(e,t,s){var r=t.pendingProps,l=Re.current,a=!1,i=(t.flags&128)!==0,c;if((c=i)||(c=e!==null&&e.memoizedState===null?!1:(l&2)!==0),c?(a=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(l|=1),Se(Re,l&1),e===null)return yo(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(i=r.children,e=r.fallback,a?(r=t.mode,a=t.child,i={mode:"hidden",children:i},!(r&1)&&a!==null?(a.childLanes=0,a.pendingProps=i):a=Ja(i,r,0,null),e=vs(e,r,s,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=Co(s),t.memoizedState=ko,e):bd(t,i));if(l=e.memoizedState,l!==null&&(c=l.dehydrated,c!==null))return Rm(e,t,i,r,c,l,s);if(a){a=r.fallback,i=t.mode,l=e.child,c=l.sibling;var d={mode:"hidden",children:r.children};return!(i&1)&&t.child!==l?(r=t.child,r.childLanes=0,r.pendingProps=d,t.deletions=null):(r=Kn(l,d),r.subtreeFlags=l.subtreeFlags&14680064),c!==null?a=Kn(c,a):(a=vs(a,i,s,null),a.flags|=2),a.return=t,r.return=t,r.sibling=a,t.child=r,r=a,a=t.child,i=e.child.memoizedState,i=i===null?Co(s):{baseLanes:i.baseLanes|s,cachePool:null,transitions:i.transitions},a.memoizedState=i,a.childLanes=e.childLanes&~s,t.memoizedState=ko,r}return a=e.child,e=a.sibling,r=Kn(a,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=s),r.return=t,r.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=r,t.memoizedState=null,r}function bd(e,t){return t=Ja({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Kl(e,t,s,r){return r!==null&&id(r),yr(t,e.child,null,s),e=bd(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Rm(e,t,s,r,l,a,i){if(s)return t.flags&256?(t.flags&=-257,r=Oi(Error(G(422))),Kl(e,t,i,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(a=r.fallback,l=t.mode,r=Ja({mode:"visible",children:r.children},l,0,null),a=vs(a,l,i,null),a.flags|=2,r.return=t,a.return=t,r.sibling=a,t.child=r,t.mode&1&&yr(t,e.child,null,i),t.child.memoizedState=Co(i),t.memoizedState=ko,a);if(!(t.mode&1))return Kl(e,t,i,null);if(l.data==="$!"){if(r=l.nextSibling&&l.nextSibling.dataset,r)var c=r.dgst;return r=c,a=Error(G(419)),r=Oi(a,r,void 0),Kl(e,t,i,r)}if(c=(i&e.childLanes)!==0,St||c){if(r=rt,r!==null){switch(i&-i){case 4:l=2;break;case 16:l=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:l=32;break;case 536870912:l=268435456;break;default:l=0}l=l&(r.suspendedLanes|i)?0:l,l!==0&&l!==a.retryLane&&(a.retryLane=l,_n(e,l),Xt(r,e,l,-1))}return zd(),r=Oi(Error(G(421))),Kl(e,t,i,r)}return l.data==="$?"?(t.flags|=128,t.child=e.child,t=Km.bind(null,e),l._reactRetry=t,null):(e=a.treeContext,Et=Fn(l.nextSibling),Pt=t,Pe=!0,Kt=null,e!==null&&(Lt[Ot++]=vn,Lt[Ot++]=jn,Lt[Ot++]=bs,vn=e.id,jn=e.overflow,bs=t),t=bd(t,r.children),t.flags|=4096,t)}function au(e,t,s){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),vo(e.return,t,s)}function Ni(e,t,s,r,l){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:s,tailMode:l}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=s,a.tailMode=l)}function Tf(e,t,s){var r=t.pendingProps,l=r.revealOrder,a=r.tail;if(xt(e,t,r.children,s),r=Re.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&au(e,s,t);else if(e.tag===19)au(e,s,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Se(Re,r),!(t.mode&1))t.memoizedState=null;else switch(l){case"forwards":for(s=t.child,l=null;s!==null;)e=s.alternate,e!==null&&Ea(e)===null&&(l=s),s=s.sibling;s=l,s===null?(l=t.child,t.child=null):(l=s.sibling,s.sibling=null),Ni(t,!1,l,s,a);break;case"backwards":for(s=null,l=t.child,t.child=null;l!==null;){if(e=l.alternate,e!==null&&Ea(e)===null){t.child=l;break}e=l.sibling,l.sibling=s,s=l,l=e}Ni(t,!0,s,null,a);break;case"together":Ni(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function da(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function kn(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),ws|=t.lanes,!(s&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(G(153));if(t.child!==null){for(e=t.child,s=Kn(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=Kn(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function Dm(e,t,s){switch(t.tag){case 3:Cf(t),mr();break;case 5:Vp(t);break;case 1:_t(t.type)&&_a(t);break;case 4:fd(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,l=t.memoizedProps.value;Se(za,r._currentValue),r._currentValue=l;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Se(Re,Re.current&1),t.flags|=128,null):s&t.child.childLanes?zf(e,t,s):(Se(Re,Re.current&1),e=kn(e,t,s),e!==null?e.sibling:null);Se(Re,Re.current&1);break;case 19:if(r=(s&t.childLanes)!==0,e.flags&128){if(r)return Tf(e,t,s);t.flags|=128}if(l=t.memoizedState,l!==null&&(l.rendering=null,l.tail=null,l.lastEffect=null),Se(Re,Re.current),r)break;return null;case 22:case 23:return t.lanes=0,_f(e,t,s)}return kn(e,t,s)}var If,zo,Ef,Pf;If=function(e,t){for(var s=t.child;s!==null;){if(s.tag===5||s.tag===6)e.appendChild(s.stateNode);else if(s.tag!==4&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return;s=s.return}s.sibling.return=s.return,s=s.sibling}};zo=function(){};Ef=function(e,t,s,r){var l=e.memoizedProps;if(l!==r){e=t.stateNode,ms(on.current);var a=null;switch(s){case"input":l=Yi(e,l),r=Yi(e,r),a=[];break;case"select":l=Le({},l,{value:void 0}),r=Le({},r,{value:void 0}),a=[];break;case"textarea":l=Ji(e,l),r=Ji(e,r),a=[];break;default:typeof l.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Sa)}Vi(s,r);var i;s=null;for(f in l)if(!r.hasOwnProperty(f)&&l.hasOwnProperty(f)&&l[f]!=null)if(f==="style"){var c=l[f];for(i in c)c.hasOwnProperty(i)&&(s||(s={}),s[i]="")}else f!=="dangerouslySetInnerHTML"&&f!=="children"&&f!=="suppressContentEditableWarning"&&f!=="suppressHydrationWarning"&&f!=="autoFocus"&&(rl.hasOwnProperty(f)?a||(a=[]):(a=a||[]).push(f,null));for(f in r){var d=r[f];if(c=l!=null?l[f]:void 0,r.hasOwnProperty(f)&&d!==c&&(d!=null||c!=null))if(f==="style")if(c){for(i in c)!c.hasOwnProperty(i)||d&&d.hasOwnProperty(i)||(s||(s={}),s[i]="");for(i in d)d.hasOwnProperty(i)&&c[i]!==d[i]&&(s||(s={}),s[i]=d[i])}else s||(a||(a=[]),a.push(f,s)),s=d;else f==="dangerouslySetInnerHTML"?(d=d?d.__html:void 0,c=c?c.__html:void 0,d!=null&&c!==d&&(a=a||[]).push(f,d)):f==="children"?typeof d!="string"&&typeof d!="number"||(a=a||[]).push(f,""+d):f!=="suppressContentEditableWarning"&&f!=="suppressHydrationWarning"&&(rl.hasOwnProperty(f)?(d!=null&&f==="onScroll"&&_e("scroll",e),a||c===d||(a=[])):(a=a||[]).push(f,d))}s&&(a=a||[]).push("style",s);var f=a;(t.updateQueue=f)&&(t.flags|=4)}};Pf=function(e,t,s,r){s!==r&&(t.flags|=4)};function Wr(e,t){if(!Pe)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var r=null;s!==null;)s.alternate!==null&&(r=s),s=s.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function ut(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,r=0;if(t)for(var l=e.child;l!==null;)s|=l.lanes|l.childLanes,r|=l.subtreeFlags&14680064,r|=l.flags&14680064,l.return=e,l=l.sibling;else for(l=e.child;l!==null;)s|=l.lanes|l.childLanes,r|=l.subtreeFlags,r|=l.flags,l.return=e,l=l.sibling;return e.subtreeFlags|=r,e.childLanes=s,t}function Lm(e,t,s){var r=t.pendingProps;switch(ad(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ut(t),null;case 1:return _t(t.type)&&wa(),ut(t),null;case 3:return r=t.stateNode,vr(),ke(wt),ke(ft),gd(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Hl(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Kt!==null&&(Lo(Kt),Kt=null))),zo(e,t),ut(t),null;case 5:hd(t);var l=ms(xl.current);if(s=t.type,e!==null&&t.stateNode!=null)Ef(e,t,s,r,l),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(G(166));return ut(t),null}if(e=ms(on.current),Hl(t)){r=t.stateNode,s=t.type;var a=t.memoizedProps;switch(r[ln]=t,r[hl]=a,e=(t.mode&1)!==0,s){case"dialog":_e("cancel",r),_e("close",r);break;case"iframe":case"object":case"embed":_e("load",r);break;case"video":case"audio":for(l=0;l<Qr.length;l++)_e(Qr[l],r);break;case"source":_e("error",r);break;case"img":case"image":case"link":_e("error",r),_e("load",r);break;case"details":_e("toggle",r);break;case"input":gc(r,a),_e("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!a.multiple},_e("invalid",r);break;case"textarea":mc(r,a),_e("invalid",r)}Vi(s,a),l=null;for(var i in a)if(a.hasOwnProperty(i)){var c=a[i];i==="children"?typeof c=="string"?r.textContent!==c&&(a.suppressHydrationWarning!==!0&&Ml(r.textContent,c,e),l=["children",c]):typeof c=="number"&&r.textContent!==""+c&&(a.suppressHydrationWarning!==!0&&Ml(r.textContent,c,e),l=["children",""+c]):rl.hasOwnProperty(i)&&c!=null&&i==="onScroll"&&_e("scroll",r)}switch(s){case"input":Ll(r),xc(r,a,!0);break;case"textarea":Ll(r),yc(r);break;case"select":case"option":break;default:typeof a.onClick=="function"&&(r.onclick=Sa)}r=l,t.updateQueue=r,r!==null&&(t.flags|=4)}else{i=l.nodeType===9?l:l.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=rp(s)),e==="http://www.w3.org/1999/xhtml"?s==="script"?(e=i.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(s,{is:r.is}):(e=i.createElement(s),s==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,s),e[ln]=t,e[hl]=r,If(e,t,!1,!1),t.stateNode=e;e:{switch(i=eo(s,r),s){case"dialog":_e("cancel",e),_e("close",e),l=r;break;case"iframe":case"object":case"embed":_e("load",e),l=r;break;case"video":case"audio":for(l=0;l<Qr.length;l++)_e(Qr[l],e);l=r;break;case"source":_e("error",e),l=r;break;case"img":case"image":case"link":_e("error",e),_e("load",e),l=r;break;case"details":_e("toggle",e),l=r;break;case"input":gc(e,r),l=Yi(e,r),_e("invalid",e);break;case"option":l=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},l=Le({},r,{value:void 0}),_e("invalid",e);break;case"textarea":mc(e,r),l=Ji(e,r),_e("invalid",e);break;default:l=r}Vi(s,l),c=l;for(a in c)if(c.hasOwnProperty(a)){var d=c[a];a==="style"?ip(e,d):a==="dangerouslySetInnerHTML"?(d=d?d.__html:void 0,d!=null&&lp(e,d)):a==="children"?typeof d=="string"?(s!=="textarea"||d!=="")&&ll(e,d):typeof d=="number"&&ll(e,""+d):a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&a!=="autoFocus"&&(rl.hasOwnProperty(a)?d!=null&&a==="onScroll"&&_e("scroll",e):d!=null&&Go(e,a,d,i))}switch(s){case"input":Ll(e),xc(e,r,!1);break;case"textarea":Ll(e),yc(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Qn(r.value));break;case"select":e.multiple=!!r.multiple,a=r.value,a!=null?dr(e,!!r.multiple,a,!1):r.defaultValue!=null&&dr(e,!!r.multiple,r.defaultValue,!0);break;default:typeof l.onClick=="function"&&(e.onclick=Sa)}switch(s){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return ut(t),null;case 6:if(e&&t.stateNode!=null)Pf(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(G(166));if(s=ms(xl.current),ms(on.current),Hl(t)){if(r=t.stateNode,s=t.memoizedProps,r[ln]=t,(a=r.nodeValue!==s)&&(e=Pt,e!==null))switch(e.tag){case 3:Ml(r.nodeValue,s,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Ml(r.nodeValue,s,(e.mode&1)!==0)}a&&(t.flags|=4)}else r=(s.nodeType===9?s:s.ownerDocument).createTextNode(r),r[ln]=t,t.stateNode=r}return ut(t),null;case 13:if(ke(Re),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Pe&&Et!==null&&t.mode&1&&!(t.flags&128))Yp(),mr(),t.flags|=98560,a=!1;else if(a=Hl(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(G(318));if(a=t.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(G(317));a[ln]=t}else mr(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;ut(t),a=!1}else Kt!==null&&(Lo(Kt),Kt=null),a=!0;if(!a)return t.flags&65536?t:null}return t.flags&128?(t.lanes=s,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||Re.current&1?tt===0&&(tt=3):zd())),t.updateQueue!==null&&(t.flags|=4),ut(t),null);case 4:return vr(),zo(e,t),e===null&&pl(t.stateNode.containerInfo),ut(t),null;case 10:return cd(t.type._context),ut(t),null;case 17:return _t(t.type)&&wa(),ut(t),null;case 19:if(ke(Re),a=t.memoizedState,a===null)return ut(t),null;if(r=(t.flags&128)!==0,i=a.rendering,i===null)if(r)Wr(a,!1);else{if(tt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(i=Ea(e),i!==null){for(t.flags|=128,Wr(a,!1),r=i.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=s,s=t.child;s!==null;)a=s,e=r,a.flags&=14680066,i=a.alternate,i===null?(a.childLanes=0,a.lanes=e,a.child=null,a.subtreeFlags=0,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null,a.stateNode=null):(a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.subtreeFlags=0,a.deletions=null,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,a.type=i.type,e=i.dependencies,a.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),s=s.sibling;return Se(Re,Re.current&1|2),t.child}e=e.sibling}a.tail!==null&&He()>br&&(t.flags|=128,r=!0,Wr(a,!1),t.lanes=4194304)}else{if(!r)if(e=Ea(i),e!==null){if(t.flags|=128,r=!0,s=e.updateQueue,s!==null&&(t.updateQueue=s,t.flags|=4),Wr(a,!0),a.tail===null&&a.tailMode==="hidden"&&!i.alternate&&!Pe)return ut(t),null}else 2*He()-a.renderingStartTime>br&&s!==1073741824&&(t.flags|=128,r=!0,Wr(a,!1),t.lanes=4194304);a.isBackwards?(i.sibling=t.child,t.child=i):(s=a.last,s!==null?s.sibling=i:t.child=i,a.last=i)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=He(),t.sibling=null,s=Re.current,Se(Re,r?s&1|2:s&1),t):(ut(t),null);case 22:case 23:return Cd(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?It&1073741824&&(ut(t),t.subtreeFlags&6&&(t.flags|=8192)):ut(t),null;case 24:return null;case 25:return null}throw Error(G(156,t.tag))}function Om(e,t){switch(ad(t),t.tag){case 1:return _t(t.type)&&wa(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return vr(),ke(wt),ke(ft),gd(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return hd(t),null;case 13:if(ke(Re),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(G(340));mr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ke(Re),null;case 4:return vr(),null;case 10:return cd(t.type._context),null;case 22:case 23:return Cd(),null;case 24:return null;default:return null}}var Ql=!1,pt=!1,Nm=typeof WeakSet=="function"?WeakSet:Set,q=null;function ar(e,t){var s=e.ref;if(s!==null)if(typeof s=="function")try{s(null)}catch(r){Be(e,t,r)}else s.current=null}function To(e,t,s){try{s()}catch(r){Be(e,t,r)}}var iu=!1;function Wm(e,t){if(uo=va,e=Lp(),rd(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var r=s.getSelection&&s.getSelection();if(r&&r.rangeCount!==0){s=r.anchorNode;var l=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{s.nodeType,a.nodeType}catch{s=null;break e}var i=0,c=-1,d=-1,f=0,v=0,p=e,u=null;t:for(;;){for(var m;p!==s||l!==0&&p.nodeType!==3||(c=i+l),p!==a||r!==0&&p.nodeType!==3||(d=i+r),p.nodeType===3&&(i+=p.nodeValue.length),(m=p.firstChild)!==null;)u=p,p=m;for(;;){if(p===e)break t;if(u===s&&++f===l&&(c=i),u===a&&++v===r&&(d=i),(m=p.nextSibling)!==null)break;p=u,u=p.parentNode}p=m}s=c===-1||d===-1?null:{start:c,end:d}}else s=null}s=s||{start:0,end:0}}else s=null;for(po={focusedElem:e,selectionRange:s},va=!1,q=t;q!==null;)if(t=q,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,q=e;else for(;q!==null;){t=q;try{var j=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(j!==null){var h=j.memoizedProps,S=j.memoizedState,g=t.stateNode,x=g.getSnapshotBeforeUpdate(t.elementType===t.type?h:Ht(t.type,h),S);g.__reactInternalSnapshotBeforeUpdate=x}break;case 3:var o=t.stateNode.containerInfo;o.nodeType===1?o.textContent="":o.nodeType===9&&o.documentElement&&o.removeChild(o.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(G(163))}}catch(y){Be(t,t.return,y)}if(e=t.sibling,e!==null){e.return=t.return,q=e;break}q=t.return}return j=iu,iu=!1,j}function tl(e,t,s){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var a=l.destroy;l.destroy=void 0,a!==void 0&&To(t,s,a)}l=l.next}while(l!==r)}}function Xa(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var s=t=t.next;do{if((s.tag&e)===e){var r=s.create;s.destroy=r()}s=s.next}while(s!==t)}}function Io(e){var t=e.ref;if(t!==null){var s=e.stateNode;switch(e.tag){case 5:e=s;break;default:e=s}typeof t=="function"?t(e):t.current=e}}function Af(e){var t=e.alternate;t!==null&&(e.alternate=null,Af(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[ln],delete t[hl],delete t[go],delete t[jm],delete t[bm])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Rf(e){return e.tag===5||e.tag===3||e.tag===4}function ou(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Rf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Eo(e,t,s){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?s.nodeType===8?s.parentNode.insertBefore(e,t):s.insertBefore(e,t):(s.nodeType===8?(t=s.parentNode,t.insertBefore(e,s)):(t=s,t.appendChild(e)),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=Sa));else if(r!==4&&(e=e.child,e!==null))for(Eo(e,t,s),e=e.sibling;e!==null;)Eo(e,t,s),e=e.sibling}function Po(e,t,s){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Po(e,t,s),e=e.sibling;e!==null;)Po(e,t,s),e=e.sibling}var at=null,Gt=!1;function In(e,t,s){for(s=s.child;s!==null;)Df(e,t,s),s=s.sibling}function Df(e,t,s){if(an&&typeof an.onCommitFiberUnmount=="function")try{an.onCommitFiberUnmount(Ua,s)}catch{}switch(s.tag){case 5:pt||ar(s,t);case 6:var r=at,l=Gt;at=null,In(e,t,s),at=r,Gt=l,at!==null&&(Gt?(e=at,s=s.stateNode,e.nodeType===8?e.parentNode.removeChild(s):e.removeChild(s)):at.removeChild(s.stateNode));break;case 18:at!==null&&(Gt?(e=at,s=s.stateNode,e.nodeType===8?Ei(e.parentNode,s):e.nodeType===1&&Ei(e,s),dl(e)):Ei(at,s.stateNode));break;case 4:r=at,l=Gt,at=s.stateNode.containerInfo,Gt=!0,In(e,t,s),at=r,Gt=l;break;case 0:case 11:case 14:case 15:if(!pt&&(r=s.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var a=l,i=a.destroy;a=a.tag,i!==void 0&&(a&2||a&4)&&To(s,t,i),l=l.next}while(l!==r)}In(e,t,s);break;case 1:if(!pt&&(ar(s,t),r=s.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=s.memoizedProps,r.state=s.memoizedState,r.componentWillUnmount()}catch(c){Be(s,t,c)}In(e,t,s);break;case 21:In(e,t,s);break;case 22:s.mode&1?(pt=(r=pt)||s.memoizedState!==null,In(e,t,s),pt=r):In(e,t,s);break;default:In(e,t,s)}}function du(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var s=e.stateNode;s===null&&(s=e.stateNode=new Nm),t.forEach(function(r){var l=Qm.bind(null,e,r);s.has(r)||(s.add(r),r.then(l,l))})}}function Mt(e,t){var s=t.deletions;if(s!==null)for(var r=0;r<s.length;r++){var l=s[r];try{var a=e,i=t,c=i;e:for(;c!==null;){switch(c.tag){case 5:at=c.stateNode,Gt=!1;break e;case 3:at=c.stateNode.containerInfo,Gt=!0;break e;case 4:at=c.stateNode.containerInfo,Gt=!0;break e}c=c.return}if(at===null)throw Error(G(160));Df(a,i,l),at=null,Gt=!1;var d=l.alternate;d!==null&&(d.return=null),l.return=null}catch(f){Be(l,t,f)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Lf(t,e),t=t.sibling}function Lf(e,t){var s=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Mt(t,e),tn(e),r&4){try{tl(3,e,e.return),Xa(3,e)}catch(h){Be(e,e.return,h)}try{tl(5,e,e.return)}catch(h){Be(e,e.return,h)}}break;case 1:Mt(t,e),tn(e),r&512&&s!==null&&ar(s,s.return);break;case 5:if(Mt(t,e),tn(e),r&512&&s!==null&&ar(s,s.return),e.flags&32){var l=e.stateNode;try{ll(l,"")}catch(h){Be(e,e.return,h)}}if(r&4&&(l=e.stateNode,l!=null)){var a=e.memoizedProps,i=s!==null?s.memoizedProps:a,c=e.type,d=e.updateQueue;if(e.updateQueue=null,d!==null)try{c==="input"&&a.type==="radio"&&a.name!=null&&np(l,a),eo(c,i);var f=eo(c,a);for(i=0;i<d.length;i+=2){var v=d[i],p=d[i+1];v==="style"?ip(l,p):v==="dangerouslySetInnerHTML"?lp(l,p):v==="children"?ll(l,p):Go(l,v,p,f)}switch(c){case"input":Xi(l,a);break;case"textarea":sp(l,a);break;case"select":var u=l._wrapperState.wasMultiple;l._wrapperState.wasMultiple=!!a.multiple;var m=a.value;m!=null?dr(l,!!a.multiple,m,!1):u!==!!a.multiple&&(a.defaultValue!=null?dr(l,!!a.multiple,a.defaultValue,!0):dr(l,!!a.multiple,a.multiple?[]:"",!1))}l[hl]=a}catch(h){Be(e,e.return,h)}}break;case 6:if(Mt(t,e),tn(e),r&4){if(e.stateNode===null)throw Error(G(162));l=e.stateNode,a=e.memoizedProps;try{l.nodeValue=a}catch(h){Be(e,e.return,h)}}break;case 3:if(Mt(t,e),tn(e),r&4&&s!==null&&s.memoizedState.isDehydrated)try{dl(t.containerInfo)}catch(h){Be(e,e.return,h)}break;case 4:Mt(t,e),tn(e);break;case 13:Mt(t,e),tn(e),l=e.child,l.flags&8192&&(a=l.memoizedState!==null,l.stateNode.isHidden=a,!a||l.alternate!==null&&l.alternate.memoizedState!==null||(_d=He())),r&4&&du(e);break;case 22:if(v=s!==null&&s.memoizedState!==null,e.mode&1?(pt=(f=pt)||v,Mt(t,e),pt=f):Mt(t,e),tn(e),r&8192){if(f=e.memoizedState!==null,(e.stateNode.isHidden=f)&&!v&&e.mode&1)for(q=e,v=e.child;v!==null;){for(p=q=v;q!==null;){switch(u=q,m=u.child,u.tag){case 0:case 11:case 14:case 15:tl(4,u,u.return);break;case 1:ar(u,u.return);var j=u.stateNode;if(typeof j.componentWillUnmount=="function"){r=u,s=u.return;try{t=r,j.props=t.memoizedProps,j.state=t.memoizedState,j.componentWillUnmount()}catch(h){Be(r,s,h)}}break;case 5:ar(u,u.return);break;case 22:if(u.memoizedState!==null){uu(p);continue}}m!==null?(m.return=u,q=m):uu(p)}v=v.sibling}e:for(v=null,p=e;;){if(p.tag===5){if(v===null){v=p;try{l=p.stateNode,f?(a=l.style,typeof a.setProperty=="function"?a.setProperty("display","none","important"):a.display="none"):(c=p.stateNode,d=p.memoizedProps.style,i=d!=null&&d.hasOwnProperty("display")?d.display:null,c.style.display=ap("display",i))}catch(h){Be(e,e.return,h)}}}else if(p.tag===6){if(v===null)try{p.stateNode.nodeValue=f?"":p.memoizedProps}catch(h){Be(e,e.return,h)}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===e)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===e)break e;for(;p.sibling===null;){if(p.return===null||p.return===e)break e;v===p&&(v=null),p=p.return}v===p&&(v=null),p.sibling.return=p.return,p=p.sibling}}break;case 19:Mt(t,e),tn(e),r&4&&du(e);break;case 21:break;default:Mt(t,e),tn(e)}}function tn(e){var t=e.flags;if(t&2){try{e:{for(var s=e.return;s!==null;){if(Rf(s)){var r=s;break e}s=s.return}throw Error(G(160))}switch(r.tag){case 5:var l=r.stateNode;r.flags&32&&(ll(l,""),r.flags&=-33);var a=ou(e);Po(e,a,l);break;case 3:case 4:var i=r.stateNode.containerInfo,c=ou(e);Eo(e,c,i);break;default:throw Error(G(161))}}catch(d){Be(e,e.return,d)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Bm(e,t,s){q=e,Of(e)}function Of(e,t,s){for(var r=(e.mode&1)!==0;q!==null;){var l=q,a=l.child;if(l.tag===22&&r){var i=l.memoizedState!==null||Ql;if(!i){var c=l.alternate,d=c!==null&&c.memoizedState!==null||pt;c=Ql;var f=pt;if(Ql=i,(pt=d)&&!f)for(q=l;q!==null;)i=q,d=i.child,i.tag===22&&i.memoizedState!==null?pu(l):d!==null?(d.return=i,q=d):pu(l);for(;a!==null;)q=a,Of(a),a=a.sibling;q=l,Ql=c,pt=f}cu(e)}else l.subtreeFlags&8772&&a!==null?(a.return=l,q=a):cu(e)}}function cu(e){for(;q!==null;){var t=q;if(t.flags&8772){var s=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:pt||Xa(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!pt)if(s===null)r.componentDidMount();else{var l=t.elementType===t.type?s.memoizedProps:Ht(t.type,s.memoizedProps);r.componentDidUpdate(l,s.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var a=t.updateQueue;a!==null&&Yc(t,a,r);break;case 3:var i=t.updateQueue;if(i!==null){if(s=null,t.child!==null)switch(t.child.tag){case 5:s=t.child.stateNode;break;case 1:s=t.child.stateNode}Yc(t,i,s)}break;case 5:var c=t.stateNode;if(s===null&&t.flags&4){s=c;var d=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":d.autoFocus&&s.focus();break;case"img":d.src&&(s.src=d.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var f=t.alternate;if(f!==null){var v=f.memoizedState;if(v!==null){var p=v.dehydrated;p!==null&&dl(p)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(G(163))}pt||t.flags&512&&Io(t)}catch(u){Be(t,t.return,u)}}if(t===e){q=null;break}if(s=t.sibling,s!==null){s.return=t.return,q=s;break}q=t.return}}function uu(e){for(;q!==null;){var t=q;if(t===e){q=null;break}var s=t.sibling;if(s!==null){s.return=t.return,q=s;break}q=t.return}}function pu(e){for(;q!==null;){var t=q;try{switch(t.tag){case 0:case 11:case 15:var s=t.return;try{Xa(4,t)}catch(d){Be(t,s,d)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var l=t.return;try{r.componentDidMount()}catch(d){Be(t,l,d)}}var a=t.return;try{Io(t)}catch(d){Be(t,a,d)}break;case 5:var i=t.return;try{Io(t)}catch(d){Be(t,i,d)}}}catch(d){Be(t,t.return,d)}if(t===e){q=null;break}var c=t.sibling;if(c!==null){c.return=t.return,q=c;break}q=t.return}}var $m=Math.ceil,Ra=Cn.ReactCurrentDispatcher,Sd=Cn.ReactCurrentOwner,Wt=Cn.ReactCurrentBatchConfig,he=0,rt=null,Ye=null,it=0,It=0,ir=Jn(0),tt=0,jl=null,ws=0,qa=0,wd=0,nl=null,bt=null,_d=0,br=1/0,mn=null,Da=!1,Ao=null,Hn=null,Yl=!1,On=null,La=0,sl=0,Ro=null,ca=-1,ua=0;function mt(){return he&6?He():ca!==-1?ca:ca=He()}function Gn(e){return e.mode&1?he&2&&it!==0?it&-it:wm.transition!==null?(ua===0&&(ua=vp()),ua):(e=ye,e!==0||(e=window.event,e=e===void 0?16:Cp(e.type)),e):1}function Xt(e,t,s,r){if(50<sl)throw sl=0,Ro=null,Error(G(185));wl(e,s,r),(!(he&2)||e!==rt)&&(e===rt&&(!(he&2)&&(qa|=s),tt===4&&Dn(e,it)),kt(e,r),s===1&&he===0&&!(t.mode&1)&&(br=He()+500,Ka&&Zn()))}function kt(e,t){var s=e.callbackNode;wx(e,t);var r=ya(e,e===rt?it:0);if(r===0)s!==null&&bc(s),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(s!=null&&bc(s),t===1)e.tag===0?Sm(fu.bind(null,e)):Gp(fu.bind(null,e)),ym(function(){!(he&6)&&Zn()}),s=null;else{switch(jp(r)){case 1:s=qo;break;case 4:s=mp;break;case 16:s=ma;break;case 536870912:s=yp;break;default:s=ma}s=Hf(s,Nf.bind(null,e))}e.callbackPriority=t,e.callbackNode=s}}function Nf(e,t){if(ca=-1,ua=0,he&6)throw Error(G(327));var s=e.callbackNode;if(hr()&&e.callbackNode!==s)return null;var r=ya(e,e===rt?it:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Oa(e,r);else{t=r;var l=he;he|=2;var a=Bf();(rt!==e||it!==t)&&(mn=null,br=He()+500,ys(e,t));do try{Mm();break}catch(c){Wf(e,c)}while(!0);dd(),Ra.current=a,he=l,Ye!==null?t=0:(rt=null,it=0,t=tt)}if(t!==0){if(t===2&&(l=lo(e),l!==0&&(r=l,t=Do(e,l))),t===1)throw s=jl,ys(e,0),Dn(e,r),kt(e,He()),s;if(t===6)Dn(e,r);else{if(l=e.current.alternate,!(r&30)&&!Um(l)&&(t=Oa(e,r),t===2&&(a=lo(e),a!==0&&(r=a,t=Do(e,a))),t===1))throw s=jl,ys(e,0),Dn(e,r),kt(e,He()),s;switch(e.finishedWork=l,e.finishedLanes=r,t){case 0:case 1:throw Error(G(345));case 2:hs(e,bt,mn);break;case 3:if(Dn(e,r),(r&130023424)===r&&(t=_d+500-He(),10<t)){if(ya(e,0)!==0)break;if(l=e.suspendedLanes,(l&r)!==r){mt(),e.pingedLanes|=e.suspendedLanes&l;break}e.timeoutHandle=ho(hs.bind(null,e,bt,mn),t);break}hs(e,bt,mn);break;case 4:if(Dn(e,r),(r&4194240)===r)break;for(t=e.eventTimes,l=-1;0<r;){var i=31-Yt(r);a=1<<i,i=t[i],i>l&&(l=i),r&=~a}if(r=l,r=He()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*$m(r/1960))-r,10<r){e.timeoutHandle=ho(hs.bind(null,e,bt,mn),r);break}hs(e,bt,mn);break;case 5:hs(e,bt,mn);break;default:throw Error(G(329))}}}return kt(e,He()),e.callbackNode===s?Nf.bind(null,e):null}function Do(e,t){var s=nl;return e.current.memoizedState.isDehydrated&&(ys(e,t).flags|=256),e=Oa(e,t),e!==2&&(t=bt,bt=s,t!==null&&Lo(t)),e}function Lo(e){bt===null?bt=e:bt.push.apply(bt,e)}function Um(e){for(var t=e;;){if(t.flags&16384){var s=t.updateQueue;if(s!==null&&(s=s.stores,s!==null))for(var r=0;r<s.length;r++){var l=s[r],a=l.getSnapshot;l=l.value;try{if(!qt(a(),l))return!1}catch{return!1}}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Dn(e,t){for(t&=~wd,t&=~qa,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var s=31-Yt(t),r=1<<s;e[s]=-1,t&=~r}}function fu(e){if(he&6)throw Error(G(327));hr();var t=ya(e,0);if(!(t&1))return kt(e,He()),null;var s=Oa(e,t);if(e.tag!==0&&s===2){var r=lo(e);r!==0&&(t=r,s=Do(e,r))}if(s===1)throw s=jl,ys(e,0),Dn(e,t),kt(e,He()),s;if(s===6)throw Error(G(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,hs(e,bt,mn),kt(e,He()),null}function kd(e,t){var s=he;he|=1;try{return e(t)}finally{he=s,he===0&&(br=He()+500,Ka&&Zn())}}function _s(e){On!==null&&On.tag===0&&!(he&6)&&hr();var t=he;he|=1;var s=Wt.transition,r=ye;try{if(Wt.transition=null,ye=1,e)return e()}finally{ye=r,Wt.transition=s,he=t,!(he&6)&&Zn()}}function Cd(){It=ir.current,ke(ir)}function ys(e,t){e.finishedWork=null,e.finishedLanes=0;var s=e.timeoutHandle;if(s!==-1&&(e.timeoutHandle=-1,mm(s)),Ye!==null)for(s=Ye.return;s!==null;){var r=s;switch(ad(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&wa();break;case 3:vr(),ke(wt),ke(ft),gd();break;case 5:hd(r);break;case 4:vr();break;case 13:ke(Re);break;case 19:ke(Re);break;case 10:cd(r.type._context);break;case 22:case 23:Cd()}s=s.return}if(rt=e,Ye=e=Kn(e.current,null),it=It=t,tt=0,jl=null,wd=qa=ws=0,bt=nl=null,xs!==null){for(t=0;t<xs.length;t++)if(s=xs[t],r=s.interleaved,r!==null){s.interleaved=null;var l=r.next,a=s.pending;if(a!==null){var i=a.next;a.next=l,r.next=i}s.pending=r}xs=null}return e}function Wf(e,t){do{var s=Ye;try{if(dd(),ia.current=Aa,Pa){for(var r=De.memoizedState;r!==null;){var l=r.queue;l!==null&&(l.pending=null),r=r.next}Pa=!1}if(Ss=0,st=et=De=null,el=!1,ml=0,Sd.current=null,s===null||s.return===null){tt=1,jl=t,Ye=null;break}e:{var a=e,i=s.return,c=s,d=t;if(t=it,c.flags|=32768,d!==null&&typeof d=="object"&&typeof d.then=="function"){var f=d,v=c,p=v.tag;if(!(v.mode&1)&&(p===0||p===11||p===15)){var u=v.alternate;u?(v.updateQueue=u.updateQueue,v.memoizedState=u.memoizedState,v.lanes=u.lanes):(v.updateQueue=null,v.memoizedState=null)}var m=eu(i);if(m!==null){m.flags&=-257,tu(m,i,c,a,t),m.mode&1&&Vc(a,f,t),t=m,d=f;var j=t.updateQueue;if(j===null){var h=new Set;h.add(d),t.updateQueue=h}else j.add(d);break e}else{if(!(t&1)){Vc(a,f,t),zd();break e}d=Error(G(426))}}else if(Pe&&c.mode&1){var S=eu(i);if(S!==null){!(S.flags&65536)&&(S.flags|=256),tu(S,i,c,a,t),id(jr(d,c));break e}}a=d=jr(d,c),tt!==4&&(tt=2),nl===null?nl=[a]:nl.push(a),a=i;do{switch(a.tag){case 3:a.flags|=65536,t&=-t,a.lanes|=t;var g=bf(a,d,t);Qc(a,g);break e;case 1:c=d;var x=a.type,o=a.stateNode;if(!(a.flags&128)&&(typeof x.getDerivedStateFromError=="function"||o!==null&&typeof o.componentDidCatch=="function"&&(Hn===null||!Hn.has(o)))){a.flags|=65536,t&=-t,a.lanes|=t;var y=Sf(a,c,t);Qc(a,y);break e}}a=a.return}while(a!==null)}Uf(s)}catch(_){t=_,Ye===s&&s!==null&&(Ye=s=s.return);continue}break}while(!0)}function Bf(){var e=Ra.current;return Ra.current=Aa,e===null?Aa:e}function zd(){(tt===0||tt===3||tt===2)&&(tt=4),rt===null||!(ws&268435455)&&!(qa&268435455)||Dn(rt,it)}function Oa(e,t){var s=he;he|=2;var r=Bf();(rt!==e||it!==t)&&(mn=null,ys(e,t));do try{Fm();break}catch(l){Wf(e,l)}while(!0);if(dd(),he=s,Ra.current=r,Ye!==null)throw Error(G(261));return rt=null,it=0,tt}function Fm(){for(;Ye!==null;)$f(Ye)}function Mm(){for(;Ye!==null&&!hx();)$f(Ye)}function $f(e){var t=Mf(e.alternate,e,It);e.memoizedProps=e.pendingProps,t===null?Uf(e):Ye=t,Sd.current=null}function Uf(e){var t=e;do{var s=t.alternate;if(e=t.return,t.flags&32768){if(s=Om(s,t),s!==null){s.flags&=32767,Ye=s;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{tt=6,Ye=null;return}}else if(s=Lm(s,t,It),s!==null){Ye=s;return}if(t=t.sibling,t!==null){Ye=t;return}Ye=t=e}while(t!==null);tt===0&&(tt=5)}function hs(e,t,s){var r=ye,l=Wt.transition;try{Wt.transition=null,ye=1,Hm(e,t,s,r)}finally{Wt.transition=l,ye=r}return null}function Hm(e,t,s,r){do hr();while(On!==null);if(he&6)throw Error(G(327));s=e.finishedWork;var l=e.finishedLanes;if(s===null)return null;if(e.finishedWork=null,e.finishedLanes=0,s===e.current)throw Error(G(177));e.callbackNode=null,e.callbackPriority=0;var a=s.lanes|s.childLanes;if(_x(e,a),e===rt&&(Ye=rt=null,it=0),!(s.subtreeFlags&2064)&&!(s.flags&2064)||Yl||(Yl=!0,Hf(ma,function(){return hr(),null})),a=(s.flags&15990)!==0,s.subtreeFlags&15990||a){a=Wt.transition,Wt.transition=null;var i=ye;ye=1;var c=he;he|=4,Sd.current=null,Wm(e,s),Lf(s,e),cm(po),va=!!uo,po=uo=null,e.current=s,Bm(s),gx(),he=c,ye=i,Wt.transition=a}else e.current=s;if(Yl&&(Yl=!1,On=e,La=l),a=e.pendingLanes,a===0&&(Hn=null),yx(s.stateNode),kt(e,He()),t!==null)for(r=e.onRecoverableError,s=0;s<t.length;s++)l=t[s],r(l.value,{componentStack:l.stack,digest:l.digest});if(Da)throw Da=!1,e=Ao,Ao=null,e;return La&1&&e.tag!==0&&hr(),a=e.pendingLanes,a&1?e===Ro?sl++:(sl=0,Ro=e):sl=0,Zn(),null}function hr(){if(On!==null){var e=jp(La),t=Wt.transition,s=ye;try{if(Wt.transition=null,ye=16>e?16:e,On===null)var r=!1;else{if(e=On,On=null,La=0,he&6)throw Error(G(331));var l=he;for(he|=4,q=e.current;q!==null;){var a=q,i=a.child;if(q.flags&16){var c=a.deletions;if(c!==null){for(var d=0;d<c.length;d++){var f=c[d];for(q=f;q!==null;){var v=q;switch(v.tag){case 0:case 11:case 15:tl(8,v,a)}var p=v.child;if(p!==null)p.return=v,q=p;else for(;q!==null;){v=q;var u=v.sibling,m=v.return;if(Af(v),v===f){q=null;break}if(u!==null){u.return=m,q=u;break}q=m}}}var j=a.alternate;if(j!==null){var h=j.child;if(h!==null){j.child=null;do{var S=h.sibling;h.sibling=null,h=S}while(h!==null)}}q=a}}if(a.subtreeFlags&2064&&i!==null)i.return=a,q=i;else e:for(;q!==null;){if(a=q,a.flags&2048)switch(a.tag){case 0:case 11:case 15:tl(9,a,a.return)}var g=a.sibling;if(g!==null){g.return=a.return,q=g;break e}q=a.return}}var x=e.current;for(q=x;q!==null;){i=q;var o=i.child;if(i.subtreeFlags&2064&&o!==null)o.return=i,q=o;else e:for(i=x;q!==null;){if(c=q,c.flags&2048)try{switch(c.tag){case 0:case 11:case 15:Xa(9,c)}}catch(_){Be(c,c.return,_)}if(c===i){q=null;break e}var y=c.sibling;if(y!==null){y.return=c.return,q=y;break e}q=c.return}}if(he=l,Zn(),an&&typeof an.onPostCommitFiberRoot=="function")try{an.onPostCommitFiberRoot(Ua,e)}catch{}r=!0}return r}finally{ye=s,Wt.transition=t}}return!1}function hu(e,t,s){t=jr(s,t),t=bf(e,t,1),e=Mn(e,t,1),t=mt(),e!==null&&(wl(e,1,t),kt(e,t))}function Be(e,t,s){if(e.tag===3)hu(e,e,s);else for(;t!==null;){if(t.tag===3){hu(t,e,s);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Hn===null||!Hn.has(r))){e=jr(s,e),e=Sf(t,e,1),t=Mn(t,e,1),e=mt(),t!==null&&(wl(t,1,e),kt(t,e));break}}t=t.return}}function Gm(e,t,s){var r=e.pingCache;r!==null&&r.delete(t),t=mt(),e.pingedLanes|=e.suspendedLanes&s,rt===e&&(it&s)===s&&(tt===4||tt===3&&(it&130023424)===it&&500>He()-_d?ys(e,0):wd|=s),kt(e,t)}function Ff(e,t){t===0&&(e.mode&1?(t=Wl,Wl<<=1,!(Wl&130023424)&&(Wl=4194304)):t=1);var s=mt();e=_n(e,t),e!==null&&(wl(e,t,s),kt(e,s))}function Km(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),Ff(e,s)}function Qm(e,t){var s=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(s=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(G(314))}r!==null&&r.delete(t),Ff(e,s)}var Mf;Mf=function(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps||wt.current)St=!0;else{if(!(e.lanes&s)&&!(t.flags&128))return St=!1,Dm(e,t,s);St=!!(e.flags&131072)}else St=!1,Pe&&t.flags&1048576&&Kp(t,Ca,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;da(e,t),e=t.pendingProps;var l=xr(t,ft.current);fr(t,s),l=md(null,t,r,e,l,s);var a=yd();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,_t(r)?(a=!0,_a(t)):a=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,pd(t),l.updater=Ya,t.stateNode=l,l._reactInternals=t,bo(t,r,e,s),t=_o(null,t,r,!0,a,s)):(t.tag=0,Pe&&a&&ld(t),xt(null,t,l,s),t=t.child),t;case 16:r=t.elementType;e:{switch(da(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Xm(r),e=Ht(r,e),l){case 0:t=wo(null,t,r,e,s);break e;case 1:t=ru(null,t,r,e,s);break e;case 11:t=nu(null,t,r,e,s);break e;case 14:t=su(null,t,r,Ht(r.type,e),s);break e}throw Error(G(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ht(r,l),wo(e,t,r,l,s);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ht(r,l),ru(e,t,r,l,s);case 3:e:{if(Cf(t),e===null)throw Error(G(387));r=t.pendingProps,a=t.memoizedState,l=a.element,Zp(e,t),Ia(t,r,null,s);var i=t.memoizedState;if(r=i.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){l=jr(Error(G(423)),t),t=lu(e,t,r,s,l);break e}else if(r!==l){l=jr(Error(G(424)),t),t=lu(e,t,r,s,l);break e}else for(Et=Fn(t.stateNode.containerInfo.firstChild),Pt=t,Pe=!0,Kt=null,s=qp(t,null,r,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(mr(),r===l){t=kn(e,t,s);break e}xt(e,t,r,s)}t=t.child}return t;case 5:return Vp(t),e===null&&yo(t),r=t.type,l=t.pendingProps,a=e!==null?e.memoizedProps:null,i=l.children,fo(r,l)?i=null:a!==null&&fo(r,a)&&(t.flags|=32),kf(e,t),xt(e,t,i,s),t.child;case 6:return e===null&&yo(t),null;case 13:return zf(e,t,s);case 4:return fd(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=yr(t,null,r,s):xt(e,t,r,s),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ht(r,l),nu(e,t,r,l,s);case 7:return xt(e,t,t.pendingProps,s),t.child;case 8:return xt(e,t,t.pendingProps.children,s),t.child;case 12:return xt(e,t,t.pendingProps.children,s),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,a=t.memoizedProps,i=l.value,Se(za,r._currentValue),r._currentValue=i,a!==null)if(qt(a.value,i)){if(a.children===l.children&&!wt.current){t=kn(e,t,s);break e}}else for(a=t.child,a!==null&&(a.return=t);a!==null;){var c=a.dependencies;if(c!==null){i=a.child;for(var d=c.firstContext;d!==null;){if(d.context===r){if(a.tag===1){d=bn(-1,s&-s),d.tag=2;var f=a.updateQueue;if(f!==null){f=f.shared;var v=f.pending;v===null?d.next=d:(d.next=v.next,v.next=d),f.pending=d}}a.lanes|=s,d=a.alternate,d!==null&&(d.lanes|=s),vo(a.return,s,t),c.lanes|=s;break}d=d.next}}else if(a.tag===10)i=a.type===t.type?null:a.child;else if(a.tag===18){if(i=a.return,i===null)throw Error(G(341));i.lanes|=s,c=i.alternate,c!==null&&(c.lanes|=s),vo(i,s,t),i=a.sibling}else i=a.child;if(i!==null)i.return=a;else for(i=a;i!==null;){if(i===t){i=null;break}if(a=i.sibling,a!==null){a.return=i.return,i=a;break}i=i.return}a=i}xt(e,t,l.children,s),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,fr(t,s),l=Bt(l),r=r(l),t.flags|=1,xt(e,t,r,s),t.child;case 14:return r=t.type,l=Ht(r,t.pendingProps),l=Ht(r.type,l),su(e,t,r,l,s);case 15:return wf(e,t,t.type,t.pendingProps,s);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ht(r,l),da(e,t),t.tag=1,_t(r)?(e=!0,_a(t)):e=!1,fr(t,s),jf(t,r,l),bo(t,r,l,s),_o(null,t,r,!0,e,s);case 19:return Tf(e,t,s);case 22:return _f(e,t,s)}throw Error(G(156,t.tag))};function Hf(e,t){return xp(e,t)}function Ym(e,t,s,r){this.tag=e,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Nt(e,t,s,r){return new Ym(e,t,s,r)}function Td(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Xm(e){if(typeof e=="function")return Td(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Qo)return 11;if(e===Yo)return 14}return 2}function Kn(e,t){var s=e.alternate;return s===null?(s=Nt(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&14680064,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s}function pa(e,t,s,r,l,a){var i=2;if(r=e,typeof e=="function")Td(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Js:return vs(s.children,l,a,t);case Ko:i=8,l|=8;break;case Hi:return e=Nt(12,s,t,l|2),e.elementType=Hi,e.lanes=a,e;case Gi:return e=Nt(13,s,t,l),e.elementType=Gi,e.lanes=a,e;case Ki:return e=Nt(19,s,t,l),e.elementType=Ki,e.lanes=a,e;case Vu:return Ja(s,l,a,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Ju:i=10;break e;case Zu:i=9;break e;case Qo:i=11;break e;case Yo:i=14;break e;case Pn:i=16,r=null;break e}throw Error(G(130,e==null?e:typeof e,""))}return t=Nt(i,s,t,l),t.elementType=e,t.type=r,t.lanes=a,t}function vs(e,t,s,r){return e=Nt(7,e,r,t),e.lanes=s,e}function Ja(e,t,s,r){return e=Nt(22,e,r,t),e.elementType=Vu,e.lanes=s,e.stateNode={isHidden:!1},e}function Wi(e,t,s){return e=Nt(6,e,null,t),e.lanes=s,e}function Bi(e,t,s){return t=Nt(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function qm(e,t,s,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=vi(0),this.expirationTimes=vi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=vi(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Id(e,t,s,r,l,a,i,c,d){return e=new qm(e,t,s,c,d),t===1?(t=1,a===!0&&(t|=8)):t=0,a=Nt(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:s,cache:null,transitions:null,pendingSuspenseBoundaries:null},pd(a),e}function Jm(e,t,s){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:qs,key:r==null?null:""+r,children:e,containerInfo:t,implementation:s}}function Gf(e){if(!e)return Yn;e=e._reactInternals;e:{if(zs(e)!==e||e.tag!==1)throw Error(G(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(_t(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(G(171))}if(e.tag===1){var s=e.type;if(_t(s))return Hp(e,s,t)}return t}function Kf(e,t,s,r,l,a,i,c,d){return e=Id(s,r,!0,e,l,a,i,c,d),e.context=Gf(null),s=e.current,r=mt(),l=Gn(s),a=bn(r,l),a.callback=t??null,Mn(s,a,l),e.current.lanes=l,wl(e,l,r),kt(e,r),e}function Za(e,t,s,r){var l=t.current,a=mt(),i=Gn(l);return s=Gf(s),t.context===null?t.context=s:t.pendingContext=s,t=bn(a,i),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Mn(l,t,i),e!==null&&(Xt(e,l,i,a),aa(e,l,i)),i}function Na(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function gu(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function Ed(e,t){gu(e,t),(e=e.alternate)&&gu(e,t)}function Zm(){return null}var Qf=typeof reportError=="function"?reportError:function(e){console.error(e)};function Pd(e){this._internalRoot=e}Va.prototype.render=Pd.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(G(409));Za(e,t,null,null)};Va.prototype.unmount=Pd.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;_s(function(){Za(null,e,null,null)}),t[wn]=null}};function Va(e){this._internalRoot=e}Va.prototype.unstable_scheduleHydration=function(e){if(e){var t=wp();e={blockedOn:null,target:e,priority:t};for(var s=0;s<Rn.length&&t!==0&&t<Rn[s].priority;s++);Rn.splice(s,0,e),s===0&&kp(e)}};function Ad(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ei(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function xu(){}function Vm(e,t,s,r,l){if(l){if(typeof r=="function"){var a=r;r=function(){var f=Na(i);a.call(f)}}var i=Kf(t,r,e,0,null,!1,!1,"",xu);return e._reactRootContainer=i,e[wn]=i.current,pl(e.nodeType===8?e.parentNode:e),_s(),i}for(;l=e.lastChild;)e.removeChild(l);if(typeof r=="function"){var c=r;r=function(){var f=Na(d);c.call(f)}}var d=Id(e,0,!1,null,null,!1,!1,"",xu);return e._reactRootContainer=d,e[wn]=d.current,pl(e.nodeType===8?e.parentNode:e),_s(function(){Za(t,d,s,r)}),d}function ti(e,t,s,r,l){var a=s._reactRootContainer;if(a){var i=a;if(typeof l=="function"){var c=l;l=function(){var d=Na(i);c.call(d)}}Za(t,i,e,l)}else i=Vm(s,t,e,l,r);return Na(i)}bp=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var s=Kr(t.pendingLanes);s!==0&&(Jo(t,s|1),kt(t,He()),!(he&6)&&(br=He()+500,Zn()))}break;case 13:_s(function(){var r=_n(e,1);if(r!==null){var l=mt();Xt(r,e,1,l)}}),Ed(e,1)}};Zo=function(e){if(e.tag===13){var t=_n(e,134217728);if(t!==null){var s=mt();Xt(t,e,134217728,s)}Ed(e,134217728)}};Sp=function(e){if(e.tag===13){var t=Gn(e),s=_n(e,t);if(s!==null){var r=mt();Xt(s,e,t,r)}Ed(e,t)}};wp=function(){return ye};_p=function(e,t){var s=ye;try{return ye=e,t()}finally{ye=s}};no=function(e,t,s){switch(t){case"input":if(Xi(e,s),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<s.length;t++){var r=s[t];if(r!==e&&r.form===e.form){var l=Ga(r);if(!l)throw Error(G(90));tp(r),Xi(r,l)}}}break;case"textarea":sp(e,s);break;case"select":t=s.value,t!=null&&dr(e,!!s.multiple,t,!1)}};cp=kd;up=_s;var ey={usingClientEntryPoint:!1,Events:[kl,tr,Ga,op,dp,kd]},Br={findFiberByHostInstance:gs,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ty={bundleType:Br.bundleType,version:Br.version,rendererPackageName:Br.rendererPackageName,rendererConfig:Br.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Cn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=hp(e),e===null?null:e.stateNode},findFiberByHostInstance:Br.findFiberByHostInstance||Zm,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Xl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xl.isDisabled&&Xl.supportsFiber)try{Ua=Xl.inject(ty),an=Xl}catch{}}Rt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ey;Rt.createPortal=function(e,t){var s=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ad(t))throw Error(G(200));return Jm(e,t,null,s)};Rt.createRoot=function(e,t){if(!Ad(e))throw Error(G(299));var s=!1,r="",l=Qf;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(l=t.onRecoverableError)),t=Id(e,1,!1,null,null,s,!1,r,l),e[wn]=t.current,pl(e.nodeType===8?e.parentNode:e),new Pd(t)};Rt.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(G(188)):(e=Object.keys(e).join(","),Error(G(268,e)));return e=hp(t),e=e===null?null:e.stateNode,e};Rt.flushSync=function(e){return _s(e)};Rt.hydrate=function(e,t,s){if(!ei(t))throw Error(G(200));return ti(null,e,t,!0,s)};Rt.hydrateRoot=function(e,t,s){if(!Ad(e))throw Error(G(405));var r=s!=null&&s.hydratedSources||null,l=!1,a="",i=Qf;if(s!=null&&(s.unstable_strictMode===!0&&(l=!0),s.identifierPrefix!==void 0&&(a=s.identifierPrefix),s.onRecoverableError!==void 0&&(i=s.onRecoverableError)),t=Kf(t,null,e,1,s??null,l,!1,a,i),e[wn]=t.current,pl(e),r)for(e=0;e<r.length;e++)s=r[e],l=s._getVersion,l=l(s._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[s,l]:t.mutableSourceEagerHydrationData.push(s,l);return new Va(t)};Rt.render=function(e,t,s){if(!ei(t))throw Error(G(200));return ti(null,e,t,!1,s)};Rt.unmountComponentAtNode=function(e){if(!ei(e))throw Error(G(40));return e._reactRootContainer?(_s(function(){ti(null,null,e,!1,function(){e._reactRootContainer=null,e[wn]=null})}),!0):!1};Rt.unstable_batchedUpdates=kd;Rt.unstable_renderSubtreeIntoContainer=function(e,t,s,r){if(!ei(s))throw Error(G(200));if(e==null||e._reactInternals===void 0)throw Error(G(38));return ti(e,t,s,!1,r)};Rt.version="18.3.1-next-f1338f8080-20240426";function Yf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Yf)}catch(e){console.error(e)}}Yf(),Qu.exports=Rt;var ny=Qu.exports,Xf,mu=ny;Xf=mu.createRoot,mu.hydrateRoot;const ce="",L={incidents:"SB Incident",ideas:"SB Idea",orders:"SB Order",organizations:"SB Organization",processes:"SB Process",managements:"Managements",departments:"Department",branches:"Branch",incidentTypes:"Incident Types",ideaTypes:"Idea Types",orderTypes:"Order Types",processTypes:"Process Types",incidentClass:"Incident Class",incidentField:"Incident Field",incidentStatuses:"Incident Statuses",ideaStatuses:"Idea Statuses",orderStatuses:"Order Statuses",processStatuses:"Process Statuses",users:"User",cycles:"SB Cycle",kpiInput:"SB KPI Input",delegations:"SB Delegation",groupCompanies:"SB Group Company"},F={bg:"#f5f6fa",accent:"#4f46e5",red:"#ef4444",orange:"#f59e0b",green:"#16a34a",purple:"#7c3aed",blue:"#2563eb",teal:"#0d9488",gray:"#94a3b8"},sy=[{id:"dashboard",icon:"📊",label:"Dashboard"},{id:"inbox",icon:"📥",label:"Inbox"},{id:"incidents",icon:"📋",label:"Incidents"},{id:"ideas",icon:"💡",label:"Ideas"},{id:"orders",icon:"📦",label:"Orders"},{id:"processes",icon:"⚙️",label:"Processes"},{id:"delegations",icon:"🤝",label:"Delegations"},{id:"reports",icon:"📈",label:"Reports"}],qf=[{id:"group-companies",icon:"🌐",label:"Group Companies"},{id:"users",icon:"👤",label:"Users"},{id:"organizations",icon:"🏢",label:"Organizations"},{id:"managements",icon:"🏗️",label:"Managements"},{id:"departments",icon:"🗂️",label:"Departments"},{id:"branches",icon:"🌿",label:"Branches"},{id:"cycles",icon:"🔄",label:"Cycles"},{id:"kpi-input",icon:"📊",label:"KPI Input"},{id:"incident-types",icon:"🚨",label:"Incident Types"},{id:"idea-types",icon:"💡",label:"Idea Types"},{id:"order-types",icon:"📦",label:"Order Types"},{id:"process-types",icon:"⚙️",label:"Process Types"},{id:"incident-statuses",icon:"🔴",label:"Incident Statuses"},{id:"idea-statuses",icon:"🟢",label:"Idea Statuses"},{id:"order-statuses",icon:"🟣",label:"Order Statuses"},{id:"process-statuses",icon:"🔵",label:"Process Statuses"}],ry=new Set(["users","group-companies"]);function ly(e){return e!=="Admin"&&e!=="Auditor"?[]:qf.filter(({id:t})=>e==="Admin"||!ry.has(t))}const En=(e=[])=>[{key:"name1",label:"Name"},{key:"status",label:"Status"},...e,{key:"creation_date",label:"Created On"}],ay={incidents:{label:"Incidents",orgField:"organization",columns:[{key:"number",label:"Number"},{key:"title",label:"Title"},{key:"organization",label:"Organization"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"management",label:"Management"},{key:"department",label:"Department"},{key:"branch",label:"Branch"},{key:"date",label:"Date"},{key:"assigned_to",label:"Assigned To"},{key:"priority",label:"Priority"},{key:"economy_class",label:"Economy Class"},{key:"entity_scope",label:"Entity Scope"},{key:"hses_field",label:"HSES Field"},{key:"workflow_state",label:"Workflow State"}],defaultColumns:["number","title","organization","type","status","date","assigned_to"]},ideas:{label:"Ideas",orgField:"organization",columns:[{key:"number",label:"Number"},{key:"title",label:"Title"},{key:"organization",label:"Organization"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"management",label:"Management"},{key:"department",label:"Department"},{key:"branch",label:"Branch"},{key:"date",label:"Date"},{key:"assigned_to",label:"Assigned To"},{key:"priority",label:"Priority"},{key:"economy_class",label:"Economy Class"},{key:"current_condition",label:"Current Condition"},{key:"proposed_condition",label:"Proposed Condition"},{key:"workflow_state",label:"Workflow State"}],defaultColumns:["number","title","organization","type","status","date","assigned_to"]},orders:{label:"Orders",orgField:"organization",columns:[{key:"number",label:"Number"},{key:"title",label:"Title"},{key:"organization",label:"Organization"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"management",label:"Management"},{key:"department",label:"Department"},{key:"branch",label:"Branch"},{key:"starting_date",label:"Start Date"},{key:"ending_date",label:"End Date"},{key:"assigned_to",label:"Assigned To"},{key:"budget",label:"Budget"},{key:"actual_cost",label:"Actual Cost"},{key:"currency",label:"Currency"},{key:"stage",label:"Stage"},{key:"completion_pct",label:"Completion %"},{key:"priority",label:"Priority"},{key:"workflow_state",label:"Workflow State"}],defaultColumns:["number","title","organization","type","status","starting_date","ending_date","assigned_to","budget"]},processes:{label:"Processes",orgField:"organization",columns:[{key:"number",label:"Number"},{key:"title",label:"Title"},{key:"organization",label:"Organization"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"management",label:"Management"},{key:"department",label:"Department"},{key:"branch",label:"Branch"},{key:"date_start",label:"Start Date"},{key:"date_end",label:"End Date"},{key:"actor",label:"Actor"},{key:"cycle_type",label:"Cycle Type"},{key:"kpi_name",label:"KPI Name"},{key:"cost_per_cycle",label:"Cost / Cycle"},{key:"escalation_level",label:"Escalation"},{key:"workflow_state",label:"Workflow State"}],defaultColumns:["number","title","organization","type","status","date_start","date_end","actor"]},organizations:{label:"Organizations",columns:[{key:"name",label:"Code"},{key:"organization_name",label:"Organization Name"},{key:"type",label:"Type"},{key:"city",label:"City"},{key:"contact_email",label:"Contact Email"},{key:"is_active",label:"Active"},{key:"creation_date",label:"Created On"}],defaultColumns:["organization_name","type","city","contact_email","is_active"]},managements:{label:"Managements",orgField:"organization",columns:[{key:"name1",label:"Name"},{key:"organization",label:"Organization"},{key:"status",label:"Status"},{key:"creation_date",label:"Created On"}],defaultColumns:["name1","organization","status"]},departments:{label:"Departments",orgField:"custom_organization",columns:[{key:"department_name",label:"Department Name"},{key:"custom_organization",label:"Organization"},{key:"custom_management",label:"Management"},{key:"custom_status",label:"Status"},{key:"custom_creation_date",label:"Created On"}],defaultColumns:["department_name","custom_organization","custom_management","custom_status"]},branches:{label:"Branches",orgField:"organization",columns:[{key:"branch",label:"Branch"},{key:"organization",label:"Organization"},{key:"management",label:"Management"},{key:"department",label:"Department"},{key:"custom_status",label:"Status"},{key:"custom_creation_date",label:"Created On"}],defaultColumns:["branch","organization","management","department","custom_status"]},cycles:{label:"Cycles",orgField:"organization",columns:[{key:"name1",label:"Name"},{key:"organization",label:"Organization"},{key:"frequency",label:"Frequency"},{key:"status",label:"Status"},{key:"start_date",label:"Start Date"},{key:"end_date",label:"End Date"},{key:"update_window_days",label:"Update Window (days)"}],defaultColumns:["name1","organization","frequency","status","start_date","end_date"]},"kpi-input":{label:"KPI Input",orgField:"organization",columns:[{key:"organization",label:"Organization"},{key:"period",label:"Period"},{key:"revenue_growth",label:"Revenue Growth"},{key:"net_profit",label:"Net Profit"},{key:"cash_flow",label:"Cash Flow"},{key:"strategic_goal_pct",label:"Strategic Goal %"},{key:"customer_satisfaction",label:"Customer Satisfaction"},{key:"employee_turnover_pct",label:"Employee Turnover %"},{key:"open_safety_incidents",label:"Open Safety Incidents"},{key:"compliance_score",label:"Compliance Score"}],defaultColumns:["organization","period","revenue_growth","net_profit","cash_flow"]},"incident-types":{label:"Incident Types",columns:En(),defaultColumns:["name1","status","creation_date"]},"idea-types":{label:"Idea Types",columns:En(),defaultColumns:["name1","status","creation_date"]},"order-types":{label:"Order Types",columns:En(),defaultColumns:["name1","status","creation_date"]},"process-types":{label:"Process Types",columns:En(),defaultColumns:["name1","status","creation_date"]},"incident-statuses":{label:"Incident Statuses",columns:En([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"idea-statuses":{label:"Idea Statuses",columns:En([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"order-statuses":{label:"Order Statuses",columns:En([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"process-statuses":{label:"Process Statuses",columns:En([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},users:{label:"Users",orgField:"custom_organization",columns:[{key:"full_name",label:"Full Name"},{key:"email",label:"Email"},{key:"username",label:"Username"},{key:"mobile_no",label:"Phone"},{key:"custom_category",label:"Category"},{key:"custom_organization",label:"Organization"},{key:"custom_management",label:"Management"},{key:"custom_department",label:"Department"},{key:"custom_branch",label:"Branch"},{key:"custom_number",label:"User ID No"},{key:"enabled",label:"Active"},{key:"creation",label:"Created On"}],defaultColumns:["full_name","email","custom_category","custom_organization","enabled"]},delegations:{label:"Delegations",orgField:"organization",columns:[{key:"number",label:"Number"},{key:"auditor",label:"Auditor"},{key:"manager",label:"Manager"},{key:"organization",label:"Organization"},{key:"create_processes",label:"Create Processes"},{key:"update_process_status",label:"Update Process Status"},{key:"status",label:"Status"},{key:"requested_on",label:"Requested On"},{key:"responded_on",label:"Responded On"}],defaultColumns:["number","auditor","manager","organization","status","requested_on"]}},iy=()=>n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),oy=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),dy=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("polyline",{points:"3 6 5 6 21 6"}),n.jsx("path",{d:"M19 6l-1 14H6L5 6"}),n.jsx("path",{d:"M10 11v6M14 11v6"}),n.jsx("path",{d:"M9 6V4h6v2"})]});function nt({onView:e,onEdit:t,onDelete:s}){const r=(l,a,i,c,d,f)=>c?n.jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),c()},title:f,style:{width:30,height:30,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:"1px solid transparent",cursor:"pointer",background:l,color:i,flexShrink:0,transition:"all 0.15s ease"},onMouseEnter:v=>{v.currentTarget.style.background=a,v.currentTarget.style.transform="scale(1.08)"},onMouseLeave:v=>{v.currentTarget.style.background=l,v.currentTarget.style.transform="scale(1)"},children:d},f):null;return n.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[r("#f0f9ff","#e0f2fe","#0284c7",e,n.jsx(iy,{}),"View"),r("#f0fdf4","#dcfce7","#16a34a",t,n.jsx(oy,{}),"Edit"),s&&r("#fff1f2","#fee2e2","#e11d48",s,n.jsx(dy,{}),"Delete")]})}const I={width:"100%",height:34,padding:"7px 10px",border:"1px solid #ddd",borderRadius:6,fontSize:12,boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif"},z={display:"block",marginBottom:5,fontSize:11,color:"#555",fontWeight:600};function cy(e){return typeof(e==null?void 0:e.is_active)<"u"?!!e.is_active:typeof(e==null?void 0:e.status)<"u"?e.status!=="Inactive":typeof(e==null?void 0:e.custom_status)<"u"?e.custom_status!=="Inactive":!0}function me(e,t){return e.filter(s=>cy(s)||s.name===t)}const uy={incident:["Rejected","Executed & Closed"],idea:["Rejected","Executed & Closed"],order:["Closed"],process:["Closed"]};function Nn(e,t){return!!t&&uy[e].includes(t)}function Sr(e,t,s,r){return e.filter(l=>{const a=t[l.name]||[];return!(a.includes("SB Admin")||a.includes("System Manager")||!a.includes(s)||r&&l.custom_organization&&l.custom_organization!==r)})}const wr={width:16,height:16,cursor:"pointer",accentColor:"#2563eb",flexShrink:0};function fa(e){const t=(e||"").trim().toLowerCase();return t==="new"||t==="initial evaluation"||t==="draft"?{bg:"#eff6ff",color:"#1d4ed8",border:"#bfdbfe"}:t.includes("progress")||t.includes("review")||t.includes("proposal")||t.includes("resolution")?{bg:"#fefce8",color:"#a16207",border:"#fef08a"}:t.includes("executed")||t.includes("approved")||t.includes("active")||t.includes("closed")||t.includes("completed")?{bg:"#f0fdf4",color:"#15803d",border:"#bbf7d0"}:t.includes("rejected")||t.includes("overdue")||t.includes("fail")||t.includes("inactive")?{bg:"#fef2f2",color:"#b91c1c",border:"#fecaca"}:t.includes("deleted")?{bg:"#fff1f2",color:"#e11d48",border:"#fecdd3"}:{bg:"#f8fafc",color:"#475569",border:"#e2e8f0"}}function py(e){const t=(e||"").trim().toLowerCase();return t.includes("incident")?{bg:"#f1f5f9",color:"#334155",border:"#cbd5e1"}:t.includes("complaint")?{bg:"#fff7ed",color:"#c2410c",border:"#fed7aa"}:t.includes("violation")?{bg:"#faf5ff",color:"#7e22ce",border:"#e9d5ff"}:t.includes("process")?{bg:"#f0fdfa",color:"#0f766e",border:"#99f6e4"}:t.includes("asset")?{bg:"#ecfeff",color:"#0e7490",border:"#a5f3fc"}:t.includes("human")?{bg:"#f5f3ff",color:"#6d28d9",border:"#ddd6fe"}:t.includes("idea")?{bg:"#ecfdf5",color:"#047857",border:"#a7f3d0"}:t.includes("study")?{bg:"#eff6ff",color:"#1d4ed8",border:"#bfdbfe"}:{bg:"#f8fafc",color:"#475569",border:"#e2e8f0"}}const bl=(e,t)=>{let s;return typeof t=="object"&&t!==null?s=t:typeof t=="string"&&t.startsWith("#")?s=fa(e):typeof t=="string"?s=fa(t):s=fa(e),n.jsx("span",{className:"status-badge",style:{background:s.bg,color:s.color,border:`1px solid ${s.border}`,padding:"2px 8px",borderRadius:9999,fontSize:11,fontWeight:600,letterSpacing:"0.2px",display:"inline-flex",alignItems:"center",justifyContent:"center",lineHeight:1.3,whiteSpace:"nowrap",boxSizing:"border-box",transition:"all 0.15s ease"},children:e})},Xn=e=>bl(e,fa(e)),Rd=e=>bl(e,py(e));function zl({deletedBy:e,deletedOn:t,reason:s,onRestore:r,isRestoring:l}){return n.jsxs("div",{style:{background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:8,padding:"12px 16px",marginBottom:16,display:"flex",alignItems:"center",justifyContent:"space-between",color:"#991b1b",fontSize:13},children:[n.jsxs("div",{children:[n.jsxs("div",{style:{fontWeight:700,fontSize:14,display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[n.jsx("span",{children:"⚠️"}),n.jsx("span",{children:"DELETED RECORD / سجل محذوف"})]}),n.jsxs("div",{style:{fontSize:12,color:"#7f1d1d"},children:[e&&n.jsxs("span",{children:[n.jsx("strong",{children:"Deleted By:"})," ",e," "]}),t&&n.jsxs("span",{children:["| ",n.jsx("strong",{children:"Deleted On:"})," ",t," "]}),s&&n.jsxs("div",{children:[n.jsx("strong",{children:"Reason:"})," ",s]})]})]}),r&&n.jsxs("button",{onClick:r,disabled:l,style:{background:"#dc2626",color:"white",border:"none",borderRadius:6,padding:"8px 16px",fontSize:12,fontWeight:700,cursor:l?"not-allowed":"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",display:"flex",alignItems:"center",gap:6},children:[n.jsx("span",{children:"↺"}),n.jsx("span",{children:l?"Restoring...":"Restore Record / استعادة"})]})]})}function ni({onDelete:e,disabled:t,title:s="Delete Request",btnText:r="Delete"}){return n.jsxs("div",{style:{background:"#ffffff",borderRadius:10,padding:14,border:"1px solid #fee2e2",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:s}),n.jsxs("button",{type:"button",onClick:e,disabled:t,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:"#dc2626",color:"#ffffff",fontWeight:700,fontSize:12,cursor:t?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:6,boxShadow:"0 1px 3px rgba(220, 38, 38, 0.25)",transition:"all 0.15s ease"},onMouseEnter:l=>{t||(l.currentTarget.style.background="#b91c1c")},onMouseLeave:l=>{t||(l.currentTarget.style.background="#dc2626")},children:[n.jsx("span",{children:"🗑️"}),n.jsx("span",{children:r})]})]})}function ae({title:e,children:t,style:s}){return n.jsxs("div",{style:{background:"#ffffff",borderRadius:10,border:"1px solid #e2e8f0",padding:"16px 20px",marginBottom:16,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.03)",...s},children:[n.jsx("div",{style:{fontSize:14,fontWeight:700,color:"#1e293b",marginBottom:14,display:"flex",alignItems:"center",gap:8},children:n.jsx("span",{children:e})}),t]})}function si({title:e="Status Summary",priority:t,createdDate:s,modifiedDate:r,assignedTo:l,status:a}){const i=c=>{if(!c)return"—";try{const d=new Date(c);return isNaN(d.getTime())?c:d.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return c}};return n.jsxs("div",{style:{background:"#ffffff",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:12},children:e}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t&&n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:3},children:"Priority"}),n.jsx("div",{style:{fontSize:13,fontWeight:700,color:t==="High"||t==="Urgent"?"#dc2626":"#1e293b"},children:t})]}),a&&n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:3},children:"Status"}),n.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#334155"},children:a})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:3},children:"Assigned To"}),n.jsx("div",{style:{fontSize:12,fontWeight:600,color:l?"#334155":"#94a3b8",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l||"—"})]}),s&&n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:2},children:"Created"}),n.jsx("div",{style:{fontSize:11,color:"#64748b"},children:i(s)})]}),r&&n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:2},children:"Last Modified"}),n.jsx("div",{style:{fontSize:11,color:"#64748b"},children:i(r)})]})]})]})}const fy="modulepreload",hy=function(e){return"/"+e},yu={},gy=function(t,s,r){let l=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),c=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));l=Promise.allSettled(s.map(d=>{if(d=hy(d),d in yu)return;yu[d]=!0;const f=d.endsWith(".css"),v=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${v}`))return;const p=document.createElement("link");if(p.rel=f?"stylesheet":fy,f||(p.as="script"),p.crossOrigin="",p.href=d,c&&p.setAttribute("nonce",c),document.head.appendChild(p),f)return new Promise((u,m)=>{p.addEventListener("load",u),p.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${d}`)))})}))}function a(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return l.then(i=>{for(const c of i||[])c.status==="rejected"&&a(c.reason);return t().catch(a)})};function Jf(e,t){const s=e[t.key];return s==null||s===""?"":typeof s=="object"?JSON.stringify(s):String(s)}function xy(e,t){const s=URL.createObjectURL(e),r=document.createElement("a");r.href=s,r.download=t,r.click(),URL.revokeObjectURL(s)}function my(e,t,s){const r=e.map(i=>`"${i.label.replace(/"/g,'""')}"`).join(","),l=t.map(i=>e.map(c=>`"${Jf(i,c).replace(/"/g,'""')}"`).join(",")).join(`
|
||
`),a=new Blob([r+`
|
||
`+l],{type:"text/csv;charset=utf-8;"});xy(a,`${s}.csv`)}async function yy(e,t,s){const r=await gy(()=>import("./xlsx-D_0l8YDs.js"),[]),l=t.map(c=>{const d={};for(const f of e)d[f.label]=Jf(c,f);return d}),a=r.utils.json_to_sheet(l,{header:e.map(c=>c.label)}),i=r.utils.book_new();r.utils.book_append_sheet(i,a,"Export"),r.writeFile(i,`${s}.xlsx`)}const ql="#16a34a";function vy({title:e,rows:t,columns:s,defaultColumnKeys:r,orgField:l,organizations:a,filenameBase:i,onClose:c}){const[d,f]=w.useState(""),[v,p]=w.useState("csv"),[u,m]=w.useState(new Set(r)),j=d?t.filter(y=>y[l||"organization"]===d):t,h=s.filter(y=>u.has(y.key)),S=y=>{m(_=>{const C=new Set(_);return C.has(y)?C.delete(y):C.add(y),C})},g=async()=>{h.length===0||j.length===0||(v==="csv"?my(h,j,i):await yy(h,j,i),c())},x={fontSize:11,fontWeight:700,color:"#9ca3af",letterSpacing:.4,textTransform:"uppercase",marginBottom:10},o={background:"none",border:"none",color:"#2563eb",fontSize:12,fontWeight:600,cursor:"pointer",padding:0,fontFamily:"inherit"};return n.jsx("div",{onClick:c,style:{position:"fixed",inset:0,background:"rgba(15,23,42,0.55)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},children:n.jsxs("div",{onClick:y=>y.stopPropagation(),style:{width:560,maxWidth:"92vw",maxHeight:"86vh",background:"white",borderRadius:12,boxShadow:"0 20px 60px rgba(0,0,0,0.3)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[n.jsxs("div",{style:{background:ql,color:"white",padding:"16px 22px",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:16,fontWeight:700},children:[n.jsx("span",{style:{fontSize:18},children:"📤"})," Export ",e]}),n.jsx("button",{onClick:c,style:{background:"rgba(255,255,255,0.15)",border:"none",color:"white",width:28,height:28,borderRadius:8,cursor:"pointer",fontSize:15,lineHeight:1},children:"✕"})]}),n.jsxs("div",{style:{padding:"20px 22px",overflowY:"auto",flex:1},children:[l&&a&&a.length>0&&n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:x,children:"Filter by Organization"}),n.jsxs("select",{value:d,onChange:y=>f(y.target.value),style:{width:"100%",padding:"9px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",boxSizing:"border-box"},children:[n.jsxs("option",{value:"",children:["All Organizations (",t.length," total)"]}),a.map(y=>n.jsx("option",{value:y.name,children:y.organization_name||y.name},y.name))]})]}),n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:x,children:"File Format"}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[{id:"csv",label:"CSV",desc:"Comma-separated values"},{id:"xlsx",label:"Excel",desc:"XLSX spreadsheet"}].map(y=>n.jsxs("div",{onClick:()=>p(y.id),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",borderRadius:10,cursor:"pointer",border:`2px solid ${v===y.id?ql:"#e5e7eb"}`,background:v===y.id?"#f0fdf4":"white"},children:[n.jsx("span",{style:{fontSize:20},children:y.id==="csv"?"📄":"📊"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:y.label}),n.jsx("div",{style:{fontSize:11,color:"#888"},children:y.desc})]})]},y.id))})]}),n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[n.jsx("div",{style:{...x,marginBottom:0},children:"Columns to Export"}),n.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[n.jsx("button",{onClick:()=>m(new Set(s.map(y=>y.key))),style:o,children:"Select All"}),n.jsx("span",{style:{color:"#d1d5db"},children:"|"}),n.jsx("button",{onClick:()=>m(new Set(r)),style:o,children:"Reset to Default"})]})]}),n.jsx("div",{style:{border:"1px solid #e5e7eb",borderRadius:8,padding:12,maxHeight:170,overflowY:"auto"},children:n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"10px 12px"},children:s.map(y=>n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:7,fontSize:13,color:"#374151",cursor:"pointer"},children:[n.jsx("input",{type:"checkbox",checked:u.has(y.key),onChange:()=>S(y.key),style:{accentColor:ql,cursor:"pointer"}}),y.label]},y.key))})}),n.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:6},children:[u.size," column",u.size!==1?"s":""," selected"]})]})]}),n.jsxs("div",{style:{padding:"14px 22px",borderTop:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[n.jsx("span",{style:{fontSize:12,color:"#888"},children:d?`Exporting ${j.length} filtered row${j.length!==1?"s":""}`:`Exporting all ${j.length} row${j.length!==1?"s":""}`}),n.jsxs("div",{style:{display:"flex",gap:10},children:[n.jsx("button",{onClick:c,style:{padding:"9px 18px",borderRadius:8,border:"1px solid #e5e7eb",background:"white",color:"#374151",fontWeight:600,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:"Cancel"}),n.jsx("button",{onClick:g,disabled:h.length===0||j.length===0,style:{padding:"9px 20px",borderRadius:8,border:"none",background:ql,color:"white",fontWeight:700,fontSize:13,cursor:h.length===0||j.length===0?"not-allowed":"pointer",opacity:h.length===0||j.length===0?.5:1,fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"})]})]})]})})}const Zf="sidrah_rtl",Oo="sidrah-lang-change";function or(){try{return localStorage.getItem(Zf)==="1"}catch{return!1}}function Vf(){const e=!or();try{localStorage.setItem(Zf,e?"1":"0")}catch{}document.documentElement.setAttribute("dir",e?"rtl":"ltr"),document.documentElement.setAttribute("lang",e?"ar":"en-GB"),window.dispatchEvent(new CustomEvent(Oo))}function se(){const[e,t]=w.useState(or);return w.useEffect(()=>{const s=()=>t(or());return window.addEventListener(Oo,s),document.documentElement.setAttribute("dir",or()?"rtl":"ltr"),document.documentElement.setAttribute("lang",or()?"ar":"en-GB"),()=>window.removeEventListener(Oo,s)},[]),e?by:jy}const jy={rtl:!1,nav:{dashboard:"Dashboard",inbox:"Inbox",incidents:"Incidents",ideas:"Ideas",orders:"Orders",processes:"Processes",delegations:"Delegations",reports:"Reports",users:"Users",organizations:"Organizations",managements:"Managements",departments:"Departments",branches:"Branches",cycles:"Cycles","kpi-input":"KPI Input","incident-types":"Incident Types","idea-types":"Idea Types","order-types":"Order Types","process-types":"Process Types","incident-statuses":"Incident Statuses","idea-statuses":"Idea Statuses","order-statuses":"Order Statuses","process-statuses":"Process Statuses",settings:"Settings"},pages:{dashboard:"Dashboard",inbox:"Inbox",reports:"Reports",incidents:"Incidents",ideas:"Ideas",orders:"Orders",processes:"Processes",delegations:"Delegations",organizations:"Organizations",managements:"Managements",departments:"Departments",branches:"Branches",cycles:"Cycles","kpi-input":"KPI Input","incident-types":"Incident Types","idea-types":"Idea Types","order-types":"Order Types","process-types":"Process Types","incident-statuses":"Incident Statuses","idea-statuses":"Idea Statuses","order-statuses":"Order Statuses","process-statuses":"Process Statuses",users:"Users"},new:"+ New",save:"Save",cancel:"Cancel",edit:"Edit",delete:"Delete",deletedBadge:"DELETED",restore:"Restore",restoring:"Restoring...",restoredOk:"Record restored successfully!",deletedBanner:"⚠️ This record has been deleted",deletedBy:"Deleted by",deletedOn:"Deleted on",deletedReason:"Reason",deleteModal:{title:"Confirm Deletion",subtitle:"Are you sure you want to delete this record?",softDeleteTitle:"Delete",softDeleteDesc:"Moves the record to deleted state. It can be restored later by an Administrator.",permanentDeleteTitle:"Permanent Delete",permanentDeleteDesc:"Permanently removes this record from the database. This action cannot be undone.",reasonLabel:"Reason for deletion (optional):",reasonPlaceholder:"Enter deletion reason…",softDeleteBtn:"Delete",permanentDeleteBtn:"Permanent Delete",cancelBtn:"Cancel",deleting:"Deleting…"},view:"View",back:"← Back",clear:"Clear",search:"Search",loading:"Loading...",saving:"Saving...",savedOk:"Saved successfully!",home:"Home",noRecords:"No records found",login:{subtitle:"Sign in to continue",username:"USERNAME",password:"PASSWORD",usernamePlaceholder:"Enter username",passwordPlaceholder:"Enter password",signIn:"Sign In",signingIn:"Signing in...",invalidCreds:"Invalid username or password",emptyFields:"Please enter username and password",connError:"Connection error: "},myProfile:"My Profile",signOut:"Sign Out",switchLang:"العربية (RTL)",filter:{numberTitle:"Number / Title",searchPlaceholder:"Search...",organization:"Organization",department:"Department",branch:"Branch",status:"Status",allOrgs:"All Organizations",allDepts:"All Departments",allBranches:"All Branches",allStatuses:"All Statuses",allTypes:"All Types"},col:{number:"Number",title:"Title",organization:"Organization",type:"Type",status:"Status",actions:"Actions",name:"Name",department:"Department",branch:"Branch",city:"City",email:"Email",management:"Management",organization_type:"Type",frequency:"Frequency",period:"Period",startDate:"Start Date",endDate:"End Date",auditor:"Auditor",manager:"Manager",functions:"Functions",requestedOn:"Requested On"},field:{number:"Number",title:"Title",organization:"Organization",management:"Management",department:"Department",section:"Section",branch:"Branch",type:"Type",date:"Date",time:"Time",status:"Status",description:"Description",assignedTo:"Assigned To",hsesField:"HSES Field",priority:"Priority",economyClass:"Economy Class",entityScope:"Entity Scope",productRelation:"Product Relation",repeatedEvent:"Repeated Event",solution:"Solution / Action Plan",actualCost:"Actual Cost",summary:"Resolution Summary",auditorComment:"Auditor Comment",incidentClass:"Incident Class",incidentField:"Incident Field",currentCondition:"Current Condition",proposedCondition:"Proposed Condition",ideaClass:"Idea Class",startingDate:"Starting Date",endingDate:"Ending Date",budget:"Budget",currency:"Currency",notes:"Notes",cycle:"Cycle",stage:"Stage",completionPct:"Completion %",actor:"Actor",escalationLevel:"Escalation Level",dateStart:"Start Date",dateEnd:"End Date",cycleType:"Cycle Type",progressIndicators:"Progress Indicators",impactLevel:"Impact Level",kpiName:"KPI Name",kpiType:"KPI Type",kpiMeasure:"KPI Measure",costPerCycle:"Cost per Cycle",chainLocation:"Chain Location",notifyManager:"Notify Manager",creationDate:"Creation Date",statusActive:"Active",statusInactive:"Inactive",name1:"Name",fullName:"Full Name",username:"Username",emailAddress:"Email Address",phoneNumber:"Phone Number",category:"Category",since:"Since",active:"Active",inactive:"Inactive",enabled:"Enabled",selectMgr:"-- Select manager --",select:"-- Select --",selectType:"-- Select type --",selectClass:"-- Select class --",selectField:"-- Select field --",selectStatus:"-- Select status --",solutionPlaceholder:"Describe the solution or action taken…",commentPlaceholder:"Optional comment…",high:"High",normal:"Normal",expenses:"Expenses",capital:"Capital",earn:"Earn",payLoss:"Pay/Loss",upstream:"Upstream",onstream:"On-stream",downstream:"Downstream",government:"Government",private:"Private",linkedOrder:"Linked Order",linkedIdea:"Linked Idea",convertedToOrder:"Converted to Order",originatingIdea:"Originating Idea",viewOrder:"View Order",viewIdea:"View Idea",monthly:"Monthly",quarterly:"Quarterly",yearly:"Yearly",cycleActive:"Active",cycleCompleted:"Completed",cyclePaused:"Paused",updateWindowDays:"Update Window (days)",incidentTriageWindowDays:"Triage Window (days)",incidentResolutionWindowDays:"Resolution Window (days)",orgAcronym:"Acronym",contactEmail:"Contact Email",orgCity:"City",orgName:"Organization Name",organizationType:"Organization Type",revenue_growth:"Revenue Growth (%)",net_profit:"Net Profit",cash_flow:"Cash Flow",strategic_goal_pct:"Strategic Goal (%)",customer_satisfaction:"Customer Satisfaction",employee_turnover_pct:"Employee Turnover (%)",open_safety_incidents:"Open Safety Incidents",compliance_score:"Compliance Score"},wf:{workflow:"Workflow",noActions:"No actions available for your role in this state.",applying:"Applying…",submit:"Submit",assignToManager:"Assign to Manager",reject:"Reject",submitSolution:"Submit Solution",resolutionComplete:"Resolution complete",moveToOutsourcing:"Move to Outsourcing",closeIdea:"Close Idea"},steps:{auditorTriage:"Auditor Triage (Step 2)",managerSolution:"Manager Solution (Step 3)",ownerComment:"Owner / Auditor Comment (Step 4)",auditorEval:"Auditor Evaluation (Step 2)",managerReview:"Manager Review (Step 3)"},formTitle:{newIncident:"New Incident",editIncident:"Edit Incident",viewIncident:"Incident: ",newIdea:"New Idea",editIdea:"Edit Idea",viewIdea:"Idea: ",newOrder:"New Order",editOrder:"Edit Order",viewOrder:"Order: ",newProcess:"New Process",editProcess:"Edit Process",viewProcess:"Process: ",newOrg:"New Organization",editOrg:"Edit Organization",newMgmt:"New Management",editMgmt:"Edit Management",newDept:"New Department",editDept:"Edit Department",newBranch:"New Branch",editBranch:"Edit Branch",newUser:"New User",editUser:"Edit User",viewUser:"User Profile",newCycle:"New Cycle",editCycle:"Edit Cycle",newKpi:"New KPI Input",editKpi:"Edit KPI Input",newDelegation:"New Delegation",viewDelegation:"Delegation: "},saveIncident:"Save Incident",saveIdea:"Save Idea",saveOrder:"Save Order",saveProcess:"Save Process",saveOrg:"Save Organization",saveMgmt:"Save Management",saveDept:"Save Department",saveBranch:"Save Branch",saveUser:"Save User",saveCycle:"Save Cycle",saveKpi:"Save KPI Input",saveDelegation:"Send Delegation",saveName:"Save",dash:{allOrgs:"All organizations",incidents:"Incidents",ideas:"Ideas",orders:"Orders",processes:"Processes",level2:"Level 2 — Critical Escalation",level1:"Level 1 — Auditor Review Needed",overduePrefix:"Overdue for Triage — ",overdueSuffix:" incident(s) past 3-day window",untriaged:"Untriaged Incidents",recentKpi:"Recent KPI Inputs",manageKpi:"Manage KPI Inputs",escalatedProcesses:"Escalated Processes",escalatedOrders:"Escalated Orders",level:"Level",revenueGrowth:"Revenue Growth",netProfit:"Net Profit",strategicGoal:"Strategic Goal",customerSat:"Customer Sat.",compliance:"Compliance",safetyInc:"Safety Incidents",total:"Total"},noIncidents:"No incidents found",noIdeas:"No ideas found",noOrders:"No orders found",noProcesses:"No processes found",noUsers:"No users found",noData:"No data found",users:{category:"Category",number:"Number",fullName:"Full Name",username:"Username",email:"Email Address",phone:"Phone Number",organization:"Organization",management:"Management",department:"Department",branch:"Branch",since:"Since",status:"Status",tools:"Tools",active:"Active",inactive:"Inactive",setPassword:"Set Password",newPassword:"New password",passwordUpdated:"Password updated!",passwordFailed:"Failed. Please try again.",disableConfirm:"Delete user? They will no longer appear in the list.",password:"Password"},inbox:{title:"Inbox",noMessages:"No messages"},reports:{title:"Reports",selectOrg:"Select Organization",generate:"Generate Report"},comments:{title:"Comments",placeholder:"Write a comment…",post:"Post",noComments:"No comments yet."},activity:{title:"Activity Log",created:"Created",by:"by"}},by={rtl:!0,nav:{dashboard:"لوحة التحكم",inbox:"البريد الوارد",incidents:"الحوادث",ideas:"الأفكار",orders:"الطلبات",processes:"العمليات",delegations:"التفويضات",reports:"التقارير",users:"المستخدمون",organizations:"المؤسسات",managements:"الإدارات",departments:"الأقسام",branches:"الفروع",cycles:"الدورات","kpi-input":"مؤشرات الأداء","incident-types":"أنواع الحوادث","idea-types":"أنواع الأفكار","order-types":"أنواع الطلبات","process-types":"أنواع العمليات","incident-statuses":"حالات الحوادث","idea-statuses":"حالات الأفكار","order-statuses":"حالات الطلبات","process-statuses":"حالات العمليات",settings:"الإعدادات"},pages:{dashboard:"لوحة التحكم",inbox:"البريد الوارد",reports:"التقارير",incidents:"الحوادث",ideas:"الأفكار",orders:"الطلبات",processes:"العمليات",delegations:"التفويضات",organizations:"المؤسسات",managements:"الإدارات",departments:"الأقسام",branches:"الفروع",cycles:"الدورات","kpi-input":"مؤشرات الأداء","incident-types":"أنواع الحوادث","idea-types":"أنواع الأفكار","order-types":"أنواع الطلبات","process-types":"أنواع العمليات","incident-statuses":"حالات الحوادث","idea-statuses":"حالات الأفكار","order-statuses":"حالات الطلبات","process-statuses":"حالات العمليات",users:"المستخدمون"},new:"+ جديد",save:"حفظ",cancel:"إلغاء",edit:"تعديل",delete:"حذف",deletedBadge:"محذوف",restore:"استعادة",restoring:"جارٍ الاستعادة...",restoredOk:"تمت استعادة السجل بنجاح!",deletedBanner:"⚠️ هذا السجل محذوف",deletedBy:"تم الحذف بواسطة",deletedOn:"تاريخ الحذف",deletedReason:"السبب",deleteModal:{title:"تأكيد الحذف",subtitle:"هل أنت متأكد من رغبتك في حذف هذا السجل؟",softDeleteTitle:"حذف",softDeleteDesc:"يتم نقل السجل إلى سلة المحذوفات. يمكن للمسؤول استعادته لاحقاً.",permanentDeleteTitle:"حذف نهائي",permanentDeleteDesc:"حذف السجل نهائياً من قاعدة البيانات. لا يمكن التراجع عن هذا الإجراء.",reasonLabel:"سبب الحذف (اختياري):",reasonPlaceholder:"أدخل سبب الحذف…",softDeleteBtn:"حذف",permanentDeleteBtn:"حذف نهائي",cancelBtn:"إلغاء",deleting:"جارٍ الحذف…"},view:"عرض",back:"رجوع →",clear:"مسح",search:"بحث",loading:"جارٍ التحميل...",saving:"جارٍ الحفظ...",savedOk:"تم الحفظ بنجاح!",home:"الرئيسية",noRecords:"لا توجد سجلات",login:{subtitle:"تسجيل الدخول للمتابعة",username:"اسم المستخدم",password:"كلمة المرور",usernamePlaceholder:"أدخل اسم المستخدم",passwordPlaceholder:"أدخل كلمة المرور",signIn:"تسجيل الدخول",signingIn:"جارٍ تسجيل الدخول...",invalidCreds:"اسم المستخدم أو كلمة المرور غير صحيحة",emptyFields:"الرجاء إدخال اسم المستخدم وكلمة المرور",connError:"خطأ في الاتصال: "},myProfile:"ملفي الشخصي",signOut:"تسجيل الخروج",switchLang:"English (LTR)",filter:{numberTitle:"الرقم / العنوان",searchPlaceholder:"بحث...",organization:"المؤسسة",department:"القسم",branch:"الفرع",status:"الحالة",allOrgs:"جميع المؤسسات",allDepts:"جميع الأقسام",allBranches:"جميع الفروع",allStatuses:"جميع الحالات",allTypes:"جميع الأنواع"},col:{number:"الرقم",title:"العنوان",organization:"المؤسسة",type:"النوع",status:"الحالة",actions:"الإجراءات",name:"الاسم",department:"القسم",branch:"الفرع",city:"المدينة",email:"البريد الإلكتروني",management:"الإدارة",organization_type:"النوع",frequency:"التكرار",period:"الفترة",startDate:"تاريخ البدء",endDate:"تاريخ الانتهاء",auditor:"المدقق",manager:"المدير",functions:"الوظائف",requestedOn:"تاريخ الطلب"},field:{number:"الرقم",title:"العنوان",organization:"المؤسسة",management:"الإدارة",department:"القسم",section:"القطاع",branch:"الفرع",type:"النوع",date:"التاريخ",time:"الوقت",status:"الحالة",description:"الوصف",assignedTo:"مُسند إلى",hsesField:"مجال السلامة والصحة",priority:"الأولوية",economyClass:"التصنيف الاقتصادي",entityScope:"نطاق الكيان",productRelation:"علاقة المنتج",repeatedEvent:"حدث متكرر",solution:"الحل / خطة العمل",actualCost:"التكلفة الفعلية",summary:"ملخص الحل",auditorComment:"تعليق المدقق",incidentClass:"تصنيف الحادث",incidentField:"مجال الحادث",currentCondition:"الوضع الراهن",proposedCondition:"الوضع المقترح",ideaClass:"تصنيف الفكرة",startingDate:"تاريخ البدء",endingDate:"تاريخ الانتهاء",budget:"الميزانية",currency:"العملة",notes:"الملاحظات",cycle:"الدورة",stage:"المرحلة",completionPct:"نسبة الاكتمال",actor:"المنفذ",escalationLevel:"مستوى التصعيد",dateStart:"تاريخ البدء",dateEnd:"تاريخ الانتهاء",cycleType:"نوع الدورة",progressIndicators:"مؤشرات التقدم",impactLevel:"مستوى التأثير",kpiName:"اسم المؤشر",kpiType:"نوع المؤشر",kpiMeasure:"قياس المؤشر",costPerCycle:"التكلفة لكل دورة",chainLocation:"موقع السلسلة",notifyManager:"إشعار المدير",creationDate:"تاريخ الإنشاء",statusActive:"نشط",statusInactive:"غير نشط",name1:"الاسم",fullName:"الاسم الكامل",username:"اسم المستخدم",emailAddress:"البريد الإلكتروني",phoneNumber:"رقم الهاتف",category:"الفئة",since:"منذ",active:"نشط",inactive:"غير نشط",enabled:"مفعّل",selectMgr:"-- اختر المدير --",select:"-- اختر --",selectType:"-- اختر النوع --",selectClass:"-- اختر التصنيف --",selectField:"-- اختر المجال --",selectStatus:"-- اختر الحالة --",solutionPlaceholder:"صف الحل أو الإجراء المتخذ…",commentPlaceholder:"تعليق اختياري…",high:"عالي",normal:"عادي",expenses:"مصروفات",capital:"رأس مال",earn:"إيرادات",payLoss:"دفع/خسارة",upstream:"مرحلة المنبع",onstream:"على الخط",downstream:"مرحلة المصب",government:"حكومي",private:"خاص",linkedOrder:"الأمر المرتبط",linkedIdea:"الفكرة المرتبطة",convertedToOrder:"تم التحويل إلى أمر",originatingIdea:"الفكرة الأصلية",viewOrder:"عرض الأمر",viewIdea:"عرض الفكرة",monthly:"شهري",quarterly:"ربع سنوي",yearly:"سنوي",cycleActive:"نشط",cycleCompleted:"مكتمل",cyclePaused:"موقوف",updateWindowDays:"نافذة التحديث (أيام)",incidentTriageWindowDays:"نافذة الفرز (أيام)",incidentResolutionWindowDays:"نافذة الحل (أيام)",orgAcronym:"الاختصار",contactEmail:"البريد الإلكتروني للتواصل",orgCity:"المدينة",orgName:"اسم المؤسسة",organizationType:"نوع المؤسسة",revenue_growth:"نمو الإيرادات (%)",net_profit:"صافي الربح",cash_flow:"التدفق النقدي",strategic_goal_pct:"الهدف الاستراتيجي (%)",customer_satisfaction:"رضا العملاء",employee_turnover_pct:"معدل دوران الموظفين (%)",open_safety_incidents:"حوادث السلامة المفتوحة",compliance_score:"درجة الامتثال"},wf:{workflow:"سير العمل",noActions:"لا توجد إجراءات متاحة لدورك في هذه الحالة.",applying:"جارٍ التطبيق...",submit:"إرسال",assignToManager:"تعيين للمدير",reject:"رفض",submitSolution:"إرسال الحل",resolutionComplete:"اكتمال الحل",moveToOutsourcing:"نقل للاستعانة بمصادر خارجية",closeIdea:"إغلاق الفكرة"},steps:{auditorTriage:"فرز المدقق (الخطوة 2)",managerSolution:"حل المدير (الخطوة 3)",ownerComment:"تعليق المالك / المدقق (الخطوة 4)",auditorEval:"تقييم المدقق (الخطوة 2)",managerReview:"مراجعة المدير (الخطوة 3)"},formTitle:{newIncident:"حادث جديد",editIncident:"تعديل الحادث",viewIncident:"الحادث: ",newIdea:"فكرة جديدة",editIdea:"تعديل الفكرة",viewIdea:"الفكرة: ",newOrder:"طلب جديد",editOrder:"تعديل الطلب",viewOrder:"الطلب: ",newProcess:"عملية جديدة",editProcess:"تعديل العملية",viewProcess:"العملية: ",newOrg:"مؤسسة جديدة",editOrg:"تعديل المؤسسة",newMgmt:"إدارة جديدة",editMgmt:"تعديل الإدارة",newDept:"قسم جديد",editDept:"تعديل القسم",newBranch:"فرع جديد",editBranch:"تعديل الفرع",newUser:"مستخدم جديد",editUser:"تعديل المستخدم",viewUser:"ملف المستخدم",newCycle:"دورة جديدة",editCycle:"تعديل الدورة",newKpi:"مؤشر أداء جديد",editKpi:"تعديل مؤشر الأداء",newDelegation:"تفويض جديد",viewDelegation:"التفويض: "},saveIncident:"حفظ الحادث",saveIdea:"حفظ الفكرة",saveOrder:"حفظ الطلب",saveProcess:"حفظ العملية",saveOrg:"حفظ المؤسسة",saveMgmt:"حفظ الإدارة",saveDept:"حفظ القسم",saveBranch:"حفظ الفرع",saveUser:"حفظ المستخدم",saveCycle:"حفظ الدورة",saveKpi:"حفظ مؤشر الأداء",saveDelegation:"إرسال التفويض",saveName:"حفظ",dash:{allOrgs:"جميع المؤسسات",incidents:"الحوادث",ideas:"الأفكار",orders:"الطلبات",processes:"العمليات",level2:"المستوى 2 — تصعيد حرج",level1:"المستوى 1 — مراجعة المدقق مطلوبة",overduePrefix:"متأخر للفرز — ",overdueSuffix:" حادث(ة) تجاوز نافذة 3 أيام",untriaged:"حوادث غير مفرزة",recentKpi:"مؤشرات الأداء الأخيرة",manageKpi:"إدارة مؤشرات الأداء",escalatedProcesses:"عمليات متصاعدة",escalatedOrders:"طلبات متصاعدة",level:"المستوى",revenueGrowth:"نمو الإيرادات",netProfit:"صافي الربح",strategicGoal:"الهدف الاستراتيجي",customerSat:"رضا العملاء",compliance:"الامتثال",safetyInc:"حوادث السلامة",total:"الإجمالي"},noIncidents:"لا توجد حوادث",noIdeas:"لا توجد أفكار",noOrders:"لا توجد طلبات",noProcesses:"لا توجد عمليات",noUsers:"لا يوجد مستخدمون",noData:"لا توجد بيانات",users:{category:"الفئة",number:"الرقم",fullName:"الاسم الكامل",username:"اسم المستخدم",email:"البريد الإلكتروني",phone:"رقم الهاتف",organization:"المؤسسة",management:"الإدارة",department:"القسم",branch:"الفرع",since:"منذ",status:"الحالة",tools:"الأدوات",active:"نشط",inactive:"غير نشط",setPassword:"تعيين كلمة المرور",newPassword:"كلمة مرور جديدة",passwordUpdated:"تم تحديث كلمة المرور!",passwordFailed:"فشل. الرجاء المحاولة مرة أخرى.",disableConfirm:"حذف المستخدم؟ لن يظهر في القائمة بعد الآن.",password:"كلمة المرور"},inbox:{title:"البريد الوارد",noMessages:"لا توجد رسائل"},reports:{title:"التقارير",selectOrg:"اختر المؤسسة",generate:"إنشاء التقرير"},comments:{title:"التعليقات",placeholder:"اكتب تعليقاً…",post:"نشر",noComments:"لا توجد تعليقات بعد."},activity:{title:"سجل النشاط",created:"أُنشئ",by:"بواسطة"}};function vu({isOpen:e,doctype:t,docname:s,docTitle:r,isAdmin:l,isDeleting:a,onClose:i,onConfirmSoftDelete:c,onConfirmPermanentDelete:d}){const f=se(),[v,p]=w.useState("");if(w.useEffect(()=>{e&&p("")},[e]),w.useEffect(()=>{const m=j=>{j.key==="Escape"&&e&&!a&&i()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[e,a,i]),!e)return null;const u=t.replace(/^SB\s+/,"");return n.jsx("div",{style:{position:"fixed",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:"rgba(15, 23, 42, 0.6)",backdropFilter:"blur(3px)",animation:"fadeIn 0.15s ease"},onClick:m=>{m.target===m.currentTarget&&!a&&i()},children:n.jsxs("div",{className:"delete-modal-card",style:{background:"white",borderRadius:12,boxShadow:"0 20px 35px -10px rgba(0, 0, 0, 0.22)",maxWidth:390,width:"100%",padding:"16px 18px",boxSizing:"border-box",position:"relative",animation:"scaleIn 0.15s ease",border:"1px solid rgba(226, 232, 240, 0.9)"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:12},children:[n.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"#fee2e2",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"#ef4444"},children:n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M3 6h18m-2 0v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6m3 0V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),n.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),n.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("h3",{style:{margin:0,fontSize:14,fontWeight:700,color:"#1e293b"},children:f.deleteModal.title}),n.jsx("p",{style:{margin:"2px 0 0",fontSize:11,color:"#64748b",lineHeight:1.3},children:f.deleteModal.subtitle})]}),n.jsx("button",{type:"button",onClick:i,disabled:a,style:{background:"transparent",border:"none",color:"#94a3b8",cursor:"pointer",padding:"2px 4px",borderRadius:4,fontSize:14,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]}),n.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:6,padding:"6px 10px",marginBottom:12,display:"flex",alignItems:"center",gap:6},children:[n.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#64748b",textTransform:"uppercase",letterSpacing:"0.4px",flexShrink:0},children:[u,":"]}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#1e293b",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r?`${r} (${s})`:s})]}),n.jsxs("div",{style:{marginBottom:14},children:[n.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:"#475569",marginBottom:4},children:f.deleteModal.reasonLabel}),n.jsx("input",{type:"text",value:v,onChange:m=>p(m.target.value),placeholder:f.deleteModal.reasonPlaceholder,disabled:a,style:{width:"100%",height:30,padding:"4px 8px",border:"1px solid #cbd5e1",borderRadius:6,fontSize:12,boxSizing:"border-box",outline:"none"},onFocus:m=>{m.target.style.borderColor="#6366f1",m.target.style.boxShadow="0 0 0 2px rgba(99, 102, 241, 0.15)"},onBlur:m=>{m.target.style.borderColor="#cbd5e1",m.target.style.boxShadow="none"}})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",gap:8,flexWrap:"wrap"},children:[n.jsx("button",{type:"button",onClick:i,disabled:a,style:{padding:"5px 12px",borderRadius:6,border:"1px solid #cbd5e1",background:"#ffffff",color:"#475569",fontSize:12,fontWeight:600,cursor:a?"not-allowed":"pointer",transition:"background 0.15s"},children:f.deleteModal.cancelBtn}),n.jsxs("button",{type:"button",onClick:()=>c(v),disabled:a,title:f.deleteModal.softDeleteDesc,style:{padding:"5px 12px",borderRadius:6,border:"1px solid #fca5a5",background:"#fff1f2",color:"#b91c1c",fontSize:12,fontWeight:600,cursor:a?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:4,transition:"all 0.15s"},onMouseEnter:m=>{a||(m.currentTarget.style.background="#fee2e2")},onMouseLeave:m=>{a||(m.currentTarget.style.background="#fff1f2")},children:[n.jsx("span",{children:"🗑️"}),a?f.deleteModal.deleting:f.deleteModal.softDeleteBtn]}),l&&n.jsxs("button",{type:"button",onClick:()=>d(v),disabled:a,title:f.deleteModal.permanentDeleteDesc,style:{padding:"5px 12px",borderRadius:6,border:"none",background:"#ef4444",color:"#ffffff",fontSize:12,fontWeight:600,cursor:a?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:4,boxShadow:"0 1px 3px rgba(239, 68, 68, 0.25)",transition:"all 0.15s"},onMouseEnter:m=>{a||(m.currentTarget.style.background="#dc2626")},onMouseLeave:m=>{a||(m.currentTarget.style.background="#ef4444")},children:[n.jsx("span",{children:"💥"}),a?f.deleteModal.deleting:f.deleteModal.permanentDeleteBtn]})]})]})})}const eh="/assets/logo-BlYgMyx5.png";function th({collapsed:e,onToggleCollapsed:t,activePage:s,onNavigate:r,hasDashboard:l,hasReports:a,hasDelegations:i,role:c,hideSettings:d,rtl:f,navLabels:v,settingsLabel:p}){const u=d?[]:ly(c);return n.jsxs("div",{style:{width:e?60:230,background:"linear-gradient(180deg, #0f172a 0%, #1e1b4b 60%, #0b0f19 100%)",color:"white",flexShrink:0,display:"flex",flexDirection:"column",position:"sticky",top:0,height:"100vh",transition:"width 0.22s cubic-bezier(0.4, 0, 0.2, 1)",overflow:"hidden",boxShadow:"2px 0 12px rgba(0, 0, 0, 0.15)",borderRight:"1px solid rgba(255, 255, 255, 0.06)",zIndex:40},children:[n.jsxs("div",{style:{padding:e?"16px 0":"16px 16px 14px",borderBottom:"1px solid rgba(255, 255, 255, 0.08)",display:"flex",alignItems:"center",justifyContent:e?"center":"space-between",gap:8,flexShrink:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,overflow:"hidden"},children:[n.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"white",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.25)",padding:3,boxSizing:"border-box",overflow:"hidden"},children:n.jsx("img",{src:eh,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"contain"},onError:m=>{m.currentTarget.style.display="none"}})}),!e&&n.jsx("div",{style:{display:"flex",flexDirection:"column"},children:n.jsx("span",{style:{fontSize:14,fontWeight:800,whiteSpace:"nowrap",color:"#ffffff",letterSpacing:"-0.2px"},children:f?"صدرة للأعمال":"SEERA-ASM"})})]}),n.jsx("button",{type:"button",onClick:t,title:e?f?"توسيع":"Expand":f?"طي":"Collapse",style:{background:"rgba(255, 255, 255, 0.06)",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:6,color:"rgba(255, 255, 255, 0.75)",cursor:"pointer",fontSize:11,padding:"4px 7px",flexShrink:0,lineHeight:1,transition:"all 0.15s ease"},onMouseEnter:m=>{m.currentTarget.style.background="rgba(255, 255, 255, 0.15)",m.currentTarget.style.color="#ffffff"},onMouseLeave:m=>{m.currentTarget.style.background="rgba(255, 255, 255, 0.06)",m.currentTarget.style.color="rgba(255, 255, 255, 0.75)"},children:e?"▶":"✕"})]}),n.jsxs("nav",{style:{padding:"12px 8px",flex:1,overflowY:"auto",overflowX:"hidden"},children:[sy.filter(({id:m})=>(m!=="dashboard"||l)&&(m!=="reports"||a)&&(m!=="delegations"||i)).map(({id:m,icon:j})=>{const h=v[m]||m,S=m===s;return n.jsxs("div",{onClick:()=>r(m),title:e?h:void 0,className:"sidebar-nav-item",style:{padding:e?"8px 0":"8px 12px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:10,background:S?"rgba(99, 102, 241, 0.28)":"transparent",border:S?"1px solid rgba(129, 140, 248, 0.35)":"1px solid transparent",borderRadius:8,fontSize:e?15:13,color:S?"#ffffff":"rgba(255, 255, 255, 0.78)",fontWeight:S?600:400,transition:"all 0.15s ease",whiteSpace:"nowrap",marginBottom:2,position:"relative"},onMouseEnter:g=>{S||(g.currentTarget.style.background="rgba(255, 255, 255, 0.08)",g.currentTarget.style.color="#ffffff")},onMouseLeave:g=>{S||(g.currentTarget.style.background="transparent",g.currentTarget.style.color="rgba(255, 255, 255, 0.78)")},children:[n.jsx("span",{style:{flexShrink:0,fontSize:e?15:13},children:j}),!e&&n.jsx("span",{children:h})]},m)}),u.length>0&&n.jsxs(n.Fragment,{children:[!e&&n.jsx("div",{style:{padding:"12px 12px 4px",fontSize:10,color:"rgba(255, 255, 255, 0.45)",fontWeight:700,letterSpacing:"0.8px",textTransform:"uppercase",marginTop:8},children:p}),e&&n.jsx("div",{style:{margin:"10px auto",width:26,borderTop:"1px solid rgba(255, 255, 255, 0.12)"}}),u.map(({id:m,icon:j})=>{const h=v[m]||m,S=m===s;return n.jsxs("div",{onClick:()=>r(m),title:e?h:void 0,className:"sidebar-nav-item",style:{padding:e?"8px 0":"8px 12px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:10,background:S?"rgba(99, 102, 241, 0.28)":"transparent",border:S?"1px solid rgba(129, 140, 248, 0.35)":"1px solid transparent",borderRadius:8,fontSize:e?15:13,color:S?"#ffffff":"rgba(255, 255, 255, 0.78)",fontWeight:S?600:400,transition:"all 0.15s ease",whiteSpace:"nowrap",marginBottom:2},onMouseEnter:g=>{S||(g.currentTarget.style.background="rgba(255, 255, 255, 0.08)",g.currentTarget.style.color="#ffffff")},onMouseLeave:g=>{S||(g.currentTarget.style.background="transparent",g.currentTarget.style.color="rgba(255, 255, 255, 0.78)")},children:[n.jsx("span",{style:{flexShrink:0,fontSize:e?15:13},children:j}),!e&&n.jsx("span",{children:h})]},m)})]})]})]})}const zr=new Set(["SB Incident","SB Idea","SB Order","SB Process","SB Organization","SB Cycle","SB KPI Input","Managements","Department","Branch","Incident Types","Idea Types","Order Types","Process Types","Incident Class","Incident Field","Incident Statuses","Idea Statuses","Order Statuses","Process Statuses","SB Group Company"]);let ks="";async function Dd(){try{const e=await fetch(`${ce}/api/method/sidrah_business.api.get_csrf_token`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(e.ok){const s=(await e.json()).message||"";if(s)return ks=s,s}}catch(e){console.error("CSRF fetch error:",e)}return ks}async function Jt(){return ks||await Dd(),ks}function Wa(e,t){try{if(e!=null&&e._server_messages){const s=JSON.parse(e._server_messages);if(s.length){const r=JSON.parse(s[0]);if(r!=null&&r.message)return r.message.replace(/<[^>]+>/g,"")}}}catch{}return(e==null?void 0:e.message)||(e==null?void 0:e.exception)||t}async function Tt(e,t,s=[]){if(zr.has(e)){const i=`${ce}/api/method/sidrah_business.api.get_sb_doc?doctype=${encodeURIComponent(e)}&name=${encodeURIComponent(t)}`,c=await fetch(i,{credentials:"include",headers:{Accept:"application/json"}});if(!c.ok)throw new Error(`API Error: ${c.status}`);return(await c.json()).message}const r=s.length?`?fields=${encodeURIComponent(JSON.stringify(s))}`:"",l=await fetch(`${ce}/api/v1/resource/${e}/${encodeURIComponent(t)}${r}`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!l.ok)throw new Error(`API Error: ${l.status}`);return(await l.json()).data}async function No(e,t,s="",r=!1){const l=await Jt();if(zr.has(e)){const c=new URLSearchParams({doctype:e,name:t});s&&c.append("reason",s),r&&c.append("permanent","1");const d=await fetch(`${ce}/api/method/sidrah_business.api.delete_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":l},body:c.toString()});if(!d.ok){const f=await d.json().catch(()=>({}));throw new Error(Wa(f,`Error deleting ${t}`))}return}const a=new URLSearchParams({doctype:e,name:t});s&&a.append("reason",s),r&&a.append("permanent","1");const i=await fetch(`${ce}/api/method/sidrah_business.soft_delete.soft_delete`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":l},body:a.toString()});if(!i.ok){const c=await i.json().catch(()=>({}));throw new Error(Wa(c,`Error deleting ${t}`))}return await i.json()}async function Sy(e,t){const s=await Jt();if(zr.has(e)){const a=new URLSearchParams({doctype:e,name:t}),i=await fetch(`${ce}/api/method/sidrah_business.api.restore_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:a.toString()});if(!i.ok){const d=await i.json().catch(()=>({}));throw new Error(Wa(d,`Error restoring ${t}`))}return(await i.json()).message||{success:!0}}const r=new URLSearchParams({doctype:e,name:t}),l=await fetch(`${ce}/api/method/sidrah_business.soft_delete.restore_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:r.toString()});if(!l.ok){const a=await l.json().catch(()=>({}));throw new Error(Wa(a,`Error restoring ${t}`))}return await l.json()}async function Ee(e){if(zr.has(e))try{const r=`${ce}/api/method/sidrah_business.api.get_sb_list?doctype=${encodeURIComponent(e)}&limit=500`,l=await fetch(r,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||[]:[]}catch{return[]}const t=encodeURIComponent('["*"]'),s=`${ce}/api/v1/resource/${e}?limit_page_length=500&fields=${t}`;try{const r=await fetch(s,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return r.status===401||r.status===403?[]:r.ok?(await r.json()).data||[]:[]}catch(r){return console.error("Get error:",r),[]}}async function $i(e,t){const s=await Jt();if(zr.has(e)){const l=new URLSearchParams({doctype:e,data_json:JSON.stringify(t)}),a=await fetch(`${ce}/api/method/sidrah_business.api.create_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:l.toString()});if(!a.ok){const c=await a.json().catch(()=>({}));throw new Error(c.message||c.exc||`Error creating ${e}`)}return{data:(await a.json()).message}}const r=`${ce}/api/v1/resource/${e}`;try{const l=await fetch(r,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":s},body:JSON.stringify(t)});if(l.status===401||l.status===403)throw new Error("Permission denied - login required");if(!l.ok){const a=await l.json();throw new Error(a.message||a.exc||`API Error: ${l.status}`)}return await l.json()}catch(l){throw console.error("Post error:",l),l}}async function Ba(e,t,s){const r=await Jt();if(zr.has(e)){const a=new URLSearchParams({doctype:e,name:t,data_json:JSON.stringify(s)}),i=await fetch(`${ce}/api/method/sidrah_business.api.update_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":r},body:a.toString()});if(!i.ok){const d=await i.json().catch(()=>({}));throw new Error(d.message||d.exc||`Error updating ${e}`)}return{data:(await i.json()).message}}const l=`${ce}/api/v1/resource/${e}/${encodeURIComponent(t)}`;try{const a=await fetch(l,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":r},body:JSON.stringify(s)});if(a.status===401||a.status===403)throw new Error("Permission denied - login required");if(!a.ok){const i=await a.json();throw new Error(i.message||"Update Error")}return await a.json()}catch(a){throw console.error("Update error:",a),a}}async function wy(){const e=`${ce}/api/v1/resource/User?limit_page_length=500&fields=["name","full_name"]`;try{const t=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return t.status===401||t.status===403?[]:t.ok?(await t.json()).data||[]:[]}catch(t){return console.error("Get users error:",t),[]}}async function _y(e,t){const s=new FormData;s.append("usr",e),s.append("pwd",t);const l=await(await fetch(`${ce}/api/method/login`,{method:"POST",credentials:"include",body:s})).json();return l.csrf_token?ks=l.csrf_token:await Dd(),l}async function ky(){const e=await Jt();try{await fetch(`${ce}/api/method/logout`,{method:"POST",credentials:"include",headers:{"X-Frappe-CSRF-Token":e,Accept:"application/json"}})}catch{}ks=""}function Cy(){return ks}async function nh(){try{const e=await fetch(`${ce}/api/method/frappe.auth.get_logged_user`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return e.ok&&(await e.json()).message||""}catch{return""}}async function zy(){const e=JSON.stringify([["name","not in",["Administrator","Guest"]]]),t=`${ce}/api/v1/resource/User?limit_page_length=500&fields=${encodeURIComponent('["*"]')}&filters=${encodeURIComponent(e)}`;try{const s=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).data||[]:[]}catch{return[]}}async function Ty(){const e=`${ce}/api/method/sidrah_business.api.get_user_role_map`;try{const t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||{}:{}}catch{return{}}}async function sh(e,t){await Ba("User",e,{new_password:t})}async function Iy(e=20){try{const t=`${ce}/api/method/sidrah_business.api.get_notifications?limit=${e}`,s=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function Ey(){const e=await Jt();try{await fetch(`${ce}/api/method/sidrah_business.api.mark_notifications_read`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":e}})}catch{}}async function Py(e){const t=await Jt();try{await fetch(`${ce}/api/method/sidrah_business.api.mark_notification_read`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":t},body:new URLSearchParams({name:e}).toString()})}catch{}}async function Ay(e){const t=await Jt(),s=new URLSearchParams({name:e});await fetch(`${ce}/api/method/sidrah_business.api.disable_user`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":t},body:s.toString()})}async function Ry(e,t){try{const s=`${ce}/api/method/sidrah_business.api.get_doc_comments?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(t)}`,r=await fetch(s,{credentials:"include",headers:{Accept:"application/json"}});return r.ok?(await r.json()).message||[]:[]}catch{return[]}}async function Dy(e,t,s){const r=await Jt(),l=new URLSearchParams({doctype:e,docname:t,content:s}),a=await fetch(`${ce}/api/method/sidrah_business.api.post_doc_comment`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":r},body:l.toString()});if(!a.ok)throw new Error("Failed to post comment");return(await a.json()).message}async function Ly(e,t){try{const s=`${ce}/api/method/sidrah_business.api.get_doc_versions?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(t)}`,r=await fetch(s,{credentials:"include",headers:{Accept:"application/json"}});return r.ok?(await r.json()).message||[]:[]}catch{return[]}}async function rh(e){try{const t=`${ce}/api/method/sidrah_business.api.get_user_roles?user=${encodeURIComponent(e)}`,s=await fetch(t,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function Oy(){try{const e=`${ce}/api/method/sidrah_business.api.get_my_organization`,t=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return t.ok&&(await t.json()).message||""}catch{return""}}async function Ts(e,t={}){const s=await Jt(),r=new URLSearchParams(t),l=await fetch(`${ce}/api/method/sidrah_business.api.${e}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:r.toString()});if(!l.ok){const i=await l.json().catch(()=>({}));throw new Error(i.message||i.exc||`Error calling ${e}`)}return(await l.json()).message}async function Ny(e,t,s="",r,l,a){const i={name:e,action:t,comment:s};return r!==void 0&&(i.stage=r),a!==void 0&&(i.cycle_status=a),Ts("apply_order_workflow",i)}async function Wy(e,t,s=""){return Ts("apply_incident_workflow",{name:e,action:t,fields_json:s})}async function By(e,t,s=""){return Ts("apply_idea_workflow",{name:e,action:t,fields_json:s})}async function $y(e=""){const t=`${ce}/api/method/sidrah_business.api.get_dashboard_data${e?`?organization=${encodeURIComponent(e)}`:""}`,s=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||{}:{escalated_processes:[],escalated_orders:[],untriaged_incidents:[],kpi_inputs:[]}}async function Uy(e,t={}){return Ts("get_report_data",{report_name:e,filters_json:JSON.stringify(t)})}async function Fy(){try{const e=`${ce}/api/method/sidrah_business.api.get_inbox_items`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function My(e,t,s="",r=""){return Ts("create_delegation",{manager:e,functions_json:JSON.stringify(t),organization:s,remarks:r})}async function Hy(e,t,s=""){return Ts("respond_to_delegation",{name:e,response:t,remarks:s})}async function Gy(e,t=""){return Ts("revoke_delegation",{name:e,remarks:t})}async function Ky(){try{const e=`${ce}/api/method/sidrah_business.api.get_delegations`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function Qy(e){const t=`${ce}/api/method/sidrah_business.api.get_delegation?name=${encodeURIComponent(e)}`,s=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});if(!s.ok)throw new Error("Failed to load delegation");return(await s.json()).message}async function Yy(){try{const e=`${ce}/api/method/sidrah_business.api.get_my_delegated_functions`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function Xy(){try{const e=`${ce}/api/method/sidrah_business.api.get_my_delegated_organizations`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||{}:{}}catch{return{}}}async function qy(){try{const e=await Jt(),t=await fetch(`${ce}/api/method/sidrah_business.api.get_group_companies`,{method:"GET",credentials:"include",headers:{Accept:"application/json","X-Frappe-CSRF-Token":e}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function Jy(){const e=Cy();return e||Dd()}async function Yr(e){const t=await fetch(`${ce}/api/method/sidrah_business.api.get_process?name=${encodeURIComponent(e)}`,{credentials:"include",headers:{Accept:"application/json"}});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r.message||`Failed to load process (${t.status})`)}const s=await t.json();return s.message||s.data}async function Zy(e,t,s={}){const r=await Jy(),l=new URLSearchParams({name:e,action:t});s.actor_status&&l.set("actor_status",String(s.actor_status)),s.actor_comment&&l.set("actor_comment",String(s.actor_comment)),s.progress_indicators&&l.set("progress_indicators",JSON.stringify(s.progress_indicators));const a=await fetch(`${ce}/api/method/sidrah_business.api.apply_process_workflow`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":r},body:l.toString()});if(!a.ok){const c=await a.json().catch(()=>({})),d=c.message||(c.exception?String(c.exception).split(`
|
||
`).pop():"")||c.exc_type||`Workflow action "${t}" failed (${a.status})`;throw new Error(d)}const i=await a.json();return i.message||i.data}const Vy=["dashboard","incidents","incidents-form","ideas","ideas-form","orders","orders-form","processes","processes-form","processes-workflow","organizations","organizations-form","managements","managements-form","departments","departments-form","branches","branches-form","incident-types","incident-types-form","idea-types","idea-types-form","order-types","order-types-form","process-types","process-types-form","incident-statuses","incident-statuses-form","idea-statuses","idea-statuses-form","order-statuses","order-statuses-form","process-statuses","process-statuses-form","users","users-form","cycles","cycles-form","kpi-input","kpi-input-form","delegations","delegations-form","inbox","reports","profile"],ju=new Set(Vy),e0={"incidents-form":"incidents","ideas-form":"ideas","orders-form":"orders","processes-form":"processes","processes-workflow":"processes","organizations-form":"organizations","managements-form":"managements","departments-form":"departments","branches-form":"branches","incident-types-form":"incident-types","idea-types-form":"idea-types","order-types-form":"order-types","process-types-form":"process-types","incident-statuses-form":"incident-statuses","idea-statuses-form":"idea-statuses","order-statuses-form":"order-statuses","process-statuses-form":"process-statuses","users-form":"users","cycles-form":"cycles","kpi-input-form":"kpi-input","delegations-form":"delegations",profile:"dashboard"};function bu(){const e=window.location.hash.replace(/^#\/?/,"");if(e)return ju.has(e)?e:null;const t=window.location.pathname.split("/").filter(Boolean).pop()||"";return ju.has(t)?t:null}function t0(e){return e?e0[e]??e:null}function n0(e){return`#/${e}`}function s0({onLogin:e}){const t=se(),[s,r]=w.useState(""),[l,a]=w.useState(""),[i,c]=w.useState(""),[d,f]=w.useState(!1),[v,p]=w.useState(!1),[u,m]=w.useState(!1),j=async()=>{if(!s||!l){c(t.login.emptyFields);return}f(!0),c("");try{const S=await _y(s,l);if(S.message==="Logged In"){const x=await nh()||s,o=await rh(x),y=o.some(_=>["SB Admin","System Manager"].includes(_))?"Admin":o.includes("SB Auditor")?"Auditor":o.includes("SB Owner")?"Owner":o.includes("SB X-Auditor")?"XAuditor":o.includes("SB Manager")?"Manager":"Employee";e({name:x,full_name:S.full_name||s,role:y})}else c(t.login.invalidCreds)}catch(S){c(t.login.connError+(S instanceof Error?S.message:"Unknown"))}f(!1)},h=S=>({width:"100%",padding:"11px 16px",border:`1.5px solid ${S?"#6366f1":"#e2e8f0"}`,borderRadius:8,fontSize:14,background:S?"#f8faff":"#ffffff",color:"#1e293b",outline:"none",transition:"all 0.18s ease",boxSizing:"border-box",boxShadow:S?"0 0 0 3px rgba(99, 102, 241, 0.15)":"none"});return n.jsx("div",{style:{minHeight:"100vh",background:"#f8fafc",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"Segoe UI, system-ui, sans-serif",padding:"20px"},children:n.jsxs("div",{style:{width:380,maxWidth:"100%",display:"flex",flexDirection:"column",alignItems:"center"},children:[n.jsx("div",{style:{width:72,height:72,borderRadius:18,background:"white",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:20,boxShadow:"0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04)",border:"1px solid #f1f5f9",overflow:"hidden",padding:10},children:n.jsx("img",{src:eh,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"contain"},onError:S=>{S.currentTarget.style.display="none"}})}),n.jsxs("div",{style:{textAlign:"center",marginBottom:24},children:[n.jsx("h1",{style:{fontSize:22,fontWeight:800,color:"#0f172a",letterSpacing:"-0.3px",margin:0},children:t.rtl?"صدرة للأعمال":"SEERA-ASM"}),n.jsx("div",{style:{fontSize:13,color:"#6366f1",fontWeight:600,marginTop:4},children:t.rtl?"نظام إدارة العمليات والأعمال":"Asset Management System"}),n.jsx("div",{style:{fontSize:12,color:"#94a3b8",marginTop:6},children:t.login.subtitle})]}),n.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:12},children:[n.jsx("div",{children:n.jsx("input",{value:s,onChange:S=>r(S.target.value),onKeyDown:S=>S.key==="Enter"&&j(),onFocus:()=>p(!0),onBlur:()=>p(!1),style:h(v),placeholder:t.login.usernamePlaceholder,autoComplete:"username"})}),n.jsx("div",{children:n.jsx("input",{type:"password",value:l,onChange:S=>a(S.target.value),onKeyDown:S=>S.key==="Enter"&&j(),onFocus:()=>m(!0),onBlur:()=>m(!1),style:h(u),placeholder:t.login.passwordPlaceholder,autoComplete:"current-password"})}),i&&n.jsx("div",{style:{padding:"9px 12px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:8,color:"#dc2626",fontSize:12,textAlign:"center"},children:i}),n.jsx("button",{type:"button",onClick:j,disabled:d,style:{background:d?"#818cf8":"#4f46e5",color:"white",border:"none",padding:"12px",borderRadius:8,fontSize:14,cursor:d?"not-allowed":"pointer",fontWeight:600,marginTop:4,boxShadow:"0 2px 8px rgba(79, 70, 229, 0.3)",transition:"all 0.18s ease"},onMouseEnter:S=>{d||(S.currentTarget.style.background="#4338ca")},onMouseLeave:S=>{d||(S.currentTarget.style.background="#4f46e5")},children:d?t.login.signingIn:t.login.signIn}),n.jsx("div",{style:{textAlign:"center",marginTop:12},children:n.jsx("span",{style:{fontSize:12,color:"#6366f1",cursor:"pointer",fontWeight:500},onMouseEnter:S=>S.currentTarget.style.textDecoration="underline",onMouseLeave:S=>S.currentTarget.style.textDecoration="none",children:t.rtl?"نسيت كلمة المرور؟":"Forgot password?"})}),n.jsx("div",{style:{textAlign:"center",marginTop:8},children:n.jsx("button",{type:"button",onClick:Vf,style:{fontSize:12,color:"#94a3b8",background:"none",border:"none",cursor:"pointer"},onMouseEnter:S=>S.currentTarget.style.color="#475569",onMouseLeave:S=>S.currentTarget.style.color="#94a3b8",children:t.switchLang})})]})]})})}function r0(e,t){const s=parseInt(e.replace("#",""),16),r=s>>16&255,l=s>>8&255,a=s&255,i=c=>Math.round(c+(255-c)*t);return`rgb(${i(r)}, ${i(l)}, ${i(a)})`}function $r(e,t){const s=parseInt(e.replace("#",""),16),r=s>>16&255,l=s>>8&255,a=s&255;return`rgba(${r}, ${l}, ${a}, ${t})`}function Jl({title:e,data:t,color:s,onSelect:r}){const[,l]=t[0]??["Total",0,""],a=t.slice(1),i=a.map((d,f)=>r0(s,Math.min(f*.16,.7))),c=a.map(([d,f,v],p)=>[d,f,v,i[p]]).filter(([,d])=>d>0);return n.jsxs("div",{className:"status-card",style:{borderRadius:18,padding:"16px 18px 18px",height:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",minWidth:0,position:"relative",overflow:"hidden"},children:[n.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",background:`linear-gradient(160deg, ${$r(s,.09)} 0%, transparent 55%)`}}),n.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:3,background:`linear-gradient(90deg, ${s}, ${$r(s,.35)})`}}),n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:14},children:[n.jsx("span",{className:"status-card-title",style:{fontSize:13,fontWeight:700,paddingTop:4},children:e}),n.jsx("span",{style:{fontSize:14,fontWeight:800,color:"white",background:s,lineHeight:1,minWidth:26,textAlign:"center",padding:"6px 9px",borderRadius:10,boxShadow:`0 4px 10px ${$r(s,.35)}`},children:l})]}),l>0&&n.jsx("div",{style:{display:"flex",height:9,borderRadius:999,overflow:"hidden",background:$r(s,.1),marginBottom:13},children:c.map(([d,f,v,p],u)=>n.jsx("div",{title:`${d}: ${f}`,onClick:m=>{m.stopPropagation(),r==null||r(v)},style:{flex:`${f} 0 0`,background:p,borderRight:u<c.length-1?"2px solid white":"none",cursor:r?"pointer":"default"}},d))}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:a.map(([d,f,v],p)=>n.jsxs("div",{className:"status-card-row",onClick:f>0?u=>{u.stopPropagation(),r==null||r(v)}:void 0,style:{display:"flex",alignItems:"center",gap:9,padding:"4px 6px",borderRadius:8,cursor:f>0&&r?"pointer":"default",transition:"background 0.12s"},children:[n.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:i[p],flexShrink:0,boxShadow:`0 0 0 3px ${$r(i[p],.18)}`}}),n.jsx("span",{className:"status-card-label",style:{flex:1,fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d}),n.jsx("span",{className:"status-card-count",style:{fontSize:12,fontWeight:700,flexShrink:0},children:f})]},d))})]})}function Ut({value:e,onChange:t,organizations:s,placeholder:r="-- Choose organization --",disabled:l=!1,small:a=!1}){var p;const[i,c]=w.useState(!1),d=w.useRef(null);w.useEffect(()=>{const u=m=>{d.current&&!d.current.contains(m.target)&&c(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]);const f=e?((p=s.find(u=>u.organization_name===e||u.name===e))==null?void 0:p.organization_name)??e:r,v=s.filter(u=>!!u.is_active||u.organization_name===e||u.name===e);return n.jsxs("div",{ref:d,style:{position:"relative",width:"100%"},children:[n.jsxs("div",{onClick:()=>!l&&c(u=>!u),style:{width:"100%",padding:a?"4px 8px":"7px 10px",border:"1px solid #ddd",borderRadius:6,fontSize:a?11:12,cursor:l?"default":"pointer",height:a?28:34,background:l?"#f5f5f5":"white",color:e?"#333":"#aaa",display:"flex",justifyContent:"space-between",alignItems:"center",borderColor:i?"#3498db":"#ddd",transition:"border-color 0.2s",userSelect:"none",boxSizing:"border-box",opacity:l?.75:1},children:[n.jsx("span",{children:f}),n.jsx("span",{style:{fontSize:9,color:"#999",transform:i?"rotate(180deg)":"none",transition:"transform 0.2s"},children:"▼"})]}),i&&n.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:9999,background:"white",border:"1px solid #e0e0e0",borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",overflow:"hidden"},children:n.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[n.jsx(Su,{label:r,selected:!e,active:!0,isPlaceholder:!0,small:a,onClick:()=>{t(""),c(!1)}}),v.length===0&&n.jsx("div",{style:{padding:"12px 16px",color:"#aaa",fontSize:13},children:"No organizations"}),v.map(u=>n.jsx(Su,{label:u.organization_name,selected:e===u.organization_name||e===u.name,active:!!u.is_active,isPlaceholder:!1,small:a,onClick:()=>{t(u.organization_name),c(!1)}},u.name))]})})]})}function Su({label:e,selected:t,active:s,isPlaceholder:r,small:l,onClick:a}){const[i,c]=w.useState(!1),d=t?"#2563eb":i?"#f0f4ff":"transparent",f=t?"white":r?"#aaa":s?"#1a2332":"#e74c3c";return n.jsx("div",{onClick:a,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{padding:l?"6px 12px":"8px 14px",cursor:"pointer",fontSize:12,background:d,color:f,transition:"background 0.1s"},children:e})}function Wn({items:e,type:t,onNavigate:s}){const r=se();if(!e.length)return null;const l=t==="process"?"processes-form":"orders-form",a=t==="process"?r.dash.escalatedProcesses:r.dash.escalatedOrders;return n.jsxs("div",{children:[n.jsxs("h4",{style:{fontWeight:700,fontSize:12,color:"#e74c3c",marginBottom:6},children:[a," (",e.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:e.map(i=>n.jsxs("div",{onClick:()=>s(l,i.name),style:{padding:"8px 12px",background:"#fff5f5",borderRadius:7,border:"1px solid #fecaca",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsxs("div",{children:[n.jsx("span",{style:{fontWeight:700,fontSize:12},children:i.number||i.name}),n.jsx("span",{style:{fontSize:11,color:"#666",marginLeft:8},children:i.title})]}),n.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#e74c3c",background:"#fecaca",padding:"2px 8px",borderRadius:10},children:[r.dash.level," ",i.escalation_level]})]},i.name))})]})}function l0({kpi:e}){const t=se();return n.jsxs("div",{className:"dashboard-kpi-card",style:{borderRadius:12,padding:14,border:"1px solid #e2e8f0"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},children:[n.jsx("div",{style:{fontWeight:700,fontSize:13,color:"#1e293b"},children:e.organization}),n.jsx("span",{style:{fontSize:11,fontWeight:600,color:"#6366f1",background:"#eff6ff",border:"1px solid #bfdbfe",padding:"1px 7px",borderRadius:12},children:e.period})]}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:6},children:[{label:t.dash.revenueGrowth,val:e.revenue_growth!=null?`${e.revenue_growth}%`:"—"},{label:t.dash.netProfit,val:e.net_profit!=null?e.net_profit.toLocaleString():"—"},{label:t.dash.strategicGoal,val:e.strategic_goal_pct!=null?`${e.strategic_goal_pct}%`:"—"},{label:t.dash.customerSat,val:e.customer_satisfaction!=null?e.customer_satisfaction:"—"},{label:t.dash.compliance,val:e.compliance_score!=null?e.compliance_score:"—"},{label:t.dash.safetyInc,val:e.open_safety_incidents!=null?e.open_safety_incidents:"—"}].map(({label:s,val:r})=>n.jsxs("div",{style:{background:"#f8fafc",padding:"6px 8px",borderRadius:6,border:"1px solid #f1f5f9"},children:[n.jsx("div",{style:{fontSize:10,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.2px"},children:s}),n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginTop:1},children:r})]},s))})]})}function a0({data:e}){if(!e.length)return n.jsx("p",{style:{color:"#aaa",fontSize:13},children:"No cycle data available for trend chart."});const t=Math.max(...e.map(s=>s.pass+s.fail+s.unknown),1);return n.jsxs("div",{children:[n.jsx("div",{style:{display:"flex",gap:10,alignItems:"flex-end",overflowX:"auto",paddingBottom:4},children:e.map(s=>{const r=s.pass+s.fail+s.unknown||1,l=80;return n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:3,minWidth:48},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column-reverse",gap:1,height:l,width:32},children:[n.jsx("div",{title:`Pass: ${s.pass}`,style:{height:Math.round(s.pass/t*l),background:"#27ae60",borderRadius:"2px 2px 0 0",minHeight:s.pass?2:0}}),n.jsx("div",{title:`Fail: ${s.fail}`,style:{height:Math.round(s.fail/t*l),background:"#e74c3c",borderRadius:"2px 2px 0 0",minHeight:s.fail?2:0}}),n.jsx("div",{title:`Unknown: ${s.unknown}`,style:{height:Math.round(s.unknown/t*l),background:"#95a5a6",borderRadius:"2px 2px 0 0",minHeight:s.unknown?2:0}})]}),n.jsx("div",{style:{fontSize:9,color:"#999",textAlign:"center",lineHeight:1.2},children:s.month.replace(/^(\d{4})-(\d{2})$/,(a,i,c)=>`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][+c-1]}
|
||
${i}`)}),n.jsx("div",{style:{fontSize:9,color:"#555",textAlign:"center"},children:r>1?Math.round(s.pass/r*100)+"%":"—"})]},s.month)})}),n.jsx("div",{style:{display:"flex",gap:16,marginTop:8},children:[["#27ae60","Pass"],["#e74c3c","Fail"],["#95a5a6","Unknown"]].map(([s,r])=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,fontSize:11},children:[n.jsx("div",{style:{width:10,height:10,background:s,borderRadius:2}}),n.jsx("span",{style:{color:"#666"},children:r})]},r))})]})}function Qt({label:e,icon:t,onClick:s}){return n.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",gap:7,padding:"7px 12px",background:"white",border:"1px solid #e8e8e8",borderRadius:8,cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.06)",transition:"box-shadow 0.15s"},onMouseEnter:r=>r.currentTarget.style.boxShadow="0 3px 10px rgba(0,0,0,0.12)",onMouseLeave:r=>r.currentTarget.style.boxShadow="0 1px 3px rgba(0,0,0,0.06)",children:[n.jsx("span",{style:{fontSize:15},children:t}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#444",whiteSpace:"nowrap"},children:e})]})}function i0({dashData:e,fi:t,fid:s,fo:r,fp:l,incidentStatuses:a,ideaStatuses:i,orderStatuses:c,processStatuses:d,onNavigate:f,onNavigateStatus:v}){const p=se(),u=(e==null?void 0:e.escalated_processes)||[],m=(e==null?void 0:e.escalated_orders)||[],j=(e==null?void 0:e.attention_processes)||[],h=(e==null?void 0:e.attention_orders)||[],S=(e==null?void 0:e.untriaged_incidents)||[],g=(e==null?void 0:e.overdue_triage)||[],x=u.length>0||m.length>0,o=j.length>0||h.length>0,y=[["Total",t.length,""],...a.map(k=>[k.name1||k.name,t.filter(R=>R.status===k.name).length,k.name])],_=[["Total",s.length,""],...i.map(k=>[k.name1||k.name,s.filter(R=>R.status===k.name).length,k.name])],C=[["Total",r.length,""],...c.map(k=>[k.name1||k.name,r.filter(R=>R.status===k.name).length,k.name])],P=[["Total",l.length,""],...d.map(k=>[k.name1||k.name,l.filter(R=>R.status===k.name).length,k.name])];return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",marginBottom:4},children:[n.jsx(Qt,{label:"Incidents",icon:"⚠️",onClick:()=>f("incidents")}),n.jsx(Qt,{label:"Ideas",icon:"💡",onClick:()=>f("ideas")}),n.jsx(Qt,{label:"Orders",icon:"📦",onClick:()=>f("orders")}),n.jsx(Qt,{label:"Processes",icon:"⚙️",onClick:()=>f("processes")}),n.jsx(Qt,{label:"Inbox",icon:"📥",onClick:()=>f("inbox")}),n.jsx(Qt,{label:"Reports",icon:"📊",onClick:()=>f("reports")})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12},children:[n.jsx("div",{onClick:()=>f("incidents"),style:{cursor:"pointer"},children:n.jsx(Jl,{title:p.dash.incidents,color:F.orange,data:y,onSelect:k=>v("incidents",k)})}),n.jsx("div",{onClick:()=>f("ideas"),style:{cursor:"pointer"},children:n.jsx(Jl,{title:p.dash.ideas,color:F.blue,data:_,onSelect:k=>v("ideas",k)})}),n.jsx("div",{onClick:()=>f("orders"),style:{cursor:"pointer"},children:n.jsx(Jl,{title:p.dash.orders,color:F.purple,data:C,onSelect:k=>v("orders",k)})}),n.jsx("div",{onClick:()=>f("processes"),style:{cursor:"pointer"},children:n.jsx(Jl,{title:p.dash.processes,color:F.red,data:P,onSelect:k=>v("processes",k)})})]}),x&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #e74c3c"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:10},children:p.dash.level2}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(Wn,{items:u,type:"process",onNavigate:f}),n.jsx(Wn,{items:m,type:"order",onNavigate:f})]})]}),o&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#b45309",marginBottom:10},children:p.dash.level1}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(Wn,{items:j,type:"process",onNavigate:f}),n.jsx(Wn,{items:h,type:"order",onNavigate:f})]})]}),g.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #e74c3c"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:8},children:[p.dash.overduePrefix,g.length,p.dash.overdueSuffix]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:g.map(k=>n.jsxs("div",{onClick:()=>f("incidents-form",k.name),style:{padding:"8px 12px",background:"#fef2f2",borderRadius:8,border:"1px solid #fca5a5",cursor:"pointer",display:"flex",justifyContent:"space-between"},children:[n.jsx("span",{style:{fontWeight:700,fontSize:13},children:k.number||k.name}),n.jsx("span",{style:{fontSize:12,color:"#666"},children:k.title}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:k.date})]},k.name))})]}),S.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:F.orange,marginBottom:8},children:[p.dash.untriaged," (",S.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:S.map(k=>n.jsxs("div",{onClick:()=>f("incidents-form",k.name),style:{padding:"8px 12px",background:"#fffbeb",borderRadius:8,border:"1px solid #fed7aa",cursor:"pointer",display:"flex",justifyContent:"space-between"},children:[n.jsx("span",{style:{fontWeight:700,fontSize:13},children:k.number||k.name}),n.jsx("span",{style:{fontSize:12,color:"#666"},children:k.title}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:k.date})]},k.name))})]})]})}function o0({dashData:e,selectedOrg:t,onNavigate:s}){const r=se(),[l,a]=w.useState([]),[i,c]=w.useState([]),[d,f]=w.useState(!1),v=(e==null?void 0:e.escalated_processes)||[],p=(e==null?void 0:e.escalated_orders)||[],u=(e==null?void 0:e.attention_processes)||[],m=(e==null?void 0:e.attention_orders)||[],j=(e==null?void 0:e.kpi_inputs)||[];w.useEffect(()=>{f(!0);const g=new URLSearchParams({months:"6"});t&&g.append("organization",t),fetch(`/api/method/sidrah_business.api.get_process_trend?${g}`,{credentials:"include",headers:{Accept:"application/json"}}).then(x=>x.json()).then(x=>{const o=x.message||[],y={};for(const _ of o)y[_.month]||(y[_.month]={pass:0,fail:0,unknown:0}),_.status==="Pass"?y[_.month].pass=_.count:_.status==="Fail"?y[_.month].fail=_.count:_.status==="Unknown"&&(y[_.month].unknown=_.count);a(Object.entries(y).map(([_,C])=>({month:_,...C})))}).catch(()=>{}).finally(()=>f(!1))},[t]),w.useEffect(()=>{fetch("/api/method/sidrah_business.api.get_report_data",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":window.csrf_token||""},body:JSON.stringify({report_name:"user_activity_log",filters_json:"{}"})}).then(g=>g.json()).then(g=>{var x;c((((x=g.message)==null?void 0:x.rows)||[]).slice(0,50))}).catch(()=>{})},[t]);const h=v.length>0||p.length>0,S=u.length>0||m.length>0;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:[n.jsx(Qt,{label:"Manage Users & Roles",icon:"👥",onClick:()=>s("users")}),n.jsx(Qt,{label:"Change Active Cycle",icon:"🔄",onClick:()=>s("cycles")}),n.jsx(Qt,{label:"KPI Inputs",icon:"📈",onClick:()=>s("kpi-input")}),n.jsx(Qt,{label:"Reports",icon:"📊",onClick:()=>s("reports")}),n.jsx(Qt,{label:"Organizations",icon:"🏢",onClick:()=>s("organizations")})]}),j.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:10},children:r.dash.recentKpi}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12},children:j.map(g=>n.jsx(l0,{kpi:g},g.name))}),n.jsx("button",{onClick:()=>s("kpi-input"),style:{marginTop:10,padding:"6px 14px",borderRadius:7,border:"1px solid #2980b9",background:"white",color:"#2980b9",fontWeight:600,fontSize:12,cursor:"pointer"},children:r.dash.manageKpi})]}),h&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #e74c3c"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:10},children:["Critical Escalations — Level 2 (",v.length+p.length,")"]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(Wn,{items:v,type:"process",onNavigate:s}),n.jsx(Wn,{items:p,type:"order",onNavigate:s})]})]}),S&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#b45309",marginBottom:10},children:["Needs Attention — Level 1 (",u.length+m.length,")"]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(Wn,{items:u,type:"process",onNavigate:s}),n.jsx(Wn,{items:m,type:"order",onNavigate:s})]})]}),n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:4},children:"Process Trend — Last 6 Months"}),n.jsx("p",{style:{fontSize:11,color:"#888",marginBottom:10},children:"Pass/Fail/Unknown ratio per month across all processes. Pass % shown at bottom of each bar."}),d?n.jsx("p",{style:{color:"#aaa",fontSize:13},children:"Loading trend data…"}):n.jsx(a0,{data:l})]}),i.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:10},children:"Log Book — Recent Activity"}),n.jsx("div",{style:{overflowX:"auto"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa"},children:["Timestamp","User","Entity Type","Entity","Fields Changed"].map(g=>n.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#999",fontWeight:700,fontSize:11,whiteSpace:"nowrap"},children:g},g))})}),n.jsx("tbody",{children:i.map((g,x)=>n.jsxs("tr",{style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"8px 12px",color:"#555",whiteSpace:"nowrap"},children:g.timestamp?String(g.timestamp).slice(0,16):"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#333"},children:g.user||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#555"},children:g.entity_type||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#555"},children:g.entity_name||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#888",maxWidth:240,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.changes||"—"})]},x))})]})}),n.jsx("button",{onClick:()=>s("reports"),style:{marginTop:12,padding:"7px 16px",borderRadius:8,border:"1px solid #888",background:"white",color:"#555",fontWeight:600,fontSize:12,cursor:"pointer"},children:"Full Activity Log (Reports →)"})]})]})}function d0({incidents:e,ideas:t,orders:s,processes:r,organizations:l,incidentStatuses:a,ideaStatuses:i,orderStatuses:c,processStatuses:d,selectedOrg:f,onOrgChange:v,onNavigate:p,onNavigateStatus:u,userRole:m}){const[j,h]=w.useState(null);w.useEffect(()=>{$y(f).then(h)},[f]);const S=f?e.filter(R=>R.organization===f):e,g=f?t.filter(R=>R.organization===f):t,x=f?s.filter(R=>R.organization===f):s,o=f?r.filter(R=>R.organization===f):r,y=m==="Admin",_=m==="Owner",[C,P]=w.useState("level1"),k=_||y&&C==="level2";return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[n.jsxs("div",{style:{background:"white",borderRadius:10,padding:"8px 14px",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#4f46e5",strokeWidth:"2.5",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#1e1b4b",whiteSpace:"nowrap"},children:"Filter"})]}),n.jsx("div",{style:{flex:1,minWidth:160,maxWidth:260},children:n.jsx(Ut,{value:f,onChange:v,organizations:l,placeholder:"All Organizations",small:!0})}),y&&n.jsx("div",{style:{display:"flex",background:"#f1f0fe",borderRadius:7,padding:2,gap:2,flexShrink:0},children:["level1","level2"].map(R=>n.jsx("button",{onClick:()=>P(R),style:{padding:"4px 10px",borderRadius:5,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:C===R?R==="level2"?F.purple:F.blue:"transparent",color:C===R?"white":"#6b7280",transition:"all 0.15s"},children:R==="level1"?"Level 1":"Level 2"},R))}),!y&&n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"white",background:k?F.purple:F.blue,padding:"3px 10px",borderRadius:20,flexShrink:0},children:k?"Level 2 — Owner":"Level 1 — Operational"})]}),k?n.jsx(o0,{dashData:j,selectedOrg:f,onNavigate:p}):n.jsx(i0,{dashData:j,fi:S,fid:g,fo:x,fp:o,incidentStatuses:a,ideaStatuses:i,orderStatuses:c,processStatuses:d,onNavigate:p,onNavigateStatus:u})]})}const Xe={fontSize:11,color:"#475569",fontWeight:600,marginBottom:4,display:"block",textTransform:"uppercase",letterSpacing:.4},qe={width:"100%",padding:"6px 10px",border:"1px solid #cbd5e1",borderRadius:6,fontSize:12,background:"white",color:"#1e293b",boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif",height:32,outline:"none"};function ri({children:e}){const[t,s]=w.useState(!1);return n.jsxs("div",{style:{borderRadius:10,overflow:"hidden",boxShadow:"0 1px 3px rgba(0,0,0,0.06)",flexShrink:0,border:"1px solid #e2e8f0",marginBottom:14},children:[n.jsxs("div",{onClick:()=>s(r=>!r),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",color:"white",padding:"10px 18px",cursor:"pointer",display:"flex",alignItems:"center",gap:10,userSelect:"none",fontWeight:600,fontSize:13},children:[n.jsx("span",{style:{fontSize:12,opacity:.9},children:t?"▲":"▼"}),n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{children:"Filters"})]}),t&&n.jsx("div",{style:{background:"#f8fafc",padding:"14px 18px",borderTop:"1px solid #e2e8f0"},children:e})]})}const ie=20,wu=e=>({padding:"6px 16px",borderRadius:6,border:"1px solid #d1d5db",fontSize:12,fontWeight:600,background:e?"#f3f4f6":"white",color:e?"#c1c5cc":"#374151",cursor:e?"not-allowed":"pointer",fontFamily:"inherit"});function Ge({page:e,pageSize:t=ie,total:s,onPageChange:r}){if(s===0)return null;const l=Math.max(1,Math.ceil(s/t)),a=(e-1)*t+1,i=Math.min(e*t,s);return n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 4px",fontSize:12,color:"#6b7280",flexShrink:0},children:[n.jsxs("span",{children:["Showing ",a," to ",i," of ",s," results"]}),n.jsxs("div",{style:{display:"flex",gap:8},children:[n.jsx("button",{disabled:e<=1,onClick:()=>r(e-1),style:wu(e<=1),children:"Previous"}),n.jsx("button",{disabled:e>=l,onClick:()=>r(e+1),style:wu(e>=l),children:"Next"})]})]})}function c0({incidents:e,organizations:t,departments:s,branches:r,incidentStatuses:l,initialOrg:a,initialStatus:i,canModify:c,onView:d,onEdit:f,onDelete:v}){const p=se(),[u,m]=w.useState({search:"",organization:a||"",department:"",branch:"",status:i||""}),j=(o,y)=>m(_=>({..._,[o]:y})),[h,S]=w.useState(1),g=e.filter(o=>!(u.search&&!`${o.number} ${o.title}`.toLowerCase().includes(u.search.toLowerCase())||u.organization&&o.organization!==u.organization||u.department&&o.department!==u.department||u.branch&&o.branch!==u.branch||u.status&&o.status!==u.status));w.useEffect(()=>{S(1)},[u]);const x=g.slice((h-1)*ie,h*ie);return n.jsxs(n.Fragment,{children:[n.jsx(ri,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"10px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.numberTitle}),n.jsx("input",{style:qe,value:u.search,onChange:o=>j("search",o.target.value),placeholder:p.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.organization}),n.jsxs("select",{style:qe,value:u.organization,onChange:o=>j("organization",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.department}),n.jsxs("select",{style:qe,value:u.department,onChange:o=>j("department",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allDepts}),s.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.branch}),n.jsxs("select",{style:qe,value:u.branch,onChange:o=>j("branch",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allBranches}),r.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.status}),n.jsxs("select",{style:qe,value:u.status,onChange:o=>j("status",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allStatuses}),l.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>m({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"7px 14px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#475569",fontWeight:500},children:p.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.number}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.title}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.organization}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.type}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.status}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.actions})]})}),n.jsx("tbody",{children:g.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:p.noIncidents})}):x.map((o,y)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>d==null?void 0:d(o),style:{borderTop:"1px solid #f1f5f9",background:o.custom_is_deleted?"#fff1f2":y%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[n.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:o.number||"—"}),n.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:o.title||"—"}),n.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"12px 16px"},children:o.type?Rd(o.type):"—"}),n.jsx("td",{style:{padding:"12px 16px"},children:o.custom_is_deleted?Xn(p.deletedBadge):o.status?Xn(o.status):"—"}),n.jsx("td",{style:{padding:"10px 16px"},onClick:_=>_.stopPropagation(),children:n.jsx(nt,{onView:()=>d==null?void 0:d(o),onEdit:c&&f&&!o.custom_is_deleted&&!Nn("incident",o.workflow_state)?()=>f(o):void 0,onDelete:c&&v&&!o.custom_is_deleted?()=>v(o.name):void 0})})]},o.name))})]})}),n.jsx(Ge,{page:h,total:g.length,onPageChange:S})]})}function u0(e){if(!e)return"";const[t,s,r]=e.split("-");return!t||!s||!r?"":`${r}/${s}/${t}`}function xe({value:e,onChange:t,disabled:s,style:r,min:l,max:a}){return n.jsxs("div",{style:{position:"relative",width:"100%"},children:[n.jsx("input",{type:"text",readOnly:!0,tabIndex:-1,value:u0(e),placeholder:"DD/MM/YYYY",style:{...r,pointerEvents:"none",paddingRight:30}}),n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:s?"#bbb":"#666",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",pointerEvents:"none"},children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),n.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),n.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),n.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),n.jsx("input",{type:"date",value:e||"",disabled:s,min:l,max:a,onChange:i=>t(i.target.value),style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0,cursor:s?"default":"pointer",border:"none",padding:0,margin:0}})]})}const _u={"SB Process":"processes-form","SB Order":"orders-form","SB Incident":"incidents-form","SB Idea":"ideas-form","SB Delegation":"delegations"};function p0(e){const t=(Date.now()-new Date(e).getTime())/1e3;return t<60?`${Math.floor(t)}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function lh({notifCount:e,darkMode:t,onCountChange:s,onToggleDark:r,onViewProfile:l,onLogout:a,onNavigate:i,userName:c,userRole:d}){const[f,v]=w.useState(!1),[p,u]=w.useState([]),[m,j]=w.useState(!1),h=w.useRef(null);w.useEffect(()=>{const $=Z=>{h.current&&!h.current.contains(Z.target)&&v(!1)};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]);const S=async()=>{j(!0);const $=await Iy(30);u($),j(!1)},g=()=>{const $=!f;v($),$&&S()},x=async()=>{await Ey(),u($=>$.map(Z=>({...Z,read:1}))),s(0)},o=$=>{$.read||(Py($.name),u(de=>de.map(D=>D.name===$.name?{...D,read:1}:D)),s(Math.max(0,e-1)));const Z=$.document_type?_u[$.document_type]:void 0;Z&&i&&(i(Z,$.document_type==="SB Delegation"?void 0:$.document_name),v(!1))},y=p.filter($=>!$.read).length,_=$=>({position:"relative",width:34,height:34,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:t?"#2d3748":"#f3f4f6",color:t?"#e2e8f0":"#6b7280",fontSize:14,transition:"background 0.15s",flexShrink:0,...$}),C=t,P=C?"#1a202c":"white",k=C?"#2d3748":"#e5e7eb",R=C?"#e2e8f0":"#1a2332";return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[c&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",marginRight:4,lineHeight:1.25},children:[n.jsx("span",{style:{fontSize:13,fontWeight:600,color:C?"#e2e8f0":"#1e293b",whiteSpace:"nowrap"},children:c}),d&&n.jsx("span",{style:{fontSize:11,color:C?"#94a3b8":"#6b7280",whiteSpace:"nowrap"},children:d})]}),n.jsx("button",{style:_({background:"#4f46e5",color:"white"}),onClick:l,title:"My Profile",children:n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:[n.jsx("circle",{cx:"12",cy:"8",r:"4"}),n.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7",fill:"currentColor"})]})}),n.jsxs("div",{ref:h,style:{position:"relative"},children:[n.jsxs("button",{style:_(),onClick:g,title:"Notifications",children:[n.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),n.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),e>0&&n.jsx("span",{style:{position:"absolute",top:2,right:2,background:"#ef4444",color:"white",fontSize:9,fontWeight:700,borderRadius:999,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 3px",lineHeight:1},children:e>9?"9+":e})]}),f&&n.jsxs("div",{style:{position:"absolute",right:0,top:"calc(100% + 8px)",width:340,background:P,borderRadius:12,boxShadow:"0 8px 32px rgba(0,0,0,0.2)",zIndex:1e4,border:`1px solid ${k}`,overflow:"hidden"},children:[n.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${k}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:P},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:R},children:["Notifications",y>0&&n.jsxs("span",{style:{background:"#ef4444",color:"white",fontSize:10,fontWeight:700,borderRadius:999,padding:"2px 7px"},children:[y," new"]})]}),y>0&&n.jsx("button",{onClick:x,style:{fontSize:12,color:"#3498db",background:"none",border:"none",cursor:"pointer",fontFamily:"inherit"},children:"Mark all read"})]}),n.jsxs("div",{style:{maxHeight:380,overflowY:"auto"},children:[m&&n.jsx("div",{style:{padding:20,textAlign:"center",color:"#aaa",fontSize:13},children:"Loading…"}),!m&&p.length===0&&n.jsxs("div",{style:{padding:"36px 20px",textAlign:"center",color:"#aaa"},children:[n.jsx("div",{style:{fontSize:28,marginBottom:8},children:"🔔"}),n.jsx("div",{style:{fontSize:13},children:"No notifications"})]}),!m&&p.map($=>{const Z=!!($.document_type&&_u[$.document_type]&&i);return n.jsxs("div",{onClick:()=>o($),style:{padding:"11px 16px",borderBottom:`1px solid ${C?"#2d3748":"#f5f5f5"}`,display:"flex",gap:10,background:$.read?P:C?"#1e3a5f":"#eff6ff",cursor:Z?"pointer":"default",transition:"background 0.12s"},onMouseEnter:de=>{Z&&(de.currentTarget.style.background=C?"#243244":"#e0ecfd")},onMouseLeave:de=>{de.currentTarget.style.background=$.read?P:C?"#1e3a5f":"#eff6ff"},children:[n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:13,fontWeight:$.read?400:600,color:R,marginBottom:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:$.subject||`${$.document_type}: ${$.document_name}`}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:$.document_type&&n.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#3b82f6",background:C?"rgba(59,130,246,0.15)":"#eff6ff",padding:"1px 7px",borderRadius:8},children:[$.document_type.replace("SB ",""),$.document_name?` · ${$.document_name}`:""]})}),n.jsx("div",{style:{fontSize:11,color:"#aaa",marginTop:3},children:p0($.creation)})]}),!$.read&&n.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:"#3498db",flexShrink:0,marginTop:5}})]},$.name)})]})]})]}),n.jsx("button",{style:_(),onClick:Vf,title:or()?"Switch to English":"Switch to Arabic",children:n.jsx("span",{style:{fontSize:13,fontWeight:700,fontFamily:"serif"},children:"عA"})}),n.jsx("button",{style:_(),onClick:r,title:t?"Light mode":"Dark mode",children:t?n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"5"}),n.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),n.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),n.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),n.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),n.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),n.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),n.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),n.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}),n.jsx("button",{style:_({background:C?"#3d1515":"#fee2e2",color:"#ef4444"}),onClick:a,title:"Logout",children:n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),n.jsx("polyline",{points:"16,17 21,12 16,7"}),n.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]})})]})}function Ke({title:e,activePage:t,user:s,formStatus:r,buttonText:l,viewMode:a,statusBadge:i,onEdit:c,onCancel:d,hideSettings:f,rightPanel:v,darkMode:p,notifCount:u,onToggleDark:m,onCountChange:j,onViewProfile:h,onSubmit:S,onBack:g,onNavigate:x,onLogout:o,children:y}){const _=se(),C=s.role,P=C==="Admin"||C==="Owner"||C==="Auditor"||C==="Manager",k=C==="Admin"||C==="Owner"||C==="Auditor"||C==="Manager",R=C==="Admin"||C==="Auditor"||C==="Manager",[$,Z]=w.useState(()=>localStorage.getItem("sb_sidebar")==="1"),[de,D]=w.useState(!a);w.useEffect(()=>{if(a)D(!1);else{D(!0);const B=setTimeout(()=>{D(!1)},5e3);return()=>clearTimeout(B)}},[a]);const T=()=>Z(B=>{const M=!B;return localStorage.setItem("sb_sidebar",M?"1":"0"),M}),E=d||g;return n.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:p?"#0f172a":"#f8fafc"},children:[n.jsx(th,{collapsed:$,onToggleCollapsed:T,activePage:t,onNavigate:x,hasDashboard:P,hasReports:k,hasDelegations:R,role:C,hideSettings:f,rtl:_.rtl,navLabels:_.nav,settingsLabel:_.nav.settings}),n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[n.jsx("div",{style:{background:p?"#1e293b":"#ffffff",padding:"6px 20px",borderBottom:`1px solid ${p?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"flex-end",alignItems:"center",gap:6,flexShrink:0,boxShadow:p?"none":"0 1px 4px rgba(0,0,0,0.03)"},children:n.jsx(lh,{notifCount:u,darkMode:p,onCountChange:j,onToggleDark:m,onNavigate:x,onViewProfile:h,onLogout:o,userName:s.full_name||s.name,userRole:s.role})}),n.jsxs("div",{style:{background:p?"#1e293b":"#ffffff",padding:"12px 24px",borderBottom:`1px solid ${p?"#2d3748":"#e2e8f0"}`,display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,position:"relative"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[n.jsx("button",{onClick:g,title:_.back,style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:`1px solid ${p?"#475569":"#e2e8f0"}`,background:p?"#334155":"#ffffff",cursor:"pointer",color:"#2563eb",flexShrink:0,transition:"all 0.15s ease"},onMouseEnter:B=>{B.currentTarget.style.background=p?"#475569":"#eff6ff",B.currentTarget.style.borderColor="#93c5fd"},onMouseLeave:B=>{B.currentTarget.style.background=p?"#334155":"#ffffff",B.currentTarget.style.borderColor=p?"#475569":"#e2e8f0"},children:n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"15 18 9 12 15 6"})})}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[n.jsx("div",{style:{fontSize:17,fontWeight:700,color:p?"#f8fafc":"#0f172a"},children:e}),i&&(typeof i=="string"?n.jsx("span",{style:{padding:"3px 10px",borderRadius:16,fontSize:12,fontWeight:600,background:"#fef3c7",color:"#92400e",border:"1px solid #fde68a"},children:i}):i)]})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a&&c&&n.jsxs("button",{type:"button",onClick:c,style:{display:"flex",alignItems:"center",gap:6,padding:"7px 16px",borderRadius:6,border:"none",background:"#2563eb",color:"#ffffff",cursor:"pointer",fontSize:13,fontWeight:600,boxShadow:"0 1px 3px rgba(37,99,235,0.25)",transition:"all 0.15s ease"},onMouseEnter:B=>B.currentTarget.style.background="#1d4ed8",onMouseLeave:B=>B.currentTarget.style.background="#2563eb",children:[n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),_.edit]}),!a&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("button",{type:"button",onClick:E,style:{padding:"7px 16px",borderRadius:6,border:`1px solid ${p?"#475569":"#cbd5e1"}`,background:p?"#334155":"#ffffff",color:p?"#e2e8f0":"#475569",fontSize:13,fontWeight:600,cursor:"pointer",transition:"all 0.15s ease"},onMouseEnter:B=>{B.currentTarget.style.background=p?"#475569":"#f1f5f9"},onMouseLeave:B=>{B.currentTarget.style.background=p?"#334155":"#ffffff"},children:_.cancel}),n.jsxs("button",{type:"button",onClick:S,disabled:r==="loading",style:{display:"flex",alignItems:"center",gap:6,padding:"7px 18px",borderRadius:6,border:"none",background:"#16a34a",color:"#ffffff",fontSize:13,fontWeight:600,cursor:r==="loading"?"not-allowed":"pointer",boxShadow:"0 1px 3px rgba(22, 163, 74, 0.3)",opacity:r==="loading"?.7:1,transition:"all 0.15s ease"},onMouseEnter:B=>{r!=="loading"&&(B.currentTarget.style.background="#15803d")},onMouseLeave:B=>{r!=="loading"&&(B.currentTarget.style.background="#16a34a")},children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),n.jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),n.jsx("polyline",{points:"7 3 7 8 15 8"})]}),n.jsx("span",{children:r==="loading"?_.saving:l||"Save Changes"})]})]})]}),!a&&de&&n.jsxs("div",{style:{position:"absolute",top:-34,right:24,background:"#0284c7",color:"#ffffff",padding:"4px 12px",borderRadius:6,fontSize:12,fontWeight:600,display:"flex",alignItems:"center",gap:8,boxShadow:"0 2px 8px rgba(2, 132, 199, 0.3)",zIndex:10},children:[n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5},children:[n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),"Edit mode enabled"]}),n.jsx("button",{type:"button",onClick:()=>D(!1),title:"Dismiss",style:{background:"transparent",border:"none",color:"white",cursor:"pointer",fontSize:14,padding:0,lineHeight:1,opacity:.85},children:"✕"})]})]}),n.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"grid",gridTemplateColumns:v?"1fr 240px":"1fr",gap:16,alignItems:"start"},children:[n.jsxs("div",{style:{minWidth:0},children:[y,r==="success"&&n.jsx("div",{style:{padding:"10px 14px",borderRadius:8,background:"#f0fdf4",border:"1px solid #86efac",color:"#166534",fontSize:13,marginTop:14},children:_.savedOk}),r!=="idle"&&r!=="loading"&&r!=="success"&&n.jsx("div",{style:{padding:"10px 14px",borderRadius:8,background:"#fef2f2",border:"1px solid #fca5a5",color:"#991b1b",fontSize:13,marginTop:14},children:r})]}),v&&n.jsx("div",{style:{position:"sticky",top:0,alignSelf:"start",width:240},children:v})]})]})]})}function pe({value:e,onChange:t,items:s,placeholder:r="-- Select --",disabled:l=!1}){var p;const[a,i]=w.useState(!1),[c,d]=w.useState(""),f=w.useRef(null);w.useEffect(()=>{const u=m=>{f.current&&!f.current.contains(m.target)&&i(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]);const v=e?((p=s.find(u=>u.name===e))==null?void 0:p.label)??e:r;return n.jsxs("div",{ref:f,style:{position:"relative",width:"100%"},children:[n.jsxs("div",{onClick:()=>!l&&i(u=>!u),style:{width:"100%",height:34,padding:"7px 10px",border:"1px solid",borderColor:a?"#3498db":"#ddd",borderRadius:6,fontSize:12,cursor:l?"default":"pointer",background:l?"#f5f5f5":"white",color:e?"#333":"#aaa",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"border-color 0.2s",userSelect:"none",boxSizing:"border-box",opacity:l?.75:1},children:[n.jsx("span",{children:v}),n.jsx("span",{style:{fontSize:9,color:"#999",transform:a?"rotate(180deg)":"none",transition:"transform 0.2s"},children:"▼"})]}),a&&n.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:9999,background:"white",border:"1px solid #e0e0e0",borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",overflow:"hidden"},children:n.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[n.jsx("div",{onClick:()=>{t(""),i(!1)},onMouseEnter:()=>d("__placeholder"),onMouseLeave:()=>d(""),style:{padding:"8px 14px",cursor:"pointer",fontSize:12,color:"#aaa",background:c==="__placeholder"?"#f5f5f5":"transparent"},children:r}),s.length===0&&n.jsx("div",{style:{padding:"10px 14px",color:"#aaa",fontSize:12},children:"No records found"}),s.map(u=>n.jsx("div",{onClick:()=>{t(u.name),i(!1)},onMouseEnter:()=>d(u.name),onMouseLeave:()=>d(""),style:{padding:"8px 14px",cursor:"pointer",fontSize:12,background:e===u.name?"#2563eb":c===u.name?"#f0f4ff":"transparent",color:e===u.name?"white":"#1a2332",transition:"background 0.1s"},children:u.label},u.name))]})})]})}function f0(e){const t=(Date.now()-new Date(e).getTime())/1e3;return t<60?`${Math.floor(t)}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:t<86400*7?`${Math.floor(t/86400)}d ago`:new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function h0(e){return e.replace(/@.*/,"").replace(/[._-]/g," ").split(" ").filter(Boolean).slice(0,2).map(s=>s[0].toUpperCase()).join("")}function li({doctype:e,docname:t,currentUserName:s}){const r=se(),[l,a]=w.useState([]),[i,c]=w.useState(!1),[d,f]=w.useState(""),[v,p]=w.useState(!1),[u,m]=w.useState(!1),[j,h]=w.useState(!1),[S,g]=w.useState(""),x=5,o=w.useCallback(async()=>{c(!0);const k=await Ry(e,t);a(k),c(!1)},[e,t]);w.useEffect(()=>{o()},[o]);const y=async()=>{const k=d.trim();if(!(!k||v)){p(!0),g("");try{await Dy(e,t,k),f(""),await o()}catch{g("Failed to post comment. Please try again.")}p(!1)}},_=async k=>{if(window.confirm("Delete this comment?"))try{await No("Comment",k),a(R=>R.filter($=>$.name!==k))}catch{alert("Failed to delete comment.")}},C=j?l:l.slice(-x),P=Math.max(0,l.length-x);return n.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[n.jsxs("div",{onClick:()=>m(k=>!k),style:{padding:"12px 20px",borderBottom:u?"none":"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none",background:"white"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:"#1a2332"},children:["💬 ",r.comments.title,l.length>0&&n.jsx("span",{style:{background:"#e8f4fd",color:"#2980b9",fontSize:11,fontWeight:700,borderRadius:10,padding:"2px 8px"},children:l.length})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx("button",{onClick:k=>{k.stopPropagation(),o()},style:{background:"none",border:"none",cursor:"pointer",color:"#aaa",fontSize:16,padding:"2px 4px",lineHeight:1},title:"Refresh",children:"↻"}),n.jsx("span",{style:{color:"#ccc",fontSize:11},children:u?"▼":"▲"})]})]}),!u&&n.jsxs("div",{style:{padding:"16px 20px"},children:[!j&&P>0&&n.jsxs("button",{onClick:()=>h(!0),style:{width:"100%",padding:"8px",marginBottom:12,border:"none",background:"#f8f9fa",borderRadius:6,cursor:"pointer",fontSize:12,color:"#3498db",fontFamily:"Segoe UI"},children:["Show ",P," older comment",P!==1?"s":""]}),i&&n.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:r.loading}),!i&&l.length===0&&n.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:r.comments.noComments}),!i&&C.length>0&&n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:16},children:C.map(k=>{const R=k.comment_by||k.comment_email||k.owner||"Unknown",$=k.owner===s||k.comment_by===s;return n.jsxs("div",{style:{display:"flex",gap:10,padding:"12px 14px",background:"#f9fafb",borderRadius:8,border:"1px solid #e8e8e8"},children:[n.jsx("div",{style:{width:34,height:34,borderRadius:"50%",background:"#3498db",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,fontWeight:700,flexShrink:0},children:h0(R)}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx("span",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:R}),n.jsx("span",{style:{fontSize:11,color:"#aaa"},children:f0(k.creation)})]}),$&&n.jsx("button",{onClick:()=>_(k.name),style:{background:"none",border:"none",cursor:"pointer",color:"#e74c3c",fontSize:16,padding:"0 2px",lineHeight:1},title:"Delete comment",children:"×"})]}),n.jsx("div",{style:{fontSize:13,color:"#374151",lineHeight:1.55,wordBreak:"break-word",whiteSpace:"pre-wrap"},dangerouslySetInnerHTML:{__html:k.content||""}})]})]},k.name)})}),n.jsxs("div",{style:{borderTop:l.length>0?"1px solid #f0f0f0":"none",paddingTop:l.length>0?14:0},children:[n.jsx("textarea",{value:d,onChange:k=>f(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.ctrlKey||k.metaKey)&&y()},placeholder:r.comments.placeholder,rows:3,style:{width:"100%",padding:"10px 12px",border:"1px solid #ddd",borderRadius:8,fontSize:13,fontFamily:"Segoe UI",resize:"vertical",boxSizing:"border-box",outline:"none",color:"#1a2332"}}),S&&n.jsx("div",{style:{fontSize:12,color:"#e74c3c",marginTop:4},children:S}),n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:n.jsx("button",{onClick:y,disabled:!d.trim()||v,style:{padding:"8px 20px",background:"#3498db",color:"white",border:"none",borderRadius:6,cursor:!d.trim()||v?"not-allowed":"pointer",fontSize:13,fontWeight:600,fontFamily:"Segoe UI",opacity:!d.trim()||v?.6:1},children:v?r.saving:r.comments.post})})]})]})]})}function ku(e){if(!e)return"";const t=(Date.now()-new Date(e).getTime())/1e3;return t<60?`${Math.floor(t)}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:t<86400*7?`${Math.floor(t/86400)}d ago`:new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function g0(e){return(e||"").replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function Cu(e){return e==null||e===""?"(empty)":typeof e=="object"?JSON.stringify(e):String(e)}function Wo(e){return(e||"Unknown").replace(/@.*/,"").replace(/[._]/g," ")}function zu(e){return Wo(e).split(" ").filter(Boolean).slice(0,2).map(t=>t[0].toUpperCase()).join("")}function x0(e){let t={};try{t=JSON.parse(e.data||"{}")}catch{}const s=(t.changed||[]).map(r=>({field:r[0]||"",oldVal:Cu(r[1]),newVal:Cu(r[2])}));return{name:e.name,owner:e.owner,creation:e.creation,changes:s,added:(t.added||[]).length,removed:(t.removed||[]).length,rowChanged:(t.row_changed||[]).length}}function ai({doctype:e,docname:t,docCreation:s,docOwner:r}){const l=se(),[a,i]=w.useState([]),[c,d]=w.useState(!1),[f,v]=w.useState(!0),[p,u]=w.useState(!1),m=5,j=w.useCallback(async()=>{d(!0);const x=await Ly(e,t);i(x.map(x0)),d(!1)},[e,t]);w.useEffect(()=>{f||j()},[f,j]);const h=p?a:a.slice(0,m),S=a.length-m,g=(x,o=!1)=>({position:"absolute",left:-14,top:14,width:10,height:10,borderRadius:"50%",background:x,border:"2px solid white",boxShadow:o?`0 0 0 2px ${x}44`:"none"});return n.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[n.jsxs("div",{onClick:()=>v(x=>!x),style:{padding:"12px 20px",borderBottom:f?"none":"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:"#1a2332"},children:["📋 ",l.activity.title,!f&&a.length>0&&n.jsx("span",{style:{background:"#e8f4fd",color:"#2980b9",fontSize:11,fontWeight:700,borderRadius:10,padding:"2px 8px"},children:a.length})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!f&&n.jsx("button",{onClick:x=>{x.stopPropagation(),j()},style:{background:"none",border:"none",cursor:"pointer",color:"#aaa",fontSize:16,padding:"2px 4px",lineHeight:1},title:"Refresh",children:"↻"}),n.jsx("span",{style:{color:"#ccc",fontSize:11},children:f?"▼":"▲"})]})]}),!f&&n.jsxs("div",{style:{padding:"16px 20px"},children:[c&&n.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:l.loading}),!c&&n.jsxs("div",{style:{position:"relative",paddingLeft:20},children:[n.jsx("div",{style:{position:"absolute",left:8,top:0,bottom:0,width:2,background:"#e5e7eb"}}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[h.map((x,o)=>n.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[n.jsx("div",{style:g(o===0?"#3498db":"#d1d5db",o===0)}),n.jsxs("div",{style:{background:o===0?"#eff6ff":"#f9fafb",border:`1px solid ${o===0?"#bfdbfe":"#e5e7eb"}`,borderRadius:8,padding:"10px 14px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[n.jsx("div",{style:{width:26,height:26,borderRadius:"50%",background:"#3498db",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flexShrink:0},children:zu(x.owner)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:Wo(x.owner)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:ku(x.creation)})]}),x.changes.length>0?n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:x.changes.map((y,_)=>n.jsxs("div",{style:{fontSize:12,lineHeight:1.5},children:[n.jsx("span",{style:{fontWeight:600,color:"#6d28d9"},children:g0(y.field)}),n.jsx("span",{style:{color:"#6b7280"},children:" changed from "}),n.jsx("span",{style:{padding:"1px 5px",background:"#fee2e2",color:"#dc2626",borderRadius:3,fontSize:11,fontFamily:"monospace"},children:y.oldVal}),n.jsx("span",{style:{color:"#6b7280"},children:" → "}),n.jsx("span",{style:{padding:"1px 5px",background:"#dcfce7",color:"#16a34a",borderRadius:3,fontSize:11,fontFamily:"monospace"},children:y.newVal})]},_))}):n.jsxs("div",{style:{fontSize:12,color:"#9ca3af",fontStyle:"italic"},children:["Document updated",x.added>0&&n.jsxs("span",{children:[" · +",x.added," row(s)"]}),x.removed>0&&n.jsxs("span",{children:[" · -",x.removed," row(s)"]}),x.rowChanged>0&&n.jsxs("span",{children:[" · ~",x.rowChanged," row(s) modified"]})]})]})]},x.name)),s&&r&&n.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[n.jsx("div",{style:g("#22c55e")}),n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:"10px 14px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[n.jsx("div",{style:{width:26,height:26,borderRadius:"50%",background:"#22c55e",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flexShrink:0},children:zu(r)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:Wo(r)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:ku(s)})]}),n.jsxs("div",{style:{fontSize:12,color:"#15803d",fontWeight:600},children:["✓ ",l.activity.created]})]})]}),a.length===0&&!s&&n.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:"No activity recorded"})]})]}),!c&&S>0&&n.jsx("div",{style:{textAlign:"center",marginTop:12},children:n.jsx("button",{onClick:()=>u(x=>!x),style:{background:"none",border:"none",cursor:"pointer",color:"#3498db",fontSize:12,fontFamily:"Segoe UI",padding:"4px 8px"},children:p?"▲ Show less":`▼ Show all (${a.length})`})})]})]})}const m0={New:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Initial Evaluation":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},"Accept & Under Progress":{background:"#fefce8",color:"#92400e",border:"1px solid #fde68a"},"working on resolution":{background:"#f5f3ff",color:"#6d28d9",border:"1px solid #ddd6fe"},Rejected:{background:"#fef2f2",color:"#dc2626",border:"1px solid #fecaca"},"Executed & Closed":{background:"#f0fdf4",color:"#166534",border:"1px solid #bbf7d0"}};function y0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...m0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function v0({incForm:e,setIncForm:t,organizations:s,managements:r,departments:l,branches:a,incidentTypes:i,incidentClasses:c,incidentFields:d,incidentStatuses:f,users:v,userRoleMap:p={},formStatus:u,viewMode:m,canModify:j,onEdit:h,onDelete:S,onRestore:g,darkMode:x,notifCount:o,onToggleDark:y,onCountChange:_,onViewProfile:C,userRole:P,onSubmit:k,onBack:R,onNavigate:$,onLogout:Z,user:de,onRefresh:D}){var Ze;const T=se(),E=W=>t({...e,...W}),B=m?{background:"#f9f9f9"}:{},M=Sr(v,p,"SB Manager",e.organization),[A,K]=w.useState(""),[Y,ee]=w.useState(!1),V=e.name?m?`${T.formTitle.viewIncident}${e.number||e.name}`:T.formTitle.editIncident:T.formTitle.newIncident,ze=me(r,e.management).map(W=>({name:W.name,label:W.name1||W.name})),$e=me(l,e.department).map(W=>({name:W.name,label:W.department_name||W.name})),Oe=me(a,e.branch).map(W=>({name:W.name,label:W.branch||W.name})),ge=me(i,e.type).map(W=>({name:W.name,label:W.name1||W.name})),Je=me(c,e.incident_class).map(W=>({name:W.name,label:W.name1||W.name})),Q=me(d,e.incident_field).map(W=>({name:W.name,label:W.name1||W.name})),ne=e.workflow_state||"New",gt=P==="Employee",re=P==="Auditor"||P==="Admin",lt=P==="Manager",jt=e.name?ne==="New"?[{label:T.wf.submit,action:"Submit",color:"#2563eb"}]:ne==="Initial Evaluation"&&re?[{label:T.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:T.wf.reject,action:"Reject",color:"#dc2626"}]:ne==="Accept & Under Progress"&&(lt||re)?[{label:T.wf.submitSolution,action:"Submit Solution",color:"#059669"}]:ne==="working on resolution"&&(lt||re)?[{label:T.wf.resolutionComplete,action:"Resolution complete",color:"#166534"}]:[]:[];async function Qe(W){if(e.name){ee(!0),K("");try{const je={};W==="Assign to Manager"&&(e.assigned_to&&(je.assigned_to=e.assigned_to),e.priority&&(je.priority=e.priority),e.economy_class&&(je.economy_class=e.economy_class),e.entity_scope&&(je.entity_scope=e.entity_scope),e.hses_field&&(je.hses_field=e.hses_field),je.product_relation=String(e.product_relation??0),je.repeated=String(e.repeated??0)),W==="Submit Solution"&&(e.solution&&(je.solution=e.solution),e.summary&&(je.summary=e.summary),e.cost&&(je.cost=String(e.cost))),(W==="Resolution complete"||W==="Submit Solution")&&e.auditor_comment&&(je.auditor_comment=e.auditor_comment),await Wy(e.name,W,JSON.stringify(je)),K("Done"),D==null||D()}catch(je){K(je.message||"Error")}finally{ee(!1)}}}const U=((Ze=M.find(W=>W.name===e.assigned_to))==null?void 0:Ze.full_name)||e.assigned_to,Te=e.name?n.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:T.wf.workflow}),n.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px",marginBottom:12},children:[n.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:4},children:"Current State"}),n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b"},children:ne})]}),ne==="Initial Evaluation"&&re&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("label",{style:z,children:T.wf.assignToManager}),n.jsxs("select",{style:I,value:e.assigned_to||"",onChange:W=>E({assigned_to:W.target.value}),children:[n.jsx("option",{value:"",children:T.field.selectMgr}),M.map(W=>n.jsx("option",{value:W.name,children:W.full_name||W.name},W.name))]})]}),(ne==="Accept & Under Progress"||ne==="working on resolution")&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("label",{style:z,children:T.field.solution}),n.jsx("textarea",{style:{...I,height:75,resize:"vertical"},value:e.solution||"",onChange:W=>E({solution:W.target.value}),placeholder:T.field.solutionPlaceholder}),n.jsx("label",{style:{...z,marginTop:6},children:T.field.actualCost}),n.jsx("input",{type:"number",style:I,value:e.cost||"",onChange:W=>E({cost:parseFloat(W.target.value)||0}),placeholder:"0.00"})]}),ne==="working on resolution"&&re&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("label",{style:z,children:T.field.auditorComment}),n.jsx("textarea",{style:{...I,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:W=>E({auditor_comment:W.target.value}),placeholder:T.field.commentPlaceholder})]}),jt.length>0?n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:jt.map(W=>n.jsx("button",{onClick:()=>Qe(W.action),disabled:Y,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:W.color,color:"white",fontWeight:600,fontSize:12,cursor:Y?"not-allowed":"pointer",opacity:Y?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:n.jsx("span",{children:Y?T.wf.applying:W.label})},W.action))}):n.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:T.wf.noActions}),A&&n.jsx("p",{style:{marginTop:8,fontSize:12,color:A==="Done"?F.green:F.red},children:A})]}),n.jsx(si,{priority:e.priority,status:ne,assignedTo:re?U:void 0,createdDate:e.date,modifiedDate:e.modified}),n.jsx(li,{doctype:L.incidents,docname:e.name,currentUserName:de.name}),n.jsx(ai,{doctype:L.incidents,docname:e.name,docCreation:e.creation,docOwner:e.owner}),j&&S&&!e.custom_is_deleted&&n.jsx(ni,{title:"Delete Request",btnText:T.delete,onDelete:()=>S(e.name)})]}):null;return n.jsxs(Ke,{title:V,activePage:"incidents",user:de,formStatus:u,statusBadge:n.jsx("span",{style:y0(ne),children:ne}),buttonText:T.saveIncident,buttonColor:"#16a34a",viewMode:m,onEdit:h,darkMode:x,notifCount:o,onToggleDark:y,onCountChange:_,onViewProfile:C,rightPanel:Te,onSubmit:k,onBack:R,onNavigate:$,onLogout:Z,children:[e.custom_is_deleted===1&&n.jsx(zl,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:g?()=>g(e.name):void 0}),n.jsx(ae,{title:"Incident Information",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.number}),n.jsx("input",{style:{...I,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[T.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ut,{value:e.organization,onChange:W=>E({organization:W}),organizations:s,disabled:m||!!de.custom_organization})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.title}),n.jsx("input",{style:{...I,...B},value:e.title,disabled:m,onChange:W=>E({title:W.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.management}),n.jsx(pe,{value:e.management,onChange:W=>E({management:W}),items:ze,placeholder:T.field.select,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.department}),n.jsx(pe,{value:e.department,onChange:W=>E({department:W}),items:$e,placeholder:T.field.select,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.section}),n.jsx("input",{style:{...I,...B},value:e.section_field||"",disabled:m,onChange:W=>E({section_field:W.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.branch}),n.jsx(pe,{value:e.branch,onChange:W=>E({branch:W}),items:Oe,placeholder:T.field.select,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.type}),n.jsx(pe,{value:e.type,onChange:W=>E({type:W}),items:ge,placeholder:T.field.selectType,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.incidentClass}),n.jsx(pe,{value:e.incident_class,onChange:W=>E({incident_class:W}),items:Je,placeholder:T.field.selectClass,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.incidentField}),n.jsx(pe,{value:e.incident_field,onChange:W=>E({incident_field:W}),items:Q,placeholder:T.field.selectField,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.hsesField}),n.jsx("input",{style:{...I,...B},value:e.hses_field||"",disabled:m,onChange:W=>E({hses_field:W.target.value}),placeholder:"Safety, Health, Environment…"})]})]})}),n.jsxs(ae,{title:"Incident Details & Timing",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.date}),n.jsx(xe,{value:e.date,onChange:W=>E({date:W}),disabled:!0,style:{...I,background:"#f8fafc"}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.time}),n.jsx("input",{type:"time",style:{...I,background:"#f8fafc"},value:e.time,disabled:!0,readOnly:!0})]}),re&&n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.assignedTo}),m?n.jsx("input",{style:{...I,background:"#f8fafc",fontWeight:600,color:"#334155"},value:U||"—",readOnly:!0,disabled:!0}):n.jsx(pe,{value:e.assigned_to||"",onChange:W=>E({assigned_to:W}),items:M.map(W=>({name:W.name,label:W.full_name||W.name})),placeholder:T.field.select})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.description}),n.jsx("textarea",{style:{...I,...B,height:100,resize:"vertical"},value:e.description,disabled:m,onChange:W=>E({description:W.target.value}),placeholder:"Detailed description of the incident..."})]})]}),!gt&&n.jsxs(ae,{title:T.steps.auditorTriage,children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.priority}),n.jsxs("select",{style:{...I,...m||!re?{background:"#f8fafc"}:{}},value:e.priority||"",disabled:m||!re,onChange:W=>E({priority:W.target.value}),children:[n.jsx("option",{value:"",children:T.field.select}),n.jsx("option",{value:"High",children:T.field.high}),n.jsx("option",{value:"Normal",children:T.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.economyClass}),n.jsxs("select",{style:{...I,...m||!re?{background:"#f8fafc"}:{}},value:e.economy_class||"",disabled:m||!re,onChange:W=>E({economy_class:W.target.value}),children:[n.jsx("option",{value:"",children:T.field.select}),n.jsx("option",{value:"Expenses",children:T.field.expenses}),n.jsx("option",{value:"Capital",children:T.field.capital}),n.jsx("option",{value:"Earn",children:T.field.earn}),n.jsx("option",{value:"Pay/Loss",children:T.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.entityScope}),n.jsxs("select",{style:{...I,...m||!re?{background:"#f8fafc"}:{}},value:e.entity_scope||"",disabled:m||!re,onChange:W=>E({entity_scope:W.target.value}),children:[n.jsx("option",{value:"",children:T.field.select}),n.jsx("option",{value:"Upstream",children:T.field.upstream}),n.jsx("option",{value:"On-stream",children:T.field.onstream}),n.jsx("option",{value:"Downstream",children:T.field.downstream})]})]})]}),n.jsxs("div",{style:{display:"flex",gap:20,marginTop:12,alignItems:"center",flexWrap:"wrap"},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:m||!re,onChange:W=>E({product_relation:W.target.checked?1:0})})," ",T.field.productRelation]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.repeated,disabled:m||!re,onChange:W=>E({repeated:W.target.checked?1:0})})," ",T.field.repeatedEvent]})]})]}),!gt&&n.jsxs(ae,{title:T.steps.managerSolution,children:[n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:z,children:T.field.solution}),n.jsx("textarea",{style:{...I,height:90,resize:"vertical",...m&&!lt&&!re?{background:"#f8fafc"}:{}},value:e.solution||"",disabled:m&&!lt&&!re,onChange:W=>E({solution:W.target.value}),placeholder:T.field.solutionPlaceholder})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:12},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.actualCost}),n.jsx("input",{type:"number",style:{...I,...m&&!lt&&!re?{background:"#f8fafc"}:{}},value:e.cost||"",disabled:m&&!lt&&!re,onChange:W=>E({cost:parseFloat(W.target.value)||0}),placeholder:"0.00"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.summary}),n.jsx("input",{style:{...I,...m&&!lt&&!re?{background:"#f8fafc"}:{}},value:e.summary||"",disabled:m&&!lt&&!re,onChange:W=>E({summary:W.target.value}),placeholder:"Brief summary"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.auditorComment}),n.jsx("textarea",{style:{...I,height:70,resize:"vertical",...m&&!re?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:m&&!re,onChange:W=>E({auditor_comment:W.target.value}),placeholder:T.field.commentPlaceholder})]})]})]})}function j0({ideas:e,organizations:t,departments:s,branches:r,ideaStatuses:l,initialOrg:a,initialStatus:i,canModify:c,onView:d,onEdit:f,onDelete:v}){const p=se(),[u,m]=w.useState({search:"",organization:a||"",department:"",branch:"",status:i||""}),j=(o,y)=>m(_=>({..._,[o]:y})),[h,S]=w.useState(1),g=e.filter(o=>!(u.search&&!`${o.number} ${o.title}`.toLowerCase().includes(u.search.toLowerCase())||u.organization&&o.organization!==u.organization||u.department&&o.department!==u.department||u.branch&&o.branch!==u.branch||u.status&&o.status!==u.status));w.useEffect(()=>{S(1)},[u]);const x=g.slice((h-1)*ie,h*ie);return n.jsxs(n.Fragment,{children:[n.jsx(ri,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"10px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.numberTitle}),n.jsx("input",{style:qe,value:u.search,onChange:o=>j("search",o.target.value),placeholder:p.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.organization}),n.jsxs("select",{style:qe,value:u.organization,onChange:o=>j("organization",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.department}),n.jsxs("select",{style:qe,value:u.department,onChange:o=>j("department",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allDepts}),s.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.branch}),n.jsxs("select",{style:qe,value:u.branch,onChange:o=>j("branch",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allBranches}),r.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.status}),n.jsxs("select",{style:qe,value:u.status,onChange:o=>j("status",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allStatuses}),l.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>m({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"7px 14px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#475569",fontWeight:500},children:p.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.number}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.title}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.organization}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.status}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.actions})]})}),n.jsx("tbody",{children:g.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:p.noIdeas})}):x.map((o,y)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>d==null?void 0:d(o),style:{borderTop:"1px solid #f1f5f9",background:o.custom_is_deleted?"#fff1f2":y%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[n.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:o.number||"—"}),n.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[n.jsx("span",{children:o.title||"—"}),o.sb_order&&n.jsxs("span",{style:{fontSize:11,background:"#f0fdf4",color:"#15803d",border:"1px solid #bbf7d0",borderRadius:9999,padding:"2px 8px",fontWeight:600},children:["📦 ",o.sb_order]})]})}),n.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"12px 16px"},children:o.custom_is_deleted?Xn(p.deletedBadge):o.status?Xn(o.status):"—"}),n.jsx("td",{style:{padding:"10px 16px"},onClick:_=>_.stopPropagation(),children:n.jsx(nt,{onView:()=>d==null?void 0:d(o),onEdit:c&&f&&!o.custom_is_deleted&&!Nn("idea",o.workflow_state)?()=>f(o):void 0,onDelete:c&&v&&!o.custom_is_deleted?()=>v(o.name):void 0})})]},o.name))})]})}),n.jsx(Ge,{page:h,total:g.length,onPageChange:S})]})}const b0={New:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Initial Evaluation":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},"Accept & Under Progress":{background:"#fefce8",color:"#92400e",border:"1px solid #fde68a"},"working on proposal":{background:"#f5f3ff",color:"#6d28d9",border:"1px solid #ddd6fe"},Rejected:{background:"#fef2f2",color:"#dc2626",border:"1px solid #fecaca"},"Executed & Closed":{background:"#f0fdf4",color:"#166534",border:"1px solid #bbf7d0"}};function S0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...b0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function w0({ideaForm:e,setIdeaForm:t,organizations:s,managements:r,departments:l,branches:a,ideaTypes:i,ideaStatuses:c,users:d=[],userRoleMap:f={},formStatus:v,viewMode:p,canModify:u,onEdit:m,onDelete:j,onRestore:h,onNavigateToOrder:S,darkMode:g,notifCount:x,onToggleDark:o,onCountChange:y,onViewProfile:_,userRole:C,onSubmit:P,onBack:k,onNavigate:R,onLogout:$,user:Z,onRefresh:de}){var Qe;const D=se(),T=U=>t({...e,...U}),E=p?{background:"#f9f9f9"}:{},B=Sr(d,f,"SB Manager",e.organization),[M,A]=w.useState(""),[K,Y]=w.useState(!1),ee=e.name?p?`${D.formTitle.viewIdea}${e.number||e.title||e.name}`:D.formTitle.editIdea:D.formTitle.newIdea,V=me(r,e.management).map(U=>({name:U.name,label:U.name1||U.name})),ze=me(l,e.department).map(U=>({name:U.name,label:U.department_name||U.name})),$e=me(a,e.branch).map(U=>({name:U.name,label:U.branch||U.name})),Oe=me(i,e.type).map(U=>({name:U.name,label:U.name1||U.name})),ge=e.workflow_state||"New",Je=C==="Employee",Q=C==="Auditor"||C==="Admin",ne=C==="Manager",gt=e.name?ge==="New"?[{label:D.wf.submit,action:"Submit",color:"#2563eb"}]:ge==="Initial Evaluation"&&Q?[{label:D.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:D.wf.reject,action:"Reject",color:"#dc2626"}]:ge==="Accept & Under Progress"&&(ne||Q)?[{label:D.wf.submitSolution,action:"Submit Proposal",color:"#059669"}]:ge==="working on proposal"&&Q?[{label:D.wf.moveToOutsourcing,action:"Move to Outsourcing",color:"#0369a1"},{label:D.wf.reject,action:"Reject",color:"#dc2626"}]:[]:[];async function re(U){if(e.name){Y(!0),A("");try{const Te={};U==="Assign to Manager"&&(e.assigned_to&&(Te.assigned_to=e.assigned_to),e.priority&&(Te.priority=e.priority),e.economy_class&&(Te.economy_class=e.economy_class),e.entity_scope&&(Te.entity_scope=e.entity_scope),e.hses_field&&(Te.hses_field=e.hses_field),Te.product_relation=String(e.product_relation??0),Te.repeated=String(e.repeated??0)),U==="Submit Proposal"&&(e.solution&&(Te.solution=e.solution),e.proposed_condition&&(Te.proposed_condition=e.proposed_condition),e.cost&&(Te.cost=String(e.cost))),e.auditor_comment&&(U==="Move to Outsourcing"||U==="Reject")&&(Te.auditor_comment=e.auditor_comment);const Ze=await By(e.name,U,JSON.stringify(Te));Ze!=null&&Ze.created_order&&T({sb_order:Ze.created_order,workflow_state:"Executed & Closed",status:"Executed & Closed"}),A("Done"),de==null||de()}catch(Te){A(Te.message||"Error")}finally{Y(!1)}}}const lt=((Qe=B.find(U=>U.name===e.assigned_to))==null?void 0:Qe.full_name)||e.assigned_to,jt=e.name?n.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:D.wf.workflow}),n.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px",marginBottom:12},children:[n.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:4},children:"Current State"}),n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b"},children:ge})]}),ge==="Initial Evaluation"&&Q&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("label",{style:z,children:D.wf.assignToManager}),n.jsxs("select",{style:I,value:e.assigned_to||"",onChange:U=>T({assigned_to:U.target.value}),children:[n.jsx("option",{value:"",children:D.field.selectMgr}),B.map(U=>n.jsx("option",{value:U.name,children:U.full_name||U.name},U.name))]})]}),ge==="Accept & Under Progress"&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("label",{style:z,children:D.field.solution}),n.jsx("textarea",{style:{...I,height:75,resize:"vertical"},value:e.solution||"",onChange:U=>T({solution:U.target.value}),placeholder:D.field.solutionPlaceholder}),n.jsx("label",{style:{...z,marginTop:6},children:D.field.actualCost}),n.jsx("input",{type:"number",style:I,value:e.cost||"",onChange:U=>T({cost:parseFloat(U.target.value)||0}),placeholder:"0.00"})]}),ge==="working on proposal"&&Q&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("label",{style:z,children:D.field.auditorComment}),n.jsx("textarea",{style:{...I,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:U=>T({auditor_comment:U.target.value}),placeholder:D.field.commentPlaceholder})]}),gt.length>0?n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:gt.map(U=>n.jsx("button",{onClick:()=>re(U.action),disabled:K,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:U.color,color:"white",fontWeight:600,fontSize:12,cursor:K?"not-allowed":"pointer",opacity:K?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:n.jsx("span",{children:K?D.wf.applying:U.label})},U.action))}):n.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:D.wf.noActions}),M&&n.jsx("p",{style:{marginTop:8,fontSize:12,color:M==="Done"?F.green:F.red},children:M})]}),n.jsx(si,{priority:e.priority,status:ge,assignedTo:Q?lt:void 0,createdDate:e.date,modifiedDate:e.modified}),n.jsx(li,{doctype:L.ideas,docname:e.name,currentUserName:Z.name}),n.jsx(ai,{doctype:L.ideas,docname:e.name,docCreation:e.creation,docOwner:e.owner}),u&&j&&!e.custom_is_deleted&&n.jsx(ni,{title:"Delete Request",btnText:D.delete,onDelete:()=>j(e.name)})]}):null;return n.jsxs(Ke,{title:ee,activePage:"ideas",user:Z,formStatus:v,statusBadge:n.jsx("span",{style:S0(ge),children:ge}),buttonText:D.saveIdea,buttonColor:"#16a34a",viewMode:p,onEdit:m,darkMode:g,notifCount:x,onToggleDark:o,onCountChange:y,onViewProfile:_,rightPanel:jt,onSubmit:P,onBack:k,onNavigate:R,onLogout:$,children:[e.custom_is_deleted===1&&n.jsx(zl,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:h?()=>h(e.name):void 0}),e.sb_order&&n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:"8px 14px",marginBottom:16,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontSize:12},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[n.jsx("span",{style:{fontSize:14,flexShrink:0},children:"📦"}),n.jsxs("span",{style:{fontSize:11,fontWeight:700,color:"#15803d",textTransform:"uppercase",letterSpacing:"0.4px",whiteSpace:"nowrap"},children:[D.field.convertedToOrder,":"]}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#14532d",whiteSpace:"nowrap"},children:e.sb_order})]}),S&&n.jsxs("button",{type:"button",onClick:()=>S(e.sb_order),style:{background:"#16a34a",color:"#fff",border:"none",borderRadius:6,padding:"4px 10px",fontWeight:600,fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,flexShrink:0,transition:"background 0.15s ease"},onMouseEnter:U=>U.currentTarget.style.background="#15803d",onMouseLeave:U=>U.currentTarget.style.background="#16a34a",children:[D.field.viewOrder," →"]})]}),n.jsx(ae,{title:"Idea Information",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.number}),n.jsx("input",{style:{...I,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[D.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ut,{value:e.organization,onChange:U=>T({organization:U}),organizations:s,disabled:p||!!Z.custom_organization})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.title}),n.jsx("input",{style:{...I,...E},value:e.title,disabled:p,onChange:U=>T({title:U.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.management}),n.jsx(pe,{value:e.management,onChange:U=>T({management:U}),items:V,placeholder:D.field.select,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.department}),n.jsx(pe,{value:e.department,onChange:U=>T({department:U}),items:ze,placeholder:D.field.select,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.section}),n.jsx("input",{style:{...I,...E},value:e.section_field||"",disabled:p,onChange:U=>T({section_field:U.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.branch}),n.jsx(pe,{value:e.branch,onChange:U=>T({branch:U}),items:$e,placeholder:D.field.select,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.type}),n.jsx(pe,{value:e.type,onChange:U=>T({type:U}),items:Oe,placeholder:D.field.selectType,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.ideaClass}),n.jsxs("select",{style:{...I,...E},value:e.idea_class||"",disabled:p,onChange:U=>T({idea_class:U.target.value}),children:[n.jsx("option",{value:"",children:D.field.select}),n.jsx("option",{value:"Safety",children:"Safety"}),n.jsx("option",{value:"Non-safety",children:"Non-safety"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.hsesField}),n.jsx("input",{style:{...I,...E},value:e.hses_field||"",disabled:p,onChange:U=>T({hses_field:U.target.value}),placeholder:"Safety, Health, Environment…"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.date}),n.jsx(xe,{value:e.date||"",onChange:U=>T({date:U}),disabled:!0,style:{...I,background:"#f8fafc"}})]}),Q&&n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.assignedTo}),p?n.jsx("input",{style:{...I,background:"#f8fafc",fontWeight:600,color:"#334155"},value:lt||"—",readOnly:!0,disabled:!0}):n.jsx(pe,{value:e.assigned_to||"",onChange:U=>T({assigned_to:U}),items:B.map(U=>({name:U.name,label:U.full_name||U.name})),placeholder:D.field.select})]})]})}),n.jsx(ae,{title:"Condition Details & Description",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.currentCondition}),n.jsx("textarea",{style:{...I,...E,height:100,resize:"vertical"},value:e.current_condition,disabled:p,onChange:U=>T({current_condition:U.target.value}),placeholder:"Describe the current condition or problem..."})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.proposedCondition}),n.jsx("textarea",{style:{...I,...E,height:100,resize:"vertical"},value:e.proposed_condition,disabled:p,onChange:U=>T({proposed_condition:U.target.value}),placeholder:"Describe the proposed solution or improvement..."})]})]})}),!Je&&n.jsxs(ae,{title:D.steps.auditorEval,children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.priority}),n.jsxs("select",{style:{...I,...p&&!Q?{background:"#f8fafc"}:{}},value:e.priority||"",disabled:p&&!Q,onChange:U=>T({priority:U.target.value}),children:[n.jsx("option",{value:"",children:D.field.select}),n.jsx("option",{value:"High",children:D.field.high}),n.jsx("option",{value:"Normal",children:D.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.economyClass}),n.jsxs("select",{style:{...I,...p&&!Q?{background:"#f8fafc"}:{}},value:e.economy_class||"",disabled:p&&!Q,onChange:U=>T({economy_class:U.target.value}),children:[n.jsx("option",{value:"",children:D.field.select}),n.jsx("option",{value:"Expenses",children:D.field.expenses}),n.jsx("option",{value:"Capital",children:D.field.capital}),n.jsx("option",{value:"Earn",children:D.field.earn}),n.jsx("option",{value:"Pay/Loss",children:D.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.entityScope}),n.jsxs("select",{style:{...I,...p&&!Q?{background:"#f8fafc"}:{}},value:e.entity_scope||"",disabled:p&&!Q,onChange:U=>T({entity_scope:U.target.value}),children:[n.jsx("option",{value:"",children:D.field.select}),n.jsx("option",{value:"Upstream",children:D.field.upstream}),n.jsx("option",{value:"On-stream",children:D.field.onstream}),n.jsx("option",{value:"Downstream",children:D.field.downstream})]})]})]}),n.jsxs("div",{style:{display:"flex",gap:20,marginTop:12,alignItems:"center",flexWrap:"wrap"},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:p&&!Q,onChange:U=>T({product_relation:U.target.checked?1:0})})," ",D.field.productRelation]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.repeated,disabled:p&&!Q,onChange:U=>T({repeated:U.target.checked?1:0})})," ",D.field.repeatedEvent]})]})]}),!Je&&n.jsxs(ae,{title:D.steps.managerSolution,children:[n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:z,children:D.field.solution}),n.jsx("textarea",{style:{...I,height:90,resize:"vertical",...p&&!ne&&!Q?{background:"#f8fafc"}:{}},value:e.solution||"",disabled:p&&!ne&&!Q,onChange:U=>T({solution:U.target.value}),placeholder:D.field.solutionPlaceholder})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.actualCost}),n.jsx("input",{type:"number",style:{...I,...p&&!ne&&!Q?{background:"#f8fafc"}:{}},value:e.cost||"",disabled:p&&!ne&&!Q,onChange:U=>T({cost:parseFloat(U.target.value)||0}),placeholder:"0.00"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:D.field.auditorComment}),n.jsx("textarea",{style:{...I,height:60,resize:"vertical",...p&&!Q?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:p&&!Q,onChange:U=>T({auditor_comment:U.target.value}),placeholder:D.field.commentPlaceholder})]})]})]})]})}function _0({orders:e,organizations:t,departments:s,branches:r,orderStatuses:l,initialOrg:a,initialStatus:i,canModify:c,onView:d,onEdit:f,onDelete:v}){const p=se(),[u,m]=w.useState({search:"",organization:a||"",department:"",branch:"",status:i||""}),j=(o,y)=>m(_=>({..._,[o]:y})),[h,S]=w.useState(1),g=e.filter(o=>!(u.search&&!`${o.number} ${o.title}`.toLowerCase().includes(u.search.toLowerCase())||u.organization&&o.organization!==u.organization||u.department&&o.department!==u.department||u.branch&&o.branch!==u.branch||u.status&&o.status!==u.status));w.useEffect(()=>{S(1)},[u]);const x=g.slice((h-1)*ie,h*ie);return n.jsxs(n.Fragment,{children:[n.jsx(ri,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"10px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.numberTitle}),n.jsx("input",{style:qe,value:u.search,onChange:o=>j("search",o.target.value),placeholder:p.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.organization}),n.jsxs("select",{style:qe,value:u.organization,onChange:o=>j("organization",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.department}),n.jsxs("select",{style:qe,value:u.department,onChange:o=>j("department",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allDepts}),s.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.branch}),n.jsxs("select",{style:qe,value:u.branch,onChange:o=>j("branch",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allBranches}),r.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.status}),n.jsxs("select",{style:qe,value:u.status,onChange:o=>j("status",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allStatuses}),l.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>m({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"7px 14px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#475569",fontWeight:500},children:p.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.number}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.title}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.organization}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.type}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.status}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.actions})]})}),n.jsx("tbody",{children:g.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:p.noOrders})}):x.map((o,y)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>d==null?void 0:d(o),style:{borderTop:"1px solid #f1f5f9",background:o.custom_is_deleted?"#fff1f2":y%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[n.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:o.number||"—"}),n.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[n.jsx("span",{children:o.title||"—"}),o.sb_idea&&n.jsxs("span",{style:{fontSize:11,background:"#eff6ff",color:"#1d4ed8",border:"1px solid #bfdbfe",borderRadius:9999,padding:"2px 8px",fontWeight:600},children:["💡 ",o.sb_idea]})]})}),n.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"12px 16px"},children:o.type?Rd(o.type):"—"}),n.jsx("td",{style:{padding:"12px 16px"},children:o.custom_is_deleted?Xn(p.deletedBadge):o.status?Xn(o.status):"—"}),n.jsx("td",{style:{padding:"10px 16px"},onClick:_=>_.stopPropagation(),children:n.jsx(nt,{onView:()=>d==null?void 0:d(o),onEdit:c&&f&&!o.custom_is_deleted&&!Nn("order",o.workflow_state)?()=>f(o):void 0,onDelete:c&&v&&!o.custom_is_deleted?()=>v(o.name):void 0})})]},o.name))})]})}),n.jsx(Ge,{page:h,total:g.length,onPageChange:S})]})}const k0={1:"Initiation / Bidding",2:"Execution begins",3:"Mid-execution review",4:"Near completion",5:"Closing"},C0={Draft:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Pending Actor":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},Review:{background:"#fefce8",color:"#92400e",border:"1px solid #fde68a"},"In Study":{background:"#f5f3ff",color:"#6d28d9",border:"1px solid #ddd6fe"},Closed:{background:"#f0fdf4",color:"#166534",border:"1px solid #bbf7d0"}};function z0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...C0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function T0({orderForm:e,setOrderForm:t,organizations:s,managements:r,departments:l,branches:a,orderTypes:i,orderStatuses:c,cycles:d=[],users:f=[],userRoleMap:v={},formStatus:p,viewMode:u,canModify:m,onEdit:j,onDelete:h,onRestore:S,onNavigateToIdea:g,darkMode:x,notifCount:o,onToggleDark:y,onCountChange:_,onViewProfile:C,currentUser:P,userRole:k,onSubmit:R,onBack:$,onNavigate:Z,onLogout:de,user:D,onRefresh:T}){var dn,Il;const E=se(),B=N=>t({...e,...N}),M=u?{background:"#f9f9f9"}:{},A=Sr(f,v,"SB Employee",e.organization),[K,Y]=w.useState(""),[ee,V]=w.useState(""),[ze,$e]=w.useState(!1),[Oe,ge]=w.useState("Agree"),Je=e.name?u?`${E.formTitle.viewOrder}${e.number||e.title||e.name}`:E.formTitle.editOrder:E.formTitle.newOrder,Q=me(r,e.management).map(N=>({name:N.name,label:N.name1||N.name})),ne=me(l,e.department).map(N=>({name:N.name,label:N.department_name||N.name})),gt=me(a,e.branch).map(N=>({name:N.name,label:N.branch||N.name})),re=me(i,e.type).map(N=>({name:N.name,label:N.name1||N.name})),lt=me(d,e.cycle).map(N=>({name:N.name,label:N.name1||N.cycle_name||N.name})),jt=!!e.name,Qe=e.workflow_state||"Draft",U=Math.min(5,(e.stage||0)+1),[Te,Ze]=w.useState(U);w.useEffect(()=>{Ze(Math.min(5,(e.stage||0)+1))},[e.stage]);const W=k==="Auditor"||k==="Admin"||k==="Manager",je=W||k==="Owner",O=!!(P&&(e.actor===P||e.assigned_to===P)),le=jt?Qe==="Closed"?[]:Qe==="Draft"&&W?[{label:"Submit for Review",action:"Submit for Review",color:"#2563eb"}]:Qe==="Pending Actor"&&(O||W)?[{label:"Update Status",action:"Update Status",color:"#d97706"}]:Qe==="Review"&&je?[{label:"Move to Study",action:"Move to Study",color:"#059669"},{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"}]:Qe==="In Study"&&je?[{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"},{label:"Close Order",action:"Close Order",color:"#475569"}]:[]:[];async function X(N){if(e.name){$e(!0),Y("");try{let Ct;N==="Update Status"&&(Ct=Oe);const cn=await Ny(e.name,N,ee,N==="Update Status"?String(Te):void 0,void 0,Ct);if(V(""),ge("Agree"),Y("Done"),cn){const zn=cn;t({...e,...zn,stage:zn.stage??e.stage,completion_pct:zn.completion_pct??e.completion_pct,workflow_state:zn.workflow_state??e.workflow_state})}T==null||T()}catch(Ct){Y(Ct.message||"Error")}finally{$e(!1)}}}const Vn=((dn=A.find(N=>N.name===(e.actor||e.assigned_to)))==null?void 0:dn.full_name)||e.actor||e.assigned_to,ii=jt?n.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:E.wf.workflow}),n.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px",marginBottom:12},children:[n.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:4},children:"Current State"}),n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b"},children:Qe})]}),Qe==="Pending Actor"&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:12},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:["Stage (1–5) — ",Te*20,"% complete"]}),n.jsx("input",{type:"number",min:1,max:5,style:{...I,width:"100%"},value:Te,onChange:N=>Ze(Math.min(5,Math.max(1,parseInt(N.target.value)||1)))})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Cycle Status"}),n.jsxs("select",{style:I,value:Oe,onChange:N=>ge(N.target.value),children:[n.jsx("option",{value:"Agree",children:"✅ Agree — on track"}),n.jsx("option",{value:"Deviate",children:"⚠️ Deviate — off plan"}),n.jsx("option",{value:"Unknown",children:"❓ Unknown"})]})]})]}),n.jsxs("div",{style:{marginBottom:12},children:[n.jsxs("label",{style:z,children:["Comment ",Oe==="Deviate"&&Qe==="Pending Actor"?n.jsx("span",{style:{color:F.red},children:" * required for Deviate"}):"(optional)"]}),n.jsx("textarea",{style:{...I,height:60,resize:"vertical",borderColor:Oe==="Deviate"&&!ee?"#fca5a5":void 0},value:ee,onChange:N=>V(N.target.value),placeholder:"Add a comment…"})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:le.map(N=>{const Ct=N.action==="Update Status"&&Oe==="Deviate"&&!ee.trim();return n.jsx("button",{onClick:()=>X(N.action),disabled:ze||Ct,title:Ct?"Comment required when status is Deviate":void 0,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:N.color,color:"white",fontWeight:600,fontSize:12,cursor:ze||Ct?"not-allowed":"pointer",opacity:ze||Ct?.5:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:n.jsx("span",{children:ze?E.wf.applying:N.label})},N.action)})}),K&&n.jsx("p",{style:{marginTop:8,fontSize:12,color:K==="Done"?F.green:F.red},children:K}),le.length===0&&n.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:E.wf.noActions})]}),n.jsx(si,{priority:e.priority,status:Qe,assignedTo:W?Vn:void 0,createdDate:e.starting_date,modifiedDate:e.modified}),n.jsx(li,{doctype:L.orders,docname:e.name,currentUserName:D.name}),n.jsx(ai,{doctype:L.orders,docname:e.name,docCreation:e.creation,docOwner:e.owner}),m&&h&&!e.custom_is_deleted&&n.jsx(ni,{title:"Delete Request",btnText:E.delete,onDelete:()=>h(e.name)})]}):null;return n.jsxs(Ke,{title:Je,activePage:"orders",user:D,formStatus:p,statusBadge:n.jsx("span",{style:z0(Qe),children:Qe}),buttonText:E.saveOrder,buttonColor:"#16a34a",viewMode:u,onEdit:j,darkMode:x,notifCount:o,onToggleDark:y,onCountChange:_,onViewProfile:C,rightPanel:ii,onSubmit:R,onBack:$,onNavigate:Z,onLogout:de,children:[e.custom_is_deleted===1&&n.jsx(zl,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:S?()=>S(e.name):void 0}),e.sb_idea&&n.jsxs("div",{style:{background:"#f0f7ff",border:"1px solid #bfdbfe",borderRadius:8,padding:"8px 14px",marginBottom:16,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontSize:12},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[n.jsx("span",{style:{fontSize:14,flexShrink:0},children:"💡"}),n.jsxs("span",{style:{fontSize:11,fontWeight:700,color:"#1e40af",textTransform:"uppercase",letterSpacing:"0.4px",whiteSpace:"nowrap"},children:[E.field.originatingIdea,":"]}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#1e3a8a",whiteSpace:"nowrap"},children:e.sb_idea})]}),g&&n.jsxs("button",{type:"button",onClick:()=>g(e.sb_idea),style:{background:"#2563eb",color:"#fff",border:"none",borderRadius:6,padding:"4px 10px",fontWeight:600,fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,flexShrink:0,transition:"background 0.15s ease"},onMouseEnter:N=>N.currentTarget.style.background="#1d4ed8",onMouseLeave:N=>N.currentTarget.style.background="#2563eb",children:[E.field.viewIdea," →"]})]}),n.jsx(ae,{title:"Order Information",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.number}),n.jsx("input",{style:{...I,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[E.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ut,{value:e.organization,onChange:N=>B({organization:N}),organizations:s,disabled:u||!!D.custom_organization})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.title}),n.jsx("input",{style:{...I,...M},value:e.title,disabled:u,onChange:N=>B({title:N.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.management}),n.jsx(pe,{value:e.management,onChange:N=>B({management:N}),items:Q,placeholder:E.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.department}),n.jsx(pe,{value:e.department,onChange:N=>B({department:N}),items:ne,placeholder:E.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.section}),n.jsx("input",{style:{...I,...M},value:e.section_field||"",disabled:u,onChange:N=>B({section_field:N.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.branch}),n.jsx(pe,{value:e.branch,onChange:N=>B({branch:N}),items:gt,placeholder:E.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.type}),n.jsx(pe,{value:e.type,onChange:N=>B({type:N}),items:re,placeholder:E.field.selectType,disabled:u})]})]})}),n.jsxs(ae,{title:"Financial & Schedule",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.budget}),n.jsx("input",{type:"number",style:{...I,...M},value:e.budget||"",disabled:u,onChange:N=>B({budget:parseFloat(N.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.actualCost}),n.jsx("input",{type:"number",style:{...I,...M},value:e.actual_cost||"",disabled:u,onChange:N=>B({actual_cost:parseFloat(N.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Variance"}),(()=>{const N=(e.budget||0)-(e.actual_cost||0);return n.jsxs("div",{style:{padding:"7px 12px",borderRadius:6,fontWeight:700,fontSize:13,background:N>=0?"#f0fdf4":"#fef2f2",color:N>=0?"#166534":"#dc2626",border:`1px solid ${N>=0?"#bbf7d0":"#fecaca"}`,display:"inline-block",width:"100%",boxSizing:"border-box"},children:[N>=0?"+":"",N.toFixed(2)]})})()]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.currency}),n.jsxs("select",{style:{...I,...M},value:e.currency||"",disabled:u,onChange:N=>B({currency:N.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"SAR",children:"SAR"}),n.jsx("option",{value:"USD",children:"USD"}),n.jsx("option",{value:"EUR",children:"EUR"}),n.jsx("option",{value:"AED",children:"AED"}),n.jsx("option",{value:"GBP",children:"GBP"})]})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.startingDate}),n.jsx(xe,{value:e.starting_date,onChange:N=>B({starting_date:N}),disabled:u,style:{...I,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.endingDate}),n.jsx(xe,{value:e.ending_date,onChange:N=>B({ending_date:N}),disabled:u,style:{...I,...M}})]}),W&&n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.actor}),u?n.jsx("input",{style:{...I,background:"#f8fafc",fontWeight:600,color:"#334155"},value:Vn||"—",readOnly:!0,disabled:!0}):n.jsxs("select",{style:{...I,background:"#ffffff"},value:e.actor||e.assigned_to||"",onChange:N=>B({actor:N.target.value,assigned_to:N.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),A.map(N=>n.jsx("option",{value:N.name,children:N.full_name||N.name},N.name))]})]})]})]}),n.jsxs(ae,{title:"Classification",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.priority}),n.jsxs("select",{style:{...I,...M},value:e.priority||"",disabled:u,onChange:N=>B({priority:N.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"High",children:E.field.high}),n.jsx("option",{value:"Normal",children:E.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.economyClass}),n.jsxs("select",{style:{...I,...M},value:e.economy_class||"",disabled:u,onChange:N=>B({economy_class:N.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Expenses",children:E.field.expenses}),n.jsx("option",{value:"Capital",children:E.field.capital}),n.jsx("option",{value:"Earn",children:E.field.earn}),n.jsx("option",{value:"Pay/Loss",children:E.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.entityScope}),n.jsxs("select",{style:{...I,...M},value:e.entity_scope||"",disabled:u,onChange:N=>B({entity_scope:N.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Upstream",children:E.field.upstream}),n.jsx("option",{value:"On-stream",children:E.field.onstream}),n.jsx("option",{value:"Downstream",children:E.field.downstream})]})]})]}),n.jsxs("div",{style:{display:"flex",gap:24,marginTop:12,alignItems:"center",flexWrap:"wrap"},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.planned,disabled:u,onChange:N=>B({planned:N.target.checked?1:0})})," Planned"]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:u,onChange:N=>B({product_relation:N.target.checked?1:0})})," ",E.field.productRelation]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:z,children:E.field.hsesField}),n.jsx("input",{style:{...I,...M},value:e.hses_field||"",disabled:u,onChange:N=>B({hses_field:N.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs(ae,{title:"Cycle & Progress Tracking",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.cycle}),n.jsx(pe,{value:e.cycle||"",onChange:N=>B({cycle:N}),items:lt,placeholder:E.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.cycleType}),n.jsxs("select",{style:{...I,...M},value:e.cycle_type||"Normal",disabled:u,onChange:N=>B({cycle_type:N.target.value}),children:[n.jsx("option",{value:"Normal",children:"Normal"}),n.jsx("option",{value:"Long",children:"Long"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.stage}),n.jsx("input",{type:"number",min:1,max:5,style:{...I,background:"#f8fafc",color:"#334155",fontWeight:600},value:e.stage||1,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Completion"}),n.jsx("input",{style:{...I,background:"#f8fafc",color:"#334155",fontWeight:600},value:`${e.completion_pct||(e.stage||1)*20}%`,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Stage Description"}),n.jsx("span",{style:{display:"inline-block",padding:"7px 12px",borderRadius:6,fontSize:13,fontWeight:600,background:"#f0f9ff",color:"#0369a1",border:"1px solid #bae6fd",width:"100%",boxSizing:"border-box"},children:k0[e.stage||1]||"—"})]})]}),e.cycle_type==="Long"&&n.jsxs("div",{style:{background:"#fff7ed",border:"1px solid #fed7aa",borderRadius:8,padding:14,marginBottom:14},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#c2410c",marginBottom:10},children:"Long Cycle Milestone Dates"}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:12},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Milestone 1"}),n.jsx(xe,{value:e.long_cycle_date_1||"",onChange:N=>B({long_cycle_date_1:N}),disabled:u,style:{...I,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Milestone 2"}),n.jsx(xe,{value:e.long_cycle_date_2||"",onChange:N=>B({long_cycle_date_2:N}),disabled:u,style:{...I,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Milestone 3"}),n.jsx(xe,{value:e.long_cycle_date_3||"",onChange:N=>B({long_cycle_date_3:N}),disabled:u,style:{...I,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Milestone 4"}),n.jsx(xe,{value:e.long_cycle_date_4||"",onChange:N=>B({long_cycle_date_4:N}),disabled:u,style:{...I,...M}})]})]})]}),jt&&((Il=e.order_cycle_log)==null?void 0:Il.length)>0&&n.jsxs("div",{style:{borderTop:"1px solid #f1f5f9",paddingTop:14,marginTop:10},children:[n.jsx("p",{style:{fontWeight:700,color:"#334155",fontSize:13,marginBottom:10},children:"Cycle History"}),n.jsx("div",{style:{overflowX:"auto"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8fafc"},children:["Cycle","Date","Stage","Status","Actor","Comment"].map(N=>n.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#475569",borderBottom:"1px solid #e2e8f0"},children:N},N))})}),n.jsx("tbody",{children:(e.order_cycle_log||[]).map((N,Ct)=>{const cn=N.status==="Agree"?"#166534":N.status==="Deviate"?"#c2410c":"#92400e",zn=N.status==="Agree"?"#f0fdf4":N.status==="Deviate"?"#fff7ed":"#fefce8";return n.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:N.cycle||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:N.cycle_date||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155",textAlign:"center"},children:N.stage||"—"}),n.jsx("td",{style:{padding:"6px 10px"},children:n.jsx("span",{style:{background:zn,color:cn,padding:"2px 8px",borderRadius:12,fontWeight:600,fontSize:12},children:N.status||"—"})}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:N.actor||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#64748b",fontStyle:N.comment?"normal":"italic"},children:N.comment||"—"})]},Ct)})})]})})]})]}),n.jsxs(ae,{title:"Description & Notes",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.description}),n.jsx("textarea",{style:{...I,...M,height:90,resize:"vertical"},value:e.description,disabled:u,onChange:N=>B({description:N.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.notes}),n.jsx("textarea",{style:{...I,...M,height:90,resize:"vertical"},value:e.notes,disabled:u,onChange:N=>B({notes:N.target.value})})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.auditorComment}),n.jsx("textarea",{style:{...I,height:70,resize:"vertical",...u&&O&&!W?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:u&&O&&!W,onChange:N=>B({auditor_comment:N.target.value}),placeholder:E.field.commentPlaceholder})]})]})]})}function I0({processes:e,organizations:t,departments:s,branches:r,processStatuses:l,initialOrg:a,initialStatus:i,canModify:c,onView:d,onEdit:f,onDelete:v}){const p=se(),[u,m]=w.useState({search:"",organization:a||"",department:"",branch:"",status:i||""}),j=(o,y)=>m(_=>({..._,[o]:y})),[h,S]=w.useState(1),g=e.filter(o=>!(u.search&&!`${o.number} ${o.title}`.toLowerCase().includes(u.search.toLowerCase())||u.organization&&o.organization!==u.organization||u.department&&o.department!==u.department||u.branch&&o.branch!==u.branch||u.status&&o.status!==u.status));w.useEffect(()=>{S(1)},[u]);const x=g.slice((h-1)*ie,h*ie);return n.jsxs(n.Fragment,{children:[n.jsx(ri,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"10px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.numberTitle}),n.jsx("input",{style:qe,value:u.search,onChange:o=>j("search",o.target.value),placeholder:p.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.organization}),n.jsxs("select",{style:qe,value:u.organization,onChange:o=>j("organization",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.department}),n.jsxs("select",{style:qe,value:u.department,onChange:o=>j("department",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allDepts}),s.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.branch}),n.jsxs("select",{style:qe,value:u.branch,onChange:o=>j("branch",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allBranches}),r.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Xe,children:p.filter.status}),n.jsxs("select",{style:qe,value:u.status,onChange:o=>j("status",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allStatuses}),l.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>m({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"7px 14px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#475569",fontWeight:500},children:p.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.number}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.title}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.organization}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.field.cycleType}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.status}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.actions})]})}),n.jsx("tbody",{children:g.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:p.noProcesses})}):x.map((o,y)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>d==null?void 0:d(o),style:{borderTop:"1px solid #f1f5f9",background:o.custom_is_deleted?"#fff1f2":y%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[n.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:o.number||"—"}),n.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:o.title||o.name||"—"}),n.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"12px 16px"},children:o.cycle_type?Rd(o.cycle_type):"—"}),n.jsx("td",{style:{padding:"12px 16px"},children:o.custom_is_deleted?Xn(p.deletedBadge):o.status?Xn(o.status):"—"}),n.jsx("td",{style:{padding:"10px 16px"},onClick:_=>_.stopPropagation(),children:n.jsx(nt,{onView:()=>d==null?void 0:d(o),onEdit:c&&f&&!o.custom_is_deleted&&!Nn("process",o.workflow_state)?()=>f(o):void 0,onDelete:c&&v&&!o.custom_is_deleted?()=>v(o.name):void 0})})]},o.name))})]})}),n.jsx(Ge,{page:h,total:g.length,onPageChange:S})]})}const E0={Draft:[{action:"Submit for Review",next:"Pending Actor",allowedRoles:["Auditor","Manager"]}],"Pending Actor":[{action:"Update Status",next:"Pending Comment",allowedRoles:["Employee","Manager"]}],"Pending Comment":[{action:"Add Comment",next:"Review",allowedRoles:["Auditor","Manager"]}],Review:[{action:"Start New Cycle",next:"Pending Actor",allowedRoles:["Auditor","Manager"]},{action:"Move to Study",next:"In Study",allowedRoles:["Auditor","Manager"]}],"In Study":[{action:"Start New Cycle",next:"Pending Actor",allowedRoles:["Auditor","Manager"]},{action:"Close Process",next:"Closed",allowedRoles:["Auditor","Manager"]}]},P0={Draft:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Pending Actor":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},"Pending Comment":{background:"#f5f3ff",color:"#6d28d9",border:"1px solid #ddd6fe"},Review:{background:"#f0fdf4",color:"#15803d",border:"1px solid #bbf7d0"},"In Study":{background:"#f1f5f9",color:"#475569",border:"1px solid #cbd5e1"},Closed:{background:"#f3f4f6",color:"#6b7280",border:"1px solid #9ca3af"}};function Tu(e){return{display:"inline-block",padding:"5px 14px",borderRadius:20,fontSize:13,fontWeight:700,...P0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}const Zl={width:"100%",padding:"6px 8px",border:"1px solid #d1d5db",borderRadius:5,fontSize:12,fontFamily:"Segoe UI",boxSizing:"border-box"};function A0({processName:e,userRole:t,onRefresh:s,canUpdateStatus:r=!0}){const[l,a]=w.useState(null),[i,c]=w.useState(!0),[d,f]=w.useState(""),[v,p]=w.useState(!1),[u,m]=w.useState(""),[j,h]=w.useState(""),[S,g]=w.useState("Pass"),[x,o]=w.useState(""),[y,_]=w.useState({}),C=w.useCallback(async()=>{if(!e){c(!1);return}c(!0),f("");try{const D=await Yr(e);a(D);const T={};for(const E of D.progress_indicators||[])T[E.name]=E.actual_value!=null?String(E.actual_value):"";_(T)}catch(D){f(D instanceof Error?D.message:"Failed to load process")}c(!1)},[e]);if(w.useEffect(()=>{C()},[C]),i)return n.jsx("div",{style:{width:"100%",flexShrink:0},children:n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",padding:24,color:"#aaa",fontSize:13,textAlign:"center"},children:"Loading…"})});if(d||!l)return n.jsx("div",{style:{width:"100%",flexShrink:0},children:n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",padding:16},children:n.jsx("div",{style:{fontSize:12,color:"#991b1b",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,padding:"8px 12px"},children:d||"Could not load workflow"})})});const P=l.workflow_state||"Draft",k=E0[P]??[],R=t==="Employee"||t==="Manager",$=t!=="Manager"||r,Z=k.filter(D=>(t==="Admin"||D.allowedRoles.includes(t))&&(D.action!=="Update Status"||$)),de=async D=>{p(!0),m(""),h("");try{const T={};if(D==="Update Status"){T.actor_status=S,T.actor_comment=x;const B=l.progress_indicators||[];B.length>0&&(T.progress_indicators=B.map(M=>({name:M.name,actual_value:y[M.name]??""})))}D==="Add Comment"&&x&&(T.actor_comment=x);const E=await Zy(l.name,D,T);a(E),o(""),h(`Done — now: ${E.workflow_state||"updated"}`),s==null||s()}catch(T){m(T instanceof Error?T.message:"Action failed")}p(!1)};return n.jsx("div",{style:{width:"100%",flexShrink:0},children:n.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[n.jsx("div",{style:{background:"#1a2332",color:"white",padding:"10px 14px",fontSize:12,fontWeight:700,letterSpacing:.3},children:"Workflow"}),n.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:8},children:"Current State"}),n.jsx("div",{style:Tu(P),children:P})]}),P==="Pending Actor"&&R&&$&&n.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Update Status"}),Array.isArray(l.progress_indicators)&&l.progress_indicators.length>0&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Actual Value"}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:l.progress_indicators.map(D=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx("span",{style:{fontSize:11,color:"#555",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:D.name1,children:D.name1||D.name}),n.jsx("input",{type:"number",value:y[D.name]??"",onChange:T=>_(E=>({...E,[D.name]:T.target.value})),style:{...Zl,width:70,flexShrink:0},placeholder:"0"})]},D.name))})]}),n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Cycle Status"}),n.jsxs("select",{value:S,onChange:D=>g(D.target.value),style:Zl,children:[n.jsx("option",{value:"Pass",children:"✅ Pass — on target"}),n.jsx("option",{value:"Fail",children:"❌ Fail — off target"})]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Comment (optional)"}),n.jsx("textarea",{value:x,onChange:D=>o(D.target.value),style:{...Zl,height:52,resize:"vertical"},placeholder:"Add a comment…"})]})]}),(P==="Pending Comment"||P==="Review")&&!R&&n.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Auditor Comment"}),Array.isArray(l.cycle_logs)&&l.cycle_logs.length>0&&n.jsxs("div",{style:{marginBottom:8,padding:"6px 10px",background:"#f8fafc",borderRadius:6,border:"1px solid #e2e8f0"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",marginBottom:3},children:"Latest cycle status:"}),(()=>{const D=l.cycle_logs,T=D[D.length-1],E=T.status==="Pass"?"#16a34a":T.status==="Fail"?"#dc2626":"#9ca3af";return n.jsxs("div",{style:{fontSize:13,fontWeight:700,color:E},children:[T.status," ",T.comment?`— ${T.comment}`:""]})})()]}),n.jsx("textarea",{value:x,onChange:D=>o(D.target.value),style:{...Zl,height:52,resize:"vertical"},placeholder:"Add a comment…"})]}),n.jsxs("div",{style:{padding:"12px 14px",borderBottom:Z.length>0?"1px solid #f0f0f0":"none"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Actions"}),Z.length===0&&n.jsxs("div",{style:{fontSize:12,color:"#aaa",fontStyle:"italic",lineHeight:1.5},children:["No actions for ",n.jsx("strong",{children:t})," in ",n.jsx("strong",{children:P}),"."]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Z.map(D=>n.jsxs("button",{onClick:()=>de(D.action),disabled:v,style:{width:"100%",padding:"10px 14px",borderRadius:6,border:"none",background:D.action==="Close Process"?"#64748b":D.action==="Move to Study"?"#8e44ad":"#2563eb",color:"white",cursor:v?"not-allowed":"pointer",fontSize:13,fontWeight:600,opacity:v?.7:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsx("span",{children:v?"Applying…":D.action}),n.jsxs("span",{style:{fontSize:10,opacity:.7},children:["→ ",D.next]})]},D.action))}),u&&n.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,fontSize:12,color:"#991b1b",lineHeight:1.4},children:u}),j&&n.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,fontSize:12,color:"#166534"},children:j})]}),k.length>0&&n.jsxs("div",{style:{padding:"12px 14px"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Next States"}),k.map(D=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6,fontSize:11},children:[n.jsx("span",{style:{color:"#555",flex:1},children:D.action}),n.jsx("span",{style:{color:"#bbb"},children:"→"}),n.jsx("span",{style:Tu(D.next),children:D.next})]},D.action))]})]})})}function R0({processForm:e,setProcessForm:t,organizations:s,managements:r,departments:l,branches:a,processTypes:i,processStatuses:c,cycles:d=[],users:f=[],userRoleMap:v={},formStatus:p,viewMode:u,canModify:m,onEdit:j,onDelete:h,onRestore:S,darkMode:g,notifCount:x,onToggleDark:o,onCountChange:y,onViewProfile:_,userRole:C,delegatedFunctions:P=[],delegatedOrgs:k=null,onRefreshProcess:R,onSubmit:$,onBack:Z,onNavigate:de,onLogout:D,user:T}){var je;const E=se(),B=O=>t({...e,...O}),M=u?{background:"#f9f9f9"}:{},A=!u&&C==="Manager"&&Array.isArray(k),K=A?s.filter(O=>(k||[]).includes(O.organization_name||O.name)):s,Y=A&&(k||[]).length===1||!!T.custom_organization,ee=me(r,e.management).map(O=>({name:O.name,label:O.name1||O.name})),V=me(l,e.department).map(O=>({name:O.name,label:O.department_name||O.name})),ze=me(a,e.branch).map(O=>({name:O.name,label:O.branch||O.name})),$e=me(i,e.type).map(O=>({name:O.name,label:O.name1||O.name})),Oe=me(d,e.cycle).map(O=>({name:O.name,label:O.name1||O.name})),ge=Sr(f,v,"SB Employee",e.organization).map(O=>({name:O.name,label:O.full_name||O.name})),Je=Sr(f,v,"SB Manager",e.organization).map(O=>({name:O.name,label:O.full_name||O.name})),Q=(O,le)=>{const X=[...e.cycle_logs||[]];X[O]={...X[O],...le},B({cycle_logs:X})},ne=()=>{B({cycle_logs:[...e.cycle_logs||[],{cycle:"",cycle_date:"",status:"Pass",actor:"",comment:""}]})},gt=O=>{const le=[...e.cycle_logs||[]];le.splice(O,1),B({cycle_logs:le})},re=(O,le)=>{const X=[...e.progress_indicators||[]];X[O]={...X[O],...le},B({progress_indicators:X})},lt=()=>{B({progress_indicators:[...e.progress_indicators||[],{name1:"",type:"Nominal",unit:"",cycle:"",target:"",maximum:"",minimum:"",manager:"",order:"",actual_value:"",cycle_status:"",cycle_date:"",cycle_comment:"",status:""}]})},jt=O=>{const le=[...e.progress_indicators||[]];le.splice(O,1),B({progress_indicators:le})},Qe=e.name?u?`${E.formTitle.viewProcess}${e.title||e.name}`:E.formTitle.editProcess:E.formTitle.newProcess,U=C!=="Manager"||e.actor===T.name||P.includes("update_process_status"),Te=((je=ge.find(O=>O.name===e.actor))==null?void 0:je.label)||e.actor,Ze=e.workflow_state||"Draft",W=e.name?n.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[n.jsx(A0,{processName:e.name,userRole:C||T.role||"Employee",onRefresh:R,canUpdateStatus:U}),n.jsx(si,{priority:e.impact_level,status:Ze,assignedTo:Te,createdDate:e.date_start,modifiedDate:e.modified}),n.jsx(li,{doctype:L.processes,docname:e.name,currentUserName:T.name}),n.jsx(ai,{doctype:L.processes,docname:e.name,docCreation:e.creation,docOwner:e.owner}),m&&h&&!e.custom_is_deleted&&n.jsx(ni,{title:"Delete Request",btnText:E.delete,onDelete:()=>h(e.name)})]}):void 0;return n.jsxs(Ke,{title:Qe,activePage:"processes",user:T,formStatus:p,statusBadge:n.jsx("span",{style:{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},children:Ze}),buttonText:E.saveProcess,buttonColor:"#16a34a",viewMode:u,onEdit:j,darkMode:g,notifCount:x,onToggleDark:o,onCountChange:y,onViewProfile:_,rightPanel:W,onSubmit:$,onBack:Z,onNavigate:de,onLogout:D,children:[e.custom_is_deleted===1&&n.jsx(zl,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:S?()=>S(e.name):void 0}),n.jsx(ae,{title:"Process Information",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.number}),n.jsx("input",{style:{...I,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number||"",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[E.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ut,{value:e.organization,onChange:O=>B({organization:O}),organizations:K,disabled:u||Y}),A&&n.jsx("div",{style:{fontSize:11,color:"#888",marginTop:4},children:(k||[]).length===0?"You have no delegated organization for Processes.":`Restricted to your delegated organization${(k||[]).length>1?"s":""}: ${(k||[]).join(", ")}`})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.title}),n.jsx("input",{style:{...I,...M},value:e.title,disabled:u,onChange:O=>B({title:O.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.type}),n.jsx(pe,{value:e.type,onChange:O=>B({type:O}),items:$e,placeholder:E.field.selectType,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.management}),n.jsx(pe,{value:e.management,onChange:O=>B({management:O}),items:ee,placeholder:E.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.department}),n.jsx(pe,{value:e.department,onChange:O=>B({department:O}),items:V,placeholder:E.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.section}),n.jsx("input",{style:{...I,...M},value:e.section_field||"",disabled:u,onChange:O=>B({section_field:O.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.branch}),n.jsx(pe,{value:e.branch,onChange:O=>B({branch:O}),items:ze,placeholder:E.field.select,disabled:u})]})]})}),n.jsxs(ae,{title:"Classification",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.chainLocation}),n.jsxs("select",{style:{...I,...M},value:e.chain_location||"",disabled:u,onChange:O=>B({chain_location:O.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Upstream",children:"Upstream"}),n.jsx("option",{value:"On-stream",children:"On-stream"}),n.jsx("option",{value:"Downstream",children:"Downstream"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.economyClass}),n.jsxs("select",{style:{...I,...M},value:e.economy_class||"",disabled:u,onChange:O=>B({economy_class:O.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Expenses",children:E.field.expenses}),n.jsx("option",{value:"Capital",children:E.field.capital}),n.jsx("option",{value:"Earn",children:E.field.earn}),n.jsx("option",{value:"Pay/Loss",children:E.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.impactLevel}),n.jsxs("select",{style:{...I,...M},value:e.impact_level||"",disabled:u,onChange:O=>B({impact_level:O.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"High",children:E.field.high}),n.jsx("option",{value:"Normal",children:E.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.entityScope}),n.jsxs("select",{style:{...I,...M},value:e.entity_scope||"",disabled:u,onChange:O=>B({entity_scope:O.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Upstream",children:E.field.upstream}),n.jsx("option",{value:"On-stream",children:E.field.onstream}),n.jsx("option",{value:"Downstream",children:E.field.downstream})]})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"center"},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.hsesField}),n.jsx("input",{style:{...I,...M},value:e.hses_field||"",disabled:u,onChange:O=>B({hses_field:O.target.value}),placeholder:"Safety, Health, Environment…"})]}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,paddingTop:18},children:n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:u,onChange:O=>B({product_relation:O.target.checked?1:0})})," ",E.field.productRelation]})})]})]}),n.jsxs(ae,{title:"KPI & Timeline",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.kpiName}),n.jsx("input",{style:{...I,...M},value:e.kpi_name||"",disabled:u,onChange:O=>B({kpi_name:O.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.kpiType}),n.jsxs("select",{style:{...I,...M},value:e.kpi_type||"",disabled:u,onChange:O=>B({kpi_type:O.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Human",children:"Human"}),n.jsx("option",{value:"Substantial",children:"Substantial"}),n.jsx("option",{value:"System",children:"System"}),n.jsx("option",{value:"Value",children:"Value"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.kpiMeasure}),n.jsx("input",{style:{...I,...M},value:e.kpi_measure||"",disabled:u,onChange:O=>B({kpi_measure:O.target.value}),placeholder:"Unit of measure"})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.dateStart}),n.jsx(xe,{value:e.date_start,onChange:O=>B({date_start:O}),disabled:u,style:{...I,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.dateEnd}),n.jsx(xe,{value:e.date_end,onChange:O=>B({date_end:O}),disabled:u,style:{...I,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.cycleType}),n.jsxs("select",{style:{...I,...M},value:e.cycle_type||"",disabled:u,onChange:O=>B({cycle_type:O.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Normal",children:"Normal"}),n.jsx("option",{value:"Long",children:"Long"})]})]})]}),e.cycle_type==="Long"&&n.jsxs("div",{style:{background:"#fff7ed",border:"1px solid #fed7aa",borderRadius:8,padding:14,marginTop:14},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#c2410c",marginBottom:10},children:"Long Cycle Milestone Dates"}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:12},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Milestone 1"}),n.jsx(xe,{value:e.long_cycle_date_1||"",onChange:O=>B({long_cycle_date_1:O}),disabled:u,style:{...I,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Milestone 2"}),n.jsx(xe,{value:e.long_cycle_date_2||"",onChange:O=>B({long_cycle_date_2:O}),disabled:u,style:{...I,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Milestone 3"}),n.jsx(xe,{value:e.long_cycle_date_3||"",onChange:O=>B({long_cycle_date_3:O}),disabled:u,style:{...I,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Milestone 4"}),n.jsx(xe,{value:e.long_cycle_date_4||"",onChange:O=>B({long_cycle_date_4:O}),disabled:u,style:{...I,...M}})]})]})]})]}),n.jsxs(ae,{title:"Progress Indicators",children:[n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:12},children:!u&&n.jsx("button",{type:"button",onClick:lt,style:{padding:"7px 14px",border:"none",background:"#2563eb",color:"white",borderRadius:6,fontWeight:600,fontSize:12,cursor:"pointer"},children:"+ Add Row"})}),n.jsx("div",{style:{overflowX:"auto",minWidth:0},children:n.jsxs("table",{style:{borderCollapse:"collapse",fontSize:12,width:"max-content",minWidth:"100%"},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8fafc"},children:[n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Order"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Name"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Type"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Unit"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Target"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Min"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Max"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Manager"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actual Value"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle Status"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle Date"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle Comment"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Status"}),!u&&n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actions"})]})}),n.jsxs("tbody",{children:[(e.progress_indicators||[]).length===0&&n.jsx("tr",{children:n.jsx("td",{colSpan:u?14:15,style:{padding:18,textAlign:"center",color:"#94a3b8"},children:"No progress indicators"})}),(e.progress_indicators||[]).map((O,le)=>n.jsxs("tr",{style:{background:le%2===0?"white":"#fafafa",borderBottom:"1px solid #f1f5f9"},children:[n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("input",{style:{...I,...M,width:60},value:O.order??"",disabled:u,onChange:X=>re(le,{order:X.target.value})})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("input",{style:{...I,...M},value:O.name1,disabled:u,onChange:X=>re(le,{name1:X.target.value})})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsxs("select",{style:{...I,...M},value:O.type,disabled:u,onChange:X=>re(le,{type:X.target.value}),children:[n.jsx("option",{children:"Nominal"}),n.jsx("option",{children:"Ordinal"}),n.jsx("option",{children:"Interval"}),n.jsx("option",{children:"Ratio"})]})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("input",{style:{...I,...M,width:70},type:"text",value:O.unit??"",disabled:u,onChange:X=>re(le,{unit:X.target.value}),placeholder:"e.g. °C, kg, %"})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsxs("select",{style:{...I,...M,minWidth:120},value:O.cycle,disabled:u,onChange:X=>re(le,{cycle:X.target.value}),children:[n.jsx("option",{value:"",children:"--"}),Oe.map(X=>n.jsx("option",{value:X.name,children:X.label},X.name)),O.cycle&&!Oe.some(X=>X.name===O.cycle)&&n.jsx("option",{value:O.cycle,children:O.cycle})]})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("input",{style:{...I,...M,width:80},value:O.target,disabled:u,onChange:X=>re(le,{target:X.target.value})})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("input",{style:{...I,...M,width:80},value:O.minimum,disabled:u,onChange:X=>re(le,{minimum:X.target.value})})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("input",{style:{...I,...M,width:80},value:O.maximum,disabled:u,onChange:X=>re(le,{maximum:X.target.value})})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsxs("select",{style:{...I,...M,minWidth:140},value:O.manager,disabled:u,onChange:X=>re(le,{manager:X.target.value}),children:[n.jsx("option",{value:"",children:"--"}),Je.map(X=>n.jsx("option",{value:X.name,children:X.label},X.name)),O.manager&&!Je.some(X=>X.name===O.manager)&&n.jsx("option",{value:O.manager,children:O.manager})]})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("input",{style:{...I,...M,width:90},type:"number",value:O.actual_value??"",disabled:u,onChange:X=>re(le,{actual_value:parseFloat(X.target.value)||""})})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsxs("select",{style:{...I,...M},value:O.cycle_status??"",disabled:u,onChange:X=>re(le,{cycle_status:X.target.value}),children:[n.jsx("option",{value:"",children:"--"}),n.jsx("option",{children:"Normal"}),n.jsx("option",{children:"Below Min"}),n.jsx("option",{children:"Above Max"}),n.jsx("option",{children:"At Risk"})]})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx(xe,{value:O.cycle_date||"",onChange:X=>re(le,{cycle_date:X}),disabled:u,style:{...I,...M,width:110}})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("input",{style:{...I,...M},value:O.cycle_comment??"",disabled:u,onChange:X=>re(le,{cycle_comment:X.target.value})})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsxs("select",{style:{...I,...M},value:O.status??"",disabled:u,onChange:X=>re(le,{status:X.target.value}),children:[n.jsx("option",{value:"",children:"--"}),n.jsx("option",{children:"Normal"}),n.jsx("option",{children:"Below Min"}),n.jsx("option",{children:"Above Max"}),n.jsx("option",{children:"At Risk"})]})}),!u&&n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("button",{type:"button",onClick:()=>jt(le),style:{padding:"4px 8px",border:"1px solid #fecaca",background:"#fef2f2",color:"#dc2626",borderRadius:4,cursor:"pointer",fontSize:11,fontWeight:600},children:"Remove"})})]},le))]})]})})]}),n.jsx(ae,{title:"Cycle & Assignment",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.cycle}),n.jsx(pe,{value:e.cycle||"",onChange:O=>B({cycle:O}),items:Oe,placeholder:E.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.actor}),n.jsxs("select",{style:{...I,...M},value:e.actor||"",disabled:u,onChange:O=>B({actor:O.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),ge.map(O=>n.jsx("option",{value:O.name,children:O.label},O.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.costPerCycle}),n.jsx("input",{style:{...I,...M},type:"number",value:e.cost_per_cycle||"",disabled:u,onChange:O=>B({cost_per_cycle:parseFloat(O.target.value)||0}),placeholder:"0.00"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.escalationLevel}),n.jsx("input",{style:{...I,...M},type:"number",value:e.escalation_level||"",disabled:u,onChange:O=>B({escalation_level:parseInt(O.target.value)||0})})]})]})}),n.jsxs(ae,{title:"Cycle History",children:[n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:12},children:!u&&n.jsx("button",{type:"button",onClick:ne,style:{padding:"7px 14px",border:"none",background:"#2563eb",color:"white",borderRadius:6,fontWeight:600,fontSize:12,cursor:"pointer"},children:"+ Add Row"})}),n.jsx("div",{style:{overflowX:"auto",minWidth:0},children:n.jsxs("table",{style:{borderCollapse:"collapse",fontSize:12,width:"max-content",minWidth:"100%"},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8fafc"},children:[n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Date"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Status"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actor"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Comment"}),!u&&n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actions"})]})}),n.jsxs("tbody",{children:[(e.cycle_logs||[]).length===0&&n.jsx("tr",{children:n.jsx("td",{colSpan:u?5:6,style:{padding:18,textAlign:"center",color:"#94a3b8"},children:"No cycle history"})}),(e.cycle_logs||[]).map((O,le)=>n.jsxs("tr",{style:{background:le%2===0?"white":"#fafafa",borderBottom:"1px solid #f1f5f9"},children:[n.jsx("td",{style:{padding:"8px 10px"},children:n.jsxs("select",{style:{...I,...M},value:O.cycle||"",disabled:u,onChange:X=>Q(le,{cycle:X.target.value}),children:[n.jsx("option",{value:"",children:"-- Select --"}),Oe.map(X=>n.jsx("option",{value:X.name,children:X.label},X.name))]})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx(xe,{value:O.cycle_date||"",onChange:X=>Q(le,{cycle_date:X}),disabled:u,style:{...I,...M,width:130}})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsxs("select",{style:{...I,...M},value:O.status,disabled:u,onChange:X=>Q(le,{status:X.target.value}),children:[n.jsx("option",{value:"Pass",children:"Pass"}),n.jsx("option",{value:"Fail",children:"Fail"}),n.jsx("option",{value:"Unknown",children:"Unknown"})]})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsxs("select",{style:{...I,...M},value:O.actor||"",disabled:u,onChange:X=>Q(le,{actor:X.target.value}),children:[n.jsx("option",{value:"",children:"-- Select --"}),ge.map(X=>n.jsx("option",{value:X.name,children:X.label},X.name))]})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("input",{style:{...I,...M},value:O.comment||"",disabled:u,onChange:X=>Q(le,{comment:X.target.value})})}),!u&&n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("button",{type:"button",onClick:()=>gt(le),style:{padding:"4px 8px",border:"1px solid #fecaca",background:"#fef2f2",color:"#dc2626",borderRadius:4,cursor:"pointer",fontSize:11,fontWeight:600},children:"Remove"})})]},le))]})]})})]}),n.jsx(ae,{title:E.field.auditorComment,children:n.jsx("textarea",{style:{...I,height:70,resize:"vertical",background:"#f8fafc"},value:e.auditor_comment||"",disabled:!0,readOnly:!0,placeholder:E.field.commentPlaceholder})})]})}const D0={Admin:"#7c3aed",Auditor:"#d97706",Owner:"#0369a1",XAuditor:"#0f766e",Manager:"#2563eb",Employee:"#6b7280",Chairman:"#0f766e"};function L0({user:e,profileUser:t,darkMode:s,canModify:r,onBack:l,organizations:a=[],managements:i=[],departments:c=[],branches:d=[]}){const f=t||{},v=!!r&&e.role==="Admin",[p,u]=w.useState({first_name:f.first_name||"",middle_name:f.middle_name||"",last_name:f.last_name||"",mobile_no:f.mobile_no||"",custom_organization:f.custom_organization||"",custom_management:f.custom_management||"",custom_department:f.custom_department||"",custom_branch:f.custom_branch||"",custom_number:f.custom_number||"",custom_category:f.custom_category||""}),[m,j]=w.useState(""),[h,S]=w.useState(!1),[g,x]=w.useState({new:"",confirm:""}),[o,y]=w.useState(""),_=f.email||f.name||"",C=[p.first_name,p.middle_name,p.last_name].filter(Boolean).join(" ")||f.full_name||"",P=f.username||f.name||"",k=p.custom_category||"",R=f.enabled===0?"Inactive":"Active",$=D0[e.role]||"#6b7280",Z=s,de=Z?"#0f172a":"#f0f2f5",D=Z?"#1e293b":"white",T=Z?"#2d3748":"#e5e7eb",E=Z?"#e2e8f0":"#1a2332",B=Z?"#94a3b8":"#6b7280",M=Z?"#374151":"white",A=Z?"#2d3748":"#f9fafb",K={width:"100%",padding:"9px 12px",borderRadius:8,border:`1px solid ${T}`,fontSize:13,background:M,color:E,fontFamily:"inherit",outline:"none"},Y={...K,background:A,color:B},ee={...K,cursor:"pointer"},V={fontSize:12,fontWeight:600,color:B,marginBottom:5,display:"block"},ze={display:"grid",gridTemplateColumns:"1fr 1fr",gap:14},$e={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:14},Oe=async()=>{if(r){j("saving");try{await Ba("User",f.name,{first_name:p.first_name,middle_name:p.middle_name,last_name:p.last_name,mobile_no:p.mobile_no,custom_organization:p.custom_organization,custom_management:p.custom_management,custom_department:p.custom_department,custom_branch:p.custom_branch,custom_number:p.custom_number,custom_category:p.custom_category}),j("saved"),setTimeout(()=>j(""),2e3)}catch{j("error"),setTimeout(()=>j(""),3e3)}}},ge=async()=>{if(!g.new){y("Enter a new password");return}if(g.new!==g.confirm){y("Passwords do not match");return}y("saving");try{await sh(f.name,g.new),y("done"),x({new:"",confirm:""}),setTimeout(()=>{y(""),S(!1)},2e3)}catch{y("error")}},Je=({title:Q,icon:ne,children:gt})=>n.jsxs("div",{style:{background:D,borderRadius:12,padding:22,border:`1px solid ${T}`,boxShadow:`0 1px 4px rgba(0,0,0,${Z?.3:.06})`},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,paddingBottom:14,borderBottom:`1px solid ${T}`},children:[ne,n.jsx("span",{style:{fontSize:14,fontWeight:700,color:E},children:Q})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:gt})]});return n.jsxs("div",{style:{background:de,minHeight:"100%",padding:"0 0 32px"},children:[n.jsxs("div",{style:{background:D,borderBottom:`1px solid ${T}`,padding:"12px 28px",display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:24},children:[n.jsxs("button",{onClick:l,style:{display:"flex",alignItems:"center",gap:7,background:"none",border:"none",cursor:"pointer",fontSize:15,fontWeight:700,color:E,fontFamily:"inherit"},children:[n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:n.jsx("polyline",{points:"15,18 9,12 15,6"})}),"User Profile"]}),r&&n.jsxs("button",{onClick:Oe,style:{display:"flex",alignItems:"center",gap:8,background:m==="saved"?"#16a34a":m==="error"?"#dc2626":"#16a34a",color:"white",border:"none",borderRadius:8,padding:"9px 22px",fontSize:13,fontWeight:700,cursor:"pointer",fontFamily:"inherit"},children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),n.jsx("polyline",{points:"17,21 17,13 7,13 7,21"}),n.jsx("polyline",{points:"7,3 7,8 15,8"})]}),m==="saving"?"Saving…":m==="saved"?"Saved!":m==="error"?"Error":"Save Changes"]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"280px 1fr",gap:22,padding:"0 28px"},children:[n.jsxs("div",{style:{borderRadius:14,overflow:"hidden",boxShadow:"0 4px 20px rgba(0,0,0,0.12)",alignSelf:"start"},children:[n.jsxs("div",{style:{background:"linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%)",padding:"32px 20px 28px",display:"flex",flexDirection:"column",alignItems:"center",gap:6},children:[n.jsx("div",{style:{width:78,height:78,borderRadius:"50%",background:"rgba(255,255,255,0.22)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:4,border:"3px solid rgba(255,255,255,0.3)"},children:n.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"rgba(255,255,255,0.9)",children:[n.jsx("circle",{cx:"12",cy:"8",r:"4"}),n.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7"})]})}),n.jsx("div",{style:{fontSize:17,fontWeight:700,color:"white",textAlign:"center",lineHeight:1.3},children:C||_}),n.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.75)",textAlign:"center"},children:_})]}),n.jsx("div",{style:{background:D},children:[{icon:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:$,strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),n.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),n.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),n.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),label:"Username",value:P},{icon:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:$,strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),n.jsx("circle",{cx:"9",cy:"7",r:"4"}),n.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),n.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),label:"Role Profile",value:k||"—"},{icon:n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:R==="Active"?"#16a34a":"#dc2626",strokeWidth:"2",strokeLinecap:"round",children:n.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),label:"Status",value:R,valueColor:R==="Active"?"#16a34a":"#dc2626"},{icon:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:$,strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),n.jsx("path",{d:"m2 7 10 7 10-7"})]}),label:"Email",value:_},{icon:n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:$,strokeWidth:"2",strokeLinecap:"round",children:n.jsx("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07A19.5 19.5 0 0 1 4.69 13a19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 3.6 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),label:"Phone",value:p.mobile_no||"—"}].map(({icon:Q,label:ne,value:gt,valueColor:re})=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 16px",borderBottom:`1px solid ${T}`},children:[n.jsx("div",{style:{flexShrink:0,width:18,display:"flex",justifyContent:"center"},children:Q}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:11,color:B,marginBottom:1},children:ne}),n.jsx("div",{style:{fontSize:13,fontWeight:600,color:re||E,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:gt})]})]},ne))})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:18},children:[n.jsxs(Je,{title:"Basic Information",icon:n.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("circle",{cx:"12",cy:"8",r:"4"}),n.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7"})]}),children:[n.jsxs("div",{style:ze,children:[n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["Email ",n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Read-only)"})]}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx("div",{style:{position:"absolute",left:11,top:"50%",transform:"translateY(-50%)"},children:n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#94a3b8",strokeWidth:"2",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),n.jsx("path",{d:"m2 7 10 7 10-7"})]})}),n.jsx("input",{style:{...Y,paddingLeft:32},value:_,readOnly:!0})]})]}),n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["Full Name ",n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Auto-generated)"})]}),n.jsx("input",{style:Y,value:C,readOnly:!0})]})]}),n.jsxs("div",{style:$e,children:[n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["First Name ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{style:r?K:Y,value:p.first_name,readOnly:!r,onChange:Q=>u(ne=>({...ne,first_name:Q.target.value})),placeholder:"First name"})]}),n.jsxs("div",{children:[n.jsx("label",{style:V,children:"Middle Name"}),n.jsx("input",{style:r?K:Y,value:p.middle_name,readOnly:!r,onChange:Q=>u(ne=>({...ne,middle_name:Q.target.value})),placeholder:"Middle name"})]}),n.jsxs("div",{children:[n.jsx("label",{style:V,children:"Last Name"}),n.jsx("input",{style:r?K:Y,value:p.last_name,readOnly:!r,onChange:Q=>u(ne=>({...ne,last_name:Q.target.value})),placeholder:"Last name"})]})]}),n.jsxs("div",{style:ze,children:[n.jsxs("div",{children:[n.jsx("label",{style:V,children:"Phone Number"}),n.jsx("input",{style:r?K:Y,value:p.mobile_no,readOnly:!r,onChange:Q=>u(ne=>({...ne,mobile_no:Q.target.value})),placeholder:"Phone number"})]}),n.jsxs("div",{children:[n.jsx("label",{style:V,children:"User ID No"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx("input",{style:{...Y,paddingRight:44},value:p.custom_number||f.name||"",readOnly:!0}),n.jsx("div",{style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",background:"#ef4444",borderRadius:5,padding:"3px 7px",cursor:"default",display:"flex",alignItems:"center"},children:n.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"white",children:[n.jsx("circle",{cx:"5",cy:"12",r:"2"}),n.jsx("circle",{cx:"12",cy:"12",r:"2"}),n.jsx("circle",{cx:"19",cy:"12",r:"2"})]})})]})]})]}),n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["Category ",!v&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),v?n.jsxs("select",{style:ee,value:p.custom_category,onChange:Q=>u(ne=>({...ne,custom_category:Q.target.value})),children:[n.jsx("option",{value:"",children:"Select category"}),["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"].map(Q=>n.jsx("option",{value:Q,children:Q},Q))]}):n.jsx("input",{style:Y,value:k||"—",readOnly:!0})]})]}),n.jsxs(Je,{title:"Organization Information",icon:n.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#8b5cf6",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("rect",{x:"2",y:"7",width:"20",height:"14",rx:"2"}),n.jsx("path",{d:"M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"})]}),children:[n.jsxs("div",{style:ze,children:[n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["Organization ",!v&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),v?n.jsxs("select",{style:ee,value:p.custom_organization,onChange:Q=>u(ne=>({...ne,custom_organization:Q.target.value})),children:[n.jsx("option",{value:"",children:"Select organization"}),me(a,p.custom_organization).map(Q=>n.jsx("option",{value:Q.name,children:Q.organization_name||Q.name},Q.name))]}):n.jsx("input",{style:Y,value:p.custom_organization||"—",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["Management ",!v&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),v?n.jsxs("select",{style:ee,value:p.custom_management,onChange:Q=>u(ne=>({...ne,custom_management:Q.target.value})),children:[n.jsx("option",{value:"",children:"Select management"}),me(i,p.custom_management).map(Q=>n.jsx("option",{value:Q.name,children:Q.name1||Q.name},Q.name))]}):n.jsx("input",{style:Y,value:p.custom_management||"—",readOnly:!0})]})]}),n.jsxs("div",{style:ze,children:[n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["Department ",!v&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),v?n.jsxs("select",{style:ee,value:p.custom_department,onChange:Q=>u(ne=>({...ne,custom_department:Q.target.value})),children:[n.jsx("option",{value:"",children:"Select department"}),me(c,p.custom_department).map(Q=>n.jsx("option",{value:Q.name,children:Q.department_name||Q.name},Q.name))]}):n.jsx("input",{style:Y,value:p.custom_department||"—",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["Branch ",!v&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),v?n.jsxs("select",{style:ee,value:p.custom_branch,onChange:Q=>u(ne=>({...ne,custom_branch:Q.target.value})),children:[n.jsx("option",{value:"",children:"Select branch"}),me(d,p.custom_branch).map(Q=>n.jsx("option",{value:Q.name,children:Q.branch||Q.name},Q.name))]}):n.jsx("input",{style:Y,value:p.custom_branch||"—",readOnly:!0})]})]})]}),n.jsxs("div",{style:{background:D,borderRadius:12,padding:22,border:`1px solid ${T}`,boxShadow:`0 1px 4px rgba(0,0,0,${Z?.3:.06})`},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#f59e0b",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),n.jsx("span",{style:{fontSize:14,fontWeight:700,color:E},children:"Change Password"})]}),r&&n.jsx("button",{onClick:()=>{S(Q=>!Q),y("")},style:{fontSize:13,color:"#3b82f6",background:"none",border:"none",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:h?"Cancel":"Change Password"})]}),h&&n.jsxs("div",{style:{marginTop:18,display:"flex",flexDirection:"column",gap:12},children:[n.jsxs("div",{style:$e,children:[n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["New Password ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{type:"password",style:K,value:g.new,onChange:Q=>x(ne=>({...ne,new:Q.target.value})),placeholder:"New password"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["Confirm Password ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{type:"password",style:K,value:g.confirm,onChange:Q=>x(ne=>({...ne,confirm:Q.target.value})),placeholder:"Confirm password"})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:ge,style:{width:"100%",padding:"9px 0",borderRadius:8,border:"none",background:"#2563eb",color:"white",fontWeight:700,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:o==="saving"?"Saving…":"Update Password"})})]}),o&&o!=="saving"&&n.jsx("div",{style:{fontSize:13,color:o==="done"?"#16a34a":"#dc2626",fontWeight:500},children:o==="done"?"Password updated successfully":o==="error"?"Failed to update password":o})]})]})]})]})]})}function Ce({label:e,val:t,color:s}){return n.jsxs("div",{style:{background:"white",borderRadius:8,padding:"8px 16px",flex:1,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderTop:`3px solid ${s}`,minWidth:0,display:"flex",alignItems:"baseline",gap:8},children:[n.jsx("div",{style:{fontSize:18,fontWeight:700,color:s},children:t}),n.jsx("div",{style:{fontSize:12,color:"#999"},children:e})]})}const ah={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151",boxSizing:"border-box"},O0={...ah,cursor:"pointer"};function ht({filters:e,defaultOpen:t=!1}){const[s,r]=w.useState(t);return n.jsxs("div",{style:{background:"white",borderRadius:12,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:16},children:[n.jsxs("div",{onClick:()=>r(l=>!l),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",padding:"12px 18px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",userSelect:"none"},children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:s?n.jsx("polyline",{points:"18,15 12,9 6,15"}):n.jsx("polyline",{points:"6,9 12,15 18,9"})}),n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{style:{color:"white",fontWeight:700,fontSize:14},children:"Filters"})]}),s&&n.jsx("div",{style:{padding:"18px 20px"},children:n.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${Math.min(e.length,4)}, 1fr)`,gap:14},children:e.map((l,a)=>n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:l.label}),l.type==="search"?n.jsx("input",{style:ah,placeholder:l.placeholder,value:l.value,onChange:i=>l.onChange(i.target.value)}):n.jsx("select",{style:O0,value:l.value,onChange:i=>l.onChange(i.target.value),children:l.options.map(i=>n.jsx("option",{value:i.value,children:i.label},i.value))})]},a))})})]})}function N0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function W0({organizations:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const a=se(),[i,c]=w.useState(""),[d,f]=w.useState("all"),[v,p]=w.useState("all"),u={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},m=w.useMemo(()=>e.filter(g=>{const x=[g.organization_name,g.city].filter(Boolean).join(" ").toLowerCase();return!(i&&!x.includes(i.toLowerCase())||d!=="all"&&g.type!==d||v!=="all"&&(g.is_active?"Active":"Inactive")!==v)}),[e,i,d,v]),[j,h]=w.useState(1);w.useEffect(()=>{h(1)},[i,d,v]);const S=m.slice((j-1)*ie,j*ie);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(Ce,{label:"Total",val:m.length,color:"#1a2332"}),n.jsx(Ce,{label:"Active",val:m.filter(g=>g.is_active).length,color:F.green}),n.jsx(Ce,{label:"Government",val:m.filter(g=>g.type==="Government").length,color:F.blue}),n.jsx(Ce,{label:"Private",val:m.filter(g=>g.type==="Private").length,color:F.orange})]}),n.jsx(ht,{filters:[{type:"search",label:"Search",value:i,onChange:c,placeholder:"Name or city…"},{type:"select",label:a.col.type,value:d,onChange:f,options:[{value:"all",label:"All"},{value:"Government",label:"Government"},{value:"Private",label:"Private"}]},{type:"select",label:"Status",value:v,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:u,children:a.col.name}),n.jsx("th",{style:u,children:a.col.type}),n.jsx("th",{style:u,children:a.col.city}),n.jsx("th",{style:u,children:a.field.creationDate}),n.jsx("th",{style:u,children:a.col.status}),n.jsx("th",{style:u,children:a.col.actions})]})}),n.jsx("tbody",{children:m.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):S.map((g,x)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(g),style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.organization_name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.type||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.city||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:N0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:bl(g.is_active?a.field.statusActive:a.field.statusInactive,g.is_active?F.green:F.gray)}),n.jsx("td",{style:{padding:"8px 14px"},onClick:o=>o.stopPropagation(),children:n.jsx(nt,{onView:()=>s==null?void 0:s(g),onEdit:t&&r?()=>r(g):void 0,onDelete:t&&l?()=>l(g.name):void 0})})]},g.name))})]})}),n.jsx(Ge,{page:j,total:m.length,onPageChange:h})]})}const gn=e=>({background:e?"#f9f9f9":void 0});function B0({orgForm:e,setOrgForm:t,groupCompanies:s=[],formStatus:r,viewMode:l,onEdit:a,darkMode:i,notifCount:c,onToggleDark:d,onCountChange:f,onViewProfile:v,onSubmit:p,onBack:u,onNavigate:m,onLogout:j,user:h}){const S=se(),g=e.name?l&&e.organization_name||S.formTitle.editOrg:S.formTitle.newOrg,x=s.map(o=>({name:o.name,label:o.company_name?`${o.company_name} (${o.name})`:o.name}));return n.jsxs(Ke,{title:g,activePage:"organizations",user:h,formStatus:r,buttonText:S.saveOrg,buttonColor:"#16a34a",viewMode:l,onEdit:a,darkMode:i,notifCount:c,onToggleDark:d,onCountChange:f,onViewProfile:v,onSubmit:p,onBack:u,onNavigate:m,onLogout:j,children:[n.jsx(ae,{title:"Organization Information",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.orgName," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{type:"text",style:{...I,...gn(l||!!e.name)},value:e.organization_name,disabled:l||!!e.name,required:!0,onChange:o=>t({...e,organization_name:o.target.value})})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.orgAcronym," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{type:"text",style:{...I,...gn(l||!!e.name)},value:e.acronym||"",disabled:l||!!e.name,required:!0,onChange:o=>t({...e,acronym:o.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Group Company (Tenant)"}),n.jsx(pe,{value:e.group_company||"",onChange:o=>t({...e,group_company:o}),items:x,placeholder:"Select Group Company",disabled:l||!!h.custom_group_company})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.organizationType}),n.jsxs("select",{style:{...I,...gn(l)},value:e.type,disabled:l,onChange:o=>t({...e,type:o.target.value}),children:[n.jsx("option",{children:"Government"}),n.jsx("option",{children:"Private"}),n.jsx("option",{children:"Non-Profit"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.orgCity}),n.jsx("input",{type:"text",style:{...I,...gn(l)},value:e.city,disabled:l,onChange:o=>t({...e,city:o.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.contactEmail}),n.jsx("input",{type:"email",style:{...I,...gn(l)},value:e.contact_email,disabled:l,onChange:o=>t({...e,contact_email:o.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.creationDate}),n.jsx(xe,{value:e.creation_date||"",onChange:o=>t({...e,creation_date:o}),disabled:l,style:{...I,...gn(l)}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.status}),n.jsxs("select",{style:{...I,...gn(l)},value:e.is_active?"Active":"Inactive",disabled:l,onChange:o=>t({...e,is_active:o.target.value==="Active"?1:0}),children:[n.jsx("option",{value:"Active",children:S.field.statusActive}),n.jsx("option",{value:"Inactive",children:S.field.statusInactive})]})]})]})}),n.jsx(ae,{title:"Incident SLA Windows",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.incidentTriageWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...I,...gn(l)},value:e.incident_triage_window_days??3,disabled:l,onChange:o=>t({...e,incident_triage_window_days:parseInt(o.target.value)||3})}),n.jsx("span",{style:{fontSize:11,color:"#64748b",display:"block",marginTop:4},children:"Days after creation before an untriaged Incident is flagged overdue"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.incidentResolutionWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...I,...gn(l)},value:e.incident_resolution_window_days??5,disabled:l,onChange:o=>t({...e,incident_resolution_window_days:parseInt(o.target.value)||5})}),n.jsx("span",{style:{fontSize:11,color:"#64748b",display:"block",marginTop:4},children:"Days without an update before an in-progress Incident is flagged overdue"})]})]})})]})}function $0({groupCompanies:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const a=se(),[i,c]=w.useState(""),[d,f]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(h=>{const S=[h.company_name,h.acronym,h.code,h.owner_user].filter(Boolean).join(" ").toLowerCase();return!(i&&!S.includes(i.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,i,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[i,d]);const j=p.slice((u-1)*ie,u*ie);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(Ce,{label:"Total Group Cos",val:p.length,color:"#1a2332"}),n.jsx(Ce,{label:"Active",val:p.filter(h=>(h.status||"Active")==="Active").length,color:F.green}),n.jsx(Ce,{label:"Inactive",val:p.filter(h=>h.status==="Inactive").length,color:F.orange})]}),n.jsx(ht,{filters:[{type:"search",label:"Search",value:i,onChange:c,placeholder:"Company name, code, owner…"},{type:"select",label:"Status",value:d,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:"Active"},{value:"Inactive",label:"Inactive"}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{borderBottom:"1px solid #f0f0f0",background:"#fafafa"},children:[n.jsx("th",{style:v,children:"Company Name"}),n.jsx("th",{style:v,children:"Code / Acronym"}),n.jsx("th",{style:v,children:"Group Co Owner"}),n.jsx("th",{style:v,children:"Status"}),n.jsx("th",{style:v,children:a.col.actions})]})}),n.jsxs("tbody",{children:[j.map((h,S)=>{const g=h.custom_is_deleted===1;return n.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(h),style:{borderBottom:"1px solid #f0f0f0",background:g?"#fef2f2":S%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[n.jsxs("td",{style:{padding:"12px 14px",fontWeight:600},children:[h.company_name,g&&n.jsx("span",{style:{marginLeft:8},children:bl(a.deletedBadge,"#ef4444")})]}),n.jsx("td",{style:{padding:"12px 14px",color:"#555"},children:[h.code,h.acronym].filter(Boolean).join(" / ")||"—"}),n.jsx("td",{style:{padding:"12px 14px",color:"#555"},children:h.owner_user||"—"}),n.jsx("td",{style:{padding:"12px 14px"},children:bl(h.status||"Active",(h.status||"Active")==="Active"?F.green:F.orange)}),n.jsx("td",{style:{padding:"12px 14px"},onClick:x=>x.stopPropagation(),children:n.jsx(nt,{onView:s?()=>s(h):void 0,onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name)}),p.length===0&&n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:24,textAlign:"center",color:"#aaa"},children:"No Group Companies found"})})]})]})}),n.jsx(Ge,{page:u,total:p.length,onPageChange:m})]})}function U0({form:e,setForm:t,users:s=[],formStatus:r,viewMode:l,onEdit:a,onRestore:i,darkMode:c,notifCount:d,onToggleDark:f,onCountChange:v,onViewProfile:p,onSubmit:u,onBack:m,onNavigate:j,onLogout:h,user:S}){const g=_=>t({...e,..._}),x=l?{background:"#f8fafc"}:{},o=e.name?l?`View Group Company: ${e.company_name}`:"Edit Group Company":"New Group Company",y=s.map(_=>({name:_.name,label:_.full_name?`${_.full_name} (${_.name})`:_.name}));return n.jsxs(Ke,{title:o,activePage:"group-companies",user:S,formStatus:r,buttonText:"Save Group Company",buttonColor:"#16a34a",viewMode:l,onEdit:a,darkMode:c,notifCount:d,onToggleDark:f,onCountChange:v,onViewProfile:p,onSubmit:u,onBack:m,onNavigate:j,onLogout:h,children:[e.custom_is_deleted===1&&n.jsx(zl,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:i?()=>i(e.name):void 0}),n.jsxs(ae,{title:"Group Company Details",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:["Company Name ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...I,...x},value:e.company_name||"",disabled:l||!!e.name,onChange:_=>g({company_name:_.target.value}),placeholder:"e.g. Company A Group"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Company Code"}),n.jsx("input",{style:{...I,...x},value:e.code||"",disabled:l,onChange:_=>g({code:_.target.value}),placeholder:"e.g. CO-A"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Acronym"}),n.jsx("input",{style:{...I,...x},value:e.acronym||"",disabled:l,onChange:_=>g({acronym:_.target.value}),placeholder:"e.g. CAG"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Status"}),n.jsxs("select",{style:{...I,...x},value:e.status||"Active",disabled:l,onChange:_=>g({status:_.target.value}),children:[n.jsx("option",{value:"Active",children:"Active"}),n.jsx("option",{value:"Inactive",children:"Inactive"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Group Co Owner / Admin User"}),n.jsx(pe,{value:e.owner_user||"",onChange:_=>g({owner_user:_}),items:y,placeholder:"Select owner user",disabled:l})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Notes"}),n.jsx("textarea",{style:{...I,...x,height:75,resize:"vertical"},value:e.notes||"",disabled:l,onChange:_=>g({notes:_.target.value}),placeholder:"Additional details regarding this tenant company…"})]})]})]})}function F0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function M0({managements:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const a=se(),[i,c]=w.useState(""),[d,f]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(i&&!S.includes(i.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,i,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[i,d]);const j=p.slice((u-1)*ie,u*ie);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ce,{label:"Total",val:p.length,color:F.blue})}),n.jsx(ht,{filters:[{type:"search",label:"Search",value:i,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:a.col.name}),n.jsx("th",{style:v,children:a.field.creationDate}),n.jsx("th",{style:v,children:a.field.status}),n.jsx("th",{style:v,children:a.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):j.map((h,S)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:F0(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(nt,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Ge,{page:u,total:p.length,onPageChange:m})]})}function H0({form:e,setForm:t,organizations:s,formStatus:r,viewMode:l,onEdit:a,darkMode:i,notifCount:c,onToggleDark:d,onCountChange:f,onViewProfile:v,onSubmit:p,onBack:u,onNavigate:m,onLogout:j,user:h}){const S=se(),g=y=>t(_=>({..._,...y})),x=l?{background:"#f8fafc"}:{},o=e.name?l?`${S.formTitle.editMgmt}: ${e.name1||e.name}`:S.formTitle.editMgmt:S.formTitle.newMgmt;return n.jsx(Ke,{title:o,activePage:"managements",user:h,formStatus:r,buttonText:S.saveMgmt,buttonColor:"#16a34a",viewMode:l,onEdit:a,darkMode:i,notifCount:c,onToggleDark:d,onCountChange:f,onViewProfile:v,onSubmit:p,onBack:u,onNavigate:m,onLogout:j,children:n.jsx(ae,{title:"Management Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ut,{value:e.organization,onChange:y=>g({organization:y}),organizations:s,disabled:l||!!h.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...I,...x},value:e.name1,disabled:l||!!e.name,onChange:y=>g({name1:y.target.value}),placeholder:"Management name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.creationDate}),n.jsx(xe,{value:e.creation_date||"",onChange:y=>g({creation_date:y}),disabled:l,style:{...I,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.status}),n.jsxs("select",{style:{...I,...x},value:e.status||"Active",disabled:l,onChange:y=>g({status:y.target.value}),children:[n.jsx("option",{value:"Active",children:S.field.statusActive}),n.jsx("option",{value:"Inactive",children:S.field.statusInactive})]})]})]})})})}function G0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function K0({departments:e,managements:t,canModify:s,onView:r,onEdit:l,onDelete:a}){const i=se(),[c,d]=w.useState(""),[f,v]=w.useState(""),[p,u]=w.useState("all"),m=o=>{var y;return((y=t.find(_=>_.name===o))==null?void 0:y.name1)||o||"—"},j={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},h=w.useMemo(()=>e.filter(o=>{const y=(o.department_name||o.name||"").toLowerCase();return!(c&&!y.includes(c.toLowerCase())||f&&o.custom_management!==f||p!=="all"&&(o.custom_status||"Active")!==p)}),[e,c,f,p]),[S,g]=w.useState(1);w.useEffect(()=>{g(1)},[c,f,p]);const x=h.slice((S-1)*ie,S*ie);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ce,{label:"Total",val:h.length,color:F.teal})}),n.jsx(ht,{filters:[{type:"search",label:"Search",value:c,onChange:d,placeholder:"Search by name…"},{type:"select",label:i.col.management,value:f,onChange:v,options:[{value:"",label:"All Managements"},...t.map(o=>({value:o.name,label:o.name1||o.name}))]},{type:"select",label:"Status",value:p,onChange:u,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:j,children:i.col.name}),n.jsx("th",{style:j,children:i.col.management}),n.jsx("th",{style:j,children:i.field.creationDate}),n.jsx("th",{style:j,children:i.field.status}),n.jsx("th",{style:j,children:i.col.actions})]})}),n.jsx("tbody",{children:h.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):x.map((o,y)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>r==null?void 0:r(o),style:{borderTop:"1px solid #f0f0f0",background:y%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.department_name||o.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:m(o.custom_management)}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:G0(o.custom_creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:o.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.custom_status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:_=>_.stopPropagation(),children:n.jsx(nt,{onView:()=>r==null?void 0:r(o),onEdit:s&&l?()=>l(o):void 0,onDelete:s&&a?()=>a(o.name):void 0})})]},o.name))})]})}),n.jsx(Ge,{page:S,total:h.length,onPageChange:g})]})}function Q0({form:e,setForm:t,organizations:s,managements:r,formStatus:l,viewMode:a,onEdit:i,darkMode:c,notifCount:d,onToggleDark:f,onCountChange:v,onViewProfile:p,onSubmit:u,onBack:m,onNavigate:j,onLogout:h,user:S}){const g=se(),x=C=>t(P=>({...P,...C})),o=a?{background:"#f8fafc"}:{},y=e.name?a?`${g.formTitle.editDept}: ${e.department_name||e.name}`:g.formTitle.editDept:g.formTitle.newDept,_=me(r,e.custom_management).map(C=>({name:C.name,label:C.name1||C.name}));return n.jsx(Ke,{title:y,activePage:"departments",user:S,formStatus:l,buttonText:g.saveDept,buttonColor:"#16a34a",viewMode:a,onEdit:i,darkMode:c,notifCount:d,onToggleDark:f,onCountChange:v,onViewProfile:p,onSubmit:u,onBack:m,onNavigate:j,onLogout:h,children:n.jsx(ae,{title:"Department Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[g.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ut,{value:e.custom_organization,onChange:C=>x({custom_organization:C}),organizations:s,disabled:a||!!S.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[g.field.department," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...I,...o},value:e.department_name,disabled:a||!!e.name,onChange:C=>x({department_name:C.target.value}),placeholder:"Department name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.management}),n.jsx(pe,{value:e.custom_management,onChange:C=>x({custom_management:C}),items:_,placeholder:g.field.select,disabled:a})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.creationDate}),n.jsx(xe,{value:e.custom_creation_date||"",onChange:C=>x({custom_creation_date:C}),disabled:a,style:{...I,...o}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.status}),n.jsxs("select",{style:{...I,...o},value:e.custom_status||"Active",disabled:a,onChange:C=>x({custom_status:C.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})})})}function Y0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function X0({branches:e,managements:t,departments:s,canModify:r,onView:l,onEdit:a,onDelete:i}){const c=se(),[d,f]=w.useState(""),[v,p]=w.useState(""),[u,m]=w.useState(""),[j,h]=w.useState("all"),S=P=>{var k;return((k=t.find(R=>R.name===P))==null?void 0:k.name1)||P||"—"},g=P=>{var k;return((k=s.find(R=>R.name===P))==null?void 0:k.department_name)||P||"—"},x={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},o=w.useMemo(()=>e.filter(P=>{const k=(P.branch||P.name||"").toLowerCase();return!(d&&!k.includes(d.toLowerCase())||v&&P.management!==v||u&&P.department!==u||j!=="all"&&(P.custom_status||"Active")!==j)}),[e,d,v,u,j]),[y,_]=w.useState(1);w.useEffect(()=>{_(1)},[d,v,u,j]);const C=o.slice((y-1)*ie,y*ie);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ce,{label:"Total",val:o.length,color:F.purple})}),n.jsx(ht,{filters:[{type:"search",label:"Search",value:d,onChange:f,placeholder:"Search by name…"},{type:"select",label:c.col.management,value:v,onChange:p,options:[{value:"",label:"All Managements"},...t.map(P=>({value:P.name,label:P.name1||P.name}))]},{type:"select",label:c.col.department,value:u,onChange:m,options:[{value:"",label:"All Departments"},...s.map(P=>({value:P.name,label:P.department_name||P.name}))]},{type:"select",label:"Status",value:j,onChange:h,options:[{value:"all",label:"All"},{value:"Active",label:c.field.statusActive},{value:"Inactive",label:c.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:x,children:c.col.branch}),n.jsx("th",{style:x,children:c.col.management}),n.jsx("th",{style:x,children:c.col.department}),n.jsx("th",{style:x,children:c.field.creationDate}),n.jsx("th",{style:x,children:c.field.status}),n.jsx("th",{style:x,children:c.col.actions})]})}),n.jsx("tbody",{children:o.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:c.noData})}):C.map((P,k)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>l==null?void 0:l(P),style:{borderTop:"1px solid #f0f0f0",background:k%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:P.branch||P.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:S(P.management)}),n.jsx("td",{style:{padding:"10px 14px"},children:g(P.department)}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:Y0(P.custom_creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:P.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:P.custom_status==="Inactive"?c.field.statusInactive:c.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:R=>R.stopPropagation(),children:n.jsx(nt,{onView:()=>l==null?void 0:l(P),onEdit:r&&a?()=>a(P):void 0,onDelete:r&&i?()=>i(P.name):void 0})})]},P.name))})]})}),n.jsx(Ge,{page:y,total:o.length,onPageChange:_})]})}function q0({form:e,setForm:t,organizations:s,managements:r,departments:l,formStatus:a,viewMode:i,onEdit:c,darkMode:d,notifCount:f,onToggleDark:v,onCountChange:p,onViewProfile:u,onSubmit:m,onBack:j,onNavigate:h,onLogout:S,user:g}){const x=se(),o=k=>t(R=>({...R,...k})),y=i?{background:"#f8fafc"}:{},_=e.name?i?`${x.formTitle.editBranch}: ${e.branch||e.name}`:x.formTitle.editBranch:x.formTitle.newBranch,C=me(r,e.management).map(k=>({name:k.name,label:k.name1||k.name})),P=me(l,e.department).map(k=>({name:k.name,label:k.department_name||k.name}));return n.jsx(Ke,{title:_,activePage:"branches",user:g,formStatus:a,buttonText:x.saveBranch,buttonColor:"#16a34a",viewMode:i,onEdit:c,darkMode:d,notifCount:f,onToggleDark:v,onCountChange:p,onViewProfile:u,onSubmit:m,onBack:j,onNavigate:h,onLogout:S,children:n.jsx(ae,{title:"Branch Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[x.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ut,{value:e.organization,onChange:k=>o({organization:k}),organizations:s,disabled:i||!!g.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[x.field.branch," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...I,...y},value:e.branch,disabled:i||!!e.name,onChange:k=>o({branch:k.target.value}),placeholder:"Branch name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.management}),n.jsx(pe,{value:e.management,onChange:k=>o({management:k}),items:C,placeholder:x.field.select,disabled:i})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.department}),n.jsx(pe,{value:e.department,onChange:k=>o({department:k}),items:P,placeholder:x.field.select,disabled:i})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.creationDate}),n.jsx(xe,{value:e.custom_creation_date||"",onChange:k=>o({custom_creation_date:k}),disabled:i,style:{...I,...y}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.status}),n.jsxs("select",{style:{...I,...y},value:e.custom_status||"Active",disabled:i,onChange:k=>o({custom_status:k.target.value}),children:[n.jsx("option",{value:"Active",children:x.field.statusActive}),n.jsx("option",{value:"Inactive",children:x.field.statusInactive})]})]})]})})})}function J0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function Z0({incidentTypes:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const a=se(),[i,c]=w.useState(""),[d,f]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(i&&!S.includes(i.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,i,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[i,d]);const j=p.slice((u-1)*ie,u*ie);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ce,{label:"Total",val:p.length,color:F.red})}),n.jsx(ht,{filters:[{type:"search",label:"Search",value:i,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:a.col.name}),n.jsx("th",{style:v,children:a.field.creationDate}),n.jsx("th",{style:v,children:a.field.status}),n.jsx("th",{style:v,children:a.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):j.map((h,S)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:J0(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(nt,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Ge,{page:u,total:p.length,onPageChange:m})]})}function V0({form:e,setForm:t,formStatus:s,viewMode:r,onEdit:l,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:d,onViewProfile:f,onSubmit:v,onBack:p,onNavigate:u,onLogout:m,user:j}){const h=se(),S=o=>t(y=>({...y,...o})),g=r?{background:"#f8fafc"}:{},x=e.name?r?`Incident Type: ${e.name1||e.name}`:"Edit Incident Type":"New Incident Type";return n.jsx(Ke,{title:x,activePage:"incident-types",user:j,formStatus:s,buttonText:h.saveName,buttonColor:"#16a34a",viewMode:r,onEdit:l,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:d,onViewProfile:f,onSubmit:v,onBack:p,onNavigate:u,onLogout:m,children:n.jsx(ae,{title:"Incident Type Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...I,...g},value:e.name1,disabled:r||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Incident type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(xe,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:r,style:{...I,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...I,...g},value:e.status||"Active",disabled:r,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})})})}function e1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function t1({ideaTypes:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const a=se(),[i,c]=w.useState(""),[d,f]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(i&&!S.includes(i.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,i,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[i,d]);const j=p.slice((u-1)*ie,u*ie);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ce,{label:"Total",val:p.length,color:F.teal})}),n.jsx(ht,{filters:[{type:"search",label:"Search",value:i,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:a.col.name}),n.jsx("th",{style:v,children:a.field.creationDate}),n.jsx("th",{style:v,children:a.field.status}),n.jsx("th",{style:v,children:a.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):j.map((h,S)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:e1(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(nt,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Ge,{page:u,total:p.length,onPageChange:m})]})}function n1({form:e,setForm:t,formStatus:s,viewMode:r,onEdit:l,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:d,onViewProfile:f,onSubmit:v,onBack:p,onNavigate:u,onLogout:m,user:j}){const h=se(),S=o=>t(y=>({...y,...o})),g=r?{background:"#f8fafc"}:{},x=e.name?r?`Idea Type: ${e.name1||e.name}`:"Edit Idea Type":"New Idea Type";return n.jsx(Ke,{title:x,activePage:"idea-types",user:j,formStatus:s,buttonText:h.saveName,buttonColor:"#16a34a",viewMode:r,onEdit:l,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:d,onViewProfile:f,onSubmit:v,onBack:p,onNavigate:u,onLogout:m,children:n.jsx(ae,{title:"Idea Type Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...I,...g},value:e.name1,disabled:r||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Idea type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(xe,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:r,style:{...I,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...I,...g},value:e.status||"Active",disabled:r,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})})})}function s1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function r1({orderTypes:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const a=se(),[i,c]=w.useState(""),[d,f]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(i&&!S.includes(i.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,i,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[i,d]);const j=p.slice((u-1)*ie,u*ie);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ce,{label:"Total",val:p.length,color:F.purple})}),n.jsx(ht,{filters:[{type:"search",label:"Search",value:i,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:a.col.name}),n.jsx("th",{style:v,children:a.field.creationDate}),n.jsx("th",{style:v,children:a.field.status}),n.jsx("th",{style:v,children:a.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):j.map((h,S)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:s1(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(nt,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Ge,{page:u,total:p.length,onPageChange:m})]})}function l1({form:e,setForm:t,formStatus:s,viewMode:r,onEdit:l,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:d,onViewProfile:f,onSubmit:v,onBack:p,onNavigate:u,onLogout:m,user:j}){const h=se(),S=o=>t(y=>({...y,...o})),g=r?{background:"#f8fafc"}:{},x=e.name?r?`Order Type: ${e.name1||e.name}`:"Edit Order Type":"New Order Type";return n.jsx(Ke,{title:x,activePage:"order-types",user:j,formStatus:s,buttonText:h.saveName,buttonColor:"#16a34a",viewMode:r,onEdit:l,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:d,onViewProfile:f,onSubmit:v,onBack:p,onNavigate:u,onLogout:m,children:n.jsx(ae,{title:"Order Type Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...I,...g},value:e.name1,disabled:r||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Order type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(xe,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:r,style:{...I,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...I,...g},value:e.status||"Active",disabled:r,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})})})}function a1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function i1({processTypes:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const a=se(),[i,c]=w.useState(""),[d,f]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(i&&!S.includes(i.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,i,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[i,d]);const j=p.slice((u-1)*ie,u*ie);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ce,{label:"Total",val:p.length,color:F.blue})}),n.jsx(ht,{filters:[{type:"search",label:"Search",value:i,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:a.col.name}),n.jsx("th",{style:v,children:a.field.creationDate}),n.jsx("th",{style:v,children:a.field.status}),n.jsx("th",{style:v,children:a.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):j.map((h,S)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:a1(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(nt,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Ge,{page:u,total:p.length,onPageChange:m})]})}function o1({form:e,setForm:t,formStatus:s,viewMode:r,onEdit:l,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:d,onViewProfile:f,onSubmit:v,onBack:p,onNavigate:u,onLogout:m,user:j}){const h=se(),S=o=>t(y=>({...y,...o})),g=r?{background:"#f8fafc"}:{},x=e.name?r?`Process Type: ${e.name1||e.name}`:"Edit Process Type":"New Process Type";return n.jsx(Ke,{title:x,activePage:"process-types",user:j,formStatus:s,buttonText:h.saveName,buttonColor:"#16a34a",viewMode:r,onEdit:l,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:d,onViewProfile:f,onSubmit:v,onBack:p,onNavigate:u,onLogout:m,children:n.jsx(ae,{title:"Process Type Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...I,...g},value:e.name1,disabled:r||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Process type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(xe,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:r,style:{...I,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...I,...g},value:e.status||"Active",disabled:r,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})})})}function d1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function c1({incidentStatuses:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const a=se(),[i,c]=w.useState(""),[d,f]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(i&&!S.includes(i.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,i,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[i,d]);const j=p.slice((u-1)*ie,u*ie);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ce,{label:"Total",val:p.length,color:F.red})}),n.jsx(ht,{filters:[{type:"search",label:"Search",value:i,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:a.col.name}),n.jsx("th",{style:v,children:a.field.notifyManager}),n.jsx("th",{style:v,children:a.field.creationDate}),n.jsx("th",{style:v,children:a.field.status}),n.jsx("th",{style:v,children:a.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):j.map((h,S)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.notify_manager?a.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:d1(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(nt,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Ge,{page:u,total:p.length,onPageChange:m})]})}function u1({form:e,setForm:t,formStatus:s,viewMode:r,onEdit:l,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:d,onViewProfile:f,onSubmit:v,onBack:p,onNavigate:u,onLogout:m,user:j}){const h=se(),S=o=>t(y=>({...y,...o})),g=r?{background:"#f8fafc"}:{},x=e.name?r?`Incident Status: ${e.name1||e.name}`:"Edit Incident Status":"New Incident Status";return n.jsx(Ke,{title:x,activePage:"incident-statuses",user:j,formStatus:s,buttonText:h.saveName,buttonColor:"#16a34a",viewMode:r,onEdit:l,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:d,onViewProfile:f,onSubmit:v,onBack:p,onNavigate:u,onLogout:m,children:n.jsxs(ae,{title:"Incident Status Details",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...I,...g},value:e.name1,disabled:r||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Incident status name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(xe,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:r,style:{...I,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...I,...g},value:e.status||"Active",disabled:r,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:r,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:wr}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:r?"default":"pointer"},children:h.field.notifyManager})]})]})})}function p1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function f1({ideaStatuses:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const a=se(),[i,c]=w.useState(""),[d,f]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(i&&!S.includes(i.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,i,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[i,d]);const j=p.slice((u-1)*ie,u*ie);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ce,{label:"Total",val:p.length,color:F.teal})}),n.jsx(ht,{filters:[{type:"search",label:"Search",value:i,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:a.col.name}),n.jsx("th",{style:v,children:a.field.notifyManager}),n.jsx("th",{style:v,children:a.field.creationDate}),n.jsx("th",{style:v,children:a.field.status}),n.jsx("th",{style:v,children:a.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):j.map((h,S)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.notify_manager?a.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:p1(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(nt,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Ge,{page:u,total:p.length,onPageChange:m})]})}function h1({form:e,setForm:t,formStatus:s,viewMode:r,onEdit:l,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:d,onViewProfile:f,onSubmit:v,onBack:p,onNavigate:u,onLogout:m,user:j}){const h=se(),S=o=>t(y=>({...y,...o})),g=r?{background:"#f8fafc"}:{},x=e.name?r?`Idea Status: ${e.name1||e.name}`:"Edit Idea Status":"New Idea Status";return n.jsx(Ke,{title:x,activePage:"idea-statuses",user:j,formStatus:s,buttonText:h.saveName,buttonColor:"#16a34a",viewMode:r,onEdit:l,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:d,onViewProfile:f,onSubmit:v,onBack:p,onNavigate:u,onLogout:m,children:n.jsxs(ae,{title:"Idea Status Details",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...I,...g},value:e.name1,disabled:r||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Idea status name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(xe,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:r,style:{...I,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...I,...g},value:e.status||"Active",disabled:r,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:r,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:wr}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:r?"default":"pointer"},children:h.field.notifyManager})]})]})})}function g1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function x1({orderStatuses:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const a=se(),[i,c]=w.useState(""),[d,f]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(i&&!S.includes(i.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,i,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[i,d]);const j=p.slice((u-1)*ie,u*ie);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ce,{label:"Total",val:p.length,color:F.purple})}),n.jsx(ht,{filters:[{type:"search",label:"Search",value:i,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:a.col.name}),n.jsx("th",{style:v,children:a.field.notifyManager}),n.jsx("th",{style:v,children:a.field.creationDate}),n.jsx("th",{style:v,children:a.field.status}),n.jsx("th",{style:v,children:a.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):j.map((h,S)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.notify_manager?a.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:g1(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(nt,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Ge,{page:u,total:p.length,onPageChange:m})]})}function m1({form:e,setForm:t,formStatus:s,viewMode:r,onEdit:l,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:d,onViewProfile:f,onSubmit:v,onBack:p,onNavigate:u,onLogout:m,user:j}){const h=se(),S=o=>t(y=>({...y,...o})),g=r?{background:"#f8fafc"}:{},x=e.name?r?`Order Status: ${e.name1||e.name}`:"Edit Order Status":"New Order Status";return n.jsx(Ke,{title:x,activePage:"order-statuses",user:j,formStatus:s,buttonText:h.saveName,buttonColor:"#16a34a",viewMode:r,onEdit:l,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:d,onViewProfile:f,onSubmit:v,onBack:p,onNavigate:u,onLogout:m,children:n.jsxs(ae,{title:"Order Status Details",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...I,...g},value:e.name1,disabled:r||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Order status name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(xe,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:r,style:{...I,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...I,...g},value:e.status||"Active",disabled:r,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:r,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:wr}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:r?"default":"pointer"},children:h.field.notifyManager})]})]})})}function y1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function v1({processStatuses:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const a=se(),[i,c]=w.useState(""),[d,f]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(i&&!S.includes(i.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,i,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[i,d]);const j=p.slice((u-1)*ie,u*ie);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ce,{label:"Total",val:p.length,color:F.blue})}),n.jsx(ht,{filters:[{type:"search",label:"Search",value:i,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:a.col.name}),n.jsx("th",{style:v,children:a.field.notifyManager}),n.jsx("th",{style:v,children:a.field.creationDate}),n.jsx("th",{style:v,children:a.field.status}),n.jsx("th",{style:v,children:a.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):j.map((h,S)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.notify_manager?a.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:y1(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(nt,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Ge,{page:u,total:p.length,onPageChange:m})]})}function j1({form:e,setForm:t,formStatus:s,viewMode:r,onEdit:l,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:d,onViewProfile:f,onSubmit:v,onBack:p,onNavigate:u,onLogout:m,user:j}){const h=se(),S=o=>t(y=>({...y,...o})),g=r?{background:"#f8fafc"}:{},x=e.name?r?`Process Status: ${e.name1||e.name}`:"Edit Process Status":"New Process Status";return n.jsx(Ke,{title:x,activePage:"process-statuses",user:j,formStatus:s,buttonText:h.saveName,buttonColor:"#16a34a",viewMode:r,onEdit:l,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:d,onViewProfile:f,onSubmit:v,onBack:p,onNavigate:u,onLogout:m,children:n.jsxs(ae,{title:"Process Status Details",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...I,...g},value:e.name1,disabled:r||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Process status name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(xe,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:r,style:{...I,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...I,...g},value:e.status||"Active",disabled:r,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:r,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:wr}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:r?"default":"pointer"},children:h.field.notifyManager})]})]})})}const b1={Admin:"#7c3aed",Chairman:"#0f766e",Auditor:"#d97706","X-Auditor":"#8b5cf6",Manager:"#2563eb",Employee:"#6b7280"};function S1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function w1({users:e,canModify:t,onView:s,onEdit:r,onDisable:l}){const a=se(),[i,c]=w.useState(!1),[d,f]=w.useState(""),[v,p]=w.useState(""),[u,m]=w.useState(""),[j,h]=w.useState("active"),[S,g]=w.useState(1),[x,o]=w.useState(null),[y,_]=w.useState(""),[C,P]=w.useState("idle"),[k,R]=w.useState(null),$=async()=>{if(!(!x||!y.trim())){P("loading");try{await sh(x.name,y.trim()),P("success"),setTimeout(()=>{o(null),_(""),P("idle")},1200)}catch{P("error")}}},Z=async A=>{if(window.confirm(a.users.disableConfirm)){R(A);try{await(l==null?void 0:l(A))}finally{R(null)}}},de=e.filter(A=>{if(j==="active"&&(A.enabled===0||A.enabled==="0")||j==="inactive"&&A.enabled!==0&&A.enabled!=="0")return!1;const K=A.custom_category||"";if(u&&K!==u)return!1;const Y=A.custom_organization||"";if(v&&!Y.toLowerCase().includes(v.toLowerCase()))return!1;if(d){const ee=d.toLowerCase();if(![A.full_name,A.email,A.name,A.username,A.mobile_no].join(" ").toLowerCase().includes(ee))return!1}return!0}),D=[...new Set(e.map(A=>A.custom_organization).filter(Boolean))],T=["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"];w.useEffect(()=>{g(1)},[d,v,u,j]);const E=de.slice((S-1)*ie,S*ie),B={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151"},M={...B,cursor:"pointer"};return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,flex:1},children:[n.jsxs("div",{style:{fontSize:13,color:"#6b7280",marginBottom:16},children:["Total: ",de.length," users"]}),n.jsxs("div",{style:{background:"white",borderRadius:12,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:16},children:[n.jsxs("div",{onClick:()=>c(A=>!A),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",padding:"12px 18px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",userSelect:"none"},children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:i?n.jsx("polyline",{points:"18,15 12,9 6,15"}):n.jsx("polyline",{points:"6,9 12,15 18,9"})}),n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{style:{color:"white",fontWeight:700,fontSize:14},children:"Filters"})]}),i&&n.jsx("div",{style:{padding:"18px 20px",display:"flex",flexDirection:"column",gap:14},children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gap:14},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Search"}),n.jsx("input",{style:B,placeholder:"Name, email, username…",value:d,onChange:A=>f(A.target.value)})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Organization"}),n.jsxs("select",{style:M,value:v,onChange:A=>p(A.target.value),children:[n.jsx("option",{value:"",children:"All Organizations"}),D.map(A=>n.jsx("option",{value:A,children:A},A))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Category"}),n.jsxs("select",{style:M,value:u,onChange:A=>m(A.target.value),children:[n.jsx("option",{value:"",children:"All Categories"}),T.map(A=>n.jsx("option",{value:A,children:A},A))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Status"}),n.jsxs("select",{style:M,value:j,onChange:A=>h(A.target.value),children:[n.jsx("option",{value:"all",children:"All"}),n.jsx("option",{value:"active",children:"Active"}),n.jsx("option",{value:"inactive",children:"Inactive"})]})]})]})})]}),n.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa",borderBottom:"2px solid #f0f0f0"},children:[{label:"Category",w:100},{label:"Number",w:80},{label:"Full Name",w:140},{label:"Username",w:120},{label:"Email Address",w:180},{label:"Phone Number",w:120},{label:"Organization",w:130},{label:"Management",w:120},{label:"Department",w:120},{label:"Branch",w:100},{label:"Since",w:90},{label:"Status",w:80},{label:"Tools",w:200}].map(({label:A,w:K})=>n.jsx("th",{style:{padding:"11px 14px",textAlign:"left",color:"#6b7280",fontSize:11,fontWeight:700,whiteSpace:"nowrap",minWidth:K,letterSpacing:.3,textTransform:"uppercase"},children:A},A))})}),n.jsx("tbody",{children:de.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:13,style:{padding:"48px 20px",textAlign:"center",color:"#aaa",fontSize:14},children:"No users found"})}):E.map((A,K)=>{const Y=A.custom_category||"",ee=b1[Y]||"#6b7280";return n.jsxs("tr",{onClick:()=>s==null?void 0:s(A),style:{borderBottom:"1px solid #f3f4f6",background:K%2===0?"white":"#fafafa",transition:"background 0.1s",cursor:"pointer"},onMouseEnter:V=>V.currentTarget.style.background="#f0f7ff",onMouseLeave:V=>V.currentTarget.style.background=K%2===0?"white":"#fafafa",children:[n.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:Y?n.jsx("span",{style:{background:ee+"18",color:ee,border:`1px solid ${ee}44`,padding:"3px 10px",borderRadius:20,fontSize:11,fontWeight:700},children:Y}):n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:A.custom_number||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",fontWeight:600,color:"#1a2332",whiteSpace:"nowrap"},children:A.full_name||A.first_name||"—"}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:A.username||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:A.email||A.name}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:A.mobile_no||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:A.custom_organization||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:A.custom_management||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:A.custom_department||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:A.custom_branch||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:S1(A.creation)}),n.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:n.jsx("span",{style:{color:A.enabled?"#16a34a":"#dc2626",fontWeight:600},children:A.enabled?a.users.active:a.users.inactive})}),n.jsx("td",{style:{padding:"10px 14px",whiteSpace:"nowrap"},onClick:V=>V.stopPropagation(),children:n.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[n.jsx("button",{onClick:V=>{V.stopPropagation(),s==null||s(A)},title:"View",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#e0f7fa",color:"#0891b2"},children:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),t&&r&&n.jsx("button",{onClick:V=>{V.stopPropagation(),r(A)},title:"Edit",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#dcfce7",color:"#16a34a"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),t&&n.jsx("button",{onClick:V=>{V.stopPropagation(),o({name:A.name,email:A.email||A.name}),_(""),P("idle")},title:"Set Password",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#fef3c7",color:"#d97706"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}),t&&n.jsx("button",{onClick:V=>{V.stopPropagation(),Z(A.name)},disabled:k===A.name,title:"Disable",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#fee2e2",color:"#ef4444",opacity:k===A.name?.5:1},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("polyline",{points:"3 6 5 6 21 6"}),n.jsx("path",{d:"M19 6l-1 14H6L5 6"}),n.jsx("path",{d:"M10 11v6M14 11v6"}),n.jsx("path",{d:"M9 6V4h6v2"})]})})]})})]},A.name)})})]})}),n.jsx(Ge,{page:S,total:de.length,onPageChange:g}),x&&n.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"},children:n.jsxs("div",{style:{background:"white",borderRadius:14,padding:32,width:390,boxShadow:"0 20px 60px rgba(0,0,0,0.3)"},children:[n.jsx("div",{style:{fontSize:17,fontWeight:700,marginBottom:6,color:"#1a2332"},children:a.users.setPassword}),n.jsxs("div",{style:{fontSize:13,color:"#6b7280",marginBottom:20},children:["User: ",n.jsx("strong",{children:x.email})]}),n.jsx("input",{type:"password",value:y,onChange:A=>_(A.target.value),placeholder:a.users.newPassword,style:{width:"100%",padding:"10px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,boxSizing:"border-box",marginBottom:16,fontFamily:"Segoe UI",outline:"none"},onKeyDown:A=>A.key==="Enter"&&$(),autoFocus:!0}),C==="success"&&n.jsx("div",{style:{color:"#166534",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,padding:"8px 12px",marginBottom:12,fontSize:13},children:"Password updated successfully"}),C==="error"&&n.jsx("div",{style:{color:"#991b1b",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,padding:"8px 12px",marginBottom:12,fontSize:13},children:"Failed to update password"}),n.jsxs("div",{style:{display:"flex",gap:10},children:[n.jsx("button",{onClick:$,disabled:C==="loading"||!y.trim(),style:{flex:1,padding:10,background:"#2563eb",color:"white",border:"none",borderRadius:8,cursor:"pointer",fontSize:13,fontWeight:700,fontFamily:"inherit",opacity:y.trim()?1:.5},children:C==="loading"?"Saving…":a.users.setPassword}),n.jsx("button",{onClick:()=>{o(null),_(""),P("idle")},style:{flex:1,padding:10,background:"#f5f5f5",color:"#374151",border:"1px solid #e5e7eb",borderRadius:8,cursor:"pointer",fontSize:13,fontFamily:"inherit"},children:a.cancel})]})]})})]})}function _1({form:e,setForm:t,groupCompanies:s=[],organizations:r,managements:l,departments:a,branches:i,formStatus:c,viewMode:d,onEdit:f,darkMode:v,notifCount:p,onToggleDark:u,onCountChange:m,onViewProfile:j,isSelfProfile:h,onSubmit:S,onBack:g,onNavigate:x,onLogout:o,user:y}){const _=se(),C=T=>t(E=>({...E,...T})),P=d?{background:"#f8fafc"}:{},k=!e.name,R=h?"My Profile":k?"New User":d?`User: ${e.full_name||e.email}`:`Edit User: ${e.full_name||e.email}`,$=s.map(T=>({name:T.name,label:T.company_name?`${T.company_name} (${T.name})`:T.name})),Z=me(l,e.custom_management).map(T=>({name:T.name,label:T.name1||T.name})),de=me(a,e.custom_department).map(T=>({name:T.name,label:T.department_name||T.name})),D=me(i,e.custom_branch).map(T=>({name:T.name,label:T.branch||T.name}));return n.jsxs(Ke,{title:R,activePage:"users",user:y,formStatus:c,buttonText:_.saveUser,buttonColor:"#16a34a",viewMode:d,onEdit:f,darkMode:v,notifCount:p,onToggleDark:u,onCountChange:m,onViewProfile:j,hideSettings:h,onSubmit:S,onBack:g,onNavigate:x,onLogout:o,children:[n.jsx(ae,{title:"User Organization & Assignment",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Group Company (Tenant)"}),n.jsx(pe,{value:e.custom_group_company||"",onChange:T=>C({custom_group_company:T}),items:$,placeholder:"-- Select Group Company --",disabled:d||!!y.custom_group_company})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.organization}),n.jsx(Ut,{value:e.custom_organization,onChange:T=>C({custom_organization:T}),organizations:r,disabled:d})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.management}),n.jsx(pe,{value:e.custom_management,onChange:T=>C({custom_management:T}),items:Z,placeholder:"-- Select --",disabled:d})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.department}),n.jsx(pe,{value:e.custom_department,onChange:T=>C({custom_department:T}),items:de,placeholder:"-- Select --",disabled:d})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.branch}),n.jsx(pe,{value:e.custom_branch,onChange:T=>C({custom_branch:T}),items:D,placeholder:"-- Select --",disabled:d})]})]})}),n.jsx(ae,{title:"User Profile Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.number}),n.jsx("input",{style:{...I,...P},value:e.custom_number,disabled:d,onChange:T=>C({custom_number:T.target.value}),placeholder:"e.g. 10001"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[_.field.fullName," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...I,...P},value:e.first_name,disabled:d,onChange:T=>C({first_name:T.target.value}),placeholder:"Full name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.username}),n.jsx("input",{style:{...I,...P},value:e.username,disabled:d,onChange:T=>C({username:T.target.value}),placeholder:"Username"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.phoneNumber}),n.jsx("input",{style:{...I,...P},value:e.mobile_no,disabled:d,onChange:T=>C({mobile_no:T.target.value}),placeholder:"Phone number"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[_.field.emailAddress," ",k&&n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...I,...d||!k?{background:"#f8fafc"}:{}},value:e.email,disabled:d||!k,onChange:T=>C({email:T.target.value}),placeholder:"user@example.com",type:"email",required:k})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.category}),n.jsxs("select",{style:{...I,...P},value:e.custom_category,disabled:d,onChange:T=>C({custom_category:T.target.value}),children:[n.jsx("option",{value:"",children:_.field.select}),n.jsx("option",{children:"Admin"}),n.jsx("option",{children:"Chairman"}),n.jsx("option",{children:"Auditor"}),n.jsx("option",{children:"X-Auditor"}),n.jsx("option",{children:"Manager"}),n.jsx("option",{children:"Employee"})]})]})]})})]})}const Iu={Active:F.green,Closed:F.gray};function k1({cycles:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const a=se(),[i,c]=w.useState(""),[d,f]=w.useState(""),[v,p]=w.useState("all"),u=w.useMemo(()=>[...new Set(e.map(o=>o.organization).filter(Boolean))],[e]),m=w.useMemo(()=>e.filter(o=>{const y=(o.name1||o.name||"").toLowerCase();return!(i&&!y.includes(i.toLowerCase())||d&&o.organization!==d||v!=="all"&&o.status!==v)}),[e,i,d,v]),[j,h]=w.useState(1);w.useEffect(()=>{h(1)},[i,d,v]);const S=m.slice((j-1)*ie,j*ie),g=m.filter(o=>o.status==="Active").length,x=m.filter(o=>o.status==="Closed").length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(Ce,{label:"Total",val:m.length,color:F.teal}),n.jsx(Ce,{label:"Active",val:g,color:F.green}),n.jsx(Ce,{label:"Closed",val:x,color:F.gray})]}),n.jsx(ht,{filters:[{type:"search",label:"Search",value:i,onChange:c,placeholder:"Search by name…"},{type:"select",label:a.col.organization,value:d,onChange:f,options:[{value:"",label:"All Organizations"},...u.map(o=>({value:o,label:o}))]},{type:"select",label:"Status",value:v,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:"Active"},{value:"Closed",label:"Closed"}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.name}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.frequency}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.startDate}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.endDate}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.actions})]})}),n.jsx("tbody",{children:m.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):S.map((o,y)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:y%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.frequency||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.start_date||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.end_date||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{padding:"3px 10px",borderRadius:12,fontSize:12,background:Iu[o.status]+"22",color:Iu[o.status]||"#666"},children:o.status})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:_=>_.stopPropagation(),children:n.jsx(nt,{onView:()=>s==null?void 0:s(o),onEdit:t&&r?()=>r(o):void 0,onDelete:t&&l?()=>l(o.name):void 0})})]},o.name))})]})}),n.jsx(Ge,{page:j,total:m.length,onPageChange:h})]})}const C1=["Weekly","Bi-weekly","Monthly","Quarterly","Annually"],z1=["Active","Closed"];function T1({form:e,setForm:t,organizations:s,formStatus:r,viewMode:l,onEdit:a,darkMode:i,notifCount:c,onToggleDark:d,onCountChange:f,onViewProfile:v,onSubmit:p,onBack:u,onNavigate:m,onLogout:j,user:h}){const S=se(),g=y=>t(_=>({..._,...y})),x=l?{background:"#f8fafc"}:{},o=e.name?l?`${S.formTitle.editCycle}: ${e.name1||e.name}`:S.formTitle.editCycle:S.formTitle.newCycle;return n.jsx(Ke,{title:o,activePage:"cycles",user:h,formStatus:r,buttonText:S.saveCycle,buttonColor:"#16a34a",viewMode:l,onEdit:a,darkMode:i,notifCount:c,onToggleDark:d,onCountChange:f,onViewProfile:v,onSubmit:p,onBack:u,onNavigate:m,onLogout:j,children:n.jsx(ae,{title:"Cycle Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...I,...x},value:e.name1||"",disabled:l||!!e.name,onChange:y=>g({name1:y.target.value}),placeholder:"e.g. Q1-2026"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ut,{value:e.organization,onChange:y=>g({organization:y}),organizations:s,disabled:l||!!h.custom_organization})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.col.frequency}),n.jsx(pe,{value:e.frequency,onChange:y=>g({frequency:y}),items:C1.map(y=>({name:y,label:y})),placeholder:"-- Select Frequency --",disabled:l})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.status}),n.jsx(pe,{value:e.status,onChange:y=>g({status:y}),items:z1.map(y=>({name:y,label:y})),placeholder:"-- Select Status --",disabled:l})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.dateStart}),n.jsx(xe,{value:e.start_date||"",onChange:y=>g({start_date:y}),disabled:l,style:{...I,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.dateEnd}),n.jsx(xe,{value:e.end_date||"",onChange:y=>g({end_date:y}),disabled:l,style:{...I,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.updateWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...I,...x},value:e.update_window_days??2,disabled:l,onChange:y=>g({update_window_days:parseInt(y.target.value)||2})}),n.jsx("span",{style:{fontSize:11,color:"#64748b",display:"block",marginTop:4},children:"Grace period before Unknown is auto-assigned"})]})]})})})}function I1({kpiInputs:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const a=se(),[i,c]=w.useState(""),[d,f]=w.useState(""),v=w.useMemo(()=>[...new Set(e.map(h=>h.organization).filter(Boolean))],[e]),p=w.useMemo(()=>e.filter(h=>{const S=[h.organization,h.period].filter(Boolean).join(" ").toLowerCase();return!(i&&!S.includes(i.toLowerCase())||d&&h.organization!==d)}),[e,i,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[i,d]);const j=p.slice((u-1)*ie,u*ie);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ce,{label:"Total Records",val:p.length,color:F.blue})}),n.jsx(ht,{filters:[{type:"search",label:"Search",value:i,onChange:c,placeholder:"Organization or period…"},{type:"select",label:a.col.organization,value:d,onChange:f,options:[{value:"",label:"All Organizations"},...v.map(h=>({value:h,label:h}))]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.period}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.field.revenue_growth}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.field.net_profit}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.dash.customerSat}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):j.map((h,S)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.period||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.revenue_growth!=null?`${h.revenue_growth}%`:"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.net_profit!=null?h.net_profit.toLocaleString():"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.customer_satisfaction!=null?h.customer_satisfaction:"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(nt,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Ge,{page:u,total:p.length,onPageChange:m})]})}function E1({form:e,setForm:t,organizations:s,formStatus:r,viewMode:l,onEdit:a,darkMode:i,notifCount:c,onToggleDark:d,onCountChange:f,onViewProfile:v,onSubmit:p,onBack:u,onNavigate:m,onLogout:j,user:h}){const S=se(),g=_=>t(C=>({...C,..._})),x=l?{background:"#f8fafc"}:{},o=_=>C=>g({[_]:parseFloat(C.target.value)||0}),y=e.name?l?`${S.formTitle.editKpi}: ${e.period||e.name}`:S.formTitle.editKpi:S.formTitle.newKpi;return n.jsxs(Ke,{title:y,activePage:"kpi-input",user:h,formStatus:r,buttonText:S.saveKpi,buttonColor:"#16a34a",viewMode:l,onEdit:a,darkMode:i,notifCount:c,onToggleDark:d,onCountChange:f,onViewProfile:v,onSubmit:p,onBack:u,onNavigate:m,onLogout:j,children:[n.jsx(ae,{title:"Period & Organization",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ut,{value:e.organization,onChange:_=>g({organization:_}),organizations:s,disabled:l||!!h.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.col.period," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...I,...x},value:e.period||"",disabled:l,onChange:_=>g({period:_.target.value}),placeholder:"e.g. Q1 2026"})]})]})}),n.jsx(ae,{title:"Financial KPIs",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.revenue_growth}),n.jsx("input",{type:"number",step:"0.01",style:{...I,...x},value:e.revenue_growth||"",disabled:l,onChange:o("revenue_growth")})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.net_profit}),n.jsx("input",{type:"number",step:"0.01",style:{...I,...x},value:e.net_profit||"",disabled:l,onChange:o("net_profit")})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.cash_flow}),n.jsx("input",{type:"number",step:"0.01",style:{...I,...x},value:e.cash_flow||"",disabled:l,onChange:o("cash_flow")})]})]})}),n.jsx(ae,{title:"Operational KPIs",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.strategic_goal_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...I,...x},value:e.strategic_goal_pct||"",disabled:l,onChange:o("strategic_goal_pct")})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.customer_satisfaction}),n.jsx("input",{type:"number",step:"0.01",style:{...I,...x},value:e.customer_satisfaction||"",disabled:l,onChange:o("customer_satisfaction")})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.employee_turnover_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...I,...x},value:e.employee_turnover_pct||"",disabled:l,onChange:o("employee_turnover_pct")})]})]})}),n.jsx(ae,{title:"Safety & Compliance",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.open_safety_incidents}),n.jsx("input",{type:"number",min:0,style:{...I,...x},value:e.open_safety_incidents||"",disabled:l,onChange:_=>g({open_safety_incidents:parseInt(_.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.compliance_score}),n.jsx("input",{type:"number",step:"0.01",style:{...I,...x},value:e.compliance_score||"",disabled:l,onChange:o("compliance_score")})]})]})})]})}const P1={create_processes:"Create Processes",update_process_status:"Update Process Status"},Eu={Pending:F.orange,Accepted:F.green,Rejected:F.red,Revoked:F.gray};function A1(e){if(!e)return"—";const t=new Date(e);return isNaN(t.getTime())?"—":`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function R1(e){const t=[];return e.create_processes&&t.push("create_processes"),e.update_process_status&&t.push("update_process_status"),t}function D1({delegations:e,organizations:t,userRole:s,currentUser:r,onView:l,onRevoke:a}){const i=se(),[c,d]=w.useState(""),[f,v]=w.useState(""),[p,u]=w.useState("all"),m={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},j=w.useMemo(()=>e.filter(y=>{const _=`${y.auditor} ${y.manager}`.toLowerCase();return!(c&&!_.includes(c.toLowerCase())||f&&y.organization!==f||p!=="all"&&y.status!==p)}),[e,c,f,p]),[h,S]=w.useState(1);w.useEffect(()=>{S(1)},[c,f,p]);const g=j.slice((h-1)*ie,h*ie),x=j.filter(y=>y.status==="Pending").length,o=j.filter(y=>y.status==="Accepted").length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(Ce,{label:"Total",val:j.length,color:F.purple}),n.jsx(Ce,{label:"Pending",val:x,color:F.orange}),n.jsx(Ce,{label:"Accepted",val:o,color:F.green})]}),n.jsx(ht,{filters:[{type:"search",label:"Search",value:c,onChange:d,placeholder:"Auditor or Manager…"},{type:"select",label:i.col.organization,value:f,onChange:v,options:[{value:"",label:"All Organizations"},...t.map(y=>({value:y.organization_name||y.name,label:y.organization_name||y.name}))]},{type:"select",label:"Status",value:p,onChange:u,options:[{value:"all",label:"All"},{value:"Pending",label:"Pending"},{value:"Accepted",label:"Accepted"},{value:"Rejected",label:"Rejected"},{value:"Revoked",label:"Revoked"}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:m,children:i.col.number}),n.jsx("th",{style:m,children:i.col.auditor}),n.jsx("th",{style:m,children:i.col.manager}),n.jsx("th",{style:m,children:i.col.organization}),n.jsx("th",{style:m,children:i.col.functions}),n.jsx("th",{style:m,children:i.col.status}),n.jsx("th",{style:m,children:i.col.requestedOn}),n.jsx("th",{style:m,children:i.col.actions})]})}),n.jsx("tbody",{children:j.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:8,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((y,_)=>{const C=!!a&&(y.status==="Pending"||y.status==="Accepted")&&(s==="Admin"||s==="Auditor"&&y.auditor===r);return n.jsxs("tr",{className:"app-table-row",onClick:()=>l==null?void 0:l(y),style:{borderTop:"1px solid #f0f0f0",background:_%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:y.number||y.name}),n.jsx("td",{style:{padding:"10px 14px"},children:y.auditor}),n.jsx("td",{style:{padding:"10px 14px"},children:y.manager}),n.jsx("td",{style:{padding:"10px 14px"},children:y.organization||"All Organizations"}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:R1(y).map(P=>n.jsx("span",{style:{background:"#ede9fe",color:"#6d28d9",padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600},children:P1[P]||P},P))})}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{background:(Eu[y.status]||F.gray)+"22",color:Eu[y.status]||F.gray,padding:"3px 10px",borderRadius:12,fontSize:12,fontWeight:700},children:y.status})}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:A1(y.requested_on)}),n.jsx("td",{style:{padding:"8px 14px"},onClick:P=>P.stopPropagation(),children:n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("button",{onClick:()=>l==null?void 0:l(y),title:"View",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#e0f7fa",color:"#0891b2"},children:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),C&&n.jsx("button",{onClick:()=>a==null?void 0:a(y.name),title:"Revoke",style:{padding:"0 12px",height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:"none",cursor:"pointer",background:"#fee2e2",color:"#ef4444",fontSize:12,fontWeight:700},children:"Revoke"})]})})]},y.name)})})]})}),n.jsx(Ge,{page:h,total:j.length,onPageChange:S})]})}const Pu={Pending:F.orange,Accepted:F.green,Rejected:F.red,Revoked:F.gray};function L1(e){if(!e)return"—";const t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleString()}function O1({form:e,setForm:t,organizations:s,users:r,userRoleMap:l,formStatus:a,viewMode:i,onEdit:c,darkMode:d,notifCount:f,onToggleDark:v,onCountChange:p,onViewProfile:u,onSubmit:m,onBack:j,onNavigate:h,onLogout:S,user:g}){var P;const x=se(),o=k=>t(R=>({...R,...k})),y=i?{background:"#f8fafc"}:{},_=Sr(r,l,"SB Manager").map(k=>({name:k.name,label:k.full_name||k.name})),C=e.name?`${x.formTitle.viewDelegation}${e.number||e.name}`:x.formTitle.newDelegation;return n.jsxs(Ke,{title:C,activePage:"delegations",user:g,formStatus:a,statusBadge:e.status?n.jsx("span",{style:{background:(Pu[e.status]||F.gray)+"22",color:Pu[e.status]||F.gray,padding:"4px 12px",borderRadius:14,fontSize:13,fontWeight:700},children:e.status}):void 0,buttonText:x.saveDelegation,buttonColor:"#16a34a",viewMode:i,onEdit:c,darkMode:d,notifCount:f,onToggleDark:v,onCountChange:p,onViewProfile:u,onSubmit:m,onBack:j,onNavigate:h,onLogout:S,children:[n.jsxs(ae,{title:"Delegation Information",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.col.auditor}),n.jsx("input",{style:{...I,background:"#f8fafc",fontWeight:600,color:"#334155"},value:e.auditor||g.name,disabled:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[x.col.manager," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(pe,{value:e.manager,onChange:k=>o({manager:k}),items:_,placeholder:"-- Select Manager --",disabled:i})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.col.organization}),n.jsx(Ut,{value:e.organization,onChange:k=>o({organization:k}),organizations:s,placeholder:"-- All Organizations --",disabled:i})]})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[x.col.functions," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsxs("div",{style:{display:"flex",gap:20,marginTop:6,flexWrap:"wrap"},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:i?"default":"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",style:wr,checked:!!e.create_processes,disabled:i,onChange:k=>o({create_processes:k.target.checked?1:0})}),n.jsx("span",{children:"Create Processes"})]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:i?"default":"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",style:wr,checked:!!e.update_process_status,disabled:i,onChange:k=>o({update_process_status:k.target.checked?1:0})}),n.jsx("span",{children:"Update Process Status"})]})]})]}),!i&&n.jsxs("div",{style:{marginTop:14},children:[n.jsx("label",{style:z,children:"Remarks"}),n.jsx("textarea",{style:{...I,...y,minHeight:70,resize:"vertical"},value:e.remarks||"",onChange:k=>o({remarks:k.target.value}),placeholder:"Optional note for the Manager…"})]})]}),i&&(((P=e.delegation_log)==null?void 0:P.length)??0)>0&&n.jsx(ae,{title:"Audit Trail",children:n.jsx("div",{style:{overflowX:"auto"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8fafc"},children:[n.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Action"}),n.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Actor"}),n.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Timestamp"}),n.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Remarks"})]})}),n.jsx("tbody",{children:(e.delegation_log||[]).map((k,R)=>n.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[n.jsx("td",{style:{padding:"8px 12px",fontWeight:600,color:"#334155"},children:k.action}),n.jsx("td",{style:{padding:"8px 12px",color:"#334155"},children:k.actor}),n.jsx("td",{style:{padding:"8px 12px",color:"#64748b"},children:L1(k.timestamp)}),n.jsx("td",{style:{padding:"8px 12px",color:"#64748b"},children:k.remarks||"—"})]},k.name||R))})]})})})]})}const Au={process:"processes-form",order:"orders-form",incident:"incidents-form",idea:"ideas-form"},Ur={process:F.blue,order:F.purple,incident:F.red,idea:F.green,delegation:F.orange},Ru={process:"🔄",order:"📦",incident:"🚨",idea:"💡",delegation:"🤝"};function Fr(e,t){const s=e.replace("#",""),r=parseInt(s.substring(0,2),16),l=parseInt(s.substring(2,4),16),a=parseInt(s.substring(4,6),16);return`rgba(${r}, ${l}, ${a}, ${t})`}function N1({onNavigate:e,onRefresh:t}){const s=se(),[r,l]=w.useState([]),[a,i]=w.useState(!0),[c,d]=w.useState(""),[f,v]=w.useState(""),p=()=>Fy().then(g=>{l(g),i(!1)});w.useEffect(()=>{p()},[]);const u=r.filter(g=>g.requires_action),m=r.filter(g=>!g.requires_action),j={};for(const g of r)j[g.type]=(j[g.type]||0)+1;const h=async(g,x)=>{d(g),v("");try{await Hy(g,x),await p(),t==null||t()}catch{v(g)}d("")};function S(g,x,o){return x.length===0?null:n.jsxs("div",{style:{marginBottom:28},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:14},children:[n.jsx("span",{style:{fontSize:12,fontWeight:800,letterSpacing:.6,textTransform:"uppercase",color:o?F.accent:"#8a8fa3"},children:g}),n.jsx("span",{style:{fontSize:11,fontWeight:700,minWidth:22,textAlign:"center",padding:"2px 7px",borderRadius:999,color:o?"white":"#6b7280",background:o?F.accent:"#e9eaf2"},children:x.length}),n.jsx("div",{style:{flex:1,height:1,background:"linear-gradient(90deg, #e6e7f0, transparent)"}})]}),n.jsx("div",{className:"inbox-card-grid",children:x.map((y,_)=>{const C=y.type!=="delegation",P=Ur[y.type]||F.gray;return n.jsxs("div",{className:"inbox-card",onClick:C?()=>e(Au[y.type],y.name):void 0,style:{borderTop:`3px solid ${P}`,cursor:C?"pointer":"default"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:14},children:[n.jsx("div",{style:{width:38,height:38,borderRadius:12,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:17,background:Fr(P,.14)},children:Ru[y.type]||"📌"}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[n.jsx("span",{style:{fontWeight:700,fontSize:13,color:P,letterSpacing:.3},children:y.number}),y.requires_action&&n.jsx("span",{style:{fontSize:10,fontWeight:700,color:F.red,background:Fr(F.red,.12),padding:"1px 7px",borderRadius:999,textTransform:"uppercase",letterSpacing:.4},children:"Action"})]}),n.jsx("div",{className:"inbox-card-title",style:{fontSize:14,fontWeight:600,marginTop:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y.title}),n.jsxs("div",{className:"inbox-card-meta",style:{marginTop:5,fontSize:12},children:[y.action,y.organization&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{opacity:.5},children:" · "}),y.organization]}),y.date&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{opacity:.5},children:" · "}),y.date]})]}),f===y.name&&n.jsx("div",{style:{marginTop:6,fontSize:12,color:F.red,fontWeight:600},children:"Failed to respond — please try again."})]})]}),y.type==="delegation"?n.jsxs("div",{style:{display:"flex",gap:8,marginTop:14},children:[n.jsx("button",{onClick:()=>h(y.name,"Accepted"),disabled:c===y.name,style:{flex:1,padding:"8px 0",borderRadius:9,border:"none",background:F.green,color:"white",fontWeight:700,fontSize:13,cursor:c===y.name?"wait":"pointer",opacity:c===y.name?.6:1},children:"Accept"}),n.jsx("button",{onClick:()=>h(y.name,"Rejected"),disabled:c===y.name,style:{flex:1,padding:"8px 0",borderRadius:9,border:"none",background:F.red,color:"white",fontWeight:700,fontSize:13,cursor:c===y.name?"wait":"pointer",opacity:c===y.name?.6:1},children:"Reject"})]}):n.jsx("button",{onClick:k=>{k.stopPropagation(),e(Au[y.type],y.name)},style:{marginTop:14,width:"100%",padding:"8px 0",borderRadius:9,border:"none",background:y.requires_action?P:Fr(P,.12),color:y.requires_action?"white":P,fontWeight:700,fontSize:13,cursor:"pointer"},children:y.requires_action?"Act Now →":s.view})]},_)})})]})}return n.jsxs("div",{style:{maxWidth:1040,margin:"0 auto"},children:[!a&&r.length>0&&n.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap",marginBottom:24},children:Object.entries(j).map(([g,x])=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"6px 12px 6px 9px",borderRadius:999,background:Fr(Ur[g]||F.gray,.1),border:`1px solid ${Fr(Ur[g]||F.gray,.25)}`},children:[n.jsx("span",{style:{fontSize:13},children:Ru[g]}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:Ur[g]||F.gray,textTransform:"capitalize"},children:g}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:Ur[g]||F.gray,opacity:.7},children:x})]},g))}),a&&n.jsx("p",{style:{color:"#888"},children:s.loading}),!a&&r.length===0&&n.jsxs("div",{className:"inbox-empty",children:[n.jsx("div",{style:{fontSize:46,marginBottom:10},children:"✨"}),n.jsx("p",{style:{fontSize:16,fontWeight:600},children:s.inbox.noMessages}),n.jsx("p",{style:{fontSize:13,marginTop:4,opacity:.7},children:"You're all caught up — nothing needs your attention right now."})]}),!a&&S("Needs Action",u,!0),!a&&S("Informational",m,!1)]})}const W1=[{id:"process_status_history",label:"Process Status History",description:"Full cycle-by-cycle status for any process, with actor, date, and escalation level",roles:["Admin","Auditor","Owner"]},{id:"order_tracker",label:"Outsourcing Order Tracker",description:"Stage-by-stage progress for all orders, with cost variance",roles:["Admin","Auditor","Manager","Owner"]},{id:"incident_register",label:"Incident Register",description:"All incidents with type, status, assigned manager, and resolution timeline",roles:["Admin","Auditor","Manager","Owner"]},{id:"ideas_pipeline",label:"Ideas Pipeline",description:"All ideas by status and type, conversion rate to Study",roles:["Admin","Auditor","Manager","Owner"]},{id:"department_performance",label:"Department Performance",description:"Aggregate Pass/Fail/Unknown per department per cycle",roles:["Admin","Auditor","Owner"]},{id:"escalation_report",label:"Escalation Report",description:"All Level 2 escalations with entity type and current status",roles:["Admin","Owner"]},{id:"cost_summary",label:"Cost Summary",description:"Total cost per order, per department — budget vs actual",roles:["Admin","Owner"]},{id:"process_year_end",label:"Process Year-End Summary",description:"Full status history and accumulated cost per process for a given year (Rule 11.1-6)",roles:["Admin","Auditor","Owner"],extraFilter:"year"},{id:"user_activity_log",label:"User Activity Log",description:"All actions by user with timestamp and entity reference — Admin only",roles:["Admin"]}],Ld={number:"Number",title:"Title",organization:"Organization",department:"Department",status:"Status",actor:"Actor",cycle:"Cycle",date_start:"Start Date",date_end:"End Date",escalation_level:"Escalation",stage:"Stage",completion_pct:"Completion %",budget:"Budget",starting_date:"Start",ending_date:"End",date:"Date",assigned_to:"Assigned To",type:"Type",entity_type:"Entity",pass_count:"Pass",fail_count:"Fail",unknown_count:"Unknown",total:"Total",cycle_type:"Cycle Type",cost_per_cycle:"Cost/Cycle",total_cycles:"Total Cycles",total_cost:"Total Cost",timestamp:"Timestamp",user:"User",entity_name:"Entity",changes:"Fields Changed"};function B1(e,t){const s=e.map(l=>Ld[l]||l).join(","),r=t.map(l=>e.map(a=>`"${l[a]??""}"`).join(",")).join(`
|
||
`);return s+`
|
||
`+r}function $1(e,t){const s=new Blob([e],{type:"text/csv"}),r=URL.createObjectURL(s),l=document.createElement("a");l.href=r,l.download=t,l.click(),URL.revokeObjectURL(r)}const Du=e=>String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");function U1(e,t,s){const r=e.map(f=>`<th style="background:#4f46e5;color:#fff;padding:6px 10px;text-align:left">${Du(Ld[f]||f)}</th>`).join(""),l=t.map(f=>`<tr>${e.map(v=>`<td style="padding:4px 10px;border-bottom:1px solid #ddd">${Du(f[v])}</td>`).join("")}</tr>`).join(""),a=`<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel"><head><meta charset="UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>Report</x:Name><x:WorksheetOptions/></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table><thead><tr>${r}</tr></thead><tbody>${l}</tbody></table></body></html>`,i=new Blob(["\uFEFF"+a],{type:"application/vnd.ms-excel"}),c=URL.createObjectURL(i),d=document.createElement("a");d.href=c,d.download=s,d.click(),URL.revokeObjectURL(c)}const ih="report-print-area",Ui="report-print-portal";function F1(){const e=document.getElementById(ih);if(!e)return;const t=document.createElement("div");t.id=Ui,t.innerHTML=e.innerHTML,document.body.appendChild(t);const s=document.createElement("style");s.id="report-print-style",s.textContent=`
|
||
#${Ui} { display: none; }
|
||
@media print {
|
||
#root { display: none !important; }
|
||
#${Ui} { display: block !important; }
|
||
}
|
||
`,document.head.appendChild(s);const r=()=>{t.remove(),s.remove(),window.removeEventListener("afterprint",r)};window.addEventListener("afterprint",r),window.print()}const Lu={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",minWidth:180},Fi={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white"};function M1({organizations:e,userRole:t}){const s=se(),r=W1.filter(R=>R.roles.includes(t)),[l,a]=w.useState(""),[i,c]=w.useState(""),[d,f]=w.useState(""),[v,p]=w.useState(""),[u,m]=w.useState(String(new Date().getFullYear())),[j,h]=w.useState([]),[S,g]=w.useState([]),[x,o]=w.useState(!1),[y,_]=w.useState(""),C=r.find(R=>R.id===l);async function P(){if(l){o(!0),_(""),g([]),h([]);try{const R={};i&&(R.organization=i),d&&(R.from_date=d),v&&(R.to_date=v),(C==null?void 0:C.extraFilter)==="year"&&u&&(R.year=u);const $=await Uy(l,R);h($.columns||[]),g($.rows||[])}catch(R){_(R.message||"Error running report")}finally{o(!1)}}}const k=(C==null?void 0:C.label)||l;return n.jsxs("div",{children:[n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12,marginBottom:20},children:r.map(R=>n.jsxs("div",{onClick:()=>a(R.id),style:{background:l===R.id?"#ebf5fb":"white",border:l===R.id?`2px solid ${F.accent}`:"2px solid transparent",borderRadius:10,padding:"14px 16px",cursor:"pointer",boxShadow:"0 1px 4px rgba(0,0,0,0.07)"},children:[n.jsx("div",{style:{fontWeight:700,fontSize:14,color:"#1a2332",marginBottom:4},children:R.label}),n.jsx("div",{style:{fontSize:12,color:"#888"},children:R.description})]},R.id))}),n.jsx("div",{style:{background:"white",borderRadius:12,padding:20,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:20},children:n.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",alignItems:"flex-end"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"REPORT"}),n.jsxs("select",{style:Lu,value:l,onChange:R=>a(R.target.value),children:[n.jsx("option",{value:"",children:"-- Select Report --"}),r.map(R=>n.jsx("option",{value:R.id,children:R.label},R.id))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"ORGANIZATION"}),n.jsxs("select",{style:Lu,value:i,onChange:R=>c(R.target.value),children:[n.jsx("option",{value:"",children:s.filter.allOrgs}),e.map(R=>n.jsx("option",{value:R.name,children:R.organization_name||R.name},R.name))]})]}),(C==null?void 0:C.extraFilter)==="year"?n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"YEAR"}),n.jsx("input",{type:"number",style:{...Fi,width:90},value:u,onChange:R=>m(R.target.value),min:2020,max:2099})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"FROM"}),n.jsx(xe,{value:d,onChange:f,style:Fi})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"TO"}),n.jsx(xe,{value:v,onChange:p,style:Fi})]})]}),n.jsx("button",{onClick:P,disabled:!l||x,style:{padding:"9px 20px",borderRadius:8,border:"none",background:F.accent,color:"white",fontWeight:700,fontSize:13,cursor:l?"pointer":"not-allowed",opacity:l?1:.5},children:x?s.loading:s.reports.generate}),S.length>0&&n.jsx("button",{onClick:()=>$1(B1(j,S),`${l}.csv`),style:{padding:"9px 20px",borderRadius:8,border:"1px solid #27ae60",background:"white",color:"#27ae60",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Export CSV"}),S.length>0&&n.jsx("button",{onClick:()=>U1(j,S,`${l}.xls`),style:{padding:"9px 20px",borderRadius:8,border:"1px solid #107c41",background:"white",color:"#107c41",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Export Excel"}),S.length>0&&n.jsx("button",{onClick:F1,style:{padding:"9px 20px",borderRadius:8,border:"1px solid #888",background:"white",color:"#555",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Print / PDF"})]})}),y&&n.jsx("div",{style:{color:"#e74c3c",marginBottom:16},children:y}),S.length>0&&n.jsxs("div",{id:ih,style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto"},children:[n.jsxs("div",{style:{padding:"14px 18px",borderBottom:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsx("span",{style:{fontWeight:700,color:"#333"},children:k}),n.jsxs("span",{style:{fontSize:12,color:"#888"},children:[S.length," rows"]})]}),n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa"},children:j.map(R=>n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700,whiteSpace:"nowrap"},children:Ld[R]||R.replace(/_/g," ").toUpperCase()},R))})}),n.jsx("tbody",{children:S.map((R,$)=>n.jsx("tr",{style:{borderTop:"1px solid #f0f0f0",background:$%2===0?"white":"#fafafa"},children:j.map(Z=>n.jsx("td",{style:{padding:"10px 14px",color:"#333"},children:R[Z]!=null?String(R[Z]):"—"},Z))},$))})]})]}),!x&&S.length===0&&l&&!y&&n.jsx("div",{style:{background:"white",borderRadius:12,padding:40,textAlign:"center",color:"#aaa",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:"Select a report and click Run Report to see results."}),r.length===0&&n.jsx("div",{style:{background:"white",borderRadius:12,padding:40,textAlign:"center",color:"#aaa",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:"No reports are available for your role."})]})}const Tl=()=>new Date().toISOString().split("T")[0],Od=()=>new Date(Date.now()+30*24*60*60*1e3).toISOString().split("T")[0],H1=()=>new Date().toTimeString().slice(0,5),xn=()=>({name:"",number:"",title:"",organization:"",type:"",incident_class:"",incident_field:"",date:Tl(),time:H1(),management:"",department:"",section_field:"",branch:"",assigned_to:"",status:"",description:"",summary:"",workflow_state:"New",hses_field:"",priority:"",economy_class:"",product_relation:0,repeated:0,entity_scope:"",solution:"",cost:0,auditor_comment:""}),nn=()=>({name:"",number:"",title:"",organization:"",type:"",management:"",department:"",section_field:"",branch:"",current_condition:"",proposed_condition:"",status:"",assigned_to:"",workflow_state:"New",idea_class:"",hses_field:"",date:Tl(),priority:"",economy_class:"",product_relation:0,repeated:0,entity_scope:"",solution:"",cost:0,auditor_comment:"",sb_order:""}),sn=()=>({name:"",number:"",title:"",organization:"",type:"Buy L",management:"",department:"",section_field:"",branch:"",starting_date:Tl(),ending_date:Od(),assigned_to:"",actor:"",status:"",budget:0,actual_cost:0,currency:"SAR",description:"",notes:"",cycle:"",stage:1,completion_pct:0,escalation_level:0,workflow_state:"Draft",planned:0,priority:"",product_relation:0,entity_scope:"",economy_class:"",hses_field:"",auditor_comment:"",sb_idea:"",cycle_type:"Normal",long_cycle_date_1:"",long_cycle_date_2:"",long_cycle_date_3:"",long_cycle_date_4:""}),Vl=()=>({name:"",title:"",date_start:Tl(),date_end:Od(),number:"",status:"",cycle_type:"Normal",organization:"",type:"",management:"",department:"",section_field:"",branch:"",progress_indicators:[],cycle:"",actor:"",escalation_level:0,workflow_state:"",chain_location:"",economy_class:"",impact_level:"",product_relation:0,entity_scope:"",hses_field:"",kpi_name:"",kpi_type:"",kpi_measure:"",cost_per_cycle:0,auditor_comment:""}),Us=()=>({name:"",organization_name:"",type:"Government",city:"",contact_email:"",creation_date:new Date().toISOString().slice(0,10),is_active:1,acronym:"",incident_triage_window_days:3,incident_resolution_window_days:5}),os=()=>({name:"",organization:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ds=()=>({name:"",custom_organization:"",department_name:"",custom_management:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),cs=()=>({name:"",organization:"",branch:"",management:"",department:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),Fs=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ms=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Hs=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Gs=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ks=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Qs=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ys=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Xs=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ea=()=>({name:"",first_name:"",full_name:"",email:"",enabled:1,creation:"",username:"",mobile_no:"",custom_organization:"",custom_management:"",custom_department:"",custom_branch:"",custom_number:"",custom_category:""}),us=()=>({name:"",name1:"",organization:"",frequency:"Monthly",status:"Active",start_date:Tl(),end_date:Od(),update_window_days:2}),ps=()=>({name:"",organization:"",period:"",revenue_growth:0,net_profit:0,cash_flow:0,strategic_goal_pct:0,customer_satisfaction:0,employee_turnover_pct:0,open_safety_incidents:0,compliance_score:0}),Mr=()=>({name:"",number:"",auditor:"",manager:"",organization:"",create_processes:0,update_process_status:0,status:"Pending",requested_on:"",remarks:""}),G1=new Set(["incidents","incidents-form","ideas","ideas-form"]),K1=new Set(["orders","orders-form","incidents","incidents-form","ideas","ideas-form"]),Q1=new Set(qf.flatMap(({id:e})=>[e,`${e}-form`])),Y1=new Set(["Admin","Owner","Auditor","Manager"]),X1=new Set(["Admin","Owner","Auditor","Manager"]),q1=new Set(["Admin","Auditor","Manager"]);function J1({user:e,onLogout:t,darkMode:s,onToggleDark:r}){const l=se(),a=e.role,i=Y1.has(a),c=X1.has(a),d=q1.has(a),f=b=>b==="users"||b==="users-form"?a==="Admin":a==="Admin"||a==="Auditor"?!0:a==="Owner"||a==="XAuditor"?!1:a==="Manager"?!!(K1.has(b)||(b==="processes"||b==="processes-form")&&Bd.includes("create_processes")):G1.has(b),v=b=>a==="Employee"&&!!b&&b!=="New",p=i?"dashboard":"inbox",u=b=>b==="dashboard"?i:b==="reports"?c:b==="delegations"||b==="delegations-form"?d:b==="users"||b==="users-form"?a==="Admin":Q1.has(b)?a==="Admin"||a==="Auditor":!0,[m,j]=w.useState(()=>{const b=t0(bu());return b&&u(b)?b:p});w.useEffect(()=>{const b=n0(m);window.location.hash!==b&&window.history.pushState(null,"",b)},[m]),w.useEffect(()=>{const b=()=>{const H=bu();j(H&&u(H)?H:p)};return window.addEventListener("popstate",b),()=>window.removeEventListener("popstate",b)},[]);const h=e.custom_organization||"",[S,g]=w.useState(""),[x,o]=w.useState("");w.useEffect(()=>{if(!x)return;const b=setTimeout(()=>o(""),0);return()=>clearTimeout(b)},[x]);const y=(b,H)=>{o(H),j(b)},[_,C]=w.useState(0),[P,k]=w.useState([]),[R,$]=w.useState([]),[Z,de]=w.useState([]),[D,T]=w.useState([]),[E,B]=w.useState([]),[M,A]=w.useState([]),[K,Y]=w.useState([]),[ee,V]=w.useState([]),[ze,$e]=w.useState([]),[Oe,ge]=w.useState([]),[Je,Q]=w.useState([]),[ne,gt]=w.useState([]),[re,lt]=w.useState([]),[jt,Qe]=w.useState([]),[U,Te]=w.useState([]),[Ze,W]=w.useState([]),[je,O]=w.useState([]),[le,X]=w.useState([]),[Vn,ii]=w.useState([]),[dn,Il]=w.useState({}),[N,Ct]=w.useState([]),[cn,zn]=w.useState([]),[Nd,oh]=w.useState([]),[Wd,dh]=w.useState([]),[Bd,ch]=w.useState([]),[$d,uh]=w.useState({}),[oi,ph]=w.useState([]),El=()=>({name:"",company_name:"",acronym:"",code:"",status:"Active",owner_user:"",notes:""}),[Ud,Is]=w.useState(El()),[we,fe]=w.useState(!0),[Ue,oe]=w.useState("idle"),[Fe,te]=w.useState(!1),[Fd,Md]=w.useState(!1),[Pl,Hd]=w.useState(null),[fh,hh]=w.useState(()=>localStorage.getItem("sb_sidebar")==="1"),gh=()=>hh(b=>{const H=!b;return localStorage.setItem("sb_sidebar",H?"1":"0"),H}),[xh,di]=w.useState(!1);w.useEffect(()=>{di(!1)},[m]);const[un,pn]=w.useState(xn()),[fn,Zt]=w.useState(nn()),[es,Vt]=w.useState(sn()),[ts,en]=w.useState(Vl()),[Gd,Es]=w.useState(Us()),[Kd,ns]=w.useState(os()),[Qd,ss]=w.useState(ds()),[Yd,rs]=w.useState(cs()),[Xd,Ps]=w.useState(Fs()),[qd,As]=w.useState(Ms()),[Jd,Rs]=w.useState(Hs()),[Zd,Ds]=w.useState(Gs()),[Vd,Ls]=w.useState(Ks()),[ec,Os]=w.useState(Qs()),[tc,Ns]=w.useState(Ys()),[nc,Ws]=w.useState(Xs()),[Tr,Al]=w.useState(ea()),[sc,ls]=w.useState(us()),[rc,as]=w.useState(ps()),[Bs,Ir]=w.useState(Mr()),zt=async()=>{fe(!0);try{const[b,H,be,Ft,Tn,Ae,fi,ug,pg,fg,hg,gg,xg,mg,yg,vg,jg,bg,Sg,wg,_g,kg,Cg,zg,Tg,Ig,Eg]=await Promise.all([Ee(L.incidents),Ee(L.organizations),Ee(L.ideas),Ee(L.orders),Ee(L.processes),wy(),Ee(L.managements),Ee(L.departments),Ee(L.branches),Ee(L.incidentTypes),Ee(L.incidentClass),Ee(L.incidentField),Ee(L.ideaTypes),Ee(L.orderTypes),Ee(L.processTypes),Ee(L.incidentStatuses),Ee(L.ideaStatuses),Ee(L.orderStatuses),Ee(L.processStatuses),zy(),Ty(),Ee(L.cycles),Ee(L.kpiInput),Ky(),Yy(),Xy(),qy()]);k(b||[]),$(H||[]),de(be||[]),T(Ft||[]),B(Tn||[]),Ct(Ae||[]),A(fi||[]),Y(ug||[]),V(pg||[]),$e(fg||[]),ge(hg||[]),Q(gg||[]),gt(xg||[]),lt(mg||[]),Qe(yg||[]),Te(vg||[]),W(jg||[]),O(bg||[]),X(Sg||[]),ii(wg||[]),Il(_g||{}),zn(kg||[]),oh(Cg||[]),dh(zg||[]),ch(Tg||[]),uh(Ig||{}),ph(Eg||[])}catch(b){console.error("Error loading data:",b)}fe(!1)},lc=async()=>{try{const b=await fetch("/api/method/sidrah_business.api.get_notification_count",{credentials:"include",headers:{Accept:"application/json"}});if(b.ok){const H=await b.json();C(Number(H.message)||0)}}catch{}};w.useEffect(()=>{zt(),lc();const b=setInterval(lc,6e4);return()=>clearInterval(b)},[e.name]);const[dt,hn]=w.useState({isOpen:!1,doctype:"",name:"",title:"",isDeleting:!1}),Ie=(b,H,be)=>{hn({isOpen:!0,doctype:b,name:H,title:be||H,isDeleting:!1})},ac=b=>{const be={[L.incidents]:"incidents",[L.ideas]:"ideas",[L.orders]:"orders",[L.processes]:"processes",[L.organizations]:"organizations",[L.managements]:"managements",[L.departments]:"departments",[L.branches]:"branches",[L.cycles]:"cycles",[L.kpiInput]:"kpi-input",[L.incidentTypes]:"incident-types",[L.ideaTypes]:"idea-types",[L.orderTypes]:"order-types",[L.processTypes]:"process-types",[L.incidentStatuses]:"incident-statuses",[L.ideaStatuses]:"idea-statuses",[L.orderStatuses]:"order-statuses",[L.processStatuses]:"process-statuses",[L.groupCompanies]:"group-companies"}[b];be&&j(be)},ic=async b=>{hn(H=>({...H,isDeleting:!0}));try{const H=dt.doctype;await No(dt.doctype,dt.name,b,!1),hn(be=>({...be,isOpen:!1,isDeleting:!1})),await zt(),m.endsWith("-form")&&ac(H)}catch(H){console.error("Delete error:",H),alert((H==null?void 0:H.message)||"Delete failed. Please try again."),hn(be=>({...be,isDeleting:!1}))}},oc=async b=>{hn(H=>({...H,isDeleting:!0}));try{const H=dt.doctype;await No(dt.doctype,dt.name,b,!0),hn(be=>({...be,isOpen:!1,isDeleting:!1})),await zt(),m.endsWith("-form")&&ac(H)}catch(H){console.error("Permanent delete error:",H),alert((H==null?void 0:H.message)||"Permanent delete failed. Please try again."),hn(be=>({...be,isDeleting:!1}))}},Er=async(b,H)=>{if(window.confirm(l.rtl?"هل أنت متأكد من استعادة هذا السجل؟":"Are you sure you want to restore this record?")){fe(!0);try{await Sy(b,H),alert(l.restoredOk||"Record restored successfully!"),await zt()}catch(be){console.error("Restore error:",be),alert((be==null?void 0:be.message)||"Restore failed. Please try again.")}fe(!1)}},mh=async b=>{try{await Ay(b),await zt()}catch(H){console.error("Disable user error:",H)}},yh=async b=>{te(!0),fe(!0);try{const H=await Tt(L.incidents,b.name);pn({...xn(),...H})}catch{pn({...xn(),...b})}j("incidents-form"),fe(!1)},vh=async b=>{te(!0),fe(!0);try{const H=await Tt(L.ideas,b.name);Zt({...nn(),...H})}catch{Zt({...nn(),...b})}j("ideas-form"),fe(!1)},jh=async b=>{te(!0),fe(!0);try{const H=await Tt(L.orders,b.name);Vt({...sn(),...H})}catch{Vt({...sn(),...b})}j("orders-form"),fe(!1)},bh=async b=>{te(!0),fe(!0);try{const H=await Yr(b.name);en({...H,progress_indicators:H.progress_indicators||[],cycle_logs:H.cycle_logs||[]}),j("processes-form")}catch{en({...b,progress_indicators:b.progress_indicators||[]}),j("processes-form")}fe(!1)},Sh=b=>ve(L.organizations,b,Es,Us(),"organizations-form",!0),wh=b=>{te(!0),Is(b),j("group-companies-form")},_h=b=>{te(!1),Is(b),j("group-companies-form")},kh=async b=>{te(!0),fe(!0);try{const H=await Tt(L.managements,b.name);ns({...os(),...H})}catch{ns({...os(),...b})}j("managements-form"),fe(!1)},Ch=async b=>{te(!0),fe(!0);try{const H=await Tt(L.departments,b.name);ss({...ds(),...H})}catch{ss({...ds(),...b})}j("departments-form"),fe(!1)},zh=async b=>{te(!0),fe(!0);try{const H=await Tt(L.branches,b.name);rs({...cs(),...H})}catch{rs({...cs(),...b})}j("branches-form"),fe(!1)},Th=async b=>{te(!0),fe(!0);try{const H=await Tt(L.cycles,b.name);ls({...us(),...H})}catch{ls({...us(),...b})}j("cycles-form"),fe(!1)},Ih=async b=>{te(!0),fe(!0);try{const H=await Tt(L.kpiInput,b.name);as({...ps(),...H})}catch{as({...ps(),...b})}j("kpi-input-form"),fe(!1)},Ve=async(b,H,be,Ft,Tn)=>{oe("loading");try{if(H.name)await Ba(b,H.name,H),oe("success"),zt(),setTimeout(()=>{oe("idle"),j(Ft)},1500);else if(Tn){const Ae=await $i(b,H);Tn((Ae==null?void 0:Ae.data)??Ae),oe("success"),zt(),setTimeout(()=>oe("idle"),1500)}else await $i(b,H),be(),oe("success"),zt(),setTimeout(()=>{oe("idle"),j(Ft)},1500)}catch(Ae){console.error("Submit error:",Ae),oe(Ae instanceof Error?Ae.message:"Error saving. Please try again.")}},Ne=async()=>{await ky(),t()},ve=async(b,H,be,Ft,Tn,Ae)=>{te(Ae),fe(!0);try{const fi=await Tt(b,H.name);be({...Ft,...fi})}catch{be({...Ft,...H})}j(Tn),fe(!1)},Eh=b=>ve(L.incidents,b,pn,xn(),"incidents-form",!1),Ph=b=>ve(L.ideas,b,Zt,nn(),"ideas-form",!1),Ah=b=>ve(L.orders,b,Vt,sn(),"orders-form",!1),Rh=b=>{te(!1),fe(!0),Yr(b.name).then(H=>{en({...H,progress_indicators:H.progress_indicators||[],cycle_logs:H.cycle_logs||[]})}).catch(()=>{en({...b,progress_indicators:b.progress_indicators||[]})}).finally(()=>{j("processes-form"),fe(!1)})},Dh=b=>ve(L.organizations,b,Es,Us(),"organizations-form",!1),Lh=b=>ve(L.managements,b,ns,os(),"managements-form",!1),Oh=b=>ve(L.departments,b,ss,ds(),"departments-form",!1),Nh=b=>ve(L.branches,b,rs,cs(),"branches-form",!1),Wh=b=>ve(L.cycles,b,ls,us(),"cycles-form",!1),Bh=b=>ve(L.kpiInput,b,as,ps(),"kpi-input-form",!1),$h=async b=>{te(!0),fe(!0);try{const H=await Qy(b.name);Ir({...Mr(),...H})}catch{Ir({...Mr(),...b})}j("delegations-form"),fe(!1)},Uh=async()=>{oe("loading");try{const b=[];Bs.create_processes&&b.push("create_processes"),Bs.update_process_status&&b.push("update_process_status"),await My(Bs.manager,b,Bs.organization,Bs.remarks),Ir(Mr()),oe("success"),zt(),setTimeout(()=>{oe("idle"),j("delegations")},1500)}catch(b){console.error("Delegation submit error:",b),oe(b instanceof Error?b.message:"Error saving. Please try again.")}},Fh=async b=>{if(window.confirm(l.rtl?"هل أنت متأكد من إلغاء هذا التفويض؟":"Are you sure you want to revoke this delegation?")){fe(!0);try{await Gy(b),await zt()}catch(H){console.error("Revoke delegation error:",H),alert(H instanceof Error?H.message:"Revoke failed. Please try again.")}fe(!1)}},Mh=b=>ve(L.incidentTypes,b,Ps,Fs(),"incident-types-form",!0),Hh=b=>ve(L.incidentTypes,b,Ps,Fs(),"incident-types-form",!1),Gh=b=>ve(L.ideaTypes,b,As,Ms(),"idea-types-form",!0),Kh=b=>ve(L.ideaTypes,b,As,Ms(),"idea-types-form",!1),Qh=b=>ve(L.orderTypes,b,Rs,Hs(),"order-types-form",!0),Yh=b=>ve(L.orderTypes,b,Rs,Hs(),"order-types-form",!1),Xh=b=>ve(L.processTypes,b,Ds,Gs(),"process-types-form",!0),qh=b=>ve(L.processTypes,b,Ds,Gs(),"process-types-form",!1),Jh=b=>ve(L.incidentStatuses,b,Ls,Ks(),"incident-statuses-form",!0),Zh=b=>ve(L.incidentStatuses,b,Ls,Ks(),"incident-statuses-form",!1),Vh=b=>ve(L.ideaStatuses,b,Os,Qs(),"idea-statuses-form",!0),eg=b=>ve(L.ideaStatuses,b,Os,Qs(),"idea-statuses-form",!1),tg=b=>ve(L.orderStatuses,b,Ns,Ys(),"order-statuses-form",!0),ng=b=>ve(L.orderStatuses,b,Ns,Ys(),"order-statuses-form",!1),sg=b=>ve(L.processStatuses,b,Ws,Xs(),"process-statuses-form",!0),rg=b=>ve(L.processStatuses,b,Ws,Xs(),"process-statuses-form",!1),lg=async b=>{Hd(b),j("profile")},ag=b=>{te(!1),Md(!1),Al({...ea(),...b}),j("users-form")},ig=async()=>{oe("loading");try{if(!Tr.name){const H=await $i("User",{...Tr,send_welcome_email:0,user_type:"System User"});Al({...ea(),...Tr,...(H==null?void 0:H.data)??H}),te(!0),oe("success"),zt(),setTimeout(()=>oe("idle"),1500)}else{const{name:H,email:be,creation:Ft,full_name:Tn,...Ae}=Tr;await Ba("User",H,Ae),oe("success"),zt(),setTimeout(()=>{oe("idle"),j("users")},1500)}}catch(b){console.error("User submit error:",b),oe(b instanceof Error?b.message:"Error saving. Please try again.")}},We=()=>{const b=Vn.find(H=>H.name===e.name||H.username===e.name);Hd(b||{name:e.name,full_name:e.full_name,email:e.name,enabled:1}),j("profile")},ci=(b,H)=>{if(H){const Ft={"processes-form":L.processes,"orders-form":L.orders,"incidents-form":L.incidents,"ideas-form":L.ideas}[b];if(Ft){te(!0),fe(!0),(b==="processes-form"?Yr(H).then(Ae=>({...Ae,progress_indicators:Ae.progress_indicators||[],cycle_logs:Ae.cycle_logs||[]})):Tt(Ft,H)).then(Ae=>{b==="processes-form"?en(Ae):b==="orders-form"?Vt({...sn(),...Ae}):b==="incidents-form"?pn({...xn(),...Ae}):b==="ideas-form"&&Zt({...nn(),...Ae}),j(b),fe(!1)}).catch(()=>{j(b),fe(!1)});return}}j(b)},Me=b=>n.jsxs(n.Fragment,{children:[b,n.jsx(vu,{isOpen:dt.isOpen,doctype:dt.doctype,docname:dt.name,docTitle:dt.title,isAdmin:a==="Admin"||e.name==="Administrator",isDeleting:dt.isDeleting,onClose:()=>hn(H=>({...H,isOpen:!1})),onConfirmSoftDelete:ic,onConfirmPermanentDelete:oc})]});if(m==="incidents-form")return Me(n.jsx(v0,{incForm:un,setIncForm:pn,organizations:R,managements:M,departments:K,branches:ee,incidentTypes:ze,incidentClasses:Oe,incidentFields:Je,incidentStatuses:U,users:N,userRoleMap:dn,formStatus:Ue,viewMode:Fe||!f("incidents-form")||v(un.workflow_state),canModify:f("incidents-form"),onEdit:f("incidents-form")&&!v(un.workflow_state)&&!Nn("incident",un.workflow_state)?()=>te(!1):void 0,onDelete:f("incidents-form")?b=>Ie(L.incidents,b,un.title||un.number):void 0,onRestore:a==="Admin"?b=>Er(L.incidents,b):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,userRole:a,onSubmit:()=>Ve(L.incidents,un,()=>pn(xn()),"incidents",b=>pn({...xn(),...b})),onBack:()=>{j("incidents"),oe("idle")},onNavigate:j,onLogout:Ne,user:e,onRefresh:async()=>{if(un.name){const b=await Tt(L.incidents,un.name).catch(()=>null);b&&pn({...xn(),...b})}Ee(L.incidents).then(b=>k(b||[])).catch(()=>{})}}));if(m==="ideas-form")return Me(n.jsx(w0,{ideaForm:fn,setIdeaForm:Zt,organizations:R,managements:M,departments:K,branches:ee,ideaTypes:ne,ideaStatuses:Ze,users:N,userRoleMap:dn,formStatus:Ue,viewMode:Fe||!f("ideas-form")||v(fn.workflow_state),canModify:f("ideas-form"),onEdit:f("ideas-form")&&!v(fn.workflow_state)&&!Nn("idea",fn.workflow_state)?()=>te(!1):void 0,onDelete:f("ideas-form")?b=>Ie(L.ideas,b,fn.title||fn.number):void 0,onRestore:a==="Admin"?b=>Er(L.ideas,b):void 0,onNavigateToOrder:b=>ve(L.orders,{name:b},Vt,sn(),"orders-form",!0),darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,userRole:a,onSubmit:()=>Ve(L.ideas,fn,()=>Zt(nn()),"ideas",b=>Zt({...nn(),...b})),onBack:()=>{j("ideas"),oe("idle")},onNavigate:j,onLogout:Ne,user:e,onRefresh:async()=>{if(fn.name){const b=await Tt(L.ideas,fn.name).catch(()=>null);b&&Zt({...nn(),...b})}Ee(L.ideas).then(b=>de(b||[])).catch(()=>{})}}));if(m==="orders-form")return Me(n.jsx(T0,{orderForm:es,setOrderForm:Vt,organizations:R,managements:M,departments:K,branches:ee,orderTypes:re,orderStatuses:je,cycles:cn,users:N,userRoleMap:dn,formStatus:Ue,viewMode:Fe||!f("orders-form"),canModify:f("orders-form"),onEdit:f("orders-form")&&!Nn("order",es.workflow_state)?()=>te(!1):void 0,onDelete:f("orders-form")?b=>Ie(L.orders,b,es.title||es.number):void 0,onRestore:a==="Admin"?b=>Er(L.orders,b):void 0,onNavigateToIdea:b=>ve(L.ideas,{name:b},Zt,nn(),"ideas-form",!0),darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,currentUser:e.name,userRole:a,onSubmit:()=>Ve(L.orders,es,()=>Vt(sn()),"orders",b=>Vt({...sn(),...b})),onBack:()=>{j("orders"),oe("idle")},onNavigate:j,onLogout:Ne,user:e,onRefresh:async()=>{if(es.name){const b=await Tt(L.orders,es.name).catch(()=>null);b&&Vt({...sn(),...b})}Ee(L.orders).then(b=>T(b||[])).catch(()=>{})}}));if(m==="processes-form")return Me(n.jsx(R0,{processForm:ts,setProcessForm:en,organizations:R,managements:M,departments:K,branches:ee,processTypes:jt,processStatuses:le,cycles:cn,users:N,userRoleMap:dn,formStatus:Ue,viewMode:Fe||!f("processes-form"),canModify:f("processes-form"),onEdit:f("processes-form")&&!Nn("process",ts.workflow_state)?()=>te(!1):void 0,onDelete:f("processes-form")?b=>Ie(L.processes,b,ts.title||ts.number):void 0,onRestore:a==="Admin"?b=>Er(L.processes,b):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,userRole:e.role,delegatedFunctions:Bd,delegatedOrgs:$d.create_processes,onRefreshProcess:async()=>{if(ts.name)try{const b=await Yr(ts.name);en({...b,progress_indicators:b.progress_indicators||[],cycle_logs:b.cycle_logs||[]})}catch{}Ee(L.processes).then(b=>B(b||[])).catch(()=>{})},onSubmit:()=>Ve(L.processes,ts,()=>en(Vl()),"processes",b=>en({...Vl(),...b,progress_indicators:b.progress_indicators||[],cycle_logs:b.cycle_logs||[]})),onBack:()=>{j("processes"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));if(m==="organizations-form")return Me(n.jsx(B0,{orgForm:Gd,setOrgForm:Es,groupCompanies:oi,formStatus:Ue,viewMode:Fe||!f("organizations-form"),onEdit:f("organizations-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,onSubmit:()=>Ve(L.organizations,Gd,()=>Es(Us()),"organizations",b=>{Es({...Us(),...b}),te(!0)}),onBack:()=>{j("organizations"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));if(m==="managements-form")return Me(n.jsx(H0,{form:Kd,setForm:ns,organizations:R,formStatus:Ue,viewMode:Fe||!f("managements-form"),onEdit:f("managements-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,onSubmit:()=>Ve(L.managements,Kd,()=>ns(os()),"managements",b=>{ns({...os(),...b}),te(!0)}),onBack:()=>{j("managements"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));if(m==="departments-form")return Me(n.jsx(Q0,{form:Qd,setForm:ss,organizations:R,managements:M,formStatus:Ue,viewMode:Fe||!f("departments-form"),onEdit:f("departments-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,onSubmit:()=>Ve(L.departments,Qd,()=>ss(ds()),"departments",b=>{ss({...ds(),...b}),te(!0)}),onBack:()=>{j("departments"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));if(m==="branches-form")return Me(n.jsx(q0,{form:Yd,setForm:rs,organizations:R,managements:M,departments:K,formStatus:Ue,viewMode:Fe||!f("branches-form"),onEdit:f("branches-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,onSubmit:()=>Ve(L.branches,Yd,()=>rs(cs()),"branches",b=>{rs({...cs(),...b}),te(!0)}),onBack:()=>{j("branches"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));if(m==="cycles-form")return Me(n.jsx(T1,{form:sc,setForm:ls,organizations:R,formStatus:Ue,viewMode:Fe||!f("cycles-form"),onEdit:f("cycles-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,onSubmit:()=>Ve(L.cycles,sc,()=>ls(us()),"cycles",b=>{ls({...us(),...b}),te(!0)}),onBack:()=>{j("cycles"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));if(m==="kpi-input-form")return Me(n.jsx(E1,{form:rc,setForm:as,organizations:R,formStatus:Ue,viewMode:Fe||!f("kpi-input-form"),onEdit:f("kpi-input-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,onSubmit:()=>Ve(L.kpiInput,rc,()=>as(ps()),"kpi-input",b=>{as({...ps(),...b}),te(!0)}),onBack:()=>{j("kpi-input"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));if(m==="incident-types-form")return Me(n.jsx(V0,{form:Xd,setForm:Ps,formStatus:Ue,viewMode:Fe||!f("incident-types-form"),onEdit:f("incident-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,onSubmit:()=>Ve(L.incidentTypes,Xd,()=>Ps(Fs()),"incident-types",b=>{Ps({...Fs(),...b}),te(!0)}),onBack:()=>{j("incident-types"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));if(m==="idea-types-form")return Me(n.jsx(n1,{form:qd,setForm:As,formStatus:Ue,viewMode:Fe||!f("idea-types-form"),onEdit:f("idea-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,onSubmit:()=>Ve(L.ideaTypes,qd,()=>As(Ms()),"idea-types",b=>{As({...Ms(),...b}),te(!0)}),onBack:()=>{j("idea-types"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));if(m==="order-types-form")return Me(n.jsx(l1,{form:Jd,setForm:Rs,formStatus:Ue,viewMode:Fe||!f("order-types-form"),onEdit:f("order-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,onSubmit:()=>Ve(L.orderTypes,Jd,()=>Rs(Hs()),"order-types",b=>{Rs({...Hs(),...b}),te(!0)}),onBack:()=>{j("order-types"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));if(m==="process-types-form")return Me(n.jsx(o1,{form:Zd,setForm:Ds,formStatus:Ue,viewMode:Fe||!f("process-types-form"),onEdit:f("process-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,onSubmit:()=>Ve(L.processTypes,Zd,()=>Ds(Gs()),"process-types",b=>{Ds({...Gs(),...b}),te(!0)}),onBack:()=>{j("process-types"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));if(m==="incident-statuses-form")return Me(n.jsx(u1,{form:Vd,setForm:Ls,formStatus:Ue,viewMode:Fe||!f("incident-statuses-form"),onEdit:f("incident-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,onSubmit:()=>Ve(L.incidentStatuses,Vd,()=>Ls(Ks()),"incident-statuses",b=>{Ls({...Ks(),...b}),te(!0)}),onBack:()=>{j("incident-statuses"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));if(m==="idea-statuses-form")return Me(n.jsx(h1,{form:ec,setForm:Os,formStatus:Ue,viewMode:Fe||!f("idea-statuses-form"),onEdit:f("idea-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,onSubmit:()=>Ve(L.ideaStatuses,ec,()=>Os(Qs()),"idea-statuses",b=>{Os({...Qs(),...b}),te(!0)}),onBack:()=>{j("idea-statuses"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));if(m==="order-statuses-form")return Me(n.jsx(m1,{form:tc,setForm:Ns,formStatus:Ue,viewMode:Fe||!f("order-statuses-form"),onEdit:f("order-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,onSubmit:()=>Ve(L.orderStatuses,tc,()=>Ns(Ys()),"order-statuses",b=>{Ns({...Ys(),...b}),te(!0)}),onBack:()=>{j("order-statuses"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));if(m==="process-statuses-form")return Me(n.jsx(j1,{form:nc,setForm:Ws,formStatus:Ue,viewMode:Fe||!f("process-statuses-form"),onEdit:f("process-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,onSubmit:()=>Ve(L.processStatuses,nc,()=>Ws(Xs()),"process-statuses",b=>{Ws({...Xs(),...b}),te(!0)}),onBack:()=>{j("process-statuses"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));if(m==="users-form")return Me(n.jsx(_1,{form:Tr,setForm:Al,groupCompanies:oi,organizations:R,managements:M,departments:K,branches:ee,formStatus:Ue,viewMode:Fe||!f("users-form"),onEdit:f("users-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,isSelfProfile:Fd,onSubmit:ig,onBack:()=>{j(Fd?i?"dashboard":"inbox":"users"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));if(m==="delegations-form")return Me(n.jsx(O1,{form:Bs,setForm:Ir,organizations:R,users:N,userRoleMap:dn,formStatus:Ue,viewMode:Fe||!f("delegations-form"),onEdit:f("delegations-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,onSubmit:Uh,onBack:()=>{j("delegations"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));if(m==="group-companies-form")return Me(n.jsx(U0,{form:Ud,setForm:Is,users:N,formStatus:Ue,viewMode:Fe||!f("group-companies-form"),onEdit:f("group-companies-form")?()=>te(!1):void 0,onRestore:a==="Admin"?b=>Er(L.groupCompanies,b):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:C,onViewProfile:We,onSubmit:()=>Ve(L.groupCompanies,Ud,()=>Is(El()),"group-companies",b=>{Is({...El(),...b}),te(!0)}),onBack:()=>{j("group-companies"),oe("idle")},onNavigate:j,onLogout:Ne,user:e}));const ui={...l.pages,"group-companies":"Group Companies","group-companies-form":"Group Company Form"},og={"group-companies":{color:F.purple,formPage:"group-companies-form",reset:()=>Is(El())},incidents:{color:F.accent,formPage:"incidents-form",reset:()=>pn({...xn(),organization:h||S})},ideas:{color:F.teal,formPage:"ideas-form",reset:()=>Zt({...nn(),organization:h||S})},orders:{color:F.purple,formPage:"orders-form",reset:()=>Vt({...sn(),organization:h||S})},processes:{color:F.blue,formPage:"processes-form",reset:()=>{const b=$d.create_processes,H=h||(a==="Manager"&&b&&b.length===1?b[0]:S);en({...Vl(),organization:H})}},organizations:{color:F.accent,formPage:"organizations-form",reset:()=>Es(Us())},managements:{color:F.blue,formPage:"managements-form",reset:()=>ns({...os(),organization:h||S})},departments:{color:F.teal,formPage:"departments-form",reset:()=>ss({...ds(),custom_organization:h||S})},branches:{color:F.purple,formPage:"branches-form",reset:()=>rs({...cs(),organization:h||S})},cycles:{color:F.teal,formPage:"cycles-form",reset:()=>ls({...us(),organization:h||S})},"kpi-input":{color:F.blue,formPage:"kpi-input-form",reset:()=>as({...ps(),organization:h||S})},"incident-types":{color:F.red,formPage:"incident-types-form",reset:()=>Ps(Fs())},"idea-types":{color:F.orange,formPage:"idea-types-form",reset:()=>As(Ms())},"order-types":{color:F.green,formPage:"order-types-form",reset:()=>Rs(Hs())},"process-types":{color:F.accent,formPage:"process-types-form",reset:()=>Ds(Gs())},"incident-statuses":{color:F.red,formPage:"incident-statuses-form",reset:()=>Ls(Ks())},"idea-statuses":{color:F.teal,formPage:"idea-statuses-form",reset:()=>Os(Qs())},"order-statuses":{color:F.purple,formPage:"order-statuses-form",reset:()=>Ns(Ys())},"process-statuses":{color:F.blue,formPage:"process-statuses-form",reset:()=>Ws(Xs())},users:{color:F.blue,formPage:"users-form",reset:()=>{Al(ea()),Md(!1)}},delegations:{color:F.purple,formPage:"delegations-form",reset:()=>Ir(Mr())}},dg={"group-companies":"New Group Company",incidents:l.formTitle.newIncident,ideas:l.formTitle.newIdea,orders:l.formTitle.newOrder,processes:l.formTitle.newProcess,organizations:l.formTitle.newOrg,managements:l.formTitle.newMgmt,departments:l.formTitle.newDept,branches:l.formTitle.newBranch,users:l.formTitle.newUser,cycles:l.formTitle.newCycle,"kpi-input":l.formTitle.newKpi,delegations:l.formTitle.newDelegation,"incident-types":"New Incident Type","idea-types":"New Idea Type","order-types":"New Order Type","process-types":"New Process Type","incident-statuses":"New Incident Status","idea-statuses":"New Idea Status","order-statuses":"New Order Status","process-statuses":"New Process Status"},cg={incidents:P,ideas:Z,orders:D,processes:E,organizations:R,managements:M,departments:K,branches:ee,cycles:cn,"kpi-input":Nd,"incident-types":ze,"idea-types":ne,"order-types":re,"process-types":jt,"incident-statuses":U,"idea-statuses":Ze,"order-statuses":je,"process-statuses":le,users:Vn,delegations:Wd},is=ay[m],Pr=cg[m],J=f(m),pi=J?og[m]:null;return n.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:s?"#0f172a":F.bg},children:[n.jsx(th,{collapsed:fh,onToggleCollapsed:gh,activePage:m,onNavigate:b=>j(b),hasDashboard:i,hasReports:c,hasDelegations:d,role:a,rtl:l.rtl,navLabels:l.nav,settingsLabel:l.nav.settings}),n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[n.jsx("div",{style:{background:s?"#1e293b":"#ffffff",padding:"6px 20px",borderBottom:`1px solid ${s?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"flex-end",alignItems:"center",gap:6,flexShrink:0,boxShadow:s?"none":"0 1px 4px rgba(0,0,0,0.04)"},children:n.jsx(lh,{notifCount:_,darkMode:s,onCountChange:C,onToggleDark:r,onNavigate:ci,onViewProfile:We,onLogout:Ne,userName:e.full_name||e.name,userRole:a})}),m!=="profile"&&n.jsxs("div",{style:{background:s?"#1e293b":"white",padding:"12px 24px",borderBottom:`1px solid ${s?"#2d3748":"#e2e8f0"}`,display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:18,fontWeight:700,color:s?"#e2e8f0":"#0f172a"},children:ui[m]||m}),Pr&&n.jsxs("div",{style:{fontSize:12,color:"#64748b",marginTop:2,fontWeight:500},children:["Total: ",Pr.length," ",ui[m]?ui[m].toLowerCase():"records"]})]}),n.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[is&&Pr&&n.jsx("button",{onClick:()=>di(!0),style:{background:"#16a34a",color:"white",border:"none",padding:"7px 16px",borderRadius:8,fontSize:13,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI",display:"flex",alignItems:"center",gap:6,boxShadow:"0 1px 2px rgba(0,0,0,0.06)"},children:"📊 Export"}),pi&&n.jsxs("button",{onClick:()=>{pi.reset(),te(!1),oe("idle"),j(pi.formPage)},style:{background:"#2563eb",color:"white",border:"none",padding:"7px 16px",borderRadius:8,fontSize:13,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI",display:"flex",alignItems:"center",gap:6,boxShadow:"0 1px 2px rgba(0,0,0,0.06)"},children:["+ ",dg[m]||l.new]})]})]}),is&&Pr&&xh&&n.jsx(vy,{title:is.label,rows:Pr,columns:is.columns,defaultColumnKeys:is.defaultColumns,orgField:is.orgField,organizations:is.orgField?R:void 0,filenameBase:m,onClose:()=>di(!1)}),n.jsxs("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",padding:m==="profile"?0:"20px 24px",gap:m==="profile"?0:16},children:[we&&n.jsx("div",{style:{textAlign:"center",paddingTop:60,color:"#aaa",fontSize:15},children:l.loading}),!we&&m==="dashboard"&&i&&n.jsx(d0,{incidents:P,ideas:Z,orders:D,processes:E,organizations:R,incidentStatuses:U,ideaStatuses:Ze,orderStatuses:je,processStatuses:le,selectedOrg:S,onOrgChange:g,onNavigate:ci,onNavigateStatus:y,userRole:a}),!we&&m==="inbox"&&n.jsx(N1,{onNavigate:ci,onRefresh:zt}),!we&&m==="reports"&&c&&n.jsx(M1,{organizations:R,userRole:a}),!we&&m==="incidents"&&n.jsx(c0,{incidents:P,organizations:R,departments:K,branches:ee,incidentStatuses:U,initialOrg:S,initialStatus:x,onView:yh,onEdit:J?Eh:void 0,onDelete:J?b=>Ie(L.incidents,b):void 0,canModify:J}),!we&&m==="ideas"&&n.jsx(j0,{ideas:Z,organizations:R,departments:K,branches:ee,ideaStatuses:Ze,initialOrg:S,initialStatus:x,onView:vh,onEdit:J?Ph:void 0,onDelete:J?b=>Ie(L.ideas,b):void 0,canModify:J}),!we&&m==="orders"&&n.jsx(_0,{orders:D,organizations:R,departments:K,branches:ee,orderStatuses:je,initialOrg:S,initialStatus:x,onView:jh,onEdit:J?Ah:void 0,onDelete:J?b=>Ie(L.orders,b):void 0,canModify:J}),!we&&m==="processes"&&n.jsx(I0,{processes:E,organizations:R,departments:K,branches:ee,processStatuses:le,initialOrg:S,initialStatus:x,onView:bh,onEdit:J?Rh:void 0,onDelete:J?b=>Ie(L.processes,b):void 0,canModify:J}),!we&&m==="organizations"&&n.jsx(W0,{organizations:R,onView:Sh,onEdit:J?Dh:void 0,onDelete:J?b=>Ie(L.organizations,b):void 0,canModify:J}),!we&&m==="group-companies"&&n.jsx($0,{groupCompanies:oi,onView:wh,onEdit:J?_h:void 0,onDelete:J?b=>Ie(L.groupCompanies,b):void 0,canModify:J}),!we&&m==="managements"&&n.jsx(M0,{managements:M,onView:kh,onEdit:J?Lh:void 0,onDelete:J?b=>Ie(L.managements,b):void 0,canModify:J}),!we&&m==="departments"&&n.jsx(K0,{departments:K,managements:M,onView:Ch,onEdit:J?Oh:void 0,onDelete:J?b=>Ie(L.departments,b):void 0,canModify:J}),!we&&m==="branches"&&n.jsx(X0,{branches:ee,managements:M,departments:K,onView:zh,onEdit:J?Nh:void 0,onDelete:J?b=>Ie(L.branches,b):void 0,canModify:J}),!we&&m==="cycles"&&n.jsx(k1,{cycles:cn,canModify:J,onView:Th,onEdit:J?Wh:void 0,onDelete:J?b=>Ie(L.cycles,b):void 0}),!we&&m==="kpi-input"&&n.jsx(I1,{kpiInputs:Nd,canModify:J,onView:Ih,onEdit:J?Bh:void 0,onDelete:J?b=>Ie(L.kpiInput,b):void 0}),!we&&m==="incident-types"&&n.jsx(Z0,{incidentTypes:ze,onView:Mh,onEdit:J?Hh:void 0,onDelete:J?b=>Ie(L.incidentTypes,b):void 0,canModify:J}),!we&&m==="idea-types"&&n.jsx(t1,{ideaTypes:ne,onView:Gh,onEdit:J?Kh:void 0,onDelete:J?b=>Ie(L.ideaTypes,b):void 0,canModify:J}),!we&&m==="order-types"&&n.jsx(r1,{orderTypes:re,onView:Qh,onEdit:J?Yh:void 0,onDelete:J?b=>Ie(L.orderTypes,b):void 0,canModify:J}),!we&&m==="process-types"&&n.jsx(i1,{processTypes:jt,onView:Xh,onEdit:J?qh:void 0,onDelete:J?b=>Ie(L.processTypes,b):void 0,canModify:J}),!we&&m==="incident-statuses"&&n.jsx(c1,{incidentStatuses:U,onView:Jh,onEdit:J?Zh:void 0,onDelete:J?b=>Ie(L.incidentStatuses,b):void 0,canModify:J}),!we&&m==="idea-statuses"&&n.jsx(f1,{ideaStatuses:Ze,onView:Vh,onEdit:J?eg:void 0,onDelete:J?b=>Ie(L.ideaStatuses,b):void 0,canModify:J}),!we&&m==="order-statuses"&&n.jsx(x1,{orderStatuses:je,onView:tg,onEdit:J?ng:void 0,onDelete:J?b=>Ie(L.orderStatuses,b):void 0,canModify:J}),!we&&m==="process-statuses"&&n.jsx(v1,{processStatuses:le,onView:sg,onEdit:J?rg:void 0,onDelete:J?b=>Ie(L.processStatuses,b):void 0,canModify:J}),!we&&m==="users"&&n.jsx(w1,{users:Vn,roleMap:dn,onView:lg,onEdit:J?ag:void 0,onDelete:J?b=>Ie("User",b):void 0,onDisable:J?mh:void 0,canModify:J}),!we&&m==="delegations"&&d&&n.jsx(D1,{delegations:Wd,organizations:R,userRole:a,currentUser:e.name,onView:$h,onRevoke:J?Fh:void 0}),m==="profile"&&(()=>{const b=!!Pl&&(Pl.name===e.name||Pl.email===e.name);return n.jsx(L0,{user:e,profileUser:Pl,sbUsers:Vn,organizations:R,managements:M,departments:K,branches:ee,darkMode:s,canModify:J||b,onBack:()=>j(b?i?"dashboard":"inbox":"users"),onNavigate:j})})()]})]}),n.jsx(vu,{isOpen:dt.isOpen,doctype:dt.doctype,docname:dt.name,docTitle:dt.title,isAdmin:a==="Admin"||e.name==="Administrator",isDeleting:dt.isDeleting,onClose:()=>hn(b=>({...b,isOpen:!1})),onConfirmSoftDelete:ic,onConfirmPermanentDelete:oc})]})}function Z1(e){return e.some(t=>["SB Admin","System Manager"].includes(t))?"Admin":e.includes("SB Auditor")?"Auditor":e.includes("SB Owner")?"Owner":e.includes("SB X-Auditor")?"XAuditor":e.includes("SB Manager")?"Manager":"Employee"}function V1(){const[e,t]=w.useState(()=>{try{const c=localStorage.getItem("sidrah_user");return c?JSON.parse(c):null}catch{return null}}),[s,r]=w.useState(()=>localStorage.getItem("sb_dark")==="1"),l=()=>{const c=!s;r(c),localStorage.setItem("sb_dark",c?"1":"0"),document.documentElement.classList.toggle("dark",c)};w.useEffect(()=>{document.documentElement.classList.toggle("dark",s)},[]),w.useEffect(()=>{e&&nh().then(async c=>{const d=c||e.name,f=await rh(d);if(!f.length)return;const v=Z1(f),p=await Oy();if(v!==e.role||d!==e.name||p!==(e.custom_organization||"")){const m={...e,name:d,role:v,custom_organization:p};t(m),localStorage.setItem("sidrah_user",JSON.stringify(m))}})},[e==null?void 0:e.name]);const a=c=>{t(c),localStorage.setItem("sidrah_user",JSON.stringify(c))},i=()=>{t(null),localStorage.removeItem("sidrah_user")};return e?n.jsx(J1,{user:e,onLogout:i,darkMode:s,onToggleDark:l}):n.jsx(s0,{onLogin:a})}Xf(document.getElementById("root")).render(n.jsx(w.StrictMode,{children:n.jsx(V1,{})}));
|