2026-10-09 12:16:48 +05:30

53 lines
551 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

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

(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))l(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&l(i)}).observe(document,{childList:!0,subtree:!0});function s(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function l(r){if(r.ep)return;r.ep=!0;const a=s(r);fetch(r.href,a)}})();var $u={exports:{}},Ha={},Uu={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 Cr=Symbol.for("react.element"),Lg=Symbol.for("react.portal"),Og=Symbol.for("react.fragment"),Ng=Symbol.for("react.strict_mode"),Wg=Symbol.for("react.profiler"),Bg=Symbol.for("react.provider"),$g=Symbol.for("react.context"),Ug=Symbol.for("react.forward_ref"),Fg=Symbol.for("react.suspense"),Mg=Symbol.for("react.memo"),Hg=Symbol.for("react.lazy"),fd=Symbol.iterator;function Gg(e){return e===null||typeof e!="object"?null:(e=fd&&e[fd]||e["@@iterator"],typeof e=="function"?e:null)}var Fu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Mu=Object.assign,Hu={};function Il(e,n,s){this.props=e,this.context=n,this.refs=Hu,this.updater=s||Fu}Il.prototype.isReactComponent={};Il.prototype.setState=function(e,n){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,n,"setState")};Il.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Gu(){}Gu.prototype=Il.prototype;function Ho(e,n,s){this.props=e,this.context=n,this.refs=Hu,this.updater=s||Fu}var Go=Ho.prototype=new Gu;Go.constructor=Ho;Mu(Go,Il.prototype);Go.isPureReactComponent=!0;var hd=Array.isArray,Ku=Object.prototype.hasOwnProperty,Ko={current:null},Qu={key:!0,ref:!0,__self:!0,__source:!0};function Yu(e,n,s){var l,r={},a=null,i=null;if(n!=null)for(l in n.ref!==void 0&&(i=n.ref),n.key!==void 0&&(a=""+n.key),n)Ku.call(n,l)&&!Qu.hasOwnProperty(l)&&(r[l]=n[l]);var c=arguments.length-2;if(c===1)r.children=s;else if(1<c){for(var u=Array(c),g=0;g<c;g++)u[g]=arguments[g+2];r.children=u}if(e&&e.defaultProps)for(l in c=e.defaultProps,c)r[l]===void 0&&(r[l]=c[l]);return{$$typeof:Cr,type:e,key:a,ref:i,props:r,_owner:Ko.current}}function Kg(e,n){return{$$typeof:Cr,type:e.type,key:n,ref:e.ref,props:e.props,_owner:e._owner}}function Qo(e){return typeof e=="object"&&e!==null&&e.$$typeof===Cr}function Qg(e){var n={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(s){return n[s]})}var gd=/\/+/g;function vi(e,n){return typeof e=="object"&&e!==null&&e.key!=null?Qg(""+e.key):n.toString(36)}function ra(e,n,s,l,r){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 Cr:case Lg:i=!0}}if(i)return i=e,r=r(i),e=l===""?"."+vi(i,0):l,hd(r)?(s="",e!=null&&(s=e.replace(gd,"$&/")+"/"),ra(r,n,s,"",function(g){return g})):r!=null&&(Qo(r)&&(r=Kg(r,s+(!r.key||i&&i.key===r.key?"":(""+r.key).replace(gd,"$&/")+"/")+e)),n.push(r)),1;if(i=0,l=l===""?".":l+":",hd(e))for(var c=0;c<e.length;c++){a=e[c];var u=l+vi(a,c);i+=ra(a,n,s,u,r)}else if(u=Gg(e),typeof u=="function")for(e=u.call(e),c=0;!(a=e.next()).done;)a=a.value,u=l+vi(a,c++),i+=ra(a,n,s,u,r);else if(a==="object")throw n=String(e),Error("Objects are not valid as a React child (found: "+(n==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":n)+"). If you meant to render a collection of children, use an array instead.");return i}function Nr(e,n,s){if(e==null)return e;var l=[],r=0;return ra(e,l,"","",function(a){return n.call(s,a,r++)}),l}function Yg(e){if(e._status===-1){var n=e._result;n=n(),n.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=n)}if(e._status===1)return e._result.default;throw e._result}var St={current:null},aa={transition:null},Xg={ReactCurrentDispatcher:St,ReactCurrentBatchConfig:aa,ReactCurrentOwner:Ko};function Xu(){throw Error("act(...) is not supported in production builds of React.")}ue.Children={map:Nr,forEach:function(e,n,s){Nr(e,function(){n.apply(this,arguments)},s)},count:function(e){var n=0;return Nr(e,function(){n++}),n},toArray:function(e){return Nr(e,function(n){return n})||[]},only:function(e){if(!Qo(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ue.Component=Il;ue.Fragment=Og;ue.Profiler=Wg;ue.PureComponent=Ho;ue.StrictMode=Ng;ue.Suspense=Fg;ue.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Xg;ue.act=Xu;ue.cloneElement=function(e,n,s){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var l=Mu({},e.props),r=e.key,a=e.ref,i=e._owner;if(n!=null){if(n.ref!==void 0&&(a=n.ref,i=Ko.current),n.key!==void 0&&(r=""+n.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(u in n)Ku.call(n,u)&&!Qu.hasOwnProperty(u)&&(l[u]=n[u]===void 0&&c!==void 0?c[u]:n[u])}var u=arguments.length-2;if(u===1)l.children=s;else if(1<u){c=Array(u);for(var g=0;g<u;g++)c[g]=arguments[g+2];l.children=c}return{$$typeof:Cr,type:e.type,key:r,ref:a,props:l,_owner:i}};ue.createContext=function(e){return e={$$typeof:$g,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Bg,_context:e},e.Consumer=e};ue.createElement=Yu;ue.createFactory=function(e){var n=Yu.bind(null,e);return n.type=e,n};ue.createRef=function(){return{current:null}};ue.forwardRef=function(e){return{$$typeof:Ug,render:e}};ue.isValidElement=Qo;ue.lazy=function(e){return{$$typeof:Hg,_payload:{_status:-1,_result:e},_init:Yg}};ue.memo=function(e,n){return{$$typeof:Mg,type:e,compare:n===void 0?null:n}};ue.startTransition=function(e){var n=aa.transition;aa.transition={};try{e()}finally{aa.transition=n}};ue.unstable_act=Xu;ue.useCallback=function(e,n){return St.current.useCallback(e,n)};ue.useContext=function(e){return St.current.useContext(e)};ue.useDebugValue=function(){};ue.useDeferredValue=function(e){return St.current.useDeferredValue(e)};ue.useEffect=function(e,n){return St.current.useEffect(e,n)};ue.useId=function(){return St.current.useId()};ue.useImperativeHandle=function(e,n,s){return St.current.useImperativeHandle(e,n,s)};ue.useInsertionEffect=function(e,n){return St.current.useInsertionEffect(e,n)};ue.useLayoutEffect=function(e,n){return St.current.useLayoutEffect(e,n)};ue.useMemo=function(e,n){return St.current.useMemo(e,n)};ue.useReducer=function(e,n,s){return St.current.useReducer(e,n,s)};ue.useRef=function(e){return St.current.useRef(e)};ue.useState=function(e){return St.current.useState(e)};ue.useSyncExternalStore=function(e,n,s){return St.current.useSyncExternalStore(e,n,s)};ue.useTransition=function(){return St.current.useTransition()};ue.version="18.3.1";Uu.exports=ue;var C=Uu.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 qg=C,Jg=Symbol.for("react.element"),Zg=Symbol.for("react.fragment"),Vg=Object.prototype.hasOwnProperty,ex=qg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,tx={key:!0,ref:!0,__self:!0,__source:!0};function qu(e,n,s){var l,r={},a=null,i=null;s!==void 0&&(a=""+s),n.key!==void 0&&(a=""+n.key),n.ref!==void 0&&(i=n.ref);for(l in n)Vg.call(n,l)&&!tx.hasOwnProperty(l)&&(r[l]=n[l]);if(e&&e.defaultProps)for(l in n=e.defaultProps,n)r[l]===void 0&&(r[l]=n[l]);return{$$typeof:Jg,type:e,key:a,ref:i,props:r,_owner:ex.current}}Ha.Fragment=Zg;Ha.jsx=qu;Ha.jsxs=qu;$u.exports=Ha;var t=$u.exports,Ju={exports:{}},Nt={},Zu={exports:{}},Vu={};/**
* @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 n(Y,X){var q=Y.length;Y.push(X);e:for(;0<q;){var N=q-1>>>1,Z=Y[N];if(0<r(Z,X))Y[N]=X,Y[q]=Z,q=N;else break e}}function s(Y){return Y.length===0?null:Y[0]}function l(Y){if(Y.length===0)return null;var X=Y[0],q=Y.pop();if(q!==X){Y[0]=q;e:for(var N=0,Z=Y.length,ce=Z>>>1;N<ce;){var me=2*(N+1)-1,le=Y[me],Ve=me+1,ct=Y[Ve];if(0>r(le,q))Ve<Z&&0>r(ct,le)?(Y[N]=ct,Y[Ve]=q,N=Ve):(Y[N]=le,Y[me]=q,N=me);else if(Ve<Z&&0>r(ct,q))Y[N]=ct,Y[Ve]=q,N=Ve;else break e}}return X}function r(Y,X){var q=Y.sortIndex-X.sortIndex;return q!==0?q:Y.id-X.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 u=[],g=[],j=1,y=null,p=3,x=!1,w=!1,v=!1,S=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,o=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function d(Y){for(var X=s(g);X!==null;){if(X.callback===null)l(g);else if(X.startTime<=Y)l(g),X.sortIndex=X.expirationTime,n(u,X);else break;X=s(g)}}function f(Y){if(v=!1,d(Y),!w)if(s(u)!==null)w=!0,D(z);else{var X=s(g);X!==null&&Q(f,X.startTime-Y)}}function z(Y,X){w=!1,v&&(v=!1,m(k),k=-1),x=!0;var q=p;try{for(d(X),y=s(u);y!==null&&(!(y.expirationTime>X)||Y&&!M());){var N=y.callback;if(typeof N=="function"){y.callback=null,p=y.priorityLevel;var Z=N(y.expirationTime<=X);X=e.unstable_now(),typeof Z=="function"?y.callback=Z:y===s(u)&&l(u),d(X)}else l(u);y=s(u)}if(y!==null)var ce=!0;else{var me=s(g);me!==null&&Q(f,me.startTime-X),ce=!1}return ce}finally{y=null,p=q,x=!1}}var b=!1,h=null,k=-1,I=5,P=-1;function M(){return!(e.unstable_now()-P<I)}function ee(){if(h!==null){var Y=e.unstable_now();P=Y;var X=!0;try{X=h(!0,Y)}finally{X?W():(b=!1,h=null)}}else b=!1}var W;if(typeof o=="function")W=function(){o(ee)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,T=$.port2;$.port1.onmessage=ee,W=function(){T.postMessage(null)}}else W=function(){S(ee,0)};function D(Y){h=Y,b||(b=!0,W())}function Q(Y,X){k=S(function(){Y(e.unstable_now())},X)}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(Y){Y.callback=null},e.unstable_continueExecution=function(){w||x||(w=!0,D(z))},e.unstable_forceFrameRate=function(Y){0>Y||125<Y?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<Y?Math.floor(1e3/Y):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return s(u)},e.unstable_next=function(Y){switch(p){case 1:case 2:case 3:var X=3;break;default:X=p}var q=p;p=X;try{return Y()}finally{p=q}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(Y,X){switch(Y){case 1:case 2:case 3:case 4:case 5:break;default:Y=3}var q=p;p=Y;try{return X()}finally{p=q}},e.unstable_scheduleCallback=function(Y,X,q){var N=e.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?N+q:N):q=N,Y){case 1:var Z=-1;break;case 2:Z=250;break;case 5:Z=1073741823;break;case 4:Z=1e4;break;default:Z=5e3}return Z=q+Z,Y={id:j++,callback:X,priorityLevel:Y,startTime:q,expirationTime:Z,sortIndex:-1},q>N?(Y.sortIndex=q,n(g,Y),s(u)===null&&Y===s(g)&&(v?(m(k),k=-1):v=!0,Q(f,q-N))):(Y.sortIndex=Z,n(u,Y),w||x||(w=!0,D(z))),Y},e.unstable_shouldYield=M,e.unstable_wrapCallback=function(Y){var X=p;return function(){var q=p;p=X;try{return Y.apply(this,arguments)}finally{p=q}}}})(Vu);Zu.exports=Vu;var nx=Zu.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 sx=C,Ot=nx;function G(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,s=1;s<arguments.length;s++)n+="&args[]="+encodeURIComponent(arguments[s]);return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var ep=new Set,or={};function Ts(e,n){vl(e,n),vl(e+"Capture",n)}function vl(e,n){for(or[e]=n,e=0;e<n.length;e++)ep.add(n[e])}var zn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Yi=Object.prototype.hasOwnProperty,lx=/^[: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]*$/,xd={},md={};function rx(e){return Yi.call(md,e)?!0:Yi.call(xd,e)?!1:lx.test(e)?md[e]=!0:(xd[e]=!0,!1)}function ax(e,n,s,l){if(s!==null&&s.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:s!==null?!s.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function ix(e,n,s,l){if(n===null||typeof n>"u"||ax(e,n,s,l))return!0;if(l)return!1;if(s!==null)switch(s.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function wt(e,n,s,l,r,a,i){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=r,this.mustUseProperty=s,this.propertyName=e,this.type=n,this.sanitizeURL=a,this.removeEmptyString=i}var pt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){pt[e]=new wt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];pt[n]=new wt(n,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){pt[e]=new wt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){pt[e]=new wt(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){pt[e]=new wt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){pt[e]=new wt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){pt[e]=new wt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){pt[e]=new wt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){pt[e]=new wt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Yo=/[\-:]([a-z])/g;function Xo(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 n=e.replace(Yo,Xo);pt[n]=new wt(n,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(Yo,Xo);pt[n]=new wt(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(Yo,Xo);pt[n]=new wt(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){pt[e]=new wt(e,1,!1,e.toLowerCase(),null,!1,!1)});pt.xlinkHref=new wt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){pt[e]=new wt(e,1,!1,e.toLowerCase(),null,!0,!0)});function qo(e,n,s,l){var r=pt.hasOwnProperty(n)?pt[n]:null;(r!==null?r.type!==0:l||!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(ix(n,s,r,l)&&(s=null),l||r===null?rx(n)&&(s===null?e.removeAttribute(n):e.setAttribute(n,""+s)):r.mustUseProperty?e[r.propertyName]=s===null?r.type===3?!1:"":s:(n=r.attributeName,l=r.attributeNamespace,s===null?e.removeAttribute(n):(r=r.type,s=r===3||r===4&&s===!0?"":""+s,l?e.setAttributeNS(l,n,s):e.setAttribute(n,s))))}var Pn=sx.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Wr=Symbol.for("react.element"),el=Symbol.for("react.portal"),tl=Symbol.for("react.fragment"),Jo=Symbol.for("react.strict_mode"),Xi=Symbol.for("react.profiler"),tp=Symbol.for("react.provider"),np=Symbol.for("react.context"),Zo=Symbol.for("react.forward_ref"),qi=Symbol.for("react.suspense"),Ji=Symbol.for("react.suspense_list"),Vo=Symbol.for("react.memo"),On=Symbol.for("react.lazy"),sp=Symbol.for("react.offscreen"),yd=Symbol.iterator;function Ol(e){return e===null||typeof e!="object"?null:(e=yd&&e[yd]||e["@@iterator"],typeof e=="function"?e:null)}var Le=Object.assign,ji;function Yl(e){if(ji===void 0)try{throw Error()}catch(s){var n=s.stack.trim().match(/\n( *(at )?)/);ji=n&&n[1]||""}return`
`+ji+e}var bi=!1;function Si(e,n){if(!e||bi)return"";bi=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(n)if(n=function(){throw Error()},Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(n,[])}catch(g){var l=g}Reflect.construct(e,[],n)}else{try{n.call()}catch(g){l=g}e.call(n.prototype)}else{try{throw Error()}catch(g){l=g}e()}}catch(g){if(g&&l&&typeof g.stack=="string"){for(var r=g.stack.split(`
`),a=l.stack.split(`
`),i=r.length-1,c=a.length-1;1<=i&&0<=c&&r[i]!==a[c];)c--;for(;1<=i&&0<=c;i--,c--)if(r[i]!==a[c]){if(i!==1||c!==1)do if(i--,c--,0>c||r[i]!==a[c]){var u=`
`+r[i].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}while(1<=i&&0<=c);break}}}finally{bi=!1,Error.prepareStackTrace=s}return(e=e?e.displayName||e.name:"")?Yl(e):""}function ox(e){switch(e.tag){case 5:return Yl(e.type);case 16:return Yl("Lazy");case 13:return Yl("Suspense");case 19:return Yl("SuspenseList");case 0:case 2:case 15:return e=Si(e.type,!1),e;case 11:return e=Si(e.type.render,!1),e;case 1:return e=Si(e.type,!0),e;default:return""}}function Zi(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 tl:return"Fragment";case el:return"Portal";case Xi:return"Profiler";case Jo:return"StrictMode";case qi:return"Suspense";case Ji:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case np:return(e.displayName||"Context")+".Consumer";case tp:return(e._context.displayName||"Context")+".Provider";case Zo:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Vo:return n=e.displayName||null,n!==null?n:Zi(e.type)||"Memo";case On:n=e._payload,e=e._init;try{return Zi(e(n))}catch{}}return null}function cx(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Zi(n);case 8:return n===Jo?"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 n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Zn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function lp(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function dx(e){var n=lp(e)?"checked":"value",s=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var r=s.get,a=s.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return r.call(this)},set:function(i){l=""+i,a.call(this,i)}}),Object.defineProperty(e,n,{enumerable:s.enumerable}),{getValue:function(){return l},setValue:function(i){l=""+i},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function Br(e){e._valueTracker||(e._valueTracker=dx(e))}function rp(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var s=n.getValue(),l="";return e&&(l=lp(e)?e.checked?"true":"false":e.value),e=l,e!==s?(n.setValue(e),!0):!1}function ya(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 Vi(e,n){var s=n.checked;return Le({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:s??e._wrapperState.initialChecked})}function vd(e,n){var s=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;s=Zn(n.value!=null?n.value:s),e._wrapperState={initialChecked:l,initialValue:s,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function ap(e,n){n=n.checked,n!=null&&qo(e,"checked",n,!1)}function eo(e,n){ap(e,n);var s=Zn(n.value),l=n.type;if(s!=null)l==="number"?(s===0&&e.value===""||e.value!=s)&&(e.value=""+s):e.value!==""+s&&(e.value=""+s);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?to(e,n.type,s):n.hasOwnProperty("defaultValue")&&to(e,n.type,Zn(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function jd(e,n,s){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,s||n===e.value||(e.value=n),e.defaultValue=n}s=e.name,s!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,s!==""&&(e.name=s)}function to(e,n,s){(n!=="number"||ya(e.ownerDocument)!==e)&&(s==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+s&&(e.defaultValue=""+s))}var Xl=Array.isArray;function fl(e,n,s,l){if(e=e.options,n){n={};for(var r=0;r<s.length;r++)n["$"+s[r]]=!0;for(s=0;s<e.length;s++)r=n.hasOwnProperty("$"+e[s].value),e[s].selected!==r&&(e[s].selected=r),r&&l&&(e[s].defaultSelected=!0)}else{for(s=""+Zn(s),n=null,r=0;r<e.length;r++){if(e[r].value===s){e[r].selected=!0,l&&(e[r].defaultSelected=!0);return}n!==null||e[r].disabled||(n=e[r])}n!==null&&(n.selected=!0)}}function no(e,n){if(n.dangerouslySetInnerHTML!=null)throw Error(G(91));return Le({},n,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function bd(e,n){var s=n.value;if(s==null){if(s=n.children,n=n.defaultValue,s!=null){if(n!=null)throw Error(G(92));if(Xl(s)){if(1<s.length)throw Error(G(93));s=s[0]}n=s}n==null&&(n=""),s=n}e._wrapperState={initialValue:Zn(s)}}function ip(e,n){var s=Zn(n.value),l=Zn(n.defaultValue);s!=null&&(s=""+s,s!==e.value&&(e.value=s),n.defaultValue==null&&e.defaultValue!==s&&(e.defaultValue=s)),l!=null&&(e.defaultValue=""+l)}function Sd(e){var n=e.textContent;n===e._wrapperState.initialValue&&n!==""&&n!==null&&(e.value=n)}function op(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 so(e,n){return e==null||e==="http://www.w3.org/1999/xhtml"?op(n):e==="http://www.w3.org/2000/svg"&&n==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var $r,cp=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(n,s,l,r){MSApp.execUnsafeLocalFunction(function(){return e(n,s,l,r)})}:e}(function(e,n){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=n;else{for($r=$r||document.createElement("div"),$r.innerHTML="<svg>"+n.valueOf().toString()+"</svg>",n=$r.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function cr(e,n){if(n){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=n;return}}e.textContent=n}var Vl={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},ux=["Webkit","ms","Moz","O"];Object.keys(Vl).forEach(function(e){ux.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),Vl[n]=Vl[e]})});function dp(e,n,s){return n==null||typeof n=="boolean"||n===""?"":s||typeof n!="number"||n===0||Vl.hasOwnProperty(e)&&Vl[e]?(""+n).trim():n+"px"}function up(e,n){e=e.style;for(var s in n)if(n.hasOwnProperty(s)){var l=s.indexOf("--")===0,r=dp(s,n[s],l);s==="float"&&(s="cssFloat"),l?e.setProperty(s,r):e[s]=r}}var px=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 lo(e,n){if(n){if(px[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(G(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(G(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(G(61))}if(n.style!=null&&typeof n.style!="object")throw Error(G(62))}}function ro(e,n){if(e.indexOf("-")===-1)return typeof n.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 ao=null;function ec(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var io=null,hl=null,gl=null;function wd(e){if(e=Er(e)){if(typeof io!="function")throw Error(G(280));var n=e.stateNode;n&&(n=Xa(n),io(e.stateNode,e.type,n))}}function pp(e){hl?gl?gl.push(e):gl=[e]:hl=e}function fp(){if(hl){var e=hl,n=gl;if(gl=hl=null,wd(e),n)for(e=0;e<n.length;e++)wd(n[e])}}function hp(e,n){return e(n)}function gp(){}var wi=!1;function xp(e,n,s){if(wi)return e(n,s);wi=!0;try{return hp(e,n,s)}finally{wi=!1,(hl!==null||gl!==null)&&(gp(),fp())}}function dr(e,n){var s=e.stateNode;if(s===null)return null;var l=Xa(s);if(l===null)return null;s=l[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(e=e.type,l=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!l;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(G(231,n,typeof s));return s}var oo=!1;if(zn)try{var Nl={};Object.defineProperty(Nl,"passive",{get:function(){oo=!0}}),window.addEventListener("test",Nl,Nl),window.removeEventListener("test",Nl,Nl)}catch{oo=!1}function fx(e,n,s,l,r,a,i,c,u){var g=Array.prototype.slice.call(arguments,3);try{n.apply(s,g)}catch(j){this.onError(j)}}var er=!1,va=null,ja=!1,co=null,hx={onError:function(e){er=!0,va=e}};function gx(e,n,s,l,r,a,i,c,u){er=!1,va=null,fx.apply(hx,arguments)}function xx(e,n,s,l,r,a,i,c,u){if(gx.apply(this,arguments),er){if(er){var g=va;er=!1,va=null}else throw Error(G(198));ja||(ja=!0,co=g)}}function Ps(e){var n=e,s=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,n.flags&4098&&(s=n.return),e=n.return;while(e)}return n.tag===3?s:null}function mp(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function kd(e){if(Ps(e)!==e)throw Error(G(188))}function mx(e){var n=e.alternate;if(!n){if(n=Ps(e),n===null)throw Error(G(188));return n!==e?null:e}for(var s=e,l=n;;){var r=s.return;if(r===null)break;var a=r.alternate;if(a===null){if(l=r.return,l!==null){s=l;continue}break}if(r.child===a.child){for(a=r.child;a;){if(a===s)return kd(r),e;if(a===l)return kd(r),n;a=a.sibling}throw Error(G(188))}if(s.return!==l.return)s=r,l=a;else{for(var i=!1,c=r.child;c;){if(c===s){i=!0,s=r,l=a;break}if(c===l){i=!0,l=r,s=a;break}c=c.sibling}if(!i){for(c=a.child;c;){if(c===s){i=!0,s=a,l=r;break}if(c===l){i=!0,l=a,s=r;break}c=c.sibling}if(!i)throw Error(G(189))}}if(s.alternate!==l)throw Error(G(190))}if(s.tag!==3)throw Error(G(188));return s.stateNode.current===s?e:n}function yp(e){return e=mx(e),e!==null?vp(e):null}function vp(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var n=vp(e);if(n!==null)return n;e=e.sibling}return null}var jp=Ot.unstable_scheduleCallback,_d=Ot.unstable_cancelCallback,yx=Ot.unstable_shouldYield,vx=Ot.unstable_requestPaint,Xe=Ot.unstable_now,jx=Ot.unstable_getCurrentPriorityLevel,tc=Ot.unstable_ImmediatePriority,bp=Ot.unstable_UserBlockingPriority,ba=Ot.unstable_NormalPriority,bx=Ot.unstable_LowPriority,Sp=Ot.unstable_IdlePriority,Ga=null,pn=null;function Sx(e){if(pn&&typeof pn.onCommitFiberRoot=="function")try{pn.onCommitFiberRoot(Ga,e,void 0,(e.current.flags&128)===128)}catch{}}var Zt=Math.clz32?Math.clz32:_x,wx=Math.log,kx=Math.LN2;function _x(e){return e>>>=0,e===0?32:31-(wx(e)/kx|0)|0}var Ur=64,Fr=4194304;function ql(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 Sa(e,n){var s=e.pendingLanes;if(s===0)return 0;var l=0,r=e.suspendedLanes,a=e.pingedLanes,i=s&268435455;if(i!==0){var c=i&~r;c!==0?l=ql(c):(a&=i,a!==0&&(l=ql(a)))}else i=s&~r,i!==0?l=ql(i):a!==0&&(l=ql(a));if(l===0)return 0;if(n!==0&&n!==l&&!(n&r)&&(r=l&-l,a=n&-n,r>=a||r===16&&(a&4194240)!==0))return n;if(l&4&&(l|=s&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0<n;)s=31-Zt(n),r=1<<s,l|=e[s],n&=~r;return l}function Cx(e,n){switch(e){case 1:case 2:case 4:return n+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 n+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 zx(e,n){for(var s=e.suspendedLanes,l=e.pingedLanes,r=e.expirationTimes,a=e.pendingLanes;0<a;){var i=31-Zt(a),c=1<<i,u=r[i];u===-1?(!(c&s)||c&l)&&(r[i]=Cx(c,n)):u<=n&&(e.expiredLanes|=c),a&=~c}}function uo(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function wp(){var e=Ur;return Ur<<=1,!(Ur&4194240)&&(Ur=64),e}function ki(e){for(var n=[],s=0;31>s;s++)n.push(e);return n}function zr(e,n,s){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Zt(n),e[n]=s}function Ix(e,n){var s=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0<s;){var r=31-Zt(s),a=1<<r;n[r]=0,l[r]=-1,e[r]=-1,s&=~a}}function nc(e,n){var s=e.entangledLanes|=n;for(e=e.entanglements;s;){var l=31-Zt(s),r=1<<l;r&n|e[l]&n&&(e[l]|=n),s&=~r}}var be=0;function kp(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var _p,sc,Cp,zp,Ip,po=!1,Mr=[],Hn=null,Gn=null,Kn=null,ur=new Map,pr=new Map,Wn=[],Ex="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 Cd(e,n){switch(e){case"focusin":case"focusout":Hn=null;break;case"dragenter":case"dragleave":Gn=null;break;case"mouseover":case"mouseout":Kn=null;break;case"pointerover":case"pointerout":ur.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":pr.delete(n.pointerId)}}function Wl(e,n,s,l,r,a){return e===null||e.nativeEvent!==a?(e={blockedOn:n,domEventName:s,eventSystemFlags:l,nativeEvent:a,targetContainers:[r]},n!==null&&(n=Er(n),n!==null&&sc(n)),e):(e.eventSystemFlags|=l,n=e.targetContainers,r!==null&&n.indexOf(r)===-1&&n.push(r),e)}function Tx(e,n,s,l,r){switch(n){case"focusin":return Hn=Wl(Hn,e,n,s,l,r),!0;case"dragenter":return Gn=Wl(Gn,e,n,s,l,r),!0;case"mouseover":return Kn=Wl(Kn,e,n,s,l,r),!0;case"pointerover":var a=r.pointerId;return ur.set(a,Wl(ur.get(a)||null,e,n,s,l,r)),!0;case"gotpointercapture":return a=r.pointerId,pr.set(a,Wl(pr.get(a)||null,e,n,s,l,r)),!0}return!1}function Ep(e){var n=vs(e.target);if(n!==null){var s=Ps(n);if(s!==null){if(n=s.tag,n===13){if(n=mp(s),n!==null){e.blockedOn=n,Ip(e.priority,function(){Cp(s)});return}}else if(n===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function ia(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var s=fo(e.domEventName,e.eventSystemFlags,n[0],e.nativeEvent);if(s===null){s=e.nativeEvent;var l=new s.constructor(s.type,s);ao=l,s.target.dispatchEvent(l),ao=null}else return n=Er(s),n!==null&&sc(n),e.blockedOn=s,!1;n.shift()}return!0}function zd(e,n,s){ia(e)&&s.delete(n)}function Px(){po=!1,Hn!==null&&ia(Hn)&&(Hn=null),Gn!==null&&ia(Gn)&&(Gn=null),Kn!==null&&ia(Kn)&&(Kn=null),ur.forEach(zd),pr.forEach(zd)}function Bl(e,n){e.blockedOn===n&&(e.blockedOn=null,po||(po=!0,Ot.unstable_scheduleCallback(Ot.unstable_NormalPriority,Px)))}function fr(e){function n(r){return Bl(r,e)}if(0<Mr.length){Bl(Mr[0],e);for(var s=1;s<Mr.length;s++){var l=Mr[s];l.blockedOn===e&&(l.blockedOn=null)}}for(Hn!==null&&Bl(Hn,e),Gn!==null&&Bl(Gn,e),Kn!==null&&Bl(Kn,e),ur.forEach(n),pr.forEach(n),s=0;s<Wn.length;s++)l=Wn[s],l.blockedOn===e&&(l.blockedOn=null);for(;0<Wn.length&&(s=Wn[0],s.blockedOn===null);)Ep(s),s.blockedOn===null&&Wn.shift()}var xl=Pn.ReactCurrentBatchConfig,wa=!0;function Ax(e,n,s,l){var r=be,a=xl.transition;xl.transition=null;try{be=1,lc(e,n,s,l)}finally{be=r,xl.transition=a}}function Rx(e,n,s,l){var r=be,a=xl.transition;xl.transition=null;try{be=4,lc(e,n,s,l)}finally{be=r,xl.transition=a}}function lc(e,n,s,l){if(wa){var r=fo(e,n,s,l);if(r===null)Di(e,n,l,ka,s),Cd(e,l);else if(Tx(r,e,n,s,l))l.stopPropagation();else if(Cd(e,l),n&4&&-1<Ex.indexOf(e)){for(;r!==null;){var a=Er(r);if(a!==null&&_p(a),a=fo(e,n,s,l),a===null&&Di(e,n,l,ka,s),a===r)break;r=a}r!==null&&l.stopPropagation()}else Di(e,n,l,null,s)}}var ka=null;function fo(e,n,s,l){if(ka=null,e=ec(l),e=vs(e),e!==null)if(n=Ps(e),n===null)e=null;else if(s=n.tag,s===13){if(e=mp(n),e!==null)return e;e=null}else if(s===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null);return ka=e,null}function Tp(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(jx()){case tc:return 1;case bp:return 4;case ba:case bx:return 16;case Sp:return 536870912;default:return 16}default:return 16}}var $n=null,rc=null,oa=null;function Pp(){if(oa)return oa;var e,n=rc,s=n.length,l,r="value"in $n?$n.value:$n.textContent,a=r.length;for(e=0;e<s&&n[e]===r[e];e++);var i=s-e;for(l=1;l<=i&&n[s-l]===r[a-l];l++);return oa=r.slice(e,1<l?1-l:void 0)}function ca(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function Hr(){return!0}function Id(){return!1}function Wt(e){function n(s,l,r,a,i){this._reactName=s,this._targetInst=r,this.type=l,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)?Hr:Id,this.isPropagationStopped=Id,this}return Le(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=Hr)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=Hr)},persist:function(){},isPersistent:Hr}),n}var El={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ac=Wt(El),Ir=Le({},El,{view:0,detail:0}),Dx=Wt(Ir),_i,Ci,$l,Ka=Le({},Ir,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ic,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!==$l&&($l&&e.type==="mousemove"?(_i=e.screenX-$l.screenX,Ci=e.screenY-$l.screenY):Ci=_i=0,$l=e),_i)},movementY:function(e){return"movementY"in e?e.movementY:Ci}}),Ed=Wt(Ka),Lx=Le({},Ka,{dataTransfer:0}),Ox=Wt(Lx),Nx=Le({},Ir,{relatedTarget:0}),zi=Wt(Nx),Wx=Le({},El,{animationName:0,elapsedTime:0,pseudoElement:0}),Bx=Wt(Wx),$x=Le({},El,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Ux=Wt($x),Fx=Le({},El,{data:0}),Td=Wt(Fx),Mx={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Hx={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"},Gx={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Kx(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=Gx[e])?!!n[e]:!1}function ic(){return Kx}var Qx=Le({},Ir,{key:function(e){if(e.key){var n=Mx[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=ca(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Hx[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ic,charCode:function(e){return e.type==="keypress"?ca(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ca(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Yx=Wt(Qx),Xx=Le({},Ka,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Pd=Wt(Xx),qx=Le({},Ir,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ic}),Jx=Wt(qx),Zx=Le({},El,{propertyName:0,elapsedTime:0,pseudoElement:0}),Vx=Wt(Zx),em=Le({},Ka,{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}),tm=Wt(em),nm=[9,13,27,32],oc=zn&&"CompositionEvent"in window,tr=null;zn&&"documentMode"in document&&(tr=document.documentMode);var sm=zn&&"TextEvent"in window&&!tr,Ap=zn&&(!oc||tr&&8<tr&&11>=tr),Ad=" ",Rd=!1;function Rp(e,n){switch(e){case"keyup":return nm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Dp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var nl=!1;function lm(e,n){switch(e){case"compositionend":return Dp(n);case"keypress":return n.which!==32?null:(Rd=!0,Ad);case"textInput":return e=n.data,e===Ad&&Rd?null:e;default:return null}}function rm(e,n){if(nl)return e==="compositionend"||!oc&&Rp(e,n)?(e=Pp(),oa=rc=$n=null,nl=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return Ap&&n.locale!=="ko"?null:n.data;default:return null}}var am={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 Dd(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!am[e.type]:n==="textarea"}function Lp(e,n,s,l){pp(l),n=_a(n,"onChange"),0<n.length&&(s=new ac("onChange","change",null,s,l),e.push({event:s,listeners:n}))}var nr=null,hr=null;function im(e){Kp(e,0)}function Qa(e){var n=rl(e);if(rp(n))return e}function om(e,n){if(e==="change")return n}var Op=!1;if(zn){var Ii;if(zn){var Ei="oninput"in document;if(!Ei){var Ld=document.createElement("div");Ld.setAttribute("oninput","return;"),Ei=typeof Ld.oninput=="function"}Ii=Ei}else Ii=!1;Op=Ii&&(!document.documentMode||9<document.documentMode)}function Od(){nr&&(nr.detachEvent("onpropertychange",Np),hr=nr=null)}function Np(e){if(e.propertyName==="value"&&Qa(hr)){var n=[];Lp(n,hr,e,ec(e)),xp(im,n)}}function cm(e,n,s){e==="focusin"?(Od(),nr=n,hr=s,nr.attachEvent("onpropertychange",Np)):e==="focusout"&&Od()}function dm(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Qa(hr)}function um(e,n){if(e==="click")return Qa(n)}function pm(e,n){if(e==="input"||e==="change")return Qa(n)}function fm(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var en=typeof Object.is=="function"?Object.is:fm;function gr(e,n){if(en(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var s=Object.keys(e),l=Object.keys(n);if(s.length!==l.length)return!1;for(l=0;l<s.length;l++){var r=s[l];if(!Yi.call(n,r)||!en(e[r],n[r]))return!1}return!0}function Nd(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Wd(e,n){var s=Nd(e);e=0;for(var l;s;){if(s.nodeType===3){if(l=e+s.textContent.length,e<=n&&l>=n)return{node:s,offset:n-e};e=l}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=Nd(s)}}function Wp(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Wp(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Bp(){for(var e=window,n=ya();n instanceof e.HTMLIFrameElement;){try{var s=typeof n.contentWindow.location.href=="string"}catch{s=!1}if(s)e=n.contentWindow;else break;n=ya(e.document)}return n}function cc(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function hm(e){var n=Bp(),s=e.focusedElem,l=e.selectionRange;if(n!==s&&s&&s.ownerDocument&&Wp(s.ownerDocument.documentElement,s)){if(l!==null&&cc(s)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in s)s.selectionStart=n,s.selectionEnd=Math.min(e,s.value.length);else if(e=(n=s.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var r=s.textContent.length,a=Math.min(l.start,r);l=l.end===void 0?a:Math.min(l.end,r),!e.extend&&a>l&&(r=l,l=a,a=r),r=Wd(s,a);var i=Wd(s,l);r&&i&&(e.rangeCount!==1||e.anchorNode!==r.node||e.anchorOffset!==r.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(n=n.createRange(),n.setStart(r.node,r.offset),e.removeAllRanges(),a>l?(e.addRange(n),e.extend(i.node,i.offset)):(n.setEnd(i.node,i.offset),e.addRange(n)))}}for(n=[],e=s;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;s<n.length;s++)e=n[s],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var gm=zn&&"documentMode"in document&&11>=document.documentMode,sl=null,ho=null,sr=null,go=!1;function Bd(e,n,s){var l=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;go||sl==null||sl!==ya(l)||(l=sl,"selectionStart"in l&&cc(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),sr&&gr(sr,l)||(sr=l,l=_a(ho,"onSelect"),0<l.length&&(n=new ac("onSelect","select",null,n,s),e.push({event:n,listeners:l}),n.target=sl)))}function Gr(e,n){var s={};return s[e.toLowerCase()]=n.toLowerCase(),s["Webkit"+e]="webkit"+n,s["Moz"+e]="moz"+n,s}var ll={animationend:Gr("Animation","AnimationEnd"),animationiteration:Gr("Animation","AnimationIteration"),animationstart:Gr("Animation","AnimationStart"),transitionend:Gr("Transition","TransitionEnd")},Ti={},$p={};zn&&($p=document.createElement("div").style,"AnimationEvent"in window||(delete ll.animationend.animation,delete ll.animationiteration.animation,delete ll.animationstart.animation),"TransitionEvent"in window||delete ll.transitionend.transition);function Ya(e){if(Ti[e])return Ti[e];if(!ll[e])return e;var n=ll[e],s;for(s in n)if(n.hasOwnProperty(s)&&s in $p)return Ti[e]=n[s];return e}var Up=Ya("animationend"),Fp=Ya("animationiteration"),Mp=Ya("animationstart"),Hp=Ya("transitionend"),Gp=new Map,$d="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 ts(e,n){Gp.set(e,n),Ts(n,[e])}for(var Pi=0;Pi<$d.length;Pi++){var Ai=$d[Pi],xm=Ai.toLowerCase(),mm=Ai[0].toUpperCase()+Ai.slice(1);ts(xm,"on"+mm)}ts(Up,"onAnimationEnd");ts(Fp,"onAnimationIteration");ts(Mp,"onAnimationStart");ts("dblclick","onDoubleClick");ts("focusin","onFocus");ts("focusout","onBlur");ts(Hp,"onTransitionEnd");vl("onMouseEnter",["mouseout","mouseover"]);vl("onMouseLeave",["mouseout","mouseover"]);vl("onPointerEnter",["pointerout","pointerover"]);vl("onPointerLeave",["pointerout","pointerover"]);Ts("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Ts("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Ts("onBeforeInput",["compositionend","keypress","textInput","paste"]);Ts("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Ts("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Ts("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Jl="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(" "),ym=new Set("cancel close invalid load scroll toggle".split(" ").concat(Jl));function Ud(e,n,s){var l=e.type||"unknown-event";e.currentTarget=s,xx(l,n,void 0,e),e.currentTarget=null}function Kp(e,n){n=(n&4)!==0;for(var s=0;s<e.length;s++){var l=e[s],r=l.event;l=l.listeners;e:{var a=void 0;if(n)for(var i=l.length-1;0<=i;i--){var c=l[i],u=c.instance,g=c.currentTarget;if(c=c.listener,u!==a&&r.isPropagationStopped())break e;Ud(r,c,g),a=u}else for(i=0;i<l.length;i++){if(c=l[i],u=c.instance,g=c.currentTarget,c=c.listener,u!==a&&r.isPropagationStopped())break e;Ud(r,c,g),a=u}}}if(ja)throw e=co,ja=!1,co=null,e}function Ce(e,n){var s=n[jo];s===void 0&&(s=n[jo]=new Set);var l=e+"__bubble";s.has(l)||(Qp(n,e,2,!1),s.add(l))}function Ri(e,n,s){var l=0;n&&(l|=4),Qp(s,e,l,n)}var Kr="_reactListening"+Math.random().toString(36).slice(2);function xr(e){if(!e[Kr]){e[Kr]=!0,ep.forEach(function(s){s!=="selectionchange"&&(ym.has(s)||Ri(s,!1,e),Ri(s,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[Kr]||(n[Kr]=!0,Ri("selectionchange",!1,n))}}function Qp(e,n,s,l){switch(Tp(n)){case 1:var r=Ax;break;case 4:r=Rx;break;default:r=lc}s=r.bind(null,n,s,e),r=void 0,!oo||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(r=!0),l?r!==void 0?e.addEventListener(n,s,{capture:!0,passive:r}):e.addEventListener(n,s,!0):r!==void 0?e.addEventListener(n,s,{passive:r}):e.addEventListener(n,s,!1)}function Di(e,n,s,l,r){var a=l;if(!(n&1)&&!(n&2)&&l!==null)e:for(;;){if(l===null)return;var i=l.tag;if(i===3||i===4){var c=l.stateNode.containerInfo;if(c===r||c.nodeType===8&&c.parentNode===r)break;if(i===4)for(i=l.return;i!==null;){var u=i.tag;if((u===3||u===4)&&(u=i.stateNode.containerInfo,u===r||u.nodeType===8&&u.parentNode===r))return;i=i.return}for(;c!==null;){if(i=vs(c),i===null)return;if(u=i.tag,u===5||u===6){l=a=i;continue e}c=c.parentNode}}l=l.return}xp(function(){var g=a,j=ec(s),y=[];e:{var p=Gp.get(e);if(p!==void 0){var x=ac,w=e;switch(e){case"keypress":if(ca(s)===0)break e;case"keydown":case"keyup":x=Yx;break;case"focusin":w="focus",x=zi;break;case"focusout":w="blur",x=zi;break;case"beforeblur":case"afterblur":x=zi;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":x=Ed;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":x=Ox;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":x=Jx;break;case Up:case Fp:case Mp:x=Bx;break;case Hp:x=Vx;break;case"scroll":x=Dx;break;case"wheel":x=tm;break;case"copy":case"cut":case"paste":x=Ux;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":x=Pd}var v=(n&4)!==0,S=!v&&e==="scroll",m=v?p!==null?p+"Capture":null:p;v=[];for(var o=g,d;o!==null;){d=o;var f=d.stateNode;if(d.tag===5&&f!==null&&(d=f,m!==null&&(f=dr(o,m),f!=null&&v.push(mr(o,f,d)))),S)break;o=o.return}0<v.length&&(p=new x(p,w,null,s,j),y.push({event:p,listeners:v}))}}if(!(n&7)){e:{if(p=e==="mouseover"||e==="pointerover",x=e==="mouseout"||e==="pointerout",p&&s!==ao&&(w=s.relatedTarget||s.fromElement)&&(vs(w)||w[In]))break e;if((x||p)&&(p=j.window===j?j:(p=j.ownerDocument)?p.defaultView||p.parentWindow:window,x?(w=s.relatedTarget||s.toElement,x=g,w=w?vs(w):null,w!==null&&(S=Ps(w),w!==S||w.tag!==5&&w.tag!==6)&&(w=null)):(x=null,w=g),x!==w)){if(v=Ed,f="onMouseLeave",m="onMouseEnter",o="mouse",(e==="pointerout"||e==="pointerover")&&(v=Pd,f="onPointerLeave",m="onPointerEnter",o="pointer"),S=x==null?p:rl(x),d=w==null?p:rl(w),p=new v(f,o+"leave",x,s,j),p.target=S,p.relatedTarget=d,f=null,vs(j)===g&&(v=new v(m,o+"enter",w,s,j),v.target=d,v.relatedTarget=S,f=v),S=f,x&&w)t:{for(v=x,m=w,o=0,d=v;d;d=Hs(d))o++;for(d=0,f=m;f;f=Hs(f))d++;for(;0<o-d;)v=Hs(v),o--;for(;0<d-o;)m=Hs(m),d--;for(;o--;){if(v===m||m!==null&&v===m.alternate)break t;v=Hs(v),m=Hs(m)}v=null}else v=null;x!==null&&Fd(y,p,x,v,!1),w!==null&&S!==null&&Fd(y,S,w,v,!0)}}e:{if(p=g?rl(g):window,x=p.nodeName&&p.nodeName.toLowerCase(),x==="select"||x==="input"&&p.type==="file")var z=om;else if(Dd(p))if(Op)z=pm;else{z=dm;var b=cm}else(x=p.nodeName)&&x.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(z=um);if(z&&(z=z(e,g))){Lp(y,z,s,j);break e}b&&b(e,p,g),e==="focusout"&&(b=p._wrapperState)&&b.controlled&&p.type==="number"&&to(p,"number",p.value)}switch(b=g?rl(g):window,e){case"focusin":(Dd(b)||b.contentEditable==="true")&&(sl=b,ho=g,sr=null);break;case"focusout":sr=ho=sl=null;break;case"mousedown":go=!0;break;case"contextmenu":case"mouseup":case"dragend":go=!1,Bd(y,s,j);break;case"selectionchange":if(gm)break;case"keydown":case"keyup":Bd(y,s,j)}var h;if(oc)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 nl?Rp(e,s)&&(k="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(k="onCompositionStart");k&&(Ap&&s.locale!=="ko"&&(nl||k!=="onCompositionStart"?k==="onCompositionEnd"&&nl&&(h=Pp()):($n=j,rc="value"in $n?$n.value:$n.textContent,nl=!0)),b=_a(g,k),0<b.length&&(k=new Td(k,e,null,s,j),y.push({event:k,listeners:b}),h?k.data=h:(h=Dp(s),h!==null&&(k.data=h)))),(h=sm?lm(e,s):rm(e,s))&&(g=_a(g,"onBeforeInput"),0<g.length&&(j=new Td("onBeforeInput","beforeinput",null,s,j),y.push({event:j,listeners:g}),j.data=h))}Kp(y,n)})}function mr(e,n,s){return{instance:e,listener:n,currentTarget:s}}function _a(e,n){for(var s=n+"Capture",l=[];e!==null;){var r=e,a=r.stateNode;r.tag===5&&a!==null&&(r=a,a=dr(e,s),a!=null&&l.unshift(mr(e,a,r)),a=dr(e,n),a!=null&&l.push(mr(e,a,r))),e=e.return}return l}function Hs(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Fd(e,n,s,l,r){for(var a=n._reactName,i=[];s!==null&&s!==l;){var c=s,u=c.alternate,g=c.stateNode;if(u!==null&&u===l)break;c.tag===5&&g!==null&&(c=g,r?(u=dr(s,a),u!=null&&i.unshift(mr(s,u,c))):r||(u=dr(s,a),u!=null&&i.push(mr(s,u,c)))),s=s.return}i.length!==0&&e.push({event:n,listeners:i})}var vm=/\r\n?/g,jm=/\u0000|\uFFFD/g;function Md(e){return(typeof e=="string"?e:""+e).replace(vm,`
`).replace(jm,"")}function Qr(e,n,s){if(n=Md(n),Md(e)!==n&&s)throw Error(G(425))}function Ca(){}var xo=null,mo=null;function yo(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var vo=typeof setTimeout=="function"?setTimeout:void 0,bm=typeof clearTimeout=="function"?clearTimeout:void 0,Hd=typeof Promise=="function"?Promise:void 0,Sm=typeof queueMicrotask=="function"?queueMicrotask:typeof Hd<"u"?function(e){return Hd.resolve(null).then(e).catch(wm)}:vo;function wm(e){setTimeout(function(){throw e})}function Li(e,n){var s=n,l=0;do{var r=s.nextSibling;if(e.removeChild(s),r&&r.nodeType===8)if(s=r.data,s==="/$"){if(l===0){e.removeChild(r),fr(n);return}l--}else s!=="$"&&s!=="$?"&&s!=="$!"||l++;s=r}while(s);fr(n)}function Qn(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?")break;if(n==="/$")return null}}return e}function Gd(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"){if(n===0)return e;n--}else s==="/$"&&n++}e=e.previousSibling}return null}var Tl=Math.random().toString(36).slice(2),un="__reactFiber$"+Tl,yr="__reactProps$"+Tl,In="__reactContainer$"+Tl,jo="__reactEvents$"+Tl,km="__reactListeners$"+Tl,_m="__reactHandles$"+Tl;function vs(e){var n=e[un];if(n)return n;for(var s=e.parentNode;s;){if(n=s[In]||s[un]){if(s=n.alternate,n.child!==null||s!==null&&s.child!==null)for(e=Gd(e);e!==null;){if(s=e[un])return s;e=Gd(e)}return n}e=s,s=e.parentNode}return null}function Er(e){return e=e[un]||e[In],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function rl(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(G(33))}function Xa(e){return e[yr]||null}var bo=[],al=-1;function ns(e){return{current:e}}function ze(e){0>al||(e.current=bo[al],bo[al]=null,al--)}function ke(e,n){al++,bo[al]=e.current,e.current=n}var Vn={},yt=ns(Vn),Ct=ns(!1),ks=Vn;function jl(e,n){var s=e.type.contextTypes;if(!s)return Vn;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var r={},a;for(a in s)r[a]=n[a];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=r),r}function zt(e){return e=e.childContextTypes,e!=null}function za(){ze(Ct),ze(yt)}function Kd(e,n,s){if(yt.current!==Vn)throw Error(G(168));ke(yt,n),ke(Ct,s)}function Yp(e,n,s){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return s;l=l.getChildContext();for(var r in l)if(!(r in n))throw Error(G(108,cx(e)||"Unknown",r));return Le({},s,l)}function Ia(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Vn,ks=yt.current,ke(yt,e),ke(Ct,Ct.current),!0}function Qd(e,n,s){var l=e.stateNode;if(!l)throw Error(G(169));s?(e=Yp(e,n,ks),l.__reactInternalMemoizedMergedChildContext=e,ze(Ct),ze(yt),ke(yt,e)):ze(Ct),ke(Ct,s)}var wn=null,qa=!1,Oi=!1;function Xp(e){wn===null?wn=[e]:wn.push(e)}function Cm(e){qa=!0,Xp(e)}function ss(){if(!Oi&&wn!==null){Oi=!0;var e=0,n=be;try{var s=wn;for(be=1;e<s.length;e++){var l=s[e];do l=l(!0);while(l!==null)}wn=null,qa=!1}catch(r){throw wn!==null&&(wn=wn.slice(e+1)),jp(tc,ss),r}finally{be=n,Oi=!1}}return null}var il=[],ol=0,Ea=null,Ta=0,Bt=[],$t=0,_s=null,kn=1,_n="";function ms(e,n){il[ol++]=Ta,il[ol++]=Ea,Ea=e,Ta=n}function qp(e,n,s){Bt[$t++]=kn,Bt[$t++]=_n,Bt[$t++]=_s,_s=e;var l=kn;e=_n;var r=32-Zt(l)-1;l&=~(1<<r),s+=1;var a=32-Zt(n)+r;if(30<a){var i=r-r%5;a=(l&(1<<i)-1).toString(32),l>>=i,r-=i,kn=1<<32-Zt(n)+r|s<<r|l,_n=a+e}else kn=1<<a|s<<r|l,_n=e}function dc(e){e.return!==null&&(ms(e,1),qp(e,1,0))}function uc(e){for(;e===Ea;)Ea=il[--ol],il[ol]=null,Ta=il[--ol],il[ol]=null;for(;e===_s;)_s=Bt[--$t],Bt[$t]=null,_n=Bt[--$t],Bt[$t]=null,kn=Bt[--$t],Bt[$t]=null}var Lt=null,Dt=null,Pe=!1,qt=null;function Jp(e,n){var s=Ut(5,null,null,0);s.elementType="DELETED",s.stateNode=n,s.return=e,n=e.deletions,n===null?(e.deletions=[s],e.flags|=16):n.push(s)}function Yd(e,n){switch(e.tag){case 5:var s=e.type;return n=n.nodeType!==1||s.toLowerCase()!==n.nodeName.toLowerCase()?null:n,n!==null?(e.stateNode=n,Lt=e,Dt=Qn(n.firstChild),!0):!1;case 6:return n=e.pendingProps===""||n.nodeType!==3?null:n,n!==null?(e.stateNode=n,Lt=e,Dt=null,!0):!1;case 13:return n=n.nodeType!==8?null:n,n!==null?(s=_s!==null?{id:kn,overflow:_n}:null,e.memoizedState={dehydrated:n,treeContext:s,retryLane:1073741824},s=Ut(18,null,null,0),s.stateNode=n,s.return=e,e.child=s,Lt=e,Dt=null,!0):!1;default:return!1}}function So(e){return(e.mode&1)!==0&&(e.flags&128)===0}function wo(e){if(Pe){var n=Dt;if(n){var s=n;if(!Yd(e,n)){if(So(e))throw Error(G(418));n=Qn(s.nextSibling);var l=Lt;n&&Yd(e,n)?Jp(l,s):(e.flags=e.flags&-4097|2,Pe=!1,Lt=e)}}else{if(So(e))throw Error(G(418));e.flags=e.flags&-4097|2,Pe=!1,Lt=e}}}function Xd(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Lt=e}function Yr(e){if(e!==Lt)return!1;if(!Pe)return Xd(e),Pe=!0,!1;var n;if((n=e.tag!==3)&&!(n=e.tag!==5)&&(n=e.type,n=n!=="head"&&n!=="body"&&!yo(e.type,e.memoizedProps)),n&&(n=Dt)){if(So(e))throw Zp(),Error(G(418));for(;n;)Jp(e,n),n=Qn(n.nextSibling)}if(Xd(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(G(317));e:{for(e=e.nextSibling,n=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"){if(n===0){Dt=Qn(e.nextSibling);break e}n--}else s!=="$"&&s!=="$!"&&s!=="$?"||n++}e=e.nextSibling}Dt=null}}else Dt=Lt?Qn(e.stateNode.nextSibling):null;return!0}function Zp(){for(var e=Dt;e;)e=Qn(e.nextSibling)}function bl(){Dt=Lt=null,Pe=!1}function pc(e){qt===null?qt=[e]:qt.push(e)}var zm=Pn.ReactCurrentBatchConfig;function Ul(e,n,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 l=s.stateNode}if(!l)throw Error(G(147,e));var r=l,a=""+e;return n!==null&&n.ref!==null&&typeof n.ref=="function"&&n.ref._stringRef===a?n.ref:(n=function(i){var c=r.refs;i===null?delete c[a]:c[a]=i},n._stringRef=a,n)}if(typeof e!="string")throw Error(G(284));if(!s._owner)throw Error(G(290,e))}return e}function Xr(e,n){throw e=Object.prototype.toString.call(n),Error(G(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e))}function qd(e){var n=e._init;return n(e._payload)}function Vp(e){function n(m,o){if(e){var d=m.deletions;d===null?(m.deletions=[o],m.flags|=16):d.push(o)}}function s(m,o){if(!e)return null;for(;o!==null;)n(m,o),o=o.sibling;return null}function l(m,o){for(m=new Map;o!==null;)o.key!==null?m.set(o.key,o):m.set(o.index,o),o=o.sibling;return m}function r(m,o){return m=Jn(m,o),m.index=0,m.sibling=null,m}function a(m,o,d){return m.index=d,e?(d=m.alternate,d!==null?(d=d.index,d<o?(m.flags|=2,o):d):(m.flags|=2,o)):(m.flags|=1048576,o)}function i(m){return e&&m.alternate===null&&(m.flags|=2),m}function c(m,o,d,f){return o===null||o.tag!==6?(o=Mi(d,m.mode,f),o.return=m,o):(o=r(o,d),o.return=m,o)}function u(m,o,d,f){var z=d.type;return z===tl?j(m,o,d.props.children,f,d.key):o!==null&&(o.elementType===z||typeof z=="object"&&z!==null&&z.$$typeof===On&&qd(z)===o.type)?(f=r(o,d.props),f.ref=Ul(m,o,d),f.return=m,f):(f=xa(d.type,d.key,d.props,null,m.mode,f),f.ref=Ul(m,o,d),f.return=m,f)}function g(m,o,d,f){return o===null||o.tag!==4||o.stateNode.containerInfo!==d.containerInfo||o.stateNode.implementation!==d.implementation?(o=Hi(d,m.mode,f),o.return=m,o):(o=r(o,d.children||[]),o.return=m,o)}function j(m,o,d,f,z){return o===null||o.tag!==7?(o=ws(d,m.mode,f,z),o.return=m,o):(o=r(o,d),o.return=m,o)}function y(m,o,d){if(typeof o=="string"&&o!==""||typeof o=="number")return o=Mi(""+o,m.mode,d),o.return=m,o;if(typeof o=="object"&&o!==null){switch(o.$$typeof){case Wr:return d=xa(o.type,o.key,o.props,null,m.mode,d),d.ref=Ul(m,null,o),d.return=m,d;case el:return o=Hi(o,m.mode,d),o.return=m,o;case On:var f=o._init;return y(m,f(o._payload),d)}if(Xl(o)||Ol(o))return o=ws(o,m.mode,d,null),o.return=m,o;Xr(m,o)}return null}function p(m,o,d,f){var z=o!==null?o.key:null;if(typeof d=="string"&&d!==""||typeof d=="number")return z!==null?null:c(m,o,""+d,f);if(typeof d=="object"&&d!==null){switch(d.$$typeof){case Wr:return d.key===z?u(m,o,d,f):null;case el:return d.key===z?g(m,o,d,f):null;case On:return z=d._init,p(m,o,z(d._payload),f)}if(Xl(d)||Ol(d))return z!==null?null:j(m,o,d,f,null);Xr(m,d)}return null}function x(m,o,d,f,z){if(typeof f=="string"&&f!==""||typeof f=="number")return m=m.get(d)||null,c(o,m,""+f,z);if(typeof f=="object"&&f!==null){switch(f.$$typeof){case Wr:return m=m.get(f.key===null?d:f.key)||null,u(o,m,f,z);case el:return m=m.get(f.key===null?d:f.key)||null,g(o,m,f,z);case On:var b=f._init;return x(m,o,d,b(f._payload),z)}if(Xl(f)||Ol(f))return m=m.get(d)||null,j(o,m,f,z,null);Xr(o,f)}return null}function w(m,o,d,f){for(var z=null,b=null,h=o,k=o=0,I=null;h!==null&&k<d.length;k++){h.index>k?(I=h,h=null):I=h.sibling;var P=p(m,h,d[k],f);if(P===null){h===null&&(h=I);break}e&&h&&P.alternate===null&&n(m,h),o=a(P,o,k),b===null?z=P:b.sibling=P,b=P,h=I}if(k===d.length)return s(m,h),Pe&&ms(m,k),z;if(h===null){for(;k<d.length;k++)h=y(m,d[k],f),h!==null&&(o=a(h,o,k),b===null?z=h:b.sibling=h,b=h);return Pe&&ms(m,k),z}for(h=l(m,h);k<d.length;k++)I=x(h,m,k,d[k],f),I!==null&&(e&&I.alternate!==null&&h.delete(I.key===null?k:I.key),o=a(I,o,k),b===null?z=I:b.sibling=I,b=I);return e&&h.forEach(function(M){return n(m,M)}),Pe&&ms(m,k),z}function v(m,o,d,f){var z=Ol(d);if(typeof z!="function")throw Error(G(150));if(d=z.call(d),d==null)throw Error(G(151));for(var b=z=null,h=o,k=o=0,I=null,P=d.next();h!==null&&!P.done;k++,P=d.next()){h.index>k?(I=h,h=null):I=h.sibling;var M=p(m,h,P.value,f);if(M===null){h===null&&(h=I);break}e&&h&&M.alternate===null&&n(m,h),o=a(M,o,k),b===null?z=M:b.sibling=M,b=M,h=I}if(P.done)return s(m,h),Pe&&ms(m,k),z;if(h===null){for(;!P.done;k++,P=d.next())P=y(m,P.value,f),P!==null&&(o=a(P,o,k),b===null?z=P:b.sibling=P,b=P);return Pe&&ms(m,k),z}for(h=l(m,h);!P.done;k++,P=d.next())P=x(h,m,k,P.value,f),P!==null&&(e&&P.alternate!==null&&h.delete(P.key===null?k:P.key),o=a(P,o,k),b===null?z=P:b.sibling=P,b=P);return e&&h.forEach(function(ee){return n(m,ee)}),Pe&&ms(m,k),z}function S(m,o,d,f){if(typeof d=="object"&&d!==null&&d.type===tl&&d.key===null&&(d=d.props.children),typeof d=="object"&&d!==null){switch(d.$$typeof){case Wr:e:{for(var z=d.key,b=o;b!==null;){if(b.key===z){if(z=d.type,z===tl){if(b.tag===7){s(m,b.sibling),o=r(b,d.props.children),o.return=m,m=o;break e}}else if(b.elementType===z||typeof z=="object"&&z!==null&&z.$$typeof===On&&qd(z)===b.type){s(m,b.sibling),o=r(b,d.props),o.ref=Ul(m,b,d),o.return=m,m=o;break e}s(m,b);break}else n(m,b);b=b.sibling}d.type===tl?(o=ws(d.props.children,m.mode,f,d.key),o.return=m,m=o):(f=xa(d.type,d.key,d.props,null,m.mode,f),f.ref=Ul(m,o,d),f.return=m,m=f)}return i(m);case el:e:{for(b=d.key;o!==null;){if(o.key===b)if(o.tag===4&&o.stateNode.containerInfo===d.containerInfo&&o.stateNode.implementation===d.implementation){s(m,o.sibling),o=r(o,d.children||[]),o.return=m,m=o;break e}else{s(m,o);break}else n(m,o);o=o.sibling}o=Hi(d,m.mode,f),o.return=m,m=o}return i(m);case On:return b=d._init,S(m,o,b(d._payload),f)}if(Xl(d))return w(m,o,d,f);if(Ol(d))return v(m,o,d,f);Xr(m,d)}return typeof d=="string"&&d!==""||typeof d=="number"?(d=""+d,o!==null&&o.tag===6?(s(m,o.sibling),o=r(o,d),o.return=m,m=o):(s(m,o),o=Mi(d,m.mode,f),o.return=m,m=o),i(m)):s(m,o)}return S}var Sl=Vp(!0),ef=Vp(!1),Pa=ns(null),Aa=null,cl=null,fc=null;function hc(){fc=cl=Aa=null}function gc(e){var n=Pa.current;ze(Pa),e._currentValue=n}function ko(e,n,s){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===s)break;e=e.return}}function ml(e,n){Aa=e,fc=cl=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&n&&(_t=!0),e.firstContext=null)}function Mt(e){var n=e._currentValue;if(fc!==e)if(e={context:e,memoizedValue:n,next:null},cl===null){if(Aa===null)throw Error(G(308));cl=e,Aa.dependencies={lanes:0,firstContext:e}}else cl=cl.next=e;return n}var js=null;function xc(e){js===null?js=[e]:js.push(e)}function tf(e,n,s,l){var r=n.interleaved;return r===null?(s.next=s,xc(n)):(s.next=r.next,r.next=s),n.interleaved=s,En(e,l)}function En(e,n){e.lanes|=n;var s=e.alternate;for(s!==null&&(s.lanes|=n),s=e,e=e.return;e!==null;)e.childLanes|=n,s=e.alternate,s!==null&&(s.childLanes|=n),s=e,e=e.return;return s.tag===3?s.stateNode:null}var Nn=!1;function mc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function nf(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Cn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Yn(e,n,s){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,ge&2){var r=l.pending;return r===null?n.next=n:(n.next=r.next,r.next=n),l.pending=n,En(e,s)}return r=l.interleaved,r===null?(n.next=n,xc(l)):(n.next=r.next,r.next=n),l.interleaved=n,En(e,s)}function da(e,n,s){if(n=n.updateQueue,n!==null&&(n=n.shared,(s&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,s|=l,n.lanes=s,nc(e,s)}}function Jd(e,n){var s=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,s===l)){var r=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?r=a=i:a=a.next=i,s=s.next}while(s!==null);a===null?r=a=n:a=a.next=n}else r=a=n;s={baseState:l.baseState,firstBaseUpdate:r,lastBaseUpdate:a,shared:l.shared,effects:l.effects},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=n:e.next=n,s.lastBaseUpdate=n}function Ra(e,n,s,l){var r=e.updateQueue;Nn=!1;var a=r.firstBaseUpdate,i=r.lastBaseUpdate,c=r.shared.pending;if(c!==null){r.shared.pending=null;var u=c,g=u.next;u.next=null,i===null?a=g:i.next=g,i=u;var j=e.alternate;j!==null&&(j=j.updateQueue,c=j.lastBaseUpdate,c!==i&&(c===null?j.firstBaseUpdate=g:c.next=g,j.lastBaseUpdate=u))}if(a!==null){var y=r.baseState;i=0,j=g=u=null,c=a;do{var p=c.lane,x=c.eventTime;if((l&p)===p){j!==null&&(j=j.next={eventTime:x,lane:0,tag:c.tag,payload:c.payload,callback:c.callback,next:null});e:{var w=e,v=c;switch(p=n,x=s,v.tag){case 1:if(w=v.payload,typeof w=="function"){y=w.call(x,y,p);break e}y=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=v.payload,p=typeof w=="function"?w.call(x,y,p):w,p==null)break e;y=Le({},y,p);break e;case 2:Nn=!0}}c.callback!==null&&c.lane!==0&&(e.flags|=64,p=r.effects,p===null?r.effects=[c]:p.push(c))}else x={eventTime:x,lane:p,tag:c.tag,payload:c.payload,callback:c.callback,next:null},j===null?(g=j=x,u=y):j=j.next=x,i|=p;if(c=c.next,c===null){if(c=r.shared.pending,c===null)break;p=c,c=p.next,p.next=null,r.lastBaseUpdate=p,r.shared.pending=null}}while(!0);if(j===null&&(u=y),r.baseState=u,r.firstBaseUpdate=g,r.lastBaseUpdate=j,n=r.shared.interleaved,n!==null){r=n;do i|=r.lane,r=r.next;while(r!==n)}else a===null&&(r.shared.lanes=0);zs|=i,e.lanes=i,e.memoizedState=y}}function Zd(e,n,s){if(e=n.effects,n.effects=null,e!==null)for(n=0;n<e.length;n++){var l=e[n],r=l.callback;if(r!==null){if(l.callback=null,l=s,typeof r!="function")throw Error(G(191,r));r.call(l)}}}var Tr={},fn=ns(Tr),vr=ns(Tr),jr=ns(Tr);function bs(e){if(e===Tr)throw Error(G(174));return e}function yc(e,n){switch(ke(jr,n),ke(vr,e),ke(fn,Tr),e=n.nodeType,e){case 9:case 11:n=(n=n.documentElement)?n.namespaceURI:so(null,"");break;default:e=e===8?n.parentNode:n,n=e.namespaceURI||null,e=e.tagName,n=so(n,e)}ze(fn),ke(fn,n)}function wl(){ze(fn),ze(vr),ze(jr)}function sf(e){bs(jr.current);var n=bs(fn.current),s=so(n,e.type);n!==s&&(ke(vr,e),ke(fn,s))}function vc(e){vr.current===e&&(ze(fn),ze(vr))}var Re=ns(0);function Da(e){for(var n=e;n!==null;){if(n.tag===13){var s=n.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||s.data==="$?"||s.data==="$!"))return n}else if(n.tag===19&&n.memoizedProps.revealOrder!==void 0){if(n.flags&128)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var Ni=[];function jc(){for(var e=0;e<Ni.length;e++)Ni[e]._workInProgressVersionPrimary=null;Ni.length=0}var ua=Pn.ReactCurrentDispatcher,Wi=Pn.ReactCurrentBatchConfig,Cs=0,De=null,lt=null,it=null,La=!1,lr=!1,br=0,Im=0;function gt(){throw Error(G(321))}function bc(e,n){if(n===null)return!1;for(var s=0;s<n.length&&s<e.length;s++)if(!en(e[s],n[s]))return!1;return!0}function Sc(e,n,s,l,r,a){if(Cs=a,De=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,ua.current=e===null||e.memoizedState===null?Am:Rm,e=s(l,r),lr){a=0;do{if(lr=!1,br=0,25<=a)throw Error(G(301));a+=1,it=lt=null,n.updateQueue=null,ua.current=Dm,e=s(l,r)}while(lr)}if(ua.current=Oa,n=lt!==null&&lt.next!==null,Cs=0,it=lt=De=null,La=!1,n)throw Error(G(300));return e}function wc(){var e=br!==0;return br=0,e}function dn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return it===null?De.memoizedState=it=e:it=it.next=e,it}function Ht(){if(lt===null){var e=De.alternate;e=e!==null?e.memoizedState:null}else e=lt.next;var n=it===null?De.memoizedState:it.next;if(n!==null)it=n,lt=e;else{if(e===null)throw Error(G(310));lt=e,e={memoizedState:lt.memoizedState,baseState:lt.baseState,baseQueue:lt.baseQueue,queue:lt.queue,next:null},it===null?De.memoizedState=it=e:it=it.next=e}return it}function Sr(e,n){return typeof n=="function"?n(e):n}function Bi(e){var n=Ht(),s=n.queue;if(s===null)throw Error(G(311));s.lastRenderedReducer=e;var l=lt,r=l.baseQueue,a=s.pending;if(a!==null){if(r!==null){var i=r.next;r.next=a.next,a.next=i}l.baseQueue=r=a,s.pending=null}if(r!==null){a=r.next,l=l.baseState;var c=i=null,u=null,g=a;do{var j=g.lane;if((Cs&j)===j)u!==null&&(u=u.next={lane:0,action:g.action,hasEagerState:g.hasEagerState,eagerState:g.eagerState,next:null}),l=g.hasEagerState?g.eagerState:e(l,g.action);else{var y={lane:j,action:g.action,hasEagerState:g.hasEagerState,eagerState:g.eagerState,next:null};u===null?(c=u=y,i=l):u=u.next=y,De.lanes|=j,zs|=j}g=g.next}while(g!==null&&g!==a);u===null?i=l:u.next=c,en(l,n.memoizedState)||(_t=!0),n.memoizedState=l,n.baseState=i,n.baseQueue=u,s.lastRenderedState=l}if(e=s.interleaved,e!==null){r=e;do a=r.lane,De.lanes|=a,zs|=a,r=r.next;while(r!==e)}else r===null&&(s.lanes=0);return[n.memoizedState,s.dispatch]}function $i(e){var n=Ht(),s=n.queue;if(s===null)throw Error(G(311));s.lastRenderedReducer=e;var l=s.dispatch,r=s.pending,a=n.memoizedState;if(r!==null){s.pending=null;var i=r=r.next;do a=e(a,i.action),i=i.next;while(i!==r);en(a,n.memoizedState)||(_t=!0),n.memoizedState=a,n.baseQueue===null&&(n.baseState=a),s.lastRenderedState=a}return[a,l]}function lf(){}function rf(e,n){var s=De,l=Ht(),r=n(),a=!en(l.memoizedState,r);if(a&&(l.memoizedState=r,_t=!0),l=l.queue,kc(cf.bind(null,s,l,e),[e]),l.getSnapshot!==n||a||it!==null&&it.memoizedState.tag&1){if(s.flags|=2048,wr(9,of.bind(null,s,l,r,n),void 0,null),ot===null)throw Error(G(349));Cs&30||af(s,n,r)}return r}function af(e,n,s){e.flags|=16384,e={getSnapshot:n,value:s},n=De.updateQueue,n===null?(n={lastEffect:null,stores:null},De.updateQueue=n,n.stores=[e]):(s=n.stores,s===null?n.stores=[e]:s.push(e))}function of(e,n,s,l){n.value=s,n.getSnapshot=l,df(n)&&uf(e)}function cf(e,n,s){return s(function(){df(n)&&uf(e)})}function df(e){var n=e.getSnapshot;e=e.value;try{var s=n();return!en(e,s)}catch{return!0}}function uf(e){var n=En(e,1);n!==null&&Vt(n,e,1,-1)}function Vd(e){var n=dn();return typeof e=="function"&&(e=e()),n.memoizedState=n.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Sr,lastRenderedState:e},n.queue=e,e=e.dispatch=Pm.bind(null,De,e),[n.memoizedState,e]}function wr(e,n,s,l){return e={tag:e,create:n,destroy:s,deps:l,next:null},n=De.updateQueue,n===null?(n={lastEffect:null,stores:null},De.updateQueue=n,n.lastEffect=e.next=e):(s=n.lastEffect,s===null?n.lastEffect=e.next=e:(l=s.next,s.next=e,e.next=l,n.lastEffect=e)),e}function pf(){return Ht().memoizedState}function pa(e,n,s,l){var r=dn();De.flags|=e,r.memoizedState=wr(1|n,s,void 0,l===void 0?null:l)}function Ja(e,n,s,l){var r=Ht();l=l===void 0?null:l;var a=void 0;if(lt!==null){var i=lt.memoizedState;if(a=i.destroy,l!==null&&bc(l,i.deps)){r.memoizedState=wr(n,s,a,l);return}}De.flags|=e,r.memoizedState=wr(1|n,s,a,l)}function eu(e,n){return pa(8390656,8,e,n)}function kc(e,n){return Ja(2048,8,e,n)}function ff(e,n){return Ja(4,2,e,n)}function hf(e,n){return Ja(4,4,e,n)}function gf(e,n){if(typeof n=="function")return e=e(),n(e),function(){n(null)};if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function xf(e,n,s){return s=s!=null?s.concat([e]):null,Ja(4,4,gf.bind(null,n,e),s)}function _c(){}function mf(e,n){var s=Ht();n=n===void 0?null:n;var l=s.memoizedState;return l!==null&&n!==null&&bc(n,l[1])?l[0]:(s.memoizedState=[e,n],e)}function yf(e,n){var s=Ht();n=n===void 0?null:n;var l=s.memoizedState;return l!==null&&n!==null&&bc(n,l[1])?l[0]:(e=e(),s.memoizedState=[e,n],e)}function vf(e,n,s){return Cs&21?(en(s,n)||(s=wp(),De.lanes|=s,zs|=s,e.baseState=!0),n):(e.baseState&&(e.baseState=!1,_t=!0),e.memoizedState=s)}function Em(e,n){var s=be;be=s!==0&&4>s?s:4,e(!0);var l=Wi.transition;Wi.transition={};try{e(!1),n()}finally{be=s,Wi.transition=l}}function jf(){return Ht().memoizedState}function Tm(e,n,s){var l=qn(e);if(s={lane:l,action:s,hasEagerState:!1,eagerState:null,next:null},bf(e))Sf(n,s);else if(s=tf(e,n,s,l),s!==null){var r=bt();Vt(s,e,l,r),wf(s,n,l)}}function Pm(e,n,s){var l=qn(e),r={lane:l,action:s,hasEagerState:!1,eagerState:null,next:null};if(bf(e))Sf(n,r);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=n.lastRenderedReducer,a!==null))try{var i=n.lastRenderedState,c=a(i,s);if(r.hasEagerState=!0,r.eagerState=c,en(c,i)){var u=n.interleaved;u===null?(r.next=r,xc(n)):(r.next=u.next,u.next=r),n.interleaved=r;return}}catch{}finally{}s=tf(e,n,r,l),s!==null&&(r=bt(),Vt(s,e,l,r),wf(s,n,l))}}function bf(e){var n=e.alternate;return e===De||n!==null&&n===De}function Sf(e,n){lr=La=!0;var s=e.pending;s===null?n.next=n:(n.next=s.next,s.next=n),e.pending=n}function wf(e,n,s){if(s&4194240){var l=n.lanes;l&=e.pendingLanes,s|=l,n.lanes=s,nc(e,s)}}var Oa={readContext:Mt,useCallback:gt,useContext:gt,useEffect:gt,useImperativeHandle:gt,useInsertionEffect:gt,useLayoutEffect:gt,useMemo:gt,useReducer:gt,useRef:gt,useState:gt,useDebugValue:gt,useDeferredValue:gt,useTransition:gt,useMutableSource:gt,useSyncExternalStore:gt,useId:gt,unstable_isNewReconciler:!1},Am={readContext:Mt,useCallback:function(e,n){return dn().memoizedState=[e,n===void 0?null:n],e},useContext:Mt,useEffect:eu,useImperativeHandle:function(e,n,s){return s=s!=null?s.concat([e]):null,pa(4194308,4,gf.bind(null,n,e),s)},useLayoutEffect:function(e,n){return pa(4194308,4,e,n)},useInsertionEffect:function(e,n){return pa(4,2,e,n)},useMemo:function(e,n){var s=dn();return n=n===void 0?null:n,e=e(),s.memoizedState=[e,n],e},useReducer:function(e,n,s){var l=dn();return n=s!==void 0?s(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=Tm.bind(null,De,e),[l.memoizedState,e]},useRef:function(e){var n=dn();return e={current:e},n.memoizedState=e},useState:Vd,useDebugValue:_c,useDeferredValue:function(e){return dn().memoizedState=e},useTransition:function(){var e=Vd(!1),n=e[0];return e=Em.bind(null,e[1]),dn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,s){var l=De,r=dn();if(Pe){if(s===void 0)throw Error(G(407));s=s()}else{if(s=n(),ot===null)throw Error(G(349));Cs&30||af(l,n,s)}r.memoizedState=s;var a={value:s,getSnapshot:n};return r.queue=a,eu(cf.bind(null,l,a,e),[e]),l.flags|=2048,wr(9,of.bind(null,l,a,s,n),void 0,null),s},useId:function(){var e=dn(),n=ot.identifierPrefix;if(Pe){var s=_n,l=kn;s=(l&~(1<<32-Zt(l)-1)).toString(32)+s,n=":"+n+"R"+s,s=br++,0<s&&(n+="H"+s.toString(32)),n+=":"}else s=Im++,n=":"+n+"r"+s.toString(32)+":";return e.memoizedState=n},unstable_isNewReconciler:!1},Rm={readContext:Mt,useCallback:mf,useContext:Mt,useEffect:kc,useImperativeHandle:xf,useInsertionEffect:ff,useLayoutEffect:hf,useMemo:yf,useReducer:Bi,useRef:pf,useState:function(){return Bi(Sr)},useDebugValue:_c,useDeferredValue:function(e){var n=Ht();return vf(n,lt.memoizedState,e)},useTransition:function(){var e=Bi(Sr)[0],n=Ht().memoizedState;return[e,n]},useMutableSource:lf,useSyncExternalStore:rf,useId:jf,unstable_isNewReconciler:!1},Dm={readContext:Mt,useCallback:mf,useContext:Mt,useEffect:kc,useImperativeHandle:xf,useInsertionEffect:ff,useLayoutEffect:hf,useMemo:yf,useReducer:$i,useRef:pf,useState:function(){return $i(Sr)},useDebugValue:_c,useDeferredValue:function(e){var n=Ht();return lt===null?n.memoizedState=e:vf(n,lt.memoizedState,e)},useTransition:function(){var e=$i(Sr)[0],n=Ht().memoizedState;return[e,n]},useMutableSource:lf,useSyncExternalStore:rf,useId:jf,unstable_isNewReconciler:!1};function Yt(e,n){if(e&&e.defaultProps){n=Le({},n),e=e.defaultProps;for(var s in e)n[s]===void 0&&(n[s]=e[s]);return n}return n}function _o(e,n,s,l){n=e.memoizedState,s=s(l,n),s=s==null?n:Le({},n,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var Za={isMounted:function(e){return(e=e._reactInternals)?Ps(e)===e:!1},enqueueSetState:function(e,n,s){e=e._reactInternals;var l=bt(),r=qn(e),a=Cn(l,r);a.payload=n,s!=null&&(a.callback=s),n=Yn(e,a,r),n!==null&&(Vt(n,e,r,l),da(n,e,r))},enqueueReplaceState:function(e,n,s){e=e._reactInternals;var l=bt(),r=qn(e),a=Cn(l,r);a.tag=1,a.payload=n,s!=null&&(a.callback=s),n=Yn(e,a,r),n!==null&&(Vt(n,e,r,l),da(n,e,r))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var s=bt(),l=qn(e),r=Cn(s,l);r.tag=2,n!=null&&(r.callback=n),n=Yn(e,r,l),n!==null&&(Vt(n,e,l,s),da(n,e,l))}};function tu(e,n,s,l,r,a,i){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,a,i):n.prototype&&n.prototype.isPureReactComponent?!gr(s,l)||!gr(r,a):!0}function kf(e,n,s){var l=!1,r=Vn,a=n.contextType;return typeof a=="object"&&a!==null?a=Mt(a):(r=zt(n)?ks:yt.current,l=n.contextTypes,a=(l=l!=null)?jl(e,r):Vn),n=new n(s,a),e.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,n.updater=Za,e.stateNode=n,n._reactInternals=e,l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=r,e.__reactInternalMemoizedMaskedChildContext=a),n}function nu(e,n,s,l){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(s,l),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(s,l),n.state!==e&&Za.enqueueReplaceState(n,n.state,null)}function Co(e,n,s,l){var r=e.stateNode;r.props=s,r.state=e.memoizedState,r.refs={},mc(e);var a=n.contextType;typeof a=="object"&&a!==null?r.context=Mt(a):(a=zt(n)?ks:yt.current,r.context=jl(e,a)),r.state=e.memoizedState,a=n.getDerivedStateFromProps,typeof a=="function"&&(_o(e,n,a,s),r.state=e.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(n=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),n!==r.state&&Za.enqueueReplaceState(r,r.state,null),Ra(e,s,r,l),r.state=e.memoizedState),typeof r.componentDidMount=="function"&&(e.flags|=4194308)}function kl(e,n){try{var s="",l=n;do s+=ox(l),l=l.return;while(l);var r=s}catch(a){r=`
Error generating stack: `+a.message+`
`+a.stack}return{value:e,source:n,stack:r,digest:null}}function Ui(e,n,s){return{value:e,source:null,stack:s??null,digest:n??null}}function zo(e,n){try{console.error(n.value)}catch(s){setTimeout(function(){throw s})}}var Lm=typeof WeakMap=="function"?WeakMap:Map;function _f(e,n,s){s=Cn(-1,s),s.tag=3,s.payload={element:null};var l=n.value;return s.callback=function(){Wa||(Wa=!0,No=l),zo(e,n)},s}function Cf(e,n,s){s=Cn(-1,s),s.tag=3;var l=e.type.getDerivedStateFromError;if(typeof l=="function"){var r=n.value;s.payload=function(){return l(r)},s.callback=function(){zo(e,n)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch=="function"&&(s.callback=function(){zo(e,n),typeof l!="function"&&(Xn===null?Xn=new Set([this]):Xn.add(this));var i=n.stack;this.componentDidCatch(n.value,{componentStack:i!==null?i:""})}),s}function su(e,n,s){var l=e.pingCache;if(l===null){l=e.pingCache=new Lm;var r=new Set;l.set(n,r)}else r=l.get(n),r===void 0&&(r=new Set,l.set(n,r));r.has(s)||(r.add(s),e=Xm.bind(null,e,n,s),n.then(e,e))}function lu(e){do{var n;if((n=e.tag===13)&&(n=e.memoizedState,n=n!==null?n.dehydrated!==null:!0),n)return e;e=e.return}while(e!==null);return null}function ru(e,n,s,l,r){return e.mode&1?(e.flags|=65536,e.lanes=r,e):(e===n?e.flags|=65536:(e.flags|=128,s.flags|=131072,s.flags&=-52805,s.tag===1&&(s.alternate===null?s.tag=17:(n=Cn(-1,1),n.tag=2,Yn(s,n,1))),s.lanes|=1),e)}var Om=Pn.ReactCurrentOwner,_t=!1;function jt(e,n,s,l){n.child=e===null?ef(n,null,s,l):Sl(n,e.child,s,l)}function au(e,n,s,l,r){s=s.render;var a=n.ref;return ml(n,r),l=Sc(e,n,s,l,a,r),s=wc(),e!==null&&!_t?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~r,Tn(e,n,r)):(Pe&&s&&dc(n),n.flags|=1,jt(e,n,l,r),n.child)}function iu(e,n,s,l,r){if(e===null){var a=s.type;return typeof a=="function"&&!Rc(a)&&a.defaultProps===void 0&&s.compare===null&&s.defaultProps===void 0?(n.tag=15,n.type=a,zf(e,n,a,l,r)):(e=xa(s.type,null,l,n,n.mode,r),e.ref=n.ref,e.return=n,n.child=e)}if(a=e.child,!(e.lanes&r)){var i=a.memoizedProps;if(s=s.compare,s=s!==null?s:gr,s(i,l)&&e.ref===n.ref)return Tn(e,n,r)}return n.flags|=1,e=Jn(a,l),e.ref=n.ref,e.return=n,n.child=e}function zf(e,n,s,l,r){if(e!==null){var a=e.memoizedProps;if(gr(a,l)&&e.ref===n.ref)if(_t=!1,n.pendingProps=l=a,(e.lanes&r)!==0)e.flags&131072&&(_t=!0);else return n.lanes=e.lanes,Tn(e,n,r)}return Io(e,n,s,l,r)}function If(e,n,s){var l=n.pendingProps,r=l.children,a=e!==null?e.memoizedState:null;if(l.mode==="hidden")if(!(n.mode&1))n.memoizedState={baseLanes:0,cachePool:null,transitions:null},ke(ul,Rt),Rt|=s;else{if(!(s&1073741824))return e=a!==null?a.baseLanes|s:s,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e,cachePool:null,transitions:null},n.updateQueue=null,ke(ul,Rt),Rt|=e,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=a!==null?a.baseLanes:s,ke(ul,Rt),Rt|=l}else a!==null?(l=a.baseLanes|s,n.memoizedState=null):l=s,ke(ul,Rt),Rt|=l;return jt(e,n,r,s),n.child}function Ef(e,n){var s=n.ref;(e===null&&s!==null||e!==null&&e.ref!==s)&&(n.flags|=512,n.flags|=2097152)}function Io(e,n,s,l,r){var a=zt(s)?ks:yt.current;return a=jl(n,a),ml(n,r),s=Sc(e,n,s,l,a,r),l=wc(),e!==null&&!_t?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~r,Tn(e,n,r)):(Pe&&l&&dc(n),n.flags|=1,jt(e,n,s,r),n.child)}function ou(e,n,s,l,r){if(zt(s)){var a=!0;Ia(n)}else a=!1;if(ml(n,r),n.stateNode===null)fa(e,n),kf(n,s,l),Co(n,s,l,r),l=!0;else if(e===null){var i=n.stateNode,c=n.memoizedProps;i.props=c;var u=i.context,g=s.contextType;typeof g=="object"&&g!==null?g=Mt(g):(g=zt(s)?ks:yt.current,g=jl(n,g));var j=s.getDerivedStateFromProps,y=typeof j=="function"||typeof i.getSnapshotBeforeUpdate=="function";y||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(c!==l||u!==g)&&nu(n,i,l,g),Nn=!1;var p=n.memoizedState;i.state=p,Ra(n,l,i,r),u=n.memoizedState,c!==l||p!==u||Ct.current||Nn?(typeof j=="function"&&(_o(n,s,j,l),u=n.memoizedState),(c=Nn||tu(n,s,c,l,p,u,g))?(y||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"&&(n.flags|=4194308)):(typeof i.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=l,n.memoizedState=u),i.props=l,i.state=u,i.context=g,l=c):(typeof i.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{i=n.stateNode,nf(e,n),c=n.memoizedProps,g=n.type===n.elementType?c:Yt(n.type,c),i.props=g,y=n.pendingProps,p=i.context,u=s.contextType,typeof u=="object"&&u!==null?u=Mt(u):(u=zt(s)?ks:yt.current,u=jl(n,u));var x=s.getDerivedStateFromProps;(j=typeof x=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(c!==y||p!==u)&&nu(n,i,l,u),Nn=!1,p=n.memoizedState,i.state=p,Ra(n,l,i,r);var w=n.memoizedState;c!==y||p!==w||Ct.current||Nn?(typeof x=="function"&&(_o(n,s,x,l),w=n.memoizedState),(g=Nn||tu(n,s,g,l,p,w,u)||!1)?(j||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(l,w,u),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(l,w,u)),typeof i.componentDidUpdate=="function"&&(n.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof i.componentDidUpdate!="function"||c===e.memoizedProps&&p===e.memoizedState||(n.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||c===e.memoizedProps&&p===e.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=w),i.props=l,i.state=w,i.context=u,l=g):(typeof i.componentDidUpdate!="function"||c===e.memoizedProps&&p===e.memoizedState||(n.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||c===e.memoizedProps&&p===e.memoizedState||(n.flags|=1024),l=!1)}return Eo(e,n,s,l,a,r)}function Eo(e,n,s,l,r,a){Ef(e,n);var i=(n.flags&128)!==0;if(!l&&!i)return r&&Qd(n,s,!1),Tn(e,n,a);l=n.stateNode,Om.current=n;var c=i&&typeof s.getDerivedStateFromError!="function"?null:l.render();return n.flags|=1,e!==null&&i?(n.child=Sl(n,e.child,null,a),n.child=Sl(n,null,c,a)):jt(e,n,c,a),n.memoizedState=l.state,r&&Qd(n,s,!0),n.child}function Tf(e){var n=e.stateNode;n.pendingContext?Kd(e,n.pendingContext,n.pendingContext!==n.context):n.context&&Kd(e,n.context,!1),yc(e,n.containerInfo)}function cu(e,n,s,l,r){return bl(),pc(r),n.flags|=256,jt(e,n,s,l),n.child}var To={dehydrated:null,treeContext:null,retryLane:0};function Po(e){return{baseLanes:e,cachePool:null,transitions:null}}function Pf(e,n,s){var l=n.pendingProps,r=Re.current,a=!1,i=(n.flags&128)!==0,c;if((c=i)||(c=e!==null&&e.memoizedState===null?!1:(r&2)!==0),c?(a=!0,n.flags&=-129):(e===null||e.memoizedState!==null)&&(r|=1),ke(Re,r&1),e===null)return wo(n),e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(n.mode&1?e.data==="$!"?n.lanes=8:n.lanes=1073741824:n.lanes=1,null):(i=l.children,e=l.fallback,a?(l=n.mode,a=n.child,i={mode:"hidden",children:i},!(l&1)&&a!==null?(a.childLanes=0,a.pendingProps=i):a=ti(i,l,0,null),e=ws(e,l,s,null),a.return=n,e.return=n,a.sibling=e,n.child=a,n.child.memoizedState=Po(s),n.memoizedState=To,e):Cc(n,i));if(r=e.memoizedState,r!==null&&(c=r.dehydrated,c!==null))return Nm(e,n,i,l,c,r,s);if(a){a=l.fallback,i=n.mode,r=e.child,c=r.sibling;var u={mode:"hidden",children:l.children};return!(i&1)&&n.child!==r?(l=n.child,l.childLanes=0,l.pendingProps=u,n.deletions=null):(l=Jn(r,u),l.subtreeFlags=r.subtreeFlags&14680064),c!==null?a=Jn(c,a):(a=ws(a,i,s,null),a.flags|=2),a.return=n,l.return=n,l.sibling=a,n.child=l,l=a,a=n.child,i=e.child.memoizedState,i=i===null?Po(s):{baseLanes:i.baseLanes|s,cachePool:null,transitions:i.transitions},a.memoizedState=i,a.childLanes=e.childLanes&~s,n.memoizedState=To,l}return a=e.child,e=a.sibling,l=Jn(a,{mode:"visible",children:l.children}),!(n.mode&1)&&(l.lanes=s),l.return=n,l.sibling=null,e!==null&&(s=n.deletions,s===null?(n.deletions=[e],n.flags|=16):s.push(e)),n.child=l,n.memoizedState=null,l}function Cc(e,n){return n=ti({mode:"visible",children:n},e.mode,0,null),n.return=e,e.child=n}function qr(e,n,s,l){return l!==null&&pc(l),Sl(n,e.child,null,s),e=Cc(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Nm(e,n,s,l,r,a,i){if(s)return n.flags&256?(n.flags&=-257,l=Ui(Error(G(422))),qr(e,n,i,l)):n.memoizedState!==null?(n.child=e.child,n.flags|=128,null):(a=l.fallback,r=n.mode,l=ti({mode:"visible",children:l.children},r,0,null),a=ws(a,r,i,null),a.flags|=2,l.return=n,a.return=n,l.sibling=a,n.child=l,n.mode&1&&Sl(n,e.child,null,i),n.child.memoizedState=Po(i),n.memoizedState=To,a);if(!(n.mode&1))return qr(e,n,i,null);if(r.data==="$!"){if(l=r.nextSibling&&r.nextSibling.dataset,l)var c=l.dgst;return l=c,a=Error(G(419)),l=Ui(a,l,void 0),qr(e,n,i,l)}if(c=(i&e.childLanes)!==0,_t||c){if(l=ot,l!==null){switch(i&-i){case 4:r=2;break;case 16:r=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:r=32;break;case 536870912:r=268435456;break;default:r=0}r=r&(l.suspendedLanes|i)?0:r,r!==0&&r!==a.retryLane&&(a.retryLane=r,En(e,r),Vt(l,e,r,-1))}return Ac(),l=Ui(Error(G(421))),qr(e,n,i,l)}return r.data==="$?"?(n.flags|=128,n.child=e.child,n=qm.bind(null,e),r._reactRetry=n,null):(e=a.treeContext,Dt=Qn(r.nextSibling),Lt=n,Pe=!0,qt=null,e!==null&&(Bt[$t++]=kn,Bt[$t++]=_n,Bt[$t++]=_s,kn=e.id,_n=e.overflow,_s=n),n=Cc(n,l.children),n.flags|=4096,n)}function du(e,n,s){e.lanes|=n;var l=e.alternate;l!==null&&(l.lanes|=n),ko(e.return,n,s)}function Fi(e,n,s,l,r){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:s,tailMode:r}:(a.isBackwards=n,a.rendering=null,a.renderingStartTime=0,a.last=l,a.tail=s,a.tailMode=r)}function Af(e,n,s){var l=n.pendingProps,r=l.revealOrder,a=l.tail;if(jt(e,n,l.children,s),l=Re.current,l&2)l=l&1|2,n.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&du(e,s,n);else if(e.tag===19)du(e,s,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}l&=1}if(ke(Re,l),!(n.mode&1))n.memoizedState=null;else switch(r){case"forwards":for(s=n.child,r=null;s!==null;)e=s.alternate,e!==null&&Da(e)===null&&(r=s),s=s.sibling;s=r,s===null?(r=n.child,n.child=null):(r=s.sibling,s.sibling=null),Fi(n,!1,r,s,a);break;case"backwards":for(s=null,r=n.child,n.child=null;r!==null;){if(e=r.alternate,e!==null&&Da(e)===null){n.child=r;break}e=r.sibling,r.sibling=s,s=r,r=e}Fi(n,!0,s,null,a);break;case"together":Fi(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function fa(e,n){!(n.mode&1)&&e!==null&&(e.alternate=null,n.alternate=null,n.flags|=2)}function Tn(e,n,s){if(e!==null&&(n.dependencies=e.dependencies),zs|=n.lanes,!(s&n.childLanes))return null;if(e!==null&&n.child!==e.child)throw Error(G(153));if(n.child!==null){for(e=n.child,s=Jn(e,e.pendingProps),n.child=s,s.return=n;e.sibling!==null;)e=e.sibling,s=s.sibling=Jn(e,e.pendingProps),s.return=n;s.sibling=null}return n.child}function Wm(e,n,s){switch(n.tag){case 3:Tf(n),bl();break;case 5:sf(n);break;case 1:zt(n.type)&&Ia(n);break;case 4:yc(n,n.stateNode.containerInfo);break;case 10:var l=n.type._context,r=n.memoizedProps.value;ke(Pa,l._currentValue),l._currentValue=r;break;case 13:if(l=n.memoizedState,l!==null)return l.dehydrated!==null?(ke(Re,Re.current&1),n.flags|=128,null):s&n.child.childLanes?Pf(e,n,s):(ke(Re,Re.current&1),e=Tn(e,n,s),e!==null?e.sibling:null);ke(Re,Re.current&1);break;case 19:if(l=(s&n.childLanes)!==0,e.flags&128){if(l)return Af(e,n,s);n.flags|=128}if(r=n.memoizedState,r!==null&&(r.rendering=null,r.tail=null,r.lastEffect=null),ke(Re,Re.current),l)break;return null;case 22:case 23:return n.lanes=0,If(e,n,s)}return Tn(e,n,s)}var Rf,Ao,Df,Lf;Rf=function(e,n){for(var s=n.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===n)break;for(;s.sibling===null;){if(s.return===null||s.return===n)return;s=s.return}s.sibling.return=s.return,s=s.sibling}};Ao=function(){};Df=function(e,n,s,l){var r=e.memoizedProps;if(r!==l){e=n.stateNode,bs(fn.current);var a=null;switch(s){case"input":r=Vi(e,r),l=Vi(e,l),a=[];break;case"select":r=Le({},r,{value:void 0}),l=Le({},l,{value:void 0}),a=[];break;case"textarea":r=no(e,r),l=no(e,l),a=[];break;default:typeof r.onClick!="function"&&typeof l.onClick=="function"&&(e.onclick=Ca)}lo(s,l);var i;s=null;for(g in r)if(!l.hasOwnProperty(g)&&r.hasOwnProperty(g)&&r[g]!=null)if(g==="style"){var c=r[g];for(i in c)c.hasOwnProperty(i)&&(s||(s={}),s[i]="")}else g!=="dangerouslySetInnerHTML"&&g!=="children"&&g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(or.hasOwnProperty(g)?a||(a=[]):(a=a||[]).push(g,null));for(g in l){var u=l[g];if(c=r!=null?r[g]:void 0,l.hasOwnProperty(g)&&u!==c&&(u!=null||c!=null))if(g==="style")if(c){for(i in c)!c.hasOwnProperty(i)||u&&u.hasOwnProperty(i)||(s||(s={}),s[i]="");for(i in u)u.hasOwnProperty(i)&&c[i]!==u[i]&&(s||(s={}),s[i]=u[i])}else s||(a||(a=[]),a.push(g,s)),s=u;else g==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,c=c?c.__html:void 0,u!=null&&c!==u&&(a=a||[]).push(g,u)):g==="children"?typeof u!="string"&&typeof u!="number"||(a=a||[]).push(g,""+u):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&(or.hasOwnProperty(g)?(u!=null&&g==="onScroll"&&Ce("scroll",e),a||c===u||(a=[])):(a=a||[]).push(g,u))}s&&(a=a||[]).push("style",s);var g=a;(n.updateQueue=g)&&(n.flags|=4)}};Lf=function(e,n,s,l){s!==l&&(n.flags|=4)};function Fl(e,n){if(!Pe)switch(e.tailMode){case"hidden":n=e.tail;for(var s=null;n!==null;)n.alternate!==null&&(s=n),n=n.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var l=null;s!==null;)s.alternate!==null&&(l=s),s=s.sibling;l===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function xt(e){var n=e.alternate!==null&&e.alternate.child===e.child,s=0,l=0;if(n)for(var r=e.child;r!==null;)s|=r.lanes|r.childLanes,l|=r.subtreeFlags&14680064,l|=r.flags&14680064,r.return=e,r=r.sibling;else for(r=e.child;r!==null;)s|=r.lanes|r.childLanes,l|=r.subtreeFlags,l|=r.flags,r.return=e,r=r.sibling;return e.subtreeFlags|=l,e.childLanes=s,n}function Bm(e,n,s){var l=n.pendingProps;switch(uc(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return xt(n),null;case 1:return zt(n.type)&&za(),xt(n),null;case 3:return l=n.stateNode,wl(),ze(Ct),ze(yt),jc(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(Yr(n)?n.flags|=4:e===null||e.memoizedState.isDehydrated&&!(n.flags&256)||(n.flags|=1024,qt!==null&&($o(qt),qt=null))),Ao(e,n),xt(n),null;case 5:vc(n);var r=bs(jr.current);if(s=n.type,e!==null&&n.stateNode!=null)Df(e,n,s,l,r),e.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!l){if(n.stateNode===null)throw Error(G(166));return xt(n),null}if(e=bs(fn.current),Yr(n)){l=n.stateNode,s=n.type;var a=n.memoizedProps;switch(l[un]=n,l[yr]=a,e=(n.mode&1)!==0,s){case"dialog":Ce("cancel",l),Ce("close",l);break;case"iframe":case"object":case"embed":Ce("load",l);break;case"video":case"audio":for(r=0;r<Jl.length;r++)Ce(Jl[r],l);break;case"source":Ce("error",l);break;case"img":case"image":case"link":Ce("error",l),Ce("load",l);break;case"details":Ce("toggle",l);break;case"input":vd(l,a),Ce("invalid",l);break;case"select":l._wrapperState={wasMultiple:!!a.multiple},Ce("invalid",l);break;case"textarea":bd(l,a),Ce("invalid",l)}lo(s,a),r=null;for(var i in a)if(a.hasOwnProperty(i)){var c=a[i];i==="children"?typeof c=="string"?l.textContent!==c&&(a.suppressHydrationWarning!==!0&&Qr(l.textContent,c,e),r=["children",c]):typeof c=="number"&&l.textContent!==""+c&&(a.suppressHydrationWarning!==!0&&Qr(l.textContent,c,e),r=["children",""+c]):or.hasOwnProperty(i)&&c!=null&&i==="onScroll"&&Ce("scroll",l)}switch(s){case"input":Br(l),jd(l,a,!0);break;case"textarea":Br(l),Sd(l);break;case"select":case"option":break;default:typeof a.onClick=="function"&&(l.onclick=Ca)}l=r,n.updateQueue=l,l!==null&&(n.flags|=4)}else{i=r.nodeType===9?r:r.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=op(s)),e==="http://www.w3.org/1999/xhtml"?s==="script"?(e=i.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=i.createElement(s,{is:l.is}):(e=i.createElement(s),s==="select"&&(i=e,l.multiple?i.multiple=!0:l.size&&(i.size=l.size))):e=i.createElementNS(e,s),e[un]=n,e[yr]=l,Rf(e,n,!1,!1),n.stateNode=e;e:{switch(i=ro(s,l),s){case"dialog":Ce("cancel",e),Ce("close",e),r=l;break;case"iframe":case"object":case"embed":Ce("load",e),r=l;break;case"video":case"audio":for(r=0;r<Jl.length;r++)Ce(Jl[r],e);r=l;break;case"source":Ce("error",e),r=l;break;case"img":case"image":case"link":Ce("error",e),Ce("load",e),r=l;break;case"details":Ce("toggle",e),r=l;break;case"input":vd(e,l),r=Vi(e,l),Ce("invalid",e);break;case"option":r=l;break;case"select":e._wrapperState={wasMultiple:!!l.multiple},r=Le({},l,{value:void 0}),Ce("invalid",e);break;case"textarea":bd(e,l),r=no(e,l),Ce("invalid",e);break;default:r=l}lo(s,r),c=r;for(a in c)if(c.hasOwnProperty(a)){var u=c[a];a==="style"?up(e,u):a==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,u!=null&&cp(e,u)):a==="children"?typeof u=="string"?(s!=="textarea"||u!=="")&&cr(e,u):typeof u=="number"&&cr(e,""+u):a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&a!=="autoFocus"&&(or.hasOwnProperty(a)?u!=null&&a==="onScroll"&&Ce("scroll",e):u!=null&&qo(e,a,u,i))}switch(s){case"input":Br(e),jd(e,l,!1);break;case"textarea":Br(e),Sd(e);break;case"option":l.value!=null&&e.setAttribute("value",""+Zn(l.value));break;case"select":e.multiple=!!l.multiple,a=l.value,a!=null?fl(e,!!l.multiple,a,!1):l.defaultValue!=null&&fl(e,!!l.multiple,l.defaultValue,!0);break;default:typeof r.onClick=="function"&&(e.onclick=Ca)}switch(s){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}}l&&(n.flags|=4)}n.ref!==null&&(n.flags|=512,n.flags|=2097152)}return xt(n),null;case 6:if(e&&n.stateNode!=null)Lf(e,n,e.memoizedProps,l);else{if(typeof l!="string"&&n.stateNode===null)throw Error(G(166));if(s=bs(jr.current),bs(fn.current),Yr(n)){if(l=n.stateNode,s=n.memoizedProps,l[un]=n,(a=l.nodeValue!==s)&&(e=Lt,e!==null))switch(e.tag){case 3:Qr(l.nodeValue,s,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Qr(l.nodeValue,s,(e.mode&1)!==0)}a&&(n.flags|=4)}else l=(s.nodeType===9?s:s.ownerDocument).createTextNode(l),l[un]=n,n.stateNode=l}return xt(n),null;case 13:if(ze(Re),l=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Pe&&Dt!==null&&n.mode&1&&!(n.flags&128))Zp(),bl(),n.flags|=98560,a=!1;else if(a=Yr(n),l!==null&&l.dehydrated!==null){if(e===null){if(!a)throw Error(G(318));if(a=n.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(G(317));a[un]=n}else bl(),!(n.flags&128)&&(n.memoizedState=null),n.flags|=4;xt(n),a=!1}else qt!==null&&($o(qt),qt=null),a=!0;if(!a)return n.flags&65536?n:null}return n.flags&128?(n.lanes=s,n):(l=l!==null,l!==(e!==null&&e.memoizedState!==null)&&l&&(n.child.flags|=8192,n.mode&1&&(e===null||Re.current&1?rt===0&&(rt=3):Ac())),n.updateQueue!==null&&(n.flags|=4),xt(n),null);case 4:return wl(),Ao(e,n),e===null&&xr(n.stateNode.containerInfo),xt(n),null;case 10:return gc(n.type._context),xt(n),null;case 17:return zt(n.type)&&za(),xt(n),null;case 19:if(ze(Re),a=n.memoizedState,a===null)return xt(n),null;if(l=(n.flags&128)!==0,i=a.rendering,i===null)if(l)Fl(a,!1);else{if(rt!==0||e!==null&&e.flags&128)for(e=n.child;e!==null;){if(i=Da(e),i!==null){for(n.flags|=128,Fl(a,!1),l=i.updateQueue,l!==null&&(n.updateQueue=l,n.flags|=4),n.subtreeFlags=0,l=s,s=n.child;s!==null;)a=s,e=l,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 ke(Re,Re.current&1|2),n.child}e=e.sibling}a.tail!==null&&Xe()>_l&&(n.flags|=128,l=!0,Fl(a,!1),n.lanes=4194304)}else{if(!l)if(e=Da(i),e!==null){if(n.flags|=128,l=!0,s=e.updateQueue,s!==null&&(n.updateQueue=s,n.flags|=4),Fl(a,!0),a.tail===null&&a.tailMode==="hidden"&&!i.alternate&&!Pe)return xt(n),null}else 2*Xe()-a.renderingStartTime>_l&&s!==1073741824&&(n.flags|=128,l=!0,Fl(a,!1),n.lanes=4194304);a.isBackwards?(i.sibling=n.child,n.child=i):(s=a.last,s!==null?s.sibling=i:n.child=i,a.last=i)}return a.tail!==null?(n=a.tail,a.rendering=n,a.tail=n.sibling,a.renderingStartTime=Xe(),n.sibling=null,s=Re.current,ke(Re,l?s&1|2:s&1),n):(xt(n),null);case 22:case 23:return Pc(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&n.mode&1?Rt&1073741824&&(xt(n),n.subtreeFlags&6&&(n.flags|=8192)):xt(n),null;case 24:return null;case 25:return null}throw Error(G(156,n.tag))}function $m(e,n){switch(uc(n),n.tag){case 1:return zt(n.type)&&za(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return wl(),ze(Ct),ze(yt),jc(),e=n.flags,e&65536&&!(e&128)?(n.flags=e&-65537|128,n):null;case 5:return vc(n),null;case 13:if(ze(Re),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(G(340));bl()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return ze(Re),null;case 4:return wl(),null;case 10:return gc(n.type._context),null;case 22:case 23:return Pc(),null;case 24:return null;default:return null}}var Jr=!1,mt=!1,Um=typeof WeakSet=="function"?WeakSet:Set,J=null;function dl(e,n){var s=e.ref;if(s!==null)if(typeof s=="function")try{s(null)}catch(l){Fe(e,n,l)}else s.current=null}function Ro(e,n,s){try{s()}catch(l){Fe(e,n,l)}}var uu=!1;function Fm(e,n){if(xo=wa,e=Bp(),cc(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var l=s.getSelection&&s.getSelection();if(l&&l.rangeCount!==0){s=l.anchorNode;var r=l.anchorOffset,a=l.focusNode;l=l.focusOffset;try{s.nodeType,a.nodeType}catch{s=null;break e}var i=0,c=-1,u=-1,g=0,j=0,y=e,p=null;t:for(;;){for(var x;y!==s||r!==0&&y.nodeType!==3||(c=i+r),y!==a||l!==0&&y.nodeType!==3||(u=i+l),y.nodeType===3&&(i+=y.nodeValue.length),(x=y.firstChild)!==null;)p=y,y=x;for(;;){if(y===e)break t;if(p===s&&++g===r&&(c=i),p===a&&++j===l&&(u=i),(x=y.nextSibling)!==null)break;y=p,p=y.parentNode}y=x}s=c===-1||u===-1?null:{start:c,end:u}}else s=null}s=s||{start:0,end:0}}else s=null;for(mo={focusedElem:e,selectionRange:s},wa=!1,J=n;J!==null;)if(n=J,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,J=e;else for(;J!==null;){n=J;try{var w=n.alternate;if(n.flags&1024)switch(n.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var v=w.memoizedProps,S=w.memoizedState,m=n.stateNode,o=m.getSnapshotBeforeUpdate(n.elementType===n.type?v:Yt(n.type,v),S);m.__reactInternalSnapshotBeforeUpdate=o}break;case 3:var d=n.stateNode.containerInfo;d.nodeType===1?d.textContent="":d.nodeType===9&&d.documentElement&&d.removeChild(d.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(G(163))}}catch(f){Fe(n,n.return,f)}if(e=n.sibling,e!==null){e.return=n.return,J=e;break}J=n.return}return w=uu,uu=!1,w}function rr(e,n,s){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var r=l=l.next;do{if((r.tag&e)===e){var a=r.destroy;r.destroy=void 0,a!==void 0&&Ro(n,s,a)}r=r.next}while(r!==l)}}function Va(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var s=n=n.next;do{if((s.tag&e)===e){var l=s.create;s.destroy=l()}s=s.next}while(s!==n)}}function Do(e){var n=e.ref;if(n!==null){var s=e.stateNode;switch(e.tag){case 5:e=s;break;default:e=s}typeof n=="function"?n(e):n.current=e}}function Of(e){var n=e.alternate;n!==null&&(e.alternate=null,Of(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[un],delete n[yr],delete n[jo],delete n[km],delete n[_m])),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 Nf(e){return e.tag===5||e.tag===3||e.tag===4}function pu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Nf(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 Lo(e,n,s){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?s.nodeType===8?s.parentNode.insertBefore(e,n):s.insertBefore(e,n):(s.nodeType===8?(n=s.parentNode,n.insertBefore(e,s)):(n=s,n.appendChild(e)),s=s._reactRootContainer,s!=null||n.onclick!==null||(n.onclick=Ca));else if(l!==4&&(e=e.child,e!==null))for(Lo(e,n,s),e=e.sibling;e!==null;)Lo(e,n,s),e=e.sibling}function Oo(e,n,s){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?s.insertBefore(e,n):s.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(Oo(e,n,s),e=e.sibling;e!==null;)Oo(e,n,s),e=e.sibling}var dt=null,Xt=!1;function Dn(e,n,s){for(s=s.child;s!==null;)Wf(e,n,s),s=s.sibling}function Wf(e,n,s){if(pn&&typeof pn.onCommitFiberUnmount=="function")try{pn.onCommitFiberUnmount(Ga,s)}catch{}switch(s.tag){case 5:mt||dl(s,n);case 6:var l=dt,r=Xt;dt=null,Dn(e,n,s),dt=l,Xt=r,dt!==null&&(Xt?(e=dt,s=s.stateNode,e.nodeType===8?e.parentNode.removeChild(s):e.removeChild(s)):dt.removeChild(s.stateNode));break;case 18:dt!==null&&(Xt?(e=dt,s=s.stateNode,e.nodeType===8?Li(e.parentNode,s):e.nodeType===1&&Li(e,s),fr(e)):Li(dt,s.stateNode));break;case 4:l=dt,r=Xt,dt=s.stateNode.containerInfo,Xt=!0,Dn(e,n,s),dt=l,Xt=r;break;case 0:case 11:case 14:case 15:if(!mt&&(l=s.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){r=l=l.next;do{var a=r,i=a.destroy;a=a.tag,i!==void 0&&(a&2||a&4)&&Ro(s,n,i),r=r.next}while(r!==l)}Dn(e,n,s);break;case 1:if(!mt&&(dl(s,n),l=s.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=s.memoizedProps,l.state=s.memoizedState,l.componentWillUnmount()}catch(c){Fe(s,n,c)}Dn(e,n,s);break;case 21:Dn(e,n,s);break;case 22:s.mode&1?(mt=(l=mt)||s.memoizedState!==null,Dn(e,n,s),mt=l):Dn(e,n,s);break;default:Dn(e,n,s)}}function fu(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var s=e.stateNode;s===null&&(s=e.stateNode=new Um),n.forEach(function(l){var r=Jm.bind(null,e,l);s.has(l)||(s.add(l),l.then(r,r))})}}function Qt(e,n){var s=n.deletions;if(s!==null)for(var l=0;l<s.length;l++){var r=s[l];try{var a=e,i=n,c=i;e:for(;c!==null;){switch(c.tag){case 5:dt=c.stateNode,Xt=!1;break e;case 3:dt=c.stateNode.containerInfo,Xt=!0;break e;case 4:dt=c.stateNode.containerInfo,Xt=!0;break e}c=c.return}if(dt===null)throw Error(G(160));Wf(a,i,r),dt=null,Xt=!1;var u=r.alternate;u!==null&&(u.return=null),r.return=null}catch(g){Fe(r,n,g)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)Bf(n,e),n=n.sibling}function Bf(e,n){var s=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Qt(n,e),an(e),l&4){try{rr(3,e,e.return),Va(3,e)}catch(v){Fe(e,e.return,v)}try{rr(5,e,e.return)}catch(v){Fe(e,e.return,v)}}break;case 1:Qt(n,e),an(e),l&512&&s!==null&&dl(s,s.return);break;case 5:if(Qt(n,e),an(e),l&512&&s!==null&&dl(s,s.return),e.flags&32){var r=e.stateNode;try{cr(r,"")}catch(v){Fe(e,e.return,v)}}if(l&4&&(r=e.stateNode,r!=null)){var a=e.memoizedProps,i=s!==null?s.memoizedProps:a,c=e.type,u=e.updateQueue;if(e.updateQueue=null,u!==null)try{c==="input"&&a.type==="radio"&&a.name!=null&&ap(r,a),ro(c,i);var g=ro(c,a);for(i=0;i<u.length;i+=2){var j=u[i],y=u[i+1];j==="style"?up(r,y):j==="dangerouslySetInnerHTML"?cp(r,y):j==="children"?cr(r,y):qo(r,j,y,g)}switch(c){case"input":eo(r,a);break;case"textarea":ip(r,a);break;case"select":var p=r._wrapperState.wasMultiple;r._wrapperState.wasMultiple=!!a.multiple;var x=a.value;x!=null?fl(r,!!a.multiple,x,!1):p!==!!a.multiple&&(a.defaultValue!=null?fl(r,!!a.multiple,a.defaultValue,!0):fl(r,!!a.multiple,a.multiple?[]:"",!1))}r[yr]=a}catch(v){Fe(e,e.return,v)}}break;case 6:if(Qt(n,e),an(e),l&4){if(e.stateNode===null)throw Error(G(162));r=e.stateNode,a=e.memoizedProps;try{r.nodeValue=a}catch(v){Fe(e,e.return,v)}}break;case 3:if(Qt(n,e),an(e),l&4&&s!==null&&s.memoizedState.isDehydrated)try{fr(n.containerInfo)}catch(v){Fe(e,e.return,v)}break;case 4:Qt(n,e),an(e);break;case 13:Qt(n,e),an(e),r=e.child,r.flags&8192&&(a=r.memoizedState!==null,r.stateNode.isHidden=a,!a||r.alternate!==null&&r.alternate.memoizedState!==null||(Ec=Xe())),l&4&&fu(e);break;case 22:if(j=s!==null&&s.memoizedState!==null,e.mode&1?(mt=(g=mt)||j,Qt(n,e),mt=g):Qt(n,e),an(e),l&8192){if(g=e.memoizedState!==null,(e.stateNode.isHidden=g)&&!j&&e.mode&1)for(J=e,j=e.child;j!==null;){for(y=J=j;J!==null;){switch(p=J,x=p.child,p.tag){case 0:case 11:case 14:case 15:rr(4,p,p.return);break;case 1:dl(p,p.return);var w=p.stateNode;if(typeof w.componentWillUnmount=="function"){l=p,s=p.return;try{n=l,w.props=n.memoizedProps,w.state=n.memoizedState,w.componentWillUnmount()}catch(v){Fe(l,s,v)}}break;case 5:dl(p,p.return);break;case 22:if(p.memoizedState!==null){gu(y);continue}}x!==null?(x.return=p,J=x):gu(y)}j=j.sibling}e:for(j=null,y=e;;){if(y.tag===5){if(j===null){j=y;try{r=y.stateNode,g?(a=r.style,typeof a.setProperty=="function"?a.setProperty("display","none","important"):a.display="none"):(c=y.stateNode,u=y.memoizedProps.style,i=u!=null&&u.hasOwnProperty("display")?u.display:null,c.style.display=dp("display",i))}catch(v){Fe(e,e.return,v)}}}else if(y.tag===6){if(j===null)try{y.stateNode.nodeValue=g?"":y.memoizedProps}catch(v){Fe(e,e.return,v)}}else if((y.tag!==22&&y.tag!==23||y.memoizedState===null||y===e)&&y.child!==null){y.child.return=y,y=y.child;continue}if(y===e)break e;for(;y.sibling===null;){if(y.return===null||y.return===e)break e;j===y&&(j=null),y=y.return}j===y&&(j=null),y.sibling.return=y.return,y=y.sibling}}break;case 19:Qt(n,e),an(e),l&4&&fu(e);break;case 21:break;default:Qt(n,e),an(e)}}function an(e){var n=e.flags;if(n&2){try{e:{for(var s=e.return;s!==null;){if(Nf(s)){var l=s;break e}s=s.return}throw Error(G(160))}switch(l.tag){case 5:var r=l.stateNode;l.flags&32&&(cr(r,""),l.flags&=-33);var a=pu(e);Oo(e,a,r);break;case 3:case 4:var i=l.stateNode.containerInfo,c=pu(e);Lo(e,c,i);break;default:throw Error(G(161))}}catch(u){Fe(e,e.return,u)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function Mm(e,n,s){J=e,$f(e)}function $f(e,n,s){for(var l=(e.mode&1)!==0;J!==null;){var r=J,a=r.child;if(r.tag===22&&l){var i=r.memoizedState!==null||Jr;if(!i){var c=r.alternate,u=c!==null&&c.memoizedState!==null||mt;c=Jr;var g=mt;if(Jr=i,(mt=u)&&!g)for(J=r;J!==null;)i=J,u=i.child,i.tag===22&&i.memoizedState!==null?xu(r):u!==null?(u.return=i,J=u):xu(r);for(;a!==null;)J=a,$f(a),a=a.sibling;J=r,Jr=c,mt=g}hu(e)}else r.subtreeFlags&8772&&a!==null?(a.return=r,J=a):hu(e)}}function hu(e){for(;J!==null;){var n=J;if(n.flags&8772){var s=n.alternate;try{if(n.flags&8772)switch(n.tag){case 0:case 11:case 15:mt||Va(5,n);break;case 1:var l=n.stateNode;if(n.flags&4&&!mt)if(s===null)l.componentDidMount();else{var r=n.elementType===n.type?s.memoizedProps:Yt(n.type,s.memoizedProps);l.componentDidUpdate(r,s.memoizedState,l.__reactInternalSnapshotBeforeUpdate)}var a=n.updateQueue;a!==null&&Zd(n,a,l);break;case 3:var i=n.updateQueue;if(i!==null){if(s=null,n.child!==null)switch(n.child.tag){case 5:s=n.child.stateNode;break;case 1:s=n.child.stateNode}Zd(n,i,s)}break;case 5:var c=n.stateNode;if(s===null&&n.flags&4){s=c;var u=n.memoizedProps;switch(n.type){case"button":case"input":case"select":case"textarea":u.autoFocus&&s.focus();break;case"img":u.src&&(s.src=u.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(n.memoizedState===null){var g=n.alternate;if(g!==null){var j=g.memoizedState;if(j!==null){var y=j.dehydrated;y!==null&&fr(y)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(G(163))}mt||n.flags&512&&Do(n)}catch(p){Fe(n,n.return,p)}}if(n===e){J=null;break}if(s=n.sibling,s!==null){s.return=n.return,J=s;break}J=n.return}}function gu(e){for(;J!==null;){var n=J;if(n===e){J=null;break}var s=n.sibling;if(s!==null){s.return=n.return,J=s;break}J=n.return}}function xu(e){for(;J!==null;){var n=J;try{switch(n.tag){case 0:case 11:case 15:var s=n.return;try{Va(4,n)}catch(u){Fe(n,s,u)}break;case 1:var l=n.stateNode;if(typeof l.componentDidMount=="function"){var r=n.return;try{l.componentDidMount()}catch(u){Fe(n,r,u)}}var a=n.return;try{Do(n)}catch(u){Fe(n,a,u)}break;case 5:var i=n.return;try{Do(n)}catch(u){Fe(n,i,u)}}}catch(u){Fe(n,n.return,u)}if(n===e){J=null;break}var c=n.sibling;if(c!==null){c.return=n.return,J=c;break}J=n.return}}var Hm=Math.ceil,Na=Pn.ReactCurrentDispatcher,zc=Pn.ReactCurrentOwner,Ft=Pn.ReactCurrentBatchConfig,ge=0,ot=null,et=null,ut=0,Rt=0,ul=ns(0),rt=0,kr=null,zs=0,ei=0,Ic=0,ar=null,kt=null,Ec=0,_l=1/0,Sn=null,Wa=!1,No=null,Xn=null,Zr=!1,Un=null,Ba=0,ir=0,Wo=null,ha=-1,ga=0;function bt(){return ge&6?Xe():ha!==-1?ha:ha=Xe()}function qn(e){return e.mode&1?ge&2&&ut!==0?ut&-ut:zm.transition!==null?(ga===0&&(ga=wp()),ga):(e=be,e!==0||(e=window.event,e=e===void 0?16:Tp(e.type)),e):1}function Vt(e,n,s,l){if(50<ir)throw ir=0,Wo=null,Error(G(185));zr(e,s,l),(!(ge&2)||e!==ot)&&(e===ot&&(!(ge&2)&&(ei|=s),rt===4&&Bn(e,ut)),It(e,l),s===1&&ge===0&&!(n.mode&1)&&(_l=Xe()+500,qa&&ss()))}function It(e,n){var s=e.callbackNode;zx(e,n);var l=Sa(e,e===ot?ut:0);if(l===0)s!==null&&_d(s),e.callbackNode=null,e.callbackPriority=0;else if(n=l&-l,e.callbackPriority!==n){if(s!=null&&_d(s),n===1)e.tag===0?Cm(mu.bind(null,e)):Xp(mu.bind(null,e)),Sm(function(){!(ge&6)&&ss()}),s=null;else{switch(kp(l)){case 1:s=tc;break;case 4:s=bp;break;case 16:s=ba;break;case 536870912:s=Sp;break;default:s=ba}s=Yf(s,Uf.bind(null,e))}e.callbackPriority=n,e.callbackNode=s}}function Uf(e,n){if(ha=-1,ga=0,ge&6)throw Error(G(327));var s=e.callbackNode;if(yl()&&e.callbackNode!==s)return null;var l=Sa(e,e===ot?ut:0);if(l===0)return null;if(l&30||l&e.expiredLanes||n)n=$a(e,l);else{n=l;var r=ge;ge|=2;var a=Mf();(ot!==e||ut!==n)&&(Sn=null,_l=Xe()+500,Ss(e,n));do try{Qm();break}catch(c){Ff(e,c)}while(!0);hc(),Na.current=a,ge=r,et!==null?n=0:(ot=null,ut=0,n=rt)}if(n!==0){if(n===2&&(r=uo(e),r!==0&&(l=r,n=Bo(e,r))),n===1)throw s=kr,Ss(e,0),Bn(e,l),It(e,Xe()),s;if(n===6)Bn(e,l);else{if(r=e.current.alternate,!(l&30)&&!Gm(r)&&(n=$a(e,l),n===2&&(a=uo(e),a!==0&&(l=a,n=Bo(e,a))),n===1))throw s=kr,Ss(e,0),Bn(e,l),It(e,Xe()),s;switch(e.finishedWork=r,e.finishedLanes=l,n){case 0:case 1:throw Error(G(345));case 2:ys(e,kt,Sn);break;case 3:if(Bn(e,l),(l&130023424)===l&&(n=Ec+500-Xe(),10<n)){if(Sa(e,0)!==0)break;if(r=e.suspendedLanes,(r&l)!==l){bt(),e.pingedLanes|=e.suspendedLanes&r;break}e.timeoutHandle=vo(ys.bind(null,e,kt,Sn),n);break}ys(e,kt,Sn);break;case 4:if(Bn(e,l),(l&4194240)===l)break;for(n=e.eventTimes,r=-1;0<l;){var i=31-Zt(l);a=1<<i,i=n[i],i>r&&(r=i),l&=~a}if(l=r,l=Xe()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Hm(l/1960))-l,10<l){e.timeoutHandle=vo(ys.bind(null,e,kt,Sn),l);break}ys(e,kt,Sn);break;case 5:ys(e,kt,Sn);break;default:throw Error(G(329))}}}return It(e,Xe()),e.callbackNode===s?Uf.bind(null,e):null}function Bo(e,n){var s=ar;return e.current.memoizedState.isDehydrated&&(Ss(e,n).flags|=256),e=$a(e,n),e!==2&&(n=kt,kt=s,n!==null&&$o(n)),e}function $o(e){kt===null?kt=e:kt.push.apply(kt,e)}function Gm(e){for(var n=e;;){if(n.flags&16384){var s=n.updateQueue;if(s!==null&&(s=s.stores,s!==null))for(var l=0;l<s.length;l++){var r=s[l],a=r.getSnapshot;r=r.value;try{if(!en(a(),r))return!1}catch{return!1}}}if(s=n.child,n.subtreeFlags&16384&&s!==null)s.return=n,n=s;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Bn(e,n){for(n&=~Ic,n&=~ei,e.suspendedLanes|=n,e.pingedLanes&=~n,e=e.expirationTimes;0<n;){var s=31-Zt(n),l=1<<s;e[s]=-1,n&=~l}}function mu(e){if(ge&6)throw Error(G(327));yl();var n=Sa(e,0);if(!(n&1))return It(e,Xe()),null;var s=$a(e,n);if(e.tag!==0&&s===2){var l=uo(e);l!==0&&(n=l,s=Bo(e,l))}if(s===1)throw s=kr,Ss(e,0),Bn(e,n),It(e,Xe()),s;if(s===6)throw Error(G(345));return e.finishedWork=e.current.alternate,e.finishedLanes=n,ys(e,kt,Sn),It(e,Xe()),null}function Tc(e,n){var s=ge;ge|=1;try{return e(n)}finally{ge=s,ge===0&&(_l=Xe()+500,qa&&ss())}}function Is(e){Un!==null&&Un.tag===0&&!(ge&6)&&yl();var n=ge;ge|=1;var s=Ft.transition,l=be;try{if(Ft.transition=null,be=1,e)return e()}finally{be=l,Ft.transition=s,ge=n,!(ge&6)&&ss()}}function Pc(){Rt=ul.current,ze(ul)}function Ss(e,n){e.finishedWork=null,e.finishedLanes=0;var s=e.timeoutHandle;if(s!==-1&&(e.timeoutHandle=-1,bm(s)),et!==null)for(s=et.return;s!==null;){var l=s;switch(uc(l),l.tag){case 1:l=l.type.childContextTypes,l!=null&&za();break;case 3:wl(),ze(Ct),ze(yt),jc();break;case 5:vc(l);break;case 4:wl();break;case 13:ze(Re);break;case 19:ze(Re);break;case 10:gc(l.type._context);break;case 22:case 23:Pc()}s=s.return}if(ot=e,et=e=Jn(e.current,null),ut=Rt=n,rt=0,kr=null,Ic=ei=zs=0,kt=ar=null,js!==null){for(n=0;n<js.length;n++)if(s=js[n],l=s.interleaved,l!==null){s.interleaved=null;var r=l.next,a=s.pending;if(a!==null){var i=a.next;a.next=r,l.next=i}s.pending=l}js=null}return e}function Ff(e,n){do{var s=et;try{if(hc(),ua.current=Oa,La){for(var l=De.memoizedState;l!==null;){var r=l.queue;r!==null&&(r.pending=null),l=l.next}La=!1}if(Cs=0,it=lt=De=null,lr=!1,br=0,zc.current=null,s===null||s.return===null){rt=1,kr=n,et=null;break}e:{var a=e,i=s.return,c=s,u=n;if(n=ut,c.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){var g=u,j=c,y=j.tag;if(!(j.mode&1)&&(y===0||y===11||y===15)){var p=j.alternate;p?(j.updateQueue=p.updateQueue,j.memoizedState=p.memoizedState,j.lanes=p.lanes):(j.updateQueue=null,j.memoizedState=null)}var x=lu(i);if(x!==null){x.flags&=-257,ru(x,i,c,a,n),x.mode&1&&su(a,g,n),n=x,u=g;var w=n.updateQueue;if(w===null){var v=new Set;v.add(u),n.updateQueue=v}else w.add(u);break e}else{if(!(n&1)){su(a,g,n),Ac();break e}u=Error(G(426))}}else if(Pe&&c.mode&1){var S=lu(i);if(S!==null){!(S.flags&65536)&&(S.flags|=256),ru(S,i,c,a,n),pc(kl(u,c));break e}}a=u=kl(u,c),rt!==4&&(rt=2),ar===null?ar=[a]:ar.push(a),a=i;do{switch(a.tag){case 3:a.flags|=65536,n&=-n,a.lanes|=n;var m=_f(a,u,n);Jd(a,m);break e;case 1:c=u;var o=a.type,d=a.stateNode;if(!(a.flags&128)&&(typeof o.getDerivedStateFromError=="function"||d!==null&&typeof d.componentDidCatch=="function"&&(Xn===null||!Xn.has(d)))){a.flags|=65536,n&=-n,a.lanes|=n;var f=Cf(a,c,n);Jd(a,f);break e}}a=a.return}while(a!==null)}Gf(s)}catch(z){n=z,et===s&&s!==null&&(et=s=s.return);continue}break}while(!0)}function Mf(){var e=Na.current;return Na.current=Oa,e===null?Oa:e}function Ac(){(rt===0||rt===3||rt===2)&&(rt=4),ot===null||!(zs&268435455)&&!(ei&268435455)||Bn(ot,ut)}function $a(e,n){var s=ge;ge|=2;var l=Mf();(ot!==e||ut!==n)&&(Sn=null,Ss(e,n));do try{Km();break}catch(r){Ff(e,r)}while(!0);if(hc(),ge=s,Na.current=l,et!==null)throw Error(G(261));return ot=null,ut=0,rt}function Km(){for(;et!==null;)Hf(et)}function Qm(){for(;et!==null&&!yx();)Hf(et)}function Hf(e){var n=Qf(e.alternate,e,Rt);e.memoizedProps=e.pendingProps,n===null?Gf(e):et=n,zc.current=null}function Gf(e){var n=e;do{var s=n.alternate;if(e=n.return,n.flags&32768){if(s=$m(s,n),s!==null){s.flags&=32767,et=s;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{rt=6,et=null;return}}else if(s=Bm(s,n,Rt),s!==null){et=s;return}if(n=n.sibling,n!==null){et=n;return}et=n=e}while(n!==null);rt===0&&(rt=5)}function ys(e,n,s){var l=be,r=Ft.transition;try{Ft.transition=null,be=1,Ym(e,n,s,l)}finally{Ft.transition=r,be=l}return null}function Ym(e,n,s,l){do yl();while(Un!==null);if(ge&6)throw Error(G(327));s=e.finishedWork;var r=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(Ix(e,a),e===ot&&(et=ot=null,ut=0),!(s.subtreeFlags&2064)&&!(s.flags&2064)||Zr||(Zr=!0,Yf(ba,function(){return yl(),null})),a=(s.flags&15990)!==0,s.subtreeFlags&15990||a){a=Ft.transition,Ft.transition=null;var i=be;be=1;var c=ge;ge|=4,zc.current=null,Fm(e,s),Bf(s,e),hm(mo),wa=!!xo,mo=xo=null,e.current=s,Mm(s),vx(),ge=c,be=i,Ft.transition=a}else e.current=s;if(Zr&&(Zr=!1,Un=e,Ba=r),a=e.pendingLanes,a===0&&(Xn=null),Sx(s.stateNode),It(e,Xe()),n!==null)for(l=e.onRecoverableError,s=0;s<n.length;s++)r=n[s],l(r.value,{componentStack:r.stack,digest:r.digest});if(Wa)throw Wa=!1,e=No,No=null,e;return Ba&1&&e.tag!==0&&yl(),a=e.pendingLanes,a&1?e===Wo?ir++:(ir=0,Wo=e):ir=0,ss(),null}function yl(){if(Un!==null){var e=kp(Ba),n=Ft.transition,s=be;try{if(Ft.transition=null,be=16>e?16:e,Un===null)var l=!1;else{if(e=Un,Un=null,Ba=0,ge&6)throw Error(G(331));var r=ge;for(ge|=4,J=e.current;J!==null;){var a=J,i=a.child;if(J.flags&16){var c=a.deletions;if(c!==null){for(var u=0;u<c.length;u++){var g=c[u];for(J=g;J!==null;){var j=J;switch(j.tag){case 0:case 11:case 15:rr(8,j,a)}var y=j.child;if(y!==null)y.return=j,J=y;else for(;J!==null;){j=J;var p=j.sibling,x=j.return;if(Of(j),j===g){J=null;break}if(p!==null){p.return=x,J=p;break}J=x}}}var w=a.alternate;if(w!==null){var v=w.child;if(v!==null){w.child=null;do{var S=v.sibling;v.sibling=null,v=S}while(v!==null)}}J=a}}if(a.subtreeFlags&2064&&i!==null)i.return=a,J=i;else e:for(;J!==null;){if(a=J,a.flags&2048)switch(a.tag){case 0:case 11:case 15:rr(9,a,a.return)}var m=a.sibling;if(m!==null){m.return=a.return,J=m;break e}J=a.return}}var o=e.current;for(J=o;J!==null;){i=J;var d=i.child;if(i.subtreeFlags&2064&&d!==null)d.return=i,J=d;else e:for(i=o;J!==null;){if(c=J,c.flags&2048)try{switch(c.tag){case 0:case 11:case 15:Va(9,c)}}catch(z){Fe(c,c.return,z)}if(c===i){J=null;break e}var f=c.sibling;if(f!==null){f.return=c.return,J=f;break e}J=c.return}}if(ge=r,ss(),pn&&typeof pn.onPostCommitFiberRoot=="function")try{pn.onPostCommitFiberRoot(Ga,e)}catch{}l=!0}return l}finally{be=s,Ft.transition=n}}return!1}function yu(e,n,s){n=kl(s,n),n=_f(e,n,1),e=Yn(e,n,1),n=bt(),e!==null&&(zr(e,1,n),It(e,n))}function Fe(e,n,s){if(e.tag===3)yu(e,e,s);else for(;n!==null;){if(n.tag===3){yu(n,e,s);break}else if(n.tag===1){var l=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(Xn===null||!Xn.has(l))){e=kl(s,e),e=Cf(n,e,1),n=Yn(n,e,1),e=bt(),n!==null&&(zr(n,1,e),It(n,e));break}}n=n.return}}function Xm(e,n,s){var l=e.pingCache;l!==null&&l.delete(n),n=bt(),e.pingedLanes|=e.suspendedLanes&s,ot===e&&(ut&s)===s&&(rt===4||rt===3&&(ut&130023424)===ut&&500>Xe()-Ec?Ss(e,0):Ic|=s),It(e,n)}function Kf(e,n){n===0&&(e.mode&1?(n=Fr,Fr<<=1,!(Fr&130023424)&&(Fr=4194304)):n=1);var s=bt();e=En(e,n),e!==null&&(zr(e,n,s),It(e,s))}function qm(e){var n=e.memoizedState,s=0;n!==null&&(s=n.retryLane),Kf(e,s)}function Jm(e,n){var s=0;switch(e.tag){case 13:var l=e.stateNode,r=e.memoizedState;r!==null&&(s=r.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(G(314))}l!==null&&l.delete(n),Kf(e,s)}var Qf;Qf=function(e,n,s){if(e!==null)if(e.memoizedProps!==n.pendingProps||Ct.current)_t=!0;else{if(!(e.lanes&s)&&!(n.flags&128))return _t=!1,Wm(e,n,s);_t=!!(e.flags&131072)}else _t=!1,Pe&&n.flags&1048576&&qp(n,Ta,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;fa(e,n),e=n.pendingProps;var r=jl(n,yt.current);ml(n,s),r=Sc(null,n,l,e,r,s);var a=wc();return n.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,zt(l)?(a=!0,Ia(n)):a=!1,n.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,mc(n),r.updater=Za,n.stateNode=r,r._reactInternals=n,Co(n,l,e,s),n=Eo(null,n,l,!0,a,s)):(n.tag=0,Pe&&a&&dc(n),jt(null,n,r,s),n=n.child),n;case 16:l=n.elementType;e:{switch(fa(e,n),e=n.pendingProps,r=l._init,l=r(l._payload),n.type=l,r=n.tag=Vm(l),e=Yt(l,e),r){case 0:n=Io(null,n,l,e,s);break e;case 1:n=ou(null,n,l,e,s);break e;case 11:n=au(null,n,l,e,s);break e;case 14:n=iu(null,n,l,Yt(l.type,e),s);break e}throw Error(G(306,l,""))}return n;case 0:return l=n.type,r=n.pendingProps,r=n.elementType===l?r:Yt(l,r),Io(e,n,l,r,s);case 1:return l=n.type,r=n.pendingProps,r=n.elementType===l?r:Yt(l,r),ou(e,n,l,r,s);case 3:e:{if(Tf(n),e===null)throw Error(G(387));l=n.pendingProps,a=n.memoizedState,r=a.element,nf(e,n),Ra(n,l,null,s);var i=n.memoizedState;if(l=i.element,a.isDehydrated)if(a={element:l,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},n.updateQueue.baseState=a,n.memoizedState=a,n.flags&256){r=kl(Error(G(423)),n),n=cu(e,n,l,s,r);break e}else if(l!==r){r=kl(Error(G(424)),n),n=cu(e,n,l,s,r);break e}else for(Dt=Qn(n.stateNode.containerInfo.firstChild),Lt=n,Pe=!0,qt=null,s=ef(n,null,l,s),n.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(bl(),l===r){n=Tn(e,n,s);break e}jt(e,n,l,s)}n=n.child}return n;case 5:return sf(n),e===null&&wo(n),l=n.type,r=n.pendingProps,a=e!==null?e.memoizedProps:null,i=r.children,yo(l,r)?i=null:a!==null&&yo(l,a)&&(n.flags|=32),Ef(e,n),jt(e,n,i,s),n.child;case 6:return e===null&&wo(n),null;case 13:return Pf(e,n,s);case 4:return yc(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=Sl(n,null,l,s):jt(e,n,l,s),n.child;case 11:return l=n.type,r=n.pendingProps,r=n.elementType===l?r:Yt(l,r),au(e,n,l,r,s);case 7:return jt(e,n,n.pendingProps,s),n.child;case 8:return jt(e,n,n.pendingProps.children,s),n.child;case 12:return jt(e,n,n.pendingProps.children,s),n.child;case 10:e:{if(l=n.type._context,r=n.pendingProps,a=n.memoizedProps,i=r.value,ke(Pa,l._currentValue),l._currentValue=i,a!==null)if(en(a.value,i)){if(a.children===r.children&&!Ct.current){n=Tn(e,n,s);break e}}else for(a=n.child,a!==null&&(a.return=n);a!==null;){var c=a.dependencies;if(c!==null){i=a.child;for(var u=c.firstContext;u!==null;){if(u.context===l){if(a.tag===1){u=Cn(-1,s&-s),u.tag=2;var g=a.updateQueue;if(g!==null){g=g.shared;var j=g.pending;j===null?u.next=u:(u.next=j.next,j.next=u),g.pending=u}}a.lanes|=s,u=a.alternate,u!==null&&(u.lanes|=s),ko(a.return,s,n),c.lanes|=s;break}u=u.next}}else if(a.tag===10)i=a.type===n.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),ko(i,s,n),i=a.sibling}else i=a.child;if(i!==null)i.return=a;else for(i=a;i!==null;){if(i===n){i=null;break}if(a=i.sibling,a!==null){a.return=i.return,i=a;break}i=i.return}a=i}jt(e,n,r.children,s),n=n.child}return n;case 9:return r=n.type,l=n.pendingProps.children,ml(n,s),r=Mt(r),l=l(r),n.flags|=1,jt(e,n,l,s),n.child;case 14:return l=n.type,r=Yt(l,n.pendingProps),r=Yt(l.type,r),iu(e,n,l,r,s);case 15:return zf(e,n,n.type,n.pendingProps,s);case 17:return l=n.type,r=n.pendingProps,r=n.elementType===l?r:Yt(l,r),fa(e,n),n.tag=1,zt(l)?(e=!0,Ia(n)):e=!1,ml(n,s),kf(n,l,r),Co(n,l,r,s),Eo(null,n,l,!0,e,s);case 19:return Af(e,n,s);case 22:return If(e,n,s)}throw Error(G(156,n.tag))};function Yf(e,n){return jp(e,n)}function Zm(e,n,s,l){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=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ut(e,n,s,l){return new Zm(e,n,s,l)}function Rc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Vm(e){if(typeof e=="function")return Rc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Zo)return 11;if(e===Vo)return 14}return 2}function Jn(e,n){var s=e.alternate;return s===null?(s=Ut(e.tag,n,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=n,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,n=e.dependencies,s.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s}function xa(e,n,s,l,r,a){var i=2;if(l=e,typeof e=="function")Rc(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case tl:return ws(s.children,r,a,n);case Jo:i=8,r|=8;break;case Xi:return e=Ut(12,s,n,r|2),e.elementType=Xi,e.lanes=a,e;case qi:return e=Ut(13,s,n,r),e.elementType=qi,e.lanes=a,e;case Ji:return e=Ut(19,s,n,r),e.elementType=Ji,e.lanes=a,e;case sp:return ti(s,r,a,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case tp:i=10;break e;case np:i=9;break e;case Zo:i=11;break e;case Vo:i=14;break e;case On:i=16,l=null;break e}throw Error(G(130,e==null?e:typeof e,""))}return n=Ut(i,s,n,r),n.elementType=e,n.type=l,n.lanes=a,n}function ws(e,n,s,l){return e=Ut(7,e,l,n),e.lanes=s,e}function ti(e,n,s,l){return e=Ut(22,e,l,n),e.elementType=sp,e.lanes=s,e.stateNode={isHidden:!1},e}function Mi(e,n,s){return e=Ut(6,e,null,n),e.lanes=s,e}function Hi(e,n,s){return n=Ut(4,e.children!==null?e.children:[],e.key,n),n.lanes=s,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function ey(e,n,s,l,r){this.tag=n,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=ki(0),this.expirationTimes=ki(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ki(0),this.identifierPrefix=l,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function Dc(e,n,s,l,r,a,i,c,u){return e=new ey(e,n,s,c,u),n===1?(n=1,a===!0&&(n|=8)):n=0,a=Ut(3,null,null,n),e.current=a,a.stateNode=e,a.memoizedState={element:l,isDehydrated:s,cache:null,transitions:null,pendingSuspenseBoundaries:null},mc(a),e}function ty(e,n,s){var l=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:el,key:l==null?null:""+l,children:e,containerInfo:n,implementation:s}}function Xf(e){if(!e)return Vn;e=e._reactInternals;e:{if(Ps(e)!==e||e.tag!==1)throw Error(G(170));var n=e;do{switch(n.tag){case 3:n=n.stateNode.context;break e;case 1:if(zt(n.type)){n=n.stateNode.__reactInternalMemoizedMergedChildContext;break e}}n=n.return}while(n!==null);throw Error(G(171))}if(e.tag===1){var s=e.type;if(zt(s))return Yp(e,s,n)}return n}function qf(e,n,s,l,r,a,i,c,u){return e=Dc(s,l,!0,e,r,a,i,c,u),e.context=Xf(null),s=e.current,l=bt(),r=qn(s),a=Cn(l,r),a.callback=n??null,Yn(s,a,r),e.current.lanes=r,zr(e,r,l),It(e,l),e}function ni(e,n,s,l){var r=n.current,a=bt(),i=qn(r);return s=Xf(s),n.context===null?n.context=s:n.pendingContext=s,n=Cn(a,i),n.payload={element:e},l=l===void 0?null:l,l!==null&&(n.callback=l),e=Yn(r,n,i),e!==null&&(Vt(e,r,i,a),da(e,r,i)),i}function Ua(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 vu(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<n?s:n}}function Lc(e,n){vu(e,n),(e=e.alternate)&&vu(e,n)}function ny(){return null}var Jf=typeof reportError=="function"?reportError:function(e){console.error(e)};function Oc(e){this._internalRoot=e}si.prototype.render=Oc.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(G(409));ni(e,n,null,null)};si.prototype.unmount=Oc.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;Is(function(){ni(null,e,null,null)}),n[In]=null}};function si(e){this._internalRoot=e}si.prototype.unstable_scheduleHydration=function(e){if(e){var n=zp();e={blockedOn:null,target:e,priority:n};for(var s=0;s<Wn.length&&n!==0&&n<Wn[s].priority;s++);Wn.splice(s,0,e),s===0&&Ep(e)}};function Nc(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function li(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function ju(){}function sy(e,n,s,l,r){if(r){if(typeof l=="function"){var a=l;l=function(){var g=Ua(i);a.call(g)}}var i=qf(n,l,e,0,null,!1,!1,"",ju);return e._reactRootContainer=i,e[In]=i.current,xr(e.nodeType===8?e.parentNode:e),Is(),i}for(;r=e.lastChild;)e.removeChild(r);if(typeof l=="function"){var c=l;l=function(){var g=Ua(u);c.call(g)}}var u=Dc(e,0,!1,null,null,!1,!1,"",ju);return e._reactRootContainer=u,e[In]=u.current,xr(e.nodeType===8?e.parentNode:e),Is(function(){ni(n,u,s,l)}),u}function ri(e,n,s,l,r){var a=s._reactRootContainer;if(a){var i=a;if(typeof r=="function"){var c=r;r=function(){var u=Ua(i);c.call(u)}}ni(n,i,e,r)}else i=sy(s,n,e,r,l);return Ua(i)}_p=function(e){switch(e.tag){case 3:var n=e.stateNode;if(n.current.memoizedState.isDehydrated){var s=ql(n.pendingLanes);s!==0&&(nc(n,s|1),It(n,Xe()),!(ge&6)&&(_l=Xe()+500,ss()))}break;case 13:Is(function(){var l=En(e,1);if(l!==null){var r=bt();Vt(l,e,1,r)}}),Lc(e,1)}};sc=function(e){if(e.tag===13){var n=En(e,134217728);if(n!==null){var s=bt();Vt(n,e,134217728,s)}Lc(e,134217728)}};Cp=function(e){if(e.tag===13){var n=qn(e),s=En(e,n);if(s!==null){var l=bt();Vt(s,e,n,l)}Lc(e,n)}};zp=function(){return be};Ip=function(e,n){var s=be;try{return be=e,n()}finally{be=s}};io=function(e,n,s){switch(n){case"input":if(eo(e,s),n=s.name,s.type==="radio"&&n!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll("input[name="+JSON.stringify(""+n)+'][type="radio"]'),n=0;n<s.length;n++){var l=s[n];if(l!==e&&l.form===e.form){var r=Xa(l);if(!r)throw Error(G(90));rp(l),eo(l,r)}}}break;case"textarea":ip(e,s);break;case"select":n=s.value,n!=null&&fl(e,!!s.multiple,n,!1)}};hp=Tc;gp=Is;var ly={usingClientEntryPoint:!1,Events:[Er,rl,Xa,pp,fp,Tc]},Ml={findFiberByHostInstance:vs,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ry={bundleType:Ml.bundleType,version:Ml.version,rendererPackageName:Ml.rendererPackageName,rendererConfig:Ml.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Pn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=yp(e),e===null?null:e.stateNode},findFiberByHostInstance:Ml.findFiberByHostInstance||ny,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 Vr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Vr.isDisabled&&Vr.supportsFiber)try{Ga=Vr.inject(ry),pn=Vr}catch{}}Nt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ly;Nt.createPortal=function(e,n){var s=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Nc(n))throw Error(G(200));return ty(e,n,null,s)};Nt.createRoot=function(e,n){if(!Nc(e))throw Error(G(299));var s=!1,l="",r=Jf;return n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onRecoverableError!==void 0&&(r=n.onRecoverableError)),n=Dc(e,1,!1,null,null,s,!1,l,r),e[In]=n.current,xr(e.nodeType===8?e.parentNode:e),new Oc(n)};Nt.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(G(188)):(e=Object.keys(e).join(","),Error(G(268,e)));return e=yp(n),e=e===null?null:e.stateNode,e};Nt.flushSync=function(e){return Is(e)};Nt.hydrate=function(e,n,s){if(!li(n))throw Error(G(200));return ri(null,e,n,!0,s)};Nt.hydrateRoot=function(e,n,s){if(!Nc(e))throw Error(G(405));var l=s!=null&&s.hydratedSources||null,r=!1,a="",i=Jf;if(s!=null&&(s.unstable_strictMode===!0&&(r=!0),s.identifierPrefix!==void 0&&(a=s.identifierPrefix),s.onRecoverableError!==void 0&&(i=s.onRecoverableError)),n=qf(n,null,e,1,s??null,r,!1,a,i),e[In]=n.current,xr(e),l)for(e=0;e<l.length;e++)s=l[e],r=s._getVersion,r=r(s._source),n.mutableSourceEagerHydrationData==null?n.mutableSourceEagerHydrationData=[s,r]:n.mutableSourceEagerHydrationData.push(s,r);return new si(n)};Nt.render=function(e,n,s){if(!li(n))throw Error(G(200));return ri(null,e,n,!1,s)};Nt.unmountComponentAtNode=function(e){if(!li(e))throw Error(G(40));return e._reactRootContainer?(Is(function(){ri(null,null,e,!1,function(){e._reactRootContainer=null,e[In]=null})}),!0):!1};Nt.unstable_batchedUpdates=Tc;Nt.unstable_renderSubtreeIntoContainer=function(e,n,s,l){if(!li(s))throw Error(G(200));if(e==null||e._reactInternals===void 0)throw Error(G(38));return ri(e,n,s,!1,l)};Nt.version="18.3.1-next-f1338f8080-20240426";function Zf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Zf)}catch(e){console.error(e)}}Zf(),Ju.exports=Nt;var ay=Ju.exports,Vf,bu=ay;Vf=bu.createRoot,bu.hydrateRoot;const de="",O={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"},iy=[{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"}],eh=[{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"}],oy=new Set(["users","group-companies"]);function cy(e){return e!=="Admin"&&e!=="Auditor"?[]:eh.filter(({id:n})=>e==="Admin"||!oy.has(n))}const Ln=(e=[])=>[{key:"name1",label:"Name"},{key:"status",label:"Status"},...e,{key:"creation_date",label:"Created On"}],Me={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:Ln(),defaultColumns:["name1","status","creation_date"]},"idea-types":{label:"Idea Types",columns:Ln(),defaultColumns:["name1","status","creation_date"]},"order-types":{label:"Order Types",columns:Ln(),defaultColumns:["name1","status","creation_date"]},"process-types":{label:"Process Types",columns:Ln(),defaultColumns:["name1","status","creation_date"]},"incident-statuses":{label:"Incident Statuses",columns:Ln([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"idea-statuses":{label:"Idea Statuses",columns:Ln([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"order-statuses":{label:"Order Statuses",columns:Ln([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"process-statuses":{label:"Process Statuses",columns:Ln([{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:"Delegator"},{key:"manager",label:"Manager"},{key:"organization",label:"Organization"},{key:"incident_initial_evaluation",label:"Incident Initial Evaluation"},{key:"idea_initial_evaluation",label:"Idea Initial Evaluation"},{key:"status",label:"Status"},{key:"requested_on",label:"Requested On"},{key:"responded_on",label:"Responded On"}],defaultColumns:["number","auditor","manager","organization","incident_initial_evaluation","idea_initial_evaluation","status","requested_on"]},"group-companies":{label:"Group Companies",columns:[{key:"company_name",label:"Company Name"},{key:"code",label:"Code"},{key:"acronym",label:"Acronym"},{key:"owner_user",label:"Group Co Owner"},{key:"status",label:"Status"}],defaultColumns:["company_name","code","acronym","owner_user","status"]}},dy=()=>t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),uy=()=>t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),py=()=>t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6l-1 14H6L5 6"}),t.jsx("path",{d:"M10 11v6M14 11v6"}),t.jsx("path",{d:"M9 6V4h6v2"})]});function at({onView:e,onEdit:n,onDelete:s}){const l=(r,a,i,c,u,g)=>c?t.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),c()},title:g,style:{width:30,height:30,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:"1px solid transparent",cursor:"pointer",background:r,color:i,flexShrink:0,transition:"all 0.15s ease"},onMouseEnter:j=>{j.currentTarget.style.background=a,j.currentTarget.style.transform="scale(1.08)"},onMouseLeave:j=>{j.currentTarget.style.background=r,j.currentTarget.style.transform="scale(1)"},children:u},g):null;return t.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[l("#f0f9ff","#e0f2fe","#0284c7",e,t.jsx(dy,{}),"View"),l("#f0fdf4","#dcfce7","#16a34a",n,t.jsx(uy,{}),"Edit"),s&&l("#fff1f2","#fee2e2","#e11d48",s,t.jsx(py,{}),"Delete")]})}const A={width:"100%",height:34,padding:"7px 10px",border:"1px solid #ddd",borderRadius:6,fontSize:12,boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif"},E={display:"block",marginBottom:5,fontSize:11,color:"#555",fontWeight:600};function fy(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 ye(e,n){return e.filter(s=>fy(s)||s.name===n)}const hy={incident:["Rejected","Executed & Closed"],idea:["Rejected","Executed & Closed"],order:["Closed"],process:["Closed"]};function Fn(e,n){return!!n&&hy[e].includes(n)}function Cl(e,n,s,l){return e.filter(r=>{const a=n[r.name]||[];return!(a.includes("SB Admin")||a.includes("System Manager")||!a.includes(s)||l&&r.custom_organization&&r.custom_organization!==l)})}const zl={width:16,height:16,cursor:"pointer",accentColor:"#2563eb",flexShrink:0};function ma(e){const n=(e||"").trim().toLowerCase();return n==="new"||n==="initial evaluation"||n==="draft"?{bg:"#eff6ff",color:"#1d4ed8",border:"#bfdbfe"}:n.includes("progress")||n.includes("review")||n.includes("proposal")||n.includes("resolution")?{bg:"#fefce8",color:"#a16207",border:"#fef08a"}:n.includes("executed")||n.includes("approved")||n.includes("active")||n.includes("closed")||n.includes("completed")?{bg:"#f0fdf4",color:"#15803d",border:"#bbf7d0"}:n.includes("rejected")||n.includes("overdue")||n.includes("fail")||n.includes("inactive")?{bg:"#fef2f2",color:"#b91c1c",border:"#fecaca"}:n.includes("deleted")?{bg:"#fff1f2",color:"#e11d48",border:"#fecdd3"}:{bg:"#f8fafc",color:"#475569",border:"#e2e8f0"}}function gy(e){const n=(e||"").trim().toLowerCase();return n.includes("incident")?{bg:"#f1f5f9",color:"#334155",border:"#cbd5e1"}:n.includes("complaint")?{bg:"#fff7ed",color:"#c2410c",border:"#fed7aa"}:n.includes("violation")?{bg:"#faf5ff",color:"#7e22ce",border:"#e9d5ff"}:n.includes("process")?{bg:"#f0fdfa",color:"#0f766e",border:"#99f6e4"}:n.includes("asset")?{bg:"#ecfeff",color:"#0e7490",border:"#a5f3fc"}:n.includes("human")?{bg:"#f5f3ff",color:"#6d28d9",border:"#ddd6fe"}:n.includes("idea")?{bg:"#ecfdf5",color:"#047857",border:"#a7f3d0"}:n.includes("study")?{bg:"#eff6ff",color:"#1d4ed8",border:"#bfdbfe"}:{bg:"#f8fafc",color:"#475569",border:"#e2e8f0"}}const _r=(e,n)=>{let s;return typeof n=="object"&&n!==null?s=n:typeof n=="string"&&n.startsWith("#")?s=ma(e):typeof n=="string"?s=ma(n):s=ma(e),t.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})},es=e=>_r(e,ma(e)),Wc=e=>_r(e,gy(e));function Pr({deletedBy:e,deletedOn:n,reason:s,onRestore:l,isRestoring:r}){return t.jsxs("div",{style:{background:"#fff1f2",border:"1px solid #fecdd3",borderRadius:8,padding:"7px 14px",marginBottom:12,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,color:"#9f1239",fontSize:12,flexWrap:"wrap"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsxs("div",{style:{fontWeight:700,fontSize:12,display:"flex",alignItems:"center",gap:5,color:"#be123c",whiteSpace:"nowrap"},children:[t.jsx("span",{style:{fontSize:13},children:"⚠️"}),t.jsx("span",{children:"DELETED RECORD / سجل محذوف"})]}),t.jsxs("div",{style:{fontSize:11,color:"#881337",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e&&t.jsxs("span",{children:[t.jsx("strong",{children:"Deleted By:"})," ",e]}),n&&t.jsxs("span",{children:["| ",t.jsx("strong",{children:"Deleted On:"})," ",n]}),s&&t.jsxs("span",{children:["| ",t.jsx("strong",{children:"Reason:"})," ",s]})]})]}),l&&t.jsxs("button",{type:"button",onClick:l,disabled:r,style:{background:"#e11d48",color:"white",border:"none",borderRadius:6,padding:"5px 12px",fontSize:11,fontWeight:700,cursor:r?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:5,whiteSpace:"nowrap",transition:"all 0.15s ease"},onMouseEnter:a=>{r||(a.currentTarget.style.background="#be123c")},onMouseLeave:a=>{r||(a.currentTarget.style.background="#e11d48")},children:[t.jsx("span",{children:"↺"}),t.jsx("span",{children:r?"Restoring...":"Restore Record / استعادة"})]})]})}function ai({onDelete:e,disabled:n,title:s="Delete Request",btnText:l="Delete"}){return t.jsxs("div",{style:{background:"#ffffff",borderRadius:10,padding:14,border:"1px solid #fee2e2",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:s}),t.jsxs("button",{type:"button",onClick:e,disabled:n,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:"#dc2626",color:"#ffffff",fontWeight:700,fontSize:12,cursor:n?"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:r=>{n||(r.currentTarget.style.background="#b91c1c")},onMouseLeave:r=>{n||(r.currentTarget.style.background="#dc2626")},children:[t.jsx("span",{children:"🗑️"}),t.jsx("span",{children:l})]})]})}function re({title:e,children:n,style:s}){return t.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:[t.jsx("div",{style:{fontSize:14,fontWeight:700,color:"#1e293b",marginBottom:14,display:"flex",alignItems:"center",gap:8},children:t.jsx("span",{children:e})}),n]})}function ii({title:e="Status Summary",priority:n,createdDate:s,modifiedDate:l,assignedTo:r,status:a}){const i=c=>{if(!c)return"—";try{const u=new Date(c);return isNaN(u.getTime())?c:u.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return c}};return t.jsxs("div",{style:{background:"#ffffff",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:12},children:e}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[n&&t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:3},children:"Priority"}),t.jsx("div",{style:{fontSize:13,fontWeight:700,color:n==="High"||n==="Urgent"?"#dc2626":"#1e293b"},children:n})]}),a&&t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:3},children:"Status"}),t.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#334155"},children:a})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:3},children:"Assigned To"}),t.jsx("div",{style:{fontSize:12,fontWeight:600,color:r?"#334155":"#94a3b8",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r||"—"})]}),s&&t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:2},children:"Created"}),t.jsx("div",{style:{fontSize:11,color:"#64748b"},children:i(s)})]}),l&&t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:2},children:"Last Modified"}),t.jsx("div",{style:{fontSize:11,color:"#64748b"},children:i(l)})]})]})]})}const xy="modulepreload",my=function(e){return"/"+e},Su={},yy=function(n,s,l){let r=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"));r=Promise.allSettled(s.map(u=>{if(u=my(u),u in Su)return;Su[u]=!0;const g=u.endsWith(".css"),j=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${j}`))return;const y=document.createElement("link");if(y.rel=g?"stylesheet":xy,g||(y.as="script"),y.crossOrigin="",y.href=u,c&&y.setAttribute("nonce",c),document.head.appendChild(y),g)return new Promise((p,x)=>{y.addEventListener("load",p),y.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${u}`)))})}))}function a(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return r.then(i=>{for(const c of i||[])c.status==="rejected"&&a(c.reason);return n().catch(a)})};function th(e,n){const s=e[n.key];return s==null||s===""?"":typeof s=="object"?JSON.stringify(s):String(s)}function vy(e,n){const s=URL.createObjectURL(e),l=document.createElement("a");l.href=s,l.download=n,l.click(),URL.revokeObjectURL(s)}function He(e,n,s){const l=e.map(i=>`"${i.label.replace(/"/g,'""')}"`).join(","),r=n.map(i=>e.map(c=>`"${th(i,c).replace(/"/g,'""')}"`).join(",")).join(`
`),a=new Blob([l+`
`+r],{type:"text/csv;charset=utf-8;"});vy(a,`${s}.csv`)}async function Ge(e,n,s){const l=await yy(()=>import("./xlsx-D_0l8YDs.js"),[]),r=n.map(c=>{const u={};for(const g of e)u[g.label]=th(c,g);return u}),a=l.utils.json_to_sheet(r,{header:e.map(c=>c.label)}),i=l.utils.book_new();l.utils.book_append_sheet(i,a,"Export"),l.writeFile(i,`${s}.xlsx`)}const ea="#16a34a";function jy({title:e,rows:n,columns:s,defaultColumnKeys:l,orgField:r,organizations:a,filenameBase:i,onClose:c}){const[u,g]=C.useState(""),[j,y]=C.useState("csv"),[p,x]=C.useState(new Set(l)),w=u?n.filter(f=>f[r||"organization"]===u):n,v=s.filter(f=>p.has(f.key)),S=f=>{x(z=>{const b=new Set(z);return b.has(f)?b.delete(f):b.add(f),b})},m=async()=>{v.length===0||w.length===0||(j==="csv"?He(v,w,i):await Ge(v,w,i),c())},o={fontSize:11,fontWeight:700,color:"#9ca3af",letterSpacing:.4,textTransform:"uppercase",marginBottom:10},d={background:"none",border:"none",color:"#2563eb",fontSize:12,fontWeight:600,cursor:"pointer",padding:0,fontFamily:"inherit"};return t.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:t.jsxs("div",{onClick:f=>f.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:[t.jsxs("div",{style:{background:ea,color:"white",padding:"16px 22px",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:16,fontWeight:700},children:[t.jsx("span",{style:{fontSize:18},children:"📤"})," Export ",e]}),t.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:"✕"})]}),t.jsxs("div",{style:{padding:"20px 22px",overflowY:"auto",flex:1},children:[r&&a&&a.length>0&&t.jsxs("div",{style:{marginBottom:20},children:[t.jsx("div",{style:o,children:"Filter by Organization"}),t.jsxs("select",{value:u,onChange:f=>g(f.target.value),style:{width:"100%",padding:"9px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",boxSizing:"border-box"},children:[t.jsxs("option",{value:"",children:["All Organizations (",n.length," total)"]}),a.map(f=>t.jsx("option",{value:f.name,children:f.organization_name||f.name},f.name))]})]}),t.jsxs("div",{style:{marginBottom:20},children:[t.jsx("div",{style:o,children:"File Format"}),t.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(f=>t.jsxs("div",{onClick:()=>y(f.id),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",borderRadius:10,cursor:"pointer",border:`2px solid ${j===f.id?ea:"#e5e7eb"}`,background:j===f.id?"#f0fdf4":"white"},children:[t.jsx("span",{style:{fontSize:20},children:f.id==="csv"?"📄":"📊"}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:f.label}),t.jsx("div",{style:{fontSize:11,color:"#888"},children:f.desc})]})]},f.id))})]}),t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[t.jsx("div",{style:{...o,marginBottom:0},children:"Columns to Export"}),t.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[t.jsx("button",{onClick:()=>x(new Set(s.map(f=>f.key))),style:d,children:"Select All"}),t.jsx("span",{style:{color:"#d1d5db"},children:"|"}),t.jsx("button",{onClick:()=>x(new Set(l)),style:d,children:"Reset to Default"})]})]}),t.jsx("div",{style:{border:"1px solid #e5e7eb",borderRadius:8,padding:12,maxHeight:170,overflowY:"auto"},children:t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"10px 12px"},children:s.map(f=>t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:7,fontSize:13,color:"#374151",cursor:"pointer"},children:[t.jsx("input",{type:"checkbox",checked:p.has(f.key),onChange:()=>S(f.key),style:{accentColor:ea,cursor:"pointer"}}),f.label]},f.key))})}),t.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:6},children:[p.size," column",p.size!==1?"s":""," selected"]})]})]}),t.jsxs("div",{style:{padding:"14px 22px",borderTop:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[t.jsx("span",{style:{fontSize:12,color:"#888"},children:u?`Exporting ${w.length} filtered row${w.length!==1?"s":""}`:`Exporting all ${w.length} row${w.length!==1?"s":""}`}),t.jsxs("div",{style:{display:"flex",gap:10},children:[t.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"}),t.jsx("button",{onClick:m,disabled:v.length===0||w.length===0,style:{padding:"9px 20px",borderRadius:8,border:"none",background:ea,color:"white",fontWeight:700,fontSize:13,cursor:v.length===0||w.length===0?"not-allowed":"pointer",opacity:v.length===0||w.length===0?.5:1,fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"})]})]})]})})}const nh="sidrah_rtl",Uo="sidrah-lang-change";function pl(){try{return localStorage.getItem(nh)==="1"}catch{return!1}}function sh(){const e=!pl();try{localStorage.setItem(nh,e?"1":"0")}catch{}document.documentElement.setAttribute("dir",e?"rtl":"ltr"),document.documentElement.setAttribute("lang",e?"ar":"en-GB"),window.dispatchEvent(new CustomEvent(Uo))}function ne(){const[e,n]=C.useState(pl);return C.useEffect(()=>{const s=()=>n(pl());return window.addEventListener(Uo,s),document.documentElement.setAttribute("dir",pl()?"rtl":"ltr"),document.documentElement.setAttribute("lang",pl()?"ar":"en-GB"),()=>window.removeEventListener(Uo,s)},[]),e?Sy:by}const by={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"}},Sy={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 wu({isOpen:e,doctype:n,docname:s,docTitle:l,isAdmin:r,isDeleting:a,onClose:i,onConfirmSoftDelete:c,onConfirmPermanentDelete:u}){const g=ne(),[j,y]=C.useState("");if(C.useEffect(()=>{e&&y("")},[e]),C.useEffect(()=>{const x=w=>{w.key==="Escape"&&e&&!a&&i()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[e,a,i]),!e)return null;const p=n.replace(/^SB\s+/,"");return t.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:x=>{x.target===x.currentTarget&&!a&&i()},children:t.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:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:12},children:[t.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"#fee2e2",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"#ef4444"},children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.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"}),t.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),t.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("h3",{style:{margin:0,fontSize:14,fontWeight:700,color:"#1e293b"},children:g.deleteModal.title}),t.jsx("p",{style:{margin:"2px 0 0",fontSize:11,color:"#64748b",lineHeight:1.3},children:g.deleteModal.subtitle})]}),t.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:"✕"})]}),t.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:6,padding:"6px 10px",marginBottom:12,display:"flex",alignItems:"center",gap:6},children:[t.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#64748b",textTransform:"uppercase",letterSpacing:"0.4px",flexShrink:0},children:[p,":"]}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#1e293b",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l?`${l} (${s})`:s})]}),t.jsxs("div",{style:{marginBottom:14},children:[t.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:"#475569",marginBottom:4},children:g.deleteModal.reasonLabel}),t.jsx("input",{type:"text",value:j,onChange:x=>y(x.target.value),placeholder:g.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:x=>{x.target.style.borderColor="#6366f1",x.target.style.boxShadow="0 0 0 2px rgba(99, 102, 241, 0.15)"},onBlur:x=>{x.target.style.borderColor="#cbd5e1",x.target.style.boxShadow="none"}})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",gap:8,flexWrap:"wrap"},children:[t.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:g.deleteModal.cancelBtn}),t.jsxs("button",{type:"button",onClick:()=>c(j),disabled:a,title:g.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:x=>{a||(x.currentTarget.style.background="#fee2e2")},onMouseLeave:x=>{a||(x.currentTarget.style.background="#fff1f2")},children:[t.jsx("span",{children:"🗑️"}),a?g.deleteModal.deleting:g.deleteModal.softDeleteBtn]}),r&&t.jsxs("button",{type:"button",onClick:()=>u(j),disabled:a,title:g.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:x=>{a||(x.currentTarget.style.background="#dc2626")},onMouseLeave:x=>{a||(x.currentTarget.style.background="#ef4444")},children:[t.jsx("span",{children:"💥"}),a?g.deleteModal.deleting:g.deleteModal.permanentDeleteBtn]})]})]})})}const lh="/assets/logo-BlYgMyx5.png";function rh({collapsed:e,onToggleCollapsed:n,activePage:s,onNavigate:l,hasDashboard:r,hasReports:a,hasDelegations:i,role:c,hideSettings:u,rtl:g,navLabels:j,settingsLabel:y}){const p=u?[]:cy(c);return t.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:[t.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:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,overflow:"hidden"},children:[t.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:t.jsx("img",{src:lh,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"contain"},onError:x=>{x.currentTarget.style.display="none"}})}),!e&&t.jsx("div",{style:{display:"flex",flexDirection:"column"},children:t.jsx("span",{style:{fontSize:14,fontWeight:800,whiteSpace:"nowrap",color:"#ffffff",letterSpacing:"-0.2px"},children:g?"صدرة للأعمال":"Sidrah"})})]}),t.jsx("button",{type:"button",onClick:n,title:e?g?"توسيع":"Expand":g?"طي":"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:x=>{x.currentTarget.style.background="rgba(255, 255, 255, 0.15)",x.currentTarget.style.color="#ffffff"},onMouseLeave:x=>{x.currentTarget.style.background="rgba(255, 255, 255, 0.06)",x.currentTarget.style.color="rgba(255, 255, 255, 0.75)"},children:e?"▶":"✕"})]}),t.jsxs("nav",{style:{padding:"12px 8px",flex:1,overflowY:"auto",overflowX:"hidden"},children:[iy.filter(({id:x})=>(x!=="dashboard"||r)&&(x!=="reports"||a)&&(x!=="delegations"||i)).map(({id:x,icon:w})=>{const v=j[x]||x,S=x===s;return t.jsxs("div",{onClick:()=>l(x),title:e?v: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:m=>{S||(m.currentTarget.style.background="rgba(255, 255, 255, 0.08)",m.currentTarget.style.color="#ffffff")},onMouseLeave:m=>{S||(m.currentTarget.style.background="transparent",m.currentTarget.style.color="rgba(255, 255, 255, 0.78)")},children:[t.jsx("span",{style:{flexShrink:0,fontSize:e?15:13},children:w}),!e&&t.jsx("span",{children:v})]},x)}),p.length>0&&t.jsxs(t.Fragment,{children:[!e&&t.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:y}),e&&t.jsx("div",{style:{margin:"10px auto",width:26,borderTop:"1px solid rgba(255, 255, 255, 0.12)"}}),p.map(({id:x,icon:w})=>{const v=j[x]||x,S=x===s;return t.jsxs("div",{onClick:()=>l(x),title:e?v: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:m=>{S||(m.currentTarget.style.background="rgba(255, 255, 255, 0.08)",m.currentTarget.style.color="#ffffff")},onMouseLeave:m=>{S||(m.currentTarget.style.background="transparent",m.currentTarget.style.color="rgba(255, 255, 255, 0.78)")},children:[t.jsx("span",{style:{flexShrink:0,fontSize:e?15:13},children:w}),!e&&t.jsx("span",{children:v})]},x)})]})]})]})}const Pl=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 Es="";async function Bc(){try{const e=await fetch(`${de}/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 Es=s,s}}catch(e){console.error("CSRF fetch error:",e)}return Es}async function tn(){return Es||await Bc(),Es}function Fa(e,n){try{if(e!=null&&e._server_messages){const s=JSON.parse(e._server_messages);if(s.length){const l=JSON.parse(s[0]);if(l!=null&&l.message)return l.message.replace(/<[^>]+>/g,"")}}}catch{}return(e==null?void 0:e.message)||(e==null?void 0:e.exception)||n}async function At(e,n,s=[]){if(Pl.has(e)){const i=`${de}/api/method/sidrah_business.api.get_sb_doc?doctype=${encodeURIComponent(e)}&name=${encodeURIComponent(n)}`,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 l=s.length?`?fields=${encodeURIComponent(JSON.stringify(s))}`:"",r=await fetch(`${de}/api/v1/resource/${e}/${encodeURIComponent(n)}${l}`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`API Error: ${r.status}`);return(await r.json()).data}async function Fo(e,n,s="",l=!1){const r=await tn();if(Pl.has(e)){const c=new URLSearchParams({doctype:e,name:n});s&&c.append("reason",s),l&&c.append("permanent","1");const u=await fetch(`${de}/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":r},body:c.toString()});if(!u.ok){const g=await u.json().catch(()=>({}));throw new Error(Fa(g,`Error deleting ${n}`))}return}const a=new URLSearchParams({doctype:e,name:n});s&&a.append("reason",s),l&&a.append("permanent","1");const i=await fetch(`${de}/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":r},body:a.toString()});if(!i.ok){const c=await i.json().catch(()=>({}));throw new Error(Fa(c,`Error deleting ${n}`))}return await i.json()}async function wy(e,n){const s=await tn();if(Pl.has(e)){const a=new URLSearchParams({doctype:e,name:n}),i=await fetch(`${de}/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 u=await i.json().catch(()=>({}));throw new Error(Fa(u,`Error restoring ${n}`))}return(await i.json()).message||{success:!0}}const l=new URLSearchParams({doctype:e,name:n}),r=await fetch(`${de}/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:l.toString()});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(Fa(a,`Error restoring ${n}`))}return await r.json()}async function Te(e){if(Pl.has(e))try{const l=`${de}/api/method/sidrah_business.api.get_sb_list?doctype=${encodeURIComponent(e)}&limit=500`,r=await fetch(l,{credentials:"include",headers:{Accept:"application/json"}});return r.ok?(await r.json()).message||[]:[]}catch{return[]}const n=encodeURIComponent('["*"]'),s=`${de}/api/v1/resource/${e}?limit_page_length=500&fields=${n}`;try{const l=await fetch(s,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return l.status===401||l.status===403?[]:l.ok?(await l.json()).data||[]:[]}catch(l){return console.error("Get error:",l),[]}}async function Gi(e,n){const s=await tn();if(Pl.has(e)){const r=new URLSearchParams({doctype:e,data_json:JSON.stringify(n)}),a=await fetch(`${de}/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:r.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 l=`${de}/api/v1/resource/${e}`;try{const r=await fetch(l,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":s},body:JSON.stringify(n)});if(r.status===401||r.status===403)throw new Error("Permission denied - login required");if(!r.ok){const a=await r.json();throw new Error(a.message||a.exc||`API Error: ${r.status}`)}return await r.json()}catch(r){throw console.error("Post error:",r),r}}async function Ma(e,n,s){const l=await tn();if(Pl.has(e)){const a=new URLSearchParams({doctype:e,name:n,data_json:JSON.stringify(s)}),i=await fetch(`${de}/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":l},body:a.toString()});if(!i.ok){const u=await i.json().catch(()=>({}));throw new Error(u.message||u.exc||`Error updating ${e}`)}return{data:(await i.json()).message}}const r=`${de}/api/v1/resource/${e}/${encodeURIComponent(n)}`;try{const a=await fetch(r,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":l},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 ky(){const e=`${de}/api/v1/resource/User?limit_page_length=500&fields=["name","full_name"]`;try{const n=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return n.status===401||n.status===403?[]:n.ok?(await n.json()).data||[]:[]}catch(n){return console.error("Get users error:",n),[]}}async function _y(e,n){const s=new FormData;s.append("usr",e),s.append("pwd",n);const r=await(await fetch(`${de}/api/method/login`,{method:"POST",credentials:"include",body:s})).json();return r.csrf_token?Es=r.csrf_token:await Bc(),r}async function Cy(){const e=await tn();try{await fetch(`${de}/api/method/logout`,{method:"POST",credentials:"include",headers:{"X-Frappe-CSRF-Token":e,Accept:"application/json"}})}catch{}Es=""}function zy(){return Es}async function ah(){try{const e=await fetch(`${de}/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 Iy(){const e=JSON.stringify([["name","not in",["Administrator","Guest"]]]),n=`${de}/api/v1/resource/User?limit_page_length=500&fields=${encodeURIComponent('["*"]')}&filters=${encodeURIComponent(e)}`;try{const s=await fetch(n,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).data||[]:[]}catch{return[]}}async function Ey(){const e=`${de}/api/method/sidrah_business.api.get_user_role_map`;try{const n=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return n.ok?(await n.json()).message||{}:{}}catch{return{}}}async function ih(e,n){await Ma("User",e,{new_password:n})}async function Ty(e=20){try{const n=`${de}/api/method/sidrah_business.api.get_notifications?limit=${e}`,s=await fetch(n,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function Py(){const e=await tn();try{await fetch(`${de}/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 Ay(e){const n=await tn();try{await fetch(`${de}/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":n},body:new URLSearchParams({name:e}).toString()})}catch{}}async function Ry(e){const n=await tn(),s=new URLSearchParams({name:e});await fetch(`${de}/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":n},body:s.toString()})}async function Dy(e,n){try{const s=`${de}/api/method/sidrah_business.api.get_doc_comments?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(n)}`,l=await fetch(s,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||[]:[]}catch{return[]}}async function Ly(e,n,s){const l=await tn(),r=new URLSearchParams({doctype:e,docname:n,content:s}),a=await fetch(`${de}/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":l},body:r.toString()});if(!a.ok)throw new Error("Failed to post comment");return(await a.json()).message}async function Oy(e,n){try{const s=`${de}/api/method/sidrah_business.api.get_doc_versions?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(n)}`,l=await fetch(s,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||[]:[]}catch{return[]}}async function oh(e){try{const n=`${de}/api/method/sidrah_business.api.get_user_roles?user=${encodeURIComponent(e)}`,s=await fetch(n,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function Ny(){try{const e=`${de}/api/method/sidrah_business.api.get_my_organization`,n=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return n.ok&&(await n.json()).message||""}catch{return""}}async function As(e,n={}){const s=await tn(),l=new URLSearchParams(n),r=await fetch(`${de}/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:l.toString()});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.message||i.exc||`Error calling ${e}`)}return(await r.json()).message}async function Wy(e,n,s="",l,r,a){const i={name:e,action:n,comment:s};return l!==void 0&&(i.stage=l),a!==void 0&&(i.cycle_status=a),As("apply_order_workflow",i)}async function By(e,n,s=""){return As("apply_incident_workflow",{name:e,action:n,fields_json:s})}async function $y(e,n,s=""){return As("apply_idea_workflow",{name:e,action:n,fields_json:s})}async function Uy(e=""){const n=`${de}/api/method/sidrah_business.api.get_dashboard_data${e?`?organization=${encodeURIComponent(e)}`:""}`,s=await fetch(n,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||{}:{escalated_processes:[],escalated_orders:[],untriaged_incidents:[],kpi_inputs:[]}}async function Fy(e,n={}){return As("get_report_data",{report_name:e,filters_json:JSON.stringify(n)})}async function My(){try{const e=`${de}/api/method/sidrah_business.api.get_inbox_items`,n=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return n.ok?(await n.json()).message||[]:[]}catch{return[]}}async function Hy(e,n,s="",l=""){return As("create_delegation",{manager:e,functions_json:JSON.stringify(n),organization:s,remarks:l})}async function Gy(e,n,s=""){return As("respond_to_delegation",{name:e,response:n,remarks:s})}async function Ky(e,n=""){return As("revoke_delegation",{name:e,remarks:n})}async function Qy(){try{const e=`${de}/api/method/sidrah_business.api.get_delegations`,n=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return n.ok?(await n.json()).message||[]:[]}catch{return[]}}async function Yy(e){const n=`${de}/api/method/sidrah_business.api.get_delegation?name=${encodeURIComponent(e)}`,s=await fetch(n,{credentials:"include",headers:{Accept:"application/json"}});if(!s.ok)throw new Error("Failed to load delegation");return(await s.json()).message}async function Xy(){try{const e=`${de}/api/method/sidrah_business.api.get_my_delegated_functions`,n=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return n.ok?(await n.json()).message||[]:[]}catch{return[]}}async function qy(){try{const e=`${de}/api/method/sidrah_business.api.get_my_delegated_organizations`,n=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return n.ok?(await n.json()).message||{}:{}}catch{return{}}}async function Jy(){try{const e=await tn(),n=await fetch(`${de}/api/method/sidrah_business.api.get_group_companies`,{method:"GET",credentials:"include",headers:{Accept:"application/json","X-Frappe-CSRF-Token":e}});return n.ok?(await n.json()).message||[]:[]}catch{return[]}}async function Zy(){const e=zy();return e||Bc()}async function Zl(e){const n=await fetch(`${de}/api/method/sidrah_business.api.get_process?name=${encodeURIComponent(e)}`,{credentials:"include",headers:{Accept:"application/json"}});if(!n.ok){const l=await n.json().catch(()=>({}));throw new Error(l.message||`Failed to load process (${n.status})`)}const s=await n.json();return s.message||s.data}async function Vy(e,n,s={}){const l=await Zy(),r=new URLSearchParams({name:e,action:n});s.actor_status&&r.set("actor_status",String(s.actor_status)),s.actor_comment&&r.set("actor_comment",String(s.actor_comment)),s.progress_indicators&&r.set("progress_indicators",JSON.stringify(s.progress_indicators));const a=await fetch(`${de}/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":l},body:r.toString()});if(!a.ok){const c=await a.json().catch(()=>({})),u=c.message||(c.exception?String(c.exception).split(`
`).pop():"")||c.exc_type||`Workflow action "${n}" failed (${a.status})`;throw new Error(u)}const i=await a.json();return i.message||i.data}const e0=["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"],ku=new Set(e0),t0={"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 _u(){const e=window.location.hash.replace(/^#\/?/,"");if(e)return ku.has(e)?e:null;const n=window.location.pathname.split("/").filter(Boolean).pop()||"";return ku.has(n)?n:null}function n0(e){return e?t0[e]??e:null}function s0(e){return`#/${e}`}function l0({onLogin:e}){const n=ne(),[s,l]=C.useState(""),[r,a]=C.useState(""),[i,c]=C.useState(""),[u,g]=C.useState(!1),[j,y]=C.useState(!1),[p,x]=C.useState(!1),w=async()=>{if(!s||!r){c(n.login.emptyFields);return}g(!0),c("");try{const S=await _y(s,r);if(S.message==="Logged In"){const o=await ah()||s,d=await oh(o),f=d.some(z=>["SB Admin","System Manager"].includes(z))?"Admin":d.includes("SB Auditor")?"Auditor":d.includes("SB Owner")?"Owner":d.includes("SB X-Auditor")?"XAuditor":d.includes("SB Manager")?"Manager":"Employee";e({name:o,full_name:S.full_name||s,role:f})}else c(n.login.invalidCreds)}catch(S){c(n.login.connError+(S instanceof Error?S.message:"Unknown"))}g(!1)},v=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 t.jsx("div",{style:{minHeight:"100vh",background:"#f8fafc",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"Segoe UI, system-ui, sans-serif",padding:"20px"},children:t.jsxs("div",{style:{width:380,maxWidth:"100%",display:"flex",flexDirection:"column",alignItems:"center"},children:[t.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:t.jsx("img",{src:lh,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"contain"},onError:S=>{S.currentTarget.style.display="none"}})}),t.jsxs("div",{style:{textAlign:"center",marginBottom:24},children:[t.jsx("h1",{style:{fontSize:22,fontWeight:800,color:"#0f172a",letterSpacing:"-0.3px",margin:0},children:n.rtl?"صدرة للأعمال":"Sidrah"}),t.jsx("div",{style:{fontSize:13,color:"#6366f1",fontWeight:600,marginTop:4},children:n.rtl?"نظام إدارة العمليات والأعمال":"Asset Management System"}),t.jsx("div",{style:{fontSize:12,color:"#94a3b8",marginTop:6},children:n.login.subtitle})]}),t.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:12},children:[t.jsx("div",{children:t.jsx("input",{value:s,onChange:S=>l(S.target.value),onKeyDown:S=>S.key==="Enter"&&w(),onFocus:()=>y(!0),onBlur:()=>y(!1),style:v(j),placeholder:n.login.usernamePlaceholder,autoComplete:"username"})}),t.jsx("div",{children:t.jsx("input",{type:"password",value:r,onChange:S=>a(S.target.value),onKeyDown:S=>S.key==="Enter"&&w(),onFocus:()=>x(!0),onBlur:()=>x(!1),style:v(p),placeholder:n.login.passwordPlaceholder,autoComplete:"current-password"})}),i&&t.jsx("div",{style:{padding:"9px 12px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:8,color:"#dc2626",fontSize:12,textAlign:"center"},children:i}),t.jsx("button",{type:"button",onClick:w,disabled:u,style:{background:u?"#818cf8":"#4f46e5",color:"white",border:"none",padding:"12px",borderRadius:8,fontSize:14,cursor:u?"not-allowed":"pointer",fontWeight:600,marginTop:4,boxShadow:"0 2px 8px rgba(79, 70, 229, 0.3)",transition:"all 0.18s ease"},onMouseEnter:S=>{u||(S.currentTarget.style.background="#4338ca")},onMouseLeave:S=>{u||(S.currentTarget.style.background="#4f46e5")},children:u?n.login.signingIn:n.login.signIn}),t.jsx("div",{style:{textAlign:"center",marginTop:8},children:t.jsx("button",{type:"button",onClick:sh,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:n.switchLang})})]})]})})}function r0(e,n){const s=parseInt(e.replace("#",""),16),l=s>>16&255,r=s>>8&255,a=s&255,i=c=>Math.round(c+(255-c)*n);return`rgb(${i(l)}, ${i(r)}, ${i(a)})`}function Hl(e,n){const s=parseInt(e.replace("#",""),16),l=s>>16&255,r=s>>8&255,a=s&255;return`rgba(${l}, ${r}, ${a}, ${n})`}function ta({title:e,data:n,color:s,onSelect:l}){const[,r]=n[0]??["Total",0,""],a=n.slice(1),i=a.map((u,g)=>r0(s,Math.min(g*.16,.7))),c=a.map(([u,g,j],y)=>[u,g,j,i[y]]).filter(([,u])=>u>0);return t.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:[t.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",background:`linear-gradient(160deg, ${Hl(s,.09)} 0%, transparent 55%)`}}),t.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:3,background:`linear-gradient(90deg, ${s}, ${Hl(s,.35)})`}}),t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:14},children:[t.jsx("span",{className:"status-card-title",style:{fontSize:13,fontWeight:700,paddingTop:4},children:e}),t.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 ${Hl(s,.35)}`},children:r})]}),r>0&&t.jsx("div",{style:{display:"flex",height:9,borderRadius:999,overflow:"hidden",background:Hl(s,.1),marginBottom:13},children:c.map(([u,g,j,y],p)=>t.jsx("div",{title:`${u}: ${g}`,onClick:x=>{x.stopPropagation(),l==null||l(j)},style:{flex:`${g} 0 0`,background:y,borderRight:p<c.length-1?"2px solid white":"none",cursor:l?"pointer":"default"}},u))}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:a.map(([u,g,j],y)=>t.jsxs("div",{className:"status-card-row",onClick:g>0?p=>{p.stopPropagation(),l==null||l(j)}:void 0,style:{display:"flex",alignItems:"center",gap:9,padding:"4px 6px",borderRadius:8,cursor:g>0&&l?"pointer":"default",transition:"background 0.12s"},children:[t.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:i[y],flexShrink:0,boxShadow:`0 0 0 3px ${Hl(i[y],.18)}`}}),t.jsx("span",{className:"status-card-label",style:{flex:1,fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),t.jsx("span",{className:"status-card-count",style:{fontSize:12,fontWeight:700,flexShrink:0},children:g})]},u))})]})}function Gt({value:e,onChange:n,organizations:s,placeholder:l="-- Choose organization --",disabled:r=!1,small:a=!1}){var y;const[i,c]=C.useState(!1),u=C.useRef(null);C.useEffect(()=>{const p=x=>{u.current&&!u.current.contains(x.target)&&c(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[]);const g=e?((y=s.find(p=>p.organization_name===e||p.name===e))==null?void 0:y.organization_name)??e:l,j=s.filter(p=>!!p.is_active||p.organization_name===e||p.name===e);return t.jsxs("div",{ref:u,style:{position:"relative",width:"100%"},children:[t.jsxs("div",{onClick:()=>!r&&c(p=>!p),style:{width:"100%",padding:a?"4px 8px":"7px 10px",border:"1px solid #ddd",borderRadius:6,fontSize:a?11:12,cursor:r?"default":"pointer",height:a?28:34,background:r?"#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:r?.75:1},children:[t.jsx("span",{children:g}),t.jsx("span",{style:{fontSize:9,color:"#999",transform:i?"rotate(180deg)":"none",transition:"transform 0.2s"},children:"▼"})]}),i&&t.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:t.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[t.jsx(Cu,{label:l,selected:!e,active:!0,isPlaceholder:!0,small:a,onClick:()=>{n(""),c(!1)}}),j.length===0&&t.jsx("div",{style:{padding:"12px 16px",color:"#aaa",fontSize:13},children:"No organizations"}),j.map(p=>t.jsx(Cu,{label:p.organization_name,selected:e===p.organization_name||e===p.name,active:!!p.is_active,isPlaceholder:!1,small:a,onClick:()=>{n(p.organization_name),c(!1)}},p.name))]})})]})}function Cu({label:e,selected:n,active:s,isPlaceholder:l,small:r,onClick:a}){const[i,c]=C.useState(!1),u=n?"#2563eb":i?"#f0f4ff":"transparent",g=n?"white":l?"#aaa":s?"#1a2332":"#e74c3c";return t.jsx("div",{onClick:a,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{padding:r?"6px 12px":"8px 14px",cursor:"pointer",fontSize:12,background:u,color:g,transition:"background 0.1s"},children:e})}function Mn({items:e,type:n,onNavigate:s}){const l=ne();if(!e.length)return null;const r=n==="process"?"processes-form":"orders-form",a=n==="process"?l.dash.escalatedProcesses:l.dash.escalatedOrders;return t.jsxs("div",{children:[t.jsxs("h4",{style:{fontWeight:700,fontSize:12,color:"#e74c3c",marginBottom:6},children:[a," (",e.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:e.map(i=>t.jsxs("div",{onClick:()=>s(r,i.name),style:{padding:"8px 12px",background:"#fff5f5",borderRadius:7,border:"1px solid #fecaca",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs("div",{children:[t.jsx("span",{style:{fontWeight:700,fontSize:12},children:i.number||i.name}),t.jsx("span",{style:{fontSize:11,color:"#666",marginLeft:8},children:i.title})]}),t.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#e74c3c",background:"#fecaca",padding:"2px 8px",borderRadius:10},children:[l.dash.level," ",i.escalation_level]})]},i.name))})]})}function a0({kpi:e}){const n=ne();return t.jsxs("div",{className:"dashboard-kpi-card",style:{borderRadius:12,padding:14,border:"1px solid #e2e8f0"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},children:[t.jsx("div",{style:{fontWeight:700,fontSize:13,color:"#1e293b"},children:e.organization}),t.jsx("span",{style:{fontSize:11,fontWeight:600,color:"#6366f1",background:"#eff6ff",border:"1px solid #bfdbfe",padding:"1px 7px",borderRadius:12},children:e.period})]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:6},children:[{label:n.dash.revenueGrowth,val:e.revenue_growth!=null?`${e.revenue_growth}%`:"—"},{label:n.dash.netProfit,val:e.net_profit!=null?e.net_profit.toLocaleString():"—"},{label:n.dash.strategicGoal,val:e.strategic_goal_pct!=null?`${e.strategic_goal_pct}%`:"—"},{label:n.dash.customerSat,val:e.customer_satisfaction!=null?e.customer_satisfaction:"—"},{label:n.dash.compliance,val:e.compliance_score!=null?e.compliance_score:"—"},{label:n.dash.safetyInc,val:e.open_safety_incidents!=null?e.open_safety_incidents:"—"}].map(({label:s,val:l})=>t.jsxs("div",{style:{background:"#f8fafc",padding:"6px 8px",borderRadius:6,border:"1px solid #f1f5f9"},children:[t.jsx("div",{style:{fontSize:10,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.2px"},children:s}),t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginTop:1},children:l})]},s))})]})}function i0({data:e}){if(!e.length)return t.jsx("p",{style:{color:"#aaa",fontSize:13},children:"No cycle data available for trend chart."});const n=Math.max(...e.map(s=>s.pass+s.fail+s.unknown),1);return t.jsxs("div",{children:[t.jsx("div",{style:{display:"flex",gap:10,alignItems:"flex-end",overflowX:"auto",paddingBottom:4},children:e.map(s=>{const l=s.pass+s.fail+s.unknown||1,r=80;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:3,minWidth:48},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column-reverse",gap:1,height:r,width:32},children:[t.jsx("div",{title:`Pass: ${s.pass}`,style:{height:Math.round(s.pass/n*r),background:"#27ae60",borderRadius:"2px 2px 0 0",minHeight:s.pass?2:0}}),t.jsx("div",{title:`Fail: ${s.fail}`,style:{height:Math.round(s.fail/n*r),background:"#e74c3c",borderRadius:"2px 2px 0 0",minHeight:s.fail?2:0}}),t.jsx("div",{title:`Unknown: ${s.unknown}`,style:{height:Math.round(s.unknown/n*r),background:"#95a5a6",borderRadius:"2px 2px 0 0",minHeight:s.unknown?2:0}})]}),t.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}`)}),t.jsx("div",{style:{fontSize:9,color:"#555",textAlign:"center"},children:l>1?Math.round(s.pass/l*100)+"%":"—"})]},s.month)})}),t.jsx("div",{style:{display:"flex",gap:16,marginTop:8},children:[["#27ae60","Pass"],["#e74c3c","Fail"],["#95a5a6","Unknown"]].map(([s,l])=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,fontSize:11},children:[t.jsx("div",{style:{width:10,height:10,background:s,borderRadius:2}}),t.jsx("span",{style:{color:"#666"},children:l})]},l))})]})}function Jt({label:e,icon:n,onClick:s}){return t.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:l=>l.currentTarget.style.boxShadow="0 3px 10px rgba(0,0,0,0.12)",onMouseLeave:l=>l.currentTarget.style.boxShadow="0 1px 3px rgba(0,0,0,0.06)",children:[t.jsx("span",{style:{fontSize:15},children:n}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#444",whiteSpace:"nowrap"},children:e})]})}function o0({dashData:e,fi:n,fid:s,fo:l,fp:r,incidentStatuses:a,ideaStatuses:i,orderStatuses:c,processStatuses:u,onNavigate:g,onNavigateStatus:j}){const y=ne(),p=(e==null?void 0:e.escalated_processes)||[],x=(e==null?void 0:e.escalated_orders)||[],w=(e==null?void 0:e.attention_processes)||[],v=(e==null?void 0:e.attention_orders)||[],S=(e==null?void 0:e.untriaged_incidents)||[],m=(e==null?void 0:e.overdue_triage)||[],o=p.length>0||x.length>0,d=w.length>0||v.length>0,f=[["Total",n.length,""],...a.map(k=>[k.name1||k.name,n.filter(I=>I.status===k.name).length,k.name])],z=[["Total",s.length,""],...i.map(k=>[k.name1||k.name,s.filter(I=>I.status===k.name).length,k.name])],b=[["Total",l.length,""],...c.map(k=>[k.name1||k.name,l.filter(I=>I.status===k.name).length,k.name])],h=[["Total",r.length,""],...u.map(k=>[k.name1||k.name,r.filter(I=>I.status===k.name).length,k.name])];return t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",marginBottom:4},children:[t.jsx(Jt,{label:"Incidents",icon:"⚠️",onClick:()=>g("incidents")}),t.jsx(Jt,{label:"Ideas",icon:"💡",onClick:()=>g("ideas")}),t.jsx(Jt,{label:"Orders",icon:"📦",onClick:()=>g("orders")}),t.jsx(Jt,{label:"Processes",icon:"⚙️",onClick:()=>g("processes")}),t.jsx(Jt,{label:"Inbox",icon:"📥",onClick:()=>g("inbox")}),t.jsx(Jt,{label:"Reports",icon:"📊",onClick:()=>g("reports")})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12},children:[t.jsx("div",{onClick:()=>g("incidents"),style:{cursor:"pointer"},children:t.jsx(ta,{title:y.dash.incidents,color:F.orange,data:f,onSelect:k=>j("incidents",k)})}),t.jsx("div",{onClick:()=>g("ideas"),style:{cursor:"pointer"},children:t.jsx(ta,{title:y.dash.ideas,color:F.blue,data:z,onSelect:k=>j("ideas",k)})}),t.jsx("div",{onClick:()=>g("orders"),style:{cursor:"pointer"},children:t.jsx(ta,{title:y.dash.orders,color:F.purple,data:b,onSelect:k=>j("orders",k)})}),t.jsx("div",{onClick:()=>g("processes"),style:{cursor:"pointer"},children:t.jsx(ta,{title:y.dash.processes,color:F.red,data:h,onSelect:k=>j("processes",k)})})]}),o&&t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #e74c3c"},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:10},children:y.dash.level2}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[t.jsx(Mn,{items:p,type:"process",onNavigate:g}),t.jsx(Mn,{items:x,type:"order",onNavigate:g})]})]}),d&&t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#b45309",marginBottom:10},children:y.dash.level1}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[t.jsx(Mn,{items:w,type:"process",onNavigate:g}),t.jsx(Mn,{items:v,type:"order",onNavigate:g})]})]}),m.length>0&&t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #e74c3c"},children:[t.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:8},children:[y.dash.overduePrefix,m.length,y.dash.overdueSuffix]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:m.map(k=>t.jsxs("div",{onClick:()=>g("incidents-form",k.name),style:{padding:"8px 12px",background:"#fef2f2",borderRadius:8,border:"1px solid #fca5a5",cursor:"pointer",display:"flex",justifyContent:"space-between"},children:[t.jsx("span",{style:{fontWeight:700,fontSize:13},children:k.number||k.name}),t.jsx("span",{style:{fontSize:12,color:"#666"},children:k.title}),t.jsx("span",{style:{fontSize:11,color:"#888"},children:k.date})]},k.name))})]}),S.length>0&&t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[t.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:F.orange,marginBottom:8},children:[y.dash.untriaged," (",S.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:S.map(k=>t.jsxs("div",{onClick:()=>g("incidents-form",k.name),style:{padding:"8px 12px",background:"#fffbeb",borderRadius:8,border:"1px solid #fed7aa",cursor:"pointer",display:"flex",justifyContent:"space-between"},children:[t.jsx("span",{style:{fontWeight:700,fontSize:13},children:k.number||k.name}),t.jsx("span",{style:{fontSize:12,color:"#666"},children:k.title}),t.jsx("span",{style:{fontSize:11,color:"#888"},children:k.date})]},k.name))})]})]})}function c0({dashData:e,selectedOrg:n,onNavigate:s}){const l=ne(),[r,a]=C.useState([]),[i,c]=C.useState([]),[u,g]=C.useState(!1),j=(e==null?void 0:e.escalated_processes)||[],y=(e==null?void 0:e.escalated_orders)||[],p=(e==null?void 0:e.attention_processes)||[],x=(e==null?void 0:e.attention_orders)||[],w=(e==null?void 0:e.kpi_inputs)||[];C.useEffect(()=>{g(!0);const m=new URLSearchParams({months:"6"});n&&m.append("organization",n),fetch(`/api/method/sidrah_business.api.get_process_trend?${m}`,{credentials:"include",headers:{Accept:"application/json"}}).then(o=>o.json()).then(o=>{const d=o.message||[],f={};for(const z of d)f[z.month]||(f[z.month]={pass:0,fail:0,unknown:0}),z.status==="Pass"?f[z.month].pass=z.count:z.status==="Fail"?f[z.month].fail=z.count:z.status==="Unknown"&&(f[z.month].unknown=z.count);a(Object.entries(f).map(([z,b])=>({month:z,...b})))}).catch(()=>{}).finally(()=>g(!1))},[n]),C.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(m=>m.json()).then(m=>{var o;c((((o=m.message)==null?void 0:o.rows)||[]).slice(0,50))}).catch(()=>{})},[n]);const v=j.length>0||y.length>0,S=p.length>0||x.length>0;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:[t.jsx(Jt,{label:"Manage Users & Roles",icon:"👥",onClick:()=>s("users")}),t.jsx(Jt,{label:"Change Active Cycle",icon:"🔄",onClick:()=>s("cycles")}),t.jsx(Jt,{label:"KPI Inputs",icon:"📈",onClick:()=>s("kpi-input")}),t.jsx(Jt,{label:"Reports",icon:"📊",onClick:()=>s("reports")}),t.jsx(Jt,{label:"Organizations",icon:"🏢",onClick:()=>s("organizations")})]}),w.length>0&&t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:10},children:l.dash.recentKpi}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12},children:w.map(m=>t.jsx(a0,{kpi:m},m.name))}),t.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:l.dash.manageKpi})]}),v&&t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #e74c3c"},children:[t.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:10},children:["Critical Escalations — Level 2 (",j.length+y.length,")"]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[t.jsx(Mn,{items:j,type:"process",onNavigate:s}),t.jsx(Mn,{items:y,type:"order",onNavigate:s})]})]}),S&&t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[t.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#b45309",marginBottom:10},children:["Needs Attention — Level 1 (",p.length+x.length,")"]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[t.jsx(Mn,{items:p,type:"process",onNavigate:s}),t.jsx(Mn,{items:x,type:"order",onNavigate:s})]})]}),t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:4},children:"Process Trend — Last 6 Months"}),t.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."}),u?t.jsx("p",{style:{color:"#aaa",fontSize:13},children:"Loading trend data…"}):t.jsx(i0,{data:r})]}),i.length>0&&t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:10},children:"Log Book — Recent Activity"}),t.jsx("div",{style:{overflowX:"auto"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsx("tr",{style:{background:"#f8f9fa"},children:["Timestamp","User","Entity Type","Entity","Fields Changed"].map(m=>t.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#999",fontWeight:700,fontSize:11,whiteSpace:"nowrap"},children:m},m))})}),t.jsx("tbody",{children:i.map((m,o)=>t.jsxs("tr",{style:{borderTop:"1px solid #f0f0f0",background:o%2===0?"white":"#fafafa"},children:[t.jsx("td",{style:{padding:"8px 12px",color:"#555",whiteSpace:"nowrap"},children:m.timestamp?String(m.timestamp).slice(0,16):"—"}),t.jsx("td",{style:{padding:"8px 12px",color:"#333"},children:m.user||"—"}),t.jsx("td",{style:{padding:"8px 12px",color:"#555"},children:m.entity_type||"—"}),t.jsx("td",{style:{padding:"8px 12px",color:"#555"},children:m.entity_name||"—"}),t.jsx("td",{style:{padding:"8px 12px",color:"#888",maxWidth:240,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m.changes||"—"})]},o))})]})}),t.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:n,orders:s,processes:l,organizations:r,incidentStatuses:a,ideaStatuses:i,orderStatuses:c,processStatuses:u,selectedOrg:g,onOrgChange:j,onNavigate:y,onNavigateStatus:p,userRole:x}){const[w,v]=C.useState(null);C.useEffect(()=>{Uy(g).then(v)},[g]);const S=g?e.filter(I=>I.organization===g):e,m=g?n.filter(I=>I.organization===g):n,o=g?s.filter(I=>I.organization===g):s,d=g?l.filter(I=>I.organization===g):l,f=x==="Admin",z=x==="Owner",[b,h]=C.useState("level1"),k=z||f&&b==="level2";return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[t.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:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#4f46e5",strokeWidth:"2.5",strokeLinecap:"round",children:t.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#1e1b4b",whiteSpace:"nowrap"},children:"Filter"})]}),t.jsx("div",{style:{flex:1,minWidth:160,maxWidth:260},children:t.jsx(Gt,{value:g,onChange:j,organizations:r,placeholder:"All Organizations",small:!0})}),f&&t.jsx("div",{style:{display:"flex",background:"#f1f0fe",borderRadius:7,padding:2,gap:2,flexShrink:0},children:["level1","level2"].map(I=>t.jsx("button",{onClick:()=>h(I),style:{padding:"4px 10px",borderRadius:5,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:b===I?I==="level2"?F.purple:F.blue:"transparent",color:b===I?"white":"#6b7280",transition:"all 0.15s"},children:I==="level1"?"Level 1":"Level 2"},I))}),!f&&t.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?t.jsx(c0,{dashData:w,selectedOrg:g,onNavigate:y}):t.jsx(o0,{dashData:w,fi:S,fid:m,fo:o,fp:d,incidentStatuses:a,ideaStatuses:i,orderStatuses:c,processStatuses:u,onNavigate:y,onNavigateStatus:p})]})}const tt={fontSize:11,color:"#475569",fontWeight:600,marginBottom:4,display:"block",textTransform:"uppercase",letterSpacing:.4},nt={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 oi({children:e}){const[n,s]=C.useState(!1);return t.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:[t.jsxs("div",{onClick:()=>s(l=>!l),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:[t.jsx("span",{style:{fontSize:12,opacity:.9},children:n?"▲":"▼"}),t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:t.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),t.jsx("span",{children:"Filters"})]}),n&&t.jsx("div",{style:{background:"#f8fafc",padding:"14px 18px",borderTop:"1px solid #e2e8f0"},children:e})]})}const ae=20,zu=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 qe({page:e,pageSize:n=ae,total:s,onPageChange:l}){if(s===0)return null;const r=Math.max(1,Math.ceil(s/n)),a=(e-1)*n+1,i=Math.min(e*n,s);return t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 4px",fontSize:12,color:"#6b7280",flexShrink:0},children:[t.jsxs("span",{children:["Showing ",a," to ",i," of ",s," results"]}),t.jsxs("div",{style:{display:"flex",gap:8},children:[t.jsx("button",{disabled:e<=1,onClick:()=>l(e-1),style:zu(e<=1),children:"Previous"}),t.jsx("button",{disabled:e>=r,onClick:()=>l(e+1),style:zu(e>=r),children:"Next"})]})]})}function Je({count:e,onClear:n,onExport:s}){return e===0?null:t.jsxs("div",{style:{position:"sticky",bottom:20,zIndex:50,margin:"0 auto",width:"fit-content",maxWidth:"92%",background:"#0f172a",color:"#f8fafc",padding:"8px 18px",borderRadius:9999,boxShadow:"0 12px 32px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0,0,0,0.2)",display:"flex",alignItems:"center",gap:14,fontSize:13,animation:"fadeIn 0.2s ease",border:"1px solid #334155"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:700,color:"#38bdf8"},children:[t.jsx("span",{style:{fontSize:14},children:"✓"}),t.jsxs("span",{children:[e," selected"]})]}),s&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsxs("button",{type:"button",onClick:()=>s("csv"),style:{background:"#16a34a",color:"white",border:"none",borderRadius:20,padding:"5px 12px",fontSize:12,fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:5,transition:"background 0.15s ease"},onMouseEnter:l=>{l.currentTarget.style.background="#15803d"},onMouseLeave:l=>{l.currentTarget.style.background="#16a34a"},children:[t.jsx("span",{children:"📤"})," Export CSV"]}),t.jsxs("button",{type:"button",onClick:()=>s("xlsx"),style:{background:"#0284c7",color:"white",border:"none",borderRadius:20,padding:"5px 12px",fontSize:12,fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:5,transition:"background 0.15s ease"},onMouseEnter:l=>{l.currentTarget.style.background="#0369a1"},onMouseLeave:l=>{l.currentTarget.style.background="#0284c7"},children:[t.jsx("span",{children:"📊"})," Export Excel"]})]}),t.jsx("button",{type:"button",onClick:n,style:{background:"transparent",color:"#94a3b8",border:"none",fontSize:12,fontWeight:600,cursor:"pointer",padding:"4px 6px",transition:"color 0.15s ease"},onMouseEnter:l=>{l.currentTarget.style.color="#f1f5f9"},onMouseLeave:l=>{l.currentTarget.style.color="#94a3b8"},children:"Clear"})]})}function u0({incidents:e,organizations:n,departments:s,branches:l,incidentStatuses:r,initialOrg:a,initialStatus:i,canModify:c,userRole:u,onView:g,onEdit:j,onDelete:y}){const p=ne(),[x,w]=C.useState(new Set),[v,S]=C.useState({search:"",organization:a||"",department:"",branch:"",status:i||""}),m=(h,k)=>S(I=>({...I,[h]:k})),[o,d]=C.useState(1),f=e.filter(h=>!(v.search&&!`${h.number} ${h.title}`.toLowerCase().includes(v.search.toLowerCase())||v.organization&&h.organization!==v.organization||v.department&&h.department!==v.department||v.branch&&h.branch!==v.branch||v.status&&h.status!==v.status));C.useEffect(()=>{d(1)},[v]);const z=f.slice((o-1)*ae,o*ae),b=h=>{const k=e.filter(M=>x.has(M.name)),I=Me.incidents,P=I.columns.filter(M=>I.defaultColumns.includes(M.key));h==="csv"?He(P,k,"incidents_selected"):Ge(P,k,"incidents_selected")};return t.jsxs(t.Fragment,{children:[t.jsx(oi,{children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"10px 14px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.numberTitle}),t.jsx("input",{style:nt,value:v.search,onChange:h=>m("search",h.target.value),placeholder:p.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.organization}),t.jsxs("select",{style:nt,value:v.organization,onChange:h=>m("organization",h.target.value),children:[t.jsx("option",{value:"",children:p.filter.allOrgs}),n.map(h=>t.jsx("option",{value:h.name,children:h.organization_name||h.name},h.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.department}),t.jsxs("select",{style:nt,value:v.department,onChange:h=>m("department",h.target.value),children:[t.jsx("option",{value:"",children:p.filter.allDepts}),s.map(h=>t.jsx("option",{value:h.name,children:h.department_name||h.name},h.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.branch}),t.jsxs("select",{style:nt,value:v.branch,onChange:h=>m("branch",h.target.value),children:[t.jsx("option",{value:"",children:p.filter.allBranches}),l.map(h=>t.jsx("option",{value:h.name,children:h.branch||h.name},h.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.status}),t.jsxs("select",{style:nt,value:v.status,onChange:h=>m("status",h.target.value),children:[t.jsx("option",{value:"",children:p.filter.allStatuses}),r.map(h=>t.jsx("option",{value:h.name,children:h.name1||h.name},h.name))]})]}),t.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:t.jsx("button",{onClick:()=>S({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})})]})}),t.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[t.jsx("th",{style:{width:44,padding:"12px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:z.length>0&&z.every(h=>x.has(h.name)),onChange:h=>{if(h.target.checked)w(new Set([...x,...z.map(k=>k.name)]));else{const k=new Set(x);z.forEach(I=>k.delete(I.name)),w(k)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.type}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.actions})]})}),t.jsx("tbody",{children:f.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:p.noIncidents})}):z.map((h,k)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>g==null?void 0:g(h),style:{borderTop:"1px solid #f1f5f9",background:x.has(h.name)?"#eff6ff":h.custom_is_deleted?"#fff1f2":k%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:I=>I.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:x.has(h.name),onChange:()=>{const I=new Set(x);I.has(h.name)?I.delete(h.name):I.add(h.name),w(I)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:h.number||"—"}),t.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:h.title||"—"}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:h.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:h.type?Wc(h.type):"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:h.custom_is_deleted?es(p.deletedBadge):h.status?es(h.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:I=>I.stopPropagation(),children:t.jsx(at,{onView:()=>g==null?void 0:g(h),onEdit:c&&j&&!h.custom_is_deleted&&!Fn("incident",h.workflow_state)&&!(u==="Employee"&&h.workflow_state&&h.workflow_state!=="New")?()=>j(h):void 0,onDelete:c&&y&&!h.custom_is_deleted?()=>y(h.name):void 0})})]},h.name))})]})}),t.jsx(Je,{count:x.size,onClear:()=>w(new Set),onExport:b}),t.jsx(qe,{page:o,total:f.length,onPageChange:d})]})}function p0(e){if(!e)return"";const[n,s,l]=e.split("-");return!n||!s||!l?"":`${l}/${s}/${n}`}function xe({value:e,onChange:n,disabled:s,style:l,min:r,max:a}){return t.jsxs("div",{style:{position:"relative",width:"100%"},children:[t.jsx("input",{type:"text",readOnly:!0,tabIndex:-1,value:p0(e),placeholder:"DD/MM/YYYY",style:{...l,pointerEvents:"none",paddingRight:30}}),t.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:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),t.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),t.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),t.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),t.jsx("input",{type:"date",value:e||"",disabled:s,min:r,max:a,onChange:i=>n(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 Iu={"SB Process":"processes-form","SB Order":"orders-form","SB Incident":"incidents-form","SB Idea":"ideas-form","SB Delegation":"delegations"};function f0(e){const n=(Date.now()-new Date(e).getTime())/1e3;return n<60?`${Math.floor(n)}s ago`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:`${Math.floor(n/86400)}d ago`}function ch({notifCount:e,darkMode:n,onCountChange:s,onToggleDark:l,onViewProfile:r,onLogout:a,onNavigate:i,userName:c,userRole:u}){const[g,j]=C.useState(!1),[y,p]=C.useState([]),[x,w]=C.useState(!1),v=C.useRef(null);C.useEffect(()=>{const P=M=>{v.current&&!v.current.contains(M.target)&&j(!1)};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[]);const S=async()=>{w(!0);const P=await Ty(30);p(P),w(!1)},m=()=>{const P=!g;j(P),P&&S()},o=async()=>{await Py(),p(P=>P.map(M=>({...M,read:1}))),s(0)},d=P=>{P.read||(Ay(P.name),p(ee=>ee.map(W=>W.name===P.name?{...W,read:1}:W)),s(Math.max(0,e-1)));const M=P.document_type?Iu[P.document_type]:void 0;M&&i&&(i(M,P.document_type==="SB Delegation"?void 0:P.document_name),j(!1))},f=y.filter(P=>!P.read).length,z=P=>({position:"relative",width:34,height:34,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:n?"#2d3748":"#f3f4f6",color:n?"#e2e8f0":"#6b7280",fontSize:14,transition:"background 0.15s",flexShrink:0,...P}),b=n,h=b?"#1a202c":"white",k=b?"#2d3748":"#e5e7eb",I=b?"#e2e8f0":"#1a2332";return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[c&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",marginRight:4,lineHeight:1.25},children:[t.jsx("span",{style:{fontSize:13,fontWeight:600,color:b?"#e2e8f0":"#1e293b",whiteSpace:"nowrap"},children:c}),u&&t.jsx("span",{style:{fontSize:11,color:b?"#94a3b8":"#6b7280",whiteSpace:"nowrap"},children:u})]}),t.jsx("button",{style:z({background:"#4f46e5",color:"white"}),onClick:r,title:"My Profile",children:t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:[t.jsx("circle",{cx:"12",cy:"8",r:"4"}),t.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7",fill:"currentColor"})]})}),t.jsxs("div",{ref:v,style:{position:"relative"},children:[t.jsxs("button",{style:z(),onClick:m,title:"Notifications",children:[t.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),t.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),e>0&&t.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})]}),g&&t.jsxs("div",{style:{position:"absolute",right:0,top:"calc(100% + 8px)",width:340,background:h,borderRadius:12,boxShadow:"0 8px 32px rgba(0,0,0,0.2)",zIndex:1e4,border:`1px solid ${k}`,overflow:"hidden"},children:[t.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${k}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:h},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:I},children:["Notifications",f>0&&t.jsxs("span",{style:{background:"#ef4444",color:"white",fontSize:10,fontWeight:700,borderRadius:999,padding:"2px 7px"},children:[f," new"]})]}),f>0&&t.jsx("button",{onClick:o,style:{fontSize:12,color:"#3498db",background:"none",border:"none",cursor:"pointer",fontFamily:"inherit"},children:"Mark all read"})]}),t.jsxs("div",{style:{maxHeight:380,overflowY:"auto"},children:[x&&t.jsx("div",{style:{padding:20,textAlign:"center",color:"#aaa",fontSize:13},children:"Loading…"}),!x&&y.length===0&&t.jsxs("div",{style:{padding:"36px 20px",textAlign:"center",color:"#aaa"},children:[t.jsx("div",{style:{fontSize:28,marginBottom:8},children:"🔔"}),t.jsx("div",{style:{fontSize:13},children:"No notifications"})]}),!x&&y.map(P=>{const M=!!(P.document_type&&Iu[P.document_type]&&i);return t.jsxs("div",{onClick:()=>d(P),style:{padding:"11px 16px",borderBottom:`1px solid ${b?"#2d3748":"#f5f5f5"}`,display:"flex",gap:10,background:P.read?h:b?"#1e3a5f":"#eff6ff",cursor:M?"pointer":"default",transition:"background 0.12s"},onMouseEnter:ee=>{M&&(ee.currentTarget.style.background=b?"#243244":"#e0ecfd")},onMouseLeave:ee=>{ee.currentTarget.style.background=P.read?h:b?"#1e3a5f":"#eff6ff"},children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:13,fontWeight:P.read?400:600,color:I,marginBottom:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:P.subject||`${P.document_type}: ${P.document_name}`}),t.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:P.document_type&&t.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#3b82f6",background:b?"rgba(59,130,246,0.15)":"#eff6ff",padding:"1px 7px",borderRadius:8},children:[P.document_type.replace("SB ",""),P.document_name?` · ${P.document_name}`:""]})}),t.jsx("div",{style:{fontSize:11,color:"#aaa",marginTop:3},children:f0(P.creation)})]}),!P.read&&t.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:"#3498db",flexShrink:0,marginTop:5}})]},P.name)})]})]})]}),t.jsx("button",{style:z(),onClick:sh,title:pl()?"Switch to English":"Switch to Arabic",children:t.jsx("span",{style:{fontSize:13,fontWeight:700,fontFamily:"serif"},children:"عA"})}),t.jsx("button",{style:z(),onClick:l,title:n?"Light mode":"Dark mode",children:n?t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"5"}),t.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),t.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),t.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),t.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),t.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),t.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),t.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),t.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}),t.jsx("button",{style:z({background:b?"#3d1515":"#fee2e2",color:"#ef4444"}),onClick:a,title:"Logout",children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),t.jsx("polyline",{points:"16,17 21,12 16,7"}),t.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]})})]})}function Ze({title:e,activePage:n,user:s,formStatus:l,buttonText:r,viewMode:a,statusBadge:i,onEdit:c,onCancel:u,hideSettings:g,rightPanel:j,darkMode:y,notifCount:p,onToggleDark:x,onCountChange:w,onViewProfile:v,onSubmit:S,onBack:m,onNavigate:o,onLogout:d,children:f}){const z=ne(),b=s.role,h=b==="Admin"||b==="Owner"||b==="Auditor"||b==="Manager",k=b==="Admin"||b==="Owner"||b==="Auditor"||b==="Manager",I=b==="Admin"||b==="Auditor"||b==="Manager",[P,M]=C.useState(()=>localStorage.getItem("sb_sidebar")==="1"),[ee,W]=C.useState(!a);C.useEffect(()=>{if(a)W(!1);else{W(!0);const D=setTimeout(()=>{W(!1)},5e3);return()=>clearTimeout(D)}},[a]);const $=()=>M(D=>{const Q=!D;return localStorage.setItem("sb_sidebar",Q?"1":"0"),Q}),T=u||m;return t.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:y?"#0f172a":"#f8fafc"},children:[t.jsx(rh,{collapsed:P,onToggleCollapsed:$,activePage:n,onNavigate:o,hasDashboard:h,hasReports:k,hasDelegations:I,role:b,hideSettings:g,rtl:z.rtl,navLabels:z.nav,settingsLabel:z.nav.settings}),t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[t.jsx("div",{style:{background:y?"#1e293b":"#ffffff",padding:"6px 20px",borderBottom:`1px solid ${y?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"flex-end",alignItems:"center",gap:6,flexShrink:0,boxShadow:y?"none":"0 1px 4px rgba(0,0,0,0.03)"},children:t.jsx(ch,{notifCount:p,darkMode:y,onCountChange:w,onToggleDark:x,onNavigate:o,onViewProfile:v,onLogout:d,userName:s.full_name||s.name,userRole:s.role})}),t.jsxs("div",{style:{background:y?"#1e293b":"#ffffff",padding:"12px 24px",borderBottom:`1px solid ${y?"#2d3748":"#e2e8f0"}`,display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,position:"relative"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[t.jsx("button",{onClick:m,title:z.back,style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:`1px solid ${y?"#475569":"#e2e8f0"}`,background:y?"#334155":"#ffffff",cursor:"pointer",color:"#2563eb",flexShrink:0,transition:"all 0.15s ease"},onMouseEnter:D=>{D.currentTarget.style.background=y?"#475569":"#eff6ff",D.currentTarget.style.borderColor="#93c5fd"},onMouseLeave:D=>{D.currentTarget.style.background=y?"#334155":"#ffffff",D.currentTarget.style.borderColor=y?"#475569":"#e2e8f0"},children:t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsx("div",{style:{fontSize:17,fontWeight:700,color:y?"#f8fafc":"#0f172a"},children:e}),i&&(typeof i=="string"?t.jsx("span",{style:{padding:"3px 10px",borderRadius:16,fontSize:12,fontWeight:600,background:"#fef3c7",color:"#92400e",border:"1px solid #fde68a"},children:i}):i)]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a&&c&&t.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:D=>D.currentTarget.style.background="#1d4ed8",onMouseLeave:D=>D.currentTarget.style.background="#2563eb",children:[t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),z.edit]}),!a&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("button",{type:"button",onClick:T,style:{padding:"7px 16px",borderRadius:6,border:`1px solid ${y?"#475569":"#cbd5e1"}`,background:y?"#334155":"#ffffff",color:y?"#e2e8f0":"#475569",fontSize:13,fontWeight:600,cursor:"pointer",transition:"all 0.15s ease"},onMouseEnter:D=>{D.currentTarget.style.background=y?"#475569":"#f1f5f9"},onMouseLeave:D=>{D.currentTarget.style.background=y?"#334155":"#ffffff"},children:z.cancel}),t.jsxs("button",{type:"button",onClick:S,disabled:l==="loading",style:{display:"flex",alignItems:"center",gap:6,padding:"7px 18px",borderRadius:6,border:"none",background:"#16a34a",color:"#ffffff",fontSize:13,fontWeight:600,cursor:l==="loading"?"not-allowed":"pointer",boxShadow:"0 1px 3px rgba(22, 163, 74, 0.3)",opacity:l==="loading"?.7:1,transition:"all 0.15s ease"},onMouseEnter:D=>{l!=="loading"&&(D.currentTarget.style.background="#15803d")},onMouseLeave:D=>{l!=="loading"&&(D.currentTarget.style.background="#16a34a")},children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),t.jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),t.jsx("polyline",{points:"7 3 7 8 15 8"})]}),t.jsx("span",{children:l==="loading"?z.saving:r||"Save Changes"})]})]})]}),!a&&ee&&t.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:[t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5},children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.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"]}),t.jsx("button",{type:"button",onClick:()=>W(!1),title:"Dismiss",style:{background:"transparent",border:"none",color:"white",cursor:"pointer",fontSize:14,padding:0,lineHeight:1,opacity:.85},children:"✕"})]})]}),t.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"grid",gridTemplateColumns:j?"1fr 240px":"1fr",gap:16,alignItems:"start"},children:[t.jsxs("div",{style:{minWidth:0},children:[f,l==="success"&&t.jsx("div",{style:{padding:"10px 14px",borderRadius:8,background:"#f0fdf4",border:"1px solid #86efac",color:"#166534",fontSize:13,marginTop:14},children:z.savedOk}),l!=="idle"&&l!=="loading"&&l!=="success"&&t.jsx("div",{style:{padding:"10px 14px",borderRadius:8,background:"#fef2f2",border:"1px solid #fca5a5",color:"#991b1b",fontSize:13,marginTop:14},children:l})]}),j&&t.jsx("div",{style:{position:"sticky",top:0,alignSelf:"start",width:240},children:j})]})]})]})}function pe({value:e,onChange:n,items:s,placeholder:l="-- Select --",disabled:r=!1}){var y;const[a,i]=C.useState(!1),[c,u]=C.useState(""),g=C.useRef(null);C.useEffect(()=>{const p=x=>{g.current&&!g.current.contains(x.target)&&i(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[]);const j=e?((y=s.find(p=>p.name===e))==null?void 0:y.label)??e:l;return t.jsxs("div",{ref:g,style:{position:"relative",width:"100%"},children:[t.jsxs("div",{onClick:()=>!r&&i(p=>!p),style:{width:"100%",height:34,padding:"7px 10px",border:"1px solid",borderColor:a?"#3498db":"#ddd",borderRadius:6,fontSize:12,cursor:r?"default":"pointer",background:r?"#f5f5f5":"white",color:e?"#333":"#aaa",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"border-color 0.2s",userSelect:"none",boxSizing:"border-box",opacity:r?.75:1},children:[t.jsx("span",{children:j}),t.jsx("span",{style:{fontSize:9,color:"#999",transform:a?"rotate(180deg)":"none",transition:"transform 0.2s"},children:"▼"})]}),a&&t.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:t.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[t.jsx("div",{onClick:()=>{n(""),i(!1)},onMouseEnter:()=>u("__placeholder"),onMouseLeave:()=>u(""),style:{padding:"8px 14px",cursor:"pointer",fontSize:12,color:"#aaa",background:c==="__placeholder"?"#f5f5f5":"transparent"},children:l}),s.length===0&&t.jsx("div",{style:{padding:"10px 14px",color:"#aaa",fontSize:12},children:"No records found"}),s.map(p=>t.jsx("div",{onClick:()=>{n(p.name),i(!1)},onMouseEnter:()=>u(p.name),onMouseLeave:()=>u(""),style:{padding:"8px 14px",cursor:"pointer",fontSize:12,background:e===p.name?"#2563eb":c===p.name?"#f0f4ff":"transparent",color:e===p.name?"white":"#1a2332",transition:"background 0.1s"},children:p.label},p.name))]})})]})}function h0(e){const n=(Date.now()-new Date(e).getTime())/1e3;return n<60?`${Math.floor(n)}s ago`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:n<86400*7?`${Math.floor(n/86400)}d ago`:new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function g0(e){return e.replace(/@.*/,"").replace(/[._-]/g," ").split(" ").filter(Boolean).slice(0,2).map(s=>s[0].toUpperCase()).join("")}function ci({doctype:e,docname:n,currentUserName:s}){const l=ne(),[r,a]=C.useState([]),[i,c]=C.useState(!1),[u,g]=C.useState(""),[j,y]=C.useState(!1),[p,x]=C.useState(!1),[w,v]=C.useState(!1),[S,m]=C.useState(""),o=5,d=C.useCallback(async()=>{c(!0);const k=await Dy(e,n);a(k),c(!1)},[e,n]);C.useEffect(()=>{d()},[d]);const f=async()=>{const k=u.trim();if(!(!k||j)){y(!0),m("");try{await Ly(e,n,k),g(""),await d()}catch{m("Failed to post comment. Please try again.")}y(!1)}},z=async k=>{if(window.confirm("Delete this comment?"))try{await Fo("Comment",k),a(I=>I.filter(P=>P.name!==k))}catch{alert("Failed to delete comment.")}},b=w?r:r.slice(-o),h=Math.max(0,r.length-o);return t.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>x(k=>!k),style:{padding:"12px 20px",borderBottom:p?"none":"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none",background:"white"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:"#1a2332"},children:["💬 ",l.comments.title,r.length>0&&t.jsx("span",{style:{background:"#e8f4fd",color:"#2980b9",fontSize:11,fontWeight:700,borderRadius:10,padding:"2px 8px"},children:r.length})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("button",{onClick:k=>{k.stopPropagation(),d()},style:{background:"none",border:"none",cursor:"pointer",color:"#aaa",fontSize:16,padding:"2px 4px",lineHeight:1},title:"Refresh",children:"↻"}),t.jsx("span",{style:{color:"#ccc",fontSize:11},children:p?"▼":"▲"})]})]}),!p&&t.jsxs("div",{style:{padding:"16px 20px"},children:[!w&&h>0&&t.jsxs("button",{onClick:()=>v(!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 ",h," older comment",h!==1?"s":""]}),i&&t.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:l.loading}),!i&&r.length===0&&t.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:l.comments.noComments}),!i&&b.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:16},children:b.map(k=>{const I=k.comment_by||k.comment_email||k.owner||"Unknown",P=k.owner===s||k.comment_by===s;return t.jsxs("div",{style:{display:"flex",gap:10,padding:"12px 14px",background:"#f9fafb",borderRadius:8,border:"1px solid #e8e8e8"},children:[t.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:g0(I)}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:I}),t.jsx("span",{style:{fontSize:11,color:"#aaa"},children:h0(k.creation)})]}),P&&t.jsx("button",{onClick:()=>z(k.name),style:{background:"none",border:"none",cursor:"pointer",color:"#e74c3c",fontSize:16,padding:"0 2px",lineHeight:1},title:"Delete comment",children:"×"})]}),t.jsx("div",{style:{fontSize:13,color:"#374151",lineHeight:1.55,wordBreak:"break-word",whiteSpace:"pre-wrap"},dangerouslySetInnerHTML:{__html:k.content||""}})]})]},k.name)})}),t.jsxs("div",{style:{borderTop:r.length>0?"1px solid #f0f0f0":"none",paddingTop:r.length>0?14:0},children:[t.jsx("textarea",{value:u,onChange:k=>g(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.ctrlKey||k.metaKey)&&f()},placeholder:l.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&&t.jsx("div",{style:{fontSize:12,color:"#e74c3c",marginTop:4},children:S}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:t.jsx("button",{onClick:f,disabled:!u.trim()||j,style:{padding:"8px 20px",background:"#3498db",color:"white",border:"none",borderRadius:6,cursor:!u.trim()||j?"not-allowed":"pointer",fontSize:13,fontWeight:600,fontFamily:"Segoe UI",opacity:!u.trim()||j?.6:1},children:j?l.saving:l.comments.post})})]})]})]})}function Eu(e){if(!e)return"";const n=(Date.now()-new Date(e).getTime())/1e3;return n<60?`${Math.floor(n)}s ago`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:n<86400*7?`${Math.floor(n/86400)}d ago`:new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function x0(e){return(e||"").replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function Tu(e){return e==null||e===""?"(empty)":typeof e=="object"?JSON.stringify(e):String(e)}function Mo(e){return(e||"Unknown").replace(/@.*/,"").replace(/[._]/g," ")}function Pu(e){return Mo(e).split(" ").filter(Boolean).slice(0,2).map(n=>n[0].toUpperCase()).join("")}function m0(e){let n={};try{n=JSON.parse(e.data||"{}")}catch{}const s=(n.changed||[]).map(l=>({field:l[0]||"",oldVal:Tu(l[1]),newVal:Tu(l[2])}));return{name:e.name,owner:e.owner,creation:e.creation,changes:s,added:(n.added||[]).length,removed:(n.removed||[]).length,rowChanged:(n.row_changed||[]).length}}function di({doctype:e,docname:n,docCreation:s,docOwner:l}){const r=ne(),[a,i]=C.useState([]),[c,u]=C.useState(!1),[g,j]=C.useState(!0),[y,p]=C.useState(!1),x=5,w=C.useCallback(async()=>{u(!0);const o=await Oy(e,n);i(o.map(m0)),u(!1)},[e,n]);C.useEffect(()=>{g||w()},[g,w]);const v=y?a:a.slice(0,x),S=a.length-x,m=(o,d=!1)=>({position:"absolute",left:-14,top:14,width:10,height:10,borderRadius:"50%",background:o,border:"2px solid white",boxShadow:d?`0 0 0 2px ${o}44`:"none"});return t.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>j(o=>!o),style:{padding:"12px 20px",borderBottom:g?"none":"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:"#1a2332"},children:["📋 ",r.activity.title,!g&&a.length>0&&t.jsx("span",{style:{background:"#e8f4fd",color:"#2980b9",fontSize:11,fontWeight:700,borderRadius:10,padding:"2px 8px"},children:a.length})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!g&&t.jsx("button",{onClick:o=>{o.stopPropagation(),w()},style:{background:"none",border:"none",cursor:"pointer",color:"#aaa",fontSize:16,padding:"2px 4px",lineHeight:1},title:"Refresh",children:"↻"}),t.jsx("span",{style:{color:"#ccc",fontSize:11},children:g?"▼":"▲"})]})]}),!g&&t.jsxs("div",{style:{padding:"16px 20px"},children:[c&&t.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:r.loading}),!c&&t.jsxs("div",{style:{position:"relative",paddingLeft:20},children:[t.jsx("div",{style:{position:"absolute",left:8,top:0,bottom:0,width:2,background:"#e5e7eb"}}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[v.map((o,d)=>t.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[t.jsx("div",{style:m(d===0?"#3498db":"#d1d5db",d===0)}),t.jsxs("div",{style:{background:d===0?"#eff6ff":"#f9fafb",border:`1px solid ${d===0?"#bfdbfe":"#e5e7eb"}`,borderRadius:8,padding:"10px 14px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[t.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:Pu(o.owner)}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:Mo(o.owner)}),t.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:Eu(o.creation)})]}),o.changes.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:o.changes.map((f,z)=>t.jsxs("div",{style:{fontSize:12,lineHeight:1.5},children:[t.jsx("span",{style:{fontWeight:600,color:"#6d28d9"},children:x0(f.field)}),t.jsx("span",{style:{color:"#6b7280"},children:" changed from "}),t.jsx("span",{style:{padding:"1px 5px",background:"#fee2e2",color:"#dc2626",borderRadius:3,fontSize:11,fontFamily:"monospace"},children:f.oldVal}),t.jsx("span",{style:{color:"#6b7280"},children:" → "}),t.jsx("span",{style:{padding:"1px 5px",background:"#dcfce7",color:"#16a34a",borderRadius:3,fontSize:11,fontFamily:"monospace"},children:f.newVal})]},z))}):t.jsxs("div",{style:{fontSize:12,color:"#9ca3af",fontStyle:"italic"},children:["Document updated",o.added>0&&t.jsxs("span",{children:[" · +",o.added," row(s)"]}),o.removed>0&&t.jsxs("span",{children:[" · -",o.removed," row(s)"]}),o.rowChanged>0&&t.jsxs("span",{children:[" · ~",o.rowChanged," row(s) modified"]})]})]})]},o.name)),s&&l&&t.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[t.jsx("div",{style:m("#22c55e")}),t.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:"10px 14px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[t.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:Pu(l)}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:Mo(l)}),t.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:Eu(s)})]}),t.jsxs("div",{style:{fontSize:12,color:"#15803d",fontWeight:600},children:["✓ ",r.activity.created]})]})]}),a.length===0&&!s&&t.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:"No activity recorded"})]})]}),!c&&S>0&&t.jsx("div",{style:{textAlign:"center",marginTop:12},children:t.jsx("button",{onClick:()=>p(o=>!o),style:{background:"none",border:"none",cursor:"pointer",color:"#3498db",fontSize:12,fontFamily:"Segoe UI",padding:"4px 8px"},children:y?"▲ Show less":`▼ Show all (${a.length})`})})]})]})}const y0={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 v0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...y0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function j0({incForm:e,setIncForm:n,organizations:s,managements:l,departments:r,branches:a,incidentTypes:i,incidentClasses:c,incidentFields:u,incidentStatuses:g,users:j,userRoleMap:y={},formStatus:p,viewMode:x,canModify:w,onEdit:v,onDelete:S,onRestore:m,darkMode:o,notifCount:d,onToggleDark:f,onCountChange:z,onViewProfile:b,userRole:h,delegatedFunctions:k=[],delegatedOrgs:I={},onSubmit:P,onBack:M,onNavigate:ee,onLogout:W,user:$,onRefresh:T}){var ft;const D=ne(),Q=U=>n({...e,...U}),Y=x?{background:"#f9f9f9"}:{},X=Cl(j,y,"SB Manager",e.organization),[q,N]=C.useState(""),[Z,ce]=C.useState(!1),me=e.name?x?`${D.formTitle.viewIncident}${e.number||e.name}`:D.formTitle.editIncident:D.formTitle.newIncident,le=ye(l,e.management).map(U=>({name:U.name,label:U.name1||U.name})),Ve=ye(r,e.department).map(U=>({name:U.name,label:U.department_name||U.name})),ct=ye(a,e.branch).map(U=>({name:U.name,label:U.branch||U.name})),K=ye(i,e.type).map(U=>({name:U.name,label:U.name1||U.name})),oe=ye(c,e.incident_class).map(U=>({name:U.name,label:U.name1||U.name})),Oe=ye(u,e.incident_field).map(U=>({name:U.name,label:U.name1||U.name})),ve=e.workflow_state||"New",nn=h==="Employee",fe=h==="Auditor"||h==="Admin",je=h==="Manager",Et=je&&k.includes("incident_initial_evaluation")&&(!I.incident_initial_evaluation||(I.incident_initial_evaluation||[]).includes(e.organization)),Ne=fe||Et,L=e.name?ve==="New"?[{label:D.wf.submit,action:"Submit",color:"#2563eb"}]:ve==="Initial Evaluation"&&Ne?[{label:D.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:D.wf.reject,action:"Reject",color:"#dc2626"}]:ve==="Accept & Under Progress"&&(je||fe)?[{label:D.wf.submitSolution,action:"Submit Solution",color:"#059669"}]:ve==="working on resolution"&&(je||fe)?[{label:D.wf.resolutionComplete,action:"Resolution complete",color:"#166534"}]:[]:[];async function se(U){if(e.name){ce(!0),N("");try{const Be={};U==="Assign to Manager"&&(e.assigned_to&&(Be.assigned_to=e.assigned_to),e.priority&&(Be.priority=e.priority),e.economy_class&&(Be.economy_class=e.economy_class),e.entity_scope&&(Be.entity_scope=e.entity_scope),e.hses_field&&(Be.hses_field=e.hses_field),Be.product_relation=String(e.product_relation??0),Be.repeated=String(e.repeated??0)),U==="Submit Solution"&&(e.solution&&(Be.solution=e.solution),e.summary&&(Be.summary=e.summary),e.cost&&(Be.cost=String(e.cost))),(U==="Resolution complete"||U==="Submit Solution")&&e.auditor_comment&&(Be.auditor_comment=e.auditor_comment),await By(e.name,U,JSON.stringify(Be)),N("Done"),T==null||T()}catch(Be){N(Be.message||"Error")}finally{ce(!1)}}}const R=((ft=X.find(U=>U.name===e.assigned_to))==null?void 0:ft.full_name)||e.assigned_to,We=e.name?t.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:D.wf.workflow}),t.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px",marginBottom:12},children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:4},children:"Current State"}),t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b"},children:ve})]}),ve==="Initial Evaluation"&&Ne&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:E,children:D.wf.assignToManager}),t.jsxs("select",{style:A,value:e.assigned_to||"",onChange:U=>Q({assigned_to:U.target.value}),children:[t.jsx("option",{value:"",children:D.field.selectMgr}),X.map(U=>t.jsx("option",{value:U.name,children:U.full_name||U.name},U.name))]})]}),(ve==="Accept & Under Progress"||ve==="working on resolution")&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:E,children:D.field.solution}),t.jsx("textarea",{style:{...A,height:75,resize:"vertical"},value:e.solution||"",onChange:U=>Q({solution:U.target.value}),placeholder:D.field.solutionPlaceholder}),t.jsx("label",{style:{...E,marginTop:6},children:D.field.actualCost}),t.jsx("input",{type:"number",style:A,value:e.cost||"",onChange:U=>Q({cost:parseFloat(U.target.value)||0}),placeholder:"0.00"})]}),ve==="working on resolution"&&fe&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:E,children:D.field.auditorComment}),t.jsx("textarea",{style:{...A,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:U=>Q({auditor_comment:U.target.value}),placeholder:D.field.commentPlaceholder})]}),L.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:L.map(U=>t.jsx("button",{onClick:()=>se(U.action),disabled:Z,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:U.color,color:"white",fontWeight:600,fontSize:12,cursor:Z?"not-allowed":"pointer",opacity:Z?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:t.jsx("span",{children:Z?D.wf.applying:U.label})},U.action))}):t.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:D.wf.noActions}),q&&t.jsx("p",{style:{marginTop:8,fontSize:12,color:q==="Done"?F.green:F.red},children:q})]}),t.jsx(ii,{priority:e.priority,status:ve,assignedTo:h!=="Employee"?R:void 0,createdDate:e.date,modifiedDate:e.modified}),t.jsx(ci,{doctype:O.incidents,docname:e.name,currentUserName:$.name}),t.jsx(di,{doctype:O.incidents,docname:e.name,docCreation:e.creation,docOwner:e.owner}),w&&S&&!e.custom_is_deleted&&t.jsx(ai,{title:"Delete Request",btnText:D.delete,onDelete:()=>S(e.name)})]}):null;return t.jsxs(Ze,{title:me,activePage:"incidents",user:$,formStatus:p,statusBadge:t.jsx("span",{style:v0(ve),children:ve}),buttonText:D.saveIncident,buttonColor:"#16a34a",viewMode:x,onEdit:v,darkMode:o,notifCount:d,onToggleDark:f,onCountChange:z,onViewProfile:b,rightPanel:We,onSubmit:P,onBack:M,onNavigate:ee,onLogout:W,children:[e.custom_is_deleted===1&&t.jsx(Pr,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:m?()=>m(e.name):void 0}),t.jsx(re,{title:"Incident Information",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.number}),t.jsx("input",{style:{...A,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[D.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.organization,onChange:U=>Q({organization:U}),organizations:s,disabled:x||!!$.custom_organization})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.title}),t.jsx("input",{style:{...A,...Y},value:e.title,disabled:x,onChange:U=>Q({title:U.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.management}),t.jsx(pe,{value:e.management,onChange:U=>Q({management:U}),items:le,placeholder:D.field.select,disabled:x})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.department}),t.jsx(pe,{value:e.department,onChange:U=>Q({department:U}),items:Ve,placeholder:D.field.select,disabled:x})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.section}),t.jsx("input",{style:{...A,...Y},value:e.section_field||"",disabled:x,onChange:U=>Q({section_field:U.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.branch}),t.jsx(pe,{value:e.branch,onChange:U=>Q({branch:U}),items:ct,placeholder:D.field.select,disabled:x})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.type}),t.jsx(pe,{value:e.type,onChange:U=>Q({type:U}),items:K,placeholder:D.field.selectType,disabled:x})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.incidentClass}),t.jsx(pe,{value:e.incident_class,onChange:U=>Q({incident_class:U}),items:oe,placeholder:D.field.selectClass,disabled:x})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.incidentField}),t.jsx(pe,{value:e.incident_field,onChange:U=>Q({incident_field:U}),items:Oe,placeholder:D.field.selectField,disabled:x})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.hsesField}),t.jsx("input",{style:{...A,...Y},value:e.hses_field||"",disabled:x,onChange:U=>Q({hses_field:U.target.value}),placeholder:"Safety, Health, Environment…"})]})]})}),t.jsxs(re,{title:"Incident Details & Timing",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.date}),t.jsx(xe,{value:e.date,onChange:U=>Q({date:U}),disabled:!0,style:{...A,background:"#f8fafc"}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.time}),t.jsx("input",{type:"time",style:{...A,background:"#f8fafc"},value:e.time,disabled:!0,readOnly:!0})]}),h!=="Employee"&&t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.assignedTo}),x?t.jsx("input",{style:{...A,background:"#f8fafc",fontWeight:600,color:"#334155"},value:R||"—",readOnly:!0,disabled:!0}):t.jsx(pe,{value:e.assigned_to||"",onChange:U=>Q({assigned_to:U}),items:X.map(U=>({name:U.name,label:U.full_name||U.name})),placeholder:D.field.select})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.description}),t.jsx("textarea",{style:{...A,...Y,height:100,resize:"vertical"},value:e.description,disabled:x,onChange:U=>Q({description:U.target.value}),placeholder:"Detailed description of the incident..."})]})]}),!nn&&t.jsxs(re,{title:D.steps.auditorTriage,children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.priority}),t.jsxs("select",{style:{...A,...x||!Ne?{background:"#f8fafc"}:{}},value:e.priority||"",disabled:x||!Ne,onChange:U=>Q({priority:U.target.value}),children:[t.jsx("option",{value:"",children:D.field.select}),t.jsx("option",{value:"High",children:D.field.high}),t.jsx("option",{value:"Normal",children:D.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.economyClass}),t.jsxs("select",{style:{...A,...x||!Ne?{background:"#f8fafc"}:{}},value:e.economy_class||"",disabled:x||!Ne,onChange:U=>Q({economy_class:U.target.value}),children:[t.jsx("option",{value:"",children:D.field.select}),t.jsx("option",{value:"Expenses",children:D.field.expenses}),t.jsx("option",{value:"Capital",children:D.field.capital}),t.jsx("option",{value:"Earn",children:D.field.earn}),t.jsx("option",{value:"Pay/Loss",children:D.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.entityScope}),t.jsxs("select",{style:{...A,...x||!Ne?{background:"#f8fafc"}:{}},value:e.entity_scope||"",disabled:x||!Ne,onChange:U=>Q({entity_scope:U.target.value}),children:[t.jsx("option",{value:"",children:D.field.select}),t.jsx("option",{value:"Upstream",children:D.field.upstream}),t.jsx("option",{value:"On-stream",children:D.field.onstream}),t.jsx("option",{value:"Downstream",children:D.field.downstream})]})]})]}),t.jsxs("div",{style:{display:"flex",gap:20,marginTop:12,alignItems:"center",flexWrap:"wrap"},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:x||!Ne,onChange:U=>Q({product_relation:U.target.checked?1:0})})," ",D.field.productRelation]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.repeated,disabled:x||!Ne,onChange:U=>Q({repeated:U.target.checked?1:0})})," ",D.field.repeatedEvent]})]})]}),!nn&&t.jsxs(re,{title:D.steps.managerSolution,children:[t.jsxs("div",{style:{marginBottom:12},children:[t.jsx("label",{style:E,children:D.field.solution}),t.jsx("textarea",{style:{...A,height:90,resize:"vertical",...x&&!je&&!fe?{background:"#f8fafc"}:{}},value:e.solution||"",disabled:x&&!je&&!fe,onChange:U=>Q({solution:U.target.value}),placeholder:D.field.solutionPlaceholder})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.actualCost}),t.jsx("input",{type:"number",style:{...A,...x&&!je&&!fe?{background:"#f8fafc"}:{}},value:e.cost||"",disabled:x&&!je&&!fe,onChange:U=>Q({cost:parseFloat(U.target.value)||0}),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.summary}),t.jsx("input",{style:{...A,...x&&!je&&!fe?{background:"#f8fafc"}:{}},value:e.summary||"",disabled:x&&!je&&!fe,onChange:U=>Q({summary:U.target.value}),placeholder:"Brief summary"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:D.field.auditorComment}),t.jsx("textarea",{style:{...A,height:70,resize:"vertical",...x&&!fe?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:x&&!fe,onChange:U=>Q({auditor_comment:U.target.value}),placeholder:D.field.commentPlaceholder})]})]})]})}function b0({ideas:e,organizations:n,departments:s,branches:l,ideaStatuses:r,initialOrg:a,initialStatus:i,canModify:c,userRole:u,onView:g,onEdit:j,onDelete:y}){const p=ne(),[x,w]=C.useState(new Set),[v,S]=C.useState({search:"",organization:a||"",department:"",branch:"",status:i||""}),m=(h,k)=>S(I=>({...I,[h]:k})),[o,d]=C.useState(1),f=e.filter(h=>!(v.search&&!`${h.number} ${h.title}`.toLowerCase().includes(v.search.toLowerCase())||v.organization&&h.organization!==v.organization||v.department&&h.department!==v.department||v.branch&&h.branch!==v.branch||v.status&&h.status!==v.status));C.useEffect(()=>{d(1)},[v]);const z=f.slice((o-1)*ae,o*ae),b=h=>{const k=e.filter(M=>x.has(M.name)),I=Me.ideas,P=I.columns.filter(M=>I.defaultColumns.includes(M.key));h==="csv"?He(P,k,"ideas_selected"):Ge(P,k,"ideas_selected")};return t.jsxs(t.Fragment,{children:[t.jsx(oi,{children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"10px 14px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.numberTitle}),t.jsx("input",{style:nt,value:v.search,onChange:h=>m("search",h.target.value),placeholder:p.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.organization}),t.jsxs("select",{style:nt,value:v.organization,onChange:h=>m("organization",h.target.value),children:[t.jsx("option",{value:"",children:p.filter.allOrgs}),n.map(h=>t.jsx("option",{value:h.name,children:h.organization_name||h.name},h.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.department}),t.jsxs("select",{style:nt,value:v.department,onChange:h=>m("department",h.target.value),children:[t.jsx("option",{value:"",children:p.filter.allDepts}),s.map(h=>t.jsx("option",{value:h.name,children:h.department_name||h.name},h.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.branch}),t.jsxs("select",{style:nt,value:v.branch,onChange:h=>m("branch",h.target.value),children:[t.jsx("option",{value:"",children:p.filter.allBranches}),l.map(h=>t.jsx("option",{value:h.name,children:h.branch||h.name},h.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.status}),t.jsxs("select",{style:nt,value:v.status,onChange:h=>m("status",h.target.value),children:[t.jsx("option",{value:"",children:p.filter.allStatuses}),r.map(h=>t.jsx("option",{value:h.name,children:h.name1||h.name},h.name))]})]}),t.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:t.jsx("button",{onClick:()=>S({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})})]})}),t.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[t.jsx("th",{style:{width:44,padding:"12px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:z.length>0&&z.every(h=>x.has(h.name)),onChange:h=>{if(h.target.checked)w(new Set([...x,...z.map(k=>k.name)]));else{const k=new Set(x);z.forEach(I=>k.delete(I.name)),w(k)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.actions})]})}),t.jsx("tbody",{children:f.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:p.noIdeas})}):z.map((h,k)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>g==null?void 0:g(h),style:{borderTop:"1px solid #f1f5f9",background:x.has(h.name)?"#eff6ff":h.custom_is_deleted?"#fff1f2":k%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:I=>I.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:x.has(h.name),onChange:()=>{const I=new Set(x);I.has(h.name)?I.delete(h.name):I.add(h.name),w(I)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:h.number||"—"}),t.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[t.jsx("span",{children:h.title||"—"}),h.sb_order&&t.jsxs("span",{style:{fontSize:11,background:"#f0fdf4",color:"#15803d",border:"1px solid #bbf7d0",borderRadius:9999,padding:"2px 8px",fontWeight:600},children:["📦 ",h.sb_order]})]})}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:h.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:h.custom_is_deleted?es(p.deletedBadge):h.status?es(h.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:I=>I.stopPropagation(),children:t.jsx(at,{onView:()=>g==null?void 0:g(h),onEdit:c&&j&&!h.custom_is_deleted&&!Fn("idea",h.workflow_state)&&!(u==="Employee"&&h.workflow_state&&h.workflow_state!=="New")?()=>j(h):void 0,onDelete:c&&y&&!h.custom_is_deleted?()=>y(h.name):void 0})})]},h.name))})]})}),t.jsx(Je,{count:x.size,onClear:()=>w(new Set),onExport:b}),t.jsx(qe,{page:o,total:f.length,onPageChange:d})]})}const S0={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 w0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...S0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function k0({ideaForm:e,setIdeaForm:n,organizations:s,managements:l,departments:r,branches:a,ideaTypes:i,ideaStatuses:c,users:u=[],userRoleMap:g={},formStatus:j,viewMode:y,canModify:p,onEdit:x,onDelete:w,onRestore:v,onNavigateToOrder:S,darkMode:m,notifCount:o,onToggleDark:d,onCountChange:f,onViewProfile:z,userRole:b,delegatedFunctions:h=[],delegatedOrgs:k={},onSubmit:I,onBack:P,onNavigate:M,onLogout:ee,user:W,onRefresh:$}){var se;const T=ne(),D=R=>n({...e,...R}),Q=y?{background:"#f9f9f9"}:{},Y=Cl(u,g,"SB Manager",e.organization),[X,q]=C.useState(""),[N,Z]=C.useState(!1),ce=e.name?y?`${T.formTitle.viewIdea}${e.number||e.title||e.name}`:T.formTitle.editIdea:T.formTitle.newIdea,me=ye(l,e.management).map(R=>({name:R.name,label:R.name1||R.name})),le=ye(r,e.department).map(R=>({name:R.name,label:R.department_name||R.name})),Ve=ye(a,e.branch).map(R=>({name:R.name,label:R.branch||R.name})),ct=ye(i,e.type).map(R=>({name:R.name,label:R.name1||R.name})),K=e.workflow_state||"New",oe=b==="Employee",Oe=b==="Auditor"||b==="Admin",ve=b==="Manager",nn=ve&&h.includes("idea_initial_evaluation")&&(!k.idea_initial_evaluation||(k.idea_initial_evaluation||[]).includes(e.organization)),fe=Oe||nn,je=e.name?K==="New"?[{label:T.wf.submit,action:"Submit",color:"#2563eb"}]:K==="Initial Evaluation"&&fe?[{label:T.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:T.wf.reject,action:"Reject",color:"#dc2626"}]:K==="Accept & Under Progress"&&(ve||Oe)?[{label:T.wf.submitSolution,action:"Submit Proposal",color:"#059669"}]:K==="working on proposal"&&Oe?[{label:T.wf.moveToOutsourcing,action:"Move to Outsourcing",color:"#0369a1"},{label:T.wf.reject,action:"Reject",color:"#dc2626"}]:[]:[];async function Et(R){if(e.name){Z(!0),q("");try{const We={};R==="Assign to Manager"&&(e.assigned_to&&(We.assigned_to=e.assigned_to),e.priority&&(We.priority=e.priority),e.economy_class&&(We.economy_class=e.economy_class),e.entity_scope&&(We.entity_scope=e.entity_scope),e.hses_field&&(We.hses_field=e.hses_field),We.product_relation=String(e.product_relation??0),We.repeated=String(e.repeated??0)),R==="Submit Proposal"&&(e.solution&&(We.solution=e.solution),e.proposed_condition&&(We.proposed_condition=e.proposed_condition),e.cost&&(We.cost=String(e.cost))),e.auditor_comment&&(R==="Move to Outsourcing"||R==="Reject")&&(We.auditor_comment=e.auditor_comment);const ft=await $y(e.name,R,JSON.stringify(We));ft!=null&&ft.created_order&&D({sb_order:ft.created_order,workflow_state:"Executed & Closed",status:"Executed & Closed"}),q("Done"),$==null||$()}catch(We){q(We.message||"Error")}finally{Z(!1)}}}const Ne=((se=Y.find(R=>R.name===e.assigned_to))==null?void 0:se.full_name)||e.assigned_to,L=e.name?t.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:T.wf.workflow}),t.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px",marginBottom:12},children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:4},children:"Current State"}),t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b"},children:K})]}),K==="Initial Evaluation"&&fe&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:E,children:T.wf.assignToManager}),t.jsxs("select",{style:A,value:e.assigned_to||"",onChange:R=>D({assigned_to:R.target.value}),children:[t.jsx("option",{value:"",children:T.field.selectMgr}),Y.map(R=>t.jsx("option",{value:R.name,children:R.full_name||R.name},R.name))]})]}),K==="Accept & Under Progress"&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:E,children:T.field.solution}),t.jsx("textarea",{style:{...A,height:75,resize:"vertical"},value:e.solution||"",onChange:R=>D({solution:R.target.value}),placeholder:T.field.solutionPlaceholder}),t.jsx("label",{style:{...E,marginTop:6},children:T.field.actualCost}),t.jsx("input",{type:"number",style:A,value:e.cost||"",onChange:R=>D({cost:parseFloat(R.target.value)||0}),placeholder:"0.00"})]}),K==="working on proposal"&&Oe&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:E,children:T.field.auditorComment}),t.jsx("textarea",{style:{...A,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:R=>D({auditor_comment:R.target.value}),placeholder:T.field.commentPlaceholder})]}),je.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:je.map(R=>t.jsx("button",{onClick:()=>Et(R.action),disabled:N,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:R.color,color:"white",fontWeight:600,fontSize:12,cursor:N?"not-allowed":"pointer",opacity:N?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:t.jsx("span",{children:N?T.wf.applying:R.label})},R.action))}):t.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:T.wf.noActions}),X&&t.jsx("p",{style:{marginTop:8,fontSize:12,color:X==="Done"?F.green:F.red},children:X})]}),t.jsx(ii,{priority:e.priority,status:K,assignedTo:b!=="Employee"?Ne:void 0,createdDate:e.date,modifiedDate:e.modified}),t.jsx(ci,{doctype:O.ideas,docname:e.name,currentUserName:W.name}),t.jsx(di,{doctype:O.ideas,docname:e.name,docCreation:e.creation,docOwner:e.owner}),p&&w&&!e.custom_is_deleted&&t.jsx(ai,{title:"Delete Request",btnText:T.delete,onDelete:()=>w(e.name)})]}):null;return t.jsxs(Ze,{title:ce,activePage:"ideas",user:W,formStatus:j,statusBadge:t.jsx("span",{style:w0(K),children:K}),buttonText:T.saveIdea,buttonColor:"#16a34a",viewMode:y,onEdit:x,darkMode:m,notifCount:o,onToggleDark:d,onCountChange:f,onViewProfile:z,rightPanel:L,onSubmit:I,onBack:P,onNavigate:M,onLogout:ee,children:[e.custom_is_deleted===1&&t.jsx(Pr,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:v?()=>v(e.name):void 0}),e.sb_order&&t.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:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[t.jsx("span",{style:{fontSize:14,flexShrink:0},children:"📦"}),t.jsxs("span",{style:{fontSize:11,fontWeight:700,color:"#15803d",textTransform:"uppercase",letterSpacing:"0.4px",whiteSpace:"nowrap"},children:[T.field.convertedToOrder,":"]}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#14532d",whiteSpace:"nowrap"},children:e.sb_order})]}),S&&t.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:R=>R.currentTarget.style.background="#15803d",onMouseLeave:R=>R.currentTarget.style.background="#16a34a",children:[T.field.viewOrder," →"]})]}),t.jsx(re,{title:"Idea Information",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.number}),t.jsx("input",{style:{...A,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[T.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.organization,onChange:R=>D({organization:R}),organizations:s,disabled:y||!!W.custom_organization})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.title}),t.jsx("input",{style:{...A,...Q},value:e.title,disabled:y,onChange:R=>D({title:R.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.management}),t.jsx(pe,{value:e.management,onChange:R=>D({management:R}),items:me,placeholder:T.field.select,disabled:y})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.department}),t.jsx(pe,{value:e.department,onChange:R=>D({department:R}),items:le,placeholder:T.field.select,disabled:y})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.section}),t.jsx("input",{style:{...A,...Q},value:e.section_field||"",disabled:y,onChange:R=>D({section_field:R.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.branch}),t.jsx(pe,{value:e.branch,onChange:R=>D({branch:R}),items:Ve,placeholder:T.field.select,disabled:y})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.type}),t.jsx(pe,{value:e.type,onChange:R=>D({type:R}),items:ct,placeholder:T.field.selectType,disabled:y})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.ideaClass}),t.jsxs("select",{style:{...A,...Q},value:e.idea_class||"",disabled:y,onChange:R=>D({idea_class:R.target.value}),children:[t.jsx("option",{value:"",children:T.field.select}),t.jsx("option",{value:"Safety",children:"Safety"}),t.jsx("option",{value:"Non-safety",children:"Non-safety"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.hsesField}),t.jsx("input",{style:{...A,...Q},value:e.hses_field||"",disabled:y,onChange:R=>D({hses_field:R.target.value}),placeholder:"Safety, Health, Environment…"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.date}),t.jsx(xe,{value:e.date||"",onChange:R=>D({date:R}),disabled:!0,style:{...A,background:"#f8fafc"}})]}),b!=="Employee"&&t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.assignedTo}),y?t.jsx("input",{style:{...A,background:"#f8fafc",fontWeight:600,color:"#334155"},value:Ne||"—",readOnly:!0,disabled:!0}):t.jsx(pe,{value:e.assigned_to||"",onChange:R=>D({assigned_to:R}),items:Y.map(R=>({name:R.name,label:R.full_name||R.name})),placeholder:T.field.select})]})]})}),t.jsx(re,{title:"Condition Details & Description",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.currentCondition}),t.jsx("textarea",{style:{...A,...Q,height:100,resize:"vertical"},value:e.current_condition,disabled:y,onChange:R=>D({current_condition:R.target.value}),placeholder:"Describe the current condition or problem..."})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.proposedCondition}),t.jsx("textarea",{style:{...A,...Q,height:100,resize:"vertical"},value:e.proposed_condition,disabled:y,onChange:R=>D({proposed_condition:R.target.value}),placeholder:"Describe the proposed solution or improvement..."})]})]})}),!oe&&t.jsxs(re,{title:T.steps.auditorEval,children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.priority}),t.jsxs("select",{style:{...A,...y||!fe?{background:"#f8fafc"}:{}},value:e.priority||"",disabled:y||!fe,onChange:R=>D({priority:R.target.value}),children:[t.jsx("option",{value:"",children:T.field.select}),t.jsx("option",{value:"High",children:T.field.high}),t.jsx("option",{value:"Normal",children:T.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.economyClass}),t.jsxs("select",{style:{...A,...y||!fe?{background:"#f8fafc"}:{}},value:e.economy_class||"",disabled:y||!fe,onChange:R=>D({economy_class:R.target.value}),children:[t.jsx("option",{value:"",children:T.field.select}),t.jsx("option",{value:"Expenses",children:T.field.expenses}),t.jsx("option",{value:"Capital",children:T.field.capital}),t.jsx("option",{value:"Earn",children:T.field.earn}),t.jsx("option",{value:"Pay/Loss",children:T.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.entityScope}),t.jsxs("select",{style:{...A,...y||!fe?{background:"#f8fafc"}:{}},value:e.entity_scope||"",disabled:y||!fe,onChange:R=>D({entity_scope:R.target.value}),children:[t.jsx("option",{value:"",children:T.field.select}),t.jsx("option",{value:"Upstream",children:T.field.upstream}),t.jsx("option",{value:"On-stream",children:T.field.onstream}),t.jsx("option",{value:"Downstream",children:T.field.downstream})]})]})]}),t.jsxs("div",{style:{display:"flex",gap:20,marginTop:12,alignItems:"center",flexWrap:"wrap"},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:y||!fe,onChange:R=>D({product_relation:R.target.checked?1:0})})," ",T.field.productRelation]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.repeated,disabled:y||!fe,onChange:R=>D({repeated:R.target.checked?1:0})})," ",T.field.repeatedEvent]})]})]}),!oe&&t.jsxs(re,{title:T.steps.managerSolution,children:[t.jsxs("div",{style:{marginBottom:12},children:[t.jsx("label",{style:E,children:T.field.solution}),t.jsx("textarea",{style:{...A,height:90,resize:"vertical",...y&&!ve&&!Oe?{background:"#f8fafc"}:{}},value:e.solution||"",disabled:y&&!ve&&!Oe,onChange:R=>D({solution:R.target.value}),placeholder:T.field.solutionPlaceholder})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.actualCost}),t.jsx("input",{type:"number",style:{...A,...y&&!ve&&!Oe?{background:"#f8fafc"}:{}},value:e.cost||"",disabled:y&&!ve&&!Oe,onChange:R=>D({cost:parseFloat(R.target.value)||0}),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.auditorComment}),t.jsx("textarea",{style:{...A,height:60,resize:"vertical",...y&&!Oe?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:y&&!Oe,onChange:R=>D({auditor_comment:R.target.value}),placeholder:T.field.commentPlaceholder})]})]})]})]})}function _0({orders:e,organizations:n,departments:s,branches:l,orderStatuses:r,initialOrg:a,initialStatus:i,canModify:c,userRole:u,onView:g,onEdit:j,onDelete:y}){const p=ne(),[x,w]=C.useState(new Set),[v,S]=C.useState({search:"",organization:a||"",department:"",branch:"",status:i||""}),m=(h,k)=>S(I=>({...I,[h]:k})),[o,d]=C.useState(1),f=e.filter(h=>!(v.search&&!`${h.number} ${h.title}`.toLowerCase().includes(v.search.toLowerCase())||v.organization&&h.organization!==v.organization||v.department&&h.department!==v.department||v.branch&&h.branch!==v.branch||v.status&&h.status!==v.status));C.useEffect(()=>{d(1)},[v]);const z=f.slice((o-1)*ae,o*ae),b=h=>{const k=e.filter(M=>x.has(M.name)),I=Me.orders,P=I.columns.filter(M=>I.defaultColumns.includes(M.key));h==="csv"?He(P,k,"orders_selected"):Ge(P,k,"orders_selected")};return t.jsxs(t.Fragment,{children:[t.jsx(oi,{children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"10px 14px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.numberTitle}),t.jsx("input",{style:nt,value:v.search,onChange:h=>m("search",h.target.value),placeholder:p.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.organization}),t.jsxs("select",{style:nt,value:v.organization,onChange:h=>m("organization",h.target.value),children:[t.jsx("option",{value:"",children:p.filter.allOrgs}),n.map(h=>t.jsx("option",{value:h.name,children:h.organization_name},h.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.department}),t.jsxs("select",{style:nt,value:v.department,onChange:h=>m("department",h.target.value),children:[t.jsx("option",{value:"",children:p.filter.allDepts}),s.map(h=>t.jsx("option",{value:h.name,children:h.department_name},h.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.branch}),t.jsxs("select",{style:nt,value:v.branch,onChange:h=>m("branch",h.target.value),children:[t.jsx("option",{value:"",children:p.filter.allBranches}),l.map(h=>t.jsx("option",{value:h.name,children:h.branch},h.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.status}),t.jsxs("select",{style:nt,value:v.status,onChange:h=>m("status",h.target.value),children:[t.jsx("option",{value:"",children:p.filter.allStatuses}),r.map(h=>t.jsx("option",{value:h.name,children:h.name1||h.name},h.name))]})]}),t.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:t.jsx("button",{type:"button",onClick:()=>{S({search:"",organization:a||"",department:"",branch:"",status:""}),d(1)},style:{height:38,padding:"0 16px",border:"1px solid #d1d5db",borderRadius:8,background:"#fff",color:"#374151",fontSize:13,fontWeight:500,cursor:"pointer",width:"100%"},children:p.clear})})]})}),t.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[t.jsx("th",{style:{width:44,padding:"12px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:z.length>0&&z.every(h=>x.has(h.name)),onChange:h=>{if(h.target.checked)w(new Set([...x,...z.map(k=>k.name)]));else{const k=new Set(x);z.forEach(I=>k.delete(I.name)),w(k)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.type}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.actions})]})}),t.jsx("tbody",{children:f.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:p.noOrders})}):z.map((h,k)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>g==null?void 0:g(h),style:{borderTop:"1px solid #f1f5f9",background:x.has(h.name)?"#eff6ff":h.custom_is_deleted?"#fff1f2":k%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:I=>I.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:x.has(h.name),onChange:()=>{const I=new Set(x);I.has(h.name)?I.delete(h.name):I.add(h.name),w(I)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:h.number||"—"}),t.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[t.jsx("span",{children:h.title||"—"}),h.sb_idea&&t.jsxs("span",{style:{fontSize:11,background:"#eff6ff",color:"#1d4ed8",border:"1px solid #bfdbfe",borderRadius:9999,padding:"2px 8px",fontWeight:600},children:["💡 ",h.sb_idea]})]})}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:h.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:h.type?Wc(h.type):"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:h.custom_is_deleted?es(p.deletedBadge):h.status?es(h.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:I=>I.stopPropagation(),children:t.jsx(at,{onView:()=>g==null?void 0:g(h),onEdit:c&&j&&!h.custom_is_deleted&&!Fn("order",h.workflow_state)&&u!=="Employee"?()=>j(h):void 0,onDelete:c&&y&&!h.custom_is_deleted?()=>y(h.name):void 0})})]},h.name))})]})}),t.jsx(Je,{count:x.size,onClear:()=>w(new Set),onExport:b}),t.jsx(qe,{page:o,total:f.length,onPageChange:d})]})}const C0={1:"Initiation / Bidding",2:"Execution begins",3:"Mid-execution review",4:"Near completion",5:"Closing"},z0={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 I0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...z0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function E0({orderForm:e,setOrderForm:n,organizations:s,managements:l,departments:r,branches:a,orderTypes:i,orderStatuses:c,cycles:u=[],users:g=[],userRoleMap:j={},formStatus:y,viewMode:p,canModify:x,onEdit:w,onDelete:v,onRestore:S,onNavigateToIdea:m,darkMode:o,notifCount:d,onToggleDark:f,onCountChange:z,onViewProfile:b,currentUser:h,userRole:k,onSubmit:I,onBack:P,onNavigate:M,onLogout:ee,user:W,onRefresh:$}){var hn,Rr;const T=ne(),D=B=>n({...e,...B}),Q=p?{background:"#f9f9f9"}:{},Y=Cl(g,j,"SB Employee",e.organization),[X,q]=C.useState(""),[N,Z]=C.useState(""),[ce,me]=C.useState(!1),[le,Ve]=C.useState("Agree"),ct=e.name?p?`${T.formTitle.viewOrder}${e.number||e.title||e.name}`:T.formTitle.editOrder:T.formTitle.newOrder,K=ye(l,e.management).map(B=>({name:B.name,label:B.name1||B.name})),oe=ye(r,e.department).map(B=>({name:B.name,label:B.department_name||B.name})),Oe=ye(a,e.branch).map(B=>({name:B.name,label:B.branch||B.name})),ve=ye(i,e.type).map(B=>({name:B.name,label:B.name1||B.name})),nn=ye(u,e.cycle).map(B=>({name:B.name,label:B.name1||B.cycle_name||B.name})),fe=!!e.name,je=e.workflow_state||"Draft",Et=Math.min(5,(e.stage||0)+1),[Ne,L]=C.useState(Et);C.useEffect(()=>{L(Math.min(5,(e.stage||0)+1))},[e.stage]);const se=k==="Auditor"||k==="Admin"||k==="Manager",R=se||k==="Owner",We=!!(h&&(e.actor===h||e.assigned_to===h)),ft=fe?je==="Closed"?[]:je==="Draft"&&se?[{label:"Submit for Review",action:"Submit for Review",color:"#2563eb"}]:je==="Pending Actor"&&(We||se)?[{label:"Update Status",action:"Update Status",color:"#d97706"}]:je==="Review"&&R?[{label:"Move to Study",action:"Move to Study",color:"#059669"},{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"}]:je==="In Study"&&R?[{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"},{label:"Close Order",action:"Close Order",color:"#475569"}]:[]:[];async function U(B){if(e.name){me(!0),q("");try{let Tt;B==="Update Status"&&(Tt=le);const gn=await Wy(e.name,B,N,B==="Update Status"?String(Ne):void 0,void 0,Tt);if(Z(""),Ve("Agree"),q("Done"),gn){const An=gn;n({...e,...An,stage:An.stage??e.stage,completion_pct:An.completion_pct??e.completion_pct,workflow_state:An.workflow_state??e.workflow_state})}$==null||$()}catch(Tt){q(Tt.message||"Error")}finally{me(!1)}}}const Be=((hn=Y.find(B=>B.name===(e.actor||e.assigned_to)))==null?void 0:hn.full_name)||e.actor||e.assigned_to,ui=fe?t.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:T.wf.workflow}),t.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px",marginBottom:12},children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:4},children:"Current State"}),t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b"},children:je})]}),je==="Pending Actor"&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:12},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:["Stage (1–5) — ",Ne*20,"% complete"]}),t.jsx("input",{type:"number",min:1,max:5,style:{...A,width:"100%"},value:Ne,onChange:B=>L(Math.min(5,Math.max(1,parseInt(B.target.value)||1)))})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Cycle Status"}),t.jsxs("select",{style:A,value:le,onChange:B=>Ve(B.target.value),children:[t.jsx("option",{value:"Agree",children:"✅ Agree — on track"}),t.jsx("option",{value:"Deviate",children:"⚠️ Deviate — off plan"}),t.jsx("option",{value:"Unknown",children:"❓ Unknown"})]})]})]}),t.jsxs("div",{style:{marginBottom:12},children:[t.jsxs("label",{style:E,children:["Comment ",le==="Deviate"&&je==="Pending Actor"?t.jsx("span",{style:{color:F.red},children:" * required for Deviate"}):"(optional)"]}),t.jsx("textarea",{style:{...A,height:60,resize:"vertical",borderColor:le==="Deviate"&&!N?"#fca5a5":void 0},value:N,onChange:B=>Z(B.target.value),placeholder:"Add a comment…"})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:ft.map(B=>{const Tt=B.action==="Update Status"&&le==="Deviate"&&!N.trim();return t.jsx("button",{onClick:()=>U(B.action),disabled:ce||Tt,title:Tt?"Comment required when status is Deviate":void 0,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:B.color,color:"white",fontWeight:600,fontSize:12,cursor:ce||Tt?"not-allowed":"pointer",opacity:ce||Tt?.5:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:t.jsx("span",{children:ce?T.wf.applying:B.label})},B.action)})}),X&&t.jsx("p",{style:{marginTop:8,fontSize:12,color:X==="Done"?F.green:F.red},children:X}),ft.length===0&&t.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:T.wf.noActions})]}),t.jsx(ii,{priority:e.priority,status:je,assignedTo:k!=="Employee"?Be:void 0,createdDate:e.starting_date,modifiedDate:e.modified}),t.jsx(ci,{doctype:O.orders,docname:e.name,currentUserName:W.name}),t.jsx(di,{doctype:O.orders,docname:e.name,docCreation:e.creation,docOwner:e.owner}),x&&v&&!e.custom_is_deleted&&t.jsx(ai,{title:"Delete Request",btnText:T.delete,onDelete:()=>v(e.name)})]}):null;return t.jsxs(Ze,{title:ct,activePage:"orders",user:W,formStatus:y,statusBadge:t.jsx("span",{style:I0(je),children:je}),buttonText:T.saveOrder,buttonColor:"#16a34a",viewMode:p,onEdit:w,darkMode:o,notifCount:d,onToggleDark:f,onCountChange:z,onViewProfile:b,rightPanel:ui,onSubmit:I,onBack:P,onNavigate:M,onLogout:ee,children:[e.custom_is_deleted===1&&t.jsx(Pr,{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&&t.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:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[t.jsx("span",{style:{fontSize:14,flexShrink:0},children:"💡"}),t.jsxs("span",{style:{fontSize:11,fontWeight:700,color:"#1e40af",textTransform:"uppercase",letterSpacing:"0.4px",whiteSpace:"nowrap"},children:[T.field.originatingIdea,":"]}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#1e3a8a",whiteSpace:"nowrap"},children:e.sb_idea})]}),m&&t.jsxs("button",{type:"button",onClick:()=>m(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:B=>B.currentTarget.style.background="#1d4ed8",onMouseLeave:B=>B.currentTarget.style.background="#2563eb",children:[T.field.viewIdea," →"]})]}),t.jsx(re,{title:"Order Information",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.number}),t.jsx("input",{style:{...A,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[T.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.organization,onChange:B=>D({organization:B}),organizations:s,disabled:p||!!W.custom_organization})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.title}),t.jsx("input",{style:{...A,...Q},value:e.title,disabled:p,onChange:B=>D({title:B.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.management}),t.jsx(pe,{value:e.management,onChange:B=>D({management:B}),items:K,placeholder:T.field.select,disabled:p})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.department}),t.jsx(pe,{value:e.department,onChange:B=>D({department:B}),items:oe,placeholder:T.field.select,disabled:p})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.section}),t.jsx("input",{style:{...A,...Q},value:e.section_field||"",disabled:p,onChange:B=>D({section_field:B.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.branch}),t.jsx(pe,{value:e.branch,onChange:B=>D({branch:B}),items:Oe,placeholder:T.field.select,disabled:p})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.type}),t.jsx(pe,{value:e.type,onChange:B=>D({type:B}),items:ve,placeholder:T.field.selectType,disabled:p})]})]})}),t.jsxs(re,{title:"Financial & Schedule",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.budget}),t.jsx("input",{type:"number",style:{...A,...Q},value:e.budget||"",disabled:p,onChange:B=>D({budget:parseFloat(B.target.value)||0})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.actualCost}),t.jsx("input",{type:"number",style:{...A,...Q},value:e.actual_cost||"",disabled:p,onChange:B=>D({actual_cost:parseFloat(B.target.value)||0})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Variance"}),(()=>{const B=(e.budget||0)-(e.actual_cost||0);return t.jsxs("div",{style:{padding:"7px 12px",borderRadius:6,fontWeight:700,fontSize:13,background:B>=0?"#f0fdf4":"#fef2f2",color:B>=0?"#166534":"#dc2626",border:`1px solid ${B>=0?"#bbf7d0":"#fecaca"}`,display:"inline-block",width:"100%",boxSizing:"border-box"},children:[B>=0?"+":"",B.toFixed(2)]})})()]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.currency}),t.jsxs("select",{style:{...A,...Q},value:e.currency||"",disabled:p,onChange:B=>D({currency:B.target.value}),children:[t.jsx("option",{value:"",children:T.field.select}),t.jsx("option",{value:"SAR",children:"SAR"}),t.jsx("option",{value:"USD",children:"USD"}),t.jsx("option",{value:"EUR",children:"EUR"}),t.jsx("option",{value:"AED",children:"AED"}),t.jsx("option",{value:"GBP",children:"GBP"})]})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.startingDate}),t.jsx(xe,{value:e.starting_date,onChange:B=>D({starting_date:B}),disabled:p,style:{...A,...Q}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.endingDate}),t.jsx(xe,{value:e.ending_date,onChange:B=>D({ending_date:B}),disabled:p,style:{...A,...Q}})]}),k!=="Employee"&&t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.actor}),p?t.jsx("input",{style:{...A,background:"#f8fafc",fontWeight:600,color:"#334155"},value:Be||"—",readOnly:!0,disabled:!0}):t.jsxs("select",{style:{...A,background:"#ffffff"},value:e.actor||e.assigned_to||"",onChange:B=>D({actor:B.target.value,assigned_to:B.target.value}),children:[t.jsx("option",{value:"",children:T.field.select}),Y.map(B=>t.jsx("option",{value:B.name,children:B.full_name||B.name},B.name))]})]})]})]}),t.jsxs(re,{title:"Classification",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.priority}),t.jsxs("select",{style:{...A,...Q},value:e.priority||"",disabled:p,onChange:B=>D({priority:B.target.value}),children:[t.jsx("option",{value:"",children:T.field.select}),t.jsx("option",{value:"High",children:T.field.high}),t.jsx("option",{value:"Normal",children:T.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.economyClass}),t.jsxs("select",{style:{...A,...Q},value:e.economy_class||"",disabled:p,onChange:B=>D({economy_class:B.target.value}),children:[t.jsx("option",{value:"",children:T.field.select}),t.jsx("option",{value:"Expenses",children:T.field.expenses}),t.jsx("option",{value:"Capital",children:T.field.capital}),t.jsx("option",{value:"Earn",children:T.field.earn}),t.jsx("option",{value:"Pay/Loss",children:T.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.entityScope}),t.jsxs("select",{style:{...A,...Q},value:e.entity_scope||"",disabled:p,onChange:B=>D({entity_scope:B.target.value}),children:[t.jsx("option",{value:"",children:T.field.select}),t.jsx("option",{value:"Upstream",children:T.field.upstream}),t.jsx("option",{value:"On-stream",children:T.field.onstream}),t.jsx("option",{value:"Downstream",children:T.field.downstream})]})]})]}),t.jsxs("div",{style:{display:"flex",gap:24,marginTop:12,alignItems:"center",flexWrap:"wrap"},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.planned,disabled:p,onChange:B=>D({planned:B.target.checked?1:0})})," Planned"]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:p,onChange:B=>D({product_relation:B.target.checked?1:0})})," ",T.field.productRelation]})]}),t.jsxs("div",{style:{marginTop:12},children:[t.jsx("label",{style:E,children:T.field.hsesField}),t.jsx("input",{style:{...A,...Q},value:e.hses_field||"",disabled:p,onChange:B=>D({hses_field:B.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),t.jsxs(re,{title:"Cycle & Progress Tracking",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.cycle}),t.jsx(pe,{value:e.cycle||"",onChange:B=>D({cycle:B}),items:nn,placeholder:T.field.select,disabled:p})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.cycleType}),t.jsxs("select",{style:{...A,...Q},value:e.cycle_type||"Normal",disabled:p,onChange:B=>D({cycle_type:B.target.value}),children:[t.jsx("option",{value:"Normal",children:"Normal"}),t.jsx("option",{value:"Long",children:"Long"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.stage}),t.jsx("input",{type:"number",min:1,max:5,style:{...A,background:"#f8fafc",color:"#334155",fontWeight:600},value:e.stage||1,readOnly:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Completion"}),t.jsx("input",{style:{...A,background:"#f8fafc",color:"#334155",fontWeight:600},value:`${e.completion_pct||(e.stage||1)*20}%`,readOnly:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Stage Description"}),t.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:C0[e.stage||1]||"—"})]})]}),e.cycle_type==="Long"&&t.jsxs("div",{style:{background:"#fff7ed",border:"1px solid #fed7aa",borderRadius:8,padding:14,marginBottom:14},children:[t.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#c2410c",marginBottom:10},children:"Long Cycle Milestone Dates"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Milestone 1"}),t.jsx(xe,{value:e.long_cycle_date_1||"",onChange:B=>D({long_cycle_date_1:B}),disabled:p,style:{...A,...Q}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Milestone 2"}),t.jsx(xe,{value:e.long_cycle_date_2||"",onChange:B=>D({long_cycle_date_2:B}),disabled:p,style:{...A,...Q}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Milestone 3"}),t.jsx(xe,{value:e.long_cycle_date_3||"",onChange:B=>D({long_cycle_date_3:B}),disabled:p,style:{...A,...Q}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Milestone 4"}),t.jsx(xe,{value:e.long_cycle_date_4||"",onChange:B=>D({long_cycle_date_4:B}),disabled:p,style:{...A,...Q}})]})]})]}),fe&&((Rr=e.order_cycle_log)==null?void 0:Rr.length)>0&&t.jsxs("div",{style:{borderTop:"1px solid #f1f5f9",paddingTop:14,marginTop:10},children:[t.jsx("p",{style:{fontWeight:700,color:"#334155",fontSize:13,marginBottom:10},children:"Cycle History"}),t.jsx("div",{style:{overflowX:"auto"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsx("tr",{style:{background:"#f8fafc"},children:["Cycle","Date","Stage","Status","Actor","Comment"].map(B=>t.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#475569",borderBottom:"1px solid #e2e8f0"},children:B},B))})}),t.jsx("tbody",{children:(e.order_cycle_log||[]).map((B,Tt)=>{const gn=B.status==="Agree"?"#166534":B.status==="Deviate"?"#c2410c":"#92400e",An=B.status==="Agree"?"#f0fdf4":B.status==="Deviate"?"#fff7ed":"#fefce8";return t.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:B.cycle||"—"}),t.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:B.cycle_date||"—"}),t.jsx("td",{style:{padding:"6px 10px",color:"#334155",textAlign:"center"},children:B.stage||"—"}),t.jsx("td",{style:{padding:"6px 10px"},children:t.jsx("span",{style:{background:An,color:gn,padding:"2px 8px",borderRadius:12,fontWeight:600,fontSize:12},children:B.status||"—"})}),t.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:B.actor||"—"}),t.jsx("td",{style:{padding:"6px 10px",color:"#64748b",fontStyle:B.comment?"normal":"italic"},children:B.comment||"—"})]},Tt)})})]})})]})]}),t.jsxs(re,{title:"Description & Notes",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.description}),t.jsx("textarea",{style:{...A,...Q,height:90,resize:"vertical"},value:e.description,disabled:p,onChange:B=>D({description:B.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.notes}),t.jsx("textarea",{style:{...A,...Q,height:90,resize:"vertical"},value:e.notes,disabled:p,onChange:B=>D({notes:B.target.value})})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:T.field.auditorComment}),t.jsx("textarea",{style:{...A,height:70,resize:"vertical",...p&&We&&!se?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:p&&We&&!se,onChange:B=>D({auditor_comment:B.target.value}),placeholder:T.field.commentPlaceholder})]})]})]})}function T0({processes:e,organizations:n,departments:s,branches:l,processStatuses:r,initialOrg:a,initialStatus:i,canModify:c,userRole:u,onView:g,onEdit:j,onDelete:y}){const p=ne(),[x,w]=C.useState(new Set),[v,S]=C.useState({search:"",organization:a||"",department:"",branch:"",status:i||""}),m=(h,k)=>S(I=>({...I,[h]:k})),[o,d]=C.useState(1),f=e.filter(h=>!(v.search&&!`${h.number} ${h.title}`.toLowerCase().includes(v.search.toLowerCase())||v.organization&&h.organization!==v.organization||v.department&&h.department!==v.department||v.branch&&h.branch!==v.branch||v.status&&h.status!==v.status));C.useEffect(()=>{d(1)},[v]);const z=f.slice((o-1)*ae,o*ae),b=h=>{const k=e.filter(M=>x.has(M.name)),I=Me.processes,P=I.columns.filter(M=>I.defaultColumns.includes(M.key));h==="csv"?He(P,k,"processes_selected"):Ge(P,k,"processes_selected")};return t.jsxs(t.Fragment,{children:[t.jsx(oi,{children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"10px 14px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.numberTitle}),t.jsx("input",{style:nt,value:v.search,onChange:h=>m("search",h.target.value),placeholder:p.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.organization}),t.jsxs("select",{style:nt,value:v.organization,onChange:h=>m("organization",h.target.value),children:[t.jsx("option",{value:"",children:p.filter.allOrgs}),n.map(h=>t.jsx("option",{value:h.name,children:h.organization_name},h.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.department}),t.jsxs("select",{style:nt,value:v.department,onChange:h=>m("department",h.target.value),children:[t.jsx("option",{value:"",children:p.filter.allDepts}),s.map(h=>t.jsx("option",{value:h.name,children:h.department_name},h.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.branch}),t.jsxs("select",{style:nt,value:v.branch,onChange:h=>m("branch",h.target.value),children:[t.jsx("option",{value:"",children:p.filter.allBranches}),l.map(h=>t.jsx("option",{value:h.name,children:h.branch},h.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:p.filter.status}),t.jsxs("select",{style:nt,value:v.status,onChange:h=>m("status",h.target.value),children:[t.jsx("option",{value:"",children:p.filter.allStatuses}),r.map(h=>t.jsx("option",{value:h.name,children:h.name1||h.name},h.name))]})]}),t.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:t.jsx("button",{type:"button",onClick:()=>{S({search:"",organization:a||"",department:"",branch:"",status:""}),d(1)},style:{height:38,padding:"0 16px",border:"1px solid #d1d5db",borderRadius:8,background:"#fff",color:"#374151",fontSize:13,fontWeight:500,cursor:"pointer",width:"100%"},children:p.clear})})]})}),t.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[t.jsx("th",{style:{width:44,padding:"12px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:z.length>0&&z.every(h=>x.has(h.name)),onChange:h=>{if(h.target.checked)w(new Set([...x,...z.map(k=>k.name)]));else{const k=new Set(x);z.forEach(I=>k.delete(I.name)),w(k)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.field.cycleType}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:p.col.actions})]})}),t.jsx("tbody",{children:f.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:p.noProcesses})}):z.map((h,k)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>g==null?void 0:g(h),style:{borderTop:"1px solid #f1f5f9",background:x.has(h.name)?"#eff6ff":h.custom_is_deleted?"#fff1f2":k%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:I=>I.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:x.has(h.name),onChange:()=>{const I=new Set(x);I.has(h.name)?I.delete(h.name):I.add(h.name),w(I)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:h.number||"—"}),t.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:h.title||h.name||"—"}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:h.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:h.cycle_type?Wc(h.cycle_type):"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:h.custom_is_deleted?es(p.deletedBadge):h.status?es(h.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:I=>I.stopPropagation(),children:t.jsx(at,{onView:()=>g==null?void 0:g(h),onEdit:c&&j&&!h.custom_is_deleted&&!Fn("process",h.workflow_state)&&u!=="Employee"?()=>j(h):void 0,onDelete:c&&y&&!h.custom_is_deleted?()=>y(h.name):void 0})})]},h.name))})]})}),t.jsx(Je,{count:x.size,onClear:()=>w(new Set),onExport:b}),t.jsx(qe,{page:o,total:f.length,onPageChange:d})]})}const P0={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"]}]},A0={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 Au(e){return{display:"inline-block",padding:"5px 14px",borderRadius:20,fontSize:13,fontWeight:700,...A0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}const na={width:"100%",padding:"6px 8px",border:"1px solid #d1d5db",borderRadius:5,fontSize:12,fontFamily:"Segoe UI",boxSizing:"border-box"};function R0({processName:e,userRole:n,onRefresh:s,canUpdateStatus:l=!0}){const[r,a]=C.useState(null),[i,c]=C.useState(!0),[u,g]=C.useState(""),[j,y]=C.useState(!1),[p,x]=C.useState(""),[w,v]=C.useState(""),[S,m]=C.useState("Pass"),[o,d]=C.useState(""),[f,z]=C.useState({}),b=C.useCallback(async()=>{if(!e){c(!1);return}c(!0),g("");try{const W=await Zl(e);a(W);const $={};for(const T of W.progress_indicators||[])$[T.name]=T.actual_value!=null?String(T.actual_value):"";z($)}catch(W){g(W instanceof Error?W.message:"Failed to load process")}c(!1)},[e]);if(C.useEffect(()=>{b()},[b]),i)return t.jsx("div",{style:{width:"100%",flexShrink:0},children:t.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(u||!r)return t.jsx("div",{style:{width:"100%",flexShrink:0},children:t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",padding:16},children:t.jsx("div",{style:{fontSize:12,color:"#991b1b",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,padding:"8px 12px"},children:u||"Could not load workflow"})})});const h=r.workflow_state||"Draft",k=P0[h]??[],I=n==="Employee"||n==="Manager",P=n!=="Manager"||l,M=k.filter(W=>(n==="Admin"||W.allowedRoles.includes(n))&&(W.action!=="Update Status"||P)),ee=async W=>{y(!0),x(""),v("");try{const $={};if(W==="Update Status"){$.actor_status=S,$.actor_comment=o;const D=r.progress_indicators||[];D.length>0&&($.progress_indicators=D.map(Q=>({name:Q.name,actual_value:f[Q.name]??""})))}W==="Add Comment"&&o&&($.actor_comment=o);const T=await Vy(r.name,W,$);a(T),d(""),v(`Done — now: ${T.workflow_state||"updated"}`),s==null||s()}catch($){x($ instanceof Error?$.message:"Action failed")}y(!1)};return t.jsx("div",{style:{width:"100%",flexShrink:0},children:t.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[t.jsx("div",{style:{background:"#1a2332",color:"white",padding:"10px 14px",fontSize:12,fontWeight:700,letterSpacing:.3},children:"Workflow"}),t.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:8},children:"Current State"}),t.jsx("div",{style:Au(h),children:h})]}),h==="Pending Actor"&&I&&P&&t.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Update Status"}),Array.isArray(r.progress_indicators)&&r.progress_indicators.length>0&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Actual Value"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:r.progress_indicators.map(W=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{fontSize:11,color:"#555",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:W.name1,children:W.name1||W.name}),t.jsx("input",{type:"number",value:f[W.name]??"",onChange:$=>z(T=>({...T,[W.name]:$.target.value})),style:{...na,width:70,flexShrink:0},placeholder:"0"})]},W.name))})]}),t.jsxs("div",{style:{marginBottom:8},children:[t.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Cycle Status"}),t.jsxs("select",{value:S,onChange:W=>m(W.target.value),style:na,children:[t.jsx("option",{value:"Pass",children:"✅ Pass — on target"}),t.jsx("option",{value:"Fail",children:"❌ Fail — off target"})]})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Comment (optional)"}),t.jsx("textarea",{value:o,onChange:W=>d(W.target.value),style:{...na,height:52,resize:"vertical"},placeholder:"Add a comment…"})]})]}),(h==="Pending Comment"||h==="Review")&&!I&&t.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Auditor Comment"}),Array.isArray(r.cycle_logs)&&r.cycle_logs.length>0&&t.jsxs("div",{style:{marginBottom:8,padding:"6px 10px",background:"#f8fafc",borderRadius:6,border:"1px solid #e2e8f0"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",marginBottom:3},children:"Latest cycle status:"}),(()=>{const W=r.cycle_logs,$=W[W.length-1],T=$.status==="Pass"?"#16a34a":$.status==="Fail"?"#dc2626":"#9ca3af";return t.jsxs("div",{style:{fontSize:13,fontWeight:700,color:T},children:[$.status," ",$.comment?`— ${$.comment}`:""]})})()]}),t.jsx("textarea",{value:o,onChange:W=>d(W.target.value),style:{...na,height:52,resize:"vertical"},placeholder:"Add a comment…"})]}),t.jsxs("div",{style:{padding:"12px 14px",borderBottom:M.length>0?"1px solid #f0f0f0":"none"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Actions"}),M.length===0&&t.jsxs("div",{style:{fontSize:12,color:"#aaa",fontStyle:"italic",lineHeight:1.5},children:["No actions for ",t.jsx("strong",{children:n})," in ",t.jsx("strong",{children:h}),"."]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:M.map(W=>t.jsxs("button",{onClick:()=>ee(W.action),disabled:j,style:{width:"100%",padding:"10px 14px",borderRadius:6,border:"none",background:W.action==="Close Process"?"#64748b":W.action==="Move to Study"?"#8e44ad":"#2563eb",color:"white",cursor:j?"not-allowed":"pointer",fontSize:13,fontWeight:600,opacity:j?.7:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{children:j?"Applying…":W.action}),t.jsxs("span",{style:{fontSize:10,opacity:.7},children:["→ ",W.next]})]},W.action))}),p&&t.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,fontSize:12,color:"#991b1b",lineHeight:1.4},children:p}),w&&t.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,fontSize:12,color:"#166534"},children:w})]}),k.length>0&&t.jsxs("div",{style:{padding:"12px 14px"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Next States"}),k.map(W=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6,fontSize:11},children:[t.jsx("span",{style:{color:"#555",flex:1},children:W.action}),t.jsx("span",{style:{color:"#bbb"},children:"→"}),t.jsx("span",{style:Au(W.next),children:W.next})]},W.action))]})]})})}function D0({processForm:e,setProcessForm:n,organizations:s,managements:l,departments:r,branches:a,processTypes:i,processStatuses:c,cycles:u=[],users:g=[],userRoleMap:j={},formStatus:y,viewMode:p,canModify:x,onEdit:w,onDelete:v,onRestore:S,darkMode:m,notifCount:o,onToggleDark:d,onCountChange:f,onViewProfile:z,userRole:b,onRefreshProcess:h,onSubmit:k,onBack:I,onNavigate:P,onLogout:M,user:ee}){var Ne;const W=ne(),$=L=>n({...e,...L}),T=p?{background:"#f9f9f9"}:{},D=s,Q=!!ee.custom_organization,Y=ye(l,e.management).map(L=>({name:L.name,label:L.name1||L.name})),X=ye(r,e.department).map(L=>({name:L.name,label:L.department_name||L.name})),q=ye(a,e.branch).map(L=>({name:L.name,label:L.branch||L.name})),N=ye(i,e.type).map(L=>({name:L.name,label:L.name1||L.name})),Z=ye(u,e.cycle).map(L=>({name:L.name,label:L.name1||L.name})),ce=Cl(g,j,"SB Employee",e.organization).map(L=>({name:L.name,label:L.full_name||L.name})),me=Cl(g,j,"SB Manager",e.organization).map(L=>({name:L.name,label:L.full_name||L.name})),le=(L,se)=>{const R=[...e.cycle_logs||[]];R[L]={...R[L],...se},$({cycle_logs:R})},Ve=()=>{$({cycle_logs:[...e.cycle_logs||[],{cycle:"",cycle_date:"",status:"Pass",actor:"",comment:""}]})},ct=L=>{const se=[...e.cycle_logs||[]];se.splice(L,1),$({cycle_logs:se})},K=(L,se)=>{const R=[...e.progress_indicators||[]];R[L]={...R[L],...se},$({progress_indicators:R})},oe=()=>{$({progress_indicators:[...e.progress_indicators||[],{name1:"",type:"",unit:"",cycle:"",target:"",maximum:"",minimum:"",manager:"",order:"",actual_value:"",cycle_status:"Pass",cycle_date:"",cycle_comment:"",status:"Active"}]})},Oe=L=>{const se=[...e.progress_indicators||[]];se.splice(L,1),$({progress_indicators:se})},ve=e.name?p?`${W.formTitle.viewProcess}${e.title||e.name}`:W.formTitle.editProcess:W.formTitle.newProcess,nn=b!=="Manager"||e.actor===ee.name,fe=((Ne=ce.find(L=>L.name===e.actor))==null?void 0:Ne.label)||e.actor,je=e.workflow_state||"Draft",Et=e.name?t.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[t.jsx(R0,{processName:e.name,userRole:b||ee.role||"Employee",onRefresh:h,canUpdateStatus:nn}),t.jsx(ii,{priority:e.impact_level,status:je,assignedTo:fe,createdDate:e.date_start,modifiedDate:e.modified}),t.jsx(ci,{doctype:O.processes,docname:e.name,currentUserName:ee.name}),t.jsx(di,{doctype:O.processes,docname:e.name,docCreation:e.creation,docOwner:e.owner}),x&&v&&!e.custom_is_deleted&&t.jsx(ai,{title:"Delete Request",btnText:W.delete,onDelete:()=>v(e.name)})]}):void 0;return t.jsxs(Ze,{title:ve,activePage:"processes",user:ee,formStatus:y,statusBadge:t.jsx("span",{style:{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},children:je}),buttonText:W.saveProcess,buttonColor:"#16a34a",viewMode:p,onEdit:w,darkMode:m,notifCount:o,onToggleDark:d,onCountChange:f,onViewProfile:z,rightPanel:Et,onSubmit:k,onBack:I,onNavigate:P,onLogout:M,children:[e.custom_is_deleted===1&&t.jsx(Pr,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:S?()=>S(e.name):void 0}),t.jsx(re,{title:"Process Information",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.number}),t.jsx("input",{style:{...A,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number||"",readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[W.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.organization,onChange:L=>$({organization:L}),organizations:D,disabled:p||Q})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.title}),t.jsx("input",{style:{...A,...T},value:e.title,disabled:p,onChange:L=>$({title:L.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.type}),t.jsx(pe,{value:e.type,onChange:L=>$({type:L}),items:N,placeholder:W.field.selectType,disabled:p})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.management}),t.jsx(pe,{value:e.management,onChange:L=>$({management:L}),items:Y,placeholder:W.field.select,disabled:p})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.department}),t.jsx(pe,{value:e.department,onChange:L=>$({department:L}),items:X,placeholder:W.field.select,disabled:p})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.section}),t.jsx("input",{style:{...A,...T},value:e.section_field||"",disabled:p,onChange:L=>$({section_field:L.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.branch}),t.jsx(pe,{value:e.branch,onChange:L=>$({branch:L}),items:q,placeholder:W.field.select,disabled:p})]})]})}),t.jsxs(re,{title:"Classification",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.chainLocation}),t.jsxs("select",{style:{...A,...T},value:e.chain_location||"",disabled:p,onChange:L=>$({chain_location:L.target.value}),children:[t.jsx("option",{value:"",children:W.field.select}),t.jsx("option",{value:"Upstream",children:"Upstream"}),t.jsx("option",{value:"On-stream",children:"On-stream"}),t.jsx("option",{value:"Downstream",children:"Downstream"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.economyClass}),t.jsxs("select",{style:{...A,...T},value:e.economy_class||"",disabled:p,onChange:L=>$({economy_class:L.target.value}),children:[t.jsx("option",{value:"",children:W.field.select}),t.jsx("option",{value:"Expenses",children:W.field.expenses}),t.jsx("option",{value:"Capital",children:W.field.capital}),t.jsx("option",{value:"Earn",children:W.field.earn}),t.jsx("option",{value:"Pay/Loss",children:W.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.impactLevel}),t.jsxs("select",{style:{...A,...T},value:e.impact_level||"",disabled:p,onChange:L=>$({impact_level:L.target.value}),children:[t.jsx("option",{value:"",children:W.field.select}),t.jsx("option",{value:"High",children:W.field.high}),t.jsx("option",{value:"Normal",children:W.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.entityScope}),t.jsxs("select",{style:{...A,...T},value:e.entity_scope||"",disabled:p,onChange:L=>$({entity_scope:L.target.value}),children:[t.jsx("option",{value:"",children:W.field.select}),t.jsx("option",{value:"Upstream",children:W.field.upstream}),t.jsx("option",{value:"On-stream",children:W.field.onstream}),t.jsx("option",{value:"Downstream",children:W.field.downstream})]})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"center"},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.hsesField}),t.jsx("input",{style:{...A,...T},value:e.hses_field||"",disabled:p,onChange:L=>$({hses_field:L.target.value}),placeholder:"Safety, Health, Environment…"})]}),t.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,paddingTop:18},children:t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:p,onChange:L=>$({product_relation:L.target.checked?1:0})})," ",W.field.productRelation]})})]})]}),t.jsxs(re,{title:"KPI & Timeline",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.kpiName}),t.jsx("input",{style:{...A,...T},value:e.kpi_name||"",disabled:p,onChange:L=>$({kpi_name:L.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.kpiType}),t.jsxs("select",{style:{...A,...T},value:e.kpi_type||"",disabled:p,onChange:L=>$({kpi_type:L.target.value}),children:[t.jsx("option",{value:"",children:W.field.select}),t.jsx("option",{value:"Human",children:"Human"}),t.jsx("option",{value:"Substantial",children:"Substantial"}),t.jsx("option",{value:"System",children:"System"}),t.jsx("option",{value:"Value",children:"Value"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.kpiMeasure}),t.jsx("input",{style:{...A,...T},value:e.kpi_measure||"",disabled:p,onChange:L=>$({kpi_measure:L.target.value}),placeholder:"Unit of measure"})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.dateStart}),t.jsx(xe,{value:e.date_start,onChange:L=>$({date_start:L}),disabled:p,style:{...A,...T}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.dateEnd}),t.jsx(xe,{value:e.date_end,onChange:L=>$({date_end:L}),disabled:p,style:{...A,...T}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.cycleType}),t.jsxs("select",{style:{...A,...T},value:e.cycle_type||"",disabled:p,onChange:L=>$({cycle_type:L.target.value}),children:[t.jsx("option",{value:"",children:W.field.select}),t.jsx("option",{value:"Normal",children:"Normal"}),t.jsx("option",{value:"Long",children:"Long"})]})]})]}),e.cycle_type==="Long"&&t.jsxs("div",{style:{background:"#fff7ed",border:"1px solid #fed7aa",borderRadius:8,padding:14,marginTop:14},children:[t.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#c2410c",marginBottom:10},children:"Long Cycle Milestone Dates"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Milestone 1"}),t.jsx(xe,{value:e.long_cycle_date_1||"",onChange:L=>$({long_cycle_date_1:L}),disabled:p,style:{...A,...T}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Milestone 2"}),t.jsx(xe,{value:e.long_cycle_date_2||"",onChange:L=>$({long_cycle_date_2:L}),disabled:p,style:{...A,...T}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Milestone 3"}),t.jsx(xe,{value:e.long_cycle_date_3||"",onChange:L=>$({long_cycle_date_3:L}),disabled:p,style:{...A,...T}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Milestone 4"}),t.jsx(xe,{value:e.long_cycle_date_4||"",onChange:L=>$({long_cycle_date_4:L}),disabled:p,style:{...A,...T}})]})]})]})]}),t.jsxs(re,{title:"Progress Indicators",children:[t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:12},children:!p&&t.jsx("button",{type:"button",onClick:oe,style:{padding:"7px 14px",border:"none",background:"#2563eb",color:"white",borderRadius:6,fontWeight:600,fontSize:12,cursor:"pointer"},children:"+ Add Row"})}),t.jsx("div",{style:{overflowX:"auto",minWidth:0},children:t.jsxs("table",{style:{borderCollapse:"collapse",fontSize:12,width:"max-content",minWidth:"100%"},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc"},children:[t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Order"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Name"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Type"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Unit"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Target"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Min"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Max"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Manager"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actual Value"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle Status"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle Date"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle Comment"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Status"}),!p&&t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actions"})]})}),t.jsxs("tbody",{children:[(e.progress_indicators||[]).length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:p?14:15,style:{padding:18,textAlign:"center",color:"#94a3b8"},children:"No progress indicators"})}),(e.progress_indicators||[]).map((L,se)=>t.jsxs("tr",{style:{background:se%2===0?"white":"#fafafa",borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...A,...T,width:60},value:L.order??"",disabled:p,onChange:R=>K(se,{order:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...A,...T},value:L.name1,disabled:p,onChange:R=>K(se,{name1:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...A,...T},value:L.type,disabled:p,onChange:R=>K(se,{type:R.target.value}),children:[t.jsx("option",{children:"Nominal"}),t.jsx("option",{children:"Ordinal"}),t.jsx("option",{children:"Interval"}),t.jsx("option",{children:"Ratio"})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...A,...T,width:70},type:"text",value:L.unit??"",disabled:p,onChange:R=>K(se,{unit:R.target.value}),placeholder:"e.g. °C, kg, %"})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...A,...T,minWidth:120},value:L.cycle,disabled:p,onChange:R=>K(se,{cycle:R.target.value}),children:[t.jsx("option",{value:"",children:"--"}),Z.map(R=>t.jsx("option",{value:R.name,children:R.label},R.name)),L.cycle&&!Z.some(R=>R.name===L.cycle)&&t.jsx("option",{value:L.cycle,children:L.cycle})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...A,...T,width:80},value:L.target,disabled:p,onChange:R=>K(se,{target:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...A,...T,width:80},value:L.minimum,disabled:p,onChange:R=>K(se,{minimum:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...A,...T,width:80},value:L.maximum,disabled:p,onChange:R=>K(se,{maximum:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...A,...T,minWidth:140},value:L.manager,disabled:p,onChange:R=>K(se,{manager:R.target.value}),children:[t.jsx("option",{value:"",children:"--"}),me.map(R=>t.jsx("option",{value:R.name,children:R.label},R.name)),L.manager&&!me.some(R=>R.name===L.manager)&&t.jsx("option",{value:L.manager,children:L.manager})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...A,...T,width:90},type:"number",value:L.actual_value??"",disabled:p,onChange:R=>K(se,{actual_value:parseFloat(R.target.value)||""})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...A,...T},value:L.cycle_status??"",disabled:p,onChange:R=>K(se,{cycle_status:R.target.value}),children:[t.jsx("option",{value:"",children:"--"}),t.jsx("option",{children:"Normal"}),t.jsx("option",{children:"Below Min"}),t.jsx("option",{children:"Above Max"}),t.jsx("option",{children:"At Risk"})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx(xe,{value:L.cycle_date||"",onChange:R=>K(se,{cycle_date:R}),disabled:p,style:{...A,...T,width:110}})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...A,...T},value:L.cycle_comment??"",disabled:p,onChange:R=>K(se,{cycle_comment:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...A,...T},value:L.status??"",disabled:p,onChange:R=>K(se,{status:R.target.value}),children:[t.jsx("option",{value:"",children:"--"}),t.jsx("option",{children:"Normal"}),t.jsx("option",{children:"Below Min"}),t.jsx("option",{children:"Above Max"}),t.jsx("option",{children:"At Risk"})]})}),!p&&t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("button",{type:"button",onClick:()=>Oe(se),style:{padding:"4px 8px",border:"1px solid #fecaca",background:"#fef2f2",color:"#dc2626",borderRadius:4,cursor:"pointer",fontSize:11,fontWeight:600},children:"Remove"})})]},se))]})]})})]}),t.jsx(re,{title:"Cycle & Assignment",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.cycle}),t.jsx(pe,{value:e.cycle||"",onChange:L=>$({cycle:L}),items:Z,placeholder:W.field.select,disabled:p})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.actor}),t.jsxs("select",{style:{...A,...T},value:e.actor||"",disabled:p,onChange:L=>$({actor:L.target.value}),children:[t.jsx("option",{value:"",children:W.field.select}),ce.map(L=>t.jsx("option",{value:L.name,children:L.label},L.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.costPerCycle}),t.jsx("input",{style:{...A,...T},type:"number",value:e.cost_per_cycle||"",disabled:p,onChange:L=>$({cost_per_cycle:parseFloat(L.target.value)||0}),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.escalationLevel}),t.jsx("input",{style:{...A,...T},type:"number",value:e.escalation_level||"",disabled:p,onChange:L=>$({escalation_level:parseInt(L.target.value)||0})})]})]})}),t.jsxs(re,{title:"Cycle History",children:[t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:12},children:!p&&t.jsx("button",{type:"button",onClick:Ve,style:{padding:"7px 14px",border:"none",background:"#2563eb",color:"white",borderRadius:6,fontWeight:600,fontSize:12,cursor:"pointer"},children:"+ Add Row"})}),t.jsx("div",{style:{overflowX:"auto",minWidth:0},children:t.jsxs("table",{style:{borderCollapse:"collapse",fontSize:12,width:"max-content",minWidth:"100%"},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc"},children:[t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Date"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Status"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actor"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Comment"}),!p&&t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actions"})]})}),t.jsxs("tbody",{children:[(e.cycle_logs||[]).length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:p?5:6,style:{padding:18,textAlign:"center",color:"#94a3b8"},children:"No cycle history"})}),(e.cycle_logs||[]).map((L,se)=>t.jsxs("tr",{style:{background:se%2===0?"white":"#fafafa",borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...A,...T},value:L.cycle||"",disabled:p,onChange:R=>le(se,{cycle:R.target.value}),children:[t.jsx("option",{value:"",children:"-- Select --"}),Z.map(R=>t.jsx("option",{value:R.name,children:R.label},R.name))]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx(xe,{value:L.cycle_date||"",onChange:R=>le(se,{cycle_date:R}),disabled:p,style:{...A,...T,width:130}})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...A,...T},value:L.status,disabled:p,onChange:R=>le(se,{status:R.target.value}),children:[t.jsx("option",{value:"Pass",children:"Pass"}),t.jsx("option",{value:"Fail",children:"Fail"}),t.jsx("option",{value:"Unknown",children:"Unknown"})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...A,...T},value:L.actor||"",disabled:p,onChange:R=>le(se,{actor:R.target.value}),children:[t.jsx("option",{value:"",children:"-- Select --"}),ce.map(R=>t.jsx("option",{value:R.name,children:R.label},R.name))]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...A,...T},value:L.comment||"",disabled:p,onChange:R=>le(se,{comment:R.target.value})})}),!p&&t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("button",{type:"button",onClick:()=>ct(se),style:{padding:"4px 8px",border:"1px solid #fecaca",background:"#fef2f2",color:"#dc2626",borderRadius:4,cursor:"pointer",fontSize:11,fontWeight:600},children:"Remove"})})]},se))]})]})})]}),t.jsx(re,{title:W.field.auditorComment,children:t.jsx("textarea",{style:{...A,height:70,resize:"vertical",background:"#f8fafc"},value:e.auditor_comment||"",disabled:!0,readOnly:!0,placeholder:W.field.commentPlaceholder})})]})}const L0={Admin:"#7c3aed",Auditor:"#d97706",Owner:"#0369a1",XAuditor:"#0f766e",Manager:"#2563eb",Employee:"#6b7280",Chairman:"#0f766e"};function O0({user:e,profileUser:n,darkMode:s,canModify:l,onBack:r,organizations:a=[],managements:i=[],departments:c=[],branches:u=[]}){const g=n||{},j=!!l&&e.role==="Admin",[y,p]=C.useState({first_name:g.first_name||"",middle_name:g.middle_name||"",last_name:g.last_name||"",mobile_no:g.mobile_no||"",custom_organization:g.custom_organization||"",custom_management:g.custom_management||"",custom_department:g.custom_department||"",custom_branch:g.custom_branch||"",custom_number:g.custom_number||"",custom_category:g.custom_category||""}),[x,w]=C.useState(""),[v,S]=C.useState(!1),[m,o]=C.useState({new:"",confirm:""}),[d,f]=C.useState(""),z=g.email||g.name||"",b=[y.first_name,y.middle_name,y.last_name].filter(Boolean).join(" ")||g.full_name||"",h=g.username||g.name||"",k=y.custom_category||"",I=g.enabled===0?"Inactive":"Active",P=L0[e.role]||"#6b7280",M=s,ee=M?"#0f172a":"#f0f2f5",W=M?"#1e293b":"white",$=M?"#2d3748":"#e5e7eb",T=M?"#e2e8f0":"#1a2332",D=M?"#94a3b8":"#6b7280",Q=M?"#374151":"white",Y=M?"#2d3748":"#f9fafb",X={width:"100%",padding:"9px 12px",borderRadius:8,border:`1px solid ${$}`,fontSize:13,background:Q,color:T,fontFamily:"inherit",outline:"none"},q={...X,background:Y,color:D},N={...X,cursor:"pointer"},Z={fontSize:12,fontWeight:600,color:D,marginBottom:5,display:"block"},ce={display:"grid",gridTemplateColumns:"1fr 1fr",gap:14},me={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:14},le=async()=>{if(l){w("saving");try{await Ma("User",g.name,{first_name:y.first_name,middle_name:y.middle_name,last_name:y.last_name,mobile_no:y.mobile_no,custom_organization:y.custom_organization,custom_management:y.custom_management,custom_department:y.custom_department,custom_branch:y.custom_branch,custom_number:y.custom_number,custom_category:y.custom_category}),w("saved"),setTimeout(()=>w(""),2e3)}catch{w("error"),setTimeout(()=>w(""),3e3)}}},Ve=async()=>{if(!m.new){f("Enter a new password");return}if(m.new!==m.confirm){f("Passwords do not match");return}f("saving");try{await ih(g.name,m.new),f("done"),o({new:"",confirm:""}),setTimeout(()=>{f(""),S(!1)},2e3)}catch{f("error")}},ct=({title:K,icon:oe,children:Oe})=>t.jsxs("div",{style:{background:W,borderRadius:12,padding:22,border:`1px solid ${$}`,boxShadow:`0 1px 4px rgba(0,0,0,${M?.3:.06})`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,paddingBottom:14,borderBottom:`1px solid ${$}`},children:[oe,t.jsx("span",{style:{fontSize:14,fontWeight:700,color:T},children:K})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:Oe})]});return t.jsxs("div",{style:{background:ee,minHeight:"100%",padding:"0 0 32px"},children:[t.jsxs("div",{style:{background:W,borderBottom:`1px solid ${$}`,padding:"12px 28px",display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:24},children:[t.jsxs("button",{onClick:r,style:{display:"flex",alignItems:"center",gap:7,background:"none",border:"none",cursor:"pointer",fontSize:15,fontWeight:700,color:T,fontFamily:"inherit"},children:[t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:t.jsx("polyline",{points:"15,18 9,12 15,6"})}),"User Profile"]}),l&&t.jsxs("button",{onClick:le,style:{display:"flex",alignItems:"center",gap:8,background:x==="saved"?"#16a34a":x==="error"?"#dc2626":"#16a34a",color:"white",border:"none",borderRadius:8,padding:"9px 22px",fontSize:13,fontWeight:700,cursor:"pointer",fontFamily:"inherit"},children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),t.jsx("polyline",{points:"17,21 17,13 7,13 7,21"}),t.jsx("polyline",{points:"7,3 7,8 15,8"})]}),x==="saving"?"Saving…":x==="saved"?"Saved!":x==="error"?"Error":"Save Changes"]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"280px 1fr",gap:22,padding:"0 28px"},children:[t.jsxs("div",{style:{borderRadius:14,overflow:"hidden",boxShadow:"0 4px 20px rgba(0,0,0,0.12)",alignSelf:"start"},children:[t.jsxs("div",{style:{background:"linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%)",padding:"32px 20px 28px",display:"flex",flexDirection:"column",alignItems:"center",gap:6},children:[t.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:t.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"rgba(255,255,255,0.9)",children:[t.jsx("circle",{cx:"12",cy:"8",r:"4"}),t.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7"})]})}),t.jsx("div",{style:{fontSize:17,fontWeight:700,color:"white",textAlign:"center",lineHeight:1.3},children:b||z}),t.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.75)",textAlign:"center"},children:z})]}),t.jsx("div",{style:{background:W},children:[{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:P,strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),t.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),t.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),t.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),label:"Username",value:h},{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:P,strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),label:"Role Profile",value:k||"—"},{icon:t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:I==="Active"?"#16a34a":"#dc2626",strokeWidth:"2",strokeLinecap:"round",children:t.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),label:"Status",value:I,valueColor:I==="Active"?"#16a34a":"#dc2626"},{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:P,strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),t.jsx("path",{d:"m2 7 10 7 10-7"})]}),label:"Email",value:z},{icon:t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:P,strokeWidth:"2",strokeLinecap:"round",children:t.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:y.mobile_no||"—"}].map(({icon:K,label:oe,value:Oe,valueColor:ve})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 16px",borderBottom:`1px solid ${$}`},children:[t.jsx("div",{style:{flexShrink:0,width:18,display:"flex",justifyContent:"center"},children:K}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:11,color:D,marginBottom:1},children:oe}),t.jsx("div",{style:{fontSize:13,fontWeight:600,color:ve||T,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Oe})]})]},oe))})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:18},children:[t.jsxs(ct,{title:"Basic Information",icon:t.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("circle",{cx:"12",cy:"8",r:"4"}),t.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7"})]}),children:[t.jsxs("div",{style:ce,children:[t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Email ",t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Read-only)"})]}),t.jsxs("div",{style:{position:"relative"},children:[t.jsx("div",{style:{position:"absolute",left:11,top:"50%",transform:"translateY(-50%)"},children:t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#94a3b8",strokeWidth:"2",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),t.jsx("path",{d:"m2 7 10 7 10-7"})]})}),t.jsx("input",{style:{...q,paddingLeft:32},value:z,readOnly:!0})]})]}),t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Full Name ",t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Auto-generated)"})]}),t.jsx("input",{style:q,value:b,readOnly:!0})]})]}),t.jsxs("div",{style:me,children:[t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["First Name ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{style:l?X:q,value:y.first_name,readOnly:!l,onChange:K=>p(oe=>({...oe,first_name:K.target.value})),placeholder:"First name"})]}),t.jsxs("div",{children:[t.jsx("label",{style:Z,children:"Middle Name"}),t.jsx("input",{style:l?X:q,value:y.middle_name,readOnly:!l,onChange:K=>p(oe=>({...oe,middle_name:K.target.value})),placeholder:"Middle name"})]}),t.jsxs("div",{children:[t.jsx("label",{style:Z,children:"Last Name"}),t.jsx("input",{style:l?X:q,value:y.last_name,readOnly:!l,onChange:K=>p(oe=>({...oe,last_name:K.target.value})),placeholder:"Last name"})]})]}),t.jsxs("div",{style:ce,children:[t.jsxs("div",{children:[t.jsx("label",{style:Z,children:"Phone Number"}),t.jsx("input",{style:l?X:q,value:y.mobile_no,readOnly:!l,onChange:K=>p(oe=>({...oe,mobile_no:K.target.value})),placeholder:"Phone number"})]}),t.jsxs("div",{children:[t.jsx("label",{style:Z,children:"User ID No"}),t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{style:{...q,paddingRight:44},value:y.custom_number||g.name||"",readOnly:!0}),t.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:t.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"white",children:[t.jsx("circle",{cx:"5",cy:"12",r:"2"}),t.jsx("circle",{cx:"12",cy:"12",r:"2"}),t.jsx("circle",{cx:"19",cy:"12",r:"2"})]})})]})]})]}),t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Category ",!j&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),j?t.jsxs("select",{style:N,value:y.custom_category,onChange:K=>p(oe=>({...oe,custom_category:K.target.value})),children:[t.jsx("option",{value:"",children:"Select category"}),["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"].map(K=>t.jsx("option",{value:K,children:K},K))]}):t.jsx("input",{style:q,value:k||"—",readOnly:!0})]})]}),t.jsxs(ct,{title:"Organization Information",icon:t.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#8b5cf6",strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("rect",{x:"2",y:"7",width:"20",height:"14",rx:"2"}),t.jsx("path",{d:"M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"})]}),children:[t.jsxs("div",{style:ce,children:[t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Organization ",!j&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),j?t.jsxs("select",{style:N,value:y.custom_organization,onChange:K=>p(oe=>({...oe,custom_organization:K.target.value})),children:[t.jsx("option",{value:"",children:"Select organization"}),ye(a,y.custom_organization).map(K=>t.jsx("option",{value:K.name,children:K.organization_name||K.name},K.name))]}):t.jsx("input",{style:q,value:y.custom_organization||"—",readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Management ",!j&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),j?t.jsxs("select",{style:N,value:y.custom_management,onChange:K=>p(oe=>({...oe,custom_management:K.target.value})),children:[t.jsx("option",{value:"",children:"Select management"}),ye(i,y.custom_management).map(K=>t.jsx("option",{value:K.name,children:K.name1||K.name},K.name))]}):t.jsx("input",{style:q,value:y.custom_management||"—",readOnly:!0})]})]}),t.jsxs("div",{style:ce,children:[t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Department ",!j&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),j?t.jsxs("select",{style:N,value:y.custom_department,onChange:K=>p(oe=>({...oe,custom_department:K.target.value})),children:[t.jsx("option",{value:"",children:"Select department"}),ye(c,y.custom_department).map(K=>t.jsx("option",{value:K.name,children:K.department_name||K.name},K.name))]}):t.jsx("input",{style:q,value:y.custom_department||"—",readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Branch ",!j&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),j?t.jsxs("select",{style:N,value:y.custom_branch,onChange:K=>p(oe=>({...oe,custom_branch:K.target.value})),children:[t.jsx("option",{value:"",children:"Select branch"}),ye(u,y.custom_branch).map(K=>t.jsx("option",{value:K.name,children:K.branch||K.name},K.name))]}):t.jsx("input",{style:q,value:y.custom_branch||"—",readOnly:!0})]})]})]}),t.jsxs("div",{style:{background:W,borderRadius:12,padding:22,border:`1px solid ${$}`,boxShadow:`0 1px 4px rgba(0,0,0,${M?.3:.06})`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#f59e0b",strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),t.jsx("span",{style:{fontSize:14,fontWeight:700,color:T},children:"Change Password"})]}),l&&t.jsx("button",{onClick:()=>{S(K=>!K),f("")},style:{fontSize:13,color:"#3b82f6",background:"none",border:"none",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:v?"Cancel":"Change Password"})]}),v&&t.jsxs("div",{style:{marginTop:18,display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:me,children:[t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["New Password ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{type:"password",style:X,value:m.new,onChange:K=>o(oe=>({...oe,new:K.target.value})),placeholder:"New password"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Confirm Password ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{type:"password",style:X,value:m.confirm,onChange:K=>o(oe=>({...oe,confirm:K.target.value})),placeholder:"Confirm password"})]}),t.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:t.jsx("button",{onClick:Ve,style:{width:"100%",padding:"9px 0",borderRadius:8,border:"none",background:"#2563eb",color:"white",fontWeight:700,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:d==="saving"?"Saving…":"Update Password"})})]}),d&&d!=="saving"&&t.jsx("div",{style:{fontSize:13,color:d==="done"?"#16a34a":"#dc2626",fontWeight:500},children:d==="done"?"Password updated successfully":d==="error"?"Failed to update password":d})]})]})]})]})]})}function Ie({label:e,val:n,color:s}){return t.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:[t.jsx("div",{style:{fontSize:18,fontWeight:700,color:s},children:n}),t.jsx("div",{style:{fontSize:12,color:"#999"},children:e})]})}const dh={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151",boxSizing:"border-box"},N0={...dh,cursor:"pointer"};function vt({filters:e,defaultOpen:n=!1}){const[s,l]=C.useState(n);return t.jsxs("div",{style:{background:"white",borderRadius:12,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:16},children:[t.jsxs("div",{onClick:()=>l(r=>!r),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",padding:"12px 18px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",userSelect:"none"},children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:s?t.jsx("polyline",{points:"18,15 12,9 6,15"}):t.jsx("polyline",{points:"6,9 12,15 18,9"})}),t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:t.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),t.jsx("span",{style:{color:"white",fontWeight:700,fontSize:14},children:"Filters"})]}),s&&t.jsx("div",{style:{padding:"18px 20px"},children:t.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${Math.min(e.length,4)}, 1fr)`,gap:14},children:e.map((r,a)=>t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:r.label}),r.type==="search"?t.jsx("input",{style:dh,placeholder:r.placeholder,value:r.value,onChange:i=>r.onChange(i.target.value)}):t.jsx("select",{style:N0,value:r.value,onChange:i=>r.onChange(i.target.value),children:r.options.map(i=>t.jsx("option",{value:i.value,children:i.label},i.value))})]},a))})})]})}function W0(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function B0({organizations:e,canModify:n,onView:s,onEdit:l,onDelete:r}){const a=ne(),[i,c]=C.useState(new Set),[u,g]=C.useState(""),[j,y]=C.useState("all"),[p,x]=C.useState("all"),w={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},v=C.useMemo(()=>e.filter(f=>{const z=[f.organization_name,f.city].filter(Boolean).join(" ").toLowerCase();return!(u&&!z.includes(u.toLowerCase())||j!=="all"&&f.type!==j||p!=="all"&&(f.is_active?"Active":"Inactive")!==p)}),[e,u,j,p]),[S,m]=C.useState(1);C.useEffect(()=>{m(1)},[u,j,p]);const o=v.slice((S-1)*ae,S*ae),d=f=>{const z=e.filter(k=>i.has(k.name)),b=Me.organizations,h=b.columns.filter(k=>b.defaultColumns.includes(k.key));f==="csv"?He(h,z,"organizations_selected"):Ge(h,z,"organizations_selected")};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Ie,{label:"Total",val:v.length,color:"#1a2332"}),t.jsx(Ie,{label:"Active",val:v.filter(f=>f.is_active).length,color:F.green}),t.jsx(Ie,{label:"Government",val:v.filter(f=>f.type==="Government").length,color:F.blue}),t.jsx(Ie,{label:"Private",val:v.filter(f=>f.type==="Private").length,color:F.orange})]}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:u,onChange:g,placeholder:"Name or city…"},{type:"select",label:a.col.type,value:j,onChange:y,options:[{value:"all",label:"All"},{value:"Government",label:"Government"},{value:"Private",label:"Private"}]},{type:"select",label:"Status",value:p,onChange:x,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:o.length>0&&o.every(f=>i.has(f.name)),onChange:f=>{if(f.target.checked)c(new Set([...i,...o.map(z=>z.name)]));else{const z=new Set(i);o.forEach(b=>z.delete(b.name)),c(z)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:w,children:a.col.name}),t.jsx("th",{style:w,children:a.col.type}),t.jsx("th",{style:w,children:a.col.city}),t.jsx("th",{style:w,children:a.field.creationDate}),t.jsx("th",{style:w,children:a.col.status}),t.jsx("th",{style:w,children:a.col.actions})]})}),t.jsx("tbody",{children:v.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):o.map((f,z)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(f),style:{borderTop:"1px solid #f0f0f0",background:i.has(f.name)?"#eff6ff":z%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:b=>b.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:i.has(f.name),onChange:()=>{const b=new Set(i);b.has(f.name)?b.delete(f.name):b.add(f.name),c(b)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:f.organization_name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:f.type||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:f.city||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:W0(f.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:_r(f.is_active?a.field.statusActive:a.field.statusInactive,f.is_active?F.green:F.gray)}),t.jsx("td",{style:{padding:"8px 14px"},onClick:b=>b.stopPropagation(),children:t.jsx(at,{onView:()=>s==null?void 0:s(f),onEdit:n&&l?()=>l(f):void 0,onDelete:n&&r?()=>r(f.name):void 0})})]},f.name))})]})}),t.jsx(Je,{count:i.size,onClear:()=>c(new Set),onExport:d}),t.jsx(qe,{page:S,total:v.length,onPageChange:m})]})}const jn=e=>({background:e?"#f9f9f9":void 0});function $0({orgForm:e,setOrgForm:n,groupCompanies:s=[],formStatus:l,viewMode:r,onEdit:a,darkMode:i,notifCount:c,onToggleDark:u,onCountChange:g,onViewProfile:j,onSubmit:y,onBack:p,onNavigate:x,onLogout:w,user:v}){const S=ne(),m=e.name?r&&e.organization_name||S.formTitle.editOrg:S.formTitle.newOrg,o=s.map(d=>({name:d.name,label:d.company_name?`${d.company_name} (${d.name})`:d.name}));return t.jsxs(Ze,{title:m,activePage:"organizations",user:v,formStatus:l,buttonText:S.saveOrg,buttonColor:"#16a34a",viewMode:r,onEdit:a,darkMode:i,notifCount:c,onToggleDark:u,onCountChange:g,onViewProfile:j,onSubmit:y,onBack:p,onNavigate:x,onLogout:w,children:[t.jsx(re,{title:"Organization Information",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[S.field.orgName," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{type:"text",style:{...A,...jn(r||!!e.name)},value:e.organization_name,disabled:r||!!e.name,required:!0,onChange:d=>n({...e,organization_name:d.target.value})})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[S.field.orgAcronym," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{type:"text",style:{...A,...jn(r||!!e.name)},value:e.acronym||"",disabled:r||!!e.name,required:!0,onChange:d=>n({...e,acronym:d.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Group Company (Tenant)"}),t.jsx(pe,{value:e.group_company||"",onChange:d=>n({...e,group_company:d}),items:o,placeholder:"Select Group Company",disabled:r||!!v.custom_group_company})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.organizationType}),t.jsxs("select",{style:{...A,...jn(r)},value:e.type,disabled:r,onChange:d=>n({...e,type:d.target.value}),children:[t.jsx("option",{children:"Government"}),t.jsx("option",{children:"Private"}),t.jsx("option",{children:"Non-Profit"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.orgCity}),t.jsx("input",{type:"text",style:{...A,...jn(r)},value:e.city,disabled:r,onChange:d=>n({...e,city:d.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.contactEmail}),t.jsx("input",{type:"email",style:{...A,...jn(r)},value:e.contact_email,disabled:r,onChange:d=>n({...e,contact_email:d.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:d=>n({...e,creation_date:d}),disabled:r,style:{...A,...jn(r)}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.status}),t.jsxs("select",{style:{...A,...jn(r)},value:e.is_active?"Active":"Inactive",disabled:r,onChange:d=>n({...e,is_active:d.target.value==="Active"?1:0}),children:[t.jsx("option",{value:"Active",children:S.field.statusActive}),t.jsx("option",{value:"Inactive",children:S.field.statusInactive})]})]})]})}),t.jsx(re,{title:"Incident SLA Windows",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.incidentTriageWindowDays}),t.jsx("input",{type:"number",min:1,max:30,style:{...A,...jn(r)},value:e.incident_triage_window_days??3,disabled:r,onChange:d=>n({...e,incident_triage_window_days:parseInt(d.target.value)||3})}),t.jsx("span",{style:{fontSize:11,color:"#64748b",display:"block",marginTop:4},children:"Days after creation before an untriaged Incident is flagged overdue"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.incidentResolutionWindowDays}),t.jsx("input",{type:"number",min:1,max:30,style:{...A,...jn(r)},value:e.incident_resolution_window_days??5,disabled:r,onChange:d=>n({...e,incident_resolution_window_days:parseInt(d.target.value)||5})}),t.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 U0({groupCompanies:e,canModify:n,onView:s,onEdit:l,onDelete:r}){const a=ne(),[i,c]=C.useState(new Set),[u,g]=C.useState(""),[j,y]=C.useState("all"),p={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},x=C.useMemo(()=>e.filter(o=>{const d=[o.company_name,o.acronym,o.code,o.owner_user].filter(Boolean).join(" ").toLowerCase();return!(u&&!d.includes(u.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,u,j]),[w,v]=C.useState(1);C.useEffect(()=>{v(1)},[u,j]);const S=x.slice((w-1)*ae,w*ae),m=o=>{const d=e.filter(b=>i.has(b.name)),f=Me["group-companies"],z=f.columns.filter(b=>f.defaultColumns.includes(b.key));o==="csv"?He(z,d,"group_companies_selected"):Ge(z,d,"group_companies_selected")};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Ie,{label:"Total Group Cos",val:x.length,color:"#1a2332"}),t.jsx(Ie,{label:"Active",val:x.filter(o=>(o.status||"Active")==="Active").length,color:F.green}),t.jsx(Ie,{label:"Inactive",val:x.filter(o=>o.status==="Inactive").length,color:F.orange})]}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:u,onChange:g,placeholder:"Company name, code, owner…"},{type:"select",label:"Status",value:j,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:"Active"},{value:"Inactive",label:"Inactive"}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{borderBottom:"1px solid #f0f0f0",background:"#fafafa"},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:S.length>0&&S.every(o=>i.has(o.name)),onChange:o=>{if(o.target.checked)c(new Set([...i,...S.map(d=>d.name)]));else{const d=new Set(i);S.forEach(f=>d.delete(f.name)),c(d)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:p,children:"Company Name"}),t.jsx("th",{style:p,children:"Code / Acronym"}),t.jsx("th",{style:p,children:"Group Co Owner"}),t.jsx("th",{style:p,children:"Status"}),t.jsx("th",{style:p,children:a.col.actions})]})}),t.jsxs("tbody",{children:[S.map((o,d)=>{const f=o.custom_is_deleted===1;return t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderBottom:"1px solid #f0f0f0",background:i.has(o.name)?"#eff6ff":f?"#fef2f2":d%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:z=>z.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:i.has(o.name),onChange:()=>{const z=new Set(i);z.has(o.name)?z.delete(o.name):z.add(o.name),c(z)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsxs("td",{style:{padding:"12px 14px",fontWeight:600},children:[o.company_name,f&&t.jsx("span",{style:{marginLeft:8},children:_r(a.deletedBadge,"#ef4444")})]}),t.jsx("td",{style:{padding:"12px 14px",color:"#555"},children:[o.code,o.acronym].filter(Boolean).join(" / ")||"—"}),t.jsx("td",{style:{padding:"12px 14px",color:"#555"},children:o.owner_user||"—"}),t.jsx("td",{style:{padding:"12px 14px"},children:_r(o.status||"Active",(o.status||"Active")==="Active"?F.green:F.orange)}),t.jsx("td",{style:{padding:"12px 14px"},onClick:z=>z.stopPropagation(),children:t.jsx(at,{onView:s?()=>s(o):void 0,onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name)}),x.length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:24,textAlign:"center",color:"#aaa"},children:"No Group Companies found"})})]})]})}),t.jsx(Je,{count:i.size,onClear:()=>c(new Set),onExport:m}),t.jsx(qe,{page:w,total:x.length,onPageChange:v})]})}function F0({form:e,setForm:n,users:s=[],formStatus:l,viewMode:r,onEdit:a,onRestore:i,darkMode:c,notifCount:u,onToggleDark:g,onCountChange:j,onViewProfile:y,onSubmit:p,onBack:x,onNavigate:w,onLogout:v,user:S}){const m=z=>n({...e,...z}),o=r?{background:"#f8fafc"}:{},d=e.name?r?`View Group Company: ${e.company_name}`:"Edit Group Company":"New Group Company",f=s.map(z=>({name:z.name,label:z.full_name?`${z.full_name} (${z.name})`:z.name}));return t.jsxs(Ze,{title:d,activePage:"group-companies",user:S,formStatus:l,buttonText:"Save Group Company",buttonColor:"#16a34a",viewMode:r,onEdit:a,darkMode:c,notifCount:u,onToggleDark:g,onCountChange:j,onViewProfile:y,onSubmit:p,onBack:x,onNavigate:w,onLogout:v,children:[e.custom_is_deleted===1&&t.jsx(Pr,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:i?()=>i(e.name):void 0}),t.jsxs(re,{title:"Group Company Details",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:["Company Name ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...o},value:e.company_name||"",disabled:r||!!e.name,onChange:z=>m({company_name:z.target.value}),placeholder:"e.g. Company A Group"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Company Code"}),t.jsx("input",{style:{...A,...o},value:e.code||"",disabled:r,onChange:z=>m({code:z.target.value}),placeholder:"e.g. CO-A"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Acronym"}),t.jsx("input",{style:{...A,...o},value:e.acronym||"",disabled:r,onChange:z=>m({acronym:z.target.value}),placeholder:"e.g. CAG"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Status"}),t.jsxs("select",{style:{...A,...o},value:e.status||"Active",disabled:r,onChange:z=>m({status:z.target.value}),children:[t.jsx("option",{value:"Active",children:"Active"}),t.jsx("option",{value:"Inactive",children:"Inactive"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Group Co Owner / Admin User"}),t.jsx(pe,{value:e.owner_user||"",onChange:z=>m({owner_user:z}),items:f,placeholder:"Select owner user",disabled:r})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Notes"}),t.jsx("textarea",{style:{...A,...o,height:75,resize:"vertical"},value:e.notes||"",disabled:r,onChange:z=>m({notes:z.target.value}),placeholder:"Additional details regarding this tenant company…"})]})]})]})}function M0(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function H0({managements:e,canModify:n,onView:s,onEdit:l,onDelete:r}){const a=ne(),[i,c]=C.useState(new Set),[u,g]=C.useState(""),[j,y]=C.useState("all"),p={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},x=C.useMemo(()=>e.filter(o=>{const d=(o.name1||o.name||"").toLowerCase();return!(u&&!d.includes(u.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,u,j]),[w,v]=C.useState(1);C.useEffect(()=>{v(1)},[u,j]);const S=x.slice((w-1)*ae,w*ae),m=o=>{const d=e.filter(b=>i.has(b.name)),f=Me.managements,z=f.columns.filter(b=>f.defaultColumns.includes(b.key));o==="csv"?He(z,d,"managements_selected"):Ge(z,d,"managements_selected")};return t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:x.length,color:F.blue})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:u,onChange:g,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:S.length>0&&S.every(o=>i.has(o.name)),onChange:o=>{if(o.target.checked)c(new Set([...i,...S.map(d=>d.name)]));else{const d=new Set(i);S.forEach(f=>d.delete(f.name)),c(d)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:p,children:a.col.name}),t.jsx("th",{style:p,children:a.field.creationDate}),t.jsx("th",{style:p,children:a.field.status}),t.jsx("th",{style:p,children:a.col.actions})]})}),t.jsx("tbody",{children:x.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):S.map((o,d)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:i.has(o.name)?"#eff6ff":d%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:f=>f.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:i.has(o.name),onChange:()=>{const f=new Set(i);f.has(o.name)?f.delete(o.name):f.add(o.name),c(f)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:M0(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:f=>f.stopPropagation(),children:t.jsx(at,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Je,{count:i.size,onClear:()=>c(new Set),onExport:m}),t.jsx(qe,{page:w,total:x.length,onPageChange:v})]})}function G0({form:e,setForm:n,organizations:s,formStatus:l,viewMode:r,onEdit:a,darkMode:i,notifCount:c,onToggleDark:u,onCountChange:g,onViewProfile:j,onSubmit:y,onBack:p,onNavigate:x,onLogout:w,user:v}){const S=ne(),m=f=>n(z=>({...z,...f})),o=r?{background:"#f8fafc"}:{},d=e.name?r?`${S.formTitle.editMgmt}: ${e.name1||e.name}`:S.formTitle.editMgmt:S.formTitle.newMgmt;return t.jsx(Ze,{title:d,activePage:"managements",user:v,formStatus:l,buttonText:S.saveMgmt,buttonColor:"#16a34a",viewMode:r,onEdit:a,darkMode:i,notifCount:c,onToggleDark:u,onCountChange:g,onViewProfile:j,onSubmit:y,onBack:p,onNavigate:x,onLogout:w,children:t.jsx(re,{title:"Management Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[S.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.organization,onChange:f=>m({organization:f}),organizations:s,disabled:r||!!v.custom_organization})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[S.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...o},value:e.name1,disabled:r||!!e.name,onChange:f=>m({name1:f.target.value}),placeholder:"Management name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:f=>m({creation_date:f}),disabled:r,style:{...A,...o}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.status}),t.jsxs("select",{style:{...A,...o},value:e.status||"Active",disabled:r,onChange:f=>m({status:f.target.value}),children:[t.jsx("option",{value:"Active",children:S.field.statusActive}),t.jsx("option",{value:"Inactive",children:S.field.statusInactive})]})]})]})})})}function K0(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function Q0({departments:e,managements:n,canModify:s,onView:l,onEdit:r,onDelete:a}){const i=ne(),[c,u]=C.useState(new Set),[g,j]=C.useState(""),[y,p]=C.useState(""),[x,w]=C.useState("all"),v=b=>{var h;return((h=n.find(k=>k.name===b))==null?void 0:h.name1)||b||"—"},S={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},m=C.useMemo(()=>e.filter(b=>{const h=(b.department_name||b.name||"").toLowerCase();return!(g&&!h.includes(g.toLowerCase())||y&&b.custom_management!==y||x!=="all"&&(b.custom_status||"Active")!==x)}),[e,g,y,x]),[o,d]=C.useState(1);C.useEffect(()=>{d(1)},[g,y,x]);const f=m.slice((o-1)*ae,o*ae),z=b=>{const h=e.filter(P=>c.has(P.name)),k=Me.departments,I=k.columns.filter(P=>k.defaultColumns.includes(P.key));b==="csv"?He(I,h,"departments_selected"):Ge(I,h,"departments_selected")};return t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:m.length,color:F.teal})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:g,onChange:j,placeholder:"Search by name…"},{type:"select",label:i.col.management,value:y,onChange:p,options:[{value:"",label:"All Managements"},...n.map(b=>({value:b.name,label:b.name1||b.name}))]},{type:"select",label:"Status",value:x,onChange:w,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:f.length>0&&f.every(b=>c.has(b.name)),onChange:b=>{if(b.target.checked)u(new Set([...c,...f.map(h=>h.name)]));else{const h=new Set(c);f.forEach(k=>h.delete(k.name)),u(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:S,children:i.col.name}),t.jsx("th",{style:S,children:i.col.management}),t.jsx("th",{style:S,children:i.field.creationDate}),t.jsx("th",{style:S,children:i.field.status}),t.jsx("th",{style:S,children:i.col.actions})]})}),t.jsx("tbody",{children:m.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):f.map((b,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>l==null?void 0:l(b),style:{borderTop:"1px solid #f0f0f0",background:c.has(b.name)?"#eff6ff":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:k=>k.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:c.has(b.name),onChange:()=>{const k=new Set(c);k.has(b.name)?k.delete(b.name):k.add(b.name),u(k)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:b.department_name||b.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:v(b.custom_management)}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:K0(b.custom_creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{color:b.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:b.custom_status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:k=>k.stopPropagation(),children:t.jsx(at,{onView:()=>l==null?void 0:l(b),onEdit:s&&r?()=>r(b):void 0,onDelete:s&&a?()=>a(b.name):void 0})})]},b.name))})]})}),t.jsx(Je,{count:c.size,onClear:()=>u(new Set),onExport:z}),t.jsx(qe,{page:o,total:m.length,onPageChange:d})]})}function Y0({form:e,setForm:n,organizations:s,managements:l,formStatus:r,viewMode:a,onEdit:i,darkMode:c,notifCount:u,onToggleDark:g,onCountChange:j,onViewProfile:y,onSubmit:p,onBack:x,onNavigate:w,onLogout:v,user:S}){const m=ne(),o=b=>n(h=>({...h,...b})),d=a?{background:"#f8fafc"}:{},f=e.name?a?`${m.formTitle.editDept}: ${e.department_name||e.name}`:m.formTitle.editDept:m.formTitle.newDept,z=ye(l,e.custom_management).map(b=>({name:b.name,label:b.name1||b.name}));return t.jsx(Ze,{title:f,activePage:"departments",user:S,formStatus:r,buttonText:m.saveDept,buttonColor:"#16a34a",viewMode:a,onEdit:i,darkMode:c,notifCount:u,onToggleDark:g,onCountChange:j,onViewProfile:y,onSubmit:p,onBack:x,onNavigate:w,onLogout:v,children:t.jsx(re,{title:"Department Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[m.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.custom_organization,onChange:b=>o({custom_organization:b}),organizations:s,disabled:a||!!S.custom_organization})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[m.field.department," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...d},value:e.department_name,disabled:a||!!e.name,onChange:b=>o({department_name:b.target.value}),placeholder:"Department name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:m.field.management}),t.jsx(pe,{value:e.custom_management,onChange:b=>o({custom_management:b}),items:z,placeholder:m.field.select,disabled:a})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:m.field.creationDate}),t.jsx(xe,{value:e.custom_creation_date||"",onChange:b=>o({custom_creation_date:b}),disabled:a,style:{...A,...d}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:m.field.status}),t.jsxs("select",{style:{...A,...d},value:e.custom_status||"Active",disabled:a,onChange:b=>o({custom_status:b.target.value}),children:[t.jsx("option",{value:"Active",children:m.field.statusActive}),t.jsx("option",{value:"Inactive",children:m.field.statusInactive})]})]})]})})})}function X0(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function q0({branches:e,managements:n,departments:s,canModify:l,onView:r,onEdit:a,onDelete:i}){const c=ne(),[u,g]=C.useState(new Set),[j,y]=C.useState(""),[p,x]=C.useState(""),[w,v]=C.useState(""),[S,m]=C.useState("all"),o=P=>{var M;return((M=n.find(ee=>ee.name===P))==null?void 0:M.name1)||P||"—"},d=P=>{var M;return((M=s.find(ee=>ee.name===P))==null?void 0:M.department_name)||P||"—"},f={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},z=C.useMemo(()=>e.filter(P=>{const M=(P.branch||P.name||"").toLowerCase();return!(j&&!M.includes(j.toLowerCase())||p&&P.management!==p||w&&P.department!==w||S!=="all"&&(P.custom_status||"Active")!==S)}),[e,j,p,w,S]),[b,h]=C.useState(1);C.useEffect(()=>{h(1)},[j,p,w,S]);const k=z.slice((b-1)*ae,b*ae),I=P=>{const M=e.filter($=>u.has($.name)),ee=Me.branches,W=ee.columns.filter($=>ee.defaultColumns.includes($.key));P==="csv"?He(W,M,"branches_selected"):Ge(W,M,"branches_selected")};return t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:z.length,color:F.purple})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:j,onChange:y,placeholder:"Search by name…"},{type:"select",label:c.col.management,value:p,onChange:x,options:[{value:"",label:"All Managements"},...n.map(P=>({value:P.name,label:P.name1||P.name}))]},{type:"select",label:c.col.department,value:w,onChange:v,options:[{value:"",label:"All Departments"},...s.map(P=>({value:P.name,label:P.department_name||P.name}))]},{type:"select",label:"Status",value:S,onChange:m,options:[{value:"all",label:"All"},{value:"Active",label:c.field.statusActive},{value:"Inactive",label:c.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:k.length>0&&k.every(P=>u.has(P.name)),onChange:P=>{if(P.target.checked)g(new Set([...u,...k.map(M=>M.name)]));else{const M=new Set(u);k.forEach(ee=>M.delete(ee.name)),g(M)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:f,children:c.col.branch}),t.jsx("th",{style:f,children:c.col.management}),t.jsx("th",{style:f,children:c.col.department}),t.jsx("th",{style:f,children:c.field.creationDate}),t.jsx("th",{style:f,children:c.field.status}),t.jsx("th",{style:f,children:c.col.actions})]})}),t.jsx("tbody",{children:z.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:c.noData})}):k.map((P,M)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>r==null?void 0:r(P),style:{borderTop:"1px solid #f0f0f0",background:u.has(P.name)?"#eff6ff":M%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:ee=>ee.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:u.has(P.name),onChange:()=>{const ee=new Set(u);ee.has(P.name)?ee.delete(P.name):ee.add(P.name),g(ee)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:P.branch||P.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:o(P.management)}),t.jsx("td",{style:{padding:"10px 14px"},children:d(P.department)}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:X0(P.custom_creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{color:P.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:P.custom_status==="Inactive"?c.field.statusInactive:c.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:ee=>ee.stopPropagation(),children:t.jsx(at,{onView:()=>r==null?void 0:r(P),onEdit:l&&a?()=>a(P):void 0,onDelete:l&&i?()=>i(P.name):void 0})})]},P.name))})]})}),t.jsx(Je,{count:u.size,onClear:()=>g(new Set),onExport:I}),t.jsx(qe,{page:b,total:z.length,onPageChange:h})]})}function J0({form:e,setForm:n,organizations:s,managements:l,departments:r,formStatus:a,viewMode:i,onEdit:c,darkMode:u,notifCount:g,onToggleDark:j,onCountChange:y,onViewProfile:p,onSubmit:x,onBack:w,onNavigate:v,onLogout:S,user:m}){const o=ne(),d=k=>n(I=>({...I,...k})),f=i?{background:"#f8fafc"}:{},z=e.name?i?`${o.formTitle.editBranch}: ${e.branch||e.name}`:o.formTitle.editBranch:o.formTitle.newBranch,b=ye(l,e.management).map(k=>({name:k.name,label:k.name1||k.name})),h=ye(r,e.department).map(k=>({name:k.name,label:k.department_name||k.name}));return t.jsx(Ze,{title:z,activePage:"branches",user:m,formStatus:a,buttonText:o.saveBranch,buttonColor:"#16a34a",viewMode:i,onEdit:c,darkMode:u,notifCount:g,onToggleDark:j,onCountChange:y,onViewProfile:p,onSubmit:x,onBack:w,onNavigate:v,onLogout:S,children:t.jsx(re,{title:"Branch Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[o.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.organization,onChange:k=>d({organization:k}),organizations:s,disabled:i||!!m.custom_organization})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[o.field.branch," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...f},value:e.branch,disabled:i||!!e.name,onChange:k=>d({branch:k.target.value}),placeholder:"Branch name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:o.field.management}),t.jsx(pe,{value:e.management,onChange:k=>d({management:k}),items:b,placeholder:o.field.select,disabled:i})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:o.field.department}),t.jsx(pe,{value:e.department,onChange:k=>d({department:k}),items:h,placeholder:o.field.select,disabled:i})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:o.field.creationDate}),t.jsx(xe,{value:e.custom_creation_date||"",onChange:k=>d({custom_creation_date:k}),disabled:i,style:{...A,...f}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:o.field.status}),t.jsxs("select",{style:{...A,...f},value:e.custom_status||"Active",disabled:i,onChange:k=>d({custom_status:k.target.value}),children:[t.jsx("option",{value:"Active",children:o.field.statusActive}),t.jsx("option",{value:"Inactive",children:o.field.statusInactive})]})]})]})})})}function Z0(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function V0({incidentTypes:e,canModify:n,onView:s,onEdit:l,onDelete:r}){const a=ne(),[i,c]=C.useState(new Set),[u,g]=C.useState(""),[j,y]=C.useState("all"),p={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},x=C.useMemo(()=>e.filter(o=>{const d=(o.name1||o.name||"").toLowerCase();return!(u&&!d.includes(u.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,u,j]),[w,v]=C.useState(1);C.useEffect(()=>{v(1)},[u,j]);const S=x.slice((w-1)*ae,w*ae),m=o=>{const d=e.filter(b=>i.has(b.name)),f=Me["incident-types"],z=f.columns.filter(b=>f.defaultColumns.includes(b.key));o==="csv"?He(z,d,"incident_types_selected"):Ge(z,d,"incident_types_selected")};return t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:x.length,color:F.red})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:u,onChange:g,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:S.length>0&&S.every(o=>i.has(o.name)),onChange:o=>{if(o.target.checked)c(new Set([...i,...S.map(d=>d.name)]));else{const d=new Set(i);S.forEach(f=>d.delete(f.name)),c(d)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:p,children:a.col.name}),t.jsx("th",{style:p,children:a.field.creationDate}),t.jsx("th",{style:p,children:a.field.status}),t.jsx("th",{style:p,children:a.col.actions})]})}),t.jsx("tbody",{children:x.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):S.map((o,d)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:i.has(o.name)?"#eff6ff":d%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:f=>f.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:i.has(o.name),onChange:()=>{const f=new Set(i);f.has(o.name)?f.delete(o.name):f.add(o.name),c(f)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:Z0(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:f=>f.stopPropagation(),children:t.jsx(at,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Je,{count:i.size,onClear:()=>c(new Set),onExport:m}),t.jsx(qe,{page:w,total:x.length,onPageChange:v})]})}function e1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:u,onViewProfile:g,onSubmit:j,onBack:y,onNavigate:p,onLogout:x,user:w}){const v=ne(),S=d=>n(f=>({...f,...d})),m=l?{background:"#f8fafc"}:{},o=e.name?l?`Incident Type: ${e.name1||e.name}`:"Edit Incident Type":"New Incident Type";return t.jsx(Ze,{title:o,activePage:"incident-types",user:w,formStatus:s,buttonText:v.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:u,onViewProfile:g,onSubmit:j,onBack:y,onNavigate:p,onLogout:x,children:t.jsx(re,{title:"Incident Type Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[v.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...m},value:e.name1,disabled:l||!!e.name,onChange:d=>S({name1:d.target.value}),placeholder:"Incident type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:v.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:d=>S({creation_date:d}),disabled:l,style:{...A,...m}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:v.field.status}),t.jsxs("select",{style:{...A,...m},value:e.status||"Active",disabled:l,onChange:d=>S({status:d.target.value}),children:[t.jsx("option",{value:"Active",children:v.field.statusActive}),t.jsx("option",{value:"Inactive",children:v.field.statusInactive})]})]})]})})})}function t1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function n1({ideaTypes:e,canModify:n,onView:s,onEdit:l,onDelete:r}){const a=ne(),[i,c]=C.useState(new Set),[u,g]=C.useState(""),[j,y]=C.useState("all"),p={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},x=C.useMemo(()=>e.filter(o=>{const d=(o.name1||o.name||"").toLowerCase();return!(u&&!d.includes(u.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,u,j]),[w,v]=C.useState(1);C.useEffect(()=>{v(1)},[u,j]);const S=x.slice((w-1)*ae,w*ae),m=o=>{const d=e.filter(b=>i.has(b.name)),f=Me["idea-types"],z=f.columns.filter(b=>f.defaultColumns.includes(b.key));o==="csv"?He(z,d,"idea_types_selected"):Ge(z,d,"idea_types_selected")};return t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:x.length,color:F.teal})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:u,onChange:g,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:S.length>0&&S.every(o=>i.has(o.name)),onChange:o=>{if(o.target.checked)c(new Set([...i,...S.map(d=>d.name)]));else{const d=new Set(i);S.forEach(f=>d.delete(f.name)),c(d)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:p,children:a.col.name}),t.jsx("th",{style:p,children:a.field.creationDate}),t.jsx("th",{style:p,children:a.field.status}),t.jsx("th",{style:p,children:a.col.actions})]})}),t.jsx("tbody",{children:x.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):S.map((o,d)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:i.has(o.name)?"#eff6ff":d%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:f=>f.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:i.has(o.name),onChange:()=>{const f=new Set(i);f.has(o.name)?f.delete(o.name):f.add(o.name),c(f)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:t1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:f=>f.stopPropagation(),children:t.jsx(at,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Je,{count:i.size,onClear:()=>c(new Set),onExport:m}),t.jsx(qe,{page:w,total:x.length,onPageChange:v})]})}function s1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:u,onViewProfile:g,onSubmit:j,onBack:y,onNavigate:p,onLogout:x,user:w}){const v=ne(),S=d=>n(f=>({...f,...d})),m=l?{background:"#f8fafc"}:{},o=e.name?l?`Idea Type: ${e.name1||e.name}`:"Edit Idea Type":"New Idea Type";return t.jsx(Ze,{title:o,activePage:"idea-types",user:w,formStatus:s,buttonText:v.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:u,onViewProfile:g,onSubmit:j,onBack:y,onNavigate:p,onLogout:x,children:t.jsx(re,{title:"Idea Type Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[v.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...m},value:e.name1,disabled:l||!!e.name,onChange:d=>S({name1:d.target.value}),placeholder:"Idea type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:v.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:d=>S({creation_date:d}),disabled:l,style:{...A,...m}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:v.field.status}),t.jsxs("select",{style:{...A,...m},value:e.status||"Active",disabled:l,onChange:d=>S({status:d.target.value}),children:[t.jsx("option",{value:"Active",children:v.field.statusActive}),t.jsx("option",{value:"Inactive",children:v.field.statusInactive})]})]})]})})})}function l1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function r1({orderTypes:e,canModify:n,onView:s,onEdit:l,onDelete:r}){const a=ne(),[i,c]=C.useState(new Set),[u,g]=C.useState(""),[j,y]=C.useState("all"),p={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},x=C.useMemo(()=>e.filter(o=>{const d=(o.name1||o.name||"").toLowerCase();return!(u&&!d.includes(u.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,u,j]),[w,v]=C.useState(1);C.useEffect(()=>{v(1)},[u,j]);const S=x.slice((w-1)*ae,w*ae),m=o=>{const d=e.filter(b=>i.has(b.name)),f=Me["order-types"],z=f.columns.filter(b=>f.defaultColumns.includes(b.key));o==="csv"?He(z,d,"order_types_selected"):Ge(z,d,"order_types_selected")};return t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:x.length,color:F.purple})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:u,onChange:g,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:S.length>0&&S.every(o=>i.has(o.name)),onChange:o=>{if(o.target.checked)c(new Set([...i,...S.map(d=>d.name)]));else{const d=new Set(i);S.forEach(f=>d.delete(f.name)),c(d)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:p,children:a.col.name}),t.jsx("th",{style:p,children:a.field.creationDate}),t.jsx("th",{style:p,children:a.field.status}),t.jsx("th",{style:p,children:a.col.actions})]})}),t.jsx("tbody",{children:x.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):S.map((o,d)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:i.has(o.name)?"#eff6ff":d%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:f=>f.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:i.has(o.name),onChange:()=>{const f=new Set(i);f.has(o.name)?f.delete(o.name):f.add(o.name),c(f)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:l1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:f=>f.stopPropagation(),children:t.jsx(at,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Je,{count:i.size,onClear:()=>c(new Set),onExport:m}),t.jsx(qe,{page:w,total:x.length,onPageChange:v})]})}function a1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:u,onViewProfile:g,onSubmit:j,onBack:y,onNavigate:p,onLogout:x,user:w}){const v=ne(),S=d=>n(f=>({...f,...d})),m=l?{background:"#f8fafc"}:{},o=e.name?l?`Order Type: ${e.name1||e.name}`:"Edit Order Type":"New Order Type";return t.jsx(Ze,{title:o,activePage:"order-types",user:w,formStatus:s,buttonText:v.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:u,onViewProfile:g,onSubmit:j,onBack:y,onNavigate:p,onLogout:x,children:t.jsx(re,{title:"Order Type Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[v.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...m},value:e.name1,disabled:l||!!e.name,onChange:d=>S({name1:d.target.value}),placeholder:"Order type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:v.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:d=>S({creation_date:d}),disabled:l,style:{...A,...m}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:v.field.status}),t.jsxs("select",{style:{...A,...m},value:e.status||"Active",disabled:l,onChange:d=>S({status:d.target.value}),children:[t.jsx("option",{value:"Active",children:v.field.statusActive}),t.jsx("option",{value:"Inactive",children:v.field.statusInactive})]})]})]})})})}function i1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function o1({processTypes:e,canModify:n,onView:s,onEdit:l,onDelete:r}){const a=ne(),[i,c]=C.useState(new Set),[u,g]=C.useState(""),[j,y]=C.useState("all"),p={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},x=C.useMemo(()=>e.filter(o=>{const d=(o.name1||o.name||"").toLowerCase();return!(u&&!d.includes(u.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,u,j]),[w,v]=C.useState(1);C.useEffect(()=>{v(1)},[u,j]);const S=x.slice((w-1)*ae,w*ae),m=o=>{const d=e.filter(b=>i.has(b.name)),f=Me["process-types"],z=f.columns.filter(b=>f.defaultColumns.includes(b.key));o==="csv"?He(z,d,"process_types_selected"):Ge(z,d,"process_types_selected")};return t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:x.length,color:F.blue})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:u,onChange:g,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:S.length>0&&S.every(o=>i.has(o.name)),onChange:o=>{if(o.target.checked)c(new Set([...i,...S.map(d=>d.name)]));else{const d=new Set(i);S.forEach(f=>d.delete(f.name)),c(d)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:p,children:a.col.name}),t.jsx("th",{style:p,children:a.field.creationDate}),t.jsx("th",{style:p,children:a.field.status}),t.jsx("th",{style:p,children:a.col.actions})]})}),t.jsx("tbody",{children:x.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):S.map((o,d)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:i.has(o.name)?"#eff6ff":d%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:f=>f.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:i.has(o.name),onChange:()=>{const f=new Set(i);f.has(o.name)?f.delete(o.name):f.add(o.name),c(f)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:i1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:f=>f.stopPropagation(),children:t.jsx(at,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Je,{count:i.size,onClear:()=>c(new Set),onExport:m}),t.jsx(qe,{page:w,total:x.length,onPageChange:v})]})}function c1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:u,onViewProfile:g,onSubmit:j,onBack:y,onNavigate:p,onLogout:x,user:w}){const v=ne(),S=d=>n(f=>({...f,...d})),m=l?{background:"#f8fafc"}:{},o=e.name?l?`Process Type: ${e.name1||e.name}`:"Edit Process Type":"New Process Type";return t.jsx(Ze,{title:o,activePage:"process-types",user:w,formStatus:s,buttonText:v.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:u,onViewProfile:g,onSubmit:j,onBack:y,onNavigate:p,onLogout:x,children:t.jsx(re,{title:"Process Type Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[v.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...m},value:e.name1,disabled:l||!!e.name,onChange:d=>S({name1:d.target.value}),placeholder:"Process type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:v.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:d=>S({creation_date:d}),disabled:l,style:{...A,...m}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:v.field.status}),t.jsxs("select",{style:{...A,...m},value:e.status||"Active",disabled:l,onChange:d=>S({status:d.target.value}),children:[t.jsx("option",{value:"Active",children:v.field.statusActive}),t.jsx("option",{value:"Inactive",children:v.field.statusInactive})]})]})]})})})}function d1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function u1({incidentStatuses:e,canModify:n,onView:s,onEdit:l,onDelete:r}){const a=ne(),[i,c]=C.useState(new Set),[u,g]=C.useState(""),[j,y]=C.useState("all"),p={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},x=C.useMemo(()=>e.filter(o=>{const d=(o.name1||o.name||"").toLowerCase();return!(u&&!d.includes(u.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,u,j]),[w,v]=C.useState(1);C.useEffect(()=>{v(1)},[u,j]);const S=x.slice((w-1)*ae,w*ae),m=o=>{const d=e.filter(b=>i.has(b.name)),f=Me["incident-statuses"],z=f.columns.filter(b=>f.defaultColumns.includes(b.key));o==="csv"?He(z,d,"incident_statuses_selected"):Ge(z,d,"incident_statuses_selected")};return t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:x.length,color:F.red})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:u,onChange:g,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:S.length>0&&S.every(o=>i.has(o.name)),onChange:o=>{if(o.target.checked)c(new Set([...i,...S.map(d=>d.name)]));else{const d=new Set(i);S.forEach(f=>d.delete(f.name)),c(d)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:p,children:a.col.name}),t.jsx("th",{style:p,children:a.field.notifyManager}),t.jsx("th",{style:p,children:a.field.creationDate}),t.jsx("th",{style:p,children:a.field.status}),t.jsx("th",{style:p,children:a.col.actions})]})}),t.jsx("tbody",{children:x.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):S.map((o,d)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:i.has(o.name)?"#eff6ff":d%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:f=>f.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:i.has(o.name),onChange:()=>{const f=new Set(i);f.has(o.name)?f.delete(o.name):f.add(o.name),c(f)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:o.notify_manager?a.field.statusActive:"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:d1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:f=>f.stopPropagation(),children:t.jsx(at,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Je,{count:i.size,onClear:()=>c(new Set),onExport:m}),t.jsx(qe,{page:w,total:x.length,onPageChange:v})]})}function p1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:u,onViewProfile:g,onSubmit:j,onBack:y,onNavigate:p,onLogout:x,user:w}){const v=ne(),S=d=>n(f=>({...f,...d})),m=l?{background:"#f8fafc"}:{},o=e.name?l?`Incident Status: ${e.name1||e.name}`:"Edit Incident Status":"New Incident Status";return t.jsx(Ze,{title:o,activePage:"incident-statuses",user:w,formStatus:s,buttonText:v.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:u,onViewProfile:g,onSubmit:j,onBack:y,onNavigate:p,onLogout:x,children:t.jsxs(re,{title:"Incident Status Details",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[v.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...m},value:e.name1,disabled:l||!!e.name,onChange:d=>S({name1:d.target.value}),placeholder:"Incident status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:v.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:d=>S({creation_date:d}),disabled:l,style:{...A,...m}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:v.field.status}),t.jsxs("select",{style:{...A,...m},value:e.status||"Active",disabled:l,onChange:d=>S({status:d.target.value}),children:[t.jsx("option",{value:"Active",children:v.field.statusActive}),t.jsx("option",{value:"Inactive",children:v.field.statusInactive})]})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:l,onChange:d=>S({notify_manager:d.target.checked?1:0}),style:zl}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:v.field.notifyManager})]})]})})}function f1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function h1({ideaStatuses:e,canModify:n,onView:s,onEdit:l,onDelete:r}){const a=ne(),[i,c]=C.useState(new Set),[u,g]=C.useState(""),[j,y]=C.useState("all"),p={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},x=C.useMemo(()=>e.filter(o=>{const d=(o.name1||o.name||"").toLowerCase();return!(u&&!d.includes(u.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,u,j]),[w,v]=C.useState(1);C.useEffect(()=>{v(1)},[u,j]);const S=x.slice((w-1)*ae,w*ae),m=o=>{const d=e.filter(b=>i.has(b.name)),f=Me["idea-statuses"],z=f.columns.filter(b=>f.defaultColumns.includes(b.key));o==="csv"?He(z,d,"idea_statuses_selected"):Ge(z,d,"idea_statuses_selected")};return t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:x.length,color:F.teal})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:u,onChange:g,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:S.length>0&&S.every(o=>i.has(o.name)),onChange:o=>{if(o.target.checked)c(new Set([...i,...S.map(d=>d.name)]));else{const d=new Set(i);S.forEach(f=>d.delete(f.name)),c(d)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:p,children:a.col.name}),t.jsx("th",{style:p,children:a.field.notifyManager}),t.jsx("th",{style:p,children:a.field.creationDate}),t.jsx("th",{style:p,children:a.field.status}),t.jsx("th",{style:p,children:a.col.actions})]})}),t.jsx("tbody",{children:x.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):S.map((o,d)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:i.has(o.name)?"#eff6ff":d%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:f=>f.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:i.has(o.name),onChange:()=>{const f=new Set(i);f.has(o.name)?f.delete(o.name):f.add(o.name),c(f)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:o.notify_manager?a.field.statusActive:"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:f1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:f=>f.stopPropagation(),children:t.jsx(at,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Je,{count:i.size,onClear:()=>c(new Set),onExport:m}),t.jsx(qe,{page:w,total:x.length,onPageChange:v})]})}function g1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:u,onViewProfile:g,onSubmit:j,onBack:y,onNavigate:p,onLogout:x,user:w}){const v=ne(),S=d=>n(f=>({...f,...d})),m=l?{background:"#f8fafc"}:{},o=e.name?l?`Idea Status: ${e.name1||e.name}`:"Edit Idea Status":"New Idea Status";return t.jsx(Ze,{title:o,activePage:"idea-statuses",user:w,formStatus:s,buttonText:v.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:u,onViewProfile:g,onSubmit:j,onBack:y,onNavigate:p,onLogout:x,children:t.jsxs(re,{title:"Idea Status Details",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[v.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...m},value:e.name1,disabled:l||!!e.name,onChange:d=>S({name1:d.target.value}),placeholder:"Idea status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:v.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:d=>S({creation_date:d}),disabled:l,style:{...A,...m}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:v.field.status}),t.jsxs("select",{style:{...A,...m},value:e.status||"Active",disabled:l,onChange:d=>S({status:d.target.value}),children:[t.jsx("option",{value:"Active",children:v.field.statusActive}),t.jsx("option",{value:"Inactive",children:v.field.statusInactive})]})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:l,onChange:d=>S({notify_manager:d.target.checked?1:0}),style:zl}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:v.field.notifyManager})]})]})})}function x1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function m1({orderStatuses:e,canModify:n,onView:s,onEdit:l,onDelete:r}){const a=ne(),[i,c]=C.useState(new Set),[u,g]=C.useState(""),[j,y]=C.useState("all"),p={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},x=C.useMemo(()=>e.filter(o=>{const d=(o.name1||o.name||"").toLowerCase();return!(u&&!d.includes(u.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,u,j]),[w,v]=C.useState(1);C.useEffect(()=>{v(1)},[u,j]);const S=x.slice((w-1)*ae,w*ae),m=o=>{const d=e.filter(b=>i.has(b.name)),f=Me["order-statuses"],z=f.columns.filter(b=>f.defaultColumns.includes(b.key));o==="csv"?He(z,d,"order_statuses_selected"):Ge(z,d,"order_statuses_selected")};return t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:x.length,color:F.purple})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:u,onChange:g,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:S.length>0&&S.every(o=>i.has(o.name)),onChange:o=>{if(o.target.checked)c(new Set([...i,...S.map(d=>d.name)]));else{const d=new Set(i);S.forEach(f=>d.delete(f.name)),c(d)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:p,children:a.col.name}),t.jsx("th",{style:p,children:a.field.notifyManager}),t.jsx("th",{style:p,children:a.field.creationDate}),t.jsx("th",{style:p,children:a.field.status}),t.jsx("th",{style:p,children:a.col.actions})]})}),t.jsx("tbody",{children:x.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):S.map((o,d)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:i.has(o.name)?"#eff6ff":d%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:f=>f.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:i.has(o.name),onChange:()=>{const f=new Set(i);f.has(o.name)?f.delete(o.name):f.add(o.name),c(f)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:o.notify_manager?a.field.statusActive:"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:x1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:f=>f.stopPropagation(),children:t.jsx(at,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Je,{count:i.size,onClear:()=>c(new Set),onExport:m}),t.jsx(qe,{page:w,total:x.length,onPageChange:v})]})}function y1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:u,onViewProfile:g,onSubmit:j,onBack:y,onNavigate:p,onLogout:x,user:w}){const v=ne(),S=d=>n(f=>({...f,...d})),m=l?{background:"#f8fafc"}:{},o=e.name?l?`Order Status: ${e.name1||e.name}`:"Edit Order Status":"New Order Status";return t.jsx(Ze,{title:o,activePage:"order-statuses",user:w,formStatus:s,buttonText:v.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:u,onViewProfile:g,onSubmit:j,onBack:y,onNavigate:p,onLogout:x,children:t.jsxs(re,{title:"Order Status Details",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[v.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...m},value:e.name1,disabled:l||!!e.name,onChange:d=>S({name1:d.target.value}),placeholder:"Order status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:v.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:d=>S({creation_date:d}),disabled:l,style:{...A,...m}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:v.field.status}),t.jsxs("select",{style:{...A,...m},value:e.status||"Active",disabled:l,onChange:d=>S({status:d.target.value}),children:[t.jsx("option",{value:"Active",children:v.field.statusActive}),t.jsx("option",{value:"Inactive",children:v.field.statusInactive})]})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:l,onChange:d=>S({notify_manager:d.target.checked?1:0}),style:zl}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:v.field.notifyManager})]})]})})}function v1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function j1({processStatuses:e,canModify:n,onView:s,onEdit:l,onDelete:r}){const a=ne(),[i,c]=C.useState(new Set),[u,g]=C.useState(""),[j,y]=C.useState("all"),p={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},x=C.useMemo(()=>e.filter(o=>{const d=(o.name1||o.name||"").toLowerCase();return!(u&&!d.includes(u.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,u,j]),[w,v]=C.useState(1);C.useEffect(()=>{v(1)},[u,j]);const S=x.slice((w-1)*ae,w*ae),m=o=>{const d=e.filter(b=>i.has(b.name)),f=Me["process-statuses"],z=f.columns.filter(b=>f.defaultColumns.includes(b.key));o==="csv"?He(z,d,"process_statuses_selected"):Ge(z,d,"process_statuses_selected")};return t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:x.length,color:F.blue})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:u,onChange:g,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:S.length>0&&S.every(o=>i.has(o.name)),onChange:o=>{if(o.target.checked)c(new Set([...i,...S.map(d=>d.name)]));else{const d=new Set(i);S.forEach(f=>d.delete(f.name)),c(d)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:p,children:a.col.name}),t.jsx("th",{style:p,children:a.field.notifyManager}),t.jsx("th",{style:p,children:a.field.creationDate}),t.jsx("th",{style:p,children:a.field.status}),t.jsx("th",{style:p,children:a.col.actions})]})}),t.jsx("tbody",{children:x.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):S.map((o,d)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:i.has(o.name)?"#eff6ff":d%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:f=>f.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:i.has(o.name),onChange:()=>{const f=new Set(i);f.has(o.name)?f.delete(o.name):f.add(o.name),c(f)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:o.notify_manager?a.field.statusActive:"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:v1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:f=>f.stopPropagation(),children:t.jsx(at,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Je,{count:i.size,onClear:()=>c(new Set),onExport:m}),t.jsx(qe,{page:w,total:x.length,onPageChange:v})]})}function b1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:u,onViewProfile:g,onSubmit:j,onBack:y,onNavigate:p,onLogout:x,user:w}){const v=ne(),S=d=>n(f=>({...f,...d})),m=l?{background:"#f8fafc"}:{},o=e.name?l?`Process Status: ${e.name1||e.name}`:"Edit Process Status":"New Process Status";return t.jsx(Ze,{title:o,activePage:"process-statuses",user:w,formStatus:s,buttonText:v.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:c,onCountChange:u,onViewProfile:g,onSubmit:j,onBack:y,onNavigate:p,onLogout:x,children:t.jsxs(re,{title:"Process Status Details",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[v.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...m},value:e.name1,disabled:l||!!e.name,onChange:d=>S({name1:d.target.value}),placeholder:"Process status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:v.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:d=>S({creation_date:d}),disabled:l,style:{...A,...m}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:v.field.status}),t.jsxs("select",{style:{...A,...m},value:e.status||"Active",disabled:l,onChange:d=>S({status:d.target.value}),children:[t.jsx("option",{value:"Active",children:v.field.statusActive}),t.jsx("option",{value:"Inactive",children:v.field.statusInactive})]})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:l,onChange:d=>S({notify_manager:d.target.checked?1:0}),style:zl}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:v.field.notifyManager})]})]})})}const S1={Admin:"#7c3aed",Chairman:"#0f766e",Auditor:"#d97706","X-Auditor":"#8b5cf6",Manager:"#2563eb",Employee:"#6b7280"};function w1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function k1({users:e,canModify:n,onView:s,onEdit:l,onDisable:r}){const a=ne(),[i,c]=C.useState(new Set),[u,g]=C.useState(!1),[j,y]=C.useState(""),[p,x]=C.useState(""),[w,v]=C.useState(""),[S,m]=C.useState("active"),[o,d]=C.useState(1),[f,z]=C.useState(null),[b,h]=C.useState(""),[k,I]=C.useState("idle"),[P,M]=C.useState(null),ee=async()=>{if(!(!f||!b.trim())){I("loading");try{await ih(f.name,b.trim()),I("success"),setTimeout(()=>{z(null),h(""),I("idle")},1200)}catch{I("error")}}},W=async N=>{if(window.confirm(a.users.disableConfirm)){M(N);try{await(r==null?void 0:r(N))}finally{M(null)}}},$=e.filter(N=>{if(S==="active"&&(N.enabled===0||N.enabled==="0")||S==="inactive"&&N.enabled!==0&&N.enabled!=="0")return!1;const Z=N.custom_category||"";if(w&&Z!==w)return!1;const ce=N.custom_organization||"";if(p&&!ce.toLowerCase().includes(p.toLowerCase()))return!1;if(j){const me=j.toLowerCase();if(![N.full_name,N.email,N.name,N.username,N.mobile_no].join(" ").toLowerCase().includes(me))return!1}return!0}),T=[...new Set(e.map(N=>N.custom_organization).filter(Boolean))],D=["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"];C.useEffect(()=>{d(1)},[j,p,w,S]);const Q=$.slice((o-1)*ae,o*ae),Y={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151"},X={...Y,cursor:"pointer"},q=N=>{const Z=$.filter(le=>i.has(le.name)),ce=Me.users,me=ce.columns.filter(le=>ce.defaultColumns.includes(le.key));N==="csv"?He(me,Z,"users_selected"):Ge(me,Z,"users_selected")};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,flex:1},children:[t.jsxs("div",{style:{background:"white",borderRadius:12,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:16},children:[t.jsxs("div",{onClick:()=>g(N=>!N),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",padding:"12px 18px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",userSelect:"none"},children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:u?t.jsx("polyline",{points:"18,15 12,9 6,15"}):t.jsx("polyline",{points:"6,9 12,15 18,9"})}),t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:t.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),t.jsx("span",{style:{color:"white",fontWeight:700,fontSize:14},children:"Filters"})]}),u&&t.jsxs("div",{style:{padding:"18px 20px",display:"flex",flexDirection:"column",gap:14},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:14},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Search"}),t.jsx("input",{style:Y,placeholder:"Name, email, username…",value:j,onChange:N=>{y(N.target.value),d(1)}})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Organization"}),t.jsxs("select",{style:X,value:p,onChange:N=>{x(N.target.value),d(1)},children:[t.jsx("option",{value:"",children:"All Organizations"}),T.map(N=>t.jsx("option",{value:N,children:N},N))]})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Category"}),t.jsxs("select",{style:X,value:w,onChange:N=>{v(N.target.value),d(1)},children:[t.jsx("option",{value:"",children:"All Categories"}),D.map(N=>t.jsx("option",{value:N,children:N},N))]})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Status"}),t.jsxs("select",{style:X,value:S,onChange:N=>{m(N.target.value),d(1)},children:[t.jsx("option",{value:"all",children:"All"}),t.jsx("option",{value:"active",children:"Active"}),t.jsx("option",{value:"inactive",children:"Inactive"})]})]})]}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{type:"button",onClick:()=>{x(""),v(""),m("active"),y(""),d(1)},style:{padding:"7px 16px",background:"#f3f4f6",color:"#374151",border:"1px solid #d1d5db",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:600},children:"Clear Filters"})})]})]}),t.jsx("div",{style:{background:"white",borderRadius:10,border:"1px solid #e5e7eb",overflow:"auto",flex:1,boxShadow:"0 1px 4px rgba(0,0,0,0.05)"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f9fafb",borderBottom:"2px solid #e5e7eb",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"11px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:Q.length>0&&Q.every(N=>i.has(N.name)),onChange:N=>{if(N.target.checked)c(new Set([...i,...Q.map(Z=>Z.name)]));else{const Z=new Set(i);Q.forEach(ce=>Z.delete(ce.name)),c(Z)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),[{label:"Category",w:110},{label:"Number",w:90},{label:a.col.name,w:160},{label:"Username",w:130},{label:"Email",w:180},{label:"Phone",w:110},{label:a.col.organization,w:140},{label:a.col.management,w:120},{label:a.col.department,w:120},{label:"Branch",w:100},{label:"Since",w:90},{label:"Status",w:80},{label:"Tools",w:200}].map(({label:N,w:Z})=>t.jsx("th",{style:{padding:"11px 14px",textAlign:"left",color:"#6b7280",fontSize:11,fontWeight:700,whiteSpace:"nowrap",minWidth:Z,letterSpacing:.3,textTransform:"uppercase"},children:N},N))]})}),t.jsx("tbody",{children:$.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:14,style:{padding:"48px 20px",textAlign:"center",color:"#aaa",fontSize:14},children:"No users found"})}):Q.map((N,Z)=>{const ce=N.custom_category||"",me=S1[ce]||"#6b7280";return t.jsxs("tr",{onClick:()=>s==null?void 0:s(N),style:{borderBottom:"1px solid #f3f4f6",background:i.has(N.name)?"#eff6ff":Z%2===0?"white":"#fafafa",transition:"background 0.1s",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"11px 14px",textAlign:"center"},onClick:le=>le.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:i.has(N.name),onChange:()=>{const le=new Set(i);le.has(N.name)?le.delete(N.name):le.add(N.name),c(le)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:ce?t.jsx("span",{style:{background:me+"18",color:me,border:`1px solid ${me}44`,padding:"3px 10px",borderRadius:20,fontSize:11,fontWeight:700},children:ce}):t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:N.custom_number||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",fontWeight:600,color:"#1a2332",whiteSpace:"nowrap"},children:N.full_name||N.first_name||"—"}),t.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:N.username||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:N.email||N.name}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:N.mobile_no||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:N.custom_organization||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:N.custom_management||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:N.custom_department||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:N.custom_branch||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:w1(N.creation)}),t.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:t.jsx("span",{style:{color:N.enabled?"#16a34a":"#dc2626",fontWeight:600},children:N.enabled?a.users.active:a.users.inactive})}),t.jsx("td",{style:{padding:"10px 14px",whiteSpace:"nowrap"},onClick:le=>le.stopPropagation(),children:t.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[t.jsx("button",{onClick:le=>{le.stopPropagation(),s==null||s(N)},title:"View",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#e0f7fa",color:"#0891b2"},children:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),n&&l&&t.jsx("button",{onClick:le=>{le.stopPropagation(),l(N)},title:"Edit",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#dcfce7",color:"#16a34a"},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),n&&t.jsx("button",{onClick:le=>{le.stopPropagation(),z({name:N.name,email:N.email||N.name}),h(""),I("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:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}),n&&t.jsx("button",{onClick:le=>{le.stopPropagation(),W(N.name)},disabled:P===N.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:P===N.name?.5:1},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6l-1 14H6L5 6"}),t.jsx("path",{d:"M10 11v6M14 11v6"}),t.jsx("path",{d:"M9 6V4h6v2"})]})})]})})]},N.name)})})]})}),t.jsx(Je,{count:i.size,onClear:()=>c(new Set),onExport:q}),t.jsx(qe,{page:o,total:$.length,onPageChange:d}),f&&t.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsxs("div",{style:{background:"white",borderRadius:14,padding:32,width:390,boxShadow:"0 20px 60px rgba(0,0,0,0.3)"},children:[t.jsx("div",{style:{fontSize:17,fontWeight:700,marginBottom:6,color:"#1a2332"},children:a.users.setPassword}),t.jsxs("div",{style:{fontSize:13,color:"#6b7280",marginBottom:20},children:["User: ",t.jsx("strong",{children:f.email})]}),t.jsx("input",{type:"password",value:b,onChange:N=>h(N.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:N=>N.key==="Enter"&&ee(),autoFocus:!0}),k==="success"&&t.jsx("div",{style:{color:"#166534",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,padding:"8px 12px",marginBottom:12,fontSize:13},children:"Password updated successfully"}),k==="error"&&t.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"}),t.jsxs("div",{style:{display:"flex",gap:10},children:[t.jsx("button",{onClick:ee,disabled:k==="loading"||!b.trim(),style:{flex:1,padding:10,background:"#2563eb",color:"white",border:"none",borderRadius:8,cursor:"pointer",fontSize:13,fontWeight:700,fontFamily:"inherit",opacity:b.trim()?1:.5},children:k==="loading"?"Saving…":a.users.setPassword}),t.jsx("button",{onClick:()=>{z(null),h(""),I("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:n,groupCompanies:s=[],organizations:l,managements:r,departments:a,branches:i,formStatus:c,viewMode:u,onEdit:g,darkMode:j,notifCount:y,onToggleDark:p,onCountChange:x,onViewProfile:w,isSelfProfile:v,onSubmit:S,onBack:m,onNavigate:o,onLogout:d,user:f}){const z=ne(),b=$=>n(T=>({...T,...$})),h=u?{background:"#f8fafc"}:{},k=!e.name,I=v?"My Profile":k?"New User":u?`User: ${e.full_name||e.email}`:`Edit User: ${e.full_name||e.email}`,P=s.map($=>({name:$.name,label:$.company_name?`${$.company_name} (${$.name})`:$.name})),M=ye(r,e.custom_management).map($=>({name:$.name,label:$.name1||$.name})),ee=ye(a,e.custom_department).map($=>({name:$.name,label:$.department_name||$.name})),W=ye(i,e.custom_branch).map($=>({name:$.name,label:$.branch||$.name}));return t.jsxs(Ze,{title:I,activePage:"users",user:f,formStatus:c,buttonText:z.saveUser,buttonColor:"#16a34a",viewMode:u,onEdit:g,darkMode:j,notifCount:y,onToggleDark:p,onCountChange:x,onViewProfile:w,hideSettings:v,onSubmit:S,onBack:m,onNavigate:o,onLogout:d,children:[t.jsx(re,{title:"User Organization & Assignment",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Group Company (Tenant)"}),t.jsx(pe,{value:e.custom_group_company||"",onChange:$=>b({custom_group_company:$}),items:P,placeholder:"-- Select Group Company --",disabled:u||!!f.custom_group_company})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:z.field.organization}),t.jsx(Gt,{value:e.custom_organization,onChange:$=>b({custom_organization:$}),organizations:l,disabled:u})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:z.field.management}),t.jsx(pe,{value:e.custom_management,onChange:$=>b({custom_management:$}),items:M,placeholder:"-- Select --",disabled:u})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:z.field.department}),t.jsx(pe,{value:e.custom_department,onChange:$=>b({custom_department:$}),items:ee,placeholder:"-- Select --",disabled:u})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:z.field.branch}),t.jsx(pe,{value:e.custom_branch,onChange:$=>b({custom_branch:$}),items:W,placeholder:"-- Select --",disabled:u})]})]})}),t.jsx(re,{title:"User Profile Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:z.field.number}),t.jsx("input",{style:{...A,...h},value:e.custom_number,disabled:u,onChange:$=>b({custom_number:$.target.value}),placeholder:"e.g. 10001"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[z.field.fullName," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...h},value:e.first_name,disabled:u,onChange:$=>b({first_name:$.target.value}),placeholder:"Full name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:z.field.username}),t.jsx("input",{style:{...A,...h},value:e.username,disabled:u,onChange:$=>b({username:$.target.value}),placeholder:"Username"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:z.field.phoneNumber}),t.jsx("input",{style:{...A,...h},value:e.mobile_no,disabled:u,onChange:$=>b({mobile_no:$.target.value}),placeholder:"Phone number"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[z.field.emailAddress," ",k&&t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...u||!k?{background:"#f8fafc"}:{}},value:e.email,disabled:u||!k,onChange:$=>b({email:$.target.value}),placeholder:"user@example.com",type:"email",required:k})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:z.field.category}),t.jsxs("select",{style:{...A,...h},value:e.custom_category,disabled:u,onChange:$=>b({custom_category:$.target.value}),children:[t.jsx("option",{value:"",children:z.field.select}),t.jsx("option",{children:"Admin"}),t.jsx("option",{children:"Chairman"}),t.jsx("option",{children:"Auditor"}),t.jsx("option",{children:"X-Auditor"}),t.jsx("option",{children:"Manager"}),t.jsx("option",{children:"Employee"})]})]})]})})]})}const Ru={Active:F.green,Closed:F.gray};function C1({cycles:e,canModify:n,onView:s,onEdit:l,onDelete:r}){const a=ne(),[i,c]=C.useState(new Set),[u,g]=C.useState(""),[j,y]=C.useState(""),[p,x]=C.useState("all"),w=C.useMemo(()=>[...new Set(e.map(b=>b.organization).filter(Boolean))],[e]),v=C.useMemo(()=>e.filter(b=>{const h=(b.name1||b.name||"").toLowerCase();return!(u&&!h.includes(u.toLowerCase())||j&&b.organization!==j||p!=="all"&&b.status!==p)}),[e,u,j,p]),[S,m]=C.useState(1);C.useEffect(()=>{m(1)},[u,j,p]);const o=v.slice((S-1)*ae,S*ae),d=b=>{const h=e.filter(P=>i.has(P.name)),k=Me.cycles,I=k.columns.filter(P=>k.defaultColumns.includes(P.key));b==="csv"?He(I,h,"cycles_selected"):Ge(I,h,"cycles_selected")},f=v.filter(b=>b.status==="Active").length,z=v.filter(b=>b.status==="Closed").length;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Ie,{label:"Total",val:v.length,color:F.teal}),t.jsx(Ie,{label:"Active",val:f,color:F.green}),t.jsx(Ie,{label:"Closed",val:z,color:F.gray})]}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:u,onChange:g,placeholder:"Search by name…"},{type:"select",label:a.col.organization,value:j,onChange:y,options:[{value:"",label:"All Organizations"},...w.map(b=>({value:b,label:b}))]},{type:"select",label:"Status",value:p,onChange:x,options:[{value:"all",label:"All"},{value:"Active",label:"Active"},{value:"Closed",label:"Closed"}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:o.length>0&&o.every(b=>i.has(b.name)),onChange:b=>{if(b.target.checked)c(new Set([...i,...o.map(h=>h.name)]));else{const h=new Set(i);o.forEach(k=>h.delete(k.name)),c(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.name}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.organization}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.frequency}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.startDate}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.endDate}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.status}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.actions})]})}),t.jsx("tbody",{children:v.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:8,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):o.map((b,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(b),style:{borderTop:"1px solid #f0f0f0",background:i.has(b.name)?"#eff6ff":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:k=>k.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:i.has(b.name),onChange:()=>{const k=new Set(i);k.has(b.name)?k.delete(b.name):k.add(b.name),c(k)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:b.name1||b.name}),t.jsx("td",{style:{padding:"10px 14px"},children:b.organization||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:b.frequency||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:b.start_date||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:b.end_date||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{padding:"3px 10px",borderRadius:12,fontSize:12,background:Ru[b.status]+"22",color:Ru[b.status]||"#666"},children:b.status})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:k=>k.stopPropagation(),children:t.jsx(at,{onView:()=>s==null?void 0:s(b),onEdit:n&&l?()=>l(b):void 0,onDelete:n&&r?()=>r(b.name):void 0})})]},b.name))})]})}),t.jsx(Je,{count:i.size,onClear:()=>c(new Set),onExport:d}),t.jsx(qe,{page:S,total:v.length,onPageChange:m})]})}const z1=["Weekly","Bi-weekly","Monthly","Quarterly","Annually"],I1=["Active","Closed"];function E1({form:e,setForm:n,organizations:s,formStatus:l,viewMode:r,onEdit:a,darkMode:i,notifCount:c,onToggleDark:u,onCountChange:g,onViewProfile:j,onSubmit:y,onBack:p,onNavigate:x,onLogout:w,user:v}){const S=ne(),m=f=>n(z=>({...z,...f})),o=r?{background:"#f8fafc"}:{},d=e.name?r?`${S.formTitle.editCycle}: ${e.name1||e.name}`:S.formTitle.editCycle:S.formTitle.newCycle;return t.jsx(Ze,{title:d,activePage:"cycles",user:v,formStatus:l,buttonText:S.saveCycle,buttonColor:"#16a34a",viewMode:r,onEdit:a,darkMode:i,notifCount:c,onToggleDark:u,onCountChange:g,onViewProfile:j,onSubmit:y,onBack:p,onNavigate:x,onLogout:w,children:t.jsx(re,{title:"Cycle Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[S.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...o},value:e.name1||"",disabled:r||!!e.name,onChange:f=>m({name1:f.target.value}),placeholder:"e.g. Q1-2026"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[S.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.organization,onChange:f=>m({organization:f}),organizations:s,disabled:r||!!v.custom_organization})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.col.frequency}),t.jsx(pe,{value:e.frequency,onChange:f=>m({frequency:f}),items:z1.map(f=>({name:f,label:f})),placeholder:"-- Select Frequency --",disabled:r})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.status}),t.jsx(pe,{value:e.status,onChange:f=>m({status:f}),items:I1.map(f=>({name:f,label:f})),placeholder:"-- Select Status --",disabled:r})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.dateStart}),t.jsx(xe,{value:e.start_date||"",onChange:f=>m({start_date:f}),disabled:r,style:{...A,...o}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.dateEnd}),t.jsx(xe,{value:e.end_date||"",onChange:f=>m({end_date:f}),disabled:r,style:{...A,...o}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.updateWindowDays}),t.jsx("input",{type:"number",min:1,max:30,style:{...A,...o},value:e.update_window_days??2,disabled:r,onChange:f=>m({update_window_days:parseInt(f.target.value)||2})}),t.jsx("span",{style:{fontSize:11,color:"#64748b",display:"block",marginTop:4},children:"Grace period before Unknown is auto-assigned"})]})]})})})}function T1({kpiInputs:e,canModify:n,onView:s,onEdit:l,onDelete:r}){const a=ne(),[i,c]=C.useState(new Set),[u,g]=C.useState(""),[j,y]=C.useState(""),p=C.useMemo(()=>[...new Set(e.map(o=>o.organization).filter(Boolean))],[e]),x=C.useMemo(()=>e.filter(o=>{const d=[o.organization,o.period].filter(Boolean).join(" ").toLowerCase();return!(u&&!d.includes(u.toLowerCase())||j&&o.organization!==j)}),[e,u,j]),[w,v]=C.useState(1);C.useEffect(()=>{v(1)},[u,j]);const S=x.slice((w-1)*ae,w*ae),m=o=>{const d=e.filter(b=>i.has(b.name)),f=Me["kpi-input"],z=f.columns.filter(b=>f.defaultColumns.includes(b.key));o==="csv"?He(z,d,"kpi_input_selected"):Ge(z,d,"kpi_input_selected")};return t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total Records",val:x.length,color:F.blue})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:u,onChange:g,placeholder:"Organization or period…"},{type:"select",label:a.col.organization,value:j,onChange:y,options:[{value:"",label:"All Organizations"},...p.map(o=>({value:o,label:o}))]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:S.length>0&&S.every(o=>i.has(o.name)),onChange:o=>{if(o.target.checked)c(new Set([...i,...S.map(d=>d.name)]));else{const d=new Set(i);S.forEach(f=>d.delete(f.name)),c(d)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.organization}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.period}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.field.revenue_growth}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.field.net_profit}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.dash.customerSat}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:a.col.actions})]})}),t.jsx("tbody",{children:x.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):S.map((o,d)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:i.has(o.name)?"#eff6ff":d%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:f=>f.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:i.has(o.name),onChange:()=>{const f=new Set(i);f.has(o.name)?f.delete(o.name):f.add(o.name),c(f)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.organization||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:o.period||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:o.revenue_growth!=null?`${o.revenue_growth}%`:"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:o.net_profit!=null?o.net_profit.toLocaleString():"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:o.customer_satisfaction!=null?o.customer_satisfaction:"—"}),t.jsx("td",{style:{padding:"8px 14px"},onClick:f=>f.stopPropagation(),children:t.jsx(at,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Je,{count:i.size,onClear:()=>c(new Set),onExport:m}),t.jsx(qe,{page:w,total:x.length,onPageChange:v})]})}function P1({form:e,setForm:n,organizations:s,formStatus:l,viewMode:r,onEdit:a,darkMode:i,notifCount:c,onToggleDark:u,onCountChange:g,onViewProfile:j,onSubmit:y,onBack:p,onNavigate:x,onLogout:w,user:v}){const S=ne(),m=z=>n(b=>({...b,...z})),o=r?{background:"#f8fafc"}:{},d=z=>b=>m({[z]:parseFloat(b.target.value)||0}),f=e.name?r?`${S.formTitle.editKpi}: ${e.period||e.name}`:S.formTitle.editKpi:S.formTitle.newKpi;return t.jsxs(Ze,{title:f,activePage:"kpi-input",user:v,formStatus:l,buttonText:S.saveKpi,buttonColor:"#16a34a",viewMode:r,onEdit:a,darkMode:i,notifCount:c,onToggleDark:u,onCountChange:g,onViewProfile:j,onSubmit:y,onBack:p,onNavigate:x,onLogout:w,children:[t.jsx(re,{title:"Period & Organization",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[S.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.organization,onChange:z=>m({organization:z}),organizations:s,disabled:r||!!v.custom_organization})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[S.col.period," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...o},value:e.period||"",disabled:r,onChange:z=>m({period:z.target.value}),placeholder:"e.g. Q1 2026"})]})]})}),t.jsx(re,{title:"Financial KPIs",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.revenue_growth}),t.jsx("input",{type:"number",step:"0.01",style:{...A,...o},value:e.revenue_growth||"",disabled:r,onChange:d("revenue_growth")})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.net_profit}),t.jsx("input",{type:"number",step:"0.01",style:{...A,...o},value:e.net_profit||"",disabled:r,onChange:d("net_profit")})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.cash_flow}),t.jsx("input",{type:"number",step:"0.01",style:{...A,...o},value:e.cash_flow||"",disabled:r,onChange:d("cash_flow")})]})]})}),t.jsx(re,{title:"Operational KPIs",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.strategic_goal_pct}),t.jsx("input",{type:"number",step:"0.01",style:{...A,...o},value:e.strategic_goal_pct||"",disabled:r,onChange:d("strategic_goal_pct")})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.customer_satisfaction}),t.jsx("input",{type:"number",step:"0.01",style:{...A,...o},value:e.customer_satisfaction||"",disabled:r,onChange:d("customer_satisfaction")})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.employee_turnover_pct}),t.jsx("input",{type:"number",step:"0.01",style:{...A,...o},value:e.employee_turnover_pct||"",disabled:r,onChange:d("employee_turnover_pct")})]})]})}),t.jsx(re,{title:"Safety & Compliance",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.open_safety_incidents}),t.jsx("input",{type:"number",min:0,style:{...A,...o},value:e.open_safety_incidents||"",disabled:r,onChange:z=>m({open_safety_incidents:parseInt(z.target.value)||0})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:S.field.compliance_score}),t.jsx("input",{type:"number",step:"0.01",style:{...A,...o},value:e.compliance_score||"",disabled:r,onChange:d("compliance_score")})]})]})})]})}const A1={incident_initial_evaluation:"Incident Initial Evaluation",idea_initial_evaluation:"Idea Initial Evaluation"},Du={Pending:F.orange,Accepted:F.green,Rejected:F.red,Revoked:F.gray};function R1(e){if(!e)return"—";const n=new Date(e);return isNaN(n.getTime())?"—":`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function D1(e){const n=[];return e.incident_initial_evaluation&&n.push("incident_initial_evaluation"),e.idea_initial_evaluation&&n.push("idea_initial_evaluation"),n}function L1({delegations:e,organizations:n,userRole:s,currentUser:l,onView:r,onRevoke:a}){const i=ne(),[c,u]=C.useState(new Set),[g,j]=C.useState(""),[y,p]=C.useState(""),[x,w]=C.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},S=C.useMemo(()=>e.filter(h=>{const k=`${h.auditor} ${h.manager}`.toLowerCase();return!(g&&!k.includes(g.toLowerCase())||y&&h.organization!==y||x!=="all"&&h.status!==x)}),[e,g,y,x]),[m,o]=C.useState(1);C.useEffect(()=>{o(1)},[g,y,x]);const d=S.slice((m-1)*ae,m*ae),f=h=>{const k=e.filter(M=>c.has(M.name)),I=Me.delegations,P=I.columns.filter(M=>I.defaultColumns.includes(M.key));h==="csv"?He(P,k,"delegations_selected"):Ge(P,k,"delegations_selected")},z=S.filter(h=>h.status==="Pending").length,b=S.filter(h=>h.status==="Accepted").length;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Ie,{label:"Total",val:S.length,color:F.purple}),t.jsx(Ie,{label:"Pending",val:z,color:F.orange}),t.jsx(Ie,{label:"Accepted",val:b,color:F.green})]}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:g,onChange:j,placeholder:"Auditor or Manager…"},{type:"select",label:i.col.organization,value:y,onChange:p,options:[{value:"",label:"All Organizations"},...n.map(h=>({value:h.organization_name||h.name,label:h.organization_name||h.name}))]},{type:"select",label:"Status",value:x,onChange:w,options:[{value:"all",label:"All"},{value:"Pending",label:"Pending"},{value:"Accepted",label:"Accepted"},{value:"Rejected",label:"Rejected"},{value:"Revoked",label:"Revoked"}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:d.length>0&&d.every(h=>c.has(h.name)),onChange:h=>{if(h.target.checked)u(new Set([...c,...d.map(k=>k.name)]));else{const k=new Set(c);d.forEach(I=>k.delete(I.name)),u(k)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:v,children:i.col.number}),t.jsx("th",{style:v,children:i.col.auditor}),t.jsx("th",{style:v,children:i.col.manager}),t.jsx("th",{style:v,children:i.col.organization}),t.jsx("th",{style:v,children:i.col.functions}),t.jsx("th",{style:v,children:i.col.status}),t.jsx("th",{style:v,children:i.col.requestedOn}),t.jsx("th",{style:v,children:i.col.actions})]})}),t.jsx("tbody",{children:S.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:9,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):d.map((h,k)=>{const I=!!a&&(h.status==="Pending"||h.status==="Accepted")&&(s==="Admin"||h.auditor===l);return t.jsxs("tr",{className:"app-table-row",onClick:()=>r==null?void 0:r(h),style:{borderTop:"1px solid #f0f0f0",background:c.has(h.name)?"#eff6ff":k%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:P=>P.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:c.has(h.name),onChange:()=>{const P=new Set(c);P.has(h.name)?P.delete(h.name):P.add(h.name),u(P)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.number||h.name}),t.jsx("td",{style:{padding:"10px 14px"},children:h.auditor}),t.jsx("td",{style:{padding:"10px 14px"},children:h.manager}),t.jsx("td",{style:{padding:"10px 14px"},children:h.organization||"All Organizations"}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:D1(h).map(P=>t.jsx("span",{style:{background:"#ede9fe",color:"#6d28d9",padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600},children:A1[P]||P},P))})}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{background:(Du[h.status]||F.gray)+"22",color:Du[h.status]||F.gray,padding:"3px 10px",borderRadius:12,fontSize:12,fontWeight:700},children:h.status})}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:R1(h.requested_on)}),t.jsx("td",{style:{padding:"8px 14px"},onClick:P=>P.stopPropagation(),children:t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("button",{onClick:()=>r==null?void 0:r(h),title:"View",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#e0f7fa",color:"#0891b2"},children:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),I&&t.jsx("button",{onClick:()=>a==null?void 0:a(h.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"})]})})]},h.name)})})]})}),t.jsx(Je,{count:c.size,onClear:()=>u(new Set),onExport:f}),t.jsx(qe,{page:m,total:S.length,onPageChange:o})]})}const Lu={Pending:F.orange,Accepted:F.green,Rejected:F.red,Revoked:F.gray};function O1(e){if(!e)return"—";const n=new Date(e);return isNaN(n.getTime())?"—":n.toLocaleString()}function N1({form:e,setForm:n,organizations:s,users:l,userRoleMap:r,formStatus:a,viewMode:i,onEdit:c,darkMode:u,notifCount:g,onToggleDark:j,onCountChange:y,onViewProfile:p,onSubmit:x,onBack:w,onNavigate:v,onLogout:S,user:m}){var h;const o=ne(),d=k=>n(I=>({...I,...k})),f=i?{background:"#f8fafc"}:{},z=Cl(l,r,"SB Manager",e.organization).filter(k=>k.name!==(e.auditor||m.name)).map(k=>({name:k.name,label:k.full_name||k.name})),b=e.name?`${o.formTitle.viewDelegation}${e.number||e.name}`:o.formTitle.newDelegation;return t.jsxs(Ze,{title:b,activePage:"delegations",user:m,formStatus:a,statusBadge:e.status?t.jsx("span",{style:{background:(Lu[e.status]||F.gray)+"22",color:Lu[e.status]||F.gray,padding:"4px 12px",borderRadius:14,fontSize:13,fontWeight:700},children:e.status}):void 0,buttonText:o.saveDelegation,buttonColor:"#16a34a",viewMode:i,onEdit:c,darkMode:u,notifCount:g,onToggleDark:j,onCountChange:y,onViewProfile:p,onSubmit:x,onBack:w,onNavigate:v,onLogout:S,children:[t.jsxs(re,{title:"Delegation Information",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:o.col.auditor}),t.jsx("input",{style:{...A,background:"#f8fafc",fontWeight:600,color:"#334155"},value:e.auditor||m.name,disabled:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[o.col.manager," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(pe,{value:e.manager,onChange:k=>d({manager:k}),items:z,placeholder:"-- Select Manager --",disabled:i})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:o.col.organization}),t.jsx(Gt,{value:e.organization,onChange:k=>d({organization:k}),organizations:s,placeholder:"-- All Organizations --",disabled:i})]})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[o.col.functions," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsxs("div",{style:{display:"flex",gap:20,marginTop:6,flexWrap:"wrap"},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:i?"default":"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",style:zl,checked:!!e.incident_initial_evaluation,disabled:i,onChange:k=>d({incident_initial_evaluation:k.target.checked?1:0})}),t.jsx("span",{children:"Initial Evaluation (Events / Incidents)"})]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:i?"default":"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",style:zl,checked:!!e.idea_initial_evaluation,disabled:i,onChange:k=>d({idea_initial_evaluation:k.target.checked?1:0})}),t.jsx("span",{children:"Initial Evaluation (Ideas)"})]})]})]}),!i&&t.jsxs("div",{style:{marginTop:14},children:[t.jsx("label",{style:E,children:"Remarks"}),t.jsx("textarea",{style:{...A,...f,minHeight:70,resize:"vertical"},value:e.remarks||"",onChange:k=>d({remarks:k.target.value}),placeholder:"Optional note for the Manager…"})]})]}),i&&(((h=e.delegation_log)==null?void 0:h.length)??0)>0&&t.jsx(re,{title:"Audit Trail",children:t.jsx("div",{style:{overflowX:"auto"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc"},children:[t.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Action"}),t.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Actor"}),t.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Timestamp"}),t.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Remarks"})]})}),t.jsx("tbody",{children:(e.delegation_log||[]).map((k,I)=>t.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"8px 12px",fontWeight:600,color:"#334155"},children:k.action}),t.jsx("td",{style:{padding:"8px 12px",color:"#334155"},children:k.actor}),t.jsx("td",{style:{padding:"8px 12px",color:"#64748b"},children:O1(k.timestamp)}),t.jsx("td",{style:{padding:"8px 12px",color:"#64748b"},children:k.remarks||"—"})]},k.name||I))})]})})})]})}const Ou={process:"processes-form",order:"orders-form",incident:"incidents-form",idea:"ideas-form"},Gl={process:F.blue,order:F.purple,incident:F.red,idea:F.green,delegation:F.orange},Nu={process:"🔄",order:"📦",incident:"🚨",idea:"💡",delegation:"🤝"};function Kl(e,n){const s=e.replace("#",""),l=parseInt(s.substring(0,2),16),r=parseInt(s.substring(2,4),16),a=parseInt(s.substring(4,6),16);return`rgba(${l}, ${r}, ${a}, ${n})`}function W1({onNavigate:e,onRefresh:n}){const s=ne(),[l,r]=C.useState([]),[a,i]=C.useState(!0),[c,u]=C.useState(""),[g,j]=C.useState(""),y=()=>My().then(m=>{r(m),i(!1)});C.useEffect(()=>{y()},[]);const p=l.filter(m=>m.requires_action),x=l.filter(m=>!m.requires_action),w={};for(const m of l)w[m.type]=(w[m.type]||0)+1;const v=async(m,o)=>{u(m),j("");try{await Gy(m,o),await y(),n==null||n()}catch{j(m)}u("")};function S(m,o,d){return o.length===0?null:t.jsxs("div",{style:{marginBottom:28},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:14},children:[t.jsx("span",{style:{fontSize:12,fontWeight:800,letterSpacing:.6,textTransform:"uppercase",color:d?F.accent:"#8a8fa3"},children:m}),t.jsx("span",{style:{fontSize:11,fontWeight:700,minWidth:22,textAlign:"center",padding:"2px 7px",borderRadius:999,color:d?"white":"#6b7280",background:d?F.accent:"#e9eaf2"},children:o.length}),t.jsx("div",{style:{flex:1,height:1,background:"linear-gradient(90deg, #e6e7f0, transparent)"}})]}),t.jsx("div",{className:"inbox-card-grid",children:o.map((f,z)=>{const b=f.type!=="delegation",h=Gl[f.type]||F.gray;return t.jsxs("div",{className:"inbox-card",onClick:b?()=>e(Ou[f.type],f.name):void 0,style:{borderTop:`3px solid ${h}`,cursor:b?"pointer":"default"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:14},children:[t.jsx("div",{style:{width:38,height:38,borderRadius:12,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:17,background:Kl(h,.14)},children:Nu[f.type]||"📌"}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx("span",{style:{fontWeight:700,fontSize:13,color:h,letterSpacing:.3},children:f.number}),f.requires_action&&t.jsx("span",{style:{fontSize:10,fontWeight:700,color:F.red,background:Kl(F.red,.12),padding:"1px 7px",borderRadius:999,textTransform:"uppercase",letterSpacing:.4},children:"Action"})]}),t.jsx("div",{className:"inbox-card-title",style:{fontSize:14,fontWeight:600,marginTop:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.title}),t.jsxs("div",{className:"inbox-card-meta",style:{marginTop:5,fontSize:12},children:[f.action,f.organization&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{opacity:.5},children:" · "}),f.organization]}),f.date&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{opacity:.5},children:" · "}),f.date]})]}),g===f.name&&t.jsx("div",{style:{marginTop:6,fontSize:12,color:F.red,fontWeight:600},children:"Failed to respond — please try again."})]})]}),f.type==="delegation"?t.jsxs("div",{style:{display:"flex",gap:8,marginTop:14},children:[t.jsx("button",{onClick:()=>v(f.name,"Accepted"),disabled:c===f.name,style:{flex:1,padding:"8px 0",borderRadius:9,border:"none",background:F.green,color:"white",fontWeight:700,fontSize:13,cursor:c===f.name?"wait":"pointer",opacity:c===f.name?.6:1},children:"Accept"}),t.jsx("button",{onClick:()=>v(f.name,"Rejected"),disabled:c===f.name,style:{flex:1,padding:"8px 0",borderRadius:9,border:"none",background:F.red,color:"white",fontWeight:700,fontSize:13,cursor:c===f.name?"wait":"pointer",opacity:c===f.name?.6:1},children:"Reject"})]}):t.jsx("button",{onClick:k=>{k.stopPropagation(),e(Ou[f.type],f.name)},style:{marginTop:14,width:"100%",padding:"8px 0",borderRadius:9,border:"none",background:f.requires_action?h:Kl(h,.12),color:f.requires_action?"white":h,fontWeight:700,fontSize:13,cursor:"pointer"},children:f.requires_action?"Act Now →":s.view})]},z)})})]})}return t.jsxs("div",{style:{maxWidth:1040,margin:"0 auto"},children:[!a&&l.length>0&&t.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap",marginBottom:24},children:Object.entries(w).map(([m,o])=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"6px 12px 6px 9px",borderRadius:999,background:Kl(Gl[m]||F.gray,.1),border:`1px solid ${Kl(Gl[m]||F.gray,.25)}`},children:[t.jsx("span",{style:{fontSize:13},children:Nu[m]}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:Gl[m]||F.gray,textTransform:"capitalize"},children:m}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:Gl[m]||F.gray,opacity:.7},children:o})]},m))}),a&&t.jsx("p",{style:{color:"#888"},children:s.loading}),!a&&l.length===0&&t.jsxs("div",{className:"inbox-empty",children:[t.jsx("div",{style:{fontSize:46,marginBottom:10},children:"✨"}),t.jsx("p",{style:{fontSize:16,fontWeight:600},children:s.inbox.noMessages}),t.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",p,!0),!a&&S("Informational",x,!1)]})}const B1=[{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"]}],$c={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 $1(e,n){const s=e.map(r=>$c[r]||r).join(","),l=n.map(r=>e.map(a=>`"${r[a]??""}"`).join(",")).join(`
`);return s+`
`+l}function U1(e,n){const s=new Blob([e],{type:"text/csv"}),l=URL.createObjectURL(s),r=document.createElement("a");r.href=l,r.download=n,r.click(),URL.revokeObjectURL(l)}const Wu=e=>String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");function F1(e,n,s){const l=e.map(g=>`<th style="background:#4f46e5;color:#fff;padding:6px 10px;text-align:left">${Wu($c[g]||g)}</th>`).join(""),r=n.map(g=>`<tr>${e.map(j=>`<td style="padding:4px 10px;border-bottom:1px solid #ddd">${Wu(g[j])}</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>${l}</tr></thead><tbody>${r}</tbody></table></body></html>`,i=new Blob(["\uFEFF"+a],{type:"application/vnd.ms-excel"}),c=URL.createObjectURL(i),u=document.createElement("a");u.href=c,u.download=s,u.click(),URL.revokeObjectURL(c)}const uh="report-print-area",Ki="report-print-portal";function M1(){const e=document.getElementById(uh);if(!e)return;const n=document.createElement("div");n.id=Ki,n.innerHTML=e.innerHTML,document.body.appendChild(n);const s=document.createElement("style");s.id="report-print-style",s.textContent=`
#${Ki} { display: none; }
@media print {
#root { display: none !important; }
#${Ki} { display: block !important; }
}
`,document.head.appendChild(s);const l=()=>{n.remove(),s.remove(),window.removeEventListener("afterprint",l)};window.addEventListener("afterprint",l),window.print()}const Bu={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",minWidth:180},Qi={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white"};function H1({organizations:e,userRole:n}){const s=ne(),l=B1.filter(I=>I.roles.includes(n)),[r,a]=C.useState(""),[i,c]=C.useState(""),[u,g]=C.useState(""),[j,y]=C.useState(""),[p,x]=C.useState(String(new Date().getFullYear())),[w,v]=C.useState([]),[S,m]=C.useState([]),[o,d]=C.useState(!1),[f,z]=C.useState(""),b=l.find(I=>I.id===r);async function h(){if(r){d(!0),z(""),m([]),v([]);try{const I={};i&&(I.organization=i),u&&(I.from_date=u),j&&(I.to_date=j),(b==null?void 0:b.extraFilter)==="year"&&p&&(I.year=p);const P=await Fy(r,I);v(P.columns||[]),m(P.rows||[])}catch(I){z(I.message||"Error running report")}finally{d(!1)}}}const k=(b==null?void 0:b.label)||r;return t.jsxs("div",{children:[t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12,marginBottom:20},children:l.map(I=>t.jsxs("div",{onClick:()=>a(I.id),style:{background:r===I.id?"#ebf5fb":"white",border:r===I.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:[t.jsx("div",{style:{fontWeight:700,fontSize:14,color:"#1a2332",marginBottom:4},children:I.label}),t.jsx("div",{style:{fontSize:12,color:"#888"},children:I.description})]},I.id))}),t.jsx("div",{style:{background:"white",borderRadius:12,padding:20,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:20},children:t.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",alignItems:"flex-end"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"REPORT"}),t.jsxs("select",{style:Bu,value:r,onChange:I=>a(I.target.value),children:[t.jsx("option",{value:"",children:"-- Select Report --"}),l.map(I=>t.jsx("option",{value:I.id,children:I.label},I.id))]})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"ORGANIZATION"}),t.jsxs("select",{style:Bu,value:i,onChange:I=>c(I.target.value),children:[t.jsx("option",{value:"",children:s.filter.allOrgs}),e.map(I=>t.jsx("option",{value:I.name,children:I.organization_name||I.name},I.name))]})]}),(b==null?void 0:b.extraFilter)==="year"?t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"YEAR"}),t.jsx("input",{type:"number",style:{...Qi,width:90},value:p,onChange:I=>x(I.target.value),min:2020,max:2099})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"FROM"}),t.jsx(xe,{value:u,onChange:g,style:Qi})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"TO"}),t.jsx(xe,{value:j,onChange:y,style:Qi})]})]}),t.jsx("button",{onClick:h,disabled:!r||o,style:{padding:"9px 20px",borderRadius:8,border:"none",background:F.accent,color:"white",fontWeight:700,fontSize:13,cursor:r?"pointer":"not-allowed",opacity:r?1:.5},children:o?s.loading:s.reports.generate}),S.length>0&&t.jsx("button",{onClick:()=>U1($1(w,S),`${r}.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&&t.jsx("button",{onClick:()=>F1(w,S,`${r}.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&&t.jsx("button",{onClick:M1,style:{padding:"9px 20px",borderRadius:8,border:"1px solid #888",background:"white",color:"#555",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Print / PDF"})]})}),f&&t.jsx("div",{style:{color:"#e74c3c",marginBottom:16},children:f}),S.length>0&&t.jsxs("div",{id:uh,style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto"},children:[t.jsxs("div",{style:{padding:"14px 18px",borderBottom:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{style:{fontWeight:700,color:"#333"},children:k}),t.jsxs("span",{style:{fontSize:12,color:"#888"},children:[S.length," rows"]})]}),t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsx("tr",{style:{background:"#f8f9fa"},children:w.map(I=>t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700,whiteSpace:"nowrap"},children:$c[I]||I.replace(/_/g," ").toUpperCase()},I))})}),t.jsx("tbody",{children:S.map((I,P)=>t.jsx("tr",{style:{borderTop:"1px solid #f0f0f0",background:P%2===0?"white":"#fafafa"},children:w.map(M=>t.jsx("td",{style:{padding:"10px 14px",color:"#333"},children:I[M]!=null?String(I[M]):"—"},M))},P))})]})]}),!o&&S.length===0&&r&&!f&&t.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."}),l.length===0&&t.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 Ar=()=>new Date().toISOString().split("T")[0],Uc=()=>new Date(Date.now()+30*24*60*60*1e3).toISOString().split("T")[0],G1=()=>new Date().toTimeString().slice(0,5),bn=()=>({name:"",number:"",title:"",organization:"",type:"",incident_class:"",incident_field:"",date:Ar(),time:G1(),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:""}),on=()=>({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:Ar(),priority:"",economy_class:"",product_relation:0,repeated:0,entity_scope:"",solution:"",cost:0,auditor_comment:"",sb_order:""}),cn=()=>({name:"",number:"",title:"",organization:"",type:"Buy L",management:"",department:"",section_field:"",branch:"",starting_date:Ar(),ending_date:Uc(),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:""}),sa=()=>({name:"",title:"",date_start:Ar(),date_end:Uc(),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:""}),Gs=()=>({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}),ps=()=>({name:"",organization:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),fs=()=>({name:"",custom_organization:"",department_name:"",custom_management:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),hs=()=>({name:"",organization:"",branch:"",management:"",department:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),Ks=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Qs=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ys=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Xs=()=>({name:"",name1:"",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"}),Js=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Zs=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Vs=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),la=()=>({name:"",first_name:"",full_name:"",email:"",enabled:1,creation:"",username:"",mobile_no:"",custom_organization:"",custom_management:"",custom_department:"",custom_branch:"",custom_number:"",custom_category:""}),gs=()=>({name:"",name1:"",organization:"",frequency:"Monthly",status:"Active",start_date:Ar(),end_date:Uc(),update_window_days:2}),xs=()=>({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}),Ql=()=>({name:"",number:"",auditor:"",manager:"",organization:"",incident_initial_evaluation:0,idea_initial_evaluation:0,status:"Pending",requested_on:"",remarks:""}),K1=new Set(["incidents","incidents-form","ideas","ideas-form"]),Q1=new Set(["orders","orders-form","incidents","incidents-form","ideas","ideas-form"]),Y1=new Set(eh.flatMap(({id:e})=>[e,`${e}-form`])),X1=new Set(["Admin","Owner","Auditor","Manager"]),q1=new Set(["Admin","Owner","Auditor","Manager"]),J1=new Set(["Admin","Auditor","Manager"]);function Z1({user:e,onLogout:n,darkMode:s,onToggleDark:l}){const r=ne(),a=e.role,i=X1.has(a),c=q1.has(a),u=J1.has(a),g=_=>_==="users"||_==="users-form"?a==="Admin":a==="Admin"||a==="Auditor"?!0:a==="Owner"||a==="XAuditor"?!1:a==="Manager"?!!Q1.has(_):K1.has(_),j=_=>a==="Employee"&&!!_&&_!=="New",y=i?"dashboard":"inbox",p=_=>_==="dashboard"?i:_==="reports"?c:_==="delegations"||_==="delegations-form"?u:_==="users"||_==="users-form"?a==="Admin":Y1.has(_)?a==="Admin"||a==="Auditor":!0,[x,w]=C.useState(()=>{const _=n0(_u());return _&&p(_)?_:y});C.useEffect(()=>{const _=s0(x);window.location.hash!==_&&window.history.pushState(null,"",_)},[x]),C.useEffect(()=>{const _=()=>{const H=_u();w(H&&p(H)?H:y)};return window.addEventListener("popstate",_),()=>window.removeEventListener("popstate",_)},[]);const v=e.custom_organization||"",[S,m]=C.useState(""),[o,d]=C.useState("");C.useEffect(()=>{if(!o)return;const _=setTimeout(()=>d(""),0);return()=>clearTimeout(_)},[o]);const f=(_,H)=>{d(H),w(_)},[z,b]=C.useState(0),[h,k]=C.useState([]),[I,P]=C.useState([]),[M,ee]=C.useState([]),[W,$]=C.useState([]),[T,D]=C.useState([]),[Q,Y]=C.useState([]),[X,q]=C.useState([]),[N,Z]=C.useState([]),[ce,me]=C.useState([]),[le,Ve]=C.useState([]),[ct,K]=C.useState([]),[oe,Oe]=C.useState([]),[ve,nn]=C.useState([]),[fe,je]=C.useState([]),[Et,Ne]=C.useState([]),[L,se]=C.useState([]),[R,We]=C.useState([]),[ft,U]=C.useState([]),[Be,ui]=C.useState([]),[hn,Rr]=C.useState({}),[B,Tt]=C.useState([]),[gn,An]=C.useState([]),[Fc,ph]=C.useState([]),[Mc,fh]=C.useState([]),[Hc,hh]=C.useState([]),[pi,gh]=C.useState({}),[fi,xh]=C.useState([]),Dr=()=>({name:"",company_name:"",acronym:"",code:"",status:"Active",owner_user:"",notes:""}),[Gc,Rs]=C.useState(Dr()),[_e,he]=C.useState(!0),[Ke,ie]=C.useState("idle"),[Qe,te]=C.useState(!1),[Kc,Qc]=C.useState(!1),[Lr,Yc]=C.useState(null),[mh,yh]=C.useState(()=>localStorage.getItem("sb_sidebar")==="1"),vh=()=>yh(_=>{const H=!_;return localStorage.setItem("sb_sidebar",H?"1":"0"),H}),[jh,hi]=C.useState(!1);C.useEffect(()=>{hi(!1)},[x]);const[xn,mn]=C.useState(bn()),[yn,sn]=C.useState(on()),[ls,ln]=C.useState(cn()),[rs,rn]=C.useState(sa()),[Xc,Ds]=C.useState(Gs()),[qc,as]=C.useState(ps()),[Jc,is]=C.useState(fs()),[Zc,os]=C.useState(hs()),[Vc,Ls]=C.useState(Ks()),[ed,Os]=C.useState(Qs()),[td,Ns]=C.useState(Ys()),[nd,Ws]=C.useState(Xs()),[sd,Bs]=C.useState(qs()),[ld,$s]=C.useState(Js()),[rd,Us]=C.useState(Zs()),[ad,Fs]=C.useState(Vs()),[Al,Or]=C.useState(la()),[id,cs]=C.useState(gs()),[od,ds]=C.useState(xs()),[Ms,Rl]=C.useState(Ql()),Pt=async()=>{he(!0);try{const[_,H,we,Kt,Rn,Ae,yi,gg,xg,mg,yg,vg,jg,bg,Sg,wg,kg,_g,Cg,zg,Ig,Eg,Tg,Pg,Ag,Rg,Dg]=await Promise.all([Te(O.incidents),Te(O.organizations),Te(O.ideas),Te(O.orders),Te(O.processes),ky(),Te(O.managements),Te(O.departments),Te(O.branches),Te(O.incidentTypes),Te(O.incidentClass),Te(O.incidentField),Te(O.ideaTypes),Te(O.orderTypes),Te(O.processTypes),Te(O.incidentStatuses),Te(O.ideaStatuses),Te(O.orderStatuses),Te(O.processStatuses),Iy(),Ey(),Te(O.cycles),Te(O.kpiInput),Qy(),Xy(),qy(),Jy()]);k(_||[]),P(H||[]),ee(we||[]),$(Kt||[]),D(Rn||[]),Tt(Ae||[]),Y(yi||[]),q(gg||[]),Z(xg||[]),me(mg||[]),Ve(yg||[]),K(vg||[]),Oe(jg||[]),nn(bg||[]),je(Sg||[]),Ne(wg||[]),se(kg||[]),We(_g||[]),U(Cg||[]),ui(zg||[]),Rr(Ig||{}),An(Eg||[]),ph(Tg||[]),fh(Pg||[]),hh(Ag||[]),gh(Rg||{}),xh(Dg||[])}catch(_){console.error("Error loading data:",_)}he(!1)},cd=async()=>{try{const _=await fetch("/api/method/sidrah_business.api.get_notification_count",{credentials:"include",headers:{Accept:"application/json"}});if(_.ok){const H=await _.json();b(Number(H.message)||0)}}catch{}};C.useEffect(()=>{Pt(),cd();const _=setInterval(cd,6e4);return()=>clearInterval(_)},[e.name]);const[ht,vn]=C.useState({isOpen:!1,doctype:"",name:"",title:"",isDeleting:!1}),Ee=(_,H,we)=>{vn({isOpen:!0,doctype:_,name:H,title:we||H,isDeleting:!1})},dd=_=>{const we={[O.incidents]:"incidents",[O.ideas]:"ideas",[O.orders]:"orders",[O.processes]:"processes",[O.organizations]:"organizations",[O.managements]:"managements",[O.departments]:"departments",[O.branches]:"branches",[O.cycles]:"cycles",[O.kpiInput]:"kpi-input",[O.incidentTypes]:"incident-types",[O.ideaTypes]:"idea-types",[O.orderTypes]:"order-types",[O.processTypes]:"process-types",[O.incidentStatuses]:"incident-statuses",[O.ideaStatuses]:"idea-statuses",[O.orderStatuses]:"order-statuses",[O.processStatuses]:"process-statuses",[O.groupCompanies]:"group-companies"}[_];we&&w(we)},ud=async _=>{vn(H=>({...H,isDeleting:!0}));try{const H=ht.doctype;await Fo(ht.doctype,ht.name,_,!1),vn(we=>({...we,isOpen:!1,isDeleting:!1})),await Pt(),x.endsWith("-form")&&dd(H)}catch(H){console.error("Delete error:",H),alert((H==null?void 0:H.message)||"Delete failed. Please try again."),vn(we=>({...we,isDeleting:!1}))}},pd=async _=>{vn(H=>({...H,isDeleting:!0}));try{const H=ht.doctype;await Fo(ht.doctype,ht.name,_,!0),vn(we=>({...we,isOpen:!1,isDeleting:!1})),await Pt(),x.endsWith("-form")&&dd(H)}catch(H){console.error("Permanent delete error:",H),alert((H==null?void 0:H.message)||"Permanent delete failed. Please try again."),vn(we=>({...we,isDeleting:!1}))}},Dl=async(_,H)=>{if(window.confirm(r.rtl?"هل أنت متأكد من استعادة هذا السجل؟":"Are you sure you want to restore this record?")){he(!0);try{await wy(_,H),alert(r.restoredOk||"Record restored successfully!"),await Pt()}catch(we){console.error("Restore error:",we),alert((we==null?void 0:we.message)||"Restore failed. Please try again.")}he(!1)}},bh=async _=>{try{await Ry(_),await Pt()}catch(H){console.error("Disable user error:",H)}},Sh=async _=>{te(!0),he(!0);try{const H=await At(O.incidents,_.name);mn({...bn(),...H})}catch{mn({...bn(),..._})}w("incidents-form"),he(!1)},wh=async _=>{te(!0),he(!0);try{const H=await At(O.ideas,_.name);sn({...on(),...H})}catch{sn({...on(),..._})}w("ideas-form"),he(!1)},kh=async _=>{te(!0),he(!0);try{const H=await At(O.orders,_.name);ln({...cn(),...H})}catch{ln({...cn(),..._})}w("orders-form"),he(!1)},_h=async _=>{te(!0),he(!0);try{const H=await Zl(_.name);rn({...H,progress_indicators:H.progress_indicators||[],cycle_logs:H.cycle_logs||[]}),w("processes-form")}catch{rn({..._,progress_indicators:_.progress_indicators||[]}),w("processes-form")}he(!1)},Ch=_=>Se(O.organizations,_,Ds,Gs(),"organizations-form",!0),zh=_=>{te(!0),Rs(_),w("group-companies-form")},Ih=_=>{te(!1),Rs(_),w("group-companies-form")},Eh=async _=>{te(!0),he(!0);try{const H=await At(O.managements,_.name);as({...ps(),...H})}catch{as({...ps(),..._})}w("managements-form"),he(!1)},Th=async _=>{te(!0),he(!0);try{const H=await At(O.departments,_.name);is({...fs(),...H})}catch{is({...fs(),..._})}w("departments-form"),he(!1)},Ph=async _=>{te(!0),he(!0);try{const H=await At(O.branches,_.name);os({...hs(),...H})}catch{os({...hs(),..._})}w("branches-form"),he(!1)},Ah=async _=>{te(!0),he(!0);try{const H=await At(O.cycles,_.name);cs({...gs(),...H})}catch{cs({...gs(),..._})}w("cycles-form"),he(!1)},Rh=async _=>{te(!0),he(!0);try{const H=await At(O.kpiInput,_.name);ds({...xs(),...H})}catch{ds({...xs(),..._})}w("kpi-input-form"),he(!1)},st=async(_,H,we,Kt,Rn)=>{ie("loading");try{if(H.name)await Ma(_,H.name,H),ie("success"),Pt(),setTimeout(()=>{ie("idle"),w(Kt)},1500);else if(Rn){const Ae=await Gi(_,H);Rn((Ae==null?void 0:Ae.data)??Ae),ie("success"),Pt(),setTimeout(()=>ie("idle"),1500)}else await Gi(_,H),we(),ie("success"),Pt(),setTimeout(()=>{ie("idle"),w(Kt)},1500)}catch(Ae){console.error("Submit error:",Ae),ie(Ae instanceof Error?Ae.message:"Error saving. Please try again.")}},$e=async()=>{await Cy(),n()},Se=async(_,H,we,Kt,Rn,Ae)=>{te(Ae),he(!0);try{const yi=await At(_,H.name);we({...Kt,...yi})}catch{we({...Kt,...H})}w(Rn),he(!1)},Dh=_=>Se(O.incidents,_,mn,bn(),"incidents-form",!1),Lh=_=>Se(O.ideas,_,sn,on(),"ideas-form",!1),Oh=_=>Se(O.orders,_,ln,cn(),"orders-form",!1),Nh=_=>{te(!1),he(!0),Zl(_.name).then(H=>{rn({...H,progress_indicators:H.progress_indicators||[],cycle_logs:H.cycle_logs||[]})}).catch(()=>{rn({..._,progress_indicators:_.progress_indicators||[]})}).finally(()=>{w("processes-form"),he(!1)})},Wh=_=>Se(O.organizations,_,Ds,Gs(),"organizations-form",!1),Bh=_=>Se(O.managements,_,as,ps(),"managements-form",!1),$h=_=>Se(O.departments,_,is,fs(),"departments-form",!1),Uh=_=>Se(O.branches,_,os,hs(),"branches-form",!1),Fh=_=>Se(O.cycles,_,cs,gs(),"cycles-form",!1),Mh=_=>Se(O.kpiInput,_,ds,xs(),"kpi-input-form",!1),Hh=async _=>{te(!0),he(!0);try{const H=await Yy(_.name);Rl({...Ql(),...H})}catch{Rl({...Ql(),..._})}w("delegations-form"),he(!1)},Gh=async()=>{ie("loading");try{const _=[];Ms.incident_initial_evaluation&&_.push("incident_initial_evaluation"),Ms.idea_initial_evaluation&&_.push("idea_initial_evaluation"),await Hy(Ms.manager,_,Ms.organization,Ms.remarks),Rl(Ql()),ie("success"),Pt(),setTimeout(()=>{ie("idle"),w("delegations")},1500)}catch(_){console.error("Delegation submit error:",_),ie(_ instanceof Error?_.message:"Error saving. Please try again.")}},Kh=async _=>{if(window.confirm(r.rtl?"هل أنت متأكد من إلغاء هذا التفويض؟":"Are you sure you want to revoke this delegation?")){he(!0);try{await Ky(_),await Pt()}catch(H){console.error("Revoke delegation error:",H),alert(H instanceof Error?H.message:"Revoke failed. Please try again.")}he(!1)}},Qh=_=>Se(O.incidentTypes,_,Ls,Ks(),"incident-types-form",!0),Yh=_=>Se(O.incidentTypes,_,Ls,Ks(),"incident-types-form",!1),Xh=_=>Se(O.ideaTypes,_,Os,Qs(),"idea-types-form",!0),qh=_=>Se(O.ideaTypes,_,Os,Qs(),"idea-types-form",!1),Jh=_=>Se(O.orderTypes,_,Ns,Ys(),"order-types-form",!0),Zh=_=>Se(O.orderTypes,_,Ns,Ys(),"order-types-form",!1),Vh=_=>Se(O.processTypes,_,Ws,Xs(),"process-types-form",!0),eg=_=>Se(O.processTypes,_,Ws,Xs(),"process-types-form",!1),tg=_=>Se(O.incidentStatuses,_,Bs,qs(),"incident-statuses-form",!0),ng=_=>Se(O.incidentStatuses,_,Bs,qs(),"incident-statuses-form",!1),sg=_=>Se(O.ideaStatuses,_,$s,Js(),"idea-statuses-form",!0),lg=_=>Se(O.ideaStatuses,_,$s,Js(),"idea-statuses-form",!1),rg=_=>Se(O.orderStatuses,_,Us,Zs(),"order-statuses-form",!0),ag=_=>Se(O.orderStatuses,_,Us,Zs(),"order-statuses-form",!1),ig=_=>Se(O.processStatuses,_,Fs,Vs(),"process-statuses-form",!0),og=_=>Se(O.processStatuses,_,Fs,Vs(),"process-statuses-form",!1),cg=async _=>{Yc(_),w("profile")},dg=_=>{te(!1),Qc(!1),Or({...la(),..._}),w("users-form")},ug=async()=>{ie("loading");try{if(!Al.name){const H=await Gi("User",{...Al,send_welcome_email:0,user_type:"System User"});Or({...la(),...Al,...(H==null?void 0:H.data)??H}),te(!0),ie("success"),Pt(),setTimeout(()=>ie("idle"),1500)}else{const{name:H,email:we,creation:Kt,full_name:Rn,...Ae}=Al;await Ma("User",H,Ae),ie("success"),Pt(),setTimeout(()=>{ie("idle"),w("users")},1500)}}catch(_){console.error("User submit error:",_),ie(_ instanceof Error?_.message:"Error saving. Please try again.")}},Ue=()=>{const _=Be.find(H=>H.name===e.name||H.username===e.name);Yc(_||{name:e.name,full_name:e.full_name,email:e.name,enabled:1}),w("profile")},gi=(_,H)=>{if(H){const Kt={"processes-form":O.processes,"orders-form":O.orders,"incidents-form":O.incidents,"ideas-form":O.ideas}[_];if(Kt){te(!0),he(!0),(_==="processes-form"?Zl(H).then(Ae=>({...Ae,progress_indicators:Ae.progress_indicators||[],cycle_logs:Ae.cycle_logs||[]})):At(Kt,H)).then(Ae=>{_==="processes-form"?rn(Ae):_==="orders-form"?ln({...cn(),...Ae}):_==="incidents-form"?mn({...bn(),...Ae}):_==="ideas-form"&&sn({...on(),...Ae}),w(_),he(!1)}).catch(()=>{w(_),he(!1)});return}}w(_)},Ye=_=>t.jsxs(t.Fragment,{children:[_,t.jsx(wu,{isOpen:ht.isOpen,doctype:ht.doctype,docname:ht.name,docTitle:ht.title,isAdmin:a==="Admin"||e.name==="Administrator",isDeleting:ht.isDeleting,onClose:()=>vn(H=>({...H,isOpen:!1})),onConfirmSoftDelete:ud,onConfirmPermanentDelete:pd})]});if(x==="incidents-form")return Ye(t.jsx(j0,{incForm:xn,setIncForm:mn,organizations:I,managements:Q,departments:X,branches:N,incidentTypes:ce,incidentClasses:le,incidentFields:ct,incidentStatuses:Et,users:B,userRoleMap:hn,formStatus:Ke,viewMode:Qe||!g("incidents-form")||j(xn.workflow_state),canModify:g("incidents-form"),onEdit:g("incidents-form")&&!j(xn.workflow_state)&&!Fn("incident",xn.workflow_state)?()=>te(!1):void 0,onDelete:g("incidents-form")?_=>Ee(O.incidents,_,xn.title||xn.number):void 0,onRestore:a==="Admin"?_=>Dl(O.incidents,_):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,userRole:a,delegatedFunctions:Hc,delegatedOrgs:pi,onSubmit:()=>st(O.incidents,xn,()=>mn(bn()),"incidents",_=>mn({...bn(),..._})),onBack:()=>{w("incidents"),ie("idle")},onNavigate:w,onLogout:$e,user:e,onRefresh:async()=>{if(xn.name){const _=await At(O.incidents,xn.name).catch(()=>null);_&&mn({...bn(),..._})}Te(O.incidents).then(_=>k(_||[])).catch(()=>{})}}));if(x==="ideas-form")return Ye(t.jsx(k0,{ideaForm:yn,setIdeaForm:sn,organizations:I,managements:Q,departments:X,branches:N,ideaTypes:oe,ideaStatuses:L,users:B,userRoleMap:hn,formStatus:Ke,viewMode:Qe||!g("ideas-form")||j(yn.workflow_state),canModify:g("ideas-form"),onEdit:g("ideas-form")&&!j(yn.workflow_state)&&!Fn("idea",yn.workflow_state)?()=>te(!1):void 0,onDelete:g("ideas-form")?_=>Ee(O.ideas,_,yn.title||yn.number):void 0,onRestore:a==="Admin"?_=>Dl(O.ideas,_):void 0,onNavigateToOrder:_=>Se(O.orders,{name:_},ln,cn(),"orders-form",!0),darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,userRole:a,delegatedFunctions:Hc,delegatedOrgs:pi,onSubmit:()=>st(O.ideas,yn,()=>sn(on()),"ideas",_=>sn({...on(),..._})),onBack:()=>{w("ideas"),ie("idle")},onNavigate:w,onLogout:$e,user:e,onRefresh:async()=>{if(yn.name){const _=await At(O.ideas,yn.name).catch(()=>null);_&&sn({...on(),..._})}Te(O.ideas).then(_=>ee(_||[])).catch(()=>{})}}));if(x==="orders-form")return Ye(t.jsx(E0,{orderForm:ls,setOrderForm:ln,organizations:I,managements:Q,departments:X,branches:N,orderTypes:ve,orderStatuses:R,cycles:gn,users:B,userRoleMap:hn,formStatus:Ke,viewMode:Qe||!g("orders-form"),canModify:g("orders-form"),onEdit:g("orders-form")&&!Fn("order",ls.workflow_state)?()=>te(!1):void 0,onDelete:g("orders-form")?_=>Ee(O.orders,_,ls.title||ls.number):void 0,onRestore:a==="Admin"?_=>Dl(O.orders,_):void 0,onNavigateToIdea:_=>Se(O.ideas,{name:_},sn,on(),"ideas-form",!0),darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,currentUser:e.name,userRole:a,onSubmit:()=>st(O.orders,ls,()=>ln(cn()),"orders",_=>ln({...cn(),..._})),onBack:()=>{w("orders"),ie("idle")},onNavigate:w,onLogout:$e,user:e,onRefresh:async()=>{if(ls.name){const _=await At(O.orders,ls.name).catch(()=>null);_&&ln({...cn(),..._})}Te(O.orders).then(_=>$(_||[])).catch(()=>{})}}));if(x==="processes-form")return Ye(t.jsx(D0,{processForm:rs,setProcessForm:rn,organizations:I,managements:Q,departments:X,branches:N,processTypes:fe,processStatuses:ft,cycles:gn,users:B,userRoleMap:hn,formStatus:Ke,viewMode:Qe||!g("processes-form"),canModify:g("processes-form"),onEdit:g("processes-form")&&!Fn("process",rs.workflow_state)?()=>te(!1):void 0,onDelete:g("processes-form")?_=>Ee(O.processes,_,rs.title||rs.number):void 0,onRestore:a==="Admin"?_=>Dl(O.processes,_):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,userRole:e.role,onRefreshProcess:async()=>{if(rs.name)try{const _=await Zl(rs.name);rn({..._,progress_indicators:_.progress_indicators||[],cycle_logs:_.cycle_logs||[]})}catch{}Te(O.processes).then(_=>D(_||[])).catch(()=>{})},onSubmit:()=>st(O.processes,rs,()=>rn(sa()),"processes",_=>rn({...sa(),..._,progress_indicators:_.progress_indicators||[],cycle_logs:_.cycle_logs||[]})),onBack:()=>{w("processes"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));if(x==="organizations-form")return Ye(t.jsx($0,{orgForm:Xc,setOrgForm:Ds,groupCompanies:fi,formStatus:Ke,viewMode:Qe||!g("organizations-form"),onEdit:g("organizations-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,onSubmit:()=>st(O.organizations,Xc,()=>Ds(Gs()),"organizations",_=>{Ds({...Gs(),..._}),te(!0)}),onBack:()=>{w("organizations"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));if(x==="managements-form")return Ye(t.jsx(G0,{form:qc,setForm:as,organizations:I,formStatus:Ke,viewMode:Qe||!g("managements-form"),onEdit:g("managements-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,onSubmit:()=>st(O.managements,qc,()=>as(ps()),"managements",_=>{as({...ps(),..._}),te(!0)}),onBack:()=>{w("managements"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));if(x==="departments-form")return Ye(t.jsx(Y0,{form:Jc,setForm:is,organizations:I,managements:Q,formStatus:Ke,viewMode:Qe||!g("departments-form"),onEdit:g("departments-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,onSubmit:()=>st(O.departments,Jc,()=>is(fs()),"departments",_=>{is({...fs(),..._}),te(!0)}),onBack:()=>{w("departments"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));if(x==="branches-form")return Ye(t.jsx(J0,{form:Zc,setForm:os,organizations:I,managements:Q,departments:X,formStatus:Ke,viewMode:Qe||!g("branches-form"),onEdit:g("branches-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,onSubmit:()=>st(O.branches,Zc,()=>os(hs()),"branches",_=>{os({...hs(),..._}),te(!0)}),onBack:()=>{w("branches"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));if(x==="cycles-form")return Ye(t.jsx(E1,{form:id,setForm:cs,organizations:I,formStatus:Ke,viewMode:Qe||!g("cycles-form"),onEdit:g("cycles-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,onSubmit:()=>st(O.cycles,id,()=>cs(gs()),"cycles",_=>{cs({...gs(),..._}),te(!0)}),onBack:()=>{w("cycles"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));if(x==="kpi-input-form")return Ye(t.jsx(P1,{form:od,setForm:ds,organizations:I,formStatus:Ke,viewMode:Qe||!g("kpi-input-form"),onEdit:g("kpi-input-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,onSubmit:()=>st(O.kpiInput,od,()=>ds(xs()),"kpi-input",_=>{ds({...xs(),..._}),te(!0)}),onBack:()=>{w("kpi-input"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));if(x==="incident-types-form")return Ye(t.jsx(e1,{form:Vc,setForm:Ls,formStatus:Ke,viewMode:Qe||!g("incident-types-form"),onEdit:g("incident-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,onSubmit:()=>st(O.incidentTypes,Vc,()=>Ls(Ks()),"incident-types",_=>{Ls({...Ks(),..._}),te(!0)}),onBack:()=>{w("incident-types"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));if(x==="idea-types-form")return Ye(t.jsx(s1,{form:ed,setForm:Os,formStatus:Ke,viewMode:Qe||!g("idea-types-form"),onEdit:g("idea-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,onSubmit:()=>st(O.ideaTypes,ed,()=>Os(Qs()),"idea-types",_=>{Os({...Qs(),..._}),te(!0)}),onBack:()=>{w("idea-types"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));if(x==="order-types-form")return Ye(t.jsx(a1,{form:td,setForm:Ns,formStatus:Ke,viewMode:Qe||!g("order-types-form"),onEdit:g("order-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,onSubmit:()=>st(O.orderTypes,td,()=>Ns(Ys()),"order-types",_=>{Ns({...Ys(),..._}),te(!0)}),onBack:()=>{w("order-types"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));if(x==="process-types-form")return Ye(t.jsx(c1,{form:nd,setForm:Ws,formStatus:Ke,viewMode:Qe||!g("process-types-form"),onEdit:g("process-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,onSubmit:()=>st(O.processTypes,nd,()=>Ws(Xs()),"process-types",_=>{Ws({...Xs(),..._}),te(!0)}),onBack:()=>{w("process-types"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));if(x==="incident-statuses-form")return Ye(t.jsx(p1,{form:sd,setForm:Bs,formStatus:Ke,viewMode:Qe||!g("incident-statuses-form"),onEdit:g("incident-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,onSubmit:()=>st(O.incidentStatuses,sd,()=>Bs(qs()),"incident-statuses",_=>{Bs({...qs(),..._}),te(!0)}),onBack:()=>{w("incident-statuses"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));if(x==="idea-statuses-form")return Ye(t.jsx(g1,{form:ld,setForm:$s,formStatus:Ke,viewMode:Qe||!g("idea-statuses-form"),onEdit:g("idea-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,onSubmit:()=>st(O.ideaStatuses,ld,()=>$s(Js()),"idea-statuses",_=>{$s({...Js(),..._}),te(!0)}),onBack:()=>{w("idea-statuses"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));if(x==="order-statuses-form")return Ye(t.jsx(y1,{form:rd,setForm:Us,formStatus:Ke,viewMode:Qe||!g("order-statuses-form"),onEdit:g("order-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,onSubmit:()=>st(O.orderStatuses,rd,()=>Us(Zs()),"order-statuses",_=>{Us({...Zs(),..._}),te(!0)}),onBack:()=>{w("order-statuses"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));if(x==="process-statuses-form")return Ye(t.jsx(b1,{form:ad,setForm:Fs,formStatus:Ke,viewMode:Qe||!g("process-statuses-form"),onEdit:g("process-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,onSubmit:()=>st(O.processStatuses,ad,()=>Fs(Vs()),"process-statuses",_=>{Fs({...Vs(),..._}),te(!0)}),onBack:()=>{w("process-statuses"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));if(x==="users-form")return Ye(t.jsx(_1,{form:Al,setForm:Or,groupCompanies:fi,organizations:I,managements:Q,departments:X,branches:N,formStatus:Ke,viewMode:Qe||!g("users-form"),onEdit:g("users-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,isSelfProfile:Kc,onSubmit:ug,onBack:()=>{w(Kc?i?"dashboard":"inbox":"users"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));if(x==="delegations-form")return Ye(t.jsx(N1,{form:Ms,setForm:Rl,organizations:I,users:B,userRoleMap:hn,formStatus:Ke,viewMode:Qe||!g("delegations-form"),onEdit:g("delegations-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,onSubmit:Gh,onBack:()=>{w("delegations"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));if(x==="group-companies-form")return Ye(t.jsx(F0,{form:Gc,setForm:Rs,users:B,formStatus:Ke,viewMode:Qe||!g("group-companies-form"),onEdit:g("group-companies-form")?()=>te(!1):void 0,onRestore:a==="Admin"?_=>Dl(O.groupCompanies,_):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:b,onViewProfile:Ue,onSubmit:()=>st(O.groupCompanies,Gc,()=>Rs(Dr()),"group-companies",_=>{Rs({...Dr(),..._}),te(!0)}),onBack:()=>{w("group-companies"),ie("idle")},onNavigate:w,onLogout:$e,user:e}));const xi={...r.pages,"group-companies":"Group Companies","group-companies-form":"Group Company Form"},pg={"group-companies":{color:F.purple,formPage:"group-companies-form",reset:()=>Rs(Dr())},incidents:{color:F.accent,formPage:"incidents-form",reset:()=>mn({...bn(),organization:v||S})},ideas:{color:F.teal,formPage:"ideas-form",reset:()=>sn({...on(),organization:v||S})},orders:{color:F.purple,formPage:"orders-form",reset:()=>ln({...cn(),organization:v||S})},processes:{color:F.blue,formPage:"processes-form",reset:()=>{const _=pi.create_processes,H=v||(a==="Manager"&&_&&_.length===1?_[0]:S);rn({...sa(),organization:H})}},organizations:{color:F.accent,formPage:"organizations-form",reset:()=>Ds(Gs())},managements:{color:F.blue,formPage:"managements-form",reset:()=>as({...ps(),organization:v||S})},departments:{color:F.teal,formPage:"departments-form",reset:()=>is({...fs(),custom_organization:v||S})},branches:{color:F.purple,formPage:"branches-form",reset:()=>os({...hs(),organization:v||S})},cycles:{color:F.teal,formPage:"cycles-form",reset:()=>cs({...gs(),organization:v||S})},"kpi-input":{color:F.blue,formPage:"kpi-input-form",reset:()=>ds({...xs(),organization:v||S})},"incident-types":{color:F.red,formPage:"incident-types-form",reset:()=>Ls(Ks())},"idea-types":{color:F.orange,formPage:"idea-types-form",reset:()=>Os(Qs())},"order-types":{color:F.green,formPage:"order-types-form",reset:()=>Ns(Ys())},"process-types":{color:F.accent,formPage:"process-types-form",reset:()=>Ws(Xs())},"incident-statuses":{color:F.red,formPage:"incident-statuses-form",reset:()=>Bs(qs())},"idea-statuses":{color:F.teal,formPage:"idea-statuses-form",reset:()=>$s(Js())},"order-statuses":{color:F.purple,formPage:"order-statuses-form",reset:()=>Us(Zs())},"process-statuses":{color:F.blue,formPage:"process-statuses-form",reset:()=>Fs(Vs())},users:{color:F.blue,formPage:"users-form",reset:()=>{Or(la()),Qc(!1)}},delegations:{color:F.purple,formPage:"delegations-form",reset:()=>Rl(Ql())}},fg={"group-companies":"New Group Company",incidents:r.formTitle.newIncident,ideas:r.formTitle.newIdea,orders:r.formTitle.newOrder,processes:r.formTitle.newProcess,organizations:r.formTitle.newOrg,managements:r.formTitle.newMgmt,departments:r.formTitle.newDept,branches:r.formTitle.newBranch,users:r.formTitle.newUser,cycles:r.formTitle.newCycle,"kpi-input":r.formTitle.newKpi,delegations:r.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"},hg={incidents:h,ideas:M,orders:W,processes:T,organizations:I,managements:Q,departments:X,branches:N,cycles:gn,"kpi-input":Fc,"incident-types":ce,"idea-types":oe,"order-types":ve,"process-types":fe,"incident-statuses":Et,"idea-statuses":L,"order-statuses":R,"process-statuses":ft,users:Be,delegations:Mc},us=Me[x],Ll=hg[x],V=g(x),mi=V?pg[x]:null;return t.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:s?"#0f172a":F.bg},children:[t.jsx(rh,{collapsed:mh,onToggleCollapsed:vh,activePage:x,onNavigate:_=>w(_),hasDashboard:i,hasReports:c,hasDelegations:u,role:a,rtl:r.rtl,navLabels:r.nav,settingsLabel:r.nav.settings}),t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[t.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:t.jsx(ch,{notifCount:z,darkMode:s,onCountChange:b,onToggleDark:l,onNavigate:gi,onViewProfile:Ue,onLogout:$e,userName:e.full_name||e.name,userRole:a})}),x!=="profile"&&t.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:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:18,fontWeight:700,color:s?"#e2e8f0":"#0f172a"},children:xi[x]||x}),Ll&&t.jsxs("div",{style:{fontSize:12,color:"#64748b",marginTop:2,fontWeight:500},children:["Total: ",Ll.length," ",xi[x]?xi[x].toLowerCase():"records"]})]}),t.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[us&&Ll&&t.jsx("button",{onClick:()=>hi(!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"}),mi&&t.jsxs("button",{onClick:()=>{mi.reset(),te(!1),ie("idle"),w(mi.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:["+ ",fg[x]||r.new]})]})]}),us&&Ll&&jh&&t.jsx(jy,{title:us.label,rows:Ll,columns:us.columns,defaultColumnKeys:us.defaultColumns,orgField:us.orgField,organizations:us.orgField?I:void 0,filenameBase:x,onClose:()=>hi(!1)}),t.jsxs("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",padding:x==="profile"?0:"20px 24px",gap:x==="profile"?0:16},children:[_e&&t.jsx("div",{style:{textAlign:"center",paddingTop:60,color:"#aaa",fontSize:15},children:r.loading}),!_e&&x==="dashboard"&&i&&t.jsx(d0,{incidents:h,ideas:M,orders:W,processes:T,organizations:I,incidentStatuses:Et,ideaStatuses:L,orderStatuses:R,processStatuses:ft,selectedOrg:S,onOrgChange:m,onNavigate:gi,onNavigateStatus:f,userRole:a}),!_e&&x==="inbox"&&t.jsx(W1,{onNavigate:gi,onRefresh:Pt}),!_e&&x==="reports"&&c&&t.jsx(H1,{organizations:I,userRole:a}),!_e&&x==="incidents"&&t.jsx(u0,{incidents:h,organizations:I,departments:X,branches:N,incidentStatuses:Et,initialOrg:S,initialStatus:o,onView:Sh,onEdit:V?Dh:void 0,onDelete:V?_=>Ee(O.incidents,_):void 0,canModify:V,userRole:a}),!_e&&x==="ideas"&&t.jsx(b0,{ideas:M,organizations:I,departments:X,branches:N,ideaStatuses:L,initialOrg:S,initialStatus:o,onView:wh,onEdit:V?Lh:void 0,onDelete:V?_=>Ee(O.ideas,_):void 0,canModify:V,userRole:a}),!_e&&x==="orders"&&t.jsx(_0,{orders:W,organizations:I,departments:X,branches:N,orderStatuses:R,initialOrg:S,initialStatus:o,onView:kh,onEdit:V?Oh:void 0,onDelete:V?_=>Ee(O.orders,_):void 0,canModify:V,userRole:a}),!_e&&x==="processes"&&t.jsx(T0,{processes:T,organizations:I,departments:X,branches:N,processStatuses:ft,initialOrg:S,initialStatus:o,onView:_h,onEdit:V?Nh:void 0,onDelete:V?_=>Ee(O.processes,_):void 0,canModify:V,userRole:a}),!_e&&x==="organizations"&&t.jsx(B0,{organizations:I,onView:Ch,onEdit:V?Wh:void 0,onDelete:V?_=>Ee(O.organizations,_):void 0,canModify:V}),!_e&&x==="group-companies"&&t.jsx(U0,{groupCompanies:fi,onView:zh,onEdit:V?Ih:void 0,onDelete:V?_=>Ee(O.groupCompanies,_):void 0,canModify:V}),!_e&&x==="managements"&&t.jsx(H0,{managements:Q,onView:Eh,onEdit:V?Bh:void 0,onDelete:V?_=>Ee(O.managements,_):void 0,canModify:V}),!_e&&x==="departments"&&t.jsx(Q0,{departments:X,managements:Q,onView:Th,onEdit:V?$h:void 0,onDelete:V?_=>Ee(O.departments,_):void 0,canModify:V}),!_e&&x==="branches"&&t.jsx(q0,{branches:N,managements:Q,departments:X,onView:Ph,onEdit:V?Uh:void 0,onDelete:V?_=>Ee(O.branches,_):void 0,canModify:V}),!_e&&x==="cycles"&&t.jsx(C1,{cycles:gn,canModify:V,onView:Ah,onEdit:V?Fh:void 0,onDelete:V?_=>Ee(O.cycles,_):void 0}),!_e&&x==="kpi-input"&&t.jsx(T1,{kpiInputs:Fc,canModify:V,onView:Rh,onEdit:V?Mh:void 0,onDelete:V?_=>Ee(O.kpiInput,_):void 0}),!_e&&x==="incident-types"&&t.jsx(V0,{incidentTypes:ce,onView:Qh,onEdit:V?Yh:void 0,onDelete:V?_=>Ee(O.incidentTypes,_):void 0,canModify:V}),!_e&&x==="idea-types"&&t.jsx(n1,{ideaTypes:oe,onView:Xh,onEdit:V?qh:void 0,onDelete:V?_=>Ee(O.ideaTypes,_):void 0,canModify:V}),!_e&&x==="order-types"&&t.jsx(r1,{orderTypes:ve,onView:Jh,onEdit:V?Zh:void 0,onDelete:V?_=>Ee(O.orderTypes,_):void 0,canModify:V}),!_e&&x==="process-types"&&t.jsx(o1,{processTypes:fe,onView:Vh,onEdit:V?eg:void 0,onDelete:V?_=>Ee(O.processTypes,_):void 0,canModify:V}),!_e&&x==="incident-statuses"&&t.jsx(u1,{incidentStatuses:Et,onView:tg,onEdit:V?ng:void 0,onDelete:V?_=>Ee(O.incidentStatuses,_):void 0,canModify:V}),!_e&&x==="idea-statuses"&&t.jsx(h1,{ideaStatuses:L,onView:sg,onEdit:V?lg:void 0,onDelete:V?_=>Ee(O.ideaStatuses,_):void 0,canModify:V}),!_e&&x==="order-statuses"&&t.jsx(m1,{orderStatuses:R,onView:rg,onEdit:V?ag:void 0,onDelete:V?_=>Ee(O.orderStatuses,_):void 0,canModify:V}),!_e&&x==="process-statuses"&&t.jsx(j1,{processStatuses:ft,onView:ig,onEdit:V?og:void 0,onDelete:V?_=>Ee(O.processStatuses,_):void 0,canModify:V}),!_e&&x==="users"&&t.jsx(k1,{users:Be,roleMap:hn,onView:cg,onEdit:V?dg:void 0,onDelete:V?_=>Ee("User",_):void 0,onDisable:V?bh:void 0,canModify:V}),!_e&&x==="delegations"&&u&&t.jsx(L1,{delegations:Mc,organizations:I,userRole:a,currentUser:e.name,onView:Hh,onRevoke:V?Kh:void 0}),x==="profile"&&(()=>{const _=!!Lr&&(Lr.name===e.name||Lr.email===e.name);return t.jsx(O0,{user:e,profileUser:Lr,sbUsers:Be,organizations:I,managements:Q,departments:X,branches:N,darkMode:s,canModify:V||_,onBack:()=>w(_?i?"dashboard":"inbox":"users"),onNavigate:w})})()]})]}),t.jsx(wu,{isOpen:ht.isOpen,doctype:ht.doctype,docname:ht.name,docTitle:ht.title,isAdmin:a==="Admin"||e.name==="Administrator",isDeleting:ht.isDeleting,onClose:()=>vn(_=>({..._,isOpen:!1})),onConfirmSoftDelete:ud,onConfirmPermanentDelete:pd})]})}function V1(e){return e.some(n=>["SB Admin","System Manager"].includes(n))?"Admin":e.includes("SB Auditor")?"Auditor":e.includes("SB Owner")?"Owner":e.includes("SB X-Auditor")?"XAuditor":e.includes("SB Manager")?"Manager":"Employee"}function ev(){const[e,n]=C.useState(()=>{try{const c=localStorage.getItem("sidrah_user");return c?JSON.parse(c):null}catch{return null}}),[s,l]=C.useState(()=>localStorage.getItem("sb_dark")==="1"),r=()=>{const c=!s;l(c),localStorage.setItem("sb_dark",c?"1":"0"),document.documentElement.classList.toggle("dark",c)};C.useEffect(()=>{document.documentElement.classList.toggle("dark",s)},[]),C.useEffect(()=>{e&&ah().then(async c=>{const u=c||e.name,g=await oh(u);if(!g.length)return;const j=V1(g),y=await Ny();if(j!==e.role||u!==e.name||y!==(e.custom_organization||"")){const x={...e,name:u,role:j,custom_organization:y};n(x),localStorage.setItem("sidrah_user",JSON.stringify(x))}})},[e==null?void 0:e.name]);const a=c=>{n(c),localStorage.setItem("sidrah_user",JSON.stringify(c))},i=()=>{n(null),localStorage.removeItem("sidrah_user")};return e?t.jsx(Z1,{user:e,onLogout:i,darkMode:s,onToggleDark:r}):t.jsx(l0,{onLogin:a})}Vf(document.getElementById("root")).render(t.jsx(C.StrictMode,{children:t.jsx(ev,{})}));