53 lines
595 KiB
JavaScript
53 lines
595 KiB
JavaScript
(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))l(a);new MutationObserver(a=>{for(const r of a)if(r.type==="childList")for(const i of r.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&l(i)}).observe(document,{childList:!0,subtree:!0});function s(a){const r={};return a.integrity&&(r.integrity=a.integrity),a.referrerPolicy&&(r.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?r.credentials="include":a.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function l(a){if(a.ep)return;a.ep=!0;const r=s(a);fetch(a.href,r)}})();var Gu={exports:{}},li={},Qu={exports:{}},he={};/**
|
||
* @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 Na=Symbol.for("react.element"),Lg=Symbol.for("react.portal"),Wg=Symbol.for("react.fragment"),Ng=Symbol.for("react.strict_mode"),Bg=Symbol.for("react.profiler"),$g=Symbol.for("react.provider"),Ug=Symbol.for("react.context"),Mg=Symbol.for("react.forward_ref"),Fg=Symbol.for("react.suspense"),Hg=Symbol.for("react.memo"),Gg=Symbol.for("react.lazy"),bc=Symbol.iterator;function Qg(e){return e===null||typeof e!="object"?null:(e=bc&&e[bc]||e["@@iterator"],typeof e=="function"?e:null)}var Ku={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Yu=Object.assign,Xu={};function $l(e,n,s){this.props=e,this.context=n,this.refs=Xu,this.updater=s||Ku}$l.prototype.isReactComponent={};$l.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")};$l.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function qu(){}qu.prototype=$l.prototype;function md(e,n,s){this.props=e,this.context=n,this.refs=Xu,this.updater=s||Ku}var xd=md.prototype=new qu;xd.constructor=md;Yu(xd,$l.prototype);xd.isPureReactComponent=!0;var Sc=Array.isArray,Ju=Object.prototype.hasOwnProperty,yd={current:null},Vu={key:!0,ref:!0,__self:!0,__source:!0};function Zu(e,n,s){var l,a={},r=null,i=null;if(n!=null)for(l in n.ref!==void 0&&(i=n.ref),n.key!==void 0&&(r=""+n.key),n)Ju.call(n,l)&&!Vu.hasOwnProperty(l)&&(a[l]=n[l]);var d=arguments.length-2;if(d===1)a.children=s;else if(1<d){for(var f=Array(d),p=0;p<d;p++)f[p]=arguments[p+2];a.children=f}if(e&&e.defaultProps)for(l in d=e.defaultProps,d)a[l]===void 0&&(a[l]=d[l]);return{$$typeof:Na,type:e,key:r,ref:i,props:a,_owner:yd.current}}function Kg(e,n){return{$$typeof:Na,type:e.type,key:n,ref:e.ref,props:e.props,_owner:e._owner}}function vd(e){return typeof e=="object"&&e!==null&&e.$$typeof===Na}function Yg(e){var n={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(s){return n[s]})}var _c=/\/+/g;function Hi(e,n){return typeof e=="object"&&e!==null&&e.key!=null?Yg(""+e.key):n.toString(36)}function vr(e,n,s,l,a){var r=typeof e;(r==="undefined"||r==="boolean")&&(e=null);var i=!1;if(e===null)i=!0;else switch(r){case"string":case"number":i=!0;break;case"object":switch(e.$$typeof){case Na:case Lg:i=!0}}if(i)return i=e,a=a(i),e=l===""?"."+Hi(i,0):l,Sc(a)?(s="",e!=null&&(s=e.replace(_c,"$&/")+"/"),vr(a,n,s,"",function(p){return p})):a!=null&&(vd(a)&&(a=Kg(a,s+(!a.key||i&&i.key===a.key?"":(""+a.key).replace(_c,"$&/")+"/")+e)),n.push(a)),1;if(i=0,l=l===""?".":l+":",Sc(e))for(var d=0;d<e.length;d++){r=e[d];var f=l+Hi(r,d);i+=vr(r,n,s,f,a)}else if(f=Qg(e),typeof f=="function")for(e=f.call(e),d=0;!(r=e.next()).done;)r=r.value,f=l+Hi(r,d++),i+=vr(r,n,s,f,a);else if(r==="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 Va(e,n,s){if(e==null)return e;var l=[],a=0;return vr(e,l,"","",function(r){return n.call(s,r,a++)}),l}function Xg(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 It={current:null},jr={transition:null},qg={ReactCurrentDispatcher:It,ReactCurrentBatchConfig:jr,ReactCurrentOwner:yd};function ep(){throw Error("act(...) is not supported in production builds of React.")}he.Children={map:Va,forEach:function(e,n,s){Va(e,function(){n.apply(this,arguments)},s)},count:function(e){var n=0;return Va(e,function(){n++}),n},toArray:function(e){return Va(e,function(n){return n})||[]},only:function(e){if(!vd(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};he.Component=$l;he.Fragment=Wg;he.Profiler=Bg;he.PureComponent=md;he.StrictMode=Ng;he.Suspense=Fg;he.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=qg;he.act=ep;he.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=Yu({},e.props),a=e.key,r=e.ref,i=e._owner;if(n!=null){if(n.ref!==void 0&&(r=n.ref,i=yd.current),n.key!==void 0&&(a=""+n.key),e.type&&e.type.defaultProps)var d=e.type.defaultProps;for(f in n)Ju.call(n,f)&&!Vu.hasOwnProperty(f)&&(l[f]=n[f]===void 0&&d!==void 0?d[f]:n[f])}var f=arguments.length-2;if(f===1)l.children=s;else if(1<f){d=Array(f);for(var p=0;p<f;p++)d[p]=arguments[p+2];l.children=d}return{$$typeof:Na,type:e.type,key:a,ref:r,props:l,_owner:i}};he.createContext=function(e){return e={$$typeof:Ug,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:$g,_context:e},e.Consumer=e};he.createElement=Zu;he.createFactory=function(e){var n=Zu.bind(null,e);return n.type=e,n};he.createRef=function(){return{current:null}};he.forwardRef=function(e){return{$$typeof:Mg,render:e}};he.isValidElement=vd;he.lazy=function(e){return{$$typeof:Gg,_payload:{_status:-1,_result:e},_init:Xg}};he.memo=function(e,n){return{$$typeof:Hg,type:e,compare:n===void 0?null:n}};he.startTransition=function(e){var n=jr.transition;jr.transition={};try{e()}finally{jr.transition=n}};he.unstable_act=ep;he.useCallback=function(e,n){return It.current.useCallback(e,n)};he.useContext=function(e){return It.current.useContext(e)};he.useDebugValue=function(){};he.useDeferredValue=function(e){return It.current.useDeferredValue(e)};he.useEffect=function(e,n){return It.current.useEffect(e,n)};he.useId=function(){return It.current.useId()};he.useImperativeHandle=function(e,n,s){return It.current.useImperativeHandle(e,n,s)};he.useInsertionEffect=function(e,n){return It.current.useInsertionEffect(e,n)};he.useLayoutEffect=function(e,n){return It.current.useLayoutEffect(e,n)};he.useMemo=function(e,n){return It.current.useMemo(e,n)};he.useReducer=function(e,n,s){return It.current.useReducer(e,n,s)};he.useRef=function(e){return It.current.useRef(e)};he.useState=function(e){return It.current.useState(e)};he.useSyncExternalStore=function(e,n,s){return It.current.useSyncExternalStore(e,n,s)};he.useTransition=function(){return It.current.useTransition()};he.version="18.3.1";Qu.exports=he;var _=Qu.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 Jg=_,Vg=Symbol.for("react.element"),Zg=Symbol.for("react.fragment"),em=Object.prototype.hasOwnProperty,tm=Jg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,nm={key:!0,ref:!0,__self:!0,__source:!0};function tp(e,n,s){var l,a={},r=null,i=null;s!==void 0&&(r=""+s),n.key!==void 0&&(r=""+n.key),n.ref!==void 0&&(i=n.ref);for(l in n)em.call(n,l)&&!nm.hasOwnProperty(l)&&(a[l]=n[l]);if(e&&e.defaultProps)for(l in n=e.defaultProps,n)a[l]===void 0&&(a[l]=n[l]);return{$$typeof:Vg,type:e,key:r,ref:i,props:a,_owner:tm.current}}li.Fragment=Zg;li.jsx=tp;li.jsxs=tp;Gu.exports=li;var t=Gu.exports,np={exports:{}},Ht={},sp={exports:{}},lp={};/**
|
||
* @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(P,F){var K=P.length;P.push(F);e:for(;0<K;){var E=K-1>>>1,ee=P[E];if(0<a(ee,F))P[E]=F,P[K]=ee,K=E;else break e}}function s(P){return P.length===0?null:P[0]}function l(P){if(P.length===0)return null;var F=P[0],K=P.pop();if(K!==F){P[0]=K;e:for(var E=0,ee=P.length,V=ee>>>1;E<V;){var ce=2*(E+1)-1,ie=P[ce],tt=ce+1,Re=P[tt];if(0>a(ie,K))tt<ee&&0>a(Re,ie)?(P[E]=Re,P[tt]=K,E=tt):(P[E]=ie,P[ce]=K,E=ce);else if(tt<ee&&0>a(Re,K))P[E]=Re,P[tt]=K,E=tt;else break e}}return F}function a(P,F){var K=P.sortIndex-F.sortIndex;return K!==0?K:P.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var r=performance;e.unstable_now=function(){return r.now()}}else{var i=Date,d=i.now();e.unstable_now=function(){return i.now()-d}}var f=[],p=[],k=1,j=null,S=3,u=!1,v=!1,z=!1,C=typeof setTimeout=="function"?setTimeout:null,g=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 h(P){for(var F=s(p);F!==null;){if(F.callback===null)l(p);else if(F.startTime<=P)l(p),F.sortIndex=F.expirationTime,n(f,F);else break;F=s(p)}}function x(P){if(z=!1,h(P),!v)if(s(f)!==null)v=!0,$(y);else{var F=s(p);F!==null&&I(x,F.startTime-P)}}function y(P,F){v=!1,z&&(z=!1,g(b),b=-1),u=!0;var K=S;try{for(h(F),j=s(f);j!==null&&(!(j.expirationTime>F)||P&&!M());){var E=j.callback;if(typeof E=="function"){j.callback=null,S=j.priorityLevel;var ee=E(j.expirationTime<=F);F=e.unstable_now(),typeof ee=="function"?j.callback=ee:j===s(f)&&l(f),h(F)}else l(f);j=s(f)}if(j!==null)var V=!0;else{var ce=s(p);ce!==null&&I(x,ce.startTime-F),V=!1}return V}finally{j=null,S=K,u=!1}}var w=!1,c=null,b=-1,A=5,T=-1;function M(){return!(e.unstable_now()-T<A)}function H(){if(c!==null){var P=e.unstable_now();T=P;var F=!0;try{F=c(!0,P)}finally{F?le():(w=!1,c=null)}}else w=!1}var le;if(typeof o=="function")le=function(){o(H)};else if(typeof MessageChannel<"u"){var U=new MessageChannel,G=U.port2;U.port1.onmessage=H,le=function(){G.postMessage(null)}}else le=function(){C(H,0)};function $(P){c=P,w||(w=!0,le())}function I(P,F){b=C(function(){P(e.unstable_now())},F)}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(P){P.callback=null},e.unstable_continueExecution=function(){v||u||(v=!0,$(y))},e.unstable_forceFrameRate=function(P){0>P||125<P?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<P?Math.floor(1e3/P):5},e.unstable_getCurrentPriorityLevel=function(){return S},e.unstable_getFirstCallbackNode=function(){return s(f)},e.unstable_next=function(P){switch(S){case 1:case 2:case 3:var F=3;break;default:F=S}var K=S;S=F;try{return P()}finally{S=K}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(P,F){switch(P){case 1:case 2:case 3:case 4:case 5:break;default:P=3}var K=S;S=P;try{return F()}finally{S=K}},e.unstable_scheduleCallback=function(P,F,K){var E=e.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?E+K:E):K=E,P){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=K+ee,P={id:k++,callback:F,priorityLevel:P,startTime:K,expirationTime:ee,sortIndex:-1},K>E?(P.sortIndex=K,n(p,P),s(f)===null&&P===s(p)&&(z?(g(b),b=-1):z=!0,I(x,K-E))):(P.sortIndex=ee,n(f,P),v||u||(v=!0,$(y))),P},e.unstable_shouldYield=M,e.unstable_wrapCallback=function(P){var F=S;return function(){var K=S;S=F;try{return P.apply(this,arguments)}finally{S=K}}}})(lp);sp.exports=lp;var sm=sp.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 lm=_,Ft=sm;function Y(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 ap=new Set,va={};function Fs(e,n){Al(e,n),Al(e+"Capture",n)}function Al(e,n){for(va[e]=n,e=0;e<n.length;e++)ap.add(n[e])}var Mn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),bo=Object.prototype.hasOwnProperty,am=/^[: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]*$/,wc={},kc={};function rm(e){return bo.call(kc,e)?!0:bo.call(wc,e)?!1:am.test(e)?kc[e]=!0:(wc[e]=!0,!1)}function im(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 om(e,n,s,l){if(n===null||typeof n>"u"||im(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 Et(e,n,s,l,a,r,i){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=a,this.mustUseProperty=s,this.propertyName=e,this.type=n,this.sanitizeURL=r,this.removeEmptyString=i}var mt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){mt[e]=new Et(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];mt[n]=new Et(n,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){mt[e]=new Et(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){mt[e]=new Et(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){mt[e]=new Et(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){mt[e]=new Et(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){mt[e]=new Et(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){mt[e]=new Et(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){mt[e]=new Et(e,5,!1,e.toLowerCase(),null,!1,!1)});var jd=/[\-:]([a-z])/g;function bd(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(jd,bd);mt[n]=new Et(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(jd,bd);mt[n]=new Et(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(jd,bd);mt[n]=new Et(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){mt[e]=new Et(e,1,!1,e.toLowerCase(),null,!1,!1)});mt.xlinkHref=new Et("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){mt[e]=new Et(e,1,!1,e.toLowerCase(),null,!0,!0)});function Sd(e,n,s,l){var a=mt.hasOwnProperty(n)?mt[n]:null;(a!==null?a.type!==0:l||!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(om(n,s,a,l)&&(s=null),l||a===null?rm(n)&&(s===null?e.removeAttribute(n):e.setAttribute(n,""+s)):a.mustUseProperty?e[a.propertyName]=s===null?a.type===3?!1:"":s:(n=a.attributeName,l=a.attributeNamespace,s===null?e.removeAttribute(n):(a=a.type,s=a===3||a===4&&s===!0?"":""+s,l?e.setAttributeNS(l,n,s):e.setAttribute(n,s))))}var Qn=lm.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Za=Symbol.for("react.element"),pl=Symbol.for("react.portal"),fl=Symbol.for("react.fragment"),_d=Symbol.for("react.strict_mode"),So=Symbol.for("react.profiler"),rp=Symbol.for("react.provider"),ip=Symbol.for("react.context"),wd=Symbol.for("react.forward_ref"),_o=Symbol.for("react.suspense"),wo=Symbol.for("react.suspense_list"),kd=Symbol.for("react.memo"),Xn=Symbol.for("react.lazy"),op=Symbol.for("react.offscreen"),Cc=Symbol.iterator;function Xl(e){return e===null||typeof e!="object"?null:(e=Cc&&e[Cc]||e["@@iterator"],typeof e=="function"?e:null)}var $e=Object.assign,Gi;function aa(e){if(Gi===void 0)try{throw Error()}catch(s){var n=s.stack.trim().match(/\n( *(at )?)/);Gi=n&&n[1]||""}return`
|
||
`+Gi+e}var Qi=!1;function Ki(e,n){if(!e||Qi)return"";Qi=!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(p){var l=p}Reflect.construct(e,[],n)}else{try{n.call()}catch(p){l=p}e.call(n.prototype)}else{try{throw Error()}catch(p){l=p}e()}}catch(p){if(p&&l&&typeof p.stack=="string"){for(var a=p.stack.split(`
|
||
`),r=l.stack.split(`
|
||
`),i=a.length-1,d=r.length-1;1<=i&&0<=d&&a[i]!==r[d];)d--;for(;1<=i&&0<=d;i--,d--)if(a[i]!==r[d]){if(i!==1||d!==1)do if(i--,d--,0>d||a[i]!==r[d]){var f=`
|
||
`+a[i].replace(" at new "," at ");return e.displayName&&f.includes("<anonymous>")&&(f=f.replace("<anonymous>",e.displayName)),f}while(1<=i&&0<=d);break}}}finally{Qi=!1,Error.prepareStackTrace=s}return(e=e?e.displayName||e.name:"")?aa(e):""}function dm(e){switch(e.tag){case 5:return aa(e.type);case 16:return aa("Lazy");case 13:return aa("Suspense");case 19:return aa("SuspenseList");case 0:case 2:case 15:return e=Ki(e.type,!1),e;case 11:return e=Ki(e.type.render,!1),e;case 1:return e=Ki(e.type,!0),e;default:return""}}function ko(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 fl:return"Fragment";case pl:return"Portal";case So:return"Profiler";case _d:return"StrictMode";case _o:return"Suspense";case wo:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ip:return(e.displayName||"Context")+".Consumer";case rp:return(e._context.displayName||"Context")+".Provider";case wd:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case kd:return n=e.displayName||null,n!==null?n:ko(e.type)||"Memo";case Xn:n=e._payload,e=e._init;try{return ko(e(n))}catch{}}return null}function cm(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 ko(n);case 8:return n===_d?"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 us(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function dp(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function um(e){var n=dp(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 a=s.get,r=s.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return a.call(this)},set:function(i){l=""+i,r.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 er(e){e._valueTracker||(e._valueTracker=um(e))}function cp(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var s=n.getValue(),l="";return e&&(l=dp(e)?e.checked?"true":"false":e.value),e=l,e!==s?(n.setValue(e),!0):!1}function Pr(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 Co(e,n){var s=n.checked;return $e({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:s??e._wrapperState.initialChecked})}function zc(e,n){var s=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;s=us(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 up(e,n){n=n.checked,n!=null&&Sd(e,"checked",n,!1)}function zo(e,n){up(e,n);var s=us(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")?Io(e,n.type,s):n.hasOwnProperty("defaultValue")&&Io(e,n.type,us(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function Ic(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 Io(e,n,s){(n!=="number"||Pr(e.ownerDocument)!==e)&&(s==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+s&&(e.defaultValue=""+s))}var ra=Array.isArray;function kl(e,n,s,l){if(e=e.options,n){n={};for(var a=0;a<s.length;a++)n["$"+s[a]]=!0;for(s=0;s<e.length;s++)a=n.hasOwnProperty("$"+e[s].value),e[s].selected!==a&&(e[s].selected=a),a&&l&&(e[s].defaultSelected=!0)}else{for(s=""+us(s),n=null,a=0;a<e.length;a++){if(e[a].value===s){e[a].selected=!0,l&&(e[a].defaultSelected=!0);return}n!==null||e[a].disabled||(n=e[a])}n!==null&&(n.selected=!0)}}function Eo(e,n){if(n.dangerouslySetInnerHTML!=null)throw Error(Y(91));return $e({},n,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Ec(e,n){var s=n.value;if(s==null){if(s=n.children,n=n.defaultValue,s!=null){if(n!=null)throw Error(Y(92));if(ra(s)){if(1<s.length)throw Error(Y(93));s=s[0]}n=s}n==null&&(n=""),s=n}e._wrapperState={initialValue:us(s)}}function pp(e,n){var s=us(n.value),l=us(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 Tc(e){var n=e.textContent;n===e._wrapperState.initialValue&&n!==""&&n!==null&&(e.value=n)}function fp(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 To(e,n){return e==null||e==="http://www.w3.org/1999/xhtml"?fp(n):e==="http://www.w3.org/2000/svg"&&n==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var tr,hp=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(n,s,l,a){MSApp.execUnsafeLocalFunction(function(){return e(n,s,l,a)})}:e}(function(e,n){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=n;else{for(tr=tr||document.createElement("div"),tr.innerHTML="<svg>"+n.valueOf().toString()+"</svg>",n=tr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function ja(e,n){if(n){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=n;return}}e.textContent=n}var ca={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},pm=["Webkit","ms","Moz","O"];Object.keys(ca).forEach(function(e){pm.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),ca[n]=ca[e]})});function gp(e,n,s){return n==null||typeof n=="boolean"||n===""?"":s||typeof n!="number"||n===0||ca.hasOwnProperty(e)&&ca[e]?(""+n).trim():n+"px"}function mp(e,n){e=e.style;for(var s in n)if(n.hasOwnProperty(s)){var l=s.indexOf("--")===0,a=gp(s,n[s],l);s==="float"&&(s="cssFloat"),l?e.setProperty(s,a):e[s]=a}}var fm=$e({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 Ao(e,n){if(n){if(fm[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(Y(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(Y(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(Y(61))}if(n.style!=null&&typeof n.style!="object")throw Error(Y(62))}}function Po(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 Ro=null;function Cd(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Do=null,Cl=null,zl=null;function Ac(e){if(e=Ua(e)){if(typeof Do!="function")throw Error(Y(280));var n=e.stateNode;n&&(n=di(n),Do(e.stateNode,e.type,n))}}function xp(e){Cl?zl?zl.push(e):zl=[e]:Cl=e}function yp(){if(Cl){var e=Cl,n=zl;if(zl=Cl=null,Ac(e),n)for(e=0;e<n.length;e++)Ac(n[e])}}function vp(e,n){return e(n)}function jp(){}var Yi=!1;function bp(e,n,s){if(Yi)return e(n,s);Yi=!0;try{return vp(e,n,s)}finally{Yi=!1,(Cl!==null||zl!==null)&&(jp(),yp())}}function ba(e,n){var s=e.stateNode;if(s===null)return null;var l=di(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(Y(231,n,typeof s));return s}var Oo=!1;if(Mn)try{var ql={};Object.defineProperty(ql,"passive",{get:function(){Oo=!0}}),window.addEventListener("test",ql,ql),window.removeEventListener("test",ql,ql)}catch{Oo=!1}function hm(e,n,s,l,a,r,i,d,f){var p=Array.prototype.slice.call(arguments,3);try{n.apply(s,p)}catch(k){this.onError(k)}}var ua=!1,Rr=null,Dr=!1,Lo=null,gm={onError:function(e){ua=!0,Rr=e}};function mm(e,n,s,l,a,r,i,d,f){ua=!1,Rr=null,hm.apply(gm,arguments)}function xm(e,n,s,l,a,r,i,d,f){if(mm.apply(this,arguments),ua){if(ua){var p=Rr;ua=!1,Rr=null}else throw Error(Y(198));Dr||(Dr=!0,Lo=p)}}function Hs(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 Sp(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 Pc(e){if(Hs(e)!==e)throw Error(Y(188))}function ym(e){var n=e.alternate;if(!n){if(n=Hs(e),n===null)throw Error(Y(188));return n!==e?null:e}for(var s=e,l=n;;){var a=s.return;if(a===null)break;var r=a.alternate;if(r===null){if(l=a.return,l!==null){s=l;continue}break}if(a.child===r.child){for(r=a.child;r;){if(r===s)return Pc(a),e;if(r===l)return Pc(a),n;r=r.sibling}throw Error(Y(188))}if(s.return!==l.return)s=a,l=r;else{for(var i=!1,d=a.child;d;){if(d===s){i=!0,s=a,l=r;break}if(d===l){i=!0,l=a,s=r;break}d=d.sibling}if(!i){for(d=r.child;d;){if(d===s){i=!0,s=r,l=a;break}if(d===l){i=!0,l=r,s=a;break}d=d.sibling}if(!i)throw Error(Y(189))}}if(s.alternate!==l)throw Error(Y(190))}if(s.tag!==3)throw Error(Y(188));return s.stateNode.current===s?e:n}function _p(e){return e=ym(e),e!==null?wp(e):null}function wp(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var n=wp(e);if(n!==null)return n;e=e.sibling}return null}var kp=Ft.unstable_scheduleCallback,Rc=Ft.unstable_cancelCallback,vm=Ft.unstable_shouldYield,jm=Ft.unstable_requestPaint,Ve=Ft.unstable_now,bm=Ft.unstable_getCurrentPriorityLevel,zd=Ft.unstable_ImmediatePriority,Cp=Ft.unstable_UserBlockingPriority,Or=Ft.unstable_NormalPriority,Sm=Ft.unstable_LowPriority,zp=Ft.unstable_IdlePriority,ai=null,In=null;function _m(e){if(In&&typeof In.onCommitFiberRoot=="function")try{In.onCommitFiberRoot(ai,e,void 0,(e.current.flags&128)===128)}catch{}}var gn=Math.clz32?Math.clz32:Cm,wm=Math.log,km=Math.LN2;function Cm(e){return e>>>=0,e===0?32:31-(wm(e)/km|0)|0}var nr=64,sr=4194304;function ia(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 Lr(e,n){var s=e.pendingLanes;if(s===0)return 0;var l=0,a=e.suspendedLanes,r=e.pingedLanes,i=s&268435455;if(i!==0){var d=i&~a;d!==0?l=ia(d):(r&=i,r!==0&&(l=ia(r)))}else i=s&~a,i!==0?l=ia(i):r!==0&&(l=ia(r));if(l===0)return 0;if(n!==0&&n!==l&&!(n&a)&&(a=l&-l,r=n&-n,a>=r||a===16&&(r&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-gn(n),a=1<<s,l|=e[s],n&=~a;return l}function zm(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 Im(e,n){for(var s=e.suspendedLanes,l=e.pingedLanes,a=e.expirationTimes,r=e.pendingLanes;0<r;){var i=31-gn(r),d=1<<i,f=a[i];f===-1?(!(d&s)||d&l)&&(a[i]=zm(d,n)):f<=n&&(e.expiredLanes|=d),r&=~d}}function Wo(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Ip(){var e=nr;return nr<<=1,!(nr&4194240)&&(nr=64),e}function Xi(e){for(var n=[],s=0;31>s;s++)n.push(e);return n}function Ba(e,n,s){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-gn(n),e[n]=s}function Em(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 a=31-gn(s),r=1<<a;n[a]=0,l[a]=-1,e[a]=-1,s&=~r}}function Id(e,n){var s=e.entangledLanes|=n;for(e=e.entanglements;s;){var l=31-gn(s),a=1<<l;a&n|e[l]&n&&(e[l]|=n),s&=~a}}var we=0;function Ep(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Tp,Ed,Ap,Pp,Rp,No=!1,lr=[],ss=null,ls=null,as=null,Sa=new Map,_a=new Map,Jn=[],Tm="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 Dc(e,n){switch(e){case"focusin":case"focusout":ss=null;break;case"dragenter":case"dragleave":ls=null;break;case"mouseover":case"mouseout":as=null;break;case"pointerover":case"pointerout":Sa.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":_a.delete(n.pointerId)}}function Jl(e,n,s,l,a,r){return e===null||e.nativeEvent!==r?(e={blockedOn:n,domEventName:s,eventSystemFlags:l,nativeEvent:r,targetContainers:[a]},n!==null&&(n=Ua(n),n!==null&&Ed(n)),e):(e.eventSystemFlags|=l,n=e.targetContainers,a!==null&&n.indexOf(a)===-1&&n.push(a),e)}function Am(e,n,s,l,a){switch(n){case"focusin":return ss=Jl(ss,e,n,s,l,a),!0;case"dragenter":return ls=Jl(ls,e,n,s,l,a),!0;case"mouseover":return as=Jl(as,e,n,s,l,a),!0;case"pointerover":var r=a.pointerId;return Sa.set(r,Jl(Sa.get(r)||null,e,n,s,l,a)),!0;case"gotpointercapture":return r=a.pointerId,_a.set(r,Jl(_a.get(r)||null,e,n,s,l,a)),!0}return!1}function Dp(e){var n=As(e.target);if(n!==null){var s=Hs(n);if(s!==null){if(n=s.tag,n===13){if(n=Sp(s),n!==null){e.blockedOn=n,Rp(e.priority,function(){Ap(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 br(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var s=Bo(e.domEventName,e.eventSystemFlags,n[0],e.nativeEvent);if(s===null){s=e.nativeEvent;var l=new s.constructor(s.type,s);Ro=l,s.target.dispatchEvent(l),Ro=null}else return n=Ua(s),n!==null&&Ed(n),e.blockedOn=s,!1;n.shift()}return!0}function Oc(e,n,s){br(e)&&s.delete(n)}function Pm(){No=!1,ss!==null&&br(ss)&&(ss=null),ls!==null&&br(ls)&&(ls=null),as!==null&&br(as)&&(as=null),Sa.forEach(Oc),_a.forEach(Oc)}function Vl(e,n){e.blockedOn===n&&(e.blockedOn=null,No||(No=!0,Ft.unstable_scheduleCallback(Ft.unstable_NormalPriority,Pm)))}function wa(e){function n(a){return Vl(a,e)}if(0<lr.length){Vl(lr[0],e);for(var s=1;s<lr.length;s++){var l=lr[s];l.blockedOn===e&&(l.blockedOn=null)}}for(ss!==null&&Vl(ss,e),ls!==null&&Vl(ls,e),as!==null&&Vl(as,e),Sa.forEach(n),_a.forEach(n),s=0;s<Jn.length;s++)l=Jn[s],l.blockedOn===e&&(l.blockedOn=null);for(;0<Jn.length&&(s=Jn[0],s.blockedOn===null);)Dp(s),s.blockedOn===null&&Jn.shift()}var Il=Qn.ReactCurrentBatchConfig,Wr=!0;function Rm(e,n,s,l){var a=we,r=Il.transition;Il.transition=null;try{we=1,Td(e,n,s,l)}finally{we=a,Il.transition=r}}function Dm(e,n,s,l){var a=we,r=Il.transition;Il.transition=null;try{we=4,Td(e,n,s,l)}finally{we=a,Il.transition=r}}function Td(e,n,s,l){if(Wr){var a=Bo(e,n,s,l);if(a===null)ao(e,n,l,Nr,s),Dc(e,l);else if(Am(a,e,n,s,l))l.stopPropagation();else if(Dc(e,l),n&4&&-1<Tm.indexOf(e)){for(;a!==null;){var r=Ua(a);if(r!==null&&Tp(r),r=Bo(e,n,s,l),r===null&&ao(e,n,l,Nr,s),r===a)break;a=r}a!==null&&l.stopPropagation()}else ao(e,n,l,null,s)}}var Nr=null;function Bo(e,n,s,l){if(Nr=null,e=Cd(l),e=As(e),e!==null)if(n=Hs(e),n===null)e=null;else if(s=n.tag,s===13){if(e=Sp(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 Nr=e,null}function Op(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(bm()){case zd:return 1;case Cp:return 4;case Or:case Sm:return 16;case zp:return 536870912;default:return 16}default:return 16}}var Zn=null,Ad=null,Sr=null;function Lp(){if(Sr)return Sr;var e,n=Ad,s=n.length,l,a="value"in Zn?Zn.value:Zn.textContent,r=a.length;for(e=0;e<s&&n[e]===a[e];e++);var i=s-e;for(l=1;l<=i&&n[s-l]===a[r-l];l++);return Sr=a.slice(e,1<l?1-l:void 0)}function _r(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 ar(){return!0}function Lc(){return!1}function Gt(e){function n(s,l,a,r,i){this._reactName=s,this._targetInst=a,this.type=l,this.nativeEvent=r,this.target=i,this.currentTarget=null;for(var d in e)e.hasOwnProperty(d)&&(s=e[d],this[d]=s?s(r):r[d]);return this.isDefaultPrevented=(r.defaultPrevented!=null?r.defaultPrevented:r.returnValue===!1)?ar:Lc,this.isPropagationStopped=Lc,this}return $e(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=ar)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=ar)},persist:function(){},isPersistent:ar}),n}var Ul={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Pd=Gt(Ul),$a=$e({},Ul,{view:0,detail:0}),Om=Gt($a),qi,Ji,Zl,ri=$e({},$a,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Rd,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!==Zl&&(Zl&&e.type==="mousemove"?(qi=e.screenX-Zl.screenX,Ji=e.screenY-Zl.screenY):Ji=qi=0,Zl=e),qi)},movementY:function(e){return"movementY"in e?e.movementY:Ji}}),Wc=Gt(ri),Lm=$e({},ri,{dataTransfer:0}),Wm=Gt(Lm),Nm=$e({},$a,{relatedTarget:0}),Vi=Gt(Nm),Bm=$e({},Ul,{animationName:0,elapsedTime:0,pseudoElement:0}),$m=Gt(Bm),Um=$e({},Ul,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Mm=Gt(Um),Fm=$e({},Ul,{data:0}),Nc=Gt(Fm),Hm={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Gm={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"},Qm={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Km(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=Qm[e])?!!n[e]:!1}function Rd(){return Km}var Ym=$e({},$a,{key:function(e){if(e.key){var n=Hm[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=_r(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Gm[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Rd,charCode:function(e){return e.type==="keypress"?_r(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?_r(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Xm=Gt(Ym),qm=$e({},ri,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Bc=Gt(qm),Jm=$e({},$a,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Rd}),Vm=Gt(Jm),Zm=$e({},Ul,{propertyName:0,elapsedTime:0,pseudoElement:0}),ex=Gt(Zm),tx=$e({},ri,{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}),nx=Gt(tx),sx=[9,13,27,32],Dd=Mn&&"CompositionEvent"in window,pa=null;Mn&&"documentMode"in document&&(pa=document.documentMode);var lx=Mn&&"TextEvent"in window&&!pa,Wp=Mn&&(!Dd||pa&&8<pa&&11>=pa),$c=" ",Uc=!1;function Np(e,n){switch(e){case"keyup":return sx.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var hl=!1;function ax(e,n){switch(e){case"compositionend":return Bp(n);case"keypress":return n.which!==32?null:(Uc=!0,$c);case"textInput":return e=n.data,e===$c&&Uc?null:e;default:return null}}function rx(e,n){if(hl)return e==="compositionend"||!Dd&&Np(e,n)?(e=Lp(),Sr=Ad=Zn=null,hl=!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 Wp&&n.locale!=="ko"?null:n.data;default:return null}}var ix={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 Mc(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!ix[e.type]:n==="textarea"}function $p(e,n,s,l){xp(l),n=Br(n,"onChange"),0<n.length&&(s=new Pd("onChange","change",null,s,l),e.push({event:s,listeners:n}))}var fa=null,ka=null;function ox(e){Jp(e,0)}function ii(e){var n=xl(e);if(cp(n))return e}function dx(e,n){if(e==="change")return n}var Up=!1;if(Mn){var Zi;if(Mn){var eo="oninput"in document;if(!eo){var Fc=document.createElement("div");Fc.setAttribute("oninput","return;"),eo=typeof Fc.oninput=="function"}Zi=eo}else Zi=!1;Up=Zi&&(!document.documentMode||9<document.documentMode)}function Hc(){fa&&(fa.detachEvent("onpropertychange",Mp),ka=fa=null)}function Mp(e){if(e.propertyName==="value"&&ii(ka)){var n=[];$p(n,ka,e,Cd(e)),bp(ox,n)}}function cx(e,n,s){e==="focusin"?(Hc(),fa=n,ka=s,fa.attachEvent("onpropertychange",Mp)):e==="focusout"&&Hc()}function ux(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ii(ka)}function px(e,n){if(e==="click")return ii(n)}function fx(e,n){if(e==="input"||e==="change")return ii(n)}function hx(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var xn=typeof Object.is=="function"?Object.is:hx;function Ca(e,n){if(xn(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 a=s[l];if(!bo.call(n,a)||!xn(e[a],n[a]))return!1}return!0}function Gc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Qc(e,n){var s=Gc(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=Gc(s)}}function Fp(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Fp(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Hp(){for(var e=window,n=Pr();n instanceof e.HTMLIFrameElement;){try{var s=typeof n.contentWindow.location.href=="string"}catch{s=!1}if(s)e=n.contentWindow;else break;n=Pr(e.document)}return n}function Od(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 gx(e){var n=Hp(),s=e.focusedElem,l=e.selectionRange;if(n!==s&&s&&s.ownerDocument&&Fp(s.ownerDocument.documentElement,s)){if(l!==null&&Od(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 a=s.textContent.length,r=Math.min(l.start,a);l=l.end===void 0?r:Math.min(l.end,a),!e.extend&&r>l&&(a=l,l=r,r=a),a=Qc(s,r);var i=Qc(s,l);a&&i&&(e.rangeCount!==1||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(n=n.createRange(),n.setStart(a.node,a.offset),e.removeAllRanges(),r>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 mx=Mn&&"documentMode"in document&&11>=document.documentMode,gl=null,$o=null,ha=null,Uo=!1;function Kc(e,n,s){var l=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;Uo||gl==null||gl!==Pr(l)||(l=gl,"selectionStart"in l&&Od(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}),ha&&Ca(ha,l)||(ha=l,l=Br($o,"onSelect"),0<l.length&&(n=new Pd("onSelect","select",null,n,s),e.push({event:n,listeners:l}),n.target=gl)))}function rr(e,n){var s={};return s[e.toLowerCase()]=n.toLowerCase(),s["Webkit"+e]="webkit"+n,s["Moz"+e]="moz"+n,s}var ml={animationend:rr("Animation","AnimationEnd"),animationiteration:rr("Animation","AnimationIteration"),animationstart:rr("Animation","AnimationStart"),transitionend:rr("Transition","TransitionEnd")},to={},Gp={};Mn&&(Gp=document.createElement("div").style,"AnimationEvent"in window||(delete ml.animationend.animation,delete ml.animationiteration.animation,delete ml.animationstart.animation),"TransitionEvent"in window||delete ml.transitionend.transition);function oi(e){if(to[e])return to[e];if(!ml[e])return e;var n=ml[e],s;for(s in n)if(n.hasOwnProperty(s)&&s in Gp)return to[e]=n[s];return e}var Qp=oi("animationend"),Kp=oi("animationiteration"),Yp=oi("animationstart"),Xp=oi("transitionend"),qp=new Map,Yc="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 hs(e,n){qp.set(e,n),Fs(n,[e])}for(var no=0;no<Yc.length;no++){var so=Yc[no],xx=so.toLowerCase(),yx=so[0].toUpperCase()+so.slice(1);hs(xx,"on"+yx)}hs(Qp,"onAnimationEnd");hs(Kp,"onAnimationIteration");hs(Yp,"onAnimationStart");hs("dblclick","onDoubleClick");hs("focusin","onFocus");hs("focusout","onBlur");hs(Xp,"onTransitionEnd");Al("onMouseEnter",["mouseout","mouseover"]);Al("onMouseLeave",["mouseout","mouseover"]);Al("onPointerEnter",["pointerout","pointerover"]);Al("onPointerLeave",["pointerout","pointerover"]);Fs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Fs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Fs("onBeforeInput",["compositionend","keypress","textInput","paste"]);Fs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Fs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Fs("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var oa="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(" "),vx=new Set("cancel close invalid load scroll toggle".split(" ").concat(oa));function Xc(e,n,s){var l=e.type||"unknown-event";e.currentTarget=s,xm(l,n,void 0,e),e.currentTarget=null}function Jp(e,n){n=(n&4)!==0;for(var s=0;s<e.length;s++){var l=e[s],a=l.event;l=l.listeners;e:{var r=void 0;if(n)for(var i=l.length-1;0<=i;i--){var d=l[i],f=d.instance,p=d.currentTarget;if(d=d.listener,f!==r&&a.isPropagationStopped())break e;Xc(a,d,p),r=f}else for(i=0;i<l.length;i++){if(d=l[i],f=d.instance,p=d.currentTarget,d=d.listener,f!==r&&a.isPropagationStopped())break e;Xc(a,d,p),r=f}}}if(Dr)throw e=Lo,Dr=!1,Lo=null,e}function Te(e,n){var s=n[Qo];s===void 0&&(s=n[Qo]=new Set);var l=e+"__bubble";s.has(l)||(Vp(n,e,2,!1),s.add(l))}function lo(e,n,s){var l=0;n&&(l|=4),Vp(s,e,l,n)}var ir="_reactListening"+Math.random().toString(36).slice(2);function za(e){if(!e[ir]){e[ir]=!0,ap.forEach(function(s){s!=="selectionchange"&&(vx.has(s)||lo(s,!1,e),lo(s,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[ir]||(n[ir]=!0,lo("selectionchange",!1,n))}}function Vp(e,n,s,l){switch(Op(n)){case 1:var a=Rm;break;case 4:a=Dm;break;default:a=Td}s=a.bind(null,n,s,e),a=void 0,!Oo||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(a=!0),l?a!==void 0?e.addEventListener(n,s,{capture:!0,passive:a}):e.addEventListener(n,s,!0):a!==void 0?e.addEventListener(n,s,{passive:a}):e.addEventListener(n,s,!1)}function ao(e,n,s,l,a){var r=l;if(!(n&1)&&!(n&2)&&l!==null)e:for(;;){if(l===null)return;var i=l.tag;if(i===3||i===4){var d=l.stateNode.containerInfo;if(d===a||d.nodeType===8&&d.parentNode===a)break;if(i===4)for(i=l.return;i!==null;){var f=i.tag;if((f===3||f===4)&&(f=i.stateNode.containerInfo,f===a||f.nodeType===8&&f.parentNode===a))return;i=i.return}for(;d!==null;){if(i=As(d),i===null)return;if(f=i.tag,f===5||f===6){l=r=i;continue e}d=d.parentNode}}l=l.return}bp(function(){var p=r,k=Cd(s),j=[];e:{var S=qp.get(e);if(S!==void 0){var u=Pd,v=e;switch(e){case"keypress":if(_r(s)===0)break e;case"keydown":case"keyup":u=Xm;break;case"focusin":v="focus",u=Vi;break;case"focusout":v="blur",u=Vi;break;case"beforeblur":case"afterblur":u=Vi;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":u=Wc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":u=Wm;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":u=Vm;break;case Qp:case Kp:case Yp:u=$m;break;case Xp:u=ex;break;case"scroll":u=Om;break;case"wheel":u=nx;break;case"copy":case"cut":case"paste":u=Mm;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":u=Bc}var z=(n&4)!==0,C=!z&&e==="scroll",g=z?S!==null?S+"Capture":null:S;z=[];for(var o=p,h;o!==null;){h=o;var x=h.stateNode;if(h.tag===5&&x!==null&&(h=x,g!==null&&(x=ba(o,g),x!=null&&z.push(Ia(o,x,h)))),C)break;o=o.return}0<z.length&&(S=new u(S,v,null,s,k),j.push({event:S,listeners:z}))}}if(!(n&7)){e:{if(S=e==="mouseover"||e==="pointerover",u=e==="mouseout"||e==="pointerout",S&&s!==Ro&&(v=s.relatedTarget||s.fromElement)&&(As(v)||v[Fn]))break e;if((u||S)&&(S=k.window===k?k:(S=k.ownerDocument)?S.defaultView||S.parentWindow:window,u?(v=s.relatedTarget||s.toElement,u=p,v=v?As(v):null,v!==null&&(C=Hs(v),v!==C||v.tag!==5&&v.tag!==6)&&(v=null)):(u=null,v=p),u!==v)){if(z=Wc,x="onMouseLeave",g="onMouseEnter",o="mouse",(e==="pointerout"||e==="pointerover")&&(z=Bc,x="onPointerLeave",g="onPointerEnter",o="pointer"),C=u==null?S:xl(u),h=v==null?S:xl(v),S=new z(x,o+"leave",u,s,k),S.target=C,S.relatedTarget=h,x=null,As(k)===p&&(z=new z(g,o+"enter",v,s,k),z.target=h,z.relatedTarget=C,x=z),C=x,u&&v)t:{for(z=u,g=v,o=0,h=z;h;h=nl(h))o++;for(h=0,x=g;x;x=nl(x))h++;for(;0<o-h;)z=nl(z),o--;for(;0<h-o;)g=nl(g),h--;for(;o--;){if(z===g||g!==null&&z===g.alternate)break t;z=nl(z),g=nl(g)}z=null}else z=null;u!==null&&qc(j,S,u,z,!1),v!==null&&C!==null&&qc(j,C,v,z,!0)}}e:{if(S=p?xl(p):window,u=S.nodeName&&S.nodeName.toLowerCase(),u==="select"||u==="input"&&S.type==="file")var y=dx;else if(Mc(S))if(Up)y=fx;else{y=ux;var w=cx}else(u=S.nodeName)&&u.toLowerCase()==="input"&&(S.type==="checkbox"||S.type==="radio")&&(y=px);if(y&&(y=y(e,p))){$p(j,y,s,k);break e}w&&w(e,S,p),e==="focusout"&&(w=S._wrapperState)&&w.controlled&&S.type==="number"&&Io(S,"number",S.value)}switch(w=p?xl(p):window,e){case"focusin":(Mc(w)||w.contentEditable==="true")&&(gl=w,$o=p,ha=null);break;case"focusout":ha=$o=gl=null;break;case"mousedown":Uo=!0;break;case"contextmenu":case"mouseup":case"dragend":Uo=!1,Kc(j,s,k);break;case"selectionchange":if(mx)break;case"keydown":case"keyup":Kc(j,s,k)}var c;if(Dd)e:{switch(e){case"compositionstart":var b="onCompositionStart";break e;case"compositionend":b="onCompositionEnd";break e;case"compositionupdate":b="onCompositionUpdate";break e}b=void 0}else hl?Np(e,s)&&(b="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(b="onCompositionStart");b&&(Wp&&s.locale!=="ko"&&(hl||b!=="onCompositionStart"?b==="onCompositionEnd"&&hl&&(c=Lp()):(Zn=k,Ad="value"in Zn?Zn.value:Zn.textContent,hl=!0)),w=Br(p,b),0<w.length&&(b=new Nc(b,e,null,s,k),j.push({event:b,listeners:w}),c?b.data=c:(c=Bp(s),c!==null&&(b.data=c)))),(c=lx?ax(e,s):rx(e,s))&&(p=Br(p,"onBeforeInput"),0<p.length&&(k=new Nc("onBeforeInput","beforeinput",null,s,k),j.push({event:k,listeners:p}),k.data=c))}Jp(j,n)})}function Ia(e,n,s){return{instance:e,listener:n,currentTarget:s}}function Br(e,n){for(var s=n+"Capture",l=[];e!==null;){var a=e,r=a.stateNode;a.tag===5&&r!==null&&(a=r,r=ba(e,s),r!=null&&l.unshift(Ia(e,r,a)),r=ba(e,n),r!=null&&l.push(Ia(e,r,a))),e=e.return}return l}function nl(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function qc(e,n,s,l,a){for(var r=n._reactName,i=[];s!==null&&s!==l;){var d=s,f=d.alternate,p=d.stateNode;if(f!==null&&f===l)break;d.tag===5&&p!==null&&(d=p,a?(f=ba(s,r),f!=null&&i.unshift(Ia(s,f,d))):a||(f=ba(s,r),f!=null&&i.push(Ia(s,f,d)))),s=s.return}i.length!==0&&e.push({event:n,listeners:i})}var jx=/\r\n?/g,bx=/\u0000|\uFFFD/g;function Jc(e){return(typeof e=="string"?e:""+e).replace(jx,`
|
||
`).replace(bx,"")}function or(e,n,s){if(n=Jc(n),Jc(e)!==n&&s)throw Error(Y(425))}function $r(){}var Mo=null,Fo=null;function Ho(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 Go=typeof setTimeout=="function"?setTimeout:void 0,Sx=typeof clearTimeout=="function"?clearTimeout:void 0,Vc=typeof Promise=="function"?Promise:void 0,_x=typeof queueMicrotask=="function"?queueMicrotask:typeof Vc<"u"?function(e){return Vc.resolve(null).then(e).catch(wx)}:Go;function wx(e){setTimeout(function(){throw e})}function ro(e,n){var s=n,l=0;do{var a=s.nextSibling;if(e.removeChild(s),a&&a.nodeType===8)if(s=a.data,s==="/$"){if(l===0){e.removeChild(a),wa(n);return}l--}else s!=="$"&&s!=="$?"&&s!=="$!"||l++;s=a}while(s);wa(n)}function rs(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 Zc(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 Ml=Math.random().toString(36).slice(2),zn="__reactFiber$"+Ml,Ea="__reactProps$"+Ml,Fn="__reactContainer$"+Ml,Qo="__reactEvents$"+Ml,kx="__reactListeners$"+Ml,Cx="__reactHandles$"+Ml;function As(e){var n=e[zn];if(n)return n;for(var s=e.parentNode;s;){if(n=s[Fn]||s[zn]){if(s=n.alternate,n.child!==null||s!==null&&s.child!==null)for(e=Zc(e);e!==null;){if(s=e[zn])return s;e=Zc(e)}return n}e=s,s=e.parentNode}return null}function Ua(e){return e=e[zn]||e[Fn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function xl(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Y(33))}function di(e){return e[Ea]||null}var Ko=[],yl=-1;function gs(e){return{current:e}}function Ae(e){0>yl||(e.current=Ko[yl],Ko[yl]=null,yl--)}function ze(e,n){yl++,Ko[yl]=e.current,e.current=n}var ps={},bt=gs(ps),Ot=gs(!1),Ws=ps;function Pl(e,n){var s=e.type.contextTypes;if(!s)return ps;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var a={},r;for(r in s)a[r]=n[r];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=a),a}function Lt(e){return e=e.childContextTypes,e!=null}function Ur(){Ae(Ot),Ae(bt)}function eu(e,n,s){if(bt.current!==ps)throw Error(Y(168));ze(bt,n),ze(Ot,s)}function Zp(e,n,s){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return s;l=l.getChildContext();for(var a in l)if(!(a in n))throw Error(Y(108,cm(e)||"Unknown",a));return $e({},s,l)}function Mr(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ps,Ws=bt.current,ze(bt,e),ze(Ot,Ot.current),!0}function tu(e,n,s){var l=e.stateNode;if(!l)throw Error(Y(169));s?(e=Zp(e,n,Ws),l.__reactInternalMemoizedMergedChildContext=e,Ae(Ot),Ae(bt),ze(bt,e)):Ae(Ot),ze(Ot,s)}var Nn=null,ci=!1,io=!1;function ef(e){Nn===null?Nn=[e]:Nn.push(e)}function zx(e){ci=!0,ef(e)}function ms(){if(!io&&Nn!==null){io=!0;var e=0,n=we;try{var s=Nn;for(we=1;e<s.length;e++){var l=s[e];do l=l(!0);while(l!==null)}Nn=null,ci=!1}catch(a){throw Nn!==null&&(Nn=Nn.slice(e+1)),kp(zd,ms),a}finally{we=n,io=!1}}return null}var vl=[],jl=0,Fr=null,Hr=0,Xt=[],qt=0,Ns=null,Bn=1,$n="";function Es(e,n){vl[jl++]=Hr,vl[jl++]=Fr,Fr=e,Hr=n}function tf(e,n,s){Xt[qt++]=Bn,Xt[qt++]=$n,Xt[qt++]=Ns,Ns=e;var l=Bn;e=$n;var a=32-gn(l)-1;l&=~(1<<a),s+=1;var r=32-gn(n)+a;if(30<r){var i=a-a%5;r=(l&(1<<i)-1).toString(32),l>>=i,a-=i,Bn=1<<32-gn(n)+a|s<<a|l,$n=r+e}else Bn=1<<r|s<<a|l,$n=e}function Ld(e){e.return!==null&&(Es(e,1),tf(e,1,0))}function Wd(e){for(;e===Fr;)Fr=vl[--jl],vl[jl]=null,Hr=vl[--jl],vl[jl]=null;for(;e===Ns;)Ns=Xt[--qt],Xt[qt]=null,$n=Xt[--qt],Xt[qt]=null,Bn=Xt[--qt],Xt[qt]=null}var Mt=null,Ut=null,Le=!1,hn=null;function nf(e,n){var s=Jt(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 nu(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,Mt=e,Ut=rs(n.firstChild),!0):!1;case 6:return n=e.pendingProps===""||n.nodeType!==3?null:n,n!==null?(e.stateNode=n,Mt=e,Ut=null,!0):!1;case 13:return n=n.nodeType!==8?null:n,n!==null?(s=Ns!==null?{id:Bn,overflow:$n}:null,e.memoizedState={dehydrated:n,treeContext:s,retryLane:1073741824},s=Jt(18,null,null,0),s.stateNode=n,s.return=e,e.child=s,Mt=e,Ut=null,!0):!1;default:return!1}}function Yo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Xo(e){if(Le){var n=Ut;if(n){var s=n;if(!nu(e,n)){if(Yo(e))throw Error(Y(418));n=rs(s.nextSibling);var l=Mt;n&&nu(e,n)?nf(l,s):(e.flags=e.flags&-4097|2,Le=!1,Mt=e)}}else{if(Yo(e))throw Error(Y(418));e.flags=e.flags&-4097|2,Le=!1,Mt=e}}}function su(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Mt=e}function dr(e){if(e!==Mt)return!1;if(!Le)return su(e),Le=!0,!1;var n;if((n=e.tag!==3)&&!(n=e.tag!==5)&&(n=e.type,n=n!=="head"&&n!=="body"&&!Ho(e.type,e.memoizedProps)),n&&(n=Ut)){if(Yo(e))throw sf(),Error(Y(418));for(;n;)nf(e,n),n=rs(n.nextSibling)}if(su(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Y(317));e:{for(e=e.nextSibling,n=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"){if(n===0){Ut=rs(e.nextSibling);break e}n--}else s!=="$"&&s!=="$!"&&s!=="$?"||n++}e=e.nextSibling}Ut=null}}else Ut=Mt?rs(e.stateNode.nextSibling):null;return!0}function sf(){for(var e=Ut;e;)e=rs(e.nextSibling)}function Rl(){Ut=Mt=null,Le=!1}function Nd(e){hn===null?hn=[e]:hn.push(e)}var Ix=Qn.ReactCurrentBatchConfig;function ea(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(Y(309));var l=s.stateNode}if(!l)throw Error(Y(147,e));var a=l,r=""+e;return n!==null&&n.ref!==null&&typeof n.ref=="function"&&n.ref._stringRef===r?n.ref:(n=function(i){var d=a.refs;i===null?delete d[r]:d[r]=i},n._stringRef=r,n)}if(typeof e!="string")throw Error(Y(284));if(!s._owner)throw Error(Y(290,e))}return e}function cr(e,n){throw e=Object.prototype.toString.call(n),Error(Y(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e))}function lu(e){var n=e._init;return n(e._payload)}function lf(e){function n(g,o){if(e){var h=g.deletions;h===null?(g.deletions=[o],g.flags|=16):h.push(o)}}function s(g,o){if(!e)return null;for(;o!==null;)n(g,o),o=o.sibling;return null}function l(g,o){for(g=new Map;o!==null;)o.key!==null?g.set(o.key,o):g.set(o.index,o),o=o.sibling;return g}function a(g,o){return g=cs(g,o),g.index=0,g.sibling=null,g}function r(g,o,h){return g.index=h,e?(h=g.alternate,h!==null?(h=h.index,h<o?(g.flags|=2,o):h):(g.flags|=2,o)):(g.flags|=1048576,o)}function i(g){return e&&g.alternate===null&&(g.flags|=2),g}function d(g,o,h,x){return o===null||o.tag!==6?(o=go(h,g.mode,x),o.return=g,o):(o=a(o,h),o.return=g,o)}function f(g,o,h,x){var y=h.type;return y===fl?k(g,o,h.props.children,x,h.key):o!==null&&(o.elementType===y||typeof y=="object"&&y!==null&&y.$$typeof===Xn&&lu(y)===o.type)?(x=a(o,h.props),x.ref=ea(g,o,h),x.return=g,x):(x=Tr(h.type,h.key,h.props,null,g.mode,x),x.ref=ea(g,o,h),x.return=g,x)}function p(g,o,h,x){return o===null||o.tag!==4||o.stateNode.containerInfo!==h.containerInfo||o.stateNode.implementation!==h.implementation?(o=mo(h,g.mode,x),o.return=g,o):(o=a(o,h.children||[]),o.return=g,o)}function k(g,o,h,x,y){return o===null||o.tag!==7?(o=Ls(h,g.mode,x,y),o.return=g,o):(o=a(o,h),o.return=g,o)}function j(g,o,h){if(typeof o=="string"&&o!==""||typeof o=="number")return o=go(""+o,g.mode,h),o.return=g,o;if(typeof o=="object"&&o!==null){switch(o.$$typeof){case Za:return h=Tr(o.type,o.key,o.props,null,g.mode,h),h.ref=ea(g,null,o),h.return=g,h;case pl:return o=mo(o,g.mode,h),o.return=g,o;case Xn:var x=o._init;return j(g,x(o._payload),h)}if(ra(o)||Xl(o))return o=Ls(o,g.mode,h,null),o.return=g,o;cr(g,o)}return null}function S(g,o,h,x){var y=o!==null?o.key:null;if(typeof h=="string"&&h!==""||typeof h=="number")return y!==null?null:d(g,o,""+h,x);if(typeof h=="object"&&h!==null){switch(h.$$typeof){case Za:return h.key===y?f(g,o,h,x):null;case pl:return h.key===y?p(g,o,h,x):null;case Xn:return y=h._init,S(g,o,y(h._payload),x)}if(ra(h)||Xl(h))return y!==null?null:k(g,o,h,x,null);cr(g,h)}return null}function u(g,o,h,x,y){if(typeof x=="string"&&x!==""||typeof x=="number")return g=g.get(h)||null,d(o,g,""+x,y);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Za:return g=g.get(x.key===null?h:x.key)||null,f(o,g,x,y);case pl:return g=g.get(x.key===null?h:x.key)||null,p(o,g,x,y);case Xn:var w=x._init;return u(g,o,h,w(x._payload),y)}if(ra(x)||Xl(x))return g=g.get(h)||null,k(o,g,x,y,null);cr(o,x)}return null}function v(g,o,h,x){for(var y=null,w=null,c=o,b=o=0,A=null;c!==null&&b<h.length;b++){c.index>b?(A=c,c=null):A=c.sibling;var T=S(g,c,h[b],x);if(T===null){c===null&&(c=A);break}e&&c&&T.alternate===null&&n(g,c),o=r(T,o,b),w===null?y=T:w.sibling=T,w=T,c=A}if(b===h.length)return s(g,c),Le&&Es(g,b),y;if(c===null){for(;b<h.length;b++)c=j(g,h[b],x),c!==null&&(o=r(c,o,b),w===null?y=c:w.sibling=c,w=c);return Le&&Es(g,b),y}for(c=l(g,c);b<h.length;b++)A=u(c,g,b,h[b],x),A!==null&&(e&&A.alternate!==null&&c.delete(A.key===null?b:A.key),o=r(A,o,b),w===null?y=A:w.sibling=A,w=A);return e&&c.forEach(function(M){return n(g,M)}),Le&&Es(g,b),y}function z(g,o,h,x){var y=Xl(h);if(typeof y!="function")throw Error(Y(150));if(h=y.call(h),h==null)throw Error(Y(151));for(var w=y=null,c=o,b=o=0,A=null,T=h.next();c!==null&&!T.done;b++,T=h.next()){c.index>b?(A=c,c=null):A=c.sibling;var M=S(g,c,T.value,x);if(M===null){c===null&&(c=A);break}e&&c&&M.alternate===null&&n(g,c),o=r(M,o,b),w===null?y=M:w.sibling=M,w=M,c=A}if(T.done)return s(g,c),Le&&Es(g,b),y;if(c===null){for(;!T.done;b++,T=h.next())T=j(g,T.value,x),T!==null&&(o=r(T,o,b),w===null?y=T:w.sibling=T,w=T);return Le&&Es(g,b),y}for(c=l(g,c);!T.done;b++,T=h.next())T=u(c,g,b,T.value,x),T!==null&&(e&&T.alternate!==null&&c.delete(T.key===null?b:T.key),o=r(T,o,b),w===null?y=T:w.sibling=T,w=T);return e&&c.forEach(function(H){return n(g,H)}),Le&&Es(g,b),y}function C(g,o,h,x){if(typeof h=="object"&&h!==null&&h.type===fl&&h.key===null&&(h=h.props.children),typeof h=="object"&&h!==null){switch(h.$$typeof){case Za:e:{for(var y=h.key,w=o;w!==null;){if(w.key===y){if(y=h.type,y===fl){if(w.tag===7){s(g,w.sibling),o=a(w,h.props.children),o.return=g,g=o;break e}}else if(w.elementType===y||typeof y=="object"&&y!==null&&y.$$typeof===Xn&&lu(y)===w.type){s(g,w.sibling),o=a(w,h.props),o.ref=ea(g,w,h),o.return=g,g=o;break e}s(g,w);break}else n(g,w);w=w.sibling}h.type===fl?(o=Ls(h.props.children,g.mode,x,h.key),o.return=g,g=o):(x=Tr(h.type,h.key,h.props,null,g.mode,x),x.ref=ea(g,o,h),x.return=g,g=x)}return i(g);case pl:e:{for(w=h.key;o!==null;){if(o.key===w)if(o.tag===4&&o.stateNode.containerInfo===h.containerInfo&&o.stateNode.implementation===h.implementation){s(g,o.sibling),o=a(o,h.children||[]),o.return=g,g=o;break e}else{s(g,o);break}else n(g,o);o=o.sibling}o=mo(h,g.mode,x),o.return=g,g=o}return i(g);case Xn:return w=h._init,C(g,o,w(h._payload),x)}if(ra(h))return v(g,o,h,x);if(Xl(h))return z(g,o,h,x);cr(g,h)}return typeof h=="string"&&h!==""||typeof h=="number"?(h=""+h,o!==null&&o.tag===6?(s(g,o.sibling),o=a(o,h),o.return=g,g=o):(s(g,o),o=go(h,g.mode,x),o.return=g,g=o),i(g)):s(g,o)}return C}var Dl=lf(!0),af=lf(!1),Gr=gs(null),Qr=null,bl=null,Bd=null;function $d(){Bd=bl=Qr=null}function Ud(e){var n=Gr.current;Ae(Gr),e._currentValue=n}function qo(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 El(e,n){Qr=e,Bd=bl=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&n&&(Dt=!0),e.firstContext=null)}function en(e){var n=e._currentValue;if(Bd!==e)if(e={context:e,memoizedValue:n,next:null},bl===null){if(Qr===null)throw Error(Y(308));bl=e,Qr.dependencies={lanes:0,firstContext:e}}else bl=bl.next=e;return n}var Ps=null;function Md(e){Ps===null?Ps=[e]:Ps.push(e)}function rf(e,n,s,l){var a=n.interleaved;return a===null?(s.next=s,Md(n)):(s.next=a.next,a.next=s),n.interleaved=s,Hn(e,l)}function Hn(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 qn=!1;function Fd(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function of(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 Un(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function is(e,n,s){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,ye&2){var a=l.pending;return a===null?n.next=n:(n.next=a.next,a.next=n),l.pending=n,Hn(e,s)}return a=l.interleaved,a===null?(n.next=n,Md(l)):(n.next=a.next,a.next=n),l.interleaved=n,Hn(e,s)}function wr(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,Id(e,s)}}function au(e,n){var s=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,s===l)){var a=null,r=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};r===null?a=r=i:r=r.next=i,s=s.next}while(s!==null);r===null?a=r=n:r=r.next=n}else a=r=n;s={baseState:l.baseState,firstBaseUpdate:a,lastBaseUpdate:r,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 Kr(e,n,s,l){var a=e.updateQueue;qn=!1;var r=a.firstBaseUpdate,i=a.lastBaseUpdate,d=a.shared.pending;if(d!==null){a.shared.pending=null;var f=d,p=f.next;f.next=null,i===null?r=p:i.next=p,i=f;var k=e.alternate;k!==null&&(k=k.updateQueue,d=k.lastBaseUpdate,d!==i&&(d===null?k.firstBaseUpdate=p:d.next=p,k.lastBaseUpdate=f))}if(r!==null){var j=a.baseState;i=0,k=p=f=null,d=r;do{var S=d.lane,u=d.eventTime;if((l&S)===S){k!==null&&(k=k.next={eventTime:u,lane:0,tag:d.tag,payload:d.payload,callback:d.callback,next:null});e:{var v=e,z=d;switch(S=n,u=s,z.tag){case 1:if(v=z.payload,typeof v=="function"){j=v.call(u,j,S);break e}j=v;break e;case 3:v.flags=v.flags&-65537|128;case 0:if(v=z.payload,S=typeof v=="function"?v.call(u,j,S):v,S==null)break e;j=$e({},j,S);break e;case 2:qn=!0}}d.callback!==null&&d.lane!==0&&(e.flags|=64,S=a.effects,S===null?a.effects=[d]:S.push(d))}else u={eventTime:u,lane:S,tag:d.tag,payload:d.payload,callback:d.callback,next:null},k===null?(p=k=u,f=j):k=k.next=u,i|=S;if(d=d.next,d===null){if(d=a.shared.pending,d===null)break;S=d,d=S.next,S.next=null,a.lastBaseUpdate=S,a.shared.pending=null}}while(!0);if(k===null&&(f=j),a.baseState=f,a.firstBaseUpdate=p,a.lastBaseUpdate=k,n=a.shared.interleaved,n!==null){a=n;do i|=a.lane,a=a.next;while(a!==n)}else r===null&&(a.shared.lanes=0);$s|=i,e.lanes=i,e.memoizedState=j}}function ru(e,n,s){if(e=n.effects,n.effects=null,e!==null)for(n=0;n<e.length;n++){var l=e[n],a=l.callback;if(a!==null){if(l.callback=null,l=s,typeof a!="function")throw Error(Y(191,a));a.call(l)}}}var Ma={},En=gs(Ma),Ta=gs(Ma),Aa=gs(Ma);function Rs(e){if(e===Ma)throw Error(Y(174));return e}function Hd(e,n){switch(ze(Aa,n),ze(Ta,e),ze(En,Ma),e=n.nodeType,e){case 9:case 11:n=(n=n.documentElement)?n.namespaceURI:To(null,"");break;default:e=e===8?n.parentNode:n,n=e.namespaceURI||null,e=e.tagName,n=To(n,e)}Ae(En),ze(En,n)}function Ol(){Ae(En),Ae(Ta),Ae(Aa)}function df(e){Rs(Aa.current);var n=Rs(En.current),s=To(n,e.type);n!==s&&(ze(Ta,e),ze(En,s))}function Gd(e){Ta.current===e&&(Ae(En),Ae(Ta))}var Ne=gs(0);function Yr(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 oo=[];function Qd(){for(var e=0;e<oo.length;e++)oo[e]._workInProgressVersionPrimary=null;oo.length=0}var kr=Qn.ReactCurrentDispatcher,co=Qn.ReactCurrentBatchConfig,Bs=0,Be=null,it=null,ut=null,Xr=!1,ga=!1,Pa=0,Ex=0;function yt(){throw Error(Y(321))}function Kd(e,n){if(n===null)return!1;for(var s=0;s<n.length&&s<e.length;s++)if(!xn(e[s],n[s]))return!1;return!0}function Yd(e,n,s,l,a,r){if(Bs=r,Be=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,kr.current=e===null||e.memoizedState===null?Rx:Dx,e=s(l,a),ga){r=0;do{if(ga=!1,Pa=0,25<=r)throw Error(Y(301));r+=1,ut=it=null,n.updateQueue=null,kr.current=Ox,e=s(l,a)}while(ga)}if(kr.current=qr,n=it!==null&&it.next!==null,Bs=0,ut=it=Be=null,Xr=!1,n)throw Error(Y(300));return e}function Xd(){var e=Pa!==0;return Pa=0,e}function Cn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ut===null?Be.memoizedState=ut=e:ut=ut.next=e,ut}function tn(){if(it===null){var e=Be.alternate;e=e!==null?e.memoizedState:null}else e=it.next;var n=ut===null?Be.memoizedState:ut.next;if(n!==null)ut=n,it=e;else{if(e===null)throw Error(Y(310));it=e,e={memoizedState:it.memoizedState,baseState:it.baseState,baseQueue:it.baseQueue,queue:it.queue,next:null},ut===null?Be.memoizedState=ut=e:ut=ut.next=e}return ut}function Ra(e,n){return typeof n=="function"?n(e):n}function uo(e){var n=tn(),s=n.queue;if(s===null)throw Error(Y(311));s.lastRenderedReducer=e;var l=it,a=l.baseQueue,r=s.pending;if(r!==null){if(a!==null){var i=a.next;a.next=r.next,r.next=i}l.baseQueue=a=r,s.pending=null}if(a!==null){r=a.next,l=l.baseState;var d=i=null,f=null,p=r;do{var k=p.lane;if((Bs&k)===k)f!==null&&(f=f.next={lane:0,action:p.action,hasEagerState:p.hasEagerState,eagerState:p.eagerState,next:null}),l=p.hasEagerState?p.eagerState:e(l,p.action);else{var j={lane:k,action:p.action,hasEagerState:p.hasEagerState,eagerState:p.eagerState,next:null};f===null?(d=f=j,i=l):f=f.next=j,Be.lanes|=k,$s|=k}p=p.next}while(p!==null&&p!==r);f===null?i=l:f.next=d,xn(l,n.memoizedState)||(Dt=!0),n.memoizedState=l,n.baseState=i,n.baseQueue=f,s.lastRenderedState=l}if(e=s.interleaved,e!==null){a=e;do r=a.lane,Be.lanes|=r,$s|=r,a=a.next;while(a!==e)}else a===null&&(s.lanes=0);return[n.memoizedState,s.dispatch]}function po(e){var n=tn(),s=n.queue;if(s===null)throw Error(Y(311));s.lastRenderedReducer=e;var l=s.dispatch,a=s.pending,r=n.memoizedState;if(a!==null){s.pending=null;var i=a=a.next;do r=e(r,i.action),i=i.next;while(i!==a);xn(r,n.memoizedState)||(Dt=!0),n.memoizedState=r,n.baseQueue===null&&(n.baseState=r),s.lastRenderedState=r}return[r,l]}function cf(){}function uf(e,n){var s=Be,l=tn(),a=n(),r=!xn(l.memoizedState,a);if(r&&(l.memoizedState=a,Dt=!0),l=l.queue,qd(hf.bind(null,s,l,e),[e]),l.getSnapshot!==n||r||ut!==null&&ut.memoizedState.tag&1){if(s.flags|=2048,Da(9,ff.bind(null,s,l,a,n),void 0,null),pt===null)throw Error(Y(349));Bs&30||pf(s,n,a)}return a}function pf(e,n,s){e.flags|=16384,e={getSnapshot:n,value:s},n=Be.updateQueue,n===null?(n={lastEffect:null,stores:null},Be.updateQueue=n,n.stores=[e]):(s=n.stores,s===null?n.stores=[e]:s.push(e))}function ff(e,n,s,l){n.value=s,n.getSnapshot=l,gf(n)&&mf(e)}function hf(e,n,s){return s(function(){gf(n)&&mf(e)})}function gf(e){var n=e.getSnapshot;e=e.value;try{var s=n();return!xn(e,s)}catch{return!0}}function mf(e){var n=Hn(e,1);n!==null&&mn(n,e,1,-1)}function iu(e){var n=Cn();return typeof e=="function"&&(e=e()),n.memoizedState=n.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ra,lastRenderedState:e},n.queue=e,e=e.dispatch=Px.bind(null,Be,e),[n.memoizedState,e]}function Da(e,n,s,l){return e={tag:e,create:n,destroy:s,deps:l,next:null},n=Be.updateQueue,n===null?(n={lastEffect:null,stores:null},Be.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 xf(){return tn().memoizedState}function Cr(e,n,s,l){var a=Cn();Be.flags|=e,a.memoizedState=Da(1|n,s,void 0,l===void 0?null:l)}function ui(e,n,s,l){var a=tn();l=l===void 0?null:l;var r=void 0;if(it!==null){var i=it.memoizedState;if(r=i.destroy,l!==null&&Kd(l,i.deps)){a.memoizedState=Da(n,s,r,l);return}}Be.flags|=e,a.memoizedState=Da(1|n,s,r,l)}function ou(e,n){return Cr(8390656,8,e,n)}function qd(e,n){return ui(2048,8,e,n)}function yf(e,n){return ui(4,2,e,n)}function vf(e,n){return ui(4,4,e,n)}function jf(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 bf(e,n,s){return s=s!=null?s.concat([e]):null,ui(4,4,jf.bind(null,n,e),s)}function Jd(){}function Sf(e,n){var s=tn();n=n===void 0?null:n;var l=s.memoizedState;return l!==null&&n!==null&&Kd(n,l[1])?l[0]:(s.memoizedState=[e,n],e)}function _f(e,n){var s=tn();n=n===void 0?null:n;var l=s.memoizedState;return l!==null&&n!==null&&Kd(n,l[1])?l[0]:(e=e(),s.memoizedState=[e,n],e)}function wf(e,n,s){return Bs&21?(xn(s,n)||(s=Ip(),Be.lanes|=s,$s|=s,e.baseState=!0),n):(e.baseState&&(e.baseState=!1,Dt=!0),e.memoizedState=s)}function Tx(e,n){var s=we;we=s!==0&&4>s?s:4,e(!0);var l=co.transition;co.transition={};try{e(!1),n()}finally{we=s,co.transition=l}}function kf(){return tn().memoizedState}function Ax(e,n,s){var l=ds(e);if(s={lane:l,action:s,hasEagerState:!1,eagerState:null,next:null},Cf(e))zf(n,s);else if(s=rf(e,n,s,l),s!==null){var a=zt();mn(s,e,l,a),If(s,n,l)}}function Px(e,n,s){var l=ds(e),a={lane:l,action:s,hasEagerState:!1,eagerState:null,next:null};if(Cf(e))zf(n,a);else{var r=e.alternate;if(e.lanes===0&&(r===null||r.lanes===0)&&(r=n.lastRenderedReducer,r!==null))try{var i=n.lastRenderedState,d=r(i,s);if(a.hasEagerState=!0,a.eagerState=d,xn(d,i)){var f=n.interleaved;f===null?(a.next=a,Md(n)):(a.next=f.next,f.next=a),n.interleaved=a;return}}catch{}finally{}s=rf(e,n,a,l),s!==null&&(a=zt(),mn(s,e,l,a),If(s,n,l))}}function Cf(e){var n=e.alternate;return e===Be||n!==null&&n===Be}function zf(e,n){ga=Xr=!0;var s=e.pending;s===null?n.next=n:(n.next=s.next,s.next=n),e.pending=n}function If(e,n,s){if(s&4194240){var l=n.lanes;l&=e.pendingLanes,s|=l,n.lanes=s,Id(e,s)}}var qr={readContext:en,useCallback:yt,useContext:yt,useEffect:yt,useImperativeHandle:yt,useInsertionEffect:yt,useLayoutEffect:yt,useMemo:yt,useReducer:yt,useRef:yt,useState:yt,useDebugValue:yt,useDeferredValue:yt,useTransition:yt,useMutableSource:yt,useSyncExternalStore:yt,useId:yt,unstable_isNewReconciler:!1},Rx={readContext:en,useCallback:function(e,n){return Cn().memoizedState=[e,n===void 0?null:n],e},useContext:en,useEffect:ou,useImperativeHandle:function(e,n,s){return s=s!=null?s.concat([e]):null,Cr(4194308,4,jf.bind(null,n,e),s)},useLayoutEffect:function(e,n){return Cr(4194308,4,e,n)},useInsertionEffect:function(e,n){return Cr(4,2,e,n)},useMemo:function(e,n){var s=Cn();return n=n===void 0?null:n,e=e(),s.memoizedState=[e,n],e},useReducer:function(e,n,s){var l=Cn();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=Ax.bind(null,Be,e),[l.memoizedState,e]},useRef:function(e){var n=Cn();return e={current:e},n.memoizedState=e},useState:iu,useDebugValue:Jd,useDeferredValue:function(e){return Cn().memoizedState=e},useTransition:function(){var e=iu(!1),n=e[0];return e=Tx.bind(null,e[1]),Cn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,s){var l=Be,a=Cn();if(Le){if(s===void 0)throw Error(Y(407));s=s()}else{if(s=n(),pt===null)throw Error(Y(349));Bs&30||pf(l,n,s)}a.memoizedState=s;var r={value:s,getSnapshot:n};return a.queue=r,ou(hf.bind(null,l,r,e),[e]),l.flags|=2048,Da(9,ff.bind(null,l,r,s,n),void 0,null),s},useId:function(){var e=Cn(),n=pt.identifierPrefix;if(Le){var s=$n,l=Bn;s=(l&~(1<<32-gn(l)-1)).toString(32)+s,n=":"+n+"R"+s,s=Pa++,0<s&&(n+="H"+s.toString(32)),n+=":"}else s=Ex++,n=":"+n+"r"+s.toString(32)+":";return e.memoizedState=n},unstable_isNewReconciler:!1},Dx={readContext:en,useCallback:Sf,useContext:en,useEffect:qd,useImperativeHandle:bf,useInsertionEffect:yf,useLayoutEffect:vf,useMemo:_f,useReducer:uo,useRef:xf,useState:function(){return uo(Ra)},useDebugValue:Jd,useDeferredValue:function(e){var n=tn();return wf(n,it.memoizedState,e)},useTransition:function(){var e=uo(Ra)[0],n=tn().memoizedState;return[e,n]},useMutableSource:cf,useSyncExternalStore:uf,useId:kf,unstable_isNewReconciler:!1},Ox={readContext:en,useCallback:Sf,useContext:en,useEffect:qd,useImperativeHandle:bf,useInsertionEffect:yf,useLayoutEffect:vf,useMemo:_f,useReducer:po,useRef:xf,useState:function(){return po(Ra)},useDebugValue:Jd,useDeferredValue:function(e){var n=tn();return it===null?n.memoizedState=e:wf(n,it.memoizedState,e)},useTransition:function(){var e=po(Ra)[0],n=tn().memoizedState;return[e,n]},useMutableSource:cf,useSyncExternalStore:uf,useId:kf,unstable_isNewReconciler:!1};function pn(e,n){if(e&&e.defaultProps){n=$e({},n),e=e.defaultProps;for(var s in e)n[s]===void 0&&(n[s]=e[s]);return n}return n}function Jo(e,n,s,l){n=e.memoizedState,s=s(l,n),s=s==null?n:$e({},n,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var pi={isMounted:function(e){return(e=e._reactInternals)?Hs(e)===e:!1},enqueueSetState:function(e,n,s){e=e._reactInternals;var l=zt(),a=ds(e),r=Un(l,a);r.payload=n,s!=null&&(r.callback=s),n=is(e,r,a),n!==null&&(mn(n,e,a,l),wr(n,e,a))},enqueueReplaceState:function(e,n,s){e=e._reactInternals;var l=zt(),a=ds(e),r=Un(l,a);r.tag=1,r.payload=n,s!=null&&(r.callback=s),n=is(e,r,a),n!==null&&(mn(n,e,a,l),wr(n,e,a))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var s=zt(),l=ds(e),a=Un(s,l);a.tag=2,n!=null&&(a.callback=n),n=is(e,a,l),n!==null&&(mn(n,e,l,s),wr(n,e,l))}};function du(e,n,s,l,a,r,i){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,r,i):n.prototype&&n.prototype.isPureReactComponent?!Ca(s,l)||!Ca(a,r):!0}function Ef(e,n,s){var l=!1,a=ps,r=n.contextType;return typeof r=="object"&&r!==null?r=en(r):(a=Lt(n)?Ws:bt.current,l=n.contextTypes,r=(l=l!=null)?Pl(e,a):ps),n=new n(s,r),e.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,n.updater=pi,e.stateNode=n,n._reactInternals=e,l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=r),n}function cu(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&&pi.enqueueReplaceState(n,n.state,null)}function Vo(e,n,s,l){var a=e.stateNode;a.props=s,a.state=e.memoizedState,a.refs={},Fd(e);var r=n.contextType;typeof r=="object"&&r!==null?a.context=en(r):(r=Lt(n)?Ws:bt.current,a.context=Pl(e,r)),a.state=e.memoizedState,r=n.getDerivedStateFromProps,typeof r=="function"&&(Jo(e,n,r,s),a.state=e.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof a.getSnapshotBeforeUpdate=="function"||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(n=a.state,typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount(),n!==a.state&&pi.enqueueReplaceState(a,a.state,null),Kr(e,s,a,l),a.state=e.memoizedState),typeof a.componentDidMount=="function"&&(e.flags|=4194308)}function Ll(e,n){try{var s="",l=n;do s+=dm(l),l=l.return;while(l);var a=s}catch(r){a=`
|
||
Error generating stack: `+r.message+`
|
||
`+r.stack}return{value:e,source:n,stack:a,digest:null}}function fo(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 Lx=typeof WeakMap=="function"?WeakMap:Map;function Tf(e,n,s){s=Un(-1,s),s.tag=3,s.payload={element:null};var l=n.value;return s.callback=function(){Vr||(Vr=!0,dd=l),Zo(e,n)},s}function Af(e,n,s){s=Un(-1,s),s.tag=3;var l=e.type.getDerivedStateFromError;if(typeof l=="function"){var a=n.value;s.payload=function(){return l(a)},s.callback=function(){Zo(e,n)}}var r=e.stateNode;return r!==null&&typeof r.componentDidCatch=="function"&&(s.callback=function(){Zo(e,n),typeof l!="function"&&(os===null?os=new Set([this]):os.add(this));var i=n.stack;this.componentDidCatch(n.value,{componentStack:i!==null?i:""})}),s}function uu(e,n,s){var l=e.pingCache;if(l===null){l=e.pingCache=new Lx;var a=new Set;l.set(n,a)}else a=l.get(n),a===void 0&&(a=new Set,l.set(n,a));a.has(s)||(a.add(s),e=qx.bind(null,e,n,s),n.then(e,e))}function pu(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 fu(e,n,s,l,a){return e.mode&1?(e.flags|=65536,e.lanes=a,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=Un(-1,1),n.tag=2,is(s,n,1))),s.lanes|=1),e)}var Wx=Qn.ReactCurrentOwner,Dt=!1;function Ct(e,n,s,l){n.child=e===null?af(n,null,s,l):Dl(n,e.child,s,l)}function hu(e,n,s,l,a){s=s.render;var r=n.ref;return El(n,a),l=Yd(e,n,s,l,r,a),s=Xd(),e!==null&&!Dt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~a,Gn(e,n,a)):(Le&&s&&Ld(n),n.flags|=1,Ct(e,n,l,a),n.child)}function gu(e,n,s,l,a){if(e===null){var r=s.type;return typeof r=="function"&&!ac(r)&&r.defaultProps===void 0&&s.compare===null&&s.defaultProps===void 0?(n.tag=15,n.type=r,Pf(e,n,r,l,a)):(e=Tr(s.type,null,l,n,n.mode,a),e.ref=n.ref,e.return=n,n.child=e)}if(r=e.child,!(e.lanes&a)){var i=r.memoizedProps;if(s=s.compare,s=s!==null?s:Ca,s(i,l)&&e.ref===n.ref)return Gn(e,n,a)}return n.flags|=1,e=cs(r,l),e.ref=n.ref,e.return=n,n.child=e}function Pf(e,n,s,l,a){if(e!==null){var r=e.memoizedProps;if(Ca(r,l)&&e.ref===n.ref)if(Dt=!1,n.pendingProps=l=r,(e.lanes&a)!==0)e.flags&131072&&(Dt=!0);else return n.lanes=e.lanes,Gn(e,n,a)}return ed(e,n,s,l,a)}function Rf(e,n,s){var l=n.pendingProps,a=l.children,r=e!==null?e.memoizedState:null;if(l.mode==="hidden")if(!(n.mode&1))n.memoizedState={baseLanes:0,cachePool:null,transitions:null},ze(_l,$t),$t|=s;else{if(!(s&1073741824))return e=r!==null?r.baseLanes|s:s,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e,cachePool:null,transitions:null},n.updateQueue=null,ze(_l,$t),$t|=e,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=r!==null?r.baseLanes:s,ze(_l,$t),$t|=l}else r!==null?(l=r.baseLanes|s,n.memoizedState=null):l=s,ze(_l,$t),$t|=l;return Ct(e,n,a,s),n.child}function Df(e,n){var s=n.ref;(e===null&&s!==null||e!==null&&e.ref!==s)&&(n.flags|=512,n.flags|=2097152)}function ed(e,n,s,l,a){var r=Lt(s)?Ws:bt.current;return r=Pl(n,r),El(n,a),s=Yd(e,n,s,l,r,a),l=Xd(),e!==null&&!Dt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~a,Gn(e,n,a)):(Le&&l&&Ld(n),n.flags|=1,Ct(e,n,s,a),n.child)}function mu(e,n,s,l,a){if(Lt(s)){var r=!0;Mr(n)}else r=!1;if(El(n,a),n.stateNode===null)zr(e,n),Ef(n,s,l),Vo(n,s,l,a),l=!0;else if(e===null){var i=n.stateNode,d=n.memoizedProps;i.props=d;var f=i.context,p=s.contextType;typeof p=="object"&&p!==null?p=en(p):(p=Lt(s)?Ws:bt.current,p=Pl(n,p));var k=s.getDerivedStateFromProps,j=typeof k=="function"||typeof i.getSnapshotBeforeUpdate=="function";j||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(d!==l||f!==p)&&cu(n,i,l,p),qn=!1;var S=n.memoizedState;i.state=S,Kr(n,l,i,a),f=n.memoizedState,d!==l||S!==f||Ot.current||qn?(typeof k=="function"&&(Jo(n,s,k,l),f=n.memoizedState),(d=qn||du(n,s,d,l,S,f,p))?(j||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=f),i.props=l,i.state=f,i.context=p,l=d):(typeof i.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{i=n.stateNode,of(e,n),d=n.memoizedProps,p=n.type===n.elementType?d:pn(n.type,d),i.props=p,j=n.pendingProps,S=i.context,f=s.contextType,typeof f=="object"&&f!==null?f=en(f):(f=Lt(s)?Ws:bt.current,f=Pl(n,f));var u=s.getDerivedStateFromProps;(k=typeof u=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(d!==j||S!==f)&&cu(n,i,l,f),qn=!1,S=n.memoizedState,i.state=S,Kr(n,l,i,a);var v=n.memoizedState;d!==j||S!==v||Ot.current||qn?(typeof u=="function"&&(Jo(n,s,u,l),v=n.memoizedState),(p=qn||du(n,s,p,l,S,v,f)||!1)?(k||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(l,v,f),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(l,v,f)),typeof i.componentDidUpdate=="function"&&(n.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof i.componentDidUpdate!="function"||d===e.memoizedProps&&S===e.memoizedState||(n.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||d===e.memoizedProps&&S===e.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=v),i.props=l,i.state=v,i.context=f,l=p):(typeof i.componentDidUpdate!="function"||d===e.memoizedProps&&S===e.memoizedState||(n.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||d===e.memoizedProps&&S===e.memoizedState||(n.flags|=1024),l=!1)}return td(e,n,s,l,r,a)}function td(e,n,s,l,a,r){Df(e,n);var i=(n.flags&128)!==0;if(!l&&!i)return a&&tu(n,s,!1),Gn(e,n,r);l=n.stateNode,Wx.current=n;var d=i&&typeof s.getDerivedStateFromError!="function"?null:l.render();return n.flags|=1,e!==null&&i?(n.child=Dl(n,e.child,null,r),n.child=Dl(n,null,d,r)):Ct(e,n,d,r),n.memoizedState=l.state,a&&tu(n,s,!0),n.child}function Of(e){var n=e.stateNode;n.pendingContext?eu(e,n.pendingContext,n.pendingContext!==n.context):n.context&&eu(e,n.context,!1),Hd(e,n.containerInfo)}function xu(e,n,s,l,a){return Rl(),Nd(a),n.flags|=256,Ct(e,n,s,l),n.child}var nd={dehydrated:null,treeContext:null,retryLane:0};function sd(e){return{baseLanes:e,cachePool:null,transitions:null}}function Lf(e,n,s){var l=n.pendingProps,a=Ne.current,r=!1,i=(n.flags&128)!==0,d;if((d=i)||(d=e!==null&&e.memoizedState===null?!1:(a&2)!==0),d?(r=!0,n.flags&=-129):(e===null||e.memoizedState!==null)&&(a|=1),ze(Ne,a&1),e===null)return Xo(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,r?(l=n.mode,r=n.child,i={mode:"hidden",children:i},!(l&1)&&r!==null?(r.childLanes=0,r.pendingProps=i):r=gi(i,l,0,null),e=Ls(e,l,s,null),r.return=n,e.return=n,r.sibling=e,n.child=r,n.child.memoizedState=sd(s),n.memoizedState=nd,e):Vd(n,i));if(a=e.memoizedState,a!==null&&(d=a.dehydrated,d!==null))return Nx(e,n,i,l,d,a,s);if(r){r=l.fallback,i=n.mode,a=e.child,d=a.sibling;var f={mode:"hidden",children:l.children};return!(i&1)&&n.child!==a?(l=n.child,l.childLanes=0,l.pendingProps=f,n.deletions=null):(l=cs(a,f),l.subtreeFlags=a.subtreeFlags&14680064),d!==null?r=cs(d,r):(r=Ls(r,i,s,null),r.flags|=2),r.return=n,l.return=n,l.sibling=r,n.child=l,l=r,r=n.child,i=e.child.memoizedState,i=i===null?sd(s):{baseLanes:i.baseLanes|s,cachePool:null,transitions:i.transitions},r.memoizedState=i,r.childLanes=e.childLanes&~s,n.memoizedState=nd,l}return r=e.child,e=r.sibling,l=cs(r,{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 Vd(e,n){return n=gi({mode:"visible",children:n},e.mode,0,null),n.return=e,e.child=n}function ur(e,n,s,l){return l!==null&&Nd(l),Dl(n,e.child,null,s),e=Vd(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Nx(e,n,s,l,a,r,i){if(s)return n.flags&256?(n.flags&=-257,l=fo(Error(Y(422))),ur(e,n,i,l)):n.memoizedState!==null?(n.child=e.child,n.flags|=128,null):(r=l.fallback,a=n.mode,l=gi({mode:"visible",children:l.children},a,0,null),r=Ls(r,a,i,null),r.flags|=2,l.return=n,r.return=n,l.sibling=r,n.child=l,n.mode&1&&Dl(n,e.child,null,i),n.child.memoizedState=sd(i),n.memoizedState=nd,r);if(!(n.mode&1))return ur(e,n,i,null);if(a.data==="$!"){if(l=a.nextSibling&&a.nextSibling.dataset,l)var d=l.dgst;return l=d,r=Error(Y(419)),l=fo(r,l,void 0),ur(e,n,i,l)}if(d=(i&e.childLanes)!==0,Dt||d){if(l=pt,l!==null){switch(i&-i){case 4:a=2;break;case 16:a=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:a=32;break;case 536870912:a=268435456;break;default:a=0}a=a&(l.suspendedLanes|i)?0:a,a!==0&&a!==r.retryLane&&(r.retryLane=a,Hn(e,a),mn(l,e,a,-1))}return lc(),l=fo(Error(Y(421))),ur(e,n,i,l)}return a.data==="$?"?(n.flags|=128,n.child=e.child,n=Jx.bind(null,e),a._reactRetry=n,null):(e=r.treeContext,Ut=rs(a.nextSibling),Mt=n,Le=!0,hn=null,e!==null&&(Xt[qt++]=Bn,Xt[qt++]=$n,Xt[qt++]=Ns,Bn=e.id,$n=e.overflow,Ns=n),n=Vd(n,l.children),n.flags|=4096,n)}function yu(e,n,s){e.lanes|=n;var l=e.alternate;l!==null&&(l.lanes|=n),qo(e.return,n,s)}function ho(e,n,s,l,a){var r=e.memoizedState;r===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:s,tailMode:a}:(r.isBackwards=n,r.rendering=null,r.renderingStartTime=0,r.last=l,r.tail=s,r.tailMode=a)}function Wf(e,n,s){var l=n.pendingProps,a=l.revealOrder,r=l.tail;if(Ct(e,n,l.children,s),l=Ne.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&&yu(e,s,n);else if(e.tag===19)yu(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(ze(Ne,l),!(n.mode&1))n.memoizedState=null;else switch(a){case"forwards":for(s=n.child,a=null;s!==null;)e=s.alternate,e!==null&&Yr(e)===null&&(a=s),s=s.sibling;s=a,s===null?(a=n.child,n.child=null):(a=s.sibling,s.sibling=null),ho(n,!1,a,s,r);break;case"backwards":for(s=null,a=n.child,n.child=null;a!==null;){if(e=a.alternate,e!==null&&Yr(e)===null){n.child=a;break}e=a.sibling,a.sibling=s,s=a,a=e}ho(n,!0,s,null,r);break;case"together":ho(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function zr(e,n){!(n.mode&1)&&e!==null&&(e.alternate=null,n.alternate=null,n.flags|=2)}function Gn(e,n,s){if(e!==null&&(n.dependencies=e.dependencies),$s|=n.lanes,!(s&n.childLanes))return null;if(e!==null&&n.child!==e.child)throw Error(Y(153));if(n.child!==null){for(e=n.child,s=cs(e,e.pendingProps),n.child=s,s.return=n;e.sibling!==null;)e=e.sibling,s=s.sibling=cs(e,e.pendingProps),s.return=n;s.sibling=null}return n.child}function Bx(e,n,s){switch(n.tag){case 3:Of(n),Rl();break;case 5:df(n);break;case 1:Lt(n.type)&&Mr(n);break;case 4:Hd(n,n.stateNode.containerInfo);break;case 10:var l=n.type._context,a=n.memoizedProps.value;ze(Gr,l._currentValue),l._currentValue=a;break;case 13:if(l=n.memoizedState,l!==null)return l.dehydrated!==null?(ze(Ne,Ne.current&1),n.flags|=128,null):s&n.child.childLanes?Lf(e,n,s):(ze(Ne,Ne.current&1),e=Gn(e,n,s),e!==null?e.sibling:null);ze(Ne,Ne.current&1);break;case 19:if(l=(s&n.childLanes)!==0,e.flags&128){if(l)return Wf(e,n,s);n.flags|=128}if(a=n.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),ze(Ne,Ne.current),l)break;return null;case 22:case 23:return n.lanes=0,Rf(e,n,s)}return Gn(e,n,s)}var Nf,ld,Bf,$f;Nf=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}};ld=function(){};Bf=function(e,n,s,l){var a=e.memoizedProps;if(a!==l){e=n.stateNode,Rs(En.current);var r=null;switch(s){case"input":a=Co(e,a),l=Co(e,l),r=[];break;case"select":a=$e({},a,{value:void 0}),l=$e({},l,{value:void 0}),r=[];break;case"textarea":a=Eo(e,a),l=Eo(e,l),r=[];break;default:typeof a.onClick!="function"&&typeof l.onClick=="function"&&(e.onclick=$r)}Ao(s,l);var i;s=null;for(p in a)if(!l.hasOwnProperty(p)&&a.hasOwnProperty(p)&&a[p]!=null)if(p==="style"){var d=a[p];for(i in d)d.hasOwnProperty(i)&&(s||(s={}),s[i]="")}else p!=="dangerouslySetInnerHTML"&&p!=="children"&&p!=="suppressContentEditableWarning"&&p!=="suppressHydrationWarning"&&p!=="autoFocus"&&(va.hasOwnProperty(p)?r||(r=[]):(r=r||[]).push(p,null));for(p in l){var f=l[p];if(d=a!=null?a[p]:void 0,l.hasOwnProperty(p)&&f!==d&&(f!=null||d!=null))if(p==="style")if(d){for(i in d)!d.hasOwnProperty(i)||f&&f.hasOwnProperty(i)||(s||(s={}),s[i]="");for(i in f)f.hasOwnProperty(i)&&d[i]!==f[i]&&(s||(s={}),s[i]=f[i])}else s||(r||(r=[]),r.push(p,s)),s=f;else p==="dangerouslySetInnerHTML"?(f=f?f.__html:void 0,d=d?d.__html:void 0,f!=null&&d!==f&&(r=r||[]).push(p,f)):p==="children"?typeof f!="string"&&typeof f!="number"||(r=r||[]).push(p,""+f):p!=="suppressContentEditableWarning"&&p!=="suppressHydrationWarning"&&(va.hasOwnProperty(p)?(f!=null&&p==="onScroll"&&Te("scroll",e),r||d===f||(r=[])):(r=r||[]).push(p,f))}s&&(r=r||[]).push("style",s);var p=r;(n.updateQueue=p)&&(n.flags|=4)}};$f=function(e,n,s,l){s!==l&&(n.flags|=4)};function ta(e,n){if(!Le)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 vt(e){var n=e.alternate!==null&&e.alternate.child===e.child,s=0,l=0;if(n)for(var a=e.child;a!==null;)s|=a.lanes|a.childLanes,l|=a.subtreeFlags&14680064,l|=a.flags&14680064,a.return=e,a=a.sibling;else for(a=e.child;a!==null;)s|=a.lanes|a.childLanes,l|=a.subtreeFlags,l|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=l,e.childLanes=s,n}function $x(e,n,s){var l=n.pendingProps;switch(Wd(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return vt(n),null;case 1:return Lt(n.type)&&Ur(),vt(n),null;case 3:return l=n.stateNode,Ol(),Ae(Ot),Ae(bt),Qd(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(dr(n)?n.flags|=4:e===null||e.memoizedState.isDehydrated&&!(n.flags&256)||(n.flags|=1024,hn!==null&&(pd(hn),hn=null))),ld(e,n),vt(n),null;case 5:Gd(n);var a=Rs(Aa.current);if(s=n.type,e!==null&&n.stateNode!=null)Bf(e,n,s,l,a),e.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!l){if(n.stateNode===null)throw Error(Y(166));return vt(n),null}if(e=Rs(En.current),dr(n)){l=n.stateNode,s=n.type;var r=n.memoizedProps;switch(l[zn]=n,l[Ea]=r,e=(n.mode&1)!==0,s){case"dialog":Te("cancel",l),Te("close",l);break;case"iframe":case"object":case"embed":Te("load",l);break;case"video":case"audio":for(a=0;a<oa.length;a++)Te(oa[a],l);break;case"source":Te("error",l);break;case"img":case"image":case"link":Te("error",l),Te("load",l);break;case"details":Te("toggle",l);break;case"input":zc(l,r),Te("invalid",l);break;case"select":l._wrapperState={wasMultiple:!!r.multiple},Te("invalid",l);break;case"textarea":Ec(l,r),Te("invalid",l)}Ao(s,r),a=null;for(var i in r)if(r.hasOwnProperty(i)){var d=r[i];i==="children"?typeof d=="string"?l.textContent!==d&&(r.suppressHydrationWarning!==!0&&or(l.textContent,d,e),a=["children",d]):typeof d=="number"&&l.textContent!==""+d&&(r.suppressHydrationWarning!==!0&&or(l.textContent,d,e),a=["children",""+d]):va.hasOwnProperty(i)&&d!=null&&i==="onScroll"&&Te("scroll",l)}switch(s){case"input":er(l),Ic(l,r,!0);break;case"textarea":er(l),Tc(l);break;case"select":case"option":break;default:typeof r.onClick=="function"&&(l.onclick=$r)}l=a,n.updateQueue=l,l!==null&&(n.flags|=4)}else{i=a.nodeType===9?a:a.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=fp(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[zn]=n,e[Ea]=l,Nf(e,n,!1,!1),n.stateNode=e;e:{switch(i=Po(s,l),s){case"dialog":Te("cancel",e),Te("close",e),a=l;break;case"iframe":case"object":case"embed":Te("load",e),a=l;break;case"video":case"audio":for(a=0;a<oa.length;a++)Te(oa[a],e);a=l;break;case"source":Te("error",e),a=l;break;case"img":case"image":case"link":Te("error",e),Te("load",e),a=l;break;case"details":Te("toggle",e),a=l;break;case"input":zc(e,l),a=Co(e,l),Te("invalid",e);break;case"option":a=l;break;case"select":e._wrapperState={wasMultiple:!!l.multiple},a=$e({},l,{value:void 0}),Te("invalid",e);break;case"textarea":Ec(e,l),a=Eo(e,l),Te("invalid",e);break;default:a=l}Ao(s,a),d=a;for(r in d)if(d.hasOwnProperty(r)){var f=d[r];r==="style"?mp(e,f):r==="dangerouslySetInnerHTML"?(f=f?f.__html:void 0,f!=null&&hp(e,f)):r==="children"?typeof f=="string"?(s!=="textarea"||f!=="")&&ja(e,f):typeof f=="number"&&ja(e,""+f):r!=="suppressContentEditableWarning"&&r!=="suppressHydrationWarning"&&r!=="autoFocus"&&(va.hasOwnProperty(r)?f!=null&&r==="onScroll"&&Te("scroll",e):f!=null&&Sd(e,r,f,i))}switch(s){case"input":er(e),Ic(e,l,!1);break;case"textarea":er(e),Tc(e);break;case"option":l.value!=null&&e.setAttribute("value",""+us(l.value));break;case"select":e.multiple=!!l.multiple,r=l.value,r!=null?kl(e,!!l.multiple,r,!1):l.defaultValue!=null&&kl(e,!!l.multiple,l.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=$r)}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 vt(n),null;case 6:if(e&&n.stateNode!=null)$f(e,n,e.memoizedProps,l);else{if(typeof l!="string"&&n.stateNode===null)throw Error(Y(166));if(s=Rs(Aa.current),Rs(En.current),dr(n)){if(l=n.stateNode,s=n.memoizedProps,l[zn]=n,(r=l.nodeValue!==s)&&(e=Mt,e!==null))switch(e.tag){case 3:or(l.nodeValue,s,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&or(l.nodeValue,s,(e.mode&1)!==0)}r&&(n.flags|=4)}else l=(s.nodeType===9?s:s.ownerDocument).createTextNode(l),l[zn]=n,n.stateNode=l}return vt(n),null;case 13:if(Ae(Ne),l=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Le&&Ut!==null&&n.mode&1&&!(n.flags&128))sf(),Rl(),n.flags|=98560,r=!1;else if(r=dr(n),l!==null&&l.dehydrated!==null){if(e===null){if(!r)throw Error(Y(318));if(r=n.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(Y(317));r[zn]=n}else Rl(),!(n.flags&128)&&(n.memoizedState=null),n.flags|=4;vt(n),r=!1}else hn!==null&&(pd(hn),hn=null),r=!0;if(!r)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||Ne.current&1?ot===0&&(ot=3):lc())),n.updateQueue!==null&&(n.flags|=4),vt(n),null);case 4:return Ol(),ld(e,n),e===null&&za(n.stateNode.containerInfo),vt(n),null;case 10:return Ud(n.type._context),vt(n),null;case 17:return Lt(n.type)&&Ur(),vt(n),null;case 19:if(Ae(Ne),r=n.memoizedState,r===null)return vt(n),null;if(l=(n.flags&128)!==0,i=r.rendering,i===null)if(l)ta(r,!1);else{if(ot!==0||e!==null&&e.flags&128)for(e=n.child;e!==null;){if(i=Yr(e),i!==null){for(n.flags|=128,ta(r,!1),l=i.updateQueue,l!==null&&(n.updateQueue=l,n.flags|=4),n.subtreeFlags=0,l=s,s=n.child;s!==null;)r=s,e=l,r.flags&=14680066,i=r.alternate,i===null?(r.childLanes=0,r.lanes=e,r.child=null,r.subtreeFlags=0,r.memoizedProps=null,r.memoizedState=null,r.updateQueue=null,r.dependencies=null,r.stateNode=null):(r.childLanes=i.childLanes,r.lanes=i.lanes,r.child=i.child,r.subtreeFlags=0,r.deletions=null,r.memoizedProps=i.memoizedProps,r.memoizedState=i.memoizedState,r.updateQueue=i.updateQueue,r.type=i.type,e=i.dependencies,r.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),s=s.sibling;return ze(Ne,Ne.current&1|2),n.child}e=e.sibling}r.tail!==null&&Ve()>Wl&&(n.flags|=128,l=!0,ta(r,!1),n.lanes=4194304)}else{if(!l)if(e=Yr(i),e!==null){if(n.flags|=128,l=!0,s=e.updateQueue,s!==null&&(n.updateQueue=s,n.flags|=4),ta(r,!0),r.tail===null&&r.tailMode==="hidden"&&!i.alternate&&!Le)return vt(n),null}else 2*Ve()-r.renderingStartTime>Wl&&s!==1073741824&&(n.flags|=128,l=!0,ta(r,!1),n.lanes=4194304);r.isBackwards?(i.sibling=n.child,n.child=i):(s=r.last,s!==null?s.sibling=i:n.child=i,r.last=i)}return r.tail!==null?(n=r.tail,r.rendering=n,r.tail=n.sibling,r.renderingStartTime=Ve(),n.sibling=null,s=Ne.current,ze(Ne,l?s&1|2:s&1),n):(vt(n),null);case 22:case 23:return sc(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&n.mode&1?$t&1073741824&&(vt(n),n.subtreeFlags&6&&(n.flags|=8192)):vt(n),null;case 24:return null;case 25:return null}throw Error(Y(156,n.tag))}function Ux(e,n){switch(Wd(n),n.tag){case 1:return Lt(n.type)&&Ur(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Ol(),Ae(Ot),Ae(bt),Qd(),e=n.flags,e&65536&&!(e&128)?(n.flags=e&-65537|128,n):null;case 5:return Gd(n),null;case 13:if(Ae(Ne),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(Y(340));Rl()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ae(Ne),null;case 4:return Ol(),null;case 10:return Ud(n.type._context),null;case 22:case 23:return sc(),null;case 24:return null;default:return null}}var pr=!1,jt=!1,Mx=typeof WeakSet=="function"?WeakSet:Set,J=null;function Sl(e,n){var s=e.ref;if(s!==null)if(typeof s=="function")try{s(null)}catch(l){Ke(e,n,l)}else s.current=null}function ad(e,n,s){try{s()}catch(l){Ke(e,n,l)}}var vu=!1;function Fx(e,n){if(Mo=Wr,e=Hp(),Od(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 a=l.anchorOffset,r=l.focusNode;l=l.focusOffset;try{s.nodeType,r.nodeType}catch{s=null;break e}var i=0,d=-1,f=-1,p=0,k=0,j=e,S=null;t:for(;;){for(var u;j!==s||a!==0&&j.nodeType!==3||(d=i+a),j!==r||l!==0&&j.nodeType!==3||(f=i+l),j.nodeType===3&&(i+=j.nodeValue.length),(u=j.firstChild)!==null;)S=j,j=u;for(;;){if(j===e)break t;if(S===s&&++p===a&&(d=i),S===r&&++k===l&&(f=i),(u=j.nextSibling)!==null)break;j=S,S=j.parentNode}j=u}s=d===-1||f===-1?null:{start:d,end:f}}else s=null}s=s||{start:0,end:0}}else s=null;for(Fo={focusedElem:e,selectionRange:s},Wr=!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 v=n.alternate;if(n.flags&1024)switch(n.tag){case 0:case 11:case 15:break;case 1:if(v!==null){var z=v.memoizedProps,C=v.memoizedState,g=n.stateNode,o=g.getSnapshotBeforeUpdate(n.elementType===n.type?z:pn(n.type,z),C);g.__reactInternalSnapshotBeforeUpdate=o}break;case 3:var h=n.stateNode.containerInfo;h.nodeType===1?h.textContent="":h.nodeType===9&&h.documentElement&&h.removeChild(h.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Y(163))}}catch(x){Ke(n,n.return,x)}if(e=n.sibling,e!==null){e.return=n.return,J=e;break}J=n.return}return v=vu,vu=!1,v}function ma(e,n,s){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var a=l=l.next;do{if((a.tag&e)===e){var r=a.destroy;a.destroy=void 0,r!==void 0&&ad(n,s,r)}a=a.next}while(a!==l)}}function fi(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 rd(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 Uf(e){var n=e.alternate;n!==null&&(e.alternate=null,Uf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[zn],delete n[Ea],delete n[Qo],delete n[kx],delete n[Cx])),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 Mf(e){return e.tag===5||e.tag===3||e.tag===4}function ju(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Mf(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 id(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=$r));else if(l!==4&&(e=e.child,e!==null))for(id(e,n,s),e=e.sibling;e!==null;)id(e,n,s),e=e.sibling}function od(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(od(e,n,s),e=e.sibling;e!==null;)od(e,n,s),e=e.sibling}var ht=null,fn=!1;function Kn(e,n,s){for(s=s.child;s!==null;)Ff(e,n,s),s=s.sibling}function Ff(e,n,s){if(In&&typeof In.onCommitFiberUnmount=="function")try{In.onCommitFiberUnmount(ai,s)}catch{}switch(s.tag){case 5:jt||Sl(s,n);case 6:var l=ht,a=fn;ht=null,Kn(e,n,s),ht=l,fn=a,ht!==null&&(fn?(e=ht,s=s.stateNode,e.nodeType===8?e.parentNode.removeChild(s):e.removeChild(s)):ht.removeChild(s.stateNode));break;case 18:ht!==null&&(fn?(e=ht,s=s.stateNode,e.nodeType===8?ro(e.parentNode,s):e.nodeType===1&&ro(e,s),wa(e)):ro(ht,s.stateNode));break;case 4:l=ht,a=fn,ht=s.stateNode.containerInfo,fn=!0,Kn(e,n,s),ht=l,fn=a;break;case 0:case 11:case 14:case 15:if(!jt&&(l=s.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){a=l=l.next;do{var r=a,i=r.destroy;r=r.tag,i!==void 0&&(r&2||r&4)&&ad(s,n,i),a=a.next}while(a!==l)}Kn(e,n,s);break;case 1:if(!jt&&(Sl(s,n),l=s.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=s.memoizedProps,l.state=s.memoizedState,l.componentWillUnmount()}catch(d){Ke(s,n,d)}Kn(e,n,s);break;case 21:Kn(e,n,s);break;case 22:s.mode&1?(jt=(l=jt)||s.memoizedState!==null,Kn(e,n,s),jt=l):Kn(e,n,s);break;default:Kn(e,n,s)}}function bu(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var s=e.stateNode;s===null&&(s=e.stateNode=new Mx),n.forEach(function(l){var a=Vx.bind(null,e,l);s.has(l)||(s.add(l),l.then(a,a))})}}function cn(e,n){var s=n.deletions;if(s!==null)for(var l=0;l<s.length;l++){var a=s[l];try{var r=e,i=n,d=i;e:for(;d!==null;){switch(d.tag){case 5:ht=d.stateNode,fn=!1;break e;case 3:ht=d.stateNode.containerInfo,fn=!0;break e;case 4:ht=d.stateNode.containerInfo,fn=!0;break e}d=d.return}if(ht===null)throw Error(Y(160));Ff(r,i,a),ht=null,fn=!1;var f=a.alternate;f!==null&&(f.return=null),a.return=null}catch(p){Ke(a,n,p)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)Hf(n,e),n=n.sibling}function Hf(e,n){var s=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(cn(n,e),Sn(e),l&4){try{ma(3,e,e.return),fi(3,e)}catch(z){Ke(e,e.return,z)}try{ma(5,e,e.return)}catch(z){Ke(e,e.return,z)}}break;case 1:cn(n,e),Sn(e),l&512&&s!==null&&Sl(s,s.return);break;case 5:if(cn(n,e),Sn(e),l&512&&s!==null&&Sl(s,s.return),e.flags&32){var a=e.stateNode;try{ja(a,"")}catch(z){Ke(e,e.return,z)}}if(l&4&&(a=e.stateNode,a!=null)){var r=e.memoizedProps,i=s!==null?s.memoizedProps:r,d=e.type,f=e.updateQueue;if(e.updateQueue=null,f!==null)try{d==="input"&&r.type==="radio"&&r.name!=null&&up(a,r),Po(d,i);var p=Po(d,r);for(i=0;i<f.length;i+=2){var k=f[i],j=f[i+1];k==="style"?mp(a,j):k==="dangerouslySetInnerHTML"?hp(a,j):k==="children"?ja(a,j):Sd(a,k,j,p)}switch(d){case"input":zo(a,r);break;case"textarea":pp(a,r);break;case"select":var S=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!r.multiple;var u=r.value;u!=null?kl(a,!!r.multiple,u,!1):S!==!!r.multiple&&(r.defaultValue!=null?kl(a,!!r.multiple,r.defaultValue,!0):kl(a,!!r.multiple,r.multiple?[]:"",!1))}a[Ea]=r}catch(z){Ke(e,e.return,z)}}break;case 6:if(cn(n,e),Sn(e),l&4){if(e.stateNode===null)throw Error(Y(162));a=e.stateNode,r=e.memoizedProps;try{a.nodeValue=r}catch(z){Ke(e,e.return,z)}}break;case 3:if(cn(n,e),Sn(e),l&4&&s!==null&&s.memoizedState.isDehydrated)try{wa(n.containerInfo)}catch(z){Ke(e,e.return,z)}break;case 4:cn(n,e),Sn(e);break;case 13:cn(n,e),Sn(e),a=e.child,a.flags&8192&&(r=a.memoizedState!==null,a.stateNode.isHidden=r,!r||a.alternate!==null&&a.alternate.memoizedState!==null||(tc=Ve())),l&4&&bu(e);break;case 22:if(k=s!==null&&s.memoizedState!==null,e.mode&1?(jt=(p=jt)||k,cn(n,e),jt=p):cn(n,e),Sn(e),l&8192){if(p=e.memoizedState!==null,(e.stateNode.isHidden=p)&&!k&&e.mode&1)for(J=e,k=e.child;k!==null;){for(j=J=k;J!==null;){switch(S=J,u=S.child,S.tag){case 0:case 11:case 14:case 15:ma(4,S,S.return);break;case 1:Sl(S,S.return);var v=S.stateNode;if(typeof v.componentWillUnmount=="function"){l=S,s=S.return;try{n=l,v.props=n.memoizedProps,v.state=n.memoizedState,v.componentWillUnmount()}catch(z){Ke(l,s,z)}}break;case 5:Sl(S,S.return);break;case 22:if(S.memoizedState!==null){_u(j);continue}}u!==null?(u.return=S,J=u):_u(j)}k=k.sibling}e:for(k=null,j=e;;){if(j.tag===5){if(k===null){k=j;try{a=j.stateNode,p?(r=a.style,typeof r.setProperty=="function"?r.setProperty("display","none","important"):r.display="none"):(d=j.stateNode,f=j.memoizedProps.style,i=f!=null&&f.hasOwnProperty("display")?f.display:null,d.style.display=gp("display",i))}catch(z){Ke(e,e.return,z)}}}else if(j.tag===6){if(k===null)try{j.stateNode.nodeValue=p?"":j.memoizedProps}catch(z){Ke(e,e.return,z)}}else if((j.tag!==22&&j.tag!==23||j.memoizedState===null||j===e)&&j.child!==null){j.child.return=j,j=j.child;continue}if(j===e)break e;for(;j.sibling===null;){if(j.return===null||j.return===e)break e;k===j&&(k=null),j=j.return}k===j&&(k=null),j.sibling.return=j.return,j=j.sibling}}break;case 19:cn(n,e),Sn(e),l&4&&bu(e);break;case 21:break;default:cn(n,e),Sn(e)}}function Sn(e){var n=e.flags;if(n&2){try{e:{for(var s=e.return;s!==null;){if(Mf(s)){var l=s;break e}s=s.return}throw Error(Y(160))}switch(l.tag){case 5:var a=l.stateNode;l.flags&32&&(ja(a,""),l.flags&=-33);var r=ju(e);od(e,r,a);break;case 3:case 4:var i=l.stateNode.containerInfo,d=ju(e);id(e,d,i);break;default:throw Error(Y(161))}}catch(f){Ke(e,e.return,f)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function Hx(e,n,s){J=e,Gf(e)}function Gf(e,n,s){for(var l=(e.mode&1)!==0;J!==null;){var a=J,r=a.child;if(a.tag===22&&l){var i=a.memoizedState!==null||pr;if(!i){var d=a.alternate,f=d!==null&&d.memoizedState!==null||jt;d=pr;var p=jt;if(pr=i,(jt=f)&&!p)for(J=a;J!==null;)i=J,f=i.child,i.tag===22&&i.memoizedState!==null?wu(a):f!==null?(f.return=i,J=f):wu(a);for(;r!==null;)J=r,Gf(r),r=r.sibling;J=a,pr=d,jt=p}Su(e)}else a.subtreeFlags&8772&&r!==null?(r.return=a,J=r):Su(e)}}function Su(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:jt||fi(5,n);break;case 1:var l=n.stateNode;if(n.flags&4&&!jt)if(s===null)l.componentDidMount();else{var a=n.elementType===n.type?s.memoizedProps:pn(n.type,s.memoizedProps);l.componentDidUpdate(a,s.memoizedState,l.__reactInternalSnapshotBeforeUpdate)}var r=n.updateQueue;r!==null&&ru(n,r,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}ru(n,i,s)}break;case 5:var d=n.stateNode;if(s===null&&n.flags&4){s=d;var f=n.memoizedProps;switch(n.type){case"button":case"input":case"select":case"textarea":f.autoFocus&&s.focus();break;case"img":f.src&&(s.src=f.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(n.memoizedState===null){var p=n.alternate;if(p!==null){var k=p.memoizedState;if(k!==null){var j=k.dehydrated;j!==null&&wa(j)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Y(163))}jt||n.flags&512&&rd(n)}catch(S){Ke(n,n.return,S)}}if(n===e){J=null;break}if(s=n.sibling,s!==null){s.return=n.return,J=s;break}J=n.return}}function _u(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 wu(e){for(;J!==null;){var n=J;try{switch(n.tag){case 0:case 11:case 15:var s=n.return;try{fi(4,n)}catch(f){Ke(n,s,f)}break;case 1:var l=n.stateNode;if(typeof l.componentDidMount=="function"){var a=n.return;try{l.componentDidMount()}catch(f){Ke(n,a,f)}}var r=n.return;try{rd(n)}catch(f){Ke(n,r,f)}break;case 5:var i=n.return;try{rd(n)}catch(f){Ke(n,i,f)}}}catch(f){Ke(n,n.return,f)}if(n===e){J=null;break}var d=n.sibling;if(d!==null){d.return=n.return,J=d;break}J=n.return}}var Gx=Math.ceil,Jr=Qn.ReactCurrentDispatcher,Zd=Qn.ReactCurrentOwner,Vt=Qn.ReactCurrentBatchConfig,ye=0,pt=null,st=null,gt=0,$t=0,_l=gs(0),ot=0,Oa=null,$s=0,hi=0,ec=0,xa=null,Rt=null,tc=0,Wl=1/0,Wn=null,Vr=!1,dd=null,os=null,fr=!1,es=null,Zr=0,ya=0,cd=null,Ir=-1,Er=0;function zt(){return ye&6?Ve():Ir!==-1?Ir:Ir=Ve()}function ds(e){return e.mode&1?ye&2&>!==0?gt&-gt:Ix.transition!==null?(Er===0&&(Er=Ip()),Er):(e=we,e!==0||(e=window.event,e=e===void 0?16:Op(e.type)),e):1}function mn(e,n,s,l){if(50<ya)throw ya=0,cd=null,Error(Y(185));Ba(e,s,l),(!(ye&2)||e!==pt)&&(e===pt&&(!(ye&2)&&(hi|=s),ot===4&&Vn(e,gt)),Wt(e,l),s===1&&ye===0&&!(n.mode&1)&&(Wl=Ve()+500,ci&&ms()))}function Wt(e,n){var s=e.callbackNode;Im(e,n);var l=Lr(e,e===pt?gt:0);if(l===0)s!==null&&Rc(s),e.callbackNode=null,e.callbackPriority=0;else if(n=l&-l,e.callbackPriority!==n){if(s!=null&&Rc(s),n===1)e.tag===0?zx(ku.bind(null,e)):ef(ku.bind(null,e)),_x(function(){!(ye&6)&&ms()}),s=null;else{switch(Ep(l)){case 1:s=zd;break;case 4:s=Cp;break;case 16:s=Or;break;case 536870912:s=zp;break;default:s=Or}s=Zf(s,Qf.bind(null,e))}e.callbackPriority=n,e.callbackNode=s}}function Qf(e,n){if(Ir=-1,Er=0,ye&6)throw Error(Y(327));var s=e.callbackNode;if(Tl()&&e.callbackNode!==s)return null;var l=Lr(e,e===pt?gt:0);if(l===0)return null;if(l&30||l&e.expiredLanes||n)n=ei(e,l);else{n=l;var a=ye;ye|=2;var r=Yf();(pt!==e||gt!==n)&&(Wn=null,Wl=Ve()+500,Os(e,n));do try{Yx();break}catch(d){Kf(e,d)}while(!0);$d(),Jr.current=r,ye=a,st!==null?n=0:(pt=null,gt=0,n=ot)}if(n!==0){if(n===2&&(a=Wo(e),a!==0&&(l=a,n=ud(e,a))),n===1)throw s=Oa,Os(e,0),Vn(e,l),Wt(e,Ve()),s;if(n===6)Vn(e,l);else{if(a=e.current.alternate,!(l&30)&&!Qx(a)&&(n=ei(e,l),n===2&&(r=Wo(e),r!==0&&(l=r,n=ud(e,r))),n===1))throw s=Oa,Os(e,0),Vn(e,l),Wt(e,Ve()),s;switch(e.finishedWork=a,e.finishedLanes=l,n){case 0:case 1:throw Error(Y(345));case 2:Ts(e,Rt,Wn);break;case 3:if(Vn(e,l),(l&130023424)===l&&(n=tc+500-Ve(),10<n)){if(Lr(e,0)!==0)break;if(a=e.suspendedLanes,(a&l)!==l){zt(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=Go(Ts.bind(null,e,Rt,Wn),n);break}Ts(e,Rt,Wn);break;case 4:if(Vn(e,l),(l&4194240)===l)break;for(n=e.eventTimes,a=-1;0<l;){var i=31-gn(l);r=1<<i,i=n[i],i>a&&(a=i),l&=~r}if(l=a,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Gx(l/1960))-l,10<l){e.timeoutHandle=Go(Ts.bind(null,e,Rt,Wn),l);break}Ts(e,Rt,Wn);break;case 5:Ts(e,Rt,Wn);break;default:throw Error(Y(329))}}}return Wt(e,Ve()),e.callbackNode===s?Qf.bind(null,e):null}function ud(e,n){var s=xa;return e.current.memoizedState.isDehydrated&&(Os(e,n).flags|=256),e=ei(e,n),e!==2&&(n=Rt,Rt=s,n!==null&&pd(n)),e}function pd(e){Rt===null?Rt=e:Rt.push.apply(Rt,e)}function Qx(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 a=s[l],r=a.getSnapshot;a=a.value;try{if(!xn(r(),a))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 Vn(e,n){for(n&=~ec,n&=~hi,e.suspendedLanes|=n,e.pingedLanes&=~n,e=e.expirationTimes;0<n;){var s=31-gn(n),l=1<<s;e[s]=-1,n&=~l}}function ku(e){if(ye&6)throw Error(Y(327));Tl();var n=Lr(e,0);if(!(n&1))return Wt(e,Ve()),null;var s=ei(e,n);if(e.tag!==0&&s===2){var l=Wo(e);l!==0&&(n=l,s=ud(e,l))}if(s===1)throw s=Oa,Os(e,0),Vn(e,n),Wt(e,Ve()),s;if(s===6)throw Error(Y(345));return e.finishedWork=e.current.alternate,e.finishedLanes=n,Ts(e,Rt,Wn),Wt(e,Ve()),null}function nc(e,n){var s=ye;ye|=1;try{return e(n)}finally{ye=s,ye===0&&(Wl=Ve()+500,ci&&ms())}}function Us(e){es!==null&&es.tag===0&&!(ye&6)&&Tl();var n=ye;ye|=1;var s=Vt.transition,l=we;try{if(Vt.transition=null,we=1,e)return e()}finally{we=l,Vt.transition=s,ye=n,!(ye&6)&&ms()}}function sc(){$t=_l.current,Ae(_l)}function Os(e,n){e.finishedWork=null,e.finishedLanes=0;var s=e.timeoutHandle;if(s!==-1&&(e.timeoutHandle=-1,Sx(s)),st!==null)for(s=st.return;s!==null;){var l=s;switch(Wd(l),l.tag){case 1:l=l.type.childContextTypes,l!=null&&Ur();break;case 3:Ol(),Ae(Ot),Ae(bt),Qd();break;case 5:Gd(l);break;case 4:Ol();break;case 13:Ae(Ne);break;case 19:Ae(Ne);break;case 10:Ud(l.type._context);break;case 22:case 23:sc()}s=s.return}if(pt=e,st=e=cs(e.current,null),gt=$t=n,ot=0,Oa=null,ec=hi=$s=0,Rt=xa=null,Ps!==null){for(n=0;n<Ps.length;n++)if(s=Ps[n],l=s.interleaved,l!==null){s.interleaved=null;var a=l.next,r=s.pending;if(r!==null){var i=r.next;r.next=a,l.next=i}s.pending=l}Ps=null}return e}function Kf(e,n){do{var s=st;try{if($d(),kr.current=qr,Xr){for(var l=Be.memoizedState;l!==null;){var a=l.queue;a!==null&&(a.pending=null),l=l.next}Xr=!1}if(Bs=0,ut=it=Be=null,ga=!1,Pa=0,Zd.current=null,s===null||s.return===null){ot=1,Oa=n,st=null;break}e:{var r=e,i=s.return,d=s,f=n;if(n=gt,d.flags|=32768,f!==null&&typeof f=="object"&&typeof f.then=="function"){var p=f,k=d,j=k.tag;if(!(k.mode&1)&&(j===0||j===11||j===15)){var S=k.alternate;S?(k.updateQueue=S.updateQueue,k.memoizedState=S.memoizedState,k.lanes=S.lanes):(k.updateQueue=null,k.memoizedState=null)}var u=pu(i);if(u!==null){u.flags&=-257,fu(u,i,d,r,n),u.mode&1&&uu(r,p,n),n=u,f=p;var v=n.updateQueue;if(v===null){var z=new Set;z.add(f),n.updateQueue=z}else v.add(f);break e}else{if(!(n&1)){uu(r,p,n),lc();break e}f=Error(Y(426))}}else if(Le&&d.mode&1){var C=pu(i);if(C!==null){!(C.flags&65536)&&(C.flags|=256),fu(C,i,d,r,n),Nd(Ll(f,d));break e}}r=f=Ll(f,d),ot!==4&&(ot=2),xa===null?xa=[r]:xa.push(r),r=i;do{switch(r.tag){case 3:r.flags|=65536,n&=-n,r.lanes|=n;var g=Tf(r,f,n);au(r,g);break e;case 1:d=f;var o=r.type,h=r.stateNode;if(!(r.flags&128)&&(typeof o.getDerivedStateFromError=="function"||h!==null&&typeof h.componentDidCatch=="function"&&(os===null||!os.has(h)))){r.flags|=65536,n&=-n,r.lanes|=n;var x=Af(r,d,n);au(r,x);break e}}r=r.return}while(r!==null)}qf(s)}catch(y){n=y,st===s&&s!==null&&(st=s=s.return);continue}break}while(!0)}function Yf(){var e=Jr.current;return Jr.current=qr,e===null?qr:e}function lc(){(ot===0||ot===3||ot===2)&&(ot=4),pt===null||!($s&268435455)&&!(hi&268435455)||Vn(pt,gt)}function ei(e,n){var s=ye;ye|=2;var l=Yf();(pt!==e||gt!==n)&&(Wn=null,Os(e,n));do try{Kx();break}catch(a){Kf(e,a)}while(!0);if($d(),ye=s,Jr.current=l,st!==null)throw Error(Y(261));return pt=null,gt=0,ot}function Kx(){for(;st!==null;)Xf(st)}function Yx(){for(;st!==null&&!vm();)Xf(st)}function Xf(e){var n=Vf(e.alternate,e,$t);e.memoizedProps=e.pendingProps,n===null?qf(e):st=n,Zd.current=null}function qf(e){var n=e;do{var s=n.alternate;if(e=n.return,n.flags&32768){if(s=Ux(s,n),s!==null){s.flags&=32767,st=s;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{ot=6,st=null;return}}else if(s=$x(s,n,$t),s!==null){st=s;return}if(n=n.sibling,n!==null){st=n;return}st=n=e}while(n!==null);ot===0&&(ot=5)}function Ts(e,n,s){var l=we,a=Vt.transition;try{Vt.transition=null,we=1,Xx(e,n,s,l)}finally{Vt.transition=a,we=l}return null}function Xx(e,n,s,l){do Tl();while(es!==null);if(ye&6)throw Error(Y(327));s=e.finishedWork;var a=e.finishedLanes;if(s===null)return null;if(e.finishedWork=null,e.finishedLanes=0,s===e.current)throw Error(Y(177));e.callbackNode=null,e.callbackPriority=0;var r=s.lanes|s.childLanes;if(Em(e,r),e===pt&&(st=pt=null,gt=0),!(s.subtreeFlags&2064)&&!(s.flags&2064)||fr||(fr=!0,Zf(Or,function(){return Tl(),null})),r=(s.flags&15990)!==0,s.subtreeFlags&15990||r){r=Vt.transition,Vt.transition=null;var i=we;we=1;var d=ye;ye|=4,Zd.current=null,Fx(e,s),Hf(s,e),gx(Fo),Wr=!!Mo,Fo=Mo=null,e.current=s,Hx(s),jm(),ye=d,we=i,Vt.transition=r}else e.current=s;if(fr&&(fr=!1,es=e,Zr=a),r=e.pendingLanes,r===0&&(os=null),_m(s.stateNode),Wt(e,Ve()),n!==null)for(l=e.onRecoverableError,s=0;s<n.length;s++)a=n[s],l(a.value,{componentStack:a.stack,digest:a.digest});if(Vr)throw Vr=!1,e=dd,dd=null,e;return Zr&1&&e.tag!==0&&Tl(),r=e.pendingLanes,r&1?e===cd?ya++:(ya=0,cd=e):ya=0,ms(),null}function Tl(){if(es!==null){var e=Ep(Zr),n=Vt.transition,s=we;try{if(Vt.transition=null,we=16>e?16:e,es===null)var l=!1;else{if(e=es,es=null,Zr=0,ye&6)throw Error(Y(331));var a=ye;for(ye|=4,J=e.current;J!==null;){var r=J,i=r.child;if(J.flags&16){var d=r.deletions;if(d!==null){for(var f=0;f<d.length;f++){var p=d[f];for(J=p;J!==null;){var k=J;switch(k.tag){case 0:case 11:case 15:ma(8,k,r)}var j=k.child;if(j!==null)j.return=k,J=j;else for(;J!==null;){k=J;var S=k.sibling,u=k.return;if(Uf(k),k===p){J=null;break}if(S!==null){S.return=u,J=S;break}J=u}}}var v=r.alternate;if(v!==null){var z=v.child;if(z!==null){v.child=null;do{var C=z.sibling;z.sibling=null,z=C}while(z!==null)}}J=r}}if(r.subtreeFlags&2064&&i!==null)i.return=r,J=i;else e:for(;J!==null;){if(r=J,r.flags&2048)switch(r.tag){case 0:case 11:case 15:ma(9,r,r.return)}var g=r.sibling;if(g!==null){g.return=r.return,J=g;break e}J=r.return}}var o=e.current;for(J=o;J!==null;){i=J;var h=i.child;if(i.subtreeFlags&2064&&h!==null)h.return=i,J=h;else e:for(i=o;J!==null;){if(d=J,d.flags&2048)try{switch(d.tag){case 0:case 11:case 15:fi(9,d)}}catch(y){Ke(d,d.return,y)}if(d===i){J=null;break e}var x=d.sibling;if(x!==null){x.return=d.return,J=x;break e}J=d.return}}if(ye=a,ms(),In&&typeof In.onPostCommitFiberRoot=="function")try{In.onPostCommitFiberRoot(ai,e)}catch{}l=!0}return l}finally{we=s,Vt.transition=n}}return!1}function Cu(e,n,s){n=Ll(s,n),n=Tf(e,n,1),e=is(e,n,1),n=zt(),e!==null&&(Ba(e,1,n),Wt(e,n))}function Ke(e,n,s){if(e.tag===3)Cu(e,e,s);else for(;n!==null;){if(n.tag===3){Cu(n,e,s);break}else if(n.tag===1){var l=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(os===null||!os.has(l))){e=Ll(s,e),e=Af(n,e,1),n=is(n,e,1),e=zt(),n!==null&&(Ba(n,1,e),Wt(n,e));break}}n=n.return}}function qx(e,n,s){var l=e.pingCache;l!==null&&l.delete(n),n=zt(),e.pingedLanes|=e.suspendedLanes&s,pt===e&&(gt&s)===s&&(ot===4||ot===3&&(gt&130023424)===gt&&500>Ve()-tc?Os(e,0):ec|=s),Wt(e,n)}function Jf(e,n){n===0&&(e.mode&1?(n=sr,sr<<=1,!(sr&130023424)&&(sr=4194304)):n=1);var s=zt();e=Hn(e,n),e!==null&&(Ba(e,n,s),Wt(e,s))}function Jx(e){var n=e.memoizedState,s=0;n!==null&&(s=n.retryLane),Jf(e,s)}function Vx(e,n){var s=0;switch(e.tag){case 13:var l=e.stateNode,a=e.memoizedState;a!==null&&(s=a.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(Y(314))}l!==null&&l.delete(n),Jf(e,s)}var Vf;Vf=function(e,n,s){if(e!==null)if(e.memoizedProps!==n.pendingProps||Ot.current)Dt=!0;else{if(!(e.lanes&s)&&!(n.flags&128))return Dt=!1,Bx(e,n,s);Dt=!!(e.flags&131072)}else Dt=!1,Le&&n.flags&1048576&&tf(n,Hr,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;zr(e,n),e=n.pendingProps;var a=Pl(n,bt.current);El(n,s),a=Yd(null,n,l,e,a,s);var r=Xd();return n.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Lt(l)?(r=!0,Mr(n)):r=!1,n.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Fd(n),a.updater=pi,n.stateNode=a,a._reactInternals=n,Vo(n,l,e,s),n=td(null,n,l,!0,r,s)):(n.tag=0,Le&&r&&Ld(n),Ct(null,n,a,s),n=n.child),n;case 16:l=n.elementType;e:{switch(zr(e,n),e=n.pendingProps,a=l._init,l=a(l._payload),n.type=l,a=n.tag=ey(l),e=pn(l,e),a){case 0:n=ed(null,n,l,e,s);break e;case 1:n=mu(null,n,l,e,s);break e;case 11:n=hu(null,n,l,e,s);break e;case 14:n=gu(null,n,l,pn(l.type,e),s);break e}throw Error(Y(306,l,""))}return n;case 0:return l=n.type,a=n.pendingProps,a=n.elementType===l?a:pn(l,a),ed(e,n,l,a,s);case 1:return l=n.type,a=n.pendingProps,a=n.elementType===l?a:pn(l,a),mu(e,n,l,a,s);case 3:e:{if(Of(n),e===null)throw Error(Y(387));l=n.pendingProps,r=n.memoizedState,a=r.element,of(e,n),Kr(n,l,null,s);var i=n.memoizedState;if(l=i.element,r.isDehydrated)if(r={element:l,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},n.updateQueue.baseState=r,n.memoizedState=r,n.flags&256){a=Ll(Error(Y(423)),n),n=xu(e,n,l,s,a);break e}else if(l!==a){a=Ll(Error(Y(424)),n),n=xu(e,n,l,s,a);break e}else for(Ut=rs(n.stateNode.containerInfo.firstChild),Mt=n,Le=!0,hn=null,s=af(n,null,l,s),n.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(Rl(),l===a){n=Gn(e,n,s);break e}Ct(e,n,l,s)}n=n.child}return n;case 5:return df(n),e===null&&Xo(n),l=n.type,a=n.pendingProps,r=e!==null?e.memoizedProps:null,i=a.children,Ho(l,a)?i=null:r!==null&&Ho(l,r)&&(n.flags|=32),Df(e,n),Ct(e,n,i,s),n.child;case 6:return e===null&&Xo(n),null;case 13:return Lf(e,n,s);case 4:return Hd(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=Dl(n,null,l,s):Ct(e,n,l,s),n.child;case 11:return l=n.type,a=n.pendingProps,a=n.elementType===l?a:pn(l,a),hu(e,n,l,a,s);case 7:return Ct(e,n,n.pendingProps,s),n.child;case 8:return Ct(e,n,n.pendingProps.children,s),n.child;case 12:return Ct(e,n,n.pendingProps.children,s),n.child;case 10:e:{if(l=n.type._context,a=n.pendingProps,r=n.memoizedProps,i=a.value,ze(Gr,l._currentValue),l._currentValue=i,r!==null)if(xn(r.value,i)){if(r.children===a.children&&!Ot.current){n=Gn(e,n,s);break e}}else for(r=n.child,r!==null&&(r.return=n);r!==null;){var d=r.dependencies;if(d!==null){i=r.child;for(var f=d.firstContext;f!==null;){if(f.context===l){if(r.tag===1){f=Un(-1,s&-s),f.tag=2;var p=r.updateQueue;if(p!==null){p=p.shared;var k=p.pending;k===null?f.next=f:(f.next=k.next,k.next=f),p.pending=f}}r.lanes|=s,f=r.alternate,f!==null&&(f.lanes|=s),qo(r.return,s,n),d.lanes|=s;break}f=f.next}}else if(r.tag===10)i=r.type===n.type?null:r.child;else if(r.tag===18){if(i=r.return,i===null)throw Error(Y(341));i.lanes|=s,d=i.alternate,d!==null&&(d.lanes|=s),qo(i,s,n),i=r.sibling}else i=r.child;if(i!==null)i.return=r;else for(i=r;i!==null;){if(i===n){i=null;break}if(r=i.sibling,r!==null){r.return=i.return,i=r;break}i=i.return}r=i}Ct(e,n,a.children,s),n=n.child}return n;case 9:return a=n.type,l=n.pendingProps.children,El(n,s),a=en(a),l=l(a),n.flags|=1,Ct(e,n,l,s),n.child;case 14:return l=n.type,a=pn(l,n.pendingProps),a=pn(l.type,a),gu(e,n,l,a,s);case 15:return Pf(e,n,n.type,n.pendingProps,s);case 17:return l=n.type,a=n.pendingProps,a=n.elementType===l?a:pn(l,a),zr(e,n),n.tag=1,Lt(l)?(e=!0,Mr(n)):e=!1,El(n,s),Ef(n,l,a),Vo(n,l,a,s),td(null,n,l,!0,e,s);case 19:return Wf(e,n,s);case 22:return Rf(e,n,s)}throw Error(Y(156,n.tag))};function Zf(e,n){return kp(e,n)}function Zx(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 Jt(e,n,s,l){return new Zx(e,n,s,l)}function ac(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ey(e){if(typeof e=="function")return ac(e)?1:0;if(e!=null){if(e=e.$$typeof,e===wd)return 11;if(e===kd)return 14}return 2}function cs(e,n){var s=e.alternate;return s===null?(s=Jt(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 Tr(e,n,s,l,a,r){var i=2;if(l=e,typeof e=="function")ac(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case fl:return Ls(s.children,a,r,n);case _d:i=8,a|=8;break;case So:return e=Jt(12,s,n,a|2),e.elementType=So,e.lanes=r,e;case _o:return e=Jt(13,s,n,a),e.elementType=_o,e.lanes=r,e;case wo:return e=Jt(19,s,n,a),e.elementType=wo,e.lanes=r,e;case op:return gi(s,a,r,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case rp:i=10;break e;case ip:i=9;break e;case wd:i=11;break e;case kd:i=14;break e;case Xn:i=16,l=null;break e}throw Error(Y(130,e==null?e:typeof e,""))}return n=Jt(i,s,n,a),n.elementType=e,n.type=l,n.lanes=r,n}function Ls(e,n,s,l){return e=Jt(7,e,l,n),e.lanes=s,e}function gi(e,n,s,l){return e=Jt(22,e,l,n),e.elementType=op,e.lanes=s,e.stateNode={isHidden:!1},e}function go(e,n,s){return e=Jt(6,e,null,n),e.lanes=s,e}function mo(e,n,s){return n=Jt(4,e.children!==null?e.children:[],e.key,n),n.lanes=s,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function ty(e,n,s,l,a){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=Xi(0),this.expirationTimes=Xi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Xi(0),this.identifierPrefix=l,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function rc(e,n,s,l,a,r,i,d,f){return e=new ty(e,n,s,d,f),n===1?(n=1,r===!0&&(n|=8)):n=0,r=Jt(3,null,null,n),e.current=r,r.stateNode=e,r.memoizedState={element:l,isDehydrated:s,cache:null,transitions:null,pendingSuspenseBoundaries:null},Fd(r),e}function ny(e,n,s){var l=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:pl,key:l==null?null:""+l,children:e,containerInfo:n,implementation:s}}function eh(e){if(!e)return ps;e=e._reactInternals;e:{if(Hs(e)!==e||e.tag!==1)throw Error(Y(170));var n=e;do{switch(n.tag){case 3:n=n.stateNode.context;break e;case 1:if(Lt(n.type)){n=n.stateNode.__reactInternalMemoizedMergedChildContext;break e}}n=n.return}while(n!==null);throw Error(Y(171))}if(e.tag===1){var s=e.type;if(Lt(s))return Zp(e,s,n)}return n}function th(e,n,s,l,a,r,i,d,f){return e=rc(s,l,!0,e,a,r,i,d,f),e.context=eh(null),s=e.current,l=zt(),a=ds(s),r=Un(l,a),r.callback=n??null,is(s,r,a),e.current.lanes=a,Ba(e,a,l),Wt(e,l),e}function mi(e,n,s,l){var a=n.current,r=zt(),i=ds(a);return s=eh(s),n.context===null?n.context=s:n.pendingContext=s,n=Un(r,i),n.payload={element:e},l=l===void 0?null:l,l!==null&&(n.callback=l),e=is(a,n,i),e!==null&&(mn(e,a,i,r),wr(e,a,i)),i}function ti(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 zu(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<n?s:n}}function ic(e,n){zu(e,n),(e=e.alternate)&&zu(e,n)}function sy(){return null}var nh=typeof reportError=="function"?reportError:function(e){console.error(e)};function oc(e){this._internalRoot=e}xi.prototype.render=oc.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(Y(409));mi(e,n,null,null)};xi.prototype.unmount=oc.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;Us(function(){mi(null,e,null,null)}),n[Fn]=null}};function xi(e){this._internalRoot=e}xi.prototype.unstable_scheduleHydration=function(e){if(e){var n=Pp();e={blockedOn:null,target:e,priority:n};for(var s=0;s<Jn.length&&n!==0&&n<Jn[s].priority;s++);Jn.splice(s,0,e),s===0&&Dp(e)}};function dc(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function yi(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Iu(){}function ly(e,n,s,l,a){if(a){if(typeof l=="function"){var r=l;l=function(){var p=ti(i);r.call(p)}}var i=th(n,l,e,0,null,!1,!1,"",Iu);return e._reactRootContainer=i,e[Fn]=i.current,za(e.nodeType===8?e.parentNode:e),Us(),i}for(;a=e.lastChild;)e.removeChild(a);if(typeof l=="function"){var d=l;l=function(){var p=ti(f);d.call(p)}}var f=rc(e,0,!1,null,null,!1,!1,"",Iu);return e._reactRootContainer=f,e[Fn]=f.current,za(e.nodeType===8?e.parentNode:e),Us(function(){mi(n,f,s,l)}),f}function vi(e,n,s,l,a){var r=s._reactRootContainer;if(r){var i=r;if(typeof a=="function"){var d=a;a=function(){var f=ti(i);d.call(f)}}mi(n,i,e,a)}else i=ly(s,n,e,a,l);return ti(i)}Tp=function(e){switch(e.tag){case 3:var n=e.stateNode;if(n.current.memoizedState.isDehydrated){var s=ia(n.pendingLanes);s!==0&&(Id(n,s|1),Wt(n,Ve()),!(ye&6)&&(Wl=Ve()+500,ms()))}break;case 13:Us(function(){var l=Hn(e,1);if(l!==null){var a=zt();mn(l,e,1,a)}}),ic(e,1)}};Ed=function(e){if(e.tag===13){var n=Hn(e,134217728);if(n!==null){var s=zt();mn(n,e,134217728,s)}ic(e,134217728)}};Ap=function(e){if(e.tag===13){var n=ds(e),s=Hn(e,n);if(s!==null){var l=zt();mn(s,e,n,l)}ic(e,n)}};Pp=function(){return we};Rp=function(e,n){var s=we;try{return we=e,n()}finally{we=s}};Do=function(e,n,s){switch(n){case"input":if(zo(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 a=di(l);if(!a)throw Error(Y(90));cp(l),zo(l,a)}}}break;case"textarea":pp(e,s);break;case"select":n=s.value,n!=null&&kl(e,!!s.multiple,n,!1)}};vp=nc;jp=Us;var ay={usingClientEntryPoint:!1,Events:[Ua,xl,di,xp,yp,nc]},na={findFiberByHostInstance:As,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ry={bundleType:na.bundleType,version:na.version,rendererPackageName:na.rendererPackageName,rendererConfig:na.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Qn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=_p(e),e===null?null:e.stateNode},findFiberByHostInstance:na.findFiberByHostInstance||sy,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 hr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!hr.isDisabled&&hr.supportsFiber)try{ai=hr.inject(ry),In=hr}catch{}}Ht.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ay;Ht.createPortal=function(e,n){var s=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!dc(n))throw Error(Y(200));return ny(e,n,null,s)};Ht.createRoot=function(e,n){if(!dc(e))throw Error(Y(299));var s=!1,l="",a=nh;return n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),n=rc(e,1,!1,null,null,s,!1,l,a),e[Fn]=n.current,za(e.nodeType===8?e.parentNode:e),new oc(n)};Ht.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(Y(188)):(e=Object.keys(e).join(","),Error(Y(268,e)));return e=_p(n),e=e===null?null:e.stateNode,e};Ht.flushSync=function(e){return Us(e)};Ht.hydrate=function(e,n,s){if(!yi(n))throw Error(Y(200));return vi(null,e,n,!0,s)};Ht.hydrateRoot=function(e,n,s){if(!dc(e))throw Error(Y(405));var l=s!=null&&s.hydratedSources||null,a=!1,r="",i=nh;if(s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(r=s.identifierPrefix),s.onRecoverableError!==void 0&&(i=s.onRecoverableError)),n=th(n,null,e,1,s??null,a,!1,r,i),e[Fn]=n.current,za(e),l)for(e=0;e<l.length;e++)s=l[e],a=s._getVersion,a=a(s._source),n.mutableSourceEagerHydrationData==null?n.mutableSourceEagerHydrationData=[s,a]:n.mutableSourceEagerHydrationData.push(s,a);return new xi(n)};Ht.render=function(e,n,s){if(!yi(n))throw Error(Y(200));return vi(null,e,n,!1,s)};Ht.unmountComponentAtNode=function(e){if(!yi(e))throw Error(Y(40));return e._reactRootContainer?(Us(function(){vi(null,null,e,!1,function(){e._reactRootContainer=null,e[Fn]=null})}),!0):!1};Ht.unstable_batchedUpdates=nc;Ht.unstable_renderSubtreeIntoContainer=function(e,n,s,l){if(!yi(s))throw Error(Y(200));if(e==null||e._reactInternals===void 0)throw Error(Y(38));return vi(e,n,s,!1,l)};Ht.version="18.3.1-next-f1338f8080-20240426";function sh(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(sh)}catch(e){console.error(e)}}sh(),np.exports=Ht;var iy=np.exports,lh,Eu=iy;lh=Eu.createRoot,Eu.hydrateRoot;const ue="",R={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",currency:"Currency"},X={bg:"#f5f6fa",accent:"#4f46e5",red:"#ef4444",orange:"#f59e0b",green:"#16a34a",purple:"#7c3aed",blue:"#2563eb",teal:"#0d9488",gray:"#94a3b8"},oy=[{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"}],ah=[{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"}],dy=new Set(["users","group-companies"]);function cy(e){return e!=="Admin"&&e!=="Auditor"&&e!=="CEO"?[]:ah.filter(({id:n})=>e==="Admin"||e==="CEO"||!dy.has(n))}const Yn=(e=[])=>[{key:"name1",label:"Name"},{key:"status",label:"Status"},...e,{key:"creation_date",label:"Created On"}],uy={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:Yn(),defaultColumns:["name1","status","creation_date"]},"idea-types":{label:"Idea Types",columns:Yn(),defaultColumns:["name1","status","creation_date"]},"order-types":{label:"Order Types",columns:Yn(),defaultColumns:["name1","status","creation_date"]},"process-types":{label:"Process Types",columns:Yn(),defaultColumns:["name1","status","creation_date"]},"incident-statuses":{label:"Incident Statuses",columns:Yn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"idea-statuses":{label:"Idea Statuses",columns:Yn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"order-statuses":{label:"Order Statuses",columns:Yn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"process-statuses":{label:"Process Statuses",columns:Yn([{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"]}},py=()=>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"})]}),fy=()=>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"})]}),hy=()=>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 dt({onView:e,onEdit:n,onDelete:s}){const l=(a,r,i,d,f,p)=>d?t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),d()},title:p,style:{width:30,height:30,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:"1px solid transparent",cursor:"pointer",background:a,color:i,flexShrink:0,transition:"all 0.15s ease"},onMouseEnter:k=>{k.currentTarget.style.background=r,k.currentTarget.style.transform="scale(1.08)"},onMouseLeave:k=>{k.currentTarget.style.background=a,k.currentTarget.style.transform="scale(1)"},children:f},p):null;return t.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[l("#f0f9ff","#e0f2fe","#0284c7",e,t.jsx(py,{}),"View"),l("#f0fdf4","#dcfce7","#16a34a",n,t.jsx(fy,{}),"Edit"),s&&l("#fff1f2","#fee2e2","#e11d48",s,t.jsx(hy,{}),"Delete")]})}const O={width:"100%",height:34,padding:"7px 10px",border:"1px solid #ddd",borderRadius:6,fontSize:12,boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif"},D={display:"block",marginBottom:5,fontSize:11,color:"#555",fontWeight:600};function rh(e){return e?e.custom_is_deleted===1||e.custom_is_deleted==="1"||e.custom_is_deleted===!0||e.is_deleted===1||e.is_deleted==="1"||e.is_deleted===!0||e.status==="Deleted"||e.custom_status==="Deleted":!1}function gy(e){return rh(e)?!1: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 be(e,n){return(e||[]).filter(s=>!rh(s)&&(gy(s)||s.name===n))}const my={incident:["Rejected","Executed & Closed"],idea:["Rejected","Executed & Closed"],order:["Closed"],process:["Closed"]};function ts(e,n){return!!n&&my[e].includes(n)}function Zt(e,n){return(e||[]).filter(s=>{if(!s)return!1;const l=s,a=l.organization||l.custom_organization;if(n.organization&&a&&a!==n.organization)return!1;const r=l.management||l.custom_management;if(n.management&&r&&r!==n.management)return!1;const i=l.department||l.custom_department;return!(n.department&&i&&i!==n.department)})}function Nl(e,n,s,l){return(e||[]).filter(a=>{const r=n[a.name]||[],i=a.custom_category||"",d=s==="SB Manager"&&i==="Manager"||s==="SB Employee"&&i==="Employee"||s==="SB Auditor"&&(i==="Auditor"||i==="X-Auditor")||s==="SB Admin"&&i==="Admin"||(s==="CEO"||s==="SB CEO")&&(i==="CEO"||i==="Chairman");return!((r.includes("SB Admin")||r.includes("System Manager")||i==="Admin")&&s!=="SB Admin"||!r.includes(s)&&!d||l&&a.custom_organization&&a.custom_organization!==l)})}const Bl={width:16,height:16,cursor:"pointer",accentColor:"#2563eb",flexShrink:0};function Ar(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 xy(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 La=(e,n)=>{let s;return typeof n=="object"&&n!==null?s=n:typeof n=="string"&&n.startsWith("#")?s=Ar(e):typeof n=="string"?s=Ar(n):s=Ar(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})},fs=e=>La(e,Ar(e)),cc=e=>La(e,xy(e));function Ze({deletedBy:e,deletedOn:n,reason:s,onRestore:l,onPermanentDelete:a,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]})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[l&&t.jsxs("button",{type:"button",onClick:l,disabled:r,style:{background:"#16a34a",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:i=>{r||(i.currentTarget.style.background="#15803d")},onMouseLeave:i=>{r||(i.currentTarget.style.background="#16a34a")},children:[t.jsx("span",{children:"↺"}),t.jsx("span",{children:r?"Restoring...":"Restore Record / استعادة"})]}),a&&t.jsxs("button",{type:"button",onClick:a,style:{background:"#dc2626",color:"white",border:"none",borderRadius:6,padding:"5px 12px",fontSize:11,fontWeight:700,cursor:"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:i=>{i.currentTarget.style.background="#b91c1c"},onMouseLeave:i=>{i.currentTarget.style.background="#dc2626"},children:[t.jsx("span",{children:"🗑️"}),t.jsx("span",{children:"Permanent Delete / حذف نهائي"})]})]})]})}function ji({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:a=>{n||(a.currentTarget.style.background="#b91c1c")},onMouseLeave:a=>{n||(a.currentTarget.style.background="#dc2626")},children:[t.jsx("span",{children:"🗑️"}),t.jsx("span",{children:l})]})]})}function oe({title:e,children:n,style:s}){return t.jsxs("div",{className:"form-card",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",{className:"form-card-title",style:{fontSize:14,fontWeight:700,color:"#1e293b",marginBottom:14,display:"flex",alignItems:"center",gap:8},children:t.jsx("span",{children:e})}),n]})}function bi({title:e="Status Summary",priority:n,createdDate:s,modifiedDate:l,assignedTo:a,status:r}){const i=d=>{if(!d)return"—";try{const f=new Date(d);return isNaN(f.getTime())?d:f.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return d}};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})]}),r&&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:r})]}),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:a?"#334155":"#94a3b8",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a||"—"})]}),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 yy="modulepreload",vy=function(e){return"/"+e},Tu={},jy=function(n,s,l){let a=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),d=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));a=Promise.allSettled(s.map(f=>{if(f=vy(f),f in Tu)return;Tu[f]=!0;const p=f.endsWith(".css"),k=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${k}`))return;const j=document.createElement("link");if(j.rel=p?"stylesheet":yy,p||(j.as="script"),j.crossOrigin="",j.href=f,d&&j.setAttribute("nonce",d),document.head.appendChild(j),p)return new Promise((S,u)=>{j.addEventListener("load",S),j.addEventListener("error",()=>u(new Error(`Unable to preload CSS for ${f}`)))})}))}function r(i){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=i,window.dispatchEvent(d),!d.defaultPrevented)throw i}return a.then(i=>{for(const d of i||[])d.status==="rejected"&&r(d.reason);return n().catch(r)})};function ih(e,n){const s=e[n.key];return s==null||s===""?"":typeof s=="object"?JSON.stringify(s):String(s)}function by(e,n){const s=URL.createObjectURL(e),l=document.createElement("a");l.href=s,l.download=n,l.click(),URL.revokeObjectURL(s)}function Sy(e,n,s){const l=e.map(i=>`"${i.label.replace(/"/g,'""')}"`).join(","),a=n.map(i=>e.map(d=>`"${ih(i,d).replace(/"/g,'""')}"`).join(",")).join(`
|
||
`),r=new Blob([l+`
|
||
`+a],{type:"text/csv;charset=utf-8;"});by(r,`${s}.csv`)}async function _y(e,n,s){const l=await jy(()=>import("./xlsx-D_0l8YDs.js"),[]),a=n.map(d=>{const f={};for(const p of e)f[p.label]=ih(d,p);return f}),r=l.utils.json_to_sheet(a,{header:e.map(d=>d.label)}),i=l.utils.book_new();l.utils.book_append_sheet(i,r,"Export"),l.writeFile(i,`${s}.xlsx`)}const _n="#16a34a";function wy({title:e,rows:n,selectedRows:s=[],pageRows:l=[],columns:a,defaultColumnKeys:r,filenameBase:i,onClose:d}){const[f,p]=_.useState(s.length>0?"selected":"all"),[k,j]=_.useState("csv"),[S,u]=_.useState(new Set(r)),[v,z]=_.useState("");_.useEffect(()=>{s&&s.length>0&&p("selected")},[s]);const C=f==="selected"?s:f==="page"?l:n,g=a.filter(b=>S.has(b.key)),o=v?a.filter(b=>b.label.toLowerCase().includes(v.toLowerCase())):a,h=b=>{u(A=>{const T=new Set(A);return T.has(b)?T.delete(b):T.add(b),T})},x=async()=>{g.length===0||C.length===0||(k==="csv"?Sy(g,C,i):await _y(g,C,i),d())},y={fontSize:11,fontWeight:700,color:"#9ca3af",letterSpacing:.4,textTransform:"uppercase",marginBottom:10},w={background:"none",border:"none",color:"#2563eb",fontSize:12,fontWeight:600,cursor:"pointer",padding:0,fontFamily:"inherit"},c=[{id:"selected",label:"Selected rows",sub:`${s.length} row${s.length!==1?"s":""} selected`,count:s.length,disabled:s.length===0},{id:"page",label:"Current page",sub:`${l.length} row${l.length!==1?"s":""} on this page`,count:l.length},{id:"all",label:"All records (current filters)",sub:`${n.length} total matching records`,count:n.length}];return t.jsx("div",{onClick:d,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:b=>b.stopPropagation(),style:{width:580,maxWidth:"92vw",maxHeight:"90vh",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:_n,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.jsxs("span",{style:{fontSize:12,fontWeight:400,opacity:.8},children:[a.length," fields available · ",S.size," selected"]})]}),t.jsx("button",{onClick:d,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,display:"flex",flexDirection:"column",gap:20},children:[t.jsxs("div",{children:[t.jsx("div",{style:y,children:"What to export"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:c.map(b=>t.jsxs("label",{onClick:()=>!b.disabled&&p(b.id),style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderRadius:10,cursor:b.disabled?"not-allowed":"pointer",border:`2px solid ${f===b.id?_n:"#e5e7eb"}`,background:f===b.id?"#f0fdf4":b.disabled?"#fafafa":"white",opacity:b.disabled?.5:1,transition:"border-color 0.15s, background 0.15s"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx("div",{style:{width:16,height:16,borderRadius:"50%",border:`2px solid ${f===b.id?_n:"#d1d5db"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:f===b.id&&t.jsx("div",{style:{width:7,height:7,borderRadius:"50%",background:_n}})}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#111827"},children:b.label}),t.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:1},children:b.sub})]})]}),t.jsx("span",{style:{background:f===b.id?_n:"#e5e7eb",color:f===b.id?"white":"#374151",fontSize:12,fontWeight:700,padding:"2px 10px",borderRadius:9999},children:b.count})]},b.id))})]}),t.jsxs("div",{children:[t.jsx("div",{style:y,children:"File Format"}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[{id:"csv",label:"CSV",desc:"Universal, works everywhere",icon:"📄"},{id:"xlsx",label:"Excel (.xlsx)",desc:"Native Excel workbook",icon:"📊"}].map(b=>t.jsxs("div",{onClick:()=>j(b.id),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",borderRadius:10,cursor:"pointer",border:`2px solid ${k===b.id?_n:"#e5e7eb"}`,background:k===b.id?"#f0fdf4":"white"},children:[t.jsx("div",{style:{width:16,height:16,borderRadius:"50%",border:`2px solid ${k===b.id?_n:"#d1d5db"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:k===b.id&&t.jsx("div",{style:{width:7,height:7,borderRadius:"50%",background:_n}})}),t.jsx("span",{style:{fontSize:20},children:b.icon}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:b.label}),t.jsx("div",{style:{fontSize:11,color:"#888"},children:b.desc})]})]},b.id))})]}),t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[t.jsx("div",{style:{...y,marginBottom:0},children:"Columns to Export"}),t.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[t.jsx("button",{onClick:()=>u(new Set(a.map(b=>b.key))),style:w,children:"All"}),t.jsx("span",{style:{color:"#d1d5db"},children:"|"}),t.jsx("button",{onClick:()=>u(new Set(r)),style:w,children:"Default"}),t.jsx("span",{style:{color:"#d1d5db"},children:"|"}),t.jsx("button",{onClick:()=>u(new Set),style:{...w,color:"#ef4444"},children:"None"})]})]}),t.jsx("div",{style:{marginBottom:8},children:t.jsx("input",{type:"text",placeholder:"Search fields...",value:v,onChange:b=>z(b.target.value),style:{width:"100%",padding:"7px 10px",borderRadius:8,border:"1px solid #e5e7eb",fontSize:12,boxSizing:"border-box",background:"#f9fafb"}})}),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(160px, 1fr))",gap:"10px 12px"},children:o.map(b=>t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:7,fontSize:13,color:"#374151",cursor:"pointer",padding:"3px 5px",borderRadius:5,background:S.has(b.key)?"#f0fdf4":"transparent"},children:[t.jsx("input",{type:"checkbox",checked:S.has(b.key),onChange:()=>h(b.key),style:{accentColor:_n,cursor:"pointer"}}),b.label]},b.key))})}),t.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:6},children:[S.size," of ",a.length," fields selected"]})]})]}),t.jsxs("div",{style:{padding:"14px 22px",borderTop:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[t.jsxs("span",{style:{fontSize:12,color:"#888"},children:["Exporting ",C.length," ",f==="selected"?"selected":f==="page"?"page":""," row",C.length!==1?"s":""]}),t.jsxs("div",{style:{display:"flex",gap:10},children:[t.jsx("button",{onClick:d,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:x,disabled:g.length===0||C.length===0,style:{padding:"9px 20px",borderRadius:8,border:"none",background:_n,color:"white",fontWeight:700,fontSize:13,cursor:g.length===0||C.length===0?"not-allowed":"pointer",opacity:g.length===0||C.length===0?.5:1,fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"})]})]})]})})}const oh="sidrah_rtl",fd="sidrah-lang-change";function wl(){try{return localStorage.getItem(oh)==="1"}catch{return!1}}function dh(){const e=!wl();try{localStorage.setItem(oh,e?"1":"0")}catch{}document.documentElement.setAttribute("dir",e?"rtl":"ltr"),document.documentElement.setAttribute("lang",e?"ar":"en-GB"),window.dispatchEvent(new CustomEvent(fd))}function se(){const[e,n]=_.useState(wl);return _.useEffect(()=>{const s=()=>n(wl());return window.addEventListener(fd,s),document.documentElement.setAttribute("dir",wl()?"rtl":"ltr"),document.documentElement.setAttribute("lang",wl()?"ar":"en-GB"),()=>window.removeEventListener(fd,s)},[]),e?Cy:ky}const ky={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 --",eventCategory:"Event Category",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"}},Cy={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:"-- اختر --",eventCategory:"فئة الحدث",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 Au({isOpen:e,doctype:n,docname:s,docTitle:l,isAdmin:a,isDeleting:r,onClose:i,onConfirmSoftDelete:d,onConfirmPermanentDelete:f}){const p=se(),[k,j]=_.useState("");if(_.useEffect(()=>{e&&j("")},[e]),_.useEffect(()=>{const u=v=>{v.key==="Escape"&&e&&!r&&i()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e,r,i]),!e)return null;const S=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:u=>{u.target===u.currentTarget&&!r&&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:p.deleteModal.title}),t.jsx("p",{style:{margin:"2px 0 0",fontSize:11,color:"#64748b",lineHeight:1.3},children:p.deleteModal.subtitle})]}),t.jsx("button",{type:"button",onClick:i,disabled:r,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:[S,":"]}),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:p.deleteModal.reasonLabel}),t.jsx("input",{type:"text",value:k,onChange:u=>j(u.target.value),placeholder:p.deleteModal.reasonPlaceholder,disabled:r,style:{width:"100%",height:30,padding:"4px 8px",border:"1px solid #cbd5e1",borderRadius:6,fontSize:12,boxSizing:"border-box",outline:"none"},onFocus:u=>{u.target.style.borderColor="#6366f1",u.target.style.boxShadow="0 0 0 2px rgba(99, 102, 241, 0.15)"},onBlur:u=>{u.target.style.borderColor="#cbd5e1",u.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:r,style:{padding:"5px 12px",borderRadius:6,border:"1px solid #cbd5e1",background:"#ffffff",color:"#475569",fontSize:12,fontWeight:600,cursor:r?"not-allowed":"pointer",transition:"background 0.15s"},children:p.deleteModal.cancelBtn}),t.jsxs("button",{type:"button",onClick:()=>d(k),disabled:r,title:p.deleteModal.softDeleteDesc,style:{padding:"5px 12px",borderRadius:6,border:"1px solid #fca5a5",background:"#fff1f2",color:"#b91c1c",fontSize:12,fontWeight:600,cursor:r?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:4,transition:"all 0.15s"},onMouseEnter:u=>{r||(u.currentTarget.style.background="#fee2e2")},onMouseLeave:u=>{r||(u.currentTarget.style.background="#fff1f2")},children:[t.jsx("span",{children:"🗑️"}),r?p.deleteModal.deleting:p.deleteModal.softDeleteBtn]}),a&&t.jsxs("button",{type:"button",onClick:()=>f(k),disabled:r,title:p.deleteModal.permanentDeleteDesc,style:{padding:"5px 12px",borderRadius:6,border:"none",background:"#ef4444",color:"#ffffff",fontSize:12,fontWeight:600,cursor:r?"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:u=>{r||(u.currentTarget.style.background="#dc2626")},onMouseLeave:u=>{r||(u.currentTarget.style.background="#ef4444")},children:[t.jsx("span",{children:"💥"}),r?p.deleteModal.deleting:p.deleteModal.permanentDeleteBtn]})]})]})})}const ch="/assets/logo-BlYgMyx5.png";function uh({collapsed:e,onToggleCollapsed:n,activePage:s,onNavigate:l,hasDashboard:a,hasReports:r,hasDelegations:i,role:d,hideSettings:f,rtl:p,navLabels:k,settingsLabel:j}){const S=f?[]:cy(d);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:ch,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"contain"},onError:u=>{u.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:p?"صدرة للأعمال":"Sidrah"})})]}),t.jsx("button",{type:"button",onClick:n,title:e?p?"توسيع":"Expand":p?"طي":"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:u=>{u.currentTarget.style.background="rgba(255, 255, 255, 0.15)",u.currentTarget.style.color="#ffffff"},onMouseLeave:u=>{u.currentTarget.style.background="rgba(255, 255, 255, 0.06)",u.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:[oy.filter(({id:u})=>(u!=="dashboard"||a)&&(u!=="reports"||r)&&(u!=="delegations"||i)).map(({id:u,icon:v})=>{const z=k[u]||u,C=u===s;return t.jsxs("div",{onClick:()=>l(u),title:e?z: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:C?"rgba(99, 102, 241, 0.28)":"transparent",border:C?"1px solid rgba(129, 140, 248, 0.35)":"1px solid transparent",borderRadius:8,fontSize:e?15:13,color:C?"#ffffff":"rgba(255, 255, 255, 0.78)",fontWeight:C?600:400,transition:"all 0.15s ease",whiteSpace:"nowrap",marginBottom:2,position:"relative"},onMouseEnter:g=>{C||(g.currentTarget.style.background="rgba(255, 255, 255, 0.08)",g.currentTarget.style.color="#ffffff")},onMouseLeave:g=>{C||(g.currentTarget.style.background="transparent",g.currentTarget.style.color="rgba(255, 255, 255, 0.78)")},children:[t.jsx("span",{style:{flexShrink:0,fontSize:e?15:13},children:v}),!e&&t.jsx("span",{children:z})]},u)}),S.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:j}),e&&t.jsx("div",{style:{margin:"10px auto",width:26,borderTop:"1px solid rgba(255, 255, 255, 0.12)"}}),S.map(({id:u,icon:v})=>{const z=k[u]||u,C=u===s;return t.jsxs("div",{onClick:()=>l(u),title:e?z: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:C?"rgba(99, 102, 241, 0.28)":"transparent",border:C?"1px solid rgba(129, 140, 248, 0.35)":"1px solid transparent",borderRadius:8,fontSize:e?15:13,color:C?"#ffffff":"rgba(255, 255, 255, 0.78)",fontWeight:C?600:400,transition:"all 0.15s ease",whiteSpace:"nowrap",marginBottom:2},onMouseEnter:g=>{C||(g.currentTarget.style.background="rgba(255, 255, 255, 0.08)",g.currentTarget.style.color="#ffffff")},onMouseLeave:g=>{C||(g.currentTarget.style.background="transparent",g.currentTarget.style.color="rgba(255, 255, 255, 0.78)")},children:[t.jsx("span",{style:{flexShrink:0,fontSize:e?15:13},children:v}),!e&&t.jsx("span",{children:z})]},u)})]})]})]})}const Fl=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 Ms="";async function uc(){try{const e=await fetch(`${ue}/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 Ms=s,s}}catch(e){console.error("CSRF fetch error:",e)}return Ms}async function nn(){return Ms||await uc(),Ms}function Wa(e,n){try{if(e!=null&&e._server_messages){const l=JSON.parse(e._server_messages);if(l.length){const a=JSON.parse(l[0]);if(a!=null&&a.message)return a.message.replace(/<[^>]+>/g,"").trim()}}}catch{}let s=(e==null?void 0:e.message)||(e==null?void 0:e.exception)||(e==null?void 0:e.exc)||n;if(typeof s=="string"&&s.includes("frappe.exceptions.")){const l=s.split(`
|
||
`).map(r=>r.trim()).filter(r=>r&&!r.startsWith("Traceback")&&!r.startsWith("File "));s=(l[l.length-1]||s).replace(/^frappe\.exceptions\.\w+:\s*/,"").trim()}return s||n}async function Bt(e,n,s=[]){if(Fl.has(e)){const i=`${ue}/api/method/sidrah_business.api.get_sb_doc?doctype=${encodeURIComponent(e)}&name=${encodeURIComponent(n)}`,d=await fetch(i,{credentials:"include",headers:{Accept:"application/json"}});if(!d.ok)throw new Error(`API Error: ${d.status}`);return(await d.json()).message}const l=s.length?`?fields=${encodeURIComponent(JSON.stringify(s))}`:"",a=await fetch(`${ue}/api/v1/resource/${e}/${encodeURIComponent(n)}${l}`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!a.ok)throw new Error(`API Error: ${a.status}`);return(await a.json()).data}async function hd(e,n,s="",l=!1){const a=await nn();if(Fl.has(e)){const d=new URLSearchParams({doctype:e,name:n});s&&d.append("reason",s),l&&d.append("permanent","1");const f=await fetch(`${ue}/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":a},body:d.toString()});if(!f.ok){const p=await f.json().catch(()=>({}));throw new Error(Wa(p,`Error deleting ${n}`))}return}const r=new URLSearchParams({doctype:e,name:n});s&&r.append("reason",s),l&&r.append("permanent","1");const i=await fetch(`${ue}/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":a},body:r.toString()});if(!i.ok){const d=await i.json().catch(()=>({}));throw new Error(Wa(d,`Error deleting ${n}`))}return await i.json()}async function zy(e,n){const s=await nn();if(Fl.has(e)){const r=new URLSearchParams({doctype:e,name:n}),i=await fetch(`${ue}/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:r.toString()});if(!i.ok){const f=await i.json().catch(()=>({}));throw new Error(Wa(f,`Error restoring ${n}`))}return(await i.json()).message||{success:!0}}const l=new URLSearchParams({doctype:e,name:n}),a=await fetch(`${ue}/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(!a.ok){const r=await a.json().catch(()=>({}));throw new Error(Wa(r,`Error restoring ${n}`))}return await a.json()}async function Oe(e){if(Fl.has(e))try{const l=`${ue}/api/method/sidrah_business.api.get_sb_list?doctype=${encodeURIComponent(e)}&limit=500`,a=await fetch(l,{credentials:"include",headers:{Accept:"application/json"}});return a.ok?(await a.json()).message||[]:[]}catch{return[]}const n=encodeURIComponent('["*"]'),s=`${ue}/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 ni(e,n){const s=await nn();if(Fl.has(e)){const a=new URLSearchParams({doctype:e,data_json:JSON.stringify(n)}),r=await fetch(`${ue}/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:a.toString()});if(!r.ok){const d=await r.json().catch(()=>({}));throw new Error(d.message||d.exc||`Error creating ${e}`)}return{data:(await r.json()).message}}const l=`${ue}/api/v1/resource/${e}`;try{const a=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(a.status===401||a.status===403)throw new Error("Permission denied - login required");if(!a.ok){const r=await a.json();throw new Error(r.message||r.exc||`API Error: ${a.status}`)}return await a.json()}catch(a){throw console.error("Post error:",a),a}}async function Ds(e,n,s){const l=await nn();if(Fl.has(e)){const r=new URLSearchParams({doctype:e,name:n,data_json:JSON.stringify(s)}),i=await fetch(`${ue}/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:r.toString()});if(!i.ok){const f=await i.json().catch(()=>({}));throw new Error(f.message||f.exc||`Error updating ${e}`)}return{data:(await i.json()).message}}const a=`${ue}/api/v1/resource/${e}/${encodeURIComponent(n)}`;try{const r=await fetch(a,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":l},body:JSON.stringify(s)});if(r.status===401||r.status===403)throw new Error("Permission denied - login required");if(!r.ok){const i=await r.json();throw new Error(i.message||"Update Error")}return await r.json()}catch(r){throw console.error("Update error:",r),r}}async function Iy(){const e=`${ue}/api/method/sidrah_business.api.get_users`;try{const n=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(n.status===401||n.status===403)return[];if(!n.ok)return[];const s=await n.json();return s.message||s.data||[]}catch(n){return console.error("Get users error:",n),[]}}async function Ey(e,n){const s=new FormData;s.append("usr",e),s.append("pwd",n);const a=await(await fetch(`${ue}/api/method/login`,{method:"POST",credentials:"include",body:s})).json();return a.csrf_token?Ms=a.csrf_token:await uc(),a}async function Ty(){const e=await nn();try{await fetch(`${ue}/api/method/logout`,{method:"POST",credentials:"include",headers:{"X-Frappe-CSRF-Token":e,Accept:"application/json"}})}catch{}Ms=""}function Ay(){return Ms}async function ph(){try{const e=await fetch(`${ue}/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 Py(){const e=JSON.stringify([["name","not in",["Administrator","Guest"]]]),n=`${ue}/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 Ry(){const e=`${ue}/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 si(e,n){const s=await nn();try{const l=new URLSearchParams({user:e,password:n});(await fetch(`${ue}/api/method/sidrah_business.api.set_user_password`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:l.toString()})).ok||await Ds("User",e,{new_password:n})}catch{await Ds("User",e,{new_password:n})}}async function Dy(e=20){try{const n=`${ue}/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 Oy(){const e=await nn();try{await fetch(`${ue}/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 Ly(e){const n=await nn();try{await fetch(`${ue}/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 Wy(e){const n=await nn(),s=new URLSearchParams({name:e});await fetch(`${ue}/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 Ny(e,n){try{const s=`${ue}/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 By(e,n,s){const l=await nn(),a=new URLSearchParams({doctype:e,docname:n,content:s}),r=await fetch(`${ue}/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:a.toString()});if(!r.ok)throw new Error("Failed to post comment");return(await r.json()).message}async function $y(e,n){try{const s=`${ue}/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 fh(e){try{const n=`${ue}/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 Uy(){try{const e=`${ue}/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 Gs(e,n={}){const s=await nn(),l=new URLSearchParams(n),a=await fetch(`${ue}/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(!a.ok){const i=await a.json().catch(()=>({}));throw new Error(Wa(i,`Error calling ${e}`))}return(await a.json()).message}async function My(e,n,s="",l,a,r){const i={name:e,action:n,comment:s};return l!==void 0&&(i.stage=l),r!==void 0&&(i.cycle_status=r),Gs("apply_order_workflow",i)}async function Fy(e,n,s=""){return Gs("apply_incident_workflow",{name:e,action:n,fields_json:s})}async function Hy(e,n,s=""){return Gs("apply_idea_workflow",{name:e,action:n,fields_json:s})}async function Gy(e=""){const n=`${ue}/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 Qy(e,n={}){return Gs("get_report_data",{report_name:e,filters_json:JSON.stringify(n)})}async function Ky(){try{const e=`${ue}/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 Yy(e,n,s="",l="",a="",r=""){return Gs("create_delegation",{manager:e,functions_json:JSON.stringify(n),organization:s,remarks:l,incident_name:a,idea_name:r})}async function Xy(e,n,s=""){return Gs("respond_to_delegation",{name:e,response:n,remarks:s})}async function qy(e,n=""){return Gs("revoke_delegation",{name:e,remarks:n})}async function Jy(){try{const e=`${ue}/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 Vy(e){const n=`${ue}/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 Zy(){try{const e=`${ue}/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 e0(){try{const e=`${ue}/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 t0(){try{const e=await nn(),n=await fetch(`${ue}/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 n0(){const e=Ay();return e||uc()}async function da(e){const n=await fetch(`${ue}/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 s0(e,n,s={}){const l=await n0(),a=new URLSearchParams({name:e,action:n});s.actor_status&&a.set("actor_status",String(s.actor_status)),s.actor_comment&&a.set("actor_comment",String(s.actor_comment)),s.progress_indicators&&a.set("progress_indicators",JSON.stringify(s.progress_indicators));const r=await fetch(`${ue}/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:a.toString()});if(!r.ok){const d=await r.json().catch(()=>({})),f=d.message||(d.exception?String(d.exception).split(`
|
||
`).pop():"")||d.exc_type||`Workflow action "${n}" failed (${r.status})`;throw new Error(f)}const i=await r.json();return i.message||i.data}const l0=["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"],Pu=new Set(l0),a0={"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 Ru(){const e=window.location.hash.replace(/^#\/?/,"");if(e)return Pu.has(e)?e:null;const n=window.location.pathname.split("/").filter(Boolean).pop()||"";return Pu.has(n)?n:null}function r0(e){return e?a0[e]??e:null}function i0(e){return`#/${e}`}function o0({onLogin:e}){const n=se(),[s,l]=_.useState(""),[a,r]=_.useState(""),[i,d]=_.useState(""),[f,p]=_.useState(!1),[k,j]=_.useState(!1),[S,u]=_.useState(!1),v=async()=>{if(!s||!a){d(n.login.emptyFields);return}p(!0),d("");try{const C=await Ey(s,a);if(C.message==="Logged In"){const o=await ph()||s,h=await fh(o),x=h.some(y=>["CEO","Ceo","SB CEO"].includes(y))?"CEO":h.some(y=>["SB Admin","System Manager"].includes(y))?"Admin":h.includes("SB Auditor")?"Auditor":h.includes("SB Owner")?"Owner":h.includes("SB X-Auditor")?"XAuditor":h.includes("SB Manager")?"Manager":"Employee";e({name:o,full_name:C.full_name||s,role:x})}else d(n.login.invalidCreds)}catch(C){d(n.login.connError+(C instanceof Error?C.message:"Unknown"))}p(!1)},z=C=>({width:"100%",padding:"11px 16px",border:`1.5px solid ${C?"#6366f1":"#e2e8f0"}`,borderRadius:8,fontSize:14,background:C?"#f8faff":"#ffffff",color:"#1e293b",outline:"none",transition:"all 0.18s ease",boxSizing:"border-box",boxShadow:C?"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:ch,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"contain"},onError:C=>{C.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:C=>l(C.target.value),onKeyDown:C=>C.key==="Enter"&&v(),onFocus:()=>j(!0),onBlur:()=>j(!1),style:z(k),placeholder:n.login.usernamePlaceholder,autoComplete:"username"})}),t.jsx("div",{children:t.jsx("input",{type:"password",value:a,onChange:C=>r(C.target.value),onKeyDown:C=>C.key==="Enter"&&v(),onFocus:()=>u(!0),onBlur:()=>u(!1),style:z(S),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:v,disabled:f,style:{background:f?"#818cf8":"#4f46e5",color:"white",border:"none",padding:"12px",borderRadius:8,fontSize:14,cursor:f?"not-allowed":"pointer",fontWeight:600,marginTop:4,boxShadow:"0 2px 8px rgba(79, 70, 229, 0.3)",transition:"all 0.18s ease"},onMouseEnter:C=>{f||(C.currentTarget.style.background="#4338ca")},onMouseLeave:C=>{f||(C.currentTarget.style.background="#4f46e5")},children:f?n.login.signingIn:n.login.signIn}),t.jsx("div",{style:{textAlign:"center",marginTop:8},children:t.jsx("button",{type:"button",onClick:dh,style:{fontSize:12,color:"#94a3b8",background:"none",border:"none",cursor:"pointer"},onMouseEnter:C=>C.currentTarget.style.color="#475569",onMouseLeave:C=>C.currentTarget.style.color="#94a3b8",children:n.switchLang})})]})]})})}function d0(e,n){const s=parseInt(e.replace("#",""),16),l=s>>16&255,a=s>>8&255,r=s&255,i=d=>Math.round(d+(255-d)*n);return`rgb(${i(l)}, ${i(a)}, ${i(r)})`}function sa(e,n){const s=parseInt(e.replace("#",""),16),l=s>>16&255,a=s>>8&255,r=s&255;return`rgba(${l}, ${a}, ${r}, ${n})`}function gr({title:e,data:n,color:s,onSelect:l}){const[,a]=n[0]??["Total",0,""],r=n.slice(1),i=r.map((f,p)=>d0(s,Math.min(p*.16,.7))),d=r.map(([f,p,k],j)=>[f,p,k,i[j]]).filter(([,f])=>f>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, ${sa(s,.09)} 0%, transparent 55%)`}}),t.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:3,background:`linear-gradient(90deg, ${s}, ${sa(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 ${sa(s,.35)}`},children:a})]}),a>0&&t.jsx("div",{style:{display:"flex",height:9,borderRadius:999,overflow:"hidden",background:sa(s,.1),marginBottom:13},children:d.map(([f,p,k,j],S)=>t.jsx("div",{title:`${f}: ${p}`,onClick:u=>{u.stopPropagation(),l==null||l(k)},style:{flex:`${p} 0 0`,background:j,borderRight:S<d.length-1?"2px solid white":"none",cursor:l?"pointer":"default"}},f))}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:r.map(([f,p,k],j)=>t.jsxs("div",{className:"status-card-row",onClick:p>0?S=>{S.stopPropagation(),l==null||l(k)}:void 0,style:{display:"flex",alignItems:"center",gap:9,padding:"4px 6px",borderRadius:8,cursor:p>0&&l?"pointer":"default",transition:"background 0.12s"},children:[t.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:i[j],flexShrink:0,boxShadow:`0 0 0 3px ${sa(i[j],.18)}`}}),t.jsx("span",{className:"status-card-label",style:{flex:1,fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f}),t.jsx("span",{className:"status-card-count",style:{fontSize:12,fontWeight:700,flexShrink:0},children:p})]},f))})]})}function sn({value:e,onChange:n,organizations:s,placeholder:l="Select organization...",disabled:a=!1,small:r=!1,userRole:i,onCreateNew:d,onQuickCreateSuccess:f}){var G;const[p,k]=_.useState(!1),[j,S]=_.useState(""),[u,v]=_.useState(!1),[z,C]=_.useState(""),[g,o]=_.useState(""),[h,x]=_.useState(!1),[y,w]=_.useState(""),c=_.useRef(null),b=_.useRef(null);_.useEffect(()=>{const $=I=>{c.current&&!c.current.contains(I.target)&&k(!1)};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]);const A=e?((G=s.find($=>$.organization_name===e||$.name===e))==null?void 0:G.organization_name)??e:"",M=s.filter($=>{if(!$)return!1;const I=$;return I.custom_is_deleted===1||I.custom_is_deleted==="1"||I.custom_is_deleted===!0||I.is_deleted===1||I.is_deleted==="1"||I.is_deleted===!0||I.status==="Deleted"||I.custom_status==="Deleted"?!1:!!$.is_active||$.organization_name===e||$.name===e}).filter($=>{if(!j.trim())return!0;const I=j.toLowerCase().trim();return($.organization_name||"").toLowerCase().includes(I)||($.name||"").toLowerCase().includes(I)||($.acronym||"").toLowerCase().includes(I)}),le=!(i==="Employee"||i==="SB Employee"),U=async $=>{if($.preventDefault(),!!z.trim()){x(!0),w("");try{const I={organization_name:z.trim(),acronym:g.trim(),is_active:1},P=await ni("SB Organization",I),F=(P==null?void 0:P.data)||P,K=(F==null?void 0:F.organization_name)||z.trim();n(K),f&&f(K),v(!1),C(""),o("")}catch(I){console.error("Quick create org error:",I),w((I==null?void 0:I.message)||"Failed to create organization. Please try again.")}finally{x(!1)}}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:c,className:`custom-select-container ${a?"disabled":""} ${p?"open":""}`,style:{position:"relative",width:"100%"},children:[t.jsxs("div",{className:`custom-select-trigger ${r?"small":""} ${a?"disabled":""} ${p?"open":""} ${!e&&!j?"is-placeholder":""}`,style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingRight:8},onClick:()=>{a||(p||(k(!0),S("")),setTimeout(()=>{var $;return($=b.current)==null?void 0:$.focus()},0))},children:[t.jsx("input",{ref:b,type:"text",disabled:a,placeholder:l,value:p?j:A,onChange:$=>{p||k(!0),S($.target.value)},onFocus:()=>{!a&&!p&&(k(!0),S(""))},style:{border:"none",outline:"none",background:"transparent",width:"100%",fontSize:"inherit",fontFamily:"inherit",color:"inherit",cursor:a?"not-allowed":"text",padding:0}}),e&&!a?t.jsx("span",{title:"Clear selection",style:{cursor:"pointer",color:"#94a3b8",fontSize:14,fontWeight:600,padding:"0 4px",lineHeight:1,userSelect:"none",transition:"color 0.15s ease",flexShrink:0},onClick:$=>{$.stopPropagation(),n(""),S(""),k(!1)},onMouseEnter:$=>$.currentTarget.style.color="#475569",onMouseLeave:$=>$.currentTarget.style.color="#94a3b8",children:"✕"}):t.jsx("span",{className:"trigger-arrow",style:{pointerEvents:"none",flexShrink:0},children:"▼"})]}),p&&t.jsx("div",{className:"custom-select-dropdown",children:t.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[M.length===0&&!le&&t.jsx("div",{className:"custom-select-empty",children:"No matching organizations"}),M.map($=>t.jsx(c0,{label:$.organization_name,selected:e===$.organization_name||e===$.name,active:!!$.is_active,isPlaceholder:!1,small:r,onClick:()=>{n($.organization_name),S(""),k(!1)}},$.name)),le&&t.jsxs("div",{style:{borderTop:"1px solid #e2e8f0",color:"#16a34a",fontWeight:700,fontSize:r?12:13,padding:"10px 14px",display:"flex",alignItems:"center",gap:6,cursor:"pointer",background:"#ffffff",transition:"all 0.15s ease"},onClick:()=>{k(!1),d?d():(C(""),o(""),w(""),v(!0))},onMouseEnter:$=>{$.currentTarget.style.background="#f0fdf4"},onMouseLeave:$=>{$.currentTarget.style.background="#ffffff"},children:[t.jsx("span",{style:{fontSize:16,fontWeight:800,color:"#16a34a",lineHeight:1},children:"+"}),t.jsx("span",{children:"Create New Organization"})]})]})})]}),u&&t.jsx("div",{style:{position:"fixed",inset:0,zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(15, 23, 42, 0.55)",backdropFilter:"blur(3px)",padding:16},onClick:$=>{$.target===$.currentTarget&&!h&&v(!1)},children:t.jsxs("div",{style:{background:"#ffffff",borderRadius:12,boxShadow:"0 20px 40px rgba(0, 0, 0, 0.2)",maxWidth:440,width:"100%",overflow:"hidden",animation:"scaleIn 0.15s ease"},children:[t.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:16,fontWeight:700,color:"#1e293b"},children:[t.jsx("span",{style:{color:"#2563eb",fontSize:18,fontWeight:800},children:"+"}),t.jsx("span",{children:"Create New Organization"})]}),t.jsx("button",{type:"button",onClick:()=>!h&&v(!1),style:{background:"none",border:"none",color:"#94a3b8",fontSize:18,cursor:"pointer",padding:"2px 6px",borderRadius:4},children:"✕"})]}),t.jsxs("form",{onSubmit:U,style:{padding:"20px"},children:[y&&t.jsx("div",{style:{background:"#fef2f2",border:"1px solid #fecaca",color:"#dc2626",padding:"8px 12px",borderRadius:6,fontSize:12,marginBottom:14},children:y}),t.jsxs("div",{style:{marginBottom:14},children:[t.jsxs("label",{style:{display:"block",fontSize:12,fontWeight:700,color:"#334155",marginBottom:6},children:["Organization Name ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{type:"text",value:z,onChange:$=>C($.target.value),placeholder:"Enter organization name",autoFocus:!0,disabled:h,style:{width:"100%",padding:"9px 12px",borderRadius:8,border:"1px solid #cbd5e1",fontSize:13,boxSizing:"border-box",outline:"none"}})]}),t.jsxs("div",{style:{marginBottom:16},children:[t.jsx("label",{style:{display:"block",fontSize:12,fontWeight:700,color:"#334155",marginBottom:6},children:"Acronym"}),t.jsx("input",{type:"text",value:g,onChange:$=>o($.target.value),placeholder:"e.g. KAU",disabled:h,style:{width:"100%",padding:"9px 12px",borderRadius:8,border:"1px solid #cbd5e1",fontSize:13,boxSizing:"border-box",outline:"none"}})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10,marginTop:22},children:[t.jsx("button",{type:"button",onClick:()=>v(!1),disabled:h,style:{padding:"8px 16px",borderRadius:8,border:"1px solid #cbd5e1",background:"#f8fafc",color:"#475569",fontWeight:600,fontSize:13,cursor:h?"not-allowed":"pointer"},children:"Cancel"}),t.jsxs("button",{type:"submit",disabled:h||!z.trim(),style:{padding:"8px 18px",borderRadius:8,border:"none",background:"#2563eb",color:"#ffffff",fontWeight:700,fontSize:13,cursor:h||!z.trim()?"not-allowed":"pointer",opacity:h||!z.trim()?.6:1,display:"flex",alignItems:"center",gap:6,boxShadow:"0 2px 4px rgba(37, 99, 235, 0.25)"},children:[t.jsx("span",{style:{fontSize:15,fontWeight:800},children:"+"}),t.jsx("span",{children:h?"Creating...":"Create"})]})]})]})]})})]})}function c0({label:e,selected:n,active:s,isPlaceholder:l,small:a,onClick:r}){const[i,d]=_.useState(!1);return t.jsx("div",{onClick:r,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),className:`custom-select-option ${n?"selected":""} ${i?"hovered":""} ${l?"placeholder-option":""} ${s?"":"inactive-option"} ${a?"small":""}`,children:e})}function un({label:e,icon:n,onClick:s}){return t.jsxs("button",{onClick:s,className:"hero-quicklink-btn",style:{display:"flex",alignItems:"center",gap:8,padding:"7px 14px",background:"rgba(255, 255, 255, 0.12)",border:"1px solid rgba(255, 255, 255, 0.22)",borderRadius:10,cursor:"pointer",backdropFilter:"blur(8px)",color:"white",fontSize:13,fontWeight:700,boxShadow:"0 2px 6px rgba(0,0,0,0.12)",transition:"all 0.18s cubic-bezier(0.4, 0, 0.2, 1)"},children:[t.jsx("span",{style:{fontSize:15,display:"flex",alignItems:"center"},children:n}),t.jsx("span",{style:{whiteSpace:"nowrap"},children:e})]})}function ns({items:e,type:n,onNavigate:s}){const l=se();if(!e.length)return null;const a=n==="process"?"processes-form":"orders-form",r=n==="process"?l.dash.escalatedProcesses:l.dash.escalatedOrders,i=e.some(d=>d.escalation_level===2||d.escalation_level==="2");return t.jsxs("div",{children:[t.jsxs("h4",{style:{fontWeight:700,fontSize:12,color:i?"#ef4444":"#f59e0b",marginBottom:8,display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{children:i?"🚨":"⚠️"}),t.jsxs("span",{children:[r," (",e.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.map(d=>t.jsxs("div",{onClick:()=>s(a,d.name),className:"dashboard-alert-item",style:{padding:"10px 14px",background:i?"#fef2f2":"#fffbeb",borderRadius:10,border:`1px solid ${i?"#fecaca":"#fed7aa"}`,cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.15s ease"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[t.jsx("span",{style:{fontWeight:700,fontSize:12,color:i?"#991b1b":"#92400e",whiteSpace:"nowrap"},children:d.number||d.name}),t.jsx("span",{style:{fontSize:12,color:"#475569",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.title})]}),t.jsxs("span",{style:{fontSize:10,fontWeight:700,color:i?"#b91c1c":"#b45309",background:i?"#fee2e2":"#fef3c7",border:`1px solid ${i?"#fca5a5":"#fde68a"}`,padding:"2px 8px",borderRadius:9999,flexShrink:0},children:[l.dash.level," ",d.escalation_level]})]},d.name))})]})}function u0({kpi:e}){const n=se();return t.jsxs("div",{className:"dashboard-kpi-card",style:{borderRadius:14,padding:"16px 18px",border:"1px solid #e2e8f0",background:"white",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",transition:"all 0.2s ease",display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("div",{style:{fontWeight:800,fontSize:14,color:"#1e293b"},children:e.organization}),t.jsx("span",{style:{fontSize:11,fontWeight:700,color:"#4f46e5",background:"#eff6ff",border:"1px solid #c7d2fe",padding:"2px 9px",borderRadius:9999},children:e.period})]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[{label:n.dash.revenueGrowth,val:e.revenue_growth!=null?`${e.revenue_growth}%`:"—",color:"#10b981"},{label:n.dash.netProfit,val:e.net_profit!=null?e.net_profit.toLocaleString():"—",color:"#3b82f6"},{label:n.dash.strategicGoal,val:e.strategic_goal_pct!=null?`${e.strategic_goal_pct}%`:"—",color:"#8b5cf6"},{label:n.dash.customerSat,val:e.customer_satisfaction!=null?e.customer_satisfaction:"—",color:"#f59e0b"},{label:n.dash.compliance,val:e.compliance_score!=null?e.compliance_score:"—",color:"#06b6d4"},{label:n.dash.safetyInc,val:e.open_safety_incidents!=null?e.open_safety_incidents:"—",color:"#ef4444"}].map(({label:s,val:l,color:a})=>t.jsxs("div",{style:{background:"#f8fafc",padding:"8px 10px",borderRadius:8,border:"1px solid #f1f5f9"},children:[t.jsx("div",{style:{fontSize:10,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px"},children:s}),t.jsxs("div",{style:{fontSize:14,fontWeight:800,color:"#1e293b",marginTop:2,display:"flex",alignItems:"center",gap:4},children:[t.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:a}}),l]})]},s))})]})}function p0({data:e}){if(!e.length)return t.jsx("p",{style:{color:"#94a3b8",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:14,alignItems:"flex-end",overflowX:"auto",paddingBottom:8,paddingTop:10},children:e.map(s=>{const l=s.pass+s.fail+s.unknown||1,a=100;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6,minWidth:54},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column-reverse",gap:2,height:a,width:36,background:"#f1f5f9",borderRadius:6,padding:2,boxSizing:"border-box"},children:[t.jsx("div",{title:`Pass: ${s.pass}`,style:{height:Math.round(s.pass/n*(a-4)),background:"linear-gradient(180deg, #34d399 0%, #10b981 100%)",borderRadius:"4px 4px 0 0",minHeight:s.pass?4:0}}),t.jsx("div",{title:`Fail: ${s.fail}`,style:{height:Math.round(s.fail/n*(a-4)),background:"linear-gradient(180deg, #f87171 0%, #ef4444 100%)",borderRadius:"4px 4px 0 0",minHeight:s.fail?4:0}}),t.jsx("div",{title:`Unknown: ${s.unknown}`,style:{height:Math.round(s.unknown/n*(a-4)),background:"#94a3b8",borderRadius:"4px 4px 0 0",minHeight:s.unknown?4:0}})]}),t.jsx("div",{style:{fontSize:10,fontWeight:600,color:"#64748b",textAlign:"center",lineHeight:1.2},children:s.month.replace(/^(\d{4})-(\d{2})$/,(r,i,d)=>`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][+d-1]} '${i.slice(2)}`)}),t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#10b981",textAlign:"center"},children:l>1?Math.round(s.pass/l*100)+"%":"—"})]},s.month)})}),t.jsx("div",{style:{display:"flex",gap:20,marginTop:12,borderTop:"1px solid #f1f5f9",paddingTop:10},children:[["#10b981","Pass (Verified)"],["#ef4444","Fail (Action Required)"],["#94a3b8","Unknown / Unrecorded"]].map(([s,l])=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,fontWeight:600},children:[t.jsx("div",{style:{width:10,height:10,background:s,borderRadius:3}}),t.jsx("span",{style:{color:"#64748b"},children:l})]},l))})]})}function f0({dashData:e,fi:n,fid:s,fo:l,fp:a,incidentStatuses:r,ideaStatuses:i,orderStatuses:d,processStatuses:f,onNavigate:p,onNavigateStatus:k}){const j=se(),S=(e==null?void 0:e.escalated_processes)||[],u=(e==null?void 0:e.escalated_orders)||[],v=(e==null?void 0:e.attention_processes)||[],z=(e==null?void 0:e.attention_orders)||[],C=(e==null?void 0:e.untriaged_incidents)||[],g=(e==null?void 0:e.overdue_triage)||[],o=S.length>0||u.length>0,h=v.length>0||z.length>0,x=[["Total",n.length,""],...r.map(b=>[b.name1||b.name,n.filter(A=>A.status===b.name).length,b.name])],y=[["Total",s.length,""],...i.map(b=>[b.name1||b.name,s.filter(A=>A.status===b.name).length,b.name])],w=[["Total",l.length,""],...d.map(b=>[b.name1||b.name,l.filter(A=>A.status===b.name).length,b.name])],c=[["Total",a.length,""],...f.map(b=>[b.name1||b.name,a.filter(A=>A.status===b.name).length,b.name])];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:[t.jsx("div",{onClick:()=>p("incidents"),style:{cursor:"pointer"},children:t.jsx(gr,{title:j.dash.incidents,color:"#ef4444",data:x,onSelect:b=>k("incidents",b)})}),t.jsx("div",{onClick:()=>p("ideas"),style:{cursor:"pointer"},children:t.jsx(gr,{title:j.dash.ideas,color:"#10b981",data:y,onSelect:b=>k("ideas",b)})}),t.jsx("div",{onClick:()=>p("orders"),style:{cursor:"pointer"},children:t.jsx(gr,{title:j.dash.orders,color:"#8b5cf6",data:w,onSelect:b=>k("orders",b)})}),t.jsx("div",{onClick:()=>p("processes"),style:{cursor:"pointer"},children:t.jsx(gr,{title:j.dash.processes,color:"#3b82f6",data:c,onSelect:b=>k("processes",b)})})]}),(o||h)&&t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:16},children:[o&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #fee2e2",borderLeft:"5px solid #ef4444"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:14,color:"#ef4444",margin:0},children:j.dash.level2}),t.jsxs("span",{style:{fontSize:11,fontWeight:700,background:"#fef2f2",color:"#ef4444",padding:"2px 8px",borderRadius:9999},children:[S.length+u.length," Critical"]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx(ns,{items:S,type:"process",onNavigate:p}),t.jsx(ns,{items:u,type:"order",onNavigate:p})]})]}),h&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #fef3c7",borderLeft:"5px solid #f59e0b"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:14,color:"#b45309",margin:0},children:j.dash.level1}),t.jsxs("span",{style:{fontSize:11,fontWeight:700,background:"#fffbeb",color:"#b45309",padding:"2px 8px",borderRadius:9999},children:[v.length+z.length," Action Needed"]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx(ns,{items:v,type:"process",onNavigate:p}),t.jsx(ns,{items:z,type:"order",onNavigate:p})]})]})]}),(g.length>0||C.length>0)&&t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:16},children:[g.length>0&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #fee2e2",borderLeft:"5px solid #dc2626"},children:[t.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#dc2626",marginBottom:10},children:[j.dash.overduePrefix,g.length,j.dash.overdueSuffix]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:g.map(b=>t.jsxs("div",{onClick:()=>p("incidents-form",b.name),style:{padding:"8px 12px",background:"#fef2f2",borderRadius:8,border:"1px solid #fca5a5",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{style:{fontWeight:700,fontSize:12,color:"#991b1b"},children:b.number||b.name}),t.jsx("span",{style:{fontSize:12,color:"#475569"},children:b.title}),t.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:b.date})]},b.name))})]}),C.length>0&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #ffedd5",borderLeft:"5px solid #f97316"},children:[t.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#ea580c",marginBottom:10},children:[j.dash.untriaged," (",C.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:C.map(b=>t.jsxs("div",{onClick:()=>p("incidents-form",b.name),style:{padding:"8px 12px",background:"#fff7ed",borderRadius:8,border:"1px solid #fed7aa",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{style:{fontWeight:700,fontSize:12,color:"#9a3412"},children:b.number||b.name}),t.jsx("span",{style:{fontSize:12,color:"#475569"},children:b.title}),t.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:b.date})]},b.name))})]})]})]})}function h0({dashData:e,selectedOrg:n,onNavigate:s}){const l=se(),[a,r]=_.useState([]),[i,d]=_.useState([]),[f,p]=_.useState(!1),k=(e==null?void 0:e.escalated_processes)||[],j=(e==null?void 0:e.escalated_orders)||[],S=(e==null?void 0:e.attention_processes)||[],u=(e==null?void 0:e.attention_orders)||[],v=(e==null?void 0:e.kpi_inputs)||[];_.useEffect(()=>{p(!0);const g=new URLSearchParams({months:"6"});n&&g.append("organization",n),fetch(`/api/method/sidrah_business.api.get_process_trend?${g}`,{credentials:"include",headers:{Accept:"application/json"}}).then(o=>o.json()).then(o=>{const h=o.message||[],x={};for(const y of h)x[y.month]||(x[y.month]={pass:0,fail:0,unknown:0}),y.status==="Pass"?x[y.month].pass=y.count:y.status==="Fail"?x[y.month].fail=y.count:y.status==="Unknown"&&(x[y.month].unknown=y.count);r(Object.entries(x).map(([y,w])=>({month:y,...w})))}).catch(()=>{}).finally(()=>p(!1))},[n]),_.useEffect(()=>{fetch("/api/method/sidrah_business.api.get_report_data",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":window.csrf_token||""},body:JSON.stringify({report_name:"user_activity_log",filters_json:"{}"})}).then(g=>g.json()).then(g=>{var o;d((((o=g.message)==null?void 0:o.rows)||[]).slice(0,50))}).catch(()=>{})},[n]);const z=k.length>0||j.length>0,C=S.length>0||u.length>0;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[v.length>0&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"18px 20px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #e2e8f0"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:14},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:14,color:"#1e293b",margin:0},children:l.dash.recentKpi}),t.jsxs("button",{onClick:()=>s("kpi-input"),style:{padding:"6px 14px",borderRadius:8,border:"1px solid #cbd5e1",background:"#f8fafc",color:"#334155",fontWeight:600,fontSize:12,cursor:"pointer"},children:[l.dash.manageKpi," →"]})]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:14},children:v.map(g=>t.jsx(u0,{kpi:g},g.name))})]}),(z||C)&&t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:16},children:[z&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #fee2e2",borderLeft:"5px solid #ef4444"},children:[t.jsxs("h3",{style:{fontWeight:800,fontSize:14,color:"#ef4444",marginBottom:12},children:["Critical Escalations — Level 2 (",k.length+j.length,")"]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx(ns,{items:k,type:"process",onNavigate:s}),t.jsx(ns,{items:j,type:"order",onNavigate:s})]})]}),C&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #fef3c7",borderLeft:"5px solid #f59e0b"},children:[t.jsxs("h3",{style:{fontWeight:800,fontSize:14,color:"#b45309",marginBottom:12},children:["Needs Attention — Level 1 (",S.length+u.length,")"]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx(ns,{items:S,type:"process",onNavigate:s}),t.jsx(ns,{items:u,type:"order",onNavigate:s})]})]})]}),t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"18px 20px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #e2e8f0"},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:14,color:"#1e293b",marginBottom:4},children:"Process Execution Trend — Last 6 Months"}),t.jsx("p",{style:{fontSize:12,color:"#64748b",marginBottom:12},children:"Pass / Fail verification metrics across all processes and review cycles."}),f?t.jsx("p",{style:{color:"#94a3b8",fontSize:13},children:"Loading trend analytics…"}):t.jsx(p0,{data:a})]}),i.length>0&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"18px 20px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #e2e8f0"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:14},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:14,color:"#1e293b",margin:0},children:"Audit Log Book — Recent Activity"}),t.jsx("button",{onClick:()=>s("reports"),style:{padding:"6px 14px",borderRadius:8,border:"1px solid #cbd5e1",background:"#f8fafc",color:"#334155",fontWeight:600,fontSize:12,cursor:"pointer"},children:"Full Activity Log →"})]}),t.jsx("div",{style:{overflowX:"auto",borderRadius:10,border:"1px solid #f1f5f9"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsx("tr",{style:{background:"#f8fafc"},children:["Timestamp","User","Entity Type","Entity","Fields Changed"].map(g=>t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#64748b",fontWeight:700,fontSize:11,whiteSpace:"nowrap"},children:g},g))})}),t.jsx("tbody",{children:i.map((g,o)=>t.jsxs("tr",{style:{borderTop:"1px solid #f1f5f9",background:o%2===0?"white":"#fafafa"},children:[t.jsx("td",{style:{padding:"10px 14px",color:"#64748b",whiteSpace:"nowrap"},children:g.timestamp?String(g.timestamp).slice(0,16):"—"}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600,color:"#1e293b"},children:g.user||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#475569"},children:t.jsx("span",{style:{background:"#f1f5f9",padding:"2px 8px",borderRadius:6,fontWeight:600,fontSize:11},children:g.entity_type||"—"})}),t.jsx("td",{style:{padding:"10px 14px",color:"#1e293b",fontWeight:500},children:g.entity_name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#64748b",maxWidth:280,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.changes||"—"})]},o))})]})})]})]})}function g0({incidents:e,ideas:n,orders:s,processes:l,organizations:a,incidentStatuses:r,ideaStatuses:i,orderStatuses:d,processStatuses:f,selectedOrg:p,onOrgChange:k,onNavigate:j,onNavigateStatus:S,userRole:u}){const[v,z]=_.useState(null),[C,g]=_.useState(!1),o=()=>{g(!0),Gy(p).then(z).finally(()=>g(!1))};_.useEffect(()=>{o()},[p]);const h=_.useMemo(()=>p?e.filter(H=>H.organization===p):e,[e,p]),x=_.useMemo(()=>p?n.filter(H=>H.organization===p):n,[n,p]),y=_.useMemo(()=>p?s.filter(H=>H.organization===p):s,[s,p]),w=_.useMemo(()=>p?l.filter(H=>H.organization===p):l,[l,p]),c=u==="Admin",b=u==="Owner",[A,T]=_.useState("level1"),M=b||c&&A==="level2";return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsxs("div",{style:{background:"linear-gradient(135deg, #1e1b4b 0%, #312e81 45%, #1e3a8a 100%)",borderRadius:16,padding:"22px 26px",color:"white",boxShadow:"0 8px 30px rgba(30, 27, 75, 0.25)",position:"relative",zIndex:20},children:[t.jsxs("div",{style:{position:"absolute",inset:0,borderRadius:"inherit",overflow:"hidden",pointerEvents:"none"},children:[t.jsx("div",{style:{position:"absolute",top:-50,right:-50,width:220,height:220,borderRadius:"50%",background:"rgba(99, 102, 241, 0.25)",filter:"blur(50px)"}}),t.jsx("div",{style:{position:"absolute",bottom:-40,left:"35%",width:180,height:180,borderRadius:"50%",background:"rgba(59, 130, 246, 0.2)",filter:"blur(45px)"}})]}),t.jsxs("div",{style:{position:"relative",zIndex:1},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",flexWrap:"wrap",gap:16,marginBottom:20},children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:4},children:[t.jsx("span",{style:{fontSize:24},children:"⚡"}),t.jsx("h2",{style:{fontSize:22,fontWeight:800,color:"white",margin:0,letterSpacing:-.5},children:M?"Executive Performance Dashboard":"Operational Activity Dashboard"})]}),t.jsx("p",{style:{fontSize:13,color:"#c7d2fe",margin:0,opacity:.9},children:p?`Real-time analytics for ${p}`:"Enterprise overview across all organizations & business units"})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsx("div",{style:{minWidth:190,maxWidth:260},children:t.jsx(sn,{value:p,onChange:k,organizations:a,placeholder:"All Organizations",small:!0})}),c&&t.jsxs("div",{style:{display:"flex",background:"rgba(255, 255, 255, 0.12)",borderRadius:10,padding:3,gap:3,backdropFilter:"blur(8px)",border:"1px solid rgba(255, 255, 255, 0.15)"},children:[t.jsx("button",{onClick:()=>T("level1"),style:{padding:"5px 12px",borderRadius:7,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:A==="level1"?"white":"transparent",color:A==="level1"?"#1e1b4b":"#c7d2fe",boxShadow:A==="level1"?"0 2px 6px rgba(0,0,0,0.15)":"none",transition:"all 0.15s ease"},children:"Level 1 (Ops)"}),t.jsx("button",{onClick:()=>T("level2"),style:{padding:"5px 12px",borderRadius:7,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:A==="level2"?"#8b5cf6":"transparent",color:"white",boxShadow:A==="level2"?"0 2px 6px rgba(0,0,0,0.2)":"none",transition:"all 0.15s ease"},children:"Level 2 (Exec)"})]}),!c&&t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"white",background:M?"#8b5cf6":"#3b82f6",padding:"5px 14px",borderRadius:9999,border:"1px solid rgba(255, 255, 255, 0.2)",boxShadow:"0 2px 6px rgba(0,0,0,0.15)"},children:M?"👑 Owner View":"💼 Operations View"}),t.jsx("button",{onClick:o,disabled:C,title:"Refresh Metrics",style:{width:32,height:32,borderRadius:10,background:"rgba(255, 255, 255, 0.15)",border:"1px solid rgba(255, 255, 255, 0.2)",color:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,transition:"all 0.15s"},children:t.jsx("span",{style:{display:"inline-block",transform:C?"rotate(180deg)":"none",transition:"transform 0.4s ease"},children:"🔄"})})]})]}),t.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap",alignItems:"center"},children:M?t.jsxs(t.Fragment,{children:[t.jsx(un,{label:"Manage Users & Roles",icon:"👥",onClick:()=>j("users")}),t.jsx(un,{label:"Active Review Cycles",icon:"🔄",onClick:()=>j("cycles")}),t.jsx(un,{label:"Strategic KPI Inputs",icon:"📈",onClick:()=>j("kpi-input")}),t.jsx(un,{label:"Executive Reports",icon:"📊",onClick:()=>j("reports")}),t.jsx(un,{label:"Organizations Hierarchy",icon:"🏢",onClick:()=>j("organizations")})]}):t.jsxs(t.Fragment,{children:[t.jsx(un,{label:"Incidents",icon:"⚠️",onClick:()=>j("incidents")}),t.jsx(un,{label:"Ideas",icon:"💡",onClick:()=>j("ideas")}),t.jsx(un,{label:"Orders",icon:"📦",onClick:()=>j("orders")}),t.jsx(un,{label:"Processes",icon:"⚙️",onClick:()=>j("processes")}),t.jsx(un,{label:"Inbox",icon:"📥",onClick:()=>j("inbox")}),t.jsx(un,{label:"Reports",icon:"📊",onClick:()=>j("reports")})]})})]})]}),M?t.jsx(h0,{dashData:v,selectedOrg:p,onNavigate:j}):t.jsx(f0,{dashData:v,fi:h,fid:x,fo:y,fp:w,incidentStatuses:r,ideaStatuses:i,orderStatuses:d,processStatuses:f,onNavigate:j,onNavigateStatus:S})]})}const lt={fontSize:11,color:"#475569",fontWeight:600,marginBottom:4,display:"block",textTransform:"uppercase",letterSpacing:.4},at={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 Si({children:e}){const[n,s]=_.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,Du=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 Ue({page:e,pageSize:n=ae,total:s,onPageChange:l}){if(s===0)return null;const a=Math.max(1,Math.ceil(s/n)),r=(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 ",r," 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:Du(e<=1),children:"Previous"}),t.jsx("button",{disabled:e>=a,onClick:()=>l(e+1),style:Du(e>=a),children:"Next"})]})]})}function m0({incidents:e,organizations:n,departments:s,branches:l,incidentStatuses:a,initialOrg:r,initialStatus:i,canModify:d,userRole:f,onView:p,onEdit:k,onDelete:j,onSelectionChange:S}){const u=se(),[v,z]=_.useState(new Set),[C,g]=_.useState({search:"",organization:r||"",department:"",branch:"",status:i||""}),o=(c,b)=>g(A=>({...A,[c]:b})),[h,x]=_.useState(1),y=e.filter(c=>!(C.search&&!`${c.number} ${c.title}`.toLowerCase().includes(C.search.toLowerCase())||C.organization&&c.organization!==C.organization||C.department&&c.department!==C.department||C.branch&&c.branch!==C.branch||C.status&&c.status!==C.status));_.useEffect(()=>{x(1)},[C]);const w=y.slice((h-1)*ae,h*ae);return _.useEffect(()=>{if(S){const c=e.filter(b=>v.has(b.name));S(c,w)}},[v,w,e]),t.jsxs(t.Fragment,{children:[t.jsx(Si,{children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"10px 14px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.numberTitle}),t.jsx("input",{style:at,value:C.search,onChange:c=>o("search",c.target.value),placeholder:u.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.organization}),t.jsxs("select",{style:at,value:C.organization,onChange:c=>o("organization",c.target.value),children:[t.jsx("option",{value:"",children:u.filter.allOrgs}),n.map(c=>t.jsx("option",{value:c.name,children:c.organization_name||c.name},c.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.department}),t.jsxs("select",{style:at,value:C.department,onChange:c=>o("department",c.target.value),children:[t.jsx("option",{value:"",children:u.filter.allDepts}),s.map(c=>t.jsx("option",{value:c.name,children:c.department_name||c.name},c.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.branch}),t.jsxs("select",{style:at,value:C.branch,onChange:c=>o("branch",c.target.value),children:[t.jsx("option",{value:"",children:u.filter.allBranches}),l.map(c=>t.jsx("option",{value:c.name,children:c.branch||c.name},c.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.status}),t.jsxs("select",{style:at,value:C.status,onChange:c=>o("status",c.target.value),children:[t.jsx("option",{value:"",children:u.filter.allStatuses}),a.map(c=>t.jsx("option",{value:c.name,children:c.name1||c.name},c.name))]})]})]})}),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:w.length>0&&w.every(c=>v.has(c.name)),onChange:c=>{if(c.target.checked)z(new Set([...v,...w.map(b=>b.name)]));else{const b=new Set(v);w.forEach(A=>b.delete(A.name)),z(b)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.type}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.actions})]})}),t.jsx("tbody",{children:y.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:u.noIncidents})}):w.map((c,b)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>p==null?void 0:p(c),style:{borderTop:"1px solid #f1f5f9",background:v.has(c.name)?"#eff6ff":c.custom_is_deleted?"#fff1f2":b%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:A=>A.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:v.has(c.name),onChange:()=>{const A=new Set(v);A.has(c.name)?A.delete(c.name):A.add(c.name),z(A)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:c.number||"—"}),t.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:c.title||c.name||"—"}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:c.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:c.type?cc(c.type):"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:c.custom_is_deleted?fs(u.deletedBadge):c.status?fs(c.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:A=>A.stopPropagation(),children:t.jsx(dt,{onView:()=>p==null?void 0:p(c),onEdit:d&&k&&!c.custom_is_deleted&&!ts("incident",c.workflow_state)&&!(f==="Employee"&&c.workflow_state&&c.workflow_state!=="New")?()=>k(c):void 0,onDelete:d&&j&&!c.custom_is_deleted?()=>j(c.name):void 0})})]},c.name))})]})}),t.jsx(Ue,{page:h,total:y.length,onPageChange:x})]})}function x0(e){if(!e)return"";const[n,s,l]=e.split("-");return!n||!s||!l?"":`${l}/${s}/${n}`}function ve({value:e,onChange:n,disabled:s,style:l,min:a,max:r}){return t.jsxs("div",{style:{position:"relative",width:"100%"},children:[t.jsx("input",{type:"text",readOnly:!0,tabIndex:-1,value:x0(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:a,max:r,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 Ou={"SB Process":"processes-form","SB Order":"orders-form","SB Incident":"incidents-form","SB Idea":"ideas-form","SB Delegation":"delegations"};function y0(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 hh({notifCount:e,darkMode:n,onCountChange:s,onToggleDark:l,onViewProfile:a,onLogout:r,onNavigate:i,userName:d,userRole:f}){const[p,k]=_.useState(!1),[j,S]=_.useState([]),[u,v]=_.useState(!1),z=_.useRef(null);_.useEffect(()=>{const T=M=>{z.current&&!z.current.contains(M.target)&&k(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const C=async()=>{v(!0);const T=await Dy(30);S(T),v(!1)},g=()=>{const T=!p;k(T),T&&C()},o=async()=>{await Oy(),S(T=>T.map(M=>({...M,read:1}))),s(0)},h=T=>{T.read||(Ly(T.name),S(H=>H.map(le=>le.name===T.name?{...le,read:1}:le)),s(Math.max(0,e-1)));const M=T.document_type?Ou[T.document_type]:void 0;M&&i&&(i(M,T.document_type==="SB Delegation"?void 0:T.document_name),k(!1))},x=j.filter(T=>!T.read).length,y=T=>({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,...T}),w=n,c=w?"#1a202c":"white",b=w?"#2d3748":"#e5e7eb",A=w?"#e2e8f0":"#1a2332";return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[d&&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:w?"#e2e8f0":"#1e293b",whiteSpace:"nowrap"},children:d}),f&&t.jsx("span",{style:{fontSize:11,color:w?"#94a3b8":"#6b7280",whiteSpace:"nowrap"},children:f})]}),t.jsx("button",{style:y({background:"#4f46e5",color:"white"}),onClick:a,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:z,style:{position:"relative"},children:[t.jsxs("button",{style:y(),onClick:g,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})]}),p&&t.jsxs("div",{style:{position:"absolute",right:0,top:"calc(100% + 8px)",width:340,background:c,borderRadius:12,boxShadow:"0 8px 32px rgba(0,0,0,0.2)",zIndex:1e4,border:`1px solid ${b}`,overflow:"hidden"},children:[t.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${b}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:c},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:A},children:["Notifications",x>0&&t.jsxs("span",{style:{background:"#ef4444",color:"white",fontSize:10,fontWeight:700,borderRadius:999,padding:"2px 7px"},children:[x," new"]})]}),x>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:[u&&t.jsx("div",{style:{padding:20,textAlign:"center",color:"#aaa",fontSize:13},children:"Loading…"}),!u&&j.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"})]}),!u&&j.map(T=>{const M=!!(T.document_type&&Ou[T.document_type]&&i);return t.jsxs("div",{onClick:()=>h(T),style:{padding:"11px 16px",borderBottom:`1px solid ${w?"#2d3748":"#f5f5f5"}`,display:"flex",gap:10,background:T.read?c:w?"#1e3a5f":"#eff6ff",cursor:M?"pointer":"default",transition:"background 0.12s"},onMouseEnter:H=>{M&&(H.currentTarget.style.background=w?"#243244":"#e0ecfd")},onMouseLeave:H=>{H.currentTarget.style.background=T.read?c:w?"#1e3a5f":"#eff6ff"},children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:13,fontWeight:T.read?400:600,color:A,marginBottom:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T.subject||`${T.document_type}: ${T.document_name}`}),t.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:T.document_type&&t.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#3b82f6",background:w?"rgba(59,130,246,0.15)":"#eff6ff",padding:"1px 7px",borderRadius:8},children:[T.document_type.replace("SB ",""),T.document_name?` · ${T.document_name}`:""]})}),t.jsx("div",{style:{fontSize:11,color:"#aaa",marginTop:3},children:y0(T.creation)})]}),!T.read&&t.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:"#3498db",flexShrink:0,marginTop:5}})]},T.name)})]})]})]}),t.jsx("button",{style:y(),onClick:dh,title:wl()?"Switch to English":"Switch to Arabic",children:t.jsx("span",{style:{fontSize:13,fontWeight:700,fontFamily:"serif"},children:"عA"})}),t.jsx("button",{style:y(),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:y({background:w?"#3d1515":"#fee2e2",color:"#ef4444"}),onClick:r,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 et({title:e,activePage:n,user:s,formStatus:l,buttonText:a,viewMode:r,statusBadge:i,onEdit:d,onCancel:f,hideSettings:p,rightPanel:k,darkMode:j,notifCount:S,onToggleDark:u,onCountChange:v,onViewProfile:z,onSubmit:C,onBack:g,onNavigate:o,onLogout:h,children:x}){const y=se(),w=s.role,c=w==="Admin"||w==="Owner"||w==="Auditor"||w==="Manager",b=w==="Admin"||w==="Owner"||w==="Auditor"||w==="Manager",A=w==="Admin"||w==="Auditor"||w==="Manager",[T,M]=_.useState(()=>localStorage.getItem("sb_sidebar")==="1"),H=_.useRef(void 0),[le,U]=_.useState(!1);_.useEffect(()=>{if(H.current===!0&&r===!1){U(!0);const I=setTimeout(()=>{U(!1)},4e3);return()=>clearTimeout(I)}else U(!1);H.current=r},[r]);const G=()=>M(I=>{const P=!I;return localStorage.setItem("sb_sidebar",P?"1":"0"),P}),$=f||g;return t.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:j?"#0f172a":"#f8fafc"},children:[t.jsx(uh,{collapsed:T,onToggleCollapsed:G,activePage:n,onNavigate:o,hasDashboard:c,hasReports:b,hasDelegations:A,role:w,hideSettings:p,rtl:y.rtl,navLabels:y.nav,settingsLabel:y.nav.settings}),t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[t.jsx("div",{style:{background:j?"#1e293b":"#ffffff",padding:"6px 20px",borderBottom:`1px solid ${j?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"flex-end",alignItems:"center",gap:6,flexShrink:0,boxShadow:j?"none":"0 1px 4px rgba(0,0,0,0.03)"},children:t.jsx(hh,{notifCount:S,darkMode:j,onCountChange:v,onToggleDark:u,onNavigate:o,onViewProfile:z,onLogout:h,userName:s.full_name||s.name,userRole:s.role})}),t.jsxs("div",{style:{background:j?"#1e293b":"#ffffff",padding:"12px 24px",borderBottom:`1px solid ${j?"#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:g,title:y.back,style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:`1px solid ${j?"#475569":"#e2e8f0"}`,background:j?"#334155":"#ffffff",cursor:"pointer",color:"#2563eb",flexShrink:0,transition:"all 0.15s ease"},onMouseEnter:I=>{I.currentTarget.style.background=j?"#475569":"#eff6ff",I.currentTarget.style.borderColor="#93c5fd"},onMouseLeave:I=>{I.currentTarget.style.background=j?"#334155":"#ffffff",I.currentTarget.style.borderColor=j?"#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:j?"#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:[r&&d&&t.jsxs("button",{type:"button",onClick:d,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:I=>I.currentTarget.style.background="#1d4ed8",onMouseLeave:I=>I.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"})]}),y.edit]}),!r&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("button",{type:"button",onClick:$,style:{padding:"7px 16px",borderRadius:6,border:`1px solid ${j?"#475569":"#cbd5e1"}`,background:j?"#334155":"#ffffff",color:j?"#e2e8f0":"#475569",fontSize:13,fontWeight:600,cursor:"pointer",transition:"all 0.15s ease"},onMouseEnter:I=>{I.currentTarget.style.background=j?"#475569":"#f1f5f9"},onMouseLeave:I=>{I.currentTarget.style.background=j?"#334155":"#ffffff"},children:y.cancel}),t.jsxs("button",{type:"button",onClick:C,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:I=>{l!=="loading"&&(I.currentTarget.style.background="#15803d")},onMouseLeave:I=>{l!=="loading"&&(I.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"?y.saving:a||"Save Changes"})]})]})]}),!r&&le&&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:()=>U(!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:k?"1fr 240px":"1fr",gap:16,alignItems:"start"},children:[t.jsxs("div",{style:{minWidth:0},children:[x,l==="success"&&t.jsx("div",{style:{padding:"10px 14px",borderRadius:8,background:"#f0fdf4",border:"1px solid #86efac",color:"#166534",fontSize:13,marginTop:14},children:y.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})]}),k&&t.jsx("div",{style:{position:"sticky",top:0,alignSelf:"start",width:240},children:k})]})]})]})}function xo(e){return e?e==="Department"?{key:"department_name",label:"Department Name"}:e==="Branch"?{key:"branch",label:"Branch Name"}:e==="SB Organization"||e==="Organization"?{key:"organization_name",label:"Organization Name"}:e==="SB Group Company"||e==="Group Company"?{key:"company_name",label:"Company Name"}:{key:"name1",label:`${e.replace(/^SB\s+/,"")} Name`}:{key:"name1",label:"Name"}}function ge({value:e,onChange:n,items:s,placeholder:l="Select...",disabled:a=!1,onCreateNew:r,createNewText:i,doctypeName:d,userRole:f,onQuickCreateSuccess:p,extraFields:k={}}){var F;const[j,S]=_.useState(!1),[u,v]=_.useState(""),[z,C]=_.useState(""),[g,o]=_.useState(!1),[h,x]=_.useState(""),[y,w]=_.useState(!1),[c,b]=_.useState(""),A=_.useRef(null),T=_.useRef(null);_.useEffect(()=>{const K=E=>{A.current&&!A.current.contains(E.target)&&S(!1)};return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[]);const M=(s||[]).filter(K=>{if(!K)return!1;const E=K;return!(E.custom_is_deleted===1||E.custom_is_deleted==="1"||E.custom_is_deleted===!0||E.is_deleted===1||E.is_deleted==="1"||E.is_deleted===!0||E.status==="Deleted"||E.custom_status==="Deleted")}),H=e?((F=M.find(K=>K.name===e))==null?void 0:F.label)??e:"",le=M.filter(K=>{if(!u.trim())return!0;const E=u.toLowerCase().trim();return(K.label||"").toLowerCase().includes(E)||(K.name||"").toLowerCase().includes(E)}),G=!(f==="Employee"||f==="SB Employee")&&(!!r||!!d||!!i),$=d?`Create New ${d.replace(/^SB\s+/,"")}`:"Create New",I=i||$,P=async K=>{if(K.preventDefault(),!(!h.trim()||!d)){w(!0),b("");try{const E=xo(d),ee={[E.key]:h.trim(),...k};["Incident Types","Idea Types","Order Types","Process Types"].includes(d)&&(ee.status="Active");const V=await ni(d,ee),ce=(V==null?void 0:V.data)||V,ie=(ce==null?void 0:ce.name)||(ce==null?void 0:ce[E.key])||h.trim();n(ie),p&&p(ie),o(!1),x("")}catch(E){console.error("Quick create error:",E),b((E==null?void 0:E.message)||"Failed to create item. Please try again.")}finally{w(!1)}}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:A,className:`custom-select-container ${a?"disabled":""} ${j?"open":""}`,style:{position:"relative",width:"100%"},children:[t.jsxs("div",{className:`custom-select-trigger ${a?"disabled":""} ${j?"open":""} ${!e&&!u?"is-placeholder":""}`,style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingRight:8},onClick:()=>{a||(j||(S(!0),v("")),setTimeout(()=>{var K;return(K=T.current)==null?void 0:K.focus()},0))},children:[t.jsx("input",{ref:T,type:"text",disabled:a,placeholder:l,value:j?u:H,onChange:K=>{j||S(!0),v(K.target.value)},onFocus:()=>{!a&&!j&&(S(!0),v(""))},style:{border:"none",outline:"none",background:"transparent",width:"100%",fontSize:"inherit",fontFamily:"inherit",color:"inherit",cursor:a?"not-allowed":"text",padding:0}}),e&&!a?t.jsx("span",{title:"Clear selection",style:{cursor:"pointer",color:"#94a3b8",fontSize:14,fontWeight:600,padding:"0 4px",lineHeight:1,userSelect:"none",transition:"color 0.15s ease",flexShrink:0},onClick:K=>{K.stopPropagation(),n(""),v(""),S(!1)},onMouseEnter:K=>K.currentTarget.style.color="#475569",onMouseLeave:K=>K.currentTarget.style.color="#94a3b8",children:"✕"}):t.jsx("span",{className:"trigger-arrow",style:{pointerEvents:"none",flexShrink:0},children:"▼"})]}),j&&t.jsx("div",{className:"custom-select-dropdown",children:t.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[le.length===0&&!G&&t.jsx("div",{className:"custom-select-empty",children:"No matching records found"}),le.map(K=>t.jsx("div",{className:`custom-select-option ${e===K.name?"selected":""} ${z===K.name?"hovered":""}`,onClick:()=>{n(K.name),v(""),S(!1)},onMouseEnter:()=>C(K.name),onMouseLeave:()=>C(""),children:K.label},K.name)),G&&t.jsxs("div",{className:`custom-select-option create-new-option ${z==="__create_new"?"hovered":""}`,style:{borderTop:"1px solid #e2e8f0",color:"#16a34a",fontWeight:700,fontSize:13,padding:"10px 14px",display:"flex",alignItems:"center",gap:6,cursor:"pointer",background:z==="__create_new"?"#f0fdf4":"#ffffff",transition:"all 0.15s ease"},onClick:()=>{S(!1),r?r():(x(""),b(""),o(!0))},onMouseEnter:()=>C("__create_new"),onMouseLeave:()=>C(""),children:[t.jsx("span",{style:{fontSize:16,fontWeight:800,color:"#16a34a",lineHeight:1},children:"+"}),t.jsx("span",{children:I})]})]})})]}),g&&d&&t.jsx("div",{style:{position:"fixed",inset:0,zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(15, 23, 42, 0.55)",backdropFilter:"blur(3px)",padding:16},onClick:K=>{K.target===K.currentTarget&&!y&&o(!1)},children:t.jsxs("div",{style:{background:"#ffffff",borderRadius:12,boxShadow:"0 20px 40px rgba(0, 0, 0, 0.2)",maxWidth:440,width:"100%",overflow:"hidden",animation:"scaleIn 0.15s ease"},children:[t.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:16,fontWeight:700,color:"#1e293b"},children:[t.jsx("span",{style:{color:"#2563eb",fontSize:18,fontWeight:800},children:"+"}),t.jsx("span",{children:`Create New ${d.replace(/^SB\s+/,"")}`})]}),t.jsx("button",{type:"button",onClick:()=>!y&&o(!1),style:{background:"none",border:"none",color:"#94a3b8",fontSize:18,cursor:"pointer",padding:"2px 6px",borderRadius:4},children:"✕"})]}),t.jsxs("form",{onSubmit:P,style:{padding:"20px"},children:[c&&t.jsx("div",{style:{background:"#fef2f2",border:"1px solid #fecaca",color:"#dc2626",padding:"8px 12px",borderRadius:6,fontSize:12,marginBottom:14},children:c}),t.jsxs("div",{style:{marginBottom:16},children:[t.jsxs("label",{style:{display:"block",fontSize:12,fontWeight:700,color:"#334155",marginBottom:6},children:[xo(d).label," ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{type:"text",value:h,onChange:K=>x(K.target.value),placeholder:`Enter ${xo(d).label.toLowerCase()}`,autoFocus:!0,disabled:y,style:{width:"100%",padding:"9px 12px",borderRadius:8,border:"1px solid #cbd5e1",fontSize:13,boxSizing:"border-box",outline:"none"}})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10,marginTop:22},children:[t.jsx("button",{type:"button",onClick:()=>o(!1),disabled:y,style:{padding:"8px 16px",borderRadius:8,border:"1px solid #cbd5e1",background:"#f8fafc",color:"#475569",fontWeight:600,fontSize:13,cursor:y?"not-allowed":"pointer"},children:"Cancel"}),t.jsxs("button",{type:"submit",disabled:y||!h.trim(),style:{padding:"8px 18px",borderRadius:8,border:"none",background:"#2563eb",color:"#ffffff",fontWeight:700,fontSize:13,cursor:y||!h.trim()?"not-allowed":"pointer",opacity:y||!h.trim()?.6:1,display:"flex",alignItems:"center",gap:6,boxShadow:"0 2px 4px rgba(37, 99, 235, 0.25)"},children:[t.jsx("span",{style:{fontSize:15,fontWeight:800},children:"+"}),t.jsx("span",{children:y?"Creating...":"Create"})]})]})]})]})})]})}function v0(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 j0(e){return e.replace(/@.*/,"").replace(/[._-]/g," ").split(" ").filter(Boolean).slice(0,2).map(s=>s[0].toUpperCase()).join("")}function _i({doctype:e,docname:n,currentUserName:s}){const l=se(),[a,r]=_.useState([]),[i,d]=_.useState(!1),[f,p]=_.useState(""),[k,j]=_.useState(!1),[S,u]=_.useState(!1),[v,z]=_.useState(!1),[C,g]=_.useState(""),o=5,h=_.useCallback(async()=>{d(!0);const b=await Ny(e,n);r(b),d(!1)},[e,n]);_.useEffect(()=>{h()},[h]);const x=async()=>{const b=f.trim();if(!(!b||k)){j(!0),g("");try{await By(e,n,b),p(""),await h()}catch{g("Failed to post comment. Please try again.")}j(!1)}},y=async b=>{if(window.confirm("Delete this comment?"))try{await hd("Comment",b),r(A=>A.filter(T=>T.name!==b))}catch{alert("Failed to delete comment.")}},w=v?a:a.slice(-o),c=Math.max(0,a.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:()=>u(b=>!b),style:{padding:"12px 20px",borderBottom:S?"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,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:[t.jsx("button",{onClick:b=>{b.stopPropagation(),h()},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:S?"▼":"▲"})]})]}),!S&&t.jsxs("div",{style:{padding:"16px 20px"},children:[!v&&c>0&&t.jsxs("button",{onClick:()=>z(!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 ",c," older comment",c!==1?"s":""]}),i&&t.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:l.loading}),!i&&a.length===0&&t.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:l.comments.noComments}),!i&&w.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:16},children:w.map(b=>{const A=b.comment_by||b.comment_email||b.owner||"Unknown",T=b.owner===s||b.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:j0(A)}),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:A}),t.jsx("span",{style:{fontSize:11,color:"#aaa"},children:v0(b.creation)})]}),T&&t.jsx("button",{onClick:()=>y(b.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:b.content||""}})]})]},b.name)})}),t.jsxs("div",{style:{borderTop:a.length>0?"1px solid #f0f0f0":"none",paddingTop:a.length>0?14:0},children:[t.jsx("textarea",{value:f,onChange:b=>p(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.ctrlKey||b.metaKey)&&x()},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"}}),C&&t.jsx("div",{style:{fontSize:12,color:"#e74c3c",marginTop:4},children:C}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:t.jsx("button",{onClick:x,disabled:!f.trim()||k,style:{padding:"8px 20px",background:"#3498db",color:"white",border:"none",borderRadius:6,cursor:!f.trim()||k?"not-allowed":"pointer",fontSize:13,fontWeight:600,fontFamily:"Segoe UI",opacity:!f.trim()||k?.6:1},children:k?l.saving:l.comments.post})})]})]})]})}function Lu(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 b0(e){return(e||"").replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function Wu(e){return e==null||e===""?"(empty)":typeof e=="object"?JSON.stringify(e):String(e)}function gd(e){return(e||"Unknown").replace(/@.*/,"").replace(/[._]/g," ")}function Nu(e){return gd(e).split(" ").filter(Boolean).slice(0,2).map(n=>n[0].toUpperCase()).join("")}function S0(e){let n={};try{n=JSON.parse(e.data||"{}")}catch{}const s=(n.changed||[]).map(l=>({field:l[0]||"",oldVal:Wu(l[1]),newVal:Wu(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 wi({doctype:e,docname:n,docCreation:s,docOwner:l}){const a=se(),[r,i]=_.useState([]),[d,f]=_.useState(!1),[p,k]=_.useState(!0),[j,S]=_.useState(!1),u=5,v=_.useCallback(async()=>{f(!0);const o=await $y(e,n);i(o.map(S0)),f(!1)},[e,n]);_.useEffect(()=>{p||v()},[p,v]);const z=j?r:r.slice(0,u),C=r.length-u,g=(o,h=!1)=>({position:"absolute",left:-14,top:14,width:10,height:10,borderRadius:"50%",background:o,border:"2px solid white",boxShadow:h?`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:()=>k(o=>!o),style:{padding:"12px 20px",borderBottom:p?"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:["📋 ",a.activity.title,!p&&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:[!p&&t.jsx("button",{onClick:o=>{o.stopPropagation(),v()},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:[d&&t.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:a.loading}),!d&&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:[z.map((o,h)=>t.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[t.jsx("div",{style:g(h===0?"#3498db":"#d1d5db",h===0)}),t.jsxs("div",{style:{background:h===0?"#eff6ff":"#f9fafb",border:`1px solid ${h===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:Nu(o.owner)}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:gd(o.owner)}),t.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:Lu(o.creation)})]}),o.changes.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:o.changes.map((x,y)=>t.jsxs("div",{style:{fontSize:12,lineHeight:1.5},children:[t.jsx("span",{style:{fontWeight:600,color:"#6d28d9"},children:b0(x.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:x.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:x.newVal})]},y))}):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:g("#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:Nu(l)}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:gd(l)}),t.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:Lu(s)})]}),t.jsxs("div",{style:{fontSize:12,color:"#15803d",fontWeight:600},children:["✓ ",a.activity.created]})]})]}),r.length===0&&!s&&t.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:"No activity recorded"})]})]}),!d&&C>0&&t.jsx("div",{style:{textAlign:"center",marginTop:12},children:t.jsx("button",{onClick:()=>S(o=>!o),style:{background:"none",border:"none",cursor:"pointer",color:"#3498db",fontSize:12,fontFamily:"Segoe UI",padding:"4px 8px"},children:j?"▲ Show less":`▼ Show all (${r.length})`})})]})]})}const _0={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 w0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,..._0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function k0({incForm:e,setIncForm:n,organizations:s,groupCompanies:l=[],managements:a,departments:r,branches:i,incidentTypes:d,incidentClasses:f,incidentFields:p,incidentStatuses:k,users:j,userRoleMap:S={},formStatus:u,viewMode:v,canModify:z,onEdit:C,onDelete:g,onRestore:o,onPermanentDelete:h,darkMode:x,notifCount:y,onToggleDark:w,onCountChange:c,onViewProfile:b,userRole:A,delegatedFunctions:T=[],delegatedOrgs:M={},onSubmit:H,onBack:le,onNavigate:U,onLogout:G,user:$,onRefresh:I}){var kt;const P=se(),F=Q=>n({...e,...Q}),K=v?{background:"#f9f9f9"}:{},E=Nl(j,S,"SB Manager",e.organization),[ee,V]=_.useState(""),[ce,ie]=_.useState(!1),tt=e.name?v?`${P.formTitle.viewIncident}${e.number||e.name}`:P.formTitle.editIncident:P.formTitle.newIncident,Re=Zt(a,{organization:e.organization}),_t=Zt(r,{organization:e.organization,management:e.management}),q=Zt(i,{organization:e.organization,management:e.management,department:e.department}),de=be(Re,e.management).map(Q=>({name:Q.name,label:Q.name1||Q.name})),wt=be(_t,e.department).map(Q=>({name:Q.name,label:Q.department_name||Q.name})),ln=be(q,e.branch).map(Q=>({name:Q.name,label:Q.branch||Q.name})),me=be(d,e.type).map(Q=>({name:Q.name,label:Q.name1||Q.name})),yn=be(f,e.incident_class).map(Q=>({name:Q.name,label:Q.name1||Q.name})),nt=be(p,e.incident_field).map(Q=>({name:Q.name,label:Q.name1||Q.name})),Ie=e.workflow_state||"New",Tt=A==="Employee",Se=A==="Auditor"||A==="Admin",We=A==="Manager",an=We&&T.includes("incident_initial_evaluation")&&(!M.incident_initial_evaluation||(M.incident_initial_evaluation||[]).includes(e.organization)),fe=Se||an,B=e.name?Ie==="New"?[{label:P.wf.submit,action:"Submit",color:"#2563eb"}]:Ie==="Initial Evaluation"&&fe?[{label:P.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:P.wf.reject,action:"Reject",color:"#dc2626"}]:Ie==="Accept & Under Progress"&&(We||Se)?[{label:P.wf.submitSolution,action:"Submit Solution",color:"#059669"}]:Ie==="working on resolution"&&(We||Se)?[{label:P.wf.resolutionComplete,action:"Resolution complete",color:"#166534"}]:[]:[];async function ne(Q){if(e.name){ie(!0),V("");try{const Me={};Q==="Assign to Manager"&&(e.assigned_to&&(Me.assigned_to=e.assigned_to),e.priority&&(Me.priority=e.priority),e.economy_class&&(Me.economy_class=e.economy_class),e.entity_scope&&(Me.entity_scope=e.entity_scope),e.hses_field&&(Me.hses_field=e.hses_field),Me.product_relation=String(e.product_relation??0),Me.repeated=String(e.repeated??0)),Q==="Submit Solution"&&(e.solution&&(Me.solution=e.solution),e.summary&&(Me.summary=e.summary),e.cost&&(Me.cost=String(e.cost))),(Q==="Resolution complete"||Q==="Submit Solution")&&e.auditor_comment&&(Me.auditor_comment=e.auditor_comment),await Fy(e.name,Q,JSON.stringify(Me)),V("Done"),I==null||I()}catch(Me){V(Me.message||"Error")}finally{ie(!1)}}}const L=((kt=E.find(Q=>Q.name===e.assigned_to))==null?void 0:kt.full_name)||e.assigned_to,je=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:P.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:Ie})]}),Ie==="Initial Evaluation"&&fe&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:D,children:P.wf.assignToManager}),t.jsxs("select",{style:O,value:e.assigned_to||"",onChange:Q=>F({assigned_to:Q.target.value}),children:[t.jsx("option",{value:"",children:P.field.selectMgr}),E.map(Q=>t.jsx("option",{value:Q.name,children:Q.full_name||Q.name},Q.name))]})]}),(Ie==="Accept & Under Progress"||Ie==="working on resolution")&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:D,children:P.field.solution}),t.jsx("textarea",{style:{...O,height:75,resize:"vertical"},value:e.solution||"",onChange:Q=>F({solution:Q.target.value}),placeholder:P.field.solutionPlaceholder}),t.jsx("label",{style:{...D,marginTop:6},children:P.field.actualCost}),t.jsx("input",{type:"number",style:O,value:e.cost||"",onChange:Q=>F({cost:parseFloat(Q.target.value)||0}),placeholder:"0.00"})]}),Ie==="working on resolution"&&Se&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:D,children:P.field.auditorComment}),t.jsx("textarea",{style:{...O,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:Q=>F({auditor_comment:Q.target.value}),placeholder:P.field.commentPlaceholder})]}),B.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:B.map(Q=>t.jsx("button",{onClick:()=>ne(Q.action),disabled:ce,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:Q.color,color:"white",fontWeight:600,fontSize:12,cursor:ce?"not-allowed":"pointer",opacity:ce?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:t.jsx("span",{children:ce?P.wf.applying:Q.label})},Q.action))}):t.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:P.wf.noActions}),ee&&t.jsx("p",{style:{marginTop:8,fontSize:12,color:ee==="Done"?X.green:X.red},children:ee})]}),t.jsx(bi,{priority:e.priority,status:Ie,assignedTo:L||(e.assigned_to?e.assigned_to:void 0),createdDate:e.date,modifiedDate:e.modified}),t.jsx(_i,{doctype:R.incidents,docname:e.name,currentUserName:$.name}),t.jsx(wi,{doctype:R.incidents,docname:e.name,docCreation:e.creation,docOwner:e.owner}),z&&g&&!e.custom_is_deleted&&t.jsx(ji,{title:"Delete Request",btnText:P.delete,onDelete:()=>g(e.name)})]}):null;return t.jsxs(et,{title:tt,activePage:"incidents",user:$,formStatus:u,statusBadge:t.jsx("span",{style:w0(Ie),children:Ie}),buttonText:P.saveIncident,buttonColor:"#16a34a",viewMode:v,onEdit:C,darkMode:x,notifCount:y,onToggleDark:w,onCountChange:c,onViewProfile:b,rightPanel:je,onSubmit:H,onBack:le,onNavigate:U,onLogout:G,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:o?()=>o(e.name):void 0,onPermanentDelete:h?()=>h(e.name):void 0}),t.jsx(oe,{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:D,children:P.field.number}),t.jsx("input",{style:{...O,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:D,children:[P.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(sn,{value:e.organization,onChange:Q=>{var At;const Me=(At=s.find(xs=>xs.name===Q))==null?void 0:At.group_company;F({organization:Q,...$.custom_group_company?{}:{group_company:Me||e.group_company}})},organizations:s,disabled:v||!!$.custom_organization,userRole:A,onQuickCreateSuccess:I})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:P.field.title}),t.jsx("input",{style:{...O,...K},value:e.title,disabled:v,onChange:Q=>F({title:Q.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:P.field.management}),t.jsx(ge,{value:e.management,onChange:Q=>F({management:Q}),items:de,placeholder:P.field.select,disabled:v,userRole:A,doctypeName:R.managements,extraFields:{organization:e.organization},onQuickCreateSuccess:I})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:P.field.department}),t.jsx(ge,{value:e.department,onChange:Q=>F({department:Q}),items:wt,placeholder:P.field.select,disabled:v,userRole:A,doctypeName:R.departments,extraFields:{organization:e.organization,management:e.management},onQuickCreateSuccess:I})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:P.field.section}),t.jsx("input",{style:{...O,...K},value:e.section_field||"",disabled:v,onChange:Q=>F({section_field:Q.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:P.field.branch}),t.jsx(ge,{value:e.branch,onChange:Q=>F({branch:Q}),items:ln,placeholder:P.field.select,disabled:v,userRole:A,doctypeName:R.branches,extraFields:{organization:e.organization,management:e.management,department:e.department},onQuickCreateSuccess:I})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:P.field.eventCategory}),t.jsxs("select",{style:{...O,...K},value:e.event_category||"",disabled:v,onChange:Q=>F({event_category:Q.target.value}),children:[t.jsx("option",{value:"",children:P.field.select}),e.event_category&&!["Complaint","Accident","Violent"].includes(e.event_category)&&t.jsx("option",{value:e.event_category,children:e.event_category}),t.jsx("option",{value:"Complaint",children:"Complaint"}),t.jsx("option",{value:"Accident",children:"Accident"}),t.jsx("option",{value:"Violent",children:"Violent"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:P.field.type}),t.jsx(ge,{value:e.type,onChange:Q=>F({type:Q}),items:me,placeholder:P.field.selectType,disabled:v,userRole:A,doctypeName:R.incidentTypes,onQuickCreateSuccess:I})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:P.field.incidentClass}),t.jsx(ge,{value:e.incident_class,onChange:Q=>F({incident_class:Q}),items:yn,placeholder:P.field.selectClass,disabled:v,userRole:A,doctypeName:R.incidentClass,onQuickCreateSuccess:I})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:P.field.incidentField}),t.jsx(ge,{value:e.incident_field,onChange:Q=>F({incident_field:Q}),items:nt,placeholder:P.field.selectField,disabled:v,userRole:A,doctypeName:R.incidentField,onQuickCreateSuccess:I})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:P.field.hsesField}),t.jsx("input",{style:{...O,...K},value:e.hses_field||"",disabled:v,onChange:Q=>F({hses_field:Q.target.value}),placeholder:"Safety, Health, Environment…"})]})]})}),t.jsxs(oe,{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:D,children:P.field.date}),t.jsx(ve,{value:e.date,onChange:Q=>F({date:Q}),disabled:!0,style:{...O,background:"#f8fafc"}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:P.field.time}),t.jsx("input",{type:"time",style:{...O,background:"#f8fafc"},value:e.time,disabled:!0,readOnly:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:P.field.assignedTo}),v||A==="Employee"?t.jsx("input",{style:{...O,background:"#f8fafc",fontWeight:600,color:"#334155"},value:L||e.assigned_to||"—",readOnly:!0,disabled:!0}):t.jsx(ge,{value:e.assigned_to||"",onChange:Q=>F({assigned_to:Q}),items:E.map(Q=>({name:Q.name,label:Q.full_name||Q.name})),placeholder:P.field.select})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:P.field.description}),t.jsx("textarea",{style:{...O,...K,height:100,resize:"vertical"},value:e.description,disabled:v,onChange:Q=>F({description:Q.target.value}),placeholder:"Detailed description of the incident..."})]})]}),!Tt&&t.jsxs(oe,{title:P.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:D,children:P.field.priority}),t.jsxs("select",{style:{...O,...v||!fe?{background:"#f8fafc"}:{}},value:e.priority||"",disabled:v||!fe,onChange:Q=>F({priority:Q.target.value}),children:[t.jsx("option",{value:"",children:P.field.select}),t.jsx("option",{value:"High",children:P.field.high}),t.jsx("option",{value:"Normal",children:P.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:P.field.economyClass}),t.jsxs("select",{style:{...O,...v||!fe?{background:"#f8fafc"}:{}},value:e.economy_class||"",disabled:v||!fe,onChange:Q=>F({economy_class:Q.target.value}),children:[t.jsx("option",{value:"",children:P.field.select}),t.jsx("option",{value:"Expenses",children:P.field.expenses}),t.jsx("option",{value:"Capital",children:P.field.capital}),t.jsx("option",{value:"Earn",children:P.field.earn}),t.jsx("option",{value:"Pay/Loss",children:P.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:P.field.entityScope}),t.jsxs("select",{style:{...O,...v||!fe?{background:"#f8fafc"}:{}},value:e.entity_scope||"",disabled:v||!fe,onChange:Q=>F({entity_scope:Q.target.value}),children:[t.jsx("option",{value:"",children:P.field.select}),t.jsx("option",{value:"Upstream",children:P.field.upstream}),t.jsx("option",{value:"On-stream",children:P.field.onstream}),t.jsx("option",{value:"Downstream",children:P.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:v||!fe,onChange:Q=>F({product_relation:Q.target.checked?1:0})})," ",P.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:v||!fe,onChange:Q=>F({repeated:Q.target.checked?1:0})})," ",P.field.repeatedEvent]})]})]}),!Tt&&t.jsxs(oe,{title:P.steps.managerSolution,children:[t.jsxs("div",{style:{marginBottom:12},children:[t.jsx("label",{style:D,children:P.field.solution}),t.jsx("textarea",{style:{...O,height:90,resize:"vertical",...v&&!We&&!Se?{background:"#f8fafc"}:{}},value:e.solution||"",disabled:v&&!We&&!Se,onChange:Q=>F({solution:Q.target.value}),placeholder:P.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:D,children:P.field.actualCost}),t.jsx("input",{type:"number",style:{...O,...v&&!We&&!Se?{background:"#f8fafc"}:{}},value:e.cost||"",disabled:v&&!We&&!Se,onChange:Q=>F({cost:parseFloat(Q.target.value)||0}),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:P.field.summary}),t.jsx("input",{style:{...O,...v&&!We&&!Se?{background:"#f8fafc"}:{}},value:e.summary||"",disabled:v&&!We&&!Se,onChange:Q=>F({summary:Q.target.value}),placeholder:"Brief summary"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:P.field.auditorComment}),t.jsx("textarea",{style:{...O,height:70,resize:"vertical",...v&&!Se?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:v&&!Se,onChange:Q=>F({auditor_comment:Q.target.value}),placeholder:P.field.commentPlaceholder})]})]})]})}function C0({ideas:e,organizations:n,departments:s,branches:l,ideaStatuses:a,initialOrg:r,initialStatus:i,canModify:d,userRole:f,onView:p,onEdit:k,onDelete:j,onSelectionChange:S}){const u=se(),[v,z]=_.useState(new Set),[C,g]=_.useState({search:"",organization:r||"",department:"",branch:"",status:i||""}),o=(c,b)=>g(A=>({...A,[c]:b})),[h,x]=_.useState(1),y=e.filter(c=>!(C.search&&!`${c.number} ${c.title}`.toLowerCase().includes(C.search.toLowerCase())||C.organization&&c.organization!==C.organization||C.department&&c.department!==C.department||C.branch&&c.branch!==C.branch||C.status&&c.status!==C.status));_.useEffect(()=>{x(1)},[C]);const w=y.slice((h-1)*ae,h*ae);return _.useEffect(()=>{if(S){const c=e.filter(b=>v.has(b.name));S(c,w)}},[v,w,e]),t.jsxs(t.Fragment,{children:[t.jsx(Si,{children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"10px 14px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.numberTitle}),t.jsx("input",{style:at,value:C.search,onChange:c=>o("search",c.target.value),placeholder:u.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.organization}),t.jsxs("select",{style:at,value:C.organization,onChange:c=>o("organization",c.target.value),children:[t.jsx("option",{value:"",children:u.filter.allOrgs}),n.map(c=>t.jsx("option",{value:c.name,children:c.organization_name||c.name},c.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.department}),t.jsxs("select",{style:at,value:C.department,onChange:c=>o("department",c.target.value),children:[t.jsx("option",{value:"",children:u.filter.allDepts}),s.map(c=>t.jsx("option",{value:c.name,children:c.department_name||c.name},c.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.branch}),t.jsxs("select",{style:at,value:C.branch,onChange:c=>o("branch",c.target.value),children:[t.jsx("option",{value:"",children:u.filter.allBranches}),l.map(c=>t.jsx("option",{value:c.name,children:c.branch||c.name},c.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.status}),t.jsxs("select",{style:at,value:C.status,onChange:c=>o("status",c.target.value),children:[t.jsx("option",{value:"",children:u.filter.allStatuses}),a.map(c=>t.jsx("option",{value:c.name,children:c.name1||c.name},c.name))]})]})]})}),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:w.length>0&&w.every(c=>v.has(c.name)),onChange:c=>{if(c.target.checked)z(new Set([...v,...w.map(b=>b.name)]));else{const b=new Set(v);w.forEach(A=>b.delete(A.name)),z(b)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.actions})]})}),t.jsx("tbody",{children:y.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:u.noIdeas})}):w.map((c,b)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>p==null?void 0:p(c),style:{borderTop:"1px solid #f1f5f9",background:v.has(c.name)?"#eff6ff":c.custom_is_deleted?"#fff1f2":b%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:A=>A.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:v.has(c.name),onChange:()=>{const A=new Set(v);A.has(c.name)?A.delete(c.name):A.add(c.name),z(A)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:c.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:c.title||"—"}),c.sb_order&&t.jsxs("span",{style:{fontSize:11,background:"#f0fdf4",color:"#15803d",border:"1px solid #bbf7d0",borderRadius:9999,padding:"2px 8px",fontWeight:600},children:["📦 ",c.sb_order]})]})}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:c.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:c.custom_is_deleted?fs(u.deletedBadge):c.status?fs(c.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:A=>A.stopPropagation(),children:t.jsx(dt,{onView:()=>p==null?void 0:p(c),onEdit:d&&k&&!c.custom_is_deleted&&!ts("idea",c.workflow_state)&&!(f==="Employee"&&c.workflow_state&&c.workflow_state!=="New")?()=>k(c):void 0,onDelete:d&&j&&!c.custom_is_deleted?()=>j(c.name):void 0})})]},c.name))})]})}),t.jsx(Ue,{page:h,total:y.length,onPageChange:x})]})}const z0={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 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({ideaForm:e,setIdeaForm:n,organizations:s,groupCompanies:l=[],managements:a,departments:r,branches:i,ideaTypes:d,ideaStatuses:f,users:p=[],userRoleMap:k={},formStatus:j,viewMode:S,canModify:u,onEdit:v,onDelete:z,onRestore:C,onPermanentDelete:g,onNavigateToOrder:o,darkMode:h,notifCount:x,onToggleDark:y,onCountChange:w,onViewProfile:c,userRole:b,delegatedFunctions:A=[],delegatedOrgs:T={},onSubmit:M,onBack:H,onNavigate:le,onLogout:U,user:G,onRefresh:$}){var ne;const I=se(),P=L=>n({...e,...L}),F=S?{background:"#f9f9f9"}:{},K=Nl(p,k,"SB Manager",e.organization),[E,ee]=_.useState(""),[V,ce]=_.useState(!1),ie=e.name?S?`${I.formTitle.viewIdea}${e.number||e.title||e.name}`:I.formTitle.editIdea:I.formTitle.newIdea,tt=Zt(a,{organization:e.organization}),Re=Zt(r,{organization:e.organization,management:e.management}),_t=Zt(i,{organization:e.organization,management:e.management,department:e.department}),q=be(tt,e.management).map(L=>({name:L.name,label:L.name1||L.name})),de=be(Re,e.department).map(L=>({name:L.name,label:L.department_name||L.name})),wt=be(_t,e.branch).map(L=>({name:L.name,label:L.branch||L.name})),ln=be(d,e.type).map(L=>({name:L.name,label:L.name1||L.name})),me=e.workflow_state||"New",yn=b==="Employee",nt=b==="Auditor"||b==="Admin",Ie=b==="Manager",Tt=Ie&&A.includes("idea_initial_evaluation")&&(!T.idea_initial_evaluation||(T.idea_initial_evaluation||[]).includes(e.organization)),Se=nt||Tt,We=e.name?me==="New"?[{label:I.wf.submit,action:"Submit",color:"#2563eb"}]:me==="Initial Evaluation"&&Se?[{label:I.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:I.wf.reject,action:"Reject",color:"#dc2626"}]:me==="Accept & Under Progress"&&(Ie||nt)?[{label:I.wf.submitSolution,action:"Submit Proposal",color:"#059669"}]:me==="working on proposal"&&nt?[{label:I.wf.moveToOutsourcing,action:"Move to Outsourcing",color:"#0369a1"},{label:I.wf.reject,action:"Reject",color:"#dc2626"}]:[]:[];async function an(L){if(e.name){ce(!0),ee("");try{const je={};L==="Assign to Manager"&&(e.assigned_to&&(je.assigned_to=e.assigned_to),e.priority&&(je.priority=e.priority),e.economy_class&&(je.economy_class=e.economy_class),e.entity_scope&&(je.entity_scope=e.entity_scope),e.hses_field&&(je.hses_field=e.hses_field),je.product_relation=String(e.product_relation??0),je.repeated=String(e.repeated??0)),L==="Submit Proposal"&&(e.solution&&(je.solution=e.solution),e.proposed_condition&&(je.proposed_condition=e.proposed_condition),e.cost&&(je.cost=String(e.cost))),e.auditor_comment&&(L==="Move to Outsourcing"||L==="Reject")&&(je.auditor_comment=e.auditor_comment);const kt=await Hy(e.name,L,JSON.stringify(je));kt!=null&&kt.created_order&&P({sb_order:kt.created_order,workflow_state:"Executed & Closed",status:"Executed & Closed"}),ee("Done"),$==null||$()}catch(je){ee(je.message||"Error")}finally{ce(!1)}}}const fe=((ne=K.find(L=>L.name===e.assigned_to))==null?void 0:ne.full_name)||e.assigned_to,B=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:I.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:me})]}),me==="Initial Evaluation"&&Se&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:D,children:I.wf.assignToManager}),t.jsxs("select",{style:O,value:e.assigned_to||"",onChange:L=>P({assigned_to:L.target.value}),children:[t.jsx("option",{value:"",children:I.field.selectMgr}),K.map(L=>t.jsx("option",{value:L.name,children:L.full_name||L.name},L.name))]})]}),me==="Accept & Under Progress"&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:D,children:I.field.solution}),t.jsx("textarea",{style:{...O,height:75,resize:"vertical"},value:e.solution||"",onChange:L=>P({solution:L.target.value}),placeholder:I.field.solutionPlaceholder}),t.jsx("label",{style:{...D,marginTop:6},children:I.field.actualCost}),t.jsx("input",{type:"number",style:O,value:e.cost||"",onChange:L=>P({cost:parseFloat(L.target.value)||0}),placeholder:"0.00"})]}),me==="working on proposal"&&nt&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:D,children:I.field.auditorComment}),t.jsx("textarea",{style:{...O,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:L=>P({auditor_comment:L.target.value}),placeholder:I.field.commentPlaceholder})]}),We.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:We.map(L=>t.jsx("button",{onClick:()=>an(L.action),disabled:V,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:L.color,color:"white",fontWeight:600,fontSize:12,cursor:V?"not-allowed":"pointer",opacity:V?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:t.jsx("span",{children:V?I.wf.applying:L.label})},L.action))}):t.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:I.wf.noActions}),E&&t.jsx("p",{style:{marginTop:8,fontSize:12,color:E==="Done"?X.green:X.red},children:E})]}),t.jsx(bi,{priority:e.priority,status:me,assignedTo:fe||(e.assigned_to?e.assigned_to:void 0),createdDate:e.date,modifiedDate:e.modified}),t.jsx(_i,{doctype:R.ideas,docname:e.name,currentUserName:G.name}),t.jsx(wi,{doctype:R.ideas,docname:e.name,docCreation:e.creation,docOwner:e.owner}),u&&z&&!e.custom_is_deleted&&t.jsx(ji,{title:"Delete Request",btnText:I.delete,onDelete:()=>z(e.name)})]}):null;return t.jsxs(et,{title:ie,activePage:"ideas",user:G,formStatus:j,statusBadge:t.jsx("span",{style:I0(me),children:me}),buttonText:I.saveIdea,buttonColor:"#16a34a",viewMode:S,onEdit:v,darkMode:h,notifCount:x,onToggleDark:y,onCountChange:w,onViewProfile:c,rightPanel:B,onSubmit:M,onBack:H,onNavigate:le,onLogout:U,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:C?()=>C(e.name):void 0,onPermanentDelete:g?()=>g(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:[I.field.convertedToOrder,":"]}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#14532d",whiteSpace:"nowrap"},children:e.sb_order})]}),o&&t.jsxs("button",{type:"button",onClick:()=>o(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:L=>L.currentTarget.style.background="#15803d",onMouseLeave:L=>L.currentTarget.style.background="#16a34a",children:[I.field.viewOrder," →"]})]}),t.jsx(oe,{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:D,children:I.field.number}),t.jsx("input",{style:{...O,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:D,children:[I.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(sn,{value:e.organization,onChange:L=>{var kt;const je=(kt=s.find(Q=>Q.name===L))==null?void 0:kt.group_company;P({organization:L,...G.custom_group_company?{}:{group_company:je||e.group_company}})},organizations:s,disabled:S||!!G.custom_organization,userRole:b,onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.title}),t.jsx("input",{style:{...O,...F},value:e.title,disabled:S,onChange:L=>P({title:L.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.management}),t.jsx(ge,{value:e.management,onChange:L=>P({management:L}),items:q,placeholder:I.field.select,disabled:S,userRole:b,doctypeName:R.managements,extraFields:{organization:e.organization},onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.department}),t.jsx(ge,{value:e.department,onChange:L=>P({department:L}),items:de,placeholder:I.field.select,disabled:S,userRole:b,doctypeName:R.departments,extraFields:{organization:e.organization,management:e.management},onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.section}),t.jsx("input",{style:{...O,...F},value:e.section_field||"",disabled:S,onChange:L=>P({section_field:L.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.branch}),t.jsx(ge,{value:e.branch,onChange:L=>P({branch:L}),items:wt,placeholder:I.field.select,disabled:S,userRole:b,doctypeName:R.branches,extraFields:{organization:e.organization,management:e.management,department:e.department},onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.type}),t.jsx(ge,{value:e.type,onChange:L=>P({type:L}),items:ln,placeholder:I.field.selectType,disabled:S,userRole:b,doctypeName:R.ideaTypes,onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.ideaClass}),t.jsxs("select",{style:{...O,...F},value:e.idea_class||"",disabled:S,onChange:L=>P({idea_class:L.target.value}),children:[t.jsx("option",{value:"",children:I.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:D,children:I.field.hsesField}),t.jsx("input",{style:{...O,...F},value:e.hses_field||"",disabled:S,onChange:L=>P({hses_field:L.target.value}),placeholder:"Safety, Health, Environment…"})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.date}),t.jsx(ve,{value:e.date||"",onChange:L=>P({date:L}),disabled:!0,style:{...O,background:"#f8fafc"}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.assignedTo}),S||b==="Employee"?t.jsx("input",{style:{...O,background:"#f8fafc",fontWeight:600,color:"#334155"},value:fe||e.assigned_to||"—",readOnly:!0,disabled:!0}):t.jsx(ge,{value:e.assigned_to||"",onChange:L=>P({assigned_to:L}),items:K.map(L=>({name:L.name,label:L.full_name||L.name})),placeholder:I.field.select})]})]})}),t.jsx(oe,{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:D,children:I.field.currentCondition}),t.jsx("textarea",{style:{...O,...F,height:100,resize:"vertical"},value:e.current_condition,disabled:S,onChange:L=>P({current_condition:L.target.value}),placeholder:"Describe the current condition or problem..."})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.proposedCondition}),t.jsx("textarea",{style:{...O,...F,height:100,resize:"vertical"},value:e.proposed_condition,disabled:S,onChange:L=>P({proposed_condition:L.target.value}),placeholder:"Describe the proposed solution or improvement..."})]})]})}),!yn&&t.jsxs(oe,{title:I.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:D,children:I.field.priority}),t.jsxs("select",{style:{...O,...S||!Se?{background:"#f8fafc"}:{}},value:e.priority||"",disabled:S||!Se,onChange:L=>P({priority:L.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"High",children:I.field.high}),t.jsx("option",{value:"Normal",children:I.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.economyClass}),t.jsxs("select",{style:{...O,...S||!Se?{background:"#f8fafc"}:{}},value:e.economy_class||"",disabled:S||!Se,onChange:L=>P({economy_class:L.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"Expenses",children:I.field.expenses}),t.jsx("option",{value:"Capital",children:I.field.capital}),t.jsx("option",{value:"Earn",children:I.field.earn}),t.jsx("option",{value:"Pay/Loss",children:I.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.entityScope}),t.jsxs("select",{style:{...O,...S||!Se?{background:"#f8fafc"}:{}},value:e.entity_scope||"",disabled:S||!Se,onChange:L=>P({entity_scope:L.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"Upstream",children:I.field.upstream}),t.jsx("option",{value:"On-stream",children:I.field.onstream}),t.jsx("option",{value:"Downstream",children:I.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:S||!Se,onChange:L=>P({product_relation:L.target.checked?1:0})})," ",I.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:S||!Se,onChange:L=>P({repeated:L.target.checked?1:0})})," ",I.field.repeatedEvent]})]})]}),!yn&&t.jsxs(oe,{title:I.steps.managerSolution,children:[t.jsxs("div",{style:{marginBottom:12},children:[t.jsx("label",{style:D,children:I.field.solution}),t.jsx("textarea",{style:{...O,height:90,resize:"vertical",...S&&!Ie&&!nt?{background:"#f8fafc"}:{}},value:e.solution||"",disabled:S&&!Ie&&!nt,onChange:L=>P({solution:L.target.value}),placeholder:I.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:D,children:I.field.actualCost}),t.jsx("input",{type:"number",style:{...O,...S&&!Ie&&!nt?{background:"#f8fafc"}:{}},value:e.cost||"",disabled:S&&!Ie&&!nt,onChange:L=>P({cost:parseFloat(L.target.value)||0}),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.auditorComment}),t.jsx("textarea",{style:{...O,height:60,resize:"vertical",...S&&!nt?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:S&&!nt,onChange:L=>P({auditor_comment:L.target.value}),placeholder:I.field.commentPlaceholder})]})]})]})]})}function T0({orders:e,organizations:n,departments:s,branches:l,orderStatuses:a,initialOrg:r,initialStatus:i,canModify:d,userRole:f,onView:p,onEdit:k,onDelete:j,onSelectionChange:S}){const u=se(),[v,z]=_.useState(new Set),[C,g]=_.useState({search:"",organization:r||"",department:"",branch:"",status:i||""}),o=(c,b)=>g(A=>({...A,[c]:b})),[h,x]=_.useState(1),y=e.filter(c=>!(C.search&&!`${c.number} ${c.title}`.toLowerCase().includes(C.search.toLowerCase())||C.organization&&c.organization!==C.organization||C.department&&c.department!==C.department||C.branch&&c.branch!==C.branch||C.status&&c.status!==C.status));_.useEffect(()=>{x(1)},[C]);const w=y.slice((h-1)*ae,h*ae);return _.useEffect(()=>{if(S){const c=e.filter(b=>v.has(b.name));S(c,w)}},[v,w,e]),t.jsxs(t.Fragment,{children:[t.jsx(Si,{children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"10px 14px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.numberTitle}),t.jsx("input",{style:at,value:C.search,onChange:c=>o("search",c.target.value),placeholder:u.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.organization}),t.jsxs("select",{style:at,value:C.organization,onChange:c=>o("organization",c.target.value),children:[t.jsx("option",{value:"",children:u.filter.allOrgs}),n.map(c=>t.jsx("option",{value:c.name,children:c.organization_name||c.name},c.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.department}),t.jsxs("select",{style:at,value:C.department,onChange:c=>o("department",c.target.value),children:[t.jsx("option",{value:"",children:u.filter.allDepts}),s.map(c=>t.jsx("option",{value:c.name,children:c.department_name||c.name},c.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.branch}),t.jsxs("select",{style:at,value:C.branch,onChange:c=>o("branch",c.target.value),children:[t.jsx("option",{value:"",children:u.filter.allBranches}),l.map(c=>t.jsx("option",{value:c.name,children:c.branch||c.name},c.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.status}),t.jsxs("select",{style:at,value:C.status,onChange:c=>o("status",c.target.value),children:[t.jsx("option",{value:"",children:u.filter.allStatuses}),a.map(c=>t.jsx("option",{value:c.name,children:c.name1||c.name},c.name))]})]})]})}),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:w.length>0&&w.every(c=>v.has(c.name)),onChange:c=>{if(c.target.checked)z(new Set([...v,...w.map(b=>b.name)]));else{const b=new Set(v);w.forEach(A=>b.delete(A.name)),z(b)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.type}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.actions})]})}),t.jsx("tbody",{children:y.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:u.noOrders})}):w.map((c,b)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>p==null?void 0:p(c),style:{borderTop:"1px solid #f1f5f9",background:v.has(c.name)?"#eff6ff":c.custom_is_deleted?"#fff1f2":b%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:A=>A.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:v.has(c.name),onChange:()=>{const A=new Set(v);A.has(c.name)?A.delete(c.name):A.add(c.name),z(A)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:c.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:c.title||c.name||"—"}),c.sb_idea&&t.jsxs("span",{style:{fontSize:11,background:"#eff6ff",color:"#1d4ed8",border:"1px solid #bfdbfe",borderRadius:9999,padding:"2px 8px",fontWeight:600},children:["💡 ",c.sb_idea]})]})}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:c.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:c.type?cc(c.type):"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:c.custom_is_deleted?fs(u.deletedBadge):c.status?fs(c.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:A=>A.stopPropagation(),children:t.jsx(dt,{onView:()=>p==null?void 0:p(c),onEdit:d&&k&&!c.custom_is_deleted&&!ts("order",c.workflow_state)&&f!=="Employee"?()=>k(c):void 0,onDelete:d&&j&&!c.custom_is_deleted?()=>j(c.name):void 0})})]},c.name))})]})}),t.jsx(Ue,{page:h,total:y.length,onPageChange:x})]})}const A0={1:"Initiation / Bidding",2:"Execution begins",3:"Mid-execution review",4:"Near completion",5:"Closing"},P0={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 R0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...P0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function D0({orderForm:e,setOrderForm:n,organizations:s,groupCompanies:l=[],managements:a,departments:r,branches:i,orderTypes:d,orderStatuses:f,cycles:p=[],users:k=[],userRoleMap:j={},formStatus:S,viewMode:u,canModify:v,onEdit:z,onDelete:C,onRestore:g,onPermanentDelete:o,onNavigateToIdea:h,darkMode:x,notifCount:y,onToggleDark:w,onCountChange:c,onViewProfile:b,currentUser:A,userRole:T,onSubmit:M,onBack:H,onNavigate:le,onLogout:U,user:G,onRefresh:$}){var Ya,Hl;const I=se(),P=N=>n({...e,...N}),F=u?{background:"#f9f9f9"}:{},K=Nl(k,j,"SB Employee",e.organization),[E,ee]=_.useState(""),[V,ce]=_.useState(""),[ie,tt]=_.useState(!1),[Re,_t]=_.useState("Agree"),q=e.name?u?`${I.formTitle.viewOrder}${e.number||e.title||e.name}`:I.formTitle.editOrder:I.formTitle.newOrder,de=Zt(a,{organization:e.organization}),wt=Zt(r,{organization:e.organization,management:e.management}),ln=Zt(i,{organization:e.organization,management:e.management,department:e.department}),me=be(de,e.management).map(N=>({name:N.name,label:N.name1||N.name})),yn=be(wt,e.department).map(N=>({name:N.name,label:N.department_name||N.name})),nt=be(ln,e.branch).map(N=>({name:N.name,label:N.branch||N.name})),Ie=be(d,e.type).map(N=>({name:N.name,label:N.name1||N.name})),Tt=["SAR","USD","EUR","AED","GBP","KWD","BHD","QAR","OMR","EGP"],Se=Array.from(new Set([...Tt,e.currency].filter(Boolean))).map(N=>({name:N,label:N})),We=be(p,e.cycle).map(N=>({name:N.name,label:N.name1||N.cycle_name||N.name})),an=!!e.name,fe=e.workflow_state||"Draft",B=Math.min(5,(e.stage||0)+1),[ne,L]=_.useState(B);_.useEffect(()=>{L(Math.min(5,(e.stage||0)+1))},[e.stage]);const je=T==="Auditor"||T==="Admin"||T==="Manager",kt=je||T==="Owner",Q=!!(A&&(e.actor===A||e.assigned_to===A)),Me=e.stage===5||e.completion_pct===100||e.status==="Completion"||fe==="Completed"||fe==="Closed",At=e.order_cycle_log||[],xs=At.length>0?At[At.length-1].status:Re,ys=xs==="Deviate"||xs==="Deviated"||xs==="Unknown",Ha=(()=>{if(!an)return[];if(fe==="Closed"||fe==="Completed")return[];if(fe==="Draft"&&je)return[{label:"Submit for Review",action:"Submit for Review",color:"#2563eb"}];if(fe==="Pending Actor"&&(Q||je))return[{label:"Update Status",action:"Update Status",color:"#d97706"}];if(fe==="Review"&&kt){const N=[{label:"Move to Study",action:"Move to Study",color:"#059669"}];return(!Me||ys)&&N.push({label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"}),Me&&N.push({label:"Close Order",action:"Close Order",color:"#475569"}),N}if(fe==="In Study"&&kt){const N=[];return(!Me||ys)&&N.push({label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"}),N.push({label:"Close Order",action:"Close Order",color:"#475569"}),N}return[]})();async function Ga(N){if(e.name){tt(!0),ee("");try{let ft;N==="Update Status"&&(ft=Re);const Tn=await My(e.name,N,V,N==="Update Status"?String(ne):void 0,void 0,ft);if(ce(""),_t("Agree"),ee("Done"),Tn){const De=Tn;n({...e,...De,stage:De.stage??e.stage,completion_pct:De.completion_pct??e.completion_pct,workflow_state:De.workflow_state??e.workflow_state})}$==null||$()}catch(ft){ee(ft.message||"Error")}finally{tt(!1)}}}const Qa=((Ya=K.find(N=>N.name===(e.actor||e.assigned_to)))==null?void 0:Ya.full_name)||e.actor||e.assigned_to,Ka=an?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:I.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:fe})]}),fe==="Pending Actor"&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:12},children:[t.jsxs("div",{children:[t.jsxs("label",{style:D,children:["Stage (1–5) — ",ne*20,"% complete"]}),t.jsx("input",{type:"number",min:1,max:5,style:{...O,width:"100%"},value:ne,onChange:N=>L(Math.min(5,Math.max(1,parseInt(N.target.value)||1)))})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:"Cycle Status"}),t.jsxs("select",{style:O,value:Re,onChange:N=>_t(N.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:D,children:["Comment ",Re==="Deviate"&&fe==="Pending Actor"?t.jsx("span",{style:{color:X.red},children:" * required for Deviate"}):"(optional)"]}),t.jsx("textarea",{style:{...O,height:60,resize:"vertical",borderColor:Re==="Deviate"&&!V?"#fca5a5":void 0},value:V,onChange:N=>ce(N.target.value),placeholder:"Add a comment…"})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:Ha.map(N=>{const ft=N.action==="Update Status"&&Re==="Deviate"&&!V.trim();return t.jsx("button",{onClick:()=>Ga(N.action),disabled:ie||ft,title:ft?"Comment required when status is Deviate":void 0,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:N.color,color:"white",fontWeight:600,fontSize:12,cursor:ie||ft?"not-allowed":"pointer",opacity:ie||ft?.5:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:t.jsx("span",{children:ie?I.wf.applying:N.label})},N.action)})}),E&&t.jsx("p",{style:{marginTop:8,fontSize:12,color:E==="Done"?X.green:X.red},children:E}),Ha.length===0&&t.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:I.wf.noActions})]}),t.jsx(bi,{priority:e.priority,status:fe,assignedTo:T!=="Employee"?Qa:void 0,createdDate:e.starting_date,modifiedDate:e.modified}),t.jsx(_i,{doctype:R.orders,docname:e.name,currentUserName:G.name}),t.jsx(wi,{doctype:R.orders,docname:e.name,docCreation:e.creation,docOwner:e.owner}),v&&C&&!e.custom_is_deleted&&t.jsx(ji,{title:"Delete Request",btnText:I.delete,onDelete:()=>C(e.name)})]}):null;return t.jsxs(et,{title:q,activePage:"orders",user:G,formStatus:S,statusBadge:t.jsx("span",{style:R0(fe),children:fe}),buttonText:I.saveOrder,buttonColor:"#16a34a",viewMode:u,onEdit:z,darkMode:x,notifCount:y,onToggleDark:w,onCountChange:c,onViewProfile:b,rightPanel:Ka,onSubmit:M,onBack:H,onNavigate:le,onLogout:U,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:g?()=>g(e.name):void 0,onPermanentDelete:o?()=>o(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:[I.field.originatingIdea,":"]}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#1e3a8a",whiteSpace:"nowrap"},children:e.sb_idea})]}),h&&t.jsxs("button",{type:"button",onClick:()=>h(e.sb_idea),style:{background:"#2563eb",color:"#fff",border:"none",borderRadius:6,padding:"4px 10px",fontWeight:600,fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,flexShrink:0,transition:"background 0.15s ease"},onMouseEnter:N=>N.currentTarget.style.background="#1d4ed8",onMouseLeave:N=>N.currentTarget.style.background="#2563eb",children:[I.field.viewIdea," →"]})]}),t.jsx(oe,{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:D,children:I.field.number}),t.jsx("input",{style:{...O,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:D,children:[I.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(sn,{value:e.organization,onChange:N=>{var Tn;const ft=(Tn=s.find(De=>De.name===N))==null?void 0:Tn.group_company;P({organization:N,...G.custom_group_company?{}:{group_company:ft||e.group_company}})},organizations:s,disabled:u||!!G.custom_organization,userRole:T,onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.title}),t.jsx("input",{style:{...O,...F},value:e.title,disabled:u,onChange:N=>P({title:N.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.management}),t.jsx(ge,{value:e.management,onChange:N=>P({management:N}),items:me,placeholder:I.field.select,disabled:u,userRole:T,doctypeName:R.managements,extraFields:{organization:e.organization},onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.department}),t.jsx(ge,{value:e.department,onChange:N=>P({department:N}),items:yn,placeholder:I.field.select,disabled:u,userRole:T,doctypeName:R.departments,extraFields:{organization:e.organization,management:e.management},onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.section}),t.jsx("input",{style:{...O,...F},value:e.section_field||"",disabled:u,onChange:N=>P({section_field:N.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.branch}),t.jsx(ge,{value:e.branch,onChange:N=>P({branch:N}),items:nt,placeholder:I.field.select,disabled:u,userRole:T,doctypeName:R.branches,extraFields:{organization:e.organization,management:e.management,department:e.department},onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.type}),t.jsx(ge,{value:e.type,onChange:N=>P({type:N}),items:Ie,placeholder:I.field.selectType,disabled:u,userRole:T,doctypeName:R.orderTypes,onQuickCreateSuccess:$})]})]})}),t.jsxs(oe,{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:D,children:I.field.budget}),t.jsx("input",{type:"number",style:{...O,...F},value:e.budget||"",disabled:u,onChange:N=>P({budget:parseFloat(N.target.value)||0})})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.actualCost}),t.jsx("input",{type:"number",style:{...O,...F},value:e.actual_cost||"",disabled:u,onChange:N=>P({actual_cost:parseFloat(N.target.value)||0})})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:"Variance"}),(()=>{const N=(e.budget||0)-(e.actual_cost||0);return t.jsxs("div",{style:{padding:"7px 12px",borderRadius:6,fontWeight:700,fontSize:13,background:N>=0?"#f0fdf4":"#fef2f2",color:N>=0?"#166534":"#dc2626",border:`1px solid ${N>=0?"#bbf7d0":"#fecaca"}`,display:"inline-block",width:"100%",boxSizing:"border-box"},children:[N>=0?"+":"",N.toFixed(2)]})})()]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.currency}),t.jsx(ge,{value:e.currency||"",onChange:N=>P({currency:N}),items:Se,placeholder:I.field.select,disabled:u,userRole:T,doctypeName:R.currency,onQuickCreateSuccess:$})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.startingDate}),t.jsx(ve,{value:e.starting_date,onChange:N=>P({starting_date:N}),disabled:u,style:{...O,...F}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.endingDate}),t.jsx(ve,{value:e.ending_date,onChange:N=>P({ending_date:N}),disabled:u,style:{...O,...F}})]}),T!=="Employee"&&t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.actor}),u?t.jsx("input",{style:{...O,background:"#f8fafc",fontWeight:600,color:"#334155"},value:Qa||"—",readOnly:!0,disabled:!0}):t.jsxs("select",{style:{...O,background:"#ffffff"},value:e.actor||e.assigned_to||"",onChange:N=>P({actor:N.target.value,assigned_to:N.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),K.map(N=>t.jsx("option",{value:N.name,children:N.full_name||N.name},N.name))]})]})]})]}),t.jsxs(oe,{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:D,children:I.field.priority}),t.jsxs("select",{style:{...O,...F},value:e.priority||"",disabled:u,onChange:N=>P({priority:N.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"High",children:I.field.high}),t.jsx("option",{value:"Normal",children:I.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.economyClass}),t.jsxs("select",{style:{...O,...F},value:e.economy_class||"",disabled:u,onChange:N=>P({economy_class:N.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"Expenses",children:I.field.expenses}),t.jsx("option",{value:"Capital",children:I.field.capital}),t.jsx("option",{value:"Earn",children:I.field.earn}),t.jsx("option",{value:"Pay/Loss",children:I.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.entityScope}),t.jsxs("select",{style:{...O,...F},value:e.entity_scope||"",disabled:u,onChange:N=>P({entity_scope:N.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"Upstream",children:I.field.upstream}),t.jsx("option",{value:"On-stream",children:I.field.onstream}),t.jsx("option",{value:"Downstream",children:I.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:u,onChange:N=>P({planned:N.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:u,onChange:N=>P({product_relation:N.target.checked?1:0})})," ",I.field.productRelation]})]}),t.jsxs("div",{style:{marginTop:12},children:[t.jsx("label",{style:D,children:I.field.hsesField}),t.jsx("input",{style:{...O,...F},value:e.hses_field||"",disabled:u,onChange:N=>P({hses_field:N.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),t.jsxs(oe,{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:D,children:I.field.cycle}),t.jsx(ge,{value:e.cycle||"",onChange:N=>P({cycle:N}),items:We,placeholder:I.field.select,disabled:u,userRole:T,doctypeName:R.cycles,extraFields:{organization:e.organization},onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.cycleType}),t.jsxs("select",{style:{...O,...F},value:e.cycle_type||"Normal",disabled:u,onChange:N=>P({cycle_type:N.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:D,children:I.field.stage}),t.jsx("input",{type:"number",min:1,max:5,style:{...O,background:"#f8fafc",color:"#334155",fontWeight:600},value:e.stage||1,readOnly:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:"Completion"}),t.jsx("input",{style:{...O,background:"#f8fafc",color:"#334155",fontWeight:600},value:`${e.completion_pct||(e.stage||1)*20}%`,readOnly:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,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:A0[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:D,children:"Milestone 1"}),t.jsx(ve,{value:e.long_cycle_date_1||"",onChange:N=>P({long_cycle_date_1:N}),disabled:u,style:{...O,...F}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:"Milestone 2"}),t.jsx(ve,{value:e.long_cycle_date_2||"",onChange:N=>P({long_cycle_date_2:N}),disabled:u,style:{...O,...F}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:"Milestone 3"}),t.jsx(ve,{value:e.long_cycle_date_3||"",onChange:N=>P({long_cycle_date_3:N}),disabled:u,style:{...O,...F}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:"Milestone 4"}),t.jsx(ve,{value:e.long_cycle_date_4||"",onChange:N=>P({long_cycle_date_4:N}),disabled:u,style:{...O,...F}})]})]})]}),an&&((Hl=e.order_cycle_log)==null?void 0:Hl.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(N=>t.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#475569",borderBottom:"1px solid #e2e8f0"},children:N},N))})}),t.jsx("tbody",{children:(e.order_cycle_log||[]).map((N,ft)=>{const Tn=N.status==="Agree"?"#166534":N.status==="Deviate"?"#c2410c":"#92400e",De=N.status==="Agree"?"#f0fdf4":N.status==="Deviate"?"#fff7ed":"#fefce8";return t.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:N.cycle||"—"}),t.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:N.cycle_date||"—"}),t.jsx("td",{style:{padding:"6px 10px",color:"#334155",textAlign:"center"},children:N.stage||"—"}),t.jsx("td",{style:{padding:"6px 10px"},children:t.jsx("span",{style:{background:De,color:Tn,padding:"2px 8px",borderRadius:12,fontWeight:600,fontSize:12},children:N.status||"—"})}),t.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:N.actor||"—"}),t.jsx("td",{style:{padding:"6px 10px",color:"#64748b",fontStyle:N.comment?"normal":"italic"},children:N.comment||"—"})]},ft)})})]})})]})]}),t.jsxs(oe,{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:D,children:I.field.description}),t.jsx("textarea",{style:{...O,...F,height:90,resize:"vertical"},value:e.description,disabled:u,onChange:N=>P({description:N.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.notes}),t.jsx("textarea",{style:{...O,...F,height:90,resize:"vertical"},value:e.notes,disabled:u,onChange:N=>P({notes:N.target.value})})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:I.field.auditorComment}),t.jsx("textarea",{style:{...O,height:70,resize:"vertical",...u&&Q&&!je?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:u&&Q&&!je,onChange:N=>P({auditor_comment:N.target.value}),placeholder:I.field.commentPlaceholder})]})]})]})}function O0({processes:e,organizations:n,departments:s,branches:l,processStatuses:a,initialOrg:r,initialStatus:i,canModify:d,userRole:f,onView:p,onEdit:k,onDelete:j,onSelectionChange:S}){const u=se(),[v,z]=_.useState(new Set),[C,g]=_.useState({search:"",organization:r||"",department:"",branch:"",status:i||""}),o=(c,b)=>g(A=>({...A,[c]:b})),[h,x]=_.useState(1),y=e.filter(c=>!(C.search&&!`${c.number} ${c.title}`.toLowerCase().includes(C.search.toLowerCase())||C.organization&&c.organization!==C.organization||C.department&&c.department!==C.department||C.branch&&c.branch!==C.branch||C.status&&c.status!==C.status));_.useEffect(()=>{x(1)},[C]);const w=y.slice((h-1)*ae,h*ae);return _.useEffect(()=>{if(S){const c=e.filter(b=>v.has(b.name));S(c,w)}},[v,w,e]),t.jsxs(t.Fragment,{children:[t.jsx(Si,{children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"10px 14px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.numberTitle}),t.jsx("input",{style:at,value:C.search,onChange:c=>o("search",c.target.value),placeholder:u.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.organization}),t.jsxs("select",{style:at,value:C.organization,onChange:c=>o("organization",c.target.value),children:[t.jsx("option",{value:"",children:u.filter.allOrgs}),n.map(c=>t.jsx("option",{value:c.name,children:c.organization_name||c.name},c.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.department}),t.jsxs("select",{style:at,value:C.department,onChange:c=>o("department",c.target.value),children:[t.jsx("option",{value:"",children:u.filter.allDepts}),s.map(c=>t.jsx("option",{value:c.name,children:c.department_name||c.name},c.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.branch}),t.jsxs("select",{style:at,value:C.branch,onChange:c=>o("branch",c.target.value),children:[t.jsx("option",{value:"",children:u.filter.allBranches}),l.map(c=>t.jsx("option",{value:c.name,children:c.branch||c.name},c.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:lt,children:u.filter.status}),t.jsxs("select",{style:at,value:C.status,onChange:c=>o("status",c.target.value),children:[t.jsx("option",{value:"",children:u.filter.allStatuses}),a.map(c=>t.jsx("option",{value:c.name,children:c.name1||c.name},c.name))]})]})]})}),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:w.length>0&&w.every(c=>v.has(c.name)),onChange:c=>{if(c.target.checked)z(new Set([...v,...w.map(b=>b.name)]));else{const b=new Set(v);w.forEach(A=>b.delete(A.name)),z(b)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.field.cycleType}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:u.col.actions})]})}),t.jsx("tbody",{children:y.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:u.noProcesses})}):w.map((c,b)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>p==null?void 0:p(c),style:{borderTop:"1px solid #f1f5f9",background:v.has(c.name)?"#eff6ff":c.custom_is_deleted?"#fff1f2":b%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:A=>A.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:v.has(c.name),onChange:()=>{const A=new Set(v);A.has(c.name)?A.delete(c.name):A.add(c.name),z(A)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:c.number||"—"}),t.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:c.title||c.name||"—"}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:c.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:c.cycle_type?cc(c.cycle_type):"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:c.custom_is_deleted?fs(u.deletedBadge):c.status?fs(c.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:A=>A.stopPropagation(),children:t.jsx(dt,{onView:()=>p==null?void 0:p(c),onEdit:d&&k&&!c.custom_is_deleted&&!ts("process",c.workflow_state)&&f!=="Employee"?()=>k(c):void 0,onDelete:d&&j&&!c.custom_is_deleted?()=>j(c.name):void 0})})]},c.name))})]})}),t.jsx(Ue,{page:h,total:y.length,onPageChange:x})]})}const L0={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"]},{action:"Close Process",next:"Closed",allowedRoles:["Auditor","Manager"]}],"In Study":[{action:"Start New Cycle",next:"Pending Actor",allowedRoles:["Auditor","Manager"]},{action:"Close Process",next:"Closed",allowedRoles:["Auditor","Manager"]}]},W0={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"},Completed:{background:"#ecfdf5",color:"#047857",border:"1px solid #a7f3d0"},Closed:{background:"#f3f4f6",color:"#6b7280",border:"1px solid #9ca3af"}};function Bu(e){return{display:"inline-block",padding:"5px 14px",borderRadius:20,fontSize:13,fontWeight:700,...W0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}const mr={width:"100%",padding:"6px 8px",border:"1px solid #d1d5db",borderRadius:5,fontSize:12,fontFamily:"Segoe UI",boxSizing:"border-box"};function N0({processName:e,userRole:n,onRefresh:s,canUpdateStatus:l=!0}){const[a,r]=_.useState(null),[i,d]=_.useState(!0),[f,p]=_.useState(""),[k,j]=_.useState(!1),[S,u]=_.useState(""),[v,z]=_.useState(""),[C,g]=_.useState("Pass"),[o,h]=_.useState(""),[x,y]=_.useState({}),w=_.useCallback(async()=>{if(!e){d(!1);return}d(!0),p("");try{const U=await da(e);r(U);const G={};for(const $ of U.progress_indicators||[])G[$.name]=$.actual_value!=null?String($.actual_value):"";y(G)}catch(U){p(U instanceof Error?U.message:"Failed to load process")}d(!1)},[e]);if(_.useEffect(()=>{w()},[w]),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(f||!a)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:f||"Could not load workflow"})})});const c=a.workflow_state||"Draft",b=L0[c]??[],A=n==="Employee"||n==="Manager",T=n!=="Manager"||l,M=a.completion_pct===100||a.stage===5||a.status==="Completion"||a.status==="Completed"||c==="Completed"||c==="Closed",H=b.filter(U=>U.action==="Start New Cycle"&&M?!1:(n==="Admin"||U.allowedRoles.includes(n))&&(U.action!=="Update Status"||T)),le=async U=>{j(!0),u(""),z("");try{const G={};if(U==="Update Status"){G.actor_status=C,G.actor_comment=o;const I=a.progress_indicators||[];I.length>0&&(G.progress_indicators=I.map(P=>({name:P.name,actual_value:x[P.name]??""})))}U==="Add Comment"&&o&&(G.actor_comment=o);const $=await s0(a.name,U,G);r($),h(""),z(`Done — now: ${$.workflow_state||"updated"}`),s==null||s()}catch(G){u(G instanceof Error?G.message:"Action failed")}j(!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:Bu(c),children:c})]}),c==="Pending Actor"&&A&&T&&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(a.progress_indicators)&&a.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:a.progress_indicators.map(U=>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:U.name1,children:U.name1||U.name}),t.jsx("input",{type:"number",value:x[U.name]??"",onChange:G=>y($=>({...$,[U.name]:G.target.value})),style:{...mr,width:70,flexShrink:0},placeholder:"0"})]},U.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:C,onChange:U=>g(U.target.value),style:mr,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:U=>h(U.target.value),style:{...mr,height:52,resize:"vertical"},placeholder:"Add a comment…"})]})]}),(c==="Pending Comment"||c==="Review")&&!A&&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(a.cycle_logs)&&a.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 U=a.cycle_logs,G=U[U.length-1],$=G.status==="Pass"?"#16a34a":G.status==="Fail"?"#dc2626":"#9ca3af";return t.jsxs("div",{style:{fontSize:13,fontWeight:700,color:$},children:[G.status," ",G.comment?`— ${G.comment}`:""]})})()]}),t.jsx("textarea",{value:o,onChange:U=>h(U.target.value),style:{...mr,height:52,resize:"vertical"},placeholder:"Add a comment…"})]}),t.jsxs("div",{style:{padding:"12px 14px",borderBottom:H.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"}),H.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:c}),"."]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:H.map(U=>t.jsxs("button",{onClick:()=>le(U.action),disabled:k,style:{width:"100%",padding:"10px 14px",borderRadius:6,border:"none",background:U.action==="Close Process"?"#64748b":U.action==="Move to Study"?"#8e44ad":"#2563eb",color:"white",cursor:k?"not-allowed":"pointer",fontSize:13,fontWeight:600,opacity:k?.7:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{children:k?"Applying…":U.action}),t.jsxs("span",{style:{fontSize:10,opacity:.7},children:["→ ",U.next]})]},U.action))}),S&&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:S}),v&&t.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,fontSize:12,color:"#166534"},children:v})]}),b.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"}),b.map(U=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6,fontSize:11},children:[t.jsx("span",{style:{color:"#555",flex:1},children:U.action}),t.jsx("span",{style:{color:"#bbb"},children:"→"}),t.jsx("span",{style:Bu(U.next),children:U.next})]},U.action))]})]})})}function B0({processForm:e,setProcessForm:n,organizations:s,groupCompanies:l=[],managements:a,departments:r,branches:i,processTypes:d,processStatuses:f,cycles:p=[],users:k=[],userRoleMap:j={},formStatus:S,viewMode:u,canModify:v,onEdit:z,onDelete:C,onRestore:g,onPermanentDelete:o,darkMode:h,notifCount:x,onToggleDark:y,onCountChange:w,onViewProfile:c,userRole:b,onRefreshProcess:A,onSubmit:T,onBack:M,onNavigate:H,onLogout:le,user:U}){var fe;const G=se(),$=B=>n({...e,...B}),I=u?{background:"#f9f9f9"}:{},P=s,F=!!U.custom_organization,K=Zt(a,{organization:e.organization}),E=Zt(r,{organization:e.organization,management:e.management}),ee=Zt(i,{organization:e.organization,management:e.management,department:e.department}),V=be(K,e.management).map(B=>({name:B.name,label:B.name1||B.name})),ce=be(E,e.department).map(B=>({name:B.name,label:B.department_name||B.name})),ie=be(ee,e.branch).map(B=>({name:B.name,label:B.branch||B.name})),tt=be(d,e.type).map(B=>({name:B.name,label:B.name1||B.name})),Re=be(p,e.cycle).map(B=>({name:B.name,label:B.name1||B.name})),_t=Nl(k,j,"SB Employee",e.organization).map(B=>({name:B.name,label:B.full_name||B.name})),q=Nl(k,j,"SB Manager",e.organization).map(B=>({name:B.name,label:B.full_name||B.name})),de=(B,ne)=>{const L=[...e.cycle_logs||[]];L[B]={...L[B],...ne},$({cycle_logs:L})},wt=()=>{$({cycle_logs:[...e.cycle_logs||[],{cycle:"",cycle_date:"",status:"Pass",actor:"",comment:""}]})},ln=B=>{const ne=[...e.cycle_logs||[]];ne.splice(B,1),$({cycle_logs:ne})},me=(B,ne)=>{const L=[...e.progress_indicators||[]];L[B]={...L[B],...ne},$({progress_indicators:L})},yn=()=>{$({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"}]})},nt=B=>{const ne=[...e.progress_indicators||[]];ne.splice(B,1),$({progress_indicators:ne})},Ie=e.name?u?`${G.formTitle.viewProcess}${e.title||e.name}`:G.formTitle.editProcess:G.formTitle.newProcess,Tt=b!=="Manager"||e.actor===U.name,Se=((fe=_t.find(B=>B.name===e.actor))==null?void 0:fe.label)||e.actor,We=e.workflow_state||"Draft",an=e.name?t.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[t.jsx(N0,{processName:e.name,userRole:b||U.role||"Employee",onRefresh:A,canUpdateStatus:Tt}),t.jsx(bi,{priority:e.impact_level,status:We,assignedTo:Se,createdDate:e.date_start,modifiedDate:e.modified}),t.jsx(_i,{doctype:R.processes,docname:e.name,currentUserName:U.name}),t.jsx(wi,{doctype:R.processes,docname:e.name,docCreation:e.creation,docOwner:e.owner}),v&&C&&!e.custom_is_deleted&&t.jsx(ji,{title:"Delete Request",btnText:G.delete,onDelete:()=>C(e.name)})]}):void 0;return t.jsxs(et,{title:Ie,activePage:"processes",user:U,formStatus:S,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:We}),buttonText:G.saveProcess,buttonColor:"#16a34a",viewMode:u,onEdit:z,darkMode:h,notifCount:x,onToggleDark:y,onCountChange:w,onViewProfile:c,rightPanel:an,onSubmit:T,onBack:M,onNavigate:H,onLogout:le,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:g?()=>g(e.name):void 0,onPermanentDelete:o?()=>o(e.name):void 0}),t.jsx(oe,{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:D,children:G.field.number}),t.jsx("input",{style:{...O,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number||"",readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:D,children:[G.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(sn,{value:e.organization,onChange:B=>{var L;const ne=(L=s.find(je=>je.name===B))==null?void 0:L.group_company;$({organization:B,...U.custom_group_company?{}:{group_company:ne||e.group_company}})},organizations:P,disabled:u||F,userRole:b,onQuickCreateSuccess:A})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:G.field.title}),t.jsx("input",{style:{...O,...I},value:e.title,disabled:u,onChange:B=>$({title:B.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:G.field.type}),t.jsx(ge,{value:e.type,onChange:B=>$({type:B}),items:tt,placeholder:G.field.selectType,disabled:u,userRole:b,doctypeName:R.processTypes,onQuickCreateSuccess:A})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:G.field.management}),t.jsx(ge,{value:e.management,onChange:B=>$({management:B}),items:V,placeholder:G.field.select,disabled:u,userRole:b,doctypeName:R.managements,extraFields:{organization:e.organization},onQuickCreateSuccess:A})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:G.field.department}),t.jsx(ge,{value:e.department,onChange:B=>$({department:B}),items:ce,placeholder:G.field.select,disabled:u,userRole:b,doctypeName:R.departments,extraFields:{organization:e.organization,management:e.management},onQuickCreateSuccess:A})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:G.field.section}),t.jsx("input",{style:{...O,...I},value:e.section_field||"",disabled:u,onChange:B=>$({section_field:B.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:G.field.branch}),t.jsx(ge,{value:e.branch,onChange:B=>$({branch:B}),items:ie,placeholder:G.field.select,disabled:u,userRole:b,doctypeName:R.branches,extraFields:{organization:e.organization,management:e.management,department:e.department},onQuickCreateSuccess:A})]})]})}),t.jsxs(oe,{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:D,children:G.field.chainLocation}),t.jsxs("select",{style:{...O,...I},value:e.chain_location||"",disabled:u,onChange:B=>$({chain_location:B.target.value}),children:[t.jsx("option",{value:"",children:G.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:D,children:G.field.economyClass}),t.jsxs("select",{style:{...O,...I},value:e.economy_class||"",disabled:u,onChange:B=>$({economy_class:B.target.value}),children:[t.jsx("option",{value:"",children:G.field.select}),t.jsx("option",{value:"Expenses",children:G.field.expenses}),t.jsx("option",{value:"Capital",children:G.field.capital}),t.jsx("option",{value:"Earn",children:G.field.earn}),t.jsx("option",{value:"Pay/Loss",children:G.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:G.field.impactLevel}),t.jsxs("select",{style:{...O,...I},value:e.impact_level||"",disabled:u,onChange:B=>$({impact_level:B.target.value}),children:[t.jsx("option",{value:"",children:G.field.select}),t.jsx("option",{value:"High",children:G.field.high}),t.jsx("option",{value:"Normal",children:G.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:G.field.entityScope}),t.jsxs("select",{style:{...O,...I},value:e.entity_scope||"",disabled:u,onChange:B=>$({entity_scope:B.target.value}),children:[t.jsx("option",{value:"",children:G.field.select}),t.jsx("option",{value:"Upstream",children:G.field.upstream}),t.jsx("option",{value:"On-stream",children:G.field.onstream}),t.jsx("option",{value:"Downstream",children:G.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:D,children:G.field.hsesField}),t.jsx("input",{style:{...O,...I},value:e.hses_field||"",disabled:u,onChange:B=>$({hses_field:B.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:u,onChange:B=>$({product_relation:B.target.checked?1:0})})," ",G.field.productRelation]})})]})]}),t.jsxs(oe,{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:D,children:G.field.kpiName}),t.jsx("input",{style:{...O,...I},value:e.kpi_name||"",disabled:u,onChange:B=>$({kpi_name:B.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:G.field.kpiType}),t.jsxs("select",{style:{...O,...I},value:e.kpi_type||"",disabled:u,onChange:B=>$({kpi_type:B.target.value}),children:[t.jsx("option",{value:"",children:G.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:D,children:G.field.kpiMeasure}),t.jsx("input",{style:{...O,...I},value:e.kpi_measure||"",disabled:u,onChange:B=>$({kpi_measure:B.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:D,children:G.field.dateStart}),t.jsx(ve,{value:e.date_start,onChange:B=>$({date_start:B}),disabled:u,style:{...O,...I}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:G.field.dateEnd}),t.jsx(ve,{value:e.date_end,onChange:B=>$({date_end:B}),disabled:u,style:{...O,...I}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:G.field.cycleType}),t.jsxs("select",{style:{...O,...I},value:e.cycle_type||"",disabled:u,onChange:B=>$({cycle_type:B.target.value}),children:[t.jsx("option",{value:"",children:G.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:D,children:"Milestone 1"}),t.jsx(ve,{value:e.long_cycle_date_1||"",onChange:B=>$({long_cycle_date_1:B}),disabled:u,style:{...O,...I}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:"Milestone 2"}),t.jsx(ve,{value:e.long_cycle_date_2||"",onChange:B=>$({long_cycle_date_2:B}),disabled:u,style:{...O,...I}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:"Milestone 3"}),t.jsx(ve,{value:e.long_cycle_date_3||"",onChange:B=>$({long_cycle_date_3:B}),disabled:u,style:{...O,...I}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:"Milestone 4"}),t.jsx(ve,{value:e.long_cycle_date_4||"",onChange:B=>$({long_cycle_date_4:B}),disabled:u,style:{...O,...I}})]})]})]})]}),t.jsxs(oe,{title:"Progress Indicators",children:[t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:12},children:!u&&t.jsx("button",{type:"button",onClick:yn,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"}),!u&&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:u?14:15,style:{padding:18,textAlign:"center",color:"#94a3b8"},children:"No progress indicators"})}),(e.progress_indicators||[]).map((B,ne)=>t.jsxs("tr",{style:{background:ne%2===0?"white":"#fafafa",borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...O,...I,width:60},value:B.order??"",disabled:u,onChange:L=>me(ne,{order:L.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...O,...I},value:B.name1,disabled:u,onChange:L=>me(ne,{name1:L.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...O,...I},value:B.type,disabled:u,onChange:L=>me(ne,{type:L.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:{...O,...I,width:70},type:"text",value:B.unit??"",disabled:u,onChange:L=>me(ne,{unit:L.target.value}),placeholder:"e.g. °C, kg, %"})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...O,...I,minWidth:120},value:B.cycle,disabled:u,onChange:L=>me(ne,{cycle:L.target.value}),children:[t.jsx("option",{value:"",children:"--"}),Re.map(L=>t.jsx("option",{value:L.name,children:L.label},L.name)),B.cycle&&!Re.some(L=>L.name===B.cycle)&&t.jsx("option",{value:B.cycle,children:B.cycle})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...O,...I,width:80},value:B.target,disabled:u,onChange:L=>me(ne,{target:L.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...O,...I,width:80},value:B.minimum,disabled:u,onChange:L=>me(ne,{minimum:L.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...O,...I,width:80},value:B.maximum,disabled:u,onChange:L=>me(ne,{maximum:L.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...O,...I,minWidth:140},value:B.manager,disabled:u,onChange:L=>me(ne,{manager:L.target.value}),children:[t.jsx("option",{value:"",children:"--"}),q.map(L=>t.jsx("option",{value:L.name,children:L.label},L.name)),B.manager&&!q.some(L=>L.name===B.manager)&&t.jsx("option",{value:B.manager,children:B.manager})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...O,...I,width:90},type:"number",value:B.actual_value??"",disabled:u,onChange:L=>me(ne,{actual_value:parseFloat(L.target.value)||""})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...O,...I},value:B.cycle_status??"",disabled:u,onChange:L=>me(ne,{cycle_status:L.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(ve,{value:B.cycle_date||"",onChange:L=>me(ne,{cycle_date:L}),disabled:u,style:{...O,...I,width:110}})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...O,...I},value:B.cycle_comment??"",disabled:u,onChange:L=>me(ne,{cycle_comment:L.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...O,...I},value:B.status??"",disabled:u,onChange:L=>me(ne,{status:L.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"})]})}),!u&&t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("button",{type:"button",onClick:()=>nt(ne),style:{padding:"4px 8px",border:"1px solid #fecaca",background:"#fef2f2",color:"#dc2626",borderRadius:4,cursor:"pointer",fontSize:11,fontWeight:600},children:"Remove"})})]},ne))]})]})})]}),t.jsx(oe,{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:D,children:G.field.cycle}),t.jsx(ge,{value:e.cycle||"",onChange:B=>$({cycle:B}),items:Re,placeholder:G.field.select,disabled:u,userRole:b,doctypeName:R.cycles,extraFields:{organization:e.organization},onQuickCreateSuccess:A})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:G.field.actor}),t.jsxs("select",{style:{...O,...I},value:e.actor||"",disabled:u,onChange:B=>$({actor:B.target.value}),children:[t.jsx("option",{value:"",children:G.field.select}),_t.map(B=>t.jsx("option",{value:B.name,children:B.label},B.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:G.field.costPerCycle}),t.jsx("input",{style:{...O,...I},type:"number",value:e.cost_per_cycle||"",disabled:u,onChange:B=>$({cost_per_cycle:parseFloat(B.target.value)||0}),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:G.field.escalationLevel}),t.jsx("input",{style:{...O,...I},type:"number",value:e.escalation_level||"",disabled:u,onChange:B=>$({escalation_level:parseInt(B.target.value)||0})})]})]})}),t.jsxs(oe,{title:"Cycle History",children:[t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:12},children:!u&&t.jsx("button",{type:"button",onClick:wt,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"}),!u&&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:u?5:6,style:{padding:18,textAlign:"center",color:"#94a3b8"},children:"No cycle history"})}),(e.cycle_logs||[]).map((B,ne)=>t.jsxs("tr",{style:{background:ne%2===0?"white":"#fafafa",borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...O,...I},value:B.cycle||"",disabled:u,onChange:L=>de(ne,{cycle:L.target.value}),children:[t.jsx("option",{value:"",children:"-- Select --"}),Re.map(L=>t.jsx("option",{value:L.name,children:L.label},L.name))]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx(ve,{value:B.cycle_date||"",onChange:L=>de(ne,{cycle_date:L}),disabled:u,style:{...O,...I,width:130}})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...O,...I},value:B.status,disabled:u,onChange:L=>de(ne,{status:L.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:{...O,...I},value:B.actor||"",disabled:u,onChange:L=>de(ne,{actor:L.target.value}),children:[t.jsx("option",{value:"",children:"-- Select --"}),_t.map(L=>t.jsx("option",{value:L.name,children:L.label},L.name))]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...O,...I},value:B.comment||"",disabled:u,onChange:L=>de(ne,{comment:L.target.value})})}),!u&&t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("button",{type:"button",onClick:()=>ln(ne),style:{padding:"4px 8px",border:"1px solid #fecaca",background:"#fef2f2",color:"#dc2626",borderRadius:4,cursor:"pointer",fontSize:11,fontWeight:600},children:"Remove"})})]},ne))]})]})})]}),t.jsx(oe,{title:G.field.auditorComment,children:t.jsx("textarea",{style:{...O,height:70,resize:"vertical",background:"#f8fafc"},value:e.auditor_comment||"",disabled:!0,readOnly:!0,placeholder:G.field.commentPlaceholder})})]})}const $0={CEO:"#8b5cf6",Admin:"#7c3aed",Auditor:"#d97706",Owner:"#0369a1",XAuditor:"#0f766e",Manager:"#2563eb",Employee:"#6b7280",Chairman:"#0f766e"};function U0({user:e,profileUser:n,darkMode:s,canModify:l,onBack:a,organizations:r=[],managements:i=[],departments:d=[],branches:f=[],groupCompanies:p=[]}){const k=n||{},j=!!l&&(e.role==="Admin"||e.role==="CEO"),[S,u]=_.useState({first_name:k.first_name||"",middle_name:k.middle_name||"",last_name:k.last_name||"",mobile_no:k.mobile_no||"",custom_organization:k.custom_organization||"",custom_group_company:k.custom_group_company||"",custom_manager:k.custom_manager||"",custom_management:k.custom_management||"",custom_department:k.custom_department||"",custom_branch:k.custom_branch||"",custom_number:k.custom_number||"",custom_category:k.custom_category||""}),[v,z]=_.useState(""),[C,g]=_.useState(!1),[o,h]=_.useState({new:"",confirm:""}),[x,y]=_.useState(""),w=k.email||k.name||"",c=[S.first_name,S.middle_name,S.last_name].filter(Boolean).join(" ")||k.full_name||"",b=k.username||k.name||"",A=S.custom_category||"",T=k.enabled===0?"Inactive":"Active",M=$0[e.role]||"#6b7280",H=s,le=H?"#0f172a":"#f0f2f5",U=H?"#1e293b":"white",G=H?"#2d3748":"#e5e7eb",$=H?"#e2e8f0":"#1a2332",I=H?"#94a3b8":"#6b7280",P=H?"#374151":"white",F=H?"#2d3748":"#f9fafb",K={width:"100%",padding:"9px 12px",borderRadius:8,border:`1px solid ${G}`,fontSize:13,background:P,color:$,fontFamily:"inherit",outline:"none"},E={...K,background:F,color:I},ee={...K,cursor:"pointer"},V={fontSize:12,fontWeight:600,color:I,marginBottom:5,display:"block"},ce={display:"grid",gridTemplateColumns:"1fr 1fr",gap:14},ie={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:14},tt=async()=>{if(l){z("saving");try{await Ds("User",k.name,{first_name:S.first_name,middle_name:S.middle_name,last_name:S.last_name,mobile_no:S.mobile_no,custom_organization:S.custom_organization,custom_group_company:S.custom_group_company,custom_manager:S.custom_manager,custom_management:S.custom_management,custom_department:S.custom_department,custom_branch:S.custom_branch,custom_number:S.custom_number,custom_category:S.custom_category}),z("saved"),setTimeout(()=>z(""),2e3)}catch{z("error"),setTimeout(()=>z(""),3e3)}}},Re=async()=>{if(!o.new){y("Enter a new password");return}if(o.new!==o.confirm){y("Passwords do not match");return}y("saving");try{await si(k.name,o.new),y("done"),h({new:"",confirm:""}),setTimeout(()=>{y(""),g(!1)},2e3)}catch{y("error")}},_t=({title:q,icon:de,children:wt})=>t.jsxs("div",{style:{background:U,borderRadius:12,padding:22,border:`1px solid ${G}`,boxShadow:`0 1px 4px rgba(0,0,0,${H?.3:.06})`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,paddingBottom:14,borderBottom:`1px solid ${G}`},children:[de,t.jsx("span",{style:{fontSize:14,fontWeight:700,color:$},children:q})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:wt})]});return t.jsxs("div",{style:{background:le,minHeight:"100%",padding:"0 0 32px"},children:[t.jsxs("div",{style:{background:U,borderBottom:`1px solid ${G}`,padding:"12px 28px",display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:24},children:[t.jsxs("button",{onClick:a,style:{display:"flex",alignItems:"center",gap:7,background:"none",border:"none",cursor:"pointer",fontSize:15,fontWeight:700,color:$,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:tt,style:{display:"flex",alignItems:"center",gap:8,background:v==="saved"?"#16a34a":v==="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"})]}),v==="saving"?"Saving…":v==="saved"?"Saved!":v==="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:c||w}),t.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.75)",textAlign:"center"},children:w})]}),t.jsx("div",{style:{background:U},children:[{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:M,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:b},{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:M,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:A||"—"},{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:M,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"})]}),label:"Group Company",value:S.custom_group_company||"—"},{icon:t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:T==="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:T,valueColor:T==="Active"?"#16a34a":"#dc2626"},{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:M,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:w},{icon:t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:M,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:S.mobile_no||"—"}].map(({icon:q,label:de,value:wt,valueColor:ln})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 16px",borderBottom:`1px solid ${G}`},children:[t.jsx("div",{style:{flexShrink:0,width:18,display:"flex",justifyContent:"center"},children:q}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:11,color:I,marginBottom:1},children:de}),t.jsx("div",{style:{fontSize:13,fontWeight:600,color:ln||$,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:wt})]})]},de))})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:18},children:[t.jsxs(_t,{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:V,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:{...E,paddingLeft:32},value:w,readOnly:!0})]})]}),t.jsxs("div",{children:[t.jsxs("label",{style:V,children:["Full Name ",t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Auto-generated)"})]}),t.jsx("input",{style:E,value:c,readOnly:!0})]})]}),t.jsxs("div",{style:ie,children:[t.jsxs("div",{children:[t.jsxs("label",{style:V,children:["First Name ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{style:l?K:E,value:S.first_name,readOnly:!l,onChange:q=>u(de=>({...de,first_name:q.target.value})),placeholder:"First name"})]}),t.jsxs("div",{children:[t.jsx("label",{style:V,children:"Middle Name"}),t.jsx("input",{style:l?K:E,value:S.middle_name,readOnly:!l,onChange:q=>u(de=>({...de,middle_name:q.target.value})),placeholder:"Middle name"})]}),t.jsxs("div",{children:[t.jsx("label",{style:V,children:"Last Name"}),t.jsx("input",{style:l?K:E,value:S.last_name,readOnly:!l,onChange:q=>u(de=>({...de,last_name:q.target.value})),placeholder:"Last name"})]})]}),t.jsxs("div",{style:ce,children:[t.jsxs("div",{children:[t.jsx("label",{style:V,children:"Phone Number"}),t.jsx("input",{style:l?K:E,value:S.mobile_no,readOnly:!l,onChange:q=>u(de=>({...de,mobile_no:q.target.value})),placeholder:"Phone number"})]}),t.jsxs("div",{children:[t.jsx("label",{style:V,children:"User ID No"}),t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{style:{...E,paddingRight:44},value:S.custom_number||k.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",{style:ce,children:[t.jsxs("div",{children:[t.jsxs("label",{style:V,children:["Category ",!j&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),j?t.jsxs("select",{style:ee,value:S.custom_category,onChange:q=>u(de=>({...de,custom_category:q.target.value})),children:[t.jsx("option",{value:"",children:"Select category"}),["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"].map(q=>t.jsx("option",{value:q,children:q},q))]}):t.jsx("input",{style:E,value:A||"—",readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:V,children:["Group Company ",!j&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),j?t.jsxs("select",{style:ee,value:S.custom_group_company,onChange:q=>u(de=>({...de,custom_group_company:q.target.value})),children:[t.jsx("option",{value:"",children:"Select group company"}),p.map(q=>t.jsx("option",{value:q.name,children:q.company_name||q.name},q.name))]}):t.jsx("input",{style:E,value:S.custom_group_company||"—",readOnly:!0})]})]})]}),t.jsxs(_t,{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:V,children:["Organization ",!j&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),j?t.jsxs("select",{style:ee,value:S.custom_organization,onChange:q=>u(de=>({...de,custom_organization:q.target.value})),children:[t.jsx("option",{value:"",children:"Select organization"}),be(r,S.custom_organization).map(q=>t.jsx("option",{value:q.name,children:q.organization_name||q.name},q.name))]}):t.jsx("input",{style:E,value:S.custom_organization||"—",readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:V,children:["Management ",!j&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),j?t.jsxs("select",{style:ee,value:S.custom_management,onChange:q=>u(de=>({...de,custom_management:q.target.value})),children:[t.jsx("option",{value:"",children:"Select management"}),be(i,S.custom_management).map(q=>t.jsx("option",{value:q.name,children:q.name1||q.name},q.name))]}):t.jsx("input",{style:E,value:S.custom_management||"—",readOnly:!0})]})]}),t.jsxs("div",{style:ce,children:[t.jsxs("div",{children:[t.jsxs("label",{style:V,children:["Department ",!j&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),j?t.jsxs("select",{style:ee,value:S.custom_department,onChange:q=>u(de=>({...de,custom_department:q.target.value})),children:[t.jsx("option",{value:"",children:"Select department"}),be(d,S.custom_department).map(q=>t.jsx("option",{value:q.name,children:q.department_name||q.name},q.name))]}):t.jsx("input",{style:E,value:S.custom_department||"—",readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:V,children:["Branch ",!j&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),j?t.jsxs("select",{style:ee,value:S.custom_branch,onChange:q=>u(de=>({...de,custom_branch:q.target.value})),children:[t.jsx("option",{value:"",children:"Select branch"}),be(f,S.custom_branch).map(q=>t.jsx("option",{value:q.name,children:q.branch||q.name},q.name))]}):t.jsx("input",{style:E,value:S.custom_branch||"—",readOnly:!0})]})]})]}),t.jsxs("div",{style:{background:U,borderRadius:12,padding:22,border:`1px solid ${G}`,boxShadow:`0 1px 4px rgba(0,0,0,${H?.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:$},children:"Change Password"})]}),l&&t.jsx("button",{onClick:()=>{g(q=>!q),y("")},style:{fontSize:13,color:"#3b82f6",background:"none",border:"none",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:C?"Cancel":"Change Password"})]}),C&&t.jsxs("div",{style:{marginTop:18,display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:ie,children:[t.jsxs("div",{children:[t.jsxs("label",{style:V,children:["New Password ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{type:"password",style:K,value:o.new,onChange:q=>h(de=>({...de,new:q.target.value})),placeholder:"New password"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:V,children:["Confirm Password ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{type:"password",style:K,value:o.confirm,onChange:q=>h(de=>({...de,confirm:q.target.value})),placeholder:"Confirm password"})]}),t.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:t.jsx("button",{onClick:Re,style:{width:"100%",padding:"9px 0",borderRadius:8,border:"none",background:"#2563eb",color:"white",fontWeight:700,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:x==="saving"?"Saving…":"Update Password"})})]}),x&&x!=="saving"&&t.jsx("div",{style:{fontSize:13,color:x==="done"?"#16a34a":"#dc2626",fontWeight:500},children:x==="done"?"Password updated successfully":x==="error"?"Failed to update password":x})]})]})]})]})]})}function Pe({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 gh={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151",boxSizing:"border-box"},M0={...gh,cursor:"pointer"};function St({filters:e,defaultOpen:n=!1}){const[s,l]=_.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(a=>!a),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",padding:"12px 18px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",userSelect:"none"},children:[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((a,r)=>t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:a.label}),a.type==="search"?t.jsx("input",{style:gh,placeholder:a.placeholder,value:a.value,onChange:i=>a.onChange(i.target.value)}):t.jsx("select",{style:M0,value:a.value,onChange:i=>a.onChange(i.target.value),children:a.options.map(i=>t.jsx("option",{value:i.value,children:i.label},i.value))})]},r))})})]})}function F0(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({organizations:e,canModify:n,onView:s,onEdit:l,onDelete:a,onSelectionChange:r}){const i=se(),[d,f]=_.useState(new Set),[p,k]=_.useState(""),[j,S]=_.useState("all"),[u,v]=_.useState("all"),z={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},C=_.useMemo(()=>e.filter(x=>{const y=[x.organization_name,x.city].filter(Boolean).join(" ").toLowerCase();return!(p&&!y.includes(p.toLowerCase())||j!=="all"&&x.type!==j||u!=="all"&&(x.is_active?"Active":"Inactive")!==u)}),[e,p,j,u]),[g,o]=_.useState(1);_.useEffect(()=>{o(1)},[p,j,u]);const h=C.slice((g-1)*ae,g*ae);return _.useEffect(()=>{if(r){const x=e.filter(y=>d.has(y.name));r(x,h)}},[d,h]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Pe,{label:"Total",val:C.length,color:"#1a2332"}),t.jsx(Pe,{label:"Active",val:C.filter(x=>x.is_active).length,color:X.green}),t.jsx(Pe,{label:"Government",val:C.filter(x=>x.type==="Government").length,color:X.blue}),t.jsx(Pe,{label:"Private",val:C.filter(x=>x.type==="Private").length,color:X.orange})]}),t.jsx(St,{filters:[{type:"search",label:"Search",value:p,onChange:k,placeholder:"Name or city…"},{type:"select",label:i.col.type,value:j,onChange:S,options:[{value:"all",label:"All"},{value:"Government",label:"Government"},{value:"Private",label:"Private"}]},{type:"select",label:"Status",value:u,onChange:v,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:h.length>0&&h.every(x=>d.has(x.name)),onChange:x=>{if(x.target.checked)f(new Set([...d,...h.map(y=>y.name)]));else{const y=new Set(d);h.forEach(w=>y.delete(w.name)),f(y)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:z,children:i.col.name}),t.jsx("th",{style:z,children:i.col.type}),t.jsx("th",{style:z,children:i.col.city}),t.jsx("th",{style:z,children:i.field.creationDate}),t.jsx("th",{style:z,children:i.col.status}),t.jsx("th",{style:z,children:i.col.actions})]})}),t.jsx("tbody",{children:C.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):h.map((x,y)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(x),style:{borderTop:"1px solid #f0f0f0",background:d.has(x.name)?"#eff6ff":x.custom_is_deleted?"#fff1f2":y%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:w=>w.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(x.name),onChange:()=>{const w=new Set(d);w.has(x.name)?w.delete(x.name):w.add(x.name),f(w)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:x.organization_name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:x.type||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:x.city||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:F0(x.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:x.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):La(x.is_active?i.field.statusActive:i.field.statusInactive,x.is_active?X.green:X.gray)}),t.jsx("td",{style:{padding:"8px 14px"},onClick:w=>w.stopPropagation(),children:t.jsx(dt,{onView:()=>s==null?void 0:s(x),onEdit:n&&l&&!x.custom_is_deleted?()=>l(x):void 0,onDelete:n&&a&&!x.custom_is_deleted?()=>a(x.name):void 0})})]},x.name))})]})}),t.jsx(Ue,{page:g,total:C.length,onPageChange:o})]})}const On=e=>({background:e?"#f9f9f9":void 0});function G0({orgForm:e,setOrgForm:n,groupCompanies:s=[],formStatus:l,viewMode:a,onEdit:r,onRestore:i,onPermanentDelete:d,darkMode:f,notifCount:p,onToggleDark:k,onCountChange:j,onViewProfile:S,onSubmit:u,onBack:v,onNavigate:z,onLogout:C,user:g}){const o=se(),h=e.name?a&&e.organization_name||o.formTitle.editOrg:o.formTitle.newOrg;return t.jsxs(et,{title:h,activePage:"organizations",user:g,formStatus:l,buttonText:o.saveOrg,buttonColor:"#16a34a",viewMode:a,onEdit:r,darkMode:f,notifCount:p,onToggleDark:k,onCountChange:j,onViewProfile:S,onSubmit:u,onBack:v,onNavigate:z,onLogout:C,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:i&&e.name?()=>i(e.name):void 0,onPermanentDelete:d&&e.name?()=>d(e.name):void 0}),t.jsx(oe,{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:D,children:[o.field.orgName," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{type:"text",style:{...O,...On(a||!!e.name)},value:e.organization_name,disabled:a||!!e.name,required:!0,onChange:x=>n({...e,organization_name:x.target.value})})]}),t.jsxs("div",{children:[t.jsxs("label",{style:D,children:[o.field.orgAcronym," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{type:"text",style:{...O,...On(a||!!e.name)},value:e.acronym||"",disabled:a||!!e.name,required:!0,onChange:x=>n({...e,acronym:x.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:o.field.organizationType}),t.jsxs("select",{style:{...O,...On(a)},value:e.type,disabled:a,onChange:x=>n({...e,type:x.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:D,children:o.field.orgCity}),t.jsx("input",{type:"text",style:{...O,...On(a)},value:e.city,disabled:a,onChange:x=>n({...e,city:x.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:o.field.contactEmail}),t.jsx("input",{type:"email",style:{...O,...On(a)},value:e.contact_email,disabled:a,onChange:x=>n({...e,contact_email:x.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:o.field.creationDate}),t.jsx(ve,{value:e.creation_date||"",onChange:x=>n({...e,creation_date:x}),disabled:a,style:{...O,...On(a)}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:o.field.status}),t.jsxs("select",{style:{...O,...On(a)},value:e.is_active?"Active":"Inactive",disabled:a,onChange:x=>n({...e,is_active:x.target.value==="Active"?1:0}),children:[t.jsx("option",{value:"Active",children:o.field.statusActive}),t.jsx("option",{value:"Inactive",children:o.field.statusInactive})]})]})]})}),t.jsx(oe,{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:D,children:o.field.incidentTriageWindowDays}),t.jsx("input",{type:"number",min:1,max:30,style:{...O,...On(a)},value:e.incident_triage_window_days??3,disabled:a,onChange:x=>n({...e,incident_triage_window_days:parseInt(x.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:D,children:o.field.incidentResolutionWindowDays}),t.jsx("input",{type:"number",min:1,max:30,style:{...O,...On(a)},value:e.incident_resolution_window_days??5,disabled:a,onChange:x=>n({...e,incident_resolution_window_days:parseInt(x.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 Q0({groupCompanies:e,canModify:n,onView:s,onEdit:l,onDelete:a,onSelectionChange:r}){const i=se(),[d,f]=_.useState(new Set),[p,k]=_.useState(""),[j,S]=_.useState("all"),u={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},v=_.useMemo(()=>e.filter(o=>{const h=[o.company_name,o.acronym,o.code,o.owner_user].filter(Boolean).join(" ").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,C]=_.useState(1);_.useEffect(()=>{C(1)},[p,j]);const g=v.slice((z-1)*ae,z*ae);return _.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Pe,{label:"Total Group Cos",val:v.length,color:"#1a2332"}),t.jsx(Pe,{label:"Active",val:v.filter(o=>(o.status||"Active")==="Active").length,color:X.green}),t.jsx(Pe,{label:"Inactive",val:v.filter(o=>o.status==="Inactive").length,color:X.orange})]}),t.jsx(St,{filters:[{type:"search",label:"Search",value:p,onChange:k,placeholder:"Company name, code, owner…"},{type:"select",label:"Status",value:j,onChange:S,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:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:u,children:"Company Name"}),t.jsx("th",{style:u,children:"Code / Acronym"}),t.jsx("th",{style:u,children:"Group Co Owner"}),t.jsx("th",{style:u,children:"Status"}),t.jsx("th",{style:u,children:i.col.actions})]})}),t.jsxs("tbody",{children:[g.map((o,h)=>{const x=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:d.has(o.name)?"#eff6ff":x?"#fef2f2":h%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:y=>y.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const y=new Set(d);y.has(o.name)?y.delete(o.name):y.add(o.name),f(y)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsxs("td",{style:{padding:"12px 14px",fontWeight:600},children:[o.company_name,x&&t.jsx("span",{style:{marginLeft:8},children:La(i.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:La(o.status||"Active",(o.status||"Active")==="Active"?X.green:X.orange)}),t.jsx("td",{style:{padding:"12px 14px"},onClick:y=>y.stopPropagation(),children:t.jsx(dt,{onView:s?()=>s(o):void 0,onEdit:n&&l?()=>l(o):void 0,onDelete:n&&a?()=>a(o.name):void 0})})]},o.name)}),v.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(Ue,{page:z,total:v.length,onPageChange:C})]})}function K0({form:e,setForm:n,users:s=[],formStatus:l,viewMode:a,onEdit:r,onRestore:i,onPermanentDelete:d,darkMode:f,notifCount:p,onToggleDark:k,onCountChange:j,onViewProfile:S,onSubmit:u,onBack:v,onNavigate:z,onLogout:C,user:g}){const o=w=>n({...e,...w}),h=a?{background:"#f8fafc"}:{};_.useEffect(()=>{if(!e.owner_user&&!a){const w=s.find(c=>c.custom_group_company===e.name&&(c.role==="Admin"||c.custom_category==="Admin"));w?o({owner_user:w.name}):!e.name&&(g.role==="Admin"||g.role==="CEO")&&o({owner_user:g.name})}},[e.name,e.owner_user,a,s,g.name,g.role]);const x=e.name?a?`View Group Company: ${e.company_name}`:"Edit Group Company":"New Group Company",y=s.map(w=>({name:w.name,label:w.full_name?`${w.full_name} (${w.name})`:w.name}));return t.jsxs(et,{title:x,activePage:"group-companies",user:g,formStatus:l,buttonText:"Save Group Company",buttonColor:"#16a34a",viewMode:a,onEdit:r,darkMode:f,notifCount:p,onToggleDark:k,onCountChange:j,onViewProfile:S,onSubmit:u,onBack:v,onNavigate:z,onLogout:C,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:i?()=>i(e.name):void 0,onPermanentDelete:d?()=>d(e.name):void 0}),t.jsxs(oe,{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:D,children:["Company Name ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...O,...h},value:e.company_name||"",disabled:a||!!e.name,onChange:w=>o({company_name:w.target.value}),placeholder:"e.g. Company A Group"})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:"Company Code"}),t.jsx("input",{style:{...O,...h},value:e.code||"",disabled:a,onChange:w=>o({code:w.target.value}),placeholder:"e.g. CO-A"})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:"Acronym"}),t.jsx("input",{style:{...O,...h},value:e.acronym||"",disabled:a,onChange:w=>o({acronym:w.target.value}),placeholder:"e.g. CAG"})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:"Status"}),t.jsxs("select",{style:{...O,...h},value:e.status||"Active",disabled:a,onChange:w=>o({status:w.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:D,children:"Group Co Owner / Admin User"}),t.jsx(ge,{value:e.owner_user||"",onChange:w=>o({owner_user:w}),items:y,placeholder:"Select owner user",disabled:a})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:"Notes"}),t.jsx("textarea",{style:{...O,...h,height:75,resize:"vertical"},value:e.notes||"",disabled:a,onChange:w=>o({notes:w.target.value}),placeholder:"Additional details regarding this tenant company…"})]})]})]})}function Y0(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 X0({managements:e,canModify:n,onView:s,onEdit:l,onDelete:a,onSelectionChange:r}){const i=se(),[d,f]=_.useState(new Set),[p,k]=_.useState(""),[j,S]=_.useState("all"),u={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},v=_.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,C]=_.useState(1);_.useEffect(()=>{C(1)},[p,j]);const g=v.slice((z-1)*ae,z*ae);return _.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Pe,{label:"Total",val:v.length,color:X.blue})}),t.jsx(St,{filters:[{type:"search",label:"Search",value:p,onChange:k,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:S,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:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:u,children:i.col.name}),t.jsx("th",{style:u,children:i.field.creationDate}),t.jsx("th",{style:u,children:i.field.status}),t.jsx("th",{style:u,children:i.col.actions})]})}),t.jsx("tbody",{children:v.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},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:Y0(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(dt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l&&!o.custom_is_deleted?()=>l(o):void 0,onDelete:n&&a&&!o.custom_is_deleted?()=>a(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:v.length,onPageChange:C})]})}function q0({form:e,setForm:n,organizations:s,groupCompanies:l=[],formStatus:a,viewMode:r,onEdit:i,onRestore:d,onPermanentDelete:f,darkMode:p,notifCount:k,onToggleDark:j,onCountChange:S,onViewProfile:u,onSubmit:v,onBack:z,onNavigate:C,onLogout:g,user:o}){const h=se(),x=c=>n(b=>({...b,...c})),y=r?{background:"#f8fafc"}:{},w=e.name?r?`${h.formTitle.editMgmt}: ${e.name1||e.name}`:h.formTitle.editMgmt:h.formTitle.newMgmt;return t.jsxs(et,{title:w,activePage:"managements",user:o,formStatus:a,buttonText:h.saveMgmt,buttonColor:"#16a34a",viewMode:r,onEdit:i,darkMode:p,notifCount:k,onToggleDark:j,onCountChange:S,onViewProfile:u,onSubmit:v,onBack:z,onNavigate:C,onLogout:g,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:d&&e.name?()=>d(e.name):void 0,onPermanentDelete:f&&e.name?()=>f(e.name):void 0}),t.jsx(oe,{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:D,children:[h.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(sn,{value:e.organization,onChange:c=>{var A;const b=(A=s.find(T=>T.name===c))==null?void 0:A.group_company;x({organization:c,...o.custom_group_company?{}:{group_company:b||e.group_company}})},organizations:s,disabled:r||!!o.custom_organization,userRole:o.role})]}),t.jsxs("div",{children:[t.jsxs("label",{style:D,children:[h.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...O,...y},value:e.name1,disabled:r||!!e.name,onChange:c=>x({name1:c.target.value}),placeholder:"Management name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:h.field.creationDate}),t.jsx(ve,{value:e.creation_date||"",onChange:c=>x({creation_date:c}),disabled:r,style:{...O,...y}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:h.field.status}),t.jsxs("select",{style:{...O,...y},value:e.status||"Active",disabled:r,onChange:c=>x({status:c.target.value}),children:[t.jsx("option",{value:"Active",children:h.field.statusActive}),t.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})})]})}function J0(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({departments:e,managements:n,canModify:s,onView:l,onEdit:a,onDelete:r,onSelectionChange:i}){const d=se(),[f,p]=_.useState(new Set),[k,j]=_.useState(""),[S,u]=_.useState(""),[v,z]=_.useState("all"),C=w=>{var c;return((c=n.find(b=>b.name===w))==null?void 0:c.name1)||w||"—"},g={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},o=_.useMemo(()=>e.filter(w=>{const c=(w.department_name||w.name||"").toLowerCase();return!(k&&!c.includes(k.toLowerCase())||S&&w.custom_management!==S||v!=="all"&&(w.custom_status||"Active")!==v)}),[e,k,S,v]),[h,x]=_.useState(1);_.useEffect(()=>{x(1)},[k,S,v]);const y=o.slice((h-1)*ae,h*ae);return _.useEffect(()=>{if(i){const w=e.filter(c=>f.has(c.name));i(w,y)}},[f,y]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Pe,{label:"Total",val:o.length,color:X.teal})}),t.jsx(St,{filters:[{type:"search",label:"Search",value:k,onChange:j,placeholder:"Search by name…"},{type:"select",label:d.col.management,value:S,onChange:u,options:[{value:"",label:"All Managements"},...n.map(w=>({value:w.name,label:w.name1||w.name}))]},{type:"select",label:"Status",value:v,onChange:z,options:[{value:"all",label:"All"},{value:"Active",label:d.field.statusActive},{value:"Inactive",label:d.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:y.length>0&&y.every(w=>f.has(w.name)),onChange:w=>{if(w.target.checked)p(new Set([...f,...y.map(c=>c.name)]));else{const c=new Set(f);y.forEach(b=>c.delete(b.name)),p(c)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:g,children:d.col.name}),t.jsx("th",{style:g,children:d.col.management}),t.jsx("th",{style:g,children:d.field.creationDate}),t.jsx("th",{style:g,children:d.field.status}),t.jsx("th",{style:g,children:d.col.actions})]})}),t.jsx("tbody",{children:o.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:d.noData})}):y.map((w,c)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>l==null?void 0:l(w),style:{borderTop:"1px solid #f0f0f0",background:f.has(w.name)?"#eff6ff":w.custom_is_deleted?"#fff1f2":c%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:f.has(w.name),onChange:()=>{const b=new Set(f);b.has(w.name)?b.delete(w.name):b.add(w.name),p(b)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:w.department_name||w.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:C(w.custom_management)}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:J0(w.custom_creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:w.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:d.deletedBadge}):t.jsx("span",{style:{color:w.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:w.custom_status==="Inactive"?d.field.statusInactive:d.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:b=>b.stopPropagation(),children:t.jsx(dt,{onView:()=>l==null?void 0:l(w),onEdit:s&&a&&!w.custom_is_deleted?()=>a(w):void 0,onDelete:s&&r&&!w.custom_is_deleted?()=>r(w.name):void 0})})]},w.name))})]})}),t.jsx(Ue,{page:h,total:o.length,onPageChange:x})]})}function Z0({form:e,setForm:n,organizations:s,groupCompanies:l=[],managements:a,formStatus:r,viewMode:i,onEdit:d,onRestore:f,onPermanentDelete:p,darkMode:k,notifCount:j,onToggleDark:S,onCountChange:u,onViewProfile:v,onSubmit:z,onBack:C,onNavigate:g,onLogout:o,user:h}){const x=se(),y=A=>n(T=>({...T,...A})),w=i?{background:"#f8fafc"}:{},c=e.name?i?`${x.formTitle.editDept}: ${e.department_name||e.name}`:x.formTitle.editDept:x.formTitle.newDept,b=be(a,e.custom_management).map(A=>({name:A.name,label:A.name1||A.name}));return t.jsxs(et,{title:c,activePage:"departments",user:h,formStatus:r,buttonText:x.saveDept,buttonColor:"#16a34a",viewMode:i,onEdit:d,darkMode:k,notifCount:j,onToggleDark:S,onCountChange:u,onViewProfile:v,onSubmit:z,onBack:C,onNavigate:g,onLogout:o,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:f&&e.name?()=>f(e.name):void 0,onPermanentDelete:p&&e.name?()=>p(e.name):void 0}),t.jsx(oe,{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:D,children:[x.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(sn,{value:e.custom_organization,onChange:A=>{var M;const T=(M=s.find(H=>H.name===A))==null?void 0:M.group_company;y({custom_organization:A,...h.custom_group_company?{}:{group_company:T||e.group_company}})},organizations:s,disabled:i||!!h.custom_organization,userRole:h.role})]}),t.jsxs("div",{children:[t.jsxs("label",{style:D,children:[x.field.department," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...O,...w},value:e.department_name,disabled:i||!!e.name,onChange:A=>y({department_name:A.target.value}),placeholder:"Department name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:x.field.management}),t.jsx(ge,{value:e.custom_management,onChange:A=>y({custom_management:A}),items:b,placeholder:x.field.select,disabled:i,userRole:h.role,doctypeName:R.managements,extraFields:{organization:e.custom_organization}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:x.field.creationDate}),t.jsx(ve,{value:e.custom_creation_date||"",onChange:A=>y({custom_creation_date:A}),disabled:i,style:{...O,...w}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:x.field.status}),t.jsxs("select",{style:{...O,...w},value:e.custom_status||"Active",disabled:i,onChange:A=>y({custom_status:A.target.value}),children:[t.jsx("option",{value:"Active",children:x.field.statusActive}),t.jsx("option",{value:"Inactive",children:x.field.statusInactive})]})]})]})})]})}function e1(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 t1({branches:e,managements:n,departments:s,canModify:l,onView:a,onEdit:r,onDelete:i,onSelectionChange:d}){const f=se(),[p,k]=_.useState(new Set),[j,S]=_.useState(""),[u,v]=_.useState(""),[z,C]=_.useState(""),[g,o]=_.useState("all"),h=T=>{var M;return((M=n.find(H=>H.name===T))==null?void 0:M.name1)||T||"—"},x=T=>{var M;return((M=s.find(H=>H.name===T))==null?void 0:M.department_name)||T||"—"},y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},w=_.useMemo(()=>e.filter(T=>{const M=(T.branch||T.name||"").toLowerCase();return!(j&&!M.includes(j.toLowerCase())||u&&T.management!==u||z&&T.department!==z||g!=="all"&&(T.custom_status||"Active")!==g)}),[e,j,u,z,g]),[c,b]=_.useState(1);_.useEffect(()=>{b(1)},[j,u,z,g]);const A=w.slice((c-1)*ae,c*ae);return _.useEffect(()=>{if(d){const T=e.filter(M=>p.has(M.name));d(T,A)}},[p,A]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Pe,{label:"Total",val:w.length,color:X.purple})}),t.jsx(St,{filters:[{type:"search",label:"Search",value:j,onChange:S,placeholder:"Search by name…"},{type:"select",label:f.col.management,value:u,onChange:v,options:[{value:"",label:"All Managements"},...n.map(T=>({value:T.name,label:T.name1||T.name}))]},{type:"select",label:f.col.department,value:z,onChange:C,options:[{value:"",label:"All Departments"},...s.map(T=>({value:T.name,label:T.department_name||T.name}))]},{type:"select",label:"Status",value:g,onChange:o,options:[{value:"all",label:"All"},{value:"Active",label:f.field.statusActive},{value:"Inactive",label:f.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:A.length>0&&A.every(T=>p.has(T.name)),onChange:T=>{if(T.target.checked)k(new Set([...p,...A.map(M=>M.name)]));else{const M=new Set(p);A.forEach(H=>M.delete(H.name)),k(M)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:y,children:f.col.branch}),t.jsx("th",{style:y,children:f.col.management}),t.jsx("th",{style:y,children:f.col.department}),t.jsx("th",{style:y,children:f.field.creationDate}),t.jsx("th",{style:y,children:f.field.status}),t.jsx("th",{style:y,children:f.col.actions})]})}),t.jsx("tbody",{children:w.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:f.noData})}):A.map((T,M)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>a==null?void 0:a(T),style:{borderTop:"1px solid #f0f0f0",background:p.has(T.name)?"#eff6ff":T.custom_is_deleted?"#fff1f2":M%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:H=>H.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:p.has(T.name),onChange:()=>{const H=new Set(p);H.has(T.name)?H.delete(T.name):H.add(T.name),k(H)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:T.branch||T.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:h(T.management)}),t.jsx("td",{style:{padding:"10px 14px"},children:x(T.department)}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:e1(T.custom_creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:T.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:f.deletedBadge}):t.jsx("span",{style:{color:T.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:T.custom_status==="Inactive"?f.field.statusInactive:f.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:H=>H.stopPropagation(),children:t.jsx(dt,{onView:()=>a==null?void 0:a(T),onEdit:l&&r&&!T.custom_is_deleted?()=>r(T):void 0,onDelete:l&&i&&!T.custom_is_deleted?()=>i(T.name):void 0})})]},T.name))})]})}),t.jsx(Ue,{page:c,total:w.length,onPageChange:b})]})}function n1({form:e,setForm:n,organizations:s,groupCompanies:l=[],managements:a,departments:r,formStatus:i,viewMode:d,onEdit:f,onRestore:p,onPermanentDelete:k,darkMode:j,notifCount:S,onToggleDark:u,onCountChange:v,onViewProfile:z,onSubmit:C,onBack:g,onNavigate:o,onLogout:h,user:x}){const y=se(),w=M=>n(H=>({...H,...M})),c=d?{background:"#f8fafc"}:{},b=be(a,e.management).map(M=>({name:M.name,label:M.name1||M.name})),A=be(r,e.department).map(M=>({name:M.name,label:M.department_name||M.name})),T=e.name?d?`${y.formTitle.editBranch}: ${e.branch||e.name}`:y.formTitle.editBranch:y.formTitle.newBranch;return t.jsxs(et,{title:T,activePage:"branches",user:x,formStatus:i,buttonText:y.saveBranch,buttonColor:"#16a34a",viewMode:d,onEdit:f,darkMode:j,notifCount:S,onToggleDark:u,onCountChange:v,onViewProfile:z,onSubmit:C,onBack:g,onNavigate:o,onLogout:h,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:p&&e.name?()=>p(e.name):void 0,onPermanentDelete:k&&e.name?()=>k(e.name):void 0}),t.jsx(oe,{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:D,children:[y.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(sn,{value:e.organization,onChange:M=>{var le;const H=(le=s.find(U=>U.name===M))==null?void 0:le.group_company;w({organization:M,...x.custom_group_company?{}:{group_company:H||e.group_company}})},organizations:s,disabled:d||!!x.custom_organization,userRole:x.role})]}),t.jsxs("div",{children:[t.jsxs("label",{style:D,children:[y.field.branch," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...O,...c},value:e.branch,disabled:d||!!e.name,onChange:M=>w({branch:M.target.value}),placeholder:"Branch name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:y.field.management}),t.jsx(ge,{value:e.management,onChange:M=>w({management:M}),items:b,placeholder:y.field.select,disabled:d,userRole:x.role,doctypeName:R.managements,extraFields:{organization:e.organization}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:y.field.department}),t.jsx(ge,{value:e.department,onChange:M=>w({department:M}),items:A,placeholder:y.field.select,disabled:d,userRole:x.role,doctypeName:R.departments,extraFields:{organization:e.organization,management:e.management}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:y.field.creationDate}),t.jsx(ve,{value:e.custom_creation_date||"",onChange:M=>w({custom_creation_date:M}),disabled:d,style:{...O,...c}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:y.field.status}),t.jsxs("select",{style:{...O,...c},value:e.custom_status||"Active",disabled:d,onChange:M=>w({custom_status:M.target.value}),children:[t.jsx("option",{value:"Active",children:y.field.statusActive}),t.jsx("option",{value:"Inactive",children:y.field.statusInactive})]})]})]})})]})}function s1(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 l1({incidentTypes:e,canModify:n,onView:s,onEdit:l,onDelete:a,onSelectionChange:r}){const i=se(),[d,f]=_.useState(new Set),[p,k]=_.useState(""),[j,S]=_.useState("all"),u={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},v=_.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,C]=_.useState(1);_.useEffect(()=>{C(1)},[p,j]);const g=v.slice((z-1)*ae,z*ae);return _.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Pe,{label:"Total",val:v.length,color:X.red})}),t.jsx(St,{filters:[{type:"search",label:"Search",value:p,onChange:k,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:S,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:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:u,children:i.col.name}),t.jsx("th",{style:u,children:i.field.creationDate}),t.jsx("th",{style:u,children:i.field.status}),t.jsx("th",{style:u,children:i.col.actions})]})}),t.jsx("tbody",{children:v.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},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:s1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(dt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l&&!o.custom_is_deleted?()=>l(o):void 0,onDelete:n&&a&&!o.custom_is_deleted?()=>a(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:v.length,onPageChange:C})]})}function a1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:a,onRestore:r,onPermanentDelete:i,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:k,onViewProfile:j,onSubmit:S,onBack:u,onNavigate:v,onLogout:z,user:C}){const g=se(),o=y=>n(w=>({...w,...y})),h=l?{background:"#f8fafc"}:{},x=e.name?l?`Incident Type: ${e.name1||e.name}`:"Edit Incident Type":"New Incident Type";return t.jsxs(et,{title:x,activePage:"incident-types",user:C,formStatus:s,buttonText:g.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:a,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:k,onViewProfile:j,onSubmit:S,onBack:u,onNavigate:v,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:r&&e.name?()=>r(e.name):void 0,onPermanentDelete:i&&e.name?()=>i(e.name):void 0}),t.jsx(oe,{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:D,children:[g.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...O,...h},value:e.name1,disabled:l||!!e.name,onChange:y=>o({name1:y.target.value}),placeholder:"Incident type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:g.field.creationDate}),t.jsx(ve,{value:e.creation_date||"",onChange:y=>o({creation_date:y}),disabled:l,style:{...O,...h}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:g.field.status}),t.jsxs("select",{style:{...O,...h},value:e.status||"Active",disabled:l,onChange:y=>o({status:y.target.value}),children:[t.jsx("option",{value:"Active",children:g.field.statusActive}),t.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})})]})}function r1(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 i1({ideaTypes:e,canModify:n,onView:s,onEdit:l,onDelete:a,onSelectionChange:r}){const i=se(),[d,f]=_.useState(new Set),[p,k]=_.useState(""),[j,S]=_.useState("all"),u={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},v=_.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,C]=_.useState(1);_.useEffect(()=>{C(1)},[p,j]);const g=v.slice((z-1)*ae,z*ae);return _.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Pe,{label:"Total",val:v.length,color:X.teal})}),t.jsx(St,{filters:[{type:"search",label:"Search",value:p,onChange:k,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:S,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:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:u,children:i.col.name}),t.jsx("th",{style:u,children:i.field.creationDate}),t.jsx("th",{style:u,children:i.field.status}),t.jsx("th",{style:u,children:i.col.actions})]})}),t.jsx("tbody",{children:v.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},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:r1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(dt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l&&!o.custom_is_deleted?()=>l(o):void 0,onDelete:n&&a&&!o.custom_is_deleted?()=>a(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:v.length,onPageChange:C})]})}function o1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:a,onRestore:r,onPermanentDelete:i,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:k,onViewProfile:j,onSubmit:S,onBack:u,onNavigate:v,onLogout:z,user:C}){const g=se(),o=y=>n(w=>({...w,...y})),h=l?{background:"#f8fafc"}:{},x=e.name?l?`Idea Type: ${e.name1||e.name}`:"Edit Idea Type":"New Idea Type";return t.jsxs(et,{title:x,activePage:"idea-types",user:C,formStatus:s,buttonText:g.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:a,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:k,onViewProfile:j,onSubmit:S,onBack:u,onNavigate:v,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:r&&e.name?()=>r(e.name):void 0,onPermanentDelete:i&&e.name?()=>i(e.name):void 0}),t.jsx(oe,{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:D,children:[g.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...O,...h},value:e.name1,disabled:l||!!e.name,onChange:y=>o({name1:y.target.value}),placeholder:"Idea type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:g.field.creationDate}),t.jsx(ve,{value:e.creation_date||"",onChange:y=>o({creation_date:y}),disabled:l,style:{...O,...h}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:g.field.status}),t.jsxs("select",{style:{...O,...h},value:e.status||"Active",disabled:l,onChange:y=>o({status:y.target.value}),children:[t.jsx("option",{value:"Active",children:g.field.statusActive}),t.jsx("option",{value:"Inactive",children:g.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 c1({orderTypes:e,canModify:n,onView:s,onEdit:l,onDelete:a,onSelectionChange:r}){const i=se(),[d,f]=_.useState(new Set),[p,k]=_.useState(""),[j,S]=_.useState("all"),u={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},v=_.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,C]=_.useState(1);_.useEffect(()=>{C(1)},[p,j]);const g=v.slice((z-1)*ae,z*ae);return _.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Pe,{label:"Total",val:v.length,color:X.purple})}),t.jsx(St,{filters:[{type:"search",label:"Search",value:p,onChange:k,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:S,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:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:u,children:i.col.name}),t.jsx("th",{style:u,children:i.field.creationDate}),t.jsx("th",{style:u,children:i.field.status}),t.jsx("th",{style:u,children:i.col.actions})]})}),t.jsx("tbody",{children:v.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},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:d1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(dt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l&&!o.custom_is_deleted?()=>l(o):void 0,onDelete:n&&a&&!o.custom_is_deleted?()=>a(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:v.length,onPageChange:C})]})}function u1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:a,onRestore:r,onPermanentDelete:i,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:k,onViewProfile:j,onSubmit:S,onBack:u,onNavigate:v,onLogout:z,user:C}){const g=se(),o=y=>n(w=>({...w,...y})),h=l?{background:"#f8fafc"}:{},x=e.name?l?`Order Type: ${e.name1||e.name}`:"Edit Order Type":"New Order Type";return t.jsxs(et,{title:x,activePage:"order-types",user:C,formStatus:s,buttonText:g.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:a,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:k,onViewProfile:j,onSubmit:S,onBack:u,onNavigate:v,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:r&&e.name?()=>r(e.name):void 0,onPermanentDelete:i&&e.name?()=>i(e.name):void 0}),t.jsx(oe,{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:D,children:[g.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...O,...h},value:e.name1,disabled:l||!!e.name,onChange:y=>o({name1:y.target.value}),placeholder:"Order type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:g.field.creationDate}),t.jsx(ve,{value:e.creation_date||"",onChange:y=>o({creation_date:y}),disabled:l,style:{...O,...h}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:g.field.status}),t.jsxs("select",{style:{...O,...h},value:e.status||"Active",disabled:l,onChange:y=>o({status:y.target.value}),children:[t.jsx("option",{value:"Active",children:g.field.statusActive}),t.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})})]})}function p1(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 f1({processTypes:e,canModify:n,onView:s,onEdit:l,onDelete:a,onSelectionChange:r}){const i=se(),[d,f]=_.useState(new Set),[p,k]=_.useState(""),[j,S]=_.useState("all"),u={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},v=_.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,C]=_.useState(1);_.useEffect(()=>{C(1)},[p,j]);const g=v.slice((z-1)*ae,z*ae);return _.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Pe,{label:"Total",val:v.length,color:X.blue})}),t.jsx(St,{filters:[{type:"search",label:"Search",value:p,onChange:k,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:S,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:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:u,children:i.col.name}),t.jsx("th",{style:u,children:i.field.creationDate}),t.jsx("th",{style:u,children:i.field.status}),t.jsx("th",{style:u,children:i.col.actions})]})}),t.jsx("tbody",{children:v.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},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:p1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(dt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l&&!o.custom_is_deleted?()=>l(o):void 0,onDelete:n&&a&&!o.custom_is_deleted?()=>a(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:v.length,onPageChange:C})]})}function h1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:a,onRestore:r,onPermanentDelete:i,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:k,onViewProfile:j,onSubmit:S,onBack:u,onNavigate:v,onLogout:z,user:C}){const g=se(),o=y=>n(w=>({...w,...y})),h=l?{background:"#f8fafc"}:{},x=e.name?l?`Process Type: ${e.name1||e.name}`:"Edit Process Type":"New Process Type";return t.jsxs(et,{title:x,activePage:"process-types",user:C,formStatus:s,buttonText:g.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:a,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:k,onViewProfile:j,onSubmit:S,onBack:u,onNavigate:v,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:r&&e.name?()=>r(e.name):void 0,onPermanentDelete:i&&e.name?()=>i(e.name):void 0}),t.jsx(oe,{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:D,children:[g.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...O,...h},value:e.name1,disabled:l||!!e.name,onChange:y=>o({name1:y.target.value}),placeholder:"Process type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:g.field.creationDate}),t.jsx(ve,{value:e.creation_date||"",onChange:y=>o({creation_date:y}),disabled:l,style:{...O,...h}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:g.field.status}),t.jsxs("select",{style:{...O,...h},value:e.status||"Active",disabled:l,onChange:y=>o({status:y.target.value}),children:[t.jsx("option",{value:"Active",children:g.field.statusActive}),t.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})})]})}function g1(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({incidentStatuses:e,canModify:n,onView:s,onEdit:l,onDelete:a,onSelectionChange:r}){const i=se(),[d,f]=_.useState(new Set),[p,k]=_.useState(""),[j,S]=_.useState("all"),u={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},v=_.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,C]=_.useState(1);_.useEffect(()=>{C(1)},[p,j]);const g=v.slice((z-1)*ae,z*ae);return _.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Pe,{label:"Total",val:v.length,color:X.red})}),t.jsx(St,{filters:[{type:"search",label:"Search",value:p,onChange:k,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:S,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:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:u,children:i.col.name}),t.jsx("th",{style:u,children:i.field.notifyManager}),t.jsx("th",{style:u,children:i.field.creationDate}),t.jsx("th",{style:u,children:i.field.status}),t.jsx("th",{style:u,children:i.col.actions})]})}),t.jsx("tbody",{children:v.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},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?i.field.statusActive:"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:g1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(dt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l&&!o.custom_is_deleted?()=>l(o):void 0,onDelete:n&&a&&!o.custom_is_deleted?()=>a(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:v.length,onPageChange:C})]})}function x1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:a,onRestore:r,onPermanentDelete:i,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:k,onViewProfile:j,onSubmit:S,onBack:u,onNavigate:v,onLogout:z,user:C}){const g=se(),o=y=>n(w=>({...w,...y})),h=l?{background:"#f8fafc"}:{},x=e.name?l?`Incident Status: ${e.name1||e.name}`:"Edit Incident Status":"New Incident Status";return t.jsxs(et,{title:x,activePage:"incident-statuses",user:C,formStatus:s,buttonText:g.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:a,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:k,onViewProfile:j,onSubmit:S,onBack:u,onNavigate:v,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:r&&e.name?()=>r(e.name):void 0,onPermanentDelete:i&&e.name?()=>i(e.name):void 0}),t.jsxs(oe,{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:D,children:[g.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...O,...h},value:e.name1,disabled:l||!!e.name,onChange:y=>o({name1:y.target.value}),placeholder:"Incident status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:g.field.creationDate}),t.jsx(ve,{value:e.creation_date||"",onChange:y=>o({creation_date:y}),disabled:l,style:{...O,...h}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:g.field.status}),t.jsxs("select",{style:{...O,...h},value:e.status||"Active",disabled:l,onChange:y=>o({status:y.target.value}),children:[t.jsx("option",{value:"Active",children:g.field.statusActive}),t.jsx("option",{value:"Inactive",children:g.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:y=>o({notify_manager:y.target.checked?1:0}),style:Bl}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:g.field.notifyManager})]})]})]})}function y1(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 v1({ideaStatuses:e,canModify:n,onView:s,onEdit:l,onDelete:a,onSelectionChange:r}){const i=se(),[d,f]=_.useState(new Set),[p,k]=_.useState(""),[j,S]=_.useState("all"),u={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},v=_.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,C]=_.useState(1);_.useEffect(()=>{C(1)},[p,j]);const g=v.slice((z-1)*ae,z*ae);return _.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Pe,{label:"Total",val:v.length,color:X.teal})}),t.jsx(St,{filters:[{type:"search",label:"Search",value:p,onChange:k,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:S,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:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:u,children:i.col.name}),t.jsx("th",{style:u,children:i.field.notifyManager}),t.jsx("th",{style:u,children:i.field.creationDate}),t.jsx("th",{style:u,children:i.field.status}),t.jsx("th",{style:u,children:i.col.actions})]})}),t.jsx("tbody",{children:v.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},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?i.field.statusActive:"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:y1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(dt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l&&!o.custom_is_deleted?()=>l(o):void 0,onDelete:n&&a&&!o.custom_is_deleted?()=>a(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:v.length,onPageChange:C})]})}function j1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:a,onRestore:r,onPermanentDelete:i,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:k,onViewProfile:j,onSubmit:S,onBack:u,onNavigate:v,onLogout:z,user:C}){const g=se(),o=y=>n(w=>({...w,...y})),h=l?{background:"#f8fafc"}:{},x=e.name?l?`Idea Status: ${e.name1||e.name}`:"Edit Idea Status":"New Idea Status";return t.jsxs(et,{title:x,activePage:"idea-statuses",user:C,formStatus:s,buttonText:g.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:a,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:k,onViewProfile:j,onSubmit:S,onBack:u,onNavigate:v,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:r&&e.name?()=>r(e.name):void 0,onPermanentDelete:i&&e.name?()=>i(e.name):void 0}),t.jsxs(oe,{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:D,children:[g.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...O,...h},value:e.name1,disabled:l||!!e.name,onChange:y=>o({name1:y.target.value}),placeholder:"Idea status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:g.field.creationDate}),t.jsx(ve,{value:e.creation_date||"",onChange:y=>o({creation_date:y}),disabled:l,style:{...O,...h}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:g.field.status}),t.jsxs("select",{style:{...O,...h},value:e.status||"Active",disabled:l,onChange:y=>o({status:y.target.value}),children:[t.jsx("option",{value:"Active",children:g.field.statusActive}),t.jsx("option",{value:"Inactive",children:g.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:y=>o({notify_manager:y.target.checked?1:0}),style:Bl}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:g.field.notifyManager})]})]})]})}function b1(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 S1({orderStatuses:e,canModify:n,onView:s,onEdit:l,onDelete:a,onSelectionChange:r}){const i=se(),[d,f]=_.useState(new Set),[p,k]=_.useState(""),[j,S]=_.useState("all"),u={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},v=_.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,C]=_.useState(1);_.useEffect(()=>{C(1)},[p,j]);const g=v.slice((z-1)*ae,z*ae);return _.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Pe,{label:"Total",val:v.length,color:X.purple})}),t.jsx(St,{filters:[{type:"search",label:"Search",value:p,onChange:k,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:S,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:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:u,children:i.col.name}),t.jsx("th",{style:u,children:i.field.notifyManager}),t.jsx("th",{style:u,children:i.field.creationDate}),t.jsx("th",{style:u,children:i.field.status}),t.jsx("th",{style:u,children:i.col.actions})]})}),t.jsx("tbody",{children:v.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},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?i.field.statusActive:"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:b1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(dt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l&&!o.custom_is_deleted?()=>l(o):void 0,onDelete:n&&a&&!o.custom_is_deleted?()=>a(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:v.length,onPageChange:C})]})}function _1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:a,onRestore:r,onPermanentDelete:i,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:k,onViewProfile:j,onSubmit:S,onBack:u,onNavigate:v,onLogout:z,user:C}){const g=se(),o=y=>n(w=>({...w,...y})),h=l?{background:"#f8fafc"}:{},x=e.name?l?`Order Status: ${e.name1||e.name}`:"Edit Order Status":"New Order Status";return t.jsxs(et,{title:x,activePage:"order-statuses",user:C,formStatus:s,buttonText:g.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:a,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:k,onViewProfile:j,onSubmit:S,onBack:u,onNavigate:v,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:r&&e.name?()=>r(e.name):void 0,onPermanentDelete:i&&e.name?()=>i(e.name):void 0}),t.jsxs(oe,{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:D,children:[g.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...O,...h},value:e.name1,disabled:l||!!e.name,onChange:y=>o({name1:y.target.value}),placeholder:"Order status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:g.field.creationDate}),t.jsx(ve,{value:e.creation_date||"",onChange:y=>o({creation_date:y}),disabled:l,style:{...O,...h}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:g.field.status}),t.jsxs("select",{style:{...O,...h},value:e.status||"Active",disabled:l,onChange:y=>o({status:y.target.value}),children:[t.jsx("option",{value:"Active",children:g.field.statusActive}),t.jsx("option",{value:"Inactive",children:g.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:y=>o({notify_manager:y.target.checked?1:0}),style:Bl}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:g.field.notifyManager})]})]})]})}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({processStatuses:e,canModify:n,onView:s,onEdit:l,onDelete:a,onSelectionChange:r}){const i=se(),[d,f]=_.useState(new Set),[p,k]=_.useState(""),[j,S]=_.useState("all"),u={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},v=_.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,C]=_.useState(1);_.useEffect(()=>{C(1)},[p,j]);const g=v.slice((z-1)*ae,z*ae);return _.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Pe,{label:"Total",val:v.length,color:X.blue})}),t.jsx(St,{filters:[{type:"search",label:"Search",value:p,onChange:k,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:S,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:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:u,children:i.col.name}),t.jsx("th",{style:u,children:i.field.notifyManager}),t.jsx("th",{style:u,children:i.field.creationDate}),t.jsx("th",{style:u,children:i.field.status}),t.jsx("th",{style:u,children:i.col.actions})]})}),t.jsx("tbody",{children:v.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},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?i.field.statusActive:"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:w1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(dt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l&&!o.custom_is_deleted?()=>l(o):void 0,onDelete:n&&a&&!o.custom_is_deleted?()=>a(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:v.length,onPageChange:C})]})}function C1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:a,onRestore:r,onPermanentDelete:i,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:k,onViewProfile:j,onSubmit:S,onBack:u,onNavigate:v,onLogout:z,user:C}){const g=se(),o=y=>n(w=>({...w,...y})),h=l?{background:"#f8fafc"}:{},x=e.name?l?`Process Status: ${e.name1||e.name}`:"Edit Process Status":"New Process Status";return t.jsxs(et,{title:x,activePage:"process-statuses",user:C,formStatus:s,buttonText:g.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:a,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:k,onViewProfile:j,onSubmit:S,onBack:u,onNavigate:v,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:r&&e.name?()=>r(e.name):void 0,onPermanentDelete:i&&e.name?()=>i(e.name):void 0}),t.jsxs(oe,{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:D,children:[g.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...O,...h},value:e.name1,disabled:l||!!e.name,onChange:y=>o({name1:y.target.value}),placeholder:"Process status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:g.field.creationDate}),t.jsx(ve,{value:e.creation_date||"",onChange:y=>o({creation_date:y}),disabled:l,style:{...O,...h}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:g.field.status}),t.jsxs("select",{style:{...O,...h},value:e.status||"Active",disabled:l,onChange:y=>o({status:y.target.value}),children:[t.jsx("option",{value:"Active",children:g.field.statusActive}),t.jsx("option",{value:"Inactive",children:g.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:y=>o({notify_manager:y.target.checked?1:0}),style:Bl}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:g.field.notifyManager})]})]})]})}const z1={Admin:"#7c3aed",Chairman:"#0f766e",Auditor:"#d97706","X-Auditor":"#8b5cf6",Manager:"#2563eb",Employee:"#6b7280"};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 E1({users:e,canModify:n,onView:s,onEdit:l,onDisable:a,onSelectionChange:r}){const i=se(),[d,f]=_.useState(new Set),[p,k]=_.useState(!1),[j,S]=_.useState(""),[u,v]=_.useState(""),[z,C]=_.useState(""),[g,o]=_.useState("active"),[h,x]=_.useState(1),[y,w]=_.useState(null),[c,b]=_.useState(""),[A,T]=_.useState("idle"),[M,H]=_.useState(null),le=async()=>{if(!(!y||!c.trim())){T("loading");try{await si(y.name,c.trim()),T("success"),setTimeout(()=>{w(null),b(""),T("idle")},1200)}catch{T("error")}}},U=async E=>{if(window.confirm(i.users.disableConfirm)){H(E);try{await(a==null?void 0:a(E))}finally{H(null)}}},G=e.filter(E=>{if(g==="active"&&(E.enabled===0||E.enabled==="0")||g==="inactive"&&E.enabled!==0&&E.enabled!=="0")return!1;const ee=E.custom_category||"";if(z&&ee!==z)return!1;const V=E.custom_organization||"";if(u&&!V.toLowerCase().includes(u.toLowerCase()))return!1;if(j){const ce=j.toLowerCase();if(![E.full_name,E.email,E.name,E.username,E.mobile_no].join(" ").toLowerCase().includes(ce))return!1}return!0}),$=[...new Set(e.map(E=>E.custom_organization).filter(Boolean))],I=["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"];_.useEffect(()=>{x(1)},[j,u,z,g]);const P=G.slice((h-1)*ae,h*ae);_.useEffect(()=>{if(r){const E=G.filter(ee=>d.has(ee.name));r(E,P)}},[d,P]);const F={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151"},K={...F,cursor:"pointer"};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:()=>k(E=>!E),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:p?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"})]}),p&&t.jsx("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:F,placeholder:"Name, email, username…",value:j,onChange:E=>{S(E.target.value),x(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:K,value:u,onChange:E=>{v(E.target.value),x(1)},children:[t.jsx("option",{value:"",children:"All Organizations"}),$.map(E=>t.jsx("option",{value:E,children:E},E))]})]}),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:K,value:z,onChange:E=>{C(E.target.value),x(1)},children:[t.jsx("option",{value:"",children:"All Categories"}),I.map(E=>t.jsx("option",{value:E,children:E},E))]})]}),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:K,value:g,onChange:E=>{o(E.target.value),x(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:{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:P.length>0&&P.every(E=>d.has(E.name)),onChange:E=>{if(E.target.checked)f(new Set([...d,...P.map(ee=>ee.name)]));else{const ee=new Set(d);P.forEach(V=>ee.delete(V.name)),f(ee)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),[{label:"Category",w:110},{label:"Number",w:90},{label:i.col.name,w:160},{label:"Username",w:130},{label:"Email",w:180},{label:"Phone",w:110},{label:i.col.organization,w:140},{label:i.col.management,w:120},{label:i.col.department,w:120},{label:"Branch",w:100},{label:"Since",w:90},{label:"Status",w:80},{label:"Tools",w:200}].map(({label:E,w:ee})=>t.jsx("th",{style:{padding:"11px 14px",textAlign:"left",color:"#6b7280",fontSize:11,fontWeight:700,whiteSpace:"nowrap",minWidth:ee,letterSpacing:.3,textTransform:"uppercase"},children:E},E))]})}),t.jsx("tbody",{children:G.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"})}):P.map((E,ee)=>{const V=E.custom_category||"",ce=z1[V]||"#6b7280";return t.jsxs("tr",{onClick:()=>s==null?void 0:s(E),style:{borderBottom:"1px solid #f3f4f6",background:d.has(E.name)?"#eff6ff":ee%2===0?"white":"#fafafa",transition:"background 0.1s",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"11px 14px",textAlign:"center"},onClick:ie=>ie.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(E.name),onChange:()=>{const ie=new Set(d);ie.has(E.name)?ie.delete(E.name):ie.add(E.name),f(ie)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:V?t.jsx("span",{style:{background:ce+"18",color:ce,border:`1px solid ${ce}44`,padding:"3px 10px",borderRadius:20,fontSize:11,fontWeight:700},children:V}):t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:E.custom_number||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",fontWeight:600,color:"#1a2332",whiteSpace:"nowrap"},children:E.full_name||E.first_name||"—"}),t.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:E.username||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:E.email||E.name}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:E.mobile_no||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:E.custom_organization||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:E.custom_management||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:E.custom_department||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:E.custom_branch||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:I1(E.creation)}),t.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:t.jsx("span",{style:{color:E.enabled?"#16a34a":"#dc2626",fontWeight:600},children:E.enabled?i.users.active:i.users.inactive})}),t.jsx("td",{style:{padding:"10px 14px",whiteSpace:"nowrap"},onClick:ie=>ie.stopPropagation(),children:t.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[t.jsx("button",{onClick:ie=>{ie.stopPropagation(),s==null||s(E)},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:ie=>{ie.stopPropagation(),l(E)},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:ie=>{ie.stopPropagation(),w({name:E.name,email:E.email||E.name}),b(""),T("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:ie=>{ie.stopPropagation(),U(E.name)},disabled:M===E.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:M===E.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"})]})})]})})]},E.name)})})]})}),t.jsx(Ue,{page:h,total:G.length,onPageChange:x}),y&&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:i.users.setPassword}),t.jsxs("div",{style:{fontSize:13,color:"#6b7280",marginBottom:20},children:["User: ",t.jsx("strong",{children:y.email})]}),t.jsx("input",{type:"password",value:c,onChange:E=>b(E.target.value),placeholder:i.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:E=>E.key==="Enter"&&le(),autoFocus:!0}),A==="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"}),A==="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:le,disabled:A==="loading"||!c.trim(),style:{flex:1,padding:10,background:"#2563eb",color:"white",border:"none",borderRadius:8,cursor:"pointer",fontSize:13,fontWeight:700,fontFamily:"inherit",opacity:c.trim()?1:.5},children:A==="loading"?"Saving…":i.users.setPassword}),t.jsx("button",{onClick:()=>{w(null),b(""),T("idle")},style:{flex:1,padding:10,background:"#f5f5f5",color:"#374151",border:"1px solid #e5e7eb",borderRadius:8,cursor:"pointer",fontSize:13,fontFamily:"inherit"},children:i.cancel})]})]})})]})}function T1({form:e,setForm:n,groupCompanies:s=[],organizations:l,managements:a,departments:r,branches:i,users:d=[],formStatus:f,viewMode:p,onEdit:k,onRestore:j,onPermanentDelete:S,darkMode:u,notifCount:v,onToggleDark:z,onCountChange:C,onViewProfile:g,isSelfProfile:o,onSubmit:h,onBack:x,onNavigate:y,onLogout:w,user:c}){const b=se(),A=E=>n(ee=>({...ee,...E})),T=p?{background:"#f8fafc"}:{},M=s.map(E=>({name:E.name,label:E.company_name||E.name})),H=e.custom_organization?a.filter(E=>!E.organization||E.organization===e.custom_organization):a,le=r.filter(E=>!(e.custom_organization&&E.custom_organization&&E.custom_organization!==e.custom_organization||e.custom_management&&E.custom_management&&E.custom_management!==e.custom_management)),U=i.filter(E=>!(e.custom_organization&&E.organization&&E.organization!==e.custom_organization||e.custom_management&&E.management&&E.management!==e.custom_management||e.custom_department&&E.department&&E.department!==e.custom_department)),G=be(H,e.custom_management).map(E=>({name:E.name,label:E.name1||E.name})),$=be(le,e.custom_department).map(E=>({name:E.name,label:E.department_name||E.name})),I=be(U,e.custom_branch).map(E=>({name:E.name,label:E.branch||E.name})),P=d.filter(E=>!(E.name===e.name||e.custom_organization&&E.custom_organization&&E.custom_organization!==e.custom_organization)),F=!e.name||e.name.startsWith("new-user-"),K=o?b.formTitle.viewUser:F?b.formTitle.newUser:b.formTitle.editUser;return t.jsxs(et,{title:K,activePage:"users",user:c,formStatus:f,buttonText:b.saveUser,buttonColor:"#16a34a",viewMode:p,onEdit:k,darkMode:u,notifCount:v,onToggleDark:z,onCountChange:C,onViewProfile:g,onSubmit:h,onBack:x,onNavigate:y,onLogout:w,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:j&&e.name?()=>j(e.name):void 0,onPermanentDelete:S&&e.name?()=>S(e.name):void 0}),t.jsx(oe,{title:"User Organization & Assignment",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[(c.role==="Admin"||c.role==="CEO")&&!c.custom_group_company&&t.jsxs("div",{children:[t.jsx("label",{style:D,children:"Group Company (Tenant)"}),t.jsx(ge,{value:e.custom_group_company||"",onChange:E=>A({custom_group_company:E}),items:M,placeholder:"-- Select Group Company --",disabled:p,userRole:c.role,doctypeName:R.groupCompanies})]}),e.custom_category!=="Admin"&&e.custom_category!=="CEO"&&e.role!=="Admin"&&e.role!=="CEO"&&t.jsxs("div",{children:[t.jsx("label",{style:D,children:"Reports To / Supervisor"}),t.jsxs("select",{style:{...O,...T},value:e.custom_manager||"",disabled:p,onChange:E=>A({custom_manager:E.target.value}),children:[t.jsx("option",{value:"",children:"-- No Supervisor / Direct --"}),P.map(E=>{const ee=E.full_name||E.email||E.name,V=E.custom_category?` [${E.custom_category}]`:"";return t.jsxs("option",{value:E.name,children:[ee,V]},E.name)})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:b.field.organization}),t.jsx(sn,{value:e.custom_organization,onChange:E=>A({custom_organization:E}),organizations:l,disabled:p,userRole:c.role})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:b.field.management}),t.jsx(ge,{value:e.custom_management,onChange:E=>A({custom_management:E}),items:G,placeholder:"-- Select --",disabled:p,userRole:c.role,doctypeName:R.managements,extraFields:{organization:e.custom_organization}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:b.field.department}),t.jsx(ge,{value:e.custom_department,onChange:E=>A({custom_department:E}),items:$,placeholder:"-- Select --",disabled:p,userRole:c.role,doctypeName:R.departments,extraFields:{organization:e.custom_organization,management:e.custom_management}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:b.field.branch}),t.jsx(ge,{value:e.custom_branch,onChange:E=>A({custom_branch:E}),items:I,placeholder:"-- Select --",disabled:p,userRole:c.role,doctypeName:R.branches,extraFields:{organization:e.custom_organization,management:e.custom_management,department:e.custom_department}})]})]})}),t.jsx(oe,{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:D,children:b.field.number}),t.jsx("input",{style:{...O,...T},value:e.custom_number,disabled:p,onChange:E=>A({custom_number:E.target.value}),placeholder:"e.g. 10001"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:D,children:[b.field.fullName," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...O,...T},value:e.first_name,disabled:p,onChange:E=>A({first_name:E.target.value}),placeholder:"Full name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:b.field.username}),t.jsx("input",{style:{...O,...T},value:e.username,disabled:p,onChange:E=>A({username:E.target.value}),placeholder:"Username"})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:b.field.phoneNumber}),t.jsx("input",{style:{...O,...T},value:e.mobile_no,disabled:p,onChange:E=>A({mobile_no:E.target.value}),placeholder:"Phone number"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:D,children:[b.field.emailAddress," ",F&&t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...O,...p||!F?{background:"#f8fafc"}:{}},value:e.email,disabled:p||!F,onChange:E=>A({email:E.target.value}),placeholder:"user@example.com",type:"email",required:F})]}),F&&t.jsxs("div",{children:[t.jsxs("label",{style:D,children:["Password ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...O,...T},type:"password",value:e.new_password||"",disabled:p,onChange:E=>A({new_password:E.target.value}),placeholder:"Initial password",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:b.field.category}),t.jsxs("select",{style:{...O,...T},value:e.custom_category,disabled:p,onChange:E=>A({custom_category:E.target.value}),children:[t.jsx("option",{value:"",children:b.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 $u={Active:X.green,Closed:X.gray};function A1({cycles:e,canModify:n,onView:s,onEdit:l,onDelete:a,onSelectionChange:r}){const i=se(),[d,f]=_.useState(new Set),[p,k]=_.useState(""),[j,S]=_.useState(""),[u,v]=_.useState("all"),z=_.useMemo(()=>[...new Set(e.map(w=>w.organization).filter(Boolean))],[e]),C=_.useMemo(()=>e.filter(w=>{const c=(w.name1||w.name||"").toLowerCase();return!(p&&!c.includes(p.toLowerCase())||j&&w.organization!==j||u!=="all"&&w.status!==u)}),[e,p,j,u]),[g,o]=_.useState(1);_.useEffect(()=>{o(1)},[p,j,u]);const h=C.slice((g-1)*ae,g*ae);_.useEffect(()=>{if(r){const w=e.filter(c=>d.has(c.name));r(w,h)}},[d,h]);const x=C.filter(w=>w.status==="Active").length,y=C.filter(w=>w.status==="Closed").length;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Pe,{label:"Total",val:C.length,color:X.teal}),t.jsx(Pe,{label:"Active",val:x,color:X.green}),t.jsx(Pe,{label:"Closed",val:y,color:X.gray})]}),t.jsx(St,{filters:[{type:"search",label:"Search",value:p,onChange:k,placeholder:"Search by name…"},{type:"select",label:i.col.organization,value:j,onChange:S,options:[{value:"",label:"All Organizations"},...z.map(w=>({value:w,label:w}))]},{type:"select",label:"Status",value:u,onChange:v,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:h.length>0&&h.every(w=>d.has(w.name)),onChange:w=>{if(w.target.checked)f(new Set([...d,...h.map(c=>c.name)]));else{const c=new Set(d);h.forEach(b=>c.delete(b.name)),f(c)}},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:i.col.name}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.organization}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.frequency}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.startDate}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.endDate}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.status}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.actions})]})}),t.jsx("tbody",{children:C.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:8,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):h.map((w,c)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(w),style:{borderTop:"1px solid #f0f0f0",background:d.has(w.name)?"#eff6ff":w.custom_is_deleted?"#fff1f2":c%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:d.has(w.name),onChange:()=>{const b=new Set(d);b.has(w.name)?b.delete(w.name):b.add(w.name),f(b)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:w.name1||w.name}),t.jsx("td",{style:{padding:"10px 14px"},children:w.organization||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:w.frequency||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:w.start_date||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:w.end_date||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:w.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{padding:"3px 10px",borderRadius:12,fontSize:12,background:$u[w.status]+"22",color:$u[w.status]||"#666"},children:w.status})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:b=>b.stopPropagation(),children:t.jsx(dt,{onView:()=>s==null?void 0:s(w),onEdit:n&&l&&!w.custom_is_deleted?()=>l(w):void 0,onDelete:n&&a&&!w.custom_is_deleted?()=>a(w.name):void 0})})]},w.name))})]})}),t.jsx(Ue,{page:g,total:C.length,onPageChange:o})]})}const P1=["Weekly","Bi-weekly","Monthly","Quarterly","Annually"],R1=["Active","Closed"];function D1({form:e,setForm:n,organizations:s,groupCompanies:l=[],formStatus:a,viewMode:r,onEdit:i,onRestore:d,onPermanentDelete:f,darkMode:p,notifCount:k,onToggleDark:j,onCountChange:S,onViewProfile:u,onSubmit:v,onBack:z,onNavigate:C,onLogout:g,user:o}){const h=se(),x=c=>n(b=>({...b,...c})),y=r?{background:"#f8fafc"}:{},w=e.name?r?`${h.formTitle.editCycle}: ${e.name1||e.name}`:h.formTitle.editCycle:h.formTitle.newCycle;return t.jsxs(et,{title:w,activePage:"cycles",user:o,formStatus:a,buttonText:h.saveCycle,buttonColor:"#16a34a",viewMode:r,onEdit:i,darkMode:p,notifCount:k,onToggleDark:j,onCountChange:S,onViewProfile:u,onSubmit:v,onBack:z,onNavigate:C,onLogout:g,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:d&&e.name?()=>d(e.name):void 0,onPermanentDelete:f&&e.name?()=>f(e.name):void 0}),t.jsx(oe,{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:D,children:[h.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(sn,{value:e.organization,onChange:c=>{var A;const b=(A=s.find(T=>T.name===c))==null?void 0:A.group_company;x({organization:c,...o.custom_group_company?{}:{group_company:b||e.group_company}})},organizations:s,disabled:r||!!o.custom_organization,userRole:o.role})]}),t.jsxs("div",{children:[t.jsxs("label",{style:D,children:[h.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...O,...y},value:e.name1||"",disabled:r||!!e.name,onChange:c=>x({name1:c.target.value}),placeholder:"e.g. Q1-2026"})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:h.col.frequency}),t.jsx(ge,{value:e.frequency,onChange:c=>x({frequency:c}),items:P1.map(c=>({name:c,label:c})),placeholder:"-- Select Frequency --",disabled:r})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:h.field.status}),t.jsx(ge,{value:e.status,onChange:c=>x({status:c}),items:R1.map(c=>({name:c,label:c})),placeholder:"-- Select Status --",disabled:r})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:h.field.dateStart}),t.jsx(ve,{value:e.start_date||"",onChange:c=>x({start_date:c}),disabled:r,style:{...O,...y}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:h.field.dateEnd}),t.jsx(ve,{value:e.end_date||"",onChange:c=>x({end_date:c}),disabled:r,style:{...O,...y}})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:h.field.updateWindowDays}),t.jsx("input",{type:"number",min:1,max:30,style:{...O,...y},value:e.update_window_days??2,disabled:r,onChange:c=>x({update_window_days:parseInt(c.target.value)||2})}),t.jsx("span",{style:{fontSize:11,color:"#64748b",display:"block",marginTop:4},children:"Grace period before Unknown is auto-assigned"})]})]})})]})}function O1({kpiInputs:e,canModify:n,onView:s,onEdit:l,onDelete:a,onSelectionChange:r}){const i=se(),[d,f]=_.useState(new Set),[p,k]=_.useState(""),[j,S]=_.useState(""),u=_.useMemo(()=>[...new Set(e.map(o=>o.organization).filter(Boolean))],[e]),v=_.useMemo(()=>e.filter(o=>{const h=[o.organization,o.period].filter(Boolean).join(" ").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j&&o.organization!==j)}),[e,p,j]),[z,C]=_.useState(1);_.useEffect(()=>{C(1)},[p,j]);const g=v.slice((z-1)*ae,z*ae);return _.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Pe,{label:"Total Records",val:v.length,color:X.blue})}),t.jsx(St,{filters:[{type:"search",label:"Search",value:p,onChange:k,placeholder:"Organization or period…"},{type:"select",label:i.col.organization,value:j,onChange:S,options:[{value:"",label:"All Organizations"},...u.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:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(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:i.col.organization}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.period}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.field.revenue_growth}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.field.net_profit}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.dash.customerSat}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.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:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},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.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):o.customer_satisfaction!=null?o.customer_satisfaction:"—"}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(dt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l&&!o.custom_is_deleted?()=>l(o):void 0,onDelete:n&&a&&!o.custom_is_deleted?()=>a(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:v.length,onPageChange:C})]})}function L1({form:e,setForm:n,organizations:s,groupCompanies:l=[],formStatus:a,viewMode:r,onEdit:i,onRestore:d,onPermanentDelete:f,darkMode:p,notifCount:k,onToggleDark:j,onCountChange:S,onViewProfile:u,onSubmit:v,onBack:z,onNavigate:C,onLogout:g,user:o}){const h=se(),x=b=>n(A=>({...A,...b})),y=r?{background:"#f8fafc"}:{},w=b=>A=>x({[b]:parseFloat(A.target.value)||0}),c=e.name?r?`${h.formTitle.editKpi}: ${e.period||e.name}`:h.formTitle.editKpi:h.formTitle.newKpi;return t.jsxs(et,{title:c,activePage:"kpi-input",user:o,formStatus:a,buttonText:h.saveKpi,buttonColor:"#16a34a",viewMode:r,onEdit:i,darkMode:p,notifCount:k,onToggleDark:j,onCountChange:S,onViewProfile:u,onSubmit:v,onBack:z,onNavigate:C,onLogout:g,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:d&&e.name?()=>d(e.name):void 0,onPermanentDelete:f&&e.name?()=>f(e.name):void 0}),t.jsx(oe,{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:D,children:[h.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(sn,{value:e.organization,onChange:b=>{var T;const A=(T=s.find(M=>M.name===b))==null?void 0:T.group_company;x({organization:b,...o.custom_group_company?{}:{group_company:A||e.group_company}})},organizations:s,disabled:r||!!o.custom_organization,userRole:o.role})]}),t.jsxs("div",{children:[t.jsxs("label",{style:D,children:[h.col.period," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...O,...y},value:e.period||"",disabled:r,onChange:b=>x({period:b.target.value}),placeholder:"e.g. Q1 2026"})]})]})}),t.jsx(oe,{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:D,children:h.field.revenue_growth}),t.jsx("input",{type:"number",step:"0.01",style:{...O,...y},value:e.revenue_growth||"",disabled:r,onChange:w("revenue_growth")})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:h.field.net_profit}),t.jsx("input",{type:"number",step:"0.01",style:{...O,...y},value:e.net_profit||"",disabled:r,onChange:w("net_profit")})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:h.field.cash_flow}),t.jsx("input",{type:"number",step:"0.01",style:{...O,...y},value:e.cash_flow||"",disabled:r,onChange:w("cash_flow")})]})]})}),t.jsx(oe,{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:D,children:h.field.strategic_goal_pct}),t.jsx("input",{type:"number",step:"0.01",style:{...O,...y},value:e.strategic_goal_pct||"",disabled:r,onChange:w("strategic_goal_pct")})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:h.field.customer_satisfaction}),t.jsx("input",{type:"number",step:"0.01",style:{...O,...y},value:e.customer_satisfaction||"",disabled:r,onChange:w("customer_satisfaction")})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:h.field.employee_turnover_pct}),t.jsx("input",{type:"number",step:"0.01",style:{...O,...y},value:e.employee_turnover_pct||"",disabled:r,onChange:w("employee_turnover_pct")})]})]})}),t.jsx(oe,{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:D,children:h.field.open_safety_incidents}),t.jsx("input",{type:"number",min:0,style:{...O,...y},value:e.open_safety_incidents||"",disabled:r,onChange:b=>x({open_safety_incidents:parseInt(b.target.value)||0})})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:h.field.compliance_score}),t.jsx("input",{type:"number",step:"0.01",style:{...O,...y},value:e.compliance_score||"",disabled:r,onChange:w("compliance_score")})]})]})})]})}const W1={incident_initial_evaluation:"Incident Initial Evaluation",idea_initial_evaluation:"Idea Initial Evaluation"},Uu={Pending:X.orange,Accepted:X.green,Rejected:X.red,Revoked:X.gray};function N1(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 B1(e){const n=[];return e.incident_initial_evaluation&&n.push("incident_initial_evaluation"),e.idea_initial_evaluation&&n.push("idea_initial_evaluation"),n}function $1({delegations:e,organizations:n,userRole:s,currentUser:l,onView:a,onRevoke:r,onSelectionChange:i}){const d=se(),[f,p]=_.useState(new Set),[k,j]=_.useState(""),[S,u]=_.useState(""),[v,z]=_.useState("all"),C={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},g=_.useMemo(()=>e.filter(c=>{const b=`${c.auditor} ${c.manager}`.toLowerCase();return!(k&&!b.includes(k.toLowerCase())||S&&c.organization!==S||v!=="all"&&c.status!==v)}),[e,k,S,v]),[o,h]=_.useState(1);_.useEffect(()=>{h(1)},[k,S,v]);const x=g.slice((o-1)*ae,o*ae);_.useEffect(()=>{if(i){const c=e.filter(b=>f.has(b.name));i(c,x)}},[f,x]);const y=g.filter(c=>c.status==="Pending").length,w=g.filter(c=>c.status==="Accepted").length;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Pe,{label:"Total",val:g.length,color:X.purple}),t.jsx(Pe,{label:"Pending",val:y,color:X.orange}),t.jsx(Pe,{label:"Accepted",val:w,color:X.green})]}),t.jsx(St,{filters:[{type:"search",label:"Search",value:k,onChange:j,placeholder:"Auditor or Manager…"},{type:"select",label:d.col.organization,value:S,onChange:u,options:[{value:"",label:"All Organizations"},...n.map(c=>({value:c.organization_name||c.name,label:c.organization_name||c.name}))]},{type:"select",label:"Status",value:v,onChange:z,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:x.length>0&&x.every(c=>f.has(c.name)),onChange:c=>{if(c.target.checked)p(new Set([...f,...x.map(b=>b.name)]));else{const b=new Set(f);x.forEach(A=>b.delete(A.name)),p(b)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:C,children:d.col.number}),t.jsx("th",{style:C,children:d.col.auditor}),t.jsx("th",{style:C,children:d.col.manager}),t.jsx("th",{style:C,children:d.col.organization}),t.jsx("th",{style:C,children:d.col.functions}),t.jsx("th",{style:C,children:d.col.status}),t.jsx("th",{style:C,children:d.col.requestedOn}),t.jsx("th",{style:C,children:d.col.actions})]})}),t.jsx("tbody",{children:g.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:9,style:{padding:40,textAlign:"center",color:"#aaa"},children:d.noData})}):x.map((c,b)=>{const A=!!r&&(c.status==="Pending"||c.status==="Accepted")&&(s==="Admin"||c.auditor===l);return t.jsxs("tr",{className:"app-table-row",onClick:()=>a==null?void 0:a(c),style:{borderTop:"1px solid #f0f0f0",background:f.has(c.name)?"#eff6ff":b%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:T=>T.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:f.has(c.name),onChange:()=>{const T=new Set(f);T.has(c.name)?T.delete(c.name):T.add(c.name),p(T)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:c.number||c.name}),t.jsx("td",{style:{padding:"10px 14px"},children:c.auditor}),t.jsx("td",{style:{padding:"10px 14px"},children:c.manager}),t.jsx("td",{style:{padding:"10px 14px"},children:c.organization||"All Organizations"}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:B1(c).map(T=>t.jsx("span",{style:{background:"#ede9fe",color:"#6d28d9",padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600},children:W1[T]||T},T))})}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{background:(Uu[c.status]||X.gray)+"22",color:Uu[c.status]||X.gray,padding:"3px 10px",borderRadius:12,fontSize:12,fontWeight:700},children:c.status})}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:N1(c.requested_on)}),t.jsx("td",{style:{padding:"8px 14px"},onClick:T=>T.stopPropagation(),children:t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("button",{onClick:()=>a==null?void 0:a(c),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"})]})}),A&&t.jsx("button",{onClick:()=>r==null?void 0:r(c.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"})]})})]},c.name)})})]})}),t.jsx(Ue,{page:o,total:g.length,onPageChange:h})]})}const yo={Pending:X.orange,Accepted:X.green,Rejected:X.red,Revoked:X.gray};function U1(e){if(!e)return"—";const n=new Date(e);return isNaN(n.getTime())?"—":n.toLocaleString()}function M1({form:e,setForm:n,organizations:s,users:l,userRoleMap:a,incidents:r=[],ideas:i=[],formStatus:d,viewMode:f,onEdit:p,onRestore:k,onPermanentDelete:j,darkMode:S,notifCount:u,onToggleDark:v,onCountChange:z,onViewProfile:C,onSubmit:g,onBack:o,onNavigate:h,onLogout:x,user:y}){var le;const w=se(),c=U=>n(G=>({...G,...U})),b=f?{background:"#f8fafc"}:{},A=Nl(l,a,"SB Manager",e.organization).filter(U=>U.name!==y.name).map(U=>({name:U.name,label:U.full_name||U.name})),T=(r||[]).filter(U=>(!e.organization||U.organization===e.organization)&&(U.workflow_state==="Initial Evaluation"||U.status==="Initial Evaluation")).map(U=>({name:U.name,label:`${U.number||U.name} — ${U.title}`})),M=(i||[]).filter(U=>(!e.organization||U.organization===e.organization)&&(U.workflow_state==="Initial Evaluation"||U.status==="Initial Evaluation")).map(U=>({name:U.name,label:`${U.number||U.name} — ${U.title}`})),H=e.name?`${w.formTitle.viewDelegation}${e.name}`:w.formTitle.newDelegation;return t.jsxs(et,{title:H,activePage:"delegations",user:y,formStatus:d,statusBadge:e.status?t.jsx("span",{style:{display:"inline-block",padding:"3px 10px",borderRadius:20,fontSize:12,fontWeight:700,background:`${yo[e.status]||X.gray}18`,color:yo[e.status]||X.gray,border:`1px solid ${yo[e.status]||X.gray}40`},children:e.status}):void 0,buttonText:w.saveDelegation,buttonColor:"#16a34a",viewMode:f,onEdit:p,darkMode:S,notifCount:u,onToggleDark:v,onCountChange:z,onViewProfile:C,onSubmit:g,onBack:o,onNavigate:h,onLogout:x,children:[e.custom_is_deleted===1&&t.jsx(Ze,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:k&&e.name?()=>k(e.name):void 0,onPermanentDelete:j&&e.name?()=>j(e.name):void 0}),e.status==="Revoked"&&t.jsxs("div",{style:{padding:"10px 14px",borderRadius:8,background:"#f8fafc",border:"1px solid #cbd5e1",color:"#475569",fontSize:13,fontWeight:600,marginBottom:14,display:"flex",alignItems:"center",gap:8},children:[t.jsx("span",{style:{fontSize:16},children:"🚫"})," This delegation has been Revoked and is closed for further edits or re-delegation."]}),t.jsxs(oe,{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:D,children:w.col.auditor}),t.jsx("input",{style:{...O,background:"#f8fafc",fontWeight:600,color:"#334155"},value:e.auditor||y.name,disabled:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:D,children:[w.col.manager," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(ge,{value:e.manager,onChange:U=>c({manager:U}),items:A,placeholder:"-- Select Manager --",disabled:f})]}),t.jsxs("div",{children:[t.jsx("label",{style:D,children:w.col.organization}),t.jsx(sn,{value:e.organization,onChange:U=>c({organization:U,incident_name:"",idea_name:""}),organizations:s,placeholder:"-- All Organizations --",disabled:f,userRole:y.role})]})]}),t.jsxs("div",{children:[t.jsxs("label",{style:D,children:[w.col.functions," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,marginTop:6},children:[t.jsxs("div",{className:`delegation-func-box ${e.incident_initial_evaluation?"checked":""}`,children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:f?"default":"pointer",fontSize:13,fontWeight:600},children:[t.jsx("input",{type:"checkbox",style:Bl,checked:!!e.incident_initial_evaluation,disabled:f,onChange:U=>c({incident_initial_evaluation:U.target.checked?1:0,incident_name:U.target.checked?e.incident_name:""})}),t.jsx("span",{className:"func-title",children:"Initial Evaluation (Incidents)"})]}),!!e.incident_initial_evaluation&&t.jsxs("div",{style:{marginTop:10},children:[t.jsxs("label",{style:{...D,fontSize:11},className:"func-sublabel",children:["Specific Incident ",t.jsx("span",{style:{fontWeight:400},className:"func-hint",children:"(optional — leave blank to delegate all)"})]}),f?t.jsx("input",{style:{...O,background:"#f8fafc"},value:e.incident_name||"— All Incidents in Initial Evaluation",readOnly:!0,disabled:!0}):t.jsx(ge,{value:e.incident_name||"",onChange:U=>c({incident_name:U}),items:T,placeholder:`-- Any Incident in Initial Evaluation (${T.length} available) --`,disabled:f})]})]}),t.jsxs("div",{className:`delegation-func-box ${e.idea_initial_evaluation?"checked":""}`,children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:f?"default":"pointer",fontSize:13,fontWeight:600},children:[t.jsx("input",{type:"checkbox",style:Bl,checked:!!e.idea_initial_evaluation,disabled:f,onChange:U=>c({idea_initial_evaluation:U.target.checked?1:0,idea_name:U.target.checked?e.idea_name:""})}),t.jsx("span",{className:"func-title",children:"Initial Evaluation (Ideas)"})]}),!!e.idea_initial_evaluation&&t.jsxs("div",{style:{marginTop:10},children:[t.jsxs("label",{style:{...D,fontSize:11},className:"func-sublabel",children:["Specific Idea ",t.jsx("span",{style:{fontWeight:400},className:"func-hint",children:"(optional — leave blank to delegate all)"})]}),f?t.jsx("input",{style:{...O,background:"#f8fafc"},value:e.idea_name||"— All Ideas in Initial Evaluation",readOnly:!0,disabled:!0}):t.jsx(ge,{value:e.idea_name||"",onChange:U=>c({idea_name:U}),items:M,placeholder:`-- Any Idea in Initial Evaluation (${M.length} available) --`,disabled:f})]})]})]})]}),!f&&t.jsxs("div",{style:{marginTop:14},children:[t.jsx("label",{style:D,children:"Remarks"}),t.jsx("textarea",{style:{...O,...b,minHeight:70,resize:"vertical"},value:e.remarks||"",onChange:U=>c({remarks:U.target.value}),placeholder:"Optional note for the Manager…"})]})]}),f&&(((le=e.delegation_log)==null?void 0:le.length)??0)>0&&t.jsx(oe,{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((U,G)=>t.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"8px 12px",fontWeight:600,color:"#334155"},children:U.action}),t.jsx("td",{style:{padding:"8px 12px",color:"#334155"},children:U.actor}),t.jsx("td",{style:{padding:"8px 12px",color:"#64748b"},children:U1(U.timestamp)}),t.jsx("td",{style:{padding:"8px 12px",color:"#64748b"},children:U.remarks||"—"})]},U.name||G))})]})})})]})}const Mu={process:"processes-form",order:"orders-form",incident:"incidents-form",idea:"ideas-form"},F1={process:"#3b82f6",order:"#8b5cf6",incident:"#ef4444",idea:"#10b981",delegation:"#f59e0b"},H1={process:"linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%)",order:"linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%)",incident:"linear-gradient(135deg, #ef4444 0%, #b91c1c 100%)",idea:"linear-gradient(135deg, #10b981 0%, #047857 100%)",delegation:"linear-gradient(135deg, #f59e0b 0%, #b45309 100%)"},G1={process:"⚙️",order:"📦",incident:"🚨",idea:"💡",delegation:"🤝"};function Q1({onNavigate:e,onRefresh:n}){const[s,l]=_.useState([]),[a,r]=_.useState(!0),[i,d]=_.useState(""),[f,p]=_.useState(""),[k,j]=_.useState(""),[S,u]=_.useState("all"),[v,z]=_.useState(1),C=()=>{r(!0),Ky().then(y=>{l(y||[]),r(!1)}).catch(()=>r(!1))};_.useEffect(()=>{C()},[]);const g=_.useMemo(()=>{const y={all:s.length,action:0,info:0};for(const w of s)w.requires_action?y.action=(y.action||0)+1:y.info=(y.info||0)+1,y[w.type]=(y[w.type]||0)+1;return y},[s]),o=_.useMemo(()=>s.filter(y=>{if(S==="action"&&!y.requires_action||S==="info"&&y.requires_action||S!=="all"&&S!=="action"&&S!=="info"&&y.type!==S)return!1;if(k.trim()){const w=k.toLowerCase();if(![y.number,y.title,y.action,y.organization,y.type].filter(Boolean).join(" ").toLowerCase().includes(w))return!1}return!0}),[s,S,k]);_.useEffect(()=>{z(1)},[S,k]);const h=o.slice((v-1)*ae,v*ae),x=async(y,w)=>{d(y),p("");try{await Xy(y,w),await C(),n==null||n()}catch{p(y)}finally{d("")}};return t.jsxs("div",{style:{maxWidth:1100,margin:"0 auto",display:"flex",flexDirection:"column",gap:20},children:[t.jsxs("div",{style:{background:"linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e293b 100%)",borderRadius:16,padding:"24px 28px",color:"#ffffff",boxShadow:"0 10px 25px -5px rgba(30, 27, 75, 0.25), 0 8px 10px -6px rgba(30, 27, 75, 0.2)",display:"flex",flexDirection:"column",gap:18,position:"relative",overflow:"hidden"},children:[t.jsx("div",{style:{position:"absolute",top:-40,right:-40,width:180,height:180,borderRadius:"50%",background:"radial-gradient(circle, rgba(99, 102, 241, 0.35) 0%, transparent 70%)",pointerEvents:"none"}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:14},children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx("span",{style:{fontSize:24},children:"📬"}),t.jsx("h2",{style:{fontSize:20,fontWeight:800,color:"#ffffff",margin:0,letterSpacing:"-0.3px"},children:"Unified Activity Inbox"})]}),t.jsx("p",{style:{margin:"4px 0 0",fontSize:13,color:"#c7d2fe",opacity:.9},children:"Real-time tasks, approvals, delegations, and workflow actions requiring your attention."})]}),t.jsxs("button",{type:"button",onClick:C,disabled:a,style:{background:"rgba(255, 255, 255, 0.15)",backdropFilter:"blur(8px)",border:"1px solid rgba(255, 255, 255, 0.25)",color:"white",borderRadius:10,padding:"8px 16px",fontSize:13,fontWeight:600,cursor:a?"wait":"pointer",display:"flex",alignItems:"center",gap:8,transition:"all 0.15s ease"},onMouseEnter:y=>{y.currentTarget.style.background="rgba(255, 255, 255, 0.25)"},onMouseLeave:y=>{y.currentTarget.style.background="rgba(255, 255, 255, 0.15)"},children:[t.jsx("span",{style:{transform:a?"rotate(180deg)":"none",transition:"transform 0.5s",display:"inline-block"},children:"🔄"}),a?"Refreshing…":"Refresh"]})]}),t.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:[t.jsxs("div",{style:{background:"rgba(255, 255, 255, 0.1)",backdropFilter:"blur(6px)",borderRadius:10,padding:"8px 14px",display:"flex",alignItems:"center",gap:10,border:"1px solid rgba(255, 255, 255, 0.15)"},children:[t.jsx("span",{style:{fontSize:12,color:"#e0e7ff",fontWeight:500},children:"Total Items"}),t.jsx("span",{style:{background:"white",color:"#1e1b4b",fontWeight:800,fontSize:12,padding:"2px 8px",borderRadius:999},children:g.all||0})]}),t.jsxs("div",{style:{background:"rgba(239, 68, 68, 0.2)",backdropFilter:"blur(6px)",borderRadius:10,padding:"8px 14px",display:"flex",alignItems:"center",gap:10,border:"1px solid rgba(239, 68, 68, 0.35)"},children:[t.jsx("span",{style:{fontSize:12,color:"#fecaca",fontWeight:600},children:"Action Required"}),t.jsx("span",{style:{background:"#ef4444",color:"white",fontWeight:800,fontSize:12,padding:"2px 8px",borderRadius:999},children:g.action||0})]}),t.jsxs("div",{style:{background:"rgba(59, 130, 246, 0.2)",backdropFilter:"blur(6px)",borderRadius:10,padding:"8px 14px",display:"flex",alignItems:"center",gap:10,border:"1px solid rgba(59, 130, 246, 0.35)"},children:[t.jsx("span",{style:{fontSize:12,color:"#bfdbfe",fontWeight:500},children:"Informational"}),t.jsx("span",{style:{background:"#3b82f6",color:"white",fontWeight:800,fontSize:12,padding:"2px 8px",borderRadius:999},children:g.info||0})]})]})]}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:14,background:"white",padding:"12px 16px",borderRadius:12,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},className:"form-card",children:[t.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[{id:"all",label:"All",icon:"📋",count:g.all},{id:"action",label:"Needs Action",icon:"🚨",count:g.action,badgeColor:"#ef4444"},{id:"info",label:"Info",icon:"ℹ️",count:g.info},{id:"incident",label:"Incidents",icon:"⚠️",count:g.incident},{id:"idea",label:"Ideas",icon:"💡",count:g.idea},{id:"order",label:"Orders",icon:"📦",count:g.order},{id:"process",label:"Processes",icon:"⚙️",count:g.process},{id:"delegation",label:"Delegations",icon:"🤝",count:g.delegation}].map(y=>{const w=S===y.id;return y.id!=="all"&&y.id!=="action"&&y.id!=="info"&&(!y.count||y.count===0)?null:t.jsxs("button",{type:"button",onClick:()=>u(y.id),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderRadius:999,border:w?"1px solid #4f46e5":"1px solid #e2e8f0",background:w?"#4f46e5":"#f8fafc",color:w?"#ffffff":"#475569",fontSize:12,fontWeight:600,cursor:"pointer",transition:"all 0.15s ease"},children:[t.jsx("span",{children:y.icon}),t.jsx("span",{children:y.label}),y.count!=null&&y.count>0&&t.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"1px 6px",borderRadius:999,background:w?"rgba(255,255,255,0.25)":y.badgeColor||"#e2e8f0",color:w?"#ffffff":y.badgeColor?"white":"#475569"},children:y.count})]},y.id)})}),t.jsx("div",{style:{minWidth:200,flex:"1 1 200px",maxWidth:300},children:t.jsx("input",{type:"text",placeholder:"Search items, titles, IDs…",value:k,onChange:y=>j(y.target.value),style:{width:"100%",padding:"7px 12px",borderRadius:8,border:"1px solid #cbd5e1",fontSize:12,boxSizing:"border-box",background:"#f8fafc",color:"#334155"}})})]}),a?t.jsxs("div",{style:{textAlign:"center",padding:"60px 20px",color:"#94a3b8",fontSize:14},children:[t.jsx("div",{style:{fontSize:28,marginBottom:8,animation:"spin 1s linear infinite"},children:"⏳"}),"Loading inbox updates…"]}):o.length===0?t.jsxs("div",{style:{background:"white",borderRadius:16,padding:"60px 24px",textAlign:"center",border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.03)"},className:"form-card",children:[t.jsx("div",{style:{fontSize:44,marginBottom:12},children:"✨"}),t.jsx("h3",{style:{fontSize:16,fontWeight:700,color:"#1e293b",margin:0},children:k||S!=="all"?"No matching inbox items":"You are all caught up!"}),t.jsx("p",{style:{fontSize:13,color:"#64748b",marginTop:6,maxWidth:420,margin:"6px auto 0"},children:k||S!=="all"?"Try changing your filter pills or searching for a different keyword.":"There are no active pending approvals or tasks requiring your action right now."}),(k||S!=="all")&&t.jsx("button",{type:"button",onClick:()=>{j(""),u("all")},style:{marginTop:16,padding:"7px 16px",borderRadius:8,background:"#4f46e5",color:"white",border:"none",fontWeight:600,fontSize:12,cursor:"pointer"},children:"Reset Filters"})]}):t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(330px, 1fr))",gap:14},children:h.map((y,w)=>{const c=F1[y.type]||X.gray,b=H1[y.type]||"linear-gradient(135deg, #64748b 0%, #475569 100%)",A=y.type!=="delegation";return t.jsxs("div",{className:"inbox-card form-card",onClick:A?()=>e(Mu[y.type],y.name):void 0,style:{background:"white",borderRadius:14,padding:"16px 18px",border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)",display:"flex",flexDirection:"column",justifyContent:"space-between",gap:14,cursor:A?"pointer":"default",position:"relative",overflow:"hidden",transition:"transform 0.15s ease, box-shadow 0.15s ease"},onMouseEnter:T=>{A&&(T.currentTarget.style.transform="translateY(-2px)",T.currentTarget.style.boxShadow="0 10px 20px -5px rgba(0,0,0,0.08)")},onMouseLeave:T=>{A&&(T.currentTarget.style.transform="none",T.currentTarget.style.boxShadow="0 1px 3px rgba(0,0,0,0.04)")},children:[t.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:4,background:b}}),t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,marginBottom:10},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("div",{style:{width:32,height:32,borderRadius:8,background:b,color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:15,flexShrink:0,boxShadow:`0 3px 8px -1px ${c}66`},children:G1[y.type]||"📌"}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:c,letterSpacing:"0.3px"},children:y.number||y.name})]}),y.requires_action?t.jsxs("span",{style:{fontSize:10,fontWeight:800,color:"#ef4444",background:"#fef2f2",border:"1px solid #fecaca",padding:"2px 8px",borderRadius:999,textTransform:"uppercase",letterSpacing:"0.4px",display:"flex",alignItems:"center",gap:4},children:[t.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"#ef4444"}}),"Action"]}):t.jsx("span",{style:{fontSize:10,fontWeight:700,color:"#64748b",background:"#f1f5f9",padding:"2px 8px",borderRadius:999,textTransform:"uppercase",letterSpacing:"0.3px"},children:y.type})]}),t.jsx("div",{className:"inbox-card-title",style:{fontSize:14,fontWeight:700,color:"#1e293b",lineHeight:1.35,marginBottom:6,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:y.title||y.action||"Untitled Item"}),t.jsx("div",{style:{fontSize:12,color:"#475569",lineHeight:1.4,marginBottom:8},children:y.action}),t.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[y.organization&&t.jsxs("span",{style:{fontSize:11,color:"#64748b",background:"#f8fafc",border:"1px solid #e2e8f0",padding:"2px 7px",borderRadius:6,display:"flex",alignItems:"center",gap:4},children:["🏢 ",y.organization]}),y.date&&t.jsxs("span",{style:{fontSize:11,color:"#64748b",background:"#f8fafc",border:"1px solid #e2e8f0",padding:"2px 7px",borderRadius:6},children:["📅 ",y.date]})]}),f===y.name&&t.jsx("div",{style:{marginTop:8,fontSize:11,color:"#ef4444",fontWeight:600},children:"⚠️ Failed to process response. Please try again."})]}),t.jsx("div",{children:y.type==="delegation"?t.jsxs("div",{style:{display:"flex",gap:8,marginTop:4},children:[t.jsx("button",{type:"button",onClick:()=>x(y.name,"Accepted"),disabled:i===y.name,style:{flex:1,padding:"7px 0",borderRadius:8,border:"none",background:"#16a34a",color:"white",fontWeight:700,fontSize:12,cursor:i===y.name?"wait":"pointer",opacity:i===y.name?.6:1,transition:"background 0.15s ease"},children:"✓ Accept"}),t.jsx("button",{type:"button",onClick:()=>x(y.name,"Rejected"),disabled:i===y.name,style:{flex:1,padding:"7px 0",borderRadius:8,border:"none",background:"#ef4444",color:"white",fontWeight:700,fontSize:12,cursor:i===y.name?"wait":"pointer",opacity:i===y.name?.6:1,transition:"background 0.15s ease"},children:"✕ Reject"})]}):t.jsxs("button",{type:"button",onClick:T=>{T.stopPropagation(),e(Mu[y.type],y.name)},style:{width:"100%",padding:"7px 12px",borderRadius:8,border:y.requires_action?"none":"1px solid #cbd5e1",background:y.requires_action?b:"#f8fafc",color:y.requires_action?"#ffffff":"#334155",fontWeight:700,fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:6,transition:"all 0.15s ease"},children:[t.jsx("span",{children:y.requires_action?"Review & Act Now":"View Details"}),t.jsx("span",{style:{fontSize:13},children:"→"})]})})]},y.name||w)})}),t.jsx(Ue,{page:v,total:o.length,onPageChange:z})]})}const K1=[{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"]}],pc={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 Y1(e,n){const s=e.map(a=>pc[a]||a).join(","),l=n.map(a=>e.map(r=>`"${a[r]??""}"`).join(",")).join(`
|
||
`);return s+`
|
||
`+l}function X1(e,n){const s=new Blob([e],{type:"text/csv"}),l=URL.createObjectURL(s),a=document.createElement("a");a.href=l,a.download=n,a.click(),URL.revokeObjectURL(l)}const Fu=e=>String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");function q1(e,n,s){const l=e.map(p=>`<th style="background:#4f46e5;color:#fff;padding:6px 10px;text-align:left">${Fu(pc[p]||p)}</th>`).join(""),a=n.map(p=>`<tr>${e.map(k=>`<td style="padding:4px 10px;border-bottom:1px solid #ddd">${Fu(p[k])}</td>`).join("")}</tr>`).join(""),r=`<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>${a}</tbody></table></body></html>`,i=new Blob(["\uFEFF"+r],{type:"application/vnd.ms-excel"}),d=URL.createObjectURL(i),f=document.createElement("a");f.href=d,f.download=s,f.click(),URL.revokeObjectURL(d)}const mh="report-print-area",vo="report-print-portal";function J1(){const e=document.getElementById(mh);if(!e)return;const n=document.createElement("div");n.id=vo,n.innerHTML=e.innerHTML,document.body.appendChild(n);const s=document.createElement("style");s.id="report-print-style",s.textContent=`
|
||
#${vo} { display: none; }
|
||
@media print {
|
||
#root { display: none !important; }
|
||
#${vo} { display: block !important; }
|
||
}
|
||
`,document.head.appendChild(s);const l=()=>{n.remove(),s.remove(),window.removeEventListener("afterprint",l)};window.addEventListener("afterprint",l),window.print()}const Hu={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",minWidth:180},jo={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white"};function V1({organizations:e,userRole:n}){const s=se(),l=K1.filter(H=>H.roles.includes(n)),[a,r]=_.useState(""),[i,d]=_.useState(""),[f,p]=_.useState(""),[k,j]=_.useState(""),[S,u]=_.useState(String(new Date().getFullYear())),[v,z]=_.useState([]),[C,g]=_.useState([]),[o,h]=_.useState(!1),[x,y]=_.useState(""),[w,c]=_.useState(1);_.useEffect(()=>{c(1)},[a,i,S]);const b=C.slice((w-1)*ae,w*ae),A=l.find(H=>H.id===a);async function T(){if(a){h(!0),y(""),g([]),z([]);try{const H={};i&&(H.organization=i),f&&(H.from_date=f),k&&(H.to_date=k),(A==null?void 0:A.extraFilter)==="year"&&S&&(H.year=S);const le=await Qy(a,H);z(le.columns||[]),g(le.rows||[])}catch(H){y(H.message||"Error running report")}finally{h(!1)}}}const M=(A==null?void 0:A.label)||a;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(H=>t.jsxs("div",{onClick:()=>r(H.id),style:{background:a===H.id?"#ebf5fb":"white",border:a===H.id?`2px solid ${X.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:H.label}),t.jsx("div",{style:{fontSize:12,color:"#888"},children:H.description})]},H.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:Hu,value:a,onChange:H=>r(H.target.value),children:[t.jsx("option",{value:"",children:"-- Select Report --"}),l.map(H=>t.jsx("option",{value:H.id,children:H.label},H.id))]})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"ORGANIZATION"}),t.jsxs("select",{style:Hu,value:i,onChange:H=>d(H.target.value),children:[t.jsx("option",{value:"",children:s.filter.allOrgs}),e.map(H=>t.jsx("option",{value:H.name,children:H.organization_name||H.name},H.name))]})]}),(A==null?void 0:A.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:{...jo,width:90},value:S,onChange:H=>u(H.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(ve,{value:f,onChange:p,style:jo})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"TO"}),t.jsx(ve,{value:k,onChange:j,style:jo})]})]}),t.jsx("button",{onClick:T,disabled:!a||o,style:{padding:"9px 20px",borderRadius:8,border:"none",background:X.accent,color:"white",fontWeight:700,fontSize:13,cursor:a?"pointer":"not-allowed",opacity:a?1:.5},children:o?s.loading:s.reports.generate}),C.length>0&&t.jsx("button",{onClick:()=>X1(Y1(v,C),`${a}.csv`),style:{padding:"9px 20px",borderRadius:8,border:"1px solid #27ae60",background:"white",color:"#27ae60",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Export CSV"}),C.length>0&&t.jsx("button",{onClick:()=>q1(v,C,`${a}.xls`),style:{padding:"9px 20px",borderRadius:8,border:"1px solid #107c41",background:"white",color:"#107c41",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Export Excel"}),C.length>0&&t.jsx("button",{onClick:J1,style:{padding:"9px 20px",borderRadius:8,border:"1px solid #888",background:"white",color:"#555",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Print / PDF"})]})}),x&&t.jsx("div",{style:{color:"#e74c3c",marginBottom:16},children:x}),C.length>0&&t.jsxs("div",{id:mh,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:M}),t.jsxs("span",{style:{fontSize:12,color:"#888"},children:[C.length," rows"]})]}),t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsx("tr",{style:{background:"#f8f9fa"},children:v.map(H=>t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700,whiteSpace:"nowrap"},children:pc[H]||H.replace(/_/g," ").toUpperCase()},H))})}),t.jsx("tbody",{children:b.map((H,le)=>t.jsx("tr",{style:{borderTop:"1px solid #f0f0f0",background:le%2===0?"white":"#fafafa"},children:v.map(U=>t.jsx("td",{style:{padding:"10px 14px",color:"#333"},children:H[U]!=null?String(H[U]):"—"},U))},le))})]}),t.jsx(Ue,{page:w,total:C.length,onPageChange:c})]}),!o&&C.length===0&&a&&!x&&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 Fa=()=>new Date().toISOString().split("T")[0],fc=()=>new Date(Date.now()+30*24*60*60*1e3).toISOString().split("T")[0],Z1=()=>new Date().toTimeString().slice(0,5),Ln=()=>({name:"",number:"",title:"",organization:"",group_company:"",event_category:"",type:"",incident_class:"",incident_field:"",date:Fa(),time:Z1(),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:""}),wn=()=>({name:"",number:"",title:"",organization:"",group_company:"",type:"",management:"",department:"",section_field:"",branch:"",current_condition:"",proposed_condition:"",status:"",assigned_to:"",workflow_state:"New",idea_class:"",hses_field:"",date:Fa(),priority:"",economy_class:"",product_relation:0,repeated:0,entity_scope:"",solution:"",cost:0,auditor_comment:"",sb_order:""}),kn=()=>({name:"",number:"",title:"",organization:"",group_company:"",type:"Buy L",management:"",department:"",section_field:"",branch:"",starting_date:Fa(),ending_date:fc(),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:""}),xr=()=>({name:"",title:"",date_start:Fa(),date_end:fc(),number:"",status:"",cycle_type:"Normal",organization:"",group_company:"",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:""}),sl=()=>({name:"",organization_name:"",group_company:"",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}),ws=()=>({name:"",organization:"",group_company:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ks=()=>({name:"",custom_organization:"",group_company:"",department_name:"",custom_management:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),Cs=()=>({name:"",organization:"",group_company:"",branch:"",management:"",department:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),ll=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),al=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),rl=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),il=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ol=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),dl=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),cl=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ul=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),yr=()=>({name:"",first_name:"",full_name:"",email:"",enabled:1,creation:"",username:"",mobile_no:"",custom_organization:"",custom_group_company:"",custom_manager:"",custom_management:"",custom_department:"",custom_branch:"",custom_number:"",custom_category:""}),zs=()=>({name:"",name1:"",organization:"",group_company:"",frequency:"Monthly",status:"Active",start_date:Fa(),end_date:fc(),update_window_days:2}),Is=()=>({name:"",organization:"",group_company:"",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}),la=()=>({name:"",number:"",auditor:"",manager:"",organization:"",incident_initial_evaluation:0,idea_initial_evaluation:0,status:"Pending",requested_on:"",remarks:""}),ev=new Set(["incidents","incidents-form","ideas","ideas-form"]),tv=new Set(["orders","orders-form","incidents","incidents-form","ideas","ideas-form"]),nv=new Set(ah.flatMap(({id:e})=>[e,`${e}-form`])),sv=new Set(["Admin","Owner","Auditor","Manager","CEO"]),lv=new Set(["Admin","Owner","Auditor","Manager","CEO"]),av=new Set(["Admin","Auditor","Manager","CEO"]);function rv({user:e,onLogout:n,darkMode:s,onToggleDark:l}){const a=se(),r=e.role,i=sv.has(r),d=lv.has(r),f=av.has(r),p=m=>r==="CEO"?!0:m==="users"||m==="users-form"?r==="Admin":r==="Admin"||r==="Auditor"?!0:r==="Owner"||r==="XAuditor"?!1:r==="Manager"?!!tv.has(m):ev.has(m),k=m=>r==="Employee"&&!!m&&m!=="New",j=i?"dashboard":"inbox",S=m=>r==="CEO"?!0:m==="dashboard"?i:m==="reports"?d:m==="delegations"||m==="delegations-form"?f:m==="users"||m==="users-form"?r==="Admin":nv.has(m)?r==="Admin"||r==="Auditor":!0,[u,v]=_.useState(()=>{const m=r0(Ru());return m&&S(m)?m:j});_.useEffect(()=>{const m=i0(u);window.location.hash!==m&&window.history.pushState(null,"",m)},[u]),_.useEffect(()=>{const m=()=>{const W=Ru();v(W&&S(W)?W:j)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[]);const z=e.custom_organization||"",C=e.custom_group_company||"",g=m=>{var W;return((W=M.find(_e=>_e.name===m))==null?void 0:W.group_company)||""},[o,h]=_.useState(""),[x,y]=_.useState("");_.useEffect(()=>{if(!x)return;const m=setTimeout(()=>y(""),0);return()=>clearTimeout(m)},[x]);const w=(m,W)=>{y(W),v(m)},[c,b]=_.useState(0),[A,T]=_.useState([]),[M,H]=_.useState([]),[le,U]=_.useState([]),[G,$]=_.useState([]),[I,P]=_.useState([]),[F,K]=_.useState([]),[E,ee]=_.useState([]),[V,ce]=_.useState([]),[ie,tt]=_.useState([]),[Re,_t]=_.useState([]),[q,de]=_.useState([]),[wt,ln]=_.useState([]),[me,yn]=_.useState([]),[nt,Ie]=_.useState([]),[Tt,Se]=_.useState([]),[We,an]=_.useState([]),[fe,B]=_.useState([]),[ne,L]=_.useState([]),[je,kt]=_.useState([]),[Q,Me]=_.useState({}),[At,xs]=_.useState([]),[ys,Ha]=_.useState([]),[Ga,Qa]=_.useState([]),[Ka,Ya]=_.useState([]),[Hl,N]=_.useState([]),[ft,Tn]=_.useState({}),[De,xh]=_.useState([]),Xa=()=>({name:"",company_name:"",acronym:"",code:"",status:"Active",owner_user:"",notes:""}),[ki,Qs]=_.useState(Xa()),[Ee,xe]=_.useState(!0),[Ye,pe]=_.useState("idle"),[Xe,te]=_.useState(!1),[hc,gc]=_.useState(!1),[qa,mc]=_.useState(null),[yh,vh]=_.useState(()=>localStorage.getItem("sb_sidebar")==="1"),jh=()=>vh(m=>{const W=!m;return localStorage.setItem("sb_sidebar",W?"1":"0"),W}),[bh,Ci]=_.useState(!1),[Sh,Fe]=_.useState([]),[_h,He]=_.useState([]);_.useEffect(()=>{Ci(!1),Fe([]),He([])},[u]);const[rn,An]=_.useState(Ln()),[on,vn]=_.useState(wn()),[Pn,jn]=_.useState(kn()),[Rn,bn]=_.useState(xr()),[zi,Ks]=_.useState(sl()),[Ii,vs]=_.useState(ws()),[Ei,js]=_.useState(ks()),[Ti,bs]=_.useState(Cs()),[Ai,Ys]=_.useState(ll()),[Pi,Xs]=_.useState(al()),[Ri,qs]=_.useState(rl()),[Di,Js]=_.useState(il()),[Oi,Vs]=_.useState(ol()),[Li,Zs]=_.useState(dl()),[Wi,el]=_.useState(cl()),[Ni,tl]=_.useState(ul()),[Pt,Ja]=_.useState(yr()),[Bi,Ss]=_.useState(zs()),[$i,_s]=_.useState(Is()),[Qt,Gl]=_.useState(la()),Kt=async()=>{xe(!0);try{const[m,W,_e,ct,Yt,Ce,Nt,dn,Yl,yg,vg,jg,bg,Sg,_g,wg,kg,Cg,zg,Ig,Eg,Tg,Ag,Pg,Rg,Dg,Og]=await Promise.all([Oe(R.incidents),Oe(R.organizations),Oe(R.ideas),Oe(R.orders),Oe(R.processes),Iy(),Oe(R.managements),Oe(R.departments),Oe(R.branches),Oe(R.incidentTypes),Oe(R.incidentClass),Oe(R.incidentField),Oe(R.ideaTypes),Oe(R.orderTypes),Oe(R.processTypes),Oe(R.incidentStatuses),Oe(R.ideaStatuses),Oe(R.orderStatuses),Oe(R.processStatuses),Py(),Ry(),Oe(R.cycles),Oe(R.kpiInput),Jy(),Zy(),e0(),t0()]);T(m||[]),H(W||[]),U(_e||[]),$(ct||[]),P(Yt||[]),xs(Ce||[]),K(Nt||[]),ee(dn||[]),ce(Yl||[]),tt(yg||[]),_t(vg||[]),de(jg||[]),ln(bg||[]),yn(Sg||[]),Ie(_g||[]),Se(wg||[]),an(kg||[]),B(Cg||[]),L(zg||[]),kt(Ig||[]),Me(Eg||{}),Ha(Tg||[]),Qa(Ag||[]),Ya(Pg||[]),N(Rg||[]),Tn(Dg||{}),xh(Og||[])}catch(m){console.error("Error loading data:",m)}xe(!1)},xc=async()=>{try{const m=await fetch("/api/method/sidrah_business.api.get_notification_count",{credentials:"include",headers:{Accept:"application/json"}});if(m.ok){const W=await m.json();b(Number(W.message)||0)}}catch{}};_.useEffect(()=>{Kt(),xc();const m=setInterval(xc,6e4);return()=>clearInterval(m)},[e.name]);const[xt,Dn]=_.useState({isOpen:!1,doctype:"",name:"",title:"",isDeleting:!1}),re=(m,W,_e)=>{Dn({isOpen:!0,doctype:m,name:W,title:_e||W,isDeleting:!1})},yc=m=>{const _e={[R.incidents]:"incidents",[R.ideas]:"ideas",[R.orders]:"orders",[R.processes]:"processes",[R.organizations]:"organizations",[R.managements]:"managements",[R.departments]:"departments",[R.branches]:"branches",[R.cycles]:"cycles",[R.kpiInput]:"kpi-input",[R.incidentTypes]:"incident-types",[R.ideaTypes]:"idea-types",[R.orderTypes]:"order-types",[R.processTypes]:"process-types",[R.incidentStatuses]:"incident-statuses",[R.ideaStatuses]:"idea-statuses",[R.orderStatuses]:"order-statuses",[R.processStatuses]:"process-statuses",[R.groupCompanies]:"group-companies"}[m];_e&&v(_e)},vc=async m=>{Dn(W=>({...W,isDeleting:!0}));try{const W=xt.doctype;await hd(xt.doctype,xt.name,m,!1),Dn(_e=>({..._e,isOpen:!1,isDeleting:!1})),alert(a.rtl?"تم نقل السجل إلى المحذوفات بنجاح!":"Record moved to Deleted successfully!"),await Kt(),u.endsWith("-form")&&yc(W)}catch(W){console.error("Delete error:",W),alert((W==null?void 0:W.message)||"Delete failed. Please try again."),Dn(_e=>({..._e,isDeleting:!1}))}},jc=async m=>{Dn(W=>({...W,isDeleting:!0}));try{const W=xt.doctype;await hd(xt.doctype,xt.name,m,!0),Dn(_e=>({..._e,isOpen:!1,isDeleting:!1})),alert(a.rtl?"تم حذف السجل نهائياً بنجاح!":"Record permanently deleted successfully!"),await Kt(),u.endsWith("-form")&&yc(W)}catch(W){console.error("Permanent delete error:",W),alert((W==null?void 0:W.message)||"Permanent delete failed. Please try again."),Dn(_e=>({..._e,isDeleting:!1}))}},qe=async(m,W)=>{if(window.confirm(a.rtl?"هل أنت متأكد من استعادة هذا السجل؟":"Are you sure you want to restore this record?")){xe(!0);try{await zy(m,W),alert(a.restoredOk||"Record restored successfully!"),await Kt()}catch(_e){console.error("Restore error:",_e),alert((_e==null?void 0:_e.message)||"Restore failed. Please try again.")}xe(!1)}},wh=async m=>{try{await Wy(m),await Kt()}catch(W){console.error("Disable user error:",W)}},kh=async m=>{te(!0),xe(!0);try{const W=await Bt(R.incidents,m.name);An({...Ln(),...W})}catch{An({...Ln(),...m})}v("incidents-form"),xe(!1)},Ch=async m=>{te(!0),xe(!0);try{const W=await Bt(R.ideas,m.name);vn({...wn(),...W})}catch{vn({...wn(),...m})}v("ideas-form"),xe(!1)},zh=async m=>{te(!0),xe(!0);try{const W=await Bt(R.orders,m.name);jn({...kn(),...W})}catch{jn({...kn(),...m})}v("orders-form"),xe(!1)},Ih=async m=>{te(!0),xe(!0);try{const W=await da(m.name);bn({...W,progress_indicators:W.progress_indicators||[],cycle_logs:W.cycle_logs||[]}),v("processes-form")}catch{bn({...m,progress_indicators:m.progress_indicators||[]}),v("processes-form")}xe(!1)},Eh=m=>ke(R.organizations,m,Ks,sl(),"organizations-form",!0),Th=m=>{te(!0),Qs(m),v("group-companies-form")},Ah=m=>{te(!1),Qs(m),v("group-companies-form")},Ph=async m=>{te(!0),xe(!0);try{const W=await Bt(R.managements,m.name);vs({...ws(),...W})}catch{vs({...ws(),...m})}v("managements-form"),xe(!1)},Rh=async m=>{te(!0),xe(!0);try{const W=await Bt(R.departments,m.name);js({...ks(),...W})}catch{js({...ks(),...m})}v("departments-form"),xe(!1)},Dh=async m=>{te(!0),xe(!0);try{const W=await Bt(R.branches,m.name);bs({...Cs(),...W})}catch{bs({...Cs(),...m})}v("branches-form"),xe(!1)},Oh=async m=>{te(!0),xe(!0);try{const W=await Bt(R.cycles,m.name);Ss({...zs(),...W})}catch{Ss({...zs(),...m})}v("cycles-form"),xe(!1)},Lh=async m=>{te(!0),xe(!0);try{const W=await Bt(R.kpiInput,m.name);_s({...Is(),...W})}catch{_s({...Is(),...m})}v("kpi-input-form"),xe(!1)},rt=async(m,W,_e,ct,Yt)=>{pe("loading");try{if(W.name)await Ds(m,W.name,W),pe("success"),Kt(),setTimeout(()=>pe("idle"),1500);else{const Ce=await ni(m,W),Nt=(Ce==null?void 0:Ce.data)??Ce;Yt&&Yt(Nt),pe("success"),Kt(),setTimeout(()=>pe("idle"),1500)}}catch(Ce){console.error("Submit error:",Ce),pe(Ce instanceof Error?Ce.message:"Error saving. Please try again.")}},Ge=async()=>{await Ty(),n()},ke=async(m,W,_e,ct,Yt,Ce)=>{te(Ce),xe(!0);try{const Nt=await Bt(m,W.name);_e({...ct,...Nt})}catch{_e({...ct,...W})}v(Yt),xe(!1)},Wh=m=>ke(R.incidents,m,An,Ln(),"incidents-form",!1),Nh=m=>ke(R.ideas,m,vn,wn(),"ideas-form",!1),Bh=m=>ke(R.orders,m,jn,kn(),"orders-form",!1),$h=m=>{te(!1),xe(!0),da(m.name).then(W=>{bn({...W,progress_indicators:W.progress_indicators||[],cycle_logs:W.cycle_logs||[]})}).catch(()=>{bn({...m,progress_indicators:m.progress_indicators||[]})}).finally(()=>{v("processes-form"),xe(!1)})},Uh=m=>ke(R.organizations,m,Ks,sl(),"organizations-form",!1),Mh=m=>ke(R.managements,m,vs,ws(),"managements-form",!1),Fh=m=>ke(R.departments,m,js,ks(),"departments-form",!1),Hh=m=>ke(R.branches,m,bs,Cs(),"branches-form",!1),Gh=m=>ke(R.cycles,m,Ss,zs(),"cycles-form",!1),Qh=m=>ke(R.kpiInput,m,_s,Is(),"kpi-input-form",!1),Kh=async m=>{te(!0),xe(!0);try{const W=await Vy(m.name);Gl({...la(),...W})}catch{Gl({...la(),...m})}v("delegations-form"),xe(!1)},Yh=async()=>{pe("loading");try{const m=[];Qt.incident_initial_evaluation&&m.push("incident_initial_evaluation"),Qt.idea_initial_evaluation&&m.push("idea_initial_evaluation"),await Yy(Qt.manager,m,Qt.organization,Qt.remarks||"",Qt.incident_name||"",Qt.idea_name||""),Gl(la()),pe("success"),Kt(),setTimeout(()=>{pe("idle"),v("delegations")},1500)}catch(m){console.error("Delegation submit error:",m),pe(m instanceof Error?m.message:"Error saving. Please try again.")}},Xh=async m=>{if(window.confirm(a.rtl?"هل أنت متأكد من إلغاء هذا التفويض؟":"Are you sure you want to revoke this delegation?")){xe(!0);try{await qy(m),await Kt()}catch(W){console.error("Revoke delegation error:",W),alert(W instanceof Error?W.message:"Revoke failed. Please try again.")}xe(!1)}},qh=m=>ke(R.incidentTypes,m,Ys,ll(),"incident-types-form",!0),Jh=m=>ke(R.incidentTypes,m,Ys,ll(),"incident-types-form",!1),Vh=m=>ke(R.ideaTypes,m,Xs,al(),"idea-types-form",!0),Zh=m=>ke(R.ideaTypes,m,Xs,al(),"idea-types-form",!1),eg=m=>ke(R.orderTypes,m,qs,rl(),"order-types-form",!0),tg=m=>ke(R.orderTypes,m,qs,rl(),"order-types-form",!1),ng=m=>ke(R.processTypes,m,Js,il(),"process-types-form",!0),sg=m=>ke(R.processTypes,m,Js,il(),"process-types-form",!1),lg=m=>ke(R.incidentStatuses,m,Vs,ol(),"incident-statuses-form",!0),ag=m=>ke(R.incidentStatuses,m,Vs,ol(),"incident-statuses-form",!1),rg=m=>ke(R.ideaStatuses,m,Zs,dl(),"idea-statuses-form",!0),ig=m=>ke(R.ideaStatuses,m,Zs,dl(),"idea-statuses-form",!1),og=m=>ke(R.orderStatuses,m,el,cl(),"order-statuses-form",!0),dg=m=>ke(R.orderStatuses,m,el,cl(),"order-statuses-form",!1),cg=m=>ke(R.processStatuses,m,tl,ul(),"process-statuses-form",!0),ug=m=>ke(R.processStatuses,m,tl,ul(),"process-statuses-form",!1),pg=async m=>{mc(m),v("profile")},fg=m=>{te(!1),gc(!1),Ja({...yr(),...m}),v("users-form")},hg=async()=>{pe("loading");try{if(!Pt.name){const{new_password:W,..._e}=Pt,ct=await ni("User",{..._e,send_welcome_email:0,user_type:"System User"}),Yt=(ct==null?void 0:ct.data)??ct,Ce=(Yt==null?void 0:Yt.name)||Pt.email;if(W&&Ce)try{await si(Ce,W)}catch(Nt){console.error("Password set error:",Nt)}if(Pt.custom_category==="Admin"&&Pt.custom_group_company){const Nt=De.find(dn=>dn.name===Pt.custom_group_company);if(Nt&&!Nt.owner_user)try{await Ds("SB Group Company",Nt.name,{owner_user:Ce})}catch(dn){console.error("GC owner sync error:",dn)}}Ja({...yr(),...Pt,...(ct==null?void 0:ct.data)??ct}),te(!0),pe("success"),Kt(),setTimeout(()=>pe("idle"),1500)}else{const{name:W,email:_e,creation:ct,full_name:Yt,new_password:Ce,...Nt}=Pt;if(await Ds("User",W,Nt),Ce)try{await si(W,Ce)}catch(dn){console.error("Password set error:",dn)}if(Pt.custom_category==="Admin"&&Pt.custom_group_company){const dn=De.find(Yl=>Yl.name===Pt.custom_group_company);if(dn&&!dn.owner_user)try{await Ds("SB Group Company",dn.name,{owner_user:W})}catch(Yl){console.error("GC owner sync error:",Yl)}}pe("success"),Kt(),setTimeout(()=>pe("idle"),1500)}}catch(m){console.error("User submit error:",m),pe(m instanceof Error?m.message:"Error saving. Please try again.")}},Qe=()=>{const m=je.find(W=>W.name===e.name||W.username===e.name);mc(m||{name:e.name,full_name:e.full_name,email:e.name,enabled:1}),v("profile")},Ui=(m,W)=>{if(W){const ct={"processes-form":R.processes,"orders-form":R.orders,"incidents-form":R.incidents,"ideas-form":R.ideas}[m];if(ct){te(!0),xe(!0),(m==="processes-form"?da(W).then(Ce=>({...Ce,progress_indicators:Ce.progress_indicators||[],cycle_logs:Ce.cycle_logs||[]})):Bt(ct,W)).then(Ce=>{m==="processes-form"?bn(Ce):m==="orders-form"?jn({...kn(),...Ce}):m==="incidents-form"?An({...Ln(),...Ce}):m==="ideas-form"&&vn({...wn(),...Ce}),v(m),xe(!1)}).catch(()=>{v(m),xe(!1)});return}}v(m)},Je=m=>t.jsxs(t.Fragment,{children:[m,t.jsx(Au,{isOpen:xt.isOpen,doctype:xt.doctype,docname:xt.name,docTitle:xt.title,isAdmin:r==="Admin"||e.name==="Administrator",isDeleting:xt.isDeleting,onClose:()=>Dn(W=>({...W,isOpen:!1})),onConfirmSoftDelete:vc,onConfirmPermanentDelete:jc})]});if(u==="incidents-form")return Je(t.jsx(k0,{incForm:rn,setIncForm:An,organizations:M,groupCompanies:De,managements:F,departments:E,branches:V,incidentTypes:ie,incidentClasses:Re,incidentFields:q,incidentStatuses:Tt,users:At,userRoleMap:Q,formStatus:Ye,viewMode:Xe||!p("incidents-form")||k(rn.workflow_state),canModify:p("incidents-form"),onEdit:p("incidents-form")&&!k(rn.workflow_state)&&!ts("incident",rn.workflow_state)?()=>te(!1):void 0,onDelete:p("incidents-form")?m=>re(R.incidents,m,rn.title||rn.number):void 0,onRestore:r==="Admin"?m=>qe(R.incidents,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.incidents,m,rn.title||rn.number):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,userRole:r,delegatedFunctions:Hl,delegatedOrgs:ft,onSubmit:()=>rt(R.incidents,rn,()=>An(Ln()),"incidents",m=>An({...Ln(),...m})),onBack:()=>{v("incidents"),pe("idle")},onNavigate:v,onLogout:Ge,user:e,onRefresh:async()=>{if(rn.name){const m=await Bt(R.incidents,rn.name).catch(()=>null);m&&An({...Ln(),...m})}Oe(R.incidents).then(m=>T(m||[])).catch(()=>{})}}));if(u==="ideas-form")return Je(t.jsx(E0,{ideaForm:on,setIdeaForm:vn,organizations:M,groupCompanies:De,managements:F,departments:E,branches:V,ideaTypes:wt,ideaStatuses:We,users:At,userRoleMap:Q,formStatus:Ye,viewMode:Xe||!p("ideas-form")||k(on.workflow_state),canModify:p("ideas-form"),onEdit:p("ideas-form")&&!k(on.workflow_state)&&!ts("idea",on.workflow_state)?()=>te(!1):void 0,onDelete:p("ideas-form")?m=>re(R.ideas,m,on.title||on.number):void 0,onRestore:r==="Admin"?m=>qe(R.ideas,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.ideas,m,on.title||on.number):void 0,onNavigateToOrder:m=>ke(R.orders,{name:m},jn,kn(),"orders-form",!0),darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,userRole:r,delegatedFunctions:Hl,delegatedOrgs:ft,onSubmit:()=>rt(R.ideas,on,()=>vn(wn()),"ideas",m=>vn({...wn(),...m})),onBack:()=>{v("ideas"),pe("idle")},onNavigate:v,onLogout:Ge,user:e,onRefresh:async()=>{if(on.name){const m=await Bt(R.ideas,on.name).catch(()=>null);m&&vn({...wn(),...m})}Oe(R.ideas).then(m=>U(m||[])).catch(()=>{})}}));if(u==="orders-form")return Je(t.jsx(D0,{orderForm:Pn,setOrderForm:jn,organizations:M,groupCompanies:De,managements:F,departments:E,branches:V,orderTypes:me,orderStatuses:fe,cycles:ys,users:At,userRoleMap:Q,formStatus:Ye,viewMode:Xe||!p("orders-form"),canModify:p("orders-form"),onEdit:p("orders-form")&&!ts("order",Pn.workflow_state)?()=>te(!1):void 0,onDelete:p("orders-form")?m=>re(R.orders,m,Pn.title||Pn.number):void 0,onRestore:r==="Admin"?m=>qe(R.orders,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.orders,m,Pn.title||Pn.number):void 0,onNavigateToIdea:m=>ke(R.ideas,{name:m},vn,wn(),"ideas-form",!0),darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,currentUser:e.name,userRole:r,onSubmit:()=>rt(R.orders,Pn,()=>jn(kn()),"orders",m=>jn({...kn(),...m})),onBack:()=>{v("orders"),pe("idle")},onNavigate:v,onLogout:Ge,user:e,onRefresh:async()=>{if(Pn.name){const m=await Bt(R.orders,Pn.name).catch(()=>null);m&&jn({...kn(),...m})}Oe(R.orders).then(m=>$(m||[])).catch(()=>{})}}));if(u==="processes-form")return Je(t.jsx(B0,{processForm:Rn,setProcessForm:bn,organizations:M,groupCompanies:De,managements:F,departments:E,branches:V,processTypes:nt,processStatuses:ne,cycles:ys,users:At,userRoleMap:Q,formStatus:Ye,viewMode:Xe||!p("processes-form"),canModify:p("processes-form"),onEdit:p("processes-form")&&!ts("process",Rn.workflow_state)?()=>te(!1):void 0,onDelete:p("processes-form")?m=>re(R.processes,m,Rn.title||Rn.number):void 0,onRestore:r==="Admin"?m=>qe(R.processes,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.processes,m,Rn.title||Rn.number):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,userRole:e.role,onRefreshProcess:async()=>{if(Rn.name)try{const m=await da(Rn.name);bn({...m,progress_indicators:m.progress_indicators||[],cycle_logs:m.cycle_logs||[]})}catch{}Oe(R.processes).then(m=>P(m||[])).catch(()=>{})},onSubmit:()=>rt(R.processes,Rn,()=>bn(xr()),"processes",m=>bn({...xr(),...m,progress_indicators:m.progress_indicators||[],cycle_logs:m.cycle_logs||[]})),onBack:()=>{v("processes"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}));if(u==="organizations-form")return Je(t.jsx(G0,{orgForm:zi,setOrgForm:Ks,groupCompanies:De,formStatus:Ye,viewMode:Xe||!p("organizations-form"),onEdit:p("organizations-form")?()=>te(!1):void 0,onRestore:r==="Admin"?m=>qe(R.organizations,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.organizations,m,zi.organization_name):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,onSubmit:()=>rt(R.organizations,zi,()=>Ks(sl()),"organizations",m=>{Ks({...sl(),...m}),te(!0)}),onBack:()=>{v("organizations"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}));if(u==="managements-form")return Je(t.jsx(q0,{form:Ii,setForm:vs,organizations:M,groupCompanies:De,formStatus:Ye,viewMode:Xe||!p("managements-form"),onEdit:p("managements-form")?()=>te(!1):void 0,onRestore:r==="Admin"?m=>qe(R.managements,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.managements,m,Ii.name1):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,onSubmit:()=>rt(R.managements,Ii,()=>vs(ws()),"managements",m=>{vs({...ws(),...m}),te(!0)}),onBack:()=>{v("managements"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}));if(u==="departments-form")return Je(t.jsx(Z0,{form:Ei,setForm:js,organizations:M,groupCompanies:De,managements:F,formStatus:Ye,viewMode:Xe||!p("departments-form"),onEdit:p("departments-form")?()=>te(!1):void 0,onRestore:r==="Admin"?m=>qe(R.departments,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.departments,m,Ei.department_name):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,onSubmit:()=>rt(R.departments,Ei,()=>js(ks()),"departments",m=>{js({...ks(),...m}),te(!0)}),onBack:()=>{v("departments"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}));if(u==="branches-form")return Je(t.jsx(n1,{form:Ti,setForm:bs,organizations:M,groupCompanies:De,managements:F,departments:E,formStatus:Ye,viewMode:Xe||!p("branches-form"),onEdit:p("branches-form")?()=>te(!1):void 0,onRestore:r==="Admin"?m=>qe(R.branches,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.branches,m,Ti.branch):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,onSubmit:()=>rt(R.branches,Ti,()=>bs(Cs()),"branches",m=>{bs({...Cs(),...m}),te(!0)}),onBack:()=>{v("branches"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}));if(u==="cycles-form")return Je(t.jsx(D1,{form:Bi,setForm:Ss,organizations:M,groupCompanies:De,formStatus:Ye,viewMode:Xe||!p("cycles-form"),onEdit:p("cycles-form")?()=>te(!1):void 0,onRestore:r==="Admin"?m=>qe(R.cycles,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.cycles,m,Bi.name1):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,onSubmit:()=>rt(R.cycles,Bi,()=>Ss(zs()),"cycles",m=>{Ss({...zs(),...m}),te(!0)}),onBack:()=>{v("cycles"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}));if(u==="kpi-input-form")return Je(t.jsx(L1,{form:$i,setForm:_s,organizations:M,groupCompanies:De,formStatus:Ye,viewMode:Xe||!p("kpi-input-form"),onEdit:p("kpi-input-form")?()=>te(!1):void 0,onRestore:r==="Admin"?m=>qe(R.kpiInput,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.kpiInput,m,$i.period):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,onSubmit:()=>rt(R.kpiInput,$i,()=>_s(Is()),"kpi-input",m=>{_s({...Is(),...m}),te(!0)}),onBack:()=>{v("kpi-input"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}));if(u==="incident-types-form")return Je(t.jsx(a1,{form:Ai,setForm:Ys,formStatus:Ye,viewMode:Xe||!p("incident-types-form"),onEdit:p("incident-types-form")?()=>te(!1):void 0,onRestore:r==="Admin"?m=>qe(R.incidentTypes,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.incidentTypes,m,Ai.name1):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,onSubmit:()=>rt(R.incidentTypes,Ai,()=>Ys(ll()),"incident-types",m=>{Ys({...ll(),...m}),te(!0)}),onBack:()=>{v("incident-types"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}));if(u==="idea-types-form")return Je(t.jsx(o1,{form:Pi,setForm:Xs,formStatus:Ye,viewMode:Xe||!p("idea-types-form"),onEdit:p("idea-types-form")?()=>te(!1):void 0,onRestore:r==="Admin"?m=>qe(R.ideaTypes,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.ideaTypes,m,Pi.name1):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,onSubmit:()=>rt(R.ideaTypes,Pi,()=>Xs(al()),"idea-types",m=>{Xs({...al(),...m}),te(!0)}),onBack:()=>{v("idea-types"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}));if(u==="order-types-form")return Je(t.jsx(u1,{form:Ri,setForm:qs,formStatus:Ye,viewMode:Xe||!p("order-types-form"),onEdit:p("order-types-form")?()=>te(!1):void 0,onRestore:r==="Admin"?m=>qe(R.orderTypes,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.orderTypes,m,Ri.name1):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,onSubmit:()=>rt(R.orderTypes,Ri,()=>qs(rl()),"order-types",m=>{qs({...rl(),...m}),te(!0)}),onBack:()=>{v("order-types"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}));if(u==="process-types-form")return Je(t.jsx(h1,{form:Di,setForm:Js,formStatus:Ye,viewMode:Xe||!p("process-types-form"),onEdit:p("process-types-form")?()=>te(!1):void 0,onRestore:r==="Admin"?m=>qe(R.processTypes,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.processTypes,m,Di.name1):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,onSubmit:()=>rt(R.processTypes,Di,()=>Js(il()),"process-types",m=>{Js({...il(),...m}),te(!0)}),onBack:()=>{v("process-types"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}));if(u==="incident-statuses-form")return Je(t.jsx(x1,{form:Oi,setForm:Vs,formStatus:Ye,viewMode:Xe||!p("incident-statuses-form"),onEdit:p("incident-statuses-form")?()=>te(!1):void 0,onRestore:r==="Admin"?m=>qe(R.incidentStatuses,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.incidentStatuses,m,Oi.name1):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,onSubmit:()=>rt(R.incidentStatuses,Oi,()=>Vs(ol()),"incident-statuses",m=>{Vs({...ol(),...m}),te(!0)}),onBack:()=>{v("incident-statuses"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}));if(u==="idea-statuses-form")return Je(t.jsx(j1,{form:Li,setForm:Zs,formStatus:Ye,viewMode:Xe||!p("idea-statuses-form"),onEdit:p("idea-statuses-form")?()=>te(!1):void 0,onRestore:r==="Admin"?m=>qe(R.ideaStatuses,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.ideaStatuses,m,Li.name1):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,onSubmit:()=>rt(R.ideaStatuses,Li,()=>Zs(dl()),"idea-statuses",m=>{Zs({...dl(),...m}),te(!0)}),onBack:()=>{v("idea-statuses"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}));if(u==="order-statuses-form")return Je(t.jsx(_1,{form:Wi,setForm:el,formStatus:Ye,viewMode:Xe||!p("order-statuses-form"),onEdit:p("order-statuses-form")?()=>te(!1):void 0,onRestore:r==="Admin"?m=>qe(R.orderStatuses,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.orderStatuses,m,Wi.name1):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,onSubmit:()=>rt(R.orderStatuses,Wi,()=>el(cl()),"order-statuses",m=>{el({...cl(),...m}),te(!0)}),onBack:()=>{v("order-statuses"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}));if(u==="process-statuses-form")return Je(t.jsx(C1,{form:Ni,setForm:tl,formStatus:Ye,viewMode:Xe||!p("process-statuses-form"),onEdit:p("process-statuses-form")?()=>te(!1):void 0,onRestore:r==="Admin"?m=>qe(R.processStatuses,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.processStatuses,m,Ni.name1):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,onSubmit:()=>rt(R.processStatuses,Ni,()=>tl(ul()),"process-statuses",m=>{tl({...ul(),...m}),te(!0)}),onBack:()=>{v("process-statuses"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}));if(u==="users-form")return Je(t.jsx(T1,{form:Pt,setForm:Ja,groupCompanies:De,organizations:M,managements:F,departments:E,branches:V,users:At,formStatus:Ye,viewMode:Xe||!p("users-form"),onEdit:p("users-form")?()=>te(!1):void 0,onRestore:r==="Admin"?m=>qe(R.users,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.users,m,Pt.full_name||Pt.email):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,isSelfProfile:hc,onSubmit:hg,onBack:()=>{v(hc?i?"dashboard":"inbox":"users"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}));if(u==="delegations-form"){const m=Qt.status==="Revoked"||Qt.status==="Accepted"||Qt.status==="Rejected";return Je(t.jsx(M1,{form:Qt,setForm:Gl,organizations:M,users:At,userRoleMap:Q,incidents:A,ideas:le,formStatus:Ye,viewMode:Xe||!p("delegations-form")||m,onEdit:p("delegations-form")&&!m?()=>te(!1):void 0,onRestore:r==="Admin"?W=>qe(R.delegations,W):void 0,onPermanentDelete:r==="Admin"?W=>re(R.delegations,W,Qt.name):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,onSubmit:Yh,onBack:()=>{v("delegations"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}))}if(u==="group-companies-form")return Je(t.jsx(K0,{form:ki,setForm:Qs,users:At,formStatus:Ye,viewMode:Xe||!p("group-companies-form"),onEdit:p("group-companies-form")?()=>te(!1):void 0,onRestore:r==="Admin"?m=>qe(R.groupCompanies,m):void 0,onPermanentDelete:r==="Admin"?m=>re(R.groupCompanies,m,ki.company_name):void 0,darkMode:s,notifCount:c,onToggleDark:l,onCountChange:b,onViewProfile:Qe,onSubmit:()=>rt(R.groupCompanies,ki,()=>Qs(Xa()),"group-companies",m=>{Qs({...Xa(),...m}),te(!0)}),onBack:()=>{v("group-companies"),pe("idle")},onNavigate:v,onLogout:Ge,user:e}));const Mi={...a.pages,"group-companies":"Group Companies","group-companies-form":"Group Company Form"},gg={"group-companies":{color:X.purple,formPage:"group-companies-form",reset:()=>Qs(Xa())},incidents:{color:X.accent,formPage:"incidents-form",reset:()=>{const m=z||o;An({...Ln(),organization:m,group_company:C||g(m)})}},ideas:{color:X.teal,formPage:"ideas-form",reset:()=>{const m=z||o;vn({...wn(),organization:m,group_company:C||g(m)})}},orders:{color:X.purple,formPage:"orders-form",reset:()=>{const m=z||o;jn({...kn(),organization:m,group_company:C||g(m)})}},processes:{color:X.blue,formPage:"processes-form",reset:()=>{const m=ft.create_processes,W=z||(r==="Manager"&&m&&m.length===1?m[0]:o);bn({...xr(),organization:W,group_company:C||g(W)})}},organizations:{color:X.accent,formPage:"organizations-form",reset:()=>Ks({...sl(),group_company:C})},managements:{color:X.blue,formPage:"managements-form",reset:()=>{const m=z||o;vs({...ws(),organization:m,group_company:C||g(m)})}},departments:{color:X.teal,formPage:"departments-form",reset:()=>{const m=z||o;js({...ks(),custom_organization:m,group_company:C||g(m)})}},branches:{color:X.purple,formPage:"branches-form",reset:()=>{const m=z||o;bs({...Cs(),organization:m,group_company:C||g(m)})}},cycles:{color:X.teal,formPage:"cycles-form",reset:()=>{const m=z||o;Ss({...zs(),organization:m,group_company:C||g(m)})}},"kpi-input":{color:X.blue,formPage:"kpi-input-form",reset:()=>{const m=z||o;_s({...Is(),organization:m,group_company:C||g(m)})}},"incident-types":{color:X.red,formPage:"incident-types-form",reset:()=>Ys(ll())},"idea-types":{color:X.orange,formPage:"idea-types-form",reset:()=>Xs(al())},"order-types":{color:X.green,formPage:"order-types-form",reset:()=>qs(rl())},"process-types":{color:X.accent,formPage:"process-types-form",reset:()=>Js(il())},"incident-statuses":{color:X.red,formPage:"incident-statuses-form",reset:()=>Vs(ol())},"idea-statuses":{color:X.teal,formPage:"idea-statuses-form",reset:()=>Zs(dl())},"order-statuses":{color:X.purple,formPage:"order-statuses-form",reset:()=>el(cl())},"process-statuses":{color:X.blue,formPage:"process-statuses-form",reset:()=>tl(ul())},users:{color:X.blue,formPage:"users-form",reset:()=>{Ja({...yr(),custom_group_company:C}),gc(!1)}},delegations:{color:X.purple,formPage:"delegations-form",reset:()=>Gl(la())}},mg={"group-companies":"New Group Company",incidents:a.formTitle.newIncident,ideas:a.formTitle.newIdea,orders:a.formTitle.newOrder,processes:a.formTitle.newProcess,organizations:a.formTitle.newOrg,managements:a.formTitle.newMgmt,departments:a.formTitle.newDept,branches:a.formTitle.newBranch,users:a.formTitle.newUser,cycles:a.formTitle.newCycle,"kpi-input":a.formTitle.newKpi,delegations:a.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"},xg={incidents:A,ideas:le,orders:G,processes:I,organizations:M,managements:F,departments:E,branches:V,cycles:ys,"kpi-input":Ga,"incident-types":ie,"idea-types":wt,"order-types":me,"process-types":nt,"incident-statuses":Tt,"idea-statuses":We,"order-statuses":fe,"process-statuses":ne,users:je,delegations:Ka},Ql=uy[u],Kl=xg[u],Z=p(u),Fi=Z?gg[u]:null;return t.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:s?"#0f172a":X.bg},children:[t.jsx(uh,{collapsed:yh,onToggleCollapsed:jh,activePage:u,onNavigate:m=>v(m),hasDashboard:i,hasReports:d,hasDelegations:f,role:r,rtl:a.rtl,navLabels:a.nav,settingsLabel:a.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(hh,{notifCount:c,darkMode:s,onCountChange:b,onToggleDark:l,onNavigate:Ui,onViewProfile:Qe,onLogout:Ge,userName:e.full_name||e.name,userRole:r})}),u!=="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:Mi[u]||u}),Kl&&t.jsxs("div",{style:{fontSize:12,color:"#64748b",marginTop:2,fontWeight:500},children:["Total: ",Kl.length," ",Mi[u]?Mi[u].toLowerCase():"records"]})]}),t.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[Ql&&Kl&&t.jsx("button",{onClick:()=>Ci(!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"}),Fi&&t.jsxs("button",{onClick:()=>{Fi.reset(),te(!1),pe("idle"),v(Fi.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:["+ ",mg[u]||a.new]})]})]}),Ql&&Kl&&bh&&t.jsx(wy,{title:Ql.label,rows:Kl,selectedRows:Sh,pageRows:_h,columns:Ql.columns,defaultColumnKeys:Ql.defaultColumns,filenameBase:u,onClose:()=>Ci(!1)}),t.jsxs("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",padding:u==="profile"?0:"20px 24px",gap:u==="profile"?0:16},children:[Ee&&t.jsx("div",{style:{textAlign:"center",paddingTop:60,color:"#aaa",fontSize:15},children:a.loading}),!Ee&&u==="dashboard"&&i&&t.jsx(g0,{incidents:A,ideas:le,orders:G,processes:I,organizations:M,incidentStatuses:Tt,ideaStatuses:We,orderStatuses:fe,processStatuses:ne,selectedOrg:o,onOrgChange:h,onNavigate:Ui,onNavigateStatus:w,userRole:r}),!Ee&&u==="inbox"&&t.jsx(Q1,{onNavigate:Ui,onRefresh:Kt}),!Ee&&u==="reports"&&d&&t.jsx(V1,{organizations:M,userRole:r}),!Ee&&u==="incidents"&&t.jsx(m0,{incidents:A,organizations:M,departments:E,branches:V,incidentStatuses:Tt,initialOrg:o,initialStatus:x,onView:kh,onEdit:Z?Wh:void 0,onDelete:Z?m=>re(R.incidents,m):void 0,canModify:Z,userRole:r,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="ideas"&&t.jsx(C0,{ideas:le,organizations:M,departments:E,branches:V,ideaStatuses:We,initialOrg:o,initialStatus:x,onView:Ch,onEdit:Z?Nh:void 0,onDelete:Z?m=>re(R.ideas,m):void 0,canModify:Z,userRole:r,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="orders"&&t.jsx(T0,{orders:G,organizations:M,departments:E,branches:V,orderStatuses:fe,initialOrg:o,initialStatus:x,onView:zh,onEdit:Z?Bh:void 0,onDelete:Z?m=>re(R.orders,m):void 0,canModify:Z,userRole:r,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="processes"&&t.jsx(O0,{processes:I,organizations:M,departments:E,branches:V,processStatuses:ne,initialOrg:o,initialStatus:x,onView:Ih,onEdit:Z?$h:void 0,onDelete:Z?m=>re(R.processes,m):void 0,canModify:Z,userRole:r,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="organizations"&&t.jsx(H0,{organizations:M,onView:Eh,onEdit:Z?Uh:void 0,onDelete:Z?m=>re(R.organizations,m):void 0,canModify:Z,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="group-companies"&&t.jsx(Q0,{groupCompanies:De,onView:Th,onEdit:Z?Ah:void 0,onDelete:Z?m=>re(R.groupCompanies,m):void 0,canModify:Z,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="managements"&&t.jsx(X0,{managements:F,onView:Ph,onEdit:Z?Mh:void 0,onDelete:Z?m=>re(R.managements,m):void 0,canModify:Z,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="departments"&&t.jsx(V0,{departments:E,managements:F,onView:Rh,onEdit:Z?Fh:void 0,onDelete:Z?m=>re(R.departments,m):void 0,canModify:Z,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="branches"&&t.jsx(t1,{branches:V,managements:F,departments:E,onView:Dh,onEdit:Z?Hh:void 0,onDelete:Z?m=>re(R.branches,m):void 0,canModify:Z,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="cycles"&&t.jsx(A1,{cycles:ys,canModify:Z,onView:Oh,onEdit:Z?Gh:void 0,onDelete:Z?m=>re(R.cycles,m):void 0,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="kpi-input"&&t.jsx(O1,{kpiInputs:Ga,canModify:Z,onView:Lh,onEdit:Z?Qh:void 0,onDelete:Z?m=>re(R.kpiInput,m):void 0,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="incident-types"&&t.jsx(l1,{incidentTypes:ie,onView:qh,onEdit:Z?Jh:void 0,onDelete:Z?m=>re(R.incidentTypes,m):void 0,canModify:Z,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="idea-types"&&t.jsx(i1,{ideaTypes:wt,onView:Vh,onEdit:Z?Zh:void 0,onDelete:Z?m=>re(R.ideaTypes,m):void 0,canModify:Z,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="order-types"&&t.jsx(c1,{orderTypes:me,onView:eg,onEdit:Z?tg:void 0,onDelete:Z?m=>re(R.orderTypes,m):void 0,canModify:Z,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="process-types"&&t.jsx(f1,{processTypes:nt,onView:ng,onEdit:Z?sg:void 0,onDelete:Z?m=>re(R.processTypes,m):void 0,canModify:Z,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="incident-statuses"&&t.jsx(m1,{incidentStatuses:Tt,onView:lg,onEdit:Z?ag:void 0,onDelete:Z?m=>re(R.incidentStatuses,m):void 0,canModify:Z,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="idea-statuses"&&t.jsx(v1,{ideaStatuses:We,onView:rg,onEdit:Z?ig:void 0,onDelete:Z?m=>re(R.ideaStatuses,m):void 0,canModify:Z,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="order-statuses"&&t.jsx(S1,{orderStatuses:fe,onView:og,onEdit:Z?dg:void 0,onDelete:Z?m=>re(R.orderStatuses,m):void 0,canModify:Z,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="process-statuses"&&t.jsx(k1,{processStatuses:ne,onView:cg,onEdit:Z?ug:void 0,onDelete:Z?m=>re(R.processStatuses,m):void 0,canModify:Z,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="users"&&t.jsx(E1,{users:je,roleMap:Q,onView:pg,onEdit:Z?fg:void 0,onDelete:Z?m=>re("User",m):void 0,onDisable:Z?wh:void 0,canModify:Z,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Ee&&u==="delegations"&&f&&t.jsx($1,{delegations:Ka,organizations:M,userRole:r,currentUser:e.name,onView:Kh,onRevoke:Z?Xh:void 0,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),u==="profile"&&(()=>{const m=!!qa&&(qa.name===e.name||qa.email===e.name);return t.jsx(U0,{user:e,profileUser:qa,sbUsers:je,organizations:M,groupCompanies:De,managements:F,departments:E,branches:V,darkMode:s,canModify:Z||m,onBack:()=>v(m?i?"dashboard":"inbox":"users"),onNavigate:v})})()]})]}),t.jsx(Au,{isOpen:xt.isOpen,doctype:xt.doctype,docname:xt.name,docTitle:xt.title,isAdmin:r==="Admin"||e.name==="Administrator",isDeleting:xt.isDeleting,onClose:()=>Dn(m=>({...m,isOpen:!1})),onConfirmSoftDelete:vc,onConfirmPermanentDelete:jc})]})}function iv(e){return e.some(n=>["CEO","Ceo","SB CEO"].includes(n))?"CEO":e.some(n=>["SB Admin","System Manager"].includes(n))?"Admin":e.includes("SB Manager")?"Manager":e.includes("SB Auditor")?"Auditor":e.includes("SB Owner")?"Owner":e.includes("SB X-Auditor")?"XAuditor":"Employee"}function ov(){const[e,n]=_.useState(()=>{try{const d=localStorage.getItem("sidrah_user");return d?JSON.parse(d):null}catch{return null}}),[s,l]=_.useState(()=>localStorage.getItem("sb_dark")==="1"),a=()=>{const d=!s;l(d),localStorage.setItem("sb_dark",d?"1":"0"),document.documentElement.classList.toggle("dark",d)};_.useEffect(()=>{document.documentElement.classList.toggle("dark",s)},[]),_.useEffect(()=>{e&&ph().then(async d=>{const f=d||e.name,p=await fh(f);if(!p.length)return;const k=iv(p),j=await Uy();if(k!==e.role||f!==e.name||j!==(e.custom_organization||"")){const u={...e,name:f,role:k,custom_organization:j};n(u),localStorage.setItem("sidrah_user",JSON.stringify(u))}})},[e==null?void 0:e.name]);const r=d=>{n(d),localStorage.setItem("sidrah_user",JSON.stringify(d))},i=()=>{n(null),localStorage.removeItem("sidrah_user")};return e?t.jsx(rv,{user:e,onLogout:i,darkMode:s,onToggleDark:a}):t.jsx(o0,{onLogin:r})}lh(document.getElementById("root")).render(t.jsx(_.StrictMode,{children:t.jsx(ov,{})}));
|