Dealer_Onboarding_Backend/build/assets/index-KxZzWQFD.js

789 lines
1.9 MiB
Raw Blame History

This file contains invisible Unicode characters

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

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

var m4=Object.defineProperty;var f4=(t,s,n)=>s in t?m4(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var Yx=(t,s,n)=>f4(t,typeof s!="symbol"?s+"":s,n);function p4(t,s){for(var n=0;n<s.length;n++){const r=s[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in t)){const i=Object.getOwnPropertyDescriptor(r,a);i&&Object.defineProperty(t,a,i.get?i:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=n(a);fetch(a.href,i)}})();var Wo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function wf(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Zx={exports:{}},Xd={},Qx={exports:{}},tn={};/**
* @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 pw;function x4(){if(pw)return tn;pw=1;var t=Symbol.for("react.element"),s=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),o=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),h=Symbol.iterator;function x(T){return T===null||typeof T!="object"?null:(T=h&&T[h]||T["@@iterator"],typeof T=="function"?T:null)}var u={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,v={};function w(T,I,B){this.props=T,this.context=I,this.refs=v,this.updater=B||u}w.prototype.isReactComponent={},w.prototype.setState=function(T,I){if(typeof T!="object"&&typeof T!="function"&&T!=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,T,I,"setState")},w.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function j(){}j.prototype=w.prototype;function b(T,I,B){this.props=T,this.context=I,this.refs=v,this.updater=B||u}var C=b.prototype=new j;C.constructor=b,N(C,w.prototype),C.isPureReactComponent=!0;var S=Array.isArray,R=Object.prototype.hasOwnProperty,_={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function E(T,I,B){var G,K={},H=null,X=null;if(I!=null)for(G in I.ref!==void 0&&(X=I.ref),I.key!==void 0&&(H=""+I.key),I)R.call(I,G)&&!A.hasOwnProperty(G)&&(K[G]=I[G]);var J=arguments.length-2;if(J===1)K.children=B;else if(1<J){for(var ae=Array(J),le=0;le<J;le++)ae[le]=arguments[le+2];K.children=ae}if(T&&T.defaultProps)for(G in J=T.defaultProps,J)K[G]===void 0&&(K[G]=J[G]);return{$$typeof:t,type:T,key:H,ref:X,props:K,_owner:_.current}}function q(T,I){return{$$typeof:t,type:T.type,key:I,ref:T.ref,props:T.props,_owner:T._owner}}function O(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function D(T){var I={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(B){return I[B]})}var P=/\/+/g;function L(T,I){return typeof T=="object"&&T!==null&&T.key!=null?D(""+T.key):I.toString(36)}function $(T,I,B,G,K){var H=typeof T;(H==="undefined"||H==="boolean")&&(T=null);var X=!1;if(T===null)X=!0;else switch(H){case"string":case"number":X=!0;break;case"object":switch(T.$$typeof){case t:case s:X=!0}}if(X)return X=T,K=K(X),T=G===""?"."+L(X,0):G,S(K)?(B="",T!=null&&(B=T.replace(P,"$&/")+"/"),$(K,I,B,"",function(le){return le})):K!=null&&(O(K)&&(K=q(K,B+(!K.key||X&&X.key===K.key?"":(""+K.key).replace(P,"$&/")+"/")+T)),I.push(K)),1;if(X=0,G=G===""?".":G+":",S(T))for(var J=0;J<T.length;J++){H=T[J];var ae=G+L(H,J);X+=$(H,I,B,ae,K)}else if(ae=x(T),typeof ae=="function")for(T=ae.call(T),J=0;!(H=T.next()).done;)H=H.value,ae=G+L(H,J++),X+=$(H,I,B,ae,K);else if(H==="object")throw I=String(T),Error("Objects are not valid as a React child (found: "+(I==="[object Object]"?"object with keys {"+Object.keys(T).join(", ")+"}":I)+"). If you meant to render a collection of children, use an array instead.");return X}function Y(T,I,B){if(T==null)return T;var G=[],K=0;return $(T,G,"","",function(H){return I.call(B,H,K++)}),G}function Z(T){if(T._status===-1){var I=T._result;I=I(),I.then(function(B){(T._status===0||T._status===-1)&&(T._status=1,T._result=B)},function(B){(T._status===0||T._status===-1)&&(T._status=2,T._result=B)}),T._status===-1&&(T._status=0,T._result=I)}if(T._status===1)return T._result.default;throw T._result}var W={current:null},U={transition:null},M={ReactCurrentDispatcher:W,ReactCurrentBatchConfig:U,ReactCurrentOwner:_};function z(){throw Error("act(...) is not supported in production builds of React.")}return tn.Children={map:Y,forEach:function(T,I,B){Y(T,function(){I.apply(this,arguments)},B)},count:function(T){var I=0;return Y(T,function(){I++}),I},toArray:function(T){return Y(T,function(I){return I})||[]},only:function(T){if(!O(T))throw Error("React.Children.only expected to receive a single React element child.");return T}},tn.Component=w,tn.Fragment=n,tn.Profiler=a,tn.PureComponent=b,tn.StrictMode=r,tn.Suspense=m,tn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=M,tn.act=z,tn.cloneElement=function(T,I,B){if(T==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+T+".");var G=N({},T.props),K=T.key,H=T.ref,X=T._owner;if(I!=null){if(I.ref!==void 0&&(H=I.ref,X=_.current),I.key!==void 0&&(K=""+I.key),T.type&&T.type.defaultProps)var J=T.type.defaultProps;for(ae in I)R.call(I,ae)&&!A.hasOwnProperty(ae)&&(G[ae]=I[ae]===void 0&&J!==void 0?J[ae]:I[ae])}var ae=arguments.length-2;if(ae===1)G.children=B;else if(1<ae){J=Array(ae);for(var le=0;le<ae;le++)J[le]=arguments[le+2];G.children=J}return{$$typeof:t,type:T.type,key:K,ref:H,props:G,_owner:X}},tn.createContext=function(T){return T={$$typeof:o,_currentValue:T,_currentValue2:T,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},T.Provider={$$typeof:i,_context:T},T.Consumer=T},tn.createElement=E,tn.createFactory=function(T){var I=E.bind(null,T);return I.type=T,I},tn.createRef=function(){return{current:null}},tn.forwardRef=function(T){return{$$typeof:d,render:T}},tn.isValidElement=O,tn.lazy=function(T){return{$$typeof:p,_payload:{_status:-1,_result:T},_init:Z}},tn.memo=function(T,I){return{$$typeof:f,type:T,compare:I===void 0?null:I}},tn.startTransition=function(T){var I=U.transition;U.transition={};try{T()}finally{U.transition=I}},tn.unstable_act=z,tn.useCallback=function(T,I){return W.current.useCallback(T,I)},tn.useContext=function(T){return W.current.useContext(T)},tn.useDebugValue=function(){},tn.useDeferredValue=function(T){return W.current.useDeferredValue(T)},tn.useEffect=function(T,I){return W.current.useEffect(T,I)},tn.useId=function(){return W.current.useId()},tn.useImperativeHandle=function(T,I,B){return W.current.useImperativeHandle(T,I,B)},tn.useInsertionEffect=function(T,I){return W.current.useInsertionEffect(T,I)},tn.useLayoutEffect=function(T,I){return W.current.useLayoutEffect(T,I)},tn.useMemo=function(T,I){return W.current.useMemo(T,I)},tn.useReducer=function(T,I,B){return W.current.useReducer(T,I,B)},tn.useRef=function(T){return W.current.useRef(T)},tn.useState=function(T){return W.current.useState(T)},tn.useSyncExternalStore=function(T,I,B){return W.current.useSyncExternalStore(T,I,B)},tn.useTransition=function(){return W.current.useTransition()},tn.version="18.3.1",tn}var xw;function pd(){return xw||(xw=1,Qx.exports=x4()),Qx.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 gw;function g4(){if(gw)return Xd;gw=1;var t=pd(),s=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(d,m,f){var p,h={},x=null,u=null;f!==void 0&&(x=""+f),m.key!==void 0&&(x=""+m.key),m.ref!==void 0&&(u=m.ref);for(p in m)r.call(m,p)&&!i.hasOwnProperty(p)&&(h[p]=m[p]);if(d&&d.defaultProps)for(p in m=d.defaultProps,m)h[p]===void 0&&(h[p]=m[p]);return{$$typeof:s,type:d,key:x,ref:u,props:h,_owner:a.current}}return Xd.Fragment=n,Xd.jsx=o,Xd.jsxs=o,Xd}var vw;function v4(){return vw||(vw=1,Zx.exports=g4()),Zx.exports}var e=v4(),g=pd();const wt=wf(g),Sf=p4({__proto__:null,default:wt},[g]);var rm={},Xx={exports:{}},ca={},Jx={exports:{}},eg={};/**
* @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.
*/var yw;function y4(){return yw||(yw=1,(function(t){function s(U,M){var z=U.length;U.push(M);e:for(;0<z;){var T=z-1>>>1,I=U[T];if(0<a(I,M))U[T]=M,U[z]=I,z=T;else break e}}function n(U){return U.length===0?null:U[0]}function r(U){if(U.length===0)return null;var M=U[0],z=U.pop();if(z!==M){U[0]=z;e:for(var T=0,I=U.length,B=I>>>1;T<B;){var G=2*(T+1)-1,K=U[G],H=G+1,X=U[H];if(0>a(K,z))H<I&&0>a(X,K)?(U[T]=X,U[H]=z,T=H):(U[T]=K,U[G]=z,T=G);else if(H<I&&0>a(X,z))U[T]=X,U[H]=z,T=H;else break e}}return M}function a(U,M){var z=U.sortIndex-M.sortIndex;return z!==0?z:U.id-M.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,d=o.now();t.unstable_now=function(){return o.now()-d}}var m=[],f=[],p=1,h=null,x=3,u=!1,N=!1,v=!1,w=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(U){for(var M=n(f);M!==null;){if(M.callback===null)r(f);else if(M.startTime<=U)r(f),M.sortIndex=M.expirationTime,s(m,M);else break;M=n(f)}}function S(U){if(v=!1,C(U),!N)if(n(m)!==null)N=!0,Z(R);else{var M=n(f);M!==null&&W(S,M.startTime-U)}}function R(U,M){N=!1,v&&(v=!1,j(E),E=-1),u=!0;var z=x;try{for(C(M),h=n(m);h!==null&&(!(h.expirationTime>M)||U&&!D());){var T=h.callback;if(typeof T=="function"){h.callback=null,x=h.priorityLevel;var I=T(h.expirationTime<=M);M=t.unstable_now(),typeof I=="function"?h.callback=I:h===n(m)&&r(m),C(M)}else r(m);h=n(m)}if(h!==null)var B=!0;else{var G=n(f);G!==null&&W(S,G.startTime-M),B=!1}return B}finally{h=null,x=z,u=!1}}var _=!1,A=null,E=-1,q=5,O=-1;function D(){return!(t.unstable_now()-O<q)}function P(){if(A!==null){var U=t.unstable_now();O=U;var M=!0;try{M=A(!0,U)}finally{M?L():(_=!1,A=null)}}else _=!1}var L;if(typeof b=="function")L=function(){b(P)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,Y=$.port2;$.port1.onmessage=P,L=function(){Y.postMessage(null)}}else L=function(){w(P,0)};function Z(U){A=U,_||(_=!0,L())}function W(U,M){E=w(function(){U(t.unstable_now())},M)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(U){U.callback=null},t.unstable_continueExecution=function(){N||u||(N=!0,Z(R))},t.unstable_forceFrameRate=function(U){0>U||125<U?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):q=0<U?Math.floor(1e3/U):5},t.unstable_getCurrentPriorityLevel=function(){return x},t.unstable_getFirstCallbackNode=function(){return n(m)},t.unstable_next=function(U){switch(x){case 1:case 2:case 3:var M=3;break;default:M=x}var z=x;x=M;try{return U()}finally{x=z}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(U,M){switch(U){case 1:case 2:case 3:case 4:case 5:break;default:U=3}var z=x;x=U;try{return M()}finally{x=z}},t.unstable_scheduleCallback=function(U,M,z){var T=t.unstable_now();switch(typeof z=="object"&&z!==null?(z=z.delay,z=typeof z=="number"&&0<z?T+z:T):z=T,U){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=z+I,U={id:p++,callback:M,priorityLevel:U,startTime:z,expirationTime:I,sortIndex:-1},z>T?(U.sortIndex=z,s(f,U),n(m)===null&&U===n(f)&&(v?(j(E),E=-1):v=!0,W(S,z-T))):(U.sortIndex=I,s(m,U),N||u||(N=!0,Z(R))),U},t.unstable_shouldYield=D,t.unstable_wrapCallback=function(U){var M=x;return function(){var z=x;x=M;try{return U.apply(this,arguments)}finally{x=z}}}})(eg)),eg}var bw;function b4(){return bw||(bw=1,Jx.exports=y4()),Jx.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 jw;function j4(){if(jw)return ca;jw=1;var t=pd(),s=b4();function n(l){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+l,y=1;y<arguments.length;y++)c+="&args[]="+encodeURIComponent(arguments[y]);return"Minified React error #"+l+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,a={};function i(l,c){o(l,c),o(l+"Capture",c)}function o(l,c){for(a[l]=c,l=0;l<c.length;l++)r.add(c[l])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,f=/^[: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]*$/,p={},h={};function x(l){return m.call(h,l)?!0:m.call(p,l)?!1:f.test(l)?h[l]=!0:(p[l]=!0,!1)}function u(l,c,y,k){if(y!==null&&y.type===0)return!1;switch(typeof c){case"function":case"symbol":return!0;case"boolean":return k?!1:y!==null?!y.acceptsBooleans:(l=l.toLowerCase().slice(0,5),l!=="data-"&&l!=="aria-");default:return!1}}function N(l,c,y,k){if(c===null||typeof c>"u"||u(l,c,y,k))return!0;if(k)return!1;if(y!==null)switch(y.type){case 3:return!c;case 4:return c===!1;case 5:return isNaN(c);case 6:return isNaN(c)||1>c}return!1}function v(l,c,y,k,F,V,ie){this.acceptsBooleans=c===2||c===3||c===4,this.attributeName=k,this.attributeNamespace=F,this.mustUseProperty=y,this.propertyName=l,this.type=c,this.sanitizeURL=V,this.removeEmptyString=ie}var w={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){w[l]=new v(l,0,!1,l,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var c=l[0];w[c]=new v(c,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){w[l]=new v(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){w[l]=new v(l,2,!1,l,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(l){w[l]=new v(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){w[l]=new v(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){w[l]=new v(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){w[l]=new v(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){w[l]=new v(l,5,!1,l.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function b(l){return l[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(l){var c=l.replace(j,b);w[c]=new v(c,1,!1,l,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(l){var c=l.replace(j,b);w[c]=new v(c,1,!1,l,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(l){var c=l.replace(j,b);w[c]=new v(c,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){w[l]=new v(l,1,!1,l.toLowerCase(),null,!1,!1)}),w.xlinkHref=new v("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){w[l]=new v(l,1,!1,l.toLowerCase(),null,!0,!0)});function C(l,c,y,k){var F=w.hasOwnProperty(c)?w[c]:null;(F!==null?F.type!==0:k||!(2<c.length)||c[0]!=="o"&&c[0]!=="O"||c[1]!=="n"&&c[1]!=="N")&&(N(c,y,F,k)&&(y=null),k||F===null?x(c)&&(y===null?l.removeAttribute(c):l.setAttribute(c,""+y)):F.mustUseProperty?l[F.propertyName]=y===null?F.type===3?!1:"":y:(c=F.attributeName,k=F.attributeNamespace,y===null?l.removeAttribute(c):(F=F.type,y=F===3||F===4&&y===!0?"":""+y,k?l.setAttributeNS(k,c,y):l.setAttribute(c,y))))}var S=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,R=Symbol.for("react.element"),_=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),q=Symbol.for("react.profiler"),O=Symbol.for("react.provider"),D=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),Z=Symbol.for("react.lazy"),W=Symbol.for("react.offscreen"),U=Symbol.iterator;function M(l){return l===null||typeof l!="object"?null:(l=U&&l[U]||l["@@iterator"],typeof l=="function"?l:null)}var z=Object.assign,T;function I(l){if(T===void 0)try{throw Error()}catch(y){var c=y.stack.trim().match(/\n( *(at )?)/);T=c&&c[1]||""}return`
`+T+l}var B=!1;function G(l,c){if(!l||B)return"";B=!0;var y=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(c)if(c=function(){throw Error()},Object.defineProperty(c.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(c,[])}catch(Ze){var k=Ze}Reflect.construct(l,[],c)}else{try{c.call()}catch(Ze){k=Ze}l.call(c.prototype)}else{try{throw Error()}catch(Ze){k=Ze}l()}}catch(Ze){if(Ze&&k&&typeof Ze.stack=="string"){for(var F=Ze.stack.split(`
`),V=k.stack.split(`
`),ie=F.length-1,Ne=V.length-1;1<=ie&&0<=Ne&&F[ie]!==V[Ne];)Ne--;for(;1<=ie&&0<=Ne;ie--,Ne--)if(F[ie]!==V[Ne]){if(ie!==1||Ne!==1)do if(ie--,Ne--,0>Ne||F[ie]!==V[Ne]){var Re=`
`+F[ie].replace(" at new "," at ");return l.displayName&&Re.includes("<anonymous>")&&(Re=Re.replace("<anonymous>",l.displayName)),Re}while(1<=ie&&0<=Ne);break}}}finally{B=!1,Error.prepareStackTrace=y}return(l=l?l.displayName||l.name:"")?I(l):""}function K(l){switch(l.tag){case 5:return I(l.type);case 16:return I("Lazy");case 13:return I("Suspense");case 19:return I("SuspenseList");case 0:case 2:case 15:return l=G(l.type,!1),l;case 11:return l=G(l.type.render,!1),l;case 1:return l=G(l.type,!0),l;default:return""}}function H(l){if(l==null)return null;if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case A:return"Fragment";case _:return"Portal";case q:return"Profiler";case E:return"StrictMode";case L:return"Suspense";case $:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case D:return(l.displayName||"Context")+".Consumer";case O:return(l._context.displayName||"Context")+".Provider";case P:var c=l.render;return l=l.displayName,l||(l=c.displayName||c.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case Y:return c=l.displayName||null,c!==null?c:H(l.type)||"Memo";case Z:c=l._payload,l=l._init;try{return H(l(c))}catch{}}return null}function X(l){var c=l.type;switch(l.tag){case 24:return"Cache";case 9:return(c.displayName||"Context")+".Consumer";case 10:return(c._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return l=c.render,l=l.displayName||l.name||"",c.displayName||(l!==""?"ForwardRef("+l+")":"ForwardRef");case 7:return"Fragment";case 5:return c;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return H(c);case 8:return c===E?"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 c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c}return null}function J(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function ae(l){var c=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function le(l){var c=ae(l)?"checked":"value",y=Object.getOwnPropertyDescriptor(l.constructor.prototype,c),k=""+l[c];if(!l.hasOwnProperty(c)&&typeof y<"u"&&typeof y.get=="function"&&typeof y.set=="function"){var F=y.get,V=y.set;return Object.defineProperty(l,c,{configurable:!0,get:function(){return F.call(this)},set:function(ie){k=""+ie,V.call(this,ie)}}),Object.defineProperty(l,c,{enumerable:y.enumerable}),{getValue:function(){return k},setValue:function(ie){k=""+ie},stopTracking:function(){l._valueTracker=null,delete l[c]}}}}function xe(l){l._valueTracker||(l._valueTracker=le(l))}function ce(l){if(!l)return!1;var c=l._valueTracker;if(!c)return!0;var y=c.getValue(),k="";return l&&(k=ae(l)?l.checked?"true":"false":l.value),l=k,l!==y?(c.setValue(l),!0):!1}function ve(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch{return l.body}}function Pe(l,c){var y=c.checked;return z({},c,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:y??l._wrapperState.initialChecked})}function et(l,c){var y=c.defaultValue==null?"":c.defaultValue,k=c.checked!=null?c.checked:c.defaultChecked;y=J(c.value!=null?c.value:y),l._wrapperState={initialChecked:k,initialValue:y,controlled:c.type==="checkbox"||c.type==="radio"?c.checked!=null:c.value!=null}}function kt(l,c){c=c.checked,c!=null&&C(l,"checked",c,!1)}function vt(l,c){kt(l,c);var y=J(c.value),k=c.type;if(y!=null)k==="number"?(y===0&&l.value===""||l.value!=y)&&(l.value=""+y):l.value!==""+y&&(l.value=""+y);else if(k==="submit"||k==="reset"){l.removeAttribute("value");return}c.hasOwnProperty("value")?ge(l,c.type,y):c.hasOwnProperty("defaultValue")&&ge(l,c.type,J(c.defaultValue)),c.checked==null&&c.defaultChecked!=null&&(l.defaultChecked=!!c.defaultChecked)}function ee(l,c,y){if(c.hasOwnProperty("value")||c.hasOwnProperty("defaultValue")){var k=c.type;if(!(k!=="submit"&&k!=="reset"||c.value!==void 0&&c.value!==null))return;c=""+l._wrapperState.initialValue,y||c===l.value||(l.value=c),l.defaultValue=c}y=l.name,y!==""&&(l.name=""),l.defaultChecked=!!l._wrapperState.initialChecked,y!==""&&(l.name=y)}function ge(l,c,y){(c!=="number"||ve(l.ownerDocument)!==l)&&(y==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+y&&(l.defaultValue=""+y))}var ye=Array.isArray;function Be(l,c,y,k){if(l=l.options,c){c={};for(var F=0;F<y.length;F++)c["$"+y[F]]=!0;for(y=0;y<l.length;y++)F=c.hasOwnProperty("$"+l[y].value),l[y].selected!==F&&(l[y].selected=F),F&&k&&(l[y].defaultSelected=!0)}else{for(y=""+J(y),c=null,F=0;F<l.length;F++){if(l[F].value===y){l[F].selected=!0,k&&(l[F].defaultSelected=!0);return}c!==null||l[F].disabled||(c=l[F])}c!==null&&(c.selected=!0)}}function $e(l,c){if(c.dangerouslySetInnerHTML!=null)throw Error(n(91));return z({},c,{value:void 0,defaultValue:void 0,children:""+l._wrapperState.initialValue})}function dt(l,c){var y=c.value;if(y==null){if(y=c.children,c=c.defaultValue,y!=null){if(c!=null)throw Error(n(92));if(ye(y)){if(1<y.length)throw Error(n(93));y=y[0]}c=y}c==null&&(c=""),y=c}l._wrapperState={initialValue:J(y)}}function st(l,c){var y=J(c.value),k=J(c.defaultValue);y!=null&&(y=""+y,y!==l.value&&(l.value=y),c.defaultValue==null&&l.defaultValue!==y&&(l.defaultValue=y)),k!=null&&(l.defaultValue=""+k)}function xt(l){var c=l.textContent;c===l._wrapperState.initialValue&&c!==""&&c!==null&&(l.value=c)}function Mt(l){switch(l){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 It(l,c){return l==null||l==="http://www.w3.org/1999/xhtml"?Mt(c):l==="http://www.w3.org/2000/svg"&&c==="foreignObject"?"http://www.w3.org/1999/xhtml":l}var he,pt=(function(l){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(c,y,k,F){MSApp.execUnsafeLocalFunction(function(){return l(c,y,k,F)})}:l})(function(l,c){if(l.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in l)l.innerHTML=c;else{for(he=he||document.createElement("div"),he.innerHTML="<svg>"+c.valueOf().toString()+"</svg>",c=he.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;c.firstChild;)l.appendChild(c.firstChild)}});function ht(l,c){if(c){var y=l.firstChild;if(y&&y===l.lastChild&&y.nodeType===3){y.nodeValue=c;return}}l.textContent=c}var _e={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},Vt=["Webkit","ms","Moz","O"];Object.keys(_e).forEach(function(l){Vt.forEach(function(c){c=c+l.charAt(0).toUpperCase()+l.substring(1),_e[c]=_e[l]})});function Pt(l,c,y){return c==null||typeof c=="boolean"||c===""?"":y||typeof c!="number"||c===0||_e.hasOwnProperty(l)&&_e[l]?(""+c).trim():c+"px"}function _s(l,c){l=l.style;for(var y in c)if(c.hasOwnProperty(y)){var k=y.indexOf("--")===0,F=Pt(y,c[y],k);y==="float"&&(y="cssFloat"),k?l.setProperty(y,F):l[y]=F}}var Ys=z({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 Bs(l,c){if(c){if(Ys[l]&&(c.children!=null||c.dangerouslySetInnerHTML!=null))throw Error(n(137,l));if(c.dangerouslySetInnerHTML!=null){if(c.children!=null)throw Error(n(60));if(typeof c.dangerouslySetInnerHTML!="object"||!("__html"in c.dangerouslySetInnerHTML))throw Error(n(61))}if(c.style!=null&&typeof c.style!="object")throw Error(n(62))}}function Ks(l,c){if(l.indexOf("-")===-1)return typeof c.is=="string";switch(l){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 Qs=null;function Xs(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var $s=null,Q=null,oe=null;function we(l){if(l=Md(l)){if(typeof $s!="function")throw Error(n(280));var c=l.stateNode;c&&(c=yh(c),$s(l.stateNode,l.type,c))}}function Oe(l){Q?oe?oe.push(l):oe=[l]:Q=l}function ke(){if(Q){var l=Q,c=oe;if(oe=Q=null,we(l),c)for(l=0;l<c.length;l++)we(c[l])}}function je(l,c){return l(c)}function Ve(){}var Ge=!1;function nt(l,c,y){if(Ge)return l(c,y);Ge=!0;try{return je(l,c,y)}finally{Ge=!1,(Q!==null||oe!==null)&&(Ve(),ke())}}function Zt(l,c){var y=l.stateNode;if(y===null)return null;var k=yh(y);if(k===null)return null;y=k[c];e:switch(c){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(k=!k.disabled)||(l=l.type,k=!(l==="button"||l==="input"||l==="select"||l==="textarea")),l=!k;break e;default:l=!1}if(l)return null;if(y&&typeof y!="function")throw Error(n(231,c,typeof y));return y}var Jt=!1;if(d)try{var lt={};Object.defineProperty(lt,"passive",{get:function(){Jt=!0}}),window.addEventListener("test",lt,lt),window.removeEventListener("test",lt,lt)}catch{Jt=!1}function mt(l,c,y,k,F,V,ie,Ne,Re){var Ze=Array.prototype.slice.call(arguments,3);try{c.apply(y,Ze)}catch(At){this.onError(At)}}var Ds=!1,ss=null,Ae=!1,be=null,ut={onError:function(l){Ds=!0,ss=l}};function He(l,c,y,k,F,V,ie,Ne,Re){Ds=!1,ss=null,mt.apply(ut,arguments)}function yt(l,c,y,k,F,V,ie,Ne,Re){if(He.apply(this,arguments),Ds){if(Ds){var Ze=ss;Ds=!1,ss=null}else throw Error(n(198));Ae||(Ae=!0,be=Ze)}}function ft(l){var c=l,y=l;if(l.alternate)for(;c.return;)c=c.return;else{l=c;do c=l,(c.flags&4098)!==0&&(y=c.return),l=c.return;while(l)}return c.tag===3?y:null}function es(l){if(l.tag===13){var c=l.memoizedState;if(c===null&&(l=l.alternate,l!==null&&(c=l.memoizedState)),c!==null)return c.dehydrated}return null}function ts(l){if(ft(l)!==l)throw Error(n(188))}function Cs(l){var c=l.alternate;if(!c){if(c=ft(l),c===null)throw Error(n(188));return c!==l?null:l}for(var y=l,k=c;;){var F=y.return;if(F===null)break;var V=F.alternate;if(V===null){if(k=F.return,k!==null){y=k;continue}break}if(F.child===V.child){for(V=F.child;V;){if(V===y)return ts(F),l;if(V===k)return ts(F),c;V=V.sibling}throw Error(n(188))}if(y.return!==k.return)y=F,k=V;else{for(var ie=!1,Ne=F.child;Ne;){if(Ne===y){ie=!0,y=F,k=V;break}if(Ne===k){ie=!0,k=F,y=V;break}Ne=Ne.sibling}if(!ie){for(Ne=V.child;Ne;){if(Ne===y){ie=!0,y=V,k=F;break}if(Ne===k){ie=!0,k=V,y=F;break}Ne=Ne.sibling}if(!ie)throw Error(n(189))}}if(y.alternate!==k)throw Error(n(190))}if(y.tag!==3)throw Error(n(188));return y.stateNode.current===y?l:c}function Us(l){return l=Cs(l),l!==null?rn(l):null}function rn(l){if(l.tag===5||l.tag===6)return l;for(l=l.child;l!==null;){var c=rn(l);if(c!==null)return c;l=l.sibling}return null}var Js=s.unstable_scheduleCallback,an=s.unstable_cancelCallback,hn=s.unstable_shouldYield,De=s.unstable_requestPaint,bt=s.unstable_now,Te=s.unstable_getCurrentPriorityLevel,ct=s.unstable_ImmediatePriority,tt=s.unstable_UserBlockingPriority,jt=s.unstable_NormalPriority,Ht=s.unstable_LowPriority,zt=s.unstable_IdlePriority,fs=null,qt=null;function As(l){if(qt&&typeof qt.onCommitFiberRoot=="function")try{qt.onCommitFiberRoot(fs,l,void 0,(l.current.flags&128)===128)}catch{}}var vs=Math.clz32?Math.clz32:qs,cs=Math.log,mn=Math.LN2;function qs(l){return l>>>=0,l===0?32:31-(cs(l)/mn|0)|0}var ln=64,fn=4194304;function on(l){switch(l&-l){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 l&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return l&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return l}}function Ye(l,c){var y=l.pendingLanes;if(y===0)return 0;var k=0,F=l.suspendedLanes,V=l.pingedLanes,ie=y&268435455;if(ie!==0){var Ne=ie&~F;Ne!==0?k=on(Ne):(V&=ie,V!==0&&(k=on(V)))}else ie=y&~F,ie!==0?k=on(ie):V!==0&&(k=on(V));if(k===0)return 0;if(c!==0&&c!==k&&(c&F)===0&&(F=k&-k,V=c&-c,F>=V||F===16&&(V&4194240)!==0))return c;if((k&4)!==0&&(k|=y&16),c=l.entangledLanes,c!==0)for(l=l.entanglements,c&=k;0<c;)y=31-vs(c),F=1<<y,k|=l[y],c&=~F;return k}function Ot(l,c){switch(l){case 1:case 2:case 4:return c+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 c+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 St(l,c){for(var y=l.suspendedLanes,k=l.pingedLanes,F=l.expirationTimes,V=l.pendingLanes;0<V;){var ie=31-vs(V),Ne=1<<ie,Re=F[ie];Re===-1?((Ne&y)===0||(Ne&k)!==0)&&(F[ie]=Ot(Ne,c)):Re<=c&&(l.expiredLanes|=Ne),V&=~Ne}}function rt(l){return l=l.pendingLanes&-1073741825,l!==0?l:l&1073741824?1073741824:0}function Ft(){var l=ln;return ln<<=1,(ln&4194240)===0&&(ln=64),l}function jn(l){for(var c=[],y=0;31>y;y++)c.push(l);return c}function xn(l,c,y){l.pendingLanes|=c,c!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,c=31-vs(c),l[c]=y}function qn(l,c){var y=l.pendingLanes&~c;l.pendingLanes=c,l.suspendedLanes=0,l.pingedLanes=0,l.expiredLanes&=c,l.mutableReadLanes&=c,l.entangledLanes&=c,c=l.entanglements;var k=l.eventTimes;for(l=l.expirationTimes;0<y;){var F=31-vs(y),V=1<<F;c[F]=0,k[F]=-1,l[F]=-1,y&=~V}}function En(l,c){var y=l.entangledLanes|=c;for(l=l.entanglements;y;){var k=31-vs(y),F=1<<k;F&c|l[k]&c&&(l[k]|=c),y&=~F}}var Hs=0;function Za(l){return l&=-l,1<l?4<l?(l&268435455)!==0?16:536870912:4:1}var Pa,Ls,nn,ta,sa,na=!1,Ir=[],Xn=null,zn=null,Qt=null,Jn=new Map,Rr=new Map,Wn=[],Er="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 _n(l,c){switch(l){case"focusin":case"focusout":Xn=null;break;case"dragenter":case"dragleave":zn=null;break;case"mouseover":case"mouseout":Qt=null;break;case"pointerover":case"pointerout":Jn.delete(c.pointerId);break;case"gotpointercapture":case"lostpointercapture":Rr.delete(c.pointerId)}}function ur(l,c,y,k,F,V){return l===null||l.nativeEvent!==V?(l={blockedOn:c,domEventName:y,eventSystemFlags:k,nativeEvent:V,targetContainers:[F]},c!==null&&(c=Md(c),c!==null&&Ls(c)),l):(l.eventSystemFlags|=k,c=l.targetContainers,F!==null&&c.indexOf(F)===-1&&c.push(F),l)}function rs(l,c,y,k,F){switch(c){case"focusin":return Xn=ur(Xn,l,c,y,k,F),!0;case"dragenter":return zn=ur(zn,l,c,y,k,F),!0;case"mouseover":return Qt=ur(Qt,l,c,y,k,F),!0;case"pointerover":var V=F.pointerId;return Jn.set(V,ur(Jn.get(V)||null,l,c,y,k,F)),!0;case"gotpointercapture":return V=F.pointerId,Rr.set(V,ur(Rr.get(V)||null,l,c,y,k,F)),!0}return!1}function en(l){var c=Do(l.target);if(c!==null){var y=ft(c);if(y!==null){if(c=y.tag,c===13){if(c=es(y),c!==null){l.blockedOn=c,sa(l.priority,function(){nn(y)});return}}else if(c===3&&y.stateNode.current.memoizedState.isDehydrated){l.blockedOn=y.tag===3?y.stateNode.containerInfo:null;return}}}l.blockedOn=null}function va(l){if(l.blockedOn!==null)return!1;for(var c=l.targetContainers;0<c.length;){var y=ba(l.domEventName,l.eventSystemFlags,c[0],l.nativeEvent);if(y===null){y=l.nativeEvent;var k=new y.constructor(y.type,y);Qs=k,y.target.dispatchEvent(k),Qs=null}else return c=Md(y),c!==null&&Ls(c),l.blockedOn=y,!1;c.shift()}return!0}function wi(l,c,y){va(l)&&y.delete(c)}function Si(){na=!1,Xn!==null&&va(Xn)&&(Xn=null),zn!==null&&va(zn)&&(zn=null),Qt!==null&&va(Qt)&&(Qt=null),Jn.forEach(wi),Rr.forEach(wi)}function Mr(l,c){l.blockedOn===c&&(l.blockedOn=null,na||(na=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Si)))}function Hr(l){function c(F){return Mr(F,l)}if(0<Ir.length){Mr(Ir[0],l);for(var y=1;y<Ir.length;y++){var k=Ir[y];k.blockedOn===l&&(k.blockedOn=null)}}for(Xn!==null&&Mr(Xn,l),zn!==null&&Mr(zn,l),Qt!==null&&Mr(Qt,l),Jn.forEach(c),Rr.forEach(c),y=0;y<Wn.length;y++)k=Wn[y],k.blockedOn===l&&(k.blockedOn=null);for(;0<Wn.length&&(y=Wn[0],y.blockedOn===null);)en(y),y.blockedOn===null&&Wn.shift()}var sr=S.ReactCurrentBatchConfig,ya=!0;function Hi(l,c,y,k){var F=Hs,V=sr.transition;sr.transition=null;try{Hs=1,Oa(l,c,y,k)}finally{Hs=F,sr.transition=V}}function bo(l,c,y,k){var F=Hs,V=sr.transition;sr.transition=null;try{Hs=4,Oa(l,c,y,k)}finally{Hs=F,sr.transition=V}}function Oa(l,c,y,k){if(ya){var F=ba(l,c,y,k);if(F===null)Bp(l,c,k,Cn,y),_n(l,k);else if(rs(F,l,c,y,k))k.stopPropagation();else if(_n(l,k),c&4&&-1<Er.indexOf(l)){for(;F!==null;){var V=Md(F);if(V!==null&&Pa(V),V=ba(l,c,y,k),V===null&&Bp(l,c,k,Cn,y),V===F)break;F=V}F!==null&&k.stopPropagation()}else Bp(l,c,k,null,y)}}var Cn=null;function ba(l,c,y,k){if(Cn=null,l=Xs(k),l=Do(l),l!==null)if(c=ft(l),c===null)l=null;else if(y=c.tag,y===13){if(l=es(c),l!==null)return l;l=null}else if(y===3){if(c.stateNode.current.memoizedState.isDehydrated)return c.tag===3?c.stateNode.containerInfo:null;l=null}else c!==l&&(l=null);return Cn=l,null}function Wi(l){switch(l){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(Te()){case ct:return 1;case tt:return 4;case jt:case Ht:return 16;case zt:return 536870912;default:return 16}default:return 16}}var Wr=null,jo=null,Gi=null;function No(){if(Gi)return Gi;var l,c=jo,y=c.length,k,F="value"in Wr?Wr.value:Wr.textContent,V=F.length;for(l=0;l<y&&c[l]===F[l];l++);var ie=y-l;for(k=1;k<=ie&&c[y-k]===F[V-k];k++);return Gi=F.slice(l,1<k?1-k:void 0)}function Ci(l){var c=l.keyCode;return"charCode"in l?(l=l.charCode,l===0&&c===13&&(l=13)):l=c,l===10&&(l=13),32<=l||l===13?l:0}function wl(){return!0}function Sl(){return!1}function cn(l){function c(y,k,F,V,ie){this._reactName=y,this._targetInst=F,this.type=k,this.nativeEvent=V,this.target=ie,this.currentTarget=null;for(var Ne in l)l.hasOwnProperty(Ne)&&(y=l[Ne],this[Ne]=y?y(V):V[Ne]);return this.isDefaultPrevented=(V.defaultPrevented!=null?V.defaultPrevented:V.returnValue===!1)?wl:Sl,this.isPropagationStopped=Sl,this}return z(c.prototype,{preventDefault:function(){this.defaultPrevented=!0;var y=this.nativeEvent;y&&(y.preventDefault?y.preventDefault():typeof y.returnValue!="unknown"&&(y.returnValue=!1),this.isDefaultPrevented=wl)},stopPropagation:function(){var y=this.nativeEvent;y&&(y.stopPropagation?y.stopPropagation():typeof y.cancelBubble!="unknown"&&(y.cancelBubble=!0),this.isPropagationStopped=wl)},persist:function(){},isPersistent:wl}),c}var ne={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},re=cn(ne),me=z({},ne,{view:0,detail:0}),pe=cn(me),Se,ze,Ue,ot=z({},me,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:vr,button:0,buttons:0,relatedTarget:function(l){return l.relatedTarget===void 0?l.fromElement===l.srcElement?l.toElement:l.fromElement:l.relatedTarget},movementX:function(l){return"movementX"in l?l.movementX:(l!==Ue&&(Ue&&l.type==="mousemove"?(Se=l.screenX-Ue.screenX,ze=l.screenY-Ue.screenY):ze=Se=0,Ue=l),Se)},movementY:function(l){return"movementY"in l?l.movementY:ze}}),ls=cn(ot),Gt=z({},ot,{dataTransfer:0}),Lt=cn(Gt),ws=z({},me,{relatedTarget:0}),gn=cn(ws),nr=z({},ne,{animationName:0,elapsedTime:0,pseudoElement:0}),Bt=cn(nr),Ss=z({},ne,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),is=cn(Ss),Mn=z({},ne,{data:0}),_r=cn(Mn),Gn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},gr={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"},Gr={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Qa(l){var c=this.nativeEvent;return c.getModifierState?c.getModifierState(l):(l=Gr[l])?!!c[l]:!1}function vr(){return Qa}var wo=z({},me,{key:function(l){if(l.key){var c=Gn[l.key]||l.key;if(c!=="Unidentified")return c}return l.type==="keypress"?(l=Ci(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?gr[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:vr,charCode:function(l){return l.type==="keypress"?Ci(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?Ci(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),Cl=cn(wo),xc=z({},ot,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),So=cn(xc),Al=z({},me,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:vr}),Ki=cn(Al),Xa=z({},ne,{propertyName:0,elapsedTime:0,pseudoElement:0}),gc=cn(Xa),hr=z({},ot,{deltaX:function(l){return"deltaX"in l?l.deltaX:"wheelDeltaX"in l?-l.wheelDeltaX:0},deltaY:function(l){return"deltaY"in l?l.deltaY:"wheelDeltaY"in l?-l.wheelDeltaY:"wheelDelta"in l?-l.wheelDelta:0},deltaZ:0,deltaMode:0}),vc=cn(hr),La=[9,13,27,32],kl=d&&"CompositionEvent"in window,Yi=null;d&&"documentMode"in document&&(Yi=document.documentMode);var Ia=d&&"TextEvent"in window&&!Yi,Ja=d&&(!kl||Yi&&8<Yi&&11>=Yi),Dl=" ",Zi=!1;function Co(l,c){switch(l){case"keyup":return La.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function oh(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Rl=!1;function kp(l,c){switch(l){case"compositionend":return oh(c);case"keypress":return c.which!==32?null:(Zi=!0,Dl);case"textInput":return l=c.data,l===Dl&&Zi?null:l;default:return null}}function Dp(l,c){if(Rl)return l==="compositionend"||!kl&&Co(l,c)?(l=No(),Gi=jo=Wr=null,Rl=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1<c.char.length)return c.char;if(c.which)return String.fromCharCode(c.which)}return null;case"compositionend":return Ja&&c.locale!=="ko"?null:c.data;default:return null}}var Rp={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 ch(l){var c=l&&l.nodeName&&l.nodeName.toLowerCase();return c==="input"?!!Rp[l.type]:c==="textarea"}function dh(l,c,y,k){Oe(k),c=xh(c,"onChange"),0<c.length&&(y=new re("onChange","change",null,y,k),l.push({event:y,listeners:c}))}var Ao=null,ko=null;function Ep(l){_j(l,0)}function yc(l){var c=Cc(l);if(ce(c))return l}function _p(l,c){if(l==="change")return c}var uh=!1;if(d){var Ed;if(d){var bc="oninput"in document;if(!bc){var yr=document.createElement("div");yr.setAttribute("oninput","return;"),bc=typeof yr.oninput=="function"}Ed=bc}else Ed=!1;uh=Ed&&(!document.documentMode||9<document.documentMode)}function El(){Ao&&(Ao.detachEvent("onpropertychange",hh),ko=Ao=null)}function hh(l){if(l.propertyName==="value"&&yc(ko)){var c=[];dh(c,ko,l,Xs(l)),nt(Ep,c)}}function pT(l,c,y){l==="focusin"?(El(),Ao=c,ko=y,Ao.attachEvent("onpropertychange",hh)):l==="focusout"&&El()}function xT(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return yc(ko)}function gT(l,c){if(l==="click")return yc(c)}function vT(l,c){if(l==="input"||l==="change")return yc(c)}function yT(l,c){return l===c&&(l!==0||1/l===1/c)||l!==l&&c!==c}var ei=typeof Object.is=="function"?Object.is:yT;function _d(l,c){if(ei(l,c))return!0;if(typeof l!="object"||l===null||typeof c!="object"||c===null)return!1;var y=Object.keys(l),k=Object.keys(c);if(y.length!==k.length)return!1;for(k=0;k<y.length;k++){var F=y[k];if(!m.call(c,F)||!ei(l[F],c[F]))return!1}return!0}function vj(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function yj(l,c){var y=vj(l);l=0;for(var k;y;){if(y.nodeType===3){if(k=l+y.textContent.length,l<=c&&k>=c)return{node:y,offset:c-l};l=k}e:{for(;y;){if(y.nextSibling){y=y.nextSibling;break e}y=y.parentNode}y=void 0}y=vj(y)}}function bj(l,c){return l&&c?l===c?!0:l&&l.nodeType===3?!1:c&&c.nodeType===3?bj(l,c.parentNode):"contains"in l?l.contains(c):l.compareDocumentPosition?!!(l.compareDocumentPosition(c)&16):!1:!1}function jj(){for(var l=window,c=ve();c instanceof l.HTMLIFrameElement;){try{var y=typeof c.contentWindow.location.href=="string"}catch{y=!1}if(y)l=c.contentWindow;else break;c=ve(l.document)}return c}function Tp(l){var c=l&&l.nodeName&&l.nodeName.toLowerCase();return c&&(c==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||c==="textarea"||l.contentEditable==="true")}function bT(l){var c=jj(),y=l.focusedElem,k=l.selectionRange;if(c!==y&&y&&y.ownerDocument&&bj(y.ownerDocument.documentElement,y)){if(k!==null&&Tp(y)){if(c=k.start,l=k.end,l===void 0&&(l=c),"selectionStart"in y)y.selectionStart=c,y.selectionEnd=Math.min(l,y.value.length);else if(l=(c=y.ownerDocument||document)&&c.defaultView||window,l.getSelection){l=l.getSelection();var F=y.textContent.length,V=Math.min(k.start,F);k=k.end===void 0?V:Math.min(k.end,F),!l.extend&&V>k&&(F=k,k=V,V=F),F=yj(y,V);var ie=yj(y,k);F&&ie&&(l.rangeCount!==1||l.anchorNode!==F.node||l.anchorOffset!==F.offset||l.focusNode!==ie.node||l.focusOffset!==ie.offset)&&(c=c.createRange(),c.setStart(F.node,F.offset),l.removeAllRanges(),V>k?(l.addRange(c),l.extend(ie.node,ie.offset)):(c.setEnd(ie.node,ie.offset),l.addRange(c)))}}for(c=[],l=y;l=l.parentNode;)l.nodeType===1&&c.push({element:l,left:l.scrollLeft,top:l.scrollTop});for(typeof y.focus=="function"&&y.focus(),y=0;y<c.length;y++)l=c[y],l.element.scrollLeft=l.left,l.element.scrollTop=l.top}}var jT=d&&"documentMode"in document&&11>=document.documentMode,jc=null,Pp=null,Td=null,Op=!1;function Nj(l,c,y){var k=y.window===y?y.document:y.nodeType===9?y:y.ownerDocument;Op||jc==null||jc!==ve(k)||(k=jc,"selectionStart"in k&&Tp(k)?k={start:k.selectionStart,end:k.selectionEnd}:(k=(k.ownerDocument&&k.ownerDocument.defaultView||window).getSelection(),k={anchorNode:k.anchorNode,anchorOffset:k.anchorOffset,focusNode:k.focusNode,focusOffset:k.focusOffset}),Td&&_d(Td,k)||(Td=k,k=xh(Pp,"onSelect"),0<k.length&&(c=new re("onSelect","select",null,c,y),l.push({event:c,listeners:k}),c.target=jc)))}function mh(l,c){var y={};return y[l.toLowerCase()]=c.toLowerCase(),y["Webkit"+l]="webkit"+c,y["Moz"+l]="moz"+c,y}var Nc={animationend:mh("Animation","AnimationEnd"),animationiteration:mh("Animation","AnimationIteration"),animationstart:mh("Animation","AnimationStart"),transitionend:mh("Transition","TransitionEnd")},Lp={},wj={};d&&(wj=document.createElement("div").style,"AnimationEvent"in window||(delete Nc.animationend.animation,delete Nc.animationiteration.animation,delete Nc.animationstart.animation),"TransitionEvent"in window||delete Nc.transitionend.transition);function fh(l){if(Lp[l])return Lp[l];if(!Nc[l])return l;var c=Nc[l],y;for(y in c)if(c.hasOwnProperty(y)&&y in wj)return Lp[l]=c[y];return l}var Sj=fh("animationend"),Cj=fh("animationiteration"),Aj=fh("animationstart"),kj=fh("transitionend"),Dj=new Map,Rj="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 _l(l,c){Dj.set(l,c),i(c,[l])}for(var Ip=0;Ip<Rj.length;Ip++){var Mp=Rj[Ip],NT=Mp.toLowerCase(),wT=Mp[0].toUpperCase()+Mp.slice(1);_l(NT,"on"+wT)}_l(Sj,"onAnimationEnd"),_l(Cj,"onAnimationIteration"),_l(Aj,"onAnimationStart"),_l("dblclick","onDoubleClick"),_l("focusin","onFocus"),_l("focusout","onBlur"),_l(kj,"onTransitionEnd"),o("onMouseEnter",["mouseout","mouseover"]),o("onMouseLeave",["mouseout","mouseover"]),o("onPointerEnter",["pointerout","pointerover"]),o("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Pd="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(" "),ST=new Set("cancel close invalid load scroll toggle".split(" ").concat(Pd));function Ej(l,c,y){var k=l.type||"unknown-event";l.currentTarget=y,yt(k,c,void 0,l),l.currentTarget=null}function _j(l,c){c=(c&4)!==0;for(var y=0;y<l.length;y++){var k=l[y],F=k.event;k=k.listeners;e:{var V=void 0;if(c)for(var ie=k.length-1;0<=ie;ie--){var Ne=k[ie],Re=Ne.instance,Ze=Ne.currentTarget;if(Ne=Ne.listener,Re!==V&&F.isPropagationStopped())break e;Ej(F,Ne,Ze),V=Re}else for(ie=0;ie<k.length;ie++){if(Ne=k[ie],Re=Ne.instance,Ze=Ne.currentTarget,Ne=Ne.listener,Re!==V&&F.isPropagationStopped())break e;Ej(F,Ne,Ze),V=Re}}}if(Ae)throw l=be,Ae=!1,be=null,l}function Tn(l,c){var y=c[Hp];y===void 0&&(y=c[Hp]=new Set);var k=l+"__bubble";y.has(k)||(Tj(c,l,2,!1),y.add(k))}function Fp(l,c,y){var k=0;c&&(k|=4),Tj(y,l,k,c)}var ph="_reactListening"+Math.random().toString(36).slice(2);function Od(l){if(!l[ph]){l[ph]=!0,r.forEach(function(y){y!=="selectionchange"&&(ST.has(y)||Fp(y,!1,l),Fp(y,!0,l))});var c=l.nodeType===9?l:l.ownerDocument;c===null||c[ph]||(c[ph]=!0,Fp("selectionchange",!1,c))}}function Tj(l,c,y,k){switch(Wi(c)){case 1:var F=Hi;break;case 4:F=bo;break;default:F=Oa}y=F.bind(null,c,y,l),F=void 0,!Jt||c!=="touchstart"&&c!=="touchmove"&&c!=="wheel"||(F=!0),k?F!==void 0?l.addEventListener(c,y,{capture:!0,passive:F}):l.addEventListener(c,y,!0):F!==void 0?l.addEventListener(c,y,{passive:F}):l.addEventListener(c,y,!1)}function Bp(l,c,y,k,F){var V=k;if((c&1)===0&&(c&2)===0&&k!==null)e:for(;;){if(k===null)return;var ie=k.tag;if(ie===3||ie===4){var Ne=k.stateNode.containerInfo;if(Ne===F||Ne.nodeType===8&&Ne.parentNode===F)break;if(ie===4)for(ie=k.return;ie!==null;){var Re=ie.tag;if((Re===3||Re===4)&&(Re=ie.stateNode.containerInfo,Re===F||Re.nodeType===8&&Re.parentNode===F))return;ie=ie.return}for(;Ne!==null;){if(ie=Do(Ne),ie===null)return;if(Re=ie.tag,Re===5||Re===6){k=V=ie;continue e}Ne=Ne.parentNode}}k=k.return}nt(function(){var Ze=V,At=Xs(y),Tt=[];e:{var Ct=Dj.get(l);if(Ct!==void 0){var as=re,ps=l;switch(l){case"keypress":if(Ci(y)===0)break e;case"keydown":case"keyup":as=Cl;break;case"focusin":ps="focus",as=gn;break;case"focusout":ps="blur",as=gn;break;case"beforeblur":case"afterblur":as=gn;break;case"click":if(y.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":as=ls;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":as=Lt;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":as=Ki;break;case Sj:case Cj:case Aj:as=Bt;break;case kj:as=gc;break;case"scroll":as=pe;break;case"wheel":as=vc;break;case"copy":case"cut":case"paste":as=is;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":as=So}var gs=(c&4)!==0,er=!gs&&l==="scroll",We=gs?Ct!==null?Ct+"Capture":null:Ct;gs=[];for(var Ie=Ze,Ke;Ie!==null;){Ke=Ie;var $t=Ke.stateNode;if(Ke.tag===5&&$t!==null&&(Ke=$t,We!==null&&($t=Zt(Ie,We),$t!=null&&gs.push(Ld(Ie,$t,Ke)))),er)break;Ie=Ie.return}0<gs.length&&(Ct=new as(Ct,ps,null,y,At),Tt.push({event:Ct,listeners:gs}))}}if((c&7)===0){e:{if(Ct=l==="mouseover"||l==="pointerover",as=l==="mouseout"||l==="pointerout",Ct&&y!==Qs&&(ps=y.relatedTarget||y.fromElement)&&(Do(ps)||ps[Qi]))break e;if((as||Ct)&&(Ct=At.window===At?At:(Ct=At.ownerDocument)?Ct.defaultView||Ct.parentWindow:window,as?(ps=y.relatedTarget||y.toElement,as=Ze,ps=ps?Do(ps):null,ps!==null&&(er=ft(ps),ps!==er||ps.tag!==5&&ps.tag!==6)&&(ps=null)):(as=null,ps=Ze),as!==ps)){if(gs=ls,$t="onMouseLeave",We="onMouseEnter",Ie="mouse",(l==="pointerout"||l==="pointerover")&&(gs=So,$t="onPointerLeave",We="onPointerEnter",Ie="pointer"),er=as==null?Ct:Cc(as),Ke=ps==null?Ct:Cc(ps),Ct=new gs($t,Ie+"leave",as,y,At),Ct.target=er,Ct.relatedTarget=Ke,$t=null,Do(At)===Ze&&(gs=new gs(We,Ie+"enter",ps,y,At),gs.target=Ke,gs.relatedTarget=er,$t=gs),er=$t,as&&ps)t:{for(gs=as,We=ps,Ie=0,Ke=gs;Ke;Ke=wc(Ke))Ie++;for(Ke=0,$t=We;$t;$t=wc($t))Ke++;for(;0<Ie-Ke;)gs=wc(gs),Ie--;for(;0<Ke-Ie;)We=wc(We),Ke--;for(;Ie--;){if(gs===We||We!==null&&gs===We.alternate)break t;gs=wc(gs),We=wc(We)}gs=null}else gs=null;as!==null&&Pj(Tt,Ct,as,gs,!1),ps!==null&&er!==null&&Pj(Tt,er,ps,gs,!0)}}e:{if(Ct=Ze?Cc(Ze):window,as=Ct.nodeName&&Ct.nodeName.toLowerCase(),as==="select"||as==="input"&&Ct.type==="file")var ys=_p;else if(ch(Ct))if(uh)ys=vT;else{ys=xT;var Rs=pT}else(as=Ct.nodeName)&&as.toLowerCase()==="input"&&(Ct.type==="checkbox"||Ct.type==="radio")&&(ys=gT);if(ys&&(ys=ys(l,Ze))){dh(Tt,ys,y,At);break e}Rs&&Rs(l,Ct,Ze),l==="focusout"&&(Rs=Ct._wrapperState)&&Rs.controlled&&Ct.type==="number"&&ge(Ct,"number",Ct.value)}switch(Rs=Ze?Cc(Ze):window,l){case"focusin":(ch(Rs)||Rs.contentEditable==="true")&&(jc=Rs,Pp=Ze,Td=null);break;case"focusout":Td=Pp=jc=null;break;case"mousedown":Op=!0;break;case"contextmenu":case"mouseup":case"dragend":Op=!1,Nj(Tt,y,At);break;case"selectionchange":if(jT)break;case"keydown":case"keyup":Nj(Tt,y,At)}var Es;if(kl)e:{switch(l){case"compositionstart":var zs="onCompositionStart";break e;case"compositionend":zs="onCompositionEnd";break e;case"compositionupdate":zs="onCompositionUpdate";break e}zs=void 0}else Rl?Co(l,y)&&(zs="onCompositionEnd"):l==="keydown"&&y.keyCode===229&&(zs="onCompositionStart");zs&&(Ja&&y.locale!=="ko"&&(Rl||zs!=="onCompositionStart"?zs==="onCompositionEnd"&&Rl&&(Es=No()):(Wr=At,jo="value"in Wr?Wr.value:Wr.textContent,Rl=!0)),Rs=xh(Ze,zs),0<Rs.length&&(zs=new _r(zs,l,null,y,At),Tt.push({event:zs,listeners:Rs}),Es?zs.data=Es:(Es=oh(y),Es!==null&&(zs.data=Es)))),(Es=Ia?kp(l,y):Dp(l,y))&&(Ze=xh(Ze,"onBeforeInput"),0<Ze.length&&(At=new _r("onBeforeInput","beforeinput",null,y,At),Tt.push({event:At,listeners:Ze}),At.data=Es))}_j(Tt,c)})}function Ld(l,c,y){return{instance:l,listener:c,currentTarget:y}}function xh(l,c){for(var y=c+"Capture",k=[];l!==null;){var F=l,V=F.stateNode;F.tag===5&&V!==null&&(F=V,V=Zt(l,y),V!=null&&k.unshift(Ld(l,V,F)),V=Zt(l,c),V!=null&&k.push(Ld(l,V,F))),l=l.return}return k}function wc(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5);return l||null}function Pj(l,c,y,k,F){for(var V=c._reactName,ie=[];y!==null&&y!==k;){var Ne=y,Re=Ne.alternate,Ze=Ne.stateNode;if(Re!==null&&Re===k)break;Ne.tag===5&&Ze!==null&&(Ne=Ze,F?(Re=Zt(y,V),Re!=null&&ie.unshift(Ld(y,Re,Ne))):F||(Re=Zt(y,V),Re!=null&&ie.push(Ld(y,Re,Ne)))),y=y.return}ie.length!==0&&l.push({event:c,listeners:ie})}var CT=/\r\n?/g,AT=/\u0000|\uFFFD/g;function Oj(l){return(typeof l=="string"?l:""+l).replace(CT,`
`).replace(AT,"")}function gh(l,c,y){if(c=Oj(c),Oj(l)!==c&&y)throw Error(n(425))}function vh(){}var $p=null,qp=null;function zp(l,c){return l==="textarea"||l==="noscript"||typeof c.children=="string"||typeof c.children=="number"||typeof c.dangerouslySetInnerHTML=="object"&&c.dangerouslySetInnerHTML!==null&&c.dangerouslySetInnerHTML.__html!=null}var Up=typeof setTimeout=="function"?setTimeout:void 0,kT=typeof clearTimeout=="function"?clearTimeout:void 0,Lj=typeof Promise=="function"?Promise:void 0,DT=typeof queueMicrotask=="function"?queueMicrotask:typeof Lj<"u"?function(l){return Lj.resolve(null).then(l).catch(RT)}:Up;function RT(l){setTimeout(function(){throw l})}function Vp(l,c){var y=c,k=0;do{var F=y.nextSibling;if(l.removeChild(y),F&&F.nodeType===8)if(y=F.data,y==="/$"){if(k===0){l.removeChild(F),Hr(c);return}k--}else y!=="$"&&y!=="$?"&&y!=="$!"||k++;y=F}while(y);Hr(c)}function Tl(l){for(;l!=null;l=l.nextSibling){var c=l.nodeType;if(c===1||c===3)break;if(c===8){if(c=l.data,c==="$"||c==="$!"||c==="$?")break;if(c==="/$")return null}}return l}function Ij(l){l=l.previousSibling;for(var c=0;l;){if(l.nodeType===8){var y=l.data;if(y==="$"||y==="$!"||y==="$?"){if(c===0)return l;c--}else y==="/$"&&c++}l=l.previousSibling}return null}var Sc=Math.random().toString(36).slice(2),Ai="__reactFiber$"+Sc,Id="__reactProps$"+Sc,Qi="__reactContainer$"+Sc,Hp="__reactEvents$"+Sc,ET="__reactListeners$"+Sc,_T="__reactHandles$"+Sc;function Do(l){var c=l[Ai];if(c)return c;for(var y=l.parentNode;y;){if(c=y[Qi]||y[Ai]){if(y=c.alternate,c.child!==null||y!==null&&y.child!==null)for(l=Ij(l);l!==null;){if(y=l[Ai])return y;l=Ij(l)}return c}l=y,y=l.parentNode}return null}function Md(l){return l=l[Ai]||l[Qi],!l||l.tag!==5&&l.tag!==6&&l.tag!==13&&l.tag!==3?null:l}function Cc(l){if(l.tag===5||l.tag===6)return l.stateNode;throw Error(n(33))}function yh(l){return l[Id]||null}var Wp=[],Ac=-1;function Pl(l){return{current:l}}function Pn(l){0>Ac||(l.current=Wp[Ac],Wp[Ac]=null,Ac--)}function Dn(l,c){Ac++,Wp[Ac]=l.current,l.current=c}var Ol={},Fr=Pl(Ol),ra=Pl(!1),Ro=Ol;function kc(l,c){var y=l.type.contextTypes;if(!y)return Ol;var k=l.stateNode;if(k&&k.__reactInternalMemoizedUnmaskedChildContext===c)return k.__reactInternalMemoizedMaskedChildContext;var F={},V;for(V in y)F[V]=c[V];return k&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=c,l.__reactInternalMemoizedMaskedChildContext=F),F}function aa(l){return l=l.childContextTypes,l!=null}function bh(){Pn(ra),Pn(Fr)}function Mj(l,c,y){if(Fr.current!==Ol)throw Error(n(168));Dn(Fr,c),Dn(ra,y)}function Fj(l,c,y){var k=l.stateNode;if(c=c.childContextTypes,typeof k.getChildContext!="function")return y;k=k.getChildContext();for(var F in k)if(!(F in c))throw Error(n(108,X(l)||"Unknown",F));return z({},y,k)}function jh(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||Ol,Ro=Fr.current,Dn(Fr,l),Dn(ra,ra.current),!0}function Bj(l,c,y){var k=l.stateNode;if(!k)throw Error(n(169));y?(l=Fj(l,c,Ro),k.__reactInternalMemoizedMergedChildContext=l,Pn(ra),Pn(Fr),Dn(Fr,l)):Pn(ra),Dn(ra,y)}var Xi=null,Nh=!1,Gp=!1;function $j(l){Xi===null?Xi=[l]:Xi.push(l)}function TT(l){Nh=!0,$j(l)}function Ll(){if(!Gp&&Xi!==null){Gp=!0;var l=0,c=Hs;try{var y=Xi;for(Hs=1;l<y.length;l++){var k=y[l];do k=k(!0);while(k!==null)}Xi=null,Nh=!1}catch(F){throw Xi!==null&&(Xi=Xi.slice(l+1)),Js(ct,Ll),F}finally{Hs=c,Gp=!1}}return null}var Dc=[],Rc=0,wh=null,Sh=0,Ma=[],Fa=0,Eo=null,Ji=1,el="";function _o(l,c){Dc[Rc++]=Sh,Dc[Rc++]=wh,wh=l,Sh=c}function qj(l,c,y){Ma[Fa++]=Ji,Ma[Fa++]=el,Ma[Fa++]=Eo,Eo=l;var k=Ji;l=el;var F=32-vs(k)-1;k&=~(1<<F),y+=1;var V=32-vs(c)+F;if(30<V){var ie=F-F%5;V=(k&(1<<ie)-1).toString(32),k>>=ie,F-=ie,Ji=1<<32-vs(c)+F|y<<F|k,el=V+l}else Ji=1<<V|y<<F|k,el=l}function Kp(l){l.return!==null&&(_o(l,1),qj(l,1,0))}function Yp(l){for(;l===wh;)wh=Dc[--Rc],Dc[Rc]=null,Sh=Dc[--Rc],Dc[Rc]=null;for(;l===Eo;)Eo=Ma[--Fa],Ma[Fa]=null,el=Ma[--Fa],Ma[Fa]=null,Ji=Ma[--Fa],Ma[Fa]=null}var ja=null,Na=null,Fn=!1,ti=null;function zj(l,c){var y=za(5,null,null,0);y.elementType="DELETED",y.stateNode=c,y.return=l,c=l.deletions,c===null?(l.deletions=[y],l.flags|=16):c.push(y)}function Uj(l,c){switch(l.tag){case 5:var y=l.type;return c=c.nodeType!==1||y.toLowerCase()!==c.nodeName.toLowerCase()?null:c,c!==null?(l.stateNode=c,ja=l,Na=Tl(c.firstChild),!0):!1;case 6:return c=l.pendingProps===""||c.nodeType!==3?null:c,c!==null?(l.stateNode=c,ja=l,Na=null,!0):!1;case 13:return c=c.nodeType!==8?null:c,c!==null?(y=Eo!==null?{id:Ji,overflow:el}:null,l.memoizedState={dehydrated:c,treeContext:y,retryLane:1073741824},y=za(18,null,null,0),y.stateNode=c,y.return=l,l.child=y,ja=l,Na=null,!0):!1;default:return!1}}function Zp(l){return(l.mode&1)!==0&&(l.flags&128)===0}function Qp(l){if(Fn){var c=Na;if(c){var y=c;if(!Uj(l,c)){if(Zp(l))throw Error(n(418));c=Tl(y.nextSibling);var k=ja;c&&Uj(l,c)?zj(k,y):(l.flags=l.flags&-4097|2,Fn=!1,ja=l)}}else{if(Zp(l))throw Error(n(418));l.flags=l.flags&-4097|2,Fn=!1,ja=l}}}function Vj(l){for(l=l.return;l!==null&&l.tag!==5&&l.tag!==3&&l.tag!==13;)l=l.return;ja=l}function Ch(l){if(l!==ja)return!1;if(!Fn)return Vj(l),Fn=!0,!1;var c;if((c=l.tag!==3)&&!(c=l.tag!==5)&&(c=l.type,c=c!=="head"&&c!=="body"&&!zp(l.type,l.memoizedProps)),c&&(c=Na)){if(Zp(l))throw Hj(),Error(n(418));for(;c;)zj(l,c),c=Tl(c.nextSibling)}if(Vj(l),l.tag===13){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(n(317));e:{for(l=l.nextSibling,c=0;l;){if(l.nodeType===8){var y=l.data;if(y==="/$"){if(c===0){Na=Tl(l.nextSibling);break e}c--}else y!=="$"&&y!=="$!"&&y!=="$?"||c++}l=l.nextSibling}Na=null}}else Na=ja?Tl(l.stateNode.nextSibling):null;return!0}function Hj(){for(var l=Na;l;)l=Tl(l.nextSibling)}function Ec(){Na=ja=null,Fn=!1}function Xp(l){ti===null?ti=[l]:ti.push(l)}var PT=S.ReactCurrentBatchConfig;function Fd(l,c,y){if(l=y.ref,l!==null&&typeof l!="function"&&typeof l!="object"){if(y._owner){if(y=y._owner,y){if(y.tag!==1)throw Error(n(309));var k=y.stateNode}if(!k)throw Error(n(147,l));var F=k,V=""+l;return c!==null&&c.ref!==null&&typeof c.ref=="function"&&c.ref._stringRef===V?c.ref:(c=function(ie){var Ne=F.refs;ie===null?delete Ne[V]:Ne[V]=ie},c._stringRef=V,c)}if(typeof l!="string")throw Error(n(284));if(!y._owner)throw Error(n(290,l))}return l}function Ah(l,c){throw l=Object.prototype.toString.call(c),Error(n(31,l==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":l))}function Wj(l){var c=l._init;return c(l._payload)}function Gj(l){function c(We,Ie){if(l){var Ke=We.deletions;Ke===null?(We.deletions=[Ie],We.flags|=16):Ke.push(Ie)}}function y(We,Ie){if(!l)return null;for(;Ie!==null;)c(We,Ie),Ie=Ie.sibling;return null}function k(We,Ie){for(We=new Map;Ie!==null;)Ie.key!==null?We.set(Ie.key,Ie):We.set(Ie.index,Ie),Ie=Ie.sibling;return We}function F(We,Ie){return We=Ul(We,Ie),We.index=0,We.sibling=null,We}function V(We,Ie,Ke){return We.index=Ke,l?(Ke=We.alternate,Ke!==null?(Ke=Ke.index,Ke<Ie?(We.flags|=2,Ie):Ke):(We.flags|=2,Ie)):(We.flags|=1048576,Ie)}function ie(We){return l&&We.alternate===null&&(We.flags|=2),We}function Ne(We,Ie,Ke,$t){return Ie===null||Ie.tag!==6?(Ie=Ux(Ke,We.mode,$t),Ie.return=We,Ie):(Ie=F(Ie,Ke),Ie.return=We,Ie)}function Re(We,Ie,Ke,$t){var ys=Ke.type;return ys===A?At(We,Ie,Ke.props.children,$t,Ke.key):Ie!==null&&(Ie.elementType===ys||typeof ys=="object"&&ys!==null&&ys.$$typeof===Z&&Wj(ys)===Ie.type)?($t=F(Ie,Ke.props),$t.ref=Fd(We,Ie,Ke),$t.return=We,$t):($t=Zh(Ke.type,Ke.key,Ke.props,null,We.mode,$t),$t.ref=Fd(We,Ie,Ke),$t.return=We,$t)}function Ze(We,Ie,Ke,$t){return Ie===null||Ie.tag!==4||Ie.stateNode.containerInfo!==Ke.containerInfo||Ie.stateNode.implementation!==Ke.implementation?(Ie=Vx(Ke,We.mode,$t),Ie.return=We,Ie):(Ie=F(Ie,Ke.children||[]),Ie.return=We,Ie)}function At(We,Ie,Ke,$t,ys){return Ie===null||Ie.tag!==7?(Ie=Bo(Ke,We.mode,$t,ys),Ie.return=We,Ie):(Ie=F(Ie,Ke),Ie.return=We,Ie)}function Tt(We,Ie,Ke){if(typeof Ie=="string"&&Ie!==""||typeof Ie=="number")return Ie=Ux(""+Ie,We.mode,Ke),Ie.return=We,Ie;if(typeof Ie=="object"&&Ie!==null){switch(Ie.$$typeof){case R:return Ke=Zh(Ie.type,Ie.key,Ie.props,null,We.mode,Ke),Ke.ref=Fd(We,null,Ie),Ke.return=We,Ke;case _:return Ie=Vx(Ie,We.mode,Ke),Ie.return=We,Ie;case Z:var $t=Ie._init;return Tt(We,$t(Ie._payload),Ke)}if(ye(Ie)||M(Ie))return Ie=Bo(Ie,We.mode,Ke,null),Ie.return=We,Ie;Ah(We,Ie)}return null}function Ct(We,Ie,Ke,$t){var ys=Ie!==null?Ie.key:null;if(typeof Ke=="string"&&Ke!==""||typeof Ke=="number")return ys!==null?null:Ne(We,Ie,""+Ke,$t);if(typeof Ke=="object"&&Ke!==null){switch(Ke.$$typeof){case R:return Ke.key===ys?Re(We,Ie,Ke,$t):null;case _:return Ke.key===ys?Ze(We,Ie,Ke,$t):null;case Z:return ys=Ke._init,Ct(We,Ie,ys(Ke._payload),$t)}if(ye(Ke)||M(Ke))return ys!==null?null:At(We,Ie,Ke,$t,null);Ah(We,Ke)}return null}function as(We,Ie,Ke,$t,ys){if(typeof $t=="string"&&$t!==""||typeof $t=="number")return We=We.get(Ke)||null,Ne(Ie,We,""+$t,ys);if(typeof $t=="object"&&$t!==null){switch($t.$$typeof){case R:return We=We.get($t.key===null?Ke:$t.key)||null,Re(Ie,We,$t,ys);case _:return We=We.get($t.key===null?Ke:$t.key)||null,Ze(Ie,We,$t,ys);case Z:var Rs=$t._init;return as(We,Ie,Ke,Rs($t._payload),ys)}if(ye($t)||M($t))return We=We.get(Ke)||null,At(Ie,We,$t,ys,null);Ah(Ie,$t)}return null}function ps(We,Ie,Ke,$t){for(var ys=null,Rs=null,Es=Ie,zs=Ie=0,Nr=null;Es!==null&&zs<Ke.length;zs++){Es.index>zs?(Nr=Es,Es=null):Nr=Es.sibling;var wn=Ct(We,Es,Ke[zs],$t);if(wn===null){Es===null&&(Es=Nr);break}l&&Es&&wn.alternate===null&&c(We,Es),Ie=V(wn,Ie,zs),Rs===null?ys=wn:Rs.sibling=wn,Rs=wn,Es=Nr}if(zs===Ke.length)return y(We,Es),Fn&&_o(We,zs),ys;if(Es===null){for(;zs<Ke.length;zs++)Es=Tt(We,Ke[zs],$t),Es!==null&&(Ie=V(Es,Ie,zs),Rs===null?ys=Es:Rs.sibling=Es,Rs=Es);return Fn&&_o(We,zs),ys}for(Es=k(We,Es);zs<Ke.length;zs++)Nr=as(Es,We,zs,Ke[zs],$t),Nr!==null&&(l&&Nr.alternate!==null&&Es.delete(Nr.key===null?zs:Nr.key),Ie=V(Nr,Ie,zs),Rs===null?ys=Nr:Rs.sibling=Nr,Rs=Nr);return l&&Es.forEach(function(Vl){return c(We,Vl)}),Fn&&_o(We,zs),ys}function gs(We,Ie,Ke,$t){var ys=M(Ke);if(typeof ys!="function")throw Error(n(150));if(Ke=ys.call(Ke),Ke==null)throw Error(n(151));for(var Rs=ys=null,Es=Ie,zs=Ie=0,Nr=null,wn=Ke.next();Es!==null&&!wn.done;zs++,wn=Ke.next()){Es.index>zs?(Nr=Es,Es=null):Nr=Es.sibling;var Vl=Ct(We,Es,wn.value,$t);if(Vl===null){Es===null&&(Es=Nr);break}l&&Es&&Vl.alternate===null&&c(We,Es),Ie=V(Vl,Ie,zs),Rs===null?ys=Vl:Rs.sibling=Vl,Rs=Vl,Es=Nr}if(wn.done)return y(We,Es),Fn&&_o(We,zs),ys;if(Es===null){for(;!wn.done;zs++,wn=Ke.next())wn=Tt(We,wn.value,$t),wn!==null&&(Ie=V(wn,Ie,zs),Rs===null?ys=wn:Rs.sibling=wn,Rs=wn);return Fn&&_o(We,zs),ys}for(Es=k(We,Es);!wn.done;zs++,wn=Ke.next())wn=as(Es,We,zs,wn.value,$t),wn!==null&&(l&&wn.alternate!==null&&Es.delete(wn.key===null?zs:wn.key),Ie=V(wn,Ie,zs),Rs===null?ys=wn:Rs.sibling=wn,Rs=wn);return l&&Es.forEach(function(h4){return c(We,h4)}),Fn&&_o(We,zs),ys}function er(We,Ie,Ke,$t){if(typeof Ke=="object"&&Ke!==null&&Ke.type===A&&Ke.key===null&&(Ke=Ke.props.children),typeof Ke=="object"&&Ke!==null){switch(Ke.$$typeof){case R:e:{for(var ys=Ke.key,Rs=Ie;Rs!==null;){if(Rs.key===ys){if(ys=Ke.type,ys===A){if(Rs.tag===7){y(We,Rs.sibling),Ie=F(Rs,Ke.props.children),Ie.return=We,We=Ie;break e}}else if(Rs.elementType===ys||typeof ys=="object"&&ys!==null&&ys.$$typeof===Z&&Wj(ys)===Rs.type){y(We,Rs.sibling),Ie=F(Rs,Ke.props),Ie.ref=Fd(We,Rs,Ke),Ie.return=We,We=Ie;break e}y(We,Rs);break}else c(We,Rs);Rs=Rs.sibling}Ke.type===A?(Ie=Bo(Ke.props.children,We.mode,$t,Ke.key),Ie.return=We,We=Ie):($t=Zh(Ke.type,Ke.key,Ke.props,null,We.mode,$t),$t.ref=Fd(We,Ie,Ke),$t.return=We,We=$t)}return ie(We);case _:e:{for(Rs=Ke.key;Ie!==null;){if(Ie.key===Rs)if(Ie.tag===4&&Ie.stateNode.containerInfo===Ke.containerInfo&&Ie.stateNode.implementation===Ke.implementation){y(We,Ie.sibling),Ie=F(Ie,Ke.children||[]),Ie.return=We,We=Ie;break e}else{y(We,Ie);break}else c(We,Ie);Ie=Ie.sibling}Ie=Vx(Ke,We.mode,$t),Ie.return=We,We=Ie}return ie(We);case Z:return Rs=Ke._init,er(We,Ie,Rs(Ke._payload),$t)}if(ye(Ke))return ps(We,Ie,Ke,$t);if(M(Ke))return gs(We,Ie,Ke,$t);Ah(We,Ke)}return typeof Ke=="string"&&Ke!==""||typeof Ke=="number"?(Ke=""+Ke,Ie!==null&&Ie.tag===6?(y(We,Ie.sibling),Ie=F(Ie,Ke),Ie.return=We,We=Ie):(y(We,Ie),Ie=Ux(Ke,We.mode,$t),Ie.return=We,We=Ie),ie(We)):y(We,Ie)}return er}var _c=Gj(!0),Kj=Gj(!1),kh=Pl(null),Dh=null,Tc=null,Jp=null;function ex(){Jp=Tc=Dh=null}function tx(l){var c=kh.current;Pn(kh),l._currentValue=c}function sx(l,c,y){for(;l!==null;){var k=l.alternate;if((l.childLanes&c)!==c?(l.childLanes|=c,k!==null&&(k.childLanes|=c)):k!==null&&(k.childLanes&c)!==c&&(k.childLanes|=c),l===y)break;l=l.return}}function Pc(l,c){Dh=l,Jp=Tc=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&c)!==0&&(ia=!0),l.firstContext=null)}function Ba(l){var c=l._currentValue;if(Jp!==l)if(l={context:l,memoizedValue:c,next:null},Tc===null){if(Dh===null)throw Error(n(308));Tc=l,Dh.dependencies={lanes:0,firstContext:l}}else Tc=Tc.next=l;return c}var To=null;function nx(l){To===null?To=[l]:To.push(l)}function Yj(l,c,y,k){var F=c.interleaved;return F===null?(y.next=y,nx(c)):(y.next=F.next,F.next=y),c.interleaved=y,tl(l,k)}function tl(l,c){l.lanes|=c;var y=l.alternate;for(y!==null&&(y.lanes|=c),y=l,l=l.return;l!==null;)l.childLanes|=c,y=l.alternate,y!==null&&(y.childLanes|=c),y=l,l=l.return;return y.tag===3?y.stateNode:null}var Il=!1;function rx(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Zj(l,c){l=l.updateQueue,c.updateQueue===l&&(c.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,effects:l.effects})}function sl(l,c){return{eventTime:l,lane:c,tag:0,payload:null,callback:null,next:null}}function Ml(l,c,y){var k=l.updateQueue;if(k===null)return null;if(k=k.shared,(Nn&2)!==0){var F=k.pending;return F===null?c.next=c:(c.next=F.next,F.next=c),k.pending=c,tl(l,y)}return F=k.interleaved,F===null?(c.next=c,nx(k)):(c.next=F.next,F.next=c),k.interleaved=c,tl(l,y)}function Rh(l,c,y){if(c=c.updateQueue,c!==null&&(c=c.shared,(y&4194240)!==0)){var k=c.lanes;k&=l.pendingLanes,y|=k,c.lanes=y,En(l,y)}}function Qj(l,c){var y=l.updateQueue,k=l.alternate;if(k!==null&&(k=k.updateQueue,y===k)){var F=null,V=null;if(y=y.firstBaseUpdate,y!==null){do{var ie={eventTime:y.eventTime,lane:y.lane,tag:y.tag,payload:y.payload,callback:y.callback,next:null};V===null?F=V=ie:V=V.next=ie,y=y.next}while(y!==null);V===null?F=V=c:V=V.next=c}else F=V=c;y={baseState:k.baseState,firstBaseUpdate:F,lastBaseUpdate:V,shared:k.shared,effects:k.effects},l.updateQueue=y;return}l=y.lastBaseUpdate,l===null?y.firstBaseUpdate=c:l.next=c,y.lastBaseUpdate=c}function Eh(l,c,y,k){var F=l.updateQueue;Il=!1;var V=F.firstBaseUpdate,ie=F.lastBaseUpdate,Ne=F.shared.pending;if(Ne!==null){F.shared.pending=null;var Re=Ne,Ze=Re.next;Re.next=null,ie===null?V=Ze:ie.next=Ze,ie=Re;var At=l.alternate;At!==null&&(At=At.updateQueue,Ne=At.lastBaseUpdate,Ne!==ie&&(Ne===null?At.firstBaseUpdate=Ze:Ne.next=Ze,At.lastBaseUpdate=Re))}if(V!==null){var Tt=F.baseState;ie=0,At=Ze=Re=null,Ne=V;do{var Ct=Ne.lane,as=Ne.eventTime;if((k&Ct)===Ct){At!==null&&(At=At.next={eventTime:as,lane:0,tag:Ne.tag,payload:Ne.payload,callback:Ne.callback,next:null});e:{var ps=l,gs=Ne;switch(Ct=c,as=y,gs.tag){case 1:if(ps=gs.payload,typeof ps=="function"){Tt=ps.call(as,Tt,Ct);break e}Tt=ps;break e;case 3:ps.flags=ps.flags&-65537|128;case 0:if(ps=gs.payload,Ct=typeof ps=="function"?ps.call(as,Tt,Ct):ps,Ct==null)break e;Tt=z({},Tt,Ct);break e;case 2:Il=!0}}Ne.callback!==null&&Ne.lane!==0&&(l.flags|=64,Ct=F.effects,Ct===null?F.effects=[Ne]:Ct.push(Ne))}else as={eventTime:as,lane:Ct,tag:Ne.tag,payload:Ne.payload,callback:Ne.callback,next:null},At===null?(Ze=At=as,Re=Tt):At=At.next=as,ie|=Ct;if(Ne=Ne.next,Ne===null){if(Ne=F.shared.pending,Ne===null)break;Ct=Ne,Ne=Ct.next,Ct.next=null,F.lastBaseUpdate=Ct,F.shared.pending=null}}while(!0);if(At===null&&(Re=Tt),F.baseState=Re,F.firstBaseUpdate=Ze,F.lastBaseUpdate=At,c=F.shared.interleaved,c!==null){F=c;do ie|=F.lane,F=F.next;while(F!==c)}else V===null&&(F.shared.lanes=0);Lo|=ie,l.lanes=ie,l.memoizedState=Tt}}function Xj(l,c,y){if(l=c.effects,c.effects=null,l!==null)for(c=0;c<l.length;c++){var k=l[c],F=k.callback;if(F!==null){if(k.callback=null,k=y,typeof F!="function")throw Error(n(191,F));F.call(k)}}}var Bd={},ki=Pl(Bd),$d=Pl(Bd),qd=Pl(Bd);function Po(l){if(l===Bd)throw Error(n(174));return l}function ax(l,c){switch(Dn(qd,c),Dn($d,l),Dn(ki,Bd),l=c.nodeType,l){case 9:case 11:c=(c=c.documentElement)?c.namespaceURI:It(null,"");break;default:l=l===8?c.parentNode:c,c=l.namespaceURI||null,l=l.tagName,c=It(c,l)}Pn(ki),Dn(ki,c)}function Oc(){Pn(ki),Pn($d),Pn(qd)}function Jj(l){Po(qd.current);var c=Po(ki.current),y=It(c,l.type);c!==y&&(Dn($d,l),Dn(ki,y))}function ix(l){$d.current===l&&(Pn(ki),Pn($d))}var Un=Pl(0);function _h(l){for(var c=l;c!==null;){if(c.tag===13){var y=c.memoizedState;if(y!==null&&(y=y.dehydrated,y===null||y.data==="$?"||y.data==="$!"))return c}else if(c.tag===19&&c.memoizedProps.revealOrder!==void 0){if((c.flags&128)!==0)return c}else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===l)break;for(;c.sibling===null;){if(c.return===null||c.return===l)return null;c=c.return}c.sibling.return=c.return,c=c.sibling}return null}var lx=[];function ox(){for(var l=0;l<lx.length;l++)lx[l]._workInProgressVersionPrimary=null;lx.length=0}var Th=S.ReactCurrentDispatcher,cx=S.ReactCurrentBatchConfig,Oo=0,Vn=null,mr=null,br=null,Ph=!1,zd=!1,Ud=0,OT=0;function Br(){throw Error(n(321))}function dx(l,c){if(c===null)return!1;for(var y=0;y<c.length&&y<l.length;y++)if(!ei(l[y],c[y]))return!1;return!0}function ux(l,c,y,k,F,V){if(Oo=V,Vn=c,c.memoizedState=null,c.updateQueue=null,c.lanes=0,Th.current=l===null||l.memoizedState===null?FT:BT,l=y(k,F),zd){V=0;do{if(zd=!1,Ud=0,25<=V)throw Error(n(301));V+=1,br=mr=null,c.updateQueue=null,Th.current=$T,l=y(k,F)}while(zd)}if(Th.current=Ih,c=mr!==null&&mr.next!==null,Oo=0,br=mr=Vn=null,Ph=!1,c)throw Error(n(300));return l}function hx(){var l=Ud!==0;return Ud=0,l}function Di(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return br===null?Vn.memoizedState=br=l:br=br.next=l,br}function $a(){if(mr===null){var l=Vn.alternate;l=l!==null?l.memoizedState:null}else l=mr.next;var c=br===null?Vn.memoizedState:br.next;if(c!==null)br=c,mr=l;else{if(l===null)throw Error(n(310));mr=l,l={memoizedState:mr.memoizedState,baseState:mr.baseState,baseQueue:mr.baseQueue,queue:mr.queue,next:null},br===null?Vn.memoizedState=br=l:br=br.next=l}return br}function Vd(l,c){return typeof c=="function"?c(l):c}function mx(l){var c=$a(),y=c.queue;if(y===null)throw Error(n(311));y.lastRenderedReducer=l;var k=mr,F=k.baseQueue,V=y.pending;if(V!==null){if(F!==null){var ie=F.next;F.next=V.next,V.next=ie}k.baseQueue=F=V,y.pending=null}if(F!==null){V=F.next,k=k.baseState;var Ne=ie=null,Re=null,Ze=V;do{var At=Ze.lane;if((Oo&At)===At)Re!==null&&(Re=Re.next={lane:0,action:Ze.action,hasEagerState:Ze.hasEagerState,eagerState:Ze.eagerState,next:null}),k=Ze.hasEagerState?Ze.eagerState:l(k,Ze.action);else{var Tt={lane:At,action:Ze.action,hasEagerState:Ze.hasEagerState,eagerState:Ze.eagerState,next:null};Re===null?(Ne=Re=Tt,ie=k):Re=Re.next=Tt,Vn.lanes|=At,Lo|=At}Ze=Ze.next}while(Ze!==null&&Ze!==V);Re===null?ie=k:Re.next=Ne,ei(k,c.memoizedState)||(ia=!0),c.memoizedState=k,c.baseState=ie,c.baseQueue=Re,y.lastRenderedState=k}if(l=y.interleaved,l!==null){F=l;do V=F.lane,Vn.lanes|=V,Lo|=V,F=F.next;while(F!==l)}else F===null&&(y.lanes=0);return[c.memoizedState,y.dispatch]}function fx(l){var c=$a(),y=c.queue;if(y===null)throw Error(n(311));y.lastRenderedReducer=l;var k=y.dispatch,F=y.pending,V=c.memoizedState;if(F!==null){y.pending=null;var ie=F=F.next;do V=l(V,ie.action),ie=ie.next;while(ie!==F);ei(V,c.memoizedState)||(ia=!0),c.memoizedState=V,c.baseQueue===null&&(c.baseState=V),y.lastRenderedState=V}return[V,k]}function eN(){}function tN(l,c){var y=Vn,k=$a(),F=c(),V=!ei(k.memoizedState,F);if(V&&(k.memoizedState=F,ia=!0),k=k.queue,px(rN.bind(null,y,k,l),[l]),k.getSnapshot!==c||V||br!==null&&br.memoizedState.tag&1){if(y.flags|=2048,Hd(9,nN.bind(null,y,k,F,c),void 0,null),jr===null)throw Error(n(349));(Oo&30)!==0||sN(y,c,F)}return F}function sN(l,c,y){l.flags|=16384,l={getSnapshot:c,value:y},c=Vn.updateQueue,c===null?(c={lastEffect:null,stores:null},Vn.updateQueue=c,c.stores=[l]):(y=c.stores,y===null?c.stores=[l]:y.push(l))}function nN(l,c,y,k){c.value=y,c.getSnapshot=k,aN(c)&&iN(l)}function rN(l,c,y){return y(function(){aN(c)&&iN(l)})}function aN(l){var c=l.getSnapshot;l=l.value;try{var y=c();return!ei(l,y)}catch{return!0}}function iN(l){var c=tl(l,1);c!==null&&ai(c,l,1,-1)}function lN(l){var c=Di();return typeof l=="function"&&(l=l()),c.memoizedState=c.baseState=l,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Vd,lastRenderedState:l},c.queue=l,l=l.dispatch=MT.bind(null,Vn,l),[c.memoizedState,l]}function Hd(l,c,y,k){return l={tag:l,create:c,destroy:y,deps:k,next:null},c=Vn.updateQueue,c===null?(c={lastEffect:null,stores:null},Vn.updateQueue=c,c.lastEffect=l.next=l):(y=c.lastEffect,y===null?c.lastEffect=l.next=l:(k=y.next,y.next=l,l.next=k,c.lastEffect=l)),l}function oN(){return $a().memoizedState}function Oh(l,c,y,k){var F=Di();Vn.flags|=l,F.memoizedState=Hd(1|c,y,void 0,k===void 0?null:k)}function Lh(l,c,y,k){var F=$a();k=k===void 0?null:k;var V=void 0;if(mr!==null){var ie=mr.memoizedState;if(V=ie.destroy,k!==null&&dx(k,ie.deps)){F.memoizedState=Hd(c,y,V,k);return}}Vn.flags|=l,F.memoizedState=Hd(1|c,y,V,k)}function cN(l,c){return Oh(8390656,8,l,c)}function px(l,c){return Lh(2048,8,l,c)}function dN(l,c){return Lh(4,2,l,c)}function uN(l,c){return Lh(4,4,l,c)}function hN(l,c){if(typeof c=="function")return l=l(),c(l),function(){c(null)};if(c!=null)return l=l(),c.current=l,function(){c.current=null}}function mN(l,c,y){return y=y!=null?y.concat([l]):null,Lh(4,4,hN.bind(null,c,l),y)}function xx(){}function fN(l,c){var y=$a();c=c===void 0?null:c;var k=y.memoizedState;return k!==null&&c!==null&&dx(c,k[1])?k[0]:(y.memoizedState=[l,c],l)}function pN(l,c){var y=$a();c=c===void 0?null:c;var k=y.memoizedState;return k!==null&&c!==null&&dx(c,k[1])?k[0]:(l=l(),y.memoizedState=[l,c],l)}function xN(l,c,y){return(Oo&21)===0?(l.baseState&&(l.baseState=!1,ia=!0),l.memoizedState=y):(ei(y,c)||(y=Ft(),Vn.lanes|=y,Lo|=y,l.baseState=!0),c)}function LT(l,c){var y=Hs;Hs=y!==0&&4>y?y:4,l(!0);var k=cx.transition;cx.transition={};try{l(!1),c()}finally{Hs=y,cx.transition=k}}function gN(){return $a().memoizedState}function IT(l,c,y){var k=ql(l);if(y={lane:k,action:y,hasEagerState:!1,eagerState:null,next:null},vN(l))yN(c,y);else if(y=Yj(l,c,y,k),y!==null){var F=Yr();ai(y,l,k,F),bN(y,c,k)}}function MT(l,c,y){var k=ql(l),F={lane:k,action:y,hasEagerState:!1,eagerState:null,next:null};if(vN(l))yN(c,F);else{var V=l.alternate;if(l.lanes===0&&(V===null||V.lanes===0)&&(V=c.lastRenderedReducer,V!==null))try{var ie=c.lastRenderedState,Ne=V(ie,y);if(F.hasEagerState=!0,F.eagerState=Ne,ei(Ne,ie)){var Re=c.interleaved;Re===null?(F.next=F,nx(c)):(F.next=Re.next,Re.next=F),c.interleaved=F;return}}catch{}finally{}y=Yj(l,c,F,k),y!==null&&(F=Yr(),ai(y,l,k,F),bN(y,c,k))}}function vN(l){var c=l.alternate;return l===Vn||c!==null&&c===Vn}function yN(l,c){zd=Ph=!0;var y=l.pending;y===null?c.next=c:(c.next=y.next,y.next=c),l.pending=c}function bN(l,c,y){if((y&4194240)!==0){var k=c.lanes;k&=l.pendingLanes,y|=k,c.lanes=y,En(l,y)}}var Ih={readContext:Ba,useCallback:Br,useContext:Br,useEffect:Br,useImperativeHandle:Br,useInsertionEffect:Br,useLayoutEffect:Br,useMemo:Br,useReducer:Br,useRef:Br,useState:Br,useDebugValue:Br,useDeferredValue:Br,useTransition:Br,useMutableSource:Br,useSyncExternalStore:Br,useId:Br,unstable_isNewReconciler:!1},FT={readContext:Ba,useCallback:function(l,c){return Di().memoizedState=[l,c===void 0?null:c],l},useContext:Ba,useEffect:cN,useImperativeHandle:function(l,c,y){return y=y!=null?y.concat([l]):null,Oh(4194308,4,hN.bind(null,c,l),y)},useLayoutEffect:function(l,c){return Oh(4194308,4,l,c)},useInsertionEffect:function(l,c){return Oh(4,2,l,c)},useMemo:function(l,c){var y=Di();return c=c===void 0?null:c,l=l(),y.memoizedState=[l,c],l},useReducer:function(l,c,y){var k=Di();return c=y!==void 0?y(c):c,k.memoizedState=k.baseState=c,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:c},k.queue=l,l=l.dispatch=IT.bind(null,Vn,l),[k.memoizedState,l]},useRef:function(l){var c=Di();return l={current:l},c.memoizedState=l},useState:lN,useDebugValue:xx,useDeferredValue:function(l){return Di().memoizedState=l},useTransition:function(){var l=lN(!1),c=l[0];return l=LT.bind(null,l[1]),Di().memoizedState=l,[c,l]},useMutableSource:function(){},useSyncExternalStore:function(l,c,y){var k=Vn,F=Di();if(Fn){if(y===void 0)throw Error(n(407));y=y()}else{if(y=c(),jr===null)throw Error(n(349));(Oo&30)!==0||sN(k,c,y)}F.memoizedState=y;var V={value:y,getSnapshot:c};return F.queue=V,cN(rN.bind(null,k,V,l),[l]),k.flags|=2048,Hd(9,nN.bind(null,k,V,y,c),void 0,null),y},useId:function(){var l=Di(),c=jr.identifierPrefix;if(Fn){var y=el,k=Ji;y=(k&~(1<<32-vs(k)-1)).toString(32)+y,c=":"+c+"R"+y,y=Ud++,0<y&&(c+="H"+y.toString(32)),c+=":"}else y=OT++,c=":"+c+"r"+y.toString(32)+":";return l.memoizedState=c},unstable_isNewReconciler:!1},BT={readContext:Ba,useCallback:fN,useContext:Ba,useEffect:px,useImperativeHandle:mN,useInsertionEffect:dN,useLayoutEffect:uN,useMemo:pN,useReducer:mx,useRef:oN,useState:function(){return mx(Vd)},useDebugValue:xx,useDeferredValue:function(l){var c=$a();return xN(c,mr.memoizedState,l)},useTransition:function(){var l=mx(Vd)[0],c=$a().memoizedState;return[l,c]},useMutableSource:eN,useSyncExternalStore:tN,useId:gN,unstable_isNewReconciler:!1},$T={readContext:Ba,useCallback:fN,useContext:Ba,useEffect:px,useImperativeHandle:mN,useInsertionEffect:dN,useLayoutEffect:uN,useMemo:pN,useReducer:fx,useRef:oN,useState:function(){return fx(Vd)},useDebugValue:xx,useDeferredValue:function(l){var c=$a();return mr===null?c.memoizedState=l:xN(c,mr.memoizedState,l)},useTransition:function(){var l=fx(Vd)[0],c=$a().memoizedState;return[l,c]},useMutableSource:eN,useSyncExternalStore:tN,useId:gN,unstable_isNewReconciler:!1};function si(l,c){if(l&&l.defaultProps){c=z({},c),l=l.defaultProps;for(var y in l)c[y]===void 0&&(c[y]=l[y]);return c}return c}function gx(l,c,y,k){c=l.memoizedState,y=y(k,c),y=y==null?c:z({},c,y),l.memoizedState=y,l.lanes===0&&(l.updateQueue.baseState=y)}var Mh={isMounted:function(l){return(l=l._reactInternals)?ft(l)===l:!1},enqueueSetState:function(l,c,y){l=l._reactInternals;var k=Yr(),F=ql(l),V=sl(k,F);V.payload=c,y!=null&&(V.callback=y),c=Ml(l,V,F),c!==null&&(ai(c,l,F,k),Rh(c,l,F))},enqueueReplaceState:function(l,c,y){l=l._reactInternals;var k=Yr(),F=ql(l),V=sl(k,F);V.tag=1,V.payload=c,y!=null&&(V.callback=y),c=Ml(l,V,F),c!==null&&(ai(c,l,F,k),Rh(c,l,F))},enqueueForceUpdate:function(l,c){l=l._reactInternals;var y=Yr(),k=ql(l),F=sl(y,k);F.tag=2,c!=null&&(F.callback=c),c=Ml(l,F,k),c!==null&&(ai(c,l,k,y),Rh(c,l,k))}};function jN(l,c,y,k,F,V,ie){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(k,V,ie):c.prototype&&c.prototype.isPureReactComponent?!_d(y,k)||!_d(F,V):!0}function NN(l,c,y){var k=!1,F=Ol,V=c.contextType;return typeof V=="object"&&V!==null?V=Ba(V):(F=aa(c)?Ro:Fr.current,k=c.contextTypes,V=(k=k!=null)?kc(l,F):Ol),c=new c(y,V),l.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,c.updater=Mh,l.stateNode=c,c._reactInternals=l,k&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=F,l.__reactInternalMemoizedMaskedChildContext=V),c}function wN(l,c,y,k){l=c.state,typeof c.componentWillReceiveProps=="function"&&c.componentWillReceiveProps(y,k),typeof c.UNSAFE_componentWillReceiveProps=="function"&&c.UNSAFE_componentWillReceiveProps(y,k),c.state!==l&&Mh.enqueueReplaceState(c,c.state,null)}function vx(l,c,y,k){var F=l.stateNode;F.props=y,F.state=l.memoizedState,F.refs={},rx(l);var V=c.contextType;typeof V=="object"&&V!==null?F.context=Ba(V):(V=aa(c)?Ro:Fr.current,F.context=kc(l,V)),F.state=l.memoizedState,V=c.getDerivedStateFromProps,typeof V=="function"&&(gx(l,c,V,y),F.state=l.memoizedState),typeof c.getDerivedStateFromProps=="function"||typeof F.getSnapshotBeforeUpdate=="function"||typeof F.UNSAFE_componentWillMount!="function"&&typeof F.componentWillMount!="function"||(c=F.state,typeof F.componentWillMount=="function"&&F.componentWillMount(),typeof F.UNSAFE_componentWillMount=="function"&&F.UNSAFE_componentWillMount(),c!==F.state&&Mh.enqueueReplaceState(F,F.state,null),Eh(l,y,F,k),F.state=l.memoizedState),typeof F.componentDidMount=="function"&&(l.flags|=4194308)}function Lc(l,c){try{var y="",k=c;do y+=K(k),k=k.return;while(k);var F=y}catch(V){F=`
Error generating stack: `+V.message+`
`+V.stack}return{value:l,source:c,stack:F,digest:null}}function yx(l,c,y){return{value:l,source:null,stack:y??null,digest:c??null}}function bx(l,c){try{console.error(c.value)}catch(y){setTimeout(function(){throw y})}}var qT=typeof WeakMap=="function"?WeakMap:Map;function SN(l,c,y){y=sl(-1,y),y.tag=3,y.payload={element:null};var k=c.value;return y.callback=function(){Vh||(Vh=!0,Lx=k),bx(l,c)},y}function CN(l,c,y){y=sl(-1,y),y.tag=3;var k=l.type.getDerivedStateFromError;if(typeof k=="function"){var F=c.value;y.payload=function(){return k(F)},y.callback=function(){bx(l,c)}}var V=l.stateNode;return V!==null&&typeof V.componentDidCatch=="function"&&(y.callback=function(){bx(l,c),typeof k!="function"&&(Bl===null?Bl=new Set([this]):Bl.add(this));var ie=c.stack;this.componentDidCatch(c.value,{componentStack:ie!==null?ie:""})}),y}function AN(l,c,y){var k=l.pingCache;if(k===null){k=l.pingCache=new qT;var F=new Set;k.set(c,F)}else F=k.get(c),F===void 0&&(F=new Set,k.set(c,F));F.has(y)||(F.add(y),l=t4.bind(null,l,c,y),c.then(l,l))}function kN(l){do{var c;if((c=l.tag===13)&&(c=l.memoizedState,c=c!==null?c.dehydrated!==null:!0),c)return l;l=l.return}while(l!==null);return null}function DN(l,c,y,k,F){return(l.mode&1)===0?(l===c?l.flags|=65536:(l.flags|=128,y.flags|=131072,y.flags&=-52805,y.tag===1&&(y.alternate===null?y.tag=17:(c=sl(-1,1),c.tag=2,Ml(y,c,1))),y.lanes|=1),l):(l.flags|=65536,l.lanes=F,l)}var zT=S.ReactCurrentOwner,ia=!1;function Kr(l,c,y,k){c.child=l===null?Kj(c,null,y,k):_c(c,l.child,y,k)}function RN(l,c,y,k,F){y=y.render;var V=c.ref;return Pc(c,F),k=ux(l,c,y,k,V,F),y=hx(),l!==null&&!ia?(c.updateQueue=l.updateQueue,c.flags&=-2053,l.lanes&=~F,nl(l,c,F)):(Fn&&y&&Kp(c),c.flags|=1,Kr(l,c,k,F),c.child)}function EN(l,c,y,k,F){if(l===null){var V=y.type;return typeof V=="function"&&!zx(V)&&V.defaultProps===void 0&&y.compare===null&&y.defaultProps===void 0?(c.tag=15,c.type=V,_N(l,c,V,k,F)):(l=Zh(y.type,null,k,c,c.mode,F),l.ref=c.ref,l.return=c,c.child=l)}if(V=l.child,(l.lanes&F)===0){var ie=V.memoizedProps;if(y=y.compare,y=y!==null?y:_d,y(ie,k)&&l.ref===c.ref)return nl(l,c,F)}return c.flags|=1,l=Ul(V,k),l.ref=c.ref,l.return=c,c.child=l}function _N(l,c,y,k,F){if(l!==null){var V=l.memoizedProps;if(_d(V,k)&&l.ref===c.ref)if(ia=!1,c.pendingProps=k=V,(l.lanes&F)!==0)(l.flags&131072)!==0&&(ia=!0);else return c.lanes=l.lanes,nl(l,c,F)}return jx(l,c,y,k,F)}function TN(l,c,y){var k=c.pendingProps,F=k.children,V=l!==null?l.memoizedState:null;if(k.mode==="hidden")if((c.mode&1)===0)c.memoizedState={baseLanes:0,cachePool:null,transitions:null},Dn(Mc,wa),wa|=y;else{if((y&1073741824)===0)return l=V!==null?V.baseLanes|y:y,c.lanes=c.childLanes=1073741824,c.memoizedState={baseLanes:l,cachePool:null,transitions:null},c.updateQueue=null,Dn(Mc,wa),wa|=l,null;c.memoizedState={baseLanes:0,cachePool:null,transitions:null},k=V!==null?V.baseLanes:y,Dn(Mc,wa),wa|=k}else V!==null?(k=V.baseLanes|y,c.memoizedState=null):k=y,Dn(Mc,wa),wa|=k;return Kr(l,c,F,y),c.child}function PN(l,c){var y=c.ref;(l===null&&y!==null||l!==null&&l.ref!==y)&&(c.flags|=512,c.flags|=2097152)}function jx(l,c,y,k,F){var V=aa(y)?Ro:Fr.current;return V=kc(c,V),Pc(c,F),y=ux(l,c,y,k,V,F),k=hx(),l!==null&&!ia?(c.updateQueue=l.updateQueue,c.flags&=-2053,l.lanes&=~F,nl(l,c,F)):(Fn&&k&&Kp(c),c.flags|=1,Kr(l,c,y,F),c.child)}function ON(l,c,y,k,F){if(aa(y)){var V=!0;jh(c)}else V=!1;if(Pc(c,F),c.stateNode===null)Bh(l,c),NN(c,y,k),vx(c,y,k,F),k=!0;else if(l===null){var ie=c.stateNode,Ne=c.memoizedProps;ie.props=Ne;var Re=ie.context,Ze=y.contextType;typeof Ze=="object"&&Ze!==null?Ze=Ba(Ze):(Ze=aa(y)?Ro:Fr.current,Ze=kc(c,Ze));var At=y.getDerivedStateFromProps,Tt=typeof At=="function"||typeof ie.getSnapshotBeforeUpdate=="function";Tt||typeof ie.UNSAFE_componentWillReceiveProps!="function"&&typeof ie.componentWillReceiveProps!="function"||(Ne!==k||Re!==Ze)&&wN(c,ie,k,Ze),Il=!1;var Ct=c.memoizedState;ie.state=Ct,Eh(c,k,ie,F),Re=c.memoizedState,Ne!==k||Ct!==Re||ra.current||Il?(typeof At=="function"&&(gx(c,y,At,k),Re=c.memoizedState),(Ne=Il||jN(c,y,Ne,k,Ct,Re,Ze))?(Tt||typeof ie.UNSAFE_componentWillMount!="function"&&typeof ie.componentWillMount!="function"||(typeof ie.componentWillMount=="function"&&ie.componentWillMount(),typeof ie.UNSAFE_componentWillMount=="function"&&ie.UNSAFE_componentWillMount()),typeof ie.componentDidMount=="function"&&(c.flags|=4194308)):(typeof ie.componentDidMount=="function"&&(c.flags|=4194308),c.memoizedProps=k,c.memoizedState=Re),ie.props=k,ie.state=Re,ie.context=Ze,k=Ne):(typeof ie.componentDidMount=="function"&&(c.flags|=4194308),k=!1)}else{ie=c.stateNode,Zj(l,c),Ne=c.memoizedProps,Ze=c.type===c.elementType?Ne:si(c.type,Ne),ie.props=Ze,Tt=c.pendingProps,Ct=ie.context,Re=y.contextType,typeof Re=="object"&&Re!==null?Re=Ba(Re):(Re=aa(y)?Ro:Fr.current,Re=kc(c,Re));var as=y.getDerivedStateFromProps;(At=typeof as=="function"||typeof ie.getSnapshotBeforeUpdate=="function")||typeof ie.UNSAFE_componentWillReceiveProps!="function"&&typeof ie.componentWillReceiveProps!="function"||(Ne!==Tt||Ct!==Re)&&wN(c,ie,k,Re),Il=!1,Ct=c.memoizedState,ie.state=Ct,Eh(c,k,ie,F);var ps=c.memoizedState;Ne!==Tt||Ct!==ps||ra.current||Il?(typeof as=="function"&&(gx(c,y,as,k),ps=c.memoizedState),(Ze=Il||jN(c,y,Ze,k,Ct,ps,Re)||!1)?(At||typeof ie.UNSAFE_componentWillUpdate!="function"&&typeof ie.componentWillUpdate!="function"||(typeof ie.componentWillUpdate=="function"&&ie.componentWillUpdate(k,ps,Re),typeof ie.UNSAFE_componentWillUpdate=="function"&&ie.UNSAFE_componentWillUpdate(k,ps,Re)),typeof ie.componentDidUpdate=="function"&&(c.flags|=4),typeof ie.getSnapshotBeforeUpdate=="function"&&(c.flags|=1024)):(typeof ie.componentDidUpdate!="function"||Ne===l.memoizedProps&&Ct===l.memoizedState||(c.flags|=4),typeof ie.getSnapshotBeforeUpdate!="function"||Ne===l.memoizedProps&&Ct===l.memoizedState||(c.flags|=1024),c.memoizedProps=k,c.memoizedState=ps),ie.props=k,ie.state=ps,ie.context=Re,k=Ze):(typeof ie.componentDidUpdate!="function"||Ne===l.memoizedProps&&Ct===l.memoizedState||(c.flags|=4),typeof ie.getSnapshotBeforeUpdate!="function"||Ne===l.memoizedProps&&Ct===l.memoizedState||(c.flags|=1024),k=!1)}return Nx(l,c,y,k,V,F)}function Nx(l,c,y,k,F,V){PN(l,c);var ie=(c.flags&128)!==0;if(!k&&!ie)return F&&Bj(c,y,!1),nl(l,c,V);k=c.stateNode,zT.current=c;var Ne=ie&&typeof y.getDerivedStateFromError!="function"?null:k.render();return c.flags|=1,l!==null&&ie?(c.child=_c(c,l.child,null,V),c.child=_c(c,null,Ne,V)):Kr(l,c,Ne,V),c.memoizedState=k.state,F&&Bj(c,y,!0),c.child}function LN(l){var c=l.stateNode;c.pendingContext?Mj(l,c.pendingContext,c.pendingContext!==c.context):c.context&&Mj(l,c.context,!1),ax(l,c.containerInfo)}function IN(l,c,y,k,F){return Ec(),Xp(F),c.flags|=256,Kr(l,c,y,k),c.child}var wx={dehydrated:null,treeContext:null,retryLane:0};function Sx(l){return{baseLanes:l,cachePool:null,transitions:null}}function MN(l,c,y){var k=c.pendingProps,F=Un.current,V=!1,ie=(c.flags&128)!==0,Ne;if((Ne=ie)||(Ne=l!==null&&l.memoizedState===null?!1:(F&2)!==0),Ne?(V=!0,c.flags&=-129):(l===null||l.memoizedState!==null)&&(F|=1),Dn(Un,F&1),l===null)return Qp(c),l=c.memoizedState,l!==null&&(l=l.dehydrated,l!==null)?((c.mode&1)===0?c.lanes=1:l.data==="$!"?c.lanes=8:c.lanes=1073741824,null):(ie=k.children,l=k.fallback,V?(k=c.mode,V=c.child,ie={mode:"hidden",children:ie},(k&1)===0&&V!==null?(V.childLanes=0,V.pendingProps=ie):V=Qh(ie,k,0,null),l=Bo(l,k,y,null),V.return=c,l.return=c,V.sibling=l,c.child=V,c.child.memoizedState=Sx(y),c.memoizedState=wx,l):Cx(c,ie));if(F=l.memoizedState,F!==null&&(Ne=F.dehydrated,Ne!==null))return UT(l,c,ie,k,Ne,F,y);if(V){V=k.fallback,ie=c.mode,F=l.child,Ne=F.sibling;var Re={mode:"hidden",children:k.children};return(ie&1)===0&&c.child!==F?(k=c.child,k.childLanes=0,k.pendingProps=Re,c.deletions=null):(k=Ul(F,Re),k.subtreeFlags=F.subtreeFlags&14680064),Ne!==null?V=Ul(Ne,V):(V=Bo(V,ie,y,null),V.flags|=2),V.return=c,k.return=c,k.sibling=V,c.child=k,k=V,V=c.child,ie=l.child.memoizedState,ie=ie===null?Sx(y):{baseLanes:ie.baseLanes|y,cachePool:null,transitions:ie.transitions},V.memoizedState=ie,V.childLanes=l.childLanes&~y,c.memoizedState=wx,k}return V=l.child,l=V.sibling,k=Ul(V,{mode:"visible",children:k.children}),(c.mode&1)===0&&(k.lanes=y),k.return=c,k.sibling=null,l!==null&&(y=c.deletions,y===null?(c.deletions=[l],c.flags|=16):y.push(l)),c.child=k,c.memoizedState=null,k}function Cx(l,c){return c=Qh({mode:"visible",children:c},l.mode,0,null),c.return=l,l.child=c}function Fh(l,c,y,k){return k!==null&&Xp(k),_c(c,l.child,null,y),l=Cx(c,c.pendingProps.children),l.flags|=2,c.memoizedState=null,l}function UT(l,c,y,k,F,V,ie){if(y)return c.flags&256?(c.flags&=-257,k=yx(Error(n(422))),Fh(l,c,ie,k)):c.memoizedState!==null?(c.child=l.child,c.flags|=128,null):(V=k.fallback,F=c.mode,k=Qh({mode:"visible",children:k.children},F,0,null),V=Bo(V,F,ie,null),V.flags|=2,k.return=c,V.return=c,k.sibling=V,c.child=k,(c.mode&1)!==0&&_c(c,l.child,null,ie),c.child.memoizedState=Sx(ie),c.memoizedState=wx,V);if((c.mode&1)===0)return Fh(l,c,ie,null);if(F.data==="$!"){if(k=F.nextSibling&&F.nextSibling.dataset,k)var Ne=k.dgst;return k=Ne,V=Error(n(419)),k=yx(V,k,void 0),Fh(l,c,ie,k)}if(Ne=(ie&l.childLanes)!==0,ia||Ne){if(k=jr,k!==null){switch(ie&-ie){case 4:F=2;break;case 16:F=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:F=32;break;case 536870912:F=268435456;break;default:F=0}F=(F&(k.suspendedLanes|ie))!==0?0:F,F!==0&&F!==V.retryLane&&(V.retryLane=F,tl(l,F),ai(k,l,F,-1))}return qx(),k=yx(Error(n(421))),Fh(l,c,ie,k)}return F.data==="$?"?(c.flags|=128,c.child=l.child,c=s4.bind(null,l),F._reactRetry=c,null):(l=V.treeContext,Na=Tl(F.nextSibling),ja=c,Fn=!0,ti=null,l!==null&&(Ma[Fa++]=Ji,Ma[Fa++]=el,Ma[Fa++]=Eo,Ji=l.id,el=l.overflow,Eo=c),c=Cx(c,k.children),c.flags|=4096,c)}function FN(l,c,y){l.lanes|=c;var k=l.alternate;k!==null&&(k.lanes|=c),sx(l.return,c,y)}function Ax(l,c,y,k,F){var V=l.memoizedState;V===null?l.memoizedState={isBackwards:c,rendering:null,renderingStartTime:0,last:k,tail:y,tailMode:F}:(V.isBackwards=c,V.rendering=null,V.renderingStartTime=0,V.last=k,V.tail=y,V.tailMode=F)}function BN(l,c,y){var k=c.pendingProps,F=k.revealOrder,V=k.tail;if(Kr(l,c,k.children,y),k=Un.current,(k&2)!==0)k=k&1|2,c.flags|=128;else{if(l!==null&&(l.flags&128)!==0)e:for(l=c.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&FN(l,y,c);else if(l.tag===19)FN(l,y,c);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===c)break e;for(;l.sibling===null;){if(l.return===null||l.return===c)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}k&=1}if(Dn(Un,k),(c.mode&1)===0)c.memoizedState=null;else switch(F){case"forwards":for(y=c.child,F=null;y!==null;)l=y.alternate,l!==null&&_h(l)===null&&(F=y),y=y.sibling;y=F,y===null?(F=c.child,c.child=null):(F=y.sibling,y.sibling=null),Ax(c,!1,F,y,V);break;case"backwards":for(y=null,F=c.child,c.child=null;F!==null;){if(l=F.alternate,l!==null&&_h(l)===null){c.child=F;break}l=F.sibling,F.sibling=y,y=F,F=l}Ax(c,!0,y,null,V);break;case"together":Ax(c,!1,null,null,void 0);break;default:c.memoizedState=null}return c.child}function Bh(l,c){(c.mode&1)===0&&l!==null&&(l.alternate=null,c.alternate=null,c.flags|=2)}function nl(l,c,y){if(l!==null&&(c.dependencies=l.dependencies),Lo|=c.lanes,(y&c.childLanes)===0)return null;if(l!==null&&c.child!==l.child)throw Error(n(153));if(c.child!==null){for(l=c.child,y=Ul(l,l.pendingProps),c.child=y,y.return=c;l.sibling!==null;)l=l.sibling,y=y.sibling=Ul(l,l.pendingProps),y.return=c;y.sibling=null}return c.child}function VT(l,c,y){switch(c.tag){case 3:LN(c),Ec();break;case 5:Jj(c);break;case 1:aa(c.type)&&jh(c);break;case 4:ax(c,c.stateNode.containerInfo);break;case 10:var k=c.type._context,F=c.memoizedProps.value;Dn(kh,k._currentValue),k._currentValue=F;break;case 13:if(k=c.memoizedState,k!==null)return k.dehydrated!==null?(Dn(Un,Un.current&1),c.flags|=128,null):(y&c.child.childLanes)!==0?MN(l,c,y):(Dn(Un,Un.current&1),l=nl(l,c,y),l!==null?l.sibling:null);Dn(Un,Un.current&1);break;case 19:if(k=(y&c.childLanes)!==0,(l.flags&128)!==0){if(k)return BN(l,c,y);c.flags|=128}if(F=c.memoizedState,F!==null&&(F.rendering=null,F.tail=null,F.lastEffect=null),Dn(Un,Un.current),k)break;return null;case 22:case 23:return c.lanes=0,TN(l,c,y)}return nl(l,c,y)}var $N,kx,qN,zN;$N=function(l,c){for(var y=c.child;y!==null;){if(y.tag===5||y.tag===6)l.appendChild(y.stateNode);else if(y.tag!==4&&y.child!==null){y.child.return=y,y=y.child;continue}if(y===c)break;for(;y.sibling===null;){if(y.return===null||y.return===c)return;y=y.return}y.sibling.return=y.return,y=y.sibling}},kx=function(){},qN=function(l,c,y,k){var F=l.memoizedProps;if(F!==k){l=c.stateNode,Po(ki.current);var V=null;switch(y){case"input":F=Pe(l,F),k=Pe(l,k),V=[];break;case"select":F=z({},F,{value:void 0}),k=z({},k,{value:void 0}),V=[];break;case"textarea":F=$e(l,F),k=$e(l,k),V=[];break;default:typeof F.onClick!="function"&&typeof k.onClick=="function"&&(l.onclick=vh)}Bs(y,k);var ie;y=null;for(Ze in F)if(!k.hasOwnProperty(Ze)&&F.hasOwnProperty(Ze)&&F[Ze]!=null)if(Ze==="style"){var Ne=F[Ze];for(ie in Ne)Ne.hasOwnProperty(ie)&&(y||(y={}),y[ie]="")}else Ze!=="dangerouslySetInnerHTML"&&Ze!=="children"&&Ze!=="suppressContentEditableWarning"&&Ze!=="suppressHydrationWarning"&&Ze!=="autoFocus"&&(a.hasOwnProperty(Ze)?V||(V=[]):(V=V||[]).push(Ze,null));for(Ze in k){var Re=k[Ze];if(Ne=F!=null?F[Ze]:void 0,k.hasOwnProperty(Ze)&&Re!==Ne&&(Re!=null||Ne!=null))if(Ze==="style")if(Ne){for(ie in Ne)!Ne.hasOwnProperty(ie)||Re&&Re.hasOwnProperty(ie)||(y||(y={}),y[ie]="");for(ie in Re)Re.hasOwnProperty(ie)&&Ne[ie]!==Re[ie]&&(y||(y={}),y[ie]=Re[ie])}else y||(V||(V=[]),V.push(Ze,y)),y=Re;else Ze==="dangerouslySetInnerHTML"?(Re=Re?Re.__html:void 0,Ne=Ne?Ne.__html:void 0,Re!=null&&Ne!==Re&&(V=V||[]).push(Ze,Re)):Ze==="children"?typeof Re!="string"&&typeof Re!="number"||(V=V||[]).push(Ze,""+Re):Ze!=="suppressContentEditableWarning"&&Ze!=="suppressHydrationWarning"&&(a.hasOwnProperty(Ze)?(Re!=null&&Ze==="onScroll"&&Tn("scroll",l),V||Ne===Re||(V=[])):(V=V||[]).push(Ze,Re))}y&&(V=V||[]).push("style",y);var Ze=V;(c.updateQueue=Ze)&&(c.flags|=4)}},zN=function(l,c,y,k){y!==k&&(c.flags|=4)};function Wd(l,c){if(!Fn)switch(l.tailMode){case"hidden":c=l.tail;for(var y=null;c!==null;)c.alternate!==null&&(y=c),c=c.sibling;y===null?l.tail=null:y.sibling=null;break;case"collapsed":y=l.tail;for(var k=null;y!==null;)y.alternate!==null&&(k=y),y=y.sibling;k===null?c||l.tail===null?l.tail=null:l.tail.sibling=null:k.sibling=null}}function $r(l){var c=l.alternate!==null&&l.alternate.child===l.child,y=0,k=0;if(c)for(var F=l.child;F!==null;)y|=F.lanes|F.childLanes,k|=F.subtreeFlags&14680064,k|=F.flags&14680064,F.return=l,F=F.sibling;else for(F=l.child;F!==null;)y|=F.lanes|F.childLanes,k|=F.subtreeFlags,k|=F.flags,F.return=l,F=F.sibling;return l.subtreeFlags|=k,l.childLanes=y,c}function HT(l,c,y){var k=c.pendingProps;switch(Yp(c),c.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return $r(c),null;case 1:return aa(c.type)&&bh(),$r(c),null;case 3:return k=c.stateNode,Oc(),Pn(ra),Pn(Fr),ox(),k.pendingContext&&(k.context=k.pendingContext,k.pendingContext=null),(l===null||l.child===null)&&(Ch(c)?c.flags|=4:l===null||l.memoizedState.isDehydrated&&(c.flags&256)===0||(c.flags|=1024,ti!==null&&(Fx(ti),ti=null))),kx(l,c),$r(c),null;case 5:ix(c);var F=Po(qd.current);if(y=c.type,l!==null&&c.stateNode!=null)qN(l,c,y,k,F),l.ref!==c.ref&&(c.flags|=512,c.flags|=2097152);else{if(!k){if(c.stateNode===null)throw Error(n(166));return $r(c),null}if(l=Po(ki.current),Ch(c)){k=c.stateNode,y=c.type;var V=c.memoizedProps;switch(k[Ai]=c,k[Id]=V,l=(c.mode&1)!==0,y){case"dialog":Tn("cancel",k),Tn("close",k);break;case"iframe":case"object":case"embed":Tn("load",k);break;case"video":case"audio":for(F=0;F<Pd.length;F++)Tn(Pd[F],k);break;case"source":Tn("error",k);break;case"img":case"image":case"link":Tn("error",k),Tn("load",k);break;case"details":Tn("toggle",k);break;case"input":et(k,V),Tn("invalid",k);break;case"select":k._wrapperState={wasMultiple:!!V.multiple},Tn("invalid",k);break;case"textarea":dt(k,V),Tn("invalid",k)}Bs(y,V),F=null;for(var ie in V)if(V.hasOwnProperty(ie)){var Ne=V[ie];ie==="children"?typeof Ne=="string"?k.textContent!==Ne&&(V.suppressHydrationWarning!==!0&&gh(k.textContent,Ne,l),F=["children",Ne]):typeof Ne=="number"&&k.textContent!==""+Ne&&(V.suppressHydrationWarning!==!0&&gh(k.textContent,Ne,l),F=["children",""+Ne]):a.hasOwnProperty(ie)&&Ne!=null&&ie==="onScroll"&&Tn("scroll",k)}switch(y){case"input":xe(k),ee(k,V,!0);break;case"textarea":xe(k),xt(k);break;case"select":case"option":break;default:typeof V.onClick=="function"&&(k.onclick=vh)}k=F,c.updateQueue=k,k!==null&&(c.flags|=4)}else{ie=F.nodeType===9?F:F.ownerDocument,l==="http://www.w3.org/1999/xhtml"&&(l=Mt(y)),l==="http://www.w3.org/1999/xhtml"?y==="script"?(l=ie.createElement("div"),l.innerHTML="<script><\/script>",l=l.removeChild(l.firstChild)):typeof k.is=="string"?l=ie.createElement(y,{is:k.is}):(l=ie.createElement(y),y==="select"&&(ie=l,k.multiple?ie.multiple=!0:k.size&&(ie.size=k.size))):l=ie.createElementNS(l,y),l[Ai]=c,l[Id]=k,$N(l,c,!1,!1),c.stateNode=l;e:{switch(ie=Ks(y,k),y){case"dialog":Tn("cancel",l),Tn("close",l),F=k;break;case"iframe":case"object":case"embed":Tn("load",l),F=k;break;case"video":case"audio":for(F=0;F<Pd.length;F++)Tn(Pd[F],l);F=k;break;case"source":Tn("error",l),F=k;break;case"img":case"image":case"link":Tn("error",l),Tn("load",l),F=k;break;case"details":Tn("toggle",l),F=k;break;case"input":et(l,k),F=Pe(l,k),Tn("invalid",l);break;case"option":F=k;break;case"select":l._wrapperState={wasMultiple:!!k.multiple},F=z({},k,{value:void 0}),Tn("invalid",l);break;case"textarea":dt(l,k),F=$e(l,k),Tn("invalid",l);break;default:F=k}Bs(y,F),Ne=F;for(V in Ne)if(Ne.hasOwnProperty(V)){var Re=Ne[V];V==="style"?_s(l,Re):V==="dangerouslySetInnerHTML"?(Re=Re?Re.__html:void 0,Re!=null&&pt(l,Re)):V==="children"?typeof Re=="string"?(y!=="textarea"||Re!=="")&&ht(l,Re):typeof Re=="number"&&ht(l,""+Re):V!=="suppressContentEditableWarning"&&V!=="suppressHydrationWarning"&&V!=="autoFocus"&&(a.hasOwnProperty(V)?Re!=null&&V==="onScroll"&&Tn("scroll",l):Re!=null&&C(l,V,Re,ie))}switch(y){case"input":xe(l),ee(l,k,!1);break;case"textarea":xe(l),xt(l);break;case"option":k.value!=null&&l.setAttribute("value",""+J(k.value));break;case"select":l.multiple=!!k.multiple,V=k.value,V!=null?Be(l,!!k.multiple,V,!1):k.defaultValue!=null&&Be(l,!!k.multiple,k.defaultValue,!0);break;default:typeof F.onClick=="function"&&(l.onclick=vh)}switch(y){case"button":case"input":case"select":case"textarea":k=!!k.autoFocus;break e;case"img":k=!0;break e;default:k=!1}}k&&(c.flags|=4)}c.ref!==null&&(c.flags|=512,c.flags|=2097152)}return $r(c),null;case 6:if(l&&c.stateNode!=null)zN(l,c,l.memoizedProps,k);else{if(typeof k!="string"&&c.stateNode===null)throw Error(n(166));if(y=Po(qd.current),Po(ki.current),Ch(c)){if(k=c.stateNode,y=c.memoizedProps,k[Ai]=c,(V=k.nodeValue!==y)&&(l=ja,l!==null))switch(l.tag){case 3:gh(k.nodeValue,y,(l.mode&1)!==0);break;case 5:l.memoizedProps.suppressHydrationWarning!==!0&&gh(k.nodeValue,y,(l.mode&1)!==0)}V&&(c.flags|=4)}else k=(y.nodeType===9?y:y.ownerDocument).createTextNode(k),k[Ai]=c,c.stateNode=k}return $r(c),null;case 13:if(Pn(Un),k=c.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(Fn&&Na!==null&&(c.mode&1)!==0&&(c.flags&128)===0)Hj(),Ec(),c.flags|=98560,V=!1;else if(V=Ch(c),k!==null&&k.dehydrated!==null){if(l===null){if(!V)throw Error(n(318));if(V=c.memoizedState,V=V!==null?V.dehydrated:null,!V)throw Error(n(317));V[Ai]=c}else Ec(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;$r(c),V=!1}else ti!==null&&(Fx(ti),ti=null),V=!0;if(!V)return c.flags&65536?c:null}return(c.flags&128)!==0?(c.lanes=y,c):(k=k!==null,k!==(l!==null&&l.memoizedState!==null)&&k&&(c.child.flags|=8192,(c.mode&1)!==0&&(l===null||(Un.current&1)!==0?fr===0&&(fr=3):qx())),c.updateQueue!==null&&(c.flags|=4),$r(c),null);case 4:return Oc(),kx(l,c),l===null&&Od(c.stateNode.containerInfo),$r(c),null;case 10:return tx(c.type._context),$r(c),null;case 17:return aa(c.type)&&bh(),$r(c),null;case 19:if(Pn(Un),V=c.memoizedState,V===null)return $r(c),null;if(k=(c.flags&128)!==0,ie=V.rendering,ie===null)if(k)Wd(V,!1);else{if(fr!==0||l!==null&&(l.flags&128)!==0)for(l=c.child;l!==null;){if(ie=_h(l),ie!==null){for(c.flags|=128,Wd(V,!1),k=ie.updateQueue,k!==null&&(c.updateQueue=k,c.flags|=4),c.subtreeFlags=0,k=y,y=c.child;y!==null;)V=y,l=k,V.flags&=14680066,ie=V.alternate,ie===null?(V.childLanes=0,V.lanes=l,V.child=null,V.subtreeFlags=0,V.memoizedProps=null,V.memoizedState=null,V.updateQueue=null,V.dependencies=null,V.stateNode=null):(V.childLanes=ie.childLanes,V.lanes=ie.lanes,V.child=ie.child,V.subtreeFlags=0,V.deletions=null,V.memoizedProps=ie.memoizedProps,V.memoizedState=ie.memoizedState,V.updateQueue=ie.updateQueue,V.type=ie.type,l=ie.dependencies,V.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),y=y.sibling;return Dn(Un,Un.current&1|2),c.child}l=l.sibling}V.tail!==null&&bt()>Fc&&(c.flags|=128,k=!0,Wd(V,!1),c.lanes=4194304)}else{if(!k)if(l=_h(ie),l!==null){if(c.flags|=128,k=!0,y=l.updateQueue,y!==null&&(c.updateQueue=y,c.flags|=4),Wd(V,!0),V.tail===null&&V.tailMode==="hidden"&&!ie.alternate&&!Fn)return $r(c),null}else 2*bt()-V.renderingStartTime>Fc&&y!==1073741824&&(c.flags|=128,k=!0,Wd(V,!1),c.lanes=4194304);V.isBackwards?(ie.sibling=c.child,c.child=ie):(y=V.last,y!==null?y.sibling=ie:c.child=ie,V.last=ie)}return V.tail!==null?(c=V.tail,V.rendering=c,V.tail=c.sibling,V.renderingStartTime=bt(),c.sibling=null,y=Un.current,Dn(Un,k?y&1|2:y&1),c):($r(c),null);case 22:case 23:return $x(),k=c.memoizedState!==null,l!==null&&l.memoizedState!==null!==k&&(c.flags|=8192),k&&(c.mode&1)!==0?(wa&1073741824)!==0&&($r(c),c.subtreeFlags&6&&(c.flags|=8192)):$r(c),null;case 24:return null;case 25:return null}throw Error(n(156,c.tag))}function WT(l,c){switch(Yp(c),c.tag){case 1:return aa(c.type)&&bh(),l=c.flags,l&65536?(c.flags=l&-65537|128,c):null;case 3:return Oc(),Pn(ra),Pn(Fr),ox(),l=c.flags,(l&65536)!==0&&(l&128)===0?(c.flags=l&-65537|128,c):null;case 5:return ix(c),null;case 13:if(Pn(Un),l=c.memoizedState,l!==null&&l.dehydrated!==null){if(c.alternate===null)throw Error(n(340));Ec()}return l=c.flags,l&65536?(c.flags=l&-65537|128,c):null;case 19:return Pn(Un),null;case 4:return Oc(),null;case 10:return tx(c.type._context),null;case 22:case 23:return $x(),null;case 24:return null;default:return null}}var $h=!1,qr=!1,GT=typeof WeakSet=="function"?WeakSet:Set,us=null;function Ic(l,c){var y=l.ref;if(y!==null)if(typeof y=="function")try{y(null)}catch(k){Kn(l,c,k)}else y.current=null}function Dx(l,c,y){try{y()}catch(k){Kn(l,c,k)}}var UN=!1;function KT(l,c){if($p=ya,l=jj(),Tp(l)){if("selectionStart"in l)var y={start:l.selectionStart,end:l.selectionEnd};else e:{y=(y=l.ownerDocument)&&y.defaultView||window;var k=y.getSelection&&y.getSelection();if(k&&k.rangeCount!==0){y=k.anchorNode;var F=k.anchorOffset,V=k.focusNode;k=k.focusOffset;try{y.nodeType,V.nodeType}catch{y=null;break e}var ie=0,Ne=-1,Re=-1,Ze=0,At=0,Tt=l,Ct=null;t:for(;;){for(var as;Tt!==y||F!==0&&Tt.nodeType!==3||(Ne=ie+F),Tt!==V||k!==0&&Tt.nodeType!==3||(Re=ie+k),Tt.nodeType===3&&(ie+=Tt.nodeValue.length),(as=Tt.firstChild)!==null;)Ct=Tt,Tt=as;for(;;){if(Tt===l)break t;if(Ct===y&&++Ze===F&&(Ne=ie),Ct===V&&++At===k&&(Re=ie),(as=Tt.nextSibling)!==null)break;Tt=Ct,Ct=Tt.parentNode}Tt=as}y=Ne===-1||Re===-1?null:{start:Ne,end:Re}}else y=null}y=y||{start:0,end:0}}else y=null;for(qp={focusedElem:l,selectionRange:y},ya=!1,us=c;us!==null;)if(c=us,l=c.child,(c.subtreeFlags&1028)!==0&&l!==null)l.return=c,us=l;else for(;us!==null;){c=us;try{var ps=c.alternate;if((c.flags&1024)!==0)switch(c.tag){case 0:case 11:case 15:break;case 1:if(ps!==null){var gs=ps.memoizedProps,er=ps.memoizedState,We=c.stateNode,Ie=We.getSnapshotBeforeUpdate(c.elementType===c.type?gs:si(c.type,gs),er);We.__reactInternalSnapshotBeforeUpdate=Ie}break;case 3:var Ke=c.stateNode.containerInfo;Ke.nodeType===1?Ke.textContent="":Ke.nodeType===9&&Ke.documentElement&&Ke.removeChild(Ke.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch($t){Kn(c,c.return,$t)}if(l=c.sibling,l!==null){l.return=c.return,us=l;break}us=c.return}return ps=UN,UN=!1,ps}function Gd(l,c,y){var k=c.updateQueue;if(k=k!==null?k.lastEffect:null,k!==null){var F=k=k.next;do{if((F.tag&l)===l){var V=F.destroy;F.destroy=void 0,V!==void 0&&Dx(c,y,V)}F=F.next}while(F!==k)}}function qh(l,c){if(c=c.updateQueue,c=c!==null?c.lastEffect:null,c!==null){var y=c=c.next;do{if((y.tag&l)===l){var k=y.create;y.destroy=k()}y=y.next}while(y!==c)}}function Rx(l){var c=l.ref;if(c!==null){var y=l.stateNode;switch(l.tag){case 5:l=y;break;default:l=y}typeof c=="function"?c(l):c.current=l}}function VN(l){var c=l.alternate;c!==null&&(l.alternate=null,VN(c)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(c=l.stateNode,c!==null&&(delete c[Ai],delete c[Id],delete c[Hp],delete c[ET],delete c[_T])),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function HN(l){return l.tag===5||l.tag===3||l.tag===4}function WN(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||HN(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function Ex(l,c,y){var k=l.tag;if(k===5||k===6)l=l.stateNode,c?y.nodeType===8?y.parentNode.insertBefore(l,c):y.insertBefore(l,c):(y.nodeType===8?(c=y.parentNode,c.insertBefore(l,y)):(c=y,c.appendChild(l)),y=y._reactRootContainer,y!=null||c.onclick!==null||(c.onclick=vh));else if(k!==4&&(l=l.child,l!==null))for(Ex(l,c,y),l=l.sibling;l!==null;)Ex(l,c,y),l=l.sibling}function _x(l,c,y){var k=l.tag;if(k===5||k===6)l=l.stateNode,c?y.insertBefore(l,c):y.appendChild(l);else if(k!==4&&(l=l.child,l!==null))for(_x(l,c,y),l=l.sibling;l!==null;)_x(l,c,y),l=l.sibling}var Tr=null,ni=!1;function Fl(l,c,y){for(y=y.child;y!==null;)GN(l,c,y),y=y.sibling}function GN(l,c,y){if(qt&&typeof qt.onCommitFiberUnmount=="function")try{qt.onCommitFiberUnmount(fs,y)}catch{}switch(y.tag){case 5:qr||Ic(y,c);case 6:var k=Tr,F=ni;Tr=null,Fl(l,c,y),Tr=k,ni=F,Tr!==null&&(ni?(l=Tr,y=y.stateNode,l.nodeType===8?l.parentNode.removeChild(y):l.removeChild(y)):Tr.removeChild(y.stateNode));break;case 18:Tr!==null&&(ni?(l=Tr,y=y.stateNode,l.nodeType===8?Vp(l.parentNode,y):l.nodeType===1&&Vp(l,y),Hr(l)):Vp(Tr,y.stateNode));break;case 4:k=Tr,F=ni,Tr=y.stateNode.containerInfo,ni=!0,Fl(l,c,y),Tr=k,ni=F;break;case 0:case 11:case 14:case 15:if(!qr&&(k=y.updateQueue,k!==null&&(k=k.lastEffect,k!==null))){F=k=k.next;do{var V=F,ie=V.destroy;V=V.tag,ie!==void 0&&((V&2)!==0||(V&4)!==0)&&Dx(y,c,ie),F=F.next}while(F!==k)}Fl(l,c,y);break;case 1:if(!qr&&(Ic(y,c),k=y.stateNode,typeof k.componentWillUnmount=="function"))try{k.props=y.memoizedProps,k.state=y.memoizedState,k.componentWillUnmount()}catch(Ne){Kn(y,c,Ne)}Fl(l,c,y);break;case 21:Fl(l,c,y);break;case 22:y.mode&1?(qr=(k=qr)||y.memoizedState!==null,Fl(l,c,y),qr=k):Fl(l,c,y);break;default:Fl(l,c,y)}}function KN(l){var c=l.updateQueue;if(c!==null){l.updateQueue=null;var y=l.stateNode;y===null&&(y=l.stateNode=new GT),c.forEach(function(k){var F=n4.bind(null,l,k);y.has(k)||(y.add(k),k.then(F,F))})}}function ri(l,c){var y=c.deletions;if(y!==null)for(var k=0;k<y.length;k++){var F=y[k];try{var V=l,ie=c,Ne=ie;e:for(;Ne!==null;){switch(Ne.tag){case 5:Tr=Ne.stateNode,ni=!1;break e;case 3:Tr=Ne.stateNode.containerInfo,ni=!0;break e;case 4:Tr=Ne.stateNode.containerInfo,ni=!0;break e}Ne=Ne.return}if(Tr===null)throw Error(n(160));GN(V,ie,F),Tr=null,ni=!1;var Re=F.alternate;Re!==null&&(Re.return=null),F.return=null}catch(Ze){Kn(F,c,Ze)}}if(c.subtreeFlags&12854)for(c=c.child;c!==null;)YN(c,l),c=c.sibling}function YN(l,c){var y=l.alternate,k=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:if(ri(c,l),Ri(l),k&4){try{Gd(3,l,l.return),qh(3,l)}catch(gs){Kn(l,l.return,gs)}try{Gd(5,l,l.return)}catch(gs){Kn(l,l.return,gs)}}break;case 1:ri(c,l),Ri(l),k&512&&y!==null&&Ic(y,y.return);break;case 5:if(ri(c,l),Ri(l),k&512&&y!==null&&Ic(y,y.return),l.flags&32){var F=l.stateNode;try{ht(F,"")}catch(gs){Kn(l,l.return,gs)}}if(k&4&&(F=l.stateNode,F!=null)){var V=l.memoizedProps,ie=y!==null?y.memoizedProps:V,Ne=l.type,Re=l.updateQueue;if(l.updateQueue=null,Re!==null)try{Ne==="input"&&V.type==="radio"&&V.name!=null&&kt(F,V),Ks(Ne,ie);var Ze=Ks(Ne,V);for(ie=0;ie<Re.length;ie+=2){var At=Re[ie],Tt=Re[ie+1];At==="style"?_s(F,Tt):At==="dangerouslySetInnerHTML"?pt(F,Tt):At==="children"?ht(F,Tt):C(F,At,Tt,Ze)}switch(Ne){case"input":vt(F,V);break;case"textarea":st(F,V);break;case"select":var Ct=F._wrapperState.wasMultiple;F._wrapperState.wasMultiple=!!V.multiple;var as=V.value;as!=null?Be(F,!!V.multiple,as,!1):Ct!==!!V.multiple&&(V.defaultValue!=null?Be(F,!!V.multiple,V.defaultValue,!0):Be(F,!!V.multiple,V.multiple?[]:"",!1))}F[Id]=V}catch(gs){Kn(l,l.return,gs)}}break;case 6:if(ri(c,l),Ri(l),k&4){if(l.stateNode===null)throw Error(n(162));F=l.stateNode,V=l.memoizedProps;try{F.nodeValue=V}catch(gs){Kn(l,l.return,gs)}}break;case 3:if(ri(c,l),Ri(l),k&4&&y!==null&&y.memoizedState.isDehydrated)try{Hr(c.containerInfo)}catch(gs){Kn(l,l.return,gs)}break;case 4:ri(c,l),Ri(l);break;case 13:ri(c,l),Ri(l),F=l.child,F.flags&8192&&(V=F.memoizedState!==null,F.stateNode.isHidden=V,!V||F.alternate!==null&&F.alternate.memoizedState!==null||(Ox=bt())),k&4&&KN(l);break;case 22:if(At=y!==null&&y.memoizedState!==null,l.mode&1?(qr=(Ze=qr)||At,ri(c,l),qr=Ze):ri(c,l),Ri(l),k&8192){if(Ze=l.memoizedState!==null,(l.stateNode.isHidden=Ze)&&!At&&(l.mode&1)!==0)for(us=l,At=l.child;At!==null;){for(Tt=us=At;us!==null;){switch(Ct=us,as=Ct.child,Ct.tag){case 0:case 11:case 14:case 15:Gd(4,Ct,Ct.return);break;case 1:Ic(Ct,Ct.return);var ps=Ct.stateNode;if(typeof ps.componentWillUnmount=="function"){k=Ct,y=Ct.return;try{c=k,ps.props=c.memoizedProps,ps.state=c.memoizedState,ps.componentWillUnmount()}catch(gs){Kn(k,y,gs)}}break;case 5:Ic(Ct,Ct.return);break;case 22:if(Ct.memoizedState!==null){XN(Tt);continue}}as!==null?(as.return=Ct,us=as):XN(Tt)}At=At.sibling}e:for(At=null,Tt=l;;){if(Tt.tag===5){if(At===null){At=Tt;try{F=Tt.stateNode,Ze?(V=F.style,typeof V.setProperty=="function"?V.setProperty("display","none","important"):V.display="none"):(Ne=Tt.stateNode,Re=Tt.memoizedProps.style,ie=Re!=null&&Re.hasOwnProperty("display")?Re.display:null,Ne.style.display=Pt("display",ie))}catch(gs){Kn(l,l.return,gs)}}}else if(Tt.tag===6){if(At===null)try{Tt.stateNode.nodeValue=Ze?"":Tt.memoizedProps}catch(gs){Kn(l,l.return,gs)}}else if((Tt.tag!==22&&Tt.tag!==23||Tt.memoizedState===null||Tt===l)&&Tt.child!==null){Tt.child.return=Tt,Tt=Tt.child;continue}if(Tt===l)break e;for(;Tt.sibling===null;){if(Tt.return===null||Tt.return===l)break e;At===Tt&&(At=null),Tt=Tt.return}At===Tt&&(At=null),Tt.sibling.return=Tt.return,Tt=Tt.sibling}}break;case 19:ri(c,l),Ri(l),k&4&&KN(l);break;case 21:break;default:ri(c,l),Ri(l)}}function Ri(l){var c=l.flags;if(c&2){try{e:{for(var y=l.return;y!==null;){if(HN(y)){var k=y;break e}y=y.return}throw Error(n(160))}switch(k.tag){case 5:var F=k.stateNode;k.flags&32&&(ht(F,""),k.flags&=-33);var V=WN(l);_x(l,V,F);break;case 3:case 4:var ie=k.stateNode.containerInfo,Ne=WN(l);Ex(l,Ne,ie);break;default:throw Error(n(161))}}catch(Re){Kn(l,l.return,Re)}l.flags&=-3}c&4096&&(l.flags&=-4097)}function YT(l,c,y){us=l,ZN(l)}function ZN(l,c,y){for(var k=(l.mode&1)!==0;us!==null;){var F=us,V=F.child;if(F.tag===22&&k){var ie=F.memoizedState!==null||$h;if(!ie){var Ne=F.alternate,Re=Ne!==null&&Ne.memoizedState!==null||qr;Ne=$h;var Ze=qr;if($h=ie,(qr=Re)&&!Ze)for(us=F;us!==null;)ie=us,Re=ie.child,ie.tag===22&&ie.memoizedState!==null?JN(F):Re!==null?(Re.return=ie,us=Re):JN(F);for(;V!==null;)us=V,ZN(V),V=V.sibling;us=F,$h=Ne,qr=Ze}QN(l)}else(F.subtreeFlags&8772)!==0&&V!==null?(V.return=F,us=V):QN(l)}}function QN(l){for(;us!==null;){var c=us;if((c.flags&8772)!==0){var y=c.alternate;try{if((c.flags&8772)!==0)switch(c.tag){case 0:case 11:case 15:qr||qh(5,c);break;case 1:var k=c.stateNode;if(c.flags&4&&!qr)if(y===null)k.componentDidMount();else{var F=c.elementType===c.type?y.memoizedProps:si(c.type,y.memoizedProps);k.componentDidUpdate(F,y.memoizedState,k.__reactInternalSnapshotBeforeUpdate)}var V=c.updateQueue;V!==null&&Xj(c,V,k);break;case 3:var ie=c.updateQueue;if(ie!==null){if(y=null,c.child!==null)switch(c.child.tag){case 5:y=c.child.stateNode;break;case 1:y=c.child.stateNode}Xj(c,ie,y)}break;case 5:var Ne=c.stateNode;if(y===null&&c.flags&4){y=Ne;var Re=c.memoizedProps;switch(c.type){case"button":case"input":case"select":case"textarea":Re.autoFocus&&y.focus();break;case"img":Re.src&&(y.src=Re.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(c.memoizedState===null){var Ze=c.alternate;if(Ze!==null){var At=Ze.memoizedState;if(At!==null){var Tt=At.dehydrated;Tt!==null&&Hr(Tt)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}qr||c.flags&512&&Rx(c)}catch(Ct){Kn(c,c.return,Ct)}}if(c===l){us=null;break}if(y=c.sibling,y!==null){y.return=c.return,us=y;break}us=c.return}}function XN(l){for(;us!==null;){var c=us;if(c===l){us=null;break}var y=c.sibling;if(y!==null){y.return=c.return,us=y;break}us=c.return}}function JN(l){for(;us!==null;){var c=us;try{switch(c.tag){case 0:case 11:case 15:var y=c.return;try{qh(4,c)}catch(Re){Kn(c,y,Re)}break;case 1:var k=c.stateNode;if(typeof k.componentDidMount=="function"){var F=c.return;try{k.componentDidMount()}catch(Re){Kn(c,F,Re)}}var V=c.return;try{Rx(c)}catch(Re){Kn(c,V,Re)}break;case 5:var ie=c.return;try{Rx(c)}catch(Re){Kn(c,ie,Re)}}}catch(Re){Kn(c,c.return,Re)}if(c===l){us=null;break}var Ne=c.sibling;if(Ne!==null){Ne.return=c.return,us=Ne;break}us=c.return}}var ZT=Math.ceil,zh=S.ReactCurrentDispatcher,Tx=S.ReactCurrentOwner,qa=S.ReactCurrentBatchConfig,Nn=0,jr=null,rr=null,Pr=0,wa=0,Mc=Pl(0),fr=0,Kd=null,Lo=0,Uh=0,Px=0,Yd=null,la=null,Ox=0,Fc=1/0,rl=null,Vh=!1,Lx=null,Bl=null,Hh=!1,$l=null,Wh=0,Zd=0,Ix=null,Gh=-1,Kh=0;function Yr(){return(Nn&6)!==0?bt():Gh!==-1?Gh:Gh=bt()}function ql(l){return(l.mode&1)===0?1:(Nn&2)!==0&&Pr!==0?Pr&-Pr:PT.transition!==null?(Kh===0&&(Kh=Ft()),Kh):(l=Hs,l!==0||(l=window.event,l=l===void 0?16:Wi(l.type)),l)}function ai(l,c,y,k){if(50<Zd)throw Zd=0,Ix=null,Error(n(185));xn(l,y,k),((Nn&2)===0||l!==jr)&&(l===jr&&((Nn&2)===0&&(Uh|=y),fr===4&&zl(l,Pr)),oa(l,k),y===1&&Nn===0&&(c.mode&1)===0&&(Fc=bt()+500,Nh&&Ll()))}function oa(l,c){var y=l.callbackNode;St(l,c);var k=Ye(l,l===jr?Pr:0);if(k===0)y!==null&&an(y),l.callbackNode=null,l.callbackPriority=0;else if(c=k&-k,l.callbackPriority!==c){if(y!=null&&an(y),c===1)l.tag===0?TT(tw.bind(null,l)):$j(tw.bind(null,l)),DT(function(){(Nn&6)===0&&Ll()}),y=null;else{switch(Za(k)){case 1:y=ct;break;case 4:y=tt;break;case 16:y=jt;break;case 536870912:y=zt;break;default:y=jt}y=cw(y,ew.bind(null,l))}l.callbackPriority=c,l.callbackNode=y}}function ew(l,c){if(Gh=-1,Kh=0,(Nn&6)!==0)throw Error(n(327));var y=l.callbackNode;if(Bc()&&l.callbackNode!==y)return null;var k=Ye(l,l===jr?Pr:0);if(k===0)return null;if((k&30)!==0||(k&l.expiredLanes)!==0||c)c=Yh(l,k);else{c=k;var F=Nn;Nn|=2;var V=nw();(jr!==l||Pr!==c)&&(rl=null,Fc=bt()+500,Mo(l,c));do try{JT();break}catch(Ne){sw(l,Ne)}while(!0);ex(),zh.current=V,Nn=F,rr!==null?c=0:(jr=null,Pr=0,c=fr)}if(c!==0){if(c===2&&(F=rt(l),F!==0&&(k=F,c=Mx(l,F))),c===1)throw y=Kd,Mo(l,0),zl(l,k),oa(l,bt()),y;if(c===6)zl(l,k);else{if(F=l.current.alternate,(k&30)===0&&!QT(F)&&(c=Yh(l,k),c===2&&(V=rt(l),V!==0&&(k=V,c=Mx(l,V))),c===1))throw y=Kd,Mo(l,0),zl(l,k),oa(l,bt()),y;switch(l.finishedWork=F,l.finishedLanes=k,c){case 0:case 1:throw Error(n(345));case 2:Fo(l,la,rl);break;case 3:if(zl(l,k),(k&130023424)===k&&(c=Ox+500-bt(),10<c)){if(Ye(l,0)!==0)break;if(F=l.suspendedLanes,(F&k)!==k){Yr(),l.pingedLanes|=l.suspendedLanes&F;break}l.timeoutHandle=Up(Fo.bind(null,l,la,rl),c);break}Fo(l,la,rl);break;case 4:if(zl(l,k),(k&4194240)===k)break;for(c=l.eventTimes,F=-1;0<k;){var ie=31-vs(k);V=1<<ie,ie=c[ie],ie>F&&(F=ie),k&=~V}if(k=F,k=bt()-k,k=(120>k?120:480>k?480:1080>k?1080:1920>k?1920:3e3>k?3e3:4320>k?4320:1960*ZT(k/1960))-k,10<k){l.timeoutHandle=Up(Fo.bind(null,l,la,rl),k);break}Fo(l,la,rl);break;case 5:Fo(l,la,rl);break;default:throw Error(n(329))}}}return oa(l,bt()),l.callbackNode===y?ew.bind(null,l):null}function Mx(l,c){var y=Yd;return l.current.memoizedState.isDehydrated&&(Mo(l,c).flags|=256),l=Yh(l,c),l!==2&&(c=la,la=y,c!==null&&Fx(c)),l}function Fx(l){la===null?la=l:la.push.apply(la,l)}function QT(l){for(var c=l;;){if(c.flags&16384){var y=c.updateQueue;if(y!==null&&(y=y.stores,y!==null))for(var k=0;k<y.length;k++){var F=y[k],V=F.getSnapshot;F=F.value;try{if(!ei(V(),F))return!1}catch{return!1}}}if(y=c.child,c.subtreeFlags&16384&&y!==null)y.return=c,c=y;else{if(c===l)break;for(;c.sibling===null;){if(c.return===null||c.return===l)return!0;c=c.return}c.sibling.return=c.return,c=c.sibling}}return!0}function zl(l,c){for(c&=~Px,c&=~Uh,l.suspendedLanes|=c,l.pingedLanes&=~c,l=l.expirationTimes;0<c;){var y=31-vs(c),k=1<<y;l[y]=-1,c&=~k}}function tw(l){if((Nn&6)!==0)throw Error(n(327));Bc();var c=Ye(l,0);if((c&1)===0)return oa(l,bt()),null;var y=Yh(l,c);if(l.tag!==0&&y===2){var k=rt(l);k!==0&&(c=k,y=Mx(l,k))}if(y===1)throw y=Kd,Mo(l,0),zl(l,c),oa(l,bt()),y;if(y===6)throw Error(n(345));return l.finishedWork=l.current.alternate,l.finishedLanes=c,Fo(l,la,rl),oa(l,bt()),null}function Bx(l,c){var y=Nn;Nn|=1;try{return l(c)}finally{Nn=y,Nn===0&&(Fc=bt()+500,Nh&&Ll())}}function Io(l){$l!==null&&$l.tag===0&&(Nn&6)===0&&Bc();var c=Nn;Nn|=1;var y=qa.transition,k=Hs;try{if(qa.transition=null,Hs=1,l)return l()}finally{Hs=k,qa.transition=y,Nn=c,(Nn&6)===0&&Ll()}}function $x(){wa=Mc.current,Pn(Mc)}function Mo(l,c){l.finishedWork=null,l.finishedLanes=0;var y=l.timeoutHandle;if(y!==-1&&(l.timeoutHandle=-1,kT(y)),rr!==null)for(y=rr.return;y!==null;){var k=y;switch(Yp(k),k.tag){case 1:k=k.type.childContextTypes,k!=null&&bh();break;case 3:Oc(),Pn(ra),Pn(Fr),ox();break;case 5:ix(k);break;case 4:Oc();break;case 13:Pn(Un);break;case 19:Pn(Un);break;case 10:tx(k.type._context);break;case 22:case 23:$x()}y=y.return}if(jr=l,rr=l=Ul(l.current,null),Pr=wa=c,fr=0,Kd=null,Px=Uh=Lo=0,la=Yd=null,To!==null){for(c=0;c<To.length;c++)if(y=To[c],k=y.interleaved,k!==null){y.interleaved=null;var F=k.next,V=y.pending;if(V!==null){var ie=V.next;V.next=F,k.next=ie}y.pending=k}To=null}return l}function sw(l,c){do{var y=rr;try{if(ex(),Th.current=Ih,Ph){for(var k=Vn.memoizedState;k!==null;){var F=k.queue;F!==null&&(F.pending=null),k=k.next}Ph=!1}if(Oo=0,br=mr=Vn=null,zd=!1,Ud=0,Tx.current=null,y===null||y.return===null){fr=1,Kd=c,rr=null;break}e:{var V=l,ie=y.return,Ne=y,Re=c;if(c=Pr,Ne.flags|=32768,Re!==null&&typeof Re=="object"&&typeof Re.then=="function"){var Ze=Re,At=Ne,Tt=At.tag;if((At.mode&1)===0&&(Tt===0||Tt===11||Tt===15)){var Ct=At.alternate;Ct?(At.updateQueue=Ct.updateQueue,At.memoizedState=Ct.memoizedState,At.lanes=Ct.lanes):(At.updateQueue=null,At.memoizedState=null)}var as=kN(ie);if(as!==null){as.flags&=-257,DN(as,ie,Ne,V,c),as.mode&1&&AN(V,Ze,c),c=as,Re=Ze;var ps=c.updateQueue;if(ps===null){var gs=new Set;gs.add(Re),c.updateQueue=gs}else ps.add(Re);break e}else{if((c&1)===0){AN(V,Ze,c),qx();break e}Re=Error(n(426))}}else if(Fn&&Ne.mode&1){var er=kN(ie);if(er!==null){(er.flags&65536)===0&&(er.flags|=256),DN(er,ie,Ne,V,c),Xp(Lc(Re,Ne));break e}}V=Re=Lc(Re,Ne),fr!==4&&(fr=2),Yd===null?Yd=[V]:Yd.push(V),V=ie;do{switch(V.tag){case 3:V.flags|=65536,c&=-c,V.lanes|=c;var We=SN(V,Re,c);Qj(V,We);break e;case 1:Ne=Re;var Ie=V.type,Ke=V.stateNode;if((V.flags&128)===0&&(typeof Ie.getDerivedStateFromError=="function"||Ke!==null&&typeof Ke.componentDidCatch=="function"&&(Bl===null||!Bl.has(Ke)))){V.flags|=65536,c&=-c,V.lanes|=c;var $t=CN(V,Ne,c);Qj(V,$t);break e}}V=V.return}while(V!==null)}aw(y)}catch(ys){c=ys,rr===y&&y!==null&&(rr=y=y.return);continue}break}while(!0)}function nw(){var l=zh.current;return zh.current=Ih,l===null?Ih:l}function qx(){(fr===0||fr===3||fr===2)&&(fr=4),jr===null||(Lo&268435455)===0&&(Uh&268435455)===0||zl(jr,Pr)}function Yh(l,c){var y=Nn;Nn|=2;var k=nw();(jr!==l||Pr!==c)&&(rl=null,Mo(l,c));do try{XT();break}catch(F){sw(l,F)}while(!0);if(ex(),Nn=y,zh.current=k,rr!==null)throw Error(n(261));return jr=null,Pr=0,fr}function XT(){for(;rr!==null;)rw(rr)}function JT(){for(;rr!==null&&!hn();)rw(rr)}function rw(l){var c=ow(l.alternate,l,wa);l.memoizedProps=l.pendingProps,c===null?aw(l):rr=c,Tx.current=null}function aw(l){var c=l;do{var y=c.alternate;if(l=c.return,(c.flags&32768)===0){if(y=HT(y,c,wa),y!==null){rr=y;return}}else{if(y=WT(y,c),y!==null){y.flags&=32767,rr=y;return}if(l!==null)l.flags|=32768,l.subtreeFlags=0,l.deletions=null;else{fr=6,rr=null;return}}if(c=c.sibling,c!==null){rr=c;return}rr=c=l}while(c!==null);fr===0&&(fr=5)}function Fo(l,c,y){var k=Hs,F=qa.transition;try{qa.transition=null,Hs=1,e4(l,c,y,k)}finally{qa.transition=F,Hs=k}return null}function e4(l,c,y,k){do Bc();while($l!==null);if((Nn&6)!==0)throw Error(n(327));y=l.finishedWork;var F=l.finishedLanes;if(y===null)return null;if(l.finishedWork=null,l.finishedLanes=0,y===l.current)throw Error(n(177));l.callbackNode=null,l.callbackPriority=0;var V=y.lanes|y.childLanes;if(qn(l,V),l===jr&&(rr=jr=null,Pr=0),(y.subtreeFlags&2064)===0&&(y.flags&2064)===0||Hh||(Hh=!0,cw(jt,function(){return Bc(),null})),V=(y.flags&15990)!==0,(y.subtreeFlags&15990)!==0||V){V=qa.transition,qa.transition=null;var ie=Hs;Hs=1;var Ne=Nn;Nn|=4,Tx.current=null,KT(l,y),YN(y,l),bT(qp),ya=!!$p,qp=$p=null,l.current=y,YT(y),De(),Nn=Ne,Hs=ie,qa.transition=V}else l.current=y;if(Hh&&(Hh=!1,$l=l,Wh=F),V=l.pendingLanes,V===0&&(Bl=null),As(y.stateNode),oa(l,bt()),c!==null)for(k=l.onRecoverableError,y=0;y<c.length;y++)F=c[y],k(F.value,{componentStack:F.stack,digest:F.digest});if(Vh)throw Vh=!1,l=Lx,Lx=null,l;return(Wh&1)!==0&&l.tag!==0&&Bc(),V=l.pendingLanes,(V&1)!==0?l===Ix?Zd++:(Zd=0,Ix=l):Zd=0,Ll(),null}function Bc(){if($l!==null){var l=Za(Wh),c=qa.transition,y=Hs;try{if(qa.transition=null,Hs=16>l?16:l,$l===null)var k=!1;else{if(l=$l,$l=null,Wh=0,(Nn&6)!==0)throw Error(n(331));var F=Nn;for(Nn|=4,us=l.current;us!==null;){var V=us,ie=V.child;if((us.flags&16)!==0){var Ne=V.deletions;if(Ne!==null){for(var Re=0;Re<Ne.length;Re++){var Ze=Ne[Re];for(us=Ze;us!==null;){var At=us;switch(At.tag){case 0:case 11:case 15:Gd(8,At,V)}var Tt=At.child;if(Tt!==null)Tt.return=At,us=Tt;else for(;us!==null;){At=us;var Ct=At.sibling,as=At.return;if(VN(At),At===Ze){us=null;break}if(Ct!==null){Ct.return=as,us=Ct;break}us=as}}}var ps=V.alternate;if(ps!==null){var gs=ps.child;if(gs!==null){ps.child=null;do{var er=gs.sibling;gs.sibling=null,gs=er}while(gs!==null)}}us=V}}if((V.subtreeFlags&2064)!==0&&ie!==null)ie.return=V,us=ie;else e:for(;us!==null;){if(V=us,(V.flags&2048)!==0)switch(V.tag){case 0:case 11:case 15:Gd(9,V,V.return)}var We=V.sibling;if(We!==null){We.return=V.return,us=We;break e}us=V.return}}var Ie=l.current;for(us=Ie;us!==null;){ie=us;var Ke=ie.child;if((ie.subtreeFlags&2064)!==0&&Ke!==null)Ke.return=ie,us=Ke;else e:for(ie=Ie;us!==null;){if(Ne=us,(Ne.flags&2048)!==0)try{switch(Ne.tag){case 0:case 11:case 15:qh(9,Ne)}}catch(ys){Kn(Ne,Ne.return,ys)}if(Ne===ie){us=null;break e}var $t=Ne.sibling;if($t!==null){$t.return=Ne.return,us=$t;break e}us=Ne.return}}if(Nn=F,Ll(),qt&&typeof qt.onPostCommitFiberRoot=="function")try{qt.onPostCommitFiberRoot(fs,l)}catch{}k=!0}return k}finally{Hs=y,qa.transition=c}}return!1}function iw(l,c,y){c=Lc(y,c),c=SN(l,c,1),l=Ml(l,c,1),c=Yr(),l!==null&&(xn(l,1,c),oa(l,c))}function Kn(l,c,y){if(l.tag===3)iw(l,l,y);else for(;c!==null;){if(c.tag===3){iw(c,l,y);break}else if(c.tag===1){var k=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof k.componentDidCatch=="function"&&(Bl===null||!Bl.has(k))){l=Lc(y,l),l=CN(c,l,1),c=Ml(c,l,1),l=Yr(),c!==null&&(xn(c,1,l),oa(c,l));break}}c=c.return}}function t4(l,c,y){var k=l.pingCache;k!==null&&k.delete(c),c=Yr(),l.pingedLanes|=l.suspendedLanes&y,jr===l&&(Pr&y)===y&&(fr===4||fr===3&&(Pr&130023424)===Pr&&500>bt()-Ox?Mo(l,0):Px|=y),oa(l,c)}function lw(l,c){c===0&&((l.mode&1)===0?c=1:(c=fn,fn<<=1,(fn&130023424)===0&&(fn=4194304)));var y=Yr();l=tl(l,c),l!==null&&(xn(l,c,y),oa(l,y))}function s4(l){var c=l.memoizedState,y=0;c!==null&&(y=c.retryLane),lw(l,y)}function n4(l,c){var y=0;switch(l.tag){case 13:var k=l.stateNode,F=l.memoizedState;F!==null&&(y=F.retryLane);break;case 19:k=l.stateNode;break;default:throw Error(n(314))}k!==null&&k.delete(c),lw(l,y)}var ow;ow=function(l,c,y){if(l!==null)if(l.memoizedProps!==c.pendingProps||ra.current)ia=!0;else{if((l.lanes&y)===0&&(c.flags&128)===0)return ia=!1,VT(l,c,y);ia=(l.flags&131072)!==0}else ia=!1,Fn&&(c.flags&1048576)!==0&&qj(c,Sh,c.index);switch(c.lanes=0,c.tag){case 2:var k=c.type;Bh(l,c),l=c.pendingProps;var F=kc(c,Fr.current);Pc(c,y),F=ux(null,c,k,l,F,y);var V=hx();return c.flags|=1,typeof F=="object"&&F!==null&&typeof F.render=="function"&&F.$$typeof===void 0?(c.tag=1,c.memoizedState=null,c.updateQueue=null,aa(k)?(V=!0,jh(c)):V=!1,c.memoizedState=F.state!==null&&F.state!==void 0?F.state:null,rx(c),F.updater=Mh,c.stateNode=F,F._reactInternals=c,vx(c,k,l,y),c=Nx(null,c,k,!0,V,y)):(c.tag=0,Fn&&V&&Kp(c),Kr(null,c,F,y),c=c.child),c;case 16:k=c.elementType;e:{switch(Bh(l,c),l=c.pendingProps,F=k._init,k=F(k._payload),c.type=k,F=c.tag=a4(k),l=si(k,l),F){case 0:c=jx(null,c,k,l,y);break e;case 1:c=ON(null,c,k,l,y);break e;case 11:c=RN(null,c,k,l,y);break e;case 14:c=EN(null,c,k,si(k.type,l),y);break e}throw Error(n(306,k,""))}return c;case 0:return k=c.type,F=c.pendingProps,F=c.elementType===k?F:si(k,F),jx(l,c,k,F,y);case 1:return k=c.type,F=c.pendingProps,F=c.elementType===k?F:si(k,F),ON(l,c,k,F,y);case 3:e:{if(LN(c),l===null)throw Error(n(387));k=c.pendingProps,V=c.memoizedState,F=V.element,Zj(l,c),Eh(c,k,null,y);var ie=c.memoizedState;if(k=ie.element,V.isDehydrated)if(V={element:k,isDehydrated:!1,cache:ie.cache,pendingSuspenseBoundaries:ie.pendingSuspenseBoundaries,transitions:ie.transitions},c.updateQueue.baseState=V,c.memoizedState=V,c.flags&256){F=Lc(Error(n(423)),c),c=IN(l,c,k,y,F);break e}else if(k!==F){F=Lc(Error(n(424)),c),c=IN(l,c,k,y,F);break e}else for(Na=Tl(c.stateNode.containerInfo.firstChild),ja=c,Fn=!0,ti=null,y=Kj(c,null,k,y),c.child=y;y;)y.flags=y.flags&-3|4096,y=y.sibling;else{if(Ec(),k===F){c=nl(l,c,y);break e}Kr(l,c,k,y)}c=c.child}return c;case 5:return Jj(c),l===null&&Qp(c),k=c.type,F=c.pendingProps,V=l!==null?l.memoizedProps:null,ie=F.children,zp(k,F)?ie=null:V!==null&&zp(k,V)&&(c.flags|=32),PN(l,c),Kr(l,c,ie,y),c.child;case 6:return l===null&&Qp(c),null;case 13:return MN(l,c,y);case 4:return ax(c,c.stateNode.containerInfo),k=c.pendingProps,l===null?c.child=_c(c,null,k,y):Kr(l,c,k,y),c.child;case 11:return k=c.type,F=c.pendingProps,F=c.elementType===k?F:si(k,F),RN(l,c,k,F,y);case 7:return Kr(l,c,c.pendingProps,y),c.child;case 8:return Kr(l,c,c.pendingProps.children,y),c.child;case 12:return Kr(l,c,c.pendingProps.children,y),c.child;case 10:e:{if(k=c.type._context,F=c.pendingProps,V=c.memoizedProps,ie=F.value,Dn(kh,k._currentValue),k._currentValue=ie,V!==null)if(ei(V.value,ie)){if(V.children===F.children&&!ra.current){c=nl(l,c,y);break e}}else for(V=c.child,V!==null&&(V.return=c);V!==null;){var Ne=V.dependencies;if(Ne!==null){ie=V.child;for(var Re=Ne.firstContext;Re!==null;){if(Re.context===k){if(V.tag===1){Re=sl(-1,y&-y),Re.tag=2;var Ze=V.updateQueue;if(Ze!==null){Ze=Ze.shared;var At=Ze.pending;At===null?Re.next=Re:(Re.next=At.next,At.next=Re),Ze.pending=Re}}V.lanes|=y,Re=V.alternate,Re!==null&&(Re.lanes|=y),sx(V.return,y,c),Ne.lanes|=y;break}Re=Re.next}}else if(V.tag===10)ie=V.type===c.type?null:V.child;else if(V.tag===18){if(ie=V.return,ie===null)throw Error(n(341));ie.lanes|=y,Ne=ie.alternate,Ne!==null&&(Ne.lanes|=y),sx(ie,y,c),ie=V.sibling}else ie=V.child;if(ie!==null)ie.return=V;else for(ie=V;ie!==null;){if(ie===c){ie=null;break}if(V=ie.sibling,V!==null){V.return=ie.return,ie=V;break}ie=ie.return}V=ie}Kr(l,c,F.children,y),c=c.child}return c;case 9:return F=c.type,k=c.pendingProps.children,Pc(c,y),F=Ba(F),k=k(F),c.flags|=1,Kr(l,c,k,y),c.child;case 14:return k=c.type,F=si(k,c.pendingProps),F=si(k.type,F),EN(l,c,k,F,y);case 15:return _N(l,c,c.type,c.pendingProps,y);case 17:return k=c.type,F=c.pendingProps,F=c.elementType===k?F:si(k,F),Bh(l,c),c.tag=1,aa(k)?(l=!0,jh(c)):l=!1,Pc(c,y),NN(c,k,F),vx(c,k,F,y),Nx(null,c,k,!0,l,y);case 19:return BN(l,c,y);case 22:return TN(l,c,y)}throw Error(n(156,c.tag))};function cw(l,c){return Js(l,c)}function r4(l,c,y,k){this.tag=l,this.key=y,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=c,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=k,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function za(l,c,y,k){return new r4(l,c,y,k)}function zx(l){return l=l.prototype,!(!l||!l.isReactComponent)}function a4(l){if(typeof l=="function")return zx(l)?1:0;if(l!=null){if(l=l.$$typeof,l===P)return 11;if(l===Y)return 14}return 2}function Ul(l,c){var y=l.alternate;return y===null?(y=za(l.tag,c,l.key,l.mode),y.elementType=l.elementType,y.type=l.type,y.stateNode=l.stateNode,y.alternate=l,l.alternate=y):(y.pendingProps=c,y.type=l.type,y.flags=0,y.subtreeFlags=0,y.deletions=null),y.flags=l.flags&14680064,y.childLanes=l.childLanes,y.lanes=l.lanes,y.child=l.child,y.memoizedProps=l.memoizedProps,y.memoizedState=l.memoizedState,y.updateQueue=l.updateQueue,c=l.dependencies,y.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},y.sibling=l.sibling,y.index=l.index,y.ref=l.ref,y}function Zh(l,c,y,k,F,V){var ie=2;if(k=l,typeof l=="function")zx(l)&&(ie=1);else if(typeof l=="string")ie=5;else e:switch(l){case A:return Bo(y.children,F,V,c);case E:ie=8,F|=8;break;case q:return l=za(12,y,c,F|2),l.elementType=q,l.lanes=V,l;case L:return l=za(13,y,c,F),l.elementType=L,l.lanes=V,l;case $:return l=za(19,y,c,F),l.elementType=$,l.lanes=V,l;case W:return Qh(y,F,V,c);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case O:ie=10;break e;case D:ie=9;break e;case P:ie=11;break e;case Y:ie=14;break e;case Z:ie=16,k=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return c=za(ie,y,c,F),c.elementType=l,c.type=k,c.lanes=V,c}function Bo(l,c,y,k){return l=za(7,l,k,c),l.lanes=y,l}function Qh(l,c,y,k){return l=za(22,l,k,c),l.elementType=W,l.lanes=y,l.stateNode={isHidden:!1},l}function Ux(l,c,y){return l=za(6,l,null,c),l.lanes=y,l}function Vx(l,c,y){return c=za(4,l.children!==null?l.children:[],l.key,c),c.lanes=y,c.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},c}function i4(l,c,y,k,F){this.tag=c,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=jn(0),this.expirationTimes=jn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=jn(0),this.identifierPrefix=k,this.onRecoverableError=F,this.mutableSourceEagerHydrationData=null}function Hx(l,c,y,k,F,V,ie,Ne,Re){return l=new i4(l,c,y,Ne,Re),c===1?(c=1,V===!0&&(c|=8)):c=0,V=za(3,null,null,c),l.current=V,V.stateNode=l,V.memoizedState={element:k,isDehydrated:y,cache:null,transitions:null,pendingSuspenseBoundaries:null},rx(V),l}function l4(l,c,y){var k=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:_,key:k==null?null:""+k,children:l,containerInfo:c,implementation:y}}function dw(l){if(!l)return Ol;l=l._reactInternals;e:{if(ft(l)!==l||l.tag!==1)throw Error(n(170));var c=l;do{switch(c.tag){case 3:c=c.stateNode.context;break e;case 1:if(aa(c.type)){c=c.stateNode.__reactInternalMemoizedMergedChildContext;break e}}c=c.return}while(c!==null);throw Error(n(171))}if(l.tag===1){var y=l.type;if(aa(y))return Fj(l,y,c)}return c}function uw(l,c,y,k,F,V,ie,Ne,Re){return l=Hx(y,k,!0,l,F,V,ie,Ne,Re),l.context=dw(null),y=l.current,k=Yr(),F=ql(y),V=sl(k,F),V.callback=c??null,Ml(y,V,F),l.current.lanes=F,xn(l,F,k),oa(l,k),l}function Xh(l,c,y,k){var F=c.current,V=Yr(),ie=ql(F);return y=dw(y),c.context===null?c.context=y:c.pendingContext=y,c=sl(V,ie),c.payload={element:l},k=k===void 0?null:k,k!==null&&(c.callback=k),l=Ml(F,c,ie),l!==null&&(ai(l,F,ie,V),Rh(l,F,ie)),ie}function Jh(l){if(l=l.current,!l.child)return null;switch(l.child.tag){case 5:return l.child.stateNode;default:return l.child.stateNode}}function hw(l,c){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var y=l.retryLane;l.retryLane=y!==0&&y<c?y:c}}function Wx(l,c){hw(l,c),(l=l.alternate)&&hw(l,c)}function o4(){return null}var mw=typeof reportError=="function"?reportError:function(l){console.error(l)};function Gx(l){this._internalRoot=l}em.prototype.render=Gx.prototype.render=function(l){var c=this._internalRoot;if(c===null)throw Error(n(409));Xh(l,c,null,null)},em.prototype.unmount=Gx.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var c=l.containerInfo;Io(function(){Xh(null,l,null,null)}),c[Qi]=null}};function em(l){this._internalRoot=l}em.prototype.unstable_scheduleHydration=function(l){if(l){var c=ta();l={blockedOn:null,target:l,priority:c};for(var y=0;y<Wn.length&&c!==0&&c<Wn[y].priority;y++);Wn.splice(y,0,l),y===0&&en(l)}};function Kx(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}function tm(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11&&(l.nodeType!==8||l.nodeValue!==" react-mount-point-unstable "))}function fw(){}function c4(l,c,y,k,F){if(F){if(typeof k=="function"){var V=k;k=function(){var Ze=Jh(ie);V.call(Ze)}}var ie=uw(c,k,l,0,null,!1,!1,"",fw);return l._reactRootContainer=ie,l[Qi]=ie.current,Od(l.nodeType===8?l.parentNode:l),Io(),ie}for(;F=l.lastChild;)l.removeChild(F);if(typeof k=="function"){var Ne=k;k=function(){var Ze=Jh(Re);Ne.call(Ze)}}var Re=Hx(l,0,!1,null,null,!1,!1,"",fw);return l._reactRootContainer=Re,l[Qi]=Re.current,Od(l.nodeType===8?l.parentNode:l),Io(function(){Xh(c,Re,y,k)}),Re}function sm(l,c,y,k,F){var V=y._reactRootContainer;if(V){var ie=V;if(typeof F=="function"){var Ne=F;F=function(){var Re=Jh(ie);Ne.call(Re)}}Xh(c,ie,l,F)}else ie=c4(y,c,l,F,k);return Jh(ie)}Pa=function(l){switch(l.tag){case 3:var c=l.stateNode;if(c.current.memoizedState.isDehydrated){var y=on(c.pendingLanes);y!==0&&(En(c,y|1),oa(c,bt()),(Nn&6)===0&&(Fc=bt()+500,Ll()))}break;case 13:Io(function(){var k=tl(l,1);if(k!==null){var F=Yr();ai(k,l,1,F)}}),Wx(l,1)}},Ls=function(l){if(l.tag===13){var c=tl(l,134217728);if(c!==null){var y=Yr();ai(c,l,134217728,y)}Wx(l,134217728)}},nn=function(l){if(l.tag===13){var c=ql(l),y=tl(l,c);if(y!==null){var k=Yr();ai(y,l,c,k)}Wx(l,c)}},ta=function(){return Hs},sa=function(l,c){var y=Hs;try{return Hs=l,c()}finally{Hs=y}},$s=function(l,c,y){switch(c){case"input":if(vt(l,y),c=y.name,y.type==="radio"&&c!=null){for(y=l;y.parentNode;)y=y.parentNode;for(y=y.querySelectorAll("input[name="+JSON.stringify(""+c)+'][type="radio"]'),c=0;c<y.length;c++){var k=y[c];if(k!==l&&k.form===l.form){var F=yh(k);if(!F)throw Error(n(90));ce(k),vt(k,F)}}}break;case"textarea":st(l,y);break;case"select":c=y.value,c!=null&&Be(l,!!y.multiple,c,!1)}},je=Bx,Ve=Io;var d4={usingClientEntryPoint:!1,Events:[Md,Cc,yh,Oe,ke,Bx]},Qd={findFiberByHostInstance:Do,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},u4={bundleType:Qd.bundleType,version:Qd.version,rendererPackageName:Qd.rendererPackageName,rendererConfig:Qd.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:S.ReactCurrentDispatcher,findHostInstanceByFiber:function(l){return l=Us(l),l===null?null:l.stateNode},findFiberByHostInstance:Qd.findFiberByHostInstance||o4,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 nm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!nm.isDisabled&&nm.supportsFiber)try{fs=nm.inject(u4),qt=nm}catch{}}return ca.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=d4,ca.createPortal=function(l,c){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Kx(c))throw Error(n(200));return l4(l,c,null,y)},ca.createRoot=function(l,c){if(!Kx(l))throw Error(n(299));var y=!1,k="",F=mw;return c!=null&&(c.unstable_strictMode===!0&&(y=!0),c.identifierPrefix!==void 0&&(k=c.identifierPrefix),c.onRecoverableError!==void 0&&(F=c.onRecoverableError)),c=Hx(l,1,!1,null,null,y,!1,k,F),l[Qi]=c.current,Od(l.nodeType===8?l.parentNode:l),new Gx(c)},ca.findDOMNode=function(l){if(l==null)return null;if(l.nodeType===1)return l;var c=l._reactInternals;if(c===void 0)throw typeof l.render=="function"?Error(n(188)):(l=Object.keys(l).join(","),Error(n(268,l)));return l=Us(c),l=l===null?null:l.stateNode,l},ca.flushSync=function(l){return Io(l)},ca.hydrate=function(l,c,y){if(!tm(c))throw Error(n(200));return sm(null,l,c,!0,y)},ca.hydrateRoot=function(l,c,y){if(!Kx(l))throw Error(n(405));var k=y!=null&&y.hydratedSources||null,F=!1,V="",ie=mw;if(y!=null&&(y.unstable_strictMode===!0&&(F=!0),y.identifierPrefix!==void 0&&(V=y.identifierPrefix),y.onRecoverableError!==void 0&&(ie=y.onRecoverableError)),c=uw(c,null,l,1,y??null,F,!1,V,ie),l[Qi]=c.current,Od(l),k)for(l=0;l<k.length;l++)y=k[l],F=y._getVersion,F=F(y._source),c.mutableSourceEagerHydrationData==null?c.mutableSourceEagerHydrationData=[y,F]:c.mutableSourceEagerHydrationData.push(y,F);return new em(c)},ca.render=function(l,c,y){if(!tm(c))throw Error(n(200));return sm(null,l,c,!1,y)},ca.unmountComponentAtNode=function(l){if(!tm(l))throw Error(n(40));return l._reactRootContainer?(Io(function(){sm(null,null,l,!1,function(){l._reactRootContainer=null,l[Qi]=null})}),!0):!1},ca.unstable_batchedUpdates=Bx,ca.unstable_renderSubtreeIntoContainer=function(l,c,y,k){if(!tm(y))throw Error(n(200));if(l==null||l._reactInternals===void 0)throw Error(n(38));return sm(l,c,y,!1,k)},ca.version="18.3.1-next-f1338f8080-20240426",ca}var Nw;function Oy(){if(Nw)return Xx.exports;Nw=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(s){console.error(s)}}return t(),Xx.exports=j4(),Xx.exports}var ww;function N4(){if(ww)return rm;ww=1;var t=Oy();return rm.createRoot=t.createRoot,rm.hydrateRoot=t.hydrateRoot,rm}var w4=N4();const S4=wf(w4);var tg={exports:{}},sg={};/**
* @license React
* use-sync-external-store-with-selector.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Sw;function C4(){if(Sw)return sg;Sw=1;var t=pd();function s(m,f){return m===f&&(m!==0||1/m===1/f)||m!==m&&f!==f}var n=typeof Object.is=="function"?Object.is:s,r=t.useSyncExternalStore,a=t.useRef,i=t.useEffect,o=t.useMemo,d=t.useDebugValue;return sg.useSyncExternalStoreWithSelector=function(m,f,p,h,x){var u=a(null);if(u.current===null){var N={hasValue:!1,value:null};u.current=N}else N=u.current;u=o(function(){function w(R){if(!j){if(j=!0,b=R,R=h(R),x!==void 0&&N.hasValue){var _=N.value;if(x(_,R))return C=_}return C=R}if(_=C,n(b,R))return _;var A=h(R);return x!==void 0&&x(_,A)?(b=R,_):(b=R,C=A)}var j=!1,b,C,S=p===void 0?null:p;return[function(){return w(f())},S===null?void 0:function(){return w(S())}]},[f,p,h,x]);var v=r(m,u[0],u[1]);return i(function(){N.hasValue=!0,N.value=v},[v]),d(v),v},sg}var Cw;function A4(){return Cw||(Cw=1,tg.exports=C4()),tg.exports}var k4=A4();function D4(t){t()}function R4(){let t=null,s=null;return{clear(){t=null,s=null},notify(){D4(()=>{let n=t;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=t;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const a=s={callback:n,next:null,prev:s};return a.prev?a.prev.next=a:t=a,function(){!r||t===null||(r=!1,a.next?a.next.prev=a.prev:s=a.prev,a.prev?a.prev.next=a.next:t=a.next)}}}}var Aw={notify(){},get:()=>[]};function E4(t,s){let n,r=Aw,a=0,i=!1;function o(v){p();const w=r.subscribe(v);let j=!1;return()=>{j||(j=!0,w(),h())}}function d(){r.notify()}function m(){N.onStateChange&&N.onStateChange()}function f(){return i}function p(){a++,n||(n=t.subscribe(m),r=R4())}function h(){a--,n&&a===0&&(n(),n=void 0,r.clear(),r=Aw)}function x(){i||(i=!0,p())}function u(){i&&(i=!1,h())}const N={addNestedSub:o,notifyNestedSubs:d,handleChangeWrapper:m,isSubscribed:f,trySubscribe:x,tryUnsubscribe:u,getListeners:()=>r};return N}var _4=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",T4=_4(),P4=()=>typeof navigator<"u"&&navigator.product==="ReactNative",O4=P4(),L4=()=>T4||O4?g.useLayoutEffect:g.useEffect,I4=L4(),ng=Symbol.for("react-redux-context"),rg=typeof globalThis<"u"?globalThis:{};function M4(){if(!g.createContext)return{};const t=rg[ng]??(rg[ng]=new Map);let s=t.get(g.createContext);return s||(s=g.createContext(null),t.set(g.createContext,s)),s}var to=M4();function F4(t){const{children:s,context:n,serverState:r,store:a}=t,i=g.useMemo(()=>{const m=E4(a);return{store:a,subscription:m,getServerState:r?()=>r:void 0}},[a,r]),o=g.useMemo(()=>a.getState(),[a]);I4(()=>{const{subscription:m}=i;return m.onStateChange=m.notifyNestedSubs,m.trySubscribe(),o!==a.getState()&&m.notifyNestedSubs(),()=>{m.tryUnsubscribe(),m.onStateChange=void 0}},[i,o]);const d=n||to;return g.createElement(d.Provider,{value:i},s)}var B4=F4;function Ly(t=to){return function(){return g.useContext(t)}}var F2=Ly();function B2(t=to){const s=t===to?F2:Ly(t),n=()=>{const{store:r}=s();return r};return Object.assign(n,{withTypes:()=>n}),n}var $4=B2();function q4(t=to){const s=t===to?$4:B2(t),n=()=>s().dispatch;return Object.assign(n,{withTypes:()=>n}),n}var Lu=q4(),z4=(t,s)=>t===s;function U4(t=to){const s=t===to?F2:Ly(t),n=(r,a={})=>{const{equalityFn:i=z4}=typeof a=="function"?{equalityFn:a}:a,o=s(),{store:d,subscription:m,getServerState:f}=o;g.useRef(!0);const p=g.useCallback({[r.name](x){return r(x)}}[r.name],[r]),h=k4.useSyncExternalStoreWithSelector(m.addNestedSub,d.getState,f||d.getState,p,i);return g.useDebugValue(h),h};return Object.assign(n,{withTypes:()=>n}),n}var In=U4();function Or(t){return`Minified Redux error #${t}; visit https://redux.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var V4=typeof Symbol=="function"&&Symbol.observable||"@@observable",kw=V4,ag=()=>Math.random().toString(36).substring(7).split("").join("."),H4={INIT:`@@redux/INIT${ag()}`,REPLACE:`@@redux/REPLACE${ag()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ag()}`},Ym=H4;function Iy(t){if(typeof t!="object"||t===null)return!1;let s=t;for(;Object.getPrototypeOf(s)!==null;)s=Object.getPrototypeOf(s);return Object.getPrototypeOf(t)===s||Object.getPrototypeOf(t)===null}function $2(t,s,n){if(typeof t!="function")throw new Error(Or(2));if(typeof s=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Or(0));if(typeof s=="function"&&typeof n>"u"&&(n=s,s=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Or(1));return n($2)(t,s)}let r=t,a=s,i=new Map,o=i,d=0,m=!1;function f(){o===i&&(o=new Map,i.forEach((w,j)=>{o.set(j,w)}))}function p(){if(m)throw new Error(Or(3));return a}function h(w){if(typeof w!="function")throw new Error(Or(4));if(m)throw new Error(Or(5));let j=!0;f();const b=d++;return o.set(b,w),function(){if(j){if(m)throw new Error(Or(6));j=!1,f(),o.delete(b),i=null}}}function x(w){if(!Iy(w))throw new Error(Or(7));if(typeof w.type>"u")throw new Error(Or(8));if(typeof w.type!="string")throw new Error(Or(17));if(m)throw new Error(Or(9));try{m=!0,a=r(a,w)}finally{m=!1}return(i=o).forEach(b=>{b()}),w}function u(w){if(typeof w!="function")throw new Error(Or(10));r=w,x({type:Ym.REPLACE})}function N(){const w=h;return{subscribe(j){if(typeof j!="object"||j===null)throw new Error(Or(11));function b(){const S=j;S.next&&S.next(p())}return b(),{unsubscribe:w(b)}},[kw](){return this}}}return x({type:Ym.INIT}),{dispatch:x,subscribe:h,getState:p,replaceReducer:u,[kw]:N}}function W4(t){Object.keys(t).forEach(s=>{const n=t[s];if(typeof n(void 0,{type:Ym.INIT})>"u")throw new Error(Or(12));if(typeof n(void 0,{type:Ym.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Or(13))})}function G4(t){const s=Object.keys(t),n={};for(let i=0;i<s.length;i++){const o=s[i];typeof t[o]=="function"&&(n[o]=t[o])}const r=Object.keys(n);let a;try{W4(n)}catch(i){a=i}return function(o={},d){if(a)throw a;let m=!1;const f={};for(let p=0;p<r.length;p++){const h=r[p],x=n[h],u=o[h],N=x(u,d);if(typeof N>"u")throw d&&d.type,new Error(Or(14));f[h]=N,m=m||N!==u}return m=m||r.length!==Object.keys(o).length,m?f:o}}function Zm(...t){return t.length===0?s=>s:t.length===1?t[0]:t.reduce((s,n)=>(...r)=>s(n(...r)))}function K4(...t){return s=>(n,r)=>{const a=s(n,r);let i=()=>{throw new Error(Or(15))};const o={getState:a.getState,dispatch:(m,...f)=>i(m,...f)},d=t.map(m=>m(o));return i=Zm(...d)(a.dispatch),{...a,dispatch:i}}}function Y4(t){return Iy(t)&&"type"in t&&typeof t.type=="string"}var q2=Symbol.for("immer-nothing"),Dw=Symbol.for("immer-draftable"),Qr=Symbol.for("immer-state");function hi(t,...s){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Da=Object,sd=Da.getPrototypeOf,Qm="constructor",Cf="prototype",Bv="configurable",Xm="enumerable",Tm="writable",ju="value",fl=t=>!!t&&!!t[Qr];function fi(t){var s;return t?z2(t)||kf(t)||!!t[Dw]||!!((s=t[Qm])!=null&&s[Dw])||Df(t)||Rf(t):!1}var Z4=Da[Cf][Qm].toString(),Rw=new WeakMap;function z2(t){if(!t||!My(t))return!1;const s=sd(t);if(s===null||s===Da[Cf])return!0;const n=Da.hasOwnProperty.call(s,Qm)&&s[Qm];if(n===Object)return!0;if(!Kc(n))return!1;let r=Rw.get(n);return r===void 0&&(r=Function.toString.call(n),Rw.set(n,r)),r===Z4}function Af(t,s,n=!0){Iu(t)===0?(n?Reflect.ownKeys(t):Da.keys(t)).forEach(a=>{s(a,t[a],t)}):t.forEach((r,a)=>s(a,r,t))}function Iu(t){const s=t[Qr];return s?s.type_:kf(t)?1:Df(t)?2:Rf(t)?3:0}var Ew=(t,s,n=Iu(t))=>n===2?t.has(s):Da[Cf].hasOwnProperty.call(t,s),$v=(t,s,n=Iu(t))=>n===2?t.get(s):t[s],Jm=(t,s,n,r=Iu(t))=>{r===2?t.set(s,n):r===3?t.add(n):t[s]=n};function Q4(t,s){return t===s?t!==0||1/t===1/s:t!==t&&s!==s}var kf=Array.isArray,Df=t=>t instanceof Map,Rf=t=>t instanceof Set,My=t=>typeof t=="object",Kc=t=>typeof t=="function",ig=t=>typeof t=="boolean";function X4(t){const s=+t;return Number.isInteger(s)&&String(s)===t}var cl=t=>t.copy_||t.base_,Fy=t=>t.modified_?t.copy_:t.base_;function qv(t,s){if(Df(t))return new Map(t);if(Rf(t))return new Set(t);if(kf(t))return Array[Cf].slice.call(t);const n=z2(t);if(s===!0||s==="class_only"&&!n){const r=Da.getOwnPropertyDescriptors(t);delete r[Qr];let a=Reflect.ownKeys(r);for(let i=0;i<a.length;i++){const o=a[i],d=r[o];d[Tm]===!1&&(d[Tm]=!0,d[Bv]=!0),(d.get||d.set)&&(r[o]={[Bv]:!0,[Tm]:!0,[Xm]:d[Xm],[ju]:t[o]})}return Da.create(sd(t),r)}else{const r=sd(t);if(r!==null&&n)return{...t};const a=Da.create(r);return Da.assign(a,t)}}function By(t,s=!1){return Ef(t)||fl(t)||!fi(t)||(Iu(t)>1&&Da.defineProperties(t,{set:am,add:am,clear:am,delete:am}),Da.freeze(t),s&&Af(t,(n,r)=>{By(r,!0)},!1)),t}function J4(){hi(2)}var am={[ju]:J4};function Ef(t){return t===null||!My(t)?!0:Da.isFrozen(t)}var ef="MapSet",zv="Patches",_w="ArrayMethods",U2={};function sc(t){const s=U2[t];return s||hi(0,t),s}var Tw=t=>!!U2[t],Nu,V2=()=>Nu,eP=(t,s)=>({drafts_:[],parent_:t,immer_:s,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Tw(ef)?sc(ef):void 0,arrayMethodsPlugin_:Tw(_w)?sc(_w):void 0});function Pw(t,s){s&&(t.patchPlugin_=sc(zv),t.patches_=[],t.inversePatches_=[],t.patchListener_=s)}function Uv(t){Vv(t),t.drafts_.forEach(tP),t.drafts_=null}function Vv(t){t===Nu&&(Nu=t.parent_)}var Ow=t=>Nu=eP(Nu,t);function tP(t){const s=t[Qr];s.type_===0||s.type_===1?s.revoke_():s.revoked_=!0}function Lw(t,s){s.unfinalizedDrafts_=s.drafts_.length;const n=s.drafts_[0];if(t!==void 0&&t!==n){n[Qr].modified_&&(Uv(s),hi(4)),fi(t)&&(t=Iw(s,t));const{patchPlugin_:a}=s;a&&a.generateReplacementPatches_(n[Qr].base_,t,s)}else t=Iw(s,n);return sP(s,t,!0),Uv(s),s.patches_&&s.patchListener_(s.patches_,s.inversePatches_),t!==q2?t:void 0}function Iw(t,s){if(Ef(s))return s;const n=s[Qr];if(!n)return tf(s,t.handledSet_,t);if(!_f(n,t))return s;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(t);G2(n,t)}return n.copy_}function sP(t,s,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&By(s,n)}function H2(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var _f=(t,s)=>t.scope_===s,nP=[];function W2(t,s,n,r){const a=cl(t),i=t.type_;if(r!==void 0&&$v(a,r,i)===s){Jm(a,r,n,i);return}if(!t.draftLocations_){const d=t.draftLocations_=new Map;Af(a,(m,f)=>{if(fl(f)){const p=d.get(f)||[];p.push(m),d.set(f,p)}})}const o=t.draftLocations_.get(s)??nP;for(const d of o)Jm(a,d,n,i)}function rP(t,s,n){t.callbacks_.push(function(a){var d;const i=s;if(!i||!_f(i,a))return;(d=a.mapSetPlugin_)==null||d.fixSetContents(i);const o=Fy(i);W2(t,i.draft_??i,o,n),G2(i,a)})}function G2(t,s){var r;if(t.modified_&&!t.finalized_&&(t.type_===3||t.type_===1&&t.allIndicesReassigned_||(((r=t.assigned_)==null?void 0:r.size)??0)>0)){const{patchPlugin_:a}=s;if(a){const i=a.getPath(t);i&&a.generatePatches_(t,i,s)}H2(t)}}function aP(t,s,n){const{scope_:r}=t;if(fl(n)){const a=n[Qr];_f(a,r)&&a.callbacks_.push(function(){Pm(t);const o=Fy(a);W2(t,n,o,s)})}else fi(n)&&t.callbacks_.push(function(){const i=cl(t);t.type_===3?i.has(n)&&tf(n,r.handledSet_,r):$v(i,s,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(s)??!1)===!0&&t.copy_&&tf($v(t.copy_,s,t.type_),r.handledSet_,r)})}function tf(t,s,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||fl(t)||s.has(t)||!fi(t)||Ef(t)||(s.add(t),Af(t,(r,a)=>{if(fl(a)){const i=a[Qr];if(_f(i,n)){const o=Fy(i);Jm(t,r,o,t.type_),H2(i)}}else fi(a)&&tf(a,s,n)})),t}function iP(t,s){const n=kf(t),r={type_:n?1:0,scope_:s?s.scope_:V2(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:s,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let a=r,i=sf;n&&(a=[r],i=wu);const{revoke:o,proxy:d}=Proxy.revocable(a,i);return r.draft_=d,r.revoke_=o,[d,r]}var sf={get(t,s){if(s===Qr)return t;let n=t.scope_.arrayMethodsPlugin_;const r=t.type_===1&&typeof s=="string";if(r&&n!=null&&n.isArrayOperationMethod(s))return n.createMethodInterceptor(t,s);const a=cl(t);if(!Ew(a,s,t.type_))return lP(t,a,s);const i=a[s];if(t.finalized_||!fi(i)||r&&t.operationMethod&&(n!=null&&n.isMutatingArrayMethod(t.operationMethod))&&X4(s))return i;if(i===lg(t.base_,s)){Pm(t);const o=t.type_===1?+s:s,d=Wv(t.scope_,i,t,o);return t.copy_[o]=d}return i},has(t,s){return s in cl(t)},ownKeys(t){return Reflect.ownKeys(cl(t))},set(t,s,n){const r=K2(cl(t),s);if(r!=null&&r.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const a=lg(cl(t),s),i=a==null?void 0:a[Qr];if(i&&i.base_===n)return t.copy_[s]=n,t.assigned_.set(s,!1),!0;if(Q4(n,a)&&(n!==void 0||Ew(t.base_,s,t.type_)))return!0;Pm(t),Hv(t)}return t.copy_[s]===n&&(n!==void 0||s in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[s])||(t.copy_[s]=n,t.assigned_.set(s,!0),aP(t,s,n)),!0},deleteProperty(t,s){return Pm(t),lg(t.base_,s)!==void 0||s in t.base_?(t.assigned_.set(s,!1),Hv(t)):t.assigned_.delete(s),t.copy_&&delete t.copy_[s],!0},getOwnPropertyDescriptor(t,s){const n=cl(t),r=Reflect.getOwnPropertyDescriptor(n,s);return r&&{[Tm]:!0,[Bv]:t.type_!==1||s!=="length",[Xm]:r[Xm],[ju]:n[s]}},defineProperty(){hi(11)},getPrototypeOf(t){return sd(t.base_)},setPrototypeOf(){hi(12)}},wu={};for(let t in sf){let s=sf[t];wu[t]=function(){const n=arguments;return n[0]=n[0][0],s.apply(this,n)}}wu.deleteProperty=function(t,s){return wu.set.call(this,t,s,void 0)};wu.set=function(t,s,n){return sf.set.call(this,t[0],s,n,t[0])};function lg(t,s){const n=t[Qr];return(n?cl(n):t)[s]}function lP(t,s,n){var a;const r=K2(s,n);return r?ju in r?r[ju]:(a=r.get)==null?void 0:a.call(t.draft_):void 0}function K2(t,s){if(!(s in t))return;let n=sd(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,s);if(r)return r;n=sd(n)}}function Hv(t){t.modified_||(t.modified_=!0,t.parent_&&Hv(t.parent_))}function Pm(t){t.copy_||(t.assigned_=new Map,t.copy_=qv(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var oP=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(s,n,r)=>{if(Kc(s)&&!Kc(n)){const i=n;n=s;const o=this;return function(m=i,...f){return o.produce(m,p=>n.call(this,p,...f))}}Kc(n)||hi(6),r!==void 0&&!Kc(r)&&hi(7);let a;if(fi(s)){const i=Ow(this),o=Wv(i,s,void 0);let d=!0;try{a=n(o),d=!1}finally{d?Uv(i):Vv(i)}return Pw(i,r),Lw(a,i)}else if(!s||!My(s)){if(a=n(s),a===void 0&&(a=s),a===q2&&(a=void 0),this.autoFreeze_&&By(a,!0),r){const i=[],o=[];sc(zv).generateReplacementPatches_(s,a,{patches_:i,inversePatches_:o}),r(i,o)}return a}else hi(1,s)},this.produceWithPatches=(s,n)=>{if(Kc(s))return(o,...d)=>this.produceWithPatches(o,m=>s(m,...d));let r,a;return[this.produce(s,n,(o,d)=>{r=o,a=d}),r,a]},ig(t==null?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),ig(t==null?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),ig(t==null?void 0:t.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){fi(t)||hi(8),fl(t)&&(t=cP(t));const s=Ow(this),n=Wv(s,t,void 0);return n[Qr].isManual_=!0,Vv(s),n}finishDraft(t,s){const n=t&&t[Qr];(!n||!n.isManual_)&&hi(9);const{scope_:r}=n;return Pw(r,s),Lw(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,s){let n;for(n=s.length-1;n>=0;n--){const a=s[n];if(a.path.length===0&&a.op==="replace"){t=a.value;break}}n>-1&&(s=s.slice(n+1));const r=sc(zv).applyPatches_;return fl(t)?r(t,s):this.produce(t,a=>r(a,s))}};function Wv(t,s,n,r){const[a,i]=Df(s)?sc(ef).proxyMap_(s,n):Rf(s)?sc(ef).proxySet_(s,n):iP(s,n);return((n==null?void 0:n.scope_)??V2()).drafts_.push(a),i.callbacks_=(n==null?void 0:n.callbacks_)??[],i.key_=r,n&&r!==void 0?rP(n,i,r):i.callbacks_.push(function(m){var p;(p=m.mapSetPlugin_)==null||p.fixSetContents(i);const{patchPlugin_:f}=m;i.modified_&&f&&f.generatePatches_(i,[],m)}),a}function cP(t){return fl(t)||hi(10,t),Y2(t)}function Y2(t){if(!fi(t)||Ef(t))return t;const s=t[Qr];let n,r=!0;if(s){if(!s.modified_)return s.base_;s.finalized_=!0,n=qv(t,s.scope_.immer_.useStrictShallowCopy_),r=s.scope_.immer_.shouldUseStrictIteration()}else n=qv(t,!0);return Af(n,(a,i)=>{Jm(n,a,Y2(i))},r),s&&(s.finalized_=!1),n}var dP=new oP,Z2=dP.produce;function Q2(t){return({dispatch:n,getState:r})=>a=>i=>typeof i=="function"?i(n,r,t):a(i)}var uP=Q2(),hP=Q2,mP=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Zm:Zm.apply(null,arguments)},fP=t=>t&&typeof t.match=="function";function vu(t,s){function n(...r){if(s){let a=s(...r);if(!a)throw new Error(ul(0));return{type:t,payload:a.payload,..."meta"in a&&{meta:a.meta},..."error"in a&&{error:a.error}}}return{type:t,payload:r[0]}}return n.toString=()=>`${t}`,n.type=t,n.match=r=>Y4(r)&&r.type===t,n}var X2=class uu extends Array{constructor(...s){super(...s),Object.setPrototypeOf(this,uu.prototype)}static get[Symbol.species](){return uu}concat(...s){return super.concat.apply(this,s)}prepend(...s){return s.length===1&&Array.isArray(s[0])?new uu(...s[0].concat(this)):new uu(...s.concat(this))}};function Mw(t){return fi(t)?Z2(t,()=>{}):t}function im(t,s,n){return t.has(s)?t.get(s):t.set(s,n(s)).get(s)}function pP(t){return typeof t=="boolean"}var xP=()=>function(s){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:a=!0,actionCreatorCheck:i=!0}=s??{};let o=new X2;return n&&(pP(n)?o.push(uP):o.push(hP(n.extraArgument))),o},gP="RTK_autoBatch",Fw=t=>s=>{setTimeout(s,t)},vP=(t={type:"raf"})=>s=>(...n)=>{const r=s(...n);let a=!0,i=!1,o=!1;const d=new Set,m=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:Fw(10):t.type==="callback"?t.queueNotification:Fw(t.timeout),f=()=>{o=!1,i&&(i=!1,d.forEach(p=>p()))};return Object.assign({},r,{subscribe(p){const h=()=>a&&p(),x=r.subscribe(h);return d.add(p),()=>{x(),d.delete(p)}},dispatch(p){var h;try{return a=!((h=p==null?void 0:p.meta)!=null&&h[gP]),i=!a,i&&(o||(o=!0,m(f))),r.dispatch(p)}finally{a=!0}}})},yP=t=>function(n){const{autoBatch:r=!0}=n??{};let a=new X2(t);return r&&a.push(vP(typeof r=="object"?r:void 0)),a};function bP(t){const s=xP(),{reducer:n=void 0,middleware:r,devTools:a=!0,preloadedState:i=void 0,enhancers:o=void 0}=t||{};let d;if(typeof n=="function")d=n;else if(Iy(n))d=G4(n);else throw new Error(ul(1));let m;typeof r=="function"?m=r(s):m=s();let f=Zm;a&&(f=mP({trace:!1,...typeof a=="object"&&a}));const p=K4(...m),h=yP(p);let x=typeof o=="function"?o(h):h();const u=f(...x);return $2(d,i,u)}function J2(t){const s={},n=[];let r;const a={addCase(i,o){const d=typeof i=="string"?i:i.type;if(!d)throw new Error(ul(28));if(d in s)throw new Error(ul(29));return s[d]=o,a},addAsyncThunk(i,o){return o.pending&&(s[i.pending.type]=o.pending),o.rejected&&(s[i.rejected.type]=o.rejected),o.fulfilled&&(s[i.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:i.settled,reducer:o.settled}),a},addMatcher(i,o){return n.push({matcher:i,reducer:o}),a},addDefaultCase(i){return r=i,a}};return t(a),[s,n,r]}function jP(t){return typeof t=="function"}function NP(t,s){let[n,r,a]=J2(s),i;if(jP(t))i=()=>Mw(t());else{const d=Mw(t);i=()=>d}function o(d=i(),m){let f=[n[m.type],...r.filter(({matcher:p})=>p(m)).map(({reducer:p})=>p)];return f.filter(p=>!!p).length===0&&(f=[a]),f.reduce((p,h)=>{if(h)if(fl(p)){const u=h(p,m);return u===void 0?p:u}else{if(fi(p))return Z2(p,x=>h(x,m));{const x=h(p,m);if(x===void 0){if(p===null)return p;throw Error("A case reducer on a non-draftable value must not return undefined")}return x}}return p},d)}return o.getInitialState=i,o}var wP=(t,s)=>fP(t)?t.match(s):t(s);function SP(...t){return s=>t.some(n=>wP(n,s))}var CP="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",AP=(t=21)=>{let s="",n=t;for(;n--;)s+=CP[Math.random()*64|0];return s},kP=["name","message","stack","code"],og=class{constructor(t,s){Yx(this,"_type");this.payload=t,this.meta=s}},Bw=class{constructor(t,s){Yx(this,"_type");this.payload=t,this.meta=s}},DP=t=>{if(typeof t=="object"&&t!==null){const s={};for(const n of kP)typeof t[n]=="string"&&(s[n]=t[n]);return s}return{message:String(t)}},$w="External signal was aborted",RP=(()=>{function t(s,n,r){const a=vu(s+"/fulfilled",(m,f,p,h)=>({payload:m,meta:{...h||{},arg:p,requestId:f,requestStatus:"fulfilled"}})),i=vu(s+"/pending",(m,f,p)=>({payload:void 0,meta:{...p||{},arg:f,requestId:m,requestStatus:"pending"}})),o=vu(s+"/rejected",(m,f,p,h,x)=>({payload:h,error:(r&&r.serializeError||DP)(m||"Rejected"),meta:{...x||{},arg:p,requestId:f,rejectedWithValue:!!h,requestStatus:"rejected",aborted:(m==null?void 0:m.name)==="AbortError",condition:(m==null?void 0:m.name)==="ConditionError"}}));function d(m,{signal:f}={}){return(p,h,x)=>{const u=r!=null&&r.idGenerator?r.idGenerator(m):AP(),N=new AbortController;let v,w;function j(C){w=C,N.abort()}f&&(f.aborted?j($w):f.addEventListener("abort",()=>j($w),{once:!0}));const b=(async function(){var R,_;let C;try{let A=(R=r==null?void 0:r.condition)==null?void 0:R.call(r,m,{getState:h,extra:x});if(_P(A)&&(A=await A),A===!1||N.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const E=new Promise((q,O)=>{v=()=>{O({name:"AbortError",message:w||"Aborted"})},N.signal.addEventListener("abort",v,{once:!0})});p(i(u,m,(_=r==null?void 0:r.getPendingMeta)==null?void 0:_.call(r,{requestId:u,arg:m},{getState:h,extra:x}))),C=await Promise.race([E,Promise.resolve(n(m,{dispatch:p,getState:h,extra:x,requestId:u,signal:N.signal,abort:j,rejectWithValue:(q,O)=>new og(q,O),fulfillWithValue:(q,O)=>new Bw(q,O)})).then(q=>{if(q instanceof og)throw q;return q instanceof Bw?a(q.payload,u,m,q.meta):a(q,u,m)})])}catch(A){C=A instanceof og?o(null,u,m,A.payload,A.meta):o(A,u,m)}finally{v&&N.signal.removeEventListener("abort",v)}return r&&!r.dispatchConditionRejection&&o.match(C)&&C.meta.condition||p(C),C})();return Object.assign(b,{abort:j,requestId:u,arg:m,unwrap(){return b.then(EP)}})}}return Object.assign(d,{pending:i,rejected:o,fulfilled:a,settled:SP(o,a),typePrefix:s})}return t.withTypes=()=>t,t})();function EP(t){if(t.meta&&t.meta.rejectedWithValue)throw t.payload;if(t.error)throw t.error;return t.payload}function _P(t){return t!==null&&typeof t=="object"&&typeof t.then=="function"}var TP=Symbol.for("rtk-slice-createasyncthunk");function PP(t,s){return`${t}/${s}`}function OP({creators:t}={}){var n;const s=(n=t==null?void 0:t.asyncThunk)==null?void 0:n[TP];return function(a){const{name:i,reducerPath:o=i}=a;if(!i)throw new Error(ul(11));const d=(typeof a.reducers=="function"?a.reducers(IP()):a.reducers)||{},m=Object.keys(d),f={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},p={addCase(S,R){const _=typeof S=="string"?S:S.type;if(!_)throw new Error(ul(12));if(_ in f.sliceCaseReducersByType)throw new Error(ul(13));return f.sliceCaseReducersByType[_]=R,p},addMatcher(S,R){return f.sliceMatchers.push({matcher:S,reducer:R}),p},exposeAction(S,R){return f.actionCreators[S]=R,p},exposeCaseReducer(S,R){return f.sliceCaseReducersByName[S]=R,p}};m.forEach(S=>{const R=d[S],_={reducerName:S,type:PP(i,S),createNotation:typeof a.reducers=="function"};FP(R)?$P(_,R,p,s):MP(_,R,p)});function h(){const[S={},R=[],_=void 0]=typeof a.extraReducers=="function"?J2(a.extraReducers):[a.extraReducers],A={...S,...f.sliceCaseReducersByType};return NP(a.initialState,E=>{for(let q in A)E.addCase(q,A[q]);for(let q of f.sliceMatchers)E.addMatcher(q.matcher,q.reducer);for(let q of R)E.addMatcher(q.matcher,q.reducer);_&&E.addDefaultCase(_)})}const x=S=>S,u=new Map,N=new WeakMap;let v;function w(S,R){return v||(v=h()),v(S,R)}function j(){return v||(v=h()),v.getInitialState()}function b(S,R=!1){function _(E){let q=E[S];return typeof q>"u"&&R&&(q=im(N,_,j)),q}function A(E=x){const q=im(u,R,()=>new WeakMap);return im(q,E,()=>{const O={};for(const[D,P]of Object.entries(a.selectors??{}))O[D]=LP(P,E,()=>im(N,E,j),R);return O})}return{reducerPath:S,getSelectors:A,get selectors(){return A(_)},selectSlice:_}}const C={name:i,reducer:w,actions:f.actionCreators,caseReducers:f.sliceCaseReducersByName,getInitialState:j,...b(o),injectInto(S,{reducerPath:R,..._}={}){const A=R??o;return S.inject({reducerPath:A,reducer:w},_),{...C,...b(A,!0)}}};return C}}function LP(t,s,n,r){function a(i,...o){let d=s(i);return typeof d>"u"&&r&&(d=n()),t(d,...o)}return a.unwrapped=t,a}var eA=OP();function IP(){function t(s,n){return{_reducerDefinitionType:"asyncThunk",payloadCreator:s,...n}}return t.withTypes=()=>t,{reducer(s){return Object.assign({[s.name](...n){return s(...n)}}[s.name],{_reducerDefinitionType:"reducer"})},preparedReducer(s,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:s,reducer:n}},asyncThunk:t}}function MP({type:t,reducerName:s,createNotation:n},r,a){let i,o;if("reducer"in r){if(n&&!BP(r))throw new Error(ul(17));i=r.reducer,o=r.prepare}else i=r;a.addCase(t,i).exposeCaseReducer(s,i).exposeAction(s,o?vu(t,o):vu(t))}function FP(t){return t._reducerDefinitionType==="asyncThunk"}function BP(t){return t._reducerDefinitionType==="reducerWithPrepare"}function $P({type:t,reducerName:s},n,r,a){if(!a)throw new Error(ul(18));const{payloadCreator:i,fulfilled:o,pending:d,rejected:m,settled:f,options:p}=n,h=a(t,i,p);r.exposeAction(s,h),o&&r.addCase(h.fulfilled,o),d&&r.addCase(h.pending,d),m&&r.addCase(h.rejected,m),f&&r.addMatcher(h.settled,f),r.exposeCaseReducer(s,{fulfilled:o||lm,pending:d||lm,rejected:m||lm,settled:f||lm})}function lm(){}function ul(t){return`Minified Redux Toolkit error #${t}; visit https://redux-toolkit.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var wr={};/*! Axios v1.13.6 Copyright (c) 2026 Matt Zabriskie and contributors */var cg,qw;function qP(){if(qw)return cg;qw=1;function t(ne,re){return function(){return ne.apply(re,arguments)}}const{toString:s}=Object.prototype,{getPrototypeOf:n}=Object,{iterator:r,toStringTag:a}=Symbol,i=(ne=>re=>{const me=s.call(re);return ne[me]||(ne[me]=me.slice(8,-1).toLowerCase())})(Object.create(null)),o=ne=>(ne=ne.toLowerCase(),re=>i(re)===ne),d=ne=>re=>typeof re===ne,{isArray:m}=Array,f=d("undefined");function p(ne){return ne!==null&&!f(ne)&&ne.constructor!==null&&!f(ne.constructor)&&N(ne.constructor.isBuffer)&&ne.constructor.isBuffer(ne)}const h=o("ArrayBuffer");function x(ne){let re;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?re=ArrayBuffer.isView(ne):re=ne&&ne.buffer&&h(ne.buffer),re}const u=d("string"),N=d("function"),v=d("number"),w=ne=>ne!==null&&typeof ne=="object",j=ne=>ne===!0||ne===!1,b=ne=>{if(i(ne)!=="object")return!1;const re=n(ne);return(re===null||re===Object.prototype||Object.getPrototypeOf(re)===null)&&!(a in ne)&&!(r in ne)},C=ne=>{if(!w(ne)||p(ne))return!1;try{return Object.keys(ne).length===0&&Object.getPrototypeOf(ne)===Object.prototype}catch{return!1}},S=o("Date"),R=o("File"),_=ne=>!!(ne&&typeof ne.uri<"u"),A=ne=>ne&&typeof ne.getParts<"u",E=o("Blob"),q=o("FileList"),O=ne=>w(ne)&&N(ne.pipe);function D(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof Wo<"u"?Wo:{}}const P=D(),L=typeof P.FormData<"u"?P.FormData:void 0,$=ne=>{let re;return ne&&(L&&ne instanceof L||N(ne.append)&&((re=i(ne))==="formdata"||re==="object"&&N(ne.toString)&&ne.toString()==="[object FormData]"))},Y=o("URLSearchParams"),[Z,W,U,M]=["ReadableStream","Request","Response","Headers"].map(o),z=ne=>ne.trim?ne.trim():ne.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function T(ne,re,{allOwnKeys:me=!1}={}){if(ne===null||typeof ne>"u")return;let pe,Se;if(typeof ne!="object"&&(ne=[ne]),m(ne))for(pe=0,Se=ne.length;pe<Se;pe++)re.call(null,ne[pe],pe,ne);else{if(p(ne))return;const ze=me?Object.getOwnPropertyNames(ne):Object.keys(ne),Ue=ze.length;let ot;for(pe=0;pe<Ue;pe++)ot=ze[pe],re.call(null,ne[ot],ot,ne)}}function I(ne,re){if(p(ne))return null;re=re.toLowerCase();const me=Object.keys(ne);let pe=me.length,Se;for(;pe-- >0;)if(Se=me[pe],re===Se.toLowerCase())return Se;return null}const B=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:Wo,G=ne=>!f(ne)&&ne!==B;function K(){const{caseless:ne,skipUndefined:re}=G(this)&&this||{},me={},pe=(Se,ze)=>{if(ze==="__proto__"||ze==="constructor"||ze==="prototype")return;const Ue=ne&&I(me,ze)||ze;b(me[Ue])&&b(Se)?me[Ue]=K(me[Ue],Se):b(Se)?me[Ue]=K({},Se):m(Se)?me[Ue]=Se.slice():(!re||!f(Se))&&(me[Ue]=Se)};for(let Se=0,ze=arguments.length;Se<ze;Se++)arguments[Se]&&T(arguments[Se],pe);return me}const H=(ne,re,me,{allOwnKeys:pe}={})=>(T(re,(Se,ze)=>{me&&N(Se)?Object.defineProperty(ne,ze,{value:t(Se,me),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(ne,ze,{value:Se,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:pe}),ne),X=ne=>(ne.charCodeAt(0)===65279&&(ne=ne.slice(1)),ne),J=(ne,re,me,pe)=>{ne.prototype=Object.create(re.prototype,pe),Object.defineProperty(ne.prototype,"constructor",{value:ne,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(ne,"super",{value:re.prototype}),me&&Object.assign(ne.prototype,me)},ae=(ne,re,me,pe)=>{let Se,ze,Ue;const ot={};if(re=re||{},ne==null)return re;do{for(Se=Object.getOwnPropertyNames(ne),ze=Se.length;ze-- >0;)Ue=Se[ze],(!pe||pe(Ue,ne,re))&&!ot[Ue]&&(re[Ue]=ne[Ue],ot[Ue]=!0);ne=me!==!1&&n(ne)}while(ne&&(!me||me(ne,re))&&ne!==Object.prototype);return re},le=(ne,re,me)=>{ne=String(ne),(me===void 0||me>ne.length)&&(me=ne.length),me-=re.length;const pe=ne.indexOf(re,me);return pe!==-1&&pe===me},xe=ne=>{if(!ne)return null;if(m(ne))return ne;let re=ne.length;if(!v(re))return null;const me=new Array(re);for(;re-- >0;)me[re]=ne[re];return me},ce=(ne=>re=>ne&&re instanceof ne)(typeof Uint8Array<"u"&&n(Uint8Array)),ve=(ne,re)=>{const pe=(ne&&ne[r]).call(ne);let Se;for(;(Se=pe.next())&&!Se.done;){const ze=Se.value;re.call(ne,ze[0],ze[1])}},Pe=(ne,re)=>{let me;const pe=[];for(;(me=ne.exec(re))!==null;)pe.push(me);return pe},et=o("HTMLFormElement"),kt=ne=>ne.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(me,pe,Se){return pe.toUpperCase()+Se}),vt=(({hasOwnProperty:ne})=>(re,me)=>ne.call(re,me))(Object.prototype),ee=o("RegExp"),ge=(ne,re)=>{const me=Object.getOwnPropertyDescriptors(ne),pe={};T(me,(Se,ze)=>{let Ue;(Ue=re(Se,ze,ne))!==!1&&(pe[ze]=Ue||Se)}),Object.defineProperties(ne,pe)},ye=ne=>{ge(ne,(re,me)=>{if(N(ne)&&["arguments","caller","callee"].indexOf(me)!==-1)return!1;const pe=ne[me];if(N(pe)){if(re.enumerable=!1,"writable"in re){re.writable=!1;return}re.set||(re.set=()=>{throw Error("Can not rewrite read-only method '"+me+"'")})}})},Be=(ne,re)=>{const me={},pe=Se=>{Se.forEach(ze=>{me[ze]=!0})};return m(ne)?pe(ne):pe(String(ne).split(re)),me},$e=()=>{},dt=(ne,re)=>ne!=null&&Number.isFinite(ne=+ne)?ne:re;function st(ne){return!!(ne&&N(ne.append)&&ne[a]==="FormData"&&ne[r])}const xt=ne=>{const re=new Array(10),me=(pe,Se)=>{if(w(pe)){if(re.indexOf(pe)>=0)return;if(p(pe))return pe;if(!("toJSON"in pe)){re[Se]=pe;const ze=m(pe)?[]:{};return T(pe,(Ue,ot)=>{const ls=me(Ue,Se+1);!f(ls)&&(ze[ot]=ls)}),re[Se]=void 0,ze}}return pe};return me(ne,0)},Mt=o("AsyncFunction"),It=ne=>ne&&(w(ne)||N(ne))&&N(ne.then)&&N(ne.catch),he=((ne,re)=>ne?setImmediate:re?((me,pe)=>(B.addEventListener("message",({source:Se,data:ze})=>{Se===B&&ze===me&&pe.length&&pe.shift()()},!1),Se=>{pe.push(Se),B.postMessage(me,"*")}))(`axios@${Math.random()}`,[]):me=>setTimeout(me))(typeof setImmediate=="function",N(B.postMessage)),pt=typeof queueMicrotask<"u"?queueMicrotask.bind(B):typeof process<"u"&&process.nextTick||he;var _e={isArray:m,isArrayBuffer:h,isBuffer:p,isFormData:$,isArrayBufferView:x,isString:u,isNumber:v,isBoolean:j,isObject:w,isPlainObject:b,isEmptyObject:C,isReadableStream:Z,isRequest:W,isResponse:U,isHeaders:M,isUndefined:f,isDate:S,isFile:R,isReactNativeBlob:_,isReactNative:A,isBlob:E,isRegExp:ee,isFunction:N,isStream:O,isURLSearchParams:Y,isTypedArray:ce,isFileList:q,forEach:T,merge:K,extend:H,trim:z,stripBOM:X,inherits:J,toFlatObject:ae,kindOf:i,kindOfTest:o,endsWith:le,toArray:xe,forEachEntry:ve,matchAll:Pe,isHTMLForm:et,hasOwnProperty:vt,hasOwnProp:vt,reduceDescriptors:ge,freezeMethods:ye,toObjectSet:Be,toCamelCase:kt,noop:$e,toFiniteNumber:dt,findKey:I,global:B,isContextDefined:G,isSpecCompliantForm:st,toJSONObject:xt,isAsyncFn:Mt,isThenable:It,setImmediate:he,asap:pt,isIterable:ne=>ne!=null&&N(ne[r])};class Vt extends Error{static from(re,me,pe,Se,ze,Ue){const ot=new Vt(re.message,me||re.code,pe,Se,ze);return ot.cause=re,ot.name=re.name,re.status!=null&&ot.status==null&&(ot.status=re.status),Ue&&Object.assign(ot,Ue),ot}constructor(re,me,pe,Se,ze){super(re),Object.defineProperty(this,"message",{value:re,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,me&&(this.code=me),pe&&(this.config=pe),Se&&(this.request=Se),ze&&(this.response=ze,this.status=ze.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:_e.toJSONObject(this.config),code:this.code,status:this.status}}}Vt.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",Vt.ERR_BAD_OPTION="ERR_BAD_OPTION",Vt.ECONNABORTED="ECONNABORTED",Vt.ETIMEDOUT="ETIMEDOUT",Vt.ERR_NETWORK="ERR_NETWORK",Vt.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",Vt.ERR_DEPRECATED="ERR_DEPRECATED",Vt.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",Vt.ERR_BAD_REQUEST="ERR_BAD_REQUEST",Vt.ERR_CANCELED="ERR_CANCELED",Vt.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",Vt.ERR_INVALID_URL="ERR_INVALID_URL";var Pt=Vt,_s=null;function Ys(ne){return _e.isPlainObject(ne)||_e.isArray(ne)}function Bs(ne){return _e.endsWith(ne,"[]")?ne.slice(0,-2):ne}function Ks(ne,re,me){return ne?ne.concat(re).map(function(Se,ze){return Se=Bs(Se),!me&&ze?"["+Se+"]":Se}).join(me?".":""):re}function Qs(ne){return _e.isArray(ne)&&!ne.some(Ys)}const Xs=_e.toFlatObject(_e,{},null,function(re){return/^is[A-Z]/.test(re)});function $s(ne,re,me){if(!_e.isObject(ne))throw new TypeError("target must be an object");re=re||new FormData,me=_e.toFlatObject(me,{metaTokens:!0,dots:!1,indexes:!1},!1,function(Ss,is){return!_e.isUndefined(is[Ss])});const pe=me.metaTokens,Se=me.visitor||Lt,ze=me.dots,Ue=me.indexes,ls=(me.Blob||typeof Blob<"u"&&Blob)&&_e.isSpecCompliantForm(re);if(!_e.isFunction(Se))throw new TypeError("visitor must be a function");function Gt(Bt){if(Bt===null)return"";if(_e.isDate(Bt))return Bt.toISOString();if(_e.isBoolean(Bt))return Bt.toString();if(!ls&&_e.isBlob(Bt))throw new Pt("Blob is not supported. Use a Buffer instead.");return _e.isArrayBuffer(Bt)||_e.isTypedArray(Bt)?ls&&typeof Blob=="function"?new Blob([Bt]):Buffer.from(Bt):Bt}function Lt(Bt,Ss,is){let Mn=Bt;if(_e.isReactNative(re)&&_e.isReactNativeBlob(Bt))return re.append(Ks(is,Ss,ze),Gt(Bt)),!1;if(Bt&&!is&&typeof Bt=="object"){if(_e.endsWith(Ss,"{}"))Ss=pe?Ss:Ss.slice(0,-2),Bt=JSON.stringify(Bt);else if(_e.isArray(Bt)&&Qs(Bt)||(_e.isFileList(Bt)||_e.endsWith(Ss,"[]"))&&(Mn=_e.toArray(Bt)))return Ss=Bs(Ss),Mn.forEach(function(Gn,gr){!(_e.isUndefined(Gn)||Gn===null)&&re.append(Ue===!0?Ks([Ss],gr,ze):Ue===null?Ss:Ss+"[]",Gt(Gn))}),!1}return Ys(Bt)?!0:(re.append(Ks(is,Ss,ze),Gt(Bt)),!1)}const ws=[],gn=Object.assign(Xs,{defaultVisitor:Lt,convertValue:Gt,isVisitable:Ys});function nr(Bt,Ss){if(!_e.isUndefined(Bt)){if(ws.indexOf(Bt)!==-1)throw Error("Circular reference detected in "+Ss.join("."));ws.push(Bt),_e.forEach(Bt,function(Mn,_r){(!(_e.isUndefined(Mn)||Mn===null)&&Se.call(re,Mn,_e.isString(_r)?_r.trim():_r,Ss,gn))===!0&&nr(Mn,Ss?Ss.concat(_r):[_r])}),ws.pop()}}if(!_e.isObject(ne))throw new TypeError("data must be an object");return nr(ne),re}function Q(ne){const re={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(ne).replace(/[!'()~]|%20|%00/g,function(pe){return re[pe]})}function oe(ne,re){this._pairs=[],ne&&$s(ne,this,re)}const we=oe.prototype;we.append=function(re,me){this._pairs.push([re,me])},we.toString=function(re){const me=re?function(pe){return re.call(this,pe,Q)}:Q;return this._pairs.map(function(Se){return me(Se[0])+"="+me(Se[1])},"").join("&")};function Oe(ne){return encodeURIComponent(ne).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ke(ne,re,me){if(!re)return ne;const pe=me&&me.encode||Oe,Se=_e.isFunction(me)?{serialize:me}:me,ze=Se&&Se.serialize;let Ue;if(ze?Ue=ze(re,Se):Ue=_e.isURLSearchParams(re)?re.toString():new oe(re,Se).toString(pe),Ue){const ot=ne.indexOf("#");ot!==-1&&(ne=ne.slice(0,ot)),ne+=(ne.indexOf("?")===-1?"?":"&")+Ue}return ne}class je{constructor(){this.handlers=[]}use(re,me,pe){return this.handlers.push({fulfilled:re,rejected:me,synchronous:pe?pe.synchronous:!1,runWhen:pe?pe.runWhen:null}),this.handlers.length-1}eject(re){this.handlers[re]&&(this.handlers[re]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(re){_e.forEach(this.handlers,function(pe){pe!==null&&re(pe)})}}var Ve=je,Ge={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},nt=typeof URLSearchParams<"u"?URLSearchParams:oe,Zt=typeof FormData<"u"?FormData:null,Jt=typeof Blob<"u"?Blob:null,lt={isBrowser:!0,classes:{URLSearchParams:nt,FormData:Zt,Blob:Jt},protocols:["http","https","file","blob","url","data"]};const mt=typeof window<"u"&&typeof document<"u",Ds=typeof navigator=="object"&&navigator||void 0,ss=mt&&(!Ds||["ReactNative","NativeScript","NS"].indexOf(Ds.product)<0),Ae=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",be=mt&&window.location.href||"http://localhost";var ut=Object.freeze({__proto__:null,hasBrowserEnv:mt,hasStandardBrowserWebWorkerEnv:Ae,hasStandardBrowserEnv:ss,navigator:Ds,origin:be}),He={...ut,...lt};function yt(ne,re){return $s(ne,new He.classes.URLSearchParams,{visitor:function(me,pe,Se,ze){return He.isNode&&_e.isBuffer(me)?(this.append(pe,me.toString("base64")),!1):ze.defaultVisitor.apply(this,arguments)},...re})}function ft(ne){return _e.matchAll(/\w+|\[(\w*)]/g,ne).map(re=>re[0]==="[]"?"":re[1]||re[0])}function es(ne){const re={},me=Object.keys(ne);let pe;const Se=me.length;let ze;for(pe=0;pe<Se;pe++)ze=me[pe],re[ze]=ne[ze];return re}function ts(ne){function re(me,pe,Se,ze){let Ue=me[ze++];if(Ue==="__proto__")return!0;const ot=Number.isFinite(+Ue),ls=ze>=me.length;return Ue=!Ue&&_e.isArray(Se)?Se.length:Ue,ls?(_e.hasOwnProp(Se,Ue)?Se[Ue]=[Se[Ue],pe]:Se[Ue]=pe,!ot):((!Se[Ue]||!_e.isObject(Se[Ue]))&&(Se[Ue]=[]),re(me,pe,Se[Ue],ze)&&_e.isArray(Se[Ue])&&(Se[Ue]=es(Se[Ue])),!ot)}if(_e.isFormData(ne)&&_e.isFunction(ne.entries)){const me={};return _e.forEachEntry(ne,(pe,Se)=>{re(ft(pe),Se,me,0)}),me}return null}function Cs(ne,re,me){if(_e.isString(ne))try{return(re||JSON.parse)(ne),_e.trim(ne)}catch(pe){if(pe.name!=="SyntaxError")throw pe}return(me||JSON.stringify)(ne)}const Us={transitional:Ge,adapter:["xhr","http","fetch"],transformRequest:[function(re,me){const pe=me.getContentType()||"",Se=pe.indexOf("application/json")>-1,ze=_e.isObject(re);if(ze&&_e.isHTMLForm(re)&&(re=new FormData(re)),_e.isFormData(re))return Se?JSON.stringify(ts(re)):re;if(_e.isArrayBuffer(re)||_e.isBuffer(re)||_e.isStream(re)||_e.isFile(re)||_e.isBlob(re)||_e.isReadableStream(re))return re;if(_e.isArrayBufferView(re))return re.buffer;if(_e.isURLSearchParams(re))return me.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),re.toString();let ot;if(ze){if(pe.indexOf("application/x-www-form-urlencoded")>-1)return yt(re,this.formSerializer).toString();if((ot=_e.isFileList(re))||pe.indexOf("multipart/form-data")>-1){const ls=this.env&&this.env.FormData;return $s(ot?{"files[]":re}:re,ls&&new ls,this.formSerializer)}}return ze||Se?(me.setContentType("application/json",!1),Cs(re)):re}],transformResponse:[function(re){const me=this.transitional||Us.transitional,pe=me&&me.forcedJSONParsing,Se=this.responseType==="json";if(_e.isResponse(re)||_e.isReadableStream(re))return re;if(re&&_e.isString(re)&&(pe&&!this.responseType||Se)){const Ue=!(me&&me.silentJSONParsing)&&Se;try{return JSON.parse(re,this.parseReviver)}catch(ot){if(Ue)throw ot.name==="SyntaxError"?Pt.from(ot,Pt.ERR_BAD_RESPONSE,this,null,this.response):ot}}return re}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:He.classes.FormData,Blob:He.classes.Blob},validateStatus:function(re){return re>=200&&re<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};_e.forEach(["delete","get","head","post","put","patch"],ne=>{Us.headers[ne]={}});var rn=Us;const Js=_e.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);var an=ne=>{const re={};let me,pe,Se;return ne&&ne.split(`
`).forEach(function(Ue){Se=Ue.indexOf(":"),me=Ue.substring(0,Se).trim().toLowerCase(),pe=Ue.substring(Se+1).trim(),!(!me||re[me]&&Js[me])&&(me==="set-cookie"?re[me]?re[me].push(pe):re[me]=[pe]:re[me]=re[me]?re[me]+", "+pe:pe)}),re};const hn=Symbol("internals");function De(ne){return ne&&String(ne).trim().toLowerCase()}function bt(ne){return ne===!1||ne==null?ne:_e.isArray(ne)?ne.map(bt):String(ne)}function Te(ne){const re=Object.create(null),me=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let pe;for(;pe=me.exec(ne);)re[pe[1]]=pe[2];return re}const ct=ne=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(ne.trim());function tt(ne,re,me,pe,Se){if(_e.isFunction(pe))return pe.call(this,re,me);if(Se&&(re=me),!!_e.isString(re)){if(_e.isString(pe))return re.indexOf(pe)!==-1;if(_e.isRegExp(pe))return pe.test(re)}}function jt(ne){return ne.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(re,me,pe)=>me.toUpperCase()+pe)}function Ht(ne,re){const me=_e.toCamelCase(" "+re);["get","set","has"].forEach(pe=>{Object.defineProperty(ne,pe+me,{value:function(Se,ze,Ue){return this[pe].call(this,re,Se,ze,Ue)},configurable:!0})})}class zt{constructor(re){re&&this.set(re)}set(re,me,pe){const Se=this;function ze(ot,ls,Gt){const Lt=De(ls);if(!Lt)throw new Error("header name must be a non-empty string");const ws=_e.findKey(Se,Lt);(!ws||Se[ws]===void 0||Gt===!0||Gt===void 0&&Se[ws]!==!1)&&(Se[ws||ls]=bt(ot))}const Ue=(ot,ls)=>_e.forEach(ot,(Gt,Lt)=>ze(Gt,Lt,ls));if(_e.isPlainObject(re)||re instanceof this.constructor)Ue(re,me);else if(_e.isString(re)&&(re=re.trim())&&!ct(re))Ue(an(re),me);else if(_e.isObject(re)&&_e.isIterable(re)){let ot={},ls,Gt;for(const Lt of re){if(!_e.isArray(Lt))throw TypeError("Object iterator must return a key-value pair");ot[Gt=Lt[0]]=(ls=ot[Gt])?_e.isArray(ls)?[...ls,Lt[1]]:[ls,Lt[1]]:Lt[1]}Ue(ot,me)}else re!=null&&ze(me,re,pe);return this}get(re,me){if(re=De(re),re){const pe=_e.findKey(this,re);if(pe){const Se=this[pe];if(!me)return Se;if(me===!0)return Te(Se);if(_e.isFunction(me))return me.call(this,Se,pe);if(_e.isRegExp(me))return me.exec(Se);throw new TypeError("parser must be boolean|regexp|function")}}}has(re,me){if(re=De(re),re){const pe=_e.findKey(this,re);return!!(pe&&this[pe]!==void 0&&(!me||tt(this,this[pe],pe,me)))}return!1}delete(re,me){const pe=this;let Se=!1;function ze(Ue){if(Ue=De(Ue),Ue){const ot=_e.findKey(pe,Ue);ot&&(!me||tt(pe,pe[ot],ot,me))&&(delete pe[ot],Se=!0)}}return _e.isArray(re)?re.forEach(ze):ze(re),Se}clear(re){const me=Object.keys(this);let pe=me.length,Se=!1;for(;pe--;){const ze=me[pe];(!re||tt(this,this[ze],ze,re,!0))&&(delete this[ze],Se=!0)}return Se}normalize(re){const me=this,pe={};return _e.forEach(this,(Se,ze)=>{const Ue=_e.findKey(pe,ze);if(Ue){me[Ue]=bt(Se),delete me[ze];return}const ot=re?jt(ze):String(ze).trim();ot!==ze&&delete me[ze],me[ot]=bt(Se),pe[ot]=!0}),this}concat(...re){return this.constructor.concat(this,...re)}toJSON(re){const me=Object.create(null);return _e.forEach(this,(pe,Se)=>{pe!=null&&pe!==!1&&(me[Se]=re&&_e.isArray(pe)?pe.join(", "):pe)}),me}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([re,me])=>re+": "+me).join(`
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(re){return re instanceof this?re:new this(re)}static concat(re,...me){const pe=new this(re);return me.forEach(Se=>pe.set(Se)),pe}static accessor(re){const pe=(this[hn]=this[hn]={accessors:{}}).accessors,Se=this.prototype;function ze(Ue){const ot=De(Ue);pe[ot]||(Ht(Se,Ue),pe[ot]=!0)}return _e.isArray(re)?re.forEach(ze):ze(re),this}}zt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),_e.reduceDescriptors(zt.prototype,({value:ne},re)=>{let me=re[0].toUpperCase()+re.slice(1);return{get:()=>ne,set(pe){this[me]=pe}}}),_e.freezeMethods(zt);var fs=zt;function qt(ne,re){const me=this||rn,pe=re||me,Se=fs.from(pe.headers);let ze=pe.data;return _e.forEach(ne,function(ot){ze=ot.call(me,ze,Se.normalize(),re?re.status:void 0)}),Se.normalize(),ze}function As(ne){return!!(ne&&ne.__CANCEL__)}class vs extends Pt{constructor(re,me,pe){super(re??"canceled",Pt.ERR_CANCELED,me,pe),this.name="CanceledError",this.__CANCEL__=!0}}var cs=vs;function mn(ne,re,me){const pe=me.config.validateStatus;!me.status||!pe||pe(me.status)?ne(me):re(new Pt("Request failed with status code "+me.status,[Pt.ERR_BAD_REQUEST,Pt.ERR_BAD_RESPONSE][Math.floor(me.status/100)-4],me.config,me.request,me))}function qs(ne){const re=/^([-+\w]{1,25})(:?\/\/|:)/.exec(ne);return re&&re[1]||""}function ln(ne,re){ne=ne||10;const me=new Array(ne),pe=new Array(ne);let Se=0,ze=0,Ue;return re=re!==void 0?re:1e3,function(ls){const Gt=Date.now(),Lt=pe[ze];Ue||(Ue=Gt),me[Se]=ls,pe[Se]=Gt;let ws=ze,gn=0;for(;ws!==Se;)gn+=me[ws++],ws=ws%ne;if(Se=(Se+1)%ne,Se===ze&&(ze=(ze+1)%ne),Gt-Ue<re)return;const nr=Lt&&Gt-Lt;return nr?Math.round(gn*1e3/nr):void 0}}function fn(ne,re){let me=0,pe=1e3/re,Se,ze;const Ue=(Gt,Lt=Date.now())=>{me=Lt,Se=null,ze&&(clearTimeout(ze),ze=null),ne(...Gt)};return[(...Gt)=>{const Lt=Date.now(),ws=Lt-me;ws>=pe?Ue(Gt,Lt):(Se=Gt,ze||(ze=setTimeout(()=>{ze=null,Ue(Se)},pe-ws)))},()=>Se&&Ue(Se)]}const on=(ne,re,me=3)=>{let pe=0;const Se=ln(50,250);return fn(ze=>{const Ue=ze.loaded,ot=ze.lengthComputable?ze.total:void 0,ls=Ue-pe,Gt=Se(ls),Lt=Ue<=ot;pe=Ue;const ws={loaded:Ue,total:ot,progress:ot?Ue/ot:void 0,bytes:ls,rate:Gt||void 0,estimated:Gt&&ot&&Lt?(ot-Ue)/Gt:void 0,event:ze,lengthComputable:ot!=null,[re?"download":"upload"]:!0};ne(ws)},me)},Ye=(ne,re)=>{const me=ne!=null;return[pe=>re[0]({lengthComputable:me,total:ne,loaded:pe}),re[1]]},Ot=ne=>(...re)=>_e.asap(()=>ne(...re));var St=He.hasStandardBrowserEnv?((ne,re)=>me=>(me=new URL(me,He.origin),ne.protocol===me.protocol&&ne.host===me.host&&(re||ne.port===me.port)))(new URL(He.origin),He.navigator&&/(msie|trident)/i.test(He.navigator.userAgent)):()=>!0,rt=He.hasStandardBrowserEnv?{write(ne,re,me,pe,Se,ze,Ue){if(typeof document>"u")return;const ot=[`${ne}=${encodeURIComponent(re)}`];_e.isNumber(me)&&ot.push(`expires=${new Date(me).toUTCString()}`),_e.isString(pe)&&ot.push(`path=${pe}`),_e.isString(Se)&&ot.push(`domain=${Se}`),ze===!0&&ot.push("secure"),_e.isString(Ue)&&ot.push(`SameSite=${Ue}`),document.cookie=ot.join("; ")},read(ne){if(typeof document>"u")return null;const re=document.cookie.match(new RegExp("(?:^|; )"+ne+"=([^;]*)"));return re?decodeURIComponent(re[1]):null},remove(ne){this.write(ne,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Ft(ne){return typeof ne!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(ne)}function jn(ne,re){return re?ne.replace(/\/?\/$/,"")+"/"+re.replace(/^\/+/,""):ne}function xn(ne,re,me){let pe=!Ft(re);return ne&&(pe||me==!1)?jn(ne,re):re}const qn=ne=>ne instanceof fs?{...ne}:ne;function En(ne,re){re=re||{};const me={};function pe(Gt,Lt,ws,gn){return _e.isPlainObject(Gt)&&_e.isPlainObject(Lt)?_e.merge.call({caseless:gn},Gt,Lt):_e.isPlainObject(Lt)?_e.merge({},Lt):_e.isArray(Lt)?Lt.slice():Lt}function Se(Gt,Lt,ws,gn){if(_e.isUndefined(Lt)){if(!_e.isUndefined(Gt))return pe(void 0,Gt,ws,gn)}else return pe(Gt,Lt,ws,gn)}function ze(Gt,Lt){if(!_e.isUndefined(Lt))return pe(void 0,Lt)}function Ue(Gt,Lt){if(_e.isUndefined(Lt)){if(!_e.isUndefined(Gt))return pe(void 0,Gt)}else return pe(void 0,Lt)}function ot(Gt,Lt,ws){if(ws in re)return pe(Gt,Lt);if(ws in ne)return pe(void 0,Gt)}const ls={url:ze,method:ze,data:ze,baseURL:Ue,transformRequest:Ue,transformResponse:Ue,paramsSerializer:Ue,timeout:Ue,timeoutMessage:Ue,withCredentials:Ue,withXSRFToken:Ue,adapter:Ue,responseType:Ue,xsrfCookieName:Ue,xsrfHeaderName:Ue,onUploadProgress:Ue,onDownloadProgress:Ue,decompress:Ue,maxContentLength:Ue,maxBodyLength:Ue,beforeRedirect:Ue,transport:Ue,httpAgent:Ue,httpsAgent:Ue,cancelToken:Ue,socketPath:Ue,responseEncoding:Ue,validateStatus:ot,headers:(Gt,Lt,ws)=>Se(qn(Gt),qn(Lt),ws,!0)};return _e.forEach(Object.keys({...ne,...re}),function(Lt){if(Lt==="__proto__"||Lt==="constructor"||Lt==="prototype")return;const ws=_e.hasOwnProp(ls,Lt)?ls[Lt]:Se,gn=ws(ne[Lt],re[Lt],Lt);_e.isUndefined(gn)&&ws!==ot||(me[Lt]=gn)}),me}var Hs=ne=>{const re=En({},ne);let{data:me,withXSRFToken:pe,xsrfHeaderName:Se,xsrfCookieName:ze,headers:Ue,auth:ot}=re;if(re.headers=Ue=fs.from(Ue),re.url=ke(xn(re.baseURL,re.url,re.allowAbsoluteUrls),ne.params,ne.paramsSerializer),ot&&Ue.set("Authorization","Basic "+btoa((ot.username||"")+":"+(ot.password?unescape(encodeURIComponent(ot.password)):""))),_e.isFormData(me)){if(He.hasStandardBrowserEnv||He.hasStandardBrowserWebWorkerEnv)Ue.setContentType(void 0);else if(_e.isFunction(me.getHeaders)){const ls=me.getHeaders(),Gt=["content-type","content-length"];Object.entries(ls).forEach(([Lt,ws])=>{Gt.includes(Lt.toLowerCase())&&Ue.set(Lt,ws)})}}if(He.hasStandardBrowserEnv&&(pe&&_e.isFunction(pe)&&(pe=pe(re)),pe||pe!==!1&&St(re.url))){const ls=Se&&ze&&rt.read(ze);ls&&Ue.set(Se,ls)}return re},Pa=typeof XMLHttpRequest<"u"&&function(ne){return new Promise(function(me,pe){const Se=Hs(ne);let ze=Se.data;const Ue=fs.from(Se.headers).normalize();let{responseType:ot,onUploadProgress:ls,onDownloadProgress:Gt}=Se,Lt,ws,gn,nr,Bt;function Ss(){nr&&nr(),Bt&&Bt(),Se.cancelToken&&Se.cancelToken.unsubscribe(Lt),Se.signal&&Se.signal.removeEventListener("abort",Lt)}let is=new XMLHttpRequest;is.open(Se.method.toUpperCase(),Se.url,!0),is.timeout=Se.timeout;function Mn(){if(!is)return;const Gn=fs.from("getAllResponseHeaders"in is&&is.getAllResponseHeaders()),Gr={data:!ot||ot==="text"||ot==="json"?is.responseText:is.response,status:is.status,statusText:is.statusText,headers:Gn,config:ne,request:is};mn(function(vr){me(vr),Ss()},function(vr){pe(vr),Ss()},Gr),is=null}"onloadend"in is?is.onloadend=Mn:is.onreadystatechange=function(){!is||is.readyState!==4||is.status===0&&!(is.responseURL&&is.responseURL.indexOf("file:")===0)||setTimeout(Mn)},is.onabort=function(){is&&(pe(new Pt("Request aborted",Pt.ECONNABORTED,ne,is)),is=null)},is.onerror=function(gr){const Gr=gr&&gr.message?gr.message:"Network Error",Qa=new Pt(Gr,Pt.ERR_NETWORK,ne,is);Qa.event=gr||null,pe(Qa),is=null},is.ontimeout=function(){let gr=Se.timeout?"timeout of "+Se.timeout+"ms exceeded":"timeout exceeded";const Gr=Se.transitional||Ge;Se.timeoutErrorMessage&&(gr=Se.timeoutErrorMessage),pe(new Pt(gr,Gr.clarifyTimeoutError?Pt.ETIMEDOUT:Pt.ECONNABORTED,ne,is)),is=null},ze===void 0&&Ue.setContentType(null),"setRequestHeader"in is&&_e.forEach(Ue.toJSON(),function(gr,Gr){is.setRequestHeader(Gr,gr)}),_e.isUndefined(Se.withCredentials)||(is.withCredentials=!!Se.withCredentials),ot&&ot!=="json"&&(is.responseType=Se.responseType),Gt&&([gn,Bt]=on(Gt,!0),is.addEventListener("progress",gn)),ls&&is.upload&&([ws,nr]=on(ls),is.upload.addEventListener("progress",ws),is.upload.addEventListener("loadend",nr)),(Se.cancelToken||Se.signal)&&(Lt=Gn=>{is&&(pe(!Gn||Gn.type?new cs(null,ne,is):Gn),is.abort(),is=null)},Se.cancelToken&&Se.cancelToken.subscribe(Lt),Se.signal&&(Se.signal.aborted?Lt():Se.signal.addEventListener("abort",Lt)));const _r=qs(Se.url);if(_r&&He.protocols.indexOf(_r)===-1){pe(new Pt("Unsupported protocol "+_r+":",Pt.ERR_BAD_REQUEST,ne));return}is.send(ze||null)})},nn=(ne,re)=>{const{length:me}=ne=ne?ne.filter(Boolean):[];if(re||me){let pe=new AbortController,Se;const ze=function(Gt){if(!Se){Se=!0,ot();const Lt=Gt instanceof Error?Gt:this.reason;pe.abort(Lt instanceof Pt?Lt:new cs(Lt instanceof Error?Lt.message:Lt))}};let Ue=re&&setTimeout(()=>{Ue=null,ze(new Pt(`timeout of ${re}ms exceeded`,Pt.ETIMEDOUT))},re);const ot=()=>{ne&&(Ue&&clearTimeout(Ue),Ue=null,ne.forEach(Gt=>{Gt.unsubscribe?Gt.unsubscribe(ze):Gt.removeEventListener("abort",ze)}),ne=null)};ne.forEach(Gt=>Gt.addEventListener("abort",ze));const{signal:ls}=pe;return ls.unsubscribe=()=>_e.asap(ot),ls}};const ta=function*(ne,re){let me=ne.byteLength;if(me<re){yield ne;return}let pe=0,Se;for(;pe<me;)Se=pe+re,yield ne.slice(pe,Se),pe=Se},sa=async function*(ne,re){for await(const me of na(ne))yield*ta(me,re)},na=async function*(ne){if(ne[Symbol.asyncIterator]){yield*ne;return}const re=ne.getReader();try{for(;;){const{done:me,value:pe}=await re.read();if(me)break;yield pe}}finally{await re.cancel()}},Ir=(ne,re,me,pe)=>{const Se=sa(ne,re);let ze=0,Ue,ot=ls=>{Ue||(Ue=!0,pe&&pe(ls))};return new ReadableStream({async pull(ls){try{const{done:Gt,value:Lt}=await Se.next();if(Gt){ot(),ls.close();return}let ws=Lt.byteLength;if(me){let gn=ze+=ws;me(gn)}ls.enqueue(new Uint8Array(Lt))}catch(Gt){throw ot(Gt),Gt}},cancel(ls){return ot(ls),Se.return()}},{highWaterMark:2})},Xn=64*1024,{isFunction:zn}=_e,Qt=(({Request:ne,Response:re})=>({Request:ne,Response:re}))(_e.global),{ReadableStream:Jn,TextEncoder:Rr}=_e.global,Wn=(ne,...re)=>{try{return!!ne(...re)}catch{return!1}},Er=ne=>{ne=_e.merge.call({skipUndefined:!0},Qt,ne);const{fetch:re,Request:me,Response:pe}=ne,Se=re?zn(re):typeof fetch=="function",ze=zn(me),Ue=zn(pe);if(!Se)return!1;const ot=Se&&zn(Jn),ls=Se&&(typeof Rr=="function"?(Bt=>Ss=>Bt.encode(Ss))(new Rr):async Bt=>new Uint8Array(await new me(Bt).arrayBuffer())),Gt=ze&&ot&&Wn(()=>{let Bt=!1;const Ss=new me(He.origin,{body:new Jn,method:"POST",get duplex(){return Bt=!0,"half"}}).headers.has("Content-Type");return Bt&&!Ss}),Lt=Ue&&ot&&Wn(()=>_e.isReadableStream(new pe("").body)),ws={stream:Lt&&(Bt=>Bt.body)};Se&&["text","arrayBuffer","blob","formData","stream"].forEach(Bt=>{!ws[Bt]&&(ws[Bt]=(Ss,is)=>{let Mn=Ss&&Ss[Bt];if(Mn)return Mn.call(Ss);throw new Pt(`Response type '${Bt}' is not supported`,Pt.ERR_NOT_SUPPORT,is)})});const gn=async Bt=>{if(Bt==null)return 0;if(_e.isBlob(Bt))return Bt.size;if(_e.isSpecCompliantForm(Bt))return(await new me(He.origin,{method:"POST",body:Bt}).arrayBuffer()).byteLength;if(_e.isArrayBufferView(Bt)||_e.isArrayBuffer(Bt))return Bt.byteLength;if(_e.isURLSearchParams(Bt)&&(Bt=Bt+""),_e.isString(Bt))return(await ls(Bt)).byteLength},nr=async(Bt,Ss)=>{const is=_e.toFiniteNumber(Bt.getContentLength());return is??gn(Ss)};return async Bt=>{let{url:Ss,method:is,data:Mn,signal:_r,cancelToken:Gn,timeout:gr,onDownloadProgress:Gr,onUploadProgress:Qa,responseType:vr,headers:wo,withCredentials:Cl="same-origin",fetchOptions:xc}=Hs(Bt),So=re||fetch;vr=vr?(vr+"").toLowerCase():"text";let Al=nn([_r,Gn&&Gn.toAbortSignal()],gr),Ki=null;const Xa=Al&&Al.unsubscribe&&(()=>{Al.unsubscribe()});let gc;try{if(Qa&&Gt&&is!=="get"&&is!=="head"&&(gc=await nr(wo,Mn))!==0){let Ia=new me(Ss,{method:"POST",body:Mn,duplex:"half"}),Ja;if(_e.isFormData(Mn)&&(Ja=Ia.headers.get("content-type"))&&wo.setContentType(Ja),Ia.body){const[Dl,Zi]=Ye(gc,on(Ot(Qa)));Mn=Ir(Ia.body,Xn,Dl,Zi)}}_e.isString(Cl)||(Cl=Cl?"include":"omit");const hr=ze&&"credentials"in me.prototype,vc={...xc,signal:Al,method:is.toUpperCase(),headers:wo.normalize().toJSON(),body:Mn,duplex:"half",credentials:hr?Cl:void 0};Ki=ze&&new me(Ss,vc);let La=await(ze?So(Ki,xc):So(Ss,vc));const kl=Lt&&(vr==="stream"||vr==="response");if(Lt&&(Gr||kl&&Xa)){const Ia={};["status","statusText","headers"].forEach(Co=>{Ia[Co]=La[Co]});const Ja=_e.toFiniteNumber(La.headers.get("content-length")),[Dl,Zi]=Gr&&Ye(Ja,on(Ot(Gr),!0))||[];La=new pe(Ir(La.body,Xn,Dl,()=>{Zi&&Zi(),Xa&&Xa()}),Ia)}vr=vr||"text";let Yi=await ws[_e.findKey(ws,vr)||"text"](La,Bt);return!kl&&Xa&&Xa(),await new Promise((Ia,Ja)=>{mn(Ia,Ja,{data:Yi,headers:fs.from(La.headers),status:La.status,statusText:La.statusText,config:Bt,request:Ki})})}catch(hr){throw Xa&&Xa(),hr&&hr.name==="TypeError"&&/Load failed|fetch/i.test(hr.message)?Object.assign(new Pt("Network Error",Pt.ERR_NETWORK,Bt,Ki,hr&&hr.response),{cause:hr.cause||hr}):Pt.from(hr,hr&&hr.code,Bt,Ki,hr&&hr.response)}}},_n=new Map,ur=ne=>{let re=ne&&ne.env||{};const{fetch:me,Request:pe,Response:Se}=re,ze=[pe,Se,me];let Ue=ze.length,ot=Ue,ls,Gt,Lt=_n;for(;ot--;)ls=ze[ot],Gt=Lt.get(ls),Gt===void 0&&Lt.set(ls,Gt=ot?new Map:Er(re)),Lt=Gt;return Gt};ur();const rs={http:_s,xhr:Pa,fetch:{get:ur}};_e.forEach(rs,(ne,re)=>{if(ne){try{Object.defineProperty(ne,"name",{value:re})}catch{}Object.defineProperty(ne,"adapterName",{value:re})}});const en=ne=>`- ${ne}`,va=ne=>_e.isFunction(ne)||ne===null||ne===!1;function wi(ne,re){ne=_e.isArray(ne)?ne:[ne];const{length:me}=ne;let pe,Se;const ze={};for(let Ue=0;Ue<me;Ue++){pe=ne[Ue];let ot;if(Se=pe,!va(pe)&&(Se=rs[(ot=String(pe)).toLowerCase()],Se===void 0))throw new Pt(`Unknown adapter '${ot}'`);if(Se&&(_e.isFunction(Se)||(Se=Se.get(re))))break;ze[ot||"#"+Ue]=Se}if(!Se){const Ue=Object.entries(ze).map(([ls,Gt])=>`adapter ${ls} `+(Gt===!1?"is not supported by the environment":"is not available in the build"));let ot=me?Ue.length>1?`since :
`+Ue.map(en).join(`
`):" "+en(Ue[0]):"as no adapter specified";throw new Pt("There is no suitable adapter to dispatch the request "+ot,"ERR_NOT_SUPPORT")}return Se}var Si={getAdapter:wi,adapters:rs};function Mr(ne){if(ne.cancelToken&&ne.cancelToken.throwIfRequested(),ne.signal&&ne.signal.aborted)throw new cs(null,ne)}function Hr(ne){return Mr(ne),ne.headers=fs.from(ne.headers),ne.data=qt.call(ne,ne.transformRequest),["post","put","patch"].indexOf(ne.method)!==-1&&ne.headers.setContentType("application/x-www-form-urlencoded",!1),Si.getAdapter(ne.adapter||rn.adapter,ne)(ne).then(function(pe){return Mr(ne),pe.data=qt.call(ne,ne.transformResponse,pe),pe.headers=fs.from(pe.headers),pe},function(pe){return As(pe)||(Mr(ne),pe&&pe.response&&(pe.response.data=qt.call(ne,ne.transformResponse,pe.response),pe.response.headers=fs.from(pe.response.headers))),Promise.reject(pe)})}const sr="1.13.6",ya={};["object","boolean","number","function","string","symbol"].forEach((ne,re)=>{ya[ne]=function(pe){return typeof pe===ne||"a"+(re<1?"n ":" ")+ne}});const Hi={};ya.transitional=function(re,me,pe){function Se(ze,Ue){return"[Axios v"+sr+"] Transitional option '"+ze+"'"+Ue+(pe?". "+pe:"")}return(ze,Ue,ot)=>{if(re===!1)throw new Pt(Se(Ue," has been removed"+(me?" in "+me:"")),Pt.ERR_DEPRECATED);return me&&!Hi[Ue]&&(Hi[Ue]=!0,console.warn(Se(Ue," has been deprecated since v"+me+" and will be removed in the near future"))),re?re(ze,Ue,ot):!0}},ya.spelling=function(re){return(me,pe)=>(console.warn(`${pe} is likely a misspelling of ${re}`),!0)};function bo(ne,re,me){if(typeof ne!="object")throw new Pt("options must be an object",Pt.ERR_BAD_OPTION_VALUE);const pe=Object.keys(ne);let Se=pe.length;for(;Se-- >0;){const ze=pe[Se],Ue=re[ze];if(Ue){const ot=ne[ze],ls=ot===void 0||Ue(ot,ze,ne);if(ls!==!0)throw new Pt("option "+ze+" must be "+ls,Pt.ERR_BAD_OPTION_VALUE);continue}if(me!==!0)throw new Pt("Unknown option "+ze,Pt.ERR_BAD_OPTION)}}var Oa={assertOptions:bo,validators:ya};const Cn=Oa.validators;class ba{constructor(re){this.defaults=re||{},this.interceptors={request:new Ve,response:new Ve}}async request(re,me){try{return await this._request(re,me)}catch(pe){if(pe instanceof Error){let Se={};Error.captureStackTrace?Error.captureStackTrace(Se):Se=new Error;const ze=Se.stack?Se.stack.replace(/^.+\n/,""):"";try{pe.stack?ze&&!String(pe.stack).endsWith(ze.replace(/^.+\n.+\n/,""))&&(pe.stack+=`
`+ze):pe.stack=ze}catch{}}throw pe}}_request(re,me){typeof re=="string"?(me=me||{},me.url=re):me=re||{},me=En(this.defaults,me);const{transitional:pe,paramsSerializer:Se,headers:ze}=me;pe!==void 0&&Oa.assertOptions(pe,{silentJSONParsing:Cn.transitional(Cn.boolean),forcedJSONParsing:Cn.transitional(Cn.boolean),clarifyTimeoutError:Cn.transitional(Cn.boolean),legacyInterceptorReqResOrdering:Cn.transitional(Cn.boolean)},!1),Se!=null&&(_e.isFunction(Se)?me.paramsSerializer={serialize:Se}:Oa.assertOptions(Se,{encode:Cn.function,serialize:Cn.function},!0)),me.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?me.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:me.allowAbsoluteUrls=!0),Oa.assertOptions(me,{baseUrl:Cn.spelling("baseURL"),withXsrfToken:Cn.spelling("withXSRFToken")},!0),me.method=(me.method||this.defaults.method||"get").toLowerCase();let Ue=ze&&_e.merge(ze.common,ze[me.method]);ze&&_e.forEach(["delete","get","head","post","put","patch","common"],Bt=>{delete ze[Bt]}),me.headers=fs.concat(Ue,ze);const ot=[];let ls=!0;this.interceptors.request.forEach(function(Ss){if(typeof Ss.runWhen=="function"&&Ss.runWhen(me)===!1)return;ls=ls&&Ss.synchronous;const is=me.transitional||Ge;is&&is.legacyInterceptorReqResOrdering?ot.unshift(Ss.fulfilled,Ss.rejected):ot.push(Ss.fulfilled,Ss.rejected)});const Gt=[];this.interceptors.response.forEach(function(Ss){Gt.push(Ss.fulfilled,Ss.rejected)});let Lt,ws=0,gn;if(!ls){const Bt=[Hr.bind(this),void 0];for(Bt.unshift(...ot),Bt.push(...Gt),gn=Bt.length,Lt=Promise.resolve(me);ws<gn;)Lt=Lt.then(Bt[ws++],Bt[ws++]);return Lt}gn=ot.length;let nr=me;for(;ws<gn;){const Bt=ot[ws++],Ss=ot[ws++];try{nr=Bt(nr)}catch(is){Ss.call(this,is);break}}try{Lt=Hr.call(this,nr)}catch(Bt){return Promise.reject(Bt)}for(ws=0,gn=Gt.length;ws<gn;)Lt=Lt.then(Gt[ws++],Gt[ws++]);return Lt}getUri(re){re=En(this.defaults,re);const me=xn(re.baseURL,re.url,re.allowAbsoluteUrls);return ke(me,re.params,re.paramsSerializer)}}_e.forEach(["delete","get","head","options"],function(re){ba.prototype[re]=function(me,pe){return this.request(En(pe||{},{method:re,url:me,data:(pe||{}).data}))}}),_e.forEach(["post","put","patch"],function(re){function me(pe){return function(ze,Ue,ot){return this.request(En(ot||{},{method:re,headers:pe?{"Content-Type":"multipart/form-data"}:{},url:ze,data:Ue}))}}ba.prototype[re]=me(),ba.prototype[re+"Form"]=me(!0)});var Wi=ba;class Wr{constructor(re){if(typeof re!="function")throw new TypeError("executor must be a function.");let me;this.promise=new Promise(function(ze){me=ze});const pe=this;this.promise.then(Se=>{if(!pe._listeners)return;let ze=pe._listeners.length;for(;ze-- >0;)pe._listeners[ze](Se);pe._listeners=null}),this.promise.then=Se=>{let ze;const Ue=new Promise(ot=>{pe.subscribe(ot),ze=ot}).then(Se);return Ue.cancel=function(){pe.unsubscribe(ze)},Ue},re(function(ze,Ue,ot){pe.reason||(pe.reason=new cs(ze,Ue,ot),me(pe.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(re){if(this.reason){re(this.reason);return}this._listeners?this._listeners.push(re):this._listeners=[re]}unsubscribe(re){if(!this._listeners)return;const me=this._listeners.indexOf(re);me!==-1&&this._listeners.splice(me,1)}toAbortSignal(){const re=new AbortController,me=pe=>{re.abort(pe)};return this.subscribe(me),re.signal.unsubscribe=()=>this.unsubscribe(me),re.signal}static source(){let re;return{token:new Wr(function(Se){re=Se}),cancel:re}}}var jo=Wr;function Gi(ne){return function(me){return ne.apply(null,me)}}function No(ne){return _e.isObject(ne)&&ne.isAxiosError===!0}const Ci={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ci).forEach(([ne,re])=>{Ci[re]=ne});var wl=Ci;function Sl(ne){const re=new Wi(ne),me=t(Wi.prototype.request,re);return _e.extend(me,Wi.prototype,re,{allOwnKeys:!0}),_e.extend(me,re,null,{allOwnKeys:!0}),me.create=function(Se){return Sl(En(ne,Se))},me}const cn=Sl(rn);return cn.Axios=Wi,cn.CanceledError=cs,cn.CancelToken=jo,cn.isCancel=As,cn.VERSION=sr,cn.toFormData=$s,cn.AxiosError=Pt,cn.Cancel=cn.CanceledError,cn.all=function(re){return Promise.all(re)},cn.spread=Gi,cn.isAxiosError=No,cn.mergeConfig=En,cn.AxiosHeaders=fs,cn.formToJSON=ne=>ts(_e.isHTMLForm(ne)?new FormData(ne):ne),cn.getAdapter=Si.getAdapter,cn.HttpStatusCode=wl,cn.default=cn,cg=cn,cg}var zw;function zP(){if(zw)return wr;zw=1;function t($){return $&&typeof $=="object"&&"default"in $?$.default:$}Object.defineProperty(wr,"__esModule",{value:!0});var s=t(qP()),n=function(){return(n=Object.assign||function($){for(var Y,Z=1,W=arguments.length;Z<W;Z++)for(var U in Y=arguments[Z])Object.prototype.hasOwnProperty.call(Y,U)&&($[U]=Y[U]);return $}).apply(this,arguments)},r=function($,Y,Z,W){return new(Z||(Z=Promise))(function(U,M){function z(B){try{I(W.next(B))}catch(G){M(G)}}function T(B){try{I(W.throw(B))}catch(G){M(G)}}function I(B){var G;B.done?U(B.value):(G=B.value,G instanceof Z?G:new Z(function(K){K(G)})).then(z,T)}I((W=W.apply($,[])).next())})},a=function($,Y){var Z,W,U,M,z={label:0,sent:function(){if(1&U[0])throw U[1];return U[1]},trys:[],ops:[]};return M={next:T(0),throw:T(1),return:T(2)},typeof Symbol=="function"&&(M[Symbol.iterator]=function(){return this}),M;function T(I){return function(B){return(function(G){if(Z)throw new TypeError("Generator is already executing.");for(;M&&(M=0,G[0]&&(z=0)),z;)try{if(Z=1,W&&(U=2&G[0]?W.return:G[0]?W.throw||((U=W.return)&&U.call(W),0):W.next)&&!(U=U.call(W,G[1])).done)return U;switch(W=0,U&&(G=[2&G[0],U.value]),G[0]){case 0:case 1:U=G;break;case 4:return z.label++,{value:G[1],done:!1};case 5:z.label++,W=G[1],G=[0];continue;case 7:G=z.ops.pop(),z.trys.pop();continue;default:if(!(U=(U=z.trys).length>0&&U[U.length-1])&&(G[0]===6||G[0]===2)){z=0;continue}if(G[0]===3&&(!U||G[1]>U[0]&&G[1]<U[3])){z.label=G[1];break}if(G[0]===6&&z.label<U[1]){z.label=U[1],U=G;break}if(U&&z.label<U[2]){z.label=U[2],z.ops.push(G);break}U[2]&&z.ops.pop(),z.trys.pop();continue}G=Y.call($,z)}catch(K){G=[6,K],W=0}finally{Z=U=0}if(5&G[0])throw G[1];return{value:G[0]?G[1]:void 0,done:!0}})([I,B])}}},i=function($){return $ instanceof Date?$.getTime():typeof $=="number"||$===null||$===void 0?$:Number($)},o=function($,Y,Z){return Z>=$&&Z<=Y},d=function($){return!!$&&(typeof $=="object"||typeof $=="function")&&typeof $.then=="function"},m={Accept:"application/json","Content-Type":"application/json"},f={timeout:0},p=null,h="CLIENT_ERROR",x="SERVER_ERROR",u="TIMEOUT_ERROR",N="CONNECTION_ERROR",v="NETWORK_ERROR",w="UNKNOWN_ERROR",j="CANCEL_ERROR",b=["ECONNABORTED"],C=["ENOTFOUND","ECONNREFUSED","ECONNRESET"],S=["ERR_BAD_REQUEST","ERR_BAD_RESPONSE"],R=function($){return o(200,299,$)},_=function($){return o(400,499,$)},A=function($){return o(500,599,$)},E=function($){return $.message==="Network Error"?v:s.isCancel($)?j:$.code?S.includes($.code)?q($.response.status):b.includes($.code)?u:C.includes($.code)?N:w:q($.response?$.response.status:null)},q=function($){return $?R($)?p:_($)?h:A($)?x:w:w},O=function($){var Y,Z=n(n({},m),$.headers||{});if($.axiosInstance)Y=$.axiosInstance;else{var W=n(n({},$),{headers:void 0}),U=n(n({},f),W);Y=s.create(U)}var M=[],z=[],T=[],I=[],B=[],G=function(le,xe){return Z[le]=xe,Y},K=function(le){return function(xe,ce,ve){return ce===void 0&&(ce={}),ve===void 0&&(ve={}),X(n(n({},ve),{url:xe,params:ce,method:le}))}},H=function(le){return function(xe,ce,ve){return ve===void 0&&(ve={}),X(n(n({},ve),{url:xe,method:le,data:ce}))}},X=function(le){return r(void 0,void 0,void 0,function(){var xe,ce,ve,Pe;return a(this,function(et){switch(et.label){case 0:if(le.headers=n(n({},Z),le.headers),z.length>0&&z.forEach(function(kt){return kt(le)}),!(T.length>0))return[3,6];xe=0,et.label=1;case 1:return xe<T.length?(ce=T[xe](le),d(ce)?[4,ce]:[3,3]):[3,6];case 2:return et.sent(),[3,5];case 3:return[4,ce(le)];case 4:et.sent(),et.label=5;case 5:return xe++,[3,1];case 6:return ve=i(new Date),Pe=function(kt){return r(void 0,void 0,void 0,function(){var vt;return a(this,function(ee){switch(ee.label){case 0:return[4,ae(ve,kt)];case 1:return vt=ee.sent(),[2,J(vt)]}})})},[2,Y.request(le).then(Pe).catch(Pe)]}})})},J=function(le){return M.forEach(function(xe){try{xe(le)}catch{}}),le},ae=function(le,xe){return r(void 0,void 0,void 0,function(){var ce,ve,Pe,et,kt,vt,ee,ge,ye,Be,$e,dt,st,xt,Mt,It,he;return a(this,function(pt){switch(pt.label){case 0:if(ce=i(new Date),ve=ce-le,Pe=xe instanceof Error||s.isCancel(xe),et=xe,kt=xe,vt=Pe?kt.response:et,ee=vt&&vt.status||null,ge=Pe?E(xe):q(ee),ye=Pe?kt:null,Be=R(ee),$e=xe.config||null,dt=vt&&vt.headers||null,st=(he=vt&&vt.data)!==null&&he!==void 0?he:null,xt={duration:ve,problem:ge,originalError:ye,ok:Be,status:ee,headers:dt,config:$e,data:st},I.length>0&&I.forEach(function(ht){return ht(xt)}),!(B.length>0))return[3,6];Mt=0,pt.label=1;case 1:return Mt<B.length?(It=B[Mt](xt),d(It)?[4,It]:[3,3]):[3,6];case 2:return pt.sent(),[3,5];case 3:return[4,It(xt)];case 4:pt.sent(),pt.label=5;case 5:return Mt++,[3,1];case 6:return[2,xt]}})})};return{axiosInstance:Y,monitors:M,addMonitor:function(le){M.push(le)},requestTransforms:z,asyncRequestTransforms:T,responseTransforms:I,asyncResponseTransforms:B,addRequestTransform:function(le){return z.push(le)},addAsyncRequestTransform:function(le){return T.push(le)},addResponseTransform:function(le){return I.push(le)},addAsyncResponseTransform:function(le){return B.push(le)},setHeader:G,setHeaders:function(le){return Object.keys(le).forEach(function(xe){return G(xe,le[xe])}),Y},deleteHeader:function(le){return delete Z[le],Y},headers:Z,setBaseURL:function(le){return Y.defaults.baseURL=le,Y},getBaseURL:function(){return Y.defaults.baseURL},any:X,get:K("get"),delete:K("delete"),head:K("head"),post:H("post"),put:H("put"),patch:H("patch"),link:K("link"),unlink:K("unlink")}},D=s.isCancel,P=s.CancelToken,L={DEFAULT_HEADERS:m,NONE:p,CLIENT_ERROR:h,SERVER_ERROR:x,TIMEOUT_ERROR:u,CONNECTION_ERROR:N,NETWORK_ERROR:v,UNKNOWN_ERROR:w,create:O,isCancel:D,CancelToken:P};return wr.DEFAULT_HEADERS=m,wr.NONE=p,wr.CLIENT_ERROR=h,wr.SERVER_ERROR=x,wr.TIMEOUT_ERROR=u,wr.CONNECTION_ERROR=N,wr.NETWORK_ERROR=v,wr.UNKNOWN_ERROR=w,wr.CANCEL_ERROR=j,wr.getProblemFromError=E,wr.getProblemFromStatus=q,wr.create=O,wr.isCancel=D,wr.CancelToken=P,wr.default=L,wr}var UP=zP();const VP="https://dealeronboarding-uat.royalenfield.com/api",qe=UP.create({baseURL:VP,headers:{"Content-Type":"application/json",Accept:"application/json"},timeout:3e4});qe.addRequestTransform(t=>{const s=localStorage.getItem("token");s&&t.headers&&(t.headers.Authorization=`Bearer ${s}`)});qe.addResponseTransform(t=>{var s,n;if(!t.ok&&t.status===401){const r=localStorage.getItem("token");console.error("Unauthorized access - potential token expiration. Token exists in localStorage:",!!r),console.error("Full 401 Response Details:",{url:(s=t.config)==null?void 0:s.url,method:(n=t.config)==null?void 0:n.method,data:t.data}),window.dispatchEvent(new Event("auth:logout"))}});function tA(t,s){return function(){return t.apply(s,arguments)}}const{toString:HP}=Object.prototype,{getPrototypeOf:$y}=Object,{iterator:Tf,toStringTag:sA}=Symbol,Pf=(t=>s=>{const n=HP.call(s);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),yi=t=>(t=t.toLowerCase(),s=>Pf(s)===t),Of=t=>s=>typeof s===t,{isArray:xd}=Array,nd=Of("undefined");function Mu(t){return t!==null&&!nd(t)&&t.constructor!==null&&!nd(t.constructor)&&ma(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const nA=yi("ArrayBuffer");function WP(t){let s;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?s=ArrayBuffer.isView(t):s=t&&t.buffer&&nA(t.buffer),s}const GP=Of("string"),ma=Of("function"),rA=Of("number"),Fu=t=>t!==null&&typeof t=="object",KP=t=>t===!0||t===!1,Om=t=>{if(Pf(t)!=="object")return!1;const s=$y(t);return(s===null||s===Object.prototype||Object.getPrototypeOf(s)===null)&&!(sA in t)&&!(Tf in t)},YP=t=>{if(!Fu(t)||Mu(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},ZP=yi("Date"),QP=yi("File"),XP=t=>!!(t&&typeof t.uri<"u"),JP=t=>t&&typeof t.getParts<"u",eO=yi("Blob"),tO=yi("FileList"),sO=t=>Fu(t)&&ma(t.pipe);function nO(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Uw=nO(),Vw=typeof Uw.FormData<"u"?Uw.FormData:void 0,rO=t=>{let s;return t&&(Vw&&t instanceof Vw||ma(t.append)&&((s=Pf(t))==="formdata"||s==="object"&&ma(t.toString)&&t.toString()==="[object FormData]"))},aO=yi("URLSearchParams"),[iO,lO,oO,cO]=["ReadableStream","Request","Response","Headers"].map(yi),dO=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Bu(t,s,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let r,a;if(typeof t!="object"&&(t=[t]),xd(t))for(r=0,a=t.length;r<a;r++)s.call(null,t[r],r,t);else{if(Mu(t))return;const i=n?Object.getOwnPropertyNames(t):Object.keys(t),o=i.length;let d;for(r=0;r<o;r++)d=i[r],s.call(null,t[d],d,t)}}function aA(t,s){if(Mu(t))return null;s=s.toLowerCase();const n=Object.keys(t);let r=n.length,a;for(;r-- >0;)if(a=n[r],s===a.toLowerCase())return a;return null}const Go=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,iA=t=>!nd(t)&&t!==Go;function Gv(){const{caseless:t,skipUndefined:s}=iA(this)&&this||{},n={},r=(a,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;const o=t&&aA(n,i)||i;Om(n[o])&&Om(a)?n[o]=Gv(n[o],a):Om(a)?n[o]=Gv({},a):xd(a)?n[o]=a.slice():(!s||!nd(a))&&(n[o]=a)};for(let a=0,i=arguments.length;a<i;a++)arguments[a]&&Bu(arguments[a],r);return n}const uO=(t,s,n,{allOwnKeys:r}={})=>(Bu(s,(a,i)=>{n&&ma(a)?Object.defineProperty(t,i,{value:tA(a,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,i,{value:a,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),hO=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),mO=(t,s,n,r)=>{t.prototype=Object.create(s.prototype,r),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:s.prototype}),n&&Object.assign(t.prototype,n)},fO=(t,s,n,r)=>{let a,i,o;const d={};if(s=s||{},t==null)return s;do{for(a=Object.getOwnPropertyNames(t),i=a.length;i-- >0;)o=a[i],(!r||r(o,t,s))&&!d[o]&&(s[o]=t[o],d[o]=!0);t=n!==!1&&$y(t)}while(t&&(!n||n(t,s))&&t!==Object.prototype);return s},pO=(t,s,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=s.length;const r=t.indexOf(s,n);return r!==-1&&r===n},xO=t=>{if(!t)return null;if(xd(t))return t;let s=t.length;if(!rA(s))return null;const n=new Array(s);for(;s-- >0;)n[s]=t[s];return n},gO=(t=>s=>t&&s instanceof t)(typeof Uint8Array<"u"&&$y(Uint8Array)),vO=(t,s)=>{const r=(t&&t[Tf]).call(t);let a;for(;(a=r.next())&&!a.done;){const i=a.value;s.call(t,i[0],i[1])}},yO=(t,s)=>{let n;const r=[];for(;(n=t.exec(s))!==null;)r.push(n);return r},bO=yi("HTMLFormElement"),jO=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,a){return r.toUpperCase()+a}),Hw=(({hasOwnProperty:t})=>(s,n)=>t.call(s,n))(Object.prototype),NO=yi("RegExp"),lA=(t,s)=>{const n=Object.getOwnPropertyDescriptors(t),r={};Bu(n,(a,i)=>{let o;(o=s(a,i,t))!==!1&&(r[i]=o||a)}),Object.defineProperties(t,r)},wO=t=>{lA(t,(s,n)=>{if(ma(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=t[n];if(ma(r)){if(s.enumerable=!1,"writable"in s){s.writable=!1;return}s.set||(s.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},SO=(t,s)=>{const n={},r=a=>{a.forEach(i=>{n[i]=!0})};return xd(t)?r(t):r(String(t).split(s)),n},CO=()=>{},AO=(t,s)=>t!=null&&Number.isFinite(t=+t)?t:s;function kO(t){return!!(t&&ma(t.append)&&t[sA]==="FormData"&&t[Tf])}const DO=t=>{const s=new Array(10),n=(r,a)=>{if(Fu(r)){if(s.indexOf(r)>=0)return;if(Mu(r))return r;if(!("toJSON"in r)){s[a]=r;const i=xd(r)?[]:{};return Bu(r,(o,d)=>{const m=n(o,a+1);!nd(m)&&(i[d]=m)}),s[a]=void 0,i}}return r};return n(t,0)},RO=yi("AsyncFunction"),EO=t=>t&&(Fu(t)||ma(t))&&ma(t.then)&&ma(t.catch),oA=((t,s)=>t?setImmediate:s?((n,r)=>(Go.addEventListener("message",({source:a,data:i})=>{a===Go&&i===n&&r.length&&r.shift()()},!1),a=>{r.push(a),Go.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",ma(Go.postMessage)),_O=typeof queueMicrotask<"u"?queueMicrotask.bind(Go):typeof process<"u"&&process.nextTick||oA,TO=t=>t!=null&&ma(t[Tf]),Xe={isArray:xd,isArrayBuffer:nA,isBuffer:Mu,isFormData:rO,isArrayBufferView:WP,isString:GP,isNumber:rA,isBoolean:KP,isObject:Fu,isPlainObject:Om,isEmptyObject:YP,isReadableStream:iO,isRequest:lO,isResponse:oO,isHeaders:cO,isUndefined:nd,isDate:ZP,isFile:QP,isReactNativeBlob:XP,isReactNative:JP,isBlob:eO,isRegExp:NO,isFunction:ma,isStream:sO,isURLSearchParams:aO,isTypedArray:gO,isFileList:tO,forEach:Bu,merge:Gv,extend:uO,trim:dO,stripBOM:hO,inherits:mO,toFlatObject:fO,kindOf:Pf,kindOfTest:yi,endsWith:pO,toArray:xO,forEachEntry:vO,matchAll:yO,isHTMLForm:bO,hasOwnProperty:Hw,hasOwnProp:Hw,reduceDescriptors:lA,freezeMethods:wO,toObjectSet:SO,toCamelCase:jO,noop:CO,toFiniteNumber:AO,findKey:aA,global:Go,isContextDefined:iA,isSpecCompliantForm:kO,toJSONObject:DO,isAsyncFn:RO,isThenable:EO,setImmediate:oA,asap:_O,isIterable:TO};let Fs=class cA extends Error{static from(s,n,r,a,i,o){const d=new cA(s.message,n||s.code,r,a,i);return d.cause=s,d.name=s.name,s.status!=null&&d.status==null&&(d.status=s.status),o&&Object.assign(d,o),d}constructor(s,n,r,a,i){super(s),Object.defineProperty(this,"message",{value:s,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),a&&(this.request=a),i&&(this.response=i,this.status=i.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Xe.toJSONObject(this.config),code:this.code,status:this.status}}};Fs.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";Fs.ERR_BAD_OPTION="ERR_BAD_OPTION";Fs.ECONNABORTED="ECONNABORTED";Fs.ETIMEDOUT="ETIMEDOUT";Fs.ERR_NETWORK="ERR_NETWORK";Fs.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";Fs.ERR_DEPRECATED="ERR_DEPRECATED";Fs.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";Fs.ERR_BAD_REQUEST="ERR_BAD_REQUEST";Fs.ERR_CANCELED="ERR_CANCELED";Fs.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";Fs.ERR_INVALID_URL="ERR_INVALID_URL";const PO=null;function Kv(t){return Xe.isPlainObject(t)||Xe.isArray(t)}function dA(t){return Xe.endsWith(t,"[]")?t.slice(0,-2):t}function dg(t,s,n){return t?t.concat(s).map(function(a,i){return a=dA(a),!n&&i?"["+a+"]":a}).join(n?".":""):s}function OO(t){return Xe.isArray(t)&&!t.some(Kv)}const LO=Xe.toFlatObject(Xe,{},null,function(s){return/^is[A-Z]/.test(s)});function Lf(t,s,n){if(!Xe.isObject(t))throw new TypeError("target must be an object");s=s||new FormData,n=Xe.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,w){return!Xe.isUndefined(w[v])});const r=n.metaTokens,a=n.visitor||p,i=n.dots,o=n.indexes,m=(n.Blob||typeof Blob<"u"&&Blob)&&Xe.isSpecCompliantForm(s);if(!Xe.isFunction(a))throw new TypeError("visitor must be a function");function f(N){if(N===null)return"";if(Xe.isDate(N))return N.toISOString();if(Xe.isBoolean(N))return N.toString();if(!m&&Xe.isBlob(N))throw new Fs("Blob is not supported. Use a Buffer instead.");return Xe.isArrayBuffer(N)||Xe.isTypedArray(N)?m&&typeof Blob=="function"?new Blob([N]):Buffer.from(N):N}function p(N,v,w){let j=N;if(Xe.isReactNative(s)&&Xe.isReactNativeBlob(N))return s.append(dg(w,v,i),f(N)),!1;if(N&&!w&&typeof N=="object"){if(Xe.endsWith(v,"{}"))v=r?v:v.slice(0,-2),N=JSON.stringify(N);else if(Xe.isArray(N)&&OO(N)||(Xe.isFileList(N)||Xe.endsWith(v,"[]"))&&(j=Xe.toArray(N)))return v=dA(v),j.forEach(function(C,S){!(Xe.isUndefined(C)||C===null)&&s.append(o===!0?dg([v],S,i):o===null?v:v+"[]",f(C))}),!1}return Kv(N)?!0:(s.append(dg(w,v,i),f(N)),!1)}const h=[],x=Object.assign(LO,{defaultVisitor:p,convertValue:f,isVisitable:Kv});function u(N,v){if(!Xe.isUndefined(N)){if(h.indexOf(N)!==-1)throw Error("Circular reference detected in "+v.join("."));h.push(N),Xe.forEach(N,function(j,b){(!(Xe.isUndefined(j)||j===null)&&a.call(s,j,Xe.isString(b)?b.trim():b,v,x))===!0&&u(j,v?v.concat(b):[b])}),h.pop()}}if(!Xe.isObject(t))throw new TypeError("data must be an object");return u(t),s}function Ww(t){const s={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return s[r]})}function qy(t,s){this._pairs=[],t&&Lf(t,this,s)}const uA=qy.prototype;uA.append=function(s,n){this._pairs.push([s,n])};uA.toString=function(s){const n=s?function(r){return s.call(this,r,Ww)}:Ww;return this._pairs.map(function(a){return n(a[0])+"="+n(a[1])},"").join("&")};function IO(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function hA(t,s,n){if(!s)return t;const r=n&&n.encode||IO,a=Xe.isFunction(n)?{serialize:n}:n,i=a&&a.serialize;let o;if(i?o=i(s,a):o=Xe.isURLSearchParams(s)?s.toString():new qy(s,a).toString(r),o){const d=t.indexOf("#");d!==-1&&(t=t.slice(0,d)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}class Gw{constructor(){this.handlers=[]}use(s,n,r){return this.handlers.push({fulfilled:s,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(s){this.handlers[s]&&(this.handlers[s]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(s){Xe.forEach(this.handlers,function(r){r!==null&&s(r)})}}const zy={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},MO=typeof URLSearchParams<"u"?URLSearchParams:qy,FO=typeof FormData<"u"?FormData:null,BO=typeof Blob<"u"?Blob:null,$O={isBrowser:!0,classes:{URLSearchParams:MO,FormData:FO,Blob:BO},protocols:["http","https","file","blob","url","data"]},Uy=typeof window<"u"&&typeof document<"u",Yv=typeof navigator=="object"&&navigator||void 0,qO=Uy&&(!Yv||["ReactNative","NativeScript","NS"].indexOf(Yv.product)<0),zO=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",UO=Uy&&window.location.href||"http://localhost",VO=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Uy,hasStandardBrowserEnv:qO,hasStandardBrowserWebWorkerEnv:zO,navigator:Yv,origin:UO},Symbol.toStringTag,{value:"Module"})),zr={...VO,...$O};function HO(t,s){return Lf(t,new zr.classes.URLSearchParams,{visitor:function(n,r,a,i){return zr.isNode&&Xe.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...s})}function WO(t){return Xe.matchAll(/\w+|\[(\w*)]/g,t).map(s=>s[0]==="[]"?"":s[1]||s[0])}function GO(t){const s={},n=Object.keys(t);let r;const a=n.length;let i;for(r=0;r<a;r++)i=n[r],s[i]=t[i];return s}function mA(t){function s(n,r,a,i){let o=n[i++];if(o==="__proto__")return!0;const d=Number.isFinite(+o),m=i>=n.length;return o=!o&&Xe.isArray(a)?a.length:o,m?(Xe.hasOwnProp(a,o)?a[o]=[a[o],r]:a[o]=r,!d):((!a[o]||!Xe.isObject(a[o]))&&(a[o]=[]),s(n,r,a[o],i)&&Xe.isArray(a[o])&&(a[o]=GO(a[o])),!d)}if(Xe.isFormData(t)&&Xe.isFunction(t.entries)){const n={};return Xe.forEachEntry(t,(r,a)=>{s(WO(r),a,n,0)}),n}return null}function KO(t,s,n){if(Xe.isString(t))try{return(s||JSON.parse)(t),Xe.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}const $u={transitional:zy,adapter:["xhr","http","fetch"],transformRequest:[function(s,n){const r=n.getContentType()||"",a=r.indexOf("application/json")>-1,i=Xe.isObject(s);if(i&&Xe.isHTMLForm(s)&&(s=new FormData(s)),Xe.isFormData(s))return a?JSON.stringify(mA(s)):s;if(Xe.isArrayBuffer(s)||Xe.isBuffer(s)||Xe.isStream(s)||Xe.isFile(s)||Xe.isBlob(s)||Xe.isReadableStream(s))return s;if(Xe.isArrayBufferView(s))return s.buffer;if(Xe.isURLSearchParams(s))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),s.toString();let d;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return HO(s,this.formSerializer).toString();if((d=Xe.isFileList(s))||r.indexOf("multipart/form-data")>-1){const m=this.env&&this.env.FormData;return Lf(d?{"files[]":s}:s,m&&new m,this.formSerializer)}}return i||a?(n.setContentType("application/json",!1),KO(s)):s}],transformResponse:[function(s){const n=this.transitional||$u.transitional,r=n&&n.forcedJSONParsing,a=this.responseType==="json";if(Xe.isResponse(s)||Xe.isReadableStream(s))return s;if(s&&Xe.isString(s)&&(r&&!this.responseType||a)){const o=!(n&&n.silentJSONParsing)&&a;try{return JSON.parse(s,this.parseReviver)}catch(d){if(o)throw d.name==="SyntaxError"?Fs.from(d,Fs.ERR_BAD_RESPONSE,this,null,this.response):d}}return s}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:zr.classes.FormData,Blob:zr.classes.Blob},validateStatus:function(s){return s>=200&&s<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Xe.forEach(["delete","get","head","post","put","patch"],t=>{$u.headers[t]={}});const YO=Xe.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ZO=t=>{const s={};let n,r,a;return t&&t.split(`
`).forEach(function(o){a=o.indexOf(":"),n=o.substring(0,a).trim().toLowerCase(),r=o.substring(a+1).trim(),!(!n||s[n]&&YO[n])&&(n==="set-cookie"?s[n]?s[n].push(r):s[n]=[r]:s[n]=s[n]?s[n]+", "+r:r)}),s},Kw=Symbol("internals");function Jd(t){return t&&String(t).trim().toLowerCase()}function Lm(t){return t===!1||t==null?t:Xe.isArray(t)?t.map(Lm):String(t)}function QO(t){const s=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(t);)s[r[1]]=r[2];return s}const XO=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function ug(t,s,n,r,a){if(Xe.isFunction(r))return r.call(this,s,n);if(a&&(s=n),!!Xe.isString(s)){if(Xe.isString(r))return s.indexOf(r)!==-1;if(Xe.isRegExp(r))return r.test(s)}}function JO(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(s,n,r)=>n.toUpperCase()+r)}function e5(t,s){const n=Xe.toCamelCase(" "+s);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{value:function(a,i,o){return this[r].call(this,s,a,i,o)},configurable:!0})})}let fa=class{constructor(s){s&&this.set(s)}set(s,n,r){const a=this;function i(d,m,f){const p=Jd(m);if(!p)throw new Error("header name must be a non-empty string");const h=Xe.findKey(a,p);(!h||a[h]===void 0||f===!0||f===void 0&&a[h]!==!1)&&(a[h||m]=Lm(d))}const o=(d,m)=>Xe.forEach(d,(f,p)=>i(f,p,m));if(Xe.isPlainObject(s)||s instanceof this.constructor)o(s,n);else if(Xe.isString(s)&&(s=s.trim())&&!XO(s))o(ZO(s),n);else if(Xe.isObject(s)&&Xe.isIterable(s)){let d={},m,f;for(const p of s){if(!Xe.isArray(p))throw TypeError("Object iterator must return a key-value pair");d[f=p[0]]=(m=d[f])?Xe.isArray(m)?[...m,p[1]]:[m,p[1]]:p[1]}o(d,n)}else s!=null&&i(n,s,r);return this}get(s,n){if(s=Jd(s),s){const r=Xe.findKey(this,s);if(r){const a=this[r];if(!n)return a;if(n===!0)return QO(a);if(Xe.isFunction(n))return n.call(this,a,r);if(Xe.isRegExp(n))return n.exec(a);throw new TypeError("parser must be boolean|regexp|function")}}}has(s,n){if(s=Jd(s),s){const r=Xe.findKey(this,s);return!!(r&&this[r]!==void 0&&(!n||ug(this,this[r],r,n)))}return!1}delete(s,n){const r=this;let a=!1;function i(o){if(o=Jd(o),o){const d=Xe.findKey(r,o);d&&(!n||ug(r,r[d],d,n))&&(delete r[d],a=!0)}}return Xe.isArray(s)?s.forEach(i):i(s),a}clear(s){const n=Object.keys(this);let r=n.length,a=!1;for(;r--;){const i=n[r];(!s||ug(this,this[i],i,s,!0))&&(delete this[i],a=!0)}return a}normalize(s){const n=this,r={};return Xe.forEach(this,(a,i)=>{const o=Xe.findKey(r,i);if(o){n[o]=Lm(a),delete n[i];return}const d=s?JO(i):String(i).trim();d!==i&&delete n[i],n[d]=Lm(a),r[d]=!0}),this}concat(...s){return this.constructor.concat(this,...s)}toJSON(s){const n=Object.create(null);return Xe.forEach(this,(r,a)=>{r!=null&&r!==!1&&(n[a]=s&&Xe.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([s,n])=>s+": "+n).join(`
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(s){return s instanceof this?s:new this(s)}static concat(s,...n){const r=new this(s);return n.forEach(a=>r.set(a)),r}static accessor(s){const r=(this[Kw]=this[Kw]={accessors:{}}).accessors,a=this.prototype;function i(o){const d=Jd(o);r[d]||(e5(a,o),r[d]=!0)}return Xe.isArray(s)?s.forEach(i):i(s),this}};fa.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Xe.reduceDescriptors(fa.prototype,({value:t},s)=>{let n=s[0].toUpperCase()+s.slice(1);return{get:()=>t,set(r){this[n]=r}}});Xe.freezeMethods(fa);function hg(t,s){const n=this||$u,r=s||n,a=fa.from(r.headers);let i=r.data;return Xe.forEach(t,function(d){i=d.call(n,i,a.normalize(),s?s.status:void 0)}),a.normalize(),i}function fA(t){return!!(t&&t.__CANCEL__)}let qu=class extends Fs{constructor(s,n,r){super(s??"canceled",Fs.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}};function pA(t,s,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):s(new Fs("Request failed with status code "+n.status,[Fs.ERR_BAD_REQUEST,Fs.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function t5(t){const s=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return s&&s[1]||""}function s5(t,s){t=t||10;const n=new Array(t),r=new Array(t);let a=0,i=0,o;return s=s!==void 0?s:1e3,function(m){const f=Date.now(),p=r[i];o||(o=f),n[a]=m,r[a]=f;let h=i,x=0;for(;h!==a;)x+=n[h++],h=h%t;if(a=(a+1)%t,a===i&&(i=(i+1)%t),f-o<s)return;const u=p&&f-p;return u?Math.round(x*1e3/u):void 0}}function n5(t,s){let n=0,r=1e3/s,a,i;const o=(f,p=Date.now())=>{n=p,a=null,i&&(clearTimeout(i),i=null),t(...f)};return[(...f)=>{const p=Date.now(),h=p-n;h>=r?o(f,p):(a=f,i||(i=setTimeout(()=>{i=null,o(a)},r-h)))},()=>a&&o(a)]}const nf=(t,s,n=3)=>{let r=0;const a=s5(50,250);return n5(i=>{const o=i.loaded,d=i.lengthComputable?i.total:void 0,m=o-r,f=a(m),p=o<=d;r=o;const h={loaded:o,total:d,progress:d?o/d:void 0,bytes:m,rate:f||void 0,estimated:f&&d&&p?(d-o)/f:void 0,event:i,lengthComputable:d!=null,[s?"download":"upload"]:!0};t(h)},n)},Yw=(t,s)=>{const n=t!=null;return[r=>s[0]({lengthComputable:n,total:t,loaded:r}),s[1]]},Zw=t=>(...s)=>Xe.asap(()=>t(...s)),r5=zr.hasStandardBrowserEnv?((t,s)=>n=>(n=new URL(n,zr.origin),t.protocol===n.protocol&&t.host===n.host&&(s||t.port===n.port)))(new URL(zr.origin),zr.navigator&&/(msie|trident)/i.test(zr.navigator.userAgent)):()=>!0,a5=zr.hasStandardBrowserEnv?{write(t,s,n,r,a,i,o){if(typeof document>"u")return;const d=[`${t}=${encodeURIComponent(s)}`];Xe.isNumber(n)&&d.push(`expires=${new Date(n).toUTCString()}`),Xe.isString(r)&&d.push(`path=${r}`),Xe.isString(a)&&d.push(`domain=${a}`),i===!0&&d.push("secure"),Xe.isString(o)&&d.push(`SameSite=${o}`),document.cookie=d.join("; ")},read(t){if(typeof document>"u")return null;const s=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return s?decodeURIComponent(s[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function i5(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function l5(t,s){return s?t.replace(/\/?\/$/,"")+"/"+s.replace(/^\/+/,""):t}function xA(t,s,n){let r=!i5(s);return t&&(r||n==!1)?l5(t,s):s}const Qw=t=>t instanceof fa?{...t}:t;function nc(t,s){s=s||{};const n={};function r(f,p,h,x){return Xe.isPlainObject(f)&&Xe.isPlainObject(p)?Xe.merge.call({caseless:x},f,p):Xe.isPlainObject(p)?Xe.merge({},p):Xe.isArray(p)?p.slice():p}function a(f,p,h,x){if(Xe.isUndefined(p)){if(!Xe.isUndefined(f))return r(void 0,f,h,x)}else return r(f,p,h,x)}function i(f,p){if(!Xe.isUndefined(p))return r(void 0,p)}function o(f,p){if(Xe.isUndefined(p)){if(!Xe.isUndefined(f))return r(void 0,f)}else return r(void 0,p)}function d(f,p,h){if(h in s)return r(f,p);if(h in t)return r(void 0,f)}const m={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:d,headers:(f,p,h)=>a(Qw(f),Qw(p),h,!0)};return Xe.forEach(Object.keys({...t,...s}),function(p){if(p==="__proto__"||p==="constructor"||p==="prototype")return;const h=Xe.hasOwnProp(m,p)?m[p]:a,x=h(t[p],s[p],p);Xe.isUndefined(x)&&h!==d||(n[p]=x)}),n}const gA=t=>{const s=nc({},t);let{data:n,withXSRFToken:r,xsrfHeaderName:a,xsrfCookieName:i,headers:o,auth:d}=s;if(s.headers=o=fa.from(o),s.url=hA(xA(s.baseURL,s.url,s.allowAbsoluteUrls),t.params,t.paramsSerializer),d&&o.set("Authorization","Basic "+btoa((d.username||"")+":"+(d.password?unescape(encodeURIComponent(d.password)):""))),Xe.isFormData(n)){if(zr.hasStandardBrowserEnv||zr.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(Xe.isFunction(n.getHeaders)){const m=n.getHeaders(),f=["content-type","content-length"];Object.entries(m).forEach(([p,h])=>{f.includes(p.toLowerCase())&&o.set(p,h)})}}if(zr.hasStandardBrowserEnv&&(r&&Xe.isFunction(r)&&(r=r(s)),r||r!==!1&&r5(s.url))){const m=a&&i&&a5.read(i);m&&o.set(a,m)}return s},o5=typeof XMLHttpRequest<"u",c5=o5&&function(t){return new Promise(function(n,r){const a=gA(t);let i=a.data;const o=fa.from(a.headers).normalize();let{responseType:d,onUploadProgress:m,onDownloadProgress:f}=a,p,h,x,u,N;function v(){u&&u(),N&&N(),a.cancelToken&&a.cancelToken.unsubscribe(p),a.signal&&a.signal.removeEventListener("abort",p)}let w=new XMLHttpRequest;w.open(a.method.toUpperCase(),a.url,!0),w.timeout=a.timeout;function j(){if(!w)return;const C=fa.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),R={data:!d||d==="text"||d==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:C,config:t,request:w};pA(function(A){n(A),v()},function(A){r(A),v()},R),w=null}"onloadend"in w?w.onloadend=j:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(j)},w.onabort=function(){w&&(r(new Fs("Request aborted",Fs.ECONNABORTED,t,w)),w=null)},w.onerror=function(S){const R=S&&S.message?S.message:"Network Error",_=new Fs(R,Fs.ERR_NETWORK,t,w);_.event=S||null,r(_),w=null},w.ontimeout=function(){let S=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const R=a.transitional||zy;a.timeoutErrorMessage&&(S=a.timeoutErrorMessage),r(new Fs(S,R.clarifyTimeoutError?Fs.ETIMEDOUT:Fs.ECONNABORTED,t,w)),w=null},i===void 0&&o.setContentType(null),"setRequestHeader"in w&&Xe.forEach(o.toJSON(),function(S,R){w.setRequestHeader(R,S)}),Xe.isUndefined(a.withCredentials)||(w.withCredentials=!!a.withCredentials),d&&d!=="json"&&(w.responseType=a.responseType),f&&([x,N]=nf(f,!0),w.addEventListener("progress",x)),m&&w.upload&&([h,u]=nf(m),w.upload.addEventListener("progress",h),w.upload.addEventListener("loadend",u)),(a.cancelToken||a.signal)&&(p=C=>{w&&(r(!C||C.type?new qu(null,t,w):C),w.abort(),w=null)},a.cancelToken&&a.cancelToken.subscribe(p),a.signal&&(a.signal.aborted?p():a.signal.addEventListener("abort",p)));const b=t5(a.url);if(b&&zr.protocols.indexOf(b)===-1){r(new Fs("Unsupported protocol "+b+":",Fs.ERR_BAD_REQUEST,t));return}w.send(i||null)})},d5=(t,s)=>{const{length:n}=t=t?t.filter(Boolean):[];if(s||n){let r=new AbortController,a;const i=function(f){if(!a){a=!0,d();const p=f instanceof Error?f:this.reason;r.abort(p instanceof Fs?p:new qu(p instanceof Error?p.message:p))}};let o=s&&setTimeout(()=>{o=null,i(new Fs(`timeout of ${s}ms exceeded`,Fs.ETIMEDOUT))},s);const d=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(f=>{f.unsubscribe?f.unsubscribe(i):f.removeEventListener("abort",i)}),t=null)};t.forEach(f=>f.addEventListener("abort",i));const{signal:m}=r;return m.unsubscribe=()=>Xe.asap(d),m}},u5=function*(t,s){let n=t.byteLength;if(n<s){yield t;return}let r=0,a;for(;r<n;)a=r+s,yield t.slice(r,a),r=a},h5=async function*(t,s){for await(const n of m5(t))yield*u5(n,s)},m5=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const s=t.getReader();try{for(;;){const{done:n,value:r}=await s.read();if(n)break;yield r}}finally{await s.cancel()}},Xw=(t,s,n,r)=>{const a=h5(t,s);let i=0,o,d=m=>{o||(o=!0,r&&r(m))};return new ReadableStream({async pull(m){try{const{done:f,value:p}=await a.next();if(f){d(),m.close();return}let h=p.byteLength;if(n){let x=i+=h;n(x)}m.enqueue(new Uint8Array(p))}catch(f){throw d(f),f}},cancel(m){return d(m),a.return()}},{highWaterMark:2})},Jw=64*1024,{isFunction:om}=Xe,f5=(({Request:t,Response:s})=>({Request:t,Response:s}))(Xe.global),{ReadableStream:e1,TextEncoder:t1}=Xe.global,s1=(t,...s)=>{try{return!!t(...s)}catch{return!1}},p5=t=>{t=Xe.merge.call({skipUndefined:!0},f5,t);const{fetch:s,Request:n,Response:r}=t,a=s?om(s):typeof fetch=="function",i=om(n),o=om(r);if(!a)return!1;const d=a&&om(e1),m=a&&(typeof t1=="function"?(N=>v=>N.encode(v))(new t1):async N=>new Uint8Array(await new n(N).arrayBuffer())),f=i&&d&&s1(()=>{let N=!1;const v=new n(zr.origin,{body:new e1,method:"POST",get duplex(){return N=!0,"half"}}).headers.has("Content-Type");return N&&!v}),p=o&&d&&s1(()=>Xe.isReadableStream(new r("").body)),h={stream:p&&(N=>N.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(N=>{!h[N]&&(h[N]=(v,w)=>{let j=v&&v[N];if(j)return j.call(v);throw new Fs(`Response type '${N}' is not supported`,Fs.ERR_NOT_SUPPORT,w)})});const x=async N=>{if(N==null)return 0;if(Xe.isBlob(N))return N.size;if(Xe.isSpecCompliantForm(N))return(await new n(zr.origin,{method:"POST",body:N}).arrayBuffer()).byteLength;if(Xe.isArrayBufferView(N)||Xe.isArrayBuffer(N))return N.byteLength;if(Xe.isURLSearchParams(N)&&(N=N+""),Xe.isString(N))return(await m(N)).byteLength},u=async(N,v)=>{const w=Xe.toFiniteNumber(N.getContentLength());return w??x(v)};return async N=>{let{url:v,method:w,data:j,signal:b,cancelToken:C,timeout:S,onDownloadProgress:R,onUploadProgress:_,responseType:A,headers:E,withCredentials:q="same-origin",fetchOptions:O}=gA(N),D=s||fetch;A=A?(A+"").toLowerCase():"text";let P=d5([b,C&&C.toAbortSignal()],S),L=null;const $=P&&P.unsubscribe&&(()=>{P.unsubscribe()});let Y;try{if(_&&f&&w!=="get"&&w!=="head"&&(Y=await u(E,j))!==0){let T=new n(v,{method:"POST",body:j,duplex:"half"}),I;if(Xe.isFormData(j)&&(I=T.headers.get("content-type"))&&E.setContentType(I),T.body){const[B,G]=Yw(Y,nf(Zw(_)));j=Xw(T.body,Jw,B,G)}}Xe.isString(q)||(q=q?"include":"omit");const Z=i&&"credentials"in n.prototype,W={...O,signal:P,method:w.toUpperCase(),headers:E.normalize().toJSON(),body:j,duplex:"half",credentials:Z?q:void 0};L=i&&new n(v,W);let U=await(i?D(L,O):D(v,W));const M=p&&(A==="stream"||A==="response");if(p&&(R||M&&$)){const T={};["status","statusText","headers"].forEach(K=>{T[K]=U[K]});const I=Xe.toFiniteNumber(U.headers.get("content-length")),[B,G]=R&&Yw(I,nf(Zw(R),!0))||[];U=new r(Xw(U.body,Jw,B,()=>{G&&G(),$&&$()}),T)}A=A||"text";let z=await h[Xe.findKey(h,A)||"text"](U,N);return!M&&$&&$(),await new Promise((T,I)=>{pA(T,I,{data:z,headers:fa.from(U.headers),status:U.status,statusText:U.statusText,config:N,request:L})})}catch(Z){throw $&&$(),Z&&Z.name==="TypeError"&&/Load failed|fetch/i.test(Z.message)?Object.assign(new Fs("Network Error",Fs.ERR_NETWORK,N,L,Z&&Z.response),{cause:Z.cause||Z}):Fs.from(Z,Z&&Z.code,N,L,Z&&Z.response)}}},x5=new Map,vA=t=>{let s=t&&t.env||{};const{fetch:n,Request:r,Response:a}=s,i=[r,a,n];let o=i.length,d=o,m,f,p=x5;for(;d--;)m=i[d],f=p.get(m),f===void 0&&p.set(m,f=d?new Map:p5(s)),p=f;return f};vA();const Vy={http:PO,xhr:c5,fetch:{get:vA}};Xe.forEach(Vy,(t,s)=>{if(t){try{Object.defineProperty(t,"name",{value:s})}catch{}Object.defineProperty(t,"adapterName",{value:s})}});const n1=t=>`- ${t}`,g5=t=>Xe.isFunction(t)||t===null||t===!1;function v5(t,s){t=Xe.isArray(t)?t:[t];const{length:n}=t;let r,a;const i={};for(let o=0;o<n;o++){r=t[o];let d;if(a=r,!g5(r)&&(a=Vy[(d=String(r)).toLowerCase()],a===void 0))throw new Fs(`Unknown adapter '${d}'`);if(a&&(Xe.isFunction(a)||(a=a.get(s))))break;i[d||"#"+o]=a}if(!a){const o=Object.entries(i).map(([m,f])=>`adapter ${m} `+(f===!1?"is not supported by the environment":"is not available in the build"));let d=n?o.length>1?`since :
`+o.map(n1).join(`
`):" "+n1(o[0]):"as no adapter specified";throw new Fs("There is no suitable adapter to dispatch the request "+d,"ERR_NOT_SUPPORT")}return a}const yA={getAdapter:v5,adapters:Vy};function mg(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new qu(null,t)}function r1(t){return mg(t),t.headers=fa.from(t.headers),t.data=hg.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),yA.getAdapter(t.adapter||$u.adapter,t)(t).then(function(r){return mg(t),r.data=hg.call(t,t.transformResponse,r),r.headers=fa.from(r.headers),r},function(r){return fA(r)||(mg(t),r&&r.response&&(r.response.data=hg.call(t,t.transformResponse,r.response),r.response.headers=fa.from(r.response.headers))),Promise.reject(r)})}const bA="1.13.6",If={};["object","boolean","number","function","string","symbol"].forEach((t,s)=>{If[t]=function(r){return typeof r===t||"a"+(s<1?"n ":" ")+t}});const a1={};If.transitional=function(s,n,r){function a(i,o){return"[Axios v"+bA+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,d)=>{if(s===!1)throw new Fs(a(o," has been removed"+(n?" in "+n:"")),Fs.ERR_DEPRECATED);return n&&!a1[o]&&(a1[o]=!0,console.warn(a(o," has been deprecated since v"+n+" and will be removed in the near future"))),s?s(i,o,d):!0}};If.spelling=function(s){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${s}`),!0)};function y5(t,s,n){if(typeof t!="object")throw new Fs("options must be an object",Fs.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let a=r.length;for(;a-- >0;){const i=r[a],o=s[i];if(o){const d=t[i],m=d===void 0||o(d,i,t);if(m!==!0)throw new Fs("option "+i+" must be "+m,Fs.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Fs("Unknown option "+i,Fs.ERR_BAD_OPTION)}}const Im={assertOptions:y5,validators:If},Ua=Im.validators;let Xo=class{constructor(s){this.defaults=s||{},this.interceptors={request:new Gw,response:new Gw}}async request(s,n){try{return await this._request(s,n)}catch(r){if(r instanceof Error){let a={};Error.captureStackTrace?Error.captureStackTrace(a):a=new Error;const i=a.stack?a.stack.replace(/^.+\n/,""):"";try{r.stack?i&&!String(r.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(r.stack+=`
`+i):r.stack=i}catch{}}throw r}}_request(s,n){typeof s=="string"?(n=n||{},n.url=s):n=s||{},n=nc(this.defaults,n);const{transitional:r,paramsSerializer:a,headers:i}=n;r!==void 0&&Im.assertOptions(r,{silentJSONParsing:Ua.transitional(Ua.boolean),forcedJSONParsing:Ua.transitional(Ua.boolean),clarifyTimeoutError:Ua.transitional(Ua.boolean),legacyInterceptorReqResOrdering:Ua.transitional(Ua.boolean)},!1),a!=null&&(Xe.isFunction(a)?n.paramsSerializer={serialize:a}:Im.assertOptions(a,{encode:Ua.function,serialize:Ua.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Im.assertOptions(n,{baseUrl:Ua.spelling("baseURL"),withXsrfToken:Ua.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=i&&Xe.merge(i.common,i[n.method]);i&&Xe.forEach(["delete","get","head","post","put","patch","common"],N=>{delete i[N]}),n.headers=fa.concat(o,i);const d=[];let m=!0;this.interceptors.request.forEach(function(v){if(typeof v.runWhen=="function"&&v.runWhen(n)===!1)return;m=m&&v.synchronous;const w=n.transitional||zy;w&&w.legacyInterceptorReqResOrdering?d.unshift(v.fulfilled,v.rejected):d.push(v.fulfilled,v.rejected)});const f=[];this.interceptors.response.forEach(function(v){f.push(v.fulfilled,v.rejected)});let p,h=0,x;if(!m){const N=[r1.bind(this),void 0];for(N.unshift(...d),N.push(...f),x=N.length,p=Promise.resolve(n);h<x;)p=p.then(N[h++],N[h++]);return p}x=d.length;let u=n;for(;h<x;){const N=d[h++],v=d[h++];try{u=N(u)}catch(w){v.call(this,w);break}}try{p=r1.call(this,u)}catch(N){return Promise.reject(N)}for(h=0,x=f.length;h<x;)p=p.then(f[h++],f[h++]);return p}getUri(s){s=nc(this.defaults,s);const n=xA(s.baseURL,s.url,s.allowAbsoluteUrls);return hA(n,s.params,s.paramsSerializer)}};Xe.forEach(["delete","get","head","options"],function(s){Xo.prototype[s]=function(n,r){return this.request(nc(r||{},{method:s,url:n,data:(r||{}).data}))}});Xe.forEach(["post","put","patch"],function(s){function n(r){return function(i,o,d){return this.request(nc(d||{},{method:s,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}Xo.prototype[s]=n(),Xo.prototype[s+"Form"]=n(!0)});let b5=class jA{constructor(s){if(typeof s!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const r=this;this.promise.then(a=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](a);r._listeners=null}),this.promise.then=a=>{let i;const o=new Promise(d=>{r.subscribe(d),i=d}).then(a);return o.cancel=function(){r.unsubscribe(i)},o},s(function(i,o,d){r.reason||(r.reason=new qu(i,o,d),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(s){if(this.reason){s(this.reason);return}this._listeners?this._listeners.push(s):this._listeners=[s]}unsubscribe(s){if(!this._listeners)return;const n=this._listeners.indexOf(s);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const s=new AbortController,n=r=>{s.abort(r)};return this.subscribe(n),s.signal.unsubscribe=()=>this.unsubscribe(n),s.signal}static source(){let s;return{token:new jA(function(a){s=a}),cancel:s}}};function j5(t){return function(n){return t.apply(null,n)}}function N5(t){return Xe.isObject(t)&&t.isAxiosError===!0}const Zv={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Zv).forEach(([t,s])=>{Zv[s]=t});function NA(t){const s=new Xo(t),n=tA(Xo.prototype.request,s);return Xe.extend(n,Xo.prototype,s,{allOwnKeys:!0}),Xe.extend(n,s,null,{allOwnKeys:!0}),n.create=function(a){return NA(nc(t,a))},n}const Qn=NA($u);Qn.Axios=Xo;Qn.CanceledError=qu;Qn.CancelToken=b5;Qn.isCancel=fA;Qn.VERSION=bA;Qn.toFormData=Lf;Qn.AxiosError=Fs;Qn.Cancel=Qn.CanceledError;Qn.all=function(s){return Promise.all(s)};Qn.spread=j5;Qn.isAxiosError=N5;Qn.mergeConfig=nc;Qn.AxiosHeaders=fa;Qn.formToJSON=t=>mA(Xe.isHTMLForm(t)?new FormData(t):t);Qn.getAdapter=yA.getAdapter;Qn.HttpStatusCode=Zv;Qn.default=Qn;const{Axios:sY,AxiosError:nY,CanceledError:rY,isCancel:aY,CancelToken:iY,VERSION:lY,all:oY,Cancel:cY,isAxiosError:dY,spread:uY,toFormData:hY,AxiosHeaders:mY,HttpStatusCode:fY,formToJSON:pY,getAdapter:xY,mergeConfig:gY}=Qn,i1="https://dealeronboarding-uat.royalenfield.com/api",Ee={login:t=>qe.post("/auth/login",t),logout:()=>qe.post("/auth/logout"),getCurrentUser:()=>qe.get("/auth/me"),getRoles:()=>qe.get("/admin/roles"),createRole:t=>qe.post("/admin/roles",t),getPermissions:()=>qe.get("/admin/permissions"),updateRole:(t,s)=>qe.put(`/admin/roles/${t}`,s),getZones:()=>qe.get("/master/zones"),createZone:t=>qe.post("/master/zones",t),updateZone:(t,s)=>qe.put(`/master/zones/${t}`,s),createRegion:t=>qe.post("/master/regions",t),updateRegion:(t,s)=>qe.put(`/master/regions/${t}`,s),getRegions:()=>qe.get("/master/regions"),getOutlets:()=>qe.get("/outlets"),getOutletByCode:t=>qe.get(`/master/outlets/code/${t}`),getStates:t=>qe.get("/master/states",typeof t=="string"?{zoneId:t}:t),getDistricts:t=>qe.get("/master/districts",typeof t=="string"?{stateId:t}:t),getAreas:t=>qe.get("/master/areas",t),updateArea:(t,s)=>qe.put(`/master/areas/${t}`,s),createArea:t=>qe.post("/master/areas",t),getAreaManagers:()=>qe.get("/master/area-managers"),getASMs:()=>qe.get("/master/asms"),getZonalManagers:()=>qe.get("/master/zonal-managers"),saveZonalManager:t=>qe.post("/master/zonal-managers",t),getDDLeads:()=>qe.get("/master/dd-leads"),saveDDLead:t=>qe.post("/master/dd-leads",t),getManagersByRole:t=>qe.get("/master/managers",t),submitApplication:t=>qe.post("/onboarding/apply",t),exportApplicationResponses:t=>qe.get("/onboarding/applications/export-responses",t),getApplications:t=>qe.get("/onboarding/applications",t),shortlistApplications:t=>qe.post("/onboarding/applications/shortlist",t),sendBulkReminders:t=>qe.post("/onboarding/applications/reminders",t),getApplicationById:t=>qe.get(`/onboarding/applications/${t}`),updateApplication:(t,s)=>qe.put(`/onboarding/applications/${t}`,s),getLatestQuestionnaire:()=>qe.get("/questionnaire/latest"),createQuestionnaireVersion:t=>qe.post("/questionnaire/version",t),submitQuestionnaireResponse:t=>qe.post("/questionnaire/response",t),getAllQuestionnaires:()=>qe.get("/onboarding/questionnaires"),getQuestionnaireById:t=>qe.get(`/onboarding/questionnaires/${t}`),assignArchitectureTeam:(t,s)=>qe.post(`/onboarding/applications/${t}/assign-architecture`,{assignedTo:s}),updateArchitectureStatus:(t,s,n)=>qe.post(`/onboarding/applications/${t}/architecture-status`,{status:s,remarks:n}),generateDealerCodes:t=>qe.post(`/onboarding/applications/${t}/generate-codes`),updateApplicationStatus:(t,s)=>qe.put(`/onboarding/applications/${t}/status`,s),convertToOpportunity:(t,s)=>qe.post(`/onboarding/applications/${t}/convert-to-opportunity`,s),bulkConvertToOpportunity:t=>qe.post("/onboarding/applications/bulk-convert-to-opportunity",t),retriggerEvaluators:t=>qe.post(`/onboarding/applications/${t}/retrigger-evaluators`),getSecurityDeposit:t=>qe.get(`/loa/security-deposit/${t}`),updateSecurityDeposit:t=>qe.post("/loa/security-deposit",t),uploadDocument:(t,s)=>qe.post(`/onboarding/applications/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),getDocuments:t=>qe.get(`/onboarding/applications/${t}/documents`),getDocumentConfigMetadata:()=>qe.get("/onboarding/document-configs/metadata"),getDocumentConfigs:t=>qe.get("/onboarding/document-configs",t),createDocumentConfig:t=>qe.post("/onboarding/document-configs",t),updateDocumentConfig:(t,s)=>qe.put(`/onboarding/document-configs/${t}`,s),deleteDocumentConfig:t=>qe.delete(`/onboarding/document-configs/${t}`),getPublicQuestionnaire:t=>Qn.get(`${i1}/questionnaire/public/${t}`),submitPublicResponse:t=>Qn.post(`${i1}/questionnaire/public/submit`,t),getAiSummary:t=>qe.get(`/assessment/ai-summary/${t}`),scheduleInterview:t=>qe.post("/assessment/interviews",t),updateInterview:(t,s)=>qe.put(`/assessment/interviews/${t}`,s),submitEvaluation:(t,s)=>qe.post(`/assessment/interviews/${t}/evaluation`,s),submitKTMatrix:t=>qe.post("/assessment/kt-matrix",t),submitLevel2Feedback:t=>qe.post("/assessment/level2-feedback",t),getInterviews:t=>qe.get(`/assessment/interviews/${t}`),updateRecommendation:t=>qe.post("/assessment/recommendation",t),updateInterviewDecision:t=>qe.post("/assessment/decision",t),submitStageDecision:t=>qe.post("/assessment/stage-decision",t),getInterviewApprovalStatus:t=>qe.get(`/assessment/interviews/${t}/approval-status`),getApprovalPolicies:()=>qe.get("/assessment/approval-policies"),upsertApprovalPolicy:(t,s)=>qe.put(`/assessment/approval-policies/${t}`,s),getWorknotes:(t,s)=>qe.get("/collaboration/worknotes",{requestId:t,requestType:s}),addWorknote:t=>qe.post("/collaboration/worknotes",t),addParticipant:t=>qe.post("/collaboration/participants",t),removeParticipant:t=>qe.delete(`/collaboration/participants/${t}`),getUsers:t=>qe.get("/admin/users",t),createUser:t=>qe.post("/admin/users",t),updateUser:(t,s)=>qe.put(`/admin/users/${t}`,s),updateUserStatus:(t,s)=>qe.patch(`/admin/users/${t}/status`,s),deleteUser:t=>qe.delete(`/admin/users/${t}`),getDealers:t=>qe.get("/dealer",t),createDealer:t=>qe.post("/dealer",t),getDealerById:t=>qe.get(`/dealer/${t}`),updateDealer:(t,s)=>qe.put(`/dealer/${t}`,s),getDealerDashboard:()=>qe.get("/dealer/dashboard"),getDealerBankDetails:t=>qe.get(`/dealer/${t}/bank-details`),saveBankDetail:(t,s)=>qe.post(`/dealer/${t}/bank-details`,s),deleteBankDetail:t=>qe.delete(`/dealer/bank-details/${t}`),getEmailTemplates:()=>qe.get("/admin/email-templates"),getEmailTemplate:t=>qe.get(`/admin/email-templates/${t}`),createEmailTemplate:t=>qe.post("/admin/email-templates",t),updateEmailTemplate:(t,s)=>qe.put(`/admin/email-templates/${t}`,s),deleteEmailTemplate:t=>qe.delete(`/admin/email-templates/${t}`),previewEmailTemplate:t=>qe.post("/admin/email-templates/preview",t),getAuditLogs:(t,s,n=1,r=50)=>qe.get("/audit/logs",{entityType:t,entityId:s,page:n,limit:r}),getAuditSummary:(t,s)=>qe.get("/audit/summary",{entityType:t,entityId:s}),sendOtp:t=>qe.post("/prospective-login/send-otp",{phone:t}),verifyOtp:(t,s)=>qe.post("/prospective-login/verify-otp",{phone:t,otp:s}),getResignationById:t=>qe.get(`/resignation/${t}`),uploadResignationDocument:(t,s)=>qe.post(`/resignation/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),updateClearance:(t,s)=>qe.put(`/resignation/${t}/clearance`,s,{headers:s instanceof FormData?{"Content-Type":"multipart/form-data"}:{}}),updateResignationStatus:(t,s)=>qe.post(`/resignation/${t}/status`,s),getTerminationById:t=>qe.get(`/termination/${t}`),uploadTerminationDocument:(t,s)=>qe.post(`/termination/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),updateTerminationStatus:(t,s)=>qe.post(`/termination/${t}/status`,s),issueSCN:(t,s)=>qe.post(`/termination/${t}/scn`,s),uploadSCNResponse:(t,s)=>qe.post(`/termination/${t}/scn-response`,s,{headers:{"Content-Type":"multipart/form-data"}}),finalizeTermination:(t,s)=>qe.post(`/termination/${t}/finalize`,s),getResignations:t=>qe.get("/resignation",t),createResignation:t=>qe.post("/resignation",t),approveResignation:(t,s)=>qe.post(`/resignation/${t}/approve`,s),dispatchResignation:(t,s)=>qe.post(`/resignation/${t}/dispatch`,s),rejectResignation:(t,s)=>qe.post(`/resignation/${t}/reject`,s),withdrawResignation:(t,s)=>qe.post(`/resignation/${t}/withdraw`,{reason:s}),getTerminations:t=>qe.get("/termination",t),createTermination:t=>{const s=typeof FormData<"u"&&t instanceof FormData;return qe.post("/termination",t,s?{headers:{"Content-Type":"multipart/form-data"}}:void 0)},updateTermination:(t,s)=>qe.post(`/termination/${t}/status`,s),getOnboardingPayments:()=>qe.get("/settlement/onboarding"),updatePayment:(t,s)=>qe.put(`/settlement/payments/${t}`,s),getFnFSettlements:()=>qe.get("/settlement/fnf"),getFnFSettlementById:t=>qe.get(`/settlement/fnf/${t}`),calculateFnF:t=>qe.post(`/settlement/fnf/${t}/calculate`),updateFnF:(t,s)=>qe.put(`/settlement/fnf/${t}`,s),uploadFnFDocument:(t,s)=>qe.post(`/settlement/fnf/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),getSettlementDepartments:()=>qe.get("/settlement/departments"),addLineItem:(t,s)=>qe.post(`/settlement/fnf/${t}/line-items`,s),updateFnFClearance:(t,s,n)=>qe.put(`/settlement/fnf/${t}/clearances/${s}`,n,{headers:{"Content-Type":"multipart/form-data"}}),updateLineItem:(t,s)=>qe.put(`/settlement/fnf/line-items/${t}`,s),deleteLineItem:t=>qe.delete(`/settlement/fnf/line-items/${t}`),getRelocationRequests:t=>qe.get("/relocation",t),getRelocationRequestById:t=>qe.get(`/relocation/${t}`),createRelocationRequest:t=>qe.post("/relocation",t),updateRelocationRequest:(t,s,n)=>qe.post(`/relocation/${t}/action`,{action:s,...n}),uploadRelocationDocument:(t,s)=>qe.post(`/relocation/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),verifyRelocationDocument:(t,s)=>qe.post(`/relocation/${t}/documents/${s}/verify`),rejectRelocationDocument:(t,s,n)=>qe.post(`/relocation/${t}/documents/${s}/reject`,n||{}),getConstitutionalChanges:t=>qe.get("/constitutional-change",t),getConstitutionalChangeMeta:()=>qe.get("/constitutional-change/meta"),getConstitutionalChangeById:t=>qe.get(`/constitutional-change/${t}`),createConstitutionalChange:t=>qe.post("/constitutional-change",t),updateConstitutionalChange:(t,s,n)=>qe.post(`/constitutional-change/${t}/action`,{action:s,...n}),uploadConstitutionalDocuments:(t,s)=>qe.post(`/constitutional-change/${t}/documents`,{documents:s}),verifyConstitutionalDocument:(t,s)=>qe.post(`/constitutional-change/${t}/documents/${s}/verify`),rejectConstitutionalDocument:(t,s,n)=>qe.post(`/constitutional-change/${t}/documents/${s}/reject`,n||{}),getSlaConfigs:()=>qe.get("/master/sla-configs"),saveSlaConfig:t=>qe.post("/master/sla-configs",t),initializeDefaultSlas:()=>qe.post("/master/sla-configs/initialize"),getSlaOperationsDashboard:t=>qe.get("/sla/operations/dashboard",t),postSlaBatchStatus:t=>qe.post("/sla/status/batch",t),getQuestionnaireReminderSettings:()=>qe.get("/sla/settings/questionnaire-reminder"),updateQuestionnaireReminderSettings:t=>qe.put("/sla/settings/questionnaire-reminder",t),getInterviewConfigs:t=>qe.get("/master/interview-configs",t),getInterviewConfigById:t=>qe.get(`/master/interview-configs/${t}`),getInterviewConfigByType:t=>qe.get(`/master/interview-configs/active/${t}`),createInterviewConfig:t=>qe.post("/master/interview-configs",t),updateInterviewConfig:(t,s)=>qe.put(`/master/interview-configs/${t}`,s),deleteInterviewConfig:t=>qe.delete(`/master/interview-configs/${t}`),initializeDefaultInterviewConfigs:()=>qe.post("/master/interview-configs/initialize"),getSystemConfigs:t=>qe.get("/master/system-configs",t),saveSystemConfig:t=>qe.post("/master/system-configs",t),getDealerAsmMappings:()=>qe.get("/master/dealer-asm-mappings"),saveDealerAsmMapping:t=>qe.post("/master/dealer-asm-mappings",t),getEorChecklistForApplication:t=>qe.get(`/eor/application/${t}`),getEorChecklistForRelocation:t=>qe.get(`/eor/relocation/${t}`),updateEorChecklistItem:(t,s)=>qe.post(`/eor/item/${t}`,s),submitEorAudit:(t,s)=>qe.post(`/eor/audit/${t}`,s),submitFddReport:t=>qe.post("/fdd/report",t),getFddAssignment:t=>qe.get(`/fdd/${t}`),assignFddAgency:t=>qe.post("/fdd/assign",t),flagNonResponsive:t=>qe.post("/flag",t),getSystemAuditLogs:t=>qe.get("/audit/system-logs",t),getSystemAuditSummary:()=>qe.get("/audit/system-summary")},cm=Object.freeze(Object.defineProperty({__proto__:null,API:Ee,default:Ee},Symbol.toStringTag,{value:"Module"})),w5={user:null,token:localStorage.getItem("token"),isAuthenticated:!1,loading:!0,error:null},Mm=RP("auth/initializeAuth",async(t,{rejectWithValue:s})=>{const n=localStorage.getItem("token");if(!n)return s("No token found");try{const r=await Ee.getCurrentUser();if(r.ok&&r.data){const{user:a}=r.data;return{user:{id:a.id,name:a.fullName||a.email.split("@")[0],email:a.email,password:"",role:typeof a.role=="string"?a.role:a.roleCode||"User",roleCode:a.roleCode||(typeof a.role=="string"?a.role:"User")},token:n}}return s("Failed to fetch user")}catch(r){return s(r.message||"Session restoration failed")}}),wA=eA({name:"auth",initialState:w5,reducers:{setCredentials:(t,s)=>{t.user=s.payload.user,t.token=s.payload.token,t.isAuthenticated=!0,t.loading=!1,localStorage.setItem("token",s.payload.token)},logout:t=>{t.user=null,t.token=null,t.isAuthenticated=!1,t.loading=!1,localStorage.removeItem("token")},setLoading:(t,s)=>{t.loading=s.payload}},extraReducers:t=>{t.addCase(Mm.pending,s=>{s.loading=!0}).addCase(Mm.fulfilled,(s,n)=>{s.user=n.payload.user,s.token=n.payload.token,s.isAuthenticated=!0,s.loading=!1}).addCase(Mm.rejected,s=>{s.user=null,s.token=null,s.isAuthenticated=!1,s.loading=!1,localStorage.removeItem("token")})}}),{setCredentials:SA,logout:CA,setLoading:vY}=wA.actions,S5=wA.reducer,C5={zones:[],regionalOffices:[],asms:[],zonalManagerMappings:[],zonalManagers:[],roles:[],allStates:[],allDistricts:[],allAreas:[],availablePermissions:[],emailTemplates:[],slaConfigs:[],users:[],ddLeads:[],areasPagination:{total:0,page:1,limit:10,totalPages:0},loading:!1,isAreasLoading:!1,error:null},AA=eA({name:"master",initialState:C5,reducers:{setMasterData:(t,s)=>({...t,...s.payload}),setAreasData:(t,s)=>{t.allAreas=s.payload.data,t.areasPagination=s.payload.pagination},setAreasLoading:(t,s)=>{t.isAreasLoading=s.payload},setZones:(t,s)=>{t.zones=s.payload},setRegionalOffices:(t,s)=>{t.regionalOffices=s.payload},setAsms:(t,s)=>{t.asms=s.payload},setZonalManagerMappings:(t,s)=>{t.zonalManagerMappings=s.payload},setUsers:(t,s)=>{t.users=s.payload},setLoading:(t,s)=>{t.loading=s.payload},setError:(t,s)=>{t.error=s.payload},setDdLeads:(t,s)=>{t.ddLeads=s.payload}}}),{setMasterData:kA,setZones:yY,setRegionalOffices:bY,setAsms:jY,setZonalManagerMappings:NY,setUsers:wY,setLoading:l1,setError:A5,setAreasData:k5,setAreasLoading:o1,setDdLeads:SY}=AA.actions,D5=AA.reducer,R5=bP({reducer:{auth:S5,master:D5}});var zu=Oy();const Hy=wf(zu);/**
* @remix-run/router v1.23.2
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function Su(){return Su=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var n=arguments[s];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Su.apply(this,arguments)}var Yl;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(Yl||(Yl={}));const c1="popstate";function E5(t){t===void 0&&(t={});function s(r,a){let{pathname:i,search:o,hash:d}=r.location;return Qv("",{pathname:i,search:o,hash:d},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function n(r,a){return typeof a=="string"?a:DA(a)}return T5(s,n,null,t)}function lr(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function Wy(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function _5(){return Math.random().toString(36).substr(2,8)}function d1(t,s){return{usr:t.state,key:t.key,idx:s}}function Qv(t,s,n,r){return n===void 0&&(n=null),Su({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?gd(s):s,{state:n,key:s&&s.key||r||_5()})}function DA(t){let{pathname:s="/",search:n="",hash:r=""}=t;return n&&n!=="?"&&(s+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(s+=r.charAt(0)==="#"?r:"#"+r),s}function gd(t){let s={};if(t){let n=t.indexOf("#");n>=0&&(s.hash=t.substr(n),t=t.substr(0,n));let r=t.indexOf("?");r>=0&&(s.search=t.substr(r),t=t.substr(0,r)),t&&(s.pathname=t)}return s}function T5(t,s,n,r){r===void 0&&(r={});let{window:a=document.defaultView,v5Compat:i=!1}=r,o=a.history,d=Yl.Pop,m=null,f=p();f==null&&(f=0,o.replaceState(Su({},o.state,{idx:f}),""));function p(){return(o.state||{idx:null}).idx}function h(){d=Yl.Pop;let w=p(),j=w==null?null:w-f;f=w,m&&m({action:d,location:v.location,delta:j})}function x(w,j){d=Yl.Push;let b=Qv(v.location,w,j);f=p()+1;let C=d1(b,f),S=v.createHref(b);try{o.pushState(C,"",S)}catch(R){if(R instanceof DOMException&&R.name==="DataCloneError")throw R;a.location.assign(S)}i&&m&&m({action:d,location:v.location,delta:1})}function u(w,j){d=Yl.Replace;let b=Qv(v.location,w,j);f=p();let C=d1(b,f),S=v.createHref(b);o.replaceState(C,"",S),i&&m&&m({action:d,location:v.location,delta:0})}function N(w){let j=a.location.origin!=="null"?a.location.origin:a.location.href,b=typeof w=="string"?w:DA(w);return b=b.replace(/ $/,"%20"),lr(j,"No window.location.(origin|href) available to create URL for href: "+b),new URL(b,j)}let v={get action(){return d},get location(){return t(a,o)},listen(w){if(m)throw new Error("A history only accepts one active listener");return a.addEventListener(c1,h),m=w,()=>{a.removeEventListener(c1,h),m=null}},createHref(w){return s(a,w)},createURL:N,encodeLocation(w){let j=N(w);return{pathname:j.pathname,search:j.search,hash:j.hash}},push:x,replace:u,go(w){return o.go(w)}};return v}var u1;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(u1||(u1={}));function P5(t,s,n){return n===void 0&&(n="/"),O5(t,s,n)}function O5(t,s,n,r){let a=typeof s=="string"?gd(s):s,i=_A(a.pathname||"/",n);if(i==null)return null;let o=RA(t);L5(o);let d=null;for(let m=0;d==null&&m<o.length;++m){let f=G5(i);d=V5(o[m],f)}return d}function RA(t,s,n,r){s===void 0&&(s=[]),n===void 0&&(n=[]),r===void 0&&(r="");let a=(i,o,d)=>{let m={relativePath:d===void 0?i.path||"":d,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};m.relativePath.startsWith("/")&&(lr(m.relativePath.startsWith(r),'Absolute route path "'+m.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),m.relativePath=m.relativePath.slice(r.length));let f=Jo([r,m.relativePath]),p=n.concat(m);i.children&&i.children.length>0&&(lr(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+f+'".')),RA(i.children,s,p,f)),!(i.path==null&&!i.index)&&s.push({path:f,score:z5(f,i.index),routesMeta:p})};return t.forEach((i,o)=>{var d;if(i.path===""||!((d=i.path)!=null&&d.includes("?")))a(i,o);else for(let m of EA(i.path))a(i,o,m)}),s}function EA(t){let s=t.split("/");if(s.length===0)return[];let[n,...r]=s,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let o=EA(r.join("/")),d=[];return d.push(...o.map(m=>m===""?i:[i,m].join("/"))),a&&d.push(...o),d.map(m=>t.startsWith("/")&&m===""?"/":m)}function L5(t){t.sort((s,n)=>s.score!==n.score?n.score-s.score:U5(s.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const I5=/^:[\w-]+$/,M5=3,F5=2,B5=1,$5=10,q5=-2,h1=t=>t==="*";function z5(t,s){let n=t.split("/"),r=n.length;return n.some(h1)&&(r+=q5),s&&(r+=F5),n.filter(a=>!h1(a)).reduce((a,i)=>a+(I5.test(i)?M5:i===""?B5:$5),r)}function U5(t,s){return t.length===s.length&&t.slice(0,-1).every((r,a)=>r===s[a])?t[t.length-1]-s[s.length-1]:0}function V5(t,s,n){let{routesMeta:r}=t,a={},i="/",o=[];for(let d=0;d<r.length;++d){let m=r[d],f=d===r.length-1,p=i==="/"?s:s.slice(i.length)||"/",h=H5({path:m.relativePath,caseSensitive:m.caseSensitive,end:f},p),x=m.route;if(!h)return null;Object.assign(a,h.params),o.push({params:a,pathname:Jo([i,h.pathname]),pathnameBase:X5(Jo([i,h.pathnameBase])),route:x}),h.pathnameBase!=="/"&&(i=Jo([i,h.pathnameBase]))}return o}function H5(t,s){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=W5(t.path,t.caseSensitive,t.end),a=s.match(n);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),d=a.slice(1);return{params:r.reduce((f,p,h)=>{let{paramName:x,isOptional:u}=p;if(x==="*"){let v=d[h]||"";o=i.slice(0,i.length-v.length).replace(/(.)\/+$/,"$1")}const N=d[h];return u&&!N?f[x]=void 0:f[x]=(N||"").replace(/%2F/g,"/"),f},{}),pathname:i,pathnameBase:o,pattern:t}}function W5(t,s,n){s===void 0&&(s=!1),n===void 0&&(n=!0),Wy(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let r=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,d,m)=>(r.push({paramName:d,isOptional:m!=null}),m?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(r.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,s?void 0:"i"),r]}function G5(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return Wy(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+s+").")),t}}function _A(t,s){if(s==="/")return t;if(!t.toLowerCase().startsWith(s.toLowerCase()))return null;let n=s.endsWith("/")?s.length-1:s.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}const K5=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Y5=t=>K5.test(t);function Z5(t,s){s===void 0&&(s="/");let{pathname:n,search:r="",hash:a=""}=typeof t=="string"?gd(t):t,i;if(n)if(Y5(n))i=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Wy(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?i=m1(n.substring(1),"/"):i=m1(n,s)}else i=s;return{pathname:i,search:J5(r),hash:eL(a)}}function m1(t,s){let n=s.replace(/\/+$/,"").split("/");return t.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function fg(t,s,n,r){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+s+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function Q5(t){return t.filter((s,n)=>n===0||s.route.path&&s.route.path.length>0)}function TA(t,s){let n=Q5(t);return s?n.map((r,a)=>a===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function PA(t,s,n,r){r===void 0&&(r=!1);let a;typeof t=="string"?a=gd(t):(a=Su({},t),lr(!a.pathname||!a.pathname.includes("?"),fg("?","pathname","search",a)),lr(!a.pathname||!a.pathname.includes("#"),fg("#","pathname","hash",a)),lr(!a.search||!a.search.includes("#"),fg("#","search","hash",a)));let i=t===""||a.pathname==="",o=i?"/":a.pathname,d;if(o==null)d=n;else{let h=s.length-1;if(!r&&o.startsWith("..")){let x=o.split("/");for(;x[0]==="..";)x.shift(),h-=1;a.pathname=x.join("/")}d=h>=0?s[h]:"/"}let m=Z5(a,d),f=o&&o!=="/"&&o.endsWith("/"),p=(i||o===".")&&n.endsWith("/");return!m.pathname.endsWith("/")&&(f||p)&&(m.pathname+="/"),m}const Jo=t=>t.join("/").replace(/\/\/+/g,"/"),X5=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),J5=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,eL=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function tL(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const OA=["post","put","patch","delete"];new Set(OA);const sL=["get",...OA];new Set(sL);/**
* React Router v6.30.3
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function Cu(){return Cu=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var n=arguments[s];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Cu.apply(this,arguments)}const Gy=g.createContext(null),nL=g.createContext(null),Uu=g.createContext(null),Mf=g.createContext(null),vl=g.createContext({outlet:null,matches:[],isDataRoute:!1}),LA=g.createContext(null);function Vu(){return g.useContext(Mf)!=null}function yl(){return Vu()||lr(!1),g.useContext(Mf).location}function IA(t){g.useContext(Uu).static||g.useLayoutEffect(t)}function tr(){let{isDataRoute:t}=g.useContext(vl);return t?vL():rL()}function rL(){Vu()||lr(!1);let t=g.useContext(Gy),{basename:s,future:n,navigator:r}=g.useContext(Uu),{matches:a}=g.useContext(vl),{pathname:i}=yl(),o=JSON.stringify(TA(a,n.v7_relativeSplatPath)),d=g.useRef(!1);return IA(()=>{d.current=!0}),g.useCallback(function(f,p){if(p===void 0&&(p={}),!d.current)return;if(typeof f=="number"){r.go(f);return}let h=PA(f,JSON.parse(o),i,p.relative==="path");t==null&&s!=="/"&&(h.pathname=h.pathname==="/"?s:Jo([s,h.pathname])),(p.replace?r.replace:r.push)(h,p.state,p)},[s,r,o,i,t])}const aL=g.createContext(null);function iL(t){let s=g.useContext(vl).outlet;return s&&g.createElement(aL.Provider,{value:t},s)}function vd(){let{matches:t}=g.useContext(vl),s=t[t.length-1];return s?s.params:{}}function lL(t,s){return oL(t,s)}function oL(t,s,n,r){Vu()||lr(!1);let{navigator:a}=g.useContext(Uu),{matches:i}=g.useContext(vl),o=i[i.length-1],d=o?o.params:{};o&&o.pathname;let m=o?o.pathnameBase:"/";o&&o.route;let f=yl(),p;if(s){var h;let w=typeof s=="string"?gd(s):s;m==="/"||(h=w.pathname)!=null&&h.startsWith(m)||lr(!1),p=w}else p=f;let x=p.pathname||"/",u=x;if(m!=="/"){let w=m.replace(/^\//,"").split("/");u="/"+x.replace(/^\//,"").split("/").slice(w.length).join("/")}let N=P5(t,{pathname:u}),v=mL(N&&N.map(w=>Object.assign({},w,{params:Object.assign({},d,w.params),pathname:Jo([m,a.encodeLocation?a.encodeLocation(w.pathname).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?m:Jo([m,a.encodeLocation?a.encodeLocation(w.pathnameBase).pathname:w.pathnameBase])})),i,n,r);return s&&v?g.createElement(Mf.Provider,{value:{location:Cu({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:Yl.Pop}},v):v}function cL(){let t=gL(),s=tL(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return g.createElement(g.Fragment,null,g.createElement("h2",null,"Unexpected Application Error!"),g.createElement("h3",{style:{fontStyle:"italic"}},s),n?g.createElement("pre",{style:a},n):null,null)}const dL=g.createElement(cL,null);class uL extends g.Component{constructor(s){super(s),this.state={location:s.location,revalidation:s.revalidation,error:s.error}}static getDerivedStateFromError(s){return{error:s}}static getDerivedStateFromProps(s,n){return n.location!==s.location||n.revalidation!=="idle"&&s.revalidation==="idle"?{error:s.error,location:s.location,revalidation:s.revalidation}:{error:s.error!==void 0?s.error:n.error,location:n.location,revalidation:s.revalidation||n.revalidation}}componentDidCatch(s,n){console.error("React Router caught the following error during render",s,n)}render(){return this.state.error!==void 0?g.createElement(vl.Provider,{value:this.props.routeContext},g.createElement(LA.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function hL(t){let{routeContext:s,match:n,children:r}=t,a=g.useContext(Gy);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),g.createElement(vl.Provider,{value:s},r)}function mL(t,s,n,r){var a;if(s===void 0&&(s=[]),n===void 0&&(n=null),r===void 0&&(r=null),t==null){var i;if(!n)return null;if(n.errors)t=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&s.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let o=t,d=(a=n)==null?void 0:a.errors;if(d!=null){let p=o.findIndex(h=>h.route.id&&(d==null?void 0:d[h.route.id])!==void 0);p>=0||lr(!1),o=o.slice(0,Math.min(o.length,p+1))}let m=!1,f=-1;if(n&&r&&r.v7_partialHydration)for(let p=0;p<o.length;p++){let h=o[p];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(f=p),h.route.id){let{loaderData:x,errors:u}=n,N=h.route.loader&&x[h.route.id]===void 0&&(!u||u[h.route.id]===void 0);if(h.route.lazy||N){m=!0,f>=0?o=o.slice(0,f+1):o=[o[0]];break}}}return o.reduceRight((p,h,x)=>{let u,N=!1,v=null,w=null;n&&(u=d&&h.route.id?d[h.route.id]:void 0,v=h.route.errorElement||dL,m&&(f<0&&x===0?(yL("route-fallback"),N=!0,w=null):f===x&&(N=!0,w=h.route.hydrateFallbackElement||null)));let j=s.concat(o.slice(0,x+1)),b=()=>{let C;return u?C=v:N?C=w:h.route.Component?C=g.createElement(h.route.Component,null):h.route.element?C=h.route.element:C=p,g.createElement(hL,{match:h,routeContext:{outlet:p,matches:j,isDataRoute:n!=null},children:C})};return n&&(h.route.ErrorBoundary||h.route.errorElement||x===0)?g.createElement(uL,{location:n.location,revalidation:n.revalidation,component:v,error:u,children:b(),routeContext:{outlet:null,matches:j,isDataRoute:!0}}):b()},null)}var MA=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(MA||{}),FA=(function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t})(FA||{});function fL(t){let s=g.useContext(Gy);return s||lr(!1),s}function pL(t){let s=g.useContext(nL);return s||lr(!1),s}function xL(t){let s=g.useContext(vl);return s||lr(!1),s}function BA(t){let s=xL(),n=s.matches[s.matches.length-1];return n.route.id||lr(!1),n.route.id}function gL(){var t;let s=g.useContext(LA),n=pL(),r=BA();return s!==void 0?s:(t=n.errors)==null?void 0:t[r]}function vL(){let{router:t}=fL(MA.UseNavigateStable),s=BA(FA.UseNavigateStable),n=g.useRef(!1);return IA(()=>{n.current=!0}),g.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,Cu({fromRouteId:s},i)))},[t,s])}const f1={};function yL(t,s,n){f1[t]||(f1[t]=!0)}function bL(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Yn(t){let{to:s,replace:n,state:r,relative:a}=t;Vu()||lr(!1);let{future:i,static:o}=g.useContext(Uu),{matches:d}=g.useContext(vl),{pathname:m}=yl(),f=tr(),p=PA(s,TA(d,i.v7_relativeSplatPath),m,a==="path"),h=JSON.stringify(p);return g.useEffect(()=>f(JSON.parse(h),{replace:n,state:r,relative:a}),[f,h,a,n,r]),null}function jL(t){return iL(t.context)}function ks(t){lr(!1)}function NL(t){let{basename:s="/",children:n=null,location:r,navigationType:a=Yl.Pop,navigator:i,static:o=!1,future:d}=t;Vu()&&lr(!1);let m=s.replace(/^\/*/,"/"),f=g.useMemo(()=>({basename:m,navigator:i,static:o,future:Cu({v7_relativeSplatPath:!1},d)}),[m,d,i,o]);typeof r=="string"&&(r=gd(r));let{pathname:p="/",search:h="",hash:x="",state:u=null,key:N="default"}=r,v=g.useMemo(()=>{let w=_A(p,m);return w==null?null:{location:{pathname:w,search:h,hash:x,state:u,key:N},navigationType:a}},[m,p,h,x,u,N,a]);return v==null?null:g.createElement(Uu.Provider,{value:f},g.createElement(Mf.Provider,{children:n,value:v}))}function Xv(t){let{children:s,location:n}=t;return lL(Jv(s),n)}new Promise(()=>{});function Jv(t,s){s===void 0&&(s=[]);let n=[];return g.Children.forEach(t,(r,a)=>{if(!g.isValidElement(r))return;let i=[...s,a];if(r.type===g.Fragment){n.push.apply(n,Jv(r.props.children,i));return}r.type!==ks&&lr(!1),!r.props.index||!r.props.children||lr(!1);let o={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=Jv(r.props.children,i)),n.push(o)}),n}/**
* React Router DOM v6.30.3
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/const wL="6";try{window.__reactRouterVersion=wL}catch{}const SL="startTransition",p1=Sf[SL];function CL(t){let{basename:s,children:n,future:r,window:a}=t,i=g.useRef();i.current==null&&(i.current=E5({window:a,v5Compat:!0}));let o=i.current,[d,m]=g.useState({action:o.action,location:o.location}),{v7_startTransition:f}=r||{},p=g.useCallback(h=>{f&&p1?p1(()=>m(h)):m(h)},[m,f]);return g.useLayoutEffect(()=>o.listen(p),[o,p]),g.useEffect(()=>bL(r),[r]),g.createElement(NL,{basename:s,children:n,location:d.location,navigationType:d.action,navigator:o,future:r})}var x1;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(x1||(x1={}));var g1;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(g1||(g1={}));const v1=({children:t,allowedRoles:s,excludeRoles:n,redirectTo:r})=>{const{user:a,isAuthenticated:i,loading:o}=In(h=>h.auth),d=yl(),m=String((a==null?void 0:a.role)||(a==null?void 0:a.roleCode)||"").trim().toLowerCase(),f=(s||[]).map(h=>String(h).trim().toLowerCase()),p=(n||[]).map(h=>String(h).trim().toLowerCase());return o?e.jsx("div",{className:"flex h-screen items-center justify-center",children:"Loading..."}):i?n&&a&&p.includes(m)?m==="prospective dealer"?e.jsx(Yn,{to:"/prospective-dashboard",replace:!0}):e.jsx(Yn,{to:r||"/dashboard",replace:!0}):s&&a&&!f.includes(m)?e.jsx(Yn,{to:r||"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t}):e.jsx(Yn,{to:"/admin-login",state:{from:d},replace:!0})};function y1(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function Xr(...t){return s=>{let n=!1;const r=t.map(a=>{const i=y1(a,s);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a<r.length;a++){const i=r[a];typeof i=="function"?i():y1(t[a],null)}}}}function Gs(...t){return g.useCallback(Xr(...t),t)}var AL=Symbol.for("react.lazy"),rf=Sf[" use ".trim().toString()];function kL(t){return typeof t=="object"&&t!==null&&"then"in t}function $A(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===AL&&"_payload"in t&&kL(t._payload)}function Hu(t){const s=DL(t),n=g.forwardRef((r,a)=>{let{children:i,...o}=r;$A(i)&&typeof rf=="function"&&(i=rf(i._payload));const d=g.Children.toArray(i),m=d.find(EL);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}var qA=Hu("Slot");function DL(t){const s=g.forwardRef((n,r)=>{let{children:a,...i}=n;if($A(a)&&typeof rf=="function"&&(a=rf(a._payload)),g.isValidElement(a)){const o=TL(a),d=_L(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Xr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var RL=Symbol("radix.slottable");function EL(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===RL}function _L(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function TL(t){var r,a;let s=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function zA(t){var s,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var a=t.length;for(s=0;s<a;s++)t[s]&&(n=zA(t[s]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function UA(){for(var t,s,n=0,r="",a=arguments.length;n<a;n++)(t=arguments[n])&&(s=zA(t))&&(r&&(r+=" "),r+=s);return r}const b1=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,j1=UA,Ky=(t,s)=>n=>{var r;if((s==null?void 0:s.variants)==null)return j1(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:a,defaultVariants:i}=s,o=Object.keys(a).map(f=>{const p=n==null?void 0:n[f],h=i==null?void 0:i[f];if(p===null)return null;const x=b1(p)||b1(h);return a[f][x]}),d=n&&Object.entries(n).reduce((f,p)=>{let[h,x]=p;return x===void 0||(f[h]=x),f},{}),m=s==null||(r=s.compoundVariants)===null||r===void 0?void 0:r.reduce((f,p)=>{let{class:h,className:x,...u}=p;return Object.entries(u).every(N=>{let[v,w]=N;return Array.isArray(w)?w.includes({...i,...d}[v]):{...i,...d}[v]===w})?[...f,h,x]:f},[]);return j1(t,o,m,n==null?void 0:n.class,n==null?void 0:n.className)},Yy="-",PL=t=>{const s=LL(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const d=o.split(Yy);return d[0]===""&&d.length!==1&&d.shift(),VA(d,s)||OL(o)},getConflictingClassGroupIds:(o,d)=>{const m=n[o]||[];return d&&r[o]?[...m,...r[o]]:m}}},VA=(t,s)=>{var o;if(t.length===0)return s.classGroupId;const n=t[0],r=s.nextPart.get(n),a=r?VA(t.slice(1),r):void 0;if(a)return a;if(s.validators.length===0)return;const i=t.join(Yy);return(o=s.validators.find(({validator:d})=>d(i)))==null?void 0:o.classGroupId},N1=/^\[(.+)\]$/,OL=t=>{if(N1.test(t)){const s=N1.exec(t)[1],n=s==null?void 0:s.substring(0,s.indexOf(":"));if(n)return"arbitrary.."+n}},LL=t=>{const{theme:s,prefix:n}=t,r={nextPart:new Map,validators:[]};return ML(Object.entries(t.classGroups),n).forEach(([i,o])=>{ey(o,r,i,s)}),r},ey=(t,s,n,r)=>{t.forEach(a=>{if(typeof a=="string"){const i=a===""?s:w1(s,a);i.classGroupId=n;return}if(typeof a=="function"){if(IL(a)){ey(a(r),s,n,r);return}s.validators.push({validator:a,classGroupId:n});return}Object.entries(a).forEach(([i,o])=>{ey(o,w1(s,i),n,r)})})},w1=(t,s)=>{let n=t;return s.split(Yy).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},IL=t=>t.isThemeGetter,ML=(t,s)=>s?t.map(([n,r])=>{const a=r.map(i=>typeof i=="string"?s+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([o,d])=>[s+o,d])):i);return[n,a]}):t,FL=t=>{if(t<1)return{get:()=>{},set:()=>{}};let s=0,n=new Map,r=new Map;const a=(i,o)=>{n.set(i,o),s++,s>t&&(s=0,r=n,n=new Map)};return{get(i){let o=n.get(i);if(o!==void 0)return o;if((o=r.get(i))!==void 0)return a(i,o),o},set(i,o){n.has(i)?n.set(i,o):a(i,o)}}},HA="!",BL=t=>{const{separator:s,experimentalParseClassName:n}=t,r=s.length===1,a=s[0],i=s.length,o=d=>{const m=[];let f=0,p=0,h;for(let w=0;w<d.length;w++){let j=d[w];if(f===0){if(j===a&&(r||d.slice(w,w+i)===s)){m.push(d.slice(p,w)),p=w+i;continue}if(j==="/"){h=w;continue}}j==="["?f++:j==="]"&&f--}const x=m.length===0?d:d.substring(p),u=x.startsWith(HA),N=u?x.substring(1):x,v=h&&h>p?h-p:void 0;return{modifiers:m,hasImportantModifier:u,baseClassName:N,maybePostfixModifierPosition:v}};return n?d=>n({className:d,parseClassName:o}):o},$L=t=>{if(t.length<=1)return t;const s=[];let n=[];return t.forEach(r=>{r[0]==="["?(s.push(...n.sort(),r),n=[]):n.push(r)}),s.push(...n.sort()),s},qL=t=>({cache:FL(t.cacheSize),parseClassName:BL(t),...PL(t)}),zL=/\s+/,UL=(t,s)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a}=s,i=[],o=t.trim().split(zL);let d="";for(let m=o.length-1;m>=0;m-=1){const f=o[m],{modifiers:p,hasImportantModifier:h,baseClassName:x,maybePostfixModifierPosition:u}=n(f);let N=!!u,v=r(N?x.substring(0,u):x);if(!v){if(!N){d=f+(d.length>0?" "+d:d);continue}if(v=r(x),!v){d=f+(d.length>0?" "+d:d);continue}N=!1}const w=$L(p).join(":"),j=h?w+HA:w,b=j+v;if(i.includes(b))continue;i.push(b);const C=a(v,N);for(let S=0;S<C.length;++S){const R=C[S];i.push(j+R)}d=f+(d.length>0?" "+d:d)}return d};function VL(){let t=0,s,n,r="";for(;t<arguments.length;)(s=arguments[t++])&&(n=WA(s))&&(r&&(r+=" "),r+=n);return r}const WA=t=>{if(typeof t=="string")return t;let s,n="";for(let r=0;r<t.length;r++)t[r]&&(s=WA(t[r]))&&(n&&(n+=" "),n+=s);return n};function HL(t,...s){let n,r,a,i=o;function o(m){const f=s.reduce((p,h)=>h(p),t());return n=qL(f),r=n.cache.get,a=n.cache.set,i=d,d(m)}function d(m){const f=r(m);if(f)return f;const p=UL(m,n);return a(m,p),p}return function(){return i(VL.apply(null,arguments))}}const On=t=>{const s=n=>n[t]||[];return s.isThemeGetter=!0,s},GA=/^\[(?:([a-z-]+):)?(.+)\]$/i,WL=/^\d+\/\d+$/,GL=new Set(["px","full","screen"]),KL=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,YL=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ZL=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,QL=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,XL=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,al=t=>Qc(t)||GL.has(t)||WL.test(t),Hl=t=>yd(t,"length",iI),Qc=t=>!!t&&!Number.isNaN(Number(t)),pg=t=>yd(t,"number",Qc),eu=t=>!!t&&Number.isInteger(Number(t)),JL=t=>t.endsWith("%")&&Qc(t.slice(0,-1)),Zs=t=>GA.test(t),Wl=t=>KL.test(t),eI=new Set(["length","size","percentage"]),tI=t=>yd(t,eI,KA),sI=t=>yd(t,"position",KA),nI=new Set(["image","url"]),rI=t=>yd(t,nI,oI),aI=t=>yd(t,"",lI),tu=()=>!0,yd=(t,s,n)=>{const r=GA.exec(t);return r?r[1]?typeof s=="string"?r[1]===s:s.has(r[1]):n(r[2]):!1},iI=t=>YL.test(t)&&!ZL.test(t),KA=()=>!1,lI=t=>QL.test(t),oI=t=>XL.test(t),cI=()=>{const t=On("colors"),s=On("spacing"),n=On("blur"),r=On("brightness"),a=On("borderColor"),i=On("borderRadius"),o=On("borderSpacing"),d=On("borderWidth"),m=On("contrast"),f=On("grayscale"),p=On("hueRotate"),h=On("invert"),x=On("gap"),u=On("gradientColorStops"),N=On("gradientColorStopPositions"),v=On("inset"),w=On("margin"),j=On("opacity"),b=On("padding"),C=On("saturate"),S=On("scale"),R=On("sepia"),_=On("skew"),A=On("space"),E=On("translate"),q=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto",Zs,s],P=()=>[Zs,s],L=()=>["",al,Hl],$=()=>["auto",Qc,Zs],Y=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Z=()=>["solid","dashed","dotted","double","none"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],U=()=>["start","end","center","between","around","evenly","stretch"],M=()=>["","0",Zs],z=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>[Qc,Zs];return{cacheSize:500,separator:":",theme:{colors:[tu],spacing:[al,Hl],blur:["none","",Wl,Zs],brightness:T(),borderColor:[t],borderRadius:["none","","full",Wl,Zs],borderSpacing:P(),borderWidth:L(),contrast:T(),grayscale:M(),hueRotate:T(),invert:M(),gap:P(),gradientColorStops:[t],gradientColorStopPositions:[JL,Hl],inset:D(),margin:D(),opacity:T(),padding:P(),saturate:T(),scale:T(),sepia:M(),skew:T(),space:P(),translate:P()},classGroups:{aspect:[{aspect:["auto","square","video",Zs]}],container:["container"],columns:[{columns:[Wl]}],"break-after":[{"break-after":z()}],"break-before":[{"break-before":z()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...Y(),Zs]}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:q()}],"overscroll-x":[{"overscroll-x":q()}],"overscroll-y":[{"overscroll-y":q()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[v]}],"inset-x":[{"inset-x":[v]}],"inset-y":[{"inset-y":[v]}],start:[{start:[v]}],end:[{end:[v]}],top:[{top:[v]}],right:[{right:[v]}],bottom:[{bottom:[v]}],left:[{left:[v]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",eu,Zs]}],basis:[{basis:D()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Zs]}],grow:[{grow:M()}],shrink:[{shrink:M()}],order:[{order:["first","last","none",eu,Zs]}],"grid-cols":[{"grid-cols":[tu]}],"col-start-end":[{col:["auto",{span:["full",eu,Zs]},Zs]}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":[tu]}],"row-start-end":[{row:["auto",{span:[eu,Zs]},Zs]}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Zs]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Zs]}],gap:[{gap:[x]}],"gap-x":[{"gap-x":[x]}],"gap-y":[{"gap-y":[x]}],"justify-content":[{justify:["normal",...U()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...U(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...U(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[b]}],px:[{px:[b]}],py:[{py:[b]}],ps:[{ps:[b]}],pe:[{pe:[b]}],pt:[{pt:[b]}],pr:[{pr:[b]}],pb:[{pb:[b]}],pl:[{pl:[b]}],m:[{m:[w]}],mx:[{mx:[w]}],my:[{my:[w]}],ms:[{ms:[w]}],me:[{me:[w]}],mt:[{mt:[w]}],mr:[{mr:[w]}],mb:[{mb:[w]}],ml:[{ml:[w]}],"space-x":[{"space-x":[A]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[A]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Zs,s]}],"min-w":[{"min-w":[Zs,s,"min","max","fit"]}],"max-w":[{"max-w":[Zs,s,"none","full","min","max","fit","prose",{screen:[Wl]},Wl]}],h:[{h:[Zs,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Zs,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Zs,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Zs,s,"auto","min","max","fit"]}],"font-size":[{text:["base",Wl,Hl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",pg]}],"font-family":[{font:[tu]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Zs]}],"line-clamp":[{"line-clamp":["none",Qc,pg]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",al,Zs]}],"list-image":[{"list-image":["none",Zs]}],"list-style-type":[{list:["none","disc","decimal",Zs]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[j]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[j]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Z(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",al,Hl]}],"underline-offset":[{"underline-offset":["auto",al,Zs]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Zs]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Zs]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[j]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Y(),sI]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",tI]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},rI]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[N]}],"gradient-via-pos":[{via:[N]}],"gradient-to-pos":[{to:[N]}],"gradient-from":[{from:[u]}],"gradient-via":[{via:[u]}],"gradient-to":[{to:[u]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[d]}],"border-w-x":[{"border-x":[d]}],"border-w-y":[{"border-y":[d]}],"border-w-s":[{"border-s":[d]}],"border-w-e":[{"border-e":[d]}],"border-w-t":[{"border-t":[d]}],"border-w-r":[{"border-r":[d]}],"border-w-b":[{"border-b":[d]}],"border-w-l":[{"border-l":[d]}],"border-opacity":[{"border-opacity":[j]}],"border-style":[{border:[...Z(),"hidden"]}],"divide-x":[{"divide-x":[d]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[d]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[j]}],"divide-style":[{divide:Z()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...Z()]}],"outline-offset":[{"outline-offset":[al,Zs]}],"outline-w":[{outline:[al,Hl]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:L()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[j]}],"ring-offset-w":[{"ring-offset":[al,Hl]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Wl,aI]}],"shadow-color":[{shadow:[tu]}],opacity:[{opacity:[j]}],"mix-blend":[{"mix-blend":[...W(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":W()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[m]}],"drop-shadow":[{"drop-shadow":["","none",Wl,Zs]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[h]}],saturate:[{saturate:[C]}],sepia:[{sepia:[R]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[m]}],"backdrop-grayscale":[{"backdrop-grayscale":[f]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[p]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[j]}],"backdrop-saturate":[{"backdrop-saturate":[C]}],"backdrop-sepia":[{"backdrop-sepia":[R]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Zs]}],duration:[{duration:T()}],ease:[{ease:["linear","in","out","in-out",Zs]}],delay:[{delay:T()}],animate:[{animate:["none","spin","ping","pulse","bounce",Zs]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[S]}],"scale-x":[{"scale-x":[S]}],"scale-y":[{"scale-y":[S]}],rotate:[{rotate:[eu,Zs]}],"translate-x":[{"translate-x":[E]}],"translate-y":[{"translate-y":[E]}],"skew-x":[{"skew-x":[_]}],"skew-y":[{"skew-y":[_]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Zs]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Zs]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Zs]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[al,Hl,pg]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},dI=HL(cI);function Nt(...t){return dI(UA(t))}function Yt(t,s="full"){const n=new Date(t),r={day:"2-digit",month:"short",year:"numeric"};return(s==="full"||s==="time")&&(r.hour="2-digit",r.minute="2-digit",r.hour12=!0),s==="time"?n.toLocaleTimeString("en-IN",{hour:"2-digit",minute:"2-digit",hour12:!0}):s==="full"?n.toLocaleString("en-IN",r):n.toLocaleDateString("en-IN",r)}const rd=Ky("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background text-foreground hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9 rounded-md"}},defaultVariants:{variant:"default",size:"default"}}),se=g.forwardRef(({className:t,variant:s,size:n,asChild:r=!1,...a},i)=>{const o=r?qA:"button";return e.jsx(o,{"data-slot":"button",className:Nt(rd({variant:s,size:n,className:t})),ref:i,...a})});se.displayName="Button";const at=g.forwardRef(({className:t,type:s,...n},r)=>e.jsx("input",{type:s,ref:r,"data-slot":"input",className:Nt("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border px-3 py-1 text-base bg-input-background transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...n}));at.displayName="Input";function Ws({className:t,...s}){return e.jsx("textarea",{"data-slot":"textarea",className:Nt("resize-none border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-input-background px-3 py-2 text-base transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),...s})}function uI(t,s){const n=g.createContext(s),r=i=>{const{children:o,...d}=i,m=g.useMemo(()=>d,Object.values(d));return e.jsx(n.Provider,{value:m,children:o})};r.displayName=t+"Provider";function a(i){const o=g.useContext(n);if(o)return o;if(s!==void 0)return s;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[r,a]}function ga(t,s=[]){let n=[];function r(i,o){const d=g.createContext(o),m=n.length;n=[...n,o];const f=h=>{var j;const{scope:x,children:u,...N}=h,v=((j=x==null?void 0:x[t])==null?void 0:j[m])||d,w=g.useMemo(()=>N,Object.values(N));return e.jsx(v.Provider,{value:w,children:u})};f.displayName=i+"Provider";function p(h,x){var v;const u=((v=x==null?void 0:x[t])==null?void 0:v[m])||d,N=g.useContext(u);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[f,p]}const a=()=>{const i=n.map(o=>g.createContext(o));return function(d){const m=(d==null?void 0:d[t])||i;return g.useMemo(()=>({[`__scope${t}`]:{...d,[t]:m}}),[d,m])}};return a.scopeName=t,[r,hI(a,...s)]}function hI(...t){const s=t[0];if(t.length===1)return s;const n=()=>{const r=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((d,{useScope:m,scopeName:f})=>{const h=m(i)[`__scope${f}`];return{...d,...h}},{});return g.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return n.scopeName=s.scopeName,n}function Kt(t,s,{checkForDefaultPrevented:n=!0}={}){return function(a){if(t==null||t(a),n===!1||!a.defaultPrevented)return s==null?void 0:s(a)}}var cr=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},mI=Sf[" useInsertionEffect ".trim().toString()]||cr;function Bi({prop:t,defaultProp:s,onChange:n=()=>{},caller:r}){const[a,i,o]=fI({defaultProp:s,onChange:n}),d=t!==void 0,m=d?t:a;{const p=g.useRef(t!==void 0);g.useEffect(()=>{const h=p.current;h!==d&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${d?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=d},[d,r])}const f=g.useCallback(p=>{var h;if(d){const x=pI(p)?p(t):p;x!==t&&((h=o.current)==null||h.call(o,x))}else i(p)},[d,t,i,o]);return[m,f]}function fI({defaultProp:t,onChange:s}){const[n,r]=g.useState(t),a=g.useRef(n),i=g.useRef(s);return mI(()=>{i.current=s},[s]),g.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,r,i]}function pI(t){return typeof t=="function"}function Zy(t){const s=g.useRef({value:t,previous:t});return g.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}function Qy(t){const[s,n]=g.useState(void 0);return cr(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const i=a[0];let o,d;if("borderBoxSize"in i){const m=i.borderBoxSize,f=Array.isArray(m)?m[0]:m;o=f.inlineSize,d=f.blockSize}else o=t.offsetWidth,d=t.offsetHeight;n({width:o,height:d})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),s}function xI(t,s){return g.useReducer((n,r)=>s[n][r]??n,t)}var Dr=t=>{const{present:s,children:n}=t,r=gI(s),a=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),i=Gs(r.ref,vI(a));return typeof n=="function"||r.isPresent?g.cloneElement(a,{ref:i}):null};Dr.displayName="Presence";function gI(t){const[s,n]=g.useState(),r=g.useRef(null),a=g.useRef(t),i=g.useRef("none"),o=t?"mounted":"unmounted",[d,m]=xI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const f=dm(r.current);i.current=d==="mounted"?f:"none"},[d]),cr(()=>{const f=r.current,p=a.current;if(p!==t){const x=i.current,u=dm(f);t?m("MOUNT"):u==="none"||(f==null?void 0:f.display)==="none"?m("UNMOUNT"):m(p&&x!==u?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,m]),cr(()=>{if(s){let f;const p=s.ownerDocument.defaultView??window,h=u=>{const v=dm(r.current).includes(CSS.escape(u.animationName));if(u.target===s&&v&&(m("ANIMATION_END"),!a.current)){const w=s.style.animationFillMode;s.style.animationFillMode="forwards",f=p.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=w)})}},x=u=>{u.target===s&&(i.current=dm(r.current))};return s.addEventListener("animationstart",x),s.addEventListener("animationcancel",h),s.addEventListener("animationend",h),()=>{p.clearTimeout(f),s.removeEventListener("animationstart",x),s.removeEventListener("animationcancel",h),s.removeEventListener("animationend",h)}}else m("ANIMATION_END")},[s,m]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:g.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function dm(t){return(t==null?void 0:t.animationName)||"none"}function vI(t){var r,a;let s=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function yI(t){const s=bI(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find(NI);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function bI(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=SI(a),d=wI(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Xr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var jI=Symbol("radix.slottable");function NI(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===jI}function wI(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function SI(t){var r,a;let s=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var CI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],js=CI.reduce((t,s)=>{const n=yI(`Primitive.${s}`),r=g.forwardRef((a,i)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{});function YA(t,s){t&&zu.flushSync(()=>t.dispatchEvent(s))}var Ff="Checkbox",[AI]=ga(Ff),[kI,Xy]=AI(Ff);function DI(t){const{__scopeCheckbox:s,checked:n,children:r,defaultChecked:a,disabled:i,form:o,name:d,onCheckedChange:m,required:f,value:p="on",internal_do_not_use_render:h}=t,[x,u]=Bi({prop:n,defaultProp:a??!1,onChange:m,caller:Ff}),[N,v]=g.useState(null),[w,j]=g.useState(null),b=g.useRef(!1),C=N?!!o||!!N.closest("form"):!0,S={checked:x,disabled:i,setChecked:u,control:N,setControl:v,name:d,form:o,value:p,hasConsumerStoppedPropagationRef:b,required:f,defaultChecked:Ql(a)?!1:a,isFormControl:C,bubbleInput:w,setBubbleInput:j};return e.jsx(kI,{scope:s,...S,children:RI(h)?h(S):r})}var ZA="CheckboxTrigger",QA=g.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:n,...r},a)=>{const{control:i,value:o,disabled:d,checked:m,required:f,setControl:p,setChecked:h,hasConsumerStoppedPropagationRef:x,isFormControl:u,bubbleInput:N}=Xy(ZA,t),v=Gs(a,p),w=g.useRef(m);return g.useEffect(()=>{const j=i==null?void 0:i.form;if(j){const b=()=>h(w.current);return j.addEventListener("reset",b),()=>j.removeEventListener("reset",b)}},[i,h]),e.jsx(js.button,{type:"button",role:"checkbox","aria-checked":Ql(m)?"mixed":m,"aria-required":f,"data-state":nk(m),"data-disabled":d?"":void 0,disabled:d,value:o,...r,ref:v,onKeyDown:Kt(s,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:Kt(n,j=>{h(b=>Ql(b)?!0:!b),N&&u&&(x.current=j.isPropagationStopped(),x.current||j.stopPropagation())})})});QA.displayName=ZA;var XA=g.forwardRef((t,s)=>{const{__scopeCheckbox:n,name:r,checked:a,defaultChecked:i,required:o,disabled:d,value:m,onCheckedChange:f,form:p,...h}=t;return e.jsx(DI,{__scopeCheckbox:n,checked:a,defaultChecked:i,disabled:d,required:o,onCheckedChange:f,name:r,form:p,value:m,internal_do_not_use_render:({isFormControl:x})=>e.jsxs(e.Fragment,{children:[e.jsx(QA,{...h,ref:s,__scopeCheckbox:n}),x&&e.jsx(sk,{__scopeCheckbox:n})]})})});XA.displayName=Ff;var JA="CheckboxIndicator",ek=g.forwardRef((t,s)=>{const{__scopeCheckbox:n,forceMount:r,...a}=t,i=Xy(JA,n);return e.jsx(Dr,{present:r||Ql(i.checked)||i.checked===!0,children:e.jsx(js.span,{"data-state":nk(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});ek.displayName=JA;var tk="CheckboxBubbleInput",sk=g.forwardRef(({__scopeCheckbox:t,...s},n)=>{const{control:r,hasConsumerStoppedPropagationRef:a,checked:i,defaultChecked:o,required:d,disabled:m,name:f,value:p,form:h,bubbleInput:x,setBubbleInput:u}=Xy(tk,t),N=Gs(n,u),v=Zy(i),w=Qy(r);g.useEffect(()=>{const b=x;if(!b)return;const C=window.HTMLInputElement.prototype,R=Object.getOwnPropertyDescriptor(C,"checked").set,_=!a.current;if(v!==i&&R){const A=new Event("click",{bubbles:_});b.indeterminate=Ql(i),R.call(b,Ql(i)?!1:i),b.dispatchEvent(A)}},[x,v,i,a]);const j=g.useRef(Ql(i)?!1:i);return e.jsx(js.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??j.current,required:d,disabled:m,name:f,value:p,form:h,...s,tabIndex:-1,ref:N,style:{...s.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});sk.displayName=tk;function RI(t){return typeof t=="function"}function Ql(t){return t==="indeterminate"}function nk(t){return Ql(t)?"indeterminate":t?"checked":"unchecked"}/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/var EI={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const _I=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),gt=(t,s)=>{const n=g.forwardRef(({color:r="currentColor",size:a=24,strokeWidth:i=2,absoluteStrokeWidth:o,className:d="",children:m,...f},p)=>g.createElement("svg",{ref:p,...EI,width:a,height:a,stroke:r,strokeWidth:o?Number(i)*24/Number(a):i,className:["lucide",`lucide-${_I(t)}`,d].join(" "),...f},[...s.map(([h,x])=>g.createElement(h,x)),...Array.isArray(m)?m:[m]]));return n.displayName=`${t}`,n};/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ad=gt("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const sn=gt("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ha=gt("AlertTriangle",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"c3ski4"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Jr=gt("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ko=gt("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const TI=gt("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const rk=gt("Award",[["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}],["path",{d:"M15.477 12.89 17 22l-5-3-5 3 1.523-9.11",key:"em7aur"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Jy=gt("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const PI=gt("Banknote",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const OI=gt("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Au=gt("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const S1=gt("Bike",[["circle",{cx:"18.5",cy:"17.5",r:"3.5",key:"15x4ox"}],["circle",{cx:"5.5",cy:"17.5",r:"3.5",key:"1noe27"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["path",{d:"M12 17.5V14l-3-3 4-3 2 3h2",key:"1npguv"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const so=gt("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const id=gt("Building",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ak=gt("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const dr=gt("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Zn=gt("CheckCircle2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const un=gt("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const LI=gt("CheckSquare",[["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}],["path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11",key:"1jnkn4"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Hn=gt("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Aa=gt("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const lo=gt("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const bi=gt("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const yu=gt("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const II=gt("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ik=gt("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const rc=gt("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const vn=gt("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const C1=gt("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Wu=gt("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ty=gt("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ji=gt("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const lk=gt("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const MI=gt("EyeOff",[["path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24",key:"1jxqfv"}],["path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68",key:"9wicm4"}],["path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61",key:"1jreej"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const yn=gt("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const A1=gt("FastForward",[["polygon",{points:"13 19 22 12 13 5 13 19",key:"587y9g"}],["polygon",{points:"2 19 11 12 2 5 2 19",key:"3pweh0"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const hu=gt("FileCheck",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const FI=gt("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ns=gt("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const BI=gt("FileX",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const af=gt("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const eb=gt("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $I=gt("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const qI=gt("Gavel",[["path",{d:"m14.5 12.5-8 8a2.119 2.119 0 1 1-3-3l8-8",key:"15492f"}],["path",{d:"m16 16 6-6",key:"vzrcl6"}],["path",{d:"m8 8 6-6",key:"18bi4p"}],["path",{d:"m9 7 8 8",key:"5jnvq1"}],["path",{d:"m21 11-8-8",key:"z4y7zo"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const sy=gt("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ku=gt("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const zI=gt("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ok=gt("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ck=gt("HelpCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const k1=gt("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const UI=gt("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ka=gt("IndianRupee",[["path",{d:"M6 3h12",key:"ggurg9"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"m6 13 8.5 8",key:"u1kupk"}],["path",{d:"M6 13h3",key:"wdp6ag"}],["path",{d:"M9 13c6.667 0 6.667-10 0-10",key:"1nkvk2"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const _a=gt("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const dk=gt("Landmark",[["line",{x1:"3",x2:"21",y1:"22",y2:"22",key:"j8o0r"}],["line",{x1:"6",x2:"6",y1:"18",y2:"11",key:"10tf0k"}],["line",{x1:"10",x2:"10",y1:"18",y2:"11",key:"54lgf6"}],["line",{x1:"14",x2:"14",y1:"18",y2:"11",key:"380y"}],["line",{x1:"18",x2:"18",y1:"18",y2:"11",key:"1kevvc"}],["polygon",{points:"12 2 20 7 4 7",key:"jkujk7"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const VI=gt("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const um=gt("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const HI=gt("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const uk=gt("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ns=gt("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ny=gt("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const WI=gt("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const hk=gt("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ur=gt("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Vr=gt("MapPin",[["path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z",key:"2oe9fu"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ga=gt("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const GI=gt("MoreHorizontal",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const mk=gt("Navigation",[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const bu=gt("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const KI=gt("PauseCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const D1=gt("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",key:"ymcmye"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Cr=gt("Pen",[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ry=gt("Pencil",[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const tb=gt("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 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",key:"foiqr5"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const xg=gt("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const An=gt("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ay=gt("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const hl=gt("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const xr=gt("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const YI=gt("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const sb=gt("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ml=gt("Save",[["path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z",key:"1owoqh"}],["polyline",{points:"17 21 17 13 7 13 7 21",key:"1md35c"}],["polyline",{points:"7 3 7 8 15 8",key:"8nz8an"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ta=gt("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Gu=gt("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ZI=gt("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Bf=gt("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Xc=gt("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const fk=gt("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const no=gt("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const hc=gt("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const QI=gt("ShoppingBag",[["path",{d:"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z",key:"hou9p0"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const XI=gt("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const JI=gt("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const eM=gt("Smile",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const tM=gt("Star",[["polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2",key:"8f66p6"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const sM=gt("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2v0a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12v0a2 2 0 0 1-2-2V7",key:"jon5kx"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const nM=gt("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ar=gt("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Yo=gt("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const dl=gt("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const rM=gt("Truck",[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const aM=gt("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5v0a5.5 5.5 0 0 1-5.5 5.5H11",key:"llx8ln"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const or=gt("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const iM=gt("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const lM=gt("UserCog",[["circle",{cx:"18",cy:"15",r:"3",key:"gjjjvw"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M10 15H6a4 4 0 0 0-4 4v2",key:"1nfge6"}],["path",{d:"m21.7 16.4-.9-.3",key:"12j9ji"}],["path",{d:"m15.2 13.9-.9-.3",key:"1fdjdi"}],["path",{d:"m16.6 18.7.3-.9",key:"heedtr"}],["path",{d:"m19.1 12.2.3-.9",key:"1af3ki"}],["path",{d:"m19.6 18.7-.4-1",key:"1x9vze"}],["path",{d:"m16.8 12.3-.4-1",key:"vqeiwj"}],["path",{d:"m14.3 16.6 1-.4",key:"1qlj63"}],["path",{d:"m20.7 13.8 1-.4",key:"1v5t8k"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const gg=gt("UserMinus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const nb=gt("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const vg=gt("UserX",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Lr=gt("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ra=gt("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const lf=gt("Wallet",[["path",{d:"M21 12V7H5a2 2 0 0 1 0-4h14v4",key:"195gfw"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h16v-5",key:"195n9w"}],["path",{d:"M18 12a2 2 0 0 0 0 4h4v-4Z",key:"vllfpd"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const mi=gt("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ld=gt("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
* @license lucide-react v0.344.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const R1=gt("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]);function Ln({className:t,...s}){return e.jsx(XA,{"data-slot":"checkbox",className:Nt("peer border bg-input-background dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(ek,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:e.jsx(Hn,{className:"size-3.5"})})})}var oM=t=>{switch(t){case"success":return uM;case"info":return mM;case"warning":return hM;case"error":return fM;default:return null}},cM=Array(12).fill(0),dM=({visible:t,className:s})=>wt.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},wt.createElement("div",{className:"sonner-spinner"},cM.map((n,r)=>wt.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),uM=wt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},wt.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),hM=wt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},wt.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),mM=wt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},wt.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),fM=wt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},wt.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),pM=wt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},wt.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),wt.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),xM=()=>{let[t,s]=wt.useState(document.hidden);return wt.useEffect(()=>{let n=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),t},iy=1,gM=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let s=this.subscribers.indexOf(t);this.subscribers.splice(s,1)}),this.publish=t=>{this.subscribers.forEach(s=>s(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var s;let{message:n,...r}=t,a=typeof(t==null?void 0:t.id)=="number"||((s=t.id)==null?void 0:s.length)>0?t.id:iy++,i=this.toasts.find(d=>d.id===a),o=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),i?this.toasts=this.toasts.map(d=>d.id===a?(this.publish({...d,...t,id:a,title:n}),{...d,...t,id:a,dismissible:o,title:n}):d):this.addToast({title:n,...r,dismissible:o,id:a}),a},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(s=>{this.subscribers.forEach(n=>n({id:s.id,dismiss:!0}))}),this.subscribers.forEach(s=>s({id:t,dismiss:!0})),t),this.message=(t,s)=>this.create({...s,message:t}),this.error=(t,s)=>this.create({...s,message:t,type:"error"}),this.success=(t,s)=>this.create({...s,type:"success",message:t}),this.info=(t,s)=>this.create({...s,type:"info",message:t}),this.warning=(t,s)=>this.create({...s,type:"warning",message:t}),this.loading=(t,s)=>this.create({...s,type:"loading",message:t}),this.promise=(t,s)=>{if(!s)return;let n;s.loading!==void 0&&(n=this.create({...s,promise:t,type:"loading",message:s.loading,description:typeof s.description!="function"?s.description:void 0}));let r=t instanceof Promise?t:t(),a=n!==void 0,i,o=r.then(async m=>{if(i=["resolve",m],wt.isValidElement(m))a=!1,this.create({id:n,type:"default",message:m});else if(yM(m)&&!m.ok){a=!1;let f=typeof s.error=="function"?await s.error(`HTTP error! status: ${m.status}`):s.error,p=typeof s.description=="function"?await s.description(`HTTP error! status: ${m.status}`):s.description;this.create({id:n,type:"error",message:f,description:p})}else if(s.success!==void 0){a=!1;let f=typeof s.success=="function"?await s.success(m):s.success,p=typeof s.description=="function"?await s.description(m):s.description;this.create({id:n,type:"success",message:f,description:p})}}).catch(async m=>{if(i=["reject",m],s.error!==void 0){a=!1;let f=typeof s.error=="function"?await s.error(m):s.error,p=typeof s.description=="function"?await s.description(m):s.description;this.create({id:n,type:"error",message:f,description:p})}}).finally(()=>{var m;a&&(this.dismiss(n),n=void 0),(m=s.finally)==null||m.call(s)}),d=()=>new Promise((m,f)=>o.then(()=>i[0]==="reject"?f(i[1]):m(i[1])).catch(f));return typeof n!="string"&&typeof n!="number"?{unwrap:d}:Object.assign(n,{unwrap:d})},this.custom=(t,s)=>{let n=(s==null?void 0:s.id)||iy++;return this.create({jsx:t(n),id:n,...s}),n},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},da=new gM,vM=(t,s)=>{let n=(s==null?void 0:s.id)||iy++;return da.addToast({title:t,...s,id:n}),n},yM=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",bM=vM,jM=()=>da.toasts,NM=()=>da.getActiveToasts(),te=Object.assign(bM,{success:da.success,info:da.info,warning:da.warning,error:da.error,custom:da.custom,message:da.message,promise:da.promise,dismiss:da.dismiss,loading:da.loading},{getHistory:jM,getToasts:NM});function wM(t,{insertAt:s}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",s==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}wM(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
`);function hm(t){return t.label!==void 0}var SM=3,CM="32px",AM="16px",E1=4e3,kM=356,DM=14,RM=20,EM=200;function ii(...t){return t.filter(Boolean).join(" ")}function _M(t){let[s,n]=t.split("-"),r=[];return s&&r.push(s),n&&r.push(n),r}var TM=t=>{var s,n,r,a,i,o,d,m,f,p,h;let{invert:x,toast:u,unstyled:N,interacting:v,setHeights:w,visibleToasts:j,heights:b,index:C,toasts:S,expanded:R,removeToast:_,defaultRichColors:A,closeButton:E,style:q,cancelButtonStyle:O,actionButtonStyle:D,className:P="",descriptionClassName:L="",duration:$,position:Y,gap:Z,loadingIcon:W,expandByDefault:U,classNames:M,icons:z,closeButtonAriaLabel:T="Close toast",pauseWhenPageIsHidden:I}=t,[B,G]=wt.useState(null),[K,H]=wt.useState(null),[X,J]=wt.useState(!1),[ae,le]=wt.useState(!1),[xe,ce]=wt.useState(!1),[ve,Pe]=wt.useState(!1),[et,kt]=wt.useState(!1),[vt,ee]=wt.useState(0),[ge,ye]=wt.useState(0),Be=wt.useRef(u.duration||$||E1),$e=wt.useRef(null),dt=wt.useRef(null),st=C===0,xt=C+1<=j,Mt=u.type,It=u.dismissible!==!1,he=u.className||"",pt=u.descriptionClassName||"",ht=wt.useMemo(()=>b.findIndex(ke=>ke.toastId===u.id)||0,[b,u.id]),_e=wt.useMemo(()=>{var ke;return(ke=u.closeButton)!=null?ke:E},[u.closeButton,E]),Vt=wt.useMemo(()=>u.duration||$||E1,[u.duration,$]),Pt=wt.useRef(0),_s=wt.useRef(0),Ys=wt.useRef(0),Bs=wt.useRef(null),[Ks,Qs]=Y.split("-"),Xs=wt.useMemo(()=>b.reduce((ke,je,Ve)=>Ve>=ht?ke:ke+je.height,0),[b,ht]),$s=xM(),Q=u.invert||x,oe=Mt==="loading";_s.current=wt.useMemo(()=>ht*Z+Xs,[ht,Xs]),wt.useEffect(()=>{Be.current=Vt},[Vt]),wt.useEffect(()=>{J(!0)},[]),wt.useEffect(()=>{let ke=dt.current;if(ke){let je=ke.getBoundingClientRect().height;return ye(je),w(Ve=>[{toastId:u.id,height:je,position:u.position},...Ve]),()=>w(Ve=>Ve.filter(Ge=>Ge.toastId!==u.id))}},[w,u.id]),wt.useLayoutEffect(()=>{if(!X)return;let ke=dt.current,je=ke.style.height;ke.style.height="auto";let Ve=ke.getBoundingClientRect().height;ke.style.height=je,ye(Ve),w(Ge=>Ge.find(nt=>nt.toastId===u.id)?Ge.map(nt=>nt.toastId===u.id?{...nt,height:Ve}:nt):[{toastId:u.id,height:Ve,position:u.position},...Ge])},[X,u.title,u.description,w,u.id]);let we=wt.useCallback(()=>{le(!0),ee(_s.current),w(ke=>ke.filter(je=>je.toastId!==u.id)),setTimeout(()=>{_(u)},EM)},[u,_,w,_s]);wt.useEffect(()=>{if(u.promise&&Mt==="loading"||u.duration===1/0||u.type==="loading")return;let ke;return R||v||I&&$s?(()=>{if(Ys.current<Pt.current){let je=new Date().getTime()-Pt.current;Be.current=Be.current-je}Ys.current=new Date().getTime()})():Be.current!==1/0&&(Pt.current=new Date().getTime(),ke=setTimeout(()=>{var je;(je=u.onAutoClose)==null||je.call(u,u),we()},Be.current)),()=>clearTimeout(ke)},[R,v,u,Mt,I,$s,we]),wt.useEffect(()=>{u.delete&&we()},[we,u.delete]);function Oe(){var ke,je,Ve;return z!=null&&z.loading?wt.createElement("div",{className:ii(M==null?void 0:M.loader,(ke=u==null?void 0:u.classNames)==null?void 0:ke.loader,"sonner-loader"),"data-visible":Mt==="loading"},z.loading):W?wt.createElement("div",{className:ii(M==null?void 0:M.loader,(je=u==null?void 0:u.classNames)==null?void 0:je.loader,"sonner-loader"),"data-visible":Mt==="loading"},W):wt.createElement(dM,{className:ii(M==null?void 0:M.loader,(Ve=u==null?void 0:u.classNames)==null?void 0:Ve.loader),visible:Mt==="loading"})}return wt.createElement("li",{tabIndex:0,ref:dt,className:ii(P,he,M==null?void 0:M.toast,(s=u==null?void 0:u.classNames)==null?void 0:s.toast,M==null?void 0:M.default,M==null?void 0:M[Mt],(n=u==null?void 0:u.classNames)==null?void 0:n[Mt]),"data-sonner-toast":"","data-rich-colors":(r=u.richColors)!=null?r:A,"data-styled":!(u.jsx||u.unstyled||N),"data-mounted":X,"data-promise":!!u.promise,"data-swiped":et,"data-removed":ae,"data-visible":xt,"data-y-position":Ks,"data-x-position":Qs,"data-index":C,"data-front":st,"data-swiping":xe,"data-dismissible":It,"data-type":Mt,"data-invert":Q,"data-swipe-out":ve,"data-swipe-direction":K,"data-expanded":!!(R||U&&X),style:{"--index":C,"--toasts-before":C,"--z-index":S.length-C,"--offset":`${ae?vt:_s.current}px`,"--initial-height":U?"auto":`${ge}px`,...q,...u.style},onDragEnd:()=>{ce(!1),G(null),Bs.current=null},onPointerDown:ke=>{oe||!It||($e.current=new Date,ee(_s.current),ke.target.setPointerCapture(ke.pointerId),ke.target.tagName!=="BUTTON"&&(ce(!0),Bs.current={x:ke.clientX,y:ke.clientY}))},onPointerUp:()=>{var ke,je,Ve,Ge;if(ve||!It)return;Bs.current=null;let nt=Number(((ke=dt.current)==null?void 0:ke.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Zt=Number(((je=dt.current)==null?void 0:je.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Jt=new Date().getTime()-((Ve=$e.current)==null?void 0:Ve.getTime()),lt=B==="x"?nt:Zt,mt=Math.abs(lt)/Jt;if(Math.abs(lt)>=RM||mt>.11){ee(_s.current),(Ge=u.onDismiss)==null||Ge.call(u,u),H(B==="x"?nt>0?"right":"left":Zt>0?"down":"up"),we(),Pe(!0),kt(!1);return}ce(!1),G(null)},onPointerMove:ke=>{var je,Ve,Ge,nt;if(!Bs.current||!It||((je=window.getSelection())==null?void 0:je.toString().length)>0)return;let Zt=ke.clientY-Bs.current.y,Jt=ke.clientX-Bs.current.x,lt=(Ve=t.swipeDirections)!=null?Ve:_M(Y);!B&&(Math.abs(Jt)>1||Math.abs(Zt)>1)&&G(Math.abs(Jt)>Math.abs(Zt)?"x":"y");let mt={x:0,y:0};B==="y"?(lt.includes("top")||lt.includes("bottom"))&&(lt.includes("top")&&Zt<0||lt.includes("bottom")&&Zt>0)&&(mt.y=Zt):B==="x"&&(lt.includes("left")||lt.includes("right"))&&(lt.includes("left")&&Jt<0||lt.includes("right")&&Jt>0)&&(mt.x=Jt),(Math.abs(mt.x)>0||Math.abs(mt.y)>0)&&kt(!0),(Ge=dt.current)==null||Ge.style.setProperty("--swipe-amount-x",`${mt.x}px`),(nt=dt.current)==null||nt.style.setProperty("--swipe-amount-y",`${mt.y}px`)}},_e&&!u.jsx?wt.createElement("button",{"aria-label":T,"data-disabled":oe,"data-close-button":!0,onClick:oe||!It?()=>{}:()=>{var ke;we(),(ke=u.onDismiss)==null||ke.call(u,u)},className:ii(M==null?void 0:M.closeButton,(a=u==null?void 0:u.classNames)==null?void 0:a.closeButton)},(i=z==null?void 0:z.close)!=null?i:pM):null,u.jsx||g.isValidElement(u.title)?u.jsx?u.jsx:typeof u.title=="function"?u.title():u.title:wt.createElement(wt.Fragment,null,Mt||u.icon||u.promise?wt.createElement("div",{"data-icon":"",className:ii(M==null?void 0:M.icon,(o=u==null?void 0:u.classNames)==null?void 0:o.icon)},u.promise||u.type==="loading"&&!u.icon?u.icon||Oe():null,u.type!=="loading"?u.icon||(z==null?void 0:z[Mt])||oM(Mt):null):null,wt.createElement("div",{"data-content":"",className:ii(M==null?void 0:M.content,(d=u==null?void 0:u.classNames)==null?void 0:d.content)},wt.createElement("div",{"data-title":"",className:ii(M==null?void 0:M.title,(m=u==null?void 0:u.classNames)==null?void 0:m.title)},typeof u.title=="function"?u.title():u.title),u.description?wt.createElement("div",{"data-description":"",className:ii(L,pt,M==null?void 0:M.description,(f=u==null?void 0:u.classNames)==null?void 0:f.description)},typeof u.description=="function"?u.description():u.description):null),g.isValidElement(u.cancel)?u.cancel:u.cancel&&hm(u.cancel)?wt.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||O,onClick:ke=>{var je,Ve;hm(u.cancel)&&It&&((Ve=(je=u.cancel).onClick)==null||Ve.call(je,ke),we())},className:ii(M==null?void 0:M.cancelButton,(p=u==null?void 0:u.classNames)==null?void 0:p.cancelButton)},u.cancel.label):null,g.isValidElement(u.action)?u.action:u.action&&hm(u.action)?wt.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||D,onClick:ke=>{var je,Ve;hm(u.action)&&((Ve=(je=u.action).onClick)==null||Ve.call(je,ke),!ke.defaultPrevented&&we())},className:ii(M==null?void 0:M.actionButton,(h=u==null?void 0:u.classNames)==null?void 0:h.actionButton)},u.action.label):null))};function _1(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function PM(t,s){let n={};return[t,s].forEach((r,a)=>{let i=a===1,o=i?"--mobile-offset":"--offset",d=i?AM:CM;function m(f){["top","right","bottom","left"].forEach(p=>{n[`${o}-${p}`]=typeof f=="number"?`${f}px`:f})}typeof r=="number"||typeof r=="string"?m(r):typeof r=="object"?["top","right","bottom","left"].forEach(f=>{r[f]===void 0?n[`${o}-${f}`]=d:n[`${o}-${f}`]=typeof r[f]=="number"?`${r[f]}px`:r[f]}):m(d)}),n}var OM=g.forwardRef(function(t,s){let{invert:n,position:r="bottom-right",hotkey:a=["altKey","KeyT"],expand:i,closeButton:o,className:d,offset:m,mobileOffset:f,theme:p="light",richColors:h,duration:x,style:u,visibleToasts:N=SM,toastOptions:v,dir:w=_1(),gap:j=DM,loadingIcon:b,icons:C,containerAriaLabel:S="Notifications",pauseWhenPageIsHidden:R}=t,[_,A]=wt.useState([]),E=wt.useMemo(()=>Array.from(new Set([r].concat(_.filter(I=>I.position).map(I=>I.position)))),[_,r]),[q,O]=wt.useState([]),[D,P]=wt.useState(!1),[L,$]=wt.useState(!1),[Y,Z]=wt.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),W=wt.useRef(null),U=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),M=wt.useRef(null),z=wt.useRef(!1),T=wt.useCallback(I=>{A(B=>{var G;return(G=B.find(K=>K.id===I.id))!=null&&G.delete||da.dismiss(I.id),B.filter(({id:K})=>K!==I.id)})},[]);return wt.useEffect(()=>da.subscribe(I=>{if(I.dismiss){A(B=>B.map(G=>G.id===I.id?{...G,delete:!0}:G));return}setTimeout(()=>{Hy.flushSync(()=>{A(B=>{let G=B.findIndex(K=>K.id===I.id);return G!==-1?[...B.slice(0,G),{...B[G],...I},...B.slice(G+1)]:[I,...B]})})})}),[]),wt.useEffect(()=>{if(p!=="system"){Z(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Z("dark"):Z("light")),typeof window>"u")return;let I=window.matchMedia("(prefers-color-scheme: dark)");try{I.addEventListener("change",({matches:B})=>{Z(B?"dark":"light")})}catch{I.addListener(({matches:G})=>{try{Z(G?"dark":"light")}catch(K){console.error(K)}})}},[p]),wt.useEffect(()=>{_.length<=1&&P(!1)},[_]),wt.useEffect(()=>{let I=B=>{var G,K;a.every(H=>B[H]||B.code===H)&&(P(!0),(G=W.current)==null||G.focus()),B.code==="Escape"&&(document.activeElement===W.current||(K=W.current)!=null&&K.contains(document.activeElement))&&P(!1)};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[a]),wt.useEffect(()=>{if(W.current)return()=>{M.current&&(M.current.focus({preventScroll:!0}),M.current=null,z.current=!1)}},[W.current]),wt.createElement("section",{ref:s,"aria-label":`${S} ${U}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},E.map((I,B)=>{var G;let[K,H]=I.split("-");return _.length?wt.createElement("ol",{key:I,dir:w==="auto"?_1():w,tabIndex:-1,ref:W,className:d,"data-sonner-toaster":!0,"data-theme":Y,"data-y-position":K,"data-lifted":D&&_.length>1&&!i,"data-x-position":H,style:{"--front-toast-height":`${((G=q[0])==null?void 0:G.height)||0}px`,"--width":`${kM}px`,"--gap":`${j}px`,...u,...PM(m,f)},onBlur:X=>{z.current&&!X.currentTarget.contains(X.relatedTarget)&&(z.current=!1,M.current&&(M.current.focus({preventScroll:!0}),M.current=null))},onFocus:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||z.current||(z.current=!0,M.current=X.relatedTarget)},onMouseEnter:()=>P(!0),onMouseMove:()=>P(!0),onMouseLeave:()=>{L||P(!1)},onDragEnd:()=>P(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||$(!0)},onPointerUp:()=>$(!1)},_.filter(X=>!X.position&&B===0||X.position===I).map((X,J)=>{var ae,le;return wt.createElement(TM,{key:X.id,icons:C,index:J,toast:X,defaultRichColors:h,duration:(ae=v==null?void 0:v.duration)!=null?ae:x,className:v==null?void 0:v.className,descriptionClassName:v==null?void 0:v.descriptionClassName,invert:n,visibleToasts:N,closeButton:(le=v==null?void 0:v.closeButton)!=null?le:o,interacting:L,position:I,style:v==null?void 0:v.style,unstyled:v==null?void 0:v.unstyled,classNames:v==null?void 0:v.classNames,cancelButtonStyle:v==null?void 0:v.cancelButtonStyle,actionButtonStyle:v==null?void 0:v.actionButtonStyle,removeToast:T,toasts:_.filter(xe=>xe.position==X.position),heights:q.filter(xe=>xe.position==X.position),setHeights:O,expandByDefault:i,gap:j,loadingIcon:b,expanded:D,pauseWhenPageIsHidden:R,swipeDirections:t.swipeDirections})})):null}))});const hs={submitApplication:async t=>{var n;const s=await Ee.submitApplication(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to submit application");return s.data},getApplications:async t=>{var n;const s=await Ee.getApplications(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch applications");return s.data},shortlistApplications:async(t,s,n)=>{var a;const r=await Ee.shortlistApplications({applicationIds:t,assignedTo:s,remarks:n});if(!r.ok)throw new Error(((a=r.data)==null?void 0:a.message)||"Failed to shortlist applications");return r.data},getApplicationById:async t=>{var n,r;const s=await Ee.getApplicationById(t);if(!s.ok)throw console.error("API Error Response:",s.status,s.data),new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch application details");return((r=s.data)==null?void 0:r.data)||s.data},getUsers:async t=>{var n,r;const s=await Ee.getUsers(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch users");return((r=s.data)==null?void 0:r.data)||s.data},addParticipant:async t=>{var n;const s=await Ee.addParticipant(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to add participant");return s.data},scheduleInterview:async t=>{var n;const s=await Ee.scheduleInterview(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to schedule interview");return s.data},updateInterview:async(t,s)=>{var r;const n=await Ee.updateInterview(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to update interview");return n.data},getInterviews:async t=>{var r,a;const s=await Ee.getInterviews(t);if(!s.ok)throw new Error(((r=s.data)==null?void 0:r.message)||"Failed to fetch interviews");const n=((a=s.data)==null?void 0:a.data)||s.data;return Array.isArray(n)?n:[]},getDocuments:async t=>{var n,r;const s=await Ee.getDocuments(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch documents");return((r=s.data)==null?void 0:r.data)||s.data},uploadDocument:async(t,s)=>{var r;const n=await Ee.uploadDocument(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to upload document");return n.data},submitKTMatrix:async t=>{var n;const s=await Ee.submitKTMatrix(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to submit KT Matrix");return s.data},submitLevel2Feedback:async t=>{var n;const s=await Ee.submitLevel2Feedback(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to submit feedback");return s.data},updateRecommendation:async t=>{var n;const s=await Ee.updateRecommendation(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to update recommendation");return s.data},submitStageDecision:async t=>{var n;const s=await Ee.submitStageDecision(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to process stage decision");return s.data},updateInterviewDecision:async t=>{var n;const s=await Ee.updateInterviewDecision(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to update interview decision");return s.data},assignArchitectureTeam:async(t,s)=>{var r;const n=await Ee.assignArchitectureTeam(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to assign architecture team");return n.data},updateArchitectureStatus:async(t,s,n)=>{var a;const r=await Ee.updateArchitectureStatus(t,s,n);if(!r.ok)throw new Error(((a=r.data)==null?void 0:a.message)||"Failed to update architecture status");return r.data},generateDealerCodes:async t=>{var n;const s=await Ee.generateDealerCodes(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to generate dealer codes");return s.data},updateApplicationStatus:async(t,s)=>{var r;const n=await Ee.updateApplicationStatus(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to update application status");return n.data},convertToOpportunity:async(t,s)=>{var r;const n=await Ee.convertToOpportunity(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to convert application to opportunity");return n.data},bulkConvertToOpportunity:async t=>{var n;const s=await Ee.bulkConvertToOpportunity(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to perform bulk conversion");return s.data},sendBulkReminders:async t=>{var n;const s=await Ee.sendBulkReminders({applicationIds:t});if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to send reminders");return s.data},createDealer:async t=>{var n;const s=await Ee.createDealer(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to create dealer profile");return s.data},retriggerEvaluators:async t=>{var n;const s=await Ee.retriggerEvaluators(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to retrigger evaluators");return s.data},getSecurityDeposit:async t=>{var n,r;const s=await Ee.getSecurityDeposit(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch Security Deposit");return((r=s.data)==null?void 0:r.data)||s.data},updateSecurityDeposit:async t=>{var n;const s=await Ee.updateSecurityDeposit(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to update Security Deposit");return s.data},getSystemConfigs:async t=>{var n,r;const s=await Ee.getSystemConfigs(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch system configurations");return((r=s.data)==null?void 0:r.data)||s.data},getDocumentConfigMetadata:async()=>{var s,n;const t=await Ee.getDocumentConfigMetadata();if(!t.ok)throw new Error(((s=t.data)==null?void 0:s.message)||"Failed to fetch metadata");return((n=t.data)==null?void 0:n.data)||t.data},getDocumentConfigs:async t=>{var n;const s=await Ee.getDocumentConfigs(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch document configurations");return s.data},createDocumentConfig:async t=>{var n,r;const s=await Ee.createDocumentConfig(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to create document configuration");return((r=s.data)==null?void 0:r.data)||s.data},updateDocumentConfig:async(t,s)=>{var r,a;const n=await Ee.updateDocumentConfig(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to update document configuration");return((a=n.data)==null?void 0:a.data)||n.data},deleteDocumentConfig:async t=>{var n;const s=await Ee.deleteDocumentConfig(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to delete document configuration");return s.data},updateApplication:async(t,s)=>{var r;const n=await Ee.updateApplication(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to update application");return n.data},submitFddReport:async t=>{var n;const s=await Ee.submitFddReport(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to submit FDD report");return s.data},getFddAssignment:async t=>{var n;const s=await Ee.getFddAssignment(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch FDD assignment");return s.data},assignFddAgency:async t=>{var n;const s=await Ee.assignFddAgency(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to assign FDD agency");return s.data},exportResponses:async t=>{var n,r;const s=await Ee.exportApplicationResponses({applicationIds:t.join(",")});if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to export responses");return((r=s.data)==null?void 0:r.data)||[]}},Is={getRoles:async()=>(await Ee.getRoles()).data,getPermissions:async()=>(await Ee.getPermissions()).data,updateRole:async(t,s)=>(await Ee.updateRole(t,s)).data,createRole:async t=>(await Ee.createRole(t)).data,getZones:async()=>(await Ee.getZones()).data,updateZone:async(t,s)=>(await Ee.updateZone(t,s)).data,createZone:async t=>(await Ee.createZone(t)).data,createRegion:async t=>(await Ee.createRegion(t)).data,updateRegion:async(t,s)=>(await Ee.updateRegion(t,s)).data,getRegions:async()=>(await Ee.getRegions()).data,getStates:async t=>(await Ee.getStates(t)).data,getDistricts:async t=>{const s=typeof t=="string"?{stateId:t,limit:"all"}:{limit:"all",...t};return(await Ee.getDistricts(s)).data},getAreas:async t=>(await Ee.getAreas(t)).data,updateArea:async(t,s)=>(await Ee.updateArea(t,s)).data,createArea:async t=>(await Ee.createArea(t)).data,deleteArea:async t=>(await Ee.deleteArea(t)).data,getAreaManagers:async()=>(await Ee.getAreaManagers()).data,getASMs:async()=>(await Ee.getASMs()).data,getZonalManagers:async()=>(await Ee.getZonalManagers()).data,saveZonalManager:async t=>Ee.saveZonalManager(t).then(s=>s.data),getDDLeads:async()=>(await Ee.getDDLeads()).data,saveDDLead:async t=>Ee.saveDDLead(t).then(s=>s.data),getUsers:async()=>(await Ee.getUsers()).data,updateUser:async(t,s)=>(await Ee.updateUser(t,s)).data,getEmailTemplates:async()=>(await Ee.getEmailTemplates()).data,getEmailTemplate:async t=>(await Ee.getEmailTemplate(t)).data,createEmailTemplate:async t=>(await Ee.createEmailTemplate(t)).data,updateEmailTemplate:async(t,s)=>(await Ee.updateEmailTemplate(t,s)).data,deleteEmailTemplate:async t=>(await Ee.deleteEmailTemplate(t)).data,previewEmailTemplate:async t=>(await Ee.previewEmailTemplate(t)).data,getSlaConfigs:async()=>(await Ee.getSlaConfigs()).data,saveSlaConfig:async t=>(await Ee.saveSlaConfig(t)).data,initializeDefaultSlas:async()=>(await Ee.initializeDefaultSlas()).data,saveZone:async t=>t.id?Is.updateZone(t.id,t):Is.createZone(t),saveRegion:async t=>t.id?Is.updateRegion(t.id,t):Is.createRegion(t),saveASM:async t=>Ee.updateUser(t.userId,t).then(s=>s.data),getSystemConfigs:async t=>(await Ee.getSystemConfigs(t)).data,saveSystemConfig:async t=>(await Ee.saveSystemConfig(t)).data,getDealerAsmMappings:async()=>(await Ee.getDealerAsmMappings()).data,saveDealerAsmMapping:async t=>(await Ee.saveDealerAsmMapping(t)).data};function LM({onAdminLogin:t}){const[s,n]=g.useState({country:"India",stateId:"",districtId:"",name:"",interestedCity:"",email:"",pincode:"",mobile:"",ownRoyalEnfield:"",royalEnfieldModel:"",age:"",education:"",companyName:"",source:"",existingDealer:"",description:"",address:"",acceptTerms:!1}),[r,a]=g.useState(!1),[i,o]=g.useState([]),[d,m]=g.useState([]);g.useEffect(()=>{f()},[]);const f=async()=>{try{const C=await Is.getStates(),S=Array.isArray(C)?C:(C==null?void 0:C.data)||(C==null?void 0:C.states)||[];o(S)}catch(C){console.error("Error fetching states:",C)}},p=async C=>{if(C){n(S=>({...S,stateId:C,districtId:""})),m([]);try{const S=await Is.getDistricts(C),R=Array.isArray(S)?S:(S==null?void 0:S.data)||(S==null?void 0:S.districts)||[];m(R)}catch(S){console.error("Error fetching districts:",S)}}},h=C=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(C),x=C=>/^[0-9]{10}$/.test(C),u=C=>/^[0-9]{6}$/.test(C),N=!!(s.country&&s.stateId&&s.districtId&&s.name&&s.interestedCity&&s.email&&s.pincode&&s.mobile&&s.ownRoyalEnfield&&s.age&&s.education&&s.companyName&&s.source&&s.existingDealer&&s.description&&s.address&&s.acceptTerms&&r&&h(s.email)&&x(s.mobile)&&u(s.pincode)&&(s.ownRoyalEnfield==="no"||s.ownRoyalEnfield==="yes"&&s.royalEnfieldModel)),v=()=>{if(!s.mobile||s.mobile.length<10){te.error("Please enter a valid mobile number");return}te.success("OTP sent to "+s.mobile),setTimeout(()=>{a(!0),te.success("Mobile number verified")},1500)},w=async C=>{var S,R;if(C.preventDefault(),!s.country||!s.stateId||!s.districtId||!s.name||!s.interestedCity||!s.email||!s.pincode||!s.mobile||!s.ownRoyalEnfield||!s.age||!s.education||!s.companyName||!s.source||!s.existingDealer||!s.description||!s.address){te.error("Please fill in all required fields");return}if(!r){te.error("Please verify your mobile number");return}if(s.ownRoyalEnfield==="yes"&&!s.royalEnfieldModel){te.error("Please select your motorcycle model");return}if(!s.acceptTerms){te.error("Please accept the terms and conditions");return}try{const _=i.find(D=>D.id===s.stateId),A=d.find(D=>D.id===s.districtId),E=(_==null?void 0:_.name)||(_==null?void 0:_.stateName)||"",q=(A==null?void 0:A.name)||(A==null?void 0:A.districtName)||"",O={applicantName:s.name,email:s.email,phone:s.mobile,state:E,city:s.interestedCity,district:q,preferredLocation:`${s.interestedCity}, ${E}`,businessType:"Dealership",locationType:"district",locationId:s.districtId,address:s.address,pincode:s.pincode,age:s.age,education:s.education,companyName:s.companyName,source:s.source,existingDealer:s.existingDealer==="yes",ownRoyalEnfield:s.ownRoyalEnfield==="yes",royalEnfieldModel:s.royalEnfieldModel,description:s.description,experienceYears:0,investmentCapacity:"Unknown"};await hs.submitApplication(O),te.success("Application submitted successfully"),n({country:"India",stateId:"",districtId:"",name:"",interestedCity:"",email:"",pincode:"",mobile:"",ownRoyalEnfield:"",royalEnfieldModel:"",age:"",education:"",companyName:"",source:"",existingDealer:"",description:"",address:"",acceptTerms:!1}),a(!1)}catch(_){te.error(((R=(S=_.response)==null?void 0:S.data)==null?void 0:R.message)||"Failed to submit application.")}},j=["Continental GT","Interceptor 650","Himalayan","Classic 350","Classic 500","Thunderbird 350","Thunderbird 500","Thunderbird X 350","Thunderbird X 500","Bullet 350","Bullet 500","Bullet ES","Bullet Trials 350","Bullet Trials 500","Other Royal Enfield motorcycle"],b=["Existing RE dealer","Customer","RE Employee","News Paper","Website","Friends","Others"];return e.jsxs("div",{className:"min-h-screen relative flex flex-col",children:[e.jsxs("div",{className:"fixed inset-0 z-0",children:[e.jsx("img",{src:"/assets/images/become_a_dealer.webp",alt:"Royal Enfield Background",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/20"})]}),e.jsxs("nav",{className:"relative z-10 bg-black px-6 md:px-12 py-4 flex items-center justify-between border-b border-white/10",children:[e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"h-10 md:h-12 w-auto"}),e.jsxs(se,{variant:"ghost",onClick:t,className:"text-[10px] uppercase tracking-widest font-bold text-slate-400 hover:text-white transition-colors",children:[e.jsx(WI,{className:"w-3.5 h-3.5 mr-2"}),"Login"]})]}),e.jsx("main",{className:"relative z-10 flex-grow flex flex-col items-center pt-24 pb-24 px-6",children:e.jsxs("div",{className:"w-full max-w-[1240px] bg-white shadow-2xl p-8 md:p-16",children:[e.jsxs("section",{className:"text-[#333333] mb-12",children:[e.jsx("h1",{className:"text-[28px] font-bold mb-8 uppercase tracking-wide text-black",children:"Become a Dealer"}),e.jsxs("div",{className:"space-y-6 text-[15px] leading-relaxed",children:[e.jsx("p",{children:"At Royal Enfield, we endeavour to partner our patrons and customers in their journeys of exploration. Our main objective is to provide an immersive brand and retail experience in addition to ensuring a superior product experience. Our dealers, distributors and network teams are our extended partners in this task."}),e.jsx("p",{children:"Royal Enfield employs a comprehensive and professional process for Dealership allotment. Dealer selection is done based on a variety of criteria including a personal meeting with the applicant. It is only post completion of the evaluation and selection process, that other formalities are considered."}),e.jsx("p",{children:"Royal Enfield does not accept or demand money / deposits from prospective partners prior to processing the application or candidature of the Dealership."}),e.jsxs("p",{children:["If you receive any communication offering allotment of Royal Enfield Dealership against payment / transfer of money and / or otherwise, we advise you to seek information / clarifications by writing to us at ",e.jsx("b",{children:e.jsx("a",{href:"mailto:support@royalenfield.com",className:"text-red-600",children:"support@royalenfield.com"})})," or by contacting us on our customer care toll-free number ",e.jsx("b",{children:e.jsx("a",{href:"tel:18002100008",className:"text-red-600",children:"1800 210 0008"})}),"."]}),e.jsx("p",{className:"font-bold py-1 mt-8 text-black text-[15px]",children:"*This is the ONLY official website and central number for dealership enquiries for Royal Enfield and we do not have any other partner website(s)."})]})]}),e.jsxs("form",{onSubmit:w,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("select",{className:"w-full h-[44px] px-4 border border-[#cccccc] appearance-none bg-white text-[14px] outline-none",value:s.country,onChange:C=>n({...s,country:C.target.value}),children:[e.jsx("option",{value:"India",children:"India"}),e.jsx("option",{value:"Other",children:"Others"})]}),e.jsx(Aa,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{className:"w-full h-[44px] px-4 border border-[#cccccc] appearance-none bg-white text-[14px] outline-none",value:s.stateId,onChange:C=>p(C.target.value),children:[e.jsx("option",{value:"",children:"Select State*"}),i.map(C=>e.jsx("option",{value:C.id,children:C.name||C.stateName},C.id))]}),e.jsx(Aa,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{className:"w-full h-[44px] px-4 border border-[#cccccc] appearance-none bg-white text-[14px] outline-none",value:s.districtId,onChange:C=>n({...s,districtId:C.target.value}),children:[e.jsx("option",{value:"",children:"Select District*"}),d.map(C=>e.jsx("option",{value:C.id,children:C.name||C.districtName},C.id))]}),e.jsx(Aa,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-x-10 gap-y-6",children:[e.jsx(at,{placeholder:"Name*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.name,onChange:C=>n({...s,name:C.target.value})}),e.jsx(at,{placeholder:"Interested city for Dealership*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.interestedCity,onChange:C=>n({...s,interestedCity:C.target.value})}),e.jsx(at,{type:"email",placeholder:"Email Id*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.email,onChange:C=>n({...s,email:C.target.value})}),e.jsx(at,{type:"text",maxLength:6,placeholder:"Pincode*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.pincode,onChange:C=>{const S=C.target.value.replace(/\D/g,"");n({...s,pincode:S})}}),e.jsxs("div",{className:"relative",children:[e.jsx(at,{type:"text",maxLength:10,placeholder:"Mobile No.*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.mobile,onChange:C=>{const S=C.target.value.replace(/\D/g,"");n({...s,mobile:S})}}),r?e.jsx("span",{className:"absolute right-4 top-1/2 -translate-y-1/2 text-[12px] font-bold text-green-600",children:"Verified"}):e.jsx("button",{type:"button",onClick:v,className:"absolute right-4 top-1/2 -translate-y-1/2 text-[12px] font-bold text-red-600 hover:text-black transition-colors",children:"Verify"})]}),e.jsxs("div",{className:"flex items-center gap-10 h-[44px]",children:[e.jsxs("span",{className:"text-[14px] font-medium text-[#333333]",children:["Own a Royal Enfield? ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"flex gap-8",children:["yes","no"].map(C=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("div",{className:`w-5 h-5 rounded-full border flex items-center justify-center ${s.ownRoyalEnfield===C?"border-red-600":"border-[#cccccc]"}`,children:s.ownRoyalEnfield===C&&e.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-600"})}),e.jsx("input",{type:"radio",className:"hidden",checked:s.ownRoyalEnfield===C,onChange:()=>{n({...s,ownRoyalEnfield:C,royalEnfieldModel:C==="no"?"":s.royalEnfieldModel})}}),e.jsx("span",{className:"text-[14px] capitalize",children:C})]},C))})]}),e.jsx(at,{placeholder:"Age*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.age,onChange:C=>n({...s,age:C.target.value})}),s.ownRoyalEnfield==="yes"&&e.jsxs("div",{className:"relative",children:[e.jsxs("select",{className:"w-full h-[44px] px-4 border border-[#cccccc] appearance-none bg-white text-[14px] outline-none",value:s.royalEnfieldModel,onChange:C=>n({...s,royalEnfieldModel:C.target.value}),children:[e.jsx("option",{value:"",children:"Select Motorcycle*"}),j.map(C=>e.jsx("option",{value:C,children:C},C))]}),e.jsx(Aa,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"})]}),e.jsx(at,{placeholder:"Education Qualification*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.education,onChange:C=>n({...s,education:C.target.value})}),e.jsx(at,{placeholder:"Company Name*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.companyName,onChange:C=>n({...s,companyName:C.target.value})}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{className:"w-full h-[44px] px-4 border border-[#cccccc] appearance-none bg-white text-[14px] outline-none",value:s.source,onChange:C=>n({...s,source:C.target.value}),children:[e.jsx("option",{value:"",children:"Select Source*"}),b.map(C=>e.jsx("option",{value:C,children:C},C))]}),e.jsx(Aa,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"})]}),e.jsxs("div",{className:"flex flex-col justify-center h-auto min-h-[44px] space-y-1",children:[e.jsxs("span",{className:"text-[13px] font-medium text-[#333333]",children:["Are you an existing Dealer / Vendor of Royal Enfield? ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"flex gap-8",children:["yes","no"].map(C=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("div",{className:`w-5 h-5 rounded-full border flex items-center justify-center ${s.existingDealer===C?"border-red-600":"border-[#cccccc]"}`,children:s.existingDealer===C&&e.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-600"})}),e.jsx("input",{type:"radio",className:"hidden",checked:s.existingDealer===C,onChange:()=>n({...s,existingDealer:C})}),e.jsx("span",{className:"text-[14px] capitalize",children:C})]},C))})]})]}),e.jsxs("div",{className:"space-y-6 pt-4",children:[e.jsx(Ws,{placeholder:"Description*",className:"min-h-[120px] border-[#cccccc] rounded-none px-4 py-3 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999] resize-none",value:s.description,onChange:C=>n({...s,description:C.target.value})}),e.jsx(Ws,{placeholder:"Address*",className:"min-h-[120px] border-[#cccccc] rounded-none px-4 py-3 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999] resize-none",value:s.address,onChange:C=>n({...s,address:C.target.value})})]}),e.jsxs("div",{className:"pt-6 space-y-8",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("p",{className:"text-[14px] text-[#666666] leading-relaxed",children:["Disclaimer: By signing this form/checking this box, you acknowledge and agree that we may use the information you share with us, to communicate with you through e-mails, text messages, WhatsApp and calls, in order to provide our product or service related information and/or for promotional and marketing purposes. All information provided will be secured and processed as per our ",e.jsx("b",{children:"privacy policy"}),"."]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ln,{id:"terms",className:"w-5 h-5 border-[#cccccc] rounded-none data-[state=checked]:bg-black data-[state=checked]:border-black",checked:s.acceptTerms,onCheckedChange:C=>n({...s,acceptTerms:C})}),e.jsxs("label",{htmlFor:"terms",className:"text-[14px] font-medium cursor-pointer",children:["I accept the ",e.jsx("b",{children:"terms and conditions"})," as well as ",e.jsx("b",{children:"privacy policy"}),".",e.jsx("span",{className:"text-red-500",children:"*"})]})]})]}),e.jsxs("button",{type:"submit",disabled:!N,className:"h-12 px-10 bg-black text-white flex items-center gap-3 hover:bg-slate-900 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("span",{className:"font-bold uppercase tracking-wider text-[14px]",children:"Submit"}),e.jsx(bi,{className:"w-4 h-4"})]})]})]})]})}),e.jsx("footer",{className:"relative z-10 bg-black py-16",children:e.jsxs("div",{className:"max-w-[1240px] mx-auto px-6 grid grid-cols-1 md:grid-cols-3 items-center gap-8",children:[e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"h-10 w-auto opacity-100"}),e.jsxs("div",{className:"flex justify-center gap-12 text-[10px] font-bold uppercase tracking-widest text-slate-500",children:[e.jsx("a",{href:"#",className:"hover:text-white transition-all",children:"Legal"}),e.jsx("a",{href:"#",className:"hover:text-white transition-all",children:"Privacy"}),e.jsx("a",{href:"#",className:"hover:text-white transition-all",children:"Terms"})]}),e.jsx("p",{className:"text-[10px] text-center md:text-right uppercase tracking-widest text-slate-500 font-bold",children:"© 2026 Royal Enfield. All Rights Reserved."})]})})]})}const IM=()=>{const{applicationId:t}=vd(),s=tr(),{user:n}=In(A=>A.auth),[r,a]=g.useState(!0),[i,o]=g.useState([]),[d,m]=g.useState([]),[f,p]=g.useState(""),[h,x]=g.useState({}),[u,N]=g.useState(!1),[v,w]=g.useState("none");g.useEffect(()=>{(async()=>{var E,q;if(t)try{const O=await Ee.getPublicQuestionnaire(t);if(O.data.success){const D=O.data.data.questions||[];o(D);const P=Array.from(new Set(D.map(L=>L.sectionName)));m(P),P.length>0&&p(P[0])}}catch(O){console.error("Error fetching questionnaire:",O),((q=(E=O.response)==null?void 0:E.data)==null?void 0:q.code)==="ALREADY_SUBMITTED"?w("already"):te.error("Failed to load questionnaire")}finally{a(!1)}})()},[t]);const j=(A,E)=>{x(q=>({...q,[A]:E}))},b=()=>{const A=d.indexOf(f);A<d.length-1&&(p(d[A+1]),window.scrollTo({top:0,behavior:"smooth"}))},C=()=>{const A=d.indexOf(f);A>0&&(p(d[A-1]),window.scrollTo({top:0,behavior:"smooth"}))},S=async()=>{const A=i.filter(E=>E.isMandatory&&!h[E.id]);if(A.length>0){te.error(`Please answer all mandatory questions. Missing: ${A.length}`);return}try{N(!0);const E=Object.entries(h).map(([q,O])=>({questionId:q,value:O}));await Ee.submitPublicResponse({applicationId:t,responses:E}),te.success("Responses submitted successfully"),w("success")}catch(E){console.error(E),te.error("Failed to submit responses")}finally{N(!1)}};if(r)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-slate-50",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-re-red"})});if(v!=="none"){const A=v==="already";return e.jsx("div",{className:"min-h-screen bg-slate-50 flex flex-col items-center justify-center p-6",children:e.jsxs("div",{className:"bg-white p-8 rounded-lg shadow-lg max-w-md w-full text-center border-t-4 border-re-red",children:[e.jsx("div",{className:`w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4 ${A?"bg-slate-100 text-slate-600":"bg-green-100 text-green-600"}`,children:A?e.jsx(_a,{className:"w-8 h-8"}):e.jsx(un,{className:"w-8 h-8"})}),e.jsx("h2",{className:"text-2xl font-bold mb-2 text-slate-900",children:A?"Already submitted":"Thank you"}),e.jsx("p",{className:"text-slate-600 leading-relaxed",children:A?e.jsx(e.Fragment,{children:"This questionnaire has already been submitted for your application. You do not need to complete it again. If you think this is a mistake, contact support using the same email you used to apply. You may close this page when you are done."}):e.jsx(e.Fragment,{children:"Your assessment has been submitted successfully. We have received your responses and will review them as part of your application. You may close this page when you are done."})})]})})}const R=i.filter(A=>A.sectionName===f),_=d.indexOf(f);return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden h-screen bg-slate-50",children:[e.jsx("header",{className:"bg-white border-b border-slate-200 px-6 py-4 flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 font-bold text-xl",children:"Dealer Questionnaire Form"}),e.jsx("p",{className:"text-slate-600 text-sm max-w-2xl leading-snug",children:"Answer each section accurately. Your responses are part of the dealership application assessment and may be verified."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[n&&e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-slate-100 rounded-lg",children:[e.jsx("div",{className:"w-8 h-8 bg-re-red rounded-full flex items-center justify-center",children:e.jsx(Lr,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-slate-900 text-sm font-medium",children:n.name||"Applicant"}),e.jsx("p",{className:"text-slate-600 text-xs",children:n.role||"Prospective Dealer"})]})]}),e.jsx("button",{className:"p-2 text-slate-500 hover:bg-slate-100 rounded-lg",title:"Refresh",onClick:()=>window.location.reload(),children:e.jsx(xr,{className:"w-4 h-4"})}),e.jsx("button",{className:"p-2 text-slate-500 hover:bg-slate-100 rounded-lg",title:"Help",children:e.jsx(ck,{className:"w-4 h-4"})})]})]})}),e.jsxs("main",{className:"flex-1 overflow-y-auto",children:[e.jsx("div",{className:"bg-white border-b border-slate-200 sticky top-0 z-20 shadow-sm",children:e.jsx("div",{className:"max-w-5xl mx-auto px-8 py-3",children:e.jsxs("button",{onClick:()=>s("/prospective-dashboard"),className:"inline-flex items-center gap-2 text-sm font-medium text-slate-600 hover:text-slate-900 transition-colors px-3 py-2 rounded-lg hover:bg-slate-100",children:[e.jsx(Jr,{className:"w-4 h-4"}),"Back to Applicant Portal"]})})}),e.jsxs("div",{className:"max-w-5xl mx-auto py-8 px-6",children:[e.jsxs("div",{className:"bg-re-black rounded-t-lg overflow-hidden shadow-xl",children:[e.jsx("div",{className:"relative px-8 py-12",children:e.jsxs("div",{className:"relative z-10 text-center",children:[e.jsx("div",{className:"flex items-center justify-center mb-7",children:e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"h-12 w-auto"})}),e.jsx("div",{className:"h-1 w-24 bg-re-red mx-auto mb-4"}),e.jsx("h2",{className:"text-re-red text-xl mb-4 font-light",children:"Dealership Partner Application"}),e.jsx("p",{className:"text-slate-300 max-w-2xl mx-auto leading-relaxed text-sm",children:"Thank you for your interest in becoming a Royal Enfield business partner. Please complete this questionnaire to help us understand your profile and aspirations."}),e.jsxs("div",{className:"flex items-center justify-center gap-8 mt-8 border-t border-slate-700/50 pt-6 inline-flex mx-auto",children:[e.jsxs("div",{className:"text-center px-4",children:[e.jsx("div",{className:"text-re-red text-2xl font-bold",children:i.length}),e.jsx("div",{className:"text-slate-400 text-xs uppercase tracking-wider",children:"Questions"})]}),e.jsx("div",{className:"h-10 w-px bg-slate-700"}),e.jsxs("div",{className:"text-center px-4",children:[e.jsx("div",{className:"text-re-red text-2xl font-bold",children:d.length}),e.jsx("div",{className:"text-slate-400 text-xs uppercase tracking-wider",children:"Sections"})]})]})]})}),e.jsx("div",{className:"bg-slate-800/50 backdrop-blur-sm border-t border-slate-700",children:e.jsx("div",{className:"flex items-center gap-2 overflow-x-auto scrollbar-hide px-8 py-4 no-scrollbar",children:d.map(A=>e.jsxs("button",{onClick:()=>p(A),className:`flex items-center gap-2 px-4 py-2 rounded-lg whitespace-nowrap transition-all text-sm font-medium
${f===A?"bg-re-red text-white shadow-lg":"bg-slate-700/50 text-slate-300 hover:bg-slate-700 hover:text-white"}`,children:[e.jsx(Ns,{className:"w-4 h-4"}),e.jsx("span",{children:A}),f===A&&e.jsx("span",{className:"ml-2 bg-white/20 px-2 py-0.5 rounded text-xs",children:i.filter(E=>E.sectionName===A).length})]},A))})})]}),e.jsx("div",{className:"bg-white rounded-b-lg shadow-xl border border-slate-200 border-t-0 min-h-[400px]",children:e.jsxs("div",{className:"p-8",children:[e.jsxs("div",{className:"flex items-start gap-4 pb-6 border-b-2 border-red-100 mb-8",children:[e.jsx("div",{className:"w-12 h-12 bg-red-50 rounded-lg flex items-center justify-center flex-shrink-0 text-re-red",children:e.jsx(Ra,{className:"w-6 h-6"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-slate-900 text-xl font-bold mb-1",children:f}),e.jsxs("p",{className:"text-slate-500 text-sm",children:["Section ",_+1," of ",d.length," • ",R.length," questions"]})]})]}),e.jsxs("div",{className:"space-y-10",children:[R.map((A,E)=>e.jsx("div",{className:"group animate-in fade-in duration-500",style:{animationDelay:`${E*100}ms`},children:e.jsxs("div",{className:"flex items-start gap-5",children:[e.jsx("div",{className:"w-8 h-8 bg-slate-100 rounded-full flex items-center justify-center flex-shrink-0 group-hover:bg-red-50 transition-colors text-slate-600 group-hover:text-re-red-hover font-semibold text-sm",children:E+1}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"flex items-start justify-between gap-4",children:e.jsxs("label",{className:"text-sm font-medium text-slate-900 leading-relaxed block",children:[A.questionText,A.isMandatory&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]})}),e.jsxs("div",{className:"max-w-xl",children:[(A.inputType==="text"||A.inputType==="email"||A.inputType==="number")&&e.jsx("input",{type:A.inputType,className:"w-full h-10 px-3 rounded-lg border border-slate-300 focus:border-re-red focus:ring-2 focus:ring-red-200 outline-none transition-all placeholder:text-slate-400",placeholder:"Type your answer here...",value:h[A.id]||"",onChange:q=>j(A.id,q.target.value)}),A.inputType==="textarea"&&e.jsx("textarea",{className:"w-full h-32 p-3 rounded-lg border border-slate-300 focus:border-re-red focus:ring-2 focus:ring-red-200 outline-none transition-all placeholder:text-slate-400",placeholder:"Type your answer here...",value:h[A.id]||"",onChange:q=>j(A.id,q.target.value)}),(A.inputType==="select"||A.inputType==="yesno"||A.inputType==="radio"||A.inputType==="mcq")&&e.jsx("div",{className:"space-y-2",children:(A.questionOptions||(A.inputType==="yesno"?[{optionText:"Yes"},{optionText:"No"}]:[])).map((q,O)=>{const D=q.optionText||q.text;return e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer group/opt",children:[e.jsx("input",{type:"radio",name:`q-${A.id}`,className:"w-4 h-4 text-re-red focus:ring-re-red border-slate-300",checked:h[A.id]===D,onChange:()=>j(A.id,D)}),e.jsx("span",{className:"text-slate-700 group-hover/opt:text-slate-900 transition-colors",children:D})]},O)})})]})]})]})},A.id)),R.length===0&&e.jsx("div",{className:"text-center py-10 text-slate-500 italic",children:"No questions in this section."})]}),e.jsxs("div",{className:"flex items-center justify-between pt-10 mt-10 border-t border-slate-100",children:[e.jsx("button",{onClick:C,disabled:_===0,className:"px-6 py-2.5 rounded-lg text-sm font-medium border border-slate-300 text-slate-700 hover:bg-slate-50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Previous Section"}),_<d.length-1?e.jsxs("button",{onClick:b,className:"px-6 py-2.5 rounded-lg text-sm font-medium bg-re-red text-white hover:bg-re-red-hover flex items-center gap-2 transition-colors shadow-md hover:shadow-lg",children:["Next Section",e.jsx(bi,{className:"w-4 h-4"})]}):e.jsxs("button",{onClick:S,disabled:u,className:"px-8 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 flex items-center gap-2 transition-colors shadow-md hover:shadow-lg disabled:bg-slate-400",children:[u?"Submitting...":"Submit Application",!u&&e.jsx(un,{className:"w-4 h-4"})]})]})]})}),e.jsx("div",{className:"mt-8 text-center text-slate-500 text-sm",children:"© 2026 Royal Enfield. All rights reserved."})]})]})]})};var MM=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],FM=MM.reduce((t,s)=>{const n=Hu(`Primitive.${s}`),r=g.forwardRef((a,i)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),BM="Label",pk=g.forwardRef((t,s)=>e.jsx(FM.label,{...t,ref:s,onMouseDown:n=>{var a;n.target.closest("button, input, select, textarea")||((a=t.onMouseDown)==null||a.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));pk.displayName=BM;var $M=pk;function de({className:t,...s}){return e.jsx($M,{"data-slot":"label",className:Nt("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...s})}const qM=[{id:"15",name:"Super Admin",email:"admin@royalenfield.com",password:"Admin@123",role:"Super Admin"},{id:"13",name:"piyush",email:"piyush@royalenfield.com",password:"Admin@123",role:"DD-ZM"},{id:"14",name:"manish",email:"manish@royalenfield.com",password:"Admin@123",role:"RBM"},{id:"14",name:"manav",email:"manav@royalenfield.com",password:"Admin@123",role:"ZBH"},{id:"5",name:"Jaya",email:"jaya@royalenfield.com",password:"Admin@123",role:"DD Lead"},{id:"14",name:"ganesh",email:"ganesh@royalenfield.com",password:"Admin@123",role:"DD Head"},{id:"16",name:"Yashwin",email:"yashwin@royalenfield.com",password:"Admin@123",role:"NBH"},{id:"15",name:"FDD Team",email:"fdd@royalenfield.com",password:"Admin@123",role:"FDD"},{id:"13",name:"Finance Admin",email:"finance@royalenfield.com",password:"Admin@123",role:"Finance"},{id:"13",name:"abhishek",email:"abhishek@royalenfield.com",password:"Admin@123",role:"ASM"},{id:"18",name:"Lince",email:"lince@royalenfield.com",password:"Admin@123",role:"DD Admin"},{id:"18",name:"Legal Admin",email:"legal@royalenfield.com",password:"Admin@123",role:"Legal Admin"},{id:"18",name:"CEO",email:"ceo@royalenfield.com",password:"Admin@123",role:"CEO"},{id:"18",name:"CCO",email:"cco@royalenfield.com",password:"Admin@123",role:"CCO"}],Ei={totalApplications:0,loaIssued:0,level1Pending:0,level2Pending:0,level3Pending:0,eorInProgress:0,disqualified:0,pendingReminders:0,shortlistedToday:0,pendingShortlisting:0},zM=[];function T1({onLogin:t}){const[s,n]=g.useState(""),[r,a]=g.useState(""),[i,o]=g.useState(!1),[d,m]=g.useState(""),[f,p]=g.useState(!1),[h,x]=g.useState(!1),[u,N]=g.useState(!1),[v,w]=g.useState(null),j=async(R,_)=>{try{if(navigator.clipboard&&navigator.clipboard.writeText){await navigator.clipboard.writeText(R),w(_),setTimeout(()=>w(null),2e3);return}}catch{}try{const A=document.createElement("textarea");A.value=R,A.style.position="fixed",A.style.left="-999999px",A.style.top="-999999px",document.body.appendChild(A),A.focus(),A.select();const E=document.execCommand("copy");document.body.removeChild(A),E&&(w(_),setTimeout(()=>w(null),2e3))}catch{}},b=async(R,_)=>{var A,E;n(R),a(_),m(""),x(!0);try{await t(R,_)}catch(q){const O=((E=(A=q.response)==null?void 0:A.data)==null?void 0:E.message)||q.message||"Auto-login failed";m(O),te.error(O)}finally{x(!1)}},C=async R=>{var _,A;if(R.preventDefault(),!h){if(m(""),!s||!r){m("Please enter both email and password");return}x(!0);try{await t(s,r)}catch(E){const q=((A=(_=E.response)==null?void 0:_.data)==null?void 0:A.message)||E.message||"Login failed";m(q),te.error(q)}finally{x(!1)}}},S=R=>{R.preventDefault(),alert("Password reset link sent to "+s),p(!1)};return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-black p-4 overflow-y-auto",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute -top-40 -right-40 w-80 h-80 bg-red-700/15 rounded-full blur-3xl"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-80 h-80 bg-red-700/15 rounded-full blur-3xl"})]}),e.jsxs("div",{className:"relative w-full max-w-6xl grid md:grid-cols-2 gap-8 my-8",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"h-16 w-auto object-contain"})}),e.jsx("p",{className:"text-slate-400",children:"Dealership Onboarding System"})]}),e.jsx("div",{className:"bg-white rounded-lg shadow-2xl p-8",children:f?e.jsxs("form",{onSubmit:S,className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"mb-2",children:"Reset Password"}),e.jsx("p",{className:"text-slate-600",children:"Enter your email to receive a password reset link"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"reset-email",children:"Email Address"}),e.jsx(at,{id:"reset-email",type:"email",placeholder:"you@royalenfield.com",value:s,onChange:R=>n(R.target.value),required:!0,className:"w-full"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>p(!1),className:"flex-1",children:"Back to Login"}),e.jsx(se,{type:"submit",className:"flex-1 bg-re-red hover:bg-re-red-hover text-white",children:"Send Reset Link"})]})]}):e.jsxs("form",{onSubmit:C,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"email",children:"Email Address"}),e.jsx(at,{id:"email",type:"email",placeholder:"you@royalenfield.com",value:s,onChange:R=>n(R.target.value),className:"w-full",disabled:h})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(at,{id:"password",type:u?"text":"password",placeholder:"Enter your password",value:r,onChange:R=>a(R.target.value),className:"no-native-password-reveal w-full pr-10",autoComplete:"current-password",disabled:h}),e.jsx("button",{type:"button",onClick:()=>N(!u),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 focus:outline-none",disabled:h,children:u?e.jsx(MI,{className:"w-5 h-5"}):e.jsx(yn,{className:"w-5 h-5"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ln,{id:"remember",checked:i,onCheckedChange:R=>o(R),disabled:h}),e.jsx(de,{htmlFor:"remember",className:"cursor-pointer",children:"Remember Me"})]}),e.jsx("button",{type:"button",onClick:()=>p(!0),className:"text-re-red hover:text-re-red-hover disabled:opacity-50",disabled:h,children:"Forgot Password?"})]}),d&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-md",children:[e.jsx(sn,{className:"w-4 h-4 text-red-600"}),e.jsx("span",{className:"text-red-600 font-medium text-sm",children:d})]}),e.jsx(se,{type:"submit",className:"w-full bg-re-red hover:bg-re-red-hover h-11 text-white",disabled:h,children:h?e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),e.jsx("span",{children:"Logging in..."})]}):"Login"}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"relative my-4",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-slate-200"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-white px-2 text-slate-500",children:"Or"})})]}),e.jsx(se,{type:"button",variant:"outline",className:"w-full border-re-red text-re-red hover:bg-red-50 h-11",onClick:()=>window.location.href="/prospective-login",children:"Prospective User Login"})]})]})}),e.jsx("div",{className:"text-center mt-6 text-slate-400",children:e.jsx("p",{children:"© 2026 Royal Enfield. All rights reserved."})})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow-2xl p-8 overflow-y-auto max-h-[800px]",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"mb-2",children:"Test User Credentials"}),e.jsx("p",{className:"text-slate-600",children:"Click on any user to auto-login"})]}),e.jsx("div",{className:"space-y-3",children:qM.map((R,_)=>e.jsxs("div",{className:"border border-slate-200 rounded-lg p-4 hover:border-re-red hover:bg-red-50 transition-all cursor-pointer",onClick:()=>b(R.email,R.password),children:[e.jsx("div",{className:"flex items-start justify-between mb-2",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsx("span",{className:"px-2 py-1 bg-red-100 text-re-red rounded text-xs",children:R.role})}),e.jsx("p",{className:"text-slate-900",children:R.name})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-slate-500",children:"Email:"}),e.jsx("p",{className:"text-slate-900 font-mono break-all",children:R.email})]}),e.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),j(R.email,_*2)},className:"p-2 hover:bg-slate-100 rounded",children:v===_*2?e.jsx(Hn,{className:"w-4 h-4 text-green-600"}):e.jsx(C1,{className:"w-4 h-4 text-slate-400"})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-slate-500",children:"Password:"}),e.jsx("p",{className:"text-slate-900 font-mono",children:R.password})]}),e.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),j(R.password,_*2+1)},className:"p-2 hover:bg-slate-100 rounded",children:v===_*2+1?e.jsx(Hn,{className:"w-4 h-4 text-green-600"}):e.jsx(C1,{className:"w-4 h-4 text-slate-400"})})]})]}),e.jsx("div",{className:"mt-3 pt-3 border-t border-slate-200",children:e.jsxs("p",{className:"text-re-red text-center",children:["Click to login as ",R.role]})})]},R.email))})]})]})]})}function UM(){const t=tr(),s=Lu(),[n,r]=g.useState("PHONE"),[a,i]=g.useState(""),[o,d]=g.useState(""),[m,f]=g.useState(!1),[p,h]=g.useState(""),x=async N=>{var v;if(N.preventDefault(),!a||a.length<10){h("Please enter a valid 10-digit phone number");return}f(!0),h("");try{const w=await Ee.sendOtp(a);if(w.ok)r("OTP"),te.success("OTP sent successfully!");else{console.error("Send OTP error response:",w);const j=((v=w.data)==null?void 0:v.message)||"Failed to send OTP";h(j),te.error(j)}}catch(w){console.error("Send OTP network error:",w),h("Network error. Please try again."),te.error("Network error. Please try again.")}finally{f(!1)}},u=async N=>{var v;if(N.preventDefault(),!o||o.length<6){h("Please enter a valid 6-digit OTP");return}f(!0),h("");try{const w=await Ee.verifyOtp(a,o);if(w.ok&&w.data){const{token:j,user:b}=w.data.data||w.data;if(!j||!b)throw new Error("Invalid response format");s(SA({user:b,token:j})),localStorage.setItem("token",j),te.success("Logged in successfully!"),t("/prospective-dashboard")}else{const j=((v=w.data)==null?void 0:v.message)||"Invalid OTP";h(j),te.error(j)}}catch(w){console.error("Verify OTP error:",w),h("An unexpected error occurred"),te.error("An unexpected error occurred")}finally{f(!1)}};return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 p-4 overflow-y-auto",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute -top-40 -right-40 w-80 h-80 bg-re-red/10 rounded-full blur-3xl"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-80 h-80 bg-re-red/10 rounded-full blur-3xl"})]}),e.jsxs("div",{className:"relative w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-20 h-20 bg-re-red rounded-full mb-4",children:e.jsxs("svg",{viewBox:"0 0 24 24",className:"w-12 h-12 text-white",fill:"currentColor",children:[e.jsx("path",{d:"M12 2L4 6v6c0 5.5 3.8 10.7 8 12 4.2-1.3 8-6.5 8-12V6l-8-4zm0 2.2l6 3v4.8c0 4.5-3.1 8.7-6 10-2.9-1.3-6-5.5-6-10V7.2l6-3z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),e.jsx("h1",{className:"text-white mb-2",children:"Royal Enfield"}),e.jsx("p",{className:"text-slate-400",children:"Dealer Login"})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow-2xl p-8",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs(se,{variant:"ghost",className:"px-0 flex items-center gap-2 text-slate-600 hover:text-slate-900 mb-4 hover:bg-transparent",onClick:()=>n==="OTP"?r("PHONE"):t("/admin-login"),children:[e.jsx(Jr,{className:"w-4 h-4"}),n==="OTP"?"Change Phone Number":"Back to Login"]}),e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"p-2 bg-red-50 rounded-lg",children:e.jsx(JI,{className:"w-6 h-6 text-re-red"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-slate-900 text-lg font-semibold",children:"Dealer Login"}),e.jsx("p",{className:"text-slate-600 text-sm",children:"Login with your registered phone number"})]})]})]}),n==="PHONE"?e.jsxs("form",{onSubmit:x,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"phone",children:"Registered Phone Number"}),e.jsx(at,{id:"phone",type:"tel",placeholder:"Enter 10-digit phone number",maxLength:10,value:a,onChange:N=>i(N.target.value.replace(/\D/g,"")),className:"w-full",disabled:m}),e.jsx("p",{className:"text-slate-500 text-xs",children:"Enter the phone number you used during application"})]}),p&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-md",children:[e.jsx(sn,{className:"w-4 h-4 text-red-600"}),e.jsx("span",{className:"text-red-600 font-medium text-sm",children:p})]}),e.jsx(se,{type:"submit",className:"w-full bg-re-red hover:bg-re-red-hover h-9",disabled:m||a.length<10,children:m?"Sending...":"Send OTP"}),e.jsx("div",{className:"text-center text-slate-500 text-xs",children:e.jsx("p",{children:"You will receive a 6-digit OTP on your registered mobile number"})})]}):e.jsxs("form",{onSubmit:u,className:"space-y-6",children:[e.jsx("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:e.jsxs("p",{className:"text-green-800 text-center text-sm",children:["OTP sent to +91 ",a]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"otp",children:"Enter OTP"}),e.jsx(at,{id:"otp",type:"text",placeholder:"Enter 6-digit OTP",maxLength:6,value:o,onChange:N=>d(N.target.value.replace(/\D/g,"")),className:"w-full text-center text-2xl tracking-widest",disabled:m}),e.jsx("p",{className:"text-slate-500 text-xs text-center",children:"Check your SMS for the OTP"})]}),p&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-md",children:[e.jsx(sn,{className:"w-4 h-4 text-red-600"}),e.jsx("span",{className:"text-red-600 font-medium text-sm",children:p})]}),e.jsx(se,{type:"submit",className:"w-full bg-re-red hover:bg-re-red-hover h-9",disabled:m||o.length<6,children:m?"Verifying...":"Verify OTP"}),e.jsxs("div",{className:"text-center text-sm",children:[e.jsx("button",{type:"button",className:"text-re-red hover:text-re-red-hover font-medium",onClick:()=>r("PHONE"),children:"Change Phone Number"}),e.jsx("span",{className:"mx-2 text-slate-400",children:"|"}),e.jsx("button",{type:"button",className:"text-re-red hover:text-re-red-hover font-medium",onClick:x,disabled:m,children:"Resend OTP"})]})]})]}),e.jsx("div",{className:"text-center mt-6 text-slate-400",children:e.jsx("p",{children:"© 2025 Royal Enfield. All rights reserved."})})]})]})}function VM({onLogout:t}){const s=tr(),r=yl().pathname.substring(1)||"dashboard",{user:a}=In(L=>L.auth),[i,o]=g.useState(!1),[d,m]=g.useState(""),[f,p]=g.useState(!1),[h,x]=g.useState(!1),[u,N]=g.useState(null),v=g.useRef(null),w=L=>{const $=L.map(W=>W.toLowerCase()),Y=String((a==null?void 0:a.role)||"").toLowerCase(),Z=String((a==null?void 0:a.roleCode)||"").toLowerCase();return $.includes(Y)||$.includes(Z)},j=["DD Admin","DD_ADMIN","ASM","RBM","DD-ZM","DD_ZM","DD Lead","DD_LEAD","DD Head","DD_HEAD","ZBH","NBH","Legal","Legal Admin","LEGAL_ADMIN","Super Admin","SUPER_ADMIN"],b=["ASM","RBM","DD-ZM","DD_ZM","ZBH","DD Lead","DD_LEAD","DD Head","DD_HEAD","NBH","Legal Admin","LEGAL_ADMIN","Legal","DD Admin","DD_ADMIN","CCO","CEO","Super Admin","SUPER_ADMIN"],C=["DD Admin","DD_ADMIN","DD-ZM","DD_ZM","DD Lead","DD_LEAD","DD Head","DD_HEAD","NBH","Finance","Finance Admin","FINANCE_ADMIN","Super Admin","SUPER_ADMIN"],S=w(j),R=w(b),_=w(C),A=[S?{id:"resignation",label:"Resignation"}:null,R?{id:"termination",label:"Termination"}:null,_?{id:"fnf",label:"F&F"}:null].filter(Boolean),E=w(["Finance","Finance Admin"])?[{id:"dashboard",label:"Dashboard",icon:um},{id:"finance-onboarding",label:"Onboarding",icon:Ns},{id:"finance-fnf",label:"F&F",icon:gg}]:w(["Dealer"])?[{id:"dashboard",label:"Dashboard",icon:um},{id:"dealer-resignation",label:"My Resignations",icon:gg},{id:"dealer-constitutional",label:"Constitutional Change",icon:hl},{id:"dealer-relocation",label:"Relocation Requests",icon:Vr}]:w(["FDD"])?[{id:"fdd-dashboard",label:"FDD Dashboard",icon:um}]:[{id:"dashboard",label:"Dashboard",icon:um},{id:"applications",label:"Dealership Requests",icon:Ns},...A.length>0?[{id:"offboarding",label:"Offboarding",icon:gg,hasSubmenu:!0,submenuKey:"offboarding",submenu:A}]:[],{id:"constitutional-change",label:"Constitutional Change",icon:hl},{id:"relocation-requests",label:"Relocation Requests",icon:Vr}];w(["DD Lead","DD Admin","Super Admin"])&&E.splice(1,0,{id:"all-requests",label:"All Requests",icon:$I,hasSubmenu:!0,submenuKey:"allRequests",submenu:[{id:"opportunity-requests",label:"Opportunity Requests"},{id:"non-opportunities",label:"Non-opportunities"}]}),w(["Super Admin","DD Admin","DD Lead"])&&(E.push({id:"master",label:"Master",icon:Xc}),E.push({id:"sla-configurations",label:"SLA Matrix",icon:hl})),w(["Super Admin"])&&(E.push({id:"users",label:"User Management",icon:Ra}),E.push({id:"questionnaires",label:"Questionnaire Templates",icon:rc}),E.push({id:"interview-configs",label:"Interview Configs",icon:HI}),E.push({id:"system-logs",label:"System Logs",icon:ad}));const q=L=>{L.preventDefault(),d.trim()&&s("/applications")},O=g.useCallback((L,$)=>{v.current&&clearTimeout(v.current);const Y=$.getBoundingClientRect();N({submenuKey:L,top:Y.top,left:Y.right+8})},[]),D=g.useCallback((L=!1)=>{L?(v.current&&clearTimeout(v.current),N(null)):v.current=setTimeout(()=>N(null),150)},[]),P=g.useCallback(()=>{v.current&&clearTimeout(v.current)},[]);return g.useEffect(()=>{i||N(null)},[i]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`bg-black text-white h-screen flex flex-col transition-all duration-300 overflow-hidden relative flex-shrink-0 ${i?"w-20":"w-64"}`,children:[e.jsx("div",{className:"border-b border-white/10",children:i?e.jsxs("div",{className:"flex flex-col items-center py-3 gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-white flex items-center justify-center p-1 shadow-md",children:e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"RE",className:"w-full h-full object-contain"})}),e.jsx("button",{onClick:()=>o(!1),className:"p-1.5 hover:bg-white/10 rounded-lg transition-colors text-slate-400 hover:text-white",title:"Expand sidebar",children:e.jsx(bi,{className:"w-4 h-4"})})]}):e.jsxs("div",{className:"flex items-center justify-between px-4 py-4",children:[e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"h-6 w-auto"}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.2em] font-bold text-slate-400 mt-1 whitespace-nowrap",children:"Dealer Network"})]}),e.jsx("button",{onClick:()=>o(!0),className:"p-1.5 hover:bg-white/10 rounded-lg transition-colors text-slate-400 hover:text-white flex-shrink-0 ml-2",title:"Collapse sidebar",children:e.jsx(lo,{className:"w-4 h-4"})})]})}),!i&&e.jsx("div",{className:"p-4 border-b border-white/10",children:e.jsxs("form",{onSubmit:q,className:"relative",children:[e.jsx(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(at,{type:"text",placeholder:"Search applications...",value:d,onChange:L=>m(L.target.value),className:"w-full pl-10 bg-white/5 border-white/10 text-white placeholder:text-slate-500"})]})}),e.jsx("nav",{className:"flex-1 p-3 space-y-1 overflow-y-auto custom-scrollbar",children:E.map(L=>{var z,T;const $=L.icon,Y=r===L.id,Z=!!L.hasSubmenu,W=Z&&((z=L.submenu)==null?void 0:z.some(I=>r===I.id)),U=L.submenuKey,M=U==="offboarding"?f:U==="allRequests"?h:!1;return e.jsxs("div",{children:[e.jsxs("button",{onMouseEnter:I=>{i&&Z&&U&&O(U,I.currentTarget)},onMouseLeave:()=>{i&&Z&&D()},onClick:()=>{Z?i?(o(!1),U==="offboarding"?p(!0):U==="allRequests"&&x(!0)):U==="offboarding"?p(!f):U==="allRequests"&&x(!h):s(`/${L.id}`)},className:`w-full flex items-center gap-3 px-3 py-3 rounded-lg transition-colors ${i?"justify-center":""} ${Y||W?"bg-re-red text-white shadow-lg shadow-re-red/20":"text-slate-400 hover:bg-white/5 hover:text-white"}`,title:i?L.label:void 0,children:[e.jsx($,{className:"w-5 h-5 flex-shrink-0"}),!i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-left text-sm",children:L.label}),Z&&(M?e.jsx(yu,{className:"w-4 h-4 flex-shrink-0"}):e.jsx(Aa,{className:"w-4 h-4 flex-shrink-0"}))]})]}),Z&&M&&!i&&e.jsx("div",{className:"ml-3 mt-1 space-y-1 border-l border-white/10 pl-3",children:(T=L.submenu)==null?void 0:T.map(I=>{const B=r===I.id;return e.jsxs("button",{onClick:()=>s(`/${I.id}`),className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg transition-colors text-sm ${B?"bg-re-red/20 text-re-red font-semibold":"text-slate-500 hover:bg-white/5 hover:text-white"}`,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current flex-shrink-0"}),e.jsx("span",{children:I.label})]},I.id)})})]},L.id)})}),e.jsxs("div",{className:"p-4 border-t border-white/10 space-y-2",children:[!i&&a&&e.jsx("div",{className:"px-4 py-2 bg-white/5 rounded-lg mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-re-red rounded-full flex items-center justify-center font-bold flex-shrink-0",children:e.jsx("span",{children:a.name.charAt(0)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold",children:a.name}),e.jsx("p",{className:"text-slate-500 truncate text-[11px] uppercase tracking-wider",children:a.role})]})]})}),i&&a&&e.jsx("div",{className:"flex justify-center mb-2",children:e.jsx("div",{className:"w-9 h-9 bg-re-red rounded-full flex items-center justify-center font-bold text-sm",title:a.name,children:e.jsx("span",{children:a.name.charAt(0)})})}),e.jsxs(se,{onClick:t,variant:"ghost",className:`w-full ${i?"px-2 justify-center":"justify-start"} text-slate-400 hover:bg-white/5 hover:text-white`,title:i?"Logout":void 0,children:[e.jsx(hk,{className:"w-5 h-5 flex-shrink-0"}),!i&&e.jsx("span",{className:"ml-3",children:"Logout"})]})]})]}),u&&i&&(()=>{const L=E.find($=>$.submenuKey===u.submenuKey);return!L||!L.submenu?null:Hy.createPortal(e.jsxs("div",{style:{top:u.top,left:u.left},className:"fixed z-[9999] min-w-[200px] bg-gray-900 border border-white/10 rounded-xl shadow-2xl py-2",onMouseEnter:P,onMouseLeave:()=>D(),children:[e.jsx("div",{className:"px-4 py-1.5 text-xs font-bold uppercase tracking-widest text-slate-400 border-b border-white/10 mb-1",children:L.label}),L.submenu.map($=>{const Y=r===$.id;return e.jsxs("button",{onClick:()=>{s(`/${$.id}`),D(!0)},className:`w-full flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors ${Y?"bg-re-red/20 text-re-red font-semibold":"text-slate-300 hover:bg-white/10 hover:text-white"}`,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current flex-shrink-0"}),e.jsx("span",{children:$.label})]},$.id)})]}),document.body)})()]})}function P1(t){const s=HM(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find(GM);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function HM(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=YM(a),d=KM(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Xr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var WM=Symbol("radix.slottable");function GM(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===WM}function KM(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function YM(t){var r,a;let s=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function rb(t){const s=t+"CollectionProvider",[n,r]=ga(s),[a,i]=n(s,{collectionRef:{current:null},itemMap:new Map}),o=v=>{const{scope:w,children:j}=v,b=wt.useRef(null),C=wt.useRef(new Map).current;return e.jsx(a,{scope:w,itemMap:C,collectionRef:b,children:j})};o.displayName=s;const d=t+"CollectionSlot",m=P1(d),f=wt.forwardRef((v,w)=>{const{scope:j,children:b}=v,C=i(d,j),S=Gs(w,C.collectionRef);return e.jsx(m,{ref:S,children:b})});f.displayName=d;const p=t+"CollectionItemSlot",h="data-radix-collection-item",x=P1(p),u=wt.forwardRef((v,w)=>{const{scope:j,children:b,...C}=v,S=wt.useRef(null),R=Gs(w,S),_=i(p,j);return wt.useEffect(()=>(_.itemMap.set(S,{ref:S,...C}),()=>void _.itemMap.delete(S))),e.jsx(x,{[h]:"",ref:R,children:b})});u.displayName=p;function N(v){const w=i(t+"CollectionConsumer",v);return wt.useCallback(()=>{const b=w.collectionRef.current;if(!b)return[];const C=Array.from(b.querySelectorAll(`[${h}]`));return Array.from(w.itemMap.values()).sort((_,A)=>C.indexOf(_.ref.current)-C.indexOf(A.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:o,Slot:f,ItemSlot:u},N,r]}var ZM=g.createContext(void 0);function Ku(t){const s=g.useContext(ZM);return t||s||"ltr"}function Sr(t){const s=g.useRef(t);return g.useEffect(()=>{s.current=t}),g.useMemo(()=>(...n)=>{var r;return(r=s.current)==null?void 0:r.call(s,...n)},[])}function QM(t,s=globalThis==null?void 0:globalThis.document){const n=Sr(t);g.useEffect(()=>{const r=a=>{a.key==="Escape"&&n(a)};return s.addEventListener("keydown",r,{capture:!0}),()=>s.removeEventListener("keydown",r,{capture:!0})},[n,s])}var XM="DismissableLayer",ly="dismissableLayer.update",JM="dismissableLayer.pointerDownOutside",e3="dismissableLayer.focusOutside",O1,xk=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),bd=g.forwardRef((t,s)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:d,...m}=t,f=g.useContext(xk),[p,h]=g.useState(null),x=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,u]=g.useState({}),N=Gs(s,A=>h(A)),v=Array.from(f.layers),[w]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),j=v.indexOf(w),b=p?v.indexOf(p):-1,C=f.layersWithOutsidePointerEventsDisabled.size>0,S=b>=j,R=n3(A=>{const E=A.target,q=[...f.branches].some(O=>O.contains(E));!S||q||(a==null||a(A),o==null||o(A),A.defaultPrevented||d==null||d())},x),_=r3(A=>{const E=A.target;[...f.branches].some(O=>O.contains(E))||(i==null||i(A),o==null||o(A),A.defaultPrevented||d==null||d())},x);return QM(A=>{b===f.layers.size-1&&(r==null||r(A),!A.defaultPrevented&&d&&(A.preventDefault(),d()))},x),g.useEffect(()=>{if(p)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(O1=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(p)),f.layers.add(p),L1(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=O1)}},[p,x,n,f]),g.useEffect(()=>()=>{p&&(f.layers.delete(p),f.layersWithOutsidePointerEventsDisabled.delete(p),L1())},[p,f]),g.useEffect(()=>{const A=()=>u({});return document.addEventListener(ly,A),()=>document.removeEventListener(ly,A)},[]),e.jsx(js.div,{...m,ref:N,style:{pointerEvents:C?S?"auto":"none":void 0,...t.style},onFocusCapture:Kt(t.onFocusCapture,_.onFocusCapture),onBlurCapture:Kt(t.onBlurCapture,_.onBlurCapture),onPointerDownCapture:Kt(t.onPointerDownCapture,R.onPointerDownCapture)})});bd.displayName=XM;var t3="DismissableLayerBranch",s3=g.forwardRef((t,s)=>{const n=g.useContext(xk),r=g.useRef(null),a=Gs(s,r);return g.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),e.jsx(js.div,{...t,ref:a})});s3.displayName=t3;function n3(t,s=globalThis==null?void 0:globalThis.document){const n=Sr(t),r=g.useRef(!1),a=g.useRef(()=>{});return g.useEffect(()=>{const i=d=>{if(d.target&&!r.current){let m=function(){gk(JM,n,f,{discrete:!0})};const f={originalEvent:d};d.pointerType==="touch"?(s.removeEventListener("click",a.current),a.current=m,s.addEventListener("click",a.current,{once:!0})):m()}else s.removeEventListener("click",a.current);r.current=!1},o=window.setTimeout(()=>{s.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),s.removeEventListener("pointerdown",i),s.removeEventListener("click",a.current)}},[s,n]),{onPointerDownCapture:()=>r.current=!0}}function r3(t,s=globalThis==null?void 0:globalThis.document){const n=Sr(t),r=g.useRef(!1);return g.useEffect(()=>{const a=i=>{i.target&&!r.current&&gk(e3,n,{originalEvent:i},{discrete:!1})};return s.addEventListener("focusin",a),()=>s.removeEventListener("focusin",a)},[s,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function L1(){const t=new CustomEvent(ly);document.dispatchEvent(t)}function gk(t,s,n,{discrete:r}){const a=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});s&&a.addEventListener(t,s,{once:!0}),r?YA(a,i):a.dispatchEvent(i)}var yg=0;function $f(){g.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??I1()),document.body.insertAdjacentElement("beforeend",t[1]??I1()),yg++,()=>{yg===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),yg--}},[])}function I1(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var bg="focusScope.autoFocusOnMount",jg="focusScope.autoFocusOnUnmount",M1={bubbles:!1,cancelable:!0},a3="FocusScope",Yu=g.forwardRef((t,s)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[d,m]=g.useState(null),f=Sr(a),p=Sr(i),h=g.useRef(null),x=Gs(s,v=>m(v)),u=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let v=function(C){if(u.paused||!d)return;const S=C.target;d.contains(S)?h.current=S:Kl(h.current,{select:!0})},w=function(C){if(u.paused||!d)return;const S=C.relatedTarget;S!==null&&(d.contains(S)||Kl(h.current,{select:!0}))},j=function(C){if(document.activeElement===document.body)for(const R of C)R.removedNodes.length>0&&Kl(d)};document.addEventListener("focusin",v),document.addEventListener("focusout",w);const b=new MutationObserver(j);return d&&b.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",w),b.disconnect()}}},[r,d,u.paused]),g.useEffect(()=>{if(d){B1.add(u);const v=document.activeElement;if(!d.contains(v)){const j=new CustomEvent(bg,M1);d.addEventListener(bg,f),d.dispatchEvent(j),j.defaultPrevented||(i3(u3(vk(d)),{select:!0}),document.activeElement===v&&Kl(d))}return()=>{d.removeEventListener(bg,f),setTimeout(()=>{const j=new CustomEvent(jg,M1);d.addEventListener(jg,p),d.dispatchEvent(j),j.defaultPrevented||Kl(v??document.body,{select:!0}),d.removeEventListener(jg,p),B1.remove(u)},0)}}},[d,f,p,u]);const N=g.useCallback(v=>{if(!n&&!r||u.paused)return;const w=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,j=document.activeElement;if(w&&j){const b=v.currentTarget,[C,S]=l3(b);C&&S?!v.shiftKey&&j===S?(v.preventDefault(),n&&Kl(C,{select:!0})):v.shiftKey&&j===C&&(v.preventDefault(),n&&Kl(S,{select:!0})):j===b&&v.preventDefault()}},[n,r,u.paused]);return e.jsx(js.div,{tabIndex:-1,...o,ref:x,onKeyDown:N})});Yu.displayName=a3;function i3(t,{select:s=!1}={}){const n=document.activeElement;for(const r of t)if(Kl(r,{select:s}),document.activeElement!==n)return}function l3(t){const s=vk(t),n=F1(s,t),r=F1(s.reverse(),t);return[n,r]}function vk(t){const s=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const a=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||a?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)s.push(n.currentNode);return s}function F1(t,s){for(const n of t)if(!o3(n,{upTo:s}))return n}function o3(t,{upTo:s}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(s!==void 0&&t===s)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function c3(t){return t instanceof HTMLInputElement&&"select"in t}function Kl(t,{select:s=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&c3(t)&&s&&t.select()}}var B1=d3();function d3(){let t=[];return{add(s){const n=t[0];s!==n&&(n==null||n.pause()),t=$1(t,s),t.unshift(s)},remove(s){var n;t=$1(t,s),(n=t[0])==null||n.resume()}}}function $1(t,s){const n=[...t],r=n.indexOf(s);return r!==-1&&n.splice(r,1),n}function u3(t){return t.filter(s=>s.tagName!=="A")}var h3=Sf[" useId ".trim().toString()]||(()=>{}),m3=0;function Ar(t){const[s,n]=g.useState(h3());return cr(()=>{n(r=>r??String(m3++))},[t]),t||(s?`radix-${s}`:"")}const f3=["top","right","bottom","left"],ro=Math.min,Ca=Math.max,of=Math.round,mm=Math.floor,Mi=t=>({x:t,y:t}),p3={left:"right",right:"left",bottom:"top",top:"bottom"};function oy(t,s,n){return Ca(t,ro(s,n))}function pl(t,s){return typeof t=="function"?t(s):t}function xl(t){return t.split("-")[0]}function jd(t){return t.split("-")[1]}function ab(t){return t==="x"?"y":"x"}function ib(t){return t==="y"?"height":"width"}function Li(t){const s=t[0];return s==="t"||s==="b"?"y":"x"}function lb(t){return ab(Li(t))}function x3(t,s,n){n===void 0&&(n=!1);const r=jd(t),a=lb(t),i=ib(a);let o=a==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return s.reference[i]>s.floating[i]&&(o=cf(o)),[o,cf(o)]}function g3(t){const s=cf(t);return[cy(t),s,cy(s)]}function cy(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const q1=["left","right"],z1=["right","left"],v3=["top","bottom"],y3=["bottom","top"];function b3(t,s,n){switch(t){case"top":case"bottom":return n?s?z1:q1:s?q1:z1;case"left":case"right":return s?v3:y3;default:return[]}}function j3(t,s,n,r){const a=jd(t);let i=b3(xl(t),n==="start",r);return a&&(i=i.map(o=>o+"-"+a),s&&(i=i.concat(i.map(cy)))),i}function cf(t){const s=xl(t);return p3[s]+t.slice(s.length)}function N3(t){return{top:0,right:0,bottom:0,left:0,...t}}function yk(t){return typeof t!="number"?N3(t):{top:t,right:t,bottom:t,left:t}}function df(t){const{x:s,y:n,width:r,height:a}=t;return{width:r,height:a,top:n,left:s,right:s+r,bottom:n+a,x:s,y:n}}function U1(t,s,n){let{reference:r,floating:a}=t;const i=Li(s),o=lb(s),d=ib(o),m=xl(s),f=i==="y",p=r.x+r.width/2-a.width/2,h=r.y+r.height/2-a.height/2,x=r[d]/2-a[d]/2;let u;switch(m){case"top":u={x:p,y:r.y-a.height};break;case"bottom":u={x:p,y:r.y+r.height};break;case"right":u={x:r.x+r.width,y:h};break;case"left":u={x:r.x-a.width,y:h};break;default:u={x:r.x,y:r.y}}switch(jd(s)){case"start":u[o]-=x*(n&&f?-1:1);break;case"end":u[o]+=x*(n&&f?-1:1);break}return u}async function w3(t,s){var n;s===void 0&&(s={});const{x:r,y:a,platform:i,rects:o,elements:d,strategy:m}=t,{boundary:f="clippingAncestors",rootBoundary:p="viewport",elementContext:h="floating",altBoundary:x=!1,padding:u=0}=pl(s,t),N=yk(u),w=d[x?h==="floating"?"reference":"floating":h],j=df(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(w)))==null||n?w:w.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(d.floating)),boundary:f,rootBoundary:p,strategy:m})),b=h==="floating"?{x:r,y:a,width:o.floating.width,height:o.floating.height}:o.reference,C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d.floating)),S=await(i.isElement==null?void 0:i.isElement(C))?await(i.getScale==null?void 0:i.getScale(C))||{x:1,y:1}:{x:1,y:1},R=df(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:b,offsetParent:C,strategy:m}):b);return{top:(j.top-R.top+N.top)/S.y,bottom:(R.bottom-j.bottom+N.bottom)/S.y,left:(j.left-R.left+N.left)/S.x,right:(R.right-j.right+N.right)/S.x}}const S3=50,C3=async(t,s,n)=>{const{placement:r="bottom",strategy:a="absolute",middleware:i=[],platform:o}=n,d=o.detectOverflow?o:{...o,detectOverflow:w3},m=await(o.isRTL==null?void 0:o.isRTL(s));let f=await o.getElementRects({reference:t,floating:s,strategy:a}),{x:p,y:h}=U1(f,r,m),x=r,u=0;const N={};for(let v=0;v<i.length;v++){const w=i[v];if(!w)continue;const{name:j,fn:b}=w,{x:C,y:S,data:R,reset:_}=await b({x:p,y:h,initialPlacement:r,placement:x,strategy:a,middlewareData:N,rects:f,platform:d,elements:{reference:t,floating:s}});p=C??p,h=S??h,N[j]={...N[j],...R},_&&u<S3&&(u++,typeof _=="object"&&(_.placement&&(x=_.placement),_.rects&&(f=_.rects===!0?await o.getElementRects({reference:t,floating:s,strategy:a}):_.rects),{x:p,y:h}=U1(f,x,m)),v=-1)}return{x:p,y:h,placement:x,strategy:a,middlewareData:N}},A3=t=>({name:"arrow",options:t,async fn(s){const{x:n,y:r,placement:a,rects:i,platform:o,elements:d,middlewareData:m}=s,{element:f,padding:p=0}=pl(t,s)||{};if(f==null)return{};const h=yk(p),x={x:n,y:r},u=lb(a),N=ib(u),v=await o.getDimensions(f),w=u==="y",j=w?"top":"left",b=w?"bottom":"right",C=w?"clientHeight":"clientWidth",S=i.reference[N]+i.reference[u]-x[u]-i.floating[N],R=x[u]-i.reference[u],_=await(o.getOffsetParent==null?void 0:o.getOffsetParent(f));let A=_?_[C]:0;(!A||!await(o.isElement==null?void 0:o.isElement(_)))&&(A=d.floating[C]||i.floating[N]);const E=S/2-R/2,q=A/2-v[N]/2-1,O=ro(h[j],q),D=ro(h[b],q),P=O,L=A-v[N]-D,$=A/2-v[N]/2+E,Y=oy(P,$,L),Z=!m.arrow&&jd(a)!=null&&$!==Y&&i.reference[N]/2-($<P?O:D)-v[N]/2<0,W=Z?$<P?$-P:$-L:0;return{[u]:x[u]+W,data:{[u]:Y,centerOffset:$-Y-W,...Z&&{alignmentOffset:W}},reset:Z}}}),k3=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(s){var n,r;const{placement:a,middlewareData:i,rects:o,initialPlacement:d,platform:m,elements:f}=s,{mainAxis:p=!0,crossAxis:h=!0,fallbackPlacements:x,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:N="none",flipAlignment:v=!0,...w}=pl(t,s);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const j=xl(a),b=Li(d),C=xl(d)===d,S=await(m.isRTL==null?void 0:m.isRTL(f.floating)),R=x||(C||!v?[cf(d)]:g3(d)),_=N!=="none";!x&&_&&R.push(...j3(d,v,N,S));const A=[d,...R],E=await m.detectOverflow(s,w),q=[];let O=((r=i.flip)==null?void 0:r.overflows)||[];if(p&&q.push(E[j]),h){const $=x3(a,o,S);q.push(E[$[0]],E[$[1]])}if(O=[...O,{placement:a,overflows:q}],!q.every($=>$<=0)){var D,P;const $=(((D=i.flip)==null?void 0:D.index)||0)+1,Y=A[$];if(Y&&(!(h==="alignment"?b!==Li(Y):!1)||O.every(U=>Li(U.placement)===b?U.overflows[0]>0:!0)))return{data:{index:$,overflows:O},reset:{placement:Y}};let Z=(P=O.filter(W=>W.overflows[0]<=0).sort((W,U)=>W.overflows[1]-U.overflows[1])[0])==null?void 0:P.placement;if(!Z)switch(u){case"bestFit":{var L;const W=(L=O.filter(U=>{if(_){const M=Li(U.placement);return M===b||M==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(M=>M>0).reduce((M,z)=>M+z,0)]).sort((U,M)=>U[1]-M[1])[0])==null?void 0:L[0];W&&(Z=W);break}case"initialPlacement":Z=d;break}if(a!==Z)return{reset:{placement:Z}}}return{}}}};function V1(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function H1(t){return f3.some(s=>t[s]>=0)}const D3=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:n,platform:r}=s,{strategy:a="referenceHidden",...i}=pl(t,s);switch(a){case"referenceHidden":{const o=await r.detectOverflow(s,{...i,elementContext:"reference"}),d=V1(o,n.reference);return{data:{referenceHiddenOffsets:d,referenceHidden:H1(d)}}}case"escaped":{const o=await r.detectOverflow(s,{...i,altBoundary:!0}),d=V1(o,n.floating);return{data:{escapedOffsets:d,escaped:H1(d)}}}default:return{}}}}},bk=new Set(["left","top"]);async function R3(t,s){const{placement:n,platform:r,elements:a}=t,i=await(r.isRTL==null?void 0:r.isRTL(a.floating)),o=xl(n),d=jd(n),m=Li(n)==="y",f=bk.has(o)?-1:1,p=i&&m?-1:1,h=pl(s,t);let{mainAxis:x,crossAxis:u,alignmentAxis:N}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return d&&typeof N=="number"&&(u=d==="end"?N*-1:N),m?{x:u*p,y:x*f}:{x:x*f,y:u*p}}const E3=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(s){var n,r;const{x:a,y:i,placement:o,middlewareData:d}=s,m=await R3(s,t);return o===((n=d.offset)==null?void 0:n.placement)&&(r=d.arrow)!=null&&r.alignmentOffset?{}:{x:a+m.x,y:i+m.y,data:{...m,placement:o}}}}},_3=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:n,y:r,placement:a,platform:i}=s,{mainAxis:o=!0,crossAxis:d=!1,limiter:m={fn:j=>{let{x:b,y:C}=j;return{x:b,y:C}}},...f}=pl(t,s),p={x:n,y:r},h=await i.detectOverflow(s,f),x=Li(xl(a)),u=ab(x);let N=p[u],v=p[x];if(o){const j=u==="y"?"top":"left",b=u==="y"?"bottom":"right",C=N+h[j],S=N-h[b];N=oy(C,N,S)}if(d){const j=x==="y"?"top":"left",b=x==="y"?"bottom":"right",C=v+h[j],S=v-h[b];v=oy(C,v,S)}const w=m.fn({...s,[u]:N,[x]:v});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[u]:o,[x]:d}}}}}},T3=function(t){return t===void 0&&(t={}),{options:t,fn(s){const{x:n,y:r,placement:a,rects:i,middlewareData:o}=s,{offset:d=0,mainAxis:m=!0,crossAxis:f=!0}=pl(t,s),p={x:n,y:r},h=Li(a),x=ab(h);let u=p[x],N=p[h];const v=pl(d,s),w=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(m){const C=x==="y"?"height":"width",S=i.reference[x]-i.floating[C]+w.mainAxis,R=i.reference[x]+i.reference[C]-w.mainAxis;u<S?u=S:u>R&&(u=R)}if(f){var j,b;const C=x==="y"?"width":"height",S=bk.has(xl(a)),R=i.reference[h]-i.floating[C]+(S&&((j=o.offset)==null?void 0:j[h])||0)+(S?0:w.crossAxis),_=i.reference[h]+i.reference[C]+(S?0:((b=o.offset)==null?void 0:b[h])||0)-(S?w.crossAxis:0);N<R?N=R:N>_&&(N=_)}return{[x]:u,[h]:N}}}},P3=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(s){var n,r;const{placement:a,rects:i,platform:o,elements:d}=s,{apply:m=()=>{},...f}=pl(t,s),p=await o.detectOverflow(s,f),h=xl(a),x=jd(a),u=Li(a)==="y",{width:N,height:v}=i.floating;let w,j;h==="top"||h==="bottom"?(w=h,j=x===(await(o.isRTL==null?void 0:o.isRTL(d.floating))?"start":"end")?"left":"right"):(j=h,w=x==="end"?"top":"bottom");const b=v-p.top-p.bottom,C=N-p.left-p.right,S=ro(v-p[w],b),R=ro(N-p[j],C),_=!s.middlewareData.shift;let A=S,E=R;if((n=s.middlewareData.shift)!=null&&n.enabled.x&&(E=C),(r=s.middlewareData.shift)!=null&&r.enabled.y&&(A=b),_&&!x){const O=Ca(p.left,0),D=Ca(p.right,0),P=Ca(p.top,0),L=Ca(p.bottom,0);u?E=N-2*(O!==0||D!==0?O+D:Ca(p.left,p.right)):A=v-2*(P!==0||L!==0?P+L:Ca(p.top,p.bottom))}await m({...s,availableWidth:E,availableHeight:A});const q=await o.getDimensions(d.floating);return N!==q.width||v!==q.height?{reset:{rects:!0}}:{}}}};function qf(){return typeof window<"u"}function Nd(t){return jk(t)?(t.nodeName||"").toLowerCase():"#document"}function Ea(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function zi(t){var s;return(s=(jk(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function jk(t){return qf()?t instanceof Node||t instanceof Ea(t).Node:!1}function pi(t){return qf()?t instanceof Element||t instanceof Ea(t).Element:!1}function bl(t){return qf()?t instanceof HTMLElement||t instanceof Ea(t).HTMLElement:!1}function W1(t){return!qf()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Ea(t).ShadowRoot}function Zu(t){const{overflow:s,overflowX:n,overflowY:r,display:a}=xi(t);return/auto|scroll|overlay|hidden|clip/.test(s+r+n)&&a!=="inline"&&a!=="contents"}function O3(t){return/^(table|td|th)$/.test(Nd(t))}function zf(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const L3=/transform|translate|scale|rotate|perspective|filter/,I3=/paint|layout|strict|content/,$o=t=>!!t&&t!=="none";let Ng;function ob(t){const s=pi(t)?xi(t):t;return $o(s.transform)||$o(s.translate)||$o(s.scale)||$o(s.rotate)||$o(s.perspective)||!cb()&&($o(s.backdropFilter)||$o(s.filter))||L3.test(s.willChange||"")||I3.test(s.contain||"")}function M3(t){let s=ao(t);for(;bl(s)&&!od(s);){if(ob(s))return s;if(zf(s))return null;s=ao(s)}return null}function cb(){return Ng==null&&(Ng=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ng}function od(t){return/^(html|body|#document)$/.test(Nd(t))}function xi(t){return Ea(t).getComputedStyle(t)}function Uf(t){return pi(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function ao(t){if(Nd(t)==="html")return t;const s=t.assignedSlot||t.parentNode||W1(t)&&t.host||zi(t);return W1(s)?s.host:s}function Nk(t){const s=ao(t);return od(s)?t.ownerDocument?t.ownerDocument.body:t.body:bl(s)&&Zu(s)?s:Nk(s)}function Du(t,s,n){var r;s===void 0&&(s=[]),n===void 0&&(n=!0);const a=Nk(t),i=a===((r=t.ownerDocument)==null?void 0:r.body),o=Ea(a);if(i){const d=dy(o);return s.concat(o,o.visualViewport||[],Zu(a)?a:[],d&&n?Du(d):[])}else return s.concat(a,Du(a,[],n))}function dy(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function wk(t){const s=xi(t);let n=parseFloat(s.width)||0,r=parseFloat(s.height)||0;const a=bl(t),i=a?t.offsetWidth:n,o=a?t.offsetHeight:r,d=of(n)!==i||of(r)!==o;return d&&(n=i,r=o),{width:n,height:r,$:d}}function db(t){return pi(t)?t:t.contextElement}function Jc(t){const s=db(t);if(!bl(s))return Mi(1);const n=s.getBoundingClientRect(),{width:r,height:a,$:i}=wk(s);let o=(i?of(n.width):n.width)/r,d=(i?of(n.height):n.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!d||!Number.isFinite(d))&&(d=1),{x:o,y:d}}const F3=Mi(0);function Sk(t){const s=Ea(t);return!cb()||!s.visualViewport?F3:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function B3(t,s,n){return s===void 0&&(s=!1),!n||s&&n!==Ea(t)?!1:s}function ac(t,s,n,r){s===void 0&&(s=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),i=db(t);let o=Mi(1);s&&(r?pi(r)&&(o=Jc(r)):o=Jc(t));const d=B3(i,n,r)?Sk(i):Mi(0);let m=(a.left+d.x)/o.x,f=(a.top+d.y)/o.y,p=a.width/o.x,h=a.height/o.y;if(i){const x=Ea(i),u=r&&pi(r)?Ea(r):r;let N=x,v=dy(N);for(;v&&r&&u!==N;){const w=Jc(v),j=v.getBoundingClientRect(),b=xi(v),C=j.left+(v.clientLeft+parseFloat(b.paddingLeft))*w.x,S=j.top+(v.clientTop+parseFloat(b.paddingTop))*w.y;m*=w.x,f*=w.y,p*=w.x,h*=w.y,m+=C,f+=S,N=Ea(v),v=dy(N)}}return df({width:p,height:h,x:m,y:f})}function Vf(t,s){const n=Uf(t).scrollLeft;return s?s.left+n:ac(zi(t)).left+n}function Ck(t,s){const n=t.getBoundingClientRect(),r=n.left+s.scrollLeft-Vf(t,n),a=n.top+s.scrollTop;return{x:r,y:a}}function $3(t){let{elements:s,rect:n,offsetParent:r,strategy:a}=t;const i=a==="fixed",o=zi(r),d=s?zf(s.floating):!1;if(r===o||d&&i)return n;let m={scrollLeft:0,scrollTop:0},f=Mi(1);const p=Mi(0),h=bl(r);if((h||!h&&!i)&&((Nd(r)!=="body"||Zu(o))&&(m=Uf(r)),h)){const u=ac(r);f=Jc(r),p.x=u.x+r.clientLeft,p.y=u.y+r.clientTop}const x=o&&!h&&!i?Ck(o,m):Mi(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-m.scrollLeft*f.x+p.x+x.x,y:n.y*f.y-m.scrollTop*f.y+p.y+x.y}}function q3(t){return Array.from(t.getClientRects())}function z3(t){const s=zi(t),n=Uf(t),r=t.ownerDocument.body,a=Ca(s.scrollWidth,s.clientWidth,r.scrollWidth,r.clientWidth),i=Ca(s.scrollHeight,s.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Vf(t);const d=-n.scrollTop;return xi(r).direction==="rtl"&&(o+=Ca(s.clientWidth,r.clientWidth)-a),{width:a,height:i,x:o,y:d}}const G1=25;function U3(t,s){const n=Ea(t),r=zi(t),a=n.visualViewport;let i=r.clientWidth,o=r.clientHeight,d=0,m=0;if(a){i=a.width,o=a.height;const p=cb();(!p||p&&s==="fixed")&&(d=a.offsetLeft,m=a.offsetTop)}const f=Vf(r);if(f<=0){const p=r.ownerDocument,h=p.body,x=getComputedStyle(h),u=p.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,N=Math.abs(r.clientWidth-h.clientWidth-u);N<=G1&&(i-=N)}else f<=G1&&(i+=f);return{width:i,height:o,x:d,y:m}}function V3(t,s){const n=ac(t,!0,s==="fixed"),r=n.top+t.clientTop,a=n.left+t.clientLeft,i=bl(t)?Jc(t):Mi(1),o=t.clientWidth*i.x,d=t.clientHeight*i.y,m=a*i.x,f=r*i.y;return{width:o,height:d,x:m,y:f}}function K1(t,s,n){let r;if(s==="viewport")r=U3(t,n);else if(s==="document")r=z3(zi(t));else if(pi(s))r=V3(s,n);else{const a=Sk(t);r={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return df(r)}function Ak(t,s){const n=ao(t);return n===s||!pi(n)||od(n)?!1:xi(n).position==="fixed"||Ak(n,s)}function H3(t,s){const n=s.get(t);if(n)return n;let r=Du(t,[],!1).filter(d=>pi(d)&&Nd(d)!=="body"),a=null;const i=xi(t).position==="fixed";let o=i?ao(t):t;for(;pi(o)&&!od(o);){const d=xi(o),m=ob(o);!m&&d.position==="fixed"&&(a=null),(i?!m&&!a:!m&&d.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||Zu(o)&&!m&&Ak(t,o))?r=r.filter(p=>p!==o):a=d,o=ao(o)}return s.set(t,r),r}function W3(t){let{element:s,boundary:n,rootBoundary:r,strategy:a}=t;const o=[...n==="clippingAncestors"?zf(s)?[]:H3(s,this._c):[].concat(n),r],d=K1(s,o[0],a);let m=d.top,f=d.right,p=d.bottom,h=d.left;for(let x=1;x<o.length;x++){const u=K1(s,o[x],a);m=Ca(u.top,m),f=ro(u.right,f),p=ro(u.bottom,p),h=Ca(u.left,h)}return{width:f-h,height:p-m,x:h,y:m}}function G3(t){const{width:s,height:n}=wk(t);return{width:s,height:n}}function K3(t,s,n){const r=bl(s),a=zi(s),i=n==="fixed",o=ac(t,!0,i,s);let d={scrollLeft:0,scrollTop:0};const m=Mi(0);function f(){m.x=Vf(a)}if(r||!r&&!i)if((Nd(s)!=="body"||Zu(a))&&(d=Uf(s)),r){const u=ac(s,!0,i,s);m.x=u.x+s.clientLeft,m.y=u.y+s.clientTop}else a&&f();i&&!r&&a&&f();const p=a&&!r&&!i?Ck(a,d):Mi(0),h=o.left+d.scrollLeft-m.x-p.x,x=o.top+d.scrollTop-m.y-p.y;return{x:h,y:x,width:o.width,height:o.height}}function wg(t){return xi(t).position==="static"}function Y1(t,s){if(!bl(t)||xi(t).position==="fixed")return null;if(s)return s(t);let n=t.offsetParent;return zi(t)===n&&(n=n.ownerDocument.body),n}function kk(t,s){const n=Ea(t);if(zf(t))return n;if(!bl(t)){let a=ao(t);for(;a&&!od(a);){if(pi(a)&&!wg(a))return a;a=ao(a)}return n}let r=Y1(t,s);for(;r&&O3(r)&&wg(r);)r=Y1(r,s);return r&&od(r)&&wg(r)&&!ob(r)?n:r||M3(t)||n}const Y3=async function(t){const s=this.getOffsetParent||kk,n=this.getDimensions,r=await n(t.floating);return{reference:K3(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Z3(t){return xi(t).direction==="rtl"}const Q3={convertOffsetParentRelativeRectToViewportRelativeRect:$3,getDocumentElement:zi,getClippingRect:W3,getOffsetParent:kk,getElementRects:Y3,getClientRects:q3,getDimensions:G3,getScale:Jc,isElement:pi,isRTL:Z3};function Dk(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function X3(t,s){let n=null,r;const a=zi(t);function i(){var d;clearTimeout(r),(d=n)==null||d.disconnect(),n=null}function o(d,m){d===void 0&&(d=!1),m===void 0&&(m=1),i();const f=t.getBoundingClientRect(),{left:p,top:h,width:x,height:u}=f;if(d||s(),!x||!u)return;const N=mm(h),v=mm(a.clientWidth-(p+x)),w=mm(a.clientHeight-(h+u)),j=mm(p),C={rootMargin:-N+"px "+-v+"px "+-w+"px "+-j+"px",threshold:Ca(0,ro(1,m))||1};let S=!0;function R(_){const A=_[0].intersectionRatio;if(A!==m){if(!S)return o();A?o(!1,A):r=setTimeout(()=>{o(!1,1e-7)},1e3)}A===1&&!Dk(f,t.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(R,{...C,root:a.ownerDocument})}catch{n=new IntersectionObserver(R,C)}n.observe(t)}return o(!0),i}function J3(t,s,n,r){r===void 0&&(r={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:m=!1}=r,f=db(t),p=a||i?[...f?Du(f):[],...s?Du(s):[]]:[];p.forEach(j=>{a&&j.addEventListener("scroll",n,{passive:!0}),i&&j.addEventListener("resize",n)});const h=f&&d?X3(f,n):null;let x=-1,u=null;o&&(u=new ResizeObserver(j=>{let[b]=j;b&&b.target===f&&u&&s&&(u.unobserve(s),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var C;(C=u)==null||C.observe(s)})),n()}),f&&!m&&u.observe(f),s&&u.observe(s));let N,v=m?ac(t):null;m&&w();function w(){const j=ac(t);v&&!Dk(v,j)&&n(),v=j,N=requestAnimationFrame(w)}return n(),()=>{var j;p.forEach(b=>{a&&b.removeEventListener("scroll",n),i&&b.removeEventListener("resize",n)}),h==null||h(),(j=u)==null||j.disconnect(),u=null,m&&cancelAnimationFrame(N)}}const eF=E3,tF=_3,sF=k3,nF=P3,rF=D3,Z1=A3,aF=T3,iF=(t,s,n)=>{const r=new Map,a={platform:Q3,...n},i={...a.platform,_c:r};return C3(t,s,{...a,platform:i})};var lF=typeof document<"u",oF=function(){},Fm=lF?g.useLayoutEffect:oF;function uf(t,s){if(t===s)return!0;if(typeof t!=typeof s)return!1;if(typeof t=="function"&&t.toString()===s.toString())return!0;let n,r,a;if(t&&s&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==s.length)return!1;for(r=n;r--!==0;)if(!uf(t[r],s[r]))return!1;return!0}if(a=Object.keys(t),n=a.length,n!==Object.keys(s).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(s,a[r]))return!1;for(r=n;r--!==0;){const i=a[r];if(!(i==="_owner"&&t.$$typeof)&&!uf(t[i],s[i]))return!1}return!0}return t!==t&&s!==s}function Rk(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Q1(t,s){const n=Rk(t);return Math.round(s*n)/n}function Sg(t){const s=g.useRef(t);return Fm(()=>{s.current=t}),s}function cF(t){t===void 0&&(t={});const{placement:s="bottom",strategy:n="absolute",middleware:r=[],platform:a,elements:{reference:i,floating:o}={},transform:d=!0,whileElementsMounted:m,open:f}=t,[p,h]=g.useState({x:0,y:0,strategy:n,placement:s,middlewareData:{},isPositioned:!1}),[x,u]=g.useState(r);uf(x,r)||u(r);const[N,v]=g.useState(null),[w,j]=g.useState(null),b=g.useCallback(U=>{U!==_.current&&(_.current=U,v(U))},[]),C=g.useCallback(U=>{U!==A.current&&(A.current=U,j(U))},[]),S=i||N,R=o||w,_=g.useRef(null),A=g.useRef(null),E=g.useRef(p),q=m!=null,O=Sg(m),D=Sg(a),P=Sg(f),L=g.useCallback(()=>{if(!_.current||!A.current)return;const U={placement:s,strategy:n,middleware:x};D.current&&(U.platform=D.current),iF(_.current,A.current,U).then(M=>{const z={...M,isPositioned:P.current!==!1};$.current&&!uf(E.current,z)&&(E.current=z,zu.flushSync(()=>{h(z)}))})},[x,s,n,D,P]);Fm(()=>{f===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,h(U=>({...U,isPositioned:!1})))},[f]);const $=g.useRef(!1);Fm(()=>($.current=!0,()=>{$.current=!1}),[]),Fm(()=>{if(S&&(_.current=S),R&&(A.current=R),S&&R){if(O.current)return O.current(S,R,L);L()}},[S,R,L,O,q]);const Y=g.useMemo(()=>({reference:_,floating:A,setReference:b,setFloating:C}),[b,C]),Z=g.useMemo(()=>({reference:S,floating:R}),[S,R]),W=g.useMemo(()=>{const U={position:n,left:0,top:0};if(!Z.floating)return U;const M=Q1(Z.floating,p.x),z=Q1(Z.floating,p.y);return d?{...U,transform:"translate("+M+"px, "+z+"px)",...Rk(Z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:z}},[n,d,Z.floating,p.x,p.y]);return g.useMemo(()=>({...p,update:L,refs:Y,elements:Z,floatingStyles:W}),[p,L,Y,Z,W])}const dF=t=>{function s(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:a}=typeof t=="function"?t(n):t;return r&&s(r)?r.current!=null?Z1({element:r.current,padding:a}).fn(n):{}:r?Z1({element:r,padding:a}).fn(n):{}}}},uF=(t,s)=>{const n=eF(t);return{name:n.name,fn:n.fn,options:[t,s]}},hF=(t,s)=>{const n=tF(t);return{name:n.name,fn:n.fn,options:[t,s]}},mF=(t,s)=>({fn:aF(t).fn,options:[t,s]}),fF=(t,s)=>{const n=sF(t);return{name:n.name,fn:n.fn,options:[t,s]}},pF=(t,s)=>{const n=nF(t);return{name:n.name,fn:n.fn,options:[t,s]}},xF=(t,s)=>{const n=rF(t);return{name:n.name,fn:n.fn,options:[t,s]}},gF=(t,s)=>{const n=dF(t);return{name:n.name,fn:n.fn,options:[t,s]}};var vF="Arrow",Ek=g.forwardRef((t,s)=>{const{children:n,width:r=10,height:a=5,...i}=t;return e.jsx(js.svg,{...i,ref:s,width:r,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:e.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ek.displayName=vF;var yF=Ek,ub="Popper",[_k,oo]=ga(ub),[bF,Tk]=_k(ub),Pk=t=>{const{__scopePopper:s,children:n}=t,[r,a]=g.useState(null);return e.jsx(bF,{scope:s,anchor:r,onAnchorChange:a,children:n})};Pk.displayName=ub;var Ok="PopperAnchor",Lk=g.forwardRef((t,s)=>{const{__scopePopper:n,virtualRef:r,...a}=t,i=Tk(Ok,n),o=g.useRef(null),d=Gs(s,o),m=g.useRef(null);return g.useEffect(()=>{const f=m.current;m.current=(r==null?void 0:r.current)||o.current,f!==m.current&&i.onAnchorChange(m.current)}),r?null:e.jsx(js.div,{...a,ref:d})});Lk.displayName=Ok;var hb="PopperContent",[jF,NF]=_k(hb),Ik=g.forwardRef((t,s)=>{var X,J,ae,le,xe,ce;const{__scopePopper:n,side:r="bottom",sideOffset:a=0,align:i="center",alignOffset:o=0,arrowPadding:d=0,avoidCollisions:m=!0,collisionBoundary:f=[],collisionPadding:p=0,sticky:h="partial",hideWhenDetached:x=!1,updatePositionStrategy:u="optimized",onPlaced:N,...v}=t,w=Tk(hb,n),[j,b]=g.useState(null),C=Gs(s,ve=>b(ve)),[S,R]=g.useState(null),_=Qy(S),A=(_==null?void 0:_.width)??0,E=(_==null?void 0:_.height)??0,q=r+(i!=="center"?"-"+i:""),O=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},D=Array.isArray(f)?f:[f],P=D.length>0,L={padding:O,boundary:D.filter(SF),altBoundary:P},{refs:$,floatingStyles:Y,placement:Z,isPositioned:W,middlewareData:U}=cF({strategy:"fixed",placement:q,whileElementsMounted:(...ve)=>J3(...ve,{animationFrame:u==="always"}),elements:{reference:w.anchor},middleware:[uF({mainAxis:a+E,alignmentAxis:o}),m&&hF({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?mF():void 0,...L}),m&&fF({...L}),pF({...L,apply:({elements:ve,rects:Pe,availableWidth:et,availableHeight:kt})=>{const{width:vt,height:ee}=Pe.reference,ge=ve.floating.style;ge.setProperty("--radix-popper-available-width",`${et}px`),ge.setProperty("--radix-popper-available-height",`${kt}px`),ge.setProperty("--radix-popper-anchor-width",`${vt}px`),ge.setProperty("--radix-popper-anchor-height",`${ee}px`)}}),S&&gF({element:S,padding:d}),CF({arrowWidth:A,arrowHeight:E}),x&&xF({strategy:"referenceHidden",...L})]}),[M,z]=Bk(Z),T=Sr(N);cr(()=>{W&&(T==null||T())},[W,T]);const I=(X=U.arrow)==null?void 0:X.x,B=(J=U.arrow)==null?void 0:J.y,G=((ae=U.arrow)==null?void 0:ae.centerOffset)!==0,[K,H]=g.useState();return cr(()=>{j&&H(window.getComputedStyle(j).zIndex)},[j]),e.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:W?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:K,"--radix-popper-transform-origin":[(le=U.transformOrigin)==null?void 0:le.x,(xe=U.transformOrigin)==null?void 0:xe.y].join(" "),...((ce=U.hide)==null?void 0:ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(jF,{scope:n,placedSide:M,onArrowChange:R,arrowX:I,arrowY:B,shouldHideArrow:G,children:e.jsx(js.div,{"data-side":M,"data-align":z,...v,ref:C,style:{...v.style,animation:W?void 0:"none"}})})})});Ik.displayName=hb;var Mk="PopperArrow",wF={top:"bottom",right:"left",bottom:"top",left:"right"},Fk=g.forwardRef(function(s,n){const{__scopePopper:r,...a}=s,i=NF(Mk,r),o=wF[i.placedSide];return e.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:e.jsx(yF,{...a,ref:n,style:{...a.style,display:"block"}})})});Fk.displayName=Mk;function SF(t){return t!==null}var CF=t=>({name:"transformOrigin",options:t,fn(s){var w,j,b;const{placement:n,rects:r,middlewareData:a}=s,o=((w=a.arrow)==null?void 0:w.centerOffset)!==0,d=o?0:t.arrowWidth,m=o?0:t.arrowHeight,[f,p]=Bk(n),h={start:"0%",center:"50%",end:"100%"}[p],x=(((j=a.arrow)==null?void 0:j.x)??0)+d/2,u=(((b=a.arrow)==null?void 0:b.y)??0)+m/2;let N="",v="";return f==="bottom"?(N=o?h:`${x}px`,v=`${-m}px`):f==="top"?(N=o?h:`${x}px`,v=`${r.floating.height+m}px`):f==="right"?(N=`${-m}px`,v=o?h:`${u}px`):f==="left"&&(N=`${r.floating.width+m}px`,v=o?h:`${u}px`),{data:{x:N,y:v}}}});function Bk(t){const[s,n="center"]=t.split("-");return[s,n]}var Hf=Pk,Qu=Lk,Wf=Ik,Gf=Fk,AF="Portal",wd=g.forwardRef((t,s)=>{var d;const{container:n,...r}=t,[a,i]=g.useState(!1);cr(()=>i(!0),[]);const o=n||a&&((d=globalThis==null?void 0:globalThis.document)==null?void 0:d.body);return o?Hy.createPortal(e.jsx(js.div,{...r,ref:s}),o):null});wd.displayName=AF;var Cg="rovingFocusGroup.onEntryFocus",kF={bubbles:!1,cancelable:!0},Xu="RovingFocusGroup",[uy,$k,DF]=rb(Xu),[RF,Kf]=ga(Xu,[DF]),[EF,_F]=RF(Xu),qk=g.forwardRef((t,s)=>e.jsx(uy.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(uy.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(TF,{...t,ref:s})})}));qk.displayName=Xu;var TF=g.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:d,onCurrentTabStopIdChange:m,onEntryFocus:f,preventScrollOnEntryFocus:p=!1,...h}=t,x=g.useRef(null),u=Gs(s,x),N=Ku(i),[v,w]=Bi({prop:o,defaultProp:d??null,onChange:m,caller:Xu}),[j,b]=g.useState(!1),C=Sr(f),S=$k(n),R=g.useRef(!1),[_,A]=g.useState(0);return g.useEffect(()=>{const E=x.current;if(E)return E.addEventListener(Cg,C),()=>E.removeEventListener(Cg,C)},[C]),e.jsx(EF,{scope:n,orientation:r,dir:N,loop:a,currentTabStopId:v,onItemFocus:g.useCallback(E=>w(E),[w]),onItemShiftTab:g.useCallback(()=>b(!0),[]),onFocusableItemAdd:g.useCallback(()=>A(E=>E+1),[]),onFocusableItemRemove:g.useCallback(()=>A(E=>E-1),[]),children:e.jsx(js.div,{tabIndex:j||_===0?-1:0,"data-orientation":r,...h,ref:u,style:{outline:"none",...t.style},onMouseDown:Kt(t.onMouseDown,()=>{R.current=!0}),onFocus:Kt(t.onFocus,E=>{const q=!R.current;if(E.target===E.currentTarget&&q&&!j){const O=new CustomEvent(Cg,kF);if(E.currentTarget.dispatchEvent(O),!O.defaultPrevented){const D=S().filter(Z=>Z.focusable),P=D.find(Z=>Z.active),L=D.find(Z=>Z.id===v),Y=[P,L,...D].filter(Boolean).map(Z=>Z.ref.current);Vk(Y,p)}}R.current=!1}),onBlur:Kt(t.onBlur,()=>b(!1))})})}),zk="RovingFocusGroupItem",Uk=g.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...d}=t,m=Ar(),f=i||m,p=_F(zk,n),h=p.currentTabStopId===f,x=$k(n),{onFocusableItemAdd:u,onFocusableItemRemove:N,currentTabStopId:v}=p;return g.useEffect(()=>{if(r)return u(),()=>N()},[r,u,N]),e.jsx(uy.ItemSlot,{scope:n,id:f,focusable:r,active:a,children:e.jsx(js.span,{tabIndex:h?0:-1,"data-orientation":p.orientation,...d,ref:s,onMouseDown:Kt(t.onMouseDown,w=>{r?p.onItemFocus(f):w.preventDefault()}),onFocus:Kt(t.onFocus,()=>p.onItemFocus(f)),onKeyDown:Kt(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const j=LF(w,p.orientation,p.dir);if(j!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let C=x().filter(S=>S.focusable).map(S=>S.ref.current);if(j==="last")C.reverse();else if(j==="prev"||j==="next"){j==="prev"&&C.reverse();const S=C.indexOf(w.currentTarget);C=p.loop?IF(C,S+1):C.slice(S+1)}setTimeout(()=>Vk(C))}}),children:typeof o=="function"?o({isCurrentTabStop:h,hasTabStop:v!=null}):o})})});Uk.displayName=zk;var PF={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function OF(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function LF(t,s,n){const r=OF(t.key,n);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return PF[r]}function Vk(t,s=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:s}),document.activeElement!==n))return}function IF(t,s){return t.map((n,r)=>t[(s+r)%t.length])}var Hk=qk,Wk=Uk;function MF(t){const s=FF(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find($F);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function FF(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=zF(a),d=qF(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Xr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var BF=Symbol("radix.slottable");function $F(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===BF}function qF(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function zF(t){var r,a;let s=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var UF=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},$c=new WeakMap,fm=new WeakMap,pm={},Ag=0,Gk=function(t){return t&&(t.host||Gk(t.parentNode))},VF=function(t,s){return s.map(function(n){if(t.contains(n))return n;var r=Gk(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},HF=function(t,s,n,r){var a=VF(s,Array.isArray(t)?t:[t]);pm[n]||(pm[n]=new WeakMap);var i=pm[n],o=[],d=new Set,m=new Set(a),f=function(h){!h||d.has(h)||(d.add(h),f(h.parentNode))};a.forEach(f);var p=function(h){!h||m.has(h)||Array.prototype.forEach.call(h.children,function(x){if(d.has(x))p(x);else try{var u=x.getAttribute(r),N=u!==null&&u!=="false",v=($c.get(x)||0)+1,w=(i.get(x)||0)+1;$c.set(x,v),i.set(x,w),o.push(x),v===1&&N&&fm.set(x,!0),w===1&&x.setAttribute(n,"true"),N||x.setAttribute(r,"true")}catch(j){console.error("aria-hidden: cannot operate on ",x,j)}})};return p(s),d.clear(),Ag++,function(){o.forEach(function(h){var x=$c.get(h)-1,u=i.get(h)-1;$c.set(h,x),i.set(h,u),x||(fm.has(h)||h.removeAttribute(r),fm.delete(h)),u||h.removeAttribute(n)}),Ag--,Ag||($c=new WeakMap,$c=new WeakMap,fm=new WeakMap,pm={})}},Yf=function(t,s,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),a=UF(t);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),HF(r,a,n,"aria-hidden")):function(){return null}},Ti=function(){return Ti=Object.assign||function(s){for(var n,r=1,a=arguments.length;r<a;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=n[i])}return s},Ti.apply(this,arguments)};function Kk(t,s){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&s.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(t);a<r.length;a++)s.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(t,r[a])&&(n[r[a]]=t[r[a]]);return n}function WF(t,s,n){if(n||arguments.length===2)for(var r=0,a=s.length,i;r<a;r++)(i||!(r in s))&&(i||(i=Array.prototype.slice.call(s,0,r)),i[r]=s[r]);return t.concat(i||Array.prototype.slice.call(s))}var Bm="right-scroll-bar-position",$m="width-before-scroll-bar",GF="with-scroll-bars-hidden",KF="--removed-body-scroll-bar-size";function kg(t,s){return typeof t=="function"?t(s):t&&(t.current=s),t}function YF(t,s){var n=g.useState(function(){return{value:t,callback:s,facade:{get current(){return n.value},set current(r){var a=n.value;a!==r&&(n.value=r,n.callback(r,a))}}}})[0];return n.callback=s,n.facade}var ZF=typeof window<"u"?g.useLayoutEffect:g.useEffect,X1=new WeakMap;function QF(t,s){var n=YF(null,function(r){return t.forEach(function(a){return kg(a,r)})});return ZF(function(){var r=X1.get(n);if(r){var a=new Set(r),i=new Set(t),o=n.current;a.forEach(function(d){i.has(d)||kg(d,null)}),i.forEach(function(d){a.has(d)||kg(d,o)})}X1.set(n,t)},[t]),n}function XF(t){return t}function JF(t,s){s===void 0&&(s=XF);var n=[],r=!1,a={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(i){var o=s(i,r);return n.push(o),function(){n=n.filter(function(d){return d!==o})}},assignSyncMedium:function(i){for(r=!0;n.length;){var o=n;n=[],o.forEach(i)}n={push:function(d){return i(d)},filter:function(){return n}}},assignMedium:function(i){r=!0;var o=[];if(n.length){var d=n;n=[],d.forEach(i),o=n}var m=function(){var p=o;o=[],p.forEach(i)},f=function(){return Promise.resolve().then(m)};f(),n={push:function(p){o.push(p),f()},filter:function(p){return o=o.filter(p),n}}}};return a}function e6(t){t===void 0&&(t={});var s=JF(null);return s.options=Ti({async:!0,ssr:!1},t),s}var Yk=function(t){var s=t.sideCar,n=Kk(t,["sideCar"]);if(!s)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=s.read();if(!r)throw new Error("Sidecar medium not found");return g.createElement(r,Ti({},n))};Yk.isSideCarExport=!0;function t6(t,s){return t.useMedium(s),Yk}var Zk=e6(),Dg=function(){},Zf=g.forwardRef(function(t,s){var n=g.useRef(null),r=g.useState({onScrollCapture:Dg,onWheelCapture:Dg,onTouchMoveCapture:Dg}),a=r[0],i=r[1],o=t.forwardProps,d=t.children,m=t.className,f=t.removeScrollBar,p=t.enabled,h=t.shards,x=t.sideCar,u=t.noRelative,N=t.noIsolation,v=t.inert,w=t.allowPinchZoom,j=t.as,b=j===void 0?"div":j,C=t.gapMode,S=Kk(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),R=x,_=QF([n,s]),A=Ti(Ti({},S),a);return g.createElement(g.Fragment,null,p&&g.createElement(R,{sideCar:Zk,removeScrollBar:f,shards:h,noRelative:u,noIsolation:N,inert:v,setCallbacks:i,allowPinchZoom:!!w,lockRef:n,gapMode:C}),o?g.cloneElement(g.Children.only(d),Ti(Ti({},A),{ref:_})):g.createElement(b,Ti({},A,{className:m,ref:_}),d))});Zf.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Zf.classNames={fullWidth:$m,zeroRight:Bm};var s6=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function n6(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var s=s6();return s&&t.setAttribute("nonce",s),t}function r6(t,s){t.styleSheet?t.styleSheet.cssText=s:t.appendChild(document.createTextNode(s))}function a6(t){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(t)}var i6=function(){var t=0,s=null;return{add:function(n){t==0&&(s=n6())&&(r6(s,n),a6(s)),t++},remove:function(){t--,!t&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},l6=function(){var t=i6();return function(s,n){g.useEffect(function(){return t.add(s),function(){t.remove()}},[s&&n])}},Qk=function(){var t=l6(),s=function(n){var r=n.styles,a=n.dynamic;return t(r,a),null};return s},o6={left:0,top:0,right:0,gap:0},Rg=function(t){return parseInt(t||"",10)||0},c6=function(t){var s=window.getComputedStyle(document.body),n=s[t==="padding"?"paddingLeft":"marginLeft"],r=s[t==="padding"?"paddingTop":"marginTop"],a=s[t==="padding"?"paddingRight":"marginRight"];return[Rg(n),Rg(r),Rg(a)]},d6=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return o6;var s=c6(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:s[0],top:s[1],right:s[2],gap:Math.max(0,r-n+s[2]-s[0])}},u6=Qk(),ed="data-scroll-locked",h6=function(t,s,n,r){var a=t.left,i=t.top,o=t.right,d=t.gap;return n===void 0&&(n="margin"),`
.`.concat(GF,` {
overflow: hidden `).concat(r,`;
padding-right: `).concat(d,"px ").concat(r,`;
}
body[`).concat(ed,`] {
overflow: hidden `).concat(r,`;
overscroll-behavior: contain;
`).concat([s&&"position: relative ".concat(r,";"),n==="margin"&&`
padding-left: `.concat(a,`px;
padding-top: `).concat(i,`px;
padding-right: `).concat(o,`px;
margin-left:0;
margin-top:0;
margin-right: `).concat(d,"px ").concat(r,`;
`),n==="padding"&&"padding-right: ".concat(d,"px ").concat(r,";")].filter(Boolean).join(""),`
}
.`).concat(Bm,` {
right: `).concat(d,"px ").concat(r,`;
}
.`).concat($m,` {
margin-right: `).concat(d,"px ").concat(r,`;
}
.`).concat(Bm," .").concat(Bm,` {
right: 0 `).concat(r,`;
}
.`).concat($m," .").concat($m,` {
margin-right: 0 `).concat(r,`;
}
body[`).concat(ed,`] {
`).concat(KF,": ").concat(d,`px;
}
`)},J1=function(){var t=parseInt(document.body.getAttribute(ed)||"0",10);return isFinite(t)?t:0},m6=function(){g.useEffect(function(){return document.body.setAttribute(ed,(J1()+1).toString()),function(){var t=J1()-1;t<=0?document.body.removeAttribute(ed):document.body.setAttribute(ed,t.toString())}},[])},f6=function(t){var s=t.noRelative,n=t.noImportant,r=t.gapMode,a=r===void 0?"margin":r;m6();var i=g.useMemo(function(){return d6(a)},[a]);return g.createElement(u6,{styles:h6(i,!s,a,n?"":"!important")})},hy=!1;if(typeof window<"u")try{var xm=Object.defineProperty({},"passive",{get:function(){return hy=!0,!0}});window.addEventListener("test",xm,xm),window.removeEventListener("test",xm,xm)}catch{hy=!1}var qc=hy?{passive:!1}:!1,p6=function(t){return t.tagName==="TEXTAREA"},Xk=function(t,s){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[s]!=="hidden"&&!(n.overflowY===n.overflowX&&!p6(t)&&n[s]==="visible")},x6=function(t){return Xk(t,"overflowY")},g6=function(t){return Xk(t,"overflowX")},eS=function(t,s){var n=s.ownerDocument,r=s;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=Jk(t,r);if(a){var i=eD(t,r),o=i[1],d=i[2];if(o>d)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},v6=function(t){var s=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[s,n,r]},y6=function(t){var s=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[s,n,r]},Jk=function(t,s){return t==="v"?x6(s):g6(s)},eD=function(t,s){return t==="v"?v6(s):y6(s)},b6=function(t,s){return t==="h"&&s==="rtl"?-1:1},j6=function(t,s,n,r,a){var i=b6(t,window.getComputedStyle(s).direction),o=i*r,d=n.target,m=s.contains(d),f=!1,p=o>0,h=0,x=0;do{if(!d)break;var u=eD(t,d),N=u[0],v=u[1],w=u[2],j=v-w-i*N;(N||j)&&Jk(t,d)&&(h+=j,x+=N);var b=d.parentNode;d=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!m&&d!==document.body||m&&(s.contains(d)||s===d));return(p&&Math.abs(h)<1||!p&&Math.abs(x)<1)&&(f=!0),f},gm=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},tS=function(t){return[t.deltaX,t.deltaY]},sS=function(t){return t&&"current"in t?t.current:t},N6=function(t,s){return t[0]===s[0]&&t[1]===s[1]},w6=function(t){return`
.block-interactivity-`.concat(t,` {pointer-events: none;}
.allow-interactivity-`).concat(t,` {pointer-events: all;}
`)},S6=0,zc=[];function C6(t){var s=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),a=g.useState(S6++)[0],i=g.useState(Qk)[0],o=g.useRef(t);g.useEffect(function(){o.current=t},[t]),g.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var v=WF([t.lockRef.current],(t.shards||[]).map(sS),!0).filter(Boolean);return v.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),v.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var d=g.useCallback(function(v,w){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var j=gm(v),b=n.current,C="deltaX"in v?v.deltaX:b[0]-j[0],S="deltaY"in v?v.deltaY:b[1]-j[1],R,_=v.target,A=Math.abs(C)>Math.abs(S)?"h":"v";if("touches"in v&&A==="h"&&_.type==="range")return!1;var E=window.getSelection(),q=E&&E.anchorNode,O=q?q===_||q.contains(_):!1;if(O)return!1;var D=eS(A,_);if(!D)return!0;if(D?R=A:(R=A==="v"?"h":"v",D=eS(A,_)),!D)return!1;if(!r.current&&"changedTouches"in v&&(C||S)&&(r.current=R),!R)return!0;var P=r.current||R;return j6(P,w,v,P==="h"?C:S)},[]),m=g.useCallback(function(v){var w=v;if(!(!zc.length||zc[zc.length-1]!==i)){var j="deltaY"in w?tS(w):gm(w),b=s.current.filter(function(R){return R.name===w.type&&(R.target===w.target||w.target===R.shadowParent)&&N6(R.delta,j)})[0];if(b&&b.should){w.cancelable&&w.preventDefault();return}if(!b){var C=(o.current.shards||[]).map(sS).filter(Boolean).filter(function(R){return R.contains(w.target)}),S=C.length>0?d(w,C[0]):!o.current.noIsolation;S&&w.cancelable&&w.preventDefault()}}},[]),f=g.useCallback(function(v,w,j,b){var C={name:v,delta:w,target:j,should:b,shadowParent:A6(j)};s.current.push(C),setTimeout(function(){s.current=s.current.filter(function(S){return S!==C})},1)},[]),p=g.useCallback(function(v){n.current=gm(v),r.current=void 0},[]),h=g.useCallback(function(v){f(v.type,tS(v),v.target,d(v,t.lockRef.current))},[]),x=g.useCallback(function(v){f(v.type,gm(v),v.target,d(v,t.lockRef.current))},[]);g.useEffect(function(){return zc.push(i),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:x}),document.addEventListener("wheel",m,qc),document.addEventListener("touchmove",m,qc),document.addEventListener("touchstart",p,qc),function(){zc=zc.filter(function(v){return v!==i}),document.removeEventListener("wheel",m,qc),document.removeEventListener("touchmove",m,qc),document.removeEventListener("touchstart",p,qc)}},[]);var u=t.removeScrollBar,N=t.inert;return g.createElement(g.Fragment,null,N?g.createElement(i,{styles:w6(a)}):null,u?g.createElement(f6,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function A6(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const k6=t6(Zk,C6);var Ju=g.forwardRef(function(t,s){return g.createElement(Zf,Ti({},t,{ref:s,sideCar:k6}))});Ju.classNames=Zf.classNames;var my=["Enter"," "],D6=["ArrowDown","PageUp","Home"],tD=["ArrowUp","PageDown","End"],R6=[...D6,...tD],E6={ltr:[...my,"ArrowRight"],rtl:[...my,"ArrowLeft"]},_6={ltr:["ArrowLeft"],rtl:["ArrowRight"]},eh="Menu",[Ru,T6,P6]=rb(eh),[mc,sD]=ga(eh,[P6,oo,Kf]),Qf=oo(),nD=Kf(),[O6,fc]=mc(eh),[L6,th]=mc(eh),rD=t=>{const{__scopeMenu:s,open:n=!1,children:r,dir:a,onOpenChange:i,modal:o=!0}=t,d=Qf(s),[m,f]=g.useState(null),p=g.useRef(!1),h=Sr(i),x=Ku(a);return g.useEffect(()=>{const u=()=>{p.current=!0,document.addEventListener("pointerdown",N,{capture:!0,once:!0}),document.addEventListener("pointermove",N,{capture:!0,once:!0})},N=()=>p.current=!1;return document.addEventListener("keydown",u,{capture:!0}),()=>{document.removeEventListener("keydown",u,{capture:!0}),document.removeEventListener("pointerdown",N,{capture:!0}),document.removeEventListener("pointermove",N,{capture:!0})}},[]),e.jsx(Hf,{...d,children:e.jsx(O6,{scope:s,open:n,onOpenChange:h,content:m,onContentChange:f,children:e.jsx(L6,{scope:s,onClose:g.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:p,dir:x,modal:o,children:r})})})};rD.displayName=eh;var I6="MenuAnchor",mb=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t,a=Qf(n);return e.jsx(Qu,{...a,...r,ref:s})});mb.displayName=I6;var fb="MenuPortal",[M6,aD]=mc(fb,{forceMount:void 0}),iD=t=>{const{__scopeMenu:s,forceMount:n,children:r,container:a}=t,i=fc(fb,s);return e.jsx(M6,{scope:s,forceMount:n,children:e.jsx(Dr,{present:n||i.open,children:e.jsx(wd,{asChild:!0,container:a,children:r})})})};iD.displayName=fb;var Wa="MenuContent",[F6,pb]=mc(Wa),lD=g.forwardRef((t,s)=>{const n=aD(Wa,t.__scopeMenu),{forceMount:r=n.forceMount,...a}=t,i=fc(Wa,t.__scopeMenu),o=th(Wa,t.__scopeMenu);return e.jsx(Ru.Provider,{scope:t.__scopeMenu,children:e.jsx(Dr,{present:r||i.open,children:e.jsx(Ru.Slot,{scope:t.__scopeMenu,children:o.modal?e.jsx(B6,{...a,ref:s}):e.jsx($6,{...a,ref:s})})})})}),B6=g.forwardRef((t,s)=>{const n=fc(Wa,t.__scopeMenu),r=g.useRef(null),a=Gs(s,r);return g.useEffect(()=>{const i=r.current;if(i)return Yf(i)},[]),e.jsx(xb,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Kt(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),$6=g.forwardRef((t,s)=>{const n=fc(Wa,t.__scopeMenu);return e.jsx(xb,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),q6=MF("MenuContent.ScrollLock"),xb=g.forwardRef((t,s)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:a,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:d,onEntryFocus:m,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:h,onInteractOutside:x,onDismiss:u,disableOutsideScroll:N,...v}=t,w=fc(Wa,n),j=th(Wa,n),b=Qf(n),C=nD(n),S=T6(n),[R,_]=g.useState(null),A=g.useRef(null),E=Gs(s,A,w.onContentChange),q=g.useRef(0),O=g.useRef(""),D=g.useRef(0),P=g.useRef(null),L=g.useRef("right"),$=g.useRef(0),Y=N?Ju:g.Fragment,Z=N?{as:q6,allowPinchZoom:!0}:void 0,W=M=>{var X,J;const z=O.current+M,T=S().filter(ae=>!ae.disabled),I=document.activeElement,B=(X=T.find(ae=>ae.ref.current===I))==null?void 0:X.textValue,G=T.map(ae=>ae.textValue),K=J6(G,z,B),H=(J=T.find(ae=>ae.textValue===K))==null?void 0:J.ref.current;(function ae(le){O.current=le,window.clearTimeout(q.current),le!==""&&(q.current=window.setTimeout(()=>ae(""),1e3))})(z),H&&setTimeout(()=>H.focus())};g.useEffect(()=>()=>window.clearTimeout(q.current),[]),$f();const U=g.useCallback(M=>{var T,I;return L.current===((T=P.current)==null?void 0:T.side)&&t8(M,(I=P.current)==null?void 0:I.area)},[]);return e.jsx(F6,{scope:n,searchRef:O,onItemEnter:g.useCallback(M=>{U(M)&&M.preventDefault()},[U]),onItemLeave:g.useCallback(M=>{var z;U(M)||((z=A.current)==null||z.focus(),_(null))},[U]),onTriggerLeave:g.useCallback(M=>{U(M)&&M.preventDefault()},[U]),pointerGraceTimerRef:D,onPointerGraceIntentChange:g.useCallback(M=>{P.current=M},[]),children:e.jsx(Y,{...Z,children:e.jsx(Yu,{asChild:!0,trapped:a,onMountAutoFocus:Kt(i,M=>{var z;M.preventDefault(),(z=A.current)==null||z.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:e.jsx(bd,{asChild:!0,disableOutsidePointerEvents:d,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:h,onInteractOutside:x,onDismiss:u,children:e.jsx(Hk,{asChild:!0,...C,dir:j.dir,orientation:"vertical",loop:r,currentTabStopId:R,onCurrentTabStopIdChange:_,onEntryFocus:Kt(m,M=>{j.isUsingKeyboardRef.current||M.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(Wf,{role:"menu","aria-orientation":"vertical","data-state":wD(w.open),"data-radix-menu-content":"",dir:j.dir,...b,...v,ref:E,style:{outline:"none",...v.style},onKeyDown:Kt(v.onKeyDown,M=>{const T=M.target.closest("[data-radix-menu-content]")===M.currentTarget,I=M.ctrlKey||M.altKey||M.metaKey,B=M.key.length===1;T&&(M.key==="Tab"&&M.preventDefault(),!I&&B&&W(M.key));const G=A.current;if(M.target!==G||!R6.includes(M.key))return;M.preventDefault();const H=S().filter(X=>!X.disabled).map(X=>X.ref.current);tD.includes(M.key)&&H.reverse(),Q6(H)}),onBlur:Kt(t.onBlur,M=>{M.currentTarget.contains(M.target)||(window.clearTimeout(q.current),O.current="")}),onPointerMove:Kt(t.onPointerMove,Eu(M=>{const z=M.target,T=$.current!==M.clientX;if(M.currentTarget.contains(z)&&T){const I=M.clientX>$.current?"right":"left";L.current=I,$.current=M.clientX}}))})})})})})})});lD.displayName=Wa;var z6="MenuGroup",gb=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t;return e.jsx(js.div,{role:"group",...r,ref:s})});gb.displayName=z6;var U6="MenuLabel",oD=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t;return e.jsx(js.div,{...r,ref:s})});oD.displayName=U6;var hf="MenuItem",nS="menu.itemSelect",Xf=g.forwardRef((t,s)=>{const{disabled:n=!1,onSelect:r,...a}=t,i=g.useRef(null),o=th(hf,t.__scopeMenu),d=pb(hf,t.__scopeMenu),m=Gs(s,i),f=g.useRef(!1),p=()=>{const h=i.current;if(!n&&h){const x=new CustomEvent(nS,{bubbles:!0,cancelable:!0});h.addEventListener(nS,u=>r==null?void 0:r(u),{once:!0}),YA(h,x),x.defaultPrevented?f.current=!1:o.onClose()}};return e.jsx(cD,{...a,ref:m,disabled:n,onClick:Kt(t.onClick,p),onPointerDown:h=>{var x;(x=t.onPointerDown)==null||x.call(t,h),f.current=!0},onPointerUp:Kt(t.onPointerUp,h=>{var x;f.current||(x=h.currentTarget)==null||x.click()}),onKeyDown:Kt(t.onKeyDown,h=>{const x=d.searchRef.current!=="";n||x&&h.key===" "||my.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Xf.displayName=hf;var cD=g.forwardRef((t,s)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...i}=t,o=pb(hf,n),d=nD(n),m=g.useRef(null),f=Gs(s,m),[p,h]=g.useState(!1),[x,u]=g.useState("");return g.useEffect(()=>{const N=m.current;N&&u((N.textContent??"").trim())},[i.children]),e.jsx(Ru.ItemSlot,{scope:n,disabled:r,textValue:a??x,children:e.jsx(Wk,{asChild:!0,...d,focusable:!r,children:e.jsx(js.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:f,onPointerMove:Kt(t.onPointerMove,Eu(N=>{r?o.onItemLeave(N):(o.onItemEnter(N),N.defaultPrevented||N.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Kt(t.onPointerLeave,Eu(N=>o.onItemLeave(N))),onFocus:Kt(t.onFocus,()=>h(!0)),onBlur:Kt(t.onBlur,()=>h(!1))})})})}),V6="MenuCheckboxItem",dD=g.forwardRef((t,s)=>{const{checked:n=!1,onCheckedChange:r,...a}=t;return e.jsx(pD,{scope:t.__scopeMenu,checked:n,children:e.jsx(Xf,{role:"menuitemcheckbox","aria-checked":mf(n)?"mixed":n,...a,ref:s,"data-state":yb(n),onSelect:Kt(a.onSelect,()=>r==null?void 0:r(mf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});dD.displayName=V6;var uD="MenuRadioGroup",[H6,W6]=mc(uD,{value:void 0,onValueChange:()=>{}}),hD=g.forwardRef((t,s)=>{const{value:n,onValueChange:r,...a}=t,i=Sr(r);return e.jsx(H6,{scope:t.__scopeMenu,value:n,onValueChange:i,children:e.jsx(gb,{...a,ref:s})})});hD.displayName=uD;var mD="MenuRadioItem",fD=g.forwardRef((t,s)=>{const{value:n,...r}=t,a=W6(mD,t.__scopeMenu),i=n===a.value;return e.jsx(pD,{scope:t.__scopeMenu,checked:i,children:e.jsx(Xf,{role:"menuitemradio","aria-checked":i,...r,ref:s,"data-state":yb(i),onSelect:Kt(r.onSelect,()=>{var o;return(o=a.onValueChange)==null?void 0:o.call(a,n)},{checkForDefaultPrevented:!1})})})});fD.displayName=mD;var vb="MenuItemIndicator",[pD,G6]=mc(vb,{checked:!1}),xD=g.forwardRef((t,s)=>{const{__scopeMenu:n,forceMount:r,...a}=t,i=G6(vb,n);return e.jsx(Dr,{present:r||mf(i.checked)||i.checked===!0,children:e.jsx(js.span,{...a,ref:s,"data-state":yb(i.checked)})})});xD.displayName=vb;var K6="MenuSeparator",gD=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t;return e.jsx(js.div,{role:"separator","aria-orientation":"horizontal",...r,ref:s})});gD.displayName=K6;var Y6="MenuArrow",vD=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t,a=Qf(n);return e.jsx(Gf,{...a,...r,ref:s})});vD.displayName=Y6;var Z6="MenuSub",[CY,yD]=mc(Z6),mu="MenuSubTrigger",bD=g.forwardRef((t,s)=>{const n=fc(mu,t.__scopeMenu),r=th(mu,t.__scopeMenu),a=yD(mu,t.__scopeMenu),i=pb(mu,t.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:d,onPointerGraceIntentChange:m}=i,f={__scopeMenu:t.__scopeMenu},p=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>p,[p]),g.useEffect(()=>{const h=d.current;return()=>{window.clearTimeout(h),m(null)}},[d,m]),e.jsx(mb,{asChild:!0,...f,children:e.jsx(cD,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":wD(n.open),...t,ref:Xr(s,a.onTriggerChange),onClick:h=>{var x;(x=t.onClick)==null||x.call(t,h),!(t.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Kt(t.onPointerMove,Eu(h=>{i.onItemEnter(h),!h.defaultPrevented&&!t.disabled&&!n.open&&!o.current&&(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),p()},100))})),onPointerLeave:Kt(t.onPointerLeave,Eu(h=>{var u,N;p();const x=(u=n.content)==null?void 0:u.getBoundingClientRect();if(x){const v=(N=n.content)==null?void 0:N.dataset.side,w=v==="right",j=w?-5:5,b=x[w?"left":"right"],C=x[w?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+j,y:h.clientY},{x:b,y:x.top},{x:C,y:x.top},{x:C,y:x.bottom},{x:b,y:x.bottom}],side:v}),window.clearTimeout(d.current),d.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Kt(t.onKeyDown,h=>{var u;const x=i.searchRef.current!=="";t.disabled||x&&h.key===" "||E6[r.dir].includes(h.key)&&(n.onOpenChange(!0),(u=n.content)==null||u.focus(),h.preventDefault())})})})});bD.displayName=mu;var jD="MenuSubContent",ND=g.forwardRef((t,s)=>{const n=aD(Wa,t.__scopeMenu),{forceMount:r=n.forceMount,...a}=t,i=fc(Wa,t.__scopeMenu),o=th(Wa,t.__scopeMenu),d=yD(jD,t.__scopeMenu),m=g.useRef(null),f=Gs(s,m);return e.jsx(Ru.Provider,{scope:t.__scopeMenu,children:e.jsx(Dr,{present:r||i.open,children:e.jsx(Ru.Slot,{scope:t.__scopeMenu,children:e.jsx(xb,{id:d.contentId,"aria-labelledby":d.triggerId,...a,ref:f,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{var h;o.isUsingKeyboardRef.current&&((h=m.current)==null||h.focus()),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:Kt(t.onFocusOutside,p=>{p.target!==d.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Kt(t.onEscapeKeyDown,p=>{o.onClose(),p.preventDefault()}),onKeyDown:Kt(t.onKeyDown,p=>{var u;const h=p.currentTarget.contains(p.target),x=_6[o.dir].includes(p.key);h&&x&&(i.onOpenChange(!1),(u=d.trigger)==null||u.focus(),p.preventDefault())})})})})})});ND.displayName=jD;function wD(t){return t?"open":"closed"}function mf(t){return t==="indeterminate"}function yb(t){return mf(t)?"indeterminate":t?"checked":"unchecked"}function Q6(t){const s=document.activeElement;for(const n of t)if(n===s||(n.focus(),document.activeElement!==s))return}function X6(t,s){return t.map((n,r)=>t[(s+r)%t.length])}function J6(t,s,n){const a=s.length>1&&Array.from(s).every(f=>f===s[0])?s[0]:s,i=n?t.indexOf(n):-1;let o=X6(t,Math.max(i,0));a.length===1&&(o=o.filter(f=>f!==n));const m=o.find(f=>f.toLowerCase().startsWith(a.toLowerCase()));return m!==n?m:void 0}function e8(t,s){const{x:n,y:r}=t;let a=!1;for(let i=0,o=s.length-1;i<s.length;o=i++){const d=s[i],m=s[o],f=d.x,p=d.y,h=m.x,x=m.y;p>r!=x>r&&n<(h-f)*(r-p)/(x-p)+f&&(a=!a)}return a}function t8(t,s){if(!s)return!1;const n={x:t.clientX,y:t.clientY};return e8(n,s)}function Eu(t){return s=>s.pointerType==="mouse"?t(s):void 0}var s8=rD,n8=mb,r8=iD,a8=lD,i8=gb,l8=oD,o8=Xf,c8=dD,d8=hD,u8=fD,h8=xD,m8=gD,f8=vD,p8=bD,x8=ND,Jf="DropdownMenu",[g8]=ga(Jf,[sD]),ea=sD(),[v8,SD]=g8(Jf),CD=t=>{const{__scopeDropdownMenu:s,children:n,dir:r,open:a,defaultOpen:i,onOpenChange:o,modal:d=!0}=t,m=ea(s),f=g.useRef(null),[p,h]=Bi({prop:a,defaultProp:i??!1,onChange:o,caller:Jf});return e.jsx(v8,{scope:s,triggerId:Ar(),triggerRef:f,contentId:Ar(),open:p,onOpenChange:h,onOpenToggle:g.useCallback(()=>h(x=>!x),[h]),modal:d,children:e.jsx(s8,{...m,open:p,onOpenChange:h,dir:r,modal:d,children:n})})};CD.displayName=Jf;var AD="DropdownMenuTrigger",kD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=t,i=SD(AD,n),o=ea(n);return e.jsx(n8,{asChild:!0,...o,children:e.jsx(js.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:Xr(s,i.triggerRef),onPointerDown:Kt(t.onPointerDown,d=>{!r&&d.button===0&&d.ctrlKey===!1&&(i.onOpenToggle(),i.open||d.preventDefault())}),onKeyDown:Kt(t.onKeyDown,d=>{r||(["Enter"," "].includes(d.key)&&i.onOpenToggle(),d.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(d.key)&&d.preventDefault())})})})});kD.displayName=AD;var y8="DropdownMenuPortal",DD=t=>{const{__scopeDropdownMenu:s,...n}=t,r=ea(s);return e.jsx(r8,{...r,...n})};DD.displayName=y8;var RD="DropdownMenuContent",ED=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=SD(RD,n),i=ea(n),o=g.useRef(!1);return e.jsx(a8,{id:a.contentId,"aria-labelledby":a.triggerId,...i,...r,ref:s,onCloseAutoFocus:Kt(t.onCloseAutoFocus,d=>{var m;o.current||(m=a.triggerRef.current)==null||m.focus(),o.current=!1,d.preventDefault()}),onInteractOutside:Kt(t.onInteractOutside,d=>{const m=d.detail.originalEvent,f=m.button===0&&m.ctrlKey===!0,p=m.button===2||f;(!a.modal||p)&&(o.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ED.displayName=RD;var b8="DropdownMenuGroup",j8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(i8,{...a,...r,ref:s})});j8.displayName=b8;var N8="DropdownMenuLabel",_D=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(l8,{...a,...r,ref:s})});_D.displayName=N8;var w8="DropdownMenuItem",TD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(o8,{...a,...r,ref:s})});TD.displayName=w8;var S8="DropdownMenuCheckboxItem",PD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(c8,{...a,...r,ref:s})});PD.displayName=S8;var C8="DropdownMenuRadioGroup",A8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(d8,{...a,...r,ref:s})});A8.displayName=C8;var k8="DropdownMenuRadioItem",D8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(u8,{...a,...r,ref:s})});D8.displayName=k8;var R8="DropdownMenuItemIndicator",OD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(h8,{...a,...r,ref:s})});OD.displayName=R8;var E8="DropdownMenuSeparator",LD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(m8,{...a,...r,ref:s})});LD.displayName=E8;var _8="DropdownMenuArrow",T8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(f8,{...a,...r,ref:s})});T8.displayName=_8;var P8="DropdownMenuSubTrigger",O8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(p8,{...a,...r,ref:s})});O8.displayName=P8;var L8="DropdownMenuSubContent",I8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(x8,{...a,...r,ref:s,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});I8.displayName=L8;var M8=CD,F8=kD,B8=DD,$8=ED,q8=_D,z8=TD,U8=PD,V8=OD,H8=LD;function bb({...t}){return e.jsx(M8,{"data-slot":"dropdown-menu",...t})}function jb({...t}){return e.jsx(F8,{"data-slot":"dropdown-menu-trigger",...t})}function Nb({className:t,sideOffset:s=4,...n}){return e.jsx(B8,{children:e.jsx($8,{"data-slot":"dropdown-menu-content",sideOffset:s,className:Nt("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",t),...n})})}function ID({className:t,inset:s,variant:n="default",...r}){return e.jsx(z8,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":n,className:Nt("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r})}function W8({className:t,children:s,checked:n,...r}){return e.jsxs(U8,{"data-slot":"dropdown-menu-checkbox-item",className:Nt("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),checked:n,...r,children:[e.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:e.jsx(V8,{children:e.jsx(Hn,{className:"size-4"})})}),s]})}function G8({className:t,inset:s,...n}){return e.jsx(q8,{"data-slot":"dropdown-menu-label","data-inset":s,className:Nt("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",t),...n})}function K8({className:t,...s}){return e.jsx(H8,{"data-slot":"dropdown-menu-separator",className:Nt("bg-border -mx-1 my-1 h-px",t),...s})}const Y8=Ky("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function Ce({className:t,variant:s,asChild:n=!1,...r}){const a=n?qA:"span";return e.jsx(a,{"data-slot":"badge",className:Nt(Y8({variant:s}),t),...r})}const vm="/communication",Zo={getNotifications:async(t,s)=>{let n=`${vm}/notifications`;return t&&s&&(n+=`?page=${t}&limit=${s}`),(await qe.get(n)).data},markAsRead:async t=>(await qe.patch(`${vm}/notifications/${t}/read`)).data,markAllAsRead:async()=>(await qe.patch(`${vm}/notifications/read-all`)).data,updatePushSubscription:async t=>(await qe.post(`${vm}/notifications/subscribe`,{subscription:t})).data},$i=Object.create(null);$i.open="0";$i.close="1";$i.ping="2";$i.pong="3";$i.message="4";$i.upgrade="5";$i.noop="6";const qm=Object.create(null);Object.keys($i).forEach(t=>{qm[$i[t]]=t});const fy={type:"error",data:"parser error"},MD=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",FD=typeof ArrayBuffer=="function",BD=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,wb=({type:t,data:s},n,r)=>MD&&s instanceof Blob?n?r(s):rS(s,r):FD&&(s instanceof ArrayBuffer||BD(s))?n?r(s):rS(new Blob([s]),r):r($i[t]+(s||"")),rS=(t,s)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];s("b"+(r||""))},n.readAsDataURL(t)};function aS(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let Eg;function Z8(t,s){if(MD&&t.data instanceof Blob)return t.data.arrayBuffer().then(aS).then(s);if(FD&&(t.data instanceof ArrayBuffer||BD(t.data)))return s(aS(t.data));wb(t,!1,n=>{Eg||(Eg=new TextEncoder),s(Eg.encode(n))})}const iS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fu=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<iS.length;t++)fu[iS.charCodeAt(t)]=t;const Q8=t=>{let s=t.length*.75,n=t.length,r,a=0,i,o,d,m;t[t.length-1]==="="&&(s--,t[t.length-2]==="="&&s--);const f=new ArrayBuffer(s),p=new Uint8Array(f);for(r=0;r<n;r+=4)i=fu[t.charCodeAt(r)],o=fu[t.charCodeAt(r+1)],d=fu[t.charCodeAt(r+2)],m=fu[t.charCodeAt(r+3)],p[a++]=i<<2|o>>4,p[a++]=(o&15)<<4|d>>2,p[a++]=(d&3)<<6|m&63;return f},X8=typeof ArrayBuffer=="function",Sb=(t,s)=>{if(typeof t!="string")return{type:"message",data:$D(t,s)};const n=t.charAt(0);return n==="b"?{type:"message",data:J8(t.substring(1),s)}:qm[n]?t.length>1?{type:qm[n],data:t.substring(1)}:{type:qm[n]}:fy},J8=(t,s)=>{if(X8){const n=Q8(t);return $D(n,s)}else return{base64:!0,data:t}},$D=(t,s)=>{switch(s){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},qD="",e9=(t,s)=>{const n=t.length,r=new Array(n);let a=0;t.forEach((i,o)=>{wb(i,!1,d=>{r[o]=d,++a===n&&s(r.join(qD))})})},t9=(t,s)=>{const n=t.split(qD),r=[];for(let a=0;a<n.length;a++){const i=Sb(n[a],s);if(r.push(i),i.type==="error")break}return r};function s9(){return new TransformStream({transform(t,s){Z8(t,n=>{const r=n.length;let a;if(r<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,r);else if(r<65536){a=new Uint8Array(3);const i=new DataView(a.buffer);i.setUint8(0,126),i.setUint16(1,r)}else{a=new Uint8Array(9);const i=new DataView(a.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(r))}t.data&&typeof t.data!="string"&&(a[0]|=128),s.enqueue(a),s.enqueue(n)})}})}let _g;function ym(t){return t.reduce((s,n)=>s+n.length,0)}function bm(t,s){if(t[0].length===s)return t.shift();const n=new Uint8Array(s);let r=0;for(let a=0;a<s;a++)n[a]=t[0][r++],r===t[0].length&&(t.shift(),r=0);return t.length&&r<t[0].length&&(t[0]=t[0].slice(r)),n}function n9(t,s){_g||(_g=new TextDecoder);const n=[];let r=0,a=-1,i=!1;return new TransformStream({transform(o,d){for(n.push(o);;){if(r===0){if(ym(n)<1)break;const m=bm(n,1);i=(m[0]&128)===128,a=m[0]&127,a<126?r=3:a===126?r=1:r=2}else if(r===1){if(ym(n)<2)break;const m=bm(n,2);a=new DataView(m.buffer,m.byteOffset,m.length).getUint16(0),r=3}else if(r===2){if(ym(n)<8)break;const m=bm(n,8),f=new DataView(m.buffer,m.byteOffset,m.length),p=f.getUint32(0);if(p>Math.pow(2,21)-1){d.enqueue(fy);break}a=p*Math.pow(2,32)+f.getUint32(4),r=3}else{if(ym(n)<a)break;const m=bm(n,a);d.enqueue(Sb(i?m:_g.decode(m),s)),r=0}if(a===0||a>t){d.enqueue(fy);break}}}})}const zD=4;function ir(t){if(t)return r9(t)}function r9(t){for(var s in ir.prototype)t[s]=ir.prototype[s];return t}ir.prototype.on=ir.prototype.addEventListener=function(t,s){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(s),this};ir.prototype.once=function(t,s){function n(){this.off(t,n),s.apply(this,arguments)}return n.fn=s,this.on(t,n),this};ir.prototype.off=ir.prototype.removeListener=ir.prototype.removeAllListeners=ir.prototype.removeEventListener=function(t,s){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var r,a=0;a<n.length;a++)if(r=n[a],r===s||r.fn===s){n.splice(a,1);break}return n.length===0&&delete this._callbacks["$"+t],this};ir.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var s=new Array(arguments.length-1),n=this._callbacks["$"+t],r=1;r<arguments.length;r++)s[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,a=n.length;r<a;++r)n[r].apply(this,s)}return this};ir.prototype.emitReserved=ir.prototype.emit;ir.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};ir.prototype.hasListeners=function(t){return!!this.listeners(t).length};const ep=typeof Promise=="function"&&typeof Promise.resolve=="function"?s=>Promise.resolve().then(s):(s,n)=>n(s,0),Va=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),a9="arraybuffer";function UD(t,...s){return s.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{})}const i9=Va.setTimeout,l9=Va.clearTimeout;function tp(t,s){s.useNativeTimers?(t.setTimeoutFn=i9.bind(Va),t.clearTimeoutFn=l9.bind(Va)):(t.setTimeoutFn=Va.setTimeout.bind(Va),t.clearTimeoutFn=Va.clearTimeout.bind(Va))}const o9=1.33;function c9(t){return typeof t=="string"?d9(t):Math.ceil((t.byteLength||t.size)*o9)}function d9(t){let s=0,n=0;for(let r=0,a=t.length;r<a;r++)s=t.charCodeAt(r),s<128?n+=1:s<2048?n+=2:s<55296||s>=57344?n+=3:(r++,n+=4);return n}function VD(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function u9(t){let s="";for(let n in t)t.hasOwnProperty(n)&&(s.length&&(s+="&"),s+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return s}function h9(t){let s={},n=t.split("&");for(let r=0,a=n.length;r<a;r++){let i=n[r].split("=");s[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return s}class m9 extends Error{constructor(s,n,r){super(s),this.description=n,this.context=r,this.type="TransportError"}}class Cb extends ir{constructor(s){super(),this.writable=!1,tp(this,s),this.opts=s,this.query=s.query,this.socket=s.socket,this.supportsBinary=!s.forceBase64}onError(s,n,r){return super.emitReserved("error",new m9(s,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(s){this.readyState==="open"&&this.write(s)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(s){const n=Sb(s,this.socket.binaryType);this.onPacket(n)}onPacket(s){super.emitReserved("packet",s)}onClose(s){this.readyState="closed",super.emitReserved("close",s)}pause(s){}createUri(s,n={}){return s+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const s=this.opts.hostname;return s.indexOf(":")===-1?s:"["+s+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(s){const n=u9(s);return n.length?"?"+n:""}}class f9 extends Cb{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(s){this.readyState="pausing";const n=()=>{this.readyState="paused",s()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(s){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};t9(s,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const s=()=>{this.write([{type:"close"}])};this.readyState==="open"?s():this.once("open",s)}write(s){this.writable=!1,e9(s,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const s=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=VD()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(s,n)}}let HD=!1;try{HD=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const p9=HD;function x9(){}class g9 extends f9{constructor(s){if(super(s),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&s.hostname!==location.hostname||r!==s.port}}doWrite(s,n){const r=this.request({method:"POST",data:s});r.on("success",n),r.on("error",(a,i)=>{this.onError("xhr post error",a,i)})}doPoll(){const s=this.request();s.on("data",this.onData.bind(this)),s.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=s}}class Fi extends ir{constructor(s,n,r){super(),this.createRequest=s,tp(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var s;const n=UD(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let a in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(a)&&r.setRequestHeader(a,this._opts.extraHeaders[a])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(s=this._opts.cookieJar)===null||s===void 0||s.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var a;r.readyState===3&&((a=this._opts.cookieJar)===null||a===void 0||a.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(a){this.setTimeoutFn(()=>{this._onError(a)},0);return}typeof document<"u"&&(this._index=Fi.requestsCount++,Fi.requests[this._index]=this)}_onError(s){this.emitReserved("error",s,this._xhr),this._cleanup(!0)}_cleanup(s){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=x9,s)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Fi.requests[this._index],this._xhr=null}}_onLoad(){const s=this._xhr.responseText;s!==null&&(this.emitReserved("data",s),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Fi.requestsCount=0;Fi.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",lS);else if(typeof addEventListener=="function"){const t="onpagehide"in Va?"pagehide":"unload";addEventListener(t,lS,!1)}}function lS(){for(let t in Fi.requests)Fi.requests.hasOwnProperty(t)&&Fi.requests[t].abort()}const v9=(function(){const t=WD({xdomain:!1});return t&&t.responseType!==null})();class y9 extends g9{constructor(s){super(s);const n=s&&s.forceBase64;this.supportsBinary=v9&&!n}request(s={}){return Object.assign(s,{xd:this.xd},this.opts),new Fi(WD,this.uri(),s)}}function WD(t){const s=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!s||p9))return new XMLHttpRequest}catch{}if(!s)try{return new Va[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const GD=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class b9 extends Cb{get name(){return"websocket"}doOpen(){const s=this.uri(),n=this.opts.protocols,r=GD?{}:UD(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(s,n,r)}catch(a){return this.emitReserved("error",a)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=s=>this.onClose({description:"websocket connection closed",context:s}),this.ws.onmessage=s=>this.onData(s.data),this.ws.onerror=s=>this.onError("websocket error",s)}write(s){this.writable=!1;for(let n=0;n<s.length;n++){const r=s[n],a=n===s.length-1;wb(r,this.supportsBinary,i=>{try{this.doWrite(r,i)}catch{}a&&ep(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const s=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=VD()),this.supportsBinary||(n.b64=1),this.createUri(s,n)}}const Tg=Va.WebSocket||Va.MozWebSocket;class j9 extends b9{createSocket(s,n,r){return GD?new Tg(s,n,r):n?new Tg(s,n):new Tg(s)}doWrite(s,n){this.ws.send(n)}}class N9 extends Cb{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(s){return this.emitReserved("error",s)}this._transport.closed.then(()=>{this.onClose()}).catch(s=>{this.onError("webtransport error",s)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(s=>{const n=n9(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=s.readable.pipeThrough(n).getReader(),a=s9();a.readable.pipeTo(s.writable),this._writer=a.writable.getWriter();const i=()=>{r.read().then(({done:d,value:m})=>{d||(this.onPacket(m),i())}).catch(d=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(s){this.writable=!1;for(let n=0;n<s.length;n++){const r=s[n],a=n===s.length-1;this._writer.write(r).then(()=>{a&&ep(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var s;(s=this._transport)===null||s===void 0||s.close()}}const w9={websocket:j9,webtransport:N9,polling:y9},S9=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,C9=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function py(t){if(t.length>8e3)throw"URI too long";const s=t,n=t.indexOf("["),r=t.indexOf("]");n!=-1&&r!=-1&&(t=t.substring(0,n)+t.substring(n,r).replace(/:/g,";")+t.substring(r,t.length));let a=S9.exec(t||""),i={},o=14;for(;o--;)i[C9[o]]=a[o]||"";return n!=-1&&r!=-1&&(i.source=s,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=A9(i,i.path),i.queryKey=k9(i,i.query),i}function A9(t,s){const n=/\/{2,9}/g,r=s.replace(n,"/").split("/");return(s.slice(0,1)=="/"||s.length===0)&&r.splice(0,1),s.slice(-1)=="/"&&r.splice(r.length-1,1),r}function k9(t,s){const n={};return s.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,a,i){a&&(n[a]=i)}),n}const xy=typeof addEventListener=="function"&&typeof removeEventListener=="function",zm=[];xy&&addEventListener("offline",()=>{zm.forEach(t=>t())},!1);class Xl extends ir{constructor(s,n){if(super(),this.binaryType=a9,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,s&&typeof s=="object"&&(n=s,s=null),s){const r=py(s);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=py(n.host).host);tp(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const a=r.prototype.name;this.transports.push(a),this._transportsByName[a]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=h9(this.opts.query)),xy&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},zm.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(s){const n=Object.assign({},this.opts.query);n.EIO=zD,n.transport=s,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[s]);return new this._transportsByName[s](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const s=this.opts.rememberUpgrade&&Xl.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(s);n.open(),this.setTransport(n)}setTransport(s){this.transport&&this.transport.removeAllListeners(),this.transport=s,s.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",Xl.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(s){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",s),this.emitReserved("heartbeat"),s.type){case"open":this.onHandshake(JSON.parse(s.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=s.data,this._onError(n);break;case"message":this.emitReserved("data",s.data),this.emitReserved("message",s.data);break}}onHandshake(s){this.emitReserved("handshake",s),this.id=s.sid,this.transport.query.sid=s.sid,this._pingInterval=s.pingInterval,this._pingTimeout=s.pingTimeout,this._maxPayload=s.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const s=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+s,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},s),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const s=this._getWritablePackets();this.transport.send(s),this._prevBufferLen=s.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const a=this.writeBuffer[r].data;if(a&&(n+=c9(a)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const s=Date.now()>this._pingTimeoutTime;return s&&(this._pingTimeoutTime=0,ep(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),s}write(s,n,r){return this._sendPacket("message",s,n,r),this}send(s,n,r){return this._sendPacket("message",s,n,r),this}_sendPacket(s,n,r,a){if(typeof n=="function"&&(a=n,n=void 0),typeof r=="function"&&(a=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const i={type:s,data:n,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),a&&this.once("flush",a),this.flush()}close(){const s=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),s()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():s()}):this.upgrading?r():s()),this}_onError(s){if(Xl.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",s),this._onClose("transport error",s)}_onClose(s,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),xy&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=zm.indexOf(this._offlineEventListener);r!==-1&&zm.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",s,n),this.writeBuffer=[],this._prevBufferLen=0}}}Xl.protocol=zD;class D9 extends Xl{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let s=0;s<this._upgrades.length;s++)this._probe(this._upgrades[s])}_probe(s){let n=this.createTransport(s),r=!1;Xl.priorWebsocketSuccess=!1;const a=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",h=>{if(!r)if(h.type==="pong"&&h.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Xl.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(p(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const x=new Error("probe error");x.transport=n.name,this.emitReserved("upgradeError",x)}}))};function i(){r||(r=!0,p(),n.close(),n=null)}const o=h=>{const x=new Error("probe error: "+h);x.transport=n.name,i(),this.emitReserved("upgradeError",x)};function d(){o("transport closed")}function m(){o("socket closed")}function f(h){n&&h.name!==n.name&&i()}const p=()=>{n.removeListener("open",a),n.removeListener("error",o),n.removeListener("close",d),this.off("close",m),this.off("upgrading",f)};n.once("open",a),n.once("error",o),n.once("close",d),this.once("close",m),this.once("upgrading",f),this._upgrades.indexOf("webtransport")!==-1&&s!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(s){this._upgrades=this._filterUpgrades(s.upgrades),super.onHandshake(s)}_filterUpgrades(s){const n=[];for(let r=0;r<s.length;r++)~this.transports.indexOf(s[r])&&n.push(s[r]);return n}}let R9=class extends D9{constructor(s,n={}){const r=typeof s=="object"?s:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(a=>w9[a]).filter(a=>!!a)),super(s,r)}};function E9(t,s="",n){let r=t;n=n||typeof location<"u"&&location,t==null&&(t=n.protocol+"//"+n.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=n.protocol+t:t=n.host+t),/^(https?|wss?):\/\//.test(t)||(typeof n<"u"?t=n.protocol+"//"+t:t="https://"+t),r=py(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+s,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}const _9=typeof ArrayBuffer=="function",T9=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,KD=Object.prototype.toString,P9=typeof Blob=="function"||typeof Blob<"u"&&KD.call(Blob)==="[object BlobConstructor]",O9=typeof File=="function"||typeof File<"u"&&KD.call(File)==="[object FileConstructor]";function Ab(t){return _9&&(t instanceof ArrayBuffer||T9(t))||P9&&t instanceof Blob||O9&&t instanceof File}function Um(t,s){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++)if(Um(t[n]))return!0;return!1}if(Ab(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return Um(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&Um(t[n]))return!0;return!1}function L9(t){const s=[],n=t.data,r=t;return r.data=gy(n,s),r.attachments=s.length,{packet:r,buffers:s}}function gy(t,s){if(!t)return t;if(Ab(t)){const n={_placeholder:!0,num:s.length};return s.push(t),n}else if(Array.isArray(t)){const n=new Array(t.length);for(let r=0;r<t.length;r++)n[r]=gy(t[r],s);return n}else if(typeof t=="object"&&!(t instanceof Date)){const n={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=gy(t[r],s));return n}return t}function I9(t,s){return t.data=vy(t.data,s),delete t.attachments,t}function vy(t,s){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<s.length)return s[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=vy(t[n],s);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=vy(t[n],s));return t}const M9=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var pn;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(pn||(pn={}));class F9{constructor(s){this.replacer=s}encode(s){return(s.type===pn.EVENT||s.type===pn.ACK)&&Um(s)?this.encodeAsBinary({type:s.type===pn.EVENT?pn.BINARY_EVENT:pn.BINARY_ACK,nsp:s.nsp,data:s.data,id:s.id}):[this.encodeAsString(s)]}encodeAsString(s){let n=""+s.type;return(s.type===pn.BINARY_EVENT||s.type===pn.BINARY_ACK)&&(n+=s.attachments+"-"),s.nsp&&s.nsp!=="/"&&(n+=s.nsp+","),s.id!=null&&(n+=s.id),s.data!=null&&(n+=JSON.stringify(s.data,this.replacer)),n}encodeAsBinary(s){const n=L9(s),r=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(r),a}}class kb extends ir{constructor(s){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof s=="function"?{reviver:s}:s)}add(s){let n;if(typeof s=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(s);const r=n.type===pn.BINARY_EVENT;r||n.type===pn.BINARY_ACK?(n.type=r?pn.EVENT:pn.ACK,this.reconstructor=new B9(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(Ab(s)||s.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(s),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+s)}decodeString(s){let n=0;const r={type:Number(s.charAt(0))};if(pn[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===pn.BINARY_EVENT||r.type===pn.BINARY_ACK){const i=n+1;for(;s.charAt(++n)!=="-"&&n!=s.length;);const o=s.substring(i,n);if(o!=Number(o)||s.charAt(n)!=="-")throw new Error("Illegal attachments");const d=Number(o);if(!$9(d)||d<0)throw new Error("Illegal attachments");if(d>this.opts.maxAttachments)throw new Error("too many attachments");r.attachments=d}if(s.charAt(n+1)==="/"){const i=n+1;for(;++n&&!(s.charAt(n)===","||n===s.length););r.nsp=s.substring(i,n)}else r.nsp="/";const a=s.charAt(n+1);if(a!==""&&Number(a)==a){const i=n+1;for(;++n;){const o=s.charAt(n);if(o==null||Number(o)!=o){--n;break}if(n===s.length)break}r.id=Number(s.substring(i,n+1))}if(s.charAt(++n)){const i=this.tryParse(s.substr(n));if(kb.isPayloadValid(r.type,i))r.data=i;else throw new Error("invalid payload")}return r}tryParse(s){try{return JSON.parse(s,this.opts.reviver)}catch{return!1}}static isPayloadValid(s,n){switch(s){case pn.CONNECT:return oS(n);case pn.DISCONNECT:return n===void 0;case pn.CONNECT_ERROR:return typeof n=="string"||oS(n);case pn.EVENT:case pn.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&M9.indexOf(n[0])===-1);case pn.ACK:case pn.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class B9{constructor(s){this.packet=s,this.buffers=[],this.reconPack=s}takeBinaryData(s){if(this.buffers.push(s),this.buffers.length===this.reconPack.attachments){const n=I9(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const $9=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};function oS(t){return Object.prototype.toString.call(t)==="[object Object]"}const q9=Object.freeze(Object.defineProperty({__proto__:null,Decoder:kb,Encoder:F9,get PacketType(){return pn}},Symbol.toStringTag,{value:"Module"}));function ci(t,s,n){return t.on(s,n),function(){t.off(s,n)}}const z9=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class YD extends ir{constructor(s,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=s,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const s=this.io;this.subs=[ci(s,"open",this.onopen.bind(this)),ci(s,"packet",this.onpacket.bind(this)),ci(s,"error",this.onerror.bind(this)),ci(s,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...s){return s.unshift("message"),this.emit.apply(this,s),this}emit(s,...n){var r,a,i;if(z9.hasOwnProperty(s))throw new Error('"'+s.toString()+'" is a reserved event name');if(n.unshift(s),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const o={type:pn.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const p=this.ids++,h=n.pop();this._registerAckCallback(p,h),o.id=p}const d=(a=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||a===void 0?void 0:a.writable,m=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!d||(m?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(s,n){var r;const a=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(a===void 0){this.acks[s]=n;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[s];for(let d=0;d<this.sendBuffer.length;d++)this.sendBuffer[d].id===s&&this.sendBuffer.splice(d,1);n.call(this,new Error("operation has timed out"))},a),o=(...d)=>{this.io.clearTimeoutFn(i),n.apply(this,d)};o.withError=!0,this.acks[s]=o}emitWithAck(s,...n){return new Promise((r,a)=>{const i=(o,d)=>o?a(o):r(d);i.withError=!0,n.push(i),this.emit(s,...n)})}_addToQueue(s){let n;typeof s[s.length-1]=="function"&&(n=s.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:s,flags:Object.assign({fromQueue:!0},this.flags)};s.push((a,...i)=>(this._queue[0],a!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(a)):(this._queue.shift(),n&&n(null,...i)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(s=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!s||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(s){s.nsp=this.nsp,this.io._packet(s)}onopen(){typeof this.auth=="function"?this.auth(s=>{this._sendConnectPacket(s)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(s){this.packet({type:pn.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},s):s})}onerror(s){this.connected||this.emitReserved("connect_error",s)}onclose(s,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",s,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(s=>{if(!this.sendBuffer.some(r=>String(r.id)===s)){const r=this.acks[s];delete this.acks[s],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(s){if(s.nsp===this.nsp)switch(s.type){case pn.CONNECT:s.data&&s.data.sid?this.onconnect(s.data.sid,s.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case pn.EVENT:case pn.BINARY_EVENT:this.onevent(s);break;case pn.ACK:case pn.BINARY_ACK:this.onack(s);break;case pn.DISCONNECT:this.ondisconnect();break;case pn.CONNECT_ERROR:this.destroy();const r=new Error(s.data.message);r.data=s.data.data,this.emitReserved("connect_error",r);break}}onevent(s){const n=s.data||[];s.id!=null&&n.push(this.ack(s.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(s){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,s)}super.emit.apply(this,s),this._pid&&s.length&&typeof s[s.length-1]=="string"&&(this._lastOffset=s[s.length-1])}ack(s){const n=this;let r=!1;return function(...a){r||(r=!0,n.packet({type:pn.ACK,id:s,data:a}))}}onack(s){const n=this.acks[s.id];typeof n=="function"&&(delete this.acks[s.id],n.withError&&s.data.unshift(null),n.apply(this,s.data))}onconnect(s,n){this.id=s,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(s=>this.emitEvent(s)),this.receiveBuffer=[],this.sendBuffer.forEach(s=>{this.notifyOutgoingListeners(s),this.packet(s)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(s=>s()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:pn.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(s){return this.flags.compress=s,this}get volatile(){return this.flags.volatile=!0,this}timeout(s){return this.flags.timeout=s,this}onAny(s){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(s),this}prependAny(s){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(s),this}offAny(s){if(!this._anyListeners)return this;if(s){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(s===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(s){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(s),this}prependAnyOutgoing(s){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(s),this}offAnyOutgoing(s){if(!this._anyOutgoingListeners)return this;if(s){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(s===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(s){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,s.data)}}}function Sd(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}Sd.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var s=Math.random(),n=Math.floor(s*this.jitter*t);t=(Math.floor(s*10)&1)==0?t-n:t+n}return Math.min(t,this.max)|0};Sd.prototype.reset=function(){this.attempts=0};Sd.prototype.setMin=function(t){this.ms=t};Sd.prototype.setMax=function(t){this.max=t};Sd.prototype.setJitter=function(t){this.jitter=t};class yy extends ir{constructor(s,n){var r;super(),this.nsps={},this.subs=[],s&&typeof s=="object"&&(n=s,s=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,tp(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new Sd({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=s;const a=n.parser||q9;this.encoder=new a.Encoder,this.decoder=new a.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(s){return arguments.length?(this._reconnection=!!s,s||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(s){return s===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=s,this)}reconnectionDelay(s){var n;return s===void 0?this._reconnectionDelay:(this._reconnectionDelay=s,(n=this.backoff)===null||n===void 0||n.setMin(s),this)}randomizationFactor(s){var n;return s===void 0?this._randomizationFactor:(this._randomizationFactor=s,(n=this.backoff)===null||n===void 0||n.setJitter(s),this)}reconnectionDelayMax(s){var n;return s===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=s,(n=this.backoff)===null||n===void 0||n.setMax(s),this)}timeout(s){return arguments.length?(this._timeout=s,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(s){if(~this._readyState.indexOf("open"))return this;this.engine=new R9(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const a=ci(n,"open",function(){r.onopen(),s&&s()}),i=d=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",d),s?s(d):this.maybeReconnectOnOpen()},o=ci(n,"error",i);if(this._timeout!==!1){const d=this._timeout,m=this.setTimeoutFn(()=>{a(),i(new Error("timeout")),n.close()},d);this.opts.autoUnref&&m.unref(),this.subs.push(()=>{this.clearTimeoutFn(m)})}return this.subs.push(a),this.subs.push(o),this}connect(s){return this.open(s)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const s=this.engine;this.subs.push(ci(s,"ping",this.onping.bind(this)),ci(s,"data",this.ondata.bind(this)),ci(s,"error",this.onerror.bind(this)),ci(s,"close",this.onclose.bind(this)),ci(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(s){try{this.decoder.add(s)}catch(n){this.onclose("parse error",n)}}ondecoded(s){ep(()=>{this.emitReserved("packet",s)},this.setTimeoutFn)}onerror(s){this.emitReserved("error",s)}socket(s,n){let r=this.nsps[s];return r?this._autoConnect&&!r.active&&r.connect():(r=new YD(this,s,n),this.nsps[s]=r),r}_destroy(s){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(s){const n=this.encoder.encode(s);for(let r=0;r<n.length;r++)this.engine.write(n[r],s.options)}cleanup(){this.subs.forEach(s=>s()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(s,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",s,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const s=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{s.skipReconnect||(this.emitReserved("reconnect_attempt",s.backoff.attempts),!s.skipReconnect&&s.open(a=>{a?(s._reconnecting=!1,s.reconnect(),this.emitReserved("reconnect_error",a)):s.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const s=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",s)}}const su={};function Vm(t,s){typeof t=="object"&&(s=t,t=void 0),s=s||{};const n=E9(t,s.path||"/socket.io"),r=n.source,a=n.id,i=n.path,o=su[a]&&i in su[a].nsps,d=s.forceNew||s["force new connection"]||s.multiplex===!1||o;let m;return d?m=new yy(r,s):(su[a]||(su[a]=new yy(r,s)),m=su[a]),n.query&&!s.query&&(s.query=n.queryKey),m.socket(n.path,s)}Object.assign(Vm,{Manager:yy,Socket:YD,io:Vm,connect:Vm});const ZD=g.createContext({socket:null,isConnected:!1}),QD=()=>g.useContext(ZD),U9=({children:t})=>{const[s,n]=g.useState(null),[r,a]=g.useState(!1),{user:i}=In(o=>o.auth);return g.useEffect(()=>{let o="https://dealeronboarding-uat.royalenfield.com/api";o.endsWith("/api")&&(o=o.replace(/\/api$/,""));const d=Vm(o,{withCredentials:!0});return d.on("connect",()=>{console.log("Socket connected:",d.id),a(!0)}),d.on("disconnect",()=>{console.log("Socket disconnected"),a(!1)}),n(d),()=>{d.close()}},[]),g.useEffect(()=>{if(s&&r&&(i!=null&&i.id))return s.emit("join_room",`user_${i.id}`),console.log(`Joined private notification room: user_${i.id}`),()=>{s.emit("leave_room",`user_${i.id}`)}},[s,r,i==null?void 0:i.id]),e.jsx(ZD.Provider,{value:{socket:s,isConnected:r},children:t})};function Vs(t){const s=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&s==="[object Date]"?new t.constructor(+t):typeof t=="number"||s==="[object Number]"||typeof t=="string"||s==="[object String]"?new Date(t):new Date(NaN)}function xa(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function Zr(t,s){const n=Vs(t);return isNaN(s)?xa(t,NaN):(s&&n.setDate(n.getDate()+s),n)}function gi(t,s){const n=Vs(t);if(isNaN(s))return xa(t,NaN);if(!s)return n;const r=n.getDate(),a=xa(t,n.getTime());a.setMonth(n.getMonth()+s+1,0);const i=a.getDate();return r>=i?a:(n.setFullYear(a.getFullYear(),a.getMonth(),r),n)}const Db=6048e5,V9=864e5,jm=43200,cS=1440;let H9={};function Cd(){return H9}function qi(t,s){var d,m,f,p;const n=Cd(),r=(s==null?void 0:s.weekStartsOn)??((m=(d=s==null?void 0:s.locale)==null?void 0:d.options)==null?void 0:m.weekStartsOn)??n.weekStartsOn??((p=(f=n.locale)==null?void 0:f.options)==null?void 0:p.weekStartsOn)??0,a=Vs(t),i=a.getDay(),o=(i<r?7:0)+i-r;return a.setDate(a.getDate()-o),a.setHours(0,0,0,0),a}function ic(t){return qi(t,{weekStartsOn:1})}function XD(t){const s=Vs(t),n=s.getFullYear(),r=xa(t,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);const a=ic(r),i=xa(t,0);i.setFullYear(n,0,4),i.setHours(0,0,0,0);const o=ic(i);return s.getTime()>=a.getTime()?n+1:s.getTime()>=o.getTime()?n:n-1}function cd(t){const s=Vs(t);return s.setHours(0,0,0,0),s}function dd(t){const s=Vs(t),n=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds()));return n.setUTCFullYear(s.getFullYear()),+t-+n}function Ii(t,s){const n=cd(t),r=cd(s),a=+n-dd(n),i=+r-dd(r);return Math.round((a-i)/V9)}function W9(t){const s=XD(t),n=xa(t,0);return n.setFullYear(s,0,4),n.setHours(0,0,0,0),ic(n)}function by(t,s){const n=s*7;return Zr(t,n)}function G9(t,s){return gi(t,s*12)}function K9(t){let s;return t.forEach(function(n){const r=Vs(n);(s===void 0||s<r||isNaN(Number(r)))&&(s=r)}),s||new Date(NaN)}function Y9(t){let s;return t.forEach(n=>{const r=Vs(n);(!s||s>r||isNaN(+r))&&(s=r)}),s||new Date(NaN)}function Hm(t,s){const n=Vs(t),r=Vs(s),a=n.getTime()-r.getTime();return a<0?-1:a>0?1:a}function Z9(t){return xa(t,Date.now())}function ha(t,s){const n=cd(t),r=cd(s);return+n==+r}function Rb(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Q9(t){if(!Rb(t)&&typeof t!="number")return!1;const s=Vs(t);return!isNaN(Number(s))}function ud(t,s){const n=Vs(t),r=Vs(s),a=n.getFullYear()-r.getFullYear(),i=n.getMonth()-r.getMonth();return a*12+i}function X9(t,s,n){const r=qi(t,n),a=qi(s,n),i=+r-dd(r),o=+a-dd(a);return Math.round((i-o)/Db)}function J9(t){return s=>{const r=(t?Math[t]:Math.trunc)(s);return r===0?0:r}}function eB(t,s){return+Vs(t)-+Vs(s)}function tB(t){const s=Vs(t);return s.setHours(23,59,59,999),s}function sp(t){const s=Vs(t),n=s.getMonth();return s.setFullYear(s.getFullYear(),n+1,0),s.setHours(23,59,59,999),s}function sB(t){const s=Vs(t);return+tB(s)==+sp(s)}function nB(t,s){const n=Vs(t),r=Vs(s),a=Hm(n,r),i=Math.abs(ud(n,r));let o;if(i<1)o=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-a*i);let d=Hm(n,r)===-a;sB(Vs(t))&&i===1&&Hm(t,r)===1&&(d=!1),o=a*(i-Number(d))}return o===0?0:o}function rB(t,s,n){const r=eB(t,s)/1e3;return J9(n==null?void 0:n.roundingMethod)(r)}function pa(t){const s=Vs(t);return s.setDate(1),s.setHours(0,0,0,0),s}function JD(t){const s=Vs(t),n=xa(t,0);return n.setFullYear(s.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Eb(t,s){var d,m,f,p;const n=Cd(),r=(s==null?void 0:s.weekStartsOn)??((m=(d=s==null?void 0:s.locale)==null?void 0:d.options)==null?void 0:m.weekStartsOn)??n.weekStartsOn??((p=(f=n.locale)==null?void 0:f.options)==null?void 0:p.weekStartsOn)??0,a=Vs(t),i=a.getDay(),o=(i<r?-7:0)+6-(i-r);return a.setDate(a.getDate()+o),a.setHours(23,59,59,999),a}function eR(t){return Eb(t,{weekStartsOn:1})}const aB={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},iB=(t,s,n)=>{let r;const a=aB[t];return typeof a=="string"?r=a:s===1?r=a.one:r=a.other.replace("{{count}}",s.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function Pg(t){return(s={})=>{const n=s.width?String(s.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const lB={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},oB={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},cB={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},dB={date:Pg({formats:lB,defaultWidth:"full"}),time:Pg({formats:oB,defaultWidth:"full"}),dateTime:Pg({formats:cB,defaultWidth:"full"})},uB={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},hB=(t,s,n,r)=>uB[t];function nu(t){return(s,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let a;if(r==="formatting"&&t.formattingValues){const o=t.defaultFormattingWidth||t.defaultWidth,d=n!=null&&n.width?String(n.width):o;a=t.formattingValues[d]||t.formattingValues[o]}else{const o=t.defaultWidth,d=n!=null&&n.width?String(n.width):t.defaultWidth;a=t.values[d]||t.values[o]}const i=t.argumentCallback?t.argumentCallback(s):s;return a[i]}}const mB={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},fB={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},pB={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},xB={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},gB={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},vB={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},yB=(t,s)=>{const n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},bB={ordinalNumber:yB,era:nu({values:mB,defaultWidth:"wide"}),quarter:nu({values:fB,defaultWidth:"wide",argumentCallback:t=>t-1}),month:nu({values:pB,defaultWidth:"wide"}),day:nu({values:xB,defaultWidth:"wide"}),dayPeriod:nu({values:gB,defaultWidth:"wide",formattingValues:vB,defaultFormattingWidth:"wide"})};function ru(t){return(s,n={})=>{const r=n.width,a=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],i=s.match(a);if(!i)return null;const o=i[0],d=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],m=Array.isArray(d)?NB(d,h=>h.test(o)):jB(d,h=>h.test(o));let f;f=t.valueCallback?t.valueCallback(m):m,f=n.valueCallback?n.valueCallback(f):f;const p=s.slice(o.length);return{value:f,rest:p}}}function jB(t,s){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&s(t[n]))return n}function NB(t,s){for(let n=0;n<t.length;n++)if(s(t[n]))return n}function wB(t){return(s,n={})=>{const r=s.match(t.matchPattern);if(!r)return null;const a=r[0],i=s.match(t.parsePattern);if(!i)return null;let o=t.valueCallback?t.valueCallback(i[0]):i[0];o=n.valueCallback?n.valueCallback(o):o;const d=s.slice(a.length);return{value:o,rest:d}}}const SB=/^(\d+)(th|st|nd|rd)?/i,CB=/\d+/i,AB={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},kB={any:[/^b/i,/^(a|c)/i]},DB={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},RB={any:[/1/i,/2/i,/3/i,/4/i]},EB={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},_B={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},TB={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},PB={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},OB={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},LB={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},IB={ordinalNumber:wB({matchPattern:SB,parsePattern:CB,valueCallback:t=>parseInt(t,10)}),era:ru({matchPatterns:AB,defaultMatchWidth:"wide",parsePatterns:kB,defaultParseWidth:"any"}),quarter:ru({matchPatterns:DB,defaultMatchWidth:"wide",parsePatterns:RB,defaultParseWidth:"any",valueCallback:t=>t+1}),month:ru({matchPatterns:EB,defaultMatchWidth:"wide",parsePatterns:_B,defaultParseWidth:"any"}),day:ru({matchPatterns:TB,defaultMatchWidth:"wide",parsePatterns:PB,defaultParseWidth:"any"}),dayPeriod:ru({matchPatterns:OB,defaultMatchWidth:"any",parsePatterns:LB,defaultParseWidth:"any"})},_b={code:"en-US",formatDistance:iB,formatLong:dB,formatRelative:hB,localize:bB,match:IB,options:{weekStartsOn:0,firstWeekContainsDate:1}};function MB(t){const s=Vs(t);return Ii(s,JD(s))+1}function tR(t){const s=Vs(t),n=+ic(s)-+W9(s);return Math.round(n/Db)+1}function sR(t,s){var p,h,x,u;const n=Vs(t),r=n.getFullYear(),a=Cd(),i=(s==null?void 0:s.firstWeekContainsDate)??((h=(p=s==null?void 0:s.locale)==null?void 0:p.options)==null?void 0:h.firstWeekContainsDate)??a.firstWeekContainsDate??((u=(x=a.locale)==null?void 0:x.options)==null?void 0:u.firstWeekContainsDate)??1,o=xa(t,0);o.setFullYear(r+1,0,i),o.setHours(0,0,0,0);const d=qi(o,s),m=xa(t,0);m.setFullYear(r,0,i),m.setHours(0,0,0,0);const f=qi(m,s);return n.getTime()>=d.getTime()?r+1:n.getTime()>=f.getTime()?r:r-1}function FB(t,s){var d,m,f,p;const n=Cd(),r=(s==null?void 0:s.firstWeekContainsDate)??((m=(d=s==null?void 0:s.locale)==null?void 0:d.options)==null?void 0:m.firstWeekContainsDate)??n.firstWeekContainsDate??((p=(f=n.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??1,a=sR(t,s),i=xa(t,0);return i.setFullYear(a,0,r),i.setHours(0,0,0,0),qi(i,s)}function nR(t,s){const n=Vs(t),r=+qi(n,s)-+FB(n,s);return Math.round(r/Db)+1}function kn(t,s){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(s,"0");return n+r}const Gl={y(t,s){const n=t.getFullYear(),r=n>0?n:1-n;return kn(s==="yy"?r%100:r,s.length)},M(t,s){const n=t.getMonth();return s==="M"?String(n+1):kn(n+1,2)},d(t,s){return kn(t.getDate(),s.length)},a(t,s){const n=t.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,s){return kn(t.getHours()%12||12,s.length)},H(t,s){return kn(t.getHours(),s.length)},m(t,s){return kn(t.getMinutes(),s.length)},s(t,s){return kn(t.getSeconds(),s.length)},S(t,s){const n=s.length,r=t.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return kn(a,s.length)}},Uc={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},dS={G:function(t,s,n){const r=t.getFullYear()>0?1:0;switch(s){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(t,s,n){if(s==="yo"){const r=t.getFullYear(),a=r>0?r:1-r;return n.ordinalNumber(a,{unit:"year"})}return Gl.y(t,s)},Y:function(t,s,n,r){const a=sR(t,r),i=a>0?a:1-a;if(s==="YY"){const o=i%100;return kn(o,2)}return s==="Yo"?n.ordinalNumber(i,{unit:"year"}):kn(i,s.length)},R:function(t,s){const n=XD(t);return kn(n,s.length)},u:function(t,s){const n=t.getFullYear();return kn(n,s.length)},Q:function(t,s,n){const r=Math.ceil((t.getMonth()+1)/3);switch(s){case"Q":return String(r);case"QQ":return kn(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,s,n){const r=Math.ceil((t.getMonth()+1)/3);switch(s){case"q":return String(r);case"qq":return kn(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,s,n){const r=t.getMonth();switch(s){case"M":case"MM":return Gl.M(t,s);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,s,n){const r=t.getMonth();switch(s){case"L":return String(r+1);case"LL":return kn(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,s,n,r){const a=nR(t,r);return s==="wo"?n.ordinalNumber(a,{unit:"week"}):kn(a,s.length)},I:function(t,s,n){const r=tR(t);return s==="Io"?n.ordinalNumber(r,{unit:"week"}):kn(r,s.length)},d:function(t,s,n){return s==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):Gl.d(t,s)},D:function(t,s,n){const r=MB(t);return s==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):kn(r,s.length)},E:function(t,s,n){const r=t.getDay();switch(s){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,s,n,r){const a=t.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(s){case"e":return String(i);case"ee":return kn(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(t,s,n,r){const a=t.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(s){case"c":return String(i);case"cc":return kn(i,s.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(t,s,n){const r=t.getDay(),a=r===0?7:r;switch(s){case"i":return String(a);case"ii":return kn(a,s.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,s,n){const a=t.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(t,s,n){const r=t.getHours();let a;switch(r===12?a=Uc.noon:r===0?a=Uc.midnight:a=r/12>=1?"pm":"am",s){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(t,s,n){const r=t.getHours();let a;switch(r>=17?a=Uc.evening:r>=12?a=Uc.afternoon:r>=4?a=Uc.morning:a=Uc.night,s){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(t,s,n){if(s==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return Gl.h(t,s)},H:function(t,s,n){return s==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):Gl.H(t,s)},K:function(t,s,n){const r=t.getHours()%12;return s==="Ko"?n.ordinalNumber(r,{unit:"hour"}):kn(r,s.length)},k:function(t,s,n){let r=t.getHours();return r===0&&(r=24),s==="ko"?n.ordinalNumber(r,{unit:"hour"}):kn(r,s.length)},m:function(t,s,n){return s==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):Gl.m(t,s)},s:function(t,s,n){return s==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):Gl.s(t,s)},S:function(t,s){return Gl.S(t,s)},X:function(t,s,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(s){case"X":return hS(r);case"XXXX":case"XX":return Vo(r);case"XXXXX":case"XXX":default:return Vo(r,":")}},x:function(t,s,n){const r=t.getTimezoneOffset();switch(s){case"x":return hS(r);case"xxxx":case"xx":return Vo(r);case"xxxxx":case"xxx":default:return Vo(r,":")}},O:function(t,s,n){const r=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+uS(r,":");case"OOOO":default:return"GMT"+Vo(r,":")}},z:function(t,s,n){const r=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+uS(r,":");case"zzzz":default:return"GMT"+Vo(r,":")}},t:function(t,s,n){const r=Math.trunc(t.getTime()/1e3);return kn(r,s.length)},T:function(t,s,n){const r=t.getTime();return kn(r,s.length)}};function uS(t,s=""){const n=t>0?"-":"+",r=Math.abs(t),a=Math.trunc(r/60),i=r%60;return i===0?n+String(a):n+String(a)+s+kn(i,2)}function hS(t,s){return t%60===0?(t>0?"-":"+")+kn(Math.abs(t)/60,2):Vo(t,s)}function Vo(t,s=""){const n=t>0?"-":"+",r=Math.abs(t),a=kn(Math.trunc(r/60),2),i=kn(r%60,2);return n+a+s+i}const mS=(t,s)=>{switch(t){case"P":return s.date({width:"short"});case"PP":return s.date({width:"medium"});case"PPP":return s.date({width:"long"});case"PPPP":default:return s.date({width:"full"})}},rR=(t,s)=>{switch(t){case"p":return s.time({width:"short"});case"pp":return s.time({width:"medium"});case"ppp":return s.time({width:"long"});case"pppp":default:return s.time({width:"full"})}},BB=(t,s)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return mS(t,s);let i;switch(r){case"P":i=s.dateTime({width:"short"});break;case"PP":i=s.dateTime({width:"medium"});break;case"PPP":i=s.dateTime({width:"long"});break;case"PPPP":default:i=s.dateTime({width:"full"});break}return i.replace("{{date}}",mS(r,s)).replace("{{time}}",rR(a,s))},$B={p:rR,P:BB},qB=/^D+$/,zB=/^Y+$/,UB=["D","DD","YY","YYYY"];function VB(t){return qB.test(t)}function HB(t){return zB.test(t)}function WB(t,s,n){const r=GB(t,s,n);if(console.warn(r),UB.includes(t))throw new RangeError(r)}function GB(t,s,n){const r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${s}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const KB=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,YB=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ZB=/^'([^]*?)'?$/,QB=/''/g,XB=/[a-zA-Z]/;function Ka(t,s,n){var p,h,x,u,N,v,w,j;const r=Cd(),a=(n==null?void 0:n.locale)??r.locale??_b,i=(n==null?void 0:n.firstWeekContainsDate)??((h=(p=n==null?void 0:n.locale)==null?void 0:p.options)==null?void 0:h.firstWeekContainsDate)??r.firstWeekContainsDate??((u=(x=r.locale)==null?void 0:x.options)==null?void 0:u.firstWeekContainsDate)??1,o=(n==null?void 0:n.weekStartsOn)??((v=(N=n==null?void 0:n.locale)==null?void 0:N.options)==null?void 0:v.weekStartsOn)??r.weekStartsOn??((j=(w=r.locale)==null?void 0:w.options)==null?void 0:j.weekStartsOn)??0,d=Vs(t);if(!Q9(d))throw new RangeError("Invalid time value");let m=s.match(YB).map(b=>{const C=b[0];if(C==="p"||C==="P"){const S=$B[C];return S(b,a.formatLong)}return b}).join("").match(KB).map(b=>{if(b==="''")return{isToken:!1,value:"'"};const C=b[0];if(C==="'")return{isToken:!1,value:JB(b)};if(dS[C])return{isToken:!0,value:b};if(C.match(XB))throw new RangeError("Format string contains an unescaped latin alphabet character `"+C+"`");return{isToken:!1,value:b}});a.localize.preprocessor&&(m=a.localize.preprocessor(d,m));const f={firstWeekContainsDate:i,weekStartsOn:o,locale:a};return m.map(b=>{if(!b.isToken)return b.value;const C=b.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&HB(C)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&VB(C))&&WB(C,s,String(t));const S=dS[C[0]];return S(d,C,a.localize,f)}).join("")}function JB(t){const s=t.match(ZB);return s?s[1].replace(QB,"'"):t}function e$(t,s,n){const r=Cd(),a=(n==null?void 0:n.locale)??r.locale??_b,i=2520,o=Hm(t,s);if(isNaN(o))throw new RangeError("Invalid time value");const d=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:o});let m,f;o>0?(m=Vs(s),f=Vs(t)):(m=Vs(t),f=Vs(s));const p=rB(f,m),h=(dd(f)-dd(m))/1e3,x=Math.round((p-h)/60);let u;if(x<2)return n!=null&&n.includeSeconds?p<5?a.formatDistance("lessThanXSeconds",5,d):p<10?a.formatDistance("lessThanXSeconds",10,d):p<20?a.formatDistance("lessThanXSeconds",20,d):p<40?a.formatDistance("halfAMinute",0,d):p<60?a.formatDistance("lessThanXMinutes",1,d):a.formatDistance("xMinutes",1,d):x===0?a.formatDistance("lessThanXMinutes",1,d):a.formatDistance("xMinutes",x,d);if(x<45)return a.formatDistance("xMinutes",x,d);if(x<90)return a.formatDistance("aboutXHours",1,d);if(x<cS){const N=Math.round(x/60);return a.formatDistance("aboutXHours",N,d)}else{if(x<i)return a.formatDistance("xDays",1,d);if(x<jm){const N=Math.round(x/cS);return a.formatDistance("xDays",N,d)}else if(x<jm*2)return u=Math.round(x/jm),a.formatDistance("aboutXMonths",u,d)}if(u=nB(f,m),u<12){const N=Math.round(x/jm);return a.formatDistance("xMonths",N,d)}else{const N=u%12,v=Math.trunc(u/12);return N<3?a.formatDistance("aboutXYears",v,d):N<9?a.formatDistance("overXYears",v,d):a.formatDistance("almostXYears",v+1,d)}}function aR(t,s){return e$(t,Z9(t),s)}function t$(t){const s=Vs(t),n=s.getFullYear(),r=s.getMonth(),a=xa(t,0);return a.setFullYear(n,r+1,0),a.setHours(0,0,0,0),a.getDate()}function s$(t){return Math.trunc(+Vs(t)/1e3)}function n$(t){const s=Vs(t),n=s.getMonth();return s.setFullYear(s.getFullYear(),n+1,0),s.setHours(0,0,0,0),s}function r$(t,s){return X9(n$(t),pa(t),s)+1}function jy(t,s){const n=Vs(t),r=Vs(s);return n.getTime()>r.getTime()}function iR(t,s){const n=Vs(t),r=Vs(s);return+n<+r}function Tb(t,s){const n=Vs(t),r=Vs(s);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()}function a$(t,s){const n=Vs(t),r=Vs(s);return n.getFullYear()===r.getFullYear()}function Og(t,s){return Zr(t,-s)}function Lg(t,s){const n=Vs(t),r=n.getFullYear(),a=n.getDate(),i=xa(t,0);i.setFullYear(r,s,15),i.setHours(0,0,0,0);const o=t$(i);return n.setMonth(s,Math.min(a,o)),n}function fS(t,s){const n=Vs(t);return isNaN(+n)?xa(t,NaN):(n.setFullYear(s),n)}function i$({title:t,subtitle:s,onRefresh:n}){const{user:r}=In(h=>h.auth),{socket:a}=QD(),[i,o]=g.useState([]),[d,m]=g.useState(0);g.useEffect(()=>{(async()=>{try{const x=await Zo.getNotifications(1,15);x.success&&(o(x.data),x.pagination&&x.pagination.unreadCount!==void 0?m(x.pagination.unreadCount):m(x.data.filter(u=>!u.isRead).length))}catch(x){console.error("Fetch notifications error:",x)}})()},[]),g.useEffect(()=>{if(a)return a.on("notification",h=>{o(x=>[h,...x].slice(0,15)),m(x=>x+1),te(h.title,{description:h.message,action:h.link?{label:"View",onClick:()=>window.location.href=h.link}:void 0})}),()=>{a.off("notification")}},[a]);const f=async h=>{try{h.isRead||(await Zo.markAsRead(h.id)).success&&(o(u=>u.map(N=>N.id===h.id?{...N,isRead:!0}:N)),m(u=>Math.max(0,u-1))),h.link&&(window.location.href=h.link)}catch(x){console.error("Notification click error:",x)}},p=async()=>{try{(await Zo.markAllAsRead()).success&&(o(x=>x.map(u=>({...u,isRead:!0}))),m(0))}catch(h){console.error("Mark all as read error:",h)}};return e.jsx("header",{className:"bg-white border-b border-slate-200 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900",children:t}),e.jsx("p",{className:"text-slate-600 text-sm leading-snug max-w-3xl",children:s})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-slate-100 rounded-lg",children:[e.jsx("div",{className:"w-8 h-8 bg-re-red rounded-full flex items-center justify-center",children:e.jsx(Lr,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-slate-900",children:r.name}),e.jsx("p",{className:"text-slate-600",children:r.role})]})]}),n&&e.jsx(se,{variant:"outline",size:"icon",onClick:n,title:"Refresh",children:e.jsx(xr,{className:"w-4 h-4"})}),e.jsx(se,{variant:"outline",size:"icon",title:"Help",children:e.jsx(ck,{className:"w-4 h-4"})}),e.jsxs(bb,{children:[e.jsx(jb,{asChild:!0,children:e.jsxs(se,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(Au,{className:"w-4 h-4"}),d>0&&e.jsx(Ce,{variant:"destructive",className:"absolute -top-1 -right-1 w-5 h-5 p-0 flex items-center justify-center text-xs",children:d})]})}),e.jsxs(Nb,{align:"end",className:"w-80",children:[e.jsxs("div",{className:"p-3 border-b flex items-center justify-between",children:[e.jsx("p",{className:"font-semibold text-slate-900",children:"Notifications"}),d>0&&e.jsx("button",{onClick:p,className:"text-xs text-blue-600 hover:underline",children:"Mark all read"})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto custom-scrollbar",children:i.length===0?e.jsx("div",{className:"p-8 text-center text-slate-500",children:"No notifications yet"}):i.map(h=>e.jsxs(ID,{className:`p-3 cursor-pointer flex items-start gap-3 ${h.isRead?"":"bg-blue-50/50"}`,onClick:()=>f(h),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-slate-900 text-sm font-medium",children:h.title}),e.jsx("p",{className:"text-slate-600 text-xs mt-1 leading-relaxed",children:h.message}),e.jsx("p",{className:"text-slate-400 text-[10px] mt-2",children:aR(new Date(h.createdAt),{addSuffix:!0})})]}),!h.isRead&&e.jsx("div",{className:"w-2 h-2 bg-blue-600 rounded-full mt-1.5 flex-shrink-0"})]},h.id))}),e.jsx("div",{className:"p-3 border-t text-center",children:e.jsx("button",{onClick:()=>window.location.href="/notifications",className:"text-xs font-medium text-blue-600 hover:text-blue-800 transition-colors",children:"View All Notifications"})})]})]})]})]})})}function Le({className:t,...s}){return e.jsx("div",{"data-slot":"card",className:Nt("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border",t),...s})}function Qe({className:t,...s}){return e.jsx("div",{"data-slot":"card-header",className:Nt("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 pt-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...s})}function Je({className:t,...s}){return e.jsx("h4",{"data-slot":"card-title",className:Nt("leading-none",t),...s})}function Xt({className:t,...s}){return e.jsx("p",{"data-slot":"card-description",className:Nt("text-muted-foreground",t),...s})}function Fe({className:t,...s}){return e.jsx("div",{"data-slot":"card-content",className:Nt("px-6 [&:last-child]:pb-6",t),...s})}function Ny(t,[s,n]){return Math.min(n,Math.max(s,t))}function l$(t,s){return g.useReducer((n,r)=>s[n][r]??n,t)}var Pb="ScrollArea",[lR]=ga(Pb),[o$,Ya]=lR(Pb),oR=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,type:r="hover",dir:a,scrollHideDelay:i=600,...o}=t,[d,m]=g.useState(null),[f,p]=g.useState(null),[h,x]=g.useState(null),[u,N]=g.useState(null),[v,w]=g.useState(null),[j,b]=g.useState(0),[C,S]=g.useState(0),[R,_]=g.useState(!1),[A,E]=g.useState(!1),q=Gs(s,D=>m(D)),O=Ku(a);return e.jsx(o$,{scope:n,type:r,dir:O,scrollHideDelay:i,scrollArea:d,viewport:f,onViewportChange:p,content:h,onContentChange:x,scrollbarX:u,onScrollbarXChange:N,scrollbarXEnabled:R,onScrollbarXEnabledChange:_,scrollbarY:v,onScrollbarYChange:w,scrollbarYEnabled:A,onScrollbarYEnabledChange:E,onCornerWidthChange:b,onCornerHeightChange:S,children:e.jsx(js.div,{dir:O,...o,ref:q,style:{position:"relative","--radix-scroll-area-corner-width":j+"px","--radix-scroll-area-corner-height":C+"px",...t.style}})})});oR.displayName=Pb;var cR="ScrollAreaViewport",dR=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,children:r,nonce:a,...i}=t,o=Ya(cR,n),d=g.useRef(null),m=Gs(s,d,o.onViewportChange);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),e.jsx(js.div,{"data-radix-scroll-area-viewport":"",...i,ref:m,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...t.style},children:e.jsx("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});dR.displayName=cR;var Ui="ScrollAreaScrollbar",uR=g.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=Ya(Ui,t.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:o}=a,d=t.orientation==="horizontal";return g.useEffect(()=>(d?i(!0):o(!0),()=>{d?i(!1):o(!1)}),[d,i,o]),a.type==="hover"?e.jsx(c$,{...r,ref:s,forceMount:n}):a.type==="scroll"?e.jsx(d$,{...r,ref:s,forceMount:n}):a.type==="auto"?e.jsx(hR,{...r,ref:s,forceMount:n}):a.type==="always"?e.jsx(Ob,{...r,ref:s}):null});uR.displayName=Ui;var c$=g.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=Ya(Ui,t.__scopeScrollArea),[i,o]=g.useState(!1);return g.useEffect(()=>{const d=a.scrollArea;let m=0;if(d){const f=()=>{window.clearTimeout(m),o(!0)},p=()=>{m=window.setTimeout(()=>o(!1),a.scrollHideDelay)};return d.addEventListener("pointerenter",f),d.addEventListener("pointerleave",p),()=>{window.clearTimeout(m),d.removeEventListener("pointerenter",f),d.removeEventListener("pointerleave",p)}}},[a.scrollArea,a.scrollHideDelay]),e.jsx(Dr,{present:n||i,children:e.jsx(hR,{"data-state":i?"visible":"hidden",...r,ref:s})})}),d$=g.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=Ya(Ui,t.__scopeScrollArea),i=t.orientation==="horizontal",o=rp(()=>m("SCROLL_END"),100),[d,m]=l$("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return g.useEffect(()=>{if(d==="idle"){const f=window.setTimeout(()=>m("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(f)}},[d,a.scrollHideDelay,m]),g.useEffect(()=>{const f=a.viewport,p=i?"scrollLeft":"scrollTop";if(f){let h=f[p];const x=()=>{const u=f[p];h!==u&&(m("SCROLL"),o()),h=u};return f.addEventListener("scroll",x),()=>f.removeEventListener("scroll",x)}},[a.viewport,i,m,o]),e.jsx(Dr,{present:n||d!=="hidden",children:e.jsx(Ob,{"data-state":d==="hidden"?"hidden":"visible",...r,ref:s,onPointerEnter:Kt(t.onPointerEnter,()=>m("POINTER_ENTER")),onPointerLeave:Kt(t.onPointerLeave,()=>m("POINTER_LEAVE"))})})}),hR=g.forwardRef((t,s)=>{const n=Ya(Ui,t.__scopeScrollArea),{forceMount:r,...a}=t,[i,o]=g.useState(!1),d=t.orientation==="horizontal",m=rp(()=>{if(n.viewport){const f=n.viewport.offsetWidth<n.viewport.scrollWidth,p=n.viewport.offsetHeight<n.viewport.scrollHeight;o(d?f:p)}},10);return hd(n.viewport,m),hd(n.content,m),e.jsx(Dr,{present:r||i,children:e.jsx(Ob,{"data-state":i?"visible":"hidden",...a,ref:s})})}),Ob=g.forwardRef((t,s)=>{const{orientation:n="vertical",...r}=t,a=Ya(Ui,t.__scopeScrollArea),i=g.useRef(null),o=g.useRef(0),[d,m]=g.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=gR(d.viewport,d.content),p={...r,sizes:d,onSizesChange:m,hasThumb:f>0&&f<1,onThumbChange:x=>i.current=x,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:x=>o.current=x};function h(x,u){return x$(x,o.current,d,u)}return n==="horizontal"?e.jsx(u$,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&i.current){const x=a.viewport.scrollLeft,u=pS(x,d,a.dir);i.current.style.transform=`translate3d(${u}px, 0, 0)`}},onWheelScroll:x=>{a.viewport&&(a.viewport.scrollLeft=x)},onDragScroll:x=>{a.viewport&&(a.viewport.scrollLeft=h(x,a.dir))}}):n==="vertical"?e.jsx(h$,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&i.current){const x=a.viewport.scrollTop,u=pS(x,d);i.current.style.transform=`translate3d(0, ${u}px, 0)`}},onWheelScroll:x=>{a.viewport&&(a.viewport.scrollTop=x)},onDragScroll:x=>{a.viewport&&(a.viewport.scrollTop=h(x))}}):null}),u$=g.forwardRef((t,s)=>{const{sizes:n,onSizesChange:r,...a}=t,i=Ya(Ui,t.__scopeScrollArea),[o,d]=g.useState(),m=g.useRef(null),f=Gs(s,m,i.onScrollbarXChange);return g.useEffect(()=>{m.current&&d(getComputedStyle(m.current))},[m]),e.jsx(fR,{"data-orientation":"horizontal",...a,ref:f,sizes:n,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":np(n)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.x),onDragScroll:p=>t.onDragScroll(p.x),onWheelScroll:(p,h)=>{if(i.viewport){const x=i.viewport.scrollLeft+p.deltaX;t.onWheelScroll(x),yR(x,h)&&p.preventDefault()}},onResize:()=>{m.current&&i.viewport&&o&&r({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:m.current.clientWidth,paddingStart:pf(o.paddingLeft),paddingEnd:pf(o.paddingRight)}})}})}),h$=g.forwardRef((t,s)=>{const{sizes:n,onSizesChange:r,...a}=t,i=Ya(Ui,t.__scopeScrollArea),[o,d]=g.useState(),m=g.useRef(null),f=Gs(s,m,i.onScrollbarYChange);return g.useEffect(()=>{m.current&&d(getComputedStyle(m.current))},[m]),e.jsx(fR,{"data-orientation":"vertical",...a,ref:f,sizes:n,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":np(n)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.y),onDragScroll:p=>t.onDragScroll(p.y),onWheelScroll:(p,h)=>{if(i.viewport){const x=i.viewport.scrollTop+p.deltaY;t.onWheelScroll(x),yR(x,h)&&p.preventDefault()}},onResize:()=>{m.current&&i.viewport&&o&&r({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:m.current.clientHeight,paddingStart:pf(o.paddingTop),paddingEnd:pf(o.paddingBottom)}})}})}),[m$,mR]=lR(Ui),fR=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:a,onThumbChange:i,onThumbPointerUp:o,onThumbPointerDown:d,onThumbPositionChange:m,onDragScroll:f,onWheelScroll:p,onResize:h,...x}=t,u=Ya(Ui,n),[N,v]=g.useState(null),w=Gs(s,q=>v(q)),j=g.useRef(null),b=g.useRef(""),C=u.viewport,S=r.content-r.viewport,R=Sr(p),_=Sr(m),A=rp(h,10);function E(q){if(j.current){const O=q.clientX-j.current.left,D=q.clientY-j.current.top;f({x:O,y:D})}}return g.useEffect(()=>{const q=O=>{const D=O.target;(N==null?void 0:N.contains(D))&&R(O,S)};return document.addEventListener("wheel",q,{passive:!1}),()=>document.removeEventListener("wheel",q,{passive:!1})},[C,N,S,R]),g.useEffect(_,[r,_]),hd(N,A),hd(u.content,A),e.jsx(m$,{scope:n,scrollbar:N,hasThumb:a,onThumbChange:Sr(i),onThumbPointerUp:Sr(o),onThumbPositionChange:_,onThumbPointerDown:Sr(d),children:e.jsx(js.div,{...x,ref:w,style:{position:"absolute",...x.style},onPointerDown:Kt(t.onPointerDown,q=>{q.button===0&&(q.target.setPointerCapture(q.pointerId),j.current=N.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",u.viewport&&(u.viewport.style.scrollBehavior="auto"),E(q))}),onPointerMove:Kt(t.onPointerMove,E),onPointerUp:Kt(t.onPointerUp,q=>{const O=q.target;O.hasPointerCapture(q.pointerId)&&O.releasePointerCapture(q.pointerId),document.body.style.webkitUserSelect=b.current,u.viewport&&(u.viewport.style.scrollBehavior=""),j.current=null})})})}),ff="ScrollAreaThumb",pR=g.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=mR(ff,t.__scopeScrollArea);return e.jsx(Dr,{present:n||a.hasThumb,children:e.jsx(f$,{ref:s,...r})})}),f$=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,style:r,...a}=t,i=Ya(ff,n),o=mR(ff,n),{onThumbPositionChange:d}=o,m=Gs(s,h=>o.onThumbChange(h)),f=g.useRef(void 0),p=rp(()=>{f.current&&(f.current(),f.current=void 0)},100);return g.useEffect(()=>{const h=i.viewport;if(h){const x=()=>{if(p(),!f.current){const u=g$(h,d);f.current=u,d()}};return d(),h.addEventListener("scroll",x),()=>h.removeEventListener("scroll",x)}},[i.viewport,p,d]),e.jsx(js.div,{"data-state":o.hasThumb?"visible":"hidden",...a,ref:m,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Kt(t.onPointerDownCapture,h=>{const u=h.target.getBoundingClientRect(),N=h.clientX-u.left,v=h.clientY-u.top;o.onThumbPointerDown({x:N,y:v})}),onPointerUp:Kt(t.onPointerUp,o.onThumbPointerUp)})});pR.displayName=ff;var Lb="ScrollAreaCorner",xR=g.forwardRef((t,s)=>{const n=Ya(Lb,t.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?e.jsx(p$,{...t,ref:s}):null});xR.displayName=Lb;var p$=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,...r}=t,a=Ya(Lb,n),[i,o]=g.useState(0),[d,m]=g.useState(0),f=!!(i&&d);return hd(a.scrollbarX,()=>{var h;const p=((h=a.scrollbarX)==null?void 0:h.offsetHeight)||0;a.onCornerHeightChange(p),m(p)}),hd(a.scrollbarY,()=>{var h;const p=((h=a.scrollbarY)==null?void 0:h.offsetWidth)||0;a.onCornerWidthChange(p),o(p)}),f?e.jsx(js.div,{...r,ref:s,style:{width:i,height:d,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function pf(t){return t?parseInt(t,10):0}function gR(t,s){const n=t/s;return isNaN(n)?0:n}function np(t){const s=gR(t.viewport,t.content),n=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,r=(t.scrollbar.size-n)*s;return Math.max(r,18)}function x$(t,s,n,r="ltr"){const a=np(n),i=a/2,o=s||i,d=a-o,m=n.scrollbar.paddingStart+o,f=n.scrollbar.size-n.scrollbar.paddingEnd-d,p=n.content-n.viewport,h=r==="ltr"?[0,p]:[p*-1,0];return vR([m,f],h)(t)}function pS(t,s,n="ltr"){const r=np(s),a=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,i=s.scrollbar.size-a,o=s.content-s.viewport,d=i-r,m=n==="ltr"?[0,o]:[o*-1,0],f=Ny(t,m);return vR([0,o],[0,d])(f)}function vR(t,s){return n=>{if(t[0]===t[1]||s[0]===s[1])return s[0];const r=(s[1]-s[0])/(t[1]-t[0]);return s[0]+r*(n-t[0])}}function yR(t,s){return t>0&&t<s}var g$=(t,s=()=>{})=>{let n={left:t.scrollLeft,top:t.scrollTop},r=0;return(function a(){const i={left:t.scrollLeft,top:t.scrollTop},o=n.left!==i.left,d=n.top!==i.top;(o||d)&&s(),n=i,r=window.requestAnimationFrame(a)})(),()=>window.cancelAnimationFrame(r)};function rp(t,s){const n=Sr(t),r=g.useRef(0);return g.useEffect(()=>()=>window.clearTimeout(r.current),[]),g.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,s)},[n,s])}function hd(t,s){const n=Sr(s);cr(()=>{let r=0;if(t){const a=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return a.observe(t),()=>{window.cancelAnimationFrame(r),a.unobserve(t)}}},[t,n])}var v$=oR,y$=dR,b$=xR;function Ib({className:t,children:s,...n}){return e.jsxs(v$,{"data-slot":"scroll-area",className:Nt("relative",t),...n,children:[e.jsx(y$,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:s}),e.jsx(j$,{}),e.jsx(b$,{})]})}function j$({className:t,orientation:s="vertical",...n}){return e.jsx(uR,{"data-slot":"scroll-area-scrollbar",orientation:s,className:Nt("flex touch-none p-px transition-colors select-none",s==="vertical"&&"h-full w-2.5 border-l border-l-transparent",s==="horizontal"&&"h-1 flex-col border-t border-t-transparent",t),...n,children:e.jsx(pR,{"data-slot":"scroll-area-thumb",className:Nt("relative flex-1 rounded-full",s==="vertical"&&"bg-border",s==="horizontal"&&"bg-slate-200/70")})})}function N$({onNavigate:t}){const s=[{title:"Total Applications",value:Ei.totalApplications,icon:Ns,color:"bg-blue-500",trend:{value:12,isPositive:!0},filter:"all"},{title:"LOA Issued",value:Ei.loaIssued,icon:un,color:"bg-green-500",trend:{value:8,isPositive:!0},filter:"Approved"},{title:"Level 1 Pending",value:Ei.level1Pending,icon:vn,color:"bg-red-500",trend:{value:3,isPositive:!1},filter:"Level 1 Pending"},{title:"Level 2 Pending",value:Ei.level2Pending,icon:iM,color:"bg-purple-500",trend:{value:5,isPositive:!0},filter:"Level 2 Pending"},{title:"Level 3 Pending",value:Ei.level3Pending,icon:ik,color:"bg-indigo-500",trend:{value:2,isPositive:!1},filter:"Level 3 Pending"},{title:"EOR In Progress",value:Ei.eorInProgress,icon:sn,color:"bg-cyan-500",trend:{value:1,isPositive:!0},filter:"EOR In Progress"},{title:"Disqualified",value:Ei.disqualified,icon:mi,color:"bg-red-500",trend:{value:4,isPositive:!1},filter:"Disqualified"},{title:"Pending Reminders",value:Ei.pendingReminders,icon:Ur,color:"bg-orange-500",trend:{value:7,isPositive:!1},filter:"Questionnaire Pending"},{title:"Shortlisted Today",value:Ei.shortlistedToday,icon:un,color:"bg-teal-500",trend:{value:5,isPositive:!0},filter:"Shortlisted"},{title:"Pending Shortlisting",value:Ei.pendingShortlisting,icon:UI,color:"bg-yellow-500",trend:{value:2,isPositive:!1},filter:"all",action:"opportunity-requests"}],n=[{status:"Pending",count:45,color:"#f59e0b"},{status:"In Progress",count:68,color:"#3b82f6"},{status:"Approved",count:25,color:"#10b981"},{status:"Rejected",count:12,color:"#ef4444"}],r=[{location:"Mumbai",count:23},{location:"Delhi",count:18},{location:"Bangalore",count:21},{location:"Chennai",count:15},{location:"Kolkata",count:12},{location:"Others",count:61}],a=Math.max(...r.map(i=>i.count));return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:s.map(i=>{const o=i.icon,d=i.trend.isPositive?dl:Yo;return e.jsxs(Le,{className:"cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>t(i.action||"applications",i.filter),children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(Je,{className:"text-slate-600",children:i.title}),e.jsx("div",{className:`${i.color} p-2 rounded-lg`,children:e.jsx(o,{className:"w-5 h-5 text-white"})})]}),e.jsx(Fe,{children:e.jsx("div",{className:"flex items-end justify-between",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-slate-900",children:i.value}),e.jsxs("div",{className:`flex items-center gap-1 mt-1 ${i.trend.isPositive?"text-green-600":"text-red-600"}`,children:[e.jsx(d,{className:"w-3 h-3"}),e.jsxs("span",{children:[i.trend.value,"% from last month"]})]})]})})})]},i.title)})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Application Status Distribution"})}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-4",children:n.map(i=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:i.color}}),e.jsx("span",{className:"text-slate-700",children:i.status})]}),e.jsx("span",{className:"text-slate-900",children:i.count})]}),e.jsx("div",{className:"w-full bg-slate-200 rounded-full h-2",children:e.jsx("div",{className:"h-2 rounded-full transition-all",style:{width:`${i.count/150*100}%`,backgroundColor:i.color}})})]},i.status))})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Applications by Location"})}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-3",children:r.map(i=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-24 text-slate-700",children:i.location}),e.jsx("div",{className:"flex-1 bg-slate-200 rounded-full h-8 relative overflow-hidden",children:e.jsx("div",{className:"bg-re-red h-full rounded-full transition-all flex items-center justify-end px-3",style:{width:`${i.count/a*100}%`},children:e.jsx("span",{className:"text-white",children:i.count})})})]},i.location))})})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Recent Activity"})}),e.jsx(Fe,{children:e.jsx(Ib,{className:"h-80",children:e.jsx("div",{className:"space-y-4",children:zM.map(i=>e.jsxs("div",{className:"flex items-start gap-4 p-3 hover:bg-slate-50 rounded-lg cursor-pointer transition-colors",onClick:()=>t("applications"),children:[e.jsxs("div",{className:"w-10 h-10 bg-red-50 rounded-full flex items-center justify-center flex-shrink-0",children:[i.action==="Approved"&&e.jsx(un,{className:"w-5 h-5 text-green-600"}),i.action==="Interview Scheduled"&&e.jsx(vn,{className:"w-5 h-5 text-blue-600"}),i.action==="Document Uploaded"&&e.jsx(Ns,{className:"w-5 h-5 text-purple-600"}),i.action==="Reminder Sent"&&e.jsx(Ur,{className:"w-5 h-5 text-orange-600"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(Ce,{variant:"outline",children:i.applicationId}),e.jsx("span",{className:"text-slate-700",children:i.action})]}),e.jsxs("p",{className:"text-slate-500 mt-1",children:["by ",i.user]})]}),e.jsx("div",{className:"text-slate-500 flex-shrink-0",children:i.timestamp})]},i.id))})})})]})]})}var ap="Tabs",[w$]=ga(ap,[Kf]),bR=Kf(),[S$,Mb]=w$(ap),jR=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:d,activationMode:m="automatic",...f}=t,p=Ku(d),[h,x]=Bi({prop:r,onChange:a,defaultProp:i??"",caller:ap});return e.jsx(S$,{scope:n,baseId:Ar(),value:h,onValueChange:x,orientation:o,dir:p,activationMode:m,children:e.jsx(js.div,{dir:p,"data-orientation":o,...f,ref:s})})});jR.displayName=ap;var NR="TabsList",wR=g.forwardRef((t,s)=>{const{__scopeTabs:n,loop:r=!0,...a}=t,i=Mb(NR,n),o=bR(n);return e.jsx(Hk,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:e.jsx(js.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:s})})});wR.displayName=NR;var SR="TabsTrigger",CR=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...i}=t,o=Mb(SR,n),d=bR(n),m=DR(o.baseId,r),f=RR(o.baseId,r),p=r===o.value;return e.jsx(Wk,{asChild:!0,...d,focusable:!a,active:p,children:e.jsx(js.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":f,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:m,...i,ref:s,onMouseDown:Kt(t.onMouseDown,h=>{!a&&h.button===0&&h.ctrlKey===!1?o.onValueChange(r):h.preventDefault()}),onKeyDown:Kt(t.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&o.onValueChange(r)}),onFocus:Kt(t.onFocus,()=>{const h=o.activationMode!=="manual";!p&&!a&&h&&o.onValueChange(r)})})})});CR.displayName=SR;var AR="TabsContent",kR=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:r,forceMount:a,children:i,...o}=t,d=Mb(AR,n),m=DR(d.baseId,r),f=RR(d.baseId,r),p=r===d.value,h=g.useRef(p);return g.useEffect(()=>{const x=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(x)},[]),e.jsx(Dr,{present:a||p,children:({present:x})=>e.jsx(js.div,{"data-state":p?"active":"inactive","data-orientation":d.orientation,role:"tabpanel","aria-labelledby":m,hidden:!x,id:f,tabIndex:0,...o,ref:s,style:{...t.style,animationDuration:h.current?"0s":void 0},children:x&&i})})});kR.displayName=AR;function DR(t,s){return`${t}-trigger-${s}`}function RR(t,s){return`${t}-content-${s}`}var C$=jR,A$=wR,k$=CR,D$=kR;function Bn({className:t,...s}){return e.jsx(C$,{"data-slot":"tabs",className:Nt("flex flex-col gap-2",t),...s})}function $n({className:t,...s}){return e.jsx(A$,{"data-slot":"tabs-list",className:Nt("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-xl p-[3px] flex",t),...s})}function Wt({className:t,...s}){return e.jsx(k$,{"data-slot":"tabs-trigger",className:Nt("data-[state=active]:bg-card dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-xl border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...s})}function Ut({className:t,...s}){return e.jsx(D$,{"data-slot":"tabs-content",className:Nt("flex-1 outline-none",t),...s})}function R$(t){const s=E$(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find(T$);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function E$(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=O$(a),d=P$(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Xr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var _$=Symbol("radix.slottable");function T$(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===_$}function P$(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function O$(t){var r,a;let s=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var ip="Dialog",[ER,_R]=ga(ip),[L$,Ni]=ER(ip),TR=t=>{const{__scopeDialog:s,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,d=g.useRef(null),m=g.useRef(null),[f,p]=Bi({prop:r,defaultProp:a??!1,onChange:i,caller:ip});return e.jsx(L$,{scope:s,triggerRef:d,contentRef:m,contentId:Ar(),titleId:Ar(),descriptionId:Ar(),open:f,onOpenChange:p,onOpenToggle:g.useCallback(()=>p(h=>!h),[p]),modal:o,children:n})};TR.displayName=ip;var PR="DialogTrigger",OR=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=Ni(PR,n),i=Gs(s,a.triggerRef);return e.jsx(js.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":$b(a.open),...r,ref:i,onClick:Kt(t.onClick,a.onOpenToggle)})});OR.displayName=PR;var Fb="DialogPortal",[I$,LR]=ER(Fb,{forceMount:void 0}),IR=t=>{const{__scopeDialog:s,forceMount:n,children:r,container:a}=t,i=Ni(Fb,s);return e.jsx(I$,{scope:s,forceMount:n,children:g.Children.map(r,o=>e.jsx(Dr,{present:n||i.open,children:e.jsx(wd,{asChild:!0,container:a,children:o})}))})};IR.displayName=Fb;var xf="DialogOverlay",MR=g.forwardRef((t,s)=>{const n=LR(xf,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=Ni(xf,t.__scopeDialog);return i.modal?e.jsx(Dr,{present:r||i.open,children:e.jsx(F$,{...a,ref:s})}):null});MR.displayName=xf;var M$=R$("DialogOverlay.RemoveScroll"),F$=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=Ni(xf,n);return e.jsx(Ju,{as:M$,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(js.div,{"data-state":$b(a.open),...r,ref:s,style:{pointerEvents:"auto",...r.style}})})}),lc="DialogContent",FR=g.forwardRef((t,s)=>{const n=LR(lc,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=Ni(lc,t.__scopeDialog);return e.jsx(Dr,{present:r||i.open,children:i.modal?e.jsx(B$,{...a,ref:s}):e.jsx($$,{...a,ref:s})})});FR.displayName=lc;var B$=g.forwardRef((t,s)=>{const n=Ni(lc,t.__scopeDialog),r=g.useRef(null),a=Gs(s,n.contentRef,r);return g.useEffect(()=>{const i=r.current;if(i)return Yf(i)},[]),e.jsx(BR,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Kt(t.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Kt(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,d=o.button===0&&o.ctrlKey===!0;(o.button===2||d)&&i.preventDefault()}),onFocusOutside:Kt(t.onFocusOutside,i=>i.preventDefault())})}),$$=g.forwardRef((t,s)=>{const n=Ni(lc,t.__scopeDialog),r=g.useRef(!1),a=g.useRef(!1);return e.jsx(BR,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,d;(o=t.onCloseAutoFocus)==null||o.call(t,i),i.defaultPrevented||(r.current||(d=n.triggerRef.current)==null||d.focus(),i.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:i=>{var m,f;(m=t.onInteractOutside)==null||m.call(t,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((f=n.triggerRef.current)==null?void 0:f.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),BR=g.forwardRef((t,s)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,d=Ni(lc,n),m=g.useRef(null),f=Gs(s,m);return $f(),e.jsxs(e.Fragment,{children:[e.jsx(Yu,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:e.jsx(bd,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":$b(d.open),...o,ref:f,onDismiss:()=>d.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(z$,{titleId:d.titleId}),e.jsx(V$,{contentRef:m,descriptionId:d.descriptionId})]})]})}),Bb="DialogTitle",$R=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=Ni(Bb,n);return e.jsx(js.h2,{id:a.titleId,...r,ref:s})});$R.displayName=Bb;var qR="DialogDescription",zR=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=Ni(qR,n);return e.jsx(js.p,{id:a.descriptionId,...r,ref:s})});zR.displayName=qR;var UR="DialogClose",VR=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=Ni(UR,n);return e.jsx(js.button,{type:"button",...r,ref:s,onClick:Kt(t.onClick,()=>a.onOpenChange(!1))})});VR.displayName=UR;function $b(t){return t?"open":"closed"}var HR="DialogTitleWarning",[q$,WR]=uI(HR,{contentName:lc,titleName:Bb,docsSlug:"dialog"}),z$=({titleId:t})=>{const s=WR(HR),n=`\`${s.contentName}\` requires a \`${s.titleName}\` for the component to be accessible for screen reader users.
If you want to hide the \`${s.titleName}\`, you can wrap it with our VisuallyHidden component.
For more information, see https://radix-ui.com/primitives/docs/components/${s.docsSlug}`;return g.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},U$="DialogDescriptionWarning",V$=({contentRef:t,descriptionId:s})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${WR(U$).contentName}}.`;return g.useEffect(()=>{var i;const a=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");s&&a&&(document.getElementById(s)||console.warn(r))},[r,t,s]),null},qb=TR,GR=OR,zb=IR,lp=MR,op=FR,KR=$R,YR=zR,Ub=VR;function ds({...t}){return e.jsx(qb,{"data-slot":"dialog",...t})}function co({...t}){return e.jsx(GR,{"data-slot":"dialog-trigger",...t})}function H$({...t}){return e.jsx(zb,{"data-slot":"dialog-portal",...t})}const ZR=g.forwardRef(({className:t,...s},n)=>e.jsx(lp,{ref:n,"data-slot":"dialog-overlay",className:Nt("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...s}));ZR.displayName=lp.displayName;const os=g.forwardRef(({className:t,children:s,...n},r)=>e.jsxs(H$,{"data-slot":"dialog-portal",children:[e.jsx(ZR,{}),e.jsxs(op,{ref:r,"data-slot":"dialog-content",className:Nt("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...n,children:[s,e.jsxs(Ub,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[e.jsx(ld,{}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));os.displayName=op.displayName;function xs({className:t,...s}){return e.jsx("div",{"data-slot":"dialog-header",className:Nt("flex flex-col gap-2 text-center sm:text-left",t),...s})}function bn({className:t,...s}){return e.jsx("div",{"data-slot":"dialog-footer",className:Nt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...s})}function ms({className:t,...s}){return e.jsx(KR,{"data-slot":"dialog-title",className:Nt("text-lg leading-none font-semibold",t),...s})}function bs({className:t,...s}){return e.jsx(YR,{"data-slot":"dialog-description",className:Nt("text-muted-foreground text-sm",t),...s})}function W$(t){const s=G$(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find(Y$);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function G$(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=Q$(a),d=Z$(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Xr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var K$=Symbol("radix.slottable");function Y$(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===K$}function Z$(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function Q$(t){var r,a;let s=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var QR=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),X$="VisuallyHidden",XR=g.forwardRef((t,s)=>e.jsx(js.span,{...t,ref:s,style:{...QR,...t.style}}));XR.displayName=X$;var J$=XR,e7=[" ","Enter","ArrowUp","ArrowDown"],t7=[" ","Enter"],oc="Select",[cp,dp,s7]=rb(oc),[Ad]=ga(oc,[s7,oo]),up=oo(),[n7,uo]=Ad(oc),[r7,a7]=Ad(oc),JR=t=>{const{__scopeSelect:s,children:n,open:r,defaultOpen:a,onOpenChange:i,value:o,defaultValue:d,onValueChange:m,dir:f,name:p,autoComplete:h,disabled:x,required:u,form:N}=t,v=up(s),[w,j]=g.useState(null),[b,C]=g.useState(null),[S,R]=g.useState(!1),_=Ku(f),[A,E]=Bi({prop:r,defaultProp:a??!1,onChange:i,caller:oc}),[q,O]=Bi({prop:o,defaultProp:d,onChange:m,caller:oc}),D=g.useRef(null),P=w?N||!!w.closest("form"):!0,[L,$]=g.useState(new Set),Y=Array.from(L).map(Z=>Z.props.value).join(";");return e.jsx(Hf,{...v,children:e.jsxs(n7,{required:u,scope:s,trigger:w,onTriggerChange:j,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:S,onValueNodeHasChildrenChange:R,contentId:Ar(),value:q,onValueChange:O,open:A,onOpenChange:E,dir:_,triggerPointerDownPosRef:D,disabled:x,children:[e.jsx(cp.Provider,{scope:s,children:e.jsx(r7,{scope:t.__scopeSelect,onNativeOptionAdd:g.useCallback(Z=>{$(W=>new Set(W).add(Z))},[]),onNativeOptionRemove:g.useCallback(Z=>{$(W=>{const U=new Set(W);return U.delete(Z),U})},[]),children:n})}),P?e.jsxs(wE,{"aria-hidden":!0,required:u,tabIndex:-1,name:p,autoComplete:h,value:q,onChange:Z=>O(Z.target.value),disabled:x,form:N,children:[q===void 0?e.jsx("option",{value:""}):null,Array.from(L)]},Y):null]})})};JR.displayName=oc;var eE="SelectTrigger",tE=g.forwardRef((t,s)=>{const{__scopeSelect:n,disabled:r=!1,...a}=t,i=up(n),o=uo(eE,n),d=o.disabled||r,m=Gs(s,o.onTriggerChange),f=dp(n),p=g.useRef("touch"),[h,x,u]=CE(v=>{const w=f().filter(C=>!C.disabled),j=w.find(C=>C.value===o.value),b=AE(w,v,j);b!==void 0&&o.onValueChange(b.value)}),N=v=>{d||(o.onOpenChange(!0),u()),v&&(o.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return e.jsx(Qu,{asChild:!0,...i,children:e.jsx(js.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:d,"data-disabled":d?"":void 0,"data-placeholder":SE(o.value)?"":void 0,...a,ref:m,onClick:Kt(a.onClick,v=>{v.currentTarget.focus(),p.current!=="mouse"&&N(v)}),onPointerDown:Kt(a.onPointerDown,v=>{p.current=v.pointerType;const w=v.target;w.hasPointerCapture(v.pointerId)&&w.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(N(v),v.preventDefault())}),onKeyDown:Kt(a.onKeyDown,v=>{const w=h.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&x(v.key),!(w&&v.key===" ")&&e7.includes(v.key)&&(N(),v.preventDefault())})})})});tE.displayName=eE;var sE="SelectValue",nE=g.forwardRef((t,s)=>{const{__scopeSelect:n,className:r,style:a,children:i,placeholder:o="",...d}=t,m=uo(sE,n),{onValueNodeHasChildrenChange:f}=m,p=i!==void 0,h=Gs(s,m.onValueNodeChange);return cr(()=>{f(p)},[f,p]),e.jsx(js.span,{...d,ref:h,style:{pointerEvents:"none"},children:SE(m.value)?e.jsx(e.Fragment,{children:o}):i})});nE.displayName=sE;var i7="SelectIcon",rE=g.forwardRef((t,s)=>{const{__scopeSelect:n,children:r,...a}=t;return e.jsx(js.span,{"aria-hidden":!0,...a,ref:s,children:r||"▼"})});rE.displayName=i7;var l7="SelectPortal",aE=t=>e.jsx(wd,{asChild:!0,...t});aE.displayName=l7;var cc="SelectContent",iE=g.forwardRef((t,s)=>{const n=uo(cc,t.__scopeSelect),[r,a]=g.useState();if(cr(()=>{a(new DocumentFragment)},[]),!n.open){const i=r;return i?zu.createPortal(e.jsx(lE,{scope:t.__scopeSelect,children:e.jsx(cp.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),i):null}return e.jsx(oE,{...t,ref:s})});iE.displayName=cc;var oi=10,[lE,ho]=Ad(cc),o7="SelectContentImpl",c7=W$("SelectContent.RemoveScroll"),oE=g.forwardRef((t,s)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:i,onPointerDownOutside:o,side:d,sideOffset:m,align:f,alignOffset:p,arrowPadding:h,collisionBoundary:x,collisionPadding:u,sticky:N,hideWhenDetached:v,avoidCollisions:w,...j}=t,b=uo(cc,n),[C,S]=g.useState(null),[R,_]=g.useState(null),A=Gs(s,X=>S(X)),[E,q]=g.useState(null),[O,D]=g.useState(null),P=dp(n),[L,$]=g.useState(!1),Y=g.useRef(!1);g.useEffect(()=>{if(C)return Yf(C)},[C]),$f();const Z=g.useCallback(X=>{const[J,...ae]=P().map(ce=>ce.ref.current),[le]=ae.slice(-1),xe=document.activeElement;for(const ce of X)if(ce===xe||(ce==null||ce.scrollIntoView({block:"nearest"}),ce===J&&R&&(R.scrollTop=0),ce===le&&R&&(R.scrollTop=R.scrollHeight),ce==null||ce.focus(),document.activeElement!==xe))return},[P,R]),W=g.useCallback(()=>Z([E,C]),[Z,E,C]);g.useEffect(()=>{L&&W()},[L,W]);const{onOpenChange:U,triggerPointerDownPosRef:M}=b;g.useEffect(()=>{if(C){let X={x:0,y:0};const J=le=>{var xe,ce;X={x:Math.abs(Math.round(le.pageX)-(((xe=M.current)==null?void 0:xe.x)??0)),y:Math.abs(Math.round(le.pageY)-(((ce=M.current)==null?void 0:ce.y)??0))}},ae=le=>{X.x<=10&&X.y<=10?le.preventDefault():C.contains(le.target)||U(!1),document.removeEventListener("pointermove",J),M.current=null};return M.current!==null&&(document.addEventListener("pointermove",J),document.addEventListener("pointerup",ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",ae,{capture:!0})}}},[C,U,M]),g.useEffect(()=>{const X=()=>U(!1);return window.addEventListener("blur",X),window.addEventListener("resize",X),()=>{window.removeEventListener("blur",X),window.removeEventListener("resize",X)}},[U]);const[z,T]=CE(X=>{const J=P().filter(xe=>!xe.disabled),ae=J.find(xe=>xe.ref.current===document.activeElement),le=AE(J,X,ae);le&&setTimeout(()=>le.ref.current.focus())}),I=g.useCallback((X,J,ae)=>{const le=!Y.current&&!ae;(b.value!==void 0&&b.value===J||le)&&(q(X),le&&(Y.current=!0))},[b.value]),B=g.useCallback(()=>C==null?void 0:C.focus(),[C]),G=g.useCallback((X,J,ae)=>{const le=!Y.current&&!ae;(b.value!==void 0&&b.value===J||le)&&D(X)},[b.value]),K=r==="popper"?wy:cE,H=K===wy?{side:d,sideOffset:m,align:f,alignOffset:p,arrowPadding:h,collisionBoundary:x,collisionPadding:u,sticky:N,hideWhenDetached:v,avoidCollisions:w}:{};return e.jsx(lE,{scope:n,content:C,viewport:R,onViewportChange:_,itemRefCallback:I,selectedItem:E,onItemLeave:B,itemTextRefCallback:G,focusSelectedItem:W,selectedItemText:O,position:r,isPositioned:L,searchRef:z,children:e.jsx(Ju,{as:c7,allowPinchZoom:!0,children:e.jsx(Yu,{asChild:!0,trapped:b.open,onMountAutoFocus:X=>{X.preventDefault()},onUnmountAutoFocus:Kt(a,X=>{var J;(J=b.trigger)==null||J.focus({preventScroll:!0}),X.preventDefault()}),children:e.jsx(bd,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:X=>X.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:e.jsx(K,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:X=>X.preventDefault(),...j,...H,onPlaced:()=>$(!0),ref:A,style:{display:"flex",flexDirection:"column",outline:"none",...j.style},onKeyDown:Kt(j.onKeyDown,X=>{const J=X.ctrlKey||X.altKey||X.metaKey;if(X.key==="Tab"&&X.preventDefault(),!J&&X.key.length===1&&T(X.key),["ArrowUp","ArrowDown","Home","End"].includes(X.key)){let le=P().filter(xe=>!xe.disabled).map(xe=>xe.ref.current);if(["ArrowUp","End"].includes(X.key)&&(le=le.slice().reverse()),["ArrowUp","ArrowDown"].includes(X.key)){const xe=X.target,ce=le.indexOf(xe);le=le.slice(ce+1)}setTimeout(()=>Z(le)),X.preventDefault()}})})})})})})});oE.displayName=o7;var d7="SelectItemAlignedPosition",cE=g.forwardRef((t,s)=>{const{__scopeSelect:n,onPlaced:r,...a}=t,i=uo(cc,n),o=ho(cc,n),[d,m]=g.useState(null),[f,p]=g.useState(null),h=Gs(s,A=>p(A)),x=dp(n),u=g.useRef(!1),N=g.useRef(!0),{viewport:v,selectedItem:w,selectedItemText:j,focusSelectedItem:b}=o,C=g.useCallback(()=>{if(i.trigger&&i.valueNode&&d&&f&&v&&w&&j){const A=i.trigger.getBoundingClientRect(),E=f.getBoundingClientRect(),q=i.valueNode.getBoundingClientRect(),O=j.getBoundingClientRect();if(i.dir!=="rtl"){const xe=O.left-E.left,ce=q.left-xe,ve=A.left-ce,Pe=A.width+ve,et=Math.max(Pe,E.width),kt=window.innerWidth-oi,vt=Ny(ce,[oi,Math.max(oi,kt-et)]);d.style.minWidth=Pe+"px",d.style.left=vt+"px"}else{const xe=E.right-O.right,ce=window.innerWidth-q.right-xe,ve=window.innerWidth-A.right-ce,Pe=A.width+ve,et=Math.max(Pe,E.width),kt=window.innerWidth-oi,vt=Ny(ce,[oi,Math.max(oi,kt-et)]);d.style.minWidth=Pe+"px",d.style.right=vt+"px"}const D=x(),P=window.innerHeight-oi*2,L=v.scrollHeight,$=window.getComputedStyle(f),Y=parseInt($.borderTopWidth,10),Z=parseInt($.paddingTop,10),W=parseInt($.borderBottomWidth,10),U=parseInt($.paddingBottom,10),M=Y+Z+L+U+W,z=Math.min(w.offsetHeight*5,M),T=window.getComputedStyle(v),I=parseInt(T.paddingTop,10),B=parseInt(T.paddingBottom,10),G=A.top+A.height/2-oi,K=P-G,H=w.offsetHeight/2,X=w.offsetTop+H,J=Y+Z+X,ae=M-J;if(J<=G){const xe=D.length>0&&w===D[D.length-1].ref.current;d.style.bottom="0px";const ce=f.clientHeight-v.offsetTop-v.offsetHeight,ve=Math.max(K,H+(xe?B:0)+ce+W),Pe=J+ve;d.style.height=Pe+"px"}else{const xe=D.length>0&&w===D[0].ref.current;d.style.top="0px";const ve=Math.max(G,Y+v.offsetTop+(xe?I:0)+H)+ae;d.style.height=ve+"px",v.scrollTop=J-G+v.offsetTop}d.style.margin=`${oi}px 0`,d.style.minHeight=z+"px",d.style.maxHeight=P+"px",r==null||r(),requestAnimationFrame(()=>u.current=!0)}},[x,i.trigger,i.valueNode,d,f,v,w,j,i.dir,r]);cr(()=>C(),[C]);const[S,R]=g.useState();cr(()=>{f&&R(window.getComputedStyle(f).zIndex)},[f]);const _=g.useCallback(A=>{A&&N.current===!0&&(C(),b==null||b(),N.current=!1)},[C,b]);return e.jsx(h7,{scope:n,contentWrapper:d,shouldExpandOnScrollRef:u,onScrollButtonChange:_,children:e.jsx("div",{ref:m,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:e.jsx(js.div,{...a,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});cE.displayName=d7;var u7="SelectPopperPosition",wy=g.forwardRef((t,s)=>{const{__scopeSelect:n,align:r="start",collisionPadding:a=oi,...i}=t,o=up(n);return e.jsx(Wf,{...o,...i,ref:s,align:r,collisionPadding:a,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});wy.displayName=u7;var[h7,Vb]=Ad(cc,{}),Sy="SelectViewport",dE=g.forwardRef((t,s)=>{const{__scopeSelect:n,nonce:r,...a}=t,i=ho(Sy,n),o=Vb(Sy,n),d=Gs(s,i.onViewportChange),m=g.useRef(0);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),e.jsx(cp.Slot,{scope:n,children:e.jsx(js.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:d,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Kt(a.onScroll,f=>{const p=f.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:x}=o;if(x!=null&&x.current&&h){const u=Math.abs(m.current-p.scrollTop);if(u>0){const N=window.innerHeight-oi*2,v=parseFloat(h.style.minHeight),w=parseFloat(h.style.height),j=Math.max(v,w);if(j<N){const b=j+u,C=Math.min(N,b),S=b-C;h.style.height=C+"px",h.style.bottom==="0px"&&(p.scrollTop=S>0?S:0,h.style.justifyContent="flex-end")}}}m.current=p.scrollTop})})})]})});dE.displayName=Sy;var uE="SelectGroup",[m7,f7]=Ad(uE),hE=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t,a=Ar();return e.jsx(m7,{scope:n,id:a,children:e.jsx(js.div,{role:"group","aria-labelledby":a,...r,ref:s})})});hE.displayName=uE;var mE="SelectLabel",fE=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t,a=f7(mE,n);return e.jsx(js.div,{id:a.id,...r,ref:s})});fE.displayName=mE;var gf="SelectItem",[p7,pE]=Ad(gf),xE=g.forwardRef((t,s)=>{const{__scopeSelect:n,value:r,disabled:a=!1,textValue:i,...o}=t,d=uo(gf,n),m=ho(gf,n),f=d.value===r,[p,h]=g.useState(i??""),[x,u]=g.useState(!1),N=Gs(s,b=>{var C;return(C=m.itemRefCallback)==null?void 0:C.call(m,b,r,a)}),v=Ar(),w=g.useRef("touch"),j=()=>{a||(d.onValueChange(r),d.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return e.jsx(p7,{scope:n,value:r,disabled:a,textId:v,isSelected:f,onItemTextChange:g.useCallback(b=>{h(C=>C||((b==null?void 0:b.textContent)??"").trim())},[]),children:e.jsx(cp.ItemSlot,{scope:n,value:r,disabled:a,textValue:p,children:e.jsx(js.div,{role:"option","aria-labelledby":v,"data-highlighted":x?"":void 0,"aria-selected":f&&x,"data-state":f?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...o,ref:N,onFocus:Kt(o.onFocus,()=>u(!0)),onBlur:Kt(o.onBlur,()=>u(!1)),onClick:Kt(o.onClick,()=>{w.current!=="mouse"&&j()}),onPointerUp:Kt(o.onPointerUp,()=>{w.current==="mouse"&&j()}),onPointerDown:Kt(o.onPointerDown,b=>{w.current=b.pointerType}),onPointerMove:Kt(o.onPointerMove,b=>{var C;w.current=b.pointerType,a?(C=m.onItemLeave)==null||C.call(m):w.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Kt(o.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=m.onItemLeave)==null||C.call(m))}),onKeyDown:Kt(o.onKeyDown,b=>{var S;((S=m.searchRef)==null?void 0:S.current)!==""&&b.key===" "||(t7.includes(b.key)&&j(),b.key===" "&&b.preventDefault())})})})})});xE.displayName=gf;var pu="SelectItemText",gE=g.forwardRef((t,s)=>{const{__scopeSelect:n,className:r,style:a,...i}=t,o=uo(pu,n),d=ho(pu,n),m=pE(pu,n),f=a7(pu,n),[p,h]=g.useState(null),x=Gs(s,j=>h(j),m.onItemTextChange,j=>{var b;return(b=d.itemTextRefCallback)==null?void 0:b.call(d,j,m.value,m.disabled)}),u=p==null?void 0:p.textContent,N=g.useMemo(()=>e.jsx("option",{value:m.value,disabled:m.disabled,children:u},m.value),[m.disabled,m.value,u]),{onNativeOptionAdd:v,onNativeOptionRemove:w}=f;return cr(()=>(v(N),()=>w(N)),[v,w,N]),e.jsxs(e.Fragment,{children:[e.jsx(js.span,{id:m.textId,...i,ref:x}),m.isSelected&&o.valueNode&&!o.valueNodeHasChildren?zu.createPortal(i.children,o.valueNode):null]})});gE.displayName=pu;var vE="SelectItemIndicator",yE=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t;return pE(vE,n).isSelected?e.jsx(js.span,{"aria-hidden":!0,...r,ref:s}):null});yE.displayName=vE;var Cy="SelectScrollUpButton",bE=g.forwardRef((t,s)=>{const n=ho(Cy,t.__scopeSelect),r=Vb(Cy,t.__scopeSelect),[a,i]=g.useState(!1),o=Gs(s,r.onScrollButtonChange);return cr(()=>{if(n.viewport&&n.isPositioned){let d=function(){const f=m.scrollTop>0;i(f)};const m=n.viewport;return d(),m.addEventListener("scroll",d),()=>m.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),a?e.jsx(NE,{...t,ref:o,onAutoScroll:()=>{const{viewport:d,selectedItem:m}=n;d&&m&&(d.scrollTop=d.scrollTop-m.offsetHeight)}}):null});bE.displayName=Cy;var Ay="SelectScrollDownButton",jE=g.forwardRef((t,s)=>{const n=ho(Ay,t.__scopeSelect),r=Vb(Ay,t.__scopeSelect),[a,i]=g.useState(!1),o=Gs(s,r.onScrollButtonChange);return cr(()=>{if(n.viewport&&n.isPositioned){let d=function(){const f=m.scrollHeight-m.clientHeight,p=Math.ceil(m.scrollTop)<f;i(p)};const m=n.viewport;return d(),m.addEventListener("scroll",d),()=>m.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),a?e.jsx(NE,{...t,ref:o,onAutoScroll:()=>{const{viewport:d,selectedItem:m}=n;d&&m&&(d.scrollTop=d.scrollTop+m.offsetHeight)}}):null});jE.displayName=Ay;var NE=g.forwardRef((t,s)=>{const{__scopeSelect:n,onAutoScroll:r,...a}=t,i=ho("SelectScrollButton",n),o=g.useRef(null),d=dp(n),m=g.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return g.useEffect(()=>()=>m(),[m]),cr(()=>{var p;const f=d().find(h=>h.ref.current===document.activeElement);(p=f==null?void 0:f.ref.current)==null||p.scrollIntoView({block:"nearest"})},[d]),e.jsx(js.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Kt(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Kt(a.onPointerMove,()=>{var f;(f=i.onItemLeave)==null||f.call(i),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Kt(a.onPointerLeave,()=>{m()})})}),x7="SelectSeparator",g7=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t;return e.jsx(js.div,{"aria-hidden":!0,...r,ref:s})});g7.displayName=x7;var ky="SelectArrow",v7=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t,a=up(n),i=uo(ky,n),o=ho(ky,n);return i.open&&o.position==="popper"?e.jsx(Gf,{...a,...r,ref:s}):null});v7.displayName=ky;var y7="SelectBubbleInput",wE=g.forwardRef(({__scopeSelect:t,value:s,...n},r)=>{const a=g.useRef(null),i=Gs(r,a),o=Zy(s);return g.useEffect(()=>{const d=a.current;if(!d)return;const m=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(m,"value").set;if(o!==s&&p){const h=new Event("change",{bubbles:!0});p.call(d,s),d.dispatchEvent(h)}},[o,s]),e.jsx(js.select,{...n,style:{...QR,...n.style},ref:i,defaultValue:s})});wE.displayName=y7;function SE(t){return t===""||t===void 0}function CE(t){const s=Sr(t),n=g.useRef(""),r=g.useRef(0),a=g.useCallback(o=>{const d=n.current+o;s(d),(function m(f){n.current=f,window.clearTimeout(r.current),f!==""&&(r.current=window.setTimeout(()=>m(""),1e3))})(d)},[s]),i=g.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return g.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,a,i]}function AE(t,s,n){const a=s.length>1&&Array.from(s).every(f=>f===s[0])?s[0]:s,i=n?t.indexOf(n):-1;let o=b7(t,Math.max(i,0));a.length===1&&(o=o.filter(f=>f!==n));const m=o.find(f=>f.textValue.toLowerCase().startsWith(a.toLowerCase()));return m!==n?m:void 0}function b7(t,s){return t.map((n,r)=>t[(s+r)%t.length])}var j7=JR,N7=tE,w7=nE,S7=rE,C7=aE,A7=iE,k7=dE,D7=hE,R7=fE,kE=xE,DE=gE,RE=yE,E7=bE,_7=jE;function Dt({...t}){return e.jsx(j7,{"data-slot":"select",...t})}function xS({...t}){return e.jsx(D7,{"data-slot":"select-group",...t})}function Rt({...t}){return e.jsx(w7,{"data-slot":"select-value",...t})}function Et({className:t,size:s="default",children:n,...r}){return e.jsxs(N7,{"data-slot":"select-trigger","data-size":s,className:Nt("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-full items-center justify-between gap-2 rounded-md border bg-input-background px-3 py-2 text-sm whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r,children:[n,e.jsx(S7,{asChild:!0,children:e.jsx(Aa,{className:"size-4 opacity-50"})})]})}function _t({className:t,children:s,position:n="popper",...r}){return e.jsx(C7,{children:e.jsxs(A7,{"data-slot":"select-content",className:Nt("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,...r,children:[e.jsx(P7,{}),e.jsx(k7,{className:Nt("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:s}),e.jsx(O7,{})]})})}function T7({className:t,...s}){return e.jsx(R7,{"data-slot":"select-label",className:Nt("text-muted-foreground px-2 py-1.5 text-xs",t),...s})}function Me({className:t,children:s,...n}){return e.jsxs(kE,{"data-slot":"select-item",className:Nt("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...n,children:[e.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:e.jsx(RE,{children:e.jsx(Hn,{className:"size-4"})})}),e.jsx(DE,{children:s})]})}function P7({className:t,...s}){return e.jsx(E7,{"data-slot":"select-scroll-up-button",className:Nt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(yu,{className:"size-4"})})}function O7({className:t,...s}){return e.jsx(_7,{"data-slot":"select-scroll-down-button",className:Nt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Aa,{className:"size-4"})})}function Ts({className:t,...s}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto custom-scrollbar-x-slim",children:e.jsx("table",{"data-slot":"table",className:Nt("w-full caption-bottom text-sm",t),...s})})}function Ps({className:t,...s}){return e.jsx("thead",{"data-slot":"table-header",className:Nt("[&_tr]:border-b",t),...s})}function Os({className:t,...s}){return e.jsx("tbody",{"data-slot":"table-body",className:Nt("[&_tr:last-child]:border-0",t),...s})}function it({className:t,...s}){return e.jsx("tr",{"data-slot":"table-row",className:Nt("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",t),...s})}function fe({className:t,...s}){return e.jsx("th",{"data-slot":"table-head",className:Nt("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}function ue({className:t,...s}){return e.jsx("td",{"data-slot":"table-cell",className:Nt("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}const EE={getOnboardingPayments:async()=>{var s,n;const t=await Ee.getOnboardingPayments();if(!t.ok)throw new Error(((s=t.data)==null?void 0:s.message)||"Failed to fetch onboarding payments");return((n=t.data)==null?void 0:n.payments)||[]},getFnFSettlements:async()=>{var s,n;const t=await Ee.getFnFSettlements();if(!t.ok)throw new Error(((s=t.data)==null?void 0:s.message)||"Failed to fetch F&F settlements");return((n=t.data)==null?void 0:n.settlements)||[]},getFnFSettlementById:async t=>{var n,r;const s=await Ee.getFnFSettlementById(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch F&F details");return(r=s.data)==null?void 0:r.fnf},updatePayment:async(t,s)=>{var r;const n=await Ee.updatePayment(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to update payment");return n.data},calculateFnF:async t=>{var n;const s=await Ee.calculateFnF(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to calculate F&F");return s.data},addLineItem:async(t,s)=>{var r;const n=await Ee.addLineItem(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to add line item");return n.data},updateFnF:async(t,s)=>{var r;const n=await Ee.updateFnF(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to update F&F settlement");return n.data}};function L7({onNavigate:t,onViewPaymentDetails:s,onViewAuditDetails:n,onViewFnFDetails:r}){var T,I,B,G;const[a,i]=g.useState([]),[o,d]=g.useState([]),[m,f]=g.useState([]),[p,h]=g.useState(!0);g.useEffect(()=>{x()},[]);const x=async()=>{try{h(!0);const[K,H]=await Promise.all([EE.getFnFSettlements(),hs.getApplications()]),X=H.data||[],J=[];X.forEach(le=>{const xe=le.overallStatus||le.status,ce=["Payment Pending","Security Deposit","Security Details","LOI In Progress","LOI Issued","LOA Pending","Dealer Code Generation","LOA_APPROVAL"].includes(xe),ve=le.securityDeposits||[];ve.length>0?ve.forEach(Pe=>{J.push({...Pe,application:le,paymentStatus:Pe.status,paymentType:Pe.depositType,amount:Pe.amount,id:Pe.id,applicationId:le.applicationId||le.id,createdAt:Pe.createdAt,verificationDate:Pe.verifiedAt})}):ce&&(["Payment Pending","Security Deposit","Security Details","LOI In Progress"].includes(xe)?J.push({id:`virtual-${le.id}-sd`,applicationId:le.applicationId||le.id,application:le,paymentStatus:"Pending",paymentType:"SECURITY_DEPOSIT",amount:5e5,createdAt:le.updatedAt,isVirtual:!0}):["LOA Pending","Dealer Code Generation","LOA_APPROVAL"].includes(xe)&&J.push({id:`virtual-${le.id}-ff`,applicationId:le.applicationId||le.id,application:le,paymentStatus:"Pending",paymentType:"FIRST_FILL",amount:15e5,createdAt:le.updatedAt,isVirtual:!0}))}),i(J),d(K);const ae=X.filter(le=>le.status==="FDD_VERIFICATION"||le.overallStatus==="FDD Verification"||le.currentStage==="FDD");f(ae)}catch(K){console.error("Fetch error:",K),te.error("Failed to load dashboard data")}finally{h(!1)}},[u,N]=g.useState(!1),[v,w]=g.useState(!1),[j,b]=g.useState(null),[C,S]=g.useState([]),[R,_]=g.useState({department:"",description:"",type:"receivable",amount:""}),[A,E]=g.useState(""),q=()=>{const K=C.filter(J=>J.type==="receivable").reduce((J,ae)=>J+ae.amount,0),H=C.filter(J=>J.type==="payable").reduce((J,ae)=>J+ae.amount,0),X=H-K;return{totalReceivable:K,totalPayable:H,netAmount:X}},O=async()=>{if(C.length===0){te.error("Please add at least one line item");return}if(!A){te.error("Please add final remarks");return}try{h(!0),te.success("Finance summary submitted successfully"),N(!1),b(null),S([]),E(""),x()}catch{te.error("Failed to submit summary")}finally{h(!1)}},D=K=>{const H=String(K||"").trim().toLowerCase();return H==="paid"||H==="verified"},P=a.filter(K=>!D(K.paymentStatus)),L=a.filter(K=>D(K.paymentStatus)),$=o.filter(K=>K.status==="Initiated"||K.status==="Calculated"),Y=o.filter(K=>K.status==="Completed"||K.status==="Cleared"),Z=()=>{if(!R.department||!R.description||!R.amount){te.error("Please fill in all line item fields");return}const K={id:Date.now().toString(),department:R.department,description:R.description,type:R.type,amount:parseFloat(R.amount)};S([...C,K]),_({department:"",description:"",type:"receivable",amount:""}),te.success("Line item added")},W=K=>{S(C.filter(H=>H.id!==K)),te.info("Line item removed")},{totalReceivable:U,totalPayable:M,netAmount:z}=q();return p?e.jsxs("div",{className:"flex items-center justify-center p-20 text-re-red",children:[e.jsx(vn,{className:"w-8 h-8 animate-spin mr-3"}),e.jsx("span",{children:"Loading Finance Data..."})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl mb-2",children:"Finance Dashboard"}),e.jsx("p",{className:"text-slate-600",children:"Verify payments and create financial settlement summaries"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-3",children:[e.jsxs(Le,{className:"cursor-pointer hover:shadow-lg transition-shadow border-red-200 bg-red-50/20",onClick:()=>{m.length>0&&n?n(m[0].applicationId||m[0].id):t==null||t("finance-onboarding")},children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Xt,{className:"text-re-red font-bold",children:"Pending Audits"}),e.jsx(Je,{className:"text-3xl text-re-red",children:m.length})]}),e.jsxs(Fe,{children:[e.jsx("p",{className:"text-slate-600 text-xs font-medium",children:"FDD Sign-offs"}),e.jsx(se,{variant:"link",className:"p-0 h-auto text-re-red mt-2 text-xs",children:"Review Now →"})]})]}),e.jsxs(Le,{className:"cursor-pointer hover:shadow-lg transition-shadow border-yellow-200",onClick:()=>t==null?void 0:t("finance-onboarding"),children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Xt,{children:"Pending Verification"}),e.jsx(Je,{className:"text-3xl text-yellow-600",children:P.length})]}),e.jsxs(Fe,{children:[e.jsx("p",{className:"text-slate-600",children:"Onboarding Payments"}),e.jsx(se,{variant:"link",className:"p-0 h-auto text-re-red mt-2",children:"View All →"})]})]}),e.jsxs(Le,{className:"cursor-pointer hover:shadow-lg transition-shadow border-green-200",onClick:()=>t==null?void 0:t("finance-onboarding"),children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Xt,{children:"Verified"}),e.jsx(Je,{className:"text-3xl text-green-600",children:L.length})]}),e.jsxs(Fe,{children:[e.jsx("p",{className:"text-slate-600",children:"Total Validated"}),e.jsx(se,{variant:"link",className:"p-0 h-auto text-re-red mt-2",children:"View All →"})]})]}),e.jsxs(Le,{className:"cursor-pointer hover:shadow-lg transition-shadow border-orange-200",onClick:()=>t==null?void 0:t("finance-fnf"),children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Xt,{children:"Pending F&F Summary"}),e.jsx(Je,{className:"text-3xl text-orange-600",children:$.length})]}),e.jsxs(Fe,{children:[e.jsx("p",{className:"text-slate-600",children:"Offboarding Cases"}),e.jsx(se,{variant:"link",className:"p-0 h-auto text-re-red mt-2",children:"View All →"})]})]}),e.jsxs(Le,{className:"cursor-pointer hover:shadow-lg transition-shadow border-green-200",onClick:()=>t==null?void 0:t("finance-fnf"),children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Xt,{children:"F&F Completed"}),e.jsx(Je,{className:"text-3xl text-green-600",children:Y.length})]}),e.jsxs(Fe,{children:[e.jsx("p",{className:"text-slate-600",children:"Settlements Done"}),e.jsx(se,{variant:"link",className:"p-0 h-auto text-re-red mt-2",children:"View All →"})]})]})]}),e.jsxs(Bn,{defaultValue:"onboarding",className:"w-full",children:[e.jsxs($n,{className:"grid w-full grid-cols-2",children:[e.jsxs(Wt,{value:"onboarding",children:[e.jsx(ka,{className:"w-4 h-4 mr-2"}),"Onboarding"]}),e.jsxs(Wt,{value:"fnf",children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),"F&F Settlement"]})]}),e.jsx(Ut,{value:"onboarding",className:"space-y-4",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"Payment Verification"}),e.jsx(Xt,{children:"Verify dealer advance payments for onboarding applications"})]}),e.jsx(Fe,{children:e.jsxs(Bn,{defaultValue:"pending",className:"w-full",children:[e.jsxs($n,{children:[e.jsxs(Wt,{value:"pending",children:["Pending (",P.length,")"]}),e.jsxs(Wt,{value:"verified",children:["Verified (",L.length,")"]})]}),e.jsx(Ut,{value:"pending",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[P.map(K=>{var H,X;return e.jsx(Le,{className:"border-yellow-200 bg-yellow-50/30",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("h3",{className:"text-lg font-bold",children:((H=K.application)==null?void 0:H.applicationId)||"N/A"}),e.jsx(Ce,{className:"bg-yellow-100 text-yellow-700 border-yellow-300",children:K.paymentStatus})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Applicant Name"}),e.jsx("p",{className:"font-medium",children:(X=K.application)==null?void 0:X.applicantName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Type"}),e.jsx("p",{children:K.paymentType==="SECURITY_DEPOSIT"?"Security Deposit":K.paymentType==="FIRST_FILL"?"First Fill":K.paymentType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Amount"}),e.jsxs("p",{className:"text-re-red-hover font-bold",children:["₹",parseFloat(K.amount).toLocaleString("en-IN")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Created On"}),e.jsx("p",{children:Yt(K.createdAt)})]})]})]}),e.jsxs("div",{className:"ml-4 flex flex-col gap-2",children:[e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>{s&&s(K.applicationId||K.id)},children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),"View Details"]}),e.jsxs(se,{size:"sm",className:"bg-green-600 hover:bg-green-700 font-bold",onClick:()=>{s&&s(K.applicationId||K.id)},children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"Verify Payment"]})]})]})})},K.id)}),P.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(un,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No pending payment verifications"})]})]})}),e.jsx(Ut,{value:"verified",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:L.map(K=>{var H,X;return e.jsx(Le,{className:"border-green-200 bg-green-50/30",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("h3",{className:"text-lg font-bold",children:((H=K.application)==null?void 0:H.applicationId)||"N/A"}),e.jsx(Ce,{className:"bg-green-100 text-green-700 border-green-300",children:K.paymentStatus})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Applicant Name"}),e.jsx("p",{className:"font-medium",children:(X=K.application)==null?void 0:X.applicantName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Type"}),e.jsx("p",{children:K.paymentType==="SECURITY_DEPOSIT"?"Security Deposit":K.paymentType==="FIRST_FILL"?"First Fill":K.paymentType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Amount"}),e.jsxs("p",{className:"text-green-700 font-bold",children:["₹",parseFloat(K.amount).toLocaleString("en-IN")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Verified On"}),e.jsx("p",{children:K.verificationDate?Yt(K.verificationDate):"N/A"})]})]})]}),e.jsx("div",{className:"ml-4",children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>{s&&s(K.applicationId||K.id)},children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},K.id)})})})]})})]})}),e.jsx(Ut,{value:"fnf",className:"space-y-4",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"F&F Financial Summary"}),e.jsx(Xt,{children:"Create financial settlement summaries for resignation and termination cases"})]}),e.jsx(Fe,{children:e.jsxs(Bn,{defaultValue:"pending",className:"w-full",children:[e.jsxs($n,{children:[e.jsxs(Wt,{value:"pending",children:["Pending Summary (",$.length,")"]}),e.jsxs(Wt,{value:"completed",children:["Completed (",Y.length,")"]})]}),e.jsx(Ut,{value:"pending",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[$.map(K=>{var H,X,J,ae,le,xe,ce;return e.jsx(Le,{className:"border-orange-200 bg-orange-50/30",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("h3",{className:"text-lg font-bold",children:((H=K.resignation)==null?void 0:H.resignationId)||K.id}),e.jsx(Ce,{variant:"outline",children:K.resignation?"Resignation":K.terminationRequest?"Termination":"General"}),e.jsx(Ce,{className:"bg-orange-100 text-orange-700 border-orange-300",children:K.status})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 text-sm mb-3",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 text-sm mb-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 font-medium text-[10px] uppercase tracking-wider mb-1",children:"Dealer Name"}),e.jsx("p",{className:"font-semibold text-slate-900",children:((J=(X=K.outlet)==null?void 0:X.dealer)==null?void 0:J.fullName)||((ae=K.outlet)==null?void 0:ae.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 font-medium text-[10px] uppercase tracking-wider mb-1",children:"Dealer Code"}),e.jsx("p",{className:"font-mono text-xs font-bold text-blue-600",children:((le=K.outlet)==null?void 0:le.code)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 font-medium text-[10px] uppercase tracking-wider mb-1",children:"Location"}),e.jsxs("p",{className:"text-slate-900",children:[((xe=K.outlet)==null?void 0:xe.city)||"N/A",", ",((ce=K.outlet)==null?void 0:ce.state)||""]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-white/50 p-2 rounded-lg border border-slate-100",children:[e.jsx(un,{className:"w-4 h-4 text-emerald-500"}),e.jsxs("span",{className:"text-slate-600 font-medium",children:[e.jsx("span",{className:"text-emerald-600 font-bold",children:(K.clearances||[]).filter(ve=>ve.status==="NOC Submitted"||ve.status==="Dues Pending").length}),"/16 Departments Cleared"]})]})]})]}),e.jsxs("div",{className:"ml-4 flex flex-col gap-2",children:[e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>{b(K),w(!0)},children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),"View Details"]}),e.jsxs(se,{size:"sm",className:"bg-blue-600 hover:bg-blue-700",onClick:()=>{b(K),S([]),E(""),N(!0)},children:[e.jsx(ak,{className:"w-4 h-4 mr-2"}),"Create Summary"]})]})]})})},K.id)}),$.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(Ns,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No F&F cases pending financial summary"})]})]})}),e.jsx(Ut,{value:"completed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:Y.map(K=>e.jsx(Le,{className:"border-green-200 bg-green-50/30",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("h3",{className:"text-lg font-bold",children:K.id}),e.jsx(Ce,{variant:"outline",children:K.type}),e.jsx(Ce,{className:"bg-green-100 text-green-700 border-green-300",children:K.status})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{className:"font-medium",children:K.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:K.dealerCode})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Net Settlement"}),e.jsxs("p",{className:K.netAmount&&K.netAmount>=0?"text-green-700":"text-red-700",children:["₹",K.netAmount?Math.abs(K.netAmount).toLocaleString("en-IN"):"0"]}),e.jsx("p",{className:"text-xs text-slate-500",children:K.netAmount&&K.netAmount>=0?"Payable to Dealer":"Receivable from Dealer"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Completed On"}),e.jsx("p",{children:K.completedOn})]})]})]}),e.jsx("div",{className:"ml-4",children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>{r&&r(K.id)},children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},K.id))})})]})})]})})]}),e.jsx(ds,{open:u,onOpenChange:N,children:e.jsxs(os,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Create Financial Settlement Summary"}),e.jsxs(bs,{children:[((T=j==null?void 0:j.resignation)==null?void 0:T.resignationId)||(j==null?void 0:j.id)," - ",j==null?void 0:j.dealerName," (",j==null?void 0:j.dealerCode,")"]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"border rounded-lg p-4 bg-slate-50",children:[e.jsx("h3",{className:"text-sm font-bold mb-4",children:"Add Financial Line Item"}),e.jsxs("div",{className:"grid grid-cols-12 gap-3",children:[e.jsxs("div",{className:"col-span-3",children:[e.jsx(de,{className:"text-xs",children:"Department"}),e.jsx(at,{placeholder:"e.g., Warranty",value:R.department,onChange:K=>_({...R,department:K.target.value})})]}),e.jsxs("div",{className:"col-span-4",children:[e.jsx(de,{className:"text-xs",children:"Description"}),e.jsx(at,{placeholder:"e.g., Pending warranty claims",value:R.description,onChange:K=>_({...R,description:K.target.value})})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(de,{className:"text-xs",children:"Type"}),e.jsxs(Dt,{value:R.type,onValueChange:K=>_({...R,type:K}),children:[e.jsx(Et,{children:e.jsx(Rt,{})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"receivable",children:"Receivable"}),e.jsx(Me,{value:"payable",children:"Payable"})]})]})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(de,{className:"text-xs",children:"Amount (₹)"}),e.jsx(at,{type:"number",placeholder:"0",value:R.amount,onChange:K=>_({...R,amount:K.target.value})})]}),e.jsx("div",{className:"col-span-1 flex items-end",children:e.jsx(se,{size:"sm",onClick:Z,className:"w-full bg-re-red hover:bg-re-red-hover",children:e.jsx(An,{className:"w-4 h-4"})})})]})]}),C.length>0&&e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Department"}),e.jsx(fe,{children:"Description"}),e.jsx(fe,{className:"text-center",children:"Type"}),e.jsx(fe,{className:"text-right",children:"Amount"}),e.jsx(fe,{className:"w-16"})]})}),e.jsx(Os,{children:C.map(K=>e.jsxs(it,{children:[e.jsx(ue,{children:K.department}),e.jsx(ue,{children:K.description}),e.jsx(ue,{className:"text-center",children:e.jsx(Ce,{className:K.type==="receivable"?"bg-red-100 text-red-700 border-red-200":"bg-green-100 text-green-700 border-green-200",children:K.type==="receivable"?"Receivable":"Payable"})}),e.jsxs(ue,{className:`text-right font-medium ${K.type==="receivable"?"text-red-700":"text-green-700"}`,children:["₹",K.amount.toLocaleString("en-IN")]}),e.jsx(ue,{children:e.jsx(se,{size:"sm",variant:"ghost",onClick:()=>W(K.id),children:e.jsx(ar,{className:"w-4 h-4 text-red-600"})})})]},K.id))})]})}),C.length>0&&e.jsxs("div",{className:"border rounded-lg p-4 bg-slate-900 text-white",children:[e.jsx("h3",{className:"text-sm font-bold mb-4",children:"Financial Settlement Summary"}),e.jsxs("div",{className:"grid grid-cols-3 gap-8",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wider mb-1",children:"Total Payable"}),e.jsxs("p",{className:"text-3xl font-bold text-green-400",children:["₹",M.toLocaleString("en-IN")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wider mb-1",children:"Total receivable"}),e.jsxs("p",{className:"text-3xl font-bold text-red-400",children:["₹",U.toLocaleString("en-IN")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wider mb-1",children:"Net Settlement"}),e.jsxs("p",{className:`text-3xl font-bold ${z>=0?"text-green-400":"text-red-400"}`,children:["₹",Math.abs(z).toLocaleString("en-IN")]}),e.jsx("p",{className:"text-xs text-slate-400 mt-1 italic",children:z>=0?"Payable to Dealer":"Receivable from Dealer"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(de,{className:"font-bold",children:["Summary Remarks ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ws,{placeholder:"Add your final reconciliation remarks here...",rows:4,value:A,onChange:K=>E(K.target.value)})]})]}),e.jsxs(bn,{className:"border-t pt-4",children:[e.jsx(se,{variant:"outline",onClick:()=>N(!1),children:"Discard"}),e.jsxs(se,{className:"bg-green-600 hover:bg-green-700",onClick:O,disabled:C.length===0,children:[e.jsx(ml,{className:"w-4 h-4 mr-2"}),"Finalize & Submit Summary"]})]})]})}),e.jsx(ds,{open:v,onOpenChange:w,children:e.jsxs(os,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Full Settlement Details"}),e.jsxs(bs,{children:[((I=j==null?void 0:j.resignation)==null?void 0:I.resignationId)||(j==null?void 0:j.id)," - ",j==null?void 0:j.dealerName]})]}),j&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Le,{className:"bg-slate-50 border-none",children:e.jsxs(Fe,{className:"pt-6 grid grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500 uppercase tracking-wider mb-1",children:"Dealer Code"}),e.jsx("p",{className:"text-lg font-bold",children:((B=j.outlet)==null?void 0:B.code)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500 uppercase tracking-wider mb-1",children:"Location"}),e.jsx("p",{className:"text-lg font-bold",children:((G=j.outlet)==null?void 0:G.city)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500 uppercase tracking-wider mb-1",children:"Current Status"}),e.jsx(Ce,{variant:"outline",className:"bg-red-50 text-re-red-hover border-red-200",children:j.status})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Le,{className:"border-blue-100",children:[e.jsx(Qe,{className:"bg-blue-50/50 pb-2",children:e.jsxs(Je,{className:"text-sm font-bold flex items-center gap-2",children:[e.jsx(dl,{className:"w-4 h-4 text-blue-600"}),"Receivables Check"]})}),e.jsxs(Fe,{className:"pt-4 space-y-3",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-500",children:"Security Deposit Credits"}),e.jsxs("span",{className:"font-bold text-slate-900",children:["₹",parseFloat(j.totalPayables||0).toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-500",children:"Other Payable Credits"}),e.jsx("span",{className:"font-bold text-slate-900",children:"₹0"})]}),e.jsxs("div",{className:"border-t pt-2 flex justify-between font-bold text-blue-700",children:[e.jsx("span",{children:"Total Payables"}),e.jsxs("span",{children:["₹",parseFloat(j.totalPayables||0).toLocaleString("en-IN")]})]})]})]}),e.jsxs(Le,{className:"border-red-100 shadow-sm",children:[e.jsx(Qe,{className:"bg-red-50/30 pb-2 border-b border-red-50",children:e.jsxs(Je,{className:"text-sm font-bold flex items-center gap-2 text-red-700",children:[e.jsx(Yo,{className:"w-4 h-4"}),"Receivables Check"]})}),e.jsxs(Fe,{className:"pt-4 space-y-3",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-500",children:"Departmental Dues (Recoverable)"}),e.jsxs("span",{className:"font-bold text-red-600",children:["₹",parseFloat(j.totalReceivables||0).toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-500",children:"Outstanding Invoices"}),e.jsx("span",{className:"font-bold text-slate-900",children:"₹0"})]}),e.jsxs("div",{className:"border-t pt-2 flex justify-between font-bold text-red-700",children:[e.jsx("span",{children:"Total Recoveries"}),e.jsxs("span",{children:["₹",parseFloat(j.totalReceivables||0).toLocaleString("en-IN")]})]})]})]})]}),e.jsxs("div",{className:"p-5 bg-slate-900 text-white rounded-xl flex items-center justify-between shadow-lg",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:`p-3 rounded-lg ${parseFloat(j.netAmount||0)>=0?"bg-emerald-500/20":"bg-rose-500/20"}`,children:e.jsx(ka,{className:`w-6 h-6 ${parseFloat(j.netAmount||0)>=0?"text-emerald-400":"text-rose-400"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-400 uppercase font-bold tracking-widest mb-1",children:"Final Net Financial Position"}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("p",{className:`text-3xl font-bold tracking-tight ${parseFloat(j.netAmount||0)>=0?"text-emerald-400":"text-rose-400"}`,children:["₹",Math.abs(parseFloat(j.netAmount||0)).toLocaleString("en-IN")]}),e.jsxs("span",{className:"text-xs font-medium text-slate-400",children:["(",parseFloat(j.netAmount||0)>=0?"Payable to Dealer":"Recoverable from Dealer",")"]})]})]})]}),e.jsx(se,{className:"bg-blue-600 hover:bg-blue-500 px-6 font-bold shadow-md transition-all active:scale-95",children:"Generate PDF Summary"})]})]}),e.jsx(bn,{children:e.jsx(se,{onClick:()=>w(!1),children:"Close Overview"})})]})})]})}const Jl={getDashboardData:async()=>{var t;try{const s=await Ee.getDealerDashboard();return((t=s.data)==null?void 0:t.data)||s.data}catch(s){throw console.error("Get dealer dashboard error:",s),s}},getConstitutionalChanges:async()=>{try{return(await Ee.getConstitutionalChanges()).data}catch(t){throw console.error("Get constitutional changes error:",t),t}},submitConstitutionalChange:async t=>{try{return(await Ee.createConstitutionalChange(t)).data}catch(s){throw console.error("Submit constitutional change error:",s),s}},getRelocationRequests:async()=>{try{return(await Ee.getRelocationRequests()).data}catch(t){throw console.error("Get relocation requests error:",t),t}},submitRelocationRequest:async t=>{try{return(await Ee.createRelocationRequest(t)).data}catch(s){throw console.error("Submit relocation request error:",s),s}}};function I7({currentUser:t,onNavigate:s}){var u,N;const[n,r]=g.useState(!0),[a,i]=g.useState(null);if(g.useEffect(()=>{(async()=>{try{const w=await Jl.getDashboardData();i(w)}catch(w){console.error("Failed to fetch dashboard:",w)}finally{r(!1)}})()},[]),n)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px]",children:[e.jsx(ns,{className:"w-10 h-10 text-re-red animate-spin mb-4"}),e.jsx("p",{className:"text-slate-600",children:"Loading your dashboard..."})]});const o=a||{},d=o.profile||{},m=o.stats||{constitutional:0,relocation:0,total:0},f=o.recentRequests||[],p=((u=o.outlets)==null?void 0:u[0])||{},h=[{title:"Constitutional Changes",value:m.constitutional,icon:hl,color:"bg-blue-500",change:"Active Requests",onClick:()=>s("dealer-constitutional")},{title:"Relocation Requests",value:m.relocation,icon:Vr,color:"bg-re-red",change:"Active Requests",onClick:()=>s("dealer-relocation")},{title:"My Outlets",value:((N=o.outlets)==null?void 0:N.length)||0,icon:QI,color:"bg-purple-500",change:"Registered",onClick:()=>{}},{title:"Total Requests",value:m.total,icon:dl,color:"bg-green-500",change:"All time",onClick:()=>{}}],x=[{title:"Constitutional Change",description:"Request change in business structure",icon:hl,color:"bg-blue-50 hover:bg-blue-100 border-blue-200",textColor:"text-blue-700",onClick:()=>s("dealer-constitutional")},{title:"Request Relocation",description:"Move dealership to new location",icon:Vr,color:"bg-red-50 hover:bg-red-100 border-red-200",textColor:"text-re-red",onClick:()=>s("dealer-relocation")}];return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg bg-gradient-to-r from-re-red to-re-red-hover p-6 text-white",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-white mb-2",children:["Welcome back, ",d.name||(t==null?void 0:t.name),"!"]}),e.jsxs("p",{className:"text-white/90",children:["Dealer Code: ",d.dealerCode," • ",d.businessName]}),e.jsxs("p",{className:"text-white/90 text-sm mt-1",children:[p.name," • ",p.location]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-white",children:"Active Dealership"}),e.jsxs(Ce,{className:"bg-green-500 text-white border-0 mt-2",children:[e.jsx(un,{className:"w-3 h-3 mr-1"}),"Operational"]})]})]})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:h.map((v,w)=>{const j=v.icon;return e.jsxs(Le,{className:"cursor-pointer hover:shadow-lg transition-shadow",onClick:v.onClick,children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Je,{className:"text-sm",children:v.title}),e.jsx("div",{className:`${v.color} p-2 rounded-lg`,children:e.jsx(j,{className:"h-4 w-4 text-white"})})]}),e.jsxs(Fe,{children:[e.jsx("div",{className:"text-slate-900 text-2xl",children:v.value}),e.jsx("p",{className:"text-xs text-slate-600 mt-1",children:v.change})]})]},w)})}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"Quick Actions"}),e.jsx(Xt,{children:"Submit new requests and manage your dealership"})]}),e.jsx(Fe,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:x.map((v,w)=>{const j=v.icon;return e.jsx("button",{onClick:v.onClick,className:`${v.color} border-2 rounded-lg p-4 text-left transition-all`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`${v.textColor} p-2 bg-white rounded-lg`,children:e.jsx(j,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:`${v.textColor} mb-1`,children:v.title}),e.jsx("p",{className:"text-slate-600 text-sm",children:v.description})]})]})},w)})})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"My Recent Requests"}),e.jsx(Xt,{children:"Track the status of your submitted requests"})]}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-3",children:f.map(v=>e.jsxs("div",{className:"flex items-center justify-between p-4 border border-slate-200 rounded-lg hover:bg-slate-50 transition-colors",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-slate-900",children:v.id}),e.jsx(Ce,{variant:"outline",className:"text-xs",children:v.type})]}),e.jsx("p",{className:"text-slate-600 text-sm",children:v.title}),e.jsxs("p",{className:"text-slate-500 text-xs mt-1",children:["Submitted on ",v.date]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ce,{className:`border ${v.color}`,children:v.status}),e.jsx(se,{variant:"ghost",size:"sm",children:"View"})]})]},v.id))})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"flex items-center gap-2",children:[e.jsx(vn,{className:"w-5 h-5 text-re-red"}),"Important Reminders"]})}),e.jsx(Fe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(sn,{className:"w-4 h-4 text-re-red mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 text-sm",children:"GST Filing Due"}),e.jsx("p",{className:"text-slate-600 text-xs",children:"Due by Jan 15, 2026"})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(sn,{className:"w-4 h-4 text-re-red mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 text-sm",children:"Inventory Audit Scheduled"}),e.jsx("p",{className:"text-slate-600 text-xs",children:"Jan 20, 2026"})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(un,{className:"w-4 h-4 text-green-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 text-sm",children:"Compliance Report Submitted"}),e.jsx("p",{className:"text-slate-600 text-xs",children:"Jan 2, 2026"})]})]})]})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"flex items-center gap-2",children:[e.jsx(Ra,{className:"w-5 h-5 text-blue-600"}),"Support & Help"]})}),e.jsx(Fe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 text-sm mb-1",children:"Regional Manager"}),e.jsx("p",{className:"text-slate-600 text-xs",children:"Rajesh Kumar - +91 98765 43210"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 text-sm mb-1",children:"Zonal Business Head"}),e.jsx("p",{className:"text-slate-600 text-xs",children:"Priya Sharma - +91 98765 43211"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 text-sm mb-1",children:"Support Email"}),e.jsx("p",{className:"text-slate-600 text-xs",children:"dealer.support@royalenfield.com"})]}),e.jsx(se,{variant:"outline",className:"w-full mt-2",children:"Contact Support"})]})})]})]})]})}function M7({id:t,onBack:s}){const n=["PAN Card","GST Certificate","Aadhaar Card","Security Deposit Receipt","First Fill Receipt","Partnership Deed","LLP Agreement","Certificate of Incorporation","MOA","AOA","Firm Registration","Rental Agreement","Property Documents","Nodal Agreement","Cancelled Check","LOI Acknowledgement","Architecture Blueprint","Site Plan","Other"],[r,a]=g.useState(null),[i,o]=g.useState(!0),[d,m]=g.useState([]),[f,p]=g.useState(""),[h,x]=g.useState(null),[u,N]=g.useState(!1),[v,w]=g.useState(!1),j={panNumber:"",gstNumber:"",registeredAddress:"",bankName:"",accountNumber:"",ifscCode:"",branchName:"",accountHolderName:""},[b,C]=g.useState(j),[S,R]=g.useState(j),_=JSON.stringify(b)!==JSON.stringify(S),A=new Set(d.map(L=>String(L.documentType||"").trim().toLowerCase())),E=f?A.has(f.toLowerCase()):!1;g.useEffect(()=>{q()},[t]);const q=async()=>{var L,$;o(!0);try{const[Y,Z]=await Promise.all([Ee.getApplicationById(t),Ee.getDocuments(t)]);if((L=Y.data)!=null&&L.success){const W=Y.data.data,U={panNumber:W.panNumber||"",gstNumber:W.gstNumber||"",registeredAddress:W.registeredAddress||W.address||"",bankName:W.bankName||"",accountNumber:W.accountNumber||"",ifscCode:W.ifscCode||"",branchName:W.branchName||"",accountHolderName:W.accountHolderName||W.applicantName||""};a(W),C(U),R(U)}(($=Z.data)!=null&&$.success||Z.ok)&&m(Z.data.data||[])}catch(Y){console.error("Failed to fetch details:",Y),te.error("Failed to load application details")}finally{o(!1)}},O=async()=>{var L;w(!0);try{console.log("Saving business details for:",t,b);const $=await Ee.updateApplication(t,b);if($.ok)te.success("Business details saved successfully"),await q();else{const Y=((L=$.data)==null?void 0:L.message)||"Failed to update business details";te.error(Y),console.error("Update failed:",$)}}catch($){console.error("Save details fatal error:",$),te.error($.message||"A network error occurred while saving")}finally{w(!1)}},D=L=>{L.target.files&&L.target.files[0]&&x(L.target.files[0])},P=async()=>{var $,Y,Z;if(!h||!f){te.error("Please select a document type and file");return}const L=new FormData;L.append("file",h),L.append("documentType",f),N(!0);try{const W=await Ee.uploadDocument(t,L);if(($=W.data)!=null&&$.success||W.ok){te.success("Document uploaded successfully"),x(null),p("");const U=document.getElementById("file-upload");U&&(U.value="");const M=await Ee.getDocuments(t);((Y=M.data)!=null&&Y.success||M.ok)&&m(M.data.data||[])}else te.error(((Z=W.data)==null?void 0:Z.message)||"Upload failed")}catch(W){console.error("Upload error:",W),te.error("Upload failed")}finally{N(!1)}};return i?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(xr,{className:"w-8 h-8 animate-spin text-re-red"})}):r?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("button",{onClick:s,className:"mr-3 p-1.5 rounded-full hover:bg-slate-200 text-slate-600 transition-colors","data-testid":"onboarding-prospective-details-back-btn",children:e.jsx(lo,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 text-2xl font-bold mb-1",children:"Application Details"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-slate-600 font-medium","data-testid":"onboarding-prospective-details-app-id",children:r.applicationId||"Loading..."}),r.districtId?e.jsx("span",{className:"text-[10px] bg-green-100 text-green-700 font-bold px-1.5 py-0.5 rounded uppercase tracking-wider","data-testid":"onboarding-prospective-details-type-badge",children:"Opportunity"}):e.jsx("span",{className:"text-[10px] bg-blue-100 text-blue-700 font-bold px-1.5 py-0.5 rounded uppercase tracking-wider","data-testid":"onboarding-prospective-details-type-badge",children:"Future Reference"})]})]})]})}),e.jsxs("div",{className:"animate-in fade-in duration-500 space-y-6",children:[e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 shadow-sm p-6","data-testid":"onboarding-prospective-details-summary-card",children:[e.jsx("div",{className:"mb-4 border-b pb-2",children:e.jsxs("h4",{className:"text-lg font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(_a,{className:"w-5 h-5 text-re-red"})," Application Summary"]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3","data-testid":"onboarding-prospective-details-applicant-info",children:[e.jsx("div",{className:"p-2 bg-blue-50 rounded-lg",children:e.jsx(Lr,{className:"w-4 h-4 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Applicant"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900","data-testid":"onboarding-prospective-details-name",children:r.applicantName}),e.jsxs("p",{className:"text-xs text-slate-600",children:[r.email," | ",r.phone]})]})]}),e.jsxs("div",{className:"flex items-start gap-3","data-testid":"onboarding-prospective-details-location-info",children:[e.jsx("div",{className:"p-2 bg-red-50 rounded-lg",children:e.jsx(Vr,{className:"w-4 h-4 text-re-red"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Proposed Location"}),e.jsxs("p",{className:"text-sm font-semibold text-slate-900",children:[r.city,", ",r.state]}),e.jsx("p",{className:"text-xs text-slate-600",children:r.preferredLocation||"Standard Area"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3","data-testid":"onboarding-prospective-details-concept-info",children:[e.jsx("div",{className:"p-2 bg-green-50 rounded-lg",children:e.jsx(id,{className:"w-4 h-4 text-green-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Business Concept"}),e.jsxs("p",{className:"text-sm font-semibold text-slate-900",children:[r.businessType," - ",r.constitutionType]}),e.jsxs("p",{className:"text-xs text-slate-600",children:["Investment: ",r.investmentCapacity]})]})]}),e.jsxs("div",{className:"flex items-start gap-3","data-testid":"onboarding-prospective-details-date-info",children:[e.jsx("div",{className:"p-2 bg-slate-50 rounded-lg",children:e.jsx(vn,{className:"w-4 h-4 text-slate-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Applied On"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:r.createdAt?new Date(r.createdAt).toLocaleDateString("en-IN",{day:"numeric",month:"long",year:"numeric"}):"-"})]})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:e.jsxs("div",{className:"lg:col-span-3 space-y-6",children:[e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 shadow-sm overflow-hidden","data-testid":"onboarding-prospective-details-statutory-card",children:[e.jsxs("div",{className:"p-4 bg-slate-900 text-white flex justify-between items-center",children:[e.jsxs("h4",{className:"flex items-center gap-2 text-sm font-bold uppercase tracking-widest",children:[e.jsx(Wu,{className:"w-4 h-4 text-re-red"})," Statutory & Bank Details"]}),e.jsxs("button",{onClick:O,disabled:v,className:`text-xs text-white px-3 py-1 rounded font-bold transition-all flex items-center gap-1 disabled:opacity-50 ${_?"bg-emerald-600 hover:bg-emerald-700 ring-2 ring-emerald-300 animate-pulse":"bg-re-red hover:bg-re-red-hover"}`,"data-testid":"onboarding-prospective-details-save-statutory-btn",children:[v?e.jsx(xr,{className:"w-3 h-3 animate-spin"}):e.jsx(Zn,{className:"w-3 h-3"}),"Save Business Info"]})]}),e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-x-6 gap-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Registered Business Name"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all",value:b.accountHolderName,onChange:L=>C({...b,accountHolderName:L.target.value}),placeholder:"As per legal documents","data-testid":"onboarding-prospective-details-input-biz-name"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Permanent Account Number (PAN)"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all uppercase",value:b.panNumber,onChange:L=>C({...b,panNumber:L.target.value.toUpperCase()}),placeholder:"ABCDE1234F",maxLength:10,"data-testid":"onboarding-prospective-details-input-pan"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"GST Identification Number (GSTIN)"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all uppercase",value:b.gstNumber,onChange:L=>C({...b,gstNumber:L.target.value.toUpperCase()}),placeholder:"27ABCDE1234F1Z5",maxLength:15,"data-testid":"onboarding-prospective-details-input-gst"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Registered Office Address"}),e.jsx("textarea",{rows:1,className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all",value:b.registeredAddress,onChange:L=>C({...b,registeredAddress:L.target.value}),placeholder:"Full legal address","data-testid":"onboarding-prospective-details-input-address"})]}),e.jsx("div",{className:"md:col-span-2 border-t pt-2 mt-2",children:e.jsxs("h5",{className:"text-xs font-black text-slate-900 uppercase flex items-center gap-2 mb-3",children:[e.jsx(dk,{className:"w-3.5 h-3.5 text-blue-600"})," Primary Bank Information"]})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Bank Name"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all",value:b.bankName,onChange:L=>C({...b,bankName:L.target.value}),placeholder:"e.g. HDFC Bank","data-testid":"onboarding-prospective-details-input-bank"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Account Number"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all",value:b.accountNumber,onChange:L=>C({...b,accountNumber:L.target.value}),placeholder:"Bank account number","data-testid":"onboarding-prospective-details-input-acc-num"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"IFSC Code"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all uppercase",value:b.ifscCode,onChange:L=>C({...b,ifscCode:L.target.value.toUpperCase()}),placeholder:"HDFC0001234",maxLength:11,"data-testid":"onboarding-prospective-details-input-ifsc"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Branch Name"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all",value:b.branchName,onChange:L=>C({...b,branchName:L.target.value}),placeholder:"e.g. South Mumbai","data-testid":"onboarding-prospective-details-input-branch"})]})]})})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 shadow-sm overflow-hidden","data-testid":"onboarding-prospective-details-upload-card",children:[e.jsx("div",{className:"p-4 border-b border-slate-200 bg-slate-50 flex justify-between items-center",children:e.jsxs("h4",{className:"flex items-center gap-2 text-sm font-bold uppercase tracking-widest text-slate-900",children:[e.jsx(or,{className:"w-4 h-4 text-re-red"})," Required Documents"]})}),e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-4 bg-slate-50 rounded-lg border border-slate-100",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Document Category"}),f&&e.jsx("span",{className:"rounded-full bg-red-50 px-2 py-0.5 text-[10px] font-bold text-re-red",children:E?"Already uploaded":"Pending upload"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Zn,{className:`pointer-events-none absolute left-3 top-1/2 z-10 h-4 w-4 -translate-y-1/2 ${E?"text-green-600":"text-slate-300"}`}),e.jsxs(Dt,{value:f,onValueChange:p,disabled:u,children:[e.jsx(Et,{className:"h-12 rounded-xl border-slate-200 bg-gradient-to-r from-white to-slate-50 pl-10 pr-3 text-sm font-medium text-slate-700 shadow-sm focus:border-re-red/40 focus:ring-2 focus:ring-re-red","data-testid":"onboarding-prospective-details-doc-type-select",children:e.jsx(Rt,{placeholder:"Choose document type"})}),e.jsx(_t,{className:"rounded-xl border-slate-200 shadow-lg","data-testid":"onboarding-prospective-details-doc-type-content",children:n.map(L=>{const $=A.has(L.toLowerCase());return e.jsxs(kE,{value:L,textValue:L,className:Nt("relative flex w-full cursor-default select-none items-center gap-2 rounded-lg py-2 pl-2 pr-8 text-sm text-slate-700 outline-none","focus:bg-red-50 focus:text-slate-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50"),"data-testid":`onboarding-prospective-details-doc-type-item-${L.replace(/\s+/g,"-").toLowerCase()}`,children:[e.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:e.jsx(RE,{children:e.jsx(Hn,{className:"size-4"})})}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx(Zn,{className:Nt("h-4 w-4 shrink-0",$?"text-green-600":"text-slate-300"),"aria-hidden":!0}),e.jsx(DE,{children:L})]})]},L)})})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Select File"}),e.jsx("input",{type:"file",id:"file-upload",className:"w-full text-xs text-slate-600 file:mr-4 file:py-1 file:px-4 file:rounded-full file:border-0 file:text-xs file:font-semibold file:bg-red-50 file:text-re-red hover:file:bg-red-100",onChange:D,disabled:u,"data-testid":"onboarding-prospective-details-file-input"})]}),e.jsx("div",{className:"md:col-span-2 flex justify-end",children:e.jsxs("button",{onClick:P,disabled:!h||!f||u,className:"bg-re-red text-white px-5 py-2 rounded-md hover:bg-re-red-hover disabled:opacity-50 text-xs font-bold transition-all shadow-sm flex items-center gap-2","data-testid":"onboarding-prospective-details-upload-btn",children:[u?e.jsx(xr,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(or,{className:"w-3.5 h-3.5"}),"Upload Document"]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-slate-900 border-b pb-1",children:[e.jsx(af,{className:"w-4 h-4 text-blue-600"}),e.jsxs("h3",{className:"text-xs font-black uppercase tracking-tighter",children:["Uploaded Library (",d.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3","data-testid":"onboarding-prospective-details-doc-library",children:d.length>0?d.map((L,$)=>e.jsxs("div",{className:"flex justify-between items-center p-3 border border-slate-100 rounded-xl bg-slate-50 group hover:border-red-200 transition-all","data-testid":`onboarding-prospective-details-doc-item-${$}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-white flex items-center justify-center border border-slate-200 group-hover:bg-blue-50",children:e.jsx(af,{className:"w-4 h-4 text-slate-400 group-hover:text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-bold text-slate-900","data-testid":`onboarding-prospective-details-doc-type-${$}`,children:L.documentType}),e.jsx("p",{className:"text-[10px] text-slate-400 truncate w-32",children:L.fileName})]})]}),e.jsx("span",{className:`text-[9px] px-2 py-0.5 rounded-full font-black uppercase tracking-tighter ${L.status==="Approved"?"bg-green-100 text-green-700":"bg-red-50 text-re-red"}`,"data-testid":`onboarding-prospective-details-doc-status-${$}`,children:L.status||"Pending"})]},L.id)):e.jsxs("div",{className:"col-span-2 py-8 text-center bg-slate-50 rounded-xl border border-dashed border-slate-200","data-testid":"onboarding-prospective-details-doc-empty",children:[e.jsx(_a,{className:"w-6 h-6 text-slate-300 mx-auto mb-2"}),e.jsx("p",{className:"text-xs text-slate-500 font-medium",children:"No documents in your library yet"})]})})]})]})]})]})})]})]}):e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 p-8 text-center",children:[e.jsx("p",{className:"text-slate-600 mb-4",children:"Application details not found."}),e.jsx("button",{onClick:s,className:"bg-re-red text-white px-4 py-2 rounded-md hover:bg-re-red-hover",children:"Go Back"})]})}function F7(){var f;const t=Lu(),s=tr(),n=yl(),{user:r}=In(p=>p.auth),[a,i]=g.useState(!1),[o,d]=g.useState("applicant"),m=()=>{t(CA()),te.info("Logged out successfully"),s("/")};return e.jsxs("div",{className:"flex h-screen bg-slate-50",children:[e.jsxs("div",{className:`bg-slate-900 text-white h-screen flex flex-col transition-all duration-300 ${a?"w-20":"w-64"}`,children:[e.jsx("div",{className:"p-4 border-b border-slate-800",children:a?e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-full",children:e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"block h-auto w-full max-h-10 object-contain"})}),e.jsx("button",{onClick:()=>i(!1),className:"p-1 hover:bg-slate-800 rounded transition-colors",title:"Expand sidebar",children:e.jsx(bi,{className:"w-5 h-5"})})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:()=>i(!0),className:"p-1 hover:bg-slate-800 rounded transition-colors",title:"Collapse sidebar",children:e.jsx(lo,{className:"w-5 h-5"})})}),e.jsx("div",{className:"w-full",children:e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"mx-auto block h-auto w-full max-h-14 object-contain"})}),e.jsx("p",{className:"text-center text-[10px] font-bold uppercase tracking-[0.2em] text-slate-400",children:"Applicant Portal"})]})}),e.jsx("nav",{className:"flex-1 p-4 space-y-2",children:e.jsx("div",{children:e.jsxs("button",{onClick:()=>{d("applicant"),s("/prospective-dashboard")},className:`w-full flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${o==="applicant"?"bg-re-red text-white hover:bg-re-red-hover":"text-slate-300 hover:bg-slate-800 hover:text-white"}`,children:[e.jsx(Ns,{className:"w-5 h-5 flex-shrink-0"}),!a&&e.jsx("span",{className:"flex-1 text-left",children:"My Applications"})]})})}),e.jsxs("div",{className:"p-4 border-t border-slate-800 space-y-2",children:[!a&&e.jsx("div",{className:"px-4 py-2 bg-slate-800 rounded-lg mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-re-red rounded-full flex items-center justify-center text-white ring-2 ring-white/20",children:e.jsx("span",{className:"font-bold",children:((f=r==null?void 0:r.name)==null?void 0:f.charAt(0))||"A"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:(r==null?void 0:r.name)||"Applicant"}),e.jsx("p",{className:"text-slate-400 truncate text-xs",children:(r==null?void 0:r.role)||"Prospective"})]})]})}),e.jsxs("button",{onClick:m,className:`w-full flex items-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all h-9 px-4 py-2 text-slate-300 hover:bg-slate-800 hover:text-white ${a?"justify-center":"justify-start"}`,children:[e.jsx(hk,{className:"w-5 h-5 flex-shrink-0"}),!a&&e.jsx("span",{className:"ml-3",children:"Logout"})]})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx("header",{className:"bg-white border-b border-slate-200 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 text-xl font-semibold",children:n.pathname.includes("/application/")?"Application details":"Applicant management"}),e.jsx("p",{className:"text-slate-600 text-sm max-w-2xl leading-snug",children:n.pathname.includes("/application/")?"Review and update statutory information and required documents for this application. Progress is coordinated by Royal Enfield after you submit.":"Start or continue your dealership application, upload documents, and use links we email you (for example the questionnaire)."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-slate-100 rounded-lg",children:[e.jsx("div",{className:"w-8 h-8 bg-re-red rounded-full flex items-center justify-center ring-2 ring-re-red/20",children:e.jsx(Lr,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-slate-900 text-sm font-medium",children:(r==null?void 0:r.name)||"Applicant"}),e.jsx("p",{className:"text-slate-600 text-xs",children:(r==null?void 0:r.role)||"User"})]})]}),e.jsx("button",{className:"p-2 rounded-md hover:bg-slate-100",title:"Refresh",onClick:()=>window.location.reload(),children:e.jsx(xr,{className:"w-4 h-4 text-slate-600"})})]})]})}),e.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:e.jsxs(Xv,{children:[e.jsx(ks,{path:"/",element:e.jsx(B7,{})}),e.jsx(ks,{path:"/application/:id",element:e.jsx($7,{})})]})})]})]})}function B7(){const t=tr(),{user:s}=In(i=>i.auth),[n,r]=g.useState([]);g.useEffect(()=>{s!=null&&s.id&&a()},[s==null?void 0:s.id]);const a=async()=>{var i;try{const o=await Ee.getApplications();(i=o.data)!=null&&i.success&&r(o.data.data)}catch(o){console.error("Failed to fetch applications",o)}};return e.jsx("div",{className:"max-w-7xl mx-auto",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-8",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 text-3xl font-bold mb-2",children:"My Applications"}),e.jsx("p",{className:"text-slate-500 font-medium",children:"Track and manage your dealership applications"})]})}),n.length===0?e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 border-dashed p-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-50 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(Ns,{className:"w-8 h-8 text-slate-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-slate-900 mb-1",children:"No applications found"}),e.jsx("p",{className:"text-slate-500 max-w-sm mx-auto mb-6",children:"You haven't submitted any dealership applications yet."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:n.map(i=>e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 p-6 shadow-sm hover:shadow-md hover:border-re-red cursor-pointer transition-all group",onClick:()=>t(`/prospective-dashboard/application/${i.id}`),children:[e.jsx("div",{className:"mb-4",children:e.jsx("div",{className:"w-12 h-12 bg-red-50 rounded-xl flex items-center justify-center group-hover:bg-re-red transition-colors",children:e.jsx(Ns,{className:"w-6 h-6 text-re-red group-hover:text-white"})})}),e.jsx("h3",{className:"text-xl font-bold text-slate-900 mb-1 truncate",children:i.applicationId}),e.jsxs("p",{className:"text-slate-500 text-sm mb-4 font-medium",children:[i.city,", ",i.state]}),e.jsx("div",{className:"space-y-4 pt-6 border-t border-slate-100",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-slate-500 font-medium",children:"Applied"}),e.jsx("span",{className:"text-xs font-bold text-slate-600",children:Yt(i.createdAt)})]})})]},i.id))})]})})}function $7(){const{id:t}=vd(),s=tr();return t?e.jsx("div",{className:"max-w-7xl mx-auto",children:e.jsx(M7,{id:t,onBack:()=>s("/prospective-dashboard")})}):null}function q7(){const t=tr(),[s,n]=g.useState([]),[r,a]=g.useState(!0),[i,o]=g.useState("");g.useEffect(()=>{d()},[]);const d=async()=>{var f;a(!0);try{const p=await Ee.getApplications();(f=p.data)!=null&&f.success&&n(p.data.data)}catch(p){console.error("Failed to fetch FDD applications:",p),te.error("Failed to load assigned applications")}finally{a(!1)}},m=s.filter(f=>{var p;return f.applicationId.toLowerCase().includes(i.toLowerCase())||f.applicantName.toLowerCase().includes(i.toLowerCase())||((p=f.city)==null?void 0:p.toLowerCase().includes(i.toLowerCase()))});return e.jsxs("div",{className:"space-y-6 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-slate-900 tracking-tight",children:"FDD Dashboard"}),e.jsx("p",{className:"text-slate-500",children:"Manage financial due diligence for assigned dealer applications"})]}),e.jsxs("button",{onClick:d,className:"flex items-center gap-2 px-4 py-2 bg-white border border-slate-200 rounded-lg hover:bg-slate-50 transition-colors text-sm font-medium",children:[e.jsx(xr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsx(Le,{className:"bg-white border-slate-200 shadow-sm",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"Total Assigned"}),e.jsx("h3",{className:"text-2xl font-bold text-slate-900",children:s.length})]}),e.jsx("div",{className:"p-2 bg-slate-100 rounded-lg text-slate-600",children:e.jsx(Ns,{className:"w-5 h-5"})})]})})}),e.jsx(Le,{className:"bg-white border-slate-200 shadow-sm",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"Pending Reports"}),e.jsx("h3",{className:"text-2xl font-bold text-slate-900",children:s.filter(f=>f.currentStage==="FDD"||f.overallStatus==="Active").length})]}),e.jsx("div",{className:"p-2 bg-slate-100 rounded-lg text-slate-600",children:e.jsx(vn,{className:"w-5 h-5"})})]})})}),e.jsx(Le,{className:"bg-white border-slate-200 shadow-sm",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"Completed Reports"}),e.jsx("h3",{className:"text-2xl font-bold text-slate-900",children:"0"})]}),e.jsx("div",{className:"p-2 bg-slate-100 rounded-lg text-slate-600",children:e.jsx(Zn,{className:"w-5 h-5"})})]})})})]}),e.jsxs(Le,{className:"shadow-sm border-slate-200 overflow-hidden",children:[e.jsxs(Qe,{className:"bg-white border-b border-slate-100 px-6 py-4 flex flex-row items-center justify-between",children:[e.jsxs(Je,{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(Ns,{className:"w-5 h-5 text-blue-600"}),"My Assigned Cases"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx("input",{type:"text",placeholder:"Search by ID or Name...",className:"pl-9 pr-4 py-2 bg-slate-50 border-slate-200 rounded-lg text-sm focus:ring-2 focus:ring-blue-500 transition-all outline-none",value:i,onChange:f=>o(f.target.value)})]}),e.jsx("button",{className:"p-2 border border-slate-200 rounded-lg hover:bg-slate-50 transition-colors",children:e.jsx(eb,{className:"w-4 h-4 text-slate-600"})})]})]}),e.jsx(Fe,{className:"p-0",children:r?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-6",children:[e.jsx(xr,{className:"w-10 h-10 animate-spin text-blue-600 mb-4"}),e.jsx("p",{className:"text-slate-500 font-medium",children:"Synchronizing application data..."})]}):m.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-6 text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-slate-50 rounded-full flex items-center justify-center mb-6",children:e.jsx(sn,{className:"w-10 h-10 text-slate-200"})}),e.jsx("h3",{className:"text-xl font-bold text-slate-900 mb-2",children:"No Applications Found"}),e.jsx("p",{className:"text-slate-500 max-w-md mx-auto",children:"You don't have any applications assigned for Financial Due Diligence at this time."})]}):e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{className:"bg-slate-50 border-b border-slate-200",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider",children:"Application Details"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider",children:"Location"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider",children:"Current Stage"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider text-right",children:"Action"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:m.map(f=>e.jsxs("tr",{className:"hover:bg-slate-50 transition-colors cursor-pointer group",onClick:()=>t(`/fdd-details/${f.id}`),children:[e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 text-blue-600 rounded-lg flex items-center justify-center font-bold",children:f.applicantName.charAt(0)}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-slate-900 group-hover:text-blue-600 transition-colors",children:f.applicationId}),e.jsx("p",{className:"text-xs text-slate-500",children:f.applicantName})]})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-slate-700",children:[f.city,", ",f.state]}),e.jsx("p",{className:"text-xs text-slate-400 capitalize",children:f.locationType||"New Market"})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx(Ce,{className:`px-3 py-1 rounded-full text-[10px] uppercase font-bold tracking-wider ${f.overallStatus==="Completed"?"bg-green-100 text-green-700":"bg-red-50 text-re-red-hover"}`,children:f.overallStatus==="Active"?"FDD Pending":f.overallStatus})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("button",{className:"p-2 text-slate-400 hover:text-blue-600 hover:bg-blue-50 rounded-lg transition-all",children:e.jsx(Ko,{className:"w-5 h-5"})})})]},f.id))})]})})})]})]})}const z7="modulepreload",U7=function(t){return"/"+t},gS={},Qo=function(s,n,r){let a=Promise.resolve();if(n&&n.length>0){let o=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),m=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));a=o(n.map(f=>{if(f=U7(f),f in gS)return;gS[f]=!0;const p=f.endsWith(".css"),h=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${h}`))return;const x=document.createElement("link");if(x.rel=p?"stylesheet":z7,p||(x.as="script"),x.crossOrigin="",x.href=f,m&&x.setAttribute("nonce",m),document.head.appendChild(x),p)return new Promise((u,N)=>{x.addEventListener("load",u),x.addEventListener("error",()=>N(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(o){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=o,window.dispatchEvent(d),!d.defaultPrevented)throw o}return a.then(o=>{for(const d of o||[])d.status==="rejected"&&i(d.reason);return s().catch(i)})};function V7(t,s=[]){let n=[];function r(i,o){const d=g.createContext(o);d.displayName=i+"Context";const m=n.length;n=[...n,o];const f=h=>{var j;const{scope:x,children:u,...N}=h,v=((j=x==null?void 0:x[t])==null?void 0:j[m])||d,w=g.useMemo(()=>N,Object.values(N));return e.jsx(v.Provider,{value:w,children:u})};f.displayName=i+"Provider";function p(h,x){var v;const u=((v=x==null?void 0:x[t])==null?void 0:v[m])||d,N=g.useContext(u);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[f,p]}const a=()=>{const i=n.map(o=>g.createContext(o));return function(d){const m=(d==null?void 0:d[t])||i;return g.useMemo(()=>({[`__scope${t}`]:{...d,[t]:m}}),[d,m])}};return a.scopeName=t,[r,H7(a,...s)]}function H7(...t){const s=t[0];if(t.length===1)return s;const n=()=>{const r=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((d,{useScope:m,scopeName:f})=>{const h=m(i)[`__scope${f}`];return{...d,...h}},{});return g.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return n.scopeName=s.scopeName,n}var W7=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Hb=W7.reduce((t,s)=>{const n=Hu(`Primitive.${s}`),r=g.forwardRef((a,i)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),Ig={exports:{}},Mg={};/**
* @license React
* use-sync-external-store-shim.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var vS;function G7(){if(vS)return Mg;vS=1;var t=pd();function s(h,x){return h===x&&(h!==0||1/h===1/x)||h!==h&&x!==x}var n=typeof Object.is=="function"?Object.is:s,r=t.useState,a=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function d(h,x){var u=x(),N=r({inst:{value:u,getSnapshot:x}}),v=N[0].inst,w=N[1];return i(function(){v.value=u,v.getSnapshot=x,m(v)&&w({inst:v})},[h,u,x]),a(function(){return m(v)&&w({inst:v}),h(function(){m(v)&&w({inst:v})})},[h]),o(u),u}function m(h){var x=h.getSnapshot;h=h.value;try{var u=x();return!n(h,u)}catch{return!0}}function f(h,x){return x()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:d;return Mg.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,Mg}var yS;function K7(){return yS||(yS=1,Ig.exports=G7()),Ig.exports}var Y7=K7();function Z7(){return Y7.useSyncExternalStore(Q7,()=>!0,()=>!1)}function Q7(){return()=>{}}var Wb="Avatar",[X7]=V7(Wb),[J7,_E]=X7(Wb),TE=g.forwardRef((t,s)=>{const{__scopeAvatar:n,...r}=t,[a,i]=g.useState("idle");return e.jsx(J7,{scope:n,imageLoadingStatus:a,onImageLoadingStatusChange:i,children:e.jsx(Hb.span,{...r,ref:s})})});TE.displayName=Wb;var PE="AvatarImage",eq=g.forwardRef((t,s)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:a=()=>{},...i}=t,o=_E(PE,n),d=tq(r,i),m=Sr(f=>{a(f),o.onImageLoadingStatusChange(f)});return cr(()=>{d!=="idle"&&m(d)},[d,m]),d==="loaded"?e.jsx(Hb.img,{...i,ref:s,src:r}):null});eq.displayName=PE;var OE="AvatarFallback",LE=g.forwardRef((t,s)=>{const{__scopeAvatar:n,delayMs:r,...a}=t,i=_E(OE,n),[o,d]=g.useState(r===void 0);return g.useEffect(()=>{if(r!==void 0){const m=window.setTimeout(()=>d(!0),r);return()=>window.clearTimeout(m)}},[r]),o&&i.imageLoadingStatus!=="loaded"?e.jsx(Hb.span,{...a,ref:s}):null});LE.displayName=OE;function bS(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function tq(t,{referrerPolicy:s,crossOrigin:n}){const r=Z7(),a=g.useRef(null),i=r?(a.current||(a.current=new window.Image),a.current):null,[o,d]=g.useState(()=>bS(i,t));return cr(()=>{d(bS(i,t))},[i,t]),cr(()=>{const m=h=>()=>{d(h)};if(!i)return;const f=m("loaded"),p=m("error");return i.addEventListener("load",f),i.addEventListener("error",p),s&&(i.referrerPolicy=s),typeof n=="string"&&(i.crossOrigin=n),()=>{i.removeEventListener("load",f),i.removeEventListener("error",p)}},[i,n,s]),o}var sq=TE,nq=LE;function Nm({className:t,...s}){return e.jsx(sq,{"data-slot":"avatar",className:Nt("relative flex size-10 shrink-0 overflow-hidden rounded-full",t),...s})}function wm({className:t,...s}){return e.jsx(nq,{"data-slot":"avatar-fallback",className:Nt("bg-muted flex size-full items-center justify-center rounded-full",t),...s})}const Sm="/collaboration",Cm={getWorknotes:async(t,s)=>(await qe.get(`${Sm}/worknotes`,{requestId:t,requestType:s})).data,addWorknote:async t=>(await qe.post(`${Sm}/worknotes`,t)).data,uploadAttachment:async(t,s,n)=>{const r=new FormData;return r.append("file",t),s&&r.append("requestId",s),n&&r.append("requestType",n),(await qe.post(`${Sm}/upload`,r,{headers:{"Content-Type":"multipart/form-data"}})).data},revokeParticipant:async(t,s)=>(await qe.delete(`${Sm}/participants/${t}`,{data:{reason:s}})).data},au=t=>[...t].sort((s,n)=>new Date(s.createdAt).getTime()-new Date(n.createdAt).getTime()),Fg=t=>{var s,n,r,a,i;return{name:((s=t==null?void 0:t.author)==null?void 0:s.name)||((n=t==null?void 0:t.author)==null?void 0:n.fullName)||"System",email:((r=t==null?void 0:t.author)==null?void 0:r.email)||"",role:String(((a=t==null?void 0:t.author)==null?void 0:a.role)||((i=t==null?void 0:t.author)==null?void 0:i.roleCode)||"")}},rq=new Set(["internal","workflow","system","audit","status"]),aq=t=>rq.has(String(t.noteType||"").toLowerCase()),iq=t=>{const s=String(t.noteType||"").toLowerCase();return s==="workflow"?"Workflow activity":s==="internal"?"Review / approval":s==="system"?"System":s==="audit"?"Audit":s==="status"?"Status update":"Activity"},lq=t=>{const s=String(t.noteType||"").toLowerCase();return s==="internal"?"APPROVAL":s==="workflow"?"WORKFLOW":s==="system"?"SYSTEM":s==="audit"?"AUDIT":s==="status"?"STATUS":"ACTIVITY"},jS=t=>t?new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}):"",Vc="https://dealeronboarding-uat.royalenfield.com/api".replace("/api","")||"http://localhost:5000";function IE(t){var Ks,Qs,Xs,$s,Q;const{user:s}=In(oe=>oe.auth),{id:n,type:r}=vd(),a=yl(),i=tr(),o=t.requestId||n||"",d=t.requestType||r||((Ks=a.state)==null?void 0:Ks.requestType)||"application",m=t.mode||((Qs=a.state)==null?void 0:Qs.mode)||"page",[f,p]=g.useState(t.applicationName||((Xs=a.state)==null?void 0:Xs.applicationName)||"Application"),[h,x]=g.useState(t.registrationNumber||(($s=a.state)==null?void 0:$s.registrationNumber)||""),u=t.onBack||(()=>i(-1)),N=t.participants||((Q=a.state)==null?void 0:Q.participants)||[],[v,w]=g.useState(N),[j,b]=g.useState([]),[C,S]=g.useState(""),[R,_]=g.useState(!1),[A,E]=g.useState(""),[q,O]=g.useState(0),[D,P]=g.useState(!0),[L,$]=g.useState(!1),[Y,Z]=g.useState([]),[W,U]=g.useState(!1),[M,z]=g.useState(!0),[T,I]=g.useState(""),[B,G]=g.useState(""),[K,H]=g.useState(null),[X,J]=g.useState(""),[ae,le]=g.useState(!1),{socket:xe}=QD(),ce=g.useRef(null),ve=g.useRef(null),[Pe,et]=g.useState(null),kt=(oe,we)=>oe.startsWith("image/")&&we?e.jsx("img",{src:`${Vc}/${we.replace(/\\/g,"/")}`,className:"w-full h-full object-cover rounded",alt:"Thumbnail"}):oe.startsWith("image/")?e.jsx(k1,{className:"w-5 h-5 text-blue-500"}):oe==="application/pdf"?e.jsx(Ns,{className:"w-5 h-5 text-red-500"}):e.jsx(af,{className:"w-5 h-5 text-slate-500"}),vt=["😊","😂","🤣","❤️","👍","🙏","🔥","✨","😍","🥰","😎","🤔","😅","🙌","👏","🎉","✅","❌","📌","📎","📍","💡","🔔","📢","⭐","🌟","💪","🚀","👀","💯","🌈","☀️","😢","😭","😞","😔","😟","😕","😠","😡","🤬","😤","😲","🙄","🤨","😓","😩","😫","🤐","😴","🤢","🤮","😱","🤡","💀","👻","🤝","👋","✌️","👌","✋","🍎","🍕","☕","💻","📱","⌚","📁","📄","📅","🔒","🔑","🛠️","⚙️","💬","💭","🌊","🍀","✈️","🏠"],ee=oe=>oe.split(" ").map(we=>we[0]).join("").toUpperCase().substring(0,2),ge=oe=>{const we=["bg-green-600","bg-blue-600","bg-purple-600","bg-re-red","bg-pink-600","bg-indigo-600","bg-teal-600"],Oe=oe.length%we.length;return we[Oe]},ye=[],Be=new Set;v.forEach(oe=>{var ke,je,Ve,Ge,nt,Zt,Jt;const we=((ke=oe.user)==null?void 0:ke.id)||oe.userId||"",Oe=oe.id;if(we&&!Be.has(we)){Be.add(we);const lt=((je=oe.user)==null?void 0:je.fullName)||((Ve=oe.user)==null?void 0:Ve.name)||oe.fullName||oe.name||"Unknown User",mt=((Ge=oe.user)==null?void 0:Ge.email)||oe.email||"",Ds=((nt=oe.user)==null?void 0:nt.roleCode)||oe.roleCode||((Zt=oe.user)==null?void 0:Zt.role)||oe.role||"Participant";ye.push({id:we,recordId:Oe,name:lt,email:mt,initials:ee(lt),color:ge(lt),role:Ds,isOnline:!1,revokedAt:(Jt=oe.metadata)==null?void 0:Jt.revokedAt})}});const $e=async()=>{try{P(!0);const oe=await Cm.getWorknotes(o,d);if(oe.success){const we=oe.data.map(Oe=>({id:Oe.id,noteText:Oe.noteText,noteType:Oe.noteType,createdAt:Oe.createdAt,userId:Oe.userId,author:Oe.author?Fg(Oe):{name:"System",email:"",role:"system"},attachments:Oe.attachments||[]}));b(au(we))}}catch(oe){console.error("Fetch notes error:",oe),te.error("Failed to load work notes")}finally{P(!1)}};g.useEffect(()=>{if($e(),xe)return xe.emit("join_room",o),xe.on("new_worknote",oe=>{const we={id:oe.id,noteText:oe.noteText,noteType:oe.noteType,createdAt:oe.createdAt,userId:oe.userId,author:oe.author?Fg(oe):{name:"System",email:"",role:"system"},attachments:oe.attachments||[]};b(Oe=>{if(Oe.some(Ve=>Ve.id===we.id))return Oe;const je=Oe.findIndex(Ve=>{var Ge,nt;return Ve.id.startsWith("temp-")&&Ve.noteText===we.noteText&&((Ge=Ve.author.email)==null?void 0:Ge.toLowerCase())===((nt=we.author.email)==null?void 0:nt.toLowerCase())});if(je!==-1){const Ve=[...Oe];return Ve[je]=we,au(Ve)}return au([...Oe,we])})}),()=>{xe.emit("leave_room",o),xe.off("new_worknote")}},[o,d,xe]),g.useEffect(()=>{if(!o||!d)return;(async()=>{var we,Oe,ke,je,Ve,Ge,nt,Zt,Jt,lt;try{let mt=null;if(d==="application")mt=await hs.getApplicationById(o),mt&&(v.length===0&&mt.participants&&w(mt.participants),(!f||f==="Application")&&p(mt.companyName||"Application"),h||x(mt.registrationNumber||""));else if(d==="termination"){const{API:Ds}=await Qo(async()=>{const{API:Ae}=await Promise.resolve().then(()=>cm);return{API:Ae}},void 0),ss=await Ds.getTerminationById(o);(we=ss.data)!=null&&we.success&&(mt=ss.data.termination,v.length===0&&mt.participants&&w(mt.participants),(!f||f==="Application"||f==="Termination")&&p(((Oe=mt.dealer)==null?void 0:Oe.businessName)||"Termination"),h||x(mt.requestId||""))}else if(d==="constitutional"||d==="constitutional-change"){const{API:Ds}=await Qo(async()=>{const{API:Ae}=await Promise.resolve().then(()=>cm);return{API:Ae}},void 0),ss=await Ds.getConstitutionalChangeById(o);(ke=ss.data)!=null&&ke.success&&(mt=ss.data.request,v.length===0&&mt.participants&&w(mt.participants),(!f||f==="Application"||f==="Constitutional Change")&&p(((je=mt.outlet)==null?void 0:je.name)||"Constitutional Change"),h||x(mt.requestId||""))}else if(d==="resignation"){const{API:Ds}=await Qo(async()=>{const{API:Ae}=await Promise.resolve().then(()=>cm);return{API:Ae}},void 0),ss=await Ds.getResignationById(o);(Ve=ss.data)!=null&&Ve.success&&(mt=ss.data.resignation,v.length===0&&mt.participants&&w(mt.participants),(!f||f==="Application"||f==="Resignation")&&p(((Ge=mt.dealer)==null?void 0:Ge.businessName)||"Resignation"),h||x(mt.resignationId||""))}else if(d==="fnf"){const{API:Ds}=await Qo(async()=>{const{API:Ae}=await Promise.resolve().then(()=>cm);return{API:Ae}},void 0),ss=await Ds.getFnFSettlementById(o);if((nt=ss.data)!=null&&nt.success){mt=ss.data.fnf,v.length===0&&mt.participants&&w(mt.participants||[]);const Ae=((Jt=(Zt=mt.outlet)==null?void 0:Zt.dealer)==null?void 0:Jt.fullName)||((lt=mt.dealer)==null?void 0:lt.fullName)||"F&F Settlement";(!f||f==="Application"||f==="F&F Settlement")&&p(Ae),h||x(mt.settlementId||"")}}}catch(mt){console.error(`Failed to fetch ${d} details:`,mt)}})()},[o,d,v.length,f,h]);const dt=g.useRef(null);g.useEffect(()=>{dt.current&&dt.current.scrollIntoView({behavior:"smooth"})},[j]);const st=oe=>{const we=oe.target.value,Oe=oe.target.selectionStart||0;S(we),O(Oe);const ke=we.substring(0,Oe),je=ke.lastIndexOf("@");if(je!==-1&&je===ke.length-1)_(!0),E("");else if(je!==-1){const Ve=ke.substring(je+1);Ve.includes(" ")?_(!1):(_(!0),E(Ve))}else _(!1)},xt=oe=>{var Ge;const Oe=C.substring(0,q).lastIndexOf("@"),ke=C.substring(q),je=`@${oe.name}`,Ve=C.substring(0,Oe)+je+" "+ke;S(Ve),_(!1),(Ge=ce.current)==null||Ge.focus()},Mt=oe=>{var ke,je;const we=((ke=ce.current)==null?void 0:ke.selectionStart)||C.length,Oe=C.substring(0,we)+oe+C.substring(we);S(Oe),$(!1),(je=ce.current)==null||je.focus()},It=async oe=>{const we=oe.target.files;if(!(!we||we.length===0)){U(!0);try{for(const Oe of Array.from(we)){const ke=await Cm.uploadAttachment(Oe,o,d);ke.success&&Z(je=>[...je,ke.data])}}catch(Oe){console.error("File upload error:",Oe),te.error("Failed to upload attachment")}finally{U(!1),ve.current&&(ve.current.value="")}}},he=oe=>{Z(we=>we.filter(Oe=>Oe.id!==oe))},pt=async()=>{if(!C.trim()&&Y.length===0)return;const oe=C,we=Y;S(""),Z([]);let Oe=oe;const ke=[];ye.forEach(je=>{if(je.id&&je.name){const Ve=je.name.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Ge=new RegExp(`@${Ve}\\b`,"gi");Oe.match(Ge)&&(ke.push(je.id),Oe=Oe.replace(Ge,`@[${je.name}](user:${je.id})`))}});try{const je=`temp-${Date.now()}`,Ve={id:je,noteText:Oe,noteType:"General",createdAt:new Date().toISOString(),userId:s==null?void 0:s.id,author:{name:(s==null?void 0:s.name)||"You",email:(s==null?void 0:s.email)||"",role:(s==null?void 0:s.role)||""},attachments:we};b(nt=>au([...nt,Ve]));const Ge=await Cm.addWorknote({requestId:o,requestType:d,noteText:Oe,noteType:"General",tags:ke,attachmentDocIds:we.map(nt=>nt.id)});if(Ge.success&&Ge.data){const nt=Ge.data,Zt={id:nt.id,noteText:nt.noteText,noteType:nt.noteType,createdAt:nt.createdAt,userId:nt.userId,author:nt.author?Fg(nt):{name:"System",email:"",role:"system"},attachments:nt.attachments||[]};b(Jt=>au(Jt.map(lt=>lt.id===je?Zt:lt)))}}catch(je){console.error("Send message error:",je),te.error("Failed to send message")}},ht=oe=>{if(!["DD Lead","DD Head","NBH","DD Admin","Super Admin"].includes((s==null?void 0:s.roleCode)||"")){te.error("Only authorized roles can revoke participants");return}H(oe),J("")},_e=async()=>{if(K){le(!0);try{const oe=await Cm.revokeParticipant(K.recordId,X);oe.success&&(te.success(oe.message),H(null),w([]))}catch{te.error("Error revoking participant")}finally{le(!1)}}},Vt=oe=>{oe.key==="Enter"&&!oe.shiftKey&&(oe.preventDefault(),pt())},Pt=oe=>{if(!oe)return"";const we=/(@\[[^\]]+\]\([^\)]+\))/g;return oe.split(we).map((ke,je)=>{const Ve=ke.match(/@\[([^\]]+)\]\(([^\)]+)\)/);if(Ve){const Ge=Ve[1];return e.jsxs("span",{className:"text-blue-600 font-medium hover:underline cursor-pointer",children:["@",Ge]},je)}return ke})},_s=B.trim().toLowerCase(),Ys=_s?j.filter(oe=>{var we;return(oe.noteText||"").toLowerCase().includes(_s)||(((we=oe.author)==null?void 0:we.name)||"").toLowerCase().includes(_s)||(oe.noteType||"").toLowerCase().includes(_s)}):j,Bs=ye.filter(oe=>{const we=oe.name.toLowerCase().includes(A.toLowerCase()),Oe=oe.id&&(s==null?void 0:s.id)&&String(oe.id)===String(s.id)||oe.email&&(s==null?void 0:s.email)&&oe.email.toLowerCase()===s.email.toLowerCase();return we&&!Oe});return e.jsxs("div",{className:"h-full flex flex-col bg-slate-50 overflow-hidden",children:[e.jsx("div",{className:"bg-white border-b border-slate-200 px-6 py-4 z-10","data-testid":"onboarding-worknotes-header",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(se,{variant:"ghost",size:"icon",onClick:u,className:"hover:bg-slate-100","data-testid":"onboarding-worknotes-back-btn",children:e.jsx(Jr,{className:"w-5 h-5"})}),e.jsx("div",{className:"w-12 h-12 bg-purple-600 rounded-lg flex items-center justify-center",children:e.jsx(Ga,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900","data-testid":"onboarding-worknotes-title",children:"Work Notes"}),e.jsxs("div",{className:"flex items-center gap-2 text-slate-600","data-testid":"onboarding-worknotes-meta",children:[e.jsx("span",{"data-testid":"onboarding-worknotes-app-name",children:f}),e.jsx("span",{className:"text-slate-400",children:"|"}),e.jsx("span",{className:"text-slate-500","data-testid":"onboarding-worknotes-reg-num",children:h})]})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"hidden sm:flex items-center -space-x-2 mr-2","data-testid":"onboarding-worknotes-participant-avatars",children:[ye.slice(0,3).map((oe,we)=>e.jsx(Nm,{className:"w-8 h-8 border-2 border-white ring-1 ring-slate-100","data-testid":`onboarding-worknotes-avatar-${we}`,children:e.jsx(wm,{className:`${oe.color} text-white text-[10px]`,children:oe.initials})},we)),ye.length>3&&e.jsx("div",{className:"w-8 h-8 rounded-full bg-slate-100 border-2 border-white flex items-center justify-center ring-1 ring-slate-100","data-testid":"onboarding-worknotes-avatar-more",children:e.jsxs("span",{className:"text-slate-600 text-[10px] font-bold",children:["+",ye.length-3]})})]}),e.jsxs(se,{variant:"ghost",size:"sm",onClick:$e,className:"text-slate-500 hover:text-blue-600 flex items-center gap-1.5 px-2 h-9 rounded-lg hover:bg-slate-50 transition-colors",disabled:D,"data-testid":"onboarding-worknotes-sync-btn",children:[e.jsx(hl,{className:`w-4 h-4 ${D?"animate-spin":""}`}),e.jsx("span",{className:"text-xs font-medium hidden md:inline",children:"Sync"})]}),e.jsxs(se,{variant:M?"secondary":"ghost",size:"sm",onClick:()=>z(!M),className:`flex items-center gap-1.5 px-2 h-9 rounded-lg transition-all ${M?"bg-blue-50 text-blue-600 hover:bg-blue-100":"text-slate-500 hover:bg-slate-50"}`,"data-testid":"onboarding-worknotes-toggle-sidebar-btn",children:[e.jsx(Ra,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs font-medium hidden md:inline",children:"Participants"})]})]})]})}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-white min-h-0 relative",children:[e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4 custom-scrollbar bg-slate-50 relative z-0","data-testid":"onboarding-worknotes-chat-area",children:e.jsxs("div",{className:`max-w-4xl mx-auto flex flex-col py-4 gap-4 ${m==="modal"?"":"px-4"}`,children:[e.jsx("div",{className:"sticky top-0 z-[1] -mx-1 px-1 pb-1 bg-slate-50/95 backdrop-blur-sm",children:e.jsxs("div",{className:"relative",children:[e.jsx(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400 pointer-events-none"}),e.jsx(at,{type:"search",value:B,onChange:oe=>G(oe.target.value),placeholder:"Search messages...",className:"pl-9 h-10 bg-white border-slate-200 rounded-xl text-sm shadow-sm","aria-label":"Search messages","data-testid":"onboarding-worknotes-search-input"})]})}),Ys.map((oe,we)=>{var ke,je,Ve,Ge,nt,Zt,Jt;if(aq(oe)){const lt=((ke=oe.author)==null?void 0:ke.name)||"System",mt=(je=oe.author)!=null&&je.role&&oe.author.role!=="0"&&oe.author.role!==""?oe.author.role:"";return e.jsx("div",{className:"flex w-full justify-center px-1 py-1 sm:px-2","data-testid":`onboarding-worknotes-activity-row-${we}`,children:e.jsxs("div",{role:"status",title:iq(oe),className:"flex w-full max-w-[min(100%,42rem)] items-start gap-2.5 rounded-xl border border-slate-200/90 bg-slate-100/80 px-3 py-2.5 shadow-sm",children:[e.jsx(ad,{className:"mt-0.5 h-4 w-4 shrink-0 text-purple-600",strokeWidth:2.5,"aria-hidden":!0}),e.jsx("span",{className:"shrink-0 pt-0.5 text-[10px] font-bold uppercase tracking-wide text-slate-600","data-testid":`onboarding-worknotes-activity-type-${we}`,children:lq(oe)}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:e.jsxs("p",{className:"text-sm leading-snug text-slate-800",children:[e.jsx("span",{className:"font-semibold text-slate-900","data-testid":`onboarding-worknotes-activity-who-${we}`,children:lt}),mt?e.jsxs("span",{className:"text-xs font-normal text-slate-500",children:[" · ",mt]}):null,e.jsx("span",{className:"font-normal text-slate-600",children:" — "}),e.jsx("span",{className:"font-normal text-slate-700","data-testid":`onboarding-worknotes-activity-text-${we}`,children:Pt(oe.noteText)})]})}),e.jsx("time",{className:"shrink-0 whitespace-nowrap pt-0.5 text-right text-[10px] leading-tight text-slate-400 tabular-nums sm:text-[11px]",dateTime:oe.createdAt,"data-testid":`onboarding-worknotes-activity-time-${we}`,children:jS(oe.createdAt)})]})},oe.id)}const Oe=((Ve=oe==null?void 0:oe.author)==null?void 0:Ve.email)&&(s==null?void 0:s.email)&&oe.author.email.toLowerCase()===s.email.toLowerCase()||(oe==null?void 0:oe.userId)&&(s==null?void 0:s.id)&&String(oe.userId)===String(s.id)||oe.id.startsWith("temp-");return e.jsx("div",{className:`flex w-full ${Oe?"justify-end":"justify-start"}`,"data-testid":`onboarding-worknotes-message-row-${we}`,children:e.jsxs("div",{className:`flex gap-3 max-w-[min(85%,36rem)] ${Oe?"flex-row-reverse":""}`,children:[e.jsx(Nm,{className:"w-10 h-10 flex-shrink-0 mt-1","data-testid":`onboarding-worknotes-message-avatar-${we}`,children:e.jsx(wm,{className:`${ge(((Ge=oe==null?void 0:oe.author)==null?void 0:Ge.name)||"System")} text-white`,children:ee(((nt=oe==null?void 0:oe.author)==null?void 0:nt.name)||"S")})}),e.jsxs("div",{className:`flex flex-col min-w-0 ${Oe?"items-end":"items-start"}`,children:[e.jsxs("div",{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 mb-1 px-1 ${Oe?"flex-row-reverse text-right":"text-left"}`,children:[e.jsx("span",{className:"text-slate-900 font-medium text-sm","data-testid":`onboarding-worknotes-message-author-${we}`,children:Oe?"You":((Zt=oe==null?void 0:oe.author)==null?void 0:Zt.name)||"Unknown"}),e.jsx("span",{className:"text-slate-400 text-[10px] uppercase tracking-wide",children:(Jt=oe==null?void 0:oe.author)!=null&&Jt.role&&oe.author.role!=="0"&&oe.author.role!==""?`(${oe.author.role})`:""}),e.jsx("span",{className:"text-slate-400 text-[10px] tabular-nums","data-testid":`onboarding-worknotes-message-time-${we}`,children:jS(oe.createdAt)})]}),e.jsxs("div",{className:`rounded-2xl border px-4 py-2.5 shadow-sm relative text-left ${Oe?"bg-blue-50 border-blue-100 text-slate-800 rounded-tr-none":"bg-white border-slate-200 text-slate-700 rounded-tl-none"}`,"data-testid":`onboarding-worknotes-message-bubble-${we}`,children:[e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap break-words","data-testid":`onboarding-worknotes-message-text-${we}`,children:Pt(oe.noteText)}),oe.attachments&&oe.attachments.length>0&&e.jsx("div",{className:"mt-2 space-y-2 border-t border-slate-100 pt-2","data-testid":`onboarding-worknotes-message-attachments-${we}`,children:oe.attachments.map((lt,mt)=>{const Ds=lt.mimeType.startsWith("image/");return e.jsx("div",{className:"flex items-center gap-2","data-testid":`onboarding-worknotes-message-attachment-${we}-${mt}`,children:Ds?e.jsx("div",{className:"rounded-lg overflow-hidden border border-slate-100 max-w-[200px]",children:e.jsx("img",{src:`${Vc}/${lt.filePath.replace(/\\/g,"/")}`,alt:lt.fileName,className:"w-full h-auto cursor-pointer",onClick:()=>et(lt),"data-testid":`onboarding-worknotes-message-attachment-img-${we}-${mt}`})}):lt.mimeType==="application/pdf"?e.jsxs("button",{type:"button",onClick:()=>et(lt),className:"flex items-center gap-2 text-xs text-blue-600 hover:underline","data-testid":`onboarding-worknotes-message-attachment-preview-${we}-${mt}`,children:[e.jsx(bu,{className:"w-3 h-3"}),lt.fileName," (Preview)"]}):e.jsxs("a",{href:`${Vc}/${lt.filePath.replace(/\\/g,"/")}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-xs text-blue-600 hover:underline","data-testid":`onboarding-worknotes-message-attachment-link-${we}-${mt}`,children:[e.jsx(bu,{className:"w-3 h-3"}),lt.fileName]})},lt.id)})})]})]})]})},oe.id)}),j.length===0&&!D&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center","data-testid":"onboarding-worknotes-empty-state",children:[e.jsx(Ga,{className:"w-16 h-16 text-slate-300 mb-4"}),e.jsx("h3",{className:"text-slate-900 mb-2",children:"No messages yet"}),e.jsx("p",{className:"text-slate-600",children:"Start the conversation by sending a message below"})]}),j.length>0&&Ys.length===0&&!D&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center text-slate-500 text-sm",children:['No messages match "',B.trim(),'". Clear the search box to see the full thread.']}),D&&e.jsx("div",{className:"flex justify-center items-center py-8",children:e.jsx("span",{className:"text-slate-500",children:"Loading notes..."})}),e.jsx("div",{ref:dt})]})}),e.jsx("div",{className:"bg-white border-t border-slate-100 px-6 py-4 shadow-[0_-4px_10px_-5px_rgba(0,0,0,0.05)]","data-testid":"onboarding-worknotes-composer",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-4",children:[Y.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3 mb-3","data-testid":"onboarding-worknotes-attached-files",children:Y.map((oe,we)=>{const Oe=oe.mimeType.startsWith("image/")||oe.mimeType==="application/pdf";return e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-white rounded-xl border border-slate-200 shadow-sm hover:border-blue-300 transition-all group max-w-[200px]","data-testid":`onboarding-worknotes-attached-file-${we}`,children:[e.jsx("div",{className:"w-10 h-10 bg-slate-50 rounded-lg flex items-center justify-center flex-shrink-0 overflow-hidden",children:kt(oe.mimeType,oe.filePath)}),e.jsxs("div",{className:"flex-1 min-w-0 pr-6 relative",children:[e.jsx("p",{className:`text-xs font-medium text-slate-700 truncate ${Oe?"hover:text-blue-600 cursor-pointer hover:underline":""}`,onClick:()=>Oe&&et(oe),children:oe.fileName}),e.jsx("button",{onClick:()=>he(oe.id),className:"absolute -top-1 -right-1 p-1 bg-white rounded-full border border-slate-100 text-slate-400 hover:text-red-500 shadow-sm opacity-0 group-hover:opacity-100 transition-opacity","data-testid":`onboarding-worknotes-remove-attachment-${we}`,children:e.jsx(ld,{className:"w-3 h-3"})})]})]},oe.id)})}),e.jsxs("div",{className:"flex items-end gap-3 bg-white p-2.5 rounded-2xl border border-slate-200 shadow-sm focus-within:border-blue-400 focus-within:ring-1 focus-within:ring-blue-100 transition-all relative",children:[R&&Bs.length>0&&e.jsx("div",{className:"absolute bottom-full left-0 mb-2 w-64 bg-white border border-slate-200 rounded-lg shadow-lg overflow-hidden max-h-48 overflow-y-auto z-50 custom-scrollbar","data-testid":"onboarding-worknotes-mention-suggestions",children:Bs.map((oe,we)=>e.jsxs("button",{onClick:()=>xt(oe),className:"w-full flex items-center gap-3 px-4 py-2 hover:bg-slate-50 transition-colors text-left","data-testid":`onboarding-worknotes-mention-item-${we}`,children:[e.jsx(Nm,{className:"w-8 h-8",children:e.jsx(wm,{className:`${oe.color} text-white text-xs`,children:oe.initials})}),e.jsx("div",{className:"flex flex-col",children:e.jsx("span",{className:"text-slate-900 text-sm font-medium",children:oe.name})})]},oe.id))}),e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx("input",{type:"file",ref:ve,className:"hidden",multiple:!0,onChange:It}),e.jsx(se,{variant:"ghost",size:"icon",className:"w-9 h-9 text-slate-400 hover:text-blue-600 hover:bg-blue-50 rounded-xl",onClick:()=>{var oe;return(oe=ve.current)==null?void 0:oe.click()},"data-testid":"onboarding-worknotes-attachment-btn",children:e.jsx(bu,{className:"w-5 h-5"})}),e.jsxs(se,{variant:"ghost",size:"icon",className:`w-9 h-9 text-slate-400 hover:text-blue-600 hover:bg-blue-50 rounded-xl relative ${L?"bg-blue-50 text-blue-600":""}`,onClick:()=>$(!L),"data-testid":"onboarding-worknotes-emoji-btn",children:[e.jsx(eM,{className:"w-5 h-5"}),L&&e.jsxs("div",{className:"absolute bottom-12 left-0 z-50 bg-white border border-slate-200 rounded-xl shadow-2xl w-72 animate-in fade-in slide-in-from-bottom-2 overflow-hidden","data-testid":"onboarding-worknotes-emoji-picker",children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-100 bg-slate-50 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"Emojis"}),e.jsx("button",{onClick:()=>$(!1),className:"text-slate-400 hover:text-slate-600 text-lg leading-none",children:"×"})]}),e.jsx("div",{className:"p-2 grid grid-cols-8 gap-1 max-h-60 overflow-y-auto custom-scrollbar",children:vt.map((oe,we)=>e.jsx("button",{className:"w-8 h-8 flex items-center justify-center hover:bg-blue-50 hover:scale-110 rounded-lg transition-all text-lg",onClick:Oe=>{Oe.stopPropagation(),Mt(oe)},"data-testid":`onboarding-worknotes-emoji-item-${we}`,children:oe},oe))})]})]}),e.jsx(se,{variant:"ghost",size:"icon",className:"w-9 h-9 text-slate-400 hover:text-blue-600 hover:bg-blue-50 rounded-xl",onClick:()=>{var oe;return(oe=ve.current)==null?void 0:oe.click()},children:e.jsx(k1,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 relative",children:e.jsx(at,{ref:ce,type:"text",placeholder:"Type your message... Use @username to mention someone",value:C,onChange:st,onKeyPress:Vt,className:"w-full pr-4 border-none focus-visible:ring-0 px-0"})}),e.jsx(se,{onClick:pt,disabled:!C.trim()&&Y.length===0||W,className:"bg-blue-600 hover:bg-blue-700 text-white rounded-xl h-10 w-10 p-0",children:W?e.jsx("div",{className:"h-4 w-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):e.jsx(Gu,{className:"w-5 h-5"})})]}),e.jsxs("p",{className:"text-slate-400 text-[10px] px-1 flex items-center gap-1",children:[e.jsx(_a,{className:"w-3 h-3"}),e.jsxs("span",{children:["Press Enter to send • Use @ to mention • ",W?"Uploading files...":"Files attached appear above"]})]})]})})]}),M&&e.jsxs("div",{className:`w-[280px] lg:w-[320px] bg-slate-50 border-l border-slate-200 flex flex-col transition-all animate-in slide-in-from-right-full ${m==="modal"?"hidden lg:flex":"flex"}`,children:[e.jsxs("div",{className:"p-4 border-b border-slate-200 bg-white",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(Ra,{className:"w-4 h-4 text-blue-600"}),"Participants",e.jsx(Ce,{variant:"secondary",className:"bg-slate-100 text-slate-600 ml-1",children:ye.length})]}),e.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-slate-600",onClick:()=>z(!1),children:e.jsx(ld,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(at,{type:"text",placeholder:"Search people...",value:T,onChange:oe=>I(oe.target.value),className:"pl-9 bg-slate-50 border-slate-200 h-9 text-sm rounded-lg focus-visible:bg-white transition-all"})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-1 custom-scrollbar",children:[ye.filter(oe=>{var we;return oe.name.toLowerCase().includes(T.toLowerCase())||((we=oe.role)==null?void 0:we.toLowerCase().includes(T.toLowerCase()))}).map(oe=>{const we=!!oe.revokedAt,Oe=["DD Lead","DD Head","NBH","DD Admin","Super Admin"].includes((s==null?void 0:s.roleCode)||"")&&!we&&oe.id!==(s==null?void 0:s.id);return e.jsxs("div",{className:Nt("group flex items-start gap-3 p-3 rounded-xl transition-all cursor-default border border-transparent",we?"opacity-50 bg-slate-100 grayscale-[0.5]":"hover:bg-white hover:shadow-sm hover:border-slate-100"),children:[e.jsxs("div",{className:"relative",children:[e.jsx(Nm,{className:Nt("w-10 h-10 ring-2 ring-transparent transition-all",!we&&"group-hover:ring-blue-100"),children:e.jsx(wm,{className:`${oe.color} text-white text-xs font-bold`,children:oe.initials})}),oe.isOnline&&!we&&e.jsx("span",{className:"absolute bottom-0 right-0 w-3 h-3 bg-green-500 border-2 border-slate-50 rounded-full shadow-sm"}),we&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-red-100 rounded-full p-0.5 border border-white",children:e.jsx(vg,{className:"w-2.5 h-2.5 text-red-600"})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("p",{className:Nt("text-sm font-semibold truncate",we?"text-slate-500 line-through":"text-slate-900"),children:oe.name}),we&&e.jsx(Ce,{variant:"outline",className:"text-[8px] h-3.5 px-1 bg-red-50 text-red-600 border-red-100",children:"Revoked"})]}),oe.id===(s==null?void 0:s.id)&&e.jsx(Ce,{variant:"outline",className:"text-[9px] h-4 px-1 border-blue-200 text-blue-600 bg-blue-50",children:"You"})]}),e.jsx("p",{className:"text-[11px] text-slate-500 font-medium uppercase tracking-wider mb-1",children:oe.role}),e.jsx("p",{className:"text-[11px] text-slate-400 truncate italic",children:oe.email})]}),Oe&&e.jsx(se,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-slate-300 hover:text-red-600 hover:bg-red-50 opacity-0 group-hover:opacity-100 transition-all self-center",onClick:()=>ht(oe),children:e.jsx(vg,{className:"w-3.5 h-3.5"})}),!Oe&&!we&&e.jsx(bi,{className:"w-4 h-4 text-slate-300 group-hover:text-slate-400 opacity-0 group-hover:opacity-100 transition-all self-center"})]},oe.id)}),ye.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center opacity-50",children:[e.jsx(Ra,{className:"w-8 h-8 text-slate-300 mb-2"}),e.jsx("p",{className:"text-xs text-slate-500",children:"No participants found"})]})]}),e.jsxs("div",{className:"p-4 bg-white border-t border-slate-200",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsx("span",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-widest",children:"Active Session"})]}),e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg bg-slate-50 border border-slate-100",children:[e.jsx(vn,{className:"w-4 h-4 text-slate-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 font-medium uppercase",children:"Last Activity"}),e.jsx("p",{className:"text-xs text-slate-900 font-semibold",children:"Just now"})]})]})]})]})]}),e.jsx(ds,{open:!!Pe,onOpenChange:oe=>!oe&&et(null),children:e.jsxs(os,{className:"max-w-6xl h-[90vh] flex flex-col p-4",children:[e.jsx(xs,{children:e.jsxs(ms,{className:"flex items-center gap-2",children:[Pe&&kt(Pe.mimeType),e.jsx("span",{className:"truncate",children:Pe==null?void 0:Pe.fileName})]})}),e.jsx("div",{className:"flex-1 overflow-hidden rounded-lg bg-slate-100 flex items-center justify-center p-4",children:Pe!=null&&Pe.mimeType.startsWith("image/")?e.jsx("img",{src:`${Vc}/${Pe.filePath.replace(/\\/g,"/")}`,className:"max-w-full max-h-full object-contain",alt:"Preview"}):(Pe==null?void 0:Pe.mimeType)==="application/pdf"?e.jsx("iframe",{src:`${Vc}/${Pe.filePath.replace(/\\/g,"/")}`,className:"w-full h-full border-none",title:"PDF Preview"}):e.jsxs("div",{className:"text-center",children:[e.jsx(af,{className:"w-16 h-16 text-slate-300 mx-auto mb-4"}),e.jsx("p",{className:"text-slate-500",children:"Preview not available for this file type."}),e.jsx("a",{href:`${Vc}/${Pe==null?void 0:Pe.filePath.replace(/\\/g,"/")}`,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline text-sm",children:"Open in new tab"})]})})]})}),e.jsx(ds,{open:!!K,onOpenChange:oe=>!oe&&H(null),children:e.jsxs(os,{className:"max-w-md p-0 overflow-hidden border-none shadow-2xl [&>button]:text-white [&>button]:opacity-100",children:[e.jsxs("div",{className:"bg-gradient-to-br from-red-600 to-red-700 p-6 text-white text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-white/20 rounded-full flex items-center justify-center mx-auto mb-4 border border-white/30 backdrop-blur-sm animate-pulse",children:e.jsx(vg,{className:"w-8 h-8 text-white"})}),e.jsx("h3",{className:"text-xl font-bold mb-2",children:"Revoke Participant Access?"}),e.jsxs("p",{className:"text-red-100 text-sm",children:["You are about to revoke access for ",e.jsx("span",{className:"font-bold text-white",children:K==null?void 0:K.name}),". They will no longer be able to view or interact with this request."]})]}),e.jsxs("div",{className:"p-6 bg-white space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase tracking-widest",children:"Reason for Revocation"}),e.jsx(at,{value:X,onChange:oe=>J(oe.target.value),placeholder:"e.g. Roles changed, Case transferred...",className:"bg-slate-50 border-slate-200 focus:bg-white transition-all h-11"})]}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx(se,{variant:"outline",className:"flex-1 h-11 border-slate-200 text-slate-600 hover:bg-slate-50",onClick:()=>H(null),children:"Cancel"}),e.jsxs(se,{className:"flex-1 h-11 bg-red-600 hover:bg-red-700 text-white font-bold shadow-lg shadow-red-200",onClick:_e,disabled:ae,children:[ae?e.jsx(hl,{className:"w-4 h-4 animate-spin mr-2"}):null,"Revoke Access"]})]})]})]})})]})}const Gb="!w-[80vw] !max-w-[80vw] sm:!max-w-[80vw]",mo=({isOpen:t,onClose:s,document:n})=>{var i;const a=n?`http://localhost:5000${n.filePath.startsWith("/")?"":"/"}${n.filePath}`:"";return e.jsx(ds,{open:t,onOpenChange:s,children:e.jsx(os,{className:`${Gb} h-[85vh] flex flex-col p-0 overflow-hidden bg-white shadow-2xl border-none`,children:n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b bg-slate-50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-red-50 flex items-center justify-center border border-red-200",children:e.jsx(yn,{className:"w-5 h-5 text-re-red"})}),e.jsxs("div",{children:[e.jsx(ms,{className:"text-sm font-bold text-slate-900 leading-none mb-1",children:n.fileName}),e.jsx("p",{className:"text-[10px] text-slate-500 font-medium uppercase tracking-wider",children:n.documentType})]})]}),e.jsx("div",{className:"flex items-center gap-2 pr-10",children:e.jsxs(se,{variant:"outline",size:"sm",className:"h-8 gap-2",onClick:()=>window.open(a,"_blank"),children:[e.jsx(ji,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Download"})]})})]}),e.jsx("div",{className:"flex-1 bg-slate-100 relative overflow-hidden flex items-center justify-center p-4",children:(i=n.fileName)!=null&&i.toLowerCase().endsWith(".pdf")?e.jsx("iframe",{src:`${a}#toolbar=0`,className:"w-full h-full bg-white shadow-inner rounded-sm",title:"Preview"}):e.jsx("img",{src:a,className:"max-h-full max-w-full object-contain shadow-lg rounded-sm",alt:"Preview"})})]}):e.jsx("div",{className:"flex items-center justify-center h-full text-slate-400",children:"Loading document..."})})})};function oq(){var W,U,M,z;const{id:t}=vd(),s=tr(),[n,r]=g.useState(null),[a,i]=g.useState(null),[o,d]=g.useState(!0),[m,f]=g.useState(!1),[p,h]=g.useState(""),[x,u]=g.useState("details"),[N,v]=g.useState(!1),[w,j]=g.useState(null),[b,C]=g.useState(!1),[S,R]=g.useState(!1),[_,A]=g.useState(""),E=In(T=>T.auth.user),q=(E==null?void 0:E.role)==="FDD";g.useEffect(()=>{t&&O()},[t]);const O=async()=>{var T,I,B,G;d(!0);try{const[K,H]=await Promise.all([Ee.getApplicationById(t),Ee.getFddAssignment(t)]);(T=K.data)!=null&&T.success&&r(K.data.data),(I=H.data)!=null&&I.success&&i(H.data.data)}catch(K){console.error("Error fetching application:",K);const H=((G=(B=K.response)==null?void 0:B.data)==null?void 0:G.message)||"Access Denied: Not authorized for FDD access";te.error(H),s("/fdd-dashboard")}finally{d(!1)}},D=async T=>{var G,K,H;const I=(G=T.target.files)==null?void 0:G[0];if(!I||!p){p||te.error("Please select a document type first");return}f(!0);const B=new FormData;B.append("file",I),B.append("documentType",p),B.append("stage","FDD"),B.append("applicationId",t),B.append("requestType","application");try{const X=await Ee.uploadDocument(t,B);if((K=X.data)!=null&&K.success){if(p==="FDD Final Audit Report"){const J=((H=X.data.data)==null?void 0:H.id)||X.data.id;await Ee.submitFddReport({assignmentId:a==null?void 0:a.id,applicationId:t,reportDocumentId:J,findings:"Final Audit Report submitted.",recommendation:"REVIEW_PENDING"})}te.success(`${p} uploaded successfully`),O(),h("")}}catch{te.error("Failed to upload document")}finally{f(!1)}},P=T=>{if(!T||!T.filePath){te.error("Document source file not found");return}j({fileName:T.originalName||T.fileName||"Document",filePath:T.filePath,documentType:T.documentType,createdAt:T.createdAt,mimeType:T.mimeType}),v(!0)};if(o)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-[70vh] bg-slate-50/50 rounded-2xl border border-slate-200 border-dashed",children:[e.jsx(ns,{className:"w-12 h-12 animate-spin text-blue-600 mb-4"}),e.jsx("p",{className:"text-slate-500 font-medium",children:"Authenticating and loading secure data..."})]});if(!n)return null;const L=n.currentStage==="FDD_VERIFICATION"||n.currentStage==="FDD",$=(a==null?void 0:a.status)==="Report Submitted",Y=!L&&(n.overallStatus!=="Active"||n.currentProgress>=75)||$,Z=!L&&n.currentProgress<70&&!$;return e.jsxs("div",{className:"flex flex-col gap-6 max-w-7xl mx-auto mb-10",children:[(n==null?void 0:n.statutoryStatus)==="Flagged"&&e.jsxs("div",{className:"bg-red-50 border border-red-200 p-4 rounded-xl flex items-center gap-4 animate-in fade-in slide-in-from-top-4 duration-500","data-testid":"onboarding-fdd-details-flag-banner",children:[e.jsx("div",{className:"bg-red-100 p-2 rounded-lg",children:e.jsx(Ha,{className:"w-5 h-5 text-red-600"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-red-900 leading-none",children:"APPLICATION FLAGGED BY YOU"}),e.jsx("p",{className:"text-red-700 text-[10px] font-bold uppercase tracking-wider mt-1 opacity-80",children:"Marked as non-responsive for follow-up by DD Team"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("button",{onClick:()=>s("/fdd-dashboard"),className:"flex items-center gap-2 text-slate-600 hover:text-slate-900 font-medium transition-all group","data-testid":"onboarding-fdd-details-back-btn",children:[e.jsx("div",{className:"p-2 rounded-full group-hover:bg-slate-100 transition-colors",children:e.jsx(Jr,{className:"w-5 h-5"})}),"Back to Dashboard"]}),e.jsx("div",{className:"flex items-center gap-3",children:Z?e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-slate-100 border border-slate-200 text-slate-500 font-bold text-[10px] uppercase tracking-[0.1em] rounded-lg","data-testid":"onboarding-fdd-details-awaiting-badge",children:[e.jsx(vn,{className:"w-4 h-4"}),"Awaiting Previous Stages"]}):Y?e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-green-50 border border-green-200 text-green-700 font-bold text-[10px] uppercase tracking-[0.1em] rounded-lg shadow-inner","data-testid":"onboarding-fdd-details-submitted-badge",children:[e.jsx(Zn,{className:"w-4 h-4"}),"Final Audit Report Submitted"]}):e.jsx(e.Fragment,{children:q&&e.jsxs("button",{disabled:m,onClick:()=>R(!0),className:"px-4 py-2 bg-red-50 text-red-600 font-bold text-xs uppercase tracking-wider hover:bg-red-100 rounded-lg transition-all flex items-center gap-2 border border-red-100 shadow-sm","data-testid":"onboarding-fdd-details-flag-btn",children:[e.jsx(Ha,{className:"w-4 h-4"}),"Flag Non-Responsive"]})})})]}),e.jsx(Le,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-header",children:e.jsx(Fe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-14 h-14 bg-slate-900 text-white rounded-lg flex items-center justify-center font-bold text-xl","data-testid":"onboarding-fdd-details-avatar",children:n.applicantName.charAt(0)}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-900 tracking-tight","data-testid":"onboarding-fdd-details-name",children:n.applicantName}),e.jsx(Ce,{variant:"outline",className:"text-slate-500 font-medium px-2 py-0","data-testid":"onboarding-fdd-details-id-badge",children:n.applicationId})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-slate-500","data-testid":"onboarding-fdd-details-meta",children:[e.jsxs("span",{children:[n.city,", ",n.state]}),e.jsx("span",{className:"text-slate-300",children:"•"}),e.jsx("span",{children:n.businessType||"Dealership"})]})]})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"text-right hidden md:block",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Status"}),e.jsx("p",{className:"text-sm font-bold text-slate-700",children:"Financial Due Diligence"})]})})]})})}),e.jsxs("div",{className:"flex items-center gap-8 border-b border-slate-200","data-testid":"onboarding-fdd-details-tabs",children:[e.jsxs("button",{onClick:()=>u("details"),className:`pb-3 text-sm font-semibold transition-all relative ${x==="details"?"text-blue-600":"text-slate-500 hover:text-slate-700"}`,"data-testid":"onboarding-fdd-details-tab-workspace",children:["Workspace",x==="details"&&e.jsx("div",{className:"absolute bottom-[-1px] left-0 right-0 h-0.5 bg-blue-600"})]}),e.jsxs("button",{onClick:()=>u("worknotes"),className:`pb-3 text-sm font-semibold transition-all relative ${x==="worknotes"?"text-blue-600":"text-slate-500 hover:text-slate-700"}`,"data-testid":"onboarding-fdd-details-tab-worknotes",children:[e.jsx("div",{className:"flex items-center gap-2",children:"Work Notes"}),x==="worknotes"&&e.jsx("div",{className:"absolute bottom-[-1px] left-0 right-0 h-0.5 bg-blue-600"})]})]}),x==="details"?e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx("div",{className:"lg:col-span-2 space-y-6",children:e.jsxs(Le,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-workspace-card",children:[e.jsx(Qe,{className:"border-b border-slate-100 px-6 py-4",children:e.jsxs(Je,{className:"text-base font-bold flex items-center gap-2 text-slate-800",children:[e.jsx(or,{className:"w-4 h-4 text-slate-500"}),Y?"Finalized Financial Reports":Z?"Audit Workspace":"Financial Report Submission"]})}),e.jsxs(Fe,{className:"p-6",children:[Z&&e.jsxs("div",{className:"mb-6 p-8 bg-slate-50 border border-dashed border-slate-200 rounded-xl flex flex-col items-center justify-center text-center","data-testid":"onboarding-fdd-details-not-active",children:[e.jsx("div",{className:"w-16 h-16 bg-white rounded-full flex items-center justify-center text-slate-300 mb-4 shadow-sm",children:e.jsx(vn,{className:"w-8 h-8"})}),e.jsx("h4",{className:"text-lg font-bold text-slate-900 mb-2",children:"Stage Not Yet Active"}),e.jsx("p",{className:"text-sm text-slate-500 max-w-sm mb-6",children:"This application is still being processed in previous documentation or interview stages. The FDD workspace will activate once the previous stages are approved."}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold text-slate-400 uppercase tracking-widest px-4 py-1.5 bg-white rounded-full border border-slate-200",children:["Status: ",n.status||"Pending Review"]})]}),Y&&e.jsxs("div",{className:"mb-6 p-4 bg-green-50/50 border border-green-100 rounded-xl flex items-center gap-4","data-testid":"onboarding-fdd-details-completed-alert",children:[e.jsx("div",{className:"w-10 h-10 bg-green-100 rounded-full flex items-center justify-center text-green-600 shrink-0",children:e.jsx(Zn,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-green-800",children:"Verification Stage Completed"}),e.jsx("p",{className:"text-[11px] text-green-600 font-medium",children:"The FDD report has been submitted and the case is now locked for further audits."})]})]}),!Y&&!Z&&e.jsxs("div",{className:"p-10 border-2 border-dashed border-slate-200 rounded-lg flex flex-col items-center justify-center text-center","data-testid":"onboarding-fdd-details-upload-section",children:[e.jsx("div",{className:"w-12 h-12 bg-slate-50 text-slate-400 rounded-full flex items-center justify-center mb-4",children:e.jsx(Ns,{className:"w-6 h-6"})}),e.jsx("p",{className:"text-slate-600 font-medium mb-1","data-testid":"onboarding-fdd-details-upload-title",children:q?"Select and upload the due diligence report":"View Authorized Documents"}),e.jsx("p",{className:"text-slate-400 text-xs mb-6","data-testid":"onboarding-fdd-details-upload-hint",children:q?"PDF or JPG formats accepted (Max 10MB)":"You are in View-Only mode for this Audit"}),q&&e.jsxs("div",{className:"w-full max-w-sm space-y-4",children:[e.jsxs("select",{value:p,onChange:T=>h(T.target.value),className:"w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded text-sm font-medium text-slate-700 outline-none focus:ring-1 focus:ring-blue-500 transition-all","data-testid":"onboarding-fdd-details-doc-type-select",children:[e.jsx("option",{value:"",children:"Select Document Category..."}),e.jsx("option",{value:"FDD Final Audit Report",children:"FDD Final Audit Report"}),e.jsx("option",{value:"Bank Statement",children:"Bank Statement"}),e.jsx("option",{value:"Income Tax Returns (ITR)",children:"Income Tax Returns (ITR)"}),e.jsx("option",{value:"CIBIL Report",children:"CIBIL Report"}),e.jsx("option",{value:"Business Valuation Report",children:"Business Valuation Report"}),e.jsx("option",{value:"Property Documents",children:"Property Documents"})]}),e.jsx("div",{className:"relative",children:m?e.jsxs("div",{className:"w-full py-2.5 bg-slate-100 rounded flex items-center justify-center gap-2","data-testid":"onboarding-fdd-details-uploading-state",children:[e.jsx(ns,{className:"w-4 h-4 animate-spin text-slate-400"}),e.jsx("span",{className:"text-slate-500 text-xs font-bold uppercase tracking-wider",children:"Uploading..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"file",className:"absolute inset-0 opacity-0 cursor-pointer",onChange:D,disabled:!p,"data-testid":"onboarding-fdd-details-file-input"}),e.jsx("div",{className:`w-full py-2.5 text-center font-bold uppercase tracking-wider text-xs rounded transition-all ${p?"bg-slate-900 text-white hover:bg-slate-800":"bg-slate-100 text-slate-300"}`,"data-testid":"onboarding-fdd-details-browse-btn",children:"Browse & Upload"})]})})]})]}),e.jsxs("div",{className:"mt-8 border-t border-slate-100 pt-8","data-testid":"onboarding-fdd-details-documents-section",children:[e.jsx("h3",{className:"text-sm font-bold text-slate-800 mb-4 px-1",children:"Submitted Documentation"}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{"data-testid":"onboarding-fdd-details-applicant-docs",children:[e.jsxs("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider mb-2 flex items-center gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-blue-500"}),"Applicant's KYC & Financials"]}),e.jsxs("div",{className:"space-y-2",children:[(W=n.uploadedDocuments)==null?void 0:W.filter(T=>!T.uploader||T.uploader.roleCode!=="FDD").map((T,I)=>{var B;return e.jsxs("div",{className:"p-3 border border-slate-100 rounded flex items-center justify-between hover:bg-slate-50 transition-all group","data-testid":`onboarding-fdd-details-applicant-doc-row-${I}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-slate-100 flex items-center justify-center text-slate-400 group-hover:bg-white transition-colors",children:e.jsx(Ns,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-xs font-bold text-slate-900","data-testid":`onboarding-fdd-details-applicant-doc-name-${I}`,children:T.originalName||T.fileName}),e.jsx("span",{className:"text-[8px] bg-slate-100 text-slate-500 px-1 py-0.5 rounded uppercase font-bold tracking-tighter",children:"APPLICANT"})]}),e.jsxs("p",{className:"text-[10px] text-slate-400 font-medium","data-testid":`onboarding-fdd-details-applicant-doc-meta-${I}`,children:[T.documentType," • ",Yt(T.createdAt),((B=T.uploader)==null?void 0:B.fullName)&&` • by ${T.uploader.fullName}`]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:()=>P(T),className:"p-1.5 hover:bg-white rounded text-slate-400 hover:text-blue-600 transition-all","data-testid":`onboarding-fdd-details-applicant-doc-preview-${I}`,children:e.jsx(yn,{className:"w-4 h-4"})})})]},I)}),((U=n.uploadedDocuments)==null?void 0:U.filter(T=>!T.uploader||T.uploader.roleCode!=="FDD").length)===0&&e.jsx("p",{className:"text-[10px] text-slate-400 italic px-1","data-testid":"onboarding-fdd-details-applicant-docs-empty",children:"No documents from applicant yet."})]})]}),e.jsxs("div",{"data-testid":"onboarding-fdd-details-my-submissions",children:[e.jsxs("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider mb-2 flex items-center gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"My Uploaded Reports"]}),e.jsxs("div",{className:"space-y-2",children:[(M=n.uploadedDocuments)==null?void 0:M.filter(T=>{var I;return((I=T.uploader)==null?void 0:I.roleCode)==="FDD"}).map((T,I)=>{var B;return e.jsxs("div",{className:"p-3 border border-red-100 bg-red-50/30 rounded flex items-center justify-between hover:bg-red-50 transition-all group","data-testid":`onboarding-fdd-details-my-report-row-${I}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-red-50 flex items-center justify-center text-re-red",children:e.jsx(Ns,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-xs font-bold text-slate-900","data-testid":`onboarding-fdd-details-my-report-name-${I}`,children:T.originalName||T.fileName}),e.jsx("span",{className:"text-[8px] bg-red-500 text-white px-1 py-0.5 rounded uppercase font-bold tracking-tighter",children:"YOUR AUDIT REPORT"})]}),e.jsxs("p",{className:"text-[10px] text-slate-400 font-medium","data-testid":`onboarding-fdd-details-my-report-meta-${I}`,children:[T.documentType," • ",Yt(T.createdAt),((B=T.uploader)==null?void 0:B.fullName)&&` • by ${T.uploader.fullName}`]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:()=>P(T),className:"p-1.5 hover:bg-white rounded text-slate-400 hover:text-re-red transition-all","data-testid":`onboarding-fdd-details-my-report-preview-${I}`,children:e.jsx(yn,{className:"w-4 h-4"})})})]},I)}),((z=n.uploadedDocuments)==null?void 0:z.filter(T=>{var I;return((I=T.uploader)==null?void 0:I.roleCode)==="FDD"}).length)===0&&e.jsx("div",{className:"text-center py-4 bg-slate-50 border border-dashed border-slate-200 rounded-lg","data-testid":"onboarding-fdd-details-my-submissions-empty",children:e.jsx("p",{className:"text-slate-400 text-[10px]",children:"No audit reports uploaded yet."})})]})]})]})]})]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Le,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-profile-card",children:[e.jsx(Qe,{className:"border-b border-slate-100 px-6 pt-4 pb-2.5",children:e.jsx(Je,{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Applicant Profile"})}),e.jsxs(Fe,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"space-y-1 pb-3 border-b border-slate-50","data-testid":"onboarding-fdd-details-target-loc",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Target Location"}),e.jsxs("p",{className:"text-sm font-extrabold text-slate-900",children:[n.city,", ",n.state]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-xs","data-testid":"onboarding-fdd-details-profile-meta",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Education"}),e.jsx("p",{className:"font-bold text-slate-800",children:n.education||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Experience"}),e.jsxs("p",{className:"font-bold text-slate-800",children:[n.experienceYears||"0"," Years"]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Investment Cap"}),e.jsx("p",{className:"font-bold text-slate-800",children:n.investmentCapacity||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Age"}),e.jsx("p",{className:"font-bold text-slate-800",children:n.age||"N/A"})]})]}),e.jsxs("div",{className:"space-y-1 pt-3 border-t border-slate-50 text-xs","data-testid":"onboarding-fdd-details-communication",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Communication"}),e.jsx("p",{className:"font-bold text-slate-800",children:n.email}),e.jsx("p",{className:"text-slate-500 font-medium",children:n.phone})]})]})]}),e.jsxs(Le,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-statutory-card",children:[e.jsx(Qe,{className:"border-b border-slate-100 px-6 pt-4 pb-2.5",children:e.jsx(Je,{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Statutory Details"})}),e.jsx(Fe,{className:"p-5 space-y-3",children:e.jsxs("div",{className:"grid grid-cols-1 gap-2.5 text-xs",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Constitution Type"}),e.jsx("p",{className:"font-bold text-slate-800",children:n.constitutionType||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"PAN Number"}),e.jsx("p",{className:"font-bold text-slate-800 uppercase tracking-tight",children:n.panNumber||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"GST Number"}),e.jsx("p",{className:"font-bold text-slate-800 uppercase tracking-tight",children:n.gstNumber||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Registered Address"}),e.jsx("p",{className:"font-medium text-slate-700 leading-relaxed text-[11px]",children:n.registeredAddress||"N/A"})]})]})})]}),e.jsxs(Le,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-bank-card",children:[e.jsx(Qe,{className:"border-b border-slate-100 px-6 pt-4 pb-2.5",children:e.jsx(Je,{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Bank Details"})}),e.jsx(Fe,{className:"p-5 space-y-3",children:e.jsxs("div",{className:"grid grid-cols-1 gap-2.5 text-xs",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Account Holder"}),e.jsx("p",{className:"font-bold text-slate-800",children:n.accountHolderName||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Bank Name"}),e.jsx("p",{className:"font-bold text-slate-800",children:n.bankName||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Account Number"}),e.jsx("p",{className:"font-bold text-slate-800 tabular-nums",children:n.accountNumber||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"IFSC Code & Branch"}),e.jsxs("p",{className:"font-bold text-slate-800 uppercase tracking-tight",children:[n.ifscCode||"N/A",n.branchName&&e.jsxs("span",{className:"text-slate-400 font-medium ml-2",children:["— ",n.branchName]})]})]})]})})]}),e.jsxs("div",{className:"p-6 bg-slate-900 rounded-lg text-white font-medium","data-testid":"onboarding-fdd-details-instructions",children:[e.jsx("h4",{className:"text-sm font-bold mb-2",children:"Instructions"}),e.jsxs("ul",{className:"text-xs text-slate-300 space-y-2 list-disc pl-4",children:[e.jsx("li",{children:"Bank statements must cover 12 months."}),e.jsx("li",{children:"GST discrepancies must be noted."}),e.jsx("li",{children:"Verify property papers with originals."})]})]})]})]}):e.jsx("div",{className:"bg-white rounded-lg border border-slate-200 min-h-[600px] overflow-hidden",children:e.jsx(IE,{onBack:()=>u("details"),requestId:t,requestType:"application"})}),e.jsx(mo,{isOpen:N,onClose:()=>v(!1),document:w}),e.jsx(ds,{open:b,onOpenChange:C,children:e.jsxs(os,{className:"max-w-md p-0 overflow-hidden border-none shadow-2xl","data-testid":"onboarding-fdd-details-finalize-modal",children:[e.jsxs("div",{className:"bg-slate-950 p-6 flex items-center justify-center relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-re-red/20 to-transparent"}),e.jsx("div",{className:"w-16 h-16 bg-re-red/20 rounded-full flex items-center justify-center animate-pulse relative z-10",children:e.jsx(no,{className:"w-8 h-8 text-re-red"})})]}),e.jsxs("div",{className:"p-8 space-y-4",children:[e.jsxs(xs,{children:[e.jsx(ms,{className:"text-2xl font-bold text-slate-900 text-center","data-testid":"onboarding-fdd-details-finalize-title",children:"Submit Audit Report"}),e.jsxs(bs,{className:"text-slate-500 text-center pt-2 leading-relaxed text-base","data-testid":"onboarding-fdd-details-finalize-desc",children:["You are about to submit your final findings. This action will ",e.jsx("span",{className:"font-bold text-slate-800 underline decoration-re-red decoration-2",children:"notify the Admin"})," for review and approval."]})]}),e.jsxs("div",{className:"bg-red-50 p-4 rounded-xl flex gap-3 border border-red-100 italic","data-testid":"onboarding-fdd-details-finalize-info",children:[e.jsx(_a,{className:"w-5 h-5 text-re-red shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-red-800 leading-normal",children:"Once submitted, you cannot edit the findings. Ensure all documents are uploaded."})]}),e.jsx("div",{className:"space-y-4 pt-2",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{className:"text-[10px] font-black uppercase tracking-widest text-slate-400",children:"Detailed Audit Findings & Remarks"}),e.jsx(Ws,{placeholder:"Enter detailed financial observations...",className:"min-h-[120px] bg-slate-50 border-slate-200 rounded-xl focus:ring-re-red text-sm resize-none",value:_,onChange:T=>A(T.target.value),"data-testid":"onboarding-fdd-details-finalize-remarks"})]})}),e.jsxs(bn,{className:"flex flex-col sm:flex-row gap-3 pt-4 sm:pt-6",children:[e.jsx(se,{variant:"outline",className:"w-full sm:flex-1 h-12 rounded-xl font-bold text-slate-600 hover:bg-slate-50 border-slate-200",onClick:()=>C(!1),disabled:m,"data-testid":"onboarding-fdd-details-finalize-cancel",children:"Cancel"}),e.jsx(se,{className:"w-full sm:flex-1 h-12 rounded-xl font-bold bg-slate-950 hover:bg-slate-900 text-white shadow-lg shadow-slate-200 transition-all active:scale-95 border-b-2 border-re-red","data-testid":"onboarding-fdd-details-finalize-confirm",onClick:async()=>{var T,I;try{if(!_.trim()){te.error("Please provide findings.");return}f(!0);const B=(T=a==null?void 0:a.reports)==null?void 0:T[0];(I=(await Ee.submitFddReport({assignmentId:a==null?void 0:a.id,applicationId:t,reportDocumentId:B==null?void 0:B.reportDocumentId,findings:_,recommendation:null})).data)!=null&&I.success&&(te.success("FDD Report submitted successfully."),C(!1),O())}catch{te.error("Failed to submit report")}finally{f(!1)}},disabled:m,children:m?e.jsx(ns,{className:"w-5 h-5 animate-spin"}):"Confirm & Submit"})]})]})]})}),e.jsx(ds,{open:S,onOpenChange:R,children:e.jsxs(os,{className:"max-w-md p-0 overflow-hidden border-none shadow-2xl","data-testid":"onboarding-fdd-details-flag-modal",children:[e.jsxs("div",{className:"bg-slate-950 p-6 flex items-center justify-center relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-600/20 to-transparent"}),e.jsx("div",{className:"w-16 h-16 bg-red-600/20 rounded-full flex items-center justify-center relative z-10",children:e.jsx(Ha,{className:"w-8 h-8 text-red-500"})})]}),e.jsxs("div",{className:"p-8 space-y-4",children:[e.jsxs(xs,{children:[e.jsx(ms,{className:"text-2xl font-bold text-slate-900 text-center","data-testid":"onboarding-fdd-details-flag-modal-title",children:"Flag Applicant"}),e.jsxs(bs,{className:"text-slate-500 text-center pt-2 leading-relaxed text-base","data-testid":"onboarding-fdd-details-flag-modal-desc",children:["Are you sure you want to flag this applicant as ",e.jsx("span",{className:"font-bold text-red-600",children:"Non-Responsive"}),"?"]})]}),e.jsx("div",{className:"bg-red-50 p-4 rounded-xl flex gap-3 border border-red-100 italic",children:e.jsx("p",{className:"text-xs text-red-800 leading-normal text-center w-full","data-testid":"onboarding-fdd-details-flag-modal-text",children:'"Applicant is non-responsive to FDD queries."'})}),e.jsxs(bn,{className:"flex flex-col sm:flex-row gap-3 pt-4 sm:pt-6",children:[e.jsx(se,{variant:"outline",className:"w-full sm:flex-1 h-12 rounded-xl font-bold text-slate-600 hover:bg-slate-50 border-slate-200",onClick:()=>R(!1),disabled:m,"data-testid":"onboarding-fdd-details-flag-modal-cancel",children:"Go Back"}),e.jsx(se,{className:"w-full sm:flex-1 h-12 rounded-xl font-bold bg-slate-950 hover:bg-slate-900 text-white shadow-lg shadow-slate-200 transition-all active:scale-95 border-b-2 border-red-600","data-testid":"onboarding-fdd-details-flag-modal-confirm",onClick:async()=>{try{f(!0),await Ee.flagNonResponsive({applicationId:t,remarks:"Applicant is non-responsive to FDD queries."}),te.error("Application flagged for non-responsiveness."),R(!1),O()}catch{te.error("Action failed")}finally{f(!1)}},disabled:m,children:m?e.jsx(ns,{className:"w-5 h-5 animate-spin"}):"Flag Applicant"})]})]})]})})]})}const Zl={getOperationsDashboard:async t=>(await Ee.getSlaOperationsDashboard(t)).data,getBatchStatus:async t=>(await Ee.postSlaBatchStatus({items:t})).data,exportOperationsCsv:async t=>{const s="https://dealeronboarding-uat.royalenfield.com/api",n=new URLSearchParams;t!=null&&t.module&&n.set("module",t.module),t!=null&&t.mineOnly&&n.set("mineOnly","true");const r=localStorage.getItem("token"),a=await fetch(`${s}/sla/operations/export?${n.toString()}`,{headers:r?{Authorization:`Bearer ${r}`}:{}});if(!a.ok)throw new Error("Export failed");const i=await a.blob(),o=URL.createObjectURL(i),d=document.createElement("a");d.href=o,d.download=`sla-queue-${Date.now()}.csv`,d.click(),URL.revokeObjectURL(o)},getQuestionnaireReminderSettings:async()=>(await Ee.getQuestionnaireReminderSettings()).data,updateQuestionnaireReminderSettings:async t=>(await Ee.updateQuestionnaireReminderSettings(t)).data},cq={healthy:"bg-emerald-100 text-emerald-800 border-emerald-200",warning:"bg-red-50 text-red-800 border-red-200",critical:"bg-orange-100 text-orange-800 border-orange-200",breached:"bg-red-100 text-red-800 border-red-200"},dq={healthy:"On track",warning:"Due soon",critical:"At risk",breached:"Breached"};function kr({status:t,compact:s}){if(!t)return null;const n=t.isPaused?"warning":t.bucket,r=t.isPaused?"Paused":dq[t.bucket];return e.jsx(Ce,{variant:"outline",className:`text-[10px] font-semibold ${cq[n]} ${s?"px-1.5":""}`,title:`${t.stageName} · ${t.remainingLabel} (${t.percentUsed}% of TAT)`,children:s?r:`${r} · ${t.remainingLabel}`})}function uq(t,s=[]){let n=[];function r(i,o){const d=g.createContext(o);d.displayName=i+"Context";const m=n.length;n=[...n,o];const f=h=>{var j;const{scope:x,children:u,...N}=h,v=((j=x==null?void 0:x[t])==null?void 0:j[m])||d,w=g.useMemo(()=>N,Object.values(N));return e.jsx(v.Provider,{value:w,children:u})};f.displayName=i+"Provider";function p(h,x){var v;const u=((v=x==null?void 0:x[t])==null?void 0:v[m])||d,N=g.useContext(u);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[f,p]}const a=()=>{const i=n.map(o=>g.createContext(o));return function(d){const m=(d==null?void 0:d[t])||i;return g.useMemo(()=>({[`__scope${t}`]:{...d,[t]:m}}),[d,m])}};return a.scopeName=t,[r,hq(a,...s)]}function hq(...t){const s=t[0];if(t.length===1)return s;const n=()=>{const r=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((d,{useScope:m,scopeName:f})=>{const h=m(i)[`__scope${f}`];return{...d,...h}},{});return g.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return n.scopeName=s.scopeName,n}var mq=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ME=mq.reduce((t,s)=>{const n=Hu(`Primitive.${s}`),r=g.forwardRef((a,i)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),Kb="Progress",Yb=100,[fq]=uq(Kb),[pq,xq]=fq(Kb),FE=g.forwardRef((t,s)=>{const{__scopeProgress:n,value:r=null,max:a,getValueLabel:i=gq,...o}=t;(a||a===0)&&!NS(a)&&console.error(vq(`${a}`,"Progress"));const d=NS(a)?a:Yb;r!==null&&!wS(r,d)&&console.error(yq(`${r}`,"Progress"));const m=wS(r,d)?r:null,f=vf(m)?i(m,d):void 0;return e.jsx(pq,{scope:n,value:m,max:d,children:e.jsx(ME.div,{"aria-valuemax":d,"aria-valuemin":0,"aria-valuenow":vf(m)?m:void 0,"aria-valuetext":f,role:"progressbar","data-state":qE(m,d),"data-value":m??void 0,"data-max":d,...o,ref:s})})});FE.displayName=Kb;var BE="ProgressIndicator",$E=g.forwardRef((t,s)=>{const{__scopeProgress:n,...r}=t,a=xq(BE,n);return e.jsx(ME.div,{"data-state":qE(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...r,ref:s})});$E.displayName=BE;function gq(t,s){return`${Math.round(t/s*100)}%`}function qE(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function vf(t){return typeof t=="number"}function NS(t){return vf(t)&&!isNaN(t)&&t>0}function wS(t,s){return vf(t)&&!isNaN(t)&&t<=s&&t>=0}function vq(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${Yb}\`.`}function yq(t,s){return`Invalid prop \`value\` of value \`${t}\` supplied to \`${s}\`. The \`value\` prop must be:
- a positive number
- less than the value passed to \`max\` (or ${Yb} if no \`max\` prop is set)
- \`null\` or \`undefined\` if the progress is indeterminate.
Defaulting to \`null\`.`}var bq=FE,jq=$E;function dc({className:t,indicatorClassName:s,value:n,...r}){return e.jsx(bq,{"data-slot":"progress",className:Nt("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",t),...r,children:e.jsx(jq,{"data-slot":"progress-indicator",className:Nt("bg-primary h-full w-full flex-1 transition-all",s),style:{transform:`translateX(-${100-(n||0)}%)`}})})}const Nq=["Rejected","Revoked","Withdrawn"];function kd(t,s){const n=String(t||""),r=String(s||"");return Nq.some(a=>n.includes(a)||r===a)}function Zb(t,s){const n=String(t||""),r=String(s||"");return n==="Completed"||r==="Completed"||n==="Settled"||n==="Onboarded"||n==="Verified"||n==="Closed"}function wq(t,s){return Zb(t,s)?"success":kd(t,s)?"negative":"inProgress"}const pr={inProgress:{bar:"bg-status-progress",barBadge:"bg-status-progress hover:bg-status-progress-hover text-white border-transparent",badge:"bg-status-progress-soft text-status-progress-strong border-status-progress",badgeSolid:"bg-status-progress hover:bg-status-progress-hover text-white border-transparent",text:"text-status-progress-muted",textStrong:"text-status-progress-strong",icon:"text-status-progress",workflowIcon:"bg-status-workflow-icon",workflowPanel:"bg-status-workflow-panel -ml-4 pl-4 pr-4 py-3 rounded-lg border border-status-workflow-panel",workflowTitle:"text-status-progress-strong",workflowSubtitle:"text-status-progress-muted",workflowStageBadge:"bg-status-workflow-badge border",panel:"bg-status-workflow-panel -ml-4 pl-4 pr-4 py-3 rounded-lg border border-status-workflow-panel",title:"text-status-progress-strong",subtitle:"text-status-progress-muted",stageBadge:"bg-status-workflow-badge border",progress:"bg-status-progress",workflowActive:"bg-status-workflow-active"},success:{bar:"bg-green-600",barBadge:"bg-green-600 hover:bg-green-700 text-white border-transparent",badge:"bg-green-100 text-green-800 border-green-200",badgeSolid:"bg-green-600 hover:bg-green-700 text-white border-transparent",text:"text-green-700",textStrong:"text-green-900",icon:"text-green-600",workflowIcon:"bg-green-100 text-green-600",workflowPanel:"bg-green-50 border border-green-200",workflowTitle:"text-green-900",workflowSubtitle:"text-green-700",workflowStageBadge:"bg-green-100 text-green-700 border-green-300",panel:"bg-green-50 border border-green-200",title:"text-green-900",subtitle:"text-green-700",stageBadge:"bg-green-100 text-green-700 border-green-300",progress:"bg-green-600",workflowActive:"bg-green-600 border-green-600"},negative:{bar:"bg-re-red",barBadge:"bg-re-red hover:bg-re-red-hover text-white border-transparent",badge:"bg-red-50 text-re-red border-red-200",badgeSolid:"bg-re-red hover:bg-re-red-hover text-white border-transparent",text:"text-re-red-hover",textStrong:"text-red-900",icon:"text-re-red",workflowIcon:"bg-red-100 text-re-red",workflowPanel:"bg-red-50 border border-red-200",workflowTitle:"text-red-900",workflowSubtitle:"text-re-red-hover",workflowStageBadge:"bg-red-50 text-re-red border-red-200",panel:"bg-red-50 border border-red-200",title:"text-red-900",subtitle:"text-re-red-hover",stageBadge:"bg-red-50 text-re-red border-red-200",progress:"bg-re-red",workflowActive:"bg-re-red border-re-red"},neutral:{bar:"bg-slate-300",barBadge:"bg-slate-500 text-white border-transparent",badge:"bg-slate-100 text-slate-700 border-slate-200",badgeSolid:"bg-slate-600 hover:bg-slate-700 text-white border-transparent",text:"text-slate-600",textStrong:"text-slate-900",icon:"text-slate-500",workflowIcon:"bg-slate-100 text-slate-400",workflowPanel:"",workflowTitle:"text-slate-900",workflowSubtitle:"text-slate-600",workflowStageBadge:"bg-slate-100 text-slate-500 border-slate-300",panel:"",title:"text-slate-900",subtitle:"text-slate-600",stageBadge:"bg-slate-100 text-slate-500 border-slate-300",progress:"bg-slate-300",workflowActive:"bg-slate-400 border-slate-400"}};function zE(t,s){return pr[wq(t,s)]}function gl(t,s){return zE(t,s).bar}function Sq(t,s){return zE(t,s).barBadge}function Cq(t){return t>=100?pr.success.bar:pr.inProgress.bar}function Aq(t){return t>=100?pr.success.barBadge:pr.inProgress.barBadge}function UE(t){const s=String(t||""),n=s.toUpperCase();return s.includes("Rejected")||n.includes("DOCUMENT_REJECTED")?pr.negative.badge:s==="Verified"||s==="Completed"||n.includes("DOCUMENT_VERIFIED")?pr.success.badge:s.includes("Pending")||s.includes("Review")||s==="In Progress"?pr.inProgress.badge:pr.neutral.badge}function Qb(t,s){return Zb(t,s)?pr.success.badge:(kd(t,s),pr.negative.badge)}function Xb(t,s){return Zb(t,s)?pr.success.badgeSolid:(kd(t,s),pr.negative.badgeSolid)}function eo(t,s){const n=String(t||""),r=String(s||"");return kd(r,n)||/rejected|revoked/i.test(n)?pr.negative.badge:n==="Completed"||r==="Completed"||n==="Closed"?pr.success.badge:pr.negative.badge}function hp({value:t,status:s,currentStage:n,barClassName:r="h-2 w-20 bg-status-progress-soft",showPercent:a=!1,percentClassName:i="text-slate-600 shrink-0","data-testid":o}){return e.jsxs("div",{className:Nt("flex items-center gap-2 min-w-0",a&&"w-full max-w-[8rem]"),"data-testid":o?`${o}-container`:void 0,children:[e.jsx(dc,{value:t,className:r,indicatorClassName:gl(s,n),"data-testid":o}),a&&e.jsxs("span",{className:i,"data-testid":o?`${o}-text`:void 0,children:[t,"%"]})]})}function fo({className:t,...s}){return e.jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:Nt("mx-auto flex w-full justify-center",t),...s})}function po({className:t,...s}){return e.jsx("ul",{"data-slot":"pagination-content",className:Nt("flex flex-row items-center gap-1",t),...s})}function Sn({...t}){return e.jsx("li",{"data-slot":"pagination-item",...t})}function Vi({className:t,isActive:s,size:n="icon",...r}){return e.jsx("a",{"aria-current":s?"page":void 0,"data-slot":"pagination-link","data-active":s,className:Nt(rd({variant:s?"outline":"ghost",size:n}),t),...r})}function xo({className:t,...s}){return e.jsxs(Vi,{"aria-label":"Go to previous page",size:"default",className:Nt("gap-1 px-2.5 sm:pl-2.5",t),...s,children:[e.jsx(lo,{}),e.jsx("span",{className:"hidden sm:block",children:"Previous"})]})}function go({className:t,...s}){return e.jsxs(Vi,{"aria-label":"Go to next page",size:"default",className:Nt("gap-1 px-2.5 sm:pr-2.5",t),...s,children:[e.jsx("span",{className:"hidden sm:block",children:"Next"}),e.jsx(bi,{})]})}function vo({className:t,...s}){return e.jsxs("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:Nt("flex size-9 items-center justify-center",t),...s,children:[e.jsx(GI,{className:"size-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]})}function kq({onViewDetails:t,initialFilter:s}){const{user:n}=In(z=>z.auth),[r,a]=g.useState(""),[i,o]=g.useState("all"),[d,m]=g.useState(s||"all"),[f,p]=g.useState([]),[h,x]=g.useState(!1),[u]=g.useState("date"),[N,v]=g.useState(!1),[w,j]=g.useState(!1),[b,C]=g.useState([]),[S,R]=g.useState({}),[_,A]=g.useState([]),[E,q]=g.useState(1),[O,D]=g.useState(null),P=10;g.useEffect(()=>{L()},[E,i,d,r]);const L=async()=>{try{const z=await hs.getApplications({page:E,limit:P,status:d!=="all"?d:void 0,location:i!=="all"?i:void 0,search:r||void 0,ddLeadShortlisted:"true",isShortlisted:"true",assignedTo:w?n==null?void 0:n.id:void 0}),T=z.data||[];D(z.meta);const I=T.map(B=>({id:B.id,registrationNumber:B.applicationId||"N/A",name:B.applicantName,email:B.email,phone:B.phone,age:B.age,education:B.education,residentialAddress:B.address||B.city||"",businessAddress:B.address||"",preferredLocation:B.preferredLocation,state:B.state,ownsBike:B.ownRoyalEnfield==="yes",pastExperience:B.experienceYears?`${B.experienceYears} years`:B.description||"",status:B.overallStatus,questionnaireMarks:0,rank:0,totalApplicantsAtLocation:0,submissionDate:B.createdAt,assignedUsers:[],assignedTo:B.assignedTo,progress:B.progressPercentage||0,isShortlisted:B.ddLeadShortlisted||B.isShortlisted||!1,companyName:B.companyName,source:B.source,existingDealer:B.existingDealer,royalEnfieldModel:B.royalEnfieldModel,description:B.description,pincode:B.pincode,locationType:B.locationType,ownRoyalEnfield:B.ownRoyalEnfield,address:B.address}));if(C(I),I.length>0?Zl.getBatchStatus(I.map(B=>({entityType:"application",entityId:B.id}))).then(B=>{if(B!=null&&B.success){const G={};I.forEach(K=>{G[K.id]=B.data[`application:${K.id}`]??null}),R(G)}}).catch(()=>R({})):R({}),_.length===0){const B=Array.from(new Set(I.map(G=>G.preferredLocation))).filter(Boolean);A(B)}}catch(z){console.error("Failed to fetch applications",z)}finally{}},$=b.sort((z,T)=>u==="date"?new Date(T.submissionDate).getTime()-new Date(z.submissionDate).getTime():0),Y=z=>{p(T=>T.includes(z)?T.filter(I=>I!==z):[...T,z])},Z=()=>{f.length===$.length?p([]):p($.map(z=>z.id))},W=async()=>{if(f.length!==0)try{x(!0);const z=await hs.sendBulkReminders(f);z.success&&(te.success(z.message||`Reminder emails sent to ${f.length} applicant(s)`),p([]))}catch(z){console.error("Failed to send reminders:",z),te.error(z.message||"Failed to send reminders")}finally{x(!1)}},U=()=>{alert("Exporting applications to CSV...")},M=z=>({Submitted:"bg-slate-500","Questionnaire Pending":"bg-orange-500","Questionnaire Completed":"bg-blue-500",Shortlisted:"bg-cyan-500","Level 1 Pending":"bg-red-500","Level 1 Approved":"bg-green-500","Level 2 Pending":"bg-purple-500","Level 2 Approved":"bg-green-600","Level 2 Recommended":"bg-teal-500","Level 3 Pending":"bg-indigo-500","FDD Verification":"bg-violet-500","Payment Pending":"bg-yellow-500","LOI Issued":"bg-lime-500","Dealer Code Generation":"bg-fuchsia-500","Architecture Team Assigned":"bg-blue-500","Architecture Document Upload":"bg-blue-500","Architecture Team Completion":"bg-blue-500","Statutory GST":"bg-emerald-500","Statutory PAN":"bg-emerald-500","Statutory Nodal":"bg-emerald-500","Statutory Check":"bg-emerald-500","Statutory Partnership":"bg-emerald-500","Statutory Firm Reg":"bg-emerald-500","Statutory Virtual Code":"bg-emerald-500","Statutory Domain":"bg-emerald-500","Statutory MSD":"bg-emerald-500","Statutory LOI Ack":"bg-emerald-500","EOR In Progress":"bg-sky-500","LOA Pending":"bg-emerald-500",Approved:"bg-green-700",Rejected:"bg-red-500",Disqualified:"bg-red-700"})[z]||"bg-slate-500";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-4",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(at,{type:"text",placeholder:"Search by name, ID, or email...",value:r,onChange:z=>a(z.target.value),className:"pl-10","data-testid":"onboarding-applications-search-input"})]}),e.jsxs(Dt,{value:i,onValueChange:o,children:[e.jsx(Et,{className:"w-full lg:w-48","data-testid":"onboarding-applications-location-filter",children:e.jsx(Rt,{placeholder:"All Locations"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"all",children:"All Locations"}),_.map(z=>e.jsx(Me,{value:z,children:z},z))]})]}),e.jsxs(Dt,{value:d,onValueChange:m,children:[e.jsx(Et,{className:"w-full lg:w-48","data-testid":"onboarding-applications-status-filter",children:e.jsx(Rt,{placeholder:"All Statuses"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"all",children:"All Statuses"}),e.jsx(Me,{value:"Questionnaire Pending",children:"Questionnaire Pending"}),e.jsx(Me,{value:"Shortlisted",children:"Shortlisted"}),e.jsx(Me,{value:"Level 1 Pending",children:"Level 1 Pending"}),e.jsx(Me,{value:"Level 2 Pending",children:"Level 2 Pending"}),e.jsx(Me,{value:"Level 3 Pending",children:"Level 3 Pending"}),e.jsx(Me,{value:"EOR In Progress",children:"EOR In Progress"}),e.jsx(Me,{value:"Approved",children:"Approved"}),e.jsx(Me,{value:"Rejected",children:"Rejected"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ln,{id:"my-assignments",checked:w,onCheckedChange:z=>j(z),"data-testid":"onboarding-applications-assignments-checkbox"}),e.jsx(de,{htmlFor:"my-assignments","data-testid":"onboarding-applications-assignments-label",children:"My Assignments Only"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mt-4",children:[e.jsxs(se,{variant:"outline",size:"sm",onClick:U,"data-testid":"onboarding-applications-export-button",children:[e.jsx(ji,{className:"w-4 h-4 mr-2"}),"Export"]}),f.length>0&&e.jsxs(se,{variant:"outline",size:"sm",onClick:W,disabled:h,"data-testid":"onboarding-applications-reminders-button",children:[h?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Ur,{className:"w-4 h-4 mr-2"}),"Send Reminders (",f.length,")"]}),e.jsxs("div",{className:"ml-auto text-slate-600","data-testid":"onboarding-applications-count-text",children:[O?O.total:$.length," application",(O==null?void 0:O.total)!==1?"s":""]})]})]}),e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200",children:[e.jsxs(Ts,{"data-testid":"onboarding-applications-table",children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{className:"w-12",children:e.jsx(Ln,{checked:f.length===$.length&&$.length>0,onCheckedChange:Z,"data-testid":"onboarding-applications-header-checkbox"})}),e.jsx(fe,{children:"ID"}),e.jsx(fe,{children:"Name"}),e.jsx(fe,{children:"Preferred Location"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"SLA"}),e.jsx(fe,{children:"Applicant Location"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Applied On"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Os,{children:$.map((z,T)=>e.jsxs(it,{"data-testid":`onboarding-application-row-${T}`,children:[e.jsx(ue,{children:e.jsx(Ln,{checked:f.includes(z.id),onCheckedChange:()=>Y(z.id),"data-testid":`onboarding-application-checkbox-${T}`})}),e.jsx(ue,{"data-testid":`onboarding-application-id-${T}`,children:z.registrationNumber}),e.jsx(ue,{"data-testid":`onboarding-application-name-${T}`,children:z.name}),e.jsx(ue,{"data-testid":`onboarding-application-pref-location-${T}`,children:z.preferredLocation}),e.jsx(ue,{children:e.jsx(Ce,{className:M(z.status),"data-testid":`onboarding-application-status-${T}`,children:z.status})}),e.jsx(ue,{children:e.jsx(kr,{status:S[z.id],compact:!0})}),e.jsx(ue,{className:"text-slate-600 max-w-xs truncate","data-testid":`onboarding-application-addr-${T}`,children:z.residentialAddress}),e.jsx(ue,{children:e.jsx(hp,{value:z.progress,status:z.status,showPercent:!0,"data-testid":`onboarding-application-progress-bar-${T}`})}),e.jsx(ue,{"data-testid":`onboarding-application-date-${T}`,children:Yt(z.submissionDate)}),e.jsx(ue,{children:e.jsx(se,{size:"sm",variant:"outline",onClick:()=>t(z.id),"data-testid":`onboarding-application-view-btn-${T}`,children:"View"})})]},z.id))})]}),O&&O.totalPages>1&&e.jsx("div",{className:"py-4 border-t px-4 flex justify-center",children:e.jsx(fo,{children:e.jsxs(po,{children:[e.jsx(Sn,{children:e.jsx(xo,{onClick:()=>q(z=>Math.max(1,z-1)),className:E===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(O.totalPages)].map((z,T)=>{const I=T+1;return I===1||I===O.totalPages||I>=E-1&&I<=E+1?e.jsx(Sn,{children:e.jsx(Vi,{isActive:E===I,onClick:()=>q(I),className:"cursor-pointer",children:I})},I):I===2&&E>3||I===O.totalPages-1&&E<O.totalPages-2?e.jsx(Sn,{children:e.jsx(vo,{})},I):null}),e.jsx(Sn,{children:e.jsx(go,{onClick:()=>q(z=>Math.min(O.totalPages,z+1)),className:E===O.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]}),e.jsx(ds,{open:N,onOpenChange:v,children:e.jsxs(os,{className:"max-w-2xl","data-testid":"onboarding-new-app-modal",children:[e.jsx(xs,{children:e.jsx(ms,{children:"Add New Application (Admin)"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-slate-600",children:"This form allows administrators to manually add applications to the system."}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(de,{children:"Name"}),e.jsx(at,{placeholder:"Full Name","data-testid":"onboarding-new-app-name"})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Email"}),e.jsx(at,{type:"email",placeholder:"email@example.com","data-testid":"onboarding-new-app-email"})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Phone"}),e.jsx(at,{placeholder:"+91 XXXXX XXXXX","data-testid":"onboarding-new-app-phone"})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Preferred Location"}),e.jsxs(Dt,{children:[e.jsx(Et,{"data-testid":"onboarding-new-app-location-select",children:e.jsx(Rt,{placeholder:"Select location"})}),e.jsx(_t,{children:_.map(z=>e.jsx(Me,{value:z,children:z},z))})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(se,{variant:"outline",onClick:()=>v(!1),"data-testid":"onboarding-new-app-cancel",children:"Cancel"}),e.jsx(se,{className:"bg-re-red hover:bg-re-red-hover","data-testid":"onboarding-new-app-submit",children:"Create Application"})]})]})]})})]})}function VE({application:t,onViewDetails:s}){var r;const n=a=>({Submitted:"bg-slate-500","Questionnaire Pending":"bg-orange-500","Questionnaire Completed":"bg-blue-500",Shortlisted:"bg-cyan-500","Level 1 Pending":"bg-red-500","Level 1 Approved":"bg-green-500","Level 2 Pending":"bg-purple-500","Level 2 Approved":"bg-green-600","Level 2 Recommended":"bg-teal-500","Level 3 Pending":"bg-indigo-500","FDD Verification":"bg-violet-500","Payment Pending":"bg-yellow-500","LOI Issued":"bg-lime-500","Dealer Code Generation":"bg-fuchsia-500","Architecture Team Assigned":"bg-blue-500","Architecture Document Upload":"bg-blue-500","Architecture Team Completion":"bg-blue-500","Statutory GST":"bg-emerald-500","Statutory PAN":"bg-emerald-500","Statutory Nodal":"bg-emerald-500","Statutory Check":"bg-emerald-500","Statutory Partnership":"bg-emerald-500","Statutory Firm Reg":"bg-emerald-500","Statutory Virtual Code":"bg-emerald-500","Statutory Domain":"bg-emerald-500","Statutory MSD":"bg-emerald-500","Statutory LOI Ack":"bg-emerald-500","EOR In Progress":"bg-sky-500","LOA Pending":"bg-emerald-500",Approved:"bg-green-700",Rejected:"bg-red-500",Disqualified:"bg-red-700"})[a]||"bg-slate-500";return e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-6 hover:shadow-lg transition-shadow","data-testid":`onboarding-application-card-${t.id}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"text-slate-900","data-testid":"onboarding-application-card-name",children:t.name}),(r=t.tags)==null?void 0:r.map(a=>e.jsx(Ce,{variant:"outline",className:a==="Approved"?"border-green-500 text-green-700":"border-teal-500 text-teal-700","data-testid":`onboarding-application-card-tag-${a}`,children:a},a))]}),e.jsx("p",{className:"text-slate-600","data-testid":"onboarding-application-card-registration",children:t.registrationNumber})]}),e.jsx(Ce,{className:n(t.status),"data-testid":"onboarding-application-card-status",children:t.status})]}),e.jsxs("div",{className:"space-y-3 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-slate-600",children:[e.jsx(Vr,{className:"w-4 h-4"}),e.jsx("span",{"data-testid":"onboarding-application-card-location",children:t.preferredLocation}),t.rank&&t.totalApplicantsAtLocation&&e.jsxs(Ce,{variant:"outline","data-testid":"onboarding-application-card-rank",children:["Rank ",t.rank,"/",t.totalApplicantsAtLocation]})]}),e.jsxs("div",{className:"flex items-start gap-2 text-slate-600",children:[e.jsx(id,{className:"w-4 h-4 mt-0.5"}),e.jsx("span",{className:"text-sm","data-testid":"onboarding-application-card-address",children:t.businessAddress})]}),e.jsxs("div",{className:"flex items-center gap-2 text-slate-600",children:[e.jsx(Ur,{className:"w-4 h-4"}),e.jsx("span",{"data-testid":"onboarding-application-card-email",children:t.email})]}),e.jsxs("div",{className:"flex items-center gap-2 text-slate-600",children:[e.jsx(tb,{className:"w-4 h-4"}),e.jsx("span",{"data-testid":"onboarding-application-card-phone",children:t.phone})]}),t.questionnaireMarks!==void 0&&e.jsxs("div",{className:"flex items-center gap-2 text-slate-600",children:[e.jsx(rk,{className:"w-4 h-4"}),e.jsxs("span",{"data-testid":"onboarding-application-card-score",children:["Score: ",t.questionnaireMarks,"/100"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-slate-600",children:[e.jsx(dr,{className:"w-4 h-4"}),e.jsxs("span",{"data-testid":"onboarding-application-card-submission-date",children:["Submitted: ",Yt(t.submissionDate)]})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-slate-600",children:"Progress"}),e.jsxs("span",{className:"text-slate-900","data-testid":"onboarding-application-card-progress-text",children:[t.progress,"%"]})]}),e.jsx(hp,{value:t.progress,status:t.status,barClassName:"h-2 w-full bg-status-progress-soft","data-testid":"onboarding-application-card-progress-bar"})]}),t.deadline&&t.status==="Questionnaire Pending"&&e.jsx("div",{className:"mb-4 p-3 bg-orange-50 border border-orange-200 rounded-md","data-testid":"onboarding-application-card-deadline-warning",children:e.jsxs("p",{className:"text-orange-800",children:["Deadline: ",Yt(t.deadline)]})}),e.jsx(se,{onClick:()=>s(t.id),className:"w-full bg-re-red hover:bg-re-red-hover","data-testid":"onboarding-application-card-view-button",children:"View Details"})]})}function Dq({onViewDetails:t,initialFilter:s="all"}){const[n,r]=g.useState("grid"),[a,i]=g.useState(""),[o,d]=g.useState(s),[m,f]=g.useState("all"),[p,h]=g.useState("all"),[x,u]=g.useState([]),[N,v]=g.useState(!1),[w,j]=g.useState(""),[b,C]=g.useState([]),[S,R]=g.useState(!0),[_,A]=g.useState([]),[E,q]=g.useState([]),[O,D]=g.useState(1),[P,L]=g.useState(null);g.useEffect(()=>{Y()},[O,a,o,m,p]),g.useEffect(()=>{D(1)},[a,o,m,p]),g.useEffect(()=>{$()},[]);const $=async()=>{try{const B=await Is.getStates(),K=(Array.isArray(B)?B:(B==null?void 0:B.data)||(B==null?void 0:B.states)||[]).map(H=>typeof H=="string"?H:H.name||H.stateName).filter(Boolean);A(K)}catch(B){console.error("Failed to fetch states:",B)}},Y=async()=>{try{R(!0);const B=await hs.getApplications({page:O,limit:10,search:a,status:o==="all"?void 0:o,location:m!=="all"?m:void 0,state:p!=="all"?p:void 0,isShortlisted:void 0}),G=B.data||[];L(B.meta);const K=G.map(X=>({id:X.id,registrationNumber:X.applicationId||"N/A",name:X.applicantName,email:X.email,phone:X.phone,age:X.age,education:X.education,residentialAddress:X.address||X.city||"",businessAddress:X.address||"",preferredLocation:X.preferredLocation,state:X.state,ownsBike:X.ownRoyalEnfield==="yes",pastExperience:X.experienceYears?`${X.experienceYears} years`:X.description||"",status:X.overallStatus,questionnaireMarks:X.score||X.questionnaireMarks||0,rank:0,totalApplicantsAtLocation:0,submissionDate:X.createdAt,assignedUsers:[],progress:X.progressPercentage||0,isShortlisted:X.isShortlisted||X.ddLeadShortlisted,companyName:X.companyName,source:X.source,existingDealer:X.existingDealer,royalEnfieldModel:X.royalEnfieldModel,description:X.description,pincode:X.pincode,locationType:X.locationType,ownRoyalEnfield:X.ownRoyalEnfield,address:X.address}));C(K);const H=Array.from(new Set(K.map(X=>X.preferredLocation))).filter(Boolean);q(H)}catch(B){console.error("Failed to fetch applications:",B),te.error("Failed to load applications")}finally{R(!1)}},Z=b,W=B=>{u(B?Z.map(G=>G.id):[])},U=(B,G)=>{u(G?[...x,B]:x.filter(K=>K!==B))},M=()=>{if(x.length===0){te.error("Please select at least one application to shortlist");return}v(!0)},z=async()=>{try{te.success(`${x.length} application(s) shortlisted successfully!`),v(!1),Y()}catch{te.error("Failed to shortlist")}},T=["Submitted","Questionnaire Pending","Questionnaire Completed"],I=B=>({Submitted:"bg-blue-100 text-blue-800","Questionnaire Pending":"bg-yellow-100 text-yellow-800","Questionnaire Completed":"bg-cyan-100 text-cyan-800",Shortlisted:"bg-purple-100 text-purple-800","Level 1 Interview Pending":"bg-orange-100 text-orange-800","Level 1 Approved":"bg-green-100 text-green-800","Level 2 Interview Pending":"bg-orange-100 text-orange-800","Level 2 Approved":"bg-green-100 text-green-800","Level 2 Recommended":"bg-teal-100 text-teal-800","Level 3 Interview Pending":"bg-orange-100 text-orange-800","In Review":"bg-slate-100 text-slate-800","Level 3 Approved":"bg-green-100 text-green-800","FDD Verification":"bg-indigo-100 text-indigo-800","Payment Pending":"bg-red-50 text-red-800","LOI In Progress":"bg-sky-100 text-sky-800","LOI Issued":"bg-sky-100 text-sky-800","Dealer Code Generation":"bg-purple-100 text-purple-800","Architecture Team Assigned":"bg-blue-100 text-blue-800","Architecture Document Upload":"bg-blue-100 text-blue-800","Architecture Team Completion":"bg-blue-100 text-blue-800","Statutory GST":"bg-emerald-100 text-emerald-800","Statutory PAN":"bg-emerald-100 text-emerald-800","Statutory Nodal":"bg-emerald-100 text-emerald-800","Statutory Check":"bg-emerald-100 text-emerald-800","Statutory Partnership":"bg-emerald-100 text-emerald-800","Statutory Firm Reg":"bg-emerald-100 text-emerald-800","Statutory Rental":"bg-emerald-100 text-emerald-800","Statutory Virtual Code":"bg-emerald-100 text-emerald-800","Statutory Domain":"bg-emerald-100 text-emerald-800","Statutory MSD":"bg-emerald-100 text-emerald-800","Statutory LOI Ack":"bg-emerald-100 text-emerald-800","EOR In Progress":"bg-violet-100 text-violet-800","EOR Complete":"bg-violet-100 text-violet-800","LOA Pending":"bg-pink-100 text-pink-800",Inauguration:"bg-red-50 text-red-800",Approved:"bg-green-100 text-green-800",Rejected:"bg-red-100 text-red-800",Disqualified:"bg-gray-100 text-gray-800",Onboarded:"bg-emerald-100 text-emerald-800","LOI Approved":"bg-sky-100 text-sky-800","Security Deposit In Progress":"bg-red-50 text-red-800","Security Deposit Approved":"bg-green-100 text-green-800","Security Deposit":"bg-red-50 text-red-800","Security Details In Progress":"bg-red-50 text-red-800","Security Details Approved":"bg-green-100 text-green-800","Security Details":"bg-red-50 text-red-800","LOA Issued":"bg-pink-100 text-pink-800"})[B]||"bg-gray-100 text-gray-800";return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4","data-testid":"onboarding-all-apps-banner",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-red-900 mb-1",children:"DD Workflow - Initial Application Review"}),e.jsxs("p",{className:"text-red-800",children:["This page shows ",e.jsx("strong",{children:"only applications that haven't been shortlisted yet"}),". Review and select promising candidates using the ",e.jsx("strong",{children:"Shortlist"})," button. Once shortlisted, applications will be removed from here and moved to the ",e.jsx("strong",{children:"Dealership Requests"})," page for further processing."]})]})]})}),e.jsx("div",{className:"bg-white rounded-lg border border-slate-200 p-6",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(at,{type:"text",placeholder:"Search by name or registration number...",value:a,onChange:B=>i(B.target.value),className:"pl-10","data-testid":"onboarding-all-apps-search-input"})]}),e.jsxs(Dt,{value:o,onValueChange:d,children:[e.jsx(Et,{className:"w-full md:w-48","data-testid":"onboarding-all-apps-status-filter",children:e.jsx(Rt,{placeholder:"Filter by status"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"all",children:"All Statuses"}),T.map(B=>e.jsx(Me,{value:B,children:B},B))]})]}),e.jsxs(Dt,{value:p,onValueChange:h,children:[e.jsx(Et,{className:"w-full md:w-48","data-testid":"onboarding-all-apps-state-filter",children:e.jsx(Rt,{placeholder:"Filter by state"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"all",children:"All States"}),_.map(B=>e.jsx(Me,{value:B,children:B},B))]})]}),e.jsxs(Dt,{value:m,onValueChange:f,children:[e.jsx(Et,{className:"w-full md:w-48","data-testid":"onboarding-all-apps-location-filter",children:e.jsx(Rt,{placeholder:"Filter by location"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"all",children:"All Locations"}),E.map(B=>e.jsx(Me,{value:B,children:B},B))]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(se,{variant:n==="grid"?"default":"outline",size:"sm",onClick:()=>r("grid"),className:n==="grid"?"bg-re-red hover:bg-re-red-hover":"","data-testid":"onboarding-all-apps-grid-view-btn",children:[e.jsx(ok,{className:"w-4 h-4 mr-2"}),"Grid"]}),e.jsxs(se,{variant:n==="table"?"default":"outline",size:"sm",onClick:()=>r("table"),className:n==="table"?"bg-re-red hover:bg-re-red-hover":"","data-testid":"onboarding-all-apps-table-view-btn",children:[e.jsx(uk,{className:"w-4 h-4 mr-2"}),"Table"]})]}),e.jsxs(se,{variant:"outline",size:"sm","data-testid":"onboarding-all-apps-export-btn",children:[e.jsx(ji,{className:"w-4 h-4 mr-2"}),"Export"]}),x.length>0&&e.jsx(e.Fragment,{children:e.jsxs(se,{size:"sm",onClick:M,className:"bg-green-600 hover:bg-green-700","data-testid":"onboarding-all-apps-shortlist-btn",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"Shortlist (",x.length,")"]})}),e.jsx("div",{className:"ml-auto",children:e.jsxs(Ce,{variant:"outline",className:"text-slate-600","data-testid":"onboarding-all-apps-pending-badge",children:[(P==null?void 0:P.total)||Z.length," pending shortlisting"]})})]})]})}),S?e.jsx("div",{className:"flex justify-center items-center h-96 bg-white rounded-lg border border-slate-200",children:e.jsx(ns,{className:"w-8 h-8 animate-spin text-re-red"})}):n==="grid"?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4","data-testid":"onboarding-all-apps-grid-container",children:Z.map((B,G)=>e.jsxs("div",{className:"relative","data-testid":`onboarding-all-apps-grid-item-${G}`,children:[e.jsx("div",{className:"absolute top-4 left-4 z-10",children:e.jsx(Ln,{checked:x.includes(B.id),onCheckedChange:K=>U(B.id,K),className:"bg-white","data-testid":`onboarding-all-apps-grid-checkbox-${G}`})}),B.isShortlisted&&e.jsx("div",{className:"absolute top-4 right-4 z-10",children:e.jsx(Ce,{className:"bg-green-600","data-testid":`onboarding-all-apps-grid-shortlisted-badge-${G}`,children:"Shortlisted"})}),e.jsx(VE,{application:B,onViewDetails:t})]},B.id))}):e.jsx("div",{className:"bg-white rounded-lg border border-slate-200",children:e.jsxs(Ts,{"data-testid":"onboarding-all-apps-table",children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{className:"w-12",children:e.jsx(Ln,{checked:x.length===Z.length&&Z.length>0,onCheckedChange:W,"data-testid":"onboarding-all-apps-header-checkbox"})}),e.jsx(fe,{children:"Registration"}),e.jsx(fe,{children:"Name"}),e.jsx(fe,{children:"Location"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Shortlisted"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Submitted"})]})}),e.jsx(Os,{children:Z.map((B,G)=>e.jsxs(it,{className:"cursor-pointer hover:bg-slate-50",onClick:()=>t(B.id),"data-testid":`onboarding-all-apps-row-${G}`,children:[e.jsx(ue,{onClick:K=>K.stopPropagation(),children:e.jsx(Ln,{checked:x.includes(B.id),onCheckedChange:K=>U(B.id,K),"data-testid":`onboarding-all-apps-checkbox-${G}`})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-all-apps-reg-id-${G}`,children:B.registrationNumber})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-all-apps-name-${G}`,children:B.name})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-all-apps-location-${G}`,children:B.preferredLocation})}),e.jsx(ue,{children:e.jsx(Ce,{className:I(B.status),"data-testid":`onboarding-all-apps-status-${G}`,children:B.status})}),e.jsx(ue,{children:B.isShortlisted?e.jsx(Ce,{className:"bg-green-600","data-testid":`onboarding-all-apps-shortlisted-yes-${G}`,children:"Yes"}):e.jsx(Ce,{variant:"outline","data-testid":`onboarding-all-apps-shortlisted-no-${G}`,children:"No"})}),e.jsx(ue,{children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(hp,{value:B.progress,status:B.status,showPercent:!0,"data-testid":`onboarding-all-apps-progress-bar-${G}`})})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-all-apps-date-${G}`,children:Yt(B.submissionDate)})})]},B.id))})]})}),P&&P.totalPages>1&&e.jsx("div",{className:"py-6 border-t border-slate-200 bg-white rounded-b-lg",children:e.jsx(fo,{children:e.jsxs(po,{children:[e.jsx(Sn,{children:e.jsx(xo,{onClick:()=>D(B=>Math.max(1,B-1)),className:O===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(P.totalPages)].map((B,G)=>{const K=G+1;return K===1||K===P.totalPages||K>=O-1&&K<=O+1?e.jsx(Sn,{children:e.jsx(Vi,{isActive:O===K,onClick:()=>D(K),className:"cursor-pointer",children:K})},K):K===O-2||K===O+2?e.jsx(Sn,{children:e.jsx(vo,{})},K):null}),e.jsx(Sn,{children:e.jsx(go,{onClick:()=>D(B=>Math.min(P.totalPages,B+1)),className:O===P.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})}),e.jsx(ds,{open:N,onOpenChange:v,children:e.jsxs(os,{"data-testid":"onboarding-all-apps-shortlist-modal",children:[e.jsxs(xs,{children:[e.jsx(ms,{"data-testid":"onboarding-all-apps-shortlist-title",children:"Shortlist Applications"}),e.jsxs(bs,{"data-testid":"onboarding-all-apps-shortlist-desc",children:["You are about to shortlist ",x.length," application(s). These applications will be moved to the Dealership Requests page."]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{htmlFor:"shortlist-remark",children:"Shortlisting Remark (Optional)"}),e.jsx(Ws,{id:"shortlist-remark",placeholder:"Enter reason for shortlisting these applications...",value:w,onChange:B=>j(B.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-all-apps-shortlist-remark"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>v(!1),"data-testid":"onboarding-all-apps-shortlist-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-green-600 hover:bg-green-700",onClick:z,"data-testid":"onboarding-all-apps-shortlist-confirm",children:"Confirm Shortlist"})]})]})]})})]})}function Rq(t){const s=Eq(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find(Tq);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function Eq(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=Oq(a),d=Pq(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Xr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var _q=Symbol("radix.slottable");function Tq(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===_q}function Pq(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function Oq(t){var r,a;let s=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var mp="Popover",[HE]=ga(mp,[oo]),sh=oo(),[Lq,yo]=HE(mp),WE=t=>{const{__scopePopover:s,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!1}=t,d=sh(s),m=g.useRef(null),[f,p]=g.useState(!1),[h,x]=Bi({prop:r,defaultProp:a??!1,onChange:i,caller:mp});return e.jsx(Hf,{...d,children:e.jsx(Lq,{scope:s,contentId:Ar(),triggerRef:m,open:h,onOpenChange:x,onOpenToggle:g.useCallback(()=>x(u=>!u),[x]),hasCustomAnchor:f,onCustomAnchorAdd:g.useCallback(()=>p(!0),[]),onCustomAnchorRemove:g.useCallback(()=>p(!1),[]),modal:o,children:n})})};WE.displayName=mp;var GE="PopoverAnchor",Iq=g.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=yo(GE,n),i=sh(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:d}=a;return g.useEffect(()=>(o(),()=>d()),[o,d]),e.jsx(Qu,{...i,...r,ref:s})});Iq.displayName=GE;var KE="PopoverTrigger",YE=g.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=yo(KE,n),i=sh(n),o=Gs(s,a.triggerRef),d=e.jsx(js.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":e_(a.open),...r,ref:o,onClick:Kt(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?d:e.jsx(Qu,{asChild:!0,...i,children:d})});YE.displayName=KE;var Jb="PopoverPortal",[Mq,Fq]=HE(Jb,{forceMount:void 0}),ZE=t=>{const{__scopePopover:s,forceMount:n,children:r,container:a}=t,i=yo(Jb,s);return e.jsx(Mq,{scope:s,forceMount:n,children:e.jsx(Dr,{present:n||i.open,children:e.jsx(wd,{asChild:!0,container:a,children:r})})})};ZE.displayName=Jb;var md="PopoverContent",QE=g.forwardRef((t,s)=>{const n=Fq(md,t.__scopePopover),{forceMount:r=n.forceMount,...a}=t,i=yo(md,t.__scopePopover);return e.jsx(Dr,{present:r||i.open,children:i.modal?e.jsx($q,{...a,ref:s}):e.jsx(qq,{...a,ref:s})})});QE.displayName=md;var Bq=Rq("PopoverContent.RemoveScroll"),$q=g.forwardRef((t,s)=>{const n=yo(md,t.__scopePopover),r=g.useRef(null),a=Gs(s,r),i=g.useRef(!1);return g.useEffect(()=>{const o=r.current;if(o)return Yf(o)},[]),e.jsx(Ju,{as:Bq,allowPinchZoom:!0,children:e.jsx(XE,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Kt(t.onCloseAutoFocus,o=>{var d;o.preventDefault(),i.current||(d=n.triggerRef.current)==null||d.focus()}),onPointerDownOutside:Kt(t.onPointerDownOutside,o=>{const d=o.detail.originalEvent,m=d.button===0&&d.ctrlKey===!0,f=d.button===2||m;i.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:Kt(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),qq=g.forwardRef((t,s)=>{const n=yo(md,t.__scopePopover),r=g.useRef(!1),a=g.useRef(!1);return e.jsx(XE,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,d;(o=t.onCloseAutoFocus)==null||o.call(t,i),i.defaultPrevented||(r.current||(d=n.triggerRef.current)==null||d.focus(),i.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:i=>{var m,f;(m=t.onInteractOutside)==null||m.call(t,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((f=n.triggerRef.current)==null?void 0:f.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),XE=g.forwardRef((t,s)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:f,onInteractOutside:p,...h}=t,x=yo(md,n),u=sh(n);return $f(),e.jsx(Yu,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:e.jsx(bd,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:p,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:f,onDismiss:()=>x.onOpenChange(!1),children:e.jsx(Wf,{"data-state":e_(x.open),role:"dialog",id:x.contentId,...u,...h,ref:s,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),JE="PopoverClose",zq=g.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=yo(JE,n);return e.jsx(js.button,{type:"button",...r,ref:s,onClick:Kt(t.onClick,()=>a.onOpenChange(!1))})});zq.displayName=JE;var Uq="PopoverArrow",Vq=g.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=sh(n);return e.jsx(Gf,{...a,...r,ref:s})});Vq.displayName=Uq;function e_(t){return t?"open":"closed"}var Hq=WE,Wq=YE,Gq=ZE,Kq=QE;function _u({...t}){return e.jsx(Hq,{"data-slot":"popover",...t})}function Tu({...t}){return e.jsx(Wq,{"data-slot":"popover-trigger",...t})}function Pu({className:t,align:s="center",sideOffset:n=4,...r}){return e.jsx(Gq,{children:e.jsx(Kq,{"data-slot":"popover-content",align:s,sideOffset:n,className:Nt("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...r})})}var Ms=function(){return Ms=Object.assign||function(s){for(var n,r=1,a=arguments.length;r<a;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=n[i])}return s},Ms.apply(this,arguments)};function Yq(t,s){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&s.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(t);a<r.length;a++)s.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(t,r[a])&&(n[r[a]]=t[r[a]]);return n}function t_(t,s,n){for(var r=0,a=s.length,i;r<a;r++)(i||!(r in s))&&(i||(i=Array.prototype.slice.call(s,0,r)),i[r]=s[r]);return t.concat(i||Array.prototype.slice.call(s))}function nh(t){return t.mode==="multiple"}function rh(t){return t.mode==="range"}function fp(t){return t.mode==="single"}var Zq={root:"rdp",multiple_months:"rdp-multiple_months",with_weeknumber:"rdp-with_weeknumber",vhidden:"rdp-vhidden",button_reset:"rdp-button_reset",button:"rdp-button",caption:"rdp-caption",caption_start:"rdp-caption_start",caption_end:"rdp-caption_end",caption_between:"rdp-caption_between",caption_label:"rdp-caption_label",caption_dropdowns:"rdp-caption_dropdowns",dropdown:"rdp-dropdown",dropdown_month:"rdp-dropdown_month",dropdown_year:"rdp-dropdown_year",dropdown_icon:"rdp-dropdown_icon",months:"rdp-months",month:"rdp-month",table:"rdp-table",tbody:"rdp-tbody",tfoot:"rdp-tfoot",head:"rdp-head",head_row:"rdp-head_row",head_cell:"rdp-head_cell",nav:"rdp-nav",nav_button:"rdp-nav_button",nav_button_previous:"rdp-nav_button_previous",nav_button_next:"rdp-nav_button_next",nav_icon:"rdp-nav_icon",row:"rdp-row",weeknumber:"rdp-weeknumber",cell:"rdp-cell",day:"rdp-day",day_today:"rdp-day_today",day_outside:"rdp-day_outside",day_selected:"rdp-day_selected",day_disabled:"rdp-day_disabled",day_hidden:"rdp-day_hidden",day_range_start:"rdp-day_range_start",day_range_end:"rdp-day_range_end",day_range_middle:"rdp-day_range_middle"};function Qq(t,s){return Ka(t,"LLLL y",s)}function Xq(t,s){return Ka(t,"d",s)}function Jq(t,s){return Ka(t,"LLLL",s)}function ez(t){return"".concat(t)}function tz(t,s){return Ka(t,"cccccc",s)}function sz(t,s){return Ka(t,"yyyy",s)}var nz=Object.freeze({__proto__:null,formatCaption:Qq,formatDay:Xq,formatMonthCaption:Jq,formatWeekNumber:ez,formatWeekdayName:tz,formatYearCaption:sz}),rz=function(t,s,n){return Ka(t,"do MMMM (EEEE)",n)},az=function(){return"Month: "},iz=function(){return"Go to next month"},lz=function(){return"Go to previous month"},oz=function(t,s){return Ka(t,"cccc",s)},cz=function(t){return"Week n. ".concat(t)},dz=function(){return"Year: "},uz=Object.freeze({__proto__:null,labelDay:rz,labelMonthDropdown:az,labelNext:iz,labelPrevious:lz,labelWeekNumber:cz,labelWeekday:oz,labelYearDropdown:dz});function hz(){var t="buttons",s=Zq,n=_b,r={},a={},i=1,o={},d=new Date;return{captionLayout:t,classNames:s,formatters:nz,labels:uz,locale:n,modifiersClassNames:r,modifiers:a,numberOfMonths:i,styles:o,today:d,mode:"default"}}function mz(t){var s=t.fromYear,n=t.toYear,r=t.fromMonth,a=t.toMonth,i=t.fromDate,o=t.toDate;return r?i=pa(r):s&&(i=new Date(s,0,1)),a?o=sp(a):n&&(o=new Date(n,11,31)),{fromDate:i?cd(i):void 0,toDate:o?cd(o):void 0}}var s_=g.createContext(void 0);function fz(t){var s,n=t.initialProps,r=hz(),a=mz(n),i=a.fromDate,o=a.toDate,d=(s=n.captionLayout)!==null&&s!==void 0?s:r.captionLayout;d!=="buttons"&&(!i||!o)&&(d="buttons");var m;(fp(n)||nh(n)||rh(n))&&(m=n.onSelect);var f=Ms(Ms(Ms({},r),n),{captionLayout:d,classNames:Ms(Ms({},r.classNames),n.classNames),components:Ms({},n.components),formatters:Ms(Ms({},r.formatters),n.formatters),fromDate:i,labels:Ms(Ms({},r.labels),n.labels),mode:n.mode||r.mode,modifiers:Ms(Ms({},r.modifiers),n.modifiers),modifiersClassNames:Ms(Ms({},r.modifiersClassNames),n.modifiersClassNames),onSelect:m,styles:Ms(Ms({},r.styles),n.styles),toDate:o});return e.jsx(s_.Provider,{value:f,children:t.children})}function Rn(){var t=g.useContext(s_);if(!t)throw new Error("useDayPicker must be used within a DayPickerProvider.");return t}function n_(t){var s=Rn(),n=s.locale,r=s.classNames,a=s.styles,i=s.formatters.formatCaption;return e.jsx("div",{className:r.caption_label,style:a.caption_label,"aria-live":"polite",role:"presentation",id:t.id,children:i(t.displayMonth,{locale:n})})}function pz(t){return e.jsx("svg",Ms({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},t,{children:e.jsx("path",{d:"M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z",fill:"currentColor",fillRule:"nonzero"})}))}function r_(t){var s,n,r=t.onChange,a=t.value,i=t.children,o=t.caption,d=t.className,m=t.style,f=Rn(),p=(n=(s=f.components)===null||s===void 0?void 0:s.IconDropdown)!==null&&n!==void 0?n:pz;return e.jsxs("div",{className:d,style:m,children:[e.jsx("span",{className:f.classNames.vhidden,children:t["aria-label"]}),e.jsx("select",{name:t.name,"aria-label":t["aria-label"],className:f.classNames.dropdown,style:f.styles.dropdown,value:a,onChange:r,children:i}),e.jsxs("div",{className:f.classNames.caption_label,style:f.styles.caption_label,"aria-hidden":"true",children:[o,e.jsx(p,{className:f.classNames.dropdown_icon,style:f.styles.dropdown_icon})]})]})}function xz(t){var s,n=Rn(),r=n.fromDate,a=n.toDate,i=n.styles,o=n.locale,d=n.formatters.formatMonthCaption,m=n.classNames,f=n.components,p=n.labels.labelMonthDropdown;if(!r)return e.jsx(e.Fragment,{});if(!a)return e.jsx(e.Fragment,{});var h=[];if(a$(r,a))for(var x=pa(r),u=r.getMonth();u<=a.getMonth();u++)h.push(Lg(x,u));else for(var x=pa(new Date),u=0;u<=11;u++)h.push(Lg(x,u));var N=function(w){var j=Number(w.target.value),b=Lg(pa(t.displayMonth),j);t.onChange(b)},v=(s=f==null?void 0:f.Dropdown)!==null&&s!==void 0?s:r_;return e.jsx(v,{name:"months","aria-label":p(),className:m.dropdown_month,style:i.dropdown_month,onChange:N,value:t.displayMonth.getMonth(),caption:d(t.displayMonth,{locale:o}),children:h.map(function(w){return e.jsx("option",{value:w.getMonth(),children:d(w,{locale:o})},w.getMonth())})})}function gz(t){var s,n=t.displayMonth,r=Rn(),a=r.fromDate,i=r.toDate,o=r.locale,d=r.styles,m=r.classNames,f=r.components,p=r.formatters.formatYearCaption,h=r.labels.labelYearDropdown,x=[];if(!a)return e.jsx(e.Fragment,{});if(!i)return e.jsx(e.Fragment,{});for(var u=a.getFullYear(),N=i.getFullYear(),v=u;v<=N;v++)x.push(fS(JD(new Date),v));var w=function(b){var C=fS(pa(n),Number(b.target.value));t.onChange(C)},j=(s=f==null?void 0:f.Dropdown)!==null&&s!==void 0?s:r_;return e.jsx(j,{name:"years","aria-label":h(),className:m.dropdown_year,style:d.dropdown_year,onChange:w,value:n.getFullYear(),caption:p(n,{locale:o}),children:x.map(function(b){return e.jsx("option",{value:b.getFullYear(),children:p(b,{locale:o})},b.getFullYear())})})}function vz(t,s){var n=g.useState(t),r=n[0],a=n[1],i=s===void 0?r:s;return[i,a]}function yz(t){var s=t.month,n=t.defaultMonth,r=t.today,a=s||n||r||new Date,i=t.toDate,o=t.fromDate,d=t.numberOfMonths,m=d===void 0?1:d;if(i&&ud(i,a)<0){var f=-1*(m-1);a=gi(i,f)}return o&&ud(a,o)<0&&(a=o),pa(a)}function bz(){var t=Rn(),s=yz(t),n=vz(s,t.month),r=n[0],a=n[1],i=function(o){var d;if(!t.disableNavigation){var m=pa(o);a(m),(d=t.onMonthChange)===null||d===void 0||d.call(t,m)}};return[r,i]}function jz(t,s){for(var n=s.reverseMonths,r=s.numberOfMonths,a=pa(t),i=pa(gi(a,r)),o=ud(i,a),d=[],m=0;m<o;m++){var f=gi(a,m);d.push(f)}return n&&(d=d.reverse()),d}function Nz(t,s){if(!s.disableNavigation){var n=s.toDate,r=s.pagedNavigation,a=s.numberOfMonths,i=a===void 0?1:a,o=r?i:1,d=pa(t);if(!n)return gi(d,o);var m=ud(n,t);if(!(m<i))return gi(d,o)}}function wz(t,s){if(!s.disableNavigation){var n=s.fromDate,r=s.pagedNavigation,a=s.numberOfMonths,i=a===void 0?1:a,o=r?i:1,d=pa(t);if(!n)return gi(d,-o);var m=ud(d,n);if(!(m<=0))return gi(d,-o)}}var a_=g.createContext(void 0);function Sz(t){var s=Rn(),n=bz(),r=n[0],a=n[1],i=jz(r,s),o=Nz(r,s),d=wz(r,s),m=function(h){return i.some(function(x){return Tb(h,x)})},f=function(h,x){m(h)||(x&&iR(h,x)?a(gi(h,1+s.numberOfMonths*-1)):a(h))},p={currentMonth:r,displayMonths:i,goToMonth:a,goToDate:f,previousMonth:d,nextMonth:o,isDateDisplayed:m};return e.jsx(a_.Provider,{value:p,children:t.children})}function ah(){var t=g.useContext(a_);if(!t)throw new Error("useNavigation must be used within a NavigationProvider");return t}function SS(t){var s,n=Rn(),r=n.classNames,a=n.styles,i=n.components,o=ah().goToMonth,d=function(p){o(gi(p,t.displayIndex?-t.displayIndex:0))},m=(s=i==null?void 0:i.CaptionLabel)!==null&&s!==void 0?s:n_,f=e.jsx(m,{id:t.id,displayMonth:t.displayMonth});return e.jsxs("div",{className:r.caption_dropdowns,style:a.caption_dropdowns,children:[e.jsx("div",{className:r.vhidden,children:f}),e.jsx(xz,{onChange:d,displayMonth:t.displayMonth}),e.jsx(gz,{onChange:d,displayMonth:t.displayMonth})]})}function Cz(t){return e.jsx("svg",Ms({width:"16px",height:"16px",viewBox:"0 0 120 120"},t,{children:e.jsx("path",{d:"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z",fill:"currentColor",fillRule:"nonzero"})}))}function Az(t){return e.jsx("svg",Ms({width:"16px",height:"16px",viewBox:"0 0 120 120"},t,{children:e.jsx("path",{d:"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z",fill:"currentColor"})}))}var yf=g.forwardRef(function(t,s){var n=Rn(),r=n.classNames,a=n.styles,i=[r.button_reset,r.button];t.className&&i.push(t.className);var o=i.join(" "),d=Ms(Ms({},a.button_reset),a.button);return t.style&&Object.assign(d,t.style),e.jsx("button",Ms({},t,{ref:s,type:"button",className:o,style:d}))});function kz(t){var s,n,r=Rn(),a=r.dir,i=r.locale,o=r.classNames,d=r.styles,m=r.labels,f=m.labelPrevious,p=m.labelNext,h=r.components;if(!t.nextMonth&&!t.previousMonth)return e.jsx(e.Fragment,{});var x=f(t.previousMonth,{locale:i}),u=[o.nav_button,o.nav_button_previous].join(" "),N=p(t.nextMonth,{locale:i}),v=[o.nav_button,o.nav_button_next].join(" "),w=(s=h==null?void 0:h.IconRight)!==null&&s!==void 0?s:Az,j=(n=h==null?void 0:h.IconLeft)!==null&&n!==void 0?n:Cz;return e.jsxs("div",{className:o.nav,style:d.nav,children:[!t.hidePrevious&&e.jsx(yf,{name:"previous-month","aria-label":x,className:u,style:d.nav_button_previous,disabled:!t.previousMonth,onClick:t.onPreviousClick,children:a==="rtl"?e.jsx(w,{className:o.nav_icon,style:d.nav_icon}):e.jsx(j,{className:o.nav_icon,style:d.nav_icon})}),!t.hideNext&&e.jsx(yf,{name:"next-month","aria-label":N,className:v,style:d.nav_button_next,disabled:!t.nextMonth,onClick:t.onNextClick,children:a==="rtl"?e.jsx(j,{className:o.nav_icon,style:d.nav_icon}):e.jsx(w,{className:o.nav_icon,style:d.nav_icon})})]})}function CS(t){var s=Rn().numberOfMonths,n=ah(),r=n.previousMonth,a=n.nextMonth,i=n.goToMonth,o=n.displayMonths,d=o.findIndex(function(N){return Tb(t.displayMonth,N)}),m=d===0,f=d===o.length-1,p=s>1&&(m||!f),h=s>1&&(f||!m),x=function(){r&&i(r)},u=function(){a&&i(a)};return e.jsx(kz,{displayMonth:t.displayMonth,hideNext:p,hidePrevious:h,nextMonth:a,previousMonth:r,onPreviousClick:x,onNextClick:u})}function Dz(t){var s,n=Rn(),r=n.classNames,a=n.disableNavigation,i=n.styles,o=n.captionLayout,d=n.components,m=(s=d==null?void 0:d.CaptionLabel)!==null&&s!==void 0?s:n_,f;return a?f=e.jsx(m,{id:t.id,displayMonth:t.displayMonth}):o==="dropdown"?f=e.jsx(SS,{displayMonth:t.displayMonth,id:t.id}):o==="dropdown-buttons"?f=e.jsxs(e.Fragment,{children:[e.jsx(SS,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(CS,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id})]}):f=e.jsxs(e.Fragment,{children:[e.jsx(m,{id:t.id,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(CS,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:r.caption,style:i.caption,children:f})}function Rz(t){var s=Rn(),n=s.footer,r=s.styles,a=s.classNames.tfoot;return n?e.jsx("tfoot",{className:a,style:r.tfoot,children:e.jsx("tr",{children:e.jsx("td",{colSpan:8,children:n})})}):e.jsx(e.Fragment,{})}function Ez(t,s,n){for(var r=n?ic(new Date):qi(new Date,{locale:t,weekStartsOn:s}),a=[],i=0;i<7;i++){var o=Zr(r,i);a.push(o)}return a}function _z(){var t=Rn(),s=t.classNames,n=t.styles,r=t.showWeekNumber,a=t.locale,i=t.weekStartsOn,o=t.ISOWeek,d=t.formatters.formatWeekdayName,m=t.labels.labelWeekday,f=Ez(a,i,o);return e.jsxs("tr",{style:n.head_row,className:s.head_row,children:[r&&e.jsx("td",{style:n.head_cell,className:s.head_cell}),f.map(function(p,h){return e.jsx("th",{scope:"col",className:s.head_cell,style:n.head_cell,"aria-label":m(p,{locale:a}),children:d(p,{locale:a})},h)})]})}function Tz(){var t,s=Rn(),n=s.classNames,r=s.styles,a=s.components,i=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:_z;return e.jsx("thead",{style:r.head,className:n.head,children:e.jsx(i,{})})}function Pz(t){var s=Rn(),n=s.locale,r=s.formatters.formatDay;return e.jsx(e.Fragment,{children:r(t.date,{locale:n})})}var ej=g.createContext(void 0);function Oz(t){if(!nh(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(ej.Provider,{value:s,children:t.children})}return e.jsx(Lz,{initialProps:t.initialProps,children:t.children})}function Lz(t){var s=t.initialProps,n=t.children,r=s.selected,a=s.min,i=s.max,o=function(f,p,h){var x,u;(x=s.onDayClick)===null||x===void 0||x.call(s,f,p,h);var N=!!(p.selected&&a&&(r==null?void 0:r.length)===a);if(!N){var v=!!(!p.selected&&i&&(r==null?void 0:r.length)===i);if(!v){var w=r?t_([],r):[];if(p.selected){var j=w.findIndex(function(b){return ha(f,b)});w.splice(j,1)}else w.push(f);(u=s.onSelect)===null||u===void 0||u.call(s,w,f,p,h)}}},d={disabled:[]};r&&d.disabled.push(function(f){var p=i&&r.length>i-1,h=r.some(function(x){return ha(x,f)});return!!(p&&!h)});var m={selected:r,onDayClick:o,modifiers:d};return e.jsx(ej.Provider,{value:m,children:n})}function tj(){var t=g.useContext(ej);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function Iz(t,s){var n=s||{},r=n.from,a=n.to;return r&&a?ha(a,t)&&ha(r,t)?void 0:ha(a,t)?{from:a,to:void 0}:ha(r,t)?void 0:jy(r,t)?{from:t,to:a}:{from:r,to:t}:a?jy(t,a)?{from:a,to:t}:{from:t,to:a}:r?iR(t,r)?{from:t,to:r}:{from:r,to:t}:{from:t,to:void 0}}var sj=g.createContext(void 0);function Mz(t){if(!rh(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(sj.Provider,{value:s,children:t.children})}return e.jsx(Fz,{initialProps:t.initialProps,children:t.children})}function Fz(t){var s=t.initialProps,n=t.children,r=s.selected,a=r||{},i=a.from,o=a.to,d=s.min,m=s.max,f=function(u,N,v){var w,j;(w=s.onDayClick)===null||w===void 0||w.call(s,u,N,v);var b=Iz(u,r);(j=s.onSelect)===null||j===void 0||j.call(s,b,u,N,v)},p={range_start:[],range_end:[],range_middle:[],disabled:[]};if(i?(p.range_start=[i],o?(p.range_end=[o],ha(i,o)||(p.range_middle=[{after:i,before:o}])):p.range_end=[i]):o&&(p.range_start=[o],p.range_end=[o]),d&&(i&&!o&&p.disabled.push({after:Og(i,d-1),before:Zr(i,d-1)}),i&&o&&p.disabled.push({after:i,before:Zr(i,d-1)}),!i&&o&&p.disabled.push({after:Og(o,d-1),before:Zr(o,d-1)})),m){if(i&&!o&&(p.disabled.push({before:Zr(i,-m+1)}),p.disabled.push({after:Zr(i,m-1)})),i&&o){var h=Ii(o,i)+1,x=m-h;p.disabled.push({before:Og(i,x)}),p.disabled.push({after:Zr(o,x)})}!i&&o&&(p.disabled.push({before:Zr(o,-m+1)}),p.disabled.push({after:Zr(o,m-1)}))}return e.jsx(sj.Provider,{value:{selected:r,onDayClick:f,modifiers:p},children:n})}function nj(){var t=g.useContext(sj);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function Wm(t){return Array.isArray(t)?t_([],t):t!==void 0?[t]:[]}function Bz(t){var s={};return Object.entries(t).forEach(function(n){var r=n[0],a=n[1];s[r]=Wm(a)}),s}var vi;(function(t){t.Outside="outside",t.Disabled="disabled",t.Selected="selected",t.Hidden="hidden",t.Today="today",t.RangeStart="range_start",t.RangeEnd="range_end",t.RangeMiddle="range_middle"})(vi||(vi={}));var $z=vi.Selected,il=vi.Disabled,qz=vi.Hidden,zz=vi.Today,Bg=vi.RangeEnd,$g=vi.RangeMiddle,qg=vi.RangeStart,Uz=vi.Outside;function Vz(t,s,n){var r,a=(r={},r[$z]=Wm(t.selected),r[il]=Wm(t.disabled),r[qz]=Wm(t.hidden),r[zz]=[t.today],r[Bg]=[],r[$g]=[],r[qg]=[],r[Uz]=[],r);return t.fromDate&&a[il].push({before:t.fromDate}),t.toDate&&a[il].push({after:t.toDate}),nh(t)?a[il]=a[il].concat(s.modifiers[il]):rh(t)&&(a[il]=a[il].concat(n.modifiers[il]),a[qg]=n.modifiers[qg],a[$g]=n.modifiers[$g],a[Bg]=n.modifiers[Bg]),a}var i_=g.createContext(void 0);function Hz(t){var s=Rn(),n=tj(),r=nj(),a=Vz(s,n,r),i=Bz(s.modifiers),o=Ms(Ms({},a),i);return e.jsx(i_.Provider,{value:o,children:t.children})}function l_(){var t=g.useContext(i_);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function Wz(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function Gz(t){return!!(t&&typeof t=="object"&&"from"in t)}function Kz(t){return!!(t&&typeof t=="object"&&"after"in t)}function Yz(t){return!!(t&&typeof t=="object"&&"before"in t)}function Zz(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function Qz(t,s){var n,r=s.from,a=s.to;if(r&&a){var i=Ii(a,r)<0;i&&(n=[a,r],r=n[0],a=n[1]);var o=Ii(t,r)>=0&&Ii(a,t)>=0;return o}return a?ha(a,t):r?ha(r,t):!1}function Xz(t){return Rb(t)}function Jz(t){return Array.isArray(t)&&t.every(Rb)}function eU(t,s){return s.some(function(n){if(typeof n=="boolean")return n;if(Xz(n))return ha(t,n);if(Jz(n))return n.includes(t);if(Gz(n))return Qz(t,n);if(Zz(n))return n.dayOfWeek.includes(t.getDay());if(Wz(n)){var r=Ii(n.before,t),a=Ii(n.after,t),i=r>0,o=a<0,d=jy(n.before,n.after);return d?o&&i:i||o}return Kz(n)?Ii(t,n.after)>0:Yz(n)?Ii(n.before,t)>0:typeof n=="function"?n(t):!1})}function rj(t,s,n){var r=Object.keys(s).reduce(function(i,o){var d=s[o];return eU(t,d)&&i.push(o),i},[]),a={};return r.forEach(function(i){return a[i]=!0}),n&&!Tb(t,n)&&(a.outside=!0),a}function tU(t,s){for(var n=pa(t[0]),r=sp(t[t.length-1]),a,i,o=n;o<=r;){var d=rj(o,s),m=!d.disabled&&!d.hidden;if(!m){o=Zr(o,1);continue}if(d.selected)return o;d.today&&!i&&(i=o),a||(a=o),o=Zr(o,1)}return i||a}var sU=365;function o_(t,s){var n=s.moveBy,r=s.direction,a=s.context,i=s.modifiers,o=s.retry,d=o===void 0?{count:0,lastFocused:t}:o,m=a.weekStartsOn,f=a.fromDate,p=a.toDate,h=a.locale,x={day:Zr,week:by,month:gi,year:G9,startOfWeek:function(w){return a.ISOWeek?ic(w):qi(w,{locale:h,weekStartsOn:m})},endOfWeek:function(w){return a.ISOWeek?eR(w):Eb(w,{locale:h,weekStartsOn:m})}},u=x[n](t,r==="after"?1:-1);r==="before"&&f?u=K9([f,u]):r==="after"&&p&&(u=Y9([p,u]));var N=!0;if(i){var v=rj(u,i);N=!v.disabled&&!v.hidden}return N?u:d.count>sU?d.lastFocused:o_(u,{moveBy:n,direction:r,context:a,modifiers:i,retry:Ms(Ms({},d),{count:d.count+1})})}var c_=g.createContext(void 0);function nU(t){var s=ah(),n=l_(),r=g.useState(),a=r[0],i=r[1],o=g.useState(),d=o[0],m=o[1],f=tU(s.displayMonths,n),p=a??(d&&s.isDateDisplayed(d))?d:f,h=function(){m(a),i(void 0)},x=function(w){i(w)},u=Rn(),N=function(w,j){if(a){var b=o_(a,{moveBy:w,direction:j,context:u,modifiers:n});ha(a,b)||(s.goToDate(b,a),x(b))}},v={focusedDay:a,focusTarget:p,blur:h,focus:x,focusDayAfter:function(){return N("day","after")},focusDayBefore:function(){return N("day","before")},focusWeekAfter:function(){return N("week","after")},focusWeekBefore:function(){return N("week","before")},focusMonthBefore:function(){return N("month","before")},focusMonthAfter:function(){return N("month","after")},focusYearBefore:function(){return N("year","before")},focusYearAfter:function(){return N("year","after")},focusStartOfWeek:function(){return N("startOfWeek","before")},focusEndOfWeek:function(){return N("endOfWeek","after")}};return e.jsx(c_.Provider,{value:v,children:t.children})}function aj(){var t=g.useContext(c_);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function rU(t,s){var n=l_(),r=rj(t,n,s);return r}var ij=g.createContext(void 0);function aU(t){if(!fp(t.initialProps)){var s={selected:void 0};return e.jsx(ij.Provider,{value:s,children:t.children})}return e.jsx(iU,{initialProps:t.initialProps,children:t.children})}function iU(t){var s=t.initialProps,n=t.children,r=function(i,o,d){var m,f,p;if((m=s.onDayClick)===null||m===void 0||m.call(s,i,o,d),o.selected&&!s.required){(f=s.onSelect)===null||f===void 0||f.call(s,void 0,i,o,d);return}(p=s.onSelect)===null||p===void 0||p.call(s,i,i,o,d)},a={selected:s.selected,onDayClick:r};return e.jsx(ij.Provider,{value:a,children:n})}function d_(){var t=g.useContext(ij);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function lU(t,s){var n=Rn(),r=d_(),a=tj(),i=nj(),o=aj(),d=o.focusDayAfter,m=o.focusDayBefore,f=o.focusWeekAfter,p=o.focusWeekBefore,h=o.blur,x=o.focus,u=o.focusMonthBefore,N=o.focusMonthAfter,v=o.focusYearBefore,w=o.focusYearAfter,j=o.focusStartOfWeek,b=o.focusEndOfWeek,C=function(W){var U,M,z,T;fp(n)?(U=r.onDayClick)===null||U===void 0||U.call(r,t,s,W):nh(n)?(M=a.onDayClick)===null||M===void 0||M.call(a,t,s,W):rh(n)?(z=i.onDayClick)===null||z===void 0||z.call(i,t,s,W):(T=n.onDayClick)===null||T===void 0||T.call(n,t,s,W)},S=function(W){var U;x(t),(U=n.onDayFocus)===null||U===void 0||U.call(n,t,s,W)},R=function(W){var U;h(),(U=n.onDayBlur)===null||U===void 0||U.call(n,t,s,W)},_=function(W){var U;(U=n.onDayMouseEnter)===null||U===void 0||U.call(n,t,s,W)},A=function(W){var U;(U=n.onDayMouseLeave)===null||U===void 0||U.call(n,t,s,W)},E=function(W){var U;(U=n.onDayPointerEnter)===null||U===void 0||U.call(n,t,s,W)},q=function(W){var U;(U=n.onDayPointerLeave)===null||U===void 0||U.call(n,t,s,W)},O=function(W){var U;(U=n.onDayTouchCancel)===null||U===void 0||U.call(n,t,s,W)},D=function(W){var U;(U=n.onDayTouchEnd)===null||U===void 0||U.call(n,t,s,W)},P=function(W){var U;(U=n.onDayTouchMove)===null||U===void 0||U.call(n,t,s,W)},L=function(W){var U;(U=n.onDayTouchStart)===null||U===void 0||U.call(n,t,s,W)},$=function(W){var U;(U=n.onDayKeyUp)===null||U===void 0||U.call(n,t,s,W)},Y=function(W){var U;switch(W.key){case"ArrowLeft":W.preventDefault(),W.stopPropagation(),n.dir==="rtl"?d():m();break;case"ArrowRight":W.preventDefault(),W.stopPropagation(),n.dir==="rtl"?m():d();break;case"ArrowDown":W.preventDefault(),W.stopPropagation(),f();break;case"ArrowUp":W.preventDefault(),W.stopPropagation(),p();break;case"PageUp":W.preventDefault(),W.stopPropagation(),W.shiftKey?v():u();break;case"PageDown":W.preventDefault(),W.stopPropagation(),W.shiftKey?w():N();break;case"Home":W.preventDefault(),W.stopPropagation(),j();break;case"End":W.preventDefault(),W.stopPropagation(),b();break}(U=n.onDayKeyDown)===null||U===void 0||U.call(n,t,s,W)},Z={onClick:C,onFocus:S,onBlur:R,onKeyDown:Y,onKeyUp:$,onMouseEnter:_,onMouseLeave:A,onPointerEnter:E,onPointerLeave:q,onTouchCancel:O,onTouchEnd:D,onTouchMove:P,onTouchStart:L};return Z}function oU(){var t=Rn(),s=d_(),n=tj(),r=nj(),a=fp(t)?s.selected:nh(t)?n.selected:rh(t)?r.selected:void 0;return a}function cU(t){return Object.values(vi).includes(t)}function dU(t,s){var n=[t.classNames.day];return Object.keys(s).forEach(function(r){var a=t.modifiersClassNames[r];if(a)n.push(a);else if(cU(r)){var i=t.classNames["day_".concat(r)];i&&n.push(i)}}),n}function uU(t,s){var n=Ms({},t.styles.day);return Object.keys(s).forEach(function(r){var a;n=Ms(Ms({},n),(a=t.modifiersStyles)===null||a===void 0?void 0:a[r])}),n}function hU(t,s,n){var r,a,i,o=Rn(),d=aj(),m=rU(t,s),f=lU(t,m),p=oU(),h=!!(o.onDayClick||o.mode!=="default");g.useEffect(function(){var _;m.outside||d.focusedDay&&h&&ha(d.focusedDay,t)&&((_=n.current)===null||_===void 0||_.focus())},[d.focusedDay,t,n,h,m.outside]);var x=dU(o,m).join(" "),u=uU(o,m),N=!!(m.outside&&!o.showOutsideDays||m.hidden),v=(i=(a=o.components)===null||a===void 0?void 0:a.DayContent)!==null&&i!==void 0?i:Pz,w=e.jsx(v,{date:t,displayMonth:s,activeModifiers:m}),j={style:u,className:x,children:w,role:"gridcell"},b=d.focusTarget&&ha(d.focusTarget,t)&&!m.outside,C=d.focusedDay&&ha(d.focusedDay,t),S=Ms(Ms(Ms({},j),(r={disabled:m.disabled,role:"gridcell"},r["aria-selected"]=m.selected,r.tabIndex=C||b?0:-1,r)),f),R={isButton:h,isHidden:N,activeModifiers:m,selectedDays:p,buttonProps:S,divProps:j};return R}function mU(t){var s=g.useRef(null),n=hU(t.date,t.displayMonth,s);return n.isHidden?e.jsx("div",{role:"gridcell"}):n.isButton?e.jsx(yf,Ms({name:"day",ref:s},n.buttonProps)):e.jsx("div",Ms({},n.divProps))}function fU(t){var s=t.number,n=t.dates,r=Rn(),a=r.onWeekNumberClick,i=r.styles,o=r.classNames,d=r.locale,m=r.labels.labelWeekNumber,f=r.formatters.formatWeekNumber,p=f(Number(s),{locale:d});if(!a)return e.jsx("span",{className:o.weeknumber,style:i.weeknumber,children:p});var h=m(Number(s),{locale:d}),x=function(u){a(s,n,u)};return e.jsx(yf,{name:"week-number","aria-label":h,className:o.weeknumber,style:i.weeknumber,onClick:x,children:p})}function pU(t){var s,n,r=Rn(),a=r.styles,i=r.classNames,o=r.showWeekNumber,d=r.components,m=(s=d==null?void 0:d.Day)!==null&&s!==void 0?s:mU,f=(n=d==null?void 0:d.WeekNumber)!==null&&n!==void 0?n:fU,p;return o&&(p=e.jsx("td",{className:i.cell,style:a.cell,children:e.jsx(f,{number:t.weekNumber,dates:t.dates})})),e.jsxs("tr",{className:i.row,style:a.row,children:[p,t.dates.map(function(h){return e.jsx("td",{className:i.cell,style:a.cell,role:"presentation",children:e.jsx(m,{displayMonth:t.displayMonth,date:h})},s$(h))})]})}function AS(t,s,n){for(var r=n!=null&&n.ISOWeek?eR(s):Eb(s,n),a=n!=null&&n.ISOWeek?ic(t):qi(t,n),i=Ii(r,a),o=[],d=0;d<=i;d++)o.push(Zr(a,d));var m=o.reduce(function(f,p){var h=n!=null&&n.ISOWeek?tR(p):nR(p,n),x=f.find(function(u){return u.weekNumber===h});return x?(x.dates.push(p),f):(f.push({weekNumber:h,dates:[p]}),f)},[]);return m}function xU(t,s){var n=AS(pa(t),sp(t),s);if(s!=null&&s.useFixedWeeks){var r=r$(t,s);if(r<6){var a=n[n.length-1],i=a.dates[a.dates.length-1],o=by(i,6-r),d=AS(by(i,1),o,s);n.push.apply(n,d)}}return n}function gU(t){var s,n,r,a=Rn(),i=a.locale,o=a.classNames,d=a.styles,m=a.hideHead,f=a.fixedWeeks,p=a.components,h=a.weekStartsOn,x=a.firstWeekContainsDate,u=a.ISOWeek,N=xU(t.displayMonth,{useFixedWeeks:!!f,ISOWeek:u,locale:i,weekStartsOn:h,firstWeekContainsDate:x}),v=(s=p==null?void 0:p.Head)!==null&&s!==void 0?s:Tz,w=(n=p==null?void 0:p.Row)!==null&&n!==void 0?n:pU,j=(r=p==null?void 0:p.Footer)!==null&&r!==void 0?r:Rz;return e.jsxs("table",{id:t.id,className:o.table,style:d.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!m&&e.jsx(v,{}),e.jsx("tbody",{className:o.tbody,style:d.tbody,children:N.map(function(b){return e.jsx(w,{displayMonth:t.displayMonth,dates:b.dates,weekNumber:b.weekNumber},b.weekNumber)})}),e.jsx(j,{displayMonth:t.displayMonth})]})}function vU(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var yU=vU()?g.useLayoutEffect:g.useEffect,zg=!1,bU=0;function kS(){return"react-day-picker-".concat(++bU)}function jU(t){var s,n=t??(zg?kS():null),r=g.useState(n),a=r[0],i=r[1];return yU(function(){a===null&&i(kS())},[]),g.useEffect(function(){zg===!1&&(zg=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function NU(t){var s,n,r=Rn(),a=r.dir,i=r.classNames,o=r.styles,d=r.components,m=ah().displayMonths,f=jU(r.id?"".concat(r.id,"-").concat(t.displayIndex):void 0),p=r.id?"".concat(r.id,"-grid-").concat(t.displayIndex):void 0,h=[i.month],x=o.month,u=t.displayIndex===0,N=t.displayIndex===m.length-1,v=!u&&!N;a==="rtl"&&(s=[u,N],N=s[0],u=s[1]),u&&(h.push(i.caption_start),x=Ms(Ms({},x),o.caption_start)),N&&(h.push(i.caption_end),x=Ms(Ms({},x),o.caption_end)),v&&(h.push(i.caption_between),x=Ms(Ms({},x),o.caption_between));var w=(n=d==null?void 0:d.Caption)!==null&&n!==void 0?n:Dz;return e.jsxs("div",{className:h.join(" "),style:x,children:[e.jsx(w,{id:f,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(gU,{id:p,"aria-labelledby":f,displayMonth:t.displayMonth})]},t.displayIndex)}function wU(t){var s=Rn(),n=s.classNames,r=s.styles;return e.jsx("div",{className:n.months,style:r.months,children:t.children})}function SU(t){var s,n,r=t.initialProps,a=Rn(),i=aj(),o=ah(),d=g.useState(!1),m=d[0],f=d[1];g.useEffect(function(){a.initialFocus&&i.focusTarget&&(m||(i.focus(i.focusTarget),f(!0)))},[a.initialFocus,m,i.focus,i.focusTarget,i]);var p=[a.classNames.root,a.className];a.numberOfMonths>1&&p.push(a.classNames.multiple_months),a.showWeekNumber&&p.push(a.classNames.with_weeknumber);var h=Ms(Ms({},a.styles.root),a.style),x=Object.keys(r).filter(function(N){return N.startsWith("data-")}).reduce(function(N,v){var w;return Ms(Ms({},N),(w={},w[v]=r[v],w))},{}),u=(n=(s=r.components)===null||s===void 0?void 0:s.Months)!==null&&n!==void 0?n:wU;return e.jsx("div",Ms({className:p.join(" "),style:h,dir:a.dir,id:a.id,nonce:r.nonce,title:r.title,lang:r.lang},x,{children:e.jsx(u,{children:o.displayMonths.map(function(N,v){return e.jsx(NU,{displayIndex:v,displayMonth:N},v)})})}))}function CU(t){var s=t.children,n=Yq(t,["children"]);return e.jsx(fz,{initialProps:n,children:e.jsx(Sz,{children:e.jsx(aU,{initialProps:n,children:e.jsx(Oz,{initialProps:n,children:e.jsx(Mz,{initialProps:n,children:e.jsx(Hz,{children:e.jsx(nU,{children:s})})})})})})})}function AU(t){return e.jsx(CU,Ms({},t,{children:e.jsx(SU,{initialProps:t})}))}function bf({className:t,classNames:s,showOutsideDays:n=!0,...r}){return e.jsx(AU,{showOutsideDays:n,className:Nt("p-3",t),classNames:{months:"flex flex-col sm:flex-row gap-2",month:"flex flex-col gap-4",caption:"flex justify-center pt-1 relative items-center w-full",caption_label:"text-sm font-medium",nav:"flex items-center gap-1",nav_button:Nt(rd({variant:"outline"}),"size-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-x-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:Nt("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md",r.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:Nt(rd({variant:"ghost"}),"size-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground",day_range_end:"day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...s},components:{IconLeft:({className:a,...i})=>e.jsx(lo,{className:Nt("size-4",a),...i}),IconRight:({className:a,...i})=>e.jsx(bi,{className:Nt("size-4",a),...i})},...r})}function kU({onViewDetails:t}){const[s,n]=g.useState("table"),[r,a]=g.useState(""),[i,o]=g.useState("all"),[d,m]=g.useState("all"),[f,p]=g.useState("all"),[h,x]=g.useState(""),[u,N]=g.useState(""),[v,w]=g.useState("date-desc"),[j,b]=g.useState(1),[C,S]=g.useState(null),[R,_]=g.useState([]),[A,E]=g.useState(!1),[q,O]=g.useState(!1),[D,P]=g.useState(""),[L,$]=g.useState([]),[Y,Z]=g.useState([]),[W,U]=g.useState([]),[M,z]=g.useState(!0);g.useEffect(()=>{I()},[h,u,i,r,j,d,f]),g.useEffect(()=>{b(1)},[h,u,i,r,d,f]),g.useEffect(()=>{T()},[]);const T=async()=>{try{const ce=await Is.getStates(),Pe=(Array.isArray(ce)?ce:(ce==null?void 0:ce.data)||(ce==null?void 0:ce.states)||[]).map(et=>typeof et=="string"?et:et.name||et.stateName).filter(Boolean);$(Pe)}catch(ce){console.error("Failed to fetch states:",ce)}},I=async()=>{try{z(!0);const ce=["Questionnaire Pending","Questionnaire Completed","Shortlisted"],ve=await hs.getApplications({fromDate:h,toDate:u,status:i==="all"?ce.join(","):i,location:d!=="all"?d:void 0,state:f!=="all"?f:void 0,ddLeadShortlisted:"false",isShortlisted:"true",search:r,page:j,limit:10}),Pe=ve.data||[];S(ve.meta);const et=Pe.map(ee=>({id:ee.id,registrationNumber:ee.applicationId||"N/A",name:ee.applicantName,email:ee.email,phone:ee.phone,age:ee.age,education:ee.education,residentialAddress:ee.address||ee.city||"",businessAddress:ee.address||"",preferredLocation:ee.preferredLocation,state:ee.state,ownsBike:ee.ownRoyalEnfield==="yes",pastExperience:ee.experienceYears?`${ee.experienceYears} years`:ee.description||"",status:ee.overallStatus,questionnaireMarks:ee.score||ee.questionnaireMarks||0,rank:0,totalApplicantsAtLocation:0,submissionDate:ee.createdAt,assignedUsers:[],progress:ee.progressPercentage||0,isShortlisted:ee.isShortlisted,ddLeadShortlisted:ee.ddLeadShortlisted,companyName:ee.companyName,source:ee.source,existingDealer:ee.existingDealer,royalEnfieldModel:ee.royalEnfieldModel,description:ee.description,pincode:ee.pincode,locationType:ee.locationType,ownRoyalEnfield:ee.ownRoyalEnfield,address:ee.address}));U(et);const kt=Array.from(new Set(et.map(ee=>ee.preferredLocation))).filter(Boolean);Z(ee=>Array.from(new Set([...ee,...kt])));const vt=Array.from(new Set(et.map(ee=>ee.state))).filter(Boolean);$(ee=>Array.from(new Set([...ee,...vt])))}catch(ce){console.error("Failed to fetch applications:",ce),te.error("Failed to load opportunity requests")}finally{z(!1)}},B=W.sort((ce,ve)=>v==="score-desc"?(ve.questionnaireMarks||0)-(ce.questionnaireMarks||0):v==="score-asc"?(ce.questionnaireMarks||0)-(ve.questionnaireMarks||0):v==="date-desc"?new Date(ve.submissionDate).getTime()-new Date(ce.submissionDate).getTime():v==="date-asc"?new Date(ce.submissionDate).getTime()-new Date(ve.submissionDate).getTime():0),G=ce=>{_(ce?B.map(ve=>ve.id):[])},K=(ce,ve)=>{_(ve?[...R,ce]:R.filter(Pe=>Pe!==ce))},H=()=>{if(R.length===0){te.error("Please select at least one application to shortlist");return}O(!0)},X=async()=>{try{const ce=await hs.shortlistApplications(R,[],D);if(ce&&ce.success)await I(),_([]),O(!1),P(""),te.success(`${R.length} application(s) shortlisted successfully. Users will be assigned automatically.`);else throw new Error((ce==null?void 0:ce.message)||"Failed to process shortlisting")}catch(ce){console.error("Failed to shortlist applications:",ce),te.error(ce.message||"Failed to process shortlisting")}},J=async()=>{if(R.length===0){te.error("Please select at least one application");return}try{E(!0);const ce=await hs.sendBulkReminders(R);ce.success&&(te.success(ce.message||`Reminder emails sent to ${R.length} applicant(s)`),_([]))}catch(ce){console.error("Failed to send reminders:",ce),te.error(ce.message||"Failed to send reminders")}finally{E(!1)}},ae=async()=>{const ce=B.filter(et=>et.status!=="Questionnaire Pending"),ve=ce.filter(et=>R.includes(et.id));let Pe=[];if(R.length>0){if(ve.length===0){te.error('Selected applications are in "Questionnaire Pending" status and cannot be exported.');return}Pe=ve.map(et=>et.id),ve.length<R.length&&te.info(`Skipping ${R.length-ve.length} applications with pending questionnaires.`)}else Pe=ce.map(et=>et.id);if(Pe.length===0){te.error("No applications with completed questionnaires available for export");return}try{const et=te.loading("Preparing Excel export..."),kt=await hs.exportResponses(Pe);if(te.dismiss(et),!kt||kt.length===0){te.error("No response data found");return}const vt=Object.keys(kt[0]),ge=[vt.join(","),...kt.map(dt=>vt.map(st=>{const xt=dt[st]??"";return`"${String(xt).replace(/"/g,'""')}"`}).join(","))].join(`
`),ye=new Blob([ge],{type:"text/csv;charset=utf-8;"}),Be=URL.createObjectURL(ye),$e=document.createElement("a");$e.setAttribute("href",Be),$e.setAttribute("download",`onboarding_responses_${new Date().toISOString().split("T")[0]}.xlsx`),document.body.appendChild($e),$e.click(),document.body.removeChild($e),te.success(`Exported ${Pe.length} records to Excel successfully`)}catch(et){console.error("Export failed:",et),te.error(et.message||"Failed to export responses")}},le=["Questionnaire Pending","Questionnaire Completed","Shortlisted"],xe=ce=>({Submitted:"bg-blue-100 text-blue-800","Questionnaire Pending":"bg-yellow-100 text-yellow-800","Questionnaire Completed":"bg-cyan-100 text-cyan-800",Shortlisted:"bg-purple-100 text-purple-800","Level 1 Interview Pending":"bg-orange-100 text-orange-800","Level 1 Approved":"bg-green-100 text-green-800","Level 2 Interview Pending":"bg-orange-100 text-orange-800","Level 2 Approved":"bg-green-100 text-green-800","Level 2 Recommended":"bg-teal-100 text-teal-800","Level 3 Interview Pending":"bg-orange-100 text-orange-800","FDD Verification":"bg-indigo-100 text-indigo-800","Payment Pending":"bg-red-50 text-red-800","LOI Issued":"bg-sky-100 text-sky-800","Dealer Code Generation":"bg-purple-100 text-purple-800","Architecture Team Assigned":"bg-blue-100 text-blue-800","Architecture Document Upload":"bg-blue-100 text-blue-800","Architecture Team Completion":"bg-blue-100 text-blue-800","Statutory GST":"bg-emerald-100 text-emerald-800","Statutory PAN":"bg-emerald-100 text-emerald-800","Statutory Nodal":"bg-emerald-100 text-emerald-800","Statutory Check":"bg-emerald-100 text-emerald-800","Statutory Partnership":"bg-emerald-100 text-emerald-800","Statutory Firm Reg":"bg-emerald-100 text-emerald-800","Statutory Rental":"bg-emerald-100 text-emerald-800","Statutory Virtual Code":"bg-emerald-100 text-emerald-800","Statutory Domain":"bg-emerald-100 text-emerald-800","Statutory MSD":"bg-emerald-100 text-emerald-800","Statutory LOI Ack":"bg-emerald-100 text-emerald-800","EOR In Progress":"bg-violet-100 text-violet-800","LOA Pending":"bg-pink-100 text-pink-800",Inauguration:"bg-green-100 text-green-800",Approved:"bg-green-100 text-green-800",Rejected:"bg-red-100 text-red-800",Disqualified:"bg-gray-100 text-gray-800","In Review":"bg-slate-100 text-slate-800","Level 3 Approved":"bg-green-100 text-green-800","LOI In Progress":"bg-sky-50 text-sky-700","LOI Approved":"bg-green-100 text-green-800","Security Deposit In Progress":"bg-blue-50 text-blue-700","Security Deposit Approved":"bg-green-100 text-green-800","Security Deposit":"bg-blue-100 text-blue-800","Security Details In Progress":"bg-blue-50 text-blue-700","Security Details Approved":"bg-green-100 text-green-800","Security Details":"bg-blue-100 text-blue-800","LOI Issued In Progress":"bg-sky-50 text-sky-700","Statutory Work In Progress":"bg-emerald-50 text-emerald-700","Statutory Work Completed":"bg-green-100 text-green-800","Architecture Work In Progress":"bg-blue-50 text-blue-700","Architecture Work Completed":"bg-green-100 text-green-800","Dealer Code Generation In Progress":"bg-purple-50 text-purple-700","Dealer Code Generated":"bg-green-100 text-green-800","LOA Issued":"bg-pink-100 text-pink-800","EOR Complete":"bg-violet-100 text-violet-800",Onboarded:"bg-green-200 text-green-900"})[ce]||"bg-gray-100 text-gray-800";return M?e.jsx("div",{className:"flex justify-center items-center h-96",children:e.jsx(ns,{className:"w-8 h-8 animate-spin text-re-red"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-white rounded-lg border border-slate-200 p-6",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(at,{type:"text",placeholder:"Search by name or registration number...",value:r,onChange:ce=>a(ce.target.value),className:"pl-10","data-testid":"onboarding-opp-requests-search-input"})]}),e.jsxs(Dt,{value:i,onValueChange:o,children:[e.jsx(Et,{className:"w-full md:w-48","data-testid":"onboarding-opp-requests-status-select",children:e.jsx(Rt,{placeholder:"Filter by status"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"all",children:"All Statuses"}),le.map(ce=>e.jsx(Me,{value:ce,children:ce},ce))]})]}),e.jsx(se,{variant:"ghost",size:"sm",className:"text-slate-500 hover:text-slate-700 h-9",onClick:()=>{x(""),N(""),o("all"),m("all"),p("all"),a("")},"data-testid":"onboarding-opp-requests-clear-filters",children:"Clear Filters"}),e.jsxs(Dt,{value:f,onValueChange:p,children:[e.jsx(Et,{className:"w-full md:w-48","data-testid":"onboarding-opp-requests-state-select",children:e.jsx(Rt,{placeholder:"Filter by state"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"all",children:"All States"}),L.map(ce=>e.jsx(Me,{value:ce,children:ce},ce))]})]}),e.jsxs(Dt,{value:d,onValueChange:m,children:[e.jsx(Et,{className:"w-full md:w-48","data-testid":"onboarding-opp-requests-location-select",children:e.jsx(Rt,{placeholder:"Filter by location"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"all",children:"All Locations"}),Y.map(ce=>e.jsx(Me,{value:ce,children:ce},ce))]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 md:flex-none",children:[e.jsxs(_u,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(se,{variant:"outline",className:Nt("w-full md:w-40 justify-start text-left font-normal h-9 px-3",!h&&"text-muted-foreground"),"data-testid":"onboarding-opp-requests-from-date-trigger",children:[e.jsx(dr,{className:"mr-2 h-4 w-4 text-slate-400"}),h?Ka(new Date(h),"PPP"):e.jsx("span",{className:"text-xs",children:"From Date"})]})}),e.jsx(Pu,{className:"w-auto p-0",align:"start",children:e.jsx(bf,{mode:"single",selected:h?new Date(h):void 0,onSelect:ce=>x(ce?ce.toISOString().split("T")[0]:""),initialFocus:!0})})]}),e.jsx("span",{className:"text-slate-400",children:"to"}),e.jsxs(_u,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(se,{variant:"outline",className:Nt("w-full md:w-40 justify-start text-left font-normal h-9 px-3",!u&&"text-muted-foreground"),"data-testid":"onboarding-opp-requests-to-date-trigger",children:[e.jsx(dr,{className:"mr-2 h-4 w-4 text-slate-400"}),u?Ka(new Date(u),"PPP"):e.jsx("span",{className:"text-xs",children:"To Date"})]})}),e.jsx(Pu,{className:"w-auto p-0",align:"start",children:e.jsx(bf,{mode:"single",selected:u?new Date(u):void 0,onSelect:ce=>N(ce?ce.toISOString().split("T")[0]:""),initialFocus:!0})})]})]}),e.jsxs(Dt,{value:v,onValueChange:w,children:[e.jsx(Et,{className:"w-full md:w-48","data-testid":"onboarding-opp-requests-sort-select",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(TI,{className:"w-4 h-4 text-slate-400"}),e.jsx(Rt,{placeholder:"Sort by"})]})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"date-desc",children:"Newest Applied"}),e.jsx(Me,{value:"date-asc",children:"Oldest Applied"}),e.jsx(Me,{value:"score-desc",children:"Highest Score"}),e.jsx(Me,{value:"score-asc",children:"Lowest Score"})]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(se,{variant:s==="grid"?"default":"outline",size:"sm",onClick:()=>n("grid"),className:s==="grid"?"bg-re-red hover:bg-re-red-hover":"","data-testid":"onboarding-opp-requests-view-grid-btn",children:[e.jsx(ok,{className:"w-4 h-4 mr-2"}),"Grid"]}),e.jsxs(se,{variant:s==="table"?"default":"outline",size:"sm",onClick:()=>n("table"),className:s==="table"?"bg-re-red hover:bg-re-red-hover":"","data-testid":"onboarding-opp-requests-view-table-btn",children:[e.jsx(uk,{className:"w-4 h-4 mr-2"}),"Table"]})]}),e.jsxs(se,{variant:"outline",size:"sm",onClick:ae,"data-testid":"onboarding-opp-requests-export-btn",children:[e.jsx(ji,{className:"w-4 h-4 mr-2"}),"Export"]}),R.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(se,{variant:"outline",size:"sm",onClick:J,disabled:A,"data-testid":"onboarding-opp-requests-bulk-reminder-btn",children:[A?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Ur,{className:"w-4 h-4 mr-2"}),"Send Reminders (",R.length,")"]}),e.jsxs(se,{size:"sm",onClick:H,className:"bg-green-600 hover:bg-green-700","data-testid":"onboarding-opp-requests-bulk-shortlist-btn",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"Shortlist (",R.length,")"]})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs(Ce,{variant:"outline",className:"text-slate-600","data-testid":"onboarding-opp-requests-pending-count",children:[(C==null?void 0:C.total)||B.length," pending shortlisting"]})})]})]})}),s==="grid"?e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4","data-testid":"onboarding-opp-requests-grid",children:[B.map((ce,ve)=>e.jsxs("div",{className:"relative","data-testid":`onboarding-opp-requests-grid-item-${ve}`,children:[e.jsx("div",{className:"absolute top-4 left-4 z-10",children:e.jsx(Ln,{checked:R.includes(ce.id),onCheckedChange:Pe=>K(ce.id,Pe),className:"bg-white","data-testid":`onboarding-opp-requests-grid-checkbox-${ve}`})}),e.jsx(VE,{application:ce,onViewDetails:t})]},ce.id)),B.length===0&&e.jsxs("div",{className:"col-span-full text-center py-12 text-slate-500 bg-white rounded-lg border border-slate-200","data-testid":"onboarding-opp-requests-grid-empty",children:[e.jsx(un,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{className:"text-lg mb-2",children:"No opportunity requests found"}),e.jsx("p",{className:"text-sm",children:"Try adjusting your filters"})]})]}):e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200","data-testid":"onboarding-opp-requests-table-container",children:[e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{className:"w-12",children:e.jsx(Ln,{checked:R.length===B.length&&B.length>0,onCheckedChange:G,"data-testid":"onboarding-opp-requests-table-select-all"})}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-reg",children:"Registration"}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-name",children:"Name"}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-pref-loc",children:"Preferred Location"}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-status",children:"Status"}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-score",children:"Score"}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-app-loc",children:"Applicant Location"}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-shortlisted",children:"Shortlisted"}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-progress",children:"Progress"}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-date",children:"Applied On"})]})}),e.jsxs(Os,{children:[B.map((ce,ve)=>e.jsxs(it,{className:"cursor-pointer hover:bg-slate-50",onClick:()=>t(ce.id),"data-testid":`onboarding-opp-requests-row-${ve}`,children:[e.jsx(ue,{onClick:Pe=>Pe.stopPropagation(),children:e.jsx(Ln,{checked:R.includes(ce.id),onCheckedChange:Pe=>K(ce.id,Pe),"data-testid":`onboarding-opp-requests-table-select-item-${ce.id}`})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-opp-requests-reg-${ve}`,children:ce.registrationNumber})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-opp-requests-name-${ve}`,children:ce.name})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-opp-requests-pref-loc-${ve}`,children:ce.preferredLocation})}),e.jsx(ue,{children:e.jsx(Ce,{className:xe(ce.status),"data-testid":`onboarding-opp-requests-status-${ve}`,children:ce.status})}),e.jsx(ue,{children:e.jsx("span",{className:"font-semibold text-slate-900","data-testid":`onboarding-opp-requests-score-${ve}`,children:ce.questionnaireMarks})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-opp-requests-app-loc-${ve}`,children:ce.businessAddress})}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline","data-testid":`onboarding-opp-requests-shortlisted-badge-${ve}`,children:"No"})}),e.jsx(ue,{children:e.jsx(hp,{value:ce.progress,status:ce.status,showPercent:!0,"data-testid":`onboarding-opp-requests-progress-${ve}`})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-opp-requests-date-${ve}`,children:Yt(ce.submissionDate)})})]},ce.id)),B.length===0&&e.jsx(it,{children:e.jsxs(ue,{colSpan:9,className:"text-center py-12 text-slate-500","data-testid":"onboarding-opp-requests-table-empty",children:[e.jsx(un,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{className:"text-lg mb-2",children:"No opportunity requests found"}),e.jsx("p",{className:"text-sm",children:"Try adjusting your filters"})]})})]})]}),C&&C.totalPages>1&&e.jsx("div",{className:"py-4 border-t border-slate-200",children:e.jsx(fo,{children:e.jsxs(po,{children:[e.jsx(Sn,{children:e.jsx(xo,{onClick:()=>b(ce=>Math.max(1,ce-1)),className:j===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(C.totalPages)].map((ce,ve)=>{const Pe=ve+1;return Pe===1||Pe===C.totalPages||Pe>=j-1&&Pe<=j+1?e.jsx(Sn,{children:e.jsx(Vi,{isActive:j===Pe,onClick:()=>b(Pe),className:"cursor-pointer",children:Pe})},Pe):Pe===j-2||Pe===j+2?e.jsx(Sn,{children:e.jsx(vo,{})},Pe):null}),e.jsx(Sn,{children:e.jsx(go,{onClick:()=>b(ce=>Math.min(C.totalPages,ce+1)),className:j===C.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]}),e.jsx(ds,{open:q,onOpenChange:O,children:e.jsxs(os,{className:"overflow-visible","data-testid":"onboarding-opp-requests-shortlist-modal",children:[e.jsxs(xs,{children:[e.jsx(ms,{"data-testid":"onboarding-opp-requests-shortlist-modal-title",children:"Shortlist Applications"}),e.jsxs(bs,{children:["You are about to shortlist ",R.length," application(s). These applications will be moved to the Dealership Requests page and users will be assigned automatically based on the applied location."]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{children:"Shortlisting Remark (Optional)"}),e.jsx(Ws,{placeholder:"Enter reason for shortlisting these applications...",value:D,onChange:ce=>P(ce.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-opp-requests-remark-textarea"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>{O(!1),P("")},"data-testid":"onboarding-opp-requests-shortlist-cancel-btn",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-green-600 hover:bg-green-700",onClick:X,"data-testid":"onboarding-opp-requests-shortlist-confirm-btn",children:"Confirm Shortlist"})]})]})]})})]})}function DU({onViewDetails:t}){var W,U;const[s,n]=g.useState(""),[r,a]=g.useState("all"),[i,o]=g.useState("all"),[d,m]=g.useState(""),[f,p]=g.useState(""),[h,x]=g.useState(1),[u,N]=g.useState(null),[v,w]=g.useState([]),[j,b]=g.useState(!0),[C,S]=g.useState([]),[R,_]=g.useState([]),[A,E]=g.useState([]),[q,O]=g.useState(!1),D=async()=>{var M,z,T,I;if(A.length!==0)try{O(!0);const B=await hs.bulkConvertToOpportunity({ids:A});B!=null&&B.success&&((((M=B.data)==null?void 0:M.success)>0||!B.data)&&te.success(B.message||`Successfully converted ${((z=B.data)==null?void 0:z.success)||A.length} leads.`),((T=B.data)==null?void 0:T.failed)>0&&((I=B.data)!=null&&I.errors)&&B.data.errors.forEach(G=>{te.error(G,{duration:5e3})}),E([]),await Y())}catch(B){console.error("Bulk conversion error:",B),te.error(B.message||"Failed to perform bulk conversion")}finally{O(!1)}},P=()=>{A.length===Z.length?E([]):E(Z.map(M=>M.id))},L=M=>{E(z=>z.includes(M)?z.filter(T=>T!==M):[...z,M])};g.useEffect(()=>{Y()},[d,f,s,h,r,i]),g.useEffect(()=>{x(1)},[d,f,s,r,i]),g.useEffect(()=>{$()},[]);const $=async()=>{try{const M=await Is.getStates(),T=(Array.isArray(M)?M:(M==null?void 0:M.data)||(M==null?void 0:M.states)||[]).map(I=>typeof I=="string"?I:I.name||I.stateName).filter(Boolean);S(T)}catch(M){console.error("Failed to fetch states:",M)}},Y=async()=>{try{b(!0);const M=await hs.getApplications({fromDate:d,toDate:f,search:s,status:"Submitted",isShortlisted:"false",location:r!=="all"?r:void 0,state:i!=="all"?i:void 0,page:h,limit:10}),z=M.data||[];N(M.meta);const T=z.map(G=>({id:G.id,registrationNumber:G.applicationId||"N/A",name:G.applicantName,email:G.email,phone:G.phone,age:G.age,education:G.education,residentialAddress:G.address||G.city||"",businessAddress:G.address||"",preferredLocation:G.preferredLocation,state:G.state,ownsBike:G.ownRoyalEnfield==="yes",pastExperience:G.experienceYears?`${G.experienceYears} years`:G.description||"",status:G.overallStatus,questionnaireMarks:G.score||G.questionnaireMarks||0,rank:0,totalApplicantsAtLocation:0,submissionDate:G.createdAt,assignedUsers:[],progress:G.progressPercentage||0,isShortlisted:G.isShortlisted,companyName:G.companyName,source:G.source,existingDealer:G.existingDealer,royalEnfieldModel:G.royalEnfieldModel,description:G.description,pincode:G.pincode,locationType:G.locationType,ownRoyalEnfield:G.ownRoyalEnfield,address:G.address}));w(T);const I=Array.from(new Set(T.map(G=>G.preferredLocation))).filter(Boolean);_(G=>Array.from(new Set([...G,...I])));const B=Array.from(new Set(T.map(G=>G.state))).filter(Boolean);S(G=>Array.from(new Set([...G,...B])))}catch(M){console.error("Failed to fetch applications:",M),te.error("Failed to load non-opportunity requests")}finally{b(!1)}},Z=v;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl mb-2",children:"Non-opportunities (Lead Generation)"}),e.jsx("p",{className:"text-slate-600",children:"Interest submissions from regions where dealerships are currently not being offered. These leads received non-opportunity notification and are stored for future reference."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx("div",{className:"bg-white rounded-lg border border-slate-200 p-4","data-testid":"onboarding-non-opps-stat-total",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Total Leads"}),e.jsx("p",{className:"text-2xl text-slate-900 mt-1",children:(u==null?void 0:u.total)||v.length})]}),e.jsx("div",{className:"p-3 bg-blue-100 rounded-lg",children:e.jsx(ty,{className:"w-6 h-6 text-blue-600"})})]})}),e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-4","data-testid":"onboarding-non-opps-stat-locations",children:[e.jsx("p",{className:"text-slate-600",children:"Unique Locations"}),e.jsx("p",{className:"text-2xl text-slate-900 mt-1",children:((W=u==null?void 0:u.stats)==null?void 0:W.uniqueLocations)||0})]}),e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-4","data-testid":"onboarding-non-opps-stat-exp",children:[e.jsx("p",{className:"text-slate-600",children:"With Experience"}),e.jsx("p",{className:"text-2xl text-re-red mt-1",children:((U=u==null?void 0:u.stats)==null?void 0:U.withExperience)||0})]})]}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(at,{type:"text",placeholder:"Search by name, email, phone, or registration number...",value:s,onChange:M=>n(M.target.value),className:"pl-10","data-testid":"onboarding-non-opps-search-input"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(_u,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(se,{variant:"outline",className:Nt("w-full md:w-36 justify-start text-left font-normal h-10 px-3",!d&&"text-muted-foreground"),"data-testid":"onboarding-non-opps-from-date-trigger",children:[e.jsx(dr,{className:"mr-2 h-4 w-4 text-slate-400"}),d?Ka(new Date(d),"PP"):e.jsx("span",{className:"text-xs text-slate-500",children:"From Date"})]})}),e.jsx(Pu,{className:"w-auto p-0",align:"start",children:e.jsx(bf,{mode:"single",selected:d?new Date(d):void 0,onSelect:M=>m(M?M.toISOString().split("T")[0]:""),initialFocus:!0})})]}),e.jsx("span",{className:"text-slate-400",children:"to"}),e.jsxs(_u,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(se,{variant:"outline",className:Nt("w-full md:w-36 justify-start text-left font-normal h-10 px-3",!f&&"text-muted-foreground"),"data-testid":"onboarding-non-opps-to-date-trigger",children:[e.jsx(dr,{className:"mr-2 h-4 w-4 text-slate-400"}),f?Ka(new Date(f),"PP"):e.jsx("span",{className:"text-xs text-slate-500",children:"To Date"})]})}),e.jsx(Pu,{className:"w-auto p-0",align:"start",children:e.jsx(bf,{mode:"single",selected:f?new Date(f):void 0,onSelect:M=>p(M?M.toISOString().split("T")[0]:""),initialFocus:!0})})]})]}),e.jsxs(Dt,{value:r,onValueChange:a,children:[e.jsx(Et,{className:"w-full lg:w-48","data-testid":"onboarding-non-opps-location-select",children:e.jsx(Rt,{placeholder:"All Locations"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"all",children:"All Locations"}),R.map(M=>e.jsx(Me,{value:M,children:M},M))]})]}),e.jsx(se,{variant:"ghost",size:"sm",className:"text-slate-500 hover:text-slate-700 h-10 px-3",onClick:()=>{m(""),p(""),a("all"),o("all"),n("")},"data-testid":"onboarding-non-opps-clear-filters",children:"Clear Filters"}),e.jsxs(Dt,{value:i,onValueChange:o,children:[e.jsx(Et,{className:"w-full lg:w-48","data-testid":"onboarding-non-opps-state-select",children:e.jsx(Rt,{placeholder:"All States"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"all",children:"All States"}),C.map(M=>e.jsx(Me,{value:M,children:M},M))]})]}),e.jsx(se,{variant:"outline",size:"icon","data-testid":"onboarding-non-opps-export-btn",children:e.jsx(ji,{className:"w-4 h-4"})}),A.length>0&&e.jsxs(se,{className:"bg-re-red hover:bg-re-red-hover font-bold",onClick:D,disabled:q,children:[q?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(LI,{className:"w-4 h-4 mr-2"}),"Convert ",A.length," to Opportunity"]})]}),e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 overflow-hidden","data-testid":"onboarding-non-opps-table-container",children:[e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{className:"w-12",children:e.jsx(Ln,{checked:Z.length>0&&A.length===Z.length,onCheckedChange:P})}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-name",children:"Name"}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-phone",children:"Phone"}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-email",children:"Email"}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-loc",children:"Preferred Location"}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-address",children:"Main Address"}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-age",children:"Age"}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-exp",children:"Experience"}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-edu",children:"Education"}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-date",children:"Applied On"}),e.jsx(fe,{className:"text-right","data-testid":"onboarding-non-opps-th-actions",children:"Actions"})]})}),e.jsx(Os,{children:j?e.jsx(it,{children:e.jsxs(ue,{colSpan:11,className:"text-center py-20",children:[e.jsx(ns,{className:"w-8 h-8 mx-auto animate-spin text-re-red mb-2"}),e.jsx("p",{className:"text-slate-500 text-sm",children:"Loading applications..."})]})}):Z.length===0?e.jsx(it,{children:e.jsxs(ue,{colSpan:11,className:"text-center py-12 text-slate-500","data-testid":"onboarding-non-opps-empty-state",children:[e.jsx(ty,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{className:"text-lg mb-2",children:"No lead generation data found"}),e.jsx("p",{className:"text-sm",children:"Try adjusting your filters"})]})}):Z.map((M,z)=>e.jsxs(it,{"data-testid":`onboarding-non-opps-row-${z}`,className:A.includes(M.id)?"bg-red-50/50":"",children:[e.jsx(ue,{children:e.jsx(Ln,{checked:A.includes(M.id),onCheckedChange:()=>L(M.id)})}),e.jsx(ue,{children:e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900","data-testid":`onboarding-non-opps-name-${z}`,children:M.name}),e.jsx("p",{className:"text-slate-500 text-sm","data-testid":`onboarding-non-opps-id-${z}`,children:M.registrationNumber})]})}),e.jsx(ue,{className:"text-slate-900","data-testid":`onboarding-non-opps-phone-${z}`,children:M.phone}),e.jsx(ue,{className:"text-slate-600","data-testid":`onboarding-non-opps-email-${z}`,children:M.email}),e.jsx(ue,{children:e.jsxs("div",{"data-testid":`onboarding-non-opps-pref-loc-${z}`,children:[e.jsx("p",{className:"text-slate-900",children:M.preferredLocation}),e.jsx("p",{className:"text-slate-500 text-sm",children:M.state})]})}),e.jsx(ue,{className:"text-slate-600 max-w-xs truncate","data-testid":`onboarding-non-opps-address-${z}`,children:M.residentialAddress}),e.jsx(ue,{className:"text-slate-900","data-testid":`onboarding-non-opps-age-${z}`,children:M.age}),e.jsx(ue,{className:"text-slate-600","data-testid":`onboarding-non-opps-experience-${z}`,children:M.pastExperience}),e.jsx(ue,{className:"text-slate-900","data-testid":`onboarding-non-opps-education-${z}`,children:M.education}),e.jsx(ue,{className:"text-slate-600","data-testid":`onboarding-non-opps-date-${z}`,children:Yt(M.submissionDate)}),e.jsx(ue,{className:"text-right",children:e.jsx("div",{className:"flex justify-end gap-2",children:e.jsx(se,{variant:"outline",size:"sm",onClick:()=>t(M.id),"data-testid":`onboarding-non-opps-view-btn-${z}`,children:"View"})})})]},M.id))})]}),u&&u.totalPages>1&&e.jsx("div",{className:"py-4 border-t border-slate-200",children:e.jsx(fo,{children:e.jsxs(po,{children:[e.jsx(Sn,{children:e.jsx(xo,{onClick:()=>x(M=>Math.max(1,M-1)),className:h===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(u.totalPages)].map((M,z)=>{const T=z+1;return T===1||T===u.totalPages||T>=h-1&&T<=h+1?e.jsx(Sn,{children:e.jsx(Vi,{isActive:h===T,onClick:()=>x(T),className:"cursor-pointer",children:T})},T):T===h-2||T===h+2?e.jsx(Sn,{children:e.jsx(vo,{})},T):null}),e.jsx(Sn,{children:e.jsx(go,{onClick:()=>x(M=>Math.min(u.totalPages,M+1)),className:h===u.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})}function RU({application:t,slaStatus:s,isNonResponsive:n,isAdmin:r,onBack:a,onOpenWorknotes:i}){return e.jsxs(e.Fragment,{children:[n&&e.jsxs("div",{className:"bg-red-50 border border-red-200 p-4 rounded-2xl flex items-center justify-between animate-in fade-in slide-in-from-top-4 duration-500","data-testid":"onboarding-details-non-responsive-banner",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"bg-red-100 p-2 rounded-xl",children:e.jsx(fk,{className:"w-6 h-6 text-red-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-black text-red-900 tracking-tight leading-none uppercase",children:"Applicant Flagged Non-Responsive"}),e.jsx("p",{className:"text-red-700 text-[11px] font-bold uppercase tracking-widest mt-1 opacity-80",children:"Audit process is currently on hold due to missing cooperation"})]})]}),r&&e.jsx(se,{variant:"outline",size:"sm",className:"bg-white border-red-200 text-red-600 hover:bg-red-50 font-black text-[10px] uppercase tracking-widest hidden sm:block h-9","data-testid":"onboarding-details-review-audit-button",onClick:()=>{const o=document.querySelector('[value="worknotes"]');o==null||o.click()},children:"Review Audit"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(se,{variant:"outline",size:"icon",onClick:a,className:"shrink-0","data-testid":"onboarding-details-back-button",children:e.jsx(Jr,{className:"w-4 h-4"})}),e.jsxs("div",{className:"truncate",children:[e.jsx("h1",{className:"text-slate-900 truncate leading-tight","data-testid":"onboarding-details-application-name",children:t.name}),e.jsx("p",{className:"text-slate-600 truncate text-sm","data-testid":"onboarding-details-registration-number",children:t.registrationNumber}),s&&e.jsx("div",{className:"mt-1",children:e.jsx(kr,{status:s})})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsxs(se,{variant:"outline",className:"relative hover:bg-red-50 hover:border-red-300 hover:text-re-red-hover transition-all shadow-sm",onClick:i,"data-testid":"onboarding-details-view-work-notes",children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"View Work Notes"]})})]})]})}var EU=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_U=EU.reduce((t,s)=>{const n=Hu(`Primitive.${s}`),r=g.forwardRef((a,i)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),TU="Separator",DS="horizontal",PU=["horizontal","vertical"],u_=g.forwardRef((t,s)=>{const{decorative:n,orientation:r=DS,...a}=t,i=OU(r)?r:DS,d=n?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return e.jsx(_U.div,{"data-orientation":i,...d,...a,ref:s})});u_.displayName=TU;function OU(t){return PU.includes(t)}var LU=u_;function ec({className:t,orientation:s="horizontal",decorative:n=!0,...r}){return e.jsx(LU,{"data-slot":"separator-root",decorative:n,orientation:s,className:Nt("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...r})}function IU({application:t,canEditStatutory:s,isEditingStatutory:n,isSavingStatutory:r,statutoryForm:a,onEditFirmType:i,onEditStatutory:o,onCancelEditStatutory:d,onSaveStatutory:m,onStatutoryFormChange:f}){return e.jsxs(Le,{"data-testid":"onboarding-applicant-info-card",children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Applicant Information"})}),e.jsxs(Fe,{className:"p-4 sm:p-6 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-x-6 gap-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Lr,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Full Name"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-name",children:t.name})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ur,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Email"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-email",children:t.email})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(tb,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Phone"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-phone",children:t.phone})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Lr,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Age"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-age",children:t.age?`${t.age} years`:"N/A"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(zI,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Education"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-education",children:t.education||"N/A"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Vr,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Preferred Location"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-preferred-location",children:t.preferredLocation||"N/A"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Vr,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location Type"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-location-type",children:t.locationType||"N/A"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(so,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"text-slate-600 flex items-center justify-between group cursor-pointer",onClick:i,"data-testid":"onboarding-applicant-info-edit-firm-type",children:["Proposed Firm Type",e.jsx(ry,{className:"w-3 h-3 text-slate-300 group-hover:text-re-red transition-colors"})]}),e.jsx("p",{className:"text-slate-900 font-black text-re-red-hover tracking-tight leading-none mt-1","data-testid":"onboarding-applicant-info-firm-type",children:t.constitutionType||"Not Provided"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(S1,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Owns Bike"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-owns-bike",children:t.ownRoyalEnfield==="yes"?"Yes":"No"})]})]}),t.ownRoyalEnfield==="yes"&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(S1,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Bike Model"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-bike-model",children:t.royalEnfieldModel||"N/A"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Lr,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Existing Dealer"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-existing-dealer",children:t.existingDealer==="yes"?"Yes":"No"})]})]}),t.existingDealer==="yes"&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Lr,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Company Name"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-company-name",children:t.companyName||"N/A"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(rc,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Source"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-source",children:t.source||"N/A"})]})]}),t.questionnaireMarks!==void 0&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(rk,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Questionnaire Score"}),e.jsxs("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-score",children:[t.questionnaireMarks,"/100"]})]})]})]}),e.jsx(ec,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 mb-2",children:"Address"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-address",children:t.address||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 mb-2",children:"Pincode"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-pincode",children:t.pincode||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 mb-2",children:"Description"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-description",children:t.description||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 mb-2",children:"Past Experience"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-experience",children:t.pastExperience||"N/A"})]}),e.jsxs("div",{className:"pt-6 border-t mt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-sm font-black text-slate-900 uppercase tracking-widest flex items-center gap-2",children:[e.jsx(Wu,{className:"w-4 h-4 text-re-red"})," Statutory & Bank Information"]}),s&&!n&&e.jsxs(se,{variant:"ghost",size:"sm",onClick:o,className:"h-8 text-re-red hover:text-re-red-hover hover:bg-red-50 gap-1.5","data-testid":"onboarding-applicant-info-edit-statutory",children:[e.jsx(ry,{className:"w-3.5 h-3.5"}),"Edit Details"]})]}),n?e.jsxs("div",{className:"bg-slate-50/50 p-6 rounded-xl border-2 border-red-100 space-y-4","data-testid":"onboarding-applicant-info-statutory-edit-form",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Legal Entity Name"}),e.jsx(at,{value:a.accountHolderName,onChange:p=>f({...a,accountHolderName:p.target.value}),placeholder:"Enter Legal Entity Name",className:"bg-white border-slate-200","data-testid":"onboarding-applicant-info-input-legal-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{className:"text-[10px] uppercase font-bold text-slate-500",children:"PAN Number"}),e.jsx(at,{value:a.panNumber,onChange:p=>f({...a,panNumber:p.target.value.toUpperCase()}),placeholder:"10-digit PAN",maxLength:10,className:"bg-white border-slate-200 uppercase","data-testid":"onboarding-applicant-info-input-pan"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{className:"text-[10px] uppercase font-bold text-slate-500",children:"GST Number"}),e.jsx(at,{value:a.gstNumber,onChange:p=>f({...a,gstNumber:p.target.value.toUpperCase()}),placeholder:"15-digit GSTIN",maxLength:15,className:"bg-white border-slate-200 uppercase","data-testid":"onboarding-applicant-info-input-gst"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Registered Address"}),e.jsx(at,{value:a.registeredAddress,onChange:p=>f({...a,registeredAddress:p.target.value}),placeholder:"Enter Registered Office Address",className:"bg-white border-slate-200","data-testid":"onboarding-applicant-info-input-registered-address"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Bank Name"}),e.jsx(at,{value:a.bankName,onChange:p=>f({...a,bankName:p.target.value}),placeholder:"Enter Bank Name",className:"bg-white border-slate-200","data-testid":"onboarding-applicant-info-input-bank-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Account Number"}),e.jsx(at,{value:a.accountNumber,onChange:p=>f({...a,accountNumber:p.target.value}),placeholder:"Enter Account Number",className:"bg-white border-slate-200","data-testid":"onboarding-applicant-info-input-account-number"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{className:"text-[10px] uppercase font-bold text-slate-500",children:"IFSC Code"}),e.jsx(at,{value:a.ifscCode,onChange:p=>f({...a,ifscCode:p.target.value.toUpperCase()}),placeholder:"11-digit IFSC",maxLength:11,className:"bg-white border-slate-200 uppercase","data-testid":"onboarding-applicant-info-input-ifsc-code"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[e.jsx(se,{variant:"outline",size:"sm",onClick:d,disabled:r,"data-testid":"onboarding-applicant-info-statutory-cancel",children:"Cancel"}),e.jsx(se,{size:"sm",onClick:m,disabled:r,className:"bg-re-red hover:bg-re-red-hover","data-testid":"onboarding-applicant-info-statutory-save",children:r?e.jsx(ns,{className:"w-4 h-4 animate-spin"}):"Save Details"})]})]}):e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 bg-slate-50/50 p-4 rounded-xl border border-slate-100","data-testid":"onboarding-applicant-info-statutory-display",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold tracking-tight",children:"Legal Entity Name"}),e.jsx("p",{className:"text-xs font-semibold text-slate-900","data-testid":"onboarding-applicant-info-display-legal-name",children:t.accountHolderName||"Pending"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold tracking-tight",children:"PAN Number"}),e.jsx("p",{className:"text-xs font-semibold text-slate-900 uppercase","data-testid":"onboarding-applicant-info-display-pan",children:t.panNumber||"Pending"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold tracking-tight",children:"GST Number"}),e.jsx("p",{className:"text-xs font-semibold text-slate-900 uppercase","data-testid":"onboarding-applicant-info-display-gst",children:t.gstNumber||"Pending"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold tracking-tight",children:"Registered Address"}),e.jsx("p",{className:"text-xs font-semibold text-slate-900","data-testid":"onboarding-applicant-info-display-registered-address",children:t.registeredAddress||"Pending"})]}),e.jsxs("div",{className:"space-y-1","data-testid":"onboarding-applicant-info-display-bank-info",children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold tracking-tight",children:"Bank Details"}),e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:t.bankName||"N/A"}),e.jsxs("p",{className:"text-[10px] text-slate-600",children:["A/C: ",t.accountNumber||"N/A"]}),e.jsxs("p",{className:"text-[10px] text-slate-600",children:["IFSC: ",t.ifscCode||"N/A"]})]})]})]})]})]})}const MU=({application:t})=>{if(!t.questionnaireResponses||t.questionnaireResponses.length===0)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-slate-500 bg-slate-50 rounded-lg border border-dashed border-slate-300","data-testid":"onboarding-questionnaire-empty",children:[e.jsx(rc,{className:"w-12 h-12 mb-3 text-slate-300"}),e.jsx("h3",{className:"text-lg font-medium text-slate-700",children:"Response is Pending"}),e.jsx("p",{className:"text-sm",children:"The applicant has not submitted the questionnaire yet."})]});const s=[...t.questionnaireResponses].sort((r,a)=>{var i,o;return(((i=r.question)==null?void 0:i.order)||0)-(((o=a.question)==null?void 0:o.order)||0)}),n=t.score||t.questionnaireMarks||0;return e.jsxs("div",{className:"space-y-6","data-testid":"onboarding-questionnaire-view",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(rc,{className:"w-5 h-5 text-re-red"}),e.jsx("h3",{className:"text-slate-900",children:"Questionnaire Responses"})]}),n!==void 0&&e.jsxs(Ce,{className:"bg-re-red","data-testid":"onboarding-questionnaire-total-score",children:["Score: ",n,"/100"]})]}),e.jsx("div",{className:"space-y-6",children:s.map((r,a)=>{const i=r.question,o=(i==null?void 0:i.questionText)||"Unknown Question",d=r.responseValue||"No Answer",m=(i==null?void 0:i.sectionName)||"General",f=(i==null?void 0:i.questionOptions)||[],p=f.find(v=>v.optionText===d),h=p?p.score:0,x=Math.max(...f.map(v=>v.score||0),0),u=typeof d=="string"&&d.startsWith("data:"),N=u&&d.startsWith("data:image");return e.jsxs("div",{className:"border border-slate-200 rounded-lg p-5 hover:border-red-300 transition-colors","data-testid":`onboarding-questionnaire-item-${a}`,children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-red-50 flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-re-red",children:a+1})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ce,{variant:"outline",className:"text-slate-600 bg-slate-50","data-testid":`onboarding-questionnaire-item-section-${a}`,children:m}),f.length>0&&x>0&&e.jsxs(Ce,{className:h>0?"bg-green-600":"bg-slate-400","data-testid":`onboarding-questionnaire-item-score-${a}`,children:[h,"/",x]})]}),e.jsx("h4",{className:"text-slate-900 font-medium","data-testid":`onboarding-questionnaire-item-text-${a}`,children:o})]})]}),e.jsx("div",{className:"ml-11",children:N?e.jsx("div",{className:"mt-2","data-testid":`onboarding-questionnaire-item-image-${a}`,children:e.jsx("img",{src:d,alt:"Response Attachment",className:"max-w-full h-auto max-h-64 rounded border p-1 object-contain"})}):u?e.jsx("a",{href:d,download:`upload_${a}.pdf`,className:"text-blue-600 underline text-sm break-all","data-testid":`onboarding-questionnaire-item-download-${a}`,children:"Download Attachment"}):e.jsx("div",{className:"text-slate-600 leading-relaxed break-words whitespace-pre-wrap","data-testid":`onboarding-questionnaire-item-answer-${a}`,children:r.attachmentUrl?e.jsx("a",{href:r.attachmentUrl,target:"_blank",rel:"noreferrer",className:"text-blue-600 underline","data-testid":`onboarding-questionnaire-item-attachment-${a}`,children:"View Attachment"}):d})})]},r.id)})})]})},FU=Ky("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function di({className:t,variant:s,...n}){return e.jsx("div",{"data-slot":"alert",role:"alert",className:Nt(FU({variant:s}),t),...n})}function _i({className:t,...s}){return e.jsx("div",{"data-slot":"alert-title",className:Nt("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...s})}function ui({className:t,...s}){return e.jsx("div",{"data-slot":"alert-description",className:Nt("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...s})}var BU={};function $U(t){const{application:s,activeTab:n,setActiveTab:r,processStages:a,documents:i,interviews:o,expandedBranches:d,setExpandedBranches:m,setSelectedStage:f,setShowDocumentsModal:p,setShowUploadForm:h,handleRetriggerEvaluators:x,handleRescheduleInterview:u,setSelectedEvaluationForView:N,setShowFeedbackDetailsModal:v,renderFddAuditContent:w,eorProgress:j,eorData:b,eorChecklist:C,setUploadDocType:S,isAdmin:R,fetchApplication:_,fetchEorData:A,deposits:E,getDeposit:q,paymentConfigs:O,setPreviewDoc:D,setShowPreviewModal:P,auditLoading:L,auditLogs:$,auditLogActionBadgeClass:Y}=t,Z=U=>String(U||"").trim().toLowerCase().replace(/[_\s-]+/g," "),W=(U,M)=>{var I,B,G;const z=[(I=U==null?void 0:U.user)==null?void 0:I.role,(B=U==null?void 0:U.user)==null?void 0:B.roleCode,(G=U==null?void 0:U.metadata)==null?void 0:G.role].map(Z),T=M.map(Z);return z.some(K=>T.includes(K))};return e.jsx(Le,{"data-testid":"onboarding-details-tabs-container",children:e.jsxs(Bn,{value:n,onValueChange:r,children:[e.jsx(Qe,{className:"pb-4 px-4 sm:px-6",children:e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim -mx-4 px-4 sm:-mx-6 sm:px-6",children:e.jsxs($n,{className:"w-max min-w-full justify-start h-11 bg-slate-100/80 p-1","data-testid":"onboarding-tabs-list",children:[e.jsx(Wt,{value:"questionnaire",className:"min-w-[120px]","data-testid":"onboarding-tab-trigger-questionnaire",children:"Questionnaire"}),e.jsx(Wt,{value:"progress",className:"min-w-[80px]","data-testid":"onboarding-tab-trigger-progress",children:"Progress"}),e.jsx(Wt,{value:"documents",className:"min-w-[100px]","data-testid":"onboarding-tab-trigger-documents",children:"Documents"}),e.jsx(Wt,{value:"interviews",className:"min-w-[100px]","data-testid":"onboarding-tab-trigger-interviews",children:"Interviews"}),e.jsx(Wt,{value:"fdd",className:"min-w-[120px]","data-testid":"onboarding-tab-trigger-fdd",children:"FDD Audit"}),e.jsx(Wt,{value:"eor",className:"min-w-[120px]","data-testid":"onboarding-tab-trigger-eor",children:"EOR Checklist"}),e.jsx(Wt,{value:"payments",className:"min-w-[100px]","data-testid":"onboarding-tab-trigger-payments",children:"Payments"}),e.jsx(Wt,{value:"audit",className:"min-w-[100px]","data-testid":"onboarding-tab-trigger-audit",children:"Audit Trail"})]})})}),e.jsxs(Fe,{children:[e.jsx(Ut,{value:"questionnaire",className:"space-y-6","data-testid":"onboarding-tab-content-questionnaire",children:e.jsx(MU,{application:s})}),e.jsxs(Ut,{value:"progress",className:"space-y-6","data-testid":"onboarding-tab-content-progress",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-slate-900",children:"Application Journey"}),e.jsxs(Ce,{className:Sq(s.status),"data-testid":"onboarding-progress-percentage-badge",children:[s.progress,"% Complete"]})]}),e.jsx(dc,{value:s.progress,className:"h-3 mb-6 bg-status-progress-soft",indicatorClassName:gl(s.status),"data-testid":"onboarding-progress-bar"})]}),e.jsx("div",{className:"relative status-progress-ui","data-testid":"onboarding-progress-stages-container",children:(()=>{const U={1:["DD-ZM","RBM"],2:["DD Lead","ZBH"],3:["NBH","DD Head"]},M={LOI_APPROVAL:["DD Head","NBH"],LOA_APPROVAL:["DD Head","NBH"]},z=I=>(s.participants||[]).filter(G=>{var H,X,J,ae,le,xe,ce,ve,Pe,et,kt,vt;return((H=G.metadata)==null?void 0:H.stageCode)===I||((J=(X=G.metadata)==null?void 0:X.allAssignments)==null?void 0:J.includes(I))||typeof I=="number"&&(((ae=G.metadata)==null?void 0:ae.interviewLevel)===I||((le=G.metadata)==null?void 0:le.interviewLevel)===String(I)||((ce=(xe=G.metadata)==null?void 0:xe.allAssignments)==null?void 0:ce.includes(I))||((Pe=(ve=G.metadata)==null?void 0:ve.allAssignments)==null?void 0:Pe.includes(String(I))))||typeof I=="string"&&!isNaN(Number(I))&&(((et=G.metadata)==null?void 0:et.interviewLevel)===Number(I)||((vt=(kt=G.metadata)==null?void 0:kt.allAssignments)==null?void 0:vt.includes(Number(I))))?!0:typeof I=="number"?W(G,U[I]||[]):W(G,M[I]||[])}).map(G=>{var X,J,ae,le,xe;const K=typeof I=="number"?`INTERVIEW_LEVEL_${I}`:I,H=(s.stageApprovals||[]).find(ce=>ce.stageCode===K&&String(ce.actorUserId)===String(G.userId));return{name:((X=G.user)==null?void 0:X.name)||((J=G.user)==null?void 0:J.fullName)||"Unknown",role:((ae=G.user)==null?void 0:ae.role)||((le=G.user)==null?void 0:le.roleCode)||((xe=G.metadata)==null?void 0:xe.role)||"Reviewer",status:H?H.decision==="Approved"?"approved":"rejected":"pending"}}),T=(I,B)=>{const K={"1st Level Interview":1,"2nd Level Interview":2,"3rd Level Interview":3,"LOI Approval":"LOI_APPROVAL",LOA:"LOA_APPROVAL"}[I];if(!K)return null;const H=z(K);return H.length===0?null:e.jsx("div",{className:"flex flex-wrap gap-2 mt-3","data-testid":`onboarding-stage-approvers-${B}`,children:H.map((X,J)=>e.jsxs("div",{className:"group relative flex items-center gap-1.5 bg-slate-50 border border-slate-200 rounded-full pl-1 pr-2.5 py-0.5 transition-all hover:bg-white hover:shadow-sm","data-testid":`onboarding-stage-approver-${B}-${J}`,children:[e.jsx("div",{className:Nt("w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold text-white",X.status==="approved"?"bg-green-500":X.status==="rejected"?"bg-red-500":"bg-slate-300"),children:X.name.split(" ").map(ae=>ae[0]).join("").substring(0,2).toUpperCase()}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-700 leading-none",children:X.name}),e.jsx("span",{className:"text-[8px] text-slate-500 leading-none mt-0.5",children:X.role})]}),e.jsx("div",{className:Nt("absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full border border-white",X.status==="approved"?"bg-green-500":X.status==="rejected"?"bg-red-500":"bg-status-progress"),"data-testid":`onboarding-stage-approver-status-dot-${B}-${J}`}),e.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-slate-900 text-white text-[10px] rounded opacity-0 group-hover:opacity-100 pointer-events-none transition-opacity whitespace-nowrap z-50",children:[X.role,": ",X.status.toUpperCase()]})]},J))})};return a.map((I,B)=>e.jsxs("div",{"data-testid":`onboarding-progress-stage-${B}`,children:[e.jsxs("div",{className:"flex gap-4 pb-8",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center border-2 z-10 relative ${I.status==="completed"?"bg-green-500 border-green-500 text-white shadow-md":I.status==="active"?I.isLocked?"bg-slate-400 border-slate-400 text-white":"bg-status-workflow-active border-status-workflow-active text-white animate-pulse-subtle":"bg-white border-slate-300 text-slate-400 shadow-none"}`,"data-testid":`onboarding-progress-stage-icon-${B}`,children:I.isParallel?e.jsx(sy,{className:"w-5 h-5"}):I.isLocked?e.jsxs("div",{className:"group relative",children:[e.jsx(ny,{className:"w-5 h-5 text-white cursor-help"}),e.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-3 py-1.5 bg-slate-900 text-white text-[10px] rounded shadow-xl opacity-0 group-hover:opacity-100 pointer-events-none transition-all duration-200 whitespace-nowrap z-[100] border border-slate-700",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"font-bold text-status-progress flex items-center gap-1",children:[e.jsx(sn,{className:"w-3 h-3"})," Stage Locked"]}),e.jsx("span",{children:I.lockMessage})]}),e.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 border-8 border-transparent border-t-slate-900"})]})]}):e.jsx(e.Fragment,{children:I.status==="completed"?e.jsx(Zn,{className:"w-6 h-6"}):I.status==="active"?e.jsx(vn,{className:"w-5 h-5 text-white"}):e.jsx("div",{className:"w-3 h-3 bg-slate-300 rounded-full"})})}),B<a.length-1&&!I.isParallel&&e.jsx("div",{className:`absolute top-10 left-1/2 -translate-x-1/2 w-0.5 h-full z-0 ${I.status==="completed"?"bg-green-500/30":"bg-slate-200"}`,"data-testid":`onboarding-progress-stage-connector-${B}`})]}),e.jsxs("div",{className:"flex-1 pt-1",children:[e.jsx("p",{className:Nt("font-bold transition-colors",I.status==="completed"?"text-green-700":I.status==="active"?"text-status-progress-muted":"text-slate-900"),"data-testid":`onboarding-progress-stage-name-${B}`,children:I.name}),I.description&&e.jsx("p",{className:"text-slate-600 text-sm mt-0.5 leading-relaxed","data-testid":`onboarding-progress-stage-desc-${B}`,children:I.description}),T(I.name,B),I.evaluators&&I.evaluators.length>0&&!["LOI Approval","LOA","1st Level Interview","2nd Level Interview","3rd Level Interview"].includes(I.name)&&e.jsxs("p",{className:"text-status-progress text-xs mt-1.5 flex items-center gap-1 bg-status-progress-soft w-fit px-2 py-0.5 rounded border border-status-progress","data-testid":`onboarding-progress-stage-evaluators-${B}`,children:[e.jsx(Lr,{className:"w-3 h-3"}),"Evaluators: ",I.evaluators.join(" + ")]}),(()=>{var xe;const G={3:2,4:2,5:2,6:2,8:2,12:2},K=Number(I.id),H=G[K],J={3:1,4:1,5:2,6:3,8:"LOI_APPROVAL",12:"LOA_APPROVAL"}[K],ae=J?z(J).length:((xe=I.evaluators)==null?void 0:xe.length)||0,le=K===3?I.status==="completed":I.status!=="pending";return H&&ae<H&&s.status!=="Rejected"&&le?e.jsx("div",{className:"mt-2","data-testid":`onboarding-progress-stage-warning-${B}`,children:e.jsxs(di,{variant:"destructive",className:"py-2 px-3 border-red-200 bg-red-50 text-red-800",children:[e.jsx(sn,{className:"h-4 w-4 text-re-red"}),e.jsx(_i,{className:"text-xs font-semibold",children:"Missing Evaluators"}),e.jsxs(ui,{className:"text-xs",children:[ae===0?"Respective role users were not found for this location.":`Some roles (${ae}/${H}) are missing for this location.`,e.jsxs(se,{variant:"link",size:"sm",className:"h-auto p-0 ml-1 text-xs text-re-red-hover underline",onClick:x,"data-testid":`onboarding-progress-stage-retrigger-${B}`,children:[e.jsx(xr,{className:"w-3 h-3 mr-1"}),"Re-trigger Assignment"]})]})]})}):null})(),(()=>{const G=i.filter(H=>{var X;return H.stage===I.name||!H.stage&&((X=H.documentType)==null?void 0:X.toLowerCase().includes(I.name.toLowerCase().split(" ")[0]))}).length,K=I.status==="active"&&!I.isLocked;return G===0&&!K?null:e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("button",{onClick:()=>{f(I.name),p(!0),G===0&&K&&h(!0)},className:"text-xs font-semibold text-blue-600 hover:text-blue-800 flex items-center gap-1.5 px-3 py-1 rounded-full bg-blue-50 border border-blue-100 hover:bg-blue-100 transition-all shadow-sm","data-testid":`onboarding-progress-stage-docs-${B}`,children:[e.jsx(Ns,{className:"w-3.5 h-3.5"}),G>0?`${G} Documents`:"Upload"]})})})(),e.jsxs("p",{className:"text-slate-500 mt-1 text-xs","data-testid":`onboarding-progress-stage-status-text-${B}`,children:[I.status==="completed"&&I.date&&`Completed: ${Yt(I.date)}`,I.status==="active"&&"In Progress",I.status==="pending"&&"Pending"]})]})]}),I.isParallel&&I.branches&&e.jsxs("div",{className:"ml-5 mb-8","data-testid":`onboarding-progress-parallel-branches-${B}`,children:[I.branches.map((G,K)=>{const H=G.name.toLowerCase().replace(/\s+/g,"-"),X=d[H],J=G.color==="blue"?"blue":"green";return e.jsxs("div",{className:"mb-6 last:mb-0",children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsxs("button",{onClick:()=>m(ae=>({...ae,[H]:!ae[H]})),className:`flex-1 flex items-center gap-3 p-4 rounded-lg border-2 transition-all hover:shadow-md ${J==="blue"?"border-blue-300 bg-blue-50 hover:bg-blue-100":"border-green-300 bg-green-50 hover:bg-green-100"}`,"data-testid":`onboarding-progress-branch-trigger-${H}`,children:[X?e.jsx(Aa,{className:`w-5 h-5 ${J==="blue"?"text-blue-600":"text-green-600"}`}):e.jsx(bi,{className:`w-5 h-5 ${J==="blue"?"text-blue-600":"text-green-600"}`}),e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center ${J==="blue"?"bg-blue-200":"bg-green-200"}`,children:e.jsx(sy,{className:`w-4 h-4 ${J==="blue"?"text-blue-700":"text-green-700"}`})}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsx("p",{className:`${J==="blue"?"text-blue-900":"text-green-900"} font-semibold tracking-tight`,children:G.name}),e.jsxs("p",{className:`text-[10px] uppercase font-bold tracking-wider ${J==="blue"?"text-blue-500":"text-green-500"}`,children:[G.stages.length," SUB-STEPS"]})]})]})}),X&&e.jsx("div",{className:"mt-4 ml-8 border-l-2 border-slate-200 pl-6 space-y-6","data-testid":`onboarding-progress-branch-content-${H}`,children:G.stages.map((ae,le)=>e.jsx("div",{className:"relative",children:e.jsx("div",{className:"flex gap-4 text-xs","data-testid":`onboarding-progress-branch-stage-${H}-${le}`,children:(()=>{const xe=i.filter(ve=>{var Pe;return((Pe=ve.documentType)==null?void 0:Pe.toLowerCase().includes(ae.name.toLowerCase().split(" ")[0]))||ve.stage===ae.name}),ce=ae.status==="completed"||xe.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center border-2 ${ce?`${J==="blue"?"bg-blue-500 border-blue-500":"bg-green-500 border-green-500"}`:ae.status==="active"?"bg-status-workflow-active border-status-workflow-active text-white shadow-sm":"bg-white border-slate-300 text-slate-400"}`,"data-testid":`onboarding-progress-branch-stage-icon-${H}-${le}`,children:ce?e.jsx(Hn,{className:"w-4 h-4 text-white",strokeWidth:3}):ae.status==="active"?e.jsx(vn,{className:"w-4 h-4 text-white"}):e.jsx("div",{className:"w-2 h-2 bg-slate-300 rounded-full"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold text-slate-800","data-testid":`onboarding-progress-branch-stage-name-${H}-${le}`,children:ae.name}),ae.description&&e.jsx("p",{className:"text-slate-500 text-xs mt-0.5",children:ae.description}),(()=>{const ve=ae.status==="active";return xe.length===0&&!ve?null:e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("button",{onClick:()=>{f(ae.name),p(!0),xe.length===0&&ve&&h(!0)},className:Nt("text-[10px] font-medium flex items-center gap-1 transition-colors",J==="blue"?"text-blue-600 hover:text-blue-800":"text-green-600 hover:text-green-800"),"data-testid":`onboarding-progress-branch-stage-docs-${H}-${le}`,children:[e.jsx(Ns,{className:"w-2.5 h-2.5"}),xe.length>0?`${xe.length} Docs`:"Upload"]})})})(),e.jsx("p",{className:"text-slate-400 text-[10px] mt-1","data-testid":`onboarding-progress-branch-stage-status-${H}-${le}`,children:ce&&ae.date?`Done: ${Yt(ae.date)}`:ce&&xe.length>0?`Uploaded: ${Yt(xe[0].updatedAt||xe[0].createdAt)}`:"Pending"})]})]})})()})},ae.id))})]},K)}),e.jsx("div",{className:"h-8 w-0.5 bg-slate-300 ml-5 opacity-50"})]})]},I.id))})()})]}),e.jsxs(Ut,{value:"documents",className:"space-y-4","data-testid":"onboarding-tab-content-documents",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-slate-900",children:"Uploaded Documents"}),e.jsxs(se,{size:"sm",className:"bg-re-red hover:bg-re-red-hover","data-testid":"onboarding-documents-upload-tab-button",onClick:()=>{f(null),p(!0),h(!0)},children:[e.jsx(or,{className:"w-4 h-4 mr-2"}),"Upload Document"]})]}),e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim",children:e.jsxs(Ts,{"data-testid":"onboarding-documents-table",children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{className:"min-w-[200px]",children:"File Name"}),e.jsx(fe,{className:"min-w-[120px]",children:"Type"}),e.jsx(fe,{className:"min-w-[120px]",children:"Upload Date"}),e.jsx(fe,{className:"min-w-[150px]",children:"Uploader"}),e.jsx(fe,{className:"text-right min-w-[100px]",children:"Actions"})]})}),e.jsx(Os,{children:i.length===0?e.jsx(it,{"data-testid":"onboarding-documents-empty-row",children:e.jsx(ue,{colSpan:5,className:"text-center py-8 text-slate-500",children:"No documents uploaded yet"})}):i.map((U,M)=>{var z;return e.jsxs(it,{"data-testid":`onboarding-document-row-${M}`,children:[e.jsxs(ue,{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"truncate max-w-[150px] md:max-w-[300px]","data-testid":`onboarding-document-name-${M}`,children:U.fileName})]}),e.jsx(ue,{"data-testid":`onboarding-document-type-${M}`,children:U.documentType}),e.jsx(ue,{children:Yt(U.createdAt)}),e.jsx(ue,{"data-testid":`onboarding-document-uploader-${M}`,children:((z=U.uploader)==null?void 0:z.fullName)||(U.uploadedBy?"Unknown User":"Applicant")}),e.jsx(ue,{children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(se,{size:"sm",variant:"outline","data-testid":`onboarding-document-preview-${M}`,onClick:()=>{D(U),P(!0)},children:e.jsx(yn,{className:"w-3 h-3 text-slate-500"})}),e.jsx(se,{size:"sm",variant:"outline","data-testid":`onboarding-document-download-${M}`,onClick:()=>{const T=BU.NEXT_PUBLIC_API_URL||"http://localhost:5000";window.open(`${T}/${U.filePath}`,"_blank")},children:e.jsx(ji,{className:"w-3 h-3 text-slate-500"})})]})})]},U.id)})})]})})]}),e.jsxs(Ut,{value:"interviews",className:"space-y-6","data-testid":"onboarding-tab-content-interviews",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900 mb-4",children:"Scheduled Interviews"}),e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim",children:e.jsxs(Ts,{"data-testid":"onboarding-interviews-scheduled-table",children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{className:"min-w-[100px]",children:"Level"}),e.jsx(fe,{className:"min-w-[180px]",children:"Date & Time"}),e.jsx(fe,{className:"min-w-[100px]",children:"Type"}),e.jsx(fe,{className:"min-w-[200px]",children:"Location/Link"}),e.jsx(fe,{className:"min-w-[120px]",children:"Status"}),e.jsx(fe,{className:"min-w-[150px]",children:"Scheduled By"}),e.jsx(fe,{className:"text-right",children:"Actions"})]})}),e.jsx(Os,{children:!o||o.length===0?e.jsx(it,{"data-testid":"onboarding-interviews-empty-row",children:e.jsx(ue,{colSpan:7,className:"text-center py-8 text-slate-500",children:"No interviews scheduled yet"})}):(Array.isArray(o)?o:[]).map((U,M)=>{var z,T;return e.jsxs(it,{"data-testid":`onboarding-interview-row-${M}`,children:[e.jsxs(ue,{className:"font-medium",children:["Level ",U.level]}),e.jsx(ue,{children:U.scheduleDate?new Date(U.scheduleDate).toLocaleString():"N/A"}),e.jsx(ue,{className:"capitalize",children:U.interviewType}),e.jsx(ue,{children:(z=U.interviewType)!=null&&z.toLowerCase().includes("virtual")?e.jsx("a",{href:U.linkOrLocation,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline","data-testid":`onboarding-interview-link-${M}`,children:"Join Meeting"}):e.jsx("span",{"data-testid":`onboarding-interview-location-${M}`,children:U.linkOrLocation})}),e.jsx(ue,{children:e.jsx(Ce,{variant:U.status==="Completed"?"default":"secondary","data-testid":`onboarding-interview-status-${M}`,children:U.status})}),e.jsx(ue,{children:((T=U.scheduler)==null?void 0:T.fullName)||U.scheduledBy||"N/A"}),e.jsx(ue,{className:"text-right",children:(U.status==="Scheduled"||U.status==="scheduled")&&e.jsx(se,{variant:"ghost",size:"sm",className:"text-primary-600 hover:text-primary-700 hover:bg-primary-50 h-8 px-2","data-testid":`onboarding-interview-reschedule-${M}`,onClick:()=>u(U),children:"Reschedule"})})]},U.id)})})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900 mb-4",children:"Interview Feedback"}),!o||o.length===0?e.jsx("p",{className:"text-slate-500 italic","data-testid":"onboarding-interviews-no-feedback",children:"No interviews scheduled."}):(Array.isArray(o)?o:[]).map((U,M)=>e.jsxs("div",{className:"mb-6 border p-4 rounded-lg bg-slate-50/50","data-testid":`onboarding-interview-feedback-block-${M}`,children:[e.jsxs("h4",{className:"font-semibold text-slate-800 mb-2",children:["Level ",U.level," Interview",e.jsxs("span",{className:"font-normal text-slate-500 text-sm ml-2",children:["(",Yt(U.scheduleDate)," - ",U.interviewType,")"]})]}),U.evaluations&&U.evaluations.length>0?e.jsxs(Ts,{"data-testid":`onboarding-interview-evaluations-table-${M}`,children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Interviewer"}),e.jsx(fe,{children:"Role"}),e.jsx(fe,{children:U.level===1?"Score (KT Matrix)":"Overall Score"}),e.jsx(fe,{children:"Remarks"}),e.jsx(fe,{children:"Recommendation"})]})}),e.jsx(Os,{children:U.evaluations.map((z,T)=>{var I,B,G;return e.jsxs(it,{"data-testid":`onboarding-interview-evaluation-row-${M}-${T}`,children:[e.jsx(ue,{className:"font-medium",children:(I=z.evaluator)==null?void 0:I.fullName}),e.jsx(ue,{children:((G=(B=z.evaluator)==null?void 0:B.role)==null?void 0:G.roleName)||"N/A"}),e.jsx(ue,{children:z.ktMatrixScore?e.jsxs(Ce,{variant:U.level===1?Number(z.ktMatrixScore)>=50?"outline":"destructive":Number(z.ktMatrixScore)>=5?"outline":"destructive","data-testid":`onboarding-interview-evaluation-score-${M}-${T}`,children:[z.ktMatrixScore,"/",U.level===1?"100":"10"]}):"N/A"}),e.jsx(ue,{className:"max-w-xs truncate",title:z.remarks||z.qualitativeFeedback,children:z.remarks?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"font-medium text-slate-800",children:z.remarks}),z.feedbackDetails&&z.feedbackDetails.length>0&&e.jsx(se,{variant:"link",className:"p-0 h-auto font-normal text-blue-600 text-xs w-fit","data-testid":`onboarding-interview-evaluation-details-btn-${M}-${T}`,onClick:()=>{N({...z,interview:U}),v(!0)},children:"View Detailed Feedback"})]}):z.feedbackDetails&&z.feedbackDetails.length>0?e.jsx(se,{variant:"link",className:"p-0 h-auto font-normal text-blue-600","data-testid":`onboarding-interview-evaluation-details-btn-${M}-${T}`,onClick:()=>{N({...z,interview:U}),v(!0)},children:"View Detailed Feedback"}):z.qualitativeFeedback||"-"}),e.jsx(ue,{"data-testid":`onboarding-interview-evaluation-rec-${M}-${T}`,children:z.recommendation||"-"})]},z.id)})})]}):e.jsx("p",{className:"text-sm text-slate-500 italic pl-2",children:"No feedback recorded yet."})]},U.id))]}),["Level 2 Approved","Level 3 Interview Pending","Approved","Onboarded"].includes(s.status)&&e.jsxs("div",{"data-testid":"onboarding-interviews-summary-l2",children:[e.jsx("h3",{className:"text-slate-900 mb-4",children:"Level 2 Interview Summary"}),e.jsxs("div",{className:"p-4 bg-slate-50 rounded-lg",children:[e.jsx("p",{className:"text-slate-600",children:"Decision: Approved by both ZBH and DD Lead"}),e.jsx("p",{className:"text-slate-600 mt-2",children:"Overall Assessment: Strong candidate with excellent business plan"})]})]})]}),e.jsx(Ut,{value:"fdd",className:"space-y-6","data-testid":"onboarding-tab-content-fdd",children:w()}),e.jsxs(Ut,{value:"eor",className:"space-y-4 status-progress-ui","data-testid":"onboarding-tab-content-eor",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-slate-900",children:"Essential Operating Requirements"}),e.jsxs(Ce,{className:Aq(j),"data-testid":"onboarding-eor-progress-badge",children:[Math.round(j),"% Complete"]})]}),e.jsx(dc,{value:j,className:"h-3 mb-6 bg-status-progress-soft",indicatorClassName:Cq(j),"data-testid":"onboarding-eor-progress-bar"}),e.jsx("div",{className:"space-y-3","data-testid":"onboarding-eor-checklist",children:((b==null?void 0:b.items)||C).map((U,M)=>{const z=U.description||U.item,T=!!U.proofDocument;return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-slate-50 rounded-xl transition-all border border-transparent hover:border-slate-200 group","data-testid":`onboarding-eor-item-${M}`,children:[e.jsx(Ln,{checked:U.isCompliant||U.completed,className:"pointer-events-none shrink-0","data-testid":`onboarding-eor-checkbox-${M}`}),e.jsxs("div",{className:"flex flex-col flex-1 min-w-0 cursor-pointer","data-testid":`onboarding-eor-clickable-${M}`,onClick:()=>{f(`EOR: ${z}`),S(z),p(!0),h(!T)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:U.isCompliant||U.completed?"text-slate-900 font-bold":"text-slate-600 font-medium",children:z}),T&&!U.isCompliant&&e.jsx(Ce,{variant:"outline",className:"text-[10px] h-4 px-1.5 bg-red-50 text-re-red border-red-200 uppercase tracking-wider font-bold",children:"Needs Verification"})]}),T&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-blue-600 font-semibold mt-1",children:[e.jsx(Ns,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"truncate",children:U.proofDocument.fileName})]}),!T&&e.jsx("span",{className:"text-[10px] text-slate-400 mt-1 uppercase tracking-tighter",children:"Click to upload proof"})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[T&&!U.isCompliant&&R&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(se,{size:"sm",className:"h-8 px-3 bg-green-600 hover:bg-green-700 text-white font-bold rounded-lg shadow-sm","data-testid":`onboarding-eor-verify-btn-${M}`,onClick:async()=>{await(await Qo(async()=>{const{eorService:I}=await Promise.resolve().then(()=>Vg);return{eorService:I}},void 0)).eorService.updateItem(b.id,{...U,isCompliant:!0}),A(),te.success(`${z} verified!`)},children:"Verify"}),e.jsx(se,{size:"sm",variant:"outline",className:"h-8 px-3 border-red-200 text-red-600 hover:bg-red-50 font-bold rounded-lg","data-testid":`onboarding-eor-reject-btn-${M}`,onClick:async()=>{await(await Qo(async()=>{const{eorService:I}=await Promise.resolve().then(()=>Vg);return{eorService:I}},void 0)).eorService.updateItem(b.id,{...U,isCompliant:!1,proofDocumentId:null}),A(),te.success(`${z} rejected.`)},children:"Reject"})]}),(U.isCompliant||U.completed)&&e.jsx("div",{className:"bg-green-100 p-1.5 rounded-full","data-testid":`onboarding-eor-done-icon-${M}`,children:e.jsx(un,{className:"w-4 h-4 text-green-600"})}),!T&&e.jsx("div",{className:"p-2 text-slate-300 group-hover:text-re-red transition-colors","data-testid":`onboarding-eor-upload-hint-${M}`,children:e.jsx(or,{className:"w-4 h-4"})})]})]},U.id)})}),j===100&&R&&(s.status==="EOR In Progress"||s.status==="LOA Pending")&&e.jsx("div",{className:"mt-8 p-6 bg-green-50 rounded-xl border-2 border-green-200 animate-in fade-in slide-in-from-bottom-4 duration-500","data-testid":"onboarding-eor-complete-banner",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-green-100 flex items-center justify-center shrink-0",children:e.jsx(no,{className:"w-7 h-7 text-green-600"})}),e.jsxs("div",{className:"flex-1 text-center sm:text-left",children:[e.jsx("h4",{className:"text-green-900 font-bold text-lg",children:"EOR Checklist Complete"}),e.jsx("p",{className:"text-green-700 text-sm",children:"All 12 mandatory requirements have been verified. You can now complete the audit and move to final inauguration."})]}),e.jsx(se,{className:"w-full sm:w-auto bg-green-600 hover:bg-green-700 text-white font-bold h-12 px-8 rounded-xl shadow-lg shadow-green-600/20 transition-all hover:scale-[1.02] active:scale-[0.98]","data-testid":"onboarding-eor-submit-audit",onClick:async()=>{try{const U=b==null?void 0:b.id;if(!U)throw new Error("Checklist ID not found");await(await Qo(async()=>{const{eorService:M}=await Promise.resolve().then(()=>Vg);return{eorService:M}},void 0)).eorService.submitAudit(U,{status:"Completed",overallComments:"EOR Checklist verified and audit completed."}),te.success("EOR Audit completed successfully!"),_(),A()}catch(U){te.error(U.message||"Failed to complete EOR audit")}},children:"Complete Audit & Proceed"})]})})]}),e.jsxs(Ut,{value:"payments",className:"space-y-6","data-testid":"onboarding-tab-content-payments",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-900",children:"Security Deposits"}),e.jsxs(Ce,{variant:"outline",className:"bg-slate-50 text-slate-500 border-slate-200","data-testid":"onboarding-payments-count-badge",children:[E.length," Payment Record(s)"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(()=>{const U=q("SECURITY_DEPOSIT"),M=O.SECURITY_DEPOSIT,z=(M==null?void 0:M.amount)||5e5;return e.jsx(Le,{className:Nt("border-l-4",(U==null?void 0:U.status)==="Verified"?"border-l-green-500":(U==null?void 0:U.status)==="Rejected"?"border-l-red-500":"border-l-re-red"),"data-testid":"onboarding-payment-card-security",children:e.jsxs(Fe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-red-50 flex items-center justify-center text-re-red",children:e.jsx(rc,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-semibold text-slate-700",children:"Security Deposit"})]}),e.jsx(Ce,{className:Nt((U==null?void 0:U.status)==="Verified"?"bg-green-100 text-green-700 hover:bg-green-100":(U==null?void 0:U.status)==="Rejected"?"bg-red-100 text-red-700 hover:bg-red-100":"bg-red-50 text-re-red-hover hover:bg-red-50"),"data-testid":"onboarding-payment-status-security",children:(U==null?void 0:U.status)||"Awaiting"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-baseline",children:[e.jsx("span",{className:"text-xs text-slate-500 uppercase font-bold tracking-wider",children:"Amount Received"}),e.jsxs("span",{className:"text-lg font-bold text-slate-900","data-testid":"onboarding-payment-amount-security",children:["₹",Number((U==null?void 0:U.amount)||0).toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-baseline border-t border-slate-100 pt-2",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Expected Total"}),e.jsxs("span",{className:"text-sm font-medium text-slate-600",children:["₹",z.toLocaleString()]})]}),(U==null?void 0:U.paymentReference)&&e.jsxs("div",{className:"bg-slate-50 p-2 rounded text-xs font-mono text-slate-600 flex justify-between items-center","data-testid":"onboarding-payment-ref-security",children:[e.jsxs("span",{children:["Ref: ",U.paymentReference]}),U.verifiedAt&&e.jsx("span",{children:Yt(U.verifiedAt)})]}),(U==null?void 0:U.remarks)&&e.jsxs("div",{className:"text-[11px] text-slate-500 bg-red-50/50 p-2 rounded border border-red-100 italic","data-testid":"onboarding-payment-remarks-security",children:['"',U.remarks,'"']}),e.jsxs("div",{className:"pt-4 mt-2 border-t border-slate-100",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider mb-2",children:"Verification Documents"}),e.jsxs("div",{className:"space-y-2",children:[i.filter(T=>{var I,B;return((I=T.documentType)==null?void 0:I.toLowerCase().includes("security"))&&((B=T.documentType)==null?void 0:B.toLowerCase().includes("deposit"))}).map((T,I)=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded bg-slate-50/50 border border-slate-100","data-testid":`onboarding-payment-doc-security-${I}`,children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.jsx(Ns,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-[10px] font-medium text-slate-700 truncate",children:T.fileName||T.name})]}),e.jsx(se,{variant:"ghost",size:"sm",className:"h-6 px-2 text-[10px] text-re-red hover:text-re-red-hover hover:bg-red-50","data-testid":`onboarding-payment-doc-view-security-${I}`,onClick:()=>{D(T),P(!0)},children:"View"})]},I)),i.filter(T=>{var I,B;return((I=T.documentType)==null?void 0:I.toLowerCase().includes("security"))&&((B=T.documentType)==null?void 0:B.toLowerCase().includes("deposit"))}).length===0&&e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"No proof uploaded"})]})]})]})]})})})(),(()=>{const U=q("FIRST_FILL"),M=O.FIRST_FILL,z=(M==null?void 0:M.amount)||15e5;return e.jsx(Le,{className:Nt("border-l-4",(U==null?void 0:U.status)==="Verified"?"border-l-green-500":(U==null?void 0:U.status)==="Rejected"?"border-l-red-500":"border-l-re-red"),"data-testid":"onboarding-payment-card-first-fill",children:e.jsxs(Fe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-blue-50 flex items-center justify-center text-blue-600",children:e.jsx(no,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-semibold text-slate-700",children:"First Fill"})]}),e.jsx(Ce,{className:Nt((U==null?void 0:U.status)==="Verified"?"bg-green-100 text-green-700 hover:bg-green-100":(U==null?void 0:U.status)==="Rejected"?"bg-red-100 text-red-700 hover:bg-red-100":"bg-red-50 text-re-red-hover hover:bg-red-50"),"data-testid":"onboarding-payment-status-first-fill",children:(U==null?void 0:U.status)||"Awaiting"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-baseline",children:[e.jsx("span",{className:"text-xs text-slate-500 uppercase font-bold tracking-wider",children:"Amount Received"}),e.jsxs("span",{className:"text-lg font-bold text-slate-900","data-testid":"onboarding-payment-amount-first-fill",children:["₹",Number((U==null?void 0:U.amount)||0).toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-baseline border-t border-slate-100 pt-2",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Expected Total"}),e.jsxs("span",{className:"text-sm font-medium text-slate-600",children:["₹",z.toLocaleString()]})]}),(U==null?void 0:U.paymentReference)&&e.jsxs("div",{className:"bg-slate-50 p-2 rounded text-xs font-mono text-slate-600 flex justify-between items-center","data-testid":"onboarding-payment-ref-first-fill",children:[e.jsxs("span",{children:["Ref: ",U.paymentReference]}),U.verifiedAt&&e.jsx("span",{children:Yt(U.verifiedAt)})]}),(U==null?void 0:U.remarks)&&e.jsxs("div",{className:"text-[11px] text-slate-500 bg-red-50/50 p-2 rounded border border-red-100 italic","data-testid":"onboarding-payment-remarks-first-fill",children:['"',U.remarks,'"']}),e.jsxs("div",{className:"pt-4 mt-2 border-t border-slate-100",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider mb-2",children:"Verification Documents"}),e.jsxs("div",{className:"space-y-2",children:[i.filter(T=>{var I,B;return((I=T.documentType)==null?void 0:I.toLowerCase().includes("first"))&&((B=T.documentType)==null?void 0:B.toLowerCase().includes("fill"))}).map((T,I)=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded bg-slate-50/50 border border-slate-100","data-testid":`onboarding-payment-doc-first-fill-${I}`,children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.jsx(Ns,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-[10px] font-medium text-slate-700 truncate",children:T.fileName||T.name})]}),e.jsx(se,{variant:"ghost",size:"sm",className:"h-6 px-2 text-[10px] text-blue-600 hover:text-blue-700 hover:bg-blue-50","data-testid":`onboarding-payment-doc-view-first-fill-${I}`,onClick:()=>{D(T),P(!0)},children:"View"})]},I)),i.filter(T=>{var I,B;return((I=T.documentType)==null?void 0:I.toLowerCase().includes("first"))&&((B=T.documentType)==null?void 0:B.toLowerCase().includes("fill"))}).length===0&&e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"No proof uploaded"})]})]})]})]})})})()]})]}),e.jsx(Ut,{value:"audit","data-testid":"onboarding-tab-content-audit",children:e.jsx(Ib,{className:"h-[30rem] rounded-md border border-slate-100 bg-slate-50/50",children:e.jsx("div",{className:"space-y-2.5 p-3 pr-4","data-testid":"onboarding-audit-logs-container",children:L?e.jsxs("div",{className:"flex items-center justify-center py-10","data-testid":"onboarding-audit-loading",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-re-red"}),e.jsx("span",{className:"ml-2 text-sm text-slate-500",children:"Loading audit trail…"})]}):$.length===0?e.jsx("div",{className:"rounded-lg border border-dashed border-slate-200 bg-white py-10 text-center text-sm text-slate-500","data-testid":"onboarding-audit-empty",children:"No audit logs recorded yet for this application."}):$.map((U,M)=>e.jsxs("div",{className:"rounded-lg border border-slate-200/90 bg-white p-3 text-sm shadow-sm","data-testid":`onboarding-audit-log-item-${M}`,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-x-3 gap-y-1.5",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx(Ce,{variant:"outline",className:Nt("shrink-0 text-[10px] font-semibold uppercase tracking-wide",Y(U.action)),"data-testid":`onboarding-audit-log-action-${M}`,children:String(U.action||"EVENT").replace(/_/g," ")}),U.stage?e.jsx("span",{className:"max-w-[200px] truncate text-[11px] text-slate-500",title:U.stage,"data-testid":`onboarding-audit-log-stage-${M}`,children:U.stage}):null]}),e.jsx("time",{className:"shrink-0 text-xs tabular-nums text-slate-400",dateTime:U.timestamp,"data-testid":`onboarding-audit-log-time-${M}`,children:Yt(U.timestamp)})]}),e.jsx("p",{className:"mt-2 text-[13px] leading-relaxed text-slate-800","data-testid":`onboarding-audit-log-desc-${M}`,children:U.description||"—"}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-slate-500",children:[e.jsx(Lr,{className:"h-3.5 w-3.5 shrink-0 text-slate-400","aria-hidden":!0}),e.jsxs("span",{className:"min-w-0 truncate",children:[e.jsx("span",{className:"font-medium text-slate-600","data-testid":`onboarding-audit-log-user-${M}`,children:U.userName||"System"}),U.userEmail?e.jsxs("span",{className:"text-slate-400","data-testid":`onboarding-audit-log-email-${M}`,children:[" · ",U.userEmail]}):null]})]})]},U.id))})})})]})]})})}function qU(t){var B;const{application:s,permissions:n,getDeposit:r,isNonResponsive:a,isAdmin:i,currentUserStageAction:o,currentUserEvaluation:d,onOpenApproveModal:m,onOpenRejectModal:f,onOpenWorknote:p,onOpenScheduleModal:h,currentUser:x,handleGenerateDealerCodes:u,onOpenAssignArchitectureModal:N,onOpenAssignFdd:v,showAssignFddModal:w,setShowAssignFddModal:j,fddAgencies:b,selectedAgencyId:C,setSelectedAgencyId:S,isAssigningAgency:R,handleAssignAgency:_,activeInterviewForUser:A,hasSubmittedFeedback:E,setSelectedInterviewForFeedback:q,setShowKTMatrixModal:O,setShowLevel2FeedbackModal:D,setShowLevel3FeedbackModal:P,onGoToDashboard:L,showAssignModal:$,setShowAssignModal:Y,selectedUser:Z,setSelectedUser:W,users:U,participantType:M,setParticipantType:z,handleAddParticipant:T,isAssigningParticipant:I}=t;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Le,{"data-testid":"onboarding-details-summary-card",children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Summary"})}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Registration ID"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-details-summary-reg-id",children:s.registrationNumber})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Status"}),e.jsx(Ce,{className:Nt("mt-1",Xb(s.status)),"data-testid":"onboarding-details-summary-status",children:s.status})]}),s.rank&&e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Rank"}),e.jsxs("p",{className:"text-slate-900","data-testid":"onboarding-details-summary-rank",children:[s.rank," of ",s.totalApplicantsAtLocation,e.jsxs("span",{className:"text-slate-500",children:[" in ",s.preferredLocation]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Progress"}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(dc,{value:s.progress,className:"flex-1 bg-red-50",indicatorClassName:gl(s.status),"data-testid":"onboarding-details-summary-progress-bar"}),e.jsxs("span",{className:"text-slate-900","data-testid":"onboarding-details-summary-progress-text",children:[s.progress,"%"]})]})]}),s.deadline&&e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Questionnaire Deadline"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-details-summary-deadline",children:Yt(s.deadline)})]})]})]}),(s.isShortlisted!==!1||s.status==="Submitted")&&e.jsxs(Le,{"data-testid":"onboarding-details-actions-card",children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Actions"})}),e.jsxs(Fe,{className:"space-y-3",children:[n.isLoaLocked&&e.jsxs(di,{variant:"destructive",className:"mb-4 bg-red-50 border-red-200 text-red-800","data-testid":"onboarding-details-loa-locked-alert",children:[e.jsx(ny,{className:"w-4 h-4 text-re-red"}),e.jsx(_i,{className:"text-red-900 font-semibold",children:"LOA approval locked"}),e.jsxs(ui,{className:"text-red-800",children:[e.jsx("span",{className:"font-medium",children:"First Fill"})," (later-stage payment) must be verified by Finance before LOA approval can proceed. This is separate from the initial Security Deposit before LOI Issued."]})]}),((B=r("FIRST_FILL"))==null?void 0:B.status)==="Verified"&&s.status!=="LOA Pending"&&!["LOA Issued","EOR In Progress","EOR Complete","Inauguration","Approved","Onboarded","Rejected"].includes(s.status)&&e.jsxs(di,{className:"mb-4 border-violet-200 bg-violet-50/90 text-violet-950","data-testid":"onboarding-details-first-fill-verified-alert",children:[e.jsx(_a,{className:"h-4 w-4 text-violet-700"}),e.jsx(_i,{className:"font-semibold",children:"First Fill verified on file"}),e.jsxs(ui,{className:"text-sm text-violet-900/90 leading-relaxed",children:["Finance has verified the ",e.jsx("span",{className:"font-medium",children:"First Fill"})," payment. The application status was ",e.jsx("span",{className:"font-medium",children:"not"})," changed until you reach"," ",e.jsx("span",{className:"font-medium",children:"LOA Pending"}),". When you get there, LOA approval will not be blocked by payment (same pattern as recording the initial Security Deposit before the LOI security step)."]})]}),n.isSecurityDetailsLocked&&e.jsxs(di,{variant:"destructive",className:"mb-4 bg-red-50 border-red-200 text-red-800","data-testid":"onboarding-details-security-locked-alert",children:[e.jsx(ny,{className:"w-4 h-4 text-re-red"}),e.jsx(_i,{className:"text-red-900 font-semibold",children:"Security Deposit approval locked"}),e.jsxs(ui,{className:"text-red-800",children:["Finance must verify the ",e.jsx("span",{className:"font-medium",children:"Security Deposit"})," before this stage can be approved. You can still use ",e.jsx("span",{className:"font-medium",children:"Reject"})," if needed."]})]}),["Security Deposit","Security Details","Payment Pending"].includes(s.status)&&e.jsxs(di,{className:"mb-4 border-sky-200 bg-sky-50/90 text-sky-900","data-testid":"onboarding-details-security-review-alert",children:[e.jsx(_a,{className:"h-4 w-4 text-sky-700"}),e.jsx(_i,{className:"text-sky-950 font-semibold",children:"Security Deposit review"}),e.jsxs(ui,{className:"text-sm text-sky-900/90 leading-relaxed",children:["Check the initial Security Deposit on the ",e.jsx("span",{className:"font-medium",children:"Payments"})," tab (Finance may have already marked it verified). When satisfied, use ",e.jsx("span",{className:"font-medium",children:"Approve"})," ","to move to ",e.jsx("span",{className:"font-medium",children:"LOI Issued"}),"."]})]}),a&&i&&e.jsxs(di,{variant:"destructive",className:"mb-4 bg-red-50 border-red-200 text-red-800","data-testid":"onboarding-details-non-responsive-alert",children:[e.jsx(sn,{className:"w-4 h-4 text-red-600"}),e.jsx(_i,{className:"text-red-900 font-black uppercase tracking-tighter",children:"⚠️ Non-Responsive Flag"}),e.jsx(ui,{className:"text-red-800 text-xs font-bold leading-tight",children:"FDD Audit has flagged this applicant. Review audit logs before approval."})]}),i&&(s.status==="Level 3 Approved"||s.status==="FDD Verification")&&(!s.fddAssignments||s.fddAssignments.length===0)&&e.jsxs(di,{className:"mb-4 bg-red-50 border-red-200 text-red-800","data-testid":"onboarding-details-fdd-assignment-alert",children:[e.jsx(sn,{className:"w-4 h-4 text-re-red"}),e.jsx(_i,{className:"text-red-900 font-bold",children:"FDD Assignment Required"}),e.jsx(ui,{className:"text-red-800 font-medium",children:"This application is pending financial due diligence. Please assign an FDD Agency to proceed with the audit."})]}),n.canApprove&&e.jsxs(se,{className:"w-full bg-green-600 hover:bg-green-700 font-bold",onClick:m,"data-testid":"onboarding-details-approve-button",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),["Inauguration","Approved"].includes(s.status)?"Onboard Dealer":"Approve"]}),n.canReject&&e.jsxs(se,{variant:"destructive",className:"w-full font-bold",onClick:f,"data-testid":"onboarding-details-reject-button",children:[e.jsx(mi,{className:"w-4 h-4 mr-2"}),"Reject"]}),n.showDecisionMessage&&e.jsxs("div",{className:`w-full p-2 text-center rounded border ${(o==null?void 0:o.decision)==="Approved"||(d==null?void 0:d.decision)==="Approved"||(d==null?void 0:d.recommendation)==="Approved"||(d==null?void 0:d.decision)==="Selected"?"bg-green-50 border-green-200 text-green-700":"bg-red-50 border-red-200 text-red-700"}`,"data-testid":"onboarding-details-decision-message",children:["You have ",(o==null?void 0:o.decision)==="Approved"||(d==null?void 0:d.decision)==="Approved"||(d==null?void 0:d.recommendation)==="Approved"||(d==null?void 0:d.decision)==="Selected"?"Approved":"Rejected"]}),e.jsx(ec,{}),e.jsxs(se,{variant:"outline",className:"w-full",onClick:p,"data-testid":"onboarding-details-worknote-button",children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"Work Note"]}),n.canSchedule&&e.jsxs(se,{variant:"outline",className:"w-full",onClick:h,"data-testid":"onboarding-details-schedule-button",children:[e.jsx(dr,{className:"w-4 h-4 mr-2"}),"Schedule Interview"]}),x&&["DD Admin","Super Admin"].includes(x.role)&&["Dealer Code Generation","LOA Pending","Architecture Team Assigned","Architecture Document Upload","Architecture Team Completion"].includes(s.status)&&e.jsxs(e.Fragment,{children:[!s.dealerCode&&e.jsxs(se,{className:"w-full bg-blue-600 hover:bg-blue-700",onClick:u,"data-testid":"onboarding-details-generate-dealer-codes",children:[e.jsx(R1,{className:"w-4 h-4 mr-2"}),"Generate Dealer Codes"]}),s.dealerCode&&!s.architectureAssignedTo&&e.jsxs(se,{variant:"outline",className:"w-full border-blue-200 hover:bg-blue-50 text-blue-700",onClick:N,"data-testid":"onboarding-details-assign-architecture",children:[e.jsx(sy,{className:"w-4 h-4 mr-2"}),"Assign Architecture Team"]})]}),i&&["Level 3 Approved","Level 3 Recommended","FDD Verification","FDD In Progress"].includes(s.status)&&(!s.fddAssignments||s.fddAssignments.length===0)&&e.jsxs(ds,{open:w,onOpenChange:j,children:[e.jsxs(se,{variant:"outline",className:"w-full border-purple-200 hover:bg-purple-50 text-purple-700",onClick:v,"data-testid":"onboarding-details-assign-fdd",children:[e.jsx(ik,{className:"w-4 h-4 mr-2"}),"Assign FDD"]}),e.jsxs(os,{"data-testid":"onboarding-details-assign-fdd-modal",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Assign FDD Agency"}),e.jsx(bs,{children:"Select an FDD partner agency to perform the financial due diligence audit for this application."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{children:"FDD Agency"}),e.jsxs(Dt,{value:C,onValueChange:S,children:[e.jsx(Et,{className:"mt-2","data-testid":"onboarding-details-assign-fdd-select",children:e.jsx(Rt,{placeholder:b!=null&&b.length?"Choose partner agency...":"No agencies available"})}),e.jsx(_t,{children:(b||[]).map(G=>e.jsxs(Me,{value:G.id,children:[G.fullName||G.name," (",G.email,")"]},G.id))})]})]}),e.jsx(se,{className:"w-full bg-re-red hover:bg-re-red-hover font-bold h-11",onClick:_,disabled:R||!C,"data-testid":"onboarding-details-assign-fdd-submit",children:R?"Assigning...":"Assign Agency"})]})]})]}),A&&!E&&e.jsxs(bb,{children:[e.jsx(jb,{asChild:!0,children:e.jsxs(se,{variant:"outline",className:"w-full","data-testid":"onboarding-details-feedback-dropdown-trigger",children:[e.jsx(tM,{className:"w-4 h-4 mr-2"}),"Interview Feedback",e.jsx(Aa,{className:"w-4 h-4 ml-auto"})]})}),e.jsx(Nb,{className:"w-56","data-testid":"onboarding-details-feedback-dropdown-content",children:e.jsxs(ID,{"data-testid":`onboarding-details-feedback-item-${A.id}`,onClick:()=>{q(A),A.level===1?O(!0):A.level===2?D(!0):P(!0)},children:["Level ",A.level," - ",A.interviewType]},A.id)})]}),s.status==="Questionnaire Pending"&&e.jsxs(e.Fragment,{children:[e.jsxs(se,{variant:"outline",className:"w-full","data-testid":"onboarding-details-send-reminder",children:[e.jsx(Ur,{className:"w-4 h-4 mr-2"}),"Send Reminder"]}),e.jsxs(se,{variant:"outline",className:"w-full","data-testid":"onboarding-details-extend-deadline",children:[e.jsx(vn,{className:"w-4 h-4 mr-2"}),"Extend Deadline"]})]}),s.dealer&&e.jsxs("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg space-y-3","data-testid":"onboarding-details-dealer-active-banner",children:[e.jsxs("div",{className:"flex items-center gap-2 text-green-800 font-semibold",children:[e.jsx(un,{className:"w-5 h-5 text-green-600"}),"Dealer Profile Active"]}),e.jsx("div",{className:"text-sm text-green-700",children:"This application has been successfully onboarded as a dealer. A user account has been created for the dealer."}),s.dealerCode&&e.jsxs("div",{className:"flex items-center justify-between text-xs font-mono bg-white p-2 rounded border border-green-100","data-testid":"onboarding-details-active-dealer-code",children:[e.jsx("span",{className:"text-slate-500",children:"Dealer Code:"}),e.jsx("span",{className:"font-bold text-slate-900",children:s.dealerCode.code})]}),e.jsxs(se,{className:"w-full bg-green-600 hover:bg-green-700 text-white",onClick:L,"data-testid":"onboarding-details-goto-dashboard",children:[e.jsx(R1,{className:"w-4 h-4 mr-2"}),"Go to Dealer Dashboard"]})]}),x&&["DD Admin","Super Admin"].includes(x.role)&&e.jsxs(ds,{open:$,onOpenChange:Y,children:[e.jsx(co,{asChild:!0,children:e.jsxs(se,{variant:"outline",className:"w-full","data-testid":"onboarding-details-assign-user-trigger",children:[e.jsx(Lr,{className:"w-4 h-4 mr-2"}),"Assign User"]})}),e.jsxs(os,{"data-testid":"onboarding-details-assign-user-modal",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Assign User to Application"}),e.jsx(bs,{children:"Select a user and their role for this application."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{children:"Select User"}),e.jsxs(Dt,{value:Z,onValueChange:W,children:[e.jsx(Et,{className:"mt-2","data-testid":"onboarding-details-assign-user-select",children:e.jsx(Rt,{placeholder:"Search users..."})}),e.jsx(_t,{children:U.map(G=>e.jsxs(Me,{value:G.id,children:[G.fullName," (",G.email,")"]},G.id))})]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Assignment Role"}),e.jsxs(Dt,{value:M,onValueChange:z,children:[e.jsx(Et,{className:"mt-2","data-testid":"onboarding-details-assign-role-select",children:e.jsx(Rt,{placeholder:"Select role"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"owner",children:"Owner"}),e.jsx(Me,{value:"contributor",children:"Contributor"}),e.jsx(Me,{value:"reviewer",children:"Reviewer"})]})]})]}),e.jsx(se,{className:"w-full bg-re-red hover:bg-re-red-hover font-bold h-11",onClick:T,disabled:I,"data-testid":"onboarding-details-assign-user-submit",children:I?"Assigning...":"Assign User"})]})]})]})]})]})]})}function zU(t){const{application:s,fetchApplication:n,showApproveModal:r,setShowApproveModal:a,approvalRemark:i,setApprovalRemark:o,setApprovalFile:d,isApproving:m,handleApprove:f,showOnboardModal:p,setShowOnboardModal:h,isOnboarding:x,setIsOnboarding:u,showRejectModal:N,setShowRejectModal:v,rejectionReason:w,setRejectionReason:j,isRejecting:b,handleReject:C,showScheduleModal:S,setShowScheduleModal:R,showCancelInterviewModal:_,setShowCancelInterviewModal:A,setInterviewIdToCancel:E,isCancellingInterview:q,handleConfirmCancelInterview:O,interviewToReschedule:D,setInterviewToReschedule:P,interviewType:L,setInterviewType:$,interviewMode:Y,setInterviewMode:Z,interviewDate:W,setInterviewDate:U,meetingLink:M,setMeetingLink:z,location:T,setLocation:I,isInterviewCompleted:B,isInterviewActive:G,users:K,selectedInterviewerId:H,setSelectedInterviewerId:X,handleAddInterviewer:J,scheduledInterviewParticipants:ae,handleRemoveInterviewer:le,isScheduling:xe,handleScheduleInterview:ce,showAssignArchitectureModal:ve,setShowAssignArchitectureModal:Pe,architectureLeadId:et,setArchitectureLeadId:kt,isAssigningArchitecture:vt,handleAssignArchitecture:ee,showArchitectureStatusModal:ge,setShowArchitectureStatusModal:ye,architectureStatus:Be,setArchitectureStatus:$e,architectureRemarks:dt,setArchitectureRemarks:st,isUpdatingArchitecture:xt,handleUpdateArchitectureStatus:Mt}=t,It=he=>{var pt,ht;return(he==null?void 0:he.__stageRole)||((pt=he==null?void 0:he.role)==null?void 0:pt.roleName)||((ht=he==null?void 0:he.role)==null?void 0:ht.roleCode)||(he==null?void 0:he.roleCode)||(he==null?void 0:he.role)||"Panelist"};return e.jsxs(e.Fragment,{children:[e.jsx(ds,{open:r,onOpenChange:a,children:e.jsxs(os,{"data-testid":"onboarding-approve-modal",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Approve Application"}),e.jsx(bs,{children:"Provide approval remarks and optionally attach supporting documents."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(de,{children:["Remark ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ws,{placeholder:"Enter approval remarks...",value:i,onChange:he=>o(he.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-approve-remark-textarea"})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Attach File (Optional)"}),e.jsx(at,{type:"file",className:"mt-2",onChange:he=>d(he.target.files?he.target.files[0]:null),"data-testid":"onboarding-approve-file-input"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>a(!1),disabled:m,"data-testid":"onboarding-approve-cancel-button",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-green-600 hover:bg-green-700",onClick:f,disabled:m,"data-testid":"onboarding-approve-submit-button",children:m?e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}),"Approving..."]}):"Submit Approval"})]})]})]})}),e.jsx(ds,{open:p,onOpenChange:h,children:e.jsxs(os,{className:"max-w-md","data-testid":"onboarding-onboard-modal",children:[e.jsxs(xs,{children:[e.jsx("div",{className:"mx-auto w-12 h-12 bg-green-100 rounded-full flex items-center justify-center mb-4",children:e.jsx(un,{className:"w-8 h-8 text-green-600"})}),e.jsx(ms,{className:"text-center text-xl font-bold",children:"Finalize Onboarding"}),e.jsxs(bs,{className:"text-center pt-2",children:["You are about to officially onboard ",e.jsx("span",{className:"font-semibold text-slate-900",children:s.name})," as a Royal Enfield dealer."]})]}),e.jsxs("div",{className:"bg-slate-50 p-4 rounded-lg border border-slate-200 mt-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-1 bg-green-500 rounded-full p-0.5",children:e.jsx(Hn,{className:"w-3 h-3 text-white"})}),e.jsx("p",{className:"text-sm text-slate-600",children:"Official dealer profile will be created."})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-1 bg-green-500 rounded-full p-0.5",children:e.jsx(Hn,{className:"w-3 h-3 text-white"})}),e.jsxs("p",{className:"text-sm text-slate-600",children:["User account will be activated with role ",e.jsx("span",{className:"font-medium text-slate-900",children:"Dealer"}),"."]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-1 bg-green-500 rounded-full p-0.5",children:e.jsx(Hn,{className:"w-3 h-3 text-white"})}),e.jsx("p",{className:"text-sm text-slate-600",children:"Primary outlet will be registered in the system."})]})]}),e.jsxs("div",{className:"mt-6 flex flex-col gap-3",children:[e.jsx(se,{className:"w-full bg-green-600 hover:bg-green-700 h-11 text-lg font-semibold shadow-lg shadow-green-100","data-testid":"onboarding-onboard-confirm-button",onClick:async()=>{u(!0);try{await hs.createDealer({applicationId:s.id}),te.success("Dealer profile and login account created successfully!"),h(!1),n()}catch{te.error("Failed to create dealer profile")}finally{u(!1)}},disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"w-5 h-5 mr-2 animate-spin"}),"Processing Onboarding..."]}):"Confirm & Onboard Dealer"}),e.jsx(se,{variant:"ghost",className:"w-full text-slate-500 hover:text-slate-700",onClick:()=>h(!1),disabled:x,"data-testid":"onboarding-onboard-cancel-button",children:"Cancel"})]})]})}),e.jsx(ds,{open:N,onOpenChange:v,children:e.jsxs(os,{"data-testid":"onboarding-reject-modal",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Reject Application"}),e.jsx(bs,{children:"Please provide a clear reason for rejecting this application."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(de,{children:["Reason for Rejection ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ws,{placeholder:"Enter rejection reason...",value:w,onChange:he=>j(he.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-reject-remark-textarea"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>v(!1),disabled:b,"data-testid":"onboarding-reject-cancel-button",children:"Cancel"}),e.jsx(se,{variant:"destructive",className:"flex-1",onClick:C,disabled:b,"data-testid":"onboarding-reject-submit-button",children:b?e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}),"Rejecting..."]}):"Confirm Rejection"})]})]})]})}),e.jsx(ds,{open:S,onOpenChange:he=>{R(he),he||P(null)},children:e.jsxs(os,{"data-testid":"onboarding-schedule-modal",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:D?"Reschedule Interview":"Schedule Interview"}),e.jsx(bs,{children:"Set up an interview session with the applicant and relevant team members."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{children:"Interview Type"}),e.jsxs(Dt,{value:L,onValueChange:$,children:[e.jsx(Et,{className:"mt-2","data-testid":"onboarding-schedule-type-select",children:e.jsx(Rt,{placeholder:"Select interview type"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"level1",disabled:B(1)||G(1),children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("span",{children:"Level 1"}),B(1)&&e.jsx(un,{className:"w-4 h-4 text-green-500 ml-2 inline"}),G(1)&&e.jsx(vn,{className:"w-4 h-4 text-re-red ml-2 inline"})]})}),e.jsx(Me,{value:"level2",disabled:!B(1)||B(2)||G(2),children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("span",{children:"Level 2"}),!B(1)&&e.jsx("span",{className:"text-[10px] text-slate-400 ml-2",children:"(Prerequisite: L1)"}),B(2)&&e.jsx(un,{className:"w-4 h-4 text-green-500 ml-2 inline"}),G(2)&&e.jsx(vn,{className:"w-4 h-4 text-re-red ml-2 inline"})]})}),e.jsx(Me,{value:"level3",disabled:!B(2)||B(3)||G(3),children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("span",{children:"Level 3"}),!B(2)&&e.jsx("span",{className:"text-[10px] text-slate-400 ml-2",children:"(Prerequisite: L2)"}),B(3)&&e.jsx(un,{className:"w-4 h-4 text-green-500 ml-2 inline"}),G(3)&&e.jsx(vn,{className:"w-4 h-4 text-re-red ml-2 inline"})]})})]})]})]}),e.jsxs("div",{children:[e.jsxs(de,{children:["Interview Mode ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Dt,{value:Y,onValueChange:Z,children:[e.jsx(Et,{className:"mt-2","data-testid":"onboarding-schedule-mode-select",children:e.jsx(Rt,{placeholder:"Select interview mode"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"virtual",children:"Virtual"}),e.jsx(Me,{value:"physical",children:"Physical"})]})]})]}),e.jsxs("div",{children:[e.jsxs(de,{children:["Date & Time ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{type:"datetime-local",className:"mt-2",value:W,onChange:he=>U(he.target.value),"data-testid":"onboarding-schedule-date-input"})]}),Y==="virtual"&&e.jsxs("div",{children:[e.jsx(de,{children:"Meeting Link"}),e.jsx(at,{placeholder:"https://meet.google.com/...",className:"mt-2",value:M,onChange:he=>z(he.target.value),"data-testid":"onboarding-schedule-link-input"})]}),Y==="physical"&&e.jsxs("div",{children:[e.jsx(de,{children:"Location"}),e.jsx(at,{placeholder:"Enter interview location address",className:"mt-2",value:T,onChange:he=>I(he.target.value),"data-testid":"onboarding-schedule-location-input"})]}),e.jsxs("div",{children:[e.jsxs(de,{children:["Interviewers ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsxs(Dt,{value:H,onValueChange:X,children:[e.jsx(Et,{className:"flex-1","data-testid":"onboarding-schedule-interviewer-select",children:e.jsx(Rt,{placeholder:"Select interviewer"})}),e.jsx(_t,{children:K.map(he=>{var pt;return e.jsxs(Me,{value:he.id,children:[he.fullName||he.name," (",((pt=he.role)==null?void 0:pt.roleName)||he.roleCode,")"]},he.id)})})]}),e.jsx(se,{onClick:J,type:"button",variant:"secondary","data-testid":"onboarding-schedule-add-interviewer-button",children:"Add"})]}),ae.length>0&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsx(de,{className:"text-xs text-muted-foreground",children:"Selected Interviewers:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ae.map(he=>e.jsxs("div",{className:"flex items-center gap-1 bg-secondary px-2 py-1 rounded text-sm","data-testid":`onboarding-schedule-participant-${he.id}`,children:[e.jsx("span",{children:he.fullName||he.name||"Unknown"}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["(",It(he),")"]}),e.jsx("button",{onClick:()=>le(he.id),className:"text-muted-foreground hover:text-destructive","data-testid":`onboarding-schedule-remove-participant-${he.id}`,children:"×"})]},he.id))})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>{R(!1),P(null)},disabled:xe,"data-testid":"onboarding-schedule-cancel-button",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-primary-600 hover:bg-primary-700",onClick:ce,disabled:xe,"data-testid":"onboarding-schedule-submit-button",children:xe?D?"Rescheduling...":"Scheduling...":D?"Reschedule":"Schedule"})]})]})]})}),e.jsx(ds,{open:_,onOpenChange:he=>{A(he),he||E("")},children:e.jsxs(os,{"data-testid":"onboarding-cancel-interview-modal",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Cancel Interview"}),e.jsx(bs,{children:"Are you sure you want to cancel this interview?"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>{A(!1),E("")},disabled:q,"data-testid":"onboarding-cancel-interview-close",children:"No"}),e.jsx(se,{variant:"destructive",className:"flex-1",onClick:O,disabled:q,"data-testid":"onboarding-cancel-interview-confirm",children:q?"Cancelling...":"Yes, Cancel"})]})]})}),e.jsx(ds,{open:ve,onOpenChange:Pe,children:e.jsxs(os,{"data-testid":"onboarding-architecture-assign-modal",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Assign Architecture Team"}),e.jsx(bs,{children:"Select an architecture team lead for site planning and blueprints."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(de,{children:["Select Architecture Lead ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Dt,{value:et,onValueChange:kt,children:[e.jsx(Et,{className:"mt-2","data-testid":"onboarding-architecture-lead-select",children:e.jsx(Rt,{placeholder:"Search users..."})}),e.jsxs(_t,{children:[K.filter(he=>{var pt;return he.roleCode==="ARCHITECTURE"||((pt=he.role)==null?void 0:pt.roleCode)==="ARCHITECTURE"||he.role==="Architecture"||he.role==="Architecture Team"}).map(he=>e.jsxs(Me,{value:he.id,children:[he.fullName," (",he.email,")"]},he.id)),K.filter(he=>{var pt;return he.roleCode==="ARCHITECTURE"||((pt=he.role)==null?void 0:pt.roleCode)==="ARCHITECTURE"||he.role==="Architecture"||he.role==="Architecture Team"}).length===0&&K.map(he=>e.jsxs(Me,{value:he.id,children:[he.fullName," (",he.roleCode||he.role,")"]},he.id))]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>Pe(!1),disabled:vt,"data-testid":"onboarding-architecture-assign-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-blue-600 hover:bg-blue-700",onClick:ee,disabled:vt,"data-testid":"onboarding-architecture-assign-submit",children:vt?"Assigning...":"Assign Team"})]})]})]})}),e.jsx(ds,{open:ge,onOpenChange:ye,children:e.jsxs(os,{"data-testid":"onboarding-architecture-status-modal",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Update Architecture Status"}),e.jsx(bs,{children:"Mark the architectural work as completed and optionally add remarks."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(de,{children:["Status ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Dt,{value:Be,onValueChange:$e,children:[e.jsx(Et,{className:"mt-2","data-testid":"onboarding-architecture-status-select",children:e.jsx(Rt,{placeholder:"Select status"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"COMPLETED",children:"Completed"}),e.jsx(Me,{value:"REJECTED",children:"Rejected / Needs Revision"})]})]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Remarks (Optional)"}),e.jsx(Ws,{placeholder:"Enter any planning or site-visit remarks...",value:dt,onChange:he=>st(he.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-architecture-remarks-textarea"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>ye(!1),disabled:xt,"data-testid":"onboarding-architecture-status-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-blue-600 hover:bg-blue-700",onClick:Mt,disabled:xt,"data-testid":"onboarding-architecture-status-submit",children:xt?"Updating...":"Update Status"})]})]})]})})]})}function UU(t){var Qs,Xs,$s,Q,oe,we,Oe,ke;const{application:s,ktCriteria:n,l2Fields:r,l3Fields:a,showKTMatrixModal:i,setShowKTMatrixModal:o,ktMatrixSelectedValues:d,handleKTMatrixChange:m,ktMatrixRemarks:f,setKtMatrixRemarks:p,ktMatrixRecommendation:h,setKtMatrixRecommendation:x,calculateKTScore:u,handleSubmitKTMatrix:N,isSubmittingKT:v,showLevel2FeedbackModal:w,setShowLevel2FeedbackModal:j,level2Feedback:b,handleLevel2Change:C,level2Recommendation:S,setLevel2Recommendation:R,handleSubmitLevel2Feedback:_,isSubmittingLevel2:A,showFeedbackDetailsModal:E,setShowFeedbackDetailsModal:q,selectedEvaluationForView:O,selectedInterviewForFeedback:D,showLevel3FeedbackModal:P,setShowLevel3FeedbackModal:L,level3Feedback:$,handleLevel3Change:Y,level3Recommendation:Z,setLevel3Recommendation:W,handleSubmitLevel3Feedback:U,isSubmittingLevel3:M,showDocumentsModal:z,setShowDocumentsModal:T,showUploadForm:I,setShowUploadForm:B,selectedStage:G,getDocumentsForStage:K,setPreviewDoc:H,setShowPreviewModal:X,uploadDocType:J,setUploadDocType:ae,setUploadFile:le,isUploading:xe,handleUpload:ce,uploadFile:ve,showPreviewModal:Pe,previewDoc:et,showFddFinalizeModal:kt,setShowFddFinalizeModal:vt,currentUser:ee,fddAuditRecommendation:ge,setFddAuditRecommendation:ye,fddAuditFindings:Be,setFddAuditFindings:$e,isFinalizingFdd:dt,setIsFinalizingFdd:st,fetchApplication:xt,showFddFlagModal:Mt,setShowFddFlagModal:It,isFddFlagging:he,setIsFddFlagging:pt,showFirmTypeModal:ht,setShowFirmTypeModal:_e,tempFirmType:Vt,setTempFirmType:Pt,updatingFirmType:_s,handleUpdateFirmType:Ys}=t,Bs=D!=null&&D.scheduleDate?new Date(D.scheduleDate).toISOString().split("T")[0]:"",Ks=(ee==null?void 0:ee.fullName)||(ee==null?void 0:ee.name)||"";return e.jsxs(e.Fragment,{children:[e.jsx(ds,{open:i,onOpenChange:o,children:e.jsxs(os,{className:"flex min-h-0 max-h-[90vh] w-[calc(100%-2rem)] max-w-lg flex-col gap-0 overflow-hidden p-0 sm:max-w-lg","data-testid":"onboarding-kt-matrix-modal",children:[e.jsxs(xs,{className:"shrink-0 space-y-2 border-b px-5 py-4 text-left",children:[e.jsx(ms,{className:"text-base",children:"KT matrix"}),e.jsxs(bs,{className:"text-sm leading-relaxed",children:["Level 1 interview · ",s.name,e.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[Object.keys(d).length," of ",n.length," criteria answered"]})]})]}),e.jsx("div",{className:"custom-scrollbar-slim min-h-0 flex-1 overflow-y-auto px-5 py-5",children:e.jsxs("div",{className:"space-y-6",children:[n.length===0&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800",children:"KT Matrix configuration is not available. Configure it in Master > Interview Configurations."}),n.map((je,Ve)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs(de,{htmlFor:`kt-matrix-${Ve}`,className:"block text-sm font-medium leading-relaxed text-foreground",children:[e.jsxs("span",{className:"text-muted-foreground",children:[Ve+1,"."]})," ",je.name," ",e.jsx("span",{className:"text-red-500",children:"*"})," ",e.jsxs("span",{className:"font-normal text-muted-foreground",children:["(",je.weight,"%)"]})]}),e.jsxs(Dt,{value:d[je.name]??void 0,onValueChange:Ge=>{const nt=je.options.find(Zt=>Zt.value===Ge);nt&&m(je.name,nt.value,nt.score)},children:[e.jsx(Et,{id:`kt-matrix-${Ve}`,className:"h-10 w-full text-left text-sm font-normal","data-testid":`onboarding-kt-matrix-select-${Ve}`,children:e.jsx(Rt,{placeholder:"Choose an option…"})}),e.jsx(_t,{position:"popper",className:"max-h-72 w-[var(--radix-select-trigger-width)]",children:je.options.map(Ge=>e.jsxs(Me,{value:Ge.value,className:"py-2.5 text-sm leading-snug","data-testid":`onboarding-kt-matrix-option-${Ve}-${Ge.value}`,children:[Ge.label," ",e.jsxs("span",{className:"text-muted-foreground",children:["(",Ge.score,")"]})]},Ge.value))})]})]},je.name)),e.jsxs("div",{className:"space-y-2 border-t border-border pt-6",children:[e.jsxs(de,{htmlFor:"kt-matrix-remarks",className:"text-sm font-medium",children:["Remarks ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ws,{id:"kt-matrix-remarks",placeholder:"Enter remarks...",className:"min-h-[96px] resize-y text-sm leading-relaxed",value:f,onChange:je=>p(je.target.value),"data-testid":"onboarding-kt-matrix-remarks-textarea"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(de,{className:"text-sm font-medium",children:["Recommendation ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Dt,{value:h,onValueChange:x,children:[e.jsx(Et,{"data-testid":"onboarding-kt-matrix-recommendation-select",children:e.jsx(Rt,{placeholder:"Select recommendation"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"Approve",children:"Approve"}),e.jsx(Me,{value:"Reject",children:"Reject"}),e.jsx(Me,{value:"Hold",children:"Hold"})]})]})]})]})}),e.jsxs("div",{className:"flex shrink-0 flex-col gap-4 border-t px-5 py-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Weighted total ",e.jsx("span",{className:"font-semibold tabular-nums text-foreground","data-testid":"onboarding-kt-matrix-total-score",children:u()}),e.jsx("span",{className:"text-muted-foreground",children:" / 100"})]}),e.jsxs("div",{className:"flex gap-2 sm:shrink-0",children:[e.jsx(se,{variant:"outline",onClick:()=>o(!1),"data-testid":"onboarding-kt-matrix-cancel",children:"Cancel"}),e.jsx(se,{onClick:N,disabled:v||n.length===0||Object.keys(d).length<n.length||!(f!=null&&f.trim()),"data-testid":"onboarding-kt-matrix-submit",children:v?"Saving…":"Submit"})]})]})]})}),e.jsx(ds,{open:w,onOpenChange:j,children:e.jsxs(os,{className:"max-w-2xl max-h-[90vh] overflow-y-auto","data-testid":"onboarding-level2-feedback-modal",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Level 2 Interview Feedback"}),e.jsx(bs,{children:"Provide detailed feedback from the Level 2 interview (DD Lead + ZBH evaluation)."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(de,{children:["Interview Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{type:"date",className:"mt-2",value:b.interviewDate||Bs,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(de,{children:["Interviewer Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{placeholder:"Enter your name",className:"mt-2",value:b.interviewerName||Ks,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(de,{children:["Overall Performance Score ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Dt,{value:b.overallScore,onValueChange:je=>C("overallScore",je),children:[e.jsx(Et,{className:"mt-2","data-testid":"onboarding-level2-overall-score-select",children:e.jsx(Rt,{placeholder:"Select score"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"10",children:"Outstanding (9-10)"}),e.jsx(Me,{value:"8",children:"Excellent (7-8)"}),e.jsx(Me,{value:"6",children:"Good (5-6)"}),e.jsx(Me,{value:"4",children:"Average (3-4)"}),e.jsx(Me,{value:"2",children:"Below Average (1-2)"})]})]})]}),e.jsx(ec,{}),r.length===0&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800",children:"Level 2 feedback configuration is not available. Configure it in Master > Interview Configurations."}),(r||[]).map((je,Ve)=>e.jsxs("div",{children:[e.jsxs(de,{children:[je.label,je.isRequired&&e.jsx("span",{className:"text-red-500",children:"*"})]}),je.type==="select"?e.jsxs(Dt,{value:b[je.itemKey]||"",onValueChange:Ge=>C(je.itemKey,Ge),children:[e.jsx(Et,{className:"mt-2",children:e.jsx(Rt,{placeholder:`Select ${je.label}...`})}),e.jsx(_t,{children:(je.options||[]).map((Ge,nt)=>e.jsx(Me,{value:Ge.optionValue||Ge.value,children:Ge.optionLabel||Ge.label},nt))})]}):je.type==="number"?e.jsx(at,{type:"number",className:"mt-2",value:b[je.itemKey]||"",onChange:Ge=>C(je.itemKey,Ge.target.value)}):e.jsx(Ws,{placeholder:`Enter ${je.label.toLowerCase()}...`,className:"mt-2",rows:3,value:b[je.itemKey]||"",onChange:Ge=>C(je.itemKey,Ge.target.value)})]},je.itemKey||Ve)),e.jsxs("div",{children:[e.jsxs(de,{children:["Recommendation ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Dt,{value:S,onValueChange:R,children:[e.jsx(Et,{className:"mt-2","data-testid":"onboarding-level2-recommendation-select",children:e.jsx(Rt,{placeholder:"Select recommendation"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"Approve",children:"Approve"}),e.jsx(Me,{value:"Reject",children:"Reject"}),e.jsx(Me,{value:"Hold",children:"Hold"})]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>j(!1),"data-testid":"onboarding-level2-feedback-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-black hover:bg-zinc-800 text-white",onClick:_,disabled:A||r.length===0,"data-testid":"onboarding-level2-feedback-submit",children:A?"Submitting...":"Submit Feedback"})]})]})]})}),e.jsx(ds,{open:E,onOpenChange:q,children:e.jsxs(os,{className:"max-w-2xl max-h-[90vh] overflow-y-auto","data-testid":"onboarding-feedback-details-modal",children:[e.jsx(xs,{children:e.jsx(ms,{children:"Interview Feedback Details"})}),O&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 bg-slate-50 p-4 rounded-lg",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-500",children:"Interviewer"}),e.jsx("p",{className:"font-semibold","data-testid":"onboarding-feedback-details-interviewer",children:(Qs=O.evaluator)==null?void 0:Qs.fullName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-500",children:"Role"}),e.jsx("p",{"data-testid":"onboarding-feedback-details-role",children:(($s=(Xs=O.evaluator)==null?void 0:Xs.role)==null?void 0:$s.roleName)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-500",children:((Q=O.interview)==null?void 0:Q.level)===1?"Score (KT Matrix)":"Overall Score"}),e.jsx("p",{className:"font-bold text-lg","data-testid":"onboarding-feedback-details-score",children:O.ktMatrixScore?`${O.ktMatrixScore}/${((oe=O.interview)==null?void 0:oe.level)===1?"100":"10"}`:"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-500",children:"Recommendation"}),e.jsx(Ce,{variant:(we=O.recommendation)!=null&&we.toLowerCase().includes("reject")?"destructive":(Oe=O.recommendation)!=null&&Oe.toLowerCase().includes("hold")?"secondary":"default","data-testid":"onboarding-feedback-details-recommendation",children:O.recommendation||"N/A"})]})]}),e.jsx(ec,{}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold mb-3",children:"Detailed Feedback"}),((ke=O.feedbackDetails)==null?void 0:ke.length)>0?e.jsx("div",{className:"space-y-4",children:O.feedbackDetails.map((je,Ve)=>e.jsxs("div",{className:"border-b last:border-0 pb-3 last:pb-0","data-testid":`onboarding-feedback-detail-item-${Ve}`,children:[e.jsx("p",{className:"font-medium text-slate-900",children:je.feedbackType}),e.jsx("p",{className:"text-slate-700 mt-1 whitespace-pre-wrap text-sm",children:je.comments})]},Ve))}):e.jsx("p",{className:"text-slate-500 italic",children:"No detailed feedback available."})]})]})]})}),e.jsx(ds,{open:P,onOpenChange:L,children:e.jsxs(os,{className:"max-w-2xl max-h-[90vh] overflow-y-auto","data-testid":"onboarding-level3-feedback-modal",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Level 3 Interview Feedback"}),e.jsx(bs,{children:"Provide detailed feedback from the Level 3 interview (NBH + DD-Head evaluation)."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(de,{children:["Interview Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{type:"date",className:"mt-2",value:$.interviewDate||Bs,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(de,{children:["Interviewer Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{placeholder:"Enter your name",className:"mt-2",value:$.interviewerName||Ks,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(de,{children:["Overall Performance Score ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Dt,{value:$.overallScore,onValueChange:je=>Y("overallScore",je),children:[e.jsx(Et,{className:"mt-2","data-testid":"onboarding-level3-overall-score-select",children:e.jsx(Rt,{placeholder:"Select score"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"10",children:"Outstanding (9-10)"}),e.jsx(Me,{value:"8",children:"Excellent (7-8)"}),e.jsx(Me,{value:"6",children:"Good (5-6)"}),e.jsx(Me,{value:"4",children:"Average (3-4)"}),e.jsx(Me,{value:"2",children:"Below Average (1-2)"})]})]})]}),e.jsx(ec,{}),a.length===0&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800",children:"Level 3 feedback configuration is not available. Configure it in Master > Interview Configurations."}),(a||[]).map((je,Ve)=>e.jsxs("div",{children:[e.jsxs(de,{children:[je.label,je.isRequired&&e.jsx("span",{className:"text-red-500",children:"*"})]}),je.type==="select"?e.jsxs(Dt,{value:$[je.itemKey]||"",onValueChange:Ge=>Y(je.itemKey,Ge),children:[e.jsx(Et,{className:"mt-2",children:e.jsx(Rt,{placeholder:`Select ${je.label}...`})}),e.jsx(_t,{children:(je.options||[]).map((Ge,nt)=>e.jsx(Me,{value:Ge.optionValue||Ge.value,children:Ge.optionLabel||Ge.label},nt))})]}):je.type==="number"?e.jsx(at,{type:"number",className:"mt-2",value:$[je.itemKey]||"",onChange:Ge=>Y(je.itemKey,Ge.target.value)}):e.jsx(Ws,{placeholder:`Enter ${je.label.toLowerCase()}...`,className:"mt-2",rows:3,value:$[je.itemKey]||"",onChange:Ge=>Y(je.itemKey,Ge.target.value)})]},je.itemKey||Ve)),e.jsxs("div",{children:[e.jsxs(de,{children:["Recommendation ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Dt,{value:Z,onValueChange:W,children:[e.jsx(Et,{className:"mt-2","data-testid":"onboarding-level3-recommendation-select",children:e.jsx(Rt,{placeholder:"Select recommendation"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"Approve",children:"Approve"}),e.jsx(Me,{value:"Reject",children:"Reject"}),e.jsx(Me,{value:"Hold",children:"Hold"})]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>L(!1),"data-testid":"onboarding-level3-feedback-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-black hover:bg-zinc-800 text-white",onClick:U,disabled:M||a.length===0,"data-testid":"onboarding-level3-feedback-submit",children:M?"Submitting...":"Submit Feedback"})]})]})]})}),e.jsx(ds,{open:z,onOpenChange:je=>{T(je),je||B(!1)},children:e.jsxs(os,{className:"max-w-[95vw] sm:max-w-2xl md:max-w-3xl lg:max-w-4xl max-h-[90vh] overflow-hidden flex flex-col p-4 sm:p-6","data-testid":"onboarding-documents-modal",children:[e.jsxs(xs,{className:"pb-4",children:[e.jsxs(ms,{className:"text-xl font-bold flex items-center gap-2",children:[e.jsx(Ns,{className:"w-5 h-5 text-re-red"}),"Documents - ",G||"General"]}),e.jsx(bs,{className:"text-slate-500",children:"View and manage documents uploaded for this stage."})]}),I?e.jsxs("div",{className:"space-y-6 py-4","data-testid":"onboarding-documents-upload-form",children:[e.jsx("div",{className:"bg-slate-50/50 p-4 sm:p-6 rounded-2xl border border-slate-200",children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(de,{className:"text-slate-700 font-semibold px-1",children:["Document Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{type:"text",placeholder:"Enter document name",value:J,onChange:je=>ae(je.target.value),className:"bg-white border-slate-200 h-12 rounded-xl focus:ring-re-red shadow-sm","data-testid":"onboarding-documents-name-input"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(de,{className:"text-slate-700 font-semibold px-1",children:["Select File ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{type:"file",className:"bg-white border-slate-200 h-12 rounded-xl focus:ring-re-red shadow-sm file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-sm file:font-semibold file:bg-red-50 file:text-re-red-hover hover:file:bg-red-50 cursor-pointer",onChange:je=>{const Ve=je.target.files?je.target.files[0]:null;if(le(Ve),Ve){const Ge=Ve.name.replace(/\.[^/.]+$/,"");ae(Ge)}},"data-testid":"onboarding-documents-file-input"})]})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 pt-4",children:[e.jsx(se,{className:"flex-1 order-2 sm:order-1 py-3 sm:py-5 rounded-xl border-slate-200 font-semibold text-slate-600 hover:bg-slate-50",variant:"outline",onClick:()=>B(!1),disabled:xe,"data-testid":"onboarding-documents-upload-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 order-1 sm:order-2 bg-re-red hover:bg-re-red-hover text-white font-bold py-3 sm:py-5 rounded-xl shadow-lg shadow-re-red/15 transition-all hover:scale-[1.01] active:scale-[0.99]",onClick:async()=>{await ce(),B(!1)},disabled:!ve||!J||xe,"data-testid":"onboarding-documents-upload-submit",children:xe?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(or,{className:"w-5 h-5"}),"Confirm Upload"]})})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 space-y-4",children:[K(G||"").length>0?e.jsx("div",{className:"custom-scrollbar-x-slim flex-1 overflow-auto border rounded-lg border-slate-200","data-testid":"onboarding-documents-table-container",children:e.jsxs(Ts,{className:"w-full table-auto",children:[e.jsx(Ps,{className:"bg-slate-50/80 sticky top-0 z-10",children:e.jsxs(it,{className:"hover:bg-transparent border-b",children:[e.jsx(fe,{className:"w-[45%] min-w-[150px] font-semibold text-slate-900 py-3",children:"Document Name"}),e.jsx(fe,{className:"w-[15%] min-w-[100px] font-semibold text-slate-900 py-3",children:"Type"}),e.jsx(fe,{className:"w-[15%] min-w-[100px] font-semibold text-slate-900 py-3",children:"Upload Date"}),e.jsx(fe,{className:"w-[15%] min-w-[140px] font-semibold text-slate-900 py-3",children:"Uploaded By"}),e.jsx(fe,{className:"text-right w-[10%] min-w-[80px] font-semibold text-slate-900 py-3",children:"Actions"})]})}),e.jsx(Os,{children:K(G||"").map((je,Ve)=>{var Ge,nt;return e.jsxs(it,{className:"hover:bg-slate-50/50 transition-colors","data-testid":`onboarding-document-row-${Ve}`,children:[e.jsx(ue,{className:"py-3",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Ns,{className:"w-4 h-4 text-slate-400 shrink-0"}),e.jsx("span",{className:"truncate font-medium text-slate-700",title:je.fileName,"data-testid":`onboarding-document-name-${Ve}`,children:je.fileName})]})}),e.jsx(ue,{className:"py-3",children:e.jsx(Ce,{variant:"outline",className:"capitalize whitespace-nowrap font-normal border-slate-200 bg-white","data-testid":`onboarding-document-type-${Ve}`,children:((Ge=je.documentType)==null?void 0:Ge.toLowerCase())||"Other"})}),e.jsx(ue,{className:"py-3 whitespace-nowrap text-slate-600",children:Yt(je.createdAt)}),e.jsx(ue,{className:"py-3 text-slate-600",children:((nt=je.uploader)==null?void 0:nt.fullName)||(je.uploadedBy?"System User":"Applicant")}),e.jsx(ue,{className:"text-right py-3",children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 rounded-full",onClick:()=>{H(je),X(!0)},"data-testid":`onboarding-document-preview-${Ve}`,children:e.jsx(yn,{className:"w-4 h-4"})}),e.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-re-red hover:bg-red-50 rounded-full",onClick:()=>{window.open(`https://dealeronboarding-uat.royalenfield.com/api/${je.filePath}`,"_blank")},"data-testid":`onboarding-document-download-${Ve}`,children:e.jsx(ji,{className:"w-4 h-4"})})]})})]},je.id)})})]})}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-center border rounded-lg bg-slate-50/30","data-testid":"onboarding-documents-empty",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-slate-100 flex items-center justify-center mb-4",children:e.jsx(Ns,{className:"w-8 h-8 text-slate-300"})}),e.jsx("h3",{className:"text-slate-900 font-semibold mb-2",children:"No Documents Found"}),e.jsx("p",{className:"text-slate-600 text-sm max-w-[250px]",children:"No documents have been uploaded for this stage yet."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 pt-2 mt-auto",children:[e.jsxs(se,{className:"flex-1 bg-re-red hover:bg-re-red-hover text-white font-bold py-3 sm:py-5 rounded-xl shadow-lg shadow-re-red/15 transition-all hover:scale-[1.01] active:scale-[0.99]",onClick:()=>B(!0),"data-testid":"onboarding-documents-upload-button",children:[e.jsx(or,{className:"w-5 h-5 mr-3"}),"Upload Document"]}),e.jsx(se,{variant:"outline",className:"flex-1 sm:flex-none py-3 sm:py-5 px-8 rounded-xl border-slate-200 font-semibold text-slate-600 hover:bg-slate-50",onClick:()=>T(!1),"data-testid":"onboarding-documents-close-button",children:"Close"})]})]})]})}),e.jsx(mo,{isOpen:Pe,onClose:()=>X(!1),document:et}),e.jsx(ds,{open:kt,onOpenChange:vt,children:e.jsxs(os,{className:"max-w-md p-0 overflow-hidden border-none shadow-2xl rounded-3xl","data-testid":"onboarding-fdd-finalize-modal",children:[e.jsxs("div",{className:"bg-slate-950 p-8 flex items-center justify-center relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-re-red/20 to-transparent"}),e.jsx("div",{className:"w-20 h-20 bg-re-red/20 rounded-full flex items-center justify-center animate-pulse relative z-10 shadow-[0_0_40px_rgba(218,41,28,0.2)]",children:e.jsx(no,{className:"w-10 h-10 text-re-red"})})]}),e.jsxs("div",{className:"p-8 space-y-6 bg-white",children:[e.jsxs(xs,{children:[e.jsx(ms,{className:"text-2xl font-black text-slate-900 text-center tracking-tight",children:"Finalize FDD Audit"}),e.jsxs(bs,{className:"text-slate-500 text-center pt-2 leading-relaxed text-sm font-medium",children:["You are about to submit your final findings. This action will ",e.jsx("span",{className:"font-bold text-slate-900 underline decoration-re-red decoration-2",children:"lock the audit session"})," and trigger the LOI approval workflow."]})]}),e.jsxs("div",{className:"space-y-4",children:[(ee==null?void 0:ee.role)!=="FDD"&&(ee==null?void 0:ee.roleCode)!=="FDD"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(de,{className:"text-[10px] font-black uppercase tracking-widest text-slate-400",children:["Auditor Recommendation ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"flex gap-2",children:["Recommended","Qualified with Observations","Not Recommended"].map(je=>e.jsx(se,{variant:ge===je?"default":"outline",className:Nt("flex-1 h-10 font-bold text-[9px] uppercase tracking-wider rounded-xl transition-all",ge===je&&je==="Recommended"&&"bg-emerald-600 hover:bg-emerald-700",ge===je&&je==="Qualified with Observations"&&"bg-red-500 hover:bg-re-red",ge===je&&je==="Not Recommended"&&"bg-red-600 hover:bg-red-700"),onClick:()=>ye(je),"data-testid":`onboarding-fdd-recommendation-${je.replace(/\s+/g,"-").toLowerCase()}`,children:je},je))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{className:"text-[10px] font-black uppercase tracking-widest text-slate-400",children:"Findings Summary"}),e.jsx(Ws,{placeholder:"Summarize key financial findings or discrepancies...",className:"min-h-[100px] rounded-xl border-slate-200 focus:ring-re-red text-sm",value:Be,onChange:je=>$e(je.target.value),"data-testid":"onboarding-fdd-findings-textarea"})]})]}),e.jsxs("div",{className:"bg-red-50 p-4 rounded-2xl flex gap-3 border border-red-100",children:[e.jsx(_a,{className:"w-5 h-5 text-re-red shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-red-800 font-medium italic",children:"Ensure the final PDF report is uploaded first. This satisfies the FDD statutory requirement."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 pt-2",children:[e.jsx(se,{variant:"outline",className:"w-full sm:flex-1 h-12 rounded-2xl font-bold text-slate-600 hover:bg-slate-50 border-slate-200",onClick:()=>vt(!1),disabled:dt,"data-testid":"onboarding-fdd-finalize-cancel",children:"Cancel"}),e.jsx(se,{className:"w-full sm:flex-1 h-12 rounded-2xl font-bold bg-slate-950 hover:bg-slate-900 text-white shadow-lg shadow-slate-200 transition-all active:scale-95 border-b-4 border-re-red",disabled:dt||!Be,"data-testid":"onboarding-fdd-finalize-submit",onClick:async()=>{try{st(!0),await hs.submitStageDecision({applicationId:s.id,stageCode:"FDD_VERIFICATION",decision:"Approved",remarks:(ee==null?void 0:ee.role)==="FDD"||(ee==null?void 0:ee.roleCode)==="FDD"?`Findings: ${Be}`:`[RECOMMENDATION: ${ge}]
Findings: ${Be}`,nextStatus:"LOI In Progress",nextProgress:65}),te.success("FDD Audit finalized and submitted."),vt(!1),xt()}catch{te.error("Submission failed")}finally{st(!1)}},children:dt?e.jsx(ns,{className:"w-5 h-5 animate-spin"}):"Confirm & Submit"})]})]})]})}),e.jsx(ds,{open:Mt,onOpenChange:It,children:e.jsxs(os,{className:"max-w-md p-0 overflow-hidden border-none shadow-2xl rounded-3xl","data-testid":"onboarding-fdd-flag-modal",children:[e.jsxs("div",{className:"bg-slate-950 p-8 flex items-center justify-center relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-600/20 to-transparent"}),e.jsx("div",{className:"w-20 h-20 bg-red-600/20 rounded-full flex items-center justify-center relative z-10 shadow-[0_0_40px_rgba(220,38,38,0.2)]",children:e.jsx(fk,{className:"w-10 h-10 text-red-500"})})]}),e.jsxs("div",{className:"p-8 space-y-6 bg-white text-center",children:[e.jsxs(xs,{children:[e.jsx(ms,{className:"text-2xl font-black text-slate-900 tracking-tight",children:"Flag Non-Responsive"}),e.jsx(bs,{className:"text-slate-500 pt-2 leading-relaxed text-sm font-medium",children:"Are you sure you want to flag this applicant? This will notify the DD Admin that the audit cannot proceed due to applicant's non-cooperation."})]}),e.jsxs("div",{className:"bg-red-50 p-4 rounded-2xl flex gap-3 border border-red-100",children:[e.jsx(sn,{className:"w-5 h-5 text-red-600 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-red-800 text-left font-medium",children:'"Applicant is unresponsive to multiple queries and financial document requests."'})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 pt-2",children:[e.jsx(se,{variant:"outline",className:"w-full sm:flex-1 h-12 rounded-2xl font-bold text-slate-600 hover:bg-slate-50 border-slate-200",onClick:()=>It(!1),disabled:he,"data-testid":"onboarding-fdd-flag-cancel",children:"Go Back"}),e.jsx(se,{className:"w-full sm:flex-1 h-12 rounded-2xl font-bold bg-slate-950 hover:bg-slate-900 text-white shadow-lg shadow-slate-200 transition-all active:scale-95 border-b-4 border-red-600",disabled:he,"data-testid":"onboarding-fdd-flag-submit",onClick:async()=>{try{pt(!0),await hs.submitStageDecision({applicationId:s.id,stageCode:"FDD_VERIFICATION",decision:"Rejected",remarks:"Applicant is non-responsive to FDD queries."}),te.error("Applicant flagged as non-responsive."),It(!1),xt()}catch{te.error("Action failed")}finally{pt(!1)}},children:he?e.jsx(ns,{className:"w-5 h-5 animate-spin"}):"Confirm Flag"})]})]})]})}),e.jsx(ds,{open:ht,onOpenChange:_e,children:e.jsxs(os,{className:"max-w-md p-0 overflow-hidden rounded-3xl border-none shadow-2xl","data-testid":"onboarding-firm-type-modal",children:[e.jsxs("div",{className:"bg-re-red p-8 text-white",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-white/20 flex items-center justify-center mb-6 backdrop-blur-sm border border-white/30 shadow-inner",children:e.jsx(so,{className:"w-8 h-8 text-white"})}),e.jsx("h3",{className:"text-2xl font-black tracking-tight mb-2",children:"Update Firm Type"}),e.jsx("p",{className:"text-red-100/80 text-sm font-medium leading-relaxed",children:"Select the proposed legal constitution for this dealership application."})]}),e.jsxs("div",{className:"p-8 space-y-6 bg-white",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(de,{className:"text-[10px] text-slate-400 uppercase tracking-widest font-black",children:["Proposed Legal Constitution ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Dt,{value:Vt,onValueChange:Pt,children:[e.jsx(Et,{className:"h-12 rounded-xl border-slate-200 focus:ring-re-red","data-testid":"onboarding-firm-type-select",children:e.jsx(Rt,{placeholder:"Select Firm Type"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"Proprietorship","data-testid":"onboarding-firm-type-proprietorship",children:"Proprietorship"}),e.jsx(Me,{value:"Partnership","data-testid":"onboarding-firm-type-partnership",children:"Partnership"}),e.jsx(Me,{value:"Limited Liability partnership","data-testid":"onboarding-firm-type-llp",children:"LLP (Limited Liability partnership)"}),e.jsx(Me,{value:"Private Limited Company","data-testid":"onboarding-firm-type-pvt-ltd",children:"Private Limited Company"}),e.jsx(Me,{value:"Public Limited Company","data-testid":"onboarding-firm-type-pub-ltd",children:"Public Limited Company"})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx(se,{variant:"outline",className:"flex-1 h-12 rounded-xl font-bold text-slate-600 border-slate-200",onClick:()=>_e(!1),disabled:_s,"data-testid":"onboarding-firm-type-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 h-12 rounded-xl font-bold bg-re-red hover:bg-re-red-hover text-white shadow-lg shadow-red-200 transition-all active:scale-95",disabled:_s||!Vt,onClick:Ys,"data-testid":"onboarding-firm-type-submit",children:_s?e.jsx(ns,{className:"w-5 h-5 animate-spin"}):"Update Type"})]})]})]})})]})}var VU={};function HU({application:t,documents:s,setPreviewDoc:n,setShowPreviewModal:r,setIsUploading:a,fetchApplication:i,refreshDocuments:o}){var N,v;const d=(t==null?void 0:t.fddAssignments)||[],m=((N=t==null?void 0:t.participants)==null?void 0:N.filter(w=>{var j,b,C,S;return((j=w.user)==null?void 0:j.role)==="FDD"||((b=w.user)==null?void 0:b.roleCode)==="FDD"||((S=(C=w.user)==null?void 0:C.allRoles)==null?void 0:S.includes("FDD"))}))||[],f=d.length>0||m.length>0,p=(v=m[0])==null?void 0:v.user,h=[{type:"Bank Statement",label:"Bank Statements"},{type:"Income Tax Returns (ITR)",label:"ITR (Last 3 Years)"},{type:"CIBIL Report",label:"CIBIL / Credit Reports"},{type:"Property Documents",label:"Property Documents"},{type:"Business Valuation Report",label:"Valuation Reports"},{type:"FDD Final Audit Report",label:"Final Audit Report"}],x=w=>{const j=w.toLowerCase();return(s||[]).find(b=>{const C=(b.documentType||"").toLowerCase(),S=(b.fileName||"").toLowerCase();return!!(C===j||j.includes("itr")&&(C.includes("itr")||S.includes("itr"))||j.includes("bank statement")&&(C.includes("bank")||S.includes("bank"))||j.includes("cibil")&&(C.includes("cibil")||S.includes("cibil")||C.includes("credit")))})},u=w=>{const j=(w.documentType||"").toLowerCase();return(w.stage||"").toLowerCase()==="fdd"||j.includes("report")||j.includes("itr")||j.includes("bank")||j.includes("cibil")||j.includes("valuation")};return!f&&!["FDD Verification","LOI In Progress","Payment Pending"].includes(t.status)?e.jsx("div",{className:"space-y-6","data-testid":"onboarding-fdd-no-assignment",children:e.jsxs("div",{className:"flex flex-col items-center justify-center p-12 bg-slate-50 rounded-2xl border-2 border-dashed border-slate-200",children:[e.jsx(no,{className:"w-12 h-12 text-slate-300 mb-4"}),e.jsx("h3",{className:"text-slate-900 font-semibold uppercase tracking-widest text-xs",children:"No FDD Assignment"}),e.jsx("p",{className:"text-slate-500 text-[10px] text-center max-w-xs mt-2 font-medium leading-relaxed uppercase tracking-tight",children:"The Financial Due Diligence process has not been initiated for this application yet."})]})}):e.jsxs("div",{className:"space-y-8","data-testid":"onboarding-fdd-audit-content",children:[f&&e.jsx("div",{className:"flex items-center justify-between p-4 bg-slate-50 border border-slate-200 rounded-xl mb-6","data-testid":"onboarding-fdd-assignment-banner",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-red-50 rounded-lg",children:e.jsx(no,{className:"w-5 h-5 text-re-red"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-slate-900",children:"FDD Assignment Active"}),p&&e.jsxs("p",{className:"text-xs text-slate-500 font-medium","data-testid":"onboarding-fdd-assigned-user",children:["Assigned to: ",p.name]})]})]})}),e.jsxs(Le,{className:"border-slate-200 shadow-sm overflow-hidden rounded-2xl","data-testid":"onboarding-fdd-checklist-card",children:[e.jsx(Qe,{className:"bg-slate-50/50 border-b border-slate-100 py-4",children:e.jsxs(Je,{className:"text-sm font-black uppercase tracking-widest text-slate-500 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rc,{className:"w-4 h-4"})," Financial Artefacts Checklist"]}),e.jsx(Ce,{variant:"outline",className:"text-[10px] bg-white",children:"Verify before sign-off"})]})}),e.jsx(Fe,{className:"p-0",children:e.jsx("div",{className:"divide-y divide-slate-100",children:h.map((w,j)=>{const b=x(w.type);return e.jsxs("div",{className:"flex items-center justify-between p-4 px-6 hover:bg-slate-50/50 transition-colors","data-testid":`onboarding-fdd-checklist-item-${j}`,children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:Nt("w-8 h-8 rounded-lg flex items-center justify-center",b?"bg-emerald-50 text-emerald-600":"bg-slate-50 text-slate-300"),children:b?e.jsx(un,{className:"w-5 h-5"}):e.jsx(sn,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-slate-800",children:w.label}),e.jsx("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-tighter","data-testid":`onboarding-fdd-checklist-status-${j}`,children:b?`Uploaded: ${Yt(b.createdAt)}`:"Missing in Documentation"})]})]}),b?e.jsxs(se,{variant:"ghost",size:"sm",className:"h-8 text-blue-600 font-black text-[10px] uppercase tracking-widest hover:bg-blue-50",onClick:()=>{n(b),r(!0)},"data-testid":`onboarding-fdd-checklist-preview-${j}`,children:[e.jsx(yn,{className:"w-4 h-4 mr-1"})," Preview"]}):e.jsxs(se,{variant:"outline",size:"sm",className:"h-8 border-slate-200 text-slate-500 font-black text-[10px] uppercase tracking-widest hover:bg-slate-50 hover:text-blue-600","data-testid":`onboarding-fdd-checklist-upload-${j}`,onClick:()=>{const C=document.createElement("input");C.type="file",C.onchange=async S=>{var _;const R=S.target.files[0];if(R)try{a(!0);const A=new FormData;A.append("file",R),A.append("documentType",w.type),A.append("stage","FDD"),A.append("applicationId",t.id);const E=await hs.uploadDocument(t.id,A);w.type==="FDD Final Audit Report"&&(await hs.submitFddReport({applicationId:t.id,reportDocumentId:((_=E.data)==null?void 0:_.id)||E.id,findings:"Final Audit Report uploaded via checklist.",recommendation:"REVIEW_PENDING"}),i()),te.success(`${w.label} uploaded successfully`),o()}catch{te.error("Upload failed")}finally{a(!1)}},C.click()},children:[e.jsx(or,{className:"w-4 h-4 mr-1 text-slate-300"})," Upload"]})]},w.type)})})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-900",children:"Supporting Audit Documents"}),e.jsxs(Ce,{variant:"outline",className:"bg-slate-50 text-slate-500 border-slate-200","data-testid":"onboarding-fdd-support-docs-count",children:[(s||[]).filter(u).length," Document(s)"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4","data-testid":"onboarding-fdd-support-docs-grid",children:[(s||[]).filter(u).map((w,j)=>e.jsxs("div",{className:"group bg-white border border-slate-200 rounded-xl p-4 flex items-center justify-between hover:border-red-300 transition-all hover:shadow-md","data-testid":`onboarding-fdd-support-doc-${j}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-slate-50 flex items-center justify-center",children:e.jsx(Ns,{className:"w-5 h-5 text-slate-400"})}),e.jsxs("div",{className:"overflow-hidden",children:[e.jsx("p",{className:"text-slate-900 font-bold text-sm truncate max-w-[150px]",title:w.fileName,"data-testid":`onboarding-fdd-support-doc-name-${j}`,children:w.fileName}),e.jsx("p",{className:"text-slate-500 text-[10px] font-medium uppercase",children:w.documentType})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-re-red hover:bg-red-50",onClick:()=>{const b=VU.NEXT_PUBLIC_API_URL||"http://localhost:5000";window.open(`${b}/${w.filePath}`,"_blank")},"data-testid":`onboarding-fdd-support-doc-download-${j}`,children:e.jsx(ji,{className:"w-4 h-4"})}),e.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-re-red hover:bg-red-50",onClick:()=>{n(w),r(!0)},"data-testid":`onboarding-fdd-support-doc-preview-${j}`,children:e.jsx(yn,{className:"w-4 h-4"})})]})]},w.id)),(s||[]).filter(u).length===0&&e.jsx("div",{className:"col-span-full p-8 text-center bg-slate-50 rounded-xl border border-dashed border-slate-200","data-testid":"onboarding-fdd-support-docs-empty",children:e.jsx("p",{className:"text-slate-400 text-sm",children:"No supporting audit documents uploaded yet."})})]})]})]})}function WU(t){const s=String(t||"").toUpperCase();return s.includes("REJECT")||s.includes("DELET")||s.includes("DISQUALIF")?"border-red-200 bg-red-50/90 text-red-800":s==="CREATED"||s.includes("APPROV")||s.includes("COMPLETE")?"border-emerald-200 bg-emerald-50/90 text-emerald-900":s.includes("DOCUMENT")||s.includes("UPLOAD")||s.includes("ATTACHMENT")?"border-sky-200 bg-sky-50/80 text-sky-900":s.includes("PAYMENT")||s.includes("SECURITY")||s.includes("DEPOSIT")?"border-violet-200 bg-violet-50/80 text-violet-900":s.includes("FDD")||s.includes("QUESTIONNAIRE")||s.includes("INTERVIEW")?"border-red-200 bg-red-50/80 text-red-900":"border-slate-200 bg-slate-50 text-slate-700"}function jf(t,s){return t==null||s==null?!1:String(t).trim()===String(s).trim()}function h_(t){return String(t??"").trim().toLowerCase().replace(/\s+/g," ")}function Am(t){const s=h_(t);return s?s==="scheduled"||s==="rescheduled"||s==="pending"||s==="in progress"||s==="inprogress":!1}function GU(t){return h_(t)==="completed"}function Ug(t,s){var n;return!s||!((n=t==null?void 0:t.participants)!=null&&n.length)?!1:t.participants.some(r=>{var a;return jf(r.userId,s)||jf((a=r.user)==null?void 0:a.id,s)})}function KU(t){const s=String(t??"").trim();return{"Level 1 Interview Pending":1,"Level 1 Recommended":1,"Level 2 Interview Pending":2,"Level 2 Recommended":2,"Level 3 Interview Pending":3,"Level 3 Recommended":3}[s]}function RS(t){return String(t??"").trim().toLowerCase().replace(/[_\s-]+/g,"")}function YU(t,s){var d,m;if(!t)return!1;const n=["Super Admin","DD Admin"];if(n.includes(String(t.role??""))||n.includes(String(t.roleCode??"")))return!0;const a={1:["DD-ZM","DD ZM","RBM"],2:["DD Lead","ZBH"],3:["NBH","DD Head"]}[s];if(!(a!=null&&a.length))return!1;const i=a.map(RS),o=[t.role,t.roleCode,t.roleName,(d=t.role)==null?void 0:d.roleCode,(m=t.role)==null?void 0:m.roleName].filter(Boolean).map(RS);for(const f of o)if(f){for(const p of i)if(p&&(f===p||f.includes(p)||p.includes(f)))return!0}return!1}function ZU({application:t,interviews:s,currentUser:n,getDeposit:r,eorProgress:a}){var C,S,R;const i=Array.isArray(s)?s:[],o=KU(t==null?void 0:t.status),d=(o!=null?i.find(_=>Am(_.status)&&Ug(_,n==null?void 0:n.id)&&Number(_.level)===o):void 0)??i.find(_=>Am(_.status)&&Ug(_,n==null?void 0:n.id)),m=o!=null&&n&&YU(n,o)?i.find(_=>Number(_.level)===o&&Am(_.status)):void 0,f=d??m,p=i.find(_=>Ug(_,n==null?void 0:n.id)),h=((C=f==null?void 0:f.evaluations)==null?void 0:C.find(_=>jf(_.evaluatorId,n==null?void 0:n.id)))??((S=p==null?void 0:p.evaluations)==null?void 0:S.find(_=>jf(_.evaluatorId,n==null?void 0:n.id))),x=_=>i.some(A=>Number(A.level)===_&&GU(A.status)),u=_=>i.some(A=>Number(A.level)===_&&Am(A.status)),N=!!h,v={"Level 1 Interview Pending":"INTERVIEW_LEVEL_1","Level 2 Interview Pending":"INTERVIEW_LEVEL_2","Level 2 Recommended":"INTERVIEW_LEVEL_2","Level 3 Interview Pending":"INTERVIEW_LEVEL_3","LOI In Progress":"LOI_APPROVAL","LOA Pending":"LOA_APPROVAL"},w=v[t==null?void 0:t.status],j=(R=t==null?void 0:t.stageApprovals)==null?void 0:R.find(_=>_.stageCode===w&&String(_.actorUserId)===String(n==null?void 0:n.id));return{activeInterviewForUser:f,lastInterviewForUser:p,currentUserEvaluation:h,hasSubmittedFeedback:N,currentUserStageAction:j,isInterviewCompleted:x,isInterviewActive:u,permissions:(()=>{var U,M,z,T,I;if(!t||!n)return{canApprove:!1,canReject:!1,canSchedule:!1,canAssign:!1,isLoaLocked:!1,isSecurityDetailsLocked:!1,showDecisionMessage:!1};const _=["DD Admin","Super Admin","NBH","DD Lead","DD Head","Finance","Finance Admin","FDD","ZBH","RBM"].includes(n.role),A=["Level 3 Approved","FDD Verification","LOI In Progress","Security Deposit","Security Details","Payment Pending","LOI Issued","Statutory LOI Ack","Architecture Team Assigned","Architecture Document Upload","Architecture Team Completion","Statutory GST","Statutory PAN","Statutory Nodal","Statutory Check","Statutory Partnership","Statutory Firm Reg","Statutory Rental","Statutory Virtual Code","Statutory Domain","Statutory MSD","LOA Pending","EOR In Progress","EOR Complete","Inauguration","Approved"].includes(t.status),E=t.status==="LOA Pending"&&((U=r("FIRST_FILL"))==null?void 0:U.status)!=="Verified",q=["Security Deposit","Security Details","Payment Pending"].includes(t.status)&&((M=r("SECURITY_DEPOSIT"))==null?void 0:M.status)!=="Verified",O=t.status==="Onboarded"||t.status==="Rejected",D=(z=t.stageApprovals)==null?void 0:z.some(B=>B.stageCode==="LOI_APPROVAL"&&B.actorRole==="DD Head"&&B.decision==="Approved"),P=(T=t.stageApprovals)==null?void 0:T.some(B=>B.stageCode==="LOA_APPROVAL"&&B.actorRole==="DD Head"&&B.decision==="Approved");let L=!0;["Super Admin","DD Admin","DD Lead","DD Head"].includes(n.role)||((t.status==="FDD Verification"||t.status==="Level 3 Approved")&&(L=!1),t.status==="LOI In Progress"&&(L=n.role==="NBH"?!!D:n.role==="DD Head"),t.status==="LOA Pending"&&(L=n.role==="NBH"?!!P:n.role==="DD Head"));const $=!!((I=t.stageApprovals)!=null&&I.find(B=>v[t.status]===B.stageCode&&String(B.actorUserId)===String(n.id))),Y=["Approved","Rejected","Selected"].includes((h==null?void 0:h.decision)||(h==null?void 0:h.recommendation)||""),Z=(f?Y:!1)||$,W=!O&&!Z&&_&&A&&L&&(!["EOR In Progress","Inauguration","Approved"].includes(t.status)||a===100);return{canApprove:W&&!E&&!q,canReject:W&&!E,isLoaLocked:E,isSecurityDetailsLocked:q,showDecisionMessage:Z&&(!A||$),canSchedule:["DD Admin","Super Admin","DD AM","ASM"].includes(n.role)&&!O&&![1,2,3].every(B=>i.some(G=>G.level===B)),canAssign:["DD Admin","Super Admin","DD AM"].includes(n.role)}})()}}function QU({initialTab:t="questionnaire"}){const[s,n]=g.useState(!1),[r,a]=g.useState(!1),[i,o]=g.useState(""),[d,m]=g.useState(t),[f,p]=g.useState(!1),[h,x]=g.useState(!1),[u,N]=g.useState(!1),[v,w]=g.useState(!1),[j,b]=g.useState(""),[C,S]=g.useState([]),[R,_]=g.useState(!1),[A,E]=g.useState(!1),[q,O]=g.useState(""),[D,P]=g.useState(null),[L,$]=g.useState(!1),[Y,Z]=g.useState(!1),[W,U]=g.useState(!1),[M,z]=g.useState(!1),[T,I]=g.useState(!1),[B,G]=g.useState(null),[K,H]=g.useState("virtual"),[X,J]=g.useState(""),[ae,le]=g.useState({}),[xe,ce]=g.useState([]),[ve,Pe]=g.useState(""),[et,kt]=g.useState("contributor"),[vt,ee]=g.useState(""),[ge,ye]=g.useState("level1"),[Be,$e]=g.useState(""),[dt,st]=g.useState(""),[xt,Mt]=g.useState(!1),[It,he]=g.useState(null),[pt,ht]=g.useState(""),[_e,Vt]=g.useState(null),[Pt,_s]=g.useState(!1),[Ys,Bs]=g.useState(null),[Ks,Qs]=g.useState(!1),[Xs,$s]=g.useState(""),[Q,oe]=g.useState(!1),[we,Oe]=g.useState({}),[ke,je]=g.useState(!1),[Ve,Ge]=g.useState([]),[nt,Zt]=g.useState(!1),[Jt,lt]=g.useState(!1),[mt,Ds]=g.useState(!1),[ss,Ae]=g.useState(""),[be,ut]=g.useState(!1),[He,yt]=g.useState(!1),[ft,es]=g.useState(""),[ts,Cs]=g.useState(""),[Us,rn]=g.useState(!1),[Js,an]=g.useState(!1),[hn,De]=g.useState([]),[bt,Te]=g.useState([]),[ct,tt]=g.useState(""),[jt,Ht]=g.useState(!1),[zt,fs]=g.useState(!1),[qt,As]=g.useState(!1),[vs,cs]=g.useState(!1),[mn,qs]=g.useState({}),[ln,fn]=g.useState({}),[on,Ye]=g.useState(""),[Ot,St]=g.useState("Approve"),[rt,Ft]=g.useState(!1),[jn,xn]=g.useState(null),[qn,En]=g.useState(!1),[Hs,Za]=g.useState(!1),[Pa,Ls]=g.useState("Recommended"),[nn,ta]=g.useState(""),[sa,na]=g.useState(!1),[Ir,Xn]=g.useState(!1),[zn,Qt]=g.useState({}),[Jn,Rr]=g.useState("Approve"),[Wn,Er]=g.useState(!1),[_n,ur]=g.useState({}),[rs,en]=g.useState("Approve"),[va,wi]=g.useState(!1),[Si,Mr]=g.useState(null),[Hr,sr]=g.useState(!1);return{showFirmTypeModal:s,setShowFirmTypeModal:n,updatingFirmType:r,setUpdatingFirmType:a,tempFirmType:i,setTempFirmType:o,activeTab:d,setActiveTab:m,showApproveModal:f,setShowApproveModal:p,showOnboardModal:h,setShowOnboardModal:x,isOnboarding:u,setIsOnboarding:N,showRejectModal:v,setShowRejectModal:w,rejectionReason:j,setRejectionReason:b,scheduledInterviewParticipants:C,setScheduledInterviewParticipants:S,showScheduleModal:R,setShowScheduleModal:_,showCancelInterviewModal:A,setShowCancelInterviewModal:E,interviewIdToCancel:q,setInterviewIdToCancel:O,interviewToReschedule:D,setInterviewToReschedule:P,showKTMatrixModal:L,setShowKTMatrixModal:$,showLevel2FeedbackModal:Y,setShowLevel2FeedbackModal:Z,showLevel3FeedbackModal:W,setShowLevel3FeedbackModal:U,showDocumentsModal:M,setShowDocumentsModal:z,showAssignModal:T,setShowAssignModal:I,selectedStage:B,setSelectedStage:G,interviewMode:K,setInterviewMode:H,approvalRemark:X,setApprovalRemark:J,expandedBranches:ae,setExpandedBranches:le,users:xe,setUsers:ce,selectedUser:ve,setSelectedUser:Pe,participantType:et,setParticipantType:kt,interviewDate:vt,setInterviewDate:ee,interviewType:ge,setInterviewType:ye,meetingLink:Be,setMeetingLink:$e,location:dt,setLocation:st,showUploadForm:xt,setShowUploadForm:Mt,uploadFile:It,setUploadFile:he,uploadDocType:pt,setUploadDocType:ht,approvalFile:_e,setApprovalFile:Vt,isUploading:Pt,setIsUploading:_s,previewDoc:Ys,setPreviewDoc:Bs,showPreviewModal:Ks,setShowPreviewModal:Qs,selectedInterviewerId:Xs,setSelectedInterviewerId:$s,isEditingStatutory:Q,setIsEditingStatutory:oe,statutoryForm:we,setStatutoryForm:Oe,isSavingStatutory:ke,setIsSavingStatutory:je,interviews:Ve,setInterviews:Ge,isScheduling:nt,setIsScheduling:Zt,isCancellingInterview:Jt,setIsCancellingInterview:lt,showAssignArchitectureModal:mt,setShowAssignArchitectureModal:Ds,architectureLeadId:ss,setArchitectureLeadId:Ae,isAssigningArchitecture:be,setIsAssigningArchitecture:ut,showArchitectureStatusModal:He,setShowArchitectureStatusModal:yt,architectureStatus:ft,setArchitectureStatus:es,architectureRemarks:ts,setArchitectureRemarks:Cs,isUpdatingArchitecture:Us,setIsUpdatingArchitecture:rn,isAssigningParticipant:Js,setIsAssigningParticipant:an,documentConfigs:hn,setDocumentConfigs:De,fddAgencies:bt,setFddAgencies:Te,selectedAgencyId:ct,setSelectedAgencyId:tt,isAssigningAgency:jt,setIsAssigningAgency:Ht,showAssignFddModal:zt,setShowAssignFddModal:fs,isApproving:qt,setIsApproving:As,isRejecting:vs,setIsRejecting:cs,ktMatrixScores:mn,setKtMatrixScores:qs,ktMatrixSelectedValues:ln,setKtMatrixSelectedValues:fn,ktMatrixRemarks:on,setKtMatrixRemarks:Ye,ktMatrixRecommendation:Ot,setKtMatrixRecommendation:St,isSubmittingKT:rt,setIsSubmittingKT:Ft,selectedInterviewForFeedback:jn,setSelectedInterviewForFeedback:xn,showFddFinalizeModal:qn,setShowFddFinalizeModal:En,showFddFlagModal:Hs,setShowFddFlagModal:Za,fddAuditRecommendation:Pa,setFddAuditRecommendation:Ls,fddAuditFindings:nn,setFddAuditFindings:ta,isFinalizingFdd:sa,setIsFinalizingFdd:na,isFddFlagging:Ir,setIsFddFlagging:Xn,level2Feedback:zn,setLevel2Feedback:Qt,level2Recommendation:Jn,setLevel2Recommendation:Rr,isSubmittingLevel2:Wn,setIsSubmittingLevel2:Er,level3Feedback:_n,setLevel3Feedback:ur,level3Recommendation:rs,setLevel3Recommendation:en,isSubmittingLevel3:va,setIsSubmittingLevel3:wi,selectedEvaluationForView:Si,setSelectedEvaluationForView:Mr,showFeedbackDetailsModal:Hr,setShowFeedbackDetailsModal:sr}}const m_=()=>new Date().toISOString().split("T")[0],XU=t=>({strategicVision:"",managementCapabilities:"",operationalUnderstanding:"",keyStrengths:"",areasOfConcern:"",additionalComments:"",overallScore:"",interviewerName:(t==null?void 0:t.name)||"",interviewDate:m_()}),JU=t=>({strategicVision:"",managementCapabilities:"",operationalUnderstanding:"",brandAlignment:"",executiveSummary:"",keyStrengths:"",areasOfConcern:"",additionalComments:"",overallScore:"",interviewerName:(t==null?void 0:t.name)||"",interviewDate:m_()});function eV({ktMatrixScores:t,setKtMatrixScores:s,setKtMatrixSelectedValues:n,ktMatrixRemarks:r,setKtMatrixRemarks:a,ktMatrixRecommendation:i,setKtMatrixRecommendation:o,selectedInterviewForFeedback:d,interviews:m,setIsSubmittingKT:f,setShowKTMatrixModal:p,level2Feedback:h,setLevel2Feedback:x,level2Recommendation:u,setLevel2Recommendation:N,setIsSubmittingLevel2:v,setShowLevel2FeedbackModal:w,level3Feedback:j,setLevel3Feedback:b,level3Recommendation:C,setLevel3Recommendation:S,setIsSubmittingLevel3:R,setShowLevel3FeedbackModal:_,currentUser:A,fetchInterviews:E,fetchApplication:q,ktMatrixConfig:O,level2Config:D,level3Config:P}){const L=J=>J==="Approve"?"Recommended":J==="Reject"?"Not Recommended":"Hold",$=J=>J==="Approve"?"Approved":J==="Reject"?"Rejected":null,Y=()=>O!=null&&O.items&&O.items.length>0?O.items.map(J=>({name:J.label,weight:Number(J.weight)||0,maxScore:Number(J.maxScore)||10,options:(J.options||[]).map(ae=>({label:ae.optionLabel,value:ae.optionValue,score:Number(ae.score)||0}))})):[],Z=()=>D!=null&&D.items&&D.items.length>0?D.items:[],W=()=>P!=null&&P.items&&P.items.length>0?P.items:[],U=Y(),M=Z(),z=W();return{handleKTMatrixChange:(J,ae,le)=>{s(xe=>({...xe,[J]:le})),n(xe=>({...xe,[J]:ae}))},calculateKTScore:()=>{let J=0;return U.forEach(ae=>{const le=t[ae.name||ae.label]||0,xe=ae.maxScore||10,ce=ae.weight||0;J+=le/xe*ce}),J.toFixed(2)},handleSubmitKTMatrix:async()=>{var ae,le;if(U.length===0){te.error("KT Matrix configuration is missing. Please configure it in Master > Interview Configurations.");return}if(Object.keys(t).length<U.length){te.warning("Please fill all fields in the KT Matrix");return}const J=(d==null?void 0:d.id)||((ae=m.find(xe=>xe.status!=="Completed"))==null?void 0:ae.id)||((le=m[0])==null?void 0:le.id);if(!J){te.error("No active interview found to link this KT Matrix to.");return}try{f(!0);const xe=U.map(ve=>({criterionName:ve.name||ve.label,score:t[ve.name||ve.label]||0,maxScore:ve.maxScore||10,weightage:ve.weight||0}));await hs.submitKTMatrix({interviewId:J,criteriaScores:xe,feedback:r,recommendation:L(i)});const ce=$(i);ce&&await hs.updateInterviewDecision({interviewId:J,decision:ce,remarks:r||`Level 1 ${ce.toLowerCase()} via KT Matrix`}),te.success(ce?`KT Matrix submitted and interview ${ce.toLowerCase()}`:"KT Matrix submitted and interview kept on hold"),p(!1),s({}),n({}),a(""),o("Approve"),await E(),await q()}catch{te.error("Failed to submit KT Matrix")}finally{f(!1)}},handleLevel2Change:(J,ae)=>{x(le=>({...le,[J]:ae}))},handleSubmitLevel2Feedback:async()=>{var ae;if(M.length===0){te.error("Level 2 feedback configuration is missing. Please configure it in Master > Interview Configurations.");return}if(!h.overallScore){te.warning("Please provide an overall score.");return}const J=(d==null?void 0:d.id)||((ae=m.find(le=>le.status!=="Completed"&&le.level===2))==null?void 0:ae.id);if(!J){te.error("No active Level 2 interview found to link this feedback to.");return}try{v(!0);const le=M.map(ve=>({type:ve.label,comments:h[ve.itemKey]||""})).filter(ve=>ve.comments.trim()!=="");await hs.submitLevel2Feedback({interviewId:J,overallScore:Number(h.overallScore),feedbackItems:le,recommendation:L(u)});const xe=$(u),ce=h.additionalComments||"Level 2 decision submitted via feedback modal";xe&&await hs.updateInterviewDecision({interviewId:J,decision:xe,remarks:ce}),te.success(xe?`Level 2 feedback submitted and interview ${xe.toLowerCase()}`:"Level 2 feedback submitted and interview kept on hold"),w(!1),x(XU(A)),N("Approve"),await E(),await q()}catch{te.error("Failed to submit Level 2 Feedback")}finally{v(!1)}},handleLevel3Change:(J,ae)=>{b(le=>({...le,[J]:ae}))},handleSubmitLevel3Feedback:async()=>{var ae;if(z.length===0){te.error("Level 3 feedback configuration is missing. Please configure it in Master > Interview Configurations.");return}if(!j.overallScore){te.warning("Please provide an overall score.");return}const J=(d==null?void 0:d.id)||((ae=m.find(le=>le.status!=="Completed"&&le.level===3))==null?void 0:ae.id);if(!J){te.error("No active Level 3 interview found to link this feedback to.");return}try{R(!0);const le=z.map(ve=>({type:ve.label,comments:j[ve.itemKey]||""})).filter(ve=>ve.comments.trim()!=="");await hs.submitLevel2Feedback({interviewId:J,overallScore:Number(j.overallScore),feedbackItems:le,recommendation:L(C)});const xe=$(C),ce=j.executiveSummary||j.additionalComments||"Level 3 decision submitted via feedback modal";xe&&await hs.updateInterviewDecision({interviewId:J,decision:xe,remarks:ce}),te.success(xe?`Level 3 feedback submitted and interview ${xe.toLowerCase()}`:"Level 3 feedback submitted and interview kept on hold"),_(!1),b(JU(A)),S("Approve"),await E(),await q()}catch{te.error("Failed to submit Level 3 Feedback")}finally{R(!1)}},ktCriteria:U,l2Fields:M,l3Fields:z}}function tV(){const[t,s]=g.useState(null),[n,r]=g.useState(null),[a,i]=g.useState(null),[o,d]=g.useState(!1),[m,f]=g.useState(null),p=g.useCallback(async x=>{var u,N;try{const v=await Ee.getInterviewConfigByType(x);if((u=v.data)!=null&&u.success)return v.data.data}catch(v){((N=v==null?void 0:v.response)==null?void 0:N.status)!==404&&console.warn(`Failed to fetch ${x} config:`,v)}return null},[]),h=g.useCallback(async()=>{d(!0),f(null);try{const[x,u,N]=await Promise.all([p("KT_MATRIX"),p("LEVEL2_FEEDBACK"),p("LEVEL3_FEEDBACK")]);s(x),r(u),i(N)}catch{f("Failed to load interview configurations"),te.error("Failed to load interview configurations")}finally{d(!1)}},[p]);return g.useEffect(()=>{h()},[h]),{ktMatrixConfig:t,level2Config:n,level3Config:a,loading:o,error:m,refresh:h}}function sV(t){const{application:s,applicationId:n,currentUser:r,interviews:a,approvalFile:i,approvalRemark:o,rejectionReason:d,architectureLeadId:m,architectureStatus:f,architectureRemarks:p,selectedUser:h,participantType:x,users:u,interviewDate:N,setInterviewDate:v,interviewType:w,setInterviewType:j,interviewMode:b,setInterviewMode:C,meetingLink:S,setMeetingLink:R,location:_,setLocation:A,scheduledInterviewParticipants:E,uploadFile:q,uploadDocType:O,selectedStage:D,setIsApproving:P,setShowApproveModal:L,setApprovalRemark:$,setApprovalFile:Y,setIsRejecting:Z,setShowRejectModal:W,setRejectionReason:U,setIsAssigningArchitecture:M,setShowAssignArchitectureModal:z,setIsUpdatingArchitecture:T,setShowArchitectureStatusModal:I,setIsAssigningParticipant:B,setSelectedUser:G,setShowAssignModal:K,setLoading:H,setIsScheduling:X,setShowScheduleModal:J,setShowCancelInterviewModal:ae,interviewIdToCancel:le,setInterviewIdToCancel:xe,interviewToReschedule:ce,setInterviewToReschedule:ve,setIsCancellingInterview:Pe,setIsUploading:et,setShowUploadForm:kt,setUploadFile:vt,setUploadDocType:ee,setDocuments:ge,selectedInterviewerId:ye,setSelectedInterviewerId:Be,setScheduledInterviewParticipants:$e,setUsers:dt,showScheduleModal:st,showAssignArchitectureModal:xt,showAssignModal:Mt,fetchApplication:It,fetchInterviews:he,fetchEorData:pt}=t,ht=()=>{if(!ye)return;const Ge=(Array.isArray(u)?u:[]).find(nt=>nt.id===ye);Ge&&!E.find(nt=>nt.id===Ge.id)&&($e([...E,Ge]),Be(""))},_e=Ve=>{$e(E.filter(Ge=>Ge.id!==Ve))},Vt=g.useCallback(async Ve=>{if(!(!r||!["DD Admin","Super Admin","DD Lead","DD Head","NBH"].includes(r.role)))try{const Ge={};if(Ve){const lt={level1:["DD-ZM","RBM"],level2:["DD Lead","ZBH"],level3:["NBH","DD Head"]};lt[Ve]&&(Ge.preferredRoleCode=lt[Ve]),s&&(Ge.locationId=s.districtId||s.areaId||s.regionId||s.zoneId)}Ge.isExternal=!1;const nt=await hs.getUsers(Ge),Jt=(Array.isArray(nt)?nt:nt&&Array.isArray(nt.data)?nt.data:nt&&Array.isArray(nt.users)?nt.users:[]).filter(lt=>(lt.status||"").toLowerCase()!=="inactive");dt(Jt.sort((lt,mt)=>String(lt.fullName||lt.name||"").localeCompare(String(mt.fullName||mt.name||""))))}catch{dt([])}},[r,s,dt]),Pt=g.useCallback(()=>{if(!st||!s||ce)return;const Ve=parseInt(w.replace("level",""))||1,Ge={1:["DD-ZM","RBM"],2:["DD Lead","ZBH"],3:["NBH","DD Head"]},nt=ss=>String(ss||"").trim().toLowerCase().replace(/[_\s-]+/g," "),Zt=(Ge[Ve]||[]).map(nt),Jt=(ss,Ae)=>{var He,yt,ft;const be=[(He=ss==null?void 0:ss.metadata)==null?void 0:He.role,(yt=Ae==null?void 0:Ae.role)==null?void 0:yt.roleName,(ft=Ae==null?void 0:Ae.role)==null?void 0:ft.roleCode,Ae==null?void 0:Ae.roleCode,Ae==null?void 0:Ae.role].filter(Boolean),ut=be.find(es=>Zt.includes(nt(es)));return String(ut||be[0]||"Panelist")},lt=((s==null?void 0:s.participants)||[]).filter(ss=>{var Ae,be,ut,He,yt,ft,es,ts,Cs;return((Ae=ss.metadata)==null?void 0:Ae.interviewLevel)===Ve||((be=ss.metadata)==null?void 0:be.interviewLevel)===String(Ve)||((He=(ut=ss.metadata)==null?void 0:ut.allAssignments)==null?void 0:He.includes(Ve))||((ft=(yt=ss.metadata)==null?void 0:yt.allAssignments)==null?void 0:ft.includes(String(Ve)))||Zt.includes(nt((es=ss.user)==null?void 0:es.role))||Zt.includes(nt((ts=ss.user)==null?void 0:ts.roleCode))||Zt.includes(nt((Cs=ss.metadata)==null?void 0:Cs.role))}).map(ss=>{const Ae=ss.user||{};return{...Ae,__stageRole:Jt(ss,Ae)}}).filter(ss=>!!(ss!=null&&ss.id));if(lt.length===0){$e([]);return}const mt=[],Ds=new Set;lt.forEach(ss=>{ss.id&&!Ds.has(ss.id)&&(Ds.add(ss.id),mt.push(ss))}),$e(mt)},[st,s,w,ce,$e]),_s=async()=>{if(!N){te.warning("Please select date and time");return}try{X(!0);const Ve={applicationId:s==null?void 0:s.id,level:w,scheduledAt:N,type:b==="virtual"?"Virtual Interview":"Physical Interview",location:b==="virtual"?S:_,participants:E.map(Ge=>Ge.id)};ce?(await hs.updateInterview(ce.id,{...Ve,status:"Scheduled"}),te.success("Interview rescheduled successfully")):(await hs.scheduleInterview(Ve),te.success("Interview scheduled successfully")),J(!1),ve(null),await he(),await It()}catch{te.error(ce?"Failed to reschedule interview":"Failed to schedule interview")}finally{X(!1)}},Ys=async Ve=>{xe(Ve),ae(!0)},Bs=async Ve=>{var nt,Zt;ve(Ve),j(`level${Ve.level}`),C((nt=Ve.interviewType)!=null&&nt.toLowerCase().includes("virtual")?"virtual":"physical"),v(Ve.scheduleDate?(()=>{const Jt=new Date(Ve.scheduleDate);return new Date(Jt.getTime()-Jt.getTimezoneOffset()*6e4).toISOString().slice(0,16)})():""),(Zt=Ve.interviewType)!=null&&Zt.toLowerCase().includes("virtual")?R(Ve.linkOrLocation||""):A(Ve.linkOrLocation||"");const Ge=(Ve.participants||[]).map(Jt=>Jt.user||Jt).filter(Boolean);$e(Ge),J(!0)},Ks=async()=>{if(le)try{Pe(!0),await hs.updateInterview(le,{status:"Cancelled"}),te.success("Interview cancelled successfully"),ae(!1),xe(""),await he()}catch{te.error("Failed to cancel interview")}finally{Pe(!1)}},Qs=async()=>{var Ve;if(!q||!O){te.warning("Please enter a document name and select a file");return}try{et(!0);const Ge=new FormData,nt=((Ve=q.name.match(/\.[^/.]+$/))==null?void 0:Ve[0])||"",Zt=O.trim(),Jt=Zt.toLowerCase().endsWith(nt.toLowerCase())?Zt:`${Zt}${nt}`;Ge.append("file",q,Jt);const lt=D!=null&&D.startsWith("EOR: ")?D.replace(/^EOR:\s*/,""):null;Ge.append("documentType",lt||"Other"),D&&Ge.append("stage",D),await hs.uploadDocument(n,Ge),te.success("Document uploaded successfully"),kt(!1),vt(null),ee("");const mt=await hs.getDocuments(n);ge(mt||[]),await pt()}catch{te.error("Failed to upload document")}finally{et(!1)}},Xs=async()=>{var Ve;try{P(!0);const Ge=a.find(lt=>{var mt;return lt.status!=="Completed"&&lt.status!=="Cancelled"&&((mt=lt.participants)==null?void 0:mt.some(Ds=>Ds.userId===(r==null?void 0:r.id)))});if(i&&n)try{const lt=new FormData;lt.append("file",i),lt.append("documentType","Approval Attachment");let mt=null;Ge&&(Ge.level===1||Ge.level==="1"?mt="1st Level Interview":Ge.level===2||Ge.level==="2"?mt="2nd Level Interview":(Ge.level===3||Ge.level==="3")&&(mt="3rd Level Interview")),mt||(s.status==="Shortlisted"||s.status==="Level 1 Interview Pending"?mt="1st Level Interview":s.status==="Level 1 Approved"||s.status==="Level 2 Interview Pending"?mt="2nd Level Interview":(s.status==="Level 2 Approved"||s.status==="Level 3 Interview Pending")&&(mt="3rd Level Interview")),mt&&lt.append("stage",mt),await hs.uploadDocument(n,lt)}catch{te.error("Failed to upload document")}if(Ge)try{await hs.updateInterviewDecision({interviewId:Ge.id,decision:"Approved",remarks:o}),te.success("Interview approved successfully"),L(!1),$(""),Y(null),await he(),await It();return}catch{te.error("Failed to approve interview");return}if(!o.trim()){te.warning("Please enter a remark");return}let nt=s.status;switch(s.status){case"Shortlisted":case"Level 1 Interview Pending":nt="Level 1 Approved";break;case"Level 1 Approved":case"Level 2 Interview Pending":nt="Level 2 Approved";break;case"Level 2 Approved":case"Level 3 Interview Pending":nt="Level 3 Approved";break;case"Level 3 Approved":nt="FDD Verification";break;case"FDD Verification":nt="LOI In Progress";break;case"LOI In Progress":nt="Security Deposit";break;case"Security Deposit":case"Security Details":case"Payment Pending":nt="LOI Issued";break;case"LOI Issued":nt="Dealer Code Generation";break;case"Dealer Code Generation":case"Architecture Team Assigned":case"Architecture Document Upload":case"Architecture Team Completion":case"Statutory GST":case"Statutory PAN":case"Statutory Nodal":case"Statutory Check":case"Statutory Partnership":case"Statutory Firm Reg":case"Statutory Rental":case"Statutory Virtual Code":case"Statutory Domain":case"Statutory MSD":case"Statutory LOI Ack":nt="LOA Pending";break;case"LOA Pending":nt="EOR In Progress";break;case"EOR In Progress":nt="EOR Complete";break;case"EOR Complete":nt="Inauguration";break;case"Inauguration":case"Approved":nt="Onboarded";break;default:nt="Onboarded"}const Jt={"Level 1 Interview Pending":"INTERVIEW_LEVEL_1","Level 2 Interview Pending":"INTERVIEW_LEVEL_2","Level 2 Recommended":"INTERVIEW_LEVEL_2","Level 3 Interview Pending":"INTERVIEW_LEVEL_3","LOI In Progress":"LOI_APPROVAL","LOA Pending":"LOA_APPROVAL"}[s.status];if(Jt){const lt=await hs.submitStageDecision({applicationId:s.id,stageCode:Jt,decision:"Approved",remarks:o,nextStatus:nt});(Ve=lt.data)!=null&&Ve.statusUpdated?te.success(lt.message||"Stage completed and moved to next step"):te.info(lt.message||"Approval recorded. Waiting for other mandatory approvers.")}else await hs.updateApplicationStatus(n,{status:nt,remarks:o});nt==="Onboarded"?(await hs.createDealer({applicationId:n}),te.success("Application finalized and Dealer profile created!")):te.success(`Application moved to ${nt}`),L(!1),$(""),Y(null),await It()}catch(Ge){te.error(Ge.message||"Failed to process approval")}finally{P(!1)}},$s=async()=>{try{Z(!0);const Ve=a.find(Zt=>{var Jt;return Zt.status!=="Completed"&&Zt.status!=="Cancelled"&&((Jt=Zt.participants)==null?void 0:Jt.some(lt=>lt.userId===(r==null?void 0:r.id)))});if(Ve)try{await hs.updateInterviewDecision({interviewId:Ve.id,decision:"Rejected",remarks:d}),te.success("Interview rejected"),W(!1),U(""),await he(),await It();return}catch{te.error("Failed to reject interview");return}if(!d.trim()){te.warning("Please enter a reason for rejection");return}const nt={"Level 1 Interview Pending":"INTERVIEW_LEVEL_1","Level 2 Interview Pending":"INTERVIEW_LEVEL_2","Level 2 Recommended":"INTERVIEW_LEVEL_2","Level 3 Interview Pending":"INTERVIEW_LEVEL_3","LOI In Progress":"LOI_APPROVAL","LOA Pending":"LOA_APPROVAL"}[s.status];nt?await hs.submitStageDecision({applicationId:s.id,stageCode:nt,decision:"Rejected",remarks:d,interviewId:Ve==null?void 0:Ve.id}):await hs.updateApplicationStatus(n,{status:"Rejected",remarks:d}),te.success("Application rejected"),W(!1),U(""),await It()}catch(Ve){te.error(Ve.message||"Failed to process rejection")}finally{Z(!1)}},Q=async()=>{try{await hs.generateDealerCodes(n),te.success("Dealer codes generated successfully"),await It()}catch(Ve){te.error(Ve.message||"Failed to generate dealer codes")}},oe=async()=>{if(!m){te.warning("Please select an architecture lead");return}try{M(!0),await hs.assignArchitectureTeam(n,m),te.success("Architecture team assigned successfully"),z(!1),await It()}catch(Ve){te.error(Ve.message||"Failed to assign architecture team")}finally{M(!1)}},we=async()=>{try{T(!0),await hs.updateArchitectureStatus(n,f,p),te.success("Architecture status updated successfully"),I(!1),await It()}catch{te.error("Failed to update architecture status")}finally{T(!1)}},Oe=async()=>{if(!h){te.warning("Please select a user");return}try{B(!0);const Ve=Array.isArray(u)?u.find(Ge=>Ge.id===h):null;Ve&&(Ve.role==="FDD"||Ve.roleCode==="FDD")&&(await hs.assignFddAgency({applicationId:n,assignedToAgency:h}),te.info(`${Ve.fullName||Ve.name} assigned as FDD Agency based on role.`)),await hs.addParticipant({requestId:n,requestType:"application",userId:h,participantType:x||"contributor"}),te.success("User assigned successfully!"),await It(),G(""),K(!1)}catch{te.error("Failed to assign user")}finally{B(!1)}},ke=async()=>{try{H(!0),await hs.retriggerEvaluators(n),te.success("Evaluators re-assigned successfully"),await It()}catch{te.error("Failed to re-assign evaluators")}finally{H(!1)}},je=g.useCallback(async()=>{if(st&&s){await Vt(w),Pt();return}(xt||Mt)&&s&&await Vt()},[st,xt,Mt,s,w,Vt,Pt]);return{handleAddInterviewer:ht,handleRemoveInterviewer:_e,fetchUsers:Vt,maybeFetchUsersForModal:je,handleScheduleInterview:_s,handleRescheduleInterview:Bs,handleCancelInterview:Ys,handleConfirmCancelInterview:Ks,handleUpload:Qs,handleApprove:Xs,handleReject:$s,handleGenerateDealerCodes:Q,handleAssignArchitecture:oe,handleUpdateArchitectureStatus:we,handleAddParticipant:Oe,handleRetriggerEvaluators:ke}}const f_={getChecklist:async(t,s)=>{const n=s?`/eor/relocation/${s}`:`/eor/application/${t}`;return(await qe.get(n)).data},createChecklist:async t=>(await qe.post("/eor",t)).data,updateItem:async(t,s)=>(await qe.post(`/eor/item/${t}`,s)).data,submitAudit:async(t,s)=>(await qe.post(`/eor/audit/${t}`,s)).data},Vg=Object.freeze(Object.defineProperty({__proto__:null,eorService:f_},Symbol.toStringTag,{value:"Module"})),nV={getAuditLogs:async(t,s,n=1,r=50)=>{var a;try{const i=await Ee.getAuditLogs(t,s,n,r);return((a=i.data)==null?void 0:a.data)||i.data||[]}catch(i){throw console.error("Get audit logs error:",i),i}},getAuditSummary:async(t,s)=>{var n;try{const r=await Ee.getAuditSummary(t,s);return((n=r.data)==null?void 0:n.data)||r.data}catch(r){throw console.error("Get audit summary error:",r),r}}},rV={getWorknotes:async(t,s)=>{var r,a;const n=await Ee.getWorknotes(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to fetch worknotes");return((a=n.data)==null?void 0:a.data)||n.data},addWorknote:async t=>{var n,r;const s=await Ee.addWorknote(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to add worknote");return((r=s.data)==null?void 0:r.data)||s.data},addParticipant:async t=>{var n;const s=await Ee.addParticipant(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to add participant");return s.data},removeParticipant:async t=>{var n;const s=await Ee.removeParticipant(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to remove participant");return s.data}};function aV({applicationId:t}){const[s,n]=g.useState(null),[r,a]=g.useState(!0),[i,o]=g.useState([]),[d,m]=g.useState(null),[f,p]=g.useState([]),[h,x]=g.useState(!1),[u,N]=g.useState([]),[v,w]=g.useState([]),[j,b]=g.useState({}),C=g.useCallback(async()=>{try{const A=await hs.getDocuments(t);o(A||[])}catch(A){console.error("Failed to refresh documents:",A)}},[t]),S=g.useCallback(async(A=!1)=>{try{A||a(!0);const E=await hs.getApplicationById(t),q=(D,P)=>{var $;const L=($=E.progressTracking)==null?void 0:$.find(Y=>Y.stageName===D);if(L!=null&&L.stageCompletedAt)return new Date(L.stageCompletedAt).toISOString();if(L!=null&&L.stageStartedAt)return new Date(L.stageStartedAt).toISOString();if(P){const Y=(E.statusHistory||[]).find(Z=>Z.newStatus===P);if(Y)return new Date(Y.createdAt).toISOString()}},O={id:E.id,registrationNumber:E.applicationId||"N/A",name:E.applicantName,email:E.email,phone:E.phone,age:E.age,education:E.education,residentialAddress:E.address||E.city||"",businessAddress:E.address||"",preferredLocation:E.preferredLocation,state:E.state,ownsBike:E.ownRoyalEnfield==="yes",pastExperience:E.experienceYears?`${E.experienceYears} years`:E.description||"",status:E.overallStatus,questionnaireMarks:E.score||E.questionnaireMarks||0,questionnaireResponses:E.questionnaireResponses||[],rank:0,totalApplicantsAtLocation:0,assignedUsers:[],progress:E.progressPercentage||0,isShortlisted:E.isShortlisted||!0,companyName:E.companyName,source:E.source,existingDealer:E.existingDealer,royalEnfieldModel:E.royalEnfieldModel,description:E.description,pincode:E.pincode,locationType:E.locationType,ownRoyalEnfield:E.ownRoyalEnfield,address:E.address,submissionDate:E.createdAt?new Date(E.createdAt).toISOString():"",questionnaireDate:q("Questionnaire","Questionnaire Completed")||q("Questionnaire","Questionnaire Pending"),shortlistDate:q("Shortlist","Shortlisted"),level1InterviewDate:q("1st Level Interview","Level 1 Approved"),level2InterviewDate:q("2nd Level Interview","Level 2 Approved"),level3InterviewDate:q("3rd Level Interview","Level 3 Approved"),fddDate:q("FDD","FDD Verification"),loiApprovalDate:q("LOI Approval","LOI In Progress"),securityDetailsDate:q("Security Deposit","Security Deposit")||q("Security Details","Security Details"),loiIssueDate:q("LOI Issue","LOI Issued"),dealerCodeDate:q("Dealer Code Generation","Dealer Code Generation"),architectureAssignedDate:q("Architecture Team Assigned","Architecture Team Assigned"),architectureDocumentDate:q("Architecture Document Upload","Architecture Document Upload"),architectureCompletionDate:q("Architecture Team Completion","Architecture Team Completion"),loaDate:q("LOA","LOA Pending"),eorCompleteDate:q("EOR Complete","EOR Complete"),inaugurationDate:q("Inauguration","Inauguration"),onboardedDate:E.overallStatus==="Onboarded"?E.updatedAt?new Date(E.updatedAt).toISOString():new Date().toISOString():void 0,progressTracking:E.progressTracking||[],participants:E.participants||[],dealerCode:E.dealerCode,zoneId:E.zoneId,regionId:E.regionId,areaId:E.areaId,districtId:E.districtId,stageApprovals:E.stageApprovals||[],fddAssignments:E.fddAssignments||[],constitutionType:E.constitutionType,architectureStatus:E.architectureStatus,statutoryStatus:E.statutoryStatus,panNumber:E.panNumber,gstNumber:E.gstNumber,bankName:E.bankName,accountNumber:E.accountNumber,ifscCode:E.ifscCode,branchName:E.branchName,accountHolderName:E.accountHolderName,registeredAddress:E.registeredAddress};n(O),E.uploadedDocuments&&o(E.uploadedDocuments||[])}catch(E){console.error("Failed to fetch application details",E)}finally{a(!1)}},[t]),R=g.useCallback(async()=>{if(t)try{const A=await f_.getChecklist(t);A.success&&A.data&&m(A.data)}catch{m(null)}},[t]),_=A=>v.find(E=>E.depositType===A);return g.useEffect(()=>{t&&(S(),C())},[t]),g.useEffect(()=>{t&&R()},[t,s==null?void 0:s.status]),g.useEffect(()=>{if(!(s!=null&&s.id))return;(async()=>{x(!0);try{const E=await nV.getAuditLogs("application",s.id,1,100);p(Array.isArray(E)?E:[])}catch{p([])}finally{x(!1)}try{const E=await rV.getWorknotes("application",s.id);N(E.data||[])}catch{N([])}})()},[s==null?void 0:s.id]),g.useEffect(()=>{if(!t)return;(async()=>{try{const[E,q]=await Promise.all([hs.getSecurityDeposit(t),hs.getSystemConfigs({category:"SECURITY_DEPOSIT",format:"map"})]);w(Array.isArray(E)?E:[E].filter(Boolean)),b(q||{})}catch(E){console.error("Failed to fetch payment data",E)}})()},[t]),{application:s,loading:r,setLoading:a,documents:i,setDocuments:o,eorData:d,auditLogs:f,auditLoading:h,worknotes:u,deposits:v,paymentConfigs:j,refreshDocuments:C,fetchApplication:S,fetchEorData:R,getDeposit:_}}function iV({application:t,applicationId:s,tempFirmType:n,setUpdatingFirmType:r,setShowFirmTypeModal:a,setStatutoryForm:i,setIsEditingStatutory:o,setIsSavingStatutory:d,statutoryForm:m,setFddAgencies:f,selectedAgencyId:p,setIsAssigningAgency:h,fetchApplication:x}){const u=async()=>{try{r(!0),await hs.updateApplication(s,{constitutionType:n}),te.success("Firm type updated successfully"),a(!1),await x()}catch{te.error("Failed to update firm type")}finally{r(!1)}},N=()=>{t&&(i({accountHolderName:t.accountHolderName||"",panNumber:t.panNumber||"",gstNumber:t.gstNumber||"",bankName:t.bankName||"",accountNumber:t.accountNumber||"",ifscCode:t.ifscCode||"",registeredAddress:t.registeredAddress||""}),o(!0))},v=async()=>{try{d(!0),await hs.updateApplication(s,m),te.success("Statutory & Bank details updated successfully"),o(!1),await x(!0)}catch{te.error("Failed to update details")}finally{d(!1)}},w=g.useCallback(async()=>{try{const b=await hs.getUsers({roleCode:"FDD"});f(Array.isArray(b)?b:[])}catch{f([])}},[f]);return{handleUpdateFirmType:u,handleEditStatutory:N,handleSaveStatutory:v,fetchFddAgencies:w,handleAssignAgency:async()=>{if(!p){te.warning("Please select an agency");return}try{h(!0),await hs.assignFddAgency({applicationId:(t==null?void 0:t.id)||s,assignedToAgency:p}),await hs.addParticipant({requestId:(t==null?void 0:t.id)||s,requestType:"application",userId:p,participantType:"contributor"}),te.success("FDD Agency assigned and added as participant"),await x()}catch{te.error("Failed to assign agency")}finally{h(!1)}}}}function lV({application:t,documents:s,interviews:n,eorData:r,getDeposit:a,documentConfigs:i=[]}){var w;const o=j=>String(j||"").trim().toLowerCase().replace(/[_\s-]+/g," "),d=(j,b)=>{var R,_,A;const C=[(R=j==null?void 0:j.user)==null?void 0:R.role,(_=j==null?void 0:j.user)==null?void 0:_.roleCode,(A=j==null?void 0:j.metadata)==null?void 0:A.role].map(o),S=b.map(o);return C.some(E=>S.includes(E))},m=j=>{var b,C,S,R,_;return`${((b=j==null?void 0:j.user)==null?void 0:b.fullName)||((C=j==null?void 0:j.user)==null?void 0:C.name)||"User"} (${((S=j==null?void 0:j.user)==null?void 0:S.role)||((R=j==null?void 0:j.user)==null?void 0:R.roleCode)||((_=j==null?void 0:j.metadata)==null?void 0:_.role)||(j==null?void 0:j.participantType)||"participant"})`},f=j=>(s||[]).some(b=>b.documentType===j),p=()=>{const j=t.progressTracking||[],b=j.find(C=>C.stageName==="Security Deposit")||j.find(C=>C.stageName==="Security Details");return b!=null&&b.status?b.status:"pending"},h=(j,b="pending")=>{const C=(t.progressTracking||[]).find(S=>S.stageName===j);return C!=null&&C.status?C.status:b},x=[{id:1,name:"Submitted",status:"completed",date:t.submissionDate,description:"Application submitted",documentsUploaded:3},{id:2,name:"Questionnaire",status:h("Questionnaire"),date:t.questionnaireDate,description:"Questionnaire completed",documentsUploaded:0},{id:3,name:"Shortlist",status:h("Shortlist"),date:t.shortlistDate,description:"Application shortlisted by DD",evaluators:Array.from(new Set((t.participants||[]).filter(j=>j.participantType==="assignee").map(j=>{var b,C,S;return`${((b=j.user)==null?void 0:b.fullName)||((C=j.user)==null?void 0:C.name)||"User"} (${((S=j.user)==null?void 0:S.roleCode)||j.participantType})`}))),documentsUploaded:2},{id:4,name:"1st Level Interview",status:h("1st Level Interview"),date:t.level1InterviewDate,description:"DD-ZM + RBM evaluation",evaluators:Array.from(new Set((t.participants||[]).filter(j=>{var b,C,S,R,_,A;return((b=j.metadata)==null?void 0:b.interviewLevel)===1||((C=j.metadata)==null?void 0:C.interviewLevel)==="1"||((R=(S=j.metadata)==null?void 0:S.allAssignments)==null?void 0:R.includes(1))||((A=(_=j.metadata)==null?void 0:_.allAssignments)==null?void 0:A.includes("1"))||d(j,["DD-ZM","RBM"])}).map(m))),documentsUploaded:1},{id:5,name:"2nd Level Interview",status:h("2nd Level Interview"),date:t.level2InterviewDate,description:"DD Lead + ZBH evaluation",evaluators:Array.from(new Set((t.participants||[]).filter(j=>{var b,C,S,R,_,A;return((b=j.metadata)==null?void 0:b.interviewLevel)===2||((C=j.metadata)==null?void 0:C.interviewLevel)==="2"||((R=(S=j.metadata)==null?void 0:S.allAssignments)==null?void 0:R.includes(2))||((A=(_=j.metadata)==null?void 0:_.allAssignments)==null?void 0:A.includes("2"))||d(j,["DD Lead","ZBH"])}).map(m))),documentsUploaded:1},{id:6,name:"3rd Level Interview",status:h("3rd Level Interview"),date:t.level3InterviewDate,description:"NBH + DD Head evaluation",evaluators:Array.from(new Set((t.participants||[]).filter(j=>{var b,C,S,R,_,A;return((b=j.metadata)==null?void 0:b.interviewLevel)===3||((C=j.metadata)==null?void 0:C.interviewLevel)==="3"||((R=(S=j.metadata)==null?void 0:S.allAssignments)==null?void 0:R.includes(3))||((A=(_=j.metadata)==null?void 0:_.allAssignments)==null?void 0:A.includes("3"))||d(j,["NBH","DD Head"])}).map(m))),documentsUploaded:2},{id:7,name:"FDD",status:h("FDD"),date:t.fddDate,description:"Financial Due Diligence",documentsUploaded:5},{id:8,name:"LOI Approval",status:h("LOI Approval"),date:t.loiApprovalDate,description:"Letter of Intent approval",evaluators:Array.from(new Set((t.participants||[]).filter(j=>{var b,C,S;return((b=j.metadata)==null?void 0:b.stageCode)==="LOI_APPROVAL"||((S=(C=j.metadata)==null?void 0:C.allAssignments)==null?void 0:S.includes("LOI_APPROVAL"))}).map(m))),documentsUploaded:1},{id:9,name:"Security Deposit",status:p(),date:t.securityDetailsDate,description:"Security Deposit verification",documentsUploaded:3},{id:10,name:"LOI Issue",status:h("LOI Issue"),date:t.loiIssueDate,description:"Letter of Intent issued",isParallel:!0,branches:[{name:"LOI Documents",color:"green",stages:i.some(j=>j.stageCode==="LOI Issue")?i.filter(j=>j.stageCode==="LOI Issue").map((j,b)=>({id:`10a-${b}`,name:j.documentType,status:f(j.documentType)?"completed":"active",description:j.isMandatory?`Upload ${j.documentType} (Mandatory)`:`Upload ${j.documentType}`})):[{id:"10a-1",name:"Letter of Intent",status:f("Letter of Intent")||f("LOI")?"completed":"active",description:"Letter of Intent document"},{id:"10a-2",name:"Signed LOI",status:f("Signed LOI")||f("LOI Signed Copy")?"completed":"active",description:"Signed Letter of Intent"}]}]},{id:11,name:"Dealer Code Generation",status:h("Dealer Code Generation"),date:t.dealerCodeDate,description:"Dealer code generated and assigned",isParallel:!0,branches:[{name:"Architectural Work",color:"green",stages:[{id:"11a-1",name:"Architecture Assignment",status:t.architectureAssignedTo?"completed":t.status==="Architecture Team Assigned"?"active":"pending",description:"Assigned to architecture team"},{id:"11a-2",name:"Site Plan Blueprint",status:f("Architecture Blueprint")?"completed":t.architectureAssignedTo?"active":"pending",description:"Blueprints and site plans"},{id:"11a-3",name:"Architecture Work",status:t.architectureStatus==="COMPLETED"?"completed":t.architectureStatus==="IN_PROGRESS"||f("Architecture Blueprint")?"active":"pending",description:"Final architecture approval"}]},{name:"Statutory Documents",color:"green",stages:[{id:"11b-1",name:"GST",status:f("GST Certificate")||f("GST")?"completed":"active",description:"GST certificate"},{id:"11b-2",name:"PAN",status:f("PAN Card")||f("PAN")?"completed":"active",description:"PAN card"},{id:"11b-3",name:"Nodal Agreement",status:f("Nodal Agreement")?"completed":"active",description:"Nodal agreement document"},{id:"11b-4",name:"Cancelled Check",status:f("Cancelled Check")?"completed":"active",description:"Cancelled check copy"},{id:"11b-5",name:"Partnership Deed/LLP/MOA/AOA/COI",status:f("Partnership Deed/LLP/MOA/AOA/COI")||f("Partnership Deed")?"completed":"active",description:"Business entity documents"},{id:"11b-6",name:"Firm Registration Certificate",status:f("Firm Registration Certificate")||f("Firm Registration")?"completed":"active",description:"Firm registration certificate"},{id:"11b-7",name:"Rental agreement/ Lease agreement / Own/ Land agreement",status:f("Rental agreement/ Lease agreement / Own/ Land agreement")||f("Property Document")?"completed":"active",description:"Property agreement document"},{id:"11b-8",name:"Virtual Code",status:f("Virtual Code")||f("Virtual Code Confirmation")?"completed":"active",description:"Virtual code availability"},{id:"11b-9",name:"Domain ID",status:f("Domain ID")||f("Domain ID Setup")?"completed":"active",description:"Domain ID setup"},{id:"11b-10",name:"MSD Configuration",status:f("MSD Configuration")?"completed":"active",description:"Microsoft Dynamics configuration"},{id:"11b-11",name:"LOI Acknowledgement Copy",status:f("LOI Acknowledgement Copy")||f("LOI Acknowledgement")?"completed":"active",description:"LOI acknowledgement copy"}]}]},{id:12,name:"LOA",status:h("LOA"),isLocked:t.status==="LOA Pending"&&((w=a("FIRST_FILL"))==null?void 0:w.status)!=="Verified",lockMessage:"First Fill (₹15L) must be verified by Finance before LOA Approval.",evaluators:Array.from(new Set((t.participants||[]).filter(j=>{var b,C,S;return((b=j.metadata)==null?void 0:b.stageCode)==="LOA_APPROVAL"||((S=(C=j.metadata)==null?void 0:C.allAssignments)==null?void 0:S.includes("LOA_APPROVAL"))}).map(m))),description:"Letter of Authorization"},{id:13,name:"EOR Complete",status:h("EOR Complete"),description:"Essential Operating Requirements"},{id:14,name:"Inauguration",status:h("Inauguration"),description:"Dealership inauguration"},{id:15,name:"Dealership Active",status:h("Onboarded"),description:"Dealer profile active"}],u=[{id:1,item:"Sales Standards",completed:!1},{id:2,item:"Service & Spares",completed:!1},{id:3,item:"DMS infra",completed:!1},{id:4,item:"Manpower Training",completed:!1},{id:5,item:"Trade certificate with test ride bikes registration",completed:!1},{id:6,item:"GST certificate including Accessories & Apparels billing",completed:!1},{id:7,item:"Inventory Funding",completed:!1},{id:8,item:"Virtual code availability",completed:!1},{id:9,item:"Vendor payments",completed:!1},{id:10,item:"Details for website submission",completed:!1},{id:11,item:"Infra Insurance both Showroom and Service center",completed:!1},{id:12,item:"Auto ordering",completed:!1}],N=x.reduce((j,b)=>(j.push({name:b.name}),b.branches&&b.branches.forEach(C=>C.stages.forEach(S=>j.push({name:S.name,parentBranch:C.name}))),(b.name==="EOR In Progress"||b.name==="EOR Complete")&&((r==null?void 0:r.items)||u).forEach(C=>j.push({name:`EOR: ${C.description||C.item}`,parentBranch:"EOR"})),j),[]);return{processStages:x,eorChecklist:u,flattenedStages:N,getDocumentsForStage:j=>s.filter(b=>{var C;return b.stage===j||!b.stage&&((C=b.documentType)==null?void 0:C.toLowerCase().includes(j.toLowerCase().split(" ")[0]))})}}const ES=()=>{var bc;const{id:t}=vd(),s=tr(),{user:n}=In(yr=>yr.auth),r=t||"",a=()=>s(-1),[i,o]=g.useState(null);g.useEffect(()=>{r&&Zl.getBatchStatus([{entityType:"application",entityId:r}]).then(yr=>{yr!=null&&yr.success&&o(yr.data[`application:${r}`]??null)}).catch(()=>o(null))},[r]);const{application:d,loading:m,setLoading:f,documents:p,setDocuments:h,eorData:x,auditLogs:u,auditLoading:N,worknotes:v,deposits:w,paymentConfigs:j,refreshDocuments:b,fetchApplication:C,fetchEorData:S,getDeposit:R}=aV({applicationId:r}),_=x!=null&&x.items?x.items.filter(yr=>yr.isCompliant).length/x.items.length*100:0,A=yl(),{showFirmTypeModal:E,setShowFirmTypeModal:q,updatingFirmType:O,setUpdatingFirmType:D,tempFirmType:P,setTempFirmType:L,activeTab:$,setActiveTab:Y,showApproveModal:Z,setShowApproveModal:W,showOnboardModal:U,setShowOnboardModal:M,isOnboarding:z,setIsOnboarding:T,showRejectModal:I,setShowRejectModal:B,rejectionReason:G,setRejectionReason:K,scheduledInterviewParticipants:H,setScheduledInterviewParticipants:X,showScheduleModal:J,setShowScheduleModal:ae,showCancelInterviewModal:le,setShowCancelInterviewModal:xe,interviewIdToCancel:ce,setInterviewIdToCancel:ve,interviewToReschedule:Pe,setInterviewToReschedule:et,showKTMatrixModal:kt,setShowKTMatrixModal:vt,showLevel2FeedbackModal:ee,setShowLevel2FeedbackModal:ge,showLevel3FeedbackModal:ye,setShowLevel3FeedbackModal:Be,showDocumentsModal:$e,setShowDocumentsModal:dt,showAssignModal:st,setShowAssignModal:xt,selectedStage:Mt,setSelectedStage:It,interviewMode:he,setInterviewMode:pt,approvalRemark:ht,setApprovalRemark:_e,expandedBranches:Vt,setExpandedBranches:Pt,users:_s,setUsers:Ys,selectedUser:Bs,setSelectedUser:Ks,participantType:Qs,setParticipantType:Xs,interviewDate:$s,setInterviewDate:Q,interviewType:oe,setInterviewType:we,meetingLink:Oe,setMeetingLink:ke,location:je,setLocation:Ve,showUploadForm:Ge,setShowUploadForm:nt,uploadFile:Zt,setUploadFile:Jt,uploadDocType:lt,setUploadDocType:mt,approvalFile:Ds,setApprovalFile:ss,isUploading:Ae,setIsUploading:be,previewDoc:ut,setPreviewDoc:He,showPreviewModal:yt,setShowPreviewModal:ft,selectedInterviewerId:es,setSelectedInterviewerId:ts,isEditingStatutory:Cs,setIsEditingStatutory:Us,statutoryForm:rn,setStatutoryForm:Js,isSavingStatutory:an,setIsSavingStatutory:hn,interviews:De,setInterviews:bt,isScheduling:Te,setIsScheduling:ct,isCancellingInterview:tt,setIsCancellingInterview:jt,showAssignArchitectureModal:Ht,setShowAssignArchitectureModal:zt,architectureLeadId:fs,setArchitectureLeadId:qt,isAssigningArchitecture:As,setIsAssigningArchitecture:vs,showArchitectureStatusModal:cs,setShowArchitectureStatusModal:mn,architectureStatus:qs,setArchitectureStatus:ln,architectureRemarks:fn,setArchitectureRemarks:on,isUpdatingArchitecture:Ye,setIsUpdatingArchitecture:Ot,isAssigningParticipant:St,setIsAssigningParticipant:rt,documentConfigs:Ft,setDocumentConfigs:jn,fddAgencies:xn,setFddAgencies:qn,selectedAgencyId:En,setSelectedAgencyId:Hs,isAssigningAgency:Za,setIsAssigningAgency:Pa,showAssignFddModal:Ls,setShowAssignFddModal:nn,isApproving:ta,setIsApproving:sa,isRejecting:na,setIsRejecting:Ir,ktMatrixScores:Xn,setKtMatrixScores:zn,ktMatrixSelectedValues:Qt,setKtMatrixSelectedValues:Jn,ktMatrixRemarks:Rr,setKtMatrixRemarks:Wn,ktMatrixRecommendation:Er,setKtMatrixRecommendation:_n,isSubmittingKT:ur,setIsSubmittingKT:rs,selectedInterviewForFeedback:en,setSelectedInterviewForFeedback:va,showFddFinalizeModal:wi,setShowFddFinalizeModal:Si,showFddFlagModal:Mr,setShowFddFlagModal:Hr,fddAuditRecommendation:sr,setFddAuditRecommendation:ya,fddAuditFindings:Hi,setFddAuditFindings:bo,isFinalizingFdd:Oa,setIsFinalizingFdd:Cn,isFddFlagging:ba,setIsFddFlagging:Wi,level2Feedback:Wr,setLevel2Feedback:jo,level2Recommendation:Gi,setLevel2Recommendation:No,isSubmittingLevel2:Ci,setIsSubmittingLevel2:wl,level3Feedback:Sl,setLevel3Feedback:cn,level3Recommendation:ne,setLevel3Recommendation:re,isSubmittingLevel3:me,setIsSubmittingLevel3:pe,showFeedbackDetailsModal:Se,setShowFeedbackDetailsModal:ze,selectedEvaluationForView:Ue,setSelectedEvaluationForView:ot}=QU({initialTab:((bc=A.state)==null?void 0:bc.activeTab)||"questionnaire"}),ls=(v||[]).some(yr=>(yr.noteText||"").includes("FLAGGED:"))||(d==null?void 0:d.statutoryStatus)==="Flagged",{handleUpdateFirmType:Gt,handleEditStatutory:Lt,handleSaveStatutory:ws,fetchFddAgencies:gn,handleAssignAgency:nr}=iV({application:d,applicationId:r,tempFirmType:P,setUpdatingFirmType:D,setShowFirmTypeModal:q,setStatutoryForm:Js,setIsEditingStatutory:Us,setIsSavingStatutory:hn,statutoryForm:rn,setFddAgencies:qn,selectedAgencyId:En,setIsAssigningAgency:Pa,fetchApplication:C}),Bt=(n==null?void 0:n.roleCode)==="Super Admin"||(n==null?void 0:n.roleCode)==="DD Admin"||(n==null?void 0:n.role)==="Super Admin"||(n==null?void 0:n.role)==="DD Admin",Ss=(n==null?void 0:n.roleCode)==="Super Admin"||(n==null?void 0:n.roleCode)==="DD Admin"||(n==null?void 0:n.role)==="Super Admin"||(n==null?void 0:n.role)==="DD Admin"||(n==null?void 0:n.role)==="NBH"||(n==null?void 0:n.role)==="DD Head"||(n==null?void 0:n.roleCode)==="NBH"||(n==null?void 0:n.roleCode)==="DD_HEAD";g.useEffect(()=>{(async()=>{try{const El=await hs.getDocumentConfigs({limit:1e3}),hh=El.data||(Array.isArray(El)?El:[]);jn(hh)}catch(El){console.error("Failed to fetch document configs:",El)}})()},[jn]),g.useEffect(()=>{J&&d&&(d.status==="Shortlisted"||d.status==="Questionnaire Completed"?we("level1"):d.status==="Level 1 Approved"?we("level2"):(d.status==="Level 2 Approved"||d.status==="Level 2 Recommended")&&we("level3"))},[J,d==null?void 0:d.status,we]);const is=async()=>{if(r)try{const yr=await hs.getInterviews(r);bt(yr||[])}catch(yr){console.error("Failed to fetch interviews",yr)}};g.useEffect(()=>{is()},[r]);const{ktMatrixConfig:Mn,level2Config:_r,level3Config:Gn}=tV(),{handleKTMatrixChange:gr,calculateKTScore:Gr,handleSubmitKTMatrix:Qa,handleLevel2Change:vr,handleSubmitLevel2Feedback:wo,handleLevel3Change:Cl,handleSubmitLevel3Feedback:xc,ktCriteria:So,l2Fields:Al,l3Fields:Ki}=eV({ktMatrixScores:Xn,setKtMatrixScores:zn,setKtMatrixSelectedValues:Jn,ktMatrixRemarks:Rr,setKtMatrixRemarks:Wn,ktMatrixRecommendation:Er,setKtMatrixRecommendation:_n,selectedInterviewForFeedback:en,interviews:De,setIsSubmittingKT:rs,setShowKTMatrixModal:vt,level2Feedback:Wr,setLevel2Feedback:jo,level2Recommendation:Gi,setLevel2Recommendation:No,setIsSubmittingLevel2:wl,setShowLevel2FeedbackModal:ge,level3Feedback:Sl,setLevel3Feedback:cn,level3Recommendation:ne,setLevel3Recommendation:re,setIsSubmittingLevel3:pe,setShowLevel3FeedbackModal:Be,currentUser:n,fetchInterviews:is,fetchApplication:C,ktMatrixConfig:Mn,level2Config:_r,level3Config:Gn});g.useEffect(()=>{["documents","progress","fdd","eor"].includes($)&&r&&b(),$==="fdd"&&((n==null?void 0:n.role)==="DD Admin"||(n==null?void 0:n.role)==="Super Admin")&&gn()},[$,r,b,gn,n==null?void 0:n.role]);const{handleAddInterviewer:Xa,handleRemoveInterviewer:gc,maybeFetchUsersForModal:hr,handleScheduleInterview:vc,handleRescheduleInterview:La,handleConfirmCancelInterview:kl,handleUpload:Yi,handleApprove:Ia,handleReject:Ja,handleGenerateDealerCodes:Dl,handleAssignArchitecture:Zi,handleUpdateArchitectureStatus:Co,handleAddParticipant:oh,handleRetriggerEvaluators:Rl}=sV({application:d,applicationId:r,currentUser:n,interviews:De,approvalFile:Ds,approvalRemark:ht,rejectionReason:G,architectureLeadId:fs,architectureStatus:qs,architectureRemarks:fn,selectedUser:Bs,participantType:Qs,users:_s,interviewDate:$s,setInterviewDate:Q,interviewType:oe,setInterviewType:we,interviewMode:he,setInterviewMode:pt,meetingLink:Oe,setMeetingLink:ke,location:je,setLocation:Ve,scheduledInterviewParticipants:H,uploadFile:Zt,uploadDocType:lt,selectedStage:Mt,setIsApproving:sa,setShowApproveModal:W,setApprovalRemark:_e,setApprovalFile:ss,setIsRejecting:Ir,setShowRejectModal:B,setRejectionReason:K,setIsAssigningArchitecture:vs,setShowAssignArchitectureModal:zt,setIsUpdatingArchitecture:Ot,setShowArchitectureStatusModal:mn,setIsAssigningParticipant:rt,setSelectedUser:Ks,setShowAssignModal:xt,setLoading:f,setIsScheduling:ct,setShowScheduleModal:ae,setShowCancelInterviewModal:xe,interviewIdToCancel:ce,setInterviewIdToCancel:ve,interviewToReschedule:Pe,setInterviewToReschedule:et,setIsCancellingInterview:jt,setIsUploading:be,setShowUploadForm:nt,setUploadFile:Jt,setUploadDocType:mt,setDocuments:h,selectedInterviewerId:es,setSelectedInterviewerId:ts,setScheduledInterviewParticipants:X,setUsers:Ys,showScheduleModal:J,showAssignArchitectureModal:Ht,showAssignModal:st,fetchApplication:C,fetchInterviews:is,fetchEorData:S});if(g.useEffect(()=>{hr()},[J,Ht,st,oe,d==null?void 0:d.id,hr]),m&&!d)return e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx(ns,{className:"w-10 h-10 animate-spin text-re-red"})});if(!d)return e.jsx("div",{className:"flex justify-center items-center h-96",children:"Application not found"});const{processStages:kp,eorChecklist:Dp,flattenedStages:Rp,getDocumentsForStage:ch}=lV({application:d,documents:p,interviews:De,eorData:x,getDeposit:R,documentConfigs:Ft}),{activeInterviewForUser:dh,currentUserEvaluation:Ao,hasSubmittedFeedback:ko,currentUserStageAction:Ep,isInterviewCompleted:yc,isInterviewActive:_p,permissions:uh}=ZU({application:d,interviews:De,currentUser:n,getDeposit:R,eorProgress:_}),Ed=()=>e.jsx(HU,{application:d,documents:p,setPreviewDoc:He,setShowPreviewModal:ft,setIsUploading:be,fetchApplication:C,refreshDocuments:b});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(RU,{application:d,slaStatus:i,isNonResponsive:ls,isAdmin:Ss,onBack:a,onOpenWorknotes:()=>s(`/worknotes/application/${d.id}`,{state:{applicationName:d.name,registrationNumber:d.registrationNumber,participants:d.participants}})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsx(IU,{application:d,canEditStatutory:Bt,isEditingStatutory:Cs,isSavingStatutory:an,statutoryForm:rn,onEditFirmType:()=>{L(d.constitutionType||""),q(!0)},onEditStatutory:Lt,onCancelEditStatutory:()=>Us(!1),onSaveStatutory:ws,onStatutoryFormChange:Js}),d.isShortlisted!==!1&&e.jsx($U,{application:d,activeTab:$,setActiveTab:Y,processStages:kp,documents:p,interviews:De,expandedBranches:Vt,setExpandedBranches:Pt,setSelectedStage:It,setShowDocumentsModal:dt,setShowUploadForm:nt,handleRetriggerEvaluators:Rl,handleRescheduleInterview:La,setSelectedEvaluationForView:ot,setShowFeedbackDetailsModal:ze,renderFddAuditContent:Ed,eorProgress:_,eorData:x,eorChecklist:Dp,setUploadDocType:mt,isAdmin:Ss,fetchApplication:C,fetchEorData:S,deposits:w,getDeposit:R,paymentConfigs:j,setPreviewDoc:He,setShowPreviewModal:ft,auditLoading:N,auditLogs:u,auditLogActionBadgeClass:WU})]}),e.jsx(qU,{application:d,permissions:uh,getDeposit:R,isNonResponsive:ls,isAdmin:Ss,currentUserStageAction:Ep,currentUserEvaluation:Ao,onOpenApproveModal:()=>W(!0),onOpenRejectModal:()=>B(!0),onOpenWorknote:()=>s(`/worknotes/application/${d.id}`,{state:{applicationName:d.name,registrationNumber:d.registrationNumber,participants:d.participants}}),onOpenScheduleModal:()=>ae(!0),currentUser:n,handleGenerateDealerCodes:Dl,onOpenAssignArchitectureModal:()=>zt(!0),onOpenAssignFdd:()=>{Hs(""),gn(),nn(!0)},showAssignFddModal:Ls,setShowAssignFddModal:nn,fddAgencies:xn,selectedAgencyId:En,setSelectedAgencyId:Hs,isAssigningAgency:Za,handleAssignAgency:async()=>{await nr(),nn(!1)},activeInterviewForUser:dh,hasSubmittedFeedback:ko,setSelectedInterviewForFeedback:va,setShowKTMatrixModal:vt,setShowLevel2FeedbackModal:ge,setShowLevel3FeedbackModal:Be,onGoToDashboard:()=>s("/dashboard"),showAssignModal:st,setShowAssignModal:xt,selectedUser:Bs,setSelectedUser:Ks,users:_s,participantType:Qs,setParticipantType:Xs,handleAddParticipant:oh,isAssigningParticipant:St}),e.jsx(zU,{application:d,fetchApplication:C,showApproveModal:Z,setShowApproveModal:W,approvalRemark:ht,setApprovalRemark:_e,setApprovalFile:ss,isApproving:ta,handleApprove:Ia,showOnboardModal:U,setShowOnboardModal:M,isOnboarding:z,setIsOnboarding:T,showRejectModal:I,setShowRejectModal:B,rejectionReason:G,setRejectionReason:K,isRejecting:na,handleReject:Ja,showScheduleModal:J,setShowScheduleModal:ae,showCancelInterviewModal:le,setShowCancelInterviewModal:xe,setInterviewIdToCancel:ve,isCancellingInterview:tt,handleConfirmCancelInterview:kl,interviewToReschedule:Pe,setInterviewToReschedule:et,interviewType:oe,setInterviewType:we,interviewMode:he,setInterviewMode:pt,interviewDate:$s,setInterviewDate:Q,meetingLink:Oe,setMeetingLink:ke,location:je,setLocation:Ve,isInterviewCompleted:yc,isInterviewActive:_p,users:_s,selectedInterviewerId:es,setSelectedInterviewerId:ts,handleAddInterviewer:Xa,scheduledInterviewParticipants:H,handleRemoveInterviewer:gc,isScheduling:Te,handleScheduleInterview:vc,showAssignArchitectureModal:Ht,setShowAssignArchitectureModal:zt,architectureLeadId:fs,setArchitectureLeadId:qt,isAssigningArchitecture:As,handleAssignArchitecture:Zi,showArchitectureStatusModal:cs,setShowArchitectureStatusModal:mn,architectureStatus:qs,setArchitectureStatus:ln,architectureRemarks:fn,setArchitectureRemarks:on,isUpdatingArchitecture:Ye,handleUpdateArchitectureStatus:Co}),e.jsx(UU,{application:d,ktCriteria:So,l2Fields:Al,l3Fields:Ki,showKTMatrixModal:kt,setShowKTMatrixModal:vt,ktMatrixSelectedValues:Qt,handleKTMatrixChange:gr,ktMatrixRemarks:Rr,setKtMatrixRemarks:Wn,ktMatrixRecommendation:Er,setKtMatrixRecommendation:_n,calculateKTScore:Gr,handleSubmitKTMatrix:Qa,isSubmittingKT:ur,showLevel2FeedbackModal:ee,setShowLevel2FeedbackModal:ge,level2Feedback:Wr,handleLevel2Change:vr,level2Recommendation:Gi,setLevel2Recommendation:No,handleSubmitLevel2Feedback:wo,isSubmittingLevel2:Ci,showFeedbackDetailsModal:Se,setShowFeedbackDetailsModal:ze,selectedEvaluationForView:Ue,selectedInterviewForFeedback:en,showLevel3FeedbackModal:ye,setShowLevel3FeedbackModal:Be,level3Feedback:Sl,handleLevel3Change:Cl,level3Recommendation:ne,setLevel3Recommendation:re,handleSubmitLevel3Feedback:xc,isSubmittingLevel3:me,showDocumentsModal:$e,setShowDocumentsModal:dt,showUploadForm:Ge,setShowUploadForm:nt,selectedStage:Mt,getDocumentsForStage:ch,setPreviewDoc:He,setShowPreviewModal:ft,flattenedStages:Rp,setSelectedStage:It,uploadDocType:lt,setUploadDocType:mt,setUploadFile:Jt,isUploading:Ae,handleUpload:Yi,uploadFile:Zt,documentConfigs:Ft,showPreviewModal:yt,previewDoc:ut,showFddFinalizeModal:wi,setShowFddFinalizeModal:Si,currentUser:n,fddAuditRecommendation:sr,setFddAuditRecommendation:ya,fddAuditFindings:Hi,setFddAuditFindings:bo,isFinalizingFdd:Oa,setIsFinalizingFdd:Cn,fetchApplication:C,showFddFlagModal:Mr,setShowFddFlagModal:Hr,isFddFlagging:ba,setIsFddFlagging:Wi,showFirmTypeModal:E,setShowFirmTypeModal:q,tempFirmType:P,setTempFirmType:L,updatingFirmType:O,handleUpdateFirmType:Gt})]})]})};function pc(t,s=!0){const[n,r]=g.useState({});return g.useEffect(()=>{if(!s||t.length===0){r({});return}Zl.getBatchStatus(t).then(i=>{i!=null&&i.success&&r(i.data)}).catch(()=>r({}))},[s,JSON.stringify(t.map(i=>`${i.entityType}:${i.entityId}`).sort())]),{byKey:n,get:(i,o)=>n[`${i}:${o}`]??null}}const Hg=t=>t.includes("Approved")||t.includes("Completed")?"bg-green-100 text-green-700 border-green-300":t.includes("Review")||t.includes("Pending")?"bg-yellow-100 text-yellow-700 border-yellow-300":t.includes("Rejected")?"bg-red-100 text-red-700 border-red-300":"bg-blue-100 text-blue-700 border-blue-300";function oV({onViewDetails:t}){const[s,n]=g.useState([]),[r,a]=g.useState(!0),[i,o]=g.useState(1),[d,m]=g.useState("all"),[f,p]=g.useState(null),h=10,x=async()=>{var b;a(!0);try{const S=(await Ee.getResignations({page:i,limit:h,status:d==="all"?void 0:d==="open"?"open":"Completed,Closed"})).data;S!=null&&S.success&&(n(S.requests||((b=S.resignations)==null?void 0:b.rows)||S.resignations||[]),p(S.meta))}catch(C){console.error("Error fetching resignations:",C),te.error("Failed to fetch resignation requests")}finally{a(!1)}};g.useEffect(()=>{x()},[i,d]);const u=b=>{m(b),o(1)},N=d==="open"?s:[],v=d==="completed"?s:[],w=s.map(b=>({entityType:"resignation",entityId:b.id})),{get:j}=pc(w,s.length>0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Xt,{children:"All Requests"}),e.jsx(Je,{className:"text-3xl",children:(f==null?void 0:f.total)||0})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Total Requests"})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Xt,{children:"Open"}),e.jsx(Je,{className:"text-3xl text-yellow-600",children:d==="open"?(f==null?void 0:f.total)||0:"..."})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Requires Your Action"})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Xt,{children:"Completed"}),e.jsx(Je,{className:"text-3xl text-green-600",children:d==="completed"?(f==null?void 0:f.total)||0:"..."})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Finalized"})})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(Je,{children:"Resignation Requests"}),e.jsxs(Xt,{children:["Track and manage dealer resignation requests",e.jsx("span",{className:"block mt-1 text-slate-500",children:"• Note: Resignation requests are initiated by the dealer or via ASM."})]})]})})}),e.jsx(Fe,{children:e.jsxs(Bn,{value:d,onValueChange:u,className:"w-full",children:[e.jsxs($n,{children:[e.jsx(Wt,{value:"all",children:"All Requests"}),e.jsx(Wt,{value:"open",children:"Open"}),e.jsx(Wt,{value:"completed",children:"Completed"})]}),e.jsx(Ut,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4 text-center py-1",children:r?e.jsx("div",{className:"text-center py-12",children:"Loading requests..."}):s.length>0?e.jsxs(e.Fragment,{children:[s.map(b=>{var C,S,R,_,A,E,q,O,D,P,L;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-red-50 rounded-lg",children:e.jsx(Ns,{className:"w-6 h-6 text-re-red"})}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:b.resignationId}),e.jsx(Ce,{className:Hg(b.status),children:b.status}),e.jsx(kr,{status:j("resignation",b.id),compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((S=(C=b.dealer)==null?void 0:C.dealerProfile)==null?void 0:S.businessName)||((R=b.outlet)==null?void 0:R.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:((E=(A=(_=b.dealer)==null?void 0:_.dealerProfile)==null?void 0:A.dealerCode)==null?void 0:E.dealerCode)||((q=b.outlet)==null?void 0:q.code)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:((D=(O=b.dealer)==null?void 0:O.dealerProfile)==null?void 0:D.registeredAddress)||((P=b.outlet)!=null&&P.city&&((L=b.outlet)!=null&&L.state)?`${b.outlet.city}, ${b.outlet.state}`:"N/A")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Type"}),e.jsx("p",{children:b.resignationType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Reason"}),e.jsx("p",{className:"truncate max-w-[200px]",children:b.reason})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:b.currentStage})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(dr,{className:"w-4 h-4 text-slate-500"}),e.jsx("p",{children:Yt(b.submittedOn)})]})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(b.id),className:"ml-4",children:[e.jsx(yn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},b.id)}),f&&f.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center",children:e.jsx(fo,{children:e.jsxs(po,{children:[e.jsx(Sn,{children:e.jsx(xo,{onClick:()=>o(b=>Math.max(1,b-1)),className:i===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(f.totalPages)].map((b,C)=>{const S=C+1;return S===1||S===f.totalPages||S>=i-1&&S<=i+1?e.jsx(Sn,{children:e.jsx(Vi,{isActive:i===S,onClick:()=>o(S),className:"cursor-pointer",children:S})},S):S===2&&i>3||S===f.totalPages-1&&i<f.totalPages-2?e.jsx(Sn,{children:e.jsx(vo,{})},S):null}),e.jsx(Sn,{children:e.jsx(go,{onClick:()=>o(b=>Math.min(f.totalPages,b+1)),className:i===f.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]}):e.jsx("div",{className:"text-center py-12 text-slate-500",children:e.jsx("p",{children:"No resignation requests found"})})})}),e.jsx(Ut,{value:"open",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:N.length>0?N.map(b=>{var C,S,R,_,A,E,q;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-yellow-100 rounded-lg",children:e.jsx(Ns,{className:"w-6 h-6 text-yellow-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:b.resignationId}),e.jsx(Ce,{className:Hg(b.status),children:b.status}),e.jsx(kr,{status:j("resignation",b.id),compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((S=(C=b.dealer)==null?void 0:C.dealerProfile)==null?void 0:S.businessName)||((R=b.outlet)==null?void 0:R.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:((A=(_=b.dealer)==null?void 0:_.dealerProfile)==null?void 0:A.registeredAddress)||((E=b.outlet)!=null&&E.city&&((q=b.outlet)!=null&&q.state)?`${b.outlet.city}, ${b.outlet.state}`:"N/A")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:b.currentStage})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Yt(b.submittedOn)})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(b.id),className:"ml-4",children:[e.jsx(yn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},b.id)}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(Ns,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No requests requiring your action"})]})})}),e.jsx(Ut,{value:"completed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:v.length>0?v.map(b=>{var C,S,R,_,A,E;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-green-100 rounded-lg",children:e.jsx(Ns,{className:"w-6 h-6 text-green-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:b.resignationId}),e.jsx(Ce,{className:Hg(b.status),children:b.status}),e.jsx(kr,{status:j("resignation",b.id),compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((S=(C=b.dealer)==null?void 0:C.dealerProfile)==null?void 0:S.businessName)||((R=b.outlet)==null?void 0:R.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:((A=(_=b.dealer)==null?void 0:_.dealerProfile)==null?void 0:A.registeredAddress)||((E=b.outlet)==null?void 0:E.city)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Final Stage"}),e.jsx("p",{children:b.currentStage})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Yt(b.submittedOn)})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(b.id),className:"ml-4",children:[e.jsx(yn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},b.id)}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(Ns,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No completed resignations to display"})]})})})]})})]})]})}const Pi="Last Working Day",_S="Proposed Last Working Day",Hc={AWAITING_FNF:"Awaiting F&F",AWAITING_FNF_LWD_PENDING:"Awaiting F&F (LWD Pending)"},Oi=pr.inProgress;function lj(t){if(!t)return"Pending";let s=t;return s=s.replace(/Personal Hearing/gi,"SCN Response Evaluation"),s=s.replace(/\(LWD Pending\)/gi,"(Last Working Day Pending)"),s=s.replace(/\bLWD\b/g,Pi),s}const cV=t=>{switch(t){case"Critical":return"bg-red-100 text-red-700 border-red-300";case"High":return"bg-orange-100 text-orange-700 border-orange-300";case"Medium":return"bg-yellow-100 text-yellow-700 border-yellow-300";case"Low":return"bg-blue-100 text-blue-700 border-blue-300";default:return"bg-slate-100 text-slate-700 border-slate-300"}},Wg=t=>t.includes("Approved")||t.includes("Terminated")?"bg-green-100 text-green-700 border-green-300":t.includes("Review")||t.includes("Pending")?"bg-yellow-100 text-yellow-700 border-yellow-300":t.includes("Rejected")?"bg-red-100 text-red-700 border-red-300":"bg-blue-100 text-blue-700 border-blue-300",iu=lj;function dV({currentUser:t,onViewDetails:s}){const[n,r]=g.useState(!1),[a,i]=g.useState([]),[o,d]=g.useState(""),[m,f]=g.useState(!1),[p,h]=g.useState(""),[x,u]=g.useState(null),[N,v]=g.useState([]),[w,j]=g.useState({}),[b,C]=g.useState(!0),[S,R]=g.useState(1),[_,A]=g.useState(null),[E,q]=g.useState("all"),O=10,[D,P]=g.useState({terminationCategory:"",reason:"",proposedLwd:"",comments:"",documents:[]}),L=async()=>{C(!0);try{const ae=(await Ee.getTerminations({page:S,limit:O,status:E==="all"?void 0:E})).data;if(ae!=null&&ae.success){v(ae.terminations),A(ae.meta);const le=ae.terminations||[];le.length?Zl.getBatchStatus(le.map(xe=>({entityType:"termination",entityId:xe.id}))).then(xe=>{if(xe!=null&&xe.success){const ce={};le.forEach(ve=>{ce[ve.id]=xe.data[`termination:${ve.id}`]??null}),j(ce)}}).catch(()=>j({})):j({})}}catch(J){console.error("Error fetching terminations:",J),te.error("Failed to fetch termination requests")}finally{C(!1)}};g.useEffect(()=>{L()},[S,E]);const $=J=>{q(J),R(1)};g.useEffect(()=>{if(!n||!K)return;let J=!1;return(async()=>{try{f(!0);const le=(await Ee.getDealers({onboarded:"true",activeOnly:"true"})).data;if(!J&&(le!=null&&le.success)){const xe=(Array.isArray(le.data)?le.data:[]).filter(ce=>{var et,kt;const ve=String((ce==null?void 0:ce.status)||"").toLowerCase(),Pe=String(((et=ce==null?void 0:ce.user)==null?void 0:et.status)||"").toLowerCase();return ve==="active"&&((kt=ce==null?void 0:ce.user)==null?void 0:kt.isActive)&&Pe==="active"});i(xe)}}catch(ae){J||(console.error("Error fetching dealers:",ae),te.error("Failed to load dealer list"))}finally{J||f(!1)}})(),()=>{J=!0}},[n]);const Y=J=>{var ae,le,xe,ce,ve,Pe;return{id:J.id,dealerId:J.id,dealerCode:((ae=J.dealerCode)==null?void 0:ae.dealerCode)||"",legalName:J.legalName||"N/A",businessName:J.businessName||"N/A",gstNumber:J.gstNumber||"N/A",address:J.registeredAddress||((le=J.application)==null?void 0:le.preferredLocation)||"N/A",city:((xe=J.application)==null?void 0:xe.city)||"N/A",state:((ce=J.application)==null?void 0:ce.state)||"N/A",email:((ve=J.user)==null?void 0:ve.email)||"N/A",phoneNumber:((Pe=J.user)==null?void 0:Pe.mobileNumber)||"N/A"}},Z=J=>{d(J);const ae=a.find(xe=>String(xe.id)===String(J));if(!ae){h(""),u(null);return}const le=Y(ae);h(le.dealerCode),u(le)},W=J=>{h(J);const ae=J.trim().toLowerCase();if(!ae){d(""),u(null);return}const le=a.find(xe=>{var ce;return String(((ce=xe.dealerCode)==null?void 0:ce.dealerCode)||"").toLowerCase()===ae});if(!le){d(""),u(null);return}d(String(le.id)),u(Y(le))},M=!((t==null?void 0:t.role)==="Super Admin"),z=J=>{const ae=J.name.toLowerCase();return ae.endsWith(".ppt")||ae.endsWith(".pptx")},T=(J,ae)=>{!J||J.length===0||(P(le=>{const xe=le.documents,ce=new Set(xe.map(Pe=>`${Pe.name}::${Pe.size}`)),ve=[];return Array.from(J).forEach(Pe=>{const et=`${Pe.name}::${Pe.size}`;ce.has(et)||(ce.add(et),ve.push(Pe))}),{...le,documents:[...xe,...ve]}}),ae&&(ae.value=""))},I=J=>{P({...D,documents:D.documents.filter((ae,le)=>le!==J)})},B=async J=>{var ae,le;if(J.preventDefault(),!x){te.error("Please select a dealer");return}if(M){if(D.documents.length===0){te.error("Please upload at least one Presentation (.ppt or .pptx)");return}if(!D.documents.some(z)){te.error("At least one PowerPoint file (.ppt or .pptx) is required");return}}try{const xe=x.dealerId||x.id;if(!xe){te.error("Dealer record not found for the selected dealer");return}let ce;if(D.documents.length>0){const et=new FormData;et.append("dealerId",String(xe)),et.append("category",D.terminationCategory),et.append("reason",D.reason),et.append("proposedLwd",D.proposedLwd),et.append("comments",D.comments),D.documents.forEach(kt=>et.append("files",kt)),ce=et}else ce={dealerId:xe,category:D.terminationCategory,reason:D.reason,proposedLwd:D.proposedLwd,comments:D.comments};const Pe=(await Ee.createTermination(ce)).data;Pe!=null&&Pe.success&&(te.success(D.documents.length>0?"Termination request and documents submitted":"Termination request submitted successfully"),r(!1),L(),d(""),h(""),i([]),u(null),P({terminationCategory:"",reason:"",proposedLwd:"",comments:"",documents:[]}))}catch(xe){console.error("Error submitting termination:",xe),te.error(((le=(ae=xe.response)==null?void 0:ae.data)==null?void 0:le.message)||"Failed to submit termination request")}},G=["DD Lead","ASM","DD Admin","DD AM","Super Admin"],K=(t==null?void 0:t.role)&&G.includes(t.role),H=E==="open"||E==="all"?N:[],X=E==="completed"||E==="all"?N:[];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Xt,{children:"All Cases"}),e.jsx(Je,{className:"text-3xl",children:(_==null?void 0:_.total)||0})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Total Cases"})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Xt,{children:"Open"}),e.jsx(Je,{className:"text-3xl text-orange-600",children:E==="open"?(_==null?void 0:_.total)||0:"..."})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Requires Your Action"})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Xt,{children:"Completed"}),e.jsx(Je,{className:"text-3xl text-green-600",children:E==="completed"?(_==null?void 0:_.total)||0:"..."})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Finalized"})})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Je,{children:"Termination Requests"}),e.jsx(Xt,{children:"Manage dealer termination proceedings and legal compliance"})]}),K&&e.jsxs(ds,{open:n,onOpenChange:r,children:[e.jsx(co,{asChild:!0,children:e.jsxs(se,{className:"bg-red-600 hover:bg-red-700",children:[e.jsx(An,{className:"w-4 h-4 mr-2"}),"Create Termination Request"]})}),e.jsxs(os,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Create Termination Request"}),e.jsx(bs,{children:"Fill in the details to create a new termination request"})]}),e.jsxs("form",{onSubmit:B,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Select Dealer *"}),e.jsxs(Dt,{value:o,onValueChange:Z,disabled:m,children:[e.jsx(Et,{children:e.jsx(Rt,{placeholder:m?"Loading dealers...":"Select dealer"})}),e.jsx(_t,{children:a.map(J=>{var ae;return e.jsxs(Me,{value:String(J.id),children:[J.legalName||J.businessName||"Unnamed Dealer"," - ",((ae=J.dealerCode)==null?void 0:ae.dealerCode)||"No Code"]},J.id)})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"dealerCode",children:"Dealer Code *"}),e.jsx(at,{id:"dealerCode",value:p,onChange:J=>W(J.target.value),placeholder:"Type dealer code to auto-select",required:!0})]}),x&&e.jsxs("div",{className:"grid grid-cols-2 gap-4 p-4 bg-slate-50 rounded-lg",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Name (Legal)"}),e.jsx("p",{children:x.legalName||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Business Name"}),e.jsx("p",{children:x.businessName||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:x.gstNumber||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Address"}),e.jsx("p",{children:x.address})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"City/State"}),e.jsxs("p",{children:[x.city,", ",x.state]})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:x.dealerCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Contact"}),e.jsxs("p",{children:[x.email," / ",x.phoneNumber]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Termination Category *"}),e.jsxs(Dt,{value:D.terminationCategory,onValueChange:J=>P({...D,terminationCategory:J}),children:[e.jsx(Et,{children:e.jsx(Rt,{placeholder:"Select termination category"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"Working Capital",children:"Working Capital"}),e.jsx(Me,{value:"Performance Issues",children:"Performance Issues"}),e.jsx(Me,{value:"Unethical Practice",children:"Unethical Practice"}),e.jsx(Me,{value:"Unforeseen Circumstances",children:"Unforeseen Circumstances"}),e.jsx(Me,{value:"Others",children:"Others"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(de,{children:[_S," *"]}),e.jsx(at,{type:"date",value:D.proposedLwd,onChange:J=>P({...D,proposedLwd:J.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"reason",children:"Termination Reason *"}),e.jsx(at,{id:"reason",value:D.reason,onChange:J=>P({...D,reason:J.target.value}),placeholder:"Primary reason for termination",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"comments",children:"Additional Comments *"}),e.jsx(Ws,{id:"comments",value:D.comments,onChange:J=>P({...D,comments:J.target.value}),placeholder:"Detailed observations and justification",rows:4,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"documents",children:M?"Upload Documents *":"Upload Supporting Documents"}),e.jsx(at,{id:"documents",type:"file",multiple:!0,accept:".ppt,.pptx,.pdf,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png",onChange:J=>T(J.target.files,J.currentTarget),required:M&&D.documents.length===0}),M&&e.jsx("p",{className:"text-xs text-slate-500",children:"At least one PowerPoint (.ppt / .pptx) is mandatory. You can also attach MOM, dealer commitments, and other supporting files (PDF / DOC / XLS / image)."}),D.documents.length>0&&e.jsx("div",{className:"border rounded-md divide-y bg-slate-50",children:D.documents.map((J,ae)=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"truncate",children:J.name}),z(J)&&e.jsx(Ce,{className:"bg-blue-100 text-blue-700 border-blue-300",children:"Presentation"})]}),e.jsx(se,{type:"button",variant:"ghost",size:"sm",onClick:()=>I(ae),className:"text-red-600 hover:text-red-700",children:"Remove"})]},`${J.name}-${ae}`))})]}),e.jsxs(bn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(se,{type:"submit",className:"bg-red-600 hover:bg-red-700",children:"Submit Request"})]})]})]})]})]})}),e.jsxs(Fe,{children:[e.jsxs(Bn,{value:E,onValueChange:$,className:"w-full",children:[e.jsxs($n,{children:[e.jsx(Wt,{value:"all",children:"All Cases"}),e.jsx(Wt,{value:"open",children:"Open"}),e.jsx(Wt,{value:"completed",children:"Completed"})]}),e.jsx(Ut,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:b?e.jsx("div",{className:"text-center py-12",children:"Loading requests..."}):N.length>0?N.map(J=>{var ae,le,xe,ce;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-red-100 rounded-lg",children:e.jsx(mi,{className:"w-6 h-6 text-red-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg font-bold",children:J.requestId||((le=(ae=J.dealer)==null?void 0:ae.dealerCode)==null?void 0:le.code)||"N/A"}),e.jsx(Ce,{className:cV(J.severity||"Medium"),children:J.severity||"Normal"}),e.jsx(Ce,{className:Wg(J.status),children:iu(J.status)}),e.jsx(kr,{status:w[J.id],compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((xe=J.dealer)==null?void 0:xe.businessName)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:((ce=J.dealer)==null?void 0:ce.registeredAddress)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Category"}),e.jsx("p",{children:J.category})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:iu(J.currentStage)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:_S}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(dr,{className:"w-4 h-4 text-slate-500"}),e.jsx("p",{children:J.proposedLwd})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Yt(J.createdAt)})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(J.id),className:"ml-4",children:[e.jsx(yn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},J.id)}):e.jsx("div",{className:"text-center py-12 text-slate-500",children:e.jsx("p",{children:"No termination requests found"})})})}),e.jsx(Ut,{value:"open",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:H.length>0?H.map(J=>{var ae,le,xe;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-orange-100 rounded-lg",children:e.jsx(Ha,{className:"w-6 h-6 text-orange-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg font-bold",children:J.requestId||((le=(ae=J.dealer)==null?void 0:ae.dealerCode)==null?void 0:le.code)||"N/A"}),e.jsx(Ce,{className:Wg(J.status),children:iu(J.status)}),e.jsx(kr,{status:w[J.id],compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:(xe=J.dealer)==null?void 0:xe.businessName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Reason"}),e.jsx("p",{className:"truncate",children:J.reason})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:iu(J.currentStage)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Yt(J.createdAt)})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(J.id),className:"ml-4",children:[e.jsx(yn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},J.id)}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(mi,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No requests requiring your action"})]})})}),e.jsx(Ut,{value:"completed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:X.length>0?X.map(J=>{var ae,le,xe;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-green-100 rounded-lg",children:e.jsx(mi,{className:"w-6 h-6 text-green-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg font-bold",children:J.requestId||((le=(ae=J.dealer)==null?void 0:ae.dealerCode)==null?void 0:le.code)||"N/A"}),e.jsx(Ce,{className:Wg(J.status),children:iu(J.status)}),e.jsx(kr,{status:w[J.id],compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:(xe=J.dealer)==null?void 0:xe.businessName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Closed On"}),e.jsx("p",{children:Yt(J.updatedAt)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Termination Category"}),e.jsx("p",{children:J.category})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:Pi}),e.jsx("p",{children:J.proposedLwd})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(J.id),className:"ml-4",children:[e.jsx(yn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},J.id)}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(mi,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No completed terminations to display"})]})})})]}),_&&_.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center bg-white rounded-b-lg",children:e.jsx(fo,{children:e.jsxs(po,{children:[e.jsx(Sn,{children:e.jsx(xo,{onClick:()=>R(J=>Math.max(1,J-1)),className:S===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(_.totalPages)].map((J,ae)=>{const le=ae+1;return le===1||le===_.totalPages||le>=S-1&&le<=S+1?e.jsx(Sn,{children:e.jsx(Vi,{isActive:S===le,onClick:()=>R(le),className:"cursor-pointer",children:le})},le):le===2&&S>3||le===_.totalPages-1&&S<_.totalPages-2?e.jsx(Sn,{children:e.jsx(vo,{})},le):null}),e.jsx(Sn,{children:e.jsx(go,{onClick:()=>R(J=>Math.min(_.totalPages,J+1)),className:S===_.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})]})}const lu=t=>{switch(t){case"Initiated":return"bg-blue-100 text-blue-700 border-blue-300";case"DD Clearance":case"Legal Clearance":return"bg-yellow-100 text-yellow-700 border-yellow-300";case"Finance Approval":case"Calculated":return"bg-orange-100 text-orange-700 border-orange-300";case"Completed":case"Settled":return"bg-green-100 text-green-700 border-green-300";default:return"bg-slate-100 text-slate-700 border-slate-300"}},ou=t=>t==="Resignation"?"bg-red-50 text-re-red-hover border-red-300":"bg-red-100 text-red-700 border-red-300";function uV({currentUser:t,onViewDetails:s}){const[n,r]=g.useState([]),[a,i]=g.useState(!0);g.useEffect(()=>{o()},[]);const o=async()=>{try{i(!0);const N=(await Ee.getFnFSettlements()).data;N.success&&r(N.settlements||[])}catch(u){console.error("Fetch settlements error:",u),te.error("Failed to fetch settlement cases")}finally{i(!1)}};if(a)return e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(ns,{className:"w-8 h-8 animate-spin text-blue-600"})});const d=u=>{var N,v,w,j,b,C,S,R,_,A,E,q,O,D,P,L;return{id:u.id,caseNumber:u.settlementId||((N=u.resignation)==null?void 0:N.resignationId)||((v=u.terminationRequest)==null?void 0:v.requestId)||u.id.substring(0,8).toUpperCase(),status:u.status,requestType:u.resignationId?"Resignation":"Termination",dealerName:((j=(w=u.outlet)==null?void 0:w.dealer)==null?void 0:j.fullName)||((b=u.dealer)==null?void 0:b.legalName)||((C=u.dealer)==null?void 0:C.businessName)||((S=u.dealer)==null?void 0:S.fullName)||"N/A",dealerCode:((R=u.outlet)==null?void 0:R.code)||((A=(_=u.dealer)==null?void 0:_.dealerCode)==null?void 0:A.dealerCode)||"N/A",dealershipName:((E=u.outlet)==null?void 0:E.name)||"N/A",location:((q=u.outlet)==null?void 0:q.city)||((O=u.outlet)==null?void 0:O.location)||"N/A",originalRequestId:((D=u.resignation)==null?void 0:D.resignationId)||((P=u.terminationRequest)==null?void 0:P.requestId)||((L=u.terminationRequest)==null?void 0:L.id)||"N/A",submittedOn:Yt(u.createdAt),financeReportStatus:u.status==="Calculated"||u.status==="Settled"?"Completed":"Pending",totalRecoveryAmount:parseFloat(u.totalReceivables)||0,totalPayableAmount:parseFloat(u.totalPayables)||0,completedOn:u.settlementDate?Yt(u.settlementDate):null,departmentResponses:u.lineItems||[]}},m=n.map(d),f=m.filter(u=>u.status==="Initiated"),p=m.filter(u=>u.status==="DD Clearance"||u.status==="Legal Clearance"),h=m.filter(u=>u.status==="Finance Approval"||u.status==="Calculated"),x=m.filter(u=>u.status==="Completed"||u.status==="Settled");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:[e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Xt,{children:"Initiated"}),e.jsx(Je,{className:"text-3xl text-blue-600",children:f.length})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Newly created"})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Xt,{children:"Clearance"}),e.jsx(Je,{className:"text-3xl text-yellow-600",children:p.length})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Department / legal stage"})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Xt,{children:"Finance Approval"}),e.jsx(Je,{className:"text-3xl text-orange-600",children:h.length})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Ready for finance review"})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Xt,{children:"Completed"}),e.jsx(Je,{className:"text-3xl text-green-600",children:m.filter(u=>u.status==="Completed"||u.status==="Settled").length})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Finalized"})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Xt,{children:"All Cases"}),e.jsx(Je,{className:"text-3xl",children:m.length})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Total"})})]})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"Full & Final Settlement Cases"}),e.jsxs(Xt,{children:["Manage dealer exit dues clearance and settlement",t&&` • Current Role: ${t.role}`]})]}),e.jsx(Fe,{children:e.jsxs(Bn,{defaultValue:"all",className:"w-full",children:[e.jsxs($n,{children:[e.jsx(Wt,{value:"all",children:"All Cases"}),e.jsx(Wt,{value:"initiated",children:"Initiated"}),e.jsx(Wt,{value:"clearance",children:"Clearance"}),e.jsx(Wt,{value:"finance",children:"Finance Approval"}),e.jsx(Wt,{value:"completed",children:"Completed"})]}),e.jsx(Ut,{value:"initiated",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[f.map(u=>e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-blue-100 rounded-lg",children:e.jsx(hu,{className:"w-6 h-6 text-blue-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:u.caseNumber}),e.jsx(Ce,{className:lu(u.status),children:u.status}),e.jsx(Ce,{className:ou(u.requestType),children:u.requestType})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:u.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:u.dealerCode})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealership Name"}),e.jsx("p",{children:u.dealershipName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:u.location})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Original Request ID"}),e.jsx("p",{children:u.originalRequestId})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(dr,{className:"w-4 h-4 text-slate-500"}),e.jsx("p",{children:u.submittedOn})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Finance Report"}),e.jsx("p",{children:u.financeReportStatus})]})]})]})]}),e.jsx("div",{className:"flex items-center gap-2 ml-4",children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(u.id),children:[e.jsx(yn,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},u.id)),f.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(hu,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No initiated cases to display"})]})]})}),e.jsx(Ut,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:m.map(u=>e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:`p-3 rounded-lg ${u.status==="Initiated"?"bg-blue-100":u.status==="DD Clearance"||u.status==="Legal Clearance"?"bg-yellow-100":u.status==="Finance Approval"||u.status==="Calculated"?"bg-orange-100":"bg-green-100"}`,children:e.jsx(ka,{className:`w-6 h-6 ${u.status==="Initiated"?"text-blue-600":u.status==="DD Clearance"||u.status==="Legal Clearance"?"text-yellow-600":u.status==="Finance Approval"||u.status==="Calculated"?"text-orange-600":"text-green-600"}`})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:u.caseNumber}),e.jsx(Ce,{className:lu(u.status),children:u.status}),e.jsx(Ce,{className:ou(u.requestType),children:u.requestType})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:u.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealership Name"}),e.jsx("p",{children:u.dealershipName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:u.location})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:u.submittedOn})]})]})]})]}),e.jsx("div",{className:"flex items-center gap-2 ml-4",children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(u.id),children:[e.jsx(yn,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},u.id))})}),e.jsx(Ut,{value:"clearance",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[p.map(u=>e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-yellow-100 rounded-lg",children:e.jsx(ka,{className:"w-6 h-6 text-yellow-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:u.caseNumber}),e.jsx(Ce,{className:lu(u.status),children:u.status}),e.jsx(Ce,{className:ou(u.requestType),children:u.requestType})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:u.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Departments Responded"}),e.jsxs("p",{children:[u.departmentResponses.filter(N=>N.status!=="Pending").length," / ",u.departmentResponses.length]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:u.submittedOn})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(u.id),className:"ml-4",children:[e.jsx(yn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},u.id)),p.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(ka,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No clearance-stage cases"})]})]})}),e.jsx(Ut,{value:"finance",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[h.map(u=>{var N,v;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-orange-100 rounded-lg",children:e.jsx(ka,{className:"w-6 h-6 text-orange-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:u.caseNumber}),e.jsx(Ce,{className:lu(u.status),children:u.status}),e.jsx(Ce,{className:ou(u.requestType),children:u.requestType})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:u.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Receivable amount"}),e.jsxs("p",{className:"text-red-600",children:["₹",(N=u.totalRecoveryAmount)==null?void 0:N.toLocaleString()]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Payable Amount"}),e.jsxs("p",{className:"text-green-600",children:["₹",(v=u.totalPayableAmount)==null?void 0:v.toLocaleString()]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Finance Status"}),e.jsx("p",{children:u.financeReportStatus})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(u.id),className:"ml-4",children:[e.jsx(yn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},u.id)}),h.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(ka,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No finance-approval cases"})]})]})}),e.jsx(Ut,{value:"completed",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[x.map(u=>e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-green-100 rounded-lg",children:e.jsx(hu,{className:"w-6 h-6 text-green-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:u.caseNumber}),e.jsx(Ce,{className:lu(u.status),children:u.status}),e.jsx(Ce,{className:ou(u.requestType),children:u.requestType})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:u.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Completed On"}),e.jsx("p",{children:u.completedOn||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:u.submittedOn})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(u.id),className:"ml-4",children:[e.jsx(yn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},u.id)),x.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(hu,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No completed cases"})]})]})})]})})]})]})}const tc={getResignations:async()=>{try{return(await Ee.getResignations()).data}catch(t){throw console.error("Get resignations error:",t),t}},createResignation:async t=>{try{return(await Ee.createResignation(t)).data}catch(s){throw console.error("Create resignation error:",s),s}},getResignationById:async t=>{var s,n;try{const r=await Ee.getResignationById(t);return((s=r.data)==null?void 0:s.resignation)||((n=r.data)==null?void 0:n.data)||r.data}catch(r){throw console.error("Get resignation error:",r),r}},updateClearance:async(t,s)=>{try{return(await Ee.updateClearance(t,s)).data}catch(n){throw console.error("Update clearance error:",n),n}},uploadDocument:async(t,s)=>{try{return(await Ee.uploadResignationDocument(t,s)).data}catch(n){throw console.error("Upload resignation document error:",n),n}},withdraw:async(t,s)=>{try{return(await Ee.withdrawResignation(t,s)).data}catch(n){throw console.error("Withdraw resignation error:",n),n}}},Gg=["Resignation Letter","Dealer Undertaking","Approval Note","Resignation Acceptance Letter","Handover Document","Settlement Supporting Document","PPT Presentation","Other"],hV=["Request Submitted","ASM","RBM","ZBH","DD Lead","DD Head","NBH","DD Admin","Legal","F&F Initiated"],Kg=["Termination Recommendation","Show Cause Notice","SCN Response","Hearing Record","Approval Note","Termination Letter","Settlement Supporting Document","Other"],mV=["Submitted","RBM + DD-ZM Review","ZBH Review","DD Lead Review","Legal Verification","NBH Evaluation","Show Cause Notice","Personal Hearing","NBH Final Approval","CCO Approval","CEO Final Approval","Legal - Termination Letter"],fV={ASM:"ASM",RBM:"RBM",ZBH:"ZBH","DD Lead":"DD Lead","DD Head":"DD Head",NBH:"NBH","DD Admin":"DD Admin",Legal:"Legal Admin"},TS=["REJECTED","Rejected","REVOKED","Revoked","WITHDRAWN","Withdrawn"],km={"Request Submitted":["Submission","Submitted","Initiation"],ASM:["ASM","ASM Review"],RBM:["RBM","RBM Review","Regional Review","RBM + DD-ZM Review"],ZBH:["ZBH","ZBH Review","ZM Review"],"DD Lead":["DD Lead","DD Lead Review","DDL Review"],"DD Head":["DD Head","DD Head Review","DDH Review"],NBH:["NBH","NBH Approval","NBH Review"],"DD Admin":["DD Admin","DD Admin Review"],"Awaiting F&F":["Awaiting F&F","Awaiting F&F — manual initiation"],Legal:["Legal","Legal - Resignation Letter"],"F&F Initiated":["F&F Initiated","FNF_INITIATED","FNF Initiated"],Completed:["Completed"]};function pV({resignationId:t,onBack:s,currentUser:n}){var $e,dt,st,xt,Mt,It,he,pt,ht,_e,Vt,Pt,_s,Ys,Bs,Ks,Qs,Xs,$s,Q,oe,we,Oe,ke,je,Ve,Ge,nt,Zt,Jt,lt,mt,Ds,ss,Ae;const{get:r}=pc(t?[{entityType:"resignation",entityId:t}]:[],!!t),a=(be,ut)=>{const He=[...(E==null?void 0:E.documents)||[],...(E==null?void 0:E.uploadedDocuments)||[]],yt=[be,ut,...ut?km[ut]||[]:[],...km[be]||[]].filter(ft=>!!ft).map(ft=>ft.trim().toLowerCase());return He.filter(ft=>{if(!(ft!=null&&ft.stage))return!1;const es=String(ft.stage).trim().toLowerCase();return yt.includes(es)})},i=tr(),[o,d]=g.useState({open:!1,type:null}),[m,f]=g.useState(""),[p,h]=g.useState(""),[x,u]=g.useState(""),[N,v]=g.useState(""),[w,j]=g.useState([]),[b,C]=g.useState(!1),[S,R]=g.useState(!1),[_,A]=g.useState({open:!1,stageName:"",documents:[]}),[E,q]=g.useState(null),[O,D]=g.useState(!1),[P,L]=g.useState([]),[$,Y]=g.useState(!1),[Z,W]=g.useState(null),[U,M]=g.useState(!1),[z,T]=g.useState(null),[I,B]=g.useState(Gg[0]),[G,K]=g.useState(""),H=g.useMemo(()=>[...(E==null?void 0:E.documents)||[],...(E==null?void 0:E.uploadedDocuments)||[]].some(ut=>(ut.documentType||ut.type)==="PPT Presentation"),[E]),X=async()=>{try{D(!0);const be=await tc.getResignationById(t);q(be),J()}catch(be){console.error("Error fetching resignation:",be)}finally{D(!1)}},J=async()=>{try{const be=await Ee.getAuditLogs("resignation",t);be.data&&be.data.success&&L(be.data.data||[])}catch(be){console.error("Error fetching audit logs:",be)}};g.useEffect(()=>{X()},[t]);const ae=[{id:1,name:"Request Submitted",key:"Request Submitted",description:"Dealer submitted the resignation request"},{id:2,name:"ASM Review",key:"ASM",description:"Area Sales Manager review"},{id:3,name:"RBM + DD-ZM Review",key:"RBM",description:"Joint approval by Regional Business Manager and DD-ZM"},{id:4,name:"ZBH Review",key:"ZBH",description:"Zonal Business Head approval"},{id:5,name:"DD Lead Review",key:"DD Lead",description:"DD Lead consolidated review"},{id:6,name:"DD Head Review",key:"DD Head",description:"DD Head final dealer development approval"},{id:7,name:"NBH Approval",key:"NBH",description:"National Business Head approval"},{id:8,name:"Legal - Resignation Letter",key:"Legal",description:"Legal team issues resignation approval letter"},{id:9,name:"DD Admin Review",key:"DD Admin",description:"DD Admin verification and final closure"},{id:10,name:"Awaiting F&F",key:"Awaiting F&F",description:"Internal review complete — start Full & Final using Push to F&F when ready"},{id:11,name:"F&F Settlement",key:"F&F Initiated",description:"Full & Final settlement process"},{id:12,name:"Completed",key:"Completed",description:"Resignation process finalized"}],le=["Request Submitted","ASM","RBM","ZBH","DD Lead","DD Head","NBH","Legal","DD Admin","Awaiting F&F","F&F Initiated","Completed"],xe=E?["F&F Initiated","Completed","Settled","FNF_INITIATED"].includes(String(E.status||E.currentStage||""))?!0:(Array.isArray(E.timeline)?E.timeline:[]).some(He=>{const yt=String((He==null?void 0:He.stage)||"").trim().toLowerCase(),ft=String((He==null?void 0:He.targetStage)||"").trim().toLowerCase(),es=String((He==null?void 0:He.action)||"").trim().toLowerCase(),ts=yt==="legal"||yt==="legal - resignation letter",Cs=ft==="legal"||ft==="dd admin"||ft==="awaiting f&f"||ft==="f&f initiated"||ft==="fnf_initiated"||es.includes("approved");return ts&&Cs}):!1,ve=(()=>{if(!E||!n)return{canApprove:!1,canDispatch:!1,dispatchMissed:!1,canWithdraw:!1,canSendBack:!1,canPushToFnF:!1,canAssign:!1};const be=E.currentStage,ut=E.status,He=n.role,yt=be==="RBM"||be==="RBM Review"||be==="RBM + DD-ZM Review",ft=String(n.roleCode||n.role||"").trim().toUpperCase(),es=yt&&P.some(Ft=>{var jn,xn,qn,En;return Ft.action==="PARTIAL_APPROVE"&&(((jn=Ft.actor)==null?void 0:jn.id)===n.id||Ft.actorId===n.id||((xn=Ft.actor)==null?void 0:xn.email)===n.email||Ft.userEmail===n.email)&&(((qn=Ft.details)==null?void 0:qn.roleCode)===ft||((En=Ft.details)==null?void 0:En.roleCode)==="DD-ZM"&&ft==="DD ZM")}),ts=["Completed","Rejected","Withdrawn","Revoked"].includes(ut),Cs=ut==="F&F Initiated"||be==="F&F Initiated"||ut==="Settled"||ut==="FNF_INITIATED",Us=le.indexOf(be),rn=le.indexOf("NBH"),Js=Us!==-1&&rn!==-1&&Us>=rn,an=ft==="SUPER_ADMIN"||yt&&(ft==="RBM"||ft==="DD-ZM"||ft==="DD ZM")||He===fV[be],hn=be==="DD Lead"||be==="DD Lead Review",De=ft==="DD_LEAD"||ft==="DD LEAD",bt=(()=>{const Ft=new Date;Ft.setHours(0,0,0,0);const jn=E.lastOperationalDateServices||E.lastOperationalDateSales;if(!jn)return!0;const xn=new Date(jn);return xn.setHours(0,0,0,0),Ft>=xn})(),Te=be==="Awaiting F&F",ct=(()=>{const Ft=String(be||"").trim();return le.find(xn=>xn===Ft||(km[xn]||[]).includes(Ft))||Ft})(),tt=ct==="NBH",jt=ct==="Awaiting F&F",Ht=ct==="Legal",zt=["DD Lead","DD Head","DD Admin","Super Admin"],fs=["DD Lead","DD Head","DD Admin","Super Admin"],qt=be==="DD Admin"||be==="DD Admin Review",As=ft==="DD_ADMIN"||He==="DD Admin",vs=ft==="SUPER_ADMIN"||He==="Super Admin",mn=[...E.documents||[],...E.uploadedDocuments||[]].some(Ft=>{const jn=String((Ft==null?void 0:Ft.documentType)||(Ft==null?void 0:Ft.type)||"").toLowerCase(),xn=String((Ft==null?void 0:Ft.stage)||"").toLowerCase();return jn.includes("acceptance letter")||xn==="legal"}),qs=P.some(Ft=>{var qn;const jn=String((Ft==null?void 0:Ft.action)||"").toUpperCase(),xn=String((Ft==null?void 0:Ft.description)||((qn=Ft==null?void 0:Ft.details)==null?void 0:qn.action)||"").toLowerCase();return jn==="RESIGNATION_LETTER_DISPATCHED"||xn.includes("resignation letter dispatched")})||(E.timeline||[]).some(Ft=>String((Ft==null?void 0:Ft.action)||"").toLowerCase().includes("resignation letter dispatched")),ln=le.indexOf("DD Admin"),fn=le.indexOf("Completed"),on=le.indexOf(le.find(Ft=>Ft===be||(km[Ft]||[]).includes(be))||be),Ot=ln!==-1&&on!==-1&&on>=ln&&(fn===-1||on<fn)&&(As||vs)&&mn&&!qs&&!ts;return{canApprove:an&&!ts&&!Cs&&!es&&!(be==="Legal"&&xe)&&!(De&&hn&&!H)&&!(be==="DD Admin"&&!bt)&&!qt&&!Te,canDispatch:Ot,dispatchMissed:Ot&&!qt,canSendBack:an&&!ts&&!Cs&&Us>0&&He!=="Legal Admin"&&ft!=="LEGAL_ADMIN",canWithdraw:He==="Dealer"&&!Js&&!ts,canRevoke:(ft==="SUPER_ADMIN"||He==="DD Admin")&&!ts&&!Cs,canPushToFnF:zt.includes(He)&&!Cs&&!ts&&!tt&&bt&&(jt||Ht&&fs.includes(He)),canAssign:He!=="Dealer"&&!ts}})(),Pe=["Super Admin","DD Lead","DD Head","NBH","DD Admin","Legal Admin","DD-ZM"].includes((n==null?void 0:n.role)||""),et={ASM:["ASM","ASM Review","Request Initiated"],RBM:["RBM","RBM Review","RBM + DD-ZM Review"],ZBH:["ZBH","ZBH Review"],"DD Lead":["DD Lead","DD Lead Review","Lead Review"],"DD Head":["DD Head","DD Head Review","Head Review"],NBH:["NBH","NBH Approval","NBH Review"],"DD Admin":["DD Admin","DD Admin Review"],"Awaiting F&F":["Awaiting F&F","Awaiting F&F — manual initiation"],Legal:["Legal","Legal - Resignation Letter","Legal Review"],"F&F Initiated":["F&F Initiated","FNF_INITIATED","F&F Settlement","Settled"],Completed:["Completed","Finalized"]},kt=be=>{if(!be)return"";const ut=String(be).trim();return le.find(yt=>yt===ut||(et[yt]||[]).includes(ut))||ut},vt=be=>{if(!E)return"pending";const ut=["Rejected","Revoked","Withdrawn"].includes(E.status);let He=E.currentStage;if(ut&&(!He||TS.includes(String(He)))){const ts=[...E.timeline||[]].reverse().find(Cs=>(Cs==null?void 0:Cs.stage)&&!TS.includes(String(Cs.stage)));ts!=null&&ts.stage&&(He=ts.stage)}const yt=le.indexOf(kt(He)),ft=le.indexOf(be);if((E.status==="Completed"||E.status==="Settled")&&ft<=yt)return"completed";const es=["Rejected","Revoked","Withdrawn"].includes(E.status);return be==="Legal"&&xe&&!es?"completed":yt===-1?be==="ASM"?"completed":"pending":ft<yt?"completed":ft===yt?ut?"completed":"active":"pending"},ee=be=>{d({open:!0,type:be})},ge=(be,ut)=>{const He=a(be,ut).map((yt,ft)=>{var es;return{id:yt.id||`${be}-${ft}`,name:yt.name||yt.fileName||"Document",type:yt.type||yt.documentType||"Document",uploadDate:yt.uploadDate||(yt.createdAt?Yt(yt.createdAt):"N/A"),uploader:typeof yt.uploader=="string"?yt.uploader:((es=yt.uploader)==null?void 0:es.fullName)||yt.uploadedBy||"System",filePath:yt.filePath||yt.path}});A({open:!0,stageName:be,documents:He})},ye=async()=>{var be,ut,He,yt,ft,es,ts,Cs;if(!m&&!["assign","pushfnf","dispatch"].includes(o.type||"")){te.error("Please provide remarks (min 5 characters)");return}if(["sendBack","revoke"].includes(o.type||"")&&m.trim().length<5){te.error("Remarks are required for this action (min 5 characters).");return}if(o.type==="assign"&&!p){te.error("Please select a designation");return}try{Y(!0);const rn={action:o.type==="sendBack"?"sendBack":o.type,remarks:m,assignTo:N||p,force:S},Js=await Ee.updateResignationStatus(t,rn);if((be=Js.data)!=null&&be.success)te.success(((ut=Js.data)==null?void 0:ut.message)||"Action completed successfully"),d({open:!1,type:null}),f(""),h(""),v(""),j([]),R(!1),X();else{const an=((He=Js.data)==null?void 0:He.message)||"Failed to submit action";te.error(an),(yt=Js.data)!=null&&yt.canForce&&te.info(`${Pi} restriction: use "Push to F&F" and enable "Force Initiate F&F Settlement Immediately" if urgent.`)}}catch(Us){console.error("Error submitting action:",Us),te.error(((es=(ft=Us.response)==null?void 0:ft.data)==null?void 0:es.message)||"Failed to submit action"),(Cs=(ts=Us==null?void 0:Us.response)==null?void 0:ts.data)!=null&&Cs.canForce&&te.info(`${Pi} restriction: use "Push to F&F" with the force option if business-approved.`)}finally{Y(!1)}},Be=async()=>{var be,ut;if(!z){te.error("Please select a file to upload");return}try{Y(!0);const He=new FormData;He.append("file",z),He.append("documentType",I),G&&He.append("stage",G),await tc.uploadDocument(t,He),te.success("Document uploaded successfully"),M(!1),T(null),B(Gg[0]),K(""),X()}catch(He){te.error(((ut=(be=He==null?void 0:He.response)==null?void 0:be.data)==null?void 0:ut.message)||"Failed to upload document")}finally{Y(!1)}};return g.useEffect(()=>{(async()=>{if(o.type==="assign"&&(p||x)){const ut=setTimeout(async()=>{var He;try{C(!0);const yt={asm:"ASM",rbm:"RBM",zbh:"ZBH",nbh:"NBH",legal:"Legal Admin"},ft={limit:20,search:x};p&&(ft.roleCode=yt[p]||p);const es=await Ee.getUsers(ft);(He=es.data)!=null&&He.success&&j(es.data.data)}catch(yt){console.error("Error fetching users:",yt)}finally{C(!1)}},300);return()=>clearTimeout(ut)}})()},[p,x,o.type]),O&&!E?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(ns,{className:"w-8 h-8 animate-spin text-re-red"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(se,{variant:"outline",size:"icon",onClick:s,className:"hover:bg-slate-100 transition-colors",children:e.jsx(Jr,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl",children:(E==null?void 0:E.resignationId)||t}),e.jsx("p",{className:"text-slate-600",children:($e=E==null?void 0:E.outlet)==null?void 0:$e.name})]}),e.jsx(Ce,{className:(E==null?void 0:E.status)==="Completed"||(E==null?void 0:E.status)==="Settled"?"bg-green-100 text-green-700 border-green-300":(E==null?void 0:E.status)==="Rejected"||(E==null?void 0:E.status)==="Withdrawn"||(E==null?void 0:E.status)==="Revoked"?"bg-red-100 text-red-700 border-red-300":"bg-yellow-100 text-yellow-700 border-yellow-300",children:(E==null?void 0:E.status)==="Settled"?"Completed":lj((E==null?void 0:E.status)||"Pending")}),e.jsx(kr,{status:r("resignation",t)})]})}),e.jsxs(Bn,{defaultValue:"details",className:"w-full",children:[e.jsxs($n,{className:"bg-slate-100 p-1",children:[e.jsx(Wt,{value:"details",className:"data-[state=active]:bg-white",children:"Details"}),e.jsx(Wt,{value:"progress",className:"data-[state=active]:bg-white",children:"Progress"}),e.jsx(Wt,{value:"documents",className:"data-[state=active]:bg-white",children:"Documents"}),e.jsx(Wt,{value:"audit",className:"data-[state=active]:bg-white",children:"Audit Trail"}),Pe&&e.jsx(Wt,{value:"approvals",className:"data-[state=active]:bg-white",children:"Approval Summary"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 mt-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(Ut,{value:"details",className:"space-y-6",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Resignation Details"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Resignation Type"}),e.jsx("p",{children:E==null?void 0:E.resignationType})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Reason"}),e.jsx("p",{children:E==null?void 0:E.reason})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Last Operational Date (Sales)"}),e.jsx("p",{children:E!=null&&E.lastOperationalDateSales?Yt(E.lastOperationalDateSales,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Last Operational Date (Services)"}),e.jsx("p",{children:E!=null&&E.lastOperationalDateServices?Yt(E.lastOperationalDateServices,"date"):"N/A"})]})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Additional Info / Dealer Voice"}),e.jsx("p",{children:(E==null?void 0:E.additionalInfo)||"No additional info provided"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:E!=null&&E.submittedOn?Yt(E.submittedOn):"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:E==null?void 0:E.currentStage})]})]})]})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Request Information"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((dt=E==null?void 0:E.dealer)==null?void 0:dt.fullName)||((st=E==null?void 0:E.outlet)==null?void 0:st.name)})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:((Mt=(xt=E==null?void 0:E.dealer)==null?void 0:xt.dealerProfile)==null?void 0:Mt.gstNumber)||((It=E==null?void 0:E.outlet)==null?void 0:It.gstNumber)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Email"}),e.jsx("p",{children:((he=E==null?void 0:E.dealer)==null?void 0:he.email)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Sales Code"}),e.jsx("p",{children:((_e=(ht=(pt=E==null?void 0:E.dealer)==null?void 0:pt.dealerProfile)==null?void 0:ht.dealerCode)==null?void 0:_e.salesCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Service Code"}),e.jsx("p",{children:((_s=(Pt=(Vt=E==null?void 0:E.dealer)==null?void 0:Vt.dealerProfile)==null?void 0:Pt.dealerCode)==null?void 0:_s.serviceCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:((Ks=(Bs=(Ys=E==null?void 0:E.dealer)==null?void 0:Ys.dealerProfile)==null?void 0:Bs.dealerCode)==null?void 0:Ks.gmaCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Gear Code"}),e.jsx("p",{children:(($s=(Xs=(Qs=E==null?void 0:E.dealer)==null?void 0:Qs.dealerProfile)==null?void 0:Xs.dealerCode)==null?void 0:$s.gearCode)||"N/A"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(de,{className:"text-slate-600",children:"Address"}),e.jsx("p",{children:((oe=(Q=E==null?void 0:E.dealer)==null?void 0:Q.dealerProfile)==null?void 0:oe.registeredAddress)||((we=E==null?void 0:E.outlet)==null?void 0:we.address)})]})]})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Operational Details"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Inauguration"}),e.jsx("p",{children:(ke=(Oe=E==null?void 0:E.dealer)==null?void 0:Oe.dealerProfile)!=null&&ke.onboardedAt?Yt(E.dealer.dealerProfile.onboardedAt,"date"):(je=E==null?void 0:E.outlet)!=null&&je.inaugurationDate?Yt(E.outlet.inaugurationDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"LOA Date"}),e.jsx("p",{children:(Ge=(Ve=E==null?void 0:E.dealer)==null?void 0:Ve.dealerProfile)!=null&&Ge.loaDate?Yt(E.dealer.dealerProfile.loaDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"LOI Date"}),e.jsx("p",{children:(Zt=(nt=E==null?void 0:E.dealer)==null?void 0:nt.dealerProfile)!=null&&Zt.loiDate?Yt(E.dealer.dealerProfile.loiDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealership Type"}),e.jsx("p",{children:((mt=(lt=(Jt=E==null?void 0:E.dealer)==null?void 0:Jt.dealerProfile)==null?void 0:lt.application)==null?void 0:mt.businessType)||((Ds=E==null?void 0:E.outlet)==null?void 0:Ds.type)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"City Category"}),e.jsx("p",{children:((ss=E==null?void 0:E.outlet)==null?void 0:ss.cityCategory)||"N/A"})]})]})})]})]}),e.jsx(Ut,{value:"progress",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"Progress Timeline"}),e.jsx(Xt,{children:"Track the resignation request approval process"})]}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-4",children:ae.map((be,ut)=>{const He=vt(be.key),yt=a(be.name,be.key).length,ft=((E==null?void 0:E.timeline)||[]).filter(ts=>ts.stage===be.key||ts.stage===be.name),es=ft.length>0?ft[ft.length-1]:null;return e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${He==="completed"?"bg-green-100 text-green-600":He==="active"?"bg-blue-100 text-re-red":"bg-slate-100 text-slate-400"}`,children:He==="completed"?e.jsx(Hn,{className:"w-5 h-5"}):e.jsx("span",{children:be.id})}),ut<ae.length-1&&e.jsx("div",{className:`w-0.5 h-16 ${He==="completed"?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:"flex-1 pb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:He==="completed"?"text-green-600":He==="active"?"text-re-red":"text-slate-400",children:be.name}),yt>0&&e.jsxs("button",{onClick:()=>ge(be.name,be.key),className:"flex items-center gap-1 px-2 py-1 rounded-full bg-red-50 hover:bg-red-100 text-re-red-hover text-xs transition-colors cursor-pointer",children:[e.jsx(Ns,{className:"w-3 h-3"}),e.jsxs("span",{children:[yt," ",yt===1?"doc":"docs"]})]})]}),es&&e.jsxs("div",{className:"flex items-center gap-1 text-sm text-slate-600",children:[e.jsx(dr,{className:"w-4 h-4"}),e.jsx("span",{children:Yt(es.timestamp||es.createdAt)})]})]}),e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:be.description}),ft.length>0&&e.jsx("div",{className:"space-y-4 mt-3",children:ft.map((ts,Cs)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{variant:"secondary",className:"bg-slate-100 text-[10px] font-bold uppercase",children:ts.user||"System"}),e.jsx("span",{className:"text-[10px] text-slate-500 italic",children:ts.action}),e.jsx("span",{className:"text-[10px] text-slate-400 ml-auto",children:Yt(ts.timestamp||ts.createdAt)})]}),e.jsx("div",{className:"bg-slate-50 p-3 rounded-lg border border-slate-100 text-sm text-slate-700 shadow-sm",children:ts.comments||ts.remarks||"No remarks provided."})]},Cs))})]})]},be.id)})})})]})}),e.jsx(Ut,{value:"documents",children:e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Je,{children:"Documents"}),e.jsx(Xt,{children:"View and manage resignation documents"})]}),e.jsxs(se,{size:"sm",onClick:()=>M(!0),className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(or,{className:"w-4 h-4 mr-2"}),"Upload Document"]})]}),e.jsx(Fe,{children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Document Name"}),e.jsx(fe,{children:"Type"}),e.jsx(fe,{children:"Upload Date"}),e.jsx(fe,{children:"Uploader"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Os,{children:(()=>{var ut;const be=[...(E==null?void 0:E.documents)||[],...(E==null?void 0:E.uploadedDocuments)||[]];return E!=null&&E.departmentalClearances&&Object.entries(E.departmentalClearances).forEach(([He,yt])=>{yt.supportingDocument&&be.push({name:`${He} Clearance Proof`,type:"Clearance NOC",path:yt.supportingDocument,createdAt:yt.updatedAt,uploadedBy:yt.updatedBy||"Department Admin"})}),(ut=E==null?void 0:E.settlement)!=null&&ut.clearances&&E.settlement.clearances.forEach(He=>{He.supportingDocument&&be.push({name:`${He.department} Clearance NOC`,type:"Live NOC",path:He.supportingDocument,createdAt:He.clearedAt||He.updatedAt,uploadedBy:"Department Admin"})}),be.length===0?e.jsx(it,{children:e.jsx(ue,{colSpan:5,className:"text-center py-4 text-slate-500",children:"No documents found"})}):be.map((He,yt)=>{var ft;return e.jsxs(it,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"w-4 h-4 text-slate-500"}),e.jsx("span",{children:He.name||He.fileName})]})}),e.jsx(ue,{children:He.documentType||He.type||"Document"}),e.jsx(ue,{children:He.createdAt?Yt(He.createdAt):"N/A"}),e.jsx(ue,{children:((ft=He.uploader)==null?void 0:ft.fullName)||He.uploadedBy||"Dealer"}),e.jsx(ue,{children:e.jsx(se,{size:"sm",variant:"outline",onClick:()=>{const es=He.filePath||He.path,ts=es!=null&&es.startsWith("/uploads/")&&!es.startsWith("/uploads/documents/")?es.replace("/uploads/","/uploads/documents/"):es;W({fileName:He.fileName||He.name,filePath:ts,documentType:He.documentType||He.type})},children:"View"})})]},yt)})})()})]})})]})}),e.jsx(Ut,{value:"audit",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"Audit Trail"}),e.jsx(Xt,{children:"Complete history of actions on this resignation request"})]}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-4",children:P.length>0?P.map((be,ut)=>{var He,yt,ft,es,ts,Cs,Us,rn,Js,an,hn;return e.jsxs("div",{className:"flex gap-3 pb-6 border-b border-slate-100 last:border-0 relative",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-slate-300 mt-2 z-10"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:`
${(be.description||be.action||((He=be.details)==null?void 0:He.action)||"").toLowerCase().includes("reject")||(be.description||be.action||((yt=be.details)==null?void 0:yt.action)||"").toLowerCase().includes("revok")?"bg-red-100 text-red-700 border-red-200":(be.description||be.action||((ft=be.details)==null?void 0:ft.action)||"").toLowerCase().includes("sent back")||(be.description||be.action||((es=be.details)==null?void 0:es.action)||"").toLowerCase().includes("send back")?"bg-red-50 text-re-red-hover border-red-200":(be.description||be.action||((ts=be.details)==null?void 0:ts.action)||"").toLowerCase().includes("approv")||(be.description||be.action||((Cs=be.details)==null?void 0:Cs.action)||"").toLowerCase().includes("initi")?"bg-emerald-100 text-emerald-700 border-emerald-200":"bg-slate-100 text-slate-700 border-slate-200"}
`,children:be.description||be.action}),e.jsxs("span",{className:"text-xs text-slate-500 font-medium italic",children:["by ",((Us=be.actor)==null?void 0:Us.name)||be.userName||"System"]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:Yt(be.timestamp||be.createdAt)})]}),(be.remarks||((rn=be.newData)==null?void 0:rn.remarks)||((Js=be.details)==null?void 0:Js.remarks))&&e.jsx("div",{className:"p-3 bg-slate-50 border border-slate-100 rounded-lg text-sm text-slate-700 shadow-sm ml-1",children:be.remarks||((an=be.newData)==null?void 0:an.remarks)||((hn=be.details)==null?void 0:hn.remarks)})]})]},ut)}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:e.jsx("p",{children:"No activity logs found for this case."})})})})]})}),Pe&&e.jsx(Ut,{value:"approvals",children:e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Je,{children:"Approval Summary"}),e.jsx(Xt,{children:"Comprehensive view of all approvals and remarks"})]}),ve.canApprove&&e.jsxs(se,{onClick:()=>ee("approve"),className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Hn,{className:"w-4 h-4 mr-2"}),"Approve Request"]})]}),e.jsx(Fe,{children:e.jsxs(Ts,{className:"w-full border-collapse",children:[e.jsx(Ps,{children:e.jsxs(it,{className:"bg-slate-50/50",children:[e.jsx(fe,{className:"min-w-[120px]",children:"Stage"}),e.jsx(fe,{className:"min-w-[120px]",children:"Approver"}),e.jsx(fe,{className:"min-w-[200px]",children:"Action"}),e.jsx(fe,{className:"w-full min-w-[300px]",children:"Remarks"}),e.jsx(fe,{className:"min-w-[180px] text-right",children:"Date"})]})}),e.jsx(Os,{children:((E==null?void 0:E.timeline)||[]).length>0?E.timeline.map((be,ut)=>e.jsxs(it,{children:[e.jsx(ue,{className:"font-medium",children:be.stage}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",children:be.user||"System"})}),e.jsx(ue,{className:"whitespace-normal break-words",children:be.action}),e.jsx(ue,{className:"whitespace-normal break-words",children:be.remarks||be.comments||"-"}),e.jsx(ue,{className:"text-slate-500 whitespace-nowrap text-right",children:Yt(be.timestamp||be.createdAt)})]},ut)):e.jsx(it,{children:e.jsx(ue,{colSpan:5,className:"text-center py-6 text-slate-500",children:"No approval records found"})})})]})})]})})]}),e.jsx("div",{className:"space-y-6",children:e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Actions"})}),e.jsxs(Fe,{className:"space-y-3",children:[(()=>{const be=String((n==null?void 0:n.roleCode)||(n==null?void 0:n.role)||"").trim().toUpperCase(),ut=be==="DD LEAD"||be==="DD_LEAD",He=["DD Lead","DD Lead Review","DDL Review"].includes(E==null?void 0:E.currentStage);return ut&&He?e.jsxs(se,{variant:"outline",className:"w-full text-re-red-hover border-red-300 hover:bg-red-50",onClick:()=>{B("PPT Presentation"),K("DD Lead"),M(!0)},children:[e.jsx(or,{className:"w-4 h-4 mr-2"}),"Upload PPT"]}):null})(),ve.canApprove&&e.jsxs(se,{disabled:$,className:"w-full bg-green-600 hover:bg-green-700 font-bold",onClick:()=>ee("approve"),children:[$&&o.type==="approve"?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Hn,{className:"w-4 h-4 mr-2"}),"Approve"]}),ve.canDispatch&&e.jsxs(e.Fragment,{children:[ve.dispatchMissed&&e.jsxs("div",{className:"rounded-md border border-amber-300 bg-amber-50 text-amber-800 px-3 py-2 text-xs flex items-start gap-2",children:[e.jsx(sn,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:"Resignation acceptance letter was not dispatched at the DD Admin step. Please send it to the dealer now."})]}),e.jsxs(se,{disabled:$,className:`w-full font-bold ${ve.dispatchMissed?"bg-amber-600 hover:bg-amber-700":"bg-re-red hover:bg-re-red-hover"}`,onClick:()=>ee("dispatch"),children:[$&&o.type==="dispatch"?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Ur,{className:"w-4 h-4 mr-2"}),ve.dispatchMissed?"Dispatch Resignation Letter (Pending)":"Dispatch Resignation Letter"]})]}),ve.canSendBack&&e.jsxs(se,{variant:"outline",disabled:$,className:"w-full font-bold",onClick:()=>ee("sendBack"),children:[$&&o.type==="sendBack"?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(sb,{className:"w-4 h-4 mr-2"}),"Send Back"]}),ve.canWithdraw&&e.jsxs(se,{variant:"outline",disabled:$,className:"w-full text-red-600 border-red-300 hover:bg-red-50 font-bold",onClick:()=>ee("withdrawal"),children:[$&&o.type==="withdrawal"?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(ld,{className:"w-4 h-4 mr-2"}),"Withdrawal"]}),ve.canRevoke&&e.jsxs(se,{variant:"outline",disabled:$,className:"w-full text-orange-600 border-orange-300 hover:bg-orange-50 font-bold",onClick:()=>ee("revoke"),children:[$&&o.type==="revoke"?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Jy,{className:"w-4 h-4 mr-2"}),"Revoke"]}),ve.canPushToFnF&&e.jsxs(se,{variant:"outline",disabled:$,className:"w-full text-re-red-hover border-red-300 hover:bg-red-50",onClick:()=>ee("pushfnf"),children:[$&&o.type==="pushfnf"?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Gu,{className:"w-4 h-4 mr-2"}),"Push to F&F"]}),ve.canAssign&&e.jsxs(se,{variant:"outline",disabled:$,className:"w-full",onClick:()=>ee("assign"),children:[$&&o.type==="assign"?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(nb,{className:"w-4 h-4 mr-2"}),"Assign User"]}),e.jsx(ec,{}),e.jsxs(se,{variant:"outline",className:"w-full",onClick:()=>{var be;return i(`/worknotes/resignation/${t}`,{state:{applicationName:((be=E==null?void 0:E.outlet)==null?void 0:be.name)||"Resignation",registrationNumber:(E==null?void 0:E.resignationId)||"",participants:(E==null?void 0:E.participants)||[]}})},children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"View Work Notes",((Ae=E==null?void 0:E.worknotes)==null?void 0:Ae.length)>0&&e.jsx(Ce,{className:"ml-auto bg-re-red hover:bg-re-red-hover text-white h-5 px-2",children:E.worknotes.length})]})]})]})})]})]}),e.jsx(ds,{open:o.open,onOpenChange:be=>d({open:be,type:null}),children:e.jsxs(os,{children:[e.jsxs(xs,{children:[e.jsxs(ms,{children:[o.type==="approve"&&"Approve Resignation Request",o.type==="withdrawal"&&"Withdraw Resignation Request",o.type==="sendBack"&&"Send Back for Clarification",o.type==="revoke"&&"Revoke Resignation Request",o.type==="assign"&&"Assign to User",o.type==="pushfnf"&&"Push to Full & Final Settlement",o.type==="dispatch"&&"Dispatch Resignation Letter"]}),e.jsx(bs,{children:o.type==="assign"?"Select a user to assign this request to":o.type==="pushfnf"?"This will move the resignation request to F&F for dues clearance":o.type==="dispatch"?"The Legal-issued acceptance letter will be emailed to the dealer and the request will advance to Awaiting F&F. Remarks are optional.":"Please provide remarks for this action"})]}),e.jsx("div",{className:"space-y-4",children:o.type==="assign"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Designation Filter"}),e.jsxs(Dt,{value:p,onValueChange:be=>{h(be),v("")},children:[e.jsx(Et,{children:e.jsx(Rt,{placeholder:"All Roles"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"all",children:"All Roles"}),e.jsx(Me,{value:"asm",children:"ASM"}),e.jsx(Me,{value:"rbm",children:"RBM"}),e.jsx(Me,{value:"zbh",children:"ZBH"}),e.jsx(Me,{value:"nbh",children:"NBH"}),e.jsx(Me,{value:"legal",children:"Legal"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Search Name/Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(at,{placeholder:"Search...",value:x,onChange:be=>u(be.target.value),className:"pr-8"}),b&&e.jsx(ns,{className:"w-4 h-4 animate-spin absolute right-2 top-2.5 text-slate-400"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Select Specific Person *"}),e.jsxs(Dt,{value:N,onValueChange:v,children:[e.jsx(Et,{children:e.jsx(Rt,{placeholder:w.length>0?"Choose a user":"No users found"})}),e.jsx(_t,{className:"max-h-60",children:w.map(be=>e.jsx(Me,{value:be.id,children:e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("span",{className:"font-medium",children:be.fullName}),e.jsxs("span",{className:"text-[10px] text-slate-500",children:[be.roleCode," • ",be.email]})]})},be.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Assignment Remarks *"}),e.jsx(Ws,{value:m,onChange:be=>f(be.target.value),placeholder:"Why are you assigning this user?",rows:2})]})]}):o.type==="pushfnf"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-3 bg-red-50 border border-red-200 rounded-lg flex items-start gap-3",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red mt-0.5"}),e.jsxs("div",{className:"text-sm text-red-800",children:[e.jsx("p",{className:"font-bold",children:"Manual Trigger Notice"}),e.jsxs("p",{children:["Normally F&F is triggered after the ",Pi.toLowerCase(),". Use manual trigger only if urgent clearance is required."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"forceFnF",checked:S,onChange:be=>R(be.target.checked),className:"w-4 h-4 rounded border-slate-300"}),e.jsx(de,{htmlFor:"forceFnF",className:"font-medium text-slate-900 cursor-pointer",children:"Force Initiate F&F Settlement Immediately"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Remarks (Optional)"}),e.jsx(Ws,{value:m,onChange:be=>f(be.target.value),placeholder:"Add any additional notes...",rows:3})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Remarks *"}),e.jsx(Ws,{value:m,onChange:be=>f(be.target.value),placeholder:"Enter your remarks here...",rows:4})]})}),e.jsxs(bn,{children:[e.jsx(se,{variant:"outline",onClick:()=>d({open:!1,type:null}),disabled:$,children:"Cancel"}),e.jsx(se,{onClick:ye,disabled:$,className:o.type==="approve"?"bg-green-600 hover:bg-green-700":o.type==="withdrawal"?"bg-red-600 hover:bg-red-700":"bg-re-red hover:bg-re-red-hover",children:$?e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}),o.type==="dispatch"?"Dispatching...":"Processing..."]}):e.jsxs(e.Fragment,{children:[o.type==="approve"&&"Approve",o.type==="withdrawal"&&"Withdraw",o.type==="sendBack"&&"Send Back",o.type==="revoke"&&"Revoke",o.type==="assign"&&"Assign",o.type==="pushfnf"&&"Push to F&F",o.type==="dispatch"&&"Send to Dealer"]})})]})]})}),e.jsx(ds,{open:_.open,onOpenChange:be=>A({open:be,stageName:"",documents:[]}),children:e.jsxs(os,{className:Gb,children:[e.jsxs(xs,{children:[e.jsxs(ms,{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"w-5 h-5 text-re-red"}),"Documents - ",_.stageName]}),e.jsxs(bs,{children:["Documents uploaded for this stage (",_.documents.length," ",_.documents.length===1?"document":"documents",")"]})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto",children:_.documents.length>0?e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Document Name"}),e.jsx(fe,{children:"Type"}),e.jsx(fe,{children:"Upload Date"}),e.jsx(fe,{children:"Uploader"}),e.jsx(fe,{children:"Action"})]})}),e.jsx(Os,{children:_.documents.map(be=>e.jsxs(it,{children:[e.jsx(ue,{children:be.name}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",children:be.type})}),e.jsx(ue,{children:be.uploadDate}),e.jsx(ue,{children:be.uploader}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",className:"text-re-red hover:text-blue-700",onClick:()=>{if(!be.filePath)return;const ut=be.filePath.startsWith("/uploads/")&&!be.filePath.startsWith("/uploads/documents/")?be.filePath.replace("/uploads/","/uploads/documents/"):be.filePath;W({fileName:be.name,filePath:ut,documentType:be.type})},children:[e.jsx(Ns,{className:"w-4 h-4 mr-1"}),"View"]})})]},be.id))})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded for this stage yet"})}),e.jsx(bn,{children:e.jsx(se,{variant:"outline",onClick:()=>A({open:!1,stageName:"",documents:[]}),children:"Close"})})]})}),e.jsx(ds,{open:U,onOpenChange:M,children:e.jsxs(os,{children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Upload Resignation Document"}),e.jsx(bs,{children:"Add a document and map it to a stage (optional)."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Document Type"}),e.jsxs(Dt,{value:I,onValueChange:B,children:[e.jsx(Et,{children:e.jsx(Rt,{placeholder:"Select document type"})}),e.jsx(_t,{children:Gg.map(be=>e.jsx(Me,{value:be,children:be},be))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Stage (Optional)"}),e.jsxs(Dt,{value:G||"none",onValueChange:be=>K(be==="none"?"":be),children:[e.jsx(Et,{children:e.jsx(Rt,{placeholder:"Select stage"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"none",children:"No Stage Mapping"}),hV.map(be=>e.jsx(Me,{value:be,children:be},be))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"File"}),e.jsx(at,{type:"file",onChange:be=>{var ut;return T(((ut=be.target.files)==null?void 0:ut[0])||null)}})]})]}),e.jsxs(bn,{children:[e.jsx(se,{variant:"outline",onClick:()=>M(!1),disabled:$,children:"Cancel"}),e.jsx(se,{onClick:Be,disabled:$,children:$?"Uploading...":"Upload"})]})]})}),e.jsx(mo,{isOpen:!!Z,onClose:()=>W(null),document:Z})]})}const qo={getTerminationById:async t=>{const n=(await Ee.getTerminationById(t)).data;return(n==null?void 0:n.termination)||(n==null?void 0:n.data)||n},updateTerminationStatus:async(t,s,n,r)=>(await Ee.updateTerminationStatus(t,{action:s,remarks:n,...r!=null&&r.force?{force:!0}:{}})).data,issueSCN:async(t,s)=>(await Ee.issueSCN(t,s)).data,uploadSCNResponse:async(t,s,n)=>{const r=new FormData;return r.append("file",s),n&&r.append("remarks",n),(await Ee.uploadSCNResponse(t,r)).data},uploadDocument:async(t,s)=>(await Ee.uploadTerminationDocument(t,s)).data,finalizeTermination:async(t,s,n)=>(await Ee.finalizeTermination(t,{decision:s,remarks:n})).data},Nf=t=>String(t||"").toLowerCase().replace(/\s+/g," ").trim(),xV="Evaluation of Dealer SCN Response",gV=t=>{const s=Nf(t);return s?!!(s===Nf(xV)||s.includes("evaluation")&&s.includes("scn")&&s.includes("response")||s.includes("personal hearing")):!1},vV=t=>{const s=Nf(t);return s.includes("rbm")&&(s.includes("dd-zm")||s.includes("dd zm"))};function yV(t){const s=Nf(t);return s.includes("sent back")||s.includes("send back")||s.includes("reconsider")||s.includes("reconsideration")}function PS(t,s){if(!Array.isArray(t)||t.length===0)return null;const n=s==="scn_response_eval"?gV:vV,r=t;for(let a=r.length-1;a>=0;a--){const i=r[a];if(!yV(i==null?void 0:i.action)||!n(i==null?void 0:i.targetStage))continue;const o=(i==null?void 0:i.timestamp)!=null?new Date(i.timestamp).getTime():NaN;if(!Number.isNaN(o))return o}return null}function bV(t){const s=t.createdAt??t.timestamp;if(s==null)return 0;const n=new Date(s).getTime();return Number.isNaN(n)?0:n}function jV(t,s){return s==null?!0:bV(t)>=s}function NV({terminationId:t,onBack:s,currentUser:n}){var Bs,Ks,Qs,Xs,$s,Q,oe,we,Oe,ke,je,Ve,Ge,nt,Zt,Jt,lt,mt,Ds,ss,Ae,be,ut,He,yt,ft,es,ts,Cs,Us,rn,Js,an,hn;const r=tr(),{get:a}=pc(t?[{entityType:"termination",entityId:t}]:[],!!t),[i,o]=g.useState({open:!1,type:null}),[d,m]=g.useState(""),[f,p]=g.useState(""),[h,x]=g.useState(!1),[u,N]=g.useState({open:!1,stageName:"",documents:[]}),[v,w]=g.useState(!0),[j,b]=g.useState(null),[C,S]=g.useState([]),[R,_]=g.useState(!1),[A,E]=g.useState(null),[q,O]=g.useState(""),[D,P]=g.useState(!1),[L,$]=g.useState(!1),[Y,Z]=g.useState("Approve"),[W,U]=g.useState(""),[M,z]=g.useState(!1),[T,I]=g.useState(null),[B,G]=g.useState(Kg[0]),[K,H]=g.useState(""),[X,J]=g.useState(null),ae=async()=>{try{w(!0);const De=await qo.getTerminationById(t);b(De),le()}catch(De){console.error("Error fetching termination:",De)}finally{w(!1)}},le=async()=>{try{const De=await Ee.getAuditLogs("termination",t);De.data&&De.data.success&&S(De.data.data||[])}catch(De){console.error("Error fetching audit logs:",De)}};if(g.useEffect(()=>{ae()},[t]),v)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:[e.jsx(ns,{className:"w-8 h-8 text-re-red animate-spin"}),e.jsx("p",{className:"text-slate-600",children:"Loading termination details..."})]});const xe=async()=>{try{P(!0),await qo.issueSCN(t,{remarks:q}),te.success("SCN issued successfully"),_(!1),ae()}catch{te.error("Failed to issue SCN")}finally{P(!1)}},ce=async()=>{if(A)try{P(!0),await qo.uploadSCNResponse(t,A,q),te.success("SCN response uploaded"),_(!1),ae()}catch{te.error("Failed to upload response")}finally{P(!1)}},ve=async()=>{try{P(!0),await qo.finalizeTermination(t,Y,W),te.success(`Termination ${Y.toLowerCase()}ed`),$(!1),ae()}catch{te.error("Failed to finalize termination")}finally{P(!1)}},Pe=async()=>{if(!T){te.error("Please select a file to upload");return}try{P(!0);const De=new FormData;De.append("file",T),De.append("documentType",B),K&&De.append("stage",K),await qo.uploadDocument(t,De),te.success("Document uploaded successfully"),z(!1),I(null),G(Kg[0]),H(""),ae()}catch{te.error("Failed to upload document")}finally{P(!1)}},et=n&&["DD Lead","DD Head","DD_HEAD","NBH","DD Admin","Super Admin"].includes(n.role||n.roleCode),kt={Submitted:["Submitted"],"RBM + DD-ZM Review":["RBM + DD-ZM Review"],"ZBH Review":["ZBH Review"],"DD Lead Review":["DD Lead Review"],"Legal Verification":["Legal Verification"],"DD Head Review":["DD Head Review"],"NBH Evaluation":["NBH Evaluation"],"Show Cause Notice (SCN)":["Show Cause Notice","Show Cause Notice (SCN)","SCN"],"Evaluation of Dealer SCN Response":["Evaluation of Dealer SCN Response","Personal Hearing"],"NBH Final Approval":["NBH Final Approval"],"CCO Approval":["CCO Approval"],"CEO Final Approval":["CEO Final Approval"],"Legal - Termination Letter":["Legal - Termination Letter"],"Dealer Terminated":["Terminated","Dealer Terminated"]},vt=["Submitted","RBM + DD-ZM Review","ZBH Review","DD Lead Review","Legal Verification","DD Head Review","NBH Evaluation","Show Cause Notice (SCN)","Evaluation of Dealer SCN Response","NBH Final Approval","CCO Approval","CEO Final Approval","Legal - Termination Letter","Dealer Terminated"],ge=(()=>{if(!j||!n)return{canApprove:!1,canWithdraw:!1,canIssueSCN:!1,canUploadSCNResponse:!1,canFinalize:!1,canPushToFnF:!1};const De=j.currentStage,bt=j.status,Te=n.role||n.roleCode,ct=["Show Cause Notice (SCN)","SCN"].includes(De),tt=["Completed","Rejected","Withdrawn","Terminated"].includes(bt)||De==="Terminated",jt=bt==="F&F Initiated"||De==="F&F Initiated"||bt==="Settled"||bt==="FNF_INITIATED",Ht=(()=>{const qs=new Date;qs.setHours(0,0,0,0);const ln=j.proposedLwd;if(!ln)return!0;const fn=new Date(ln);return fn.setHours(0,0,0,0),qs>=fn})(),zt=PS(j.timeline,"scn_response_eval"),fs=PS(j.timeline,"rbm_review"),qt=De==="Evaluation of Dealer SCN Response"||De==="Personal Hearing",As=De==="RBM + DD-ZM Review"?fs:qt?zt:null,vs=C.some(qs=>{var jn,xn,qn;if(!jV(qs,As))return!1;const ln=qs.userId||((jn=qs.user)==null?void 0:jn.id)||((xn=qs.actor)==null?void 0:xn.id)||qs.actorId,fn=String(ln)===String(n.id),on=(qs.action||qs.description||"").toUpperCase(),Ye=on.includes("PARTIAL_APPROVE")||on.includes("PARTIAL APPROVED"),Ot=((qn=qs.details)==null?void 0:qn.stage)||qs.stage||"",St=Ot==="RBM + DD-ZM Review"||(qs.remarks||"").includes("Partial approval by"),rt=Ot==="Evaluation of Dealer SCN Response"||Ot==="Personal Hearing"||(qs.remarks||"").includes("SCN Response Review by");return fn&&Ye&&(De==="RBM + DD-ZM Review"&&St||qt&&rt)}),cs=qs=>(kt[qs]||[qs]).includes(De);return{canApprove:(Te==="Super Admin"||cs("RBM + DD-ZM Review")&&(Te==="RBM"||Te==="DD-ZM")&&!vs||cs("ZBH Review")&&Te==="ZBH"||cs("DD Lead Review")&&Te==="DD Lead"||cs("Legal Verification")&&Te==="Legal Admin"||cs("DD Head Review")&&(Te==="DD Head"||Te==="DD_HEAD")||cs("NBH Evaluation")&&Te==="NBH"||cs("Evaluation of Dealer SCN Response")&&["DD Lead","ZBH","RBM","DD Head","DD_HEAD"].includes(Te)&&!vs||cs("NBH Final Approval")&&Te==="NBH"||cs("CCO Approval")&&Te==="CCO"||cs("CEO Final Approval")&&Te==="CEO"||cs("Legal - Termination Letter")&&Te==="Legal Admin")&&!tt&&!jt&&!["NBH Final Approval","CCO Approval","CEO Final Approval","Show Cause Notice (SCN)","SCN"].includes(De),canIssueSCN:De==="NBH Evaluation"&&(Te==="NBH"||Te==="Super Admin")&&!tt,canUploadSCNResponse:ct&&["Legal Admin","DD Admin","DD Lead","Super Admin"].includes(Te)&&!tt,canHold:(cs("NBH Evaluation")||cs("NBH Final Approval"))&&(Te==="NBH"||Te==="Super Admin")&&bt!=="On Hold"&&!tt,canFinalize:(De==="NBH Final Approval"&&Te==="NBH"||De==="CCO Approval"&&Te==="CCO"||De==="CEO Final Approval"&&Te==="CEO"||Te==="Super Admin")&&["NBH Final Approval","CCO Approval","CEO Final Approval"].includes(De)&&!tt,canPushToFnF:et&&!jt&&!j.fnfSettlement&&(De==="Terminated"||bt===Hc.AWAITING_FNF||bt===Hc.AWAITING_FNF_LWD_PENDING)&&Ht,isLwdReached:Ht,canWithdraw:Te==="ASM"&&De==="Request Initiated"&&!tt,isFinalState:tt,isSettlementPhase:jt}})(),ye=j||{},Be=["Show Cause Notice","Show Cause Notice (SCN)","SCN"].includes(ye.currentStage),$e=De=>{if(!De)return"";const bt=String(De).trim();return vt.find(ct=>(kt[ct]||[ct]).includes(bt))||bt},dt=De=>{const bt=kt[De]||[De];return(ye.timeline||[]).some(Te=>Te!=null&&Te.stage?!!(bt.includes(Te.stage)||De==="Submitted"&&(Te.stage==="Submitted"||Te.stage==="Request Initiated")):!1)},st=De=>{const bt=["Rejected","Revoked","Withdrawn"].includes(ye.status),Te=["Completed","Terminated","Settled","F&F Initiated","FNF_INITIATED",Hc.AWAITING_FNF,Hc.AWAITING_FNF_LWD_PENDING].includes(ye.status)||ye.currentStage==="Terminated";let ct=ye.currentStage||ye.status;if(bt&&(ye.currentStage==="Rejected"||ye.currentStage==="Revoked"||!ye.currentStage)){const zt=[...ye.timeline||[]].reverse().find(fs=>fs.stage&&fs.stage!=="Rejected"&&fs.stage!=="Revoked");zt&&(ct=zt.stage)}const tt=$e(ct),jt=vt.indexOf(tt),Ht=vt.indexOf(De);return Te&&Ht<=jt?Ht<jt&&De!=="Submitted"&&!dt(De)?"skipped":"completed":Ht===-1?"pending":jt===-1?De==="Submitted"?"completed":"pending":Ht<jt?De!=="Submitted"&&!dt(De)?"skipped":"completed":Ht===jt?bt?"completed":"active":"pending"},xt=[...ye.documents||[],...ye.uploadedDocuments||[]],Mt=Object.keys(kt).reduce((De,bt)=>{const Te=kt[bt]||[bt],ct=xt.filter(tt=>!tt.stage||Te.includes(tt.stage)).map(tt=>{var jt;return{id:tt.id||`${bt}-${tt.fileName||tt.name}`,name:tt.fileName||tt.name||"Document",type:tt.documentType||tt.type||"Document",uploadDate:tt.uploadDate||tt.createdAt?Yt(tt.uploadDate||tt.createdAt):"N/A",uploader:((jt=tt.uploader)==null?void 0:jt.fullName)||tt.uploader||"-",path:tt.filePath||tt.path||tt.url}});return De[bt]=ct,De},{}),It=De=>{const bt=kt[De]||[De];return(ye.timeline||[]).filter(ct=>bt.includes(ct.stage)||De==="Submitted"&&(ct.stage==="Submitted"||ct.stage==="Request Initiated")).sort((ct,tt)=>new Date(ct.timestamp).getTime()-new Date(tt.timestamp).getTime())},pt=String(ye.category||"").trim().toLowerCase().includes("unethical")?"Unethical Practice category — request was escalated directly to DD Lead Review.":null,ht=[{id:1,name:"Submitted",status:st("Submitted"),description:"Termination request initiated",date:"",actionType:"",actionBy:"",remarks:"",feedback:""},{id:2,name:"RBM + DD-ZM Review",status:st("RBM + DD-ZM Review"),description:"Joint review and approval by RBM and DD-ZM"},{id:3,name:"ZBH Review",status:st("ZBH Review"),description:"Zonal Business Head evaluation"},{id:4,name:"DD Lead Review",status:st("DD Lead Review"),description:"DD Lead validation"},{id:5,name:"Legal Verification",status:st("Legal Verification"),description:"Legal team validates termination grounds"},{id:6,name:"DD Head Review",status:st("DD Head Review"),description:"DD Head strategic review"},{id:7,name:"NBH Evaluation",status:st("NBH Evaluation"),description:"National Business Head decision"},{id:8,name:"Show Cause Notice (SCN)",status:st("Show Cause Notice (SCN)"),description:"SCN sent to dealer, awaiting response"},{id:9,name:"Evaluation of Dealer SCN Response",status:st("Evaluation of Dealer SCN Response"),description:"Joint evaluation of SCN response by DD-Lead, ZBH, RBM, and DD-Head"},{id:10,name:"NBH Final Approval",status:st("NBH Final Approval"),description:"NBH final termination decision"},{id:11,name:"CCO Approval",status:st("CCO Approval"),description:"Chief Commercial Officer approval"},{id:12,name:"CEO Final Approval",status:st("CEO Final Approval"),description:"CEO final authorization"},{id:13,name:"Legal - Termination Letter",status:st("Legal - Termination Letter"),description:"Legal team issues final termination letter"},{id:14,name:"Dealer Terminated",status:st("Dealer Terminated"),description:"Dealership termination effective",date:"",actionType:"",actionBy:"",remarks:"",feedback:""}],_e=De=>{const bt=Mt[De]||[];N({open:!0,stageName:De,documents:bt})},Vt=De=>{o({open:!0,type:De})},Pt=async()=>{var ct,tt,jt,Ht,zt,fs;const De=i.type,bt=De==="sendBack"?"sendBack":De||"approve",Te=d.trim();if(["sendBack","revoke"].includes(De||"")&&Te.length<5){te.error("Please provide detailed remarks (minimum 5 characters required for Send Back / Revoke)");return}if(!Te&&!["assign","pushfnf"].includes(De||"")){te.error("Please provide remarks/comments for this action");return}if(De==="assign"&&!f){te.error("Please select a user");return}P(!0);try{let qt;if(De==="approve"||De==="sendBack"||De==="withdrawal"||De==="revoke"||De==="hold")qt=await qo.updateTerminationStatus(t,bt,d);else if(De==="pushfnf")qt=await qo.updateTerminationStatus(t,"pushfnf",d,{force:h});else{te.error("Action logic not fully implemented for this type"),P(!1);return}if(qt&&(qt.success===!1||qt.ok===!1)){console.error("[TerminationDetails] Action failed:",qt);const vs=qt.message||((ct=qt.data)==null?void 0:ct.message)||"Failed to perform action";te.error(vs),(qt.canForce||(tt=qt.data)!=null&&tt.canForce)&&te.info('Enable "Force initiate F&F" in the dialog if an exception is approved.'),P(!1);return}const As={approve:"Request approved and forwarded",withdrawal:"Request withdrawn successfully",sendBack:"Request sent back for clarification",assign:"Request assigned successfully",pushfnf:"Request pushed to F&F successfully",revoke:"Request revoked and withdrawn"};te.success(As[De]||(qt==null?void 0:qt.message)||"Action completed"),o({open:!1,type:null}),m(""),p(""),x(!1),ae()}catch(qt){const As=((Ht=(jt=qt.response)==null?void 0:jt.data)==null?void 0:Ht.message)||"Failed to perform action";te.error(As),(fs=(zt=qt==null?void 0:qt.response)==null?void 0:zt.data)!=null&&fs.canForce&&te.info('Enable "Force initiate F&F" in the dialog if an exception is approved.')}finally{P(!1)}},_s=De=>{switch(De){case"Critical":return"bg-red-100 text-red-700 border-red-300";case"High":return"bg-orange-100 text-orange-700 border-orange-300";case"Medium":return"bg-yellow-100 text-yellow-700 border-yellow-300";default:return"bg-blue-100 text-blue-700 border-blue-300"}},Ys=(ye.worknotes||[]).length;return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(se,{variant:"outline",size:"icon",onClick:s,className:"hover:bg-slate-100 transition-colors",children:e.jsx(Jr,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl",children:ye.requestId||t}),e.jsx("p",{className:"text-slate-600",children:((Bs=ye.dealer)==null?void 0:Bs.businessName)||((Ks=ye.dealer)==null?void 0:Ks.legalName)||"Termination"})]}),e.jsx(Ce,{className:_s(ye.severity),children:ye.severity}),e.jsx(Ce,{className:ye.status==="Completed"||ye.status==="Terminated"||ye.status==="Settled"?"bg-green-100 text-green-700 border-green-300":ye.status==="Rejected"||ye.status==="Withdrawn"?"bg-red-100 text-red-700 border-red-300":"bg-yellow-100 text-yellow-700 border-yellow-300",children:ye.status==="Settled"?"Completed":lj(ye.status||"Pending")}),e.jsx(kr,{status:a("termination",t)})]})}),e.jsxs(Bn,{defaultValue:"details",className:"w-full",children:[e.jsxs($n,{className:"bg-slate-100 p-1",children:[e.jsx(Wt,{value:"details",className:"data-[state=active]:bg-white",children:"Details"}),e.jsx(Wt,{value:"progress",className:"data-[state=active]:bg-white",children:"Progress"}),e.jsx(Wt,{value:"documents",className:"data-[state=active]:bg-white",children:"Documents"}),e.jsx(Wt,{value:"audit",className:"data-[state=active]:bg-white",children:"Audit Trail"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 mt-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(Ut,{value:"details",className:"space-y-6",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Dealer Information"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:((Xs=(Qs=ye.dealer)==null?void 0:Qs.dealerCode)==null?void 0:Xs.dealerCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:(($s=ye.dealer)==null?void 0:$s.businessName)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:((Q=ye.dealer)==null?void 0:Q.gstNumber)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Email"}),e.jsx("p",{children:((we=(oe=ye.dealer)==null?void 0:oe.user)==null?void 0:we.email)||"N/A"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(de,{className:"text-slate-600",children:"Address"}),e.jsx("p",{children:((Oe=ye.dealer)==null?void 0:Oe.registeredAddress)||((je=(ke=ye.dealer)==null?void 0:ke.application)==null?void 0:je.address)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"City"}),e.jsx("p",{children:((Ge=(Ve=ye.dealer)==null?void 0:Ve.application)==null?void 0:Ge.city)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"District"}),e.jsx("p",{children:((Jt=(Zt=(nt=ye.dealer)==null?void 0:nt.application)==null?void 0:Zt.district)==null?void 0:Jt.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealership Name"}),e.jsx("p",{children:((lt=ye.dealer)==null?void 0:lt.businessName)||ye.dealershipName})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Sales Code"}),e.jsx("p",{children:((Ds=(mt=ye.dealer)==null?void 0:mt.dealerCode)==null?void 0:Ds.salesCode)||ye.salesCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Service Code"}),e.jsx("p",{children:((Ae=(ss=ye.dealer)==null?void 0:ss.dealerCode)==null?void 0:Ae.serviceCode)||ye.serviceCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:((ut=(be=ye.dealer)==null?void 0:be.dealerCode)==null?void 0:ut.gmaCode)||ye.accessoriesCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:((yt=(He=ye.dealer)==null?void 0:He.dealerCode)==null?void 0:yt.gmaCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Gear Code"}),e.jsx("p",{children:((es=(ft=ye.dealer)==null?void 0:ft.dealerCode)==null?void 0:es.gearCode)||"N/A"})]})]})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Operational Details"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Inauguration"}),e.jsx("p",{children:(ts=ye.dealer)!=null&&ts.onboardedAt?Yt(ye.dealer.onboardedAt,"date"):ye.inauguration||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"LOA Date"}),e.jsx("p",{children:(Cs=ye.dealer)!=null&&Cs.loaDate?Yt(ye.dealer.loaDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"LOI Date"}),e.jsx("p",{children:(Us=ye.dealer)!=null&&Us.loiDate?Yt(ye.dealer.loiDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Last 6 Months Sales"}),e.jsx("p",{children:ye.lastSixMonthsSales})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Number of Dealerships"}),e.jsx("p",{children:ye.numberOfDealerships})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Number of Studios"}),e.jsx("p",{children:ye.numberOfStudios})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Constitution"}),e.jsx("p",{children:((rn=ye.dealer)==null?void 0:rn.constitutionType)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealership Type"}),e.jsx("p",{children:((an=(Js=ye.dealer)==null?void 0:Js.application)==null?void 0:an.businessType)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Type of Closure"}),e.jsx("p",{children:ye.typeOfClosure||"Complete"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Format Category"}),e.jsx("p",{children:ye.formatCategory||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Score Card Band"}),e.jsx("p",{children:ye.dealerScoreCardBand||"N/A"})]})]})})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50/30",children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"text-red-900 flex items-center gap-2",children:[e.jsx(Ha,{className:"w-5 h-5"}),"Termination Details"]})}),e.jsx(Fe,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Termination Category"}),e.jsx("p",{className:"text-red-900",children:ye.category})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Sub Category"}),e.jsx("p",{children:ye.subCategory||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Description"}),e.jsx("p",{children:ye.reason})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Severity"}),e.jsx("div",{className:"mt-1",children:e.jsx(Ce,{className:_s(ye.severity),children:ye.severity})})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Submitted By"}),e.jsx("p",{children:((hn=ye.initiator)==null?void 0:hn.fullName)||"System"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Yt(ye.createdAt)})]})]})]})})]})]}),e.jsx(Ut,{value:"progress",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"Termination Progress Timeline"}),e.jsx(Xt,{children:"Track the termination request approval process"})]}),e.jsxs(Fe,{children:[pt&&ht.some(De=>De.status==="skipped")&&e.jsxs(di,{className:"mb-4 border-amber-300 bg-amber-50 text-amber-900",children:[e.jsx(_a,{className:"h-4 w-4 text-amber-600"}),e.jsx(_i,{children:"Fast-tracked workflow"}),e.jsxs(ui,{children:[pt," Stages marked “Skipped” below were intentionally bypassed and never reviewed."]})]}),e.jsx("div",{className:"space-y-4",children:ht.map((De,bt)=>{var tt,jt,Ht;const Te=((tt=Mt[De.name])==null?void 0:tt.length)||0,ct=It(De.name);return e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${De.status==="completed"?"bg-green-100 text-green-600":De.status==="active"?"bg-red-50 text-re-red":De.status==="skipped"?"bg-amber-50 text-amber-600 border border-dashed border-amber-300":"bg-slate-100 text-slate-400"}`,children:De.status==="completed"?e.jsx(Hn,{className:"w-5 h-5"}):De.status==="active"?e.jsx(Ha,{className:"w-5 h-5"}):De.status==="skipped"?e.jsx(A1,{className:"w-5 h-5"}):e.jsx("span",{children:De.id})}),bt<ht.length-1&&e.jsx("div",{className:`w-0.5 ${De.remarks?"h-32":"h-16"} ${De.status==="completed"?"bg-green-300":De.status==="skipped"?"bg-amber-200":"bg-slate-200"}`})]}),e.jsxs("div",{className:"flex-1 pb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:De.status==="completed"?"text-green-600":De.status==="active"?"text-re-red":De.status==="skipped"?"text-amber-700":"text-slate-400",children:De.name}),De.status==="skipped"&&e.jsx(Ce,{className:"bg-amber-100 text-amber-800 border-amber-300 hover:bg-amber-100",title:pt||"This stage was bypassed by the workflow.",children:"Skipped"}),Te>0&&e.jsxs("button",{onClick:()=>_e(De.name),className:"flex items-center gap-1 px-2 py-1 rounded-full bg-red-50 hover:bg-red-100 text-re-red-hover text-xs transition-colors cursor-pointer",children:[e.jsx(Ns,{className:"w-3 h-3"}),e.jsxs("span",{children:[Te," ",Te===1?"doc":"docs"]})]})]}),(((jt=ct[0])==null?void 0:jt.timestamp)||De.date)&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-slate-500 bg-slate-50 px-2 py-0.5 rounded-full border border-slate-100",children:[e.jsx(dr,{className:"w-3 h-3"}),e.jsx("span",{children:Yt(((Ht=ct[0])==null?void 0:Ht.timestamp)||De.date)})]})]}),e.jsx("p",{className:"text-slate-600 text-sm",children:De.description}),De.status==="skipped"&&e.jsxs("p",{className:"text-xs text-amber-700 mt-1 flex items-center gap-1",children:[e.jsx(A1,{className:"w-3 h-3"}),pt?`Bypassed — ${pt}`:"This stage was bypassed by the workflow and not reviewed."]}),ct.length>0&&e.jsx("div",{className:"mt-3 space-y-3",children:ct.map((zt,fs)=>{var cs,mn,qs;const qt=zt.remarks||zt.comments||"",As=qt==null?void 0:qt.startsWith("Attachment:"),vs=As?qt.replace("Attachment:","").trim():qt;return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ce,{className:`
text-[10px] h-4 px-1.5
${(cs=zt.action)!=null&&cs.toLowerCase().includes("rejected")||(mn=zt.action)!=null&&mn.toLowerCase().includes("revoked")?"bg-red-100 text-red-700":(qs=zt.action)!=null&&qs.toLowerCase().includes("approved")?"bg-emerald-100 text-emerald-700":"bg-blue-100 text-blue-700"}
`,children:zt.action||"Action"}),e.jsxs("span",{className:"text-[10px] text-slate-500 font-medium",children:["by ",zt.user||"System",zt.role?` (${zt.role})`:""," • ",Yt(zt.timestamp)]})]}),e.jsx("div",{className:`
p-2.5 rounded-lg border text-sm
${As?"bg-red-50/50 border-red-100 text-red-900":"bg-slate-50 border-slate-100 text-slate-700"}
`,children:As?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"w-3.5 h-3.5 text-re-red"}),e.jsx("span",{className:"font-medium truncate",children:vs})]}):e.jsx("p",{className:"leading-relaxed",children:vs||"No remarks provided."})})]},fs)})})]})]},De.id)})})]})]})}),e.jsx(Ut,{value:"documents",children:e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Je,{children:"Documents"}),e.jsx(Xt,{children:"View and manage termination case documents"})]}),e.jsxs(se,{size:"sm",onClick:()=>z(!0),className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(or,{className:"w-4 h-4 mr-2"}),"Upload Document"]})]}),e.jsx(Fe,{children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Document Name"}),e.jsx(fe,{children:"Type"}),e.jsx(fe,{children:"Upload Date"}),e.jsx(fe,{children:"Uploader"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Os,{children:(()=>{const De=[...ye.documents||[],...ye.uploadedDocuments||[]];return De.length===0?e.jsx(it,{children:e.jsx(ue,{colSpan:5,className:"text-center py-4 text-slate-500",children:"No documents found"})}):De.map((bt,Te)=>{var ct;return e.jsxs(it,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"w-4 h-4 text-slate-500"}),e.jsx("span",{children:bt.name||bt.fileName})]})}),e.jsx(ue,{children:bt.documentType||bt.type||"Document"}),e.jsx(ue,{children:Yt(bt.uploadDate||bt.createdAt)}),e.jsx(ue,{children:((ct=bt.uploader)==null?void 0:ct.fullName)||bt.uploader||"-"}),e.jsx(ue,{children:e.jsx(se,{size:"sm",variant:"outline",onClick:()=>{const tt=bt.filePath||bt.path||bt.url;if(!tt)return;const jt=tt.startsWith("/uploads/")&&!tt.startsWith("/uploads/documents/")?tt.replace("/uploads/","/uploads/documents/"):tt;J({fileName:bt.name||bt.fileName||"Document",filePath:jt,documentType:bt.documentType||bt.type||"Document"})},children:"View"})})]},bt.id||Te)})})()})]})})]})}),e.jsx(Ut,{value:"audit",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"Audit Trail"}),e.jsx(Xt,{children:"Complete history of actions on this termination case"})]}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-4",children:C.length>0?C.map((De,bt)=>{var Te,ct,tt,jt,Ht,zt,fs,qt,As,vs,cs;return e.jsxs("div",{className:"flex gap-3 pb-6 border-b border-slate-100 last:border-0 relative",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-slate-300 mt-2 z-10"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:`
${(De.description||De.action||((Te=De.details)==null?void 0:Te.action)||"").toLowerCase().includes("reject")||(De.description||De.action||((ct=De.details)==null?void 0:ct.action)||"").toLowerCase().includes("revok")?"bg-red-100 text-red-700 border-red-200":(De.description||De.action||((tt=De.details)==null?void 0:tt.action)||"").toLowerCase().includes("sent back")||(De.description||De.action||((jt=De.details)==null?void 0:jt.action)||"").toLowerCase().includes("send back")?"bg-red-50 text-re-red-hover border-red-200":(De.description||De.action||((Ht=De.details)==null?void 0:Ht.action)||"").toLowerCase().includes("approv")||(De.description||De.action||((zt=De.details)==null?void 0:zt.action)||"").toLowerCase().includes("initi")?"bg-emerald-100 text-emerald-700 border-emerald-200":"bg-slate-100 text-slate-700 border-slate-200"}
`,children:De.description||De.action}),e.jsxs("span",{className:"text-xs text-slate-500 font-medium italic",children:["by ",((fs=De.actor)==null?void 0:fs.name)||De.userName||"System"]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:Yt(De.timestamp||De.createdAt)})]}),(De.remarks||((qt=De.newData)==null?void 0:qt.remarks)||((As=De.details)==null?void 0:As.remarks))&&e.jsx("div",{className:"p-3 bg-slate-50 border border-slate-100 rounded-lg text-sm text-slate-700 shadow-sm ml-1",children:De.remarks||((vs=De.newData)==null?void 0:vs.remarks)||((cs=De.details)==null?void 0:cs.remarks)})]})]},bt)}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:e.jsx("p",{children:"No activity logs found for this case."})})})})]})})]}),e.jsx("div",{className:"space-y-6",children:e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Actions"})}),e.jsxs(Fe,{className:"space-y-3",children:[(ye.currentStage==="Evaluation of Dealer SCN Response"||ye.currentStage==="Personal Hearing")&&e.jsxs(di,{className:"mb-2 bg-blue-50 border-blue-200",children:[e.jsx(_i,{className:"text-blue-800 text-sm font-semibold",children:"Joint Review Stage"}),e.jsxs(ui,{className:"text-blue-700 text-xs",children:["Joint evaluation by ",e.jsx("strong",{children:"DD-Lead, ZBH, RBM, and DD-Head"})," required before advancing to NBH Final Approval."]})]}),(n==null?void 0:n.role)!=="Dealer"&&e.jsxs(e.Fragment,{children:[!ge.canFinalize&&e.jsxs(e.Fragment,{children:[ge.canApprove&&e.jsxs(se,{className:"w-full bg-green-600 hover:bg-green-700 font-bold",onClick:()=>Vt("approve"),children:[e.jsx(Hn,{className:"w-4 h-4 mr-2"}),"Approve"]}),ge.canIssueSCN&&e.jsxs(se,{className:"w-full bg-purple-600 hover:bg-purple-700",onClick:()=>_(!0),children:[e.jsx(Ha,{className:"w-4 h-4 mr-2"}),"Issue SCN"]}),ge.canUploadSCNResponse&&e.jsxs(se,{className:"w-full bg-re-red hover:bg-re-red-hover",onClick:()=>{E(null),_(!0)},children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),"Upload SCN Response"]}),ge.canApprove&&e.jsxs(se,{variant:"outline",className:"w-full",onClick:()=>Vt("sendBack"),children:[e.jsx(sb,{className:"w-4 h-4 mr-2"}),"Send Back"]})]}),ge.canHold&&e.jsxs(se,{variant:"outline",className:"w-full border-orange-200 text-orange-700 hover:bg-orange-50",onClick:()=>Vt("hold"),children:[e.jsx(KI,{className:"w-4 h-4 mr-2"}),"Hold Decision"]}),ge.canFinalize&&e.jsxs(se,{className:"w-full bg-indigo-600 hover:bg-indigo-700",onClick:()=>$(!0),children:[e.jsx(no,{className:"w-4 h-4 mr-2"}),"Final Authorization"]})]}),ge.canPushToFnF&&e.jsxs(se,{variant:"outline",className:"w-full text-blue-600 border-blue-300 hover:bg-blue-50",onClick:()=>Vt("pushfnf"),children:[e.jsx(Gu,{className:"w-4 h-4 mr-2"}),"Push to F&F"]}),et&&!ge.isSettlementPhase&&!ge.canPushToFnF&&!ye.fnfSettlement&&(ye.currentStage==="Terminated"||ye.status===Hc.AWAITING_FNF||ye.status===Hc.AWAITING_FNF_LWD_PENDING)&&!ge.isLwdReached&&e.jsxs(di,{className:"border-red-200 bg-red-50",children:[e.jsx(Ha,{className:"h-4 w-4 text-re-red-hover"}),e.jsxs(_i,{className:"text-red-900",children:["Push to F&F locked until ",Pi]}),e.jsxs(ui,{className:"text-red-800 text-sm",children:[Pi," is"," ",ye.proposedLwd?new Date(ye.proposedLwd).toLocaleDateString("en-IN",{dateStyle:"medium"}):"not set",". Admins are notified by email when the ",Pi.toLowerCase()," is reached."]})]}),!ge.isFinalState&&e.jsxs(se,{variant:"outline",className:"w-full",onClick:()=>Vt("assign"),children:[e.jsx(nb,{className:"w-4 h-4 mr-2"}),"Assign User"]}),e.jsx(ec,{}),e.jsxs(se,{variant:"outline",className:"w-full",onClick:()=>{var De;return r(`/worknotes/termination/${t}`,{state:{applicationName:((De=ye==null?void 0:ye.dealer)==null?void 0:De.businessName)||"Termination",registrationNumber:t||"",participants:(ye==null?void 0:ye.participants)||[]}})},children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"View Work Notes",Ys>0&&e.jsx(Ce,{className:"ml-auto bg-re-red hover:bg-re-red-hover text-white h-5 px-2",children:Ys})]})]})]})})]})]}),e.jsx(ds,{open:i.open,onOpenChange:De=>o({open:De,type:null}),children:e.jsxs(os,{children:[e.jsxs(xs,{children:[e.jsxs(ms,{children:[i.type==="approve"&&"Approve Termination Request",i.type==="withdrawal"&&"Withdraw Termination Request",i.type==="sendBack"&&"Send Back for Clarification",i.type==="revoke"&&"Revoke Termination Request",i.type==="assign"&&"Assign to User",i.type==="pushfnf"&&"Push to Full & Final Settlement",i.type==="hold"&&"Hold Termination Case"]}),e.jsx(bs,{children:i.type==="assign"?"Select a user to assign this request to":i.type==="pushfnf"?"This creates the F&F settlement record and starts departmental clearance (manual step only).":"Please provide remarks for this action"})]}),e.jsx("div",{className:"space-y-4",children:i.type==="assign"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Select User"}),e.jsxs(Dt,{value:f,onValueChange:p,children:[e.jsx(Et,{children:e.jsx(Rt,{placeholder:"Choose a user"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"rbm",children:"RBM - Regional Business Manager"}),e.jsx(Me,{value:"zbh",children:"ZBH - Zonal Business Head"}),e.jsx(Me,{value:"dd-lead",children:"DD Lead"}),e.jsx(Me,{value:"legal",children:"Legal Team"}),e.jsx(Me,{value:"nbh",children:"NBH - National Business Head"}),e.jsx(Me,{value:"cco",children:"CCO - Chief Commercial Officer"}),e.jsx(Me,{value:"ceo",children:"CEO"})]})]})]}):i.type==="pushfnf"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-slate-600",children:["F&F can be started on or after the ",Pi,ye.proposedLwd?` (${new Date(ye.proposedLwd).toLocaleDateString("en-IN",{dateStyle:"medium"})})`:"","."]}),e.jsx(de,{children:"Remarks (Optional)"}),e.jsx(Ws,{value:d,onChange:De=>m(De.target.value),placeholder:"Add any additional notes...",rows:3}),e.jsxs("label",{className:"flex items-start gap-2 text-sm text-slate-700 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"mt-1",checked:h,onChange:De=>x(De.target.checked)}),e.jsxs("span",{children:["Force initiate F&F before ",Pi," (requires business approval; exception use only)"]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Remarks *"}),e.jsx(Ws,{value:d,onChange:De=>m(De.target.value),placeholder:"Enter your remarks here...",rows:4})]})}),e.jsxs(bn,{children:[e.jsx(se,{variant:"outline",onClick:()=>o({open:!1,type:null}),children:"Cancel"}),e.jsx(se,{onClick:Pt,className:i.type==="approve"?"bg-green-600 hover:bg-green-700":i.type==="withdrawal"?"bg-red-600 hover:bg-red-700":i.type==="hold"?"bg-orange-600 hover:bg-orange-700":"bg-blue-600 hover:bg-blue-700",children:"Confirm"})]})]})}),e.jsx(ds,{open:u.open,onOpenChange:De=>N({open:De,stageName:"",documents:[]}),children:e.jsxs(os,{className:Gb,children:[e.jsxs(xs,{children:[e.jsxs(ms,{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"w-5 h-5 text-re-red"}),"Documents - ",u.stageName]}),e.jsxs(bs,{children:["Documents uploaded for this stage (",u.documents.length," ",u.documents.length===1?"document":"documents",")"]})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto",children:u.documents.length>0?e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Document Name"}),e.jsx(fe,{children:"Type"}),e.jsx(fe,{children:"Upload Date"}),e.jsx(fe,{children:"Uploader"}),e.jsx(fe,{children:"Action"})]})}),e.jsx(Os,{children:u.documents.map(De=>e.jsxs(it,{children:[e.jsx(ue,{children:De.name}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",children:De.type})}),e.jsx(ue,{children:De.uploadDate}),e.jsx(ue,{children:De.uploader}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",className:"text-re-red hover:text-re-red-hover",onClick:()=>{const bt=De.path;if(!bt)return;const Te=bt.startsWith("/uploads/")&&!bt.startsWith("/uploads/documents/")?bt.replace("/uploads/","/uploads/documents/"):bt;J({fileName:De.name||"Document",filePath:Te,documentType:De.type||"Document"})},children:[e.jsx(Ns,{className:"w-4 h-4 mr-1"}),"View"]})})]},De.id))})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded for this stage yet"})}),e.jsx(bn,{children:e.jsx(se,{variant:"outline",onClick:()=>N({open:!1,stageName:"",documents:[]}),children:"Close"})})]})}),e.jsx(ds,{open:R,onOpenChange:_,children:e.jsxs(os,{className:"bg-white",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:Be?"Upload SCN Response":"Issue Show Cause Notice (SCN)"}),e.jsx(bs,{children:Be?"Upload the response received from the dealer regarding the SCN.":"Confirm the issuance of a formal Show Cause Notice to the dealer."})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[Be&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"SCN Response File"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"file",className:"hidden",id:"scn-file-upload",onChange:De=>{var bt;return E(((bt=De.target.files)==null?void 0:bt[0])||null)}}),e.jsx(se,{variant:"outline",className:"w-full border-dashed",onClick:()=>{var De;return(De=document.getElementById("scn-file-upload"))==null?void 0:De.click()},children:A?A.name:"Select PDF or Image"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Remarks/Details"}),e.jsx(Ws,{placeholder:"Add any internal remarks or justification...",value:q,onChange:De=>O(De.target.value),rows:4})]}),e.jsxs(bn,{className:"gap-2 sm:gap-0",children:[e.jsx(se,{variant:"outline",onClick:()=>_(!1),disabled:D,children:"Cancel"}),e.jsx(se,{className:Be?"bg-re-red hover:bg-re-red-hover":"bg-purple-600 hover:bg-purple-700",onClick:Be?ce:xe,disabled:D||Be&&!A,children:D?"Processing...":Be?"Upload Response":"Issue SCN"})]})]})]})}),e.jsx(ds,{open:L,onOpenChange:$,children:e.jsxs(os,{className:"bg-white",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Final Termination Authorization"}),e.jsx(bs,{children:"Provide your final decision on this termination case."})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Final Decision"}),e.jsxs(Dt,{value:Y,onValueChange:De=>Z(De),children:[e.jsx(Et,{className:"mt-2 text-slate-900 border-slate-300",children:e.jsx(Rt,{placeholder:"Select decision"})}),e.jsxs(_t,{className:"bg-white border-slate-200 shadow-xl overflow-visible z-[9999]",children:[e.jsx(Me,{value:"Approve",className:"text-re-red-hover focus:bg-red-50",children:"Confirm Termination"}),e.jsx(Me,{value:"Reject",className:"text-slate-600 focus:bg-slate-50",children:"Reject Termination"}),e.jsx(Me,{value:"Reconsider",className:"text-re-red focus:bg-red-50",children:"Reconsider / Give More Time"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Authorization Remarks"}),e.jsx(Ws,{placeholder:"Provide your rationale for this decision...",value:W,onChange:De=>U(De.target.value),rows:4})]}),e.jsxs(bn,{className:"gap-2 sm:gap-0",children:[e.jsx(se,{variant:"outline",onClick:()=>$(!1),disabled:D,children:"Cancel"}),e.jsx(se,{className:"bg-indigo-600 hover:bg-indigo-700",onClick:ve,disabled:D||!W,children:D?"Authorizing...":"Submit Decision"})]})]})]})}),e.jsx(ds,{open:M,onOpenChange:z,children:e.jsxs(os,{children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Upload Termination Document"}),e.jsx(bs,{children:"Add a document and map it to a stage (optional)."})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Document Type"}),e.jsxs(Dt,{value:B,onValueChange:G,children:[e.jsx(Et,{children:e.jsx(Rt,{placeholder:"Select document type"})}),e.jsx(_t,{children:Kg.map(De=>e.jsx(Me,{value:De,children:De},De))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Stage (Optional)"}),e.jsxs(Dt,{value:K||"none",onValueChange:De=>H(De==="none"?"":De),children:[e.jsx(Et,{children:e.jsx(Rt,{placeholder:"Select stage"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"none",children:"No Stage Mapping"}),mV.map(De=>e.jsx(Me,{value:De,children:De},De))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"File"}),e.jsx("input",{type:"file",onChange:De=>{var bt;return I(((bt=De.target.files)==null?void 0:bt[0])||null)}})]})]}),e.jsxs(bn,{children:[e.jsx(se,{variant:"outline",onClick:()=>z(!1),disabled:D,children:"Cancel"}),e.jsx(se,{onClick:Pe,disabled:D,children:D?"Uploading...":"Upload"})]})]})}),e.jsx(mo,{isOpen:!!X,onClose:()=>J(null),document:X})]})}const ua=t=>{if(!t)return"-";try{const s=new Date(t);return isNaN(s.getTime())?"-":s.toLocaleString("en-IN",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0})}catch{return"-"}},OS=t=>{if(!t)return"-";try{const s=new Date(t);return isNaN(s.getTime())?"-":s.toLocaleDateString("en-IN",{day:"2-digit",month:"short",year:"numeric"})}catch{return"-"}},p_=({isOpen:t,onClose:s,onSubmit:n,editingBank:r,isSubmitting:a})=>e.jsx(ds,{open:t,onOpenChange:s,children:e.jsxs(os,{className:"sm:max-w-[500px]",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:r?"Edit Bank Details":"Add Bank Account"}),e.jsx(bs,{children:"Enter the dealer's bank information for settlement transfers."})]}),e.jsxs("form",{onSubmit:n,"data-testid":"onboarding-bank-details-form",children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(de,{htmlFor:"bankName",className:"text-right text-xs",children:"Bank Name"}),e.jsx("div",{className:"col-span-3",children:e.jsx(at,{id:"bankName",name:"bankName",defaultValue:r==null?void 0:r.bankName,required:!0,placeholder:"e.g. HDFC Bank, ICICI Bank",className:"h-9","data-testid":"onboarding-bank-name-input"})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(de,{htmlFor:"accountHolderName",className:"text-right text-xs",children:"Holder Name"}),e.jsx("div",{className:"col-span-3",children:e.jsx(at,{id:"accountHolderName",name:"accountHolderName",defaultValue:r==null?void 0:r.accountHolderName,required:!0,placeholder:"Full name as per bank records",className:"h-9","data-testid":"onboarding-account-holder-name-input"})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(de,{htmlFor:"accountNumber",className:"text-right text-xs",children:"A/C Number"}),e.jsx("div",{className:"col-span-3",children:e.jsx(at,{id:"accountNumber",name:"accountNumber",defaultValue:r==null?void 0:r.accountNumber,required:!0,placeholder:"Enter account number",className:"h-9","data-testid":"onboarding-account-number-input"})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(de,{htmlFor:"ifscCode",className:"text-right text-xs",children:"IFSC Code"}),e.jsx("div",{className:"col-span-3",children:e.jsx(at,{id:"ifscCode",name:"ifscCode",defaultValue:r==null?void 0:r.ifscCode,required:!0,placeholder:"11-character code",className:"h-9","data-testid":"onboarding-ifsc-code-input"})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(de,{htmlFor:"branchName",className:"text-right text-xs",children:"Branch"}),e.jsx("div",{className:"col-span-3",children:e.jsx(at,{id:"branchName",name:"branchName",defaultValue:r==null?void 0:r.branchName,required:!0,placeholder:"Branch location",className:"h-9","data-testid":"onboarding-branch-name-input"})})]}),e.jsx("div",{className:"grid grid-cols-4 items-center gap-4",children:e.jsxs("div",{className:"flex items-center gap-2 col-start-2 col-span-3",children:[e.jsx("input",{type:"checkbox",id:"isPrimaryModal",name:"isPrimary",defaultChecked:r==null?void 0:r.isPrimary,className:"w-4 h-4 rounded border-slate-300 text-re-red focus:ring-re-red","data-testid":"onboarding-is-primary-checkbox"}),e.jsx(de,{htmlFor:"isPrimaryModal",className:"text-xs font-medium cursor-pointer",children:"Set as primary account"})]})})]}),e.jsxs(bn,{children:[e.jsx(se,{type:"button",variant:"outline",size:"sm",onClick:s,"data-testid":"onboarding-bank-details-cancel",children:"Cancel"}),e.jsxs(se,{type:"submit",disabled:a,size:"sm",className:"bg-re-red","data-testid":"onboarding-bank-details-submit",children:[a?e.jsx(ns,{className:"w-4 h-4 animate-spin mr-2"}):null,r?"Update Account":"Save Bank Details"]})]})]})]})}),LS=["Warranty Department","Accessories Department","Sales Department","RTO Department","Service Department","Parts Department","Finance Department","Insurance Department","Inventory Department","Marketing Department","HR Department","IT Department","Legal Department","Quality Department","Logistics Department","Customer Relations Department"],wV="[DEPARTMENT_CLAIM]",SV="[FINANCE_VALIDATED]";function CV({fnfId:t,onBack:s,currentUser:n}){var Bs,Ks,Qs,Xs,$s;const r=tr(),[a,i]=g.useState(null),[o,d]=g.useState(!0),[m,f]=g.useState("details"),[p,h]=g.useState(!1),[x,u]=g.useState(null),[N,v]=g.useState([]),[w,j]=g.useState([]),[b,C]=g.useState(!1),[S,R]=g.useState(null),[_,A]=g.useState(!1),[E,q]=g.useState(!1),[O,D]=g.useState(null),[P,L]=g.useState(!1),[$,Y]=g.useState({remarks:"",amount:0,type:"Receivable"}),[Z,W]=g.useState(null),[U,M]=g.useState(!1),z=g.useRef(null),[T,I]=g.useState(!1),[B,G]=g.useState(""),[K,H]=g.useState(""),[X,J]=g.useState(null);g.useEffect(()=>{Pe(),et()},[t]);const ae=Q=>{if(!Q)return Q;let oe=Q.trim();const we=LS.find(je=>je.toLowerCase()===oe.toLowerCase());if(we)return we;const ke={sales:"Sales Department",service:"Service Department",spares:"Parts Department",parts:"Parts Department","spares / parts":"Parts Department",finance:"Finance Department",accounts:"Finance Department",warranty:"Warranty Department",marketing:"Marketing Department",hr:"HR Department",it:"IT Department",legal:"Legal Department",logistics:"Logistics Department",quality:"Quality Department",fdd:"Finance Department",apparel:"Accessories Department",accessories:"Accessories Department",dms:"IT Department",rto:"Admin Department",admin:"Admin Department","admin / dd-admin":"Admin Department"}[oe.toLowerCase().replace(" department","")];return ke||Q},le=(Q,oe)=>oe==="DepartmentClaim"||typeof Q=="string"&&(Q.startsWith(wV)||Q.includes("Clearance:")),xe=Q=>(Q==null?void 0:Q.sourceType)==="FinanceValidated"&&typeof(Q==null?void 0:Q.description)=="string"&&Q.description.includes("Auto-seeded from department claim"),ce=(Q,oe)=>oe==="FinanceValidated"||typeof Q=="string"&&Q.startsWith(SV),ve=Q=>Q?{ADD_LINE_ITEM:"Line Item Added",UPDATE_LINE_ITEM:"Line Item Updated",REMOVE_LINE_ITEM:"Line Item Removed",UPDATE_CLEARANCE:"Clearance Status Updated",SETTLE_CASE:"Settlement Finalized",FNF_UPDATED:"F&F Case Updated"}[Q]||Q.split("_").map(we=>we.charAt(0).toUpperCase()+we.slice(1).toLowerCase()).join(" "):"Action",Pe=async(Q=!0)=>{var oe,we,Oe,ke,je,Ve,Ge,nt,Zt,Jt,lt,mt,Ds,ss,Ae,be,ut,He,yt,ft,es,ts,Cs,Us,rn,Js,an,hn,De,bt,Te,ct,tt,jt,Ht,zt,fs,qt,As,vs,cs,mn,qs,ln,fn,on,Ye,Ot,St,rt,Ft,jn,xn,qn,En,Hs,Za,Pa,Ls,nn,ta,sa,na,Ir;try{Q&&d(!0);const zn=(await Ee.getFnFSettlementById(t)).data;if(zn.success){const Qt=zn.fnf,Jn=(Qt.lineItems||[]).filter(rs=>rs.isActive!==!1),Wn=Jn.some(rs=>ce(rs.description,rs.sourceType))?Jn.filter(rs=>ce(rs.description,rs.sourceType)):Jn.filter(rs=>!le(rs.description,rs.sourceType)),Er={id:Qt.id,caseNumber:Qt.settlementId||((oe=Qt.resignation)==null?void 0:oe.resignationId)||((we=Qt.terminationRequest)==null?void 0:we.requestId)||Qt.id.substring(0,8),status:Qt.status,requestType:Qt.resignationId?"Resignation":"Termination",dealerName:((ke=(Oe=Qt.outlet)==null?void 0:Oe.dealer)==null?void 0:ke.fullName)||((je=Qt.dealer)==null?void 0:je.fullName)||"N/A",dealerCode:((Ve=Qt.outlet)==null?void 0:Ve.code)||((nt=(Ge=Qt.dealer)==null?void 0:Ge.dealerCode)==null?void 0:nt.dealerCode)||"N/A",dealershipName:((Zt=Qt.outlet)==null?void 0:Zt.name)||((Jt=Qt.dealer)==null?void 0:Jt.businessName)||"N/A",location:((lt=Qt.outlet)==null?void 0:lt.city)||((mt=Qt.outlet)==null?void 0:mt.location)||"N/A",originalRequestId:((Ds=Qt.resignation)==null?void 0:Ds.resignationId)||((ss=Qt.terminationRequest)==null?void 0:ss.requestId)||((Ae=Qt.terminationRequest)==null?void 0:Ae.id)||"N/A",submittedOn:ua(Qt.createdAt),lastOperationalDateSales:(be=Qt.resignation)!=null&&be.lastOperationalDateSales||(ut=Qt.terminationRequest)!=null&&ut.proposedLwd?OS(((He=Qt.resignation)==null?void 0:He.lastOperationalDateSales)||((yt=Qt.terminationRequest)==null?void 0:yt.proposedLwd)):"N/A",lastOperationalDateServices:(ft=Qt.resignation)!=null&&ft.lastOperationalDateServices||(es=Qt.terminationRequest)!=null&&es.proposedLwd?OS(((ts=Qt.resignation)==null?void 0:ts.lastOperationalDateServices)||((Cs=Qt.terminationRequest)==null?void 0:Cs.proposedLwd)):"N/A",typeOfClosure:Qt.resignationId?"Voluntary":"Involuntary",gst:((Js=(rn=(Us=Qt.outlet)==null?void 0:Us.dealer)==null?void 0:rn.dealerProfile)==null?void 0:Js.gstNumber)||((an=Qt.dealer)==null?void 0:an.gstNumber)||"N/A",pan:((bt=(De=(hn=Qt.outlet)==null?void 0:hn.dealer)==null?void 0:De.dealerProfile)==null?void 0:bt.panNumber)||((Te=Qt.dealer)==null?void 0:Te.panNumber)||"N/A",salesCode:((tt=(ct=Qt.dealer)==null?void 0:ct.dealerCode)==null?void 0:tt.salesCode)||((fs=(zt=(Ht=(jt=Qt.outlet)==null?void 0:jt.dealer)==null?void 0:Ht.dealerProfile)==null?void 0:zt.dealerCode)==null?void 0:fs.salesCode)||"N/A",serviceCode:((As=(qt=Qt.dealer)==null?void 0:qt.dealerCode)==null?void 0:As.serviceCode)||((qs=(mn=(cs=(vs=Qt.outlet)==null?void 0:vs.dealer)==null?void 0:cs.dealerProfile)==null?void 0:mn.dealerCode)==null?void 0:qs.serviceCode)||"N/A",gearCode:((fn=(ln=Qt.dealer)==null?void 0:ln.dealerCode)==null?void 0:fn.gearCode)||((St=(Ot=(Ye=(on=Qt.outlet)==null?void 0:on.dealer)==null?void 0:Ye.dealerProfile)==null?void 0:Ot.dealerCode)==null?void 0:St.gearCode)||"N/A",gmaCode:((Ft=(rt=Qt.dealer)==null?void 0:rt.dealerCode)==null?void 0:Ft.gmaCode)||((En=(qn=(xn=(jn=Qt.outlet)==null?void 0:jn.dealer)==null?void 0:xn.dealerProfile)==null?void 0:qn.dealerCode)==null?void 0:En.gmaCode)||"N/A",financeReportStatus:Qt.status==="Finance Approval"?"In Progress":Qt.status==="Completed"?"Completed":"Pending",totalPayableAmount:Wn.filter(rs=>rs.itemType==="Payable").reduce((rs,en)=>rs+(parseFloat(en.amount)||0),0),totalRecoveryAmount:Wn.filter(rs=>rs.itemType==="Receivable"||rs.itemType==="Recovery").reduce((rs,en)=>rs+(parseFloat(en.amount)||0),0),totalDeductions:Wn.filter(rs=>rs.itemType==="Deduction").reduce((rs,en)=>rs+(parseFloat(en.amount)||0),0),allLineItems:Jn,netAmount:0,departmentResponses:[]};Er.netAmount=Er.totalPayableAmount-Er.totalRecoveryAmount-Er.totalDeductions,Er.departmentResponses=["Warranty Department","Accessories Department","Sales Department","RTO Department","Service Department","Parts Department","Finance Department","Insurance Department","Inventory Department","Marketing Department","HR Department","IT Department","Legal Department","Quality Department","Logistics Department","Customer Relations Department"].map(rs=>{const en=(Qt.clearances||[]).find(Cn=>ae(Cn.department)===rs),va=Jn.filter(Cn=>ae(Cn.department)===rs&&le(Cn.description,Cn.sourceType)),wi=Jn.filter(Cn=>ae(Cn.department)===rs&&xe(Cn)),Si=va.length>0?va:wi;let Mr=0,Hr=0;Si.forEach(Cn=>{const ba=Math.abs(parseFloat(Cn.amount)||0);Cn.itemType==="Payable"?Mr+=ba:Hr+=ba});const sr=Mr-Hr,ya=Math.abs(sr)>0,Hi=(en==null?void 0:en.status)||"Pending",bo=ya?"Dues Pending":Hi==="Cleared"?"NOC Submitted":Hi,Oa=sr>0?"payable":sr<0?"recovery":null;return{id:(en==null?void 0:en.id)||`dept-${rs}`,clearanceId:(en==null?void 0:en.id)||null,departmentName:rs,status:bo,duesFlow:Oa,amountType:sr>0?"Payable to dealer":sr<0?"Receivable from dealer":null,amount:Math.abs(sr),submittedDate:en!=null&&en.clearedAt?ua(en.clearedAt):"-",remarks:(en==null?void 0:en.remarks)||"-",supportingDocument:(en==null?void 0:en.supportingDocument)||null}});const _n={...Er,documents:[...(((Hs=Qt.resignation)==null?void 0:Hs.uploadedDocuments)||[]).map(rs=>({id:`res-${rs.id}`,name:rs.fileName,type:"Resignation",uploadDate:ua(rs.createdAt),status:"Verified",url:rs.filePath})),...(Qt.clearances||[]).filter(rs=>rs.supportingDocument).map(rs=>({id:`clr-${rs.id}`,name:rs.supportingDocument.split("/").pop(),type:`${rs.department} Proof`,uploadDate:ua(rs.clearedAt),status:"Attached",url:rs.supportingDocument})),...(Qt.settlementDocs||[]).map(rs=>({id:`set-${rs.id}`,name:rs.fileName,type:"Settlement Proof",uploadDate:ua(rs.createdAt),status:"Finance",url:rs.filePath})),...(Qt.clearanceDocuments||[]).filter(rs=>rs==null?void 0:rs.supportingDocument).map((rs,en)=>({id:rs.id||`fnf-doc-${en}`,name:rs.name||(rs.supportingDocument||"").split("/").pop(),type:rs.documentType||rs.department||"F&F Document",uploadDate:rs.clearedAt?ua(rs.clearedAt):"-",status:"Attached",url:rs.supportingDocument}))],participants:Qt.participants||[]};i(_n);const ur=Qt.bankDetails||((Za=Qt.dealer)==null?void 0:Za.bankDetails)||((nn=(Ls=(Pa=Qt.outlet)==null?void 0:Pa.dealer)==null?void 0:Ls.dealerProfile)==null?void 0:nn.bankDetails);ur&&ur.length>0?j(ur):((sa=(ta=Qt.outlet)==null?void 0:ta.dealer)!=null&&sa.id||Qt.dealerId)&&kt(((Ir=(na=Qt.outlet)==null?void 0:na.dealer)==null?void 0:Ir.id)||Qt.dealerId)}}catch(Xn){console.error("Fetch F&F details error:",Xn),te.error("Failed to fetch settlement details")}finally{Q&&d(!1)}},et=async()=>{try{const oe=(await Ee.getAuditLogs("fnf",t)).data;oe.success&&v(oe.data||[])}catch(Q){console.error("Fetch audit logs error:",Q)}},kt=async Q=>{try{const we=(await Ee.getDealerBankDetails(Q)).data;we.success&&j(we.bankDetails||[])}catch(oe){console.error("Fetch bank details error:",oe)}},vt=async Q=>{var Oe,ke;Q.preventDefault();const oe=new FormData(Q.currentTarget),we=Object.fromEntries(oe.entries());try{A(!0);const je=((ke=(Oe=a==null?void 0:a.outlet)==null?void 0:Oe.dealer)==null?void 0:ke.id)||(a==null?void 0:a.dealerId);if(!je){te.error("Dealer information missing");return}(await Ee.saveBankDetail(je,{...we,id:S==null?void 0:S.id,isPrimary:oe.get("isPrimary")==="on"})).data.success&&(te.success("Bank details saved successfully"),kt(je),C(!1),R(null))}catch{te.error("Failed to save bank details")}finally{A(!1)}},ee=async Q=>{var oe,we;if(confirm("Are you sure you want to delete this bank account?"))try{if((await Ee.deleteBankDetail(Q)).data.success){te.success("Bank detail deleted");const ke=((we=(oe=a==null?void 0:a.outlet)==null?void 0:oe.dealer)==null?void 0:we.id)||(a==null?void 0:a.dealerId);ke&&kt(ke)}}catch{te.error("Failed to delete bank detail")}};if(o)return e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(ns,{className:"w-8 h-8 animate-spin text-re-red"})});if(!a)return e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-slate-600",children:"Case not found"}),e.jsx(se,{onClick:s,className:"mt-4",children:"Go Back"})]});const ye=(Q=>{const oe=new Date(Q),Oe=Math.abs(new Date().getTime()-oe.getTime());return Math.ceil(Oe/(1e3*60*60*24))})(a.submittedOn),Be=String((n==null?void 0:n.role)||"").toLowerCase(),$e=Be.includes("super admin")||Be.includes("dd admin"),dt=Q=>{if(!a||!Q)return!1;const oe=Be;if(!oe||Q.status!=="Pending")return!1;const Oe=["Finance Approval","Completed"].includes(a.status),ke=oe.includes("super admin")||oe.includes("finance")||oe.includes("dd admin");if(Oe&&!ke)return!1;if(ke)return!0;const je=Q.departmentName.replace(" Department","").toLowerCase();return oe.includes(je)},st=((a==null?void 0:a.departmentResponses)||[]).some(Q=>dt(Q)),xt=async()=>{var Q;if(!(O!=null&&O.clearanceId)||!t){te.error("Clearance record not available for this department");return}try{L(!0);const oe=new FormData,we=Number($.amount)>0?"Dues Pending":"NOC Submitted";oe.append("status",we),oe.append("remarks",$.remarks),oe.append("amount",String($.amount)),oe.append("type",$.type),Z&&oe.append("file",Z);const Oe=await Ee.updateFnFClearance(t,O.clearanceId,oe);if(!Oe.ok){te.error(((Q=Oe.data)==null?void 0:Q.message)||"Failed to update department clearance"),L(!1);return}te.success(`Clearance updated for ${O.departmentName}`),q(!1),W(null),f("departments"),Pe(!1)}catch(oe){console.error("Update clearance error:",oe),te.error("Failed to update department clearance")}finally{L(!1)}},Mt=Q=>{var we;const oe=((we=Q.target.files)==null?void 0:we[0])||null;J(oe)},It=()=>{I(!1),G(""),H(""),J(null),z.current&&(z.current.value="")},he=async()=>{var oe,we,Oe,ke;const Q=B.trim();if(!Q){te.error("Please enter a document name.");return}if(!X){te.error("Please choose a file to upload.");return}if(!t){te.error("Cannot upload — settlement id is missing.");return}M(!0);try{const je=new FormData;je.append("file",X),je.append("documentName",Q),K.trim()&&je.append("documentType",K.trim());const Ve=await Ee.uploadFnFDocument(t,je);(oe=Ve.data)!=null&&oe.success?(te.success("Document uploaded successfully"),It(),Pe(!1)):te.error(((we=Ve.data)==null?void 0:we.message)||"Failed to upload document")}catch(je){console.error("Upload F&F document error:",je),te.error(((ke=(Oe=je==null?void 0:je.response)==null?void 0:Oe.data)==null?void 0:ke.message)||"Failed to upload document")}finally{M(!1)}},pt=()=>{te.success("Notifications sent to all 16 departments"),h(!1)},ht=Q=>{switch(Q){case"New":return"bg-red-50 text-blue-700 border-blue-300";case"In Progress":return"bg-yellow-100 text-yellow-700 border-yellow-300";case"Under Review":return"bg-orange-100 text-orange-700 border-orange-300";case"Completed":return"bg-green-100 text-green-700 border-green-300";default:return"bg-slate-100 text-slate-700 border-slate-300"}},_e=Q=>{switch(Q){case"NOC Submitted":return"bg-green-100 text-green-700 border-green-300";case"Dues Pending":return"bg-red-100 text-red-700 border-red-300";case"Pending":return"bg-slate-100 text-slate-700 border-slate-300";default:return"bg-slate-100 text-slate-700 border-slate-300"}},Vt=a.departmentResponses.filter(Q=>Q.status!=="Pending").length,Pt=a.departmentResponses.length,_s=Vt/Pt*100,Ys=LS.map(Q=>{const oe=(a.departmentResponses||[]).find(lt=>lt.departmentName===Q),we=Number(oe==null?void 0:oe.amount)||0,Oe=(oe==null?void 0:oe.amountType)||"-",ke=(a.allLineItems||[]).filter(lt=>ae(lt.department)===Q),je=ke.filter(lt=>lt.sourceType==="FinanceValidated"&&lt.itemType==="Payable").reduce((lt,mt)=>lt+Math.abs(parseFloat(mt.amount)||0),0),Ve=ke.filter(lt=>lt.sourceType==="FinanceValidated"&&(lt.itemType==="Receivable"||lt.itemType==="Recovery")).reduce((lt,mt)=>lt+Math.abs(parseFloat(mt.amount)||0),0),Ge=ke.filter(lt=>lt.sourceType==="FinanceValidated"&&lt.itemType==="Deduction").reduce((lt,mt)=>lt+Math.abs(parseFloat(mt.amount)||0),0),nt=je-Ve-Ge,Zt=Math.abs(nt),Jt=nt>0?"Payable":nt<0?"Receivable":"-";return{department:Q,claimAmount:we,claimType:Oe,validatedAmount:Zt,validatedType:Jt,variance:Zt-we}});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Le,{className:`border-none shadow-md bg-gradient-to-r ${(a.totalRecoveryAmount||0)>(a.totalPayableAmount||0)?"from-red-600 to-red-500":"from-green-600 to-green-500"} text-white`,children:e.jsxs(Fe,{className:"p-6 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 bg-white/20 rounded-full",children:e.jsx(dk,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white/80 text-sm font-medium",children:"Net Settlement Balance"}),e.jsxs("h2",{className:"text-3xl font-bold",children:["₹",Math.abs(a.netAmount||0).toLocaleString()]})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx(Ce,{className:"bg-white/20 hover:bg-white/30 text-white border-none px-4 py-1 mb-2",children:(a.totalRecoveryAmount||0)>(a.totalPayableAmount||0)?"Receivable from Dealer":"Payable to Dealer"}),e.jsx("p",{className:"text-xs text-white/70",children:a.status==="Completed"?"Settlement Finalized":"Draft Calculation"})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(se,{variant:"outline",size:"icon",onClick:s,children:e.jsx(Jr,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl",children:a.caseNumber}),e.jsx("p",{className:"text-slate-600",children:a.dealerName})]}),e.jsx(Ce,{className:ht(a.status),children:a.status}),e.jsx(Ce,{className:a.requestType==="Resignation"?"bg-red-50 text-re-red-hover border-red-300":"bg-red-100 text-red-700 border-red-300",children:a.requestType})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs(se,{variant:"outline",onClick:()=>r(`/worknotes/fnf/${t}`,{state:{applicationName:a.dealerName||"F&F Settlement",registrationNumber:a.caseNumber||"",participants:a.participants||[]}}),children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"View Work Notes"]})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"Overall Progress"}),e.jsxs(Xt,{children:["Department responses: ",Vt," / ",Pt]})]}),e.jsxs(Fe,{children:[e.jsx(dc,{value:_s,className:"h-3"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"NOC Submitted"}),e.jsx("p",{className:"text-2xl text-green-600",children:a.departmentResponses.filter(Q=>Q.status==="NOC Submitted").length})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Dues Pending"}),e.jsx("p",{className:"text-2xl text-red-600",children:a.departmentResponses.filter(Q=>Q.status==="Dues Pending").length})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Pending"}),e.jsx("p",{className:"text-2xl text-slate-600",children:a.departmentResponses.filter(Q=>Q.status==="Pending").length})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Finance Status"}),e.jsx("p",{className:"text-lg",children:a.financeReportStatus})]})]})]})]}),e.jsxs(Bn,{value:m,onValueChange:f,className:"w-full",children:[e.jsxs($n,{children:[e.jsx(Wt,{value:"progress",children:"Progress"}),e.jsx(Wt,{value:"details",children:"Case Details"}),e.jsx(Wt,{value:"departments",children:"Department Responses"}),$e&&e.jsx(Wt,{value:"documents",children:"Documents"}),e.jsx(Wt,{value:"audit",children:"Audit Trail"})]}),e.jsx(Ut,{value:"progress",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"F&F Settlement Progress"}),e.jsx(Xt,{children:"Track the complete journey from initiation to completion"})]}),e.jsx(Fe,{children:e.jsx("div",{className:"relative",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex gap-4 items-start",children:[e.jsxs("div",{className:"flex shrink-0 flex-col items-center",children:[e.jsx("div",{className:"size-12 shrink-0 aspect-square rounded-full bg-green-100 border-2 border-green-600 flex items-center justify-center",children:e.jsx(Hn,{className:"w-6 h-6 text-green-600"})}),e.jsx("div",{className:"w-0.5 h-full bg-green-300 mt-2"})]}),e.jsxs("div",{className:"flex-1 pb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-slate-900",children:"F&F Initiated"}),e.jsx(Ce,{className:"bg-green-600",children:"Completed"})]}),e.jsx("span",{className:"text-sm text-slate-600",children:a.submittedOn})]}),e.jsx("p",{className:"text-slate-600 text-sm mb-3",children:"Full & Final settlement process has been initiated. Case created and basic information collected."}),e.jsx(Le,{className:"bg-green-50 border-green-200",children:e.jsx(Fe,{className:"p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Case Number"}),e.jsx("p",{className:"text-slate-900",children:a.caseNumber})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Request Type"}),e.jsx("p",{className:"text-slate-900",children:a.requestType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer"}),e.jsx("p",{className:"text-slate-900",children:a.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{className:"text-slate-900",children:a.location})]})]})})})]})]}),e.jsxs("div",{className:"flex gap-4 items-start",children:[e.jsxs("div",{className:"flex shrink-0 flex-col items-center",children:[e.jsx("div",{className:`size-12 shrink-0 aspect-square rounded-full flex items-center justify-center border-2 ${Vt===Pt||["Finance Approval","Completed"].includes(a.status)?"bg-green-100 border-green-600":Vt>0?"bg-red-50 border-re-red":"bg-slate-100 border-slate-300"}`,children:Vt===Pt||["Finance Approval","Completed"].includes(a.status)?e.jsx(Hn,{className:"w-6 h-6 text-green-600"}):Vt>0?e.jsx(Ra,{className:"w-6 h-6 text-re-red"}):e.jsx(vn,{className:"w-6 h-6 text-slate-400"})}),e.jsx("div",{className:`w-0.5 h-full mt-2 ${Vt===Pt||["Finance Approval","Completed"].includes(a.status)?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:"flex-1 pb-8",children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-slate-900",children:"Department Responses Received"}),e.jsx(Ce,{className:Vt===Pt||["Finance Approval","Completed"].includes(a.status)?"bg-green-600":Vt>0?"bg-re-red":"bg-slate-400",children:Vt===Pt||["Finance Approval","Completed"].includes(a.status)?"Completed":Vt>0?"In Progress":"Pending"})]})}),e.jsxs("p",{className:"text-slate-600 text-sm mb-3",children:["All stakeholder departments submit their NOC or dues information.",Vt>0&&` (${Vt}/${Pt} responses received)`]}),Vt>0&&e.jsx(Le,{className:Vt===Pt||["Finance Approval","Completed"].includes(a.status)?"bg-green-50 border-green-200":"bg-blue-50 border-red-200",children:e.jsx(Fe,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-slate-600",children:"Progress"}),e.jsxs("span",{className:"text-sm",children:[Vt," / ",Pt," ","departments"]})]}),e.jsx(dc,{value:_s,className:"h-2"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-sm",children:[e.jsxs("div",{className:"text-center p-2 bg-green-100 rounded",children:[e.jsx("p",{className:"text-green-700",children:"NOC Submitted"}),e.jsx("p",{className:"text-green-900",children:a.departmentResponses.filter(Q=>Q.status==="NOC Submitted").length})]}),e.jsxs("div",{className:"text-center p-2 bg-red-100 rounded",children:[e.jsx("p",{className:"text-red-700",children:"Dues Pending"}),e.jsx("p",{className:"text-red-900",children:a.departmentResponses.filter(Q=>Q.status==="Dues Pending").length})]}),e.jsxs("div",{className:"text-center p-2 bg-slate-100 rounded",children:[e.jsx("p",{className:"text-slate-700",children:"Pending"}),e.jsx("p",{className:"text-slate-900",children:a.departmentResponses.filter(Q=>Q.status==="Pending").length})]})]})]})})})]})]}),e.jsxs("div",{className:"flex gap-4 items-start",children:[e.jsxs("div",{className:"flex shrink-0 flex-col items-center",children:[e.jsx("div",{className:`size-12 shrink-0 aspect-square rounded-full flex items-center justify-center border-2 ${a.status==="Completed"?"bg-green-100 border-green-600":a.status==="Finance Approval"?"bg-red-50 border-re-red":"bg-slate-100 border-slate-300"}`,children:a.status==="Completed"?e.jsx(Hn,{className:"w-6 h-6 text-green-600"}):a.status==="Finance Approval"?e.jsx(hu,{className:"w-6 h-6 text-re-red"}):e.jsx(vn,{className:"w-6 h-6 text-slate-400"})}),e.jsx("div",{className:`w-0.5 h-full mt-2 ${a.status==="Completed"?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:"flex-1 pb-8",children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-slate-900",children:"Finance Final Summary"}),e.jsx(Ce,{className:a.status==="Completed"?"bg-green-600":a.status==="Finance Approval"?"bg-re-red":"bg-slate-400",children:a.status==="Completed"?"Completed":a.status==="Finance Approval"?"In Progress":"Pending"})]})}),e.jsx("p",{className:"text-slate-600 text-sm mb-3",children:"Finance department consolidates all department responses and prepares final settlement summary with total payable and recovery amounts."}),["Finance Approval","Completed"].includes(a.status)&&e.jsx(Le,{className:a.status==="Completed"?"bg-green-50 border-green-200":"bg-blue-50 border-red-200",children:e.jsx(Fe,{className:"p-4",children:e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"text-center p-3 bg-green-100 rounded-lg",children:[e.jsx("p",{className:"text-xs text-green-700 mb-1",children:"Payable Amount"}),e.jsxs("p",{className:"text-green-900",children:["₹",((Bs=a.totalPayableAmount)==null?void 0:Bs.toLocaleString())||"0"]})]}),e.jsxs("div",{className:"text-center p-3 bg-red-100 rounded-lg",children:[e.jsx("p",{className:"text-xs text-red-700 mb-1",children:"Receivable amount"}),e.jsxs("p",{className:"text-red-900",children:["₹",((Ks=a.totalRecoveryAmount)==null?void 0:Ks.toLocaleString())||"0"]})]}),e.jsxs("div",{className:"text-center p-3 bg-red-50 rounded-lg",children:[e.jsx("p",{className:"text-xs text-blue-700 mb-1",children:"Net Amount"}),e.jsxs("p",{className:(a.totalRecoveryAmount||0)>(a.totalPayableAmount||0)?"text-red-900":"text-green-900",children:["₹",Math.abs((a.totalRecoveryAmount||0)-(a.totalPayableAmount||0)).toLocaleString()]})]})]})})})]})]}),e.jsxs("div",{className:"flex gap-4 items-start",children:[e.jsxs("div",{className:"flex shrink-0 flex-col items-center",children:[e.jsx("div",{className:`size-12 shrink-0 aspect-square rounded-full flex items-center justify-center border-2 ${a.status==="Completed"?"bg-green-100 border-green-600":a.status==="Finance Approval"?"bg-red-50 border-re-red":"bg-slate-100 border-slate-300"}`,children:a.status==="Completed"?e.jsx(Hn,{className:"w-6 h-6 text-green-600"}):a.status==="Finance Approval"?e.jsx(Ga,{className:"w-6 h-6 text-re-red"}):e.jsx(vn,{className:"w-6 h-6 text-slate-400"})}),e.jsx("div",{className:`w-0.5 h-full mt-2 ${a.status==="Completed"?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:"flex-1 pb-8",children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-slate-900",children:"Financial Discussion with Dealer"}),e.jsx(Ce,{className:a.status==="Completed"?"bg-green-600":a.status==="Finance Approval"?"bg-re-red":"bg-slate-400",children:a.status==="Completed"?"Completed":a.status==="Finance Approval"?"In Progress":"Pending"})]})}),e.jsx("p",{className:"text-slate-600 text-sm mb-3",children:"Finance team, legal team, and relevant departments discuss final settlement with the dealer. Dealer reviews and agrees to the financial terms."}),a.status==="Finance Approval"&&e.jsx(Le,{className:"bg-orange-50 border-orange-200",children:e.jsx(Fe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(sn,{className:"w-5 h-5 text-orange-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-orange-900 mb-1",children:"Ongoing Discussions"}),e.jsx("p",{className:"text-xs text-orange-700",children:"Negotiations in progress regarding recovery/payable amounts. Finance team is working with departments and dealer to resolve discrepancies."})]})]})})})]})]}),e.jsxs("div",{className:"flex gap-4 items-start",children:[e.jsxs("div",{className:"flex shrink-0 flex-col items-center",children:[e.jsx("div",{className:`size-12 shrink-0 aspect-square rounded-full flex items-center justify-center border-2 ${a.status==="Completed"?"bg-green-100 border-green-600":"bg-slate-100 border-slate-300"}`,children:a.status==="Completed"?e.jsx(Hn,{className:"w-6 h-6 text-green-600"}):e.jsx(vn,{className:"w-6 h-6 text-slate-400"})}),e.jsx("div",{className:`w-0.5 h-full mt-2 ${a.status==="Completed"?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:"flex-1 pb-8",children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-slate-900",children:"Full and Final Settlement"}),e.jsx(Ce,{className:a.status==="Completed"?"bg-green-600":"bg-slate-400",children:a.status==="Completed"?"Completed":"Pending"})]})}),e.jsx("p",{className:"text-slate-600 text-sm mb-3",children:"All financial settlements are processed. Payments made or recoveries completed as per agreed terms. All documentation finalized."})]})]}),e.jsxs("div",{className:"flex gap-4 items-start",children:[e.jsx("div",{className:"flex shrink-0 flex-col items-center",children:e.jsx("div",{className:`size-12 shrink-0 aspect-square rounded-full flex items-center justify-center border-2 ${a.status==="Completed"?"bg-green-100 border-green-600":"bg-slate-100 border-slate-300"}`,children:a.status==="Completed"?e.jsx(Zn,{className:"w-6 h-6 text-green-600"}):e.jsx(vn,{className:"w-6 h-6 text-slate-400"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-slate-900",children:"F&F Complete"}),e.jsx(Ce,{className:a.status==="Completed"?"bg-green-600":"bg-slate-400",children:a.status==="Completed"?"Completed":"Pending"})]}),a.status==="Completed"&&e.jsx("span",{className:"text-sm text-slate-600",children:a.settlementDate||"Oct 15, 2025"})]}),e.jsx("p",{className:"text-slate-600 text-sm mb-3",children:"Full & Final settlement process completed successfully. Case closed. All obligations fulfilled."}),a.status==="Completed"&&e.jsx(Le,{className:"bg-gradient-to-r from-green-50 to-blue-50 border-green-300",children:e.jsx(Fe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-12 shrink-0 aspect-square rounded-full bg-green-600 flex items-center justify-center",children:e.jsx(Zn,{className:"w-7 h-7 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-green-900",children:"Settlement Successfully Completed"}),e.jsxs("p",{className:"text-xs text-green-700 mt-1",children:["All processes completed. Case Number:"," ",a.caseNumber]})]})]})})})]})]})]})})})]})}),e.jsxs(Ut,{value:"details",className:"space-y-6",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Basic Information"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Case Number"}),e.jsx("p",{children:a.caseNumber})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:a.dealerCode})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:a.dealerName})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealership Name"}),e.jsx("p",{children:a.dealershipName})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:a.location})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Request Type"}),e.jsx("p",{children:a.requestType})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Original Request ID"}),e.jsx("p",{children:a.originalRequestId})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:a.submittedOn})]})]})})]}),e.jsxs(Le,{className:"border-red-200 bg-blue-50/30",children:[e.jsx(Qe,{children:e.jsx(Je,{className:"text-blue-900",children:"F&F Settlement Information"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Last Operational Date (Sales)"}),e.jsx("p",{children:a.lastOperationalDateSales})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Last Operational Date (Services)"}),e.jsx("p",{children:a.lastOperationalDateServices})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Submitted Date (F&F Start)"}),e.jsx("p",{children:a.submittedOn})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Days Elapsed since Submission"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{children:[ye," days"]}),e.jsx(Ce,{variant:"outline",className:ye<30?"bg-green-100 text-green-700 border-green-300":ye<60?"bg-yellow-100 text-yellow-700 border-yellow-300":"bg-red-100 text-red-700 border-red-300",children:ye<30?"Recent":ye<60?"In Progress":"Overdue"})]})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Type of Closure"}),e.jsx("p",{children:a.typeOfClosure})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:a.gst})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Sales Code"}),e.jsx("p",{children:a.salesCode})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Service Code"}),e.jsx("p",{children:a.serviceCode})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Gear Code"}),e.jsx("p",{children:a.gearCode})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:a.gmaCode})]})]})})]}),a.status==="Under Review"&&e.jsxs(Le,{className:"border-orange-200 bg-orange-50",children:[e.jsxs(Qe,{children:[e.jsx(Je,{className:"text-orange-900",children:"Under Review"}),e.jsx(Xt,{className:"text-orange-700",children:"This case is under negotiation/discussion with the dealer, finance team, legal team, and relevant departments"})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-sm text-orange-800",children:"Discussions ongoing regarding recovery/payable amounts. Finance team is working with departments to resolve discrepancies."})})]})]}),e.jsxs(Ut,{value:"departments",children:[e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsxs(Je,{children:["Department Responses (",Vt," / ",Pt,")"]}),e.jsx(Xt,{children:"Status of NOC and dues from all departments"})]}),e.jsx(Fe,{children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Department"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Amount Type"}),e.jsx(fe,{children:"Amount"}),e.jsx(fe,{children:"Submitted Date"}),e.jsx(fe,{children:"Remarks"}),st&&e.jsx(fe,{children:"Actions"})]})}),e.jsx(Os,{children:a.departmentResponses.map(Q=>e.jsxs(it,{children:[e.jsx(ue,{children:Q.departmentName}),e.jsx(ue,{children:e.jsx(Ce,{className:_e(Q.status),children:Q.status})}),e.jsx(ue,{children:Q.amountType?e.jsx(Ce,{variant:"outline",className:Q.duesFlow==="recovery"?"bg-red-100 text-red-900 border-red-400 font-semibold":"bg-emerald-100 text-emerald-900 border-emerald-400 font-semibold",children:Q.amountType}):"-"}),e.jsx(ue,{children:Q.amount?e.jsxs("span",{className:`font-semibold tabular-nums ${Q.duesFlow==="recovery"?"text-red-700":"text-emerald-700"}`,children:["₹",Q.amount.toLocaleString()]}):"-"}),e.jsx(ue,{children:Q.submittedDate||"-"}),e.jsx(ue,{className:"max-w-xs truncate",children:Q.remarks||"-"}),st&&e.jsx(ue,{children:dt(Q)?e.jsx(se,{variant:"ghost",size:"sm",className:"text-re-red hover:text-blue-700",onClick:()=>{D(Q),Y({remarks:Q.remarks==="-"?"":Q.remarks,amount:Q.amount||0,type:Q.duesFlow==="payable"?"Payable":"Receivable"}),W(null),q(!0)},children:"Action"}):e.jsx("span",{className:"text-slate-400 text-sm",children:"-"})})]},Q.id))})]})})]}),e.jsxs(Le,{className:"border-blue-200 bg-blue-50 mt-6",children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"Department Claim vs Finance Validation"}),e.jsx(Xt,{children:"Final settlement totals are based on finance validated values."})]}),e.jsx(Fe,{children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Department"}),e.jsx(fe,{children:"Department Claim"}),e.jsx(fe,{children:"Finance Validated"}),e.jsx(fe,{children:"Variance"})]})}),e.jsx(Os,{children:Ys.map(Q=>e.jsxs(it,{children:[e.jsx(ue,{children:Q.department}),e.jsx(ue,{children:Q.claimAmount>0?`${Q.claimType} ₹${Q.claimAmount.toLocaleString()}`:"-"}),e.jsx(ue,{children:Q.validatedAmount>0?`${Q.validatedType} ₹${Q.validatedAmount.toLocaleString()}`:"-"}),e.jsx(ue,{className:Q.variance===0?"text-slate-600":Q.variance>0?"text-red-600":"text-green-600",children:Q.claimAmount===0&&Q.validatedAmount===0?"-":`₹${Q.variance.toLocaleString()}`})]},Q.department))})]})})]}),e.jsxs(Le,{className:"mt-6",children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"Financial Summary"}),e.jsx(Xt,{children:"Consolidated view of all payable and receivable amounts"})]}),e.jsx(Fe,{children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"p-6 bg-green-50 rounded-lg border border-green-200",children:[e.jsx("p",{className:"text-sm text-green-700 mb-2",children:"Total Payable Amount"}),e.jsxs("p",{className:"text-3xl text-green-600",children:["₹",((Qs=a.totalPayableAmount)==null?void 0:Qs.toLocaleString())||"0"]}),e.jsx("p",{className:"text-xs text-green-600 mt-1",children:"Amount to be paid to dealer"})]}),e.jsxs("div",{className:"p-6 bg-red-50 rounded-lg border border-red-200",children:[e.jsx("p",{className:"text-sm text-red-700 mb-2",children:"Total receivable amount"}),e.jsxs("p",{className:"text-3xl text-red-600",children:["₹",((Xs=a.totalRecoveryAmount)==null?void 0:Xs.toLocaleString())||"0"]}),e.jsx("p",{className:"text-xs text-red-600 mt-1",children:"Amount receivable from dealer"})]}),e.jsxs("div",{className:"p-6 bg-red-50 rounded-lg border border-red-200",children:[e.jsx("p",{className:"text-sm text-re-red-hover mb-2",children:"Total Deductions"}),e.jsxs("p",{className:"text-3xl text-re-red font-bold",children:["₹",(($s=a.totalDeductions)==null?void 0:$s.toLocaleString())||"0"]}),e.jsx("p",{className:"text-xs text-re-red mt-1",children:"Warranty holdbacks / Policy penalties"})]}),e.jsxs("div",{className:"p-6 bg-blue-50 rounded-lg border border-blue-200",children:[e.jsx("p",{className:"text-sm text-blue-700 mb-2",children:"Net Settlement Amount"}),e.jsxs("p",{className:`text-3xl font-extrabold ${(a.netAmount||0)<0?"text-red-600":"text-green-600"}`,children:["₹",Math.abs(a.netAmount||0).toLocaleString()]}),e.jsx("p",{className:"text-xs text-blue-600 mt-1",children:(a.netAmount||0)<0?"Receivable from dealer":"Payment to dealer"})]})]})})]}),e.jsxs(Le,{className:"mt-6",children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Finance Report Status"})}),e.jsxs(Fe,{children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Ce,{className:a.financeReportStatus==="Completed"?"bg-green-100 text-green-700 border-green-300":a.financeReportStatus==="In Progress"?"bg-yellow-100 text-yellow-700 border-yellow-300":"bg-slate-100 text-slate-700 border-slate-300",children:a.financeReportStatus}),a.financeReportStatus==="Pending"&&e.jsx("p",{className:"text-slate-600 text-sm",children:"Waiting for all department responses before finance can prepare final report"}),a.financeReportStatus==="In Progress"&&e.jsx("p",{className:"text-slate-600 text-sm",children:"Finance team is reviewing department responses and preparing final settlement report"})]}),a.financeRemarks&&e.jsxs("div",{className:"mt-4 p-4 bg-slate-50 rounded-lg",children:[e.jsx(de,{className:"text-slate-600",children:"Finance Remarks"}),e.jsx("p",{className:"mt-1",children:a.financeRemarks})]})]})]})]}),$e&&e.jsx(Ut,{value:"documents",children:e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(Je,{children:"Documents"}),e.jsx(Xt,{children:"All NOC documents and due statements from departments"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(se,{onClick:()=>I(!0),disabled:U,className:"bg-re-red hover:bg-re-red-hover text-white","data-testid":"fnf-upload-docs-btn",children:[U?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(or,{className:"w-4 h-4 mr-2"}),U?"Uploading...":"Upload Document"]})})]}),e.jsx(Fe,{children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Document Name"}),e.jsx(fe,{children:"Type"}),e.jsx(fe,{children:"Upload Date"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Actions"})]})}),e.jsxs(Os,{children:[(a.documents||[]).length===0&&e.jsx(it,{children:e.jsxs(ue,{colSpan:5,className:"text-center text-slate-500 py-8",children:["No documents uploaded yet. Click ",e.jsx("span",{className:"font-medium",children:"Upload Documents"})," to add files."]})}),(a.documents||[]).map(Q=>e.jsxs(it,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"w-4 h-4 text-slate-500"}),e.jsx("span",{children:Q.name})]})}),e.jsx(ue,{children:Q.type}),e.jsx(ue,{children:Q.uploadDate}),e.jsx(ue,{children:e.jsx(Ce,{variant:Q.status==="Verified"?"default":"secondary",children:Q.status})}),e.jsx(ue,{children:e.jsx(se,{size:"sm",variant:"outline",onClick:()=>{const oe=Q.url,we=oe.startsWith("/uploads/")&&!oe.startsWith("/uploads/documents/")?oe.replace("/uploads/","/uploads/documents/"):oe;u({fileName:Q.name,filePath:we,documentType:Q.type})},children:"View"})})]},Q.id))]})]})})]})}),e.jsx(Ut,{value:"bank",children:e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Je,{children:"Bank Details"}),e.jsx(Xt,{children:"Dealer bank accounts for settlement disbursement"})]}),e.jsxs(se,{onClick:()=>{R(null),C(!0)},className:"bg-re-red",children:[e.jsx(An,{className:"w-4 h-4 mr-2"}),"Add Account"]})]}),e.jsx(Fe,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:w.length>0?w.map(Q=>e.jsxs(Le,{className:`relative overflow-hidden ${Q.isPrimary?"border-re-red bg-blue-50/30":""}`,children:[Q.isPrimary&&e.jsx("div",{className:"absolute top-0 right-0 p-1 bg-re-red text-white text-[10px] uppercase font-bold px-2 rounded-bl",children:"Primary"}),e.jsxs(Fe,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 bg-red-50 rounded-lg",children:e.jsx(so,{className:"w-5 h-5 text-re-red"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-slate-900",children:Q.bankName}),e.jsx("p",{className:"text-xs text-slate-500",children:Q.branchName})]})]}),e.jsxs("div",{className:"space-y-3 mb-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Account Holder"}),e.jsx("p",{className:"text-sm font-medium",children:Q.accountHolderName})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Account Number"}),e.jsx("p",{className:"text-sm font-mono tracking-wider",children:Q.accountNumber.replace(/.(?=.{4})/g,"*")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold",children:"IFSC"}),e.jsx("p",{className:"text-sm font-mono",children:Q.ifscCode})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-slate-100",children:[e.jsxs(se,{variant:"ghost",size:"sm",className:"h-8 text-re-red",onClick:()=>{R(Q),C(!0)},children:[e.jsx(ry,{className:"w-3 h-3 mr-1"}),"Edit"]}),e.jsxs(se,{variant:"ghost",size:"sm",className:"h-8 text-red-600",onClick:()=>ee(Q.id),children:[e.jsx(ar,{className:"w-3 h-3 mr-1"}),"Delete"]})]})]})]},Q.id)):e.jsxs("div",{className:"col-span-full py-12 text-center border-2 border-dashed rounded-lg bg-slate-50",children:[e.jsx(so,{className:"w-12 h-12 text-slate-300 mx-auto mb-3"}),e.jsx("p",{className:"text-slate-600",children:"No bank details found"}),e.jsx(se,{variant:"link",onClick:()=>C(!0),children:"Add first bank account"})]})})})]})}),e.jsx(Ut,{value:"audit",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"Audit Trail"}),e.jsx(Xt,{children:"Complete history of actions on this F&F case"})]}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-4",children:N.length>0?N.map(Q=>{var oe,we,Oe,ke,je,Ve;return e.jsxs("div",{className:"flex gap-3 pb-4 border-b border-slate-100 last:border-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-slate-400 mt-2"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("p",{className:"font-semibold text-slate-900 flex items-center gap-2",children:[Q.action==="FNF_CREATED"&&e.jsx(Ce,{className:"bg-re-red h-2 w-2 p-0 rounded-full"}),Q.description&&!((oe=Q.newData)!=null&&oe.action)?Q.description:e.jsxs(e.Fragment,{children:[ve(((we=Q.newData)==null?void 0:we.action)||Q.action),((Oe=Q.newData)==null?void 0:Oe.department)&&e.jsxs("span",{className:"text-re-red ml-1 font-bold",children:["- ",Q.newData.department]})]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:ua(Q.createdAt||Q.timestamp)})]}),e.jsx("div",{className:"flex items-center gap-2 text-sm text-slate-600 mb-2",children:e.jsx(Ce,{variant:"outline",className:"text-[10px] uppercase",children:((ke=Q.actor)==null?void 0:ke.name)||Q.userName||"System"})}),(((je=Q.newData)==null?void 0:je.remarks)||Q.remarks)&&e.jsx("div",{className:"mt-2 p-3 bg-slate-50 border border-slate-200 rounded text-sm text-slate-700",children:((Ve=Q.newData)==null?void 0:Ve.remarks)||Q.remarks}),Q.newData&&Object.keys(Q.newData).filter(Ge=>Ge!=="remarks"&&Ge!=="status"&&Ge!=="action"&&Ge!=="department").length>0&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold px-1",children:"Changes:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(Q.newData).filter(([Ge])=>Ge!=="remarks"&&Ge!=="action"&&Ge!=="department").map(([Ge,nt])=>e.jsxs("div",{className:"text-[11px] bg-slate-100 border rounded px-2 py-0.5 flex items-center gap-1",children:[e.jsxs("span",{className:"text-slate-500",children:[Ge,":"]}),e.jsx("span",{className:"text-slate-900 font-medium",children:String(nt)})]},Ge))})]})]})]},Q.id)}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:e.jsx("p",{children:"No activity logs found for this case."})})})})]})})]}),e.jsx(ds,{open:p,onOpenChange:h,children:e.jsxs(os,{children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Send to All Stakeholders"}),e.jsx(bs,{children:"This will send notifications to all 16 departments to submit their NOC or dues information"})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"p-4 bg-blue-50 rounded-lg border border-red-200",children:[e.jsx("p",{className:"text-sm text-blue-900 mb-2",children:"Notifications will be sent to:"}),e.jsxs("ul",{className:"text-sm text-blue-800 space-y-1 ml-4",children:[e.jsx("li",{children:"• All 16 departments"}),e.jsxs("li",{children:["• Case Number: ",a.caseNumber]}),e.jsxs("li",{children:["• Dealer: ",a.dealerName]}),e.jsxs("li",{children:["• Type: ",a.requestType]})]})]})}),e.jsxs(bn,{children:[e.jsx(se,{variant:"outline",onClick:()=>h(!1),children:"Cancel"}),e.jsxs(se,{onClick:pt,className:"bg-re-red hover:bg-blue-700",children:[e.jsx(Gu,{className:"w-4 h-4 mr-2"}),"Send Notifications"]})]})]})}),e.jsx(ds,{open:E,onOpenChange:q,children:e.jsxs(os,{className:"sm:max-w-[460px]",children:[e.jsxs(xs,{children:[e.jsxs(ms,{children:["Update ",O==null?void 0:O.departmentName," Response"]}),e.jsx(bs,{children:"Provide dues/NOC response with remarks and optional supporting proof."})]}),e.jsxs("div",{className:"grid gap-4 py-2",children:[e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(de,{htmlFor:"type",className:"text-right",children:"Type"}),e.jsxs("select",{id:"type",className:"col-span-3 flex h-10 w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm",value:$.type,onChange:Q=>Y({...$,type:Q.target.value}),children:[e.jsx("option",{value:"Receivable",children:"Receivable (from dealer)"}),e.jsx("option",{value:"Payable",children:"Payable (to dealer)"}),e.jsx("option",{value:"Deduction",children:"Deduction"})]})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(de,{htmlFor:"amount",className:"text-right",children:"Amount"}),e.jsxs("div",{className:"col-span-3 relative",children:[e.jsx("span",{className:"absolute left-3 top-2.5 text-slate-500 font-medium",children:"₹"}),e.jsx("input",{id:"amount",type:"number",className:"flex h-10 w-full rounded-md border border-slate-200 bg-white pl-7 pr-3 py-2 text-sm",value:$.amount,onChange:Q=>Y({...$,amount:Number(Q.target.value)})})]})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(de,{htmlFor:"remarks",className:"text-right",children:"Remarks"}),e.jsx("textarea",{id:"remarks",className:"col-span-3 flex min-h-[80px] w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm",placeholder:"Add response details...",value:$.remarks,onChange:Q=>Y({...$,remarks:Q.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(de,{htmlFor:"proof",className:"text-right",children:"Proof"}),e.jsx("input",{id:"proof",type:"file",className:"col-span-3 text-sm",onChange:Q=>{var oe;return W(((oe=Q.target.files)==null?void 0:oe[0])||null)}})]})]}),e.jsxs(bn,{children:[e.jsx(se,{variant:"outline",onClick:()=>q(!1),children:"Cancel"}),e.jsx(se,{className:"bg-re-red hover:bg-blue-700",onClick:xt,disabled:P,children:P?"Saving...":"Submit Response"})]})]})}),e.jsx(ds,{open:T,onOpenChange:Q=>{Q?I(!0):It()},children:e.jsxs(os,{className:"sm:max-w-md",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Upload Document"}),e.jsx(bs,{children:"Provide a name for this document and attach a file. The name is required."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(de,{htmlFor:"fnf-upload-doc-name",children:["Document Name ",e.jsx("span",{className:"text-red-600",children:"*"})]}),e.jsx("input",{id:"fnf-upload-doc-name",type:"text",placeholder:"e.g. Final NOC — Sales",className:"flex h-10 w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm",value:B,onChange:Q=>G(Q.target.value),"data-testid":"fnf-upload-doc-name"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(de,{htmlFor:"fnf-upload-doc-type",children:"Document Type (optional)"}),e.jsx("input",{id:"fnf-upload-doc-type",type:"text",placeholder:"e.g. NOC, Statement, Receipt",className:"flex h-10 w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm",value:K,onChange:Q=>H(Q.target.value),"data-testid":"fnf-upload-doc-type"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(de,{htmlFor:"fnf-upload-doc-file",children:["File ",e.jsx("span",{className:"text-red-600",children:"*"})]}),e.jsx("input",{id:"fnf-upload-doc-file",ref:z,type:"file",className:"flex w-full text-sm",onChange:Mt,"data-testid":"fnf-upload-docs-input"}),X&&e.jsxs("p",{className:"text-xs text-slate-500 truncate",children:["Selected: ",e.jsx("span",{className:"font-medium",children:X.name})]})]})]}),e.jsxs(bn,{children:[e.jsx(se,{variant:"outline",onClick:It,disabled:U,children:"Cancel"}),e.jsxs(se,{className:"bg-re-red hover:bg-re-red-hover text-white",onClick:he,disabled:U||!B.trim()||!X,"data-testid":"fnf-upload-doc-submit",children:[U?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(or,{className:"w-4 h-4 mr-2"}),U?"Uploading...":"Upload"]})]})]})}),e.jsx(p_,{isOpen:b,onClose:()=>{C(!1),R(null)},onSubmit:vt,editingBank:S,isSubmitting:_}),e.jsx(mo,{isOpen:!!x,onClose:()=>u(null),document:x})]})}function AV({onViewPaymentDetails:t}={}){const[s,n]=g.useState([]),[r,a]=g.useState(!0),[i,o]=g.useState("pending");g.useEffect(()=>{d()},[]);const d=async()=>{try{a(!0);const u=await hs.getApplications();n(u.data||[])}catch(u){console.error("Fetch error:",u),te.error("Failed to fetch applications")}finally{a(!1)}},m=u=>String(u||"").trim().toLowerCase(),f=u=>{const N=m(u);return N==="verified"||N==="paid"},p=s.flatMap(u=>{const N=u.overallStatus||u.status,v=["Payment Pending","Security Deposit","Security Details","LOI In Progress","LOI Issued","LOA Pending","Dealer Code Generation","LOA_APPROVAL"].includes(N),w=u.securityDeposits||[];return w.length>0?w.map(j=>({id:j.id,applicationId:u.applicationId||u.id,application:u,paymentStatus:j.status,paymentType:j.depositType,amount:j.amount,createdAt:j.createdAt,verificationDate:j.verifiedAt,isVirtual:!1})):v?["Payment Pending","Security Deposit","Security Details","LOI In Progress"].includes(N)?[{id:`virtual-${u.id}-sd`,applicationId:u.applicationId||u.id,application:u,paymentStatus:"Pending",paymentType:"SECURITY_DEPOSIT",amount:5e5,createdAt:u.updatedAt,verificationDate:null,isVirtual:!0}]:[{id:`virtual-${u.id}-ff`,applicationId:u.applicationId||u.id,application:u,paymentStatus:"Pending",paymentType:"FIRST_FILL",amount:15e5,createdAt:u.updatedAt,verificationDate:null,isVirtual:!0}]:[]}),h=p.filter(u=>i==="all"?!0:i==="pending"?!f(u.paymentStatus):i==="verified"?f(u.paymentStatus):!0),x=u=>{t&&t(u)};return r?e.jsxs("div",{className:"flex items-center justify-center p-20 text-blue-600",children:[e.jsx(vn,{className:"w-8 h-8 animate-spin mr-3"}),e.jsx("span",{children:"Loading Finance Queue..."})]}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between bg-white p-6 rounded-2xl border border-slate-100 shadow-sm",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-slate-900 tracking-tight mb-1",children:"Payment Verification"}),e.jsx("p",{className:"text-slate-500",children:"Review and verify Security Deposit and First Fill payments for dealers"})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs(se,{onClick:d,variant:"outline",size:"sm",className:"bg-white hover:bg-slate-50","data-testid":"onboarding-finance-queue-sync-btn",children:[e.jsx(vn,{className:"w-4 h-4 mr-2"}),"Sync Dashboard"]})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsx("div",{className:"inline-flex p-1 bg-slate-100 rounded-xl",children:e.jsxs("div",{className:"flex items-center px-4 py-2 bg-white rounded-lg text-slate-900 shadow-sm font-medium text-sm","data-testid":"onboarding-finance-queue-pending-count",children:[e.jsx(ka,{className:"w-4 h-4 mr-2 text-blue-600"}),"Pending Payments (",p.filter(u=>!f(u.paymentStatus)).length,")"]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(se,{variant:i==="pending"?"secondary":"ghost",size:"sm",onClick:()=>o("pending"),className:i==="pending"?"bg-slate-200 text-slate-900":"text-slate-500","data-testid":"onboarding-finance-queue-filter-pending",children:"Pending"}),e.jsx(se,{variant:i==="verified"?"secondary":"ghost",size:"sm",onClick:()=>o("verified"),className:i==="verified"?"bg-slate-200 text-slate-900":"text-slate-500","data-testid":"onboarding-finance-queue-filter-verified",children:"Verified"}),e.jsx(se,{variant:i==="all"?"secondary":"ghost",size:"sm",onClick:()=>o("all"),className:i==="all"?"bg-slate-200 text-slate-900":"text-slate-500","data-testid":"onboarding-finance-queue-filter-all",children:"All"})]})]}),e.jsx(Le,{className:"border-none shadow-xl overflow-hidden rounded-2xl bg-white","data-testid":"onboarding-finance-queue-table-card",children:e.jsx(Fe,{className:"p-0",children:e.jsxs(Ts,{children:[e.jsx(Ps,{className:"bg-slate-50/50",children:e.jsxs(it,{className:"border-b border-slate-100 uppercase text-[10px] tracking-wider font-bold text-slate-400",children:[e.jsx(fe,{className:"py-4 pl-6","data-testid":"onboarding-finance-queue-th-details",children:"Application Details"}),e.jsx(fe,{"data-testid":"onboarding-finance-queue-th-location",children:"Location"}),e.jsx(fe,{"data-testid":"onboarding-finance-queue-th-stage",children:"Payment Stage"}),e.jsx(fe,{"data-testid":"onboarding-finance-queue-th-status",children:"Current Status"}),e.jsx(fe,{className:"text-right pr-6","data-testid":"onboarding-finance-queue-th-action",children:"Workflow Action"})]})}),e.jsx(Os,{children:h.length>0?h.map((u,N)=>{const v=u.paymentStatus||"Awaiting Payment",w=u.application||{};return e.jsxs(it,{className:"hover:bg-blue-50/20 group transition-all","data-testid":`onboarding-finance-queue-row-${N}`,children:[e.jsx(ue,{className:"py-4 pl-6",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-mono text-xs font-bold text-blue-600 mb-1","data-testid":`onboarding-finance-queue-app-id-${N}`,children:w.applicationId||w.id}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"font-semibold text-slate-900","data-testid":`onboarding-finance-queue-name-${N}`,children:w.applicantName})})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex flex-col text-sm","data-testid":`onboarding-finance-queue-location-${N}`,children:[e.jsx("span",{className:"text-slate-600 leading-none",children:w.city}),e.jsx("span",{className:"text-slate-400 text-xs mt-1",children:w.state})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2","data-testid":`onboarding-finance-queue-type-${N}`,children:[e.jsx(Wu,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-sm font-medium",children:u.paymentType==="SECURITY_DEPOSIT"?"Security Deposit (₹5L)":"First Fill (₹15L)"})]})}),e.jsx(ue,{children:e.jsx(Ce,{className:v==="Verified"?"bg-emerald-50 text-emerald-700 border-emerald-100 px-3 py-1 rounded-full":v==="Rejected"?"bg-rose-50 text-rose-700 border-rose-100 px-3 py-1 rounded-full":"bg-red-50 text-re-red-hover border-red-100 px-3 py-1 rounded-full",variant:"outline","data-testid":`onboarding-finance-queue-status-${N}`,children:v})}),e.jsx(ue,{className:"text-right pr-6",children:e.jsx(se,{size:"sm",variant:f(v)?"outline":"default",className:f(v)?"bg-white text-slate-600 border-slate-200":"bg-blue-600 hover:bg-blue-700 shadow-md",onClick:()=>x(u.applicationId||w.id),"data-testid":`onboarding-finance-queue-action-btn-${N}`,children:e.jsxs(e.Fragment,{children:[e.jsx(ka,{className:"w-4 h-4 mr-2"}),f(v)?"View Receipt":"Record Payment"]})})})]},u.id)}):e.jsx(it,{children:e.jsx(ue,{colSpan:5,className:"h-48 text-center text-slate-400 py-10","data-testid":"onboarding-finance-queue-empty",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-slate-50 rounded-full flex items-center justify-center",children:e.jsx(un,{className:"w-6 h-6 text-slate-200"})}),e.jsx("p",{className:"text-sm",children:i==="verified"?"No verified payments found":i==="pending"?"No pending payments in the queue":"No onboarding payments found"})]})})})})]})})})]})}function kV({onViewFnFDetails:t}={}){const[s,n]=g.useState([]),[r,a]=g.useState(!0),[i,o]=g.useState(null),[d,m]=g.useState(!1),[f,p]=g.useState(!1),[h,x]=g.useState(""),[u,N]=g.useState(""),[v,w]=g.useState("all");g.useEffect(()=>{j()},[]);const j=async()=>{try{a(!0);const P=(await Ee.getFnFSettlements()).data;P.success&&n(P.settlements||[])}catch(D){console.error("Fetch settlements error:",D),te.error("Failed to fetch settlement cases")}finally{a(!1)}},b=D=>{var P,L,$,Y,Z,W,U,M,z,T,I,B;return{id:D.id,caseId:D.settlementId||((P=D.resignation)==null?void 0:P.resignationId)||((L=D.terminationRequest)==null?void 0:L.requestId)||D.id.substring(0,8),dealerCode:(($=D.outlet)==null?void 0:$.code)||((Z=(Y=D.dealer)==null?void 0:Y.dealerCode)==null?void 0:Z.dealerCode)||"N/A",dealerName:((U=(W=D.outlet)==null?void 0:W.dealer)==null?void 0:U.fullName)||((M=D.dealer)==null?void 0:M.legalName)||((z=D.dealer)==null?void 0:z.businessName)||((T=D.dealer)==null?void 0:T.fullName)||"N/A",location:((I=D.outlet)==null?void 0:I.city)||((B=D.outlet)==null?void 0:B.location)||"N/A",terminationType:D.resignationId?"Resignation":"Termination",submittedDate:Yt(D.createdAt),status:D.status==="Calculated"?"Pending Finance Review":D.status==="Settled"?"Settled":D.status,financialData:{totalPayables:parseFloat(D.totalPayables)||0,totalReceivables:parseFloat(D.totalReceivables)||0,netAmount:parseFloat(D.netAmount)||0},settlementAmount:Math.abs(parseFloat(D.netAmount)||0),settlementType:parseFloat(D.netAmount)>0?"Payable to Dealer":"Receivable from Dealer",approvedDate:D.settlementDate?Yt(D.settlementDate):null}},C=s.map(b),S=C.filter(D=>v==="all"?!0:v==="pending"?D.status==="Pending Finance Review"||D.status==="Calculated"||D.status==="Initiated"||D.status==="Under Review":v==="approved"?D.status==="Settled"||D.status==="Completed":!0),R=D=>({receivables:D.totalReceivables||0,payables:D.totalPayables||0,deductions:0,netSettlement:D.netAmount||0,settlementType:(D.netAmount||0)>0?"Payable to Dealer":"Receivable from Dealer",settlementAmount:Math.abs(D.netAmount||0)}),_=D=>{t?t(D.id):(o(D),m(!0))},A=D=>{t?t(D.id):(o(D),p(!0))},E=()=>{const D=R(i.financialData);te.success(`Settlement approved: ${D.settlementType} - ₹${D.settlementAmount.toLocaleString()}`),m(!1),x(""),N(""),o(null)},q=C.filter(D=>D.status==="Pending Finance Review"||D.status==="Calculated"||D.status==="Initiated"||D.status==="Under Review").length,O=C.filter(D=>D.status==="Settled"||D.status==="Completed").length;return r?e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(ns,{className:"w-8 h-8 animate-spin text-re-red"})}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 mb-2",children:"F&F Financial Settlement"}),e.jsx("p",{className:"text-slate-600",children:"Review and process full & final settlements for dealerships"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs(Le,{children:[e.jsx(Qe,{className:"pb-3",children:e.jsx(Je,{className:"text-sm text-slate-600",children:"Pending Review"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-slate-900 text-2xl",children:q}),e.jsx(ak,{className:"w-8 h-8 text-re-red"})]})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{className:"pb-3",children:e.jsx(Je,{className:"text-sm text-slate-600",children:"Approved Settlements"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-slate-900 text-2xl",children:O}),e.jsx(un,{className:"w-8 h-8 text-green-600"})]})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{className:"pb-3",children:e.jsx(Je,{className:"text-sm text-slate-600",children:"Total Cases"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-slate-900 text-2xl",children:C.length}),e.jsx(Ns,{className:"w-8 h-8 text-blue-600"})]})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{className:"pb-3",children:e.jsx(Je,{className:"text-sm text-slate-600",children:"Net Financial Position"})}),e.jsxs(Fe,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:`text-2xl ${C.reduce((D,P)=>D+(P.financialData.netAmount||0),0)<0?"text-green-600":"text-red-600"}`,children:["₹",Math.abs(C.reduce((D,P)=>D+(P.financialData.netAmount||0),0)).toLocaleString("en-IN")]}),e.jsx(dl,{className:"w-8 h-8 text-purple-600"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:C.reduce((D,P)=>D+(P.financialData.netAmount||0),0)<0?"Net Receivable":"Net Payable"})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(se,{variant:v==="all"?"default":"outline",onClick:()=>w("all"),className:v==="all"?"bg-re-red hover:bg-re-red-hover":"",children:["All Cases (",C.length,")"]}),e.jsxs(se,{variant:v==="pending"?"default":"outline",onClick:()=>w("pending"),className:v==="pending"?"bg-re-red hover:bg-re-red-hover":"",children:["Pending Review (",q,")"]}),e.jsxs(se,{variant:v==="approved"?"default":"outline",onClick:()=>w("approved"),className:v==="approved"?"bg-re-red hover:bg-re-red-hover":"",children:["Approved (",O,")"]})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"F&F Settlement Queue"}),e.jsx(Xt,{children:"Review financial status and calculate settlements"})]}),e.jsx(Fe,{children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Case ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Location"}),e.jsx(fe,{children:"Type"}),e.jsx(fe,{children:"Submitted Date"}),e.jsx(fe,{children:"Net Settlement"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Os,{children:S.map(D=>{const P=R(D.financialData);return e.jsxs(it,{children:[e.jsx(ue,{children:e.jsxs("div",{children:[e.jsx("div",{className:"text-slate-900",children:D.caseId}),e.jsx("div",{className:"text-sm text-slate-500",children:D.dealerCode})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lr,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:D.dealerName})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vr,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:D.location})]})}),e.jsx(ue,{children:e.jsx(Ce,{variant:D.terminationType==="Resignation"?"default":"secondary",children:D.terminationType})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dr,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:D.submittedDate})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[P.settlementType==="Payable to Dealer"?e.jsx(Yo,{className:"w-4 h-4 text-red-600"}):e.jsx(dl,{className:"w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-slate-900",children:["₹",P.settlementAmount.toLocaleString()]}),e.jsx("div",{className:"text-xs text-slate-500",children:P.settlementType})]})]})}),e.jsx(ue,{children:e.jsx(Ce,{variant:D.status==="Settlement Approved"?"default":"secondary",className:D.status==="Settlement Approved"?"bg-green-600 text-white":"bg-re-red text-white",children:D.status})}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:D.status==="Pending Finance Review"?"default":"outline",className:D.status==="Pending Finance Review"?"bg-re-red hover:bg-re-red-hover":"",onClick:()=>A(D),children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),"View Details"]})})]},D.id)})})]})})]}),e.jsx(ds,{open:d,onOpenChange:m,children:e.jsxs(os,{className:"max-w-5xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Financial Settlement Review"}),e.jsxs(bs,{children:["Review financial details and calculate final settlement for ",i==null?void 0:i.dealerName]})]}),i&&e.jsxs(Bn,{defaultValue:"breakdown",className:"w-full",children:[e.jsxs($n,{className:"grid w-full grid-cols-3",children:[e.jsx(Wt,{value:"breakdown",children:"Financial Breakdown"}),e.jsx(Wt,{value:"calculation",children:"Settlement Calculation"}),e.jsx(Wt,{value:"summary",children:"Final Summary"})]}),e.jsxs(Ut,{value:"breakdown",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Le,{className:"border-green-200 bg-green-50",children:[e.jsxs(Qe,{children:[e.jsxs(Je,{className:"text-base flex items-center gap-2",children:[e.jsx(lf,{className:"w-5 h-5 text-green-600"}),"Payables to Dealer"]}),e.jsx(Xt,{children:"Amounts company owes to dealer"})]}),e.jsxs(Fe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Security Deposit"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.securityDeposit.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Inventory Value"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.inventoryValue.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Equipment Value"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.equipmentValue.toLocaleString()]})]}),e.jsx("div",{className:"pt-3 border-t border-green-300",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-900",children:"Total Payables"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",(i.financialData.securityDeposit+i.financialData.inventoryValue+i.financialData.equipmentValue).toLocaleString()]})]})})]})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50",children:[e.jsxs(Qe,{children:[e.jsxs(Je,{className:"text-base flex items-center gap-2",children:[e.jsx(ay,{className:"w-5 h-5 text-red-600"}),"Receivables from Dealer"]}),e.jsx(Xt,{children:"Amounts dealer owes to company"})]}),e.jsxs(Fe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Outstanding Invoices"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.outstandingInvoices.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Service Dues"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.serviceDues.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Parts Dues"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.partsDues.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Advances Given"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.advancesGiven.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Penalties"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.penalties.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Other Charges"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.otherCharges.toLocaleString()]})]}),e.jsx("div",{className:"pt-3 border-t border-red-300",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-900",children:"Total Receivables"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",R(i.financialData).receivables.toLocaleString()]})]})})]})]})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50",children:[e.jsxs(Qe,{children:[e.jsxs(Je,{className:"text-base flex items-center gap-2",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red"}),"Deductions"]}),e.jsx(Xt,{children:"Pending claims and deductions"})]}),e.jsx(Fe,{children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Warranty Claims Pending"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",i.financialData.warrantyPending.toLocaleString()]})]})})]})]}),e.jsx(Ut,{value:"calculation",className:"space-y-4",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"Settlement Calculation"}),e.jsx(Xt,{children:"Step-by-step calculation of final settlement amount"})]}),e.jsx(Fe,{className:"space-y-4",children:(()=>{const D=R(i.financialData);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center p-3 bg-green-50 rounded",children:[e.jsx("span",{className:"text-slate-900",children:"Total Payables (to Dealer)"}),e.jsxs("span",{className:"text-green-600 text-lg",children:["+ ₹",D.payables.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-red-50 rounded",children:[e.jsx("span",{className:"text-slate-900",children:"Total Receivables (from Dealer)"}),e.jsxs("span",{className:"text-red-600 text-lg",children:["- ₹",D.receivables.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-red-50 rounded",children:[e.jsx("span",{className:"text-slate-900",children:"Total Deductions"}),e.jsxs("span",{className:"text-re-red text-lg",children:["- ₹",D.deductions.toLocaleString()]})]})]}),e.jsx("div",{className:"h-px bg-slate-300"}),e.jsxs("div",{className:`p-4 rounded-lg ${D.netSettlement>0?"bg-red-100 border-2 border-red-300":"bg-green-100 border-2 border-green-300"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-slate-900",children:"Net Settlement"}),e.jsxs("span",{className:"text-2xl text-slate-900",children:["₹",D.settlementAmount.toLocaleString()]})]}),e.jsx("div",{className:"flex items-center gap-2",children:D.settlementType==="Payable to Dealer"?e.jsxs(e.Fragment,{children:[e.jsx(Yo,{className:"w-5 h-5 text-red-600"}),e.jsx("span",{className:"text-red-700",children:"Company needs to pay dealer"})]}):e.jsxs(e.Fragment,{children:[e.jsx(dl,{className:"w-5 h-5 text-green-600"}),e.jsx("span",{className:"text-green-700",children:"Dealer needs to pay company"})]})})]}),e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-blue-50 border border-blue-200 rounded-lg",children:[e.jsx(sn,{className:"w-5 h-5 text-blue-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-900 mb-1",children:"Calculation Formula"}),e.jsx("p",{className:"text-sm text-slate-600",children:"Net Settlement = Total Payables - Total Receivables - Total Deductions"}),e.jsxs("p",{className:"text-sm text-slate-600 mt-2",children:["= ₹",D.payables.toLocaleString()," - ₹",D.receivables.toLocaleString()," - ₹",D.deductions.toLocaleString()]})]})]})]})})()})]})}),e.jsxs(Ut,{value:"summary",className:"space-y-4",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Case Summary"})}),e.jsx(Fe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Case ID"}),e.jsx("p",{className:"text-slate-900",children:i.id})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Dealer Name"}),e.jsx("p",{className:"text-slate-900",children:i.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Dealer Code"}),e.jsx("p",{className:"text-slate-900",children:i.dealerCode})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Location"}),e.jsx("p",{className:"text-slate-900",children:i.location})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Termination Type"}),e.jsx("p",{className:"text-slate-900",children:i.terminationType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Submitted Date"}),e.jsx("p",{className:"text-slate-900",children:i.submittedDate})]})]})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Final Settlement"})}),e.jsxs(Fe,{className:"space-y-4",children:[(()=>{const D=R(i.financialData);return e.jsxs("div",{className:`p-6 rounded-lg text-center ${D.settlementType==="Payable to Dealer"?"bg-red-100 border-2 border-red-300":"bg-green-100 border-2 border-green-300"}`,children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-3",children:[D.settlementType==="Payable to Dealer"?e.jsx(Yo,{className:"w-8 h-8 text-red-600"}):e.jsx(dl,{className:"w-8 h-8 text-green-600"}),e.jsx("span",{className:`text-lg ${D.settlementType==="Payable to Dealer"?"text-red-700":"text-green-700"}`,children:D.settlementType})]}),e.jsxs("div",{className:"text-4xl text-slate-900 mb-2",children:["₹",D.settlementAmount.toLocaleString()]}),e.jsx("p",{className:"text-slate-600",children:D.settlementType==="Payable to Dealer"?"Company will pay this amount to the dealer":"Dealer must pay this amount to the company"})]})})(),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"adjustments",children:"Adjustments (if any)"}),e.jsx(at,{id:"adjustments",value:h,onChange:D=>x(D.target.value),placeholder:"Enter any adjustments to the settlement amount"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"finalNotes",children:"Final Notes"}),e.jsx(Ws,{id:"finalNotes",value:u,onChange:D=>N(D.target.value),placeholder:"Enter any final notes or remarks for this settlement...",rows:4})]})]})]})]})]}),e.jsxs(bn,{children:[e.jsx(se,{variant:"outline",onClick:()=>m(!1),children:"Cancel"}),e.jsxs(se,{className:"bg-green-600 hover:bg-green-700",onClick:E,children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"Approve Settlement"]})]})]})}),e.jsx(ds,{open:f,onOpenChange:p,children:e.jsxs(os,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Settlement Details"}),e.jsxs(bs,{children:["Complete settlement information for ",i==null?void 0:i.dealerName]})]}),i&&e.jsxs(Bn,{defaultValue:"info",className:"w-full",children:[e.jsxs($n,{className:"grid w-full grid-cols-2",children:[e.jsx(Wt,{value:"info",children:"Case Information"}),e.jsx(Wt,{value:"financial",children:"Financial Breakdown"})]}),e.jsx(Ut,{value:"info",className:"space-y-4 mt-4",children:e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{className:"text-base",children:"Case Details"})}),e.jsx(Fe,{className:"space-y-3",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Case ID"}),e.jsx("p",{className:"text-slate-900",children:i.id})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Dealer Code"}),e.jsx("p",{className:"text-slate-900",children:i.dealerCode})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Dealer Name"}),e.jsx("p",{className:"text-slate-900",children:i.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Location"}),e.jsx("p",{className:"text-slate-900",children:i.location})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Termination Type"}),e.jsx(Ce,{variant:i.terminationType==="Resignation"?"default":"secondary",children:i.terminationType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Status"}),e.jsx(Ce,{variant:i.status==="Settlement Approved"?"default":"secondary",className:i.status==="Settlement Approved"?"bg-green-600 text-white":"bg-re-red text-white",children:i.status})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Submitted Date"}),e.jsx("p",{className:"text-slate-900",children:i.submittedDate})]}),i.approvedDate&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Approved Date"}),e.jsx("p",{className:"text-slate-900",children:i.approvedDate})]})]})})]})}),e.jsx(Ut,{value:"financial",className:"space-y-4 mt-4",children:(()=>{const D=R(i.financialData);return e.jsxs(e.Fragment,{children:[e.jsxs(Le,{className:"border-green-200 bg-green-50",children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"text-base flex items-center gap-2",children:[e.jsx(lf,{className:"w-5 h-5 text-green-600"}),"Payables to Dealer"]})}),e.jsxs(Fe,{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Security Deposit"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.securityDeposit.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Inventory Value"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.inventoryValue.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Equipment Value"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.equipmentValue.toLocaleString()]})]}),e.jsx("div",{className:"pt-2 border-t border-green-300",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-900",children:"Total Payables"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",D.payables.toLocaleString()]})]})})]})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50",children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"text-base flex items-center gap-2",children:[e.jsx(ay,{className:"w-5 h-5 text-red-600"}),"Receivables from Dealer"]})}),e.jsxs(Fe,{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Outstanding Invoices"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.outstandingInvoices.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Service Dues"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.serviceDues.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Parts Dues"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.partsDues.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Advances Given"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.advancesGiven.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Penalties"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.penalties.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Other Charges"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.otherCharges.toLocaleString()]})]}),e.jsx("div",{className:"pt-2 border-t border-red-300",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-900",children:"Total Receivables"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",D.receivables.toLocaleString()]})]})})]})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50",children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"text-base flex items-center gap-2",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red"}),"Deductions"]})}),e.jsx(Fe,{children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Warranty Claims Pending"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",i.financialData.warrantyPending.toLocaleString()]})]})})]}),e.jsxs(Le,{className:`${D.settlementType==="Payable to Dealer"?"border-red-300 bg-red-100":"border-green-300 bg-green-100"}`,children:[e.jsx(Qe,{children:e.jsx(Je,{className:"text-base",children:"Net Settlement"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"text-center py-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-2",children:[D.settlementType==="Payable to Dealer"?e.jsx(Yo,{className:"w-6 h-6 text-red-600"}):e.jsx(dl,{className:"w-6 h-6 text-green-600"}),e.jsx("span",{className:`text-lg ${D.settlementType==="Payable to Dealer"?"text-red-700":"text-green-700"}`,children:D.settlementType})]}),e.jsxs("div",{className:"text-3xl text-slate-900",children:["₹",D.settlementAmount.toLocaleString()]})]})})]})]})})()})]}),e.jsxs(bn,{children:[e.jsx(se,{variant:"outline",onClick:()=>p(!1),children:"Close"}),(i==null?void 0:i.status)==="Pending Finance Review"&&e.jsx(se,{className:"bg-re-red hover:bg-re-red-hover",onClick:()=>{p(!1),_(i)},children:"Review & Settle"})]})]})})]})}const zo=(...t)=>t.filter(Boolean).join(" ");function DV({applicationId:t,onBack:s}){var E,q,O,D;const[n,r]=g.useState(null),[a,i]=g.useState([]),[o,d]=g.useState("SECURITY_DEPOSIT"),[m,f]=g.useState(!0),[p,h]=g.useState(!1),[x,u]=g.useState({}),[N,v]=g.useState({verificationTransactionId:"",receivedAmount:"",receivedDate:new Date().toISOString().split("T")[0],verificationRemarks:""}),[w,j]=g.useState(!1),[b,C]=g.useState(null),S=a.find(P=>P.depositType===o);g.useEffect(()=>{R()},[t]),g.useEffect(()=>{var P,L,$;if(S)v({verificationTransactionId:S.paymentReference||"",receivedAmount:((P=S.amount)==null?void 0:P.toString())||"",receivedDate:S.verifiedAt?new Date(S.verifiedAt).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],verificationRemarks:S.remarks||""});else{const Y=((L=x.SECURITY_DEPOSIT)==null?void 0:L.amount)||5e5,Z=(($=x.FIRST_FILL)==null?void 0:$.amount)||15e5;v({verificationTransactionId:"",receivedAmount:o==="SECURITY_DEPOSIT"?Y.toString():Z.toString(),receivedDate:new Date().toISOString().split("T")[0],verificationRemarks:""})}},[o,S,x]);const R=async()=>{try{f(!0);const[P,L,$]=await Promise.all([hs.getApplicationById(t),hs.getSecurityDeposit(t),hs.getSystemConfigs({category:"SECURITY_DEPOSIT",format:"map"})]);r(P),i(Array.isArray(L)?L:[L].filter(Boolean)),u($||{})}catch(P){console.error("Fetch error:",P),te.error("Failed to load payment data")}finally{f(!1)}},_=async()=>{if(!N.verificationTransactionId||!N.receivedDate){te.error("Please fill in all required payment details");return}try{h(!0),await hs.updateSecurityDeposit({applicationId:t,depositType:o,amount:Number(N.receivedAmount),paymentReference:N.verificationTransactionId,status:"Verified"}),te.success(`${o==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"} verified and approved`),await R()}catch{te.error("Failed to verify payment")}finally{h(!1)}},A=async()=>{if(!N.verificationRemarks){te.error("Please provide remarks for rejection");return}try{h(!0),await hs.updateSecurityDeposit({applicationId:t,depositType:o,status:"Rejected",remarks:N.verificationRemarks}),te.error(`${o==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"} rejected`),await R()}catch{te.error("Failed to reject payment")}finally{h(!1)}};return m?e.jsx("div",{className:"flex items-center justify-center p-20",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-re-red"})}):n?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(se,{variant:"outline",size:"icon",onClick:s,children:e.jsx(Jr,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl mb-1",children:"Payment Verification"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(se,{size:"sm",variant:o==="SECURITY_DEPOSIT"?"default":"outline",className:o==="SECURITY_DEPOSIT"?"bg-re-red hover:bg-re-red-hover":"",onClick:()=>d("SECURITY_DEPOSIT"),children:"Security Deposit"}),e.jsx(se,{size:"sm",variant:o==="FIRST_FILL"?"default":"outline",className:o==="FIRST_FILL"?"bg-re-red hover:bg-re-red-hover":"",onClick:()=>d("FIRST_FILL"),children:"First Fill"})]})]})]}),e.jsx(Le,{className:zo("border",(S==null?void 0:S.status)==="Verified"?"border-green-200 bg-green-50":((S==null?void 0:S.status)==="Rejected","border-red-200 bg-red-50")),children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:zo("w-12 h-12 rounded-full flex items-center justify-center",(S==null?void 0:S.status)==="Verified"?"bg-green-100":(S==null?void 0:S.status)==="Rejected"?"bg-red-100":"bg-red-50"),children:e.jsx(ka,{className:zo("w-6 h-6",(S==null?void 0:S.status)==="Verified"?"text-green-600":(S==null?void 0:S.status)==="Rejected"?"text-red-600":"text-re-red")})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 font-bold",children:o==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"}),e.jsx("p",{className:"text-sm text-slate-600",children:(S==null?void 0:S.status)==="Verified"?`Verified on ${Yt(S.verifiedAt)}`:(S==null?void 0:S.status)==="Rejected"?"Payment Rejected":"Awaiting Verification"})]})]}),e.jsx(Ce,{className:zo((S==null?void 0:S.status)==="Verified"?"bg-green-600":(S==null?void 0:S.status)==="Rejected"?"bg-red-600":"bg-re-red text-white"),children:(S==null?void 0:S.status)||"No Record"})]})})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"flex items-center gap-2 text-xl",children:[e.jsx(Lr,{className:"w-5 h-5 text-re-red"}),"Applicant Information"]})}),e.jsxs(Fe,{className:"grid grid-cols-2 gap-y-4 gap-x-8",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Application ID"}),e.jsx("p",{className:"text-slate-900 font-medium",children:n.applicationId||n.id})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Applicant Name"}),e.jsx("p",{className:"text-slate-900 font-medium",children:n.applicantName})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Location"}),e.jsxs("p",{className:"text-slate-900 font-medium",children:[n.city||n.preferredLocation,", ",n.state]})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Email / Phone"}),e.jsx("p",{className:"text-slate-700 text-sm",children:n.email}),e.jsx("p",{className:"text-slate-700 text-sm",children:n.phone})]})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"flex items-center gap-2 text-xl",children:[e.jsx(Wu,{className:"w-5 h-5 text-re-red"}),"Deposit Tracking"]})}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 bg-slate-50 rounded-lg border border-slate-200",children:[e.jsx(de,{className:"text-slate-500 block mb-1",children:"Expected Amount"}),e.jsxs("p",{className:"text-2xl font-bold text-red-900",children:["₹",(o==="SECURITY_DEPOSIT"?((E=x.SECURITY_DEPOSIT)==null?void 0:E.amount)||5e5:((q=x.FIRST_FILL)==null?void 0:q.amount)||15e5).toLocaleString()]})]}),e.jsxs("div",{className:zo("p-4 rounded-lg border",(S==null?void 0:S.status)==="Verified"?"bg-green-50 border-green-200":"bg-blue-50 border-blue-200"),children:[e.jsx(de,{className:"text-slate-500 block mb-1",children:"Receipt Status"}),e.jsx("p",{className:zo("text-2xl font-bold",(S==null?void 0:S.status)==="Verified"?"text-green-700":"text-blue-700"),children:(S==null?void 0:S.status)||"Not Started"})]})]}),(S==null?void 0:S.paymentReference)&&e.jsxs("div",{className:"grid grid-cols-2 gap-4 pt-2",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Payment Reference"}),e.jsx("p",{className:"text-slate-900 font-mono",children:S.paymentReference})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Verified By"}),e.jsx("p",{className:"text-slate-900",children:((O=S.verifier)==null?void 0:O.fullName)||"N/A"})]})]})]})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsxs(Je,{className:"flex items-center gap-2 text-xl",children:[e.jsx(Ns,{className:"w-5 h-5 text-re-red"}),"Verification Evidence"]}),e.jsx(Xt,{children:"Documents uploaded by the applicant for payment proof"})]}),e.jsx(Fe,{children:((D=n.uploadedDocuments)==null?void 0:D.filter(P=>{var L,$,Y,Z;return o==="SECURITY_DEPOSIT"?((L=P.documentType)==null?void 0:L.toLowerCase().includes("security"))&&(($=P.documentType)==null?void 0:$.toLowerCase().includes("deposit")):((Y=P.documentType)==null?void 0:Y.toLowerCase().includes("first"))&&((Z=P.documentType)==null?void 0:Z.toLowerCase().includes("fill"))}).length)>0?e.jsx("div",{className:"space-y-3",children:n.uploadedDocuments.filter(P=>{var L,$,Y,Z;return o==="SECURITY_DEPOSIT"?((L=P.documentType)==null?void 0:L.toLowerCase().includes("security"))&&(($=P.documentType)==null?void 0:$.toLowerCase().includes("deposit")):((Y=P.documentType)==null?void 0:Y.toLowerCase().includes("first"))&&((Z=P.documentType)==null?void 0:Z.toLowerCase().includes("fill"))}).map((P,L)=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-white rounded-lg border border-slate-200 hover:shadow-sm transition-shadow",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded bg-slate-100 flex items-center justify-center",children:e.jsx(Ns,{className:"w-5 h-5 text-slate-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 font-medium",children:P.fileName||P.name}),e.jsxs("p",{className:"text-xs text-slate-500 uppercase",children:[P.documentType," • ",Yt(P.createdAt)]})]})]}),e.jsx(se,{variant:"ghost",size:"sm",className:"text-re-red hover:text-re-red-hover hover:bg-red-50",onClick:()=>{C(P),j(!0)},children:"View Receipt"})]},L))}):e.jsxs("div",{className:"text-center py-10 bg-slate-50 rounded-lg border-2 border-dashed border-slate-200",children:[e.jsx(sn,{className:"w-8 h-8 text-slate-300 mx-auto mb-2"}),e.jsx("p",{className:"text-slate-500",children:"No payment documents found in this application."})]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Le,{className:"border-red-100 shadow-sm",children:[e.jsx(Qe,{className:"bg-red-50/50",children:e.jsxs(Je,{className:"flex items-center gap-2 text-lg",children:[e.jsx(lf,{className:"w-5 h-5 text-re-red"}),"Finance Action"]})}),e.jsxs(Fe,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsxs(de,{htmlFor:"verificationTxnId",className:"text-xs uppercase text-slate-500 font-bold tracking-wider",children:["UTR / Reference Number ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{id:"verificationTxnId",placeholder:"Enter Bank UTR Number",disabled:(S==null?void 0:S.status)==="Verified",className:"mt-1",value:N.verificationTransactionId,onChange:P=>v({...N,verificationTransactionId:P.target.value})})]}),e.jsxs("div",{children:[e.jsxs(de,{htmlFor:"receivedAmount",className:"text-xs uppercase text-slate-500 font-bold tracking-wider",children:["Amount Received (₹) ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{id:"receivedAmount",type:"number",placeholder:(o==="SECURITY_DEPOSIT"?5e5:15e5).toString(),disabled:(S==null?void 0:S.status)==="Verified",className:"mt-1",value:N.receivedAmount,onChange:P=>v({...N,receivedAmount:P.target.value})})]}),e.jsxs("div",{children:[e.jsxs(de,{htmlFor:"receivedDate",className:"text-xs uppercase text-slate-500 font-bold tracking-wider",children:["Credit Value Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{id:"receivedDate",type:"date",disabled:(S==null?void 0:S.status)==="Verified",className:"mt-1",value:N.receivedDate,onChange:P=>v({...N,receivedDate:P.target.value})})]}),e.jsxs("div",{children:[e.jsx(de,{htmlFor:"remarks",className:"text-xs uppercase text-slate-500 font-bold tracking-wider",children:"Verification Remarks"}),e.jsx(Ws,{id:"remarks",placeholder:"Any internal notes for reconciliation...",rows:3,className:"mt-1",value:N.verificationRemarks,onChange:P=>v({...N,verificationRemarks:P.target.value})})]}),e.jsxs("div",{className:"pt-4 space-y-3",children:[e.jsx(se,{className:zo("w-full transition-all duration-200",(S==null?void 0:S.status)==="Verified"?"bg-green-600 hover:bg-green-600 opacity-90":"bg-re-red hover:bg-re-red-hover"),onClick:_,disabled:p||(S==null?void 0:S.status)==="Verified",children:(S==null?void 0:S.status)==="Verified"?e.jsxs(e.Fragment,{children:[e.jsx(un,{className:"w-4 h-4 mr-2"})," Verified Successfully"]}):e.jsxs(e.Fragment,{children:[e.jsx(un,{className:"w-4 h-4 mr-2"})," Mark as Verified"]})}),(S==null?void 0:S.status)!=="Verified"&&(S==null?void 0:S.status)!=="Rejected"&&e.jsxs(se,{variant:"ghost",className:"w-full text-red-600 hover:text-red-700 hover:bg-red-50",onClick:A,disabled:p,children:[e.jsx(mi,{className:"w-4 h-4 mr-2"}),"Reject / Flag Discrepancy"]})]})]})]}),e.jsxs(Le,{className:"bg-slate-900 text-white border-none shadow-xl",children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(vn,{className:"w-4 h-4 text-re-red"}),"Next Steps"]})}),e.jsxs(Fe,{className:"text-xs text-slate-300 space-y-3",children:[e.jsx("p",{children:"Once verified, the following will occur:"}),e.jsxs("ul",{className:"list-disc pl-4 space-y-2",children:[e.jsxs("li",{children:["Applicant status will advance to ",o==="SECURITY_DEPOSIT"?"LOI Issuance":"LOA Approval"]}),e.jsx("li",{children:"Email notification will be sent to Applicant"}),e.jsxs("li",{children:["Digital ",o==="SECURITY_DEPOSIT"?"LOI":"LOA"," generation will be unlocked"]}),e.jsxs("li",{children:["This payment confirms the ",o==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"]})]})]})]})]})]}),e.jsx(mo,{isOpen:w,onClose:()=>j(!1),document:b})]}):e.jsx("div",{className:"p-20 text-center",children:"Application not found"})}const ll=["Warranty Department","Accessories Department","Sales Department","RTO Department","Service Department","Parts Department","Finance Department","Insurance Department","Inventory Department","Marketing Department","HR Department","IT Department","Legal Department","Quality Department","Logistics Department","Customer Relations Department"],IS="[DEPARTMENT_CLAIM]",MS="[FINANCE_VALIDATED]",Yg=[{id:"calculations",label:"Verified All Department Calculations"},{id:"bank",label:"Confirmed Bank Account Details"},{id:"docs",label:"Reviewed All Supporting Documents"},{id:"sap",label:"Synced Final Dues with SAP"},{id:"noc",label:"Received All Mandatory NOCs"}];function RV({fnfId:t,onBack:s}){const n=tr(),[r,a]=g.useState(null),[i,o]=g.useState(!0),[d,m]=g.useState("overview"),[f,p]=g.useState([]),[h,x]=g.useState([]),[u,N]=g.useState([]),[v,w]=g.useState(null),[j,b]=g.useState([]),[C,S]=g.useState(!1),[R,_]=g.useState(null),[A,E]=g.useState([]);g.useEffect(()=>{q(),Y()},[t]);const q=async()=>{var Q;try{const we=(await Ee.getSettlementDepartments()).data;we&&we.success&&((Q=we.departments)==null?void 0:Q.length)>0}catch(oe){console.error("Fetch departments error:",oe)}},O=Q=>{if(!Q)return Q;let oe=Q.trim();const we=ll.find(je=>je.toLowerCase()===oe.toLowerCase());if(we)return we;const ke={sales:"Sales Department",service:"Service Department",spares:"Parts Department",parts:"Parts Department","spares / parts":"Parts Department",finance:"Finance Department",accounts:"Finance Department",warranty:"Warranty Department",marketing:"Marketing Department",hr:"HR Department",it:"IT Department",legal:"Legal Department",logistics:"Logistics Department",quality:"Quality Department",fdd:"Finance Department",apparel:"Accessories Department",accessories:"Accessories Department",dms:"IT Department",rto:"Admin Department",admin:"Admin Department","admin / dd-admin":"Admin Department"}[oe.toLowerCase().replace(" department","")];return ke||Q},D=(Q,oe)=>oe==="DepartmentClaim"||typeof Q=="string"&&(Q.startsWith(IS)||Q.includes("Clearance:")),P=Q=>(Q==null?void 0:Q.sourceType)==="FinanceValidated"&&typeof(Q==null?void 0:Q.description)=="string"&&Q.description.includes("Auto-seeded from department claim"),L=(Q,oe)=>oe==="FinanceValidated"||typeof Q=="string"&&Q.startsWith(MS),$=Q=>(Q||"").replace(IS,"").replace(MS,"").trim(),Y=async(Q=!0)=>{var oe,we,Oe,ke,je,Ve,Ge,nt,Zt,Jt,lt,mt,Ds,ss,Ae,be,ut,He,yt,ft,es,ts,Cs,Us,rn,Js,an,hn,De,bt,Te,ct,tt,jt,Ht,zt,fs,qt,As,vs,cs,mn,qs,ln,fn,on,Ye;try{Q&&o(!0);const St=(await Ee.getFnFSettlementById(t)).data;if(St.success){const rt=St.fnf,Ft={id:rt.id,caseNumber:rt.settlementId||((oe=rt.resignation)==null?void 0:oe.resignationId)||((we=rt.terminationRequest)==null?void 0:we.requestId)||rt.id.substring(0,8),dealerName:((ke=(Oe=rt.outlet)==null?void 0:Oe.dealer)==null?void 0:ke.fullName)||((je=rt.dealer)==null?void 0:je.fullName)||"N/A",dealerCode:((Ve=rt.outlet)==null?void 0:Ve.code)||((nt=(Ge=rt.dealer)==null?void 0:Ge.dealerCode)==null?void 0:nt.dealerCode)||"N/A",location:((Zt=rt.outlet)==null?void 0:Zt.city)||((Jt=rt.outlet)==null?void 0:Jt.location)||"N/A",terminationType:rt.resignationId?"Resignation":"Termination",submittedDate:ua(rt.createdAt),createdAt:rt.createdAt,dueDate:rt.settlementDate?ua(rt.settlementDate):"TBD",status:rt.status,dealerId:((mt=(lt=rt.outlet)==null?void 0:lt.dealer)==null?void 0:mt.id)||rt.dealerId,originalRequestId:((Ds=rt.resignation)==null?void 0:Ds.resignationId)||((ss=rt.terminationRequest)==null?void 0:ss.requestId)||((Ae=rt.terminationRequest)==null?void 0:Ae.id)||"N/A",salesCode:((ut=(be=rt.dealer)==null?void 0:be.dealerCode)==null?void 0:ut.salesCode)||((es=(ft=(yt=(He=rt.outlet)==null?void 0:He.dealer)==null?void 0:yt.dealerProfile)==null?void 0:ft.dealerCode)==null?void 0:es.salesCode)||"N/A",serviceCode:((Cs=(ts=rt.dealer)==null?void 0:ts.dealerCode)==null?void 0:Cs.serviceCode)||((an=(Js=(rn=(Us=rt.outlet)==null?void 0:Us.dealer)==null?void 0:rn.dealerProfile)==null?void 0:Js.dealerCode)==null?void 0:an.serviceCode)||"N/A",gearCode:((De=(hn=rt.dealer)==null?void 0:hn.dealerCode)==null?void 0:De.gearCode)||((tt=(ct=(Te=(bt=rt.outlet)==null?void 0:bt.dealer)==null?void 0:Te.dealerProfile)==null?void 0:ct.dealerCode)==null?void 0:tt.gearCode)||"N/A",gmaCode:((Ht=(jt=rt.dealer)==null?void 0:jt.dealerCode)==null?void 0:Ht.gmaCode)||((As=(qt=(fs=(zt=rt.outlet)==null?void 0:zt.dealer)==null?void 0:fs.dealerProfile)==null?void 0:qt.dealerCode)==null?void 0:As.gmaCode)||"N/A",allLineItems:(rt.lineItems||[]).filter(Ls=>Ls.isActive!==!1),departmentResponses:ll.map(Ls=>{const nn=(rt.clearances||[]).find(_n=>O(_n.department)===Ls),ta=(rt.lineItems||[]).filter(_n=>_n.isActive!==!1),sa=ta.filter(_n=>O(_n.department)===Ls&&D(_n.description,_n.sourceType)),na=ta.filter(_n=>O(_n.department)===Ls&&P(_n)),Ir=sa.length>0?sa:na;let Xn=0,zn=0;Ir.forEach(_n=>{const ur=Math.abs(parseFloat(_n.amount)||0);_n.itemType==="Payable"?Xn+=ur:zn+=ur});const Qt=Xn-zn,Jn=Math.abs(Qt)>0,Rr=(nn==null?void 0:nn.status)||"Pending",Wn=Jn?"Dues Pending":Rr==="Cleared"?"NOC Submitted":Rr,Er=Qt>0?"payable":Qt<0?"recovery":null;return{id:(nn==null?void 0:nn.id)||`dept-${Ls}`,departmentName:Ls,status:Wn,remarks:(nn==null?void 0:nn.remarks)||"-",submittedDate:nn!=null&&nn.clearedAt?ua(nn.clearedAt):"-",amount:Math.abs(Qt),duesFlow:Er,amountType:Qt>0?"Payable to dealer":Qt<0?"Receivable from dealer":null,supportingDocument:(nn==null?void 0:nn.supportingDocument)||null}}),documents:[{name:"Resignation Letter.pdf",size:"N/A",uploadedOn:ua(rt.createdAt),type:"Resignation",url:"#"},...(rt.clearances||[]).filter(Ls=>Ls.supportingDocument).map(Ls=>({name:Ls.supportingDocument.split("/").pop(),size:"N/A",uploadedOn:ua(Ls.clearedAt),type:`${Ls.department} Proof`,url:Ls.supportingDocument})),...(rt.clearanceDocuments||[]).map(Ls=>{var nn;return{name:Ls.name||((nn=Ls.supportingDocument)==null?void 0:nn.split("/").pop())||"Document",size:"N/A",uploadedOn:ua(Ls.clearedAt||rt.createdAt),type:"Finance Upload",url:Ls.supportingDocument}})]};a(Ft);const jn=rt.bankDetails||((vs=rt.dealer)==null?void 0:vs.bankDetails)||((qs=(mn=(cs=rt.outlet)==null?void 0:cs.dealer)==null?void 0:mn.dealerProfile)==null?void 0:qs.bankDetails);jn&&jn.length>0?b(jn):((fn=(ln=rt.outlet)==null?void 0:ln.dealer)!=null&&fn.id||rt.dealerId)&&Z(((Ye=(on=rt.outlet)==null?void 0:on.dealer)==null?void 0:Ye.id)||rt.dealerId);const xn=[],qn=[],En=[],Hs=(rt.lineItems||[]).filter(Ls=>Ls.isActive!==!1);(Hs.some(Ls=>L(Ls.description,Ls.sourceType))?Hs.filter(Ls=>L(Ls.description,Ls.sourceType)):Hs.filter(Ls=>!D(Ls.description,Ls.sourceType))).forEach(Ls=>{const nn={id:Ls.id,department:O(Ls.department),description:$(Ls.description||Ls.remarks||""),amount:Math.abs(Ls.amount)};Ls.itemType==="Payable"?xn.push(nn):Ls.itemType==="Deduction"?En.push(nn):qn.push(nn)}),p(xn),x(qn),N(En),$e({verificationTransactionId:rt.transactionReference||"",settlementAmount:(rt.settlementAmount||ee().settlementAmount).toString(),settlementDate:rt.settlementDate?new Date(rt.settlementDate).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],paymentMode:rt.paymentMode||"",bankReference:"",verificationRemarks:rt.remarks||"",adjustments:"0"})}}catch(Ot){console.error("Fetch F&F error:",Ot),te.error("Failed to fetch settlement details")}finally{Q&&o(!1)}},Z=async Q=>{try{const we=(await Ee.getDealerBankDetails(Q)).data;we.success&&b(we.bankDetails||[])}catch(oe){console.error("Fetch bank details error:",oe)}},W=async Q=>{Q.preventDefault();const oe=new FormData(Q.currentTarget),we=Object.fromEntries(oe.entries());try{const Oe=r==null?void 0:r.dealerId;(await Ee.saveBankDetail(Oe,{...we,id:R==null?void 0:R.id,isPrimary:oe.get("isPrimary")==="on"})).data.success&&(te.success("Bank details saved"),Z(Oe),S(!1),_(null))}catch{te.error("Failed to save bank details")}},U=async Q=>{if(confirm("Are you sure you want to delete this bank account?"))try{(await Ee.deleteBankDetail(Q)).data.success&&(te.success("Bank detail deleted"),Z(r==null?void 0:r.dealerId))}catch{te.error("Failed to delete bank details")}},M=Q=>{E(oe=>oe.includes(Q)?oe.filter(we=>we!==Q):[...oe,Q])},[z,T]=g.useState({department:"",description:"",amount:""}),[I,B]=g.useState({department:"",description:"",amount:""}),[G,K]=g.useState({department:"",description:"",amount:""}),[H,X]=g.useState(null),[J,ae]=g.useState(null),[le,xe]=g.useState(null),[ce,ve]=g.useState({}),[Pe,et]=g.useState({}),[kt,vt]=g.useState({}),ee=()=>{const Q=f.reduce((ke,je)=>ke+(Number(je.amount)||0),0),oe=h.reduce((ke,je)=>ke+(Number(je.amount)||0),0),we=u.reduce((ke,je)=>ke+(Number(je.amount)||0),0),Oe=Q-oe-we;return{payables:Q,receivables:oe,deductions:we,netSettlement:Oe,settlementAmount:Math.abs(Oe),settlementType:Oe>0?"Payable to Dealer":Oe<0?"Receivable from Dealer":"No Settlement Required"}},ge=ee(),ye=ll.map(Q=>{const oe=((r==null?void 0:r.departmentResponses)||[]).find(lt=>lt.departmentName===Q),we=Number(oe==null?void 0:oe.amount)||0,Oe=(oe==null?void 0:oe.amountType)||"-",ke=f.filter(lt=>O(lt.department)===Q).reduce((lt,mt)=>lt+(Number(mt.amount)||0),0),je=h.filter(lt=>O(lt.department)===Q).reduce((lt,mt)=>lt+(Number(mt.amount)||0),0),Ve=u.filter(lt=>O(lt.department)===Q).reduce((lt,mt)=>lt+(Number(mt.amount)||0),0),Ge=ke-je-Ve,nt=Math.abs(Ge),Zt=Ge>0?"Payable":Ge<0?"Receivable":"-",Jt=nt-we;return{department:Q,claimAmount:we,claimType:Oe,validatedAmount:nt,validatedType:Zt,variance:Jt}}),[Be,$e]=g.useState({verificationTransactionId:"",settlementAmount:ge.settlementAmount.toString(),settlementDate:new Date().toISOString().split("T")[0],paymentMode:"",bankReference:"",verificationRemarks:"",adjustments:"0"}),dt=async()=>{var Q,oe;if(!z.department||!z.description||!z.amount){te.error("Please fill in all fields");return}try{const Oe=(await Ee.addLineItem(t,{department:z.department,description:z.description,amount:Math.abs(parseFloat(z.amount)),itemType:"Payable"})).data;Oe.success&&(p([...f,{id:Oe.lineItem.id,department:Oe.lineItem.department,description:Oe.lineItem.description,amount:Math.abs(Oe.lineItem.amount)}]),T({department:"",description:"",amount:""}),te.success("Payable item added"),Y())}catch(we){te.error(((oe=(Q=we.response)==null?void 0:Q.data)==null?void 0:oe.message)||"Failed to add payable item")}},st=async(Q,oe,we)=>{ve(Oe=>{const ke=Oe[Q]||f.find(je=>je.id===Q);return ke?{...Oe,[Q]:{...ke,[oe]:oe==="amount"?Number(we)||0:we}}:Oe})},xt=async Q=>{var we,Oe;const oe=ce[Q];if(!oe){X(null);return}p(ke=>ke.map(je=>je.id===Q?oe:je));try{await Ee.updateLineItem(Q,{department:oe.department,description:oe.description,amount:-Math.abs(Number(oe.amount)||0)}),X(null),ve(ke=>{const je={...ke};return delete je[Q],je}),te.success("Changes saved"),Y(!1)}catch(ke){te.error(((Oe=(we=ke.response)==null?void 0:we.data)==null?void 0:Oe.message)||"Failed to update item"),Y(!1)}},Mt=async Q=>{var oe,we;try{(await Ee.deleteLineItem(Q)).data.success&&(p(f.filter(je=>je.id!==Q)),te.info("Payable item removed"),Y())}catch(Oe){te.error(((we=(oe=Oe.response)==null?void 0:oe.data)==null?void 0:we.message)||"Failed to delete item")}},It=async()=>{var Q,oe;if(!I.department||!I.description||!I.amount){te.error("Please fill in all fields");return}try{const Oe=(await Ee.addLineItem(t,{department:I.department,description:I.description,amount:Math.abs(parseFloat(I.amount)),itemType:"Receivable"})).data;Oe.success&&(x([...h,{id:Oe.lineItem.id,department:Oe.lineItem.department,description:Oe.lineItem.description,amount:Oe.lineItem.amount}]),B({department:"",description:"",amount:""}),te.success("Receivable item added"),Y())}catch(we){te.error(((oe=(Q=we.response)==null?void 0:Q.data)==null?void 0:oe.message)||"Failed to add receivable item")}},he=async(Q,oe,we)=>{et(Oe=>{const ke=Oe[Q]||h.find(je=>je.id===Q);return ke?{...Oe,[Q]:{...ke,[oe]:oe==="amount"?Number(we)||0:we}}:Oe})},pt=async Q=>{var we,Oe;const oe=Pe[Q];if(!oe){ae(null);return}x(ke=>ke.map(je=>je.id===Q?oe:je));try{await Ee.updateLineItem(Q,{department:oe.department,description:oe.description,amount:Math.abs(Number(oe.amount)||0)}),ae(null),et(ke=>{const je={...ke};return delete je[Q],je}),te.success("Changes saved"),Y(!1)}catch(ke){te.error(((Oe=(we=ke.response)==null?void 0:we.data)==null?void 0:Oe.message)||"Failed to update item"),Y(!1)}},ht=async Q=>{var oe,we;try{await Ee.deleteLineItem(Q),x(h.filter(Oe=>Oe.id!==Q)),te.info("Receivable item removed"),Y()}catch(Oe){te.error(((we=(oe=Oe.response)==null?void 0:oe.data)==null?void 0:we.message)||"Failed to delete item")}},_e=async()=>{var Q,oe;if(!G.department||!G.description||!G.amount){te.error("Please fill in all fields");return}try{const Oe=(await Ee.addLineItem(t,{department:G.department,description:G.description,amount:Math.abs(parseFloat(G.amount)),itemType:"Deduction"})).data;Oe.success&&(N([...u,{id:Oe.lineItem.id,department:Oe.lineItem.department,description:Oe.lineItem.description,amount:Oe.lineItem.amount}]),K({department:"",description:"",amount:""}),te.success("Deduction item added"),Y())}catch(we){te.error(((oe=(Q=we.response)==null?void 0:Q.data)==null?void 0:oe.message)||"Failed to add deduction item")}},Vt=async(Q,oe,we)=>{vt(Oe=>{const ke=Oe[Q]||u.find(je=>je.id===Q);return ke?{...Oe,[Q]:{...ke,[oe]:oe==="amount"?Number(we)||0:we}}:Oe})},Pt=async Q=>{var we,Oe;const oe=kt[Q];if(!oe){xe(null);return}N(ke=>ke.map(je=>je.id===Q?oe:je));try{await Ee.updateLineItem(Q,{department:oe.department,description:oe.description,amount:Math.abs(Number(oe.amount)||0)}),xe(null),vt(ke=>{const je={...ke};return delete je[Q],je}),te.success("Changes saved"),Y(!1)}catch(ke){te.error(((Oe=(we=ke.response)==null?void 0:we.data)==null?void 0:Oe.message)||"Failed to update item"),Y(!1)}},_s=async Q=>{try{await Ee.deleteLineItem(Q),N(u.filter(oe=>oe.id!==Q)),te.info("Deduction item removed"),Y()}catch{te.error("Failed to delete item")}},Ys=async Q=>{var we;const oe=Q.target.files;if(oe&&oe.length>0){o(!0);try{let Oe=0;for(let ke=0;ke<oe.length;ke++){const je=new FormData;je.append("file",oe[ke]),(we=(await Ee.uploadFnFDocument(t,je)).data)!=null&&we.success&&Oe++}te.success(`${Oe} document(s) uploaded successfully`),Y(!1)}catch{te.error("Failed to upload document(s)")}finally{o(!1)}}},[Bs,Ks]=g.useState(!1),Qs=async()=>{if(!Be.verificationTransactionId||!Be.settlementDate||!Be.paymentMode){te.error("Please fill in all required settlement details");return}try{Ks(!0);const Q=(ge.settlementAmount||0)+parseFloat(Be.adjustments||"0");await EE.updateFnF(t,{status:"Completed",finalSettlementAmount:Q,settlementDate:Be.settlementDate,paymentMode:Be.paymentMode,transactionReference:Be.verificationTransactionId,remarks:Be.verificationRemarks||"Approved by Finance"}),te.success(`F&F Settlement approved and completed for ${r.dealerName}`),setTimeout(()=>s(),1500)}catch(Q){console.error("Approve settlement error:",Q),te.error(Q.message||"Failed to approve settlement")}finally{Ks(!1)}},Xs=()=>{if(!Be.verificationRemarks){te.error("Please provide remarks for rejection");return}te.error(`F&F Settlement rejected for ${r.dealerName}`),setTimeout(()=>s(),1500)},$s=()=>{if(!Be.verificationRemarks){te.error("Please provide details for clarification request");return}te.info(`Clarification request sent for ${r.dealerName}`),setTimeout(()=>s(),1500)};return i?e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(ns,{className:"w-8 h-8 animate-spin text-re-red"})}):r?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(se,{variant:"outline",size:"icon",onClick:s,children:e.jsx(Jr,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl mb-1",children:"F&F Settlement Review"}),e.jsxs("p",{className:"text-slate-600",children:["Full & Final Settlement for ",r.dealerName]})]})]}),e.jsxs(se,{variant:"outline",onClick:()=>n(`/worknotes/fnf/${t}`,{state:{applicationName:r.dealerName||"F&F Settlement",registrationNumber:r.caseNumber||r.settlementId||"",participants:r.participants||[]}}),children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"View Work Notes"]})]}),e.jsx(Le,{className:"border-red-200 bg-red-50",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-12 shrink-0 aspect-square rounded-full bg-red-50 flex items-center justify-center",children:e.jsx(ka,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900",children:"Settlement Pending Finance Approval"}),e.jsxs("p",{className:"text-sm text-slate-600",children:["Case: ",r.caseNumber," • Due: ",r.dueDate]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ce,{className:"bg-re-red",children:r.status}),e.jsx(Ce,{variant:r.terminationType==="Resignation"?"default":"secondary",children:r.terminationType})]})]})})}),e.jsx(Le,{className:`${ge.settlementType==="Payable to Dealer"?"border-red-300 bg-red-50":ge.settlementType==="Receivable from Dealer"?"border-green-300 bg-green-50":"border-slate-300 bg-slate-50"}`,children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[ge.settlementType==="Payable to Dealer"?e.jsx(Yo,{className:"w-12 h-12 text-red-600"}):ge.settlementType==="Receivable from Dealer"?e.jsx(dl,{className:"w-12 h-12 text-green-600"}):e.jsx(un,{className:"w-12 h-12 text-slate-600"}),e.jsxs("div",{children:[e.jsx("p",{className:`text-sm ${ge.settlementType==="Payable to Dealer"?"text-red-700":ge.settlementType==="Receivable from Dealer"?"text-green-700":"text-slate-700"}`,children:ge.settlementType}),e.jsx("p",{className:"text-3xl text-slate-900",children:ge.settlementType==="No Settlement Required"?"₹0":`₹${ge.settlementAmount.toLocaleString("en-IN")}`})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-slate-600",children:"Net Settlement Amount"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:ge.settlementType==="Payable to Dealer"?"Company will pay to dealer":ge.settlementType==="Receivable from Dealer"?"Dealer must pay to company":"No payment required"})]})]})})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx("div",{className:"lg:col-span-2 space-y-6",children:e.jsxs(Bn,{value:d,onValueChange:m,className:"w-full",children:[e.jsxs($n,{className:"grid w-full grid-cols-5",children:[e.jsx(Wt,{value:"overview",children:"Overview"}),e.jsx(Wt,{value:"financial",children:"Financial"}),e.jsx(Wt,{value:"departments",children:"Departments"}),e.jsx(Wt,{value:"documents",children:"Documents"}),e.jsx(Wt,{value:"bank",children:"Bank Details"})]}),e.jsxs(Ut,{value:"overview",className:"space-y-4",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"flex items-center gap-2",children:[e.jsx(Lr,{className:"w-5 h-5"}),"Case Information"]})}),e.jsx(Fe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Case Number"}),e.jsx("p",{className:"text-slate-900",children:r.caseNumber})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Dealer Code"}),e.jsx("p",{className:"text-slate-900",children:r.dealerCode})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Dealer Name"}),e.jsx("p",{className:"text-slate-900",children:r.dealerName})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Location"}),e.jsx("p",{className:"text-slate-900",children:r.location})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Termination Type"}),e.jsx(Ce,{variant:r.terminationType==="Resignation"?"default":"secondary",children:r.terminationType})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Status"}),e.jsx(Ce,{className:"bg-re-red",children:r.status})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Submitted Date"}),e.jsx("p",{className:"text-slate-900",children:r.submittedDate})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Due Date"}),e.jsx("p",{className:"text-slate-900",children:r.dueDate})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Request Age"}),e.jsx("p",{className:"text-slate-900",children:(()=>{const Q=new Date(r.createdAt),we=Math.abs(new Date().getTime()-Q.getTime()),Oe=Math.ceil(we/(1e3*60*60*24));return`${Oe} day${Oe!==1?"s":""}`})()})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Sales Code"}),e.jsx("p",{className:"text-slate-900",children:r.salesCode})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Service Code"}),e.jsx("p",{className:"text-slate-900",children:r.serviceCode})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Gear Code"}),e.jsx("p",{className:"text-slate-900",children:r.gearCode})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"GMA Code"}),e.jsx("p",{className:"text-slate-900",children:r.gmaCode})]})]})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"w-5 h-5"}),"Settlement Calculation Summary"]})}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center p-3 bg-green-50 rounded-lg",children:[e.jsx("span",{className:"text-slate-900",children:"Total Payables (to Dealer)"}),e.jsxs("span",{className:"text-green-700 text-lg",children:["+ ₹",ge.payables.toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-red-50 rounded-lg",children:[e.jsx("span",{className:"text-slate-900",children:"Total Receivables (from Dealer)"}),e.jsxs("span",{className:"text-red-700 text-lg",children:["- ₹",ge.receivables.toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-red-50 rounded-lg",children:[e.jsx("span",{className:"text-slate-900",children:"Total Deductions"}),e.jsxs("span",{className:"text-re-red-hover text-lg",children:["- ₹",ge.deductions.toLocaleString("en-IN")]})]})]}),e.jsx("div",{className:"h-px bg-slate-300"}),e.jsx("div",{className:`p-4 rounded-lg border-2 ${ge.settlementType==="Payable to Dealer"?"bg-red-100 border-red-300":ge.settlementType==="Receivable from Dealer"?"bg-green-100 border-green-300":"bg-slate-100 border-slate-300"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-900",children:"Net Settlement"}),e.jsx("p",{className:`text-sm ${ge.settlementType==="Payable to Dealer"?"text-red-700":ge.settlementType==="Receivable from Dealer"?"text-green-700":"text-slate-700"}`,children:ge.settlementType})]}),e.jsx("span",{className:"text-2xl text-slate-900",children:ge.settlementType==="No Settlement Required"?"₹0":`₹${ge.settlementAmount.toLocaleString("en-IN")}`})]})}),e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-blue-50 border border-red-200 rounded-lg",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-900 mb-1",children:"Calculation Formula"}),e.jsxs("p",{className:"text-sm text-slate-600",children:["Net Settlement = Payables - Receivables - Deductions",e.jsx("br",{}),e.jsx("span",{className:"text-xs",children:"All amounts are editable in the Financial tab"})]})]})]})]})]})]}),e.jsxs(Ut,{value:"financial",className:"space-y-4",children:[e.jsxs(Le,{className:"border-blue-200 bg-blue-50",children:[e.jsxs(Qe,{children:[e.jsx(Je,{className:"text-base",children:"Department Claim vs Finance Validation"}),e.jsx(Xt,{children:"Finance validated values are used for final settlement totals."})]}),e.jsx(Fe,{children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Department"}),e.jsx(fe,{children:"Department Claim"}),e.jsx(fe,{children:"Finance Validated"}),e.jsx(fe,{children:"Variance"})]})}),e.jsx(Os,{children:ye.map(Q=>e.jsxs(it,{children:[e.jsx(ue,{children:Q.department}),e.jsx(ue,{children:Q.claimAmount>0?`${Q.claimType} ₹${Q.claimAmount.toLocaleString("en-IN")}`:"-"}),e.jsx(ue,{children:Q.validatedAmount>0?`${Q.validatedType} ₹${Q.validatedAmount.toLocaleString("en-IN")}`:"-"}),e.jsx(ue,{className:Q.variance===0?"text-slate-600":Q.variance>0?"text-red-600":"text-green-600",children:Q.claimAmount===0&&Q.validatedAmount===0?"-":`₹${Q.variance.toLocaleString("en-IN")}`})]},Q.department))})]})})]}),e.jsxs(Le,{className:"border-green-200 bg-green-50",children:[e.jsx(Qe,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs(Je,{className:"text-base flex items-center gap-2",children:[e.jsx(lf,{className:"w-5 h-5 text-green-600"}),"Payables to Dealer (Editable)"]}),e.jsx(Xt,{children:"Add or modify amounts company owes to dealer"})]})})}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Department"}),e.jsx(fe,{children:"Description"}),e.jsx(fe,{className:"text-right",children:"Amount (₹)"}),e.jsx(fe,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Os,{children:f.map(Q=>{var oe,we,Oe;return e.jsxs(it,{children:[e.jsx(ue,{children:H===Q.id?e.jsxs(Dt,{value:((oe=ce[Q.id])==null?void 0:oe.department)||Q.department,onValueChange:ke=>st(Q.id,"department",ke),children:[e.jsx(Et,{className:"h-8",children:e.jsx(Rt,{placeholder:"Department"})}),e.jsx(_t,{children:ll.map(ke=>e.jsx(Me,{value:ke,children:ke},ke))})]}):e.jsx("span",{className:"text-slate-900",children:O(Q.department)})}),e.jsx(ue,{children:H===Q.id?e.jsx(at,{value:((we=ce[Q.id])==null?void 0:we.description)||Q.description,onChange:ke=>st(Q.id,"description",ke.target.value),className:"h-8"}):e.jsx("span",{className:"text-slate-600",children:Q.description})}),e.jsx(ue,{className:"text-right",children:H===Q.id?e.jsx(at,{type:"number",value:((Oe=ce[Q.id])==null?void 0:Oe.amount)??Q.amount,onChange:ke=>st(Q.id,"amount",ke.target.value),className:"h-8 text-right"}):e.jsxs("span",{className:"text-slate-900",children:["₹",Q.amount.toLocaleString("en-IN")]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex gap-1",children:[H===Q.id?e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>xt(Q.id),children:e.jsx(ml,{className:"w-4 h-4"})}):e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>{X(Q.id),ve(ke=>({...ke,[Q.id]:{...Q}}))},children:e.jsx(Cr,{className:"w-4 h-4"})}),e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8 text-red-600 hover:text-red-700",onClick:()=>Mt(Q.id),children:e.jsx(ar,{className:"w-4 h-4"})})]})})]},Q.id)})})]}),e.jsxs("div",{className:"border-t border-green-300 pt-4 space-y-3",children:[e.jsx("p",{className:"text-sm text-slate-700",children:"Add New Payable Item:"}),e.jsxs("div",{className:"grid grid-cols-12 gap-2",children:[e.jsxs(Dt,{value:z.department,onValueChange:Q=>T({...z,department:Q}),children:[e.jsx(Et,{className:"col-span-3",children:e.jsx(Rt,{placeholder:"Department"})}),e.jsx(_t,{children:ll.map(Q=>e.jsx(Me,{value:Q,children:Q},Q))})]}),e.jsx(at,{placeholder:"Description",value:z.description,onChange:Q=>T({...z,description:Q.target.value}),className:"col-span-5"}),e.jsx(at,{type:"number",placeholder:"Amount",value:z.amount,onChange:Q=>T({...z,amount:Q.target.value}),className:"col-span-3"}),e.jsx(se,{onClick:dt,className:"col-span-1 bg-green-600 hover:bg-green-700",children:e.jsx(An,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"pt-3 border-t-2 border-green-400",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-900",children:"Total Payables"}),e.jsxs("span",{className:"text-green-700 text-xl",children:["₹",ge.payables.toLocaleString("en-IN")]})]})})]})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50",children:[e.jsx(Qe,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs(Je,{className:"text-base flex items-center gap-2",children:[e.jsx(ay,{className:"w-5 h-5 text-red-600"}),"Receivables from Dealer (Editable)"]}),e.jsx(Xt,{children:"Add or modify amounts dealer owes to company"})]})})}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Department"}),e.jsx(fe,{children:"Description"}),e.jsx(fe,{className:"text-right",children:"Amount (₹)"}),e.jsx(fe,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Os,{children:h.map(Q=>{var oe,we,Oe;return e.jsxs(it,{children:[e.jsx(ue,{children:J===Q.id?e.jsxs(Dt,{value:((oe=Pe[Q.id])==null?void 0:oe.department)||Q.department,onValueChange:ke=>he(Q.id,"department",ke),children:[e.jsx(Et,{className:"h-8",children:e.jsx(Rt,{placeholder:"Department"})}),e.jsx(_t,{children:ll.map(ke=>e.jsx(Me,{value:ke,children:ke},ke))})]}):e.jsx("span",{className:"text-slate-900",children:O(Q.department)})}),e.jsx(ue,{children:J===Q.id?e.jsx(at,{value:((we=Pe[Q.id])==null?void 0:we.description)||Q.description,onChange:ke=>he(Q.id,"description",ke.target.value),className:"h-8"}):e.jsx("span",{className:"text-slate-600",children:Q.description})}),e.jsx(ue,{className:"text-right",children:J===Q.id?e.jsx(at,{type:"number",value:((Oe=Pe[Q.id])==null?void 0:Oe.amount)??Q.amount,onChange:ke=>he(Q.id,"amount",ke.target.value),className:"h-8 text-right"}):e.jsxs("span",{className:"text-slate-900",children:["₹",Q.amount.toLocaleString("en-IN")]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex gap-1",children:[J===Q.id?e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>pt(Q.id),children:e.jsx(ml,{className:"w-4 h-4"})}):e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>{ae(Q.id),et(ke=>({...ke,[Q.id]:{...Q}}))},children:e.jsx(Cr,{className:"w-4 h-4"})}),e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8 text-red-600 hover:text-red-700",onClick:()=>ht(Q.id),children:e.jsx(ar,{className:"w-4 h-4"})})]})})]},Q.id)})})]}),e.jsxs("div",{className:"border-t border-red-300 pt-4 space-y-3",children:[e.jsx("p",{className:"text-sm text-slate-700",children:"Add New Receivable Item:"}),e.jsxs("div",{className:"grid grid-cols-12 gap-2",children:[e.jsxs(Dt,{value:I.department,onValueChange:Q=>B({...I,department:Q}),children:[e.jsx(Et,{className:"col-span-3",children:e.jsx(Rt,{placeholder:"Department"})}),e.jsx(_t,{children:ll.map(Q=>e.jsx(Me,{value:Q,children:Q},Q))})]}),e.jsx(at,{placeholder:"Description",value:I.description,onChange:Q=>B({...I,description:Q.target.value}),className:"col-span-5"}),e.jsx(at,{type:"number",placeholder:"Amount",value:I.amount,onChange:Q=>B({...I,amount:Q.target.value}),className:"col-span-3"}),e.jsx(se,{onClick:It,className:"col-span-1 bg-red-600 hover:bg-red-700",children:e.jsx(An,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"pt-3 border-t-2 border-red-400",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-900",children:"Total Receivables"}),e.jsxs("span",{className:"text-red-700 text-xl",children:["₹",ge.receivables.toLocaleString("en-IN")]})]})})]})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50",children:[e.jsx(Qe,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs(Je,{className:"text-base flex items-center gap-2",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red"}),"Deductions (Editable)"]}),e.jsx(Xt,{children:"Add or modify pending claims and deductions"})]})})}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Department"}),e.jsx(fe,{children:"Description"}),e.jsx(fe,{className:"text-right",children:"Amount (₹)"}),e.jsx(fe,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Os,{children:u.map(Q=>{var oe,we,Oe;return e.jsxs(it,{children:[e.jsx(ue,{children:le===Q.id?e.jsxs(Dt,{value:((oe=kt[Q.id])==null?void 0:oe.department)||Q.department,onValueChange:ke=>Vt(Q.id,"department",ke),children:[e.jsx(Et,{className:"h-8",children:e.jsx(Rt,{placeholder:"Department"})}),e.jsx(_t,{children:ll.map(ke=>e.jsx(Me,{value:ke,children:ke},ke))})]}):e.jsx("span",{className:"text-slate-900",children:O(Q.department)})}),e.jsx(ue,{children:le===Q.id?e.jsx(at,{value:((we=kt[Q.id])==null?void 0:we.description)||Q.description,onChange:ke=>Vt(Q.id,"description",ke.target.value),className:"h-8"}):e.jsx("span",{className:"text-slate-600",children:Q.description})}),e.jsx(ue,{className:"text-right",children:le===Q.id?e.jsx(at,{type:"number",value:((Oe=kt[Q.id])==null?void 0:Oe.amount)??Q.amount,onChange:ke=>Vt(Q.id,"amount",ke.target.value),className:"h-8 text-right"}):e.jsxs("span",{className:"text-slate-900",children:["₹",Q.amount.toLocaleString("en-IN")]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex gap-1",children:[le===Q.id?e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Pt(Q.id),children:e.jsx(ml,{className:"w-4 h-4"})}):e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>{xe(Q.id),vt(ke=>({...ke,[Q.id]:{...Q}}))},children:e.jsx(Cr,{className:"w-4 h-4"})}),e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8 text-red-600 hover:text-red-700",onClick:()=>_s(Q.id),children:e.jsx(ar,{className:"w-4 h-4"})})]})})]},Q.id)})})]}),e.jsxs("div",{className:"border-t border-red-300 pt-4 space-y-3",children:[e.jsx("p",{className:"text-sm text-slate-700",children:"Add New Deduction Item:"}),e.jsxs("div",{className:"grid grid-cols-12 gap-2",children:[e.jsxs(Dt,{value:G.department,onValueChange:Q=>K({...G,department:Q}),children:[e.jsx(Et,{className:"col-span-3",children:e.jsx(Rt,{placeholder:"Department"})}),e.jsx(_t,{children:ll.map(Q=>e.jsx(Me,{value:Q,children:Q},Q))})]}),e.jsx(at,{placeholder:"Description",value:G.description,onChange:Q=>K({...G,description:Q.target.value}),className:"col-span-5"}),e.jsx(at,{type:"number",placeholder:"Amount",value:G.amount,onChange:Q=>K({...G,amount:Q.target.value}),className:"col-span-3"}),e.jsx(se,{onClick:_e,className:"col-span-1 bg-re-red hover:bg-re-red-hover",children:e.jsx(An,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"pt-3 border-t-2 border-red-300",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-900",children:"Total Deductions"}),e.jsxs("span",{className:"text-re-red-hover text-xl",children:["₹",ge.deductions.toLocaleString("en-IN")]})]})})]})]}),e.jsxs(Le,{className:"border-2 border-blue-300 bg-blue-50",children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"flex items-center gap-2",children:[e.jsx(un,{className:"w-5 h-5 text-re-red"}),"Final Settlement Summary"]})}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center p-3 bg-white rounded-lg",children:[e.jsx("span",{className:"text-slate-900",children:"Total Payables (to Dealer)"}),e.jsxs("span",{className:"text-green-700 text-lg",children:["+ ₹",ge.payables.toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-white rounded-lg",children:[e.jsx("span",{className:"text-slate-900",children:"Total Receivables (from Dealer)"}),e.jsxs("span",{className:"text-red-700 text-lg",children:["- ₹",ge.receivables.toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-white rounded-lg",children:[e.jsx("span",{className:"text-slate-900",children:"Total Deductions"}),e.jsxs("span",{className:"text-re-red-hover text-lg",children:["- ₹",ge.deductions.toLocaleString("en-IN")]})]})]}),e.jsx("div",{className:"h-px bg-blue-300"}),e.jsx("div",{className:`p-4 rounded-lg border-2 ${ge.settlementType==="Payable to Dealer"?"bg-red-100 border-red-400":ge.settlementType==="Receivable from Dealer"?"bg-green-100 border-green-400":"bg-slate-100 border-slate-400"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-600 mb-1",children:"Net Settlement"}),e.jsx("p",{className:`text-lg ${ge.settlementType==="Payable to Dealer"?"text-red-700":ge.settlementType==="Receivable from Dealer"?"text-green-700":"text-slate-700"}`,children:ge.settlementType})]}),e.jsx("span",{className:"text-3xl text-slate-900",children:ge.settlementType==="No Settlement Required"?"₹0":`₹${ge.settlementAmount.toLocaleString("en-IN")}`})]})}),e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-white border border-red-200 rounded-lg",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-900 mb-1",children:"Calculation Formula"}),e.jsxs("p",{className:"text-sm text-slate-600",children:["Net Settlement = Payables - Receivables - Deductions",e.jsx("br",{}),ge.netSettlement>0&&"Positive value means company pays to dealer",ge.netSettlement<0&&"Negative value means dealer pays to company",ge.netSettlement===0&&"Zero means no payment required from either party"]})]})]})]})]})]}),e.jsxs(Ut,{value:"departments",className:"space-y-4",children:[e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsxs(Je,{className:"flex items-center gap-2",children:[e.jsx(Ra,{className:"w-5 h-5"}),"Department Response Progress"]}),e.jsxs(Xt,{children:[r.departmentResponses.filter(Q=>Q.status!=="Pending").length," of ",r.departmentResponses.length," departments have responded"]})]}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsx(dc,{value:r.departmentResponses.filter(Q=>Q.status!=="Pending").length/r.departmentResponses.length*100,className:"h-3"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"p-4 bg-green-50 rounded-lg border border-green-200",children:[e.jsx("p",{className:"text-sm text-green-700 mb-1",children:"NOC Submitted"}),e.jsx("p",{className:"text-2xl text-green-600",children:r.departmentResponses.filter(Q=>Q.status==="NOC Submitted").length})]}),e.jsxs("div",{className:"p-4 bg-red-50 rounded-lg border border-red-200",children:[e.jsx("p",{className:"text-sm text-red-700 mb-1",children:"Dues Pending"}),e.jsx("p",{className:"text-2xl text-red-600",children:r.departmentResponses.filter(Q=>Q.status==="Dues Pending").length})]}),e.jsxs("div",{className:"p-4 bg-slate-50 rounded-lg border border-slate-200",children:[e.jsx("p",{className:"text-sm text-slate-700 mb-1",children:"Awaiting Response"}),e.jsx("p",{className:"text-2xl text-slate-600",children:r.departmentResponses.filter(Q=>Q.status==="Pending").length})]})]})]})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"All Department Responses"}),e.jsx(Xt,{children:"Status of NOC and dues clearance from all 16 departments (read-only for Finance; updates are done by department stakeholders)."})]}),e.jsx(Fe,{children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Department"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Amount Type"}),e.jsx(fe,{children:"Amount"}),e.jsx(fe,{children:"Submitted Date"}),e.jsx(fe,{children:"Remarks"})]})}),e.jsx(Os,{children:r.departmentResponses.map(Q=>e.jsxs(it,{className:Q.duesFlow==="recovery"?"bg-red-50/40":Q.duesFlow==="payable"?"bg-emerald-50/40":"",children:[e.jsx(ue,{children:Q.departmentName}),e.jsx(ue,{children:e.jsx(Ce,{className:`border ${Q.status==="NOC Submitted"?"bg-green-100 text-green-700 border-green-300":Q.status==="Dues Pending"?"bg-red-100 text-red-700 border-red-300":"bg-slate-100 text-slate-700 border-slate-300"}`,children:Q.status})}),e.jsx(ue,{children:Q.amountType?e.jsx(Ce,{variant:"outline",className:Q.duesFlow==="recovery"?"bg-red-100 text-red-900 border-red-400 font-semibold":Q.duesFlow==="payable"?"bg-emerald-100 text-emerald-900 border-emerald-400 font-semibold":"bg-slate-50 text-slate-700 border-slate-200",children:Q.amountType}):"-"}),e.jsx(ue,{children:Q.amount?e.jsxs("span",{className:`rounded-md px-2 py-0.5 font-semibold tabular-nums ${Q.duesFlow==="recovery"?"bg-red-100 text-red-800 ring-1 ring-red-300/70":Q.duesFlow==="payable"?"bg-emerald-100 text-emerald-800 ring-1 ring-emerald-300/70":"text-slate-700"}`,children:["₹",Q.amount.toLocaleString("en-IN")]}):"-"}),e.jsx(ue,{children:Q.submittedDate||"-"}),e.jsx(ue,{className:"max-w-xs truncate",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{children:Q.remarks||"-"}),Q.supportingDocument&&e.jsxs("button",{onClick:()=>w({fileName:`${Q.departmentName}_Proof`,filePath:Q.supportingDocument,documentType:"Departmental Clearance Proof"}),className:"flex items-center gap-1 text-[10px] text-re-red hover:underline",children:[e.jsx(bu,{className:"w-3 h-3"}),"View Proof"]})]})})]},Q.id))})]})})]}),e.jsx(Le,{className:"bg-blue-50 border-red-200",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-900 mb-1",children:"Department Response Guidelines"}),e.jsxs("ul",{className:"text-sm text-slate-700 space-y-1",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{children:"NOC Submitted:"})," Department has no outstanding dues and provided clearance"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Dues Pending:"})," Department has identified amounts to be recovered or paid"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Pending:"})," Department has not yet responded to the F&F request"]})]})]})]})})})]}),e.jsxs(Ut,{value:"documents",className:"space-y-4",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"w-5 h-5"}),"Submitted Documents"]})}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-2",children:r.documents.map((Q,oe)=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-slate-50 rounded-lg border border-slate-200",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ns,{className:"w-5 h-5 text-slate-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900",children:Q.name}),e.jsxs("p",{className:"text-sm text-slate-500",children:[Q.size," • ",Q.type," • Uploaded on ",Q.uploadedOn]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Q.url&&Q.url!=="#"&&e.jsxs("button",{onClick:()=>w({fileName:Q.name,filePath:Q.url,documentType:Q.type}),className:"text-re-red hover:text-re-red-hover text-[10px] font-semibold flex items-center gap-1",children:[e.jsx(bu,{className:"w-3 h-3"})," PREVIEW"]}),e.jsx(se,{variant:"outline",size:"sm",onClick:async()=>{if(Q.url&&Q.url!=="#")try{const Oe=await(await fetch(Q.url)).blob(),ke=window.URL.createObjectURL(Oe),je=document.createElement("a");je.href=ke,je.download=Q.name||"download",document.body.appendChild(je),je.click(),document.body.removeChild(je),window.URL.revokeObjectURL(ke)}catch{const Oe=document.createElement("a");Oe.href=Q.url,Oe.download=Q.name||"download",document.body.appendChild(Oe),Oe.click(),document.body.removeChild(Oe)}else te.error("Document URL not available")},children:"Download"})]})]},oe))})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsxs(Je,{className:"flex items-center gap-2",children:[e.jsx(or,{className:"w-5 h-5"}),"Upload Settlement Verification Documents"]}),e.jsx(Xt,{children:"Upload bank receipts, settlement proofs, or any additional documents"})]}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"border-2 border-dashed border-slate-300 rounded-lg p-8 text-center hover:border-red-300 hover:bg-red-50 transition-colors",children:[e.jsx(or,{className:"w-8 h-8 text-slate-400 mx-auto mb-2"}),e.jsx("p",{className:"text-slate-600 mb-2",children:"Click to upload or drag and drop"}),e.jsx("p",{className:"text-sm text-slate-500",children:"PDF, DOC, DOCX, PNG, JPG, XLSX (max 10MB)"}),e.jsx("input",{type:"file",multiple:!0,className:"hidden",id:"file-upload",onChange:Ys,accept:".pdf,.doc,.docx,.png,.jpg,.jpeg,.xlsx,.xls"}),e.jsx("label",{htmlFor:"file-upload",children:e.jsx(se,{variant:"outline",className:"mt-4",asChild:!0,children:e.jsx("span",{children:"Choose Files"})})})]})})})]})]}),e.jsx(Ut,{value:"bank",className:"space-y-4",children:e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Je,{className:"flex items-center gap-2",children:[e.jsx(id,{className:"w-5 h-5"}),"Dealer Bank Account Details"]}),e.jsx(Xt,{children:"Manage bank accounts for settlement transfer"})]}),e.jsxs(se,{size:"sm",className:"bg-re-red",onClick:()=>{_(null),S(!0)},children:[e.jsx(An,{className:"w-4 h-4 mr-2"}),"Add Bank Account"]})]}),e.jsx(Fe,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:j.length>0?j.map(Q=>e.jsxs(Le,{className:`relative ${Q.isPrimary?"border-re-red bg-blue-50/30":""}`,children:[Q.isPrimary&&e.jsx("div",{className:"absolute top-0 right-0 p-1 bg-re-red text-white text-[10px] uppercase font-bold px-2 rounded-bl",children:"Primary"}),e.jsx(Fe,{className:"p-4 pt-6",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Account Holder"}),e.jsx("p",{className:"text-sm font-semibold",children:Q.accountHolderName})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Bank"}),e.jsx("p",{className:"text-xs truncate",children:Q.bankName})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"IFSC"}),e.jsx("p",{className:"text-xs",children:Q.ifscCode})]})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Account Number"}),e.jsx("p",{className:"text-xs font-mono",children:Q.accountNumber})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-slate-100",children:[e.jsxs(se,{variant:"ghost",size:"sm",className:"h-7 text-[11px] text-re-red",onClick:()=>{_(Q),S(!0)},children:[e.jsx(Cr,{className:"w-3 h-3 mr-1"}),"Edit"]}),e.jsxs(se,{variant:"ghost",size:"sm",className:"h-7 text-[11px] text-red-600",onClick:()=>U(Q.id),children:[e.jsx(ar,{className:"w-3 h-3 mr-1"}),"Delete"]})]})]})})]},Q.id)):e.jsxs("div",{className:"col-span-full py-12 text-center border-2 border-dashed rounded-lg bg-slate-50",children:[e.jsx(id,{className:"w-12 h-12 text-slate-300 mx-auto mb-3"}),e.jsx("p",{className:"text-slate-600 text-sm",children:"No bank details found"})]})})})]})})]})}),e.jsx("div",{className:"space-y-6",children:e.jsxs(Le,{className:"sticky top-6",children:[e.jsxs(Qe,{children:[e.jsxs(Je,{className:"flex items-center gap-2",children:[e.jsx(Wu,{className:"w-5 h-5"}),"Settlement Verification"]}),e.jsx(Xt,{children:"Enter settlement transaction details"})]}),e.jsx(Fe,{className:"space-y-4",children:r.status==="Completed"?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-3 text-green-700 mb-2",children:[e.jsx(un,{className:"w-5 h-5"}),e.jsx("span",{className:"font-semibold",children:"Settlement Completed"})]}),e.jsx("p",{className:"text-sm text-green-600",children:"This settlement has been finalized and processed."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",children:[e.jsx("span",{className:"text-slate-500 text-sm",children:"Settlement Date"}),e.jsx("span",{className:"text-slate-900 font-medium",children:ua(Be.settlementDate)})]}),e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",children:[e.jsx("span",{className:"text-slate-500 text-sm",children:"Payment Mode"}),e.jsx("span",{className:"text-slate-900 font-medium",children:Be.paymentMode})]}),e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",children:[e.jsx("span",{className:"text-slate-500 text-sm",children:"Transaction ID"}),e.jsx("span",{className:"text-slate-900 font-medium truncate ml-4 max-w-[150px]",title:Be.verificationTransactionId,children:Be.verificationTransactionId})]}),e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",children:[e.jsx("span",{className:"text-slate-500 text-sm",children:"Final Amount"}),e.jsxs("span",{className:"text-slate-900 font-bold text-lg",children:["₹",parseFloat(Be.settlementAmount).toLocaleString()]})]})]}),Be.verificationRemarks&&e.jsxs("div",{className:"mt-4",children:[e.jsx(de,{className:"text-slate-500 mb-1 block",children:"Finance Remarks"}),e.jsx("div",{className:"p-3 bg-slate-50 rounded border text-sm text-slate-700",children:Be.verificationRemarks})]}),e.jsxs(se,{variant:"outline",className:"w-full mt-4",onClick:()=>window.print(),children:[e.jsx(FI,{className:"w-4 h-4 mr-2"}),"Download Settlement Letter"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-lg p-4 mb-4",children:[e.jsxs("p",{className:"text-sm font-bold text-slate-900 mb-3 flex items-center gap-2",children:[e.jsx(un,{className:"w-4 h-4 text-re-red"}),"Compliance Checklist"]}),e.jsx("div",{className:"space-y-3",children:Yg.map(Q=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("input",{type:"checkbox",id:`check-${Q.id}`,checked:A.includes(Q.id),onChange:()=>M(Q.id),className:"w-4 h-4 mt-1 rounded border-slate-300 text-re-red focus:ring-re-red"}),e.jsx("label",{htmlFor:`check-${Q.id}`,className:"text-sm text-slate-700 leading-tight",children:Q.label})]},Q.id))})]}),e.jsxs("div",{children:[e.jsxs(de,{htmlFor:"paymentMode",children:["Payment Mode ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{id:"paymentMode",placeholder:"e.g., NEFT, RTGS, Cheque",value:Be.paymentMode,onChange:Q=>$e({...Be,paymentMode:Q.target.value})})]}),e.jsxs("div",{children:[e.jsxs(de,{htmlFor:"verificationTxnId",children:["Transaction ID / Reference ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{id:"verificationTxnId",placeholder:"Enter transaction reference",value:Be.verificationTransactionId,onChange:Q=>$e({...Be,verificationTransactionId:Q.target.value})})]}),e.jsxs("div",{children:[e.jsx(de,{htmlFor:"bankReference",children:"Bank Reference Number"}),e.jsx(at,{id:"bankReference",placeholder:"Enter bank reference",value:Be.bankReference,onChange:Q=>$e({...Be,bankReference:Q.target.value})})]}),e.jsxs("div",{children:[e.jsxs(de,{htmlFor:"settlementAmount",children:["Settlement Amount (₹) ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{id:"settlementAmount",type:"number",placeholder:"Enter settlement amount",value:Be.settlementAmount,onChange:Q=>$e({...Be,settlementAmount:Q.target.value})})]}),e.jsxs("div",{children:[e.jsx(de,{htmlFor:"adjustments",children:"Adjustments (₹)"}),e.jsx(at,{id:"adjustments",type:"number",placeholder:"Enter any adjustments",value:Be.adjustments,onChange:Q=>{const oe=Q.target.value,we=ge.settlementAmount+parseFloat(oe||"0");$e({...Be,adjustments:oe,settlementAmount:we.toString()})}}),parseFloat(Be.adjustments)!==0&&e.jsxs("p",{className:"text-sm text-re-red mt-1 flex items-center gap-1",children:[e.jsx(sn,{className:"w-3 h-3"}),"Adjusted amount: ₹",Be.settlementAmount]})]}),e.jsxs("div",{children:[e.jsxs(de,{htmlFor:"settlementDate",children:["Settlement Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{id:"settlementDate",type:"date",value:Be.settlementDate,onChange:Q=>$e({...Be,settlementDate:Q.target.value})})]}),e.jsxs("div",{children:[e.jsx(de,{htmlFor:"verificationRemarks",children:"Verification Remarks"}),e.jsx(Ws,{id:"verificationRemarks",placeholder:"Enter any remarks or notes...",rows:4,value:Be.verificationRemarks,onChange:Q=>$e({...Be,verificationRemarks:Q.target.value})})]}),e.jsxs("div",{className:"pt-4 space-y-3 border-t",children:[e.jsxs(se,{className:"w-full bg-green-600 hover:bg-green-700",onClick:Qs,disabled:Bs||A.length<Yg.length,children:[Bs?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(un,{className:"w-4 h-4 mr-2"}),"Complete Settlement"]}),A.length<Yg.length&&e.jsx("p",{className:"text-[10px] text-center text-red-500 mt-2 italic",children:"Check all compliance items to enable settlement"}),e.jsxs(se,{variant:"outline",className:"w-full border-blue-300 text-re-red hover:bg-blue-50",onClick:$s,disabled:Bs,children:[e.jsx(Gu,{className:"w-4 h-4 mr-2"}),"Request Clarification"]}),e.jsxs(se,{variant:"outline",className:"w-full border-red-300 text-red-600 hover:bg-red-50",onClick:Xs,disabled:Bs,children:[e.jsx(mi,{className:"w-4 h-4 mr-2"}),"Reject Settlement"]})]})]})})]})})]}),e.jsx(p_,{isOpen:C,onClose:()=>{S(!1),_(null)},onSubmit:W,editingBank:R,isSubmitting:!1}),e.jsx(mo,{isOpen:!!v,onClose:()=>w(null),document:v})]}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx("p",{children:"Settlement case not found"}),e.jsx(se,{onClick:s,className:"mt-4",children:"Go Back"})]})}const EV=()=>{const t=Lu(),s=g.useCallback(async()=>{try{t(l1(!0));const[r,a,i,o,d,m,f,p,h,x,u,N,v]=await Promise.all([Is.getRoles().catch(()=>({success:!1})),Is.getZones().catch(()=>({success:!1})),Is.getPermissions().catch(()=>({success:!1})),Is.getRegions().catch(()=>({success:!1})),Is.getUsers().catch(()=>({success:!1})),Is.getStates().catch(()=>({success:!1})),Is.getEmailTemplates().catch(()=>({success:!1})),Is.getDistricts({limit:"all"}).catch(()=>({success:!1})),Is.getAreas({limit:"all"}).catch(()=>({success:!1})),Is.getSlaConfigs().catch(()=>({success:!1})),Is.getASMs().catch(()=>({success:!1})),Is.getZonalManagers().catch(()=>({success:!1})),Is.getDDLeads().catch(()=>({success:!1}))]),w=H=>H.success?H:H.data?H.data:H,j=w(r),b=w(a),C=w(i),S=w(o),R=w(d),_=w(m),A=w(f),E=w(p),q=w(h),O=w(x),D=w(u),P=w(N),L=w(v),$=((R==null?void 0:R.users)||(R==null?void 0:R.data)||[]).map(H=>{var ce;const X=Array.isArray(H.territoryProfile)?H.territoryProfile:[],J=X.filter(ve=>String(ve.locationType||"").toLowerCase()==="zone").map(ve=>ve.locationName||ve.zone).filter(Boolean),ae=X.filter(ve=>String(ve.locationType||"").toLowerCase()==="region").map(ve=>ve.locationName||ve.region).filter(Boolean),le=Array.from(new Set([...H.allZones||[],...J])),xe=Array.from(new Set([...H.allRegions||[],...ae]));return{...H,name:H.fullName||H.name,role:((ce=H.role)==null?void 0:ce.roleName)||(Array.isArray(H.allRoles)&&H.allRoles.length>0?H.allRoles[0]:"System User"),zone:le.length>0?le.join(", "):"Global",region:xe.length>0?xe.join(", "):"Unassigned",status:H.isActive!==!1?"Active":"Inactive"}}),Y=((j==null?void 0:j.roles)||(j==null?void 0:j.data)||[]).map(H=>{var X;return{id:H.id,name:H.roleName,permissions:((X=H.permissions)==null?void 0:X.map(J=>J.permissionCode))||[],userCount:H.userCount||0}}),Z=((b==null?void 0:b.zones)||(b==null?void 0:b.data)||[]).map(H=>{var J,ae,le,xe,ce;const X=(H.name||H.zoneName||"").toUpperCase();return{id:H.id,name:X,description:H.description||"",code:H.name?H.name.substring(0,3).toUpperCase():"ZON",regionCount:H.regionCount||0,asmCount:H.asmCount||0,regionalOfficerCount:H.regionalOfficerCount||0,zmCount:H.zmCount||0,states:H.states||[],zonalBusinessHead:{name:((J=H.zonalBusinessHead)==null?void 0:J.name)||((ae=H.zonalBusinessHead)==null?void 0:ae.fullName)||"Not Assigned",email:((le=H.zonalBusinessHead)==null?void 0:le.email)||"",phone:((xe=H.zonalBusinessHead)==null?void 0:xe.mobileNumber)||((ce=H.zonalBusinessHead)==null?void 0:ce.phone)||""},zonalManagers:(H.zonalManagers||[]).map(ve=>({id:ve.id,name:ve.name||ve.fullName||"Unknown",email:ve.email||"",phone:ve.phone||ve.mobileNumber||"",regions:ve.regions||[]}))}}),W=((S==null?void 0:S.regions)||(S==null?void 0:S.data)||[]).map(H=>({id:H.id,code:H.code||(H.name?H.name.substring(0,3).toUpperCase():"REG"),name:H.name||H.regionName,zoneId:H.zoneId,zoneName:H.zoneName||"Unknown",states:H.states||[],cities:H.cities||[],districts:(H.districts||[]).map(X=>({id:X.id,name:X.name,stateId:X.stateId})),asmCount:H.asmCount||0,regionalOfficerCount:H.regionalOfficerCount||0,regionalManager:H.regionalManager?{id:H.regionalManager.id,name:H.regionalManager.fullName||H.regionalManager.name,email:H.regionalManager.email,phone:H.regionalManager.mobileNumber||H.regionalManager.phone}:void 0,status:H.isActive!==!1?"Active":"Inactive"})),U=Array.isArray(D==null?void 0:D.data)?D.data:Array.isArray(D)?D:[],M=Array.isArray(P==null?void 0:P.data)?P.data:Array.isArray(P)?P:[],z=M.length>0?M:$.filter(H=>{var X;return(X=H.allRoles)==null?void 0:X.some(J=>(J==="ZM"||J==="DD-ZM"||J.includes("ZONAL MANAGER"))&&!J.includes("HEAD"))}).map(H=>{const X=(H.territoryProfile||[]).find(le=>le.roleCode==="ZM"||le.roleCode==="DD-ZM")||{},J=(H.territoryProfile||[]).filter(le=>(le.roleCode==="ZM"||le.roleCode==="DD-ZM")&&le.locationType==="region").map(le=>le.locationName),ae=(H.territoryProfile||[]).filter(le=>(le.roleCode==="ZM"||le.roleCode==="DD-ZM")&&le.locationType==="region").map(le=>le.locationId);return{id:H.id,name:H.fullName,zmCode:H.employeeId||"N/A",email:H.email,phone:H.mobileNumber,zoneId:X.zoneId,zoneName:X.zone||H.zone||"Not Assigned",regionNames:J,assignedRegionIds:ae,status:H.status}}),T=((_==null?void 0:_.states)||(_==null?void 0:_.data)||[]).map(H=>({...H,stateName:H.name})),I=((E==null?void 0:E.districts)||(E==null?void 0:E.data)||[]).map(H=>({...H,districtName:H.name,stateId:H.stateId,asmId:H.asmId,ddAmId:H.ddAmId,zmId:H.zmId})),B=(q.areas||q.data||[]).map(H=>({...H,areaName:H.name,districtId:H.districtId})),G=(O.data||[]).map(H=>{var X,J;return{id:H.id,stage:H.stageCode||"Unknown",days:H.tatValue||0,enabled:H.isActive!==!1,reminders:((X=H.reminderConfig)==null?void 0:X.reminders)||[],escalations:((J=H.escalationConfig)==null?void 0:J.escalations)||[]}}),K=Array.isArray(L==null?void 0:L.data)?L.data:Array.isArray(L)?L:[];t(kA({zones:Z,regionalOffices:W,asms:U,zonalManagerMappings:z,zonalManagers:M,roles:Y,allStates:T,allDistricts:I,allAreas:B,availablePermissions:(C==null?void 0:C.permissions)||(C==null?void 0:C.data)||[],emailTemplates:(A==null?void 0:A.data)||[],slaConfigs:G,users:$,ddLeads:K,loading:!1}))}catch(r){console.error("[useMasterData] Error fetching data:",r),t(A5("Could not load configuration data")),te.error("Could not load configuration data")}finally{t(l1(!1))}},[t]),n=g.useCallback(async r=>{try{t(o1(!0));const a=await Is.getAreas(r);a.success&&t(k5({data:a.data,pagination:a.pagination}))}catch(a){console.error("[useMasterData] Error fetching areas:",a),te.error("Could not load locations")}finally{t(o1(!1))}},[t]);return{fetchInitialData:s,fetchAreas:n}},_V=({selectedZone:t,onZoneClick:s})=>{const{zones:n}=In(r=>r.master);return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:n.map(r=>e.jsxs(Le,{className:`border-2 transition-all cursor-pointer ${t===r.id?"border-re-red shadow-lg":"hover:border-red-400"}`,onClick:()=>s(r.id),children:[e.jsx(Qe,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ku,{className:"w-5 h-5 text-re-red"}),e.jsx(Je,{className:"text-lg",children:r.name.toUpperCase().endsWith("ZONE")?r.name:`${r.name} Zone`})]}),e.jsx(Ce,{variant:"outline",className:"text-xs",children:r.code})]})}),e.jsxs(Fe,{className:"space-y-3 text-sm",children:[e.jsx("p",{className:"text-slate-600 text-xs leading-relaxed mb-3",children:r.description}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"States"}),e.jsx(Ce,{variant:"outline",children:r.states.length})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Regions"}),e.jsx(Ce,{className:"bg-indigo-600",children:r.regionCount})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Regional Officers"}),e.jsx(Ce,{className:"bg-purple-600",children:r.regionalOfficerCount})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"ASMs"}),e.jsx(Ce,{className:"bg-green-600",children:r.asmCount})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"ZMs"}),e.jsx(Ce,{className:"bg-blue-600",children:r.zmCount})]})]})]})]},r.id))})},TV=({selectedZone:t,onAddZone:s,onEditZone:n})=>{const{zones:r}=In(i=>i.master),a=r.filter(i=>t==="all"||i.id===t);return e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Je,{children:"Zone Details"}),e.jsx(Xt,{children:"Geographical coverage and state mappings for each zone"})]}),e.jsxs(se,{onClick:s,className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(An,{className:"w-4 h-4 mr-2"}),"Add Zone"]})]})}),e.jsx(Fe,{children:e.jsx(Ib,{className:"h-[400px]",children:e.jsx("div",{className:"space-y-4",children:a.map(i=>e.jsxs("div",{className:"border rounded-lg p-5 space-y-4 bg-gradient-to-br from-white to-slate-50",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-gradient-to-br from-red-500 to-re-red rounded-lg flex items-center justify-center shadow-md",children:e.jsx(ku,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900",children:i.name}),e.jsx("p",{className:"text-slate-500 text-sm",children:i.code})]})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(se,{variant:"outline",size:"sm",onClick:()=>n(i),className:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",children:e.jsx(Cr,{className:"w-4 h-4"})})})]}),i.description&&e.jsx("div",{className:"bg-slate-50 rounded-lg p-3",children:e.jsx("p",{className:"text-sm text-slate-600",children:i.description})}),e.jsxs("div",{children:[e.jsxs(de,{className:"text-xs text-slate-600 mb-2 block",children:["States Covered (",i.states.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.states.map((o,d)=>e.jsx(Ce,{variant:"secondary",className:"text-xs border-transparent bg-secondary text-secondary-foreground",children:o},d))})]}),i.zonalBusinessHead&&e.jsxs("div",{className:"border-t pt-3",children:[e.jsx(de,{className:"text-xs text-slate-600 mb-2 block",children:"Zonal Business Head (ZBH)"}),e.jsxs("div",{className:"bg-red-50 border border-red-100 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hc,{className:"w-4 h-4 text-re-red"}),e.jsx("span",{className:"text-sm font-semibold text-slate-900",children:i.zonalBusinessHead.name}),e.jsx(Ce,{className:"bg-re-red text-white text-[10px] ml-auto",children:"ZBH"})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-6 text-slate-600",children:[e.jsx(Ur,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:i.zonalBusinessHead.email})]})]})]}),i.zonalManagers&&i.zonalManagers.length>0&&e.jsxs("div",{className:"border-t pt-3",children:[e.jsxs(de,{className:"text-xs text-slate-600 mb-2 block",children:["Zonal Managers (",i.zonalManagers.length,")"]}),e.jsx("div",{className:"space-y-2",children:i.zonalManagers.map((o,d)=>e.jsxs("div",{className:"bg-slate-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ra,{className:"w-4 h-4 text-slate-600"}),e.jsx("span",{className:"text-sm text-slate-900",children:o.name}),e.jsxs(Ce,{variant:"outline",className:"text-xs ml-auto",children:["ZM-",d+1]})]}),o.email&&e.jsxs("div",{className:"flex items-center gap-2 ml-6",children:[e.jsx(Ur,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-xs text-slate-600",children:o.email})]}),o.phone&&e.jsx("div",{className:"flex items-center gap-2 ml-6",children:e.jsx("span",{className:"text-xs text-slate-600",children:o.phone})}),o.regions&&o.regions.length>0&&e.jsxs("div",{className:"ml-6 mt-2",children:[e.jsxs(de,{className:"text-xs text-slate-500 mb-1 block",children:["Managed Regions (",o.regions.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:o.regions.map((m,f)=>e.jsxs(Ce,{variant:"outline",className:"text-xs bg-white text-foreground",children:[e.jsx(ku,{className:"w-2.5 h-2.5 mr-1"}),m]},f))})]})]},d))})]})]},i.id))})})})]})},PV=({selectedZone:t,onAddRegion:s,onEditRegion:n,onDeleteRegion:r})=>{const{regionalOffices:a}=In(o=>o.master),i=a.filter(o=>t==="all"||o.zoneId===t);return e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Je,{children:"Regional Offices"}),e.jsx(Xt,{children:"Manage regional offices within zones"})]}),e.jsxs(se,{onClick:s,className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(An,{className:"w-4 h-4 mr-2"}),"Add Regional Office"]})]})}),e.jsx(Fe,{children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Region Code"}),e.jsx(fe,{children:"Region Name"}),e.jsx(fe,{children:"Zone"}),e.jsx(fe,{children:"Regional Manager"}),e.jsx(fe,{children:"Districts"}),e.jsx(fe,{children:"Cities"}),e.jsx(fe,{children:"Regional Officers"}),e.jsx(fe,{children:"ASMs"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{className:"text-right",children:"Actions"})]})}),e.jsx(Os,{children:i.map(o=>e.jsxs(it,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(so,{className:"w-4 h-4 text-indigo-600"}),e.jsx("span",{className:"font-medium",children:o.code})]})}),e.jsx(ue,{className:"font-medium",children:o.name}),e.jsx(ue,{children:o.zoneName}),e.jsx(ue,{children:o.regionalManager?e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm",children:o.regionalManager.name}),e.jsx("span",{className:"text-xs text-slate-500",children:o.regionalManager.email})]}):e.jsx("span",{className:"text-slate-400 italic",children:"Not Assigned"})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(o.districts||[]).slice(0,2).map((d,m)=>e.jsx(Ce,{variant:"secondary",className:"text-xs",children:d.name||d},m)),(o.districts||[]).length>2&&e.jsxs(Ce,{variant:"secondary",className:"text-xs",children:["+",(o.districts||[]).length-2]})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[o.cities.slice(0,3).map((d,m)=>e.jsxs("span",{className:"text-xs text-slate-600",children:[d,m<Math.min(o.cities.length,3)-1?",":""]},m)),o.cities.length>3&&e.jsxs("span",{className:"text-xs text-slate-500",children:["+",o.cities.length-3]})]})}),e.jsx(ue,{children:e.jsx(Ce,{className:"bg-purple-600",children:o.regionalOfficerCount})}),e.jsx(ue,{children:e.jsx(Ce,{className:"bg-green-600",children:o.asmCount})}),e.jsx(ue,{children:e.jsx(Ce,{variant:o.status==="Active"?"default":"secondary",className:o.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:o.status})}),e.jsx(ue,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>n(o),children:e.jsx(Cr,{className:"w-4 h-4"})}),e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>r(o.id,o.name),className:"text-re-red hover:text-re-red-hover hover:bg-red-50",children:e.jsx(ar,{className:"w-4 h-4"})})]})})]},o.id))})]})})]})},OV=({selectedZone:t,onAddASM:s,onEditASM:n,onDeleteASM:r})=>{const{asms:a,zonalManagerMappings:i}=In(m=>m.master),o=a.filter(m=>t==="all"||m.zoneId===t),d=g.useMemo(()=>{const m={};return[...a,...i].forEach(f=>{(f.areasManaged||f.districts||[]).forEach(h=>{m[h]||(m[h]=[]),m[h].includes(f.name)||m[h].push(f.name)})}),m},[a,i]);return e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Je,{children:"District Development Area Managers (DD-AM)"}),e.jsx(Xt,{children:"Manage DD-AM users across districts (multi-district)"})]}),e.jsxs(se,{onClick:s,className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(An,{className:"w-4 h-4 mr-2"}),"Add DD-AM"]})]})}),e.jsx(Fe,{children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"DD-AM Code"}),e.jsx(fe,{children:"Name"}),e.jsx(fe,{children:"Zone"}),e.jsx(fe,{children:"Region"}),e.jsx(fe,{children:"Districts Managed"}),e.jsx(fe,{children:"Contact"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{className:"text-right",children:"Actions"})]})}),e.jsx(Os,{children:o.map(m=>e.jsxs(it,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(lM,{className:"w-4 h-4 text-green-600"}),e.jsx("span",{className:"font-medium",children:m.asmCode||"N/A"})]})}),e.jsx(ue,{children:m.name}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",children:m.zoneName})}),e.jsx(ue,{className:"text-sm text-slate-600",children:m.regionName}),e.jsx(ue,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:m.areasManaged.map((f,p)=>{const h=typeof f=="string"?f:f.id,x=typeof f=="string"?f:f.name,u=(d[h]||[]).filter(v=>v!==m.name),N=u.length>0;return e.jsxs(Ce,{variant:N?"outline":"secondary",className:`text-xs ${N?"border-red-300 bg-red-50 text-re-red-hover font-medium":""}`,title:N?`Also managed by: ${u.join(", ")}`:void 0,children:[x,N&&e.jsx(Ra,{className:"w-2.5 h-2.5 ml-1 inline"})]},p)})})}),e.jsx(ue,{children:e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-slate-900",children:m.email}),e.jsx("p",{className:"text-slate-500",children:m.phone})]})}),e.jsx(ue,{children:e.jsx(Ce,{variant:m.status==="Active"?"default":"secondary",className:m.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:m.status})}),e.jsx(ue,{className:"text-right",children:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>n(m),children:e.jsx(Cr,{className:"w-4 h-4"})}),e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>r(m.id,m.name),className:"text-re-red hover:text-re-red-hover hover:bg-red-50",children:e.jsx(ar,{className:"w-4 h-4"})})]})})]},m.id))})]})})]})},LV=({selectedZone:t,onAddZM:s,onEditZM:n,onDeleteZM:r})=>{const{zonalManagers:a}=In(o=>o.master),i=(a||[]).filter(o=>t==="all"||o.zoneId===t||o.zones&&o.zones.includes(t));return e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Je,{children:"Zonal Managers (DD-ZM)"}),e.jsx(Xt,{children:"Manage Zonal Managers and their region assignments"})]}),e.jsxs(se,{onClick:s,className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(An,{className:"w-4 h-4 mr-2"}),"Add ZM"]})]})}),e.jsx(Fe,{children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"ZM Code"}),e.jsx(fe,{children:"Name"}),e.jsx(fe,{children:"Zone"}),e.jsx(fe,{children:"Regions Managed"}),e.jsx(fe,{children:"Contact"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{className:"text-right",children:"Actions"})]})}),e.jsx(Os,{children:i.map(o=>e.jsxs(it,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ra,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"font-medium",children:o.zmCode||o.code})]})}),e.jsx(ue,{children:o.name}),e.jsx(ue,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:(o.zones||[o.zoneName]).map((d,m)=>e.jsx(Ce,{variant:"outline",children:d},m))})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(o.regionNames||[]).slice(0,3).map((d,m)=>e.jsx(Ce,{variant:"secondary",className:"text-xs",children:d},m)),(o.regionNames||[]).length>3&&e.jsxs(Ce,{variant:"secondary",className:"text-xs",children:["+",(o.regionNames||[]).length-3]})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-slate-900",children:o.email}),e.jsx("p",{className:"text-slate-500",children:o.phone})]})}),e.jsx(ue,{children:e.jsx(Ce,{variant:o.status==="Active"?"default":"secondary",className:o.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:o.status})}),e.jsx(ue,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>n(o),children:e.jsx(Cr,{className:"w-4 h-4"})}),e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>r(o.id,o.name),className:"text-re-red hover:text-re-red-hover hover:bg-red-50",children:e.jsx(ar,{className:"w-4 h-4"})})]})})]},o.id))})]})})]})},IV=({userAssignedData:t})=>e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{className:"text-xl",children:"System Users & Territory Assignments"})}),e.jsx(Fe,{children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"User Details"}),e.jsx(fe,{children:"Role"}),e.jsx(fe,{children:"Assigned Zone"}),e.jsx(fe,{children:"Assigned Region"}),e.jsx(fe,{children:"Status"})]})}),e.jsx(Os,{children:t.map(s=>e.jsxs(it,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-slate-100 flex items-center justify-center",children:e.jsx(Lr,{className:"w-4 h-4 text-slate-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-900",children:s.name}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-500",children:[e.jsx(Ur,{className:"w-3 h-3"}),s.email]})]})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hc,{className:"w-3 h-3 text-re-red"}),e.jsx("span",{className:"text-sm font-medium",children:s.role})]})}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",children:s.zone})}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",className:"bg-indigo-50 text-indigo-700 border-indigo-200",children:s.region})}),e.jsx(ue,{children:e.jsx(Ce,{variant:s.status==="Active"?"default":"secondary",className:s.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:s.status})})]},s.id))})]})})]}),MV=({onAddRole:t,onEditRole:s})=>{const{roles:n}=In(r=>r.master);return e.jsxs(Le,{className:"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border shadow-sm",children:[e.jsx(Qe,{className:"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 pt-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{children:[e.jsx(Je,{className:"leading-none text-xl font-bold",children:"Role Definitions"}),e.jsx(Xt,{className:"text-muted-foreground mt-1.5",children:"Overview of available roles and their access levels"})]}),e.jsxs(se,{onClick:t,className:"bg-re-red hover:bg-re-red-hover h-9",children:[e.jsx(An,{className:"w-4 h-4 mr-2"}),"Add Role"]})]})}),e.jsx(Fe,{className:"px-6 [&:last-child]:pb-6",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:n.map(r=>{var a;return e.jsxs("div",{className:"border rounded-lg p-4 space-y-3 bg-gradient-to-br from-white to-slate-50 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hc,{className:"w-5 h-5 text-re-red"}),e.jsx("h3",{className:"text-slate-900 font-bold",children:r.name})]}),e.jsxs(Ce,{variant:"secondary",className:"border-transparent bg-secondary text-secondary-foreground text-xs font-medium",children:[r.userCount||0," users"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"items-center gap-2 font-medium text-xs text-slate-600 mb-2 block",children:"Key Permissions"}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(r.permissions||[]).slice(0,3).map((i,o)=>e.jsx(Ce,{variant:"outline",className:"border px-2 py-0.5 font-medium text-foreground text-[10px] bg-white/50",children:i.replace(/_/g," ").toLowerCase()},o)),((a=r.permissions)==null?void 0:a.length)>3&&e.jsxs(Ce,{variant:"outline",className:"text-[10px] border-slate-200",children:["+",r.permissions.length-3]})]})]}),e.jsxs(se,{variant:"outline",size:"sm",onClick:()=>s(r),className:"w-full mt-2 h-8 rounded-md gap-1.5 px-3 border bg-background text-foreground hover:bg-accent hover:text-accent-foreground transition-colors",title:"Edit Permissions",children:[e.jsx(Cr,{className:"w-3 h-3 mr-1"}),"Edit Permissions"]})]},r.id)})})})]})},FV=({isOpen:t,onOpenChange:s,role:n,onSave:r})=>{const[a,i]=g.useState([]);g.useEffect(()=>{n&&i(n.permissions||[])},[n,t]);const o=m=>{i(f=>f.includes(m)?f.filter(p=>p!==m):[...f,m])};if(!n)return null;const d=[{title:"Action Permissions",color:"from-green-50 to-emerald-50 border-green-200",textColor:"text-green-900",permissions:[{id:"action:approve",label:"Approve Applications"},{id:"action:reject",label:"Reject Applications"},{id:"action:upload_docs",label:"Upload Documents"},{id:"action:request_changes",label:"Request Changes"},{id:"action:forward",label:"Forward to Others"},{id:"action:reassign",label:"Reassign Applications"},{id:"action:schedule_interview",label:"Schedule Interviews"},{id:"action:add_comments",label:"Add Comments/Notes"},{id:"action:rank_applicants",label:"Rank Applicants"},{id:"action:final_approval",label:"Final Approval"}]},{title:"View/Access Permissions",color:"from-blue-50 to-cyan-50 border-blue-200",textColor:"text-blue-900",permissions:[{id:"view:view_details",label:"Application Details"},{id:"view:view_financial",label:"Financial Information"},{id:"view:view_discussions",label:"Discussion Notes"},{id:"view:view_progress",label:"Progress Tracking"},{id:"view:view_audit",label:"Audit Logs"},{id:"view:view_documents",label:"All Documents"},{id:"view:view_personal",label:"Personal Information"},{id:"view:view_business",label:"Business Details"},{id:"view:view_reports",label:"Reports & Analytics"},{id:"view:view_history",label:"Application History"}]},{title:"Application Stage Access",color:"from-red-50 to-orange-50 border-red-200",textColor:"text-red-900",permissions:[{id:"stage:initial_review",label:"Initial Review"},{id:"stage:field_verification",label:"Field Verification"},{id:"stage:level1_interview",label:"Level 1 Interview"},{id:"stage:level2_interview",label:"Level 2 Interview"},{id:"stage:ranking",label:"Ranking & Selection"},{id:"stage:legal_review",label:"Legal Review"},{id:"stage:financial_review",label:"Financial Review"},{id:"stage:final_approval",label:"Final Approval"},{id:"stage:payment",label:"Payment Verification"},{id:"stage:onboarding",label:"Onboarding"}]}];return e.jsx(ds,{open:t,onOpenChange:s,children:e.jsxs(os,{className:"sm:max-w-lg max-w-3xl max-h-[90vh] overflow-y-auto p-0 gap-0 border-none shadow-2xl custom-scrollbar",children:[e.jsxs(xs,{className:"p-6 pb-2 space-y-2 text-left bg-white sticky top-0 z-10 border-b",children:[e.jsxs(ms,{className:"text-xl font-bold tracking-tight",children:["Edit Role Permissions - ",n.name]}),e.jsxs(bs,{className:"text-slate-500 text-sm",children:["Configure default permissions for all users assigned to the ",n.name," role"]})]}),e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsx("div",{className:"bg-gradient-to-br from-purple-50 to-indigo-50 rounded-xl p-5 border border-purple-100 shadow-sm",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-white rounded-xl shadow-sm flex items-center justify-center border border-purple-100",children:e.jsx(hc,{className:"w-6 h-6 text-purple-600"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-bold text-slate-900",children:n.name}),e.jsxs("p",{className:"text-xs font-medium text-slate-500 uppercase tracking-widest",children:[n.userCount||0," users currently assigned"]})]})]}),e.jsx(Ce,{className:"bg-purple-600 hover:bg-purple-700 px-3 py-1 rounded-full text-[10px] font-bold tracking-wider uppercase",children:"Role Configuration"})]})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("h4",{className:"text-sm font-bold text-slate-800 flex items-center gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-red-500 rounded-full"}),"Configure Default Permissions"]}),e.jsx("div",{className:"space-y-4",children:d.map((m,f)=>e.jsxs("div",{className:`border rounded-xl p-5 bg-gradient-to-br ${m.color} shadow-sm transition-all hover:shadow-md`,children:[e.jsxs("h5",{className:`text-sm font-bold ${m.textColor} mb-4 flex items-center justify-between`,children:[m.title,e.jsxs("span",{className:"text-[10px] bg-white/50 px-2 py-0.5 rounded-full opacity-70 italic font-normal",children:["Section ",f+1]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-y-3 gap-x-6",children:m.permissions.map(p=>e.jsxs("div",{className:"flex items-center space-x-3 group cursor-pointer p-1 rounded-md hover:bg-white/40 transition-colors",children:[e.jsx(Ln,{id:`perm-${p.id}`,checked:a.includes(p.id),onCheckedChange:()=>o(p.id),className:"border-slate-300 data-[state=checked]:bg-purple-600 data-[state=checked]:border-purple-600"}),e.jsx("label",{htmlFor:`perm-${p.id}`,className:"text-sm font-medium text-slate-700 cursor-pointer group-hover:text-slate-900 transition-colors flex-1",children:p.label})]},p.id))})]},f))})]})]}),e.jsxs("div",{className:"flex gap-3 p-6 pt-4 border-t sticky bottom-0 bg-white/80 backdrop-blur-md z-10",children:[e.jsx(se,{variant:"ghost",onClick:()=>s(!1),className:"flex-1 h-11 font-bold text-slate-600 hover:bg-slate-100",children:"Cancel"}),e.jsxs(se,{onClick:()=>r(n.id,a),className:"flex-1 h-11 bg-purple-600 hover:bg-purple-700 font-bold text-white shadow-lg shadow-purple-200",children:[e.jsx(ml,{className:"w-4 h-4 mr-2"}),"Save Role Permissions"]})]})]})})},BV=({isOpen:t,onOpenChange:s,onSave:n})=>{const[r,a]=g.useState(""),[i,o]=g.useState(""),[d,m]=g.useState(""),[f,p]=g.useState(!1);g.useEffect(()=>{t&&(a(""),o(""),m(""),p(!1))},[t]);const h=async()=>{if(!(!r.trim()||!i.trim())){p(!0);try{await n({roleName:r.trim(),roleCode:i.trim(),description:d.trim()||void 0}),s(!1)}finally{p(!1)}}};return e.jsx(ds,{open:t,onOpenChange:s,children:e.jsxs(os,{className:"sm:max-w-md",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Add Role"}),e.jsx(bs,{children:"Create a new role for Master Configuration."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"role-name",children:"Role Name"}),e.jsx(at,{id:"role-name",value:r,onChange:x=>a(x.target.value),placeholder:"e.g. Finance Admin"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"role-code",children:"Role Code"}),e.jsx(at,{id:"role-code",value:i,onChange:x=>o(x.target.value),placeholder:"e.g. FINANCE_ADMIN"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"role-description",children:"Description"}),e.jsx(Ws,{id:"role-description",value:d,onChange:x=>m(x.target.value),placeholder:"Optional",rows:3})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(se,{variant:"outline",onClick:()=>s(!1),disabled:f,children:"Cancel"}),e.jsx(se,{onClick:h,disabled:f||!r.trim()||!i.trim(),children:f?"Saving...":"Create Role"})]})]})})},$V=({onEditTemplate:t,onDeleteTemplate:s})=>{const{emailTemplates:n}=In(r=>r.master);return e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs("div",{children:[e.jsx(Je,{children:"Email & Letter Templates"}),e.jsx(Xt,{children:"Templates and trigger codes come from system seed data. Edit wording and layout here; new triggers are not added from this screen."})]})}),e.jsx(Fe,{children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Template Name"}),e.jsx(fe,{children:"Subject"}),e.jsx(fe,{children:"Trigger Code"}),e.jsx(fe,{children:"Modified Date"}),e.jsx(fe,{className:"text-right",children:"Actions"})]})}),e.jsxs(Os,{children:[n.map(r=>e.jsxs(it,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-red-50 rounded-lg flex items-center justify-center",children:e.jsx(Ur,{className:"w-4 h-4 text-re-red"})}),e.jsx("span",{className:"font-medium text-slate-900",children:r.name||r.templateCode})]})}),e.jsx(ue,{className:"text-slate-600 max-w-xs truncate",children:r.subject}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",className:"bg-slate-50 text-[10px] font-mono",children:r.templateCode||"-"})}),e.jsx(ue,{className:"text-slate-500 text-sm",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(dr,{className:"w-3.5 h-3.5"}),r.updatedAt?Yt(r.updatedAt):"-"]})}),e.jsx(ue,{className:"text-right",children:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>t(r),children:e.jsx(Cr,{className:"w-4 h-4"})}),e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>s(r.id),className:"text-red-500 hover:text-re-red hover:bg-red-50",children:e.jsx(ar,{className:"w-4 h-4"})})]})})]},r.id)),n.length===0&&e.jsx(it,{children:e.jsx(ue,{colSpan:5,className:"text-center py-12",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(Ur,{className:"w-8 h-8 text-slate-200"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"No templates configured yet"})]})})})]})]})})]})},qV=({onAddLocation:t,onEditLocation:s,onDeleteLocation:n,onSearch:r,onPageChange:a,searchTerm:i,states:o,stateFilter:d,onStateFilterChange:m,statusFilter:f,onStatusFilterChange:p})=>{const{allAreas:h,areasPagination:x,isAreasLoading:u}=In(N=>N.master);return e.jsx("div",{className:"space-y-4",children:e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(Je,{children:"Dealership Locations"}),e.jsxs(Xt,{children:["Manage ",x.total," geographical locations and their operational status"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ku,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx("input",{type:"text",placeholder:"Search locations...",value:i,onChange:N=>r(N.target.value),className:"pl-9 pr-4 py-2 bg-slate-50 border border-slate-200 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-red-500 w-64 transition-all"})]}),e.jsxs(Dt,{value:d,onValueChange:m,children:[e.jsx(Et,{className:"w-48",children:e.jsx(Rt,{placeholder:"All States"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"all",children:"All States"}),o.map(N=>e.jsx(Me,{value:N.id,children:N.name||N.stateName},N.id))]})]}),e.jsxs(Dt,{value:f,onValueChange:p,children:[e.jsx(Et,{className:"w-44",children:e.jsx(Rt,{placeholder:"Opportunity Filter"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"all",children:"All Opportunities"}),e.jsx(Me,{value:"active",children:"Opportunity: Yes"}),e.jsx(Me,{value:"inactive",children:"Opportunity: No"})]})]}),e.jsxs(se,{onClick:t,className:"bg-re-red hover:bg-re-red-hover whitespace-nowrap",children:[e.jsx(An,{className:"w-4 h-4 mr-2"}),"Add Location"]})]})]})}),e.jsxs(Fe,{children:[e.jsxs("div",{className:`relative ${u?"opacity-50 pointer-events-none":""}`,children:[e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"State"}),e.jsx(fe,{children:"City"}),e.jsx(fe,{children:"District"}),e.jsx(fe,{children:"Active Period"}),e.jsx(fe,{children:"Opportunity"}),e.jsx(fe,{className:"text-right",children:"Actions"})]})}),e.jsx(Os,{children:h.length===0?e.jsx(it,{children:e.jsx(ue,{colSpan:6,className:"h-32 text-center text-slate-500 italic",children:i?"No locations found matching your search":"No locations available"})}):h.map(N=>e.jsxs(it,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vr,{className:"w-4 h-4 text-re-red"}),e.jsx("span",{className:"font-medium",children:N.stateName||"N/A"})]})}),e.jsx(ue,{className:"font-medium text-slate-900",children:N.city||"N/A"}),e.jsx(ue,{className:"text-slate-600 text-sm",children:N.name}),e.jsx(ue,{children:N.openFrom&&N.openTo?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-slate-600",children:"From:"}),e.jsx(Ce,{variant:"outline",className:"text-xs font-medium",children:Yt(N.openFrom)})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-slate-600",children:"To:"}),e.jsx(Ce,{variant:"outline",className:"text-xs font-medium",children:Yt(N.openTo)})]})]}):e.jsx("span",{className:"text-slate-400 italic text-sm",children:"Not Defined"})}),e.jsx(ue,{children:e.jsx(Ce,{variant:N.isOpportunity?"default":"secondary",className:N.isOpportunity?"bg-green-600 hover:bg-green-700 text-white border-transparent":"",children:N.isOpportunity?"Yes":"No"})}),e.jsx(ue,{className:"text-right",children:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(se,{variant:"outline",size:"sm",onClick:()=>s(N),className:"h-8 w-8 p-0",children:e.jsx(Cr,{className:"w-4 h-4"})}),e.jsx(se,{variant:"outline",size:"sm",onClick:()=>n(N.id),className:"h-8 w-8 p-0 text-re-red hover:bg-red-50 hover:text-re-red-hover",children:e.jsx(ar,{className:"w-4 h-4"})})]})})]},N.id))})]}),u&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-white/10 backdrop-blur-[1px]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-re-red"})})]}),x.totalPages>1&&e.jsxs("div",{className:"flex items-center justify-between mt-6 pt-4 border-t border-slate-100",children:[e.jsxs("div",{className:"text-sm text-slate-500",children:["Showing ",e.jsx("span",{className:"font-medium text-slate-900",children:(x.page-1)*x.limit+1})," to ",e.jsx("span",{className:"font-medium text-slate-900",children:Math.min(x.page*x.limit,x.total)})," of ",e.jsx("span",{className:"font-medium text-slate-900",children:x.total})," results"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{variant:"outline",size:"sm",onClick:()=>a(x.page-1),disabled:x.page<=1||u,className:"h-8",children:"Previous"}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,x.totalPages)},(N,v)=>{let w=x.page;return x.page<=3?w=v+1:x.page>=x.totalPages-2?w=x.totalPages-4+v:w=x.page-2+v,w<=0||w>x.totalPages?null:e.jsx(se,{variant:x.page===w?"default":"outline",size:"sm",onClick:()=>a(w),disabled:u,className:"h-8 w-8 p-0",children:w},w)})}),e.jsx(se,{variant:"outline",size:"sm",onClick:()=>a(x.page+1),disabled:x.page>=x.totalPages||u,className:"h-8",children:"Next"})]})]})]})]})})};var zV=Symbol("radix.slottable");function UV(t){const s=({children:n})=>e.jsx(e.Fragment,{children:n});return s.displayName=`${t}.Slottable`,s.__radixId=zV,s}var[pp]=ga("Tooltip",[oo]),xp=oo(),x_="TooltipProvider",VV=700,Dy="tooltip.open",[HV,oj]=pp(x_),g_=t=>{const{__scopeTooltip:s,delayDuration:n=VV,skipDelayDuration:r=300,disableHoverableContent:a=!1,children:i}=t,o=g.useRef(!0),d=g.useRef(!1),m=g.useRef(0);return g.useEffect(()=>{const f=m.current;return()=>window.clearTimeout(f)},[]),e.jsx(HV,{scope:s,isOpenDelayedRef:o,delayDuration:n,onOpen:g.useCallback(()=>{window.clearTimeout(m.current),o.current=!1},[]),onClose:g.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:d,onPointerInTransitChange:g.useCallback(f=>{d.current=f},[]),disableHoverableContent:a,children:i})};g_.displayName=x_;var Ou="Tooltip",[WV,ih]=pp(Ou),v_=t=>{const{__scopeTooltip:s,children:n,open:r,defaultOpen:a,onOpenChange:i,disableHoverableContent:o,delayDuration:d}=t,m=oj(Ou,t.__scopeTooltip),f=xp(s),[p,h]=g.useState(null),x=Ar(),u=g.useRef(0),N=o??m.disableHoverableContent,v=d??m.delayDuration,w=g.useRef(!1),[j,b]=Bi({prop:r,defaultProp:a??!1,onChange:A=>{A?(m.onOpen(),document.dispatchEvent(new CustomEvent(Dy))):m.onClose(),i==null||i(A)},caller:Ou}),C=g.useMemo(()=>j?w.current?"delayed-open":"instant-open":"closed",[j]),S=g.useCallback(()=>{window.clearTimeout(u.current),u.current=0,w.current=!1,b(!0)},[b]),R=g.useCallback(()=>{window.clearTimeout(u.current),u.current=0,b(!1)},[b]),_=g.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>{w.current=!0,b(!0),u.current=0},v)},[v,b]);return g.useEffect(()=>()=>{u.current&&(window.clearTimeout(u.current),u.current=0)},[]),e.jsx(Hf,{...f,children:e.jsx(WV,{scope:s,contentId:x,open:j,stateAttribute:C,trigger:p,onTriggerChange:h,onTriggerEnter:g.useCallback(()=>{m.isOpenDelayedRef.current?_():S()},[m.isOpenDelayedRef,_,S]),onTriggerLeave:g.useCallback(()=>{N?R():(window.clearTimeout(u.current),u.current=0)},[R,N]),onOpen:S,onClose:R,disableHoverableContent:N,children:n})})};v_.displayName=Ou;var Ry="TooltipTrigger",y_=g.forwardRef((t,s)=>{const{__scopeTooltip:n,...r}=t,a=ih(Ry,n),i=oj(Ry,n),o=xp(n),d=g.useRef(null),m=Gs(s,d,a.onTriggerChange),f=g.useRef(!1),p=g.useRef(!1),h=g.useCallback(()=>f.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),e.jsx(Qu,{asChild:!0,...o,children:e.jsx(js.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:m,onPointerMove:Kt(t.onPointerMove,x=>{x.pointerType!=="touch"&&!p.current&&!i.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:Kt(t.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:Kt(t.onPointerDown,()=>{a.open&&a.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Kt(t.onFocus,()=>{f.current||a.onOpen()}),onBlur:Kt(t.onBlur,a.onClose),onClick:Kt(t.onClick,a.onClose)})})});y_.displayName=Ry;var cj="TooltipPortal",[GV,KV]=pp(cj,{forceMount:void 0}),b_=t=>{const{__scopeTooltip:s,forceMount:n,children:r,container:a}=t,i=ih(cj,s);return e.jsx(GV,{scope:s,forceMount:n,children:e.jsx(Dr,{present:n||i.open,children:e.jsx(wd,{asChild:!0,container:a,children:r})})})};b_.displayName=cj;var fd="TooltipContent",j_=g.forwardRef((t,s)=>{const n=KV(fd,t.__scopeTooltip),{forceMount:r=n.forceMount,side:a="top",...i}=t,o=ih(fd,t.__scopeTooltip);return e.jsx(Dr,{present:r||o.open,children:o.disableHoverableContent?e.jsx(N_,{side:a,...i,ref:s}):e.jsx(YV,{side:a,...i,ref:s})})}),YV=g.forwardRef((t,s)=>{const n=ih(fd,t.__scopeTooltip),r=oj(fd,t.__scopeTooltip),a=g.useRef(null),i=Gs(s,a),[o,d]=g.useState(null),{trigger:m,onClose:f}=n,p=a.current,{onPointerInTransitChange:h}=r,x=g.useCallback(()=>{d(null),h(!1)},[h]),u=g.useCallback((N,v)=>{const w=N.currentTarget,j={x:N.clientX,y:N.clientY},b=JV(j,w.getBoundingClientRect()),C=eH(j,b),S=tH(v.getBoundingClientRect()),R=nH([...C,...S]);d(R),h(!0)},[h]);return g.useEffect(()=>()=>x(),[x]),g.useEffect(()=>{if(m&&p){const N=w=>u(w,p),v=w=>u(w,m);return m.addEventListener("pointerleave",N),p.addEventListener("pointerleave",v),()=>{m.removeEventListener("pointerleave",N),p.removeEventListener("pointerleave",v)}}},[m,p,u,x]),g.useEffect(()=>{if(o){const N=v=>{const w=v.target,j={x:v.clientX,y:v.clientY},b=(m==null?void 0:m.contains(w))||(p==null?void 0:p.contains(w)),C=!sH(j,o);b?x():C&&(x(),f())};return document.addEventListener("pointermove",N),()=>document.removeEventListener("pointermove",N)}},[m,p,o,f,x]),e.jsx(N_,{...t,ref:i})}),[ZV,QV]=pp(Ou,{isInside:!1}),XV=UV("TooltipContent"),N_=g.forwardRef((t,s)=>{const{__scopeTooltip:n,children:r,"aria-label":a,onEscapeKeyDown:i,onPointerDownOutside:o,...d}=t,m=ih(fd,n),f=xp(n),{onClose:p}=m;return g.useEffect(()=>(document.addEventListener(Dy,p),()=>document.removeEventListener(Dy,p)),[p]),g.useEffect(()=>{if(m.trigger){const h=x=>{const u=x.target;u!=null&&u.contains(m.trigger)&&p()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[m.trigger,p]),e.jsx(bd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:h=>h.preventDefault(),onDismiss:p,children:e.jsxs(Wf,{"data-state":m.stateAttribute,...f,...d,ref:s,style:{...d.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(XV,{children:r}),e.jsx(ZV,{scope:n,isInside:!0,children:e.jsx(J$,{id:m.contentId,role:"tooltip",children:a||r})})]})})});j_.displayName=fd;var w_="TooltipArrow",S_=g.forwardRef((t,s)=>{const{__scopeTooltip:n,...r}=t,a=xp(n);return QV(w_,n).isInside?null:e.jsx(Gf,{...a,...r,ref:s})});S_.displayName=w_;function JV(t,s){const n=Math.abs(s.top-t.y),r=Math.abs(s.bottom-t.y),a=Math.abs(s.right-t.x),i=Math.abs(s.left-t.x);switch(Math.min(n,r,a,i)){case i:return"left";case a:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function eH(t,s,n=5){const r=[];switch(s){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function tH(t){const{top:s,right:n,bottom:r,left:a}=t;return[{x:a,y:s},{x:n,y:s},{x:n,y:r},{x:a,y:r}]}function sH(t,s){const{x:n,y:r}=t;let a=!1;for(let i=0,o=s.length-1;i<s.length;o=i++){const d=s[i],m=s[o],f=d.x,p=d.y,h=m.x,x=m.y;p>r!=x>r&&n<(h-f)*(r-p)/(x-p)+f&&(a=!a)}return a}function nH(t){const s=t.slice();return s.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),rH(s)}function rH(t){if(t.length<=1)return t.slice();const s=[];for(let r=0;r<t.length;r++){const a=t[r];for(;s.length>=2;){const i=s[s.length-1],o=s[s.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))s.pop();else break}s.push(a)}s.pop();const n=[];for(let r=t.length-1;r>=0;r--){const a=t[r];for(;n.length>=2;){const i=n[n.length-1],o=n[n.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))n.pop();else break}n.push(a)}return n.pop(),s.length===1&&n.length===1&&s[0].x===n[0].x&&s[0].y===n[0].y?s:s.concat(n)}var aH=g_,iH=v_,lH=y_,oH=b_,cH=j_,dH=S_;function gp({delayDuration:t=0,...s}){return e.jsx(aH,{"data-slot":"tooltip-provider",delayDuration:t,...s})}function dj({...t}){return e.jsx(gp,{children:e.jsx(iH,{"data-slot":"tooltip",...t})})}function uj({...t}){return e.jsx(lH,{"data-slot":"tooltip-trigger",...t})}function hj({className:t,sideOffset:s=0,children:n,...r}){return e.jsx(oH,{children:e.jsxs(cH,{"data-slot":"tooltip-content",sideOffset:s,className:Nt("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...r,children:[n,e.jsx(dH,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const uH=({isOpen:t,onOpenChange:s,editingASMId:n,asmManagerId:r,setAsmManagerId:a,asmStatus:i,setAsmStatus:o,selectedASMZone:d,setSelectedASMZone:m,selectedASMRegion:f,setSelectedASMRegion:p,selectedASMStates:h,setSelectedASMStates:x,selectedASMDistricts:u,setSelectedASMDistricts:N,onSave:v,asmRoleCode:w,userAssignedData:j,districtsAssignedToOthers:b,getDistrictsForSelectedState:C})=>{const{zones:S,regionalOffices:R}=In(A=>A.master),_=j.filter(A=>{const E=(A.allRoles||[]).map(O=>String(O||"").toUpperCase()),q=String(A.roleCode||"").toUpperCase();return E.includes("DD-AM")||q==="DD-AM"});return wt.useEffect(()=>{if(r&&t){const A=j.find(E=>E.id===r);if(A&&A.territoryProfile){const E=A.territoryProfile.filter(q=>q.roleCode===w&&q.locationType==="district").map(q=>q.locationId);E.length>0&&N(E)}}},[r,w,t,j,N]),e.jsx(ds,{open:t,onOpenChange:s,children:e.jsxs(os,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(xs,{children:[e.jsxs(ms,{children:[n?"Edit":"Add"," DD Area Manager"]}),e.jsx(bs,{children:"Configure DD-AM details and district assignment"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{children:"Zone"}),e.jsxs(Dt,{value:d,onValueChange:A=>{m(A),p(""),x([]),N([])},children:[e.jsx(Et,{className:"mt-2 text-slate-900",children:e.jsx(Rt,{placeholder:"Select zone"})}),e.jsx(_t,{children:S.map(A=>e.jsx(Me,{value:A.id,children:A.name},A.id))})]})]}),d&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{children:"Regional Office"}),e.jsxs(Dt,{value:f,onValueChange:A=>{p(A),x([]),N([])},children:[e.jsx(Et,{className:"mt-2 text-slate-900",children:e.jsx(Rt,{placeholder:"Select regional office"})}),e.jsx(_t,{children:R.filter(A=>A.zoneId===d).map(A=>e.jsx(Me,{value:A.id,children:A.name},A.id))})]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Select DD-AM User"}),e.jsxs(Dt,{value:r,onValueChange:a,children:[e.jsx(Et,{className:"mt-2 text-slate-900",children:e.jsx(Rt,{placeholder:"Select DD-AM"})}),e.jsx(_t,{className:"max-h-64",children:_.map(A=>e.jsxs(Me,{value:A.id,children:[A.name," (",A.employeeId||"No ID",")"]},A.id))})]})]})]}),f&&e.jsxs("div",{children:[e.jsx(de,{children:"States Covered"}),e.jsx("div",{className:"mt-2 border rounded-lg p-3 max-h-48 overflow-y-auto bg-slate-50",children:(()=>{const A=R.find(q=>q.id===f),E=((A==null?void 0:A.states)||[]).map(q=>typeof q=="string"?q:q.name);return E.length>0?e.jsx("div",{className:"space-y-2",children:E.map(q=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ln,{id:`asm-state-${q}`,checked:h.some(O=>O.toLowerCase()===q.toLowerCase()),onCheckedChange:O=>{if(O)x([...h,q]);else{x(h.filter(P=>P.toLowerCase()!==q.toLowerCase()));const D=C(q);N(u.filter(P=>!D.some(L=>L.id===P)))}}}),e.jsx("label",{htmlFor:`asm-state-${q}`,className:"text-sm cursor-pointer text-slate-900",children:q})]},q))}):e.jsx("p",{className:"text-sm text-slate-500",children:"No states available for this regional office"})})()})]}),h.length>0&&e.jsxs("div",{children:[e.jsx(de,{children:"Districts/Cities Covered"}),e.jsx("div",{className:"mt-2 border rounded-lg p-3 max-h-64 overflow-y-auto bg-slate-50",children:e.jsx(gp,{children:h.map(A=>{const E=C(A);return E.length===0?null:e.jsxs("div",{className:"mb-4 last:mb-0",children:[e.jsx("h4",{className:"text-sm text-re-red-hover mb-2 pb-1 border-b border-slate-200",children:A}),e.jsx("div",{className:"space-y-2 ml-2",children:E.map(q=>e.jsx("div",{children:e.jsxs(dj,{children:[e.jsx(uj,{asChild:!0,children:e.jsxs("div",{className:"flex items-center space-x-2 py-0.5",children:[e.jsx(Ln,{id:`asm-district-${q.id}`,checked:u.includes(q.id),disabled:!!b[q.id],onCheckedChange:O=>{N(O?[...u,q.id]:u.filter(D=>D!==q.id))}}),e.jsx("label",{htmlFor:`asm-district-${q.id}`,className:`text-sm flex items-center gap-1.5 ${b[q.id]?"text-slate-400 cursor-not-allowed":"cursor-pointer text-slate-900"}`,children:q.name})]})}),b[q.id]&&e.jsx(hj,{children:e.jsxs("p",{children:["Already managed by: ",b[q.id].join(", ")]})})]})},q.id))})]},A)})})})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs(de,{children:["DD Area Manager ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Dt,{value:r,onValueChange:A=>{var q;a(A);const E=j.find(O=>O.id===A);if(E){const O=(E.territoryProfile||[]).find(D=>D.roleCode===w);O!=null&&O.zoneId&&m(O.zoneId),O!=null&&O.regionId&&p(O.regionId),N(((q=E.areasManaged)==null?void 0:q.filter(D=>D.roleCode===w).map(D=>D.id))||[]),x(E.stateNames||[])}},disabled:!!n,children:[e.jsx(Et,{className:"mt-2 w-full text-slate-900",children:e.jsx(Rt,{placeholder:"Select DD-AM User"})}),e.jsx(_t,{className:"max-h-60",children:_.length>0?_.map(A=>e.jsx(Me,{value:A.id,children:e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("span",{className:"font-medium text-slate-900",children:A.name}),e.jsx("span",{className:"text-xs text-slate-500",children:A.email})]})},A.id)):e.jsx("div",{className:"p-2 text-sm text-slate-500 text-center",children:"No users available"})})]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Status"}),e.jsxs(Dt,{value:i,onValueChange:A=>o(A),children:[e.jsx(Et,{className:"mt-2 text-slate-900",children:e.jsx(Rt,{})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"active",children:"Active"}),e.jsx(Me,{value:"inactive",children:"Inactive"})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-re-red hover:bg-re-red-hover",onClick:v,children:"Save DD-AM"})]})]})]})})};var FS=1,hH=.9,mH=.8,fH=.17,Zg=.1,Qg=.999,pH=.9999,xH=.99,gH=/[\\\/_+.#"@\[\(\{&]/,vH=/[\\\/_+.#"@\[\(\{&]/g,yH=/[\s-]/,C_=/[\s-]/g;function Ey(t,s,n,r,a,i,o){if(i===s.length)return a===t.length?FS:xH;var d=`${a},${i}`;if(o[d]!==void 0)return o[d];for(var m=r.charAt(i),f=n.indexOf(m,a),p=0,h,x,u,N;f>=0;)h=Ey(t,s,n,r,f+1,i+1,o),h>p&&(f===a?h*=FS:gH.test(t.charAt(f-1))?(h*=mH,u=t.slice(a,f-1).match(vH),u&&a>0&&(h*=Math.pow(Qg,u.length))):yH.test(t.charAt(f-1))?(h*=hH,N=t.slice(a,f-1).match(C_),N&&a>0&&(h*=Math.pow(Qg,N.length))):(h*=fH,a>0&&(h*=Math.pow(Qg,f-a))),t.charAt(f)!==s.charAt(i)&&(h*=pH)),(h<Zg&&n.charAt(f-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(f-1)!==r.charAt(i))&&(x=Ey(t,s,n,r,f+1,i+2,o),x*Zg>h&&(h=x*Zg)),h>p&&(p=h),f=n.indexOf(m,f+1);return o[d]=p,p}function BS(t){return t.toLowerCase().replace(C_," ")}function bH(t,s,n){return t=n&&n.length>0?`${t+" "+n.join(" ")}`:t,Ey(t,s,BS(t),BS(s),0,0,{})}var cu='[cmdk-group=""]',Xg='[cmdk-group-items=""]',jH='[cmdk-group-heading=""]',A_='[cmdk-item=""]',$S=`${A_}:not([aria-disabled="true"])`,_y="cmdk-item-select",Yc="data-value",NH=(t,s,n)=>bH(t,s,n),k_=g.createContext(void 0),lh=()=>g.useContext(k_),D_=g.createContext(void 0),mj=()=>g.useContext(D_),R_=g.createContext(void 0),E_=g.forwardRef((t,s)=>{let n=Zc(()=>{var I,B;return{search:"",value:(B=(I=t.value)!=null?I:t.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Zc(()=>new Set),a=Zc(()=>new Map),i=Zc(()=>new Map),o=Zc(()=>new Set),d=__(t),{label:m,children:f,value:p,onValueChange:h,filter:x,shouldFilter:u,loop:N,disablePointerSelection:v=!1,vimBindings:w=!0,...j}=t,b=Ar(),C=Ar(),S=Ar(),R=g.useRef(null),_=PH();uc(()=>{if(p!==void 0){let I=p.trim();n.current.value=I,A.emit()}},[p]),uc(()=>{_(6,L)},[]);let A=g.useMemo(()=>({subscribe:I=>(o.current.add(I),()=>o.current.delete(I)),snapshot:()=>n.current,setState:(I,B,G)=>{var K,H,X,J;if(!Object.is(n.current[I],B)){if(n.current[I]=B,I==="search")P(),O(),_(1,D);else if(I==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ae=document.getElementById(S);ae?ae.focus():(K=document.getElementById(b))==null||K.focus()}if(_(7,()=>{var ae;n.current.selectedItemId=(ae=$())==null?void 0:ae.id,A.emit()}),G||_(5,L),((H=d.current)==null?void 0:H.value)!==void 0){let ae=B??"";(J=(X=d.current).onValueChange)==null||J.call(X,ae);return}}A.emit()}},emit:()=>{o.current.forEach(I=>I())}}),[]),E=g.useMemo(()=>({value:(I,B,G)=>{var K;B!==((K=i.current.get(I))==null?void 0:K.value)&&(i.current.set(I,{value:B,keywords:G}),n.current.filtered.items.set(I,q(B,G)),_(2,()=>{O(),A.emit()}))},item:(I,B)=>(r.current.add(I),B&&(a.current.has(B)?a.current.get(B).add(I):a.current.set(B,new Set([I]))),_(3,()=>{P(),O(),n.current.value||D(),A.emit()}),()=>{i.current.delete(I),r.current.delete(I),n.current.filtered.items.delete(I);let G=$();_(4,()=>{P(),(G==null?void 0:G.getAttribute("id"))===I&&D(),A.emit()})}),group:I=>(a.current.has(I)||a.current.set(I,new Set),()=>{i.current.delete(I),a.current.delete(I)}),filter:()=>d.current.shouldFilter,label:m||t["aria-label"],getDisablePointerSelection:()=>d.current.disablePointerSelection,listId:b,inputId:S,labelId:C,listInnerRef:R}),[]);function q(I,B){var G,K;let H=(K=(G=d.current)==null?void 0:G.filter)!=null?K:NH;return I?H(I,n.current.search,B):0}function O(){if(!n.current.search||d.current.shouldFilter===!1)return;let I=n.current.filtered.items,B=[];n.current.filtered.groups.forEach(K=>{let H=a.current.get(K),X=0;H.forEach(J=>{let ae=I.get(J);X=Math.max(ae,X)}),B.push([K,X])});let G=R.current;Y().sort((K,H)=>{var X,J;let ae=K.getAttribute("id"),le=H.getAttribute("id");return((X=I.get(le))!=null?X:0)-((J=I.get(ae))!=null?J:0)}).forEach(K=>{let H=K.closest(Xg);H?H.appendChild(K.parentElement===H?K:K.closest(`${Xg} > *`)):G.appendChild(K.parentElement===G?K:K.closest(`${Xg} > *`))}),B.sort((K,H)=>H[1]-K[1]).forEach(K=>{var H;let X=(H=R.current)==null?void 0:H.querySelector(`${cu}[${Yc}="${encodeURIComponent(K[0])}"]`);X==null||X.parentElement.appendChild(X)})}function D(){let I=Y().find(G=>G.getAttribute("aria-disabled")!=="true"),B=I==null?void 0:I.getAttribute(Yc);A.setState("value",B||void 0)}function P(){var I,B,G,K;if(!n.current.search||d.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let H=0;for(let X of r.current){let J=(B=(I=i.current.get(X))==null?void 0:I.value)!=null?B:"",ae=(K=(G=i.current.get(X))==null?void 0:G.keywords)!=null?K:[],le=q(J,ae);n.current.filtered.items.set(X,le),le>0&&H++}for(let[X,J]of a.current)for(let ae of J)if(n.current.filtered.items.get(ae)>0){n.current.filtered.groups.add(X);break}n.current.filtered.count=H}function L(){var I,B,G;let K=$();K&&(((I=K.parentElement)==null?void 0:I.firstChild)===K&&((G=(B=K.closest(cu))==null?void 0:B.querySelector(jH))==null||G.scrollIntoView({block:"nearest"})),K.scrollIntoView({block:"nearest"}))}function $(){var I;return(I=R.current)==null?void 0:I.querySelector(`${A_}[aria-selected="true"]`)}function Y(){var I;return Array.from(((I=R.current)==null?void 0:I.querySelectorAll($S))||[])}function Z(I){let B=Y()[I];B&&A.setState("value",B.getAttribute(Yc))}function W(I){var B;let G=$(),K=Y(),H=K.findIndex(J=>J===G),X=K[H+I];(B=d.current)!=null&&B.loop&&(X=H+I<0?K[K.length-1]:H+I===K.length?K[0]:K[H+I]),X&&A.setState("value",X.getAttribute(Yc))}function U(I){let B=$(),G=B==null?void 0:B.closest(cu),K;for(;G&&!K;)G=I>0?_H(G,cu):TH(G,cu),K=G==null?void 0:G.querySelector($S);K?A.setState("value",K.getAttribute(Yc)):W(I)}let M=()=>Z(Y().length-1),z=I=>{I.preventDefault(),I.metaKey?M():I.altKey?U(1):W(1)},T=I=>{I.preventDefault(),I.metaKey?Z(0):I.altKey?U(-1):W(-1)};return g.createElement(js.div,{ref:s,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:I=>{var B;(B=j.onKeyDown)==null||B.call(j,I);let G=I.nativeEvent.isComposing||I.keyCode===229;if(!(I.defaultPrevented||G))switch(I.key){case"n":case"j":{w&&I.ctrlKey&&z(I);break}case"ArrowDown":{z(I);break}case"p":case"k":{w&&I.ctrlKey&&T(I);break}case"ArrowUp":{T(I);break}case"Home":{I.preventDefault(),Z(0);break}case"End":{I.preventDefault(),M();break}case"Enter":{I.preventDefault();let K=$();if(K){let H=new Event(_y);K.dispatchEvent(H)}}}}},g.createElement("label",{"cmdk-label":"",htmlFor:E.inputId,id:E.labelId,style:LH},m),vp(t,I=>g.createElement(D_.Provider,{value:A},g.createElement(k_.Provider,{value:E},I))))}),wH=g.forwardRef((t,s)=>{var n,r;let a=Ar(),i=g.useRef(null),o=g.useContext(R_),d=lh(),m=__(t),f=(r=(n=m.current)==null?void 0:n.forceMount)!=null?r:o==null?void 0:o.forceMount;uc(()=>{if(!f)return d.item(a,o==null?void 0:o.id)},[f]);let p=T_(a,i,[t.value,t.children,i],t.keywords),h=mj(),x=io(_=>_.value&&_.value===p.current),u=io(_=>f||d.filter()===!1?!0:_.search?_.filtered.items.get(a)>0:!0);g.useEffect(()=>{let _=i.current;if(!(!_||t.disabled))return _.addEventListener(_y,N),()=>_.removeEventListener(_y,N)},[u,t.onSelect,t.disabled]);function N(){var _,A;v(),(A=(_=m.current).onSelect)==null||A.call(_,p.current)}function v(){h.setState("value",p.current,!0)}if(!u)return null;let{disabled:w,value:j,onSelect:b,forceMount:C,keywords:S,...R}=t;return g.createElement(js.div,{ref:Xr(i,s),...R,id:a,"cmdk-item":"",role:"option","aria-disabled":!!w,"aria-selected":!!x,"data-disabled":!!w,"data-selected":!!x,onPointerMove:w||d.getDisablePointerSelection()?void 0:v,onClick:w?void 0:N},t.children)}),SH=g.forwardRef((t,s)=>{let{heading:n,children:r,forceMount:a,...i}=t,o=Ar(),d=g.useRef(null),m=g.useRef(null),f=Ar(),p=lh(),h=io(u=>a||p.filter()===!1?!0:u.search?u.filtered.groups.has(o):!0);uc(()=>p.group(o),[]),T_(o,d,[t.value,t.heading,m]);let x=g.useMemo(()=>({id:o,forceMount:a}),[a]);return g.createElement(js.div,{ref:Xr(d,s),...i,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&g.createElement("div",{ref:m,"cmdk-group-heading":"","aria-hidden":!0,id:f},n),vp(t,u=>g.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?f:void 0},g.createElement(R_.Provider,{value:x},u))))}),CH=g.forwardRef((t,s)=>{let{alwaysRender:n,...r}=t,a=g.useRef(null),i=io(o=>!o.search);return!n&&!i?null:g.createElement(js.div,{ref:Xr(a,s),...r,"cmdk-separator":"",role:"separator"})}),AH=g.forwardRef((t,s)=>{let{onValueChange:n,...r}=t,a=t.value!=null,i=mj(),o=io(f=>f.search),d=io(f=>f.selectedItemId),m=lh();return g.useEffect(()=>{t.value!=null&&i.setState("search",t.value)},[t.value]),g.createElement(js.input,{ref:s,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":m.listId,"aria-labelledby":m.labelId,"aria-activedescendant":d,id:m.inputId,type:"text",value:a?t.value:o,onChange:f=>{a||i.setState("search",f.target.value),n==null||n(f.target.value)}})}),kH=g.forwardRef((t,s)=>{let{children:n,label:r="Suggestions",...a}=t,i=g.useRef(null),o=g.useRef(null),d=io(f=>f.selectedItemId),m=lh();return g.useEffect(()=>{if(o.current&&i.current){let f=o.current,p=i.current,h,x=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let u=f.offsetHeight;p.style.setProperty("--cmdk-list-height",u.toFixed(1)+"px")})});return x.observe(f),()=>{cancelAnimationFrame(h),x.unobserve(f)}}},[]),g.createElement(js.div,{ref:Xr(i,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":d,"aria-label":r,id:m.listId},vp(t,f=>g.createElement("div",{ref:Xr(o,m.listInnerRef),"cmdk-list-sizer":""},f)))}),DH=g.forwardRef((t,s)=>{let{open:n,onOpenChange:r,overlayClassName:a,contentClassName:i,container:o,...d}=t;return g.createElement(qb,{open:n,onOpenChange:r},g.createElement(zb,{container:o},g.createElement(lp,{"cmdk-overlay":"",className:a}),g.createElement(op,{"aria-label":t.label,"cmdk-dialog":"",className:i},g.createElement(E_,{ref:s,...d}))))}),RH=g.forwardRef((t,s)=>io(n=>n.filtered.count===0)?g.createElement(js.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),EH=g.forwardRef((t,s)=>{let{progress:n,children:r,label:a="Loading...",...i}=t;return g.createElement(js.div,{ref:s,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},vp(t,o=>g.createElement("div",{"aria-hidden":!0},o)))}),Dd=Object.assign(E_,{List:kH,Item:wH,Input:AH,Group:SH,Separator:CH,Dialog:DH,Empty:RH,Loading:EH});function _H(t,s){let n=t.nextElementSibling;for(;n;){if(n.matches(s))return n;n=n.nextElementSibling}}function TH(t,s){let n=t.previousElementSibling;for(;n;){if(n.matches(s))return n;n=n.previousElementSibling}}function __(t){let s=g.useRef(t);return uc(()=>{s.current=t}),s}var uc=typeof window>"u"?g.useEffect:g.useLayoutEffect;function Zc(t){let s=g.useRef();return s.current===void 0&&(s.current=t()),s}function io(t){let s=mj(),n=()=>t(s.snapshot());return g.useSyncExternalStore(s.subscribe,n,n)}function T_(t,s,n,r=[]){let a=g.useRef(),i=lh();return uc(()=>{var o;let d=(()=>{var f;for(let p of n){if(typeof p=="string")return p.trim();if(typeof p=="object"&&"current"in p)return p.current?(f=p.current.textContent)==null?void 0:f.trim():a.current}})(),m=r.map(f=>f.trim());i.value(t,d,m),(o=s.current)==null||o.setAttribute(Yc,d),a.current=d}),a}var PH=()=>{let[t,s]=g.useState(),n=Zc(()=>new Map);return uc(()=>{n.current.forEach(r=>r()),n.current=new Map},[t]),(r,a)=>{n.current.set(r,a),s({})}};function OH(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function vp({asChild:t,children:s},n){return t&&g.isValidElement(s)?g.cloneElement(OH(s),{ref:s.ref},n(s.props.children)):n(s)}var LH={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function IH({className:t,...s}){return e.jsx(Dd,{"data-slot":"command",className:Nt("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",t),...s})}function MH({className:t,...s}){return e.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[e.jsx(Ta,{className:"size-4 shrink-0 opacity-50"}),e.jsx(Dd.Input,{"data-slot":"command-input",className:Nt("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",t),...s})]})}function FH({className:t,...s}){return e.jsx(Dd.List,{"data-slot":"command-list",className:Nt("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),...s})}function BH({...t}){return e.jsx(Dd.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...t})}function $H({className:t,...s}){return e.jsx(Dd.Group,{"data-slot":"command-group",className:Nt("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",t),...s})}function qS({className:t,...s}){return e.jsx(Dd.Item,{"data-slot":"command-item",className:Nt("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...s})}const qH=({value:t,onChange:s,asmUsers:n,className:r})=>{const[a,i]=g.useState(!1),o=n.find(d=>d.id===t);return e.jsxs(_u,{open:a,onOpenChange:i,children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(se,{variant:"outline",role:"combobox","aria-expanded":a,className:Nt("w-full min-w-0 justify-between",r),children:[e.jsx("span",{className:"truncate text-left",children:t==="__none__"?"Unassign":o?`${o.fullName} (${o.employeeId||o.email})`:"Select ASM"}),e.jsx(II,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Pu,{className:"w-[360px] max-w-[90vw] p-0",children:e.jsxs(IH,{children:[e.jsx(MH,{placeholder:"Search ASM by name/email/id..."}),e.jsxs(FH,{className:"max-h-64 overflow-y-auto custom-scrollbar-slim",children:[e.jsx(BH,{children:"No ASM found."}),e.jsxs($H,{children:[e.jsxs(qS,{value:"Unassign __none__",onSelect:()=>{s("__none__"),i(!1)},children:[e.jsx(Hn,{className:Nt("mr-2 h-4 w-4",t==="__none__"?"opacity-100":"opacity-0")}),"Unassign"]}),n.map(d=>e.jsxs(qS,{value:`${d.fullName} ${d.email} ${d.employeeId||""}`,onSelect:()=>{s(d.id),i(!1)},children:[e.jsx(Hn,{className:Nt("mr-2 h-4 w-4",t===d.id?"opacity-100":"opacity-0")}),d.fullName," (",d.employeeId||d.email,")"]},d.id))]})]})]})})]})},zH=()=>{const[t,s]=g.useState(!1),[n,r]=g.useState([]),[a,i]=g.useState([]),[o,d]=g.useState({}),m=async()=>{var h,x,u,N;try{s(!0);const v=await Is.getDealerAsmMappings();v!=null&&v.success&&(r(((h=v.data)==null?void 0:h.dealers)||[]),i(((x=v.data)==null?void 0:x.asmUsers)||[]))}catch(v){te.error(((N=(u=v==null?void 0:v.response)==null?void 0:u.data)==null?void 0:N.message)||"Failed to load dealer ASM mappings")}finally{s(!1)}};g.useEffect(()=>{m()},[]);const f=g.useMemo(()=>[...n].sort((h,x)=>{const u=String(h.status||"").toLowerCase()==="active",N=String(x.status||"").toLowerCase()==="active";return u!==N?u?-1:1:String(h.dealerName||"").localeCompare(String(x.dealerName||""))}),[n]),p=async h=>{var u,N;const x=o[h]||"";try{const v=await Is.saveDealerAsmMapping({dealerId:h,asmUserId:x==="__none__"?null:x||null});v!=null&&v.success?(te.success(v.message||"Dealer ASM mapping updated"),await m()):te.error((v==null?void 0:v.message)||"Failed to save mapping")}catch(v){te.error(((N=(u=v==null?void 0:v.response)==null?void 0:u.data)==null?void 0:N.message)||"Failed to save mapping")}};return e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"Dealer-Level ASM Assignment"}),e.jsx(Xt,{children:"Assign Sales ASM to onboarded dealers. DD-AM remains district-level in the section above."})]}),e.jsx(Fe,{children:t?e.jsx("p",{className:"text-sm text-slate-500",children:"Loading mappings..."}):e.jsxs(Ts,{className:"w-full",children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Dealer"}),e.jsx(fe,{children:"Dealer Code"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Current ASM"}),e.jsx(fe,{children:"Assign ASM"})]})}),e.jsxs(Os,{children:[f.length===0&&e.jsx(it,{children:e.jsx(ue,{colSpan:5,className:"text-center text-slate-500 py-8",children:"No dealers available for ASM mapping yet."})}),f.map(h=>{var x;return e.jsxs(it,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:h.dealerName}),e.jsx("span",{className:"text-xs text-slate-500",children:h.legalName})]})}),e.jsx(ue,{children:h.dealerCode||"N/A"}),e.jsx(ue,{children:e.jsx(Ce,{variant:String(h.status||"").toLowerCase()==="active"?"default":"secondary",className:String(h.status||"").toLowerCase()==="active"?"bg-emerald-100 text-emerald-700 hover:bg-emerald-200":"",children:h.status||"Unknown"})}),e.jsx(ue,{children:h.assignedAsm?e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("span",{children:h.assignedAsm.fullName}),e.jsx("span",{className:"text-xs text-slate-500 truncate",children:h.assignedAsm.employeeId||h.assignedAsm.email})]}):e.jsx("span",{className:"text-slate-400 text-sm",children:"Unassigned"})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx(qH,{asmUsers:a,value:o[h.dealerId]??((x=h.assignedAsm)==null?void 0:x.id)??"__none__",onChange:u=>d(N=>({...N,[h.dealerId]:u})),className:"flex-1 min-w-[180px]"}),e.jsx(se,{size:"sm",className:"shrink-0 bg-re-red hover:bg-re-red-hover text-white",onClick:()=>p(h.dealerId),children:"Assign"})]})})]},h.dealerId)})]})]})})]})},UH=({isOpen:t,onOpenChange:s,editingZMId:n,zmManagerId:r,setZmManagerId:a,zmStatus:i,setZmStatus:o,selectedZone:d,setSelectedZone:m,selectedRegions:f,setSelectedRegions:p,onSave:h,userAssignedData:x})=>{const{zones:u,regionalOffices:N}=In(j=>j.master),v=x.filter(j=>(j.allRoles||[]).some(C=>{const S=(C||"").toUpperCase();return["ZM","ZONAL MANAGER","ZBH","ZONE BUSINESS HEAD","RM","RBM","REGIONAL MANAGER"].includes(S)||S.includes("ZONAL")||S.includes("REGIONAL")})),w=N.filter(j=>j.zoneId===d);return e.jsx(ds,{open:t,onOpenChange:s,children:e.jsxs(os,{className:"max-w-xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(xs,{children:[e.jsxs(ms,{children:[n?"Edit":"Add"," Zonal Manager"]}),e.jsx(bs,{children:"Assign Zonal Manager to Regions within a Zone"})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"border-b border-slate-100 pb-4",children:[e.jsxs(de,{children:["Select Zonal Manager User ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Dt,{value:r,onValueChange:j=>{a(j);const b=x.find(C=>C.id===j);b&&(b.zoneId&&m(b.zoneId),b.assignedRegionIds&&p(b.assignedRegionIds))},disabled:!!n,children:[e.jsx(Et,{className:"mt-2 w-full text-slate-900 border-slate-200",children:e.jsx(Rt,{placeholder:"Select ZM User"})}),e.jsx(_t,{className:"max-h-60",children:v.map(j=>e.jsx(Me,{value:j.id,children:e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("span",{className:"font-medium text-slate-900",children:j.name}),e.jsx("span",{className:"text-xs text-slate-500",children:j.email})]})},j.id))})]})]}),e.jsxs("div",{children:[e.jsxs(de,{children:["Managed Zone ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Dt,{value:d,onValueChange:j=>{m(j),p([])},children:[e.jsx(Et,{className:"mt-2",children:e.jsx(Rt,{placeholder:"Select zone"})}),e.jsx(_t,{children:u.map(j=>e.jsx(Me,{value:j.id,children:j.name},j.id))})]})]}),d&&e.jsxs("div",{children:[e.jsxs(de,{className:"mb-2 block",children:["Assigned Regions ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"border border-slate-200 rounded-lg p-4 bg-slate-50/50 max-h-60 overflow-y-auto",children:e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[w.map(j=>e.jsxs("div",{className:"flex items-center space-x-3 p-2 rounded hover:bg-white transition-colors",children:[e.jsx(Ln,{id:`region-${j.id}`,checked:f.includes(j.id),onCheckedChange:b=>{p(b?[...f,j.id]:f.filter(C=>C!==j.id))}}),e.jsxs("label",{htmlFor:`region-${j.id}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer flex-1",children:[j.name,e.jsx("span",{className:"text-xs text-slate-500 block mt-1",children:j.code||"No Code"})]})]},j.id)),w.length===0&&e.jsx("p",{className:"text-sm text-slate-500 italic text-center py-4",children:"No regions found for this zone"})]})})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Status"}),e.jsxs(Dt,{value:i,onValueChange:j=>o(j),children:[e.jsx(Et,{className:"mt-2",children:e.jsx(Rt,{})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"active",children:"Active"}),e.jsx(Me,{value:"inactive",children:"Inactive"})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-6",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-re-red hover:bg-re-red-hover",onClick:h,children:"Save Zonal Manager"})]})]})]})})},VH=({isOpen:t,onOpenChange:s,editingZoneId:n,zoneName:r,setZoneName:a,zoneCode:i,setZoneCode:o,zoneDescription:d,setZoneDescription:m,zonalBusinessHeadId:f,setZonalBusinessHeadId:p,userAssignedData:h,onSave:x})=>{const u=(h||[]).filter(v=>{if(f!=="none"&&v.id===f)return!0;const w=(v.allRoles||[]).map(b=>String(b||"").toUpperCase()),j=String(v.roleCode||v.role||"").toUpperCase();return j==="ZBH"||j.includes("ZONAL BUSINESS HEAD")||w.some(b=>{const C=String(b||"").toUpperCase();return C==="ZBH"||C==="ZONE BUSINESS HEAD"||C==="ZONAL BUSINESS HEAD"})}),N=u.length>0?u:h||[];return wt.useEffect(()=>{},[n,t]),e.jsx(ds,{open:t,onOpenChange:s,children:e.jsxs(os,{className:"max-w-md",children:[e.jsxs(xs,{children:[e.jsxs(ms,{children:[n?"Edit":"Add"," Zone"]}),e.jsx(bs,{children:"Configure zonal details and geographical boundaries"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(de,{children:"Zone Name"}),e.jsx(at,{placeholder:"e.g., North Zone",className:"mt-2 text-slate-900",value:r,onChange:v=>a(v.target.value)})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Zone Code"}),e.jsx(at,{placeholder:"e.g., NZ",className:"mt-2 text-slate-900",value:i,onChange:v=>o(v.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Zonal Business Head"}),e.jsxs(Dt,{value:f,onValueChange:p,children:[e.jsx(Et,{className:"mt-2 w-full text-slate-900",children:e.jsx(Rt,{placeholder:"Select Head"})}),e.jsxs(_t,{className:"max-h-60",children:[e.jsx(Me,{value:"none",children:"None / Unassigned"}),N.map(v=>e.jsxs(Me,{value:v.id,children:[v.name," (",v.email,")"]},v.id))]})]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Description"}),e.jsx(Ws,{placeholder:"Describe the zone's coverage...",className:"mt-2 text-slate-900",rows:3,value:d,onChange:v=>m(v.target.value)})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-re-red hover:bg-re-red-hover",onClick:x,children:"Save Zone"})]})]})]})})},HH=({isOpen:t,onOpenChange:s,editingRegionId:n,regionName:r,setRegionName:a,regionDescription:i,setRegionDescription:o,selectedRegionZone:d,setSelectedRegionZone:m,regionalManagerId:f,setRegionalManagerId:p,selectedRegionStates:h,setSelectedRegionStates:x,onSave:u,userAssignedData:N})=>{const{zones:v,allStates:w,allDistricts:j,regionalOffices:b}=In(D=>D.master),[C,S]=wt.useState([]),R=wt.useMemo(()=>{const D={};return(b||[]).forEach(P=>{P.id!==n&&(P.districts||[]).forEach(L=>{D[L.id]=P.name})}),D},[b,n]),_=wt.useMemo(()=>{if(!d)return w;const D=new Set(j.filter(P=>P.zoneId===d||!P.zoneId||h.includes(P.id)).map(P=>P.stateId).filter(Boolean));return w.filter(P=>P.zoneId===d||D.has(P.id)||!P.zoneId)},[w,j,d,h]),A=wt.useMemo(()=>C.length===0?[]:j.filter(D=>C.includes(D.stateId)&&(!D.zoneId||D.zoneId===d||D.regionId===n)),[j,C,d,n]),E=wt.useMemo(()=>{const D={};return A.forEach(P=>{const L=w.find(Y=>Y.id===P.stateId),$=(L==null?void 0:L.name)||P.stateId;D[P.stateId]||(D[P.stateId]={stateName:$,districts:[]}),D[P.stateId].districts.push(P)}),Object.values(D)},[A,w]);wt.useEffect(()=>{if(!t){S([]);return}if(h.length>0){const D=Array.from(new Set(j.filter(P=>h.includes(P.id)).map(P=>P.stateId).filter(Boolean)));S(D)}},[t]);const q=D=>{m(D),S([]),x([])},O=(D,P)=>{if(P)S(L=>[...L,D]);else{S($=>$.filter(Y=>Y!==D));const L=j.filter($=>$.stateId===D).map($=>$.id);x(h.filter($=>!L.includes($)))}};return e.jsx(ds,{open:t,onOpenChange:s,children:e.jsxs(os,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(xs,{children:[e.jsxs(ms,{children:[n?"Edit":"Add"," Regional Office"]}),e.jsx(bs,{children:"Configure regional office details and coverage area"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{children:"Region Name"}),e.jsx(at,{placeholder:"e.g., Delhi NCR Region",className:"mt-2 text-slate-900",value:r,onChange:D=>a(D.target.value)})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Zone"}),e.jsxs(Dt,{value:d,onValueChange:q,children:[e.jsx(Et,{className:"mt-2 text-slate-900",children:e.jsx(Rt,{placeholder:"Select zone"})}),e.jsx(_t,{children:v.map(D=>e.jsx(Me,{value:D.id,children:D.name},D.id))})]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Regional Manager"}),e.jsxs(Dt,{value:f,onValueChange:p,children:[e.jsx(Et,{className:"mt-2 w-full text-slate-900",children:e.jsx(Rt,{placeholder:"Select from available users"})}),e.jsx(_t,{className:"max-h-60",children:N.map(D=>e.jsxs(Me,{value:D.id,children:[D.name||D.fullName,D.email?` — ${D.email}`:""]},D.id))})]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Description"}),e.jsx(Ws,{placeholder:"Describe the region...",className:"mt-2 text-slate-900",rows:2,value:i,onChange:D=>o(D.target.value)})]}),e.jsxs("div",{children:[e.jsx(de,{children:"States Covered"}),!d&&e.jsx("p",{className:"text-xs text-re-red mt-1",children:"Select a zone first to see available states"}),e.jsx("div",{className:"mt-2 border rounded-lg p-3 max-h-40 overflow-y-auto bg-slate-50",children:_.length===0?e.jsx("p",{className:"text-xs text-slate-400 italic",children:d?"No states with available districts in this zone":"Select a zone to load states"}):e.jsx("div",{className:"space-y-2",children:_.map(D=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ln,{id:`region-state-${D.id}`,checked:C.includes(D.id),disabled:!d,onCheckedChange:P=>O(D.id,!!P)}),e.jsx("label",{htmlFor:`region-state-${D.id}`,className:`text-sm cursor-pointer ${d?"text-slate-900":"text-slate-400"}`,children:D.name})]},D.id))})}),e.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:[C.length," ",C.length===1?"state":"states"," selected"]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Districts Covered"}),e.jsx("div",{className:"mt-2 border rounded-lg p-3 max-h-56 overflow-y-auto bg-slate-50",children:C.length===0?e.jsx("p",{className:"text-xs text-slate-400 italic",children:"Select one or more states above to see districts"}):E.length===0?e.jsx("p",{className:"text-xs text-slate-400 italic",children:"No available districts in the selected states for this zone"}):e.jsx(gp,{children:E.map(({stateName:D,districts:P})=>e.jsxs("div",{className:"mb-4 last:mb-0",children:[e.jsx("h4",{className:"text-xs font-semibold text-re-red-hover uppercase tracking-wide mb-2 pb-1 border-b border-slate-200",children:D}),e.jsx("div",{className:"space-y-2 ml-1",children:P.map(L=>{const $=R[L.id],Y=L.zoneId&&L.zoneId!==d&&L.regionId!==n,Z=!!($||Y),W=$?`Already assigned to region: ${$}`:Y?"Belongs to a different zone":"";return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(dj,{children:[e.jsx(uj,{asChild:!0,children:e.jsxs("div",{className:"flex items-center space-x-2 w-full",children:[e.jsx(Ln,{id:`region-district-${L.id}`,disabled:Z,checked:h.includes(L.id),onCheckedChange:U=>{x(U?[...h,L.id]:h.filter(M=>M!==L.id))}}),e.jsxs("label",{htmlFor:`region-district-${L.id}`,className:`text-sm flex-1 ${Z?"text-slate-400 cursor-not-allowed line-through":"text-slate-900 cursor-pointer"}`,children:[L.name,$&&e.jsxs("span",{className:"ml-2 text-xs text-red-400 font-normal no-underline",style:{textDecoration:"none"},children:["(in ",$,")"]})]})]})}),Z&&W&&e.jsx(hj,{children:e.jsx("p",{className:"text-xs",children:W})})]})},L.id)})})]},D))})}),e.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:[h.length," ",h.length===1?"district":"districts"," selected"]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-re-red hover:bg-re-red-hover",onClick:u,children:"Save Regional Office"})]})]})]})})};var yp="Switch",[WH]=ga(yp),[GH,KH]=WH(yp),P_=g.forwardRef((t,s)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:i,required:o,disabled:d,value:m="on",onCheckedChange:f,form:p,...h}=t,[x,u]=g.useState(null),N=Gs(s,C=>u(C)),v=g.useRef(!1),w=x?p||!!x.closest("form"):!0,[j,b]=Bi({prop:a,defaultProp:i??!1,onChange:f,caller:yp});return e.jsxs(GH,{scope:n,checked:j,disabled:d,children:[e.jsx(js.button,{type:"button",role:"switch","aria-checked":j,"aria-required":o,"data-state":M_(j),"data-disabled":d?"":void 0,disabled:d,value:m,...h,ref:N,onClick:Kt(t.onClick,C=>{b(S=>!S),w&&(v.current=C.isPropagationStopped(),v.current||C.stopPropagation())})}),w&&e.jsx(I_,{control:x,bubbles:!v.current,name:r,value:m,checked:j,required:o,disabled:d,form:p,style:{transform:"translateX(-100%)"}})]})});P_.displayName=yp;var O_="SwitchThumb",L_=g.forwardRef((t,s)=>{const{__scopeSwitch:n,...r}=t,a=KH(O_,n);return e.jsx(js.span,{"data-state":M_(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:s})});L_.displayName=O_;var YH="SwitchBubbleInput",I_=g.forwardRef(({__scopeSwitch:t,control:s,checked:n,bubbles:r=!0,...a},i)=>{const o=g.useRef(null),d=Gs(o,i),m=Zy(n),f=Qy(s);return g.useEffect(()=>{const p=o.current;if(!p)return;const h=window.HTMLInputElement.prototype,u=Object.getOwnPropertyDescriptor(h,"checked").set;if(m!==n&&u){const N=new Event("click",{bubbles:r});u.call(p,n),p.dispatchEvent(N)}},[m,n,r]),e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:d,style:{...a.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});I_.displayName=YH;function M_(t){return t?"checked":"unchecked"}var ZH=P_,QH=L_;function bp({className:t,...s}){return e.jsx(ZH,{"data-slot":"switch",className:Nt("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-switch-background focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(QH,{"data-slot":"switch-thumb",className:Nt("bg-card dark:data-[state=unchecked]:bg-card-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}var Jg,zS;function XH(){if(zS)return Jg;zS=1;function t(){this.__data__=[],this.size=0}return Jg=t,Jg}var e0,US;function F_(){if(US)return e0;US=1;function t(s,n){return s===n||s!==s&&n!==n}return e0=t,e0}var t0,VS;function jp(){if(VS)return t0;VS=1;var t=F_();function s(n,r){for(var a=n.length;a--;)if(t(n[a][0],r))return a;return-1}return t0=s,t0}var s0,HS;function JH(){if(HS)return s0;HS=1;var t=jp(),s=Array.prototype,n=s.splice;function r(a){var i=this.__data__,o=t(i,a);if(o<0)return!1;var d=i.length-1;return o==d?i.pop():n.call(i,o,1),--this.size,!0}return s0=r,s0}var n0,WS;function eW(){if(WS)return n0;WS=1;var t=jp();function s(n){var r=this.__data__,a=t(r,n);return a<0?void 0:r[a][1]}return n0=s,n0}var r0,GS;function tW(){if(GS)return r0;GS=1;var t=jp();function s(n){return t(this.__data__,n)>-1}return r0=s,r0}var a0,KS;function sW(){if(KS)return a0;KS=1;var t=jp();function s(n,r){var a=this.__data__,i=t(a,n);return i<0?(++this.size,a.push([n,r])):a[i][1]=r,this}return a0=s,a0}var i0,YS;function Np(){if(YS)return i0;YS=1;var t=XH(),s=JH(),n=eW(),r=tW(),a=sW();function i(o){var d=-1,m=o==null?0:o.length;for(this.clear();++d<m;){var f=o[d];this.set(f[0],f[1])}}return i.prototype.clear=t,i.prototype.delete=s,i.prototype.get=n,i.prototype.has=r,i.prototype.set=a,i0=i,i0}var l0,ZS;function nW(){if(ZS)return l0;ZS=1;var t=Np();function s(){this.__data__=new t,this.size=0}return l0=s,l0}var o0,QS;function rW(){if(QS)return o0;QS=1;function t(s){var n=this.__data__,r=n.delete(s);return this.size=n.size,r}return o0=t,o0}var c0,XS;function aW(){if(XS)return c0;XS=1;function t(s){return this.__data__.get(s)}return c0=t,c0}var d0,JS;function iW(){if(JS)return d0;JS=1;function t(s){return this.__data__.has(s)}return d0=t,d0}var u0,eC;function B_(){if(eC)return u0;eC=1;var t=typeof Wo=="object"&&Wo&&Wo.Object===Object&&Wo;return u0=t,u0}var h0,tC;function jl(){if(tC)return h0;tC=1;var t=B_(),s=typeof self=="object"&&self&&self.Object===Object&&self,n=t||s||Function("return this")();return h0=n,h0}var m0,sC;function fj(){if(sC)return m0;sC=1;var t=jl(),s=t.Symbol;return m0=s,m0}var f0,nC;function lW(){if(nC)return f0;nC=1;var t=fj(),s=Object.prototype,n=s.hasOwnProperty,r=s.toString,a=t?t.toStringTag:void 0;function i(o){var d=n.call(o,a),m=o[a];try{o[a]=void 0;var f=!0}catch{}var p=r.call(o);return f&&(d?o[a]=m:delete o[a]),p}return f0=i,f0}var p0,rC;function oW(){if(rC)return p0;rC=1;var t=Object.prototype,s=t.toString;function n(r){return s.call(r)}return p0=n,p0}var x0,aC;function wp(){if(aC)return x0;aC=1;var t=fj(),s=lW(),n=oW(),r="[object Null]",a="[object Undefined]",i=t?t.toStringTag:void 0;function o(d){return d==null?d===void 0?a:r:i&&i in Object(d)?s(d):n(d)}return x0=o,x0}var g0,iC;function $_(){if(iC)return g0;iC=1;function t(s){var n=typeof s;return s!=null&&(n=="object"||n=="function")}return g0=t,g0}var v0,lC;function q_(){if(lC)return v0;lC=1;var t=wp(),s=$_(),n="[object AsyncFunction]",r="[object Function]",a="[object GeneratorFunction]",i="[object Proxy]";function o(d){if(!s(d))return!1;var m=t(d);return m==r||m==a||m==n||m==i}return v0=o,v0}var y0,oC;function cW(){if(oC)return y0;oC=1;var t=jl(),s=t["__core-js_shared__"];return y0=s,y0}var b0,cC;function dW(){if(cC)return b0;cC=1;var t=cW(),s=(function(){var r=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""})();function n(r){return!!s&&s in r}return b0=n,b0}var j0,dC;function z_(){if(dC)return j0;dC=1;var t=Function.prototype,s=t.toString;function n(r){if(r!=null){try{return s.call(r)}catch{}try{return r+""}catch{}}return""}return j0=n,j0}var N0,uC;function uW(){if(uC)return N0;uC=1;var t=q_(),s=dW(),n=$_(),r=z_(),a=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,o=Function.prototype,d=Object.prototype,m=o.toString,f=d.hasOwnProperty,p=RegExp("^"+m.call(f).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function h(x){if(!n(x)||s(x))return!1;var u=t(x)?p:i;return u.test(r(x))}return N0=h,N0}var w0,hC;function hW(){if(hC)return w0;hC=1;function t(s,n){return s==null?void 0:s[n]}return w0=t,w0}var S0,mC;function Rd(){if(mC)return S0;mC=1;var t=uW(),s=hW();function n(r,a){var i=s(r,a);return t(i)?i:void 0}return S0=n,S0}var C0,fC;function pj(){if(fC)return C0;fC=1;var t=Rd(),s=jl(),n=t(s,"Map");return C0=n,C0}var A0,pC;function Sp(){if(pC)return A0;pC=1;var t=Rd(),s=t(Object,"create");return A0=s,A0}var k0,xC;function mW(){if(xC)return k0;xC=1;var t=Sp();function s(){this.__data__=t?t(null):{},this.size=0}return k0=s,k0}var D0,gC;function fW(){if(gC)return D0;gC=1;function t(s){var n=this.has(s)&&delete this.__data__[s];return this.size-=n?1:0,n}return D0=t,D0}var R0,vC;function pW(){if(vC)return R0;vC=1;var t=Sp(),s="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function a(i){var o=this.__data__;if(t){var d=o[i];return d===s?void 0:d}return r.call(o,i)?o[i]:void 0}return R0=a,R0}var E0,yC;function xW(){if(yC)return E0;yC=1;var t=Sp(),s=Object.prototype,n=s.hasOwnProperty;function r(a){var i=this.__data__;return t?i[a]!==void 0:n.call(i,a)}return E0=r,E0}var _0,bC;function gW(){if(bC)return _0;bC=1;var t=Sp(),s="__lodash_hash_undefined__";function n(r,a){var i=this.__data__;return this.size+=this.has(r)?0:1,i[r]=t&&a===void 0?s:a,this}return _0=n,_0}var T0,jC;function vW(){if(jC)return T0;jC=1;var t=mW(),s=fW(),n=pW(),r=xW(),a=gW();function i(o){var d=-1,m=o==null?0:o.length;for(this.clear();++d<m;){var f=o[d];this.set(f[0],f[1])}}return i.prototype.clear=t,i.prototype.delete=s,i.prototype.get=n,i.prototype.has=r,i.prototype.set=a,T0=i,T0}var P0,NC;function yW(){if(NC)return P0;NC=1;var t=vW(),s=Np(),n=pj();function r(){this.size=0,this.__data__={hash:new t,map:new(n||s),string:new t}}return P0=r,P0}var O0,wC;function bW(){if(wC)return O0;wC=1;function t(s){var n=typeof s;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?s!=="__proto__":s===null}return O0=t,O0}var L0,SC;function Cp(){if(SC)return L0;SC=1;var t=bW();function s(n,r){var a=n.__data__;return t(r)?a[typeof r=="string"?"string":"hash"]:a.map}return L0=s,L0}var I0,CC;function jW(){if(CC)return I0;CC=1;var t=Cp();function s(n){var r=t(this,n).delete(n);return this.size-=r?1:0,r}return I0=s,I0}var M0,AC;function NW(){if(AC)return M0;AC=1;var t=Cp();function s(n){return t(this,n).get(n)}return M0=s,M0}var F0,kC;function wW(){if(kC)return F0;kC=1;var t=Cp();function s(n){return t(this,n).has(n)}return F0=s,F0}var B0,DC;function SW(){if(DC)return B0;DC=1;var t=Cp();function s(n,r){var a=t(this,n),i=a.size;return a.set(n,r),this.size+=a.size==i?0:1,this}return B0=s,B0}var $0,RC;function U_(){if(RC)return $0;RC=1;var t=yW(),s=jW(),n=NW(),r=wW(),a=SW();function i(o){var d=-1,m=o==null?0:o.length;for(this.clear();++d<m;){var f=o[d];this.set(f[0],f[1])}}return i.prototype.clear=t,i.prototype.delete=s,i.prototype.get=n,i.prototype.has=r,i.prototype.set=a,$0=i,$0}var q0,EC;function CW(){if(EC)return q0;EC=1;var t=Np(),s=pj(),n=U_(),r=200;function a(i,o){var d=this.__data__;if(d instanceof t){var m=d.__data__;if(!s||m.length<r-1)return m.push([i,o]),this.size=++d.size,this;d=this.__data__=new n(m)}return d.set(i,o),this.size=d.size,this}return q0=a,q0}var z0,_C;function AW(){if(_C)return z0;_C=1;var t=Np(),s=nW(),n=rW(),r=aW(),a=iW(),i=CW();function o(d){var m=this.__data__=new t(d);this.size=m.size}return o.prototype.clear=s,o.prototype.delete=n,o.prototype.get=r,o.prototype.has=a,o.prototype.set=i,z0=o,z0}var U0,TC;function kW(){if(TC)return U0;TC=1;var t="__lodash_hash_undefined__";function s(n){return this.__data__.set(n,t),this}return U0=s,U0}var V0,PC;function DW(){if(PC)return V0;PC=1;function t(s){return this.__data__.has(s)}return V0=t,V0}var H0,OC;function RW(){if(OC)return H0;OC=1;var t=U_(),s=kW(),n=DW();function r(a){var i=-1,o=a==null?0:a.length;for(this.__data__=new t;++i<o;)this.add(a[i])}return r.prototype.add=r.prototype.push=s,r.prototype.has=n,H0=r,H0}var W0,LC;function EW(){if(LC)return W0;LC=1;function t(s,n){for(var r=-1,a=s==null?0:s.length;++r<a;)if(n(s[r],r,s))return!0;return!1}return W0=t,W0}var G0,IC;function _W(){if(IC)return G0;IC=1;function t(s,n){return s.has(n)}return G0=t,G0}var K0,MC;function V_(){if(MC)return K0;MC=1;var t=RW(),s=EW(),n=_W(),r=1,a=2;function i(o,d,m,f,p,h){var x=m&r,u=o.length,N=d.length;if(u!=N&&!(x&&N>u))return!1;var v=h.get(o),w=h.get(d);if(v&&w)return v==d&&w==o;var j=-1,b=!0,C=m&a?new t:void 0;for(h.set(o,d),h.set(d,o);++j<u;){var S=o[j],R=d[j];if(f)var _=x?f(R,S,j,d,o,h):f(S,R,j,o,d,h);if(_!==void 0){if(_)continue;b=!1;break}if(C){if(!s(d,function(A,E){if(!n(C,E)&&(S===A||p(S,A,m,f,h)))return C.push(E)})){b=!1;break}}else if(!(S===R||p(S,R,m,f,h))){b=!1;break}}return h.delete(o),h.delete(d),b}return K0=i,K0}var Y0,FC;function TW(){if(FC)return Y0;FC=1;var t=jl(),s=t.Uint8Array;return Y0=s,Y0}var Z0,BC;function PW(){if(BC)return Z0;BC=1;function t(s){var n=-1,r=Array(s.size);return s.forEach(function(a,i){r[++n]=[i,a]}),r}return Z0=t,Z0}var Q0,$C;function OW(){if($C)return Q0;$C=1;function t(s){var n=-1,r=Array(s.size);return s.forEach(function(a){r[++n]=a}),r}return Q0=t,Q0}var X0,qC;function LW(){if(qC)return X0;qC=1;var t=fj(),s=TW(),n=F_(),r=V_(),a=PW(),i=OW(),o=1,d=2,m="[object Boolean]",f="[object Date]",p="[object Error]",h="[object Map]",x="[object Number]",u="[object RegExp]",N="[object Set]",v="[object String]",w="[object Symbol]",j="[object ArrayBuffer]",b="[object DataView]",C=t?t.prototype:void 0,S=C?C.valueOf:void 0;function R(_,A,E,q,O,D,P){switch(E){case b:if(_.byteLength!=A.byteLength||_.byteOffset!=A.byteOffset)return!1;_=_.buffer,A=A.buffer;case j:return!(_.byteLength!=A.byteLength||!D(new s(_),new s(A)));case m:case f:case x:return n(+_,+A);case p:return _.name==A.name&&_.message==A.message;case u:case v:return _==A+"";case h:var L=a;case N:var $=q&o;if(L||(L=i),_.size!=A.size&&!$)return!1;var Y=P.get(_);if(Y)return Y==A;q|=d,P.set(_,A);var Z=r(L(_),L(A),q,O,D,P);return P.delete(_),Z;case w:if(S)return S.call(_)==S.call(A)}return!1}return X0=R,X0}var J0,zC;function IW(){if(zC)return J0;zC=1;function t(s,n){for(var r=-1,a=n.length,i=s.length;++r<a;)s[i+r]=n[r];return s}return J0=t,J0}var ev,UC;function xj(){if(UC)return ev;UC=1;var t=Array.isArray;return ev=t,ev}var tv,VC;function MW(){if(VC)return tv;VC=1;var t=IW(),s=xj();function n(r,a,i){var o=a(r);return s(r)?o:t(o,i(r))}return tv=n,tv}var sv,HC;function FW(){if(HC)return sv;HC=1;function t(s,n){for(var r=-1,a=s==null?0:s.length,i=0,o=[];++r<a;){var d=s[r];n(d,r,s)&&(o[i++]=d)}return o}return sv=t,sv}var nv,WC;function BW(){if(WC)return nv;WC=1;function t(){return[]}return nv=t,nv}var rv,GC;function $W(){if(GC)return rv;GC=1;var t=FW(),s=BW(),n=Object.prototype,r=n.propertyIsEnumerable,a=Object.getOwnPropertySymbols,i=a?function(o){return o==null?[]:(o=Object(o),t(a(o),function(d){return r.call(o,d)}))}:s;return rv=i,rv}var av,KC;function qW(){if(KC)return av;KC=1;function t(s,n){for(var r=-1,a=Array(s);++r<s;)a[r]=n(r);return a}return av=t,av}var iv,YC;function Ap(){if(YC)return iv;YC=1;function t(s){return s!=null&&typeof s=="object"}return iv=t,iv}var lv,ZC;function zW(){if(ZC)return lv;ZC=1;var t=wp(),s=Ap(),n="[object Arguments]";function r(a){return s(a)&&t(a)==n}return lv=r,lv}var ov,QC;function UW(){if(QC)return ov;QC=1;var t=zW(),s=Ap(),n=Object.prototype,r=n.hasOwnProperty,a=n.propertyIsEnumerable,i=t((function(){return arguments})())?t:function(o){return s(o)&&r.call(o,"callee")&&!a.call(o,"callee")};return ov=i,ov}var xu={exports:{}},cv,XC;function VW(){if(XC)return cv;XC=1;function t(){return!1}return cv=t,cv}xu.exports;var JC;function H_(){return JC||(JC=1,(function(t,s){var n=jl(),r=VW(),a=s&&!s.nodeType&&s,i=a&&!0&&t&&!t.nodeType&&t,o=i&&i.exports===a,d=o?n.Buffer:void 0,m=d?d.isBuffer:void 0,f=m||r;t.exports=f})(xu,xu.exports)),xu.exports}var dv,e2;function HW(){if(e2)return dv;e2=1;var t=9007199254740991,s=/^(?:0|[1-9]\d*)$/;function n(r,a){var i=typeof r;return a=a??t,!!a&&(i=="number"||i!="symbol"&&s.test(r))&&r>-1&&r%1==0&&r<a}return dv=n,dv}var uv,t2;function W_(){if(t2)return uv;t2=1;var t=9007199254740991;function s(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=t}return uv=s,uv}var hv,s2;function WW(){if(s2)return hv;s2=1;var t=wp(),s=W_(),n=Ap(),r="[object Arguments]",a="[object Array]",i="[object Boolean]",o="[object Date]",d="[object Error]",m="[object Function]",f="[object Map]",p="[object Number]",h="[object Object]",x="[object RegExp]",u="[object Set]",N="[object String]",v="[object WeakMap]",w="[object ArrayBuffer]",j="[object DataView]",b="[object Float32Array]",C="[object Float64Array]",S="[object Int8Array]",R="[object Int16Array]",_="[object Int32Array]",A="[object Uint8Array]",E="[object Uint8ClampedArray]",q="[object Uint16Array]",O="[object Uint32Array]",D={};D[b]=D[C]=D[S]=D[R]=D[_]=D[A]=D[E]=D[q]=D[O]=!0,D[r]=D[a]=D[w]=D[i]=D[j]=D[o]=D[d]=D[m]=D[f]=D[p]=D[h]=D[x]=D[u]=D[N]=D[v]=!1;function P(L){return n(L)&&s(L.length)&&!!D[t(L)]}return hv=P,hv}var mv,n2;function GW(){if(n2)return mv;n2=1;function t(s){return function(n){return s(n)}}return mv=t,mv}var gu={exports:{}};gu.exports;var r2;function KW(){return r2||(r2=1,(function(t,s){var n=B_(),r=s&&!s.nodeType&&s,a=r&&!0&&t&&!t.nodeType&&t,i=a&&a.exports===r,o=i&&n.process,d=(function(){try{var m=a&&a.require&&a.require("util").types;return m||o&&o.binding&&o.binding("util")}catch{}})();t.exports=d})(gu,gu.exports)),gu.exports}var fv,a2;function G_(){if(a2)return fv;a2=1;var t=WW(),s=GW(),n=KW(),r=n&&n.isTypedArray,a=r?s(r):t;return fv=a,fv}var pv,i2;function YW(){if(i2)return pv;i2=1;var t=qW(),s=UW(),n=xj(),r=H_(),a=HW(),i=G_(),o=Object.prototype,d=o.hasOwnProperty;function m(f,p){var h=n(f),x=!h&&s(f),u=!h&&!x&&r(f),N=!h&&!x&&!u&&i(f),v=h||x||u||N,w=v?t(f.length,String):[],j=w.length;for(var b in f)(p||d.call(f,b))&&!(v&&(b=="length"||u&&(b=="offset"||b=="parent")||N&&(b=="buffer"||b=="byteLength"||b=="byteOffset")||a(b,j)))&&w.push(b);return w}return pv=m,pv}var xv,l2;function ZW(){if(l2)return xv;l2=1;var t=Object.prototype;function s(n){var r=n&&n.constructor,a=typeof r=="function"&&r.prototype||t;return n===a}return xv=s,xv}var gv,o2;function QW(){if(o2)return gv;o2=1;function t(s,n){return function(r){return s(n(r))}}return gv=t,gv}var vv,c2;function XW(){if(c2)return vv;c2=1;var t=QW(),s=t(Object.keys,Object);return vv=s,vv}var yv,d2;function JW(){if(d2)return yv;d2=1;var t=ZW(),s=XW(),n=Object.prototype,r=n.hasOwnProperty;function a(i){if(!t(i))return s(i);var o=[];for(var d in Object(i))r.call(i,d)&&d!="constructor"&&o.push(d);return o}return yv=a,yv}var bv,u2;function eG(){if(u2)return bv;u2=1;var t=q_(),s=W_();function n(r){return r!=null&&s(r.length)&&!t(r)}return bv=n,bv}var jv,h2;function tG(){if(h2)return jv;h2=1;var t=YW(),s=JW(),n=eG();function r(a){return n(a)?t(a):s(a)}return jv=r,jv}var Nv,m2;function sG(){if(m2)return Nv;m2=1;var t=MW(),s=$W(),n=tG();function r(a){return t(a,n,s)}return Nv=r,Nv}var wv,f2;function nG(){if(f2)return wv;f2=1;var t=sG(),s=1,n=Object.prototype,r=n.hasOwnProperty;function a(i,o,d,m,f,p){var h=d&s,x=t(i),u=x.length,N=t(o),v=N.length;if(u!=v&&!h)return!1;for(var w=u;w--;){var j=x[w];if(!(h?j in o:r.call(o,j)))return!1}var b=p.get(i),C=p.get(o);if(b&&C)return b==o&&C==i;var S=!0;p.set(i,o),p.set(o,i);for(var R=h;++w<u;){j=x[w];var _=i[j],A=o[j];if(m)var E=h?m(A,_,j,o,i,p):m(_,A,j,i,o,p);if(!(E===void 0?_===A||f(_,A,d,m,p):E)){S=!1;break}R||(R=j=="constructor")}if(S&&!R){var q=i.constructor,O=o.constructor;q!=O&&"constructor"in i&&"constructor"in o&&!(typeof q=="function"&&q instanceof q&&typeof O=="function"&&O instanceof O)&&(S=!1)}return p.delete(i),p.delete(o),S}return wv=a,wv}var Sv,p2;function rG(){if(p2)return Sv;p2=1;var t=Rd(),s=jl(),n=t(s,"DataView");return Sv=n,Sv}var Cv,x2;function aG(){if(x2)return Cv;x2=1;var t=Rd(),s=jl(),n=t(s,"Promise");return Cv=n,Cv}var Av,g2;function iG(){if(g2)return Av;g2=1;var t=Rd(),s=jl(),n=t(s,"Set");return Av=n,Av}var kv,v2;function lG(){if(v2)return kv;v2=1;var t=Rd(),s=jl(),n=t(s,"WeakMap");return kv=n,kv}var Dv,y2;function oG(){if(y2)return Dv;y2=1;var t=rG(),s=pj(),n=aG(),r=iG(),a=lG(),i=wp(),o=z_(),d="[object Map]",m="[object Object]",f="[object Promise]",p="[object Set]",h="[object WeakMap]",x="[object DataView]",u=o(t),N=o(s),v=o(n),w=o(r),j=o(a),b=i;return(t&&b(new t(new ArrayBuffer(1)))!=x||s&&b(new s)!=d||n&&b(n.resolve())!=f||r&&b(new r)!=p||a&&b(new a)!=h)&&(b=function(C){var S=i(C),R=S==m?C.constructor:void 0,_=R?o(R):"";if(_)switch(_){case u:return x;case N:return d;case v:return f;case w:return p;case j:return h}return S}),Dv=b,Dv}var Rv,b2;function cG(){if(b2)return Rv;b2=1;var t=AW(),s=V_(),n=LW(),r=nG(),a=oG(),i=xj(),o=H_(),d=G_(),m=1,f="[object Arguments]",p="[object Array]",h="[object Object]",x=Object.prototype,u=x.hasOwnProperty;function N(v,w,j,b,C,S){var R=i(v),_=i(w),A=R?p:a(v),E=_?p:a(w);A=A==f?h:A,E=E==f?h:E;var q=A==h,O=E==h,D=A==E;if(D&&o(v)){if(!o(w))return!1;R=!0,q=!1}if(D&&!q)return S||(S=new t),R||d(v)?s(v,w,j,b,C,S):n(v,w,A,j,b,C,S);if(!(j&m)){var P=q&&u.call(v,"__wrapped__"),L=O&&u.call(w,"__wrapped__");if(P||L){var $=P?v.value():v,Y=L?w.value():w;return S||(S=new t),C($,Y,j,b,S)}}return D?(S||(S=new t),r(v,w,j,b,C,S)):!1}return Rv=N,Rv}var Ev,j2;function dG(){if(j2)return Ev;j2=1;var t=cG(),s=Ap();function n(r,a,i,o,d){return r===a?!0:r==null||a==null||!s(r)&&!s(a)?r!==r&&a!==a:t(r,a,i,o,n,d)}return Ev=n,Ev}var _v,N2;function uG(){if(N2)return _v;N2=1;var t=dG();function s(n,r){return t(n,r)}return _v=s,_v}var Gm={exports:{}};/*!
* Quill Editor v1.3.7
* https://quilljs.com/
* Copyright (c) 2014, Jason Chen
* Copyright (c) 2013, salesforce.com
*/var hG=Gm.exports,w2;function mG(){return w2||(w2=1,(function(t,s){(function(r,a){t.exports=a()})(typeof self<"u"?self:hG,function(){return(function(n){var r={};function a(i){if(r[i])return r[i].exports;var o=r[i]={i,l:!1,exports:{}};return n[i].call(o.exports,o,o.exports,a),o.l=!0,o.exports}return a.m=n,a.c=r,a.d=function(i,o,d){a.o(i,o)||Object.defineProperty(i,o,{configurable:!1,enumerable:!0,get:d})},a.n=function(i){var o=i&&i.__esModule?function(){return i.default}:function(){return i};return a.d(o,"a",o),o},a.o=function(i,o){return Object.prototype.hasOwnProperty.call(i,o)},a.p="",a(a.s=109)})([(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(17),o=a(18),d=a(19),m=a(45),f=a(46),p=a(47),h=a(48),x=a(49),u=a(12),N=a(32),v=a(33),w=a(31),j=a(1),b={Scope:j.Scope,create:j.create,find:j.find,query:j.query,register:j.register,Container:i.default,Format:o.default,Leaf:d.default,Embed:h.default,Scroll:m.default,Block:p.default,Inline:f.default,Text:x.default,Attributor:{Attribute:u.default,Class:N.default,Style:v.default,Store:w.default}};r.default=b}),(function(n,r,a){var i=this&&this.__extends||(function(){var w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(j,b){j.__proto__=b}||function(j,b){for(var C in b)b.hasOwnProperty(C)&&(j[C]=b[C])};return function(j,b){w(j,b);function C(){this.constructor=j}j.prototype=b===null?Object.create(b):(C.prototype=b.prototype,new C)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=(function(w){i(j,w);function j(b){var C=this;return b="[Parchment] "+b,C=w.call(this,b)||this,C.message=b,C.name=C.constructor.name,C}return j})(Error);r.ParchmentError=o;var d={},m={},f={},p={};r.DATA_KEY="__blot";var h;(function(w){w[w.TYPE=3]="TYPE",w[w.LEVEL=12]="LEVEL",w[w.ATTRIBUTE=13]="ATTRIBUTE",w[w.BLOT=14]="BLOT",w[w.INLINE=7]="INLINE",w[w.BLOCK=11]="BLOCK",w[w.BLOCK_BLOT=10]="BLOCK_BLOT",w[w.INLINE_BLOT=6]="INLINE_BLOT",w[w.BLOCK_ATTRIBUTE=9]="BLOCK_ATTRIBUTE",w[w.INLINE_ATTRIBUTE=5]="INLINE_ATTRIBUTE",w[w.ANY=15]="ANY"})(h=r.Scope||(r.Scope={}));function x(w,j){var b=N(w);if(b==null)throw new o("Unable to create "+w+" blot");var C=b,S=w instanceof Node||w.nodeType===Node.TEXT_NODE?w:C.create(j);return new C(S,j)}r.create=x;function u(w,j){return j===void 0&&(j=!1),w==null?null:w[r.DATA_KEY]!=null?w[r.DATA_KEY].blot:j?u(w.parentNode,j):null}r.find=u;function N(w,j){j===void 0&&(j=h.ANY);var b;if(typeof w=="string")b=p[w]||d[w];else if(w instanceof Text||w.nodeType===Node.TEXT_NODE)b=p.text;else if(typeof w=="number")w&h.LEVEL&h.BLOCK?b=p.block:w&h.LEVEL&h.INLINE&&(b=p.inline);else if(w instanceof HTMLElement){var C=(w.getAttribute("class")||"").split(/\s+/);for(var S in C)if(b=m[C[S]],b)break;b=b||f[w.tagName]}return b==null?null:j&h.LEVEL&b.scope&&j&h.TYPE&b.scope?b:null}r.query=N;function v(){for(var w=[],j=0;j<arguments.length;j++)w[j]=arguments[j];if(w.length>1)return w.map(function(S){return v(S)});var b=w[0];if(typeof b.blotName!="string"&&typeof b.attrName!="string")throw new o("Invalid definition");if(b.blotName==="abstract")throw new o("Cannot register abstract class");if(p[b.blotName||b.attrName]=b,typeof b.keyName=="string")d[b.keyName]=b;else if(b.className!=null&&(m[b.className]=b),b.tagName!=null){Array.isArray(b.tagName)?b.tagName=b.tagName.map(function(S){return S.toUpperCase()}):b.tagName=b.tagName.toUpperCase();var C=Array.isArray(b.tagName)?b.tagName:[b.tagName];C.forEach(function(S){(f[S]==null||b.className==null)&&(f[S]=b)})}return b}r.register=v}),(function(n,r,a){var i=a(51),o=a(11),d=a(3),m=a(20),f="\0",p=function(h){Array.isArray(h)?this.ops=h:h!=null&&Array.isArray(h.ops)?this.ops=h.ops:this.ops=[]};p.prototype.insert=function(h,x){var u={};return h.length===0?this:(u.insert=h,x!=null&&typeof x=="object"&&Object.keys(x).length>0&&(u.attributes=x),this.push(u))},p.prototype.delete=function(h){return h<=0?this:this.push({delete:h})},p.prototype.retain=function(h,x){if(h<=0)return this;var u={retain:h};return x!=null&&typeof x=="object"&&Object.keys(x).length>0&&(u.attributes=x),this.push(u)},p.prototype.push=function(h){var x=this.ops.length,u=this.ops[x-1];if(h=d(!0,{},h),typeof u=="object"){if(typeof h.delete=="number"&&typeof u.delete=="number")return this.ops[x-1]={delete:u.delete+h.delete},this;if(typeof u.delete=="number"&&h.insert!=null&&(x-=1,u=this.ops[x-1],typeof u!="object"))return this.ops.unshift(h),this;if(o(h.attributes,u.attributes)){if(typeof h.insert=="string"&&typeof u.insert=="string")return this.ops[x-1]={insert:u.insert+h.insert},typeof h.attributes=="object"&&(this.ops[x-1].attributes=h.attributes),this;if(typeof h.retain=="number"&&typeof u.retain=="number")return this.ops[x-1]={retain:u.retain+h.retain},typeof h.attributes=="object"&&(this.ops[x-1].attributes=h.attributes),this}}return x===this.ops.length?this.ops.push(h):this.ops.splice(x,0,h),this},p.prototype.chop=function(){var h=this.ops[this.ops.length-1];return h&&h.retain&&!h.attributes&&this.ops.pop(),this},p.prototype.filter=function(h){return this.ops.filter(h)},p.prototype.forEach=function(h){this.ops.forEach(h)},p.prototype.map=function(h){return this.ops.map(h)},p.prototype.partition=function(h){var x=[],u=[];return this.forEach(function(N){var v=h(N)?x:u;v.push(N)}),[x,u]},p.prototype.reduce=function(h,x){return this.ops.reduce(h,x)},p.prototype.changeLength=function(){return this.reduce(function(h,x){return x.insert?h+m.length(x):x.delete?h-x.delete:h},0)},p.prototype.length=function(){return this.reduce(function(h,x){return h+m.length(x)},0)},p.prototype.slice=function(h,x){h=h||0,typeof x!="number"&&(x=1/0);for(var u=[],N=m.iterator(this.ops),v=0;v<x&&N.hasNext();){var w;v<h?w=N.next(h-v):(w=N.next(x-v),u.push(w)),v+=m.length(w)}return new p(u)},p.prototype.compose=function(h){var x=m.iterator(this.ops),u=m.iterator(h.ops),N=[],v=u.peek();if(v!=null&&typeof v.retain=="number"&&v.attributes==null){for(var w=v.retain;x.peekType()==="insert"&&x.peekLength()<=w;)w-=x.peekLength(),N.push(x.next());v.retain-w>0&&u.next(v.retain-w)}for(var j=new p(N);x.hasNext()||u.hasNext();)if(u.peekType()==="insert")j.push(u.next());else if(x.peekType()==="delete")j.push(x.next());else{var b=Math.min(x.peekLength(),u.peekLength()),C=x.next(b),S=u.next(b);if(typeof S.retain=="number"){var R={};typeof C.retain=="number"?R.retain=b:R.insert=C.insert;var _=m.attributes.compose(C.attributes,S.attributes,typeof C.retain=="number");if(_&&(R.attributes=_),j.push(R),!u.hasNext()&&o(j.ops[j.ops.length-1],R)){var A=new p(x.rest());return j.concat(A).chop()}}else typeof S.delete=="number"&&typeof C.retain=="number"&&j.push(S)}return j.chop()},p.prototype.concat=function(h){var x=new p(this.ops.slice());return h.ops.length>0&&(x.push(h.ops[0]),x.ops=x.ops.concat(h.ops.slice(1))),x},p.prototype.diff=function(h,x){if(this.ops===h.ops)return new p;var u=[this,h].map(function(b){return b.map(function(C){if(C.insert!=null)return typeof C.insert=="string"?C.insert:f;var S=b===h?"on":"with";throw new Error("diff() called "+S+" non-document")}).join("")}),N=new p,v=i(u[0],u[1],x),w=m.iterator(this.ops),j=m.iterator(h.ops);return v.forEach(function(b){for(var C=b[1].length;C>0;){var S=0;switch(b[0]){case i.INSERT:S=Math.min(j.peekLength(),C),N.push(j.next(S));break;case i.DELETE:S=Math.min(C,w.peekLength()),w.next(S),N.delete(S);break;case i.EQUAL:S=Math.min(w.peekLength(),j.peekLength(),C);var R=w.next(S),_=j.next(S);o(R.insert,_.insert)?N.retain(S,m.attributes.diff(R.attributes,_.attributes)):N.push(_).delete(S);break}C-=S}}),N.chop()},p.prototype.eachLine=function(h,x){x=x||`
`;for(var u=m.iterator(this.ops),N=new p,v=0;u.hasNext();){if(u.peekType()!=="insert")return;var w=u.peek(),j=m.length(w)-u.peekLength(),b=typeof w.insert=="string"?w.insert.indexOf(x,j)-j:-1;if(b<0)N.push(u.next());else if(b>0)N.push(u.next(b));else{if(h(N,u.next(1).attributes||{},v)===!1)return;v+=1,N=new p}}N.length()>0&&h(N,{},v)},p.prototype.transform=function(h,x){if(x=!!x,typeof h=="number")return this.transformPosition(h,x);for(var u=m.iterator(this.ops),N=m.iterator(h.ops),v=new p;u.hasNext()||N.hasNext();)if(u.peekType()==="insert"&&(x||N.peekType()!=="insert"))v.retain(m.length(u.next()));else if(N.peekType()==="insert")v.push(N.next());else{var w=Math.min(u.peekLength(),N.peekLength()),j=u.next(w),b=N.next(w);if(j.delete)continue;b.delete?v.push(b):v.retain(w,m.attributes.transform(j.attributes,b.attributes,x))}return v.chop()},p.prototype.transformPosition=function(h,x){x=!!x;for(var u=m.iterator(this.ops),N=0;u.hasNext()&&N<=h;){var v=u.peekLength(),w=u.peekType();if(u.next(),w==="delete"){h-=Math.min(v,h-N);continue}else w==="insert"&&(N<h||!x)&&(h+=v);N+=v}return h},n.exports=p}),(function(n,r){var a=Object.prototype.hasOwnProperty,i=Object.prototype.toString,o=Object.defineProperty,d=Object.getOwnPropertyDescriptor,m=function(u){return typeof Array.isArray=="function"?Array.isArray(u):i.call(u)==="[object Array]"},f=function(u){if(!u||i.call(u)!=="[object Object]")return!1;var N=a.call(u,"constructor"),v=u.constructor&&u.constructor.prototype&&a.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!N&&!v)return!1;var w;for(w in u);return typeof w>"u"||a.call(u,w)},p=function(u,N){o&&N.name==="__proto__"?o(u,N.name,{enumerable:!0,configurable:!0,value:N.newValue,writable:!0}):u[N.name]=N.newValue},h=function(u,N){if(N==="__proto__")if(a.call(u,N)){if(d)return d(u,N).value}else return;return u[N]};n.exports=function x(){var u,N,v,w,j,b,C=arguments[0],S=1,R=arguments.length,_=!1;for(typeof C=="boolean"&&(_=C,C=arguments[1]||{},S=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});S<R;++S)if(u=arguments[S],u!=null)for(N in u)v=h(C,N),w=h(u,N),C!==w&&(_&&w&&(f(w)||(j=m(w)))?(j?(j=!1,b=v&&m(v)?v:[]):b=v&&f(v)?v:{},p(C,{name:N,newValue:x(_,b,w)})):typeof w<"u"&&p(C,{name:N,newValue:w}));return C}}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.BlockEmbed=r.bubbleFormats=void 0;var i=(function(){function D(P,L){for(var $=0;$<L.length;$++){var Y=L[$];Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y&&(Y.writable=!0),Object.defineProperty(P,Y.key,Y)}}return function(P,L,$){return L&&D(P.prototype,L),$&&D(P,$),P}})(),o=function D(P,L,$){P===null&&(P=Function.prototype);var Y=Object.getOwnPropertyDescriptor(P,L);if(Y===void 0){var Z=Object.getPrototypeOf(P);return Z===null?void 0:D(Z,L,$)}else{if("value"in Y)return Y.value;var W=Y.get;return W===void 0?void 0:W.call($)}},d=a(3),m=C(d),f=a(2),p=C(f),h=a(0),x=C(h),u=a(16),N=C(u),v=a(6),w=C(v),j=a(7),b=C(j);function C(D){return D&&D.__esModule?D:{default:D}}function S(D,P){if(!(D instanceof P))throw new TypeError("Cannot call a class as a function")}function R(D,P){if(!D)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return P&&(typeof P=="object"||typeof P=="function")?P:D}function _(D,P){if(typeof P!="function"&&P!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof P);D.prototype=Object.create(P&&P.prototype,{constructor:{value:D,enumerable:!1,writable:!0,configurable:!0}}),P&&(Object.setPrototypeOf?Object.setPrototypeOf(D,P):D.__proto__=P)}var A=1,E=(function(D){_(P,D);function P(){return S(this,P),R(this,(P.__proto__||Object.getPrototypeOf(P)).apply(this,arguments))}return i(P,[{key:"attach",value:function(){o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"attach",this).call(this),this.attributes=new x.default.Attributor.Store(this.domNode)}},{key:"delta",value:function(){return new p.default().insert(this.value(),(0,m.default)(this.formats(),this.attributes.values()))}},{key:"format",value:function($,Y){var Z=x.default.query($,x.default.Scope.BLOCK_ATTRIBUTE);Z!=null&&this.attributes.attribute(Z,Y)}},{key:"formatAt",value:function($,Y,Z,W){this.format(Z,W)}},{key:"insertAt",value:function($,Y,Z){if(typeof Y=="string"&&Y.endsWith(`
`)){var W=x.default.create(q.blotName);this.parent.insertBefore(W,$===0?this:this.next),W.insertAt(0,Y.slice(0,-1))}else o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"insertAt",this).call(this,$,Y,Z)}}]),P})(x.default.Embed);E.scope=x.default.Scope.BLOCK_BLOT;var q=(function(D){_(P,D);function P(L){S(this,P);var $=R(this,(P.__proto__||Object.getPrototypeOf(P)).call(this,L));return $.cache={},$}return i(P,[{key:"delta",value:function(){return this.cache.delta==null&&(this.cache.delta=this.descendants(x.default.Leaf).reduce(function($,Y){return Y.length()===0?$:$.insert(Y.value(),O(Y))},new p.default).insert(`
`,O(this))),this.cache.delta}},{key:"deleteAt",value:function($,Y){o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"deleteAt",this).call(this,$,Y),this.cache={}}},{key:"formatAt",value:function($,Y,Z,W){Y<=0||(x.default.query(Z,x.default.Scope.BLOCK)?$+Y===this.length()&&this.format(Z,W):o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"formatAt",this).call(this,$,Math.min(Y,this.length()-$-1),Z,W),this.cache={})}},{key:"insertAt",value:function($,Y,Z){if(Z!=null)return o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"insertAt",this).call(this,$,Y,Z);if(Y.length!==0){var W=Y.split(`
`),U=W.shift();U.length>0&&($<this.length()-1||this.children.tail==null?o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"insertAt",this).call(this,Math.min($,this.length()-1),U):this.children.tail.insertAt(this.children.tail.length(),U),this.cache={});var M=this;W.reduce(function(z,T){return M=M.split(z,!0),M.insertAt(0,T),T.length},$+U.length)}}},{key:"insertBefore",value:function($,Y){var Z=this.children.head;o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"insertBefore",this).call(this,$,Y),Z instanceof N.default&&Z.remove(),this.cache={}}},{key:"length",value:function(){return this.cache.length==null&&(this.cache.length=o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"length",this).call(this)+A),this.cache.length}},{key:"moveChildren",value:function($,Y){o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"moveChildren",this).call(this,$,Y),this.cache={}}},{key:"optimize",value:function($){o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"optimize",this).call(this,$),this.cache={}}},{key:"path",value:function($){return o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"path",this).call(this,$,!0)}},{key:"removeChild",value:function($){o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"removeChild",this).call(this,$),this.cache={}}},{key:"split",value:function($){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(Y&&($===0||$>=this.length()-A)){var Z=this.clone();return $===0?(this.parent.insertBefore(Z,this),this):(this.parent.insertBefore(Z,this.next),Z)}else{var W=o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"split",this).call(this,$,Y);return this.cache={},W}}}]),P})(x.default.Block);q.blotName="block",q.tagName="P",q.defaultChild="break",q.allowedChildren=[w.default,x.default.Embed,b.default];function O(D){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return D==null||(typeof D.formats=="function"&&(P=(0,m.default)(P,D.formats())),D.parent==null||D.parent.blotName=="scroll"||D.parent.statics.scope!==D.statics.scope)?P:O(D.parent,P)}r.bubbleFormats=O,r.BlockEmbed=E,r.default=q}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.overload=r.expandConfig=void 0;var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(M){return typeof M}:function(M){return M&&typeof Symbol=="function"&&M.constructor===Symbol&&M!==Symbol.prototype?"symbol":typeof M},o=(function(){function M(z,T){var I=[],B=!0,G=!1,K=void 0;try{for(var H=z[Symbol.iterator](),X;!(B=(X=H.next()).done)&&(I.push(X.value),!(T&&I.length===T));B=!0);}catch(J){G=!0,K=J}finally{try{!B&&H.return&&H.return()}finally{if(G)throw K}}return I}return function(z,T){if(Array.isArray(z))return z;if(Symbol.iterator in Object(z))return M(z,T);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function M(z,T){for(var I=0;I<T.length;I++){var B=T[I];B.enumerable=B.enumerable||!1,B.configurable=!0,"value"in B&&(B.writable=!0),Object.defineProperty(z,B.key,B)}}return function(z,T,I){return T&&M(z.prototype,T),I&&M(z,I),z}})();a(50);var m=a(2),f=O(m),p=a(14),h=O(p),x=a(8),u=O(x),N=a(9),v=O(N),w=a(0),j=O(w),b=a(15),C=O(b),S=a(3),R=O(S),_=a(10),A=O(_),E=a(34),q=O(E);function O(M){return M&&M.__esModule?M:{default:M}}function D(M,z,T){return z in M?Object.defineProperty(M,z,{value:T,enumerable:!0,configurable:!0,writable:!0}):M[z]=T,M}function P(M,z){if(!(M instanceof z))throw new TypeError("Cannot call a class as a function")}var L=(0,A.default)("quill"),$=(function(){d(M,null,[{key:"debug",value:function(T){T===!0&&(T="log"),A.default.level(T)}},{key:"find",value:function(T){return T.__quill||j.default.find(T)}},{key:"import",value:function(T){return this.imports[T]==null&&L.error("Cannot import "+T+". Are you sure it was registered?"),this.imports[T]}},{key:"register",value:function(T,I){var B=this,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(typeof T!="string"){var K=T.attrName||T.blotName;typeof K=="string"?this.register("formats/"+K,T,I):Object.keys(T).forEach(function(H){B.register(H,T[H],I)})}else this.imports[T]!=null&&!G&&L.warn("Overwriting "+T+" with",I),this.imports[T]=I,(T.startsWith("blots/")||T.startsWith("formats/"))&&I.blotName!=="abstract"?j.default.register(I):T.startsWith("modules")&&typeof I.register=="function"&&I.register()}}]);function M(z){var T=this,I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(P(this,M),this.options=Y(z,I),this.container=this.options.container,this.container==null)return L.error("Invalid Quill container",z);this.options.debug&&M.debug(this.options.debug);var B=this.container.innerHTML.trim();this.container.classList.add("ql-container"),this.container.innerHTML="",this.container.__quill=this,this.root=this.addContainer("ql-editor"),this.root.classList.add("ql-blank"),this.root.setAttribute("data-gramm",!1),this.scrollingContainer=this.options.scrollingContainer||this.root,this.emitter=new u.default,this.scroll=j.default.create(this.root,{emitter:this.emitter,whitelist:this.options.formats}),this.editor=new h.default(this.scroll),this.selection=new C.default(this.scroll,this.emitter),this.theme=new this.options.theme(this,this.options),this.keyboard=this.theme.addModule("keyboard"),this.clipboard=this.theme.addModule("clipboard"),this.history=this.theme.addModule("history"),this.theme.init(),this.emitter.on(u.default.events.EDITOR_CHANGE,function(K){K===u.default.events.TEXT_CHANGE&&T.root.classList.toggle("ql-blank",T.editor.isBlank())}),this.emitter.on(u.default.events.SCROLL_UPDATE,function(K,H){var X=T.selection.lastRange,J=X&&X.length===0?X.index:void 0;Z.call(T,function(){return T.editor.update(null,H,J)},K)});var G=this.clipboard.convert(`<div class='ql-editor' style="white-space: normal;">`+B+"<p><br></p></div>");this.setContents(G),this.history.clear(),this.options.placeholder&&this.root.setAttribute("data-placeholder",this.options.placeholder),this.options.readOnly&&this.disable()}return d(M,[{key:"addContainer",value:function(T){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(typeof T=="string"){var B=T;T=document.createElement("div"),T.classList.add(B)}return this.container.insertBefore(T,I),T}},{key:"blur",value:function(){this.selection.setRange(null)}},{key:"deleteText",value:function(T,I,B){var G=this,K=W(T,I,B),H=o(K,4);return T=H[0],I=H[1],B=H[3],Z.call(this,function(){return G.editor.deleteText(T,I)},B,T,-1*I)}},{key:"disable",value:function(){this.enable(!1)}},{key:"enable",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.scroll.enable(T),this.container.classList.toggle("ql-disabled",!T)}},{key:"focus",value:function(){var T=this.scrollingContainer.scrollTop;this.selection.focus(),this.scrollingContainer.scrollTop=T,this.scrollIntoView()}},{key:"format",value:function(T,I){var B=this,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:u.default.sources.API;return Z.call(this,function(){var K=B.getSelection(!0),H=new f.default;if(K==null)return H;if(j.default.query(T,j.default.Scope.BLOCK))H=B.editor.formatLine(K.index,K.length,D({},T,I));else{if(K.length===0)return B.selection.format(T,I),H;H=B.editor.formatText(K.index,K.length,D({},T,I))}return B.setSelection(K,u.default.sources.SILENT),H},G)}},{key:"formatLine",value:function(T,I,B,G,K){var H=this,X=void 0,J=W(T,I,B,G,K),ae=o(J,4);return T=ae[0],I=ae[1],X=ae[2],K=ae[3],Z.call(this,function(){return H.editor.formatLine(T,I,X)},K,T,0)}},{key:"formatText",value:function(T,I,B,G,K){var H=this,X=void 0,J=W(T,I,B,G,K),ae=o(J,4);return T=ae[0],I=ae[1],X=ae[2],K=ae[3],Z.call(this,function(){return H.editor.formatText(T,I,X)},K,T,0)}},{key:"getBounds",value:function(T){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,B=void 0;typeof T=="number"?B=this.selection.getBounds(T,I):B=this.selection.getBounds(T.index,T.length);var G=this.container.getBoundingClientRect();return{bottom:B.bottom-G.top,height:B.height,left:B.left-G.left,right:B.right-G.left,top:B.top-G.top,width:B.width}}},{key:"getContents",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getLength()-T,B=W(T,I),G=o(B,2);return T=G[0],I=G[1],this.editor.getContents(T,I)}},{key:"getFormat",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.getSelection(!0),I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return typeof T=="number"?this.editor.getFormat(T,I):this.editor.getFormat(T.index,T.length)}},{key:"getIndex",value:function(T){return T.offset(this.scroll)}},{key:"getLength",value:function(){return this.scroll.length()}},{key:"getLeaf",value:function(T){return this.scroll.leaf(T)}},{key:"getLine",value:function(T){return this.scroll.line(T)}},{key:"getLines",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE;return typeof T!="number"?this.scroll.lines(T.index,T.length):this.scroll.lines(T,I)}},{key:"getModule",value:function(T){return this.theme.modules[T]}},{key:"getSelection",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;return T&&this.focus(),this.update(),this.selection.getRange()[0]}},{key:"getText",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getLength()-T,B=W(T,I),G=o(B,2);return T=G[0],I=G[1],this.editor.getText(T,I)}},{key:"hasFocus",value:function(){return this.selection.hasFocus()}},{key:"insertEmbed",value:function(T,I,B){var G=this,K=arguments.length>3&&arguments[3]!==void 0?arguments[3]:M.sources.API;return Z.call(this,function(){return G.editor.insertEmbed(T,I,B)},K,T)}},{key:"insertText",value:function(T,I,B,G,K){var H=this,X=void 0,J=W(T,0,B,G,K),ae=o(J,4);return T=ae[0],X=ae[2],K=ae[3],Z.call(this,function(){return H.editor.insertText(T,I,X)},K,T,I.length)}},{key:"isEnabled",value:function(){return!this.container.classList.contains("ql-disabled")}},{key:"off",value:function(){return this.emitter.off.apply(this.emitter,arguments)}},{key:"on",value:function(){return this.emitter.on.apply(this.emitter,arguments)}},{key:"once",value:function(){return this.emitter.once.apply(this.emitter,arguments)}},{key:"pasteHTML",value:function(T,I,B){this.clipboard.dangerouslyPasteHTML(T,I,B)}},{key:"removeFormat",value:function(T,I,B){var G=this,K=W(T,I,B),H=o(K,4);return T=H[0],I=H[1],B=H[3],Z.call(this,function(){return G.editor.removeFormat(T,I)},B,T)}},{key:"scrollIntoView",value:function(){this.selection.scrollIntoView(this.scrollingContainer)}},{key:"setContents",value:function(T){var I=this,B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:u.default.sources.API;return Z.call(this,function(){T=new f.default(T);var G=I.getLength(),K=I.editor.deleteText(0,G),H=I.editor.applyDelta(T),X=H.ops[H.ops.length-1];X!=null&&typeof X.insert=="string"&&X.insert[X.insert.length-1]===`
`&&(I.editor.deleteText(I.getLength()-1,1),H.delete(1));var J=K.compose(H);return J},B)}},{key:"setSelection",value:function(T,I,B){if(T==null)this.selection.setRange(null,I||M.sources.API);else{var G=W(T,I,B),K=o(G,4);T=K[0],I=K[1],B=K[3],this.selection.setRange(new b.Range(T,I),B),B!==u.default.sources.SILENT&&this.selection.scrollIntoView(this.scrollingContainer)}}},{key:"setText",value:function(T){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:u.default.sources.API,B=new f.default().insert(T);return this.setContents(B,I)}},{key:"update",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:u.default.sources.USER,I=this.scroll.update(T);return this.selection.update(T),I}},{key:"updateContents",value:function(T){var I=this,B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:u.default.sources.API;return Z.call(this,function(){return T=new f.default(T),I.editor.applyDelta(T,B)},B,!0)}}]),M})();$.DEFAULTS={bounds:null,formats:null,modules:{},placeholder:"",readOnly:!1,scrollingContainer:null,strict:!0,theme:"default"},$.events=u.default.events,$.sources=u.default.sources,$.version="1.3.7",$.imports={delta:f.default,parchment:j.default,"core/module":v.default,"core/theme":q.default};function Y(M,z){if(z=(0,R.default)(!0,{container:M,modules:{clipboard:!0,keyboard:!0,history:!0}},z),!z.theme||z.theme===$.DEFAULTS.theme)z.theme=q.default;else if(z.theme=$.import("themes/"+z.theme),z.theme==null)throw new Error("Invalid theme "+z.theme+". Did you register it?");var T=(0,R.default)(!0,{},z.theme.DEFAULTS);[T,z].forEach(function(G){G.modules=G.modules||{},Object.keys(G.modules).forEach(function(K){G.modules[K]===!0&&(G.modules[K]={})})});var I=Object.keys(T.modules).concat(Object.keys(z.modules)),B=I.reduce(function(G,K){var H=$.import("modules/"+K);return H==null?L.error("Cannot load "+K+" module. Are you sure you registered it?"):G[K]=H.DEFAULTS||{},G},{});return z.modules!=null&&z.modules.toolbar&&z.modules.toolbar.constructor!==Object&&(z.modules.toolbar={container:z.modules.toolbar}),z=(0,R.default)(!0,{},$.DEFAULTS,{modules:B},T,z),["bounds","container","scrollingContainer"].forEach(function(G){typeof z[G]=="string"&&(z[G]=document.querySelector(z[G]))}),z.modules=Object.keys(z.modules).reduce(function(G,K){return z.modules[K]&&(G[K]=z.modules[K]),G},{}),z}function Z(M,z,T,I){if(this.options.strict&&!this.isEnabled()&&z===u.default.sources.USER)return new f.default;var B=T==null?null:this.getSelection(),G=this.editor.delta,K=M();if(B!=null&&(T===!0&&(T=B.index),I==null?B=U(B,K,z):I!==0&&(B=U(B,T,I,z)),this.setSelection(B,u.default.sources.SILENT)),K.length()>0){var H,X=[u.default.events.TEXT_CHANGE,K,G,z];if((H=this.emitter).emit.apply(H,[u.default.events.EDITOR_CHANGE].concat(X)),z!==u.default.sources.SILENT){var J;(J=this.emitter).emit.apply(J,X)}}return K}function W(M,z,T,I,B){var G={};return typeof M.index=="number"&&typeof M.length=="number"?typeof z!="number"?(B=I,I=T,T=z,z=M.length,M=M.index):(z=M.length,M=M.index):typeof z!="number"&&(B=I,I=T,T=z,z=0),(typeof T>"u"?"undefined":i(T))==="object"?(G=T,B=I):typeof T=="string"&&(I!=null?G[T]=I:B=T),B=B||u.default.sources.API,[M,z,G,B]}function U(M,z,T,I){if(M==null)return null;var B=void 0,G=void 0;if(z instanceof f.default){var K=[M.index,M.index+M.length].map(function(ae){return z.transformPosition(ae,I!==u.default.sources.USER)}),H=o(K,2);B=H[0],G=H[1]}else{var X=[M.index,M.index+M.length].map(function(ae){return ae<z||ae===z&&I===u.default.sources.USER?ae:T>=0?ae+T:Math.max(z,ae+T)}),J=o(X,2);B=J[0],G=J[1]}return new b.Range(B,G-B)}r.expandConfig=Y,r.overload=W,r.default=$}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function w(j,b){for(var C=0;C<b.length;C++){var S=b[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(j,S.key,S)}}return function(j,b,C){return b&&w(j.prototype,b),C&&w(j,C),j}})(),o=function w(j,b,C){j===null&&(j=Function.prototype);var S=Object.getOwnPropertyDescriptor(j,b);if(S===void 0){var R=Object.getPrototypeOf(j);return R===null?void 0:w(R,b,C)}else{if("value"in S)return S.value;var _=S.get;return _===void 0?void 0:_.call(C)}},d=a(7),m=h(d),f=a(0),p=h(f);function h(w){return w&&w.__esModule?w:{default:w}}function x(w,j){if(!(w instanceof j))throw new TypeError("Cannot call a class as a function")}function u(w,j){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j&&(typeof j=="object"||typeof j=="function")?j:w}function N(w,j){if(typeof j!="function"&&j!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof j);w.prototype=Object.create(j&&j.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),j&&(Object.setPrototypeOf?Object.setPrototypeOf(w,j):w.__proto__=j)}var v=(function(w){N(j,w);function j(){return x(this,j),u(this,(j.__proto__||Object.getPrototypeOf(j)).apply(this,arguments))}return i(j,[{key:"formatAt",value:function(C,S,R,_){if(j.compare(this.statics.blotName,R)<0&&p.default.query(R,p.default.Scope.BLOT)){var A=this.isolate(C,S);_&&A.wrap(R,_)}else o(j.prototype.__proto__||Object.getPrototypeOf(j.prototype),"formatAt",this).call(this,C,S,R,_)}},{key:"optimize",value:function(C){if(o(j.prototype.__proto__||Object.getPrototypeOf(j.prototype),"optimize",this).call(this,C),this.parent instanceof j&&j.compare(this.statics.blotName,this.parent.statics.blotName)>0){var S=this.parent.isolate(this.offset(),this.length());this.moveChildren(S),S.wrap(this)}}}],[{key:"compare",value:function(C,S){var R=j.order.indexOf(C),_=j.order.indexOf(S);return R>=0||_>=0?R-_:C===S?0:C<S?-1:1}}]),j})(p.default.Inline);v.allowedChildren=[v,p.default.Embed,m.default],v.order=["cursor","inline","underline","strike","italic","bold","script","link","code"],r.default=v}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(0),o=d(i);function d(x){return x&&x.__esModule?x:{default:x}}function m(x,u){if(!(x instanceof u))throw new TypeError("Cannot call a class as a function")}function f(x,u){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:x}function p(x,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);x.prototype=Object.create(u&&u.prototype,{constructor:{value:x,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(x,u):x.__proto__=u)}var h=(function(x){p(u,x);function u(){return m(this,u),f(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u})(o.default.Text);r.default=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function b(C,S){for(var R=0;R<S.length;R++){var _=S[R];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(C,_.key,_)}}return function(C,S,R){return S&&b(C.prototype,S),R&&b(C,R),C}})(),o=function b(C,S,R){C===null&&(C=Function.prototype);var _=Object.getOwnPropertyDescriptor(C,S);if(_===void 0){var A=Object.getPrototypeOf(C);return A===null?void 0:b(A,S,R)}else{if("value"in _)return _.value;var E=_.get;return E===void 0?void 0:E.call(R)}},d=a(54),m=h(d),f=a(10),p=h(f);function h(b){return b&&b.__esModule?b:{default:b}}function x(b,C){if(!(b instanceof C))throw new TypeError("Cannot call a class as a function")}function u(b,C){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return C&&(typeof C=="object"||typeof C=="function")?C:b}function N(b,C){if(typeof C!="function"&&C!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof C);b.prototype=Object.create(C&&C.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),C&&(Object.setPrototypeOf?Object.setPrototypeOf(b,C):b.__proto__=C)}var v=(0,p.default)("quill:events"),w=["selectionchange","mousedown","mouseup","click"];w.forEach(function(b){document.addEventListener(b,function(){for(var C=arguments.length,S=Array(C),R=0;R<C;R++)S[R]=arguments[R];[].slice.call(document.querySelectorAll(".ql-container")).forEach(function(_){if(_.__quill&&_.__quill.emitter){var A;(A=_.__quill.emitter).handleDOM.apply(A,S)}})})});var j=(function(b){N(C,b);function C(){x(this,C);var S=u(this,(C.__proto__||Object.getPrototypeOf(C)).call(this));return S.listeners={},S.on("error",v.error),S}return i(C,[{key:"emit",value:function(){v.log.apply(v,arguments),o(C.prototype.__proto__||Object.getPrototypeOf(C.prototype),"emit",this).apply(this,arguments)}},{key:"handleDOM",value:function(R){for(var _=arguments.length,A=Array(_>1?_-1:0),E=1;E<_;E++)A[E-1]=arguments[E];(this.listeners[R.type]||[]).forEach(function(q){var O=q.node,D=q.handler;(R.target===O||O.contains(R.target))&&D.apply(void 0,[R].concat(A))})}},{key:"listenDOM",value:function(R,_,A){this.listeners[R]||(this.listeners[R]=[]),this.listeners[R].push({node:_,handler:A})}}]),C})(m.default);j.events={EDITOR_CHANGE:"editor-change",SCROLL_BEFORE_UPDATE:"scroll-before-update",SCROLL_OPTIMIZE:"scroll-optimize",SCROLL_UPDATE:"scroll-update",SELECTION_CHANGE:"selection-change",TEXT_CHANGE:"text-change"},j.sources={API:"api",SILENT:"silent",USER:"user"},r.default=j}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});function i(d,m){if(!(d instanceof m))throw new TypeError("Cannot call a class as a function")}var o=function d(m){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};i(this,d),this.quill=m,this.options=f};o.DEFAULTS={},r.default=o}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=["error","warn","log","info"],o="warn";function d(f){if(i.indexOf(f)<=i.indexOf(o)){for(var p,h=arguments.length,x=Array(h>1?h-1:0),u=1;u<h;u++)x[u-1]=arguments[u];(p=console)[f].apply(p,x)}}function m(f){return i.reduce(function(p,h){return p[h]=d.bind(console,h,f),p},{})}d.level=m.level=function(f){o=f},r.default=m}),(function(n,r,a){var i=Array.prototype.slice,o=a(52),d=a(53),m=n.exports=function(x,u,N){return N||(N={}),x===u?!0:x instanceof Date&&u instanceof Date?x.getTime()===u.getTime():!x||!u||typeof x!="object"&&typeof u!="object"?N.strict?x===u:x==u:h(x,u,N)};function f(x){return x==null}function p(x){return!(!x||typeof x!="object"||typeof x.length!="number"||typeof x.copy!="function"||typeof x.slice!="function"||x.length>0&&typeof x[0]!="number")}function h(x,u,N){var v,w;if(f(x)||f(u)||x.prototype!==u.prototype)return!1;if(d(x))return d(u)?(x=i.call(x),u=i.call(u),m(x,u,N)):!1;if(p(x)){if(!p(u)||x.length!==u.length)return!1;for(v=0;v<x.length;v++)if(x[v]!==u[v])return!1;return!0}try{var j=o(x),b=o(u)}catch{return!1}if(j.length!=b.length)return!1;for(j.sort(),b.sort(),v=j.length-1;v>=0;v--)if(j[v]!=b[v])return!1;for(v=j.length-1;v>=0;v--)if(w=j[v],!m(x[w],u[w],N))return!1;return typeof x==typeof u}}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(1),o=(function(){function d(m,f,p){p===void 0&&(p={}),this.attrName=m,this.keyName=f;var h=i.Scope.TYPE&i.Scope.ATTRIBUTE;p.scope!=null?this.scope=p.scope&i.Scope.LEVEL|h:this.scope=i.Scope.ATTRIBUTE,p.whitelist!=null&&(this.whitelist=p.whitelist)}return d.keys=function(m){return[].map.call(m.attributes,function(f){return f.name})},d.prototype.add=function(m,f){return this.canAdd(m,f)?(m.setAttribute(this.keyName,f),!0):!1},d.prototype.canAdd=function(m,f){var p=i.query(m,i.Scope.BLOT&(this.scope|i.Scope.TYPE));return p==null?!1:this.whitelist==null?!0:typeof f=="string"?this.whitelist.indexOf(f.replace(/["']/g,""))>-1:this.whitelist.indexOf(f)>-1},d.prototype.remove=function(m){m.removeAttribute(this.keyName)},d.prototype.value=function(m){var f=m.getAttribute(this.keyName);return this.canAdd(m,f)&&f?f:""},d})();r.default=o}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.Code=void 0;var i=(function(){function E(q,O){var D=[],P=!0,L=!1,$=void 0;try{for(var Y=q[Symbol.iterator](),Z;!(P=(Z=Y.next()).done)&&(D.push(Z.value),!(O&&D.length===O));P=!0);}catch(W){L=!0,$=W}finally{try{!P&&Y.return&&Y.return()}finally{if(L)throw $}}return D}return function(q,O){if(Array.isArray(q))return q;if(Symbol.iterator in Object(q))return E(q,O);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=(function(){function E(q,O){for(var D=0;D<O.length;D++){var P=O[D];P.enumerable=P.enumerable||!1,P.configurable=!0,"value"in P&&(P.writable=!0),Object.defineProperty(q,P.key,P)}}return function(q,O,D){return O&&E(q.prototype,O),D&&E(q,D),q}})(),d=function E(q,O,D){q===null&&(q=Function.prototype);var P=Object.getOwnPropertyDescriptor(q,O);if(P===void 0){var L=Object.getPrototypeOf(q);return L===null?void 0:E(L,O,D)}else{if("value"in P)return P.value;var $=P.get;return $===void 0?void 0:$.call(D)}},m=a(2),f=b(m),p=a(0),h=b(p),x=a(4),u=b(x),N=a(6),v=b(N),w=a(7),j=b(w);function b(E){return E&&E.__esModule?E:{default:E}}function C(E,q){if(!(E instanceof q))throw new TypeError("Cannot call a class as a function")}function S(E,q){if(!E)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return q&&(typeof q=="object"||typeof q=="function")?q:E}function R(E,q){if(typeof q!="function"&&q!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof q);E.prototype=Object.create(q&&q.prototype,{constructor:{value:E,enumerable:!1,writable:!0,configurable:!0}}),q&&(Object.setPrototypeOf?Object.setPrototypeOf(E,q):E.__proto__=q)}var _=(function(E){R(q,E);function q(){return C(this,q),S(this,(q.__proto__||Object.getPrototypeOf(q)).apply(this,arguments))}return q})(v.default);_.blotName="code",_.tagName="CODE";var A=(function(E){R(q,E);function q(){return C(this,q),S(this,(q.__proto__||Object.getPrototypeOf(q)).apply(this,arguments))}return o(q,[{key:"delta",value:function(){var D=this,P=this.domNode.textContent;return P.endsWith(`
`)&&(P=P.slice(0,-1)),P.split(`
`).reduce(function(L,$){return L.insert($).insert(`
`,D.formats())},new f.default)}},{key:"format",value:function(D,P){if(!(D===this.statics.blotName&&P)){var L=this.descendant(j.default,this.length()-1),$=i(L,1),Y=$[0];Y!=null&&Y.deleteAt(Y.length()-1,1),d(q.prototype.__proto__||Object.getPrototypeOf(q.prototype),"format",this).call(this,D,P)}}},{key:"formatAt",value:function(D,P,L,$){if(P!==0&&!(h.default.query(L,h.default.Scope.BLOCK)==null||L===this.statics.blotName&&$===this.statics.formats(this.domNode))){var Y=this.newlineIndex(D);if(!(Y<0||Y>=D+P)){var Z=this.newlineIndex(D,!0)+1,W=Y-Z+1,U=this.isolate(Z,W),M=U.next;U.format(L,$),M instanceof q&&M.formatAt(0,D-Z+P-W,L,$)}}}},{key:"insertAt",value:function(D,P,L){if(L==null){var $=this.descendant(j.default,D),Y=i($,2),Z=Y[0],W=Y[1];Z.insertAt(W,P)}}},{key:"length",value:function(){var D=this.domNode.textContent.length;return this.domNode.textContent.endsWith(`
`)?D:D+1}},{key:"newlineIndex",value:function(D){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(P)return this.domNode.textContent.slice(0,D).lastIndexOf(`
`);var L=this.domNode.textContent.slice(D).indexOf(`
`);return L>-1?D+L:-1}},{key:"optimize",value:function(D){this.domNode.textContent.endsWith(`
`)||this.appendChild(h.default.create("text",`
`)),d(q.prototype.__proto__||Object.getPrototypeOf(q.prototype),"optimize",this).call(this,D);var P=this.next;P!=null&&P.prev===this&&P.statics.blotName===this.statics.blotName&&this.statics.formats(this.domNode)===P.statics.formats(P.domNode)&&(P.optimize(D),P.moveChildren(this),P.remove())}},{key:"replace",value:function(D){d(q.prototype.__proto__||Object.getPrototypeOf(q.prototype),"replace",this).call(this,D),[].slice.call(this.domNode.querySelectorAll("*")).forEach(function(P){var L=h.default.find(P);L==null?P.parentNode.removeChild(P):L instanceof h.default.Embed?L.remove():L.unwrap()})}}],[{key:"create",value:function(D){var P=d(q.__proto__||Object.getPrototypeOf(q),"create",this).call(this,D);return P.setAttribute("spellcheck",!1),P}},{key:"formats",value:function(){return!0}}]),q})(u.default);A.blotName="code-block",A.tagName="PRE",A.TAB=" ",r.Code=_,r.default=A}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(M){return typeof M}:function(M){return M&&typeof Symbol=="function"&&M.constructor===Symbol&&M!==Symbol.prototype?"symbol":typeof M},o=(function(){function M(z,T){var I=[],B=!0,G=!1,K=void 0;try{for(var H=z[Symbol.iterator](),X;!(B=(X=H.next()).done)&&(I.push(X.value),!(T&&I.length===T));B=!0);}catch(J){G=!0,K=J}finally{try{!B&&H.return&&H.return()}finally{if(G)throw K}}return I}return function(z,T){if(Array.isArray(z))return z;if(Symbol.iterator in Object(z))return M(z,T);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function M(z,T){for(var I=0;I<T.length;I++){var B=T[I];B.enumerable=B.enumerable||!1,B.configurable=!0,"value"in B&&(B.writable=!0),Object.defineProperty(z,B.key,B)}}return function(z,T,I){return T&&M(z.prototype,T),I&&M(z,I),z}})(),m=a(2),f=P(m),p=a(20),h=P(p),x=a(0),u=P(x),N=a(13),v=P(N),w=a(24),j=P(w),b=a(4),C=P(b),S=a(16),R=P(S),_=a(21),A=P(_),E=a(11),q=P(E),O=a(3),D=P(O);function P(M){return M&&M.__esModule?M:{default:M}}function L(M,z,T){return z in M?Object.defineProperty(M,z,{value:T,enumerable:!0,configurable:!0,writable:!0}):M[z]=T,M}function $(M,z){if(!(M instanceof z))throw new TypeError("Cannot call a class as a function")}var Y=/^[ -~]*$/,Z=(function(){function M(z){$(this,M),this.scroll=z,this.delta=this.getDelta()}return d(M,[{key:"applyDelta",value:function(T){var I=this,B=!1;this.scroll.update();var G=this.scroll.length();return this.scroll.batchStart(),T=U(T),T.reduce(function(K,H){var X=H.retain||H.delete||H.insert.length||1,J=H.attributes||{};if(H.insert!=null){if(typeof H.insert=="string"){var ae=H.insert;ae.endsWith(`
`)&&B&&(B=!1,ae=ae.slice(0,-1)),K>=G&&!ae.endsWith(`
`)&&(B=!0),I.scroll.insertAt(K,ae);var le=I.scroll.line(K),xe=o(le,2),ce=xe[0],ve=xe[1],Pe=(0,D.default)({},(0,b.bubbleFormats)(ce));if(ce instanceof C.default){var et=ce.descendant(u.default.Leaf,ve),kt=o(et,1),vt=kt[0];Pe=(0,D.default)(Pe,(0,b.bubbleFormats)(vt))}J=h.default.attributes.diff(Pe,J)||{}}else if(i(H.insert)==="object"){var ee=Object.keys(H.insert)[0];if(ee==null)return K;I.scroll.insertAt(K,ee,H.insert[ee])}G+=X}return Object.keys(J).forEach(function(ge){I.scroll.formatAt(K,X,ge,J[ge])}),K+X},0),T.reduce(function(K,H){return typeof H.delete=="number"?(I.scroll.deleteAt(K,H.delete),K):K+(H.retain||H.insert.length||1)},0),this.scroll.batchEnd(),this.update(T)}},{key:"deleteText",value:function(T,I){return this.scroll.deleteAt(T,I),this.update(new f.default().retain(T).delete(I))}},{key:"formatLine",value:function(T,I){var B=this,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.scroll.update(),Object.keys(G).forEach(function(K){if(!(B.scroll.whitelist!=null&&!B.scroll.whitelist[K])){var H=B.scroll.lines(T,Math.max(I,1)),X=I;H.forEach(function(J){var ae=J.length();if(!(J instanceof v.default))J.format(K,G[K]);else{var le=T-J.offset(B.scroll),xe=J.newlineIndex(le+X)-le+1;J.formatAt(le,xe,K,G[K])}X-=ae})}}),this.scroll.optimize(),this.update(new f.default().retain(T).retain(I,(0,A.default)(G)))}},{key:"formatText",value:function(T,I){var B=this,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return Object.keys(G).forEach(function(K){B.scroll.formatAt(T,I,K,G[K])}),this.update(new f.default().retain(T).retain(I,(0,A.default)(G)))}},{key:"getContents",value:function(T,I){return this.delta.slice(T,T+I)}},{key:"getDelta",value:function(){return this.scroll.lines().reduce(function(T,I){return T.concat(I.delta())},new f.default)}},{key:"getFormat",value:function(T){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,B=[],G=[];I===0?this.scroll.path(T).forEach(function(H){var X=o(H,1),J=X[0];J instanceof C.default?B.push(J):J instanceof u.default.Leaf&&G.push(J)}):(B=this.scroll.lines(T,I),G=this.scroll.descendants(u.default.Leaf,T,I));var K=[B,G].map(function(H){if(H.length===0)return{};for(var X=(0,b.bubbleFormats)(H.shift());Object.keys(X).length>0;){var J=H.shift();if(J==null)return X;X=W((0,b.bubbleFormats)(J),X)}return X});return D.default.apply(D.default,K)}},{key:"getText",value:function(T,I){return this.getContents(T,I).filter(function(B){return typeof B.insert=="string"}).map(function(B){return B.insert}).join("")}},{key:"insertEmbed",value:function(T,I,B){return this.scroll.insertAt(T,I,B),this.update(new f.default().retain(T).insert(L({},I,B)))}},{key:"insertText",value:function(T,I){var B=this,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return I=I.replace(/\r\n/g,`
`).replace(/\r/g,`
`),this.scroll.insertAt(T,I),Object.keys(G).forEach(function(K){B.scroll.formatAt(T,I.length,K,G[K])}),this.update(new f.default().retain(T).insert(I,(0,A.default)(G)))}},{key:"isBlank",value:function(){if(this.scroll.children.length==0)return!0;if(this.scroll.children.length>1)return!1;var T=this.scroll.children.head;return T.statics.blotName!==C.default.blotName||T.children.length>1?!1:T.children.head instanceof R.default}},{key:"removeFormat",value:function(T,I){var B=this.getText(T,I),G=this.scroll.line(T+I),K=o(G,2),H=K[0],X=K[1],J=0,ae=new f.default;H!=null&&(H instanceof v.default?J=H.newlineIndex(X)-X+1:J=H.length()-X,ae=H.delta().slice(X,X+J-1).insert(`
`));var le=this.getContents(T,I+J),xe=le.diff(new f.default().insert(B).concat(ae)),ce=new f.default().retain(T).concat(xe);return this.applyDelta(ce)}},{key:"update",value:function(T){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],B=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,G=this.delta;if(I.length===1&&I[0].type==="characterData"&&I[0].target.data.match(Y)&&u.default.find(I[0].target)){var K=u.default.find(I[0].target),H=(0,b.bubbleFormats)(K),X=K.offset(this.scroll),J=I[0].oldValue.replace(j.default.CONTENTS,""),ae=new f.default().insert(J),le=new f.default().insert(K.value()),xe=new f.default().retain(X).concat(ae.diff(le,B));T=xe.reduce(function(ce,ve){return ve.insert?ce.insert(ve.insert,H):ce.push(ve)},new f.default),this.delta=G.compose(T)}else this.delta=this.getDelta(),(!T||!(0,q.default)(G.compose(T),this.delta))&&(T=G.diff(this.delta,B));return T}}]),M})();function W(M,z){return Object.keys(z).reduce(function(T,I){return M[I]==null||(z[I]===M[I]?T[I]=z[I]:Array.isArray(z[I])?z[I].indexOf(M[I])<0&&(T[I]=z[I].concat([M[I]])):T[I]=[z[I],M[I]]),T},{})}function U(M){return M.reduce(function(z,T){if(T.insert===1){var I=(0,A.default)(T.attributes);return delete I.image,z.insert({image:T.attributes.image},I)}if(T.attributes!=null&&(T.attributes.list===!0||T.attributes.bullet===!0)&&(T=(0,A.default)(T),T.attributes.list?T.attributes.list="ordered":(T.attributes.list="bullet",delete T.attributes.bullet)),typeof T.insert=="string"){var B=T.insert.replace(/\r\n/g,`
`).replace(/\r/g,`
`);return z.insert(B,T.attributes)}return z.push(T)},new f.default)}r.default=Z}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.Range=void 0;var i=(function(){function E(q,O){var D=[],P=!0,L=!1,$=void 0;try{for(var Y=q[Symbol.iterator](),Z;!(P=(Z=Y.next()).done)&&(D.push(Z.value),!(O&&D.length===O));P=!0);}catch(W){L=!0,$=W}finally{try{!P&&Y.return&&Y.return()}finally{if(L)throw $}}return D}return function(q,O){if(Array.isArray(q))return q;if(Symbol.iterator in Object(q))return E(q,O);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=(function(){function E(q,O){for(var D=0;D<O.length;D++){var P=O[D];P.enumerable=P.enumerable||!1,P.configurable=!0,"value"in P&&(P.writable=!0),Object.defineProperty(q,P.key,P)}}return function(q,O,D){return O&&E(q.prototype,O),D&&E(q,D),q}})(),d=a(0),m=j(d),f=a(21),p=j(f),h=a(11),x=j(h),u=a(8),N=j(u),v=a(10),w=j(v);function j(E){return E&&E.__esModule?E:{default:E}}function b(E){if(Array.isArray(E)){for(var q=0,O=Array(E.length);q<E.length;q++)O[q]=E[q];return O}else return Array.from(E)}function C(E,q){if(!(E instanceof q))throw new TypeError("Cannot call a class as a function")}var S=(0,w.default)("quill:selection"),R=function E(q){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;C(this,E),this.index=q,this.length=O},_=(function(){function E(q,O){var D=this;C(this,E),this.emitter=O,this.scroll=q,this.composing=!1,this.mouseDown=!1,this.root=this.scroll.domNode,this.cursor=m.default.create("cursor",this),this.lastRange=this.savedRange=new R(0,0),this.handleComposition(),this.handleDragging(),this.emitter.listenDOM("selectionchange",document,function(){D.mouseDown||setTimeout(D.update.bind(D,N.default.sources.USER),1)}),this.emitter.on(N.default.events.EDITOR_CHANGE,function(P,L){P===N.default.events.TEXT_CHANGE&&L.length()>0&&D.update(N.default.sources.SILENT)}),this.emitter.on(N.default.events.SCROLL_BEFORE_UPDATE,function(){if(D.hasFocus()){var P=D.getNativeRange();P!=null&&P.start.node!==D.cursor.textNode&&D.emitter.once(N.default.events.SCROLL_UPDATE,function(){try{D.setNativeRange(P.start.node,P.start.offset,P.end.node,P.end.offset)}catch{}})}}),this.emitter.on(N.default.events.SCROLL_OPTIMIZE,function(P,L){if(L.range){var $=L.range,Y=$.startNode,Z=$.startOffset,W=$.endNode,U=$.endOffset;D.setNativeRange(Y,Z,W,U)}}),this.update(N.default.sources.SILENT)}return o(E,[{key:"handleComposition",value:function(){var O=this;this.root.addEventListener("compositionstart",function(){O.composing=!0}),this.root.addEventListener("compositionend",function(){if(O.composing=!1,O.cursor.parent){var D=O.cursor.restore();if(!D)return;setTimeout(function(){O.setNativeRange(D.startNode,D.startOffset,D.endNode,D.endOffset)},1)}})}},{key:"handleDragging",value:function(){var O=this;this.emitter.listenDOM("mousedown",document.body,function(){O.mouseDown=!0}),this.emitter.listenDOM("mouseup",document.body,function(){O.mouseDown=!1,O.update(N.default.sources.USER)})}},{key:"focus",value:function(){this.hasFocus()||(this.root.focus(),this.setRange(this.savedRange))}},{key:"format",value:function(O,D){if(!(this.scroll.whitelist!=null&&!this.scroll.whitelist[O])){this.scroll.update();var P=this.getNativeRange();if(!(P==null||!P.native.collapsed||m.default.query(O,m.default.Scope.BLOCK))){if(P.start.node!==this.cursor.textNode){var L=m.default.find(P.start.node,!1);if(L==null)return;if(L instanceof m.default.Leaf){var $=L.split(P.start.offset);L.parent.insertBefore(this.cursor,$)}else L.insertBefore(this.cursor,P.start.node);this.cursor.attach()}this.cursor.format(O,D),this.scroll.optimize(),this.setNativeRange(this.cursor.textNode,this.cursor.textNode.data.length),this.update()}}}},{key:"getBounds",value:function(O){var D=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,P=this.scroll.length();O=Math.min(O,P-1),D=Math.min(O+D,P-1)-O;var L=void 0,$=this.scroll.leaf(O),Y=i($,2),Z=Y[0],W=Y[1];if(Z==null)return null;var U=Z.position(W,!0),M=i(U,2);L=M[0],W=M[1];var z=document.createRange();if(D>0){z.setStart(L,W);var T=this.scroll.leaf(O+D),I=i(T,2);if(Z=I[0],W=I[1],Z==null)return null;var B=Z.position(W,!0),G=i(B,2);return L=G[0],W=G[1],z.setEnd(L,W),z.getBoundingClientRect()}else{var K="left",H=void 0;return L instanceof Text?(W<L.data.length?(z.setStart(L,W),z.setEnd(L,W+1)):(z.setStart(L,W-1),z.setEnd(L,W),K="right"),H=z.getBoundingClientRect()):(H=Z.domNode.getBoundingClientRect(),W>0&&(K="right")),{bottom:H.top+H.height,height:H.height,left:H[K],right:H[K],top:H.top,width:0}}}},{key:"getNativeRange",value:function(){var O=document.getSelection();if(O==null||O.rangeCount<=0)return null;var D=O.getRangeAt(0);if(D==null)return null;var P=this.normalizeNative(D);return S.info("getNativeRange",P),P}},{key:"getRange",value:function(){var O=this.getNativeRange();if(O==null)return[null,null];var D=this.normalizedToRange(O);return[D,O]}},{key:"hasFocus",value:function(){return document.activeElement===this.root}},{key:"normalizedToRange",value:function(O){var D=this,P=[[O.start.node,O.start.offset]];O.native.collapsed||P.push([O.end.node,O.end.offset]);var L=P.map(function(Z){var W=i(Z,2),U=W[0],M=W[1],z=m.default.find(U,!0),T=z.offset(D.scroll);return M===0?T:z instanceof m.default.Container?T+z.length():T+z.index(U,M)}),$=Math.min(Math.max.apply(Math,b(L)),this.scroll.length()-1),Y=Math.min.apply(Math,[$].concat(b(L)));return new R(Y,$-Y)}},{key:"normalizeNative",value:function(O){if(!A(this.root,O.startContainer)||!O.collapsed&&!A(this.root,O.endContainer))return null;var D={start:{node:O.startContainer,offset:O.startOffset},end:{node:O.endContainer,offset:O.endOffset},native:O};return[D.start,D.end].forEach(function(P){for(var L=P.node,$=P.offset;!(L instanceof Text)&&L.childNodes.length>0;)if(L.childNodes.length>$)L=L.childNodes[$],$=0;else if(L.childNodes.length===$)L=L.lastChild,$=L instanceof Text?L.data.length:L.childNodes.length+1;else break;P.node=L,P.offset=$}),D}},{key:"rangeToNative",value:function(O){var D=this,P=O.collapsed?[O.index]:[O.index,O.index+O.length],L=[],$=this.scroll.length();return P.forEach(function(Y,Z){Y=Math.min($-1,Y);var W=void 0,U=D.scroll.leaf(Y),M=i(U,2),z=M[0],T=M[1],I=z.position(T,Z!==0),B=i(I,2);W=B[0],T=B[1],L.push(W,T)}),L.length<2&&(L=L.concat(L)),L}},{key:"scrollIntoView",value:function(O){var D=this.lastRange;if(D!=null){var P=this.getBounds(D.index,D.length);if(P!=null){var L=this.scroll.length()-1,$=this.scroll.line(Math.min(D.index,L)),Y=i($,1),Z=Y[0],W=Z;if(D.length>0){var U=this.scroll.line(Math.min(D.index+D.length,L)),M=i(U,1);W=M[0]}if(!(Z==null||W==null)){var z=O.getBoundingClientRect();P.top<z.top?O.scrollTop-=z.top-P.top:P.bottom>z.bottom&&(O.scrollTop+=P.bottom-z.bottom)}}}}},{key:"setNativeRange",value:function(O,D){var P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:O,L=arguments.length>3&&arguments[3]!==void 0?arguments[3]:D,$=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;if(S.info("setNativeRange",O,D,P,L),!(O!=null&&(this.root.parentNode==null||O.parentNode==null||P.parentNode==null))){var Y=document.getSelection();if(Y!=null)if(O!=null){this.hasFocus()||this.root.focus();var Z=(this.getNativeRange()||{}).native;if(Z==null||$||O!==Z.startContainer||D!==Z.startOffset||P!==Z.endContainer||L!==Z.endOffset){O.tagName=="BR"&&(D=[].indexOf.call(O.parentNode.childNodes,O),O=O.parentNode),P.tagName=="BR"&&(L=[].indexOf.call(P.parentNode.childNodes,P),P=P.parentNode);var W=document.createRange();W.setStart(O,D),W.setEnd(P,L),Y.removeAllRanges(),Y.addRange(W)}}else Y.removeAllRanges(),this.root.blur(),document.body.focus()}}},{key:"setRange",value:function(O){var D=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:N.default.sources.API;if(typeof D=="string"&&(P=D,D=!1),S.info("setRange",O),O!=null){var L=this.rangeToNative(O);this.setNativeRange.apply(this,b(L).concat([D]))}else this.setNativeRange(null);this.update(P)}},{key:"update",value:function(){var O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:N.default.sources.USER,D=this.lastRange,P=this.getRange(),L=i(P,2),$=L[0],Y=L[1];if(this.lastRange=$,this.lastRange!=null&&(this.savedRange=this.lastRange),!(0,x.default)(D,this.lastRange)){var Z;!this.composing&&Y!=null&&Y.native.collapsed&&Y.start.node!==this.cursor.textNode&&this.cursor.restore();var W=[N.default.events.SELECTION_CHANGE,(0,p.default)(this.lastRange),(0,p.default)(D),O];if((Z=this.emitter).emit.apply(Z,[N.default.events.EDITOR_CHANGE].concat(W)),O!==N.default.sources.SILENT){var U;(U=this.emitter).emit.apply(U,W)}}}}]),E})();function A(E,q){try{q.parentNode}catch{return!1}return q instanceof Text&&(q=q.parentNode),E.contains(q)}r.Range=R,r.default=_}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function N(v,w){for(var j=0;j<w.length;j++){var b=w[j];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}return function(v,w,j){return w&&N(v.prototype,w),j&&N(v,j),v}})(),o=function N(v,w,j){v===null&&(v=Function.prototype);var b=Object.getOwnPropertyDescriptor(v,w);if(b===void 0){var C=Object.getPrototypeOf(v);return C===null?void 0:N(C,w,j)}else{if("value"in b)return b.value;var S=b.get;return S===void 0?void 0:S.call(j)}},d=a(0),m=f(d);function f(N){return N&&N.__esModule?N:{default:N}}function p(N,v){if(!(N instanceof v))throw new TypeError("Cannot call a class as a function")}function h(N,v){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:N}function x(N,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);N.prototype=Object.create(v&&v.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(N,v):N.__proto__=v)}var u=(function(N){x(v,N);function v(){return p(this,v),h(this,(v.__proto__||Object.getPrototypeOf(v)).apply(this,arguments))}return i(v,[{key:"insertInto",value:function(j,b){j.children.length===0?o(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"insertInto",this).call(this,j,b):this.remove()}},{key:"length",value:function(){return 0}},{key:"value",value:function(){return""}}],[{key:"value",value:function(){}}]),v})(m.default.Embed);u.blotName="break",u.tagName="BR",r.default=u}),(function(n,r,a){var i=this&&this.__extends||(function(){var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,u){x.__proto__=u}||function(x,u){for(var N in u)u.hasOwnProperty(N)&&(x[N]=u[N])};return function(x,u){h(x,u);function N(){this.constructor=x}x.prototype=u===null?Object.create(u):(N.prototype=u.prototype,new N)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(44),d=a(30),m=a(1),f=(function(h){i(x,h);function x(u){var N=h.call(this,u)||this;return N.build(),N}return x.prototype.appendChild=function(u){this.insertBefore(u)},x.prototype.attach=function(){h.prototype.attach.call(this),this.children.forEach(function(u){u.attach()})},x.prototype.build=function(){var u=this;this.children=new o.default,[].slice.call(this.domNode.childNodes).reverse().forEach(function(N){try{var v=p(N);u.insertBefore(v,u.children.head||void 0)}catch(w){if(w instanceof m.ParchmentError)return;throw w}})},x.prototype.deleteAt=function(u,N){if(u===0&&N===this.length())return this.remove();this.children.forEachAt(u,N,function(v,w,j){v.deleteAt(w,j)})},x.prototype.descendant=function(u,N){var v=this.children.find(N),w=v[0],j=v[1];return u.blotName==null&&u(w)||u.blotName!=null&&w instanceof u?[w,j]:w instanceof x?w.descendant(u,j):[null,-1]},x.prototype.descendants=function(u,N,v){N===void 0&&(N=0),v===void 0&&(v=Number.MAX_VALUE);var w=[],j=v;return this.children.forEachAt(N,v,function(b,C,S){(u.blotName==null&&u(b)||u.blotName!=null&&b instanceof u)&&w.push(b),b instanceof x&&(w=w.concat(b.descendants(u,C,j))),j-=S}),w},x.prototype.detach=function(){this.children.forEach(function(u){u.detach()}),h.prototype.detach.call(this)},x.prototype.formatAt=function(u,N,v,w){this.children.forEachAt(u,N,function(j,b,C){j.formatAt(b,C,v,w)})},x.prototype.insertAt=function(u,N,v){var w=this.children.find(u),j=w[0],b=w[1];if(j)j.insertAt(b,N,v);else{var C=v==null?m.create("text",N):m.create(N,v);this.appendChild(C)}},x.prototype.insertBefore=function(u,N){if(this.statics.allowedChildren!=null&&!this.statics.allowedChildren.some(function(v){return u instanceof v}))throw new m.ParchmentError("Cannot insert "+u.statics.blotName+" into "+this.statics.blotName);u.insertInto(this,N)},x.prototype.length=function(){return this.children.reduce(function(u,N){return u+N.length()},0)},x.prototype.moveChildren=function(u,N){this.children.forEach(function(v){u.insertBefore(v,N)})},x.prototype.optimize=function(u){if(h.prototype.optimize.call(this,u),this.children.length===0)if(this.statics.defaultChild!=null){var N=m.create(this.statics.defaultChild);this.appendChild(N),N.optimize(u)}else this.remove()},x.prototype.path=function(u,N){N===void 0&&(N=!1);var v=this.children.find(u,N),w=v[0],j=v[1],b=[[this,u]];return w instanceof x?b.concat(w.path(j,N)):(w!=null&&b.push([w,j]),b)},x.prototype.removeChild=function(u){this.children.remove(u)},x.prototype.replace=function(u){u instanceof x&&u.moveChildren(this),h.prototype.replace.call(this,u)},x.prototype.split=function(u,N){if(N===void 0&&(N=!1),!N){if(u===0)return this;if(u===this.length())return this.next}var v=this.clone();return this.parent.insertBefore(v,this.next),this.children.forEachAt(u,this.length(),function(w,j,b){w=w.split(j,N),v.appendChild(w)}),v},x.prototype.unwrap=function(){this.moveChildren(this.parent,this.next),this.remove()},x.prototype.update=function(u,N){var v=this,w=[],j=[];u.forEach(function(b){b.target===v.domNode&&b.type==="childList"&&(w.push.apply(w,b.addedNodes),j.push.apply(j,b.removedNodes))}),j.forEach(function(b){if(!(b.parentNode!=null&&b.tagName!=="IFRAME"&&document.body.compareDocumentPosition(b)&Node.DOCUMENT_POSITION_CONTAINED_BY)){var C=m.find(b);C!=null&&(C.domNode.parentNode==null||C.domNode.parentNode===v.domNode)&&C.detach()}}),w.filter(function(b){return b.parentNode==v.domNode}).sort(function(b,C){return b===C?0:b.compareDocumentPosition(C)&Node.DOCUMENT_POSITION_FOLLOWING?1:-1}).forEach(function(b){var C=null;b.nextSibling!=null&&(C=m.find(b.nextSibling));var S=p(b);(S.next!=C||S.next==null)&&(S.parent!=null&&S.parent.removeChild(v),v.insertBefore(S,C||void 0))})},x})(d.default);function p(h){var x=m.find(h);if(x==null)try{x=m.create(h)}catch{x=m.create(m.Scope.INLINE),[].slice.call(h.childNodes).forEach(function(N){x.domNode.appendChild(N)}),h.parentNode&&h.parentNode.replaceChild(x.domNode,h),x.attach()}return x}r.default=f}),(function(n,r,a){var i=this&&this.__extends||(function(){var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,u){x.__proto__=u}||function(x,u){for(var N in u)u.hasOwnProperty(N)&&(x[N]=u[N])};return function(x,u){h(x,u);function N(){this.constructor=x}x.prototype=u===null?Object.create(u):(N.prototype=u.prototype,new N)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(12),d=a(31),m=a(17),f=a(1),p=(function(h){i(x,h);function x(u){var N=h.call(this,u)||this;return N.attributes=new d.default(N.domNode),N}return x.formats=function(u){if(typeof this.tagName=="string")return!0;if(Array.isArray(this.tagName))return u.tagName.toLowerCase()},x.prototype.format=function(u,N){var v=f.query(u);v instanceof o.default?this.attributes.attribute(v,N):N&&v!=null&&(u!==this.statics.blotName||this.formats()[u]!==N)&&this.replaceWith(u,N)},x.prototype.formats=function(){var u=this.attributes.values(),N=this.statics.formats(this.domNode);return N!=null&&(u[this.statics.blotName]=N),u},x.prototype.replaceWith=function(u,N){var v=h.prototype.replaceWith.call(this,u,N);return this.attributes.copy(v),v},x.prototype.update=function(u,N){var v=this;h.prototype.update.call(this,u,N),u.some(function(w){return w.target===v.domNode&&w.type==="attributes"})&&this.attributes.build()},x.prototype.wrap=function(u,N){var v=h.prototype.wrap.call(this,u,N);return v instanceof x&&v.statics.scope===this.statics.scope&&this.attributes.move(v),v},x})(m.default);r.default=p}),(function(n,r,a){var i=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,h){p.__proto__=h}||function(p,h){for(var x in h)h.hasOwnProperty(x)&&(p[x]=h[x])};return function(p,h){f(p,h);function x(){this.constructor=p}p.prototype=h===null?Object.create(h):(x.prototype=h.prototype,new x)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(30),d=a(1),m=(function(f){i(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.value=function(h){return!0},p.prototype.index=function(h,x){return this.domNode===h||this.domNode.compareDocumentPosition(h)&Node.DOCUMENT_POSITION_CONTAINED_BY?Math.min(x,1):-1},p.prototype.position=function(h,x){var u=[].indexOf.call(this.parent.domNode.childNodes,this.domNode);return h>0&&(u+=1),[this.parent.domNode,u]},p.prototype.value=function(){var h;return h={},h[this.statics.blotName]=this.statics.value(this.domNode)||!0,h},p.scope=d.Scope.INLINE_BLOT,p})(o.default);r.default=m}),(function(n,r,a){var i=a(11),o=a(3),d={attributes:{compose:function(f,p,h){typeof f!="object"&&(f={}),typeof p!="object"&&(p={});var x=o(!0,{},p);h||(x=Object.keys(x).reduce(function(N,v){return x[v]!=null&&(N[v]=x[v]),N},{}));for(var u in f)f[u]!==void 0&&p[u]===void 0&&(x[u]=f[u]);return Object.keys(x).length>0?x:void 0},diff:function(f,p){typeof f!="object"&&(f={}),typeof p!="object"&&(p={});var h=Object.keys(f).concat(Object.keys(p)).reduce(function(x,u){return i(f[u],p[u])||(x[u]=p[u]===void 0?null:p[u]),x},{});return Object.keys(h).length>0?h:void 0},transform:function(f,p,h){if(typeof f!="object")return p;if(typeof p=="object"){if(!h)return p;var x=Object.keys(p).reduce(function(u,N){return f[N]===void 0&&(u[N]=p[N]),u},{});return Object.keys(x).length>0?x:void 0}}},iterator:function(f){return new m(f)},length:function(f){return typeof f.delete=="number"?f.delete:typeof f.retain=="number"?f.retain:typeof f.insert=="string"?f.insert.length:1}};function m(f){this.ops=f,this.index=0,this.offset=0}m.prototype.hasNext=function(){return this.peekLength()<1/0},m.prototype.next=function(f){f||(f=1/0);var p=this.ops[this.index];if(p){var h=this.offset,x=d.length(p);if(f>=x-h?(f=x-h,this.index+=1,this.offset=0):this.offset+=f,typeof p.delete=="number")return{delete:f};var u={};return p.attributes&&(u.attributes=p.attributes),typeof p.retain=="number"?u.retain=f:typeof p.insert=="string"?u.insert=p.insert.substr(h,f):u.insert=p.insert,u}else return{retain:1/0}},m.prototype.peek=function(){return this.ops[this.index]},m.prototype.peekLength=function(){return this.ops[this.index]?d.length(this.ops[this.index])-this.offset:1/0},m.prototype.peekType=function(){return this.ops[this.index]?typeof this.ops[this.index].delete=="number"?"delete":typeof this.ops[this.index].retain=="number"?"retain":"insert":"retain"},m.prototype.rest=function(){if(this.hasNext()){if(this.offset===0)return this.ops.slice(this.index);var f=this.offset,p=this.index,h=this.next(),x=this.ops.slice(this.index);return this.offset=f,this.index=p,[h].concat(x)}else return[]},n.exports=d}),(function(n,r){var a=(function(){function i(v,w){return w!=null&&v instanceof w}var o;try{o=Map}catch{o=function(){}}var d;try{d=Set}catch{d=function(){}}var m;try{m=Promise}catch{m=function(){}}function f(v,w,j,b,C){typeof w=="object"&&(j=w.depth,b=w.prototype,C=w.includeNonEnumerable,w=w.circular);var S=[],R=[],_=typeof Buffer<"u";typeof w>"u"&&(w=!0),typeof j>"u"&&(j=1/0);function A(E,q){if(E===null)return null;if(q===0)return E;var O,D;if(typeof E!="object")return E;if(i(E,o))O=new o;else if(i(E,d))O=new d;else if(i(E,m))O=new m(function(z,T){E.then(function(I){z(A(I,q-1))},function(I){T(A(I,q-1))})});else if(f.__isArray(E))O=[];else if(f.__isRegExp(E))O=new RegExp(E.source,N(E)),E.lastIndex&&(O.lastIndex=E.lastIndex);else if(f.__isDate(E))O=new Date(E.getTime());else{if(_&&Buffer.isBuffer(E))return Buffer.allocUnsafe?O=Buffer.allocUnsafe(E.length):O=new Buffer(E.length),E.copy(O),O;i(E,Error)?O=Object.create(E):typeof b>"u"?(D=Object.getPrototypeOf(E),O=Object.create(D)):(O=Object.create(b),D=b)}if(w){var P=S.indexOf(E);if(P!=-1)return R[P];S.push(E),R.push(O)}i(E,o)&&E.forEach(function(z,T){var I=A(T,q-1),B=A(z,q-1);O.set(I,B)}),i(E,d)&&E.forEach(function(z){var T=A(z,q-1);O.add(T)});for(var L in E){var $;D&&($=Object.getOwnPropertyDescriptor(D,L)),!($&&$.set==null)&&(O[L]=A(E[L],q-1))}if(Object.getOwnPropertySymbols)for(var Y=Object.getOwnPropertySymbols(E),L=0;L<Y.length;L++){var Z=Y[L],W=Object.getOwnPropertyDescriptor(E,Z);W&&!W.enumerable&&!C||(O[Z]=A(E[Z],q-1),W.enumerable||Object.defineProperty(O,Z,{enumerable:!1}))}if(C)for(var U=Object.getOwnPropertyNames(E),L=0;L<U.length;L++){var M=U[L],W=Object.getOwnPropertyDescriptor(E,M);W&&W.enumerable||(O[M]=A(E[M],q-1),Object.defineProperty(O,M,{enumerable:!1}))}return O}return A(v,j)}f.clonePrototype=function(w){if(w===null)return null;var j=function(){};return j.prototype=w,new j};function p(v){return Object.prototype.toString.call(v)}f.__objToStr=p;function h(v){return typeof v=="object"&&p(v)==="[object Date]"}f.__isDate=h;function x(v){return typeof v=="object"&&p(v)==="[object Array]"}f.__isArray=x;function u(v){return typeof v=="object"&&p(v)==="[object RegExp]"}f.__isRegExp=u;function N(v){var w="";return v.global&&(w+="g"),v.ignoreCase&&(w+="i"),v.multiline&&(w+="m"),w}return f.__getRegExpFlags=N,f})();typeof n=="object"&&n.exports&&(n.exports=a)}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function O(D,P){var L=[],$=!0,Y=!1,Z=void 0;try{for(var W=D[Symbol.iterator](),U;!($=(U=W.next()).done)&&(L.push(U.value),!(P&&L.length===P));$=!0);}catch(M){Y=!0,Z=M}finally{try{!$&&W.return&&W.return()}finally{if(Y)throw Z}}return L}return function(D,P){if(Array.isArray(D))return D;if(Symbol.iterator in Object(D))return O(D,P);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=(function(){function O(D,P){for(var L=0;L<P.length;L++){var $=P[L];$.enumerable=$.enumerable||!1,$.configurable=!0,"value"in $&&($.writable=!0),Object.defineProperty(D,$.key,$)}}return function(D,P,L){return P&&O(D.prototype,P),L&&O(D,L),D}})(),d=function O(D,P,L){D===null&&(D=Function.prototype);var $=Object.getOwnPropertyDescriptor(D,P);if($===void 0){var Y=Object.getPrototypeOf(D);return Y===null?void 0:O(Y,P,L)}else{if("value"in $)return $.value;var Z=$.get;return Z===void 0?void 0:Z.call(L)}},m=a(0),f=S(m),p=a(8),h=S(p),x=a(4),u=S(x),N=a(16),v=S(N),w=a(13),j=S(w),b=a(25),C=S(b);function S(O){return O&&O.__esModule?O:{default:O}}function R(O,D){if(!(O instanceof D))throw new TypeError("Cannot call a class as a function")}function _(O,D){if(!O)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D&&(typeof D=="object"||typeof D=="function")?D:O}function A(O,D){if(typeof D!="function"&&D!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof D);O.prototype=Object.create(D&&D.prototype,{constructor:{value:O,enumerable:!1,writable:!0,configurable:!0}}),D&&(Object.setPrototypeOf?Object.setPrototypeOf(O,D):O.__proto__=D)}function E(O){return O instanceof u.default||O instanceof x.BlockEmbed}var q=(function(O){A(D,O);function D(P,L){R(this,D);var $=_(this,(D.__proto__||Object.getPrototypeOf(D)).call(this,P));return $.emitter=L.emitter,Array.isArray(L.whitelist)&&($.whitelist=L.whitelist.reduce(function(Y,Z){return Y[Z]=!0,Y},{})),$.domNode.addEventListener("DOMNodeInserted",function(){}),$.optimize(),$.enable(),$}return o(D,[{key:"batchStart",value:function(){this.batch=!0}},{key:"batchEnd",value:function(){this.batch=!1,this.optimize()}},{key:"deleteAt",value:function(L,$){var Y=this.line(L),Z=i(Y,2),W=Z[0],U=Z[1],M=this.line(L+$),z=i(M,1),T=z[0];if(d(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"deleteAt",this).call(this,L,$),T!=null&&W!==T&&U>0){if(W instanceof x.BlockEmbed||T instanceof x.BlockEmbed){this.optimize();return}if(W instanceof j.default){var I=W.newlineIndex(W.length(),!0);if(I>-1&&(W=W.split(I+1),W===T)){this.optimize();return}}else if(T instanceof j.default){var B=T.newlineIndex(0);B>-1&&T.split(B+1)}var G=T.children.head instanceof v.default?null:T.children.head;W.moveChildren(T,G),W.remove()}this.optimize()}},{key:"enable",value:function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.domNode.setAttribute("contenteditable",L)}},{key:"formatAt",value:function(L,$,Y,Z){this.whitelist!=null&&!this.whitelist[Y]||(d(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"formatAt",this).call(this,L,$,Y,Z),this.optimize())}},{key:"insertAt",value:function(L,$,Y){if(!(Y!=null&&this.whitelist!=null&&!this.whitelist[$])){if(L>=this.length())if(Y==null||f.default.query($,f.default.Scope.BLOCK)==null){var Z=f.default.create(this.statics.defaultChild);this.appendChild(Z),Y==null&&$.endsWith(`
`)&&($=$.slice(0,-1)),Z.insertAt(0,$,Y)}else{var W=f.default.create($,Y);this.appendChild(W)}else d(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"insertAt",this).call(this,L,$,Y);this.optimize()}}},{key:"insertBefore",value:function(L,$){if(L.statics.scope===f.default.Scope.INLINE_BLOT){var Y=f.default.create(this.statics.defaultChild);Y.appendChild(L),L=Y}d(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"insertBefore",this).call(this,L,$)}},{key:"leaf",value:function(L){return this.path(L).pop()||[null,-1]}},{key:"line",value:function(L){return L===this.length()?this.line(L-1):this.descendant(E,L)}},{key:"lines",value:function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,$=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE,Y=function Z(W,U,M){var z=[],T=M;return W.children.forEachAt(U,M,function(I,B,G){E(I)?z.push(I):I instanceof f.default.Container&&(z=z.concat(Z(I,B,T))),T-=G}),z};return Y(this,L,$)}},{key:"optimize",value:function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],$=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.batch!==!0&&(d(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"optimize",this).call(this,L,$),L.length>0&&this.emitter.emit(h.default.events.SCROLL_OPTIMIZE,L,$))}},{key:"path",value:function(L){return d(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"path",this).call(this,L).slice(1)}},{key:"update",value:function(L){if(this.batch!==!0){var $=h.default.sources.USER;typeof L=="string"&&($=L),Array.isArray(L)||(L=this.observer.takeRecords()),L.length>0&&this.emitter.emit(h.default.events.SCROLL_BEFORE_UPDATE,$,L),d(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"update",this).call(this,L.concat([])),L.length>0&&this.emitter.emit(h.default.events.SCROLL_UPDATE,$,L)}}}]),D})(f.default.Scroll);q.blotName="scroll",q.className="ql-editor",q.tagName="DIV",q.defaultChild="block",q.allowedChildren=[u.default,x.BlockEmbed,C.default],r.default=q}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.SHORTKEY=r.default=void 0;var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(H){return typeof H}:function(H){return H&&typeof Symbol=="function"&&H.constructor===Symbol&&H!==Symbol.prototype?"symbol":typeof H},o=(function(){function H(X,J){var ae=[],le=!0,xe=!1,ce=void 0;try{for(var ve=X[Symbol.iterator](),Pe;!(le=(Pe=ve.next()).done)&&(ae.push(Pe.value),!(J&&ae.length===J));le=!0);}catch(et){xe=!0,ce=et}finally{try{!le&&ve.return&&ve.return()}finally{if(xe)throw ce}}return ae}return function(X,J){if(Array.isArray(X))return X;if(Symbol.iterator in Object(X))return H(X,J);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function H(X,J){for(var ae=0;ae<J.length;ae++){var le=J[ae];le.enumerable=le.enumerable||!1,le.configurable=!0,"value"in le&&(le.writable=!0),Object.defineProperty(X,le.key,le)}}return function(X,J,ae){return J&&H(X.prototype,J),ae&&H(X,ae),X}})(),m=a(21),f=O(m),p=a(11),h=O(p),x=a(3),u=O(x),N=a(2),v=O(N),w=a(20),j=O(w),b=a(0),C=O(b),S=a(5),R=O(S),_=a(10),A=O(_),E=a(9),q=O(E);function O(H){return H&&H.__esModule?H:{default:H}}function D(H,X,J){return X in H?Object.defineProperty(H,X,{value:J,enumerable:!0,configurable:!0,writable:!0}):H[X]=J,H}function P(H,X){if(!(H instanceof X))throw new TypeError("Cannot call a class as a function")}function L(H,X){if(!H)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return X&&(typeof X=="object"||typeof X=="function")?X:H}function $(H,X){if(typeof X!="function"&&X!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof X);H.prototype=Object.create(X&&X.prototype,{constructor:{value:H,enumerable:!1,writable:!0,configurable:!0}}),X&&(Object.setPrototypeOf?Object.setPrototypeOf(H,X):H.__proto__=X)}var Y=(0,A.default)("quill:keyboard"),Z=/Mac/i.test(navigator.platform)?"metaKey":"ctrlKey",W=(function(H){$(X,H),d(X,null,[{key:"match",value:function(ae,le){return le=K(le),["altKey","ctrlKey","metaKey","shiftKey"].some(function(xe){return!!le[xe]!==ae[xe]&&le[xe]!==null})?!1:le.key===(ae.which||ae.keyCode)}}]);function X(J,ae){P(this,X);var le=L(this,(X.__proto__||Object.getPrototypeOf(X)).call(this,J,ae));return le.bindings={},Object.keys(le.options.bindings).forEach(function(xe){xe==="list autofill"&&J.scroll.whitelist!=null&&!J.scroll.whitelist.list||le.options.bindings[xe]&&le.addBinding(le.options.bindings[xe])}),le.addBinding({key:X.keys.ENTER,shiftKey:null},I),le.addBinding({key:X.keys.ENTER,metaKey:null,ctrlKey:null,altKey:null},function(){}),/Firefox/i.test(navigator.userAgent)?(le.addBinding({key:X.keys.BACKSPACE},{collapsed:!0},M),le.addBinding({key:X.keys.DELETE},{collapsed:!0},z)):(le.addBinding({key:X.keys.BACKSPACE},{collapsed:!0,prefix:/^.?$/},M),le.addBinding({key:X.keys.DELETE},{collapsed:!0,suffix:/^.?$/},z)),le.addBinding({key:X.keys.BACKSPACE},{collapsed:!1},T),le.addBinding({key:X.keys.DELETE},{collapsed:!1},T),le.addBinding({key:X.keys.BACKSPACE,altKey:null,ctrlKey:null,metaKey:null,shiftKey:null},{collapsed:!0,offset:0},M),le.listen(),le}return d(X,[{key:"addBinding",value:function(ae){var le=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},xe=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},ce=K(ae);if(ce==null||ce.key==null)return Y.warn("Attempted to add invalid keyboard binding",ce);typeof le=="function"&&(le={handler:le}),typeof xe=="function"&&(xe={handler:xe}),ce=(0,u.default)(ce,le,xe),this.bindings[ce.key]=this.bindings[ce.key]||[],this.bindings[ce.key].push(ce)}},{key:"listen",value:function(){var ae=this;this.quill.root.addEventListener("keydown",function(le){if(!le.defaultPrevented){var xe=le.which||le.keyCode,ce=(ae.bindings[xe]||[]).filter(function(ht){return X.match(le,ht)});if(ce.length!==0){var ve=ae.quill.getSelection();if(!(ve==null||!ae.quill.hasFocus())){var Pe=ae.quill.getLine(ve.index),et=o(Pe,2),kt=et[0],vt=et[1],ee=ae.quill.getLeaf(ve.index),ge=o(ee,2),ye=ge[0],Be=ge[1],$e=ve.length===0?[ye,Be]:ae.quill.getLeaf(ve.index+ve.length),dt=o($e,2),st=dt[0],xt=dt[1],Mt=ye instanceof C.default.Text?ye.value().slice(0,Be):"",It=st instanceof C.default.Text?st.value().slice(xt):"",he={collapsed:ve.length===0,empty:ve.length===0&&kt.length()<=1,format:ae.quill.getFormat(ve),offset:vt,prefix:Mt,suffix:It},pt=ce.some(function(ht){if(ht.collapsed!=null&&ht.collapsed!==he.collapsed||ht.empty!=null&&ht.empty!==he.empty||ht.offset!=null&&ht.offset!==he.offset)return!1;if(Array.isArray(ht.format)){if(ht.format.every(function(_e){return he.format[_e]==null}))return!1}else if(i(ht.format)==="object"&&!Object.keys(ht.format).every(function(_e){return ht.format[_e]===!0?he.format[_e]!=null:ht.format[_e]===!1?he.format[_e]==null:(0,h.default)(ht.format[_e],he.format[_e])}))return!1;return ht.prefix!=null&&!ht.prefix.test(he.prefix)||ht.suffix!=null&&!ht.suffix.test(he.suffix)?!1:ht.handler.call(ae,ve,he)!==!0});pt&&le.preventDefault()}}}})}}]),X})(q.default);W.keys={BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46},W.DEFAULTS={bindings:{bold:G("bold"),italic:G("italic"),underline:G("underline"),indent:{key:W.keys.TAB,format:["blockquote","indent","list"],handler:function(X,J){if(J.collapsed&&J.offset!==0)return!0;this.quill.format("indent","+1",R.default.sources.USER)}},outdent:{key:W.keys.TAB,shiftKey:!0,format:["blockquote","indent","list"],handler:function(X,J){if(J.collapsed&&J.offset!==0)return!0;this.quill.format("indent","-1",R.default.sources.USER)}},"outdent backspace":{key:W.keys.BACKSPACE,collapsed:!0,shiftKey:null,metaKey:null,ctrlKey:null,altKey:null,format:["indent","list"],offset:0,handler:function(X,J){J.format.indent!=null?this.quill.format("indent","-1",R.default.sources.USER):J.format.list!=null&&this.quill.format("list",!1,R.default.sources.USER)}},"indent code-block":B(!0),"outdent code-block":B(!1),"remove tab":{key:W.keys.TAB,shiftKey:!0,collapsed:!0,prefix:/\t$/,handler:function(X){this.quill.deleteText(X.index-1,1,R.default.sources.USER)}},tab:{key:W.keys.TAB,handler:function(X){this.quill.history.cutoff();var J=new v.default().retain(X.index).delete(X.length).insert(" ");this.quill.updateContents(J,R.default.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(X.index+1,R.default.sources.SILENT)}},"list empty enter":{key:W.keys.ENTER,collapsed:!0,format:["list"],empty:!0,handler:function(X,J){this.quill.format("list",!1,R.default.sources.USER),J.format.indent&&this.quill.format("indent",!1,R.default.sources.USER)}},"checklist enter":{key:W.keys.ENTER,collapsed:!0,format:{list:"checked"},handler:function(X){var J=this.quill.getLine(X.index),ae=o(J,2),le=ae[0],xe=ae[1],ce=(0,u.default)({},le.formats(),{list:"checked"}),ve=new v.default().retain(X.index).insert(`
`,ce).retain(le.length()-xe-1).retain(1,{list:"unchecked"});this.quill.updateContents(ve,R.default.sources.USER),this.quill.setSelection(X.index+1,R.default.sources.SILENT),this.quill.scrollIntoView()}},"header enter":{key:W.keys.ENTER,collapsed:!0,format:["header"],suffix:/^$/,handler:function(X,J){var ae=this.quill.getLine(X.index),le=o(ae,2),xe=le[0],ce=le[1],ve=new v.default().retain(X.index).insert(`
`,J.format).retain(xe.length()-ce-1).retain(1,{header:null});this.quill.updateContents(ve,R.default.sources.USER),this.quill.setSelection(X.index+1,R.default.sources.SILENT),this.quill.scrollIntoView()}},"list autofill":{key:" ",collapsed:!0,format:{list:!1},prefix:/^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,handler:function(X,J){var ae=J.prefix.length,le=this.quill.getLine(X.index),xe=o(le,2),ce=xe[0],ve=xe[1];if(ve>ae)return!0;var Pe=void 0;switch(J.prefix.trim()){case"[]":case"[ ]":Pe="unchecked";break;case"[x]":Pe="checked";break;case"-":case"*":Pe="bullet";break;default:Pe="ordered"}this.quill.insertText(X.index," ",R.default.sources.USER),this.quill.history.cutoff();var et=new v.default().retain(X.index-ve).delete(ae+1).retain(ce.length()-2-ve).retain(1,{list:Pe});this.quill.updateContents(et,R.default.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(X.index-ae,R.default.sources.SILENT)}},"code exit":{key:W.keys.ENTER,collapsed:!0,format:["code-block"],prefix:/\n\n$/,suffix:/^\s+$/,handler:function(X){var J=this.quill.getLine(X.index),ae=o(J,2),le=ae[0],xe=ae[1],ce=new v.default().retain(X.index+le.length()-xe-2).retain(1,{"code-block":null}).delete(1);this.quill.updateContents(ce,R.default.sources.USER)}},"embed left":U(W.keys.LEFT,!1),"embed left shift":U(W.keys.LEFT,!0),"embed right":U(W.keys.RIGHT,!1),"embed right shift":U(W.keys.RIGHT,!0)}};function U(H,X){var J,ae=H===W.keys.LEFT?"prefix":"suffix";return J={key:H,shiftKey:X,altKey:null},D(J,ae,/^$/),D(J,"handler",function(xe){var ce=xe.index;H===W.keys.RIGHT&&(ce+=xe.length+1);var ve=this.quill.getLeaf(ce),Pe=o(ve,1),et=Pe[0];return et instanceof C.default.Embed?(H===W.keys.LEFT?X?this.quill.setSelection(xe.index-1,xe.length+1,R.default.sources.USER):this.quill.setSelection(xe.index-1,R.default.sources.USER):X?this.quill.setSelection(xe.index,xe.length+1,R.default.sources.USER):this.quill.setSelection(xe.index+xe.length+1,R.default.sources.USER),!1):!0}),J}function M(H,X){if(!(H.index===0||this.quill.getLength()<=1)){var J=this.quill.getLine(H.index),ae=o(J,1),le=ae[0],xe={};if(X.offset===0){var ce=this.quill.getLine(H.index-1),ve=o(ce,1),Pe=ve[0];if(Pe!=null&&Pe.length()>1){var et=le.formats(),kt=this.quill.getFormat(H.index-1,1);xe=j.default.attributes.diff(et,kt)||{}}}var vt=/[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(X.prefix)?2:1;this.quill.deleteText(H.index-vt,vt,R.default.sources.USER),Object.keys(xe).length>0&&this.quill.formatLine(H.index-vt,vt,xe,R.default.sources.USER),this.quill.focus()}}function z(H,X){var J=/^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(X.suffix)?2:1;if(!(H.index>=this.quill.getLength()-J)){var ae={},le=0,xe=this.quill.getLine(H.index),ce=o(xe,1),ve=ce[0];if(X.offset>=ve.length()-1){var Pe=this.quill.getLine(H.index+1),et=o(Pe,1),kt=et[0];if(kt){var vt=ve.formats(),ee=this.quill.getFormat(H.index,1);ae=j.default.attributes.diff(vt,ee)||{},le=kt.length()}}this.quill.deleteText(H.index,J,R.default.sources.USER),Object.keys(ae).length>0&&this.quill.formatLine(H.index+le-1,J,ae,R.default.sources.USER)}}function T(H){var X=this.quill.getLines(H),J={};if(X.length>1){var ae=X[0].formats(),le=X[X.length-1].formats();J=j.default.attributes.diff(le,ae)||{}}this.quill.deleteText(H,R.default.sources.USER),Object.keys(J).length>0&&this.quill.formatLine(H.index,1,J,R.default.sources.USER),this.quill.setSelection(H.index,R.default.sources.SILENT),this.quill.focus()}function I(H,X){var J=this;H.length>0&&this.quill.scroll.deleteAt(H.index,H.length);var ae=Object.keys(X.format).reduce(function(le,xe){return C.default.query(xe,C.default.Scope.BLOCK)&&!Array.isArray(X.format[xe])&&(le[xe]=X.format[xe]),le},{});this.quill.insertText(H.index,`
`,ae,R.default.sources.USER),this.quill.setSelection(H.index+1,R.default.sources.SILENT),this.quill.focus(),Object.keys(X.format).forEach(function(le){ae[le]==null&&(Array.isArray(X.format[le])||le!=="link"&&J.quill.format(le,X.format[le],R.default.sources.USER))})}function B(H){return{key:W.keys.TAB,shiftKey:!H,format:{"code-block":!0},handler:function(J){var ae=C.default.query("code-block"),le=J.index,xe=J.length,ce=this.quill.scroll.descendant(ae,le),ve=o(ce,2),Pe=ve[0],et=ve[1];if(Pe!=null){var kt=this.quill.getIndex(Pe),vt=Pe.newlineIndex(et,!0)+1,ee=Pe.newlineIndex(kt+et+xe),ge=Pe.domNode.textContent.slice(vt,ee).split(`
`);et=0,ge.forEach(function(ye,Be){H?(Pe.insertAt(vt+et,ae.TAB),et+=ae.TAB.length,Be===0?le+=ae.TAB.length:xe+=ae.TAB.length):ye.startsWith(ae.TAB)&&(Pe.deleteAt(vt+et,ae.TAB.length),et-=ae.TAB.length,Be===0?le-=ae.TAB.length:xe-=ae.TAB.length),et+=ye.length+1}),this.quill.update(R.default.sources.USER),this.quill.setSelection(le,xe,R.default.sources.SILENT)}}}}function G(H){return{key:H[0].toUpperCase(),shortKey:!0,handler:function(J,ae){this.quill.format(H,!ae.format[H],R.default.sources.USER)}}}function K(H){if(typeof H=="string"||typeof H=="number")return K({key:H});if((typeof H>"u"?"undefined":i(H))==="object"&&(H=(0,f.default)(H,!1)),typeof H.key=="string")if(W.keys[H.key.toUpperCase()]!=null)H.key=W.keys[H.key.toUpperCase()];else if(H.key.length===1)H.key=H.key.toUpperCase().charCodeAt(0);else return null;return H.shortKey&&(H[Z]=H.shortKey,delete H.shortKey),H}r.default=W,r.SHORTKEY=Z}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function j(b,C){var S=[],R=!0,_=!1,A=void 0;try{for(var E=b[Symbol.iterator](),q;!(R=(q=E.next()).done)&&(S.push(q.value),!(C&&S.length===C));R=!0);}catch(O){_=!0,A=O}finally{try{!R&&E.return&&E.return()}finally{if(_)throw A}}return S}return function(b,C){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return j(b,C);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=function j(b,C,S){b===null&&(b=Function.prototype);var R=Object.getOwnPropertyDescriptor(b,C);if(R===void 0){var _=Object.getPrototypeOf(b);return _===null?void 0:j(_,C,S)}else{if("value"in R)return R.value;var A=R.get;return A===void 0?void 0:A.call(S)}},d=(function(){function j(b,C){for(var S=0;S<C.length;S++){var R=C[S];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(b,R.key,R)}}return function(b,C,S){return C&&j(b.prototype,C),S&&j(b,S),b}})(),m=a(0),f=x(m),p=a(7),h=x(p);function x(j){return j&&j.__esModule?j:{default:j}}function u(j,b){if(!(j instanceof b))throw new TypeError("Cannot call a class as a function")}function N(j,b){if(!j)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b&&(typeof b=="object"||typeof b=="function")?b:j}function v(j,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof b);j.prototype=Object.create(b&&b.prototype,{constructor:{value:j,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(j,b):j.__proto__=b)}var w=(function(j){v(b,j),d(b,null,[{key:"value",value:function(){}}]);function b(C,S){u(this,b);var R=N(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,C));return R.selection=S,R.textNode=document.createTextNode(b.CONTENTS),R.domNode.appendChild(R.textNode),R._length=0,R}return d(b,[{key:"detach",value:function(){this.parent!=null&&this.parent.removeChild(this)}},{key:"format",value:function(S,R){if(this._length!==0)return o(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"format",this).call(this,S,R);for(var _=this,A=0;_!=null&&_.statics.scope!==f.default.Scope.BLOCK_BLOT;)A+=_.offset(_.parent),_=_.parent;_!=null&&(this._length=b.CONTENTS.length,_.optimize(),_.formatAt(A,b.CONTENTS.length,S,R),this._length=0)}},{key:"index",value:function(S,R){return S===this.textNode?0:o(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"index",this).call(this,S,R)}},{key:"length",value:function(){return this._length}},{key:"position",value:function(){return[this.textNode,this.textNode.data.length]}},{key:"remove",value:function(){o(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"remove",this).call(this),this.parent=null}},{key:"restore",value:function(){if(!(this.selection.composing||this.parent==null)){var S=this.textNode,R=this.selection.getNativeRange(),_=void 0,A=void 0,E=void 0;if(R!=null&&R.start.node===S&&R.end.node===S){var q=[S,R.start.offset,R.end.offset];_=q[0],A=q[1],E=q[2]}for(;this.domNode.lastChild!=null&&this.domNode.lastChild!==this.textNode;)this.domNode.parentNode.insertBefore(this.domNode.lastChild,this.domNode);if(this.textNode.data!==b.CONTENTS){var O=this.textNode.data.split(b.CONTENTS).join("");this.next instanceof h.default?(_=this.next.domNode,this.next.insertAt(0,O),this.textNode.data=b.CONTENTS):(this.textNode.data=O,this.parent.insertBefore(f.default.create(this.textNode),this),this.textNode=document.createTextNode(b.CONTENTS),this.domNode.appendChild(this.textNode))}if(this.remove(),A!=null){var D=[A,E].map(function(L){return Math.max(0,Math.min(_.data.length,L-1))}),P=i(D,2);return A=P[0],E=P[1],{startNode:_,startOffset:A,endNode:_,endOffset:E}}}}},{key:"update",value:function(S,R){var _=this;if(S.some(function(E){return E.type==="characterData"&&E.target===_.textNode})){var A=this.restore();A&&(R.range=A)}}},{key:"value",value:function(){return""}}]),b})(f.default.Embed);w.blotName="cursor",w.className="ql-cursor",w.tagName="span",w.CONTENTS="\uFEFF",r.default=w}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(0),o=f(i),d=a(4),m=f(d);function f(N){return N&&N.__esModule?N:{default:N}}function p(N,v){if(!(N instanceof v))throw new TypeError("Cannot call a class as a function")}function h(N,v){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:N}function x(N,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);N.prototype=Object.create(v&&v.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(N,v):N.__proto__=v)}var u=(function(N){x(v,N);function v(){return p(this,v),h(this,(v.__proto__||Object.getPrototypeOf(v)).apply(this,arguments))}return v})(o.default.Container);u.allowedChildren=[m.default,d.BlockEmbed,u],r.default=u}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.ColorStyle=r.ColorClass=r.ColorAttributor=void 0;var i=(function(){function w(j,b){for(var C=0;C<b.length;C++){var S=b[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(j,S.key,S)}}return function(j,b,C){return b&&w(j.prototype,b),C&&w(j,C),j}})(),o=function w(j,b,C){j===null&&(j=Function.prototype);var S=Object.getOwnPropertyDescriptor(j,b);if(S===void 0){var R=Object.getPrototypeOf(j);return R===null?void 0:w(R,b,C)}else{if("value"in S)return S.value;var _=S.get;return _===void 0?void 0:_.call(C)}},d=a(0),m=f(d);function f(w){return w&&w.__esModule?w:{default:w}}function p(w,j){if(!(w instanceof j))throw new TypeError("Cannot call a class as a function")}function h(w,j){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j&&(typeof j=="object"||typeof j=="function")?j:w}function x(w,j){if(typeof j!="function"&&j!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof j);w.prototype=Object.create(j&&j.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),j&&(Object.setPrototypeOf?Object.setPrototypeOf(w,j):w.__proto__=j)}var u=(function(w){x(j,w);function j(){return p(this,j),h(this,(j.__proto__||Object.getPrototypeOf(j)).apply(this,arguments))}return i(j,[{key:"value",value:function(C){var S=o(j.prototype.__proto__||Object.getPrototypeOf(j.prototype),"value",this).call(this,C);return S.startsWith("rgb(")?(S=S.replace(/^[^\d]+/,"").replace(/[^\d]+$/,""),"#"+S.split(",").map(function(R){return("00"+parseInt(R).toString(16)).slice(-2)}).join("")):S}}]),j})(m.default.Attributor.Style),N=new m.default.Attributor.Class("color","ql-color",{scope:m.default.Scope.INLINE}),v=new u("color","color",{scope:m.default.Scope.INLINE});r.ColorAttributor=u,r.ColorClass=N,r.ColorStyle=v}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.sanitize=r.default=void 0;var i=(function(){function v(w,j){for(var b=0;b<j.length;b++){var C=j[b];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(w,C.key,C)}}return function(w,j,b){return j&&v(w.prototype,j),b&&v(w,b),w}})(),o=function v(w,j,b){w===null&&(w=Function.prototype);var C=Object.getOwnPropertyDescriptor(w,j);if(C===void 0){var S=Object.getPrototypeOf(w);return S===null?void 0:v(S,j,b)}else{if("value"in C)return C.value;var R=C.get;return R===void 0?void 0:R.call(b)}},d=a(6),m=f(d);function f(v){return v&&v.__esModule?v:{default:v}}function p(v,w){if(!(v instanceof w))throw new TypeError("Cannot call a class as a function")}function h(v,w){if(!v)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return w&&(typeof w=="object"||typeof w=="function")?w:v}function x(v,w){if(typeof w!="function"&&w!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof w);v.prototype=Object.create(w&&w.prototype,{constructor:{value:v,enumerable:!1,writable:!0,configurable:!0}}),w&&(Object.setPrototypeOf?Object.setPrototypeOf(v,w):v.__proto__=w)}var u=(function(v){x(w,v);function w(){return p(this,w),h(this,(w.__proto__||Object.getPrototypeOf(w)).apply(this,arguments))}return i(w,[{key:"format",value:function(b,C){if(b!==this.statics.blotName||!C)return o(w.prototype.__proto__||Object.getPrototypeOf(w.prototype),"format",this).call(this,b,C);C=this.constructor.sanitize(C),this.domNode.setAttribute("href",C)}}],[{key:"create",value:function(b){var C=o(w.__proto__||Object.getPrototypeOf(w),"create",this).call(this,b);return b=this.sanitize(b),C.setAttribute("href",b),C.setAttribute("rel","noopener noreferrer"),C.setAttribute("target","_blank"),C}},{key:"formats",value:function(b){return b.getAttribute("href")}},{key:"sanitize",value:function(b){return N(b,this.PROTOCOL_WHITELIST)?b:this.SANITIZED_URL}}]),w})(m.default);u.blotName="link",u.tagName="A",u.SANITIZED_URL="about:blank",u.PROTOCOL_WHITELIST=["http","https","mailto","tel"];function N(v,w){var j=document.createElement("a");j.href=v;var b=j.href.slice(0,j.href.indexOf(":"));return w.indexOf(b)>-1}r.default=u,r.sanitize=N}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(w){return typeof w}:function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},o=(function(){function w(j,b){for(var C=0;C<b.length;C++){var S=b[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(j,S.key,S)}}return function(j,b,C){return b&&w(j.prototype,b),C&&w(j,C),j}})(),d=a(23),m=h(d),f=a(107),p=h(f);function h(w){return w&&w.__esModule?w:{default:w}}function x(w,j){if(!(w instanceof j))throw new TypeError("Cannot call a class as a function")}var u=0;function N(w,j){w.setAttribute(j,w.getAttribute(j)!=="true")}var v=(function(){function w(j){var b=this;x(this,w),this.select=j,this.container=document.createElement("span"),this.buildPicker(),this.select.style.display="none",this.select.parentNode.insertBefore(this.container,this.select),this.label.addEventListener("mousedown",function(){b.togglePicker()}),this.label.addEventListener("keydown",function(C){switch(C.keyCode){case m.default.keys.ENTER:b.togglePicker();break;case m.default.keys.ESCAPE:b.escape(),C.preventDefault();break}}),this.select.addEventListener("change",this.update.bind(this))}return o(w,[{key:"togglePicker",value:function(){this.container.classList.toggle("ql-expanded"),N(this.label,"aria-expanded"),N(this.options,"aria-hidden")}},{key:"buildItem",value:function(b){var C=this,S=document.createElement("span");return S.tabIndex="0",S.setAttribute("role","button"),S.classList.add("ql-picker-item"),b.hasAttribute("value")&&S.setAttribute("data-value",b.getAttribute("value")),b.textContent&&S.setAttribute("data-label",b.textContent),S.addEventListener("click",function(){C.selectItem(S,!0)}),S.addEventListener("keydown",function(R){switch(R.keyCode){case m.default.keys.ENTER:C.selectItem(S,!0),R.preventDefault();break;case m.default.keys.ESCAPE:C.escape(),R.preventDefault();break}}),S}},{key:"buildLabel",value:function(){var b=document.createElement("span");return b.classList.add("ql-picker-label"),b.innerHTML=p.default,b.tabIndex="0",b.setAttribute("role","button"),b.setAttribute("aria-expanded","false"),this.container.appendChild(b),b}},{key:"buildOptions",value:function(){var b=this,C=document.createElement("span");C.classList.add("ql-picker-options"),C.setAttribute("aria-hidden","true"),C.tabIndex="-1",C.id="ql-picker-options-"+u,u+=1,this.label.setAttribute("aria-controls",C.id),this.options=C,[].slice.call(this.select.options).forEach(function(S){var R=b.buildItem(S);C.appendChild(R),S.selected===!0&&b.selectItem(R)}),this.container.appendChild(C)}},{key:"buildPicker",value:function(){var b=this;[].slice.call(this.select.attributes).forEach(function(C){b.container.setAttribute(C.name,C.value)}),this.container.classList.add("ql-picker"),this.label=this.buildLabel(),this.buildOptions()}},{key:"escape",value:function(){var b=this;this.close(),setTimeout(function(){return b.label.focus()},1)}},{key:"close",value:function(){this.container.classList.remove("ql-expanded"),this.label.setAttribute("aria-expanded","false"),this.options.setAttribute("aria-hidden","true")}},{key:"selectItem",value:function(b){var C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,S=this.container.querySelector(".ql-selected");if(b!==S&&(S!=null&&S.classList.remove("ql-selected"),b!=null&&(b.classList.add("ql-selected"),this.select.selectedIndex=[].indexOf.call(b.parentNode.children,b),b.hasAttribute("data-value")?this.label.setAttribute("data-value",b.getAttribute("data-value")):this.label.removeAttribute("data-value"),b.hasAttribute("data-label")?this.label.setAttribute("data-label",b.getAttribute("data-label")):this.label.removeAttribute("data-label"),C))){if(typeof Event=="function")this.select.dispatchEvent(new Event("change"));else if((typeof Event>"u"?"undefined":i(Event))==="object"){var R=document.createEvent("Event");R.initEvent("change",!0,!0),this.select.dispatchEvent(R)}this.close()}}},{key:"update",value:function(){var b=void 0;if(this.select.selectedIndex>-1){var C=this.container.querySelector(".ql-picker-options").children[this.select.selectedIndex];b=this.select.options[this.select.selectedIndex],this.selectItem(C)}else this.selectItem(null);var S=b!=null&&b!==this.select.querySelector("option[selected]");this.label.classList.toggle("ql-active",S)}}]),w})();r.default=v}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(0),o=Y(i),d=a(5),m=Y(d),f=a(4),p=Y(f),h=a(16),x=Y(h),u=a(25),N=Y(u),v=a(24),w=Y(v),j=a(35),b=Y(j),C=a(6),S=Y(C),R=a(22),_=Y(R),A=a(7),E=Y(A),q=a(55),O=Y(q),D=a(42),P=Y(D),L=a(23),$=Y(L);function Y(Z){return Z&&Z.__esModule?Z:{default:Z}}m.default.register({"blots/block":p.default,"blots/block/embed":f.BlockEmbed,"blots/break":x.default,"blots/container":N.default,"blots/cursor":w.default,"blots/embed":b.default,"blots/inline":S.default,"blots/scroll":_.default,"blots/text":E.default,"modules/clipboard":O.default,"modules/history":P.default,"modules/keyboard":$.default}),o.default.register(p.default,x.default,w.default,S.default,_.default,E.default),r.default=m.default}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(1),o=(function(){function d(m){this.domNode=m,this.domNode[i.DATA_KEY]={blot:this}}return Object.defineProperty(d.prototype,"statics",{get:function(){return this.constructor},enumerable:!0,configurable:!0}),d.create=function(m){if(this.tagName==null)throw new i.ParchmentError("Blot definition missing tagName");var f;return Array.isArray(this.tagName)?(typeof m=="string"&&(m=m.toUpperCase(),parseInt(m).toString()===m&&(m=parseInt(m))),typeof m=="number"?f=document.createElement(this.tagName[m-1]):this.tagName.indexOf(m)>-1?f=document.createElement(m):f=document.createElement(this.tagName[0])):f=document.createElement(this.tagName),this.className&&f.classList.add(this.className),f},d.prototype.attach=function(){this.parent!=null&&(this.scroll=this.parent.scroll)},d.prototype.clone=function(){var m=this.domNode.cloneNode(!1);return i.create(m)},d.prototype.detach=function(){this.parent!=null&&this.parent.removeChild(this),delete this.domNode[i.DATA_KEY]},d.prototype.deleteAt=function(m,f){var p=this.isolate(m,f);p.remove()},d.prototype.formatAt=function(m,f,p,h){var x=this.isolate(m,f);if(i.query(p,i.Scope.BLOT)!=null&&h)x.wrap(p,h);else if(i.query(p,i.Scope.ATTRIBUTE)!=null){var u=i.create(this.statics.scope);x.wrap(u),u.format(p,h)}},d.prototype.insertAt=function(m,f,p){var h=p==null?i.create("text",f):i.create(f,p),x=this.split(m);this.parent.insertBefore(h,x)},d.prototype.insertInto=function(m,f){f===void 0&&(f=null),this.parent!=null&&this.parent.children.remove(this);var p=null;m.children.insertBefore(this,f),f!=null&&(p=f.domNode),(this.domNode.parentNode!=m.domNode||this.domNode.nextSibling!=p)&&m.domNode.insertBefore(this.domNode,p),this.parent=m,this.attach()},d.prototype.isolate=function(m,f){var p=this.split(m);return p.split(f),p},d.prototype.length=function(){return 1},d.prototype.offset=function(m){return m===void 0&&(m=this.parent),this.parent==null||this==m?0:this.parent.children.offset(this)+this.parent.offset(m)},d.prototype.optimize=function(m){this.domNode[i.DATA_KEY]!=null&&delete this.domNode[i.DATA_KEY].mutations},d.prototype.remove=function(){this.domNode.parentNode!=null&&this.domNode.parentNode.removeChild(this.domNode),this.detach()},d.prototype.replace=function(m){m.parent!=null&&(m.parent.insertBefore(this,m.next),m.remove())},d.prototype.replaceWith=function(m,f){var p=typeof m=="string"?i.create(m,f):m;return p.replace(this),p},d.prototype.split=function(m,f){return m===0?this:this.next},d.prototype.update=function(m,f){},d.prototype.wrap=function(m,f){var p=typeof m=="string"?i.create(m,f):m;return this.parent!=null&&this.parent.insertBefore(p,this.next),p.appendChild(this),p},d.blotName="abstract",d})();r.default=o}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(12),o=a(32),d=a(33),m=a(1),f=(function(){function p(h){this.attributes={},this.domNode=h,this.build()}return p.prototype.attribute=function(h,x){x?h.add(this.domNode,x)&&(h.value(this.domNode)!=null?this.attributes[h.attrName]=h:delete this.attributes[h.attrName]):(h.remove(this.domNode),delete this.attributes[h.attrName])},p.prototype.build=function(){var h=this;this.attributes={};var x=i.default.keys(this.domNode),u=o.default.keys(this.domNode),N=d.default.keys(this.domNode);x.concat(u).concat(N).forEach(function(v){var w=m.query(v,m.Scope.ATTRIBUTE);w instanceof i.default&&(h.attributes[w.attrName]=w)})},p.prototype.copy=function(h){var x=this;Object.keys(this.attributes).forEach(function(u){var N=x.attributes[u].value(x.domNode);h.format(u,N)})},p.prototype.move=function(h){var x=this;this.copy(h),Object.keys(this.attributes).forEach(function(u){x.attributes[u].remove(x.domNode)}),this.attributes={}},p.prototype.values=function(){var h=this;return Object.keys(this.attributes).reduce(function(x,u){return x[u]=h.attributes[u].value(h.domNode),x},{})},p})();r.default=f}),(function(n,r,a){var i=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,h){p.__proto__=h}||function(p,h){for(var x in h)h.hasOwnProperty(x)&&(p[x]=h[x])};return function(p,h){f(p,h);function x(){this.constructor=p}p.prototype=h===null?Object.create(h):(x.prototype=h.prototype,new x)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(12);function d(f,p){var h=f.getAttribute("class")||"";return h.split(/\s+/).filter(function(x){return x.indexOf(p+"-")===0})}var m=(function(f){i(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.keys=function(h){return(h.getAttribute("class")||"").split(/\s+/).map(function(x){return x.split("-").slice(0,-1).join("-")})},p.prototype.add=function(h,x){return this.canAdd(h,x)?(this.remove(h),h.classList.add(this.keyName+"-"+x),!0):!1},p.prototype.remove=function(h){var x=d(h,this.keyName);x.forEach(function(u){h.classList.remove(u)}),h.classList.length===0&&h.removeAttribute("class")},p.prototype.value=function(h){var x=d(h,this.keyName)[0]||"",u=x.slice(this.keyName.length+1);return this.canAdd(h,u)?u:""},p})(o.default);r.default=m}),(function(n,r,a){var i=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,h){p.__proto__=h}||function(p,h){for(var x in h)h.hasOwnProperty(x)&&(p[x]=h[x])};return function(p,h){f(p,h);function x(){this.constructor=p}p.prototype=h===null?Object.create(h):(x.prototype=h.prototype,new x)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(12);function d(f){var p=f.split("-"),h=p.slice(1).map(function(x){return x[0].toUpperCase()+x.slice(1)}).join("");return p[0]+h}var m=(function(f){i(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.keys=function(h){return(h.getAttribute("style")||"").split(";").map(function(x){var u=x.split(":");return u[0].trim()})},p.prototype.add=function(h,x){return this.canAdd(h,x)?(h.style[d(this.keyName)]=x,!0):!1},p.prototype.remove=function(h){h.style[d(this.keyName)]="",h.getAttribute("style")||h.removeAttribute("style")},p.prototype.value=function(h){var x=h.style[d(this.keyName)];return this.canAdd(h,x)?x:""},p})(o.default);r.default=m}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function m(f,p){for(var h=0;h<p.length;h++){var x=p[h];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(f,x.key,x)}}return function(f,p,h){return p&&m(f.prototype,p),h&&m(f,h),f}})();function o(m,f){if(!(m instanceof f))throw new TypeError("Cannot call a class as a function")}var d=(function(){function m(f,p){o(this,m),this.quill=f,this.options=p,this.modules={}}return i(m,[{key:"init",value:function(){var p=this;Object.keys(this.options.modules).forEach(function(h){p.modules[h]==null&&p.addModule(h)})}},{key:"addModule",value:function(p){var h=this.quill.constructor.import("modules/"+p);return this.modules[p]=new h(this.quill,this.options.modules[p]||{}),this.modules[p]}}]),m})();d.DEFAULTS={modules:{}},d.themes={default:d},r.default=d}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function j(b,C){for(var S=0;S<C.length;S++){var R=C[S];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(b,R.key,R)}}return function(b,C,S){return C&&j(b.prototype,C),S&&j(b,S),b}})(),o=function j(b,C,S){b===null&&(b=Function.prototype);var R=Object.getOwnPropertyDescriptor(b,C);if(R===void 0){var _=Object.getPrototypeOf(b);return _===null?void 0:j(_,C,S)}else{if("value"in R)return R.value;var A=R.get;return A===void 0?void 0:A.call(S)}},d=a(0),m=h(d),f=a(7),p=h(f);function h(j){return j&&j.__esModule?j:{default:j}}function x(j,b){if(!(j instanceof b))throw new TypeError("Cannot call a class as a function")}function u(j,b){if(!j)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b&&(typeof b=="object"||typeof b=="function")?b:j}function N(j,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof b);j.prototype=Object.create(b&&b.prototype,{constructor:{value:j,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(j,b):j.__proto__=b)}var v="\uFEFF",w=(function(j){N(b,j);function b(C){x(this,b);var S=u(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,C));return S.contentNode=document.createElement("span"),S.contentNode.setAttribute("contenteditable",!1),[].slice.call(S.domNode.childNodes).forEach(function(R){S.contentNode.appendChild(R)}),S.leftGuard=document.createTextNode(v),S.rightGuard=document.createTextNode(v),S.domNode.appendChild(S.leftGuard),S.domNode.appendChild(S.contentNode),S.domNode.appendChild(S.rightGuard),S}return i(b,[{key:"index",value:function(S,R){return S===this.leftGuard?0:S===this.rightGuard?1:o(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"index",this).call(this,S,R)}},{key:"restore",value:function(S){var R=void 0,_=void 0,A=S.data.split(v).join("");if(S===this.leftGuard)if(this.prev instanceof p.default){var E=this.prev.length();this.prev.insertAt(E,A),R={startNode:this.prev.domNode,startOffset:E+A.length}}else _=document.createTextNode(A),this.parent.insertBefore(m.default.create(_),this),R={startNode:_,startOffset:A.length};else S===this.rightGuard&&(this.next instanceof p.default?(this.next.insertAt(0,A),R={startNode:this.next.domNode,startOffset:A.length}):(_=document.createTextNode(A),this.parent.insertBefore(m.default.create(_),this.next),R={startNode:_,startOffset:A.length}));return S.data=v,R}},{key:"update",value:function(S,R){var _=this;S.forEach(function(A){if(A.type==="characterData"&&(A.target===_.leftGuard||A.target===_.rightGuard)){var E=_.restore(A.target);E&&(R.range=E)}})}}]),b})(m.default.Embed);r.default=w}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.AlignStyle=r.AlignClass=r.AlignAttribute=void 0;var i=a(0),o=d(i);function d(x){return x&&x.__esModule?x:{default:x}}var m={scope:o.default.Scope.BLOCK,whitelist:["right","center","justify"]},f=new o.default.Attributor.Attribute("align","align",m),p=new o.default.Attributor.Class("align","ql-align",m),h=new o.default.Attributor.Style("align","text-align",m);r.AlignAttribute=f,r.AlignClass=p,r.AlignStyle=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.BackgroundStyle=r.BackgroundClass=void 0;var i=a(0),o=m(i),d=a(26);function m(h){return h&&h.__esModule?h:{default:h}}var f=new o.default.Attributor.Class("background","ql-bg",{scope:o.default.Scope.INLINE}),p=new d.ColorAttributor("background","background-color",{scope:o.default.Scope.INLINE});r.BackgroundClass=f,r.BackgroundStyle=p}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.DirectionStyle=r.DirectionClass=r.DirectionAttribute=void 0;var i=a(0),o=d(i);function d(x){return x&&x.__esModule?x:{default:x}}var m={scope:o.default.Scope.BLOCK,whitelist:["rtl"]},f=new o.default.Attributor.Attribute("direction","dir",m),p=new o.default.Attributor.Class("direction","ql-direction",m),h=new o.default.Attributor.Style("direction","direction",m);r.DirectionAttribute=f,r.DirectionClass=p,r.DirectionStyle=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.FontClass=r.FontStyle=void 0;var i=(function(){function j(b,C){for(var S=0;S<C.length;S++){var R=C[S];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(b,R.key,R)}}return function(b,C,S){return C&&j(b.prototype,C),S&&j(b,S),b}})(),o=function j(b,C,S){b===null&&(b=Function.prototype);var R=Object.getOwnPropertyDescriptor(b,C);if(R===void 0){var _=Object.getPrototypeOf(b);return _===null?void 0:j(_,C,S)}else{if("value"in R)return R.value;var A=R.get;return A===void 0?void 0:A.call(S)}},d=a(0),m=f(d);function f(j){return j&&j.__esModule?j:{default:j}}function p(j,b){if(!(j instanceof b))throw new TypeError("Cannot call a class as a function")}function h(j,b){if(!j)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b&&(typeof b=="object"||typeof b=="function")?b:j}function x(j,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof b);j.prototype=Object.create(b&&b.prototype,{constructor:{value:j,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(j,b):j.__proto__=b)}var u={scope:m.default.Scope.INLINE,whitelist:["serif","monospace"]},N=new m.default.Attributor.Class("font","ql-font",u),v=(function(j){x(b,j);function b(){return p(this,b),h(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}return i(b,[{key:"value",value:function(S){return o(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"value",this).call(this,S).replace(/["']/g,"")}}]),b})(m.default.Attributor.Style),w=new v("font","font-family",u);r.FontStyle=w,r.FontClass=N}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.SizeStyle=r.SizeClass=void 0;var i=a(0),o=d(i);function d(p){return p&&p.__esModule?p:{default:p}}var m=new o.default.Attributor.Class("size","ql-size",{scope:o.default.Scope.INLINE,whitelist:["small","large","huge"]}),f=new o.default.Attributor.Style("size","font-size",{scope:o.default.Scope.INLINE,whitelist:["10px","18px","32px"]});r.SizeClass=m,r.SizeStyle=f}),(function(n,r,a){n.exports={align:{"":a(76),center:a(77),right:a(78),justify:a(79)},background:a(80),blockquote:a(81),bold:a(82),clean:a(83),code:a(58),"code-block":a(58),color:a(84),direction:{"":a(85),rtl:a(86)},float:{center:a(87),full:a(88),left:a(89),right:a(90)},formula:a(91),header:{1:a(92),2:a(93)},italic:a(94),image:a(95),indent:{"+1":a(96),"-1":a(97)},link:a(98),list:{ordered:a(99),bullet:a(100),check:a(101)},script:{sub:a(102),super:a(103)},strike:a(104),underline:a(105),video:a(106)}}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.getLastChangeIndex=r.default=void 0;var i=(function(){function C(S,R){for(var _=0;_<R.length;_++){var A=R[_];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(S,A.key,A)}}return function(S,R,_){return R&&C(S.prototype,R),_&&C(S,_),S}})(),o=a(0),d=x(o),m=a(5),f=x(m),p=a(9),h=x(p);function x(C){return C&&C.__esModule?C:{default:C}}function u(C,S){if(!(C instanceof S))throw new TypeError("Cannot call a class as a function")}function N(C,S){if(!C)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return S&&(typeof S=="object"||typeof S=="function")?S:C}function v(C,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof S);C.prototype=Object.create(S&&S.prototype,{constructor:{value:C,enumerable:!1,writable:!0,configurable:!0}}),S&&(Object.setPrototypeOf?Object.setPrototypeOf(C,S):C.__proto__=S)}var w=(function(C){v(S,C);function S(R,_){u(this,S);var A=N(this,(S.__proto__||Object.getPrototypeOf(S)).call(this,R,_));return A.lastRecorded=0,A.ignoreChange=!1,A.clear(),A.quill.on(f.default.events.EDITOR_CHANGE,function(E,q,O,D){E!==f.default.events.TEXT_CHANGE||A.ignoreChange||(!A.options.userOnly||D===f.default.sources.USER?A.record(q,O):A.transform(q))}),A.quill.keyboard.addBinding({key:"Z",shortKey:!0},A.undo.bind(A)),A.quill.keyboard.addBinding({key:"Z",shortKey:!0,shiftKey:!0},A.redo.bind(A)),/Win/i.test(navigator.platform)&&A.quill.keyboard.addBinding({key:"Y",shortKey:!0},A.redo.bind(A)),A}return i(S,[{key:"change",value:function(_,A){if(this.stack[_].length!==0){var E=this.stack[_].pop();this.stack[A].push(E),this.lastRecorded=0,this.ignoreChange=!0,this.quill.updateContents(E[_],f.default.sources.USER),this.ignoreChange=!1;var q=b(E[_]);this.quill.setSelection(q)}}},{key:"clear",value:function(){this.stack={undo:[],redo:[]}}},{key:"cutoff",value:function(){this.lastRecorded=0}},{key:"record",value:function(_,A){if(_.ops.length!==0){this.stack.redo=[];var E=this.quill.getContents().diff(A),q=Date.now();if(this.lastRecorded+this.options.delay>q&&this.stack.undo.length>0){var O=this.stack.undo.pop();E=E.compose(O.undo),_=O.redo.compose(_)}else this.lastRecorded=q;this.stack.undo.push({redo:_,undo:E}),this.stack.undo.length>this.options.maxStack&&this.stack.undo.shift()}}},{key:"redo",value:function(){this.change("redo","undo")}},{key:"transform",value:function(_){this.stack.undo.forEach(function(A){A.undo=_.transform(A.undo,!0),A.redo=_.transform(A.redo,!0)}),this.stack.redo.forEach(function(A){A.undo=_.transform(A.undo,!0),A.redo=_.transform(A.redo,!0)})}},{key:"undo",value:function(){this.change("undo","redo")}}]),S})(h.default);w.DEFAULTS={delay:1e3,maxStack:100,userOnly:!1};function j(C){var S=C.ops[C.ops.length-1];return S==null?!1:S.insert!=null?typeof S.insert=="string"&&S.insert.endsWith(`
`):S.attributes!=null?Object.keys(S.attributes).some(function(R){return d.default.query(R,d.default.Scope.BLOCK)!=null}):!1}function b(C){var S=C.reduce(function(_,A){return _+=A.delete||0,_},0),R=C.length()-S;return j(C)&&(R-=1),R}r.default=w,r.getLastChangeIndex=b}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.BaseTooltip=void 0;var i=(function(){function I(B,G){for(var K=0;K<G.length;K++){var H=G[K];H.enumerable=H.enumerable||!1,H.configurable=!0,"value"in H&&(H.writable=!0),Object.defineProperty(B,H.key,H)}}return function(B,G,K){return G&&I(B.prototype,G),K&&I(B,K),B}})(),o=function I(B,G,K){B===null&&(B=Function.prototype);var H=Object.getOwnPropertyDescriptor(B,G);if(H===void 0){var X=Object.getPrototypeOf(B);return X===null?void 0:I(X,G,K)}else{if("value"in H)return H.value;var J=H.get;return J===void 0?void 0:J.call(K)}},d=a(3),m=q(d),f=a(2),p=q(f),h=a(8),x=q(h),u=a(23),N=q(u),v=a(34),w=q(v),j=a(59),b=q(j),C=a(60),S=q(C),R=a(28),_=q(R),A=a(61),E=q(A);function q(I){return I&&I.__esModule?I:{default:I}}function O(I,B){if(!(I instanceof B))throw new TypeError("Cannot call a class as a function")}function D(I,B){if(!I)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return B&&(typeof B=="object"||typeof B=="function")?B:I}function P(I,B){if(typeof B!="function"&&B!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof B);I.prototype=Object.create(B&&B.prototype,{constructor:{value:I,enumerable:!1,writable:!0,configurable:!0}}),B&&(Object.setPrototypeOf?Object.setPrototypeOf(I,B):I.__proto__=B)}var L=[!1,"center","right","justify"],$=["#000000","#e60000","#ff9900","#ffff00","#008a00","#0066cc","#9933ff","#ffffff","#facccc","#ffebcc","#ffffcc","#cce8cc","#cce0f5","#ebd6ff","#bbbbbb","#f06666","#ffc266","#ffff66","#66b966","#66a3e0","#c285ff","#888888","#a10000","#b26b00","#b2b200","#006100","#0047b2","#6b24b2","#444444","#5c0000","#663d00","#666600","#003700","#002966","#3d1466"],Y=[!1,"serif","monospace"],Z=["1","2","3",!1],W=["small",!1,"large","huge"],U=(function(I){P(B,I);function B(G,K){O(this,B);var H=D(this,(B.__proto__||Object.getPrototypeOf(B)).call(this,G,K)),X=function J(ae){if(!document.body.contains(G.root))return document.body.removeEventListener("click",J);H.tooltip!=null&&!H.tooltip.root.contains(ae.target)&&document.activeElement!==H.tooltip.textbox&&!H.quill.hasFocus()&&H.tooltip.hide(),H.pickers!=null&&H.pickers.forEach(function(le){le.container.contains(ae.target)||le.close()})};return G.emitter.listenDOM("click",document.body,X),H}return i(B,[{key:"addModule",value:function(K){var H=o(B.prototype.__proto__||Object.getPrototypeOf(B.prototype),"addModule",this).call(this,K);return K==="toolbar"&&this.extendToolbar(H),H}},{key:"buildButtons",value:function(K,H){K.forEach(function(X){var J=X.getAttribute("class")||"";J.split(/\s+/).forEach(function(ae){if(ae.startsWith("ql-")&&(ae=ae.slice(3),H[ae]!=null))if(ae==="direction")X.innerHTML=H[ae][""]+H[ae].rtl;else if(typeof H[ae]=="string")X.innerHTML=H[ae];else{var le=X.value||"";le!=null&&H[ae][le]&&(X.innerHTML=H[ae][le])}})})}},{key:"buildPickers",value:function(K,H){var X=this;this.pickers=K.map(function(ae){if(ae.classList.contains("ql-align"))return ae.querySelector("option")==null&&T(ae,L),new S.default(ae,H.align);if(ae.classList.contains("ql-background")||ae.classList.contains("ql-color")){var le=ae.classList.contains("ql-background")?"background":"color";return ae.querySelector("option")==null&&T(ae,$,le==="background"?"#ffffff":"#000000"),new b.default(ae,H[le])}else return ae.querySelector("option")==null&&(ae.classList.contains("ql-font")?T(ae,Y):ae.classList.contains("ql-header")?T(ae,Z):ae.classList.contains("ql-size")&&T(ae,W)),new _.default(ae)});var J=function(){X.pickers.forEach(function(le){le.update()})};this.quill.on(x.default.events.EDITOR_CHANGE,J)}}]),B})(w.default);U.DEFAULTS=(0,m.default)(!0,{},w.default.DEFAULTS,{modules:{toolbar:{handlers:{formula:function(){this.quill.theme.tooltip.edit("formula")},image:function(){var B=this,G=this.container.querySelector("input.ql-image[type=file]");G==null&&(G=document.createElement("input"),G.setAttribute("type","file"),G.setAttribute("accept","image/png, image/gif, image/jpeg, image/bmp, image/x-icon"),G.classList.add("ql-image"),G.addEventListener("change",function(){if(G.files!=null&&G.files[0]!=null){var K=new FileReader;K.onload=function(H){var X=B.quill.getSelection(!0);B.quill.updateContents(new p.default().retain(X.index).delete(X.length).insert({image:H.target.result}),x.default.sources.USER),B.quill.setSelection(X.index+1,x.default.sources.SILENT),G.value=""},K.readAsDataURL(G.files[0])}}),this.container.appendChild(G)),G.click()},video:function(){this.quill.theme.tooltip.edit("video")}}}}});var M=(function(I){P(B,I);function B(G,K){O(this,B);var H=D(this,(B.__proto__||Object.getPrototypeOf(B)).call(this,G,K));return H.textbox=H.root.querySelector('input[type="text"]'),H.listen(),H}return i(B,[{key:"listen",value:function(){var K=this;this.textbox.addEventListener("keydown",function(H){N.default.match(H,"enter")?(K.save(),H.preventDefault()):N.default.match(H,"escape")&&(K.cancel(),H.preventDefault())})}},{key:"cancel",value:function(){this.hide()}},{key:"edit",value:function(){var K=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"link",H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;this.root.classList.remove("ql-hidden"),this.root.classList.add("ql-editing"),H!=null?this.textbox.value=H:K!==this.root.getAttribute("data-mode")&&(this.textbox.value=""),this.position(this.quill.getBounds(this.quill.selection.savedRange)),this.textbox.select(),this.textbox.setAttribute("placeholder",this.textbox.getAttribute("data-"+K)||""),this.root.setAttribute("data-mode",K)}},{key:"restoreFocus",value:function(){var K=this.quill.scrollingContainer.scrollTop;this.quill.focus(),this.quill.scrollingContainer.scrollTop=K}},{key:"save",value:function(){var K=this.textbox.value;switch(this.root.getAttribute("data-mode")){case"link":{var H=this.quill.root.scrollTop;this.linkRange?(this.quill.formatText(this.linkRange,"link",K,x.default.sources.USER),delete this.linkRange):(this.restoreFocus(),this.quill.format("link",K,x.default.sources.USER)),this.quill.root.scrollTop=H;break}case"video":K=z(K);case"formula":{if(!K)break;var X=this.quill.getSelection(!0);if(X!=null){var J=X.index+X.length;this.quill.insertEmbed(J,this.root.getAttribute("data-mode"),K,x.default.sources.USER),this.root.getAttribute("data-mode")==="formula"&&this.quill.insertText(J+1," ",x.default.sources.USER),this.quill.setSelection(J+2,x.default.sources.USER)}break}}this.textbox.value="",this.hide()}}]),B})(E.default);function z(I){var B=I.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/)||I.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);return B?(B[1]||"https")+"://www.youtube.com/embed/"+B[2]+"?showinfo=0":(B=I.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/))?(B[1]||"https")+"://player.vimeo.com/video/"+B[2]+"/":I}function T(I,B){var G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;B.forEach(function(K){var H=document.createElement("option");K===G?H.setAttribute("selected","selected"):H.setAttribute("value",K),I.appendChild(H)})}r.BaseTooltip=M,r.default=U}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function o(){this.head=this.tail=null,this.length=0}return o.prototype.append=function(){for(var d=[],m=0;m<arguments.length;m++)d[m]=arguments[m];this.insertBefore(d[0],null),d.length>1&&this.append.apply(this,d.slice(1))},o.prototype.contains=function(d){for(var m,f=this.iterator();m=f();)if(m===d)return!0;return!1},o.prototype.insertBefore=function(d,m){d&&(d.next=m,m!=null?(d.prev=m.prev,m.prev!=null&&(m.prev.next=d),m.prev=d,m===this.head&&(this.head=d)):this.tail!=null?(this.tail.next=d,d.prev=this.tail,this.tail=d):(d.prev=null,this.head=this.tail=d),this.length+=1)},o.prototype.offset=function(d){for(var m=0,f=this.head;f!=null;){if(f===d)return m;m+=f.length(),f=f.next}return-1},o.prototype.remove=function(d){this.contains(d)&&(d.prev!=null&&(d.prev.next=d.next),d.next!=null&&(d.next.prev=d.prev),d===this.head&&(this.head=d.next),d===this.tail&&(this.tail=d.prev),this.length-=1)},o.prototype.iterator=function(d){return d===void 0&&(d=this.head),function(){var m=d;return d!=null&&(d=d.next),m}},o.prototype.find=function(d,m){m===void 0&&(m=!1);for(var f,p=this.iterator();f=p();){var h=f.length();if(d<h||m&&d===h&&(f.next==null||f.next.length()!==0))return[f,d];d-=h}return[null,0]},o.prototype.forEach=function(d){for(var m,f=this.iterator();m=f();)d(m)},o.prototype.forEachAt=function(d,m,f){if(!(m<=0))for(var p=this.find(d),h=p[0],x=p[1],u,N=d-x,v=this.iterator(h);(u=v())&&N<d+m;){var w=u.length();d>N?f(u,d-N,Math.min(m,N+w-d)):f(u,0,Math.min(w,d+m-N)),N+=w}},o.prototype.map=function(d){return this.reduce(function(m,f){return m.push(d(f)),m},[])},o.prototype.reduce=function(d,m){for(var f,p=this.iterator();f=p();)m=d(m,f);return m},o})();r.default=i}),(function(n,r,a){var i=this&&this.__extends||(function(){var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,u){x.__proto__=u}||function(x,u){for(var N in u)u.hasOwnProperty(N)&&(x[N]=u[N])};return function(x,u){h(x,u);function N(){this.constructor=x}x.prototype=u===null?Object.create(u):(N.prototype=u.prototype,new N)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(17),d=a(1),m={attributes:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0},f=100,p=(function(h){i(x,h);function x(u){var N=h.call(this,u)||this;return N.scroll=N,N.observer=new MutationObserver(function(v){N.update(v)}),N.observer.observe(N.domNode,m),N.attach(),N}return x.prototype.detach=function(){h.prototype.detach.call(this),this.observer.disconnect()},x.prototype.deleteAt=function(u,N){this.update(),u===0&&N===this.length()?this.children.forEach(function(v){v.remove()}):h.prototype.deleteAt.call(this,u,N)},x.prototype.formatAt=function(u,N,v,w){this.update(),h.prototype.formatAt.call(this,u,N,v,w)},x.prototype.insertAt=function(u,N,v){this.update(),h.prototype.insertAt.call(this,u,N,v)},x.prototype.optimize=function(u,N){var v=this;u===void 0&&(u=[]),N===void 0&&(N={}),h.prototype.optimize.call(this,N);for(var w=[].slice.call(this.observer.takeRecords());w.length>0;)u.push(w.pop());for(var j=function(R,_){_===void 0&&(_=!0),!(R==null||R===v)&&R.domNode.parentNode!=null&&(R.domNode[d.DATA_KEY].mutations==null&&(R.domNode[d.DATA_KEY].mutations=[]),_&&j(R.parent))},b=function(R){R.domNode[d.DATA_KEY]==null||R.domNode[d.DATA_KEY].mutations==null||(R instanceof o.default&&R.children.forEach(b),R.optimize(N))},C=u,S=0;C.length>0;S+=1){if(S>=f)throw new Error("[Parchment] Maximum optimize iterations reached");for(C.forEach(function(R){var _=d.find(R.target,!0);_!=null&&(_.domNode===R.target&&(R.type==="childList"?(j(d.find(R.previousSibling,!1)),[].forEach.call(R.addedNodes,function(A){var E=d.find(A,!1);j(E,!1),E instanceof o.default&&E.children.forEach(function(q){j(q,!1)})})):R.type==="attributes"&&j(_.prev)),j(_))}),this.children.forEach(b),C=[].slice.call(this.observer.takeRecords()),w=C.slice();w.length>0;)u.push(w.pop())}},x.prototype.update=function(u,N){var v=this;N===void 0&&(N={}),u=u||this.observer.takeRecords(),u.map(function(w){var j=d.find(w.target,!0);return j==null?null:j.domNode[d.DATA_KEY].mutations==null?(j.domNode[d.DATA_KEY].mutations=[w],j):(j.domNode[d.DATA_KEY].mutations.push(w),null)}).forEach(function(w){w==null||w===v||w.domNode[d.DATA_KEY]==null||w.update(w.domNode[d.DATA_KEY].mutations||[],N)}),this.domNode[d.DATA_KEY].mutations!=null&&h.prototype.update.call(this,this.domNode[d.DATA_KEY].mutations,N),this.optimize(u,N)},x.blotName="scroll",x.defaultChild="block",x.scope=d.Scope.BLOCK_BLOT,x.tagName="DIV",x})(o.default);r.default=p}),(function(n,r,a){var i=this&&this.__extends||(function(){var p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,x){h.__proto__=x}||function(h,x){for(var u in x)x.hasOwnProperty(u)&&(h[u]=x[u])};return function(h,x){p(h,x);function u(){this.constructor=h}h.prototype=x===null?Object.create(x):(u.prototype=x.prototype,new u)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(18),d=a(1);function m(p,h){if(Object.keys(p).length!==Object.keys(h).length)return!1;for(var x in p)if(p[x]!==h[x])return!1;return!0}var f=(function(p){i(h,p);function h(){return p!==null&&p.apply(this,arguments)||this}return h.formats=function(x){if(x.tagName!==h.tagName)return p.formats.call(this,x)},h.prototype.format=function(x,u){var N=this;x===this.statics.blotName&&!u?(this.children.forEach(function(v){v instanceof o.default||(v=v.wrap(h.blotName,!0)),N.attributes.copy(v)}),this.unwrap()):p.prototype.format.call(this,x,u)},h.prototype.formatAt=function(x,u,N,v){if(this.formats()[N]!=null||d.query(N,d.Scope.ATTRIBUTE)){var w=this.isolate(x,u);w.format(N,v)}else p.prototype.formatAt.call(this,x,u,N,v)},h.prototype.optimize=function(x){p.prototype.optimize.call(this,x);var u=this.formats();if(Object.keys(u).length===0)return this.unwrap();var N=this.next;N instanceof h&&N.prev===this&&m(u,N.formats())&&(N.moveChildren(this),N.remove())},h.blotName="inline",h.scope=d.Scope.INLINE_BLOT,h.tagName="SPAN",h})(o.default);r.default=f}),(function(n,r,a){var i=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,h){p.__proto__=h}||function(p,h){for(var x in h)h.hasOwnProperty(x)&&(p[x]=h[x])};return function(p,h){f(p,h);function x(){this.constructor=p}p.prototype=h===null?Object.create(h):(x.prototype=h.prototype,new x)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(18),d=a(1),m=(function(f){i(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.formats=function(h){var x=d.query(p.blotName).tagName;if(h.tagName!==x)return f.formats.call(this,h)},p.prototype.format=function(h,x){d.query(h,d.Scope.BLOCK)!=null&&(h===this.statics.blotName&&!x?this.replaceWith(p.blotName):f.prototype.format.call(this,h,x))},p.prototype.formatAt=function(h,x,u,N){d.query(u,d.Scope.BLOCK)!=null?this.format(u,N):f.prototype.formatAt.call(this,h,x,u,N)},p.prototype.insertAt=function(h,x,u){if(u==null||d.query(x,d.Scope.INLINE)!=null)f.prototype.insertAt.call(this,h,x,u);else{var N=this.split(h),v=d.create(x,u);N.parent.insertBefore(v,N)}},p.prototype.update=function(h,x){navigator.userAgent.match(/Trident/)?this.build():f.prototype.update.call(this,h,x)},p.blotName="block",p.scope=d.Scope.BLOCK_BLOT,p.tagName="P",p})(o.default);r.default=m}),(function(n,r,a){var i=this&&this.__extends||(function(){var m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,p){f.__proto__=p}||function(f,p){for(var h in p)p.hasOwnProperty(h)&&(f[h]=p[h])};return function(f,p){m(f,p);function h(){this.constructor=f}f.prototype=p===null?Object.create(p):(h.prototype=p.prototype,new h)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(19),d=(function(m){i(f,m);function f(){return m!==null&&m.apply(this,arguments)||this}return f.formats=function(p){},f.prototype.format=function(p,h){m.prototype.formatAt.call(this,0,this.length(),p,h)},f.prototype.formatAt=function(p,h,x,u){p===0&&h===this.length()?this.format(x,u):m.prototype.formatAt.call(this,p,h,x,u)},f.prototype.formats=function(){return this.statics.formats(this.domNode)},f})(o.default);r.default=d}),(function(n,r,a){var i=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,h){p.__proto__=h}||function(p,h){for(var x in h)h.hasOwnProperty(x)&&(p[x]=h[x])};return function(p,h){f(p,h);function x(){this.constructor=p}p.prototype=h===null?Object.create(h):(x.prototype=h.prototype,new x)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(19),d=a(1),m=(function(f){i(p,f);function p(h){var x=f.call(this,h)||this;return x.text=x.statics.value(x.domNode),x}return p.create=function(h){return document.createTextNode(h)},p.value=function(h){var x=h.data;return x.normalize&&(x=x.normalize()),x},p.prototype.deleteAt=function(h,x){this.domNode.data=this.text=this.text.slice(0,h)+this.text.slice(h+x)},p.prototype.index=function(h,x){return this.domNode===h?x:-1},p.prototype.insertAt=function(h,x,u){u==null?(this.text=this.text.slice(0,h)+x+this.text.slice(h),this.domNode.data=this.text):f.prototype.insertAt.call(this,h,x,u)},p.prototype.length=function(){return this.text.length},p.prototype.optimize=function(h){f.prototype.optimize.call(this,h),this.text=this.statics.value(this.domNode),this.text.length===0?this.remove():this.next instanceof p&&this.next.prev===this&&(this.insertAt(this.length(),this.next.value()),this.next.remove())},p.prototype.position=function(h,x){return[this.domNode,h]},p.prototype.split=function(h,x){if(x===void 0&&(x=!1),!x){if(h===0)return this;if(h===this.length())return this.next}var u=d.create(this.domNode.splitText(h));return this.parent.insertBefore(u,this.next),this.text=this.statics.value(this.domNode),u},p.prototype.update=function(h,x){var u=this;h.some(function(N){return N.type==="characterData"&&N.target===u.domNode})&&(this.text=this.statics.value(this.domNode))},p.prototype.value=function(){return this.text},p.blotName="text",p.scope=d.Scope.INLINE_BLOT,p})(o.default);r.default=m}),(function(n,r,a){var i=document.createElement("div");if(i.classList.toggle("test-class",!1),i.classList.contains("test-class")){var o=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(d,m){return arguments.length>1&&!this.contains(d)==!m?m:o.call(this,d)}}String.prototype.startsWith||(String.prototype.startsWith=function(d,m){return m=m||0,this.substr(m,d.length)===d}),String.prototype.endsWith||(String.prototype.endsWith=function(d,m){var f=this.toString();(typeof m!="number"||!isFinite(m)||Math.floor(m)!==m||m>f.length)&&(m=f.length),m-=d.length;var p=f.indexOf(d,m);return p!==-1&&p===m}),Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(m){if(this===null)throw new TypeError("Array.prototype.find called on null or undefined");if(typeof m!="function")throw new TypeError("predicate must be a function");for(var f=Object(this),p=f.length>>>0,h=arguments[1],x,u=0;u<p;u++)if(x=f[u],m.call(h,x,u,f))return x}}),document.addEventListener("DOMContentLoaded",function(){document.execCommand("enableObjectResizing",!1,!1),document.execCommand("autoUrlDetect",!1,!1)})}),(function(n,r){var a=-1,i=1,o=0;function d(S,R,_){if(S==R)return S?[[o,S]]:[];(_<0||S.length<_)&&(_=null);var A=h(S,R),E=S.substring(0,A);S=S.substring(A),R=R.substring(A),A=x(S,R);var q=S.substring(S.length-A);S=S.substring(0,S.length-A),R=R.substring(0,R.length-A);var O=m(S,R);return E&&O.unshift([o,E]),q&&O.push([o,q]),N(O),_!=null&&(O=j(O,_)),O=b(O),O}function m(S,R){var _;if(!S)return[[i,R]];if(!R)return[[a,S]];var A=S.length>R.length?S:R,E=S.length>R.length?R:S,q=A.indexOf(E);if(q!=-1)return _=[[i,A.substring(0,q)],[o,E],[i,A.substring(q+E.length)]],S.length>R.length&&(_[0][0]=_[2][0]=a),_;if(E.length==1)return[[a,S],[i,R]];var O=u(S,R);if(O){var D=O[0],P=O[1],L=O[2],$=O[3],Y=O[4],Z=d(D,L),W=d(P,$);return Z.concat([[o,Y]],W)}return f(S,R)}function f(S,R){for(var _=S.length,A=R.length,E=Math.ceil((_+A)/2),q=E,O=2*E,D=new Array(O),P=new Array(O),L=0;L<O;L++)D[L]=-1,P[L]=-1;D[q+1]=0,P[q+1]=0;for(var $=_-A,Y=$%2!=0,Z=0,W=0,U=0,M=0,z=0;z<E;z++){for(var T=-z+Z;T<=z-W;T+=2){var I=q+T,B;T==-z||T!=z&&D[I-1]<D[I+1]?B=D[I+1]:B=D[I-1]+1;for(var G=B-T;B<_&&G<A&&S.charAt(B)==R.charAt(G);)B++,G++;if(D[I]=B,B>_)W+=2;else if(G>A)Z+=2;else if(Y){var K=q+$-T;if(K>=0&&K<O&&P[K]!=-1){var H=_-P[K];if(B>=H)return p(S,R,B,G)}}}for(var X=-z+U;X<=z-M;X+=2){var K=q+X,H;X==-z||X!=z&&P[K-1]<P[K+1]?H=P[K+1]:H=P[K-1]+1;for(var J=H-X;H<_&&J<A&&S.charAt(_-H-1)==R.charAt(A-J-1);)H++,J++;if(P[K]=H,H>_)M+=2;else if(J>A)U+=2;else if(!Y){var I=q+$-X;if(I>=0&&I<O&&D[I]!=-1){var B=D[I],G=q+B-I;if(H=_-H,B>=H)return p(S,R,B,G)}}}}return[[a,S],[i,R]]}function p(S,R,_,A){var E=S.substring(0,_),q=R.substring(0,A),O=S.substring(_),D=R.substring(A),P=d(E,q),L=d(O,D);return P.concat(L)}function h(S,R){if(!S||!R||S.charAt(0)!=R.charAt(0))return 0;for(var _=0,A=Math.min(S.length,R.length),E=A,q=0;_<E;)S.substring(q,E)==R.substring(q,E)?(_=E,q=_):A=E,E=Math.floor((A-_)/2+_);return E}function x(S,R){if(!S||!R||S.charAt(S.length-1)!=R.charAt(R.length-1))return 0;for(var _=0,A=Math.min(S.length,R.length),E=A,q=0;_<E;)S.substring(S.length-E,S.length-q)==R.substring(R.length-E,R.length-q)?(_=E,q=_):A=E,E=Math.floor((A-_)/2+_);return E}function u(S,R){var _=S.length>R.length?S:R,A=S.length>R.length?R:S;if(_.length<4||A.length*2<_.length)return null;function E(W,U,M){for(var z=W.substring(M,M+Math.floor(W.length/4)),T=-1,I="",B,G,K,H;(T=U.indexOf(z,T+1))!=-1;){var X=h(W.substring(M),U.substring(T)),J=x(W.substring(0,M),U.substring(0,T));I.length<J+X&&(I=U.substring(T-J,T)+U.substring(T,T+X),B=W.substring(0,M-J),G=W.substring(M+X),K=U.substring(0,T-J),H=U.substring(T+X))}return I.length*2>=W.length?[B,G,K,H,I]:null}var q=E(_,A,Math.ceil(_.length/4)),O=E(_,A,Math.ceil(_.length/2)),D;if(!q&&!O)return null;O?q?D=q[4].length>O[4].length?q:O:D=O:D=q;var P,L,$,Y;S.length>R.length?(P=D[0],L=D[1],$=D[2],Y=D[3]):($=D[0],Y=D[1],P=D[2],L=D[3]);var Z=D[4];return[P,L,$,Y,Z]}function N(S){S.push([o,""]);for(var R=0,_=0,A=0,E="",q="",O;R<S.length;)switch(S[R][0]){case i:A++,q+=S[R][1],R++;break;case a:_++,E+=S[R][1],R++;break;case o:_+A>1?(_!==0&&A!==0&&(O=h(q,E),O!==0&&(R-_-A>0&&S[R-_-A-1][0]==o?S[R-_-A-1][1]+=q.substring(0,O):(S.splice(0,0,[o,q.substring(0,O)]),R++),q=q.substring(O),E=E.substring(O)),O=x(q,E),O!==0&&(S[R][1]=q.substring(q.length-O)+S[R][1],q=q.substring(0,q.length-O),E=E.substring(0,E.length-O))),_===0?S.splice(R-A,_+A,[i,q]):A===0?S.splice(R-_,_+A,[a,E]):S.splice(R-_-A,_+A,[a,E],[i,q]),R=R-_-A+(_?1:0)+(A?1:0)+1):R!==0&&S[R-1][0]==o?(S[R-1][1]+=S[R][1],S.splice(R,1)):R++,A=0,_=0,E="",q="";break}S[S.length-1][1]===""&&S.pop();var D=!1;for(R=1;R<S.length-1;)S[R-1][0]==o&&S[R+1][0]==o&&(S[R][1].substring(S[R][1].length-S[R-1][1].length)==S[R-1][1]?(S[R][1]=S[R-1][1]+S[R][1].substring(0,S[R][1].length-S[R-1][1].length),S[R+1][1]=S[R-1][1]+S[R+1][1],S.splice(R-1,1),D=!0):S[R][1].substring(0,S[R+1][1].length)==S[R+1][1]&&(S[R-1][1]+=S[R+1][1],S[R][1]=S[R][1].substring(S[R+1][1].length)+S[R+1][1],S.splice(R+1,1),D=!0)),R++;D&&N(S)}var v=d;v.INSERT=i,v.DELETE=a,v.EQUAL=o,n.exports=v;function w(S,R){if(R===0)return[o,S];for(var _=0,A=0;A<S.length;A++){var E=S[A];if(E[0]===a||E[0]===o){var q=_+E[1].length;if(R===q)return[A+1,S];if(R<q){S=S.slice();var O=R-_,D=[E[0],E[1].slice(0,O)],P=[E[0],E[1].slice(O)];return S.splice(A,1,D,P),[A+1,S]}else _=q}}throw new Error("cursor_pos is out of bounds!")}function j(S,R){var _=w(S,R),A=_[1],E=_[0],q=A[E],O=A[E+1];if(q==null)return S;if(q[0]!==o)return S;if(O!=null&&q[1]+O[1]===O[1]+q[1])return A.splice(E,2,O,q),C(A,E,2);if(O!=null&&O[1].indexOf(q[1])===0){A.splice(E,2,[O[0],q[1]],[0,q[1]]);var D=O[1].slice(q[1].length);return D.length>0&&A.splice(E+2,0,[O[0],D]),C(A,E,3)}else return S}function b(S){for(var R=!1,_=function(O){return O.charCodeAt(0)>=56320&&O.charCodeAt(0)<=57343},A=function(O){return O.charCodeAt(O.length-1)>=55296&&O.charCodeAt(O.length-1)<=56319},E=2;E<S.length;E+=1)S[E-2][0]===o&&A(S[E-2][1])&&S[E-1][0]===a&&_(S[E-1][1])&&S[E][0]===i&&_(S[E][1])&&(R=!0,S[E-1][1]=S[E-2][1].slice(-1)+S[E-1][1],S[E][1]=S[E-2][1].slice(-1)+S[E][1],S[E-2][1]=S[E-2][1].slice(0,-1));if(!R)return S;for(var q=[],E=0;E<S.length;E+=1)S[E][1].length>0&&q.push(S[E]);return q}function C(S,R,_){for(var A=R+_-1;A>=0&&A>=R-1;A--)if(A+1<S.length){var E=S[A],q=S[A+1];E[0]===q[1]&&S.splice(A,2,[E[0],E[1]+q[1]])}return S}}),(function(n,r){r=n.exports=typeof Object.keys=="function"?Object.keys:a,r.shim=a;function a(i){var o=[];for(var d in i)o.push(d);return o}}),(function(n,r){var a=(function(){return Object.prototype.toString.call(arguments)})()=="[object Arguments]";r=n.exports=a?i:o,r.supported=i;function i(d){return Object.prototype.toString.call(d)=="[object Arguments]"}r.unsupported=o;function o(d){return d&&typeof d=="object"&&typeof d.length=="number"&&Object.prototype.hasOwnProperty.call(d,"callee")&&!Object.prototype.propertyIsEnumerable.call(d,"callee")||!1}}),(function(n,r){var a=Object.prototype.hasOwnProperty,i="~";function o(){}Object.create&&(o.prototype=Object.create(null),new o().__proto__||(i=!1));function d(f,p,h){this.fn=f,this.context=p,this.once=h||!1}function m(){this._events=new o,this._eventsCount=0}m.prototype.eventNames=function(){var p=[],h,x;if(this._eventsCount===0)return p;for(x in h=this._events)a.call(h,x)&&p.push(i?x.slice(1):x);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(h)):p},m.prototype.listeners=function(p,h){var x=i?i+p:p,u=this._events[x];if(h)return!!u;if(!u)return[];if(u.fn)return[u.fn];for(var N=0,v=u.length,w=new Array(v);N<v;N++)w[N]=u[N].fn;return w},m.prototype.emit=function(p,h,x,u,N,v){var w=i?i+p:p;if(!this._events[w])return!1;var j=this._events[w],b=arguments.length,C,S;if(j.fn){switch(j.once&&this.removeListener(p,j.fn,void 0,!0),b){case 1:return j.fn.call(j.context),!0;case 2:return j.fn.call(j.context,h),!0;case 3:return j.fn.call(j.context,h,x),!0;case 4:return j.fn.call(j.context,h,x,u),!0;case 5:return j.fn.call(j.context,h,x,u,N),!0;case 6:return j.fn.call(j.context,h,x,u,N,v),!0}for(S=1,C=new Array(b-1);S<b;S++)C[S-1]=arguments[S];j.fn.apply(j.context,C)}else{var R=j.length,_;for(S=0;S<R;S++)switch(j[S].once&&this.removeListener(p,j[S].fn,void 0,!0),b){case 1:j[S].fn.call(j[S].context);break;case 2:j[S].fn.call(j[S].context,h);break;case 3:j[S].fn.call(j[S].context,h,x);break;case 4:j[S].fn.call(j[S].context,h,x,u);break;default:if(!C)for(_=1,C=new Array(b-1);_<b;_++)C[_-1]=arguments[_];j[S].fn.apply(j[S].context,C)}}return!0},m.prototype.on=function(p,h,x){var u=new d(h,x||this),N=i?i+p:p;return this._events[N]?this._events[N].fn?this._events[N]=[this._events[N],u]:this._events[N].push(u):(this._events[N]=u,this._eventsCount++),this},m.prototype.once=function(p,h,x){var u=new d(h,x||this,!0),N=i?i+p:p;return this._events[N]?this._events[N].fn?this._events[N]=[this._events[N],u]:this._events[N].push(u):(this._events[N]=u,this._eventsCount++),this},m.prototype.removeListener=function(p,h,x,u){var N=i?i+p:p;if(!this._events[N])return this;if(!h)return--this._eventsCount===0?this._events=new o:delete this._events[N],this;var v=this._events[N];if(v.fn)v.fn===h&&(!u||v.once)&&(!x||v.context===x)&&(--this._eventsCount===0?this._events=new o:delete this._events[N]);else{for(var w=0,j=[],b=v.length;w<b;w++)(v[w].fn!==h||u&&!v[w].once||x&&v[w].context!==x)&&j.push(v[w]);j.length?this._events[N]=j.length===1?j[0]:j:--this._eventsCount===0?this._events=new o:delete this._events[N]}return this},m.prototype.removeAllListeners=function(p){var h;return p?(h=i?i+p:p,this._events[h]&&(--this._eventsCount===0?this._events=new o:delete this._events[h])):(this._events=new o,this._eventsCount=0),this},m.prototype.off=m.prototype.removeListener,m.prototype.addListener=m.prototype.on,m.prototype.setMaxListeners=function(){return this},m.prefixed=i,m.EventEmitter=m,typeof n<"u"&&(n.exports=m)}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.matchText=r.matchSpacing=r.matchNewline=r.matchBlot=r.matchAttributor=r.default=void 0;var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(ee){return typeof ee}:function(ee){return ee&&typeof Symbol=="function"&&ee.constructor===Symbol&&ee!==Symbol.prototype?"symbol":typeof ee},o=(function(){function ee(ge,ye){var Be=[],$e=!0,dt=!1,st=void 0;try{for(var xt=ge[Symbol.iterator](),Mt;!($e=(Mt=xt.next()).done)&&(Be.push(Mt.value),!(ye&&Be.length===ye));$e=!0);}catch(It){dt=!0,st=It}finally{try{!$e&&xt.return&&xt.return()}finally{if(dt)throw st}}return Be}return function(ge,ye){if(Array.isArray(ge))return ge;if(Symbol.iterator in Object(ge))return ee(ge,ye);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function ee(ge,ye){for(var Be=0;Be<ye.length;Be++){var $e=ye[Be];$e.enumerable=$e.enumerable||!1,$e.configurable=!0,"value"in $e&&($e.writable=!0),Object.defineProperty(ge,$e.key,$e)}}return function(ge,ye,Be){return ye&&ee(ge.prototype,ye),Be&&ee(ge,Be),ge}})(),m=a(3),f=P(m),p=a(2),h=P(p),x=a(0),u=P(x),N=a(5),v=P(N),w=a(10),j=P(w),b=a(9),C=P(b),S=a(36),R=a(37),_=a(13),A=P(_),E=a(26),q=a(38),O=a(39),D=a(40);function P(ee){return ee&&ee.__esModule?ee:{default:ee}}function L(ee,ge,ye){return ge in ee?Object.defineProperty(ee,ge,{value:ye,enumerable:!0,configurable:!0,writable:!0}):ee[ge]=ye,ee}function $(ee,ge){if(!(ee instanceof ge))throw new TypeError("Cannot call a class as a function")}function Y(ee,ge){if(!ee)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return ge&&(typeof ge=="object"||typeof ge=="function")?ge:ee}function Z(ee,ge){if(typeof ge!="function"&&ge!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof ge);ee.prototype=Object.create(ge&&ge.prototype,{constructor:{value:ee,enumerable:!1,writable:!0,configurable:!0}}),ge&&(Object.setPrototypeOf?Object.setPrototypeOf(ee,ge):ee.__proto__=ge)}var W=(0,j.default)("quill:clipboard"),U="__ql-matcher",M=[[Node.TEXT_NODE,vt],[Node.TEXT_NODE,Pe],["br",xe],[Node.ELEMENT_NODE,Pe],[Node.ELEMENT_NODE,le],[Node.ELEMENT_NODE,et],[Node.ELEMENT_NODE,ae],[Node.ELEMENT_NODE,kt],["li",ve],["b",J.bind(J,"bold")],["i",J.bind(J,"italic")],["style",ce]],z=[S.AlignAttribute,q.DirectionAttribute].reduce(function(ee,ge){return ee[ge.keyName]=ge,ee},{}),T=[S.AlignStyle,R.BackgroundStyle,E.ColorStyle,q.DirectionStyle,O.FontStyle,D.SizeStyle].reduce(function(ee,ge){return ee[ge.keyName]=ge,ee},{}),I=(function(ee){Z(ge,ee);function ge(ye,Be){$(this,ge);var $e=Y(this,(ge.__proto__||Object.getPrototypeOf(ge)).call(this,ye,Be));return $e.quill.root.addEventListener("paste",$e.onPaste.bind($e)),$e.container=$e.quill.addContainer("ql-clipboard"),$e.container.setAttribute("contenteditable",!0),$e.container.setAttribute("tabindex",-1),$e.matchers=[],M.concat($e.options.matchers).forEach(function(dt){var st=o(dt,2),xt=st[0],Mt=st[1];!Be.matchVisual&&Mt===et||$e.addMatcher(xt,Mt)}),$e}return d(ge,[{key:"addMatcher",value:function(Be,$e){this.matchers.push([Be,$e])}},{key:"convert",value:function(Be){if(typeof Be=="string")return this.container.innerHTML=Be.replace(/\>\r?\n +\</g,"><"),this.convert();var $e=this.quill.getFormat(this.quill.selection.savedRange.index);if($e[A.default.blotName]){var dt=this.container.innerText;return this.container.innerHTML="",new h.default().insert(dt,L({},A.default.blotName,$e[A.default.blotName]))}var st=this.prepareMatching(),xt=o(st,2),Mt=xt[0],It=xt[1],he=X(this.container,Mt,It);return K(he,`
`)&&he.ops[he.ops.length-1].attributes==null&&(he=he.compose(new h.default().retain(he.length()-1).delete(1))),W.log("convert",this.container.innerHTML,he),this.container.innerHTML="",he}},{key:"dangerouslyPasteHTML",value:function(Be,$e){var dt=arguments.length>2&&arguments[2]!==void 0?arguments[2]:v.default.sources.API;if(typeof Be=="string")this.quill.setContents(this.convert(Be),$e),this.quill.setSelection(0,v.default.sources.SILENT);else{var st=this.convert($e);this.quill.updateContents(new h.default().retain(Be).concat(st),dt),this.quill.setSelection(Be+st.length(),v.default.sources.SILENT)}}},{key:"onPaste",value:function(Be){var $e=this;if(!(Be.defaultPrevented||!this.quill.isEnabled())){var dt=this.quill.getSelection(),st=new h.default().retain(dt.index),xt=this.quill.scrollingContainer.scrollTop;this.container.focus(),this.quill.selection.update(v.default.sources.SILENT),setTimeout(function(){st=st.concat($e.convert()).delete(dt.length),$e.quill.updateContents(st,v.default.sources.USER),$e.quill.setSelection(st.length()-dt.length,v.default.sources.SILENT),$e.quill.scrollingContainer.scrollTop=xt,$e.quill.focus()},1)}}},{key:"prepareMatching",value:function(){var Be=this,$e=[],dt=[];return this.matchers.forEach(function(st){var xt=o(st,2),Mt=xt[0],It=xt[1];switch(Mt){case Node.TEXT_NODE:dt.push(It);break;case Node.ELEMENT_NODE:$e.push(It);break;default:[].forEach.call(Be.container.querySelectorAll(Mt),function(he){he[U]=he[U]||[],he[U].push(It)});break}}),[$e,dt]}}]),ge})(C.default);I.DEFAULTS={matchers:[],matchVisual:!0};function B(ee,ge,ye){return(typeof ge>"u"?"undefined":i(ge))==="object"?Object.keys(ge).reduce(function(Be,$e){return B(Be,$e,ge[$e])},ee):ee.reduce(function(Be,$e){return $e.attributes&&$e.attributes[ge]?Be.push($e):Be.insert($e.insert,(0,f.default)({},L({},ge,ye),$e.attributes))},new h.default)}function G(ee){if(ee.nodeType!==Node.ELEMENT_NODE)return{};var ge="__ql-computed-style";return ee[ge]||(ee[ge]=window.getComputedStyle(ee))}function K(ee,ge){for(var ye="",Be=ee.ops.length-1;Be>=0&&ye.length<ge.length;--Be){var $e=ee.ops[Be];if(typeof $e.insert!="string")break;ye=$e.insert+ye}return ye.slice(-1*ge.length)===ge}function H(ee){if(ee.childNodes.length===0)return!1;var ge=G(ee);return["block","list-item"].indexOf(ge.display)>-1}function X(ee,ge,ye){return ee.nodeType===ee.TEXT_NODE?ye.reduce(function(Be,$e){return $e(ee,Be)},new h.default):ee.nodeType===ee.ELEMENT_NODE?[].reduce.call(ee.childNodes||[],function(Be,$e){var dt=X($e,ge,ye);return $e.nodeType===ee.ELEMENT_NODE&&(dt=ge.reduce(function(st,xt){return xt($e,st)},dt),dt=($e[U]||[]).reduce(function(st,xt){return xt($e,st)},dt)),Be.concat(dt)},new h.default):new h.default}function J(ee,ge,ye){return B(ye,ee,!0)}function ae(ee,ge){var ye=u.default.Attributor.Attribute.keys(ee),Be=u.default.Attributor.Class.keys(ee),$e=u.default.Attributor.Style.keys(ee),dt={};return ye.concat(Be).concat($e).forEach(function(st){var xt=u.default.query(st,u.default.Scope.ATTRIBUTE);xt!=null&&(dt[xt.attrName]=xt.value(ee),dt[xt.attrName])||(xt=z[st],xt!=null&&(xt.attrName===st||xt.keyName===st)&&(dt[xt.attrName]=xt.value(ee)||void 0),xt=T[st],xt!=null&&(xt.attrName===st||xt.keyName===st)&&(xt=T[st],dt[xt.attrName]=xt.value(ee)||void 0))}),Object.keys(dt).length>0&&(ge=B(ge,dt)),ge}function le(ee,ge){var ye=u.default.query(ee);if(ye==null)return ge;if(ye.prototype instanceof u.default.Embed){var Be={},$e=ye.value(ee);$e!=null&&(Be[ye.blotName]=$e,ge=new h.default().insert(Be,ye.formats(ee)))}else typeof ye.formats=="function"&&(ge=B(ge,ye.blotName,ye.formats(ee)));return ge}function xe(ee,ge){return K(ge,`
`)||ge.insert(`
`),ge}function ce(){return new h.default}function ve(ee,ge){var ye=u.default.query(ee);if(ye==null||ye.blotName!=="list-item"||!K(ge,`
`))return ge;for(var Be=-1,$e=ee.parentNode;!$e.classList.contains("ql-clipboard");)(u.default.query($e)||{}).blotName==="list"&&(Be+=1),$e=$e.parentNode;return Be<=0?ge:ge.compose(new h.default().retain(ge.length()-1).retain(1,{indent:Be}))}function Pe(ee,ge){return K(ge,`
`)||(H(ee)||ge.length()>0&&ee.nextSibling&&H(ee.nextSibling))&&ge.insert(`
`),ge}function et(ee,ge){if(H(ee)&&ee.nextElementSibling!=null&&!K(ge,`
`)){var ye=ee.offsetHeight+parseFloat(G(ee).marginTop)+parseFloat(G(ee).marginBottom);ee.nextElementSibling.offsetTop>ee.offsetTop+ye*1.5&&ge.insert(`
`)}return ge}function kt(ee,ge){var ye={},Be=ee.style||{};return Be.fontStyle&&G(ee).fontStyle==="italic"&&(ye.italic=!0),Be.fontWeight&&(G(ee).fontWeight.startsWith("bold")||parseInt(G(ee).fontWeight)>=700)&&(ye.bold=!0),Object.keys(ye).length>0&&(ge=B(ge,ye)),parseFloat(Be.textIndent||0)>0&&(ge=new h.default().insert(" ").concat(ge)),ge}function vt(ee,ge){var ye=ee.data;if(ee.parentNode.tagName==="O:P")return ge.insert(ye.trim());if(ye.trim().length===0&&ee.parentNode.classList.contains("ql-clipboard"))return ge;if(!G(ee.parentNode).whiteSpace.startsWith("pre")){var Be=function(dt,st){return st=st.replace(/[^\u00a0]/g,""),st.length<1&&dt?" ":st};ye=ye.replace(/\r\n/g," ").replace(/\n/g," "),ye=ye.replace(/\s\s+/g,Be.bind(Be,!0)),(ee.previousSibling==null&&H(ee.parentNode)||ee.previousSibling!=null&&H(ee.previousSibling))&&(ye=ye.replace(/^\s+/,Be.bind(Be,!1))),(ee.nextSibling==null&&H(ee.parentNode)||ee.nextSibling!=null&&H(ee.nextSibling))&&(ye=ye.replace(/\s+$/,Be.bind(Be,!1)))}return ge.insert(ye)}r.default=I,r.matchAttributor=ae,r.matchBlot=le,r.matchNewline=Pe,r.matchSpacing=et,r.matchText=vt}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function N(v,w){for(var j=0;j<w.length;j++){var b=w[j];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}return function(v,w,j){return w&&N(v.prototype,w),j&&N(v,j),v}})(),o=function N(v,w,j){v===null&&(v=Function.prototype);var b=Object.getOwnPropertyDescriptor(v,w);if(b===void 0){var C=Object.getPrototypeOf(v);return C===null?void 0:N(C,w,j)}else{if("value"in b)return b.value;var S=b.get;return S===void 0?void 0:S.call(j)}},d=a(6),m=f(d);function f(N){return N&&N.__esModule?N:{default:N}}function p(N,v){if(!(N instanceof v))throw new TypeError("Cannot call a class as a function")}function h(N,v){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:N}function x(N,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);N.prototype=Object.create(v&&v.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(N,v):N.__proto__=v)}var u=(function(N){x(v,N);function v(){return p(this,v),h(this,(v.__proto__||Object.getPrototypeOf(v)).apply(this,arguments))}return i(v,[{key:"optimize",value:function(j){o(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"optimize",this).call(this,j),this.domNode.tagName!==this.statics.tagName[0]&&this.replaceWith(this.statics.blotName)}}],[{key:"create",value:function(){return o(v.__proto__||Object.getPrototypeOf(v),"create",this).call(this)}},{key:"formats",value:function(){return!0}}]),v})(m.default);u.blotName="bold",u.tagName=["STRONG","B"],r.default=u}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.addControls=r.default=void 0;var i=(function(){function D(P,L){var $=[],Y=!0,Z=!1,W=void 0;try{for(var U=P[Symbol.iterator](),M;!(Y=(M=U.next()).done)&&($.push(M.value),!(L&&$.length===L));Y=!0);}catch(z){Z=!0,W=z}finally{try{!Y&&U.return&&U.return()}finally{if(Z)throw W}}return $}return function(P,L){if(Array.isArray(P))return P;if(Symbol.iterator in Object(P))return D(P,L);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=(function(){function D(P,L){for(var $=0;$<L.length;$++){var Y=L[$];Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y&&(Y.writable=!0),Object.defineProperty(P,Y.key,Y)}}return function(P,L,$){return L&&D(P.prototype,L),$&&D(P,$),P}})(),d=a(2),m=j(d),f=a(0),p=j(f),h=a(5),x=j(h),u=a(10),N=j(u),v=a(9),w=j(v);function j(D){return D&&D.__esModule?D:{default:D}}function b(D,P,L){return P in D?Object.defineProperty(D,P,{value:L,enumerable:!0,configurable:!0,writable:!0}):D[P]=L,D}function C(D,P){if(!(D instanceof P))throw new TypeError("Cannot call a class as a function")}function S(D,P){if(!D)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return P&&(typeof P=="object"||typeof P=="function")?P:D}function R(D,P){if(typeof P!="function"&&P!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof P);D.prototype=Object.create(P&&P.prototype,{constructor:{value:D,enumerable:!1,writable:!0,configurable:!0}}),P&&(Object.setPrototypeOf?Object.setPrototypeOf(D,P):D.__proto__=P)}var _=(0,N.default)("quill:toolbar"),A=(function(D){R(P,D);function P(L,$){C(this,P);var Y=S(this,(P.__proto__||Object.getPrototypeOf(P)).call(this,L,$));if(Array.isArray(Y.options.container)){var Z=document.createElement("div");q(Z,Y.options.container),L.container.parentNode.insertBefore(Z,L.container),Y.container=Z}else typeof Y.options.container=="string"?Y.container=document.querySelector(Y.options.container):Y.container=Y.options.container;if(!(Y.container instanceof HTMLElement)){var W;return W=_.error("Container required for toolbar",Y.options),S(Y,W)}return Y.container.classList.add("ql-toolbar"),Y.controls=[],Y.handlers={},Object.keys(Y.options.handlers).forEach(function(U){Y.addHandler(U,Y.options.handlers[U])}),[].forEach.call(Y.container.querySelectorAll("button, select"),function(U){Y.attach(U)}),Y.quill.on(x.default.events.EDITOR_CHANGE,function(U,M){U===x.default.events.SELECTION_CHANGE&&Y.update(M)}),Y.quill.on(x.default.events.SCROLL_OPTIMIZE,function(){var U=Y.quill.selection.getRange(),M=i(U,1),z=M[0];Y.update(z)}),Y}return o(P,[{key:"addHandler",value:function($,Y){this.handlers[$]=Y}},{key:"attach",value:function($){var Y=this,Z=[].find.call($.classList,function(U){return U.indexOf("ql-")===0});if(Z){if(Z=Z.slice(3),$.tagName==="BUTTON"&&$.setAttribute("type","button"),this.handlers[Z]==null){if(this.quill.scroll.whitelist!=null&&this.quill.scroll.whitelist[Z]==null){_.warn("ignoring attaching to disabled format",Z,$);return}if(p.default.query(Z)==null){_.warn("ignoring attaching to nonexistent format",Z,$);return}}var W=$.tagName==="SELECT"?"change":"click";$.addEventListener(W,function(U){var M=void 0;if($.tagName==="SELECT"){if($.selectedIndex<0)return;var z=$.options[$.selectedIndex];z.hasAttribute("selected")?M=!1:M=z.value||!1}else $.classList.contains("ql-active")?M=!1:M=$.value||!$.hasAttribute("value"),U.preventDefault();Y.quill.focus();var T=Y.quill.selection.getRange(),I=i(T,1),B=I[0];if(Y.handlers[Z]!=null)Y.handlers[Z].call(Y,M);else if(p.default.query(Z).prototype instanceof p.default.Embed){if(M=prompt("Enter "+Z),!M)return;Y.quill.updateContents(new m.default().retain(B.index).delete(B.length).insert(b({},Z,M)),x.default.sources.USER)}else Y.quill.format(Z,M,x.default.sources.USER);Y.update(B)}),this.controls.push([Z,$])}}},{key:"update",value:function($){var Y=$==null?{}:this.quill.getFormat($);this.controls.forEach(function(Z){var W=i(Z,2),U=W[0],M=W[1];if(M.tagName==="SELECT"){var z=void 0;if($==null)z=null;else if(Y[U]==null)z=M.querySelector("option[selected]");else if(!Array.isArray(Y[U])){var T=Y[U];typeof T=="string"&&(T=T.replace(/\"/g,'\\"')),z=M.querySelector('option[value="'+T+'"]')}z==null?(M.value="",M.selectedIndex=-1):z.selected=!0}else if($==null)M.classList.remove("ql-active");else if(M.hasAttribute("value")){var I=Y[U]===M.getAttribute("value")||Y[U]!=null&&Y[U].toString()===M.getAttribute("value")||Y[U]==null&&!M.getAttribute("value");M.classList.toggle("ql-active",I)}else M.classList.toggle("ql-active",Y[U]!=null)})}}]),P})(w.default);A.DEFAULTS={};function E(D,P,L){var $=document.createElement("button");$.setAttribute("type","button"),$.classList.add("ql-"+P),L!=null&&($.value=L),D.appendChild($)}function q(D,P){Array.isArray(P[0])||(P=[P]),P.forEach(function(L){var $=document.createElement("span");$.classList.add("ql-formats"),L.forEach(function(Y){if(typeof Y=="string")E($,Y);else{var Z=Object.keys(Y)[0],W=Y[Z];Array.isArray(W)?O($,Z,W):E($,Z,W)}}),D.appendChild($)})}function O(D,P,L){var $=document.createElement("select");$.classList.add("ql-"+P),L.forEach(function(Y){var Z=document.createElement("option");Y!==!1?Z.setAttribute("value",Y):Z.setAttribute("selected","selected"),$.appendChild(Z)}),D.appendChild($)}A.DEFAULTS={container:null,handlers:{clean:function(){var P=this,L=this.quill.getSelection();if(L!=null)if(L.length==0){var $=this.quill.getFormat();Object.keys($).forEach(function(Y){p.default.query(Y,p.default.Scope.INLINE)!=null&&P.quill.format(Y,!1)})}else this.quill.removeFormat(L,x.default.sources.USER)},direction:function(P){var L=this.quill.getFormat().align;P==="rtl"&&L==null?this.quill.format("align","right",x.default.sources.USER):!P&&L==="right"&&this.quill.format("align",!1,x.default.sources.USER),this.quill.format("direction",P,x.default.sources.USER)},indent:function(P){var L=this.quill.getSelection(),$=this.quill.getFormat(L),Y=parseInt($.indent||0);if(P==="+1"||P==="-1"){var Z=P==="+1"?1:-1;$.direction==="rtl"&&(Z*=-1),this.quill.format("indent",Y+Z,x.default.sources.USER)}},link:function(P){P===!0&&(P=prompt("Enter link URL:")),this.quill.format("link",P,x.default.sources.USER)},list:function(P){var L=this.quill.getSelection(),$=this.quill.getFormat(L);P==="check"?$.list==="checked"||$.list==="unchecked"?this.quill.format("list",!1,x.default.sources.USER):this.quill.format("list","unchecked",x.default.sources.USER):this.quill.format("list",P,x.default.sources.USER)}}},r.default=A,r.addControls=q}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <polyline class="ql-even ql-stroke" points="5 7 3 9 5 11"></polyline> <polyline class="ql-even ql-stroke" points="13 7 15 9 13 11"></polyline> <line class=ql-stroke x1=10 x2=8 y1=5 y2=13></line> </svg>'}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function N(v,w){for(var j=0;j<w.length;j++){var b=w[j];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}return function(v,w,j){return w&&N(v.prototype,w),j&&N(v,j),v}})(),o=function N(v,w,j){v===null&&(v=Function.prototype);var b=Object.getOwnPropertyDescriptor(v,w);if(b===void 0){var C=Object.getPrototypeOf(v);return C===null?void 0:N(C,w,j)}else{if("value"in b)return b.value;var S=b.get;return S===void 0?void 0:S.call(j)}},d=a(28),m=f(d);function f(N){return N&&N.__esModule?N:{default:N}}function p(N,v){if(!(N instanceof v))throw new TypeError("Cannot call a class as a function")}function h(N,v){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:N}function x(N,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);N.prototype=Object.create(v&&v.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(N,v):N.__proto__=v)}var u=(function(N){x(v,N);function v(w,j){p(this,v);var b=h(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,w));return b.label.innerHTML=j,b.container.classList.add("ql-color-picker"),[].slice.call(b.container.querySelectorAll(".ql-picker-item"),0,7).forEach(function(C){C.classList.add("ql-primary")}),b}return i(v,[{key:"buildItem",value:function(j){var b=o(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"buildItem",this).call(this,j);return b.style.backgroundColor=j.getAttribute("value")||"",b}},{key:"selectItem",value:function(j,b){o(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"selectItem",this).call(this,j,b);var C=this.label.querySelector(".ql-color-label"),S=j&&j.getAttribute("data-value")||"";C&&(C.tagName==="line"?C.style.stroke=S:C.style.fill=S)}}]),v})(m.default);r.default=u}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function N(v,w){for(var j=0;j<w.length;j++){var b=w[j];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}return function(v,w,j){return w&&N(v.prototype,w),j&&N(v,j),v}})(),o=function N(v,w,j){v===null&&(v=Function.prototype);var b=Object.getOwnPropertyDescriptor(v,w);if(b===void 0){var C=Object.getPrototypeOf(v);return C===null?void 0:N(C,w,j)}else{if("value"in b)return b.value;var S=b.get;return S===void 0?void 0:S.call(j)}},d=a(28),m=f(d);function f(N){return N&&N.__esModule?N:{default:N}}function p(N,v){if(!(N instanceof v))throw new TypeError("Cannot call a class as a function")}function h(N,v){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:N}function x(N,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);N.prototype=Object.create(v&&v.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(N,v):N.__proto__=v)}var u=(function(N){x(v,N);function v(w,j){p(this,v);var b=h(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,w));return b.container.classList.add("ql-icon-picker"),[].forEach.call(b.container.querySelectorAll(".ql-picker-item"),function(C){C.innerHTML=j[C.getAttribute("data-value")||""]}),b.defaultItem=b.container.querySelector(".ql-selected"),b.selectItem(b.defaultItem),b}return i(v,[{key:"selectItem",value:function(j,b){o(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"selectItem",this).call(this,j,b),j=j||this.defaultItem,this.label.innerHTML=j.innerHTML}}]),v})(m.default);r.default=u}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function m(f,p){for(var h=0;h<p.length;h++){var x=p[h];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(f,x.key,x)}}return function(f,p,h){return p&&m(f.prototype,p),h&&m(f,h),f}})();function o(m,f){if(!(m instanceof f))throw new TypeError("Cannot call a class as a function")}var d=(function(){function m(f,p){var h=this;o(this,m),this.quill=f,this.boundsContainer=p||document.body,this.root=f.addContainer("ql-tooltip"),this.root.innerHTML=this.constructor.TEMPLATE,this.quill.root===this.quill.scrollingContainer&&this.quill.root.addEventListener("scroll",function(){h.root.style.marginTop=-1*h.quill.root.scrollTop+"px"}),this.hide()}return i(m,[{key:"hide",value:function(){this.root.classList.add("ql-hidden")}},{key:"position",value:function(p){var h=p.left+p.width/2-this.root.offsetWidth/2,x=p.bottom+this.quill.root.scrollTop;this.root.style.left=h+"px",this.root.style.top=x+"px",this.root.classList.remove("ql-flip");var u=this.boundsContainer.getBoundingClientRect(),N=this.root.getBoundingClientRect(),v=0;if(N.right>u.right&&(v=u.right-N.right,this.root.style.left=h+v+"px"),N.left<u.left&&(v=u.left-N.left,this.root.style.left=h+v+"px"),N.bottom>u.bottom){var w=N.bottom-N.top,j=p.bottom-p.top+w;this.root.style.top=x-j+"px",this.root.classList.add("ql-flip")}return v}},{key:"show",value:function(){this.root.classList.remove("ql-editing"),this.root.classList.remove("ql-hidden")}}]),m})();r.default=d}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function O(D,P){var L=[],$=!0,Y=!1,Z=void 0;try{for(var W=D[Symbol.iterator](),U;!($=(U=W.next()).done)&&(L.push(U.value),!(P&&L.length===P));$=!0);}catch(M){Y=!0,Z=M}finally{try{!$&&W.return&&W.return()}finally{if(Y)throw Z}}return L}return function(D,P){if(Array.isArray(D))return D;if(Symbol.iterator in Object(D))return O(D,P);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=function O(D,P,L){D===null&&(D=Function.prototype);var $=Object.getOwnPropertyDescriptor(D,P);if($===void 0){var Y=Object.getPrototypeOf(D);return Y===null?void 0:O(Y,P,L)}else{if("value"in $)return $.value;var Z=$.get;return Z===void 0?void 0:Z.call(L)}},d=(function(){function O(D,P){for(var L=0;L<P.length;L++){var $=P[L];$.enumerable=$.enumerable||!1,$.configurable=!0,"value"in $&&($.writable=!0),Object.defineProperty(D,$.key,$)}}return function(D,P,L){return P&&O(D.prototype,P),L&&O(D,L),D}})(),m=a(3),f=C(m),p=a(8),h=C(p),x=a(43),u=C(x),N=a(27),v=C(N),w=a(15),j=a(41),b=C(j);function C(O){return O&&O.__esModule?O:{default:O}}function S(O,D){if(!(O instanceof D))throw new TypeError("Cannot call a class as a function")}function R(O,D){if(!O)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D&&(typeof D=="object"||typeof D=="function")?D:O}function _(O,D){if(typeof D!="function"&&D!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof D);O.prototype=Object.create(D&&D.prototype,{constructor:{value:O,enumerable:!1,writable:!0,configurable:!0}}),D&&(Object.setPrototypeOf?Object.setPrototypeOf(O,D):O.__proto__=D)}var A=[[{header:["1","2","3",!1]}],["bold","italic","underline","link"],[{list:"ordered"},{list:"bullet"}],["clean"]],E=(function(O){_(D,O);function D(P,L){S(this,D),L.modules.toolbar!=null&&L.modules.toolbar.container==null&&(L.modules.toolbar.container=A);var $=R(this,(D.__proto__||Object.getPrototypeOf(D)).call(this,P,L));return $.quill.container.classList.add("ql-snow"),$}return d(D,[{key:"extendToolbar",value:function(L){L.container.classList.add("ql-snow"),this.buildButtons([].slice.call(L.container.querySelectorAll("button")),b.default),this.buildPickers([].slice.call(L.container.querySelectorAll("select")),b.default),this.tooltip=new q(this.quill,this.options.bounds),L.container.querySelector(".ql-link")&&this.quill.keyboard.addBinding({key:"K",shortKey:!0},function($,Y){L.handlers.link.call(L,!Y.format.link)})}}]),D})(u.default);E.DEFAULTS=(0,f.default)(!0,{},u.default.DEFAULTS,{modules:{toolbar:{handlers:{link:function(D){if(D){var P=this.quill.getSelection();if(P==null||P.length==0)return;var L=this.quill.getText(P);/^\S+@\S+\.\S+$/.test(L)&&L.indexOf("mailto:")!==0&&(L="mailto:"+L);var $=this.quill.theme.tooltip;$.edit("link",L)}else this.quill.format("link",!1)}}}}});var q=(function(O){_(D,O);function D(P,L){S(this,D);var $=R(this,(D.__proto__||Object.getPrototypeOf(D)).call(this,P,L));return $.preview=$.root.querySelector("a.ql-preview"),$}return d(D,[{key:"listen",value:function(){var L=this;o(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"listen",this).call(this),this.root.querySelector("a.ql-action").addEventListener("click",function($){L.root.classList.contains("ql-editing")?L.save():L.edit("link",L.preview.textContent),$.preventDefault()}),this.root.querySelector("a.ql-remove").addEventListener("click",function($){if(L.linkRange!=null){var Y=L.linkRange;L.restoreFocus(),L.quill.formatText(Y,"link",!1,h.default.sources.USER),delete L.linkRange}$.preventDefault(),L.hide()}),this.quill.on(h.default.events.SELECTION_CHANGE,function($,Y,Z){if($!=null){if($.length===0&&Z===h.default.sources.USER){var W=L.quill.scroll.descendant(v.default,$.index),U=i(W,2),M=U[0],z=U[1];if(M!=null){L.linkRange=new w.Range($.index-z,M.length());var T=v.default.formats(M.domNode);L.preview.textContent=T,L.preview.setAttribute("href",T),L.show(),L.position(L.quill.getBounds(L.linkRange));return}}else delete L.linkRange;L.hide()}})}},{key:"show",value:function(){o(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"show",this).call(this),this.root.removeAttribute("data-mode")}}]),D})(x.BaseTooltip);q.TEMPLATE=['<a class="ql-preview" rel="noopener noreferrer" target="_blank" href="about:blank"></a>','<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">','<a class="ql-action"></a>','<a class="ql-remove"></a>'].join(""),r.default=E}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(29),o=$e(i),d=a(36),m=a(38),f=a(64),p=a(65),h=$e(p),x=a(66),u=$e(x),N=a(67),v=$e(N),w=a(37),j=a(26),b=a(39),C=a(40),S=a(56),R=$e(S),_=a(68),A=$e(_),E=a(27),q=$e(E),O=a(69),D=$e(O),P=a(70),L=$e(P),$=a(71),Y=$e($),Z=a(72),W=$e(Z),U=a(73),M=$e(U),z=a(13),T=$e(z),I=a(74),B=$e(I),G=a(75),K=$e(G),H=a(57),X=$e(H),J=a(41),ae=$e(J),le=a(28),xe=$e(le),ce=a(59),ve=$e(ce),Pe=a(60),et=$e(Pe),kt=a(61),vt=$e(kt),ee=a(108),ge=$e(ee),ye=a(62),Be=$e(ye);function $e(dt){return dt&&dt.__esModule?dt:{default:dt}}o.default.register({"attributors/attribute/direction":m.DirectionAttribute,"attributors/class/align":d.AlignClass,"attributors/class/background":w.BackgroundClass,"attributors/class/color":j.ColorClass,"attributors/class/direction":m.DirectionClass,"attributors/class/font":b.FontClass,"attributors/class/size":C.SizeClass,"attributors/style/align":d.AlignStyle,"attributors/style/background":w.BackgroundStyle,"attributors/style/color":j.ColorStyle,"attributors/style/direction":m.DirectionStyle,"attributors/style/font":b.FontStyle,"attributors/style/size":C.SizeStyle},!0),o.default.register({"formats/align":d.AlignClass,"formats/direction":m.DirectionClass,"formats/indent":f.IndentClass,"formats/background":w.BackgroundStyle,"formats/color":j.ColorStyle,"formats/font":b.FontClass,"formats/size":C.SizeClass,"formats/blockquote":h.default,"formats/code-block":T.default,"formats/header":u.default,"formats/list":v.default,"formats/bold":R.default,"formats/code":z.Code,"formats/italic":A.default,"formats/link":q.default,"formats/script":D.default,"formats/strike":L.default,"formats/underline":Y.default,"formats/image":W.default,"formats/video":M.default,"formats/list/item":N.ListItem,"modules/formula":B.default,"modules/syntax":K.default,"modules/toolbar":X.default,"themes/bubble":ge.default,"themes/snow":Be.default,"ui/icons":ae.default,"ui/picker":xe.default,"ui/icon-picker":et.default,"ui/color-picker":ve.default,"ui/tooltip":vt.default},!0),r.default=o.default}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.IndentClass=void 0;var i=(function(){function v(w,j){for(var b=0;b<j.length;b++){var C=j[b];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(w,C.key,C)}}return function(w,j,b){return j&&v(w.prototype,j),b&&v(w,b),w}})(),o=function v(w,j,b){w===null&&(w=Function.prototype);var C=Object.getOwnPropertyDescriptor(w,j);if(C===void 0){var S=Object.getPrototypeOf(w);return S===null?void 0:v(S,j,b)}else{if("value"in C)return C.value;var R=C.get;return R===void 0?void 0:R.call(b)}},d=a(0),m=f(d);function f(v){return v&&v.__esModule?v:{default:v}}function p(v,w){if(!(v instanceof w))throw new TypeError("Cannot call a class as a function")}function h(v,w){if(!v)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return w&&(typeof w=="object"||typeof w=="function")?w:v}function x(v,w){if(typeof w!="function"&&w!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof w);v.prototype=Object.create(w&&w.prototype,{constructor:{value:v,enumerable:!1,writable:!0,configurable:!0}}),w&&(Object.setPrototypeOf?Object.setPrototypeOf(v,w):v.__proto__=w)}var u=(function(v){x(w,v);function w(){return p(this,w),h(this,(w.__proto__||Object.getPrototypeOf(w)).apply(this,arguments))}return i(w,[{key:"add",value:function(b,C){if(C==="+1"||C==="-1"){var S=this.value(b)||0;C=C==="+1"?S+1:S-1}return C===0?(this.remove(b),!0):o(w.prototype.__proto__||Object.getPrototypeOf(w.prototype),"add",this).call(this,b,C)}},{key:"canAdd",value:function(b,C){return o(w.prototype.__proto__||Object.getPrototypeOf(w.prototype),"canAdd",this).call(this,b,C)||o(w.prototype.__proto__||Object.getPrototypeOf(w.prototype),"canAdd",this).call(this,b,parseInt(C))}},{key:"value",value:function(b){return parseInt(o(w.prototype.__proto__||Object.getPrototypeOf(w.prototype),"value",this).call(this,b))||void 0}}]),w})(m.default.Attributor.Class),N=new u("indent","ql-indent",{scope:m.default.Scope.BLOCK,whitelist:[1,2,3,4,5,6,7,8]});r.IndentClass=N}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(4),o=d(i);function d(x){return x&&x.__esModule?x:{default:x}}function m(x,u){if(!(x instanceof u))throw new TypeError("Cannot call a class as a function")}function f(x,u){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:x}function p(x,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);x.prototype=Object.create(u&&u.prototype,{constructor:{value:x,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(x,u):x.__proto__=u)}var h=(function(x){p(u,x);function u(){return m(this,u),f(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u})(o.default);h.blotName="blockquote",h.tagName="blockquote",r.default=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function u(N,v){for(var w=0;w<v.length;w++){var j=v[w];j.enumerable=j.enumerable||!1,j.configurable=!0,"value"in j&&(j.writable=!0),Object.defineProperty(N,j.key,j)}}return function(N,v,w){return v&&u(N.prototype,v),w&&u(N,w),N}})(),o=a(4),d=m(o);function m(u){return u&&u.__esModule?u:{default:u}}function f(u,N){if(!(u instanceof N))throw new TypeError("Cannot call a class as a function")}function p(u,N){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return N&&(typeof N=="object"||typeof N=="function")?N:u}function h(u,N){if(typeof N!="function"&&N!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof N);u.prototype=Object.create(N&&N.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),N&&(Object.setPrototypeOf?Object.setPrototypeOf(u,N):u.__proto__=N)}var x=(function(u){h(N,u);function N(){return f(this,N),p(this,(N.__proto__||Object.getPrototypeOf(N)).apply(this,arguments))}return i(N,null,[{key:"formats",value:function(w){return this.tagName.indexOf(w.tagName)+1}}]),N})(d.default);x.blotName="header",x.tagName=["H1","H2","H3","H4","H5","H6"],r.default=x}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.ListItem=void 0;var i=(function(){function S(R,_){for(var A=0;A<_.length;A++){var E=_[A];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(R,E.key,E)}}return function(R,_,A){return _&&S(R.prototype,_),A&&S(R,A),R}})(),o=function S(R,_,A){R===null&&(R=Function.prototype);var E=Object.getOwnPropertyDescriptor(R,_);if(E===void 0){var q=Object.getPrototypeOf(R);return q===null?void 0:S(q,_,A)}else{if("value"in E)return E.value;var O=E.get;return O===void 0?void 0:O.call(A)}},d=a(0),m=u(d),f=a(4),p=u(f),h=a(25),x=u(h);function u(S){return S&&S.__esModule?S:{default:S}}function N(S,R,_){return R in S?Object.defineProperty(S,R,{value:_,enumerable:!0,configurable:!0,writable:!0}):S[R]=_,S}function v(S,R){if(!(S instanceof R))throw new TypeError("Cannot call a class as a function")}function w(S,R){if(!S)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return R&&(typeof R=="object"||typeof R=="function")?R:S}function j(S,R){if(typeof R!="function"&&R!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof R);S.prototype=Object.create(R&&R.prototype,{constructor:{value:S,enumerable:!1,writable:!0,configurable:!0}}),R&&(Object.setPrototypeOf?Object.setPrototypeOf(S,R):S.__proto__=R)}var b=(function(S){j(R,S);function R(){return v(this,R),w(this,(R.__proto__||Object.getPrototypeOf(R)).apply(this,arguments))}return i(R,[{key:"format",value:function(A,E){A===C.blotName&&!E?this.replaceWith(m.default.create(this.statics.scope)):o(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"format",this).call(this,A,E)}},{key:"remove",value:function(){this.prev==null&&this.next==null?this.parent.remove():o(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"remove",this).call(this)}},{key:"replaceWith",value:function(A,E){return this.parent.isolate(this.offset(this.parent),this.length()),A===this.parent.statics.blotName?(this.parent.replaceWith(A,E),this):(this.parent.unwrap(),o(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"replaceWith",this).call(this,A,E))}}],[{key:"formats",value:function(A){return A.tagName===this.tagName?void 0:o(R.__proto__||Object.getPrototypeOf(R),"formats",this).call(this,A)}}]),R})(p.default);b.blotName="list-item",b.tagName="LI";var C=(function(S){j(R,S),i(R,null,[{key:"create",value:function(A){var E=A==="ordered"?"OL":"UL",q=o(R.__proto__||Object.getPrototypeOf(R),"create",this).call(this,E);return(A==="checked"||A==="unchecked")&&q.setAttribute("data-checked",A==="checked"),q}},{key:"formats",value:function(A){if(A.tagName==="OL")return"ordered";if(A.tagName==="UL")return A.hasAttribute("data-checked")?A.getAttribute("data-checked")==="true"?"checked":"unchecked":"bullet"}}]);function R(_){v(this,R);var A=w(this,(R.__proto__||Object.getPrototypeOf(R)).call(this,_)),E=function(O){if(O.target.parentNode===_){var D=A.statics.formats(_),P=m.default.find(O.target);D==="checked"?P.format("list","unchecked"):D==="unchecked"&&P.format("list","checked")}};return _.addEventListener("touchstart",E),_.addEventListener("mousedown",E),A}return i(R,[{key:"format",value:function(A,E){this.children.length>0&&this.children.tail.format(A,E)}},{key:"formats",value:function(){return N({},this.statics.blotName,this.statics.formats(this.domNode))}},{key:"insertBefore",value:function(A,E){if(A instanceof b)o(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"insertBefore",this).call(this,A,E);else{var q=E==null?this.length():E.offset(this),O=this.split(q);O.parent.insertBefore(A,O)}}},{key:"optimize",value:function(A){o(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"optimize",this).call(this,A);var E=this.next;E!=null&&E.prev===this&&E.statics.blotName===this.statics.blotName&&E.domNode.tagName===this.domNode.tagName&&E.domNode.getAttribute("data-checked")===this.domNode.getAttribute("data-checked")&&(E.moveChildren(this),E.remove())}},{key:"replace",value:function(A){if(A.statics.blotName!==this.statics.blotName){var E=m.default.create(this.statics.defaultChild);A.moveChildren(E),this.appendChild(E)}o(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"replace",this).call(this,A)}}]),R})(x.default);C.blotName="list",C.scope=m.default.Scope.BLOCK_BLOT,C.tagName=["OL","UL"],C.defaultChild="list-item",C.allowedChildren=[b],r.ListItem=b,r.default=C}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(56),o=d(i);function d(x){return x&&x.__esModule?x:{default:x}}function m(x,u){if(!(x instanceof u))throw new TypeError("Cannot call a class as a function")}function f(x,u){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:x}function p(x,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);x.prototype=Object.create(u&&u.prototype,{constructor:{value:x,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(x,u):x.__proto__=u)}var h=(function(x){p(u,x);function u(){return m(this,u),f(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u})(o.default);h.blotName="italic",h.tagName=["EM","I"],r.default=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function N(v,w){for(var j=0;j<w.length;j++){var b=w[j];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}return function(v,w,j){return w&&N(v.prototype,w),j&&N(v,j),v}})(),o=function N(v,w,j){v===null&&(v=Function.prototype);var b=Object.getOwnPropertyDescriptor(v,w);if(b===void 0){var C=Object.getPrototypeOf(v);return C===null?void 0:N(C,w,j)}else{if("value"in b)return b.value;var S=b.get;return S===void 0?void 0:S.call(j)}},d=a(6),m=f(d);function f(N){return N&&N.__esModule?N:{default:N}}function p(N,v){if(!(N instanceof v))throw new TypeError("Cannot call a class as a function")}function h(N,v){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:N}function x(N,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);N.prototype=Object.create(v&&v.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(N,v):N.__proto__=v)}var u=(function(N){x(v,N);function v(){return p(this,v),h(this,(v.__proto__||Object.getPrototypeOf(v)).apply(this,arguments))}return i(v,null,[{key:"create",value:function(j){return j==="super"?document.createElement("sup"):j==="sub"?document.createElement("sub"):o(v.__proto__||Object.getPrototypeOf(v),"create",this).call(this,j)}},{key:"formats",value:function(j){if(j.tagName==="SUB")return"sub";if(j.tagName==="SUP")return"super"}}]),v})(m.default);u.blotName="script",u.tagName=["SUB","SUP"],r.default=u}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(6),o=d(i);function d(x){return x&&x.__esModule?x:{default:x}}function m(x,u){if(!(x instanceof u))throw new TypeError("Cannot call a class as a function")}function f(x,u){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:x}function p(x,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);x.prototype=Object.create(u&&u.prototype,{constructor:{value:x,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(x,u):x.__proto__=u)}var h=(function(x){p(u,x);function u(){return m(this,u),f(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u})(o.default);h.blotName="strike",h.tagName="S",r.default=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(6),o=d(i);function d(x){return x&&x.__esModule?x:{default:x}}function m(x,u){if(!(x instanceof u))throw new TypeError("Cannot call a class as a function")}function f(x,u){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:x}function p(x,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);x.prototype=Object.create(u&&u.prototype,{constructor:{value:x,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(x,u):x.__proto__=u)}var h=(function(x){p(u,x);function u(){return m(this,u),f(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u})(o.default);h.blotName="underline",h.tagName="U",r.default=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function w(j,b){for(var C=0;C<b.length;C++){var S=b[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(j,S.key,S)}}return function(j,b,C){return b&&w(j.prototype,b),C&&w(j,C),j}})(),o=function w(j,b,C){j===null&&(j=Function.prototype);var S=Object.getOwnPropertyDescriptor(j,b);if(S===void 0){var R=Object.getPrototypeOf(j);return R===null?void 0:w(R,b,C)}else{if("value"in S)return S.value;var _=S.get;return _===void 0?void 0:_.call(C)}},d=a(0),m=p(d),f=a(27);function p(w){return w&&w.__esModule?w:{default:w}}function h(w,j){if(!(w instanceof j))throw new TypeError("Cannot call a class as a function")}function x(w,j){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j&&(typeof j=="object"||typeof j=="function")?j:w}function u(w,j){if(typeof j!="function"&&j!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof j);w.prototype=Object.create(j&&j.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),j&&(Object.setPrototypeOf?Object.setPrototypeOf(w,j):w.__proto__=j)}var N=["alt","height","width"],v=(function(w){u(j,w);function j(){return h(this,j),x(this,(j.__proto__||Object.getPrototypeOf(j)).apply(this,arguments))}return i(j,[{key:"format",value:function(C,S){N.indexOf(C)>-1?S?this.domNode.setAttribute(C,S):this.domNode.removeAttribute(C):o(j.prototype.__proto__||Object.getPrototypeOf(j.prototype),"format",this).call(this,C,S)}}],[{key:"create",value:function(C){var S=o(j.__proto__||Object.getPrototypeOf(j),"create",this).call(this,C);return typeof C=="string"&&S.setAttribute("src",this.sanitize(C)),S}},{key:"formats",value:function(C){return N.reduce(function(S,R){return C.hasAttribute(R)&&(S[R]=C.getAttribute(R)),S},{})}},{key:"match",value:function(C){return/\.(jpe?g|gif|png)$/.test(C)||/^data:image\/.+;base64/.test(C)}},{key:"sanitize",value:function(C){return(0,f.sanitize)(C,["http","https","data"])?C:"//:0"}},{key:"value",value:function(C){return C.getAttribute("src")}}]),j})(m.default.Embed);v.blotName="image",v.tagName="IMG",r.default=v}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function w(j,b){for(var C=0;C<b.length;C++){var S=b[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(j,S.key,S)}}return function(j,b,C){return b&&w(j.prototype,b),C&&w(j,C),j}})(),o=function w(j,b,C){j===null&&(j=Function.prototype);var S=Object.getOwnPropertyDescriptor(j,b);if(S===void 0){var R=Object.getPrototypeOf(j);return R===null?void 0:w(R,b,C)}else{if("value"in S)return S.value;var _=S.get;return _===void 0?void 0:_.call(C)}},d=a(4),m=a(27),f=p(m);function p(w){return w&&w.__esModule?w:{default:w}}function h(w,j){if(!(w instanceof j))throw new TypeError("Cannot call a class as a function")}function x(w,j){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j&&(typeof j=="object"||typeof j=="function")?j:w}function u(w,j){if(typeof j!="function"&&j!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof j);w.prototype=Object.create(j&&j.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),j&&(Object.setPrototypeOf?Object.setPrototypeOf(w,j):w.__proto__=j)}var N=["height","width"],v=(function(w){u(j,w);function j(){return h(this,j),x(this,(j.__proto__||Object.getPrototypeOf(j)).apply(this,arguments))}return i(j,[{key:"format",value:function(C,S){N.indexOf(C)>-1?S?this.domNode.setAttribute(C,S):this.domNode.removeAttribute(C):o(j.prototype.__proto__||Object.getPrototypeOf(j.prototype),"format",this).call(this,C,S)}}],[{key:"create",value:function(C){var S=o(j.__proto__||Object.getPrototypeOf(j),"create",this).call(this,C);return S.setAttribute("frameborder","0"),S.setAttribute("allowfullscreen",!0),S.setAttribute("src",this.sanitize(C)),S}},{key:"formats",value:function(C){return N.reduce(function(S,R){return C.hasAttribute(R)&&(S[R]=C.getAttribute(R)),S},{})}},{key:"sanitize",value:function(C){return f.default.sanitize(C)}},{key:"value",value:function(C){return C.getAttribute("src")}}]),j})(d.BlockEmbed);v.blotName="video",v.className="ql-video",v.tagName="IFRAME",r.default=v}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.FormulaBlot=void 0;var i=(function(){function C(S,R){for(var _=0;_<R.length;_++){var A=R[_];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(S,A.key,A)}}return function(S,R,_){return R&&C(S.prototype,R),_&&C(S,_),S}})(),o=function C(S,R,_){S===null&&(S=Function.prototype);var A=Object.getOwnPropertyDescriptor(S,R);if(A===void 0){var E=Object.getPrototypeOf(S);return E===null?void 0:C(E,R,_)}else{if("value"in A)return A.value;var q=A.get;return q===void 0?void 0:q.call(_)}},d=a(35),m=u(d),f=a(5),p=u(f),h=a(9),x=u(h);function u(C){return C&&C.__esModule?C:{default:C}}function N(C,S){if(!(C instanceof S))throw new TypeError("Cannot call a class as a function")}function v(C,S){if(!C)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return S&&(typeof S=="object"||typeof S=="function")?S:C}function w(C,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof S);C.prototype=Object.create(S&&S.prototype,{constructor:{value:C,enumerable:!1,writable:!0,configurable:!0}}),S&&(Object.setPrototypeOf?Object.setPrototypeOf(C,S):C.__proto__=S)}var j=(function(C){w(S,C);function S(){return N(this,S),v(this,(S.__proto__||Object.getPrototypeOf(S)).apply(this,arguments))}return i(S,null,[{key:"create",value:function(_){var A=o(S.__proto__||Object.getPrototypeOf(S),"create",this).call(this,_);return typeof _=="string"&&(window.katex.render(_,A,{throwOnError:!1,errorColor:"#f00"}),A.setAttribute("data-value",_)),A}},{key:"value",value:function(_){return _.getAttribute("data-value")}}]),S})(m.default);j.blotName="formula",j.className="ql-formula",j.tagName="SPAN";var b=(function(C){w(S,C),i(S,null,[{key:"register",value:function(){p.default.register(j,!0)}}]);function S(){N(this,S);var R=v(this,(S.__proto__||Object.getPrototypeOf(S)).call(this));if(window.katex==null)throw new Error("Formula module requires KaTeX.");return R}return S})(x.default);r.FormulaBlot=j,r.default=b}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.CodeToken=r.CodeBlock=void 0;var i=(function(){function _(A,E){for(var q=0;q<E.length;q++){var O=E[q];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(A,O.key,O)}}return function(A,E,q){return E&&_(A.prototype,E),q&&_(A,q),A}})(),o=function _(A,E,q){A===null&&(A=Function.prototype);var O=Object.getOwnPropertyDescriptor(A,E);if(O===void 0){var D=Object.getPrototypeOf(A);return D===null?void 0:_(D,E,q)}else{if("value"in O)return O.value;var P=O.get;return P===void 0?void 0:P.call(q)}},d=a(0),m=v(d),f=a(5),p=v(f),h=a(9),x=v(h),u=a(13),N=v(u);function v(_){return _&&_.__esModule?_:{default:_}}function w(_,A){if(!(_ instanceof A))throw new TypeError("Cannot call a class as a function")}function j(_,A){if(!_)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return A&&(typeof A=="object"||typeof A=="function")?A:_}function b(_,A){if(typeof A!="function"&&A!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof A);_.prototype=Object.create(A&&A.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),A&&(Object.setPrototypeOf?Object.setPrototypeOf(_,A):_.__proto__=A)}var C=(function(_){b(A,_);function A(){return w(this,A),j(this,(A.__proto__||Object.getPrototypeOf(A)).apply(this,arguments))}return i(A,[{key:"replaceWith",value:function(q){this.domNode.textContent=this.domNode.textContent,this.attach(),o(A.prototype.__proto__||Object.getPrototypeOf(A.prototype),"replaceWith",this).call(this,q)}},{key:"highlight",value:function(q){var O=this.domNode.textContent;this.cachedText!==O&&((O.trim().length>0||this.cachedText==null)&&(this.domNode.innerHTML=q(O),this.domNode.normalize(),this.attach()),this.cachedText=O)}}]),A})(N.default);C.className="ql-syntax";var S=new m.default.Attributor.Class("token","hljs",{scope:m.default.Scope.INLINE}),R=(function(_){b(A,_),i(A,null,[{key:"register",value:function(){p.default.register(S,!0),p.default.register(C,!0)}}]);function A(E,q){w(this,A);var O=j(this,(A.__proto__||Object.getPrototypeOf(A)).call(this,E,q));if(typeof O.options.highlight!="function")throw new Error("Syntax module requires highlight.js. Please include the library on the page before Quill.");var D=null;return O.quill.on(p.default.events.SCROLL_OPTIMIZE,function(){clearTimeout(D),D=setTimeout(function(){O.highlight(),D=null},O.options.interval)}),O.highlight(),O}return i(A,[{key:"highlight",value:function(){var q=this;if(!this.quill.selection.composing){this.quill.update(p.default.sources.USER);var O=this.quill.getSelection();this.quill.scroll.descendants(C).forEach(function(D){D.highlight(q.options.highlight)}),this.quill.update(p.default.sources.SILENT),O!=null&&this.quill.setSelection(O,p.default.sources.SILENT)}}}]),A})(x.default);R.DEFAULTS={highlight:(function(){return window.hljs==null?null:function(_){var A=window.hljs.highlightAuto(_);return A.value}})(),interval:1e3},r.CodeBlock=C,r.CodeToken=S,r.default=R}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=3 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=3 x2=13 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=9 y1=4 y2=4></line> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=14 x2=4 y1=14 y2=14></line> <line class=ql-stroke x1=12 x2=6 y1=4 y2=4></line> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=15 x2=5 y1=14 y2=14></line> <line class=ql-stroke x1=15 x2=9 y1=4 y2=4></line> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=15 x2=3 y1=14 y2=14></line> <line class=ql-stroke x1=15 x2=3 y1=4 y2=4></line> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <g class="ql-fill ql-color-label"> <polygon points="6 6.868 6 6 5 6 5 7 5.942 7 6 6.868"></polygon> <rect height=1 width=1 x=4 y=4></rect> <polygon points="6.817 5 6 5 6 6 6.38 6 6.817 5"></polygon> <rect height=1 width=1 x=2 y=6></rect> <rect height=1 width=1 x=3 y=5></rect> <rect height=1 width=1 x=4 y=7></rect> <polygon points="4 11.439 4 11 3 11 3 12 3.755 12 4 11.439"></polygon> <rect height=1 width=1 x=2 y=12></rect> <rect height=1 width=1 x=2 y=9></rect> <rect height=1 width=1 x=2 y=15></rect> <polygon points="4.63 10 4 10 4 11 4.192 11 4.63 10"></polygon> <rect height=1 width=1 x=3 y=8></rect> <path d=M10.832,4.2L11,4.582V4H10.708A1.948,1.948,0,0,1,10.832,4.2Z></path> <path d=M7,4.582L7.168,4.2A1.929,1.929,0,0,1,7.292,4H7V4.582Z></path> <path d=M8,13H7.683l-0.351.8a1.933,1.933,0,0,1-.124.2H8V13Z></path> <rect height=1 width=1 x=12 y=2></rect> <rect height=1 width=1 x=11 y=3></rect> <path d=M9,3H8V3.282A1.985,1.985,0,0,1,9,3Z></path> <rect height=1 width=1 x=2 y=3></rect> <rect height=1 width=1 x=6 y=2></rect> <rect height=1 width=1 x=3 y=2></rect> <rect height=1 width=1 x=5 y=3></rect> <rect height=1 width=1 x=9 y=2></rect> <rect height=1 width=1 x=15 y=14></rect> <polygon points="13.447 10.174 13.469 10.225 13.472 10.232 13.808 11 14 11 14 10 13.37 10 13.447 10.174"></polygon> <rect height=1 width=1 x=13 y=7></rect> <rect height=1 width=1 x=15 y=5></rect> <rect height=1 width=1 x=14 y=6></rect> <rect height=1 width=1 x=15 y=8></rect> <rect height=1 width=1 x=14 y=9></rect> <path d=M3.775,14H3v1H4V14.314A1.97,1.97,0,0,1,3.775,14Z></path> <rect height=1 width=1 x=14 y=3></rect> <polygon points="12 6.868 12 6 11.62 6 12 6.868"></polygon> <rect height=1 width=1 x=15 y=2></rect> <rect height=1 width=1 x=12 y=5></rect> <rect height=1 width=1 x=13 y=4></rect> <polygon points="12.933 9 13 9 13 8 12.495 8 12.933 9"></polygon> <rect height=1 width=1 x=9 y=14></rect> <rect height=1 width=1 x=8 y=15></rect> <path d=M6,14.926V15H7V14.316A1.993,1.993,0,0,1,6,14.926Z></path> <rect height=1 width=1 x=5 y=15></rect> <path d=M10.668,13.8L10.317,13H10v1h0.792A1.947,1.947,0,0,1,10.668,13.8Z></path> <rect height=1 width=1 x=11 y=15></rect> <path d=M14.332,12.2a1.99,1.99,0,0,1,.166.8H15V12H14.245Z></path> <rect height=1 width=1 x=14 y=15></rect> <rect height=1 width=1 x=15 y=11></rect> </g> <polyline class=ql-stroke points="5.5 13 9 5 12.5 13"></polyline> <line class=ql-stroke x1=11.63 x2=6.38 y1=11 y2=11></line> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <rect class="ql-fill ql-stroke" height=3 width=3 x=4 y=5></rect> <rect class="ql-fill ql-stroke" height=3 width=3 x=11 y=5></rect> <path class="ql-even ql-fill ql-stroke" d=M7,8c0,4.031-3,5-3,5></path> <path class="ql-even ql-fill ql-stroke" d=M14,8c0,4.031-3,5-3,5></path> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-stroke d=M5,4H9.5A2.5,2.5,0,0,1,12,6.5v0A2.5,2.5,0,0,1,9.5,9H5A0,0,0,0,1,5,9V4A0,0,0,0,1,5,4Z></path> <path class=ql-stroke d=M5,9h5.5A2.5,2.5,0,0,1,13,11.5v0A2.5,2.5,0,0,1,10.5,14H5a0,0,0,0,1,0,0V9A0,0,0,0,1,5,9Z></path> </svg>'}),(function(n,r){n.exports='<svg class="" viewbox="0 0 18 18"> <line class=ql-stroke x1=5 x2=13 y1=3 y2=3></line> <line class=ql-stroke x1=6 x2=9.35 y1=12 y2=3></line> <line class=ql-stroke x1=11 x2=15 y1=11 y2=15></line> <line class=ql-stroke x1=15 x2=11 y1=11 y2=15></line> <rect class=ql-fill height=1 rx=0.5 ry=0.5 width=7 x=2 y=14></rect> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class="ql-color-label ql-stroke ql-transparent" x1=3 x2=15 y1=15 y2=15></line> <polyline class=ql-stroke points="5.5 11 9 3 12.5 11"></polyline> <line class=ql-stroke x1=11.63 x2=6.38 y1=9 y2=9></line> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <polygon class="ql-stroke ql-fill" points="3 11 5 9 3 7 3 11"></polygon> <line class="ql-stroke ql-fill" x1=15 x2=11 y1=4 y2=4></line> <path class=ql-fill d=M11,3a3,3,0,0,0,0,6h1V3H11Z></path> <rect class=ql-fill height=11 width=1 x=11 y=4></rect> <rect class=ql-fill height=11 width=1 x=13 y=4></rect> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <polygon class="ql-stroke ql-fill" points="15 12 13 10 15 8 15 12"></polygon> <line class="ql-stroke ql-fill" x1=9 x2=5 y1=4 y2=4></line> <path class=ql-fill d=M5,3A3,3,0,0,0,5,9H6V3H5Z></path> <rect class=ql-fill height=11 width=1 x=5 y=4></rect> <rect class=ql-fill height=11 width=1 x=7 y=4></rect> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-fill d=M14,16H4a1,1,0,0,1,0-2H14A1,1,0,0,1,14,16Z /> <path class=ql-fill d=M14,4H4A1,1,0,0,1,4,2H14A1,1,0,0,1,14,4Z /> <rect class=ql-fill x=3 y=6 width=12 height=6 rx=1 ry=1 /> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-fill d=M13,16H5a1,1,0,0,1,0-2h8A1,1,0,0,1,13,16Z /> <path class=ql-fill d=M13,4H5A1,1,0,0,1,5,2h8A1,1,0,0,1,13,4Z /> <rect class=ql-fill x=2 y=6 width=14 height=6 rx=1 ry=1 /> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-fill d=M15,8H13a1,1,0,0,1,0-2h2A1,1,0,0,1,15,8Z /> <path class=ql-fill d=M15,12H13a1,1,0,0,1,0-2h2A1,1,0,0,1,15,12Z /> <path class=ql-fill d=M15,16H5a1,1,0,0,1,0-2H15A1,1,0,0,1,15,16Z /> <path class=ql-fill d=M15,4H5A1,1,0,0,1,5,2H15A1,1,0,0,1,15,4Z /> <rect class=ql-fill x=2 y=6 width=8 height=6 rx=1 ry=1 /> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-fill d=M5,8H3A1,1,0,0,1,3,6H5A1,1,0,0,1,5,8Z /> <path class=ql-fill d=M5,12H3a1,1,0,0,1,0-2H5A1,1,0,0,1,5,12Z /> <path class=ql-fill d=M13,16H3a1,1,0,0,1,0-2H13A1,1,0,0,1,13,16Z /> <path class=ql-fill d=M13,4H3A1,1,0,0,1,3,2H13A1,1,0,0,1,13,4Z /> <rect class=ql-fill x=8 y=6 width=8 height=6 rx=1 ry=1 transform="translate(24 18) rotate(-180)"/> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-fill d=M11.759,2.482a2.561,2.561,0,0,0-3.53.607A7.656,7.656,0,0,0,6.8,6.2C6.109,9.188,5.275,14.677,4.15,14.927a1.545,1.545,0,0,0-1.3-.933A0.922,0.922,0,0,0,2,15.036S1.954,16,4.119,16s3.091-2.691,3.7-5.553c0.177-.826.36-1.726,0.554-2.6L8.775,6.2c0.381-1.421.807-2.521,1.306-2.676a1.014,1.014,0,0,0,1.02.56A0.966,0.966,0,0,0,11.759,2.482Z></path> <rect class=ql-fill height=1.6 rx=0.8 ry=0.8 width=5 x=5.15 y=6.2></rect> <path class=ql-fill d=M13.663,12.027a1.662,1.662,0,0,1,.266-0.276q0.193,0.069.456,0.138a2.1,2.1,0,0,0,.535.069,1.075,1.075,0,0,0,.767-0.3,1.044,1.044,0,0,0,.314-0.8,0.84,0.84,0,0,0-.238-0.619,0.8,0.8,0,0,0-.594-0.239,1.154,1.154,0,0,0-.781.3,4.607,4.607,0,0,0-.781,1q-0.091.15-.218,0.346l-0.246.38c-0.068-.288-0.137-0.582-0.212-0.885-0.459-1.847-2.494-.984-2.941-0.8-0.482.2-.353,0.647-0.094,0.529a0.869,0.869,0,0,1,1.281.585c0.217,0.751.377,1.436,0.527,2.038a5.688,5.688,0,0,1-.362.467,2.69,2.69,0,0,1-.264.271q-0.221-.08-0.471-0.147a2.029,2.029,0,0,0-.522-0.066,1.079,1.079,0,0,0-.768.3A1.058,1.058,0,0,0,9,15.131a0.82,0.82,0,0,0,.832.852,1.134,1.134,0,0,0,.787-0.3,5.11,5.11,0,0,0,.776-0.993q0.141-.219.215-0.34c0.046-.076.122-0.194,0.223-0.346a2.786,2.786,0,0,0,.918,1.726,2.582,2.582,0,0,0,2.376-.185c0.317-.181.212-0.565,0-0.494A0.807,0.807,0,0,1,14.176,15a5.159,5.159,0,0,1-.913-2.446l0,0Q13.487,12.24,13.663,12.027Z></path> </svg>'}),(function(n,r){n.exports='<svg viewBox="0 0 18 18"> <path class=ql-fill d=M10,4V14a1,1,0,0,1-2,0V10H3v4a1,1,0,0,1-2,0V4A1,1,0,0,1,3,4V8H8V4a1,1,0,0,1,2,0Zm6.06787,9.209H14.98975V7.59863a.54085.54085,0,0,0-.605-.60547h-.62744a1.01119,1.01119,0,0,0-.748.29688L11.645,8.56641a.5435.5435,0,0,0-.022.8584l.28613.30762a.53861.53861,0,0,0,.84717.0332l.09912-.08789a1.2137,1.2137,0,0,0,.2417-.35254h.02246s-.01123.30859-.01123.60547V13.209H12.041a.54085.54085,0,0,0-.605.60547v.43945a.54085.54085,0,0,0,.605.60547h4.02686a.54085.54085,0,0,0,.605-.60547v-.43945A.54085.54085,0,0,0,16.06787,13.209Z /> </svg>'}),(function(n,r){n.exports='<svg viewBox="0 0 18 18"> <path class=ql-fill d=M16.73975,13.81445v.43945a.54085.54085,0,0,1-.605.60547H11.855a.58392.58392,0,0,1-.64893-.60547V14.0127c0-2.90527,3.39941-3.42187,3.39941-4.55469a.77675.77675,0,0,0-.84717-.78125,1.17684,1.17684,0,0,0-.83594.38477c-.2749.26367-.561.374-.85791.13184l-.4292-.34082c-.30811-.24219-.38525-.51758-.1543-.81445a2.97155,2.97155,0,0,1,2.45361-1.17676,2.45393,2.45393,0,0,1,2.68408,2.40918c0,2.45312-3.1792,2.92676-3.27832,3.93848h2.79443A.54085.54085,0,0,1,16.73975,13.81445ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z /> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=7 x2=13 y1=4 y2=4></line> <line class=ql-stroke x1=5 x2=11 y1=14 y2=14></line> <line class=ql-stroke x1=8 x2=10 y1=14 y2=4></line> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <rect class=ql-stroke height=10 width=12 x=3 y=4></rect> <circle class=ql-fill cx=6 cy=7 r=1></circle> <polyline class="ql-even ql-fill" points="5 12 5 11 7 9 8 10 11 7 13 9 13 12 5 12"></polyline> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=3 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class="ql-fill ql-stroke" points="3 7 3 11 5 9 3 7"></polyline> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=3 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class=ql-stroke points="5 7 5 11 3 9 5 7"></polyline> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=7 x2=11 y1=7 y2=11></line> <path class="ql-even ql-stroke" d=M8.9,4.577a3.476,3.476,0,0,1,.36,4.679A3.476,3.476,0,0,1,4.577,8.9C3.185,7.5,2.035,6.4,4.217,4.217S7.5,3.185,8.9,4.577Z></path> <path class="ql-even ql-stroke" d=M13.423,9.1a3.476,3.476,0,0,0-4.679-.36,3.476,3.476,0,0,0,.36,4.679c1.392,1.392,2.5,2.542,4.679.36S14.815,10.5,13.423,9.1Z></path> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=7 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=7 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=7 x2=15 y1=14 y2=14></line> <line class="ql-stroke ql-thin" x1=2.5 x2=4.5 y1=5.5 y2=5.5></line> <path class=ql-fill d=M3.5,6A0.5,0.5,0,0,1,3,5.5V3.085l-0.276.138A0.5,0.5,0,0,1,2.053,3c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,4,2.5v3A0.5,0.5,0,0,1,3.5,6Z></path> <path class="ql-stroke ql-thin" d=M4.5,10.5h-2c0-.234,1.85-1.076,1.85-2.234A0.959,0.959,0,0,0,2.5,8.156></path> <path class="ql-stroke ql-thin" d=M2.5,14.846a0.959,0.959,0,0,0,1.85-.109A0.7,0.7,0,0,0,3.75,14a0.688,0.688,0,0,0,.6-0.736,0.959,0.959,0,0,0-1.85-.109></path> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=6 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=6 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=6 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=3 y1=4 y2=4></line> <line class=ql-stroke x1=3 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=3 x2=3 y1=14 y2=14></line> </svg>'}),(function(n,r){n.exports='<svg class="" viewbox="0 0 18 18"> <line class=ql-stroke x1=9 x2=15 y1=4 y2=4></line> <polyline class=ql-stroke points="3 4 4 5 6 3"></polyline> <line class=ql-stroke x1=9 x2=15 y1=14 y2=14></line> <polyline class=ql-stroke points="3 14 4 15 6 13"></polyline> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class=ql-stroke points="3 9 4 10 6 8"></polyline> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-fill d=M15.5,15H13.861a3.858,3.858,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.921,1.921,0,0,0,12.021,11.7a0.50013,0.50013,0,1,0,.957.291h0a0.914,0.914,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.076-1.16971,1.86982-1.93971,2.43082A1.45639,1.45639,0,0,0,12,15.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,15Z /> <path class=ql-fill d=M9.65,5.241a1,1,0,0,0-1.409.108L6,7.964,3.759,5.349A1,1,0,0,0,2.192,6.59178Q2.21541,6.6213,2.241,6.649L4.684,9.5,2.241,12.35A1,1,0,0,0,3.71,13.70722q0.02557-.02768.049-0.05722L6,11.036,8.241,13.65a1,1,0,1,0,1.567-1.24277Q9.78459,12.3777,9.759,12.35L7.316,9.5,9.759,6.651A1,1,0,0,0,9.65,5.241Z /> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-fill d=M15.5,7H13.861a4.015,4.015,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.922,1.922,0,0,0,12.021,3.7a0.5,0.5,0,1,0,.957.291,0.917,0.917,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.077-1.164,1.925-1.934,2.486A1.423,1.423,0,0,0,12,7.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,7Z /> <path class=ql-fill d=M9.651,5.241a1,1,0,0,0-1.41.108L6,7.964,3.759,5.349a1,1,0,1,0-1.519,1.3L4.683,9.5,2.241,12.35a1,1,0,1,0,1.519,1.3L6,11.036,8.241,13.65a1,1,0,0,0,1.519-1.3L7.317,9.5,9.759,6.651A1,1,0,0,0,9.651,5.241Z /> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class="ql-stroke ql-thin" x1=15.5 x2=2.5 y1=8.5 y2=9.5></line> <path class=ql-fill d=M9.007,8C6.542,7.791,6,7.519,6,6.5,6,5.792,7.283,5,9,5c1.571,0,2.765.679,2.969,1.309a1,1,0,0,0,1.9-.617C13.356,4.106,11.354,3,9,3,6.2,3,4,4.538,4,6.5a3.2,3.2,0,0,0,.5,1.843Z></path> <path class=ql-fill d=M8.984,10C11.457,10.208,12,10.479,12,11.5c0,0.708-1.283,1.5-3,1.5-1.571,0-2.765-.679-2.969-1.309a1,1,0,1,0-1.9.617C4.644,13.894,6.646,15,9,15c2.8,0,5-1.538,5-3.5a3.2,3.2,0,0,0-.5-1.843Z></path> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-stroke d=M5,3V9a4.012,4.012,0,0,0,4,4H9a4.012,4.012,0,0,0,4-4V3></path> <rect class=ql-fill height=1 rx=0.5 ry=0.5 width=12 x=3 y=15></rect> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <rect class=ql-stroke height=12 width=12 x=3 y=3></rect> <rect class=ql-fill height=12 width=1 x=5 y=3></rect> <rect class=ql-fill height=12 width=1 x=12 y=3></rect> <rect class=ql-fill height=2 width=8 x=5 y=8></rect> <rect class=ql-fill height=1 width=3 x=3 y=5></rect> <rect class=ql-fill height=1 width=3 x=3 y=7></rect> <rect class=ql-fill height=1 width=3 x=3 y=10></rect> <rect class=ql-fill height=1 width=3 x=3 y=12></rect> <rect class=ql-fill height=1 width=3 x=12 y=5></rect> <rect class=ql-fill height=1 width=3 x=12 y=7></rect> <rect class=ql-fill height=1 width=3 x=12 y=10></rect> <rect class=ql-fill height=1 width=3 x=12 y=12></rect> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <polygon class=ql-stroke points="7 11 9 13 11 11 7 11"></polygon> <polygon class=ql-stroke points="7 7 9 5 11 7 7 7"></polygon> </svg>'}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.BubbleTooltip=void 0;var i=function A(E,q,O){E===null&&(E=Function.prototype);var D=Object.getOwnPropertyDescriptor(E,q);if(D===void 0){var P=Object.getPrototypeOf(E);return P===null?void 0:A(P,q,O)}else{if("value"in D)return D.value;var L=D.get;return L===void 0?void 0:L.call(O)}},o=(function(){function A(E,q){for(var O=0;O<q.length;O++){var D=q[O];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(E,D.key,D)}}return function(E,q,O){return q&&A(E.prototype,q),O&&A(E,O),E}})(),d=a(3),m=w(d),f=a(8),p=w(f),h=a(43),x=w(h),u=a(15),N=a(41),v=w(N);function w(A){return A&&A.__esModule?A:{default:A}}function j(A,E){if(!(A instanceof E))throw new TypeError("Cannot call a class as a function")}function b(A,E){if(!A)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return E&&(typeof E=="object"||typeof E=="function")?E:A}function C(A,E){if(typeof E!="function"&&E!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof E);A.prototype=Object.create(E&&E.prototype,{constructor:{value:A,enumerable:!1,writable:!0,configurable:!0}}),E&&(Object.setPrototypeOf?Object.setPrototypeOf(A,E):A.__proto__=E)}var S=[["bold","italic","link"],[{header:1},{header:2},"blockquote"]],R=(function(A){C(E,A);function E(q,O){j(this,E),O.modules.toolbar!=null&&O.modules.toolbar.container==null&&(O.modules.toolbar.container=S);var D=b(this,(E.__proto__||Object.getPrototypeOf(E)).call(this,q,O));return D.quill.container.classList.add("ql-bubble"),D}return o(E,[{key:"extendToolbar",value:function(O){this.tooltip=new _(this.quill,this.options.bounds),this.tooltip.root.appendChild(O.container),this.buildButtons([].slice.call(O.container.querySelectorAll("button")),v.default),this.buildPickers([].slice.call(O.container.querySelectorAll("select")),v.default)}}]),E})(x.default);R.DEFAULTS=(0,m.default)(!0,{},x.default.DEFAULTS,{modules:{toolbar:{handlers:{link:function(E){E?this.quill.theme.tooltip.edit():this.quill.format("link",!1)}}}}});var _=(function(A){C(E,A);function E(q,O){j(this,E);var D=b(this,(E.__proto__||Object.getPrototypeOf(E)).call(this,q,O));return D.quill.on(p.default.events.EDITOR_CHANGE,function(P,L,$,Y){if(P===p.default.events.SELECTION_CHANGE)if(L!=null&&L.length>0&&Y===p.default.sources.USER){D.show(),D.root.style.left="0px",D.root.style.width="",D.root.style.width=D.root.offsetWidth+"px";var Z=D.quill.getLines(L.index,L.length);if(Z.length===1)D.position(D.quill.getBounds(L));else{var W=Z[Z.length-1],U=D.quill.getIndex(W),M=Math.min(W.length()-1,L.index+L.length-U),z=D.quill.getBounds(new u.Range(U,M));D.position(z)}}else document.activeElement!==D.textbox&&D.quill.hasFocus()&&D.hide()}),D}return o(E,[{key:"listen",value:function(){var O=this;i(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"listen",this).call(this),this.root.querySelector(".ql-close").addEventListener("click",function(){O.root.classList.remove("ql-editing")}),this.quill.on(p.default.events.SCROLL_OPTIMIZE,function(){setTimeout(function(){if(!O.root.classList.contains("ql-hidden")){var D=O.quill.getSelection();D!=null&&O.position(O.quill.getBounds(D))}},1)})}},{key:"cancel",value:function(){this.show()}},{key:"position",value:function(O){var D=i(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"position",this).call(this,O),P=this.root.querySelector(".ql-tooltip-arrow");if(P.style.marginLeft="",D===0)return D;P.style.marginLeft=-1*D-P.offsetWidth/2+"px"}}]),E})(h.BaseTooltip);_.TEMPLATE=['<span class="ql-tooltip-arrow"></span>','<div class="ql-tooltip-editor">','<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">','<a class="ql-close"></a>',"</div>"].join(""),r.BubbleTooltip=_,r.default=R}),(function(n,r,a){n.exports=a(63)})]).default})})(Gm)),Gm.exports}var li,S2;function fG(){if(S2)return li;S2=1;var t=li&&li.__extends||(function(){var p=function(h,x){return p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,N){u.__proto__=N}||function(u,N){for(var v in N)N.hasOwnProperty(v)&&(u[v]=N[v])},p(h,x)};return function(h,x){p(h,x);function u(){this.constructor=h}h.prototype=x===null?Object.create(x):(u.prototype=x.prototype,new u)}})(),s=li&&li.__assign||function(){return s=Object.assign||function(p){for(var h,x=1,u=arguments.length;x<u;x++){h=arguments[x];for(var N in h)Object.prototype.hasOwnProperty.call(h,N)&&(p[N]=h[N])}return p},s.apply(this,arguments)},n=li&&li.__spreadArrays||function(){for(var p=0,h=0,x=arguments.length;h<x;h++)p+=arguments[h].length;for(var u=Array(p),N=0,h=0;h<x;h++)for(var v=arguments[h],w=0,j=v.length;w<j;w++,N++)u[N]=v[w];return u},r=li&&li.__importDefault||function(p){return p&&p.__esModule?p:{default:p}},a=r(pd()),i=r(Oy()),o=r(uG()),d=r(mG()),m=(function(p){t(h,p);function h(x){var u=p.call(this,x)||this;u.dirtyProps=["modules","formats","bounds","theme","children"],u.cleanProps=["id","className","style","placeholder","tabIndex","onChange","onChangeSelection","onFocus","onBlur","onKeyPress","onKeyDown","onKeyUp"],u.state={generation:0},u.selection=null,u.onEditorChange=function(v,w,j,b){var C,S,R,_;v==="text-change"?(S=(C=u).onEditorChangeText)===null||S===void 0||S.call(C,u.editor.root.innerHTML,w,b,u.unprivilegedEditor):v==="selection-change"&&((_=(R=u).onEditorChangeSelection)===null||_===void 0||_.call(R,w,b,u.unprivilegedEditor))};var N=u.isControlled()?x.value:x.defaultValue;return u.value=N??"",u}return h.prototype.validateProps=function(x){var u;if(a.default.Children.count(x.children)>1)throw new Error("The Quill editing area can only be composed of a single React element.");if(a.default.Children.count(x.children)){var N=a.default.Children.only(x.children);if(((u=N)===null||u===void 0?void 0:u.type)==="textarea")throw new Error("Quill does not support editing on a <textarea>. Use a <div> instead.")}if(this.lastDeltaChangeSet&&x.value===this.lastDeltaChangeSet)throw new Error("You are passing the `delta` object from the `onChange` event back as `value`. You most probably want `editor.getContents()` instead. See: https://github.com/zenoamaro/react-quill#using-deltas")},h.prototype.shouldComponentUpdate=function(x,u){var N=this,v;if(this.validateProps(x),!this.editor||this.state.generation!==u.generation)return!0;if("value"in x){var w=this.getEditorContents(),j=(v=x.value,v??"");this.isEqualValue(j,w)||this.setEditorContents(this.editor,j)}return x.readOnly!==this.props.readOnly&&this.setEditorReadOnly(this.editor,x.readOnly),n(this.cleanProps,this.dirtyProps).some(function(b){return!o.default(x[b],N.props[b])})},h.prototype.shouldComponentRegenerate=function(x){var u=this;return this.dirtyProps.some(function(N){return!o.default(x[N],u.props[N])})},h.prototype.componentDidMount=function(){this.instantiateEditor(),this.setEditorContents(this.editor,this.getEditorContents())},h.prototype.componentWillUnmount=function(){this.destroyEditor()},h.prototype.componentDidUpdate=function(x,u){var N=this;if(this.editor&&this.shouldComponentRegenerate(x)){var v=this.editor.getContents(),w=this.editor.getSelection();this.regenerationSnapshot={delta:v,selection:w},this.setState({generation:this.state.generation+1}),this.destroyEditor()}if(this.state.generation!==u.generation){var j=this.regenerationSnapshot,v=j.delta,b=j.selection;delete this.regenerationSnapshot,this.instantiateEditor();var C=this.editor;C.setContents(v),f(function(){return N.setEditorSelection(C,b)})}},h.prototype.instantiateEditor=function(){this.editor?this.hookEditor(this.editor):this.editor=this.createEditor(this.getEditingArea(),this.getEditorConfig())},h.prototype.destroyEditor=function(){this.editor&&this.unhookEditor(this.editor)},h.prototype.isControlled=function(){return"value"in this.props},h.prototype.getEditorConfig=function(){return{bounds:this.props.bounds,formats:this.props.formats,modules:this.props.modules,placeholder:this.props.placeholder,readOnly:this.props.readOnly,scrollingContainer:this.props.scrollingContainer,tabIndex:this.props.tabIndex,theme:this.props.theme}},h.prototype.getEditor=function(){if(!this.editor)throw new Error("Accessing non-instantiated editor");return this.editor},h.prototype.createEditor=function(x,u){var N=new d.default(x,u);return u.tabIndex!=null&&this.setEditorTabIndex(N,u.tabIndex),this.hookEditor(N),N},h.prototype.hookEditor=function(x){this.unprivilegedEditor=this.makeUnprivilegedEditor(x),x.on("editor-change",this.onEditorChange)},h.prototype.unhookEditor=function(x){x.off("editor-change",this.onEditorChange)},h.prototype.getEditorContents=function(){return this.value},h.prototype.getEditorSelection=function(){return this.selection},h.prototype.isDelta=function(x){return x&&x.ops},h.prototype.isEqualValue=function(x,u){return this.isDelta(x)&&this.isDelta(u)?o.default(x.ops,u.ops):o.default(x,u)},h.prototype.setEditorContents=function(x,u){var N=this;this.value=u;var v=this.getEditorSelection();typeof u=="string"?x.setContents(x.clipboard.convert(u)):x.setContents(u),f(function(){return N.setEditorSelection(x,v)})},h.prototype.setEditorSelection=function(x,u){if(this.selection=u,u){var N=x.getLength();u.index=Math.max(0,Math.min(u.index,N-1)),u.length=Math.max(0,Math.min(u.length,N-1-u.index)),x.setSelection(u)}},h.prototype.setEditorTabIndex=function(x,u){var N,v;!((v=(N=x)===null||N===void 0?void 0:N.scroll)===null||v===void 0)&&v.domNode&&(x.scroll.domNode.tabIndex=u)},h.prototype.setEditorReadOnly=function(x,u){u?x.disable():x.enable()},h.prototype.makeUnprivilegedEditor=function(x){var u=x;return{getHTML:function(){return u.root.innerHTML},getLength:u.getLength.bind(u),getText:u.getText.bind(u),getContents:u.getContents.bind(u),getSelection:u.getSelection.bind(u),getBounds:u.getBounds.bind(u)}},h.prototype.getEditingArea=function(){if(!this.editingArea)throw new Error("Instantiating on missing editing area");var x=i.default.findDOMNode(this.editingArea);if(!x)throw new Error("Cannot find element for editing area");if(x.nodeType===3)throw new Error("Editing area cannot be a text node");return x},h.prototype.renderEditingArea=function(){var x=this,u=this.props,N=u.children,v=u.preserveWhitespace,w=this.state.generation,j={key:w,ref:function(b){x.editingArea=b}};return a.default.Children.count(N)?a.default.cloneElement(a.default.Children.only(N),j):v?a.default.createElement("pre",s({},j)):a.default.createElement("div",s({},j))},h.prototype.render=function(){var x;return a.default.createElement("div",{id:this.props.id,style:this.props.style,key:this.state.generation,className:"quill "+(x=this.props.className,x??""),onKeyPress:this.props.onKeyPress,onKeyDown:this.props.onKeyDown,onKeyUp:this.props.onKeyUp},this.renderEditingArea())},h.prototype.onEditorChangeText=function(x,u,N,v){var w,j;if(this.editor){var b=this.isDelta(this.value)?v.getContents():v.getHTML();b!==this.getEditorContents()&&(this.lastDeltaChangeSet=u,this.value=b,(j=(w=this.props).onChange)===null||j===void 0||j.call(w,x,u,N,v))}},h.prototype.onEditorChangeSelection=function(x,u,N){var v,w,j,b,C,S;if(this.editor){var R=this.getEditorSelection(),_=!R&&x,A=R&&!x;o.default(x,R)||(this.selection=x,(w=(v=this.props).onChangeSelection)===null||w===void 0||w.call(v,x,u,N),_?(b=(j=this.props).onFocus)===null||b===void 0||b.call(j,x,u,N):A&&((S=(C=this.props).onBlur)===null||S===void 0||S.call(C,R,u,N)))}},h.prototype.focus=function(){this.editor&&this.editor.focus()},h.prototype.blur=function(){this.editor&&(this.selection=null,this.editor.blur())},h.displayName="React Quill",h.Quill=d.default,h.defaultProps={theme:"snow",modules:{},readOnly:!1},h})(a.default.Component);function f(p){Promise.resolve().then(p)}return li=m,li}var pG=fG();const xG=wf(pG),gG={toolbar:[[{header:[1,2,3,!1]}],["bold","italic","underline"],[{list:"ordered"},{list:"bullet"}],["link"],["blockquote"],["clean"]]},vG=["header","bold","italic","underline","list","bullet","link","blockquote"];function Km(t){const s=t||"";return/\{\{\s*[>#\/]/.test(s)||/\{\{>\s*\w+/.test(s)||/<!DOCTYPE/i.test(s)||/<html[\s>]/i.test(s)||/<\/html>/i.test(s)||/<style\b/i.test(s)||/<head[\s>]/i.test(s)}const K_=g.forwardRef(({value:t,onChange:s,tab:n,onTabChange:r,textareaRef:a},i)=>{const o=g.useRef(null),d=g.useMemo(()=>Km(t),[t]);return g.useImperativeHandle(i,()=>({insertPlaceholder:m=>{var u,N;const f=`{{${m}}}`;if(n==="html"&&a.current){const v=a.current,w=v.selectionStart??0,j=v.selectionEnd??0,b=t.slice(0,w)+f+t.slice(j);s(b),requestAnimationFrame(()=>{v.focus();const C=w+f.length;v.setSelectionRange(C,C)});return}const p=(N=(u=o.current)==null?void 0:u.getEditor)==null?void 0:N.call(u);if(!p)return;const h=p.getSelection(!0),x=(h==null?void 0:h.index)??p.getLength();p.insertText(x,f,"user")}})),e.jsx("div",{className:"flex flex-col gap-2 flex-1 min-h-0",children:e.jsxs(Bn,{value:n,onValueChange:r,className:"flex flex-col flex-1 gap-2 min-h-0",children:[e.jsxs($n,{className:"w-fit",children:[e.jsx(Wt,{value:"visual",disabled:d,className:"text-xs",children:"Rich text"}),e.jsx(Wt,{value:"html",className:"text-xs font-mono",children:"HTML source"})]}),d&&e.jsxs(di,{className:"border-red-200 bg-red-50 py-2",children:[e.jsx(_a,{className:"h-4 w-4 text-re-red-hover"}),e.jsxs(ui,{className:"text-[11px] text-red-900",children:["This template uses layout partials (",e.jsx("code",{className:"font-mono",children:"{{> ...}}"}),"), block helpers, or a full HTML document. Edit it in ",e.jsx("strong",{children:"HTML source"})," so nothing is stripped. Use placeholders on the left to insert fields safely."]})]}),e.jsxs(Ut,{value:"visual",className:"flex-1 flex flex-col gap-2 mt-2 min-h-[420px] data-[state=inactive]:hidden",children:[e.jsx("div",{className:Nt("email-quill rounded-md border border-slate-200 bg-white overflow-hidden flex flex-col flex-1","[&_.ql-toolbar]:border-slate-200 [&_.ql-toolbar]:bg-slate-50","[&_.ql-container]:border-0 [&_.ql-editor]:min-h-[380px] [&_.ql-editor]:text-sm [&_.ql-editor]:text-slate-900"),children:e.jsx(xG,{ref:o,theme:"snow",value:t||"",onChange:s,modules:gG,formats:vG})}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:["Use headings, lists, and links. Insert dynamic fields from ",e.jsx("strong",{children:"Available Placeholders"})," on the left."]})]}),e.jsxs(Ut,{value:"html",className:"flex-1 flex flex-col mt-2 min-h-[420px] data-[state=inactive]:hidden",children:[e.jsx(Ws,{ref:a,placeholder:"Raw HTML / Handlebars — use for partials {{> ...}} or full layouts",className:"flex-1 min-h-[420px] font-mono text-xs text-slate-900 bg-slate-900/5 focus:bg-white p-4 resize-y",value:t||"",onChange:m=>s(m.target.value),spellCheck:!1}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1",children:["Full control for ",e.jsx("code",{className:"font-mono",children:"{{> email_header}}"}),", styles, and edge cases. Backend still sanitizes on save."]})]})]})})});K_.displayName="EmailTemplateBodyEditor";function yG(t){const s=/\{\{\{[\s\S]*?\}\}\}|\{\{[\s\S]*?\}\}/g;return t.replace(s,n=>n.replace(/&amp;lt;/gi,"<").replace(/&amp;gt;/gi,">").replace(/&amp;quot;/gi,'"').replace(/&amp;#39;/g,"'").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&"))}const bG=/\{\{\s*>\s*email_header\s*\}\}/i,jG=/\{\{\s*>\s*email_footer\s*\}\}/i,NG=/\{\{\s*>\s*primary_cta\s*\}\}/i,wG=/^[\s\r\n]*(?:<(?:p|div)[^>]*>)?\s*\{\{\s*>\s*email_header\s*\}\}\s*(?:<\/(?:p|div)>)?[\s\r\n]*/i,SG=/[\s\r\n]*(?:<(?:p|div)[^>]*>)?\s*\{\{\s*>\s*email_footer\s*\}\}\s*(?:<\/(?:p|div)>)?[\s\r\n]*$/i,CG=/(?:<(?:p|div)[^>]*>)?\s*\{\{\s*>\s*primary_cta\s*\}\}\s*(?:<\/(?:p|div)>)?/gi;function AG(t){const s=t||"",n=yG(s);if(!bG.test(n)||!jG.test(n))return{isShellTemplate:!1,editableHtml:s,includesCta:!1};const r=NG.test(n);let a=n.replace(wG,"").replace(SG,"").replace(CG,"");return a=a.trim(),{isShellTemplate:!0,editableHtml:a,includesCta:r}}function kG(t,s){return`{{> email_header}}
${(t||"").trim()}${s?`
{{> primary_cta}}
`:`
`}{{> email_footer}}`}const DG=({isOpen:t,onOpenChange:s,editingTemplate:n,setEditingTemplate:r,testDataInput:a,setTestDataInput:i,previewLoading:o,handlePreviewTemplate:d,previewContent:m,handleSaveTemplate:f})=>{var q;const p=wt.useRef(null),h=wt.useRef(null),[x,u]=wt.useState("visual"),[N,v]=wt.useState(""),[w,j]=wt.useState(!1),[b,C]=wt.useState(!1);wt.useEffect(()=>{if(!t||!n)return;const O=AG(n.body||"");j(O.isShellTemplate),C(O.includesCta);const D=O.isShellTemplate?O.editableHtml:n.body||"";v(D);const P=Km(D);u(P?"html":"visual")},[t,n==null?void 0:n.id,n==null?void 0:n.body]);const S=wt.useCallback(()=>w?kG(N,b):(n==null?void 0:n.body)||"",[w,N,b,n==null?void 0:n.body]),R=O=>{var D;(D=h.current)==null||D.insertPlaceholder(O)},_=(n==null?void 0:n.placeholders)||[],A=w?N:(n==null?void 0:n.body)||"",E=O=>{w?(v(O),Km(O)&&u("html")):(r({...n,body:O}),Km(O)&&u("html"))};return e.jsx(ds,{open:t,onOpenChange:s,children:e.jsxs(os,{className:"sm:max-w-7xl w-full max-h-[95vh] overflow-y-auto",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Edit Email Template"}),e.jsx(bs,{children:"Trigger codes are fixed by system seeding. Edit subject and message content below."})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-8",children:[e.jsx("div",{className:"lg:col-span-4 space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-slate-50 p-4 rounded-lg border border-slate-200 space-y-4",children:[e.jsxs("h3",{className:"text-sm font-semibold text-slate-800 flex items-center gap-2",children:[e.jsx(Xc,{className:"w-4 h-4 text-re-red"}),"General Settings"]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-xs uppercase tracking-wider text-slate-500",children:"Template Name"}),e.jsx(at,{placeholder:"e.g., Application Received",className:"mt-1.5 bg-white",value:(n==null?void 0:n.name)||"",onChange:O=>r({...n,name:O.target.value})})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-xs uppercase tracking-wider text-slate-500",children:"Trigger Code"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1 mb-1",children:"Defined when the template row is seeded; it cannot be changed here."}),e.jsx("div",{className:"mt-1.5 flex items-center",children:e.jsx(Ce,{variant:"outline",className:"bg-white font-mono text-xs px-3 py-1.5",children:(n==null?void 0:n.templateCode)||"—"})})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-xs uppercase tracking-wider text-slate-500",children:"Description"}),e.jsx(at,{placeholder:"Brief purpose of this email",className:"mt-1.5 bg-white",value:(n==null?void 0:n.description)||"",onChange:O=>r({...n,description:O.target.value})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t mt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(bp,{id:"active",checked:(n==null?void 0:n.isActive)??!0,onCheckedChange:O=>r({...n,isActive:O})}),e.jsx(de,{htmlFor:"active",className:"text-sm cursor-pointer",children:"Active"})]}),e.jsx(Ce,{className:n!=null&&n.isActive?"bg-green-100 text-green-700":"bg-slate-100 text-slate-500",children:n!=null&&n.isActive?"Template Enabled":"Template Disabled"})]})]}),e.jsxs("div",{className:"bg-red-50 p-4 rounded-lg border border-red-100",children:[e.jsxs("h3",{className:"text-sm font-semibold text-red-900 flex items-center gap-2 mb-3",children:[e.jsx(_a,{className:"w-4 h-4"}),"Available Placeholders"]}),e.jsx("p",{className:"text-[10px] text-re-red-hover mb-4 leading-relaxed",children:"Click a placeholder to insert it at the cursor."}),e.jsx("div",{className:"flex flex-wrap gap-2",children:_.length>0?_.map(O=>e.jsx("button",{type:"button",onClick:()=>R(O),className:"px-2 py-1 bg-white border border-red-200 rounded text-[11px] font-mono text-red-800 hover:bg-re-red hover:text-white hover:border-re-red transition-all flex items-center gap-1 shadow-sm",children:`{{${O}}}`},O)):e.jsx("div",{className:"w-full py-4 text-center border-2 border-dashed border-red-200 rounded-lg",children:e.jsx("p",{className:"text-[10px] text-re-red",children:"No placeholders defined for this trigger"})})})]})]})}),e.jsxs("div",{className:"lg:col-span-4 space-y-4 flex flex-col h-full min-h-[600px]",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h3",{className:"font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(Cr,{className:"w-4 h-4 text-re-red"}),"Template Designer"]})}),e.jsxs("div",{className:"flex-1 flex flex-col space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-xs font-semibold",children:"Subject Line"}),e.jsx(at,{placeholder:"Subject line with {{variables}}",className:"mt-1.5 text-slate-900 font-medium",value:(n==null?void 0:n.subject)||"",onChange:O=>r({...n,subject:O.target.value})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-[480px]",children:[e.jsx(de,{className:"text-xs font-semibold mb-1.5",children:"Email Body"}),e.jsx(K_,{ref:h,tab:x,onTabChange:O=>u(O),textareaRef:p,value:A,onChange:E})]})]})]}),e.jsxs("div",{className:"lg:col-span-4 space-y-6 lg:border-l lg:pl-8 flex flex-col h-full",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold text-slate-900 flex items-center gap-2 mb-4",children:[e.jsx(xg,{className:"w-4 h-4 text-green-600"}),"Live Simulation"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx(de,{className:"text-xs font-semibold",children:"Mock Test Data (JSON)"}),e.jsx("button",{type:"button",onClick:()=>i('{"applicantName": "Rajesh Kumar", "location": "Mumbai South", "applicationId": "APP-2026-X12", "link": "https://example.com/app", "portalLink": "https://example.com/app"}'),className:"text-[10px] text-re-red hover:underline",children:"Reset to Sample"})]}),e.jsx(Ws,{placeholder:'{"applicant_name": "John Doe"}',className:"font-mono text-[11px] text-slate-900 bg-slate-50",rows:6,value:a,onChange:O=>i(O.target.value)})]}),e.jsxs(se,{variant:"default",type:"button",className:"w-full bg-green-600 hover:bg-green-700 shadow-md",onClick:()=>d(S()),disabled:o,children:[o?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(xg,{className:"w-4 h-4 mr-2"}),"Generate Mock Preview"]})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsx(de,{className:"text-xs font-semibold mb-2",children:"Simulated Output"}),e.jsx("div",{className:"flex-1 border rounded-xl overflow-hidden flex flex-col bg-slate-50 shadow-inner",children:m?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-white p-3 border-b text-[11px] font-semibold text-slate-700 flex items-center justify-between",children:[e.jsxs("div",{className:"truncate shrink",children:[e.jsx("span",{className:"text-slate-400 mr-2",children:"Subject:"})," ",m.subject]}),e.jsxs(Ce,{variant:"outline",className:"bg-green-50 text-green-600 text-[9px] whitespace-nowrap ml-2",children:[e.jsx(Zn,{className:"w-3 h-3 mr-1"})," Compiled"]})]}),e.jsx("div",{className:"p-6 bg-white overflow-auto flex-1 shadow-sm",children:e.jsx("div",{className:"max-w-none text-sm text-slate-800 email-preview-container",dangerouslySetInnerHTML:{__html:m.html}})})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-center text-slate-400 space-y-3",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-slate-100 flex items-center justify-center",children:e.jsx(xg,{className:"w-8 h-8 opacity-20"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-500",children:"Ready for Preview"}),e.jsx("p",{className:"text-[11px]",children:'Click "Generate Mock Preview" to see the rendered email.'})]})]})})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-4 border-t mt-4",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-re-red hover:bg-re-red-hover",type:"button",onClick:()=>f(S()),disabled:!(n!=null&&n.id)||!((q=n==null?void 0:n.templateCode)!=null&&q.trim()),children:"Save Template"})]})]})})},RG=({isOpen:t,onOpenChange:s,editingLocationId:n,locationState:r,setLocationState:a,locationDistrict:i,setLocationDistrict:o,locationCity:d,setLocationCity:m,locationActiveFrom:f,setLocationActiveFrom:p,locationActiveTo:h,setLocationActiveTo:x,locationStatus:u,setLocationStatus:N,allStates:v,allDistricts:w,onSave:j})=>{const b=wt.useMemo(()=>r?(w||[]).filter(C=>C.stateId===r):[],[w,r]);return e.jsx(ds,{open:t,onOpenChange:s,children:e.jsxs(os,{children:[e.jsxs(xs,{children:[e.jsx(ms,{children:n?"Edit Location":"Add Location"}),e.jsx(bs,{children:n?"Modify dealership location details":"Add a new dealership location (Area/City)"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"State"}),e.jsxs(Dt,{value:r,onValueChange:C=>{a(C),o("")},children:[e.jsx(Et,{className:"mt-2 text-slate-900 border-slate-200 focus:ring-red-500/30 focus:border-red-500",children:e.jsx(Rt,{placeholder:"Select state"})}),e.jsx(_t,{children:(v||[]).map(C=>e.jsx(Me,{value:C.id,children:C.name||C.stateName},C.id))})]})]}),e.jsxs("div",{children:[e.jsx(de,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"City"}),e.jsx(at,{placeholder:"Enter city name",className:"mt-2 text-slate-900 border-slate-200 focus-visible:ring-red-500/30 focus-visible:border-red-500",value:d,onChange:C=>m(C.target.value)})]}),e.jsxs("div",{children:[e.jsx(de,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"District"}),e.jsxs(Dt,{value:i,onValueChange:o,disabled:!r,children:[e.jsx(Et,{className:"mt-2 text-slate-900 border-slate-200 focus:ring-red-500/30 focus:border-red-500",children:e.jsx(Rt,{placeholder:r?"Select district":"Select state first"})}),e.jsx(_t,{children:b.map(C=>e.jsx(Me,{value:C.id,children:C.name},C.id))})]})]}),e.jsxs("div",{className:"border rounded-lg p-4 bg-gradient-to-br from-blue-50 to-cyan-50 border-blue-200",children:[e.jsx(de,{className:"items-center gap-2 text-sm leading-none font-medium text-blue-900 mb-3 block",children:"Active Period"}),e.jsx("p",{className:"text-xs text-blue-700 mb-3",children:"Define the time period when this location will be available for dealership applications"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(de,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"Start Date"}),e.jsx(at,{type:"date",className:"mt-2 text-slate-900 border-slate-200 focus-visible:ring-blue-500/30 focus-visible:border-blue-500",value:f,onChange:C=>p(C.target.value)})]}),e.jsxs("div",{children:[e.jsx(de,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"End Date"}),e.jsx(at,{type:"date",className:"mt-2 text-slate-900 border-slate-200 focus-visible:ring-blue-500/30 focus-visible:border-blue-500",value:h,onChange:C=>x(C.target.value)})]})]})]}),e.jsxs("div",{children:[e.jsx(de,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"Opportunity"}),e.jsxs(Dt,{value:u,onValueChange:N,children:[e.jsx(Et,{className:"mt-2 text-slate-900 border-slate-200 focus:ring-red-500/30 focus:border-red-500",children:e.jsx(Rt,{placeholder:"Is this an active Opportunity?"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"active",children:"Yes"}),e.jsx(Me,{value:"inactive",children:"No"})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-re-red hover:bg-re-red-hover text-white shadow-md hover:shadow-lg transition-all",onClick:j,children:"Save Location"})]})]})]})})},EG=()=>{const[t,s]=g.useState([]),[n,r]=g.useState(!0),[a,i]=g.useState(null),o=async()=>{try{r(!0);const f=await Is.getSystemConfigs({category:"SECURITY_DEPOSIT"});f.success&&s(f.data)}catch(f){console.error("Fetch error:",f),te.error("Failed to load deposit configurations")}finally{r(!1)}};g.useEffect(()=>{o()},[]);const d=(f,p)=>{s(h=>h.map(x=>x.id===f?{...x,value:{...x.value,amount:parseInt(p)||0}}:x))},m=async f=>{try{i(f.id),(await Is.saveSystemConfig(f)).success&&te.success(`Configuration for ${f.key} updated successfully`)}catch{te.error("Failed to save configuration")}finally{i(null)}};return n?e.jsxs("div",{className:"flex flex-col items-center justify-center p-20 space-y-4",children:[e.jsx("div",{className:"w-10 h-10 border-4 border-re-red border-t-transparent rounded-full animate-spin"}),e.jsx("p",{className:"text-slate-600 animate-pulse",children:"Loading settings..."})]}):e.jsxs("div",{className:"space-y-4 animate-in fade-in duration-500 max-w-4xl",children:[e.jsxs(Le,{className:"border-none shadow-lg bg-white/80 backdrop-blur-md",children:[e.jsx(Qe,{className:"py-4 border-b bg-slate-50/50",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-red-100 flex items-center justify-center",children:e.jsx(Xc,{className:"w-5 h-5 text-re-red"})}),e.jsxs("div",{children:[e.jsx(Je,{className:"text-lg font-bold text-slate-900",children:"Global Payment Settings"}),e.jsx(Xt,{className:"text-xs",children:"Configure base Security Deposit amounts for onboarding workflows."})]})]})}),e.jsxs(Fe,{className:"p-4",children:[e.jsx("div",{className:"grid gap-3",children:t.map(f=>{var p;return e.jsxs("div",{className:"p-3 border rounded-xl bg-white hover:shadow-sm transition-shadow flex items-center justify-between border-slate-100",children:[e.jsxs("div",{className:"space-y-0.5 max-w-md",children:[e.jsxs("h4",{className:"font-bold text-slate-800 text-sm flex items-center gap-2",children:[f.key.replace(/_/g," "),e.jsx("span",{className:"text-[9px] bg-slate-100 text-slate-500 px-1.5 py-0.5 rounded-full uppercase tracking-wider",children:"Master"})]}),e.jsx("p",{className:"text-xs text-slate-500 leading-tight",children:f.description})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(de,{htmlFor:`amount-${f.id}`,className:"text-[10px] font-semibold text-slate-400 uppercase tracking-wider block",children:"Amount (INR)"}),e.jsxs("div",{className:"relative w-40",children:[e.jsx(ka,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-slate-400 font-bold"}),e.jsx(at,{id:`amount-${f.id}`,type:"number",className:"pl-8 h-9 text-base font-bold bg-slate-50/50 border-slate-200 focus:ring-red-500 focus:border-red-500 rounded-lg",value:((p=f.value)==null?void 0:p.amount)||"",onChange:h=>d(f.id,h.target.value)})]})]}),e.jsx("div",{className:"pt-4",children:e.jsx(se,{onClick:()=>m(f),disabled:a===f.id,className:"h-9 px-4 bg-re-red hover:bg-re-red-hover text-white rounded-lg shadow-md shadow-re-red/10 active:scale-95 transition-all flex items-center gap-1.5 group",children:a===f.id?e.jsx(xr,{className:"w-4 h-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(ml,{className:"w-4 h-4 group-hover:scale-110 transition-transform"}),e.jsx("span",{className:"font-bold text-sm",children:"Update"})]})})})]})]},f.id)})}),t.length===0&&e.jsxs("div",{className:"text-center py-12 bg-slate-50/50 rounded-xl border border-dashed border-slate-200",children:[e.jsx("div",{className:"w-12 h-12 bg-slate-100 rounded-full flex items-center justify-center mx-auto mb-3",children:e.jsx(Xc,{className:"w-6 h-6 text-slate-400"})}),e.jsx("p",{className:"text-slate-500 text-sm font-medium",children:"No configurations found."}),e.jsxs(se,{variant:"outline",className:"mt-4 rounded-lg h-9 text-xs",onClick:o,children:[e.jsx(xr,{className:"w-3.5 h-3.5 mr-1.5"})," Reload"]})]})]})]}),e.jsxs("div",{className:"bg-red-50/50 rounded-xl p-4 border border-red-100/50 flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-red-100 flex items-center justify-center flex-shrink-0",children:e.jsx(Xc,{className:"w-4 h-4 text-re-red-hover"})}),e.jsxs("div",{children:[e.jsx("h5",{className:"font-bold text-red-900 text-sm",children:"Super Admin Notice"}),e.jsx("p",{className:"text-[11px] text-red-800/80 leading-snug",children:"Updates made here take immediate effect. These values define the default expected amounts for all current and future onboarding payments."})]})]})]})},_G=()=>{const[t,s]=g.useState([]),[n,r]=g.useState(!0),[a,i]=g.useState(!1),[o,d]=g.useState(!1),[m,f]=g.useState(null),[p,h]=g.useState([]),[x,u]=g.useState({}),[N,v]=g.useState(!0),[w,j]=g.useState(""),[b,C]=g.useState(1),[S]=g.useState(10),[R,_]=g.useState(""),[A,E]=g.useState({total:0,pages:1}),q=g.useRef(!0),[O,D]=g.useState({documentType:"",stageCode:"General",allowedRoles:[],isMandatory:!1,isActive:!0,module:""}),P=["DD-ZM","RBM","DD","ZBH","DD Lead","DD Head","NBH","DD Admin","Legal Admin","Super Admin","DD AM","FDD","DDL","Finance","Finance Admin","Dealer","ARCHITECTURE"];g.useEffect(()=>{(async()=>{var z;try{const T=await hs.getDocumentConfigMetadata();T&&(h(T.modules||[]),u(T.stages||{}),((z=T.modules)==null?void 0:z.length)>0&&(_(T.modules[0]),D(I=>({...I,module:T.modules[0]}))))}catch{te.error("Failed to load system metadata")}finally{v(!1)}})()},[]);const L=g.useCallback(async()=>{if(R){q.current?r(!0):i(!0);try{const M=await hs.getDocumentConfigs({search:w,page:b,limit:S,module:R,isAdminView:!0});M&&M.pagination?(s(M.data||[]),E(M.pagination)):Array.isArray(M)&&(s(M),E({total:M.length,pages:1}))}catch(M){console.error("Fetch Configs Error:",M),q.current||te.error("Failed to sync configuration database")}finally{r(!1),i(!1),q.current=!1}}},[w,b,S,R]);g.useEffect(()=>{const M=setTimeout(()=>{L()},300);return()=>clearTimeout(M)},[L]);const $=async()=>{try{m?(await hs.updateDocumentConfig(m.id,O),te.success("Configuration updated")):(await hs.createDocumentConfig(O),te.success("Configuration created")),d(!1),L()}catch{te.error("Failed to save configuration")}},Y=async M=>{if(window.confirm("Are you sure you want to delete this configuration?"))try{await hs.deleteDocumentConfig(M),te.success("Configuration deleted"),L()}catch{te.error("Failed to delete configuration")}},Z=()=>{f(null),D({documentType:"",stageCode:"General",allowedRoles:[],isMandatory:!1,isActive:!0,module:R}),d(!0)},W=M=>{f(M),D({documentType:M.documentType,stageCode:M.stageCode,allowedRoles:M.allowedRoles||[],isMandatory:M.isMandatory,isActive:M.isActive,module:M.module||"ONBOARDING"}),d(!0)},U=M=>{D(z=>({...z,allowedRoles:z.allowedRoles.includes(M)?z.allowedRoles.filter(T=>T!==M):[...z.allowedRoles,M]}))};return N?e.jsxs("div",{className:"h-96 flex flex-col items-center justify-center gap-4",children:[e.jsx(ty,{className:"w-10 h-10 text-re-red animate-bounce"}),e.jsx("p",{className:"text-slate-500 font-bold uppercase tracking-widest text-xs",children:"Connecting to Governance Engine..."})]}):e.jsxs(Le,{className:"border-slate-200 shadow-sm overflow-hidden bg-white",children:[e.jsxs(Qe,{className:"bg-slate-50/80 border-b border-slate-200 py-4 relative",children:[a&&e.jsxs("div",{className:"absolute top-0 left-0 right-0 h-1 bg-red-100 overflow-hidden",children:[e.jsx("div",{className:"h-full bg-re-red animate-[loading_1.5s_infinite_linear]",style:{width:"30%",transformOrigin:"left"}}),e.jsx("style",{children:`
@keyframes loading {
0% { left: -30%; }
100% { left: 100%; }
}
`})]}),e.jsxs("div",{className:"flex flex-row items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-white rounded-xl shadow-sm ring-1 ring-slate-200 text-re-red",children:e.jsx(VI,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx(Je,{className:"text-lg font-bold text-slate-800",children:"Governance Matrix"}),e.jsx("p",{className:"text-[11px] text-slate-500 font-bold uppercase tracking-wider",children:"Baseline Document Rules (Synced from Backend)"})]})]}),e.jsxs(se,{onClick:Z,className:"bg-slate-900 hover:bg-black text-white rounded-xl h-9 px-4 flex gap-2 font-bold transition-all active:scale-95 shadow-md uppercase text-[10px]",children:[e.jsx(An,{className:"w-4 h-4"})," Add Policy"]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-64",children:e.jsxs(Dt,{value:R,onValueChange:M=>{_(M),C(1)},children:[e.jsx(Et,{className:"h-10 rounded-xl bg-white border-slate-200 focus:ring-red-500 font-bold text-slate-700 shadow-sm",children:e.jsx(Rt,{placeholder:"Target Module"})}),e.jsx(_t,{className:"rounded-xl shadow-2xl border-none",children:p.map(M=>e.jsx(Me,{value:M,className:"font-bold text-xs py-2.5 uppercase",children:M.replace(/_/g," ")},M))})]})}),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(at,{placeholder:"Search policies, stages or documents...",value:w,onChange:M=>{j(M.target.value),C(1)},className:"pl-10 h-10 rounded-xl bg-white border-slate-200 focus:ring-red-500 shadow-sm font-medium"})]})]})]}),e.jsxs(Fe,{className:"p-0 min-h-[400px] relative",children:[n?e.jsxs("div",{className:"absolute inset-0 z-10 bg-white/60 backdrop-blur-[1px] flex flex-col items-center justify-center gap-3",children:[e.jsx(ns,{className:"w-8 h-8 text-re-red animate-spin"}),e.jsx("span",{className:"text-slate-500 text-sm font-bold animate-pulse",children:"Syncing Policies..."})]}):null,e.jsxs(Ts,{children:[e.jsx(Ps,{className:"bg-slate-50/50",children:e.jsxs(it,{className:"border-none",children:[e.jsx(fe,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Policy Detail"}),e.jsx(fe,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Process Stage"}),e.jsx(fe,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Module"}),e.jsx(fe,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Stakeholders"}),e.jsx(fe,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Compliance Rules"}),e.jsx(fe,{className:"text-right font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Action"})]})}),e.jsx(Os,{children:!n&&t.length===0?e.jsx(it,{children:e.jsx(ue,{colSpan:6,className:"h-96 text-center text-slate-500",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 opacity-40",children:[e.jsx(Ta,{className:"w-12 h-12 mb-2"}),e.jsxs("p",{className:"font-bold text-xl",children:["No policies found for ",R]}),e.jsx("p",{className:"text-sm font-medium",children:"Try adjusting your filters or search term"})]})})}):t.map(M=>{var z,T;return e.jsxs(it,{className:"hover:bg-slate-50/80 transition-colors group h-14",children:[e.jsx(ue,{children:e.jsx("div",{className:"font-bold text-slate-900 group-hover:text-re-red-hover transition-colors uppercase text-[12px]",children:M.documentType})}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",className:"bg-blue-50/50 border-blue-100 text-blue-700 font-bold px-2 py-0.5 whitespace-nowrap text-[10px] rounded-md uppercase",children:M.stageCode})}),e.jsx(ue,{children:e.jsx("div",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-tighter",children:(z=M.module)==null?void 0:z.replace(/_/g," ")})}),e.jsx(ue,{children:e.jsx("div",{className:"flex flex-wrap gap-1 max-w-[200px]",children:((T=M.allowedRoles)==null?void 0:T.length)>0?e.jsxs(e.Fragment,{children:[M.allowedRoles.slice(0,2).map(I=>e.jsx(Ce,{variant:"secondary",className:"bg-white text-slate-600 text-[9px] border-slate-200 font-bold uppercase",children:I},I)),M.allowedRoles.length>2&&e.jsxs(Ce,{variant:"outline",className:"text-[9px] text-slate-400 font-bold border-dashed",children:["+",M.allowedRoles.length-2]})]}):e.jsx(Ce,{variant:"secondary",className:"bg-slate-50 text-slate-400 text-[9px] border-slate-100 uppercase",children:"Inherited"})})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex gap-2",children:[M.isMandatory&&e.jsx(Ce,{className:"bg-re-red text-white border-transparent text-[10px] font-bold h-5 px-1.5 rounded-sm uppercase tracking-tighter",children:"BLOCKING"}),!M.isActive&&e.jsx(Ce,{className:"bg-slate-200 text-slate-500 border-transparent text-[10px] h-5 px-1.5 rounded-sm uppercase tracking-tighter",children:"DORMANT"}),M.isActive&&!M.isMandatory&&e.jsx(Ce,{className:"bg-emerald-100 text-emerald-700 border-emerald-200 text-[10px] h-5 px-1.5 rounded-sm font-black uppercase tracking-tighter",children:"OPTIONAL"})]})}),e.jsx(ue,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(se,{variant:"ghost",size:"icon",onClick:()=>W(M),className:"h-8 w-8 text-slate-400 hover:text-blue-600 hover:bg-blue-50 rounded-lg transition-transform active:scale-90",children:e.jsx(Cr,{className:"w-4 h-4"})}),e.jsx(se,{variant:"ghost",size:"icon",onClick:()=>Y(M.id),className:"h-8 w-8 text-slate-400 hover:text-re-red hover:bg-red-50 rounded-lg transition-transform active:scale-90",children:e.jsx(ar,{className:"w-4 h-4"})})]})})]},M.id)})})]}),e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-slate-50/50 border-t border-slate-200 mt-auto",children:[e.jsxs("div",{className:"text-[11px] text-slate-500 font-bold uppercase tracking-tight",children:["Dataset Index ",e.jsxs("span",{className:"text-slate-900 border-b border-slate-300 mx-1",children:[t.length>0?(b-1)*S+1:0," - ",Math.min(b*S,A.total)]})," Total Found ",e.jsx("span",{className:"text-re-red-hover font-extrabold ml-1",children:A.total})]}),e.jsxs("div",{className:"flex gap-3 items-center",children:[e.jsxs(se,{variant:"outline",size:"sm",disabled:b===1,onClick:()=>{C(M=>Math.max(1,M-1)),window.scrollTo({top:0,behavior:"smooth"})},className:"h-9 px-3 rounded-xl border-slate-200 bg-white hover:bg-slate-50 transition-all font-bold shadow-sm disabled:opacity-30 uppercase text-[10px]",children:[e.jsx(lo,{className:"w-4 h-4 mr-1 text-slate-600"})," Prev"]}),e.jsxs("div",{className:"flex items-center px-4 h-9 bg-white border border-slate-200 rounded-xl text-xs font-extrabold text-slate-800 shadow-inner",children:[e.jsx("span",{className:"text-re-red",children:b})," ",e.jsx("span",{className:"mx-2 text-slate-300",children:"/"})," ",A.pages]}),e.jsxs(se,{variant:"outline",size:"sm",disabled:b>=A.pages,onClick:()=>{C(M=>Math.min(A.pages,M+1)),window.scrollTo({top:0,behavior:"smooth"})},className:"h-9 px-3 rounded-xl border-slate-200 bg-white hover:bg-slate-50 transition-all font-bold shadow-sm disabled:opacity-30 uppercase text-[10px]",children:["Next ",e.jsx(bi,{className:"w-4 h-4 ml-1 text-slate-600"})]})]})]})]}),e.jsx(ds,{open:o,onOpenChange:d,children:e.jsxs(os,{className:"max-w-2xl rounded-2xl border-none shadow-2xl p-0 overflow-hidden ring-1 ring-black/5",children:[e.jsx(xs,{className:"bg-slate-900 text-white p-7",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 bg-white/10 rounded-2xl backdrop-blur-md ring-1 ring-white/20",children:e.jsx(Bf,{className:"w-7 h-7 text-red-400"})}),e.jsxs("div",{children:[e.jsx(ms,{className:"text-2xl font-black tracking-tight uppercase",children:m?"Modify Policy":"Publish Rule"}),e.jsxs("p",{className:"text-xs text-slate-400 font-bold tracking-widest uppercase mt-1",children:["Configuring ",O.module," Lifecycle"]})]})]})}),e.jsxs("div",{className:"p-7 space-y-6 bg-white overflow-y-auto max-h-[70vh]",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{className:"text-slate-900 font-black px-1 text-[11px] uppercase tracking-wider",children:"Process Stream"}),e.jsxs(Dt,{value:O.module,onValueChange:M=>D(z=>({...z,module:M,stageCode:"General"})),children:[e.jsx(Et,{className:"h-12 rounded-xl border-slate-200 focus:ring-red-500 shadow-sm bg-slate-50 font-black text-xs uppercase",children:e.jsx(Rt,{placeholder:"Module"})}),e.jsx(_t,{className:"rounded-xl border-none shadow-2xl",children:p.map(M=>e.jsx(Me,{value:M,className:"py-3 px-4 rounded-lg focus:bg-red-50 font-black text-[10px] uppercase",children:M.replace(/_/g," ")},M))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{className:"text-slate-900 font-black px-1 text-[11px] uppercase tracking-wider",children:"Milestone Stage"}),e.jsxs(Dt,{value:O.stageCode,onValueChange:M=>D(z=>({...z,stageCode:M})),children:[e.jsx(Et,{className:"h-12 rounded-xl border-slate-200 focus:ring-red-500 shadow-sm bg-white font-black text-xs uppercase",children:e.jsx(Rt,{placeholder:"Select Stage"})}),e.jsx(_t,{className:"rounded-xl border-none shadow-2xl",children:(x[O.module]||["General"]).map(M=>e.jsx(Me,{value:M,className:"py-3 px-4 rounded-lg focus:bg-red-50 font-black text-[10px] uppercase",children:M},M))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{className:"text-slate-900 font-black px-1 text-[11px] uppercase tracking-wider",children:"Document Label Identifier"}),e.jsx(at,{value:O.documentType,onChange:M=>D(z=>({...z,documentType:M.target.value})),placeholder:"e.g., PAN Card, Blueprint",className:"h-12 rounded-xl border-slate-200 focus:ring-red-500 shadow-sm font-black text-sm uppercase placeholder:font-bold placeholder:text-slate-300"})]}),e.jsxs("div",{className:"space-y-4 p-5 bg-slate-50 rounded-2xl border border-slate-100 shadow-inner",children:[e.jsxs(de,{className:"text-slate-900 font-black flex items-center gap-2 mb-2 text-[11px] uppercase tracking-wider",children:[e.jsx(no,{className:"w-4 h-4 text-re-red"})," Visibility Matrix"]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:P.map(M=>e.jsxs("div",{className:`flex items-center space-x-2 p-3 rounded-xl border transition-all cursor-pointer group active:scale-95 ${O.allowedRoles.includes(M)?"bg-red-50 border-red-300 shadow-sm":"bg-white border-slate-200 hover:border-red-200 hover:shadow-sm"}`,onClick:()=>U(M),children:[e.jsx(Ln,{id:`role-${M}`,checked:O.allowedRoles.includes(M),onCheckedChange:()=>U(M),className:"w-4 h-4 data-[state=checked]:bg-re-red data-[state=checked]:border-re-red rounded"}),e.jsx(de,{htmlFor:`role-${M}`,className:`text-[10px] font-black cursor-pointer uppercase truncate ${O.allowedRoles.includes(M)?"text-red-800":"text-slate-500 group-hover:text-re-red-hover"}`,children:M})]},M))})]}),e.jsxs("div",{className:"flex gap-6 mt-4",children:[e.jsxs("div",{className:`flex items-center space-x-4 p-4 rounded-2xl border transition-all cursor-pointer flex-1 group ${O.isMandatory?"bg-red-50 border-red-200 shadow-sm":"bg-slate-50 border-slate-100 hover:bg-red-50/30"}`,onClick:()=>D(M=>({...M,isMandatory:!M.isMandatory})),children:[e.jsx(Ln,{id:"mandatory",checked:O.isMandatory,onCheckedChange:M=>D(z=>({...z,isMandatory:!!M})),className:"w-5 h-5 border-slate-300 data-[state=checked]:bg-re-red data-[state=checked]:border-re-red rounded-md"}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(de,{htmlFor:"mandatory",className:"text-xs font-black text-slate-800 cursor-pointer group-hover:text-red-900 transition-colors uppercase tracking-tight",children:"Mandatory Policy"}),e.jsx("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-tighter",children:"Blocking Next Stage Action"})]})]}),e.jsxs("div",{className:`flex items-center space-x-4 p-4 rounded-2xl border transition-all cursor-pointer flex-1 group ${O.isActive?"bg-emerald-50 border-emerald-200 shadow-sm":"bg-slate-50 border-slate-100 hover:bg-emerald-50/30"}`,onClick:()=>D(M=>({...M,isActive:!M.isActive})),children:[e.jsx(Ln,{id:"active",checked:O.isActive,onCheckedChange:M=>D(z=>({...z,isActive:!!M})),className:"w-5 h-5 border-slate-300 data-[state=checked]:bg-emerald-600 data-[state=checked]:border-emerald-600 rounded-md"}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(de,{htmlFor:"active",className:"text-xs font-black text-slate-800 cursor-pointer group-hover:text-emerald-900 transition-colors uppercase tracking-tight",children:"Active Policy"}),e.jsx("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-tighter",children:"Visible To Active Streams"})]})]})]})]}),e.jsxs(bn,{className:"bg-slate-50 p-7 flex gap-4 border-t",children:[e.jsx(se,{variant:"ghost",onClick:()=>d(!1),className:"flex-1 h-12 rounded-xl font-black uppercase text-slate-400 hover:text-slate-600 hover:bg-slate-100 text-xs",children:"Discard"}),e.jsx(se,{onClick:$,className:"flex-1 h-12 rounded-xl bg-slate-900 hover:bg-black text-white font-black text-xs uppercase shadow-xl transition-all active:scale-95",children:m?"Update Policy Database":"Publish New Policy"})]})]})})]})},TG=()=>{const[t,s]=g.useState([]),[n,r]=g.useState(!0),a=async()=>{r(!0);try{const m=await Is.getSystemConfigs({category:"ASSIGNMENT"});m.success&&s(m.data)}catch{te.error("Failed to load assignment configurations")}finally{r(!1)}};g.useEffect(()=>{a()},[]);const i=(m,f)=>{s(p=>p.map(h=>h.key===m?{...h,value:{...h.value,enabled:f}}:h))},o=async m=>{try{(await Is.saveSystemConfig({key:m.key,value:m.value,category:m.category,description:m.description})).success&&te.success(`${m.key.replace("AUTO_ASSIGN_","")} setting updated`)}catch{te.error("Failed to save configuration")}},d=[{key:"AUTO_ASSIGN_ONBOARDING",label:"Onboarding",icon:rc,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_RELOCATION",label:"Relocation",icon:rM,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_TERMINATION",label:"Termination",icon:BI,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_CONSTITUTIONAL",label:"Constitutional",icon:qI,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_RESIGNATION",label:"Resignation",icon:Ns,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_FNF",label:"F&F Settlement",icon:PI,color:"text-slate-500",bg:"bg-slate-100"}];return n?e.jsxs("div",{className:"flex flex-col items-center justify-center p-12 space-y-4",children:[e.jsx(hl,{className:"w-8 h-8 animate-spin text-re-red"}),e.jsx("p",{className:"text-slate-500 font-medium",children:"Loading governance controls..."})]}):e.jsx("div",{className:"space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-500",children:e.jsxs(Le,{className:"border-none shadow-md overflow-hidden bg-white/50 backdrop-blur-sm",children:[e.jsx(Qe,{className:"bg-gradient-to-r from-slate-900 to-slate-800 text-white p-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:e.jsx(Bf,{className:"w-6 h-6 text-red-400"})}),e.jsxs("div",{children:[e.jsx(Je,{className:"text-xl font-bold",children:"Auto-Assignment Governance"}),e.jsx(Xt,{className:"text-slate-300",children:"Control the automated mapping of participants across different business modules"})]})]})}),e.jsxs(Fe,{className:"p-6",children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:d.map(m=>{var h;const f=t.find(x=>x.key===m.key),p=((h=f==null?void 0:f.value)==null?void 0:h.enabled)??!1;return e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-xl border bg-white transition-all group",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:Nt("w-12 h-12 flex items-center justify-center rounded-full transition-colors",m.bg,m.color),children:e.jsx(m.icon,{className:"w-6 h-6"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-slate-900",children:m.label}),e.jsx(gp,{children:e.jsxs(dj,{children:[e.jsx(uj,{children:e.jsx(_a,{className:"w-3.5 h-3.5 text-slate-400"})}),e.jsx(hj,{className:"max-w-xs",children:e.jsxs("p",{children:["When OFF, all participants for new ",m.label," requests must be assigned manually by authorized administrators."]})})]})})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(Ce,{variant:p?"default":"secondary",className:p?"bg-emerald-50 text-emerald-700 border-emerald-200 hover:bg-emerald-100":"bg-slate-50 text-slate-500 border-slate-200",children:p?"Auto-Assign ON":"Manual Mode"})})]})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsx(bp,{className:"data-[state=checked]:bg-re-red",checked:p,onCheckedChange:x=>{i(m.key,x);const u=t.find(N=>N.key===m.key);u&&o({...u,value:{enabled:x}})}})})]},m.key)})}),e.jsxs("div",{className:"mt-8 p-4 bg-red-50 border border-red-100 rounded-lg flex items-start gap-3",children:[e.jsx(_a,{className:"w-5 h-5 text-re-red shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-red-800",children:[e.jsx("p",{className:"font-semibold mb-1",children:"Impact of Manual Mode:"}),e.jsx("p",{children:'Turning OFF auto-assignment will ONLY affect new requests. Existing requests will retain their current participant mappings. You will need to use the "Add Participant" button in the worknotes or application details to grant access to stakeholders.'})]})]})]})]})})},dn={DD:"DD",DD_ZM:"DD-ZM",RBM:"RBM",ZBH:"ZBH",DD_LEAD:"DD Lead",DD_HEAD:"DD Head",NBH:"NBH",DD_ADMIN:"DD Admin",LEGAL_ADMIN:"Legal Admin",SUPER_ADMIN:"Super Admin",DD_AM:"DD AM",ASM:"ASM",FINANCE:"Finance",DEALER:"Dealer",ARCHITECTURE:"ARCHITECTURE",FDD:"FDD",CCO:"CCO",CEO:"CEO"},C2={ONBOARDING:{General:dn.DD_ADMIN,KYC:dn.DD_ADMIN,"Level 1 Interview":dn.RBM,"Level 2 Interview":dn.ZBH,"Level 3 Interview":dn.NBH,FDD:dn.FDD,"LOI Approval":`${dn.DD_HEAD},${dn.NBH}`,"LOA Approval":dn.NBH,"LOI Issue":dn.DD_ADMIN,"Architecture Team Assigned":dn.ARCHITECTURE,"Architecture Document Upload":dn.ARCHITECTURE,"Architecture Team Completion":dn.ARCHITECTURE,EOR:dn.DD_ADMIN,Inauguration:dn.DD_ADMIN},RESIGNATION:{Submission:dn.DEALER,"Regional Review":dn.RBM,"ZM Review":dn.DD_ZM,"ZBH Review":dn.ZBH,"Finance Review":dn.FINANCE,"DDL Review":dn.DD_LEAD,Approved:dn.DD_HEAD},RELOCATION:{Initiated:dn.DEALER,"ASM Review":dn.ASM,"ZM Review":dn.DD_ZM,"ZBH Review":dn.ZBH,Completed:dn.DD_HEAD},CONSTITUTIONAL_CHANGE:{Draft:dn.DEALER,"Legal Review":dn.LEGAL_ADMIN,Approved:dn.DD_HEAD},TERMINATION:{Hearing:dn.NBH,Review:dn.DD_LEAD,Closed:dn.DD_HEAD}},A2={async getPolicies(){var t,s;try{return(await Ee.getApprovalPolicies()).data}catch(n){return te.error(((s=(t=n==null?void 0:n.response)==null?void 0:t.data)==null?void 0:s.message)||"Failed to fetch approval policies"),{success:!1,data:[]}}},async savePolicy(t,s){var n,r,a;try{const i=await Ee.upsertApprovalPolicy(t,s);return(n=i==null?void 0:i.data)!=null&&n.success&&te.success("Approval policy updated"),i.data}catch(i){return te.error(((a=(r=i==null?void 0:i.response)==null?void 0:r.data)==null?void 0:a.message)||"Failed to update approval policy"),{success:!1}}}},PG=Object.values(dn).sort(),OG=[{label:"Onboarding",stages:[{label:"General Info",value:"ONBOARDING_GENERAL"},{label:"KYC Verification",value:"ONBOARDING_KYC"},{label:"Level 1 Interview",value:"LEVEL_1_INTERVIEW"},{label:"Level 2 Interview",value:"LEVEL_2_INTERVIEW"},{label:"Level 3 Interview",value:"LEVEL_3_INTERVIEW"},{label:"FDD Verification",value:"FDD_VERIFICATION"},{label:"LOI Approval",value:"LOI_APPROVAL"},{label:"LOA Approval",value:"LOA_APPROVAL"},{label:"Architecture Team Assigned",value:"ARCHITECTURE_ASSIGNMENT"},{label:"Architecture Doc Upload",value:"ARCHITECTURE_DOCUMENT_UPLOAD"},{label:"Statutory Verification",value:"STATUTORY_CHECK"},{label:"EOR Verification",value:"EOR_VERIFICATION"}]},{label:"Offboarding (Resignation)",stages:[{label:"Regional Review",value:"RESIGNATION_REGIONAL_REVIEW"},{label:"ZM Review",value:"RESIGNATION_ZM_REVIEW"},{label:"ZBH Review",value:"RESIGNATION_ZBH_REVIEW"},{label:"Finance Clearance",value:"RESIGNATION_FINANCE_REVIEW"},{label:"DDL Review",value:"RESIGNATION_DDL_REVIEW"},{label:"Final Approval",value:"RESIGNATION_APPROVED"}]},{label:"Termination",stages:[{label:"RBM Review",value:"TERMINATION_HEARING"},{label:"DDL Evaluation",value:"TERMINATION_REVIEW"},{label:"Legal Verification",value:"TERMINATION_LEGAL_VERIFICATION"},{label:"Final NBH Approval",value:"TERMINATION_CLOSED"}]},{label:"Relocation & CC",stages:[{label:"Relocation ASM Review",value:"RELOCATION_ASM_REVIEW"},{label:"Relocation Head Approval",value:"RELOCATION_COMPLETED"},{label:"CC Legal Review",value:"CONSTITUTIONAL_LEGAL_REVIEW"},{label:"CC Head Approval",value:"CONSTITUTIONAL_APPROVED"}]}];function Y_(){const[t,s]=g.useState(!1),[n,r]=g.useState([]),[a,i]=g.useState(!1),[o,d]=g.useState(!1),[m,f]=g.useState(!1),[p,h]=g.useState({stageCode:"",minApprovals:1,approvalMode:"MIN_N",requiredRoles:[],isActive:!0}),x=g.useMemo(()=>[...n].sort((j,b)=>j.stageCode.localeCompare(b.stageCode)),[n]),u=async()=>{s(!0);try{const j=await A2.getPolicies();j!=null&&j.success&&r(j.data||[])}finally{s(!1)}};g.useEffect(()=>{u()},[]);const N=()=>{d(!1),f(!1),h({stageCode:"",minApprovals:1,approvalMode:"MIN_N",requiredRoles:[],isActive:!0}),i(!0)},v=j=>{d(!0),f(!0),h({stageCode:j.stageCode,minApprovals:j.minApprovals||1,approvalMode:j.approvalMode||"MIN_N",requiredRoles:Array.isArray(j.requiredRoles)?[...j.requiredRoles]:[],isActive:j.isActive!==!1}),i(!0)},w=async()=>{if(!p.stageCode.trim())return;if(p.approvalMode==="ROLE_MANDATORY"&&p.requiredRoles.length>0&&p.minApprovals>p.requiredRoles.length){alert("In ROLE_MANDATORY mode, min approvals cannot exceed the number of required roles.");return}const j={minApprovals:Number(p.minApprovals)||1,approvalMode:p.approvalMode,requiredRoles:p.requiredRoles,isActive:p.isActive},b=p.stageCode.trim().toUpperCase().replace(/\s+/g,"_"),C=await A2.savePolicy(b,j);C!=null&&C.success&&(await u(),i(!1))};return e.jsxs("div",{className:"space-y-6 max-w-7xl mx-auto py-6 px-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-slate-900 flex items-center gap-2",children:[e.jsx(Bf,{className:"w-6 h-6 text-re-red"}),"Approval Policies"]}),e.jsx("p",{className:"text-slate-500",children:"Configure stage-level approvers, mode, and minimum approvals."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(se,{variant:"outline",onClick:u,disabled:t,children:[e.jsx(xr,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"Refresh"]}),e.jsxs(se,{className:"bg-re-red hover:bg-re-red-hover",onClick:N,children:[e.jsx(An,{className:"w-4 h-4 mr-2"}),"Add New Policy"]})]})]}),e.jsxs(Le,{className:"border-slate-200 overflow-hidden shadow-sm",children:[e.jsx(Qe,{className:"bg-slate-50 px-6 py-4 border-b",children:e.jsx(Je,{className:"text-lg font-semibold text-slate-800",children:"Configured Stages"})}),e.jsx(Fe,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim",children:e.jsxs(Ts,{children:[e.jsx(Ps,{className:"bg-slate-50/50",children:e.jsxs(it,{children:[e.jsx(fe,{className:"w-[200px]",children:"Stage Code"}),e.jsx(fe,{children:"Approval Mode"}),e.jsx(fe,{children:"Min Appr."}),e.jsx(fe,{className:"min-w-[300px]",children:"Required Roles"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{className:"text-right",children:"Actions"})]})}),e.jsx(Os,{children:x.map(j=>e.jsxs(it,{className:"hover:bg-slate-50/50 transition-colors",children:[e.jsx(ue,{className:"font-mono text-xs font-semibold text-slate-700",children:j.stageCode}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",className:"font-medium px-2 py-0.5 text-slate-600 border-slate-300 uppercase",children:j.approvalMode})}),e.jsx(ue,{children:e.jsx("span",{className:"font-medium text-slate-700 bg-slate-100 px-2.5 py-1 rounded-full text-xs",children:j.minApprovals})}),e.jsx(ue,{children:e.jsx("div",{className:"flex flex-wrap gap-1.5 py-1",children:(j.requiredRoles||[]).map(b=>e.jsx(Ce,{variant:"secondary",className:"bg-slate-100 text-slate-600 border-transparent hover:bg-slate-200 text-[11px] font-normal",children:b},b))})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${j.isActive?"bg-green-500 shadow-[0_0_8px_rgba(34,197,94,0.4)]":"bg-slate-400"}`}),e.jsx("span",{className:`text-xs font-medium ${j.isActive?"text-green-700":"text-slate-500"}`,children:j.isActive?"Active":"Inactive"})]})}),e.jsx(ue,{className:"text-right",children:e.jsxs(se,{size:"sm",variant:"ghost",className:"text-re-red hover:text-re-red-hover hover:bg-red-50 h-8 px-2",onClick:()=>v(j),children:[e.jsx(Cr,{className:"w-4 h-4 mr-1.5"}),"Edit"]})})]},j.stageCode))})]})})})]}),e.jsx(ds,{open:a,onOpenChange:i,children:e.jsxs(os,{className:"sm:max-w-[480px] overflow-visible",children:[e.jsxs(xs,{className:"gap-1 pb-2 border-b",children:[e.jsxs(ms,{className:"text-base flex items-center gap-2",children:[o?e.jsx(Cr,{className:"w-4 h-4 text-re-red"}):e.jsx(An,{className:"w-4 h-4 text-re-red"}),o?"Edit Policy":"Create New Policy"]}),e.jsx(bs,{className:"text-[11px]",children:o?`Update configuration for stage ${p.stageCode}.`:"Define approval requirements for a workflow stage."})]}),e.jsxs("div",{className:"grid gap-3 py-4",children:[e.jsxs("div",{className:"grid grid-cols-4 items-start gap-4",children:[e.jsx(de,{className:"text-right text-[11px] font-semibold text-slate-500 uppercase tracking-tight pt-2",children:"Stage"}),e.jsx("div",{className:"col-span-3 space-y-2",children:!m&&!o?e.jsx("div",{className:"space-y-2",children:e.jsxs(Dt,{value:p.stageCode,onValueChange:j=>{j==="CUSTOM"?(f(!0),h({...p,stageCode:""})):h({...p,stageCode:j})},children:[e.jsx(Et,{className:"w-full h-8 text-[11px] font-medium border-slate-200",children:e.jsx(Rt,{placeholder:"Select a workflow stage..."})}),e.jsxs(_t,{className:"max-h-[300px]",children:[OG.map(j=>e.jsxs(xS,{children:[e.jsx(T7,{className:"text-[10px] uppercase text-slate-400 font-bold bg-slate-50 px-2 py-1",children:j.label}),j.stages.map(b=>e.jsxs(Me,{value:b.value,className:"text-xs",children:[b.label," ",e.jsxs("span",{className:"text-[10px] text-slate-400 font-mono ml-1",children:["(",b.value,")"]})]},b.value))]},j.label)),e.jsxs(xS,{children:[e.jsx(K8,{}),e.jsx(Me,{value:"CUSTOM",className:"text-xs font-semibold text-re-red italic",children:"+ Enter Custom Stage Code"})]})]})]})}):e.jsxs("div",{className:"relative",children:[e.jsx(at,{className:"w-full font-mono text-xs h-8 pr-8",placeholder:"e.g. FNF_SETTLEMENT",disabled:o,value:p.stageCode,onChange:j=>h({...p,stageCode:j.target.value.toUpperCase()})}),!o&&e.jsx(ld,{className:"w-3 h-3 absolute right-2.5 top-2.5 text-slate-400 cursor-pointer hover:text-slate-600",onClick:()=>{f(!1),h({...p,stageCode:""})}})]})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(de,{className:"text-right text-[11px] font-semibold text-slate-500 uppercase tracking-tight",children:"Mode"}),e.jsx("div",{className:"col-span-3",children:e.jsxs(Dt,{value:p.approvalMode,onValueChange:j=>h({...p,approvalMode:j}),children:[e.jsx(Et,{className:"w-full h-8 text-[11px] font-medium border-slate-200",children:e.jsx(Rt,{placeholder:"Select mode"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"ALL",className:"text-xs",children:"ALL (Everyone must approve)"}),e.jsx(Me,{value:"MIN_N",className:"text-xs",children:"MIN_N (First N approvals count)"}),e.jsx(Me,{value:"ROLE_MANDATORY",className:"text-xs",children:"ROLE_MANDATORY (Hierarchy base)"})]})]})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(de,{className:"text-right text-[11px] font-semibold text-slate-500 uppercase tracking-tight",children:"Min Appr."}),e.jsx("div",{className:"col-span-3",children:e.jsx(at,{type:"number",min:1,value:p.minApprovals,onChange:j=>h({...p,minApprovals:Number(j.target.value||1)}),className:"w-20 h-8 text-xs border-slate-200"})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-start gap-4",children:[e.jsx(de,{className:"text-right text-[11px] font-semibold text-slate-500 uppercase tracking-tight pt-2",children:"Roles"}),e.jsxs("div",{className:"col-span-3 space-y-2",children:[e.jsxs(bb,{children:[e.jsx(jb,{asChild:!0,children:e.jsxs(se,{variant:"outline",size:"sm",className:"w-full justify-between h-8 text-[11px] text-slate-500 font-normal border-slate-200",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(An,{className:"w-3 h-3 text-re-red"}),e.jsx("span",{children:"Add Roles..."})]}),e.jsx(Ce,{variant:"secondary",className:"bg-red-50 text-re-red-hover border-transparent text-[9px] px-1 h-4",children:p.requiredRoles.length})]})}),e.jsxs(Nb,{className:"w-[280px] max-h-[250px] overflow-y-auto shadow-xl",align:"start",children:[e.jsx(G8,{className:"text-[10px] uppercase tracking-wider text-slate-400 font-bold px-2 py-1 border-b",children:"Available Roles"}),PG.map(j=>e.jsx(W8,{className:"text-xs",checked:p.requiredRoles.includes(j),onCheckedChange:b=>{h(b?{...p,requiredRoles:[...p.requiredRoles,j]}:{...p,requiredRoles:p.requiredRoles.filter(C=>C!==j)})},children:j},j))]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 min-h-[32px] p-2 rounded-sm bg-slate-50/50 border border-slate-100",children:[p.requiredRoles.map(j=>e.jsxs(Ce,{variant:"secondary",className:"bg-white text-slate-600 border-slate-200 text-[10px] font-normal flex items-center gap-1 py-0 px-1.5 h-5 transition-all",children:[j,e.jsx(ld,{className:"w-2.5 h-2.5 cursor-pointer text-slate-400 hover:text-red-500",onClick:()=>h({...p,requiredRoles:p.requiredRoles.filter(b=>b!==j)})})]},j)),p.requiredRoles.length===0&&e.jsx("span",{className:"text-slate-400 text-[10px] italic px-1 py-0.5",children:"No roles assigned."})]})]})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(de,{className:"text-right text-[11px] font-semibold text-slate-500 uppercase tracking-tight",children:"Status"}),e.jsx("div",{className:"col-span-3",children:e.jsxs(Dt,{value:p.isActive?"active":"inactive",onValueChange:j=>h({...p,isActive:j==="active"}),children:[e.jsx(Et,{className:"w-24 h-8 text-[11px] font-medium border-slate-200",children:e.jsx(Rt,{})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"active",className:"text-xs",children:"Active"}),e.jsx(Me,{value:"inactive",className:"text-xs",children:"Inactive"})]})]})})]})]}),e.jsxs(bn,{className:"gap-2 pt-3 border-t",children:[e.jsx(se,{variant:"outline",size:"sm",className:"text-xs h-8",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(se,{className:"bg-re-red hover:bg-re-red-hover h-8 text-xs font-semibold",onClick:w,children:[e.jsx(ml,{className:"w-3 h-3 mr-1.5"}),o?"Save Changes":"Create Policy"]})]})]})})]})}const LG=()=>{const{fetchInitialData:t,fetchAreas:s}=EV(),{asms:n,zonalManagerMappings:r,allStates:a,allDistricts:i,users:o,roles:d,loading:m}=In(Ye=>Ye.master),[f,p]=g.useState("hierarchy"),[h,x]=g.useState("all"),[u,N]=g.useState(!1),[v,w]=g.useState(!1),[j,b]=g.useState(!1),[C,S]=g.useState(!1),[R,_]=g.useState(!1),[A,E]=g.useState(null),[q,O]=g.useState(""),[D,P]=g.useState("active"),[L,$]=g.useState(""),[Y,Z]=g.useState(""),[W,U]=g.useState([]),[M,z]=g.useState([]),[T,I]=g.useState("DD-AM"),[B,G]=g.useState(!1),[K,H]=g.useState(null),[X,J]=g.useState(""),[ae,le]=g.useState("active"),[xe,ce]=g.useState(""),[ve,Pe]=g.useState([]),[et,kt]=g.useState(!1),[vt,ee]=g.useState(null),[ge,ye]=g.useState(!1),[Be,$e]=g.useState(null),[dt,st]=g.useState(""),[xt,Mt]=g.useState(""),[It,he]=g.useState(""),[pt,ht]=g.useState("none"),[_e,Vt]=g.useState(null),[Pt,_s]=g.useState(""),[Ys,Bs]=g.useState(""),[Ks,Qs]=g.useState(""),[Xs,$s]=g.useState(""),[Q,oe]=g.useState([]),[we,Oe]=g.useState(null),[ke,je]=g.useState('{"applicant_name": "John Doe"}'),[Ve,Ge]=g.useState(!1),[nt,Zt]=g.useState(null),[Jt,lt]=g.useState(null),[mt,Ds]=g.useState(""),[ss,Ae]=g.useState(""),[be,ut]=g.useState(""),[He,yt]=g.useState(""),[ft,es]=g.useState(""),[ts,Cs]=g.useState("active"),[Us,rn]=g.useState(""),[Js,an]=g.useState(1),[hn,De]=g.useState("all"),[bt,Te]=g.useState("all");g.useEffect(()=>{t()},[t]),g.useEffect(()=>{if(vt&&d.length>0){const Ye=d.find(Ot=>Ot.id===vt.id);Ye&&ee(Ye)}},[d,vt==null?void 0:vt.id]);const ct=g.useMemo(()=>{const Ye={};return[...n,...r].forEach(Ot=>{(Ot.areasManaged||Ot.districts||[]).forEach(rt=>{const Ft=typeof rt=="string"?rt:rt.id;Ye[Ft]||(Ye[Ft]=[]),Ye[Ft].includes(Ot.name)||Ye[Ft].push(Ot.name)})}),Ye},[n,r]),tt=g.useCallback((Ye,Ot)=>i.filter(St=>{var rt;return((rt=St.stateName)==null?void 0:rt.toUpperCase())===(Ye==null?void 0:Ye.toUpperCase())&&(!Ot||St.regionId===Ot)}).map(St=>({id:St.id,name:St.name})),[i]),jt=async()=>{var Ye,Ot;if(!q){te.error("Please select a DD-AM user");return}try{const St={userId:q,roleCode:T,districts:M,status:D},rt=await Is.saveASM(St);rt.success?(te.success(`DD Area Manager ${A?"updated":"assigned"} successfully`),N(!1),t()):te.error(rt.message||"Failed to save ASM")}catch(St){const rt=((Ot=(Ye=St==null?void 0:St.response)==null?void 0:Ye.data)==null?void 0:Ot.message)||(St==null?void 0:St.message)||"Failed to save ASM";te.error(rt)}},Ht=Ye=>{var Ot;E(Ye.id),O(Ye.id),P(Ye.status.toLowerCase()),$(Ye.zoneId),Z(Ye.regionId),U(Ye.stateNames||[]),z(((Ot=Ye.areasManaged)==null?void 0:Ot.map(St=>St.id))||[]),I("DD-AM"),N(!0)},zt=Ye=>{var Ot;H(Ye.id),J(Ye.id),le(((Ot=Ye.status)==null?void 0:Ot.toLowerCase())==="active"?"active":"inactive"),ce(Ye.zoneId||""),Pe(Ye.assignedRegionIds||[]),G(!0)},fs=async()=>{var Ye,Ot;if(!X||!xe){te.error("Manager and Zone are required");return}try{const St={userId:X,zoneId:xe,regionIds:ve,status:ae},rt=await Is.saveZonalManager(St);rt.success?(te.success(`Zonal Manager ${K?"updated":"assigned"} successfully`),G(!1),t()):te.error(rt.message||"Failed to save Zonal Manager")}catch(St){const rt=((Ot=(Ye=St==null?void 0:St.response)==null?void 0:Ye.data)==null?void 0:Ot.message)||(St==null?void 0:St.message)||"Failed to save Zonal Manager";te.error(rt)}},qt=async()=>{var Ye,Ot;try{const St={id:Be,name:dt,code:xt,description:It,managerId:pt==="none"?null:pt},rt=await Is.saveZone(St);rt.success?(te.success("Zone saved successfully"),w(!1),t()):te.error(rt.message||"Error saving zone")}catch(St){const rt=((Ot=(Ye=St==null?void 0:St.response)==null?void 0:Ye.data)==null?void 0:Ot.message)||(St==null?void 0:St.message)||"Error saving zone";te.error(rt)}},As=async()=>{var Ye,Ot;try{const St={..._e?{id:_e}:{},name:Pt,description:Ys,parentId:Ks,managerId:Xs,districts:Q,status:"Active"},rt=await Is.saveRegion(St);rt.success?(te.success("Region saved successfully"),b(!1),t()):te.error(rt.message||"Error saving region")}catch(St){const rt=((Ot=(Ye=St==null?void 0:St.response)==null?void 0:Ye.data)==null?void 0:Ot.message)||(St==null?void 0:St.message)||"Error saving region";te.error(rt)}},vs=async Ye=>{var Ot,St;try{if(!(we!=null&&we.id)){te.error("Open a template from the list to edit.");return}const rt=await Is.updateEmailTemplate(we.id,{...we,body:Ye});rt.success?(te.success("Template saved"),S(!1),t()):te.error(rt.message||"Error saving template")}catch(rt){const Ft=((St=(Ot=rt==null?void 0:rt.response)==null?void 0:Ot.data)==null?void 0:St.message)||(rt==null?void 0:rt.message)||"Error saving template";te.error(Ft)}},cs=async Ye=>{var Ot;Ge(!0);try{let St;try{St=JSON.parse(ke)}catch{te.error("Mock test data must be valid JSON");return}const rt=await Is.previewEmailTemplate({subject:we==null?void 0:we.subject,body:Ye,data:St});rt.success?Zt(rt.data):te.error(rt.message||"Preview failed")}catch(St){const rt=(Ot=St==null?void 0:St.response)==null?void 0:Ot.data,Ft=(rt==null?void 0:rt.error)||(rt==null?void 0:rt.message);te.error(Ft||(St==null?void 0:St.message)||"Preview failed")}finally{Ge(!1)}},mn=async(Ye,Ot)=>{var St,rt;try{const Ft=await Is.updateRole(Ye,{permissions:Ot});Ft.success?(te.success("Role permissions updated successfully"),kt(!1),t()):te.error(Ft.message||"Error saving role permissions")}catch(Ft){const jn=((rt=(St=Ft==null?void 0:Ft.response)==null?void 0:St.data)==null?void 0:rt.message)||(Ft==null?void 0:Ft.message)||"Error saving role permissions";te.error(jn)}},qs=Ye=>{ee(Ye),kt(!0)},ln=async Ye=>{var Ot,St;try{const rt={...Ye,permissionIds:[]},Ft=await Is.createRole(rt);if(Ft!=null&&Ft.success){te.success("Role created successfully"),t();return}throw new Error((Ft==null?void 0:Ft.message)||"Failed to create role")}catch(rt){const Ft=((St=(Ot=rt==null?void 0:rt.response)==null?void 0:Ot.data)==null?void 0:St.message)||(rt==null?void 0:rt.message)||"Failed to create role";throw te.error(Ft),rt}},fn=Ye=>{const Ot=i.find(St=>St.id===Ye.districtId);lt(Ye.id),Ds((Ot==null?void 0:Ot.stateId)||Ye.stateId||""),ut(Ye.city||""),Ae(Ye.districtId||""),yt(Ye.openFrom?new Date(Ye.openFrom).toISOString().split("T")[0]:""),es(Ye.openTo?new Date(Ye.openTo).toISOString().split("T")[0]:""),Cs(Ye.isOpportunity?"active":"inactive"),_(!0)},on=async()=>{try{if(!mt){te.error("Please select a state");return}if(!ss){te.error("Please select a district");return}const Ye=a.find(Ft=>Ft.id===mt),Ot=i.find(Ft=>Ft.id===ss),St={id:Jt,stateId:mt,stateName:(Ye==null?void 0:Ye.name)||(Ye==null?void 0:Ye.stateName)||"",districtId:ss,name:be||(Ot==null?void 0:Ot.name)||"New Location",city:be,status:ts,openFrom:He,openTo:ft,isOpportunity:ts==="active"};(await(Jt?Is.updateArea(Jt,St):Is.createArea(St))).success&&(te.success("Location saved"),_(!1),s({search:Us,page:Js}))}catch{te.error("Error saving location")}};return g.useEffect(()=>{const Ye=setTimeout(()=>{s({search:Us,page:Js,stateId:hn==="all"?void 0:hn,isOpportunity:bt==="all"?void 0:bt==="active"?"true":"false"})},500);return()=>clearTimeout(Ye)},[Us,Js,hn,bt,s]),e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 mb-2 font-bold text-2xl",children:"Master Configuration"}),e.jsx("p",{className:"text-slate-600",children:"Centralized governance for locations, roles, and operational policies"})]})}),m?e.jsxs("div",{className:"flex flex-col items-center justify-center p-20 space-y-4",children:[e.jsx("div",{className:"w-12 h-12 border-4 border-re-red border-t-transparent rounded-full animate-spin"}),e.jsx("p",{className:"text-slate-600 font-medium animate-pulse",children:"Synchronizing Global Settings..."})]}):e.jsxs(Bn,{value:f,onValueChange:p,className:"space-y-6",children:[e.jsxs($n,{className:"grid w-full grid-cols-8 h-auto sticky top-0 z-10 bg-white/80 backdrop-blur-sm border shadow-sm rounded-xl p-1",children:[e.jsxs(Wt,{value:"hierarchy",className:"flex items-center gap-2 py-3 rounded-lg data-[state=active]:bg-re-red data-[state=active]:text-white",children:[e.jsx(ku,{className:"w-4 h-4"})," Organisation"]}),e.jsxs(Wt,{value:"roles",className:"flex items-center gap-2 py-3 rounded-lg data-[state=active]:bg-re-red data-[state=active]:text-white",children:[e.jsx(hc,{className:"w-4 h-4"})," Roles"]}),e.jsxs(Wt,{value:"templates",className:"flex items-center gap-2 py-3 rounded-lg data-[state=active]:bg-re-red data-[state=active]:text-white",children:[e.jsx(Ur,{className:"w-4 h-4"})," Emails"]}),e.jsxs(Wt,{value:"locations",className:"flex items-center gap-2 py-3 rounded-lg data-[state=active]:bg-re-red data-[state=active]:text-white",children:[e.jsx(Vr,{className:"w-4 h-4"})," Locations"]}),e.jsxs(Wt,{value:"approvals",className:"flex items-center gap-2 py-3 rounded-lg data-[state=active]:bg-re-red data-[state=active]:text-white transition-all transform hover:scale-[1.02]",children:[e.jsx(XI,{className:"w-4 h-4"})," Approvals"]}),e.jsxs(Wt,{value:"documents",className:"flex items-center gap-2 py-3 rounded-lg data-[state=active]:bg-re-red data-[state=active]:text-white transition-all transform hover:scale-[1.02]",children:[e.jsx(Ns,{className:"w-4 h-4"})," Docs Config"]}),e.jsxs(Wt,{value:"governance",className:"flex items-center gap-2 py-3 rounded-lg data-[state=active]:bg-re-red data-[state=active]:text-white transition-all transform hover:scale-[1.02]",children:[e.jsx(Bf,{className:"w-4 h-4"})," Governance"]}),e.jsxs(Wt,{value:"settings",className:"flex items-center gap-2 py-3 rounded-lg data-[state=active]:bg-re-red data-[state=active]:text-white transition-all transform hover:scale-[1.02]",children:[e.jsx(Xc,{className:"w-4 h-4"})," App Settings"]})]}),e.jsxs(Ut,{value:"hierarchy",className:"space-y-8 animate-in fade-in slide-in-from-bottom-2 duration-300",children:[e.jsx(_V,{selectedZone:h,onZoneClick:Ye=>x(h===Ye?"all":Ye)}),e.jsx(TV,{selectedZone:h,onAddZone:()=>{$e(null),st(""),Mt(""),he(""),ht("none"),w(!0)},onEditZone:Ye=>{var Ot;$e(Ye.id),st(Ye.name),Mt(Ye.code),he(Ye.description),ht(((Ot=Ye.zonalBusinessHead)==null?void 0:Ot.id)||"none"),w(!0)}}),e.jsx(PV,{selectedZone:h,onAddRegion:()=>{Vt(null),_s(""),Qs(h==="all"?"":h),$s(""),oe([]),b(!0)},onEditRegion:Ye=>{var Ot,St;Vt(Ye.id),_s(Ye.name),Qs(Ye.zoneId),$s(((Ot=Ye.regionalManager)==null?void 0:Ot.id)||""),oe(((St=Ye.districts)==null?void 0:St.map(rt=>rt.id))||[]),b(!0)},onDeleteRegion:()=>te.error("Regional office deletion is restricted via portal")}),e.jsx(LV,{selectedZone:h,onAddZM:()=>{H(null),J(""),le("active"),ce(h==="all"?"":h),Pe([]),G(!0)},onEditZM:zt,onDeleteZM:()=>te.error("ZM deletion restricted")}),e.jsx(OV,{selectedZone:h,onAddASM:()=>{E(null),O(""),$(h==="all"?"":h),Z(""),U([]),z([]),I("DD-AM"),N(!0)},onEditASM:Ht,onDeleteASM:()=>te.error("ASM deletion restricted")}),e.jsx(zH,{}),e.jsx(IV,{userAssignedData:o.length>0?o:n})]}),e.jsx(Ut,{value:"roles",className:"animate-in fade-in duration-300",children:e.jsx(MV,{onAddRole:()=>ye(!0),onEditRole:qs})}),e.jsx(Ut,{value:"templates",className:"animate-in fade-in duration-300",children:e.jsx($V,{onEditTemplate:Ye=>{if(Oe(Ye),Ye.placeholders&&Array.isArray(Ye.placeholders)){const Ot=Ye.placeholders.reduce((St,rt)=>(St[rt]=`[${rt}]`,St),{});je(JSON.stringify(Ot,null,2))}else je("{}");S(!0)},onDeleteTemplate:()=>te.error("Delete Template restricted")})}),e.jsx(Ut,{value:"locations",className:"animate-in fade-in duration-300",children:e.jsx(qV,{states:a,stateFilter:hn,onStateFilterChange:Ye=>{De(Ye),an(1)},statusFilter:bt,onStatusFilterChange:Ye=>{Te(Ye),an(1)},onAddLocation:()=>{lt(null),Ds(""),ut(""),Ae(""),yt(""),es(""),Cs("active"),_(!0)},onEditLocation:fn,onDeleteLocation:Ye=>{window.confirm("Are you sure you want to delete this location?")&&Is.deleteArea(Ye).then(Ot=>{Ot.success&&(te.success("Location deleted"),s({search:Us,page:Js,stateId:hn==="all"?void 0:hn}))})},onSearch:Ye=>{rn(Ye),an(1)},onPageChange:an,searchTerm:Us})}),e.jsx(Ut,{value:"approvals",className:"animate-in fade-in duration-300",children:e.jsx(Y_,{})}),e.jsx(Ut,{value:"documents",className:"animate-in fade-in duration-300",children:e.jsx(_G,{})}),e.jsx(Ut,{value:"governance",className:"animate-in fade-in duration-300",children:e.jsx(TG,{})}),e.jsx(Ut,{value:"settings",className:"animate-in fade-in duration-300",children:e.jsx(EG,{})})]}),e.jsx(VH,{isOpen:v,onOpenChange:w,editingZoneId:Be,zoneName:dt,setZoneName:st,zoneCode:xt,setZoneCode:Mt,zoneDescription:It,setZoneDescription:he,zonalBusinessHeadId:pt,setZonalBusinessHeadId:ht,onSave:qt,userAssignedData:o.length>0?o.map(Ye=>{var Ot,St;return{...Ye,name:Ye.fullName||Ye.name,role:(Ot=Ye.role)==null?void 0:Ot.roleName,roleCode:(St=Ye.role)==null?void 0:St.roleCode,allRoles:Ye.allRoles}}):n}),e.jsx(HH,{isOpen:j,onOpenChange:b,editingRegionId:_e,regionName:Pt,setRegionName:_s,regionDescription:Ys,setRegionDescription:Bs,selectedRegionZone:Ks,setSelectedRegionZone:Qs,regionalManagerId:Xs,setRegionalManagerId:$s,selectedRegionStates:Q,setSelectedRegionStates:oe,onSave:As,userAssignedData:o.length>0?o.map(Ye=>{var Ot,St;return{...Ye,name:Ye.fullName||Ye.name,role:(Ot=Ye.role)==null?void 0:Ot.roleName,roleCode:(St=Ye.role)==null?void 0:St.roleCode,allRoles:Ye.allRoles}}):n}),e.jsx(uH,{isOpen:u,onOpenChange:N,editingASMId:A,asmManagerId:q,setAsmManagerId:O,asmStatus:D,setAsmStatus:P,selectedASMZone:L,setSelectedASMZone:$,selectedASMRegion:Y,setSelectedASMRegion:Z,selectedASMStates:W,setSelectedASMStates:U,selectedASMDistricts:M,setSelectedASMDistricts:z,onSave:jt,asmRoleCode:T,setAsmRoleCode:I,userAssignedData:o.length>0?o.map(Ye=>{var Ot,St;return{...Ye,name:Ye.fullName||Ye.name,role:(Ot=Ye.role)==null?void 0:Ot.roleName,roleCode:(St=Ye.role)==null?void 0:St.roleCode,allRoles:Ye.allRoles}}):n,districtsAssignedToOthers:ct,getDistrictsForSelectedState:Ye=>tt(Ye,Y||void 0)}),e.jsx(UH,{isOpen:B,onOpenChange:G,editingZMId:K,zmManagerId:X,setZmManagerId:J,zmStatus:ae,setZmStatus:le,selectedZone:xe,setSelectedZone:ce,selectedRegions:ve,setSelectedRegions:Pe,onSave:fs,userAssignedData:o.length>0?o.map(Ye=>{var Ot,St;return{...Ye,name:Ye.fullName||Ye.name,role:(Ot=Ye.role)==null?void 0:Ot.roleName,roleCode:(St=Ye.role)==null?void 0:St.roleCode,allRoles:Ye.allRoles}}):n}),e.jsx(DG,{isOpen:C,onOpenChange:S,editingTemplate:we,setEditingTemplate:Oe,testDataInput:ke,setTestDataInput:je,previewLoading:Ve,handlePreviewTemplate:cs,previewContent:nt,handleSaveTemplate:vs}),e.jsx(RG,{isOpen:R,onOpenChange:_,editingLocationId:Jt,locationState:mt,setLocationState:Ds,locationDistrict:ss,setLocationDistrict:Ae,locationCity:be,setLocationCity:ut,locationActiveFrom:He,setLocationActiveFrom:yt,locationActiveTo:ft,setLocationActiveTo:es,locationStatus:ts,setLocationStatus:Cs,allStates:a,allDistricts:i,onSave:on}),e.jsx(FV,{isOpen:et,onOpenChange:kt,role:vt,onSave:mn}),e.jsx(BV,{isOpen:ge,onOpenChange:ye,onSave:ln})]})},Dm={extractErrorMessage(t,s){var n,r,a;return((r=(n=t==null?void 0:t.response)==null?void 0:n.data)==null?void 0:r.message)||((a=t==null?void 0:t.data)==null?void 0:a.message)||(t==null?void 0:t.message)||s},async getAllUsers(t){var s,n;try{return(await Ee.getUsers(t)).data}catch(r){return console.error("Error fetching users:",r),te.error(((n=(s=r.response)==null?void 0:s.data)==null?void 0:n.message)||"Failed to fetch users"),{success:!1,data:[]}}},async createUser(t){var s;try{const n=await Ee.createUser(t);return n.ok&&((s=n.data)!=null&&s.success),n.data}catch(n){console.error("Error creating user:",n);const r=this.extractErrorMessage(n,"Failed to create user");return te.error(r),{success:!1,message:r}}},async updateUser(t,s){var n,r,a;try{const i=await Ee.updateUser(t,s);return i.ok&&((n=i.data)!=null&&n.success)&&te.success(i.data.message||"User updated successfully"),i.data}catch(i){return console.error("Error updating user:",i),te.error(((a=(r=i.response)==null?void 0:r.data)==null?void 0:a.message)||"Failed to update user"),{success:!1}}},async updateUserStatus(t,s,n){var r,a,i;try{const o=await Ee.updateUserStatus(t,{status:s,isActive:n});return o.ok&&((r=o.data)!=null&&r.success)&&te.success(o.data.message||"User status updated"),o.data}catch(o){return console.error("Error updating status:",o),te.error(((i=(a=o.response)==null?void 0:a.data)==null?void 0:i.message)||"Failed to update status"),{success:!1}}}};function IG(){const t=(W,U)=>{if(!(W!=null&&W.parents)||!Array.isArray(W.parents))return"";const M=W.parents.find(z=>(z==null?void 0:z.type)===U);return(M==null?void 0:M.id)||""},s=(W,U)=>W?Array.isArray(W[U])?W[U]:Array.isArray(W.data)?W.data:[]:[],[n,r]=g.useState([]),[a,i]=g.useState([]),[o,d]=g.useState([]),[m,f]=g.useState([]),[p,h]=g.useState([]),[x,u]=g.useState([]),[N,v]=g.useState(!0),[w,j]=g.useState(""),[b,C]=g.useState("all"),[S,R]=g.useState("all"),[_,A]=g.useState(!1),[E,q]=g.useState(null),[O,D]=g.useState({fullName:"",email:"",roleCode:"",status:"active",isActive:!0,mobileNumber:"",department:"",designation:"",employeeId:"",zoneId:"",regionId:"",stateId:"",districtId:""});g.useEffect(()=>{P()},[]);const P=async()=>{v(!0);try{const[W,U,M,z]=await Promise.all([Dm.getAllUsers(),Is.getRoles(),Is.getZones(),Is.getRegions()]);W.success&&r(W.data),U.success&&i(U.data),M.success&&d(M.data),z.success&&f(z.data)}catch{te.error("Failed to load user management data")}finally{v(!1)}};g.useEffect(()=>{O.zoneId?Is.getStates(O.zoneId).then(W=>{W&&W.success&&h(s(W,"states"))}):h([])},[O.zoneId]),g.useEffect(()=>{O.stateId?Is.getDistricts(O.stateId).then(W=>{W&&W.success&&u(s(W,"districts"))}):u([])},[O.stateId]),g.useEffect(()=>{},[O.districtId]);const L=W=>{const U=W.location,M=U==null?void 0:U.type,z=W.zoneId||(M==="zone"?U==null?void 0:U.id:t(U,"zone")),T=W.regionId||(M==="region"?U==null?void 0:U.id:t(U,"region")),I=W.stateId||(M==="state"?U==null?void 0:U.id:t(U,"state")),B=W.districtId||(M==="district"?U==null?void 0:U.id:t(U,"district"));q(W),D({fullName:W.fullName||"",email:W.email||"",roleCode:W.roleCode||"",status:W.status||"active",isActive:W.isActive??!0,mobileNumber:W.mobileNumber||"",department:W.department||"",designation:W.designation||"",employeeId:W.employeeId||"",zoneId:z||"",regionId:T||"",stateId:I||"",districtId:B||""}),A(!0)},$=async()=>{var W,U;if(!O.fullName||!O.email||!O.roleCode){te.error("Please fill in all required fields");return}try{const M=O.districtId||O.stateId||O.regionId||O.zoneId||null,z={...O,locationId:M};if(E)(await Dm.updateUser(E.id,z)).success&&(A(!1),P());else{const T=await Dm.createUser(z);T.success?(te.success("User created successfully"),D({fullName:"",email:"",roleCode:"",status:"active",isActive:!0,mobileNumber:"",department:"",designation:"",employeeId:"",zoneId:"",regionId:"",stateId:"",districtId:""}),A(!1),P()):te.error(T.message||"Failed to create user")}}catch(M){const z=((U=(W=M==null?void 0:M.response)==null?void 0:W.data)==null?void 0:U.message)||(M==null?void 0:M.message)||"Operation failed";te.error(z)}},Y=async W=>{const U=W.status==="active"?"inactive":"active",M=!W.isActive;(await Dm.updateUserStatus(W.id,U,M)).success&&P()},Z=n.filter(W=>{var T,I,B;const U=((T=W.fullName)==null?void 0:T.toLowerCase().includes(w.toLowerCase()))||((I=W.email)==null?void 0:I.toLowerCase().includes(w.toLowerCase()))||((B=W.employeeId)==null?void 0:B.toLowerCase().includes(w.toLowerCase())),M=b==="all"||W.roleCode===b,z=S==="all"||W.status===S;return U&&M&&z});return e.jsxs("div",{className:"space-y-6 max-w-7xl mx-auto py-6 px-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-slate-900 flex items-center gap-2",children:[e.jsx(Ra,{className:"w-6 h-6 text-re-red"}),"User Management"]}),e.jsx("p",{className:"text-slate-500",children:"Manage system users, roles, and access permissions."})]}),e.jsxs(se,{onClick:()=>{q(null),D({fullName:"",email:"",roleCode:"",status:"active",isActive:!0,mobileNumber:"",department:"",designation:"",employeeId:"",zoneId:"",regionId:"",stateId:"",districtId:""}),A(!0)},className:"bg-re-red hover:bg-re-red-hover text-white shrink-0",children:[e.jsx(nb,{className:"w-4 h-4 mr-2"}),"Add New User"]})]}),e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{className:"p-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(at,{placeholder:"Search by name, email, ID...",className:"pl-10",value:w,onChange:W=>j(W.target.value)})]}),e.jsxs(Dt,{value:b,onValueChange:C,children:[e.jsxs(Et,{children:[e.jsx(eb,{className:"w-4 h-4 mr-2 text-slate-400"}),e.jsx(Rt,{placeholder:"Filter by Role"})]}),e.jsxs(_t,{children:[e.jsx(Me,{value:"all",children:"All Roles"}),a.map(W=>e.jsx(Me,{value:W.roleCode,children:W.roleName},W.id))]})]}),e.jsxs(Dt,{value:S,onValueChange:R,children:[e.jsx(Et,{children:e.jsx(Rt,{placeholder:"Filter by Status"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"all",children:"All Status"}),e.jsx(Me,{value:"active",children:"Active"}),e.jsx(Me,{value:"inactive",children:"Inactive"})]})]}),e.jsxs(se,{variant:"outline",onClick:P,disabled:N,children:[e.jsx(xr,{className:`w-4 h-4 mr-2 ${N?"animate-spin":""}`}),"Refresh"]})]})})}),e.jsx(Le,{className:"border-slate-200 overflow-hidden",children:e.jsx(Fe,{className:"p-0",children:e.jsxs(Ts,{children:[e.jsx(Ps,{className:"bg-slate-50",children:e.jsxs(it,{children:[e.jsx(fe,{children:"User Information"}),e.jsx(fe,{children:"Geographical Mapping"}),e.jsx(fe,{children:"Account Details"}),e.jsx(fe,{children:"Role & Department"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{className:"text-right",children:"Actions"})]})}),e.jsx(Os,{children:N?e.jsx(it,{children:e.jsx(ue,{colSpan:5,className:"h-40 text-center",children:e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-2 text-slate-500",children:[e.jsx(xr,{className:"w-8 h-8 animate-spin"}),e.jsx("p",{children:"Loading users..."})]})})}):Z.length===0?e.jsx(it,{children:e.jsxs(ue,{colSpan:5,className:"h-40 text-center text-slate-500",children:[e.jsx(Ra,{className:"w-12 h-12 mx-auto mb-2 opacity-20"}),"No users found matching your criteria."]})}):Z.map(W=>{var U,M,z,T;return e.jsxs(it,{className:"hover:bg-slate-50/50",children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-red-100 text-re-red-hover flex items-center justify-center font-bold",children:((U=W.fullName)==null?void 0:U.charAt(0))||((M=W.email)==null?void 0:M.charAt(0))}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-slate-900",children:W.fullName}),e.jsxs("div",{className:"text-xs text-slate-500 flex items-center gap-1",children:[e.jsx(Ur,{className:"w-3 h-3"}),W.email]})]})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(Ce,{variant:"outline",className:"bg-blue-50 text-blue-700 border-blue-200",children:["Location: ",((z=W.location)==null?void 0:z.name)||"N/A"]})}),e.jsxs("div",{className:"text-xs text-slate-500",children:["Type: ",(T=W.location)!=null&&T.type?W.location.type.toUpperCase():"N/A"]})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-sm font-medium",children:["ID: ",W.employeeId||"N/A"]}),e.jsxs("div",{className:"text-xs text-slate-500 flex items-center gap-1",children:[e.jsx(tb,{className:"w-3 h-3"}),W.mobileNumber||"No phone"]})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Ce,{variant:"outline",className:"bg-purple-50 text-purple-700 border-purple-200",children:[e.jsx(hc,{className:"w-3 h-3 mr-1"}),W.roleCode]}),e.jsx("div",{className:"text-xs text-slate-500",children:W.department||"No department"})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex flex-col items-start gap-1",children:e.jsxs(Ce,{variant:W.status==="active"?"default":"destructive",className:`text-xs ${W.status==="active"?"bg-green-600 hover:bg-green-700":""}`,children:[W.status==="active"?e.jsx(un,{className:"w-3 h-3 mr-1"}):e.jsx(mi,{className:"w-3 h-3 mr-1"}),W.status]})}),e.jsx(bp,{checked:W.isActive,onCheckedChange:()=>Y(W)})]})}),e.jsx(ue,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(se,{variant:"ghost",size:"icon",onClick:()=>L(W),children:e.jsx(Cr,{className:"w-4 h-4 text-slate-400 hover:text-re-red"})}),e.jsx(se,{variant:"ghost",size:"icon",children:e.jsx(ar,{className:"w-4 h-4 text-slate-400 hover:text-red-600"})})]})})]},W.id)})})]})})}),e.jsx(ds,{open:_,onOpenChange:A,children:e.jsxs(os,{className:"max-w-2xl bg-white",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:E?"Edit User":"Add New User"}),e.jsx(bs,{children:"Modify user profiles and system access settings."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"fullName",children:"Full Name *"}),e.jsx(at,{id:"fullName",value:O.fullName,onChange:W=>D({...O,fullName:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"email",children:"Email Address *"}),e.jsx(at,{id:"email",type:"email",value:O.email,onChange:W=>D({...O,email:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"employeeId",children:"Employee ID"}),e.jsx(at,{id:"employeeId",value:O.employeeId,onChange:W=>D({...O,employeeId:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"roleCode",children:"Role *"}),e.jsxs(Dt,{value:O.roleCode,onValueChange:W=>D({...O,roleCode:W}),children:[e.jsx(Et,{id:"roleCode",children:e.jsx(Rt,{placeholder:"Select a role"})}),e.jsx(_t,{children:a.map(W=>e.jsx(Me,{value:W.roleCode,children:W.roleName},W.id))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"department",children:"Department"}),e.jsx(at,{id:"department",value:O.department,onChange:W=>D({...O,department:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"designation",children:"Designation"}),e.jsx(at,{id:"designation",value:O.designation,onChange:W=>D({...O,designation:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"mobileNumber",children:"Mobile Number"}),e.jsx(at,{id:"mobileNumber",value:O.mobileNumber,onChange:W=>D({...O,mobileNumber:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"status",children:"Account Status"}),e.jsxs(Dt,{value:O.status,onValueChange:W=>D({...O,status:W}),children:[e.jsx(Et,{id:"status",children:e.jsx(Rt,{placeholder:"Select status"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"active",children:"Active"}),e.jsx(Me,{value:"inactive",children:"Inactive"})]})]})]}),e.jsxs("div",{className:"col-span-2 border-t pt-4 mt-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-slate-900 mb-1",children:"Geographical Assignments"}),e.jsx("p",{className:"text-xs text-slate-500 mb-4",children:"Optional: you can create users without territory mapping and assign later."}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"zoneId",children:"Zone (Top Level)"}),e.jsxs(Dt,{value:O.zoneId,onValueChange:W=>D({...O,zoneId:W,regionId:"",stateId:"",districtId:""}),children:[e.jsx(Et,{id:"zoneId",children:e.jsx(Rt,{placeholder:"Select Zone"})}),e.jsx(_t,{children:o.map(W=>e.jsx(Me,{value:W.id,children:W.name||W.zoneName},W.id))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"regionId",children:"Region"}),e.jsxs(Dt,{value:O.regionId,onValueChange:W=>D({...O,regionId:W}),disabled:!O.zoneId,children:[e.jsx(Et,{id:"regionId",children:e.jsx(Rt,{placeholder:"Select Region"})}),e.jsx(_t,{children:m.filter(W=>W.parents&&W.parents.some(U=>U.id===O.zoneId)||W.zoneId===O.zoneId).map(W=>e.jsx(Me,{value:W.id,children:W.name||W.regionName},W.id))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"stateId",children:"State"}),e.jsxs(Dt,{value:O.stateId,onValueChange:W=>D({...O,stateId:W,districtId:""}),disabled:!O.zoneId,children:[e.jsx(Et,{id:"stateId",children:e.jsx(Rt,{placeholder:"Select State"})}),e.jsx(_t,{children:p.filter(W=>W.parents&&W.parents.some(U=>U.id===O.zoneId)||W.zoneId===O.zoneId).map(W=>e.jsx(Me,{value:W.id,children:W.name||W.stateName},W.id))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"districtId",children:"District"}),e.jsxs(Dt,{value:O.districtId,onValueChange:W=>D({...O,districtId:W}),disabled:!O.stateId,children:[e.jsx(Et,{id:"districtId",children:e.jsx(Rt,{placeholder:"Select District"})}),e.jsx(_t,{children:x.filter(W=>W.parents&&W.parents.some(U=>U.id===O.stateId)||W.stateId===O.stateId).map(W=>e.jsx(Me,{value:W.id,children:W.name||W.districtName},W.id))})]})]})]})]})]}),e.jsxs(bn,{className:"bg-slate-50 -mx-6 -mb-6 p-4 rounded-b-lg",children:[e.jsx(se,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),e.jsx(se,{className:"bg-re-red hover:bg-re-red-hover text-white",onClick:$,children:E?"Save Changes":"Create User"})]})]})})]})}const Ty={healthy:"025% elapsed",warning:"2675% elapsed",critical:"7699% elapsed",breached:"Breached"},Z_={healthy:"bg-emerald-100 text-emerald-800 border-emerald-200",warning:"bg-red-50 text-red-800 border-red-200",critical:"bg-orange-100 text-orange-800 border-orange-200",breached:"bg-red-100 text-red-800 border-red-200"},MG=["ALL","ONBOARDING","TERMINATION","RESIGNATION","RELOCATION","CONSTITUTIONAL","FNF"];function FG({bucket:t}){return e.jsx(Ce,{variant:"outline",className:`text-[10px] font-semibold ${Z_[t]}`,children:Ty[t]})}function BG({percent:t,bucket:s}){const n=s==="breached"?"bg-red-500":s==="critical"?"bg-orange-500":s==="warning"?"bg-red-500":"bg-emerald-500",r=Math.min(t,100);return e.jsxs("div",{className:"min-w-[100px]",children:[e.jsx("div",{className:"h-1.5 w-full bg-slate-100 rounded-full overflow-hidden mb-1",children:e.jsx("div",{className:`h-full rounded-full ${n}`,style:{width:`${r}%`}})}),e.jsxs("span",{className:"text-[10px] text-slate-500",children:[t,"% of TAT"]}),e.jsx("div",{className:"mt-1",children:e.jsx(FG,{bucket:s})})]})}function Tv({items:t,emptyMessage:s}){return t.length===0?e.jsx("p",{className:"text-sm text-slate-500 py-8 text-center",children:s}):e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Case"}),e.jsx(fe,{children:"Module"}),e.jsx(fe,{children:"Stage"}),e.jsx(fe,{children:"Owner"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Time"}),e.jsx(fe,{className:"w-10"})]})}),e.jsx(Os,{children:t.map(n=>e.jsxs(it,{className:n.bucket==="breached"?"bg-red-50/40":void 0,children:[e.jsx(ue,{className:"font-medium text-slate-900",children:n.caseRef}),e.jsx(ue,{children:e.jsx(Ce,{variant:"secondary",className:"text-[10px]",children:n.module})}),e.jsx(ue,{className:"text-slate-700 max-w-[200px] truncate",title:n.stageName,children:n.stageName}),e.jsx(ue,{className:"text-slate-600 text-xs",children:n.ownerRole}),e.jsx(ue,{children:e.jsx(BG,{percent:n.percentUsed,bucket:n.bucket})}),e.jsxs(ue,{className:"text-xs text-slate-600",children:[e.jsx("div",{children:n.remainingLabel}),e.jsxs("span",{className:"text-[10px] text-slate-400 block",children:["Due ",new Date(n.deadline).toLocaleString()]})]}),e.jsx(ue,{children:e.jsx("a",{href:n.link,target:"_blank",rel:"noopener noreferrer",className:"text-re-red hover:text-red-800",title:"Open case",children:e.jsx(lk,{className:"w-4 h-4"})})})]},n.trackingId))})]})}const $G=()=>{var A,E,q,O,D,P,L,$,Y;const[t,s]=g.useState(null),[n,r]=g.useState(!0),[a,i]=g.useState("ALL"),[o,d]=g.useState("queue"),[m,f]=g.useState(!1),[p,h]=g.useState(null),[x,u]=g.useState({}),[N,v]=g.useState(!1),w=g.useCallback(async()=>{r(!0);try{const Z=await Zl.getOperationsDashboard({module:a==="ALL"?void 0:a,mineOnly:m});Z!=null&&Z.success?s(Z.data):te.error("Failed to load SLA monitor")}catch{te.error("Failed to load SLA monitor")}finally{r(!1)}},[a,o,m]);g.useEffect(()=>{w()},[w]),g.useEffect(()=>{Zl.getQuestionnaireReminderSettings().then(Z=>{Z!=null&&Z.success&&Z.data&&(h(Z.data),u(Z.data))}).catch(()=>{})},[]);const j=async()=>{v(!0);try{const Z=await Zl.updateQuestionnaireReminderSettings(x);Z!=null&&Z.success&&(h(Z.data),u(Z.data),te.success("Questionnaire reminder settings saved"))}catch{te.error("Failed to save settings")}finally{v(!1)}},b=t==null?void 0:t.summary,C=t==null?void 0:t.analytics,S=(t==null?void 0:t.activeQueue)??[],R=S.filter(Z=>Z.bucket==="breached"),_=S.filter(Z=>Z.bucket==="warning"||Z.bucket==="critical");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(ad,{className:"w-5 h-5 text-re-red"}),"SLA Operations Monitor"]}),e.jsxs("p",{className:"text-sm text-slate-500",children:["Live queue, aging buckets, breaches, and scheduler health",(t==null?void 0:t.generatedAt)&&e.jsxs("span",{className:"ml-2 text-slate-400",children:["· Updated ",new Date(t.generatedAt).toLocaleTimeString()]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mr-2",children:[e.jsx(Ln,{id:"sla-mine-only",checked:m,onCheckedChange:Z=>f(!!Z)}),e.jsx(de,{htmlFor:"sla-mine-only",className:"text-sm cursor-pointer",children:"My queue only"})]}),e.jsxs(Dt,{value:a,onValueChange:i,children:[e.jsx(Et,{className:"w-[180px] h-9",children:e.jsx(Rt,{placeholder:"Module"})}),e.jsx(_t,{children:MG.map(Z=>e.jsx(Me,{value:Z,children:Z==="ALL"?"All modules":Z},Z))})]}),e.jsxs(se,{variant:"outline",size:"sm",onClick:()=>Zl.exportOperationsCsv({module:a==="ALL"?void 0:a,mineOnly:m}).catch(()=>te.error("Export failed")),children:[e.jsx(ji,{className:"w-4 h-4 mr-1"}),"Export CSV"]}),e.jsxs(se,{variant:"outline",size:"sm",onClick:w,disabled:n,children:[e.jsx(xr,{className:`w-4 h-4 mr-1 ${n?"animate-spin":""}`}),"Refresh"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-3",children:[e.jsx(du,{label:"In queue",value:(b==null?void 0:b.activeCount)??"—",icon:e.jsx(vn,{className:"w-4 h-4 text-blue-600"})}),e.jsx(du,{label:"Breached",value:(b==null?void 0:b.breachedCount)??"—",icon:e.jsx(Ha,{className:"w-4 h-4 text-red-600"}),highlight:"red"}),e.jsx(du,{label:"Due soon",value:(b==null?void 0:b.dueSoonCount)??"—",icon:e.jsx(nM,{className:"w-4 h-4 text-re-red"})}),e.jsx(du,{label:"On track",value:(b==null?void 0:b.onTrackCount)??"—",icon:e.jsx(Zn,{className:"w-4 h-4 text-emerald-600"})}),e.jsx(du,{label:"Open breaches",value:(b==null?void 0:b.openBreachesCount)??"—",icon:e.jsx(Ha,{className:"w-4 h-4 text-re-red"})})]}),C&&e.jsxs(Le,{className:"border-slate-200",children:[e.jsxs(Qe,{className:"pb-2",children:[e.jsxs(Je,{className:"text-sm flex items-center gap-2",children:[e.jsx(OI,{className:"w-4 h-4 text-re-red"}),"Analytics (last ",C.periodDays," days)"]}),e.jsx(Xt,{children:"Breach rate, resolution time, and top delayed stages"})]}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(Rm,{label:"Tracks started",value:C.tracksStarted}),e.jsx(Rm,{label:"Breach rate",value:`${C.breachRatePercent}%`,highlight:!0}),e.jsx(Rm,{label:"Avg resolution",value:C.avgResolutionHours!=null?`${C.avgResolutionHours}h`:"—"}),e.jsx(Rm,{label:"Completed tracks",value:C.completedTracks})]}),C.topDelayedStages.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase mb-2",children:"Top delayed stages"}),e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Stage"}),e.jsx(fe,{children:"Breaches (30d)"}),e.jsx(fe,{children:"Active breached"})]})}),e.jsx(Os,{children:C.topDelayedStages.map(Z=>e.jsxs(it,{children:[e.jsx(ue,{className:"font-medium",children:Z.stageName}),e.jsx(ue,{children:Z.breachCount}),e.jsx(ue,{children:Z.currentlyBreached})]},Z.stageName))})]})]}),Object.keys(C.breachesByModule).length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(C.breachesByModule).map(([Z,W])=>e.jsxs(Ce,{variant:"outline",children:[Z,": ",W," breaches"]},Z))})]})]}),b&&e.jsxs(Le,{className:"border-slate-200",children:[e.jsxs(Qe,{className:"pb-2",children:[e.jsx(Je,{className:"text-sm",children:"Aging buckets"}),e.jsx(Xt,{children:"Percent of configured TAT elapsed"})]}),e.jsxs(Fe,{className:"flex flex-wrap gap-2",children:[Object.keys(Ty).map(Z=>e.jsxs(Ce,{variant:"outline",className:`px-3 py-1 ${Z_[Z]}`,children:[Ty[Z],": ",b.buckets[Z]??0]},Z)),b.tracksWithoutConfig>0&&e.jsxs(Ce,{variant:"outline",className:"bg-slate-100 text-slate-600",children:["No config match: ",b.tracksWithoutConfig]})]})]}),e.jsxs(Bn,{value:o,onValueChange:d,children:[e.jsxs($n,{className:"bg-slate-100",children:[e.jsxs(Wt,{value:"queue",children:["Active queue (",S.length,")"]}),e.jsxs(Wt,{value:"breached",children:["Breached (",R.length,")"]}),e.jsxs(Wt,{value:"due",children:["Due soon (",_.length,")"]}),e.jsxs(Wt,{value:"breach-log",children:["Open breaches (",((A=t==null?void 0:t.breaches)==null?void 0:A.length)??0,")"]}),e.jsx(Wt,{value:"schedulers",children:"Schedulers"})]}),e.jsx(Ut,{value:"queue",className:"mt-4",children:e.jsx(Le,{children:e.jsx(Fe,{className:"pt-4",children:e.jsx(Tv,{items:S,emptyMessage:"No active SLA timers in queue."})})})}),e.jsx(Ut,{value:"breached",className:"mt-4",children:e.jsx(Le,{children:e.jsx(Fe,{className:"pt-4",children:e.jsx(Tv,{items:R,emptyMessage:"No breached items — all active SLAs are within TAT."})})})}),e.jsx(Ut,{value:"due",className:"mt-4",children:e.jsx(Le,{children:e.jsx(Fe,{className:"pt-4",children:e.jsx(Tv,{items:_,emptyMessage:"Nothing in the 2699% window right now."})})})}),e.jsx(Ut,{value:"breach-log",className:"mt-4",children:e.jsx(Le,{children:e.jsx(Fe,{className:"pt-4",children:(E=t==null?void 0:t.breaches)!=null&&E.length?e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Case"}),e.jsx(fe,{children:"Module"}),e.jsx(fe,{children:"Stage"}),e.jsx(fe,{children:"Breached at"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{})]})}),e.jsx(Os,{children:t.breaches.map(Z=>e.jsxs(it,{children:[e.jsx(ue,{className:"font-medium",children:Z.caseRef}),e.jsx(ue,{children:e.jsx(Ce,{variant:"secondary",className:"text-[10px]",children:Z.module})}),e.jsx(ue,{className:"truncate max-w-[200px]",children:Z.stageName}),e.jsx(ue,{className:"text-xs",children:new Date(Z.breachedAt).toLocaleString()}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",children:Z.status})}),e.jsx(ue,{children:e.jsx("a",{href:Z.link,target:"_blank",rel:"noopener noreferrer",className:"text-re-red",children:e.jsx(lk,{className:"w-4 h-4"})})})]},Z.id))})]}):e.jsx("p",{className:"text-sm text-slate-500 py-8 text-center",children:"No open breach records."})})})}),e.jsx(Ut,{value:"schedulers",className:"mt-4",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsxs(Je,{className:"text-sm flex items-center gap-2",children:[e.jsx(Ur,{className:"w-4 h-4"}),"Prospect questionnaire reminders"]}),e.jsxs(Xt,{children:["Email/WhatsApp to applicants in Questionnaire Pending (not internal SLA)",(p==null?void 0:p.source)&&e.jsxs("span",{className:"block text-slate-400",children:["Source: ",p.source]})]})]}),e.jsxs(Fe,{className:"space-y-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ln,{id:"q-enabled",checked:!!x.enabled,onCheckedChange:Z=>u(W=>({...W,enabled:!!Z}))}),e.jsx(de,{htmlFor:"q-enabled",children:"Scheduler enabled"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-xs",children:"First after (days)"}),e.jsx(at,{type:"number",min:1,value:x.firstAfterDays??"",onChange:Z=>u(W=>({...W,firstAfterDays:Number(Z.target.value)}))})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-xs",children:"Interval (days)"}),e.jsx(at,{type:"number",min:1,value:x.intervalDays??"",onChange:Z=>u(W=>({...W,intervalDays:Number(Z.target.value)}))})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-xs",children:"Max reminders"}),e.jsx(at,{type:"number",min:1,value:x.maxCount??"",onChange:Z=>u(W=>({...W,maxCount:Number(Z.target.value)}))})]})]}),e.jsx(se,{size:"sm",onClick:j,disabled:N,children:N?"Saving…":"Save reminder settings"})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"text-sm flex items-center gap-2",children:[e.jsx(ZI,{className:"w-4 h-4"}),"Infrastructure"]})}),e.jsxs(Fe,{className:"space-y-2 text-sm",children:[e.jsx(Pv,{label:"Redis",value:(q=t==null?void 0:t.scheduler)!=null&&q.redisEnabled?"Enabled":"Disabled",ok:(O=t==null?void 0:t.scheduler)==null?void 0:O.redisEnabled}),e.jsx(Pv,{label:"SLA fast mode",value:(D=t==null?void 0:t.scheduler)!=null&&D.slaFastMode?"On":"Off",ok:!((P=t==null?void 0:t.scheduler)!=null&&P.slaFastMode)}),e.jsx(Pv,{label:"Questionnaire fast mode",value:(L=t==null?void 0:t.scheduler)!=null&&L.questionnaireFastMode?"On":"Off",ok:!(($=t==null?void 0:t.scheduler)!=null&&$.questionnaireFastMode)})]})]}),(((Y=t==null?void 0:t.scheduler)==null?void 0:Y.queues)??[]).map(Z=>{var W;return e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-2",children:[e.jsx(Je,{className:"text-sm",children:Z.name}),Z.key&&e.jsx(Xt,{children:Z.key})]}),e.jsx(Fe,{className:"text-sm",children:Z.error?e.jsx("p",{className:"text-red-600",children:Z.error}):e.jsxs(e.Fragment,{children:[Z.counts&&e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:Object.entries(Z.counts).map(([U,M])=>e.jsxs(Ce,{variant:"outline",children:[U,": ",M]},U))}),(W=Z.repeatable)!=null&&W.length?e.jsx("ul",{className:"text-xs text-slate-600 space-y-1",children:Z.repeatable.map((U,M)=>e.jsxs("li",{children:[U.name||U.pattern,U.next?` · next ${new Date(U.next).toLocaleString()}`:""]},M))}):e.jsx("p",{className:"text-slate-400 text-xs",children:"No repeatable jobs registered"})]})})]},Z.name)})]})})]})]})};function Rm({label:t,value:s,highlight:n}){return e.jsxs("div",{className:`rounded-lg border p-3 ${n?"border-red-200 bg-red-50/40":"border-slate-200 bg-slate-50/50"}`,children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-500",children:t}),e.jsx("p",{className:"text-xl font-bold text-slate-900",children:s})]})}function du({label:t,value:s,icon:n,highlight:r}){return e.jsx(Le,{className:r==="red"?"border-red-200 bg-red-50/30":"border-slate-200",children:e.jsx(Fe,{className:"pt-4 pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500 uppercase tracking-wide",children:t}),e.jsx("p",{className:"text-2xl font-bold text-slate-900",children:s})]}),n]})})})}function Pv({label:t,value:s,ok:n}){return e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:t}),e.jsx("span",{className:n===!1?"text-re-red-hover font-medium":"text-slate-900",children:s})]})}const qG=({isOpen:t,onClose:s,sla:n,onSave:r})=>{const[a,i]=g.useState({activityName:"",tatHours:24,tatUnit:"hours",isActive:!0,reminders:[],escalationConfigs:[]}),[o,d]=g.useState(!1);g.useEffect(()=>{n&&i({...n,reminders:n.reminders||[],escalationConfigs:n.escalationConfigs||[]})},[n]);const m=()=>{i({...a,reminders:[...a.reminders,{timeValue:1,timeUnit:"days",isEnabled:!0}]})},f=u=>{const N=[...a.reminders];N.splice(u,1),i({...a,reminders:N})},p=()=>{i({...a,escalationConfigs:[...a.escalationConfigs,{level:a.escalationConfigs.length+1,timeValue:1,timeUnit:"days",notifyEmail:""}]})},h=u=>{const N=[...a.escalationConfigs];N.splice(u,1);const v=N.map((w,j)=>({...w,level:j+1}));i({...a,escalationConfigs:v})},x=async u=>{if(u.preventDefault(),!a.activityName||!a.ownerRole){te.error("Activity Name and Owner Role are required");return}try{d(!0),await Is.saveSlaConfig(a),te.success(n!=null&&n.id?"SLA Configuration updated":"New SLA Configuration created"),r(),s()}catch(N){console.error("Save SLA error:",N),te.error("Failed to save SLA configuration")}finally{d(!1)}};return e.jsx(ds,{open:t,onOpenChange:s,children:e.jsxs(os,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(xs,{children:[e.jsxs(ms,{children:[n!=null&&n.id?"Configure SLA":"Add New SLA",": ",a.activityName||"New Activity"]}),e.jsx(bs,{children:"Define the Turn Around Time and notification rules for this stage."})]}),e.jsxs("form",{onSubmit:x,className:"space-y-6 py-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"activityName",children:"Activity Name (Workflow Stage)"}),e.jsxs(Dt,{value:a.activityName,onValueChange:u=>{let N=a.ownerRole;for(const v of Object.values(C2))if(v[u]){N=v[u];break}i({...a,activityName:u,ownerRole:N})},disabled:!!(n!=null&&n.id),children:[e.jsx(Et,{id:"activityName",children:e.jsx(Rt,{placeholder:"Select Stage"})}),e.jsx(_t,{children:Object.entries(C2).map(([u,N])=>e.jsxs(wt.Fragment,{children:[e.jsx("div",{className:"px-2 py-1.5 text-xs font-semibold text-slate-500 bg-slate-50",children:u}),Object.keys(N).map(v=>e.jsx(Me,{value:v,children:v},v))]},u))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"ownerRole",children:"Owner Role (Auto-resolved)"}),e.jsxs(Dt,{value:a.ownerRole,onValueChange:u=>i({...a,ownerRole:u}),disabled:!!(n!=null&&n.id),children:[e.jsx(Et,{id:"ownerRole",children:e.jsx(Rt,{placeholder:"Select Role"})}),e.jsx(_t,{children:Object.values(dn).map(u=>e.jsx(Me,{value:u,children:u},u))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"tatHours",children:"Target TAT"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(at,{id:"tatHours",type:"number",value:a.tatHours,onChange:u=>i({...a,tatHours:parseInt(u.target.value)})}),e.jsxs(Dt,{value:a.tatUnit,onValueChange:u=>i({...a,tatUnit:u}),children:[e.jsx(Et,{className:"w-32",children:e.jsx(Rt,{})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"hours",children:"Hours"}),e.jsx(Me,{value:"days",children:"Days"})]})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2 pt-8",children:[e.jsx(bp,{id:"isActive",className:"data-[state=checked]:bg-re-red",checked:a.isActive,onCheckedChange:u=>i({...a,isActive:u})}),e.jsx(de,{htmlFor:"isActive",children:"Active SLA Tracking"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between border-b pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Au,{className:"w-4 h-4 text-blue-600"}),e.jsx("h4",{className:"font-medium text-sm",children:"Reminders"})]}),e.jsxs(se,{type:"button",variant:"outline",size:"sm",onClick:m,className:"h-7 text-xs",children:[e.jsx(An,{className:"w-3 h-3 mr-1"})," Add Reminder"]})]}),e.jsxs("div",{className:"space-y-3",children:[a.reminders.map((u,N)=>e.jsxs("div",{className:"flex items-center gap-3 bg-slate-50 p-2 rounded-lg border border-slate-100",children:[e.jsx("span",{className:"text-xs font-medium text-slate-500 w-12 text-center",children:"Before"}),e.jsx(at,{type:"number",className:"w-20 h-8",value:u.timeValue,onChange:v=>{const w=[...a.reminders];w[N].timeValue=parseInt(v.target.value),i({...a,reminders:w})}}),e.jsxs(Dt,{value:u.timeUnit,onValueChange:v=>{const w=[...a.reminders];w[N].timeUnit=v,i({...a,reminders:w})},children:[e.jsx(Et,{className:"w-24 h-8 text-xs",children:e.jsx(Rt,{})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"hours",children:"Hours"}),e.jsx(Me,{value:"days",children:"Days"})]})]}),e.jsx(se,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(N),className:"h-8 w-8 p-0 text-slate-400 hover:text-red-500",children:e.jsx(ar,{className:"w-4 h-4"})})]},N)),a.reminders.length===0&&e.jsx("p",{className:"text-center text-xs text-slate-400 py-2",children:"No reminders set"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between border-b pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ha,{className:"w-4 h-4 text-re-red"}),e.jsx("h4",{className:"font-medium text-sm",children:"Escalation Levels"})]}),e.jsxs(se,{type:"button",variant:"outline",size:"sm",onClick:p,className:"h-7 text-xs",children:[e.jsx(An,{className:"w-3 h-3 mr-1"})," Add Level"]})]}),e.jsxs("div",{className:"space-y-3",children:[a.escalationConfigs.map((u,N)=>e.jsxs("div",{className:"bg-slate-50 p-3 rounded-lg border border-slate-100 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ce,{variant:"outline",className:"bg-red-50 text-re-red-hover border-red-100",children:["Level ",u.level]}),e.jsx(se,{type:"button",variant:"ghost",size:"sm",onClick:()=>h(N),className:"h-7 w-7 p-0 text-slate-400 hover:text-red-500",children:e.jsx(ar,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(de,{className:"text-[10px] uppercase text-slate-500",children:"Escalate After Breaching By"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(at,{type:"number",className:"h-8",value:u.timeValue,onChange:v=>{const w=[...a.escalationConfigs];w[N].timeValue=parseInt(v.target.value),i({...a,escalationConfigs:w})}}),e.jsxs(Dt,{value:u.timeUnit,onValueChange:v=>{const w=[...a.escalationConfigs];w[N].timeUnit=v,i({...a,escalationConfigs:w})},children:[e.jsx(Et,{className:"w-24 h-8 text-xs",children:e.jsx(Rt,{})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"hours",children:"Hours"}),e.jsx(Me,{value:"days",children:"Days"})]})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(de,{className:"text-[10px] uppercase text-slate-500",children:"Notification Recipient (Role)"}),e.jsxs(Dt,{value:u.notifyRole||"",onValueChange:v=>{const w=[...a.escalationConfigs];w[N].notifyRole=v,w[N].notifyEmail="",i({...a,escalationConfigs:w})},children:[e.jsx(Et,{className:"h-8 text-xs",children:e.jsx(Rt,{placeholder:"Select Recipient Role"})}),e.jsx(_t,{children:Object.values(dn).map(v=>e.jsx(Me,{value:v,children:v},v))})]})]})]})]},N)),a.escalationConfigs.length===0&&e.jsx("p",{className:"text-center text-xs text-slate-400 py-2",children:"No escalation levels defined"})]})]}),e.jsxs(bn,{className:"pt-4 border-t",children:[e.jsx(se,{type:"button",variant:"outline",onClick:s,disabled:o,children:"Cancel"}),e.jsx(se,{type:"submit",disabled:o,className:"bg-re-red hover:bg-re-red-hover text-white",children:o?"Saving...":"Save Configuration"})]})]})]})})},zG=()=>{const t=Lu(),{slaConfigs:s,loading:n}=In(v=>v.master),[r,a]=g.useState(!1),[i,o]=g.useState(null),[d,m]=g.useState(!1),[f,p]=g.useState("monitor"),h=async()=>{try{const v=await Is.getSlaConfigs();v&&v.success&&t(kA({slaConfigs:v.data}))}catch{te.error("Failed to fetch SLA configurations")}};g.useEffect(()=>{h()},[]);const x=async()=>{try{m(!0);const v=await Is.initializeDefaultSlas();v&&v.success&&(te.success("Default SLAs initialized successfully"),h())}catch{te.error("Failed to initialize default SLAs")}finally{m(!1)}},u=v=>{o(v),a(!0)},N=()=>{o(null),a(!0)};return e.jsxs("div",{className:"space-y-6 max-w-7xl mx-auto",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-slate-900 flex items-center gap-2",children:[e.jsx(vn,{className:"w-6 h-6 text-re-red"}),"SLA & Escalation"]}),e.jsx("p",{className:"text-slate-500",children:"Configure TAT rules and monitor live queue, breaches, and schedulers"})]}),e.jsxs(Bn,{value:f,onValueChange:p,children:[e.jsxs($n,{className:"bg-slate-100",children:[e.jsxs(Wt,{value:"monitor",className:"flex items-center gap-1.5",children:[e.jsx(ad,{className:"w-4 h-4"}),"Operations monitor"]}),e.jsx(Wt,{value:"config",children:"Configuration matrix"})]}),e.jsx(Ut,{value:"monitor",className:"mt-6",children:e.jsx($G,{})}),e.jsxs(Ut,{value:"config",className:"mt-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-end gap-3",children:[e.jsxs(se,{variant:"outline",onClick:x,disabled:n||d,children:[e.jsx(xr,{className:`w-4 h-4 mr-2 ${d?"animate-spin":""}`}),"Initialize Defaults"]}),e.jsxs(se,{onClick:N,disabled:n,className:"bg-re-red hover:bg-re-red-hover text-white",children:[e.jsx(An,{className:"w-4 h-4 mr-2"}),"Add Manual SLA"]}),e.jsx(se,{variant:"ghost",size:"icon",onClick:h,disabled:n,children:e.jsx(xr,{className:`w-4 h-4 ${n?"animate-spin":""}`})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.map(v=>{var w,j;return e.jsxs(Le,{className:"border-slate-200 hover:shadow-md transition-shadow group overflow-hidden",children:[e.jsx(Qe,{className:"pb-3 bg-gradient-to-br from-white to-slate-50/50",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-red-50 border border-red-100 flex items-center justify-center",children:e.jsx(vn,{className:"w-5 h-5 text-re-red"})}),e.jsxs("div",{children:[e.jsx(Je,{className:"text-lg",children:v.activityName}),e.jsx(Xt,{className:"flex items-center gap-1.5 mt-0.5",children:e.jsxs("span",{className:"font-semibold text-re-red-hover",children:["Target TAT: ",v.tatHours," ",v.tatUnit]})})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{variant:v.isActive?"default":"secondary",className:v.isActive?"bg-emerald-600":"bg-slate-400",children:v.isActive?e.jsxs(e.Fragment,{children:[e.jsx(un,{className:"w-3 h-3 mr-1"})," Active"]}):"Disabled"}),e.jsx(se,{variant:"ghost",size:"icon",onClick:()=>u(v),className:"h-8 w-8 text-slate-400 hover:text-re-red",children:e.jsx(Cr,{className:"w-4 h-4"})})]})]})}),e.jsxs(Fe,{className:"pt-4 grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"border-l-2 border-blue-400 pl-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Au,{className:"w-4 h-4 text-blue-600"}),e.jsxs("span",{className:"text-xs font-bold text-slate-700 uppercase tracking-wider",children:["Reminders (",((w=v.reminders)==null?void 0:w.length)||0,")"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[(v.reminders||[]).map((b,C)=>e.jsxs("div",{className:"text-xs text-slate-600 flex items-center gap-1",children:[e.jsxs(Ce,{variant:"outline",className:"text-[10px] h-4.5 bg-blue-50 border-blue-200",children:[b.timeValue," ",b.timeUnit]}),e.jsx("span",{children:"before SLA"})]},C)),(!v.reminders||v.reminders.length===0)&&e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"None configured"})]})]}),e.jsxs("div",{className:"border-l-2 border-red-400 pl-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ha,{className:"w-4 h-4 text-re-red"}),e.jsxs("span",{className:"text-xs font-bold text-slate-700 uppercase tracking-wider",children:["Escalations (",((j=v.escalationConfigs)==null?void 0:j.length)||0,")"]})]}),e.jsxs("div",{className:"space-y-2",children:[(v.escalationConfigs||[]).map((b,C)=>e.jsxs("div",{className:"text-[11px]",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-slate-900 font-medium",children:[e.jsxs(Ce,{variant:"outline",className:"text-[9px] h-4 px-1 bg-red-50 border-red-200 text-re-red-hover",children:["L",b.level]}),e.jsxs("span",{children:["after ",b.timeValue," ",b.timeUnit]})]}),e.jsx("p",{className:"text-slate-500 ml-8 font-mono truncate",children:b.notifyEmail})]},C)),(!v.escalationConfigs||v.escalationConfigs.length===0)&&e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"None configured"})]})]})]})]},v.id)}),s.length===0&&!n&&e.jsxs("div",{className:"lg:col-span-2 py-20 text-center border-2 border-dashed rounded-2xl bg-slate-50/50",children:[e.jsx(vn,{className:"w-12 h-12 text-slate-200 mx-auto mb-4"}),e.jsx("h3",{className:"text-slate-600 font-medium",children:"No SLA Workflows found"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"Please initialize default configurations from the admin tools"})]})]})]})]}),e.jsx(qG,{isOpen:r,onClose:()=>a(!1),sla:i,onSave:h})]})},Q_="Private Limited",X_="LLP",J_="Partnership",gj="Proprietorship",eT=[gj,J_,X_,Q_];function UG(t){return eT.includes(t)}function VG(t){const s=String(t||"").trim();if(!s)return null;if(UG(s))return s;const n=s.toLowerCase().replace(/\./g,"").replace(/\s+/g," ").trim();return n.includes("private")&&(n.includes("ltd")||n.includes("limited"))||n==="pvt ltd"||n==="pvtltd"?Q_:n.includes("llp")?X_:n.includes("partnership")?J_:n.includes("proprietorship")||n==="sole proprietorship"?gj:eT.find(a=>a.toLowerCase()===s.toLowerCase())||null}function tT(t){return VG(t)||gj}const HG={Partnership:[1,2,3,4,8,9,10,16],LLP:[1,2,3,7,8,10,11,16],"Private Limited":[1,2,3,5,6,7,8,10,16],Proprietorship:[1,2,3,10,16]},WG=99,GG={1:"GST",2:"Firm Pan Copy",3:"Self attested KYC's",4:"Partnership Agreement (Notarised)",5:"MOA (Applicable for Only Pvt.Ltd)",6:"AOA (Applicable for Only Pvt.Ltd)",7:"COI (Applicable for Only Pvt.Ltd & LLP)",8:"BPA - Business Purchase Agreement",9:"Firm Registration Certificate (Partnership)",10:"Cancelled Cheque",11:"LLP Agreement (Notarised)",12:"ZBH Approval",13:"NBH Approval",14:"RBM Approval",15:"DD-Lead Approval",16:"Declaration / Authorization Letter",[WG]:"Other"},k2=(t,s)=>Qb(t,s),ol=t=>{switch(t){case"Proprietorship":return"bg-purple-100 text-purple-700 border-purple-300";case"Partnership":return"bg-blue-100 text-blue-700 border-blue-300";case"LLP":return"bg-indigo-100 text-indigo-700 border-indigo-300";case"Private Limited":return"bg-cyan-100 text-cyan-700 border-cyan-300";default:return"bg-slate-100 text-slate-700 border-slate-300"}};function KG({onViewDetails:t}){var Pe,et,kt,vt;const[s,n]=g.useState(!1),[r,a]=g.useState([]),[i,o]=g.useState([]),[d,m]=g.useState([]),[f,p]=g.useState(""),[h,x]=g.useState(""),[u,N]=g.useState([]),[v,w]=g.useState(null),[j,b]=g.useState(""),[C,S]=g.useState(""),[R,_]=g.useState([]),[A,E]=g.useState([]),[q,O]=g.useState(!0),[D,P]=g.useState(1),[L,$]=g.useState(null),[Y,Z]=g.useState("all"),W=10,U=A.map(ee=>({entityType:"constitutional",entityId:ee.id||ee.requestId})),{get:M}=pc(U,A.length>0),[z,T]=g.useState(!1),[I,B]=g.useState(!1),G=ee=>ee.status==="Completed"||ee.status==="Closed"||ee.currentStage==="Completed",K=ee=>ee.status==="Rejected"||ee.status==="Revoked"||ee.currentStage==="Rejected"||ee.currentStage==="Revoked",H=ee=>!G(ee)&&!K(ee)&&ee.status!=="Submitted",X=ee=>ee.status==="Submitted"||ee.currentStage==="Submitted",J=ee=>{Z(ee),P(1)};g.useEffect(()=>{ae()},[D,Y]),g.useEffect(()=>{if(!s)return;let ee=!1;return(async()=>{var ge,ye,Be,$e;try{B(!0);const[dt,st,xt]=await Promise.all([Ee.getConstitutionalChangeMeta(),Ee.getDealers({onboarded:"true"}),Ee.getOutlets()]);if(ee)return;(ge=dt.data)!=null&&ge.success&&Array.isArray(dt.data.structureTargets)&&a(dt.data.structureTargets);const Mt=((ye=st.data)==null?void 0:ye.data)??((Be=st.data)==null?void 0:Be.dealers)??[];o(Array.isArray(Mt)?Mt:[]);const It=(($e=xt.data)==null?void 0:$e.outlets)??[];m(Array.isArray(It)?It:[])}catch(dt){console.error(dt),te.error("Failed to load dealers or form options")}finally{ee||B(!1)}})(),()=>{ee=!0}},[s]);const ae=async()=>{try{O(!0);const ee=await Ee.getConstitutionalChanges({page:D,limit:W,status:Y==="all"?void 0:Y});ee.data.success&&(E(ee.data.requests||[]),$(ee.meta))}catch(ee){console.error("Fetch requests error:",ee),te.error("Failed to fetch requests")}finally{O(!1)}},le=ee=>{var $e,dt,st;if(p(ee),x(""),b(""),_([]),!ee){w(null),N([]);return}const ge=i.find(xt=>{var Mt;return((Mt=xt.user)==null?void 0:Mt.id)===ee});if(!(($e=ge==null?void 0:ge.user)!=null&&$e.id)){w(null),N([]);return}const ye=tT(ge.constitutionType),Be=d.filter(xt=>String(xt.dealerId)===String(ee));N(Be),Be.length===1&&x(Be[0].id),w({dealerUserId:ge.user.id,dealerName:ge.businessName,dealershipName:ge.legalName||ge.businessName,address:ge.registeredAddress||((dt=ge.application)==null?void 0:dt.preferredLocation)||"—",gst:ge.gstNumber||"N/A",currentType:ye,dealerCode:((st=ge.dealerCode)==null?void 0:st.dealerCode)||"—",region:"—",zone:"—"})},xe=ee=>{b(ee),_(HG[ee]||[])},ce=async ee=>{var ge,ye;if(ee.preventDefault(),!(v!=null&&v.dealerUserId)){te.error("Please select a dealer");return}if(u.length>1&&!h){te.error("Please select an outlet for this dealer");return}if(!j){te.error("Please select proposed constitution type");return}if(!C.trim()){te.error("Please provide a reason for constitutional change");return}if(v.currentType===j){te.error("Proposed type cannot be the same as the current constitution");return}try{T(!0);const Be={forDealerUserId:v.dealerUserId,outletId:h||void 0,changeType:j,reason:C.trim(),currentConstitution:v.currentType};(await Ee.createConstitutionalChange(Be)).data.success&&(te.success("Constitutional change request submitted successfully"),n(!1),ae(),p(""),x(""),N([]),w(null),b(""),S(""),_([]))}catch(Be){console.error("Submit request error:",Be);const $e=((ye=(ge=Be==null?void 0:Be.response)==null?void 0:ge.data)==null?void 0:ye.message)||"Failed to submit request";te.error($e)}finally{T(!1)}},ve=[{title:"Total Requests",value:((Pe=L==null?void 0:L.stats)==null?void 0:Pe.total)||0,icon:Ns,color:"bg-blue-500"},{title:"Submitted / Review",value:((et=L==null?void 0:L.stats)==null?void 0:et.pending)||0,icon:dr,color:"bg-re-red"},{title:"Completed",value:((kt=L==null?void 0:L.stats)==null?void 0:kt.completed)||0,icon:hc,color:"bg-green-500"},{title:"Rejected / Revoked",value:((vt=L==null?void 0:L.stats)==null?void 0:vt.rejected)||0,icon:id,color:"bg-red-500"}];return e.jsxs("div",{className:"space-y-6",children:[q&&e.jsx("div",{className:"fixed inset-0 bg-slate-900/20 backdrop-blur-sm z-50 flex items-center justify-center",children:e.jsx(ns,{className:"w-8 h-8 text-re-red animate-spin"})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 mb-2",children:"Constitutional Change Management"}),e.jsx("p",{className:"text-slate-600",children:"Manage dealership constitutional change requests - Adding/Removing partners or changing business structure"})]}),e.jsxs(ds,{open:s,onOpenChange:n,children:[e.jsx(co,{asChild:!0,children:e.jsxs(se,{className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(An,{className:"w-4 h-4 mr-2"}),"New Request"]})}),e.jsxs(os,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Create Constitutional Change Request"}),e.jsx(bs,{children:"Submit a request for dealership constitutional change. All fields are mandatory."})]}),e.jsxs("form",{onSubmit:ce,className:"space-y-4",children:[I&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500 py-2",children:[e.jsx(ns,{className:"h-4 w-4 animate-spin"}),"Loading dealers and options…"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"dealerUser",children:"Dealer *"}),e.jsxs(Dt,{value:f,onValueChange:le,disabled:I,required:!0,children:[e.jsx(Et,{id:"dealerUser",children:e.jsx(Rt,{placeholder:"Select dealer account"})}),e.jsx(_t,{className:"max-h-72",children:i.filter(ee=>{var ge;return(ge=ee.user)==null?void 0:ge.id}).map(ee=>{var ge;return e.jsx(Me,{value:ee.user.id,children:(((ge=ee.dealerCode)==null?void 0:ge.dealerCode)||"No code")+" — "+(ee.businessName||ee.legalName||"Dealer")},ee.user.id)})})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Internal users create the request on behalf of the selected dealer; the workflow uses the same endpoint as dealer-initiated requests."})]}),u.length>1&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"outletPick",children:"Outlet *"}),e.jsxs(Dt,{value:h,onValueChange:x,required:!0,children:[e.jsx(Et,{id:"outletPick",children:e.jsx(Rt,{placeholder:"Select outlet"})}),e.jsx(_t,{children:u.map(ee=>e.jsxs(Me,{value:ee.id,children:[ee.code," — ",ee.name]},ee.id))})]})]}),v&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-lg p-4 space-y-3",children:[e.jsx("h3",{className:"text-slate-900",children:"Dealer Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Dealer Code:"}),e.jsx("p",{className:"text-slate-900",children:v.dealerCode})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Dealer Name:"}),e.jsx("p",{className:"text-slate-900",children:v.dealerName})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Legal / display name:"}),e.jsx("p",{className:"text-slate-900",children:v.dealershipName})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Address:"}),e.jsx("p",{className:"text-slate-900",children:v.address})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"GST:"}),e.jsx("p",{className:"text-slate-900",children:v.gst})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Current constitution (from profile):"}),e.jsx(Ce,{className:ol(v.currentType),children:v.currentType})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"targetType",children:"Proposed constitution *"}),e.jsxs(Dt,{value:j,onValueChange:xe,required:!0,children:[e.jsx(Et,{children:e.jsx(Rt,{placeholder:"Select proposed constitution"})}),e.jsx(_t,{children:r.filter(ee=>ee.value!==(v==null?void 0:v.currentType)).map(ee=>e.jsx(Me,{value:ee.value,children:ee.label},ee.value))})]}),v&&j&&v.currentType===j&&e.jsx("p",{className:"text-red-600 text-sm",children:"Target type cannot be same as current type"})]}),j&&R.length>0&&e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4 space-y-2",children:[e.jsxs("h4",{className:"text-blue-900",children:["Required Documents for ",j]}),e.jsx("div",{className:"grid grid-cols-1 gap-2",children:R.map(ee=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsxs("span",{className:"text-blue-600 font-medium",children:[ee,"."]}),e.jsx("span",{className:"text-blue-800",children:GG[ee]})]},ee))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"reason",children:"Reason for Constitutional Change *"}),e.jsx(Ws,{id:"reason",placeholder:"Provide detailed reason for the constitutional change request...",value:C,onChange:ee=>S(ee.target.value),rows:4,required:!0})]}),e.jsxs(bn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(se,{type:"submit",className:"bg-re-red hover:bg-re-red-hover",disabled:!v||!j||v&&v.currentType===j||u.length>1&&!h||I||z,children:z?e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Request"})]})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:ve.map((ee,ge)=>{const ye=ee.icon;return e.jsx(Le,{children:e.jsx(Fe,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:ee.title}),e.jsx("p",{className:"text-slate-900 text-2xl mt-1",children:ee.value})]}),e.jsx("div",{className:`${ee.color} w-12 h-12 rounded-lg flex items-center justify-center`,children:e.jsx(ye,{className:"w-6 h-6 text-white"})})]})})},ge)})}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"Constitutional Change Requests"}),e.jsx(Xt,{children:"Track and manage all constitutional change requests across all stages"})]}),e.jsxs(Fe,{children:[e.jsxs(Bn,{value:Y,onValueChange:J,className:"w-full",children:[e.jsxs($n,{className:"grid w-full grid-cols-4",children:[e.jsx(Wt,{value:"all",children:"All Requests"}),e.jsx(Wt,{value:"pending",children:"Submitted / Review"}),e.jsx(Wt,{value:"rejected",children:"Rejected / Revoked"}),e.jsx(Wt,{value:"completed",children:"Completed"})]}),e.jsx(Ut,{value:"all",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Constitutional Change"}),e.jsx(fe,{children:"Current Stage"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Submitted On"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Os,{children:A.length===0?e.jsx(it,{children:e.jsx(ue,{colSpan:7,className:"text-center py-8 text-slate-500",children:"No constitutional change requests found"})}):A.map(ee=>{var ge,ye,Be,$e,dt,st,xt,Mt,It,he,pt,ht,_e,Vt,Pt,_s;return e.jsxs(it,{children:[e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:ee.requestId}),e.jsx("div",{className:"text-slate-600 text-sm",children:((Be=(ye=(ge=ee.dealer)==null?void 0:ge.dealerProfile)==null?void 0:ye.dealerCode)==null?void 0:Be.dealerCode)||(($e=ee.outlet)==null?void 0:$e.code)||"N/A"})]}),e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:((st=(dt=ee.dealer)==null?void 0:dt.dealerProfile)==null?void 0:st.businessName)||((xt=ee.outlet)==null?void 0:xt.name)||"N/A"}),e.jsx("div",{className:"text-slate-600 text-sm",children:((It=(Mt=ee.dealer)==null?void 0:Mt.dealerProfile)==null?void 0:It.registeredAddress)||((he=ee.outlet)!=null&&he.city&&((pt=ee.outlet)!=null&&pt.state)?`${ee.outlet.city}, ${ee.outlet.state}`:((Vt=(_e=(ht=ee.dealer)==null?void 0:ht.dealerProfile)==null?void 0:_e.application)==null?void 0:Vt.city)||((Pt=ee.outlet)==null?void 0:Pt.address)||"N/A")})]}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:ol(ee.currentConstitution||"Proprietorship"),children:ee.currentConstitution||"—"}),e.jsx(Ko,{className:"w-4 h-4 text-slate-400"}),e.jsx(Ce,{className:ol(ee.changeType),children:ee.changeType})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx(Ce,{className:eo(ee.currentStage,ee.status),children:ee.currentStage}),e.jsx(kr,{status:M("constitutional",ee.id||ee.requestId),compact:!0})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-300 ${gl(ee.status,ee.currentStage)}`,style:{width:`${ee.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-slate-600 text-sm",children:[ee.progressPercentage||0,"%"]})]})}),e.jsxs(ue,{children:[e.jsx("div",{className:"text-slate-900",children:Yt(ee.createdAt)}),e.jsxs("div",{className:"text-slate-600 text-sm",children:["By ",((_s=ee.dealer)==null?void 0:_s.fullName)||"Dealer"]})]}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(ee.requestId),children:[e.jsx(yn,{className:"w-4 h-4 mr-1"}),"View"]})})]},ee.requestId)})})]})})}),e.jsx(Ut,{value:"pending",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Constitutional Change"}),e.jsx(fe,{children:"Current Stage"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Actions"})]})}),e.jsxs(Os,{children:[A.filter(ee=>X(ee)||H(ee)).map(ee=>{var ge,ye,Be,$e,dt,st,xt,Mt,It,he,pt,ht;return e.jsxs(it,{children:[e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:ee.requestId}),e.jsx("div",{className:"text-slate-600 text-sm",children:((Be=(ye=(ge=ee.dealer)==null?void 0:ge.dealerProfile)==null?void 0:ye.dealerCode)==null?void 0:Be.dealerCode)||(($e=ee.outlet)==null?void 0:$e.code)||"N/A"})]}),e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:((st=(dt=ee.dealer)==null?void 0:dt.dealerProfile)==null?void 0:st.businessName)||((xt=ee.outlet)==null?void 0:xt.name)||"N/A"}),e.jsx("div",{className:"text-slate-600 text-sm",children:((It=(Mt=ee.dealer)==null?void 0:Mt.dealerProfile)==null?void 0:It.registeredAddress)||((he=ee.outlet)!=null&&he.city&&((pt=ee.outlet)!=null&&pt.state)?`${ee.outlet.city}, ${ee.outlet.state}`:((ht=ee.outlet)==null?void 0:ht.address)||"N/A")})]}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:ol(ee.currentConstitution||"Proprietorship"),children:ee.currentConstitution||"—"}),e.jsx(Ko,{className:"w-4 h-4 text-slate-400"}),e.jsx(Ce,{className:ol(ee.changeType),children:ee.changeType})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx(Ce,{className:eo(ee.currentStage,ee.status),children:ee.currentStage}),e.jsx(kr,{status:M("constitutional",ee.id||ee.requestId),compact:!0})]})}),e.jsx(ue,{children:e.jsx(Ce,{className:k2(ee.status,ee.currentStage),children:ee.status})}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(ee.requestId),children:[e.jsx(yn,{className:"w-4 h-4 mr-1"}),"View"]})})]},ee.requestId)}),A.filter(ee=>X(ee)||H(ee)).length===0&&e.jsx(it,{children:e.jsx(ue,{colSpan:6,className:"text-center py-8 text-slate-500",children:"No pending requests found"})})]})]})})}),e.jsx(Ut,{value:"in-progress",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Constitutional Change"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Current Stage"}),e.jsx(fe,{children:"Actions"})]})}),e.jsxs(Os,{children:[A.filter(ee=>K(ee)).map(ee=>{var ge,ye,Be,$e,dt,st,xt,Mt,It,he,pt,ht,_e,Vt,Pt;return e.jsxs(it,{children:[e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:ee.requestId}),e.jsx("div",{className:"text-slate-600 text-sm",children:((Be=(ye=(ge=ee.dealer)==null?void 0:ge.dealerProfile)==null?void 0:ye.dealerCode)==null?void 0:Be.dealerCode)||(($e=ee.outlet)==null?void 0:$e.code)||"N/A"})]}),e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:((st=(dt=ee.dealer)==null?void 0:dt.dealerProfile)==null?void 0:st.businessName)||((xt=ee.outlet)==null?void 0:xt.name)||"N/A"}),e.jsx("div",{className:"text-slate-600 text-sm",children:((It=(Mt=ee.dealer)==null?void 0:Mt.dealerProfile)==null?void 0:It.registeredAddress)||((he=ee.outlet)!=null&&he.city&&((pt=ee.outlet)!=null&&pt.state)?`${ee.outlet.city}, ${ee.outlet.state}`:((Vt=(_e=(ht=ee.dealer)==null?void 0:ht.dealerProfile)==null?void 0:_e.application)==null?void 0:Vt.city)||((Pt=ee.outlet)==null?void 0:Pt.address)||"N/A")})]}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:ol(ee.currentConstitution||"Proprietorship"),children:ee.currentConstitution||"—"}),e.jsx(Ko,{className:"w-4 h-4 text-slate-400"}),e.jsx(Ce,{className:ol(ee.changeType),children:ee.changeType})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-300 ${gl(ee.status,ee.currentStage)}`,style:{width:`${ee.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-slate-600 text-sm",children:[ee.progressPercentage||0,"%"]})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx(Ce,{className:eo(ee.currentStage,ee.status),children:ee.currentStage}),e.jsx(kr,{status:M("constitutional",ee.id||ee.requestId),compact:!0})]})}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(ee.requestId),children:[e.jsx(yn,{className:"w-4 h-4 mr-1"}),"View"]})})]},ee.requestId)}),A.filter(ee=>K(ee)).length===0&&e.jsx(it,{children:e.jsx(ue,{colSpan:6,className:"text-center py-8 text-slate-500",children:"No in-progress requests found"})})]})]})})}),e.jsx(Ut,{value:"completed",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Constitutional Change"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Submitted On"}),e.jsx(fe,{children:"Actions"})]})}),e.jsxs(Os,{children:[A.filter(ee=>G(ee)).map(ee=>{var ge,ye,Be,$e,dt,st,xt,Mt,It,he,pt,ht;return e.jsxs(it,{children:[e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:ee.requestId}),e.jsx("div",{className:"text-slate-600 text-sm",children:((Be=(ye=(ge=ee.dealer)==null?void 0:ge.dealerProfile)==null?void 0:ye.dealerCode)==null?void 0:Be.dealerCode)||(($e=ee.outlet)==null?void 0:$e.code)||"N/A"})]}),e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:((st=(dt=ee.dealer)==null?void 0:dt.dealerProfile)==null?void 0:st.businessName)||((xt=ee.outlet)==null?void 0:xt.name)||"N/A"}),e.jsx("div",{className:"text-slate-600 text-sm",children:((It=(Mt=ee.dealer)==null?void 0:Mt.dealerProfile)==null?void 0:It.registeredAddress)||((he=ee.outlet)!=null&&he.city&&((pt=ee.outlet)!=null&&pt.state)?`${ee.outlet.city}, ${ee.outlet.state}`:((ht=ee.outlet)==null?void 0:ht.address)||"N/A")})]}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:ol(ee.currentConstitution||"Proprietorship"),children:ee.currentConstitution||"—"}),e.jsx(Ko,{className:"w-4 h-4 text-slate-400"}),e.jsx(Ce,{className:ol(ee.changeType),children:ee.changeType})]})}),e.jsx(ue,{children:e.jsx(Ce,{className:k2(ee.status,ee.currentStage),children:ee.status})}),e.jsx(ue,{children:e.jsx("div",{className:"text-slate-900",children:Yt(ee.createdAt)})}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(ee.requestId),children:[e.jsx(yn,{className:"w-4 h-4 mr-1"}),"View"]})})]},ee.requestId)}),A.filter(ee=>G(ee)).length===0&&e.jsx(it,{children:e.jsx(ue,{colSpan:6,className:"text-center py-8 text-slate-500",children:"No completed requests found"})})]})]})})})]}),L&&L.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center bg-white rounded-b-lg",children:e.jsx(fo,{children:e.jsxs(po,{children:[e.jsx(Sn,{children:e.jsx(xo,{onClick:()=>P(ee=>Math.max(1,ee-1)),className:D===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(L.totalPages)].map((ee,ge)=>{const ye=ge+1;return ye===1||ye===L.totalPages||ye>=D-1&&ye<=D+1?e.jsx(Sn,{children:e.jsx(Vi,{isActive:D===ye,onClick:()=>P(ye),className:"cursor-pointer",children:ye})},ye):ye===2&&D>3||ye===L.totalPages-1&&D<L.totalPages-2?e.jsx(Sn,{children:e.jsx(vo,{})},ye):null}),e.jsx(Sn,{children:e.jsx(go,{onClick:()=>P(ee=>Math.min(L.totalPages,ee+1)),className:D===L.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})]})}const Em={APPROVE:"approve",SEND_BACK:"sendBack",REVOKE:"revoke",REJECT:"reject",WITHDRAWAL:"withdrawal",ASSIGN:"assign",PUSH_FNF:"pushfnf",RECONSIDER:"reconsider",ISSUE_SCN:"issueSCN",SCN_RESPONSE:"scnResponse"},_m=[{id:2,name:"ASM Review",key:"asm-review",role:"ASM"},{id:3,name:"ZM/RBM Review",key:"zm-rbm-review",role:"ZM/RBM"},{id:4,name:"ZBH Review",key:"zbh-review",role:"ZBH"},{id:5,name:"DD Lead Review",key:"lead-review",role:"DD Lead"},{id:6,name:"DD Head Review",key:"head-review",role:"DD Head"},{id:7,name:"NBH Approval",key:"nbh-approval",role:"NBH"},{id:8,name:"Legal Review",key:"legal-review",role:"Legal Team"},{id:9,name:"Completed",key:"completed",role:"System"}],D2=t=>t==="ZM/RBM Review"?"ZM+RBM Review":t,R2=t=>t==="ZM/RBM"?"ZM+RBM":t,E2={Partnership:[1,2,3,4,8,9,10,16],LLP:[1,2,3,7,8,10,11,16],"Private Limited":[1,2,3,5,6,7,8,10,16],"Pvt Ltd":[1,2,3,5,6,7,8,10,16],Proprietorship:[1,2,3,10,16]},Ho=99,Wc={1:"GST Certificate",2:"Firm PAN Copy",3:"Self attested KYC's",4:"Partnership Agreement (Notarised)",5:"MOA (Applicable for Only Pvt.Ltd)",6:"AOA (Applicable for Only Pvt.Ltd)",7:"COI (Applicable for Only Pvt.Ltd & LLP)",8:"BPA - Business Purchase Agreement",9:"Firm Registration Certificate (Partnership)",10:"Cancelled Cheque",11:"LLP Agreement (Notarised)",12:"ZBH Approval",13:"NBH Approval",14:"RBM Approval",15:"DD-Lead Approval",16:"Declaration / Authorization Letter",[Ho]:"Other"},_2=t=>{switch(t){case"Proprietorship":return"bg-purple-100 text-purple-700 border-purple-300";case"Partnership":return"bg-blue-100 text-blue-700 border-blue-300";case"LLP":return"bg-indigo-100 text-indigo-700 border-indigo-300";case"Private Limited":case"Pvt Ltd":return"bg-cyan-100 text-cyan-700 border-cyan-300";default:return"bg-slate-100 text-slate-700 border-slate-300"}},Ov=t=>UE(t),YG=t=>t?"h-8 px-2 text-red-700 hover:bg-red-50 hover:text-red-800":"h-8 px-2 text-slate-700 hover:bg-slate-50",ZG=t=>{const s=String(t.action||"").toUpperCase(),n=String(t.description||"").toUpperCase(),r=String(t.remarks||"").toUpperCase(),a=t.details||t.newData||{},i=String(a.targetStage||"").toUpperCase(),o=String(a.action||"").toUpperCase(),d=`${s} ${n} ${r} ${o}`.toUpperCase();return d.includes("REJECT")?{variant:"danger",badge:s.replace(/_/g," ")||"REJECTED"}:d.includes("REVOK")?{variant:"danger",badge:s.replace(/_/g," ")||"REVOKED"}:d.includes("SENT BACK")||d.includes("SEND BACK")||d.includes("RECONSIDER")?{variant:"pending",badge:s.replace(/_/g," ")||"SENT BACK"}:d.includes("APPROV")||d.includes("INITI")||d.includes("CREATE")||d.includes("VERIF")||d.includes("UPLOAD")?{variant:"success",badge:s.replace(/_/g," ")||"APPROVED"}:i==="COMPLETED"||d.includes("COMPLET")?{variant:"success",badge:"COMPLETED"}:i?{variant:"success",badge:"APPROVED"}:{variant:"neutral",badge:s.replace(/_/g," ")||"EVENT"}},T2=t=>{const s=String(t||"").trim().toLowerCase();return s?s.includes("proprietor")?"Proprietorship":s.includes("partner")?"Partnership":s.includes("llp")?"LLP":s.includes("private")||s.includes("pvt")?"Private Limited":t:""};function QG({requestId:t,onBack:s,currentUser:n}){var Bs,Ks,Qs,Xs,$s,Q,oe,we,Oe,ke,je,Ve,Ge,nt,Zt,Jt,lt,mt,Ds,ss,Ae,be,ut,He,yt,ft,es,ts,Cs,Us,rn,Js,an,hn,De,bt;const{get:r}=pc(t?[{entityType:"constitutional",entityId:t}]:[],!!t),a=tr(),[i,o]=g.useState(!1),[d,m]=g.useState("approve"),[f,p]=g.useState(""),[h,x]=g.useState(!1),[u,N]=g.useState(null),[v,w]=g.useState(null),[j,b]=g.useState(!1),[C,S]=g.useState("workflow"),[R,_]=g.useState("required"),[A,E]=g.useState(null),[q,O]=g.useState([]),[D,P]=g.useState(!0),[L,$]=g.useState(!1),[Y,Z]=g.useState(null),[W,U]=g.useState(!1),[M,z]=g.useState(!1),[T,I]=g.useState(null),[B,G]=g.useState(""),[K,H]=g.useState(!1),X=async Te=>{if(Te)try{const ct=await Ee.getAuditLogs("constitutional_change",Te);ct.data&&ct.data.success&&O(ct.data.data||[])}catch(ct){console.error("Error fetching audit logs:",ct)}},J=async Te=>{try{Te!=null&&Te.silent||P(!0);const ct=await Ee.getConstitutionalChangeById(t);if(ct.data.success){const tt=ct.data.request;E(tt),await X((tt==null?void 0:tt.id)||t)}else te.error("Failed to fetch request details")}catch(ct){console.error("Fetch request details error:",ct),te.error("Error loading request details")}finally{Te!=null&&Te.silent||P(!1)}};g.useEffect(()=>{J()},[t]);const ae=g.useMemo(()=>q.length>0?q:((A==null?void 0:A.timeline)||[]).map((ct,tt)=>({id:`timeline-${tt}`,action:String(ct.action||"UPDATED"),description:ct.remarks||ct.action||"Updated",stage:ct.stage||null,userName:ct.user||ct.userName||"System",remarks:ct.remarks,timestamp:ct.timestamp||ct.createdAt})),[q,A==null?void 0:A.timeline]),le=g.useMemo(()=>{const Te=T2(String((A==null?void 0:A.changeType)||"")),tt=[...E2[Te]||[]];return tt.includes(Ho)||tt.push(Ho),tt.sort((jt,Ht)=>jt===Ho?1:Ht===Ho?-1:jt-Ht)},[A==null?void 0:A.changeType]);if(D)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:[e.jsx(ns,{className:"w-8 h-8 text-re-red animate-spin"}),e.jsx("p",{className:"text-slate-600",children:"Loading request details..."})]});if(!A)return e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-8 text-center",children:[e.jsx("h2",{className:"text-slate-900 mb-2",children:"Request Not Found"}),e.jsx("p",{className:"text-slate-600 mb-4",children:"The constitutional change request you're looking for doesn't exist."}),e.jsx(se,{onClick:s,children:"Go Back"})]});const xe=T2(A.changeType),ce=E2[xe]||[],ve=Te=>{const ct=A.documents||[],tt=Wc[Te];return ct.find(jt=>{const Ht=Number(jt==null?void 0:jt.docNumber);return!!(!Number.isNaN(Ht)&&Ht===Te||tt&&typeof(jt==null?void 0:jt.name)=="string"&&jt.name.includes(tt))})},Pe=Te=>{const ct=ve(Te);return!!ct&&String(ct.status||"")!=="Rejected"},kt=(()=>{let Te=A.currentStage||"";if(["Rejected","Revoked","Withdrawn"].includes(A.status)&&(Te==="Rejected"||Te==="Revoked"||!Te)){const jt=[...A.timeline||[]].reverse().find(Ht=>Ht.stage&&!["Rejected","Revoked","REJECTED","REVOKED"].includes(Ht.stage));jt&&(Te=jt.stage)}const ct={"ASM Review":1,"ZM/RBM Review":2,"ZM+RBM Review":2,"ZBH Review":3,"DD Lead Review":4,"DD Head Review":5,"NBH Approval":6,"Legal Review":7,Completed:8};if(ct[Te])return ct[Te];const tt=Te.trim().toLowerCase();for(const[jt,Ht]of Object.entries(ct))if(jt.toLowerCase()===tt||jt.toLowerCase().includes(tt)||tt.includes(jt.toLowerCase()))return Ht;return 1})(),vt=A.currentStage==="Completed"||String(A.status||"")==="Completed"&&!["Rejected","Revoked"].includes(String(A.currentStage||"")),ee=kd(A.status,A.currentStage),ge=gl(A.status,A.currentStage),ye=Xb(A.status,A.currentStage),Be=Te=>{const tt={Submitted:["Submitted","Draft"],"ASM Review":["ASM Review"],"ZM/RBM Review":["ZM/RBM Review","ZM+RBM Review","ZM Review","RBM Review"],"ZBH Review":["ZBH Review"],"DD Lead Review":["DD Lead Review","Lead Review"],"DD Head Review":["DD Head Review","Head Review"],"NBH Approval":["NBH Approval"],"Legal Review":["Legal Review"],Completed:["Completed"]}[Te]||[Te],jt=(A.timeline||[]).filter(Ht=>{const zt=String(Ht.stage||Ht.targetStage||"").trim();return tt.includes(zt)});return jt.length?jt[jt.length-1]:null},dt=(()=>{var on,Ye;if(!A||!n)return{canApprove:!1,canReject:!1,canSendBack:!1,canRevoke:!1,isFinalState:!1,hasCurrentUserApprovedZmRbm:!1};const Te=A.currentStage,ct=A.status,tt=n.role||n.roleCode,jt=String(n.roleCode||n.role||"").trim().toUpperCase(),Ht=["Completed","Rejected","Revoked"].includes(String(ct||""))||["Rejected","Revoked","Completed"].includes(String(Te||"")),zt=_m.find(Ot=>Ot.name===Te||Ot.key===Te),fs=Te==="Submitted",qt=n.roleCode==="SUPER_ADMIN"||fs&&(tt==="ASM"||n.roleCode==="ASM")||!fs&&((zt==null?void 0:zt.role)==="ASM"&&tt==="ASM"||((zt==null?void 0:zt.role)==="ZM/RBM"||(zt==null?void 0:zt.role)==="ZM+RBM")&&(tt==="DD-ZM"||tt==="RBM")||(zt==null?void 0:zt.role)==="ZBH"&&tt==="ZBH"||(zt==null?void 0:zt.role)==="DD Lead"&&tt==="DD Lead"||(zt==null?void 0:zt.role)==="DD Head"&&tt==="DD Head"||(zt==null?void 0:zt.role)==="NBH"&&tt==="NBH"||(zt==null?void 0:zt.role)==="Legal Team"&&tt==="Legal Admin"),As=["ZBH","DD Lead","DD Head","NBH"],vs=qt&&!Ht&&(n.roleCode==="SUPER_ADMIN"||As.includes(tt))&&Te!=="Legal Review"&&Te!=="Submitted";let cs=A.metadata||{};if(typeof cs=="string")try{cs=JSON.parse(cs)}catch(Ot){console.error("Failed to parse metadata",Ot),cs={}}const mn=((on=cs==null?void 0:cs.jointApprovals)==null?void 0:on.zmRbm)||{},qs=Te==="ZM/RBM Review"||Te==="ZM+RBM Review",ln=jt==="RBM"?"RBM":jt==="DD-ZM"||jt==="DD ZM"||jt==="ZM"?"DD-ZM":null,fn=qs&&ln&&!!((Ye=mn==null?void 0:mn[ln])!=null&&Ye.approvedByUserId);return{canApprove:qt&&!Ht&&!fn,canReject:qt&&!Ht&&!fn,canSendBack:vs,canRevoke:vs,isFinalState:Ht,hasCurrentUserApprovedZmRbm:fn}})(),st=(Bs=A.dealer)==null?void 0:Bs.dealerProfile,xt=st==null?void 0:st.application,Mt=((xt==null?void 0:xt.loiRequests)||[]).find(Te=>/approved/i.test(String((Te==null?void 0:Te.status)||""))),It=((xt==null?void 0:xt.loaRequests)||[]).find(Te=>/approved/i.test(String((Te==null?void 0:Te.status)||""))),he=(st==null?void 0:st.loiDate)??(Mt==null?void 0:Mt.approvedAt),pt=(st==null?void 0:st.loaDate)??(It==null?void 0:It.approvedAt),ht=Te=>{m(Te),Z(null),o(!0)},_e=async Te=>{var jt,Ht,zt;Te.preventDefault();const ct=String(f||"").trim();if((d==="sendBack"||d==="revoke")&&ct.length<5){te.error("Detailed remarks (minimum 5 characters) are required for Send Back and Revoke actions.");return}if(!ct&&d!=="approve"){te.error("Remarks are required for this action.");return}try{$(!0),Z(null);const fs=d==="approve"?Em.APPROVE:d==="reject"?Em.REJECT:d==="sendBack"?Em.SEND_BACK:Em.REVOKE,qt=await Ee.updateConstitutionalChange(t,fs,{comments:f}),As=qt==null?void 0:qt.data;if(qt!=null&&qt.ok&&(As!=null&&As.success)){const mn=d==="approve"?"approved":d==="reject"?"rejected":d==="sendBack"?"sent back":"revoked";te.success(`Request ${mn} successfully`),o(!1),p(""),Z(null),await J();return}const vs=(As==null?void 0:As.message)||((jt=qt==null?void 0:qt.data)==null?void 0:jt.error)||"Failed to submit action";Z(vs);const cs=/mandatory documents/i.test(vs);te.error(vs,{duration:cs?14e3:8e3})}catch(fs){console.error("Submit action error:",fs);const qt=((zt=(Ht=fs==null?void 0:fs.response)==null?void 0:Ht.data)==null?void 0:zt.message)||(fs==null?void 0:fs.message)||"Failed to submit action";Z(qt),te.error(qt,{duration:/mandatory documents/i.test(qt)?14e3:8e3})}finally{$(!1)}},Vt=async()=>{var Te,ct,tt;if(!u||!v){te.error("Please select document type and file");return}try{U(!0);const jt=Array.isArray(A.documents)?[...A.documents]:[],zt=u!==Ho?jt.findIndex(As=>Number(As==null?void 0:As.docNumber)===u):-1,fs={id:((ct=(Te=globalThis.crypto)==null?void 0:Te.randomUUID)==null?void 0:ct.call(Te))??`doc-${Date.now()}-${u}`,docNumber:u,name:Wc[u]||"Other",fileName:v.name,status:"Pending Verification",uploadedOn:new Date().toISOString(),uploadedBy:(n==null?void 0:n.name)||"Dealer"};zt>=0?jt[zt]={...jt[zt],...fs}:jt.push(fs),(tt=(await Ee.uploadConstitutionalDocuments(t,jt)).data)!=null&&tt.success?(te.success("Document uploaded successfully"),x(!1),N(null),w(null),await J({silent:!0})):te.error("Failed to upload document")}catch(jt){console.error("Upload document error:",jt),te.error("Failed to upload document")}finally{U(!1)}},Pt=(Te,ct)=>(Te==null?void 0:Te.id)!=null?String(Te.id):String(ct),_s=async(Te,ct)=>{var tt,jt;try{const Ht=Pt(Te,ct),zt=await Ee.verifyConstitutionalDocument(t,Ht);(tt=zt.data)!=null&&tt.success?(te.success("Document verified successfully"),await J({silent:!0}),A!=null&&A.id&&await X(A.id)):te.error(((jt=zt.data)==null?void 0:jt.message)||"Failed to verify document")}catch(Ht){console.error("Verify document error:",Ht),te.error("Failed to verify document")}},Ys=async()=>{var ct,tt;if(T==null||!String(B).trim()){te.error("Please enter a rejection reason.");return}const Te=((A==null?void 0:A.documents)||[])[T];if(!Te){te.error("Document not found");return}try{H(!0);const jt=Pt(Te,T),Ht=await Ee.rejectConstitutionalDocument(t,jt,{remarks:B.trim()});(ct=Ht.data)!=null&&ct.success?(te.success("Document marked as rejected"),z(!1),I(null),G(""),await J({silent:!0}),A!=null&&A.id&&await X(A.id)):te.error(((tt=Ht.data)==null?void 0:tt.message)||"Failed to reject document")}catch(jt){console.error("Reject document error:",jt),te.error("Failed to reject document")}finally{H(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(se,{variant:"outline",onClick:s,className:"flex items-center gap-2",children:[e.jsx(Jr,{className:"w-4 h-4"}),"Back"]}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-slate-900",children:[A.requestId," - Constitutional Change Details"]}),e.jsxs("p",{className:"text-slate-600",children:[((Qs=(Ks=A.dealer)==null?void 0:Ks.dealerProfile)==null?void 0:Qs.businessName)||((Xs=A.outlet)==null?void 0:Xs.name)||"N/A"," (",((oe=(Q=($s=A.dealer)==null?void 0:$s.dealerProfile)==null?void 0:Q.dealerCode)==null?void 0:oe.dealerCode)||((we=A.outlet)==null?void 0:we.code)||"N/A",")"]})]})]}),e.jsx(Ce,{className:ye,children:A.status}),e.jsx(kr,{status:r("constitutional",t)})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Request Overview"})}),e.jsxs(Fe,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"Dealer Details"}),e.jsx("p",{className:"text-slate-900",children:((ke=(Oe=A.dealer)==null?void 0:Oe.dealerProfile)==null?void 0:ke.businessName)||((je=A.outlet)==null?void 0:je.name)||"N/A"}),e.jsx("p",{className:"text-slate-600 text-sm",children:((nt=(Ge=(Ve=A.dealer)==null?void 0:Ve.dealerProfile)==null?void 0:Ge.dealerCode)==null?void 0:nt.dealerCode)||((Zt=A.outlet)==null?void 0:Zt.code)||"N/A"}),e.jsx("p",{className:"text-slate-600 text-sm",children:((lt=(Jt=A.dealer)==null?void 0:Jt.dealerProfile)==null?void 0:lt.registeredAddress)||((mt=A.outlet)==null?void 0:mt.city)||((Ds=A.outlet)==null?void 0:Ds.address)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-2",children:"Constitutional Change"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:_2(A.oldValue||A.currentConstitution||((ss=A.outlet)==null?void 0:ss.type)||"Proprietorship"),children:A.oldValue||A.currentConstitution||((Ae=A.outlet)==null?void 0:Ae.type)||"Proprietorship"}),e.jsx(Ko,{className:"w-4 h-4 text-slate-400"}),e.jsx(Ce,{className:_2(A.newValue||A.changeType),children:A.newValue||A.changeType})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"Request Information"}),e.jsxs("p",{className:"text-slate-900 text-sm",children:["Submitted: ",Yt(A.createdAt)]}),e.jsxs("p",{className:"text-slate-600 text-sm",children:["By: ",((be=A.dealer)==null?void 0:be.fullName)||"Dealer"]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-slate-600 text-sm",children:"Current Stage:"}),e.jsx(Ce,{className:eo(A.currentStage,A.status),children:A.currentStage})]})]})]}),e.jsxs("div",{className:"mt-6",children:[e.jsx("p",{className:"text-slate-600 text-sm mb-2",children:"Reason for Change"}),e.jsx("p",{className:"text-slate-900",children:A.description})]})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Establishment & Dealer Codes"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"Sales Code"}),e.jsx("p",{className:"text-slate-900",children:((yt=(He=(ut=A.dealer)==null?void 0:ut.dealerProfile)==null?void 0:He.dealerCode)==null?void 0:yt.salesCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"Service Code"}),e.jsx("p",{className:"text-slate-900",children:((ts=(es=(ft=A.dealer)==null?void 0:ft.dealerProfile)==null?void 0:es.dealerCode)==null?void 0:ts.serviceCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"GMA Code"}),e.jsx("p",{className:"text-slate-900",children:((rn=(Us=(Cs=A.dealer)==null?void 0:Cs.dealerProfile)==null?void 0:Us.dealerCode)==null?void 0:rn.gmaCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"Gear Code"}),e.jsx("p",{className:"text-slate-900",children:((hn=(an=(Js=A.dealer)==null?void 0:Js.dealerProfile)==null?void 0:an.dealerCode)==null?void 0:hn.gearCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"Inauguration Date"}),e.jsx("p",{className:"text-slate-900",children:(bt=(De=A.dealer)==null?void 0:De.dealerProfile)!=null&&bt.onboardedAt?Yt(A.dealer.dealerProfile.onboardedAt,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"LOI Date"}),e.jsx("p",{className:"text-slate-900",children:he?Yt(he,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"LOA Date"}),e.jsx("p",{className:"text-slate-900",children:pt?Yt(pt,"date"):"N/A"})]})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx("div",{className:"lg:col-span-2 space-y-6",children:e.jsx(Le,{children:e.jsxs(Bn,{value:C,onValueChange:S,className:"w-full",children:[e.jsx(Qe,{className:"pb-4",children:e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim -mx-6 px-6",children:e.jsxs($n,{className:"w-max min-w-full justify-start",children:[e.jsx(Wt,{value:"workflow",children:"Workflow Progress"}),e.jsx(Wt,{value:"documents",children:"Documents"}),e.jsx(Wt,{value:"history",children:"History & Audit Trail"})]})})}),e.jsxs(Fe,{children:[e.jsxs(Ut,{value:"workflow",className:"mt-0 status-progress-ui",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-slate-900",children:"Overall Progress"}),e.jsxs(Ce,{className:`${ge} text-white border-transparent hover:opacity-90`,children:[A.progressPercentage,"% Complete"]})]}),e.jsx("div",{className:"h-3 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-500 ${ge}`,style:{width:`${A.progressPercentage}%`}})})]}),ee&&e.jsxs("div",{className:"mb-4 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-800",children:["This request is closed as ",e.jsx("strong",{children:String(A.status)}),". The approval path below is for reference only."]}),e.jsx("div",{className:"space-y-4",children:ee?e.jsx("ul",{className:"list-disc space-y-1 pl-5 text-sm text-slate-600",children:_m.map(Te=>e.jsxs("li",{children:[e.jsx("span",{className:"text-slate-900",children:D2(Te.name)})," — ",R2(Te.role)]},Te.id))}):_m.map((Te,ct)=>{var ln;const tt=vt||ct<kt-1,jt=!vt&&ct===kt-1,Ht=Be(Te.name),zt=(Ht==null?void 0:Ht.comments)||(Ht==null?void 0:Ht.feedback)||(Ht==null?void 0:Ht.remarks),fs=Te.name==="ZM/RBM Review";let qt=A.metadata||{};if(typeof qt=="string")try{qt=JSON.parse(qt)}catch{qt={}}const As=((ln=qt==null?void 0:qt.jointApprovals)==null?void 0:ln.zmRbm)||{},vs=As==null?void 0:As.RBM,cs=As==null?void 0:As["DD-ZM"],mn=String((n==null?void 0:n.roleCode)||(n==null?void 0:n.role)||"").toUpperCase(),qs=mn==="RBM"?vs:mn==="DD-ZM"||mn==="DD ZM"||mn==="ZM"?cs:null;return e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${tt?"bg-green-100":jt?Oi.icon:"bg-slate-100"}`,children:tt?e.jsx(Zn,{className:"w-5 h-5 text-green-600"}):jt?e.jsx(vn,{className:"w-5 h-5 text-re-red"}):e.jsx(sn,{className:"w-5 h-5 text-slate-400"})}),ct<_m.length-1&&e.jsx("div",{className:`w-0.5 h-12 ${tt?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:`flex-1 pb-8 ${jt?Oi.panel:""}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:`${jt?Oi.title:"text-slate-900"}`,children:D2(Te.name)}),e.jsx("p",{className:`text-sm ${jt?Oi.subtitle:"text-slate-600"}`,children:`Responsible: ${R2(Te.role)}`})]}),e.jsx(Ce,{className:tt?"bg-green-100 text-green-700 border-green-300":jt?Oi.stageBadge:"bg-slate-100 text-slate-500 border-slate-300",children:tt?"Completed":jt?"In Progress":"Pending"})]}),Ht&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-600",children:[e.jsxs(Ce,{variant:"outline",className:"text-[11px] normal-case",children:["Last updated by: ",Ht.user||Ht.userName||"System"]}),e.jsx("span",{children:Yt(Ht.timestamp||Ht.createdAt)})]}),zt&&e.jsx("div",{className:"p-2 rounded border border-slate-200 bg-slate-50 text-sm text-slate-700",children:zt})]}),fs&&e.jsxs("div",{className:"mt-3 rounded-md border border-slate-200 bg-slate-50 p-3",children:[e.jsx("p",{className:"text-xs text-slate-600 mb-2",children:"Joint approval status"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(Ce,{className:vs!=null&&vs.approvedByUserId?"bg-green-100 text-green-700 border-green-300":"bg-slate-100 text-slate-500 border-slate-300",children:["RBM: ",vs!=null&&vs.approvedByUserId?"Approved":"Pending"]}),e.jsxs(Ce,{className:cs!=null&&cs.approvedByUserId?"bg-green-100 text-green-700 border-green-300":"bg-slate-100 text-slate-500 border-slate-300",children:["DD-ZM: ",cs!=null&&cs.approvedByUserId?"Approved":"Pending"]}),(qs==null?void 0:qs.approvedByUserId)&&e.jsx(Ce,{className:"bg-blue-100 text-blue-700 border-blue-300",children:"Approved by you"})]}),((vs==null?void 0:vs.remarks)||(cs==null?void 0:cs.remarks))&&e.jsxs("div",{className:"mt-3 grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsxs("div",{className:"rounded border border-slate-200 bg-white p-2",children:[e.jsx("p",{className:"text-[11px] text-slate-500 mb-1",children:"RBM Comment"}),e.jsx("p",{className:"text-sm text-slate-700",children:(vs==null?void 0:vs.remarks)||"-"})]}),e.jsxs("div",{className:"rounded border border-slate-200 bg-white p-2",children:[e.jsx("p",{className:"text-[11px] text-slate-500 mb-1",children:"DD-ZM Comment"}),e.jsx("p",{className:"text-sm text-slate-700",children:(cs==null?void 0:cs.remarks)||"-"})]})]})]})]})]},Te.id)})})]}),e.jsx(Ut,{value:"documents",className:"mt-0",children:e.jsxs(Bn,{value:R,onValueChange:_,className:"w-full",children:[e.jsxs($n,{className:"w-full justify-start mb-4",children:[e.jsx(Wt,{value:"required",children:"Required for Process"}),e.jsx(Wt,{value:"existing",children:"Existing Documents"})]}),e.jsx(Ut,{value:"required",className:"mt-0",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("h4",{className:"text-slate-900",children:"Document Checklist"}),e.jsxs(ds,{open:h,onOpenChange:Te=>{x(Te),Te||(b(!1),w(null))},children:[e.jsx(co,{asChild:!0,children:e.jsxs(se,{size:"sm",className:"bg-re-red hover:bg-re-red-hover",onClick:()=>{b(!1),N(null),w(null)},children:[e.jsx(or,{className:"w-4 h-4 mr-2"}),"Upload Document"]})}),e.jsxs(os,{children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Upload Document"}),e.jsx(bs,{children:j?"Pick a file for the selected document.":"Select the document type and upload the file."})]}),e.jsxs("div",{className:"space-y-4",children:[j&&u!=null?e.jsxs("div",{children:[e.jsx(de,{children:"Document"}),e.jsx("div",{className:"mt-1 flex items-center gap-2 bg-red-50 border border-red-200 rounded-md px-3 h-10",children:e.jsx(Ce,{className:"bg-re-red text-white border-transparent",children:Wc[u]||`Document ${u}`})})]}):e.jsxs("div",{children:[e.jsx(de,{children:"Document Type"}),e.jsxs("select",{className:"mt-1 flex h-10 w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm ring-offset-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-re-red focus-visible:ring-offset-2",value:u!=null?String(u):"",onChange:Te=>{const ct=Te.target.value;N(ct?Number(ct):null)},children:[e.jsx("option",{value:"",children:"Select document type"}),le.map(Te=>e.jsxs("option",{value:String(Te),children:[Te!==Ho&&Pe(Te)?"✓ ":"",Wc[Te]||`Document ${Te}`]},Te))]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Upload File"}),e.jsx(at,{type:"file",className:"mt-1",onChange:Te=>{var ct;return w(((ct=Te.target.files)==null?void 0:ct[0])||null)}})]})]}),e.jsxs(bn,{children:[e.jsx(se,{variant:"outline",onClick:()=>x(!1),children:"Cancel"}),e.jsx(se,{className:"bg-re-red hover:bg-re-red-hover",onClick:Vt,disabled:W,children:W?"Uploading...":"Upload"})]})]})]})]}),e.jsx("div",{className:"space-y-2",children:ce.map(Te=>{const ct=ve(Te),tt=ct&&String(ct.status)==="Rejected",jt=ct&&!tt;return e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${tt?"bg-red-50 border-red-200":jt?"bg-green-50 border-green-200":"bg-slate-50 border-slate-200"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[tt?e.jsx(sn,{className:"w-5 h-5 text-red-600"}):jt?e.jsx(Zn,{className:"w-5 h-5 text-green-600"}):e.jsx(sn,{className:"w-5 h-5 text-slate-400"}),e.jsxs("div",{children:[e.jsx("p",{className:tt?"text-red-900":jt?"text-green-900":"text-slate-900",children:Wc[Te]}),ct&&e.jsxs("p",{className:tt?"text-red-700 text-sm":jt?"text-green-700 text-sm":"text-slate-600 text-sm",children:[ct.fileName||ct.name,tt&&(ct.rejectionReason||ct.rejectionRemarks)?` — ${ct.rejectionReason||ct.rejectionRemarks}`:""]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[ct?e.jsx(Ce,{className:Ov(ct.status),children:ct.status}):e.jsx(Ce,{className:"bg-slate-100 text-slate-600 border-slate-300",children:"Not Uploaded"}),!jt&&e.jsxs(se,{size:"sm",variant:"ghost",className:YG(!!tt),onClick:()=>{N(Te),w(null),b(!0),x(!0)},children:[e.jsx(or,{className:"w-3.5 h-3.5 mr-1"}),tt?"Re-upload":"Upload"]})]})]},Te)})})]})}),e.jsx(Ut,{value:"existing",className:"mt-0",children:(A.documents||[]).length>0?e.jsxs("div",{children:[e.jsx("h4",{className:"text-slate-900 mb-3",children:"All Uploaded Documents"}),e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Document Name"}),e.jsx(fe,{children:"File Name"}),e.jsx(fe,{children:"Uploaded On"}),e.jsx(fe,{children:"Uploaded By"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Os,{children:(A.documents||[]).map((Te,ct)=>{var tt;return e.jsxs(it,{className:String(Te.status)==="Rejected"?"bg-red-50/80":void 0,children:[e.jsx(ue,{className:"text-slate-900",children:Te.docNumber?Wc[Te.docNumber]:Te.name}),e.jsx(ue,{className:"text-slate-600",children:Te.fileName||Te.name}),e.jsx(ue,{className:"text-slate-600",children:Yt(Te.uploadedOn||Te.createdAt)}),e.jsx(ue,{className:"text-slate-600",children:typeof Te.uploadedBy=="string"?Te.uploadedBy:((tt=Te.uploadedBy)==null?void 0:tt.fullName)||"Dealer"}),e.jsx(ue,{children:e.jsx(Ce,{className:Ov(Te.status),children:Te.status})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{size:"sm",variant:"outline",className:"h-8 w-8 p-0",title:"View document",children:e.jsx(yn,{className:"w-4 h-4"})}),e.jsx(se,{size:"sm",variant:"outline",className:"h-8 w-8 p-0",title:"Download document",children:e.jsx(ji,{className:"w-4 h-4"})}),Te.status!=="Verified"&&Te.status!=="Rejected"&&(()=>{const jt=(n==null?void 0:n.role)||(n==null?void 0:n.roleCode)||"";return["DD Lead","DD Head","NBH","Legal Admin","DD Admin","Super Admin","SUPER_ADMIN","DD_ADMIN"].includes(jt)})()&&e.jsxs(e.Fragment,{children:[e.jsx(se,{size:"sm",className:"bg-green-600 hover:bg-green-700",onClick:()=>_s(Te,ct),children:"Verify"}),e.jsx(se,{size:"sm",variant:"outline",className:"border-red-300 text-red-700 hover:bg-red-50",onClick:()=>{I(ct),G(""),z(!0)},children:"Reject"})]})]})})]},ct)})})]})})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded yet"})})]})}),e.jsx(Ut,{value:"history",className:"mt-0",children:e.jsxs("div",{className:"space-y-4",children:[ae.map((Te,ct)=>{var fn;const tt=ZG(Te),Ht=(((fn=Te.actor)==null?void 0:fn.name)||Te.userName||"System").split("·").map(on=>on.trim()),zt=[...new Set(Ht)].join(", "),As=String(Te.stage||Te.action||"").trim().replace(/\[Master data\]\s*/i,"").replace(/Constitutional change [A-Z0-9-]+ (completed|updated):/i,"$1:").replace(/dealer constitution updated from "(.*)" to "(.*)"\.?/i,'"$1" → "$2"').trim()||tt.badge||"Action",vs=String(Te.remarks||"").trim(),cs=String(Te.description||"").trim(),qs=[/^Approval\s*-\s*Stage:/i,/^Record (created|updated)/i,/^Document (uploaded|verified|rejected)/i].some(on=>on.test(cs)),ln=vs||(qs?"":cs)||null;return e.jsxs("div",{className:"flex items-start gap-4 pb-4 border-b border-slate-200 last:border-0",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0 ${tt.variant==="success"?"bg-green-100":tt.variant==="danger"?"bg-red-100":tt.variant==="pending"?"bg-red-50":"bg-slate-100"}`,children:tt.variant==="success"?e.jsx(Zn,{className:"w-5 h-5 text-green-600"}):tt.variant==="danger"?e.jsx(sn,{className:"w-5 h-5 text-red-600"}):tt.variant==="pending"?e.jsx(vn,{className:"w-5 h-5 text-re-red"}):e.jsx(vn,{className:"w-5 h-5 text-slate-500"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-slate-900 capitalize",children:As}),e.jsxs("p",{className:"text-slate-500 text-sm",children:["by ",e.jsx("span",{className:"font-medium text-slate-700",children:zt})]})]}),e.jsx(Ce,{className:Ov(tt.badge),children:tt.badge.replace(/_/g," ")})]}),ln&&e.jsx("div",{className:"mt-2 p-3 bg-slate-50 rounded border border-slate-100 text-slate-700 text-sm",children:ln}),e.jsx("p",{className:"text-slate-400 text-xs mt-2 font-medium uppercase tracking-wider",children:Yt(Te.timestamp||Te.createdAt)})]})]},Te.id||ct)}),ae.length===0&&e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No history found"})]})})]})]})})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Current Status"})}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Current Stage"}),e.jsx(Ce,{className:eo(A.currentStage,A.status),children:A.currentStage})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Progress"}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-300 ${ge}`,style:{width:`${A.progressPercentage??0}%`}})}),e.jsxs("span",{className:"text-slate-900",children:[A.progressPercentage??0,"%"]})]})]})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Actions"})}),e.jsxs(Fe,{className:"space-y-3",children:[dt.canApprove&&e.jsxs(se,{className:"w-full bg-green-600 hover:bg-green-700",onClick:()=>ht("approve"),disabled:L,children:[L&&d==="approve"?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Zn,{className:"w-4 h-4 mr-2"}),"Approve Request"]}),!dt.canApprove&&dt.hasCurrentUserApprovedZmRbm&&e.jsxs(se,{variant:"outline",className:"w-full border-green-300 text-green-700 bg-green-50 cursor-not-allowed",disabled:!0,children:[e.jsx(Zn,{className:"w-4 h-4 mr-2"}),"Approved by you"]}),dt.canReject&&e.jsxs(se,{variant:"destructive",className:"w-full",onClick:()=>ht("reject"),disabled:L,children:[L&&d==="reject"?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(sn,{className:"w-4 h-4 mr-2"}),"Reject proposal"]}),dt.canSendBack&&e.jsxs(se,{variant:"outline",className:"w-full border-red-300 text-red-900 hover:bg-red-50",onClick:()=>ht("sendBack"),disabled:L,children:[L&&d==="sendBack"?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(aM,{className:"w-4 h-4 mr-2"}),"Send back"]}),dt.canRevoke&&e.jsxs(se,{variant:"outline",className:"w-full border-red-300 text-re-red-hover hover:bg-red-50",onClick:()=>ht("revoke"),disabled:L,children:[L&&d==="revoke"?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Jy,{className:"w-4 h-4 mr-2"}),"Revoke request"]}),!dt.canApprove&&!dt.canReject&&!dt.canSendBack&&!dt.canRevoke&&e.jsx("div",{className:"text-center py-4 bg-slate-50 rounded-lg border border-dashed border-slate-200",children:e.jsx("p",{className:"text-slate-500 text-xs px-4",children:dt.isFinalState?"This request is finalized.":"No actions available for your role at this stage."})}),e.jsx("div",{className:"border-t border-slate-200 pt-3 mt-3",children:e.jsxs(se,{variant:"outline",className:"w-full border-blue-700 text-blue-800 hover:bg-blue-50",onClick:()=>{var Te;return a(`/worknotes/constitutional/${(A==null?void 0:A.id)||t}`,{state:{requestType:"constitutional",applicationName:((Te=A==null?void 0:A.outlet)==null?void 0:Te.name)||"Constitutional Change",registrationNumber:(A==null?void 0:A.requestId)||t||"",participants:(A==null?void 0:A.participants)||[]}})},children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"Worknotes (",((A==null?void 0:A.worknotes)||[]).length,")"]})})]})]})]})]}),e.jsx(ds,{open:i,onOpenChange:Te=>{o(Te),Te||Z(null)},children:e.jsxs(os,{children:[e.jsxs(xs,{children:[e.jsx(ms,{children:d==="approve"?"Approve request":d==="reject"?"Reject proposal":d==="sendBack"?"Send back to previous stage":"Revoke request"}),e.jsx(bs,{children:d==="sendBack"||d==="revoke"?"SRS §12.2.3: remarks are mandatory and will be posted to Work Notes for Send Back / Revoke.":"Comments will be recorded in the audit trail and work notes where applicable."})]}),e.jsxs("form",{onSubmit:_e,className:"space-y-4",children:[Y&&e.jsxs("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-900 flex gap-2",children:[e.jsx(sn,{className:"w-5 h-5 shrink-0 text-red-600","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium",children:"This action was not completed"}),e.jsx("p",{className:"mt-1 whitespace-pre-wrap break-words",children:Y}),/mandatory documents/i.test(Y)&&e.jsxs("p",{className:"mt-2 text-red-800",children:["Use the ",e.jsx("strong",{children:"Documents"})," tab to upload every required file for this constitution type, then approve again."]})]})]}),e.jsx("div",{children:e.jsx(de,{htmlFor:"comments",children:d==="sendBack"||d==="revoke"?"Remarks (required) *":"Comments *"})}),e.jsx(Ws,{id:"comments",value:f,onChange:Te=>p(Te.target.value),placeholder:d==="sendBack"||d==="revoke"?"Enter mandatory remarks for Work Notes…":"Enter your comments…",rows:4,required:d!=="approve"}),e.jsxs(bn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(se,{type:"submit",className:d==="approve"?"bg-green-600 hover:bg-green-700":"bg-re-red hover:bg-re-red-hover",disabled:L,children:L?e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}),"Processing..."]}):d==="approve"?"Approve":d==="reject"?"Reject":d==="sendBack"?"Send back":"Revoke"})]})]})]})}),e.jsx(ds,{open:M,onOpenChange:z,children:e.jsxs(os,{children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Reject document"}),e.jsx(bs,{children:"Mark this upload as rejected and provide a reason. The action is recorded in the audit trail."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(de,{htmlFor:"rejectReason",children:"Rejection reason *"}),e.jsx(Ws,{id:"rejectReason",rows:4,value:B,onChange:Te=>G(Te.target.value),placeholder:"Explain what must be corrected or re-uploaded…"})]}),e.jsxs(bn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>z(!1),children:"Cancel"}),e.jsx(se,{type:"button",variant:"destructive",disabled:K,onClick:()=>void Ys(),children:K?e.jsx(ns,{className:"w-4 h-4 animate-spin"}):"Confirm reject"})]})]})})]})}const XG=(t,s)=>{var n,r,a;return((r=(n=t==null?void 0:t.response)==null?void 0:n.data)==null?void 0:r.message)||((a=t==null?void 0:t.data)==null?void 0:a.message)||(t==null?void 0:t.message)||s},Lv=(t,s)=>eo(t,s);function JG({currentUser:t,onViewDetails:s}){const[n,r]=g.useState([]),[a,i]=g.useState(!0),[o,d]=g.useState(1),[m,f]=g.useState(null),[p,h]=g.useState("all"),x=10,[u,N]=g.useState(!1),[v,w]=g.useState([]),[j,b]=g.useState(null),[C,S]=g.useState(""),[R,_]=g.useState(""),[A,E]=g.useState(""),[q,O]=g.useState(""),[D,P]=g.useState(""),[L,$]=g.useState(""),[Y,Z]=g.useState(""),[W,U]=g.useState(""),[M,z]=g.useState(""),[T,I]=g.useState(!1),[B,G]=g.useState([]),[K,H]=g.useState([]),[X,J]=g.useState(""),[ae,le]=g.useState(""),[xe,ce]=g.useState(!1),ve=(t==null?void 0:t.role)==="Super Admin"||(t==null?void 0:t.roleCode)==="Super Admin",Pe=n.map(he=>({entityType:"relocation",entityId:he.id||he.requestId})),{get:et}=pc(Pe,n.length>0),kt=he=>he.status==="Completed"||he.status==="Closed"||he.currentStage==="Completed",vt=he=>he.status==="Rejected"||he.status==="Revoked"||he.currentStage==="Rejected",ee=he=>!kt(he)&&!vt(he)&&String(he.status||"").startsWith("Pending");g.useEffect(()=>{Mt()},[o,p]),g.useEffect(()=>{ve&&(ye(),Be())},[ve]);const ge=he=>{h(he),d(1)},ye=async()=>{var he;try{const pt=await Ee.getOutlets();pt.data.success&&w(pt.data.outlets||((he=pt.data.data)==null?void 0:he.outlets)||pt.data.data||[])}catch(pt){console.error("Fetch outlets error:",pt)}},Be=async()=>{var he,pt,ht,_e;try{ce(!0);const[Vt,Pt]=await Promise.all([Ee.getStates().catch(()=>({success:!1})),Ee.getDistricts({limit:"all"}).catch(()=>({success:!1}))]),_s=(he=Vt==null?void 0:Vt.data)!=null&&he.success?((pt=Vt.data.data)==null?void 0:pt.states)||Vt.data.data||[]:[],Ys=(ht=Pt==null?void 0:Pt.data)!=null&&ht.success?((_e=Pt.data.data)==null?void 0:_e.districts)||Pt.data.data||[]:[];G(_s),H(Ys)}catch(Vt){console.error("Fetch master data error:",Vt)}finally{ce(!1)}},$e=he=>{J(he),le("");const pt=B.find(ht=>ht.id===he);pt&&_(pt.name)},dt=he=>{le(he);const pt=K.find(ht=>ht.id===he);pt&&S(pt.name)},st=async he=>{if(he.preventDefault(),!j||!C||!R||!A||!q||!D||!L||!Y){te.error("Please fill all mandatory fields");return}try{I(!0);const pt={outletId:j.id,relocationType:"Intercity",currentAddress:j.address||"",currentCity:j.city||"",currentState:j.state||"",newAddress:A,newCity:C,newState:R,newDistrictId:ae||null,newStateId:X||null,reason:q,distance:D,propertyType:L,proposedDate:Y,newLatitude:W?parseFloat(W):null,newLongitude:M?parseFloat(M):null,currentLatitude:j.latitude||null,currentLongitude:j.longitude||null};(await Ee.createRelocationRequest(pt)).data.success&&(te.success(`Relocation request submitted successfully for ${j.name}`),N(!1),Mt(),b(null),S(""),_(""),E(""),O(""),P(""),$(""),Z(""),U(""),z(""))}catch(pt){console.error("Submit relocation error:",pt),te.error(XG(pt,"Failed to submit relocation request"))}finally{I(!1)}},xt=X?K.filter(he=>he.stateId===X):K,Mt=async()=>{try{i(!0);const he=await Ee.getRelocationRequests({page:o,limit:x,status:p==="all"?void 0:p});he.data.success&&(r(he.data.requests),f(he.meta))}catch(he){console.error("Fetch relocation requests error:",he),te.error("Failed to fetch relocation requests")}finally{i(!1)}},It=[{title:"Total Requests",value:n.length,icon:Ns,color:"bg-blue-500"},{title:"Pending Review",value:n.filter(he=>ee(he)).length,icon:dr,color:"bg-re-red"},{title:"Completed",value:n.filter(he=>kt(he)).length,icon:Vr,color:"bg-green-500"},{title:"Rejected / Revoked",value:n.filter(he=>vt(he)).length,icon:id,color:"bg-red-500"}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 mb-2",children:"Relocation Request Management"}),e.jsx("p",{className:"text-slate-600",children:"Manage dealer relocation requests - Moving dealership to a new location"}),e.jsx("span",{className:"block mt-1 text-slate-500 text-sm",children:"• Note: Relocation requests are initiated by the dealer."})]}),ve&&e.jsxs(ds,{open:u,onOpenChange:N,children:[e.jsx(co,{asChild:!0,children:e.jsxs(se,{className:"bg-re-red hover:bg-re-red-hover text-white",children:[e.jsx(An,{className:"w-4 h-4 mr-2"}),"New Relocation Request"]})}),e.jsxs(os,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Submit Relocation Request"}),e.jsx(bs,{children:"Create a new relocation request on behalf of a dealer"})]}),e.jsxs("form",{onSubmit:st,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"outlet",children:"Select Outlet to Relocate *"}),e.jsxs(Dt,{value:j==null?void 0:j.id,onValueChange:he=>b(v.find(pt=>pt.id===he)),required:!0,children:[e.jsx(Et,{children:e.jsx(Rt,{placeholder:"Select an outlet"})}),e.jsx(_t,{children:v.map(he=>e.jsxs(Me,{value:he.id,children:[he.name," (",he.code,")"]},he.id))})]})]}),j&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-lg p-4 space-y-2 text-sm",children:[e.jsx("h3",{className:"text-slate-900 font-medium",children:"Current Location"}),e.jsxs("p",{className:"text-slate-600",children:[j.address,", ",j.city,", ",j.state," - ",j.pincode]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"newState",children:"Proposed State *"}),e.jsxs(Dt,{value:X,onValueChange:$e,required:!0,disabled:xe,children:[e.jsx(Et,{id:"newState",children:e.jsx(Rt,{placeholder:xe?"Loading...":"Select state"})}),e.jsx(_t,{children:B.map(he=>e.jsx(Me,{value:he.id,children:he.name},he.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"newCity",children:"Proposed City/District *"}),e.jsxs(Dt,{value:ae,onValueChange:dt,required:!0,disabled:!X||xe,children:[e.jsx(Et,{id:"newCity",children:e.jsx(Rt,{placeholder:X?xe?"Loading...":"Select district":"Select state first"})}),e.jsx(_t,{children:xt.map(he=>e.jsx(Me,{value:he.id,children:he.name},he.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"newAddress",children:"Proposed Full Address *"}),e.jsx(Ws,{id:"newAddress",placeholder:"Enter detailed address of the proposed new location...",value:A,onChange:he=>E(he.target.value),rows:3,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"distance",children:"Estimated Distance from Current Location (in km) *"}),e.jsx(at,{id:"distance",type:"text",placeholder:"e.g. 5.5 km",value:D,onChange:he=>P(he.target.value),required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"propertyType",children:"Property Type *"}),e.jsxs(Dt,{value:L,onValueChange:$,required:!0,children:[e.jsx(Et,{id:"propertyType",children:e.jsx(Rt,{placeholder:"Select type"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"Owned",children:"Owned"}),e.jsx(Me,{value:"Leased",children:"Leased"}),e.jsx(Me,{value:"Rented",children:"Rented"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"expectedDate",children:"Expected Relocation Date *"}),e.jsx(at,{id:"expectedDate",type:"date",value:Y,onChange:he=>Z(he.target.value),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"reason",children:"Reason for Relocation *"}),e.jsx(Ws,{id:"reason",placeholder:"Why is this relocation requested?",value:q,onChange:he=>O(he.target.value),rows:4,required:!0})]}),e.jsxs(bn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>N(!1),children:"Cancel"}),e.jsx(se,{type:"submit",className:"bg-re-red hover:bg-re-red-hover text-white",disabled:T,children:T?e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Relocation Request"})]})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:It.map((he,pt)=>{const ht=he.icon;return e.jsx(Le,{children:e.jsx(Fe,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:he.title}),e.jsx("p",{className:"text-slate-900 text-2xl mt-1",children:he.value})]}),e.jsx("div",{className:`${he.color} w-12 h-12 rounded-lg flex items-center justify-center`,children:e.jsx(ht,{className:"w-6 h-6 text-white"})})]})})},pt)})}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"Relocation Requests"}),e.jsx(Xt,{children:"Track and manage all dealership relocation requests across all stages"})]}),e.jsxs(Fe,{children:[e.jsxs(Bn,{value:p,onValueChange:ge,className:"w-full",children:[e.jsxs($n,{className:"grid w-full grid-cols-4",children:[e.jsx(Wt,{value:"all",children:"All Requests"}),e.jsx(Wt,{value:"pending",children:"Pending Review"}),e.jsx(Wt,{value:"rejected",children:"Rejected / Revoked"}),e.jsx(Wt,{value:"completed",children:"Completed"})]}),e.jsx(Ut,{value:"all",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Relocation Details"}),e.jsx(fe,{children:"Distance"}),e.jsx(fe,{children:"Current Stage"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Submitted On"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Os,{children:a?e.jsx(it,{children:e.jsx(ue,{colSpan:8,className:"h-32 text-center",children:e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-2",children:[e.jsx(ns,{className:"w-6 h-6 text-re-red animate-spin"}),e.jsx("p",{className:"text-slate-500 text-sm",children:"Loading requests..."})]})})}):n.length===0?e.jsx(it,{children:e.jsx(ue,{colSpan:8,className:"h-32 text-center text-slate-500",children:"No relocation requests found"})}):n.map(he=>{var pt,ht,_e;return e.jsxs(it,{children:[e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:he.requestId||he.id}),e.jsx("div",{className:"text-slate-600 text-sm",children:((pt=he.outlet)==null?void 0:pt.code)||he.dealerCode})]}),e.jsx(ue,{children:e.jsx("div",{className:"font-medium text-slate-900",children:((ht=he.outlet)==null?void 0:ht.name)||he.dealerName})}),e.jsx(ue,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1 text-slate-600 text-sm",children:[e.jsx("span",{className:"text-slate-500",children:"From:"}),e.jsx("span",{children:he.currentLocation})]}),e.jsxs("div",{className:"flex items-center gap-1 text-slate-900 text-sm",children:[e.jsx(mk,{className:"w-3 h-3 text-re-red"}),e.jsx("span",{className:"text-slate-500",children:"To:"}),e.jsx("span",{children:he.proposedLocation})]})]})}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",className:"border-slate-300 text-slate-700",children:he.distance})}),e.jsxs(ue,{children:[e.jsx(kr,{status:et("relocation",he.id||he.requestId),compact:!0}),e.jsx(Ce,{className:Lv(he.currentStage,he.status),children:he.currentStage})]}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-300 ${gl(he.status,he.currentStage)}`,style:{width:`${he.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-slate-600 text-sm",children:[he.progressPercentage||0,"%"]})]})}),e.jsxs(ue,{children:[e.jsx("div",{className:"text-slate-900",children:Yt(he.createdAt)}),e.jsxs("div",{className:"text-slate-600 text-sm",children:["By ",((_e=he.dealer)==null?void 0:_e.fullName)||"Dealer"]})]}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(he.id),children:[e.jsx(yn,{className:"w-4 h-4 mr-1"}),"View"]})})]},he.id)})})]})})}),e.jsx(Ut,{value:"pending",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Relocation Details"}),e.jsx(fe,{children:"Current Stage"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Os,{children:a?e.jsx(it,{children:e.jsx(ue,{colSpan:5,className:"h-32 text-center",children:e.jsx(ns,{className:"w-6 h-6 text-re-red animate-spin mx-auto"})})}):n.filter(he=>ee(he)).map(he=>{var pt,ht;return e.jsxs(it,{children:[e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:he.requestId||he.id}),e.jsx("div",{className:"text-slate-600 text-sm",children:((pt=he.outlet)==null?void 0:pt.code)||he.dealerCode})]}),e.jsx(ue,{children:e.jsx("div",{className:"font-medium text-slate-900",children:((ht=he.outlet)==null?void 0:ht.name)||he.dealerName})}),e.jsx(ue,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-slate-600 text-sm",children:["From: ",he.currentLocation]}),e.jsxs("div",{className:"text-slate-900 text-sm",children:["To: ",he.proposedLocation]})]})}),e.jsxs(ue,{children:[e.jsx(kr,{status:et("relocation",he.id||he.requestId),compact:!0}),e.jsx(Ce,{className:Lv(he.currentStage,he.status),children:he.currentStage})]}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(he.id),children:[e.jsx(yn,{className:"w-4 h-4 mr-1"}),"View"]})})]},he.id)})})]})})}),e.jsx(Ut,{value:"in-progress",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Relocation Details"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Current Stage"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Os,{children:a?e.jsx(it,{children:e.jsx(ue,{colSpan:6,className:"h-32 text-center",children:e.jsx(ns,{className:"w-6 h-6 text-re-red animate-spin mx-auto"})})}):n.filter(he=>vt(he)).map(he=>{var pt,ht;return e.jsxs(it,{children:[e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:he.requestId||he.id}),e.jsx("div",{className:"text-slate-600 text-sm",children:((pt=he.outlet)==null?void 0:pt.code)||he.dealerCode})]}),e.jsx(ue,{children:e.jsx("div",{className:"font-medium text-slate-900",children:((ht=he.outlet)==null?void 0:ht.name)||he.dealerName})}),e.jsx(ue,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-slate-600 text-sm",children:["From: ",he.currentLocation]}),e.jsxs("div",{className:"text-slate-900 text-sm",children:["To: ",he.proposedLocation]})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-300 ${gl(he.status,he.currentStage)}`,style:{width:`${he.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-slate-600 text-sm",children:[he.progressPercentage||0,"%"]})]})}),e.jsxs(ue,{children:[e.jsx(kr,{status:et("relocation",he.id||he.requestId),compact:!0}),e.jsx(Ce,{className:Lv(he.currentStage,he.status),children:he.currentStage})]}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(he.id),children:[e.jsx(yn,{className:"w-4 h-4 mr-1"}),"View"]})})]},he.id)})})]})})}),e.jsx(Ut,{value:"completed",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Relocation Details"}),e.jsx(fe,{children:"Submitted On"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Os,{children:a?e.jsx(it,{children:e.jsx(ue,{colSpan:5,className:"h-32 text-center",children:e.jsx(ns,{className:"w-6 h-6 text-re-red animate-spin mx-auto"})})}):n.filter(he=>kt(he)).map(he=>{var pt,ht;return e.jsxs(it,{children:[e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:he.requestId||he.id}),e.jsx("div",{className:"text-slate-600 text-sm",children:((pt=he.outlet)==null?void 0:pt.code)||he.dealerCode})]}),e.jsx(ue,{children:e.jsx("div",{className:"font-medium text-slate-900",children:((ht=he.outlet)==null?void 0:ht.name)||he.dealerName})}),e.jsx(ue,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-slate-600 text-sm",children:["From: ",he.currentLocation]}),e.jsxs("div",{className:"text-slate-900 text-sm",children:["To: ",he.proposedLocation]})]})}),e.jsx(ue,{children:e.jsx("div",{className:"text-slate-900",children:Yt(he.createdAt)})}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(he.id),children:[e.jsx(yn,{className:"w-4 h-4 mr-1"}),"View"]})})]},he.id)})})]})})})]}),m&&m.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center bg-white rounded-b-lg",children:e.jsx(fo,{children:e.jsxs(po,{children:[e.jsx(Sn,{children:e.jsx(xo,{onClick:()=>d(he=>Math.max(1,he-1)),className:o===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(m.totalPages)].map((he,pt)=>{const ht=pt+1;return ht===1||ht===m.totalPages||ht>=o-1&&ht<=o+1?e.jsx(Sn,{children:e.jsx(Vi,{isActive:o===ht,onClick:()=>d(ht),className:"cursor-pointer",children:ht})},ht):ht===2&&o>3||ht===m.totalPages-1&&o<m.totalPages-2?e.jsx(Sn,{children:e.jsx(vo,{})},ht):null}),e.jsx(Sn,{children:e.jsx(go,{onClick:()=>d(he=>Math.min(m.totalPages,he+1)),className:o===m.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})]})}const Sa=[{id:1,name:"ASM Review",key:"ASM_REVIEW",role:"ASM"},{id:2,name:"RBM Review",key:"RBM_REVIEW",role:"RBM"},{id:3,name:"DD ZM Review",key:"DD_ZM_REVIEW",role:"DD-ZM"},{id:4,name:"ZBH Review",key:"ZBH_REVIEW",role:"ZBH"},{id:5,name:"DD Lead Review",key:"DD_LEAD_REVIEW",role:"DD Lead"},{id:6,name:"NBH Approval",key:"NBH_APPROVAL",role:"NBH"},{id:7,name:"Legal Clearance",key:"LEGAL_CLEARANCE",role:"Legal Admin"},{id:8,name:"Relocation Complete",key:"COMPLETED",role:"System"}];function Py(t){const s=String(t||"").trim().replace(/\u00a0/g," ");if(!s||s==="Submitted")return 0;const n=s.toLowerCase();if(["completed","relocation complete","closed"].includes(n))return Sa.length+1;const r=s.match(/^pending\s+(.+)$/i),a=(r?r[1]:s).trim();let i=Sa.findIndex(o=>o.name===a||o.name===s||o.key===a||o.key===s);return i<0&&(i=Sa.findIndex(o=>a.toLowerCase().includes(o.name.toLowerCase())||o.name.toLowerCase().includes(a.toLowerCase()))),i>=0?i+1:0}function eK(t){const s=String(t||"").toLowerCase();return!!(s.includes("sent back")||s.includes("send")&&s.includes("back"))}function tK(t){const s=String((t==null?void 0:t.action)||"");return!!(/document\s*verified/i.test(s)||/document/i.test(s)&&/upload/i.test(s))}function sT(t,s){if(tK(s))return t;const n=String((s==null?void 0:s.action)||"");if(eK(n)){const a=Py(String((s==null?void 0:s.targetStage)||""));return a>0?a:t}let r=t;for(const a of[s==null?void 0:s.targetStage,s==null?void 0:s.stage].filter(Boolean)){const i=Py(String(a));i>r&&(r=i)}return r}function sK(t){const s=[...t||[]].filter(Boolean).sort((r,a)=>new Date((r==null?void 0:r.timestamp)||(r==null?void 0:r.createdAt)||0).getTime()-new Date((a==null?void 0:a.timestamp)||(a==null?void 0:a.createdAt)||0).getTime());let n=0;for(const r of s)n=sT(n,r);return n}function nK(t){const s=[...t||[]].filter(Boolean).sort((r,a)=>new Date((r==null?void 0:r.createdAt)||(r==null?void 0:r.timestamp)||0).getTime()-new Date((a==null?void 0:a.createdAt)||(a==null?void 0:a.timestamp)||0).getTime());let n=0;for(const r of s){const a=String((r==null?void 0:r.action)||"");if(a==="DOCUMENT_UPLOADED"||a==="DOCUMENT_VERIFIED")continue;const i=(r==null?void 0:r.details)||(r==null?void 0:r.newData)||{},o=[a,i==null?void 0:i.action,String((i==null?void 0:i.type)||"")].filter(Boolean).join(" ");n=sT(n,{action:o,stage:(i==null?void 0:i.stage)!==void 0?String(i.stage):(r==null?void 0:r.stage)!==void 0?String(r.stage):void 0,targetStage:(i==null?void 0:i.targetStage)!==void 0?String(i.targetStage):void 0})}return n}function rK(t,s,n){const a=(Array.isArray(t)?[...t]:[]).filter(i=>{const o=String((i==null?void 0:i.stage)||"").trim();return o===s.name||o===s.key||n===0&&(o==="Submitted"||o==="Request submitted")});return a.sort((i,o)=>{const d=new Date((i==null?void 0:i.timestamp)||(i==null?void 0:i.createdAt)||0).getTime(),m=new Date((o==null?void 0:o.timestamp)||(o==null?void 0:o.createdAt)||0).getTime();return d-m}),a}const Gc=["Property documents for new location","Lease/Rental agreement for new location","NOC from current landlord","Municipal approvals","Fire safety certificate","Pollution clearance","Layout/Floor plan of new location","Photos of new location","Locality map","Building plan approval","Electricity connection documents","Water supply documents"],P2=t=>UE(t),aK=t=>t?"h-7 px-2 text-red-700 hover:bg-red-50 hover:text-red-800 flex-shrink-0":"h-7 px-2 text-slate-700 hover:bg-slate-50 flex-shrink-0",Uo=(t,s)=>{var r,a,i;const n=((r=t==null?void 0:t.response)==null?void 0:r.data)||(t==null?void 0:t.data);if(n!=null&&n.readiness){const o=((a=n.readiness)==null?void 0:a.missingUploads)||[],d=((i=n.readiness)==null?void 0:i.pendingVerification)||[],m=[o.length?`Missing: ${o.join(", ")}`:"",d.length?`Pending verification: ${d.join(", ")}`:""].filter(Boolean).join(" | ");return m?`${n.message||s} (${m})`:n.message||s}return(n==null?void 0:n.message)||(t==null?void 0:t.message)||s};function iK({requestId:t,onBack:s,currentUser:n}){var je,Ve,Ge,nt,Zt,Jt,lt,mt,Ds,ss;const{get:r}=pc(t?[{entityType:"relocation",entityId:t}]:[],!!t),a=tr(),[i,o]=g.useState(null),[d,m]=g.useState([]),[f,p]=g.useState(!0),[h,x]=g.useState(!1),[u,N]=g.useState(!1),[v,w]=g.useState("approve"),[j,b]=g.useState(""),[C,S]=g.useState(!1),[R,_]=g.useState(null),[A,E]=g.useState(!1),[q,O]=g.useState(!1),[D,P]=g.useState(null),[L,$]=g.useState(Gc[0]),[Y,Z]=g.useState(!1),[W,U]=g.useState(!1),[M,z]=g.useState("workflow"),[T,I]=g.useState(!1),[B,G]=g.useState(null),[K,H]=g.useState(!1),[X,J]=g.useState(null),[ae,le]=g.useState(""),[xe,ce]=g.useState(!1);g.useEffect(()=>{vt(),ve()},[t]);const ve=async()=>{try{const Ae=await Ee.getAuditLogs("relocation",t);Ae.data&&Ae.data.success&&m(Ae.data.data||[])}catch(Ae){console.error("Error fetching audit logs:",Ae)}},Pe=async Ae=>{try{E(!0);const be=Ae||(i==null?void 0:i.id)||t,ut=await Ee.getEorChecklistForRelocation(be);ut.data.success&&_(ut.data.data)}catch(be){console.error("Fetch EOR checklist error:",be)}finally{E(!1)}},et=async(Ae,be,ut)=>{if(R)try{(await Ee.updateEorChecklistItem(R.id,{description:Ae,isCompliant:be,itemType:ut,remarks:""})).data.success&&Pe()}catch(He){console.error("Update EOR item error:",He),te.error(Uo(He,"Failed to update item"))}},kt=async()=>{if(R)try{O(!0),(await Ee.submitEorAudit(R.id,{status:"Completed",overallComments:"Relocation EOR Audit Completed"})).data.success&&(te.success("EOR Audit submitted successfully"),vt(),Pe())}catch(Ae){console.error("Submit EOR audit error:",Ae),te.error(Uo(Ae,"Failed to submit EOR audit"))}finally{O(!1)}},vt=async(Ae=!1)=>{try{Ae||p(!0);const be=await Ee.getRelocationRequestById(t);if(be.data.success){const ut=be.data.request;o(ut)}}catch(be){console.error("Fetch relocation request details error:",be),te.error(Uo(be,"Failed to fetch request details"))}finally{p(!1)}},ee=()=>{if(!i)return 1;if(i.status==="Completed"||i.currentStage==="Completed")return Sa.length+1;if(i.status==="Rejected"||i.status==="Revoked"||i.status==="Withdrawn"){const He=[...i.timeline||[]].filter(Boolean).reverse();for(const yt of He){const ft=String(yt.stage||"").trim(),es=String(yt.targetStage||"").trim(),ts=Sa.findIndex(Cs=>Cs.name===ft||Cs.key===es||Cs.key===ft||Cs.name===es);if(ts>=0)return ts+1}return 1}const Ae=i.currentStage,be=Sa.findIndex(He=>He.name===Ae||He.key===Ae||He.name.replace(/\s+/g," ")===String(Ae||"").replace(/\s+/g," "));if(be>=0)return be+1;const ut=Py(String(i.status||""));return ut>0?ut:1},ge=Array.isArray(i==null?void 0:i.timeline)?i.timeline:[],ye=sK(ge),Be=nK(d),$e=i?ee():1,dt=!!i&&Math.max(ye,Be)>$e&&(ge.length>0||d.length>0),st=i?Sa[Math.min(Math.max($e,1),Sa.length)-1]:void 0,xt=(i==null?void 0:i.status)==="Completed"||(i==null?void 0:i.currentStage)==="Completed"||$e>=Sa.length+1,Mt=xt?100:Math.min(100,Math.round($e/Sa.length*100)),It=xt?100:Mt,he=i?kd(i.status,i.currentStage):!1,pt=i?gl(i.status,i.currentStage):"bg-status-progress",ht=i?Xb(i.status,i.currentStage):"bg-re-red hover:bg-re-red-hover text-white border-transparent",_e=i?Gc.filter(Ae=>{var be;return!((be=i.documents)!=null&&be.some(ut=>ut.type===Ae||ut.name&&ut.name.toLowerCase().includes(Ae.toLowerCase().split(" ")[0])))}):[],Vt=i?Gc.filter(Ae=>{var ut;const be=((ut=i.documents)==null?void 0:ut.filter(He=>He.type===Ae||He.name&&He.name.toLowerCase().includes(Ae.toLowerCase().split(" ")[0])))||[];return be.length>0&&!be.some(He=>He.status==="Verified")}):[],Pt=Ae=>{var ut,He,yt;if(!i||!i.participants||i.participants.length===0)return null;const be=i.participants.find(ft=>{var es,ts;return((es=ft.metadata)==null?void 0:es.stage)===Ae||((ts=ft.metadata)==null?void 0:ts.stage)===Ae.toUpperCase().replace(/ /g,"_")});return be&&(((ut=be.user)==null?void 0:ut.fullName)||((He=be.user)==null?void 0:He.name)||((yt=be.user)==null?void 0:yt.role))||null},Ys=(!i||!n?!1:(n==null?void 0:n.role)==="Super Admin"||n.role==="Super Admin"?!0:!!(st!=null&&st.role&&n.role===st.role))&&i.status!=="Completed"&&i.status!=="Rejected"&&i.status!=="Revoked",Bs=Ys&&i.currentStage&&i.currentStage!=="ASM Review"&&i.currentStage!=="Rejected",Ks=Ys&&["ZBH","DD Lead","NBH","Legal Admin","Super Admin"].includes((n==null?void 0:n.role)||""),Qs=(i==null?void 0:i.currentStage)==="NBH Approval"||(i==null?void 0:i.currentStage)==="Legal Clearance",Xs=Ys&&(!Qs||_e.length===0&&Vt.length===0),$s=Ae=>{w(Ae),N(!0)},Q=async Ae=>{Ae.preventDefault();const be=String(j||"").trim();if((v==="sendBack"||v==="revoke")&&be.length<5){te.error(`Remarks are required for ${v==="sendBack"?"Send Back":"Revoke"} (minimum 5 characters).`);return}try{x(!0);const ft={approve:"approve",reject:"reject",hold:"hold",sendBack:"sendBack",revoke:"revoke"}[v]||"approve";if((await Ee.updateRelocationRequest(t,ft,{remarks:be})).data.success){const ts=v==="sendBack"?"sent back":v==="revoke"?"revoked":`${v}ed`;te.success(`Request ${ts} successfully`),N(!1),b(""),vt(),ve(),v==="approve"&&(st==null?void 0:st.key)==="LEGAL_CLEARANCE"&&(i!=null&&i.id)&&Pe(i.id)}}catch(yt){console.error("Submit action error:",yt),te.error(Uo(yt,"Failed to submit action"))}finally{x(!1)}},oe=async()=>{if(!D||!L){te.error("Please select both a document type and a file");return}try{U(!0);const Ae=new FormData;Ae.append("file",D),Ae.append("documentType",L),Ae.append("stage",i.currentStage),(await Ee.uploadRelocationDocument(t,Ae)).data.success&&(te.success("Document uploaded successfully"),S(!1),P(null),vt(!0),ve())}catch(Ae){console.error("Upload document error:",Ae),te.error(Uo(Ae,"Failed to upload document"))}finally{U(!1)}},we=async Ae=>{try{(await Ee.verifyRelocationDocument(t,Ae)).data.success&&(te.success("Document verified successfully"),vt(!0),ve())}catch(be){console.error("Verify document error:",be),te.error(Uo(be,"Failed to verify document"))}},Oe=async()=>{var Ae,be;if(!X||!String(ae).trim()){te.error("Please enter a rejection reason.");return}try{ce(!0);const ut=await Ee.rejectRelocationDocument(t,X,{remarks:ae.trim()});(Ae=ut.data)!=null&&Ae.success?(te.success("Document rejected successfully"),H(!1),J(null),le(""),vt(!0),ve()):te.error(((be=ut.data)==null?void 0:be.message)||"Failed to reject document")}catch(ut){console.error("Reject document error:",ut),te.error(Uo(ut,"Failed to reject document"))}finally{ce(!1)}},ke=Ae=>{G({fileName:Ae.name,filePath:Ae.url,documentType:Ae.type,createdAt:Ae.uploadedOn,mimeType:Ae.mimeType}),I(!0)};return f?e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:[e.jsx(ns,{className:"w-10 h-10 text-re-red animate-spin"}),e.jsx("p",{className:"text-slate-500 font-medium",children:"Loading request details..."})]}):i?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(se,{variant:"outline",onClick:s,className:"flex items-center gap-2",children:[e.jsx(Jr,{className:"w-4 h-4"}),"Back"]}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-slate-900",children:[i.requestId," - Relocation Request Details"]}),e.jsxs("p",{className:"text-slate-600",children:[(je=i.outlet)==null?void 0:je.name," (",(Ve=i.outlet)==null?void 0:Ve.code,")"]}),e.jsx("div",{className:"mt-1",children:e.jsx(kr,{status:r("relocation",t)})})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(se,{variant:"outline",className:"relative hover:bg-red-50 hover:border-red-300 hover:text-re-red-hover transition-all shadow-sm",onClick:()=>{var Ae;return a(`/worknotes/relocation/${t}`,{state:{applicationName:((Ae=i==null?void 0:i.outlet)==null?void 0:Ae.name)||"Relocation",registrationNumber:(i==null?void 0:i.requestId)||"",participants:(i==null?void 0:i.participants)||[]}})},children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"View Work Notes",((Ge=i==null?void 0:i.worknotes)==null?void 0:Ge.length)>0&&e.jsx(Ce,{className:"ml-2 bg-re-red hover:bg-re-red-hover text-white h-5 px-2",children:i.worknotes.length})]}),e.jsx(Ce,{className:ht,children:i.status})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Relocation Overview"})}),e.jsxs(Fe,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"Dealer Details"}),e.jsx("p",{className:"text-slate-900",children:(nt=i.outlet)==null?void 0:nt.name}),e.jsx("p",{className:"text-slate-600 text-sm",children:(Zt=i.outlet)==null?void 0:Zt.code}),e.jsx("p",{className:"text-slate-600 text-xs mt-1",children:(Jt=i.dealer)==null?void 0:Jt.fullName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-2",children:"Relocation Route"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vr,{className:"w-4 h-4 text-slate-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-xs",children:"From (Current)"}),e.jsx("p",{className:"text-slate-900 text-sm",children:i.currentLocation||(i.outlet?`${i.outlet.address}, ${i.outlet.city}`:"N/A")})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mk,{className:"w-4 h-4 text-re-red"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-xs",children:"To (Proposed)"}),e.jsx("p",{className:"text-slate-900 text-sm",children:i.proposedLocation||`${i.newAddress}, ${i.newCity}`})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(Ce,{variant:"outline",className:"border-slate-300 text-slate-700",children:["Type: ",i.relocationType]}),i.distance&&e.jsxs(Ce,{variant:"outline",className:"border-red-200 bg-red-50 text-re-red-hover",children:["Distance: ",i.distance]}),i.propertyType&&e.jsxs(Ce,{variant:"outline",className:"border-blue-200 bg-blue-50 text-blue-700",children:["Property: ",i.propertyType]}),i.expectedRelocationDate&&e.jsxs(Ce,{variant:"outline",className:"border-purple-200 bg-purple-50 text-purple-700",children:["Expected Date: ",i.expectedRelocationDate]})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"Request Information"}),e.jsxs("p",{className:"text-slate-900 text-sm",children:["Submitted: ",Yt(i.createdAt)]}),e.jsxs("p",{className:"text-slate-600 text-sm",children:["By: ",(lt=i.dealer)==null?void 0:lt.fullName]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-slate-600 text-sm",children:"Current Stage:"}),e.jsx(Ce,{className:eo(i.currentStage,i.status),children:String(i.currentStage||"").replace(/_/g," ")})]})]})]}),e.jsxs("div",{className:"mt-6",children:[e.jsx("p",{className:"text-slate-600 text-sm mb-2",children:"Reason for Relocation"}),e.jsx("p",{className:"text-slate-900",children:i.reason})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx("div",{className:"lg:col-span-2 space-y-6",children:e.jsx(Le,{children:e.jsxs(Bn,{value:M,onValueChange:z,className:"w-full",children:[e.jsx(Qe,{className:"pb-4",children:e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim -mx-6 px-6",children:e.jsxs($n,{className:"w-max min-w-full justify-start",children:[e.jsx(Wt,{value:"workflow",children:"Workflow Progress"}),e.jsx(Wt,{value:"documents",children:"Documents"}),e.jsx(Wt,{value:"history",children:"History & Audit Trail"})]})})}),e.jsxs(Fe,{children:[e.jsxs(Ut,{value:"workflow",className:"mt-0 status-progress-ui",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-slate-900",children:"Overall Progress"}),e.jsxs(Ce,{className:`${pt} text-white border-transparent hover:opacity-90`,children:[It,"% Complete"]})]}),e.jsx("div",{className:"h-3 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-500 ${pt}`,style:{width:`${It}%`}})})]}),he&&e.jsxs("div",{className:"mb-6 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-800",children:["This request is closed as ",e.jsx("strong",{children:String(i.status)}),". The approval path below is for reference only."]}),dt&&!he&&e.jsxs("div",{className:"mb-6 rounded-lg border border-red-300 bg-red-50 px-4 py-3 text-sm text-red-900",children:[e.jsx("span",{className:"font-medium",children:"Activity ahead of current stage:"})," Some timeline or audit entries reference steps after the official current stage (",String(i.currentStage),"). Per-step history below may include future steps; the highlighted step and approvals follow the server current stage only."]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-900",children:"Progress Timeline"}),e.jsx(Xt,{className:"mt-1",children:"Track the relocation approval process — activity recorded at each stage appears below that step."})]}),e.jsx("div",{className:"space-y-4",children:he?e.jsx("ul",{className:"list-disc space-y-1 pl-5 text-sm text-slate-600",children:Sa.map(Ae=>e.jsxs("li",{children:[e.jsx("span",{className:"text-slate-900",children:Ae.name})," — ",Ae.role]},Ae.id))}):Sa.map((Ae,be)=>{const ut=xt||be<$e-1,He=!xt&&be===$e-1,yt=rK(ge,Ae,be),ft=yt.length>0?yt[yt.length-1]:null;return e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${ut?"bg-green-100 text-green-600":He?Oi.icon:"bg-slate-100 text-slate-400"}`,children:ut?e.jsx(Zn,{className:"w-5 h-5"}):He?e.jsx(vn,{className:"w-5 h-5"}):e.jsx("span",{className:"text-xs font-semibold",children:Ae.id})}),be<Sa.length-1&&e.jsx("div",{className:`w-0.5 h-16 ${ut?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:`flex-1 pb-8 ${He?Oi.panel:""}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1 gap-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:ut?"text-green-700":He?Oi.title:"text-slate-900",children:Ae.name}),e.jsxs("p",{className:`text-sm ${He?Oi.subtitle:"text-slate-600"}`,children:["Responsible: ",Ae.role]}),Pt(Ae.name)&&e.jsxs("p",{className:"text-xs text-blue-600 font-medium mt-1",children:["Assigned: ",Pt(Ae.name)]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx(Ce,{className:ut?"bg-green-100 text-green-700 border-green-300":He?Oi.stageBadge:"bg-slate-100 text-slate-500 border-slate-300",children:ut?"Completed":He?"In Progress":"Pending"}),ft&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-slate-600",children:[e.jsx(dr,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:Yt(ft.timestamp||ft.createdAt)})]})]})]}),ft&&e.jsxs("div",{className:"space-y-2 mt-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Ce,{variant:"secondary",className:"bg-slate-100 text-[10px] font-bold uppercase",children:ft.user||"System"}),e.jsx("span",{className:"text-[10px] text-slate-500 italic",children:ft.action||"Update"}),ft.targetStage&&ft.targetStage!==ft.stage&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["→ ",String(ft.targetStage).replace(/_/g," ")]})]}),e.jsx("div",{className:"bg-slate-50 p-3 rounded-lg border border-slate-100 text-sm text-slate-700 shadow-sm",children:ft.remarks||ft.comments||"No remarks provided."}),yt.length>1&&e.jsxs("p",{className:"text-[10px] text-slate-500",children:[yt.length," events at this stage; showing the latest."]})]})]})]},Ae.id)})})]}),e.jsx(Ut,{value:"documents",className:"mt-0",children:e.jsxs(Bn,{defaultValue:"required",className:"w-full",children:[e.jsxs($n,{className:"w-full justify-start mb-4",children:[e.jsx(Wt,{value:"required",children:"Required for Process"}),e.jsx(Wt,{value:"existing",children:"Existing Documents"})]}),e.jsx(Ut,{value:"required",className:"mt-0",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-slate-900",children:"Required Documents"}),e.jsxs(ds,{open:C,onOpenChange:Ae=>{S(Ae),Ae||(Z(!1),P(null))},children:[e.jsx(co,{asChild:!0,children:e.jsxs(se,{size:"sm",className:"bg-re-red hover:bg-re-red-hover",onClick:()=>{Z(!1),$(Gc[0]),P(null)},children:[e.jsx(or,{className:"w-4 h-4 mr-2"}),"Upload Document"]})}),e.jsxs(os,{children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Upload Document"}),e.jsx(bs,{children:Y?"Pick a file for the selected document.":"Select the document type and upload the file."})]}),e.jsxs("div",{className:"space-y-4",children:[Y?e.jsxs("div",{children:[e.jsx(de,{children:"Document"}),e.jsx("div",{className:"mt-1 flex items-center gap-2 bg-red-50 border border-red-200 rounded-md px-3 h-10",children:e.jsx(Ce,{className:"bg-re-red text-white border-transparent",children:L})})]}):e.jsxs("div",{children:[e.jsx(de,{children:"Document Type"}),e.jsx("select",{className:"w-full mt-1 px-3 py-2 border border-slate-300 rounded-md",value:L,onChange:Ae=>$(Ae.target.value),children:Gc.map((Ae,be)=>{var He;const ut=(He=i.documents)==null?void 0:He.some(yt=>yt.type===Ae||yt.name.toLowerCase().includes(Ae.toLowerCase().split(" ")[0]));return e.jsx("option",{value:Ae,children:ut?`✅ ${Ae}`:Ae},be)})})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Upload File"}),e.jsx(at,{type:"file",className:"mt-1",onChange:Ae=>{var be;return P(((be=Ae.target.files)==null?void 0:be[0])||null)}})]})]}),e.jsxs(bn,{children:[e.jsx(se,{variant:"outline",onClick:()=>S(!1),disabled:W,children:"Cancel"}),e.jsx(se,{className:"bg-re-red hover:bg-re-red-hover",onClick:oe,disabled:W,children:W?e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}),"Uploading..."]}):"Upload"})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Gc.map((Ae,be)=>{var ft;const ut=(ft=i.documents)==null?void 0:ft.find(es=>es.type===Ae||es.name.toLowerCase().includes(Ae.toLowerCase().split(" ")[0])),He=ut&&String(ut.status)==="Rejected",yt=ut&&!He;return e.jsxs("div",{className:`flex items-center justify-between gap-2 p-2 rounded border text-sm ${He?"bg-red-50 border-red-200":yt?"bg-green-50 border-green-200":"bg-slate-50 border-slate-200"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[He?e.jsx(sn,{className:"w-4 h-4 text-red-600 flex-shrink-0"}):yt?e.jsx(Zn,{className:"w-4 h-4 text-green-600 flex-shrink-0"}):e.jsx(sn,{className:"w-4 h-4 text-slate-400 flex-shrink-0"}),e.jsx("span",{className:`truncate ${He?"text-red-900":yt?"text-green-900":"text-slate-700"}`,children:Ae})]}),!yt&&e.jsxs(se,{size:"sm",variant:"ghost",className:aK(!!He),onClick:()=>{$(Ae),P(null),Z(!0),S(!0)},children:[e.jsx(or,{className:"w-3.5 h-3.5 mr-1"}),He?"Re-upload":"Upload"]})]},be)})})]})}),e.jsx(Ut,{value:"existing",className:"mt-0",children:i.documents&&i.documents.length>0?e.jsxs("div",{children:[e.jsx("h4",{className:"text-slate-900 mb-3",children:"All Uploaded Documents"}),e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Document Name"}),e.jsx(fe,{children:"Category"}),e.jsx(fe,{children:"Uploaded On"}),e.jsx(fe,{children:"Uploaded By"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Os,{children:i.documents.map(Ae=>e.jsxs(it,{className:String(Ae.status)==="Rejected"?"bg-red-50/80":void 0,children:[e.jsx(ue,{className:"text-slate-900",children:Ae.name}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",className:"border-slate-300",children:Ae.category||"General"})}),e.jsx(ue,{className:"text-slate-600",children:Yt(Ae.uploadedOn)}),e.jsx(ue,{className:"text-slate-600",children:Ae.uploadedBy}),e.jsx(ue,{children:e.jsx(Ce,{className:P2(Ae.status),children:Ae.status})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{size:"icon",variant:"outline",className:"h-8 w-8",onClick:()=>Ae.url&&ke(Ae),disabled:!Ae.url,title:Ae.url?"View Document":"File path not available",children:e.jsx(yn,{className:"w-4 h-4"})}),e.jsx(se,{size:"icon",variant:"outline",className:"h-8 w-8",onClick:()=>Ae.url&&window.open(`http://localhost:5000/${Ae.url}`,"_blank"),disabled:!Ae.url,title:Ae.url?"Download Document":"File path not available",children:e.jsx(ji,{className:"w-4 h-4"})}),Ae.status==="Pending Verification"&&(()=>{const be=(n==null?void 0:n.role)||(n==null?void 0:n.roleCode)||"";return["DD Lead","NBH","Legal Admin","DD Admin","Super Admin","SUPER_ADMIN","DD_ADMIN"].includes(be)})()&&e.jsxs(e.Fragment,{children:[e.jsxs(se,{size:"sm",className:"h-8 bg-green-600 hover:bg-green-700 text-white gap-1",onClick:()=>we(Ae.id),title:"Verify Document",children:[e.jsx(Zn,{className:"w-4 h-4"}),"Verify"]}),e.jsxs(se,{size:"sm",variant:"destructive",className:"h-8 gap-1",onClick:()=>{J(Ae.id),le(""),H(!0)},title:"Reject Document",children:[e.jsx(sn,{className:"w-4 h-4"}),"Reject"]})]})]})})]},Ae.id))})]})})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded yet"})})]})}),e.jsx(Ut,{value:"eor",className:"mt-0",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-slate-900",children:"EOR Readiness Checklist"}),e.jsx("p",{className:"text-slate-600 text-sm",children:"Verify new location infrastructure and statutory compliances"}),e.jsx("p",{className:"text-slate-500 text-xs mt-1 max-w-2xl",children:"When document types match a checklist line, proofs from the Documents tab are linked here automatically (same files; no separate EOR upload required)."})]}),R&&e.jsx(Ce,{className:P2(R.status),children:R.status})]}),R?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{className:"bg-slate-50",children:[e.jsx(fe,{className:"w-[50px]"}),e.jsx(fe,{children:"Category"}),e.jsx(fe,{children:"Checklist Item"}),e.jsx(fe,{children:"Proof & Documents"})]})}),e.jsx(Os,{children:!R.items||R.items.length===0?e.jsx(it,{children:e.jsx(ue,{colSpan:4,className:"text-center text-slate-500 py-8 text-sm",children:'No checklist rows returned. Use "Try Refreshing" above or reload the page.'})}):R.items.map(Ae=>e.jsxs(it,{children:[e.jsx(ue,{children:e.jsx("input",{type:"checkbox",checked:Ae.isCompliant,onChange:be=>et(Ae.description,be.target.checked,Ae.itemType),disabled:R.status==="Completed"||(n==null?void 0:n.role)!=="NBH"&&(n==null?void 0:n.role)!=="Super Admin",className:"w-4 h-4 rounded border-slate-300 text-re-red"})}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",className:"border-slate-300 capitalize text-xs",children:Ae.itemType})}),e.jsx(ue,{className:"text-slate-900 font-medium text-sm",children:Ae.description}),e.jsx(ue,{children:e.jsx("div",{className:"flex flex-col items-start gap-1",children:Ae.proofDocumentId&&Ae.proofDocument?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-slate-600 truncate max-w-[220px]",title:Ae.proofDocument.fileName,children:Ae.proofDocument.fileName}),e.jsxs(se,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-blue-600 px-0",onClick:()=>ke({name:Ae.proofDocument.fileName,url:Ae.proofDocument.filePath,type:Ae.proofDocument.documentType,uploadedOn:Ae.proofDocument.updatedAt||Ae.proofDocument.createdAt,mimeType:Ae.proofDocument.mimeType}),children:[e.jsx(yn,{className:"w-3.5 h-3.5 mr-1"}),"View"]})]}):Ae.proofDocumentId?e.jsx("span",{className:"text-xs text-re-red-hover",children:"Proof linked (refresh if file details are missing)"}):e.jsxs(se,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-slate-400",disabled:R.status==="Completed",children:[e.jsx(or,{className:"w-3.5 h-3.5 mr-1"}),"Upload"]})})})]},Ae.id))})]})}),((n==null?void 0:n.role)==="NBH"||(n==null?void 0:n.role)==="Super Admin")&&R.status!=="Completed"&&e.jsx("div",{className:"flex justify-end pt-4 border-t border-slate-200",children:e.jsxs(se,{className:"bg-green-600 hover:bg-green-700",onClick:kt,disabled:q||!((mt=R.items)!=null&&mt.length)||!R.items.every(Ae=>Ae.isCompliant),children:[q?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Zn,{className:"w-4 h-4 mr-2"}),"Finalize EOR & Complete Relocation"]})}),!((Ds=R.items)!=null&&Ds.every(Ae=>Ae.isCompliant))&&e.jsx("p",{className:"text-right text-xs text-re-red italic",children:"All items must be marked as compliant before final submission."})]}):e.jsx("div",{className:"bg-slate-50 border border-dashed border-slate-300 rounded-lg p-12 text-center",children:A?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(ns,{className:"w-8 h-8 text-re-red animate-spin"}),e.jsx("p",{className:"text-slate-500",children:"Fetching checklist..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(sn,{className:"w-12 h-12 text-slate-300 mx-auto mb-4"}),e.jsx("h5",{className:"text-slate-900 mb-1",children:"No Checklist Found"}),e.jsx("p",{className:"text-slate-500 text-sm mb-4",children:"The EOR checklist will be automatically initiated once the request reaches the final clearance stage."}),e.jsx(se,{variant:"outline",onClick:()=>Pe(i==null?void 0:i.id),children:"Try Refreshing"})]})})]})}),e.jsx(Ut,{value:"history",className:"mt-0",children:e.jsx("div",{className:"space-y-4",children:d.length>0?d.map((Ae,be)=>{var ut,He,yt,ft,es,ts,Cs,Us,rn,Js,an,hn;return e.jsxs("div",{className:"flex gap-4 pb-6 border-b border-slate-100 last:border-0 relative",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-slate-300 mt-2 z-10"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:`
${(Ae.description||Ae.action||((ut=Ae.details)==null?void 0:ut.action)||"").toLowerCase().includes("reject")||(Ae.description||Ae.action||((He=Ae.details)==null?void 0:He.action)||"").toLowerCase().includes("revok")?"bg-red-100 text-red-700 border-red-200":(Ae.description||Ae.action||((yt=Ae.details)==null?void 0:yt.action)||"").toLowerCase().includes("sent back")||(Ae.description||Ae.action||((ft=Ae.details)==null?void 0:ft.action)||"").toLowerCase().includes("send back")?"bg-red-50 text-re-red-hover border-red-200":(Ae.description||Ae.action||((es=Ae.details)==null?void 0:es.action)||"").toLowerCase().includes("approv")||(Ae.description||Ae.action||((ts=Ae.details)==null?void 0:ts.action)||"").toLowerCase().includes("initi")||(Ae.action||"").toLowerCase().includes("complete")?"bg-emerald-100 text-emerald-700 border-emerald-200":"bg-slate-100 text-slate-700 border-slate-200"}
`,children:Ae.action}),e.jsxs("span",{className:"text-xs text-slate-500 font-medium italic",children:["by ",((Cs=Ae.actor)==null?void 0:Cs.name)||Ae.userName||"System"]}),((Us=Ae.details)==null?void 0:Us.stage)&&e.jsxs("span",{className:"text-[10px] text-slate-400 font-normal",children:["at ",Ae.details.stage]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:Yt(Ae.timestamp||Ae.createdAt)})]}),(Ae.remarks||Ae.description||((rn=Ae.newData)==null?void 0:rn.remarks)||((Js=Ae.details)==null?void 0:Js.remarks))&&e.jsx("div",{className:"p-3 bg-slate-50 border border-slate-100 rounded-lg text-sm text-slate-700 shadow-sm ml-1",children:Ae.remarks||Ae.description||((an=Ae.newData)==null?void 0:an.remarks)||((hn=Ae.details)==null?void 0:hn.remarks)})]})]},be)}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No history found"})})})]})]})})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Current Status"})}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Current Stage"}),e.jsx(Ce,{className:eo(i.currentStage,i.status),children:i.currentStage})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Progress"}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-300 ${pt}`,style:{width:`${It}%`}})}),e.jsxs("span",{className:"text-slate-900",children:[It,"%"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Distance"}),e.jsx("p",{className:"text-slate-900",children:i.distance})]})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Actions"})}),e.jsxs(Fe,{className:"space-y-3",children:[Ys&&e.jsxs(e.Fragment,{children:[e.jsxs(se,{className:"w-full bg-green-600 hover:bg-green-700",onClick:()=>$s("approve"),disabled:h||!Xs,children:[h&&v==="approve"?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Zn,{className:"w-4 h-4 mr-2"}),"Approve Request"]}),!Xs&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-800",children:"Approval is blocked until mandatory documents are uploaded and verified for this stage."}),e.jsxs(se,{variant:"destructive",className:"w-full",onClick:()=>$s("reject"),disabled:h,children:[h&&v==="reject"?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(sn,{className:"w-4 h-4 mr-2"}),"Reject Request"]}),Bs&&e.jsxs(se,{variant:"outline",className:"w-full border-red-300 text-red-900 hover:bg-red-50",onClick:()=>$s("sendBack"),disabled:h,children:[h&&v==="sendBack"?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(YI,{className:"w-4 h-4 mr-2"}),"Send Back"]}),Ks&&e.jsxs(se,{variant:"outline",className:"w-full border-red-300 text-red-800 hover:bg-red-50",onClick:()=>$s("revoke"),disabled:h,children:[h&&v==="revoke"?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Jy,{className:"w-4 h-4 mr-2"}),"Revoke Request"]}),e.jsx("div",{className:"border-t border-slate-200 pt-3 mt-3"})]}),e.jsxs(se,{variant:"outline",className:"w-full border-blue-300 text-blue-700 hover:bg-blue-50",onClick:()=>{var Ae;return a(`/worknotes/relocation/${t}`,{state:{applicationName:((Ae=i==null?void 0:i.outlet)==null?void 0:Ae.name)||"Relocation",registrationNumber:(i==null?void 0:i.requestId)||"",participants:(i==null?void 0:i.participants)||[]}})},children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"Worknotes (",((ss=i==null?void 0:i.worknotes)==null?void 0:ss.length)||0,")"]})]})]})]})]}),e.jsx(ds,{open:u,onOpenChange:N,children:e.jsxs(os,{children:[e.jsxs(xs,{children:[e.jsx(ms,{children:v==="approve"?"Approve Request":v==="reject"?"Reject Request":v==="sendBack"?"Send Back Request":v==="revoke"?"Revoke Request":"Put Request on Hold"}),e.jsx(bs,{children:v==="sendBack"||v==="revoke"?"Remarks are required and will be recorded in Work Notes and the audit trail.":"Please provide comments for this action. This will be recorded in the audit trail."})]}),e.jsxs("form",{onSubmit:Q,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{htmlFor:"comments",children:v==="sendBack"||v==="revoke"?"Remarks *":"Comments *"}),e.jsx("div",{className:"space-y-2"})]}),e.jsx(Ws,{id:"comments",value:j,onChange:Ae=>b(Ae.target.value),placeholder:v==="sendBack"?"Explain what needs to be corrected at the previous stage…":v==="revoke"?"Document why this relocation request is being revoked…":"Enter your comments...",rows:4,required:!0}),e.jsxs(bn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>N(!1),disabled:h,children:"Cancel"}),e.jsxs(se,{type:"submit",className:v==="approve"?"bg-green-600 hover:bg-green-700":"bg-re-red hover:bg-re-red-hover",disabled:h,children:[h?e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}):null,v==="approve"?"Approve":v==="reject"?"Reject":v==="sendBack"?"Send Back":v==="revoke"?"Revoke":"Put on Hold"]})]})]})]})}),e.jsx(ds,{open:K,onOpenChange:H,children:e.jsxs(os,{children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Reject document"}),e.jsx(bs,{children:"Mark this upload as rejected and provide a reason. The action is recorded in the audit trail."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(de,{htmlFor:"rejectDocReason",children:"Rejection reason *"}),e.jsx(Ws,{id:"rejectDocReason",rows:4,value:ae,onChange:Ae=>le(Ae.target.value),placeholder:"Explain what must be corrected or re-uploaded…"})]}),e.jsxs(bn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>H(!1),children:"Cancel"}),e.jsx(se,{type:"button",variant:"destructive",disabled:xe,onClick:()=>void Oe(),children:xe?e.jsx(ns,{className:"w-4 h-4 animate-spin"}):"Confirm reject"})]})]})}),e.jsx(mo,{isOpen:T,onClose:()=>I(!1),document:B})]}):e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-8 text-center",children:[e.jsx("h2",{className:"text-slate-900 mb-2",children:"Request Not Found"}),e.jsx("p",{className:"text-slate-600 mb-4",children:"The relocation request you're looking for doesn't exist."}),e.jsx(se,{onClick:s,children:"Go Back"})]})}function lK({onViewDetails:t}){const[s,n]=g.useState(!1),[r,a]=g.useState(null),[i,o]=g.useState(""),[d,m]=g.useState(""),[f,p]=g.useState(""),[h,x]=g.useState(""),[u,N]=g.useState(""),[v,w]=g.useState([]),[j,b]=g.useState([]),[C,S]=g.useState(!0),[R,_]=g.useState(!1),[A,E]=g.useState(null);g.useEffect(()=>{q()},[]);const q=async()=>{try{S(!0);const L=await Jl.getDashboardData(),$=await tc.getResignations();w(L.outlets||[]),E(L.profile),b($.resignations||[])}catch(L){console.error("Fetch resignation data error:",L),te.error("Failed to load outlets and requests")}finally{S(!1)}},O=L=>{a(L),n(!0)},D=async L=>{if(L.preventDefault(),!i){te.error("Please select resignation type");return}if(!d||!f){te.error("Please enter last operational dates");return}if(!h.trim()){te.error("Please provide a reason for resignation");return}try{_(!0);const $={outletId:r==null?void 0:r.id,resignationType:i,lastOperationalDateSales:d,lastOperationalDateServices:f,reason:h,additionalInfo:u};await tc.createResignation($),te.success(`Resignation request submitted successfully for ${r==null?void 0:r.name}`),n(!1),q(),a(null),o(""),m(""),p(""),x(""),N("")}catch($){console.error("Submit resignation error:",$),te.error("Failed to submit resignation request")}finally{_(!1)}},P=[{title:"Total Outlets",value:v.length,icon:so,color:"bg-blue-500"},{title:"Active Outlets",value:v.filter(L=>L.status==="Active").length,icon:un,color:"bg-green-500"},{title:"Pending Resignations",value:v.filter(L=>L.status==="Pending Resignation").length,icon:vn,color:"bg-re-red"}];return e.jsxs("div",{className:"space-y-6",children:[C&&e.jsx("div",{className:"min-h-[400px] flex items-center justify-center",children:e.jsx(ns,{className:"w-8 h-8 text-re-red animate-spin"})}),!C&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 mb-2",children:"Dealership Resignation Management"}),e.jsx("p",{className:"text-slate-600",children:"Manage resignation requests for your dealerships and studios"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:P.map((L,$)=>{const Y=L.icon;return e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Je,{className:"text-sm",children:L.title}),e.jsx("div",{className:`${L.color} p-2 rounded-lg`,children:e.jsx(Y,{className:"h-4 w-4 text-white"})})]}),e.jsx(Fe,{children:e.jsx("div",{className:"text-slate-900 text-2xl",children:L.value})})]},$)})}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"My Outlets"}),e.jsx(Xt,{children:"Select an outlet to request resignation"})]}),e.jsx(Fe,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:v.map(L=>{const $=L.type==="Dealership"?so:sM,Y=L.status==="Pending Resignation",Z=j.find(W=>W.outletId===L.id&&W.status!=="Completed"&&W.status!=="Rejected");return e.jsxs("div",{className:"border border-slate-200 rounded-lg p-4 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`${L.type==="Dealership"?"bg-blue-100":"bg-purple-100"} p-2 rounded-lg`,children:e.jsx($,{className:`w-5 h-5 ${L.type==="Dealership"?"text-blue-600":"text-purple-600"}`})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900",children:L.name}),e.jsx("p",{className:"text-slate-600 text-sm",children:L.code})]})]}),e.jsx(Ce,{className:`border ${L.status==="Active"?"bg-green-100 text-green-700 border-green-300":L.status==="Pending Resignation"?"bg-red-50 text-re-red border-red-200":"bg-slate-100 text-slate-700 border-slate-300"}`,children:L.status})]}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsx(Vr,{className:"w-4 h-4 text-slate-400 mt-0.5 flex-shrink-0"}),e.jsx("div",{children:e.jsx("p",{className:"text-slate-600",children:L.location})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(dr,{className:"w-4 h-4 text-slate-400"}),e.jsxs("span",{className:"text-slate-600",children:["Outlet Code: ",L.code]})]})]}),Y?e.jsx("div",{className:"bg-red-50 border border-red-200 rounded p-3 text-sm",children:e.jsxs("p",{className:"text-slate-800",children:["Resignation in progress - ",e.jsx("span",{className:"underline cursor-pointer",onClick:()=>t&&(Z==null?void 0:Z.resignationId)&&t(Z.resignationId),children:"View Request"})]})}):e.jsxs(se,{className:"w-full bg-red-600 hover:bg-red-700",onClick:()=>O(L),children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),"Request Resignation"]})]},L.id)})})})]}),e.jsx(ds,{open:s,onOpenChange:n,children:e.jsxs(os,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Submit Resignation Request"}),e.jsx(bs,{children:"Fill in the details for your resignation request. All fields are mandatory."})]}),e.jsxs("form",{onSubmit:D,className:"space-y-4",children:[e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-lg p-4 space-y-2",children:[e.jsx("h3",{className:"text-slate-900",children:"Outlet Information"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Outlet Code:"}),e.jsx("p",{className:"text-slate-900",children:r==null?void 0:r.code})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Outlet Name:"}),e.jsx("p",{className:"text-slate-900",children:r==null?void 0:r.name})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Dealer Code:"}),e.jsx("p",{className:"text-slate-900",children:(A==null?void 0:A.dealerCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"City:"}),e.jsx("p",{className:"text-slate-900",children:r==null?void 0:r.location})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-slate-600",children:"Location:"}),e.jsx("p",{className:"text-slate-900",children:r==null?void 0:r.location})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"resignationType",children:"Resignation Type *"}),e.jsxs(Dt,{value:i,onValueChange:o,required:!0,children:[e.jsx(Et,{children:e.jsx(Rt,{placeholder:"Select resignation type"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"Voluntary",children:"Voluntary"}),e.jsx(Me,{value:"Retirement",children:"Retirement"}),e.jsx(Me,{value:"Health Issues",children:"Health Issues"}),e.jsx(Me,{value:"Business Closure",children:"Business Closure"}),e.jsx(Me,{value:"Other",children:"Other"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"lastOpDateSales",children:"Last Operational Date - Sales *"}),e.jsx(at,{id:"lastOpDateSales",type:"date",value:d,onChange:L=>m(L.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"lastOpDateServices",children:"Last Operational Date - Services *"}),e.jsx(at,{id:"lastOpDateServices",type:"date",value:f,onChange:L=>p(L.target.value),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"reason",children:"Reason for Resignation *"}),e.jsx(Ws,{id:"reason",placeholder:"Please provide detailed reason for resignation...",value:h,onChange:L=>x(L.target.value),rows:4,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"additionalInfo",children:"Additional Information (Optional)"}),e.jsx(Ws,{id:"additionalInfo",placeholder:"Any additional details...",value:u,onChange:L=>N(L.target.value),rows:3})]}),e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:[e.jsx("h4",{className:"text-re-red mb-2 font-semibold",children:"Important Information"}),e.jsxs("ul",{className:"text-slate-700 text-sm space-y-1",children:[e.jsx("li",{children:"• F&F settlement process will be initiated after submission"}),e.jsx("li",{children:"• All department clearances must be obtained"}),e.jsx("li",{children:"• Final settlement will be processed after closure"}),e.jsx("li",{children:"• Please ensure all documents are ready for submission"})]})]}),e.jsxs(bn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>{n(!1),a(null)},children:"Cancel"}),e.jsx(se,{type:"submit",className:"bg-red-600 hover:bg-red-700",disabled:R,children:R?e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Resignation Request"})]})]})]})}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"My Resignation Requests"}),e.jsx(Xt,{children:"View your submitted resignation requests"})]}),e.jsx(Fe,{children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Outlet"}),e.jsx(fe,{children:"Type"}),e.jsx(fe,{children:"Submitted On"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Os,{children:j.length===0?e.jsx(it,{children:e.jsx(ue,{colSpan:5,className:"text-center py-4 text-slate-500",children:"No resignation requests found"})}):j.map(L=>{var $;return e.jsxs(it,{children:[e.jsx(ue,{className:"font-medium text-slate-900",children:L.resignationId}),e.jsx(ue,{children:($=L.outlet)==null?void 0:$.name}),e.jsx(ue,{children:L.resignationType}),e.jsx(ue,{children:Yt(L.submittedOn)}),e.jsx(ue,{children:e.jsxs(se,{variant:"ghost",size:"sm",onClick:()=>t&&t(L.resignationId),children:[e.jsx(yn,{className:"w-4 h-4 mr-1"}),"View"]})})]},L.id)})})]})})]})]})]})}var oK=Symbol("radix.slottable");function cK(t){const s=({children:n})=>e.jsx(e.Fragment,{children:n});return s.displayName=`${t}.Slottable`,s.__radixId=oK,s}var nT="AlertDialog",[dK]=ga(nT,[_R]),Nl=_R(),rT=t=>{const{__scopeAlertDialog:s,...n}=t,r=Nl(s);return e.jsx(qb,{...r,...n,modal:!0})};rT.displayName=nT;var uK="AlertDialogTrigger",hK=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=Nl(n);return e.jsx(GR,{...a,...r,ref:s})});hK.displayName=uK;var mK="AlertDialogPortal",aT=t=>{const{__scopeAlertDialog:s,...n}=t,r=Nl(s);return e.jsx(zb,{...r,...n})};aT.displayName=mK;var fK="AlertDialogOverlay",iT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=Nl(n);return e.jsx(lp,{...a,...r,ref:s})});iT.displayName=fK;var td="AlertDialogContent",[pK,xK]=dK(td),gK=cK("AlertDialogContent"),lT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,children:r,...a}=t,i=Nl(n),o=g.useRef(null),d=Gs(s,o),m=g.useRef(null);return e.jsx(q$,{contentName:td,titleName:oT,docsSlug:"alert-dialog",children:e.jsx(pK,{scope:n,cancelRef:m,children:e.jsxs(op,{role:"alertdialog",...i,...a,ref:d,onOpenAutoFocus:Kt(a.onOpenAutoFocus,f=>{var p;f.preventDefault(),(p=m.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:f=>f.preventDefault(),onInteractOutside:f=>f.preventDefault(),children:[e.jsx(gK,{children:r}),e.jsx(yK,{contentRef:o})]})})})});lT.displayName=td;var oT="AlertDialogTitle",cT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=Nl(n);return e.jsx(KR,{...a,...r,ref:s})});cT.displayName=oT;var dT="AlertDialogDescription",uT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=Nl(n);return e.jsx(YR,{...a,...r,ref:s})});uT.displayName=dT;var vK="AlertDialogAction",hT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=Nl(n);return e.jsx(Ub,{...a,...r,ref:s})});hT.displayName=vK;var mT="AlertDialogCancel",fT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,{cancelRef:a}=xK(mT,n),i=Nl(n),o=Gs(s,a);return e.jsx(Ub,{...i,...r,ref:o})});fT.displayName=mT;var yK=({contentRef:t})=>{const s=`\`${td}\` requires a description for the component to be accessible for screen reader users.
You can add a description to the \`${td}\` by passing a \`${dT}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${td}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return g.useEffect(()=>{var r;document.getElementById((r=t.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},bK=rT,jK=aT,NK=iT,wK=lT,SK=hT,CK=fT,AK=cT,kK=uT;function DK({...t}){return e.jsx(bK,{"data-slot":"alert-dialog",...t})}function RK({...t}){return e.jsx(jK,{"data-slot":"alert-dialog-portal",...t})}function EK({className:t,...s}){return e.jsx(NK,{"data-slot":"alert-dialog-overlay",className:Nt("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...s})}function _K({className:t,...s}){return e.jsxs(RK,{children:[e.jsx(EK,{}),e.jsx(wK,{"data-slot":"alert-dialog-content",className:Nt("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...s})]})}function TK({className:t,...s}){return e.jsx("div",{"data-slot":"alert-dialog-header",className:Nt("flex flex-col gap-2 text-center sm:text-left",t),...s})}function PK({className:t,...s}){return e.jsx("div",{"data-slot":"alert-dialog-footer",className:Nt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...s})}function OK({className:t,...s}){return e.jsx(AK,{"data-slot":"alert-dialog-title",className:Nt("text-lg font-semibold",t),...s})}function LK({className:t,...s}){return e.jsx(kK,{"data-slot":"alert-dialog-description",className:Nt("text-muted-foreground text-sm",t),...s})}function IK({className:t,...s}){return e.jsx(SK,{className:Nt(rd(),t),...s})}function MK({className:t,...s}){return e.jsx(CK,{className:Nt(rd({variant:"outline"}),t),...s})}function FK({resignationId:t,onBack:s}){var N,v,w;const[n,r]=g.useState(!0),[a,i]=g.useState(null),[o,d]=g.useState(!1),[m,f]=g.useState(!1),[p,h]=g.useState("User requested withdrawal");g.useEffect(()=>{t&&(async()=>{try{r(!0);const b=await tc.getResignationById(t);i(b)}catch(b){console.error("Failed to fetch resignation details:",b),te.error("Unable to load resignation details")}finally{r(!1)}})()},[t]);const x=async()=>{try{const j=await tc.getResignationById(t);i(j)}catch{te.error("Unable to refresh resignation details")}},u=async()=>{var j,b;try{d(!0),await tc.withdraw(t,p),te.success("Resignation request withdrawn successfully"),f(!1),await x()}catch(C){te.error(((b=(j=C==null?void 0:C.response)==null?void 0:j.data)==null?void 0:b.message)||"Failed to withdraw resignation")}finally{d(!1)}};return n?e.jsx("div",{className:"min-h-[320px] flex items-center justify-center",children:e.jsx(vn,{className:"w-8 h-8 animate-spin text-re-red"})}):a?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(se,{variant:"outline",onClick:s,children:[e.jsx(Jr,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-slate-900",children:"Resignation Request Details"}),e.jsx("p",{className:"text-slate-600 text-sm",children:"Review your resignation request details"})]}),a.status!=="Withdrawn"&&a.status!=="Completed"&&a.status!=="Rejected"&&!["NBH","DD Admin","Legal","Awaiting F&F","F&F Initiated"].includes(a.currentStage)&&e.jsxs(se,{variant:"destructive",className:"bg-red-600 hover:bg-red-700",onClick:()=>f(!0),disabled:o,children:[e.jsx(mi,{className:"w-4 h-4 mr-2"}),o?"Withdrawing...":"Withdraw Request"]})]}),e.jsx(DK,{open:m,onOpenChange:f,children:e.jsxs(_K,{children:[e.jsxs(TK,{children:[e.jsx(OK,{children:"Are you absolutely sure?"}),e.jsx(LK,{children:"This action will withdraw your resignation request. This action cannot be undone and you will need to submit a new request if you change your mind."}),e.jsxs("div",{className:"mt-4 space-y-2",children:[e.jsx(de,{htmlFor:"withdrawal-reason",children:"Reason for withdrawal"}),e.jsx(at,{id:"withdrawal-reason",placeholder:"Please enter a reason...",value:p,onChange:j=>h(j.target.value)})]})]}),e.jsxs(PK,{children:[e.jsx(MK,{disabled:o,children:"Cancel"}),e.jsx(IK,{onClick:j=>{j.preventDefault(),u()},className:"bg-red-600 hover:bg-red-700 text-white",disabled:o,children:o?"Withdrawing...":"Yes, Withdraw Request"})]})]})}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsxs(Je,{className:"flex items-center gap-2",children:[e.jsx(Zn,{className:"w-5 h-5 text-re-red"}),"Request Summary"]}),e.jsx(Xt,{children:"Key details about your resignation request"})]}),e.jsxs(Fe,{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Request ID"}),e.jsx("p",{className:"text-slate-900",children:a.resignationId||a.id})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Submitted On"}),e.jsx("p",{className:"text-slate-900",children:Yt(a.submittedOn||a.createdAt)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Resignation Type"}),e.jsx("p",{className:"text-slate-900",children:a.resignationType||"N/A"})]})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"flex items-center gap-2",children:[e.jsx(Lr,{className:"w-5 h-5 text-blue-600"}),"Outlet and Dates"]})}),e.jsxs(Fe,{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Outlet"}),e.jsx("p",{className:"text-slate-900",children:((N=a.outlet)==null?void 0:N.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Outlet Code"}),e.jsx("p",{className:"text-slate-900",children:((v=a.outlet)==null?void 0:v.code)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Last Operational Date (Sales)"}),e.jsx("p",{className:"text-slate-900",children:a.lastOperationalDateSales?Yt(a.lastOperationalDateSales):"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Last Operational Date (Services)"}),e.jsx("p",{className:"text-slate-900",children:a.lastOperationalDateServices?Yt(a.lastOperationalDateServices):"N/A"})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Reason"}),e.jsx("p",{className:"text-slate-900",children:a.reason||"-"})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 flex items-center gap-1",children:[e.jsx(Vr,{className:"w-3 h-3"}),"Outlet Address"]}),e.jsx("p",{className:"text-slate-900",children:((w=a.outlet)==null?void 0:w.address)||"-"})]})]})]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs(se,{variant:"outline",onClick:s,children:[e.jsx(Jr,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsx(Le,{children:e.jsx(Fe,{className:"py-8 text-center text-slate-600",children:"Resignation details not found."})})]})}const BK=(t,s)=>Qb(t,s);function $K({onViewDetails:t}){const[s,n]=g.useState(!1),[r,a]=g.useState(""),[i,o]=g.useState(""),[d,m]=g.useState(""),[f,p]=g.useState(""),[h,x]=g.useState(""),[u,N]=g.useState([]),[v,w]=g.useState(!0),[j,b]=g.useState(!1),[C,S]=g.useState(null),[R,_]=g.useState([]);g.useEffect(()=>{A()},[]);const A=async()=>{var O,D;try{w(!0);const[P,L,$]=await Promise.all([Jl.getDashboardData(),Jl.getConstitutionalChanges(),Ee.getConstitutionalChangeMeta()]);S(P.profile);const Y=tT((O=P.profile)==null?void 0:O.constitutionType);a(Y),N(L.requests||[]),(D=$.data)!=null&&D.success&&Array.isArray($.data.structureTargets)&&_($.data.structureTargets)}catch(P){console.error("Fetch constitutional data error:",P),te.error("Failed to load requests")}finally{w(!1)}},E=async O=>{var D,P;if(O.preventDefault(),!i){te.error("Please select proposed constitution type");return}if(r===i){te.error("Proposed constitution must be different from current");return}if(!d.trim()){te.error("Please provide a reason for constitutional change");return}try{b(!0);const L={currentConstitution:r,changeType:i,reason:d.trim(),newPartnersDetails:f,shareholdingPattern:h};await Jl.submitConstitutionalChange(L),te.success("Constitutional change request submitted successfully"),n(!1),A(),o(""),m(""),p(""),x("")}catch(L){console.error("Submit constitutional change error:",L);const $=((P=(D=L==null?void 0:L.response)==null?void 0:D.data)==null?void 0:P.message)||"Failed to submit constitutional change request";te.error($)}finally{b(!1)}},q=[{title:"Total Requests",value:u.length,icon:hl,color:"bg-blue-500"},{title:"Pending",value:u.filter(O=>O.status!=="Completed"&&O.status!=="Rejected").length,icon:dr,color:"bg-re-red"},{title:"Completed",value:u.filter(O=>O.status==="Completed").length,icon:Ns,color:"bg-green-500"}];return e.jsxs("div",{className:"space-y-6",children:[v&&e.jsx("div",{className:"min-h-[400px] flex items-center justify-center",children:e.jsx(ns,{className:"w-8 h-8 text-blue-600 animate-spin"})}),!v&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 mb-2",children:"My Constitutional Change Requests"}),e.jsx("p",{className:"text-slate-600",children:"Submit and track requests for changing your business constitution"})]}),e.jsxs(ds,{open:s,onOpenChange:n,children:[e.jsx(co,{asChild:!0,children:e.jsxs(se,{className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(An,{className:"w-4 h-4 mr-2"}),"New Constitutional Change"]})}),e.jsxs(os,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Submit Constitutional Change Request"}),e.jsx(bs,{children:"Request to change your dealership's business constitution structure"})]}),e.jsxs("form",{onSubmit:E,className:"space-y-4",children:[e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-lg p-4 space-y-2",children:[e.jsx("h3",{className:"text-slate-900",children:"Current Dealership Information"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Dealer Code:"}),e.jsx("p",{className:"text-slate-900",children:(C==null?void 0:C.dealerCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Dealer Name:"}),e.jsx("p",{className:"text-slate-900",children:(C==null?void 0:C.businessName)||"N/A"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-slate-600",children:"Current Constitution:"}),e.jsx("p",{className:"text-slate-900",children:r})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"currentConstitution",children:"Current Constitution *"}),e.jsx(at,{id:"currentConstitution",value:r,disabled:!0,className:"bg-slate-100"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"proposedConstitution",children:"Proposed Constitution *"}),e.jsxs(Dt,{value:i,onValueChange:o,required:!0,children:[e.jsx(Et,{children:e.jsx(Rt,{placeholder:"Select new constitution"})}),e.jsx(_t,{children:R.filter(O=>O.value!==r).map(O=>e.jsx(Me,{value:O.value,children:O.label},O.value))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"reason",children:"Reason for Change *"}),e.jsx(Ws,{id:"reason",placeholder:"Please provide detailed reason for constitutional change...",value:d,onChange:O=>m(O.target.value),rows:4,required:!0})]}),(i==="Partnership"||i==="LLP")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"newPartners",children:"Details of New Partners/Members"}),e.jsx(Ws,{id:"newPartners",placeholder:"Name, relationship, and experience of new partners...",value:f,onChange:O=>p(O.target.value),rows:3})]}),(i==="Private Limited"||i==="LLP")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"shareholdingPattern",children:"Proposed Shareholding Pattern"}),e.jsx(Ws,{id:"shareholdingPattern",placeholder:"Details of share distribution among partners/directors...",value:h,onChange:O=>x(O.target.value),rows:3})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[e.jsx("h4",{className:"text-blue-900 mb-2",children:"Documents Required (to be uploaded later)"}),e.jsxs("ul",{className:"text-blue-800 text-sm space-y-1",children:[e.jsx("li",{children:"• GST Registration Certificate"}),e.jsx("li",{children:"• Firm PAN Copy"}),e.jsx("li",{children:"• Self-attested KYC documents"}),e.jsx("li",{children:"• Business Purchase Agreement (BPA)"}),e.jsx("li",{children:"• Partnership Agreement / Firm Registration (if target is Partnership)"}),e.jsx("li",{children:"• LLP Agreement / COI (if target is LLP)"}),e.jsx("li",{children:"• MOA, AOA, COI (if target is Private Limited)"}),e.jsx("li",{children:"• Cancelled Cheque"}),e.jsx("li",{children:"• Declaration / Authorization Letter"})]})]}),e.jsxs(bn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(se,{type:"submit",className:"bg-blue-600 hover:bg-blue-700",disabled:j,children:j?e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Request"})]})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:q.map((O,D)=>{const P=O.icon;return e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Je,{className:"text-sm",children:O.title}),e.jsx("div",{className:`${O.color} p-2 rounded-lg`,children:e.jsx(P,{className:"h-4 w-4 text-white"})})]}),e.jsx(Fe,{children:e.jsx("div",{className:"text-slate-900 text-2xl",children:O.value})})]},D)})}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"My Constitutional Change Requests"}),e.jsx(Xt,{children:"View and track all your constitutional change requests"})]}),e.jsx(Fe,{children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Current"}),e.jsx(fe,{children:"Proposed"}),e.jsx(fe,{children:"Submitted On"}),e.jsx(fe,{children:"Current Status"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Os,{children:u.length===0?e.jsx(it,{children:e.jsx(ue,{colSpan:7,className:"text-center py-4 text-slate-500",children:"No constitutional change requests found"})}):u.map(O=>e.jsxs(it,{children:[e.jsx(ue,{children:e.jsx("span",{className:"text-slate-900",children:O.requestId})}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",children:O.currentConstitution})}),e.jsx(ue,{children:e.jsx(Ce,{className:"bg-blue-100 text-blue-700 border-blue-300",children:O.changeType})}),e.jsx(ue,{className:"text-slate-600",children:Yt(O.createdAt)}),e.jsx(ue,{children:e.jsx(Ce,{className:`border ${BK(O.status)}`,children:O.status})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 bg-slate-200 rounded-full h-2 min-w-[60px]",children:e.jsx("div",{className:"bg-blue-600 h-2 rounded-full",style:{width:`${O.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-xs text-slate-600",children:[O.progressPercentage||0,"%"]})]})}),e.jsx(ue,{children:e.jsxs(se,{variant:"ghost",size:"sm",onClick:()=>t&&t(O.requestId),children:[e.jsx(yn,{className:"w-4 h-4 mr-1"}),"View"]})})]},O.id))})]})})]})]})]})}const qK=(t,s)=>Qb(t,s),Iv=(t,s)=>{var n,r,a;return((r=(n=t==null?void 0:t.response)==null?void 0:n.data)==null?void 0:r.message)||((a=t==null?void 0:t.data)==null?void 0:a.message)||(t==null?void 0:t.message)||s};function zK({onViewDetails:t}){const[s,n]=g.useState(!1),[r,a]=g.useState(null),[i,o]=g.useState(""),[d,m]=g.useState(""),[f,p]=g.useState(""),[h,x]=g.useState(""),[u,N]=g.useState(""),[v,w]=g.useState(""),[j,b]=g.useState(""),[C,S]=g.useState(""),[R,_]=g.useState(""),[A,E]=g.useState([]),[q,O]=g.useState([]),[D,P]=g.useState(""),[L,$]=g.useState(""),[Y,Z]=g.useState(!1),[W,U]=g.useState([]),[M,z]=g.useState([]),[T,I]=g.useState(!0),[B,G]=g.useState(!1);g.useEffect(()=>{H(),X()},[]);const K=D?q.filter(ce=>ce.stateId===D):q,H=async()=>{try{I(!0);const ce=await Jl.getDashboardData(),ve=await Jl.getRelocationRequests();U(ce.outlets||[]),z(ve.requests||[])}catch(ce){console.error("Fetch relocation data error:",ce),te.error(Iv(ce,"Failed to load outlets and requests"))}finally{I(!1)}},X=async()=>{var ce,ve;try{Z(!0);const[Pe,et]=await Promise.all([Is.getStates().catch(()=>({success:!1})),Is.getDistricts({limit:"all"}).catch(()=>({success:!1}))]),kt=Pe!=null&&Pe.success?((ce=Pe.data)==null?void 0:ce.states)||Pe.data||[]:[],vt=et!=null&&et.success?((ve=et.data)==null?void 0:ve.districts)||et.data||[]:[];E(kt),O(vt)}catch(Pe){console.error("Fetch master data error:",Pe),te.error(Iv(Pe,"Failed to load master data"))}finally{Z(!1)}},J=ce=>{P(ce),$("");const ve=A.find(Pe=>Pe.id===ce);ve&&m(ve.name)},ae=ce=>{$(ce);const ve=q.find(Pe=>Pe.id===ce);ve&&o(ve.name)},le=async ce=>{if(ce.preventDefault(),!r){te.error("Please select an outlet");return}if(!i.trim()||!d.trim()||!f.trim()){te.error("Please provide complete relocation details");return}if(!h.trim()){te.error("Please provide a reason for relocation");return}if(!u.trim()||!v||!j){te.error("Please fill all mandatory fields (Distance, Property Type, Date)");return}try{G(!0);const ve={outletId:r.id,relocationType:"Intercity",currentAddress:r.address||"",currentCity:r.city||"",currentState:r.state||"",newAddress:f,newCity:i,newState:d,newDistrictId:L||null,newStateId:D||null,distance:u,reason:h,propertyType:v,proposedDate:j,proposedLatitude:C?parseFloat(C):null,proposedLongitude:R?parseFloat(R):null,currentLatitude:r.latitude||null,currentLongitude:r.longitude||null};await Jl.submitRelocationRequest(ve),te.success(`Relocation request submitted successfully for ${r.name}`),n(!1),H(),a(null),o(""),m(""),p(""),x(""),N(""),w(""),b(""),S(""),_(""),t&&H()}catch(ve){console.error("Submit relocation error:",ve),te.error(Iv(ve,"Failed to submit relocation request"))}finally{G(!1)}},xe=[{title:"Total Requests",value:M.length,icon:Vr,color:"bg-blue-500"},{title:"Pending",value:M.filter(ce=>ce.status!=="Completed"&&ce.status!=="Rejected").length,icon:dr,color:"bg-re-red"},{title:"Approved",value:M.filter(ce=>ce.status==="Completed").length,icon:so,color:"bg-green-500"}];return e.jsxs("div",{className:"space-y-6",children:[T&&e.jsx("div",{className:"min-h-[400px] flex items-center justify-center",children:e.jsx(ns,{className:"w-8 h-8 text-re-red animate-spin"})}),!T&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 mb-2",children:"Relocation Requests"}),e.jsx("p",{className:"text-slate-600",children:"Request to relocate your existing dealership or studio to a new location"})]}),e.jsxs(ds,{open:s,onOpenChange:n,children:[e.jsx(co,{asChild:!0,children:e.jsxs(se,{className:"bg-re-red hover:bg-re-red-hover text-white",children:[e.jsx(An,{className:"w-4 h-4 mr-2"}),"New Relocation Request"]})}),e.jsxs(os,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(xs,{children:[e.jsx(ms,{children:"Submit Relocation Request"}),e.jsx(bs,{children:"Provide details about the outlet you want to relocate and its proposed new location"})]}),e.jsxs("form",{onSubmit:le,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"outlet",children:"Select Outlet to Relocate *"}),e.jsxs(Dt,{value:r==null?void 0:r.id,onValueChange:ce=>a(W.find(ve=>ve.id===ce)),required:!0,children:[e.jsx(Et,{children:e.jsx(Rt,{placeholder:"Select an outlet"})}),e.jsx(_t,{children:W.map(ce=>e.jsxs(Me,{value:ce.id,children:[ce.name," (",ce.code,")"]},ce.id))})]})]}),r&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-lg p-4 space-y-2",children:[e.jsx("h3",{className:"text-slate-900 text-sm font-medium",children:"Current Location"}),e.jsx("p",{className:"text-slate-600 text-sm",children:r.location})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"newState",children:"Proposed State *"}),e.jsxs(Dt,{value:D,onValueChange:J,required:!0,disabled:Y,children:[e.jsx(Et,{id:"newState",children:e.jsx(Rt,{placeholder:Y?"Loading...":"Select state"})}),e.jsx(_t,{children:A.map(ce=>e.jsx(Me,{value:ce.id,children:ce.name},ce.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"newCity",children:"Proposed City/District *"}),e.jsxs(Dt,{value:L,onValueChange:ae,required:!0,disabled:!D||Y,children:[e.jsx(Et,{id:"newCity",children:e.jsx(Rt,{placeholder:D?Y?"Loading...":"Select district":"Select state first"})}),e.jsx(_t,{children:K.map(ce=>e.jsx(Me,{value:ce.id,children:ce.name},ce.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"newAddress",children:"Proposed Full Address *"}),e.jsx(Ws,{id:"newAddress",placeholder:"Enter detailed address of the proposed new location...",value:f,onChange:ce=>p(ce.target.value),rows:3,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"distance",children:"Estimated Distance from Current Location (in km) *"}),e.jsx(at,{id:"distance",placeholder:"e.g. 5.5 km",value:u,onChange:ce=>N(ce.target.value),required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"propertyType",children:"Property Type *"}),e.jsxs(Dt,{value:v,onValueChange:w,required:!0,children:[e.jsx(Et,{id:"propertyType",children:e.jsx(Rt,{placeholder:"Select type"})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"Owned",children:"Owned"}),e.jsx(Me,{value:"Leased",children:"Leased"}),e.jsx(Me,{value:"Rented",children:"Rented"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"expectedDate",children:"Expected Relocation Date *"}),e.jsx(at,{id:"expectedDate",type:"date",value:j,onChange:ce=>b(ce.target.value),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"reason",children:"Reason for Relocation *"}),e.jsx(Ws,{id:"reason",placeholder:"Why do you want to relocate this outlet?",value:h,onChange:ce=>x(ce.target.value),rows:4,required:!0})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[e.jsx("h4",{className:"text-blue-900 mb-2 font-medium",children:"Policy Notes"}),e.jsxs("ul",{className:"text-blue-800 text-xs space-y-1",children:[e.jsx("li",{children:"• Relocation is subject to feasibility study of the new location"}),e.jsx("li",{children:"• Maximum allowed distance and other policy criteria apply"}),e.jsx("li",{children:"• Site visit will be conducted by RBM/ASM"}),e.jsx("li",{children:"• New outlet code might be generated upon approval"})]})]}),e.jsxs(bn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(se,{type:"submit",className:"bg-re-red hover:bg-re-red-hover text-white",disabled:B,children:B?e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"w-4 h-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Relocation Request"})]})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:xe.map((ce,ve)=>{const Pe=ce.icon;return e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Je,{className:"text-sm",children:ce.title}),e.jsx("div",{className:`${ce.color} p-2 rounded-lg`,children:e.jsx(Pe,{className:"h-4 w-4 text-white"})})]}),e.jsx(Fe,{children:e.jsx("div",{className:"text-slate-900 text-2xl",children:ce.value})})]},ve)})}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:"My Relocation Requests"}),e.jsx(Xt,{children:"Track the status of your relocation applications"})]}),e.jsx(Fe,{children:e.jsxs(Ts,{children:[e.jsx(Ps,{children:e.jsxs(it,{children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Outlet"}),e.jsx(fe,{children:"Target Location"}),e.jsx(fe,{children:"Submitted On"}),e.jsx(fe,{children:"Current Status"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Os,{children:M.length===0?e.jsx(it,{children:e.jsx(ue,{colSpan:7,className:"text-center py-4 text-slate-500",children:"No relocation requests found"})}):M.map(ce=>{var ve;return e.jsxs(it,{children:[e.jsx(ue,{children:e.jsx("span",{className:"text-slate-900 font-medium",children:ce.requestId})}),e.jsx(ue,{children:(ve=ce.outlet)==null?void 0:ve.name}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[e.jsx("span",{className:"text-slate-500",children:ce.currentCity}),e.jsx(Ko,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:ce.newCity})]})}),e.jsx(ue,{className:"text-slate-600",children:Yt(ce.createdAt)}),e.jsx(ue,{children:e.jsx(Ce,{className:`border ${qK(ce.status)}`,children:ce.status})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 bg-slate-200 rounded-full h-2 min-w-[60px]",children:e.jsx("div",{className:"bg-re-red h-2 rounded-full",style:{width:`${ce.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-xs text-slate-600",children:[ce.progressPercentage||0,"%"]})]})}),e.jsx(ue,{children:e.jsxs(se,{variant:"ghost",size:"sm",onClick:()=>t&&t(ce.requestId),children:[e.jsx(yn,{className:"w-4 h-4 mr-1"}),"View"]})})]},ce.id)})})]})})]})]})]})}const UK=["Personal Information","Financial Information","Location & Background","Motivation","Business Structure","Professional Background","Infrastructure","Financial Planning","Growth & Expansion","Brand Affinity","Vision & Strategy"],O2=()=>{const{id:t}=vd(),s=tr(),[n,r]=g.useState(`v${new Date().toISOString().split("T")[0]}`),[a,i]=g.useState([{sectionName:"Personal Information",questionText:"",inputType:"text",weight:0,order:1,isMandatory:!0}]),[o,d]=g.useState(!1),[m,f]=g.useState(!!t);g.useEffect(()=>{t&&p(t)},[t]);const p=async C=>{var S;try{f(!0);const R=await Ee.getQuestionnaireById(C);if((S=R.data)!=null&&S.success){const _=R.data.data;r(`${_.version} (Copy)`),_.questions&&_.questions.length>0&&i(_.questions.map(A=>{var O,D;let E=(O=A.inputType)==null?void 0:O.toLowerCase().trim();return E==="mcq"&&(E="select"),["text","number","file","yesno","select","radio","textarea","email","mcq"].includes(E)||(E="text"),{...A,inputType:E,weight:parseFloat(A.weight),options:((D=A.questionOptions)==null?void 0:D.map(P=>({text:P.optionText,score:P.score})))||[]}}))}else te.error("Failed to load questionnaire"),s("/questionnaires")}catch(R){console.error(R),te.error("Error fetching questionnaire")}finally{f(!1)}},h=a.reduce((C,S)=>C+(S.weight||0),0),x=()=>{i([...a,{sectionName:"Personal Information",questionText:"",inputType:"text",weight:0,order:a.length+1,isMandatory:!0}])},u=C=>{const R=a.filter((_,A)=>A!==C).map((_,A)=>({..._,order:A+1}));i(R)},N=(C,S,R)=>{var A;const _=[...a];if(S==="weight"){const E=parseFloat(R)||0;_[C].options&&(_[C].options=_[C].options.map(q=>({...q,score:Math.min(q.score,E)})))}S==="inputType"&&R==="yesno"&&(!_[C].options||((A=_[C].options)==null?void 0:A.length)===0)?_[C].options=[{text:"Yes",score:_[C].weight||5},{text:"No",score:0}]:S==="inputType"&&R==="select"&&!_[C].options&&(_[C].options=[]),_[C]={..._[C],[S]:R},i(_)},v=C=>{const S=[...a];S[C].options||(S[C].options=[]),S[C].options.push({text:"",score:0}),i(S)},w=(C,S,R,_)=>{const A=[...a];if(A[C].options){let E=_;if(R==="score"){const q=A[C].weight||0;E=Math.min(parseFloat(_)||0,q)}A[C].options[S]={...A[C].options[S],[R]:E},i(A)}},j=(C,S)=>{const R=[...a];R[C].options&&(R[C].options=R[C].options.filter((_,A)=>A!==S),i(R))},b=async()=>{var C;if(a.some(S=>!S.questionText)){te.error("All questions must have text");return}for(let S=0;S<a.length;S++){const R=a[S];if(R.inputType==="select"||R.inputType==="yesno"){const _=(C=R.options)==null?void 0:C.find(A=>A.score>R.weight);if(_){te.error(`Question ${S+1}: Option "${_.text}" score (${_.score}) exceeds question weightage (${R.weight})`);return}}}if(h!==100){te.error(`Total weightage must be exactly 100. Current total: ${h}`);return}try{d(!0),await Ee.createQuestionnaireVersion({version:n,questions:a}),te.success("Questionnaire version created successfully"),s("/questionnaires")}catch(S){console.error(S),te.error("Failed to create questionnaire")}finally{d(!1)}};return m?e.jsx("div",{className:"flex justify-center p-12",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-re-red"})}):e.jsxs("div",{className:"p-6 bg-white rounded-lg shadow-md max-w-[1600px] mx-auto",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center mb-8 gap-4 border-b border-gray-100 pb-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>s("/questionnaires"),className:"p-2 hover:bg-slate-100 rounded-full transition-colors text-slate-500",children:e.jsx(Jr,{size:20})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-slate-900",children:t?"Edit Questionnaire Version":"Create New Version"}),e.jsx("p",{className:"text-slate-500 text-sm mt-1",children:t?"Modify existing template and save as new version":"Define questions, logic and weightage"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 w-full md:w-auto",children:[e.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded-lg border ${h===100?"bg-green-50 border-green-200 text-green-700":"bg-red-50 border-red-200 text-re-red-hover"}`,children:[h!==100&&e.jsx(sn,{size:16}),e.jsxs("span",{className:"text-sm font-semibold",children:["Total Score: ",h,"/100"]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 md:flex-initial",children:[e.jsx("input",{type:"text",value:n,onChange:C=>r(C.target.value),className:"border border-slate-300 p-2 rounded-lg w-full md:w-48 text-sm focus:ring-2 focus:ring-red-500 outline-none",placeholder:"Version Name (e.g. v2.0)"}),e.jsxs("button",{onClick:b,disabled:o,className:"bg-re-red text-white px-6 py-2 rounded-lg flex items-center gap-2 hover:bg-re-red-hover disabled:bg-slate-300 disabled:cursor-not-allowed transition shadow-sm font-medium whitespace-nowrap",children:[e.jsx(ml,{size:18})," ",o?"Saving...":"Publish"]})]})]})]}),e.jsx("div",{className:"space-y-4",children:a.map((C,S)=>{var R;return e.jsxs("div",{className:"group border border-slate-200 p-5 rounded-xl bg-slate-50/50 hover:bg-white hover:shadow-md transition-all duration-200 flex gap-4 items-start relative",children:[e.jsx("div",{className:"pt-2.5",children:e.jsx("div",{className:"w-8 h-8 rounded-full bg-slate-200 flex items-center justify-center text-slate-600 font-semibold text-sm",children:S+1})}),e.jsxs("div",{className:"flex-1 flex flex-col gap-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-5",children:[e.jsxs("div",{className:"md:col-span-6 lg:col-span-5",children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1.5",children:"Question Text"}),e.jsx("input",{type:"text",value:C.questionText,onChange:_=>N(S,"questionText",_.target.value),className:"w-full border border-slate-300 p-2.5 rounded-lg focus:ring-2 focus:ring-red-500 outline-none transition-shadow",placeholder:"Enter your question here..."})]}),e.jsxs("div",{className:"md:col-span-6 lg:col-span-3",children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1.5",children:"Section"}),e.jsx("select",{value:C.sectionName,onChange:_=>N(S,"sectionName",_.target.value),className:"w-full border border-slate-300 p-2.5 rounded-lg focus:ring-2 focus:ring-red-500 outline-none bg-white",children:UK.map(_=>e.jsx("option",{value:_,children:_},_))})]}),e.jsxs("div",{className:"md:col-span-4 lg:col-span-2",children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1.5",children:"Input Type"}),e.jsxs("select",{value:C.inputType,onChange:_=>N(S,"inputType",_.target.value),className:"w-full border border-slate-300 p-2.5 rounded-lg focus:ring-2 focus:ring-red-500 outline-none bg-white",children:[e.jsx("option",{value:"text",children:"One Liner"}),e.jsx("option",{value:"email",children:"Email Address"}),e.jsx("option",{value:"textarea",children:"Paragraph"}),e.jsx("option",{value:"number",children:"Numeric"}),e.jsx("option",{value:"file",children:"File Upload"}),e.jsx("option",{value:"yesno",children:"Yes / No"}),e.jsx("option",{value:"select",children:"Options (Dropdown)"}),e.jsx("option",{value:"radio",children:"Options (Radio)"})]})]}),e.jsx("div",{className:"md:col-span-4 lg:col-span-2",children:e.jsx("div",{className:"flex items-center gap-3 h-full pt-6",children:e.jsx("div",{className:"flex-1",children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"number",value:isNaN(C.weight)?0:C.weight,onChange:_=>N(S,"weight",parseFloat(_.target.value)||0),className:"w-full border border-slate-300 p-2.5 rounded-lg focus:ring-2 focus:ring-red-500 outline-none pl-3 pr-8",title:"Weightage"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 text-xs font-bold",children:"%"})]})})})})]}),(C.inputType==="select"||C.inputType==="yesno"||C.inputType==="radio"||C.inputType==="mcq")&&e.jsxs("div",{className:"w-full mt-4 pl-4 md:pl-16 border-t border-slate-100 pt-4",children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-500 uppercase tracking-wider mb-2",children:"Answer Options & Scores"}),e.jsx("div",{className:"space-y-2",children:(R=C.options)==null?void 0:R.map((_,A)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"text",value:_.text,onChange:E=>w(S,A,"text",E.target.value),className:"flex-1 border border-slate-300 p-2 rounded-md text-sm focus:ring-1 focus:ring-red-500 outline-none",placeholder:`Option ${A+1}`}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-slate-400 font-medium",children:"Score:"}),e.jsx("input",{type:"number",value:isNaN(_.score)?0:_.score,max:isNaN(C.weight)?0:C.weight,min:0,onChange:E=>w(S,A,"score",E.target.value),className:`w-20 border ${_.score>C.weight||isNaN(_.score)?"border-red-500 text-red-600":"border-slate-300"} p-2 rounded-md text-sm focus:ring-1 focus:ring-red-500 outline-none`})]}),e.jsx("button",{onClick:()=>j(S,A),className:"p-1.5 text-slate-400 hover:text-red-500 transition-colors",title:"Remove Option",children:e.jsx(ar,{size:16})})]},A))}),e.jsxs("button",{onClick:()=>v(S),className:"mt-3 text-sm flex items-center gap-1 text-re-red hover:text-re-red-hover font-medium",children:[e.jsx(An,{size:16})," Add Option"]})]})]}),e.jsx("button",{onClick:()=>u(S),className:"absolute -right-3 -top-3 md:static md:mt-8 md:mr-2 w-8 h-8 flex items-center justify-center rounded-full bg-white md:bg-transparent text-slate-400 hover:text-red-600 hover:bg-red-50 border border-slate-200 md:border-transparent shadow-sm md:shadow-none transition-all",title:"Remove Question",children:e.jsx(ar,{size:18})})]},S)})}),e.jsxs("button",{onClick:x,className:"mt-8 w-full border-2 border-dashed border-slate-300 p-4 rounded-xl text-slate-500 hover:border-red-500 hover:text-re-red hover:bg-red-50/30 flex justify-center items-center gap-2 transition-all font-medium",children:[e.jsx(An,{size:20})," Add Another Question"]})]})},L2=()=>{const[t,s]=g.useState([]),[n,r]=g.useState(!0),a=tr();g.useEffect(()=>{i()},[]);const i=async()=>{var o;try{r(!0);const d=await Ee.getAllQuestionnaires();(o=d.data)!=null&&o.success?s(d.data.data):te.error("Failed to load questionnaire versions")}catch(d){console.error(d),te.error("Error fetching versions")}finally{r(!1)}};return e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-slate-900",children:"Questionnaire Versions"}),e.jsx("p",{className:"text-slate-500",children:"Manage your questionnaire templates and versions"})]}),e.jsxs("button",{onClick:()=>a("/questionnaire-builder"),className:"bg-re-red text-white px-4 py-2 rounded-lg flex items-center gap-2 hover:bg-re-red-hover transition",children:[e.jsx(An,{size:20})," Create New Version"]})]}),n?e.jsx("div",{className:"flex justify-center p-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-re-red"})}):t.length===0?e.jsxs("div",{className:"text-center p-12 bg-white rounded-lg shadow-sm border border-slate-200",children:[e.jsx("p",{className:"text-slate-500 mb-4",children:"No questionnaire versions found."}),e.jsx("button",{onClick:()=>a("/questionnaire-builder"),className:"text-re-red font-medium hover:underline",children:"Create your first version"})]}):e.jsx("div",{className:"bg-white rounded-lg shadow-sm border border-slate-200 overflow-hidden",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{className:"bg-slate-50 border-b border-slate-100",children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-4 font-medium text-slate-600",children:"Version Name"}),e.jsx("th",{className:"p-4 font-medium text-slate-600",children:"Status"}),e.jsx("th",{className:"p-4 font-medium text-slate-600",children:"Created At"}),e.jsx("th",{className:"p-4 font-medium text-slate-600 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:t.map(o=>e.jsxs("tr",{className:"hover:bg-slate-50 transition",children:[e.jsx("td",{className:"p-4 font-medium text-slate-900",children:o.version}),e.jsx("td",{className:"p-4",children:o.isActive?e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium bg-green-100 text-green-700 border border-green-200",children:[e.jsx(un,{size:12})," Active"]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium bg-slate-100 text-slate-600 border border-slate-200",children:[e.jsx(mi,{size:12})," Inactive"]})}),e.jsx("td",{className:"p-4 text-slate-600 text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dr,{size:14,className:"text-slate-400"}),Ka(new Date(o.createdAt),"MMM dd, yyyy HH:mm")]})}),e.jsx("td",{className:"p-4 text-right",children:e.jsxs("button",{onClick:()=>a(`/questionnaire-builder/${o.id}`),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded text-sm font-medium text-slate-600 hover:text-re-red hover:bg-red-50 transition border border-slate-200 hover:border-red-200",children:[e.jsx(Cr,{size:14})," Edit / Clone"]})})]},o.id))})]})})]})},Mv=[{value:"KT_MATRIX",label:"KT Matrix (Level 1)",description:"Scored criteria for Level 1 interview assessment"},{value:"LEVEL2_FEEDBACK",label:"Level 2 Feedback",description:"Qualitative feedback fields for Level 2 interview"},{value:"LEVEL3_FEEDBACK",label:"Level 3 Feedback",description:"Qualitative feedback fields for Level 3 interview"}],VK=()=>{const[t,s]=g.useState([]),[,n]=g.useState(!1),[r,a]=g.useState("KT_MATRIX"),[i,o]=g.useState(!1),[d,m]=g.useState(null),[f,p]=g.useState(!1),[h,x]=g.useState(!1),u=g.useCallback(async()=>{var D;try{n(!0);const P=await Ee.getInterviewConfigs();(D=P.data)!=null&&D.success&&s(P.data.data||[])}catch(P){console.error("Fetch configs error:",P),te.error("Failed to load interview configurations")}finally{n(!1)}},[]);g.useEffect(()=>{u()},[u]);const N=D=>t.find(P=>P.configType===D&&P.isActive),v=D=>{var L;const P={KT_MATRIX:[{itemKey:"example_criterion",label:"Example Criterion",type:"select",order:1,isRequired:!0,weight:5,maxScore:10,options:[{optionLabel:"Excellent",optionValue:"excellent",score:10,order:1},{optionLabel:"Good",optionValue:"good",score:5,order:2}]}],LEVEL2_FEEDBACK:[{itemKey:"strategicVision",label:"Strategic Vision",type:"textarea",order:1,isRequired:!0,weight:null,maxScore:null},{itemKey:"managementCapabilities",label:"Management Capabilities",type:"textarea",order:2,isRequired:!0,weight:null,maxScore:null},{itemKey:"additionalComments",label:"Additional Comments",type:"textarea",order:3,isRequired:!1,weight:null,maxScore:null}],LEVEL3_FEEDBACK:[{itemKey:"businessVision",label:"Business Vision & Strategy",type:"textarea",order:1,isRequired:!0,weight:null,maxScore:null},{itemKey:"leadership",label:"Leadership & Decision Making",type:"textarea",order:2,isRequired:!0,weight:null,maxScore:null},{itemKey:"additionalComments",label:"Additional Comments",type:"textarea",order:3,isRequired:!1,weight:null,maxScore:null}]};m({configType:D,name:`${((L=Mv.find($=>$.value===D))==null?void 0:L.label)||"New Config"}`,version:`v${new Date().toISOString().split("T")[0]}`,isActive:!0,items:P[D]||[]}),o(!0)},w=async D=>{var P;try{n(!0);const L=await Ee.getInterviewConfigById(D);(P=L.data)!=null&&P.success&&(m(L.data.data),o(!0))}catch{te.error("Failed to load configuration for editing")}finally{n(!1)}},j=async()=>{var D,P;if(d){if(!d.name||!d.version){te.error("Name and version are required");return}if(!d.items||d.items.length===0){te.error("Add at least one item");return}if(d.configType==="KT_MATRIX"){const L=d.items.reduce(($,Y)=>$+(Number(Y.weight)||0),0);if(Math.abs(L-100)>.01){te.error(`KT Matrix total weight must be 100. Current: ${L}`);return}for(const $ of d.items)if($.type==="select"&&(!$.options||$.options.length===0)){te.error(`Select item "${$.label}" must have options`);return}}try{p(!0);const L={configType:d.configType,name:d.name,version:d.version,items:d.items.map(($,Y)=>{var Z;return{...$,order:$.order||Y+1,options:(Z=$.options)==null?void 0:Z.map((W,U)=>({...W,order:W.order||U+1}))}})};d.id?(await Ee.updateInterviewConfig(d.id,L),te.success("Configuration updated successfully")):(await Ee.createInterviewConfig(L),te.success("New configuration published successfully")),o(!1),m(null),await u()}catch(L){console.error("Save error:",L),te.error(((P=(D=L==null?void 0:L.response)==null?void 0:D.data)==null?void 0:P.message)||"Failed to save configuration")}finally{p(!1)}}},b=async D=>{if(confirm("Are you sure you want to delete this configuration?"))try{await Ee.deleteInterviewConfig(D),te.success("Configuration deleted"),await u()}catch{te.error("Failed to delete configuration")}},C=async()=>{if(confirm("This will reset all interview configurations to system defaults. Continue?"))try{x(!0),await Ee.initializeDefaultInterviewConfigs(),te.success("Default configurations initialized"),await u()}catch{te.error("Failed to initialize defaults")}finally{x(!1)}},S=()=>{var P,L;if(!d)return;const D={itemKey:`field_${(((P=d.items)==null?void 0:P.length)||0)+1}`,label:"",type:d.configType==="KT_MATRIX"?"select":"textarea",order:(((L=d.items)==null?void 0:L.length)||0)+1,isRequired:!0,weight:d.configType==="KT_MATRIX"?5:null,maxScore:d.configType==="KT_MATRIX"?10:null,options:d.configType==="KT_MATRIX"?[{optionLabel:"Option 1",optionValue:"opt1",score:10,order:1},{optionLabel:"Option 2",optionValue:"opt2",score:5,order:2}]:void 0};m({...d,items:[...d.items||[],D]})},R=D=>{var $;if(!d)return;const L=((($=d.items)==null?void 0:$.filter((Y,Z)=>Z!==D))||[]).map((Y,Z)=>({...Y,order:Z+1}));m({...d,items:L})},_=(D,P,L)=>{if(!d)return;const $=[...d.items||[]];$[D]={...$[D],[P]:L},m({...d,items:$})},A=D=>{if(!d)return;const P=[...d.items||[]],L=P[D];L.options||(L.options=[]),L.options.push({optionLabel:"",optionValue:"",score:0,order:L.options.length+1}),m({...d,items:P})},E=(D,P,L,$)=>{if(!d)return;const Y=[...d.items||[]];Y[D].options&&(Y[D].options[P]={...Y[D].options[P],[L]:$},m({...d,items:Y}))},q=(D,P)=>{if(!d)return;const L=[...d.items||[]];L[D].options&&(L[D].options=L[D].options.filter(($,Y)=>Y!==P),m({...d,items:L}))},O=(d==null?void 0:d.configType)==="KT_MATRIX"?(d.items||[]).reduce((D,P)=>D+(Number(P.weight)||0),0):0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-slate-900",children:"Interview Configuration"}),e.jsx("p",{className:"text-slate-500 text-sm mt-1",children:"Manage KT Matrix criteria and feedback fields for all interview levels"})]}),e.jsxs(se,{variant:"outline",onClick:C,disabled:h,className:"gap-2",children:[e.jsx(sb,{size:16})," ",h?"Initializing...":"Reset to Defaults"]})]}),e.jsxs(Bn,{value:r,onValueChange:a,children:[e.jsx($n,{className:"grid w-full grid-cols-3",children:Mv.map(D=>e.jsx(Wt,{value:D.value,children:D.label},D.value))}),Mv.map(D=>{var $;const P=N(D.value),L=t.filter(Y=>Y.configType===D.value);return e.jsx(Ut,{value:D.value,children:e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Je,{className:"text-lg",children:D.label}),e.jsx("p",{className:"text-sm text-slate-500",children:D.description})]}),e.jsxs(se,{onClick:()=>v(D.value),className:"gap-2",children:[e.jsx(An,{size:16})," Publish New Version"]})]}),e.jsxs(Fe,{children:[P?e.jsx("div",{className:"mb-6 p-4 bg-green-50 border border-green-200 rounded-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold text-green-800",children:["Active: ",P.name]}),e.jsxs("p",{className:"text-sm text-green-700",children:["Version ",P.version," • ",(($=P.items)==null?void 0:$.length)||0," items"]})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>P.id&&w(P.id),children:e.jsx(D1,{size:16})})})]})}):e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg text-red-800",children:'No active configuration found. Click "Publish New Version" to create one, or "Reset to Defaults" to initialize system defaults.'}),e.jsx("h3",{className:"text-sm font-semibold text-slate-700 mb-3",children:"Version History"}),L.length===0?e.jsx("p",{className:"text-sm text-slate-500",children:"No versions found."}):e.jsx("div",{className:"space-y-2",children:L.map(Y=>{var Z;return e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${Y.isActive?"bg-green-50 border-green-200":"bg-white border-slate-200"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[Y.isActive&&e.jsx(Ce,{className:"bg-green-600",children:"Active"}),e.jsx("span",{className:"font-medium text-sm",children:Y.name}),e.jsx("span",{className:"text-xs text-slate-500",children:Y.version}),e.jsxs("span",{className:"text-xs text-slate-400",children:[((Z=Y.items)==null?void 0:Z.length)||0," items"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>Y.id&&w(Y.id),children:e.jsx(D1,{size:14})}),e.jsx(se,{variant:"ghost",size:"sm",className:"text-re-red hover:text-re-red-hover",onClick:()=>Y.id&&b(Y.id),children:e.jsx(ar,{size:14})})]})]},Y.id)})})]})]})},D.value)})]})," ",e.jsx(ds,{open:i,onOpenChange:o,children:e.jsxs(os,{className:"max-w-[95vw] w-full lg:max-w-7xl p-0 overflow-hidden border-none shadow-2xl rounded-2xl flex flex-col max-h-[95vh]",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-slate-100 bg-white flex shrink-0 items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{children:[e.jsx(ms,{className:"text-lg font-bold text-slate-900 leading-none",children:d!=null&&d.id?"Edit Configuration":"New Configuration"}),e.jsxs(bs,{className:"text-[11px] text-slate-500 mt-1 uppercase tracking-wider font-semibold",children:[d==null?void 0:d.configType.replace(/_/g," ")," · ",(d==null?void 0:d.version)||"v1.0"]})]}),(d==null?void 0:d.configType)==="KT_MATRIX"&&e.jsxs("div",{className:`px-3 py-1.5 rounded-md text-[10px] font-black uppercase tracking-tight ${O===100?"bg-emerald-50 text-emerald-700 border border-emerald-100":"bg-red-50 text-re-red-hover border border-red-100"}`,children:["Weight: ",O,"% / 100%"]})]}),e.jsx("div",{className:"flex items-center gap-2"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4 bg-white space-y-6 custom-scrollbar",children:d&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 items-end bg-slate-50/40 p-4 rounded-xl border border-slate-100",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(de,{className:"text-[10px] font-bold text-slate-400 uppercase tracking-widest pl-1",children:"Name"}),e.jsx(at,{value:d.name,onChange:D=>m({...d,name:D.target.value}),className:"h-9 border-slate-200 bg-white shadow-none text-sm font-normal"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(de,{className:"text-[10px] font-bold text-slate-400 uppercase tracking-widest pl-1",children:"Version"}),e.jsx(at,{value:d.version,onChange:D=>m({...d,version:D.target.value}),className:"h-9 border-slate-200 bg-white shadow-none text-sm font-normal"})]}),e.jsx("div",{className:"flex items-center justify-end h-9",children:e.jsxs(se,{variant:"outline",onClick:S,className:"h-full border-dashed border-slate-300 text-slate-500 hover:text-slate-900 text-xs font-bold px-4",children:[e.jsx(An,{size:14,className:"mr-2"})," Add Criteria"]})})]}),e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim pb-4 -mx-1 px-1",children:e.jsx("div",{className:"min-w-[900px] border border-slate-100 rounded-xl",children:e.jsxs("table",{className:"w-full text-left border-collapse table-fixed",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50/50 border-b border-slate-100 text-[10px] uppercase font-black text-slate-400 tracking-[0.1em]",children:[e.jsx("th",{className:"px-4 py-2 w-12 text-center",children:"#"}),e.jsx("th",{className:"px-4 py-2 w-[35%]",children:"Label"}),e.jsx("th",{className:"px-4 py-2 w-[20%]",children:"Data Key"}),e.jsx("th",{className:"px-4 py-2 w-32",children:"Type"}),d.configType==="KT_MATRIX"&&e.jsxs(e.Fragment,{children:[e.jsx("th",{className:"px-4 py-2 w-24",children:"Weight"}),e.jsx("th",{className:"px-4 py-2 w-20",children:"Max"})]}),e.jsx("th",{className:"px-4 py-2 w-16 text-center",children:"Req."}),e.jsx("th",{className:"px-4 py-2 w-10"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-50",children:(d.items||[]).map((D,P)=>e.jsxs(wt.Fragment,{children:[e.jsxs("tr",{className:"group hover:bg-slate-50/10 transition-colors",children:[e.jsx("td",{className:"px-4 py-3 text-slate-300 font-bold text-[11px] align-top pt-5 text-center",children:String(P+1).padStart(2,"0")}),e.jsx("td",{className:"px-4 py-3 align-top",children:e.jsx(at,{value:D.label,onChange:L=>_(P,"label",L.target.value),className:"h-10 border-slate-100 hover:border-slate-300 focus:bg-white bg-slate-50/30 text-sm font-normal transition-all",placeholder:"Age/Qualification etc."})}),e.jsx("td",{className:"px-4 py-3 align-top",children:e.jsx(at,{value:D.itemKey,onChange:L=>_(P,"itemKey",L.target.value),className:"h-10 border-slate-100 hover:border-slate-300 focus:bg-white bg-slate-50/30 font-mono text-[11px] text-slate-500"})}),e.jsx("td",{className:"px-4 py-3 align-top",children:e.jsxs(Dt,{value:D.type,onValueChange:L=>_(P,"type",L),children:[e.jsx(Et,{className:"h-10 border-slate-100 hover:border-slate-300 bg-slate-50/30 text-xs focus:ring-0",children:e.jsx(Rt,{})}),e.jsxs(_t,{children:[e.jsx(Me,{value:"select",children:"Options"}),e.jsx(Me,{value:"text",children:"One Liner"}),e.jsx(Me,{value:"textarea",children:"Paragraph"}),e.jsx(Me,{value:"number",children:"Numeric"})]})]})}),d.configType==="KT_MATRIX"&&e.jsxs(e.Fragment,{children:[e.jsx("td",{className:"px-4 py-3 align-top",children:e.jsxs("div",{className:"relative group/num",children:[e.jsx(at,{type:"number",value:D.weight||"",onChange:L=>_(P,"weight",parseFloat(L.target.value)||0),className:"h-10 w-full border-slate-100 bg-slate-50/30 text-sm font-normal text-right pr-8 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),e.jsxs("div",{className:"absolute right-0.5 top-0.5 bottom-0.5 flex flex-col border-l border-slate-200/50 bg-white/40 rounded-r-md overflow-hidden opacity-40 group-hover/num:opacity-100 transition-opacity",children:[e.jsx("button",{type:"button",onClick:()=>_(P,"weight",(D.weight||0)+1),className:"flex-1 px-1.5 hover:bg-slate-200/50 flex items-center justify-center border-b border-slate-200/50",children:e.jsx(yu,{size:10,className:"text-slate-600"})}),e.jsx("button",{type:"button",onClick:()=>_(P,"weight",Math.max(0,(D.weight||0)-1)),className:"flex-1 px-1.5 hover:bg-slate-200/50 flex items-center justify-center",children:e.jsx(Aa,{size:10,className:"text-slate-600"})})]}),e.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-[9px] text-slate-300 font-bold",children:"%"})]})}),e.jsx("td",{className:"px-4 py-3 align-top",children:e.jsxs("div",{className:"relative group/num",children:[e.jsx(at,{type:"number",value:D.maxScore||"",onChange:L=>_(P,"maxScore",parseFloat(L.target.value)||0),className:"h-10 border-slate-100 bg-slate-50/30 text-sm font-normal text-right pr-6 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),e.jsxs("div",{className:"absolute right-0.5 top-0.5 bottom-0.5 flex flex-col border-l border-slate-200/50 bg-white/40 rounded-r-md overflow-hidden opacity-40 group-hover/num:opacity-100 transition-opacity",children:[e.jsx("button",{type:"button",onClick:()=>_(P,"maxScore",(D.maxScore||0)+1),className:"flex-1 px-1.5 hover:bg-slate-200/50 flex items-center justify-center border-b border-slate-200/50",children:e.jsx(yu,{size:10,className:"text-slate-600"})}),e.jsx("button",{type:"button",onClick:()=>_(P,"maxScore",Math.max(0,(D.maxScore||0)-1)),className:"flex-1 px-1.5 hover:bg-slate-200/50 flex items-center justify-center",children:e.jsx(Aa,{size:10,className:"text-slate-600"})})]})]})})]}),e.jsx("td",{className:"px-4 py-3 align-top text-center pt-5",children:e.jsx("input",{type:"checkbox",checked:D.isRequired,onChange:L=>_(P,"isRequired",L.target.checked),className:"w-4 h-4 accent-slate-900 border-slate-300"})}),e.jsx("td",{className:"px-4 py-3 align-top pt-4",children:e.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-200 hover:text-red-500 hover:bg-red-50",onClick:()=>R(P),children:e.jsx(ar,{size:16})})})]}),D.type==="select"&&e.jsxs("tr",{className:"bg-slate-50/30",children:[e.jsx("td",{colSpan:1}),e.jsx("td",{colSpan:d.configType==="KT_MATRIX"?7:5,className:"px-4 py-4",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-slate-200/50 pb-2 mb-2",children:[e.jsxs("p",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest flex items-center gap-2",children:[e.jsx("div",{className:"w-1 h-3 bg-red-400 rounded-full"})," Options"]}),e.jsxs(se,{variant:"ghost",size:"sm",className:"h-7 px-3 text-[10px] font-bold uppercase text-slate-600 hover:bg-white border border-transparent hover:border-slate-200",onClick:()=>A(P),children:[e.jsx(An,{className:"w-3 h-3 mr-1.5"})," Append Option"]})]}),e.jsxs("div",{className:"grid grid-cols-12 gap-3 mb-2 px-1",children:[e.jsx("div",{className:"col-span-6 text-[9px] font-black uppercase text-slate-300 tracking-tighter",children:"Display Label"}),e.jsx("div",{className:"col-span-3 text-[9px] font-black uppercase text-slate-300 tracking-tighter",children:"API Value"}),e.jsx("div",{className:"col-span-2 text-[9px] font-black uppercase text-slate-300 tracking-tighter",children:"Score"})]}),e.jsx("div",{className:"space-y-2",children:(D.options||[]).map((L,$)=>e.jsxs("div",{className:"grid grid-cols-12 gap-3 items-center group/opt",children:[e.jsx("div",{className:"col-span-6",children:e.jsx(at,{placeholder:"Label",value:L.optionLabel,onChange:Y=>E(P,$,"optionLabel",Y.target.value),className:"h-9 border-slate-200 bg-white text-xs font-normal"})}),e.jsx("div",{className:"col-span-3",children:e.jsx(at,{placeholder:"Value",value:L.optionValue,onChange:Y=>E(P,$,"optionValue",Y.target.value),className:"h-9 border-slate-200 bg-white text-xs font-mono"})}),e.jsx("div",{className:"col-span-2",children:e.jsxs("div",{className:"relative group/optnum",children:[e.jsx(at,{type:"number",placeholder:"0",value:L.score,onChange:Y=>E(P,$,"score",parseFloat(Y.target.value)||0),className:"h-9 border-slate-200 bg-white text-xs font-normal text-right pr-6 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),e.jsxs("div",{className:"absolute right-0.5 top-0.5 bottom-0.5 flex flex-col border-l border-slate-100 bg-slate-50/50 rounded-r-md overflow-hidden opacity-0 group-hover/optnum:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>E(P,$,"score",(L.score||0)+1),className:"flex-1 px-1 hover:bg-slate-200 flex items-center justify-center border-b border-slate-100",children:e.jsx(yu,{size:8})}),e.jsx("button",{onClick:()=>E(P,$,"score",(L.score||0)-1),className:"flex-1 px-1 hover:bg-slate-200 flex items-center justify-center",children:e.jsx(Aa,{size:8})})]})]})}),e.jsx("div",{className:"col-span-1 flex justify-center",children:e.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-300 hover:text-red-500 opacity-0 group-hover/opt:opacity-100",onClick:()=>q(P,$),children:e.jsx(ar,{size:13})})})]},$))})]})})]})]},P))})]})})})]})}),e.jsxs("div",{className:"px-6 py-4 bg-slate-50 border-t border-slate-100 flex shrink-0 justify-end gap-3",children:[e.jsx(se,{variant:"ghost",className:"px-6 h-10 text-xs font-bold text-slate-500 hover:bg-slate-200 transition-colors",onClick:()=>o(!1),children:"Dismiss"}),e.jsxs(se,{className:"bg-slate-900 hover:bg-slate-950 text-white px-8 h-10 rounded-lg text-xs font-black uppercase tracking-widest shadow-xl shadow-slate-200 transition-all active:scale-95",onClick:j,disabled:f,children:[f?e.jsx(ns,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx(ml,{className:"w-4 h-4 mr-2"}),"Commit Changes"]})]})]})})]})},HK=[{value:"__all__",label:"All Modules"},{value:"QUESTIONNAIRE",label:"Questionnaire"},{value:"INTERVIEW_CONFIG",label:"Interview Configuration"},{value:"SYSTEM_CONFIG",label:"System Configuration"},{value:"SLA_CONFIG",label:"SLA Configuration"},{value:"EMAIL_TEMPLATE",label:"Email Template"},{value:"MASTER_HIERARCHY",label:"Master Hierarchy"},{value:"ROLE_ASSIGNMENT",label:"Role Assignment"},{value:"USER_ADMIN",label:"User Administration"},{value:"DEALER_MAPPING",label:"Dealer Mapping"}],WK=[{value:"__all__",label:"All Actions"},{value:"CREATED",label:"Created"},{value:"UPDATED",label:"Updated"},{value:"DELETED",label:"Deleted"},{value:"ACTIVATED",label:"Activated"},{value:"DEACTIVATED",label:"Deactivated"},{value:"INITIALIZED",label:"Initialized"},{value:"SUBMITTED",label:"Submitted"},{value:"ASSIGNED",label:"Assigned"},{value:"UNASSIGNED",label:"Unassigned"},{value:"REORDERED",label:"Reordered"}],GK={CREATED:"bg-emerald-100 text-emerald-700 border-emerald-200",UPDATED:"bg-blue-100 text-blue-700 border-blue-200",DELETED:"bg-rose-100 text-rose-700 border-rose-200",ACTIVATED:"bg-emerald-100 text-emerald-700 border-emerald-200",DEACTIVATED:"bg-slate-200 text-slate-700 border-slate-300",INITIALIZED:"bg-red-50 text-re-red-hover border-red-200",SUBMITTED:"bg-indigo-100 text-indigo-700 border-indigo-200",ASSIGNED:"bg-violet-100 text-violet-700 border-violet-200",UNASSIGNED:"bg-slate-200 text-slate-700 border-slate-300",REORDERED:"bg-sky-100 text-sky-700 border-sky-200"},I2=t=>{try{return new Date(t).toLocaleString("en-IN",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return t}},Fv=({value:t})=>t==null?e.jsx("p",{className:"text-xs italic text-slate-400",children:"—"}):e.jsx("pre",{className:"text-xs bg-slate-900 text-slate-100 rounded-lg p-3 overflow-auto max-h-72 whitespace-pre-wrap break-words",children:JSON.stringify(t,null,2)}),KK=()=>{var Z,W,U;const[t,s]=g.useState([]),[n,r]=g.useState(null),[a,i]=g.useState(!1),[o,d]=g.useState(1),[m]=g.useState(25),[f,p]=g.useState(1),[h,x]=g.useState(0),[u,N]=g.useState("__all__"),[v,w]=g.useState("__all__"),[j,b]=g.useState(""),[C,S]=g.useState(""),[R,_]=g.useState(""),[A,E]=g.useState(""),[q,O]=g.useState(null),D=g.useMemo(()=>({module:u!=="__all__"?u:void 0,action:v!=="__all__"?v:void 0,search:A||void 0,dateFrom:C||void 0,dateTo:R||void 0,page:o,limit:m}),[u,v,A,C,R,o,m]),P=g.useCallback(async()=>{var M,z;i(!0);try{const T=await Ee.getSystemAuditLogs(D),I=T==null?void 0:T.data;T!=null&&T.ok&&(I!=null&&I.success)?(s(I.data||[]),p(((M=I.pagination)==null?void 0:M.totalPages)||1),x(((z=I.pagination)==null?void 0:z.total)||0)):(te.error((I==null?void 0:I.message)||"Unable to load system logs"),s([]))}catch(T){console.error("[SystemLogsPage] fetchLogs error:",T),te.error("Failed to load system logs"),s([])}finally{i(!1)}},[D]),L=g.useCallback(async()=>{try{const M=await Ee.getSystemAuditSummary(),z=M==null?void 0:M.data;M!=null&&M.ok&&(z!=null&&z.success)&&r(z.data||null)}catch(M){console.error("[SystemLogsPage] fetchSummary error:",M)}},[]);g.useEffect(()=>{P()},[P]),g.useEffect(()=>{L()},[L]);const $=()=>{d(1),E(j.trim())},Y=()=>{N("__all__"),w("__all__"),b(""),E(""),S(""),_(""),d(1)};return e.jsxs("div",{className:"space-y-6 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-slate-900 flex items-center gap-2",children:[e.jsx(ad,{className:"w-6 h-6 text-re-red"}),"System Activity Logs"]}),e.jsx("p",{className:"text-slate-500",children:"Configuration-level changes across questionnaires, interview configs, master hierarchy, system / SLA configs, and role assignments."})]}),e.jsxs(se,{variant:"outline",onClick:()=>{P(),L()},disabled:a,children:[e.jsx(xr,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"Refresh"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-5 gap-3",children:[e.jsxs(Le,{className:"border-slate-200",children:[e.jsx(Qe,{className:"pb-2",children:e.jsx(Je,{className:"text-xs font-bold text-slate-500 uppercase tracking-wider",children:"Total Events"})}),e.jsxs(Fe,{children:[e.jsx("p",{className:"text-2xl font-bold text-slate-900",children:(n==null?void 0:n.totalEntries)??"—"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-1",children:"Lifetime"})]})]}),((n==null?void 0:n.byModule)||[]).slice(0,4).map(M=>e.jsxs(Le,{className:"border-slate-200",children:[e.jsx(Qe,{className:"pb-2",children:e.jsx(Je,{className:"text-xs font-bold text-slate-500 uppercase tracking-wider",children:M.moduleLabel})}),e.jsxs(Fe,{children:[e.jsx("p",{className:"text-2xl font-bold text-slate-900",children:M.total}),e.jsx("button",{onClick:()=>{N(M.module),d(1)},className:"text-[11px] text-re-red hover:underline mt-1",children:"View module →"})]})]},M.module))]}),e.jsx(Le,{className:"border-slate-200",children:e.jsxs(Fe,{className:"pt-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-6 gap-3 items-end",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsxs("label",{className:"text-xs font-semibold text-slate-600 mb-1 block flex items-center gap-1",children:[e.jsx(Ta,{className:"w-3 h-3"})," Search"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(at,{placeholder:"Entity name, description, or actor…",value:j,onChange:M=>b(M.target.value),onKeyDown:M=>{M.key==="Enter"&&$()}}),e.jsx(se,{variant:"outline",onClick:$,children:"Go"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-slate-600 mb-1 block",children:"Module"}),e.jsxs(Dt,{value:u,onValueChange:M=>{N(M),d(1)},children:[e.jsx(Et,{children:e.jsx(Rt,{placeholder:"All Modules"})}),e.jsx(_t,{children:HK.map(M=>e.jsx(Me,{value:M.value,children:M.label},M.value))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-slate-600 mb-1 block",children:"Action"}),e.jsxs(Dt,{value:v,onValueChange:M=>{w(M),d(1)},children:[e.jsx(Et,{children:e.jsx(Rt,{placeholder:"All Actions"})}),e.jsx(_t,{children:WK.map(M=>e.jsx(Me,{value:M.value,children:M.label},M.value))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-slate-600 mb-1 block",children:"From"}),e.jsx(at,{type:"date",value:C,onChange:M=>{S(M.target.value),d(1)}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-slate-600 mb-1 block",children:"To"}),e.jsx(at,{type:"date",value:R,onChange:M=>{_(M.target.value),d(1)}})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("div",{className:"text-xs text-slate-500 flex items-center gap-2",children:[e.jsx(eb,{className:"w-3 h-3"}),"Showing ",t.length," of ",h," matching event(s)"]}),e.jsx(se,{variant:"ghost",size:"sm",onClick:Y,children:"Reset filters"})]})]})}),e.jsxs(Le,{className:"border-slate-200 overflow-hidden",children:[e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-slate-50 text-slate-600",children:e.jsxs("tr",{className:"text-left",children:[e.jsx("th",{className:"px-4 py-3 font-semibold",children:"When"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Module"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Action"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Entity"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Actor"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Description"}),e.jsx("th",{className:"px-4 py-3 font-semibold w-10"})]})}),e.jsxs("tbody",{className:"divide-y divide-slate-100",children:[a&&e.jsx("tr",{children:e.jsxs("td",{colSpan:7,className:"px-4 py-10 text-center text-slate-400",children:[e.jsx(xr,{className:"w-5 h-5 inline-block mr-2 animate-spin"}),"Loading system logs…"]})}),!a&&t.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-10 text-center text-slate-400",children:"No events match the current filters."})}),!a&&t.map(M=>{var z,T,I;return e.jsxs("tr",{className:"hover:bg-slate-50/70 cursor-pointer",onClick:()=>O(M),children:[e.jsx("td",{className:"px-4 py-3 whitespace-nowrap text-slate-700",children:I2(M.timestamp)}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx(Ce,{variant:"outline",className:"border-slate-300 text-slate-700",children:M.moduleLabel})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx(Ce,{variant:"outline",className:GK[M.action]||"bg-slate-100 text-slate-700 border-slate-200",children:M.actionLabel})}),e.jsxs("td",{className:"px-4 py-3 text-slate-800",children:[e.jsx("div",{className:"font-medium truncate max-w-[260px]",title:M.entityLabel||"",children:M.entityLabel||`${M.entityType}`}),M.entityId&&e.jsx("div",{className:"text-[10px] font-mono text-slate-400 truncate max-w-[260px]",children:M.entityId})]}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-full bg-slate-100 text-slate-600 flex items-center justify-center text-xs font-semibold",children:(((z=M.actor)==null?void 0:z.name)||"S").charAt(0).toUpperCase()}),e.jsxs("div",{children:[e.jsx("div",{className:"text-slate-800 leading-tight",children:((T=M.actor)==null?void 0:T.name)||"System"}),((I=M.actor)==null?void 0:I.role)&&e.jsx("div",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:M.actor.role})]})]})}),e.jsx("td",{className:"px-4 py-3 text-slate-600",children:e.jsx("div",{className:"truncate max-w-[360px]",title:M.description,children:M.description})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:B=>{B.stopPropagation(),O(M)},title:"View details",children:e.jsx(yn,{className:"w-4 h-4 text-slate-500"})})})]},M.id)})]})]})}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-slate-100 bg-slate-50/50",children:[e.jsxs("div",{className:"text-xs text-slate-500",children:["Page ",o," of ",f]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(se,{size:"sm",variant:"outline",disabled:a||o<=1,onClick:()=>d(M=>Math.max(1,M-1)),children:[e.jsx(lo,{className:"w-4 h-4 mr-1"}),"Prev"]}),e.jsxs(se,{size:"sm",variant:"outline",disabled:a||o>=f,onClick:()=>d(M=>Math.min(f,M+1)),children:["Next",e.jsx(bi,{className:"w-4 h-4 ml-1"})]})]})]})]}),e.jsx(ds,{open:!!q,onOpenChange:M=>!M&&O(null),children:e.jsx(os,{className:"max-w-3xl max-h-[85vh] overflow-y-auto",children:q&&e.jsxs(e.Fragment,{children:[e.jsxs(xs,{children:[e.jsxs(ms,{className:"flex items-center gap-2",children:[e.jsx(ad,{className:"w-5 h-5 text-re-red"}),q.moduleLabel," · ",q.actionLabel]}),e.jsx(bs,{className:"text-slate-600",children:q.description})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm mt-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider mb-1",children:"Entity"}),e.jsx("p",{className:"text-slate-800",children:q.entityLabel||q.entityType}),q.entityId&&e.jsx("p",{className:"text-[11px] font-mono text-slate-400 mt-0.5",children:q.entityId})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider mb-1",children:"Actor"}),e.jsxs("p",{className:"text-slate-800 flex items-center gap-2",children:[e.jsx(Lr,{className:"w-4 h-4 text-slate-400"}),((Z=q.actor)==null?void 0:Z.name)||"System"]}),((W=q.actor)==null?void 0:W.role)&&e.jsx("p",{className:"text-[11px] text-slate-500 uppercase tracking-wider mt-0.5",children:q.actor.role}),((U=q.actor)==null?void 0:U.email)&&e.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:q.actor.email})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider mb-1",children:"When"}),e.jsx("p",{className:"text-slate-800",children:I2(q.timestamp)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider mb-1",children:"Source"}),e.jsx("p",{className:"text-slate-800",children:q.ipAddress||"—"}),e.jsx("p",{className:"text-[11px] text-slate-500 truncate",title:q.userAgent||"",children:q.userAgent||""})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider mb-2",children:"Previous values"}),e.jsx(Fv,{value:q.oldData})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider mb-2",children:"New values"}),e.jsx(Fv,{value:q.newData})]})]}),q.metadata&&e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider mb-2",children:"Metadata"}),e.jsx(Fv,{value:q.metadata})]})]})})})]})},YK=()=>{const[t,s]=g.useState([]),[n,r]=g.useState(!0),[a,i]=g.useState(1),[o,d]=g.useState(1),m=15,f=tr(),p=async N=>{try{r(!0);const v=await Zo.getNotifications(N,m);v.success&&(s(v.data),v.pagination&&d(v.pagination.totalPages))}catch(v){console.error("Failed to fetch notifications",v)}finally{r(!1)}};g.useEffect(()=>{p(a)},[a]);const h=async(N,v)=>{v.stopPropagation(),await Zo.markAsRead(N),p(a)},x=async()=>{await Zo.markAllAsRead(),p(a)},u=async N=>{if(N.isRead||await Zo.markAsRead(N.id),N.link){const v=N.link;try{const w=new URL(v);w.origin===window.location.origin?f(w.pathname+w.search+w.hash):window.open(v,"_blank")}catch{f(v)}}else p(a)};return e.jsxs("div",{className:"p-6 max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(Au,{className:"w-6 h-6 text-blue-600"}),"Notifications Center"]}),e.jsx("p",{className:"text-gray-500 text-sm mt-1",children:"View and manage all your alerts"})]}),e.jsxs(se,{variant:"outline",onClick:x,disabled:n||!t.some(N=>!N.isRead),children:[e.jsx(Hn,{className:"w-4 h-4 mr-2"}),"Mark all as read"]})]}),e.jsx(Le,{className:"shadow-sm border-gray-200",children:e.jsx(Fe,{className:"p-0",children:n?e.jsx("div",{className:"flex justify-center items-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):t.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-gray-500",children:[e.jsx(Au,{className:"w-12 h-12 text-gray-300 mb-4"}),e.jsx("p",{className:"text-lg font-medium",children:"No notifications yet"}),e.jsx("p",{className:"text-sm",children:"When you get updates, they'll show up here."})]}):e.jsx("div",{className:"divide-y divide-gray-100",children:t.map(N=>e.jsxs("div",{className:`p-4 hover:bg-gray-50 transition-colors flex items-start gap-4 cursor-pointer ${N.isRead?"":"bg-blue-50/50"}`,onClick:()=>u(N),children:[e.jsx("div",{className:"mt-1 flex-shrink-0 cursor-pointer",onClick:v=>h(N.id,v),children:N.isRead?e.jsx("div",{className:"w-3 h-3 border-2 border-gray-300 rounded-full"}):e.jsx("div",{className:"w-3 h-3 bg-blue-600 rounded-full shadow-sm"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex justify-between items-start mb-1",children:[e.jsx("h4",{className:`text-sm font-semibold ${N.isRead?"text-gray-700":"text-gray-900"}`,children:N.title}),e.jsxs("div",{className:"flex items-center text-xs text-gray-500 whitespace-nowrap ml-4",children:[e.jsx(vn,{className:"w-3 h-3 mr-1"}),aR(new Date(N.createdAt),{addSuffix:!0})]})]}),e.jsx("p",{className:"text-sm text-gray-600 line-clamp-2",children:N.message})]})]},N.id))})})}),!n&&o>1&&e.jsxs("div",{className:"flex items-center justify-between mt-6 px-4",children:[e.jsxs("p",{className:"text-sm text-gray-600",children:["Showing page ",e.jsx("span",{className:"font-medium text-gray-900",children:a})," of"," ",e.jsx("span",{className:"font-medium text-gray-900",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(se,{variant:"outline",size:"sm",disabled:a===1,onClick:()=>i(N=>Math.max(1,N-1)),children:[e.jsx(lo,{className:"w-4 h-4"}),"Previous"]}),e.jsxs(se,{variant:"outline",size:"sm",disabled:a===o,onClick:()=>i(N=>Math.min(o,N+1)),children:["Next",e.jsx(bi,{className:"w-4 h-4"})]})]})]})]})},M2=({...t})=>e.jsx(OM,{theme:"light",className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...t}),ZK=({onLogout:t,title:s,subtitle:n})=>e.jsxs("div",{className:"flex h-screen bg-slate-50 overflow-hidden",children:[e.jsx(VM,{onLogout:t}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(i$,{title:s,subtitle:n,onRefresh:()=>window.location.reload()}),e.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:e.jsx(jL,{})})]})]});function QK(){const t=Lu(),{user:s,isAuthenticated:n,loading:r}=In(b=>b.auth),[a,i]=g.useState(!1),o=tr(),d=yl(),m=(s==null?void 0:s.role)||(s==null?void 0:s.roleCode)||"",f=b=>{const C=b.map(_=>_.toLowerCase()),S=String((s==null?void 0:s.role)||"").toLowerCase(),R=String((s==null?void 0:s.roleCode)||"").toLowerCase();return C.includes(S)||C.includes(R)},p=["DD Admin","DD_ADMIN","ASM","RBM","DD-ZM","DD_ZM","DD Lead","DD_LEAD","DD Head","DD_HEAD","ZBH","NBH","Legal","Legal Admin","LEGAL_ADMIN","Super Admin","SUPER_ADMIN"],h=["ASM","RBM","DD-ZM","DD_ZM","ZBH","DD Lead","DD_LEAD","DD Head","DD_HEAD","NBH","Legal Admin","LEGAL_ADMIN","Legal","DD Admin","DD_ADMIN","CCO","CEO","Super Admin","SUPER_ADMIN"],x=["DD Admin","DD_ADMIN","DD-ZM","DD_ZM","DD Lead","DD_LEAD","DD Head","DD_HEAD","NBH","Finance","Finance Admin","FINANCE_ADMIN","Super Admin","SUPER_ADMIN"],u=["Finance","Finance Admin"];g.useEffect(()=>{t(Mm())},[t]);const N=async(b,C)=>{var S;try{const R=await Ee.login({email:b,password:C});if(R.ok&&R.data){const{token:_,user:A}=R.data;localStorage.setItem("token",_);const E={id:A.id,name:A.fullName||b.split("@")[0],email:A.email,password:C,role:typeof A.role=="string"?A.role:A.roleCode||"User"};t(SA({user:E,token:_})),te.success(`Welcome back, ${E.name}!`),i(!1)}else{const _=((S=R.data)==null?void 0:S.message)||"Invalid credentials";te.error(_)}}catch(R){console.error("Login error:",R),te.error("Something went wrong. Please try again.")}},v=()=>{t(CA()),i(!1),te.info("Logged out successfully"),o("/")};g.useEffect(()=>{const b=()=>{v(),te.error("Session expired. Please login again.")};return window.addEventListener("auth:logout",b),()=>window.removeEventListener("auth:logout",b)},[t,o]);const w=b=>b.startsWith("/applications/")&&b.length>14?"Application Details":b.startsWith("/resignation/")&&!b.startsWith("/dealer-resignation")?"Resignation Details":b.startsWith("/dealer-resignation/")?"Resignation Request Details":b.startsWith("/termination/")?"Termination Details":b.startsWith("/fnf/")?"F&F Request Details":b.startsWith("/constitutional-change/")?"Constitutional Change Details":b.startsWith("/relocation-requests/")?"Relocation Request Details":b.startsWith("/finance-onboarding/")?"Payment Details":b.startsWith("/finance-audit/")?"Finance Audit":b.startsWith("/finance-fnf/")?"F&F Settlement Details":b.startsWith("/fdd-details/")?"FDD Audit Workspace":b.startsWith("/questionnaire-builder/")?"Questionnaire Builder":b.startsWith("/worknotes/")?"Work Notes":{"/dashboard":"Dashboard","/applications":"Dealership Requests","/all-applications":"All Applications","/opportunity-requests":"Opportunity Requests","/non-opportunities":"Non-opportunities","/tasks":"My Tasks","/reports":"Reports & Analytics","/settings":"Settings","/users":"User Management","/resignation":"Resignation Management","/termination":"Termination Management","/fnf":"Full & Final Settlement","/finance-onboarding":"Payment Verification","/finance-fnf":"F&F Financial Settlement","/master":"Master Configuration","/constitutional-change":"Constitutional Change","/relocation-requests":"Relocation Requests","/dealer-resignation":"Dealer Resignation Management","/dealer-constitutional":"Dealer Constitutional Change","/dealer-relocation":"Dealer Relocation Requests","/questionnaire-builder":"Questionnaire Builder","/approval-policies":"Approval Policies","/fdd-dashboard":"FDD Dashboard","/fdd-details":"Audit Workspace","/questions":"Questionnaires","/questionnaires":"Questionnaire Templates","/interview-configs":"Interview Configuration","/system-logs":"System Logs","/sla-configurations":"SLA Matrix","/notifications":"Notifications"}[b]||"Dashboard",j=(b,C)=>{const S=(C||"").toLowerCase(),R=S==="dealer"||S.includes("dealer"),_=S.includes("finance");if(b.startsWith("/worknotes/"))return"Collaborative notes and clarifications linked to this onboarding or offboarding record.";if(b.startsWith("/applications/")&&b!=="/applications")return"Review stages, documents, interviews, and decisions for this single dealership onboarding application.";if(b==="/applications")return"Search, filter, and open dealership applications your role can work on.";if(b==="/all-applications")return"Cross-team view of every dealership application in the pipeline.";if(b==="/opportunity-requests")return"Applications tied to an opportunity location for DD prioritisation.";if(b==="/non-opportunities")return"Applications without a mapped opportunity; track for future reference or follow-up.";if(b==="/dashboard")return R?"Your home for outlet actions: constitutional change (how your business is legally registered), relocation, and resignation requests.":_?"Payment verification, finance audits, and F&F settlement work for dealership accounts.":"Operational snapshot for dealership onboarding: workloads, alerts, and shortcuts for your role.";if(b.startsWith("/dealer-resignation/"))return"Read-only summary of the resignation you submitted for this outlet.";if(b==="/dealer-resignation")return"Start a new outlet resignation or open a request you already submitted.";if(b==="/dealer-constitutional")return"Constitutional change updates your outlets registered legal structure (for example sole proprietorship to private limited). Submit one request per outlet; Royal Enfield teams review documents and approve before records change.";if(b==="/dealer-relocation")return"Request a move of your dealership to a new address or territory, and track requests in progress.";if(b.startsWith("/constitutional-change/"))return"Review evidence, comments, and workflow for this constitutional change case.";if(b==="/constitutional-change")return"Process dealer requests to change registered legal constitution, supporting documents, and approvals.";if(b.startsWith("/relocation-requests/"))return"Assess feasibility, documents, and approvals for this relocation request.";if(b==="/relocation-requests")return"Manage dealer relocation proposals: new sites, handovers, and compliance checks.";if(b.startsWith("/resignation/")&&!b.startsWith("/dealer-resignation"))return"HR workflow: clearances, handovers, and settlement steps for this resignation.";if(b==="/resignation")return"Queue of dealership resignation cases across your authorised outlets.";if(b.startsWith("/termination/"))return"Contractual exit details, evidence, and approvals for this termination case.";if(b==="/termination")return"Monitor dealership terminations, disputes, and mandated approvals.";if(b.startsWith("/fnf/"))return"Line items, deductions, and payout status for this full & final settlement.";if(b==="/fnf")return"Track F&F batches from clearance through finance payout.";if(b.startsWith("/finance-onboarding/"))return"Payment schedule, proofs, and audit notes for this onboarding application.";if(b==="/finance-onboarding")return"Validate Security Deposit, first fills, and related onboarding payments.";if(b.startsWith("/finance-audit/"))return"Finance audit trail and checklist for this application.";if(b.startsWith("/finance-fnf/"))return"Settlement calculations and release steps for this F&F record.";if(b==="/finance-fnf")return"Finance queue for F&F approvals and disbursements.";if(b.startsWith("/fdd-details/"))return"Field Development Director audit workspace for this application.";if(b==="/fdd-dashboard")return"FDD workload: audits due, flags raised, and follow-up actions.";if(b.startsWith("/questionnaire-builder/")||b==="/questionnaire-builder")return"Author and publish questionnaire versions used in dealership assessments.";if(b==="/questionnaires"||b==="/questions")return"List of published questionnaire templates and versions.";if(b==="/master")return"Hierarchy, geography, templates, and reference data shared across onboarding.";if(b==="/users")return"Create and maintain internal users, roles, and access for this portal.";if(b==="/approval-policies")return"Configure who must approve each onboarding stage or document type.";if(b==="/sla-configurations")return"Define turnaround targets and escalations for onboarding milestones.";if(b==="/interview-configs")return"Set up interview templates, panels, and scoring used during selection.";if(b==="/system-logs")return"Immutable record of configuration and administrative actions for compliance.";if(b==="/notifications")return"System and workflow alerts for your account.";if(b==="/tasks")return"Tasks assigned to you (placeholder module).";if(b==="/reports")return"Analytics and exports for onboarding performance (placeholder module).";if(b==="/settings")return"Profile, notifications, and security preferences for your account.";const A=w(b);return A==="Dashboard"?"Operational snapshot for dealership onboarding: workloads, alerts, and shortcuts for your role.":`You are viewing: ${A}.`};return r?e.jsx("div",{className:"flex items-center justify-center h-screen bg-slate-50",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-red-600"})}):n?e.jsxs(U9,{children:[e.jsxs(Xv,{children:[e.jsx(ks,{path:"/prospective-dashboard/*",element:e.jsx(v1,{allowedRoles:["Prospective Dealer"],children:e.jsx(F7,{})})}),e.jsxs(ks,{element:e.jsx(v1,{excludeRoles:["Prospective Dealer"],redirectTo:"/prospective-dashboard",children:e.jsx(ZK,{onLogout:v,title:w(d.pathname),subtitle:j(d.pathname,m)})}),children:[e.jsx(ks,{path:"/",element:e.jsx(Yn,{to:"/dashboard",replace:!0})}),e.jsx(ks,{path:"/dashboard",element:f(u)?e.jsx(L7,{currentUser:s,onNavigate:b=>o(`/${b}`),onViewPaymentDetails:b=>o(`/finance-onboarding/${b}`),onViewAuditDetails:b=>o(`/finance-audit/${b}`),onViewFnFDetails:b=>o(`/finance-fnf/${b}`)}):f(["Dealer"])?e.jsx(I7,{currentUser:s,onNavigate:b=>o(`/${b}`)}):e.jsx(N$,{onNavigate:b=>o(`/${b}`)})}),e.jsx(ks,{path:"/applications",element:e.jsx(kq,{onViewDetails:b=>o(`/applications/${b}`),initialFilter:"all"})}),e.jsx(ks,{path:"/applications/:id",element:e.jsx(ES,{})}),e.jsx(ks,{path:"/worknotes/:type/:id",element:e.jsx(IE,{onBack:()=>window.history.back()})}),e.jsx(ks,{path:"/all-applications",element:f(["DD","DD Admin","Super Admin"])?e.jsx(Dq,{onViewDetails:b=>o(`/applications/${b}`),initialFilter:"all"}):e.jsx(Yn,{to:"/dashboard"})}),e.jsx(ks,{path:"/fdd-dashboard",element:e.jsx(q7,{})}),e.jsx(ks,{path:"/fdd-details/:id",element:e.jsx(oq,{})}),e.jsx(ks,{path:"/opportunity-requests",element:e.jsx(kU,{onViewDetails:b=>o(`/applications/${b}`)})}),e.jsx(ks,{path:"/non-opportunities",element:e.jsx(DU,{onViewDetails:b=>o(`/applications/${b}`)})}),e.jsx(ks,{path:"/users",element:e.jsx(IG,{})}),e.jsx(ks,{path:"/notifications",element:e.jsx(YK,{})}),e.jsx(ks,{path:"/approval-policies",element:f(["Super Admin","DD Admin"])?e.jsx(Y_,{}):e.jsx(Yn,{to:"/dashboard"})}),e.jsx(ks,{path:"/sla-configurations",element:f(["Super Admin","DD Admin","DD Lead"])?e.jsx(zG,{}):e.jsx(Yn,{to:"/dashboard"})}),e.jsx(ks,{path:"/master",element:e.jsx(LG,{})}),e.jsx(ks,{path:"/questions",element:e.jsx(L2,{})}),e.jsx(ks,{path:"/questionnaire-builder",element:e.jsx(O2,{})}),e.jsx(ks,{path:"/questionnaire-builder/:id",element:e.jsx(O2,{})}),e.jsx(ks,{path:"/questionnaires",element:e.jsx(L2,{})}),e.jsx(ks,{path:"/interview-configs",element:f(["Super Admin","DD Admin","DD Head"])?e.jsx(VK,{}):e.jsx(Yn,{to:"/dashboard"})}),e.jsx(ks,{path:"/system-logs",element:f(["Super Admin"])?e.jsx(KK,{}):e.jsx(Yn,{to:"/dashboard"})}),e.jsx(ks,{path:"/resignation",element:f(p)?e.jsx(oV,{currentUser:s,onViewDetails:b=>o(`/resignation/${b}`)}):e.jsx(Yn,{to:"/dashboard"})}),e.jsx(ks,{path:"/resignation/:id",element:f(p)?e.jsx(pV,{resignationId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/resignation"),currentUser:s}):e.jsx(Yn,{to:"/dashboard"})}),e.jsx(ks,{path:"/termination",element:f(h)?e.jsx(dV,{currentUser:s,onViewDetails:b=>o(`/termination/${b}`)}):e.jsx(Yn,{to:"/dashboard"})}),e.jsx(ks,{path:"/termination/:id",element:f(h)?e.jsx(NV,{terminationId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/termination"),currentUser:s}):e.jsx(Yn,{to:"/dashboard"})}),e.jsx(ks,{path:"/fnf",element:f(x)?e.jsx(uV,{currentUser:s,onViewDetails:b=>o(`/fnf/${b}`)}):e.jsx(Yn,{to:"/dashboard"})}),e.jsx(ks,{path:"/fnf/:id",element:f(x)?e.jsx(CV,{fnfId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/fnf"),currentUser:s}):e.jsx(Yn,{to:"/dashboard"})}),e.jsx(ks,{path:"/finance-onboarding",element:f(u)?e.jsx(AV,{onViewPaymentDetails:b=>o(`/finance-onboarding/${b}`),onViewAuditDetails:b=>o(`/finance-audit/${b}`)}):e.jsx(Yn,{to:"/dashboard"})}),e.jsx(ks,{path:"/finance-onboarding/:id",element:f(u)?e.jsx(DV,{applicationId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/finance-onboarding")}):e.jsx(Yn,{to:"/dashboard"})}),e.jsx(ks,{path:"/finance-audit/:id",element:e.jsx(ES,{})}),e.jsx(ks,{path:"/finance-fnf",element:f(u)?e.jsx(kV,{onViewFnFDetails:b=>o(`/finance-fnf/${b}`)}):e.jsx(Yn,{to:"/dashboard"})}),e.jsx(ks,{path:"/finance-fnf/:id",element:f(u)?e.jsx(RV,{fnfId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/finance-fnf")}):e.jsx(Yn,{to:"/dashboard"})}),e.jsx(ks,{path:"/constitutional-change",element:e.jsx(KG,{currentUser:s,onViewDetails:b=>o(`/constitutional-change/${b}`)})}),e.jsx(ks,{path:"/constitutional-change/:id",element:e.jsx(QG,{requestId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/constitutional-change"),currentUser:s})}),e.jsx(ks,{path:"/relocation-requests",element:e.jsx(JG,{currentUser:s,onViewDetails:b=>o(`/relocation-requests/${b}`)})}),e.jsx(ks,{path:"/relocation-requests/:id",element:e.jsx(iK,{requestId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/relocation-requests"),currentUser:s})}),e.jsx(ks,{path:"/dealer-resignation",element:e.jsx(lK,{currentUser:s,onViewDetails:b=>o(`/dealer-resignation/${b}`)})}),e.jsx(ks,{path:"/dealer-resignation/:id",element:f(["Dealer"])?e.jsx(FK,{resignationId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/dealer-resignation")}):e.jsx(Yn,{to:"/dashboard"})}),e.jsx(ks,{path:"/dealer-constitutional",element:e.jsx($K,{currentUser:s,onViewDetails:b=>o(`/constitutional-change/${b}`)})}),e.jsx(ks,{path:"/dealer-relocation",element:e.jsx(zK,{currentUser:s,onViewDetails:b=>o(`/relocation-requests/${b}`)})}),e.jsx(ks,{path:"/tasks",element:e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-8 text-center",children:[e.jsx("h2",{className:"text-slate-900 mb-2",children:"My Tasks"}),e.jsx("p",{className:"text-slate-600",children:"Task management interface would be displayed here"}),e.jsx("p",{className:"text-slate-500 mt-4",children:"Shows applications assigned to the current user"})]})}),e.jsx(ks,{path:"/reports",element:e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-8 text-center",children:[e.jsx("h2",{className:"text-slate-900 mb-2",children:"Reports & Analytics"}),e.jsx("p",{className:"text-slate-600",children:"Advanced reporting and analytics dashboard"}),e.jsx("p",{className:"text-slate-500 mt-4",children:"Charts, export capabilities, and custom filters"})]})}),e.jsx(ks,{path:"/settings",element:e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-8",children:[e.jsx("h2",{className:"text-slate-900 mb-4",children:"Settings"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900 mb-2",children:"Profile Settings"}),e.jsx("p",{className:"text-slate-600",children:"Update your profile information and preferences"})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900 mb-2",children:"Notification Preferences"}),e.jsx("p",{className:"text-slate-600",children:"Configure email and system notifications"})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900 mb-2",children:"Security"}),e.jsx("p",{className:"text-slate-600",children:"Change password and manage security settings"})]})]})]})}),e.jsx(ks,{path:"*",element:e.jsx(Yn,{to:"/dashboard",replace:!0})})]})]}),e.jsx(M2,{})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Xv,{children:[e.jsx(ks,{path:"/admin-login",element:e.jsx(T1,{onLogin:N})}),e.jsx(ks,{path:"/prospective-login",element:e.jsx(UM,{})}),e.jsx(ks,{path:"/questionnaire/:applicationId",element:e.jsx(IM,{})}),e.jsx(ks,{path:"*",element:a?e.jsx(T1,{onLogin:N}):e.jsx(LM,{onAdminLogin:()=>i(!0)})})]}),e.jsx(M2,{})]})}S4.createRoot(document.getElementById("root")).render(e.jsx(wt.StrictMode,{children:e.jsx(B4,{store:R5,children:e.jsx(CL,{children:e.jsx(QK,{})})})}));