Dealer_Onboarding_Backend/build/assets/index-CAe70IkM.js

753 lines
1.8 MiB
Raw Permalink 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 AT=Object.defineProperty;var kT=(t,s,n)=>s in t?AT(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var ax=(t,s,n)=>kT(t,typeof s!="symbol"?s+"":s,n);function RT(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 l=Object.getOwnPropertyDescriptor(r,a);l&&Object.defineProperty(t,a,l.get?l:{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 l of a)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(a){if(a.ep)return;a.ep=!0;const l=n(a);fetch(a.href,l)}})();var Eo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function _m(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ix={exports:{}},vd={},lx={exports:{}},Us={};/**
* @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 Jj;function ET(){if(Jj)return Us;Jj=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"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),x=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),m=Symbol.iterator;function p(D){return D===null||typeof D!="object"?null:(D=m&&D[m]||D["@@iterator"],typeof D=="function"?D:null)}var u={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,g={};function y(D,O,V){this.props=D,this.context=O,this.refs=g,this.updater=V||u}y.prototype.isReactComponent={},y.prototype.setState=function(D,O){if(typeof D!="object"&&typeof D!="function"&&D!=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,D,O,"setState")},y.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function N(){}N.prototype=y.prototype;function S(D,O,V){this.props=D,this.context=O,this.refs=g,this.updater=V||u}var C=S.prototype=new N;C.constructor=S,j(C,y.prototype),C.isPureReactComponent=!0;var w=Array.isArray,R=Object.prototype.hasOwnProperty,P={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function I(D,O,V){var K,Y={},U=null,X=null;if(O!=null)for(K in O.ref!==void 0&&(X=O.ref),O.key!==void 0&&(U=""+O.key),O)R.call(O,K)&&!A.hasOwnProperty(K)&&(Y[K]=O[K]);var ne=arguments.length-2;if(ne===1)Y.children=V;else if(1<ne){for(var oe=Array(ne),re=0;re<ne;re++)oe[re]=arguments[re+2];Y.children=oe}if(D&&D.defaultProps)for(K in ne=D.defaultProps,ne)Y[K]===void 0&&(Y[K]=ne[K]);return{$$typeof:t,type:D,key:U,ref:X,props:Y,_owner:P.current}}function $(D,O){return{$$typeof:t,type:D.type,key:O,ref:D.ref,props:D.props,_owner:D._owner}}function T(D){return typeof D=="object"&&D!==null&&D.$$typeof===t}function E(D){var O={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(V){return O[V]})}var _=/\/+/g;function M(D,O){return typeof D=="object"&&D!==null&&D.key!=null?E(""+D.key):O.toString(36)}function q(D,O,V,K,Y){var U=typeof D;(U==="undefined"||U==="boolean")&&(D=null);var X=!1;if(D===null)X=!0;else switch(U){case"string":case"number":X=!0;break;case"object":switch(D.$$typeof){case t:case s:X=!0}}if(X)return X=D,Y=Y(X),D=K===""?"."+M(X,0):K,w(Y)?(V="",D!=null&&(V=D.replace(_,"$&/")+"/"),q(Y,O,V,"",function(re){return re})):Y!=null&&(T(Y)&&(Y=$(Y,V+(!Y.key||X&&X.key===Y.key?"":(""+Y.key).replace(_,"$&/")+"/")+D)),O.push(Y)),1;if(X=0,K=K===""?".":K+":",w(D))for(var ne=0;ne<D.length;ne++){U=D[ne];var oe=K+M(U,ne);X+=q(U,O,V,oe,Y)}else if(oe=p(D),typeof oe=="function")for(D=oe.call(D),ne=0;!(U=D.next()).done;)U=U.value,oe=K+M(U,ne++),X+=q(U,O,V,oe,Y);else if(U==="object")throw O=String(D),Error("Objects are not valid as a React child (found: "+(O==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":O)+"). If you meant to render a collection of children, use an array instead.");return X}function G(D,O,V){if(D==null)return D;var K=[],Y=0;return q(D,K,"","",function(U){return O.call(V,U,Y++)}),K}function Z(D){if(D._status===-1){var O=D._result;O=O(),O.then(function(V){(D._status===0||D._status===-1)&&(D._status=1,D._result=V)},function(V){(D._status===0||D._status===-1)&&(D._status=2,D._result=V)}),D._status===-1&&(D._status=0,D._result=O)}if(D._status===1)return D._result.default;throw D._result}var W={current:null},z={transition:null},F={ReactCurrentDispatcher:W,ReactCurrentBatchConfig:z,ReactCurrentOwner:P};function B(){throw Error("act(...) is not supported in production builds of React.")}return Us.Children={map:G,forEach:function(D,O,V){G(D,function(){O.apply(this,arguments)},V)},count:function(D){var O=0;return G(D,function(){O++}),O},toArray:function(D){return G(D,function(O){return O})||[]},only:function(D){if(!T(D))throw Error("React.Children.only expected to receive a single React element child.");return D}},Us.Component=y,Us.Fragment=n,Us.Profiler=a,Us.PureComponent=S,Us.StrictMode=r,Us.Suspense=h,Us.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=F,Us.act=B,Us.cloneElement=function(D,O,V){if(D==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+D+".");var K=j({},D.props),Y=D.key,U=D.ref,X=D._owner;if(O!=null){if(O.ref!==void 0&&(U=O.ref,X=P.current),O.key!==void 0&&(Y=""+O.key),D.type&&D.type.defaultProps)var ne=D.type.defaultProps;for(oe in O)R.call(O,oe)&&!A.hasOwnProperty(oe)&&(K[oe]=O[oe]===void 0&&ne!==void 0?ne[oe]:O[oe])}var oe=arguments.length-2;if(oe===1)K.children=V;else if(1<oe){ne=Array(oe);for(var re=0;re<oe;re++)ne[re]=arguments[re+2];K.children=ne}return{$$typeof:t,type:D.type,key:Y,ref:U,props:K,_owner:X}},Us.createContext=function(D){return D={$$typeof:c,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},D.Provider={$$typeof:l,_context:D},D.Consumer=D},Us.createElement=I,Us.createFactory=function(D){var O=I.bind(null,D);return O.type=D,O},Us.createRef=function(){return{current:null}},Us.forwardRef=function(D){return{$$typeof:d,render:D}},Us.isValidElement=T,Us.lazy=function(D){return{$$typeof:f,_payload:{_status:-1,_result:D},_init:Z}},Us.memo=function(D,O){return{$$typeof:x,type:D,compare:O===void 0?null:O}},Us.startTransition=function(D){var O=z.transition;z.transition={};try{D()}finally{z.transition=O}},Us.unstable_act=B,Us.useCallback=function(D,O){return W.current.useCallback(D,O)},Us.useContext=function(D){return W.current.useContext(D)},Us.useDebugValue=function(){},Us.useDeferredValue=function(D){return W.current.useDeferredValue(D)},Us.useEffect=function(D,O){return W.current.useEffect(D,O)},Us.useId=function(){return W.current.useId()},Us.useImperativeHandle=function(D,O,V){return W.current.useImperativeHandle(D,O,V)},Us.useInsertionEffect=function(D,O){return W.current.useInsertionEffect(D,O)},Us.useLayoutEffect=function(D,O){return W.current.useLayoutEffect(D,O)},Us.useMemo=function(D,O){return W.current.useMemo(D,O)},Us.useReducer=function(D,O,V){return W.current.useReducer(D,O,V)},Us.useRef=function(D){return W.current.useRef(D)},Us.useState=function(D){return W.current.useState(D)},Us.useSyncExternalStore=function(D,O,V){return W.current.useSyncExternalStore(D,O,V)},Us.useTransition=function(){return W.current.useTransition()},Us.version="18.3.1",Us}var eN;function Lc(){return eN||(eN=1,lx.exports=ET()),lx.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 tN;function DT(){if(tN)return vd;tN=1;var t=Lc(),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,l={key:!0,ref:!0,__self:!0,__source:!0};function c(d,h,x){var f,m={},p=null,u=null;x!==void 0&&(p=""+x),h.key!==void 0&&(p=""+h.key),h.ref!==void 0&&(u=h.ref);for(f in h)r.call(h,f)&&!l.hasOwnProperty(f)&&(m[f]=h[f]);if(d&&d.defaultProps)for(f in h=d.defaultProps,h)m[f]===void 0&&(m[f]=h[f]);return{$$typeof:s,type:d,key:p,ref:u,props:m,_owner:a.current}}return vd.Fragment=n,vd.jsx=c,vd.jsxs=c,vd}var sN;function TT(){return sN||(sN=1,ix.exports=DT()),ix.exports}var e=TT(),v=Lc();const gt=_m(v),Om=RT({__proto__:null,default:gt},[v]);var jh={},ox={exports:{}},Zr={},cx={exports:{}},dx={};/**
* @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 nN;function PT(){return nN||(nN=1,(function(t){function s(z,F){var B=z.length;z.push(F);e:for(;0<B;){var D=B-1>>>1,O=z[D];if(0<a(O,F))z[D]=F,z[B]=O,B=D;else break e}}function n(z){return z.length===0?null:z[0]}function r(z){if(z.length===0)return null;var F=z[0],B=z.pop();if(B!==F){z[0]=B;e:for(var D=0,O=z.length,V=O>>>1;D<V;){var K=2*(D+1)-1,Y=z[K],U=K+1,X=z[U];if(0>a(Y,B))U<O&&0>a(X,Y)?(z[D]=X,z[U]=B,D=U):(z[D]=Y,z[K]=B,D=K);else if(U<O&&0>a(X,B))z[D]=X,z[U]=B,D=U;else break e}}return F}function a(z,F){var B=z.sortIndex-F.sortIndex;return B!==0?B:z.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;t.unstable_now=function(){return l.now()}}else{var c=Date,d=c.now();t.unstable_now=function(){return c.now()-d}}var h=[],x=[],f=1,m=null,p=3,u=!1,j=!1,g=!1,y=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,S=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(z){for(var F=n(x);F!==null;){if(F.callback===null)r(x);else if(F.startTime<=z)r(x),F.sortIndex=F.expirationTime,s(h,F);else break;F=n(x)}}function w(z){if(g=!1,C(z),!j)if(n(h)!==null)j=!0,Z(R);else{var F=n(x);F!==null&&W(w,F.startTime-z)}}function R(z,F){j=!1,g&&(g=!1,N(I),I=-1),u=!0;var B=p;try{for(C(F),m=n(h);m!==null&&(!(m.expirationTime>F)||z&&!E());){var D=m.callback;if(typeof D=="function"){m.callback=null,p=m.priorityLevel;var O=D(m.expirationTime<=F);F=t.unstable_now(),typeof O=="function"?m.callback=O:m===n(h)&&r(h),C(F)}else r(h);m=n(h)}if(m!==null)var V=!0;else{var K=n(x);K!==null&&W(w,K.startTime-F),V=!1}return V}finally{m=null,p=B,u=!1}}var P=!1,A=null,I=-1,$=5,T=-1;function E(){return!(t.unstable_now()-T<$)}function _(){if(A!==null){var z=t.unstable_now();T=z;var F=!0;try{F=A(!0,z)}finally{F?M():(P=!1,A=null)}}else P=!1}var M;if(typeof S=="function")M=function(){S(_)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,G=q.port2;q.port1.onmessage=_,M=function(){G.postMessage(null)}}else M=function(){y(_,0)};function Z(z){A=z,P||(P=!0,M())}function W(z,F){I=y(function(){z(t.unstable_now())},F)}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(z){z.callback=null},t.unstable_continueExecution=function(){j||u||(j=!0,Z(R))},t.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<z?Math.floor(1e3/z):5},t.unstable_getCurrentPriorityLevel=function(){return p},t.unstable_getFirstCallbackNode=function(){return n(h)},t.unstable_next=function(z){switch(p){case 1:case 2:case 3:var F=3;break;default:F=p}var B=p;p=F;try{return z()}finally{p=B}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(z,F){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var B=p;p=z;try{return F()}finally{p=B}},t.unstable_scheduleCallback=function(z,F,B){var D=t.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?D+B:D):B=D,z){case 1:var O=-1;break;case 2:O=250;break;case 5:O=1073741823;break;case 4:O=1e4;break;default:O=5e3}return O=B+O,z={id:f++,callback:F,priorityLevel:z,startTime:B,expirationTime:O,sortIndex:-1},B>D?(z.sortIndex=B,s(x,z),n(h)===null&&z===n(x)&&(g?(N(I),I=-1):g=!0,W(w,B-D))):(z.sortIndex=O,s(h,z),j||u||(j=!0,Z(R))),z},t.unstable_shouldYield=E,t.unstable_wrapCallback=function(z){var F=p;return function(){var B=p;p=F;try{return z.apply(this,arguments)}finally{p=B}}}})(dx)),dx}var rN;function _T(){return rN||(rN=1,cx.exports=PT()),cx.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 aN;function OT(){if(aN)return Zr;aN=1;var t=Lc(),s=_T();function n(i){for(var o="https://reactjs.org/docs/error-decoder.html?invariant="+i,b=1;b<arguments.length;b++)o+="&args[]="+encodeURIComponent(arguments[b]);return"Minified React error #"+i+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,a={};function l(i,o){c(i,o),c(i+"Capture",o)}function c(i,o){for(a[i]=o,i=0;i<o.length;i++)r.add(o[i])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,x=/^[: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]*$/,f={},m={};function p(i){return h.call(m,i)?!0:h.call(f,i)?!1:x.test(i)?m[i]=!0:(f[i]=!0,!1)}function u(i,o,b,k){if(b!==null&&b.type===0)return!1;switch(typeof o){case"function":case"symbol":return!0;case"boolean":return k?!1:b!==null?!b.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function j(i,o,b,k){if(o===null||typeof o>"u"||u(i,o,b,k))return!0;if(k)return!1;if(b!==null)switch(b.type){case 3:return!o;case 4:return o===!1;case 5:return isNaN(o);case 6:return isNaN(o)||1>o}return!1}function g(i,o,b,k,L,H,ae){this.acceptsBooleans=o===2||o===3||o===4,this.attributeName=k,this.attributeNamespace=L,this.mustUseProperty=b,this.propertyName=i,this.type=o,this.sanitizeURL=H,this.removeEmptyString=ae}var y={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){y[i]=new g(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var o=i[0];y[o]=new g(o,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){y[i]=new g(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){y[i]=new g(i,2,!1,i,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(i){y[i]=new g(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){y[i]=new g(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){y[i]=new g(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){y[i]=new g(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){y[i]=new g(i,5,!1,i.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function S(i){return i[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(i){var o=i.replace(N,S);y[o]=new g(o,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var o=i.replace(N,S);y[o]=new g(o,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var o=i.replace(N,S);y[o]=new g(o,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){y[i]=new g(i,1,!1,i.toLowerCase(),null,!1,!1)}),y.xlinkHref=new g("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){y[i]=new g(i,1,!1,i.toLowerCase(),null,!0,!0)});function C(i,o,b,k){var L=y.hasOwnProperty(o)?y[o]:null;(L!==null?L.type!==0:k||!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(j(o,b,L,k)&&(b=null),k||L===null?p(o)&&(b===null?i.removeAttribute(o):i.setAttribute(o,""+b)):L.mustUseProperty?i[L.propertyName]=b===null?L.type===3?!1:"":b:(o=L.attributeName,k=L.attributeNamespace,b===null?i.removeAttribute(o):(L=L.type,b=L===3||L===4&&b===!0?"":""+b,k?i.setAttributeNS(k,o,b):i.setAttribute(o,b))))}var w=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,R=Symbol.for("react.element"),P=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),$=Symbol.for("react.profiler"),T=Symbol.for("react.provider"),E=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),q=Symbol.for("react.suspense_list"),G=Symbol.for("react.memo"),Z=Symbol.for("react.lazy"),W=Symbol.for("react.offscreen"),z=Symbol.iterator;function F(i){return i===null||typeof i!="object"?null:(i=z&&i[z]||i["@@iterator"],typeof i=="function"?i:null)}var B=Object.assign,D;function O(i){if(D===void 0)try{throw Error()}catch(b){var o=b.stack.trim().match(/\n( *(at )?)/);D=o&&o[1]||""}return`
`+D+i}var V=!1;function K(i,o){if(!i||V)return"";V=!0;var b=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(o)if(o=function(){throw Error()},Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(Je){var k=Je}Reflect.construct(i,[],o)}else{try{o.call()}catch(Je){k=Je}i.call(o.prototype)}else{try{throw Error()}catch(Je){k=Je}i()}}catch(Je){if(Je&&k&&typeof Je.stack=="string"){for(var L=Je.stack.split(`
`),H=k.stack.split(`
`),ae=L.length-1,je=H.length-1;1<=ae&&0<=je&&L[ae]!==H[je];)je--;for(;1<=ae&&0<=je;ae--,je--)if(L[ae]!==H[je]){if(ae!==1||je!==1)do if(ae--,je--,0>je||L[ae]!==H[je]){var De=`
`+L[ae].replace(" at new "," at ");return i.displayName&&De.includes("<anonymous>")&&(De=De.replace("<anonymous>",i.displayName)),De}while(1<=ae&&0<=je);break}}}finally{V=!1,Error.prepareStackTrace=b}return(i=i?i.displayName||i.name:"")?O(i):""}function Y(i){switch(i.tag){case 5:return O(i.type);case 16:return O("Lazy");case 13:return O("Suspense");case 19:return O("SuspenseList");case 0:case 2:case 15:return i=K(i.type,!1),i;case 11:return i=K(i.type.render,!1),i;case 1:return i=K(i.type,!0),i;default:return""}}function U(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case A:return"Fragment";case P:return"Portal";case $:return"Profiler";case I:return"StrictMode";case M:return"Suspense";case q:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case E:return(i.displayName||"Context")+".Consumer";case T:return(i._context.displayName||"Context")+".Provider";case _:var o=i.render;return i=i.displayName,i||(i=o.displayName||o.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case G:return o=i.displayName||null,o!==null?o:U(i.type)||"Memo";case Z:o=i._payload,i=i._init;try{return U(i(o))}catch{}}return null}function X(i){var o=i.type;switch(i.tag){case 24:return"Cache";case 9:return(o.displayName||"Context")+".Consumer";case 10:return(o._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=o.render,i=i.displayName||i.name||"",o.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return o;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return U(o);case 8:return o===I?"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 o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o}return null}function ne(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function oe(i){var o=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function re(i){var o=oe(i)?"checked":"value",b=Object.getOwnPropertyDescriptor(i.constructor.prototype,o),k=""+i[o];if(!i.hasOwnProperty(o)&&typeof b<"u"&&typeof b.get=="function"&&typeof b.set=="function"){var L=b.get,H=b.set;return Object.defineProperty(i,o,{configurable:!0,get:function(){return L.call(this)},set:function(ae){k=""+ae,H.call(this,ae)}}),Object.defineProperty(i,o,{enumerable:b.enumerable}),{getValue:function(){return k},setValue:function(ae){k=""+ae},stopTracking:function(){i._valueTracker=null,delete i[o]}}}}function ge(i){i._valueTracker||(i._valueTracker=re(i))}function ve(i){if(!i)return!1;var o=i._valueTracker;if(!o)return!0;var b=o.getValue(),k="";return i&&(k=oe(i)?i.checked?"true":"false":i.value),i=k,i!==b?(o.setValue(i),!0):!1}function Se(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}function We(i,o){var b=o.checked;return B({},o,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:b??i._wrapperState.initialChecked})}function Ce(i,o){var b=o.defaultValue==null?"":o.defaultValue,k=o.checked!=null?o.checked:o.defaultChecked;b=ne(o.value!=null?o.value:b),i._wrapperState={initialChecked:k,initialValue:b,controlled:o.type==="checkbox"||o.type==="radio"?o.checked!=null:o.value!=null}}function fe(i,o){o=o.checked,o!=null&&C(i,"checked",o,!1)}function Ye(i,o){fe(i,o);var b=ne(o.value),k=o.type;if(b!=null)k==="number"?(b===0&&i.value===""||i.value!=b)&&(i.value=""+b):i.value!==""+b&&(i.value=""+b);else if(k==="submit"||k==="reset"){i.removeAttribute("value");return}o.hasOwnProperty("value")?_e(i,o.type,b):o.hasOwnProperty("defaultValue")&&_e(i,o.type,ne(o.defaultValue)),o.checked==null&&o.defaultChecked!=null&&(i.defaultChecked=!!o.defaultChecked)}function be(i,o,b){if(o.hasOwnProperty("value")||o.hasOwnProperty("defaultValue")){var k=o.type;if(!(k!=="submit"&&k!=="reset"||o.value!==void 0&&o.value!==null))return;o=""+i._wrapperState.initialValue,b||o===i.value||(i.value=o),i.defaultValue=o}b=i.name,b!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,b!==""&&(i.name=b)}function _e(i,o,b){(o!=="number"||Se(i.ownerDocument)!==i)&&(b==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+b&&(i.defaultValue=""+b))}var ke=Array.isArray;function qe(i,o,b,k){if(i=i.options,o){o={};for(var L=0;L<b.length;L++)o["$"+b[L]]=!0;for(b=0;b<i.length;b++)L=o.hasOwnProperty("$"+i[b].value),i[b].selected!==L&&(i[b].selected=L),L&&k&&(i[b].defaultSelected=!0)}else{for(b=""+ne(b),o=null,L=0;L<i.length;L++){if(i[L].value===b){i[L].selected=!0,k&&(i[L].defaultSelected=!0);return}o!==null||i[L].disabled||(o=i[L])}o!==null&&(o.selected=!0)}}function Ve(i,o){if(o.dangerouslySetInnerHTML!=null)throw Error(n(91));return B({},o,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function dt(i,o){var b=o.value;if(b==null){if(b=o.children,o=o.defaultValue,b!=null){if(o!=null)throw Error(n(92));if(ke(b)){if(1<b.length)throw Error(n(93));b=b[0]}o=b}o==null&&(o=""),b=o}i._wrapperState={initialValue:ne(b)}}function xt(i,o){var b=ne(o.value),k=ne(o.defaultValue);b!=null&&(b=""+b,b!==i.value&&(i.value=b),o.defaultValue==null&&i.defaultValue!==b&&(i.defaultValue=b)),k!=null&&(i.defaultValue=""+k)}function ye(i){var o=i.textContent;o===i._wrapperState.initialValue&&o!==""&&o!==null&&(i.value=o)}function le(i){switch(i){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 Qe(i,o){return i==null||i==="http://www.w3.org/1999/xhtml"?le(o):i==="http://www.w3.org/2000/svg"&&o==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var rt,Kt=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(o,b,k,L){MSApp.execUnsafeLocalFunction(function(){return i(o,b,k,L)})}:i})(function(i,o){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=o;else{for(rt=rt||document.createElement("div"),rt.innerHTML="<svg>"+o.valueOf().toString()+"</svg>",o=rt.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;o.firstChild;)i.appendChild(o.firstChild)}});function Rt(i,o){if(o){var b=i.firstChild;if(b&&b===i.lastChild&&b.nodeType===3){b.nodeValue=o;return}}i.textContent=o}var Re={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},Qt=["Webkit","ms","Moz","O"];Object.keys(Re).forEach(function(i){Qt.forEach(function(o){o=o+i.charAt(0).toUpperCase()+i.substring(1),Re[o]=Re[i]})});function qt(i,o,b){return o==null||typeof o=="boolean"||o===""?"":b||typeof o!="number"||o===0||Re.hasOwnProperty(i)&&Re[i]?(""+o).trim():o+"px"}function ws(i,o){i=i.style;for(var b in o)if(o.hasOwnProperty(b)){var k=b.indexOf("--")===0,L=qt(b,o[b],k);b==="float"&&(b="cssFloat"),k?i.setProperty(b,L):i[b]=L}}var _s=B({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 ns(i,o){if(o){if(_s[i]&&(o.children!=null||o.dangerouslySetInnerHTML!=null))throw Error(n(137,i));if(o.dangerouslySetInnerHTML!=null){if(o.children!=null)throw Error(n(60));if(typeof o.dangerouslySetInnerHTML!="object"||!("__html"in o.dangerouslySetInnerHTML))throw Error(n(61))}if(o.style!=null&&typeof o.style!="object")throw Error(n(62))}}function Cs(i,o){if(i.indexOf("-")===-1)return typeof o.is=="string";switch(i){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 Bs=null;function Ft(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var ie=null,Fe=null,Q=null;function pe(i){if(i=nd(i)){if(typeof ie!="function")throw Error(n(280));var o=i.stateNode;o&&(o=Lu(o),ie(i.stateNode,i.type,o))}}function Ne(i){Fe?Q?Q.push(i):Q=[i]:Fe=i}function Ee(){if(Fe){var i=Fe,o=Q;if(Q=Fe=null,pe(i),o)for(i=0;i<o.length;i++)pe(o[i])}}function it(i,o){return i(o)}function st(){}var bt=!1;function Ue(i,o,b){if(bt)return i(o,b);bt=!0;try{return it(i,o,b)}finally{bt=!1,(Fe!==null||Q!==null)&&(st(),Ee())}}function Lt(i,o){var b=i.stateNode;if(b===null)return null;var k=Lu(b);if(k===null)return null;b=k[o];e:switch(o){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)||(i=i.type,k=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!k;break e;default:i=!1}if(i)return null;if(b&&typeof b!="function")throw Error(n(231,o,typeof b));return b}var ut=!1;if(d)try{var yt={};Object.defineProperty(yt,"passive",{get:function(){ut=!0}}),window.addEventListener("test",yt,yt),window.removeEventListener("test",yt,yt)}catch{ut=!1}function kt(i,o,b,k,L,H,ae,je,De){var Je=Array.prototype.slice.call(arguments,3);try{o.apply(b,Je)}catch(Nt){this.onError(Nt)}}var Ie=!1,_t=null,ht=!1,zt=null,rs={onError:function(i){Ie=!0,_t=i}};function Yt(i,o,b,k,L,H,ae,je,De){Ie=!1,_t=null,kt.apply(rs,arguments)}function Os(i,o,b,k,L,H,ae,je,De){if(Yt.apply(this,arguments),Ie){if(Ie){var Je=_t;Ie=!1,_t=null}else throw Error(n(198));ht||(ht=!0,zt=Je)}}function Is(i){var o=i,b=i;if(i.alternate)for(;o.return;)o=o.return;else{i=o;do o=i,(o.flags&4098)!==0&&(b=o.return),i=o.return;while(i)}return o.tag===3?b:null}function zs(i){if(i.tag===13){var o=i.memoizedState;if(o===null&&(i=i.alternate,i!==null&&(o=i.memoizedState)),o!==null)return o.dehydrated}return null}function en(i){if(Is(i)!==i)throw Error(n(188))}function he(i){var o=i.alternate;if(!o){if(o=Is(i),o===null)throw Error(n(188));return o!==i?null:i}for(var b=i,k=o;;){var L=b.return;if(L===null)break;var H=L.alternate;if(H===null){if(k=L.return,k!==null){b=k;continue}break}if(L.child===H.child){for(H=L.child;H;){if(H===b)return en(L),i;if(H===k)return en(L),o;H=H.sibling}throw Error(n(188))}if(b.return!==k.return)b=L,k=H;else{for(var ae=!1,je=L.child;je;){if(je===b){ae=!0,b=L,k=H;break}if(je===k){ae=!0,k=L,b=H;break}je=je.sibling}if(!ae){for(je=H.child;je;){if(je===b){ae=!0,b=H,k=L;break}if(je===k){ae=!0,k=H,b=L;break}je=je.sibling}if(!ae)throw Error(n(189))}}if(b.alternate!==k)throw Error(n(190))}if(b.tag!==3)throw Error(n(188));return b.stateNode.current===b?i:o}function Ge(i){return i=he(i),i!==null?at(i):null}function at(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var o=at(i);if(o!==null)return o;i=i.sibling}return null}var pt=s.unstable_scheduleCallback,mt=s.unstable_cancelCallback,Bt=s.unstable_shouldYield,Ds=s.unstable_requestPaint,as=s.unstable_now,Vs=s.unstable_getCurrentPriorityLevel,Ls=s.unstable_ImmediatePriority,Ts=s.unstable_UserBlockingPriority,ln=s.unstable_NormalPriority,pn=s.unstable_LowPriority,hn=s.unstable_IdlePriority,Ws=null,Qs=null;function zn(i){if(Qs&&typeof Qs.onCommitFiberRoot=="function")try{Qs.onCommitFiberRoot(Ws,i,void 0,(i.current.flags&128)===128)}catch{}}var on=Math.clz32?Math.clz32:Tr,Un=Math.log,yr=Math.LN2;function Tr(i){return i>>>=0,i===0?32:31-(Un(i)/yr|0)|0}var er=64,tr=4194304;function En(i){switch(i&-i){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 i&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return i&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return i}}function Xe(i,o){var b=i.pendingLanes;if(b===0)return 0;var k=0,L=i.suspendedLanes,H=i.pingedLanes,ae=b&268435455;if(ae!==0){var je=ae&~L;je!==0?k=En(je):(H&=ae,H!==0&&(k=En(H)))}else ae=b&~L,ae!==0?k=En(ae):H!==0&&(k=En(H));if(k===0)return 0;if(o!==0&&o!==k&&(o&L)===0&&(L=k&-k,H=o&-o,L>=H||L===16&&(H&4194240)!==0))return o;if((k&4)!==0&&(k|=b&16),o=i.entangledLanes,o!==0)for(i=i.entanglements,o&=k;0<o;)b=31-on(o),L=1<<b,k|=i[b],o&=~L;return k}function $t(i,o){switch(i){case 1:case 2:case 4:return o+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 o+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 Ze(i,o){for(var b=i.suspendedLanes,k=i.pingedLanes,L=i.expirationTimes,H=i.pendingLanes;0<H;){var ae=31-on(H),je=1<<ae,De=L[ae];De===-1?((je&b)===0||(je&k)!==0)&&(L[ae]=$t(je,o)):De<=o&&(i.expiredLanes|=je),H&=~je}}function Ut(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function jt(){var i=er;return er<<=1,(er&4194240)===0&&(er=64),i}function In(i){for(var o=[],b=0;31>b;b++)o.push(i);return o}function jr(i,o,b){i.pendingLanes|=o,o!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,o=31-on(o),i[o]=b}function Pr(i,o){var b=i.pendingLanes&~o;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=o,i.mutableReadLanes&=o,i.entangledLanes&=o,o=i.entanglements;var k=i.eventTimes;for(i=i.expirationTimes;0<b;){var L=31-on(b),H=1<<L;o[L]=0,k[L]=-1,i[L]=-1,b&=~H}}function xn(i,o){var b=i.entangledLanes|=o;for(i=i.entanglements;b;){var k=31-on(b),L=1<<k;L&o|i[k]&o&&(i[k]|=o),b&=~L}}var qs=0;function ha(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var Tt,xs,Vr,ta,ma,_r=!1,sr=[],gn=null,mn=null,Qn=null,fr=new Map,pr=new Map,dn=[],wn="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 Da(i,o){switch(i){case"focusin":case"focusout":gn=null;break;case"dragenter":case"dragleave":mn=null;break;case"mouseover":case"mouseout":Qn=null;break;case"pointerover":case"pointerout":fr.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":pr.delete(o.pointerId)}}function fa(i,o,b,k,L,H){return i===null||i.nativeEvent!==H?(i={blockedOn:o,domEventName:b,eventSystemFlags:k,nativeEvent:H,targetContainers:[L]},o!==null&&(o=nd(o),o!==null&&xs(o)),i):(i.eventSystemFlags|=k,o=i.targetContainers,L!==null&&o.indexOf(L)===-1&&o.push(L),i)}function Ai(i,o,b,k,L){switch(o){case"focusin":return gn=fa(gn,i,o,b,k,L),!0;case"dragenter":return mn=fa(mn,i,o,b,k,L),!0;case"mouseover":return Qn=fa(Qn,i,o,b,k,L),!0;case"pointerover":var H=L.pointerId;return fr.set(H,fa(fr.get(H)||null,i,o,b,k,L)),!0;case"gotpointercapture":return H=L.pointerId,pr.set(H,fa(pr.get(H)||null,i,o,b,k,L)),!0}return!1}function ki(i){var o=uo(i.target);if(o!==null){var b=Is(o);if(b!==null){if(o=b.tag,o===13){if(o=zs(b),o!==null){i.blockedOn=o,ma(i.priority,function(){Vr(b)});return}}else if(o===3&&b.stateNode.current.memoizedState.isDehydrated){i.blockedOn=b.tag===3?b.stateNode.containerInfo:null;return}}}i.blockedOn=null}function ni(i){if(i.blockedOn!==null)return!1;for(var o=i.targetContainers;0<o.length;){var b=ai(i.domEventName,i.eventSystemFlags,o[0],i.nativeEvent);if(b===null){b=i.nativeEvent;var k=new b.constructor(b.type,b);Bs=k,b.target.dispatchEvent(k),Bs=null}else return o=nd(b),o!==null&&xs(o),i.blockedOn=b,!1;o.shift()}return!0}function rl(i,o,b){ni(i)&&b.delete(o)}function Go(){_r=!1,gn!==null&&ni(gn)&&(gn=null),mn!==null&&ni(mn)&&(mn=null),Qn!==null&&ni(Qn)&&(Qn=null),fr.forEach(rl),pr.forEach(rl)}function Ta(i,o){i.blockedOn===o&&(i.blockedOn=null,_r||(_r=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Go)))}function ri(i){function o(L){return Ta(L,i)}if(0<sr.length){Ta(sr[0],i);for(var b=1;b<sr.length;b++){var k=sr[b];k.blockedOn===i&&(k.blockedOn=null)}}for(gn!==null&&Ta(gn,i),mn!==null&&Ta(mn,i),Qn!==null&&Ta(Qn,i),fr.forEach(o),pr.forEach(o),b=0;b<dn.length;b++)k=dn[b],k.blockedOn===i&&(k.blockedOn=null);for(;0<dn.length&&(b=dn[0],b.blockedOn===null);)ki(b),b.blockedOn===null&&dn.shift()}var Pa=w.ReactCurrentBatchConfig,_a=!0;function to(i,o,b,k){var L=qs,H=Pa.transition;Pa.transition=null;try{qs=1,Oa(i,o,b,k)}finally{qs=L,Pa.transition=H}}function Zc(i,o,b,k){var L=qs,H=Pa.transition;Pa.transition=null;try{qs=4,Oa(i,o,b,k)}finally{qs=L,Pa.transition=H}}function Oa(i,o,b,k){if(_a){var L=ai(i,o,b,k);if(L===null)Yf(i,o,k,Vn,b),Da(i,k);else if(Ai(L,i,o,b,k))k.stopPropagation();else if(Da(i,k),o&4&&-1<wn.indexOf(i)){for(;L!==null;){var H=nd(L);if(H!==null&&Tt(H),H=ai(i,o,b,k),H===null&&Yf(i,o,k,Vn,b),H===L)break;L=H}L!==null&&k.stopPropagation()}else Yf(i,o,k,null,b)}}var Vn=null;function ai(i,o,b,k){if(Vn=null,i=Ft(k),i=uo(i),i!==null)if(o=Is(i),o===null)i=null;else if(b=o.tag,b===13){if(i=zs(o),i!==null)return i;i=null}else if(b===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;i=null}else o!==i&&(i=null);return Vn=i,null}function Ri(i){switch(i){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(Vs()){case Ls:return 1;case Ts:return 4;case ln:case pn:return 16;case hn:return 536870912;default:return 16}default:return 16}}var Or=null,so=null,Ei=null;function no(){if(Ei)return Ei;var i,o=so,b=o.length,k,L="value"in Or?Or.value:Or.textContent,H=L.length;for(i=0;i<b&&o[i]===L[i];i++);var ae=b-i;for(k=1;k<=ae&&o[b-k]===L[H-k];k++);return Ei=L.slice(i,1<k?1-k:void 0)}function ii(i){var o=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&o===13&&(i=13)):i=o,i===10&&(i=13),32<=i||i===13?i:0}function al(){return!0}function ro(){return!1}function Hs(i){function o(b,k,L,H,ae){this._reactName=b,this._targetInst=L,this.type=k,this.nativeEvent=H,this.target=ae,this.currentTarget=null;for(var je in i)i.hasOwnProperty(je)&&(b=i[je],this[je]=b?b(H):H[je]);return this.isDefaultPrevented=(H.defaultPrevented!=null?H.defaultPrevented:H.returnValue===!1)?al:ro,this.isPropagationStopped=ro,this}return B(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var b=this.nativeEvent;b&&(b.preventDefault?b.preventDefault():typeof b.returnValue!="unknown"&&(b.returnValue=!1),this.isDefaultPrevented=al)},stopPropagation:function(){var b=this.nativeEvent;b&&(b.stopPropagation?b.stopPropagation():typeof b.cancelBubble!="unknown"&&(b.cancelBubble=!0),this.isPropagationStopped=al)},persist:function(){},isPersistent:al}),o}var J={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},te=Hs(J),ue=B({},J,{view:0,detail:0}),xe=Hs(ue),we,$e,Be,lt=B({},ue,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:rr,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==Be&&(Be&&i.type==="mousemove"?(we=i.screenX-Be.screenX,$e=i.screenY-Be.screenY):$e=we=0,Be=i),we)},movementY:function(i){return"movementY"in i?i.movementY:$e}}),Jt=Hs(lt),Mt=B({},lt,{dataTransfer:0}),Et=Hs(Mt),gs=B({},ue,{relatedTarget:0}),tn=Hs(gs),Hn=B({},J,{animationName:0,elapsedTime:0,pseudoElement:0}),Ot=Hs(Hn),bs=B({},J,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),es=Hs(bs),Sn=B({},J,{data:0}),xr=Hs(Sn),Dn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},nr={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"},Ir={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ia(i){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(i):(i=Ir[i])?!!o[i]:!1}function rr(){return Ia}var ao=B({},ue,{key:function(i){if(i.key){var o=Dn[i.key]||i.key;if(o!=="Unidentified")return o}return i.type==="keypress"?(i=ii(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?nr[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:rr,charCode:function(i){return i.type==="keypress"?ii(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?ii(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),il=Hs(ao),io=B({},lt,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),lo=Hs(io),ll=B({},ue,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:rr}),Di=Hs(ll),La=B({},J,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ko=Hs(La),ar=B({},lt,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),Yo=Hs(ar),pa=[9,13,27,32],ol=d&&"CompositionEvent"in window,Ti=null;d&&"documentMode"in document&&(Ti=document.documentMode);var xa=d&&"TextEvent"in window&&!Ti,Ma=d&&(!ol||Ti&&8<Ti&&11>=Ti),cl=" ",Pi=!1;function oo(i,o){switch(i){case"keyup":return pa.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ku(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var dl=!1;function Lf(i,o){switch(i){case"compositionend":return ku(o);case"keypress":return o.which!==32?null:(Pi=!0,cl);case"textInput":return i=o.data,i===cl&&Pi?null:i;default:return null}}function Mf(i,o){if(dl)return i==="compositionend"||!ol&&oo(i,o)?(i=no(),Ei=so=Or=null,dl=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return Ma&&o.locale!=="ko"?null:o.data;default:return null}}var Ff={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 Ru(i){var o=i&&i.nodeName&&i.nodeName.toLowerCase();return o==="input"?!!Ff[i.type]:o==="textarea"}function Eu(i,o,b,k){Ne(k),o=_u(o,"onChange"),0<o.length&&(b=new te("onChange","change",null,b,k),i.push({event:b,listeners:o}))}var co=null,ul=null;function ga(i){py(i,0)}function li(i){var o=ec(i);if(ve(o))return i}function Bf(i,o){if(i==="change")return o}var Xb=!1;if(d){var $f;if(d){var qf="oninput"in document;if(!qf){var Jb=document.createElement("div");Jb.setAttribute("oninput","return;"),qf=typeof Jb.oninput=="function"}$f=qf}else $f=!1;Xb=$f&&(!document.documentMode||9<document.documentMode)}function ey(){co&&(co.detachEvent("onpropertychange",ty),ul=co=null)}function ty(i){if(i.propertyName==="value"&&li(ul)){var o=[];Eu(o,ul,i,Ft(i)),Ue(ga,o)}}function RD(i,o,b){i==="focusin"?(ey(),co=o,ul=b,co.attachEvent("onpropertychange",ty)):i==="focusout"&&ey()}function ED(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return li(ul)}function DD(i,o){if(i==="click")return li(o)}function TD(i,o){if(i==="input"||i==="change")return li(o)}function PD(i,o){return i===o&&(i!==0||1/i===1/o)||i!==i&&o!==o}var Fa=typeof Object.is=="function"?Object.is:PD;function Qc(i,o){if(Fa(i,o))return!0;if(typeof i!="object"||i===null||typeof o!="object"||o===null)return!1;var b=Object.keys(i),k=Object.keys(o);if(b.length!==k.length)return!1;for(k=0;k<b.length;k++){var L=b[k];if(!h.call(o,L)||!Fa(i[L],o[L]))return!1}return!0}function sy(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function ny(i,o){var b=sy(i);i=0;for(var k;b;){if(b.nodeType===3){if(k=i+b.textContent.length,i<=o&&k>=o)return{node:b,offset:o-i};i=k}e:{for(;b;){if(b.nextSibling){b=b.nextSibling;break e}b=b.parentNode}b=void 0}b=sy(b)}}function ry(i,o){return i&&o?i===o?!0:i&&i.nodeType===3?!1:o&&o.nodeType===3?ry(i,o.parentNode):"contains"in i?i.contains(o):i.compareDocumentPosition?!!(i.compareDocumentPosition(o)&16):!1:!1}function ay(){for(var i=window,o=Se();o instanceof i.HTMLIFrameElement;){try{var b=typeof o.contentWindow.location.href=="string"}catch{b=!1}if(b)i=o.contentWindow;else break;o=Se(i.document)}return o}function zf(i){var o=i&&i.nodeName&&i.nodeName.toLowerCase();return o&&(o==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||o==="textarea"||i.contentEditable==="true")}function _D(i){var o=ay(),b=i.focusedElem,k=i.selectionRange;if(o!==b&&b&&b.ownerDocument&&ry(b.ownerDocument.documentElement,b)){if(k!==null&&zf(b)){if(o=k.start,i=k.end,i===void 0&&(i=o),"selectionStart"in b)b.selectionStart=o,b.selectionEnd=Math.min(i,b.value.length);else if(i=(o=b.ownerDocument||document)&&o.defaultView||window,i.getSelection){i=i.getSelection();var L=b.textContent.length,H=Math.min(k.start,L);k=k.end===void 0?H:Math.min(k.end,L),!i.extend&&H>k&&(L=k,k=H,H=L),L=ny(b,H);var ae=ny(b,k);L&&ae&&(i.rangeCount!==1||i.anchorNode!==L.node||i.anchorOffset!==L.offset||i.focusNode!==ae.node||i.focusOffset!==ae.offset)&&(o=o.createRange(),o.setStart(L.node,L.offset),i.removeAllRanges(),H>k?(i.addRange(o),i.extend(ae.node,ae.offset)):(o.setEnd(ae.node,ae.offset),i.addRange(o)))}}for(o=[],i=b;i=i.parentNode;)i.nodeType===1&&o.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof b.focus=="function"&&b.focus(),b=0;b<o.length;b++)i=o[b],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var OD=d&&"documentMode"in document&&11>=document.documentMode,Zo=null,Uf=null,Xc=null,Vf=!1;function iy(i,o,b){var k=b.window===b?b.document:b.nodeType===9?b:b.ownerDocument;Vf||Zo==null||Zo!==Se(k)||(k=Zo,"selectionStart"in k&&zf(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}),Xc&&Qc(Xc,k)||(Xc=k,k=_u(Uf,"onSelect"),0<k.length&&(o=new te("onSelect","select",null,o,b),i.push({event:o,listeners:k}),o.target=Zo)))}function Du(i,o){var b={};return b[i.toLowerCase()]=o.toLowerCase(),b["Webkit"+i]="webkit"+o,b["Moz"+i]="moz"+o,b}var Qo={animationend:Du("Animation","AnimationEnd"),animationiteration:Du("Animation","AnimationIteration"),animationstart:Du("Animation","AnimationStart"),transitionend:Du("Transition","TransitionEnd")},Hf={},ly={};d&&(ly=document.createElement("div").style,"AnimationEvent"in window||(delete Qo.animationend.animation,delete Qo.animationiteration.animation,delete Qo.animationstart.animation),"TransitionEvent"in window||delete Qo.transitionend.transition);function Tu(i){if(Hf[i])return Hf[i];if(!Qo[i])return i;var o=Qo[i],b;for(b in o)if(o.hasOwnProperty(b)&&b in ly)return Hf[i]=o[b];return i}var oy=Tu("animationend"),cy=Tu("animationiteration"),dy=Tu("animationstart"),uy=Tu("transitionend"),hy=new Map,my="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 hl(i,o){hy.set(i,o),l(o,[i])}for(var Wf=0;Wf<my.length;Wf++){var Gf=my[Wf],ID=Gf.toLowerCase(),LD=Gf[0].toUpperCase()+Gf.slice(1);hl(ID,"on"+LD)}hl(oy,"onAnimationEnd"),hl(cy,"onAnimationIteration"),hl(dy,"onAnimationStart"),hl("dblclick","onDoubleClick"),hl("focusin","onFocus"),hl("focusout","onBlur"),hl(uy,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Jc="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(" "),MD=new Set("cancel close invalid load scroll toggle".split(" ").concat(Jc));function fy(i,o,b){var k=i.type||"unknown-event";i.currentTarget=b,Os(k,o,void 0,i),i.currentTarget=null}function py(i,o){o=(o&4)!==0;for(var b=0;b<i.length;b++){var k=i[b],L=k.event;k=k.listeners;e:{var H=void 0;if(o)for(var ae=k.length-1;0<=ae;ae--){var je=k[ae],De=je.instance,Je=je.currentTarget;if(je=je.listener,De!==H&&L.isPropagationStopped())break e;fy(L,je,Je),H=De}else for(ae=0;ae<k.length;ae++){if(je=k[ae],De=je.instance,Je=je.currentTarget,je=je.listener,De!==H&&L.isPropagationStopped())break e;fy(L,je,Je),H=De}}}if(ht)throw i=zt,ht=!1,zt=null,i}function bn(i,o){var b=o[tp];b===void 0&&(b=o[tp]=new Set);var k=i+"__bubble";b.has(k)||(xy(o,i,2,!1),b.add(k))}function Kf(i,o,b){var k=0;o&&(k|=4),xy(b,i,k,o)}var Pu="_reactListening"+Math.random().toString(36).slice(2);function ed(i){if(!i[Pu]){i[Pu]=!0,r.forEach(function(b){b!=="selectionchange"&&(MD.has(b)||Kf(b,!1,i),Kf(b,!0,i))});var o=i.nodeType===9?i:i.ownerDocument;o===null||o[Pu]||(o[Pu]=!0,Kf("selectionchange",!1,o))}}function xy(i,o,b,k){switch(Ri(o)){case 1:var L=to;break;case 4:L=Zc;break;default:L=Oa}b=L.bind(null,o,b,i),L=void 0,!ut||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(L=!0),k?L!==void 0?i.addEventListener(o,b,{capture:!0,passive:L}):i.addEventListener(o,b,!0):L!==void 0?i.addEventListener(o,b,{passive:L}):i.addEventListener(o,b,!1)}function Yf(i,o,b,k,L){var H=k;if((o&1)===0&&(o&2)===0&&k!==null)e:for(;;){if(k===null)return;var ae=k.tag;if(ae===3||ae===4){var je=k.stateNode.containerInfo;if(je===L||je.nodeType===8&&je.parentNode===L)break;if(ae===4)for(ae=k.return;ae!==null;){var De=ae.tag;if((De===3||De===4)&&(De=ae.stateNode.containerInfo,De===L||De.nodeType===8&&De.parentNode===L))return;ae=ae.return}for(;je!==null;){if(ae=uo(je),ae===null)return;if(De=ae.tag,De===5||De===6){k=H=ae;continue e}je=je.parentNode}}k=k.return}Ue(function(){var Je=H,Nt=Ft(b),Dt=[];e:{var vt=hy.get(i);if(vt!==void 0){var Xt=te,is=i;switch(i){case"keypress":if(ii(b)===0)break e;case"keydown":case"keyup":Xt=il;break;case"focusin":is="focus",Xt=tn;break;case"focusout":is="blur",Xt=tn;break;case"beforeblur":case"afterblur":Xt=tn;break;case"click":if(b.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Xt=Jt;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Xt=Et;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Xt=Di;break;case oy:case cy:case dy:Xt=Ot;break;case uy:Xt=Ko;break;case"scroll":Xt=xe;break;case"wheel":Xt=Yo;break;case"copy":case"cut":case"paste":Xt=es;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Xt=lo}var cs=(o&4)!==0,Ln=!cs&&i==="scroll",He=cs?vt!==null?vt+"Capture":null:vt;cs=[];for(var Oe=Je,Ke;Oe!==null;){Ke=Oe;var It=Ke.stateNode;if(Ke.tag===5&&It!==null&&(Ke=It,He!==null&&(It=Lt(Oe,He),It!=null&&cs.push(td(Oe,It,Ke)))),Ln)break;Oe=Oe.return}0<cs.length&&(vt=new Xt(vt,is,null,b,Nt),Dt.push({event:vt,listeners:cs}))}}if((o&7)===0){e:{if(vt=i==="mouseover"||i==="pointerover",Xt=i==="mouseout"||i==="pointerout",vt&&b!==Bs&&(is=b.relatedTarget||b.fromElement)&&(uo(is)||is[_i]))break e;if((Xt||vt)&&(vt=Nt.window===Nt?Nt:(vt=Nt.ownerDocument)?vt.defaultView||vt.parentWindow:window,Xt?(is=b.relatedTarget||b.toElement,Xt=Je,is=is?uo(is):null,is!==null&&(Ln=Is(is),is!==Ln||is.tag!==5&&is.tag!==6)&&(is=null)):(Xt=null,is=Je),Xt!==is)){if(cs=Jt,It="onMouseLeave",He="onMouseEnter",Oe="mouse",(i==="pointerout"||i==="pointerover")&&(cs=lo,It="onPointerLeave",He="onPointerEnter",Oe="pointer"),Ln=Xt==null?vt:ec(Xt),Ke=is==null?vt:ec(is),vt=new cs(It,Oe+"leave",Xt,b,Nt),vt.target=Ln,vt.relatedTarget=Ke,It=null,uo(Nt)===Je&&(cs=new cs(He,Oe+"enter",is,b,Nt),cs.target=Ke,cs.relatedTarget=Ln,It=cs),Ln=It,Xt&&is)t:{for(cs=Xt,He=is,Oe=0,Ke=cs;Ke;Ke=Xo(Ke))Oe++;for(Ke=0,It=He;It;It=Xo(It))Ke++;for(;0<Oe-Ke;)cs=Xo(cs),Oe--;for(;0<Ke-Oe;)He=Xo(He),Ke--;for(;Oe--;){if(cs===He||He!==null&&cs===He.alternate)break t;cs=Xo(cs),He=Xo(He)}cs=null}else cs=null;Xt!==null&&gy(Dt,vt,Xt,cs,!1),is!==null&&Ln!==null&&gy(Dt,Ln,is,cs,!0)}}e:{if(vt=Je?ec(Je):window,Xt=vt.nodeName&&vt.nodeName.toLowerCase(),Xt==="select"||Xt==="input"&&vt.type==="file")var hs=Bf;else if(Ru(vt))if(Xb)hs=TD;else{hs=ED;var ys=RD}else(Xt=vt.nodeName)&&Xt.toLowerCase()==="input"&&(vt.type==="checkbox"||vt.type==="radio")&&(hs=DD);if(hs&&(hs=hs(i,Je))){Eu(Dt,hs,b,Nt);break e}ys&&ys(i,vt,Je),i==="focusout"&&(ys=vt._wrapperState)&&ys.controlled&&vt.type==="number"&&_e(vt,"number",vt.value)}switch(ys=Je?ec(Je):window,i){case"focusin":(Ru(ys)||ys.contentEditable==="true")&&(Zo=ys,Uf=Je,Xc=null);break;case"focusout":Xc=Uf=Zo=null;break;case"mousedown":Vf=!0;break;case"contextmenu":case"mouseup":case"dragend":Vf=!1,iy(Dt,b,Nt);break;case"selectionchange":if(OD)break;case"keydown":case"keyup":iy(Dt,b,Nt)}var js;if(ol)e:{switch(i){case"compositionstart":var Ps="onCompositionStart";break e;case"compositionend":Ps="onCompositionEnd";break e;case"compositionupdate":Ps="onCompositionUpdate";break e}Ps=void 0}else dl?oo(i,b)&&(Ps="onCompositionEnd"):i==="keydown"&&b.keyCode===229&&(Ps="onCompositionStart");Ps&&(Ma&&b.locale!=="ko"&&(dl||Ps!=="onCompositionStart"?Ps==="onCompositionEnd"&&dl&&(js=no()):(Or=Nt,so="value"in Or?Or.value:Or.textContent,dl=!0)),ys=_u(Je,Ps),0<ys.length&&(Ps=new xr(Ps,i,null,b,Nt),Dt.push({event:Ps,listeners:ys}),js?Ps.data=js:(js=ku(b),js!==null&&(Ps.data=js)))),(js=xa?Lf(i,b):Mf(i,b))&&(Je=_u(Je,"onBeforeInput"),0<Je.length&&(Nt=new xr("onBeforeInput","beforeinput",null,b,Nt),Dt.push({event:Nt,listeners:Je}),Nt.data=js))}py(Dt,o)})}function td(i,o,b){return{instance:i,listener:o,currentTarget:b}}function _u(i,o){for(var b=o+"Capture",k=[];i!==null;){var L=i,H=L.stateNode;L.tag===5&&H!==null&&(L=H,H=Lt(i,b),H!=null&&k.unshift(td(i,H,L)),H=Lt(i,o),H!=null&&k.push(td(i,H,L))),i=i.return}return k}function Xo(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function gy(i,o,b,k,L){for(var H=o._reactName,ae=[];b!==null&&b!==k;){var je=b,De=je.alternate,Je=je.stateNode;if(De!==null&&De===k)break;je.tag===5&&Je!==null&&(je=Je,L?(De=Lt(b,H),De!=null&&ae.unshift(td(b,De,je))):L||(De=Lt(b,H),De!=null&&ae.push(td(b,De,je)))),b=b.return}ae.length!==0&&i.push({event:o,listeners:ae})}var FD=/\r\n?/g,BD=/\u0000|\uFFFD/g;function vy(i){return(typeof i=="string"?i:""+i).replace(FD,`
`).replace(BD,"")}function Ou(i,o,b){if(o=vy(o),vy(i)!==o&&b)throw Error(n(425))}function Iu(){}var Zf=null,Qf=null;function Xf(i,o){return i==="textarea"||i==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var Jf=typeof setTimeout=="function"?setTimeout:void 0,$D=typeof clearTimeout=="function"?clearTimeout:void 0,by=typeof Promise=="function"?Promise:void 0,qD=typeof queueMicrotask=="function"?queueMicrotask:typeof by<"u"?function(i){return by.resolve(null).then(i).catch(zD)}:Jf;function zD(i){setTimeout(function(){throw i})}function ep(i,o){var b=o,k=0;do{var L=b.nextSibling;if(i.removeChild(b),L&&L.nodeType===8)if(b=L.data,b==="/$"){if(k===0){i.removeChild(L),ri(o);return}k--}else b!=="$"&&b!=="$?"&&b!=="$!"||k++;b=L}while(b);ri(o)}function ml(i){for(;i!=null;i=i.nextSibling){var o=i.nodeType;if(o===1||o===3)break;if(o===8){if(o=i.data,o==="$"||o==="$!"||o==="$?")break;if(o==="/$")return null}}return i}function yy(i){i=i.previousSibling;for(var o=0;i;){if(i.nodeType===8){var b=i.data;if(b==="$"||b==="$!"||b==="$?"){if(o===0)return i;o--}else b==="/$"&&o++}i=i.previousSibling}return null}var Jo=Math.random().toString(36).slice(2),oi="__reactFiber$"+Jo,sd="__reactProps$"+Jo,_i="__reactContainer$"+Jo,tp="__reactEvents$"+Jo,UD="__reactListeners$"+Jo,VD="__reactHandles$"+Jo;function uo(i){var o=i[oi];if(o)return o;for(var b=i.parentNode;b;){if(o=b[_i]||b[oi]){if(b=o.alternate,o.child!==null||b!==null&&b.child!==null)for(i=yy(i);i!==null;){if(b=i[oi])return b;i=yy(i)}return o}i=b,b=i.parentNode}return null}function nd(i){return i=i[oi]||i[_i],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function ec(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function Lu(i){return i[sd]||null}var sp=[],tc=-1;function fl(i){return{current:i}}function yn(i){0>tc||(i.current=sp[tc],sp[tc]=null,tc--)}function vn(i,o){tc++,sp[tc]=i.current,i.current=o}var pl={},Nr=fl(pl),Hr=fl(!1),ho=pl;function sc(i,o){var b=i.type.contextTypes;if(!b)return pl;var k=i.stateNode;if(k&&k.__reactInternalMemoizedUnmaskedChildContext===o)return k.__reactInternalMemoizedMaskedChildContext;var L={},H;for(H in b)L[H]=o[H];return k&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=o,i.__reactInternalMemoizedMaskedChildContext=L),L}function Wr(i){return i=i.childContextTypes,i!=null}function Mu(){yn(Hr),yn(Nr)}function jy(i,o,b){if(Nr.current!==pl)throw Error(n(168));vn(Nr,o),vn(Hr,b)}function Ny(i,o,b){var k=i.stateNode;if(o=o.childContextTypes,typeof k.getChildContext!="function")return b;k=k.getChildContext();for(var L in k)if(!(L in o))throw Error(n(108,X(i)||"Unknown",L));return B({},b,k)}function Fu(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||pl,ho=Nr.current,vn(Nr,i),vn(Hr,Hr.current),!0}function wy(i,o,b){var k=i.stateNode;if(!k)throw Error(n(169));b?(i=Ny(i,o,ho),k.__reactInternalMemoizedMergedChildContext=i,yn(Hr),yn(Nr),vn(Nr,i)):yn(Hr),vn(Hr,b)}var Oi=null,Bu=!1,np=!1;function Sy(i){Oi===null?Oi=[i]:Oi.push(i)}function HD(i){Bu=!0,Sy(i)}function xl(){if(!np&&Oi!==null){np=!0;var i=0,o=qs;try{var b=Oi;for(qs=1;i<b.length;i++){var k=b[i];do k=k(!0);while(k!==null)}Oi=null,Bu=!1}catch(L){throw Oi!==null&&(Oi=Oi.slice(i+1)),pt(Ls,xl),L}finally{qs=o,np=!1}}return null}var nc=[],rc=0,$u=null,qu=0,va=[],ba=0,mo=null,Ii=1,Li="";function fo(i,o){nc[rc++]=qu,nc[rc++]=$u,$u=i,qu=o}function Cy(i,o,b){va[ba++]=Ii,va[ba++]=Li,va[ba++]=mo,mo=i;var k=Ii;i=Li;var L=32-on(k)-1;k&=~(1<<L),b+=1;var H=32-on(o)+L;if(30<H){var ae=L-L%5;H=(k&(1<<ae)-1).toString(32),k>>=ae,L-=ae,Ii=1<<32-on(o)+L|b<<L|k,Li=H+i}else Ii=1<<H|b<<L|k,Li=i}function rp(i){i.return!==null&&(fo(i,1),Cy(i,1,0))}function ap(i){for(;i===$u;)$u=nc[--rc],nc[rc]=null,qu=nc[--rc],nc[rc]=null;for(;i===mo;)mo=va[--ba],va[ba]=null,Li=va[--ba],va[ba]=null,Ii=va[--ba],va[ba]=null}var sa=null,na=null,Cn=!1,Ba=null;function Ay(i,o){var b=wa(5,null,null,0);b.elementType="DELETED",b.stateNode=o,b.return=i,o=i.deletions,o===null?(i.deletions=[b],i.flags|=16):o.push(b)}function ky(i,o){switch(i.tag){case 5:var b=i.type;return o=o.nodeType!==1||b.toLowerCase()!==o.nodeName.toLowerCase()?null:o,o!==null?(i.stateNode=o,sa=i,na=ml(o.firstChild),!0):!1;case 6:return o=i.pendingProps===""||o.nodeType!==3?null:o,o!==null?(i.stateNode=o,sa=i,na=null,!0):!1;case 13:return o=o.nodeType!==8?null:o,o!==null?(b=mo!==null?{id:Ii,overflow:Li}:null,i.memoizedState={dehydrated:o,treeContext:b,retryLane:1073741824},b=wa(18,null,null,0),b.stateNode=o,b.return=i,i.child=b,sa=i,na=null,!0):!1;default:return!1}}function ip(i){return(i.mode&1)!==0&&(i.flags&128)===0}function lp(i){if(Cn){var o=na;if(o){var b=o;if(!ky(i,o)){if(ip(i))throw Error(n(418));o=ml(b.nextSibling);var k=sa;o&&ky(i,o)?Ay(k,b):(i.flags=i.flags&-4097|2,Cn=!1,sa=i)}}else{if(ip(i))throw Error(n(418));i.flags=i.flags&-4097|2,Cn=!1,sa=i}}}function Ry(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;sa=i}function zu(i){if(i!==sa)return!1;if(!Cn)return Ry(i),Cn=!0,!1;var o;if((o=i.tag!==3)&&!(o=i.tag!==5)&&(o=i.type,o=o!=="head"&&o!=="body"&&!Xf(i.type,i.memoizedProps)),o&&(o=na)){if(ip(i))throw Ey(),Error(n(418));for(;o;)Ay(i,o),o=ml(o.nextSibling)}if(Ry(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,o=0;i;){if(i.nodeType===8){var b=i.data;if(b==="/$"){if(o===0){na=ml(i.nextSibling);break e}o--}else b!=="$"&&b!=="$!"&&b!=="$?"||o++}i=i.nextSibling}na=null}}else na=sa?ml(i.stateNode.nextSibling):null;return!0}function Ey(){for(var i=na;i;)i=ml(i.nextSibling)}function ac(){na=sa=null,Cn=!1}function op(i){Ba===null?Ba=[i]:Ba.push(i)}var WD=w.ReactCurrentBatchConfig;function rd(i,o,b){if(i=b.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(b._owner){if(b=b._owner,b){if(b.tag!==1)throw Error(n(309));var k=b.stateNode}if(!k)throw Error(n(147,i));var L=k,H=""+i;return o!==null&&o.ref!==null&&typeof o.ref=="function"&&o.ref._stringRef===H?o.ref:(o=function(ae){var je=L.refs;ae===null?delete je[H]:je[H]=ae},o._stringRef=H,o)}if(typeof i!="string")throw Error(n(284));if(!b._owner)throw Error(n(290,i))}return i}function Uu(i,o){throw i=Object.prototype.toString.call(o),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":i))}function Dy(i){var o=i._init;return o(i._payload)}function Ty(i){function o(He,Oe){if(i){var Ke=He.deletions;Ke===null?(He.deletions=[Oe],He.flags|=16):Ke.push(Oe)}}function b(He,Oe){if(!i)return null;for(;Oe!==null;)o(He,Oe),Oe=Oe.sibling;return null}function k(He,Oe){for(He=new Map;Oe!==null;)Oe.key!==null?He.set(Oe.key,Oe):He.set(Oe.index,Oe),Oe=Oe.sibling;return He}function L(He,Oe){return He=Sl(He,Oe),He.index=0,He.sibling=null,He}function H(He,Oe,Ke){return He.index=Ke,i?(Ke=He.alternate,Ke!==null?(Ke=Ke.index,Ke<Oe?(He.flags|=2,Oe):Ke):(He.flags|=2,Oe)):(He.flags|=1048576,Oe)}function ae(He){return i&&He.alternate===null&&(He.flags|=2),He}function je(He,Oe,Ke,It){return Oe===null||Oe.tag!==6?(Oe=Jp(Ke,He.mode,It),Oe.return=He,Oe):(Oe=L(Oe,Ke),Oe.return=He,Oe)}function De(He,Oe,Ke,It){var hs=Ke.type;return hs===A?Nt(He,Oe,Ke.props.children,It,Ke.key):Oe!==null&&(Oe.elementType===hs||typeof hs=="object"&&hs!==null&&hs.$$typeof===Z&&Dy(hs)===Oe.type)?(It=L(Oe,Ke.props),It.ref=rd(He,Oe,Ke),It.return=He,It):(It=mh(Ke.type,Ke.key,Ke.props,null,He.mode,It),It.ref=rd(He,Oe,Ke),It.return=He,It)}function Je(He,Oe,Ke,It){return Oe===null||Oe.tag!==4||Oe.stateNode.containerInfo!==Ke.containerInfo||Oe.stateNode.implementation!==Ke.implementation?(Oe=ex(Ke,He.mode,It),Oe.return=He,Oe):(Oe=L(Oe,Ke.children||[]),Oe.return=He,Oe)}function Nt(He,Oe,Ke,It,hs){return Oe===null||Oe.tag!==7?(Oe=No(Ke,He.mode,It,hs),Oe.return=He,Oe):(Oe=L(Oe,Ke),Oe.return=He,Oe)}function Dt(He,Oe,Ke){if(typeof Oe=="string"&&Oe!==""||typeof Oe=="number")return Oe=Jp(""+Oe,He.mode,Ke),Oe.return=He,Oe;if(typeof Oe=="object"&&Oe!==null){switch(Oe.$$typeof){case R:return Ke=mh(Oe.type,Oe.key,Oe.props,null,He.mode,Ke),Ke.ref=rd(He,null,Oe),Ke.return=He,Ke;case P:return Oe=ex(Oe,He.mode,Ke),Oe.return=He,Oe;case Z:var It=Oe._init;return Dt(He,It(Oe._payload),Ke)}if(ke(Oe)||F(Oe))return Oe=No(Oe,He.mode,Ke,null),Oe.return=He,Oe;Uu(He,Oe)}return null}function vt(He,Oe,Ke,It){var hs=Oe!==null?Oe.key:null;if(typeof Ke=="string"&&Ke!==""||typeof Ke=="number")return hs!==null?null:je(He,Oe,""+Ke,It);if(typeof Ke=="object"&&Ke!==null){switch(Ke.$$typeof){case R:return Ke.key===hs?De(He,Oe,Ke,It):null;case P:return Ke.key===hs?Je(He,Oe,Ke,It):null;case Z:return hs=Ke._init,vt(He,Oe,hs(Ke._payload),It)}if(ke(Ke)||F(Ke))return hs!==null?null:Nt(He,Oe,Ke,It,null);Uu(He,Ke)}return null}function Xt(He,Oe,Ke,It,hs){if(typeof It=="string"&&It!==""||typeof It=="number")return He=He.get(Ke)||null,je(Oe,He,""+It,hs);if(typeof It=="object"&&It!==null){switch(It.$$typeof){case R:return He=He.get(It.key===null?Ke:It.key)||null,De(Oe,He,It,hs);case P:return He=He.get(It.key===null?Ke:It.key)||null,Je(Oe,He,It,hs);case Z:var ys=It._init;return Xt(He,Oe,Ke,ys(It._payload),hs)}if(ke(It)||F(It))return He=He.get(Ke)||null,Nt(Oe,He,It,hs,null);Uu(Oe,It)}return null}function is(He,Oe,Ke,It){for(var hs=null,ys=null,js=Oe,Ps=Oe=0,or=null;js!==null&&Ps<Ke.length;Ps++){js.index>Ps?(or=js,js=null):or=js.sibling;var sn=vt(He,js,Ke[Ps],It);if(sn===null){js===null&&(js=or);break}i&&js&&sn.alternate===null&&o(He,js),Oe=H(sn,Oe,Ps),ys===null?hs=sn:ys.sibling=sn,ys=sn,js=or}if(Ps===Ke.length)return b(He,js),Cn&&fo(He,Ps),hs;if(js===null){for(;Ps<Ke.length;Ps++)js=Dt(He,Ke[Ps],It),js!==null&&(Oe=H(js,Oe,Ps),ys===null?hs=js:ys.sibling=js,ys=js);return Cn&&fo(He,Ps),hs}for(js=k(He,js);Ps<Ke.length;Ps++)or=Xt(js,He,Ps,Ke[Ps],It),or!==null&&(i&&or.alternate!==null&&js.delete(or.key===null?Ps:or.key),Oe=H(or,Oe,Ps),ys===null?hs=or:ys.sibling=or,ys=or);return i&&js.forEach(function(Cl){return o(He,Cl)}),Cn&&fo(He,Ps),hs}function cs(He,Oe,Ke,It){var hs=F(Ke);if(typeof hs!="function")throw Error(n(150));if(Ke=hs.call(Ke),Ke==null)throw Error(n(151));for(var ys=hs=null,js=Oe,Ps=Oe=0,or=null,sn=Ke.next();js!==null&&!sn.done;Ps++,sn=Ke.next()){js.index>Ps?(or=js,js=null):or=js.sibling;var Cl=vt(He,js,sn.value,It);if(Cl===null){js===null&&(js=or);break}i&&js&&Cl.alternate===null&&o(He,js),Oe=H(Cl,Oe,Ps),ys===null?hs=Cl:ys.sibling=Cl,ys=Cl,js=or}if(sn.done)return b(He,js),Cn&&fo(He,Ps),hs;if(js===null){for(;!sn.done;Ps++,sn=Ke.next())sn=Dt(He,sn.value,It),sn!==null&&(Oe=H(sn,Oe,Ps),ys===null?hs=sn:ys.sibling=sn,ys=sn);return Cn&&fo(He,Ps),hs}for(js=k(He,js);!sn.done;Ps++,sn=Ke.next())sn=Xt(js,He,Ps,sn.value,It),sn!==null&&(i&&sn.alternate!==null&&js.delete(sn.key===null?Ps:sn.key),Oe=H(sn,Oe,Ps),ys===null?hs=sn:ys.sibling=sn,ys=sn);return i&&js.forEach(function(CT){return o(He,CT)}),Cn&&fo(He,Ps),hs}function Ln(He,Oe,Ke,It){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 hs=Ke.key,ys=Oe;ys!==null;){if(ys.key===hs){if(hs=Ke.type,hs===A){if(ys.tag===7){b(He,ys.sibling),Oe=L(ys,Ke.props.children),Oe.return=He,He=Oe;break e}}else if(ys.elementType===hs||typeof hs=="object"&&hs!==null&&hs.$$typeof===Z&&Dy(hs)===ys.type){b(He,ys.sibling),Oe=L(ys,Ke.props),Oe.ref=rd(He,ys,Ke),Oe.return=He,He=Oe;break e}b(He,ys);break}else o(He,ys);ys=ys.sibling}Ke.type===A?(Oe=No(Ke.props.children,He.mode,It,Ke.key),Oe.return=He,He=Oe):(It=mh(Ke.type,Ke.key,Ke.props,null,He.mode,It),It.ref=rd(He,Oe,Ke),It.return=He,He=It)}return ae(He);case P:e:{for(ys=Ke.key;Oe!==null;){if(Oe.key===ys)if(Oe.tag===4&&Oe.stateNode.containerInfo===Ke.containerInfo&&Oe.stateNode.implementation===Ke.implementation){b(He,Oe.sibling),Oe=L(Oe,Ke.children||[]),Oe.return=He,He=Oe;break e}else{b(He,Oe);break}else o(He,Oe);Oe=Oe.sibling}Oe=ex(Ke,He.mode,It),Oe.return=He,He=Oe}return ae(He);case Z:return ys=Ke._init,Ln(He,Oe,ys(Ke._payload),It)}if(ke(Ke))return is(He,Oe,Ke,It);if(F(Ke))return cs(He,Oe,Ke,It);Uu(He,Ke)}return typeof Ke=="string"&&Ke!==""||typeof Ke=="number"?(Ke=""+Ke,Oe!==null&&Oe.tag===6?(b(He,Oe.sibling),Oe=L(Oe,Ke),Oe.return=He,He=Oe):(b(He,Oe),Oe=Jp(Ke,He.mode,It),Oe.return=He,He=Oe),ae(He)):b(He,Oe)}return Ln}var ic=Ty(!0),Py=Ty(!1),Vu=fl(null),Hu=null,lc=null,cp=null;function dp(){cp=lc=Hu=null}function up(i){var o=Vu.current;yn(Vu),i._currentValue=o}function hp(i,o,b){for(;i!==null;){var k=i.alternate;if((i.childLanes&o)!==o?(i.childLanes|=o,k!==null&&(k.childLanes|=o)):k!==null&&(k.childLanes&o)!==o&&(k.childLanes|=o),i===b)break;i=i.return}}function oc(i,o){Hu=i,cp=lc=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&o)!==0&&(Gr=!0),i.firstContext=null)}function ya(i){var o=i._currentValue;if(cp!==i)if(i={context:i,memoizedValue:o,next:null},lc===null){if(Hu===null)throw Error(n(308));lc=i,Hu.dependencies={lanes:0,firstContext:i}}else lc=lc.next=i;return o}var po=null;function mp(i){po===null?po=[i]:po.push(i)}function _y(i,o,b,k){var L=o.interleaved;return L===null?(b.next=b,mp(o)):(b.next=L.next,L.next=b),o.interleaved=b,Mi(i,k)}function Mi(i,o){i.lanes|=o;var b=i.alternate;for(b!==null&&(b.lanes|=o),b=i,i=i.return;i!==null;)i.childLanes|=o,b=i.alternate,b!==null&&(b.childLanes|=o),b=i,i=i.return;return b.tag===3?b.stateNode:null}var gl=!1;function fp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Oy(i,o){i=i.updateQueue,o.updateQueue===i&&(o.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function Fi(i,o){return{eventTime:i,lane:o,tag:0,payload:null,callback:null,next:null}}function vl(i,o,b){var k=i.updateQueue;if(k===null)return null;if(k=k.shared,(Xs&2)!==0){var L=k.pending;return L===null?o.next=o:(o.next=L.next,L.next=o),k.pending=o,Mi(i,b)}return L=k.interleaved,L===null?(o.next=o,mp(k)):(o.next=L.next,L.next=o),k.interleaved=o,Mi(i,b)}function Wu(i,o,b){if(o=o.updateQueue,o!==null&&(o=o.shared,(b&4194240)!==0)){var k=o.lanes;k&=i.pendingLanes,b|=k,o.lanes=b,xn(i,b)}}function Iy(i,o){var b=i.updateQueue,k=i.alternate;if(k!==null&&(k=k.updateQueue,b===k)){var L=null,H=null;if(b=b.firstBaseUpdate,b!==null){do{var ae={eventTime:b.eventTime,lane:b.lane,tag:b.tag,payload:b.payload,callback:b.callback,next:null};H===null?L=H=ae:H=H.next=ae,b=b.next}while(b!==null);H===null?L=H=o:H=H.next=o}else L=H=o;b={baseState:k.baseState,firstBaseUpdate:L,lastBaseUpdate:H,shared:k.shared,effects:k.effects},i.updateQueue=b;return}i=b.lastBaseUpdate,i===null?b.firstBaseUpdate=o:i.next=o,b.lastBaseUpdate=o}function Gu(i,o,b,k){var L=i.updateQueue;gl=!1;var H=L.firstBaseUpdate,ae=L.lastBaseUpdate,je=L.shared.pending;if(je!==null){L.shared.pending=null;var De=je,Je=De.next;De.next=null,ae===null?H=Je:ae.next=Je,ae=De;var Nt=i.alternate;Nt!==null&&(Nt=Nt.updateQueue,je=Nt.lastBaseUpdate,je!==ae&&(je===null?Nt.firstBaseUpdate=Je:je.next=Je,Nt.lastBaseUpdate=De))}if(H!==null){var Dt=L.baseState;ae=0,Nt=Je=De=null,je=H;do{var vt=je.lane,Xt=je.eventTime;if((k&vt)===vt){Nt!==null&&(Nt=Nt.next={eventTime:Xt,lane:0,tag:je.tag,payload:je.payload,callback:je.callback,next:null});e:{var is=i,cs=je;switch(vt=o,Xt=b,cs.tag){case 1:if(is=cs.payload,typeof is=="function"){Dt=is.call(Xt,Dt,vt);break e}Dt=is;break e;case 3:is.flags=is.flags&-65537|128;case 0:if(is=cs.payload,vt=typeof is=="function"?is.call(Xt,Dt,vt):is,vt==null)break e;Dt=B({},Dt,vt);break e;case 2:gl=!0}}je.callback!==null&&je.lane!==0&&(i.flags|=64,vt=L.effects,vt===null?L.effects=[je]:vt.push(je))}else Xt={eventTime:Xt,lane:vt,tag:je.tag,payload:je.payload,callback:je.callback,next:null},Nt===null?(Je=Nt=Xt,De=Dt):Nt=Nt.next=Xt,ae|=vt;if(je=je.next,je===null){if(je=L.shared.pending,je===null)break;vt=je,je=vt.next,vt.next=null,L.lastBaseUpdate=vt,L.shared.pending=null}}while(!0);if(Nt===null&&(De=Dt),L.baseState=De,L.firstBaseUpdate=Je,L.lastBaseUpdate=Nt,o=L.shared.interleaved,o!==null){L=o;do ae|=L.lane,L=L.next;while(L!==o)}else H===null&&(L.shared.lanes=0);vo|=ae,i.lanes=ae,i.memoizedState=Dt}}function Ly(i,o,b){if(i=o.effects,o.effects=null,i!==null)for(o=0;o<i.length;o++){var k=i[o],L=k.callback;if(L!==null){if(k.callback=null,k=b,typeof L!="function")throw Error(n(191,L));L.call(k)}}}var ad={},ci=fl(ad),id=fl(ad),ld=fl(ad);function xo(i){if(i===ad)throw Error(n(174));return i}function pp(i,o){switch(vn(ld,o),vn(id,i),vn(ci,ad),i=o.nodeType,i){case 9:case 11:o=(o=o.documentElement)?o.namespaceURI:Qe(null,"");break;default:i=i===8?o.parentNode:o,o=i.namespaceURI||null,i=i.tagName,o=Qe(o,i)}yn(ci),vn(ci,o)}function cc(){yn(ci),yn(id),yn(ld)}function My(i){xo(ld.current);var o=xo(ci.current),b=Qe(o,i.type);o!==b&&(vn(id,i),vn(ci,b))}function xp(i){id.current===i&&(yn(ci),yn(id))}var An=fl(0);function Ku(i){for(var o=i;o!==null;){if(o.tag===13){var b=o.memoizedState;if(b!==null&&(b=b.dehydrated,b===null||b.data==="$?"||b.data==="$!"))return o}else if(o.tag===19&&o.memoizedProps.revealOrder!==void 0){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===i)break;for(;o.sibling===null;){if(o.return===null||o.return===i)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var gp=[];function vp(){for(var i=0;i<gp.length;i++)gp[i]._workInProgressVersionPrimary=null;gp.length=0}var Yu=w.ReactCurrentDispatcher,bp=w.ReactCurrentBatchConfig,go=0,kn=null,Xn=null,ir=null,Zu=!1,od=!1,cd=0,GD=0;function wr(){throw Error(n(321))}function yp(i,o){if(o===null)return!1;for(var b=0;b<o.length&&b<i.length;b++)if(!Fa(i[b],o[b]))return!1;return!0}function jp(i,o,b,k,L,H){if(go=H,kn=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,Yu.current=i===null||i.memoizedState===null?QD:XD,i=b(k,L),od){H=0;do{if(od=!1,cd=0,25<=H)throw Error(n(301));H+=1,ir=Xn=null,o.updateQueue=null,Yu.current=JD,i=b(k,L)}while(od)}if(Yu.current=Ju,o=Xn!==null&&Xn.next!==null,go=0,ir=Xn=kn=null,Zu=!1,o)throw Error(n(300));return i}function Np(){var i=cd!==0;return cd=0,i}function di(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ir===null?kn.memoizedState=ir=i:ir=ir.next=i,ir}function ja(){if(Xn===null){var i=kn.alternate;i=i!==null?i.memoizedState:null}else i=Xn.next;var o=ir===null?kn.memoizedState:ir.next;if(o!==null)ir=o,Xn=i;else{if(i===null)throw Error(n(310));Xn=i,i={memoizedState:Xn.memoizedState,baseState:Xn.baseState,baseQueue:Xn.baseQueue,queue:Xn.queue,next:null},ir===null?kn.memoizedState=ir=i:ir=ir.next=i}return ir}function dd(i,o){return typeof o=="function"?o(i):o}function wp(i){var o=ja(),b=o.queue;if(b===null)throw Error(n(311));b.lastRenderedReducer=i;var k=Xn,L=k.baseQueue,H=b.pending;if(H!==null){if(L!==null){var ae=L.next;L.next=H.next,H.next=ae}k.baseQueue=L=H,b.pending=null}if(L!==null){H=L.next,k=k.baseState;var je=ae=null,De=null,Je=H;do{var Nt=Je.lane;if((go&Nt)===Nt)De!==null&&(De=De.next={lane:0,action:Je.action,hasEagerState:Je.hasEagerState,eagerState:Je.eagerState,next:null}),k=Je.hasEagerState?Je.eagerState:i(k,Je.action);else{var Dt={lane:Nt,action:Je.action,hasEagerState:Je.hasEagerState,eagerState:Je.eagerState,next:null};De===null?(je=De=Dt,ae=k):De=De.next=Dt,kn.lanes|=Nt,vo|=Nt}Je=Je.next}while(Je!==null&&Je!==H);De===null?ae=k:De.next=je,Fa(k,o.memoizedState)||(Gr=!0),o.memoizedState=k,o.baseState=ae,o.baseQueue=De,b.lastRenderedState=k}if(i=b.interleaved,i!==null){L=i;do H=L.lane,kn.lanes|=H,vo|=H,L=L.next;while(L!==i)}else L===null&&(b.lanes=0);return[o.memoizedState,b.dispatch]}function Sp(i){var o=ja(),b=o.queue;if(b===null)throw Error(n(311));b.lastRenderedReducer=i;var k=b.dispatch,L=b.pending,H=o.memoizedState;if(L!==null){b.pending=null;var ae=L=L.next;do H=i(H,ae.action),ae=ae.next;while(ae!==L);Fa(H,o.memoizedState)||(Gr=!0),o.memoizedState=H,o.baseQueue===null&&(o.baseState=H),b.lastRenderedState=H}return[H,k]}function Fy(){}function By(i,o){var b=kn,k=ja(),L=o(),H=!Fa(k.memoizedState,L);if(H&&(k.memoizedState=L,Gr=!0),k=k.queue,Cp(zy.bind(null,b,k,i),[i]),k.getSnapshot!==o||H||ir!==null&&ir.memoizedState.tag&1){if(b.flags|=2048,ud(9,qy.bind(null,b,k,L,o),void 0,null),lr===null)throw Error(n(349));(go&30)!==0||$y(b,o,L)}return L}function $y(i,o,b){i.flags|=16384,i={getSnapshot:o,value:b},o=kn.updateQueue,o===null?(o={lastEffect:null,stores:null},kn.updateQueue=o,o.stores=[i]):(b=o.stores,b===null?o.stores=[i]:b.push(i))}function qy(i,o,b,k){o.value=b,o.getSnapshot=k,Uy(o)&&Vy(i)}function zy(i,o,b){return b(function(){Uy(o)&&Vy(i)})}function Uy(i){var o=i.getSnapshot;i=i.value;try{var b=o();return!Fa(i,b)}catch{return!0}}function Vy(i){var o=Mi(i,1);o!==null&&Ua(o,i,1,-1)}function Hy(i){var o=di();return typeof i=="function"&&(i=i()),o.memoizedState=o.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:dd,lastRenderedState:i},o.queue=i,i=i.dispatch=ZD.bind(null,kn,i),[o.memoizedState,i]}function ud(i,o,b,k){return i={tag:i,create:o,destroy:b,deps:k,next:null},o=kn.updateQueue,o===null?(o={lastEffect:null,stores:null},kn.updateQueue=o,o.lastEffect=i.next=i):(b=o.lastEffect,b===null?o.lastEffect=i.next=i:(k=b.next,b.next=i,i.next=k,o.lastEffect=i)),i}function Wy(){return ja().memoizedState}function Qu(i,o,b,k){var L=di();kn.flags|=i,L.memoizedState=ud(1|o,b,void 0,k===void 0?null:k)}function Xu(i,o,b,k){var L=ja();k=k===void 0?null:k;var H=void 0;if(Xn!==null){var ae=Xn.memoizedState;if(H=ae.destroy,k!==null&&yp(k,ae.deps)){L.memoizedState=ud(o,b,H,k);return}}kn.flags|=i,L.memoizedState=ud(1|o,b,H,k)}function Gy(i,o){return Qu(8390656,8,i,o)}function Cp(i,o){return Xu(2048,8,i,o)}function Ky(i,o){return Xu(4,2,i,o)}function Yy(i,o){return Xu(4,4,i,o)}function Zy(i,o){if(typeof o=="function")return i=i(),o(i),function(){o(null)};if(o!=null)return i=i(),o.current=i,function(){o.current=null}}function Qy(i,o,b){return b=b!=null?b.concat([i]):null,Xu(4,4,Zy.bind(null,o,i),b)}function Ap(){}function Xy(i,o){var b=ja();o=o===void 0?null:o;var k=b.memoizedState;return k!==null&&o!==null&&yp(o,k[1])?k[0]:(b.memoizedState=[i,o],i)}function Jy(i,o){var b=ja();o=o===void 0?null:o;var k=b.memoizedState;return k!==null&&o!==null&&yp(o,k[1])?k[0]:(i=i(),b.memoizedState=[i,o],i)}function ej(i,o,b){return(go&21)===0?(i.baseState&&(i.baseState=!1,Gr=!0),i.memoizedState=b):(Fa(b,o)||(b=jt(),kn.lanes|=b,vo|=b,i.baseState=!0),o)}function KD(i,o){var b=qs;qs=b!==0&&4>b?b:4,i(!0);var k=bp.transition;bp.transition={};try{i(!1),o()}finally{qs=b,bp.transition=k}}function tj(){return ja().memoizedState}function YD(i,o,b){var k=Nl(i);if(b={lane:k,action:b,hasEagerState:!1,eagerState:null,next:null},sj(i))nj(o,b);else if(b=_y(i,o,b,k),b!==null){var L=Mr();Ua(b,i,k,L),rj(b,o,k)}}function ZD(i,o,b){var k=Nl(i),L={lane:k,action:b,hasEagerState:!1,eagerState:null,next:null};if(sj(i))nj(o,L);else{var H=i.alternate;if(i.lanes===0&&(H===null||H.lanes===0)&&(H=o.lastRenderedReducer,H!==null))try{var ae=o.lastRenderedState,je=H(ae,b);if(L.hasEagerState=!0,L.eagerState=je,Fa(je,ae)){var De=o.interleaved;De===null?(L.next=L,mp(o)):(L.next=De.next,De.next=L),o.interleaved=L;return}}catch{}finally{}b=_y(i,o,L,k),b!==null&&(L=Mr(),Ua(b,i,k,L),rj(b,o,k))}}function sj(i){var o=i.alternate;return i===kn||o!==null&&o===kn}function nj(i,o){od=Zu=!0;var b=i.pending;b===null?o.next=o:(o.next=b.next,b.next=o),i.pending=o}function rj(i,o,b){if((b&4194240)!==0){var k=o.lanes;k&=i.pendingLanes,b|=k,o.lanes=b,xn(i,b)}}var Ju={readContext:ya,useCallback:wr,useContext:wr,useEffect:wr,useImperativeHandle:wr,useInsertionEffect:wr,useLayoutEffect:wr,useMemo:wr,useReducer:wr,useRef:wr,useState:wr,useDebugValue:wr,useDeferredValue:wr,useTransition:wr,useMutableSource:wr,useSyncExternalStore:wr,useId:wr,unstable_isNewReconciler:!1},QD={readContext:ya,useCallback:function(i,o){return di().memoizedState=[i,o===void 0?null:o],i},useContext:ya,useEffect:Gy,useImperativeHandle:function(i,o,b){return b=b!=null?b.concat([i]):null,Qu(4194308,4,Zy.bind(null,o,i),b)},useLayoutEffect:function(i,o){return Qu(4194308,4,i,o)},useInsertionEffect:function(i,o){return Qu(4,2,i,o)},useMemo:function(i,o){var b=di();return o=o===void 0?null:o,i=i(),b.memoizedState=[i,o],i},useReducer:function(i,o,b){var k=di();return o=b!==void 0?b(o):o,k.memoizedState=k.baseState=o,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:o},k.queue=i,i=i.dispatch=YD.bind(null,kn,i),[k.memoizedState,i]},useRef:function(i){var o=di();return i={current:i},o.memoizedState=i},useState:Hy,useDebugValue:Ap,useDeferredValue:function(i){return di().memoizedState=i},useTransition:function(){var i=Hy(!1),o=i[0];return i=KD.bind(null,i[1]),di().memoizedState=i,[o,i]},useMutableSource:function(){},useSyncExternalStore:function(i,o,b){var k=kn,L=di();if(Cn){if(b===void 0)throw Error(n(407));b=b()}else{if(b=o(),lr===null)throw Error(n(349));(go&30)!==0||$y(k,o,b)}L.memoizedState=b;var H={value:b,getSnapshot:o};return L.queue=H,Gy(zy.bind(null,k,H,i),[i]),k.flags|=2048,ud(9,qy.bind(null,k,H,b,o),void 0,null),b},useId:function(){var i=di(),o=lr.identifierPrefix;if(Cn){var b=Li,k=Ii;b=(k&~(1<<32-on(k)-1)).toString(32)+b,o=":"+o+"R"+b,b=cd++,0<b&&(o+="H"+b.toString(32)),o+=":"}else b=GD++,o=":"+o+"r"+b.toString(32)+":";return i.memoizedState=o},unstable_isNewReconciler:!1},XD={readContext:ya,useCallback:Xy,useContext:ya,useEffect:Cp,useImperativeHandle:Qy,useInsertionEffect:Ky,useLayoutEffect:Yy,useMemo:Jy,useReducer:wp,useRef:Wy,useState:function(){return wp(dd)},useDebugValue:Ap,useDeferredValue:function(i){var o=ja();return ej(o,Xn.memoizedState,i)},useTransition:function(){var i=wp(dd)[0],o=ja().memoizedState;return[i,o]},useMutableSource:Fy,useSyncExternalStore:By,useId:tj,unstable_isNewReconciler:!1},JD={readContext:ya,useCallback:Xy,useContext:ya,useEffect:Cp,useImperativeHandle:Qy,useInsertionEffect:Ky,useLayoutEffect:Yy,useMemo:Jy,useReducer:Sp,useRef:Wy,useState:function(){return Sp(dd)},useDebugValue:Ap,useDeferredValue:function(i){var o=ja();return Xn===null?o.memoizedState=i:ej(o,Xn.memoizedState,i)},useTransition:function(){var i=Sp(dd)[0],o=ja().memoizedState;return[i,o]},useMutableSource:Fy,useSyncExternalStore:By,useId:tj,unstable_isNewReconciler:!1};function $a(i,o){if(i&&i.defaultProps){o=B({},o),i=i.defaultProps;for(var b in i)o[b]===void 0&&(o[b]=i[b]);return o}return o}function kp(i,o,b,k){o=i.memoizedState,b=b(k,o),b=b==null?o:B({},o,b),i.memoizedState=b,i.lanes===0&&(i.updateQueue.baseState=b)}var eh={isMounted:function(i){return(i=i._reactInternals)?Is(i)===i:!1},enqueueSetState:function(i,o,b){i=i._reactInternals;var k=Mr(),L=Nl(i),H=Fi(k,L);H.payload=o,b!=null&&(H.callback=b),o=vl(i,H,L),o!==null&&(Ua(o,i,L,k),Wu(o,i,L))},enqueueReplaceState:function(i,o,b){i=i._reactInternals;var k=Mr(),L=Nl(i),H=Fi(k,L);H.tag=1,H.payload=o,b!=null&&(H.callback=b),o=vl(i,H,L),o!==null&&(Ua(o,i,L,k),Wu(o,i,L))},enqueueForceUpdate:function(i,o){i=i._reactInternals;var b=Mr(),k=Nl(i),L=Fi(b,k);L.tag=2,o!=null&&(L.callback=o),o=vl(i,L,k),o!==null&&(Ua(o,i,k,b),Wu(o,i,k))}};function aj(i,o,b,k,L,H,ae){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(k,H,ae):o.prototype&&o.prototype.isPureReactComponent?!Qc(b,k)||!Qc(L,H):!0}function ij(i,o,b){var k=!1,L=pl,H=o.contextType;return typeof H=="object"&&H!==null?H=ya(H):(L=Wr(o)?ho:Nr.current,k=o.contextTypes,H=(k=k!=null)?sc(i,L):pl),o=new o(b,H),i.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=eh,i.stateNode=o,o._reactInternals=i,k&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=L,i.__reactInternalMemoizedMaskedChildContext=H),o}function lj(i,o,b,k){i=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(b,k),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(b,k),o.state!==i&&eh.enqueueReplaceState(o,o.state,null)}function Rp(i,o,b,k){var L=i.stateNode;L.props=b,L.state=i.memoizedState,L.refs={},fp(i);var H=o.contextType;typeof H=="object"&&H!==null?L.context=ya(H):(H=Wr(o)?ho:Nr.current,L.context=sc(i,H)),L.state=i.memoizedState,H=o.getDerivedStateFromProps,typeof H=="function"&&(kp(i,o,H,b),L.state=i.memoizedState),typeof o.getDerivedStateFromProps=="function"||typeof L.getSnapshotBeforeUpdate=="function"||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(o=L.state,typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount(),o!==L.state&&eh.enqueueReplaceState(L,L.state,null),Gu(i,b,L,k),L.state=i.memoizedState),typeof L.componentDidMount=="function"&&(i.flags|=4194308)}function dc(i,o){try{var b="",k=o;do b+=Y(k),k=k.return;while(k);var L=b}catch(H){L=`
Error generating stack: `+H.message+`
`+H.stack}return{value:i,source:o,stack:L,digest:null}}function Ep(i,o,b){return{value:i,source:null,stack:b??null,digest:o??null}}function Dp(i,o){try{console.error(o.value)}catch(b){setTimeout(function(){throw b})}}var eT=typeof WeakMap=="function"?WeakMap:Map;function oj(i,o,b){b=Fi(-1,b),b.tag=3,b.payload={element:null};var k=o.value;return b.callback=function(){lh||(lh=!0,Hp=k),Dp(i,o)},b}function cj(i,o,b){b=Fi(-1,b),b.tag=3;var k=i.type.getDerivedStateFromError;if(typeof k=="function"){var L=o.value;b.payload=function(){return k(L)},b.callback=function(){Dp(i,o)}}var H=i.stateNode;return H!==null&&typeof H.componentDidCatch=="function"&&(b.callback=function(){Dp(i,o),typeof k!="function"&&(yl===null?yl=new Set([this]):yl.add(this));var ae=o.stack;this.componentDidCatch(o.value,{componentStack:ae!==null?ae:""})}),b}function dj(i,o,b){var k=i.pingCache;if(k===null){k=i.pingCache=new eT;var L=new Set;k.set(o,L)}else L=k.get(o),L===void 0&&(L=new Set,k.set(o,L));L.has(b)||(L.add(b),i=fT.bind(null,i,o,b),o.then(i,i))}function uj(i){do{var o;if((o=i.tag===13)&&(o=i.memoizedState,o=o!==null?o.dehydrated!==null:!0),o)return i;i=i.return}while(i!==null);return null}function hj(i,o,b,k,L){return(i.mode&1)===0?(i===o?i.flags|=65536:(i.flags|=128,b.flags|=131072,b.flags&=-52805,b.tag===1&&(b.alternate===null?b.tag=17:(o=Fi(-1,1),o.tag=2,vl(b,o,1))),b.lanes|=1),i):(i.flags|=65536,i.lanes=L,i)}var tT=w.ReactCurrentOwner,Gr=!1;function Lr(i,o,b,k){o.child=i===null?Py(o,null,b,k):ic(o,i.child,b,k)}function mj(i,o,b,k,L){b=b.render;var H=o.ref;return oc(o,L),k=jp(i,o,b,k,H,L),b=Np(),i!==null&&!Gr?(o.updateQueue=i.updateQueue,o.flags&=-2053,i.lanes&=~L,Bi(i,o,L)):(Cn&&b&&rp(o),o.flags|=1,Lr(i,o,k,L),o.child)}function fj(i,o,b,k,L){if(i===null){var H=b.type;return typeof H=="function"&&!Xp(H)&&H.defaultProps===void 0&&b.compare===null&&b.defaultProps===void 0?(o.tag=15,o.type=H,pj(i,o,H,k,L)):(i=mh(b.type,null,k,o,o.mode,L),i.ref=o.ref,i.return=o,o.child=i)}if(H=i.child,(i.lanes&L)===0){var ae=H.memoizedProps;if(b=b.compare,b=b!==null?b:Qc,b(ae,k)&&i.ref===o.ref)return Bi(i,o,L)}return o.flags|=1,i=Sl(H,k),i.ref=o.ref,i.return=o,o.child=i}function pj(i,o,b,k,L){if(i!==null){var H=i.memoizedProps;if(Qc(H,k)&&i.ref===o.ref)if(Gr=!1,o.pendingProps=k=H,(i.lanes&L)!==0)(i.flags&131072)!==0&&(Gr=!0);else return o.lanes=i.lanes,Bi(i,o,L)}return Tp(i,o,b,k,L)}function xj(i,o,b){var k=o.pendingProps,L=k.children,H=i!==null?i.memoizedState:null;if(k.mode==="hidden")if((o.mode&1)===0)o.memoizedState={baseLanes:0,cachePool:null,transitions:null},vn(hc,ra),ra|=b;else{if((b&1073741824)===0)return i=H!==null?H.baseLanes|b:b,o.lanes=o.childLanes=1073741824,o.memoizedState={baseLanes:i,cachePool:null,transitions:null},o.updateQueue=null,vn(hc,ra),ra|=i,null;o.memoizedState={baseLanes:0,cachePool:null,transitions:null},k=H!==null?H.baseLanes:b,vn(hc,ra),ra|=k}else H!==null?(k=H.baseLanes|b,o.memoizedState=null):k=b,vn(hc,ra),ra|=k;return Lr(i,o,L,b),o.child}function gj(i,o){var b=o.ref;(i===null&&b!==null||i!==null&&i.ref!==b)&&(o.flags|=512,o.flags|=2097152)}function Tp(i,o,b,k,L){var H=Wr(b)?ho:Nr.current;return H=sc(o,H),oc(o,L),b=jp(i,o,b,k,H,L),k=Np(),i!==null&&!Gr?(o.updateQueue=i.updateQueue,o.flags&=-2053,i.lanes&=~L,Bi(i,o,L)):(Cn&&k&&rp(o),o.flags|=1,Lr(i,o,b,L),o.child)}function vj(i,o,b,k,L){if(Wr(b)){var H=!0;Fu(o)}else H=!1;if(oc(o,L),o.stateNode===null)sh(i,o),ij(o,b,k),Rp(o,b,k,L),k=!0;else if(i===null){var ae=o.stateNode,je=o.memoizedProps;ae.props=je;var De=ae.context,Je=b.contextType;typeof Je=="object"&&Je!==null?Je=ya(Je):(Je=Wr(b)?ho:Nr.current,Je=sc(o,Je));var Nt=b.getDerivedStateFromProps,Dt=typeof Nt=="function"||typeof ae.getSnapshotBeforeUpdate=="function";Dt||typeof ae.UNSAFE_componentWillReceiveProps!="function"&&typeof ae.componentWillReceiveProps!="function"||(je!==k||De!==Je)&&lj(o,ae,k,Je),gl=!1;var vt=o.memoizedState;ae.state=vt,Gu(o,k,ae,L),De=o.memoizedState,je!==k||vt!==De||Hr.current||gl?(typeof Nt=="function"&&(kp(o,b,Nt,k),De=o.memoizedState),(je=gl||aj(o,b,je,k,vt,De,Je))?(Dt||typeof ae.UNSAFE_componentWillMount!="function"&&typeof ae.componentWillMount!="function"||(typeof ae.componentWillMount=="function"&&ae.componentWillMount(),typeof ae.UNSAFE_componentWillMount=="function"&&ae.UNSAFE_componentWillMount()),typeof ae.componentDidMount=="function"&&(o.flags|=4194308)):(typeof ae.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=k,o.memoizedState=De),ae.props=k,ae.state=De,ae.context=Je,k=je):(typeof ae.componentDidMount=="function"&&(o.flags|=4194308),k=!1)}else{ae=o.stateNode,Oy(i,o),je=o.memoizedProps,Je=o.type===o.elementType?je:$a(o.type,je),ae.props=Je,Dt=o.pendingProps,vt=ae.context,De=b.contextType,typeof De=="object"&&De!==null?De=ya(De):(De=Wr(b)?ho:Nr.current,De=sc(o,De));var Xt=b.getDerivedStateFromProps;(Nt=typeof Xt=="function"||typeof ae.getSnapshotBeforeUpdate=="function")||typeof ae.UNSAFE_componentWillReceiveProps!="function"&&typeof ae.componentWillReceiveProps!="function"||(je!==Dt||vt!==De)&&lj(o,ae,k,De),gl=!1,vt=o.memoizedState,ae.state=vt,Gu(o,k,ae,L);var is=o.memoizedState;je!==Dt||vt!==is||Hr.current||gl?(typeof Xt=="function"&&(kp(o,b,Xt,k),is=o.memoizedState),(Je=gl||aj(o,b,Je,k,vt,is,De)||!1)?(Nt||typeof ae.UNSAFE_componentWillUpdate!="function"&&typeof ae.componentWillUpdate!="function"||(typeof ae.componentWillUpdate=="function"&&ae.componentWillUpdate(k,is,De),typeof ae.UNSAFE_componentWillUpdate=="function"&&ae.UNSAFE_componentWillUpdate(k,is,De)),typeof ae.componentDidUpdate=="function"&&(o.flags|=4),typeof ae.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof ae.componentDidUpdate!="function"||je===i.memoizedProps&&vt===i.memoizedState||(o.flags|=4),typeof ae.getSnapshotBeforeUpdate!="function"||je===i.memoizedProps&&vt===i.memoizedState||(o.flags|=1024),o.memoizedProps=k,o.memoizedState=is),ae.props=k,ae.state=is,ae.context=De,k=Je):(typeof ae.componentDidUpdate!="function"||je===i.memoizedProps&&vt===i.memoizedState||(o.flags|=4),typeof ae.getSnapshotBeforeUpdate!="function"||je===i.memoizedProps&&vt===i.memoizedState||(o.flags|=1024),k=!1)}return Pp(i,o,b,k,H,L)}function Pp(i,o,b,k,L,H){gj(i,o);var ae=(o.flags&128)!==0;if(!k&&!ae)return L&&wy(o,b,!1),Bi(i,o,H);k=o.stateNode,tT.current=o;var je=ae&&typeof b.getDerivedStateFromError!="function"?null:k.render();return o.flags|=1,i!==null&&ae?(o.child=ic(o,i.child,null,H),o.child=ic(o,null,je,H)):Lr(i,o,je,H),o.memoizedState=k.state,L&&wy(o,b,!0),o.child}function bj(i){var o=i.stateNode;o.pendingContext?jy(i,o.pendingContext,o.pendingContext!==o.context):o.context&&jy(i,o.context,!1),pp(i,o.containerInfo)}function yj(i,o,b,k,L){return ac(),op(L),o.flags|=256,Lr(i,o,b,k),o.child}var _p={dehydrated:null,treeContext:null,retryLane:0};function Op(i){return{baseLanes:i,cachePool:null,transitions:null}}function jj(i,o,b){var k=o.pendingProps,L=An.current,H=!1,ae=(o.flags&128)!==0,je;if((je=ae)||(je=i!==null&&i.memoizedState===null?!1:(L&2)!==0),je?(H=!0,o.flags&=-129):(i===null||i.memoizedState!==null)&&(L|=1),vn(An,L&1),i===null)return lp(o),i=o.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((o.mode&1)===0?o.lanes=1:i.data==="$!"?o.lanes=8:o.lanes=1073741824,null):(ae=k.children,i=k.fallback,H?(k=o.mode,H=o.child,ae={mode:"hidden",children:ae},(k&1)===0&&H!==null?(H.childLanes=0,H.pendingProps=ae):H=fh(ae,k,0,null),i=No(i,k,b,null),H.return=o,i.return=o,H.sibling=i,o.child=H,o.child.memoizedState=Op(b),o.memoizedState=_p,i):Ip(o,ae));if(L=i.memoizedState,L!==null&&(je=L.dehydrated,je!==null))return sT(i,o,ae,k,je,L,b);if(H){H=k.fallback,ae=o.mode,L=i.child,je=L.sibling;var De={mode:"hidden",children:k.children};return(ae&1)===0&&o.child!==L?(k=o.child,k.childLanes=0,k.pendingProps=De,o.deletions=null):(k=Sl(L,De),k.subtreeFlags=L.subtreeFlags&14680064),je!==null?H=Sl(je,H):(H=No(H,ae,b,null),H.flags|=2),H.return=o,k.return=o,k.sibling=H,o.child=k,k=H,H=o.child,ae=i.child.memoizedState,ae=ae===null?Op(b):{baseLanes:ae.baseLanes|b,cachePool:null,transitions:ae.transitions},H.memoizedState=ae,H.childLanes=i.childLanes&~b,o.memoizedState=_p,k}return H=i.child,i=H.sibling,k=Sl(H,{mode:"visible",children:k.children}),(o.mode&1)===0&&(k.lanes=b),k.return=o,k.sibling=null,i!==null&&(b=o.deletions,b===null?(o.deletions=[i],o.flags|=16):b.push(i)),o.child=k,o.memoizedState=null,k}function Ip(i,o){return o=fh({mode:"visible",children:o},i.mode,0,null),o.return=i,i.child=o}function th(i,o,b,k){return k!==null&&op(k),ic(o,i.child,null,b),i=Ip(o,o.pendingProps.children),i.flags|=2,o.memoizedState=null,i}function sT(i,o,b,k,L,H,ae){if(b)return o.flags&256?(o.flags&=-257,k=Ep(Error(n(422))),th(i,o,ae,k)):o.memoizedState!==null?(o.child=i.child,o.flags|=128,null):(H=k.fallback,L=o.mode,k=fh({mode:"visible",children:k.children},L,0,null),H=No(H,L,ae,null),H.flags|=2,k.return=o,H.return=o,k.sibling=H,o.child=k,(o.mode&1)!==0&&ic(o,i.child,null,ae),o.child.memoizedState=Op(ae),o.memoizedState=_p,H);if((o.mode&1)===0)return th(i,o,ae,null);if(L.data==="$!"){if(k=L.nextSibling&&L.nextSibling.dataset,k)var je=k.dgst;return k=je,H=Error(n(419)),k=Ep(H,k,void 0),th(i,o,ae,k)}if(je=(ae&i.childLanes)!==0,Gr||je){if(k=lr,k!==null){switch(ae&-ae){case 4:L=2;break;case 16:L=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:L=32;break;case 536870912:L=268435456;break;default:L=0}L=(L&(k.suspendedLanes|ae))!==0?0:L,L!==0&&L!==H.retryLane&&(H.retryLane=L,Mi(i,L),Ua(k,i,L,-1))}return Qp(),k=Ep(Error(n(421))),th(i,o,ae,k)}return L.data==="$?"?(o.flags|=128,o.child=i.child,o=pT.bind(null,i),L._reactRetry=o,null):(i=H.treeContext,na=ml(L.nextSibling),sa=o,Cn=!0,Ba=null,i!==null&&(va[ba++]=Ii,va[ba++]=Li,va[ba++]=mo,Ii=i.id,Li=i.overflow,mo=o),o=Ip(o,k.children),o.flags|=4096,o)}function Nj(i,o,b){i.lanes|=o;var k=i.alternate;k!==null&&(k.lanes|=o),hp(i.return,o,b)}function Lp(i,o,b,k,L){var H=i.memoizedState;H===null?i.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:k,tail:b,tailMode:L}:(H.isBackwards=o,H.rendering=null,H.renderingStartTime=0,H.last=k,H.tail=b,H.tailMode=L)}function wj(i,o,b){var k=o.pendingProps,L=k.revealOrder,H=k.tail;if(Lr(i,o,k.children,b),k=An.current,(k&2)!==0)k=k&1|2,o.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=o.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Nj(i,b,o);else if(i.tag===19)Nj(i,b,o);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===o)break e;for(;i.sibling===null;){if(i.return===null||i.return===o)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}k&=1}if(vn(An,k),(o.mode&1)===0)o.memoizedState=null;else switch(L){case"forwards":for(b=o.child,L=null;b!==null;)i=b.alternate,i!==null&&Ku(i)===null&&(L=b),b=b.sibling;b=L,b===null?(L=o.child,o.child=null):(L=b.sibling,b.sibling=null),Lp(o,!1,L,b,H);break;case"backwards":for(b=null,L=o.child,o.child=null;L!==null;){if(i=L.alternate,i!==null&&Ku(i)===null){o.child=L;break}i=L.sibling,L.sibling=b,b=L,L=i}Lp(o,!0,b,null,H);break;case"together":Lp(o,!1,null,null,void 0);break;default:o.memoizedState=null}return o.child}function sh(i,o){(o.mode&1)===0&&i!==null&&(i.alternate=null,o.alternate=null,o.flags|=2)}function Bi(i,o,b){if(i!==null&&(o.dependencies=i.dependencies),vo|=o.lanes,(b&o.childLanes)===0)return null;if(i!==null&&o.child!==i.child)throw Error(n(153));if(o.child!==null){for(i=o.child,b=Sl(i,i.pendingProps),o.child=b,b.return=o;i.sibling!==null;)i=i.sibling,b=b.sibling=Sl(i,i.pendingProps),b.return=o;b.sibling=null}return o.child}function nT(i,o,b){switch(o.tag){case 3:bj(o),ac();break;case 5:My(o);break;case 1:Wr(o.type)&&Fu(o);break;case 4:pp(o,o.stateNode.containerInfo);break;case 10:var k=o.type._context,L=o.memoizedProps.value;vn(Vu,k._currentValue),k._currentValue=L;break;case 13:if(k=o.memoizedState,k!==null)return k.dehydrated!==null?(vn(An,An.current&1),o.flags|=128,null):(b&o.child.childLanes)!==0?jj(i,o,b):(vn(An,An.current&1),i=Bi(i,o,b),i!==null?i.sibling:null);vn(An,An.current&1);break;case 19:if(k=(b&o.childLanes)!==0,(i.flags&128)!==0){if(k)return wj(i,o,b);o.flags|=128}if(L=o.memoizedState,L!==null&&(L.rendering=null,L.tail=null,L.lastEffect=null),vn(An,An.current),k)break;return null;case 22:case 23:return o.lanes=0,xj(i,o,b)}return Bi(i,o,b)}var Sj,Mp,Cj,Aj;Sj=function(i,o){for(var b=o.child;b!==null;){if(b.tag===5||b.tag===6)i.appendChild(b.stateNode);else if(b.tag!==4&&b.child!==null){b.child.return=b,b=b.child;continue}if(b===o)break;for(;b.sibling===null;){if(b.return===null||b.return===o)return;b=b.return}b.sibling.return=b.return,b=b.sibling}},Mp=function(){},Cj=function(i,o,b,k){var L=i.memoizedProps;if(L!==k){i=o.stateNode,xo(ci.current);var H=null;switch(b){case"input":L=We(i,L),k=We(i,k),H=[];break;case"select":L=B({},L,{value:void 0}),k=B({},k,{value:void 0}),H=[];break;case"textarea":L=Ve(i,L),k=Ve(i,k),H=[];break;default:typeof L.onClick!="function"&&typeof k.onClick=="function"&&(i.onclick=Iu)}ns(b,k);var ae;b=null;for(Je in L)if(!k.hasOwnProperty(Je)&&L.hasOwnProperty(Je)&&L[Je]!=null)if(Je==="style"){var je=L[Je];for(ae in je)je.hasOwnProperty(ae)&&(b||(b={}),b[ae]="")}else Je!=="dangerouslySetInnerHTML"&&Je!=="children"&&Je!=="suppressContentEditableWarning"&&Je!=="suppressHydrationWarning"&&Je!=="autoFocus"&&(a.hasOwnProperty(Je)?H||(H=[]):(H=H||[]).push(Je,null));for(Je in k){var De=k[Je];if(je=L!=null?L[Je]:void 0,k.hasOwnProperty(Je)&&De!==je&&(De!=null||je!=null))if(Je==="style")if(je){for(ae in je)!je.hasOwnProperty(ae)||De&&De.hasOwnProperty(ae)||(b||(b={}),b[ae]="");for(ae in De)De.hasOwnProperty(ae)&&je[ae]!==De[ae]&&(b||(b={}),b[ae]=De[ae])}else b||(H||(H=[]),H.push(Je,b)),b=De;else Je==="dangerouslySetInnerHTML"?(De=De?De.__html:void 0,je=je?je.__html:void 0,De!=null&&je!==De&&(H=H||[]).push(Je,De)):Je==="children"?typeof De!="string"&&typeof De!="number"||(H=H||[]).push(Je,""+De):Je!=="suppressContentEditableWarning"&&Je!=="suppressHydrationWarning"&&(a.hasOwnProperty(Je)?(De!=null&&Je==="onScroll"&&bn("scroll",i),H||je===De||(H=[])):(H=H||[]).push(Je,De))}b&&(H=H||[]).push("style",b);var Je=H;(o.updateQueue=Je)&&(o.flags|=4)}},Aj=function(i,o,b,k){b!==k&&(o.flags|=4)};function hd(i,o){if(!Cn)switch(i.tailMode){case"hidden":o=i.tail;for(var b=null;o!==null;)o.alternate!==null&&(b=o),o=o.sibling;b===null?i.tail=null:b.sibling=null;break;case"collapsed":b=i.tail;for(var k=null;b!==null;)b.alternate!==null&&(k=b),b=b.sibling;k===null?o||i.tail===null?i.tail=null:i.tail.sibling=null:k.sibling=null}}function Sr(i){var o=i.alternate!==null&&i.alternate.child===i.child,b=0,k=0;if(o)for(var L=i.child;L!==null;)b|=L.lanes|L.childLanes,k|=L.subtreeFlags&14680064,k|=L.flags&14680064,L.return=i,L=L.sibling;else for(L=i.child;L!==null;)b|=L.lanes|L.childLanes,k|=L.subtreeFlags,k|=L.flags,L.return=i,L=L.sibling;return i.subtreeFlags|=k,i.childLanes=b,o}function rT(i,o,b){var k=o.pendingProps;switch(ap(o),o.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Sr(o),null;case 1:return Wr(o.type)&&Mu(),Sr(o),null;case 3:return k=o.stateNode,cc(),yn(Hr),yn(Nr),vp(),k.pendingContext&&(k.context=k.pendingContext,k.pendingContext=null),(i===null||i.child===null)&&(zu(o)?o.flags|=4:i===null||i.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,Ba!==null&&(Kp(Ba),Ba=null))),Mp(i,o),Sr(o),null;case 5:xp(o);var L=xo(ld.current);if(b=o.type,i!==null&&o.stateNode!=null)Cj(i,o,b,k,L),i.ref!==o.ref&&(o.flags|=512,o.flags|=2097152);else{if(!k){if(o.stateNode===null)throw Error(n(166));return Sr(o),null}if(i=xo(ci.current),zu(o)){k=o.stateNode,b=o.type;var H=o.memoizedProps;switch(k[oi]=o,k[sd]=H,i=(o.mode&1)!==0,b){case"dialog":bn("cancel",k),bn("close",k);break;case"iframe":case"object":case"embed":bn("load",k);break;case"video":case"audio":for(L=0;L<Jc.length;L++)bn(Jc[L],k);break;case"source":bn("error",k);break;case"img":case"image":case"link":bn("error",k),bn("load",k);break;case"details":bn("toggle",k);break;case"input":Ce(k,H),bn("invalid",k);break;case"select":k._wrapperState={wasMultiple:!!H.multiple},bn("invalid",k);break;case"textarea":dt(k,H),bn("invalid",k)}ns(b,H),L=null;for(var ae in H)if(H.hasOwnProperty(ae)){var je=H[ae];ae==="children"?typeof je=="string"?k.textContent!==je&&(H.suppressHydrationWarning!==!0&&Ou(k.textContent,je,i),L=["children",je]):typeof je=="number"&&k.textContent!==""+je&&(H.suppressHydrationWarning!==!0&&Ou(k.textContent,je,i),L=["children",""+je]):a.hasOwnProperty(ae)&&je!=null&&ae==="onScroll"&&bn("scroll",k)}switch(b){case"input":ge(k),be(k,H,!0);break;case"textarea":ge(k),ye(k);break;case"select":case"option":break;default:typeof H.onClick=="function"&&(k.onclick=Iu)}k=L,o.updateQueue=k,k!==null&&(o.flags|=4)}else{ae=L.nodeType===9?L:L.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=le(b)),i==="http://www.w3.org/1999/xhtml"?b==="script"?(i=ae.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof k.is=="string"?i=ae.createElement(b,{is:k.is}):(i=ae.createElement(b),b==="select"&&(ae=i,k.multiple?ae.multiple=!0:k.size&&(ae.size=k.size))):i=ae.createElementNS(i,b),i[oi]=o,i[sd]=k,Sj(i,o,!1,!1),o.stateNode=i;e:{switch(ae=Cs(b,k),b){case"dialog":bn("cancel",i),bn("close",i),L=k;break;case"iframe":case"object":case"embed":bn("load",i),L=k;break;case"video":case"audio":for(L=0;L<Jc.length;L++)bn(Jc[L],i);L=k;break;case"source":bn("error",i),L=k;break;case"img":case"image":case"link":bn("error",i),bn("load",i),L=k;break;case"details":bn("toggle",i),L=k;break;case"input":Ce(i,k),L=We(i,k),bn("invalid",i);break;case"option":L=k;break;case"select":i._wrapperState={wasMultiple:!!k.multiple},L=B({},k,{value:void 0}),bn("invalid",i);break;case"textarea":dt(i,k),L=Ve(i,k),bn("invalid",i);break;default:L=k}ns(b,L),je=L;for(H in je)if(je.hasOwnProperty(H)){var De=je[H];H==="style"?ws(i,De):H==="dangerouslySetInnerHTML"?(De=De?De.__html:void 0,De!=null&&Kt(i,De)):H==="children"?typeof De=="string"?(b!=="textarea"||De!=="")&&Rt(i,De):typeof De=="number"&&Rt(i,""+De):H!=="suppressContentEditableWarning"&&H!=="suppressHydrationWarning"&&H!=="autoFocus"&&(a.hasOwnProperty(H)?De!=null&&H==="onScroll"&&bn("scroll",i):De!=null&&C(i,H,De,ae))}switch(b){case"input":ge(i),be(i,k,!1);break;case"textarea":ge(i),ye(i);break;case"option":k.value!=null&&i.setAttribute("value",""+ne(k.value));break;case"select":i.multiple=!!k.multiple,H=k.value,H!=null?qe(i,!!k.multiple,H,!1):k.defaultValue!=null&&qe(i,!!k.multiple,k.defaultValue,!0);break;default:typeof L.onClick=="function"&&(i.onclick=Iu)}switch(b){case"button":case"input":case"select":case"textarea":k=!!k.autoFocus;break e;case"img":k=!0;break e;default:k=!1}}k&&(o.flags|=4)}o.ref!==null&&(o.flags|=512,o.flags|=2097152)}return Sr(o),null;case 6:if(i&&o.stateNode!=null)Aj(i,o,i.memoizedProps,k);else{if(typeof k!="string"&&o.stateNode===null)throw Error(n(166));if(b=xo(ld.current),xo(ci.current),zu(o)){if(k=o.stateNode,b=o.memoizedProps,k[oi]=o,(H=k.nodeValue!==b)&&(i=sa,i!==null))switch(i.tag){case 3:Ou(k.nodeValue,b,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&Ou(k.nodeValue,b,(i.mode&1)!==0)}H&&(o.flags|=4)}else k=(b.nodeType===9?b:b.ownerDocument).createTextNode(k),k[oi]=o,o.stateNode=k}return Sr(o),null;case 13:if(yn(An),k=o.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(Cn&&na!==null&&(o.mode&1)!==0&&(o.flags&128)===0)Ey(),ac(),o.flags|=98560,H=!1;else if(H=zu(o),k!==null&&k.dehydrated!==null){if(i===null){if(!H)throw Error(n(318));if(H=o.memoizedState,H=H!==null?H.dehydrated:null,!H)throw Error(n(317));H[oi]=o}else ac(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Sr(o),H=!1}else Ba!==null&&(Kp(Ba),Ba=null),H=!0;if(!H)return o.flags&65536?o:null}return(o.flags&128)!==0?(o.lanes=b,o):(k=k!==null,k!==(i!==null&&i.memoizedState!==null)&&k&&(o.child.flags|=8192,(o.mode&1)!==0&&(i===null||(An.current&1)!==0?Jn===0&&(Jn=3):Qp())),o.updateQueue!==null&&(o.flags|=4),Sr(o),null);case 4:return cc(),Mp(i,o),i===null&&ed(o.stateNode.containerInfo),Sr(o),null;case 10:return up(o.type._context),Sr(o),null;case 17:return Wr(o.type)&&Mu(),Sr(o),null;case 19:if(yn(An),H=o.memoizedState,H===null)return Sr(o),null;if(k=(o.flags&128)!==0,ae=H.rendering,ae===null)if(k)hd(H,!1);else{if(Jn!==0||i!==null&&(i.flags&128)!==0)for(i=o.child;i!==null;){if(ae=Ku(i),ae!==null){for(o.flags|=128,hd(H,!1),k=ae.updateQueue,k!==null&&(o.updateQueue=k,o.flags|=4),o.subtreeFlags=0,k=b,b=o.child;b!==null;)H=b,i=k,H.flags&=14680066,ae=H.alternate,ae===null?(H.childLanes=0,H.lanes=i,H.child=null,H.subtreeFlags=0,H.memoizedProps=null,H.memoizedState=null,H.updateQueue=null,H.dependencies=null,H.stateNode=null):(H.childLanes=ae.childLanes,H.lanes=ae.lanes,H.child=ae.child,H.subtreeFlags=0,H.deletions=null,H.memoizedProps=ae.memoizedProps,H.memoizedState=ae.memoizedState,H.updateQueue=ae.updateQueue,H.type=ae.type,i=ae.dependencies,H.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),b=b.sibling;return vn(An,An.current&1|2),o.child}i=i.sibling}H.tail!==null&&as()>mc&&(o.flags|=128,k=!0,hd(H,!1),o.lanes=4194304)}else{if(!k)if(i=Ku(ae),i!==null){if(o.flags|=128,k=!0,b=i.updateQueue,b!==null&&(o.updateQueue=b,o.flags|=4),hd(H,!0),H.tail===null&&H.tailMode==="hidden"&&!ae.alternate&&!Cn)return Sr(o),null}else 2*as()-H.renderingStartTime>mc&&b!==1073741824&&(o.flags|=128,k=!0,hd(H,!1),o.lanes=4194304);H.isBackwards?(ae.sibling=o.child,o.child=ae):(b=H.last,b!==null?b.sibling=ae:o.child=ae,H.last=ae)}return H.tail!==null?(o=H.tail,H.rendering=o,H.tail=o.sibling,H.renderingStartTime=as(),o.sibling=null,b=An.current,vn(An,k?b&1|2:b&1),o):(Sr(o),null);case 22:case 23:return Zp(),k=o.memoizedState!==null,i!==null&&i.memoizedState!==null!==k&&(o.flags|=8192),k&&(o.mode&1)!==0?(ra&1073741824)!==0&&(Sr(o),o.subtreeFlags&6&&(o.flags|=8192)):Sr(o),null;case 24:return null;case 25:return null}throw Error(n(156,o.tag))}function aT(i,o){switch(ap(o),o.tag){case 1:return Wr(o.type)&&Mu(),i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 3:return cc(),yn(Hr),yn(Nr),vp(),i=o.flags,(i&65536)!==0&&(i&128)===0?(o.flags=i&-65537|128,o):null;case 5:return xp(o),null;case 13:if(yn(An),i=o.memoizedState,i!==null&&i.dehydrated!==null){if(o.alternate===null)throw Error(n(340));ac()}return i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 19:return yn(An),null;case 4:return cc(),null;case 10:return up(o.type._context),null;case 22:case 23:return Zp(),null;case 24:return null;default:return null}}var nh=!1,Cr=!1,iT=typeof WeakSet=="function"?WeakSet:Set,ts=null;function uc(i,o){var b=i.ref;if(b!==null)if(typeof b=="function")try{b(null)}catch(k){Tn(i,o,k)}else b.current=null}function Fp(i,o,b){try{b()}catch(k){Tn(i,o,k)}}var kj=!1;function lT(i,o){if(Zf=_a,i=ay(),zf(i)){if("selectionStart"in i)var b={start:i.selectionStart,end:i.selectionEnd};else e:{b=(b=i.ownerDocument)&&b.defaultView||window;var k=b.getSelection&&b.getSelection();if(k&&k.rangeCount!==0){b=k.anchorNode;var L=k.anchorOffset,H=k.focusNode;k=k.focusOffset;try{b.nodeType,H.nodeType}catch{b=null;break e}var ae=0,je=-1,De=-1,Je=0,Nt=0,Dt=i,vt=null;t:for(;;){for(var Xt;Dt!==b||L!==0&&Dt.nodeType!==3||(je=ae+L),Dt!==H||k!==0&&Dt.nodeType!==3||(De=ae+k),Dt.nodeType===3&&(ae+=Dt.nodeValue.length),(Xt=Dt.firstChild)!==null;)vt=Dt,Dt=Xt;for(;;){if(Dt===i)break t;if(vt===b&&++Je===L&&(je=ae),vt===H&&++Nt===k&&(De=ae),(Xt=Dt.nextSibling)!==null)break;Dt=vt,vt=Dt.parentNode}Dt=Xt}b=je===-1||De===-1?null:{start:je,end:De}}else b=null}b=b||{start:0,end:0}}else b=null;for(Qf={focusedElem:i,selectionRange:b},_a=!1,ts=o;ts!==null;)if(o=ts,i=o.child,(o.subtreeFlags&1028)!==0&&i!==null)i.return=o,ts=i;else for(;ts!==null;){o=ts;try{var is=o.alternate;if((o.flags&1024)!==0)switch(o.tag){case 0:case 11:case 15:break;case 1:if(is!==null){var cs=is.memoizedProps,Ln=is.memoizedState,He=o.stateNode,Oe=He.getSnapshotBeforeUpdate(o.elementType===o.type?cs:$a(o.type,cs),Ln);He.__reactInternalSnapshotBeforeUpdate=Oe}break;case 3:var Ke=o.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(It){Tn(o,o.return,It)}if(i=o.sibling,i!==null){i.return=o.return,ts=i;break}ts=o.return}return is=kj,kj=!1,is}function md(i,o,b){var k=o.updateQueue;if(k=k!==null?k.lastEffect:null,k!==null){var L=k=k.next;do{if((L.tag&i)===i){var H=L.destroy;L.destroy=void 0,H!==void 0&&Fp(o,b,H)}L=L.next}while(L!==k)}}function rh(i,o){if(o=o.updateQueue,o=o!==null?o.lastEffect:null,o!==null){var b=o=o.next;do{if((b.tag&i)===i){var k=b.create;b.destroy=k()}b=b.next}while(b!==o)}}function Bp(i){var o=i.ref;if(o!==null){var b=i.stateNode;switch(i.tag){case 5:i=b;break;default:i=b}typeof o=="function"?o(i):o.current=i}}function Rj(i){var o=i.alternate;o!==null&&(i.alternate=null,Rj(o)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(o=i.stateNode,o!==null&&(delete o[oi],delete o[sd],delete o[tp],delete o[UD],delete o[VD])),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}function Ej(i){return i.tag===5||i.tag===3||i.tag===4}function Dj(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||Ej(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function $p(i,o,b){var k=i.tag;if(k===5||k===6)i=i.stateNode,o?b.nodeType===8?b.parentNode.insertBefore(i,o):b.insertBefore(i,o):(b.nodeType===8?(o=b.parentNode,o.insertBefore(i,b)):(o=b,o.appendChild(i)),b=b._reactRootContainer,b!=null||o.onclick!==null||(o.onclick=Iu));else if(k!==4&&(i=i.child,i!==null))for($p(i,o,b),i=i.sibling;i!==null;)$p(i,o,b),i=i.sibling}function qp(i,o,b){var k=i.tag;if(k===5||k===6)i=i.stateNode,o?b.insertBefore(i,o):b.appendChild(i);else if(k!==4&&(i=i.child,i!==null))for(qp(i,o,b),i=i.sibling;i!==null;)qp(i,o,b),i=i.sibling}var gr=null,qa=!1;function bl(i,o,b){for(b=b.child;b!==null;)Tj(i,o,b),b=b.sibling}function Tj(i,o,b){if(Qs&&typeof Qs.onCommitFiberUnmount=="function")try{Qs.onCommitFiberUnmount(Ws,b)}catch{}switch(b.tag){case 5:Cr||uc(b,o);case 6:var k=gr,L=qa;gr=null,bl(i,o,b),gr=k,qa=L,gr!==null&&(qa?(i=gr,b=b.stateNode,i.nodeType===8?i.parentNode.removeChild(b):i.removeChild(b)):gr.removeChild(b.stateNode));break;case 18:gr!==null&&(qa?(i=gr,b=b.stateNode,i.nodeType===8?ep(i.parentNode,b):i.nodeType===1&&ep(i,b),ri(i)):ep(gr,b.stateNode));break;case 4:k=gr,L=qa,gr=b.stateNode.containerInfo,qa=!0,bl(i,o,b),gr=k,qa=L;break;case 0:case 11:case 14:case 15:if(!Cr&&(k=b.updateQueue,k!==null&&(k=k.lastEffect,k!==null))){L=k=k.next;do{var H=L,ae=H.destroy;H=H.tag,ae!==void 0&&((H&2)!==0||(H&4)!==0)&&Fp(b,o,ae),L=L.next}while(L!==k)}bl(i,o,b);break;case 1:if(!Cr&&(uc(b,o),k=b.stateNode,typeof k.componentWillUnmount=="function"))try{k.props=b.memoizedProps,k.state=b.memoizedState,k.componentWillUnmount()}catch(je){Tn(b,o,je)}bl(i,o,b);break;case 21:bl(i,o,b);break;case 22:b.mode&1?(Cr=(k=Cr)||b.memoizedState!==null,bl(i,o,b),Cr=k):bl(i,o,b);break;default:bl(i,o,b)}}function Pj(i){var o=i.updateQueue;if(o!==null){i.updateQueue=null;var b=i.stateNode;b===null&&(b=i.stateNode=new iT),o.forEach(function(k){var L=xT.bind(null,i,k);b.has(k)||(b.add(k),k.then(L,L))})}}function za(i,o){var b=o.deletions;if(b!==null)for(var k=0;k<b.length;k++){var L=b[k];try{var H=i,ae=o,je=ae;e:for(;je!==null;){switch(je.tag){case 5:gr=je.stateNode,qa=!1;break e;case 3:gr=je.stateNode.containerInfo,qa=!0;break e;case 4:gr=je.stateNode.containerInfo,qa=!0;break e}je=je.return}if(gr===null)throw Error(n(160));Tj(H,ae,L),gr=null,qa=!1;var De=L.alternate;De!==null&&(De.return=null),L.return=null}catch(Je){Tn(L,o,Je)}}if(o.subtreeFlags&12854)for(o=o.child;o!==null;)_j(o,i),o=o.sibling}function _j(i,o){var b=i.alternate,k=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(za(o,i),ui(i),k&4){try{md(3,i,i.return),rh(3,i)}catch(cs){Tn(i,i.return,cs)}try{md(5,i,i.return)}catch(cs){Tn(i,i.return,cs)}}break;case 1:za(o,i),ui(i),k&512&&b!==null&&uc(b,b.return);break;case 5:if(za(o,i),ui(i),k&512&&b!==null&&uc(b,b.return),i.flags&32){var L=i.stateNode;try{Rt(L,"")}catch(cs){Tn(i,i.return,cs)}}if(k&4&&(L=i.stateNode,L!=null)){var H=i.memoizedProps,ae=b!==null?b.memoizedProps:H,je=i.type,De=i.updateQueue;if(i.updateQueue=null,De!==null)try{je==="input"&&H.type==="radio"&&H.name!=null&&fe(L,H),Cs(je,ae);var Je=Cs(je,H);for(ae=0;ae<De.length;ae+=2){var Nt=De[ae],Dt=De[ae+1];Nt==="style"?ws(L,Dt):Nt==="dangerouslySetInnerHTML"?Kt(L,Dt):Nt==="children"?Rt(L,Dt):C(L,Nt,Dt,Je)}switch(je){case"input":Ye(L,H);break;case"textarea":xt(L,H);break;case"select":var vt=L._wrapperState.wasMultiple;L._wrapperState.wasMultiple=!!H.multiple;var Xt=H.value;Xt!=null?qe(L,!!H.multiple,Xt,!1):vt!==!!H.multiple&&(H.defaultValue!=null?qe(L,!!H.multiple,H.defaultValue,!0):qe(L,!!H.multiple,H.multiple?[]:"",!1))}L[sd]=H}catch(cs){Tn(i,i.return,cs)}}break;case 6:if(za(o,i),ui(i),k&4){if(i.stateNode===null)throw Error(n(162));L=i.stateNode,H=i.memoizedProps;try{L.nodeValue=H}catch(cs){Tn(i,i.return,cs)}}break;case 3:if(za(o,i),ui(i),k&4&&b!==null&&b.memoizedState.isDehydrated)try{ri(o.containerInfo)}catch(cs){Tn(i,i.return,cs)}break;case 4:za(o,i),ui(i);break;case 13:za(o,i),ui(i),L=i.child,L.flags&8192&&(H=L.memoizedState!==null,L.stateNode.isHidden=H,!H||L.alternate!==null&&L.alternate.memoizedState!==null||(Vp=as())),k&4&&Pj(i);break;case 22:if(Nt=b!==null&&b.memoizedState!==null,i.mode&1?(Cr=(Je=Cr)||Nt,za(o,i),Cr=Je):za(o,i),ui(i),k&8192){if(Je=i.memoizedState!==null,(i.stateNode.isHidden=Je)&&!Nt&&(i.mode&1)!==0)for(ts=i,Nt=i.child;Nt!==null;){for(Dt=ts=Nt;ts!==null;){switch(vt=ts,Xt=vt.child,vt.tag){case 0:case 11:case 14:case 15:md(4,vt,vt.return);break;case 1:uc(vt,vt.return);var is=vt.stateNode;if(typeof is.componentWillUnmount=="function"){k=vt,b=vt.return;try{o=k,is.props=o.memoizedProps,is.state=o.memoizedState,is.componentWillUnmount()}catch(cs){Tn(k,b,cs)}}break;case 5:uc(vt,vt.return);break;case 22:if(vt.memoizedState!==null){Lj(Dt);continue}}Xt!==null?(Xt.return=vt,ts=Xt):Lj(Dt)}Nt=Nt.sibling}e:for(Nt=null,Dt=i;;){if(Dt.tag===5){if(Nt===null){Nt=Dt;try{L=Dt.stateNode,Je?(H=L.style,typeof H.setProperty=="function"?H.setProperty("display","none","important"):H.display="none"):(je=Dt.stateNode,De=Dt.memoizedProps.style,ae=De!=null&&De.hasOwnProperty("display")?De.display:null,je.style.display=qt("display",ae))}catch(cs){Tn(i,i.return,cs)}}}else if(Dt.tag===6){if(Nt===null)try{Dt.stateNode.nodeValue=Je?"":Dt.memoizedProps}catch(cs){Tn(i,i.return,cs)}}else if((Dt.tag!==22&&Dt.tag!==23||Dt.memoizedState===null||Dt===i)&&Dt.child!==null){Dt.child.return=Dt,Dt=Dt.child;continue}if(Dt===i)break e;for(;Dt.sibling===null;){if(Dt.return===null||Dt.return===i)break e;Nt===Dt&&(Nt=null),Dt=Dt.return}Nt===Dt&&(Nt=null),Dt.sibling.return=Dt.return,Dt=Dt.sibling}}break;case 19:za(o,i),ui(i),k&4&&Pj(i);break;case 21:break;default:za(o,i),ui(i)}}function ui(i){var o=i.flags;if(o&2){try{e:{for(var b=i.return;b!==null;){if(Ej(b)){var k=b;break e}b=b.return}throw Error(n(160))}switch(k.tag){case 5:var L=k.stateNode;k.flags&32&&(Rt(L,""),k.flags&=-33);var H=Dj(i);qp(i,H,L);break;case 3:case 4:var ae=k.stateNode.containerInfo,je=Dj(i);$p(i,je,ae);break;default:throw Error(n(161))}}catch(De){Tn(i,i.return,De)}i.flags&=-3}o&4096&&(i.flags&=-4097)}function oT(i,o,b){ts=i,Oj(i)}function Oj(i,o,b){for(var k=(i.mode&1)!==0;ts!==null;){var L=ts,H=L.child;if(L.tag===22&&k){var ae=L.memoizedState!==null||nh;if(!ae){var je=L.alternate,De=je!==null&&je.memoizedState!==null||Cr;je=nh;var Je=Cr;if(nh=ae,(Cr=De)&&!Je)for(ts=L;ts!==null;)ae=ts,De=ae.child,ae.tag===22&&ae.memoizedState!==null?Mj(L):De!==null?(De.return=ae,ts=De):Mj(L);for(;H!==null;)ts=H,Oj(H),H=H.sibling;ts=L,nh=je,Cr=Je}Ij(i)}else(L.subtreeFlags&8772)!==0&&H!==null?(H.return=L,ts=H):Ij(i)}}function Ij(i){for(;ts!==null;){var o=ts;if((o.flags&8772)!==0){var b=o.alternate;try{if((o.flags&8772)!==0)switch(o.tag){case 0:case 11:case 15:Cr||rh(5,o);break;case 1:var k=o.stateNode;if(o.flags&4&&!Cr)if(b===null)k.componentDidMount();else{var L=o.elementType===o.type?b.memoizedProps:$a(o.type,b.memoizedProps);k.componentDidUpdate(L,b.memoizedState,k.__reactInternalSnapshotBeforeUpdate)}var H=o.updateQueue;H!==null&&Ly(o,H,k);break;case 3:var ae=o.updateQueue;if(ae!==null){if(b=null,o.child!==null)switch(o.child.tag){case 5:b=o.child.stateNode;break;case 1:b=o.child.stateNode}Ly(o,ae,b)}break;case 5:var je=o.stateNode;if(b===null&&o.flags&4){b=je;var De=o.memoizedProps;switch(o.type){case"button":case"input":case"select":case"textarea":De.autoFocus&&b.focus();break;case"img":De.src&&(b.src=De.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(o.memoizedState===null){var Je=o.alternate;if(Je!==null){var Nt=Je.memoizedState;if(Nt!==null){var Dt=Nt.dehydrated;Dt!==null&&ri(Dt)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Cr||o.flags&512&&Bp(o)}catch(vt){Tn(o,o.return,vt)}}if(o===i){ts=null;break}if(b=o.sibling,b!==null){b.return=o.return,ts=b;break}ts=o.return}}function Lj(i){for(;ts!==null;){var o=ts;if(o===i){ts=null;break}var b=o.sibling;if(b!==null){b.return=o.return,ts=b;break}ts=o.return}}function Mj(i){for(;ts!==null;){var o=ts;try{switch(o.tag){case 0:case 11:case 15:var b=o.return;try{rh(4,o)}catch(De){Tn(o,b,De)}break;case 1:var k=o.stateNode;if(typeof k.componentDidMount=="function"){var L=o.return;try{k.componentDidMount()}catch(De){Tn(o,L,De)}}var H=o.return;try{Bp(o)}catch(De){Tn(o,H,De)}break;case 5:var ae=o.return;try{Bp(o)}catch(De){Tn(o,ae,De)}}}catch(De){Tn(o,o.return,De)}if(o===i){ts=null;break}var je=o.sibling;if(je!==null){je.return=o.return,ts=je;break}ts=o.return}}var cT=Math.ceil,ah=w.ReactCurrentDispatcher,zp=w.ReactCurrentOwner,Na=w.ReactCurrentBatchConfig,Xs=0,lr=null,Wn=null,vr=0,ra=0,hc=fl(0),Jn=0,fd=null,vo=0,ih=0,Up=0,pd=null,Kr=null,Vp=0,mc=1/0,$i=null,lh=!1,Hp=null,yl=null,oh=!1,jl=null,ch=0,xd=0,Wp=null,dh=-1,uh=0;function Mr(){return(Xs&6)!==0?as():dh!==-1?dh:dh=as()}function Nl(i){return(i.mode&1)===0?1:(Xs&2)!==0&&vr!==0?vr&-vr:WD.transition!==null?(uh===0&&(uh=jt()),uh):(i=qs,i!==0||(i=window.event,i=i===void 0?16:Ri(i.type)),i)}function Ua(i,o,b,k){if(50<xd)throw xd=0,Wp=null,Error(n(185));jr(i,b,k),((Xs&2)===0||i!==lr)&&(i===lr&&((Xs&2)===0&&(ih|=b),Jn===4&&wl(i,vr)),Yr(i,k),b===1&&Xs===0&&(o.mode&1)===0&&(mc=as()+500,Bu&&xl()))}function Yr(i,o){var b=i.callbackNode;Ze(i,o);var k=Xe(i,i===lr?vr:0);if(k===0)b!==null&&mt(b),i.callbackNode=null,i.callbackPriority=0;else if(o=k&-k,i.callbackPriority!==o){if(b!=null&&mt(b),o===1)i.tag===0?HD(Bj.bind(null,i)):Sy(Bj.bind(null,i)),qD(function(){(Xs&6)===0&&xl()}),b=null;else{switch(ha(k)){case 1:b=Ls;break;case 4:b=Ts;break;case 16:b=ln;break;case 536870912:b=hn;break;default:b=ln}b=Gj(b,Fj.bind(null,i))}i.callbackPriority=o,i.callbackNode=b}}function Fj(i,o){if(dh=-1,uh=0,(Xs&6)!==0)throw Error(n(327));var b=i.callbackNode;if(fc()&&i.callbackNode!==b)return null;var k=Xe(i,i===lr?vr:0);if(k===0)return null;if((k&30)!==0||(k&i.expiredLanes)!==0||o)o=hh(i,k);else{o=k;var L=Xs;Xs|=2;var H=qj();(lr!==i||vr!==o)&&($i=null,mc=as()+500,yo(i,o));do try{hT();break}catch(je){$j(i,je)}while(!0);dp(),ah.current=H,Xs=L,Wn!==null?o=0:(lr=null,vr=0,o=Jn)}if(o!==0){if(o===2&&(L=Ut(i),L!==0&&(k=L,o=Gp(i,L))),o===1)throw b=fd,yo(i,0),wl(i,k),Yr(i,as()),b;if(o===6)wl(i,k);else{if(L=i.current.alternate,(k&30)===0&&!dT(L)&&(o=hh(i,k),o===2&&(H=Ut(i),H!==0&&(k=H,o=Gp(i,H))),o===1))throw b=fd,yo(i,0),wl(i,k),Yr(i,as()),b;switch(i.finishedWork=L,i.finishedLanes=k,o){case 0:case 1:throw Error(n(345));case 2:jo(i,Kr,$i);break;case 3:if(wl(i,k),(k&130023424)===k&&(o=Vp+500-as(),10<o)){if(Xe(i,0)!==0)break;if(L=i.suspendedLanes,(L&k)!==k){Mr(),i.pingedLanes|=i.suspendedLanes&L;break}i.timeoutHandle=Jf(jo.bind(null,i,Kr,$i),o);break}jo(i,Kr,$i);break;case 4:if(wl(i,k),(k&4194240)===k)break;for(o=i.eventTimes,L=-1;0<k;){var ae=31-on(k);H=1<<ae,ae=o[ae],ae>L&&(L=ae),k&=~H}if(k=L,k=as()-k,k=(120>k?120:480>k?480:1080>k?1080:1920>k?1920:3e3>k?3e3:4320>k?4320:1960*cT(k/1960))-k,10<k){i.timeoutHandle=Jf(jo.bind(null,i,Kr,$i),k);break}jo(i,Kr,$i);break;case 5:jo(i,Kr,$i);break;default:throw Error(n(329))}}}return Yr(i,as()),i.callbackNode===b?Fj.bind(null,i):null}function Gp(i,o){var b=pd;return i.current.memoizedState.isDehydrated&&(yo(i,o).flags|=256),i=hh(i,o),i!==2&&(o=Kr,Kr=b,o!==null&&Kp(o)),i}function Kp(i){Kr===null?Kr=i:Kr.push.apply(Kr,i)}function dT(i){for(var o=i;;){if(o.flags&16384){var b=o.updateQueue;if(b!==null&&(b=b.stores,b!==null))for(var k=0;k<b.length;k++){var L=b[k],H=L.getSnapshot;L=L.value;try{if(!Fa(H(),L))return!1}catch{return!1}}}if(b=o.child,o.subtreeFlags&16384&&b!==null)b.return=o,o=b;else{if(o===i)break;for(;o.sibling===null;){if(o.return===null||o.return===i)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function wl(i,o){for(o&=~Up,o&=~ih,i.suspendedLanes|=o,i.pingedLanes&=~o,i=i.expirationTimes;0<o;){var b=31-on(o),k=1<<b;i[b]=-1,o&=~k}}function Bj(i){if((Xs&6)!==0)throw Error(n(327));fc();var o=Xe(i,0);if((o&1)===0)return Yr(i,as()),null;var b=hh(i,o);if(i.tag!==0&&b===2){var k=Ut(i);k!==0&&(o=k,b=Gp(i,k))}if(b===1)throw b=fd,yo(i,0),wl(i,o),Yr(i,as()),b;if(b===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=o,jo(i,Kr,$i),Yr(i,as()),null}function Yp(i,o){var b=Xs;Xs|=1;try{return i(o)}finally{Xs=b,Xs===0&&(mc=as()+500,Bu&&xl())}}function bo(i){jl!==null&&jl.tag===0&&(Xs&6)===0&&fc();var o=Xs;Xs|=1;var b=Na.transition,k=qs;try{if(Na.transition=null,qs=1,i)return i()}finally{qs=k,Na.transition=b,Xs=o,(Xs&6)===0&&xl()}}function Zp(){ra=hc.current,yn(hc)}function yo(i,o){i.finishedWork=null,i.finishedLanes=0;var b=i.timeoutHandle;if(b!==-1&&(i.timeoutHandle=-1,$D(b)),Wn!==null)for(b=Wn.return;b!==null;){var k=b;switch(ap(k),k.tag){case 1:k=k.type.childContextTypes,k!=null&&Mu();break;case 3:cc(),yn(Hr),yn(Nr),vp();break;case 5:xp(k);break;case 4:cc();break;case 13:yn(An);break;case 19:yn(An);break;case 10:up(k.type._context);break;case 22:case 23:Zp()}b=b.return}if(lr=i,Wn=i=Sl(i.current,null),vr=ra=o,Jn=0,fd=null,Up=ih=vo=0,Kr=pd=null,po!==null){for(o=0;o<po.length;o++)if(b=po[o],k=b.interleaved,k!==null){b.interleaved=null;var L=k.next,H=b.pending;if(H!==null){var ae=H.next;H.next=L,k.next=ae}b.pending=k}po=null}return i}function $j(i,o){do{var b=Wn;try{if(dp(),Yu.current=Ju,Zu){for(var k=kn.memoizedState;k!==null;){var L=k.queue;L!==null&&(L.pending=null),k=k.next}Zu=!1}if(go=0,ir=Xn=kn=null,od=!1,cd=0,zp.current=null,b===null||b.return===null){Jn=1,fd=o,Wn=null;break}e:{var H=i,ae=b.return,je=b,De=o;if(o=vr,je.flags|=32768,De!==null&&typeof De=="object"&&typeof De.then=="function"){var Je=De,Nt=je,Dt=Nt.tag;if((Nt.mode&1)===0&&(Dt===0||Dt===11||Dt===15)){var vt=Nt.alternate;vt?(Nt.updateQueue=vt.updateQueue,Nt.memoizedState=vt.memoizedState,Nt.lanes=vt.lanes):(Nt.updateQueue=null,Nt.memoizedState=null)}var Xt=uj(ae);if(Xt!==null){Xt.flags&=-257,hj(Xt,ae,je,H,o),Xt.mode&1&&dj(H,Je,o),o=Xt,De=Je;var is=o.updateQueue;if(is===null){var cs=new Set;cs.add(De),o.updateQueue=cs}else is.add(De);break e}else{if((o&1)===0){dj(H,Je,o),Qp();break e}De=Error(n(426))}}else if(Cn&&je.mode&1){var Ln=uj(ae);if(Ln!==null){(Ln.flags&65536)===0&&(Ln.flags|=256),hj(Ln,ae,je,H,o),op(dc(De,je));break e}}H=De=dc(De,je),Jn!==4&&(Jn=2),pd===null?pd=[H]:pd.push(H),H=ae;do{switch(H.tag){case 3:H.flags|=65536,o&=-o,H.lanes|=o;var He=oj(H,De,o);Iy(H,He);break e;case 1:je=De;var Oe=H.type,Ke=H.stateNode;if((H.flags&128)===0&&(typeof Oe.getDerivedStateFromError=="function"||Ke!==null&&typeof Ke.componentDidCatch=="function"&&(yl===null||!yl.has(Ke)))){H.flags|=65536,o&=-o,H.lanes|=o;var It=cj(H,je,o);Iy(H,It);break e}}H=H.return}while(H!==null)}Uj(b)}catch(hs){o=hs,Wn===b&&b!==null&&(Wn=b=b.return);continue}break}while(!0)}function qj(){var i=ah.current;return ah.current=Ju,i===null?Ju:i}function Qp(){(Jn===0||Jn===3||Jn===2)&&(Jn=4),lr===null||(vo&268435455)===0&&(ih&268435455)===0||wl(lr,vr)}function hh(i,o){var b=Xs;Xs|=2;var k=qj();(lr!==i||vr!==o)&&($i=null,yo(i,o));do try{uT();break}catch(L){$j(i,L)}while(!0);if(dp(),Xs=b,ah.current=k,Wn!==null)throw Error(n(261));return lr=null,vr=0,Jn}function uT(){for(;Wn!==null;)zj(Wn)}function hT(){for(;Wn!==null&&!Bt();)zj(Wn)}function zj(i){var o=Wj(i.alternate,i,ra);i.memoizedProps=i.pendingProps,o===null?Uj(i):Wn=o,zp.current=null}function Uj(i){var o=i;do{var b=o.alternate;if(i=o.return,(o.flags&32768)===0){if(b=rT(b,o,ra),b!==null){Wn=b;return}}else{if(b=aT(b,o),b!==null){b.flags&=32767,Wn=b;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{Jn=6,Wn=null;return}}if(o=o.sibling,o!==null){Wn=o;return}Wn=o=i}while(o!==null);Jn===0&&(Jn=5)}function jo(i,o,b){var k=qs,L=Na.transition;try{Na.transition=null,qs=1,mT(i,o,b,k)}finally{Na.transition=L,qs=k}return null}function mT(i,o,b,k){do fc();while(jl!==null);if((Xs&6)!==0)throw Error(n(327));b=i.finishedWork;var L=i.finishedLanes;if(b===null)return null;if(i.finishedWork=null,i.finishedLanes=0,b===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var H=b.lanes|b.childLanes;if(Pr(i,H),i===lr&&(Wn=lr=null,vr=0),(b.subtreeFlags&2064)===0&&(b.flags&2064)===0||oh||(oh=!0,Gj(ln,function(){return fc(),null})),H=(b.flags&15990)!==0,(b.subtreeFlags&15990)!==0||H){H=Na.transition,Na.transition=null;var ae=qs;qs=1;var je=Xs;Xs|=4,zp.current=null,lT(i,b),_j(b,i),_D(Qf),_a=!!Zf,Qf=Zf=null,i.current=b,oT(b),Ds(),Xs=je,qs=ae,Na.transition=H}else i.current=b;if(oh&&(oh=!1,jl=i,ch=L),H=i.pendingLanes,H===0&&(yl=null),zn(b.stateNode),Yr(i,as()),o!==null)for(k=i.onRecoverableError,b=0;b<o.length;b++)L=o[b],k(L.value,{componentStack:L.stack,digest:L.digest});if(lh)throw lh=!1,i=Hp,Hp=null,i;return(ch&1)!==0&&i.tag!==0&&fc(),H=i.pendingLanes,(H&1)!==0?i===Wp?xd++:(xd=0,Wp=i):xd=0,xl(),null}function fc(){if(jl!==null){var i=ha(ch),o=Na.transition,b=qs;try{if(Na.transition=null,qs=16>i?16:i,jl===null)var k=!1;else{if(i=jl,jl=null,ch=0,(Xs&6)!==0)throw Error(n(331));var L=Xs;for(Xs|=4,ts=i.current;ts!==null;){var H=ts,ae=H.child;if((ts.flags&16)!==0){var je=H.deletions;if(je!==null){for(var De=0;De<je.length;De++){var Je=je[De];for(ts=Je;ts!==null;){var Nt=ts;switch(Nt.tag){case 0:case 11:case 15:md(8,Nt,H)}var Dt=Nt.child;if(Dt!==null)Dt.return=Nt,ts=Dt;else for(;ts!==null;){Nt=ts;var vt=Nt.sibling,Xt=Nt.return;if(Rj(Nt),Nt===Je){ts=null;break}if(vt!==null){vt.return=Xt,ts=vt;break}ts=Xt}}}var is=H.alternate;if(is!==null){var cs=is.child;if(cs!==null){is.child=null;do{var Ln=cs.sibling;cs.sibling=null,cs=Ln}while(cs!==null)}}ts=H}}if((H.subtreeFlags&2064)!==0&&ae!==null)ae.return=H,ts=ae;else e:for(;ts!==null;){if(H=ts,(H.flags&2048)!==0)switch(H.tag){case 0:case 11:case 15:md(9,H,H.return)}var He=H.sibling;if(He!==null){He.return=H.return,ts=He;break e}ts=H.return}}var Oe=i.current;for(ts=Oe;ts!==null;){ae=ts;var Ke=ae.child;if((ae.subtreeFlags&2064)!==0&&Ke!==null)Ke.return=ae,ts=Ke;else e:for(ae=Oe;ts!==null;){if(je=ts,(je.flags&2048)!==0)try{switch(je.tag){case 0:case 11:case 15:rh(9,je)}}catch(hs){Tn(je,je.return,hs)}if(je===ae){ts=null;break e}var It=je.sibling;if(It!==null){It.return=je.return,ts=It;break e}ts=je.return}}if(Xs=L,xl(),Qs&&typeof Qs.onPostCommitFiberRoot=="function")try{Qs.onPostCommitFiberRoot(Ws,i)}catch{}k=!0}return k}finally{qs=b,Na.transition=o}}return!1}function Vj(i,o,b){o=dc(b,o),o=oj(i,o,1),i=vl(i,o,1),o=Mr(),i!==null&&(jr(i,1,o),Yr(i,o))}function Tn(i,o,b){if(i.tag===3)Vj(i,i,b);else for(;o!==null;){if(o.tag===3){Vj(o,i,b);break}else if(o.tag===1){var k=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof k.componentDidCatch=="function"&&(yl===null||!yl.has(k))){i=dc(b,i),i=cj(o,i,1),o=vl(o,i,1),i=Mr(),o!==null&&(jr(o,1,i),Yr(o,i));break}}o=o.return}}function fT(i,o,b){var k=i.pingCache;k!==null&&k.delete(o),o=Mr(),i.pingedLanes|=i.suspendedLanes&b,lr===i&&(vr&b)===b&&(Jn===4||Jn===3&&(vr&130023424)===vr&&500>as()-Vp?yo(i,0):Up|=b),Yr(i,o)}function Hj(i,o){o===0&&((i.mode&1)===0?o=1:(o=tr,tr<<=1,(tr&130023424)===0&&(tr=4194304)));var b=Mr();i=Mi(i,o),i!==null&&(jr(i,o,b),Yr(i,b))}function pT(i){var o=i.memoizedState,b=0;o!==null&&(b=o.retryLane),Hj(i,b)}function xT(i,o){var b=0;switch(i.tag){case 13:var k=i.stateNode,L=i.memoizedState;L!==null&&(b=L.retryLane);break;case 19:k=i.stateNode;break;default:throw Error(n(314))}k!==null&&k.delete(o),Hj(i,b)}var Wj;Wj=function(i,o,b){if(i!==null)if(i.memoizedProps!==o.pendingProps||Hr.current)Gr=!0;else{if((i.lanes&b)===0&&(o.flags&128)===0)return Gr=!1,nT(i,o,b);Gr=(i.flags&131072)!==0}else Gr=!1,Cn&&(o.flags&1048576)!==0&&Cy(o,qu,o.index);switch(o.lanes=0,o.tag){case 2:var k=o.type;sh(i,o),i=o.pendingProps;var L=sc(o,Nr.current);oc(o,b),L=jp(null,o,k,i,L,b);var H=Np();return o.flags|=1,typeof L=="object"&&L!==null&&typeof L.render=="function"&&L.$$typeof===void 0?(o.tag=1,o.memoizedState=null,o.updateQueue=null,Wr(k)?(H=!0,Fu(o)):H=!1,o.memoizedState=L.state!==null&&L.state!==void 0?L.state:null,fp(o),L.updater=eh,o.stateNode=L,L._reactInternals=o,Rp(o,k,i,b),o=Pp(null,o,k,!0,H,b)):(o.tag=0,Cn&&H&&rp(o),Lr(null,o,L,b),o=o.child),o;case 16:k=o.elementType;e:{switch(sh(i,o),i=o.pendingProps,L=k._init,k=L(k._payload),o.type=k,L=o.tag=vT(k),i=$a(k,i),L){case 0:o=Tp(null,o,k,i,b);break e;case 1:o=vj(null,o,k,i,b);break e;case 11:o=mj(null,o,k,i,b);break e;case 14:o=fj(null,o,k,$a(k.type,i),b);break e}throw Error(n(306,k,""))}return o;case 0:return k=o.type,L=o.pendingProps,L=o.elementType===k?L:$a(k,L),Tp(i,o,k,L,b);case 1:return k=o.type,L=o.pendingProps,L=o.elementType===k?L:$a(k,L),vj(i,o,k,L,b);case 3:e:{if(bj(o),i===null)throw Error(n(387));k=o.pendingProps,H=o.memoizedState,L=H.element,Oy(i,o),Gu(o,k,null,b);var ae=o.memoizedState;if(k=ae.element,H.isDehydrated)if(H={element:k,isDehydrated:!1,cache:ae.cache,pendingSuspenseBoundaries:ae.pendingSuspenseBoundaries,transitions:ae.transitions},o.updateQueue.baseState=H,o.memoizedState=H,o.flags&256){L=dc(Error(n(423)),o),o=yj(i,o,k,b,L);break e}else if(k!==L){L=dc(Error(n(424)),o),o=yj(i,o,k,b,L);break e}else for(na=ml(o.stateNode.containerInfo.firstChild),sa=o,Cn=!0,Ba=null,b=Py(o,null,k,b),o.child=b;b;)b.flags=b.flags&-3|4096,b=b.sibling;else{if(ac(),k===L){o=Bi(i,o,b);break e}Lr(i,o,k,b)}o=o.child}return o;case 5:return My(o),i===null&&lp(o),k=o.type,L=o.pendingProps,H=i!==null?i.memoizedProps:null,ae=L.children,Xf(k,L)?ae=null:H!==null&&Xf(k,H)&&(o.flags|=32),gj(i,o),Lr(i,o,ae,b),o.child;case 6:return i===null&&lp(o),null;case 13:return jj(i,o,b);case 4:return pp(o,o.stateNode.containerInfo),k=o.pendingProps,i===null?o.child=ic(o,null,k,b):Lr(i,o,k,b),o.child;case 11:return k=o.type,L=o.pendingProps,L=o.elementType===k?L:$a(k,L),mj(i,o,k,L,b);case 7:return Lr(i,o,o.pendingProps,b),o.child;case 8:return Lr(i,o,o.pendingProps.children,b),o.child;case 12:return Lr(i,o,o.pendingProps.children,b),o.child;case 10:e:{if(k=o.type._context,L=o.pendingProps,H=o.memoizedProps,ae=L.value,vn(Vu,k._currentValue),k._currentValue=ae,H!==null)if(Fa(H.value,ae)){if(H.children===L.children&&!Hr.current){o=Bi(i,o,b);break e}}else for(H=o.child,H!==null&&(H.return=o);H!==null;){var je=H.dependencies;if(je!==null){ae=H.child;for(var De=je.firstContext;De!==null;){if(De.context===k){if(H.tag===1){De=Fi(-1,b&-b),De.tag=2;var Je=H.updateQueue;if(Je!==null){Je=Je.shared;var Nt=Je.pending;Nt===null?De.next=De:(De.next=Nt.next,Nt.next=De),Je.pending=De}}H.lanes|=b,De=H.alternate,De!==null&&(De.lanes|=b),hp(H.return,b,o),je.lanes|=b;break}De=De.next}}else if(H.tag===10)ae=H.type===o.type?null:H.child;else if(H.tag===18){if(ae=H.return,ae===null)throw Error(n(341));ae.lanes|=b,je=ae.alternate,je!==null&&(je.lanes|=b),hp(ae,b,o),ae=H.sibling}else ae=H.child;if(ae!==null)ae.return=H;else for(ae=H;ae!==null;){if(ae===o){ae=null;break}if(H=ae.sibling,H!==null){H.return=ae.return,ae=H;break}ae=ae.return}H=ae}Lr(i,o,L.children,b),o=o.child}return o;case 9:return L=o.type,k=o.pendingProps.children,oc(o,b),L=ya(L),k=k(L),o.flags|=1,Lr(i,o,k,b),o.child;case 14:return k=o.type,L=$a(k,o.pendingProps),L=$a(k.type,L),fj(i,o,k,L,b);case 15:return pj(i,o,o.type,o.pendingProps,b);case 17:return k=o.type,L=o.pendingProps,L=o.elementType===k?L:$a(k,L),sh(i,o),o.tag=1,Wr(k)?(i=!0,Fu(o)):i=!1,oc(o,b),ij(o,k,L),Rp(o,k,L,b),Pp(null,o,k,!0,i,b);case 19:return wj(i,o,b);case 22:return xj(i,o,b)}throw Error(n(156,o.tag))};function Gj(i,o){return pt(i,o)}function gT(i,o,b,k){this.tag=i,this.key=b,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=o,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 wa(i,o,b,k){return new gT(i,o,b,k)}function Xp(i){return i=i.prototype,!(!i||!i.isReactComponent)}function vT(i){if(typeof i=="function")return Xp(i)?1:0;if(i!=null){if(i=i.$$typeof,i===_)return 11;if(i===G)return 14}return 2}function Sl(i,o){var b=i.alternate;return b===null?(b=wa(i.tag,o,i.key,i.mode),b.elementType=i.elementType,b.type=i.type,b.stateNode=i.stateNode,b.alternate=i,i.alternate=b):(b.pendingProps=o,b.type=i.type,b.flags=0,b.subtreeFlags=0,b.deletions=null),b.flags=i.flags&14680064,b.childLanes=i.childLanes,b.lanes=i.lanes,b.child=i.child,b.memoizedProps=i.memoizedProps,b.memoizedState=i.memoizedState,b.updateQueue=i.updateQueue,o=i.dependencies,b.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},b.sibling=i.sibling,b.index=i.index,b.ref=i.ref,b}function mh(i,o,b,k,L,H){var ae=2;if(k=i,typeof i=="function")Xp(i)&&(ae=1);else if(typeof i=="string")ae=5;else e:switch(i){case A:return No(b.children,L,H,o);case I:ae=8,L|=8;break;case $:return i=wa(12,b,o,L|2),i.elementType=$,i.lanes=H,i;case M:return i=wa(13,b,o,L),i.elementType=M,i.lanes=H,i;case q:return i=wa(19,b,o,L),i.elementType=q,i.lanes=H,i;case W:return fh(b,L,H,o);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case T:ae=10;break e;case E:ae=9;break e;case _:ae=11;break e;case G:ae=14;break e;case Z:ae=16,k=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return o=wa(ae,b,o,L),o.elementType=i,o.type=k,o.lanes=H,o}function No(i,o,b,k){return i=wa(7,i,k,o),i.lanes=b,i}function fh(i,o,b,k){return i=wa(22,i,k,o),i.elementType=W,i.lanes=b,i.stateNode={isHidden:!1},i}function Jp(i,o,b){return i=wa(6,i,null,o),i.lanes=b,i}function ex(i,o,b){return o=wa(4,i.children!==null?i.children:[],i.key,o),o.lanes=b,o.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},o}function bT(i,o,b,k,L){this.tag=o,this.containerInfo=i,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=In(0),this.expirationTimes=In(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=In(0),this.identifierPrefix=k,this.onRecoverableError=L,this.mutableSourceEagerHydrationData=null}function tx(i,o,b,k,L,H,ae,je,De){return i=new bT(i,o,b,je,De),o===1?(o=1,H===!0&&(o|=8)):o=0,H=wa(3,null,null,o),i.current=H,H.stateNode=i,H.memoizedState={element:k,isDehydrated:b,cache:null,transitions:null,pendingSuspenseBoundaries:null},fp(H),i}function yT(i,o,b){var k=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:P,key:k==null?null:""+k,children:i,containerInfo:o,implementation:b}}function Kj(i){if(!i)return pl;i=i._reactInternals;e:{if(Is(i)!==i||i.tag!==1)throw Error(n(170));var o=i;do{switch(o.tag){case 3:o=o.stateNode.context;break e;case 1:if(Wr(o.type)){o=o.stateNode.__reactInternalMemoizedMergedChildContext;break e}}o=o.return}while(o!==null);throw Error(n(171))}if(i.tag===1){var b=i.type;if(Wr(b))return Ny(i,b,o)}return o}function Yj(i,o,b,k,L,H,ae,je,De){return i=tx(b,k,!0,i,L,H,ae,je,De),i.context=Kj(null),b=i.current,k=Mr(),L=Nl(b),H=Fi(k,L),H.callback=o??null,vl(b,H,L),i.current.lanes=L,jr(i,L,k),Yr(i,k),i}function ph(i,o,b,k){var L=o.current,H=Mr(),ae=Nl(L);return b=Kj(b),o.context===null?o.context=b:o.pendingContext=b,o=Fi(H,ae),o.payload={element:i},k=k===void 0?null:k,k!==null&&(o.callback=k),i=vl(L,o,ae),i!==null&&(Ua(i,L,ae,H),Wu(i,L,ae)),ae}function xh(i){if(i=i.current,!i.child)return null;switch(i.child.tag){case 5:return i.child.stateNode;default:return i.child.stateNode}}function Zj(i,o){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var b=i.retryLane;i.retryLane=b!==0&&b<o?b:o}}function sx(i,o){Zj(i,o),(i=i.alternate)&&Zj(i,o)}function jT(){return null}var Qj=typeof reportError=="function"?reportError:function(i){console.error(i)};function nx(i){this._internalRoot=i}gh.prototype.render=nx.prototype.render=function(i){var o=this._internalRoot;if(o===null)throw Error(n(409));ph(i,o,null,null)},gh.prototype.unmount=nx.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var o=i.containerInfo;bo(function(){ph(null,i,null,null)}),o[_i]=null}};function gh(i){this._internalRoot=i}gh.prototype.unstable_scheduleHydration=function(i){if(i){var o=ta();i={blockedOn:null,target:i,priority:o};for(var b=0;b<dn.length&&o!==0&&o<dn[b].priority;b++);dn.splice(b,0,i),b===0&&ki(i)}};function rx(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function vh(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function Xj(){}function NT(i,o,b,k,L){if(L){if(typeof k=="function"){var H=k;k=function(){var Je=xh(ae);H.call(Je)}}var ae=Yj(o,k,i,0,null,!1,!1,"",Xj);return i._reactRootContainer=ae,i[_i]=ae.current,ed(i.nodeType===8?i.parentNode:i),bo(),ae}for(;L=i.lastChild;)i.removeChild(L);if(typeof k=="function"){var je=k;k=function(){var Je=xh(De);je.call(Je)}}var De=tx(i,0,!1,null,null,!1,!1,"",Xj);return i._reactRootContainer=De,i[_i]=De.current,ed(i.nodeType===8?i.parentNode:i),bo(function(){ph(o,De,b,k)}),De}function bh(i,o,b,k,L){var H=b._reactRootContainer;if(H){var ae=H;if(typeof L=="function"){var je=L;L=function(){var De=xh(ae);je.call(De)}}ph(o,ae,i,L)}else ae=NT(b,o,i,L,k);return xh(ae)}Tt=function(i){switch(i.tag){case 3:var o=i.stateNode;if(o.current.memoizedState.isDehydrated){var b=En(o.pendingLanes);b!==0&&(xn(o,b|1),Yr(o,as()),(Xs&6)===0&&(mc=as()+500,xl()))}break;case 13:bo(function(){var k=Mi(i,1);if(k!==null){var L=Mr();Ua(k,i,1,L)}}),sx(i,1)}},xs=function(i){if(i.tag===13){var o=Mi(i,134217728);if(o!==null){var b=Mr();Ua(o,i,134217728,b)}sx(i,134217728)}},Vr=function(i){if(i.tag===13){var o=Nl(i),b=Mi(i,o);if(b!==null){var k=Mr();Ua(b,i,o,k)}sx(i,o)}},ta=function(){return qs},ma=function(i,o){var b=qs;try{return qs=i,o()}finally{qs=b}},ie=function(i,o,b){switch(o){case"input":if(Ye(i,b),o=b.name,b.type==="radio"&&o!=null){for(b=i;b.parentNode;)b=b.parentNode;for(b=b.querySelectorAll("input[name="+JSON.stringify(""+o)+'][type="radio"]'),o=0;o<b.length;o++){var k=b[o];if(k!==i&&k.form===i.form){var L=Lu(k);if(!L)throw Error(n(90));ve(k),Ye(k,L)}}}break;case"textarea":xt(i,b);break;case"select":o=b.value,o!=null&&qe(i,!!b.multiple,o,!1)}},it=Yp,st=bo;var wT={usingClientEntryPoint:!1,Events:[nd,ec,Lu,Ne,Ee,Yp]},gd={findFiberByHostInstance:uo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ST={bundleType:gd.bundleType,version:gd.version,rendererPackageName:gd.rendererPackageName,rendererConfig:gd.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:w.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=Ge(i),i===null?null:i.stateNode},findFiberByHostInstance:gd.findFiberByHostInstance||jT,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 yh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yh.isDisabled&&yh.supportsFiber)try{Ws=yh.inject(ST),Qs=yh}catch{}}return Zr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=wT,Zr.createPortal=function(i,o){var b=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!rx(o))throw Error(n(200));return yT(i,o,null,b)},Zr.createRoot=function(i,o){if(!rx(i))throw Error(n(299));var b=!1,k="",L=Qj;return o!=null&&(o.unstable_strictMode===!0&&(b=!0),o.identifierPrefix!==void 0&&(k=o.identifierPrefix),o.onRecoverableError!==void 0&&(L=o.onRecoverableError)),o=tx(i,1,!1,null,null,b,!1,k,L),i[_i]=o.current,ed(i.nodeType===8?i.parentNode:i),new nx(o)},Zr.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var o=i._reactInternals;if(o===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=Ge(o),i=i===null?null:i.stateNode,i},Zr.flushSync=function(i){return bo(i)},Zr.hydrate=function(i,o,b){if(!vh(o))throw Error(n(200));return bh(null,i,o,!0,b)},Zr.hydrateRoot=function(i,o,b){if(!rx(i))throw Error(n(405));var k=b!=null&&b.hydratedSources||null,L=!1,H="",ae=Qj;if(b!=null&&(b.unstable_strictMode===!0&&(L=!0),b.identifierPrefix!==void 0&&(H=b.identifierPrefix),b.onRecoverableError!==void 0&&(ae=b.onRecoverableError)),o=Yj(o,null,i,1,b??null,L,!1,H,ae),i[_i]=o.current,ed(i),k)for(i=0;i<k.length;i++)b=k[i],L=b._getVersion,L=L(b._source),o.mutableSourceEagerHydrationData==null?o.mutableSourceEagerHydrationData=[b,L]:o.mutableSourceEagerHydrationData.push(b,L);return new gh(o)},Zr.render=function(i,o,b){if(!vh(o))throw Error(n(200));return bh(null,i,o,!1,b)},Zr.unmountComponentAtNode=function(i){if(!vh(i))throw Error(n(40));return i._reactRootContainer?(bo(function(){bh(null,null,i,!1,function(){i._reactRootContainer=null,i[_i]=null})}),!0):!1},Zr.unstable_batchedUpdates=Yp,Zr.unstable_renderSubtreeIntoContainer=function(i,o,b,k){if(!vh(b))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return bh(i,o,b,!1,k)},Zr.version="18.3.1-next-f1338f8080-20240426",Zr}var iN;function Dv(){if(iN)return ox.exports;iN=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(),ox.exports=OT(),ox.exports}var lN;function IT(){if(lN)return jh;lN=1;var t=Dv();return jh.createRoot=t.createRoot,jh.hydrateRoot=t.hydrateRoot,jh}var LT=IT();const MT=_m(LT);var ux={exports:{}},hx={};/**
* @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 oN;function FT(){if(oN)return hx;oN=1;var t=Lc();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.useSyncExternalStore,a=t.useRef,l=t.useEffect,c=t.useMemo,d=t.useDebugValue;return hx.useSyncExternalStoreWithSelector=function(h,x,f,m,p){var u=a(null);if(u.current===null){var j={hasValue:!1,value:null};u.current=j}else j=u.current;u=c(function(){function y(R){if(!N){if(N=!0,S=R,R=m(R),p!==void 0&&j.hasValue){var P=j.value;if(p(P,R))return C=P}return C=R}if(P=C,n(S,R))return P;var A=m(R);return p!==void 0&&p(P,A)?(S=R,P):(S=R,C=A)}var N=!1,S,C,w=f===void 0?null:f;return[function(){return y(x())},w===null?void 0:function(){return y(w())}]},[x,f,m,p]);var g=r(h,u[0],u[1]);return l(function(){j.hasValue=!0,j.value=g},[g]),d(g),g},hx}var cN;function BT(){return cN||(cN=1,ux.exports=FT()),ux.exports}var $T=BT();function qT(t){t()}function zT(){let t=null,s=null;return{clear(){t=null,s=null},notify(){qT(()=>{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 dN={notify(){},get:()=>[]};function UT(t,s){let n,r=dN,a=0,l=!1;function c(g){f();const y=r.subscribe(g);let N=!1;return()=>{N||(N=!0,y(),m())}}function d(){r.notify()}function h(){j.onStateChange&&j.onStateChange()}function x(){return l}function f(){a++,n||(n=t.subscribe(h),r=zT())}function m(){a--,n&&a===0&&(n(),n=void 0,r.clear(),r=dN)}function p(){l||(l=!0,f())}function u(){l&&(l=!1,m())}const j={addNestedSub:c,notifyNestedSubs:d,handleChangeWrapper:h,isSubscribed:x,trySubscribe:p,tryUnsubscribe:u,getListeners:()=>r};return j}var VT=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",HT=VT(),WT=()=>typeof navigator<"u"&&navigator.product==="ReactNative",GT=WT(),KT=()=>HT||GT?v.useLayoutEffect:v.useEffect,YT=KT(),mx=Symbol.for("react-redux-context"),fx=typeof globalThis<"u"?globalThis:{};function ZT(){if(!v.createContext)return{};const t=fx[mx]??(fx[mx]=new Map);let s=t.get(v.createContext);return s||(s=v.createContext(null),t.set(v.createContext,s)),s}var Ll=ZT();function QT(t){const{children:s,context:n,serverState:r,store:a}=t,l=v.useMemo(()=>{const h=UT(a);return{store:a,subscription:h,getServerState:r?()=>r:void 0}},[a,r]),c=v.useMemo(()=>a.getState(),[a]);YT(()=>{const{subscription:h}=l;return h.onStateChange=h.notifyNestedSubs,h.trySubscribe(),c!==a.getState()&&h.notifyNestedSubs(),()=>{h.tryUnsubscribe(),h.onStateChange=void 0}},[l,c]);const d=n||Ll;return v.createElement(d.Provider,{value:l},s)}var XT=QT;function Tv(t=Ll){return function(){return v.useContext(t)}}var mC=Tv();function fC(t=Ll){const s=t===Ll?mC:Tv(t),n=()=>{const{store:r}=s();return r};return Object.assign(n,{withTypes:()=>n}),n}var JT=fC();function eP(t=Ll){const s=t===Ll?JT:fC(t),n=()=>s().dispatch;return Object.assign(n,{withTypes:()=>n}),n}var su=eP(),tP=(t,s)=>t===s;function sP(t=Ll){const s=t===Ll?mC:Tv(t),n=(r,a={})=>{const{equalityFn:l=tP}=typeof a=="function"?{equalityFn:a}:a,c=s(),{store:d,subscription:h,getServerState:x}=c;v.useRef(!0);const f=v.useCallback({[r.name](p){return r(p)}}[r.name],[r]),m=$T.useSyncExternalStoreWithSelector(h.addNestedSub,d.getState,x||d.getState,f,l);return v.useDebugValue(m),m};return Object.assign(n,{withTypes:()=>n}),n}var Nn=sP();function br(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 nP=typeof Symbol=="function"&&Symbol.observable||"@@observable",uN=nP,px=()=>Math.random().toString(36).substring(7).split("").join("."),rP={INIT:`@@redux/INIT${px()}`,REPLACE:`@@redux/REPLACE${px()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${px()}`},om=rP;function Pv(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 pC(t,s,n){if(typeof t!="function")throw new Error(br(2));if(typeof s=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(br(0));if(typeof s=="function"&&typeof n>"u"&&(n=s,s=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(br(1));return n(pC)(t,s)}let r=t,a=s,l=new Map,c=l,d=0,h=!1;function x(){c===l&&(c=new Map,l.forEach((y,N)=>{c.set(N,y)}))}function f(){if(h)throw new Error(br(3));return a}function m(y){if(typeof y!="function")throw new Error(br(4));if(h)throw new Error(br(5));let N=!0;x();const S=d++;return c.set(S,y),function(){if(N){if(h)throw new Error(br(6));N=!1,x(),c.delete(S),l=null}}}function p(y){if(!Pv(y))throw new Error(br(7));if(typeof y.type>"u")throw new Error(br(8));if(typeof y.type!="string")throw new Error(br(17));if(h)throw new Error(br(9));try{h=!0,a=r(a,y)}finally{h=!1}return(l=c).forEach(S=>{S()}),y}function u(y){if(typeof y!="function")throw new Error(br(10));r=y,p({type:om.REPLACE})}function j(){const y=m;return{subscribe(N){if(typeof N!="object"||N===null)throw new Error(br(11));function S(){const w=N;w.next&&w.next(f())}return S(),{unsubscribe:y(S)}},[uN](){return this}}}return p({type:om.INIT}),{dispatch:p,subscribe:m,getState:f,replaceReducer:u,[uN]:j}}function aP(t){Object.keys(t).forEach(s=>{const n=t[s];if(typeof n(void 0,{type:om.INIT})>"u")throw new Error(br(12));if(typeof n(void 0,{type:om.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(br(13))})}function iP(t){const s=Object.keys(t),n={};for(let l=0;l<s.length;l++){const c=s[l];typeof t[c]=="function"&&(n[c]=t[c])}const r=Object.keys(n);let a;try{aP(n)}catch(l){a=l}return function(c={},d){if(a)throw a;let h=!1;const x={};for(let f=0;f<r.length;f++){const m=r[f],p=n[m],u=c[m],j=p(u,d);if(typeof j>"u")throw d&&d.type,new Error(br(14));x[m]=j,h=h||j!==u}return h=h||r.length!==Object.keys(c).length,h?x:c}}function cm(...t){return t.length===0?s=>s:t.length===1?t[0]:t.reduce((s,n)=>(...r)=>s(n(...r)))}function lP(...t){return s=>(n,r)=>{const a=s(n,r);let l=()=>{throw new Error(br(15))};const c={getState:a.getState,dispatch:(h,...x)=>l(h,...x)},d=t.map(h=>h(c));return l=cm(...d)(a.dispatch),{...a,dispatch:l}}}function oP(t){return Pv(t)&&"type"in t&&typeof t.type=="string"}var xC=Symbol.for("immer-nothing"),hN=Symbol.for("immer-draftable"),Fr=Symbol.for("immer-state");function Ka(t,...s){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var ca=Object,Rc=ca.getPrototypeOf,dm="constructor",Im="prototype",F0="configurable",um="enumerable",Wh="writable",Vd="value",Zi=t=>!!t&&!!t[Fr];function Qa(t){var s;return t?gC(t)||Mm(t)||!!t[hN]||!!((s=t[dm])!=null&&s[hN])||Fm(t)||Bm(t):!1}var cP=ca[Im][dm].toString(),mN=new WeakMap;function gC(t){if(!t||!_v(t))return!1;const s=Rc(t);if(s===null||s===ca[Im])return!0;const n=ca.hasOwnProperty.call(s,dm)&&s[dm];if(n===Object)return!0;if(!yc(n))return!1;let r=mN.get(n);return r===void 0&&(r=Function.toString.call(n),mN.set(n,r)),r===cP}function Lm(t,s,n=!0){nu(t)===0?(n?Reflect.ownKeys(t):ca.keys(t)).forEach(a=>{s(a,t[a],t)}):t.forEach((r,a)=>s(a,r,t))}function nu(t){const s=t[Fr];return s?s.type_:Mm(t)?1:Fm(t)?2:Bm(t)?3:0}var fN=(t,s,n=nu(t))=>n===2?t.has(s):ca[Im].hasOwnProperty.call(t,s),B0=(t,s,n=nu(t))=>n===2?t.get(s):t[s],hm=(t,s,n,r=nu(t))=>{r===2?t.set(s,n):r===3?t.add(n):t[s]=n};function dP(t,s){return t===s?t!==0||1/t===1/s:t!==t&&s!==s}var Mm=Array.isArray,Fm=t=>t instanceof Map,Bm=t=>t instanceof Set,_v=t=>typeof t=="object",yc=t=>typeof t=="function",xx=t=>typeof t=="boolean";function uP(t){const s=+t;return Number.isInteger(s)&&String(s)===t}var Vi=t=>t.copy_||t.base_,Ov=t=>t.modified_?t.copy_:t.base_;function $0(t,s){if(Fm(t))return new Map(t);if(Bm(t))return new Set(t);if(Mm(t))return Array[Im].slice.call(t);const n=gC(t);if(s===!0||s==="class_only"&&!n){const r=ca.getOwnPropertyDescriptors(t);delete r[Fr];let a=Reflect.ownKeys(r);for(let l=0;l<a.length;l++){const c=a[l],d=r[c];d[Wh]===!1&&(d[Wh]=!0,d[F0]=!0),(d.get||d.set)&&(r[c]={[F0]:!0,[Wh]:!0,[um]:d[um],[Vd]:t[c]})}return ca.create(Rc(t),r)}else{const r=Rc(t);if(r!==null&&n)return{...t};const a=ca.create(r);return ca.assign(a,t)}}function Iv(t,s=!1){return $m(t)||Zi(t)||!Qa(t)||(nu(t)>1&&ca.defineProperties(t,{set:Nh,add:Nh,clear:Nh,delete:Nh}),ca.freeze(t),s&&Lm(t,(n,r)=>{Iv(r,!0)},!1)),t}function hP(){Ka(2)}var Nh={[Vd]:hP};function $m(t){return t===null||!_v(t)?!0:ca.isFrozen(t)}var mm="MapSet",q0="Patches",pN="ArrayMethods",vC={};function Lo(t){const s=vC[t];return s||Ka(0,t),s}var xN=t=>!!vC[t],Hd,bC=()=>Hd,mP=(t,s)=>({drafts_:[],parent_:t,immer_:s,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:xN(mm)?Lo(mm):void 0,arrayMethodsPlugin_:xN(pN)?Lo(pN):void 0});function gN(t,s){s&&(t.patchPlugin_=Lo(q0),t.patches_=[],t.inversePatches_=[],t.patchListener_=s)}function z0(t){U0(t),t.drafts_.forEach(fP),t.drafts_=null}function U0(t){t===Hd&&(Hd=t.parent_)}var vN=t=>Hd=mP(Hd,t);function fP(t){const s=t[Fr];s.type_===0||s.type_===1?s.revoke_():s.revoked_=!0}function bN(t,s){s.unfinalizedDrafts_=s.drafts_.length;const n=s.drafts_[0];if(t!==void 0&&t!==n){n[Fr].modified_&&(z0(s),Ka(4)),Qa(t)&&(t=yN(s,t));const{patchPlugin_:a}=s;a&&a.generateReplacementPatches_(n[Fr].base_,t,s)}else t=yN(s,n);return pP(s,t,!0),z0(s),s.patches_&&s.patchListener_(s.patches_,s.inversePatches_),t!==xC?t:void 0}function yN(t,s){if($m(s))return s;const n=s[Fr];if(!n)return fm(s,t.handledSet_,t);if(!qm(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);NC(n,t)}return n.copy_}function pP(t,s,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&Iv(s,n)}function yC(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var qm=(t,s)=>t.scope_===s,xP=[];function jC(t,s,n,r){const a=Vi(t),l=t.type_;if(r!==void 0&&B0(a,r,l)===s){hm(a,r,n,l);return}if(!t.draftLocations_){const d=t.draftLocations_=new Map;Lm(a,(h,x)=>{if(Zi(x)){const f=d.get(x)||[];f.push(h),d.set(x,f)}})}const c=t.draftLocations_.get(s)??xP;for(const d of c)hm(a,d,n,l)}function gP(t,s,n){t.callbacks_.push(function(a){var d;const l=s;if(!l||!qm(l,a))return;(d=a.mapSetPlugin_)==null||d.fixSetContents(l);const c=Ov(l);jC(t,l.draft_??l,c,n),NC(l,a)})}function NC(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 l=a.getPath(t);l&&a.generatePatches_(t,l,s)}yC(t)}}function vP(t,s,n){const{scope_:r}=t;if(Zi(n)){const a=n[Fr];qm(a,r)&&a.callbacks_.push(function(){Gh(t);const c=Ov(a);jC(t,n,c,s)})}else Qa(n)&&t.callbacks_.push(function(){const l=Vi(t);t.type_===3?l.has(n)&&fm(n,r.handledSet_,r):B0(l,s,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(s)??!1)===!0&&t.copy_&&fm(B0(t.copy_,s,t.type_),r.handledSet_,r)})}function fm(t,s,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Zi(t)||s.has(t)||!Qa(t)||$m(t)||(s.add(t),Lm(t,(r,a)=>{if(Zi(a)){const l=a[Fr];if(qm(l,n)){const c=Ov(l);hm(t,r,c,t.type_),yC(l)}}else Qa(a)&&fm(a,s,n)})),t}function bP(t,s){const n=Mm(t),r={type_:n?1:0,scope_:s?s.scope_:bC(),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,l=pm;n&&(a=[r],l=Wd);const{revoke:c,proxy:d}=Proxy.revocable(a,l);return r.draft_=d,r.revoke_=c,[d,r]}var pm={get(t,s){if(s===Fr)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=Vi(t);if(!fN(a,s,t.type_))return yP(t,a,s);const l=a[s];if(t.finalized_||!Qa(l)||r&&t.operationMethod&&(n!=null&&n.isMutatingArrayMethod(t.operationMethod))&&uP(s))return l;if(l===gx(t.base_,s)){Gh(t);const c=t.type_===1?+s:s,d=H0(t.scope_,l,t,c);return t.copy_[c]=d}return l},has(t,s){return s in Vi(t)},ownKeys(t){return Reflect.ownKeys(Vi(t))},set(t,s,n){const r=wC(Vi(t),s);if(r!=null&&r.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const a=gx(Vi(t),s),l=a==null?void 0:a[Fr];if(l&&l.base_===n)return t.copy_[s]=n,t.assigned_.set(s,!1),!0;if(dP(n,a)&&(n!==void 0||fN(t.base_,s,t.type_)))return!0;Gh(t),V0(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),vP(t,s,n)),!0},deleteProperty(t,s){return Gh(t),gx(t.base_,s)!==void 0||s in t.base_?(t.assigned_.set(s,!1),V0(t)):t.assigned_.delete(s),t.copy_&&delete t.copy_[s],!0},getOwnPropertyDescriptor(t,s){const n=Vi(t),r=Reflect.getOwnPropertyDescriptor(n,s);return r&&{[Wh]:!0,[F0]:t.type_!==1||s!=="length",[um]:r[um],[Vd]:n[s]}},defineProperty(){Ka(11)},getPrototypeOf(t){return Rc(t.base_)},setPrototypeOf(){Ka(12)}},Wd={};for(let t in pm){let s=pm[t];Wd[t]=function(){const n=arguments;return n[0]=n[0][0],s.apply(this,n)}}Wd.deleteProperty=function(t,s){return Wd.set.call(this,t,s,void 0)};Wd.set=function(t,s,n){return pm.set.call(this,t[0],s,n,t[0])};function gx(t,s){const n=t[Fr];return(n?Vi(n):t)[s]}function yP(t,s,n){var a;const r=wC(s,n);return r?Vd in r?r[Vd]:(a=r.get)==null?void 0:a.call(t.draft_):void 0}function wC(t,s){if(!(s in t))return;let n=Rc(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,s);if(r)return r;n=Rc(n)}}function V0(t){t.modified_||(t.modified_=!0,t.parent_&&V0(t.parent_))}function Gh(t){t.copy_||(t.assigned_=new Map,t.copy_=$0(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var jP=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(s,n,r)=>{if(yc(s)&&!yc(n)){const l=n;n=s;const c=this;return function(h=l,...x){return c.produce(h,f=>n.call(this,f,...x))}}yc(n)||Ka(6),r!==void 0&&!yc(r)&&Ka(7);let a;if(Qa(s)){const l=vN(this),c=H0(l,s,void 0);let d=!0;try{a=n(c),d=!1}finally{d?z0(l):U0(l)}return gN(l,r),bN(a,l)}else if(!s||!_v(s)){if(a=n(s),a===void 0&&(a=s),a===xC&&(a=void 0),this.autoFreeze_&&Iv(a,!0),r){const l=[],c=[];Lo(q0).generateReplacementPatches_(s,a,{patches_:l,inversePatches_:c}),r(l,c)}return a}else Ka(1,s)},this.produceWithPatches=(s,n)=>{if(yc(s))return(c,...d)=>this.produceWithPatches(c,h=>s(h,...d));let r,a;return[this.produce(s,n,(c,d)=>{r=c,a=d}),r,a]},xx(t==null?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),xx(t==null?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),xx(t==null?void 0:t.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){Qa(t)||Ka(8),Zi(t)&&(t=NP(t));const s=vN(this),n=H0(s,t,void 0);return n[Fr].isManual_=!0,U0(s),n}finishDraft(t,s){const n=t&&t[Fr];(!n||!n.isManual_)&&Ka(9);const{scope_:r}=n;return gN(r,s),bN(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=Lo(q0).applyPatches_;return Zi(t)?r(t,s):this.produce(t,a=>r(a,s))}};function H0(t,s,n,r){const[a,l]=Fm(s)?Lo(mm).proxyMap_(s,n):Bm(s)?Lo(mm).proxySet_(s,n):bP(s,n);return((n==null?void 0:n.scope_)??bC()).drafts_.push(a),l.callbacks_=(n==null?void 0:n.callbacks_)??[],l.key_=r,n&&r!==void 0?gP(n,l,r):l.callbacks_.push(function(h){var f;(f=h.mapSetPlugin_)==null||f.fixSetContents(l);const{patchPlugin_:x}=h;l.modified_&&x&&x.generatePatches_(l,[],h)}),a}function NP(t){return Zi(t)||Ka(10,t),SC(t)}function SC(t){if(!Qa(t)||$m(t))return t;const s=t[Fr];let n,r=!0;if(s){if(!s.modified_)return s.base_;s.finalized_=!0,n=$0(t,s.scope_.immer_.useStrictShallowCopy_),r=s.scope_.immer_.shouldUseStrictIteration()}else n=$0(t,!0);return Lm(n,(a,l)=>{hm(n,a,SC(l))},r),s&&(s.finalized_=!1),n}var wP=new jP,CC=wP.produce;function AC(t){return({dispatch:n,getState:r})=>a=>l=>typeof l=="function"?l(n,r,t):a(l)}var SP=AC(),CP=AC,AP=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?cm:cm.apply(null,arguments)},kP=t=>t&&typeof t.match=="function";function Bd(t,s){function n(...r){if(s){let a=s(...r);if(!a)throw new Error(Gi(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=>oP(r)&&r.type===t,n}var kC=class Td extends Array{constructor(...s){super(...s),Object.setPrototypeOf(this,Td.prototype)}static get[Symbol.species](){return Td}concat(...s){return super.concat.apply(this,s)}prepend(...s){return s.length===1&&Array.isArray(s[0])?new Td(...s[0].concat(this)):new Td(...s.concat(this))}};function jN(t){return Qa(t)?CC(t,()=>{}):t}function wh(t,s,n){return t.has(s)?t.get(s):t.set(s,n(s)).get(s)}function RP(t){return typeof t=="boolean"}var EP=()=>function(s){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:a=!0,actionCreatorCheck:l=!0}=s??{};let c=new kC;return n&&(RP(n)?c.push(SP):c.push(CP(n.extraArgument))),c},DP="RTK_autoBatch",NN=t=>s=>{setTimeout(s,t)},TP=(t={type:"raf"})=>s=>(...n)=>{const r=s(...n);let a=!0,l=!1,c=!1;const d=new Set,h=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:NN(10):t.type==="callback"?t.queueNotification:NN(t.timeout),x=()=>{c=!1,l&&(l=!1,d.forEach(f=>f()))};return Object.assign({},r,{subscribe(f){const m=()=>a&&f(),p=r.subscribe(m);return d.add(f),()=>{p(),d.delete(f)}},dispatch(f){var m;try{return a=!((m=f==null?void 0:f.meta)!=null&&m[DP]),l=!a,l&&(c||(c=!0,h(x))),r.dispatch(f)}finally{a=!0}}})},PP=t=>function(n){const{autoBatch:r=!0}=n??{};let a=new kC(t);return r&&a.push(TP(typeof r=="object"?r:void 0)),a};function _P(t){const s=EP(),{reducer:n=void 0,middleware:r,devTools:a=!0,preloadedState:l=void 0,enhancers:c=void 0}=t||{};let d;if(typeof n=="function")d=n;else if(Pv(n))d=iP(n);else throw new Error(Gi(1));let h;typeof r=="function"?h=r(s):h=s();let x=cm;a&&(x=AP({trace:!1,...typeof a=="object"&&a}));const f=lP(...h),m=PP(f);let p=typeof c=="function"?c(m):m();const u=x(...p);return pC(d,l,u)}function RC(t){const s={},n=[];let r;const a={addCase(l,c){const d=typeof l=="string"?l:l.type;if(!d)throw new Error(Gi(28));if(d in s)throw new Error(Gi(29));return s[d]=c,a},addAsyncThunk(l,c){return c.pending&&(s[l.pending.type]=c.pending),c.rejected&&(s[l.rejected.type]=c.rejected),c.fulfilled&&(s[l.fulfilled.type]=c.fulfilled),c.settled&&n.push({matcher:l.settled,reducer:c.settled}),a},addMatcher(l,c){return n.push({matcher:l,reducer:c}),a},addDefaultCase(l){return r=l,a}};return t(a),[s,n,r]}function OP(t){return typeof t=="function"}function IP(t,s){let[n,r,a]=RC(s),l;if(OP(t))l=()=>jN(t());else{const d=jN(t);l=()=>d}function c(d=l(),h){let x=[n[h.type],...r.filter(({matcher:f})=>f(h)).map(({reducer:f})=>f)];return x.filter(f=>!!f).length===0&&(x=[a]),x.reduce((f,m)=>{if(m)if(Zi(f)){const u=m(f,h);return u===void 0?f:u}else{if(Qa(f))return CC(f,p=>m(p,h));{const p=m(f,h);if(p===void 0){if(f===null)return f;throw Error("A case reducer on a non-draftable value must not return undefined")}return p}}return f},d)}return c.getInitialState=l,c}var LP=(t,s)=>kP(t)?t.match(s):t(s);function MP(...t){return s=>t.some(n=>LP(n,s))}var FP="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",BP=(t=21)=>{let s="",n=t;for(;n--;)s+=FP[Math.random()*64|0];return s},$P=["name","message","stack","code"],vx=class{constructor(t,s){ax(this,"_type");this.payload=t,this.meta=s}},wN=class{constructor(t,s){ax(this,"_type");this.payload=t,this.meta=s}},qP=t=>{if(typeof t=="object"&&t!==null){const s={};for(const n of $P)typeof t[n]=="string"&&(s[n]=t[n]);return s}return{message:String(t)}},SN="External signal was aborted",zP=(()=>{function t(s,n,r){const a=Bd(s+"/fulfilled",(h,x,f,m)=>({payload:h,meta:{...m||{},arg:f,requestId:x,requestStatus:"fulfilled"}})),l=Bd(s+"/pending",(h,x,f)=>({payload:void 0,meta:{...f||{},arg:x,requestId:h,requestStatus:"pending"}})),c=Bd(s+"/rejected",(h,x,f,m,p)=>({payload:m,error:(r&&r.serializeError||qP)(h||"Rejected"),meta:{...p||{},arg:f,requestId:x,rejectedWithValue:!!m,requestStatus:"rejected",aborted:(h==null?void 0:h.name)==="AbortError",condition:(h==null?void 0:h.name)==="ConditionError"}}));function d(h,{signal:x}={}){return(f,m,p)=>{const u=r!=null&&r.idGenerator?r.idGenerator(h):BP(),j=new AbortController;let g,y;function N(C){y=C,j.abort()}x&&(x.aborted?N(SN):x.addEventListener("abort",()=>N(SN),{once:!0}));const S=(async function(){var R,P;let C;try{let A=(R=r==null?void 0:r.condition)==null?void 0:R.call(r,h,{getState:m,extra:p});if(VP(A)&&(A=await A),A===!1||j.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const I=new Promise(($,T)=>{g=()=>{T({name:"AbortError",message:y||"Aborted"})},j.signal.addEventListener("abort",g,{once:!0})});f(l(u,h,(P=r==null?void 0:r.getPendingMeta)==null?void 0:P.call(r,{requestId:u,arg:h},{getState:m,extra:p}))),C=await Promise.race([I,Promise.resolve(n(h,{dispatch:f,getState:m,extra:p,requestId:u,signal:j.signal,abort:N,rejectWithValue:($,T)=>new vx($,T),fulfillWithValue:($,T)=>new wN($,T)})).then($=>{if($ instanceof vx)throw $;return $ instanceof wN?a($.payload,u,h,$.meta):a($,u,h)})])}catch(A){C=A instanceof vx?c(null,u,h,A.payload,A.meta):c(A,u,h)}finally{g&&j.signal.removeEventListener("abort",g)}return r&&!r.dispatchConditionRejection&&c.match(C)&&C.meta.condition||f(C),C})();return Object.assign(S,{abort:N,requestId:u,arg:h,unwrap(){return S.then(UP)}})}}return Object.assign(d,{pending:l,rejected:c,fulfilled:a,settled:MP(c,a),typePrefix:s})}return t.withTypes=()=>t,t})();function UP(t){if(t.meta&&t.meta.rejectedWithValue)throw t.payload;if(t.error)throw t.error;return t.payload}function VP(t){return t!==null&&typeof t=="object"&&typeof t.then=="function"}var HP=Symbol.for("rtk-slice-createasyncthunk");function WP(t,s){return`${t}/${s}`}function GP({creators:t}={}){var n;const s=(n=t==null?void 0:t.asyncThunk)==null?void 0:n[HP];return function(a){const{name:l,reducerPath:c=l}=a;if(!l)throw new Error(Gi(11));const d=(typeof a.reducers=="function"?a.reducers(YP()):a.reducers)||{},h=Object.keys(d),x={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},f={addCase(w,R){const P=typeof w=="string"?w:w.type;if(!P)throw new Error(Gi(12));if(P in x.sliceCaseReducersByType)throw new Error(Gi(13));return x.sliceCaseReducersByType[P]=R,f},addMatcher(w,R){return x.sliceMatchers.push({matcher:w,reducer:R}),f},exposeAction(w,R){return x.actionCreators[w]=R,f},exposeCaseReducer(w,R){return x.sliceCaseReducersByName[w]=R,f}};h.forEach(w=>{const R=d[w],P={reducerName:w,type:WP(l,w),createNotation:typeof a.reducers=="function"};QP(R)?JP(P,R,f,s):ZP(P,R,f)});function m(){const[w={},R=[],P=void 0]=typeof a.extraReducers=="function"?RC(a.extraReducers):[a.extraReducers],A={...w,...x.sliceCaseReducersByType};return IP(a.initialState,I=>{for(let $ in A)I.addCase($,A[$]);for(let $ of x.sliceMatchers)I.addMatcher($.matcher,$.reducer);for(let $ of R)I.addMatcher($.matcher,$.reducer);P&&I.addDefaultCase(P)})}const p=w=>w,u=new Map,j=new WeakMap;let g;function y(w,R){return g||(g=m()),g(w,R)}function N(){return g||(g=m()),g.getInitialState()}function S(w,R=!1){function P(I){let $=I[w];return typeof $>"u"&&R&&($=wh(j,P,N)),$}function A(I=p){const $=wh(u,R,()=>new WeakMap);return wh($,I,()=>{const T={};for(const[E,_]of Object.entries(a.selectors??{}))T[E]=KP(_,I,()=>wh(j,I,N),R);return T})}return{reducerPath:w,getSelectors:A,get selectors(){return A(P)},selectSlice:P}}const C={name:l,reducer:y,actions:x.actionCreators,caseReducers:x.sliceCaseReducersByName,getInitialState:N,...S(c),injectInto(w,{reducerPath:R,...P}={}){const A=R??c;return w.inject({reducerPath:A,reducer:y},P),{...C,...S(A,!0)}}};return C}}function KP(t,s,n,r){function a(l,...c){let d=s(l);return typeof d>"u"&&r&&(d=n()),t(d,...c)}return a.unwrapped=t,a}var EC=GP();function YP(){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 ZP({type:t,reducerName:s,createNotation:n},r,a){let l,c;if("reducer"in r){if(n&&!XP(r))throw new Error(Gi(17));l=r.reducer,c=r.prepare}else l=r;a.addCase(t,l).exposeCaseReducer(s,l).exposeAction(s,c?Bd(t,c):Bd(t))}function QP(t){return t._reducerDefinitionType==="asyncThunk"}function XP(t){return t._reducerDefinitionType==="reducerWithPrepare"}function JP({type:t,reducerName:s},n,r,a){if(!a)throw new Error(Gi(18));const{payloadCreator:l,fulfilled:c,pending:d,rejected:h,settled:x,options:f}=n,m=a(t,l,f);r.exposeAction(s,m),c&&r.addCase(m.fulfilled,c),d&&r.addCase(m.pending,d),h&&r.addCase(m.rejected,h),x&&r.addMatcher(m.settled,x),r.exposeCaseReducer(s,{fulfilled:c||Sh,pending:d||Sh,rejected:h||Sh,settled:x||Sh})}function Sh(){}function Gi(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 cr={};/*! Axios v1.13.6 Copyright (c) 2026 Matt Zabriskie and contributors */var bx,CN;function e_(){if(CN)return bx;CN=1;function t(J,te){return function(){return J.apply(te,arguments)}}const{toString:s}=Object.prototype,{getPrototypeOf:n}=Object,{iterator:r,toStringTag:a}=Symbol,l=(J=>te=>{const ue=s.call(te);return J[ue]||(J[ue]=ue.slice(8,-1).toLowerCase())})(Object.create(null)),c=J=>(J=J.toLowerCase(),te=>l(te)===J),d=J=>te=>typeof te===J,{isArray:h}=Array,x=d("undefined");function f(J){return J!==null&&!x(J)&&J.constructor!==null&&!x(J.constructor)&&j(J.constructor.isBuffer)&&J.constructor.isBuffer(J)}const m=c("ArrayBuffer");function p(J){let te;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?te=ArrayBuffer.isView(J):te=J&&J.buffer&&m(J.buffer),te}const u=d("string"),j=d("function"),g=d("number"),y=J=>J!==null&&typeof J=="object",N=J=>J===!0||J===!1,S=J=>{if(l(J)!=="object")return!1;const te=n(J);return(te===null||te===Object.prototype||Object.getPrototypeOf(te)===null)&&!(a in J)&&!(r in J)},C=J=>{if(!y(J)||f(J))return!1;try{return Object.keys(J).length===0&&Object.getPrototypeOf(J)===Object.prototype}catch{return!1}},w=c("Date"),R=c("File"),P=J=>!!(J&&typeof J.uri<"u"),A=J=>J&&typeof J.getParts<"u",I=c("Blob"),$=c("FileList"),T=J=>y(J)&&j(J.pipe);function E(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof Eo<"u"?Eo:{}}const _=E(),M=typeof _.FormData<"u"?_.FormData:void 0,q=J=>{let te;return J&&(M&&J instanceof M||j(J.append)&&((te=l(J))==="formdata"||te==="object"&&j(J.toString)&&J.toString()==="[object FormData]"))},G=c("URLSearchParams"),[Z,W,z,F]=["ReadableStream","Request","Response","Headers"].map(c),B=J=>J.trim?J.trim():J.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function D(J,te,{allOwnKeys:ue=!1}={}){if(J===null||typeof J>"u")return;let xe,we;if(typeof J!="object"&&(J=[J]),h(J))for(xe=0,we=J.length;xe<we;xe++)te.call(null,J[xe],xe,J);else{if(f(J))return;const $e=ue?Object.getOwnPropertyNames(J):Object.keys(J),Be=$e.length;let lt;for(xe=0;xe<Be;xe++)lt=$e[xe],te.call(null,J[lt],lt,J)}}function O(J,te){if(f(J))return null;te=te.toLowerCase();const ue=Object.keys(J);let xe=ue.length,we;for(;xe-- >0;)if(we=ue[xe],te===we.toLowerCase())return we;return null}const V=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:Eo,K=J=>!x(J)&&J!==V;function Y(){const{caseless:J,skipUndefined:te}=K(this)&&this||{},ue={},xe=(we,$e)=>{if($e==="__proto__"||$e==="constructor"||$e==="prototype")return;const Be=J&&O(ue,$e)||$e;S(ue[Be])&&S(we)?ue[Be]=Y(ue[Be],we):S(we)?ue[Be]=Y({},we):h(we)?ue[Be]=we.slice():(!te||!x(we))&&(ue[Be]=we)};for(let we=0,$e=arguments.length;we<$e;we++)arguments[we]&&D(arguments[we],xe);return ue}const U=(J,te,ue,{allOwnKeys:xe}={})=>(D(te,(we,$e)=>{ue&&j(we)?Object.defineProperty(J,$e,{value:t(we,ue),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(J,$e,{value:we,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:xe}),J),X=J=>(J.charCodeAt(0)===65279&&(J=J.slice(1)),J),ne=(J,te,ue,xe)=>{J.prototype=Object.create(te.prototype,xe),Object.defineProperty(J.prototype,"constructor",{value:J,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(J,"super",{value:te.prototype}),ue&&Object.assign(J.prototype,ue)},oe=(J,te,ue,xe)=>{let we,$e,Be;const lt={};if(te=te||{},J==null)return te;do{for(we=Object.getOwnPropertyNames(J),$e=we.length;$e-- >0;)Be=we[$e],(!xe||xe(Be,J,te))&&!lt[Be]&&(te[Be]=J[Be],lt[Be]=!0);J=ue!==!1&&n(J)}while(J&&(!ue||ue(J,te))&&J!==Object.prototype);return te},re=(J,te,ue)=>{J=String(J),(ue===void 0||ue>J.length)&&(ue=J.length),ue-=te.length;const xe=J.indexOf(te,ue);return xe!==-1&&xe===ue},ge=J=>{if(!J)return null;if(h(J))return J;let te=J.length;if(!g(te))return null;const ue=new Array(te);for(;te-- >0;)ue[te]=J[te];return ue},ve=(J=>te=>J&&te instanceof J)(typeof Uint8Array<"u"&&n(Uint8Array)),Se=(J,te)=>{const xe=(J&&J[r]).call(J);let we;for(;(we=xe.next())&&!we.done;){const $e=we.value;te.call(J,$e[0],$e[1])}},We=(J,te)=>{let ue;const xe=[];for(;(ue=J.exec(te))!==null;)xe.push(ue);return xe},Ce=c("HTMLFormElement"),fe=J=>J.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(ue,xe,we){return xe.toUpperCase()+we}),Ye=(({hasOwnProperty:J})=>(te,ue)=>J.call(te,ue))(Object.prototype),be=c("RegExp"),_e=(J,te)=>{const ue=Object.getOwnPropertyDescriptors(J),xe={};D(ue,(we,$e)=>{let Be;(Be=te(we,$e,J))!==!1&&(xe[$e]=Be||we)}),Object.defineProperties(J,xe)},ke=J=>{_e(J,(te,ue)=>{if(j(J)&&["arguments","caller","callee"].indexOf(ue)!==-1)return!1;const xe=J[ue];if(j(xe)){if(te.enumerable=!1,"writable"in te){te.writable=!1;return}te.set||(te.set=()=>{throw Error("Can not rewrite read-only method '"+ue+"'")})}})},qe=(J,te)=>{const ue={},xe=we=>{we.forEach($e=>{ue[$e]=!0})};return h(J)?xe(J):xe(String(J).split(te)),ue},Ve=()=>{},dt=(J,te)=>J!=null&&Number.isFinite(J=+J)?J:te;function xt(J){return!!(J&&j(J.append)&&J[a]==="FormData"&&J[r])}const ye=J=>{const te=new Array(10),ue=(xe,we)=>{if(y(xe)){if(te.indexOf(xe)>=0)return;if(f(xe))return xe;if(!("toJSON"in xe)){te[we]=xe;const $e=h(xe)?[]:{};return D(xe,(Be,lt)=>{const Jt=ue(Be,we+1);!x(Jt)&&($e[lt]=Jt)}),te[we]=void 0,$e}}return xe};return ue(J,0)},le=c("AsyncFunction"),Qe=J=>J&&(y(J)||j(J))&&j(J.then)&&j(J.catch),rt=((J,te)=>J?setImmediate:te?((ue,xe)=>(V.addEventListener("message",({source:we,data:$e})=>{we===V&&$e===ue&&xe.length&&xe.shift()()},!1),we=>{xe.push(we),V.postMessage(ue,"*")}))(`axios@${Math.random()}`,[]):ue=>setTimeout(ue))(typeof setImmediate=="function",j(V.postMessage)),Kt=typeof queueMicrotask<"u"?queueMicrotask.bind(V):typeof process<"u"&&process.nextTick||rt;var Re={isArray:h,isArrayBuffer:m,isBuffer:f,isFormData:q,isArrayBufferView:p,isString:u,isNumber:g,isBoolean:N,isObject:y,isPlainObject:S,isEmptyObject:C,isReadableStream:Z,isRequest:W,isResponse:z,isHeaders:F,isUndefined:x,isDate:w,isFile:R,isReactNativeBlob:P,isReactNative:A,isBlob:I,isRegExp:be,isFunction:j,isStream:T,isURLSearchParams:G,isTypedArray:ve,isFileList:$,forEach:D,merge:Y,extend:U,trim:B,stripBOM:X,inherits:ne,toFlatObject:oe,kindOf:l,kindOfTest:c,endsWith:re,toArray:ge,forEachEntry:Se,matchAll:We,isHTMLForm:Ce,hasOwnProperty:Ye,hasOwnProp:Ye,reduceDescriptors:_e,freezeMethods:ke,toObjectSet:qe,toCamelCase:fe,noop:Ve,toFiniteNumber:dt,findKey:O,global:V,isContextDefined:K,isSpecCompliantForm:xt,toJSONObject:ye,isAsyncFn:le,isThenable:Qe,setImmediate:rt,asap:Kt,isIterable:J=>J!=null&&j(J[r])};class Qt extends Error{static from(te,ue,xe,we,$e,Be){const lt=new Qt(te.message,ue||te.code,xe,we,$e);return lt.cause=te,lt.name=te.name,te.status!=null&&lt.status==null&&(lt.status=te.status),Be&&Object.assign(lt,Be),lt}constructor(te,ue,xe,we,$e){super(te),Object.defineProperty(this,"message",{value:te,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,ue&&(this.code=ue),xe&&(this.config=xe),we&&(this.request=we),$e&&(this.response=$e,this.status=$e.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:Re.toJSONObject(this.config),code:this.code,status:this.status}}}Qt.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",Qt.ERR_BAD_OPTION="ERR_BAD_OPTION",Qt.ECONNABORTED="ECONNABORTED",Qt.ETIMEDOUT="ETIMEDOUT",Qt.ERR_NETWORK="ERR_NETWORK",Qt.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",Qt.ERR_DEPRECATED="ERR_DEPRECATED",Qt.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",Qt.ERR_BAD_REQUEST="ERR_BAD_REQUEST",Qt.ERR_CANCELED="ERR_CANCELED",Qt.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",Qt.ERR_INVALID_URL="ERR_INVALID_URL";var qt=Qt,ws=null;function _s(J){return Re.isPlainObject(J)||Re.isArray(J)}function ns(J){return Re.endsWith(J,"[]")?J.slice(0,-2):J}function Cs(J,te,ue){return J?J.concat(te).map(function(we,$e){return we=ns(we),!ue&&$e?"["+we+"]":we}).join(ue?".":""):te}function Bs(J){return Re.isArray(J)&&!J.some(_s)}const Ft=Re.toFlatObject(Re,{},null,function(te){return/^is[A-Z]/.test(te)});function ie(J,te,ue){if(!Re.isObject(J))throw new TypeError("target must be an object");te=te||new FormData,ue=Re.toFlatObject(ue,{metaTokens:!0,dots:!1,indexes:!1},!1,function(bs,es){return!Re.isUndefined(es[bs])});const xe=ue.metaTokens,we=ue.visitor||Et,$e=ue.dots,Be=ue.indexes,Jt=(ue.Blob||typeof Blob<"u"&&Blob)&&Re.isSpecCompliantForm(te);if(!Re.isFunction(we))throw new TypeError("visitor must be a function");function Mt(Ot){if(Ot===null)return"";if(Re.isDate(Ot))return Ot.toISOString();if(Re.isBoolean(Ot))return Ot.toString();if(!Jt&&Re.isBlob(Ot))throw new qt("Blob is not supported. Use a Buffer instead.");return Re.isArrayBuffer(Ot)||Re.isTypedArray(Ot)?Jt&&typeof Blob=="function"?new Blob([Ot]):Buffer.from(Ot):Ot}function Et(Ot,bs,es){let Sn=Ot;if(Re.isReactNative(te)&&Re.isReactNativeBlob(Ot))return te.append(Cs(es,bs,$e),Mt(Ot)),!1;if(Ot&&!es&&typeof Ot=="object"){if(Re.endsWith(bs,"{}"))bs=xe?bs:bs.slice(0,-2),Ot=JSON.stringify(Ot);else if(Re.isArray(Ot)&&Bs(Ot)||(Re.isFileList(Ot)||Re.endsWith(bs,"[]"))&&(Sn=Re.toArray(Ot)))return bs=ns(bs),Sn.forEach(function(Dn,nr){!(Re.isUndefined(Dn)||Dn===null)&&te.append(Be===!0?Cs([bs],nr,$e):Be===null?bs:bs+"[]",Mt(Dn))}),!1}return _s(Ot)?!0:(te.append(Cs(es,bs,$e),Mt(Ot)),!1)}const gs=[],tn=Object.assign(Ft,{defaultVisitor:Et,convertValue:Mt,isVisitable:_s});function Hn(Ot,bs){if(!Re.isUndefined(Ot)){if(gs.indexOf(Ot)!==-1)throw Error("Circular reference detected in "+bs.join("."));gs.push(Ot),Re.forEach(Ot,function(Sn,xr){(!(Re.isUndefined(Sn)||Sn===null)&&we.call(te,Sn,Re.isString(xr)?xr.trim():xr,bs,tn))===!0&&Hn(Sn,bs?bs.concat(xr):[xr])}),gs.pop()}}if(!Re.isObject(J))throw new TypeError("data must be an object");return Hn(J),te}function Fe(J){const te={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(J).replace(/[!'()~]|%20|%00/g,function(xe){return te[xe]})}function Q(J,te){this._pairs=[],J&&ie(J,this,te)}const pe=Q.prototype;pe.append=function(te,ue){this._pairs.push([te,ue])},pe.toString=function(te){const ue=te?function(xe){return te.call(this,xe,Fe)}:Fe;return this._pairs.map(function(we){return ue(we[0])+"="+ue(we[1])},"").join("&")};function Ne(J){return encodeURIComponent(J).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Ee(J,te,ue){if(!te)return J;const xe=ue&&ue.encode||Ne,we=Re.isFunction(ue)?{serialize:ue}:ue,$e=we&&we.serialize;let Be;if($e?Be=$e(te,we):Be=Re.isURLSearchParams(te)?te.toString():new Q(te,we).toString(xe),Be){const lt=J.indexOf("#");lt!==-1&&(J=J.slice(0,lt)),J+=(J.indexOf("?")===-1?"?":"&")+Be}return J}class it{constructor(){this.handlers=[]}use(te,ue,xe){return this.handlers.push({fulfilled:te,rejected:ue,synchronous:xe?xe.synchronous:!1,runWhen:xe?xe.runWhen:null}),this.handlers.length-1}eject(te){this.handlers[te]&&(this.handlers[te]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(te){Re.forEach(this.handlers,function(xe){xe!==null&&te(xe)})}}var st=it,bt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Ue=typeof URLSearchParams<"u"?URLSearchParams:Q,Lt=typeof FormData<"u"?FormData:null,ut=typeof Blob<"u"?Blob:null,yt={isBrowser:!0,classes:{URLSearchParams:Ue,FormData:Lt,Blob:ut},protocols:["http","https","file","blob","url","data"]};const kt=typeof window<"u"&&typeof document<"u",Ie=typeof navigator=="object"&&navigator||void 0,_t=kt&&(!Ie||["ReactNative","NativeScript","NS"].indexOf(Ie.product)<0),ht=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",zt=kt&&window.location.href||"http://localhost";var rs=Object.freeze({__proto__:null,hasBrowserEnv:kt,hasStandardBrowserWebWorkerEnv:ht,hasStandardBrowserEnv:_t,navigator:Ie,origin:zt}),Yt={...rs,...yt};function Os(J,te){return ie(J,new Yt.classes.URLSearchParams,{visitor:function(ue,xe,we,$e){return Yt.isNode&&Re.isBuffer(ue)?(this.append(xe,ue.toString("base64")),!1):$e.defaultVisitor.apply(this,arguments)},...te})}function Is(J){return Re.matchAll(/\w+|\[(\w*)]/g,J).map(te=>te[0]==="[]"?"":te[1]||te[0])}function zs(J){const te={},ue=Object.keys(J);let xe;const we=ue.length;let $e;for(xe=0;xe<we;xe++)$e=ue[xe],te[$e]=J[$e];return te}function en(J){function te(ue,xe,we,$e){let Be=ue[$e++];if(Be==="__proto__")return!0;const lt=Number.isFinite(+Be),Jt=$e>=ue.length;return Be=!Be&&Re.isArray(we)?we.length:Be,Jt?(Re.hasOwnProp(we,Be)?we[Be]=[we[Be],xe]:we[Be]=xe,!lt):((!we[Be]||!Re.isObject(we[Be]))&&(we[Be]=[]),te(ue,xe,we[Be],$e)&&Re.isArray(we[Be])&&(we[Be]=zs(we[Be])),!lt)}if(Re.isFormData(J)&&Re.isFunction(J.entries)){const ue={};return Re.forEachEntry(J,(xe,we)=>{te(Is(xe),we,ue,0)}),ue}return null}function he(J,te,ue){if(Re.isString(J))try{return(te||JSON.parse)(J),Re.trim(J)}catch(xe){if(xe.name!=="SyntaxError")throw xe}return(ue||JSON.stringify)(J)}const Ge={transitional:bt,adapter:["xhr","http","fetch"],transformRequest:[function(te,ue){const xe=ue.getContentType()||"",we=xe.indexOf("application/json")>-1,$e=Re.isObject(te);if($e&&Re.isHTMLForm(te)&&(te=new FormData(te)),Re.isFormData(te))return we?JSON.stringify(en(te)):te;if(Re.isArrayBuffer(te)||Re.isBuffer(te)||Re.isStream(te)||Re.isFile(te)||Re.isBlob(te)||Re.isReadableStream(te))return te;if(Re.isArrayBufferView(te))return te.buffer;if(Re.isURLSearchParams(te))return ue.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),te.toString();let lt;if($e){if(xe.indexOf("application/x-www-form-urlencoded")>-1)return Os(te,this.formSerializer).toString();if((lt=Re.isFileList(te))||xe.indexOf("multipart/form-data")>-1){const Jt=this.env&&this.env.FormData;return ie(lt?{"files[]":te}:te,Jt&&new Jt,this.formSerializer)}}return $e||we?(ue.setContentType("application/json",!1),he(te)):te}],transformResponse:[function(te){const ue=this.transitional||Ge.transitional,xe=ue&&ue.forcedJSONParsing,we=this.responseType==="json";if(Re.isResponse(te)||Re.isReadableStream(te))return te;if(te&&Re.isString(te)&&(xe&&!this.responseType||we)){const Be=!(ue&&ue.silentJSONParsing)&&we;try{return JSON.parse(te,this.parseReviver)}catch(lt){if(Be)throw lt.name==="SyntaxError"?qt.from(lt,qt.ERR_BAD_RESPONSE,this,null,this.response):lt}}return te}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Yt.classes.FormData,Blob:Yt.classes.Blob},validateStatus:function(te){return te>=200&&te<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Re.forEach(["delete","get","head","post","put","patch"],J=>{Ge.headers[J]={}});var at=Ge;const pt=Re.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 mt=J=>{const te={};let ue,xe,we;return J&&J.split(`
`).forEach(function(Be){we=Be.indexOf(":"),ue=Be.substring(0,we).trim().toLowerCase(),xe=Be.substring(we+1).trim(),!(!ue||te[ue]&&pt[ue])&&(ue==="set-cookie"?te[ue]?te[ue].push(xe):te[ue]=[xe]:te[ue]=te[ue]?te[ue]+", "+xe:xe)}),te};const Bt=Symbol("internals");function Ds(J){return J&&String(J).trim().toLowerCase()}function as(J){return J===!1||J==null?J:Re.isArray(J)?J.map(as):String(J)}function Vs(J){const te=Object.create(null),ue=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let xe;for(;xe=ue.exec(J);)te[xe[1]]=xe[2];return te}const Ls=J=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(J.trim());function Ts(J,te,ue,xe,we){if(Re.isFunction(xe))return xe.call(this,te,ue);if(we&&(te=ue),!!Re.isString(te)){if(Re.isString(xe))return te.indexOf(xe)!==-1;if(Re.isRegExp(xe))return xe.test(te)}}function ln(J){return J.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(te,ue,xe)=>ue.toUpperCase()+xe)}function pn(J,te){const ue=Re.toCamelCase(" "+te);["get","set","has"].forEach(xe=>{Object.defineProperty(J,xe+ue,{value:function(we,$e,Be){return this[xe].call(this,te,we,$e,Be)},configurable:!0})})}class hn{constructor(te){te&&this.set(te)}set(te,ue,xe){const we=this;function $e(lt,Jt,Mt){const Et=Ds(Jt);if(!Et)throw new Error("header name must be a non-empty string");const gs=Re.findKey(we,Et);(!gs||we[gs]===void 0||Mt===!0||Mt===void 0&&we[gs]!==!1)&&(we[gs||Jt]=as(lt))}const Be=(lt,Jt)=>Re.forEach(lt,(Mt,Et)=>$e(Mt,Et,Jt));if(Re.isPlainObject(te)||te instanceof this.constructor)Be(te,ue);else if(Re.isString(te)&&(te=te.trim())&&!Ls(te))Be(mt(te),ue);else if(Re.isObject(te)&&Re.isIterable(te)){let lt={},Jt,Mt;for(const Et of te){if(!Re.isArray(Et))throw TypeError("Object iterator must return a key-value pair");lt[Mt=Et[0]]=(Jt=lt[Mt])?Re.isArray(Jt)?[...Jt,Et[1]]:[Jt,Et[1]]:Et[1]}Be(lt,ue)}else te!=null&&$e(ue,te,xe);return this}get(te,ue){if(te=Ds(te),te){const xe=Re.findKey(this,te);if(xe){const we=this[xe];if(!ue)return we;if(ue===!0)return Vs(we);if(Re.isFunction(ue))return ue.call(this,we,xe);if(Re.isRegExp(ue))return ue.exec(we);throw new TypeError("parser must be boolean|regexp|function")}}}has(te,ue){if(te=Ds(te),te){const xe=Re.findKey(this,te);return!!(xe&&this[xe]!==void 0&&(!ue||Ts(this,this[xe],xe,ue)))}return!1}delete(te,ue){const xe=this;let we=!1;function $e(Be){if(Be=Ds(Be),Be){const lt=Re.findKey(xe,Be);lt&&(!ue||Ts(xe,xe[lt],lt,ue))&&(delete xe[lt],we=!0)}}return Re.isArray(te)?te.forEach($e):$e(te),we}clear(te){const ue=Object.keys(this);let xe=ue.length,we=!1;for(;xe--;){const $e=ue[xe];(!te||Ts(this,this[$e],$e,te,!0))&&(delete this[$e],we=!0)}return we}normalize(te){const ue=this,xe={};return Re.forEach(this,(we,$e)=>{const Be=Re.findKey(xe,$e);if(Be){ue[Be]=as(we),delete ue[$e];return}const lt=te?ln($e):String($e).trim();lt!==$e&&delete ue[$e],ue[lt]=as(we),xe[lt]=!0}),this}concat(...te){return this.constructor.concat(this,...te)}toJSON(te){const ue=Object.create(null);return Re.forEach(this,(xe,we)=>{xe!=null&&xe!==!1&&(ue[we]=te&&Re.isArray(xe)?xe.join(", "):xe)}),ue}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([te,ue])=>te+": "+ue).join(`
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(te){return te instanceof this?te:new this(te)}static concat(te,...ue){const xe=new this(te);return ue.forEach(we=>xe.set(we)),xe}static accessor(te){const xe=(this[Bt]=this[Bt]={accessors:{}}).accessors,we=this.prototype;function $e(Be){const lt=Ds(Be);xe[lt]||(pn(we,Be),xe[lt]=!0)}return Re.isArray(te)?te.forEach($e):$e(te),this}}hn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Re.reduceDescriptors(hn.prototype,({value:J},te)=>{let ue=te[0].toUpperCase()+te.slice(1);return{get:()=>J,set(xe){this[ue]=xe}}}),Re.freezeMethods(hn);var Ws=hn;function Qs(J,te){const ue=this||at,xe=te||ue,we=Ws.from(xe.headers);let $e=xe.data;return Re.forEach(J,function(lt){$e=lt.call(ue,$e,we.normalize(),te?te.status:void 0)}),we.normalize(),$e}function zn(J){return!!(J&&J.__CANCEL__)}class on extends qt{constructor(te,ue,xe){super(te??"canceled",qt.ERR_CANCELED,ue,xe),this.name="CanceledError",this.__CANCEL__=!0}}var Un=on;function yr(J,te,ue){const xe=ue.config.validateStatus;!ue.status||!xe||xe(ue.status)?J(ue):te(new qt("Request failed with status code "+ue.status,[qt.ERR_BAD_REQUEST,qt.ERR_BAD_RESPONSE][Math.floor(ue.status/100)-4],ue.config,ue.request,ue))}function Tr(J){const te=/^([-+\w]{1,25})(:?\/\/|:)/.exec(J);return te&&te[1]||""}function er(J,te){J=J||10;const ue=new Array(J),xe=new Array(J);let we=0,$e=0,Be;return te=te!==void 0?te:1e3,function(Jt){const Mt=Date.now(),Et=xe[$e];Be||(Be=Mt),ue[we]=Jt,xe[we]=Mt;let gs=$e,tn=0;for(;gs!==we;)tn+=ue[gs++],gs=gs%J;if(we=(we+1)%J,we===$e&&($e=($e+1)%J),Mt-Be<te)return;const Hn=Et&&Mt-Et;return Hn?Math.round(tn*1e3/Hn):void 0}}function tr(J,te){let ue=0,xe=1e3/te,we,$e;const Be=(Mt,Et=Date.now())=>{ue=Et,we=null,$e&&(clearTimeout($e),$e=null),J(...Mt)};return[(...Mt)=>{const Et=Date.now(),gs=Et-ue;gs>=xe?Be(Mt,Et):(we=Mt,$e||($e=setTimeout(()=>{$e=null,Be(we)},xe-gs)))},()=>we&&Be(we)]}const En=(J,te,ue=3)=>{let xe=0;const we=er(50,250);return tr($e=>{const Be=$e.loaded,lt=$e.lengthComputable?$e.total:void 0,Jt=Be-xe,Mt=we(Jt),Et=Be<=lt;xe=Be;const gs={loaded:Be,total:lt,progress:lt?Be/lt:void 0,bytes:Jt,rate:Mt||void 0,estimated:Mt&&lt&&Et?(lt-Be)/Mt:void 0,event:$e,lengthComputable:lt!=null,[te?"download":"upload"]:!0};J(gs)},ue)},Xe=(J,te)=>{const ue=J!=null;return[xe=>te[0]({lengthComputable:ue,total:J,loaded:xe}),te[1]]},$t=J=>(...te)=>Re.asap(()=>J(...te));var Ze=Yt.hasStandardBrowserEnv?((J,te)=>ue=>(ue=new URL(ue,Yt.origin),J.protocol===ue.protocol&&J.host===ue.host&&(te||J.port===ue.port)))(new URL(Yt.origin),Yt.navigator&&/(msie|trident)/i.test(Yt.navigator.userAgent)):()=>!0,Ut=Yt.hasStandardBrowserEnv?{write(J,te,ue,xe,we,$e,Be){if(typeof document>"u")return;const lt=[`${J}=${encodeURIComponent(te)}`];Re.isNumber(ue)&&lt.push(`expires=${new Date(ue).toUTCString()}`),Re.isString(xe)&&lt.push(`path=${xe}`),Re.isString(we)&&lt.push(`domain=${we}`),$e===!0&&lt.push("secure"),Re.isString(Be)&&lt.push(`SameSite=${Be}`),document.cookie=lt.join("; ")},read(J){if(typeof document>"u")return null;const te=document.cookie.match(new RegExp("(?:^|; )"+J+"=([^;]*)"));return te?decodeURIComponent(te[1]):null},remove(J){this.write(J,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function jt(J){return typeof J!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(J)}function In(J,te){return te?J.replace(/\/?\/$/,"")+"/"+te.replace(/^\/+/,""):J}function jr(J,te,ue){let xe=!jt(te);return J&&(xe||ue==!1)?In(J,te):te}const Pr=J=>J instanceof Ws?{...J}:J;function xn(J,te){te=te||{};const ue={};function xe(Mt,Et,gs,tn){return Re.isPlainObject(Mt)&&Re.isPlainObject(Et)?Re.merge.call({caseless:tn},Mt,Et):Re.isPlainObject(Et)?Re.merge({},Et):Re.isArray(Et)?Et.slice():Et}function we(Mt,Et,gs,tn){if(Re.isUndefined(Et)){if(!Re.isUndefined(Mt))return xe(void 0,Mt,gs,tn)}else return xe(Mt,Et,gs,tn)}function $e(Mt,Et){if(!Re.isUndefined(Et))return xe(void 0,Et)}function Be(Mt,Et){if(Re.isUndefined(Et)){if(!Re.isUndefined(Mt))return xe(void 0,Mt)}else return xe(void 0,Et)}function lt(Mt,Et,gs){if(gs in te)return xe(Mt,Et);if(gs in J)return xe(void 0,Mt)}const Jt={url:$e,method:$e,data:$e,baseURL:Be,transformRequest:Be,transformResponse:Be,paramsSerializer:Be,timeout:Be,timeoutMessage:Be,withCredentials:Be,withXSRFToken:Be,adapter:Be,responseType:Be,xsrfCookieName:Be,xsrfHeaderName:Be,onUploadProgress:Be,onDownloadProgress:Be,decompress:Be,maxContentLength:Be,maxBodyLength:Be,beforeRedirect:Be,transport:Be,httpAgent:Be,httpsAgent:Be,cancelToken:Be,socketPath:Be,responseEncoding:Be,validateStatus:lt,headers:(Mt,Et,gs)=>we(Pr(Mt),Pr(Et),gs,!0)};return Re.forEach(Object.keys({...J,...te}),function(Et){if(Et==="__proto__"||Et==="constructor"||Et==="prototype")return;const gs=Re.hasOwnProp(Jt,Et)?Jt[Et]:we,tn=gs(J[Et],te[Et],Et);Re.isUndefined(tn)&&gs!==lt||(ue[Et]=tn)}),ue}var qs=J=>{const te=xn({},J);let{data:ue,withXSRFToken:xe,xsrfHeaderName:we,xsrfCookieName:$e,headers:Be,auth:lt}=te;if(te.headers=Be=Ws.from(Be),te.url=Ee(jr(te.baseURL,te.url,te.allowAbsoluteUrls),J.params,J.paramsSerializer),lt&&Be.set("Authorization","Basic "+btoa((lt.username||"")+":"+(lt.password?unescape(encodeURIComponent(lt.password)):""))),Re.isFormData(ue)){if(Yt.hasStandardBrowserEnv||Yt.hasStandardBrowserWebWorkerEnv)Be.setContentType(void 0);else if(Re.isFunction(ue.getHeaders)){const Jt=ue.getHeaders(),Mt=["content-type","content-length"];Object.entries(Jt).forEach(([Et,gs])=>{Mt.includes(Et.toLowerCase())&&Be.set(Et,gs)})}}if(Yt.hasStandardBrowserEnv&&(xe&&Re.isFunction(xe)&&(xe=xe(te)),xe||xe!==!1&&Ze(te.url))){const Jt=we&&$e&&Ut.read($e);Jt&&Be.set(we,Jt)}return te},Tt=typeof XMLHttpRequest<"u"&&function(J){return new Promise(function(ue,xe){const we=qs(J);let $e=we.data;const Be=Ws.from(we.headers).normalize();let{responseType:lt,onUploadProgress:Jt,onDownloadProgress:Mt}=we,Et,gs,tn,Hn,Ot;function bs(){Hn&&Hn(),Ot&&Ot(),we.cancelToken&&we.cancelToken.unsubscribe(Et),we.signal&&we.signal.removeEventListener("abort",Et)}let es=new XMLHttpRequest;es.open(we.method.toUpperCase(),we.url,!0),es.timeout=we.timeout;function Sn(){if(!es)return;const Dn=Ws.from("getAllResponseHeaders"in es&&es.getAllResponseHeaders()),Ir={data:!lt||lt==="text"||lt==="json"?es.responseText:es.response,status:es.status,statusText:es.statusText,headers:Dn,config:J,request:es};yr(function(rr){ue(rr),bs()},function(rr){xe(rr),bs()},Ir),es=null}"onloadend"in es?es.onloadend=Sn:es.onreadystatechange=function(){!es||es.readyState!==4||es.status===0&&!(es.responseURL&&es.responseURL.indexOf("file:")===0)||setTimeout(Sn)},es.onabort=function(){es&&(xe(new qt("Request aborted",qt.ECONNABORTED,J,es)),es=null)},es.onerror=function(nr){const Ir=nr&&nr.message?nr.message:"Network Error",Ia=new qt(Ir,qt.ERR_NETWORK,J,es);Ia.event=nr||null,xe(Ia),es=null},es.ontimeout=function(){let nr=we.timeout?"timeout of "+we.timeout+"ms exceeded":"timeout exceeded";const Ir=we.transitional||bt;we.timeoutErrorMessage&&(nr=we.timeoutErrorMessage),xe(new qt(nr,Ir.clarifyTimeoutError?qt.ETIMEDOUT:qt.ECONNABORTED,J,es)),es=null},$e===void 0&&Be.setContentType(null),"setRequestHeader"in es&&Re.forEach(Be.toJSON(),function(nr,Ir){es.setRequestHeader(Ir,nr)}),Re.isUndefined(we.withCredentials)||(es.withCredentials=!!we.withCredentials),lt&&lt!=="json"&&(es.responseType=we.responseType),Mt&&([tn,Ot]=En(Mt,!0),es.addEventListener("progress",tn)),Jt&&es.upload&&([gs,Hn]=En(Jt),es.upload.addEventListener("progress",gs),es.upload.addEventListener("loadend",Hn)),(we.cancelToken||we.signal)&&(Et=Dn=>{es&&(xe(!Dn||Dn.type?new Un(null,J,es):Dn),es.abort(),es=null)},we.cancelToken&&we.cancelToken.subscribe(Et),we.signal&&(we.signal.aborted?Et():we.signal.addEventListener("abort",Et)));const xr=Tr(we.url);if(xr&&Yt.protocols.indexOf(xr)===-1){xe(new qt("Unsupported protocol "+xr+":",qt.ERR_BAD_REQUEST,J));return}es.send($e||null)})},Vr=(J,te)=>{const{length:ue}=J=J?J.filter(Boolean):[];if(te||ue){let xe=new AbortController,we;const $e=function(Mt){if(!we){we=!0,lt();const Et=Mt instanceof Error?Mt:this.reason;xe.abort(Et instanceof qt?Et:new Un(Et instanceof Error?Et.message:Et))}};let Be=te&&setTimeout(()=>{Be=null,$e(new qt(`timeout of ${te}ms exceeded`,qt.ETIMEDOUT))},te);const lt=()=>{J&&(Be&&clearTimeout(Be),Be=null,J.forEach(Mt=>{Mt.unsubscribe?Mt.unsubscribe($e):Mt.removeEventListener("abort",$e)}),J=null)};J.forEach(Mt=>Mt.addEventListener("abort",$e));const{signal:Jt}=xe;return Jt.unsubscribe=()=>Re.asap(lt),Jt}};const ta=function*(J,te){let ue=J.byteLength;if(ue<te){yield J;return}let xe=0,we;for(;xe<ue;)we=xe+te,yield J.slice(xe,we),xe=we},ma=async function*(J,te){for await(const ue of _r(J))yield*ta(ue,te)},_r=async function*(J){if(J[Symbol.asyncIterator]){yield*J;return}const te=J.getReader();try{for(;;){const{done:ue,value:xe}=await te.read();if(ue)break;yield xe}}finally{await te.cancel()}},sr=(J,te,ue,xe)=>{const we=ma(J,te);let $e=0,Be,lt=Jt=>{Be||(Be=!0,xe&&xe(Jt))};return new ReadableStream({async pull(Jt){try{const{done:Mt,value:Et}=await we.next();if(Mt){lt(),Jt.close();return}let gs=Et.byteLength;if(ue){let tn=$e+=gs;ue(tn)}Jt.enqueue(new Uint8Array(Et))}catch(Mt){throw lt(Mt),Mt}},cancel(Jt){return lt(Jt),we.return()}},{highWaterMark:2})},gn=64*1024,{isFunction:mn}=Re,Qn=(({Request:J,Response:te})=>({Request:J,Response:te}))(Re.global),{ReadableStream:fr,TextEncoder:pr}=Re.global,dn=(J,...te)=>{try{return!!J(...te)}catch{return!1}},wn=J=>{J=Re.merge.call({skipUndefined:!0},Qn,J);const{fetch:te,Request:ue,Response:xe}=J,we=te?mn(te):typeof fetch=="function",$e=mn(ue),Be=mn(xe);if(!we)return!1;const lt=we&&mn(fr),Jt=we&&(typeof pr=="function"?(Ot=>bs=>Ot.encode(bs))(new pr):async Ot=>new Uint8Array(await new ue(Ot).arrayBuffer())),Mt=$e&&lt&&dn(()=>{let Ot=!1;const bs=new ue(Yt.origin,{body:new fr,method:"POST",get duplex(){return Ot=!0,"half"}}).headers.has("Content-Type");return Ot&&!bs}),Et=Be&&lt&&dn(()=>Re.isReadableStream(new xe("").body)),gs={stream:Et&&(Ot=>Ot.body)};we&&["text","arrayBuffer","blob","formData","stream"].forEach(Ot=>{!gs[Ot]&&(gs[Ot]=(bs,es)=>{let Sn=bs&&bs[Ot];if(Sn)return Sn.call(bs);throw new qt(`Response type '${Ot}' is not supported`,qt.ERR_NOT_SUPPORT,es)})});const tn=async Ot=>{if(Ot==null)return 0;if(Re.isBlob(Ot))return Ot.size;if(Re.isSpecCompliantForm(Ot))return(await new ue(Yt.origin,{method:"POST",body:Ot}).arrayBuffer()).byteLength;if(Re.isArrayBufferView(Ot)||Re.isArrayBuffer(Ot))return Ot.byteLength;if(Re.isURLSearchParams(Ot)&&(Ot=Ot+""),Re.isString(Ot))return(await Jt(Ot)).byteLength},Hn=async(Ot,bs)=>{const es=Re.toFiniteNumber(Ot.getContentLength());return es??tn(bs)};return async Ot=>{let{url:bs,method:es,data:Sn,signal:xr,cancelToken:Dn,timeout:nr,onDownloadProgress:Ir,onUploadProgress:Ia,responseType:rr,headers:ao,withCredentials:il="same-origin",fetchOptions:io}=qs(Ot),lo=te||fetch;rr=rr?(rr+"").toLowerCase():"text";let ll=Vr([xr,Dn&&Dn.toAbortSignal()],nr),Di=null;const La=ll&&ll.unsubscribe&&(()=>{ll.unsubscribe()});let Ko;try{if(Ia&&Mt&&es!=="get"&&es!=="head"&&(Ko=await Hn(ao,Sn))!==0){let xa=new ue(bs,{method:"POST",body:Sn,duplex:"half"}),Ma;if(Re.isFormData(Sn)&&(Ma=xa.headers.get("content-type"))&&ao.setContentType(Ma),xa.body){const[cl,Pi]=Xe(Ko,En($t(Ia)));Sn=sr(xa.body,gn,cl,Pi)}}Re.isString(il)||(il=il?"include":"omit");const ar=$e&&"credentials"in ue.prototype,Yo={...io,signal:ll,method:es.toUpperCase(),headers:ao.normalize().toJSON(),body:Sn,duplex:"half",credentials:ar?il:void 0};Di=$e&&new ue(bs,Yo);let pa=await($e?lo(Di,io):lo(bs,Yo));const ol=Et&&(rr==="stream"||rr==="response");if(Et&&(Ir||ol&&La)){const xa={};["status","statusText","headers"].forEach(oo=>{xa[oo]=pa[oo]});const Ma=Re.toFiniteNumber(pa.headers.get("content-length")),[cl,Pi]=Ir&&Xe(Ma,En($t(Ir),!0))||[];pa=new xe(sr(pa.body,gn,cl,()=>{Pi&&Pi(),La&&La()}),xa)}rr=rr||"text";let Ti=await gs[Re.findKey(gs,rr)||"text"](pa,Ot);return!ol&&La&&La(),await new Promise((xa,Ma)=>{yr(xa,Ma,{data:Ti,headers:Ws.from(pa.headers),status:pa.status,statusText:pa.statusText,config:Ot,request:Di})})}catch(ar){throw La&&La(),ar&&ar.name==="TypeError"&&/Load failed|fetch/i.test(ar.message)?Object.assign(new qt("Network Error",qt.ERR_NETWORK,Ot,Di,ar&&ar.response),{cause:ar.cause||ar}):qt.from(ar,ar&&ar.code,Ot,Di,ar&&ar.response)}}},Da=new Map,fa=J=>{let te=J&&J.env||{};const{fetch:ue,Request:xe,Response:we}=te,$e=[xe,we,ue];let Be=$e.length,lt=Be,Jt,Mt,Et=Da;for(;lt--;)Jt=$e[lt],Mt=Et.get(Jt),Mt===void 0&&Et.set(Jt,Mt=lt?new Map:wn(te)),Et=Mt;return Mt};fa();const Ai={http:ws,xhr:Tt,fetch:{get:fa}};Re.forEach(Ai,(J,te)=>{if(J){try{Object.defineProperty(J,"name",{value:te})}catch{}Object.defineProperty(J,"adapterName",{value:te})}});const ki=J=>`- ${J}`,ni=J=>Re.isFunction(J)||J===null||J===!1;function rl(J,te){J=Re.isArray(J)?J:[J];const{length:ue}=J;let xe,we;const $e={};for(let Be=0;Be<ue;Be++){xe=J[Be];let lt;if(we=xe,!ni(xe)&&(we=Ai[(lt=String(xe)).toLowerCase()],we===void 0))throw new qt(`Unknown adapter '${lt}'`);if(we&&(Re.isFunction(we)||(we=we.get(te))))break;$e[lt||"#"+Be]=we}if(!we){const Be=Object.entries($e).map(([Jt,Mt])=>`adapter ${Jt} `+(Mt===!1?"is not supported by the environment":"is not available in the build"));let lt=ue?Be.length>1?`since :
`+Be.map(ki).join(`
`):" "+ki(Be[0]):"as no adapter specified";throw new qt("There is no suitable adapter to dispatch the request "+lt,"ERR_NOT_SUPPORT")}return we}var Go={getAdapter:rl,adapters:Ai};function Ta(J){if(J.cancelToken&&J.cancelToken.throwIfRequested(),J.signal&&J.signal.aborted)throw new Un(null,J)}function ri(J){return Ta(J),J.headers=Ws.from(J.headers),J.data=Qs.call(J,J.transformRequest),["post","put","patch"].indexOf(J.method)!==-1&&J.headers.setContentType("application/x-www-form-urlencoded",!1),Go.getAdapter(J.adapter||at.adapter,J)(J).then(function(xe){return Ta(J),xe.data=Qs.call(J,J.transformResponse,xe),xe.headers=Ws.from(xe.headers),xe},function(xe){return zn(xe)||(Ta(J),xe&&xe.response&&(xe.response.data=Qs.call(J,J.transformResponse,xe.response),xe.response.headers=Ws.from(xe.response.headers))),Promise.reject(xe)})}const Pa="1.13.6",_a={};["object","boolean","number","function","string","symbol"].forEach((J,te)=>{_a[J]=function(xe){return typeof xe===J||"a"+(te<1?"n ":" ")+J}});const to={};_a.transitional=function(te,ue,xe){function we($e,Be){return"[Axios v"+Pa+"] Transitional option '"+$e+"'"+Be+(xe?". "+xe:"")}return($e,Be,lt)=>{if(te===!1)throw new qt(we(Be," has been removed"+(ue?" in "+ue:"")),qt.ERR_DEPRECATED);return ue&&!to[Be]&&(to[Be]=!0,console.warn(we(Be," has been deprecated since v"+ue+" and will be removed in the near future"))),te?te($e,Be,lt):!0}},_a.spelling=function(te){return(ue,xe)=>(console.warn(`${xe} is likely a misspelling of ${te}`),!0)};function Zc(J,te,ue){if(typeof J!="object")throw new qt("options must be an object",qt.ERR_BAD_OPTION_VALUE);const xe=Object.keys(J);let we=xe.length;for(;we-- >0;){const $e=xe[we],Be=te[$e];if(Be){const lt=J[$e],Jt=lt===void 0||Be(lt,$e,J);if(Jt!==!0)throw new qt("option "+$e+" must be "+Jt,qt.ERR_BAD_OPTION_VALUE);continue}if(ue!==!0)throw new qt("Unknown option "+$e,qt.ERR_BAD_OPTION)}}var Oa={assertOptions:Zc,validators:_a};const Vn=Oa.validators;class ai{constructor(te){this.defaults=te||{},this.interceptors={request:new st,response:new st}}async request(te,ue){try{return await this._request(te,ue)}catch(xe){if(xe instanceof Error){let we={};Error.captureStackTrace?Error.captureStackTrace(we):we=new Error;const $e=we.stack?we.stack.replace(/^.+\n/,""):"";try{xe.stack?$e&&!String(xe.stack).endsWith($e.replace(/^.+\n.+\n/,""))&&(xe.stack+=`
`+$e):xe.stack=$e}catch{}}throw xe}}_request(te,ue){typeof te=="string"?(ue=ue||{},ue.url=te):ue=te||{},ue=xn(this.defaults,ue);const{transitional:xe,paramsSerializer:we,headers:$e}=ue;xe!==void 0&&Oa.assertOptions(xe,{silentJSONParsing:Vn.transitional(Vn.boolean),forcedJSONParsing:Vn.transitional(Vn.boolean),clarifyTimeoutError:Vn.transitional(Vn.boolean),legacyInterceptorReqResOrdering:Vn.transitional(Vn.boolean)},!1),we!=null&&(Re.isFunction(we)?ue.paramsSerializer={serialize:we}:Oa.assertOptions(we,{encode:Vn.function,serialize:Vn.function},!0)),ue.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?ue.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:ue.allowAbsoluteUrls=!0),Oa.assertOptions(ue,{baseUrl:Vn.spelling("baseURL"),withXsrfToken:Vn.spelling("withXSRFToken")},!0),ue.method=(ue.method||this.defaults.method||"get").toLowerCase();let Be=$e&&Re.merge($e.common,$e[ue.method]);$e&&Re.forEach(["delete","get","head","post","put","patch","common"],Ot=>{delete $e[Ot]}),ue.headers=Ws.concat(Be,$e);const lt=[];let Jt=!0;this.interceptors.request.forEach(function(bs){if(typeof bs.runWhen=="function"&&bs.runWhen(ue)===!1)return;Jt=Jt&&bs.synchronous;const es=ue.transitional||bt;es&&es.legacyInterceptorReqResOrdering?lt.unshift(bs.fulfilled,bs.rejected):lt.push(bs.fulfilled,bs.rejected)});const Mt=[];this.interceptors.response.forEach(function(bs){Mt.push(bs.fulfilled,bs.rejected)});let Et,gs=0,tn;if(!Jt){const Ot=[ri.bind(this),void 0];for(Ot.unshift(...lt),Ot.push(...Mt),tn=Ot.length,Et=Promise.resolve(ue);gs<tn;)Et=Et.then(Ot[gs++],Ot[gs++]);return Et}tn=lt.length;let Hn=ue;for(;gs<tn;){const Ot=lt[gs++],bs=lt[gs++];try{Hn=Ot(Hn)}catch(es){bs.call(this,es);break}}try{Et=ri.call(this,Hn)}catch(Ot){return Promise.reject(Ot)}for(gs=0,tn=Mt.length;gs<tn;)Et=Et.then(Mt[gs++],Mt[gs++]);return Et}getUri(te){te=xn(this.defaults,te);const ue=jr(te.baseURL,te.url,te.allowAbsoluteUrls);return Ee(ue,te.params,te.paramsSerializer)}}Re.forEach(["delete","get","head","options"],function(te){ai.prototype[te]=function(ue,xe){return this.request(xn(xe||{},{method:te,url:ue,data:(xe||{}).data}))}}),Re.forEach(["post","put","patch"],function(te){function ue(xe){return function($e,Be,lt){return this.request(xn(lt||{},{method:te,headers:xe?{"Content-Type":"multipart/form-data"}:{},url:$e,data:Be}))}}ai.prototype[te]=ue(),ai.prototype[te+"Form"]=ue(!0)});var Ri=ai;class Or{constructor(te){if(typeof te!="function")throw new TypeError("executor must be a function.");let ue;this.promise=new Promise(function($e){ue=$e});const xe=this;this.promise.then(we=>{if(!xe._listeners)return;let $e=xe._listeners.length;for(;$e-- >0;)xe._listeners[$e](we);xe._listeners=null}),this.promise.then=we=>{let $e;const Be=new Promise(lt=>{xe.subscribe(lt),$e=lt}).then(we);return Be.cancel=function(){xe.unsubscribe($e)},Be},te(function($e,Be,lt){xe.reason||(xe.reason=new Un($e,Be,lt),ue(xe.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(te){if(this.reason){te(this.reason);return}this._listeners?this._listeners.push(te):this._listeners=[te]}unsubscribe(te){if(!this._listeners)return;const ue=this._listeners.indexOf(te);ue!==-1&&this._listeners.splice(ue,1)}toAbortSignal(){const te=new AbortController,ue=xe=>{te.abort(xe)};return this.subscribe(ue),te.signal.unsubscribe=()=>this.unsubscribe(ue),te.signal}static source(){let te;return{token:new Or(function(we){te=we}),cancel:te}}}var so=Or;function Ei(J){return function(ue){return J.apply(null,ue)}}function no(J){return Re.isObject(J)&&J.isAxiosError===!0}const ii={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(ii).forEach(([J,te])=>{ii[te]=J});var al=ii;function ro(J){const te=new Ri(J),ue=t(Ri.prototype.request,te);return Re.extend(ue,Ri.prototype,te,{allOwnKeys:!0}),Re.extend(ue,te,null,{allOwnKeys:!0}),ue.create=function(we){return ro(xn(J,we))},ue}const Hs=ro(at);return Hs.Axios=Ri,Hs.CanceledError=Un,Hs.CancelToken=so,Hs.isCancel=zn,Hs.VERSION=Pa,Hs.toFormData=ie,Hs.AxiosError=qt,Hs.Cancel=Hs.CanceledError,Hs.all=function(te){return Promise.all(te)},Hs.spread=Ei,Hs.isAxiosError=no,Hs.mergeConfig=xn,Hs.AxiosHeaders=Ws,Hs.formToJSON=J=>en(Re.isHTMLForm(J)?new FormData(J):J),Hs.getAdapter=Go.getAdapter,Hs.HttpStatusCode=al,Hs.default=Hs,bx=Hs,bx}var AN;function t_(){if(AN)return cr;AN=1;function t(q){return q&&typeof q=="object"&&"default"in q?q.default:q}Object.defineProperty(cr,"__esModule",{value:!0});var s=t(e_()),n=function(){return(n=Object.assign||function(q){for(var G,Z=1,W=arguments.length;Z<W;Z++)for(var z in G=arguments[Z])Object.prototype.hasOwnProperty.call(G,z)&&(q[z]=G[z]);return q}).apply(this,arguments)},r=function(q,G,Z,W){return new(Z||(Z=Promise))(function(z,F){function B(V){try{O(W.next(V))}catch(K){F(K)}}function D(V){try{O(W.throw(V))}catch(K){F(K)}}function O(V){var K;V.done?z(V.value):(K=V.value,K instanceof Z?K:new Z(function(Y){Y(K)})).then(B,D)}O((W=W.apply(q,[])).next())})},a=function(q,G){var Z,W,z,F,B={label:0,sent:function(){if(1&z[0])throw z[1];return z[1]},trys:[],ops:[]};return F={next:D(0),throw:D(1),return:D(2)},typeof Symbol=="function"&&(F[Symbol.iterator]=function(){return this}),F;function D(O){return function(V){return(function(K){if(Z)throw new TypeError("Generator is already executing.");for(;F&&(F=0,K[0]&&(B=0)),B;)try{if(Z=1,W&&(z=2&K[0]?W.return:K[0]?W.throw||((z=W.return)&&z.call(W),0):W.next)&&!(z=z.call(W,K[1])).done)return z;switch(W=0,z&&(K=[2&K[0],z.value]),K[0]){case 0:case 1:z=K;break;case 4:return B.label++,{value:K[1],done:!1};case 5:B.label++,W=K[1],K=[0];continue;case 7:K=B.ops.pop(),B.trys.pop();continue;default:if(!(z=(z=B.trys).length>0&&z[z.length-1])&&(K[0]===6||K[0]===2)){B=0;continue}if(K[0]===3&&(!z||K[1]>z[0]&&K[1]<z[3])){B.label=K[1];break}if(K[0]===6&&B.label<z[1]){B.label=z[1],z=K;break}if(z&&B.label<z[2]){B.label=z[2],B.ops.push(K);break}z[2]&&B.ops.pop(),B.trys.pop();continue}K=G.call(q,B)}catch(Y){K=[6,Y],W=0}finally{Z=z=0}if(5&K[0])throw K[1];return{value:K[0]?K[1]:void 0,done:!0}})([O,V])}}},l=function(q){return q instanceof Date?q.getTime():typeof q=="number"||q===null||q===void 0?q:Number(q)},c=function(q,G,Z){return Z>=q&&Z<=G},d=function(q){return!!q&&(typeof q=="object"||typeof q=="function")&&typeof q.then=="function"},h={Accept:"application/json","Content-Type":"application/json"},x={timeout:0},f=null,m="CLIENT_ERROR",p="SERVER_ERROR",u="TIMEOUT_ERROR",j="CONNECTION_ERROR",g="NETWORK_ERROR",y="UNKNOWN_ERROR",N="CANCEL_ERROR",S=["ECONNABORTED"],C=["ENOTFOUND","ECONNREFUSED","ECONNRESET"],w=["ERR_BAD_REQUEST","ERR_BAD_RESPONSE"],R=function(q){return c(200,299,q)},P=function(q){return c(400,499,q)},A=function(q){return c(500,599,q)},I=function(q){return q.message==="Network Error"?g:s.isCancel(q)?N:q.code?w.includes(q.code)?$(q.response.status):S.includes(q.code)?u:C.includes(q.code)?j:y:$(q.response?q.response.status:null)},$=function(q){return q?R(q)?f:P(q)?m:A(q)?p:y:y},T=function(q){var G,Z=n(n({},h),q.headers||{});if(q.axiosInstance)G=q.axiosInstance;else{var W=n(n({},q),{headers:void 0}),z=n(n({},x),W);G=s.create(z)}var F=[],B=[],D=[],O=[],V=[],K=function(re,ge){return Z[re]=ge,G},Y=function(re){return function(ge,ve,Se){return ve===void 0&&(ve={}),Se===void 0&&(Se={}),X(n(n({},Se),{url:ge,params:ve,method:re}))}},U=function(re){return function(ge,ve,Se){return Se===void 0&&(Se={}),X(n(n({},Se),{url:ge,method:re,data:ve}))}},X=function(re){return r(void 0,void 0,void 0,function(){var ge,ve,Se,We;return a(this,function(Ce){switch(Ce.label){case 0:if(re.headers=n(n({},Z),re.headers),B.length>0&&B.forEach(function(fe){return fe(re)}),!(D.length>0))return[3,6];ge=0,Ce.label=1;case 1:return ge<D.length?(ve=D[ge](re),d(ve)?[4,ve]:[3,3]):[3,6];case 2:return Ce.sent(),[3,5];case 3:return[4,ve(re)];case 4:Ce.sent(),Ce.label=5;case 5:return ge++,[3,1];case 6:return Se=l(new Date),We=function(fe){return r(void 0,void 0,void 0,function(){var Ye;return a(this,function(be){switch(be.label){case 0:return[4,oe(Se,fe)];case 1:return Ye=be.sent(),[2,ne(Ye)]}})})},[2,G.request(re).then(We).catch(We)]}})})},ne=function(re){return F.forEach(function(ge){try{ge(re)}catch{}}),re},oe=function(re,ge){return r(void 0,void 0,void 0,function(){var ve,Se,We,Ce,fe,Ye,be,_e,ke,qe,Ve,dt,xt,ye,le,Qe,rt;return a(this,function(Kt){switch(Kt.label){case 0:if(ve=l(new Date),Se=ve-re,We=ge instanceof Error||s.isCancel(ge),Ce=ge,fe=ge,Ye=We?fe.response:Ce,be=Ye&&Ye.status||null,_e=We?I(ge):$(be),ke=We?fe:null,qe=R(be),Ve=ge.config||null,dt=Ye&&Ye.headers||null,xt=(rt=Ye&&Ye.data)!==null&&rt!==void 0?rt:null,ye={duration:Se,problem:_e,originalError:ke,ok:qe,status:be,headers:dt,config:Ve,data:xt},O.length>0&&O.forEach(function(Rt){return Rt(ye)}),!(V.length>0))return[3,6];le=0,Kt.label=1;case 1:return le<V.length?(Qe=V[le](ye),d(Qe)?[4,Qe]:[3,3]):[3,6];case 2:return Kt.sent(),[3,5];case 3:return[4,Qe(ye)];case 4:Kt.sent(),Kt.label=5;case 5:return le++,[3,1];case 6:return[2,ye]}})})};return{axiosInstance:G,monitors:F,addMonitor:function(re){F.push(re)},requestTransforms:B,asyncRequestTransforms:D,responseTransforms:O,asyncResponseTransforms:V,addRequestTransform:function(re){return B.push(re)},addAsyncRequestTransform:function(re){return D.push(re)},addResponseTransform:function(re){return O.push(re)},addAsyncResponseTransform:function(re){return V.push(re)},setHeader:K,setHeaders:function(re){return Object.keys(re).forEach(function(ge){return K(ge,re[ge])}),G},deleteHeader:function(re){return delete Z[re],G},headers:Z,setBaseURL:function(re){return G.defaults.baseURL=re,G},getBaseURL:function(){return G.defaults.baseURL},any:X,get:Y("get"),delete:Y("delete"),head:Y("head"),post:U("post"),put:U("put"),patch:U("patch"),link:Y("link"),unlink:Y("unlink")}},E=s.isCancel,_=s.CancelToken,M={DEFAULT_HEADERS:h,NONE:f,CLIENT_ERROR:m,SERVER_ERROR:p,TIMEOUT_ERROR:u,CONNECTION_ERROR:j,NETWORK_ERROR:g,UNKNOWN_ERROR:y,create:T,isCancel:E,CancelToken:_};return cr.DEFAULT_HEADERS=h,cr.NONE=f,cr.CLIENT_ERROR=m,cr.SERVER_ERROR=p,cr.TIMEOUT_ERROR=u,cr.CONNECTION_ERROR=j,cr.NETWORK_ERROR=g,cr.UNKNOWN_ERROR=y,cr.CANCEL_ERROR=N,cr.getProblemFromError=I,cr.getProblemFromStatus=$,cr.create=T,cr.isCancel=E,cr.CancelToken=_,cr.default=M,cr}var s_=t_();const n_="https://dealeronboarding-uat.royalenfield.com/api",ze=s_.create({baseURL:n_,headers:{"Content-Type":"application/json",Accept:"application/json"},timeout:3e4});ze.addRequestTransform(t=>{const s=localStorage.getItem("token");s&&t.headers&&(t.headers.Authorization=`Bearer ${s}`)});ze.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 DC(t,s){return function(){return t.apply(s,arguments)}}const{toString:r_}=Object.prototype,{getPrototypeOf:Lv}=Object,{iterator:zm,toStringTag:TC}=Symbol,Um=(t=>s=>{const n=r_.call(s);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ti=t=>(t=t.toLowerCase(),s=>Um(s)===t),Vm=t=>s=>typeof s===t,{isArray:Mc}=Array,Ec=Vm("undefined");function ru(t){return t!==null&&!Ec(t)&&t.constructor!==null&&!Ec(t.constructor)&&Xr(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const PC=ti("ArrayBuffer");function a_(t){let s;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?s=ArrayBuffer.isView(t):s=t&&t.buffer&&PC(t.buffer),s}const i_=Vm("string"),Xr=Vm("function"),_C=Vm("number"),au=t=>t!==null&&typeof t=="object",l_=t=>t===!0||t===!1,Kh=t=>{if(Um(t)!=="object")return!1;const s=Lv(t);return(s===null||s===Object.prototype||Object.getPrototypeOf(s)===null)&&!(TC in t)&&!(zm in t)},o_=t=>{if(!au(t)||ru(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},c_=ti("Date"),d_=ti("File"),u_=t=>!!(t&&typeof t.uri<"u"),h_=t=>t&&typeof t.getParts<"u",m_=ti("Blob"),f_=ti("FileList"),p_=t=>au(t)&&Xr(t.pipe);function x_(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const kN=x_(),RN=typeof kN.FormData<"u"?kN.FormData:void 0,g_=t=>{let s;return t&&(RN&&t instanceof RN||Xr(t.append)&&((s=Um(t))==="formdata"||s==="object"&&Xr(t.toString)&&t.toString()==="[object FormData]"))},v_=ti("URLSearchParams"),[b_,y_,j_,N_]=["ReadableStream","Request","Response","Headers"].map(ti),w_=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function iu(t,s,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let r,a;if(typeof t!="object"&&(t=[t]),Mc(t))for(r=0,a=t.length;r<a;r++)s.call(null,t[r],r,t);else{if(ru(t))return;const l=n?Object.getOwnPropertyNames(t):Object.keys(t),c=l.length;let d;for(r=0;r<c;r++)d=l[r],s.call(null,t[d],d,t)}}function OC(t,s){if(ru(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 Do=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,IC=t=>!Ec(t)&&t!==Do;function W0(){const{caseless:t,skipUndefined:s}=IC(this)&&this||{},n={},r=(a,l)=>{if(l==="__proto__"||l==="constructor"||l==="prototype")return;const c=t&&OC(n,l)||l;Kh(n[c])&&Kh(a)?n[c]=W0(n[c],a):Kh(a)?n[c]=W0({},a):Mc(a)?n[c]=a.slice():(!s||!Ec(a))&&(n[c]=a)};for(let a=0,l=arguments.length;a<l;a++)arguments[a]&&iu(arguments[a],r);return n}const S_=(t,s,n,{allOwnKeys:r}={})=>(iu(s,(a,l)=>{n&&Xr(a)?Object.defineProperty(t,l,{value:DC(a,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,l,{value:a,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),C_=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),A_=(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)},k_=(t,s,n,r)=>{let a,l,c;const d={};if(s=s||{},t==null)return s;do{for(a=Object.getOwnPropertyNames(t),l=a.length;l-- >0;)c=a[l],(!r||r(c,t,s))&&!d[c]&&(s[c]=t[c],d[c]=!0);t=n!==!1&&Lv(t)}while(t&&(!n||n(t,s))&&t!==Object.prototype);return s},R_=(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},E_=t=>{if(!t)return null;if(Mc(t))return t;let s=t.length;if(!_C(s))return null;const n=new Array(s);for(;s-- >0;)n[s]=t[s];return n},D_=(t=>s=>t&&s instanceof t)(typeof Uint8Array<"u"&&Lv(Uint8Array)),T_=(t,s)=>{const r=(t&&t[zm]).call(t);let a;for(;(a=r.next())&&!a.done;){const l=a.value;s.call(t,l[0],l[1])}},P_=(t,s)=>{let n;const r=[];for(;(n=t.exec(s))!==null;)r.push(n);return r},__=ti("HTMLFormElement"),O_=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,a){return r.toUpperCase()+a}),EN=(({hasOwnProperty:t})=>(s,n)=>t.call(s,n))(Object.prototype),I_=ti("RegExp"),LC=(t,s)=>{const n=Object.getOwnPropertyDescriptors(t),r={};iu(n,(a,l)=>{let c;(c=s(a,l,t))!==!1&&(r[l]=c||a)}),Object.defineProperties(t,r)},L_=t=>{LC(t,(s,n)=>{if(Xr(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=t[n];if(Xr(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+"'")})}})},M_=(t,s)=>{const n={},r=a=>{a.forEach(l=>{n[l]=!0})};return Mc(t)?r(t):r(String(t).split(s)),n},F_=()=>{},B_=(t,s)=>t!=null&&Number.isFinite(t=+t)?t:s;function $_(t){return!!(t&&Xr(t.append)&&t[TC]==="FormData"&&t[zm])}const q_=t=>{const s=new Array(10),n=(r,a)=>{if(au(r)){if(s.indexOf(r)>=0)return;if(ru(r))return r;if(!("toJSON"in r)){s[a]=r;const l=Mc(r)?[]:{};return iu(r,(c,d)=>{const h=n(c,a+1);!Ec(h)&&(l[d]=h)}),s[a]=void 0,l}}return r};return n(t,0)},z_=ti("AsyncFunction"),U_=t=>t&&(au(t)||Xr(t))&&Xr(t.then)&&Xr(t.catch),MC=((t,s)=>t?setImmediate:s?((n,r)=>(Do.addEventListener("message",({source:a,data:l})=>{a===Do&&l===n&&r.length&&r.shift()()},!1),a=>{r.push(a),Do.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Xr(Do.postMessage)),V_=typeof queueMicrotask<"u"?queueMicrotask.bind(Do):typeof process<"u"&&process.nextTick||MC,H_=t=>t!=null&&Xr(t[zm]),et={isArray:Mc,isArrayBuffer:PC,isBuffer:ru,isFormData:g_,isArrayBufferView:a_,isString:i_,isNumber:_C,isBoolean:l_,isObject:au,isPlainObject:Kh,isEmptyObject:o_,isReadableStream:b_,isRequest:y_,isResponse:j_,isHeaders:N_,isUndefined:Ec,isDate:c_,isFile:d_,isReactNativeBlob:u_,isReactNative:h_,isBlob:m_,isRegExp:I_,isFunction:Xr,isStream:p_,isURLSearchParams:v_,isTypedArray:D_,isFileList:f_,forEach:iu,merge:W0,extend:S_,trim:w_,stripBOM:C_,inherits:A_,toFlatObject:k_,kindOf:Um,kindOfTest:ti,endsWith:R_,toArray:E_,forEachEntry:T_,matchAll:P_,isHTMLForm:__,hasOwnProperty:EN,hasOwnProp:EN,reduceDescriptors:LC,freezeMethods:L_,toObjectSet:M_,toCamelCase:O_,noop:F_,toFiniteNumber:B_,findKey:OC,global:Do,isContextDefined:IC,isSpecCompliantForm:$_,toJSONObject:q_,isAsyncFn:z_,isThenable:U_,setImmediate:MC,asap:V_,isIterable:H_};let As=class FC extends Error{static from(s,n,r,a,l,c){const d=new FC(s.message,n||s.code,r,a,l);return d.cause=s,d.name=s.name,s.status!=null&&d.status==null&&(d.status=s.status),c&&Object.assign(d,c),d}constructor(s,n,r,a,l){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),l&&(this.response=l,this.status=l.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:et.toJSONObject(this.config),code:this.code,status:this.status}}};As.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";As.ERR_BAD_OPTION="ERR_BAD_OPTION";As.ECONNABORTED="ECONNABORTED";As.ETIMEDOUT="ETIMEDOUT";As.ERR_NETWORK="ERR_NETWORK";As.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";As.ERR_DEPRECATED="ERR_DEPRECATED";As.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";As.ERR_BAD_REQUEST="ERR_BAD_REQUEST";As.ERR_CANCELED="ERR_CANCELED";As.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";As.ERR_INVALID_URL="ERR_INVALID_URL";const W_=null;function G0(t){return et.isPlainObject(t)||et.isArray(t)}function BC(t){return et.endsWith(t,"[]")?t.slice(0,-2):t}function yx(t,s,n){return t?t.concat(s).map(function(a,l){return a=BC(a),!n&&l?"["+a+"]":a}).join(n?".":""):s}function G_(t){return et.isArray(t)&&!t.some(G0)}const K_=et.toFlatObject(et,{},null,function(s){return/^is[A-Z]/.test(s)});function Hm(t,s,n){if(!et.isObject(t))throw new TypeError("target must be an object");s=s||new FormData,n=et.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,y){return!et.isUndefined(y[g])});const r=n.metaTokens,a=n.visitor||f,l=n.dots,c=n.indexes,h=(n.Blob||typeof Blob<"u"&&Blob)&&et.isSpecCompliantForm(s);if(!et.isFunction(a))throw new TypeError("visitor must be a function");function x(j){if(j===null)return"";if(et.isDate(j))return j.toISOString();if(et.isBoolean(j))return j.toString();if(!h&&et.isBlob(j))throw new As("Blob is not supported. Use a Buffer instead.");return et.isArrayBuffer(j)||et.isTypedArray(j)?h&&typeof Blob=="function"?new Blob([j]):Buffer.from(j):j}function f(j,g,y){let N=j;if(et.isReactNative(s)&&et.isReactNativeBlob(j))return s.append(yx(y,g,l),x(j)),!1;if(j&&!y&&typeof j=="object"){if(et.endsWith(g,"{}"))g=r?g:g.slice(0,-2),j=JSON.stringify(j);else if(et.isArray(j)&&G_(j)||(et.isFileList(j)||et.endsWith(g,"[]"))&&(N=et.toArray(j)))return g=BC(g),N.forEach(function(C,w){!(et.isUndefined(C)||C===null)&&s.append(c===!0?yx([g],w,l):c===null?g:g+"[]",x(C))}),!1}return G0(j)?!0:(s.append(yx(y,g,l),x(j)),!1)}const m=[],p=Object.assign(K_,{defaultVisitor:f,convertValue:x,isVisitable:G0});function u(j,g){if(!et.isUndefined(j)){if(m.indexOf(j)!==-1)throw Error("Circular reference detected in "+g.join("."));m.push(j),et.forEach(j,function(N,S){(!(et.isUndefined(N)||N===null)&&a.call(s,N,et.isString(S)?S.trim():S,g,p))===!0&&u(N,g?g.concat(S):[S])}),m.pop()}}if(!et.isObject(t))throw new TypeError("data must be an object");return u(t),s}function DN(t){const s={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return s[r]})}function Mv(t,s){this._pairs=[],t&&Hm(t,this,s)}const $C=Mv.prototype;$C.append=function(s,n){this._pairs.push([s,n])};$C.toString=function(s){const n=s?function(r){return s.call(this,r,DN)}:DN;return this._pairs.map(function(a){return n(a[0])+"="+n(a[1])},"").join("&")};function Y_(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function qC(t,s,n){if(!s)return t;const r=n&&n.encode||Y_,a=et.isFunction(n)?{serialize:n}:n,l=a&&a.serialize;let c;if(l?c=l(s,a):c=et.isURLSearchParams(s)?s.toString():new Mv(s,a).toString(r),c){const d=t.indexOf("#");d!==-1&&(t=t.slice(0,d)),t+=(t.indexOf("?")===-1?"?":"&")+c}return t}class TN{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){et.forEach(this.handlers,function(r){r!==null&&s(r)})}}const Fv={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Z_=typeof URLSearchParams<"u"?URLSearchParams:Mv,Q_=typeof FormData<"u"?FormData:null,X_=typeof Blob<"u"?Blob:null,J_={isBrowser:!0,classes:{URLSearchParams:Z_,FormData:Q_,Blob:X_},protocols:["http","https","file","blob","url","data"]},Bv=typeof window<"u"&&typeof document<"u",K0=typeof navigator=="object"&&navigator||void 0,eO=Bv&&(!K0||["ReactNative","NativeScript","NS"].indexOf(K0.product)<0),tO=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",sO=Bv&&window.location.href||"http://localhost",nO=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Bv,hasStandardBrowserEnv:eO,hasStandardBrowserWebWorkerEnv:tO,navigator:K0,origin:sO},Symbol.toStringTag,{value:"Module"})),Ar={...nO,...J_};function rO(t,s){return Hm(t,new Ar.classes.URLSearchParams,{visitor:function(n,r,a,l){return Ar.isNode&&et.isBuffer(n)?(this.append(r,n.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...s})}function aO(t){return et.matchAll(/\w+|\[(\w*)]/g,t).map(s=>s[0]==="[]"?"":s[1]||s[0])}function iO(t){const s={},n=Object.keys(t);let r;const a=n.length;let l;for(r=0;r<a;r++)l=n[r],s[l]=t[l];return s}function zC(t){function s(n,r,a,l){let c=n[l++];if(c==="__proto__")return!0;const d=Number.isFinite(+c),h=l>=n.length;return c=!c&&et.isArray(a)?a.length:c,h?(et.hasOwnProp(a,c)?a[c]=[a[c],r]:a[c]=r,!d):((!a[c]||!et.isObject(a[c]))&&(a[c]=[]),s(n,r,a[c],l)&&et.isArray(a[c])&&(a[c]=iO(a[c])),!d)}if(et.isFormData(t)&&et.isFunction(t.entries)){const n={};return et.forEachEntry(t,(r,a)=>{s(aO(r),a,n,0)}),n}return null}function lO(t,s,n){if(et.isString(t))try{return(s||JSON.parse)(t),et.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}const lu={transitional:Fv,adapter:["xhr","http","fetch"],transformRequest:[function(s,n){const r=n.getContentType()||"",a=r.indexOf("application/json")>-1,l=et.isObject(s);if(l&&et.isHTMLForm(s)&&(s=new FormData(s)),et.isFormData(s))return a?JSON.stringify(zC(s)):s;if(et.isArrayBuffer(s)||et.isBuffer(s)||et.isStream(s)||et.isFile(s)||et.isBlob(s)||et.isReadableStream(s))return s;if(et.isArrayBufferView(s))return s.buffer;if(et.isURLSearchParams(s))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),s.toString();let d;if(l){if(r.indexOf("application/x-www-form-urlencoded")>-1)return rO(s,this.formSerializer).toString();if((d=et.isFileList(s))||r.indexOf("multipart/form-data")>-1){const h=this.env&&this.env.FormData;return Hm(d?{"files[]":s}:s,h&&new h,this.formSerializer)}}return l||a?(n.setContentType("application/json",!1),lO(s)):s}],transformResponse:[function(s){const n=this.transitional||lu.transitional,r=n&&n.forcedJSONParsing,a=this.responseType==="json";if(et.isResponse(s)||et.isReadableStream(s))return s;if(s&&et.isString(s)&&(r&&!this.responseType||a)){const c=!(n&&n.silentJSONParsing)&&a;try{return JSON.parse(s,this.parseReviver)}catch(d){if(c)throw d.name==="SyntaxError"?As.from(d,As.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:Ar.classes.FormData,Blob:Ar.classes.Blob},validateStatus:function(s){return s>=200&&s<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};et.forEach(["delete","get","head","post","put","patch"],t=>{lu.headers[t]={}});const oO=et.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"]),cO=t=>{const s={};let n,r,a;return t&&t.split(`
`).forEach(function(c){a=c.indexOf(":"),n=c.substring(0,a).trim().toLowerCase(),r=c.substring(a+1).trim(),!(!n||s[n]&&oO[n])&&(n==="set-cookie"?s[n]?s[n].push(r):s[n]=[r]:s[n]=s[n]?s[n]+", "+r:r)}),s},PN=Symbol("internals");function bd(t){return t&&String(t).trim().toLowerCase()}function Yh(t){return t===!1||t==null?t:et.isArray(t)?t.map(Yh):String(t)}function dO(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 uO=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function jx(t,s,n,r,a){if(et.isFunction(r))return r.call(this,s,n);if(a&&(s=n),!!et.isString(s)){if(et.isString(r))return s.indexOf(r)!==-1;if(et.isRegExp(r))return r.test(s)}}function hO(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(s,n,r)=>n.toUpperCase()+r)}function mO(t,s){const n=et.toCamelCase(" "+s);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{value:function(a,l,c){return this[r].call(this,s,a,l,c)},configurable:!0})})}let Jr=class{constructor(s){s&&this.set(s)}set(s,n,r){const a=this;function l(d,h,x){const f=bd(h);if(!f)throw new Error("header name must be a non-empty string");const m=et.findKey(a,f);(!m||a[m]===void 0||x===!0||x===void 0&&a[m]!==!1)&&(a[m||h]=Yh(d))}const c=(d,h)=>et.forEach(d,(x,f)=>l(x,f,h));if(et.isPlainObject(s)||s instanceof this.constructor)c(s,n);else if(et.isString(s)&&(s=s.trim())&&!uO(s))c(cO(s),n);else if(et.isObject(s)&&et.isIterable(s)){let d={},h,x;for(const f of s){if(!et.isArray(f))throw TypeError("Object iterator must return a key-value pair");d[x=f[0]]=(h=d[x])?et.isArray(h)?[...h,f[1]]:[h,f[1]]:f[1]}c(d,n)}else s!=null&&l(n,s,r);return this}get(s,n){if(s=bd(s),s){const r=et.findKey(this,s);if(r){const a=this[r];if(!n)return a;if(n===!0)return dO(a);if(et.isFunction(n))return n.call(this,a,r);if(et.isRegExp(n))return n.exec(a);throw new TypeError("parser must be boolean|regexp|function")}}}has(s,n){if(s=bd(s),s){const r=et.findKey(this,s);return!!(r&&this[r]!==void 0&&(!n||jx(this,this[r],r,n)))}return!1}delete(s,n){const r=this;let a=!1;function l(c){if(c=bd(c),c){const d=et.findKey(r,c);d&&(!n||jx(r,r[d],d,n))&&(delete r[d],a=!0)}}return et.isArray(s)?s.forEach(l):l(s),a}clear(s){const n=Object.keys(this);let r=n.length,a=!1;for(;r--;){const l=n[r];(!s||jx(this,this[l],l,s,!0))&&(delete this[l],a=!0)}return a}normalize(s){const n=this,r={};return et.forEach(this,(a,l)=>{const c=et.findKey(r,l);if(c){n[c]=Yh(a),delete n[l];return}const d=s?hO(l):String(l).trim();d!==l&&delete n[l],n[d]=Yh(a),r[d]=!0}),this}concat(...s){return this.constructor.concat(this,...s)}toJSON(s){const n=Object.create(null);return et.forEach(this,(r,a)=>{r!=null&&r!==!1&&(n[a]=s&&et.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[PN]=this[PN]={accessors:{}}).accessors,a=this.prototype;function l(c){const d=bd(c);r[d]||(mO(a,c),r[d]=!0)}return et.isArray(s)?s.forEach(l):l(s),this}};Jr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);et.reduceDescriptors(Jr.prototype,({value:t},s)=>{let n=s[0].toUpperCase()+s.slice(1);return{get:()=>t,set(r){this[n]=r}}});et.freezeMethods(Jr);function Nx(t,s){const n=this||lu,r=s||n,a=Jr.from(r.headers);let l=r.data;return et.forEach(t,function(d){l=d.call(n,l,a.normalize(),s?s.status:void 0)}),a.normalize(),l}function UC(t){return!!(t&&t.__CANCEL__)}let ou=class extends As{constructor(s,n,r){super(s??"canceled",As.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}};function VC(t,s,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):s(new As("Request failed with status code "+n.status,[As.ERR_BAD_REQUEST,As.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function fO(t){const s=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return s&&s[1]||""}function pO(t,s){t=t||10;const n=new Array(t),r=new Array(t);let a=0,l=0,c;return s=s!==void 0?s:1e3,function(h){const x=Date.now(),f=r[l];c||(c=x),n[a]=h,r[a]=x;let m=l,p=0;for(;m!==a;)p+=n[m++],m=m%t;if(a=(a+1)%t,a===l&&(l=(l+1)%t),x-c<s)return;const u=f&&x-f;return u?Math.round(p*1e3/u):void 0}}function xO(t,s){let n=0,r=1e3/s,a,l;const c=(x,f=Date.now())=>{n=f,a=null,l&&(clearTimeout(l),l=null),t(...x)};return[(...x)=>{const f=Date.now(),m=f-n;m>=r?c(x,f):(a=x,l||(l=setTimeout(()=>{l=null,c(a)},r-m)))},()=>a&&c(a)]}const xm=(t,s,n=3)=>{let r=0;const a=pO(50,250);return xO(l=>{const c=l.loaded,d=l.lengthComputable?l.total:void 0,h=c-r,x=a(h),f=c<=d;r=c;const m={loaded:c,total:d,progress:d?c/d:void 0,bytes:h,rate:x||void 0,estimated:x&&d&&f?(d-c)/x:void 0,event:l,lengthComputable:d!=null,[s?"download":"upload"]:!0};t(m)},n)},_N=(t,s)=>{const n=t!=null;return[r=>s[0]({lengthComputable:n,total:t,loaded:r}),s[1]]},ON=t=>(...s)=>et.asap(()=>t(...s)),gO=Ar.hasStandardBrowserEnv?((t,s)=>n=>(n=new URL(n,Ar.origin),t.protocol===n.protocol&&t.host===n.host&&(s||t.port===n.port)))(new URL(Ar.origin),Ar.navigator&&/(msie|trident)/i.test(Ar.navigator.userAgent)):()=>!0,vO=Ar.hasStandardBrowserEnv?{write(t,s,n,r,a,l,c){if(typeof document>"u")return;const d=[`${t}=${encodeURIComponent(s)}`];et.isNumber(n)&&d.push(`expires=${new Date(n).toUTCString()}`),et.isString(r)&&d.push(`path=${r}`),et.isString(a)&&d.push(`domain=${a}`),l===!0&&d.push("secure"),et.isString(c)&&d.push(`SameSite=${c}`),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 bO(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function yO(t,s){return s?t.replace(/\/?\/$/,"")+"/"+s.replace(/^\/+/,""):t}function HC(t,s,n){let r=!bO(s);return t&&(r||n==!1)?yO(t,s):s}const IN=t=>t instanceof Jr?{...t}:t;function Mo(t,s){s=s||{};const n={};function r(x,f,m,p){return et.isPlainObject(x)&&et.isPlainObject(f)?et.merge.call({caseless:p},x,f):et.isPlainObject(f)?et.merge({},f):et.isArray(f)?f.slice():f}function a(x,f,m,p){if(et.isUndefined(f)){if(!et.isUndefined(x))return r(void 0,x,m,p)}else return r(x,f,m,p)}function l(x,f){if(!et.isUndefined(f))return r(void 0,f)}function c(x,f){if(et.isUndefined(f)){if(!et.isUndefined(x))return r(void 0,x)}else return r(void 0,f)}function d(x,f,m){if(m in s)return r(x,f);if(m in t)return r(void 0,x)}const h={url:l,method:l,data:l,baseURL:c,transformRequest:c,transformResponse:c,paramsSerializer:c,timeout:c,timeoutMessage:c,withCredentials:c,withXSRFToken:c,adapter:c,responseType:c,xsrfCookieName:c,xsrfHeaderName:c,onUploadProgress:c,onDownloadProgress:c,decompress:c,maxContentLength:c,maxBodyLength:c,beforeRedirect:c,transport:c,httpAgent:c,httpsAgent:c,cancelToken:c,socketPath:c,responseEncoding:c,validateStatus:d,headers:(x,f,m)=>a(IN(x),IN(f),m,!0)};return et.forEach(Object.keys({...t,...s}),function(f){if(f==="__proto__"||f==="constructor"||f==="prototype")return;const m=et.hasOwnProp(h,f)?h[f]:a,p=m(t[f],s[f],f);et.isUndefined(p)&&m!==d||(n[f]=p)}),n}const WC=t=>{const s=Mo({},t);let{data:n,withXSRFToken:r,xsrfHeaderName:a,xsrfCookieName:l,headers:c,auth:d}=s;if(s.headers=c=Jr.from(c),s.url=qC(HC(s.baseURL,s.url,s.allowAbsoluteUrls),t.params,t.paramsSerializer),d&&c.set("Authorization","Basic "+btoa((d.username||"")+":"+(d.password?unescape(encodeURIComponent(d.password)):""))),et.isFormData(n)){if(Ar.hasStandardBrowserEnv||Ar.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if(et.isFunction(n.getHeaders)){const h=n.getHeaders(),x=["content-type","content-length"];Object.entries(h).forEach(([f,m])=>{x.includes(f.toLowerCase())&&c.set(f,m)})}}if(Ar.hasStandardBrowserEnv&&(r&&et.isFunction(r)&&(r=r(s)),r||r!==!1&&gO(s.url))){const h=a&&l&&vO.read(l);h&&c.set(a,h)}return s},jO=typeof XMLHttpRequest<"u",NO=jO&&function(t){return new Promise(function(n,r){const a=WC(t);let l=a.data;const c=Jr.from(a.headers).normalize();let{responseType:d,onUploadProgress:h,onDownloadProgress:x}=a,f,m,p,u,j;function g(){u&&u(),j&&j(),a.cancelToken&&a.cancelToken.unsubscribe(f),a.signal&&a.signal.removeEventListener("abort",f)}let y=new XMLHttpRequest;y.open(a.method.toUpperCase(),a.url,!0),y.timeout=a.timeout;function N(){if(!y)return;const C=Jr.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),R={data:!d||d==="text"||d==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:C,config:t,request:y};VC(function(A){n(A),g()},function(A){r(A),g()},R),y=null}"onloadend"in y?y.onloadend=N:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(N)},y.onabort=function(){y&&(r(new As("Request aborted",As.ECONNABORTED,t,y)),y=null)},y.onerror=function(w){const R=w&&w.message?w.message:"Network Error",P=new As(R,As.ERR_NETWORK,t,y);P.event=w||null,r(P),y=null},y.ontimeout=function(){let w=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const R=a.transitional||Fv;a.timeoutErrorMessage&&(w=a.timeoutErrorMessage),r(new As(w,R.clarifyTimeoutError?As.ETIMEDOUT:As.ECONNABORTED,t,y)),y=null},l===void 0&&c.setContentType(null),"setRequestHeader"in y&&et.forEach(c.toJSON(),function(w,R){y.setRequestHeader(R,w)}),et.isUndefined(a.withCredentials)||(y.withCredentials=!!a.withCredentials),d&&d!=="json"&&(y.responseType=a.responseType),x&&([p,j]=xm(x,!0),y.addEventListener("progress",p)),h&&y.upload&&([m,u]=xm(h),y.upload.addEventListener("progress",m),y.upload.addEventListener("loadend",u)),(a.cancelToken||a.signal)&&(f=C=>{y&&(r(!C||C.type?new ou(null,t,y):C),y.abort(),y=null)},a.cancelToken&&a.cancelToken.subscribe(f),a.signal&&(a.signal.aborted?f():a.signal.addEventListener("abort",f)));const S=fO(a.url);if(S&&Ar.protocols.indexOf(S)===-1){r(new As("Unsupported protocol "+S+":",As.ERR_BAD_REQUEST,t));return}y.send(l||null)})},wO=(t,s)=>{const{length:n}=t=t?t.filter(Boolean):[];if(s||n){let r=new AbortController,a;const l=function(x){if(!a){a=!0,d();const f=x instanceof Error?x:this.reason;r.abort(f instanceof As?f:new ou(f instanceof Error?f.message:f))}};let c=s&&setTimeout(()=>{c=null,l(new As(`timeout of ${s}ms exceeded`,As.ETIMEDOUT))},s);const d=()=>{t&&(c&&clearTimeout(c),c=null,t.forEach(x=>{x.unsubscribe?x.unsubscribe(l):x.removeEventListener("abort",l)}),t=null)};t.forEach(x=>x.addEventListener("abort",l));const{signal:h}=r;return h.unsubscribe=()=>et.asap(d),h}},SO=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},CO=async function*(t,s){for await(const n of AO(t))yield*SO(n,s)},AO=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()}},LN=(t,s,n,r)=>{const a=CO(t,s);let l=0,c,d=h=>{c||(c=!0,r&&r(h))};return new ReadableStream({async pull(h){try{const{done:x,value:f}=await a.next();if(x){d(),h.close();return}let m=f.byteLength;if(n){let p=l+=m;n(p)}h.enqueue(new Uint8Array(f))}catch(x){throw d(x),x}},cancel(h){return d(h),a.return()}},{highWaterMark:2})},MN=64*1024,{isFunction:Ch}=et,kO=(({Request:t,Response:s})=>({Request:t,Response:s}))(et.global),{ReadableStream:FN,TextEncoder:BN}=et.global,$N=(t,...s)=>{try{return!!t(...s)}catch{return!1}},RO=t=>{t=et.merge.call({skipUndefined:!0},kO,t);const{fetch:s,Request:n,Response:r}=t,a=s?Ch(s):typeof fetch=="function",l=Ch(n),c=Ch(r);if(!a)return!1;const d=a&&Ch(FN),h=a&&(typeof BN=="function"?(j=>g=>j.encode(g))(new BN):async j=>new Uint8Array(await new n(j).arrayBuffer())),x=l&&d&&$N(()=>{let j=!1;const g=new n(Ar.origin,{body:new FN,method:"POST",get duplex(){return j=!0,"half"}}).headers.has("Content-Type");return j&&!g}),f=c&&d&&$N(()=>et.isReadableStream(new r("").body)),m={stream:f&&(j=>j.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(j=>{!m[j]&&(m[j]=(g,y)=>{let N=g&&g[j];if(N)return N.call(g);throw new As(`Response type '${j}' is not supported`,As.ERR_NOT_SUPPORT,y)})});const p=async j=>{if(j==null)return 0;if(et.isBlob(j))return j.size;if(et.isSpecCompliantForm(j))return(await new n(Ar.origin,{method:"POST",body:j}).arrayBuffer()).byteLength;if(et.isArrayBufferView(j)||et.isArrayBuffer(j))return j.byteLength;if(et.isURLSearchParams(j)&&(j=j+""),et.isString(j))return(await h(j)).byteLength},u=async(j,g)=>{const y=et.toFiniteNumber(j.getContentLength());return y??p(g)};return async j=>{let{url:g,method:y,data:N,signal:S,cancelToken:C,timeout:w,onDownloadProgress:R,onUploadProgress:P,responseType:A,headers:I,withCredentials:$="same-origin",fetchOptions:T}=WC(j),E=s||fetch;A=A?(A+"").toLowerCase():"text";let _=wO([S,C&&C.toAbortSignal()],w),M=null;const q=_&&_.unsubscribe&&(()=>{_.unsubscribe()});let G;try{if(P&&x&&y!=="get"&&y!=="head"&&(G=await u(I,N))!==0){let D=new n(g,{method:"POST",body:N,duplex:"half"}),O;if(et.isFormData(N)&&(O=D.headers.get("content-type"))&&I.setContentType(O),D.body){const[V,K]=_N(G,xm(ON(P)));N=LN(D.body,MN,V,K)}}et.isString($)||($=$?"include":"omit");const Z=l&&"credentials"in n.prototype,W={...T,signal:_,method:y.toUpperCase(),headers:I.normalize().toJSON(),body:N,duplex:"half",credentials:Z?$:void 0};M=l&&new n(g,W);let z=await(l?E(M,T):E(g,W));const F=f&&(A==="stream"||A==="response");if(f&&(R||F&&q)){const D={};["status","statusText","headers"].forEach(Y=>{D[Y]=z[Y]});const O=et.toFiniteNumber(z.headers.get("content-length")),[V,K]=R&&_N(O,xm(ON(R),!0))||[];z=new r(LN(z.body,MN,V,()=>{K&&K(),q&&q()}),D)}A=A||"text";let B=await m[et.findKey(m,A)||"text"](z,j);return!F&&q&&q(),await new Promise((D,O)=>{VC(D,O,{data:B,headers:Jr.from(z.headers),status:z.status,statusText:z.statusText,config:j,request:M})})}catch(Z){throw q&&q(),Z&&Z.name==="TypeError"&&/Load failed|fetch/i.test(Z.message)?Object.assign(new As("Network Error",As.ERR_NETWORK,j,M,Z&&Z.response),{cause:Z.cause||Z}):As.from(Z,Z&&Z.code,j,M,Z&&Z.response)}}},EO=new Map,GC=t=>{let s=t&&t.env||{};const{fetch:n,Request:r,Response:a}=s,l=[r,a,n];let c=l.length,d=c,h,x,f=EO;for(;d--;)h=l[d],x=f.get(h),x===void 0&&f.set(h,x=d?new Map:RO(s)),f=x;return x};GC();const $v={http:W_,xhr:NO,fetch:{get:GC}};et.forEach($v,(t,s)=>{if(t){try{Object.defineProperty(t,"name",{value:s})}catch{}Object.defineProperty(t,"adapterName",{value:s})}});const qN=t=>`- ${t}`,DO=t=>et.isFunction(t)||t===null||t===!1;function TO(t,s){t=et.isArray(t)?t:[t];const{length:n}=t;let r,a;const l={};for(let c=0;c<n;c++){r=t[c];let d;if(a=r,!DO(r)&&(a=$v[(d=String(r)).toLowerCase()],a===void 0))throw new As(`Unknown adapter '${d}'`);if(a&&(et.isFunction(a)||(a=a.get(s))))break;l[d||"#"+c]=a}if(!a){const c=Object.entries(l).map(([h,x])=>`adapter ${h} `+(x===!1?"is not supported by the environment":"is not available in the build"));let d=n?c.length>1?`since :
`+c.map(qN).join(`
`):" "+qN(c[0]):"as no adapter specified";throw new As("There is no suitable adapter to dispatch the request "+d,"ERR_NOT_SUPPORT")}return a}const KC={getAdapter:TO,adapters:$v};function wx(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new ou(null,t)}function zN(t){return wx(t),t.headers=Jr.from(t.headers),t.data=Nx.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),KC.getAdapter(t.adapter||lu.adapter,t)(t).then(function(r){return wx(t),r.data=Nx.call(t,t.transformResponse,r),r.headers=Jr.from(r.headers),r},function(r){return UC(r)||(wx(t),r&&r.response&&(r.response.data=Nx.call(t,t.transformResponse,r.response),r.response.headers=Jr.from(r.response.headers))),Promise.reject(r)})}const YC="1.13.6",Wm={};["object","boolean","number","function","string","symbol"].forEach((t,s)=>{Wm[t]=function(r){return typeof r===t||"a"+(s<1?"n ":" ")+t}});const UN={};Wm.transitional=function(s,n,r){function a(l,c){return"[Axios v"+YC+"] Transitional option '"+l+"'"+c+(r?". "+r:"")}return(l,c,d)=>{if(s===!1)throw new As(a(c," has been removed"+(n?" in "+n:"")),As.ERR_DEPRECATED);return n&&!UN[c]&&(UN[c]=!0,console.warn(a(c," has been deprecated since v"+n+" and will be removed in the near future"))),s?s(l,c,d):!0}};Wm.spelling=function(s){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${s}`),!0)};function PO(t,s,n){if(typeof t!="object")throw new As("options must be an object",As.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let a=r.length;for(;a-- >0;){const l=r[a],c=s[l];if(c){const d=t[l],h=d===void 0||c(d,l,t);if(h!==!0)throw new As("option "+l+" must be "+h,As.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new As("Unknown option "+l,As.ERR_BAD_OPTION)}}const Zh={assertOptions:PO,validators:Wm},Sa=Zh.validators;let Oo=class{constructor(s){this.defaults=s||{},this.interceptors={request:new TN,response:new TN}}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 l=a.stack?a.stack.replace(/^.+\n/,""):"";try{r.stack?l&&!String(r.stack).endsWith(l.replace(/^.+\n.+\n/,""))&&(r.stack+=`
`+l):r.stack=l}catch{}}throw r}}_request(s,n){typeof s=="string"?(n=n||{},n.url=s):n=s||{},n=Mo(this.defaults,n);const{transitional:r,paramsSerializer:a,headers:l}=n;r!==void 0&&Zh.assertOptions(r,{silentJSONParsing:Sa.transitional(Sa.boolean),forcedJSONParsing:Sa.transitional(Sa.boolean),clarifyTimeoutError:Sa.transitional(Sa.boolean),legacyInterceptorReqResOrdering:Sa.transitional(Sa.boolean)},!1),a!=null&&(et.isFunction(a)?n.paramsSerializer={serialize:a}:Zh.assertOptions(a,{encode:Sa.function,serialize:Sa.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Zh.assertOptions(n,{baseUrl:Sa.spelling("baseURL"),withXsrfToken:Sa.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let c=l&&et.merge(l.common,l[n.method]);l&&et.forEach(["delete","get","head","post","put","patch","common"],j=>{delete l[j]}),n.headers=Jr.concat(c,l);const d=[];let h=!0;this.interceptors.request.forEach(function(g){if(typeof g.runWhen=="function"&&g.runWhen(n)===!1)return;h=h&&g.synchronous;const y=n.transitional||Fv;y&&y.legacyInterceptorReqResOrdering?d.unshift(g.fulfilled,g.rejected):d.push(g.fulfilled,g.rejected)});const x=[];this.interceptors.response.forEach(function(g){x.push(g.fulfilled,g.rejected)});let f,m=0,p;if(!h){const j=[zN.bind(this),void 0];for(j.unshift(...d),j.push(...x),p=j.length,f=Promise.resolve(n);m<p;)f=f.then(j[m++],j[m++]);return f}p=d.length;let u=n;for(;m<p;){const j=d[m++],g=d[m++];try{u=j(u)}catch(y){g.call(this,y);break}}try{f=zN.call(this,u)}catch(j){return Promise.reject(j)}for(m=0,p=x.length;m<p;)f=f.then(x[m++],x[m++]);return f}getUri(s){s=Mo(this.defaults,s);const n=HC(s.baseURL,s.url,s.allowAbsoluteUrls);return qC(n,s.params,s.paramsSerializer)}};et.forEach(["delete","get","head","options"],function(s){Oo.prototype[s]=function(n,r){return this.request(Mo(r||{},{method:s,url:n,data:(r||{}).data}))}});et.forEach(["post","put","patch"],function(s){function n(r){return function(l,c,d){return this.request(Mo(d||{},{method:s,headers:r?{"Content-Type":"multipart/form-data"}:{},url:l,data:c}))}}Oo.prototype[s]=n(),Oo.prototype[s+"Form"]=n(!0)});let _O=class ZC{constructor(s){if(typeof s!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(l){n=l});const r=this;this.promise.then(a=>{if(!r._listeners)return;let l=r._listeners.length;for(;l-- >0;)r._listeners[l](a);r._listeners=null}),this.promise.then=a=>{let l;const c=new Promise(d=>{r.subscribe(d),l=d}).then(a);return c.cancel=function(){r.unsubscribe(l)},c},s(function(l,c,d){r.reason||(r.reason=new ou(l,c,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 ZC(function(a){s=a}),cancel:s}}};function OO(t){return function(n){return t.apply(null,n)}}function IO(t){return et.isObject(t)&&t.isAxiosError===!0}const Y0={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(Y0).forEach(([t,s])=>{Y0[s]=t});function QC(t){const s=new Oo(t),n=DC(Oo.prototype.request,s);return et.extend(n,Oo.prototype,s,{allOwnKeys:!0}),et.extend(n,s,null,{allOwnKeys:!0}),n.create=function(a){return QC(Mo(t,a))},n}const On=QC(lu);On.Axios=Oo;On.CanceledError=ou;On.CancelToken=_O;On.isCancel=UC;On.VERSION=YC;On.toFormData=Hm;On.AxiosError=As;On.Cancel=On.CanceledError;On.all=function(s){return Promise.all(s)};On.spread=OO;On.isAxiosError=IO;On.mergeConfig=Mo;On.AxiosHeaders=Jr;On.formToJSON=t=>zC(et.isHTMLForm(t)?new FormData(t):t);On.getAdapter=KC.getAdapter;On.HttpStatusCode=Y0;On.default=On;const{Axios:pH,AxiosError:xH,CanceledError:gH,isCancel:vH,CancelToken:bH,VERSION:yH,all:jH,Cancel:NH,isAxiosError:wH,spread:SH,toFormData:CH,AxiosHeaders:AH,HttpStatusCode:kH,formToJSON:RH,getAdapter:EH,mergeConfig:DH}=On,VN="https://dealeronboarding-uat.royalenfield.com/api",Te={login:t=>ze.post("/auth/login",t),logout:()=>ze.post("/auth/logout"),getCurrentUser:()=>ze.get("/auth/me"),getRoles:()=>ze.get("/admin/roles"),createRole:t=>ze.post("/admin/roles",t),getPermissions:()=>ze.get("/admin/permissions"),updateRole:(t,s)=>ze.put(`/admin/roles/${t}`,s),getZones:()=>ze.get("/master/zones"),createZone:t=>ze.post("/master/zones",t),updateZone:(t,s)=>ze.put(`/master/zones/${t}`,s),createRegion:t=>ze.post("/master/regions",t),updateRegion:(t,s)=>ze.put(`/master/regions/${t}`,s),getRegions:()=>ze.get("/master/regions"),getOutlets:()=>ze.get("/outlets"),getOutletByCode:t=>ze.get(`/master/outlets/code/${t}`),getStates:t=>ze.get("/master/states",typeof t=="string"?{zoneId:t}:t),getDistricts:t=>ze.get("/master/districts",typeof t=="string"?{stateId:t}:t),getAreas:t=>ze.get("/master/areas",t),updateArea:(t,s)=>ze.put(`/master/areas/${t}`,s),createArea:t=>ze.post("/master/areas",t),getAreaManagers:()=>ze.get("/master/area-managers"),getASMs:()=>ze.get("/master/asms"),getZonalManagers:()=>ze.get("/master/zonal-managers"),saveZonalManager:t=>ze.post("/master/zonal-managers",t),getDDLeads:()=>ze.get("/master/dd-leads"),saveDDLead:t=>ze.post("/master/dd-leads",t),getManagersByRole:t=>ze.get("/master/managers",t),submitApplication:t=>ze.post("/onboarding/apply",t),exportApplicationResponses:t=>ze.get("/onboarding/applications/export-responses",t),getApplications:t=>ze.get("/onboarding/applications",t),shortlistApplications:t=>ze.post("/onboarding/applications/shortlist",t),getApplicationById:t=>ze.get(`/onboarding/applications/${t}`),updateApplication:(t,s)=>ze.put(`/onboarding/applications/${t}`,s),getLatestQuestionnaire:()=>ze.get("/questionnaire/latest"),createQuestionnaireVersion:t=>ze.post("/questionnaire/version",t),submitQuestionnaireResponse:t=>ze.post("/questionnaire/response",t),getAllQuestionnaires:()=>ze.get("/onboarding/questionnaires"),getQuestionnaireById:t=>ze.get(`/onboarding/questionnaires/${t}`),assignArchitectureTeam:(t,s)=>ze.post(`/onboarding/applications/${t}/assign-architecture`,{assignedTo:s}),updateArchitectureStatus:(t,s,n)=>ze.post(`/onboarding/applications/${t}/architecture-status`,{status:s,remarks:n}),generateDealerCodes:t=>ze.post(`/onboarding/applications/${t}/generate-codes`),updateApplicationStatus:(t,s)=>ze.put(`/onboarding/applications/${t}/status`,s),convertToOpportunity:(t,s)=>ze.post(`/onboarding/applications/${t}/convert-to-opportunity`,s),bulkConvertToOpportunity:t=>ze.post("/onboarding/applications/bulk-convert-to-opportunity",t),retriggerEvaluators:t=>ze.post(`/onboarding/applications/${t}/retrigger-evaluators`),getSecurityDeposit:t=>ze.get(`/loa/security-deposit/${t}`),updateSecurityDeposit:t=>ze.post("/loa/security-deposit",t),uploadDocument:(t,s)=>ze.post(`/onboarding/applications/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),getDocuments:t=>ze.get(`/onboarding/applications/${t}/documents`),getDocumentConfigMetadata:()=>ze.get("/onboarding/document-configs/metadata"),getDocumentConfigs:t=>ze.get("/onboarding/document-configs",t),createDocumentConfig:t=>ze.post("/onboarding/document-configs",t),updateDocumentConfig:(t,s)=>ze.put(`/onboarding/document-configs/${t}`,s),deleteDocumentConfig:t=>ze.delete(`/onboarding/document-configs/${t}`),getPublicQuestionnaire:t=>On.get(`${VN}/questionnaire/public/${t}`),submitPublicResponse:t=>On.post(`${VN}/questionnaire/public/submit`,t),getAiSummary:t=>ze.get(`/assessment/ai-summary/${t}`),scheduleInterview:t=>ze.post("/assessment/interviews",t),updateInterview:(t,s)=>ze.put(`/assessment/interviews/${t}`,s),submitEvaluation:(t,s)=>ze.post(`/assessment/interviews/${t}/evaluation`,s),submitKTMatrix:t=>ze.post("/assessment/kt-matrix",t),submitLevel2Feedback:t=>ze.post("/assessment/level2-feedback",t),getInterviews:t=>ze.get(`/assessment/interviews/${t}`),updateRecommendation:t=>ze.post("/assessment/recommendation",t),updateInterviewDecision:t=>ze.post("/assessment/decision",t),submitStageDecision:t=>ze.post("/assessment/stage-decision",t),getInterviewApprovalStatus:t=>ze.get(`/assessment/interviews/${t}/approval-status`),getApprovalPolicies:()=>ze.get("/assessment/approval-policies"),upsertApprovalPolicy:(t,s)=>ze.put(`/assessment/approval-policies/${t}`,s),getWorknotes:(t,s)=>ze.get("/collaboration/worknotes",{requestId:t,requestType:s}),addWorknote:t=>ze.post("/collaboration/worknotes",t),addParticipant:t=>ze.post("/collaboration/participants",t),removeParticipant:t=>ze.delete(`/collaboration/participants/${t}`),getUsers:t=>ze.get("/admin/users",t),createUser:t=>ze.post("/admin/users",t),updateUser:(t,s)=>ze.put(`/admin/users/${t}`,s),updateUserStatus:(t,s)=>ze.patch(`/admin/users/${t}/status`,s),deleteUser:t=>ze.delete(`/admin/users/${t}`),getDealers:t=>ze.get("/dealer",t),createDealer:t=>ze.post("/dealer",t),getDealerById:t=>ze.get(`/dealer/${t}`),updateDealer:(t,s)=>ze.put(`/dealer/${t}`,s),getDealerDashboard:()=>ze.get("/dealer/dashboard"),getDealerBankDetails:t=>ze.get(`/dealer/${t}/bank-details`),saveBankDetail:(t,s)=>ze.post(`/dealer/${t}/bank-details`,s),deleteBankDetail:t=>ze.delete(`/dealer/bank-details/${t}`),getEmailTemplates:()=>ze.get("/admin/email-templates"),getEmailTemplate:t=>ze.get(`/admin/email-templates/${t}`),createEmailTemplate:t=>ze.post("/admin/email-templates",t),updateEmailTemplate:(t,s)=>ze.put(`/admin/email-templates/${t}`,s),deleteEmailTemplate:t=>ze.delete(`/admin/email-templates/${t}`),previewEmailTemplate:t=>ze.post("/admin/email-templates/preview",t),getAuditLogs:(t,s,n=1,r=50)=>ze.get("/audit/logs",{entityType:t,entityId:s,page:n,limit:r}),getAuditSummary:(t,s)=>ze.get("/audit/summary",{entityType:t,entityId:s}),sendOtp:t=>ze.post("/prospective-login/send-otp",{phone:t}),verifyOtp:(t,s)=>ze.post("/prospective-login/verify-otp",{phone:t,otp:s}),getResignationById:t=>ze.get(`/resignation/${t}`),uploadResignationDocument:(t,s)=>ze.post(`/resignation/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),updateClearance:(t,s)=>ze.put(`/resignation/${t}/clearance`,s,{headers:s instanceof FormData?{"Content-Type":"multipart/form-data"}:{}}),updateResignationStatus:(t,s)=>ze.post(`/resignation/${t}/status`,s),getTerminationById:t=>ze.get(`/termination/${t}`),uploadTerminationDocument:(t,s)=>ze.post(`/termination/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),updateTerminationStatus:(t,s)=>ze.post(`/termination/${t}/status`,s),issueSCN:(t,s)=>ze.post(`/termination/${t}/scn`,s),uploadSCNResponse:(t,s)=>ze.post(`/termination/${t}/scn-response`,s,{headers:{"Content-Type":"multipart/form-data"}}),finalizeTermination:(t,s)=>ze.post(`/termination/${t}/finalize`,s),getResignations:t=>ze.get("/resignation",t),createResignation:t=>ze.post("/resignation",t),approveResignation:(t,s)=>ze.post(`/resignation/${t}/approve`,s),rejectResignation:(t,s)=>ze.post(`/resignation/${t}/reject`,s),withdrawResignation:(t,s)=>ze.post(`/resignation/${t}/withdraw`,{reason:s}),getTerminations:t=>ze.get("/termination",t),createTermination:t=>ze.post("/termination",t),updateTermination:(t,s)=>ze.post(`/termination/${t}/status`,s),getOnboardingPayments:()=>ze.get("/settlement/onboarding"),updatePayment:(t,s)=>ze.put(`/settlement/payments/${t}`,s),getFnFSettlements:()=>ze.get("/settlement/fnf"),getFnFSettlementById:t=>ze.get(`/settlement/fnf/${t}`),calculateFnF:t=>ze.post(`/settlement/fnf/${t}/calculate`),updateFnF:(t,s)=>ze.put(`/settlement/fnf/${t}`,s),uploadFnFDocument:(t,s)=>ze.post(`/settlement/fnf/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),getSettlementDepartments:()=>ze.get("/settlement/departments"),addLineItem:(t,s)=>ze.post(`/settlement/fnf/${t}/line-items`,s),updateFnFClearance:(t,s,n)=>ze.put(`/settlement/fnf/${t}/clearances/${s}`,n,{headers:{"Content-Type":"multipart/form-data"}}),updateLineItem:(t,s)=>ze.put(`/settlement/fnf/line-items/${t}`,s),deleteLineItem:t=>ze.delete(`/settlement/fnf/line-items/${t}`),getRelocationRequests:t=>ze.get("/relocation",t),getRelocationRequestById:t=>ze.get(`/relocation/${t}`),createRelocationRequest:t=>ze.post("/relocation",t),updateRelocationRequest:(t,s,n)=>ze.post(`/relocation/${t}/action`,{action:s,...n}),uploadRelocationDocument:(t,s)=>ze.post(`/relocation/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),verifyRelocationDocument:(t,s)=>ze.post(`/relocation/${t}/documents/${s}/verify`),rejectRelocationDocument:(t,s,n)=>ze.post(`/relocation/${t}/documents/${s}/reject`,n||{}),getConstitutionalChanges:t=>ze.get("/constitutional-change",t),getConstitutionalChangeMeta:()=>ze.get("/constitutional-change/meta"),getConstitutionalChangeById:t=>ze.get(`/constitutional-change/${t}`),createConstitutionalChange:t=>ze.post("/constitutional-change",t),updateConstitutionalChange:(t,s,n)=>ze.post(`/constitutional-change/${t}/action`,{action:s,...n}),uploadConstitutionalDocuments:(t,s)=>ze.post(`/constitutional-change/${t}/documents`,{documents:s}),getSlaConfigs:()=>ze.get("/master/sla-configs"),saveSlaConfig:t=>ze.post("/master/sla-configs",t),initializeDefaultSlas:()=>ze.post("/master/sla-configs/initialize"),getInterviewConfigs:t=>ze.get("/master/interview-configs",t),getInterviewConfigById:t=>ze.get(`/master/interview-configs/${t}`),getInterviewConfigByType:t=>ze.get(`/master/interview-configs/active/${t}`),createInterviewConfig:t=>ze.post("/master/interview-configs",t),updateInterviewConfig:(t,s)=>ze.put(`/master/interview-configs/${t}`,s),deleteInterviewConfig:t=>ze.delete(`/master/interview-configs/${t}`),initializeDefaultInterviewConfigs:()=>ze.post("/master/interview-configs/initialize"),getSystemConfigs:t=>ze.get("/master/system-configs",t),saveSystemConfig:t=>ze.post("/master/system-configs",t),getDealerAsmMappings:()=>ze.get("/master/dealer-asm-mappings"),saveDealerAsmMapping:t=>ze.post("/master/dealer-asm-mappings",t),getEorChecklistForApplication:t=>ze.get(`/eor/application/${t}`),getEorChecklistForRelocation:t=>ze.get(`/eor/relocation/${t}`),updateEorChecklistItem:(t,s)=>ze.post(`/eor/item/${t}`,s),submitEorAudit:(t,s)=>ze.post(`/eor/audit/${t}`,s),submitFddReport:t=>ze.post("/fdd/report",t),getFddAssignment:t=>ze.get(`/fdd/${t}`),assignFddAgency:t=>ze.post("/fdd/assign",t),flagNonResponsive:t=>ze.post("/flag",t)},Pd=Object.freeze(Object.defineProperty({__proto__:null,API:Te,default:Te},Symbol.toStringTag,{value:"Module"})),LO={user:null,token:localStorage.getItem("token"),isAuthenticated:!1,loading:!0,error:null},Qh=zP("auth/initializeAuth",async(t,{rejectWithValue:s})=>{const n=localStorage.getItem("token");if(!n)return s("No token found");try{const r=await Te.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")}}),XC=EC({name:"auth",initialState:LO,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(Qh.pending,s=>{s.loading=!0}).addCase(Qh.fulfilled,(s,n)=>{s.user=n.payload.user,s.token=n.payload.token,s.isAuthenticated=!0,s.loading=!1}).addCase(Qh.rejected,s=>{s.user=null,s.token=null,s.isAuthenticated=!1,s.loading=!1,localStorage.removeItem("token")})}}),{setCredentials:JC,logout:e2,setLoading:TH}=XC.actions,MO=XC.reducer,FO={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},t2=EC({name:"master",initialState:FO,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:s2,setZones:PH,setRegionalOffices:_H,setAsms:OH,setZonalManagerMappings:IH,setUsers:LH,setLoading:HN,setError:BO,setAreasData:$O,setAreasLoading:WN,setDdLeads:MH}=t2.actions,qO=t2.reducer,zO=_P({reducer:{auth:MO,master:qO}});var cu=Dv();const qv=_m(cu);/**
* @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 Gd(){return Gd=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},Gd.apply(this,arguments)}var Dl;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(Dl||(Dl={}));const GN="popstate";function UO(t){t===void 0&&(t={});function s(r,a){let{pathname:l,search:c,hash:d}=r.location;return Z0("",{pathname:l,search:c,hash:d},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function n(r,a){return typeof a=="string"?a:n2(a)}return HO(s,n,null,t)}function Yn(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function zv(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function VO(){return Math.random().toString(36).substr(2,8)}function KN(t,s){return{usr:t.state,key:t.key,idx:s}}function Z0(t,s,n,r){return n===void 0&&(n=null),Gd({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?Fc(s):s,{state:n,key:s&&s.key||r||VO()})}function n2(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 Fc(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 HO(t,s,n,r){r===void 0&&(r={});let{window:a=document.defaultView,v5Compat:l=!1}=r,c=a.history,d=Dl.Pop,h=null,x=f();x==null&&(x=0,c.replaceState(Gd({},c.state,{idx:x}),""));function f(){return(c.state||{idx:null}).idx}function m(){d=Dl.Pop;let y=f(),N=y==null?null:y-x;x=y,h&&h({action:d,location:g.location,delta:N})}function p(y,N){d=Dl.Push;let S=Z0(g.location,y,N);x=f()+1;let C=KN(S,x),w=g.createHref(S);try{c.pushState(C,"",w)}catch(R){if(R instanceof DOMException&&R.name==="DataCloneError")throw R;a.location.assign(w)}l&&h&&h({action:d,location:g.location,delta:1})}function u(y,N){d=Dl.Replace;let S=Z0(g.location,y,N);x=f();let C=KN(S,x),w=g.createHref(S);c.replaceState(C,"",w),l&&h&&h({action:d,location:g.location,delta:0})}function j(y){let N=a.location.origin!=="null"?a.location.origin:a.location.href,S=typeof y=="string"?y:n2(y);return S=S.replace(/ $/,"%20"),Yn(N,"No window.location.(origin|href) available to create URL for href: "+S),new URL(S,N)}let g={get action(){return d},get location(){return t(a,c)},listen(y){if(h)throw new Error("A history only accepts one active listener");return a.addEventListener(GN,m),h=y,()=>{a.removeEventListener(GN,m),h=null}},createHref(y){return s(a,y)},createURL:j,encodeLocation(y){let N=j(y);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:p,replace:u,go(y){return c.go(y)}};return g}var YN;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(YN||(YN={}));function WO(t,s,n){return n===void 0&&(n="/"),GO(t,s,n)}function GO(t,s,n,r){let a=typeof s=="string"?Fc(s):s,l=i2(a.pathname||"/",n);if(l==null)return null;let c=r2(t);KO(c);let d=null;for(let h=0;d==null&&h<c.length;++h){let x=i4(l);d=n4(c[h],x)}return d}function r2(t,s,n,r){s===void 0&&(s=[]),n===void 0&&(n=[]),r===void 0&&(r="");let a=(l,c,d)=>{let h={relativePath:d===void 0?l.path||"":d,caseSensitive:l.caseSensitive===!0,childrenIndex:c,route:l};h.relativePath.startsWith("/")&&(Yn(h.relativePath.startsWith(r),'Absolute route path "'+h.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),h.relativePath=h.relativePath.slice(r.length));let x=Io([r,h.relativePath]),f=n.concat(h);l.children&&l.children.length>0&&(Yn(l.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+x+'".')),r2(l.children,s,f,x)),!(l.path==null&&!l.index)&&s.push({path:x,score:t4(x,l.index),routesMeta:f})};return t.forEach((l,c)=>{var d;if(l.path===""||!((d=l.path)!=null&&d.includes("?")))a(l,c);else for(let h of a2(l.path))a(l,c,h)}),s}function a2(t){let s=t.split("/");if(s.length===0)return[];let[n,...r]=s,a=n.endsWith("?"),l=n.replace(/\?$/,"");if(r.length===0)return a?[l,""]:[l];let c=a2(r.join("/")),d=[];return d.push(...c.map(h=>h===""?l:[l,h].join("/"))),a&&d.push(...c),d.map(h=>t.startsWith("/")&&h===""?"/":h)}function KO(t){t.sort((s,n)=>s.score!==n.score?n.score-s.score:s4(s.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const YO=/^:[\w-]+$/,ZO=3,QO=2,XO=1,JO=10,e4=-2,ZN=t=>t==="*";function t4(t,s){let n=t.split("/"),r=n.length;return n.some(ZN)&&(r+=e4),s&&(r+=QO),n.filter(a=>!ZN(a)).reduce((a,l)=>a+(YO.test(l)?ZO:l===""?XO:JO),r)}function s4(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 n4(t,s,n){let{routesMeta:r}=t,a={},l="/",c=[];for(let d=0;d<r.length;++d){let h=r[d],x=d===r.length-1,f=l==="/"?s:s.slice(l.length)||"/",m=r4({path:h.relativePath,caseSensitive:h.caseSensitive,end:x},f),p=h.route;if(!m)return null;Object.assign(a,m.params),c.push({params:a,pathname:Io([l,m.pathname]),pathnameBase:u4(Io([l,m.pathnameBase])),route:p}),m.pathnameBase!=="/"&&(l=Io([l,m.pathnameBase]))}return c}function r4(t,s){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=a4(t.path,t.caseSensitive,t.end),a=s.match(n);if(!a)return null;let l=a[0],c=l.replace(/(.)\/+$/,"$1"),d=a.slice(1);return{params:r.reduce((x,f,m)=>{let{paramName:p,isOptional:u}=f;if(p==="*"){let g=d[m]||"";c=l.slice(0,l.length-g.length).replace(/(.)\/+$/,"$1")}const j=d[m];return u&&!j?x[p]=void 0:x[p]=(j||"").replace(/%2F/g,"/"),x},{}),pathname:l,pathnameBase:c,pattern:t}}function a4(t,s,n){s===void 0&&(s=!1),n===void 0&&(n=!0),zv(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,(c,d,h)=>(r.push({paramName:d,isOptional:h!=null}),h?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(r.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,s?void 0:"i"),r]}function i4(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return zv(!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 i2(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 l4=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,o4=t=>l4.test(t);function c4(t,s){s===void 0&&(s="/");let{pathname:n,search:r="",hash:a=""}=typeof t=="string"?Fc(t):t,l;if(n)if(o4(n))l=n;else{if(n.includes("//")){let c=n;n=n.replace(/\/\/+/g,"/"),zv(!1,"Pathnames cannot have embedded double slashes - normalizing "+(c+" -> "+n))}n.startsWith("/")?l=QN(n.substring(1),"/"):l=QN(n,s)}else l=s;return{pathname:l,search:h4(r),hash:m4(a)}}function QN(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 Sx(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 d4(t){return t.filter((s,n)=>n===0||s.route.path&&s.route.path.length>0)}function l2(t,s){let n=d4(t);return s?n.map((r,a)=>a===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function o2(t,s,n,r){r===void 0&&(r=!1);let a;typeof t=="string"?a=Fc(t):(a=Gd({},t),Yn(!a.pathname||!a.pathname.includes("?"),Sx("?","pathname","search",a)),Yn(!a.pathname||!a.pathname.includes("#"),Sx("#","pathname","hash",a)),Yn(!a.search||!a.search.includes("#"),Sx("#","search","hash",a)));let l=t===""||a.pathname==="",c=l?"/":a.pathname,d;if(c==null)d=n;else{let m=s.length-1;if(!r&&c.startsWith("..")){let p=c.split("/");for(;p[0]==="..";)p.shift(),m-=1;a.pathname=p.join("/")}d=m>=0?s[m]:"/"}let h=c4(a,d),x=c&&c!=="/"&&c.endsWith("/"),f=(l||c===".")&&n.endsWith("/");return!h.pathname.endsWith("/")&&(x||f)&&(h.pathname+="/"),h}const Io=t=>t.join("/").replace(/\/\/+/g,"/"),u4=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),h4=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,m4=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function f4(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const c2=["post","put","patch","delete"];new Set(c2);const p4=["get",...c2];new Set(p4);/**
* 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 Kd(){return Kd=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},Kd.apply(this,arguments)}const Uv=v.createContext(null),x4=v.createContext(null),du=v.createContext(null),Gm=v.createContext(null),Ji=v.createContext({outlet:null,matches:[],isDataRoute:!1}),d2=v.createContext(null);function uu(){return v.useContext(Gm)!=null}function Ul(){return uu()||Yn(!1),v.useContext(Gm).location}function u2(t){v.useContext(du).static||v.useLayoutEffect(t)}function qn(){let{isDataRoute:t}=v.useContext(Ji);return t?T4():g4()}function g4(){uu()||Yn(!1);let t=v.useContext(Uv),{basename:s,future:n,navigator:r}=v.useContext(du),{matches:a}=v.useContext(Ji),{pathname:l}=Ul(),c=JSON.stringify(l2(a,n.v7_relativeSplatPath)),d=v.useRef(!1);return u2(()=>{d.current=!0}),v.useCallback(function(x,f){if(f===void 0&&(f={}),!d.current)return;if(typeof x=="number"){r.go(x);return}let m=o2(x,JSON.parse(c),l,f.relative==="path");t==null&&s!=="/"&&(m.pathname=m.pathname==="/"?s:Io([s,m.pathname])),(f.replace?r.replace:r.push)(m,f.state,f)},[s,r,c,l,t])}const v4=v.createContext(null);function b4(t){let s=v.useContext(Ji).outlet;return s&&v.createElement(v4.Provider,{value:t},s)}function Bc(){let{matches:t}=v.useContext(Ji),s=t[t.length-1];return s?s.params:{}}function y4(t,s){return j4(t,s)}function j4(t,s,n,r){uu()||Yn(!1);let{navigator:a}=v.useContext(du),{matches:l}=v.useContext(Ji),c=l[l.length-1],d=c?c.params:{};c&&c.pathname;let h=c?c.pathnameBase:"/";c&&c.route;let x=Ul(),f;if(s){var m;let y=typeof s=="string"?Fc(s):s;h==="/"||(m=y.pathname)!=null&&m.startsWith(h)||Yn(!1),f=y}else f=x;let p=f.pathname||"/",u=p;if(h!=="/"){let y=h.replace(/^\//,"").split("/");u="/"+p.replace(/^\//,"").split("/").slice(y.length).join("/")}let j=WO(t,{pathname:u}),g=A4(j&&j.map(y=>Object.assign({},y,{params:Object.assign({},d,y.params),pathname:Io([h,a.encodeLocation?a.encodeLocation(y.pathname).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?h:Io([h,a.encodeLocation?a.encodeLocation(y.pathnameBase).pathname:y.pathnameBase])})),l,n,r);return s&&g?v.createElement(Gm.Provider,{value:{location:Kd({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:Dl.Pop}},g):g}function N4(){let t=D4(),s=f4(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 v.createElement(v.Fragment,null,v.createElement("h2",null,"Unexpected Application Error!"),v.createElement("h3",{style:{fontStyle:"italic"}},s),n?v.createElement("pre",{style:a},n):null,null)}const w4=v.createElement(N4,null);class S4 extends v.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?v.createElement(Ji.Provider,{value:this.props.routeContext},v.createElement(d2.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function C4(t){let{routeContext:s,match:n,children:r}=t,a=v.useContext(Uv);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),v.createElement(Ji.Provider,{value:s},r)}function A4(t,s,n,r){var a;if(s===void 0&&(s=[]),n===void 0&&(n=null),r===void 0&&(r=null),t==null){var l;if(!n)return null;if(n.errors)t=n.matches;else if((l=r)!=null&&l.v7_partialHydration&&s.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let c=t,d=(a=n)==null?void 0:a.errors;if(d!=null){let f=c.findIndex(m=>m.route.id&&(d==null?void 0:d[m.route.id])!==void 0);f>=0||Yn(!1),c=c.slice(0,Math.min(c.length,f+1))}let h=!1,x=-1;if(n&&r&&r.v7_partialHydration)for(let f=0;f<c.length;f++){let m=c[f];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(x=f),m.route.id){let{loaderData:p,errors:u}=n,j=m.route.loader&&p[m.route.id]===void 0&&(!u||u[m.route.id]===void 0);if(m.route.lazy||j){h=!0,x>=0?c=c.slice(0,x+1):c=[c[0]];break}}}return c.reduceRight((f,m,p)=>{let u,j=!1,g=null,y=null;n&&(u=d&&m.route.id?d[m.route.id]:void 0,g=m.route.errorElement||w4,h&&(x<0&&p===0?(P4("route-fallback"),j=!0,y=null):x===p&&(j=!0,y=m.route.hydrateFallbackElement||null)));let N=s.concat(c.slice(0,p+1)),S=()=>{let C;return u?C=g:j?C=y:m.route.Component?C=v.createElement(m.route.Component,null):m.route.element?C=m.route.element:C=f,v.createElement(C4,{match:m,routeContext:{outlet:f,matches:N,isDataRoute:n!=null},children:C})};return n&&(m.route.ErrorBoundary||m.route.errorElement||p===0)?v.createElement(S4,{location:n.location,revalidation:n.revalidation,component:g,error:u,children:S(),routeContext:{outlet:null,matches:N,isDataRoute:!0}}):S()},null)}var h2=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(h2||{}),m2=(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})(m2||{});function k4(t){let s=v.useContext(Uv);return s||Yn(!1),s}function R4(t){let s=v.useContext(x4);return s||Yn(!1),s}function E4(t){let s=v.useContext(Ji);return s||Yn(!1),s}function f2(t){let s=E4(),n=s.matches[s.matches.length-1];return n.route.id||Yn(!1),n.route.id}function D4(){var t;let s=v.useContext(d2),n=R4(),r=f2();return s!==void 0?s:(t=n.errors)==null?void 0:t[r]}function T4(){let{router:t}=k4(h2.UseNavigateStable),s=f2(m2.UseNavigateStable),n=v.useRef(!1);return u2(()=>{n.current=!0}),v.useCallback(function(a,l){l===void 0&&(l={}),n.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,Kd({fromRouteId:s},l)))},[t,s])}const XN={};function P4(t,s,n){XN[t]||(XN[t]=!0)}function _4(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Mn(t){let{to:s,replace:n,state:r,relative:a}=t;uu()||Yn(!1);let{future:l,static:c}=v.useContext(du),{matches:d}=v.useContext(Ji),{pathname:h}=Ul(),x=qn(),f=o2(s,l2(d,l.v7_relativeSplatPath),h,a==="path"),m=JSON.stringify(f);return v.useEffect(()=>x(JSON.parse(m),{replace:n,state:r,relative:a}),[x,m,a,n,r]),null}function O4(t){return b4(t.context)}function Ns(t){Yn(!1)}function I4(t){let{basename:s="/",children:n=null,location:r,navigationType:a=Dl.Pop,navigator:l,static:c=!1,future:d}=t;uu()&&Yn(!1);let h=s.replace(/^\/*/,"/"),x=v.useMemo(()=>({basename:h,navigator:l,static:c,future:Kd({v7_relativeSplatPath:!1},d)}),[h,d,l,c]);typeof r=="string"&&(r=Fc(r));let{pathname:f="/",search:m="",hash:p="",state:u=null,key:j="default"}=r,g=v.useMemo(()=>{let y=i2(f,h);return y==null?null:{location:{pathname:y,search:m,hash:p,state:u,key:j},navigationType:a}},[h,f,m,p,u,j,a]);return g==null?null:v.createElement(du.Provider,{value:x},v.createElement(Gm.Provider,{children:n,value:g}))}function Q0(t){let{children:s,location:n}=t;return y4(X0(s),n)}new Promise(()=>{});function X0(t,s){s===void 0&&(s=[]);let n=[];return v.Children.forEach(t,(r,a)=>{if(!v.isValidElement(r))return;let l=[...s,a];if(r.type===v.Fragment){n.push.apply(n,X0(r.props.children,l));return}r.type!==Ns&&Yn(!1),!r.props.index||!r.props.children||Yn(!1);let c={id:r.props.id||l.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&&(c.children=X0(r.props.children,l)),n.push(c)}),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 L4="6";try{window.__reactRouterVersion=L4}catch{}const M4="startTransition",JN=Om[M4];function F4(t){let{basename:s,children:n,future:r,window:a}=t,l=v.useRef();l.current==null&&(l.current=UO({window:a,v5Compat:!0}));let c=l.current,[d,h]=v.useState({action:c.action,location:c.location}),{v7_startTransition:x}=r||{},f=v.useCallback(m=>{x&&JN?JN(()=>h(m)):h(m)},[h,x]);return v.useLayoutEffect(()=>c.listen(f),[c,f]),v.useEffect(()=>_4(r),[r]),v.createElement(I4,{basename:s,children:n,location:d.location,navigationType:d.action,navigator:c,future:r})}var ew;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(ew||(ew={}));var tw;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(tw||(tw={}));const sw=({children:t,allowedRoles:s,excludeRoles:n,redirectTo:r})=>{const{user:a,isAuthenticated:l,loading:c}=Nn(m=>m.auth),d=Ul(),h=String((a==null?void 0:a.role)||(a==null?void 0:a.roleCode)||"").trim().toLowerCase(),x=(s||[]).map(m=>String(m).trim().toLowerCase()),f=(n||[]).map(m=>String(m).trim().toLowerCase());return c?e.jsx("div",{className:"flex h-screen items-center justify-center",children:"Loading..."}):l?n&&a&&f.includes(h)?h==="prospective dealer"?e.jsx(Mn,{to:"/prospective-dashboard",replace:!0}):e.jsx(Mn,{to:r||"/dashboard",replace:!0}):s&&a&&!x.includes(h)?e.jsx(Mn,{to:r||"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t}):e.jsx(Mn,{to:"/admin-login",state:{from:d},replace:!0})};function nw(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function Br(...t){return s=>{let n=!1;const r=t.map(a=>{const l=nw(a,s);return!n&&typeof l=="function"&&(n=!0),l});if(n)return()=>{for(let a=0;a<r.length;a++){const l=r[a];typeof l=="function"?l():nw(t[a],null)}}}}function Ms(...t){return v.useCallback(Br(...t),t)}var B4=Symbol.for("react.lazy"),gm=Om[" use ".trim().toString()];function $4(t){return typeof t=="object"&&t!==null&&"then"in t}function p2(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===B4&&"_payload"in t&&$4(t._payload)}function hu(t){const s=q4(t),n=v.forwardRef((r,a)=>{let{children:l,...c}=r;p2(l)&&typeof gm=="function"&&(l=gm(l._payload));const d=v.Children.toArray(l),h=d.find(U4);if(h){const x=h.props.children,f=d.map(m=>m===h?v.Children.count(x)>1?v.Children.only(null):v.isValidElement(x)?x.props.children:null:m);return e.jsx(s,{...c,ref:a,children:v.isValidElement(x)?v.cloneElement(x,void 0,f):null})}return e.jsx(s,{...c,ref:a,children:l})});return n.displayName=`${t}.Slot`,n}var x2=hu("Slot");function q4(t){const s=v.forwardRef((n,r)=>{let{children:a,...l}=n;if(p2(a)&&typeof gm=="function"&&(a=gm(a._payload)),v.isValidElement(a)){const c=H4(a),d=V4(l,a.props);return a.type!==v.Fragment&&(d.ref=r?Br(r,c):c),v.cloneElement(a,d)}return v.Children.count(a)>1?v.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var z4=Symbol("radix.slottable");function U4(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===z4}function V4(t,s){const n={...s};for(const r in s){const a=t[r],l=s[r];/^on[A-Z]/.test(r)?a&&l?n[r]=(...d)=>{const h=l(...d);return a(...d),h}:a&&(n[r]=a):r==="style"?n[r]={...a,...l}:r==="className"&&(n[r]=[a,l].filter(Boolean).join(" "))}return{...t,...n}}function H4(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 g2(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=g2(t[s]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function v2(){for(var t,s,n=0,r="",a=arguments.length;n<a;n++)(t=arguments[n])&&(s=g2(t))&&(r&&(r+=" "),r+=s);return r}const rw=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,aw=v2,Vv=(t,s)=>n=>{var r;if((s==null?void 0:s.variants)==null)return aw(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:a,defaultVariants:l}=s,c=Object.keys(a).map(x=>{const f=n==null?void 0:n[x],m=l==null?void 0:l[x];if(f===null)return null;const p=rw(f)||rw(m);return a[x][p]}),d=n&&Object.entries(n).reduce((x,f)=>{let[m,p]=f;return p===void 0||(x[m]=p),x},{}),h=s==null||(r=s.compoundVariants)===null||r===void 0?void 0:r.reduce((x,f)=>{let{class:m,className:p,...u}=f;return Object.entries(u).every(j=>{let[g,y]=j;return Array.isArray(y)?y.includes({...l,...d}[g]):{...l,...d}[g]===y})?[...x,m,p]:x},[]);return aw(t,c,h,n==null?void 0:n.class,n==null?void 0:n.className)},Hv="-",W4=t=>{const s=K4(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:c=>{const d=c.split(Hv);return d[0]===""&&d.length!==1&&d.shift(),b2(d,s)||G4(c)},getConflictingClassGroupIds:(c,d)=>{const h=n[c]||[];return d&&r[c]?[...h,...r[c]]:h}}},b2=(t,s)=>{var c;if(t.length===0)return s.classGroupId;const n=t[0],r=s.nextPart.get(n),a=r?b2(t.slice(1),r):void 0;if(a)return a;if(s.validators.length===0)return;const l=t.join(Hv);return(c=s.validators.find(({validator:d})=>d(l)))==null?void 0:c.classGroupId},iw=/^\[(.+)\]$/,G4=t=>{if(iw.test(t)){const s=iw.exec(t)[1],n=s==null?void 0:s.substring(0,s.indexOf(":"));if(n)return"arbitrary.."+n}},K4=t=>{const{theme:s,prefix:n}=t,r={nextPart:new Map,validators:[]};return Z4(Object.entries(t.classGroups),n).forEach(([l,c])=>{J0(c,r,l,s)}),r},J0=(t,s,n,r)=>{t.forEach(a=>{if(typeof a=="string"){const l=a===""?s:lw(s,a);l.classGroupId=n;return}if(typeof a=="function"){if(Y4(a)){J0(a(r),s,n,r);return}s.validators.push({validator:a,classGroupId:n});return}Object.entries(a).forEach(([l,c])=>{J0(c,lw(s,l),n,r)})})},lw=(t,s)=>{let n=t;return s.split(Hv).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},Y4=t=>t.isThemeGetter,Z4=(t,s)=>s?t.map(([n,r])=>{const a=r.map(l=>typeof l=="string"?s+l:typeof l=="object"?Object.fromEntries(Object.entries(l).map(([c,d])=>[s+c,d])):l);return[n,a]}):t,Q4=t=>{if(t<1)return{get:()=>{},set:()=>{}};let s=0,n=new Map,r=new Map;const a=(l,c)=>{n.set(l,c),s++,s>t&&(s=0,r=n,n=new Map)};return{get(l){let c=n.get(l);if(c!==void 0)return c;if((c=r.get(l))!==void 0)return a(l,c),c},set(l,c){n.has(l)?n.set(l,c):a(l,c)}}},y2="!",X4=t=>{const{separator:s,experimentalParseClassName:n}=t,r=s.length===1,a=s[0],l=s.length,c=d=>{const h=[];let x=0,f=0,m;for(let y=0;y<d.length;y++){let N=d[y];if(x===0){if(N===a&&(r||d.slice(y,y+l)===s)){h.push(d.slice(f,y)),f=y+l;continue}if(N==="/"){m=y;continue}}N==="["?x++:N==="]"&&x--}const p=h.length===0?d:d.substring(f),u=p.startsWith(y2),j=u?p.substring(1):p,g=m&&m>f?m-f:void 0;return{modifiers:h,hasImportantModifier:u,baseClassName:j,maybePostfixModifierPosition:g}};return n?d=>n({className:d,parseClassName:c}):c},J4=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},e5=t=>({cache:Q4(t.cacheSize),parseClassName:X4(t),...W4(t)}),t5=/\s+/,s5=(t,s)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a}=s,l=[],c=t.trim().split(t5);let d="";for(let h=c.length-1;h>=0;h-=1){const x=c[h],{modifiers:f,hasImportantModifier:m,baseClassName:p,maybePostfixModifierPosition:u}=n(x);let j=!!u,g=r(j?p.substring(0,u):p);if(!g){if(!j){d=x+(d.length>0?" "+d:d);continue}if(g=r(p),!g){d=x+(d.length>0?" "+d:d);continue}j=!1}const y=J4(f).join(":"),N=m?y+y2:y,S=N+g;if(l.includes(S))continue;l.push(S);const C=a(g,j);for(let w=0;w<C.length;++w){const R=C[w];l.push(N+R)}d=x+(d.length>0?" "+d:d)}return d};function n5(){let t=0,s,n,r="";for(;t<arguments.length;)(s=arguments[t++])&&(n=j2(s))&&(r&&(r+=" "),r+=n);return r}const j2=t=>{if(typeof t=="string")return t;let s,n="";for(let r=0;r<t.length;r++)t[r]&&(s=j2(t[r]))&&(n&&(n+=" "),n+=s);return n};function r5(t,...s){let n,r,a,l=c;function c(h){const x=s.reduce((f,m)=>m(f),t());return n=e5(x),r=n.cache.get,a=n.cache.set,l=d,d(h)}function d(h){const x=r(h);if(x)return x;const f=s5(h,n);return a(h,f),f}return function(){return l(n5.apply(null,arguments))}}const jn=t=>{const s=n=>n[t]||[];return s.isThemeGetter=!0,s},N2=/^\[(?:([a-z-]+):)?(.+)\]$/i,a5=/^\d+\/\d+$/,i5=new Set(["px","full","screen"]),l5=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,o5=/\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$/,c5=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,d5=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,u5=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,qi=t=>wc(t)||i5.has(t)||a5.test(t),Al=t=>$c(t,"length",b5),wc=t=>!!t&&!Number.isNaN(Number(t)),Cx=t=>$c(t,"number",wc),yd=t=>!!t&&Number.isInteger(Number(t)),h5=t=>t.endsWith("%")&&wc(t.slice(0,-1)),$s=t=>N2.test(t),kl=t=>l5.test(t),m5=new Set(["length","size","percentage"]),f5=t=>$c(t,m5,w2),p5=t=>$c(t,"position",w2),x5=new Set(["image","url"]),g5=t=>$c(t,x5,j5),v5=t=>$c(t,"",y5),jd=()=>!0,$c=(t,s,n)=>{const r=N2.exec(t);return r?r[1]?typeof s=="string"?r[1]===s:s.has(r[1]):n(r[2]):!1},b5=t=>o5.test(t)&&!c5.test(t),w2=()=>!1,y5=t=>d5.test(t),j5=t=>u5.test(t),N5=()=>{const t=jn("colors"),s=jn("spacing"),n=jn("blur"),r=jn("brightness"),a=jn("borderColor"),l=jn("borderRadius"),c=jn("borderSpacing"),d=jn("borderWidth"),h=jn("contrast"),x=jn("grayscale"),f=jn("hueRotate"),m=jn("invert"),p=jn("gap"),u=jn("gradientColorStops"),j=jn("gradientColorStopPositions"),g=jn("inset"),y=jn("margin"),N=jn("opacity"),S=jn("padding"),C=jn("saturate"),w=jn("scale"),R=jn("sepia"),P=jn("skew"),A=jn("space"),I=jn("translate"),$=()=>["auto","contain","none"],T=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto",$s,s],_=()=>[$s,s],M=()=>["",qi,Al],q=()=>["auto",wc,$s],G=()=>["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"],z=()=>["start","end","center","between","around","evenly","stretch"],F=()=>["","0",$s],B=()=>["auto","avoid","all","avoid-page","page","left","right","column"],D=()=>[wc,$s];return{cacheSize:500,separator:":",theme:{colors:[jd],spacing:[qi,Al],blur:["none","",kl,$s],brightness:D(),borderColor:[t],borderRadius:["none","","full",kl,$s],borderSpacing:_(),borderWidth:M(),contrast:D(),grayscale:F(),hueRotate:D(),invert:F(),gap:_(),gradientColorStops:[t],gradientColorStopPositions:[h5,Al],inset:E(),margin:E(),opacity:D(),padding:_(),saturate:D(),scale:D(),sepia:F(),skew:D(),space:_(),translate:_()},classGroups:{aspect:[{aspect:["auto","square","video",$s]}],container:["container"],columns:[{columns:[kl]}],"break-after":[{"break-after":B()}],"break-before":[{"break-before":B()}],"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:[...G(),$s]}],overflow:[{overflow:T()}],"overflow-x":[{"overflow-x":T()}],"overflow-y":[{"overflow-y":T()}],overscroll:[{overscroll:$()}],"overscroll-x":[{"overscroll-x":$()}],"overscroll-y":[{"overscroll-y":$()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",yd,$s]}],basis:[{basis:E()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",$s]}],grow:[{grow:F()}],shrink:[{shrink:F()}],order:[{order:["first","last","none",yd,$s]}],"grid-cols":[{"grid-cols":[jd]}],"col-start-end":[{col:["auto",{span:["full",yd,$s]},$s]}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":[jd]}],"row-start-end":[{row:["auto",{span:[yd,$s]},$s]}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",$s]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",$s]}],gap:[{gap:[p]}],"gap-x":[{"gap-x":[p]}],"gap-y":[{"gap-y":[p]}],"justify-content":[{justify:["normal",...z()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...z(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...z(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[S]}],px:[{px:[S]}],py:[{py:[S]}],ps:[{ps:[S]}],pe:[{pe:[S]}],pt:[{pt:[S]}],pr:[{pr:[S]}],pb:[{pb:[S]}],pl:[{pl:[S]}],m:[{m:[y]}],mx:[{mx:[y]}],my:[{my:[y]}],ms:[{ms:[y]}],me:[{me:[y]}],mt:[{mt:[y]}],mr:[{mr:[y]}],mb:[{mb:[y]}],ml:[{ml:[y]}],"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",$s,s]}],"min-w":[{"min-w":[$s,s,"min","max","fit"]}],"max-w":[{"max-w":[$s,s,"none","full","min","max","fit","prose",{screen:[kl]},kl]}],h:[{h:[$s,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[$s,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[$s,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[$s,s,"auto","min","max","fit"]}],"font-size":[{text:["base",kl,Al]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Cx]}],"font-family":[{font:[jd]}],"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",$s]}],"line-clamp":[{"line-clamp":["none",wc,Cx]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",qi,$s]}],"list-image":[{"list-image":["none",$s]}],"list-style-type":[{list:["none","disc","decimal",$s]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[N]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[N]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Z(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",qi,Al]}],"underline-offset":[{"underline-offset":["auto",qi,$s]}],"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:_()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",$s]}],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",$s]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[N]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...G(),p5]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",f5]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},g5]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[j]}],"gradient-via-pos":[{via:[j]}],"gradient-to-pos":[{to:[j]}],"gradient-from":[{from:[u]}],"gradient-via":[{via:[u]}],"gradient-to":[{to:[u]}],rounded:[{rounded:[l]}],"rounded-s":[{"rounded-s":[l]}],"rounded-e":[{"rounded-e":[l]}],"rounded-t":[{"rounded-t":[l]}],"rounded-r":[{"rounded-r":[l]}],"rounded-b":[{"rounded-b":[l]}],"rounded-l":[{"rounded-l":[l]}],"rounded-ss":[{"rounded-ss":[l]}],"rounded-se":[{"rounded-se":[l]}],"rounded-ee":[{"rounded-ee":[l]}],"rounded-es":[{"rounded-es":[l]}],"rounded-tl":[{"rounded-tl":[l]}],"rounded-tr":[{"rounded-tr":[l]}],"rounded-br":[{"rounded-br":[l]}],"rounded-bl":[{"rounded-bl":[l]}],"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":[N]}],"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":[N]}],"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":[qi,$s]}],"outline-w":[{outline:[qi,Al]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:M()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[N]}],"ring-offset-w":[{"ring-offset":[qi,Al]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",kl,v5]}],"shadow-color":[{shadow:[jd]}],opacity:[{opacity:[N]}],"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:[h]}],"drop-shadow":[{"drop-shadow":["","none",kl,$s]}],grayscale:[{grayscale:[x]}],"hue-rotate":[{"hue-rotate":[f]}],invert:[{invert:[m]}],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":[h]}],"backdrop-grayscale":[{"backdrop-grayscale":[x]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[f]}],"backdrop-invert":[{"backdrop-invert":[m]}],"backdrop-opacity":[{"backdrop-opacity":[N]}],"backdrop-saturate":[{"backdrop-saturate":[C]}],"backdrop-sepia":[{"backdrop-sepia":[R]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[c]}],"border-spacing-x":[{"border-spacing-x":[c]}],"border-spacing-y":[{"border-spacing-y":[c]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",$s]}],duration:[{duration:D()}],ease:[{ease:["linear","in","out","in-out",$s]}],delay:[{delay:D()}],animate:[{animate:["none","spin","ping","pulse","bounce",$s]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[w]}],"scale-x":[{"scale-x":[w]}],"scale-y":[{"scale-y":[w]}],rotate:[{rotate:[yd,$s]}],"translate-x":[{"translate-x":[I]}],"translate-y":[{"translate-y":[I]}],"skew-x":[{"skew-x":[P]}],"skew-y":[{"skew-y":[P]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",$s]}],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",$s]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"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",$s]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[qi,Al,Cx]}],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"]}}},w5=r5(N5);function Pt(...t){return w5(v2(t))}function Ht(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 Km=Vv("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=v.forwardRef(({className:t,variant:s,size:n,asChild:r=!1,...a},l)=>{const c=r?x2:"button";return e.jsx(c,{"data-slot":"button",className:Pt(Km({variant:s,size:n,className:t})),ref:l,...a})});se.displayName="Button";const ot=v.forwardRef(({className:t,type:s,...n},r)=>e.jsx("input",{type:s,ref:r,"data-slot":"input",className:Pt("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}));ot.displayName="Input";function Fs({className:t,...s}){return e.jsx("textarea",{"data-slot":"textarea",className:Pt("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 S5(t,s){const n=v.createContext(s),r=l=>{const{children:c,...d}=l,h=v.useMemo(()=>d,Object.values(d));return e.jsx(n.Provider,{value:h,children:c})};r.displayName=t+"Provider";function a(l){const c=v.useContext(n);if(c)return c;if(s!==void 0)return s;throw new Error(`\`${l}\` must be used within \`${t}\``)}return[r,a]}function ea(t,s=[]){let n=[];function r(l,c){const d=v.createContext(c),h=n.length;n=[...n,c];const x=m=>{var N;const{scope:p,children:u,...j}=m,g=((N=p==null?void 0:p[t])==null?void 0:N[h])||d,y=v.useMemo(()=>j,Object.values(j));return e.jsx(g.Provider,{value:y,children:u})};x.displayName=l+"Provider";function f(m,p){var g;const u=((g=p==null?void 0:p[t])==null?void 0:g[h])||d,j=v.useContext(u);if(j)return j;if(c!==void 0)return c;throw new Error(`\`${m}\` must be used within \`${l}\``)}return[x,f]}const a=()=>{const l=n.map(c=>v.createContext(c));return function(d){const h=(d==null?void 0:d[t])||l;return v.useMemo(()=>({[`__scope${t}`]:{...d,[t]:h}}),[d,h])}};return a.scopeName=t,[r,C5(a,...s)]}function C5(...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(l){const c=r.reduce((d,{useScope:h,scopeName:x})=>{const m=h(l)[`__scope${x}`];return{...d,...m}},{});return v.useMemo(()=>({[`__scope${s.scopeName}`]:c}),[c])}};return n.scopeName=s.scopeName,n}function Vt(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 Zn=globalThis!=null&&globalThis.document?v.useLayoutEffect:()=>{},A5=Om[" useInsertionEffect ".trim().toString()]||Zn;function bi({prop:t,defaultProp:s,onChange:n=()=>{},caller:r}){const[a,l,c]=k5({defaultProp:s,onChange:n}),d=t!==void 0,h=d?t:a;{const f=v.useRef(t!==void 0);v.useEffect(()=>{const m=f.current;m!==d&&console.warn(`${r} is changing from ${m?"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.`),f.current=d},[d,r])}const x=v.useCallback(f=>{var m;if(d){const p=R5(f)?f(t):f;p!==t&&((m=c.current)==null||m.call(c,p))}else l(f)},[d,t,l,c]);return[h,x]}function k5({defaultProp:t,onChange:s}){const[n,r]=v.useState(t),a=v.useRef(n),l=v.useRef(s);return A5(()=>{l.current=s},[s]),v.useEffect(()=>{var c;a.current!==n&&((c=l.current)==null||c.call(l,n),a.current=n)},[n,a]),[n,r,l]}function R5(t){return typeof t=="function"}function Wv(t){const s=v.useRef({value:t,previous:t});return v.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}function Gv(t){const[s,n]=v.useState(void 0);return Zn(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const l=a[0];let c,d;if("borderBoxSize"in l){const h=l.borderBoxSize,x=Array.isArray(h)?h[0]:h;c=x.inlineSize,d=x.blockSize}else c=t.offsetWidth,d=t.offsetHeight;n({width:c,height:d})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),s}function E5(t,s){return v.useReducer((n,r)=>s[n][r]??n,t)}var mr=t=>{const{present:s,children:n}=t,r=D5(s),a=typeof n=="function"?n({present:r.isPresent}):v.Children.only(n),l=Ms(r.ref,T5(a));return typeof n=="function"||r.isPresent?v.cloneElement(a,{ref:l}):null};mr.displayName="Presence";function D5(t){const[s,n]=v.useState(),r=v.useRef(null),a=v.useRef(t),l=v.useRef("none"),c=t?"mounted":"unmounted",[d,h]=E5(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const x=Ah(r.current);l.current=d==="mounted"?x:"none"},[d]),Zn(()=>{const x=r.current,f=a.current;if(f!==t){const p=l.current,u=Ah(x);t?h("MOUNT"):u==="none"||(x==null?void 0:x.display)==="none"?h("UNMOUNT"):h(f&&p!==u?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,h]),Zn(()=>{if(s){let x;const f=s.ownerDocument.defaultView??window,m=u=>{const g=Ah(r.current).includes(CSS.escape(u.animationName));if(u.target===s&&g&&(h("ANIMATION_END"),!a.current)){const y=s.style.animationFillMode;s.style.animationFillMode="forwards",x=f.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=y)})}},p=u=>{u.target===s&&(l.current=Ah(r.current))};return s.addEventListener("animationstart",p),s.addEventListener("animationcancel",m),s.addEventListener("animationend",m),()=>{f.clearTimeout(x),s.removeEventListener("animationstart",p),s.removeEventListener("animationcancel",m),s.removeEventListener("animationend",m)}}else h("ANIMATION_END")},[s,h]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:v.useCallback(x=>{r.current=x?getComputedStyle(x):null,n(x)},[])}}function Ah(t){return(t==null?void 0:t.animationName)||"none"}function T5(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 P5(t){const s=_5(t),n=v.forwardRef((r,a)=>{const{children:l,...c}=r,d=v.Children.toArray(l),h=d.find(I5);if(h){const x=h.props.children,f=d.map(m=>m===h?v.Children.count(x)>1?v.Children.only(null):v.isValidElement(x)?x.props.children:null:m);return e.jsx(s,{...c,ref:a,children:v.isValidElement(x)?v.cloneElement(x,void 0,f):null})}return e.jsx(s,{...c,ref:a,children:l})});return n.displayName=`${t}.Slot`,n}function _5(t){const s=v.forwardRef((n,r)=>{const{children:a,...l}=n;if(v.isValidElement(a)){const c=M5(a),d=L5(l,a.props);return a.type!==v.Fragment&&(d.ref=r?Br(r,c):c),v.cloneElement(a,d)}return v.Children.count(a)>1?v.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var O5=Symbol("radix.slottable");function I5(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===O5}function L5(t,s){const n={...s};for(const r in s){const a=t[r],l=s[r];/^on[A-Z]/.test(r)?a&&l?n[r]=(...d)=>{const h=l(...d);return a(...d),h}:a&&(n[r]=a):r==="style"?n[r]={...a,...l}:r==="className"&&(n[r]=[a,l].filter(Boolean).join(" "))}return{...t,...n}}function M5(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 F5=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ps=F5.reduce((t,s)=>{const n=P5(`Primitive.${s}`),r=v.forwardRef((a,l)=>{const{asChild:c,...d}=a,h=c?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(h,{...d,ref:l})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{});function S2(t,s){t&&cu.flushSync(()=>t.dispatchEvent(s))}var Ym="Checkbox",[B5]=ea(Ym),[$5,Kv]=B5(Ym);function q5(t){const{__scopeCheckbox:s,checked:n,children:r,defaultChecked:a,disabled:l,form:c,name:d,onCheckedChange:h,required:x,value:f="on",internal_do_not_use_render:m}=t,[p,u]=bi({prop:n,defaultProp:a??!1,onChange:h,caller:Ym}),[j,g]=v.useState(null),[y,N]=v.useState(null),S=v.useRef(!1),C=j?!!c||!!j.closest("form"):!0,w={checked:p,disabled:l,setChecked:u,control:j,setControl:g,name:d,form:c,value:f,hasConsumerStoppedPropagationRef:S,required:x,defaultChecked:_l(a)?!1:a,isFormControl:C,bubbleInput:y,setBubbleInput:N};return e.jsx($5,{scope:s,...w,children:z5(m)?m(w):r})}var C2="CheckboxTrigger",A2=v.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:n,...r},a)=>{const{control:l,value:c,disabled:d,checked:h,required:x,setControl:f,setChecked:m,hasConsumerStoppedPropagationRef:p,isFormControl:u,bubbleInput:j}=Kv(C2,t),g=Ms(a,f),y=v.useRef(h);return v.useEffect(()=>{const N=l==null?void 0:l.form;if(N){const S=()=>m(y.current);return N.addEventListener("reset",S),()=>N.removeEventListener("reset",S)}},[l,m]),e.jsx(ps.button,{type:"button",role:"checkbox","aria-checked":_l(h)?"mixed":h,"aria-required":x,"data-state":P2(h),"data-disabled":d?"":void 0,disabled:d,value:c,...r,ref:g,onKeyDown:Vt(s,N=>{N.key==="Enter"&&N.preventDefault()}),onClick:Vt(n,N=>{m(S=>_l(S)?!0:!S),j&&u&&(p.current=N.isPropagationStopped(),p.current||N.stopPropagation())})})});A2.displayName=C2;var k2=v.forwardRef((t,s)=>{const{__scopeCheckbox:n,name:r,checked:a,defaultChecked:l,required:c,disabled:d,value:h,onCheckedChange:x,form:f,...m}=t;return e.jsx(q5,{__scopeCheckbox:n,checked:a,defaultChecked:l,disabled:d,required:c,onCheckedChange:x,name:r,form:f,value:h,internal_do_not_use_render:({isFormControl:p})=>e.jsxs(e.Fragment,{children:[e.jsx(A2,{...m,ref:s,__scopeCheckbox:n}),p&&e.jsx(T2,{__scopeCheckbox:n})]})})});k2.displayName=Ym;var R2="CheckboxIndicator",E2=v.forwardRef((t,s)=>{const{__scopeCheckbox:n,forceMount:r,...a}=t,l=Kv(R2,n);return e.jsx(mr,{present:r||_l(l.checked)||l.checked===!0,children:e.jsx(ps.span,{"data-state":P2(l.checked),"data-disabled":l.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});E2.displayName=R2;var D2="CheckboxBubbleInput",T2=v.forwardRef(({__scopeCheckbox:t,...s},n)=>{const{control:r,hasConsumerStoppedPropagationRef:a,checked:l,defaultChecked:c,required:d,disabled:h,name:x,value:f,form:m,bubbleInput:p,setBubbleInput:u}=Kv(D2,t),j=Ms(n,u),g=Wv(l),y=Gv(r);v.useEffect(()=>{const S=p;if(!S)return;const C=window.HTMLInputElement.prototype,R=Object.getOwnPropertyDescriptor(C,"checked").set,P=!a.current;if(g!==l&&R){const A=new Event("click",{bubbles:P});S.indeterminate=_l(l),R.call(S,_l(l)?!1:l),S.dispatchEvent(A)}},[p,g,l,a]);const N=v.useRef(_l(l)?!1:l);return e.jsx(ps.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??N.current,required:d,disabled:h,name:x,value:f,form:m,...s,tabIndex:-1,ref:j,style:{...s.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});T2.displayName=D2;function z5(t){return typeof t=="function"}function _l(t){return t==="indeterminate"}function P2(t){return _l(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 U5={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 V5=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),ft=(t,s)=>{const n=v.forwardRef(({color:r="currentColor",size:a=24,strokeWidth:l=2,absoluteStrokeWidth:c,className:d="",children:h,...x},f)=>v.createElement("svg",{ref:f,...U5,width:a,height:a,stroke:r,strokeWidth:c?Number(l)*24/Number(a):l,className:["lucide",`lucide-${V5(t)}`,d].join(" "),...x},[...s.map(([m,p])=>v.createElement(m,p)),...Array.isArray(h)?h:[h]]));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 H5=ft("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 Ks=ft("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 Ya=ft("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 $r=ft("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 To=ft("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 W5=ft("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 _2=ft("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 Yv=ft("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 G5=ft("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 Yd=ft("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 ow=ft("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 Ml=ft("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 Dc=ft("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 O2=ft("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 $n=ft("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 Fn=ft("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 Ys=ft("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 K5=ft("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 Bn=ft("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 la=ft("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 qc=ft("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 el=ft("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 $d=ft("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 Y5=ft("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 Z5=ft("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 Fo=ft("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 Js=ft("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 cw=ft("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 mu=ft("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 ev=ft("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 Ni=ft("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 Q5=ft("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 nn=ft("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 _d=ft("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 X5=ft("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 fs=ft("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 J5=ft("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 vm=ft("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 I2=ft("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 eI=ft("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 tI=ft("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 tv=ft("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 Zd=ft("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 sI=ft("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 L2=ft("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 M2=ft("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 dw=ft("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 nI=ft("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 oa=ft("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 Xa=ft("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 F2=ft("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 rI=ft("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 kh=ft("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 aI=ft("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 B2=ft("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 ss=ft("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 sv=ft("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 iI=ft("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 $2=ft("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 qr=ft("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 Er=ft("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 zr=ft("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 lI=ft("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 q2=ft("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 qd=ft("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 uw=ft("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 ur=ft("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 nv=ft("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 Zv=ft("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 Ax=ft("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 cn=ft("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 rv=ft("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 Ki=ft("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 Rr=ft("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 oI=ft("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 Qv=ft("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 Yi=ft("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 Ra=ft("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 fu=ft("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 Zm=ft("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 Sc=ft("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 Xv=ft("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 Fl=ft("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 Vo=ft("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 cI=ft("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 dI=ft("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 uI=ft("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 hI=ft("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 mI=ft("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 fI=ft("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 Gn=ft("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 Po=ft("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 Wi=ft("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 pI=ft("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 xI=ft("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 Dr=ft("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 gI=ft("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 vI=ft("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 kx=ft("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 Jv=ft("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 Rx=ft("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 kr=ft("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 da=ft("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 bm=ft("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 Za=ft("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 Tc=ft("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 hw=ft("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]);function Rn({className:t,...s}){return e.jsx(k2,{"data-slot":"checkbox",className:Pt("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(E2,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:e.jsx(Bn,{className:"size-3.5"})})})}var bI=t=>{switch(t){case"success":return NI;case"info":return SI;case"warning":return wI;case"error":return CI;default:return null}},yI=Array(12).fill(0),jI=({visible:t,className:s})=>gt.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},gt.createElement("div",{className:"sonner-spinner"},yI.map((n,r)=>gt.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),NI=gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},gt.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"})),wI=gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},gt.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"})),SI=gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},gt.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"})),CI=gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},gt.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"})),AI=gt.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"},gt.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),gt.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),kI=()=>{let[t,s]=gt.useState(document.hidden);return gt.useEffect(()=>{let n=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),t},av=1,RI=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:av++,l=this.toasts.find(d=>d.id===a),c=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),l?this.toasts=this.toasts.map(d=>d.id===a?(this.publish({...d,...t,id:a,title:n}),{...d,...t,id:a,dismissible:c,title:n}):d):this.addToast({title:n,...r,dismissible:c,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,l,c=r.then(async h=>{if(l=["resolve",h],gt.isValidElement(h))a=!1,this.create({id:n,type:"default",message:h});else if(DI(h)&&!h.ok){a=!1;let x=typeof s.error=="function"?await s.error(`HTTP error! status: ${h.status}`):s.error,f=typeof s.description=="function"?await s.description(`HTTP error! status: ${h.status}`):s.description;this.create({id:n,type:"error",message:x,description:f})}else if(s.success!==void 0){a=!1;let x=typeof s.success=="function"?await s.success(h):s.success,f=typeof s.description=="function"?await s.description(h):s.description;this.create({id:n,type:"success",message:x,description:f})}}).catch(async h=>{if(l=["reject",h],s.error!==void 0){a=!1;let x=typeof s.error=="function"?await s.error(h):s.error,f=typeof s.description=="function"?await s.description(h):s.description;this.create({id:n,type:"error",message:x,description:f})}}).finally(()=>{var h;a&&(this.dismiss(n),n=void 0),(h=s.finally)==null||h.call(s)}),d=()=>new Promise((h,x)=>c.then(()=>l[0]==="reject"?x(l[1]):h(l[1])).catch(x));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)||av++;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}},Qr=new RI,EI=(t,s)=>{let n=(s==null?void 0:s.id)||av++;return Qr.addToast({title:t,...s,id:n}),n},DI=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",TI=EI,PI=()=>Qr.toasts,_I=()=>Qr.getActiveToasts(),ee=Object.assign(TI,{success:Qr.success,info:Qr.info,warning:Qr.warning,error:Qr.error,custom:Qr.custom,message:Qr.message,promise:Qr.promise,dismiss:Qr.dismiss,loading:Qr.loading},{getHistory:PI,getToasts:_I});function OI(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))}OI(`: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 Rh(t){return t.label!==void 0}var II=3,LI="32px",MI="16px",mw=4e3,FI=356,BI=14,$I=20,qI=200;function Va(...t){return t.filter(Boolean).join(" ")}function zI(t){let[s,n]=t.split("-"),r=[];return s&&r.push(s),n&&r.push(n),r}var UI=t=>{var s,n,r,a,l,c,d,h,x,f,m;let{invert:p,toast:u,unstyled:j,interacting:g,setHeights:y,visibleToasts:N,heights:S,index:C,toasts:w,expanded:R,removeToast:P,defaultRichColors:A,closeButton:I,style:$,cancelButtonStyle:T,actionButtonStyle:E,className:_="",descriptionClassName:M="",duration:q,position:G,gap:Z,loadingIcon:W,expandByDefault:z,classNames:F,icons:B,closeButtonAriaLabel:D="Close toast",pauseWhenPageIsHidden:O}=t,[V,K]=gt.useState(null),[Y,U]=gt.useState(null),[X,ne]=gt.useState(!1),[oe,re]=gt.useState(!1),[ge,ve]=gt.useState(!1),[Se,We]=gt.useState(!1),[Ce,fe]=gt.useState(!1),[Ye,be]=gt.useState(0),[_e,ke]=gt.useState(0),qe=gt.useRef(u.duration||q||mw),Ve=gt.useRef(null),dt=gt.useRef(null),xt=C===0,ye=C+1<=N,le=u.type,Qe=u.dismissible!==!1,rt=u.className||"",Kt=u.descriptionClassName||"",Rt=gt.useMemo(()=>S.findIndex(Ee=>Ee.toastId===u.id)||0,[S,u.id]),Re=gt.useMemo(()=>{var Ee;return(Ee=u.closeButton)!=null?Ee:I},[u.closeButton,I]),Qt=gt.useMemo(()=>u.duration||q||mw,[u.duration,q]),qt=gt.useRef(0),ws=gt.useRef(0),_s=gt.useRef(0),ns=gt.useRef(null),[Cs,Bs]=G.split("-"),Ft=gt.useMemo(()=>S.reduce((Ee,it,st)=>st>=Rt?Ee:Ee+it.height,0),[S,Rt]),ie=kI(),Fe=u.invert||p,Q=le==="loading";ws.current=gt.useMemo(()=>Rt*Z+Ft,[Rt,Ft]),gt.useEffect(()=>{qe.current=Qt},[Qt]),gt.useEffect(()=>{ne(!0)},[]),gt.useEffect(()=>{let Ee=dt.current;if(Ee){let it=Ee.getBoundingClientRect().height;return ke(it),y(st=>[{toastId:u.id,height:it,position:u.position},...st]),()=>y(st=>st.filter(bt=>bt.toastId!==u.id))}},[y,u.id]),gt.useLayoutEffect(()=>{if(!X)return;let Ee=dt.current,it=Ee.style.height;Ee.style.height="auto";let st=Ee.getBoundingClientRect().height;Ee.style.height=it,ke(st),y(bt=>bt.find(Ue=>Ue.toastId===u.id)?bt.map(Ue=>Ue.toastId===u.id?{...Ue,height:st}:Ue):[{toastId:u.id,height:st,position:u.position},...bt])},[X,u.title,u.description,y,u.id]);let pe=gt.useCallback(()=>{re(!0),be(ws.current),y(Ee=>Ee.filter(it=>it.toastId!==u.id)),setTimeout(()=>{P(u)},qI)},[u,P,y,ws]);gt.useEffect(()=>{if(u.promise&&le==="loading"||u.duration===1/0||u.type==="loading")return;let Ee;return R||g||O&&ie?(()=>{if(_s.current<qt.current){let it=new Date().getTime()-qt.current;qe.current=qe.current-it}_s.current=new Date().getTime()})():qe.current!==1/0&&(qt.current=new Date().getTime(),Ee=setTimeout(()=>{var it;(it=u.onAutoClose)==null||it.call(u,u),pe()},qe.current)),()=>clearTimeout(Ee)},[R,g,u,le,O,ie,pe]),gt.useEffect(()=>{u.delete&&pe()},[pe,u.delete]);function Ne(){var Ee,it,st;return B!=null&&B.loading?gt.createElement("div",{className:Va(F==null?void 0:F.loader,(Ee=u==null?void 0:u.classNames)==null?void 0:Ee.loader,"sonner-loader"),"data-visible":le==="loading"},B.loading):W?gt.createElement("div",{className:Va(F==null?void 0:F.loader,(it=u==null?void 0:u.classNames)==null?void 0:it.loader,"sonner-loader"),"data-visible":le==="loading"},W):gt.createElement(jI,{className:Va(F==null?void 0:F.loader,(st=u==null?void 0:u.classNames)==null?void 0:st.loader),visible:le==="loading"})}return gt.createElement("li",{tabIndex:0,ref:dt,className:Va(_,rt,F==null?void 0:F.toast,(s=u==null?void 0:u.classNames)==null?void 0:s.toast,F==null?void 0:F.default,F==null?void 0:F[le],(n=u==null?void 0:u.classNames)==null?void 0:n[le]),"data-sonner-toast":"","data-rich-colors":(r=u.richColors)!=null?r:A,"data-styled":!(u.jsx||u.unstyled||j),"data-mounted":X,"data-promise":!!u.promise,"data-swiped":Ce,"data-removed":oe,"data-visible":ye,"data-y-position":Cs,"data-x-position":Bs,"data-index":C,"data-front":xt,"data-swiping":ge,"data-dismissible":Qe,"data-type":le,"data-invert":Fe,"data-swipe-out":Se,"data-swipe-direction":Y,"data-expanded":!!(R||z&&X),style:{"--index":C,"--toasts-before":C,"--z-index":w.length-C,"--offset":`${oe?Ye:ws.current}px`,"--initial-height":z?"auto":`${_e}px`,...$,...u.style},onDragEnd:()=>{ve(!1),K(null),ns.current=null},onPointerDown:Ee=>{Q||!Qe||(Ve.current=new Date,be(ws.current),Ee.target.setPointerCapture(Ee.pointerId),Ee.target.tagName!=="BUTTON"&&(ve(!0),ns.current={x:Ee.clientX,y:Ee.clientY}))},onPointerUp:()=>{var Ee,it,st,bt;if(Se||!Qe)return;ns.current=null;let Ue=Number(((Ee=dt.current)==null?void 0:Ee.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Lt=Number(((it=dt.current)==null?void 0:it.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ut=new Date().getTime()-((st=Ve.current)==null?void 0:st.getTime()),yt=V==="x"?Ue:Lt,kt=Math.abs(yt)/ut;if(Math.abs(yt)>=$I||kt>.11){be(ws.current),(bt=u.onDismiss)==null||bt.call(u,u),U(V==="x"?Ue>0?"right":"left":Lt>0?"down":"up"),pe(),We(!0),fe(!1);return}ve(!1),K(null)},onPointerMove:Ee=>{var it,st,bt,Ue;if(!ns.current||!Qe||((it=window.getSelection())==null?void 0:it.toString().length)>0)return;let Lt=Ee.clientY-ns.current.y,ut=Ee.clientX-ns.current.x,yt=(st=t.swipeDirections)!=null?st:zI(G);!V&&(Math.abs(ut)>1||Math.abs(Lt)>1)&&K(Math.abs(ut)>Math.abs(Lt)?"x":"y");let kt={x:0,y:0};V==="y"?(yt.includes("top")||yt.includes("bottom"))&&(yt.includes("top")&&Lt<0||yt.includes("bottom")&&Lt>0)&&(kt.y=Lt):V==="x"&&(yt.includes("left")||yt.includes("right"))&&(yt.includes("left")&&ut<0||yt.includes("right")&&ut>0)&&(kt.x=ut),(Math.abs(kt.x)>0||Math.abs(kt.y)>0)&&fe(!0),(bt=dt.current)==null||bt.style.setProperty("--swipe-amount-x",`${kt.x}px`),(Ue=dt.current)==null||Ue.style.setProperty("--swipe-amount-y",`${kt.y}px`)}},Re&&!u.jsx?gt.createElement("button",{"aria-label":D,"data-disabled":Q,"data-close-button":!0,onClick:Q||!Qe?()=>{}:()=>{var Ee;pe(),(Ee=u.onDismiss)==null||Ee.call(u,u)},className:Va(F==null?void 0:F.closeButton,(a=u==null?void 0:u.classNames)==null?void 0:a.closeButton)},(l=B==null?void 0:B.close)!=null?l:AI):null,u.jsx||v.isValidElement(u.title)?u.jsx?u.jsx:typeof u.title=="function"?u.title():u.title:gt.createElement(gt.Fragment,null,le||u.icon||u.promise?gt.createElement("div",{"data-icon":"",className:Va(F==null?void 0:F.icon,(c=u==null?void 0:u.classNames)==null?void 0:c.icon)},u.promise||u.type==="loading"&&!u.icon?u.icon||Ne():null,u.type!=="loading"?u.icon||(B==null?void 0:B[le])||bI(le):null):null,gt.createElement("div",{"data-content":"",className:Va(F==null?void 0:F.content,(d=u==null?void 0:u.classNames)==null?void 0:d.content)},gt.createElement("div",{"data-title":"",className:Va(F==null?void 0:F.title,(h=u==null?void 0:u.classNames)==null?void 0:h.title)},typeof u.title=="function"?u.title():u.title),u.description?gt.createElement("div",{"data-description":"",className:Va(M,Kt,F==null?void 0:F.description,(x=u==null?void 0:u.classNames)==null?void 0:x.description)},typeof u.description=="function"?u.description():u.description):null),v.isValidElement(u.cancel)?u.cancel:u.cancel&&Rh(u.cancel)?gt.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||T,onClick:Ee=>{var it,st;Rh(u.cancel)&&Qe&&((st=(it=u.cancel).onClick)==null||st.call(it,Ee),pe())},className:Va(F==null?void 0:F.cancelButton,(f=u==null?void 0:u.classNames)==null?void 0:f.cancelButton)},u.cancel.label):null,v.isValidElement(u.action)?u.action:u.action&&Rh(u.action)?gt.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||E,onClick:Ee=>{var it,st;Rh(u.action)&&((st=(it=u.action).onClick)==null||st.call(it,Ee),!Ee.defaultPrevented&&pe())},className:Va(F==null?void 0:F.actionButton,(m=u==null?void 0:u.classNames)==null?void 0:m.actionButton)},u.action.label):null))};function fw(){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 VI(t,s){let n={};return[t,s].forEach((r,a)=>{let l=a===1,c=l?"--mobile-offset":"--offset",d=l?MI:LI;function h(x){["top","right","bottom","left"].forEach(f=>{n[`${c}-${f}`]=typeof x=="number"?`${x}px`:x})}typeof r=="number"||typeof r=="string"?h(r):typeof r=="object"?["top","right","bottom","left"].forEach(x=>{r[x]===void 0?n[`${c}-${x}`]=d:n[`${c}-${x}`]=typeof r[x]=="number"?`${r[x]}px`:r[x]}):h(d)}),n}var HI=v.forwardRef(function(t,s){let{invert:n,position:r="bottom-right",hotkey:a=["altKey","KeyT"],expand:l,closeButton:c,className:d,offset:h,mobileOffset:x,theme:f="light",richColors:m,duration:p,style:u,visibleToasts:j=II,toastOptions:g,dir:y=fw(),gap:N=BI,loadingIcon:S,icons:C,containerAriaLabel:w="Notifications",pauseWhenPageIsHidden:R}=t,[P,A]=gt.useState([]),I=gt.useMemo(()=>Array.from(new Set([r].concat(P.filter(O=>O.position).map(O=>O.position)))),[P,r]),[$,T]=gt.useState([]),[E,_]=gt.useState(!1),[M,q]=gt.useState(!1),[G,Z]=gt.useState(f!=="system"?f:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),W=gt.useRef(null),z=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),F=gt.useRef(null),B=gt.useRef(!1),D=gt.useCallback(O=>{A(V=>{var K;return(K=V.find(Y=>Y.id===O.id))!=null&&K.delete||Qr.dismiss(O.id),V.filter(({id:Y})=>Y!==O.id)})},[]);return gt.useEffect(()=>Qr.subscribe(O=>{if(O.dismiss){A(V=>V.map(K=>K.id===O.id?{...K,delete:!0}:K));return}setTimeout(()=>{qv.flushSync(()=>{A(V=>{let K=V.findIndex(Y=>Y.id===O.id);return K!==-1?[...V.slice(0,K),{...V[K],...O},...V.slice(K+1)]:[O,...V]})})})}),[]),gt.useEffect(()=>{if(f!=="system"){Z(f);return}if(f==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Z("dark"):Z("light")),typeof window>"u")return;let O=window.matchMedia("(prefers-color-scheme: dark)");try{O.addEventListener("change",({matches:V})=>{Z(V?"dark":"light")})}catch{O.addListener(({matches:K})=>{try{Z(K?"dark":"light")}catch(Y){console.error(Y)}})}},[f]),gt.useEffect(()=>{P.length<=1&&_(!1)},[P]),gt.useEffect(()=>{let O=V=>{var K,Y;a.every(U=>V[U]||V.code===U)&&(_(!0),(K=W.current)==null||K.focus()),V.code==="Escape"&&(document.activeElement===W.current||(Y=W.current)!=null&&Y.contains(document.activeElement))&&_(!1)};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[a]),gt.useEffect(()=>{if(W.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,B.current=!1)}},[W.current]),gt.createElement("section",{ref:s,"aria-label":`${w} ${z}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},I.map((O,V)=>{var K;let[Y,U]=O.split("-");return P.length?gt.createElement("ol",{key:O,dir:y==="auto"?fw():y,tabIndex:-1,ref:W,className:d,"data-sonner-toaster":!0,"data-theme":G,"data-y-position":Y,"data-lifted":E&&P.length>1&&!l,"data-x-position":U,style:{"--front-toast-height":`${((K=$[0])==null?void 0:K.height)||0}px`,"--width":`${FI}px`,"--gap":`${N}px`,...u,...VI(h,x)},onBlur:X=>{B.current&&!X.currentTarget.contains(X.relatedTarget)&&(B.current=!1,F.current&&(F.current.focus({preventScroll:!0}),F.current=null))},onFocus:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||B.current||(B.current=!0,F.current=X.relatedTarget)},onMouseEnter:()=>_(!0),onMouseMove:()=>_(!0),onMouseLeave:()=>{M||_(!1)},onDragEnd:()=>_(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||q(!0)},onPointerUp:()=>q(!1)},P.filter(X=>!X.position&&V===0||X.position===O).map((X,ne)=>{var oe,re;return gt.createElement(UI,{key:X.id,icons:C,index:ne,toast:X,defaultRichColors:m,duration:(oe=g==null?void 0:g.duration)!=null?oe:p,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:j,closeButton:(re=g==null?void 0:g.closeButton)!=null?re:c,interacting:M,position:O,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:D,toasts:P.filter(ge=>ge.position==X.position),heights:$.filter(ge=>ge.position==X.position),setHeights:T,expandByDefault:l,gap:N,loadingIcon:S,expanded:E,pauseWhenPageIsHidden:R,swipeDirections:t.swipeDirections})})):null}))});const ds={submitApplication:async t=>{var n;const s=await Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.bulkConvertToOpportunity(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to perform bulk conversion");return s.data},createDealer:async t=>{var n;const s=await Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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)||[]}},Ss={getRoles:async()=>(await Te.getRoles()).data,getPermissions:async()=>(await Te.getPermissions()).data,updateRole:async(t,s)=>(await Te.updateRole(t,s)).data,createRole:async t=>(await Te.createRole(t)).data,getZones:async()=>(await Te.getZones()).data,updateZone:async(t,s)=>(await Te.updateZone(t,s)).data,createZone:async t=>(await Te.createZone(t)).data,createRegion:async t=>(await Te.createRegion(t)).data,updateRegion:async(t,s)=>(await Te.updateRegion(t,s)).data,getRegions:async()=>(await Te.getRegions()).data,getStates:async t=>(await Te.getStates(t)).data,getDistricts:async t=>{const s=typeof t=="string"?{stateId:t,limit:"all"}:{limit:"all",...t};return(await Te.getDistricts(s)).data},getAreas:async t=>(await Te.getAreas(t)).data,updateArea:async(t,s)=>(await Te.updateArea(t,s)).data,createArea:async t=>(await Te.createArea(t)).data,deleteArea:async t=>(await Te.deleteArea(t)).data,getAreaManagers:async()=>(await Te.getAreaManagers()).data,getASMs:async()=>(await Te.getASMs()).data,getZonalManagers:async()=>(await Te.getZonalManagers()).data,saveZonalManager:async t=>Te.saveZonalManager(t).then(s=>s.data),getDDLeads:async()=>(await Te.getDDLeads()).data,saveDDLead:async t=>Te.saveDDLead(t).then(s=>s.data),getUsers:async()=>(await Te.getUsers()).data,updateUser:async(t,s)=>(await Te.updateUser(t,s)).data,getEmailTemplates:async()=>(await Te.getEmailTemplates()).data,getEmailTemplate:async t=>(await Te.getEmailTemplate(t)).data,createEmailTemplate:async t=>(await Te.createEmailTemplate(t)).data,updateEmailTemplate:async(t,s)=>(await Te.updateEmailTemplate(t,s)).data,deleteEmailTemplate:async t=>(await Te.deleteEmailTemplate(t)).data,previewEmailTemplate:async t=>(await Te.previewEmailTemplate(t)).data,getSlaConfigs:async()=>(await Te.getSlaConfigs()).data,saveSlaConfig:async t=>(await Te.saveSlaConfig(t)).data,initializeDefaultSlas:async()=>(await Te.initializeDefaultSlas()).data,saveZone:async t=>t.id?Ss.updateZone(t.id,t):Ss.createZone(t),saveRegion:async t=>t.id?Ss.updateRegion(t.id,t):Ss.createRegion(t),saveASM:async t=>Te.updateUser(t.userId,t).then(s=>s.data),getSystemConfigs:async t=>(await Te.getSystemConfigs(t)).data,saveSystemConfig:async t=>(await Te.saveSystemConfig(t)).data,getDealerAsmMappings:async()=>(await Te.getDealerAsmMappings()).data,saveDealerAsmMapping:async t=>(await Te.saveDealerAsmMapping(t)).data};function WI({onAdminLogin:t}){const[s,n]=v.useState({country:"India",stateId:"",districtId:"",name:"",interestedCity:"",email:"",pincode:"",mobile:"",ownRoyalEnfield:"",royalEnfieldModel:"",age:"",education:"",companyName:"",source:"",existingDealer:"",description:"",address:"",acceptTerms:!1}),[r,a]=v.useState(!1),[l,c]=v.useState([]),[d,h]=v.useState([]);v.useEffect(()=>{x()},[]);const x=async()=>{try{const g=await Ss.getStates(),y=Array.isArray(g)?g:(g==null?void 0:g.data)||(g==null?void 0:g.states)||[];c(y)}catch(g){console.error("Error fetching states:",g)}},f=async g=>{if(g){n(y=>({...y,stateId:g,districtId:""})),h([]);try{const y=await Ss.getDistricts(g),N=Array.isArray(y)?y:(y==null?void 0:y.data)||(y==null?void 0:y.districts)||[];h(N)}catch(y){console.error("Error fetching districts:",y)}}},m=()=>{if(!s.mobile||s.mobile.length<10){ee.error("Please enter a valid mobile number");return}ee.success("OTP sent to "+s.mobile),setTimeout(()=>{a(!0),ee.success("Mobile number verified")},1500)},p=async g=>{var y,N;if(g.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){ee.error("Please fill in all required fields");return}if(!r){ee.error("Please verify your mobile number");return}if(!s.acceptTerms){ee.error("Please accept the terms and conditions");return}try{const S=l.find(A=>A.id===s.stateId),C=d.find(A=>A.id===s.districtId),w=(S==null?void 0:S.name)||(S==null?void 0:S.stateName)||"",R=(C==null?void 0:C.name)||(C==null?void 0:C.districtName)||"",P={applicantName:s.name,email:s.email,phone:s.mobile,state:w,city:s.interestedCity,district:R,preferredLocation:`${s.interestedCity}, ${w}`,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 ds.submitApplication(P),ee.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(S){ee.error(((N=(y=S.response)==null?void 0:y.data)==null?void 0:N.message)||"Failed to submit application.")}},u=["Classic 650","Scram 440","Goan Classic 350","Bear 650","Guerrilla 450","Shotgun 650","Himalayan 450","Bullet 350","Super Meteor 650","Hunter 350","Scram 411","Meteor 350","Interceptor INT 650","Continental GT 650","Classic 350","Other Royal Enfield motorcycle"],j=["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(iI,{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:p,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:g=>n({...s,country:g.target.value}),children:[e.jsx("option",{value:"India",children:"India"}),e.jsx("option",{value:"Other",children:"Others"})]}),e.jsx(la,{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:g=>f(g.target.value),children:[e.jsx("option",{value:"",children:"Select State*"}),l.map(g=>e.jsx("option",{value:g.id,children:g.name||g.stateName},g.id))]}),e.jsx(la,{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:g=>n({...s,districtId:g.target.value}),children:[e.jsx("option",{value:"",children:"Select District*"}),d.map(g=>e.jsx("option",{value:g.id,children:g.name||g.districtName},g.id))]}),e.jsx(la,{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(ot,{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:g=>n({...s,name:g.target.value})}),e.jsx(ot,{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:g=>n({...s,interestedCity:g.target.value})}),e.jsx(ot,{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:g=>n({...s,email:g.target.value})}),e.jsx(ot,{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:g=>n({...s,pincode:g.target.value})}),e.jsxs("div",{className:"relative",children:[e.jsx(ot,{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:g=>n({...s,mobile:g.target.value})}),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:m,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(g=>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===g?"border-red-600":"border-[#cccccc]"}`,children:s.ownRoyalEnfield===g&&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===g,onChange:()=>n({...s,ownRoyalEnfield:g})}),e.jsx("span",{className:"text-[14px] capitalize",children:g})]},g))})]}),e.jsx(ot,{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:g=>n({...s,age:g.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 disabled:bg-slate-50",value:s.royalEnfieldModel,disabled:s.ownRoyalEnfield!=="yes",onChange:g=>n({...s,royalEnfieldModel:g.target.value}),children:[e.jsx("option",{value:"",children:"Motorcycle Owned"}),u.map(g=>e.jsx("option",{value:g,children:g},g))]}),e.jsx(la,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"})]}),e.jsx(ot,{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:g=>n({...s,education:g.target.value})}),e.jsx(ot,{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:g=>n({...s,companyName:g.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:g=>n({...s,source:g.target.value}),children:[e.jsx("option",{value:"",children:"Select Source*"}),j.map(g=>e.jsx("option",{value:g,children:g},g))]}),e.jsx(la,{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(g=>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===g?"border-red-600":"border-[#cccccc]"}`,children:s.existingDealer===g&&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===g,onChange:()=>n({...s,existingDealer:g})}),e.jsx("span",{className:"text-[14px] capitalize",children:g})]},g))})]})]}),e.jsxs("div",{className:"space-y-6 pt-4",children:[e.jsx(Fs,{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:g=>n({...s,description:g.target.value})}),e.jsx(Fs,{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:g=>n({...s,address:g.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(Rn,{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:g=>n({...s,acceptTerms:g})}),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.jsxs("button",{type:"submit",className:"h-12 px-10 bg-black text-white flex items-center gap-3 hover:bg-slate-900 transition-colors",children:[e.jsx("span",{className:"font-bold uppercase tracking-wider text-[14px]",children:"Submit"}),e.jsx(el,{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 GI=()=>{const{applicationId:t}=Bc(),s=qn(),{user:n}=Nn(A=>A.auth),[r,a]=v.useState(!0),[l,c]=v.useState([]),[d,h]=v.useState([]),[x,f]=v.useState(""),[m,p]=v.useState({}),[u,j]=v.useState(!1),[g,y]=v.useState(!1);v.useEffect(()=>{(async()=>{var I,$;if(t)try{const T=await Te.getPublicQuestionnaire(t);if(T.data.success){const E=T.data.data.questions||[];c(E);const _=Array.from(new Set(E.map(M=>M.sectionName)));h(_),_.length>0&&f(_[0])}}catch(T){console.error("Error fetching questionnaire:",T),(($=(I=T.response)==null?void 0:I.data)==null?void 0:$.code)==="ALREADY_SUBMITTED"?y(!0):ee.error("Failed to load questionnaire")}finally{a(!1)}})()},[t]);const N=(A,I)=>{p($=>({...$,[A]:I}))},S=()=>{const A=d.indexOf(x);A<d.length-1&&(f(d[A+1]),window.scrollTo({top:0,behavior:"smooth"}))},C=()=>{const A=d.indexOf(x);A>0&&(f(d[A-1]),window.scrollTo({top:0,behavior:"smooth"}))},w=async()=>{const A=l.filter(I=>I.isMandatory&&!m[I.id]);if(A.length>0){ee.error(`Please answer all mandatory questions. Missing: ${A.length}`);return}try{j(!0);const I=Object.entries(m).map(([$,T])=>({questionId:$,value:T}));await Te.submitPublicResponse({applicationId:t,responses:I}),ee.success("Responses submitted successfully"),y(!0),setTimeout(()=>s("/prospective-dashboard"),3e3)}catch(I){console.error(I),ee.error("Failed to submit responses")}finally{j(!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-amber-600"})});if(g)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-amber-600",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 text-green-600 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(Ys,{className:"w-8 h-8"})}),e.jsx("h2",{className:"text-2xl font-bold mb-2 text-slate-900",children:"Assessment Submitted"}),e.jsx("p",{className:"text-slate-600 mb-6",children:"Thank you! Your assessment has been submitted successfully. Redirecting to dashboard..."}),e.jsx("button",{onClick:()=>s("/prospective-dashboard"),className:"w-full py-2 bg-amber-600 text-white rounded-lg hover:bg-amber-700 transition-colors",children:"Return to Dashboard"})]})});const R=l.filter(A=>A.sectionName===x),P=d.indexOf(x);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",children:"Manage and track dealership applications"})]}),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-amber-600 rounded-full flex items-center justify-center",children:e.jsx(kr,{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(Rr,{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(M2,{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($r,{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-amber-600 mx-auto mb-4"}),e.jsx("h2",{className:"text-amber-400 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-amber-400 text-2xl font-bold",children:l.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-amber-400 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:()=>f(A),className:`flex items-center gap-2 px-4 py-2 rounded-lg whitespace-nowrap transition-all text-sm font-medium
${x===A?"bg-amber-600 text-white shadow-lg":"bg-slate-700/50 text-slate-300 hover:bg-slate-700 hover:text-white"}`,children:[e.jsx(fs,{className:"w-4 h-4"}),e.jsx("span",{children:A}),x===A&&e.jsx("span",{className:"ml-2 bg-white/20 px-2 py-0.5 rounded text-xs",children:l.filter(I=>I.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-amber-100 mb-8",children:[e.jsx("div",{className:"w-12 h-12 bg-amber-50 rounded-lg flex items-center justify-center flex-shrink-0 text-amber-600",children:e.jsx(da,{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:x}),e.jsxs("p",{className:"text-slate-500 text-sm",children:["Section ",P+1," of ",d.length," • ",R.length," questions"]})]})]}),e.jsxs("div",{className:"space-y-10",children:[R.map((A,I)=>e.jsx("div",{className:"group animate-in fade-in duration-500",style:{animationDelay:`${I*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-amber-100 transition-colors text-slate-600 group-hover:text-amber-700 font-semibold text-sm",children:I+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-amber-500 focus:ring-2 focus:ring-amber-200 outline-none transition-all placeholder:text-slate-400",placeholder:"Type your answer here...",value:m[A.id]||"",onChange:$=>N(A.id,$.target.value)}),A.inputType==="textarea"&&e.jsx("textarea",{className:"w-full h-32 p-3 rounded-lg border border-slate-300 focus:border-amber-500 focus:ring-2 focus:ring-amber-200 outline-none transition-all placeholder:text-slate-400",placeholder:"Type your answer here...",value:m[A.id]||"",onChange:$=>N(A.id,$.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(($,T)=>{const E=$.optionText||$.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-amber-600 focus:ring-amber-500 border-slate-300",checked:m[A.id]===E,onChange:()=>N(A.id,E)}),e.jsx("span",{className:"text-slate-700 group-hover/opt:text-slate-900 transition-colors",children:E})]},T)})})]})]})]})},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:P===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"}),P<d.length-1?e.jsxs("button",{onClick:S,className:"px-6 py-2.5 rounded-lg text-sm font-medium bg-amber-600 text-white hover:bg-amber-700 flex items-center gap-2 transition-colors shadow-md hover:shadow-lg",children:["Next Section",e.jsx(el,{className:"w-4 h-4"})]}):e.jsxs("button",{onClick:w,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(Ys,{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 KI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],YI=KI.reduce((t,s)=>{const n=hu(`Primitive.${s}`),r=v.forwardRef((a,l)=>{const{asChild:c,...d}=a,h=c?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(h,{...d,ref:l})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),ZI="Label",z2=v.forwardRef((t,s)=>e.jsx(YI.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())}}));z2.displayName=ZI;var QI=z2;function ce({className:t,...s}){return e.jsx(QI,{"data-slot":"label",className:Pt("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 XI=[{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"}],hi={totalApplications:0,loaIssued:0,level1Pending:0,level2Pending:0,level3Pending:0,eorInProgress:0,disqualified:0,pendingReminders:0,shortlistedToday:0,pendingShortlisting:0},JI=[];function pw({onLogin:t}){const[s,n]=v.useState(""),[r,a]=v.useState(""),[l,c]=v.useState(!1),[d,h]=v.useState(""),[x,f]=v.useState(!1),[m,p]=v.useState(!1),[u,j]=v.useState(!1),[g,y]=v.useState(null),N=async(R,P)=>{try{if(navigator.clipboard&&navigator.clipboard.writeText){await navigator.clipboard.writeText(R),y(P),setTimeout(()=>y(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 I=document.execCommand("copy");document.body.removeChild(A),I&&(y(P),setTimeout(()=>y(null),2e3))}catch{}},S=async(R,P)=>{var A,I;n(R),a(P),h(""),p(!0);try{await t(R,P)}catch($){const T=((I=(A=$.response)==null?void 0:A.data)==null?void 0:I.message)||$.message||"Auto-login failed";h(T),ee.error(T)}finally{p(!1)}},C=async R=>{var P,A;if(R.preventDefault(),!m){if(h(""),!s||!r){h("Please enter both email and password");return}p(!0);try{await t(s,r)}catch(I){const $=((A=(P=I.response)==null?void 0:P.data)==null?void 0:A.message)||I.message||"Login failed";h($),ee.error($)}finally{p(!1)}}},w=R=>{R.preventDefault(),alert("Password reset link sent to "+s),f(!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:x?e.jsxs("form",{onSubmit:w,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(ce,{htmlFor:"reset-email",children:"Email Address"}),e.jsx(ot,{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:()=>f(!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(ce,{htmlFor:"email",children:"Email Address"}),e.jsx(ot,{id:"email",type:"email",placeholder:"you@royalenfield.com",value:s,onChange:R=>n(R.target.value),className:"w-full",disabled:m})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(ot,{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:m}),e.jsx("button",{type:"button",onClick:()=>j(!u),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 focus:outline-none",disabled:m,children:u?e.jsx(Q5,{className:"w-5 h-5"}):e.jsx(nn,{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(Rn,{id:"remember",checked:l,onCheckedChange:R=>c(R),disabled:m}),e.jsx(ce,{htmlFor:"remember",className:"cursor-pointer",children:"Remember Me"})]}),e.jsx("button",{type:"button",onClick:()=>f(!0),className:"text-re-red hover:text-re-red-hover disabled:opacity-50",disabled:m,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(Ks,{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:m,children:m?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:XI.map((R,P)=>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:()=>S(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(),N(R.email,P*2)},className:"p-2 hover:bg-slate-100 rounded",children:g===P*2?e.jsx(Bn,{className:"w-4 h-4 text-green-600"}):e.jsx(cw,{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(),N(R.password,P*2+1)},className:"p-2 hover:bg-slate-100 rounded",children:g===P*2+1?e.jsx(Bn,{className:"w-4 h-4 text-green-600"}):e.jsx(cw,{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 eL(){const t=qn(),s=su(),[n,r]=v.useState("PHONE"),[a,l]=v.useState(""),[c,d]=v.useState(""),[h,x]=v.useState(!1),[f,m]=v.useState(""),p=async j=>{var g;if(j.preventDefault(),!a||a.length<10){m("Please enter a valid 10-digit phone number");return}x(!0),m("");try{const y=await Te.sendOtp(a);if(y.ok)r("OTP"),ee.success("OTP sent successfully!");else{console.error("Send OTP error response:",y);const N=((g=y.data)==null?void 0:g.message)||"Failed to send OTP";m(N),ee.error(N)}}catch(y){console.error("Send OTP network error:",y),m("Network error. Please try again."),ee.error("Network error. Please try again.")}finally{x(!1)}},u=async j=>{var g;if(j.preventDefault(),!c||c.length<6){m("Please enter a valid 6-digit OTP");return}x(!0),m("");try{const y=await Te.verifyOtp(a,c);if(y.ok&&y.data){const{token:N,user:S}=y.data.data||y.data;if(!N||!S)throw new Error("Invalid response format");s(JC({user:S,token:N})),localStorage.setItem("token",N),ee.success("Logged in successfully!"),t("/prospective-dashboard")}else{const N=((g=y.data)==null?void 0:g.message)||"Invalid OTP";m(N),ee.error(N)}}catch(y){console.error("Verify OTP error:",y),m("An unexpected error occurred"),ee.error("An unexpected error occurred")}finally{x(!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-amber-600/10 rounded-full blur-3xl"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-80 h-80 bg-amber-600/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-amber-600 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($r,{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-amber-100 rounded-lg",children:e.jsx(uI,{className:"w-6 h-6 text-amber-600"})}),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:p,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"phone",children:"Registered Phone Number"}),e.jsx(ot,{id:"phone",type:"tel",placeholder:"Enter 10-digit phone number",maxLength:10,value:a,onChange:j=>l(j.target.value.replace(/\D/g,"")),className:"w-full",disabled:h}),e.jsx("p",{className:"text-slate-500 text-xs",children:"Enter the phone number you used during application"})]}),f&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-md",children:[e.jsx(Ks,{className:"w-4 h-4 text-red-600"}),e.jsx("span",{className:"text-red-600 font-medium text-sm",children:f})]}),e.jsx(se,{type:"submit",className:"w-full bg-amber-600 hover:bg-amber-700 h-9",disabled:h||a.length<10,children:h?"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(ce,{htmlFor:"otp",children:"Enter OTP"}),e.jsx(ot,{id:"otp",type:"text",placeholder:"Enter 6-digit OTP",maxLength:6,value:c,onChange:j=>d(j.target.value.replace(/\D/g,"")),className:"w-full text-center text-2xl tracking-widest",disabled:h}),e.jsx("p",{className:"text-slate-500 text-xs text-center",children:"Check your SMS for the OTP"})]}),f&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-md",children:[e.jsx(Ks,{className:"w-4 h-4 text-red-600"}),e.jsx("span",{className:"text-red-600 font-medium text-sm",children:f})]}),e.jsx(se,{type:"submit",className:"w-full bg-amber-600 hover:bg-amber-700 h-9",disabled:h||c.length<6,children:h?"Verifying...":"Verify OTP"}),e.jsxs("div",{className:"text-center text-sm",children:[e.jsx("button",{type:"button",className:"text-amber-600 hover:text-amber-700 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-amber-600 hover:text-amber-700 font-medium",onClick:p,disabled:h,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 tL({onLogout:t}){const s=qn(),r=Ul().pathname.substring(1)||"dashboard",{user:a}=Nn(G=>G.auth),[l,c]=v.useState(!1),[d,h]=v.useState(""),[x,f]=v.useState(!1),[m,p]=v.useState(!1),[u,j]=v.useState(null),g=v.useRef(null),y=(a==null?void 0:a.role)||(a==null?void 0:a.roleCode)||"",N=String(y).trim().toLowerCase(),S=G=>G.map(Z=>Z.toLowerCase()).includes(N),C=["DD Admin","ASM","RBM","DD Lead","ZBH","NBH","Legal","Legal Admin","Super Admin"],w=["ASM","RBM","ZBH","DD Lead","DD Head","NBH","Legal Admin","Legal","DD Admin","CCO","CEO","Super Admin"],R=["DD Admin","DD Lead","NBH","Finance","Finance Admin","Super Admin"],P=S(C),A=S(w),I=S(R),$=[P?{id:"resignation",label:"Resignation"}:null,A?{id:"termination",label:"Termination"}:null,I?{id:"fnf",label:"F&F"}:null].filter(Boolean),T=S(["Finance","Finance Admin"])?[{id:"dashboard",label:"Dashboard",icon:kh},{id:"finance-onboarding",label:"Onboarding",icon:fs},{id:"finance-fnf",label:"F&F",icon:kx}]:S(["Dealer"])?[{id:"dashboard",label:"Dashboard",icon:kh},{id:"dealer-resignation",label:"My Resignations",icon:kx},{id:"dealer-constitutional",label:"Constitutional Change",icon:Ki},{id:"dealer-relocation",label:"Relocation Requests",icon:Er}]:S(["FDD"])?[{id:"fdd-dashboard",label:"FDD Dashboard",icon:kh}]:[{id:"dashboard",label:"Dashboard",icon:kh},{id:"applications",label:"Dealership Requests",icon:fs},...$.length>0?[{id:"offboarding",label:"Offboarding",icon:kx,hasSubmenu:!0,submenuKey:"offboarding",submenu:$}]:[],{id:"constitutional-change",label:"Constitutional Change",icon:Ki},{id:"relocation-requests",label:"Relocation Requests",icon:Er}];S(["DD Lead","DD Admin","Super Admin"])&&T.splice(1,0,{id:"all-requests",label:"All Requests",icon:eI,hasSubmenu:!0,submenuKey:"allRequests",submenu:[{id:"opportunity-requests",label:"Opportunity Requests"},{id:"non-opportunities",label:"Non-opportunities"}]}),S(["Super Admin","DD Admin","DD Lead"])&&(T.push({id:"master",label:"Master",icon:Sc}),T.push({id:"sla-configurations",label:"SLA Matrix",icon:Ki})),S(["Super Admin"])&&(T.push({id:"users",label:"User Management",icon:da}),T.push({id:"questionnaires",label:"Questionnaire Templates",icon:Fo}),T.push({id:"interview-configs",label:"Interview Configs",icon:aI}));const E=G=>{G.preventDefault(),d.trim()&&s("/applications")},_=v.useCallback((G,Z)=>{g.current&&clearTimeout(g.current);const W=Z.getBoundingClientRect();j({submenuKey:G,top:W.top,left:W.right+8})},[]),M=v.useCallback((G=!1)=>{G?(g.current&&clearTimeout(g.current),j(null)):g.current=setTimeout(()=>j(null),150)},[]),q=v.useCallback(()=>{g.current&&clearTimeout(g.current)},[]);return v.useEffect(()=>{l||j(null)},[l]),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 ${l?"w-20":"w-64"}`,children:[e.jsx("div",{className:"border-b border-white/10",children:l?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:()=>c(!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(el,{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 Onboarding"})]}),e.jsx("button",{onClick:()=>c(!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(qc,{className:"w-4 h-4"})})]})}),!l&&e.jsx("div",{className:"p-4 border-b border-white/10",children:e.jsxs("form",{onSubmit:E,className:"relative",children:[e.jsx(Ra,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(ot,{type:"text",placeholder:"Search applications...",value:d,onChange:G=>h(G.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:T.map(G=>{var O,V;const Z=G.icon,W=r===G.id,z=!!G.hasSubmenu,F=z&&((O=G.submenu)==null?void 0:O.some(K=>r===K.id)),B=G.submenuKey,D=B==="offboarding"?x:B==="allRequests"?m:!1;return e.jsxs("div",{children:[e.jsxs("button",{onMouseEnter:K=>{l&&z&&B&&_(B,K.currentTarget)},onMouseLeave:()=>{l&&z&&M()},onClick:()=>{z?l?(c(!1),B==="offboarding"?f(!0):B==="allRequests"&&p(!0)):B==="offboarding"?f(!x):B==="allRequests"&&p(!m):s(`/${G.id}`)},className:`w-full flex items-center gap-3 px-3 py-3 rounded-lg transition-colors ${l?"justify-center":""} ${W||F?"bg-re-red text-white shadow-lg shadow-re-red/20":"text-slate-400 hover:bg-white/5 hover:text-white"}`,title:l?G.label:void 0,children:[e.jsx(Z,{className:"w-5 h-5 flex-shrink-0"}),!l&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-left text-sm",children:G.label}),z&&(D?e.jsx($d,{className:"w-4 h-4 flex-shrink-0"}):e.jsx(la,{className:"w-4 h-4 flex-shrink-0"}))]})]}),z&&D&&!l&&e.jsx("div",{className:"ml-3 mt-1 space-y-1 border-l border-white/10 pl-3",children:(V=G.submenu)==null?void 0:V.map(K=>{const Y=r===K.id;return e.jsxs("button",{onClick:()=>s(`/${K.id}`),className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg transition-colors text-sm ${Y?"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:K.label})]},K.id)})})]},G.id)})}),e.jsxs("div",{className:"p-4 border-t border-white/10 space-y-2",children:[!l&&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})]})]})}),l&&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 ${l?"px-2 justify-center":"justify-start"} text-slate-400 hover:bg-white/5 hover:text-white`,title:l?"Logout":void 0,children:[e.jsx($2,{className:"w-5 h-5 flex-shrink-0"}),!l&&e.jsx("span",{className:"ml-3",children:"Logout"})]})]})]}),u&&l&&(()=>{const G=T.find(Z=>Z.submenuKey===u.submenuKey);return!G||!G.submenu?null:qv.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:q,onMouseLeave:()=>M(),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:G.label}),G.submenu.map(Z=>{const W=r===Z.id;return e.jsxs("button",{onClick:()=>{s(`/${Z.id}`),M(!0)},className:`w-full flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors ${W?"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:Z.label})]},Z.id)})]}),document.body)})()]})}function xw(t){const s=sL(t),n=v.forwardRef((r,a)=>{const{children:l,...c}=r,d=v.Children.toArray(l),h=d.find(rL);if(h){const x=h.props.children,f=d.map(m=>m===h?v.Children.count(x)>1?v.Children.only(null):v.isValidElement(x)?x.props.children:null:m);return e.jsx(s,{...c,ref:a,children:v.isValidElement(x)?v.cloneElement(x,void 0,f):null})}return e.jsx(s,{...c,ref:a,children:l})});return n.displayName=`${t}.Slot`,n}function sL(t){const s=v.forwardRef((n,r)=>{const{children:a,...l}=n;if(v.isValidElement(a)){const c=iL(a),d=aL(l,a.props);return a.type!==v.Fragment&&(d.ref=r?Br(r,c):c),v.cloneElement(a,d)}return v.Children.count(a)>1?v.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var nL=Symbol("radix.slottable");function rL(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===nL}function aL(t,s){const n={...s};for(const r in s){const a=t[r],l=s[r];/^on[A-Z]/.test(r)?a&&l?n[r]=(...d)=>{const h=l(...d);return a(...d),h}:a&&(n[r]=a):r==="style"?n[r]={...a,...l}:r==="className"&&(n[r]=[a,l].filter(Boolean).join(" "))}return{...t,...n}}function iL(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 eb(t){const s=t+"CollectionProvider",[n,r]=ea(s),[a,l]=n(s,{collectionRef:{current:null},itemMap:new Map}),c=g=>{const{scope:y,children:N}=g,S=gt.useRef(null),C=gt.useRef(new Map).current;return e.jsx(a,{scope:y,itemMap:C,collectionRef:S,children:N})};c.displayName=s;const d=t+"CollectionSlot",h=xw(d),x=gt.forwardRef((g,y)=>{const{scope:N,children:S}=g,C=l(d,N),w=Ms(y,C.collectionRef);return e.jsx(h,{ref:w,children:S})});x.displayName=d;const f=t+"CollectionItemSlot",m="data-radix-collection-item",p=xw(f),u=gt.forwardRef((g,y)=>{const{scope:N,children:S,...C}=g,w=gt.useRef(null),R=Ms(y,w),P=l(f,N);return gt.useEffect(()=>(P.itemMap.set(w,{ref:w,...C}),()=>void P.itemMap.delete(w))),e.jsx(p,{[m]:"",ref:R,children:S})});u.displayName=f;function j(g){const y=l(t+"CollectionConsumer",g);return gt.useCallback(()=>{const S=y.collectionRef.current;if(!S)return[];const C=Array.from(S.querySelectorAll(`[${m}]`));return Array.from(y.itemMap.values()).sort((P,A)=>C.indexOf(P.ref.current)-C.indexOf(A.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:c,Slot:x,ItemSlot:u},j,r]}var lL=v.createContext(void 0);function pu(t){const s=v.useContext(lL);return t||s||"ltr"}function dr(t){const s=v.useRef(t);return v.useEffect(()=>{s.current=t}),v.useMemo(()=>(...n)=>{var r;return(r=s.current)==null?void 0:r.call(s,...n)},[])}function oL(t,s=globalThis==null?void 0:globalThis.document){const n=dr(t);v.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 cL="DismissableLayer",iv="dismissableLayer.update",dL="dismissableLayer.pointerDownOutside",uL="dismissableLayer.focusOutside",gw,U2=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),zc=v.forwardRef((t,s)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:l,onInteractOutside:c,onDismiss:d,...h}=t,x=v.useContext(U2),[f,m]=v.useState(null),p=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,u]=v.useState({}),j=Ms(s,A=>m(A)),g=Array.from(x.layers),[y]=[...x.layersWithOutsidePointerEventsDisabled].slice(-1),N=g.indexOf(y),S=f?g.indexOf(f):-1,C=x.layersWithOutsidePointerEventsDisabled.size>0,w=S>=N,R=fL(A=>{const I=A.target,$=[...x.branches].some(T=>T.contains(I));!w||$||(a==null||a(A),c==null||c(A),A.defaultPrevented||d==null||d())},p),P=pL(A=>{const I=A.target;[...x.branches].some(T=>T.contains(I))||(l==null||l(A),c==null||c(A),A.defaultPrevented||d==null||d())},p);return oL(A=>{S===x.layers.size-1&&(r==null||r(A),!A.defaultPrevented&&d&&(A.preventDefault(),d()))},p),v.useEffect(()=>{if(f)return n&&(x.layersWithOutsidePointerEventsDisabled.size===0&&(gw=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),x.layersWithOutsidePointerEventsDisabled.add(f)),x.layers.add(f),vw(),()=>{n&&x.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=gw)}},[f,p,n,x]),v.useEffect(()=>()=>{f&&(x.layers.delete(f),x.layersWithOutsidePointerEventsDisabled.delete(f),vw())},[f,x]),v.useEffect(()=>{const A=()=>u({});return document.addEventListener(iv,A),()=>document.removeEventListener(iv,A)},[]),e.jsx(ps.div,{...h,ref:j,style:{pointerEvents:C?w?"auto":"none":void 0,...t.style},onFocusCapture:Vt(t.onFocusCapture,P.onFocusCapture),onBlurCapture:Vt(t.onBlurCapture,P.onBlurCapture),onPointerDownCapture:Vt(t.onPointerDownCapture,R.onPointerDownCapture)})});zc.displayName=cL;var hL="DismissableLayerBranch",mL=v.forwardRef((t,s)=>{const n=v.useContext(U2),r=v.useRef(null),a=Ms(s,r);return v.useEffect(()=>{const l=r.current;if(l)return n.branches.add(l),()=>{n.branches.delete(l)}},[n.branches]),e.jsx(ps.div,{...t,ref:a})});mL.displayName=hL;function fL(t,s=globalThis==null?void 0:globalThis.document){const n=dr(t),r=v.useRef(!1),a=v.useRef(()=>{});return v.useEffect(()=>{const l=d=>{if(d.target&&!r.current){let h=function(){V2(dL,n,x,{discrete:!0})};const x={originalEvent:d};d.pointerType==="touch"?(s.removeEventListener("click",a.current),a.current=h,s.addEventListener("click",a.current,{once:!0})):h()}else s.removeEventListener("click",a.current);r.current=!1},c=window.setTimeout(()=>{s.addEventListener("pointerdown",l)},0);return()=>{window.clearTimeout(c),s.removeEventListener("pointerdown",l),s.removeEventListener("click",a.current)}},[s,n]),{onPointerDownCapture:()=>r.current=!0}}function pL(t,s=globalThis==null?void 0:globalThis.document){const n=dr(t),r=v.useRef(!1);return v.useEffect(()=>{const a=l=>{l.target&&!r.current&&V2(uL,n,{originalEvent:l},{discrete:!1})};return s.addEventListener("focusin",a),()=>s.removeEventListener("focusin",a)},[s,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function vw(){const t=new CustomEvent(iv);document.dispatchEvent(t)}function V2(t,s,n,{discrete:r}){const a=n.originalEvent.target,l=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});s&&a.addEventListener(t,s,{once:!0}),r?S2(a,l):a.dispatchEvent(l)}var Ex=0;function Qm(){v.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??bw()),document.body.insertAdjacentElement("beforeend",t[1]??bw()),Ex++,()=>{Ex===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),Ex--}},[])}function bw(){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 Dx="focusScope.autoFocusOnMount",Tx="focusScope.autoFocusOnUnmount",yw={bubbles:!1,cancelable:!0},xL="FocusScope",xu=v.forwardRef((t,s)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:l,...c}=t,[d,h]=v.useState(null),x=dr(a),f=dr(l),m=v.useRef(null),p=Ms(s,g=>h(g)),u=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let g=function(C){if(u.paused||!d)return;const w=C.target;d.contains(w)?m.current=w:El(m.current,{select:!0})},y=function(C){if(u.paused||!d)return;const w=C.relatedTarget;w!==null&&(d.contains(w)||El(m.current,{select:!0}))},N=function(C){if(document.activeElement===document.body)for(const R of C)R.removedNodes.length>0&&El(d)};document.addEventListener("focusin",g),document.addEventListener("focusout",y);const S=new MutationObserver(N);return d&&S.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",y),S.disconnect()}}},[r,d,u.paused]),v.useEffect(()=>{if(d){Nw.add(u);const g=document.activeElement;if(!d.contains(g)){const N=new CustomEvent(Dx,yw);d.addEventListener(Dx,x),d.dispatchEvent(N),N.defaultPrevented||(gL(NL(H2(d)),{select:!0}),document.activeElement===g&&El(d))}return()=>{d.removeEventListener(Dx,x),setTimeout(()=>{const N=new CustomEvent(Tx,yw);d.addEventListener(Tx,f),d.dispatchEvent(N),N.defaultPrevented||El(g??document.body,{select:!0}),d.removeEventListener(Tx,f),Nw.remove(u)},0)}}},[d,x,f,u]);const j=v.useCallback(g=>{if(!n&&!r||u.paused)return;const y=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,N=document.activeElement;if(y&&N){const S=g.currentTarget,[C,w]=vL(S);C&&w?!g.shiftKey&&N===w?(g.preventDefault(),n&&El(C,{select:!0})):g.shiftKey&&N===C&&(g.preventDefault(),n&&El(w,{select:!0})):N===S&&g.preventDefault()}},[n,r,u.paused]);return e.jsx(ps.div,{tabIndex:-1,...c,ref:p,onKeyDown:j})});xu.displayName=xL;function gL(t,{select:s=!1}={}){const n=document.activeElement;for(const r of t)if(El(r,{select:s}),document.activeElement!==n)return}function vL(t){const s=H2(t),n=jw(s,t),r=jw(s.reverse(),t);return[n,r]}function H2(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 jw(t,s){for(const n of t)if(!bL(n,{upTo:s}))return n}function bL(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 yL(t){return t instanceof HTMLInputElement&&"select"in t}function El(t,{select:s=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&yL(t)&&s&&t.select()}}var Nw=jL();function jL(){let t=[];return{add(s){const n=t[0];s!==n&&(n==null||n.pause()),t=ww(t,s),t.unshift(s)},remove(s){var n;t=ww(t,s),(n=t[0])==null||n.resume()}}}function ww(t,s){const n=[...t],r=n.indexOf(s);return r!==-1&&n.splice(r,1),n}function NL(t){return t.filter(s=>s.tagName!=="A")}var wL=Om[" useId ".trim().toString()]||(()=>{}),SL=0;function hr(t){const[s,n]=v.useState(wL());return Zn(()=>{n(r=>r??String(SL++))},[t]),t||(s?`radix-${s}`:"")}const CL=["top","right","bottom","left"],Bl=Math.min,ia=Math.max,ym=Math.round,Eh=Math.floor,gi=t=>({x:t,y:t}),AL={left:"right",right:"left",bottom:"top",top:"bottom"};function lv(t,s,n){return ia(t,Bl(s,n))}function Qi(t,s){return typeof t=="function"?t(s):t}function Xi(t){return t.split("-")[0]}function Uc(t){return t.split("-")[1]}function tb(t){return t==="x"?"y":"x"}function sb(t){return t==="y"?"height":"width"}function xi(t){const s=t[0];return s==="t"||s==="b"?"y":"x"}function nb(t){return tb(xi(t))}function kL(t,s,n){n===void 0&&(n=!1);const r=Uc(t),a=nb(t),l=sb(a);let c=a==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return s.reference[l]>s.floating[l]&&(c=jm(c)),[c,jm(c)]}function RL(t){const s=jm(t);return[ov(t),s,ov(s)]}function ov(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const Sw=["left","right"],Cw=["right","left"],EL=["top","bottom"],DL=["bottom","top"];function TL(t,s,n){switch(t){case"top":case"bottom":return n?s?Cw:Sw:s?Sw:Cw;case"left":case"right":return s?EL:DL;default:return[]}}function PL(t,s,n,r){const a=Uc(t);let l=TL(Xi(t),n==="start",r);return a&&(l=l.map(c=>c+"-"+a),s&&(l=l.concat(l.map(ov)))),l}function jm(t){const s=Xi(t);return AL[s]+t.slice(s.length)}function _L(t){return{top:0,right:0,bottom:0,left:0,...t}}function W2(t){return typeof t!="number"?_L(t):{top:t,right:t,bottom:t,left:t}}function Nm(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 Aw(t,s,n){let{reference:r,floating:a}=t;const l=xi(s),c=nb(s),d=sb(c),h=Xi(s),x=l==="y",f=r.x+r.width/2-a.width/2,m=r.y+r.height/2-a.height/2,p=r[d]/2-a[d]/2;let u;switch(h){case"top":u={x:f,y:r.y-a.height};break;case"bottom":u={x:f,y:r.y+r.height};break;case"right":u={x:r.x+r.width,y:m};break;case"left":u={x:r.x-a.width,y:m};break;default:u={x:r.x,y:r.y}}switch(Uc(s)){case"start":u[c]-=p*(n&&x?-1:1);break;case"end":u[c]+=p*(n&&x?-1:1);break}return u}async function OL(t,s){var n;s===void 0&&(s={});const{x:r,y:a,platform:l,rects:c,elements:d,strategy:h}=t,{boundary:x="clippingAncestors",rootBoundary:f="viewport",elementContext:m="floating",altBoundary:p=!1,padding:u=0}=Qi(s,t),j=W2(u),y=d[p?m==="floating"?"reference":"floating":m],N=Nm(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(y)))==null||n?y:y.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(d.floating)),boundary:x,rootBoundary:f,strategy:h})),S=m==="floating"?{x:r,y:a,width:c.floating.width,height:c.floating.height}:c.reference,C=await(l.getOffsetParent==null?void 0:l.getOffsetParent(d.floating)),w=await(l.isElement==null?void 0:l.isElement(C))?await(l.getScale==null?void 0:l.getScale(C))||{x:1,y:1}:{x:1,y:1},R=Nm(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:S,offsetParent:C,strategy:h}):S);return{top:(N.top-R.top+j.top)/w.y,bottom:(R.bottom-N.bottom+j.bottom)/w.y,left:(N.left-R.left+j.left)/w.x,right:(R.right-N.right+j.right)/w.x}}const IL=50,LL=async(t,s,n)=>{const{placement:r="bottom",strategy:a="absolute",middleware:l=[],platform:c}=n,d=c.detectOverflow?c:{...c,detectOverflow:OL},h=await(c.isRTL==null?void 0:c.isRTL(s));let x=await c.getElementRects({reference:t,floating:s,strategy:a}),{x:f,y:m}=Aw(x,r,h),p=r,u=0;const j={};for(let g=0;g<l.length;g++){const y=l[g];if(!y)continue;const{name:N,fn:S}=y,{x:C,y:w,data:R,reset:P}=await S({x:f,y:m,initialPlacement:r,placement:p,strategy:a,middlewareData:j,rects:x,platform:d,elements:{reference:t,floating:s}});f=C??f,m=w??m,j[N]={...j[N],...R},P&&u<IL&&(u++,typeof P=="object"&&(P.placement&&(p=P.placement),P.rects&&(x=P.rects===!0?await c.getElementRects({reference:t,floating:s,strategy:a}):P.rects),{x:f,y:m}=Aw(x,p,h)),g=-1)}return{x:f,y:m,placement:p,strategy:a,middlewareData:j}},ML=t=>({name:"arrow",options:t,async fn(s){const{x:n,y:r,placement:a,rects:l,platform:c,elements:d,middlewareData:h}=s,{element:x,padding:f=0}=Qi(t,s)||{};if(x==null)return{};const m=W2(f),p={x:n,y:r},u=nb(a),j=sb(u),g=await c.getDimensions(x),y=u==="y",N=y?"top":"left",S=y?"bottom":"right",C=y?"clientHeight":"clientWidth",w=l.reference[j]+l.reference[u]-p[u]-l.floating[j],R=p[u]-l.reference[u],P=await(c.getOffsetParent==null?void 0:c.getOffsetParent(x));let A=P?P[C]:0;(!A||!await(c.isElement==null?void 0:c.isElement(P)))&&(A=d.floating[C]||l.floating[j]);const I=w/2-R/2,$=A/2-g[j]/2-1,T=Bl(m[N],$),E=Bl(m[S],$),_=T,M=A-g[j]-E,q=A/2-g[j]/2+I,G=lv(_,q,M),Z=!h.arrow&&Uc(a)!=null&&q!==G&&l.reference[j]/2-(q<_?T:E)-g[j]/2<0,W=Z?q<_?q-_:q-M:0;return{[u]:p[u]+W,data:{[u]:G,centerOffset:q-G-W,...Z&&{alignmentOffset:W}},reset:Z}}}),FL=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(s){var n,r;const{placement:a,middlewareData:l,rects:c,initialPlacement:d,platform:h,elements:x}=s,{mainAxis:f=!0,crossAxis:m=!0,fallbackPlacements:p,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:j="none",flipAlignment:g=!0,...y}=Qi(t,s);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const N=Xi(a),S=xi(d),C=Xi(d)===d,w=await(h.isRTL==null?void 0:h.isRTL(x.floating)),R=p||(C||!g?[jm(d)]:RL(d)),P=j!=="none";!p&&P&&R.push(...PL(d,g,j,w));const A=[d,...R],I=await h.detectOverflow(s,y),$=[];let T=((r=l.flip)==null?void 0:r.overflows)||[];if(f&&$.push(I[N]),m){const q=kL(a,c,w);$.push(I[q[0]],I[q[1]])}if(T=[...T,{placement:a,overflows:$}],!$.every(q=>q<=0)){var E,_;const q=(((E=l.flip)==null?void 0:E.index)||0)+1,G=A[q];if(G&&(!(m==="alignment"?S!==xi(G):!1)||T.every(z=>xi(z.placement)===S?z.overflows[0]>0:!0)))return{data:{index:q,overflows:T},reset:{placement:G}};let Z=(_=T.filter(W=>W.overflows[0]<=0).sort((W,z)=>W.overflows[1]-z.overflows[1])[0])==null?void 0:_.placement;if(!Z)switch(u){case"bestFit":{var M;const W=(M=T.filter(z=>{if(P){const F=xi(z.placement);return F===S||F==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(F=>F>0).reduce((F,B)=>F+B,0)]).sort((z,F)=>z[1]-F[1])[0])==null?void 0:M[0];W&&(Z=W);break}case"initialPlacement":Z=d;break}if(a!==Z)return{reset:{placement:Z}}}return{}}}};function kw(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function Rw(t){return CL.some(s=>t[s]>=0)}const BL=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:n,platform:r}=s,{strategy:a="referenceHidden",...l}=Qi(t,s);switch(a){case"referenceHidden":{const c=await r.detectOverflow(s,{...l,elementContext:"reference"}),d=kw(c,n.reference);return{data:{referenceHiddenOffsets:d,referenceHidden:Rw(d)}}}case"escaped":{const c=await r.detectOverflow(s,{...l,altBoundary:!0}),d=kw(c,n.floating);return{data:{escapedOffsets:d,escaped:Rw(d)}}}default:return{}}}}},G2=new Set(["left","top"]);async function $L(t,s){const{placement:n,platform:r,elements:a}=t,l=await(r.isRTL==null?void 0:r.isRTL(a.floating)),c=Xi(n),d=Uc(n),h=xi(n)==="y",x=G2.has(c)?-1:1,f=l&&h?-1:1,m=Qi(s,t);let{mainAxis:p,crossAxis:u,alignmentAxis:j}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return d&&typeof j=="number"&&(u=d==="end"?j*-1:j),h?{x:u*f,y:p*x}:{x:p*x,y:u*f}}const qL=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(s){var n,r;const{x:a,y:l,placement:c,middlewareData:d}=s,h=await $L(s,t);return c===((n=d.offset)==null?void 0:n.placement)&&(r=d.arrow)!=null&&r.alignmentOffset?{}:{x:a+h.x,y:l+h.y,data:{...h,placement:c}}}}},zL=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:n,y:r,placement:a,platform:l}=s,{mainAxis:c=!0,crossAxis:d=!1,limiter:h={fn:N=>{let{x:S,y:C}=N;return{x:S,y:C}}},...x}=Qi(t,s),f={x:n,y:r},m=await l.detectOverflow(s,x),p=xi(Xi(a)),u=tb(p);let j=f[u],g=f[p];if(c){const N=u==="y"?"top":"left",S=u==="y"?"bottom":"right",C=j+m[N],w=j-m[S];j=lv(C,j,w)}if(d){const N=p==="y"?"top":"left",S=p==="y"?"bottom":"right",C=g+m[N],w=g-m[S];g=lv(C,g,w)}const y=h.fn({...s,[u]:j,[p]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[u]:c,[p]:d}}}}}},UL=function(t){return t===void 0&&(t={}),{options:t,fn(s){const{x:n,y:r,placement:a,rects:l,middlewareData:c}=s,{offset:d=0,mainAxis:h=!0,crossAxis:x=!0}=Qi(t,s),f={x:n,y:r},m=xi(a),p=tb(m);let u=f[p],j=f[m];const g=Qi(d,s),y=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(h){const C=p==="y"?"height":"width",w=l.reference[p]-l.floating[C]+y.mainAxis,R=l.reference[p]+l.reference[C]-y.mainAxis;u<w?u=w:u>R&&(u=R)}if(x){var N,S;const C=p==="y"?"width":"height",w=G2.has(Xi(a)),R=l.reference[m]-l.floating[C]+(w&&((N=c.offset)==null?void 0:N[m])||0)+(w?0:y.crossAxis),P=l.reference[m]+l.reference[C]+(w?0:((S=c.offset)==null?void 0:S[m])||0)-(w?y.crossAxis:0);j<R?j=R:j>P&&(j=P)}return{[p]:u,[m]:j}}}},VL=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(s){var n,r;const{placement:a,rects:l,platform:c,elements:d}=s,{apply:h=()=>{},...x}=Qi(t,s),f=await c.detectOverflow(s,x),m=Xi(a),p=Uc(a),u=xi(a)==="y",{width:j,height:g}=l.floating;let y,N;m==="top"||m==="bottom"?(y=m,N=p===(await(c.isRTL==null?void 0:c.isRTL(d.floating))?"start":"end")?"left":"right"):(N=m,y=p==="end"?"top":"bottom");const S=g-f.top-f.bottom,C=j-f.left-f.right,w=Bl(g-f[y],S),R=Bl(j-f[N],C),P=!s.middlewareData.shift;let A=w,I=R;if((n=s.middlewareData.shift)!=null&&n.enabled.x&&(I=C),(r=s.middlewareData.shift)!=null&&r.enabled.y&&(A=S),P&&!p){const T=ia(f.left,0),E=ia(f.right,0),_=ia(f.top,0),M=ia(f.bottom,0);u?I=j-2*(T!==0||E!==0?T+E:ia(f.left,f.right)):A=g-2*(_!==0||M!==0?_+M:ia(f.top,f.bottom))}await h({...s,availableWidth:I,availableHeight:A});const $=await c.getDimensions(d.floating);return j!==$.width||g!==$.height?{reset:{rects:!0}}:{}}}};function Xm(){return typeof window<"u"}function Vc(t){return K2(t)?(t.nodeName||"").toLowerCase():"#document"}function ua(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function wi(t){var s;return(s=(K2(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function K2(t){return Xm()?t instanceof Node||t instanceof ua(t).Node:!1}function Ja(t){return Xm()?t instanceof Element||t instanceof ua(t).Element:!1}function tl(t){return Xm()?t instanceof HTMLElement||t instanceof ua(t).HTMLElement:!1}function Ew(t){return!Xm()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof ua(t).ShadowRoot}function gu(t){const{overflow:s,overflowX:n,overflowY:r,display:a}=ei(t);return/auto|scroll|overlay|hidden|clip/.test(s+r+n)&&a!=="inline"&&a!=="contents"}function HL(t){return/^(table|td|th)$/.test(Vc(t))}function Jm(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const WL=/transform|translate|scale|rotate|perspective|filter/,GL=/paint|layout|strict|content/,wo=t=>!!t&&t!=="none";let Px;function rb(t){const s=Ja(t)?ei(t):t;return wo(s.transform)||wo(s.translate)||wo(s.scale)||wo(s.rotate)||wo(s.perspective)||!ab()&&(wo(s.backdropFilter)||wo(s.filter))||WL.test(s.willChange||"")||GL.test(s.contain||"")}function KL(t){let s=$l(t);for(;tl(s)&&!Pc(s);){if(rb(s))return s;if(Jm(s))return null;s=$l(s)}return null}function ab(){return Px==null&&(Px=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Px}function Pc(t){return/^(html|body|#document)$/.test(Vc(t))}function ei(t){return ua(t).getComputedStyle(t)}function ef(t){return Ja(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function $l(t){if(Vc(t)==="html")return t;const s=t.assignedSlot||t.parentNode||Ew(t)&&t.host||wi(t);return Ew(s)?s.host:s}function Y2(t){const s=$l(t);return Pc(s)?t.ownerDocument?t.ownerDocument.body:t.body:tl(s)&&gu(s)?s:Y2(s)}function Qd(t,s,n){var r;s===void 0&&(s=[]),n===void 0&&(n=!0);const a=Y2(t),l=a===((r=t.ownerDocument)==null?void 0:r.body),c=ua(a);if(l){const d=cv(c);return s.concat(c,c.visualViewport||[],gu(a)?a:[],d&&n?Qd(d):[])}else return s.concat(a,Qd(a,[],n))}function cv(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Z2(t){const s=ei(t);let n=parseFloat(s.width)||0,r=parseFloat(s.height)||0;const a=tl(t),l=a?t.offsetWidth:n,c=a?t.offsetHeight:r,d=ym(n)!==l||ym(r)!==c;return d&&(n=l,r=c),{width:n,height:r,$:d}}function ib(t){return Ja(t)?t:t.contextElement}function Cc(t){const s=ib(t);if(!tl(s))return gi(1);const n=s.getBoundingClientRect(),{width:r,height:a,$:l}=Z2(s);let c=(l?ym(n.width):n.width)/r,d=(l?ym(n.height):n.height)/a;return(!c||!Number.isFinite(c))&&(c=1),(!d||!Number.isFinite(d))&&(d=1),{x:c,y:d}}const YL=gi(0);function Q2(t){const s=ua(t);return!ab()||!s.visualViewport?YL:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function ZL(t,s,n){return s===void 0&&(s=!1),!n||s&&n!==ua(t)?!1:s}function Bo(t,s,n,r){s===void 0&&(s=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),l=ib(t);let c=gi(1);s&&(r?Ja(r)&&(c=Cc(r)):c=Cc(t));const d=ZL(l,n,r)?Q2(l):gi(0);let h=(a.left+d.x)/c.x,x=(a.top+d.y)/c.y,f=a.width/c.x,m=a.height/c.y;if(l){const p=ua(l),u=r&&Ja(r)?ua(r):r;let j=p,g=cv(j);for(;g&&r&&u!==j;){const y=Cc(g),N=g.getBoundingClientRect(),S=ei(g),C=N.left+(g.clientLeft+parseFloat(S.paddingLeft))*y.x,w=N.top+(g.clientTop+parseFloat(S.paddingTop))*y.y;h*=y.x,x*=y.y,f*=y.x,m*=y.y,h+=C,x+=w,j=ua(g),g=cv(j)}}return Nm({width:f,height:m,x:h,y:x})}function tf(t,s){const n=ef(t).scrollLeft;return s?s.left+n:Bo(wi(t)).left+n}function X2(t,s){const n=t.getBoundingClientRect(),r=n.left+s.scrollLeft-tf(t,n),a=n.top+s.scrollTop;return{x:r,y:a}}function QL(t){let{elements:s,rect:n,offsetParent:r,strategy:a}=t;const l=a==="fixed",c=wi(r),d=s?Jm(s.floating):!1;if(r===c||d&&l)return n;let h={scrollLeft:0,scrollTop:0},x=gi(1);const f=gi(0),m=tl(r);if((m||!m&&!l)&&((Vc(r)!=="body"||gu(c))&&(h=ef(r)),m)){const u=Bo(r);x=Cc(r),f.x=u.x+r.clientLeft,f.y=u.y+r.clientTop}const p=c&&!m&&!l?X2(c,h):gi(0);return{width:n.width*x.x,height:n.height*x.y,x:n.x*x.x-h.scrollLeft*x.x+f.x+p.x,y:n.y*x.y-h.scrollTop*x.y+f.y+p.y}}function XL(t){return Array.from(t.getClientRects())}function JL(t){const s=wi(t),n=ef(t),r=t.ownerDocument.body,a=ia(s.scrollWidth,s.clientWidth,r.scrollWidth,r.clientWidth),l=ia(s.scrollHeight,s.clientHeight,r.scrollHeight,r.clientHeight);let c=-n.scrollLeft+tf(t);const d=-n.scrollTop;return ei(r).direction==="rtl"&&(c+=ia(s.clientWidth,r.clientWidth)-a),{width:a,height:l,x:c,y:d}}const Dw=25;function e6(t,s){const n=ua(t),r=wi(t),a=n.visualViewport;let l=r.clientWidth,c=r.clientHeight,d=0,h=0;if(a){l=a.width,c=a.height;const f=ab();(!f||f&&s==="fixed")&&(d=a.offsetLeft,h=a.offsetTop)}const x=tf(r);if(x<=0){const f=r.ownerDocument,m=f.body,p=getComputedStyle(m),u=f.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,j=Math.abs(r.clientWidth-m.clientWidth-u);j<=Dw&&(l-=j)}else x<=Dw&&(l+=x);return{width:l,height:c,x:d,y:h}}function t6(t,s){const n=Bo(t,!0,s==="fixed"),r=n.top+t.clientTop,a=n.left+t.clientLeft,l=tl(t)?Cc(t):gi(1),c=t.clientWidth*l.x,d=t.clientHeight*l.y,h=a*l.x,x=r*l.y;return{width:c,height:d,x:h,y:x}}function Tw(t,s,n){let r;if(s==="viewport")r=e6(t,n);else if(s==="document")r=JL(wi(t));else if(Ja(s))r=t6(s,n);else{const a=Q2(t);r={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return Nm(r)}function J2(t,s){const n=$l(t);return n===s||!Ja(n)||Pc(n)?!1:ei(n).position==="fixed"||J2(n,s)}function s6(t,s){const n=s.get(t);if(n)return n;let r=Qd(t,[],!1).filter(d=>Ja(d)&&Vc(d)!=="body"),a=null;const l=ei(t).position==="fixed";let c=l?$l(t):t;for(;Ja(c)&&!Pc(c);){const d=ei(c),h=rb(c);!h&&d.position==="fixed"&&(a=null),(l?!h&&!a:!h&&d.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||gu(c)&&!h&&J2(t,c))?r=r.filter(f=>f!==c):a=d,c=$l(c)}return s.set(t,r),r}function n6(t){let{element:s,boundary:n,rootBoundary:r,strategy:a}=t;const c=[...n==="clippingAncestors"?Jm(s)?[]:s6(s,this._c):[].concat(n),r],d=Tw(s,c[0],a);let h=d.top,x=d.right,f=d.bottom,m=d.left;for(let p=1;p<c.length;p++){const u=Tw(s,c[p],a);h=ia(u.top,h),x=Bl(u.right,x),f=Bl(u.bottom,f),m=ia(u.left,m)}return{width:x-m,height:f-h,x:m,y:h}}function r6(t){const{width:s,height:n}=Z2(t);return{width:s,height:n}}function a6(t,s,n){const r=tl(s),a=wi(s),l=n==="fixed",c=Bo(t,!0,l,s);let d={scrollLeft:0,scrollTop:0};const h=gi(0);function x(){h.x=tf(a)}if(r||!r&&!l)if((Vc(s)!=="body"||gu(a))&&(d=ef(s)),r){const u=Bo(s,!0,l,s);h.x=u.x+s.clientLeft,h.y=u.y+s.clientTop}else a&&x();l&&!r&&a&&x();const f=a&&!r&&!l?X2(a,d):gi(0),m=c.left+d.scrollLeft-h.x-f.x,p=c.top+d.scrollTop-h.y-f.y;return{x:m,y:p,width:c.width,height:c.height}}function _x(t){return ei(t).position==="static"}function Pw(t,s){if(!tl(t)||ei(t).position==="fixed")return null;if(s)return s(t);let n=t.offsetParent;return wi(t)===n&&(n=n.ownerDocument.body),n}function eA(t,s){const n=ua(t);if(Jm(t))return n;if(!tl(t)){let a=$l(t);for(;a&&!Pc(a);){if(Ja(a)&&!_x(a))return a;a=$l(a)}return n}let r=Pw(t,s);for(;r&&HL(r)&&_x(r);)r=Pw(r,s);return r&&Pc(r)&&_x(r)&&!rb(r)?n:r||KL(t)||n}const i6=async function(t){const s=this.getOffsetParent||eA,n=this.getDimensions,r=await n(t.floating);return{reference:a6(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function l6(t){return ei(t).direction==="rtl"}const o6={convertOffsetParentRelativeRectToViewportRelativeRect:QL,getDocumentElement:wi,getClippingRect:n6,getOffsetParent:eA,getElementRects:i6,getClientRects:XL,getDimensions:r6,getScale:Cc,isElement:Ja,isRTL:l6};function tA(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function c6(t,s){let n=null,r;const a=wi(t);function l(){var d;clearTimeout(r),(d=n)==null||d.disconnect(),n=null}function c(d,h){d===void 0&&(d=!1),h===void 0&&(h=1),l();const x=t.getBoundingClientRect(),{left:f,top:m,width:p,height:u}=x;if(d||s(),!p||!u)return;const j=Eh(m),g=Eh(a.clientWidth-(f+p)),y=Eh(a.clientHeight-(m+u)),N=Eh(f),C={rootMargin:-j+"px "+-g+"px "+-y+"px "+-N+"px",threshold:ia(0,Bl(1,h))||1};let w=!0;function R(P){const A=P[0].intersectionRatio;if(A!==h){if(!w)return c();A?c(!1,A):r=setTimeout(()=>{c(!1,1e-7)},1e3)}A===1&&!tA(x,t.getBoundingClientRect())&&c(),w=!1}try{n=new IntersectionObserver(R,{...C,root:a.ownerDocument})}catch{n=new IntersectionObserver(R,C)}n.observe(t)}return c(!0),l}function d6(t,s,n,r){r===void 0&&(r={});const{ancestorScroll:a=!0,ancestorResize:l=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:h=!1}=r,x=ib(t),f=a||l?[...x?Qd(x):[],...s?Qd(s):[]]:[];f.forEach(N=>{a&&N.addEventListener("scroll",n,{passive:!0}),l&&N.addEventListener("resize",n)});const m=x&&d?c6(x,n):null;let p=-1,u=null;c&&(u=new ResizeObserver(N=>{let[S]=N;S&&S.target===x&&u&&s&&(u.unobserve(s),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var C;(C=u)==null||C.observe(s)})),n()}),x&&!h&&u.observe(x),s&&u.observe(s));let j,g=h?Bo(t):null;h&&y();function y(){const N=Bo(t);g&&!tA(g,N)&&n(),g=N,j=requestAnimationFrame(y)}return n(),()=>{var N;f.forEach(S=>{a&&S.removeEventListener("scroll",n),l&&S.removeEventListener("resize",n)}),m==null||m(),(N=u)==null||N.disconnect(),u=null,h&&cancelAnimationFrame(j)}}const u6=qL,h6=zL,m6=FL,f6=VL,p6=BL,_w=ML,x6=UL,g6=(t,s,n)=>{const r=new Map,a={platform:o6,...n},l={...a.platform,_c:r};return LL(t,s,{...a,platform:l})};var v6=typeof document<"u",b6=function(){},Xh=v6?v.useLayoutEffect:b6;function wm(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(!wm(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 l=a[r];if(!(l==="_owner"&&t.$$typeof)&&!wm(t[l],s[l]))return!1}return!0}return t!==t&&s!==s}function sA(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Ow(t,s){const n=sA(t);return Math.round(s*n)/n}function Ox(t){const s=v.useRef(t);return Xh(()=>{s.current=t}),s}function y6(t){t===void 0&&(t={});const{placement:s="bottom",strategy:n="absolute",middleware:r=[],platform:a,elements:{reference:l,floating:c}={},transform:d=!0,whileElementsMounted:h,open:x}=t,[f,m]=v.useState({x:0,y:0,strategy:n,placement:s,middlewareData:{},isPositioned:!1}),[p,u]=v.useState(r);wm(p,r)||u(r);const[j,g]=v.useState(null),[y,N]=v.useState(null),S=v.useCallback(z=>{z!==P.current&&(P.current=z,g(z))},[]),C=v.useCallback(z=>{z!==A.current&&(A.current=z,N(z))},[]),w=l||j,R=c||y,P=v.useRef(null),A=v.useRef(null),I=v.useRef(f),$=h!=null,T=Ox(h),E=Ox(a),_=Ox(x),M=v.useCallback(()=>{if(!P.current||!A.current)return;const z={placement:s,strategy:n,middleware:p};E.current&&(z.platform=E.current),g6(P.current,A.current,z).then(F=>{const B={...F,isPositioned:_.current!==!1};q.current&&!wm(I.current,B)&&(I.current=B,cu.flushSync(()=>{m(B)}))})},[p,s,n,E,_]);Xh(()=>{x===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,m(z=>({...z,isPositioned:!1})))},[x]);const q=v.useRef(!1);Xh(()=>(q.current=!0,()=>{q.current=!1}),[]),Xh(()=>{if(w&&(P.current=w),R&&(A.current=R),w&&R){if(T.current)return T.current(w,R,M);M()}},[w,R,M,T,$]);const G=v.useMemo(()=>({reference:P,floating:A,setReference:S,setFloating:C}),[S,C]),Z=v.useMemo(()=>({reference:w,floating:R}),[w,R]),W=v.useMemo(()=>{const z={position:n,left:0,top:0};if(!Z.floating)return z;const F=Ow(Z.floating,f.x),B=Ow(Z.floating,f.y);return d?{...z,transform:"translate("+F+"px, "+B+"px)",...sA(Z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:B}},[n,d,Z.floating,f.x,f.y]);return v.useMemo(()=>({...f,update:M,refs:G,elements:Z,floatingStyles:W}),[f,M,G,Z,W])}const j6=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?_w({element:r.current,padding:a}).fn(n):{}:r?_w({element:r,padding:a}).fn(n):{}}}},N6=(t,s)=>{const n=u6(t);return{name:n.name,fn:n.fn,options:[t,s]}},w6=(t,s)=>{const n=h6(t);return{name:n.name,fn:n.fn,options:[t,s]}},S6=(t,s)=>({fn:x6(t).fn,options:[t,s]}),C6=(t,s)=>{const n=m6(t);return{name:n.name,fn:n.fn,options:[t,s]}},A6=(t,s)=>{const n=f6(t);return{name:n.name,fn:n.fn,options:[t,s]}},k6=(t,s)=>{const n=p6(t);return{name:n.name,fn:n.fn,options:[t,s]}},R6=(t,s)=>{const n=j6(t);return{name:n.name,fn:n.fn,options:[t,s]}};var E6="Arrow",nA=v.forwardRef((t,s)=>{const{children:n,width:r=10,height:a=5,...l}=t;return e.jsx(ps.svg,{...l,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"})})});nA.displayName=E6;var D6=nA,lb="Popper",[rA,Vl]=ea(lb),[T6,aA]=rA(lb),iA=t=>{const{__scopePopper:s,children:n}=t,[r,a]=v.useState(null);return e.jsx(T6,{scope:s,anchor:r,onAnchorChange:a,children:n})};iA.displayName=lb;var lA="PopperAnchor",oA=v.forwardRef((t,s)=>{const{__scopePopper:n,virtualRef:r,...a}=t,l=aA(lA,n),c=v.useRef(null),d=Ms(s,c),h=v.useRef(null);return v.useEffect(()=>{const x=h.current;h.current=(r==null?void 0:r.current)||c.current,x!==h.current&&l.onAnchorChange(h.current)}),r?null:e.jsx(ps.div,{...a,ref:d})});oA.displayName=lA;var ob="PopperContent",[P6,_6]=rA(ob),cA=v.forwardRef((t,s)=>{var X,ne,oe,re,ge,ve;const{__scopePopper:n,side:r="bottom",sideOffset:a=0,align:l="center",alignOffset:c=0,arrowPadding:d=0,avoidCollisions:h=!0,collisionBoundary:x=[],collisionPadding:f=0,sticky:m="partial",hideWhenDetached:p=!1,updatePositionStrategy:u="optimized",onPlaced:j,...g}=t,y=aA(ob,n),[N,S]=v.useState(null),C=Ms(s,Se=>S(Se)),[w,R]=v.useState(null),P=Gv(w),A=(P==null?void 0:P.width)??0,I=(P==null?void 0:P.height)??0,$=r+(l!=="center"?"-"+l:""),T=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},E=Array.isArray(x)?x:[x],_=E.length>0,M={padding:T,boundary:E.filter(I6),altBoundary:_},{refs:q,floatingStyles:G,placement:Z,isPositioned:W,middlewareData:z}=y6({strategy:"fixed",placement:$,whileElementsMounted:(...Se)=>d6(...Se,{animationFrame:u==="always"}),elements:{reference:y.anchor},middleware:[N6({mainAxis:a+I,alignmentAxis:c}),h&&w6({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?S6():void 0,...M}),h&&C6({...M}),A6({...M,apply:({elements:Se,rects:We,availableWidth:Ce,availableHeight:fe})=>{const{width:Ye,height:be}=We.reference,_e=Se.floating.style;_e.setProperty("--radix-popper-available-width",`${Ce}px`),_e.setProperty("--radix-popper-available-height",`${fe}px`),_e.setProperty("--radix-popper-anchor-width",`${Ye}px`),_e.setProperty("--radix-popper-anchor-height",`${be}px`)}}),w&&R6({element:w,padding:d}),L6({arrowWidth:A,arrowHeight:I}),p&&k6({strategy:"referenceHidden",...M})]}),[F,B]=hA(Z),D=dr(j);Zn(()=>{W&&(D==null||D())},[W,D]);const O=(X=z.arrow)==null?void 0:X.x,V=(ne=z.arrow)==null?void 0:ne.y,K=((oe=z.arrow)==null?void 0:oe.centerOffset)!==0,[Y,U]=v.useState();return Zn(()=>{N&&U(window.getComputedStyle(N).zIndex)},[N]),e.jsx("div",{ref:q.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:W?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Y,"--radix-popper-transform-origin":[(re=z.transformOrigin)==null?void 0:re.x,(ge=z.transformOrigin)==null?void 0:ge.y].join(" "),...((ve=z.hide)==null?void 0:ve.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(P6,{scope:n,placedSide:F,onArrowChange:R,arrowX:O,arrowY:V,shouldHideArrow:K,children:e.jsx(ps.div,{"data-side":F,"data-align":B,...g,ref:C,style:{...g.style,animation:W?void 0:"none"}})})})});cA.displayName=ob;var dA="PopperArrow",O6={top:"bottom",right:"left",bottom:"top",left:"right"},uA=v.forwardRef(function(s,n){const{__scopePopper:r,...a}=s,l=_6(dA,r),c=O6[l.placedSide];return e.jsx("span",{ref:l.onArrowChange,style:{position:"absolute",left:l.arrowX,top:l.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[l.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[l.placedSide],visibility:l.shouldHideArrow?"hidden":void 0},children:e.jsx(D6,{...a,ref:n,style:{...a.style,display:"block"}})})});uA.displayName=dA;function I6(t){return t!==null}var L6=t=>({name:"transformOrigin",options:t,fn(s){var y,N,S;const{placement:n,rects:r,middlewareData:a}=s,c=((y=a.arrow)==null?void 0:y.centerOffset)!==0,d=c?0:t.arrowWidth,h=c?0:t.arrowHeight,[x,f]=hA(n),m={start:"0%",center:"50%",end:"100%"}[f],p=(((N=a.arrow)==null?void 0:N.x)??0)+d/2,u=(((S=a.arrow)==null?void 0:S.y)??0)+h/2;let j="",g="";return x==="bottom"?(j=c?m:`${p}px`,g=`${-h}px`):x==="top"?(j=c?m:`${p}px`,g=`${r.floating.height+h}px`):x==="right"?(j=`${-h}px`,g=c?m:`${u}px`):x==="left"&&(j=`${r.floating.width+h}px`,g=c?m:`${u}px`),{data:{x:j,y:g}}}});function hA(t){const[s,n="center"]=t.split("-");return[s,n]}var sf=iA,vu=oA,nf=cA,rf=uA,M6="Portal",Hc=v.forwardRef((t,s)=>{var d;const{container:n,...r}=t,[a,l]=v.useState(!1);Zn(()=>l(!0),[]);const c=n||a&&((d=globalThis==null?void 0:globalThis.document)==null?void 0:d.body);return c?qv.createPortal(e.jsx(ps.div,{...r,ref:s}),c):null});Hc.displayName=M6;var Ix="rovingFocusGroup.onEntryFocus",F6={bubbles:!1,cancelable:!0},bu="RovingFocusGroup",[dv,mA,B6]=eb(bu),[$6,af]=ea(bu,[B6]),[q6,z6]=$6(bu),fA=v.forwardRef((t,s)=>e.jsx(dv.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(dv.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(U6,{...t,ref:s})})}));fA.displayName=bu;var U6=v.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:l,currentTabStopId:c,defaultCurrentTabStopId:d,onCurrentTabStopIdChange:h,onEntryFocus:x,preventScrollOnEntryFocus:f=!1,...m}=t,p=v.useRef(null),u=Ms(s,p),j=pu(l),[g,y]=bi({prop:c,defaultProp:d??null,onChange:h,caller:bu}),[N,S]=v.useState(!1),C=dr(x),w=mA(n),R=v.useRef(!1),[P,A]=v.useState(0);return v.useEffect(()=>{const I=p.current;if(I)return I.addEventListener(Ix,C),()=>I.removeEventListener(Ix,C)},[C]),e.jsx(q6,{scope:n,orientation:r,dir:j,loop:a,currentTabStopId:g,onItemFocus:v.useCallback(I=>y(I),[y]),onItemShiftTab:v.useCallback(()=>S(!0),[]),onFocusableItemAdd:v.useCallback(()=>A(I=>I+1),[]),onFocusableItemRemove:v.useCallback(()=>A(I=>I-1),[]),children:e.jsx(ps.div,{tabIndex:N||P===0?-1:0,"data-orientation":r,...m,ref:u,style:{outline:"none",...t.style},onMouseDown:Vt(t.onMouseDown,()=>{R.current=!0}),onFocus:Vt(t.onFocus,I=>{const $=!R.current;if(I.target===I.currentTarget&&$&&!N){const T=new CustomEvent(Ix,F6);if(I.currentTarget.dispatchEvent(T),!T.defaultPrevented){const E=w().filter(Z=>Z.focusable),_=E.find(Z=>Z.active),M=E.find(Z=>Z.id===g),G=[_,M,...E].filter(Boolean).map(Z=>Z.ref.current);gA(G,f)}}R.current=!1}),onBlur:Vt(t.onBlur,()=>S(!1))})})}),pA="RovingFocusGroupItem",xA=v.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:l,children:c,...d}=t,h=hr(),x=l||h,f=z6(pA,n),m=f.currentTabStopId===x,p=mA(n),{onFocusableItemAdd:u,onFocusableItemRemove:j,currentTabStopId:g}=f;return v.useEffect(()=>{if(r)return u(),()=>j()},[r,u,j]),e.jsx(dv.ItemSlot,{scope:n,id:x,focusable:r,active:a,children:e.jsx(ps.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...d,ref:s,onMouseDown:Vt(t.onMouseDown,y=>{r?f.onItemFocus(x):y.preventDefault()}),onFocus:Vt(t.onFocus,()=>f.onItemFocus(x)),onKeyDown:Vt(t.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){f.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const N=W6(y,f.orientation,f.dir);if(N!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let C=p().filter(w=>w.focusable).map(w=>w.ref.current);if(N==="last")C.reverse();else if(N==="prev"||N==="next"){N==="prev"&&C.reverse();const w=C.indexOf(y.currentTarget);C=f.loop?G6(C,w+1):C.slice(w+1)}setTimeout(()=>gA(C))}}),children:typeof c=="function"?c({isCurrentTabStop:m,hasTabStop:g!=null}):c})})});xA.displayName=pA;var V6={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function H6(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function W6(t,s,n){const r=H6(t.key,n);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return V6[r]}function gA(t,s=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:s}),document.activeElement!==n))return}function G6(t,s){return t.map((n,r)=>t[(s+r)%t.length])}var vA=fA,bA=xA;function K6(t){const s=Y6(t),n=v.forwardRef((r,a)=>{const{children:l,...c}=r,d=v.Children.toArray(l),h=d.find(Q6);if(h){const x=h.props.children,f=d.map(m=>m===h?v.Children.count(x)>1?v.Children.only(null):v.isValidElement(x)?x.props.children:null:m);return e.jsx(s,{...c,ref:a,children:v.isValidElement(x)?v.cloneElement(x,void 0,f):null})}return e.jsx(s,{...c,ref:a,children:l})});return n.displayName=`${t}.Slot`,n}function Y6(t){const s=v.forwardRef((n,r)=>{const{children:a,...l}=n;if(v.isValidElement(a)){const c=J6(a),d=X6(l,a.props);return a.type!==v.Fragment&&(d.ref=r?Br(r,c):c),v.cloneElement(a,d)}return v.Children.count(a)>1?v.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var Z6=Symbol("radix.slottable");function Q6(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Z6}function X6(t,s){const n={...s};for(const r in s){const a=t[r],l=s[r];/^on[A-Z]/.test(r)?a&&l?n[r]=(...d)=>{const h=l(...d);return a(...d),h}:a&&(n[r]=a):r==="style"?n[r]={...a,...l}:r==="className"&&(n[r]=[a,l].filter(Boolean).join(" "))}return{...t,...n}}function J6(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 e3=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},pc=new WeakMap,Dh=new WeakMap,Th={},Lx=0,yA=function(t){return t&&(t.host||yA(t.parentNode))},t3=function(t,s){return s.map(function(n){if(t.contains(n))return n;var r=yA(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})},s3=function(t,s,n,r){var a=t3(s,Array.isArray(t)?t:[t]);Th[n]||(Th[n]=new WeakMap);var l=Th[n],c=[],d=new Set,h=new Set(a),x=function(m){!m||d.has(m)||(d.add(m),x(m.parentNode))};a.forEach(x);var f=function(m){!m||h.has(m)||Array.prototype.forEach.call(m.children,function(p){if(d.has(p))f(p);else try{var u=p.getAttribute(r),j=u!==null&&u!=="false",g=(pc.get(p)||0)+1,y=(l.get(p)||0)+1;pc.set(p,g),l.set(p,y),c.push(p),g===1&&j&&Dh.set(p,!0),y===1&&p.setAttribute(n,"true"),j||p.setAttribute(r,"true")}catch(N){console.error("aria-hidden: cannot operate on ",p,N)}})};return f(s),d.clear(),Lx++,function(){c.forEach(function(m){var p=pc.get(m)-1,u=l.get(m)-1;pc.set(m,p),l.set(m,u),p||(Dh.has(m)||m.removeAttribute(r),Dh.delete(m)),u||m.removeAttribute(n)}),Lx--,Lx||(pc=new WeakMap,pc=new WeakMap,Dh=new WeakMap,Th={})}},lf=function(t,s,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),a=e3(t);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),s3(r,a,n,"aria-hidden")):function(){return null}},pi=function(){return pi=Object.assign||function(s){for(var n,r=1,a=arguments.length;r<a;r++){n=arguments[r];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(s[l]=n[l])}return s},pi.apply(this,arguments)};function jA(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 n3(t,s,n){if(n||arguments.length===2)for(var r=0,a=s.length,l;r<a;r++)(l||!(r in s))&&(l||(l=Array.prototype.slice.call(s,0,r)),l[r]=s[r]);return t.concat(l||Array.prototype.slice.call(s))}var Jh="right-scroll-bar-position",em="width-before-scroll-bar",r3="with-scroll-bars-hidden",a3="--removed-body-scroll-bar-size";function Mx(t,s){return typeof t=="function"?t(s):t&&(t.current=s),t}function i3(t,s){var n=v.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 l3=typeof window<"u"?v.useLayoutEffect:v.useEffect,Iw=new WeakMap;function o3(t,s){var n=i3(null,function(r){return t.forEach(function(a){return Mx(a,r)})});return l3(function(){var r=Iw.get(n);if(r){var a=new Set(r),l=new Set(t),c=n.current;a.forEach(function(d){l.has(d)||Mx(d,null)}),l.forEach(function(d){a.has(d)||Mx(d,c)})}Iw.set(n,t)},[t]),n}function c3(t){return t}function d3(t,s){s===void 0&&(s=c3);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(l){var c=s(l,r);return n.push(c),function(){n=n.filter(function(d){return d!==c})}},assignSyncMedium:function(l){for(r=!0;n.length;){var c=n;n=[],c.forEach(l)}n={push:function(d){return l(d)},filter:function(){return n}}},assignMedium:function(l){r=!0;var c=[];if(n.length){var d=n;n=[],d.forEach(l),c=n}var h=function(){var f=c;c=[],f.forEach(l)},x=function(){return Promise.resolve().then(h)};x(),n={push:function(f){c.push(f),x()},filter:function(f){return c=c.filter(f),n}}}};return a}function u3(t){t===void 0&&(t={});var s=d3(null);return s.options=pi({async:!0,ssr:!1},t),s}var NA=function(t){var s=t.sideCar,n=jA(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 v.createElement(r,pi({},n))};NA.isSideCarExport=!0;function h3(t,s){return t.useMedium(s),NA}var wA=u3(),Fx=function(){},of=v.forwardRef(function(t,s){var n=v.useRef(null),r=v.useState({onScrollCapture:Fx,onWheelCapture:Fx,onTouchMoveCapture:Fx}),a=r[0],l=r[1],c=t.forwardProps,d=t.children,h=t.className,x=t.removeScrollBar,f=t.enabled,m=t.shards,p=t.sideCar,u=t.noRelative,j=t.noIsolation,g=t.inert,y=t.allowPinchZoom,N=t.as,S=N===void 0?"div":N,C=t.gapMode,w=jA(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),R=p,P=o3([n,s]),A=pi(pi({},w),a);return v.createElement(v.Fragment,null,f&&v.createElement(R,{sideCar:wA,removeScrollBar:x,shards:m,noRelative:u,noIsolation:j,inert:g,setCallbacks:l,allowPinchZoom:!!y,lockRef:n,gapMode:C}),c?v.cloneElement(v.Children.only(d),pi(pi({},A),{ref:P})):v.createElement(S,pi({},A,{className:h,ref:P}),d))});of.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};of.classNames={fullWidth:em,zeroRight:Jh};var m3=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function f3(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var s=m3();return s&&t.setAttribute("nonce",s),t}function p3(t,s){t.styleSheet?t.styleSheet.cssText=s:t.appendChild(document.createTextNode(s))}function x3(t){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(t)}var g3=function(){var t=0,s=null;return{add:function(n){t==0&&(s=f3())&&(p3(s,n),x3(s)),t++},remove:function(){t--,!t&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},v3=function(){var t=g3();return function(s,n){v.useEffect(function(){return t.add(s),function(){t.remove()}},[s&&n])}},SA=function(){var t=v3(),s=function(n){var r=n.styles,a=n.dynamic;return t(r,a),null};return s},b3={left:0,top:0,right:0,gap:0},Bx=function(t){return parseInt(t||"",10)||0},y3=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[Bx(n),Bx(r),Bx(a)]},j3=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return b3;var s=y3(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])}},N3=SA(),Ac="data-scroll-locked",w3=function(t,s,n,r){var a=t.left,l=t.top,c=t.right,d=t.gap;return n===void 0&&(n="margin"),`
.`.concat(r3,` {
overflow: hidden `).concat(r,`;
padding-right: `).concat(d,"px ").concat(r,`;
}
body[`).concat(Ac,`] {
overflow: hidden `).concat(r,`;
overscroll-behavior: contain;
`).concat([s&&"position: relative ".concat(r,";"),n==="margin"&&`
padding-left: `.concat(a,`px;
padding-top: `).concat(l,`px;
padding-right: `).concat(c,`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(Jh,` {
right: `).concat(d,"px ").concat(r,`;
}
.`).concat(em,` {
margin-right: `).concat(d,"px ").concat(r,`;
}
.`).concat(Jh," .").concat(Jh,` {
right: 0 `).concat(r,`;
}
.`).concat(em," .").concat(em,` {
margin-right: 0 `).concat(r,`;
}
body[`).concat(Ac,`] {
`).concat(a3,": ").concat(d,`px;
}
`)},Lw=function(){var t=parseInt(document.body.getAttribute(Ac)||"0",10);return isFinite(t)?t:0},S3=function(){v.useEffect(function(){return document.body.setAttribute(Ac,(Lw()+1).toString()),function(){var t=Lw()-1;t<=0?document.body.removeAttribute(Ac):document.body.setAttribute(Ac,t.toString())}},[])},C3=function(t){var s=t.noRelative,n=t.noImportant,r=t.gapMode,a=r===void 0?"margin":r;S3();var l=v.useMemo(function(){return j3(a)},[a]);return v.createElement(N3,{styles:w3(l,!s,a,n?"":"!important")})},uv=!1;if(typeof window<"u")try{var Ph=Object.defineProperty({},"passive",{get:function(){return uv=!0,!0}});window.addEventListener("test",Ph,Ph),window.removeEventListener("test",Ph,Ph)}catch{uv=!1}var xc=uv?{passive:!1}:!1,A3=function(t){return t.tagName==="TEXTAREA"},CA=function(t,s){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[s]!=="hidden"&&!(n.overflowY===n.overflowX&&!A3(t)&&n[s]==="visible")},k3=function(t){return CA(t,"overflowY")},R3=function(t){return CA(t,"overflowX")},Mw=function(t,s){var n=s.ownerDocument,r=s;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=AA(t,r);if(a){var l=kA(t,r),c=l[1],d=l[2];if(c>d)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},E3=function(t){var s=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[s,n,r]},D3=function(t){var s=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[s,n,r]},AA=function(t,s){return t==="v"?k3(s):R3(s)},kA=function(t,s){return t==="v"?E3(s):D3(s)},T3=function(t,s){return t==="h"&&s==="rtl"?-1:1},P3=function(t,s,n,r,a){var l=T3(t,window.getComputedStyle(s).direction),c=l*r,d=n.target,h=s.contains(d),x=!1,f=c>0,m=0,p=0;do{if(!d)break;var u=kA(t,d),j=u[0],g=u[1],y=u[2],N=g-y-l*j;(j||N)&&AA(t,d)&&(m+=N,p+=j);var S=d.parentNode;d=S&&S.nodeType===Node.DOCUMENT_FRAGMENT_NODE?S.host:S}while(!h&&d!==document.body||h&&(s.contains(d)||s===d));return(f&&Math.abs(m)<1||!f&&Math.abs(p)<1)&&(x=!0),x},_h=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},Fw=function(t){return[t.deltaX,t.deltaY]},Bw=function(t){return t&&"current"in t?t.current:t},_3=function(t,s){return t[0]===s[0]&&t[1]===s[1]},O3=function(t){return`
.block-interactivity-`.concat(t,` {pointer-events: none;}
.allow-interactivity-`).concat(t,` {pointer-events: all;}
`)},I3=0,gc=[];function L3(t){var s=v.useRef([]),n=v.useRef([0,0]),r=v.useRef(),a=v.useState(I3++)[0],l=v.useState(SA)[0],c=v.useRef(t);v.useEffect(function(){c.current=t},[t]),v.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var g=n3([t.lockRef.current],(t.shards||[]).map(Bw),!0).filter(Boolean);return g.forEach(function(y){return y.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),g.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var d=v.useCallback(function(g,y){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!c.current.allowPinchZoom;var N=_h(g),S=n.current,C="deltaX"in g?g.deltaX:S[0]-N[0],w="deltaY"in g?g.deltaY:S[1]-N[1],R,P=g.target,A=Math.abs(C)>Math.abs(w)?"h":"v";if("touches"in g&&A==="h"&&P.type==="range")return!1;var I=window.getSelection(),$=I&&I.anchorNode,T=$?$===P||$.contains(P):!1;if(T)return!1;var E=Mw(A,P);if(!E)return!0;if(E?R=A:(R=A==="v"?"h":"v",E=Mw(A,P)),!E)return!1;if(!r.current&&"changedTouches"in g&&(C||w)&&(r.current=R),!R)return!0;var _=r.current||R;return P3(_,y,g,_==="h"?C:w)},[]),h=v.useCallback(function(g){var y=g;if(!(!gc.length||gc[gc.length-1]!==l)){var N="deltaY"in y?Fw(y):_h(y),S=s.current.filter(function(R){return R.name===y.type&&(R.target===y.target||y.target===R.shadowParent)&&_3(R.delta,N)})[0];if(S&&S.should){y.cancelable&&y.preventDefault();return}if(!S){var C=(c.current.shards||[]).map(Bw).filter(Boolean).filter(function(R){return R.contains(y.target)}),w=C.length>0?d(y,C[0]):!c.current.noIsolation;w&&y.cancelable&&y.preventDefault()}}},[]),x=v.useCallback(function(g,y,N,S){var C={name:g,delta:y,target:N,should:S,shadowParent:M3(N)};s.current.push(C),setTimeout(function(){s.current=s.current.filter(function(w){return w!==C})},1)},[]),f=v.useCallback(function(g){n.current=_h(g),r.current=void 0},[]),m=v.useCallback(function(g){x(g.type,Fw(g),g.target,d(g,t.lockRef.current))},[]),p=v.useCallback(function(g){x(g.type,_h(g),g.target,d(g,t.lockRef.current))},[]);v.useEffect(function(){return gc.push(l),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:p}),document.addEventListener("wheel",h,xc),document.addEventListener("touchmove",h,xc),document.addEventListener("touchstart",f,xc),function(){gc=gc.filter(function(g){return g!==l}),document.removeEventListener("wheel",h,xc),document.removeEventListener("touchmove",h,xc),document.removeEventListener("touchstart",f,xc)}},[]);var u=t.removeScrollBar,j=t.inert;return v.createElement(v.Fragment,null,j?v.createElement(l,{styles:O3(a)}):null,u?v.createElement(C3,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function M3(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const F3=h3(wA,L3);var yu=v.forwardRef(function(t,s){return v.createElement(of,pi({},t,{ref:s,sideCar:F3}))});yu.classNames=of.classNames;var hv=["Enter"," "],B3=["ArrowDown","PageUp","Home"],RA=["ArrowUp","PageDown","End"],$3=[...B3,...RA],q3={ltr:[...hv,"ArrowRight"],rtl:[...hv,"ArrowLeft"]},z3={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ju="Menu",[Xd,U3,V3]=eb(ju),[Ho,EA]=ea(ju,[V3,Vl,af]),cf=Vl(),DA=af(),[H3,Wo]=Ho(ju),[W3,Nu]=Ho(ju),TA=t=>{const{__scopeMenu:s,open:n=!1,children:r,dir:a,onOpenChange:l,modal:c=!0}=t,d=cf(s),[h,x]=v.useState(null),f=v.useRef(!1),m=dr(l),p=pu(a);return v.useEffect(()=>{const u=()=>{f.current=!0,document.addEventListener("pointerdown",j,{capture:!0,once:!0}),document.addEventListener("pointermove",j,{capture:!0,once:!0})},j=()=>f.current=!1;return document.addEventListener("keydown",u,{capture:!0}),()=>{document.removeEventListener("keydown",u,{capture:!0}),document.removeEventListener("pointerdown",j,{capture:!0}),document.removeEventListener("pointermove",j,{capture:!0})}},[]),e.jsx(sf,{...d,children:e.jsx(H3,{scope:s,open:n,onOpenChange:m,content:h,onContentChange:x,children:e.jsx(W3,{scope:s,onClose:v.useCallback(()=>m(!1),[m]),isUsingKeyboardRef:f,dir:p,modal:c,children:r})})})};TA.displayName=ju;var G3="MenuAnchor",cb=v.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t,a=cf(n);return e.jsx(vu,{...a,...r,ref:s})});cb.displayName=G3;var db="MenuPortal",[K3,PA]=Ho(db,{forceMount:void 0}),_A=t=>{const{__scopeMenu:s,forceMount:n,children:r,container:a}=t,l=Wo(db,s);return e.jsx(K3,{scope:s,forceMount:n,children:e.jsx(mr,{present:n||l.open,children:e.jsx(Hc,{asChild:!0,container:a,children:r})})})};_A.displayName=db;var ka="MenuContent",[Y3,ub]=Ho(ka),OA=v.forwardRef((t,s)=>{const n=PA(ka,t.__scopeMenu),{forceMount:r=n.forceMount,...a}=t,l=Wo(ka,t.__scopeMenu),c=Nu(ka,t.__scopeMenu);return e.jsx(Xd.Provider,{scope:t.__scopeMenu,children:e.jsx(mr,{present:r||l.open,children:e.jsx(Xd.Slot,{scope:t.__scopeMenu,children:c.modal?e.jsx(Z3,{...a,ref:s}):e.jsx(Q3,{...a,ref:s})})})})}),Z3=v.forwardRef((t,s)=>{const n=Wo(ka,t.__scopeMenu),r=v.useRef(null),a=Ms(s,r);return v.useEffect(()=>{const l=r.current;if(l)return lf(l)},[]),e.jsx(hb,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Vt(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Q3=v.forwardRef((t,s)=>{const n=Wo(ka,t.__scopeMenu);return e.jsx(hb,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),X3=K6("MenuContent.ScrollLock"),hb=v.forwardRef((t,s)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:a,onOpenAutoFocus:l,onCloseAutoFocus:c,disableOutsidePointerEvents:d,onEntryFocus:h,onEscapeKeyDown:x,onPointerDownOutside:f,onFocusOutside:m,onInteractOutside:p,onDismiss:u,disableOutsideScroll:j,...g}=t,y=Wo(ka,n),N=Nu(ka,n),S=cf(n),C=DA(n),w=U3(n),[R,P]=v.useState(null),A=v.useRef(null),I=Ms(s,A,y.onContentChange),$=v.useRef(0),T=v.useRef(""),E=v.useRef(0),_=v.useRef(null),M=v.useRef("right"),q=v.useRef(0),G=j?yu:v.Fragment,Z=j?{as:X3,allowPinchZoom:!0}:void 0,W=F=>{var X,ne;const B=T.current+F,D=w().filter(oe=>!oe.disabled),O=document.activeElement,V=(X=D.find(oe=>oe.ref.current===O))==null?void 0:X.textValue,K=D.map(oe=>oe.textValue),Y=dM(K,B,V),U=(ne=D.find(oe=>oe.textValue===Y))==null?void 0:ne.ref.current;(function oe(re){T.current=re,window.clearTimeout($.current),re!==""&&($.current=window.setTimeout(()=>oe(""),1e3))})(B),U&&setTimeout(()=>U.focus())};v.useEffect(()=>()=>window.clearTimeout($.current),[]),Qm();const z=v.useCallback(F=>{var D,O;return M.current===((D=_.current)==null?void 0:D.side)&&hM(F,(O=_.current)==null?void 0:O.area)},[]);return e.jsx(Y3,{scope:n,searchRef:T,onItemEnter:v.useCallback(F=>{z(F)&&F.preventDefault()},[z]),onItemLeave:v.useCallback(F=>{var B;z(F)||((B=A.current)==null||B.focus(),P(null))},[z]),onTriggerLeave:v.useCallback(F=>{z(F)&&F.preventDefault()},[z]),pointerGraceTimerRef:E,onPointerGraceIntentChange:v.useCallback(F=>{_.current=F},[]),children:e.jsx(G,{...Z,children:e.jsx(xu,{asChild:!0,trapped:a,onMountAutoFocus:Vt(l,F=>{var B;F.preventDefault(),(B=A.current)==null||B.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:e.jsx(zc,{asChild:!0,disableOutsidePointerEvents:d,onEscapeKeyDown:x,onPointerDownOutside:f,onFocusOutside:m,onInteractOutside:p,onDismiss:u,children:e.jsx(vA,{asChild:!0,...C,dir:N.dir,orientation:"vertical",loop:r,currentTabStopId:R,onCurrentTabStopIdChange:P,onEntryFocus:Vt(h,F=>{N.isUsingKeyboardRef.current||F.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(nf,{role:"menu","aria-orientation":"vertical","data-state":ZA(y.open),"data-radix-menu-content":"",dir:N.dir,...S,...g,ref:I,style:{outline:"none",...g.style},onKeyDown:Vt(g.onKeyDown,F=>{const D=F.target.closest("[data-radix-menu-content]")===F.currentTarget,O=F.ctrlKey||F.altKey||F.metaKey,V=F.key.length===1;D&&(F.key==="Tab"&&F.preventDefault(),!O&&V&&W(F.key));const K=A.current;if(F.target!==K||!$3.includes(F.key))return;F.preventDefault();const U=w().filter(X=>!X.disabled).map(X=>X.ref.current);RA.includes(F.key)&&U.reverse(),oM(U)}),onBlur:Vt(t.onBlur,F=>{F.currentTarget.contains(F.target)||(window.clearTimeout($.current),T.current="")}),onPointerMove:Vt(t.onPointerMove,Jd(F=>{const B=F.target,D=q.current!==F.clientX;if(F.currentTarget.contains(B)&&D){const O=F.clientX>q.current?"right":"left";M.current=O,q.current=F.clientX}}))})})})})})})});OA.displayName=ka;var J3="MenuGroup",mb=v.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t;return e.jsx(ps.div,{role:"group",...r,ref:s})});mb.displayName=J3;var eM="MenuLabel",IA=v.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t;return e.jsx(ps.div,{...r,ref:s})});IA.displayName=eM;var Sm="MenuItem",$w="menu.itemSelect",df=v.forwardRef((t,s)=>{const{disabled:n=!1,onSelect:r,...a}=t,l=v.useRef(null),c=Nu(Sm,t.__scopeMenu),d=ub(Sm,t.__scopeMenu),h=Ms(s,l),x=v.useRef(!1),f=()=>{const m=l.current;if(!n&&m){const p=new CustomEvent($w,{bubbles:!0,cancelable:!0});m.addEventListener($w,u=>r==null?void 0:r(u),{once:!0}),S2(m,p),p.defaultPrevented?x.current=!1:c.onClose()}};return e.jsx(LA,{...a,ref:h,disabled:n,onClick:Vt(t.onClick,f),onPointerDown:m=>{var p;(p=t.onPointerDown)==null||p.call(t,m),x.current=!0},onPointerUp:Vt(t.onPointerUp,m=>{var p;x.current||(p=m.currentTarget)==null||p.click()}),onKeyDown:Vt(t.onKeyDown,m=>{const p=d.searchRef.current!=="";n||p&&m.key===" "||hv.includes(m.key)&&(m.currentTarget.click(),m.preventDefault())})})});df.displayName=Sm;var LA=v.forwardRef((t,s)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...l}=t,c=ub(Sm,n),d=DA(n),h=v.useRef(null),x=Ms(s,h),[f,m]=v.useState(!1),[p,u]=v.useState("");return v.useEffect(()=>{const j=h.current;j&&u((j.textContent??"").trim())},[l.children]),e.jsx(Xd.ItemSlot,{scope:n,disabled:r,textValue:a??p,children:e.jsx(bA,{asChild:!0,...d,focusable:!r,children:e.jsx(ps.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...l,ref:x,onPointerMove:Vt(t.onPointerMove,Jd(j=>{r?c.onItemLeave(j):(c.onItemEnter(j),j.defaultPrevented||j.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Vt(t.onPointerLeave,Jd(j=>c.onItemLeave(j))),onFocus:Vt(t.onFocus,()=>m(!0)),onBlur:Vt(t.onBlur,()=>m(!1))})})})}),tM="MenuCheckboxItem",MA=v.forwardRef((t,s)=>{const{checked:n=!1,onCheckedChange:r,...a}=t;return e.jsx(zA,{scope:t.__scopeMenu,checked:n,children:e.jsx(df,{role:"menuitemcheckbox","aria-checked":Cm(n)?"mixed":n,...a,ref:s,"data-state":pb(n),onSelect:Vt(a.onSelect,()=>r==null?void 0:r(Cm(n)?!0:!n),{checkForDefaultPrevented:!1})})})});MA.displayName=tM;var FA="MenuRadioGroup",[sM,nM]=Ho(FA,{value:void 0,onValueChange:()=>{}}),BA=v.forwardRef((t,s)=>{const{value:n,onValueChange:r,...a}=t,l=dr(r);return e.jsx(sM,{scope:t.__scopeMenu,value:n,onValueChange:l,children:e.jsx(mb,{...a,ref:s})})});BA.displayName=FA;var $A="MenuRadioItem",qA=v.forwardRef((t,s)=>{const{value:n,...r}=t,a=nM($A,t.__scopeMenu),l=n===a.value;return e.jsx(zA,{scope:t.__scopeMenu,checked:l,children:e.jsx(df,{role:"menuitemradio","aria-checked":l,...r,ref:s,"data-state":pb(l),onSelect:Vt(r.onSelect,()=>{var c;return(c=a.onValueChange)==null?void 0:c.call(a,n)},{checkForDefaultPrevented:!1})})})});qA.displayName=$A;var fb="MenuItemIndicator",[zA,rM]=Ho(fb,{checked:!1}),UA=v.forwardRef((t,s)=>{const{__scopeMenu:n,forceMount:r,...a}=t,l=rM(fb,n);return e.jsx(mr,{present:r||Cm(l.checked)||l.checked===!0,children:e.jsx(ps.span,{...a,ref:s,"data-state":pb(l.checked)})})});UA.displayName=fb;var aM="MenuSeparator",VA=v.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t;return e.jsx(ps.div,{role:"separator","aria-orientation":"horizontal",...r,ref:s})});VA.displayName=aM;var iM="MenuArrow",HA=v.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t,a=cf(n);return e.jsx(rf,{...a,...r,ref:s})});HA.displayName=iM;var lM="MenuSub",[FH,WA]=Ho(lM),Od="MenuSubTrigger",GA=v.forwardRef((t,s)=>{const n=Wo(Od,t.__scopeMenu),r=Nu(Od,t.__scopeMenu),a=WA(Od,t.__scopeMenu),l=ub(Od,t.__scopeMenu),c=v.useRef(null),{pointerGraceTimerRef:d,onPointerGraceIntentChange:h}=l,x={__scopeMenu:t.__scopeMenu},f=v.useCallback(()=>{c.current&&window.clearTimeout(c.current),c.current=null},[]);return v.useEffect(()=>f,[f]),v.useEffect(()=>{const m=d.current;return()=>{window.clearTimeout(m),h(null)}},[d,h]),e.jsx(cb,{asChild:!0,...x,children:e.jsx(LA,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":ZA(n.open),...t,ref:Br(s,a.onTriggerChange),onClick:m=>{var p;(p=t.onClick)==null||p.call(t,m),!(t.disabled||m.defaultPrevented)&&(m.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Vt(t.onPointerMove,Jd(m=>{l.onItemEnter(m),!m.defaultPrevented&&!t.disabled&&!n.open&&!c.current&&(l.onPointerGraceIntentChange(null),c.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:Vt(t.onPointerLeave,Jd(m=>{var u,j;f();const p=(u=n.content)==null?void 0:u.getBoundingClientRect();if(p){const g=(j=n.content)==null?void 0:j.dataset.side,y=g==="right",N=y?-5:5,S=p[y?"left":"right"],C=p[y?"right":"left"];l.onPointerGraceIntentChange({area:[{x:m.clientX+N,y:m.clientY},{x:S,y:p.top},{x:C,y:p.top},{x:C,y:p.bottom},{x:S,y:p.bottom}],side:g}),window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.onPointerGraceIntentChange(null),300)}else{if(l.onTriggerLeave(m),m.defaultPrevented)return;l.onPointerGraceIntentChange(null)}})),onKeyDown:Vt(t.onKeyDown,m=>{var u;const p=l.searchRef.current!=="";t.disabled||p&&m.key===" "||q3[r.dir].includes(m.key)&&(n.onOpenChange(!0),(u=n.content)==null||u.focus(),m.preventDefault())})})})});GA.displayName=Od;var KA="MenuSubContent",YA=v.forwardRef((t,s)=>{const n=PA(ka,t.__scopeMenu),{forceMount:r=n.forceMount,...a}=t,l=Wo(ka,t.__scopeMenu),c=Nu(ka,t.__scopeMenu),d=WA(KA,t.__scopeMenu),h=v.useRef(null),x=Ms(s,h);return e.jsx(Xd.Provider,{scope:t.__scopeMenu,children:e.jsx(mr,{present:r||l.open,children:e.jsx(Xd.Slot,{scope:t.__scopeMenu,children:e.jsx(hb,{id:d.contentId,"aria-labelledby":d.triggerId,...a,ref:x,align:"start",side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{var m;c.isUsingKeyboardRef.current&&((m=h.current)==null||m.focus()),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:Vt(t.onFocusOutside,f=>{f.target!==d.trigger&&l.onOpenChange(!1)}),onEscapeKeyDown:Vt(t.onEscapeKeyDown,f=>{c.onClose(),f.preventDefault()}),onKeyDown:Vt(t.onKeyDown,f=>{var u;const m=f.currentTarget.contains(f.target),p=z3[c.dir].includes(f.key);m&&p&&(l.onOpenChange(!1),(u=d.trigger)==null||u.focus(),f.preventDefault())})})})})})});YA.displayName=KA;function ZA(t){return t?"open":"closed"}function Cm(t){return t==="indeterminate"}function pb(t){return Cm(t)?"indeterminate":t?"checked":"unchecked"}function oM(t){const s=document.activeElement;for(const n of t)if(n===s||(n.focus(),document.activeElement!==s))return}function cM(t,s){return t.map((n,r)=>t[(s+r)%t.length])}function dM(t,s,n){const a=s.length>1&&Array.from(s).every(x=>x===s[0])?s[0]:s,l=n?t.indexOf(n):-1;let c=cM(t,Math.max(l,0));a.length===1&&(c=c.filter(x=>x!==n));const h=c.find(x=>x.toLowerCase().startsWith(a.toLowerCase()));return h!==n?h:void 0}function uM(t,s){const{x:n,y:r}=t;let a=!1;for(let l=0,c=s.length-1;l<s.length;c=l++){const d=s[l],h=s[c],x=d.x,f=d.y,m=h.x,p=h.y;f>r!=p>r&&n<(m-x)*(r-f)/(p-f)+x&&(a=!a)}return a}function hM(t,s){if(!s)return!1;const n={x:t.clientX,y:t.clientY};return uM(n,s)}function Jd(t){return s=>s.pointerType==="mouse"?t(s):void 0}var mM=TA,fM=cb,pM=_A,xM=OA,gM=mb,vM=IA,bM=df,yM=MA,jM=BA,NM=qA,wM=UA,SM=VA,CM=HA,AM=GA,kM=YA,uf="DropdownMenu",[RM]=ea(uf,[EA]),Ur=EA(),[EM,QA]=RM(uf),XA=t=>{const{__scopeDropdownMenu:s,children:n,dir:r,open:a,defaultOpen:l,onOpenChange:c,modal:d=!0}=t,h=Ur(s),x=v.useRef(null),[f,m]=bi({prop:a,defaultProp:l??!1,onChange:c,caller:uf});return e.jsx(EM,{scope:s,triggerId:hr(),triggerRef:x,contentId:hr(),open:f,onOpenChange:m,onOpenToggle:v.useCallback(()=>m(p=>!p),[m]),modal:d,children:e.jsx(mM,{...h,open:f,onOpenChange:m,dir:r,modal:d,children:n})})};XA.displayName=uf;var JA="DropdownMenuTrigger",ek=v.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=t,l=QA(JA,n),c=Ur(n);return e.jsx(fM,{asChild:!0,...c,children:e.jsx(ps.button,{type:"button",id:l.triggerId,"aria-haspopup":"menu","aria-expanded":l.open,"aria-controls":l.open?l.contentId:void 0,"data-state":l.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:Br(s,l.triggerRef),onPointerDown:Vt(t.onPointerDown,d=>{!r&&d.button===0&&d.ctrlKey===!1&&(l.onOpenToggle(),l.open||d.preventDefault())}),onKeyDown:Vt(t.onKeyDown,d=>{r||(["Enter"," "].includes(d.key)&&l.onOpenToggle(),d.key==="ArrowDown"&&l.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(d.key)&&d.preventDefault())})})})});ek.displayName=JA;var DM="DropdownMenuPortal",tk=t=>{const{__scopeDropdownMenu:s,...n}=t,r=Ur(s);return e.jsx(pM,{...r,...n})};tk.displayName=DM;var sk="DropdownMenuContent",nk=v.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=QA(sk,n),l=Ur(n),c=v.useRef(!1);return e.jsx(xM,{id:a.contentId,"aria-labelledby":a.triggerId,...l,...r,ref:s,onCloseAutoFocus:Vt(t.onCloseAutoFocus,d=>{var h;c.current||(h=a.triggerRef.current)==null||h.focus(),c.current=!1,d.preventDefault()}),onInteractOutside:Vt(t.onInteractOutside,d=>{const h=d.detail.originalEvent,x=h.button===0&&h.ctrlKey===!0,f=h.button===2||x;(!a.modal||f)&&(c.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)"}})});nk.displayName=sk;var TM="DropdownMenuGroup",PM=v.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Ur(n);return e.jsx(gM,{...a,...r,ref:s})});PM.displayName=TM;var _M="DropdownMenuLabel",rk=v.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Ur(n);return e.jsx(vM,{...a,...r,ref:s})});rk.displayName=_M;var OM="DropdownMenuItem",ak=v.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Ur(n);return e.jsx(bM,{...a,...r,ref:s})});ak.displayName=OM;var IM="DropdownMenuCheckboxItem",ik=v.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Ur(n);return e.jsx(yM,{...a,...r,ref:s})});ik.displayName=IM;var LM="DropdownMenuRadioGroup",MM=v.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Ur(n);return e.jsx(jM,{...a,...r,ref:s})});MM.displayName=LM;var FM="DropdownMenuRadioItem",BM=v.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Ur(n);return e.jsx(NM,{...a,...r,ref:s})});BM.displayName=FM;var $M="DropdownMenuItemIndicator",lk=v.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Ur(n);return e.jsx(wM,{...a,...r,ref:s})});lk.displayName=$M;var qM="DropdownMenuSeparator",ok=v.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Ur(n);return e.jsx(SM,{...a,...r,ref:s})});ok.displayName=qM;var zM="DropdownMenuArrow",UM=v.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Ur(n);return e.jsx(CM,{...a,...r,ref:s})});UM.displayName=zM;var VM="DropdownMenuSubTrigger",HM=v.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Ur(n);return e.jsx(AM,{...a,...r,ref:s})});HM.displayName=VM;var WM="DropdownMenuSubContent",GM=v.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Ur(n);return e.jsx(kM,{...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)"}})});GM.displayName=WM;var KM=XA,YM=ek,ZM=tk,QM=nk,XM=rk,JM=ak,eF=ik,tF=lk,sF=ok;function xb({...t}){return e.jsx(KM,{"data-slot":"dropdown-menu",...t})}function gb({...t}){return e.jsx(YM,{"data-slot":"dropdown-menu-trigger",...t})}function vb({className:t,sideOffset:s=4,...n}){return e.jsx(ZM,{children:e.jsx(QM,{"data-slot":"dropdown-menu-content",sideOffset:s,className:Pt("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 ck({className:t,inset:s,variant:n="default",...r}){return e.jsx(JM,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":n,className:Pt("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 nF({className:t,children:s,checked:n,...r}){return e.jsxs(eF,{"data-slot":"dropdown-menu-checkbox-item",className:Pt("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(tF,{children:e.jsx(Bn,{className:"size-4"})})}),s]})}function rF({className:t,inset:s,...n}){return e.jsx(XM,{"data-slot":"dropdown-menu-label","data-inset":s,className:Pt("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",t),...n})}function aF({className:t,...s}){return e.jsx(sF,{"data-slot":"dropdown-menu-separator",className:Pt("bg-border -mx-1 my-1 h-px",t),...s})}const iF=Vv("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 Ae({className:t,variant:s,asChild:n=!1,...r}){const a=n?x2:"span";return e.jsx(a,{"data-slot":"badge",className:Pt(iF({variant:s}),t),...r})}const Oh="/communication",_o={getNotifications:async(t,s)=>{let n=`${Oh}/notifications`;return t&&s&&(n+=`?page=${t}&limit=${s}`),(await ze.get(n)).data},markAsRead:async t=>(await ze.patch(`${Oh}/notifications/${t}/read`)).data,markAllAsRead:async()=>(await ze.patch(`${Oh}/notifications/read-all`)).data,updatePushSubscription:async t=>(await ze.post(`${Oh}/notifications/subscribe`,{subscription:t})).data},yi=Object.create(null);yi.open="0";yi.close="1";yi.ping="2";yi.pong="3";yi.message="4";yi.upgrade="5";yi.noop="6";const tm=Object.create(null);Object.keys(yi).forEach(t=>{tm[yi[t]]=t});const mv={type:"error",data:"parser error"},dk=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",uk=typeof ArrayBuffer=="function",hk=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,bb=({type:t,data:s},n,r)=>dk&&s instanceof Blob?n?r(s):qw(s,r):uk&&(s instanceof ArrayBuffer||hk(s))?n?r(s):qw(new Blob([s]),r):r(yi[t]+(s||"")),qw=(t,s)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];s("b"+(r||""))},n.readAsDataURL(t)};function zw(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let $x;function lF(t,s){if(dk&&t.data instanceof Blob)return t.data.arrayBuffer().then(zw).then(s);if(uk&&(t.data instanceof ArrayBuffer||hk(t.data)))return s(zw(t.data));bb(t,!1,n=>{$x||($x=new TextEncoder),s($x.encode(n))})}const Uw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Id=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<Uw.length;t++)Id[Uw.charCodeAt(t)]=t;const oF=t=>{let s=t.length*.75,n=t.length,r,a=0,l,c,d,h;t[t.length-1]==="="&&(s--,t[t.length-2]==="="&&s--);const x=new ArrayBuffer(s),f=new Uint8Array(x);for(r=0;r<n;r+=4)l=Id[t.charCodeAt(r)],c=Id[t.charCodeAt(r+1)],d=Id[t.charCodeAt(r+2)],h=Id[t.charCodeAt(r+3)],f[a++]=l<<2|c>>4,f[a++]=(c&15)<<4|d>>2,f[a++]=(d&3)<<6|h&63;return x},cF=typeof ArrayBuffer=="function",yb=(t,s)=>{if(typeof t!="string")return{type:"message",data:mk(t,s)};const n=t.charAt(0);return n==="b"?{type:"message",data:dF(t.substring(1),s)}:tm[n]?t.length>1?{type:tm[n],data:t.substring(1)}:{type:tm[n]}:mv},dF=(t,s)=>{if(cF){const n=oF(t);return mk(n,s)}else return{base64:!0,data:t}},mk=(t,s)=>{switch(s){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},fk="",uF=(t,s)=>{const n=t.length,r=new Array(n);let a=0;t.forEach((l,c)=>{bb(l,!1,d=>{r[c]=d,++a===n&&s(r.join(fk))})})},hF=(t,s)=>{const n=t.split(fk),r=[];for(let a=0;a<n.length;a++){const l=yb(n[a],s);if(r.push(l),l.type==="error")break}return r};function mF(){return new TransformStream({transform(t,s){lF(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 l=new DataView(a.buffer);l.setUint8(0,126),l.setUint16(1,r)}else{a=new Uint8Array(9);const l=new DataView(a.buffer);l.setUint8(0,127),l.setBigUint64(1,BigInt(r))}t.data&&typeof t.data!="string"&&(a[0]|=128),s.enqueue(a),s.enqueue(n)})}})}let qx;function Ih(t){return t.reduce((s,n)=>s+n.length,0)}function Lh(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 fF(t,s){qx||(qx=new TextDecoder);const n=[];let r=0,a=-1,l=!1;return new TransformStream({transform(c,d){for(n.push(c);;){if(r===0){if(Ih(n)<1)break;const h=Lh(n,1);l=(h[0]&128)===128,a=h[0]&127,a<126?r=3:a===126?r=1:r=2}else if(r===1){if(Ih(n)<2)break;const h=Lh(n,2);a=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),r=3}else if(r===2){if(Ih(n)<8)break;const h=Lh(n,8),x=new DataView(h.buffer,h.byteOffset,h.length),f=x.getUint32(0);if(f>Math.pow(2,21)-1){d.enqueue(mv);break}a=f*Math.pow(2,32)+x.getUint32(4),r=3}else{if(Ih(n)<a)break;const h=Lh(n,a);d.enqueue(yb(l?h:qx.decode(h),s)),r=0}if(a===0||a>t){d.enqueue(mv);break}}}})}const pk=4;function Kn(t){if(t)return pF(t)}function pF(t){for(var s in Kn.prototype)t[s]=Kn.prototype[s];return t}Kn.prototype.on=Kn.prototype.addEventListener=function(t,s){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(s),this};Kn.prototype.once=function(t,s){function n(){this.off(t,n),s.apply(this,arguments)}return n.fn=s,this.on(t,n),this};Kn.prototype.off=Kn.prototype.removeListener=Kn.prototype.removeAllListeners=Kn.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};Kn.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};Kn.prototype.emitReserved=Kn.prototype.emit;Kn.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};Kn.prototype.hasListeners=function(t){return!!this.listeners(t).length};const hf=typeof Promise=="function"&&typeof Promise.resolve=="function"?s=>Promise.resolve().then(s):(s,n)=>n(s,0),Aa=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),xF="arraybuffer";function xk(t,...s){return s.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{})}const gF=Aa.setTimeout,vF=Aa.clearTimeout;function mf(t,s){s.useNativeTimers?(t.setTimeoutFn=gF.bind(Aa),t.clearTimeoutFn=vF.bind(Aa)):(t.setTimeoutFn=Aa.setTimeout.bind(Aa),t.clearTimeoutFn=Aa.clearTimeout.bind(Aa))}const bF=1.33;function yF(t){return typeof t=="string"?jF(t):Math.ceil((t.byteLength||t.size)*bF)}function jF(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 gk(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function NF(t){let s="";for(let n in t)t.hasOwnProperty(n)&&(s.length&&(s+="&"),s+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return s}function wF(t){let s={},n=t.split("&");for(let r=0,a=n.length;r<a;r++){let l=n[r].split("=");s[decodeURIComponent(l[0])]=decodeURIComponent(l[1])}return s}class SF extends Error{constructor(s,n,r){super(s),this.description=n,this.context=r,this.type="TransportError"}}class jb extends Kn{constructor(s){super(),this.writable=!1,mf(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 SF(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=yb(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=NF(s);return n.length?"?"+n:""}}class CF extends jb{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)};hF(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,uF(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]=gk()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(s,n)}}let vk=!1;try{vk=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const AF=vk;function kF(){}class RF extends CF{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,l)=>{this.onError("xhr post error",a,l)})}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 vi extends Kn{constructor(s,n,r){super(),this.createRequest=s,mf(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=xk(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=vi.requestsCount++,vi.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=kF,s)try{this._xhr.abort()}catch{}typeof document<"u"&&delete vi.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()}}vi.requestsCount=0;vi.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Vw);else if(typeof addEventListener=="function"){const t="onpagehide"in Aa?"pagehide":"unload";addEventListener(t,Vw,!1)}}function Vw(){for(let t in vi.requests)vi.requests.hasOwnProperty(t)&&vi.requests[t].abort()}const EF=(function(){const t=bk({xdomain:!1});return t&&t.responseType!==null})();class DF extends RF{constructor(s){super(s);const n=s&&s.forceBase64;this.supportsBinary=EF&&!n}request(s={}){return Object.assign(s,{xd:this.xd},this.opts),new vi(bk,this.uri(),s)}}function bk(t){const s=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!s||AF))return new XMLHttpRequest}catch{}if(!s)try{return new Aa[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const yk=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class TF extends jb{get name(){return"websocket"}doOpen(){const s=this.uri(),n=this.opts.protocols,r=yk?{}:xk(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;bb(r,this.supportsBinary,l=>{try{this.doWrite(r,l)}catch{}a&&hf(()=>{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]=gk()),this.supportsBinary||(n.b64=1),this.createUri(s,n)}}const zx=Aa.WebSocket||Aa.MozWebSocket;class PF extends TF{createSocket(s,n,r){return yk?new zx(s,n,r):n?new zx(s,n):new zx(s)}doWrite(s,n){this.ws.send(n)}}class _F extends jb{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=fF(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=s.readable.pipeThrough(n).getReader(),a=mF();a.readable.pipeTo(s.writable),this._writer=a.writable.getWriter();const l=()=>{r.read().then(({done:d,value:h})=>{d||(this.onPacket(h),l())}).catch(d=>{})};l();const c={type:"open"};this.query.sid&&(c.data=`{"sid":"${this.query.sid}"}`),this._writer.write(c).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&&hf(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var s;(s=this._transport)===null||s===void 0||s.close()}}const OF={websocket:PF,webtransport:_F,polling:DF},IF=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,LF=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function fv(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=IF.exec(t||""),l={},c=14;for(;c--;)l[LF[c]]=a[c]||"";return n!=-1&&r!=-1&&(l.source=s,l.host=l.host.substring(1,l.host.length-1).replace(/;/g,":"),l.authority=l.authority.replace("[","").replace("]","").replace(/;/g,":"),l.ipv6uri=!0),l.pathNames=MF(l,l.path),l.queryKey=FF(l,l.query),l}function MF(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 FF(t,s){const n={};return s.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,a,l){a&&(n[a]=l)}),n}const pv=typeof addEventListener=="function"&&typeof removeEventListener=="function",sm=[];pv&&addEventListener("offline",()=>{sm.forEach(t=>t())},!1);class Ol extends Kn{constructor(s,n){if(super(),this.binaryType=xF,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=fv(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=fv(n.host).host);mf(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=wF(this.opts.query)),pv&&(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"})},sm.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(s){const n=Object.assign({},this.opts.query);n.EIO=pk,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&&Ol.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",Ol.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+=yF(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,hf(()=>{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 l={type:s,data:n,options:r};this.emitReserved("packetCreate",l),this.writeBuffer.push(l),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(Ol.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(),pv&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=sm.indexOf(this._offlineEventListener);r!==-1&&sm.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",s,n),this.writeBuffer=[],this._prevBufferLen=0}}}Ol.protocol=pk;class BF extends Ol{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;Ol.priorWebsocketSuccess=!1;const a=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",m=>{if(!r)if(m.type==="pong"&&m.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Ol.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(f(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const p=new Error("probe error");p.transport=n.name,this.emitReserved("upgradeError",p)}}))};function l(){r||(r=!0,f(),n.close(),n=null)}const c=m=>{const p=new Error("probe error: "+m);p.transport=n.name,l(),this.emitReserved("upgradeError",p)};function d(){c("transport closed")}function h(){c("socket closed")}function x(m){n&&m.name!==n.name&&l()}const f=()=>{n.removeListener("open",a),n.removeListener("error",c),n.removeListener("close",d),this.off("close",h),this.off("upgrading",x)};n.once("open",a),n.once("error",c),n.once("close",d),this.once("close",h),this.once("upgrading",x),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 $F=class extends BF{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=>OF[a]).filter(a=>!!a)),super(s,r)}};function qF(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=fv(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 l=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+l+":"+r.port+s,r.href=r.protocol+"://"+l+(n&&n.port===r.port?"":":"+r.port),r}const zF=typeof ArrayBuffer=="function",UF=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,jk=Object.prototype.toString,VF=typeof Blob=="function"||typeof Blob<"u"&&jk.call(Blob)==="[object BlobConstructor]",HF=typeof File=="function"||typeof File<"u"&&jk.call(File)==="[object FileConstructor]";function Nb(t){return zF&&(t instanceof ArrayBuffer||UF(t))||VF&&t instanceof Blob||HF&&t instanceof File}function nm(t,s){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++)if(nm(t[n]))return!0;return!1}if(Nb(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return nm(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&nm(t[n]))return!0;return!1}function WF(t){const s=[],n=t.data,r=t;return r.data=xv(n,s),r.attachments=s.length,{packet:r,buffers:s}}function xv(t,s){if(!t)return t;if(Nb(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]=xv(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]=xv(t[r],s));return n}return t}function GF(t,s){return t.data=gv(t.data,s),delete t.attachments,t}function gv(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]=gv(t[n],s);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=gv(t[n],s));return t}const KF=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Zs;(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"})(Zs||(Zs={}));class YF{constructor(s){this.replacer=s}encode(s){return(s.type===Zs.EVENT||s.type===Zs.ACK)&&nm(s)?this.encodeAsBinary({type:s.type===Zs.EVENT?Zs.BINARY_EVENT:Zs.BINARY_ACK,nsp:s.nsp,data:s.data,id:s.id}):[this.encodeAsString(s)]}encodeAsString(s){let n=""+s.type;return(s.type===Zs.BINARY_EVENT||s.type===Zs.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=WF(s),r=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(r),a}}class wb extends Kn{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===Zs.BINARY_EVENT;r||n.type===Zs.BINARY_ACK?(n.type=r?Zs.EVENT:Zs.ACK,this.reconstructor=new ZF(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(Nb(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(Zs[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===Zs.BINARY_EVENT||r.type===Zs.BINARY_ACK){const l=n+1;for(;s.charAt(++n)!=="-"&&n!=s.length;);const c=s.substring(l,n);if(c!=Number(c)||s.charAt(n)!=="-")throw new Error("Illegal attachments");const d=Number(c);if(!QF(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 l=n+1;for(;++n&&!(s.charAt(n)===","||n===s.length););r.nsp=s.substring(l,n)}else r.nsp="/";const a=s.charAt(n+1);if(a!==""&&Number(a)==a){const l=n+1;for(;++n;){const c=s.charAt(n);if(c==null||Number(c)!=c){--n;break}if(n===s.length)break}r.id=Number(s.substring(l,n+1))}if(s.charAt(++n)){const l=this.tryParse(s.substr(n));if(wb.isPayloadValid(r.type,l))r.data=l;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 Zs.CONNECT:return Hw(n);case Zs.DISCONNECT:return n===void 0;case Zs.CONNECT_ERROR:return typeof n=="string"||Hw(n);case Zs.EVENT:case Zs.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&KF.indexOf(n[0])===-1);case Zs.ACK:case Zs.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class ZF{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=GF(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const QF=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};function Hw(t){return Object.prototype.toString.call(t)==="[object Object]"}const XF=Object.freeze(Object.defineProperty({__proto__:null,Decoder:wb,Encoder:YF,get PacketType(){return Zs}},Symbol.toStringTag,{value:"Module"}));function Ga(t,s,n){return t.on(s,n),function(){t.off(s,n)}}const JF=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Nk extends Kn{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=[Ga(s,"open",this.onopen.bind(this)),Ga(s,"packet",this.onpacket.bind(this)),Ga(s,"error",this.onerror.bind(this)),Ga(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,l;if(JF.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 c={type:Zs.EVENT,data:n};if(c.options={},c.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const f=this.ids++,m=n.pop();this._registerAckCallback(f,m),c.id=f}const d=(a=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||a===void 0?void 0:a.writable,h=this.connected&&!(!((l=this.io.engine)===null||l===void 0)&&l._hasPingExpired());return this.flags.volatile&&!d||(h?(this.notifyOutgoingListeners(c),this.packet(c)):this.sendBuffer.push(c)),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 l=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),c=(...d)=>{this.io.clearTimeoutFn(l),n.apply(this,d)};c.withError=!0,this.acks[s]=c}emitWithAck(s,...n){return new Promise((r,a)=>{const l=(c,d)=>c?a(c):r(d);l.withError=!0,n.push(l),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,...l)=>(this._queue[0],a!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(a)):(this._queue.shift(),n&&n(null,...l)),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:Zs.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 Zs.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 Zs.EVENT:case Zs.BINARY_EVENT:this.onevent(s);break;case Zs.ACK:case Zs.BINARY_ACK:this.onack(s);break;case Zs.DISCONNECT:this.ondisconnect();break;case Zs.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:Zs.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:Zs.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 Wc(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}Wc.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};Wc.prototype.reset=function(){this.attempts=0};Wc.prototype.setMin=function(t){this.ms=t};Wc.prototype.setMax=function(t){this.max=t};Wc.prototype.setJitter=function(t){this.jitter=t};class vv extends Kn{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,mf(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 Wc({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||XF;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 $F(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const a=Ga(n,"open",function(){r.onopen(),s&&s()}),l=d=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",d),s?s(d):this.maybeReconnectOnOpen()},c=Ga(n,"error",l);if(this._timeout!==!1){const d=this._timeout,h=this.setTimeoutFn(()=>{a(),l(new Error("timeout")),n.close()},d);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(a),this.subs.push(c),this}connect(s){return this.open(s)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const s=this.engine;this.subs.push(Ga(s,"ping",this.onping.bind(this)),Ga(s,"data",this.ondata.bind(this)),Ga(s,"error",this.onerror.bind(this)),Ga(s,"close",this.onclose.bind(this)),Ga(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){hf(()=>{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 Nk(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 Nd={};function rm(t,s){typeof t=="object"&&(s=t,t=void 0),s=s||{};const n=qF(t,s.path||"/socket.io"),r=n.source,a=n.id,l=n.path,c=Nd[a]&&l in Nd[a].nsps,d=s.forceNew||s["force new connection"]||s.multiplex===!1||c;let h;return d?h=new vv(r,s):(Nd[a]||(Nd[a]=new vv(r,s)),h=Nd[a]),n.query&&!s.query&&(s.query=n.queryKey),h.socket(n.path,s)}Object.assign(rm,{Manager:vv,Socket:Nk,io:rm,connect:rm});const wk=v.createContext({socket:null,isConnected:!1}),Sk=()=>v.useContext(wk),e8=({children:t})=>{const[s,n]=v.useState(null),[r,a]=v.useState(!1),{user:l}=Nn(c=>c.auth);return v.useEffect(()=>{let c="https://dealeronboarding-uat.royalenfield.com/api";c.endsWith("/api")&&(c=c.replace(/\/api$/,""));const d=rm(c,{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()}},[]),v.useEffect(()=>{if(s&&r&&(l!=null&&l.id))return s.emit("join_room",`user_${l.id}`),console.log(`Joined private notification room: user_${l.id}`),()=>{s.emit("leave_room",`user_${l.id}`)}},[s,r,l==null?void 0:l.id]),e.jsx(wk.Provider,{value:{socket:s,isConnected:r},children:t})};function fn(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 ql(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}const Ck=6048e5,t8=864e5,Mh=43200,Ww=1440;let s8={};function wu(){return s8}function eu(t,s){var d,h,x,f;const n=wu(),r=(s==null?void 0:s.weekStartsOn)??((h=(d=s==null?void 0:s.locale)==null?void 0:d.options)==null?void 0:h.weekStartsOn)??n.weekStartsOn??((f=(x=n.locale)==null?void 0:x.options)==null?void 0:f.weekStartsOn)??0,a=fn(t),l=a.getDay(),c=(l<r?7:0)+l-r;return a.setDate(a.getDate()-c),a.setHours(0,0,0,0),a}function Am(t){return eu(t,{weekStartsOn:1})}function Ak(t){const s=fn(t),n=s.getFullYear(),r=ql(t,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);const a=Am(r),l=ql(t,0);l.setFullYear(n,0,4),l.setHours(0,0,0,0);const c=Am(l);return s.getTime()>=a.getTime()?n+1:s.getTime()>=c.getTime()?n:n-1}function Gw(t){const s=fn(t);return s.setHours(0,0,0,0),s}function km(t){const s=fn(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 n8(t,s){const n=Gw(t),r=Gw(s),a=+n-km(n),l=+r-km(r);return Math.round((a-l)/t8)}function r8(t){const s=Ak(t),n=ql(t,0);return n.setFullYear(s,0,4),n.setHours(0,0,0,0),Am(n)}function am(t,s){const n=fn(t),r=fn(s),a=n.getTime()-r.getTime();return a<0?-1:a>0?1:a}function a8(t){return ql(t,Date.now())}function i8(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function l8(t){if(!i8(t)&&typeof t!="number")return!1;const s=fn(t);return!isNaN(Number(s))}function o8(t,s){const n=fn(t),r=fn(s),a=n.getFullYear()-r.getFullYear(),l=n.getMonth()-r.getMonth();return a*12+l}function c8(t){return s=>{const r=(t?Math[t]:Math.trunc)(s);return r===0?0:r}}function d8(t,s){return+fn(t)-+fn(s)}function u8(t){const s=fn(t);return s.setHours(23,59,59,999),s}function h8(t){const s=fn(t),n=s.getMonth();return s.setFullYear(s.getFullYear(),n+1,0),s.setHours(23,59,59,999),s}function m8(t){const s=fn(t);return+u8(s)==+h8(s)}function f8(t,s){const n=fn(t),r=fn(s),a=am(n,r),l=Math.abs(o8(n,r));let c;if(l<1)c=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-a*l);let d=am(n,r)===-a;m8(fn(t))&&l===1&&am(t,r)===1&&(d=!1),c=a*(l-Number(d))}return c===0?0:c}function p8(t,s,n){const r=d8(t,s)/1e3;return c8(n==null?void 0:n.roundingMethod)(r)}function x8(t){const s=fn(t),n=ql(t,0);return n.setFullYear(s.getFullYear(),0,1),n.setHours(0,0,0,0),n}const g8={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"}},v8=(t,s,n)=>{let r;const a=g8[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 Ux(t){return(s={})=>{const n=s.width?String(s.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const b8={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},y8={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},j8={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},N8={date:Ux({formats:b8,defaultWidth:"full"}),time:Ux({formats:y8,defaultWidth:"full"}),dateTime:Ux({formats:j8,defaultWidth:"full"})},w8={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},S8=(t,s,n,r)=>w8[t];function wd(t){return(s,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let a;if(r==="formatting"&&t.formattingValues){const c=t.defaultFormattingWidth||t.defaultWidth,d=n!=null&&n.width?String(n.width):c;a=t.formattingValues[d]||t.formattingValues[c]}else{const c=t.defaultWidth,d=n!=null&&n.width?String(n.width):t.defaultWidth;a=t.values[d]||t.values[c]}const l=t.argumentCallback?t.argumentCallback(s):s;return a[l]}}const C8={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},A8={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},k8={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"]},R8={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"]},E8={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"}},D8={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"}},T8=(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"},P8={ordinalNumber:T8,era:wd({values:C8,defaultWidth:"wide"}),quarter:wd({values:A8,defaultWidth:"wide",argumentCallback:t=>t-1}),month:wd({values:k8,defaultWidth:"wide"}),day:wd({values:R8,defaultWidth:"wide"}),dayPeriod:wd({values:E8,defaultWidth:"wide",formattingValues:D8,defaultFormattingWidth:"wide"})};function Sd(t){return(s,n={})=>{const r=n.width,a=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],l=s.match(a);if(!l)return null;const c=l[0],d=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],h=Array.isArray(d)?O8(d,m=>m.test(c)):_8(d,m=>m.test(c));let x;x=t.valueCallback?t.valueCallback(h):h,x=n.valueCallback?n.valueCallback(x):x;const f=s.slice(c.length);return{value:x,rest:f}}}function _8(t,s){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&s(t[n]))return n}function O8(t,s){for(let n=0;n<t.length;n++)if(s(t[n]))return n}function I8(t){return(s,n={})=>{const r=s.match(t.matchPattern);if(!r)return null;const a=r[0],l=s.match(t.parsePattern);if(!l)return null;let c=t.valueCallback?t.valueCallback(l[0]):l[0];c=n.valueCallback?n.valueCallback(c):c;const d=s.slice(a.length);return{value:c,rest:d}}}const L8=/^(\d+)(th|st|nd|rd)?/i,M8=/\d+/i,F8={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},B8={any:[/^b/i,/^(a|c)/i]},$8={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},q8={any:[/1/i,/2/i,/3/i,/4/i]},z8={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},U8={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]},V8={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},H8={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]},W8={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},G8={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}},K8={ordinalNumber:I8({matchPattern:L8,parsePattern:M8,valueCallback:t=>parseInt(t,10)}),era:Sd({matchPatterns:F8,defaultMatchWidth:"wide",parsePatterns:B8,defaultParseWidth:"any"}),quarter:Sd({matchPatterns:$8,defaultMatchWidth:"wide",parsePatterns:q8,defaultParseWidth:"any",valueCallback:t=>t+1}),month:Sd({matchPatterns:z8,defaultMatchWidth:"wide",parsePatterns:U8,defaultParseWidth:"any"}),day:Sd({matchPatterns:V8,defaultMatchWidth:"wide",parsePatterns:H8,defaultParseWidth:"any"}),dayPeriod:Sd({matchPatterns:W8,defaultMatchWidth:"any",parsePatterns:G8,defaultParseWidth:"any"})},kk={code:"en-US",formatDistance:v8,formatLong:N8,formatRelative:S8,localize:P8,match:K8,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Y8(t){const s=fn(t);return n8(s,x8(s))+1}function Z8(t){const s=fn(t),n=+Am(s)-+r8(s);return Math.round(n/Ck)+1}function Rk(t,s){var f,m,p,u;const n=fn(t),r=n.getFullYear(),a=wu(),l=(s==null?void 0:s.firstWeekContainsDate)??((m=(f=s==null?void 0:s.locale)==null?void 0:f.options)==null?void 0:m.firstWeekContainsDate)??a.firstWeekContainsDate??((u=(p=a.locale)==null?void 0:p.options)==null?void 0:u.firstWeekContainsDate)??1,c=ql(t,0);c.setFullYear(r+1,0,l),c.setHours(0,0,0,0);const d=eu(c,s),h=ql(t,0);h.setFullYear(r,0,l),h.setHours(0,0,0,0);const x=eu(h,s);return n.getTime()>=d.getTime()?r+1:n.getTime()>=x.getTime()?r:r-1}function Q8(t,s){var d,h,x,f;const n=wu(),r=(s==null?void 0:s.firstWeekContainsDate)??((h=(d=s==null?void 0:s.locale)==null?void 0:d.options)==null?void 0:h.firstWeekContainsDate)??n.firstWeekContainsDate??((f=(x=n.locale)==null?void 0:x.options)==null?void 0:f.firstWeekContainsDate)??1,a=Rk(t,s),l=ql(t,0);return l.setFullYear(a,0,r),l.setHours(0,0,0,0),eu(l,s)}function X8(t,s){const n=fn(t),r=+eu(n,s)-+Q8(n,s);return Math.round(r/Ck)+1}function un(t,s){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(s,"0");return n+r}const Rl={y(t,s){const n=t.getFullYear(),r=n>0?n:1-n;return un(s==="yy"?r%100:r,s.length)},M(t,s){const n=t.getMonth();return s==="M"?String(n+1):un(n+1,2)},d(t,s){return un(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 un(t.getHours()%12||12,s.length)},H(t,s){return un(t.getHours(),s.length)},m(t,s){return un(t.getMinutes(),s.length)},s(t,s){return un(t.getSeconds(),s.length)},S(t,s){const n=s.length,r=t.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return un(a,s.length)}},vc={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Kw={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 Rl.y(t,s)},Y:function(t,s,n,r){const a=Rk(t,r),l=a>0?a:1-a;if(s==="YY"){const c=l%100;return un(c,2)}return s==="Yo"?n.ordinalNumber(l,{unit:"year"}):un(l,s.length)},R:function(t,s){const n=Ak(t);return un(n,s.length)},u:function(t,s){const n=t.getFullYear();return un(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 un(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 un(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 Rl.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 un(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=X8(t,r);return s==="wo"?n.ordinalNumber(a,{unit:"week"}):un(a,s.length)},I:function(t,s,n){const r=Z8(t);return s==="Io"?n.ordinalNumber(r,{unit:"week"}):un(r,s.length)},d:function(t,s,n){return s==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):Rl.d(t,s)},D:function(t,s,n){const r=Y8(t);return s==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):un(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(),l=(a-r.weekStartsOn+8)%7||7;switch(s){case"e":return String(l);case"ee":return un(l,2);case"eo":return n.ordinalNumber(l,{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(),l=(a-r.weekStartsOn+8)%7||7;switch(s){case"c":return String(l);case"cc":return un(l,s.length);case"co":return n.ordinalNumber(l,{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 un(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=vc.noon:r===0?a=vc.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=vc.evening:r>=12?a=vc.afternoon:r>=4?a=vc.morning:a=vc.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 Rl.h(t,s)},H:function(t,s,n){return s==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):Rl.H(t,s)},K:function(t,s,n){const r=t.getHours()%12;return s==="Ko"?n.ordinalNumber(r,{unit:"hour"}):un(r,s.length)},k:function(t,s,n){let r=t.getHours();return r===0&&(r=24),s==="ko"?n.ordinalNumber(r,{unit:"hour"}):un(r,s.length)},m:function(t,s,n){return s==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):Rl.m(t,s)},s:function(t,s,n){return s==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):Rl.s(t,s)},S:function(t,s){return Rl.S(t,s)},X:function(t,s,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(s){case"X":return Zw(r);case"XXXX":case"XX":return ko(r);case"XXXXX":case"XXX":default:return ko(r,":")}},x:function(t,s,n){const r=t.getTimezoneOffset();switch(s){case"x":return Zw(r);case"xxxx":case"xx":return ko(r);case"xxxxx":case"xxx":default:return ko(r,":")}},O:function(t,s,n){const r=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+Yw(r,":");case"OOOO":default:return"GMT"+ko(r,":")}},z:function(t,s,n){const r=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+Yw(r,":");case"zzzz":default:return"GMT"+ko(r,":")}},t:function(t,s,n){const r=Math.trunc(t.getTime()/1e3);return un(r,s.length)},T:function(t,s,n){const r=t.getTime();return un(r,s.length)}};function Yw(t,s=""){const n=t>0?"-":"+",r=Math.abs(t),a=Math.trunc(r/60),l=r%60;return l===0?n+String(a):n+String(a)+s+un(l,2)}function Zw(t,s){return t%60===0?(t>0?"-":"+")+un(Math.abs(t)/60,2):ko(t,s)}function ko(t,s=""){const n=t>0?"-":"+",r=Math.abs(t),a=un(Math.trunc(r/60),2),l=un(r%60,2);return n+a+s+l}const Qw=(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"})}},Ek=(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"})}},J8=(t,s)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return Qw(t,s);let l;switch(r){case"P":l=s.dateTime({width:"short"});break;case"PP":l=s.dateTime({width:"medium"});break;case"PPP":l=s.dateTime({width:"long"});break;case"PPPP":default:l=s.dateTime({width:"full"});break}return l.replace("{{date}}",Qw(r,s)).replace("{{time}}",Ek(a,s))},e9={p:Ek,P:J8},t9=/^D+$/,s9=/^Y+$/,n9=["D","DD","YY","YYYY"];function r9(t){return t9.test(t)}function a9(t){return s9.test(t)}function i9(t,s,n){const r=l9(t,s,n);if(console.warn(r),n9.includes(t))throw new RangeError(r)}function l9(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 o9=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,c9=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,d9=/^'([^]*?)'?$/,u9=/''/g,h9=/[a-zA-Z]/;function m9(t,s,n){var f,m,p,u;const r=wu(),a=r.locale??kk,l=r.firstWeekContainsDate??((m=(f=r.locale)==null?void 0:f.options)==null?void 0:m.firstWeekContainsDate)??1,c=r.weekStartsOn??((u=(p=r.locale)==null?void 0:p.options)==null?void 0:u.weekStartsOn)??0,d=fn(t);if(!l8(d))throw new RangeError("Invalid time value");let h=s.match(c9).map(j=>{const g=j[0];if(g==="p"||g==="P"){const y=e9[g];return y(j,a.formatLong)}return j}).join("").match(o9).map(j=>{if(j==="''")return{isToken:!1,value:"'"};const g=j[0];if(g==="'")return{isToken:!1,value:f9(j)};if(Kw[g])return{isToken:!0,value:j};if(g.match(h9))throw new RangeError("Format string contains an unescaped latin alphabet character `"+g+"`");return{isToken:!1,value:j}});a.localize.preprocessor&&(h=a.localize.preprocessor(d,h));const x={firstWeekContainsDate:l,weekStartsOn:c,locale:a};return h.map(j=>{if(!j.isToken)return j.value;const g=j.value;(a9(g)||r9(g))&&i9(g,s,String(t));const y=Kw[g[0]];return y(d,g,a.localize,x)}).join("")}function f9(t){const s=t.match(d9);return s?s[1].replace(u9,"'"):t}function p9(t,s,n){const r=wu(),a=(n==null?void 0:n.locale)??r.locale??kk,l=2520,c=am(t,s);if(isNaN(c))throw new RangeError("Invalid time value");const d=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:c});let h,x;c>0?(h=fn(s),x=fn(t)):(h=fn(t),x=fn(s));const f=p8(x,h),m=(km(x)-km(h))/1e3,p=Math.round((f-m)/60);let u;if(p<2)return n!=null&&n.includeSeconds?f<5?a.formatDistance("lessThanXSeconds",5,d):f<10?a.formatDistance("lessThanXSeconds",10,d):f<20?a.formatDistance("lessThanXSeconds",20,d):f<40?a.formatDistance("halfAMinute",0,d):f<60?a.formatDistance("lessThanXMinutes",1,d):a.formatDistance("xMinutes",1,d):p===0?a.formatDistance("lessThanXMinutes",1,d):a.formatDistance("xMinutes",p,d);if(p<45)return a.formatDistance("xMinutes",p,d);if(p<90)return a.formatDistance("aboutXHours",1,d);if(p<Ww){const j=Math.round(p/60);return a.formatDistance("aboutXHours",j,d)}else{if(p<l)return a.formatDistance("xDays",1,d);if(p<Mh){const j=Math.round(p/Ww);return a.formatDistance("xDays",j,d)}else if(p<Mh*2)return u=Math.round(p/Mh),a.formatDistance("aboutXMonths",u,d)}if(u=f8(x,h),u<12){const j=Math.round(p/Mh);return a.formatDistance("xMonths",j,d)}else{const j=u%12,g=Math.trunc(u/12);return j<3?a.formatDistance("aboutXYears",g,d):j<9?a.formatDistance("overXYears",g,d):a.formatDistance("almostXYears",g+1,d)}}function Dk(t,s){return p9(t,a8(t),s)}function x9({title:t,onRefresh:s}){const{user:n}=Nn(f=>f.auth),{socket:r}=Sk(),[a,l]=v.useState([]),[c,d]=v.useState(0);v.useEffect(()=>{(async()=>{try{const m=await _o.getNotifications(1,15);m.success&&(l(m.data),m.pagination&&m.pagination.unreadCount!==void 0?d(m.pagination.unreadCount):d(m.data.filter(p=>!p.isRead).length))}catch(m){console.error("Fetch notifications error:",m)}})()},[]),v.useEffect(()=>{if(r)return r.on("notification",f=>{l(m=>[f,...m].slice(0,15)),d(m=>m+1),ee(f.title,{description:f.message,action:f.link?{label:"View",onClick:()=>window.location.href=f.link}:void 0})}),()=>{r.off("notification")}},[r]);const h=async f=>{try{f.isRead||(await _o.markAsRead(f.id)).success&&(l(p=>p.map(u=>u.id===f.id?{...u,isRead:!0}:u)),d(p=>Math.max(0,p-1))),f.link&&(window.location.href=f.link)}catch(m){console.error("Notification click error:",m)}},x=async()=>{try{(await _o.markAllAsRead()).success&&(l(m=>m.map(p=>({...p,isRead:!0}))),d(0))}catch(f){console.error("Mark all as read error:",f)}};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",children:"Manage and track dealership applications"})]}),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(kr,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-slate-900",children:n.name}),e.jsx("p",{className:"text-slate-600",children:n.role})]})]}),s&&e.jsx(se,{variant:"outline",size:"icon",onClick:s,title:"Refresh",children:e.jsx(Rr,{className:"w-4 h-4"})}),e.jsx(se,{variant:"outline",size:"icon",title:"Help",children:e.jsx(M2,{className:"w-4 h-4"})}),e.jsxs(xb,{children:[e.jsx(gb,{asChild:!0,children:e.jsxs(se,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(Yd,{className:"w-4 h-4"}),c>0&&e.jsx(Ae,{variant:"destructive",className:"absolute -top-1 -right-1 w-5 h-5 p-0 flex items-center justify-center text-xs",children:c})]})}),e.jsxs(vb,{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"}),c>0&&e.jsx("button",{onClick:x,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:a.length===0?e.jsx("div",{className:"p-8 text-center text-slate-500",children:"No notifications yet"}):a.map(f=>e.jsxs(ck,{className:`p-3 cursor-pointer flex items-start gap-3 ${f.isRead?"":"bg-blue-50/50"}`,onClick:()=>h(f),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-slate-900 text-sm font-medium",children:f.title}),e.jsx("p",{className:"text-slate-600 text-xs mt-1 leading-relaxed",children:f.message}),e.jsx("p",{className:"text-slate-400 text-[10px] mt-2",children:Dk(new Date(f.createdAt),{addSuffix:!0})})]}),!f.isRead&&e.jsx("div",{className:"w-2 h-2 bg-blue-600 rounded-full mt-1.5 flex-shrink-0"})]},f.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:Pt("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border",t),...s})}function tt({className:t,...s}){return e.jsx("div",{"data-slot":"card-header",className:Pt("@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 nt({className:t,...s}){return e.jsx("h4",{"data-slot":"card-title",className:Pt("leading-none",t),...s})}function Zt({className:t,...s}){return e.jsx("p",{"data-slot":"card-description",className:Pt("text-muted-foreground",t),...s})}function Me({className:t,...s}){return e.jsx("div",{"data-slot":"card-content",className:Pt("px-6 [&:last-child]:pb-6",t),...s})}function bv(t,[s,n]){return Math.min(n,Math.max(s,t))}function g9(t,s){return v.useReducer((n,r)=>s[n][r]??n,t)}var Sb="ScrollArea",[Tk]=ea(Sb),[v9,Ea]=Tk(Sb),Pk=v.forwardRef((t,s)=>{const{__scopeScrollArea:n,type:r="hover",dir:a,scrollHideDelay:l=600,...c}=t,[d,h]=v.useState(null),[x,f]=v.useState(null),[m,p]=v.useState(null),[u,j]=v.useState(null),[g,y]=v.useState(null),[N,S]=v.useState(0),[C,w]=v.useState(0),[R,P]=v.useState(!1),[A,I]=v.useState(!1),$=Ms(s,E=>h(E)),T=pu(a);return e.jsx(v9,{scope:n,type:r,dir:T,scrollHideDelay:l,scrollArea:d,viewport:x,onViewportChange:f,content:m,onContentChange:p,scrollbarX:u,onScrollbarXChange:j,scrollbarXEnabled:R,onScrollbarXEnabledChange:P,scrollbarY:g,onScrollbarYChange:y,scrollbarYEnabled:A,onScrollbarYEnabledChange:I,onCornerWidthChange:S,onCornerHeightChange:w,children:e.jsx(ps.div,{dir:T,...c,ref:$,style:{position:"relative","--radix-scroll-area-corner-width":N+"px","--radix-scroll-area-corner-height":C+"px",...t.style}})})});Pk.displayName=Sb;var _k="ScrollAreaViewport",Ok=v.forwardRef((t,s)=>{const{__scopeScrollArea:n,children:r,nonce:a,...l}=t,c=Ea(_k,n),d=v.useRef(null),h=Ms(s,d,c.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(ps.div,{"data-radix-scroll-area-viewport":"",...l,ref:h,style:{overflowX:c.scrollbarXEnabled?"scroll":"hidden",overflowY:c.scrollbarYEnabled?"scroll":"hidden",...t.style},children:e.jsx("div",{ref:c.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Ok.displayName=_k;var Si="ScrollAreaScrollbar",Ik=v.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=Ea(Si,t.__scopeScrollArea),{onScrollbarXEnabledChange:l,onScrollbarYEnabledChange:c}=a,d=t.orientation==="horizontal";return v.useEffect(()=>(d?l(!0):c(!0),()=>{d?l(!1):c(!1)}),[d,l,c]),a.type==="hover"?e.jsx(b9,{...r,ref:s,forceMount:n}):a.type==="scroll"?e.jsx(y9,{...r,ref:s,forceMount:n}):a.type==="auto"?e.jsx(Lk,{...r,ref:s,forceMount:n}):a.type==="always"?e.jsx(Cb,{...r,ref:s}):null});Ik.displayName=Si;var b9=v.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=Ea(Si,t.__scopeScrollArea),[l,c]=v.useState(!1);return v.useEffect(()=>{const d=a.scrollArea;let h=0;if(d){const x=()=>{window.clearTimeout(h),c(!0)},f=()=>{h=window.setTimeout(()=>c(!1),a.scrollHideDelay)};return d.addEventListener("pointerenter",x),d.addEventListener("pointerleave",f),()=>{window.clearTimeout(h),d.removeEventListener("pointerenter",x),d.removeEventListener("pointerleave",f)}}},[a.scrollArea,a.scrollHideDelay]),e.jsx(mr,{present:n||l,children:e.jsx(Lk,{"data-state":l?"visible":"hidden",...r,ref:s})})}),y9=v.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=Ea(Si,t.__scopeScrollArea),l=t.orientation==="horizontal",c=pf(()=>h("SCROLL_END"),100),[d,h]=g9("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 v.useEffect(()=>{if(d==="idle"){const x=window.setTimeout(()=>h("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(x)}},[d,a.scrollHideDelay,h]),v.useEffect(()=>{const x=a.viewport,f=l?"scrollLeft":"scrollTop";if(x){let m=x[f];const p=()=>{const u=x[f];m!==u&&(h("SCROLL"),c()),m=u};return x.addEventListener("scroll",p),()=>x.removeEventListener("scroll",p)}},[a.viewport,l,h,c]),e.jsx(mr,{present:n||d!=="hidden",children:e.jsx(Cb,{"data-state":d==="hidden"?"hidden":"visible",...r,ref:s,onPointerEnter:Vt(t.onPointerEnter,()=>h("POINTER_ENTER")),onPointerLeave:Vt(t.onPointerLeave,()=>h("POINTER_LEAVE"))})})}),Lk=v.forwardRef((t,s)=>{const n=Ea(Si,t.__scopeScrollArea),{forceMount:r,...a}=t,[l,c]=v.useState(!1),d=t.orientation==="horizontal",h=pf(()=>{if(n.viewport){const x=n.viewport.offsetWidth<n.viewport.scrollWidth,f=n.viewport.offsetHeight<n.viewport.scrollHeight;c(d?x:f)}},10);return _c(n.viewport,h),_c(n.content,h),e.jsx(mr,{present:r||l,children:e.jsx(Cb,{"data-state":l?"visible":"hidden",...a,ref:s})})}),Cb=v.forwardRef((t,s)=>{const{orientation:n="vertical",...r}=t,a=Ea(Si,t.__scopeScrollArea),l=v.useRef(null),c=v.useRef(0),[d,h]=v.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),x=qk(d.viewport,d.content),f={...r,sizes:d,onSizesChange:h,hasThumb:x>0&&x<1,onThumbChange:p=>l.current=p,onThumbPointerUp:()=>c.current=0,onThumbPointerDown:p=>c.current=p};function m(p,u){return A9(p,c.current,d,u)}return n==="horizontal"?e.jsx(j9,{...f,ref:s,onThumbPositionChange:()=>{if(a.viewport&&l.current){const p=a.viewport.scrollLeft,u=Xw(p,d,a.dir);l.current.style.transform=`translate3d(${u}px, 0, 0)`}},onWheelScroll:p=>{a.viewport&&(a.viewport.scrollLeft=p)},onDragScroll:p=>{a.viewport&&(a.viewport.scrollLeft=m(p,a.dir))}}):n==="vertical"?e.jsx(N9,{...f,ref:s,onThumbPositionChange:()=>{if(a.viewport&&l.current){const p=a.viewport.scrollTop,u=Xw(p,d);l.current.style.transform=`translate3d(0, ${u}px, 0)`}},onWheelScroll:p=>{a.viewport&&(a.viewport.scrollTop=p)},onDragScroll:p=>{a.viewport&&(a.viewport.scrollTop=m(p))}}):null}),j9=v.forwardRef((t,s)=>{const{sizes:n,onSizesChange:r,...a}=t,l=Ea(Si,t.__scopeScrollArea),[c,d]=v.useState(),h=v.useRef(null),x=Ms(s,h,l.onScrollbarXChange);return v.useEffect(()=>{h.current&&d(getComputedStyle(h.current))},[h]),e.jsx(Fk,{"data-orientation":"horizontal",...a,ref:x,sizes:n,style:{bottom:0,left:l.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:l.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ff(n)+"px",...t.style},onThumbPointerDown:f=>t.onThumbPointerDown(f.x),onDragScroll:f=>t.onDragScroll(f.x),onWheelScroll:(f,m)=>{if(l.viewport){const p=l.viewport.scrollLeft+f.deltaX;t.onWheelScroll(p),Uk(p,m)&&f.preventDefault()}},onResize:()=>{h.current&&l.viewport&&c&&r({content:l.viewport.scrollWidth,viewport:l.viewport.offsetWidth,scrollbar:{size:h.current.clientWidth,paddingStart:Em(c.paddingLeft),paddingEnd:Em(c.paddingRight)}})}})}),N9=v.forwardRef((t,s)=>{const{sizes:n,onSizesChange:r,...a}=t,l=Ea(Si,t.__scopeScrollArea),[c,d]=v.useState(),h=v.useRef(null),x=Ms(s,h,l.onScrollbarYChange);return v.useEffect(()=>{h.current&&d(getComputedStyle(h.current))},[h]),e.jsx(Fk,{"data-orientation":"vertical",...a,ref:x,sizes:n,style:{top:0,right:l.dir==="ltr"?0:void 0,left:l.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ff(n)+"px",...t.style},onThumbPointerDown:f=>t.onThumbPointerDown(f.y),onDragScroll:f=>t.onDragScroll(f.y),onWheelScroll:(f,m)=>{if(l.viewport){const p=l.viewport.scrollTop+f.deltaY;t.onWheelScroll(p),Uk(p,m)&&f.preventDefault()}},onResize:()=>{h.current&&l.viewport&&c&&r({content:l.viewport.scrollHeight,viewport:l.viewport.offsetHeight,scrollbar:{size:h.current.clientHeight,paddingStart:Em(c.paddingTop),paddingEnd:Em(c.paddingBottom)}})}})}),[w9,Mk]=Tk(Si),Fk=v.forwardRef((t,s)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:a,onThumbChange:l,onThumbPointerUp:c,onThumbPointerDown:d,onThumbPositionChange:h,onDragScroll:x,onWheelScroll:f,onResize:m,...p}=t,u=Ea(Si,n),[j,g]=v.useState(null),y=Ms(s,$=>g($)),N=v.useRef(null),S=v.useRef(""),C=u.viewport,w=r.content-r.viewport,R=dr(f),P=dr(h),A=pf(m,10);function I($){if(N.current){const T=$.clientX-N.current.left,E=$.clientY-N.current.top;x({x:T,y:E})}}return v.useEffect(()=>{const $=T=>{const E=T.target;(j==null?void 0:j.contains(E))&&R(T,w)};return document.addEventListener("wheel",$,{passive:!1}),()=>document.removeEventListener("wheel",$,{passive:!1})},[C,j,w,R]),v.useEffect(P,[r,P]),_c(j,A),_c(u.content,A),e.jsx(w9,{scope:n,scrollbar:j,hasThumb:a,onThumbChange:dr(l),onThumbPointerUp:dr(c),onThumbPositionChange:P,onThumbPointerDown:dr(d),children:e.jsx(ps.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:Vt(t.onPointerDown,$=>{$.button===0&&($.target.setPointerCapture($.pointerId),N.current=j.getBoundingClientRect(),S.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",u.viewport&&(u.viewport.style.scrollBehavior="auto"),I($))}),onPointerMove:Vt(t.onPointerMove,I),onPointerUp:Vt(t.onPointerUp,$=>{const T=$.target;T.hasPointerCapture($.pointerId)&&T.releasePointerCapture($.pointerId),document.body.style.webkitUserSelect=S.current,u.viewport&&(u.viewport.style.scrollBehavior=""),N.current=null})})})}),Rm="ScrollAreaThumb",Bk=v.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=Mk(Rm,t.__scopeScrollArea);return e.jsx(mr,{present:n||a.hasThumb,children:e.jsx(S9,{ref:s,...r})})}),S9=v.forwardRef((t,s)=>{const{__scopeScrollArea:n,style:r,...a}=t,l=Ea(Rm,n),c=Mk(Rm,n),{onThumbPositionChange:d}=c,h=Ms(s,m=>c.onThumbChange(m)),x=v.useRef(void 0),f=pf(()=>{x.current&&(x.current(),x.current=void 0)},100);return v.useEffect(()=>{const m=l.viewport;if(m){const p=()=>{if(f(),!x.current){const u=k9(m,d);x.current=u,d()}};return d(),m.addEventListener("scroll",p),()=>m.removeEventListener("scroll",p)}},[l.viewport,f,d]),e.jsx(ps.div,{"data-state":c.hasThumb?"visible":"hidden",...a,ref:h,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Vt(t.onPointerDownCapture,m=>{const u=m.target.getBoundingClientRect(),j=m.clientX-u.left,g=m.clientY-u.top;c.onThumbPointerDown({x:j,y:g})}),onPointerUp:Vt(t.onPointerUp,c.onThumbPointerUp)})});Bk.displayName=Rm;var Ab="ScrollAreaCorner",$k=v.forwardRef((t,s)=>{const n=Ea(Ab,t.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?e.jsx(C9,{...t,ref:s}):null});$k.displayName=Ab;var C9=v.forwardRef((t,s)=>{const{__scopeScrollArea:n,...r}=t,a=Ea(Ab,n),[l,c]=v.useState(0),[d,h]=v.useState(0),x=!!(l&&d);return _c(a.scrollbarX,()=>{var m;const f=((m=a.scrollbarX)==null?void 0:m.offsetHeight)||0;a.onCornerHeightChange(f),h(f)}),_c(a.scrollbarY,()=>{var m;const f=((m=a.scrollbarY)==null?void 0:m.offsetWidth)||0;a.onCornerWidthChange(f),c(f)}),x?e.jsx(ps.div,{...r,ref:s,style:{width:l,height:d,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function Em(t){return t?parseInt(t,10):0}function qk(t,s){const n=t/s;return isNaN(n)?0:n}function ff(t){const s=qk(t.viewport,t.content),n=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,r=(t.scrollbar.size-n)*s;return Math.max(r,18)}function A9(t,s,n,r="ltr"){const a=ff(n),l=a/2,c=s||l,d=a-c,h=n.scrollbar.paddingStart+c,x=n.scrollbar.size-n.scrollbar.paddingEnd-d,f=n.content-n.viewport,m=r==="ltr"?[0,f]:[f*-1,0];return zk([h,x],m)(t)}function Xw(t,s,n="ltr"){const r=ff(s),a=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,l=s.scrollbar.size-a,c=s.content-s.viewport,d=l-r,h=n==="ltr"?[0,c]:[c*-1,0],x=bv(t,h);return zk([0,c],[0,d])(x)}function zk(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 Uk(t,s){return t>0&&t<s}var k9=(t,s=()=>{})=>{let n={left:t.scrollLeft,top:t.scrollTop},r=0;return(function a(){const l={left:t.scrollLeft,top:t.scrollTop},c=n.left!==l.left,d=n.top!==l.top;(c||d)&&s(),n=l,r=window.requestAnimationFrame(a)})(),()=>window.cancelAnimationFrame(r)};function pf(t,s){const n=dr(t),r=v.useRef(0);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),v.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,s)},[n,s])}function _c(t,s){const n=dr(s);Zn(()=>{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 R9=Pk,E9=Ok,D9=$k;function kb({className:t,children:s,...n}){return e.jsxs(R9,{"data-slot":"scroll-area",className:Pt("relative",t),...n,children:[e.jsx(E9,{"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(T9,{}),e.jsx(D9,{})]})}function T9({className:t,orientation:s="vertical",...n}){return e.jsx(Ik,{"data-slot":"scroll-area-scrollbar",orientation:s,className:Pt("flex touch-none p-px transition-colors select-none",s==="vertical"&&"h-full w-2.5 border-l border-l-transparent",s==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",t),...n,children:e.jsx(Bk,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}function P9({onNavigate:t}){const s=[{title:"Total Applications",value:hi.totalApplications,icon:fs,color:"bg-blue-500",trend:{value:12,isPositive:!0},filter:"all"},{title:"LOA Issued",value:hi.loaIssued,icon:Ys,color:"bg-green-500",trend:{value:8,isPositive:!0},filter:"Approved"},{title:"Level 1 Pending",value:hi.level1Pending,icon:Js,color:"bg-amber-500",trend:{value:3,isPositive:!1},filter:"Level 1 Pending"},{title:"Level 2 Pending",value:hi.level2Pending,icon:gI,color:"bg-purple-500",trend:{value:5,isPositive:!0},filter:"Level 2 Pending"},{title:"Level 3 Pending",value:hi.level3Pending,icon:Z5,color:"bg-indigo-500",trend:{value:2,isPositive:!1},filter:"Level 3 Pending"},{title:"EOR In Progress",value:hi.eorInProgress,icon:Ks,color:"bg-cyan-500",trend:{value:1,isPositive:!0},filter:"EOR In Progress"},{title:"Disqualified",value:hi.disqualified,icon:Za,color:"bg-red-500",trend:{value:4,isPositive:!1},filter:"Disqualified"},{title:"Pending Reminders",value:hi.pendingReminders,icon:qr,color:"bg-orange-500",trend:{value:7,isPositive:!1},filter:"Questionnaire Pending"},{title:"Shortlisted Today",value:hi.shortlistedToday,icon:Ys,color:"bg-teal-500",trend:{value:5,isPositive:!0},filter:"Shortlisted"},{title:"Pending Shortlisting",value:hi.pendingShortlisting,icon:nI,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(l=>l.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(l=>{const c=l.icon,d=l.trend.isPositive?Wi:Po;return e.jsxs(Le,{className:"cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>t(l.action||"applications",l.filter),children:[e.jsxs(tt,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(nt,{className:"text-slate-600",children:l.title}),e.jsx("div",{className:`${l.color} p-2 rounded-lg`,children:e.jsx(c,{className:"w-5 h-5 text-white"})})]}),e.jsx(Me,{children:e.jsx("div",{className:"flex items-end justify-between",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-slate-900",children:l.value}),e.jsxs("div",{className:`flex items-center gap-1 mt-1 ${l.trend.isPositive?"text-green-600":"text-red-600"}`,children:[e.jsx(d,{className:"w-3 h-3"}),e.jsxs("span",{children:[l.trend.value,"% from last month"]})]})]})})})]},l.title)})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Application Status Distribution"})}),e.jsx(Me,{children:e.jsx("div",{className:"space-y-4",children:n.map(l=>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:l.color}}),e.jsx("span",{className:"text-slate-700",children:l.status})]}),e.jsx("span",{className:"text-slate-900",children:l.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:`${l.count/150*100}%`,backgroundColor:l.color}})})]},l.status))})})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Applications by Location"})}),e.jsx(Me,{children:e.jsx("div",{className:"space-y-3",children:r.map(l=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-24 text-slate-700",children:l.location}),e.jsx("div",{className:"flex-1 bg-slate-200 rounded-full h-8 relative overflow-hidden",children:e.jsx("div",{className:"bg-amber-600 h-full rounded-full transition-all flex items-center justify-end px-3",style:{width:`${l.count/a*100}%`},children:e.jsx("span",{className:"text-white",children:l.count})})})]},l.location))})})]})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Recent Activity"})}),e.jsx(Me,{children:e.jsx(kb,{className:"h-80",children:e.jsx("div",{className:"space-y-4",children:JI.map(l=>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-amber-100 rounded-full flex items-center justify-center flex-shrink-0",children:[l.action==="Approved"&&e.jsx(Ys,{className:"w-5 h-5 text-green-600"}),l.action==="Interview Scheduled"&&e.jsx(Js,{className:"w-5 h-5 text-blue-600"}),l.action==="Document Uploaded"&&e.jsx(fs,{className:"w-5 h-5 text-purple-600"}),l.action==="Reminder Sent"&&e.jsx(qr,{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(Ae,{variant:"outline",children:l.applicationId}),e.jsx("span",{className:"text-slate-700",children:l.action})]}),e.jsxs("p",{className:"text-slate-500 mt-1",children:["by ",l.user]})]}),e.jsx("div",{className:"text-slate-500 flex-shrink-0",children:l.timestamp})]},l.id))})})})]})]})}var xf="Tabs",[_9]=ea(xf,[af]),Vk=af(),[O9,Rb]=_9(xf),Hk=v.forwardRef((t,s)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:l,orientation:c="horizontal",dir:d,activationMode:h="automatic",...x}=t,f=pu(d),[m,p]=bi({prop:r,onChange:a,defaultProp:l??"",caller:xf});return e.jsx(O9,{scope:n,baseId:hr(),value:m,onValueChange:p,orientation:c,dir:f,activationMode:h,children:e.jsx(ps.div,{dir:f,"data-orientation":c,...x,ref:s})})});Hk.displayName=xf;var Wk="TabsList",Gk=v.forwardRef((t,s)=>{const{__scopeTabs:n,loop:r=!0,...a}=t,l=Rb(Wk,n),c=Vk(n);return e.jsx(vA,{asChild:!0,...c,orientation:l.orientation,dir:l.dir,loop:r,children:e.jsx(ps.div,{role:"tablist","aria-orientation":l.orientation,...a,ref:s})})});Gk.displayName=Wk;var Kk="TabsTrigger",Yk=v.forwardRef((t,s)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...l}=t,c=Rb(Kk,n),d=Vk(n),h=Xk(c.baseId,r),x=Jk(c.baseId,r),f=r===c.value;return e.jsx(bA,{asChild:!0,...d,focusable:!a,active:f,children:e.jsx(ps.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":x,"data-state":f?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:h,...l,ref:s,onMouseDown:Vt(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?c.onValueChange(r):m.preventDefault()}),onKeyDown:Vt(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&c.onValueChange(r)}),onFocus:Vt(t.onFocus,()=>{const m=c.activationMode!=="manual";!f&&!a&&m&&c.onValueChange(r)})})})});Yk.displayName=Kk;var Zk="TabsContent",Qk=v.forwardRef((t,s)=>{const{__scopeTabs:n,value:r,forceMount:a,children:l,...c}=t,d=Rb(Zk,n),h=Xk(d.baseId,r),x=Jk(d.baseId,r),f=r===d.value,m=v.useRef(f);return v.useEffect(()=>{const p=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(p)},[]),e.jsx(mr,{present:a||f,children:({present:p})=>e.jsx(ps.div,{"data-state":f?"active":"inactive","data-orientation":d.orientation,role:"tabpanel","aria-labelledby":h,hidden:!p,id:x,tabIndex:0,...c,ref:s,style:{...t.style,animationDuration:m.current?"0s":void 0},children:p&&l})})});Qk.displayName=Zk;function Xk(t,s){return`${t}-trigger-${s}`}function Jk(t,s){return`${t}-content-${s}`}var I9=Hk,L9=Gk,M9=Yk,F9=Qk;function Pn({className:t,...s}){return e.jsx(I9,{"data-slot":"tabs",className:Pt("flex flex-col gap-2",t),...s})}function _n({className:t,...s}){return e.jsx(L9,{"data-slot":"tabs-list",className:Pt("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(M9,{"data-slot":"tabs-trigger",className:Pt("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 Gt({className:t,...s}){return e.jsx(F9,{"data-slot":"tabs-content",className:Pt("flex-1 outline-none",t),...s})}function B9(t){const s=$9(t),n=v.forwardRef((r,a)=>{const{children:l,...c}=r,d=v.Children.toArray(l),h=d.find(z9);if(h){const x=h.props.children,f=d.map(m=>m===h?v.Children.count(x)>1?v.Children.only(null):v.isValidElement(x)?x.props.children:null:m);return e.jsx(s,{...c,ref:a,children:v.isValidElement(x)?v.cloneElement(x,void 0,f):null})}return e.jsx(s,{...c,ref:a,children:l})});return n.displayName=`${t}.Slot`,n}function $9(t){const s=v.forwardRef((n,r)=>{const{children:a,...l}=n;if(v.isValidElement(a)){const c=V9(a),d=U9(l,a.props);return a.type!==v.Fragment&&(d.ref=r?Br(r,c):c),v.cloneElement(a,d)}return v.Children.count(a)>1?v.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var q9=Symbol("radix.slottable");function z9(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===q9}function U9(t,s){const n={...s};for(const r in s){const a=t[r],l=s[r];/^on[A-Z]/.test(r)?a&&l?n[r]=(...d)=>{const h=l(...d);return a(...d),h}:a&&(n[r]=a):r==="style"?n[r]={...a,...l}:r==="className"&&(n[r]=[a,l].filter(Boolean).join(" "))}return{...t,...n}}function V9(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 gf="Dialog",[eR,tR]=ea(gf),[H9,si]=eR(gf),sR=t=>{const{__scopeDialog:s,children:n,open:r,defaultOpen:a,onOpenChange:l,modal:c=!0}=t,d=v.useRef(null),h=v.useRef(null),[x,f]=bi({prop:r,defaultProp:a??!1,onChange:l,caller:gf});return e.jsx(H9,{scope:s,triggerRef:d,contentRef:h,contentId:hr(),titleId:hr(),descriptionId:hr(),open:x,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(m=>!m),[f]),modal:c,children:n})};sR.displayName=gf;var nR="DialogTrigger",rR=v.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=si(nR,n),l=Ms(s,a.triggerRef);return e.jsx(ps.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":Tb(a.open),...r,ref:l,onClick:Vt(t.onClick,a.onOpenToggle)})});rR.displayName=nR;var Eb="DialogPortal",[W9,aR]=eR(Eb,{forceMount:void 0}),iR=t=>{const{__scopeDialog:s,forceMount:n,children:r,container:a}=t,l=si(Eb,s);return e.jsx(W9,{scope:s,forceMount:n,children:v.Children.map(r,c=>e.jsx(mr,{present:n||l.open,children:e.jsx(Hc,{asChild:!0,container:a,children:c})}))})};iR.displayName=Eb;var Dm="DialogOverlay",lR=v.forwardRef((t,s)=>{const n=aR(Dm,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,l=si(Dm,t.__scopeDialog);return l.modal?e.jsx(mr,{present:r||l.open,children:e.jsx(K9,{...a,ref:s})}):null});lR.displayName=Dm;var G9=B9("DialogOverlay.RemoveScroll"),K9=v.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=si(Dm,n);return e.jsx(yu,{as:G9,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(ps.div,{"data-state":Tb(a.open),...r,ref:s,style:{pointerEvents:"auto",...r.style}})})}),$o="DialogContent",oR=v.forwardRef((t,s)=>{const n=aR($o,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,l=si($o,t.__scopeDialog);return e.jsx(mr,{present:r||l.open,children:l.modal?e.jsx(Y9,{...a,ref:s}):e.jsx(Z9,{...a,ref:s})})});oR.displayName=$o;var Y9=v.forwardRef((t,s)=>{const n=si($o,t.__scopeDialog),r=v.useRef(null),a=Ms(s,n.contentRef,r);return v.useEffect(()=>{const l=r.current;if(l)return lf(l)},[]),e.jsx(cR,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Vt(t.onCloseAutoFocus,l=>{var c;l.preventDefault(),(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:Vt(t.onPointerDownOutside,l=>{const c=l.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0;(c.button===2||d)&&l.preventDefault()}),onFocusOutside:Vt(t.onFocusOutside,l=>l.preventDefault())})}),Z9=v.forwardRef((t,s)=>{const n=si($o,t.__scopeDialog),r=v.useRef(!1),a=v.useRef(!1);return e.jsx(cR,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:l=>{var c,d;(c=t.onCloseAutoFocus)==null||c.call(t,l),l.defaultPrevented||(r.current||(d=n.triggerRef.current)==null||d.focus(),l.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:l=>{var h,x;(h=t.onInteractOutside)==null||h.call(t,l),l.defaultPrevented||(r.current=!0,l.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const c=l.target;((x=n.triggerRef.current)==null?void 0:x.contains(c))&&l.preventDefault(),l.detail.originalEvent.type==="focusin"&&a.current&&l.preventDefault()}})}),cR=v.forwardRef((t,s)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:l,...c}=t,d=si($o,n),h=v.useRef(null),x=Ms(s,h);return Qm(),e.jsxs(e.Fragment,{children:[e.jsx(xu,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:l,children:e.jsx(zc,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":Tb(d.open),...c,ref:x,onDismiss:()=>d.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(X9,{titleId:d.titleId}),e.jsx(eB,{contentRef:h,descriptionId:d.descriptionId})]})]})}),Db="DialogTitle",dR=v.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=si(Db,n);return e.jsx(ps.h2,{id:a.titleId,...r,ref:s})});dR.displayName=Db;var uR="DialogDescription",hR=v.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=si(uR,n);return e.jsx(ps.p,{id:a.descriptionId,...r,ref:s})});hR.displayName=uR;var mR="DialogClose",fR=v.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=si(mR,n);return e.jsx(ps.button,{type:"button",...r,ref:s,onClick:Vt(t.onClick,()=>a.onOpenChange(!1))})});fR.displayName=mR;function Tb(t){return t?"open":"closed"}var pR="DialogTitleWarning",[Q9,xR]=S5(pR,{contentName:$o,titleName:Db,docsSlug:"dialog"}),X9=({titleId:t})=>{const s=xR(pR),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 v.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},J9="DialogDescriptionWarning",eB=({contentRef:t,descriptionId:s})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${xR(J9).contentName}}.`;return v.useEffect(()=>{var l;const a=(l=t.current)==null?void 0:l.getAttribute("aria-describedby");s&&a&&(document.getElementById(s)||console.warn(r))},[r,t,s]),null},Pb=sR,gR=rR,_b=iR,vf=lR,bf=oR,vR=dR,bR=hR,Ob=fR;function os({...t}){return e.jsx(Pb,{"data-slot":"dialog",...t})}function Hl({...t}){return e.jsx(gR,{"data-slot":"dialog-trigger",...t})}function tB({...t}){return e.jsx(_b,{"data-slot":"dialog-portal",...t})}const yR=v.forwardRef(({className:t,...s},n)=>e.jsx(vf,{ref:n,"data-slot":"dialog-overlay",className:Pt("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}));yR.displayName=vf.displayName;const ls=v.forwardRef(({className:t,children:s,...n},r)=>e.jsxs(tB,{"data-slot":"dialog-portal",children:[e.jsx(yR,{}),e.jsxs(bf,{ref:r,"data-slot":"dialog-content",className:Pt("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(Ob,{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(Tc,{}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ls.displayName=bf.displayName;function ms({className:t,...s}){return e.jsx("div",{"data-slot":"dialog-header",className:Pt("flex flex-col gap-2 text-center sm:text-left",t),...s})}function rn({className:t,...s}){return e.jsx("div",{"data-slot":"dialog-footer",className:Pt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...s})}function us({className:t,...s}){return e.jsx(vR,{"data-slot":"dialog-title",className:Pt("text-lg leading-none font-semibold",t),...s})}function vs({className:t,...s}){return e.jsx(bR,{"data-slot":"dialog-description",className:Pt("text-muted-foreground text-sm",t),...s})}function sB(t){const s=nB(t),n=v.forwardRef((r,a)=>{const{children:l,...c}=r,d=v.Children.toArray(l),h=d.find(aB);if(h){const x=h.props.children,f=d.map(m=>m===h?v.Children.count(x)>1?v.Children.only(null):v.isValidElement(x)?x.props.children:null:m);return e.jsx(s,{...c,ref:a,children:v.isValidElement(x)?v.cloneElement(x,void 0,f):null})}return e.jsx(s,{...c,ref:a,children:l})});return n.displayName=`${t}.Slot`,n}function nB(t){const s=v.forwardRef((n,r)=>{const{children:a,...l}=n;if(v.isValidElement(a)){const c=lB(a),d=iB(l,a.props);return a.type!==v.Fragment&&(d.ref=r?Br(r,c):c),v.cloneElement(a,d)}return v.Children.count(a)>1?v.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var rB=Symbol("radix.slottable");function aB(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===rB}function iB(t,s){const n={...s};for(const r in s){const a=t[r],l=s[r];/^on[A-Z]/.test(r)?a&&l?n[r]=(...d)=>{const h=l(...d);return a(...d),h}:a&&(n[r]=a):r==="style"?n[r]={...a,...l}:r==="className"&&(n[r]=[a,l].filter(Boolean).join(" "))}return{...t,...n}}function lB(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 jR=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"}),oB="VisuallyHidden",NR=v.forwardRef((t,s)=>e.jsx(ps.span,{...t,ref:s,style:{...jR,...t.style}}));NR.displayName=oB;var cB=NR,dB=[" ","Enter","ArrowUp","ArrowDown"],uB=[" ","Enter"],qo="Select",[yf,jf,hB]=eb(qo),[Gc]=ea(qo,[hB,Vl]),Nf=Vl(),[mB,Wl]=Gc(qo),[fB,pB]=Gc(qo),wR=t=>{const{__scopeSelect:s,children:n,open:r,defaultOpen:a,onOpenChange:l,value:c,defaultValue:d,onValueChange:h,dir:x,name:f,autoComplete:m,disabled:p,required:u,form:j}=t,g=Nf(s),[y,N]=v.useState(null),[S,C]=v.useState(null),[w,R]=v.useState(!1),P=pu(x),[A,I]=bi({prop:r,defaultProp:a??!1,onChange:l,caller:qo}),[$,T]=bi({prop:c,defaultProp:d,onChange:h,caller:qo}),E=v.useRef(null),_=y?j||!!y.closest("form"):!0,[M,q]=v.useState(new Set),G=Array.from(M).map(Z=>Z.props.value).join(";");return e.jsx(sf,{...g,children:e.jsxs(mB,{required:u,scope:s,trigger:y,onTriggerChange:N,valueNode:S,onValueNodeChange:C,valueNodeHasChildren:w,onValueNodeHasChildrenChange:R,contentId:hr(),value:$,onValueChange:T,open:A,onOpenChange:I,dir:P,triggerPointerDownPosRef:E,disabled:p,children:[e.jsx(yf.Provider,{scope:s,children:e.jsx(fB,{scope:t.__scopeSelect,onNativeOptionAdd:v.useCallback(Z=>{q(W=>new Set(W).add(Z))},[]),onNativeOptionRemove:v.useCallback(Z=>{q(W=>{const z=new Set(W);return z.delete(Z),z})},[]),children:n})}),_?e.jsxs(GR,{"aria-hidden":!0,required:u,tabIndex:-1,name:f,autoComplete:m,value:$,onChange:Z=>T(Z.target.value),disabled:p,form:j,children:[$===void 0?e.jsx("option",{value:""}):null,Array.from(M)]},G):null]})})};wR.displayName=qo;var SR="SelectTrigger",CR=v.forwardRef((t,s)=>{const{__scopeSelect:n,disabled:r=!1,...a}=t,l=Nf(n),c=Wl(SR,n),d=c.disabled||r,h=Ms(s,c.onTriggerChange),x=jf(n),f=v.useRef("touch"),[m,p,u]=YR(g=>{const y=x().filter(C=>!C.disabled),N=y.find(C=>C.value===c.value),S=ZR(y,g,N);S!==void 0&&c.onValueChange(S.value)}),j=g=>{d||(c.onOpenChange(!0),u()),g&&(c.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return e.jsx(vu,{asChild:!0,...l,children:e.jsx(ps.button,{type:"button",role:"combobox","aria-controls":c.contentId,"aria-expanded":c.open,"aria-required":c.required,"aria-autocomplete":"none",dir:c.dir,"data-state":c.open?"open":"closed",disabled:d,"data-disabled":d?"":void 0,"data-placeholder":KR(c.value)?"":void 0,...a,ref:h,onClick:Vt(a.onClick,g=>{g.currentTarget.focus(),f.current!=="mouse"&&j(g)}),onPointerDown:Vt(a.onPointerDown,g=>{f.current=g.pointerType;const y=g.target;y.hasPointerCapture(g.pointerId)&&y.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(j(g),g.preventDefault())}),onKeyDown:Vt(a.onKeyDown,g=>{const y=m.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&p(g.key),!(y&&g.key===" ")&&dB.includes(g.key)&&(j(),g.preventDefault())})})})});CR.displayName=SR;var AR="SelectValue",kR=v.forwardRef((t,s)=>{const{__scopeSelect:n,className:r,style:a,children:l,placeholder:c="",...d}=t,h=Wl(AR,n),{onValueNodeHasChildrenChange:x}=h,f=l!==void 0,m=Ms(s,h.onValueNodeChange);return Zn(()=>{x(f)},[x,f]),e.jsx(ps.span,{...d,ref:m,style:{pointerEvents:"none"},children:KR(h.value)?e.jsx(e.Fragment,{children:c}):l})});kR.displayName=AR;var xB="SelectIcon",RR=v.forwardRef((t,s)=>{const{__scopeSelect:n,children:r,...a}=t;return e.jsx(ps.span,{"aria-hidden":!0,...a,ref:s,children:r||"▼"})});RR.displayName=xB;var gB="SelectPortal",ER=t=>e.jsx(Hc,{asChild:!0,...t});ER.displayName=gB;var zo="SelectContent",DR=v.forwardRef((t,s)=>{const n=Wl(zo,t.__scopeSelect),[r,a]=v.useState();if(Zn(()=>{a(new DocumentFragment)},[]),!n.open){const l=r;return l?cu.createPortal(e.jsx(TR,{scope:t.__scopeSelect,children:e.jsx(yf.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),l):null}return e.jsx(PR,{...t,ref:s})});DR.displayName=zo;var Wa=10,[TR,Gl]=Gc(zo),vB="SelectContentImpl",bB=sB("SelectContent.RemoveScroll"),PR=v.forwardRef((t,s)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:l,onPointerDownOutside:c,side:d,sideOffset:h,align:x,alignOffset:f,arrowPadding:m,collisionBoundary:p,collisionPadding:u,sticky:j,hideWhenDetached:g,avoidCollisions:y,...N}=t,S=Wl(zo,n),[C,w]=v.useState(null),[R,P]=v.useState(null),A=Ms(s,X=>w(X)),[I,$]=v.useState(null),[T,E]=v.useState(null),_=jf(n),[M,q]=v.useState(!1),G=v.useRef(!1);v.useEffect(()=>{if(C)return lf(C)},[C]),Qm();const Z=v.useCallback(X=>{const[ne,...oe]=_().map(ve=>ve.ref.current),[re]=oe.slice(-1),ge=document.activeElement;for(const ve of X)if(ve===ge||(ve==null||ve.scrollIntoView({block:"nearest"}),ve===ne&&R&&(R.scrollTop=0),ve===re&&R&&(R.scrollTop=R.scrollHeight),ve==null||ve.focus(),document.activeElement!==ge))return},[_,R]),W=v.useCallback(()=>Z([I,C]),[Z,I,C]);v.useEffect(()=>{M&&W()},[M,W]);const{onOpenChange:z,triggerPointerDownPosRef:F}=S;v.useEffect(()=>{if(C){let X={x:0,y:0};const ne=re=>{var ge,ve;X={x:Math.abs(Math.round(re.pageX)-(((ge=F.current)==null?void 0:ge.x)??0)),y:Math.abs(Math.round(re.pageY)-(((ve=F.current)==null?void 0:ve.y)??0))}},oe=re=>{X.x<=10&&X.y<=10?re.preventDefault():C.contains(re.target)||z(!1),document.removeEventListener("pointermove",ne),F.current=null};return F.current!==null&&(document.addEventListener("pointermove",ne),document.addEventListener("pointerup",oe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ne),document.removeEventListener("pointerup",oe,{capture:!0})}}},[C,z,F]),v.useEffect(()=>{const X=()=>z(!1);return window.addEventListener("blur",X),window.addEventListener("resize",X),()=>{window.removeEventListener("blur",X),window.removeEventListener("resize",X)}},[z]);const[B,D]=YR(X=>{const ne=_().filter(ge=>!ge.disabled),oe=ne.find(ge=>ge.ref.current===document.activeElement),re=ZR(ne,X,oe);re&&setTimeout(()=>re.ref.current.focus())}),O=v.useCallback((X,ne,oe)=>{const re=!G.current&&!oe;(S.value!==void 0&&S.value===ne||re)&&($(X),re&&(G.current=!0))},[S.value]),V=v.useCallback(()=>C==null?void 0:C.focus(),[C]),K=v.useCallback((X,ne,oe)=>{const re=!G.current&&!oe;(S.value!==void 0&&S.value===ne||re)&&E(X)},[S.value]),Y=r==="popper"?yv:_R,U=Y===yv?{side:d,sideOffset:h,align:x,alignOffset:f,arrowPadding:m,collisionBoundary:p,collisionPadding:u,sticky:j,hideWhenDetached:g,avoidCollisions:y}:{};return e.jsx(TR,{scope:n,content:C,viewport:R,onViewportChange:P,itemRefCallback:O,selectedItem:I,onItemLeave:V,itemTextRefCallback:K,focusSelectedItem:W,selectedItemText:T,position:r,isPositioned:M,searchRef:B,children:e.jsx(yu,{as:bB,allowPinchZoom:!0,children:e.jsx(xu,{asChild:!0,trapped:S.open,onMountAutoFocus:X=>{X.preventDefault()},onUnmountAutoFocus:Vt(a,X=>{var ne;(ne=S.trigger)==null||ne.focus({preventScroll:!0}),X.preventDefault()}),children:e.jsx(zc,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:X=>X.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:e.jsx(Y,{role:"listbox",id:S.contentId,"data-state":S.open?"open":"closed",dir:S.dir,onContextMenu:X=>X.preventDefault(),...N,...U,onPlaced:()=>q(!0),ref:A,style:{display:"flex",flexDirection:"column",outline:"none",...N.style},onKeyDown:Vt(N.onKeyDown,X=>{const ne=X.ctrlKey||X.altKey||X.metaKey;if(X.key==="Tab"&&X.preventDefault(),!ne&&X.key.length===1&&D(X.key),["ArrowUp","ArrowDown","Home","End"].includes(X.key)){let re=_().filter(ge=>!ge.disabled).map(ge=>ge.ref.current);if(["ArrowUp","End"].includes(X.key)&&(re=re.slice().reverse()),["ArrowUp","ArrowDown"].includes(X.key)){const ge=X.target,ve=re.indexOf(ge);re=re.slice(ve+1)}setTimeout(()=>Z(re)),X.preventDefault()}})})})})})})});PR.displayName=vB;var yB="SelectItemAlignedPosition",_R=v.forwardRef((t,s)=>{const{__scopeSelect:n,onPlaced:r,...a}=t,l=Wl(zo,n),c=Gl(zo,n),[d,h]=v.useState(null),[x,f]=v.useState(null),m=Ms(s,A=>f(A)),p=jf(n),u=v.useRef(!1),j=v.useRef(!0),{viewport:g,selectedItem:y,selectedItemText:N,focusSelectedItem:S}=c,C=v.useCallback(()=>{if(l.trigger&&l.valueNode&&d&&x&&g&&y&&N){const A=l.trigger.getBoundingClientRect(),I=x.getBoundingClientRect(),$=l.valueNode.getBoundingClientRect(),T=N.getBoundingClientRect();if(l.dir!=="rtl"){const ge=T.left-I.left,ve=$.left-ge,Se=A.left-ve,We=A.width+Se,Ce=Math.max(We,I.width),fe=window.innerWidth-Wa,Ye=bv(ve,[Wa,Math.max(Wa,fe-Ce)]);d.style.minWidth=We+"px",d.style.left=Ye+"px"}else{const ge=I.right-T.right,ve=window.innerWidth-$.right-ge,Se=window.innerWidth-A.right-ve,We=A.width+Se,Ce=Math.max(We,I.width),fe=window.innerWidth-Wa,Ye=bv(ve,[Wa,Math.max(Wa,fe-Ce)]);d.style.minWidth=We+"px",d.style.right=Ye+"px"}const E=p(),_=window.innerHeight-Wa*2,M=g.scrollHeight,q=window.getComputedStyle(x),G=parseInt(q.borderTopWidth,10),Z=parseInt(q.paddingTop,10),W=parseInt(q.borderBottomWidth,10),z=parseInt(q.paddingBottom,10),F=G+Z+M+z+W,B=Math.min(y.offsetHeight*5,F),D=window.getComputedStyle(g),O=parseInt(D.paddingTop,10),V=parseInt(D.paddingBottom,10),K=A.top+A.height/2-Wa,Y=_-K,U=y.offsetHeight/2,X=y.offsetTop+U,ne=G+Z+X,oe=F-ne;if(ne<=K){const ge=E.length>0&&y===E[E.length-1].ref.current;d.style.bottom="0px";const ve=x.clientHeight-g.offsetTop-g.offsetHeight,Se=Math.max(Y,U+(ge?V:0)+ve+W),We=ne+Se;d.style.height=We+"px"}else{const ge=E.length>0&&y===E[0].ref.current;d.style.top="0px";const Se=Math.max(K,G+g.offsetTop+(ge?O:0)+U)+oe;d.style.height=Se+"px",g.scrollTop=ne-K+g.offsetTop}d.style.margin=`${Wa}px 0`,d.style.minHeight=B+"px",d.style.maxHeight=_+"px",r==null||r(),requestAnimationFrame(()=>u.current=!0)}},[p,l.trigger,l.valueNode,d,x,g,y,N,l.dir,r]);Zn(()=>C(),[C]);const[w,R]=v.useState();Zn(()=>{x&&R(window.getComputedStyle(x).zIndex)},[x]);const P=v.useCallback(A=>{A&&j.current===!0&&(C(),S==null||S(),j.current=!1)},[C,S]);return e.jsx(NB,{scope:n,contentWrapper:d,shouldExpandOnScrollRef:u,onScrollButtonChange:P,children:e.jsx("div",{ref:h,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:e.jsx(ps.div,{...a,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});_R.displayName=yB;var jB="SelectPopperPosition",yv=v.forwardRef((t,s)=>{const{__scopeSelect:n,align:r="start",collisionPadding:a=Wa,...l}=t,c=Nf(n);return e.jsx(nf,{...c,...l,ref:s,align:r,collisionPadding:a,style:{boxSizing:"border-box",...l.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)"}})});yv.displayName=jB;var[NB,Ib]=Gc(zo,{}),jv="SelectViewport",OR=v.forwardRef((t,s)=>{const{__scopeSelect:n,nonce:r,...a}=t,l=Gl(jv,n),c=Ib(jv,n),d=Ms(s,l.onViewportChange),h=v.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(yf.Slot,{scope:n,children:e.jsx(ps.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:d,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Vt(a.onScroll,x=>{const f=x.currentTarget,{contentWrapper:m,shouldExpandOnScrollRef:p}=c;if(p!=null&&p.current&&m){const u=Math.abs(h.current-f.scrollTop);if(u>0){const j=window.innerHeight-Wa*2,g=parseFloat(m.style.minHeight),y=parseFloat(m.style.height),N=Math.max(g,y);if(N<j){const S=N+u,C=Math.min(j,S),w=S-C;m.style.height=C+"px",m.style.bottom==="0px"&&(f.scrollTop=w>0?w:0,m.style.justifyContent="flex-end")}}}h.current=f.scrollTop})})})]})});OR.displayName=jv;var IR="SelectGroup",[wB,SB]=Gc(IR),LR=v.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t,a=hr();return e.jsx(wB,{scope:n,id:a,children:e.jsx(ps.div,{role:"group","aria-labelledby":a,...r,ref:s})})});LR.displayName=IR;var MR="SelectLabel",FR=v.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t,a=SB(MR,n);return e.jsx(ps.div,{id:a.id,...r,ref:s})});FR.displayName=MR;var Tm="SelectItem",[CB,BR]=Gc(Tm),$R=v.forwardRef((t,s)=>{const{__scopeSelect:n,value:r,disabled:a=!1,textValue:l,...c}=t,d=Wl(Tm,n),h=Gl(Tm,n),x=d.value===r,[f,m]=v.useState(l??""),[p,u]=v.useState(!1),j=Ms(s,S=>{var C;return(C=h.itemRefCallback)==null?void 0:C.call(h,S,r,a)}),g=hr(),y=v.useRef("touch"),N=()=>{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(CB,{scope:n,value:r,disabled:a,textId:g,isSelected:x,onItemTextChange:v.useCallback(S=>{m(C=>C||((S==null?void 0:S.textContent)??"").trim())},[]),children:e.jsx(yf.ItemSlot,{scope:n,value:r,disabled:a,textValue:f,children:e.jsx(ps.div,{role:"option","aria-labelledby":g,"data-highlighted":p?"":void 0,"aria-selected":x&&p,"data-state":x?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...c,ref:j,onFocus:Vt(c.onFocus,()=>u(!0)),onBlur:Vt(c.onBlur,()=>u(!1)),onClick:Vt(c.onClick,()=>{y.current!=="mouse"&&N()}),onPointerUp:Vt(c.onPointerUp,()=>{y.current==="mouse"&&N()}),onPointerDown:Vt(c.onPointerDown,S=>{y.current=S.pointerType}),onPointerMove:Vt(c.onPointerMove,S=>{var C;y.current=S.pointerType,a?(C=h.onItemLeave)==null||C.call(h):y.current==="mouse"&&S.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Vt(c.onPointerLeave,S=>{var C;S.currentTarget===document.activeElement&&((C=h.onItemLeave)==null||C.call(h))}),onKeyDown:Vt(c.onKeyDown,S=>{var w;((w=h.searchRef)==null?void 0:w.current)!==""&&S.key===" "||(uB.includes(S.key)&&N(),S.key===" "&&S.preventDefault())})})})})});$R.displayName=Tm;var Ld="SelectItemText",qR=v.forwardRef((t,s)=>{const{__scopeSelect:n,className:r,style:a,...l}=t,c=Wl(Ld,n),d=Gl(Ld,n),h=BR(Ld,n),x=pB(Ld,n),[f,m]=v.useState(null),p=Ms(s,N=>m(N),h.onItemTextChange,N=>{var S;return(S=d.itemTextRefCallback)==null?void 0:S.call(d,N,h.value,h.disabled)}),u=f==null?void 0:f.textContent,j=v.useMemo(()=>e.jsx("option",{value:h.value,disabled:h.disabled,children:u},h.value),[h.disabled,h.value,u]),{onNativeOptionAdd:g,onNativeOptionRemove:y}=x;return Zn(()=>(g(j),()=>y(j)),[g,y,j]),e.jsxs(e.Fragment,{children:[e.jsx(ps.span,{id:h.textId,...l,ref:p}),h.isSelected&&c.valueNode&&!c.valueNodeHasChildren?cu.createPortal(l.children,c.valueNode):null]})});qR.displayName=Ld;var zR="SelectItemIndicator",UR=v.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t;return BR(zR,n).isSelected?e.jsx(ps.span,{"aria-hidden":!0,...r,ref:s}):null});UR.displayName=zR;var Nv="SelectScrollUpButton",VR=v.forwardRef((t,s)=>{const n=Gl(Nv,t.__scopeSelect),r=Ib(Nv,t.__scopeSelect),[a,l]=v.useState(!1),c=Ms(s,r.onScrollButtonChange);return Zn(()=>{if(n.viewport&&n.isPositioned){let d=function(){const x=h.scrollTop>0;l(x)};const h=n.viewport;return d(),h.addEventListener("scroll",d),()=>h.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),a?e.jsx(WR,{...t,ref:c,onAutoScroll:()=>{const{viewport:d,selectedItem:h}=n;d&&h&&(d.scrollTop=d.scrollTop-h.offsetHeight)}}):null});VR.displayName=Nv;var wv="SelectScrollDownButton",HR=v.forwardRef((t,s)=>{const n=Gl(wv,t.__scopeSelect),r=Ib(wv,t.__scopeSelect),[a,l]=v.useState(!1),c=Ms(s,r.onScrollButtonChange);return Zn(()=>{if(n.viewport&&n.isPositioned){let d=function(){const x=h.scrollHeight-h.clientHeight,f=Math.ceil(h.scrollTop)<x;l(f)};const h=n.viewport;return d(),h.addEventListener("scroll",d),()=>h.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),a?e.jsx(WR,{...t,ref:c,onAutoScroll:()=>{const{viewport:d,selectedItem:h}=n;d&&h&&(d.scrollTop=d.scrollTop+h.offsetHeight)}}):null});HR.displayName=wv;var WR=v.forwardRef((t,s)=>{const{__scopeSelect:n,onAutoScroll:r,...a}=t,l=Gl("SelectScrollButton",n),c=v.useRef(null),d=jf(n),h=v.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return v.useEffect(()=>()=>h(),[h]),Zn(()=>{var f;const x=d().find(m=>m.ref.current===document.activeElement);(f=x==null?void 0:x.ref.current)==null||f.scrollIntoView({block:"nearest"})},[d]),e.jsx(ps.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Vt(a.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(r,50))}),onPointerMove:Vt(a.onPointerMove,()=>{var x;(x=l.onItemLeave)==null||x.call(l),c.current===null&&(c.current=window.setInterval(r,50))}),onPointerLeave:Vt(a.onPointerLeave,()=>{h()})})}),AB="SelectSeparator",kB=v.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t;return e.jsx(ps.div,{"aria-hidden":!0,...r,ref:s})});kB.displayName=AB;var Sv="SelectArrow",RB=v.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t,a=Nf(n),l=Wl(Sv,n),c=Gl(Sv,n);return l.open&&c.position==="popper"?e.jsx(rf,{...a,...r,ref:s}):null});RB.displayName=Sv;var EB="SelectBubbleInput",GR=v.forwardRef(({__scopeSelect:t,value:s,...n},r)=>{const a=v.useRef(null),l=Ms(r,a),c=Wv(s);return v.useEffect(()=>{const d=a.current;if(!d)return;const h=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(h,"value").set;if(c!==s&&f){const m=new Event("change",{bubbles:!0});f.call(d,s),d.dispatchEvent(m)}},[c,s]),e.jsx(ps.select,{...n,style:{...jR,...n.style},ref:l,defaultValue:s})});GR.displayName=EB;function KR(t){return t===""||t===void 0}function YR(t){const s=dr(t),n=v.useRef(""),r=v.useRef(0),a=v.useCallback(c=>{const d=n.current+c;s(d),(function h(x){n.current=x,window.clearTimeout(r.current),x!==""&&(r.current=window.setTimeout(()=>h(""),1e3))})(d)},[s]),l=v.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,a,l]}function ZR(t,s,n){const a=s.length>1&&Array.from(s).every(x=>x===s[0])?s[0]:s,l=n?t.indexOf(n):-1;let c=DB(t,Math.max(l,0));a.length===1&&(c=c.filter(x=>x!==n));const h=c.find(x=>x.textValue.toLowerCase().startsWith(a.toLowerCase()));return h!==n?h:void 0}function DB(t,s){return t.map((n,r)=>t[(s+r)%t.length])}var TB=wR,PB=CR,_B=kR,OB=RR,IB=ER,LB=DR,MB=OR,FB=LR,BB=FR,$B=$R,qB=qR,zB=UR,UB=VR,VB=HR;function wt({...t}){return e.jsx(TB,{"data-slot":"select",...t})}function Jw({...t}){return e.jsx(FB,{"data-slot":"select-group",...t})}function St({...t}){return e.jsx(_B,{"data-slot":"select-value",...t})}function Ct({className:t,size:s="default",children:n,...r}){return e.jsxs(PB,{"data-slot":"select-trigger","data-size":s,className:Pt("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(OB,{asChild:!0,children:e.jsx(la,{className:"size-4 opacity-50"})})]})}function At({className:t,children:s,position:n="popper",...r}){return e.jsx(IB,{children:e.jsxs(LB,{"data-slot":"select-content",className:Pt("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(WB,{}),e.jsx(MB,{className:Pt("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(GB,{})]})})}function HB({className:t,...s}){return e.jsx(BB,{"data-slot":"select-label",className:Pt("text-muted-foreground px-2 py-1.5 text-xs",t),...s})}function Pe({className:t,children:s,...n}){return e.jsxs($B,{"data-slot":"select-item",className:Pt("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(zB,{children:e.jsx(Bn,{className:"size-4"})})}),e.jsx(qB,{children:s})]})}function WB({className:t,...s}){return e.jsx(UB,{"data-slot":"select-scroll-up-button",className:Pt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx($d,{className:"size-4"})})}function GB({className:t,...s}){return e.jsx(VB,{"data-slot":"select-scroll-down-button",className:Pt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(la,{className:"size-4"})})}function ks({className:t,...s}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:e.jsx("table",{"data-slot":"table",className:Pt("w-full caption-bottom text-sm",t),...s})})}function Rs({className:t,...s}){return e.jsx("thead",{"data-slot":"table-header",className:Pt("[&_tr]:border-b",t),...s})}function Es({className:t,...s}){return e.jsx("tbody",{"data-slot":"table-body",className:Pt("[&_tr:last-child]:border-0",t),...s})}function ct({className:t,...s}){return e.jsx("tr",{"data-slot":"table-row",className:Pt("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",t),...s})}function me({className:t,...s}){return e.jsx("th",{"data-slot":"table-head",className:Pt("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 de({className:t,...s}){return e.jsx("td",{"data-slot":"table-cell",className:Pt("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}const QR={getOnboardingPayments:async()=>{var s,n;const t=await Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 Te.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 KB({onNavigate:t,onViewPaymentDetails:s,onViewAuditDetails:n,onViewFnFDetails:r}){var D,O,V,K;const[a,l]=v.useState([]),[c,d]=v.useState([]),[h,x]=v.useState([]),[f,m]=v.useState(!0);v.useEffect(()=>{p()},[]);const p=async()=>{try{m(!0);const[Y,U]=await Promise.all([QR.getFnFSettlements(),ds.getApplications()]),X=U.data||[],ne=[];X.forEach(re=>{const ge=re.overallStatus||re.status,ve=["Payment Pending","Security Details","LOI In Progress","LOI Issued","LOA Pending","Dealer Code Generation","LOA_APPROVAL"].includes(ge),Se=re.securityDeposits||[];Se.length>0?Se.forEach(We=>{ne.push({...We,application:re,paymentStatus:We.status,paymentType:We.depositType,amount:We.amount,id:We.id,applicationId:re.applicationId||re.id,createdAt:We.createdAt,verificationDate:We.verifiedAt})}):ve&&(["Payment Pending","Security Details","LOI In Progress"].includes(ge)?ne.push({id:`virtual-${re.id}-sd`,applicationId:re.applicationId||re.id,application:re,paymentStatus:"Pending",paymentType:"SECURITY_DEPOSIT",amount:5e5,createdAt:re.updatedAt,isVirtual:!0}):["LOA Pending","Dealer Code Generation","LOA_APPROVAL"].includes(ge)&&ne.push({id:`virtual-${re.id}-ff`,applicationId:re.applicationId||re.id,application:re,paymentStatus:"Pending",paymentType:"FIRST_FILL",amount:15e5,createdAt:re.updatedAt,isVirtual:!0}))}),l(ne),d(Y);const oe=X.filter(re=>re.status==="FDD_VERIFICATION"||re.overallStatus==="FDD Verification"||re.currentStage==="FDD");x(oe)}catch(Y){console.error("Fetch error:",Y),ee.error("Failed to load dashboard data")}finally{m(!1)}},[u,j]=v.useState(!1),[g,y]=v.useState(!1),[N,S]=v.useState(null),[C,w]=v.useState([]),[R,P]=v.useState({department:"",description:"",type:"receivable",amount:""}),[A,I]=v.useState(""),$=()=>{const Y=C.filter(ne=>ne.type==="receivable").reduce((ne,oe)=>ne+oe.amount,0),U=C.filter(ne=>ne.type==="payable").reduce((ne,oe)=>ne+oe.amount,0),X=U-Y;return{totalReceivable:Y,totalPayable:U,netAmount:X}},T=async()=>{if(C.length===0){ee.error("Please add at least one line item");return}if(!A){ee.error("Please add final remarks");return}try{m(!0),ee.success("Finance summary submitted successfully"),j(!1),S(null),w([]),I(""),p()}catch{ee.error("Failed to submit summary")}finally{m(!1)}},E=Y=>{const U=String(Y||"").trim().toLowerCase();return U==="paid"||U==="verified"},_=a.filter(Y=>!E(Y.paymentStatus)),M=a.filter(Y=>E(Y.paymentStatus)),q=c.filter(Y=>Y.status==="Initiated"||Y.status==="Calculated"),G=c.filter(Y=>Y.status==="Completed"||Y.status==="Cleared"),Z=()=>{if(!R.department||!R.description||!R.amount){ee.error("Please fill in all line item fields");return}const Y={id:Date.now().toString(),department:R.department,description:R.description,type:R.type,amount:parseFloat(R.amount)};w([...C,Y]),P({department:"",description:"",type:"receivable",amount:""}),ee.success("Line item added")},W=Y=>{w(C.filter(U=>U.id!==Y)),ee.info("Line item removed")},{totalReceivable:z,totalPayable:F,netAmount:B}=$();return f?e.jsxs("div",{className:"flex items-center justify-center p-20 text-amber-600",children:[e.jsx(Js,{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-amber-200 bg-amber-50/20",onClick:()=>{h.length>0&&n?n(h[0].applicationId||h[0].id):t==null||t("finance-onboarding")},children:[e.jsxs(tt,{className:"pb-3",children:[e.jsx(Zt,{className:"text-amber-600 font-bold",children:"Pending Audits"}),e.jsx(nt,{className:"text-3xl text-amber-600",children:h.length})]}),e.jsxs(Me,{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-amber-600 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(tt,{className:"pb-3",children:[e.jsx(Zt,{children:"Pending Verification"}),e.jsx(nt,{className:"text-3xl text-yellow-600",children:_.length})]}),e.jsxs(Me,{children:[e.jsx("p",{className:"text-slate-600",children:"Onboarding Payments"}),e.jsx(se,{variant:"link",className:"p-0 h-auto text-amber-600 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(tt,{className:"pb-3",children:[e.jsx(Zt,{children:"Verified"}),e.jsx(nt,{className:"text-3xl text-green-600",children:M.length})]}),e.jsxs(Me,{children:[e.jsx("p",{className:"text-slate-600",children:"Total Validated"}),e.jsx(se,{variant:"link",className:"p-0 h-auto text-amber-600 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(tt,{className:"pb-3",children:[e.jsx(Zt,{children:"Pending F&F Summary"}),e.jsx(nt,{className:"text-3xl text-orange-600",children:q.length})]}),e.jsxs(Me,{children:[e.jsx("p",{className:"text-slate-600",children:"Offboarding Cases"}),e.jsx(se,{variant:"link",className:"p-0 h-auto text-amber-600 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(tt,{className:"pb-3",children:[e.jsx(Zt,{children:"F&F Completed"}),e.jsx(nt,{className:"text-3xl text-green-600",children:G.length})]}),e.jsxs(Me,{children:[e.jsx("p",{className:"text-slate-600",children:"Settlements Done"}),e.jsx(se,{variant:"link",className:"p-0 h-auto text-amber-600 mt-2",children:"View All →"})]})]})]}),e.jsxs(Pn,{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(oa,{className:"w-4 h-4 mr-2"}),"Onboarding"]}),e.jsxs(Wt,{value:"fnf",children:[e.jsx(fs,{className:"w-4 h-4 mr-2"}),"F&F Settlement"]})]}),e.jsx(Gt,{value:"onboarding",className:"space-y-4",children:e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"Payment Verification"}),e.jsx(Zt,{children:"Verify dealer advance payments for onboarding applications"})]}),e.jsx(Me,{children:e.jsxs(Pn,{defaultValue:"pending",className:"w-full",children:[e.jsxs(_n,{children:[e.jsxs(Wt,{value:"pending",children:["Pending (",_.length,")"]}),e.jsxs(Wt,{value:"verified",children:["Verified (",M.length,")"]})]}),e.jsx(Gt,{value:"pending",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[_.map(Y=>{var U,X;return e.jsx(Le,{className:"border-yellow-200 bg-yellow-50/30",children:e.jsx(Me,{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:((U=Y.application)==null?void 0:U.applicationId)||"N/A"}),e.jsx(Ae,{className:"bg-yellow-100 text-yellow-700 border-yellow-300",children:Y.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=Y.application)==null?void 0:X.applicantName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Type"}),e.jsx("p",{children:Y.paymentType==="SECURITY_DEPOSIT"?"Security Deposit":Y.paymentType==="FIRST_FILL"?"First Fill":Y.paymentType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Amount"}),e.jsxs("p",{className:"text-amber-700 font-bold",children:["₹",parseFloat(Y.amount).toLocaleString("en-IN")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Created On"}),e.jsx("p",{children:Ht(Y.createdAt)})]})]})]}),e.jsxs("div",{className:"ml-4 flex flex-col gap-2",children:[e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>{s&&s(Y.applicationId||Y.id)},children:[e.jsx(fs,{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(Y.applicationId||Y.id)},children:[e.jsx(Ys,{className:"w-4 h-4 mr-2"}),"Verify Payment"]})]})]})})},Y.id)}),_.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(Ys,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No pending payment verifications"})]})]})}),e.jsx(Gt,{value:"verified",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:M.map(Y=>{var U,X;return e.jsx(Le,{className:"border-green-200 bg-green-50/30",children:e.jsx(Me,{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:((U=Y.application)==null?void 0:U.applicationId)||"N/A"}),e.jsx(Ae,{className:"bg-green-100 text-green-700 border-green-300",children:Y.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=Y.application)==null?void 0:X.applicantName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Type"}),e.jsx("p",{children:Y.paymentType==="SECURITY_DEPOSIT"?"Security Deposit":Y.paymentType==="FIRST_FILL"?"First Fill":Y.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(Y.amount).toLocaleString("en-IN")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Verified On"}),e.jsx("p",{children:Y.verificationDate?Ht(Y.verificationDate):"N/A"})]})]})]}),e.jsx("div",{className:"ml-4",children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>{s&&s(Y.applicationId||Y.id)},children:[e.jsx(fs,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},Y.id)})})})]})})]})}),e.jsx(Gt,{value:"fnf",className:"space-y-4",children:e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"F&F Financial Summary"}),e.jsx(Zt,{children:"Create financial settlement summaries for resignation and termination cases"})]}),e.jsx(Me,{children:e.jsxs(Pn,{defaultValue:"pending",className:"w-full",children:[e.jsxs(_n,{children:[e.jsxs(Wt,{value:"pending",children:["Pending Summary (",q.length,")"]}),e.jsxs(Wt,{value:"completed",children:["Completed (",G.length,")"]})]}),e.jsx(Gt,{value:"pending",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[q.map(Y=>{var U,X,ne,oe,re,ge,ve;return e.jsx(Le,{className:"border-orange-200 bg-orange-50/30",children:e.jsx(Me,{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:((U=Y.resignation)==null?void 0:U.resignationId)||Y.id}),e.jsx(Ae,{variant:"outline",children:Y.resignation?"Resignation":Y.terminationRequest?"Termination":"General"}),e.jsx(Ae,{className:"bg-orange-100 text-orange-700 border-orange-300",children:Y.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:((ne=(X=Y.outlet)==null?void 0:X.dealer)==null?void 0:ne.fullName)||((oe=Y.outlet)==null?void 0:oe.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:((re=Y.outlet)==null?void 0:re.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:[((ge=Y.outlet)==null?void 0:ge.city)||"N/A",", ",((ve=Y.outlet)==null?void 0:ve.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(Ys,{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:(Y.clearances||[]).filter(Se=>Se.status==="NOC Submitted"||Se.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:()=>{S(Y),y(!0)},children:[e.jsx(fs,{className:"w-4 h-4 mr-2"}),"View Details"]}),e.jsxs(se,{size:"sm",className:"bg-blue-600 hover:bg-blue-700",onClick:()=>{S(Y),w([]),I(""),j(!0)},children:[e.jsx(O2,{className:"w-4 h-4 mr-2"}),"Create Summary"]})]})]})})},Y.id)}),q.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(fs,{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(Gt,{value:"completed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:G.map(Y=>e.jsx(Le,{className:"border-green-200 bg-green-50/30",children:e.jsx(Me,{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:Y.id}),e.jsx(Ae,{variant:"outline",children:Y.type}),e.jsx(Ae,{className:"bg-green-100 text-green-700 border-green-300",children:Y.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:Y.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:Y.dealerCode})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Net Settlement"}),e.jsxs("p",{className:Y.netAmount&&Y.netAmount>=0?"text-green-700":"text-red-700",children:["₹",Y.netAmount?Math.abs(Y.netAmount).toLocaleString("en-IN"):"0"]}),e.jsx("p",{className:"text-xs text-slate-500",children:Y.netAmount&&Y.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:Y.completedOn})]})]})]}),e.jsx("div",{className:"ml-4",children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>{r&&r(Y.id)},children:[e.jsx(fs,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},Y.id))})})]})})]})})]}),e.jsx(os,{open:u,onOpenChange:j,children:e.jsxs(ls,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Create Financial Settlement Summary"}),e.jsxs(vs,{children:[((D=N==null?void 0:N.resignation)==null?void 0:D.resignationId)||(N==null?void 0:N.id)," - ",N==null?void 0:N.dealerName," (",N==null?void 0:N.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(ce,{className:"text-xs",children:"Department"}),e.jsx(ot,{placeholder:"e.g., Warranty",value:R.department,onChange:Y=>P({...R,department:Y.target.value})})]}),e.jsxs("div",{className:"col-span-4",children:[e.jsx(ce,{className:"text-xs",children:"Description"}),e.jsx(ot,{placeholder:"e.g., Pending warranty claims",value:R.description,onChange:Y=>P({...R,description:Y.target.value})})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(ce,{className:"text-xs",children:"Type"}),e.jsxs(wt,{value:R.type,onValueChange:Y=>P({...R,type:Y}),children:[e.jsx(Ct,{children:e.jsx(St,{})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"receivable",children:"Receivable"}),e.jsx(Pe,{value:"payable",children:"Payable"})]})]})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(ce,{className:"text-xs",children:"Amount (₹)"}),e.jsx(ot,{type:"number",placeholder:"0",value:R.amount,onChange:Y=>P({...R,amount:Y.target.value})})]}),e.jsx("div",{className:"col-span-1 flex items-end",children:e.jsx(se,{size:"sm",onClick:Z,className:"w-full bg-amber-600 hover:bg-amber-700",children:e.jsx(cn,{className:"w-4 h-4"})})})]})]}),C.length>0&&e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Department"}),e.jsx(me,{children:"Description"}),e.jsx(me,{className:"text-center",children:"Type"}),e.jsx(me,{className:"text-right",children:"Amount"}),e.jsx(me,{className:"w-16"})]})}),e.jsx(Es,{children:C.map(Y=>e.jsxs(ct,{children:[e.jsx(de,{children:Y.department}),e.jsx(de,{children:Y.description}),e.jsx(de,{className:"text-center",children:e.jsx(Ae,{className:Y.type==="receivable"?"bg-red-100 text-red-700 border-red-200":"bg-green-100 text-green-700 border-green-200",children:Y.type==="receivable"?"Receivable":"Payable"})}),e.jsxs(de,{className:`text-right font-medium ${Y.type==="receivable"?"text-red-700":"text-green-700"}`,children:["₹",Y.amount.toLocaleString("en-IN")]}),e.jsx(de,{children:e.jsx(se,{size:"sm",variant:"ghost",onClick:()=>W(Y.id),children:e.jsx(Gn,{className:"w-4 h-4 text-red-600"})})})]},Y.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:["₹",F.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:["₹",z.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 ${B>=0?"text-green-400":"text-red-400"}`,children:["₹",Math.abs(B).toLocaleString("en-IN")]}),e.jsx("p",{className:"text-xs text-slate-400 mt-1 italic",children:B>=0?"Payable to Dealer":"Receivable from Dealer"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ce,{className:"font-bold",children:["Summary Remarks ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Fs,{placeholder:"Add your final reconciliation remarks here...",rows:4,value:A,onChange:Y=>I(Y.target.value)})]})]}),e.jsxs(rn,{className:"border-t pt-4",children:[e.jsx(se,{variant:"outline",onClick:()=>j(!1),children:"Discard"}),e.jsxs(se,{className:"bg-green-600 hover:bg-green-700",onClick:T,disabled:C.length===0,children:[e.jsx(Yi,{className:"w-4 h-4 mr-2"}),"Finalize & Submit Summary"]})]})]})}),e.jsx(os,{open:g,onOpenChange:y,children:e.jsxs(ls,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Full Settlement Details"}),e.jsxs(vs,{children:[((O=N==null?void 0:N.resignation)==null?void 0:O.resignationId)||(N==null?void 0:N.id)," - ",N==null?void 0:N.dealerName]})]}),N&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Le,{className:"bg-slate-50 border-none",children:e.jsxs(Me,{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:((V=N.outlet)==null?void 0:V.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:((K=N.outlet)==null?void 0:K.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(Ae,{variant:"outline",className:"bg-amber-100 text-amber-700 border-amber-200",children:N.status})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Le,{className:"border-blue-100",children:[e.jsx(tt,{className:"bg-blue-50/50 pb-2",children:e.jsxs(nt,{className:"text-sm font-bold flex items-center gap-2",children:[e.jsx(Wi,{className:"w-4 h-4 text-blue-600"}),"Receivables Check"]})}),e.jsxs(Me,{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(N.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(N.totalPayables||0).toLocaleString("en-IN")]})]})]})]}),e.jsxs(Le,{className:"border-red-100 shadow-sm",children:[e.jsx(tt,{className:"bg-red-50/30 pb-2 border-b border-red-50",children:e.jsxs(nt,{className:"text-sm font-bold flex items-center gap-2 text-red-700",children:[e.jsx(Po,{className:"w-4 h-4"}),"Receivables Check"]})}),e.jsxs(Me,{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(N.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(N.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(N.netAmount||0)>=0?"bg-emerald-500/20":"bg-rose-500/20"}`,children:e.jsx(oa,{className:`w-6 h-6 ${parseFloat(N.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(N.netAmount||0)>=0?"text-emerald-400":"text-rose-400"}`,children:["₹",Math.abs(parseFloat(N.netAmount||0)).toLocaleString("en-IN")]}),e.jsxs("span",{className:"text-xs font-medium text-slate-400",children:["(",parseFloat(N.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(rn,{children:e.jsx(se,{onClick:()=>y(!1),children:"Close Overview"})})]})})]})}const Il={getDashboardData:async()=>{var t;try{const s=await Te.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 Te.getConstitutionalChanges()).data}catch(t){throw console.error("Get constitutional changes error:",t),t}},submitConstitutionalChange:async t=>{try{return(await Te.createConstitutionalChange(t)).data}catch(s){throw console.error("Submit constitutional change error:",s),s}},getRelocationRequests:async()=>{try{return(await Te.getRelocationRequests()).data}catch(t){throw console.error("Get relocation requests error:",t),t}},submitRelocationRequest:async t=>{try{return(await Te.createRelocationRequest(t)).data}catch(s){throw console.error("Submit relocation request error:",s),s}}};function YB({currentUser:t,onNavigate:s}){var u,j;const[n,r]=v.useState(!0),[a,l]=v.useState(null);if(v.useEffect(()=>{(async()=>{try{const y=await Il.getDashboardData();l(y)}catch(y){console.error("Failed to fetch dashboard:",y)}finally{r(!1)}})()},[]),n)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px]",children:[e.jsx(ss,{className:"w-10 h-10 text-amber-600 animate-spin mb-4"}),e.jsx("p",{className:"text-slate-600",children:"Loading your dashboard..."})]});const c=a||{},d=c.profile||{},h=c.stats||{constitutional:0,relocation:0,total:0},x=c.recentRequests||[],f=((u=c.outlets)==null?void 0:u[0])||{},m=[{title:"Constitutional Changes",value:h.constitutional,icon:Ki,color:"bg-blue-500",change:"Active Requests",onClick:()=>s("dealer-constitutional")},{title:"Relocation Requests",value:h.relocation,icon:Er,color:"bg-amber-500",change:"Active Requests",onClick:()=>s("dealer-relocation")},{title:"My Outlets",value:((j=c.outlets)==null?void 0:j.length)||0,icon:cI,color:"bg-purple-500",change:"Registered",onClick:()=>{}},{title:"Total Requests",value:h.total,icon:Wi,color:"bg-green-500",change:"All time",onClick:()=>{}}],p=[{title:"Constitutional Change",description:"Request change in business structure",icon:Ki,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:Er,color:"bg-amber-50 hover:bg-amber-100 border-amber-200",textColor:"text-amber-700",onClick:()=>s("dealer-relocation")}];return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-gradient-to-r from-amber-500 to-amber-600 rounded-lg 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-amber-100",children:["Dealer Code: ",d.dealerCode," • ",d.businessName]}),e.jsxs("p",{className:"text-amber-100 text-sm mt-1",children:[f.name," • ",f.location]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-white",children:"Active Dealership"}),e.jsxs(Ae,{className:"bg-green-500 text-white border-0 mt-2",children:[e.jsx(Ys,{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:m.map((g,y)=>{const N=g.icon;return e.jsxs(Le,{className:"cursor-pointer hover:shadow-lg transition-shadow",onClick:g.onClick,children:[e.jsxs(tt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(nt,{className:"text-sm",children:g.title}),e.jsx("div",{className:`${g.color} p-2 rounded-lg`,children:e.jsx(N,{className:"h-4 w-4 text-white"})})]}),e.jsxs(Me,{children:[e.jsx("div",{className:"text-slate-900 text-2xl",children:g.value}),e.jsx("p",{className:"text-xs text-slate-600 mt-1",children:g.change})]})]},y)})}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"Quick Actions"}),e.jsx(Zt,{children:"Submit new requests and manage your dealership"})]}),e.jsx(Me,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:p.map((g,y)=>{const N=g.icon;return e.jsx("button",{onClick:g.onClick,className:`${g.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:`${g.textColor} p-2 bg-white rounded-lg`,children:e.jsx(N,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:`${g.textColor} mb-1`,children:g.title}),e.jsx("p",{className:"text-slate-600 text-sm",children:g.description})]})]})},y)})})})]}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"My Recent Requests"}),e.jsx(Zt,{children:"Track the status of your submitted requests"})]}),e.jsx(Me,{children:e.jsx("div",{className:"space-y-3",children:x.map(g=>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:g.id}),e.jsx(Ae,{variant:"outline",className:"text-xs",children:g.type})]}),e.jsx("p",{className:"text-slate-600 text-sm",children:g.title}),e.jsxs("p",{className:"text-slate-500 text-xs mt-1",children:["Submitted on ",g.date]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ae,{className:`border ${g.color}`,children:g.status}),e.jsx(se,{variant:"ghost",size:"sm",children:"View"})]})]},g.id))})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsxs(nt,{className:"flex items-center gap-2",children:[e.jsx(Js,{className:"w-5 h-5 text-amber-600"}),"Important Reminders"]})}),e.jsx(Me,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ks,{className:"w-4 h-4 text-amber-600 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(Ks,{className:"w-4 h-4 text-amber-600 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(Ys,{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(tt,{children:e.jsxs(nt,{className:"flex items-center gap-2",children:[e.jsx(da,{className:"w-5 h-5 text-blue-600"}),"Support & Help"]})}),e.jsx(Me,{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 ZB({id:t,onBack:s}){var M,q;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]=v.useState(null),[l,c]=v.useState(!0),[d,h]=v.useState([]),[x,f]=v.useState(""),[m,p]=v.useState(null),[u,j]=v.useState(!1),[g,y]=v.useState(!1),N={panNumber:"",gstNumber:"",registeredAddress:"",bankName:"",accountNumber:"",ifscCode:"",branchName:"",accountHolderName:""},[S,C]=v.useState(N),[w,R]=v.useState(N),P=JSON.stringify(S)!==JSON.stringify(w),A=new Set(d.map(G=>String(G.documentType||"").trim().toLowerCase())),I=x?A.has(x.toLowerCase()):!1;v.useEffect(()=>{$()},[t]);const $=async()=>{var G,Z;c(!0);try{const[W,z]=await Promise.all([Te.getApplicationById(t),Te.getDocuments(t)]);if((G=W.data)!=null&&G.success){const F=W.data.data,B={panNumber:F.panNumber||"",gstNumber:F.gstNumber||"",registeredAddress:F.registeredAddress||F.address||"",bankName:F.bankName||"",accountNumber:F.accountNumber||"",ifscCode:F.ifscCode||"",branchName:F.branchName||"",accountHolderName:F.accountHolderName||F.applicantName||""};a(F),C(B),R(B)}((Z=z.data)!=null&&Z.success||z.ok)&&h(z.data.data||[])}catch(W){console.error("Failed to fetch details:",W),ee.error("Failed to load application details")}finally{c(!1)}},T=async()=>{var G;y(!0);try{console.log("Saving business details for:",t,S);const Z=await Te.updateApplication(t,S);if(Z.ok)ee.success("Business details saved successfully"),await $();else{const W=((G=Z.data)==null?void 0:G.message)||"Failed to update business details";ee.error(W),console.error("Update failed:",Z)}}catch(Z){console.error("Save details fatal error:",Z),ee.error(Z.message||"A network error occurred while saving")}finally{y(!1)}},E=G=>{G.target.files&&G.target.files[0]&&p(G.target.files[0])},_=async()=>{var Z,W,z;if(!m||!x){ee.error("Please select a document type and file");return}const G=new FormData;G.append("file",m),G.append("documentType",x),j(!0);try{const F=await Te.uploadDocument(t,G);if((Z=F.data)!=null&&Z.success||F.ok){ee.success("Document uploaded successfully"),p(null),f("");const B=document.getElementById("file-upload");B&&(B.value="");const D=await Te.getDocuments(t);((W=D.data)!=null&&W.success||D.ok)&&h(D.data.data||[])}else ee.error(((z=F.data)==null?void 0:z.message)||"Upload failed")}catch(F){console.error("Upload error:",F),ee.error("Upload failed")}finally{j(!1)}};return l?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(Rr,{className:"w-8 h-8 animate-spin text-amber-600"})}):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(qc,{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.jsxs("div",{className:"flex items-center justify-between 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(Xa,{className:"w-5 h-5 text-amber-600"})," Application Summary"]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold tracking-widest",children:"Current Stage"}),e.jsx("span",{className:"bg-amber-100 text-amber-700 px-3 py-1 rounded-full text-xs font-bold uppercase tracking-wide","data-testid":"onboarding-prospective-details-current-stage",children:r.currentStage||r.overallStatus})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 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(kr,{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-amber-50 rounded-lg",children:e.jsx(Er,{className:"w-4 h-4 text-amber-600"})}),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(Dc,{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(Js,{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.jsxs("div",{className:"bg-slate-50 rounded-xl p-4 flex flex-col justify-center border border-slate-100","data-testid":"onboarding-prospective-details-progress-card",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("p",{className:"text-xs font-bold text-slate-700 uppercase tracking-tight",children:"Onboarding Progress"}),e.jsxs("p",{className:"text-xs font-black text-amber-600",children:[r.progressPercentage||0,"%"]})]}),e.jsx("div",{className:"w-full bg-slate-200 rounded-full h-2 shadow-inner",children:e.jsx("div",{className:"bg-amber-500 h-2 rounded-full transition-all duration-1000 ease-out shadow-sm",style:{width:`${r.progressPercentage||0}%`}})}),((q=(M=r.statusHistory)==null?void 0:M[0])==null?void 0:q.changeReason)&&e.jsxs("p",{className:"mt-3 text-[11px] text-slate-600 italic leading-relaxed border-l-2 border-amber-300 pl-2",children:['"',r.statusHistory[0].changeReason,'"']})]})]})]}),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(mu,{className:"w-4 h-4 text-amber-400"})," Statutory & Bank Details"]}),e.jsxs("button",{onClick:T,disabled:g,className:`text-xs text-white px-3 py-1 rounded font-bold transition-all flex items-center gap-1 disabled:opacity-50 ${P?"bg-emerald-600 hover:bg-emerald-700 ring-2 ring-emerald-300 animate-pulse":"bg-amber-600 hover:bg-amber-700"}`,"data-testid":"onboarding-prospective-details-save-statutory-btn",children:[g?e.jsx(Rr,{className:"w-3 h-3 animate-spin"}):e.jsx(Fn,{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-amber-500 outline-none transition-all",value:S.accountHolderName,onChange:G=>C({...S,accountHolderName:G.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-amber-500 outline-none transition-all uppercase",value:S.panNumber,onChange:G=>C({...S,panNumber:G.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-amber-500 outline-none transition-all uppercase",value:S.gstNumber,onChange:G=>C({...S,gstNumber:G.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-amber-500 outline-none transition-all",value:S.registeredAddress,onChange:G=>C({...S,registeredAddress:G.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(F2,{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-amber-500 outline-none transition-all",value:S.bankName,onChange:G=>C({...S,bankName:G.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-amber-500 outline-none transition-all",value:S.accountNumber,onChange:G=>C({...S,accountNumber:G.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-amber-500 outline-none transition-all uppercase",value:S.ifscCode,onChange:G=>C({...S,ifscCode:G.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-amber-500 outline-none transition-all",value:S.branchName,onChange:G=>C({...S,branchName:G.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(Dr,{className:"w-4 h-4 text-blue-600"})," 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"}),x&&e.jsx("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-bold ${I?"bg-blue-100 text-blue-700":"bg-amber-100 text-amber-700"}`,children:I?"Already uploaded":"Pending upload"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Fn,{className:`pointer-events-none absolute left-3 top-1/2 z-10 h-4 w-4 -translate-y-1/2 ${I?"text-green-600":"text-slate-300"}`}),e.jsxs(wt,{value:x,onValueChange:f,disabled:u,children:[e.jsx(Ct,{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-amber-300 focus:ring-2 focus:ring-amber-500","data-testid":"onboarding-prospective-details-doc-type-select",children:e.jsx(St,{placeholder:"Choose document type"})}),e.jsx(At,{className:"rounded-xl border-slate-200 shadow-lg","data-testid":"onboarding-prospective-details-doc-type-content",children:n.map(G=>{const Z=A.has(G.toLowerCase());return e.jsx(Pe,{value:G,className:"rounded-lg px-3 py-2 text-sm text-slate-700 focus:bg-amber-50 focus:text-slate-900","data-testid":`onboarding-prospective-details-doc-type-item-${G.replace(/\s+/g,"-").toLowerCase()}`,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Fn,{className:`h-4 w-4 ${Z?"text-green-600":"text-slate-300"}`}),G]})},G)})})]})]})]}),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-amber-50 file:text-amber-700 hover:file:bg-amber-100",onChange:E,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:_,disabled:!m||!x||u,className:"bg-blue-600 text-white px-5 py-2 rounded-md hover:bg-blue-700 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(Rr,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Dr,{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(vm,{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((G,Z)=>e.jsxs("div",{className:"flex justify-between items-center p-3 border border-slate-100 rounded-xl bg-slate-50 group hover:border-amber-200 transition-all","data-testid":`onboarding-prospective-details-doc-item-${Z}`,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(vm,{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-${Z}`,children:G.documentType}),e.jsx("p",{className:"text-[10px] text-slate-400 truncate w-32",children:G.fileName})]})]}),e.jsx("span",{className:`text-[9px] px-2 py-0.5 rounded-full font-black uppercase tracking-tighter ${G.status==="Approved"?"bg-green-100 text-green-700":"bg-amber-100 text-amber-700"}`,"data-testid":`onboarding-prospective-details-doc-status-${Z}`,children:G.status||"Pending"})]},G.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(Xa,{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-amber-600 text-white px-4 py-2 rounded-md hover:bg-amber-700",children:"Go Back"})]})}function QB(){var h;const t=su(),s=qn(),{user:n}=Nn(x=>x.auth),[r,a]=v.useState(!1),[l,c]=v.useState("applicant"),d=()=>{t(e2()),ee.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 ${r?"w-20":"w-64"}`,children:[e.jsx("div",{className:"p-4 border-b border-slate-800",children:e.jsxs("div",{className:"flex items-center justify-between",children:[!r&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-10 h-10 bg-amber-600 rounded-lg flex items-center justify-center",children:e.jsx(fs,{className:"w-6 h-6 text-white"})}),e.jsx("span",{className:"text-amber-600 font-bold",children:"Applicant Portal"})]}),e.jsx("button",{onClick:()=>a(!r),className:"p-1 hover:bg-slate-800 rounded transition-colors",children:r?e.jsx(el,{className:"w-5 h-5"}):e.jsx(qc,{className:"w-5 h-5"})})]})}),e.jsx("nav",{className:"flex-1 p-4 space-y-2",children:e.jsx("div",{children:e.jsxs("button",{onClick:()=>{c("applicant"),s("/prospective-dashboard")},className:`w-full flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${l==="applicant"?"bg-amber-600 text-white":"text-slate-300 hover:bg-slate-800 hover:text-white"}`,children:[e.jsx(fs,{className:"w-5 h-5 flex-shrink-0"}),!r&&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:[!r&&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-amber-600 rounded-full flex items-center justify-center text-white",children:e.jsx("span",{className:"font-bold",children:((h=n==null?void 0:n.name)==null?void 0:h.charAt(0))||"A"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:(n==null?void 0:n.name)||"Applicant"}),e.jsx("p",{className:"text-slate-400 truncate text-xs",children:(n==null?void 0:n.role)||"Prospective"})]})]})}),e.jsxs("button",{onClick:d,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 ${r?"justify-center":"justify-start"}`,children:[e.jsx($2,{className:"w-5 h-5 flex-shrink-0"}),!r&&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:"Applicant Management"}),e.jsx("p",{className:"text-slate-600 text-sm",children:"Manage and track dealership applications"})]}),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-amber-600 rounded-full flex items-center justify-center",children:e.jsx(kr,{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==null?void 0:n.name)||"Applicant"}),e.jsx("p",{className:"text-slate-600 text-xs",children:(n==null?void 0:n.role)||"User"})]})]}),e.jsx("button",{className:"p-2 rounded-md hover:bg-slate-100",title:"Refresh",onClick:()=>window.location.reload(),children:e.jsx(Rr,{className:"w-4 h-4 text-slate-600"})})]})]})}),e.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:e.jsxs(Q0,{children:[e.jsx(Ns,{path:"/",element:e.jsx(XB,{})}),e.jsx(Ns,{path:"/application/:id",element:e.jsx(JB,{})})]})})]})]})}function XB(){const t=qn(),{user:s}=Nn(l=>l.auth),[n,r]=v.useState([]);v.useEffect(()=>{s!=null&&s.id&&a()},[s==null?void 0:s.id]);const a=async()=>{var l;try{const c=await Te.getApplications();(l=c.data)!=null&&l.success&&r(c.data.data)}catch(c){console.error("Failed to fetch applications",c)}};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(fs,{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(l=>e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 p-6 shadow-sm hover:shadow-md hover:border-amber-500 cursor-pointer transition-all group",onClick:()=>t(`/prospective-dashboard/application/${l.id}`),children:[e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsx("div",{className:"w-12 h-12 bg-amber-50 rounded-xl flex items-center justify-center group-hover:bg-amber-600 transition-colors",children:e.jsx(fs,{className:"w-6 h-6 text-amber-600 group-hover:text-white"})}),e.jsx(Ae,{className:`px-4 py-1.5 rounded-xl text-[10px] uppercase font-bold ${l.overallStatus==="Completed"?"bg-green-100 text-green-700":l.overallStatus==="Rejected"?"bg-red-100 text-red-700":"bg-amber-100 text-amber-700"}`,children:l.overallStatus||"Active"})]}),e.jsx("h3",{className:"text-xl font-bold text-slate-900 mb-1 truncate",children:l.applicationId}),e.jsxs("p",{className:"text-slate-500 text-sm mb-4 font-medium",children:[l.city,", ",l.state]}),e.jsxs("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:"Current Stage"}),e.jsx("span",{className:"text-xs font-bold text-slate-900 bg-slate-100 px-3 py-1 rounded-lg",children:l.currentStage||"Initial"})]}),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:Ht(l.createdAt)})]}),e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider",children:"Progress"}),e.jsxs("span",{className:"text-xs font-bold text-amber-600",children:[l.progressPercentage||0,"%"]})]}),e.jsx("div",{className:"w-full bg-slate-100 rounded-full h-2",children:e.jsx("div",{className:"bg-amber-500 h-2 rounded-full transition-all duration-1000",style:{width:`${l.progressPercentage||0}%`}})})]})]})]},l.id))})]})})}function JB(){const{id:t}=Bc(),s=qn();return t?e.jsx("div",{className:"max-w-7xl mx-auto",children:e.jsx(ZB,{id:t,onBack:()=>s("/prospective-dashboard")})}):null}function e7(){const t=qn(),[s,n]=v.useState([]),[r,a]=v.useState(!0),[l,c]=v.useState("");v.useEffect(()=>{d()},[]);const d=async()=>{var x;a(!0);try{const f=await Te.getApplications();(x=f.data)!=null&&x.success&&n(f.data.data)}catch(f){console.error("Failed to fetch FDD applications:",f),ee.error("Failed to load assigned applications")}finally{a(!1)}},h=s.filter(x=>{var f;return x.applicationId.toLowerCase().includes(l.toLowerCase())||x.applicantName.toLowerCase().includes(l.toLowerCase())||((f=x.city)==null?void 0:f.toLowerCase().includes(l.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(Rr,{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(Me,{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(fs,{className:"w-5 h-5"})})]})})}),e.jsx(Le,{className:"bg-white border-slate-200 shadow-sm",children:e.jsx(Me,{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(x=>x.currentStage==="FDD"||x.overallStatus==="Active").length})]}),e.jsx("div",{className:"p-2 bg-slate-100 rounded-lg text-slate-600",children:e.jsx(Js,{className:"w-5 h-5"})})]})})}),e.jsx(Le,{className:"bg-white border-slate-200 shadow-sm",children:e.jsx(Me,{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(Fn,{className:"w-5 h-5"})})]})})})]}),e.jsxs(Le,{className:"shadow-sm border-slate-200 overflow-hidden",children:[e.jsxs(tt,{className:"bg-white border-b border-slate-100 px-6 py-4 flex flex-row items-center justify-between",children:[e.jsxs(nt,{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(fs,{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(Ra,{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:l,onChange:x=>c(x.target.value)})]}),e.jsx("button",{className:"p-2 border border-slate-200 rounded-lg hover:bg-slate-50 transition-colors",children:e.jsx(I2,{className:"w-4 h-4 text-slate-600"})})]})]}),e.jsx(Me,{className:"p-0",children:r?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-6",children:[e.jsx(Rr,{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..."})]}):h.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(Ks,{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",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:h.map(x=>e.jsxs("tr",{className:"hover:bg-slate-50 transition-colors cursor-pointer group",onClick:()=>t(`/fdd-details/${x.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:x.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:x.applicationId}),e.jsx("p",{className:"text-xs text-slate-500",children:x.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:[x.city,", ",x.state]}),e.jsx("p",{className:"text-xs text-slate-400 capitalize",children:x.locationType||"New Market"})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx(Ae,{className:`px-3 py-1 rounded-full text-[10px] uppercase font-bold tracking-wider ${x.overallStatus==="Completed"?"bg-green-100 text-green-700":"bg-amber-100 text-amber-700"}`,children:x.overallStatus==="Active"?"FDD Pending":x.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(To,{className:"w-5 h-5"})})})]},x.id))})]})})})]})]})}const t7="modulepreload",s7=function(t){return"/"+t},e1={},Tl=function(s,n,r){let a=Promise.resolve();if(n&&n.length>0){let c=function(x){return Promise.all(x.map(f=>Promise.resolve(f).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),h=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));a=c(n.map(x=>{if(x=s7(x),x in e1)return;e1[x]=!0;const f=x.endsWith(".css"),m=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${x}"]${m}`))return;const p=document.createElement("link");if(p.rel=f?"stylesheet":t7,f||(p.as="script"),p.crossOrigin="",p.href=x,h&&p.setAttribute("nonce",h),document.head.appendChild(p),f)return new Promise((u,j)=>{p.addEventListener("load",u),p.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${x}`)))})}))}function l(c){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=c,window.dispatchEvent(d),!d.defaultPrevented)throw c}return a.then(c=>{for(const d of c||[])d.status==="rejected"&&l(d.reason);return s().catch(l)})};function n7(t,s=[]){let n=[];function r(l,c){const d=v.createContext(c);d.displayName=l+"Context";const h=n.length;n=[...n,c];const x=m=>{var N;const{scope:p,children:u,...j}=m,g=((N=p==null?void 0:p[t])==null?void 0:N[h])||d,y=v.useMemo(()=>j,Object.values(j));return e.jsx(g.Provider,{value:y,children:u})};x.displayName=l+"Provider";function f(m,p){var g;const u=((g=p==null?void 0:p[t])==null?void 0:g[h])||d,j=v.useContext(u);if(j)return j;if(c!==void 0)return c;throw new Error(`\`${m}\` must be used within \`${l}\``)}return[x,f]}const a=()=>{const l=n.map(c=>v.createContext(c));return function(d){const h=(d==null?void 0:d[t])||l;return v.useMemo(()=>({[`__scope${t}`]:{...d,[t]:h}}),[d,h])}};return a.scopeName=t,[r,r7(a,...s)]}function r7(...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(l){const c=r.reduce((d,{useScope:h,scopeName:x})=>{const m=h(l)[`__scope${x}`];return{...d,...m}},{});return v.useMemo(()=>({[`__scope${s.scopeName}`]:c}),[c])}};return n.scopeName=s.scopeName,n}var a7=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Lb=a7.reduce((t,s)=>{const n=hu(`Primitive.${s}`),r=v.forwardRef((a,l)=>{const{asChild:c,...d}=a,h=c?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(h,{...d,ref:l})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),Vx={exports:{}},Hx={};/**
* @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 t1;function i7(){if(t1)return Hx;t1=1;var t=Lc();function s(m,p){return m===p&&(m!==0||1/m===1/p)||m!==m&&p!==p}var n=typeof Object.is=="function"?Object.is:s,r=t.useState,a=t.useEffect,l=t.useLayoutEffect,c=t.useDebugValue;function d(m,p){var u=p(),j=r({inst:{value:u,getSnapshot:p}}),g=j[0].inst,y=j[1];return l(function(){g.value=u,g.getSnapshot=p,h(g)&&y({inst:g})},[m,u,p]),a(function(){return h(g)&&y({inst:g}),m(function(){h(g)&&y({inst:g})})},[m]),c(u),u}function h(m){var p=m.getSnapshot;m=m.value;try{var u=p();return!n(m,u)}catch{return!0}}function x(m,p){return p()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?x:d;return Hx.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,Hx}var s1;function l7(){return s1||(s1=1,Vx.exports=i7()),Vx.exports}var o7=l7();function c7(){return o7.useSyncExternalStore(d7,()=>!0,()=>!1)}function d7(){return()=>{}}var Mb="Avatar",[u7]=n7(Mb),[h7,XR]=u7(Mb),JR=v.forwardRef((t,s)=>{const{__scopeAvatar:n,...r}=t,[a,l]=v.useState("idle");return e.jsx(h7,{scope:n,imageLoadingStatus:a,onImageLoadingStatusChange:l,children:e.jsx(Lb.span,{...r,ref:s})})});JR.displayName=Mb;var eE="AvatarImage",m7=v.forwardRef((t,s)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:a=()=>{},...l}=t,c=XR(eE,n),d=f7(r,l),h=dr(x=>{a(x),c.onImageLoadingStatusChange(x)});return Zn(()=>{d!=="idle"&&h(d)},[d,h]),d==="loaded"?e.jsx(Lb.img,{...l,ref:s,src:r}):null});m7.displayName=eE;var tE="AvatarFallback",sE=v.forwardRef((t,s)=>{const{__scopeAvatar:n,delayMs:r,...a}=t,l=XR(tE,n),[c,d]=v.useState(r===void 0);return v.useEffect(()=>{if(r!==void 0){const h=window.setTimeout(()=>d(!0),r);return()=>window.clearTimeout(h)}},[r]),c&&l.imageLoadingStatus!=="loaded"?e.jsx(Lb.span,{...a,ref:s}):null});sE.displayName=tE;function n1(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function f7(t,{referrerPolicy:s,crossOrigin:n}){const r=c7(),a=v.useRef(null),l=r?(a.current||(a.current=new window.Image),a.current):null,[c,d]=v.useState(()=>n1(l,t));return Zn(()=>{d(n1(l,t))},[l,t]),Zn(()=>{const h=m=>()=>{d(m)};if(!l)return;const x=h("loaded"),f=h("error");return l.addEventListener("load",x),l.addEventListener("error",f),s&&(l.referrerPolicy=s),typeof n=="string"&&(l.crossOrigin=n),()=>{l.removeEventListener("load",x),l.removeEventListener("error",f)}},[l,n,s]),c}var p7=JR,x7=sE;function Fh({className:t,...s}){return e.jsx(p7,{"data-slot":"avatar",className:Pt("relative flex size-10 shrink-0 overflow-hidden rounded-full",t),...s})}function Bh({className:t,...s}){return e.jsx(x7,{"data-slot":"avatar-fallback",className:Pt("bg-muted flex size-full items-center justify-center rounded-full",t),...s})}const $h="/collaboration",qh={getWorknotes:async(t,s)=>(await ze.get(`${$h}/worknotes`,{requestId:t,requestType:s})).data,addWorknote:async t=>(await ze.post(`${$h}/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 ze.post(`${$h}/upload`,r,{headers:{"Content-Type":"multipart/form-data"}})).data},revokeParticipant:async(t,s)=>(await ze.delete(`${$h}/participants/${t}`,{data:{reason:s}})).data},Cd=t=>[...t].sort((s,n)=>new Date(s.createdAt).getTime()-new Date(n.createdAt).getTime()),Wx=t=>{var s,n,r,a,l;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)||((l=t==null?void 0:t.author)==null?void 0:l.roleCode)||"")}},g7=new Set(["internal","workflow","system","audit","status"]),v7=t=>g7.has(String(t.noteType||"").toLowerCase()),b7=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"},y7=t=>{const s=String(t.noteType||"").toLowerCase();return s==="internal"?"APPROVAL":s==="workflow"?"WORKFLOW":s==="system"?"SYSTEM":s==="audit"?"AUDIT":s==="status"?"STATUS":"ACTIVITY"},r1=t=>t?new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}):"",bc="https://dealeronboarding-uat.royalenfield.com/api".replace("/api","")||"http://localhost:5000";function nE(t){var Cs,Bs,Ft,ie,Fe;const{user:s}=Nn(Q=>Q.auth),{id:n,type:r}=Bc(),a=Ul(),l=qn(),c=t.requestId||n||"",d=t.requestType||r||((Cs=a.state)==null?void 0:Cs.requestType)||"application",h=t.mode||((Bs=a.state)==null?void 0:Bs.mode)||"page",[x,f]=v.useState(t.applicationName||((Ft=a.state)==null?void 0:Ft.applicationName)||"Application"),[m,p]=v.useState(t.registrationNumber||((ie=a.state)==null?void 0:ie.registrationNumber)||""),u=t.onBack||(()=>l(-1)),j=t.participants||((Fe=a.state)==null?void 0:Fe.participants)||[],[g,y]=v.useState(j),[N,S]=v.useState([]),[C,w]=v.useState(""),[R,P]=v.useState(!1),[A,I]=v.useState(""),[$,T]=v.useState(0),[E,_]=v.useState(!0),[M,q]=v.useState(!1),[G,Z]=v.useState([]),[W,z]=v.useState(!1),[F,B]=v.useState(!0),[D,O]=v.useState(""),[V,K]=v.useState(""),[Y,U]=v.useState(null),[X,ne]=v.useState(""),[oe,re]=v.useState(!1),{socket:ge}=Sk(),ve=v.useRef(null),Se=v.useRef(null),[We,Ce]=v.useState(null),fe=(Q,pe)=>Q.startsWith("image/")&&pe?e.jsx("img",{src:`${bc}/${pe.replace(/\\/g,"/")}`,className:"w-full h-full object-cover rounded",alt:"Thumbnail"}):Q.startsWith("image/")?e.jsx(dw,{className:"w-5 h-5 text-blue-500"}):Q==="application/pdf"?e.jsx(fs,{className:"w-5 h-5 text-red-500"}):e.jsx(vm,{className:"w-5 h-5 text-slate-500"}),Ye=["😊","😂","🤣","❤️","👍","🙏","🔥","✨","😍","🥰","😎","🤔","😅","🙌","👏","🎉","✅","❌","📌","📎","📍","💡","🔔","📢","⭐","🌟","💪","🚀","👀","💯","🌈","☀️","😢","😭","😞","😔","😟","😕","😠","😡","🤬","😤","😲","🙄","🤨","😓","😩","😫","🤐","😴","🤢","🤮","😱","🤡","💀","👻","🤝","👋","✌️","👌","✋","🍎","🍕","☕","💻","📱","⌚","📁","📄","📅","🔒","🔑","🛠️","⚙️","💬","💭","🌊","🍀","✈️","🏠"],be=Q=>Q.split(" ").map(pe=>pe[0]).join("").toUpperCase().substring(0,2),_e=Q=>{const pe=["bg-green-600","bg-blue-600","bg-purple-600","bg-amber-600","bg-pink-600","bg-indigo-600","bg-teal-600"],Ne=Q.length%pe.length;return pe[Ne]},ke=[],qe=new Set;g.forEach(Q=>{var Ee,it,st,bt,Ue,Lt,ut;const pe=((Ee=Q.user)==null?void 0:Ee.id)||Q.userId||"",Ne=Q.id;if(pe&&!qe.has(pe)){qe.add(pe);const yt=((it=Q.user)==null?void 0:it.fullName)||((st=Q.user)==null?void 0:st.name)||Q.fullName||Q.name||"Unknown User",kt=((bt=Q.user)==null?void 0:bt.email)||Q.email||"",Ie=((Ue=Q.user)==null?void 0:Ue.roleCode)||Q.roleCode||((Lt=Q.user)==null?void 0:Lt.role)||Q.role||"Participant";ke.push({id:pe,recordId:Ne,name:yt,email:kt,initials:be(yt),color:_e(yt),role:Ie,isOnline:!1,revokedAt:(ut=Q.metadata)==null?void 0:ut.revokedAt})}});const Ve=async()=>{try{_(!0);const Q=await qh.getWorknotes(c,d);if(Q.success){const pe=Q.data.map(Ne=>({id:Ne.id,noteText:Ne.noteText,noteType:Ne.noteType,createdAt:Ne.createdAt,userId:Ne.userId,author:Ne.author?Wx(Ne):{name:"System",email:"",role:"system"},attachments:Ne.attachments||[]}));S(Cd(pe))}}catch(Q){console.error("Fetch notes error:",Q),ee.error("Failed to load work notes")}finally{_(!1)}};v.useEffect(()=>{if(Ve(),ge)return ge.emit("join_room",c),ge.on("new_worknote",Q=>{const pe={id:Q.id,noteText:Q.noteText,noteType:Q.noteType,createdAt:Q.createdAt,userId:Q.userId,author:Q.author?Wx(Q):{name:"System",email:"",role:"system"},attachments:Q.attachments||[]};S(Ne=>{if(Ne.some(st=>st.id===pe.id))return Ne;const it=Ne.findIndex(st=>{var bt,Ue;return st.id.startsWith("temp-")&&st.noteText===pe.noteText&&((bt=st.author.email)==null?void 0:bt.toLowerCase())===((Ue=pe.author.email)==null?void 0:Ue.toLowerCase())});if(it!==-1){const st=[...Ne];return st[it]=pe,Cd(st)}return Cd([...Ne,pe])})}),()=>{ge.emit("leave_room",c),ge.off("new_worknote")}},[c,d,ge]),v.useEffect(()=>{if(!c||!d)return;(async()=>{var pe,Ne,Ee,it,st,bt,Ue,Lt,ut,yt;try{let kt=null;if(d==="application")kt=await ds.getApplicationById(c),kt&&(g.length===0&&kt.participants&&y(kt.participants),(!x||x==="Application")&&f(kt.companyName||"Application"),m||p(kt.registrationNumber||""));else if(d==="termination"){const{API:Ie}=await Tl(async()=>{const{API:ht}=await Promise.resolve().then(()=>Pd);return{API:ht}},void 0),_t=await Ie.getTerminationById(c);(pe=_t.data)!=null&&pe.success&&(kt=_t.data.termination,g.length===0&&kt.participants&&y(kt.participants),(!x||x==="Application"||x==="Termination")&&f(((Ne=kt.dealer)==null?void 0:Ne.businessName)||"Termination"),m||p(kt.requestId||""))}else if(d==="constitutional"||d==="constitutional-change"){const{API:Ie}=await Tl(async()=>{const{API:ht}=await Promise.resolve().then(()=>Pd);return{API:ht}},void 0),_t=await Ie.getConstitutionalChangeById(c);(Ee=_t.data)!=null&&Ee.success&&(kt=_t.data.request,g.length===0&&kt.participants&&y(kt.participants),(!x||x==="Application"||x==="Constitutional Change")&&f(((it=kt.outlet)==null?void 0:it.name)||"Constitutional Change"),m||p(kt.requestId||""))}else if(d==="resignation"){const{API:Ie}=await Tl(async()=>{const{API:ht}=await Promise.resolve().then(()=>Pd);return{API:ht}},void 0),_t=await Ie.getResignationById(c);(st=_t.data)!=null&&st.success&&(kt=_t.data.resignation,g.length===0&&kt.participants&&y(kt.participants),(!x||x==="Application"||x==="Resignation")&&f(((bt=kt.dealer)==null?void 0:bt.businessName)||"Resignation"),m||p(kt.resignationId||""))}else if(d==="fnf"){const{API:Ie}=await Tl(async()=>{const{API:ht}=await Promise.resolve().then(()=>Pd);return{API:ht}},void 0),_t=await Ie.getFnFSettlementById(c);if((Ue=_t.data)!=null&&Ue.success){kt=_t.data.fnf,g.length===0&&kt.participants&&y(kt.participants||[]);const ht=((ut=(Lt=kt.outlet)==null?void 0:Lt.dealer)==null?void 0:ut.fullName)||((yt=kt.dealer)==null?void 0:yt.fullName)||"F&F Settlement";(!x||x==="Application"||x==="F&F Settlement")&&f(ht),m||p(kt.settlementId||"")}}}catch(kt){console.error(`Failed to fetch ${d} details:`,kt)}})()},[c,d,g.length,x,m]);const dt=v.useRef(null);v.useEffect(()=>{dt.current&&dt.current.scrollIntoView({behavior:"smooth"})},[N]);const xt=Q=>{const pe=Q.target.value,Ne=Q.target.selectionStart||0;w(pe),T(Ne);const Ee=pe.substring(0,Ne),it=Ee.lastIndexOf("@");if(it!==-1&&it===Ee.length-1)P(!0),I("");else if(it!==-1){const st=Ee.substring(it+1);st.includes(" ")?P(!1):(P(!0),I(st))}else P(!1)},ye=Q=>{var bt;const Ne=C.substring(0,$).lastIndexOf("@"),Ee=C.substring($),it=`@${Q.name}`,st=C.substring(0,Ne)+it+" "+Ee;w(st),P(!1),(bt=ve.current)==null||bt.focus()},le=Q=>{var Ee,it;const pe=((Ee=ve.current)==null?void 0:Ee.selectionStart)||C.length,Ne=C.substring(0,pe)+Q+C.substring(pe);w(Ne),q(!1),(it=ve.current)==null||it.focus()},Qe=async Q=>{const pe=Q.target.files;if(!(!pe||pe.length===0)){z(!0);try{for(const Ne of Array.from(pe)){const Ee=await qh.uploadAttachment(Ne,c,d);Ee.success&&Z(it=>[...it,Ee.data])}}catch(Ne){console.error("File upload error:",Ne),ee.error("Failed to upload attachment")}finally{z(!1),Se.current&&(Se.current.value="")}}},rt=Q=>{Z(pe=>pe.filter(Ne=>Ne.id!==Q))},Kt=async()=>{if(!C.trim()&&G.length===0)return;const Q=C,pe=G;w(""),Z([]);let Ne=Q;const Ee=[];ke.forEach(it=>{if(it.id&&it.name){const st=it.name.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),bt=new RegExp(`@${st}\\b`,"gi");Ne.match(bt)&&(Ee.push(it.id),Ne=Ne.replace(bt,`@[${it.name}](user:${it.id})`))}});try{const it=`temp-${Date.now()}`,st={id:it,noteText:Ne,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:pe};S(Ue=>Cd([...Ue,st]));const bt=await qh.addWorknote({requestId:c,requestType:d,noteText:Ne,noteType:"General",tags:Ee,attachmentDocIds:pe.map(Ue=>Ue.id)});if(bt.success&&bt.data){const Ue=bt.data,Lt={id:Ue.id,noteText:Ue.noteText,noteType:Ue.noteType,createdAt:Ue.createdAt,userId:Ue.userId,author:Ue.author?Wx(Ue):{name:"System",email:"",role:"system"},attachments:Ue.attachments||[]};S(ut=>Cd(ut.map(yt=>yt.id===it?Lt:yt)))}}catch(it){console.error("Send message error:",it),ee.error("Failed to send message")}},Rt=Q=>{if(!["DD Lead","DD Head","NBH","DD Admin","Super Admin"].includes((s==null?void 0:s.roleCode)||"")){ee.error("Only authorized roles can revoke participants");return}U(Q),ne("")},Re=async()=>{if(Y){re(!0);try{const Q=await qh.revokeParticipant(Y.recordId,X);Q.success&&(ee.success(Q.message),U(null),y([]))}catch{ee.error("Error revoking participant")}finally{re(!1)}}},Qt=Q=>{Q.key==="Enter"&&!Q.shiftKey&&(Q.preventDefault(),Kt())},qt=Q=>{if(!Q)return"";const pe=/(@\[[^\]]+\]\([^\)]+\))/g;return Q.split(pe).map((Ee,it)=>{const st=Ee.match(/@\[([^\]]+)\]\(([^\)]+)\)/);if(st){const bt=st[1];return e.jsxs("span",{className:"text-blue-600 font-medium hover:underline cursor-pointer",children:["@",bt]},it)}return Ee})},ws=V.trim().toLowerCase(),_s=ws?N.filter(Q=>{var pe;return(Q.noteText||"").toLowerCase().includes(ws)||(((pe=Q.author)==null?void 0:pe.name)||"").toLowerCase().includes(ws)||(Q.noteType||"").toLowerCase().includes(ws)}):N,ns=ke.filter(Q=>{const pe=Q.name.toLowerCase().includes(A.toLowerCase()),Ne=Q.id&&(s==null?void 0:s.id)&&String(Q.id)===String(s.id)||Q.email&&(s==null?void 0:s.email)&&Q.email.toLowerCase()===s.email.toLowerCase();return pe&&!Ne});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($r,{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(zr,{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:x}),e.jsx("span",{className:"text-slate-400",children:"|"}),e.jsx("span",{className:"text-slate-500","data-testid":"onboarding-worknotes-reg-num",children:m})]})]})]}),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:[ke.slice(0,3).map((Q,pe)=>e.jsx(Fh,{className:"w-8 h-8 border-2 border-white ring-1 ring-slate-100","data-testid":`onboarding-worknotes-avatar-${pe}`,children:e.jsx(Bh,{className:`${Q.color} text-white text-[10px]`,children:Q.initials})},pe)),ke.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:["+",ke.length-3]})})]}),e.jsxs(se,{variant:"ghost",size:"sm",onClick:Ve,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:E,"data-testid":"onboarding-worknotes-sync-btn",children:[e.jsx(Ki,{className:`w-4 h-4 ${E?"animate-spin":""}`}),e.jsx("span",{className:"text-xs font-medium hidden md:inline",children:"Sync"})]}),e.jsxs(se,{variant:F?"secondary":"ghost",size:"sm",onClick:()=>B(!F),className:`flex items-center gap-1.5 px-2 h-9 rounded-lg transition-all ${F?"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(da,{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 ${h==="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(Ra,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400 pointer-events-none"}),e.jsx(ot,{type:"search",value:V,onChange:Q=>K(Q.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"})]})}),_s.map((Q,pe)=>{var Ee,it,st,bt,Ue,Lt,ut;if(v7(Q)){const yt=((Ee=Q.author)==null?void 0:Ee.name)||"System",kt=(it=Q.author)!=null&&it.role&&Q.author.role!=="0"&&Q.author.role!==""?Q.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-${pe}`,children:e.jsxs("div",{role:"status",title:b7(Q),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(H5,{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-${pe}`,children:y7(Q)}),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-${pe}`,children:yt}),kt?e.jsxs("span",{className:"text-xs font-normal text-slate-500",children:[" · ",kt]}):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-${pe}`,children:qt(Q.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:Q.createdAt,"data-testid":`onboarding-worknotes-activity-time-${pe}`,children:r1(Q.createdAt)})]})},Q.id)}const Ne=((st=Q==null?void 0:Q.author)==null?void 0:st.email)&&(s==null?void 0:s.email)&&Q.author.email.toLowerCase()===s.email.toLowerCase()||(Q==null?void 0:Q.userId)&&(s==null?void 0:s.id)&&String(Q.userId)===String(s.id)||Q.id.startsWith("temp-");return e.jsx("div",{className:`flex w-full ${Ne?"justify-end":"justify-start"}`,"data-testid":`onboarding-worknotes-message-row-${pe}`,children:e.jsxs("div",{className:`flex gap-3 max-w-[min(85%,36rem)] ${Ne?"flex-row-reverse":""}`,children:[e.jsx(Fh,{className:"w-10 h-10 flex-shrink-0 mt-1","data-testid":`onboarding-worknotes-message-avatar-${pe}`,children:e.jsx(Bh,{className:`${_e(((bt=Q==null?void 0:Q.author)==null?void 0:bt.name)||"System")} text-white`,children:be(((Ue=Q==null?void 0:Q.author)==null?void 0:Ue.name)||"S")})}),e.jsxs("div",{className:`flex flex-col min-w-0 ${Ne?"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 ${Ne?"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-${pe}`,children:Ne?"You":((Lt=Q==null?void 0:Q.author)==null?void 0:Lt.name)||"Unknown"}),e.jsx("span",{className:"text-slate-400 text-[10px] uppercase tracking-wide",children:(ut=Q==null?void 0:Q.author)!=null&&ut.role&&Q.author.role!=="0"&&Q.author.role!==""?`(${Q.author.role})`:""}),e.jsx("span",{className:"text-slate-400 text-[10px] tabular-nums","data-testid":`onboarding-worknotes-message-time-${pe}`,children:r1(Q.createdAt)})]}),e.jsxs("div",{className:`rounded-2xl border px-4 py-2.5 shadow-sm relative text-left ${Ne?"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-${pe}`,children:[e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap break-words","data-testid":`onboarding-worknotes-message-text-${pe}`,children:qt(Q.noteText)}),Q.attachments&&Q.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-${pe}`,children:Q.attachments.map((yt,kt)=>{const Ie=yt.mimeType.startsWith("image/");return e.jsx("div",{className:"flex items-center gap-2","data-testid":`onboarding-worknotes-message-attachment-${pe}-${kt}`,children:Ie?e.jsx("div",{className:"rounded-lg overflow-hidden border border-slate-100 max-w-[200px]",children:e.jsx("img",{src:`${bc}/${yt.filePath.replace(/\\/g,"/")}`,alt:yt.fileName,className:"w-full h-auto cursor-pointer",onClick:()=>Ce(yt),"data-testid":`onboarding-worknotes-message-attachment-img-${pe}-${kt}`})}):yt.mimeType==="application/pdf"?e.jsxs("button",{type:"button",onClick:()=>Ce(yt),className:"flex items-center gap-2 text-xs text-blue-600 hover:underline","data-testid":`onboarding-worknotes-message-attachment-preview-${pe}-${kt}`,children:[e.jsx(qd,{className:"w-3 h-3"}),yt.fileName," (Preview)"]}):e.jsxs("a",{href:`${bc}/${yt.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-${pe}-${kt}`,children:[e.jsx(qd,{className:"w-3 h-3"}),yt.fileName]})},yt.id)})})]})]})]})},Q.id)}),N.length===0&&!E&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center","data-testid":"onboarding-worknotes-empty-state",children:[e.jsx(zr,{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"})]}),N.length>0&&_s.length===0&&!E&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center text-slate-500 text-sm",children:['No messages match "',V.trim(),'". Clear the search box to see the full thread.']}),E&&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:[G.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3 mb-3","data-testid":"onboarding-worknotes-attached-files",children:G.map((Q,pe)=>{const Ne=Q.mimeType.startsWith("image/")||Q.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-${pe}`,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:fe(Q.mimeType,Q.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 ${Ne?"hover:text-blue-600 cursor-pointer hover:underline":""}`,onClick:()=>Ne&&Ce(Q),children:Q.fileName}),e.jsx("button",{onClick:()=>rt(Q.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-${pe}`,children:e.jsx(Tc,{className:"w-3 h-3"})})]})]},Q.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&&ns.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:ns.map((Q,pe)=>e.jsxs("button",{onClick:()=>ye(Q),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-${pe}`,children:[e.jsx(Fh,{className:"w-8 h-8",children:e.jsx(Bh,{className:`${Q.color} text-white text-xs`,children:Q.initials})}),e.jsx("div",{className:"flex flex-col",children:e.jsx("span",{className:"text-slate-900 text-sm font-medium",children:Q.name})})]},Q.id))}),e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx("input",{type:"file",ref:Se,className:"hidden",multiple:!0,onChange:Qe}),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 Q;return(Q=Se.current)==null?void 0:Q.click()},"data-testid":"onboarding-worknotes-attachment-btn",children:e.jsx(qd,{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 ${M?"bg-blue-50 text-blue-600":""}`,onClick:()=>q(!M),"data-testid":"onboarding-worknotes-emoji-btn",children:[e.jsx(hI,{className:"w-5 h-5"}),M&&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:()=>q(!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:Ye.map((Q,pe)=>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:Ne=>{Ne.stopPropagation(),le(Q)},"data-testid":`onboarding-worknotes-emoji-item-${pe}`,children:Q},Q))})]})]}),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 Q;return(Q=Se.current)==null?void 0:Q.click()},children:e.jsx(dw,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 relative",children:e.jsx(ot,{ref:ve,type:"text",placeholder:"Type your message... Use @username to mention someone",value:C,onChange:xt,onKeyPress:Qt,className:"w-full pr-4 border-none focus-visible:ring-0 px-0"})}),e.jsx(se,{onClick:Kt,disabled:!C.trim()&&G.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(fu,{className:"w-5 h-5"})})]}),e.jsxs("p",{className:"text-slate-400 text-[10px] px-1 flex items-center gap-1",children:[e.jsx(Xa,{className:"w-3 h-3"}),e.jsxs("span",{children:["Press Enter to send • Use @ to mention • ",W?"Uploading files...":"Files attached appear above"]})]})]})})]}),F&&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 ${h==="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(da,{className:"w-4 h-4 text-blue-600"}),"Participants",e.jsx(Ae,{variant:"secondary",className:"bg-slate-100 text-slate-600 ml-1",children:ke.length})]}),e.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-slate-600",onClick:()=>B(!1),children:e.jsx(Tc,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Ra,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(ot,{type:"text",placeholder:"Search people...",value:D,onChange:Q=>O(Q.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:[ke.filter(Q=>{var pe;return Q.name.toLowerCase().includes(D.toLowerCase())||((pe=Q.role)==null?void 0:pe.toLowerCase().includes(D.toLowerCase()))}).map(Q=>{const pe=!!Q.revokedAt,Ne=["DD Lead","DD Head","NBH","DD Admin","Super Admin"].includes((s==null?void 0:s.roleCode)||"")&&!pe&&Q.id!==(s==null?void 0:s.id);return e.jsxs("div",{className:Pt("group flex items-start gap-3 p-3 rounded-xl transition-all cursor-default border border-transparent",pe?"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(Fh,{className:Pt("w-10 h-10 ring-2 ring-transparent transition-all",!pe&&"group-hover:ring-blue-100"),children:e.jsx(Bh,{className:`${Q.color} text-white text-xs font-bold`,children:Q.initials})}),Q.isOnline&&!pe&&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"}),pe&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-red-100 rounded-full p-0.5 border border-white",children:e.jsx(Rx,{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:Pt("text-sm font-semibold truncate",pe?"text-slate-500 line-through":"text-slate-900"),children:Q.name}),pe&&e.jsx(Ae,{variant:"outline",className:"text-[8px] h-3.5 px-1 bg-red-50 text-red-600 border-red-100",children:"Revoked"})]}),Q.id===(s==null?void 0:s.id)&&e.jsx(Ae,{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:Q.role}),e.jsx("p",{className:"text-[11px] text-slate-400 truncate italic",children:Q.email})]}),Ne&&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:()=>Rt(Q),children:e.jsx(Rx,{className:"w-3.5 h-3.5"})}),!Ne&&!pe&&e.jsx(el,{className:"w-4 h-4 text-slate-300 group-hover:text-slate-400 opacity-0 group-hover:opacity-100 transition-all self-center"})]},Q.id)}),ke.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center opacity-50",children:[e.jsx(da,{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(Js,{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(os,{open:!!We,onOpenChange:Q=>!Q&&Ce(null),children:e.jsxs(ls,{className:"max-w-6xl h-[90vh] flex flex-col p-4",children:[e.jsx(ms,{children:e.jsxs(us,{className:"flex items-center gap-2",children:[We&&fe(We.mimeType),e.jsx("span",{className:"truncate",children:We==null?void 0:We.fileName})]})}),e.jsx("div",{className:"flex-1 overflow-hidden rounded-lg bg-slate-100 flex items-center justify-center p-4",children:We!=null&&We.mimeType.startsWith("image/")?e.jsx("img",{src:`${bc}/${We.filePath.replace(/\\/g,"/")}`,className:"max-w-full max-h-full object-contain",alt:"Preview"}):(We==null?void 0:We.mimeType)==="application/pdf"?e.jsx("iframe",{src:`${bc}/${We.filePath.replace(/\\/g,"/")}`,className:"w-full h-full border-none",title:"PDF Preview"}):e.jsxs("div",{className:"text-center",children:[e.jsx(vm,{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:`${bc}/${We==null?void 0:We.filePath.replace(/\\/g,"/")}`,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline text-sm",children:"Open in new tab"})]})})]})}),e.jsx(os,{open:!!Y,onOpenChange:Q=>!Q&&U(null),children:e.jsxs(ls,{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(Rx,{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:Y==null?void 0:Y.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(ot,{value:X,onChange:Q=>ne(Q.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:()=>U(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:Re,disabled:oe,children:[oe?e.jsx(Ki,{className:"w-4 h-4 animate-spin mr-2"}):null,"Revoke Access"]})]})]})]})})]})}const Fb="!w-[80vw] !max-w-[80vw] sm:!max-w-[80vw]",Kl=({isOpen:t,onClose:s,document:n})=>{var l;const a=n?`http://localhost:5000${n.filePath.startsWith("/")?"":"/"}${n.filePath}`:"";return e.jsx(os,{open:t,onOpenChange:s,children:e.jsx(ls,{className:`${Fb} 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-amber-100 flex items-center justify-center border border-amber-200",children:e.jsx(nn,{className:"w-5 h-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(us,{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(Ni,{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:(l=n.fileName)!=null&&l.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 j7(){var W,z,F,B;const{id:t}=Bc(),s=qn(),[n,r]=v.useState(null),[a,l]=v.useState(null),[c,d]=v.useState(!0),[h,x]=v.useState(!1),[f,m]=v.useState(""),[p,u]=v.useState("details"),[j,g]=v.useState(!1),[y,N]=v.useState(null),[S,C]=v.useState(!1),[w,R]=v.useState(!1),[P,A]=v.useState(""),I=Nn(D=>D.auth.user),$=(I==null?void 0:I.role)==="FDD";v.useEffect(()=>{t&&T()},[t]);const T=async()=>{var D,O,V,K;d(!0);try{const[Y,U]=await Promise.all([Te.getApplicationById(t),Te.getFddAssignment(t)]);(D=Y.data)!=null&&D.success&&r(Y.data.data),(O=U.data)!=null&&O.success&&l(U.data.data)}catch(Y){console.error("Error fetching application:",Y);const U=((K=(V=Y.response)==null?void 0:V.data)==null?void 0:K.message)||"Access Denied: Not authorized for FDD access";ee.error(U),s("/fdd-dashboard")}finally{d(!1)}},E=async D=>{var K,Y,U;const O=(K=D.target.files)==null?void 0:K[0];if(!O||!f){f||ee.error("Please select a document type first");return}x(!0);const V=new FormData;V.append("file",O),V.append("documentType",f),V.append("stage","FDD"),V.append("applicationId",t),V.append("requestType","application");try{const X=await Te.uploadDocument(t,V);if((Y=X.data)!=null&&Y.success){if(f==="FDD Final Audit Report"){const ne=((U=X.data.data)==null?void 0:U.id)||X.data.id;await Te.submitFddReport({assignmentId:a==null?void 0:a.id,applicationId:t,reportDocumentId:ne,findings:"Final Audit Report submitted.",recommendation:"REVIEW_PENDING"})}ee.success(`${f} uploaded successfully`),T(),m("")}}catch{ee.error("Failed to upload document")}finally{x(!1)}},_=D=>{if(!D||!D.filePath){ee.error("Document source file not found");return}N({fileName:D.originalName||D.fileName||"Document",filePath:D.filePath,documentType:D.documentType,createdAt:D.createdAt,mimeType:D.mimeType}),g(!0)};if(c)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(ss,{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 M=n.currentStage==="FDD_VERIFICATION"||n.currentStage==="FDD",q=(a==null?void 0:a.status)==="Report Submitted",G=!M&&(n.overallStatus!=="Active"||n.currentProgress>=75)||q,Z=!M&&n.currentProgress<70&&!q;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(Ya,{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($r,{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(Js,{className:"w-4 h-4"}),"Awaiting Previous Stages"]}):G?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(Fn,{className:"w-4 h-4"}),"Final Audit Report Submitted"]}):e.jsx(e.Fragment,{children:$&&e.jsxs("button",{disabled:h,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(Ya,{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(Me,{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(Ae,{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 ${p==="details"?"text-blue-600":"text-slate-500 hover:text-slate-700"}`,"data-testid":"onboarding-fdd-details-tab-workspace",children:["Workspace",p==="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 ${p==="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"}),p==="worknotes"&&e.jsx("div",{className:"absolute bottom-[-1px] left-0 right-0 h-0.5 bg-blue-600"})]})]}),p==="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(tt,{className:"border-b border-slate-100 px-6 py-4",children:e.jsxs(nt,{className:"text-base font-bold flex items-center gap-2 text-slate-800",children:[e.jsx(Dr,{className:"w-4 h-4 text-slate-500"}),G?"Finalized Financial Reports":Z?"Audit Workspace":"Financial Report Submission"]})}),e.jsxs(Me,{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(Js,{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"]})]}),G&&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(Fn,{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."})]})]}),!G&&!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(fs,{className:"w-6 h-6"})}),e.jsx("p",{className:"text-slate-600 font-medium mb-1","data-testid":"onboarding-fdd-details-upload-title",children:$?"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:$?"PDF or JPG formats accepted (Max 10MB)":"You are in View-Only mode for this Audit"}),$&&e.jsxs("div",{className:"w-full max-w-sm space-y-4",children:[e.jsxs("select",{value:f,onChange:D=>m(D.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:h?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(ss,{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:E,disabled:!f,"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 ${f?"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(D=>!D.uploader||D.uploader.roleCode!=="FDD").map((D,O)=>{var V;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-${O}`,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(fs,{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-${O}`,children:D.originalName||D.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-${O}`,children:[D.documentType," • ",Ht(D.createdAt),((V=D.uploader)==null?void 0:V.fullName)&&` • by ${D.uploader.fullName}`]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:()=>_(D),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-${O}`,children:e.jsx(nn,{className:"w-4 h-4"})})})]},O)}),((z=n.uploadedDocuments)==null?void 0:z.filter(D=>!D.uploader||D.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-amber-500"}),"My Uploaded Reports"]}),e.jsxs("div",{className:"space-y-2",children:[(F=n.uploadedDocuments)==null?void 0:F.filter(D=>{var O;return((O=D.uploader)==null?void 0:O.roleCode)==="FDD"}).map((D,O)=>{var V;return e.jsxs("div",{className:"p-3 border border-amber-100 bg-amber-50/30 rounded flex items-center justify-between hover:bg-amber-50 transition-all group","data-testid":`onboarding-fdd-details-my-report-row-${O}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-amber-100 flex items-center justify-center text-amber-500",children:e.jsx(fs,{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-${O}`,children:D.originalName||D.fileName}),e.jsx("span",{className:"text-[8px] bg-amber-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-${O}`,children:[D.documentType," • ",Ht(D.createdAt),((V=D.uploader)==null?void 0:V.fullName)&&` • by ${D.uploader.fullName}`]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:()=>_(D),className:"p-1.5 hover:bg-white rounded text-slate-400 hover:text-amber-600 transition-all","data-testid":`onboarding-fdd-details-my-report-preview-${O}`,children:e.jsx(nn,{className:"w-4 h-4"})})})]},O)}),((B=n.uploadedDocuments)==null?void 0:B.filter(D=>{var O;return((O=D.uploader)==null?void 0:O.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(tt,{className:"border-b border-slate-100 px-6 pt-4 pb-2.5",children:e.jsx(nt,{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Applicant Profile"})}),e.jsxs(Me,{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(tt,{className:"border-b border-slate-100 px-6 pt-4 pb-2.5",children:e.jsx(nt,{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Statutory Details"})}),e.jsx(Me,{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(tt,{className:"border-b border-slate-100 px-6 pt-4 pb-2.5",children:e.jsx(nt,{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Bank Details"})}),e.jsx(Me,{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(nE,{onBack:()=>u("details"),requestId:t,requestType:"application"})}),e.jsx(Kl,{isOpen:j,onClose:()=>g(!1),document:y}),e.jsx(os,{open:S,onOpenChange:C,children:e.jsxs(ls,{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-amber-600/20 to-transparent"}),e.jsx("div",{className:"w-16 h-16 bg-amber-600/20 rounded-full flex items-center justify-center animate-pulse relative z-10",children:e.jsx(Fl,{className:"w-8 h-8 text-amber-500"})})]}),e.jsxs("div",{className:"p-8 space-y-4",children:[e.jsxs(ms,{children:[e.jsx(us,{className:"text-2xl font-bold text-slate-900 text-center","data-testid":"onboarding-fdd-details-finalize-title",children:"Submit Audit Report"}),e.jsxs(vs,{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-amber-500 decoration-2",children:"notify the Admin"})," for review and approval."]})]}),e.jsxs("div",{className:"bg-amber-50 p-4 rounded-xl flex gap-3 border border-amber-100 italic","data-testid":"onboarding-fdd-details-finalize-info",children:[e.jsx(Xa,{className:"w-5 h-5 text-amber-600 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-amber-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(ce,{className:"text-[10px] font-black uppercase tracking-widest text-slate-400",children:"Detailed Audit Findings & Remarks"}),e.jsx(Fs,{placeholder:"Enter detailed financial observations...",className:"min-h-[120px] bg-slate-50 border-slate-200 rounded-xl focus:ring-amber-500 text-sm resize-none",value:P,onChange:D=>A(D.target.value),"data-testid":"onboarding-fdd-details-finalize-remarks"})]})}),e.jsxs(rn,{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:h,"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-amber-600","data-testid":"onboarding-fdd-details-finalize-confirm",onClick:async()=>{var D,O;try{if(!P.trim()){ee.error("Please provide findings.");return}x(!0);const V=(D=a==null?void 0:a.reports)==null?void 0:D[0];(O=(await Te.submitFddReport({assignmentId:a==null?void 0:a.id,applicationId:t,reportDocumentId:V==null?void 0:V.reportDocumentId,findings:P,recommendation:null})).data)!=null&&O.success&&(ee.success("FDD Report submitted successfully."),C(!1),T())}catch{ee.error("Failed to submit report")}finally{x(!1)}},disabled:h,children:h?e.jsx(ss,{className:"w-5 h-5 animate-spin"}):"Confirm & Submit"})]})]})]})}),e.jsx(os,{open:w,onOpenChange:R,children:e.jsxs(ls,{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(Ya,{className:"w-8 h-8 text-red-500"})})]}),e.jsxs("div",{className:"p-8 space-y-4",children:[e.jsxs(ms,{children:[e.jsx(us,{className:"text-2xl font-bold text-slate-900 text-center","data-testid":"onboarding-fdd-details-flag-modal-title",children:"Flag Applicant"}),e.jsxs(vs,{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(rn,{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:h,"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{x(!0),await Te.flagNonResponsive({applicationId:t,remarks:"Applicant is non-responsive to FDD queries."}),ee.error("Application flagged for non-responsiveness."),R(!1),T()}catch{ee.error("Action failed")}finally{x(!1)}},disabled:h,children:h?e.jsx(ss,{className:"w-5 h-5 animate-spin"}):"Flag Applicant"})]})]})]})})]})}function N7(t,s=[]){let n=[];function r(l,c){const d=v.createContext(c);d.displayName=l+"Context";const h=n.length;n=[...n,c];const x=m=>{var N;const{scope:p,children:u,...j}=m,g=((N=p==null?void 0:p[t])==null?void 0:N[h])||d,y=v.useMemo(()=>j,Object.values(j));return e.jsx(g.Provider,{value:y,children:u})};x.displayName=l+"Provider";function f(m,p){var g;const u=((g=p==null?void 0:p[t])==null?void 0:g[h])||d,j=v.useContext(u);if(j)return j;if(c!==void 0)return c;throw new Error(`\`${m}\` must be used within \`${l}\``)}return[x,f]}const a=()=>{const l=n.map(c=>v.createContext(c));return function(d){const h=(d==null?void 0:d[t])||l;return v.useMemo(()=>({[`__scope${t}`]:{...d,[t]:h}}),[d,h])}};return a.scopeName=t,[r,w7(a,...s)]}function w7(...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(l){const c=r.reduce((d,{useScope:h,scopeName:x})=>{const m=h(l)[`__scope${x}`];return{...d,...m}},{});return v.useMemo(()=>({[`__scope${s.scopeName}`]:c}),[c])}};return n.scopeName=s.scopeName,n}var S7=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],rE=S7.reduce((t,s)=>{const n=hu(`Primitive.${s}`),r=v.forwardRef((a,l)=>{const{asChild:c,...d}=a,h=c?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(h,{...d,ref:l})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),Bb="Progress",$b=100,[C7]=N7(Bb),[A7,k7]=C7(Bb),aE=v.forwardRef((t,s)=>{const{__scopeProgress:n,value:r=null,max:a,getValueLabel:l=R7,...c}=t;(a||a===0)&&!a1(a)&&console.error(E7(`${a}`,"Progress"));const d=a1(a)?a:$b;r!==null&&!i1(r,d)&&console.error(D7(`${r}`,"Progress"));const h=i1(r,d)?r:null,x=Pm(h)?l(h,d):void 0;return e.jsx(A7,{scope:n,value:h,max:d,children:e.jsx(rE.div,{"aria-valuemax":d,"aria-valuemin":0,"aria-valuenow":Pm(h)?h:void 0,"aria-valuetext":x,role:"progressbar","data-state":oE(h,d),"data-value":h??void 0,"data-max":d,...c,ref:s})})});aE.displayName=Bb;var iE="ProgressIndicator",lE=v.forwardRef((t,s)=>{const{__scopeProgress:n,...r}=t,a=k7(iE,n);return e.jsx(rE.div,{"data-state":oE(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...r,ref:s})});lE.displayName=iE;function R7(t,s){return`${Math.round(t/s*100)}%`}function oE(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function Pm(t){return typeof t=="number"}function a1(t){return Pm(t)&&!isNaN(t)&&t>0}function i1(t,s){return Pm(t)&&!isNaN(t)&&t<=s&&t>=0}function E7(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${$b}\`.`}function D7(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 ${$b} if no \`max\` prop is set)
- \`null\` or \`undefined\` if the progress is indeterminate.
Defaulting to \`null\`.`}var T7=aE,P7=lE;function ji({className:t,value:s,...n}){return e.jsx(T7,{"data-slot":"progress",className:Pt("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",t),...n,children:e.jsx(P7,{"data-slot":"progress-indicator",className:"bg-primary h-full w-full flex-1 transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})})}function Yl({className:t,...s}){return e.jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:Pt("mx-auto flex w-full justify-center",t),...s})}function Zl({className:t,...s}){return e.jsx("ul",{"data-slot":"pagination-content",className:Pt("flex flex-row items-center gap-1",t),...s})}function an({...t}){return e.jsx("li",{"data-slot":"pagination-item",...t})}function Ci({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:Pt(Km({variant:s?"outline":"ghost",size:n}),t),...r})}function Ql({className:t,...s}){return e.jsxs(Ci,{"aria-label":"Go to previous page",size:"default",className:Pt("gap-1 px-2.5 sm:pl-2.5",t),...s,children:[e.jsx(qc,{}),e.jsx("span",{className:"hidden sm:block",children:"Previous"})]})}function Xl({className:t,...s}){return e.jsxs(Ci,{"aria-label":"Go to next page",size:"default",className:Pt("gap-1 px-2.5 sm:pr-2.5",t),...s,children:[e.jsx("span",{className:"hidden sm:block",children:"Next"}),e.jsx(el,{})]})}function Jl({className:t,...s}){return e.jsxs("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:Pt("flex size-9 items-center justify-center",t),...s,children:[e.jsx(lI,{className:"size-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]})}function _7({onViewDetails:t,initialFilter:s}){const{user:n}=Nn(W=>W.auth),[r,a]=v.useState(""),[l,c]=v.useState("all"),[d,h]=v.useState(s||"all"),[x,f]=v.useState([]),[m,p]=v.useState("date"),[u,j]=v.useState(!1),[g,y]=v.useState(!1),[N,S]=v.useState([]),[C,w]=v.useState([]),[R,P]=v.useState(1),[A,I]=v.useState(null),$=10;v.useEffect(()=>{T()},[R,l,d,r]);const T=async()=>{try{const W=await ds.getApplications({page:R,limit:$,status:d!=="all"?d:void 0,location:l!=="all"?l:void 0,search:r||void 0,ddLeadShortlisted:"true",isShortlisted:"true",assignedTo:g?n==null?void 0:n.id:void 0}),z=W.data||[];I(W.meta);const F=z.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(S(F),C.length===0){const B=Array.from(new Set(F.map(D=>D.preferredLocation))).filter(Boolean);w(B)}}catch(W){console.error("Failed to fetch applications",W)}finally{}},E=N.sort((W,z)=>m==="date"?new Date(z.submissionDate).getTime()-new Date(W.submissionDate).getTime():0),_=W=>{f(z=>z.includes(W)?z.filter(F=>F!==W):[...z,W])},M=()=>{x.length===E.length?f([]):f(E.map(W=>W.id))},q=()=>{alert(`Sending reminders to ${x.length} applicants`),f([])},G=()=>{alert("Exporting applications to CSV...")},Z=W=>({Submitted:"bg-slate-500","Questionnaire Pending":"bg-orange-500","Questionnaire Completed":"bg-blue-500",Shortlisted:"bg-cyan-500","Level 1 Pending":"bg-amber-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"})[W]||"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(Ra,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(ot,{type:"text",placeholder:"Search by name, ID, or email...",value:r,onChange:W=>a(W.target.value),className:"pl-10","data-testid":"onboarding-applications-search-input"})]}),e.jsxs(wt,{value:l,onValueChange:c,children:[e.jsx(Ct,{className:"w-full lg:w-48","data-testid":"onboarding-applications-location-filter",children:e.jsx(St,{placeholder:"All Locations"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"all",children:"All Locations"}),C.map(W=>e.jsx(Pe,{value:W,children:W},W))]})]}),e.jsxs(wt,{value:d,onValueChange:h,children:[e.jsx(Ct,{className:"w-full lg:w-48","data-testid":"onboarding-applications-status-filter",children:e.jsx(St,{placeholder:"All Statuses"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"all",children:"All Statuses"}),e.jsx(Pe,{value:"Questionnaire Pending",children:"Questionnaire Pending"}),e.jsx(Pe,{value:"Shortlisted",children:"Shortlisted"}),e.jsx(Pe,{value:"Level 1 Pending",children:"Level 1 Pending"}),e.jsx(Pe,{value:"Level 2 Pending",children:"Level 2 Pending"}),e.jsx(Pe,{value:"Level 3 Pending",children:"Level 3 Pending"}),e.jsx(Pe,{value:"EOR In Progress",children:"EOR In Progress"}),e.jsx(Pe,{value:"Approved",children:"Approved"}),e.jsx(Pe,{value:"Rejected",children:"Rejected"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Rn,{id:"my-assignments",checked:g,onCheckedChange:W=>y(W),"data-testid":"onboarding-applications-assignments-checkbox"}),e.jsx(ce,{htmlFor:"my-assignments","data-testid":"onboarding-applications-assignments-label",children:"My Assignments Only"})]}),e.jsxs(wt,{value:m,onValueChange:W=>p(W),children:[e.jsx(Ct,{className:"w-full lg:w-40","data-testid":"onboarding-applications-sort-select",children:e.jsx(St,{placeholder:"Sort By"})}),e.jsx(At,{children:e.jsx(Pe,{value:"date",children:"Date"})})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mt-4",children:[e.jsxs(se,{variant:"outline",size:"sm",onClick:G,"data-testid":"onboarding-applications-export-button",children:[e.jsx(Ni,{className:"w-4 h-4 mr-2"}),"Export"]}),x.length>0&&e.jsxs(se,{variant:"outline",size:"sm",onClick:q,"data-testid":"onboarding-applications-reminders-button",children:[e.jsx(qr,{className:"w-4 h-4 mr-2"}),"Send Reminders (",x.length,")"]}),e.jsxs("div",{className:"ml-auto text-slate-600","data-testid":"onboarding-applications-count-text",children:[A?A.total:E.length," application",(A==null?void 0:A.total)!==1?"s":""]})]})]}),e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200",children:[e.jsxs(ks,{"data-testid":"onboarding-applications-table",children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{className:"w-12",children:e.jsx(Rn,{checked:x.length===E.length&&E.length>0,onCheckedChange:M,"data-testid":"onboarding-applications-header-checkbox"})}),e.jsx(me,{children:"ID"}),e.jsx(me,{children:"Name"}),e.jsx(me,{children:"Preferred Location"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Applicant Location"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Applied On"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Es,{children:E.map((W,z)=>e.jsxs(ct,{"data-testid":`onboarding-application-row-${z}`,children:[e.jsx(de,{children:e.jsx(Rn,{checked:x.includes(W.id),onCheckedChange:()=>_(W.id),"data-testid":`onboarding-application-checkbox-${z}`})}),e.jsx(de,{"data-testid":`onboarding-application-id-${z}`,children:W.registrationNumber}),e.jsx(de,{"data-testid":`onboarding-application-name-${z}`,children:W.name}),e.jsx(de,{"data-testid":`onboarding-application-pref-location-${z}`,children:W.preferredLocation}),e.jsx(de,{children:e.jsx(Ae,{className:Z(W.status),"data-testid":`onboarding-application-status-${z}`,children:W.status})}),e.jsx(de,{className:"text-slate-600 max-w-xs truncate","data-testid":`onboarding-application-addr-${z}`,children:W.residentialAddress}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ji,{value:W.progress,className:"h-2 w-20","data-testid":`onboarding-application-progress-bar-${z}`}),e.jsxs("span",{className:"text-slate-600","data-testid":`onboarding-application-progress-text-${z}`,children:[W.progress,"%"]})]})}),e.jsx(de,{"data-testid":`onboarding-application-date-${z}`,children:Ht(W.submissionDate)}),e.jsx(de,{children:e.jsx(se,{size:"sm",variant:"outline",onClick:()=>t(W.id),"data-testid":`onboarding-application-view-btn-${z}`,children:"View"})})]},W.id))})]}),A&&A.totalPages>1&&e.jsx("div",{className:"py-4 border-t px-4 flex justify-center",children:e.jsx(Yl,{children:e.jsxs(Zl,{children:[e.jsx(an,{children:e.jsx(Ql,{onClick:()=>P(W=>Math.max(1,W-1)),className:R===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(A.totalPages)].map((W,z)=>{const F=z+1;return F===1||F===A.totalPages||F>=R-1&&F<=R+1?e.jsx(an,{children:e.jsx(Ci,{isActive:R===F,onClick:()=>P(F),className:"cursor-pointer",children:F})},F):F===2&&R>3||F===A.totalPages-1&&R<A.totalPages-2?e.jsx(an,{children:e.jsx(Jl,{})},F):null}),e.jsx(an,{children:e.jsx(Xl,{onClick:()=>P(W=>Math.min(A.totalPages,W+1)),className:R===A.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]}),e.jsx(os,{open:u,onOpenChange:j,children:e.jsxs(ls,{className:"max-w-2xl","data-testid":"onboarding-new-app-modal",children:[e.jsx(ms,{children:e.jsx(us,{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(ce,{children:"Name"}),e.jsx(ot,{placeholder:"Full Name","data-testid":"onboarding-new-app-name"})]}),e.jsxs("div",{children:[e.jsx(ce,{children:"Email"}),e.jsx(ot,{type:"email",placeholder:"email@example.com","data-testid":"onboarding-new-app-email"})]}),e.jsxs("div",{children:[e.jsx(ce,{children:"Phone"}),e.jsx(ot,{placeholder:"+91 XXXXX XXXXX","data-testid":"onboarding-new-app-phone"})]}),e.jsxs("div",{children:[e.jsx(ce,{children:"Preferred Location"}),e.jsxs(wt,{children:[e.jsx(Ct,{"data-testid":"onboarding-new-app-location-select",children:e.jsx(St,{placeholder:"Select location"})}),e.jsx(At,{children:C.map(W=>e.jsx(Pe,{value:W,children:W},W))})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(se,{variant:"outline",onClick:()=>j(!1),"data-testid":"onboarding-new-app-cancel",children:"Cancel"}),e.jsx(se,{className:"bg-amber-600 hover:bg-amber-700","data-testid":"onboarding-new-app-submit",children:"Create Application"})]})]})]})})]})}function cE({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-amber-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(Ae,{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(Ae,{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(Er,{className:"w-4 h-4"}),e.jsx("span",{"data-testid":"onboarding-application-card-location",children:t.preferredLocation}),t.rank&&t.totalApplicantsAtLocation&&e.jsxs(Ae,{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(Dc,{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(qr,{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(Zv,{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(_2,{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($n,{className:"w-4 h-4"}),e.jsxs("span",{"data-testid":"onboarding-application-card-submission-date",children:["Submitted: ",Ht(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(ji,{value:t.progress,className:"h-2","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: ",Ht(t.deadline)]})}),e.jsx(se,{onClick:()=>s(t.id),className:"w-full bg-amber-600 hover:bg-amber-700","data-testid":"onboarding-application-card-view-button",children:"View Details"})]})}function O7({onViewDetails:t,initialFilter:s="all"}){const[n,r]=v.useState("grid"),[a,l]=v.useState(""),[c,d]=v.useState(s),[h,x]=v.useState("all"),[f,m]=v.useState("all"),[p,u]=v.useState([]),[j,g]=v.useState(!1),[y,N]=v.useState(""),[S,C]=v.useState([]),[w,R]=v.useState(!0),[P,A]=v.useState([]),[I,$]=v.useState([]),[T,E]=v.useState(1),[_,M]=v.useState(null);v.useEffect(()=>{G()},[T,a,c,h,f]),v.useEffect(()=>{E(1)},[a,c,h,f]),v.useEffect(()=>{q()},[]);const q=async()=>{try{const K=await Ss.getStates(),U=(Array.isArray(K)?K:(K==null?void 0:K.data)||(K==null?void 0:K.states)||[]).map(X=>typeof X=="string"?X:X.name||X.stateName).filter(Boolean);A(U)}catch(K){console.error("Failed to fetch states:",K)}},G=async()=>{try{R(!0);const K=await ds.getApplications({page:T,limit:10,search:a,status:c==="all"?void 0:c,location:h!=="all"?h:void 0,state:f!=="all"?f:void 0,isShortlisted:void 0}),Y=K.data||[];M(K.meta);const U=Y.map(ne=>({id:ne.id,registrationNumber:ne.applicationId||"N/A",name:ne.applicantName,email:ne.email,phone:ne.phone,age:ne.age,education:ne.education,residentialAddress:ne.address||ne.city||"",businessAddress:ne.address||"",preferredLocation:ne.preferredLocation,state:ne.state,ownsBike:ne.ownRoyalEnfield==="yes",pastExperience:ne.experienceYears?`${ne.experienceYears} years`:ne.description||"",status:ne.overallStatus,questionnaireMarks:ne.score||ne.questionnaireMarks||0,rank:0,totalApplicantsAtLocation:0,submissionDate:ne.createdAt,assignedUsers:[],progress:ne.progressPercentage||0,isShortlisted:ne.isShortlisted||ne.ddLeadShortlisted,companyName:ne.companyName,source:ne.source,existingDealer:ne.existingDealer,royalEnfieldModel:ne.royalEnfieldModel,description:ne.description,pincode:ne.pincode,locationType:ne.locationType,ownRoyalEnfield:ne.ownRoyalEnfield,address:ne.address}));C(U);const X=Array.from(new Set(U.map(ne=>ne.preferredLocation))).filter(Boolean);$(X)}catch(K){console.error("Failed to fetch applications:",K),ee.error("Failed to load applications")}finally{R(!1)}},Z=S,W=K=>{u(K?Z.map(Y=>Y.id):[])},z=(K,Y)=>{u(Y?[...p,K]:p.filter(U=>U!==K))},F=()=>{if(p.length===0){ee.error("Please select at least one application to shortlist");return}g(!0)},B=async()=>{try{ee.success(`${p.length} application(s) shortlisted successfully!`),g(!1),G()}catch{ee.error("Failed to shortlist")}},D=()=>{ee.success(`Reminder emails sent to ${p.length} applicant(s)`)},O=["Submitted","Questionnaire Pending","Questionnaire Completed"],V=K=>({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-amber-100 text-amber-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-amber-100 text-amber-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 Details In Progress":"bg-amber-100 text-amber-800","Security Details Approved":"bg-green-100 text-green-800","Security Details":"bg-amber-100 text-amber-800","LOA Issued":"bg-pink-100 text-pink-800"})[K]||"bg-gray-100 text-gray-800";return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4","data-testid":"onboarding-all-apps-banner",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ks,{className:"w-5 h-5 text-amber-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-amber-900 mb-1",children:"DD Workflow - Initial Application Review"}),e.jsxs("p",{className:"text-amber-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(Ra,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(ot,{type:"text",placeholder:"Search by name or registration number...",value:a,onChange:K=>l(K.target.value),className:"pl-10","data-testid":"onboarding-all-apps-search-input"})]}),e.jsxs(wt,{value:c,onValueChange:d,children:[e.jsx(Ct,{className:"w-full md:w-48","data-testid":"onboarding-all-apps-status-filter",children:e.jsx(St,{placeholder:"Filter by status"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"all",children:"All Statuses"}),O.map(K=>e.jsx(Pe,{value:K,children:K},K))]})]}),e.jsxs(wt,{value:f,onValueChange:m,children:[e.jsx(Ct,{className:"w-full md:w-48","data-testid":"onboarding-all-apps-state-filter",children:e.jsx(St,{placeholder:"Filter by state"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"all",children:"All States"}),P.map(K=>e.jsx(Pe,{value:K,children:K},K))]})]}),e.jsxs(wt,{value:h,onValueChange:x,children:[e.jsx(Ct,{className:"w-full md:w-48","data-testid":"onboarding-all-apps-location-filter",children:e.jsx(St,{placeholder:"Filter by location"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"all",children:"All Locations"}),I.map(K=>e.jsx(Pe,{value:K,children:K},K))]})]})]}),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-amber-600 hover:bg-amber-700":"","data-testid":"onboarding-all-apps-grid-view-btn",children:[e.jsx(L2,{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-amber-600 hover:bg-amber-700":"","data-testid":"onboarding-all-apps-table-view-btn",children:[e.jsx(B2,{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(Ni,{className:"w-4 h-4 mr-2"}),"Export"]}),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(se,{variant:"outline",size:"sm",onClick:D,"data-testid":"onboarding-all-apps-reminders-btn",children:[e.jsx(qr,{className:"w-4 h-4 mr-2"}),"Send Reminders (",p.length,")"]}),e.jsxs(se,{size:"sm",onClick:F,className:"bg-green-600 hover:bg-green-700","data-testid":"onboarding-all-apps-shortlist-btn",children:[e.jsx(Ys,{className:"w-4 h-4 mr-2"}),"Shortlist (",p.length,")"]})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs(Ae,{variant:"outline",className:"text-slate-600","data-testid":"onboarding-all-apps-pending-badge",children:[(_==null?void 0:_.total)||Z.length," pending shortlisting"]})})]})]})}),w?e.jsx("div",{className:"flex justify-center items-center h-96 bg-white rounded-lg border border-slate-200",children:e.jsx(ss,{className:"w-8 h-8 animate-spin text-amber-600"})}):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((K,Y)=>e.jsxs("div",{className:"relative","data-testid":`onboarding-all-apps-grid-item-${Y}`,children:[e.jsx("div",{className:"absolute top-4 left-4 z-10",children:e.jsx(Rn,{checked:p.includes(K.id),onCheckedChange:U=>z(K.id,U),className:"bg-white","data-testid":`onboarding-all-apps-grid-checkbox-${Y}`})}),K.isShortlisted&&e.jsx("div",{className:"absolute top-4 right-4 z-10",children:e.jsx(Ae,{className:"bg-green-600","data-testid":`onboarding-all-apps-grid-shortlisted-badge-${Y}`,children:"Shortlisted"})}),e.jsx(cE,{application:K,onViewDetails:t})]},K.id))}):e.jsx("div",{className:"bg-white rounded-lg border border-slate-200",children:e.jsxs(ks,{"data-testid":"onboarding-all-apps-table",children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{className:"w-12",children:e.jsx(Rn,{checked:p.length===Z.length&&Z.length>0,onCheckedChange:W,"data-testid":"onboarding-all-apps-header-checkbox"})}),e.jsx(me,{children:"Registration"}),e.jsx(me,{children:"Name"}),e.jsx(me,{children:"Location"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Shortlisted"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Submitted"})]})}),e.jsx(Es,{children:Z.map((K,Y)=>e.jsxs(ct,{className:"cursor-pointer hover:bg-slate-50",onClick:()=>t(K.id),"data-testid":`onboarding-all-apps-row-${Y}`,children:[e.jsx(de,{onClick:U=>U.stopPropagation(),children:e.jsx(Rn,{checked:p.includes(K.id),onCheckedChange:U=>z(K.id,U),"data-testid":`onboarding-all-apps-checkbox-${Y}`})}),e.jsx(de,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-all-apps-reg-id-${Y}`,children:K.registrationNumber})}),e.jsx(de,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-all-apps-name-${Y}`,children:K.name})}),e.jsx(de,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-all-apps-location-${Y}`,children:K.preferredLocation})}),e.jsx(de,{children:e.jsx(Ae,{className:V(K.status),"data-testid":`onboarding-all-apps-status-${Y}`,children:K.status})}),e.jsx(de,{children:K.isShortlisted?e.jsx(Ae,{className:"bg-green-600","data-testid":`onboarding-all-apps-shortlisted-yes-${Y}`,children:"Yes"}):e.jsx(Ae,{variant:"outline","data-testid":`onboarding-all-apps-shortlisted-no-${Y}`,children:"No"})}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ji,{value:K.progress,className:"w-20","data-testid":`onboarding-all-apps-progress-bar-${Y}`}),e.jsxs("span",{className:"text-slate-600","data-testid":`onboarding-all-apps-progress-text-${Y}`,children:[K.progress,"%"]})]})}),e.jsx(de,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-all-apps-date-${Y}`,children:Ht(K.submissionDate)})})]},K.id))})]})}),_&&_.totalPages>1&&e.jsx("div",{className:"py-6 border-t border-slate-200 bg-white rounded-b-lg",children:e.jsx(Yl,{children:e.jsxs(Zl,{children:[e.jsx(an,{children:e.jsx(Ql,{onClick:()=>E(K=>Math.max(1,K-1)),className:T===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(_.totalPages)].map((K,Y)=>{const U=Y+1;return U===1||U===_.totalPages||U>=T-1&&U<=T+1?e.jsx(an,{children:e.jsx(Ci,{isActive:T===U,onClick:()=>E(U),className:"cursor-pointer",children:U})},U):U===T-2||U===T+2?e.jsx(an,{children:e.jsx(Jl,{})},U):null}),e.jsx(an,{children:e.jsx(Xl,{onClick:()=>E(K=>Math.min(_.totalPages,K+1)),className:T===_.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})}),e.jsx(os,{open:j,onOpenChange:g,children:e.jsxs(ls,{"data-testid":"onboarding-all-apps-shortlist-modal",children:[e.jsxs(ms,{children:[e.jsx(us,{"data-testid":"onboarding-all-apps-shortlist-title",children:"Shortlist Applications"}),e.jsxs(vs,{"data-testid":"onboarding-all-apps-shortlist-desc",children:["You are about to shortlist ",p.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(ce,{htmlFor:"shortlist-remark",children:"Shortlisting Remark (Optional)"}),e.jsx(Fs,{id:"shortlist-remark",placeholder:"Enter reason for shortlisting these applications...",value:y,onChange:K=>N(K.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:()=>g(!1),"data-testid":"onboarding-all-apps-shortlist-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-green-600 hover:bg-green-700",onClick:B,"data-testid":"onboarding-all-apps-shortlist-confirm",children:"Confirm Shortlist"})]})]})]})})]})}function I7({onViewDetails:t}){const[s,n]=v.useState("table"),[r,a]=v.useState(""),[l,c]=v.useState("all"),[d,h]=v.useState("all"),[x,f]=v.useState("all"),[m,p]=v.useState(""),[u,j]=v.useState(""),[g,y]=v.useState("date-desc"),[N,S]=v.useState(1),[C,w]=v.useState(null),[R,P]=v.useState([]),[A,I]=v.useState(!1),[$,T]=v.useState(""),[E,_]=v.useState([]),[M,q]=v.useState([]),[G,Z]=v.useState([]),[W,z]=v.useState(!0);v.useEffect(()=>{B()},[m,u,l,r,N,d,x]),v.useEffect(()=>{S(1)},[m,u,l,r,d,x]),v.useEffect(()=>{F()},[]);const F=async()=>{try{const re=await Ss.getStates(),ve=(Array.isArray(re)?re:(re==null?void 0:re.data)||(re==null?void 0:re.states)||[]).map(Se=>typeof Se=="string"?Se:Se.name||Se.stateName).filter(Boolean);_(ve)}catch(re){console.error("Failed to fetch states:",re)}},B=async()=>{try{z(!0);const re=["Questionnaire Pending","Questionnaire Completed","Shortlisted"],ge=await ds.getApplications({fromDate:m,toDate:u,status:l==="all"?re.join(","):l,location:d!=="all"?d:void 0,state:x!=="all"?x:void 0,ddLeadShortlisted:"false",isShortlisted:"true",search:r,page:N,limit:10}),ve=ge.data||[];w(ge.meta);const Se=ve.map(Ce=>({id:Ce.id,registrationNumber:Ce.applicationId||"N/A",name:Ce.applicantName,email:Ce.email,phone:Ce.phone,age:Ce.age,education:Ce.education,residentialAddress:Ce.address||Ce.city||"",businessAddress:Ce.address||"",preferredLocation:Ce.preferredLocation,state:Ce.state,ownsBike:Ce.ownRoyalEnfield==="yes",pastExperience:Ce.experienceYears?`${Ce.experienceYears} years`:Ce.description||"",status:Ce.overallStatus,questionnaireMarks:Ce.score||Ce.questionnaireMarks||0,rank:0,totalApplicantsAtLocation:0,submissionDate:Ce.createdAt,assignedUsers:[],progress:Ce.progressPercentage||0,isShortlisted:Ce.isShortlisted,ddLeadShortlisted:Ce.ddLeadShortlisted,companyName:Ce.companyName,source:Ce.source,existingDealer:Ce.existingDealer,royalEnfieldModel:Ce.royalEnfieldModel,description:Ce.description,pincode:Ce.pincode,locationType:Ce.locationType,ownRoyalEnfield:Ce.ownRoyalEnfield,address:Ce.address}));Z(Se);const We=Array.from(new Set(Se.map(Ce=>Ce.preferredLocation))).filter(Boolean);q(We)}catch(re){console.error("Failed to fetch applications:",re),ee.error("Failed to load opportunity requests")}finally{z(!1)}},D=G.sort((re,ge)=>g==="score-desc"?(ge.questionnaireMarks||0)-(re.questionnaireMarks||0):g==="score-asc"?(re.questionnaireMarks||0)-(ge.questionnaireMarks||0):g==="date-desc"?new Date(ge.submissionDate).getTime()-new Date(re.submissionDate).getTime():g==="date-asc"?new Date(re.submissionDate).getTime()-new Date(ge.submissionDate).getTime():0),O=re=>{P(re?D.map(ge=>ge.id):[])},V=(re,ge)=>{P(ge?[...R,re]:R.filter(ve=>ve!==re))},K=()=>{if(R.length===0){ee.error("Please select at least one application to shortlist");return}I(!0)},Y=async()=>{try{const re=await ds.shortlistApplications(R,[],$);if(re&&re.success)await B(),P([]),I(!1),T(""),ee.success(`${R.length} application(s) shortlisted successfully. Users will be assigned automatically.`);else throw new Error((re==null?void 0:re.message)||"Failed to process shortlisting")}catch(re){console.error("Failed to shortlist applications:",re),ee.error(re.message||"Failed to process shortlisting")}},U=()=>{if(R.length===0){ee.error("Please select at least one application");return}ee.success(`Reminder emails sent to ${R.length} applicant(s)`)},X=async()=>{const re=D.filter(Se=>Se.status!=="Questionnaire Pending"),ge=re.filter(Se=>R.includes(Se.id));let ve=[];if(R.length>0){if(ge.length===0){ee.error('Selected applications are in "Questionnaire Pending" status and cannot be exported.');return}ve=ge.map(Se=>Se.id),ge.length<R.length&&ee.info(`Skipping ${R.length-ge.length} applications with pending questionnaires.`)}else ve=re.map(Se=>Se.id);if(ve.length===0){ee.error("No applications with completed questionnaires available for export");return}try{const Se=ee.loading("Preparing Excel export..."),We=await ds.exportResponses(ve);if(ee.dismiss(Se),!We||We.length===0){ee.error("No response data found");return}const Ce=Object.keys(We[0]),Ye=[Ce.join(","),...We.map(qe=>Ce.map(Ve=>{const dt=qe[Ve]??"";return`"${String(dt).replace(/"/g,'""')}"`}).join(","))].join(`
`),be=new Blob([Ye],{type:"text/csv;charset=utf-8;"}),_e=URL.createObjectURL(be),ke=document.createElement("a");ke.setAttribute("href",_e),ke.setAttribute("download",`onboarding_responses_${new Date().toISOString().split("T")[0]}.xlsx`),document.body.appendChild(ke),ke.click(),document.body.removeChild(ke),ee.success(`Exported ${ve.length} records to Excel successfully`)}catch(Se){console.error("Export failed:",Se),ee.error(Se.message||"Failed to export responses")}},ne=["Questionnaire Pending","Questionnaire Completed","Shortlisted"],oe=re=>({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-amber-100 text-amber-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 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"})[re]||"bg-gray-100 text-gray-800";return W?e.jsx("div",{className:"flex justify-center items-center h-96",children:e.jsx(ss,{className:"w-8 h-8 animate-spin text-amber-600"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4","data-testid":"onboarding-opp-requests-banner",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ks,{className:"w-5 h-5 text-amber-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-amber-900 mb-1",children:"DD Lead Workflow - Opportunity Requests"}),e.jsxs("p",{className:"text-amber-800",children:["This page shows ",e.jsx("strong",{children:"applications where dealerships are being offered"})," at the applicant's preferred location. These have been shortlisted by DD and are waiting for your review. Select and ",e.jsx("strong",{children:"Shortlist"})," promising candidates to move them 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(Ra,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(ot,{type:"text",placeholder:"Search by name or registration number...",value:r,onChange:re=>a(re.target.value),className:"pl-10","data-testid":"onboarding-opp-requests-search-input"})]}),e.jsxs(wt,{value:l,onValueChange:c,children:[e.jsx(Ct,{className:"w-full md:w-48","data-testid":"onboarding-opp-requests-status-select",children:e.jsx(St,{placeholder:"Filter by status"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"all",children:"All Statuses"}),ne.map(re=>e.jsx(Pe,{value:re,children:re},re))]})]}),e.jsxs(wt,{value:x,onValueChange:f,children:[e.jsx(Ct,{className:"w-full md:w-48","data-testid":"onboarding-opp-requests-state-select",children:e.jsx(St,{placeholder:"Filter by state"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"all",children:"All States"}),E.map(re=>e.jsx(Pe,{value:re,children:re},re))]})]}),e.jsxs(wt,{value:d,onValueChange:h,children:[e.jsx(Ct,{className:"w-full md:w-48","data-testid":"onboarding-opp-requests-location-select",children:e.jsx(St,{placeholder:"Filter by location"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"all",children:"All Locations"}),M.map(re=>e.jsx(Pe,{value:re,children:re},re))]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 md:flex-none",children:[e.jsxs("div",{className:"relative w-full md:w-40",children:[e.jsx($n,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400 pointer-events-none"}),e.jsx(ot,{type:"date",value:m,onChange:re=>p(re.target.value),className:"pl-10 text-xs",placeholder:"From","data-testid":"onboarding-opp-requests-from-date"})]}),e.jsx("span",{className:"text-slate-400",children:"to"}),e.jsxs("div",{className:"relative w-full md:w-40",children:[e.jsx($n,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400 pointer-events-none"}),e.jsx(ot,{type:"date",value:u,onChange:re=>j(re.target.value),className:"pl-10 text-xs",placeholder:"To","data-testid":"onboarding-opp-requests-to-date"})]})]}),e.jsxs(wt,{value:g,onValueChange:y,children:[e.jsx(Ct,{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(W5,{className:"w-4 h-4 text-slate-400"}),e.jsx(St,{placeholder:"Sort by"})]})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"date-desc",children:"Newest Applied"}),e.jsx(Pe,{value:"date-asc",children:"Oldest Applied"}),e.jsx(Pe,{value:"score-desc",children:"Highest Score"}),e.jsx(Pe,{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-amber-600 hover:bg-amber-700":"","data-testid":"onboarding-opp-requests-view-grid-btn",children:[e.jsx(L2,{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-amber-600 hover:bg-amber-700":"","data-testid":"onboarding-opp-requests-view-table-btn",children:[e.jsx(B2,{className:"w-4 h-4 mr-2"}),"Table"]})]}),e.jsxs(se,{variant:"outline",size:"sm",onClick:X,"data-testid":"onboarding-opp-requests-export-btn",children:[e.jsx(Ni,{className:"w-4 h-4 mr-2"}),"Export"]}),R.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(se,{variant:"outline",size:"sm",onClick:U,"data-testid":"onboarding-opp-requests-bulk-reminder-btn",children:[e.jsx(qr,{className:"w-4 h-4 mr-2"}),"Send Reminders (",R.length,")"]}),e.jsxs(se,{size:"sm",onClick:K,className:"bg-green-600 hover:bg-green-700","data-testid":"onboarding-opp-requests-bulk-shortlist-btn",children:[e.jsx(Ys,{className:"w-4 h-4 mr-2"}),"Shortlist (",R.length,")"]})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs(Ae,{variant:"outline",className:"text-slate-600","data-testid":"onboarding-opp-requests-pending-count",children:[(C==null?void 0:C.total)||D.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:[D.map((re,ge)=>e.jsxs("div",{className:"relative","data-testid":`onboarding-opp-requests-grid-item-${ge}`,children:[e.jsx("div",{className:"absolute top-4 left-4 z-10",children:e.jsx(Rn,{checked:R.includes(re.id),onCheckedChange:ve=>V(re.id,ve),className:"bg-white","data-testid":`onboarding-opp-requests-grid-checkbox-${ge}`})}),e.jsx(cE,{application:re,onViewDetails:t})]},re.id)),D.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(Ys,{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(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{className:"w-12",children:e.jsx(Rn,{checked:R.length===D.length&&D.length>0,onCheckedChange:O,"data-testid":"onboarding-opp-requests-table-select-all"})}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-reg",children:"Registration"}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-name",children:"Name"}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-pref-loc",children:"Preferred Location"}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-status",children:"Status"}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-score",children:"Score"}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-app-loc",children:"Applicant Location"}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-shortlisted",children:"Shortlisted"}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-progress",children:"Progress"}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-date",children:"Applied On"})]})}),e.jsxs(Es,{children:[D.map((re,ge)=>e.jsxs(ct,{className:"cursor-pointer hover:bg-slate-50",onClick:()=>t(re.id),"data-testid":`onboarding-opp-requests-row-${ge}`,children:[e.jsx(de,{onClick:ve=>ve.stopPropagation(),children:e.jsx(Rn,{checked:R.includes(re.id),onCheckedChange:ve=>V(re.id,ve),"data-testid":`onboarding-opp-requests-table-select-item-${re.id}`})}),e.jsx(de,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-opp-requests-reg-${ge}`,children:re.registrationNumber})}),e.jsx(de,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-opp-requests-name-${ge}`,children:re.name})}),e.jsx(de,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-opp-requests-pref-loc-${ge}`,children:re.preferredLocation})}),e.jsx(de,{children:e.jsx(Ae,{className:oe(re.status),"data-testid":`onboarding-opp-requests-status-${ge}`,children:re.status})}),e.jsx(de,{children:e.jsx("span",{className:"font-semibold text-slate-900","data-testid":`onboarding-opp-requests-score-${ge}`,children:re.questionnaireMarks})}),e.jsx(de,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-opp-requests-app-loc-${ge}`,children:re.businessAddress})}),e.jsx(de,{children:e.jsx(Ae,{variant:"outline","data-testid":`onboarding-opp-requests-shortlisted-badge-${ge}`,children:"No"})}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2","data-testid":`onboarding-opp-requests-progress-container-${ge}`,children:[e.jsx(ji,{value:re.progress,className:"w-20"}),e.jsxs("span",{className:"text-slate-600",children:[re.progress,"%"]})]})}),e.jsx(de,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-opp-requests-date-${ge}`,children:Ht(re.submissionDate)})})]},re.id)),D.length===0&&e.jsx(ct,{children:e.jsxs(de,{colSpan:9,className:"text-center py-12 text-slate-500","data-testid":"onboarding-opp-requests-table-empty",children:[e.jsx(Ys,{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(Yl,{children:e.jsxs(Zl,{children:[e.jsx(an,{children:e.jsx(Ql,{onClick:()=>S(re=>Math.max(1,re-1)),className:N===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(C.totalPages)].map((re,ge)=>{const ve=ge+1;return ve===1||ve===C.totalPages||ve>=N-1&&ve<=N+1?e.jsx(an,{children:e.jsx(Ci,{isActive:N===ve,onClick:()=>S(ve),className:"cursor-pointer",children:ve})},ve):ve===N-2||ve===N+2?e.jsx(an,{children:e.jsx(Jl,{})},ve):null}),e.jsx(an,{children:e.jsx(Xl,{onClick:()=>S(re=>Math.min(C.totalPages,re+1)),className:N===C.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]}),e.jsx(os,{open:A,onOpenChange:I,children:e.jsxs(ls,{className:"overflow-visible","data-testid":"onboarding-opp-requests-shortlist-modal",children:[e.jsxs(ms,{children:[e.jsx(us,{"data-testid":"onboarding-opp-requests-shortlist-modal-title",children:"Shortlist Applications"}),e.jsxs(vs,{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(ce,{children:"Shortlisting Remark (Optional)"}),e.jsx(Fs,{placeholder:"Enter reason for shortlisting these applications...",value:$,onChange:re=>T(re.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:()=>{I(!1),T("")},"data-testid":"onboarding-opp-requests-shortlist-cancel-btn",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-green-600 hover:bg-green-700",onClick:Y,"data-testid":"onboarding-opp-requests-shortlist-confirm-btn",children:"Confirm Shortlist"})]})]})]})})]})}function L7({onViewDetails:t}){var W,z;const[s,n]=v.useState(""),[r,a]=v.useState("all"),[l,c]=v.useState("all"),[d,h]=v.useState(""),[x,f]=v.useState(""),[m,p]=v.useState(1),[u,j]=v.useState(null),[g,y]=v.useState([]),[N,S]=v.useState(!0),[C,w]=v.useState([]),[R,P]=v.useState([]),[A,I]=v.useState([]),[$,T]=v.useState(!1),E=async()=>{var F,B,D,O;if(A.length!==0)try{T(!0);const V=await ds.bulkConvertToOpportunity({ids:A});V!=null&&V.success&&((((F=V.data)==null?void 0:F.success)>0||!V.data)&&ee.success(V.message||`Successfully converted ${((B=V.data)==null?void 0:B.success)||A.length} leads.`),((D=V.data)==null?void 0:D.failed)>0&&((O=V.data)!=null&&O.errors)&&V.data.errors.forEach(K=>{ee.error(K,{duration:5e3})}),I([]),await G())}catch(V){console.error("Bulk conversion error:",V),ee.error(V.message||"Failed to perform bulk conversion")}finally{T(!1)}},_=()=>{A.length===Z.length?I([]):I(Z.map(F=>F.id))},M=F=>{I(B=>B.includes(F)?B.filter(D=>D!==F):[...B,F])};v.useEffect(()=>{G()},[d,x,s,m,r,l]),v.useEffect(()=>{p(1)},[d,x,s,r,l]),v.useEffect(()=>{q()},[]);const q=async()=>{try{const F=await Ss.getStates(),D=(Array.isArray(F)?F:(F==null?void 0:F.data)||(F==null?void 0:F.states)||[]).map(O=>typeof O=="string"?O:O.name||O.stateName).filter(Boolean);w(D)}catch(F){console.error("Failed to fetch states:",F)}},G=async()=>{try{S(!0);const F=await ds.getApplications({fromDate:d,toDate:x,search:s,status:"Submitted",isShortlisted:"false",location:r!=="all"?r:void 0,state:l!=="all"?l:void 0,page:m,limit:10}),B=F.data||[];j(F.meta);const D=B.map(V=>({id:V.id,registrationNumber:V.applicationId||"N/A",name:V.applicantName,email:V.email,phone:V.phone,age:V.age,education:V.education,residentialAddress:V.address||V.city||"",businessAddress:V.address||"",preferredLocation:V.preferredLocation,state:V.state,ownsBike:V.ownRoyalEnfield==="yes",pastExperience:V.experienceYears?`${V.experienceYears} years`:V.description||"",status:V.overallStatus,questionnaireMarks:V.score||V.questionnaireMarks||0,rank:0,totalApplicantsAtLocation:0,submissionDate:V.createdAt,assignedUsers:[],progress:V.progressPercentage||0,isShortlisted:V.isShortlisted,companyName:V.companyName,source:V.source,existingDealer:V.existingDealer,royalEnfieldModel:V.royalEnfieldModel,description:V.description,pincode:V.pincode,locationType:V.locationType,ownRoyalEnfield:V.ownRoyalEnfield,address:V.address}));y(D);const O=Array.from(new Set(D.map(V=>V.preferredLocation))).filter(Boolean);P(O)}catch(F){console.error("Failed to fetch applications:",F),ee.error("Failed to load non-opportunity requests")}finally{S(!1)}},Z=g;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)||g.length})]}),e.jsx("div",{className:"p-3 bg-blue-100 rounded-lg",children:e.jsx(ev,{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-amber-600 mt-1",children:((z=u==null?void 0:u.stats)==null?void 0:z.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(Ra,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(ot,{type:"text",placeholder:"Search by name, email, phone, or registration number...",value:s,onChange:F=>n(F.target.value),className:"pl-10","data-testid":"onboarding-non-opps-search-input"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative w-full md:w-36",children:[e.jsx($n,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400 pointer-events-none"}),e.jsx(ot,{type:"date",value:d,onChange:F=>h(F.target.value),className:"pl-10 text-xs",placeholder:"From","data-testid":"onboarding-non-opps-from-date"})]}),e.jsx("span",{className:"text-slate-400",children:"to"}),e.jsxs("div",{className:"relative w-full md:w-36",children:[e.jsx($n,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400 pointer-events-none"}),e.jsx(ot,{type:"date",value:x,onChange:F=>f(F.target.value),className:"pl-10 text-xs",placeholder:"To","data-testid":"onboarding-non-opps-to-date"})]})]}),e.jsxs(wt,{value:r,onValueChange:a,children:[e.jsx(Ct,{className:"w-full lg:w-48","data-testid":"onboarding-non-opps-location-select",children:e.jsx(St,{placeholder:"All Locations"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"all",children:"All Locations"}),R.map(F=>e.jsx(Pe,{value:F,children:F},F))]})]}),e.jsxs(wt,{value:l,onValueChange:c,children:[e.jsx(Ct,{className:"w-full lg:w-48","data-testid":"onboarding-non-opps-state-select",children:e.jsx(St,{placeholder:"All States"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"all",children:"All States"}),C.map(F=>e.jsx(Pe,{value:F,children:F},F))]})]}),e.jsx(se,{variant:"outline",size:"icon","data-testid":"onboarding-non-opps-export-btn",children:e.jsx(Ni,{className:"w-4 h-4"})}),A.length>0&&e.jsxs(se,{className:"bg-amber-600 hover:bg-amber-700 font-bold",onClick:E,disabled:$,children:[$?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(K5,{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(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{className:"w-12",children:e.jsx(Rn,{checked:Z.length>0&&A.length===Z.length,onCheckedChange:_})}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-name",children:"Name"}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-phone",children:"Phone"}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-email",children:"Email"}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-loc",children:"Preferred Location"}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-address",children:"Main Address"}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-age",children:"Age"}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-exp",children:"Experience"}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-edu",children:"Education"}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-date",children:"Applied On"}),e.jsx(me,{className:"text-right","data-testid":"onboarding-non-opps-th-actions",children:"Actions"})]})}),e.jsx(Es,{children:N?e.jsx(ct,{children:e.jsxs(de,{colSpan:11,className:"text-center py-20",children:[e.jsx(ss,{className:"w-8 h-8 mx-auto animate-spin text-amber-600 mb-2"}),e.jsx("p",{className:"text-slate-500 text-sm",children:"Loading applications..."})]})}):Z.length===0?e.jsx(ct,{children:e.jsxs(de,{colSpan:11,className:"text-center py-12 text-slate-500","data-testid":"onboarding-non-opps-empty-state",children:[e.jsx(ev,{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((F,B)=>e.jsxs(ct,{"data-testid":`onboarding-non-opps-row-${B}`,className:A.includes(F.id)?"bg-amber-50/50":"",children:[e.jsx(de,{children:e.jsx(Rn,{checked:A.includes(F.id),onCheckedChange:()=>M(F.id)})}),e.jsx(de,{children:e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900","data-testid":`onboarding-non-opps-name-${B}`,children:F.name}),e.jsx("p",{className:"text-slate-500 text-sm","data-testid":`onboarding-non-opps-id-${B}`,children:F.registrationNumber})]})}),e.jsx(de,{className:"text-slate-900","data-testid":`onboarding-non-opps-phone-${B}`,children:F.phone}),e.jsx(de,{className:"text-slate-600","data-testid":`onboarding-non-opps-email-${B}`,children:F.email}),e.jsx(de,{children:e.jsxs("div",{"data-testid":`onboarding-non-opps-pref-loc-${B}`,children:[e.jsx("p",{className:"text-slate-900",children:F.preferredLocation}),e.jsx("p",{className:"text-slate-500 text-sm",children:F.state})]})}),e.jsx(de,{className:"text-slate-600 max-w-xs truncate","data-testid":`onboarding-non-opps-address-${B}`,children:F.residentialAddress}),e.jsx(de,{className:"text-slate-900","data-testid":`onboarding-non-opps-age-${B}`,children:F.age}),e.jsx(de,{className:"text-slate-600","data-testid":`onboarding-non-opps-experience-${B}`,children:F.pastExperience}),e.jsx(de,{className:"text-slate-900","data-testid":`onboarding-non-opps-education-${B}`,children:F.education}),e.jsx(de,{className:"text-slate-600","data-testid":`onboarding-non-opps-date-${B}`,children:Ht(F.submissionDate)}),e.jsx(de,{className:"text-right",children:e.jsx("div",{className:"flex justify-end gap-2",children:e.jsx(se,{variant:"outline",size:"sm",onClick:()=>t(F.id),"data-testid":`onboarding-non-opps-view-btn-${B}`,children:"View"})})})]},F.id))})]}),u&&u.totalPages>1&&e.jsx("div",{className:"py-4 border-t border-slate-200",children:e.jsx(Yl,{children:e.jsxs(Zl,{children:[e.jsx(an,{children:e.jsx(Ql,{onClick:()=>p(F=>Math.max(1,F-1)),className:m===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(u.totalPages)].map((F,B)=>{const D=B+1;return D===1||D===u.totalPages||D>=m-1&&D<=m+1?e.jsx(an,{children:e.jsx(Ci,{isActive:m===D,onClick:()=>p(D),className:"cursor-pointer",children:D})},D):D===m-2||D===m+2?e.jsx(an,{children:e.jsx(Jl,{})},D):null}),e.jsx(an,{children:e.jsx(Xl,{onClick:()=>p(F=>Math.min(u.totalPages,F+1)),className:m===u.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})}function M7({application:t,isNonResponsive:s,isAdmin:n,onBack:r,onOpenWorknotes:a}){return e.jsxs(e.Fragment,{children:[s&&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(Xv,{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"})]})]}),n&&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 l=document.querySelector('[value="worknotes"]');l==null||l.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:r,className:"shrink-0","data-testid":"onboarding-details-back-button",children:e.jsx($r,{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})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsxs(se,{variant:"outline",className:"relative hover:bg-amber-50 hover:border-amber-300 hover:text-amber-700 transition-all shadow-sm",onClick:a,"data-testid":"onboarding-details-view-work-notes",children:[e.jsx(zr,{className:"w-4 h-4 mr-2"}),"View Work Notes"]})})]})]})}var F7=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],B7=F7.reduce((t,s)=>{const n=hu(`Primitive.${s}`),r=v.forwardRef((a,l)=>{const{asChild:c,...d}=a,h=c?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(h,{...d,ref:l})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),$7="Separator",l1="horizontal",q7=["horizontal","vertical"],dE=v.forwardRef((t,s)=>{const{decorative:n,orientation:r=l1,...a}=t,l=z7(r)?r:l1,d=n?{role:"none"}:{"aria-orientation":l==="vertical"?l:void 0,role:"separator"};return e.jsx(B7.div,{"data-orientation":l,...d,...a,ref:s})});dE.displayName=$7;function z7(t){return q7.includes(t)}var U7=dE;function zd({className:t,orientation:s="horizontal",decorative:n=!0,...r}){return e.jsx(U7,{"data-slot":"separator-root",decorative:n,orientation:s,className:Pt("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 V7({application:t,canEditStatutory:s,isEditingStatutory:n,isSavingStatutory:r,statutoryForm:a,onEditFirmType:l,onEditStatutory:c,onCancelEditStatutory:d,onSaveStatutory:h,onStatutoryFormChange:x}){return e.jsxs(Le,{"data-testid":"onboarding-applicant-info-card",children:[e.jsx(tt,{children:e.jsx(nt,{children:"Applicant Information"})}),e.jsxs(Me,{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(kr,{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(qr,{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(Zv,{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(kr,{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(sI,{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(Er,{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(Er,{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(Ml,{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:l,"data-testid":"onboarding-applicant-info-edit-firm-type",children:["Proposed Firm Type",e.jsx(nv,{className:"w-3 h-3 text-slate-300 group-hover:text-amber-600 transition-colors"})]}),e.jsx("p",{className:"text-slate-900 font-black text-amber-700 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(ow,{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(ow,{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(kr,{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(kr,{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(Fo,{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(_2,{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(zd,{}),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(mu,{className:"w-4 h-4 text-amber-600"})," Statutory & Bank Information"]}),s&&!n&&e.jsxs(se,{variant:"ghost",size:"sm",onClick:c,className:"h-8 text-amber-600 hover:text-amber-700 hover:bg-amber-50 gap-1.5","data-testid":"onboarding-applicant-info-edit-statutory",children:[e.jsx(nv,{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-amber-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(ce,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Legal Entity Name"}),e.jsx(ot,{value:a.accountHolderName,onChange:f=>x({...a,accountHolderName:f.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(ce,{className:"text-[10px] uppercase font-bold text-slate-500",children:"PAN Number"}),e.jsx(ot,{value:a.panNumber,onChange:f=>x({...a,panNumber:f.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(ce,{className:"text-[10px] uppercase font-bold text-slate-500",children:"GST Number"}),e.jsx(ot,{value:a.gstNumber,onChange:f=>x({...a,gstNumber:f.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(ce,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Registered Address"}),e.jsx(ot,{value:a.registeredAddress,onChange:f=>x({...a,registeredAddress:f.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(ce,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Bank Name"}),e.jsx(ot,{value:a.bankName,onChange:f=>x({...a,bankName:f.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(ce,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Account Number"}),e.jsx(ot,{value:a.accountNumber,onChange:f=>x({...a,accountNumber:f.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(ce,{className:"text-[10px] uppercase font-bold text-slate-500",children:"IFSC Code"}),e.jsx(ot,{value:a.ifscCode,onChange:f=>x({...a,ifscCode:f.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:h,disabled:r,className:"bg-amber-600 hover:bg-amber-700","data-testid":"onboarding-applicant-info-statutory-save",children:r?e.jsx(ss,{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 H7=({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(Fo,{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 l,c;return(((l=r.question)==null?void 0:l.order)||0)-(((c=a.question)==null?void 0:c.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(Fo,{className:"w-5 h-5 text-amber-600"}),e.jsx("h3",{className:"text-slate-900",children:"Questionnaire Responses"})]}),n!==void 0&&e.jsxs(Ae,{className:"bg-amber-600","data-testid":"onboarding-questionnaire-total-score",children:["Score: ",n,"/100"]})]}),e.jsx("div",{className:"space-y-6",children:s.map((r,a)=>{const l=r.question,c=(l==null?void 0:l.questionText)||"Unknown Question",d=r.responseValue||"No Answer",h=(l==null?void 0:l.sectionName)||"General",x=(l==null?void 0:l.questionOptions)||[],f=x.find(g=>g.optionText===d),m=f?f.score:0,p=Math.max(...x.map(g=>g.score||0),0),u=typeof d=="string"&&d.startsWith("data:"),j=u&&d.startsWith("data:image");return e.jsxs("div",{className:"border border-slate-200 rounded-lg p-5 hover:border-amber-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-amber-100 flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-amber-600",children:a+1})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ae,{variant:"outline",className:"text-slate-600 bg-slate-50","data-testid":`onboarding-questionnaire-item-section-${a}`,children:h}),x.length>0&&p>0&&e.jsxs(Ae,{className:m>0?"bg-green-600":"bg-slate-400","data-testid":`onboarding-questionnaire-item-score-${a}`,children:[m,"/",p]})]}),e.jsx("h4",{className:"text-slate-900 font-medium","data-testid":`onboarding-questionnaire-item-text-${a}`,children:c})]})]}),e.jsx("div",{className:"ml-11",children:j?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)})})]})},W7=Vv("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 mi({className:t,variant:s,...n}){return e.jsx("div",{"data-slot":"alert",role:"alert",className:Pt(W7({variant:s}),t),...n})}function Hi({className:t,...s}){return e.jsx("div",{"data-slot":"alert-title",className:Pt("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...s})}function fi({className:t,...s}){return e.jsx("div",{"data-slot":"alert-description",className:Pt("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...s})}var G7={};function K7(t){const{application:s,activeTab:n,setActiveTab:r,processStages:a,documents:l,interviews:c,expandedBranches:d,setExpandedBranches:h,setSelectedStage:x,setShowDocumentsModal:f,setShowUploadForm:m,handleRetriggerEvaluators:p,handleCancelInterview:u,setSelectedEvaluationForView:j,setShowFeedbackDetailsModal:g,renderFddAuditContent:y,eorProgress:N,eorData:S,eorChecklist:C,setUploadDocType:w,isAdmin:R,fetchApplication:P,fetchEorData:A,deposits:I,getDeposit:$,paymentConfigs:T,setPreviewDoc:E,setShowPreviewModal:_,auditLoading:M,auditLogs:q,auditLogActionBadgeClass:G}=t,Z=z=>String(z||"").trim().toLowerCase().replace(/[_\s-]+/g," "),W=(z,F)=>{var O,V,K;const B=[(O=z==null?void 0:z.user)==null?void 0:O.role,(V=z==null?void 0:z.user)==null?void 0:V.roleCode,(K=z==null?void 0:z.metadata)==null?void 0:K.role].map(Z),D=F.map(Z);return B.some(Y=>D.includes(Y))};return e.jsx(Le,{"data-testid":"onboarding-details-tabs-container",children:e.jsxs(Pn,{value:n,onValueChange:r,children:[e.jsx(tt,{className:"pb-4 px-4 sm:px-6",children:e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x -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(Me,{children:[e.jsx(Gt,{value:"questionnaire",className:"space-y-6","data-testid":"onboarding-tab-content-questionnaire",children:e.jsx(H7,{application:s})}),e.jsxs(Gt,{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(Ae,{className:"bg-amber-600","data-testid":"onboarding-progress-percentage-badge",children:[s.progress,"% Complete"]})]}),e.jsx(ji,{value:s.progress,className:"h-3 mb-6","data-testid":"onboarding-progress-bar"})]}),e.jsx("div",{className:"relative","data-testid":"onboarding-progress-stages-container",children:(()=>{const z={1:["DD-ZM","RBM"],2:["DD Lead","ZBH"],3:["NBH","DD Head"]},F={LOI_APPROVAL:["DD Head","NBH"],LOA_APPROVAL:["DD Head","NBH"]},B=O=>(s.participants||[]).filter(K=>{var U,X,ne,oe,re,ge,ve,Se,We,Ce,fe,Ye;return((U=K.metadata)==null?void 0:U.stageCode)===O||((ne=(X=K.metadata)==null?void 0:X.allAssignments)==null?void 0:ne.includes(O))||typeof O=="number"&&(((oe=K.metadata)==null?void 0:oe.interviewLevel)===O||((re=K.metadata)==null?void 0:re.interviewLevel)===String(O)||((ve=(ge=K.metadata)==null?void 0:ge.allAssignments)==null?void 0:ve.includes(O))||((We=(Se=K.metadata)==null?void 0:Se.allAssignments)==null?void 0:We.includes(String(O))))||typeof O=="string"&&!isNaN(Number(O))&&(((Ce=K.metadata)==null?void 0:Ce.interviewLevel)===Number(O)||((Ye=(fe=K.metadata)==null?void 0:fe.allAssignments)==null?void 0:Ye.includes(Number(O))))?!0:typeof O=="number"?W(K,z[O]||[]):W(K,F[O]||[])}).map(K=>{var X,ne,oe,re,ge;const Y=typeof O=="number"?`INTERVIEW_LEVEL_${O}`:O,U=(s.stageApprovals||[]).find(ve=>ve.stageCode===Y&&String(ve.actorUserId)===String(K.userId));return{name:((X=K.user)==null?void 0:X.name)||((ne=K.user)==null?void 0:ne.fullName)||"Unknown",role:((oe=K.user)==null?void 0:oe.role)||((re=K.user)==null?void 0:re.roleCode)||((ge=K.metadata)==null?void 0:ge.role)||"Reviewer",status:U?U.decision==="Approved"?"approved":"rejected":"pending"}}),D=(O,V)=>{const Y={"1st Level Interview":1,"2nd Level Interview":2,"3rd Level Interview":3,"LOI Approval":"LOI_APPROVAL",LOA:"LOA_APPROVAL"}[O];if(!Y)return null;const U=B(Y);return U.length===0?null:e.jsx("div",{className:"flex flex-wrap gap-2 mt-3","data-testid":`onboarding-stage-approvers-${V}`,children:U.map((X,ne)=>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-${V}-${ne}`,children:[e.jsx("div",{className:Pt("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(oe=>oe[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:Pt("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-amber-400"),"data-testid":`onboarding-stage-approver-status-dot-${V}-${ne}`}),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()]})]},ne))})};return a.map((O,V)=>e.jsxs("div",{"data-testid":`onboarding-progress-stage-${V}`,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 ${O.status==="completed"?"bg-green-500 border-green-500 text-white shadow-md":O.status==="active"?O.isLocked?"bg-slate-400 border-slate-400 text-white":"bg-amber-500 border-amber-500 text-white animate-pulse-subtle":"bg-white border-slate-300 text-slate-400 shadow-none"}`,"data-testid":`onboarding-progress-stage-icon-${V}`,children:O.isParallel?e.jsx(tv,{className:"w-5 h-5"}):O.isLocked?e.jsxs("div",{className:"group relative",children:[e.jsx(sv,{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-amber-400 flex items-center gap-1",children:[e.jsx(Ks,{className:"w-3 h-3"})," Stage Locked"]}),e.jsx("span",{children:O.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:O.status==="completed"?e.jsx(Fn,{className:"w-6 h-6"}):O.status==="active"?e.jsx(Js,{className:"w-5 h-5 text-white"}):e.jsx("div",{className:"w-3 h-3 bg-slate-300 rounded-full"})})}),V<a.length-1&&!O.isParallel&&e.jsx("div",{className:`absolute top-10 left-1/2 -translate-x-1/2 w-0.5 h-full z-0 ${O.status==="completed"?"bg-green-500/30":"bg-slate-200"}`,"data-testid":`onboarding-progress-stage-connector-${V}`})]}),e.jsxs("div",{className:"flex-1 pt-1",children:[e.jsx("p",{className:Pt("font-bold transition-colors",O.status==="completed"?"text-green-700":O.status==="active"?"text-amber-700":"text-slate-900"),"data-testid":`onboarding-progress-stage-name-${V}`,children:O.name}),O.description&&e.jsx("p",{className:"text-slate-600 text-sm mt-0.5 leading-relaxed","data-testid":`onboarding-progress-stage-desc-${V}`,children:O.description}),D(O.name,V),O.evaluators&&O.evaluators.length>0&&!["LOI Approval","LOA","1st Level Interview","2nd Level Interview","3rd Level Interview"].includes(O.name)&&e.jsxs("p",{className:"text-amber-600 text-xs mt-1.5 flex items-center gap-1 bg-amber-50 w-fit px-2 py-0.5 rounded border border-amber-100","data-testid":`onboarding-progress-stage-evaluators-${V}`,children:[e.jsx(kr,{className:"w-3 h-3"}),"Evaluators: ",O.evaluators.join(" + ")]}),(()=>{var ge;const K={3:2,4:2,5:2,6:2,8:2,12:2},Y=Number(O.id),U=K[Y],ne={3:1,4:1,5:2,6:3,8:"LOI_APPROVAL",12:"LOA_APPROVAL"}[Y],oe=ne?B(ne).length:((ge=O.evaluators)==null?void 0:ge.length)||0,re=Y===3?O.status==="completed":O.status!=="pending";return U&&oe<U&&s.status!=="Rejected"&&re?e.jsx("div",{className:"mt-2","data-testid":`onboarding-progress-stage-warning-${V}`,children:e.jsxs(mi,{variant:"destructive",className:"py-2 px-3 border-amber-200 bg-amber-50 text-amber-800",children:[e.jsx(Ks,{className:"h-4 w-4 text-amber-600"}),e.jsx(Hi,{className:"text-xs font-semibold",children:"Missing Evaluators"}),e.jsxs(fi,{className:"text-xs",children:[oe===0?"Respective role users were not found for this location.":`Some roles (${oe}/${U}) are missing for this location.`,e.jsxs(se,{variant:"link",size:"sm",className:"h-auto p-0 ml-1 text-xs text-amber-700 underline",onClick:p,"data-testid":`onboarding-progress-stage-retrigger-${V}`,children:[e.jsx(Rr,{className:"w-3 h-3 mr-1"}),"Re-trigger Assignment"]})]})]})}):null})(),(()=>{const K=l.filter(Y=>{var U;return Y.stage===O.name||!Y.stage&&((U=Y.documentType)==null?void 0:U.toLowerCase().includes(O.name.toLowerCase().split(" ")[0]))}).length;return e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("button",{onClick:()=>{x(O.name),f(!0),K===0&&m(!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-${V}`,children:[e.jsx(fs,{className:"w-3.5 h-3.5"}),K>0?`${K} Documents`:"Upload"]})})})(),e.jsxs("p",{className:"text-slate-500 mt-1 text-xs","data-testid":`onboarding-progress-stage-status-text-${V}`,children:[O.status==="completed"&&O.date&&`Completed: ${Ht(O.date)}`,O.status==="active"&&"In Progress",O.status==="pending"&&"Pending"]})]})]}),O.isParallel&&O.branches&&e.jsxs("div",{className:"ml-5 mb-8","data-testid":`onboarding-progress-parallel-branches-${V}`,children:[O.branches.map((K,Y)=>{const U=K.name.toLowerCase().replace(/\s+/g,"-"),X=d[U],ne=K.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:()=>h(oe=>({...oe,[U]:!oe[U]})),className:`flex-1 flex items-center gap-3 p-4 rounded-lg border-2 transition-all hover:shadow-md ${ne==="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-${U}`,children:[X?e.jsx(la,{className:`w-5 h-5 ${ne==="blue"?"text-blue-600":"text-green-600"}`}):e.jsx(el,{className:`w-5 h-5 ${ne==="blue"?"text-blue-600":"text-green-600"}`}),e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center ${ne==="blue"?"bg-blue-200":"bg-green-200"}`,children:e.jsx(tv,{className:`w-4 h-4 ${ne==="blue"?"text-blue-700":"text-green-700"}`})}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsx("p",{className:`${ne==="blue"?"text-blue-900":"text-green-900"} font-semibold tracking-tight`,children:K.name}),e.jsxs("p",{className:`text-[10px] uppercase font-bold tracking-wider ${ne==="blue"?"text-blue-500":"text-green-500"}`,children:[K.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-${U}`,children:K.stages.map((oe,re)=>e.jsx("div",{className:"relative",children:e.jsx("div",{className:"flex gap-4 text-xs","data-testid":`onboarding-progress-branch-stage-${U}-${re}`,children:(()=>{const ge=l.filter(Se=>{var We;return((We=Se.documentType)==null?void 0:We.toLowerCase().includes(oe.name.toLowerCase().split(" ")[0]))||Se.stage===oe.name}),ve=oe.status==="completed"||ge.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 ${ve?`${ne==="blue"?"bg-blue-500 border-blue-500":"bg-green-500 border-green-500"}`:oe.status==="active"?"bg-amber-500 border-amber-500 text-white shadow-sm":"bg-white border-slate-300 text-slate-400"}`,"data-testid":`onboarding-progress-branch-stage-icon-${U}-${re}`,children:ve?e.jsx(Bn,{className:"w-4 h-4 text-white",strokeWidth:3}):oe.status==="active"?e.jsx(Js,{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-${U}-${re}`,children:oe.name}),oe.description&&e.jsx("p",{className:"text-slate-500 text-xs mt-0.5",children:oe.description}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("button",{onClick:()=>{x(oe.name),f(!0),ge.length===0&&m(!0)},className:Pt("text-[10px] font-medium flex items-center gap-1 transition-colors",ne==="blue"?"text-blue-600 hover:text-blue-800":"text-green-600 hover:text-green-800"),"data-testid":`onboarding-progress-branch-stage-docs-${U}-${re}`,children:[e.jsx(fs,{className:"w-2.5 h-2.5"}),ge.length>0?`${ge.length} Docs`:"Upload"]})}),e.jsx("p",{className:"text-slate-400 text-[10px] mt-1","data-testid":`onboarding-progress-branch-stage-status-${U}-${re}`,children:ve&&oe.date?`Done: ${Ht(oe.date)}`:ve&&ge.length>0?`Uploaded: ${Ht(ge[0].updatedAt||ge[0].createdAt)}`:oe.status==="active"?"Evaluating":"Pending"})]})]})})()})},oe.id))})]},Y)}),e.jsx("div",{className:"h-8 w-0.5 bg-slate-300 ml-5 opacity-50"})]})]},O.id))})()})]}),e.jsxs(Gt,{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-amber-600 hover:bg-amber-700","data-testid":"onboarding-documents-upload-tab-button",onClick:()=>{x(null),f(!0),m(!0)},children:[e.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Upload Document"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ks,{"data-testid":"onboarding-documents-table",children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{className:"min-w-[200px]",children:"File Name"}),e.jsx(me,{className:"min-w-[120px]",children:"Type"}),e.jsx(me,{className:"min-w-[120px]",children:"Upload Date"}),e.jsx(me,{className:"min-w-[150px]",children:"Uploader"}),e.jsx(me,{className:"text-right min-w-[100px]",children:"Actions"})]})}),e.jsx(Es,{children:l.length===0?e.jsx(ct,{"data-testid":"onboarding-documents-empty-row",children:e.jsx(de,{colSpan:5,className:"text-center py-8 text-slate-500",children:"No documents uploaded yet"})}):l.map((z,F)=>{var B;return e.jsxs(ct,{"data-testid":`onboarding-document-row-${F}`,children:[e.jsxs(de,{className:"flex items-center gap-2",children:[e.jsx(fs,{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-${F}`,children:z.fileName})]}),e.jsx(de,{"data-testid":`onboarding-document-type-${F}`,children:z.documentType}),e.jsx(de,{children:Ht(z.createdAt)}),e.jsx(de,{"data-testid":`onboarding-document-uploader-${F}`,children:((B=z.uploader)==null?void 0:B.fullName)||(z.uploadedBy?"Unknown User":"Applicant")}),e.jsx(de,{children:e.jsx("div",{className:"flex justify-end gap-2",children:e.jsx(se,{size:"sm",variant:"outline","data-testid":`onboarding-document-download-${F}`,onClick:()=>{const D=G7.NEXT_PUBLIC_API_URL||"http://localhost:5000";window.open(`${D}/${z.filePath}`,"_blank")},children:e.jsx(Ni,{className:"w-3 h-3"})})})})]},z.id)})})]})})]}),e.jsxs(Gt,{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",children:e.jsxs(ks,{"data-testid":"onboarding-interviews-scheduled-table",children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{className:"min-w-[100px]",children:"Level"}),e.jsx(me,{className:"min-w-[180px]",children:"Date & Time"}),e.jsx(me,{className:"min-w-[100px]",children:"Type"}),e.jsx(me,{className:"min-w-[200px]",children:"Location/Link"}),e.jsx(me,{className:"min-w-[120px]",children:"Status"}),e.jsx(me,{className:"min-w-[150px]",children:"Scheduled By"}),e.jsx(me,{className:"text-right",children:"Actions"})]})}),e.jsx(Es,{children:!c||c.length===0?e.jsx(ct,{"data-testid":"onboarding-interviews-empty-row",children:e.jsx(de,{colSpan:7,className:"text-center py-8 text-slate-500",children:"No interviews scheduled yet"})}):(Array.isArray(c)?c:[]).map((z,F)=>{var B,D;return e.jsxs(ct,{"data-testid":`onboarding-interview-row-${F}`,children:[e.jsxs(de,{className:"font-medium",children:["Level ",z.level]}),e.jsx(de,{children:z.scheduleDate?new Date(z.scheduleDate).toLocaleString():"N/A"}),e.jsx(de,{className:"capitalize",children:z.interviewType}),e.jsx(de,{children:(B=z.interviewType)!=null&&B.toLowerCase().includes("virtual")?e.jsx("a",{href:z.linkOrLocation,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline","data-testid":`onboarding-interview-link-${F}`,children:"Join Meeting"}):e.jsx("span",{"data-testid":`onboarding-interview-location-${F}`,children:z.linkOrLocation})}),e.jsx(de,{children:e.jsx(Ae,{variant:z.status==="Completed"?"default":"secondary","data-testid":`onboarding-interview-status-${F}`,children:z.status})}),e.jsx(de,{children:((D=z.scheduler)==null?void 0:D.fullName)||z.scheduledBy||"N/A"}),e.jsx(de,{className:"text-right",children:(z.status==="Scheduled"||z.status==="scheduled")&&e.jsx(se,{variant:"ghost",size:"sm",className:"text-red-500 hover:text-red-700 hover:bg-red-50 h-8 px-2","data-testid":`onboarding-interview-cancel-${F}`,onClick:()=>u(z.id),children:"Cancel"})})]},z.id)})})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900 mb-4",children:"Interview Feedback"}),!c||c.length===0?e.jsx("p",{className:"text-slate-500 italic","data-testid":"onboarding-interviews-no-feedback",children:"No interviews scheduled."}):(Array.isArray(c)?c:[]).map((z,F)=>e.jsxs("div",{className:"mb-6 border p-4 rounded-lg bg-slate-50/50","data-testid":`onboarding-interview-feedback-block-${F}`,children:[e.jsxs("h4",{className:"font-semibold text-slate-800 mb-2",children:["Level ",z.level," Interview",e.jsxs("span",{className:"font-normal text-slate-500 text-sm ml-2",children:["(",Ht(z.scheduleDate)," - ",z.interviewType,")"]})]}),z.evaluations&&z.evaluations.length>0?e.jsxs(ks,{"data-testid":`onboarding-interview-evaluations-table-${F}`,children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Interviewer"}),e.jsx(me,{children:"Role"}),e.jsx(me,{children:z.level===1?"Score (KT Matrix)":"Overall Score"}),e.jsx(me,{children:"Remarks"}),e.jsx(me,{children:"Recommendation"})]})}),e.jsx(Es,{children:z.evaluations.map((B,D)=>{var O,V,K;return e.jsxs(ct,{"data-testid":`onboarding-interview-evaluation-row-${F}-${D}`,children:[e.jsx(de,{className:"font-medium",children:(O=B.evaluator)==null?void 0:O.fullName}),e.jsx(de,{children:((K=(V=B.evaluator)==null?void 0:V.role)==null?void 0:K.roleName)||"N/A"}),e.jsx(de,{children:B.ktMatrixScore?e.jsxs(Ae,{variant:z.level===1?Number(B.ktMatrixScore)>=50?"outline":"destructive":Number(B.ktMatrixScore)>=5?"outline":"destructive","data-testid":`onboarding-interview-evaluation-score-${F}-${D}`,children:[B.ktMatrixScore,"/",z.level===1?"100":"10"]}):"N/A"}),e.jsx(de,{className:"max-w-xs truncate",title:B.remarks||B.qualitativeFeedback,children:B.remarks?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"font-medium text-slate-800",children:B.remarks}),B.feedbackDetails&&B.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-${F}-${D}`,onClick:()=>{j({...B,interview:z}),g(!0)},children:"View Detailed Feedback"})]}):B.feedbackDetails&&B.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-${F}-${D}`,onClick:()=>{j({...B,interview:z}),g(!0)},children:"View Detailed Feedback"}):B.qualitativeFeedback||"-"}),e.jsx(de,{"data-testid":`onboarding-interview-evaluation-rec-${F}-${D}`,children:B.recommendation||"-"})]},B.id)})})]}):e.jsx("p",{className:"text-sm text-slate-500 italic pl-2",children:"No feedback recorded yet."})]},z.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(Gt,{value:"fdd",className:"space-y-6","data-testid":"onboarding-tab-content-fdd",children:y()}),e.jsxs(Gt,{value:"eor",className:"space-y-4","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(Ae,{className:"bg-amber-600","data-testid":"onboarding-eor-progress-badge",children:[Math.round(N),"% Complete"]})]}),e.jsx(ji,{value:N,className:"h-3 mb-6","data-testid":"onboarding-eor-progress-bar"}),e.jsx("div",{className:"space-y-3","data-testid":"onboarding-eor-checklist",children:((S==null?void 0:S.items)||C).map((z,F)=>{const B=z.description||z.item,D=!!z.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-${F}`,children:[e.jsx(Rn,{checked:z.isCompliant||z.completed,className:"pointer-events-none shrink-0","data-testid":`onboarding-eor-checkbox-${F}`}),e.jsxs("div",{className:"flex flex-col flex-1 min-w-0 cursor-pointer","data-testid":`onboarding-eor-clickable-${F}`,onClick:()=>{x(`EOR: ${B}`),w(B),f(!0),m(!D)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:z.isCompliant||z.completed?"text-slate-900 font-bold":"text-slate-600 font-medium",children:B}),D&&!z.isCompliant&&e.jsx(Ae,{variant:"outline",className:"text-[10px] h-4 px-1.5 bg-amber-50 text-amber-600 border-amber-200 uppercase tracking-wider font-bold",children:"Needs Verification"})]}),D&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-blue-600 font-semibold mt-1",children:[e.jsx(fs,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"truncate",children:z.proofDocument.fileName})]}),!D&&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:[D&&!z.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-${F}`,onClick:async()=>{await(await Tl(async()=>{const{eorService:O}=await Promise.resolve().then(()=>Gx);return{eorService:O}},void 0)).eorService.updateItem(S.id,{...z,isCompliant:!0}),A(),ee.success(`${B} 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-${F}`,onClick:async()=>{await(await Tl(async()=>{const{eorService:O}=await Promise.resolve().then(()=>Gx);return{eorService:O}},void 0)).eorService.updateItem(S.id,{...z,isCompliant:!1,proofDocumentId:null}),A(),ee.success(`${B} rejected.`)},children:"Reject"})]}),(z.isCompliant||z.completed)&&e.jsx("div",{className:"bg-green-100 p-1.5 rounded-full","data-testid":`onboarding-eor-done-icon-${F}`,children:e.jsx(Ys,{className:"w-4 h-4 text-green-600"})}),!D&&e.jsx("div",{className:"p-2 text-slate-300 group-hover:text-amber-500 transition-colors","data-testid":`onboarding-eor-upload-hint-${F}`,children:e.jsx(Dr,{className:"w-4 h-4"})})]})]},z.id)})}),N===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(Fl,{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 z=S==null?void 0:S.id;if(!z)throw new Error("Checklist ID not found");await(await Tl(async()=>{const{eorService:F}=await Promise.resolve().then(()=>Gx);return{eorService:F}},void 0)).eorService.submitAudit(z,{status:"Completed",overallComments:"EOR Checklist verified and audit completed."}),ee.success("EOR Audit completed successfully!"),P(),A()}catch(z){ee.error(z.message||"Failed to complete EOR audit")}},children:"Complete Audit & Proceed"})]})})]}),e.jsxs(Gt,{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(Ae,{variant:"outline",className:"bg-slate-50 text-slate-500 border-slate-200","data-testid":"onboarding-payments-count-badge",children:[I.length," Payment Record(s)"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(()=>{const z=$("SECURITY_DEPOSIT"),F=T.SECURITY_DEPOSIT,B=(F==null?void 0:F.amount)||5e5;return e.jsx(Le,{className:Pt("border-l-4",(z==null?void 0:z.status)==="Verified"?"border-l-green-500":(z==null?void 0:z.status)==="Rejected"?"border-l-red-500":"border-l-amber-500"),"data-testid":"onboarding-payment-card-security",children:e.jsxs(Me,{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-amber-50 flex items-center justify-center text-amber-600",children:e.jsx(Fo,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-semibold text-slate-700",children:"Security Deposit"})]}),e.jsx(Ae,{className:Pt((z==null?void 0:z.status)==="Verified"?"bg-green-100 text-green-700 hover:bg-green-100":(z==null?void 0:z.status)==="Rejected"?"bg-red-100 text-red-700 hover:bg-red-100":"bg-amber-100 text-amber-700 hover:bg-amber-100"),"data-testid":"onboarding-payment-status-security",children:(z==null?void 0:z.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((z==null?void 0:z.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:["₹",B.toLocaleString()]})]}),(z==null?void 0:z.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: ",z.paymentReference]}),z.verifiedAt&&e.jsx("span",{children:Ht(z.verifiedAt)})]}),(z==null?void 0:z.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:['"',z.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:[l.filter(D=>{var O,V;return((O=D.documentType)==null?void 0:O.toLowerCase().includes("security"))&&((V=D.documentType)==null?void 0:V.toLowerCase().includes("deposit"))}).map((D,O)=>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-${O}`,children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.jsx(fs,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-[10px] font-medium text-slate-700 truncate",children:D.fileName||D.name})]}),e.jsx(se,{variant:"ghost",size:"sm",className:"h-6 px-2 text-[10px] text-amber-600 hover:text-amber-700 hover:bg-amber-50","data-testid":`onboarding-payment-doc-view-security-${O}`,onClick:()=>{E(D),_(!0)},children:"View"})]},O)),l.filter(D=>{var O,V;return((O=D.documentType)==null?void 0:O.toLowerCase().includes("security"))&&((V=D.documentType)==null?void 0:V.toLowerCase().includes("deposit"))}).length===0&&e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"No proof uploaded"})]})]})]})]})})})(),(()=>{const z=$("FIRST_FILL"),F=T.FIRST_FILL,B=(F==null?void 0:F.amount)||15e5;return e.jsx(Le,{className:Pt("border-l-4",(z==null?void 0:z.status)==="Verified"?"border-l-green-500":(z==null?void 0:z.status)==="Rejected"?"border-l-red-500":"border-l-amber-500"),"data-testid":"onboarding-payment-card-first-fill",children:e.jsxs(Me,{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(Fl,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-semibold text-slate-700",children:"First Fill"})]}),e.jsx(Ae,{className:Pt((z==null?void 0:z.status)==="Verified"?"bg-green-100 text-green-700 hover:bg-green-100":(z==null?void 0:z.status)==="Rejected"?"bg-red-100 text-red-700 hover:bg-red-100":"bg-amber-100 text-amber-700 hover:bg-amber-100"),"data-testid":"onboarding-payment-status-first-fill",children:(z==null?void 0:z.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((z==null?void 0:z.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:["₹",B.toLocaleString()]})]}),(z==null?void 0:z.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: ",z.paymentReference]}),z.verifiedAt&&e.jsx("span",{children:Ht(z.verifiedAt)})]}),(z==null?void 0:z.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:['"',z.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:[l.filter(D=>{var O,V;return((O=D.documentType)==null?void 0:O.toLowerCase().includes("first"))&&((V=D.documentType)==null?void 0:V.toLowerCase().includes("fill"))}).map((D,O)=>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-${O}`,children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.jsx(fs,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-[10px] font-medium text-slate-700 truncate",children:D.fileName||D.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-${O}`,onClick:()=>{E(D),_(!0)},children:"View"})]},O)),l.filter(D=>{var O,V;return((O=D.documentType)==null?void 0:O.toLowerCase().includes("first"))&&((V=D.documentType)==null?void 0:V.toLowerCase().includes("fill"))}).length===0&&e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"No proof uploaded"})]})]})]})]})})})()]})]}),e.jsx(Gt,{value:"audit","data-testid":"onboarding-tab-content-audit",children:e.jsx(kb,{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:M?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-amber-600"}),e.jsx("span",{className:"ml-2 text-sm text-slate-500",children:"Loading audit trail…"})]}):q.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."}):q.map((z,F)=>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-${F}`,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(Ae,{variant:"outline",className:Pt("shrink-0 text-[10px] font-semibold uppercase tracking-wide",G(z.action)),"data-testid":`onboarding-audit-log-action-${F}`,children:String(z.action||"EVENT").replace(/_/g," ")}),z.stage?e.jsx("span",{className:"max-w-[200px] truncate text-[11px] text-slate-500",title:z.stage,"data-testid":`onboarding-audit-log-stage-${F}`,children:z.stage}):null]}),e.jsx("time",{className:"shrink-0 text-xs tabular-nums text-slate-400",dateTime:z.timestamp,"data-testid":`onboarding-audit-log-time-${F}`,children:Ht(z.timestamp)})]}),e.jsx("p",{className:"mt-2 text-[13px] leading-relaxed text-slate-800","data-testid":`onboarding-audit-log-desc-${F}`,children:z.description||"—"}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-slate-500",children:[e.jsx(kr,{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-${F}`,children:z.userName||"System"}),z.userEmail?e.jsxs("span",{className:"text-slate-400","data-testid":`onboarding-audit-log-email-${F}`,children:[" · ",z.userEmail]}):null]})]})]},z.id))})})})]})]})})}function Y7(t){var G;const{application:s,permissions:n,getDeposit:r,isNonResponsive:a,isAdmin:l,currentUserStageAction:c,currentUserEvaluation:d,onOpenApproveModal:h,onOpenRejectModal:x,onOpenWorknote:f,onOpenScheduleModal:m,currentUser:p,handleGenerateDealerCodes:u,onOpenAssignArchitectureModal:j,activeInterviewForUser:g,hasSubmittedFeedback:y,setSelectedInterviewForFeedback:N,setShowKTMatrixModal:S,setShowLevel2FeedbackModal:C,setShowLevel3FeedbackModal:w,onGoToDashboard:R,showAssignModal:P,setShowAssignModal:A,selectedUser:I,setSelectedUser:$,users:T,participantType:E,setParticipantType:_,handleAddParticipant:M,isAssigningParticipant:q}=t;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Le,{"data-testid":"onboarding-details-summary-card",children:[e.jsx(tt,{children:e.jsx(nt,{children:"Summary"})}),e.jsxs(Me,{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(Ae,{className:Pt("mt-1",s.status==="Onboarded"?"bg-green-600 hover:bg-green-700 text-white":s.status==="Rejected"?"bg-red-600":"bg-amber-600"),"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(ji,{value:s.progress,className:"flex-1","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:Ht(s.deadline)})]})]})]}),(s.isShortlisted!==!1||s.status==="Submitted")&&e.jsxs(Le,{"data-testid":"onboarding-details-actions-card",children:[e.jsx(tt,{children:e.jsx(nt,{children:"Actions"})}),e.jsxs(Me,{className:"space-y-3",children:[n.isLoaLocked&&e.jsxs(mi,{variant:"destructive",className:"mb-4 bg-amber-50 border-amber-200 text-amber-800","data-testid":"onboarding-details-loa-locked-alert",children:[e.jsx(sv,{className:"w-4 h-4 text-amber-600"}),e.jsx(Hi,{className:"text-amber-900 font-semibold",children:"LOA approval locked"}),e.jsxs(fi,{className:"text-amber-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."]})]}),((G=r("FIRST_FILL"))==null?void 0:G.status)==="Verified"&&s.status!=="LOA Pending"&&!["LOA Issued","EOR In Progress","EOR Complete","Inauguration","Approved","Onboarded","Rejected"].includes(s.status)&&e.jsxs(mi,{className:"mb-4 border-violet-200 bg-violet-50/90 text-violet-950","data-testid":"onboarding-details-first-fill-verified-alert",children:[e.jsx(Xa,{className:"h-4 w-4 text-violet-700"}),e.jsx(Hi,{className:"font-semibold",children:"First Fill verified on file"}),e.jsxs(fi,{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(mi,{variant:"destructive",className:"mb-4 bg-amber-50 border-amber-200 text-amber-800","data-testid":"onboarding-details-security-locked-alert",children:[e.jsx(sv,{className:"w-4 h-4 text-amber-600"}),e.jsx(Hi,{className:"text-amber-900 font-semibold",children:"Security Details approval locked"}),e.jsxs(fi,{className:"text-amber-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 Details","Payment Pending"].includes(s.status)&&e.jsxs(mi,{className:"mb-4 border-sky-200 bg-sky-50/90 text-sky-900","data-testid":"onboarding-details-security-review-alert",children:[e.jsx(Xa,{className:"h-4 w-4 text-sky-700"}),e.jsx(Hi,{className:"text-sky-950 font-semibold",children:"Security Details review"}),e.jsxs(fi,{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&&l&&e.jsxs(mi,{variant:"destructive",className:"mb-4 bg-red-50 border-red-200 text-red-800","data-testid":"onboarding-details-non-responsive-alert",children:[e.jsx(Ks,{className:"w-4 h-4 text-red-600"}),e.jsx(Hi,{className:"text-red-900 font-black uppercase tracking-tighter",children:"⚠️ Non-Responsive Flag"}),e.jsx(fi,{className:"text-red-800 text-xs font-bold leading-tight",children:"FDD Audit has flagged this applicant. Review audit logs before approval."})]}),l&&(s.status==="Level 3 Approved"||s.status==="FDD Verification")&&(!s.fddAssignments||s.fddAssignments.length===0)&&e.jsxs(mi,{className:"mb-4 bg-amber-50 border-amber-200 text-amber-800","data-testid":"onboarding-details-fdd-assignment-alert",children:[e.jsx(Ks,{className:"w-4 h-4 text-amber-600"}),e.jsx(Hi,{className:"text-amber-900 font-bold",children:"FDD Assignment Required"}),e.jsx(fi,{className:"text-amber-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:h,"data-testid":"onboarding-details-approve-button",children:[e.jsx(Ys,{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:x,"data-testid":"onboarding-details-reject-button",children:[e.jsx(Za,{className:"w-4 h-4 mr-2"}),"Reject"]}),n.showDecisionMessage&&e.jsxs("div",{className:`w-full p-2 text-center rounded border ${(c==null?void 0:c.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 ",(c==null?void 0:c.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(zd,{}),e.jsxs(se,{variant:"outline",className:"w-full",onClick:f,"data-testid":"onboarding-details-worknote-button",children:[e.jsx(zr,{className:"w-4 h-4 mr-2"}),"Work Note"]}),n.canSchedule&&e.jsxs(se,{variant:"outline",className:"w-full",onClick:m,"data-testid":"onboarding-details-schedule-button",children:[e.jsx($n,{className:"w-4 h-4 mr-2"}),"Schedule Interview"]}),p&&["DD Admin","Super Admin"].includes(p.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(hw,{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:j,"data-testid":"onboarding-details-assign-architecture",children:[e.jsx(tv,{className:"w-4 h-4 mr-2"}),"Assign Architecture Team"]})]}),g&&!y&&e.jsxs(xb,{children:[e.jsx(gb,{asChild:!0,children:e.jsxs(se,{variant:"outline",className:"w-full","data-testid":"onboarding-details-feedback-dropdown-trigger",children:[e.jsx(mI,{className:"w-4 h-4 mr-2"}),"Interview Feedback",e.jsx(la,{className:"w-4 h-4 ml-auto"})]})}),e.jsx(vb,{className:"w-56","data-testid":"onboarding-details-feedback-dropdown-content",children:e.jsxs(ck,{"data-testid":`onboarding-details-feedback-item-${g.id}`,onClick:()=>{N(g),g.level===1?S(!0):g.level===2?C(!0):w(!0)},children:["Level ",g.level," - ",g.interviewType]},g.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(qr,{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(Js,{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(Ys,{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:R,"data-testid":"onboarding-details-goto-dashboard",children:[e.jsx(hw,{className:"w-4 h-4 mr-2"}),"Go to Dealer Dashboard"]})]}),p&&["DD Admin","Super Admin"].includes(p.role)&&e.jsxs(os,{open:P,onOpenChange:A,children:[e.jsx(Hl,{asChild:!0,children:e.jsxs(se,{variant:"outline",className:"w-full","data-testid":"onboarding-details-assign-user-trigger",children:[e.jsx(kr,{className:"w-4 h-4 mr-2"}),"Assign User"]})}),e.jsxs(ls,{"data-testid":"onboarding-details-assign-user-modal",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Assign User to Application"}),e.jsx(vs,{children:"Select a user and their role for this application."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ce,{children:"Select User"}),e.jsxs(wt,{value:I,onValueChange:$,children:[e.jsx(Ct,{className:"mt-2","data-testid":"onboarding-details-assign-user-select",children:e.jsx(St,{placeholder:"Search users..."})}),e.jsx(At,{children:T.map(Z=>e.jsxs(Pe,{value:Z.id,children:[Z.fullName," (",Z.email,")"]},Z.id))})]})]}),e.jsxs("div",{children:[e.jsx(ce,{children:"Assignment Role"}),e.jsxs(wt,{value:E,onValueChange:_,children:[e.jsx(Ct,{className:"mt-2","data-testid":"onboarding-details-assign-role-select",children:e.jsx(St,{placeholder:"Select role"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"owner",children:"Owner"}),e.jsx(Pe,{value:"contributor",children:"Contributor"}),e.jsx(Pe,{value:"reviewer",children:"Reviewer"})]})]})]}),e.jsx(se,{className:"w-full bg-amber-600 hover:bg-amber-700 font-bold h-11",onClick:M,disabled:q,"data-testid":"onboarding-details-assign-user-submit",children:q?"Assigning...":"Assign User"})]})]})]})]})]})]})}function Z7(t){const{application:s,fetchApplication:n,showApproveModal:r,setShowApproveModal:a,approvalRemark:l,setApprovalRemark:c,setApprovalFile:d,isApproving:h,handleApprove:x,showOnboardModal:f,setShowOnboardModal:m,isOnboarding:p,setIsOnboarding:u,showRejectModal:j,setShowRejectModal:g,rejectionReason:y,setRejectionReason:N,isRejecting:S,handleReject:C,showScheduleModal:w,setShowScheduleModal:R,showCancelInterviewModal:P,setShowCancelInterviewModal:A,setInterviewIdToCancel:I,isCancellingInterview:$,handleConfirmCancelInterview:T,interviewType:E,setInterviewType:_,interviewMode:M,setInterviewMode:q,interviewDate:G,setInterviewDate:Z,meetingLink:W,setMeetingLink:z,location:F,setLocation:B,isInterviewCompleted:D,isInterviewActive:O,users:V,selectedInterviewerId:K,setSelectedInterviewerId:Y,handleAddInterviewer:U,scheduledInterviewParticipants:X,handleRemoveInterviewer:ne,isScheduling:oe,handleScheduleInterview:re,showAssignArchitectureModal:ge,setShowAssignArchitectureModal:ve,architectureLeadId:Se,setArchitectureLeadId:We,isAssigningArchitecture:Ce,handleAssignArchitecture:fe,showArchitectureStatusModal:Ye,setShowArchitectureStatusModal:be,architectureStatus:_e,setArchitectureStatus:ke,architectureRemarks:qe,setArchitectureRemarks:Ve,isUpdatingArchitecture:dt,handleUpdateArchitectureStatus:xt}=t,ye=le=>{var Qe,rt;return(le==null?void 0:le.__stageRole)||((Qe=le==null?void 0:le.role)==null?void 0:Qe.roleName)||((rt=le==null?void 0:le.role)==null?void 0:rt.roleCode)||(le==null?void 0:le.roleCode)||(le==null?void 0:le.role)||"Panelist"};return e.jsxs(e.Fragment,{children:[e.jsx(os,{open:r,onOpenChange:a,children:e.jsxs(ls,{"data-testid":"onboarding-approve-modal",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Approve Application"}),e.jsx(vs,{children:"Provide approval remarks and optionally attach supporting documents."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(ce,{children:["Remark ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Fs,{placeholder:"Enter approval remarks...",value:l,onChange:le=>c(le.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-approve-remark-textarea"})]}),e.jsxs("div",{children:[e.jsx(ce,{children:"Attach File (Optional)"}),e.jsx(ot,{type:"file",className:"mt-2",onChange:le=>d(le.target.files?le.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:h,"data-testid":"onboarding-approve-cancel-button",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-green-600 hover:bg-green-700",onClick:x,disabled:h,"data-testid":"onboarding-approve-submit-button",children:h?e.jsxs(e.Fragment,{children:[e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}),"Approving..."]}):"Submit Approval"})]})]})]})}),e.jsx(os,{open:f,onOpenChange:m,children:e.jsxs(ls,{className:"max-w-md","data-testid":"onboarding-onboard-modal",children:[e.jsxs(ms,{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(Ys,{className:"w-8 h-8 text-green-600"})}),e.jsx(us,{className:"text-center text-xl font-bold",children:"Finalize Onboarding"}),e.jsxs(vs,{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(Bn,{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(Bn,{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(Bn,{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 ds.createDealer({applicationId:s.id}),ee.success("Dealer profile and login account created successfully!"),m(!1),n()}catch{ee.error("Failed to create dealer profile")}finally{u(!1)}},disabled:p,children:p?e.jsxs(e.Fragment,{children:[e.jsx(ss,{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:()=>m(!1),disabled:p,"data-testid":"onboarding-onboard-cancel-button",children:"Cancel"})]})]})}),e.jsx(os,{open:j,onOpenChange:g,children:e.jsxs(ls,{"data-testid":"onboarding-reject-modal",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Reject Application"}),e.jsx(vs,{children:"Please provide a clear reason for rejecting this application."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(ce,{children:["Reason for Rejection ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Fs,{placeholder:"Enter rejection reason...",value:y,onChange:le=>N(le.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:()=>g(!1),disabled:S,"data-testid":"onboarding-reject-cancel-button",children:"Cancel"}),e.jsx(se,{variant:"destructive",className:"flex-1",onClick:C,disabled:S,"data-testid":"onboarding-reject-submit-button",children:S?e.jsxs(e.Fragment,{children:[e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}),"Rejecting..."]}):"Confirm Rejection"})]})]})]})}),e.jsx(os,{open:w,onOpenChange:R,children:e.jsxs(ls,{"data-testid":"onboarding-schedule-modal",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Schedule Interview"}),e.jsx(vs,{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(ce,{children:"Interview Type"}),e.jsxs(wt,{value:E,onValueChange:_,children:[e.jsx(Ct,{className:"mt-2","data-testid":"onboarding-schedule-type-select",children:e.jsx(St,{placeholder:"Select interview type"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"level1",disabled:D(1)||O(1),children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("span",{children:"Level 1"}),D(1)&&e.jsx(Ys,{className:"w-4 h-4 text-green-500 ml-2 inline"}),O(1)&&e.jsx(Js,{className:"w-4 h-4 text-amber-500 ml-2 inline"})]})}),e.jsx(Pe,{value:"level2",disabled:!D(1)||D(2)||O(2),children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("span",{children:"Level 2"}),!D(1)&&e.jsx("span",{className:"text-[10px] text-slate-400 ml-2",children:"(Prerequisite: L1)"}),D(2)&&e.jsx(Ys,{className:"w-4 h-4 text-green-500 ml-2 inline"}),O(2)&&e.jsx(Js,{className:"w-4 h-4 text-amber-500 ml-2 inline"})]})}),e.jsx(Pe,{value:"level3",disabled:!D(2)||D(3)||O(3),children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("span",{children:"Level 3"}),!D(2)&&e.jsx("span",{className:"text-[10px] text-slate-400 ml-2",children:"(Prerequisite: L2)"}),D(3)&&e.jsx(Ys,{className:"w-4 h-4 text-green-500 ml-2 inline"}),O(3)&&e.jsx(Js,{className:"w-4 h-4 text-amber-500 ml-2 inline"})]})})]})]})]}),e.jsxs("div",{children:[e.jsxs(ce,{children:["Interview Mode ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(wt,{value:M,onValueChange:q,children:[e.jsx(Ct,{className:"mt-2","data-testid":"onboarding-schedule-mode-select",children:e.jsx(St,{placeholder:"Select interview mode"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"virtual",children:"Virtual"}),e.jsx(Pe,{value:"physical",children:"Physical"})]})]})]}),e.jsxs("div",{children:[e.jsxs(ce,{children:["Date & Time ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ot,{type:"datetime-local",className:"mt-2",value:G,onChange:le=>Z(le.target.value),"data-testid":"onboarding-schedule-date-input"})]}),M==="virtual"&&e.jsxs("div",{children:[e.jsx(ce,{children:"Meeting Link"}),e.jsx(ot,{placeholder:"https://meet.google.com/...",className:"mt-2",value:W,onChange:le=>z(le.target.value),"data-testid":"onboarding-schedule-link-input"})]}),M==="physical"&&e.jsxs("div",{children:[e.jsx(ce,{children:"Location"}),e.jsx(ot,{placeholder:"Enter interview location address",className:"mt-2",value:F,onChange:le=>B(le.target.value),"data-testid":"onboarding-schedule-location-input"})]}),e.jsxs("div",{children:[e.jsxs(ce,{children:["Interviewers ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsxs(wt,{value:K,onValueChange:Y,children:[e.jsx(Ct,{className:"flex-1","data-testid":"onboarding-schedule-interviewer-select",children:e.jsx(St,{placeholder:"Select interviewer"})}),e.jsx(At,{children:V.map(le=>{var Qe;return e.jsxs(Pe,{value:le.id,children:[le.fullName||le.name," (",((Qe=le.role)==null?void 0:Qe.roleName)||le.roleCode,")"]},le.id)})})]}),e.jsx(se,{onClick:U,type:"button",variant:"secondary","data-testid":"onboarding-schedule-add-interviewer-button",children:"Add"})]}),X.length>0&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsx(ce,{className:"text-xs text-muted-foreground",children:"Selected Interviewers:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:X.map(le=>e.jsxs("div",{className:"flex items-center gap-1 bg-secondary px-2 py-1 rounded text-sm","data-testid":`onboarding-schedule-participant-${le.id}`,children:[e.jsx("span",{children:le.fullName||le.name||"Unknown"}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["(",ye(le),")"]}),e.jsx("button",{onClick:()=>ne(le.id),className:"text-muted-foreground hover:text-destructive","data-testid":`onboarding-schedule-remove-participant-${le.id}`,children:"×"})]},le.id))})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>R(!1),disabled:oe,"data-testid":"onboarding-schedule-cancel-button",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-amber-600 hover:bg-amber-700",onClick:re,disabled:oe,"data-testid":"onboarding-schedule-submit-button",children:oe?"Scheduling...":"Schedule"})]})]})]})}),e.jsx(os,{open:P,onOpenChange:le=>{A(le),le||I("")},children:e.jsxs(ls,{"data-testid":"onboarding-cancel-interview-modal",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Cancel Interview"}),e.jsx(vs,{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),I("")},disabled:$,"data-testid":"onboarding-cancel-interview-close",children:"No"}),e.jsx(se,{variant:"destructive",className:"flex-1",onClick:T,disabled:$,"data-testid":"onboarding-cancel-interview-confirm",children:$?"Cancelling...":"Yes, Cancel"})]})]})}),e.jsx(os,{open:ge,onOpenChange:ve,children:e.jsxs(ls,{"data-testid":"onboarding-architecture-assign-modal",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Assign Architecture Team"}),e.jsx(vs,{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(ce,{children:["Select Architecture Lead ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(wt,{value:Se,onValueChange:We,children:[e.jsx(Ct,{className:"mt-2","data-testid":"onboarding-architecture-lead-select",children:e.jsx(St,{placeholder:"Search users..."})}),e.jsxs(At,{children:[V.filter(le=>{var Qe;return le.roleCode==="ARCHITECTURE"||((Qe=le.role)==null?void 0:Qe.roleCode)==="ARCHITECTURE"||le.role==="Architecture"||le.role==="Architecture Team"}).map(le=>e.jsxs(Pe,{value:le.id,children:[le.fullName," (",le.email,")"]},le.id)),V.filter(le=>{var Qe;return le.roleCode==="ARCHITECTURE"||((Qe=le.role)==null?void 0:Qe.roleCode)==="ARCHITECTURE"||le.role==="Architecture"||le.role==="Architecture Team"}).length===0&&V.map(le=>e.jsxs(Pe,{value:le.id,children:[le.fullName," (",le.roleCode||le.role,")"]},le.id))]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>ve(!1),disabled:Ce,"data-testid":"onboarding-architecture-assign-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-blue-600 hover:bg-blue-700",onClick:fe,disabled:Ce,"data-testid":"onboarding-architecture-assign-submit",children:Ce?"Assigning...":"Assign Team"})]})]})]})}),e.jsx(os,{open:Ye,onOpenChange:be,children:e.jsxs(ls,{"data-testid":"onboarding-architecture-status-modal",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Update Architecture Status"}),e.jsx(vs,{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(ce,{children:["Status ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(wt,{value:_e,onValueChange:ke,children:[e.jsx(Ct,{className:"mt-2","data-testid":"onboarding-architecture-status-select",children:e.jsx(St,{placeholder:"Select status"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"COMPLETED",children:"Completed"}),e.jsx(Pe,{value:"REJECTED",children:"Rejected / Needs Revision"})]})]})]}),e.jsxs("div",{children:[e.jsx(ce,{children:"Remarks (Optional)"}),e.jsx(Fs,{placeholder:"Enter any planning or site-visit remarks...",value:qe,onChange:le=>Ve(le.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:()=>be(!1),disabled:dt,"data-testid":"onboarding-architecture-status-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-blue-600 hover:bg-blue-700",onClick:xt,disabled:dt,"data-testid":"onboarding-architecture-status-submit",children:dt?"Updating...":"Update Status"})]})]})]})})]})}function Q7(t){var Fe,Q,pe,Ne,Ee,it,st,bt;const{application:s,ktCriteria:n,l2Fields:r,l3Fields:a,showKTMatrixModal:l,setShowKTMatrixModal:c,ktMatrixSelectedValues:d,handleKTMatrixChange:h,ktMatrixRemarks:x,setKtMatrixRemarks:f,ktMatrixRecommendation:m,setKtMatrixRecommendation:p,calculateKTScore:u,handleSubmitKTMatrix:j,isSubmittingKT:g,showLevel2FeedbackModal:y,setShowLevel2FeedbackModal:N,level2Feedback:S,handleLevel2Change:C,level2Recommendation:w,setLevel2Recommendation:R,handleSubmitLevel2Feedback:P,isSubmittingLevel2:A,showFeedbackDetailsModal:I,setShowFeedbackDetailsModal:$,selectedEvaluationForView:T,selectedInterviewForFeedback:E,showLevel3FeedbackModal:_,setShowLevel3FeedbackModal:M,level3Feedback:q,handleLevel3Change:G,level3Recommendation:Z,setLevel3Recommendation:W,handleSubmitLevel3Feedback:z,isSubmittingLevel3:F,showDocumentsModal:B,setShowDocumentsModal:D,showUploadForm:O,setShowUploadForm:V,selectedStage:K,getDocumentsForStage:Y,setPreviewDoc:U,setShowPreviewModal:X,flattenedStages:ne,setSelectedStage:oe,uploadDocType:re,setUploadDocType:ge,setUploadFile:ve,isUploading:Se,handleUpload:We,uploadFile:Ce,documentConfigs:fe,showPreviewModal:Ye,previewDoc:be,showFddFinalizeModal:_e,setShowFddFinalizeModal:ke,currentUser:qe,fddAuditRecommendation:Ve,setFddAuditRecommendation:dt,fddAuditFindings:xt,setFddAuditFindings:ye,isFinalizingFdd:le,setIsFinalizingFdd:Qe,fetchApplication:rt,showFddFlagModal:Kt,setShowFddFlagModal:Rt,isFddFlagging:Re,setIsFddFlagging:Qt,showFirmTypeModal:qt,setShowFirmTypeModal:ws,tempFirmType:_s,setTempFirmType:ns,updatingFirmType:Cs,handleUpdateFirmType:Bs}=t,Ft=E!=null&&E.scheduleDate?new Date(E.scheduleDate).toISOString().split("T")[0]:"",ie=(qe==null?void 0:qe.fullName)||(qe==null?void 0:qe.name)||"";return e.jsxs(e.Fragment,{children:[e.jsx(os,{open:l,onOpenChange:c,children:e.jsxs(ls,{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(ms,{className:"shrink-0 space-y-2 border-b px-5 py-4 text-left",children:[e.jsx(us,{className:"text-base",children:"KT matrix"}),e.jsxs(vs,{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-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-800",children:"KT Matrix configuration is not available. Configure it in Master > Interview Configurations."}),n.map((Ue,Lt)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ce,{htmlFor:`kt-matrix-${Lt}`,className:"block text-sm font-medium leading-relaxed text-foreground",children:[e.jsxs("span",{className:"text-muted-foreground",children:[Lt+1,"."]})," ",Ue.name," ",e.jsx("span",{className:"text-red-500",children:"*"})," ",e.jsxs("span",{className:"font-normal text-muted-foreground",children:["(",Ue.weight,"%)"]})]}),e.jsxs(wt,{value:d[Ue.name]??void 0,onValueChange:ut=>{const yt=Ue.options.find(kt=>kt.value===ut);yt&&h(Ue.name,yt.value,yt.score)},children:[e.jsx(Ct,{id:`kt-matrix-${Lt}`,className:"h-10 w-full text-left text-sm font-normal","data-testid":`onboarding-kt-matrix-select-${Lt}`,children:e.jsx(St,{placeholder:"Choose an option…"})}),e.jsx(At,{position:"popper",className:"max-h-72 w-[var(--radix-select-trigger-width)]",children:Ue.options.map(ut=>e.jsxs(Pe,{value:ut.value,className:"py-2.5 text-sm leading-snug","data-testid":`onboarding-kt-matrix-option-${Lt}-${ut.value}`,children:[ut.label," ",e.jsxs("span",{className:"text-muted-foreground",children:["(",ut.score,")"]})]},ut.value))})]})]},Ue.name)),e.jsxs("div",{className:"space-y-2 border-t border-border pt-6",children:[e.jsxs(ce,{htmlFor:"kt-matrix-remarks",className:"text-sm font-medium",children:["Notes ",e.jsx("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),e.jsx(Fs,{id:"kt-matrix-remarks",placeholder:"Optional remarks…",className:"min-h-[96px] resize-y text-sm leading-relaxed",value:x,onChange:Ue=>f(Ue.target.value),"data-testid":"onboarding-kt-matrix-remarks-textarea"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ce,{className:"text-sm font-medium",children:["Recommendation ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(wt,{value:m,onValueChange:p,children:[e.jsx(Ct,{"data-testid":"onboarding-kt-matrix-recommendation-select",children:e.jsx(St,{placeholder:"Select recommendation"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"Approve",children:"Approve"}),e.jsx(Pe,{value:"Reject",children:"Reject"}),e.jsx(Pe,{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:()=>c(!1),"data-testid":"onboarding-kt-matrix-cancel",children:"Cancel"}),e.jsx(se,{onClick:j,disabled:g||n.length===0||Object.keys(d).length<n.length,"data-testid":"onboarding-kt-matrix-submit",children:g?"Saving…":"Submit"})]})]})]})}),e.jsx(os,{open:y,onOpenChange:N,children:e.jsxs(ls,{className:"max-w-2xl max-h-[90vh] overflow-y-auto","data-testid":"onboarding-level2-feedback-modal",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Level 2 Interview Feedback"}),e.jsx(vs,{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(ce,{children:["Interview Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ot,{type:"date",className:"mt-2",value:S.interviewDate||Ft,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(ce,{children:["Interviewer Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ot,{placeholder:"Enter your name",className:"mt-2",value:S.interviewerName||ie,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(ce,{children:["Overall Performance Score ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(wt,{value:S.overallScore,onValueChange:Ue=>C("overallScore",Ue),children:[e.jsx(Ct,{className:"mt-2","data-testid":"onboarding-level2-overall-score-select",children:e.jsx(St,{placeholder:"Select score"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"10",children:"Outstanding (9-10)"}),e.jsx(Pe,{value:"8",children:"Excellent (7-8)"}),e.jsx(Pe,{value:"6",children:"Good (5-6)"}),e.jsx(Pe,{value:"4",children:"Average (3-4)"}),e.jsx(Pe,{value:"2",children:"Below Average (1-2)"})]})]})]}),e.jsxs("div",{children:[e.jsxs(ce,{children:["Recommendation ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(wt,{value:w,onValueChange:R,children:[e.jsx(Ct,{className:"mt-2","data-testid":"onboarding-level2-recommendation-select",children:e.jsx(St,{placeholder:"Select recommendation"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"Approve",children:"Approve"}),e.jsx(Pe,{value:"Reject",children:"Reject"}),e.jsx(Pe,{value:"Hold",children:"Hold"})]})]})]}),e.jsx(zd,{}),r.length===0&&e.jsx("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-800",children:"Level 2 feedback configuration is not available. Configure it in Master > Interview Configurations."}),(r||[]).map((Ue,Lt)=>e.jsxs("div",{children:[e.jsxs(ce,{children:[Ue.label,Ue.isRequired&&e.jsx("span",{className:"text-red-500",children:"*"})]}),Ue.type==="select"?e.jsxs(wt,{value:S[Ue.itemKey]||"",onValueChange:ut=>C(Ue.itemKey,ut),children:[e.jsx(Ct,{className:"mt-2",children:e.jsx(St,{placeholder:`Select ${Ue.label}...`})}),e.jsx(At,{children:(Ue.options||[]).map((ut,yt)=>e.jsx(Pe,{value:ut.optionValue||ut.value,children:ut.optionLabel||ut.label},yt))})]}):Ue.type==="number"?e.jsx(ot,{type:"number",className:"mt-2",value:S[Ue.itemKey]||"",onChange:ut=>C(Ue.itemKey,ut.target.value)}):e.jsx(Fs,{placeholder:`Enter ${Ue.label.toLowerCase()}...`,className:"mt-2",rows:3,value:S[Ue.itemKey]||"",onChange:ut=>C(Ue.itemKey,ut.target.value)})]},Ue.itemKey||Lt)),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>N(!1),"data-testid":"onboarding-level2-feedback-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-black hover:bg-zinc-800 text-white",onClick:P,disabled:A||r.length===0,"data-testid":"onboarding-level2-feedback-submit",children:A?"Submitting...":"Submit Feedback"})]})]})]})}),e.jsx(os,{open:I,onOpenChange:$,children:e.jsxs(ls,{className:"max-w-2xl max-h-[90vh] overflow-y-auto","data-testid":"onboarding-feedback-details-modal",children:[e.jsx(ms,{children:e.jsx(us,{children:"Interview Feedback Details"})}),T&&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:(Fe=T.evaluator)==null?void 0:Fe.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:((pe=(Q=T.evaluator)==null?void 0:Q.role)==null?void 0:pe.roleName)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-500",children:((Ne=T.interview)==null?void 0:Ne.level)===1?"Score (KT Matrix)":"Overall Score"}),e.jsx("p",{className:"font-bold text-lg","data-testid":"onboarding-feedback-details-score",children:T.ktMatrixScore?`${T.ktMatrixScore}/${((Ee=T.interview)==null?void 0:Ee.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(Ae,{variant:(it=T.recommendation)!=null&&it.toLowerCase().includes("reject")?"destructive":(st=T.recommendation)!=null&&st.toLowerCase().includes("hold")?"secondary":"default","data-testid":"onboarding-feedback-details-recommendation",children:T.recommendation||"N/A"})]})]}),e.jsx(zd,{}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold mb-3",children:"Detailed Feedback"}),((bt=T.feedbackDetails)==null?void 0:bt.length)>0?e.jsx("div",{className:"space-y-4",children:T.feedbackDetails.map((Ue,Lt)=>e.jsxs("div",{className:"border-b last:border-0 pb-3 last:pb-0","data-testid":`onboarding-feedback-detail-item-${Lt}`,children:[e.jsx("p",{className:"font-medium text-slate-900",children:Ue.feedbackType}),e.jsx("p",{className:"text-slate-700 mt-1 whitespace-pre-wrap text-sm",children:Ue.comments})]},Lt))}):e.jsx("p",{className:"text-slate-500 italic",children:"No detailed feedback available."})]})]})]})}),e.jsx(os,{open:_,onOpenChange:M,children:e.jsxs(ls,{className:"max-w-2xl max-h-[90vh] overflow-y-auto","data-testid":"onboarding-level3-feedback-modal",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Level 3 Interview Feedback"}),e.jsx(vs,{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(ce,{children:["Interview Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ot,{type:"date",className:"mt-2",value:q.interviewDate||Ft,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(ce,{children:["Interviewer Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ot,{placeholder:"Enter your name",className:"mt-2",value:q.interviewerName||ie,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(ce,{children:["Overall Performance Score ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(wt,{value:q.overallScore,onValueChange:Ue=>G("overallScore",Ue),children:[e.jsx(Ct,{className:"mt-2","data-testid":"onboarding-level3-overall-score-select",children:e.jsx(St,{placeholder:"Select score"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"10",children:"Outstanding (9-10)"}),e.jsx(Pe,{value:"8",children:"Excellent (7-8)"}),e.jsx(Pe,{value:"6",children:"Good (5-6)"}),e.jsx(Pe,{value:"4",children:"Average (3-4)"}),e.jsx(Pe,{value:"2",children:"Below Average (1-2)"})]})]})]}),e.jsxs("div",{children:[e.jsxs(ce,{children:["Recommendation ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(wt,{value:Z,onValueChange:W,children:[e.jsx(Ct,{className:"mt-2","data-testid":"onboarding-level3-recommendation-select",children:e.jsx(St,{placeholder:"Select recommendation"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"Approve",children:"Approve"}),e.jsx(Pe,{value:"Reject",children:"Reject"}),e.jsx(Pe,{value:"Hold",children:"Hold"})]})]})]}),e.jsx(zd,{}),a.length===0&&e.jsx("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-800",children:"Level 3 feedback configuration is not available. Configure it in Master > Interview Configurations."}),(a||[]).map((Ue,Lt)=>e.jsxs("div",{children:[e.jsxs(ce,{children:[Ue.label,Ue.isRequired&&e.jsx("span",{className:"text-red-500",children:"*"})]}),Ue.type==="select"?e.jsxs(wt,{value:q[Ue.itemKey]||"",onValueChange:ut=>G(Ue.itemKey,ut),children:[e.jsx(Ct,{className:"mt-2",children:e.jsx(St,{placeholder:`Select ${Ue.label}...`})}),e.jsx(At,{children:(Ue.options||[]).map((ut,yt)=>e.jsx(Pe,{value:ut.optionValue||ut.value,children:ut.optionLabel||ut.label},yt))})]}):Ue.type==="number"?e.jsx(ot,{type:"number",className:"mt-2",value:q[Ue.itemKey]||"",onChange:ut=>G(Ue.itemKey,ut.target.value)}):e.jsx(Fs,{placeholder:`Enter ${Ue.label.toLowerCase()}...`,className:"mt-2",rows:3,value:q[Ue.itemKey]||"",onChange:ut=>G(Ue.itemKey,ut.target.value)})]},Ue.itemKey||Lt)),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>M(!1),"data-testid":"onboarding-level3-feedback-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-black hover:bg-zinc-800 text-white",onClick:z,disabled:F||a.length===0,"data-testid":"onboarding-level3-feedback-submit",children:F?"Submitting...":"Submit Feedback"})]})]})]})}),e.jsx(os,{open:B,onOpenChange:Ue=>{D(Ue),Ue||V(!1)},children:e.jsxs(ls,{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(ms,{className:"pb-4",children:[e.jsxs(us,{className:"text-xl font-bold flex items-center gap-2",children:[e.jsx(fs,{className:"w-5 h-5 text-amber-600"}),"Documents - ",K||"General"]}),e.jsx(vs,{className:"text-slate-500",children:"View and manage documents uploaded for this stage."})]}),O?e.jsxs("div",{className:"space-y-6 py-4","data-testid":"onboarding-documents-upload-form",children:[e.jsxs("div",{className:"grid gap-6 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-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ce,{className:"text-slate-700 font-semibold px-1",children:["Stage context ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(wt,{value:K||"null",onValueChange:Ue=>oe(Ue==="null"?null:Ue),children:[e.jsx(Ct,{className:"bg-white border-slate-200 h-11 rounded-xl focus:ring-amber-500 shadow-sm","data-testid":"onboarding-documents-stage-select",children:e.jsx(St,{placeholder:"Select stage"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"null",children:"General / No Stage"}),ne.map((Ue,Lt)=>e.jsx(Pe,{value:Ue.name,children:Ue.parentBranch?`${Ue.parentBranch}: ${Ue.name}`:Ue.name},`${Ue.name}-${Lt}`))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ce,{className:"text-slate-700 font-semibold px-1",children:["Document Type ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(wt,{value:re,onValueChange:ge,children:[e.jsx(Ct,{className:"bg-white border-slate-200 h-11 rounded-xl focus:ring-amber-500 shadow-sm","data-testid":"onboarding-documents-type-select",children:e.jsx(St,{placeholder:"Select type"})}),e.jsx(At,{children:(()=>{const Ue=["Other"],Lt=fe.filter(yt=>{var _t;const kt=(_t=yt.stageCode)==null?void 0:_t.trim(),Ie=(K||"General").trim();return!!(kt===Ie||Ie.startsWith("EOR:")&&kt==="EOR"||!K&&kt==="General")});let ut=[];if(Lt.length>0?ut=Lt.map(yt=>yt.documentType):!K||K==="General"?ut=["PAN Card","GST Certificate","Aadhaar Card","Passport Size Photograph","Partnership Deed","LLP Agreement","Certificate of Incorporation","Board Resolution","Firm Registration Certificate","Cancelled Check","Bank Statement","Other"]:K!=null&&K.toLowerCase().includes("architecture")?ut=["Architecture Blueprint","Site Plan","Proposed Site City Map","Site Readiness Report","Architecture Completion Certificate","Other"]:K!=null&&K.toLowerCase().includes("fdd")?ut=["FDD Final Audit Report","Bank Statement","Income Tax Returns (ITR)","CIBIL Report","Other"]:ut=Ue,K!=null&&K.startsWith("EOR: ")){const yt=K.replace("EOR: ","");ut.includes(yt)||(ut=[yt,...ut])}return Array.from(new Set(ut)).map((yt,kt)=>e.jsx(Pe,{value:yt,"data-testid":`onboarding-documents-type-option-${kt}`,children:yt},`${yt}-${kt}`))})()})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ce,{className:"text-slate-700 font-semibold px-1",children:["Select File ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ot,{type:"file",className:"bg-white border-slate-200 h-12 rounded-xl focus:ring-amber-500 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-amber-50 file:text-amber-700 hover:file:bg-amber-100 cursor-pointer",onChange:Ue=>ve(Ue.target.files?Ue.target.files[0]:null),"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:()=>V(!1),disabled:Se,"data-testid":"onboarding-documents-upload-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 order-1 sm:order-2 bg-amber-600 hover:bg-amber-700 text-white font-bold py-3 sm:py-5 rounded-xl shadow-lg shadow-amber-600/15 transition-all hover:scale-[1.01] active:scale-[0.99]",onClick:async()=>{await We(),V(!1)},disabled:!Ce||!re||Se,"data-testid":"onboarding-documents-upload-submit",children:Se?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(Dr,{className:"w-5 h-5"}),"Confirm Upload"]})})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 space-y-4",children:[Y(K||"").length>0?e.jsx("div",{className:"flex-1 overflow-auto border rounded-lg border-slate-200","data-testid":"onboarding-documents-table-container",children:e.jsxs(ks,{className:"w-full table-auto",children:[e.jsx(Rs,{className:"bg-slate-50/80 sticky top-0 z-10",children:e.jsxs(ct,{className:"hover:bg-transparent border-b",children:[e.jsx(me,{className:"w-[45%] min-w-[150px] font-semibold text-slate-900 py-3",children:"Document Name"}),e.jsx(me,{className:"w-[15%] min-w-[100px] font-semibold text-slate-900 py-3",children:"Type"}),e.jsx(me,{className:"w-[15%] min-w-[100px] font-semibold text-slate-900 py-3",children:"Upload Date"}),e.jsx(me,{className:"w-[15%] min-w-[140px] font-semibold text-slate-900 py-3",children:"Uploaded By"}),e.jsx(me,{className:"text-right w-[10%] min-w-[80px] font-semibold text-slate-900 py-3",children:"Actions"})]})}),e.jsx(Es,{children:Y(K||"").map((Ue,Lt)=>{var ut,yt;return e.jsxs(ct,{className:"hover:bg-slate-50/50 transition-colors","data-testid":`onboarding-document-row-${Lt}`,children:[e.jsx(de,{className:"py-3",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(fs,{className:"w-4 h-4 text-slate-400 shrink-0"}),e.jsx("span",{className:"truncate font-medium text-slate-700",title:Ue.fileName,"data-testid":`onboarding-document-name-${Lt}`,children:Ue.fileName})]})}),e.jsx(de,{className:"py-3",children:e.jsx(Ae,{variant:"outline",className:"capitalize whitespace-nowrap font-normal border-slate-200 bg-white","data-testid":`onboarding-document-type-${Lt}`,children:((ut=Ue.documentType)==null?void 0:ut.toLowerCase())||"Other"})}),e.jsx(de,{className:"py-3 whitespace-nowrap text-slate-600",children:Ht(Ue.createdAt)}),e.jsx(de,{className:"py-3 text-slate-600",children:((yt=Ue.uploader)==null?void 0:yt.fullName)||(Ue.uploadedBy?"System User":"Applicant")}),e.jsx(de,{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:()=>{U(Ue),X(!0)},"data-testid":`onboarding-document-preview-${Lt}`,children:e.jsx(nn,{className:"w-4 h-4"})}),e.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-amber-600 hover:bg-amber-50 rounded-full",onClick:()=>{window.open(`https://dealeronboarding-uat.royalenfield.com/api/${Ue.filePath}`,"_blank")},"data-testid":`onboarding-document-download-${Lt}`,children:e.jsx(Ni,{className:"w-4 h-4"})})]})})]},Ue.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(fs,{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-amber-600 hover:bg-amber-700 text-white font-bold py-3 sm:py-5 rounded-xl shadow-lg shadow-amber-600/15 transition-all hover:scale-[1.01] active:scale-[0.99]",onClick:()=>V(!0),"data-testid":"onboarding-documents-upload-button",children:[e.jsx(Dr,{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:()=>D(!1),"data-testid":"onboarding-documents-close-button",children:"Close"})]})]})]})}),e.jsx(Kl,{isOpen:Ye,onClose:()=>X(!1),document:be}),e.jsx(os,{open:_e,onOpenChange:ke,children:e.jsxs(ls,{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-amber-600/20 to-transparent"}),e.jsx("div",{className:"w-20 h-20 bg-amber-600/20 rounded-full flex items-center justify-center animate-pulse relative z-10 shadow-[0_0_40px_rgba(245,158,11,0.2)]",children:e.jsx(Fl,{className:"w-10 h-10 text-amber-500"})})]}),e.jsxs("div",{className:"p-8 space-y-6 bg-white",children:[e.jsxs(ms,{children:[e.jsx(us,{className:"text-2xl font-black text-slate-900 text-center tracking-tight",children:"Finalize FDD Audit"}),e.jsxs(vs,{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-amber-500 decoration-2",children:"lock the audit session"})," and trigger the LOI approval workflow."]})]}),e.jsxs("div",{className:"space-y-4",children:[(qe==null?void 0:qe.role)!=="FDD"&&(qe==null?void 0:qe.roleCode)!=="FDD"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ce,{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(Ue=>e.jsx(se,{variant:Ve===Ue?"default":"outline",className:Pt("flex-1 h-10 font-bold text-[9px] uppercase tracking-wider rounded-xl transition-all",Ve===Ue&&Ue==="Recommended"&&"bg-emerald-600 hover:bg-emerald-700",Ve===Ue&&Ue==="Qualified with Observations"&&"bg-amber-500 hover:bg-amber-600",Ve===Ue&&Ue==="Not Recommended"&&"bg-red-600 hover:bg-red-700"),onClick:()=>dt(Ue),"data-testid":`onboarding-fdd-recommendation-${Ue.replace(/\s+/g,"-").toLowerCase()}`,children:Ue},Ue))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{className:"text-[10px] font-black uppercase tracking-widest text-slate-400",children:"Findings Summary"}),e.jsx(Fs,{placeholder:"Summarize key financial findings or discrepancies...",className:"min-h-[100px] rounded-xl border-slate-200 focus:ring-amber-500 text-sm",value:xt,onChange:Ue=>ye(Ue.target.value),"data-testid":"onboarding-fdd-findings-textarea"})]})]}),e.jsxs("div",{className:"bg-amber-50 p-4 rounded-2xl flex gap-3 border border-amber-100",children:[e.jsx(Xa,{className:"w-5 h-5 text-amber-600 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-amber-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:()=>ke(!1),disabled:le,"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-amber-500",disabled:le||!xt,"data-testid":"onboarding-fdd-finalize-submit",onClick:async()=>{try{Qe(!0),await ds.submitStageDecision({applicationId:s.id,stageCode:"FDD_VERIFICATION",decision:"Approved",remarks:(qe==null?void 0:qe.role)==="FDD"||(qe==null?void 0:qe.roleCode)==="FDD"?`Findings: ${xt}`:`[RECOMMENDATION: ${Ve}]
Findings: ${xt}`,nextStatus:"LOI In Progress",nextProgress:65}),ee.success("FDD Audit finalized and submitted."),ke(!1),rt()}catch{ee.error("Submission failed")}finally{Qe(!1)}},children:le?e.jsx(ss,{className:"w-5 h-5 animate-spin"}):"Confirm & Submit"})]})]})]})}),e.jsx(os,{open:Kt,onOpenChange:Rt,children:e.jsxs(ls,{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(Xv,{className:"w-10 h-10 text-red-500"})})]}),e.jsxs("div",{className:"p-8 space-y-6 bg-white text-center",children:[e.jsxs(ms,{children:[e.jsx(us,{className:"text-2xl font-black text-slate-900 tracking-tight",children:"Flag Non-Responsive"}),e.jsx(vs,{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(Ks,{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:()=>Rt(!1),disabled:Re,"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:Re,"data-testid":"onboarding-fdd-flag-submit",onClick:async()=>{try{Qt(!0),await ds.submitStageDecision({applicationId:s.id,stageCode:"FDD_VERIFICATION",decision:"Rejected",remarks:"Applicant is non-responsive to FDD queries."}),ee.error("Applicant flagged as non-responsive."),Rt(!1),rt()}catch{ee.error("Action failed")}finally{Qt(!1)}},children:Re?e.jsx(ss,{className:"w-5 h-5 animate-spin"}):"Confirm Flag"})]})]})]})}),e.jsx(os,{open:qt,onOpenChange:ws,children:e.jsxs(ls,{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-amber-600 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(Ml,{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-amber-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(ce,{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(wt,{value:_s,onValueChange:ns,children:[e.jsx(Ct,{className:"h-12 rounded-xl border-slate-200 focus:ring-amber-500","data-testid":"onboarding-firm-type-select",children:e.jsx(St,{placeholder:"Select Firm Type"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"Proprietorship","data-testid":"onboarding-firm-type-proprietorship",children:"Proprietorship"}),e.jsx(Pe,{value:"Partnership","data-testid":"onboarding-firm-type-partnership",children:"Partnership"}),e.jsx(Pe,{value:"Limited Liability partnership","data-testid":"onboarding-firm-type-llp",children:"LLP (Limited Liability partnership)"}),e.jsx(Pe,{value:"Private Limited Company","data-testid":"onboarding-firm-type-pvt-ltd",children:"Private Limited Company"}),e.jsx(Pe,{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:()=>ws(!1),disabled:Cs,"data-testid":"onboarding-firm-type-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 h-12 rounded-xl font-bold bg-amber-600 hover:bg-amber-700 text-white shadow-lg shadow-amber-200 transition-all active:scale-95",disabled:Cs||!_s,onClick:Bs,"data-testid":"onboarding-firm-type-submit",children:Cs?e.jsx(ss,{className:"w-5 h-5 animate-spin"}):"Update Type"})]})]})]})})]})}var X7={};function J7({application:t,currentUser:s,documents:n,fddAgencies:r,selectedAgencyId:a,setSelectedAgencyId:l,isAssigningAgency:c,handleAssignAgency:d,setPreviewDoc:h,setShowPreviewModal:x,setIsUploading:f,fetchApplication:m,refreshDocuments:p}){var w,R;const u=(t==null?void 0:t.fddAssignments)||[],j=((w=t==null?void 0:t.participants)==null?void 0:w.filter(P=>{var A,I,$,T;return((A=P.user)==null?void 0:A.role)==="FDD"||((I=P.user)==null?void 0:I.roleCode)==="FDD"||((T=($=P.user)==null?void 0:$.allRoles)==null?void 0:T.includes("FDD"))}))||[],g=u.length>0||j.length>0,y=(R=j[0])==null?void 0:R.user,N=[{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"}],S=P=>{const A=P.toLowerCase();return(n||[]).find(I=>{const $=(I.documentType||"").toLowerCase(),T=(I.fileName||"").toLowerCase();return!!($===A||A.includes("itr")&&($.includes("itr")||T.includes("itr"))||A.includes("bank statement")&&($.includes("bank")||T.includes("bank"))||A.includes("cibil")&&($.includes("cibil")||T.includes("cibil")||$.includes("credit")))})},C=P=>{const A=(P.documentType||"").toLowerCase();return(P.stage||"").toLowerCase()==="fdd"||A.includes("report")||A.includes("itr")||A.includes("bank")||A.includes("cibil")||A.includes("valuation")};return!g&&!["FDD Verification","LOI In Progress","Payment Pending"].includes(t.status)?e.jsxs("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(Fl,{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."})]}),((s==null?void 0:s.role)==="DD Admin"||(s==null?void 0:s.role)==="Super Admin")&&e.jsxs(Le,{className:"border-amber-100 bg-amber-50/30 overflow-hidden rounded-2xl","data-testid":"onboarding-fdd-initiate-card",children:[e.jsx(tt,{className:"pb-2",children:e.jsxs(nt,{className:"text-xs font-black uppercase tracking-widest text-amber-800 flex items-center gap-2",children:[e.jsx(Xv,{className:"w-4 h-4"}),"Initiate FDD Audit"]})}),e.jsx(Me,{children:e.jsxs("div",{className:"flex flex-col md:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("label",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-1.5 block",children:["Select FDD Agency ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("select",{className:"w-full h-11 bg-white border border-slate-200 rounded-xl px-4 text-sm font-medium focus:ring-2 focus:ring-amber-500/20 focus:border-amber-500 outline-none transition-all shadow-sm",value:a,onChange:P=>l(P.target.value),"data-testid":"onboarding-fdd-agency-select",children:[e.jsx("option",{value:"",children:"Choose partner agency..."}),(r||[]).map(P=>e.jsxs("option",{value:P.id,"data-testid":`onboarding-fdd-agency-option-${P.id}`,children:[P.fullName||P.name," (",P.email,")"]},P.id))]})]}),e.jsx("div",{className:"flex items-end",children:e.jsx(se,{className:"bg-slate-900 text-white hover:bg-slate-800 font-black text-[10px] uppercase tracking-widest px-8 h-11 border-none shadow-lg shadow-slate-900/10 transition-all active:scale-[0.98]",onClick:d,disabled:c||!a,"data-testid":"onboarding-fdd-assign-button",children:c?"Assigning...":"Assign & Start Audit"})})]})})]})]}):e.jsxs("div",{className:"space-y-8","data-testid":"onboarding-fdd-audit-content",children:[g&&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-amber-100 rounded-lg",children:e.jsx(Fl,{className:"w-5 h-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-slate-900",children:"FDD Assignment Active"}),y&&e.jsxs("p",{className:"text-xs text-slate-500 font-medium","data-testid":"onboarding-fdd-assigned-user",children:["Assigned to: ",y.name]})]})]})}),e.jsxs(Le,{className:"border-slate-200 shadow-sm overflow-hidden rounded-2xl","data-testid":"onboarding-fdd-checklist-card",children:[e.jsx(tt,{className:"bg-slate-50/50 border-b border-slate-100 py-4",children:e.jsxs(nt,{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(Fo,{className:"w-4 h-4"})," Financial Artefacts Checklist"]}),e.jsx(Ae,{variant:"outline",className:"text-[10px] bg-white",children:"Verify before sign-off"})]})}),e.jsx(Me,{className:"p-0",children:e.jsx("div",{className:"divide-y divide-slate-100",children:N.map((P,A)=>{const I=S(P.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-${A}`,children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:Pt("w-8 h-8 rounded-lg flex items-center justify-center",I?"bg-emerald-50 text-emerald-600":"bg-slate-50 text-slate-300"),children:I?e.jsx(Ys,{className:"w-5 h-5"}):e.jsx(Ks,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-slate-800",children:P.label}),e.jsx("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-tighter","data-testid":`onboarding-fdd-checklist-status-${A}`,children:I?`Uploaded: ${Ht(I.createdAt)}`:"Missing in Documentation"})]})]}),I?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:()=>{h(I),x(!0)},"data-testid":`onboarding-fdd-checklist-preview-${A}`,children:[e.jsx(nn,{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-${A}`,onClick:()=>{const $=document.createElement("input");$.type="file",$.onchange=async T=>{var _;const E=T.target.files[0];if(E)try{f(!0);const M=new FormData;M.append("file",E),M.append("documentType",P.type),M.append("stage","FDD"),M.append("applicationId",t.id);const q=await ds.uploadDocument(t.id,M);P.type==="FDD Final Audit Report"&&(await ds.submitFddReport({applicationId:t.id,reportDocumentId:((_=q.data)==null?void 0:_.id)||q.id,findings:"Final Audit Report uploaded via checklist.",recommendation:"REVIEW_PENDING"}),m()),ee.success(`${P.label} uploaded successfully`),p()}catch{ee.error("Upload failed")}finally{f(!1)}},$.click()},children:[e.jsx(Dr,{className:"w-4 h-4 mr-1 text-slate-300"})," Upload"]})]},P.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(Ae,{variant:"outline",className:"bg-slate-50 text-slate-500 border-slate-200","data-testid":"onboarding-fdd-support-docs-count",children:[(n||[]).filter(C).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:[(n||[]).filter(C).map((P,A)=>e.jsxs("div",{className:"group bg-white border border-slate-200 rounded-xl p-4 flex items-center justify-between hover:border-amber-400 transition-all hover:shadow-md","data-testid":`onboarding-fdd-support-doc-${A}`,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(fs,{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:P.fileName,"data-testid":`onboarding-fdd-support-doc-name-${A}`,children:P.fileName}),e.jsx("p",{className:"text-slate-500 text-[10px] font-medium uppercase",children:P.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-amber-600 hover:bg-amber-50",onClick:()=>{const I=X7.NEXT_PUBLIC_API_URL||"http://localhost:5000";window.open(`${I}/${P.filePath}`,"_blank")},"data-testid":`onboarding-fdd-support-doc-download-${A}`,children:e.jsx(Ni,{className:"w-4 h-4"})}),e.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-amber-600 hover:bg-amber-50",onClick:()=>{h(P),x(!0)},"data-testid":`onboarding-fdd-support-doc-preview-${A}`,children:e.jsx(nn,{className:"w-4 h-4"})})]})]},P.id)),(n||[]).filter(C).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 e$(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-amber-200 bg-amber-50/80 text-amber-900":"border-slate-200 bg-slate-50 text-slate-700"}function t$({application:t,interviews:s,currentUser:n,getDeposit:r,eorProgress:a}){var y,N,S;const l=Array.isArray(s)?s:[],c=l.find(C=>{var w;return["Scheduled","Rescheduled","Pending","In Progress"].includes(C.status)&&((w=C.participants)==null?void 0:w.some(R=>R.userId===(n==null?void 0:n.id)))}),d=[...l].reverse().find(C=>{var w;return(w=C.participants)==null?void 0:w.some(R=>R.userId===(n==null?void 0:n.id))}),h=(N=(y=c||d)==null?void 0:y.evaluations)==null?void 0:N.find(C=>C.evaluatorId===(n==null?void 0:n.id)),x=C=>l.some(w=>Number(w.level)===C&&w.status==="Completed"),f=C=>l.some(w=>Number(w.level)===C&&w.status==="Scheduled"),m=!!h,p={"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"},u=p[t==null?void 0:t.status],j=(S=t==null?void 0:t.stageApprovals)==null?void 0:S.find(C=>C.stageCode===u&&String(C.actorUserId)===String(n==null?void 0:n.id));return{activeInterviewForUser:c,lastInterviewForUser:d,currentUserEvaluation:h,hasSubmittedFeedback:m,currentUserStageAction:j,isInterviewCompleted:x,isInterviewActive:f,permissions:(()=>{var G,Z,W,z,F;if(!t||!n)return{canApprove:!1,canReject:!1,canSchedule:!1,canAssign:!1,isLoaLocked:!1,isSecurityDetailsLocked:!1,showDecisionMessage:!1};const C=["DD Admin","Super Admin","NBH","DD Lead","DD Head","Finance","Finance Admin","FDD","ZBH","RBM"].includes(n.role),w=["Level 3 Approved","FDD Verification","LOI In Progress","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),R=t.status==="LOA Pending"&&((G=r("FIRST_FILL"))==null?void 0:G.status)!=="Verified",P=["Security Details","Payment Pending"].includes(t.status)&&((Z=r("SECURITY_DEPOSIT"))==null?void 0:Z.status)!=="Verified",A=t.status==="Onboarded"||t.status==="Rejected",I=(W=t.stageApprovals)==null?void 0:W.some(B=>B.stageCode==="LOI_APPROVAL"&&B.actorRole==="DD Head"&&B.decision==="Approved"),$=(z=t.stageApprovals)==null?void 0:z.some(B=>B.stageCode==="LOA_APPROVAL"&&B.actorRole==="DD Head"&&B.decision==="Approved");let T=!0;["Super Admin","DD Admin","DD Lead","DD Head"].includes(n.role)||((t.status==="FDD Verification"||t.status==="Level 3 Approved")&&(T=!1),t.status==="LOI In Progress"&&(T=n.role==="NBH"?!!I:n.role==="DD Head"),t.status==="LOA Pending"&&(T=n.role==="NBH"?!!$:n.role==="DD Head"));const E=!!((F=t.stageApprovals)!=null&&F.find(B=>p[t.status]===B.stageCode&&String(B.actorUserId)===String(n.id))),_=["Approved","Rejected","Selected"].includes((h==null?void 0:h.decision)||(h==null?void 0:h.recommendation)||""),M=(c?_:!1)||E,q=!A&&!M&&C&&w&&T&&(!["EOR In Progress","Inauguration","Approved"].includes(t.status)||a===100);return{canApprove:q&&!R&&!P,canReject:q&&!R,isLoaLocked:R,isSecurityDetailsLocked:P,showDecisionMessage:M&&(!w||E),canSchedule:["DD Admin","Super Admin","DD AM","ASM"].includes(n.role)&&!A&&![1,2,3].every(B=>l.some(D=>D.level===B)),canAssign:["DD Admin","Super Admin","DD AM"].includes(n.role)}})()}}function s$({initialTab:t="questionnaire"}){const[s,n]=v.useState(!1),[r,a]=v.useState(!1),[l,c]=v.useState(""),[d,h]=v.useState(t),[x,f]=v.useState(!1),[m,p]=v.useState(!1),[u,j]=v.useState(!1),[g,y]=v.useState(!1),[N,S]=v.useState(""),[C,w]=v.useState([]),[R,P]=v.useState(!1),[A,I]=v.useState(!1),[$,T]=v.useState(""),[E,_]=v.useState(!1),[M,q]=v.useState(!1),[G,Z]=v.useState(!1),[W,z]=v.useState(!1),[F,B]=v.useState(!1),[D,O]=v.useState(null),[V,K]=v.useState("virtual"),[Y,U]=v.useState(""),[X,ne]=v.useState({}),[oe,re]=v.useState([]),[ge,ve]=v.useState(""),[Se,We]=v.useState("contributor"),[Ce,fe]=v.useState(""),[Ye,be]=v.useState("level1"),[_e,ke]=v.useState(""),[qe,Ve]=v.useState(""),[dt,xt]=v.useState(!1),[ye,le]=v.useState(null),[Qe,rt]=v.useState(""),[Kt,Rt]=v.useState(null),[Re,Qt]=v.useState(!1),[qt,ws]=v.useState(null),[_s,ns]=v.useState(!1),[Cs,Bs]=v.useState(""),[Ft,ie]=v.useState(!1),[Fe,Q]=v.useState({}),[pe,Ne]=v.useState(!1),[Ee,it]=v.useState([]),[st,bt]=v.useState(!1),[Ue,Lt]=v.useState(!1),[ut,yt]=v.useState(!1),[kt,Ie]=v.useState(""),[_t,ht]=v.useState(!1),[zt,rs]=v.useState(!1),[Yt,Os]=v.useState(""),[Is,zs]=v.useState(""),[en,he]=v.useState(!1),[Ge,at]=v.useState(!1),[pt,mt]=v.useState([]),[Bt,Ds]=v.useState([]),[as,Vs]=v.useState(""),[Ls,Ts]=v.useState(!1),[ln,pn]=v.useState(!1),[hn,Ws]=v.useState(!1),[Qs,zn]=v.useState({}),[on,Un]=v.useState({}),[yr,Tr]=v.useState(""),[er,tr]=v.useState("Approve"),[En,Xe]=v.useState(!1),[$t,Ze]=v.useState(null),[Ut,jt]=v.useState(!1),[In,jr]=v.useState(!1),[Pr,xn]=v.useState("Recommended"),[qs,ha]=v.useState(""),[Tt,xs]=v.useState(!1),[Vr,ta]=v.useState(!1),[ma,_r]=v.useState({}),[sr,gn]=v.useState("Approve"),[mn,Qn]=v.useState(!1),[fr,pr]=v.useState({}),[dn,wn]=v.useState("Approve"),[Da,fa]=v.useState(!1),[Ai,ki]=v.useState(null),[ni,rl]=v.useState(!1);return{showFirmTypeModal:s,setShowFirmTypeModal:n,updatingFirmType:r,setUpdatingFirmType:a,tempFirmType:l,setTempFirmType:c,activeTab:d,setActiveTab:h,showApproveModal:x,setShowApproveModal:f,showOnboardModal:m,setShowOnboardModal:p,isOnboarding:u,setIsOnboarding:j,showRejectModal:g,setShowRejectModal:y,rejectionReason:N,setRejectionReason:S,scheduledInterviewParticipants:C,setScheduledInterviewParticipants:w,showScheduleModal:R,setShowScheduleModal:P,showCancelInterviewModal:A,setShowCancelInterviewModal:I,interviewIdToCancel:$,setInterviewIdToCancel:T,showKTMatrixModal:E,setShowKTMatrixModal:_,showLevel2FeedbackModal:M,setShowLevel2FeedbackModal:q,showLevel3FeedbackModal:G,setShowLevel3FeedbackModal:Z,showDocumentsModal:W,setShowDocumentsModal:z,showAssignModal:F,setShowAssignModal:B,selectedStage:D,setSelectedStage:O,interviewMode:V,setInterviewMode:K,approvalRemark:Y,setApprovalRemark:U,expandedBranches:X,setExpandedBranches:ne,users:oe,setUsers:re,selectedUser:ge,setSelectedUser:ve,participantType:Se,setParticipantType:We,interviewDate:Ce,setInterviewDate:fe,interviewType:Ye,setInterviewType:be,meetingLink:_e,setMeetingLink:ke,location:qe,setLocation:Ve,showUploadForm:dt,setShowUploadForm:xt,uploadFile:ye,setUploadFile:le,uploadDocType:Qe,setUploadDocType:rt,approvalFile:Kt,setApprovalFile:Rt,isUploading:Re,setIsUploading:Qt,previewDoc:qt,setPreviewDoc:ws,showPreviewModal:_s,setShowPreviewModal:ns,selectedInterviewerId:Cs,setSelectedInterviewerId:Bs,isEditingStatutory:Ft,setIsEditingStatutory:ie,statutoryForm:Fe,setStatutoryForm:Q,isSavingStatutory:pe,setIsSavingStatutory:Ne,interviews:Ee,setInterviews:it,isScheduling:st,setIsScheduling:bt,isCancellingInterview:Ue,setIsCancellingInterview:Lt,showAssignArchitectureModal:ut,setShowAssignArchitectureModal:yt,architectureLeadId:kt,setArchitectureLeadId:Ie,isAssigningArchitecture:_t,setIsAssigningArchitecture:ht,showArchitectureStatusModal:zt,setShowArchitectureStatusModal:rs,architectureStatus:Yt,setArchitectureStatus:Os,architectureRemarks:Is,setArchitectureRemarks:zs,isUpdatingArchitecture:en,setIsUpdatingArchitecture:he,isAssigningParticipant:Ge,setIsAssigningParticipant:at,documentConfigs:pt,setDocumentConfigs:mt,fddAgencies:Bt,setFddAgencies:Ds,selectedAgencyId:as,setSelectedAgencyId:Vs,isAssigningAgency:Ls,setIsAssigningAgency:Ts,isApproving:ln,setIsApproving:pn,isRejecting:hn,setIsRejecting:Ws,ktMatrixScores:Qs,setKtMatrixScores:zn,ktMatrixSelectedValues:on,setKtMatrixSelectedValues:Un,ktMatrixRemarks:yr,setKtMatrixRemarks:Tr,ktMatrixRecommendation:er,setKtMatrixRecommendation:tr,isSubmittingKT:En,setIsSubmittingKT:Xe,selectedInterviewForFeedback:$t,setSelectedInterviewForFeedback:Ze,showFddFinalizeModal:Ut,setShowFddFinalizeModal:jt,showFddFlagModal:In,setShowFddFlagModal:jr,fddAuditRecommendation:Pr,setFddAuditRecommendation:xn,fddAuditFindings:qs,setFddAuditFindings:ha,isFinalizingFdd:Tt,setIsFinalizingFdd:xs,isFddFlagging:Vr,setIsFddFlagging:ta,level2Feedback:ma,setLevel2Feedback:_r,level2Recommendation:sr,setLevel2Recommendation:gn,isSubmittingLevel2:mn,setIsSubmittingLevel2:Qn,level3Feedback:fr,setLevel3Feedback:pr,level3Recommendation:dn,setLevel3Recommendation:wn,isSubmittingLevel3:Da,setIsSubmittingLevel3:fa,selectedEvaluationForView:Ai,setSelectedEvaluationForView:ki,showFeedbackDetailsModal:ni,setShowFeedbackDetailsModal:rl}}const uE=()=>new Date().toISOString().split("T")[0],n$=t=>({strategicVision:"",managementCapabilities:"",operationalUnderstanding:"",keyStrengths:"",areasOfConcern:"",additionalComments:"",overallScore:"",interviewerName:(t==null?void 0:t.name)||"",interviewDate:uE()}),r$=t=>({strategicVision:"",managementCapabilities:"",operationalUnderstanding:"",brandAlignment:"",executiveSummary:"",keyStrengths:"",areasOfConcern:"",additionalComments:"",overallScore:"",interviewerName:(t==null?void 0:t.name)||"",interviewDate:uE()});function a$({ktMatrixScores:t,setKtMatrixScores:s,setKtMatrixSelectedValues:n,ktMatrixRemarks:r,setKtMatrixRemarks:a,ktMatrixRecommendation:l,setKtMatrixRecommendation:c,selectedInterviewForFeedback:d,interviews:h,setIsSubmittingKT:x,setShowKTMatrixModal:f,level2Feedback:m,setLevel2Feedback:p,level2Recommendation:u,setLevel2Recommendation:j,setIsSubmittingLevel2:g,setShowLevel2FeedbackModal:y,level3Feedback:N,setLevel3Feedback:S,level3Recommendation:C,setLevel3Recommendation:w,setIsSubmittingLevel3:R,setShowLevel3FeedbackModal:P,currentUser:A,fetchInterviews:I,fetchApplication:$,ktMatrixConfig:T,level2Config:E,level3Config:_}){const M=ne=>ne==="Approve"?"Recommended":ne==="Reject"?"Not Recommended":"Hold",q=ne=>ne==="Approve"?"Approved":ne==="Reject"?"Rejected":null,G=()=>T!=null&&T.items&&T.items.length>0?T.items.map(ne=>({name:ne.label,weight:Number(ne.weight)||0,maxScore:Number(ne.maxScore)||10,options:(ne.options||[]).map(oe=>({label:oe.optionLabel,value:oe.optionValue,score:Number(oe.score)||0}))})):[],Z=()=>E!=null&&E.items&&E.items.length>0?E.items:[],W=()=>_!=null&&_.items&&_.items.length>0?_.items:[],z=G(),F=Z(),B=W();return{handleKTMatrixChange:(ne,oe,re)=>{s(ge=>({...ge,[ne]:re})),n(ge=>({...ge,[ne]:oe}))},calculateKTScore:()=>{let ne=0;return z.forEach(oe=>{const re=t[oe.name||oe.label]||0,ge=oe.maxScore||10,ve=oe.weight||0;ne+=re/ge*ve}),ne.toFixed(2)},handleSubmitKTMatrix:async()=>{var oe,re;if(z.length===0){ee.error("KT Matrix configuration is missing. Please configure it in Master > Interview Configurations.");return}if(Object.keys(t).length<z.length){ee.warning("Please fill all fields in the KT Matrix");return}const ne=(d==null?void 0:d.id)||((oe=h.find(ge=>ge.status!=="Completed"))==null?void 0:oe.id)||((re=h[0])==null?void 0:re.id);if(!ne){ee.error("No active interview found to link this KT Matrix to.");return}try{x(!0);const ge=z.map(Se=>({criterionName:Se.name||Se.label,score:t[Se.name||Se.label]||0,maxScore:Se.maxScore||10,weightage:Se.weight||0}));await ds.submitKTMatrix({interviewId:ne,criteriaScores:ge,feedback:r,recommendation:M(l)});const ve=q(l);ve&&await ds.updateInterviewDecision({interviewId:ne,decision:ve,remarks:r||`Level 1 ${ve.toLowerCase()} via KT Matrix`}),ee.success(ve?`KT Matrix submitted and interview ${ve.toLowerCase()}`:"KT Matrix submitted and interview kept on hold"),f(!1),s({}),n({}),a(""),c("Approve"),await I(),await $()}catch{ee.error("Failed to submit KT Matrix")}finally{x(!1)}},handleLevel2Change:(ne,oe)=>{p(re=>({...re,[ne]:oe}))},handleSubmitLevel2Feedback:async()=>{var oe;if(F.length===0){ee.error("Level 2 feedback configuration is missing. Please configure it in Master > Interview Configurations.");return}if(!m.overallScore){ee.warning("Please provide an overall score.");return}const ne=(d==null?void 0:d.id)||((oe=h.find(re=>re.status!=="Completed"&&re.level===2))==null?void 0:oe.id);if(!ne){ee.error("No active Level 2 interview found to link this feedback to.");return}try{g(!0);const re=F.map(Se=>({type:Se.label,comments:m[Se.itemKey]||""})).filter(Se=>Se.comments.trim()!=="");await ds.submitLevel2Feedback({interviewId:ne,overallScore:Number(m.overallScore),feedbackItems:re,recommendation:M(u)});const ge=q(u),ve=m.additionalComments||"Level 2 decision submitted via feedback modal";ge&&await ds.updateInterviewDecision({interviewId:ne,decision:ge,remarks:ve}),ee.success(ge?`Level 2 feedback submitted and interview ${ge.toLowerCase()}`:"Level 2 feedback submitted and interview kept on hold"),y(!1),p(n$(A)),j("Approve"),await I(),await $()}catch{ee.error("Failed to submit Level 2 Feedback")}finally{g(!1)}},handleLevel3Change:(ne,oe)=>{S(re=>({...re,[ne]:oe}))},handleSubmitLevel3Feedback:async()=>{var oe;if(B.length===0){ee.error("Level 3 feedback configuration is missing. Please configure it in Master > Interview Configurations.");return}if(!N.overallScore){ee.warning("Please provide an overall score.");return}const ne=(d==null?void 0:d.id)||((oe=h.find(re=>re.status!=="Completed"&&re.level===3))==null?void 0:oe.id);if(!ne){ee.error("No active Level 3 interview found to link this feedback to.");return}try{R(!0);const re=B.map(Se=>({type:Se.label,comments:N[Se.itemKey]||""})).filter(Se=>Se.comments.trim()!=="");await ds.submitLevel2Feedback({interviewId:ne,overallScore:Number(N.overallScore),feedbackItems:re,recommendation:M(C)});const ge=q(C),ve=N.executiveSummary||N.additionalComments||"Level 3 decision submitted via feedback modal";ge&&await ds.updateInterviewDecision({interviewId:ne,decision:ge,remarks:ve}),ee.success(ge?`Level 3 feedback submitted and interview ${ge.toLowerCase()}`:"Level 3 feedback submitted and interview kept on hold"),P(!1),S(r$(A)),w("Approve"),await I(),await $()}catch{ee.error("Failed to submit Level 3 Feedback")}finally{R(!1)}},ktCriteria:z,l2Fields:F,l3Fields:B}}function i$(){const[t,s]=v.useState(null),[n,r]=v.useState(null),[a,l]=v.useState(null),[c,d]=v.useState(!1),[h,x]=v.useState(null),f=v.useCallback(async p=>{var u,j;try{const g=await Te.getInterviewConfigByType(p);if((u=g.data)!=null&&u.success)return g.data.data}catch(g){((j=g==null?void 0:g.response)==null?void 0:j.status)!==404&&console.warn(`Failed to fetch ${p} config:`,g)}return null},[]),m=v.useCallback(async()=>{d(!0),x(null);try{const[p,u,j]=await Promise.all([f("KT_MATRIX"),f("LEVEL2_FEEDBACK"),f("LEVEL3_FEEDBACK")]);s(p),r(u),l(j)}catch{x("Failed to load interview configurations"),ee.error("Failed to load interview configurations")}finally{d(!1)}},[f]);return v.useEffect(()=>{m()},[m]),{ktMatrixConfig:t,level2Config:n,level3Config:a,loading:c,error:h,refresh:m}}function l$(t){const{application:s,applicationId:n,currentUser:r,interviews:a,approvalFile:l,approvalRemark:c,rejectionReason:d,architectureLeadId:h,architectureStatus:x,architectureRemarks:f,selectedUser:m,participantType:p,users:u,interviewDate:j,interviewType:g,interviewMode:y,meetingLink:N,location:S,scheduledInterviewParticipants:C,uploadFile:w,uploadDocType:R,selectedStage:P,setIsApproving:A,setShowApproveModal:I,setApprovalRemark:$,setApprovalFile:T,setIsRejecting:E,setShowRejectModal:_,setRejectionReason:M,setIsAssigningArchitecture:q,setShowAssignArchitectureModal:G,setIsUpdatingArchitecture:Z,setShowArchitectureStatusModal:W,setIsAssigningParticipant:z,setSelectedUser:F,setShowAssignModal:B,setLoading:D,setIsScheduling:O,setShowScheduleModal:V,setShowCancelInterviewModal:K,interviewIdToCancel:Y,setInterviewIdToCancel:U,setIsCancellingInterview:X,setIsUploading:ne,setShowUploadForm:oe,setUploadFile:re,setUploadDocType:ge,setDocuments:ve,selectedInterviewerId:Se,setSelectedInterviewerId:We,setScheduledInterviewParticipants:Ce,setUsers:fe,showScheduleModal:Ye,showAssignArchitectureModal:be,showAssignModal:_e,fetchApplication:ke,fetchInterviews:qe,fetchEorData:Ve}=t,dt=()=>{if(!Se)return;const ie=(Array.isArray(u)?u:[]).find(Fe=>Fe.id===Se);ie&&!C.find(Fe=>Fe.id===ie.id)&&(Ce([...C,ie]),We(""))},xt=Ft=>{Ce(C.filter(ie=>ie.id!==Ft))},ye=v.useCallback(async Ft=>{if(!(!r||!["DD Admin","Super Admin","DD Lead","DD Head","NBH"].includes(r.role)))try{const ie={};if(Ft){const Ne={level1:["DD-ZM","RBM"],level2:["DD Lead","ZBH"],level3:["NBH","DD Head"]};Ne[Ft]&&(ie.preferredRoleCode=Ne[Ft]),s&&(ie.locationId=s.districtId||s.areaId||s.regionId||s.zoneId)}ie.isExternal=!1;const Fe=await ds.getUsers(ie),pe=(Array.isArray(Fe)?Fe:Fe&&Array.isArray(Fe.data)?Fe.data:Fe&&Array.isArray(Fe.users)?Fe.users:[]).filter(Ne=>(Ne.status||"").toLowerCase()!=="inactive");fe(pe.sort((Ne,Ee)=>String(Ne.fullName||Ne.name||"").localeCompare(String(Ee.fullName||Ee.name||""))))}catch{fe([])}},[r,s,fe]),le=v.useCallback(()=>{if(!Ye||!s)return;const Ft=parseInt(g.replace("level",""))||1,ie={1:["DD-ZM","RBM"],2:["DD Lead","ZBH"],3:["NBH","DD Head"]},Fe=st=>String(st||"").trim().toLowerCase().replace(/[_\s-]+/g," "),Q=(ie[Ft]||[]).map(Fe),pe=(st,bt)=>{var ut,yt,kt;const Ue=[(ut=st==null?void 0:st.metadata)==null?void 0:ut.role,(yt=bt==null?void 0:bt.role)==null?void 0:yt.roleName,(kt=bt==null?void 0:bt.role)==null?void 0:kt.roleCode,bt==null?void 0:bt.roleCode,bt==null?void 0:bt.role].filter(Boolean),Lt=Ue.find(Ie=>Q.includes(Fe(Ie)));return String(Lt||Ue[0]||"Panelist")},Ne=((s==null?void 0:s.participants)||[]).filter(st=>{var bt,Ue,Lt,ut,yt,kt,Ie,_t,ht;return((bt=st.metadata)==null?void 0:bt.interviewLevel)===Ft||((Ue=st.metadata)==null?void 0:Ue.interviewLevel)===String(Ft)||((ut=(Lt=st.metadata)==null?void 0:Lt.allAssignments)==null?void 0:ut.includes(Ft))||((kt=(yt=st.metadata)==null?void 0:yt.allAssignments)==null?void 0:kt.includes(String(Ft)))||Q.includes(Fe((Ie=st.user)==null?void 0:Ie.role))||Q.includes(Fe((_t=st.user)==null?void 0:_t.roleCode))||Q.includes(Fe((ht=st.metadata)==null?void 0:ht.role))}).map(st=>{const bt=st.user||{};return{...bt,__stageRole:pe(st,bt)}}).filter(st=>!!(st!=null&&st.id));if(Ne.length===0){Ce([]);return}const Ee=[],it=new Set;Ne.forEach(st=>{st.id&&!it.has(st.id)&&(it.add(st.id),Ee.push(st))}),Ce(Ee)},[Ye,s,g,Ce]),Qe=async()=>{if(!j){ee.warning("Please select date and time");return}try{O(!0),await ds.scheduleInterview({applicationId:s==null?void 0:s.id,level:g,scheduledAt:j,type:y==="virtual"?"Virtual Interview":"Physical Interview",location:y==="virtual"?N:S,participants:C.map(Ft=>Ft.id)}),ee.success("Interview scheduled successfully"),V(!1),await qe(),await ke()}catch{ee.error("Failed to schedule interview")}finally{O(!1)}},rt=async Ft=>{U(Ft),K(!0)},Kt=async()=>{if(Y)try{X(!0),await ds.updateInterview(Y,{status:"Cancelled"}),ee.success("Interview cancelled successfully"),K(!1),U(""),await qe()}catch{ee.error("Failed to cancel interview")}finally{X(!1)}},Rt=async()=>{if(!w||!R){ee.warning("Please select a file and document type");return}try{ne(!0);const Ft=new FormData;Ft.append("file",w),Ft.append("documentType",R),P&&Ft.append("stage",P),await ds.uploadDocument(n,Ft),ee.success("Document uploaded successfully"),oe(!1),re(null),ge("");const ie=await ds.getDocuments(n);ve(ie||[]),await Ve()}catch{ee.error("Failed to upload document")}finally{ne(!1)}},Re=async()=>{var Ft;try{A(!0);const ie=a.find(Ne=>{var Ee;return Ne.status!=="Completed"&&Ne.status!=="Cancelled"&&((Ee=Ne.participants)==null?void 0:Ee.some(it=>it.userId===(r==null?void 0:r.id)))});if(l&&n)try{const Ne=new FormData;Ne.append("file",l),Ne.append("documentType","Approval Attachment");let Ee=null;ie&&(ie.level===1||ie.level==="1"?Ee="1st Level Interview":ie.level===2||ie.level==="2"?Ee="2nd Level Interview":(ie.level===3||ie.level==="3")&&(Ee="3rd Level Interview")),Ee||(s.status==="Shortlisted"||s.status==="Level 1 Interview Pending"?Ee="1st Level Interview":s.status==="Level 1 Approved"||s.status==="Level 2 Interview Pending"?Ee="2nd Level Interview":(s.status==="Level 2 Approved"||s.status==="Level 3 Interview Pending")&&(Ee="3rd Level Interview")),Ee&&Ne.append("stage",Ee),await ds.uploadDocument(n,Ne)}catch{ee.error("Failed to upload document")}if(ie)try{await ds.updateInterviewDecision({interviewId:ie.id,decision:"Approved",remarks:c}),ee.success("Interview approved successfully"),I(!1),$(""),T(null),await qe(),await ke();return}catch{ee.error("Failed to approve interview");return}if(!c.trim()){ee.warning("Please enter a remark");return}let Fe=s.status;switch(s.status){case"Shortlisted":case"Level 1 Interview Pending":Fe="Level 1 Approved";break;case"Level 1 Approved":case"Level 2 Interview Pending":Fe="Level 2 Approved";break;case"Level 2 Approved":case"Level 3 Interview Pending":Fe="Level 3 Approved";break;case"Level 3 Approved":Fe="FDD Verification";break;case"FDD Verification":Fe="LOI In Progress";break;case"LOI In Progress":Fe="Security Details";break;case"Security Details":case"Payment Pending":Fe="LOI Issued";break;case"LOI Issued":Fe="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":Fe="LOA Pending";break;case"LOA Pending":Fe="EOR In Progress";break;case"EOR In Progress":Fe="EOR Complete";break;case"EOR Complete":Fe="Inauguration";break;case"Inauguration":case"Approved":Fe="Onboarded";break;default:Fe="Onboarded"}const pe={"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(pe){const Ne=await ds.submitStageDecision({applicationId:s.id,stageCode:pe,decision:"Approved",remarks:c,nextStatus:Fe});(Ft=Ne.data)!=null&&Ft.statusUpdated?ee.success(Ne.message||"Stage completed and moved to next step"):ee.info(Ne.message||"Approval recorded. Waiting for other mandatory approvers.")}else await ds.updateApplicationStatus(n,{status:Fe,remarks:c});Fe==="Onboarded"?(await ds.createDealer({applicationId:n}),ee.success("Application finalized and Dealer profile created!")):ee.success(`Application moved to ${Fe}`),I(!1),$(""),T(null),await ke()}catch(ie){ee.error(ie.message||"Failed to process approval")}finally{A(!1)}},Qt=async()=>{try{E(!0);const Ft=a.find(Q=>{var pe;return Q.status!=="Completed"&&Q.status!=="Cancelled"&&((pe=Q.participants)==null?void 0:pe.some(Ne=>Ne.userId===(r==null?void 0:r.id)))});if(Ft)try{await ds.updateInterviewDecision({interviewId:Ft.id,decision:"Rejected",remarks:d}),ee.success("Interview rejected"),_(!1),M(""),await qe(),await ke();return}catch{ee.error("Failed to reject interview");return}if(!d.trim()){ee.warning("Please enter a reason for rejection");return}const Fe={"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];Fe?await ds.submitStageDecision({applicationId:s.id,stageCode:Fe,decision:"Rejected",remarks:d,interviewId:Ft==null?void 0:Ft.id}):await ds.updateApplicationStatus(n,{status:"Rejected",remarks:d}),ee.success("Application rejected"),_(!1),M(""),await ke()}catch(Ft){ee.error(Ft.message||"Failed to process rejection")}finally{E(!1)}},qt=async()=>{try{await ds.generateDealerCodes(n),ee.success("Dealer codes generated successfully"),await ke()}catch(Ft){ee.error(Ft.message||"Failed to generate dealer codes")}},ws=async()=>{if(!h){ee.warning("Please select an architecture lead");return}try{q(!0),await ds.assignArchitectureTeam(n,h),ee.success("Architecture team assigned successfully"),G(!1),await ke()}catch(Ft){ee.error(Ft.message||"Failed to assign architecture team")}finally{q(!1)}},_s=async()=>{try{Z(!0),await ds.updateArchitectureStatus(n,x,f),ee.success("Architecture status updated successfully"),W(!1),await ke()}catch{ee.error("Failed to update architecture status")}finally{Z(!1)}},ns=async()=>{if(!m){ee.warning("Please select a user");return}try{z(!0);const Ft=Array.isArray(u)?u.find(ie=>ie.id===m):null;Ft&&(Ft.role==="FDD"||Ft.roleCode==="FDD")&&(await ds.assignFddAgency({applicationId:n,assignedToAgency:m}),ee.info(`${Ft.fullName||Ft.name} assigned as FDD Agency based on role.`)),await ds.addParticipant({requestId:n,requestType:"application",userId:m,participantType:p||"contributor"}),ee.success("User assigned successfully!"),await ke(),F(""),B(!1)}catch{ee.error("Failed to assign user")}finally{z(!1)}},Cs=async()=>{try{D(!0),await ds.retriggerEvaluators(n),ee.success("Evaluators re-assigned successfully"),await ke()}catch{ee.error("Failed to re-assign evaluators")}finally{D(!1)}},Bs=v.useCallback(async()=>{if(Ye&&s){await ye(g),le();return}(be||_e)&&s&&await ye()},[Ye,be,_e,s,g,ye,le]);return{handleAddInterviewer:dt,handleRemoveInterviewer:xt,fetchUsers:ye,maybeFetchUsersForModal:Bs,handleScheduleInterview:Qe,handleCancelInterview:rt,handleConfirmCancelInterview:Kt,handleUpload:Rt,handleApprove:Re,handleReject:Qt,handleGenerateDealerCodes:qt,handleAssignArchitecture:ws,handleUpdateArchitectureStatus:_s,handleAddParticipant:ns,handleRetriggerEvaluators:Cs}}const hE={getChecklist:async(t,s)=>{const n=s?`/eor/relocation/${s}`:`/eor/application/${t}`;return(await ze.get(n)).data},createChecklist:async t=>(await ze.post("/eor",t)).data,updateItem:async(t,s)=>(await ze.post(`/eor/item/${t}`,s)).data,submitAudit:async(t,s)=>(await ze.post(`/eor/audit/${t}`,s)).data},Gx=Object.freeze(Object.defineProperty({__proto__:null,eorService:hE},Symbol.toStringTag,{value:"Module"})),o$={getAuditLogs:async(t,s,n=1,r=50)=>{var a;try{const l=await Te.getAuditLogs(t,s,n,r);return((a=l.data)==null?void 0:a.data)||l.data||[]}catch(l){throw console.error("Get audit logs error:",l),l}},getAuditSummary:async(t,s)=>{var n;try{const r=await Te.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}}},c$={getWorknotes:async(t,s)=>{var r,a;const n=await Te.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 Te.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 Te.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 Te.removeParticipant(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to remove participant");return s.data}};function d$({applicationId:t}){const[s,n]=v.useState(null),[r,a]=v.useState(!0),[l,c]=v.useState([]),[d,h]=v.useState(null),[x,f]=v.useState([]),[m,p]=v.useState(!1),[u,j]=v.useState([]),[g,y]=v.useState([]),[N,S]=v.useState({}),C=v.useCallback(async()=>{try{const A=await ds.getDocuments(t);c(A||[])}catch(A){console.error("Failed to refresh documents:",A)}},[t]),w=v.useCallback(async(A=!1)=>{try{A||a(!0);const I=await ds.getApplicationById(t),$=(E,_)=>{var q;const M=(q=I.progressTracking)==null?void 0:q.find(G=>G.stageName===E);if(M!=null&&M.stageCompletedAt)return new Date(M.stageCompletedAt).toISOString();if(M!=null&&M.stageStartedAt)return new Date(M.stageStartedAt).toISOString();if(_){const G=(I.statusHistory||[]).find(Z=>Z.newStatus===_);if(G)return new Date(G.createdAt).toISOString()}},T={id:I.id,registrationNumber:I.applicationId||"N/A",name:I.applicantName,email:I.email,phone:I.phone,age:I.age,education:I.education,residentialAddress:I.address||I.city||"",businessAddress:I.address||"",preferredLocation:I.preferredLocation,state:I.state,ownsBike:I.ownRoyalEnfield==="yes",pastExperience:I.experienceYears?`${I.experienceYears} years`:I.description||"",status:I.overallStatus,questionnaireMarks:I.score||I.questionnaireMarks||0,questionnaireResponses:I.questionnaireResponses||[],rank:0,totalApplicantsAtLocation:0,assignedUsers:[],progress:I.progressPercentage||0,isShortlisted:I.isShortlisted||!0,companyName:I.companyName,source:I.source,existingDealer:I.existingDealer,royalEnfieldModel:I.royalEnfieldModel,description:I.description,pincode:I.pincode,locationType:I.locationType,ownRoyalEnfield:I.ownRoyalEnfield,address:I.address,submissionDate:I.createdAt?new Date(I.createdAt).toISOString():"",questionnaireDate:$("Questionnaire","Questionnaire Completed")||$("Questionnaire","Questionnaire Pending"),shortlistDate:$("Shortlist","Shortlisted"),level1InterviewDate:$("1st Level Interview","Level 1 Approved"),level2InterviewDate:$("2nd Level Interview","Level 2 Approved"),level3InterviewDate:$("3rd Level Interview","Level 3 Approved"),fddDate:$("FDD","FDD Verification"),loiApprovalDate:$("LOI Approval","LOI In Progress"),securityDetailsDate:$("Security Details","Security Details"),loiIssueDate:$("LOI Issue","LOI Issued"),dealerCodeDate:$("Dealer Code Generation","Dealer Code Generation"),architectureAssignedDate:$("Architecture Team Assigned","Architecture Team Assigned"),architectureDocumentDate:$("Architecture Document Upload","Architecture Document Upload"),architectureCompletionDate:$("Architecture Team Completion","Architecture Team Completion"),loaDate:$("LOA","LOA Pending"),eorCompleteDate:$("EOR Complete","EOR Complete"),inaugurationDate:$("Inauguration","Inauguration"),onboardedDate:I.overallStatus==="Onboarded"?I.updatedAt?new Date(I.updatedAt).toISOString():new Date().toISOString():void 0,progressTracking:I.progressTracking||[],participants:I.participants||[],dealerCode:I.dealerCode,zoneId:I.zoneId,regionId:I.regionId,areaId:I.areaId,districtId:I.districtId,stageApprovals:I.stageApprovals||[],fddAssignments:I.fddAssignments||[],constitutionType:I.constitutionType,architectureStatus:I.architectureStatus,statutoryStatus:I.statutoryStatus,panNumber:I.panNumber,gstNumber:I.gstNumber,bankName:I.bankName,accountNumber:I.accountNumber,ifscCode:I.ifscCode,branchName:I.branchName,accountHolderName:I.accountHolderName,registeredAddress:I.registeredAddress};n(T),I.uploadedDocuments&&c(I.uploadedDocuments||[])}catch(I){console.error("Failed to fetch application details",I)}finally{a(!1)}},[t]),R=v.useCallback(async()=>{if(t)try{const A=await hE.getChecklist(t);A.success&&A.data&&h(A.data)}catch{h(null)}},[t]),P=A=>g.find(I=>I.depositType===A);return v.useEffect(()=>{t&&(w(),C())},[t]),v.useEffect(()=>{t&&R()},[t,s==null?void 0:s.status]),v.useEffect(()=>{if(!(s!=null&&s.id))return;(async()=>{p(!0);try{const I=await o$.getAuditLogs("application",s.id,1,100);f(Array.isArray(I)?I:[])}catch{f([])}finally{p(!1)}try{const I=await c$.getWorknotes("application",s.id);j(I.data||[])}catch{j([])}})()},[s==null?void 0:s.id]),v.useEffect(()=>{if(!t)return;(async()=>{try{const[I,$]=await Promise.all([ds.getSecurityDeposit(t),ds.getSystemConfigs({category:"SECURITY_DEPOSIT",format:"map"})]);y(Array.isArray(I)?I:[I].filter(Boolean)),S($||{})}catch(I){console.error("Failed to fetch payment data",I)}})()},[t]),{application:s,loading:r,setLoading:a,documents:l,setDocuments:c,eorData:d,auditLogs:x,auditLoading:m,worknotes:u,deposits:g,paymentConfigs:N,refreshDocuments:C,fetchApplication:w,fetchEorData:R,getDeposit:P}}function u$({application:t,applicationId:s,tempFirmType:n,setUpdatingFirmType:r,setShowFirmTypeModal:a,setStatutoryForm:l,setIsEditingStatutory:c,setIsSavingStatutory:d,statutoryForm:h,setFddAgencies:x,selectedAgencyId:f,setIsAssigningAgency:m,fetchApplication:p}){const u=async()=>{try{r(!0),await ds.updateApplication(s,{constitutionType:n}),ee.success("Firm type updated successfully"),a(!1),await p()}catch{ee.error("Failed to update firm type")}finally{r(!1)}},j=()=>{t&&(l({accountHolderName:t.accountHolderName||"",panNumber:t.panNumber||"",gstNumber:t.gstNumber||"",bankName:t.bankName||"",accountNumber:t.accountNumber||"",ifscCode:t.ifscCode||"",registeredAddress:t.registeredAddress||""}),c(!0))},g=async()=>{try{d(!0),await ds.updateApplication(s,h),ee.success("Statutory & Bank details updated successfully"),c(!1),await p(!0)}catch{ee.error("Failed to update details")}finally{d(!1)}},y=v.useCallback(async()=>{try{const S=await ds.getUsers({roleCode:"FDD"});x(Array.isArray(S)?S:[])}catch{x([])}},[x]);return{handleUpdateFirmType:u,handleEditStatutory:j,handleSaveStatutory:g,fetchFddAgencies:y,handleAssignAgency:async()=>{if(!f){ee.warning("Please select an agency");return}try{m(!0),await ds.assignFddAgency({applicationId:(t==null?void 0:t.id)||s,assignedToAgency:f}),await ds.addParticipant({requestId:(t==null?void 0:t.id)||s,requestType:"application",userId:f,participantType:"contributor"}),ee.success("FDD Agency assigned and added as participant"),await p()}catch{ee.error("Failed to assign agency")}finally{m(!1)}}}}function h$({application:t,documents:s,interviews:n,eorData:r,getDeposit:a}){var g;const l=y=>String(y||"").trim().toLowerCase().replace(/[_\s-]+/g," "),c=(y,N)=>{var w,R,P;const S=[(w=y==null?void 0:y.user)==null?void 0:w.role,(R=y==null?void 0:y.user)==null?void 0:R.roleCode,(P=y==null?void 0:y.metadata)==null?void 0:P.role].map(l),C=N.map(l);return S.some(A=>C.includes(A))},d=y=>{var N,S,C,w,R;return`${((N=y==null?void 0:y.user)==null?void 0:N.fullName)||((S=y==null?void 0:y.user)==null?void 0:S.name)||"User"} (${((C=y==null?void 0:y.user)==null?void 0:C.role)||((w=y==null?void 0:y.user)==null?void 0:w.roleCode)||((R=y==null?void 0:y.metadata)==null?void 0:R.role)||(y==null?void 0:y.participantType)||"participant"})`},h=y=>(s||[]).some(N=>N.documentType===y),x=y=>(n||[]).some(N=>{var S;return(N.level===y||N.level===y.toString())&&((S=N.status)==null?void 0:S.toLowerCase())==="scheduled"}),f=(y,N)=>{const S=(t.progressTracking||[]).find(C=>C.stageName===y);return S&&(S.status==="completed"||S.status==="active")?S.status:N()},m=[{id:1,name:"Submitted",status:"completed",date:t.submissionDate,description:"Application submitted",documentsUploaded:3},{id:2,name:"Questionnaire",status:f("Questionnaire",()=>["Questionnaire Completed","Shortlisted","Level 1 Interview Pending","Level 1 Approved","Level 2 Interview Pending","Level 2 Approved","Level 2 Recommended","Level 3 Interview Pending","Level 3 Approved","FDD Verification","LOI In Progress","Payment Pending","LOI Issued","Statutory LOI Ack","Dealer Code Generation","Architecture Work","Statutory Work","LOA Pending","LOA Issued","EOR In Progress","EOR Complete","Inauguration","Approved","Onboarded"].includes(t.status)?"completed":t.status==="Questionnaire Pending"?"active":"pending"),date:t.questionnaireDate,description:"Questionnaire completed",documentsUploaded:0},{id:3,name:"Shortlist",status:f("Shortlist",()=>["Shortlisted","Level 1 Interview Pending","Level 1 Approved","Level 2 Interview Pending","Level 2 Approved","Level 2 Recommended","Level 3 Interview Pending","Level 3 Approved","FDD Verification","LOI In Progress","Payment Pending","LOI Issued","Statutory LOI Ack","Dealer Code Generation","Architecture Work","Statutory Work","LOA Pending","LOA Issued","EOR In Progress","EOR Complete","Inauguration","Approved","Rejected","Onboarded"].includes(t.status)?"completed":"pending"),date:t.shortlistDate,description:"Application shortlisted by DD",evaluators:Array.from(new Set((t.participants||[]).filter(y=>y.participantType==="assignee").map(y=>{var N,S,C;return`${((N=y.user)==null?void 0:N.fullName)||((S=y.user)==null?void 0:S.name)||"User"} (${((C=y.user)==null?void 0:C.roleCode)||y.participantType})`}))),documentsUploaded:2},{id:4,name:"1st Level Interview",status:f("1st Level Interview",()=>["Level 1 Approved","Level 2 Interview Pending","Level 2 Approved","Level 2 Recommended","Level 3 Interview Pending","Level 3 Approved","FDD Verification","LOI In Progress","Payment Pending","LOI Issued","Statutory LOI Ack","Dealer Code Generation","Architecture Work","Statutory Work","LOA Pending","LOA Issued","EOR In Progress","EOR Complete","Inauguration","Approved","Onboarded"].includes(t.status)?"completed":t.status==="Level 1 Interview Pending"&&x(1)?"active":"pending"),date:t.level1InterviewDate,description:"DD-ZM + RBM evaluation",evaluators:Array.from(new Set((t.participants||[]).filter(y=>{var N,S,C,w,R,P;return((N=y.metadata)==null?void 0:N.interviewLevel)===1||((S=y.metadata)==null?void 0:S.interviewLevel)==="1"||((w=(C=y.metadata)==null?void 0:C.allAssignments)==null?void 0:w.includes(1))||((P=(R=y.metadata)==null?void 0:R.allAssignments)==null?void 0:P.includes("1"))||c(y,["DD-ZM","RBM"])}).map(d))),documentsUploaded:1},{id:5,name:"2nd Level Interview",status:f("2nd Level Interview",()=>["Level 2 Approved","Level 2 Recommended","Level 3 Interview Pending","Level 3 Approved","FDD Verification","LOI In Progress","Payment Pending","LOI Issued","Statutory LOI Ack","Dealer Code Generation","Architecture Work","Statutory Work","LOA Pending","LOA Issued","EOR In Progress","EOR Complete","Inauguration","Approved","Onboarded"].includes(t.status)?"completed":t.status==="Level 2 Interview Pending"&&x(2)?"active":"pending"),date:t.level2InterviewDate,description:"DD Lead + ZBH evaluation",evaluators:Array.from(new Set((t.participants||[]).filter(y=>{var N,S,C,w,R,P;return((N=y.metadata)==null?void 0:N.interviewLevel)===2||((S=y.metadata)==null?void 0:S.interviewLevel)==="2"||((w=(C=y.metadata)==null?void 0:C.allAssignments)==null?void 0:w.includes(2))||((P=(R=y.metadata)==null?void 0:R.allAssignments)==null?void 0:P.includes("2"))||c(y,["DD Lead","ZBH"])}).map(d))),documentsUploaded:1},{id:6,name:"3rd Level Interview",status:f("3rd Level Interview",()=>["Level 3 Approved","FDD Verification","LOI In Progress","Payment Pending","LOI Issued","Statutory LOI Ack","Dealer Code Generation","Architecture Work","Statutory Work","LOA Pending","LOA Issued","EOR In Progress","EOR Complete","Inauguration","Approved","Onboarded"].includes(t.status)?"completed":t.status==="Level 3 Interview Pending"&&x(3)?"active":"pending"),date:t.level3InterviewDate,description:"NBH + DD Head evaluation",evaluators:Array.from(new Set((t.participants||[]).filter(y=>{var N,S,C,w,R,P;return((N=y.metadata)==null?void 0:N.interviewLevel)===3||((S=y.metadata)==null?void 0:S.interviewLevel)==="3"||((w=(C=y.metadata)==null?void 0:C.allAssignments)==null?void 0:w.includes(3))||((P=(R=y.metadata)==null?void 0:R.allAssignments)==null?void 0:P.includes("3"))||c(y,["NBH","DD Head"])}).map(d))),documentsUploaded:2},{id:7,name:"FDD",status:f("FDD",()=>["LOI In Progress","Payment Pending","LOI Issued","Statutory LOI Ack","Dealer Code Generation","Architecture Work","Statutory Work","LOA Pending","LOA Issued","EOR In Progress","EOR Complete","Inauguration","Approved","Onboarded"].includes(t.status)?"completed":t.status==="FDD Verification"?"active":"pending"),date:t.fddDate,description:"Financial Due Diligence",documentsUploaded:5},{id:8,name:"LOI Approval",status:f("LOI Approval",()=>["Security Details","Payment Pending","LOI Issued","Statutory LOI Ack","Dealer Code Generation","Architecture Work","Statutory Work","LOA Pending","LOA Issued","EOR In Progress","EOR Complete","Inauguration","Approved","Onboarded"].includes(t.status)?"completed":t.status==="LOI In Progress"?"active":"pending"),date:t.loiApprovalDate,description:"Letter of Intent approval",evaluators:Array.from(new Set((t.participants||[]).filter(y=>{var N,S,C;return((N=y.metadata)==null?void 0:N.stageCode)==="LOI_APPROVAL"||((C=(S=y.metadata)==null?void 0:S.allAssignments)==null?void 0:C.includes("LOI_APPROVAL"))}).map(d))),documentsUploaded:1},{id:9,name:"Security Details",status:f("Security Details",()=>["LOI Issued","Statutory LOI Ack","Dealer Code Generation","Architecture Work","Statutory Work","LOA Pending","LOA Issued","EOR In Progress","EOR Complete","Inauguration","Approved","Onboarded"].includes(t.status)?"completed":t.status==="Security Details"||t.status==="Payment Pending"?"active":"pending"),date:t.securityDetailsDate,description:"Security verification",documentsUploaded:3},{id:10,name:"LOI Issue",status:f("LOI Issue",()=>["Statutory LOI Ack","Dealer Code Generation","Architecture Work","Statutory Work","LOA Pending","LOA Issued","EOR In Progress","EOR Complete","Inauguration","Approved","Onboarded"].includes(t.status)?"completed":t.status==="LOI Issued"?"active":"pending"),date:t.loiIssueDate,description:"Letter of Intent issued",documentsUploaded:1},{id:11,name:"Dealer Code Generation",status:f("Dealer Code Generation",()=>t.dealerCode||["Dealer Code Generation","Architecture Work","Statutory Work","LOA Pending","LOA Issued","EOR In Progress","EOR Complete","Inauguration","Approved","Onboarded"].includes(t.status)?"completed":"pending"),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:h("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"||h("Architecture Blueprint")?"active":"pending",description:"Final architecture approval"}]},{name:"Statutory Documents",color:"green",stages:[{id:"11b-1",name:"GST",status:h("GST Certificate")||h("GST")?"completed":"active",description:"GST certificate"},{id:"11b-2",name:"PAN",status:h("PAN Card")||h("PAN")?"completed":"active",description:"PAN card"},{id:"11b-3",name:"Nodal Agreement",status:h("Nodal Agreement")?"completed":"active",description:"Nodal agreement document"},{id:"11b-4",name:"Cancelled Check",status:h("Cancelled Check")?"completed":"active",description:"Cancelled check copy"},{id:"11b-5",name:"Partnership Deed/LLP/MOA/AOA/COI",status:h("Partnership Deed/LLP/MOA/AOA/COI")||h("Partnership Deed")?"completed":"active",description:"Business entity documents"},{id:"11b-6",name:"Firm Registration Certificate",status:h("Firm Registration Certificate")||h("Firm Registration")?"completed":"active",description:"Firm registration certificate"},{id:"11b-7",name:"Rental agreement/ Lease agreement / Own/ Land agreement",status:h("Rental agreement/ Lease agreement / Own/ Land agreement")||h("Property Document")?"completed":"active",description:"Property agreement document"},{id:"11b-8",name:"Virtual Code",status:h("Virtual Code")||h("Virtual Code Confirmation")?"completed":"active",description:"Virtual code availability"},{id:"11b-9",name:"Domain ID",status:h("Domain ID")||h("Domain ID Setup")?"completed":"active",description:"Domain ID setup"},{id:"11b-10",name:"MSD Configuration",status:h("MSD Configuration")?"completed":"active",description:"Microsoft Dynamics configuration"},{id:"11b-11",name:"LOI Acknowledgement Copy",status:h("LOI Acknowledgement Copy")||h("LOI Acknowledgement")?"completed":"active",description:"LOI acknowledgement copy"}]}]},{id:12,name:"LOA",status:f("LOA",()=>["EOR In Progress","EOR Complete","Inauguration","Approved","Onboarded"].includes(t.status)?"completed":t.status==="LOA Pending"?"active":"pending"),isLocked:t.status==="LOA Pending"&&((g=a("FIRST_FILL"))==null?void 0:g.status)!=="Verified",lockMessage:"First Fill (₹15L) must be verified by Finance before LOA Approval.",evaluators:Array.from(new Set((t.participants||[]).filter(y=>{var N,S,C;return((N=y.metadata)==null?void 0:N.stageCode)==="LOA_APPROVAL"||((C=(S=y.metadata)==null?void 0:S.allAssignments)==null?void 0:C.includes("LOA_APPROVAL"))}).map(d))),description:"Letter of Authorization"},{id:13,name:"EOR Complete",status:f("EOR Complete",()=>["Inauguration","Approved","Onboarded"].includes(t.status)?"completed":t.status==="EOR Complete"?"active":"pending"),description:"Essential Operating Requirements"},{id:14,name:"Inauguration",status:f("Inauguration",()=>["Approved","Onboarded"].includes(t.status)?"completed":t.status==="Inauguration"?"active":"pending"),description:"Dealership inauguration"},{id:15,name:"Dealership Active",status:f("Onboarded",()=>t.status==="Onboarded"?"completed":["Inauguration","Approved"].includes(t.status)?"active":"pending"),description:"Dealer profile active"}],p=[{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}],u=m.reduce((y,N)=>(y.push({name:N.name}),N.branches&&N.branches.forEach(S=>S.stages.forEach(C=>y.push({name:C.name,parentBranch:S.name}))),(N.name==="EOR In Progress"||N.name==="EOR Complete")&&((r==null?void 0:r.items)||p).forEach(S=>y.push({name:`EOR: ${S.description||S.item}`,parentBranch:"EOR"})),y),[]);return{processStages:m,eorChecklist:p,flattenedStages:u,getDocumentsForStage:y=>s.filter(N=>{var S;return N.stage===y||!N.stage&&((S=N.documentType)==null?void 0:S.toLowerCase().includes(y.toLowerCase().split(" ")[0]))})}}const o1=()=>{var ul;const{id:t}=Bc(),s=qn(),{user:n}=Nn(ga=>ga.auth),r=t||"",a=()=>s(-1),{application:l,loading:c,setLoading:d,documents:h,setDocuments:x,eorData:f,auditLogs:m,auditLoading:p,worknotes:u,deposits:j,paymentConfigs:g,refreshDocuments:y,fetchApplication:N,fetchEorData:S,getDeposit:C}=d$({applicationId:r}),w=f!=null&&f.items?f.items.filter(ga=>ga.isCompliant).length/f.items.length*100:0,R=Ul(),{showFirmTypeModal:P,setShowFirmTypeModal:A,updatingFirmType:I,setUpdatingFirmType:$,tempFirmType:T,setTempFirmType:E,activeTab:_,setActiveTab:M,showApproveModal:q,setShowApproveModal:G,showOnboardModal:Z,setShowOnboardModal:W,isOnboarding:z,setIsOnboarding:F,showRejectModal:B,setShowRejectModal:D,rejectionReason:O,setRejectionReason:V,scheduledInterviewParticipants:K,setScheduledInterviewParticipants:Y,showScheduleModal:U,setShowScheduleModal:X,showCancelInterviewModal:ne,setShowCancelInterviewModal:oe,interviewIdToCancel:re,setInterviewIdToCancel:ge,showKTMatrixModal:ve,setShowKTMatrixModal:Se,showLevel2FeedbackModal:We,setShowLevel2FeedbackModal:Ce,showLevel3FeedbackModal:fe,setShowLevel3FeedbackModal:Ye,showDocumentsModal:be,setShowDocumentsModal:_e,showAssignModal:ke,setShowAssignModal:qe,selectedStage:Ve,setSelectedStage:dt,interviewMode:xt,setInterviewMode:ye,approvalRemark:le,setApprovalRemark:Qe,expandedBranches:rt,setExpandedBranches:Kt,users:Rt,setUsers:Re,selectedUser:Qt,setSelectedUser:qt,participantType:ws,setParticipantType:_s,interviewDate:ns,setInterviewDate:Cs,interviewType:Bs,setInterviewType:Ft,meetingLink:ie,setMeetingLink:Fe,location:Q,setLocation:pe,showUploadForm:Ne,setShowUploadForm:Ee,uploadFile:it,setUploadFile:st,uploadDocType:bt,setUploadDocType:Ue,approvalFile:Lt,setApprovalFile:ut,isUploading:yt,setIsUploading:kt,previewDoc:Ie,setPreviewDoc:_t,showPreviewModal:ht,setShowPreviewModal:zt,selectedInterviewerId:rs,setSelectedInterviewerId:Yt,isEditingStatutory:Os,setIsEditingStatutory:Is,statutoryForm:zs,setStatutoryForm:en,isSavingStatutory:he,setIsSavingStatutory:Ge,interviews:at,setInterviews:pt,isScheduling:mt,setIsScheduling:Bt,isCancellingInterview:Ds,setIsCancellingInterview:as,showAssignArchitectureModal:Vs,setShowAssignArchitectureModal:Ls,architectureLeadId:Ts,setArchitectureLeadId:ln,isAssigningArchitecture:pn,setIsAssigningArchitecture:hn,showArchitectureStatusModal:Ws,setShowArchitectureStatusModal:Qs,architectureStatus:zn,setArchitectureStatus:on,architectureRemarks:Un,setArchitectureRemarks:yr,isUpdatingArchitecture:Tr,setIsUpdatingArchitecture:er,isAssigningParticipant:tr,setIsAssigningParticipant:En,documentConfigs:Xe,setDocumentConfigs:$t,fddAgencies:Ze,setFddAgencies:Ut,selectedAgencyId:jt,setSelectedAgencyId:In,isAssigningAgency:jr,setIsAssigningAgency:Pr,isApproving:xn,setIsApproving:qs,isRejecting:ha,setIsRejecting:Tt,ktMatrixScores:xs,setKtMatrixScores:Vr,ktMatrixSelectedValues:ta,setKtMatrixSelectedValues:ma,ktMatrixRemarks:_r,setKtMatrixRemarks:sr,ktMatrixRecommendation:gn,setKtMatrixRecommendation:mn,isSubmittingKT:Qn,setIsSubmittingKT:fr,selectedInterviewForFeedback:pr,setSelectedInterviewForFeedback:dn,showFddFinalizeModal:wn,setShowFddFinalizeModal:Da,showFddFlagModal:fa,setShowFddFlagModal:Ai,fddAuditRecommendation:ki,setFddAuditRecommendation:ni,fddAuditFindings:rl,setFddAuditFindings:Go,isFinalizingFdd:Ta,setIsFinalizingFdd:ri,isFddFlagging:Pa,setIsFddFlagging:_a,level2Feedback:to,setLevel2Feedback:Zc,level2Recommendation:Oa,setLevel2Recommendation:Vn,isSubmittingLevel2:ai,setIsSubmittingLevel2:Ri,level3Feedback:Or,setLevel3Feedback:so,level3Recommendation:Ei,setLevel3Recommendation:no,isSubmittingLevel3:ii,setIsSubmittingLevel3:al,showFeedbackDetailsModal:ro,setShowFeedbackDetailsModal:Hs,selectedEvaluationForView:J,setSelectedEvaluationForView:te}=s$({initialTab:((ul=R.state)==null?void 0:ul.activeTab)||"questionnaire"}),ue=(u||[]).some(ga=>(ga.noteText||"").includes("FLAGGED:"))||(l==null?void 0:l.statutoryStatus)==="Flagged",{handleUpdateFirmType:xe,handleEditStatutory:we,handleSaveStatutory:$e,fetchFddAgencies:Be,handleAssignAgency:lt}=u$({application:l,applicationId:r,tempFirmType:T,setUpdatingFirmType:$,setShowFirmTypeModal:A,setStatutoryForm:en,setIsEditingStatutory:Is,setIsSavingStatutory:Ge,statutoryForm:zs,setFddAgencies:Ut,selectedAgencyId:jt,setIsAssigningAgency:Pr,fetchApplication:N}),Jt=(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",Mt=(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";v.useEffect(()=>{(async()=>{try{const li=await ds.getDocumentConfigs({limit:1e3}),Bf=li.data||(Array.isArray(li)?li:[]);$t(Bf)}catch(li){console.error("Failed to fetch document configs:",li)}})()},[$t]),v.useEffect(()=>{U&&l&&(l.status==="Shortlisted"||l.status==="Questionnaire Completed"?Ft("level1"):l.status==="Level 1 Approved"?Ft("level2"):(l.status==="Level 2 Approved"||l.status==="Level 2 Recommended")&&Ft("level3"))},[U,l==null?void 0:l.status,Ft]);const Et=async()=>{if(r)try{const ga=await ds.getInterviews(r);pt(ga||[])}catch(ga){console.error("Failed to fetch interviews",ga)}};v.useEffect(()=>{Et()},[r]);const{ktMatrixConfig:gs,level2Config:tn,level3Config:Hn}=i$(),{handleKTMatrixChange:Ot,calculateKTScore:bs,handleSubmitKTMatrix:es,handleLevel2Change:Sn,handleSubmitLevel2Feedback:xr,handleLevel3Change:Dn,handleSubmitLevel3Feedback:nr,ktCriteria:Ir,l2Fields:Ia,l3Fields:rr}=a$({ktMatrixScores:xs,setKtMatrixScores:Vr,setKtMatrixSelectedValues:ma,ktMatrixRemarks:_r,setKtMatrixRemarks:sr,ktMatrixRecommendation:gn,setKtMatrixRecommendation:mn,selectedInterviewForFeedback:pr,interviews:at,setIsSubmittingKT:fr,setShowKTMatrixModal:Se,level2Feedback:to,setLevel2Feedback:Zc,level2Recommendation:Oa,setLevel2Recommendation:Vn,setIsSubmittingLevel2:Ri,setShowLevel2FeedbackModal:Ce,level3Feedback:Or,setLevel3Feedback:so,level3Recommendation:Ei,setLevel3Recommendation:no,setIsSubmittingLevel3:al,setShowLevel3FeedbackModal:Ye,currentUser:n,fetchInterviews:Et,fetchApplication:N,ktMatrixConfig:gs,level2Config:tn,level3Config:Hn});v.useEffect(()=>{["documents","progress","fdd","eor"].includes(_)&&r&&y(),_==="fdd"&&((n==null?void 0:n.role)==="DD Admin"||(n==null?void 0:n.role)==="Super Admin")&&Be()},[_,r,y,Be,n==null?void 0:n.role]);const{handleAddInterviewer:ao,handleRemoveInterviewer:il,maybeFetchUsersForModal:io,handleScheduleInterview:lo,handleCancelInterview:ll,handleConfirmCancelInterview:Di,handleUpload:La,handleApprove:Ko,handleReject:ar,handleGenerateDealerCodes:Yo,handleAssignArchitecture:pa,handleUpdateArchitectureStatus:ol,handleAddParticipant:Ti,handleRetriggerEvaluators:xa}=l$({application:l,applicationId:r,currentUser:n,interviews:at,approvalFile:Lt,approvalRemark:le,rejectionReason:O,architectureLeadId:Ts,architectureStatus:zn,architectureRemarks:Un,selectedUser:Qt,participantType:ws,users:Rt,interviewDate:ns,interviewType:Bs,interviewMode:xt,meetingLink:ie,location:Q,scheduledInterviewParticipants:K,uploadFile:it,uploadDocType:bt,selectedStage:Ve,setIsApproving:qs,setShowApproveModal:G,setApprovalRemark:Qe,setApprovalFile:ut,setIsRejecting:Tt,setShowRejectModal:D,setRejectionReason:V,setIsAssigningArchitecture:hn,setShowAssignArchitectureModal:Ls,setIsUpdatingArchitecture:er,setShowArchitectureStatusModal:Qs,setIsAssigningParticipant:En,setSelectedUser:qt,setShowAssignModal:qe,setLoading:d,setIsScheduling:Bt,setShowScheduleModal:X,setShowCancelInterviewModal:oe,interviewIdToCancel:re,setInterviewIdToCancel:ge,setIsCancellingInterview:as,setIsUploading:kt,setShowUploadForm:Ee,setUploadFile:st,setUploadDocType:Ue,setDocuments:x,selectedInterviewerId:rs,setSelectedInterviewerId:Yt,setScheduledInterviewParticipants:Y,setUsers:Re,showScheduleModal:U,showAssignArchitectureModal:Vs,showAssignModal:ke,fetchApplication:N,fetchInterviews:Et,fetchEorData:S});if(v.useEffect(()=>{io()},[U,Vs,ke,Bs,l==null?void 0:l.id,io]),c&&!l)return e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx(ss,{className:"w-10 h-10 animate-spin text-amber-600"})});if(!l)return e.jsx("div",{className:"flex justify-center items-center h-96",children:"Application not found"});const{processStages:Ma,eorChecklist:cl,flattenedStages:Pi,getDocumentsForStage:oo}=h$({application:l,documents:h,interviews:at,eorData:f,getDeposit:C}),{activeInterviewForUser:ku,currentUserEvaluation:dl,hasSubmittedFeedback:Lf,currentUserStageAction:Mf,isInterviewCompleted:Ff,isInterviewActive:Ru,permissions:Eu}=t$({application:l,interviews:at,currentUser:n,getDeposit:C,eorProgress:w}),co=()=>e.jsx(J7,{application:l,currentUser:n,documents:h,fddAgencies:Ze,selectedAgencyId:jt,setSelectedAgencyId:In,isAssigningAgency:jr,handleAssignAgency:lt,setPreviewDoc:_t,setShowPreviewModal:zt,setIsUploading:kt,fetchApplication:N,refreshDocuments:y});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(M7,{application:l,isNonResponsive:ue,isAdmin:Mt,onBack:a,onOpenWorknotes:()=>s(`/worknotes/application/${l.id}`,{state:{applicationName:l.name,registrationNumber:l.registrationNumber,participants:l.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(V7,{application:l,canEditStatutory:Jt,isEditingStatutory:Os,isSavingStatutory:he,statutoryForm:zs,onEditFirmType:()=>{E(l.constitutionType||""),A(!0)},onEditStatutory:we,onCancelEditStatutory:()=>Is(!1),onSaveStatutory:$e,onStatutoryFormChange:en}),l.isShortlisted!==!1&&e.jsx(K7,{application:l,activeTab:_,setActiveTab:M,processStages:Ma,documents:h,interviews:at,expandedBranches:rt,setExpandedBranches:Kt,setSelectedStage:dt,setShowDocumentsModal:_e,setShowUploadForm:Ee,handleRetriggerEvaluators:xa,handleCancelInterview:ll,setSelectedEvaluationForView:te,setShowFeedbackDetailsModal:Hs,renderFddAuditContent:co,eorProgress:w,eorData:f,eorChecklist:cl,setUploadDocType:Ue,isAdmin:Mt,fetchApplication:N,fetchEorData:S,deposits:j,getDeposit:C,paymentConfigs:g,setPreviewDoc:_t,setShowPreviewModal:zt,auditLoading:p,auditLogs:m,auditLogActionBadgeClass:e$})]}),e.jsx(Y7,{application:l,permissions:Eu,getDeposit:C,isNonResponsive:ue,isAdmin:Mt,currentUserStageAction:Mf,currentUserEvaluation:dl,onOpenApproveModal:()=>G(!0),onOpenRejectModal:()=>D(!0),onOpenWorknote:()=>s(`/worknotes/application/${l.id}`,{state:{applicationName:l.name,registrationNumber:l.registrationNumber,participants:l.participants}}),onOpenScheduleModal:()=>X(!0),currentUser:n,handleGenerateDealerCodes:Yo,onOpenAssignArchitectureModal:()=>Ls(!0),activeInterviewForUser:ku,hasSubmittedFeedback:Lf,setSelectedInterviewForFeedback:dn,setShowKTMatrixModal:Se,setShowLevel2FeedbackModal:Ce,setShowLevel3FeedbackModal:Ye,onGoToDashboard:()=>s("/dashboard"),showAssignModal:ke,setShowAssignModal:qe,selectedUser:Qt,setSelectedUser:qt,users:Rt,participantType:ws,setParticipantType:_s,handleAddParticipant:Ti,isAssigningParticipant:tr}),e.jsx(Z7,{application:l,fetchApplication:N,showApproveModal:q,setShowApproveModal:G,approvalRemark:le,setApprovalRemark:Qe,setApprovalFile:ut,isApproving:xn,handleApprove:Ko,showOnboardModal:Z,setShowOnboardModal:W,isOnboarding:z,setIsOnboarding:F,showRejectModal:B,setShowRejectModal:D,rejectionReason:O,setRejectionReason:V,isRejecting:ha,handleReject:ar,showScheduleModal:U,setShowScheduleModal:X,showCancelInterviewModal:ne,setShowCancelInterviewModal:oe,setInterviewIdToCancel:ge,isCancellingInterview:Ds,handleConfirmCancelInterview:Di,interviewType:Bs,setInterviewType:Ft,interviewMode:xt,setInterviewMode:ye,interviewDate:ns,setInterviewDate:Cs,meetingLink:ie,setMeetingLink:Fe,location:Q,setLocation:pe,isInterviewCompleted:Ff,isInterviewActive:Ru,users:Rt,selectedInterviewerId:rs,setSelectedInterviewerId:Yt,handleAddInterviewer:ao,scheduledInterviewParticipants:K,handleRemoveInterviewer:il,isScheduling:mt,handleScheduleInterview:lo,showAssignArchitectureModal:Vs,setShowAssignArchitectureModal:Ls,architectureLeadId:Ts,setArchitectureLeadId:ln,isAssigningArchitecture:pn,handleAssignArchitecture:pa,showArchitectureStatusModal:Ws,setShowArchitectureStatusModal:Qs,architectureStatus:zn,setArchitectureStatus:on,architectureRemarks:Un,setArchitectureRemarks:yr,isUpdatingArchitecture:Tr,handleUpdateArchitectureStatus:ol}),e.jsx(Q7,{application:l,ktCriteria:Ir,l2Fields:Ia,l3Fields:rr,showKTMatrixModal:ve,setShowKTMatrixModal:Se,ktMatrixSelectedValues:ta,handleKTMatrixChange:Ot,ktMatrixRemarks:_r,setKtMatrixRemarks:sr,ktMatrixRecommendation:gn,setKtMatrixRecommendation:mn,calculateKTScore:bs,handleSubmitKTMatrix:es,isSubmittingKT:Qn,showLevel2FeedbackModal:We,setShowLevel2FeedbackModal:Ce,level2Feedback:to,handleLevel2Change:Sn,level2Recommendation:Oa,setLevel2Recommendation:Vn,handleSubmitLevel2Feedback:xr,isSubmittingLevel2:ai,showFeedbackDetailsModal:ro,setShowFeedbackDetailsModal:Hs,selectedEvaluationForView:J,selectedInterviewForFeedback:pr,showLevel3FeedbackModal:fe,setShowLevel3FeedbackModal:Ye,level3Feedback:Or,handleLevel3Change:Dn,level3Recommendation:Ei,setLevel3Recommendation:no,handleSubmitLevel3Feedback:nr,isSubmittingLevel3:ii,showDocumentsModal:be,setShowDocumentsModal:_e,showUploadForm:Ne,setShowUploadForm:Ee,selectedStage:Ve,getDocumentsForStage:oo,setPreviewDoc:_t,setShowPreviewModal:zt,flattenedStages:Pi,setSelectedStage:dt,uploadDocType:bt,setUploadDocType:Ue,setUploadFile:st,isUploading:yt,handleUpload:La,uploadFile:it,documentConfigs:Xe,showPreviewModal:ht,previewDoc:Ie,showFddFinalizeModal:wn,setShowFddFinalizeModal:Da,currentUser:n,fddAuditRecommendation:ki,setFddAuditRecommendation:ni,fddAuditFindings:rl,setFddAuditFindings:Go,isFinalizingFdd:Ta,setIsFinalizingFdd:ri,fetchApplication:N,showFddFlagModal:fa,setShowFddFlagModal:Ai,isFddFlagging:Pa,setIsFddFlagging:_a,showFirmTypeModal:P,setShowFirmTypeModal:A,tempFirmType:T,setTempFirmType:E,updatingFirmType:I,handleUpdateFirmType:xe})]})]})},Kx=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 m$({onViewDetails:t}){const[s,n]=v.useState([]),[r,a]=v.useState(!0),[l,c]=v.useState(1),[d,h]=v.useState("all"),[x,f]=v.useState(null),m=10,p=async()=>{var y;a(!0);try{const S=(await Te.getResignations({page:l,limit:m,status:d==="all"?void 0:d==="open"?"open":"Completed,Closed"})).data;S!=null&&S.success&&(n(S.requests||((y=S.resignations)==null?void 0:y.rows)||S.resignations||[]),f(S.meta))}catch(N){console.error("Error fetching resignations:",N),ee.error("Failed to fetch resignation requests")}finally{a(!1)}};v.useEffect(()=>{p()},[l,d]);const u=y=>{h(y),c(1)},j=d==="open"?s:[],g=d==="completed"?s:[];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(tt,{className:"pb-3",children:[e.jsx(Zt,{children:"All Requests"}),e.jsx(nt,{className:"text-3xl",children:(x==null?void 0:x.total)||0})]}),e.jsx(Me,{children:e.jsx("p",{className:"text-slate-600",children:"Total Requests"})})]}),e.jsxs(Le,{children:[e.jsxs(tt,{className:"pb-3",children:[e.jsx(Zt,{children:"Open"}),e.jsx(nt,{className:"text-3xl text-yellow-600",children:d==="open"?(x==null?void 0:x.total)||0:"..."})]}),e.jsx(Me,{children:e.jsx("p",{className:"text-slate-600",children:"Requires Your Action"})})]}),e.jsxs(Le,{children:[e.jsxs(tt,{className:"pb-3",children:[e.jsx(Zt,{children:"Completed"}),e.jsx(nt,{className:"text-3xl text-green-600",children:d==="completed"?(x==null?void 0:x.total)||0:"..."})]}),e.jsx(Me,{children:e.jsx("p",{className:"text-slate-600",children:"Finalized"})})]})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(nt,{children:"Resignation Requests"}),e.jsxs(Zt,{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(Me,{children:e.jsxs(Pn,{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(Gt,{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(y=>{var N,S,C,w,R,P,A,I,$,T,E;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Me,{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-amber-100 rounded-lg",children:e.jsx(fs,{className:"w-6 h-6 text-amber-600"})}),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:y.resignationId}),e.jsx(Ae,{className:Kx(y.status),children:y.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",{children:((S=(N=y.dealer)==null?void 0:N.dealerProfile)==null?void 0:S.businessName)||((C=y.outlet)==null?void 0:C.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:((P=(R=(w=y.dealer)==null?void 0:w.dealerProfile)==null?void 0:R.dealerCode)==null?void 0:P.dealerCode)||((A=y.outlet)==null?void 0:A.code)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:(($=(I=y.dealer)==null?void 0:I.dealerProfile)==null?void 0:$.registeredAddress)||((T=y.outlet)!=null&&T.city&&((E=y.outlet)!=null&&E.state)?`${y.outlet.city}, ${y.outlet.state}`:"N/A")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Type"}),e.jsx("p",{children:y.resignationType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Reason"}),e.jsx("p",{className:"truncate max-w-[200px]",children:y.reason})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:y.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($n,{className:"w-4 h-4 text-slate-500"}),e.jsx("p",{children:Ht(y.submittedOn)})]})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(y.id),className:"ml-4",children:[e.jsx(nn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},y.id)}),x&&x.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center",children:e.jsx(Yl,{children:e.jsxs(Zl,{children:[e.jsx(an,{children:e.jsx(Ql,{onClick:()=>c(y=>Math.max(1,y-1)),className:l===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(x.totalPages)].map((y,N)=>{const S=N+1;return S===1||S===x.totalPages||S>=l-1&&S<=l+1?e.jsx(an,{children:e.jsx(Ci,{isActive:l===S,onClick:()=>c(S),className:"cursor-pointer",children:S})},S):S===2&&l>3||S===x.totalPages-1&&l<x.totalPages-2?e.jsx(an,{children:e.jsx(Jl,{})},S):null}),e.jsx(an,{children:e.jsx(Xl,{onClick:()=>c(y=>Math.min(x.totalPages,y+1)),className:l===x.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(Gt,{value:"open",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:j.length>0?j.map(y=>{var N,S,C,w,R,P,A;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Me,{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(fs,{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:y.resignationId}),e.jsx(Ae,{className:Kx(y.status),children:y.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",{children:((S=(N=y.dealer)==null?void 0:N.dealerProfile)==null?void 0:S.businessName)||((C=y.outlet)==null?void 0:C.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:((R=(w=y.dealer)==null?void 0:w.dealerProfile)==null?void 0:R.registeredAddress)||((P=y.outlet)!=null&&P.city&&((A=y.outlet)!=null&&A.state)?`${y.outlet.city}, ${y.outlet.state}`:"N/A")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:y.currentStage})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Ht(y.submittedOn)})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(y.id),className:"ml-4",children:[e.jsx(nn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},y.id)}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(fs,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No requests requiring your action"})]})})}),e.jsx(Gt,{value:"completed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:g.length>0?g.map(y=>{var N,S,C,w,R,P;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Me,{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(fs,{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:y.resignationId}),e.jsx(Ae,{className:Kx(y.status),children:y.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",{children:((S=(N=y.dealer)==null?void 0:N.dealerProfile)==null?void 0:S.businessName)||((C=y.outlet)==null?void 0:C.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:((R=(w=y.dealer)==null?void 0:w.dealerProfile)==null?void 0:R.registeredAddress)||((P=y.outlet)==null?void 0:P.city)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Final Stage"}),e.jsx("p",{children:y.currentStage})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Ht(y.submittedOn)})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(y.id),className:"ml-4",children:[e.jsx(nn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},y.id)}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(fs,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No completed resignations to display"})]})})})]})})]})]})}const f$=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"}},Yx=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";function p$({currentUser:t,onViewDetails:s}){const[n,r]=v.useState(!1),[a,l]=v.useState([]),[c,d]=v.useState(""),[h,x]=v.useState(!1),[f,m]=v.useState(""),[p,u]=v.useState(null),[j,g]=v.useState([]),[y,N]=v.useState(!0),[S,C]=v.useState(1),[w,R]=v.useState(null),[P,A]=v.useState("all"),I=10,[$,T]=v.useState({terminationCategory:"",reason:"",proposedLwd:"",comments:"",document:null}),E=async()=>{N(!0);try{const D=(await Te.getTerminations({page:S,limit:I,status:P==="all"?void 0:P})).data;D!=null&&D.success&&(g(D.terminations),R(D.meta))}catch(B){console.error("Error fetching terminations:",B),ee.error("Failed to fetch termination requests")}finally{N(!1)}};v.useEffect(()=>{E()},[S,P]);const _=B=>{A(B),C(1)};v.useEffect(()=>{if(!n||!W)return;let B=!1;return(async()=>{try{x(!0);const O=(await Te.getDealers({onboarded:"true",activeOnly:"true"})).data;if(!B&&(O!=null&&O.success)){const V=(Array.isArray(O.data)?O.data:[]).filter(K=>{var X,ne;const Y=String((K==null?void 0:K.status)||"").toLowerCase(),U=String(((X=K==null?void 0:K.user)==null?void 0:X.status)||"").toLowerCase();return Y==="active"&&((ne=K==null?void 0:K.user)==null?void 0:ne.isActive)&&U==="active"});l(V)}}catch(D){B||(console.error("Error fetching dealers:",D),ee.error("Failed to load dealer list"))}finally{B||x(!1)}})(),()=>{B=!0}},[n]);const M=B=>{var D,O,V,K,Y,U;return{id:B.id,dealerId:B.id,dealerCode:((D=B.dealerCode)==null?void 0:D.dealerCode)||"",legalName:B.legalName||"N/A",businessName:B.businessName||"N/A",gstNumber:B.gstNumber||"N/A",address:B.registeredAddress||((O=B.application)==null?void 0:O.preferredLocation)||"N/A",city:((V=B.application)==null?void 0:V.city)||"N/A",state:((K=B.application)==null?void 0:K.state)||"N/A",email:((Y=B.user)==null?void 0:Y.email)||"N/A",phoneNumber:((U=B.user)==null?void 0:U.mobileNumber)||"N/A"}},q=B=>{d(B);const D=a.find(V=>String(V.id)===String(B));if(!D){m(""),u(null);return}const O=M(D);m(O.dealerCode),u(O)},G=B=>{m(B);const D=B.trim().toLowerCase();if(!D){d(""),u(null);return}const O=a.find(V=>{var K;return String(((K=V.dealerCode)==null?void 0:K.dealerCode)||"").toLowerCase()===D});if(!O){d(""),u(null);return}d(String(O.id)),u(M(O))},Z=async B=>{var D,O,V;if(B.preventDefault(),!p){ee.error("Please select a dealer");return}try{const K={dealerId:p.dealerId||p.id,category:$.terminationCategory,reason:$.reason,proposedLwd:$.proposedLwd,comments:$.comments};if(!K.dealerId){ee.error("Dealer record not found for the selected dealer");return}const U=(await Te.createTermination(K)).data;if(U!=null&&U.success){const X=(D=U.termination)==null?void 0:D.id;if(X&&$.document){const ne=new FormData;ne.append("file",$.document),ne.append("documentType","Termination Recommendation"),ne.append("stage","Submitted");try{await Te.uploadTerminationDocument(X,ne),ee.success("Termination request and supporting document submitted")}catch(oe){console.error("Error uploading supporting document:",oe),ee.warning("Termination created, but document upload failed. You can upload it from the details page.")}}else ee.success("Termination request submitted successfully");r(!1),E(),d(""),m(""),l([]),u(null),T({terminationCategory:"",reason:"",proposedLwd:"",comments:"",document:null})}}catch(K){console.error("Error submitting termination:",K),ee.error(((V=(O=K.response)==null?void 0:O.data)==null?void 0:V.message)||"Failed to submit termination request")}},W=(t==null?void 0:t.role)==="DD Lead",z=P==="open"||P==="all"?j:[],F=P==="completed"||P==="all"?j:[];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(mi,{className:"border-red-200 bg-red-50",children:[e.jsx(Ya,{className:"h-4 w-4 text-red-600"}),e.jsx(Hi,{className:"text-red-900",children:"Restricted Access"}),e.jsx(fi,{className:"text-red-700",children:"This section contains sensitive information. All termination actions are logged and require proper authorization."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(Le,{children:[e.jsxs(tt,{className:"pb-3",children:[e.jsx(Zt,{children:"All Cases"}),e.jsx(nt,{className:"text-3xl",children:(w==null?void 0:w.total)||0})]}),e.jsx(Me,{children:e.jsx("p",{className:"text-slate-600",children:"Total Cases"})})]}),e.jsxs(Le,{children:[e.jsxs(tt,{className:"pb-3",children:[e.jsx(Zt,{children:"Open"}),e.jsx(nt,{className:"text-3xl text-orange-600",children:P==="open"?(w==null?void 0:w.total)||0:"..."})]}),e.jsx(Me,{children:e.jsx("p",{className:"text-slate-600",children:"Requires Your Action"})})]}),e.jsxs(Le,{children:[e.jsxs(tt,{className:"pb-3",children:[e.jsx(Zt,{children:"Completed"}),e.jsx(nt,{className:"text-3xl text-green-600",children:P==="completed"?(w==null?void 0:w.total)||0:"..."})]}),e.jsx(Me,{children:e.jsx("p",{className:"text-slate-600",children:"Finalized"})})]})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(nt,{children:"Termination Requests"}),e.jsxs(Zt,{children:["Manage dealer termination proceedings and legal compliance",!W&&e.jsxs("span",{className:"block mt-1 text-red-600",children:["• Note: Only DD Lead can create termination requests. Current role: ",(t==null?void 0:t.role)||"Not logged in"]})]})]}),W&&e.jsxs(os,{open:n,onOpenChange:r,children:[e.jsx(Hl,{asChild:!0,children:e.jsxs(se,{className:"bg-red-600 hover:bg-red-700",children:[e.jsx(cn,{className:"w-4 h-4 mr-2"}),"Create Termination Request"]})}),e.jsxs(ls,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Create Termination Request"}),e.jsx(vs,{children:"Fill in the details to create a new termination request"})]}),e.jsxs("form",{onSubmit:Z,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{children:"Select Dealer *"}),e.jsxs(wt,{value:c,onValueChange:q,disabled:h,children:[e.jsx(Ct,{children:e.jsx(St,{placeholder:h?"Loading dealers...":"Select dealer"})}),e.jsx(At,{children:a.map(B=>{var D;return e.jsxs(Pe,{value:String(B.id),children:[B.legalName||B.businessName||"Unnamed Dealer"," - ",((D=B.dealerCode)==null?void 0:D.dealerCode)||"No Code"]},B.id)})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"dealerCode",children:"Dealer Code *"}),e.jsx(ot,{id:"dealerCode",value:f,onChange:B=>G(B.target.value),placeholder:"Type dealer code to auto-select",required:!0})]}),p&&e.jsxs("div",{className:"grid grid-cols-2 gap-4 p-4 bg-slate-50 rounded-lg",children:[e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Dealer Name (Legal)"}),e.jsx("p",{children:p.legalName||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Business Name"}),e.jsx("p",{children:p.businessName||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:p.gstNumber||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Address"}),e.jsx("p",{children:p.address})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"City/State"}),e.jsxs("p",{children:[p.city,", ",p.state]})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:p.dealerCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Contact"}),e.jsxs("p",{children:[p.email," / ",p.phoneNumber]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{children:"Termination Category *"}),e.jsxs(wt,{value:$.terminationCategory,onValueChange:B=>T({...$,terminationCategory:B}),children:[e.jsx(Ct,{children:e.jsx(St,{placeholder:"Select termination category"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"Working Capital",children:"Working Capital"}),e.jsx(Pe,{value:"Performance Issues",children:"Performance Issues"}),e.jsx(Pe,{value:"Unethical Practical",children:"Unethical Practical"}),e.jsx(Pe,{value:"Unforeseen Circumstances",children:"Unforeseen Circumstances"}),e.jsx(Pe,{value:"Others",children:"Others"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{children:"Proposed LWD *"}),e.jsx(ot,{type:"date",value:$.proposedLwd,onChange:B=>T({...$,proposedLwd:B.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"reason",children:"Termination Reason *"}),e.jsx(ot,{id:"reason",value:$.reason,onChange:B=>T({...$,reason:B.target.value}),placeholder:"Primary reason for termination",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"comments",children:"Additional Comments *"}),e.jsx(Fs,{id:"comments",value:$.comments,onChange:B=>T({...$,comments:B.target.value}),placeholder:"Detailed observations and justification",rows:4,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"document",children:"Upload Supporting Document"}),e.jsx(ot,{id:"document",type:"file",onChange:B=>{var D;return T({...$,document:((D=B.target.files)==null?void 0:D[0])||null})}})]}),e.jsxs(rn,{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(Me,{children:[e.jsxs(Pn,{value:P,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(Gt,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:y?e.jsx("div",{className:"text-center py-12",children:"Loading requests..."}):j.length>0?j.map(B=>{var D,O,V,K;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Me,{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(Za,{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:B.requestId||((O=(D=B.dealer)==null?void 0:D.dealerCode)==null?void 0:O.code)||"N/A"}),e.jsxs("span",{className:"text-slate-400 text-xs",children:["#",B.id.substring(0,8)]}),e.jsx(Ae,{className:f$(B.severity||"Medium"),children:B.severity||"Normal"}),e.jsx(Ae,{className:Yx(B.status),children:B.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",{children:((V=B.dealer)==null?void 0:V.businessName)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:((K=B.dealer)==null?void 0:K.registeredAddress)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Category"}),e.jsx("p",{children:B.category})]}),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:"Proposed LWD"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx($n,{className:"w-4 h-4 text-slate-500"}),e.jsx("p",{children:B.proposedLwd})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Ht(B.createdAt)})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(B.id),className:"ml-4",children:[e.jsx(nn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},B.id)}):e.jsx("div",{className:"text-center py-12 text-slate-500",children:e.jsx("p",{children:"No termination requests found"})})})}),e.jsx(Gt,{value:"open",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:z.length>0?z.map(B=>{var D,O,V;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Me,{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(Ya,{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:B.requestId||((O=(D=B.dealer)==null?void 0:D.dealerCode)==null?void 0:O.code)||"N/A"}),e.jsxs("span",{className:"text-slate-400 text-xs",children:["#",B.id.substring(0,8)]}),e.jsx(Ae,{className:Yx(B.status),children:B.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",{children:(V=B.dealer)==null?void 0:V.businessName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Reason"}),e.jsx("p",{className:"truncate",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.jsx("p",{children:Ht(B.createdAt)})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(B.id),className:"ml-4",children:[e.jsx(nn,{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(Za,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No requests requiring your action"})]})})}),e.jsx(Gt,{value:"completed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:F.length>0?F.map(B=>{var D,O,V;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Me,{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(Za,{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:B.requestId||((O=(D=B.dealer)==null?void 0:D.dealerCode)==null?void 0:O.code)||"N/A"}),e.jsxs("span",{className:"text-slate-400 text-xs",children:["#",B.id.substring(0,8)]}),e.jsx(Ae,{className:Yx(B.status),children:B.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",{children:(V=B.dealer)==null?void 0:V.businessName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Closed On"}),e.jsx("p",{children:Ht(B.updatedAt)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Termination Category"}),e.jsx("p",{children:B.category})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"LWD"}),e.jsx("p",{children:B.proposedLwd})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(B.id),className:"ml-4",children:[e.jsx(nn,{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(Za,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No completed terminations to display"})]})})})]}),w&&w.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center bg-white rounded-b-lg",children:e.jsx(Yl,{children:e.jsxs(Zl,{children:[e.jsx(an,{children:e.jsx(Ql,{onClick:()=>C(B=>Math.max(1,B-1)),className:S===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(w.totalPages)].map((B,D)=>{const O=D+1;return O===1||O===w.totalPages||O>=S-1&&O<=S+1?e.jsx(an,{children:e.jsx(Ci,{isActive:S===O,onClick:()=>C(O),className:"cursor-pointer",children:O})},O):O===2&&S>3||O===w.totalPages-1&&S<w.totalPages-2?e.jsx(an,{children:e.jsx(Jl,{})},O):null}),e.jsx(an,{children:e.jsx(Xl,{onClick:()=>C(B=>Math.min(w.totalPages,B+1)),className:S===w.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})]})}const Ad=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"}},kd=t=>t==="Resignation"?"bg-amber-100 text-amber-700 border-amber-300":"bg-red-100 text-red-700 border-red-300";function x$({currentUser:t,onViewDetails:s}){const[n,r]=v.useState([]),[a,l]=v.useState(!0);v.useEffect(()=>{c()},[]);const c=async()=>{try{l(!0);const j=(await Te.getFnFSettlements()).data;j.success&&r(j.settlements||[])}catch(u){console.error("Fetch settlements error:",u),ee.error("Failed to fetch settlement cases")}finally{l(!1)}};if(a)return e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(ss,{className:"w-8 h-8 animate-spin text-blue-600"})});const d=u=>{var j,g,y,N,S,C,w,R,P,A,I,$,T,E,_,M;return{id:u.id,caseNumber:u.settlementId||((j=u.resignation)==null?void 0:j.resignationId)||((g=u.terminationRequest)==null?void 0:g.requestId)||u.id.substring(0,8).toUpperCase(),status:u.status,requestType:u.resignationId?"Resignation":"Termination",dealerName:((N=(y=u.outlet)==null?void 0:y.dealer)==null?void 0:N.fullName)||((S=u.dealer)==null?void 0:S.legalName)||((C=u.dealer)==null?void 0:C.businessName)||((w=u.dealer)==null?void 0:w.fullName)||"N/A",dealerCode:((R=u.outlet)==null?void 0:R.code)||((A=(P=u.dealer)==null?void 0:P.dealerCode)==null?void 0:A.dealerCode)||"N/A",dealershipName:((I=u.outlet)==null?void 0:I.name)||"N/A",location:(($=u.outlet)==null?void 0:$.city)||((T=u.outlet)==null?void 0:T.location)||"N/A",originalRequestId:((E=u.resignation)==null?void 0:E.resignationId)||((_=u.terminationRequest)==null?void 0:_.requestId)||((M=u.terminationRequest)==null?void 0:M.id)||"N/A",submittedOn:Ht(u.createdAt),financeReportStatus:u.status==="Calculated"||u.status==="Settled"?"Completed":"Pending",totalRecoveryAmount:parseFloat(u.totalReceivables)||0,totalPayableAmount:parseFloat(u.totalPayables)||0,completedOn:u.settlementDate?Ht(u.settlementDate):null,departmentResponses:u.lineItems||[]}},h=n.map(d),x=h.filter(u=>u.status==="Initiated"),f=h.filter(u=>u.status==="DD Clearance"||u.status==="Legal Clearance"),m=h.filter(u=>u.status==="Finance Approval"||u.status==="Calculated"),p=h.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(tt,{className:"pb-3",children:[e.jsx(Zt,{children:"Initiated"}),e.jsx(nt,{className:"text-3xl text-blue-600",children:x.length})]}),e.jsx(Me,{children:e.jsx("p",{className:"text-slate-600",children:"Newly created"})})]}),e.jsxs(Le,{children:[e.jsxs(tt,{className:"pb-3",children:[e.jsx(Zt,{children:"Clearance"}),e.jsx(nt,{className:"text-3xl text-yellow-600",children:f.length})]}),e.jsx(Me,{children:e.jsx("p",{className:"text-slate-600",children:"Department / legal stage"})})]}),e.jsxs(Le,{children:[e.jsxs(tt,{className:"pb-3",children:[e.jsx(Zt,{children:"Finance Approval"}),e.jsx(nt,{className:"text-3xl text-orange-600",children:m.length})]}),e.jsx(Me,{children:e.jsx("p",{className:"text-slate-600",children:"Ready for finance review"})})]}),e.jsxs(Le,{children:[e.jsxs(tt,{className:"pb-3",children:[e.jsx(Zt,{children:"Completed"}),e.jsx(nt,{className:"text-3xl text-green-600",children:h.filter(u=>u.status==="Completed"||u.status==="Settled").length})]}),e.jsx(Me,{children:e.jsx("p",{className:"text-slate-600",children:"Finalized"})})]}),e.jsxs(Le,{children:[e.jsxs(tt,{className:"pb-3",children:[e.jsx(Zt,{children:"All Cases"}),e.jsx(nt,{className:"text-3xl",children:h.length})]}),e.jsx(Me,{children:e.jsx("p",{className:"text-slate-600",children:"Total"})})]})]}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"Full & Final Settlement Cases"}),e.jsxs(Zt,{children:["Manage dealer exit dues clearance and settlement",t&&` • Current Role: ${t.role}`]})]}),e.jsx(Me,{children:e.jsxs(Pn,{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(Gt,{value:"initiated",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(Me,{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(_d,{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(Ae,{className:Ad(u.status),children:u.status}),e.jsx(Ae,{className:kd(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($n,{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(nn,{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(_d,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No initiated cases to display"})]})]})}),e.jsx(Gt,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:h.map(u=>e.jsx(Le,{className:"border-slate-200",children:e.jsx(Me,{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(oa,{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(Ae,{className:Ad(u.status),children:u.status}),e.jsx(Ae,{className:kd(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(nn,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},u.id))})}),e.jsx(Gt,{value:"clearance",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(Me,{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(oa,{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(Ae,{className:Ad(u.status),children:u.status}),e.jsx(Ae,{className:kd(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(j=>j.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(nn,{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(oa,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No clearance-stage cases"})]})]})}),e.jsx(Gt,{value:"finance",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[m.map(u=>{var j,g;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Me,{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(oa,{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(Ae,{className:Ad(u.status),children:u.status}),e.jsx(Ae,{className:kd(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:["₹",(j=u.totalRecoveryAmount)==null?void 0:j.toLocaleString()]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Payable Amount"}),e.jsxs("p",{className:"text-green-600",children:["₹",(g=u.totalPayableAmount)==null?void 0:g.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(nn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},u.id)}),m.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(oa,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No finance-approval cases"})]})]})}),e.jsx(Gt,{value:"completed",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(Me,{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(_d,{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(Ae,{className:Ad(u.status),children:u.status}),e.jsx(Ae,{className:kd(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(nn,{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(_d,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No completed cases"})]})]})})]})})]})]})}const Pl={getResignations:async()=>{try{return(await Te.getResignations()).data}catch(t){throw console.error("Get resignations error:",t),t}},createResignation:async t=>{try{return(await Te.createResignation(t)).data}catch(s){throw console.error("Create resignation error:",s),s}},getResignationById:async t=>{var s,n;try{const r=await Te.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 Te.updateClearance(t,s)).data}catch(n){throw console.error("Update clearance error:",n),n}},uploadDocument:async(t,s)=>{try{return(await Te.uploadResignationDocument(t,s)).data}catch(n){throw console.error("Upload resignation document error:",n),n}},withdraw:async(t,s)=>{try{return(await Te.withdrawResignation(t,s)).data}catch(n){throw console.error("Withdraw resignation error:",n),n}}},Ud=["Resignation Letter","Dealer Undertaking","Approval Note","Legal Communication","Handover Document","Settlement Supporting Document","Other"],mE=["ASM","RBM","ZBH","DD Lead","NBH","DD Admin","Legal","F&F Initiated"],Zx=["Termination Recommendation","Show Cause Notice","SCN Response","Hearing Record","Approval Note","Termination Letter","Settlement Supporting Document","Other"],g$=["Submitted","RBM 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"],v$={ASM:"ASM",RBM:"RBM",ZBH:"ZBH","DD Lead":"DD Lead",NBH:"NBH","DD Admin":"DD Admin",Legal:"Legal Admin"},c1=["REJECTED","Rejected","REVOKED","Revoked","WITHDRAWN","Withdrawn"],d1={ASM:["ASM","ASM Review","Submission","Submitted"],RBM:["RBM","RBM Review","Regional Review"],ZBH:["ZBH","ZBH Review","ZM Review"],"DD Lead":["DD Lead","DD Lead Review","DDL Review"],NBH:["NBH","NBH Approval","NBH Review"],"DD Admin":["DD Admin","DD Admin Review"],Legal:["Legal","Legal - Resignation Letter"],"F&F Initiated":["F&F Initiated","FNF_INITIATED","FNF Initiated"],Completed:["Completed"]};function b$({resignationId:t,onBack:s,currentUser:n}){var _e,ke,qe,Ve,dt,xt,ye,le,Qe,rt,Kt,Rt,Re,Qt,qt,ws,_s,ns,Cs,Bs,Ft,ie,Fe,Q,pe,Ne,Ee,it,st,bt,Ue,Lt,ut,yt,kt;const r=(Ie,_t)=>{const ht=[...(A==null?void 0:A.documents)||[],...(A==null?void 0:A.uploadedDocuments)||[]],zt=[Ie,_t,..._t?d1[_t]||[]:[],...d1[Ie]||[]].filter(rs=>!!rs).map(rs=>rs.trim().toLowerCase());return ht.filter(rs=>{if(!(rs!=null&&rs.stage))return!1;const Yt=String(rs.stage).trim().toLowerCase();return zt.includes(Yt)})},a=qn(),[l,c]=v.useState({open:!1,type:null}),[d,h]=v.useState(""),[x,f]=v.useState(""),[m,p]=v.useState(""),[u,j]=v.useState(""),[g,y]=v.useState([]),[N,S]=v.useState(!1),[C,w]=v.useState(!1),[R,P]=v.useState({open:!1,stageName:"",documents:[]}),[A,I]=v.useState(null),[$,T]=v.useState(!1),[E,_]=v.useState([]),[M,q]=v.useState(!1),[G,Z]=v.useState(null),[W,z]=v.useState(!1),[F,B]=v.useState(null),[D,O]=v.useState(Ud[0]),[V,K]=v.useState(""),Y=async()=>{try{T(!0);const Ie=await Pl.getResignationById(t);I(Ie),U()}catch(Ie){console.error("Error fetching resignation:",Ie)}finally{T(!1)}},U=async()=>{try{const Ie=await Te.getAuditLogs("resignation",t);Ie.data&&Ie.data.success&&_(Ie.data.data||[])}catch(Ie){console.error("Error fetching audit logs:",Ie)}};v.useEffect(()=>{Y()},[t]);const X=[{id:1,name:"ASM Review",key:"ASM",description:"Area Sales Manager review"},{id:2,name:"RBM Review",key:"RBM",description:"Regional Business Manager evaluation"},{id:3,name:"ZBH Review",key:"ZBH",description:"Zonal Business Head approval"},{id:4,name:"DD Lead Review",key:"DD Lead",description:"DD Lead final review"},{id:5,name:"NBH Approval",key:"NBH",description:"National Business Head approval"},{id:6,name:"DD Admin Review",key:"DD Admin",description:"DD Admin verification"},{id:7,name:"Legal - Resignation Letter",key:"Legal",description:"Legal team issues resignation approval letter"},{id:8,name:"F&F Settlement",key:"F&F Initiated",description:"Full & Final settlement process"},{id:9,name:"Completed",key:"Completed",description:"Resignation process finalized"}],ne=["ASM","RBM","ZBH","DD Lead","NBH","DD Admin","Legal","F&F Initiated","Completed"],oe=A?["F&F Initiated","Completed","Settled","FNF_INITIATED"].includes(String(A.status||A.currentStage||""))?!0:(Array.isArray(A.timeline)?A.timeline:[]).some(ht=>{const zt=String((ht==null?void 0:ht.stage)||"").trim().toLowerCase(),rs=String((ht==null?void 0:ht.targetStage)||"").trim().toLowerCase(),Yt=String((ht==null?void 0:ht.action)||"").trim().toLowerCase(),Os=zt==="legal"||zt==="legal - resignation letter",Is=rs==="legal"||rs==="f&f initiated"||rs==="fnf_initiated"||Yt.includes("approved");return Os&&Is}):!1,ge=(()=>{if(!A||!n)return{canApprove:!1,canWithdraw:!1,canSendBack:!1,canPushToFnF:!1,canAssign:!1};const Ie=A.currentStage,_t=A.status,ht=n.role,zt=["Completed","Rejected","Withdrawn","Revoked"].includes(_t),rs=_t==="F&F Initiated"||Ie==="F&F Initiated"||_t==="Settled"||_t==="FNF_INITIATED",Yt=ne.indexOf(Ie),Os=ne.indexOf("NBH"),Is=Yt!==-1&&Os!==-1&&Yt>=Os,zs=ht==="Super Admin"||ht===v$[Ie];return{canApprove:zs&&!zt&&!rs&&!(Ie==="Legal"&&oe),canSendBack:zs&&!zt&&!rs&&Yt>0,canWithdraw:ht==="Dealer"&&!Is&&!zt,canRevoke:(ht==="Super Admin"||ht==="DD Admin")&&!zt&&!rs,canPushToFnF:["DD Lead","DD Head","NBH","DD Admin","Super Admin"].includes(ht)&&!rs&&!zt,canAssign:ht!=="Dealer"&&!zt}})(),ve={ASM:["ASM","ASM Review","Request Initiated"],RBM:["RBM","RBM Review"],ZBH:["ZBH","ZBH Review"],"DD Lead":["DD Lead","DD Lead Review","Lead Review"],NBH:["NBH","NBH Approval","NBH Review"],"DD Admin":["DD Admin","DD Admin Review"],Legal:["Legal","Legal - Resignation Letter","Legal Review"],"F&F Initiated":["F&F Initiated","FNF_INITIATED","F&F Settlement","Settled"],Completed:["Completed","Finalized"]},Se=Ie=>{if(!Ie)return"";const _t=String(Ie).trim();return ne.find(zt=>zt===_t||(ve[zt]||[]).includes(_t))||_t},We=Ie=>{if(!A)return"pending";const _t=["Rejected","Revoked","Withdrawn"].includes(A.status);let ht=A.currentStage;if(_t&&(!ht||c1.includes(String(ht)))){const Os=[...A.timeline||[]].reverse().find(Is=>(Is==null?void 0:Is.stage)&&!c1.includes(String(Is.stage)));Os!=null&&Os.stage&&(ht=Os.stage)}const zt=ne.indexOf(Se(ht)),rs=ne.indexOf(Ie);if((A.status==="Completed"||A.status==="Settled")&&rs<=zt)return"completed";const Yt=["Rejected","Revoked","Withdrawn"].includes(A.status);return Ie==="Legal"&&oe&&!Yt?"completed":zt===-1?Ie==="ASM"?"completed":"pending":rs<zt?"completed":rs===zt?_t?"completed":"active":"pending"},Ce=Ie=>{c({open:!0,type:Ie})},fe=(Ie,_t)=>{const ht=r(Ie,_t).map((zt,rs)=>{var Yt;return{id:zt.id||`${Ie}-${rs}`,name:zt.name||zt.fileName||"Document",type:zt.type||zt.documentType||"Document",uploadDate:zt.uploadDate||(zt.createdAt?Ht(zt.createdAt):"N/A"),uploader:typeof zt.uploader=="string"?zt.uploader:((Yt=zt.uploader)==null?void 0:Yt.fullName)||zt.uploadedBy||"System",filePath:zt.filePath||zt.path}});P({open:!0,stageName:Ie,documents:ht})},Ye=async()=>{var Ie,_t,ht,zt,rs,Yt,Os,Is;if(!d&&!["assign","pushfnf"].includes(l.type||"")){ee.error("Please provide remarks (min 5 characters)");return}if(["sendBack","revoke"].includes(l.type||"")&&d.trim().length<5){ee.error("Remarks are required for this action (min 5 characters).");return}if(l.type==="assign"&&!x){ee.error("Please select a designation");return}try{q(!0);const en={action:l.type==="sendBack"?"sendBack":l.type,remarks:d,assignTo:u||x,force:C},he=await Te.updateResignationStatus(t,en);if((Ie=he.data)!=null&&Ie.success)ee.success(((_t=he.data)==null?void 0:_t.message)||"Action completed successfully"),c({open:!1,type:null}),h(""),f(""),j(""),y([]),w(!1),Y();else{const Ge=((ht=he.data)==null?void 0:ht.message)||"Failed to submit action";ee.error(Ge),(zt=he.data)!=null&&zt.canForce&&ee.info('LWD restriction hit. Use "Push to F&F" and enable "Force Initiate F&F Settlement Immediately" if urgent.')}}catch(zs){console.error("Error submitting action:",zs),ee.error(((Yt=(rs=zs.response)==null?void 0:rs.data)==null?void 0:Yt.message)||"Failed to submit action"),(Is=(Os=zs==null?void 0:zs.response)==null?void 0:Os.data)!=null&&Is.canForce&&ee.info('LWD restriction hit. Use "Push to F&F" with force option if business-approved.')}finally{q(!1)}},be=async()=>{var Ie,_t;if(!F){ee.error("Please select a file to upload");return}try{q(!0);const ht=new FormData;ht.append("file",F),ht.append("documentType",D),V&&ht.append("stage",V),await Pl.uploadDocument(t,ht),ee.success("Document uploaded successfully"),z(!1),B(null),O(Ud[0]),K(""),Y()}catch(ht){ee.error(((_t=(Ie=ht==null?void 0:ht.response)==null?void 0:Ie.data)==null?void 0:_t.message)||"Failed to upload document")}finally{q(!1)}};return v.useEffect(()=>{(async()=>{if(l.type==="assign"&&(x||m)){const _t=setTimeout(async()=>{var ht;try{S(!0);const zt={asm:"ASM",rbm:"RBM",zbh:"ZBH",nbh:"NBH",legal:"Legal Admin"},rs={limit:20,search:m};x&&(rs.roleCode=zt[x]||x);const Yt=await Te.getUsers(rs);(ht=Yt.data)!=null&&ht.success&&y(Yt.data.data)}catch(zt){console.error("Error fetching users:",zt)}finally{S(!1)}},300);return()=>clearTimeout(_t)}})()},[x,m,l.type]),$&&!A?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(ss,{className:"w-8 h-8 animate-spin text-amber-600"})}):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($r,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl",children:(A==null?void 0:A.resignationId)||t}),e.jsx("p",{className:"text-slate-600",children:(_e=A==null?void 0:A.outlet)==null?void 0:_e.name})]}),e.jsx(Ae,{className:(A==null?void 0:A.status)==="Completed"||(A==null?void 0:A.status)==="Settled"?"bg-green-100 text-green-700 border-green-300":(A==null?void 0:A.status)==="Rejected"||(A==null?void 0:A.status)==="Withdrawn"||(A==null?void 0:A.status)==="Revoked"?"bg-red-100 text-red-700 border-red-300":"bg-yellow-100 text-yellow-700 border-yellow-300",children:(A==null?void 0:A.status)==="Settled"?"Completed":(A==null?void 0:A.status)||"Pending"})]})}),e.jsx(Le,{className:"border-slate-200 shadow-sm",children:e.jsx(Me,{className:"pt-6",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-slate-600 mr-2",children:"Workflow Actions:"}),ge.canApprove&&e.jsxs(se,{size:"sm",disabled:M,className:"bg-green-600 hover:bg-green-700 transition-all hover:shadow-md",onClick:()=>Ce("approve"),children:[M&&l.type==="approve"?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Bn,{className:"w-4 h-4 mr-2"}),"Approve"]}),ge.canSendBack&&e.jsxs(se,{size:"sm",variant:"outline",disabled:M,className:"hover:bg-slate-50 transition-all font-bold",onClick:()=>Ce("sendBack"),children:[M&&l.type==="sendBack"?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Qv,{className:"w-4 h-4 mr-2"}),"Send Back"]}),ge.canWithdraw&&e.jsxs(se,{size:"sm",variant:"outline",disabled:M,className:"text-red-600 border-red-300 hover:bg-red-50 transition-all font-bold",onClick:()=>Ce("withdrawal"),children:[M&&l.type==="withdrawal"?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Tc,{className:"w-4 h-4 mr-2"}),"Withdrawal"]}),ge.canRevoke&&e.jsxs(se,{size:"sm",variant:"outline",disabled:M,className:"text-orange-600 border-orange-300 hover:bg-orange-50 transition-all font-bold",onClick:()=>Ce("revoke"),children:[M&&l.type==="revoke"?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Yv,{className:"w-4 h-4 mr-2"}),"Revoke"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[ge.canPushToFnF&&e.jsxs(se,{size:"sm",variant:"outline",disabled:M,className:"text-amber-600 border-blue-300 hover:bg-blue-50 transition-all",onClick:()=>Ce("pushfnf"),children:[M&&l.type==="pushfnf"?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(fu,{className:"w-4 h-4 mr-2"}),"Push to F&F"]}),ge.canAssign&&e.jsxs(se,{size:"sm",variant:"outline",disabled:M,className:"hover:bg-slate-50 transition-all",onClick:()=>Ce("assign"),children:[M&&l.type==="assign"?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Jv,{className:"w-4 h-4 mr-2"}),"Assign User"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-slate-200",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zr,{className:"w-4 h-4 text-slate-500"}),e.jsx("span",{className:"text-sm text-slate-600",children:"Communication & Notes"})]}),e.jsxs(se,{size:"sm",variant:"outline",className:"relative hover:bg-amber-50 hover:border-amber-300 hover:text-amber-700 transition-all shadow-sm",onClick:()=>{var Ie;return a(`/worknotes/resignation/${t}`,{state:{applicationName:((Ie=A==null?void 0:A.outlet)==null?void 0:Ie.name)||"Resignation",registrationNumber:(A==null?void 0:A.resignationId)||"",participants:(A==null?void 0:A.participants)||[]}})},children:[e.jsx(zr,{className:"w-4 h-4 mr-2"}),"View Work Notes",((ke=A==null?void 0:A.worknotes)==null?void 0:ke.length)>0&&e.jsx(Ae,{className:"ml-2 bg-amber-600 hover:bg-amber-700 text-white h-5 px-2",children:A.worknotes.length})]})]})]})})}),e.jsxs(Pn,{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(Gt,{value:"details",className:"space-y-6",children:[e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Request Information"})}),e.jsx(Me,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((qe=A==null?void 0:A.dealer)==null?void 0:qe.fullName)||((Ve=A==null?void 0:A.outlet)==null?void 0:Ve.name)})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:((xt=(dt=A==null?void 0:A.dealer)==null?void 0:dt.dealerProfile)==null?void 0:xt.gstNumber)||((ye=A==null?void 0:A.outlet)==null?void 0:ye.gstNumber)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Dealer Email"}),e.jsx("p",{children:((le=A==null?void 0:A.dealer)==null?void 0:le.email)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Sales Code"}),e.jsx("p",{children:((Kt=(rt=(Qe=A==null?void 0:A.dealer)==null?void 0:Qe.dealerProfile)==null?void 0:rt.dealerCode)==null?void 0:Kt.salesCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Service Code"}),e.jsx("p",{children:((Qt=(Re=(Rt=A==null?void 0:A.dealer)==null?void 0:Rt.dealerProfile)==null?void 0:Re.dealerCode)==null?void 0:Qt.serviceCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:((_s=(ws=(qt=A==null?void 0:A.dealer)==null?void 0:qt.dealerProfile)==null?void 0:ws.dealerCode)==null?void 0:_s.gmaCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Gear Code"}),e.jsx("p",{children:((Bs=(Cs=(ns=A==null?void 0:A.dealer)==null?void 0:ns.dealerProfile)==null?void 0:Cs.dealerCode)==null?void 0:Bs.gearCode)||"N/A"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(ce,{className:"text-slate-600",children:"Address"}),e.jsx("p",{children:((ie=(Ft=A==null?void 0:A.dealer)==null?void 0:Ft.dealerProfile)==null?void 0:ie.registeredAddress)||((Fe=A==null?void 0:A.outlet)==null?void 0:Fe.address)})]})]})})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Operational Details"})}),e.jsx(Me,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Inauguration"}),e.jsx("p",{children:(pe=(Q=A==null?void 0:A.dealer)==null?void 0:Q.dealerProfile)!=null&&pe.onboardedAt?Ht(A.dealer.dealerProfile.onboardedAt,"date"):(Ne=A==null?void 0:A.outlet)!=null&&Ne.inaugurationDate?Ht(A.outlet.inaugurationDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"LOA Date"}),e.jsx("p",{children:(it=(Ee=A==null?void 0:A.dealer)==null?void 0:Ee.dealerProfile)!=null&&it.loaDate?Ht(A.dealer.dealerProfile.loaDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"LOI Date"}),e.jsx("p",{children:(bt=(st=A==null?void 0:A.dealer)==null?void 0:st.dealerProfile)!=null&&bt.loiDate?Ht(A.dealer.dealerProfile.loiDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Dealership Type"}),e.jsx("p",{children:((ut=(Lt=(Ue=A==null?void 0:A.dealer)==null?void 0:Ue.dealerProfile)==null?void 0:Lt.application)==null?void 0:ut.businessType)||((yt=A==null?void 0:A.outlet)==null?void 0:yt.type)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"City Category"}),e.jsx("p",{children:((kt=A==null?void 0:A.outlet)==null?void 0:kt.cityCategory)||"N/A"})]})]})})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Resignation Details"})}),e.jsx(Me,{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(ce,{className:"text-slate-600",children:"Resignation Type"}),e.jsx("p",{children:A==null?void 0:A.resignationType})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Reason"}),e.jsx("p",{children:A==null?void 0:A.reason})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Last Operational Date (Sales)"}),e.jsx("p",{children:A!=null&&A.lastOperationalDateSales?Ht(A.lastOperationalDateSales,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Last Operational Date (Services)"}),e.jsx("p",{children:A!=null&&A.lastOperationalDateServices?Ht(A.lastOperationalDateServices,"date"):"N/A"})]})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Additional Info / Dealer Voice"}),e.jsx("p",{children:(A==null?void 0:A.additionalInfo)||"No additional info provided"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:A!=null&&A.submittedOn?Ht(A.submittedOn):"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:A==null?void 0:A.currentStage})]})]})]})})]})]}),e.jsx(Gt,{value:"progress",children:e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"Progress Timeline"}),e.jsx(Zt,{children:"Track the resignation request approval process"})]}),e.jsx(Me,{children:e.jsx("div",{className:"space-y-4",children:X.map((Ie,_t)=>{const ht=We(Ie.key),zt=r(Ie.name,Ie.key).length,rs=((A==null?void 0:A.timeline)||[]).filter(Os=>Os.stage===Ie.key||Os.stage===Ie.name),Yt=rs.length>0?rs[rs.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 ${ht==="completed"?"bg-green-100 text-green-600":ht==="active"?"bg-blue-100 text-amber-600":"bg-slate-100 text-slate-400"}`,children:ht==="completed"?e.jsx(Bn,{className:"w-5 h-5"}):e.jsx("span",{children:Ie.id})}),_t<X.length-1&&e.jsx("div",{className:`w-0.5 h-16 ${ht==="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:ht==="completed"?"text-green-600":ht==="active"?"text-amber-600":"text-slate-400",children:Ie.name}),zt>0&&e.jsxs("button",{onClick:()=>fe(Ie.name,Ie.key),className:"flex items-center gap-1 px-2 py-1 rounded-full bg-amber-100 hover:bg-amber-200 text-amber-700 text-xs transition-colors cursor-pointer",children:[e.jsx(fs,{className:"w-3 h-3"}),e.jsxs("span",{children:[zt," ",zt===1?"doc":"docs"]})]})]}),Yt&&e.jsxs("div",{className:"flex items-center gap-1 text-sm text-slate-600",children:[e.jsx($n,{className:"w-4 h-4"}),e.jsx("span",{children:Ht(Yt.timestamp||Yt.createdAt)})]})]}),e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:Ie.description}),Yt&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae,{variant:"secondary",className:"bg-slate-100 text-[10px] font-bold uppercase",children:Yt.user||"System"}),e.jsx("span",{className:"text-[10px] text-slate-500 italic",children:Yt.action})]}),e.jsx("div",{className:"bg-slate-50 p-3 rounded-lg border border-slate-100 text-sm text-slate-700 shadow-sm",children:Yt.comments||Yt.remarks||"No remarks provided."})]})]})]},Ie.id)})})})]})}),e.jsx(Gt,{value:"documents",children:e.jsxs(Le,{children:[e.jsxs(tt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(nt,{children:"Documents"}),e.jsx(Zt,{children:"View and manage resignation documents"})]}),e.jsxs(se,{size:"sm",onClick:()=>z(!0),className:"bg-amber-600 hover:bg-amber-700",children:[e.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Upload Document"]})]}),e.jsx(Me,{children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Document Name"}),e.jsx(me,{children:"Type"}),e.jsx(me,{children:"Upload Date"}),e.jsx(me,{children:"Uploader"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Es,{children:(()=>{var _t;const Ie=[...(A==null?void 0:A.documents)||[],...(A==null?void 0:A.uploadedDocuments)||[]];return A!=null&&A.departmentalClearances&&Object.entries(A.departmentalClearances).forEach(([ht,zt])=>{zt.supportingDocument&&Ie.push({name:`${ht} Clearance Proof`,type:"Clearance NOC",path:zt.supportingDocument,createdAt:zt.updatedAt,uploadedBy:zt.updatedBy||"Department Admin"})}),(_t=A==null?void 0:A.settlement)!=null&&_t.clearances&&A.settlement.clearances.forEach(ht=>{ht.supportingDocument&&Ie.push({name:`${ht.department} Clearance NOC`,type:"Live NOC",path:ht.supportingDocument,createdAt:ht.clearedAt||ht.updatedAt,uploadedBy:"Department Admin"})}),Ie.length===0?e.jsx(ct,{children:e.jsx(de,{colSpan:5,className:"text-center py-4 text-slate-500",children:"No documents found"})}):Ie.map((ht,zt)=>{var rs;return e.jsxs(ct,{children:[e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"w-4 h-4 text-slate-500"}),e.jsx("span",{children:ht.name||ht.fileName})]})}),e.jsx(de,{children:ht.documentType||ht.type||"Document"}),e.jsx(de,{children:ht.createdAt?Ht(ht.createdAt):"N/A"}),e.jsx(de,{children:((rs=ht.uploader)==null?void 0:rs.fullName)||ht.uploadedBy||"Dealer"}),e.jsx(de,{children:e.jsx(se,{size:"sm",variant:"outline",onClick:()=>{const Yt=ht.filePath||ht.path,Os=Yt!=null&&Yt.startsWith("/uploads/")&&!Yt.startsWith("/uploads/documents/")?Yt.replace("/uploads/","/uploads/documents/"):Yt;Z({fileName:ht.fileName||ht.name,filePath:Os,documentType:ht.documentType||ht.type})},children:"View"})})]},zt)})})()})]})})]})}),e.jsx(Gt,{value:"audit",children:e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"Audit Trail"}),e.jsx(Zt,{children:"Complete history of actions on this resignation request"})]}),e.jsx(Me,{children:e.jsx("div",{className:"space-y-4",children:E.length>0?E.map((Ie,_t)=>{var ht,zt,rs,Yt,Os,Is,zs,en,he,Ge,at;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(Ae,{className:`
${(Ie.description||Ie.action||((ht=Ie.details)==null?void 0:ht.action)||"").toLowerCase().includes("reject")||(Ie.description||Ie.action||((zt=Ie.details)==null?void 0:zt.action)||"").toLowerCase().includes("revok")?"bg-red-100 text-red-700 border-red-200":(Ie.description||Ie.action||((rs=Ie.details)==null?void 0:rs.action)||"").toLowerCase().includes("sent back")||(Ie.description||Ie.action||((Yt=Ie.details)==null?void 0:Yt.action)||"").toLowerCase().includes("send back")?"bg-amber-100 text-amber-700 border-amber-200":(Ie.description||Ie.action||((Os=Ie.details)==null?void 0:Os.action)||"").toLowerCase().includes("approv")||(Ie.description||Ie.action||((Is=Ie.details)==null?void 0:Is.action)||"").toLowerCase().includes("initi")?"bg-emerald-100 text-emerald-700 border-emerald-200":"bg-slate-100 text-slate-700 border-slate-200"}
`,children:Ie.description||Ie.action}),e.jsxs("span",{className:"text-xs text-slate-500 font-medium italic",children:["by ",((zs=Ie.actor)==null?void 0:zs.name)||Ie.userName||"System"]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:Ht(Ie.timestamp||Ie.createdAt)})]}),(Ie.remarks||((en=Ie.newData)==null?void 0:en.remarks)||((he=Ie.details)==null?void 0:he.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:Ie.remarks||((Ge=Ie.newData)==null?void 0:Ge.remarks)||((at=Ie.details)==null?void 0:at.remarks)})]})]},_t)}):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(os,{open:l.open,onOpenChange:Ie=>c({open:Ie,type:null}),children:e.jsxs(ls,{children:[e.jsxs(ms,{children:[e.jsxs(us,{children:[l.type==="approve"&&"Approve Resignation Request",l.type==="withdrawal"&&"Withdraw Resignation Request",l.type==="sendBack"&&"Send Back for Clarification",l.type==="revoke"&&"Revoke Resignation Request",l.type==="assign"&&"Assign to User",l.type==="pushfnf"&&"Push to Full & Final Settlement"]}),e.jsx(vs,{children:l.type==="assign"?"Select a user to assign this request to":l.type==="pushfnf"?"This will move the resignation request to F&F for dues clearance":"Please provide remarks for this action"})]}),e.jsx("div",{className:"space-y-4",children:l.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(ce,{children:"Designation Filter"}),e.jsxs(wt,{value:x,onValueChange:Ie=>{f(Ie),j("")},children:[e.jsx(Ct,{children:e.jsx(St,{placeholder:"All Roles"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"all",children:"All Roles"}),e.jsx(Pe,{value:"asm",children:"ASM"}),e.jsx(Pe,{value:"rbm",children:"RBM"}),e.jsx(Pe,{value:"zbh",children:"ZBH"}),e.jsx(Pe,{value:"nbh",children:"NBH"}),e.jsx(Pe,{value:"legal",children:"Legal"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{children:"Search Name/Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(ot,{placeholder:"Search...",value:m,onChange:Ie=>p(Ie.target.value),className:"pr-8"}),N&&e.jsx(ss,{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(ce,{children:"Select Specific Person *"}),e.jsxs(wt,{value:u,onValueChange:j,children:[e.jsx(Ct,{children:e.jsx(St,{placeholder:g.length>0?"Choose a user":"No users found"})}),e.jsx(At,{className:"max-h-60",children:g.map(Ie=>e.jsx(Pe,{value:Ie.id,children:e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("span",{className:"font-medium",children:Ie.fullName}),e.jsxs("span",{className:"text-[10px] text-slate-500",children:[Ie.roleCode," • ",Ie.email]})]})},Ie.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{children:"Assignment Remarks *"}),e.jsx(Fs,{value:d,onChange:Ie=>h(Ie.target.value),placeholder:"Why are you assigning this user?",rows:2})]})]}):l.type==="pushfnf"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded-lg flex items-start gap-3",children:[e.jsx(Ks,{className:"w-5 h-5 text-amber-600 mt-0.5"}),e.jsxs("div",{className:"text-sm text-amber-800",children:[e.jsx("p",{className:"font-bold",children:"Manual Trigger Notice"}),e.jsx("p",{children:"Normally F&F is triggered after LWD. 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:C,onChange:Ie=>w(Ie.target.checked),className:"w-4 h-4 rounded border-slate-300"}),e.jsx(ce,{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(ce,{children:"Remarks (Optional)"}),e.jsx(Fs,{value:d,onChange:Ie=>h(Ie.target.value),placeholder:"Add any additional notes...",rows:3})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{children:"Remarks *"}),e.jsx(Fs,{value:d,onChange:Ie=>h(Ie.target.value),placeholder:"Enter your remarks here...",rows:4})]})}),e.jsxs(rn,{children:[e.jsx(se,{variant:"outline",onClick:()=>c({open:!1,type:null}),disabled:M,children:"Cancel"}),e.jsx(se,{onClick:Ye,disabled:M,className:l.type==="approve"?"bg-green-600 hover:bg-green-700":l.type==="withdrawal"?"bg-red-600 hover:bg-red-700":"bg-amber-600 hover:bg-amber-700",children:M?e.jsxs(e.Fragment,{children:[e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:[l.type==="approve"&&"Approve",l.type==="withdrawal"&&"Withdraw",l.type==="sendBack"&&"Send Back",l.type==="revoke"&&"Revoke",l.type==="assign"&&"Assign",l.type==="pushfnf"&&"Push to F&F"]})})]})]})}),e.jsx(os,{open:R.open,onOpenChange:Ie=>P({open:Ie,stageName:"",documents:[]}),children:e.jsxs(ls,{className:Fb,children:[e.jsxs(ms,{children:[e.jsxs(us,{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"w-5 h-5 text-amber-600"}),"Documents - ",R.stageName]}),e.jsxs(vs,{children:["Documents uploaded for this stage (",R.documents.length," ",R.documents.length===1?"document":"documents",")"]})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto",children:R.documents.length>0?e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Document Name"}),e.jsx(me,{children:"Type"}),e.jsx(me,{children:"Upload Date"}),e.jsx(me,{children:"Uploader"}),e.jsx(me,{children:"Action"})]})}),e.jsx(Es,{children:R.documents.map(Ie=>e.jsxs(ct,{children:[e.jsx(de,{children:Ie.name}),e.jsx(de,{children:e.jsx(Ae,{variant:"outline",children:Ie.type})}),e.jsx(de,{children:Ie.uploadDate}),e.jsx(de,{children:Ie.uploader}),e.jsx(de,{children:e.jsxs(se,{size:"sm",variant:"outline",className:"text-amber-600 hover:text-blue-700",onClick:()=>{if(!Ie.filePath)return;const _t=Ie.filePath.startsWith("/uploads/")&&!Ie.filePath.startsWith("/uploads/documents/")?Ie.filePath.replace("/uploads/","/uploads/documents/"):Ie.filePath;Z({fileName:Ie.name,filePath:_t,documentType:Ie.type})},children:[e.jsx(fs,{className:"w-4 h-4 mr-1"}),"View"]})})]},Ie.id))})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded for this stage yet"})}),e.jsx(rn,{children:e.jsx(se,{variant:"outline",onClick:()=>P({open:!1,stageName:"",documents:[]}),children:"Close"})})]})}),e.jsx(os,{open:W,onOpenChange:z,children:e.jsxs(ls,{children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Upload Resignation Document"}),e.jsx(vs,{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(ce,{children:"Document Type"}),e.jsxs(wt,{value:D,onValueChange:O,children:[e.jsx(Ct,{children:e.jsx(St,{placeholder:"Select document type"})}),e.jsx(At,{children:Ud.map(Ie=>e.jsx(Pe,{value:Ie,children:Ie},Ie))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{children:"Stage (Optional)"}),e.jsxs(wt,{value:V||"none",onValueChange:Ie=>K(Ie==="none"?"":Ie),children:[e.jsx(Ct,{children:e.jsx(St,{placeholder:"Select stage"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"none",children:"No Stage Mapping"}),mE.map(Ie=>e.jsx(Pe,{value:Ie,children:Ie},Ie))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{children:"File"}),e.jsx(ot,{type:"file",onChange:Ie=>{var _t;return B(((_t=Ie.target.files)==null?void 0:_t[0])||null)}})]})]}),e.jsxs(rn,{children:[e.jsx(se,{variant:"outline",onClick:()=>z(!1),disabled:M,children:"Cancel"}),e.jsx(se,{onClick:be,disabled:M,children:M?"Uploading...":"Upload"})]})]})}),e.jsx(Kl,{isOpen:!!G,onClose:()=>Z(null),document:G})]})}const So={getTerminationById:async t=>{const n=(await Te.getTerminationById(t)).data;return(n==null?void 0:n.termination)||(n==null?void 0:n.data)||n},updateTerminationStatus:async(t,s,n)=>(await Te.updateTerminationStatus(t,{action:s,remarks:n})).data,issueSCN:async(t,s)=>(await Te.issueSCN(t,s)).data,uploadSCNResponse:async(t,s,n)=>{const r=new FormData;return r.append("file",s),n&&r.append("remarks",n),(await Te.uploadSCNResponse(t,r)).data},uploadDocument:async(t,s)=>(await Te.uploadTerminationDocument(t,s)).data,finalizeTermination:async(t,s,n)=>(await Te.finalizeTermination(t,{decision:s,remarks:n})).data};function y$({terminationId:t,onBack:s,currentUser:n}){var Rt,Re,Qt,qt,ws,_s,ns,Cs,Bs,Ft,ie,Fe,Q,pe,Ne,Ee,it,st,bt,Ue,Lt,ut,yt,kt,Ie,_t,ht,zt,rs,Yt,Os,Is,zs,en;const r=qn(),[a,l]=v.useState({open:!1,type:null}),[c,d]=v.useState(""),[h,x]=v.useState(""),[f,m]=v.useState({open:!1,stageName:"",documents:[]}),[p,u]=v.useState(!0),[j,g]=v.useState(null),[y,N]=v.useState([]),[S,C]=v.useState(!1),[w,R]=v.useState(null),[P,A]=v.useState(""),[I,$]=v.useState(!1),[T,E]=v.useState(!1),[_,M]=v.useState("Approve"),[q,G]=v.useState(""),[Z,W]=v.useState(!1),[z,F]=v.useState(null),[B,D]=v.useState(Zx[0]),[O,V]=v.useState(""),[K,Y]=v.useState(null),U=async()=>{try{u(!0);const he=await So.getTerminationById(t);g(he),X()}catch(he){console.error("Error fetching termination:",he)}finally{u(!1)}},X=async()=>{try{const he=await Te.getAuditLogs("termination",t);he.data&&he.data.success&&N(he.data.data||[])}catch(he){console.error("Error fetching audit logs:",he)}};if(v.useEffect(()=>{U()},[t]),p)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:[e.jsx(ss,{className:"w-8 h-8 text-amber-600 animate-spin"}),e.jsx("p",{className:"text-slate-600",children:"Loading termination details..."})]});const ne=async()=>{try{$(!0),await So.issueSCN(t,{remarks:P}),ee.success("SCN issued successfully"),C(!1),U()}catch{ee.error("Failed to issue SCN")}finally{$(!1)}},oe=async()=>{if(w)try{$(!0),await So.uploadSCNResponse(t,w,P),ee.success("SCN response uploaded"),C(!1),U()}catch{ee.error("Failed to upload response")}finally{$(!1)}},re=async()=>{try{$(!0),await So.finalizeTermination(t,_,q),ee.success(`Termination ${_.toLowerCase()}ed`),E(!1),U()}catch{ee.error("Failed to finalize termination")}finally{$(!1)}},ge=async()=>{if(!z){ee.error("Please select a file to upload");return}try{$(!0);const he=new FormData;he.append("file",z),he.append("documentType",B),O&&he.append("stage",O),await So.uploadDocument(t,he),ee.success("Document uploaded successfully"),W(!1),F(null),D(Zx[0]),V(""),U()}catch{ee.error("Failed to upload document")}finally{$(!1)}},ve=n&&["DD Lead","DD Head","NBH","DD Admin","Super Admin"].includes(n.role||n.roleCode),We=(()=>{if(!j||!n)return{canApprove:!1,canWithdraw:!1,canIssueSCN:!1,canUploadSCNResponse:!1,canFinalize:!1,canPushToFnF:!1};const he=j.currentStage,Ge=j.status,at=n.role||n.roleCode,pt=["Show Cause Notice","Show Cause Notice (SCN)","SCN"].includes(he),mt=["Completed","Rejected","Withdrawn","Terminated"].includes(Ge)||he==="Terminated",Bt=Ge==="F&F Initiated"||he==="F&F Initiated"||Ge==="Settled"||Ge==="FNF_INITIATED";return{canApprove:(at==="Super Admin"||at==="DD Admin"||he==="RBM Review"&&at==="RBM"||he==="ZBH Review"&&at==="ZBH"||he==="DD Lead Review"&&at==="DD Lead"||he==="Legal Verification"&&at==="Legal Admin"||he==="DD Head Review"&&at==="DD Head"||he==="NBH Evaluation"&&at==="NBH"||he==="NBH Final Approval"&&at==="NBH"||he==="CCO Approval"&&at==="CCO"||he==="CEO Final Approval"&&at==="CEO"||he==="Legal - Termination Letter"&&at==="Legal Admin")&&!mt&&!Bt&&!["NBH Final Approval","CCO Approval","CEO Final Approval","Show Cause Notice","Show Cause Notice (SCN)","SCN"].includes(he),canIssueSCN:he==="NBH Evaluation"&&(at==="NBH"||at==="Super Admin")&&!mt,canUploadSCNResponse:pt&&["Legal Admin","DD Admin","Super Admin"].includes(at)&&!mt,canFinalize:(he==="NBH Final Approval"&&at==="NBH"||he==="CCO Approval"&&at==="CCO"||he==="CEO Final Approval"&&at==="CEO"||at==="Super Admin")&&["NBH Final Approval","CCO Approval","CEO Final Approval"].includes(he)&&!mt,canPushToFnF:ve&&!Bt&&["Legal - Termination Letter","Terminated","Dealer Terminated"].includes(he),canWithdraw:at==="ASM"&&he==="Request Initiated"&&!mt,isFinalState:mt,isSettlementPhase:Bt}})(),Ce=j||{},fe=["Show Cause Notice","Show Cause Notice (SCN)","SCN"].includes(Ce.currentStage),Ye={Submitted:["Submitted","Request Initiated"],"RBM Review":["RBM 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"],"Personal Hearing":["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"]},be=["Submitted","RBM Review","ZBH Review","DD Lead Review","Legal Verification","DD Head Review","NBH Evaluation","Show Cause Notice (SCN)","Personal Hearing","NBH Final Approval","CCO Approval","CEO Final Approval","Legal - Termination Letter","Dealer Terminated"],_e=he=>{if(!he)return"";const Ge=String(he).trim();return be.find(pt=>(Ye[pt]||[pt]).includes(Ge))||Ge},ke=he=>{const Ge=["Rejected","Revoked","Withdrawn"].includes(Ce.status),at=["Completed","Terminated","Settled","F&F Initiated","FNF_INITIATED"].includes(Ce.status)||Ce.currentStage==="Terminated";let pt=Ce.currentStage||Ce.status;if(Ge&&(Ce.currentStage==="Rejected"||Ce.currentStage==="Revoked"||!Ce.currentStage)){const as=[...Ce.timeline||[]].reverse().find(Vs=>Vs.stage&&Vs.stage!=="Rejected"&&Vs.stage!=="Revoked");as&&(pt=as.stage)}const mt=_e(pt),Bt=be.indexOf(mt),Ds=be.indexOf(he);return at&&Ds<=Bt?"completed":Ds===-1?"pending":Bt===-1?he==="Submitted"?"completed":"pending":Ds<Bt?"completed":Ds===Bt?Ge?"completed":"active":"pending"},qe=[...Ce.documents||[],...Ce.uploadedDocuments||[]],Ve=Object.keys(Ye).reduce((he,Ge)=>{const at=Ye[Ge]||[Ge],pt=qe.filter(mt=>!mt.stage||at.includes(mt.stage)).map(mt=>{var Bt;return{id:mt.id||`${Ge}-${mt.fileName||mt.name}`,name:mt.fileName||mt.name||"Document",type:mt.documentType||mt.type||"Document",uploadDate:mt.uploadDate||mt.createdAt?Ht(mt.uploadDate||mt.createdAt):"N/A",uploader:((Bt=mt.uploader)==null?void 0:Bt.fullName)||mt.uploader||"-",path:mt.filePath||mt.path||mt.url}});return he[Ge]=pt,he},{}),dt=he=>{const Ge=Ye[he]||[he],at=(Ce.timeline||[]).filter(pt=>Ge.includes(pt.stage));return at.length===0?null:he==="Submitted"?at.find(mt=>String((mt==null?void 0:mt.action)||"").toLowerCase().includes("initiated"))||at[0]:at[at.length-1]},xt=[{id:1,name:"Submitted",status:ke("Submitted"),description:"Termination request initiated",date:"",actionType:"",actionBy:"",remarks:"",feedback:""},{id:2,name:"RBM Review",status:ke("RBM Review"),description:"Regional Business Manager review"},{id:3,name:"ZBH Review",status:ke("ZBH Review"),description:"Zonal Business Head evaluation"},{id:4,name:"DD Lead Review",status:ke("DD Lead Review"),description:"DD Lead validation"},{id:5,name:"Legal Verification",status:ke("Legal Verification"),description:"Legal team validates termination grounds"},{id:6,name:"DD Head Review",status:ke("DD Head Review"),description:"DD Head strategic review"},{id:7,name:"NBH Evaluation",status:ke("NBH Evaluation"),description:"National Business Head decision"},{id:8,name:"Show Cause Notice (SCN)",status:ke("Show Cause Notice (SCN)"),description:"SCN sent to dealer, awaiting response"},{id:9,name:"Personal Hearing",status:ke("Personal Hearing"),description:"Evaluation of SCN response & Hearing"},{id:10,name:"NBH Final Approval",status:ke("NBH Final Approval"),description:"NBH final termination decision"},{id:11,name:"CCO Approval",status:ke("CCO Approval"),description:"Chief Commercial Officer approval"},{id:12,name:"CEO Final Approval",status:ke("CEO Final Approval"),description:"CEO final authorization"},{id:13,name:"Legal - Termination Letter",status:ke("Legal - Termination Letter"),description:"Legal team issues final termination letter"},{id:14,name:"Dealer Terminated",status:ke("Dealer Terminated"),description:"Dealership termination effective",date:"",actionType:"",actionBy:"",remarks:"",feedback:""}],ye=he=>{const Ge=Ve[he]||[];m({open:!0,stageName:he,documents:Ge})},le=he=>{l({open:!0,type:he})},Qe=async()=>{var pt,mt;const he=a.type,Ge=he==="sendBack"?"sendBack":he||"approve",at=c.trim();if(["sendBack","revoke"].includes(he||"")&&at.length<5){ee.error("Please provide detailed remarks (minimum 5 characters required for Send Back / Revoke)");return}if(!at&&!["assign","pushfnf"].includes(he||"")){ee.error("Please provide remarks/comments for this action");return}if(he==="assign"&&!h){ee.error("Please select a user");return}$(!0);try{if(he==="approve"||he==="sendBack"||he==="withdrawal"||he==="revoke")await So.updateTerminationStatus(t,Ge,c);else if(he==="pushfnf")await So.updateTerminationStatus(t,"pushfnf",c);else{ee.error("Action logic not fully implemented for this type"),$(!1);return}const Bt={approve:"Request approved and forwarded",withdrawal:"Request withdrawn successfully",sendBack:"Request sent back for clarification",assign:`Request assigned to ${h}`,pushfnf:"Request pushed to F&F successfully",revoke:"Request revoked and withdrawn"};ee.success(Bt[he]||"Action completed"),l({open:!1,type:null}),d(""),x(""),U()}catch(Bt){const Ds=((mt=(pt=Bt.response)==null?void 0:pt.data)==null?void 0:mt.message)||"Failed to perform action";ee.error(Ds)}finally{$(!1)}},rt=he=>{switch(he){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"}},Kt=(Ce.worknotes||[]).length;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(mi,{className:"border-amber-200 bg-amber-50",children:[e.jsx(Ya,{className:"h-4 w-4 text-amber-600"}),e.jsx(Hi,{className:"text-amber-900",children:"Sensitive Information"}),e.jsx(fi,{className:"text-amber-700",children:"This is a termination case. All actions are logged and audited. Proceed with caution."})]}),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($r,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl",children:Ce.requestId||t}),e.jsx("p",{className:"text-slate-600",children:((Rt=Ce.dealer)==null?void 0:Rt.businessName)||((Re=Ce.dealer)==null?void 0:Re.legalName)||"Termination"})]}),e.jsx(Ae,{className:rt(Ce.severity),children:Ce.severity}),e.jsx(Ae,{className:Ce.status==="Completed"||Ce.status==="Terminated"||Ce.status==="Settled"?"bg-green-100 text-green-700 border-green-300":Ce.status==="Rejected"||Ce.status==="Withdrawn"?"bg-red-100 text-red-700 border-red-300":"bg-yellow-100 text-yellow-700 border-yellow-300",children:Ce.status==="Settled"?"Completed":Ce.status||"Pending"})]})}),e.jsx(Le,{className:"border-amber-200 shadow-sm",children:e.jsx(Me,{className:"pt-6",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-slate-600 mr-2",children:"Termination Actions:"}),(n==null?void 0:n.role)!=="Dealer"&&e.jsxs(e.Fragment,{children:[!We.canFinalize&&e.jsxs(e.Fragment,{children:[We.canApprove&&e.jsxs(se,{size:"sm",className:"bg-green-600 hover:bg-green-700 transition-all hover:shadow-md",onClick:()=>le("approve"),children:[e.jsx(Bn,{className:"w-4 h-4 mr-2"}),"Approve"]}),We.canIssueSCN&&e.jsxs(se,{size:"sm",className:"bg-purple-600 hover:bg-purple-700 transition-all shadow-sm",onClick:()=>C(!0),children:[e.jsx(Ya,{className:"w-4 h-4 mr-2"}),"Issue SCN"]}),We.canUploadSCNResponse&&e.jsxs(se,{size:"sm",className:"bg-amber-600 hover:bg-amber-700 transition-all shadow-sm",onClick:()=>{R(null),C(!0)},children:[e.jsx(fs,{className:"w-4 h-4 mr-2"}),"Upload SCN Response"]}),We.canApprove&&e.jsxs(se,{size:"sm",variant:"outline",className:"hover:bg-slate-50 transition-all",onClick:()=>le("sendBack"),children:[e.jsx(Qv,{className:"w-4 h-4 mr-2"}),"Send Back"]})]}),We.canFinalize&&e.jsxs(se,{size:"sm",className:"bg-indigo-600 hover:bg-indigo-700 transition-all shadow-sm",onClick:()=>E(!0),children:[e.jsx(Fl,{className:"w-4 h-4 mr-2"}),"Final Authorization"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[We.canPushToFnF&&e.jsxs(se,{size:"sm",variant:"outline",className:"text-blue-600 border-blue-300 hover:bg-blue-50 transition-all",onClick:()=>le("pushfnf"),children:[e.jsx(fu,{className:"w-4 h-4 mr-2"}),"Push to F&F"]}),!We.isFinalState&&e.jsxs(se,{size:"sm",variant:"outline",className:"hover:bg-slate-50 transition-all",onClick:()=>le("assign"),children:[e.jsx(Jv,{className:"w-4 h-4 mr-2"}),"Assign User"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-amber-200",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zr,{className:"w-4 h-4 text-slate-500"}),e.jsx("span",{className:"text-sm text-slate-600",children:"Communication & Notes"})]}),e.jsxs(se,{size:"sm",variant:"outline",className:"relative hover:bg-amber-50 hover:border-amber-300 hover:text-amber-700 transition-all shadow-sm",onClick:()=>{var he;return r(`/worknotes/termination/${t}`,{state:{applicationName:((he=Ce==null?void 0:Ce.dealer)==null?void 0:he.businessName)||"Termination",registrationNumber:t||"",participants:(Ce==null?void 0:Ce.participants)||[]}})},children:[e.jsx(zr,{className:"w-4 h-4 mr-2"}),"View Work Notes",Kt>0&&e.jsx(Ae,{className:"ml-2 bg-amber-600 hover:bg-amber-700 text-white h-5 px-2",children:Kt})]})]})]})})}),e.jsxs(Pn,{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(Gt,{value:"details",className:"space-y-6",children:[e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Dealer Information"})}),e.jsx(Me,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:((qt=(Qt=Ce.dealer)==null?void 0:Qt.dealerCode)==null?void 0:qt.dealerCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((ws=Ce.dealer)==null?void 0:ws.businessName)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:((_s=Ce.dealer)==null?void 0:_s.gstNumber)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Dealer Email"}),e.jsx("p",{children:((Cs=(ns=Ce.dealer)==null?void 0:ns.user)==null?void 0:Cs.email)||"N/A"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(ce,{className:"text-slate-600",children:"Address"}),e.jsx("p",{children:((Bs=Ce.dealer)==null?void 0:Bs.registeredAddress)||((ie=(Ft=Ce.dealer)==null?void 0:Ft.application)==null?void 0:ie.address)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"City"}),e.jsx("p",{children:((Q=(Fe=Ce.dealer)==null?void 0:Fe.application)==null?void 0:Q.city)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"District"}),e.jsx("p",{children:((Ee=(Ne=(pe=Ce.dealer)==null?void 0:pe.application)==null?void 0:Ne.district)==null?void 0:Ee.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Dealership Name"}),e.jsx("p",{children:((it=Ce.dealer)==null?void 0:it.businessName)||Ce.dealershipName})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Sales Code"}),e.jsx("p",{children:((bt=(st=Ce.dealer)==null?void 0:st.dealerCode)==null?void 0:bt.salesCode)||Ce.salesCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Service Code"}),e.jsx("p",{children:((Lt=(Ue=Ce.dealer)==null?void 0:Ue.dealerCode)==null?void 0:Lt.serviceCode)||Ce.serviceCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:((yt=(ut=Ce.dealer)==null?void 0:ut.dealerCode)==null?void 0:yt.gmaCode)||Ce.accessoriesCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:((Ie=(kt=Ce.dealer)==null?void 0:kt.dealerCode)==null?void 0:Ie.gmaCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Gear Code"}),e.jsx("p",{children:((ht=(_t=Ce.dealer)==null?void 0:_t.dealerCode)==null?void 0:ht.gearCode)||"N/A"})]})]})})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Operational Details"})}),e.jsx(Me,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Inauguration"}),e.jsx("p",{children:(zt=Ce.dealer)!=null&&zt.onboardedAt?Ht(Ce.dealer.onboardedAt,"date"):Ce.inauguration||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"LOA Date"}),e.jsx("p",{children:(rs=Ce.dealer)!=null&&rs.loaDate?Ht(Ce.dealer.loaDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"LOI Date"}),e.jsx("p",{children:(Yt=Ce.dealer)!=null&&Yt.loiDate?Ht(Ce.dealer.loiDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Last 6 Months Sales"}),e.jsx("p",{children:Ce.lastSixMonthsSales})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Number of Dealerships"}),e.jsx("p",{children:Ce.numberOfDealerships})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Number of Studios"}),e.jsx("p",{children:Ce.numberOfStudios})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Constitution"}),e.jsx("p",{children:((Os=Ce.dealer)==null?void 0:Os.constitutionType)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Dealership Type"}),e.jsx("p",{children:((zs=(Is=Ce.dealer)==null?void 0:Is.application)==null?void 0:zs.businessType)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Type of Closure"}),e.jsx("p",{children:Ce.typeOfClosure||"Complete"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Format Category"}),e.jsx("p",{children:Ce.formatCategory||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Dealer Score Card Band"}),e.jsx("p",{children:Ce.dealerScoreCardBand||"N/A"})]})]})})]}),e.jsxs(Le,{className:"border-amber-200 bg-amber-50/30",children:[e.jsx(tt,{children:e.jsxs(nt,{className:"text-amber-900 flex items-center gap-2",children:[e.jsx(Ya,{className:"w-5 h-5"}),"Termination Details"]})}),e.jsx(Me,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Termination Category"}),e.jsx("p",{className:"text-amber-900",children:Ce.category})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Sub Category"}),e.jsx("p",{children:Ce.subCategory||"N/A"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Description"}),e.jsx("p",{children:Ce.reason})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Severity"}),e.jsx("div",{className:"mt-1",children:e.jsx(Ae,{className:rt(Ce.severity),children:Ce.severity})})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Submitted By"}),e.jsx("p",{children:((en=Ce.initiator)==null?void 0:en.fullName)||"System"})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Ht(Ce.createdAt)})]})]})]})})]})]}),e.jsx(Gt,{value:"progress",children:e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"Termination Progress Timeline"}),e.jsx(Zt,{children:"Track the termination request approval process"})]}),e.jsx(Me,{children:e.jsx("div",{className:"space-y-4",children:xt.map((he,Ge)=>{var mt;const at=((mt=Ve[he.name])==null?void 0:mt.length)||0,pt=dt(he.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 ${he.status==="completed"?"bg-green-100 text-green-600":he.status==="active"?"bg-amber-100 text-amber-600":"bg-slate-100 text-slate-400"}`,children:he.status==="completed"?e.jsx(Bn,{className:"w-5 h-5"}):he.status==="active"?e.jsx(Ya,{className:"w-5 h-5"}):e.jsx("span",{children:he.id})}),Ge<xt.length-1&&e.jsx("div",{className:`w-0.5 ${he.remarks?"h-32":"h-16"} ${he.status==="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.status==="completed"?"text-green-600":he.status==="active"?"text-amber-600":"text-slate-400",children:he.name}),at>0&&e.jsxs("button",{onClick:()=>ye(he.name),className:"flex items-center gap-1 px-2 py-1 rounded-full bg-amber-100 hover:bg-amber-200 text-amber-700 text-xs transition-colors cursor-pointer",children:[e.jsx(fs,{className:"w-3 h-3"}),e.jsxs("span",{children:[at," ",at===1?"doc":"docs"]})]})]}),((pt==null?void 0:pt.timestamp)||he.date)&&e.jsxs("div",{className:"flex items-center gap-1 text-sm text-slate-600",children:[e.jsx($n,{className:"w-4 h-4"}),e.jsx("span",{children:Ht((pt==null?void 0:pt.timestamp)||he.date)})]})]}),e.jsx("p",{className:"text-slate-600 text-sm",children:he.description}),pt&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae,{className:"bg-blue-100 text-blue-700 border-blue-300",children:pt.action||"Updated"}),e.jsxs("span",{className:"text-xs text-slate-500",children:["by ",pt.user||"System"]})]}),e.jsx("div",{className:"bg-slate-50 border border-slate-200 rounded-lg p-3",children:e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{children:[e.jsx(ce,{className:"text-xs text-slate-600",children:"Remarks:"}),e.jsx("p",{className:"text-sm text-slate-700 mt-1",children:pt.remarks||"No remarks provided."})]})})})]})]})]},he.id)})})})]})}),e.jsx(Gt,{value:"documents",children:e.jsxs(Le,{children:[e.jsxs(tt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(nt,{children:"Documents"}),e.jsx(Zt,{children:"View and manage termination case documents"})]}),e.jsxs(se,{size:"sm",onClick:()=>W(!0),className:"bg-amber-600 hover:bg-amber-700",children:[e.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Upload Document"]})]}),e.jsx(Me,{children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Document Name"}),e.jsx(me,{children:"Type"}),e.jsx(me,{children:"Upload Date"}),e.jsx(me,{children:"Uploader"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Es,{children:(()=>{const he=[...Ce.documents||[],...Ce.uploadedDocuments||[]];return he.length===0?e.jsx(ct,{children:e.jsx(de,{colSpan:5,className:"text-center py-4 text-slate-500",children:"No documents found"})}):he.map((Ge,at)=>{var pt;return e.jsxs(ct,{children:[e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"w-4 h-4 text-slate-500"}),e.jsx("span",{children:Ge.name||Ge.fileName})]})}),e.jsx(de,{children:Ge.documentType||Ge.type||"Document"}),e.jsx(de,{children:Ht(Ge.uploadDate||Ge.createdAt)}),e.jsx(de,{children:((pt=Ge.uploader)==null?void 0:pt.fullName)||Ge.uploader||"-"}),e.jsx(de,{children:e.jsx(se,{size:"sm",variant:"outline",onClick:()=>{const mt=Ge.filePath||Ge.path||Ge.url;if(!mt)return;const Bt=mt.startsWith("/uploads/")&&!mt.startsWith("/uploads/documents/")?mt.replace("/uploads/","/uploads/documents/"):mt;Y({fileName:Ge.name||Ge.fileName||"Document",filePath:Bt,documentType:Ge.documentType||Ge.type||"Document"})},children:"View"})})]},Ge.id||at)})})()})]})})]})}),e.jsx(Gt,{value:"audit",children:e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"Audit Trail"}),e.jsx(Zt,{children:"Complete history of actions on this termination case"})]}),e.jsx(Me,{children:e.jsx("div",{className:"space-y-4",children:y.length>0?y.map((he,Ge)=>{var at,pt,mt,Bt,Ds,as,Vs,Ls,Ts,ln,pn;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(Ae,{className:`
${(he.description||he.action||((at=he.details)==null?void 0:at.action)||"").toLowerCase().includes("reject")||(he.description||he.action||((pt=he.details)==null?void 0:pt.action)||"").toLowerCase().includes("revok")?"bg-red-100 text-red-700 border-red-200":(he.description||he.action||((mt=he.details)==null?void 0:mt.action)||"").toLowerCase().includes("sent back")||(he.description||he.action||((Bt=he.details)==null?void 0:Bt.action)||"").toLowerCase().includes("send back")?"bg-amber-100 text-amber-700 border-amber-200":(he.description||he.action||((Ds=he.details)==null?void 0:Ds.action)||"").toLowerCase().includes("approv")||(he.description||he.action||((as=he.details)==null?void 0:as.action)||"").toLowerCase().includes("initi")?"bg-emerald-100 text-emerald-700 border-emerald-200":"bg-slate-100 text-slate-700 border-slate-200"}
`,children:he.description||he.action}),e.jsxs("span",{className:"text-xs text-slate-500 font-medium italic",children:["by ",((Vs=he.actor)==null?void 0:Vs.name)||he.userName||"System"]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:Ht(he.timestamp||he.createdAt)})]}),(he.remarks||((Ls=he.newData)==null?void 0:Ls.remarks)||((Ts=he.details)==null?void 0:Ts.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:he.remarks||((ln=he.newData)==null?void 0:ln.remarks)||((pn=he.details)==null?void 0:pn.remarks)})]})]},Ge)}):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(os,{open:a.open,onOpenChange:he=>l({open:he,type:null}),children:e.jsxs(ls,{children:[e.jsxs(ms,{children:[e.jsxs(us,{children:[a.type==="approve"&&"Approve Termination Request",a.type==="withdrawal"&&"Withdraw Termination Request",a.type==="sendBack"&&"Send Back for Clarification",a.type==="revoke"&&"Revoke Termination Request",a.type==="assign"&&"Assign to User",a.type==="pushfnf"&&"Push to Full & Final Settlement"]}),e.jsx(vs,{children:a.type==="assign"?"Select a user to assign this request to":a.type==="pushfnf"?"This will move the termination case to F&F for dues clearance":"Please provide remarks for this action"})]}),e.jsx("div",{className:"space-y-4",children:a.type==="assign"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{children:"Select User"}),e.jsxs(wt,{value:h,onValueChange:x,children:[e.jsx(Ct,{children:e.jsx(St,{placeholder:"Choose a user"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"rbm",children:"RBM - Regional Business Manager"}),e.jsx(Pe,{value:"zbh",children:"ZBH - Zonal Business Head"}),e.jsx(Pe,{value:"dd-lead",children:"DD Lead"}),e.jsx(Pe,{value:"legal",children:"Legal Team"}),e.jsx(Pe,{value:"nbh",children:"NBH - National Business Head"}),e.jsx(Pe,{value:"cco",children:"CCO - Chief Commercial Officer"}),e.jsx(Pe,{value:"ceo",children:"CEO"})]})]})]}):a.type==="pushfnf"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{children:"Remarks (Optional)"}),e.jsx(Fs,{value:c,onChange:he=>d(he.target.value),placeholder:"Add any additional notes...",rows:3})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{children:"Remarks *"}),e.jsx(Fs,{value:c,onChange:he=>d(he.target.value),placeholder:"Enter your remarks here...",rows:4})]})}),e.jsxs(rn,{children:[e.jsx(se,{variant:"outline",onClick:()=>l({open:!1,type:null}),children:"Cancel"}),e.jsx(se,{onClick:Qe,className:a.type==="approve"?"bg-green-600 hover:bg-green-700":a.type==="withdrawal"?"bg-red-600 hover:bg-red-700":"bg-blue-600 hover:bg-blue-700",children:"Confirm"})]})]})}),e.jsx(os,{open:f.open,onOpenChange:he=>m({open:he,stageName:"",documents:[]}),children:e.jsxs(ls,{className:Fb,children:[e.jsxs(ms,{children:[e.jsxs(us,{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"w-5 h-5 text-amber-600"}),"Documents - ",f.stageName]}),e.jsxs(vs,{children:["Documents uploaded for this stage (",f.documents.length," ",f.documents.length===1?"document":"documents",")"]})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto",children:f.documents.length>0?e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Document Name"}),e.jsx(me,{children:"Type"}),e.jsx(me,{children:"Upload Date"}),e.jsx(me,{children:"Uploader"}),e.jsx(me,{children:"Action"})]})}),e.jsx(Es,{children:f.documents.map(he=>e.jsxs(ct,{children:[e.jsx(de,{children:he.name}),e.jsx(de,{children:e.jsx(Ae,{variant:"outline",children:he.type})}),e.jsx(de,{children:he.uploadDate}),e.jsx(de,{children:he.uploader}),e.jsx(de,{children:e.jsxs(se,{size:"sm",variant:"outline",className:"text-amber-600 hover:text-amber-700",onClick:()=>{const Ge=he.path;if(!Ge)return;const at=Ge.startsWith("/uploads/")&&!Ge.startsWith("/uploads/documents/")?Ge.replace("/uploads/","/uploads/documents/"):Ge;Y({fileName:he.name||"Document",filePath:at,documentType:he.type||"Document"})},children:[e.jsx(fs,{className:"w-4 h-4 mr-1"}),"View"]})})]},he.id))})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded for this stage yet"})}),e.jsx(rn,{children:e.jsx(se,{variant:"outline",onClick:()=>m({open:!1,stageName:"",documents:[]}),children:"Close"})})]})}),e.jsx(os,{open:S,onOpenChange:C,children:e.jsxs(ls,{className:"bg-white",children:[e.jsxs(ms,{children:[e.jsx(us,{children:fe?"Upload SCN Response":"Issue Show Cause Notice (SCN)"}),e.jsx(vs,{children:fe?"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:[fe&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{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:he=>{var Ge;return R(((Ge=he.target.files)==null?void 0:Ge[0])||null)}}),e.jsx(se,{variant:"outline",className:"w-full border-dashed",onClick:()=>{var he;return(he=document.getElementById("scn-file-upload"))==null?void 0:he.click()},children:w?w.name:"Select PDF or Image"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{children:"Remarks/Details"}),e.jsx(Fs,{placeholder:"Add any internal remarks or justification...",value:P,onChange:he=>A(he.target.value),rows:4})]}),e.jsxs(rn,{className:"gap-2 sm:gap-0",children:[e.jsx(se,{variant:"outline",onClick:()=>C(!1),disabled:I,children:"Cancel"}),e.jsx(se,{className:fe?"bg-amber-600 hover:bg-amber-700":"bg-purple-600 hover:bg-purple-700",onClick:fe?oe:ne,disabled:I||fe&&!w,children:I?"Processing...":fe?"Upload Response":"Issue SCN"})]})]})]})}),e.jsx(os,{open:T,onOpenChange:E,children:e.jsxs(ls,{className:"bg-white",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Final Termination Authorization"}),e.jsx(vs,{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(ce,{children:"Final Decision"}),e.jsxs(wt,{value:_,onValueChange:he=>M(he),children:[e.jsx(Ct,{className:"mt-2 text-slate-900 border-slate-300",children:e.jsx(St,{placeholder:"Select decision"})}),e.jsxs(At,{className:"bg-white border-slate-200 shadow-xl overflow-visible z-[9999]",children:[e.jsx(Pe,{value:"Approve",className:"text-amber-700 focus:bg-amber-50",children:"Confirm Termination"}),e.jsx(Pe,{value:"Reject",className:"text-slate-600 focus:bg-slate-50",children:"Reject Termination"}),e.jsx(Pe,{value:"Reconsider",className:"text-amber-600 focus:bg-amber-50",children:"Reconsider / Give More Time"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{children:"Authorization Remarks"}),e.jsx(Fs,{placeholder:"Provide your rationale for this decision...",value:q,onChange:he=>G(he.target.value),rows:4})]}),e.jsxs(rn,{className:"gap-2 sm:gap-0",children:[e.jsx(se,{variant:"outline",onClick:()=>E(!1),disabled:I,children:"Cancel"}),e.jsx(se,{className:"bg-indigo-600 hover:bg-indigo-700",onClick:re,disabled:I||!q,children:I?"Authorizing...":"Submit Decision"})]})]})]})}),e.jsx(os,{open:Z,onOpenChange:W,children:e.jsxs(ls,{children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Upload Termination Document"}),e.jsx(vs,{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(ce,{children:"Document Type"}),e.jsxs(wt,{value:B,onValueChange:D,children:[e.jsx(Ct,{children:e.jsx(St,{placeholder:"Select document type"})}),e.jsx(At,{children:Zx.map(he=>e.jsx(Pe,{value:he,children:he},he))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{children:"Stage (Optional)"}),e.jsxs(wt,{value:O||"none",onValueChange:he=>V(he==="none"?"":he),children:[e.jsx(Ct,{children:e.jsx(St,{placeholder:"Select stage"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"none",children:"No Stage Mapping"}),g$.map(he=>e.jsx(Pe,{value:he,children:he},he))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{children:"File"}),e.jsx("input",{type:"file",onChange:he=>{var Ge;return F(((Ge=he.target.files)==null?void 0:Ge[0])||null)}})]})]}),e.jsxs(rn,{children:[e.jsx(se,{variant:"outline",onClick:()=>W(!1),disabled:I,children:"Cancel"}),e.jsx(se,{onClick:ge,disabled:I,children:I?"Uploading...":"Upload"})]})]})}),e.jsx(Kl,{isOpen:!!K,onClose:()=>Y(null),document:K})]})}const aa=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"-"}},u1=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"-"}},fE=({isOpen:t,onClose:s,onSubmit:n,editingBank:r,isSubmitting:a})=>e.jsx(os,{open:t,onOpenChange:s,children:e.jsxs(ls,{className:"sm:max-w-[500px]",children:[e.jsxs(ms,{children:[e.jsx(us,{children:r?"Edit Bank Details":"Add Bank Account"}),e.jsx(vs,{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(ce,{htmlFor:"bankName",className:"text-right text-xs",children:"Bank Name"}),e.jsx("div",{className:"col-span-3",children:e.jsx(ot,{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(ce,{htmlFor:"accountHolderName",className:"text-right text-xs",children:"Holder Name"}),e.jsx("div",{className:"col-span-3",children:e.jsx(ot,{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(ce,{htmlFor:"accountNumber",className:"text-right text-xs",children:"A/C Number"}),e.jsx("div",{className:"col-span-3",children:e.jsx(ot,{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(ce,{htmlFor:"ifscCode",className:"text-right text-xs",children:"IFSC Code"}),e.jsx("div",{className:"col-span-3",children:e.jsx(ot,{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(ce,{htmlFor:"branchName",className:"text-right text-xs",children:"Branch"}),e.jsx("div",{className:"col-span-3",children:e.jsx(ot,{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-amber-600 focus:ring-amber-500","data-testid":"onboarding-is-primary-checkbox"}),e.jsx(ce,{htmlFor:"isPrimaryModal",className:"text-xs font-medium cursor-pointer",children:"Set as primary account"})]})})]}),e.jsxs(rn,{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-amber-600","data-testid":"onboarding-bank-details-submit",children:[a?e.jsx(ss,{className:"w-4 h-4 animate-spin mr-2"}):null,r?"Update Account":"Save Bank Details"]})]})]})]})}),h1=["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"],j$="[DEPARTMENT_CLAIM]",N$="[FINANCE_VALIDATED]";function w$({fnfId:t,onBack:s,currentUser:n}){var ke,qe,Ve,dt,xt;const r=qn(),[a,l]=v.useState(null),[c,d]=v.useState(!0),[h,x]=v.useState("details"),[f,m]=v.useState(!1),[p,u]=v.useState(null),[j,g]=v.useState([]),[y,N]=v.useState([]),[S,C]=v.useState(!1),[w,R]=v.useState(null),[P,A]=v.useState(!1),[I,$]=v.useState(!1),[T,E]=v.useState(null),[_,M]=v.useState(!1),[q,G]=v.useState({remarks:"",amount:0,type:"Receivable"}),[Z,W]=v.useState(null);v.useEffect(()=>{V(),K()},[t]);const z=ye=>{if(!ye)return ye;let le=ye.trim();const Qe=h1.find(Rt=>Rt.toLowerCase()===le.toLowerCase());if(Qe)return Qe;const Kt={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"}[le.toLowerCase().replace(" department","")];return Kt||ye},F=(ye,le)=>le==="DepartmentClaim"||typeof ye=="string"&&(ye.startsWith(j$)||ye.includes("Clearance:")),B=ye=>(ye==null?void 0:ye.sourceType)==="FinanceValidated"&&typeof(ye==null?void 0:ye.description)=="string"&&ye.description.includes("Auto-seeded from department claim"),D=(ye,le)=>le==="FinanceValidated"||typeof ye=="string"&&ye.startsWith(N$),O=ye=>ye?{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"}[ye]||ye.split("_").map(Qe=>Qe.charAt(0).toUpperCase()+Qe.slice(1).toLowerCase()).join(" "):"Action",V=async(ye=!0)=>{var le,Qe,rt,Kt,Rt,Re,Qt,qt,ws,_s,ns,Cs,Bs,Ft,ie,Fe,Q,pe,Ne,Ee,it,st,bt,Ue,Lt,ut,yt,kt,Ie,_t,ht,zt,rs,Yt,Os,Is,zs,en,he,Ge,at,pt,mt,Bt,Ds,as,Vs,Ls,Ts,ln,pn,hn,Ws,Qs,zn,on,Un,yr,Tr,er,tr,En,Xe,$t;try{ye&&d(!0);const Ut=(await Te.getFnFSettlementById(t)).data;if(Ut.success){const jt=Ut.fnf,In=(jt.lineItems||[]).filter(Tt=>Tt.isActive!==!1),Pr=In.some(Tt=>D(Tt.description,Tt.sourceType))?In.filter(Tt=>D(Tt.description,Tt.sourceType)):In.filter(Tt=>!F(Tt.description,Tt.sourceType)),xn={id:jt.id,caseNumber:jt.settlementId||((le=jt.resignation)==null?void 0:le.resignationId)||((Qe=jt.terminationRequest)==null?void 0:Qe.requestId)||jt.id.substring(0,8),status:jt.status,requestType:jt.resignationId?"Resignation":"Termination",dealerName:((Kt=(rt=jt.outlet)==null?void 0:rt.dealer)==null?void 0:Kt.fullName)||((Rt=jt.dealer)==null?void 0:Rt.fullName)||"N/A",dealerCode:((Re=jt.outlet)==null?void 0:Re.code)||((qt=(Qt=jt.dealer)==null?void 0:Qt.dealerCode)==null?void 0:qt.dealerCode)||"N/A",dealershipName:((ws=jt.outlet)==null?void 0:ws.name)||((_s=jt.dealer)==null?void 0:_s.businessName)||"N/A",location:((ns=jt.outlet)==null?void 0:ns.city)||((Cs=jt.outlet)==null?void 0:Cs.location)||"N/A",originalRequestId:((Bs=jt.resignation)==null?void 0:Bs.resignationId)||((Ft=jt.terminationRequest)==null?void 0:Ft.requestId)||((ie=jt.terminationRequest)==null?void 0:ie.id)||"N/A",submittedOn:aa(jt.createdAt),lastOperationalDateSales:(Fe=jt.resignation)!=null&&Fe.lastOperationalDateSales||(Q=jt.terminationRequest)!=null&&Q.proposedLwd?u1(((pe=jt.resignation)==null?void 0:pe.lastOperationalDateSales)||((Ne=jt.terminationRequest)==null?void 0:Ne.proposedLwd)):"N/A",lastOperationalDateServices:(Ee=jt.resignation)!=null&&Ee.lastOperationalDateServices||(it=jt.terminationRequest)!=null&&it.proposedLwd?u1(((st=jt.resignation)==null?void 0:st.lastOperationalDateServices)||((bt=jt.terminationRequest)==null?void 0:bt.proposedLwd)):"N/A",typeOfClosure:jt.resignationId?"Voluntary":"Involuntary",gst:((ut=(Lt=(Ue=jt.outlet)==null?void 0:Ue.dealer)==null?void 0:Lt.dealerProfile)==null?void 0:ut.gstNumber)||((yt=jt.dealer)==null?void 0:yt.gstNumber)||"N/A",pan:((_t=(Ie=(kt=jt.outlet)==null?void 0:kt.dealer)==null?void 0:Ie.dealerProfile)==null?void 0:_t.panNumber)||((ht=jt.dealer)==null?void 0:ht.panNumber)||"N/A",salesCode:((rs=(zt=jt.dealer)==null?void 0:zt.dealerCode)==null?void 0:rs.salesCode)||((zs=(Is=(Os=(Yt=jt.outlet)==null?void 0:Yt.dealer)==null?void 0:Os.dealerProfile)==null?void 0:Is.dealerCode)==null?void 0:zs.salesCode)||"N/A",serviceCode:((he=(en=jt.dealer)==null?void 0:en.dealerCode)==null?void 0:he.serviceCode)||((mt=(pt=(at=(Ge=jt.outlet)==null?void 0:Ge.dealer)==null?void 0:at.dealerProfile)==null?void 0:pt.dealerCode)==null?void 0:mt.serviceCode)||"N/A",gearCode:((Ds=(Bt=jt.dealer)==null?void 0:Bt.dealerCode)==null?void 0:Ds.gearCode)||((Ts=(Ls=(Vs=(as=jt.outlet)==null?void 0:as.dealer)==null?void 0:Vs.dealerProfile)==null?void 0:Ls.dealerCode)==null?void 0:Ts.gearCode)||"N/A",gmaCode:((pn=(ln=jt.dealer)==null?void 0:ln.dealerCode)==null?void 0:pn.gmaCode)||((zn=(Qs=(Ws=(hn=jt.outlet)==null?void 0:hn.dealer)==null?void 0:Ws.dealerProfile)==null?void 0:Qs.dealerCode)==null?void 0:zn.gmaCode)||"N/A",financeReportStatus:jt.status==="Finance Approval"?"In Progress":jt.status==="Completed"?"Completed":"Pending",totalPayableAmount:Pr.filter(Tt=>Tt.itemType==="Payable").reduce((Tt,xs)=>Tt+(parseFloat(xs.amount)||0),0),totalRecoveryAmount:Pr.filter(Tt=>Tt.itemType==="Receivable"||Tt.itemType==="Recovery").reduce((Tt,xs)=>Tt+(parseFloat(xs.amount)||0),0),totalDeductions:Pr.filter(Tt=>Tt.itemType==="Deduction").reduce((Tt,xs)=>Tt+(parseFloat(xs.amount)||0),0),allLineItems:In,netAmount:0,departmentResponses:[]};xn.netAmount=xn.totalPayableAmount-xn.totalRecoveryAmount-xn.totalDeductions,xn.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(Tt=>{const xs=(jt.clearances||[]).find(dn=>z(dn.department)===Tt),Vr=In.filter(dn=>z(dn.department)===Tt&&F(dn.description,dn.sourceType)),ta=In.filter(dn=>z(dn.department)===Tt&&B(dn)),ma=Vr.length>0?Vr:ta;let _r=0,sr=0;ma.forEach(dn=>{const wn=Math.abs(parseFloat(dn.amount)||0);dn.itemType==="Payable"?_r+=wn:sr+=wn});const gn=_r-sr,mn=Math.abs(gn)>0,Qn=(xs==null?void 0:xs.status)||"Pending",fr=mn?"Dues Pending":Qn==="Cleared"?"NOC Submitted":Qn,pr=gn>0?"payable":gn<0?"recovery":null;return{id:(xs==null?void 0:xs.id)||`dept-${Tt}`,clearanceId:(xs==null?void 0:xs.id)||null,departmentName:Tt,status:fr,duesFlow:pr,amountType:gn>0?"Payable to dealer":gn<0?"Receivable from dealer":null,amount:Math.abs(gn),submittedDate:xs!=null&&xs.clearedAt?aa(xs.clearedAt):"-",remarks:(xs==null?void 0:xs.remarks)||"-",supportingDocument:(xs==null?void 0:xs.supportingDocument)||null}});const qs={...xn,documents:[...(((on=jt.resignation)==null?void 0:on.uploadedDocuments)||[]).map(Tt=>({id:`res-${Tt.id}`,name:Tt.fileName,type:"Resignation",uploadDate:aa(Tt.createdAt),status:"Verified",url:Tt.filePath})),...(jt.clearances||[]).filter(Tt=>Tt.supportingDocument).map(Tt=>({id:`clr-${Tt.id}`,name:Tt.supportingDocument.split("/").pop(),type:`${Tt.department} Proof`,uploadDate:aa(Tt.clearedAt),status:"Attached",url:Tt.supportingDocument})),...(jt.settlementDocs||[]).map(Tt=>({id:`set-${Tt.id}`,name:Tt.fileName,type:"Settlement Proof",uploadDate:aa(Tt.createdAt),status:"Finance",url:Tt.filePath}))],participants:jt.participants||[]};l(qs);const ha=jt.bankDetails||((Un=jt.dealer)==null?void 0:Un.bankDetails)||((er=(Tr=(yr=jt.outlet)==null?void 0:yr.dealer)==null?void 0:Tr.dealerProfile)==null?void 0:er.bankDetails);ha&&ha.length>0?N(ha):((En=(tr=jt.outlet)==null?void 0:tr.dealer)!=null&&En.id||jt.dealerId)&&Y((($t=(Xe=jt.outlet)==null?void 0:Xe.dealer)==null?void 0:$t.id)||jt.dealerId)}}catch(Ze){console.error("Fetch F&F details error:",Ze),ee.error("Failed to fetch settlement details")}finally{ye&&d(!1)}},K=async()=>{try{const le=(await Te.getAuditLogs("fnf",t)).data;le.success&&g(le.data||[])}catch(ye){console.error("Fetch audit logs error:",ye)}},Y=async ye=>{try{const Qe=(await Te.getDealerBankDetails(ye)).data;Qe.success&&N(Qe.bankDetails||[])}catch(le){console.error("Fetch bank details error:",le)}},U=async ye=>{var rt,Kt;ye.preventDefault();const le=new FormData(ye.currentTarget),Qe=Object.fromEntries(le.entries());try{A(!0);const Rt=((Kt=(rt=a==null?void 0:a.outlet)==null?void 0:rt.dealer)==null?void 0:Kt.id)||(a==null?void 0:a.dealerId);if(!Rt){ee.error("Dealer information missing");return}(await Te.saveBankDetail(Rt,{...Qe,id:w==null?void 0:w.id,isPrimary:le.get("isPrimary")==="on"})).data.success&&(ee.success("Bank details saved successfully"),Y(Rt),C(!1),R(null))}catch{ee.error("Failed to save bank details")}finally{A(!1)}},X=async ye=>{var le,Qe;if(confirm("Are you sure you want to delete this bank account?"))try{if((await Te.deleteBankDetail(ye)).data.success){ee.success("Bank detail deleted");const Kt=((Qe=(le=a==null?void 0:a.outlet)==null?void 0:le.dealer)==null?void 0:Qe.id)||(a==null?void 0:a.dealerId);Kt&&Y(Kt)}}catch{ee.error("Failed to delete bank detail")}};if(c)return e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(ss,{className:"w-8 h-8 animate-spin text-amber-600"})});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 oe=(ye=>{const le=new Date(ye),rt=Math.abs(new Date().getTime()-le.getTime());return Math.ceil(rt/(1e3*60*60*24))})(a.submittedOn),re=ye=>{if(!a||!ye)return!1;const le=String((n==null?void 0:n.role)||"").toLowerCase();if(!le||ye.status!=="Pending")return!1;const rt=["Finance Approval","Completed"].includes(a.status),Kt=le.includes("super admin")||le.includes("finance")||le.includes("dd admin");if(rt&&!Kt)return!1;if(Kt)return!0;const Rt=ye.departmentName.replace(" Department","").toLowerCase();return le.includes(Rt)},ge=((a==null?void 0:a.departmentResponses)||[]).some(ye=>re(ye)),ve=async()=>{var ye;if(!(T!=null&&T.clearanceId)||!t){ee.error("Clearance record not available for this department");return}try{M(!0);const le=new FormData,Qe=Number(q.amount)>0?"Dues Pending":"NOC Submitted";le.append("status",Qe),le.append("remarks",q.remarks),le.append("amount",String(q.amount)),le.append("type",q.type),Z&&le.append("file",Z);const rt=await Te.updateFnFClearance(t,T.clearanceId,le);if(!rt.ok){ee.error(((ye=rt.data)==null?void 0:ye.message)||"Failed to update department clearance"),M(!1);return}ee.success(`Clearance updated for ${T.departmentName}`),$(!1),W(null),x("departments"),V(!1)}catch(le){console.error("Update clearance error:",le),ee.error("Failed to update department clearance")}finally{M(!1)}},Se=()=>{ee.success("Notifications sent to all 16 departments"),m(!1)},We=ye=>{switch(ye){case"New":return"bg-amber-100 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"}},Ce=ye=>{switch(ye){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"}},fe=a.departmentResponses.filter(ye=>ye.status!=="Pending").length,Ye=a.departmentResponses.length,be=fe/Ye*100,_e=h1.map(ye=>{const le=(a.departmentResponses||[]).find(ns=>ns.departmentName===ye),Qe=Number(le==null?void 0:le.amount)||0,rt=(le==null?void 0:le.amountType)||"-",Kt=(a.allLineItems||[]).filter(ns=>z(ns.department)===ye),Rt=Kt.filter(ns=>ns.sourceType==="FinanceValidated"&&ns.itemType==="Payable").reduce((ns,Cs)=>ns+Math.abs(parseFloat(Cs.amount)||0),0),Re=Kt.filter(ns=>ns.sourceType==="FinanceValidated"&&(ns.itemType==="Receivable"||ns.itemType==="Recovery")).reduce((ns,Cs)=>ns+Math.abs(parseFloat(Cs.amount)||0),0),Qt=Kt.filter(ns=>ns.sourceType==="FinanceValidated"&&ns.itemType==="Deduction").reduce((ns,Cs)=>ns+Math.abs(parseFloat(Cs.amount)||0),0),qt=Rt-Re-Qt,ws=Math.abs(qt),_s=qt>0?"Payable":qt<0?"Receivable":"-";return{department:ye,claimAmount:Qe,claimType:rt,validatedAmount:ws,validatedType:_s,variance:ws-Qe}});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(Me,{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(F2,{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(Ae,{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($r,{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(Ae,{className:We(a.status),children:a.status}),e.jsx(Ae,{className:a.requestType==="Resignation"?"bg-amber-100 text-amber-700 border-amber-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(zr,{className:"w-4 h-4 mr-2"}),"View Work Notes"]})})]}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"Overall Progress"}),e.jsxs(Zt,{children:["Department responses: ",fe," / ",Ye]})]}),e.jsxs(Me,{children:[e.jsx(ji,{value:be,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(ye=>ye.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(ye=>ye.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(ye=>ye.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(Pn,{value:h,onValueChange:x,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.jsx(Wt,{value:"financial",children:"Financial Summary"}),e.jsx(Wt,{value:"documents",children:"Documents"}),e.jsx(Wt,{value:"bank",children:"Bank Details"}),e.jsx(Wt,{value:"audit",children:"Audit Trail"})]}),e.jsx(Gt,{value:"progress",children:e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"F&F Settlement Progress"}),e.jsx(Zt,{children:"Track the complete journey from initiation to completion"})]}),e.jsx(Me,{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(Bn,{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(Ae,{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(Me,{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 ${fe===Ye||["Finance Approval","Completed"].includes(a.status)?"bg-green-100 border-green-600":fe>0?"bg-amber-100 border-amber-600":"bg-slate-100 border-slate-300"}`,children:fe===Ye||["Finance Approval","Completed"].includes(a.status)?e.jsx(Bn,{className:"w-6 h-6 text-green-600"}):fe>0?e.jsx(da,{className:"w-6 h-6 text-amber-600"}):e.jsx(Js,{className:"w-6 h-6 text-slate-400"})}),e.jsx("div",{className:`w-0.5 h-full mt-2 ${fe===Ye||["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(Ae,{className:fe===Ye||["Finance Approval","Completed"].includes(a.status)?"bg-green-600":fe>0?"bg-amber-600":"bg-slate-400",children:fe===Ye||["Finance Approval","Completed"].includes(a.status)?"Completed":fe>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.",fe>0&&` (${fe}/${Ye} responses received)`]}),fe>0&&e.jsx(Le,{className:fe===Ye||["Finance Approval","Completed"].includes(a.status)?"bg-green-50 border-green-200":"bg-blue-50 border-amber-200",children:e.jsx(Me,{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:[fe," / ",Ye," ","departments"]})]}),e.jsx(ji,{value:be,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(ye=>ye.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(ye=>ye.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(ye=>ye.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-amber-100 border-amber-600":"bg-slate-100 border-slate-300"}`,children:a.status==="Completed"?e.jsx(Bn,{className:"w-6 h-6 text-green-600"}):a.status==="Finance Approval"?e.jsx(_d,{className:"w-6 h-6 text-amber-600"}):e.jsx(Js,{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(Ae,{className:a.status==="Completed"?"bg-green-600":a.status==="Finance Approval"?"bg-amber-600":"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-amber-200",children:e.jsx(Me,{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:["₹",((ke=a.totalPayableAmount)==null?void 0:ke.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:["₹",((qe=a.totalRecoveryAmount)==null?void 0:qe.toLocaleString())||"0"]})]}),e.jsxs("div",{className:"text-center p-3 bg-amber-100 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-amber-100 border-amber-600":"bg-slate-100 border-slate-300"}`,children:a.status==="Completed"?e.jsx(Bn,{className:"w-6 h-6 text-green-600"}):a.status==="Finance Approval"?e.jsx(zr,{className:"w-6 h-6 text-amber-600"}):e.jsx(Js,{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(Ae,{className:a.status==="Completed"?"bg-green-600":a.status==="Finance Approval"?"bg-amber-600":"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(Me,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ks,{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(Bn,{className:"w-6 h-6 text-green-600"}):e.jsx(Js,{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(Ae,{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(Fn,{className:"w-6 h-6 text-green-600"}):e.jsx(Js,{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(Ae,{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(Me,{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(Fn,{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(Gt,{value:"details",className:"space-y-6",children:[e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Basic Information"})}),e.jsx(Me,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Case Number"}),e.jsx("p",{children:a.caseNumber})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:a.dealerCode})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:a.dealerName})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Dealership Name"}),e.jsx("p",{children:a.dealershipName})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:a.location})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Request Type"}),e.jsx("p",{children:a.requestType})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Original Request ID"}),e.jsx("p",{children:a.originalRequestId})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:a.submittedOn})]})]})})]}),e.jsxs(Le,{className:"border-amber-200 bg-blue-50/30",children:[e.jsx(tt,{children:e.jsx(nt,{className:"text-blue-900",children:"F&F Settlement Information"})}),e.jsx(Me,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Last Operational Date (Sales)"}),e.jsx("p",{children:a.lastOperationalDateSales})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Last Operational Date (Services)"}),e.jsx("p",{children:a.lastOperationalDateServices})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Submitted Date (F&F Start)"}),e.jsx("p",{children:a.submittedOn})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Days Elapsed since Submission"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{children:[oe," days"]}),e.jsx(Ae,{variant:"outline",className:oe<30?"bg-green-100 text-green-700 border-green-300":oe<60?"bg-yellow-100 text-yellow-700 border-yellow-300":"bg-red-100 text-red-700 border-red-300",children:oe<30?"Recent":oe<60?"In Progress":"Overdue"})]})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Type of Closure"}),e.jsx("p",{children:a.typeOfClosure})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:a.gst})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Sales Code"}),e.jsx("p",{children:a.salesCode})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Service Code"}),e.jsx("p",{children:a.serviceCode})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-600",children:"Gear Code"}),e.jsx("p",{children:a.gearCode})]}),e.jsxs("div",{children:[e.jsx(ce,{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(tt,{children:[e.jsx(nt,{className:"text-orange-900",children:"Under Review"}),e.jsx(Zt,{className:"text-orange-700",children:"This case is under negotiation/discussion with the dealer, finance team, legal team, and relevant departments"})]}),e.jsx(Me,{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.jsx(Gt,{value:"departments",children:e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsxs(nt,{children:["Department Responses (",fe," / ",Ye,")"]}),e.jsx(Zt,{children:"Status of NOC and dues from all departments"})]}),e.jsx(Me,{children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Department"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Amount Type"}),e.jsx(me,{children:"Amount"}),e.jsx(me,{children:"Submitted Date"}),e.jsx(me,{children:"Remarks"}),ge&&e.jsx(me,{children:"Actions"})]})}),e.jsx(Es,{children:a.departmentResponses.map(ye=>e.jsxs(ct,{children:[e.jsx(de,{children:ye.departmentName}),e.jsx(de,{children:e.jsx(Ae,{className:Ce(ye.status),children:ye.status})}),e.jsx(de,{children:ye.amountType?e.jsx(Ae,{variant:"outline",className:ye.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:ye.amountType}):"-"}),e.jsx(de,{children:ye.amount?e.jsxs("span",{className:`font-semibold tabular-nums ${ye.duesFlow==="recovery"?"text-red-700":"text-emerald-700"}`,children:["₹",ye.amount.toLocaleString()]}):"-"}),e.jsx(de,{children:ye.submittedDate||"-"}),e.jsx(de,{className:"max-w-xs truncate",children:ye.remarks||"-"}),ge&&e.jsx(de,{children:re(ye)?e.jsx(se,{variant:"ghost",size:"sm",className:"text-amber-600 hover:text-blue-700",onClick:()=>{E(ye),G({remarks:ye.remarks==="-"?"":ye.remarks,amount:ye.amount||0,type:ye.duesFlow==="payable"?"Payable":"Receivable"}),W(null),$(!0)},children:"Action"}):e.jsx("span",{className:"text-slate-400 text-sm",children:"-"})})]},ye.id))})]})})]})}),e.jsx(Gt,{value:"financial",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Le,{className:"border-blue-200 bg-blue-50",children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"Department Claim vs Finance Validation"}),e.jsx(Zt,{children:"Final settlement totals are based on finance validated values."})]}),e.jsx(Me,{children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Department"}),e.jsx(me,{children:"Department Claim"}),e.jsx(me,{children:"Finance Validated"}),e.jsx(me,{children:"Variance"})]})}),e.jsx(Es,{children:_e.map(ye=>e.jsxs(ct,{children:[e.jsx(de,{children:ye.department}),e.jsx(de,{children:ye.claimAmount>0?`${ye.claimType} ₹${ye.claimAmount.toLocaleString()}`:"-"}),e.jsx(de,{children:ye.validatedAmount>0?`${ye.validatedType} ₹${ye.validatedAmount.toLocaleString()}`:"-"}),e.jsx(de,{className:ye.variance===0?"text-slate-600":ye.variance>0?"text-red-600":"text-green-600",children:ye.claimAmount===0&&ye.validatedAmount===0?"-":`₹${ye.variance.toLocaleString()}`})]},ye.department))})]})})]}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"Financial Summary"}),e.jsx(Zt,{children:"Consolidated view of all payable and receivable amounts"})]}),e.jsx(Me,{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:["₹",((Ve=a.totalPayableAmount)==null?void 0:Ve.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:["₹",((dt=a.totalRecoveryAmount)==null?void 0:dt.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-amber-50 rounded-lg border border-amber-200",children:[e.jsx("p",{className:"text-sm text-amber-700 mb-2",children:"Total Deductions"}),e.jsxs("p",{className:"text-3xl text-amber-600 font-bold",children:["₹",((xt=a.totalDeductions)==null?void 0:xt.toLocaleString())||"0"]}),e.jsx("p",{className:"text-xs text-amber-600 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,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Finance Report Status"})}),e.jsxs(Me,{children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Ae,{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(ce,{className:"text-slate-600",children:"Finance Remarks"}),e.jsx("p",{className:"mt-1",children:a.financeRemarks})]})]})]})]})}),e.jsx(Gt,{value:"documents",children:e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"Documents"}),e.jsx(Zt,{children:"All NOC documents and due statements from departments"})]}),e.jsx(Me,{children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Document Name"}),e.jsx(me,{children:"Type"}),e.jsx(me,{children:"Upload Date"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Es,{children:a.documents.map(ye=>e.jsxs(ct,{children:[e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"w-4 h-4 text-slate-500"}),e.jsx("span",{children:ye.name})]})}),e.jsx(de,{children:ye.type}),e.jsx(de,{children:ye.uploadDate}),e.jsx(de,{children:e.jsx(Ae,{variant:ye.status==="Verified"?"default":"secondary",children:ye.status})}),e.jsx(de,{children:e.jsx(se,{size:"sm",variant:"outline",onClick:()=>{const le=ye.url,Qe=le.startsWith("/uploads/")&&!le.startsWith("/uploads/documents/")?le.replace("/uploads/","/uploads/documents/"):le;u({fileName:ye.name,filePath:Qe,documentType:ye.type})},children:"View"})})]},ye.id))})]})})]})}),e.jsx(Gt,{value:"bank",children:e.jsxs(Le,{children:[e.jsxs(tt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(nt,{children:"Bank Details"}),e.jsx(Zt,{children:"Dealer bank accounts for settlement disbursement"})]}),e.jsxs(se,{onClick:()=>{R(null),C(!0)},className:"bg-amber-600",children:[e.jsx(cn,{className:"w-4 h-4 mr-2"}),"Add Account"]})]}),e.jsx(Me,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:y.length>0?y.map(ye=>e.jsxs(Le,{className:`relative overflow-hidden ${ye.isPrimary?"border-amber-500 bg-blue-50/30":""}`,children:[ye.isPrimary&&e.jsx("div",{className:"absolute top-0 right-0 p-1 bg-amber-600 text-white text-[10px] uppercase font-bold px-2 rounded-bl",children:"Primary"}),e.jsxs(Me,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 bg-amber-100 rounded-lg",children:e.jsx(Ml,{className:"w-5 h-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-slate-900",children:ye.bankName}),e.jsx("p",{className:"text-xs text-slate-500",children:ye.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:ye.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:ye.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:ye.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-amber-600",onClick:()=>{R(ye),C(!0)},children:[e.jsx(nv,{className:"w-3 h-3 mr-1"}),"Edit"]}),e.jsxs(se,{variant:"ghost",size:"sm",className:"h-8 text-red-600",onClick:()=>X(ye.id),children:[e.jsx(Gn,{className:"w-3 h-3 mr-1"}),"Delete"]})]})]})]},ye.id)):e.jsxs("div",{className:"col-span-full py-12 text-center border-2 border-dashed rounded-lg bg-slate-50",children:[e.jsx(Ml,{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(Gt,{value:"audit",children:e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"Audit Trail"}),e.jsx(Zt,{children:"Complete history of actions on this F&F case"})]}),e.jsx(Me,{children:e.jsx("div",{className:"space-y-4",children:j.length>0?j.map(ye=>{var le,Qe,rt,Kt,Rt,Re;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:[ye.action==="FNF_CREATED"&&e.jsx(Ae,{className:"bg-amber-600 h-2 w-2 p-0 rounded-full"}),ye.description&&!((le=ye.newData)!=null&&le.action)?ye.description:e.jsxs(e.Fragment,{children:[O(((Qe=ye.newData)==null?void 0:Qe.action)||ye.action),((rt=ye.newData)==null?void 0:rt.department)&&e.jsxs("span",{className:"text-amber-600 ml-1 font-bold",children:["- ",ye.newData.department]})]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:aa(ye.createdAt||ye.timestamp)})]}),e.jsx("div",{className:"flex items-center gap-2 text-sm text-slate-600 mb-2",children:e.jsx(Ae,{variant:"outline",className:"text-[10px] uppercase",children:((Kt=ye.actor)==null?void 0:Kt.name)||ye.userName||"System"})}),(((Rt=ye.newData)==null?void 0:Rt.remarks)||ye.remarks)&&e.jsx("div",{className:"mt-2 p-3 bg-slate-50 border border-slate-200 rounded text-sm text-slate-700",children:((Re=ye.newData)==null?void 0:Re.remarks)||ye.remarks}),ye.newData&&Object.keys(ye.newData).filter(Qt=>Qt!=="remarks"&&Qt!=="status"&&Qt!=="action"&&Qt!=="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(ye.newData).filter(([Qt])=>Qt!=="remarks"&&Qt!=="action"&&Qt!=="department").map(([Qt,qt])=>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:[Qt,":"]}),e.jsx("span",{className:"text-slate-900 font-medium",children:String(qt)})]},Qt))})]})]})]},ye.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(os,{open:f,onOpenChange:m,children:e.jsxs(ls,{children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Send to All Stakeholders"}),e.jsx(vs,{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-amber-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(rn,{children:[e.jsx(se,{variant:"outline",onClick:()=>m(!1),children:"Cancel"}),e.jsxs(se,{onClick:Se,className:"bg-amber-600 hover:bg-blue-700",children:[e.jsx(fu,{className:"w-4 h-4 mr-2"}),"Send Notifications"]})]})]})}),e.jsx(os,{open:I,onOpenChange:$,children:e.jsxs(ls,{className:"sm:max-w-[460px]",children:[e.jsxs(ms,{children:[e.jsxs(us,{children:["Update ",T==null?void 0:T.departmentName," Response"]}),e.jsx(vs,{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(ce,{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:q.type,onChange:ye=>G({...q,type:ye.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(ce,{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:q.amount,onChange:ye=>G({...q,amount:Number(ye.target.value)})})]})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(ce,{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:q.remarks,onChange:ye=>G({...q,remarks:ye.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(ce,{htmlFor:"proof",className:"text-right",children:"Proof"}),e.jsx("input",{id:"proof",type:"file",className:"col-span-3 text-sm",onChange:ye=>{var le;return W(((le=ye.target.files)==null?void 0:le[0])||null)}})]})]}),e.jsxs(rn,{children:[e.jsx(se,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),e.jsx(se,{className:"bg-amber-600 hover:bg-blue-700",onClick:ve,disabled:_,children:_?"Saving...":"Submit Response"})]})]})}),e.jsx(fE,{isOpen:S,onClose:()=>{C(!1),R(null)},onSubmit:U,editingBank:w,isSubmitting:P}),e.jsx(Kl,{isOpen:!!p,onClose:()=>u(null),document:p})]})}function S$({onViewPaymentDetails:t}={}){const[s,n]=v.useState([]),[r,a]=v.useState(!0),[l,c]=v.useState("pending");v.useEffect(()=>{d()},[]);const d=async()=>{try{a(!0);const u=await ds.getApplications();n(u.data||[])}catch(u){console.error("Fetch error:",u),ee.error("Failed to fetch applications")}finally{a(!1)}},h=u=>String(u||"").trim().toLowerCase(),x=u=>{const j=h(u);return j==="verified"||j==="paid"},f=s.flatMap(u=>{const j=u.overallStatus||u.status,g=["Payment Pending","Security Details","LOI In Progress","LOI Issued","LOA Pending","Dealer Code Generation","LOA_APPROVAL"].includes(j),y=u.securityDeposits||[];return y.length>0?y.map(N=>({id:N.id,applicationId:u.applicationId||u.id,application:u,paymentStatus:N.status,paymentType:N.depositType,amount:N.amount,createdAt:N.createdAt,verificationDate:N.verifiedAt,isVirtual:!1})):g?["Payment Pending","Security Details","LOI In Progress"].includes(j)?[{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}]:[]}),m=f.filter(u=>l==="all"?!0:l==="pending"?!x(u.paymentStatus):l==="verified"?x(u.paymentStatus):!0),p=u=>{t&&t(u)};return r?e.jsxs("div",{className:"flex items-center justify-center p-20 text-blue-600",children:[e.jsx(Js,{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 dealer security deposits and first fill payments"})]}),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(Js,{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(oa,{className:"w-4 h-4 mr-2 text-blue-600"}),"Pending Payments (",f.filter(u=>!x(u.paymentStatus)).length,")"]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(se,{variant:l==="pending"?"secondary":"ghost",size:"sm",onClick:()=>c("pending"),className:l==="pending"?"bg-slate-200 text-slate-900":"text-slate-500","data-testid":"onboarding-finance-queue-filter-pending",children:"Pending"}),e.jsx(se,{variant:l==="verified"?"secondary":"ghost",size:"sm",onClick:()=>c("verified"),className:l==="verified"?"bg-slate-200 text-slate-900":"text-slate-500","data-testid":"onboarding-finance-queue-filter-verified",children:"Verified"}),e.jsx(se,{variant:l==="all"?"secondary":"ghost",size:"sm",onClick:()=>c("all"),className:l==="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(Me,{className:"p-0",children:e.jsxs(ks,{children:[e.jsx(Rs,{className:"bg-slate-50/50",children:e.jsxs(ct,{className:"border-b border-slate-100 uppercase text-[10px] tracking-wider font-bold text-slate-400",children:[e.jsx(me,{className:"py-4 pl-6","data-testid":"onboarding-finance-queue-th-details",children:"Application Details"}),e.jsx(me,{"data-testid":"onboarding-finance-queue-th-location",children:"Location"}),e.jsx(me,{"data-testid":"onboarding-finance-queue-th-stage",children:"Payment Stage"}),e.jsx(me,{"data-testid":"onboarding-finance-queue-th-status",children:"Current Status"}),e.jsx(me,{className:"text-right pr-6","data-testid":"onboarding-finance-queue-th-action",children:"Workflow Action"})]})}),e.jsx(Es,{children:m.length>0?m.map((u,j)=>{const g=u.paymentStatus||"Awaiting Payment",y=u.application||{};return e.jsxs(ct,{className:"hover:bg-blue-50/20 group transition-all","data-testid":`onboarding-finance-queue-row-${j}`,children:[e.jsx(de,{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-${j}`,children:y.applicationId||y.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-${j}`,children:y.applicantName})})]})}),e.jsx(de,{children:e.jsxs("div",{className:"flex flex-col text-sm","data-testid":`onboarding-finance-queue-location-${j}`,children:[e.jsx("span",{className:"text-slate-600 leading-none",children:y.city}),e.jsx("span",{className:"text-slate-400 text-xs mt-1",children:y.state})]})}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2","data-testid":`onboarding-finance-queue-type-${j}`,children:[e.jsx(mu,{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(de,{children:e.jsx(Ae,{className:g==="Verified"?"bg-emerald-50 text-emerald-700 border-emerald-100 px-3 py-1 rounded-full":g==="Rejected"?"bg-rose-50 text-rose-700 border-rose-100 px-3 py-1 rounded-full":"bg-amber-50 text-amber-700 border-amber-100 px-3 py-1 rounded-full",variant:"outline","data-testid":`onboarding-finance-queue-status-${j}`,children:g})}),e.jsx(de,{className:"text-right pr-6",children:e.jsx(se,{size:"sm",variant:x(g)?"outline":"default",className:x(g)?"bg-white text-slate-600 border-slate-200":"bg-blue-600 hover:bg-blue-700 shadow-md",onClick:()=>p(u.applicationId||y.id),"data-testid":`onboarding-finance-queue-action-btn-${j}`,children:e.jsxs(e.Fragment,{children:[e.jsx(oa,{className:"w-4 h-4 mr-2"}),x(g)?"View Receipt":"Record Payment"]})})})]},u.id)}):e.jsx(ct,{children:e.jsx(de,{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(Ys,{className:"w-6 h-6 text-slate-200"})}),e.jsx("p",{className:"text-sm",children:l==="verified"?"No verified payments found":l==="pending"?"No pending payments in the queue":"No onboarding payments found"})]})})})})]})})})]})}function C$({onViewFnFDetails:t}={}){const[s,n]=v.useState([]),[r,a]=v.useState(!0),[l,c]=v.useState(null),[d,h]=v.useState(!1),[x,f]=v.useState(!1),[m,p]=v.useState(""),[u,j]=v.useState(""),[g,y]=v.useState("all");v.useEffect(()=>{N()},[]);const N=async()=>{try{a(!0);const _=(await Te.getFnFSettlements()).data;_.success&&n(_.settlements||[])}catch(E){console.error("Fetch settlements error:",E),ee.error("Failed to fetch settlement cases")}finally{a(!1)}},S=E=>{var _,M,q,G,Z,W,z,F,B,D,O,V;return{id:E.id,caseId:E.settlementId||((_=E.resignation)==null?void 0:_.resignationId)||((M=E.terminationRequest)==null?void 0:M.requestId)||E.id.substring(0,8),dealerCode:((q=E.outlet)==null?void 0:q.code)||((Z=(G=E.dealer)==null?void 0:G.dealerCode)==null?void 0:Z.dealerCode)||"N/A",dealerName:((z=(W=E.outlet)==null?void 0:W.dealer)==null?void 0:z.fullName)||((F=E.dealer)==null?void 0:F.legalName)||((B=E.dealer)==null?void 0:B.businessName)||((D=E.dealer)==null?void 0:D.fullName)||"N/A",location:((O=E.outlet)==null?void 0:O.city)||((V=E.outlet)==null?void 0:V.location)||"N/A",terminationType:E.resignationId?"Resignation":"Termination",submittedDate:Ht(E.createdAt),status:E.status==="Calculated"?"Pending Finance Review":E.status==="Settled"?"Settled":E.status,financialData:{totalPayables:parseFloat(E.totalPayables)||0,totalReceivables:parseFloat(E.totalReceivables)||0,netAmount:parseFloat(E.netAmount)||0},settlementAmount:Math.abs(parseFloat(E.netAmount)||0),settlementType:parseFloat(E.netAmount)>0?"Payable to Dealer":"Receivable from Dealer",approvedDate:E.settlementDate?Ht(E.settlementDate):null}},C=s.map(S),w=C.filter(E=>g==="all"?!0:g==="pending"?E.status==="Pending Finance Review"||E.status==="Calculated"||E.status==="Initiated"||E.status==="Under Review":g==="approved"?E.status==="Settled"||E.status==="Completed":!0),R=E=>({receivables:E.totalReceivables||0,payables:E.totalPayables||0,deductions:0,netSettlement:E.netAmount||0,settlementType:(E.netAmount||0)>0?"Payable to Dealer":"Receivable from Dealer",settlementAmount:Math.abs(E.netAmount||0)}),P=E=>{t?t(E.id):(c(E),h(!0))},A=E=>{t?t(E.id):(c(E),f(!0))},I=()=>{const E=R(l.financialData);ee.success(`Settlement approved: ${E.settlementType} - ₹${E.settlementAmount.toLocaleString()}`),h(!1),p(""),j(""),c(null)},$=C.filter(E=>E.status==="Pending Finance Review"||E.status==="Calculated"||E.status==="Initiated"||E.status==="Under Review").length,T=C.filter(E=>E.status==="Settled"||E.status==="Completed").length;return r?e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(ss,{className:"w-8 h-8 animate-spin text-amber-600"})}):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(tt,{className:"pb-3",children:e.jsx(nt,{className:"text-sm text-slate-600",children:"Pending Review"})}),e.jsx(Me,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-slate-900 text-2xl",children:$}),e.jsx(O2,{className:"w-8 h-8 text-amber-600"})]})})]}),e.jsxs(Le,{children:[e.jsx(tt,{className:"pb-3",children:e.jsx(nt,{className:"text-sm text-slate-600",children:"Approved Settlements"})}),e.jsx(Me,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-slate-900 text-2xl",children:T}),e.jsx(Ys,{className:"w-8 h-8 text-green-600"})]})})]}),e.jsxs(Le,{children:[e.jsx(tt,{className:"pb-3",children:e.jsx(nt,{className:"text-sm text-slate-600",children:"Total Cases"})}),e.jsx(Me,{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(fs,{className:"w-8 h-8 text-blue-600"})]})})]}),e.jsxs(Le,{children:[e.jsx(tt,{className:"pb-3",children:e.jsx(nt,{className:"text-sm text-slate-600",children:"Net Financial Position"})}),e.jsxs(Me,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:`text-2xl ${C.reduce((E,_)=>E+(_.financialData.netAmount||0),0)<0?"text-green-600":"text-red-600"}`,children:["₹",Math.abs(C.reduce((E,_)=>E+(_.financialData.netAmount||0),0)).toLocaleString("en-IN")]}),e.jsx(Wi,{className:"w-8 h-8 text-purple-600"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:C.reduce((E,_)=>E+(_.financialData.netAmount||0),0)<0?"Net Receivable":"Net Payable"})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(se,{variant:g==="all"?"default":"outline",onClick:()=>y("all"),className:g==="all"?"bg-amber-600 hover:bg-amber-700":"",children:["All Cases (",C.length,")"]}),e.jsxs(se,{variant:g==="pending"?"default":"outline",onClick:()=>y("pending"),className:g==="pending"?"bg-amber-600 hover:bg-amber-700":"",children:["Pending Review (",$,")"]}),e.jsxs(se,{variant:g==="approved"?"default":"outline",onClick:()=>y("approved"),className:g==="approved"?"bg-amber-600 hover:bg-amber-700":"",children:["Approved (",T,")"]})]}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"F&F Settlement Queue"}),e.jsx(Zt,{children:"Review financial status and calculate settlements"})]}),e.jsx(Me,{children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Case ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Location"}),e.jsx(me,{children:"Type"}),e.jsx(me,{children:"Submitted Date"}),e.jsx(me,{children:"Net Settlement"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Es,{children:w.map(E=>{const _=R(E.financialData);return e.jsxs(ct,{children:[e.jsx(de,{children:e.jsxs("div",{children:[e.jsx("div",{className:"text-slate-900",children:E.caseId}),e.jsx("div",{className:"text-sm text-slate-500",children:E.dealerCode})]})}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(kr,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:E.dealerName})]})}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Er,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:E.location})]})}),e.jsx(de,{children:e.jsx(Ae,{variant:E.terminationType==="Resignation"?"default":"secondary",children:E.terminationType})}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($n,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:E.submittedDate})]})}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[_.settlementType==="Payable to Dealer"?e.jsx(Po,{className:"w-4 h-4 text-red-600"}):e.jsx(Wi,{className:"w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-slate-900",children:["₹",_.settlementAmount.toLocaleString()]}),e.jsx("div",{className:"text-xs text-slate-500",children:_.settlementType})]})]})}),e.jsx(de,{children:e.jsx(Ae,{variant:E.status==="Settlement Approved"?"default":"secondary",className:E.status==="Settlement Approved"?"bg-green-600 text-white":"bg-amber-600 text-white",children:E.status})}),e.jsx(de,{children:e.jsxs(se,{size:"sm",variant:E.status==="Pending Finance Review"?"default":"outline",className:E.status==="Pending Finance Review"?"bg-amber-600 hover:bg-amber-700":"",onClick:()=>A(E),children:[e.jsx(fs,{className:"w-4 h-4 mr-2"}),"View Details"]})})]},E.id)})})]})})]}),e.jsx(os,{open:d,onOpenChange:h,children:e.jsxs(ls,{className:"max-w-5xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Financial Settlement Review"}),e.jsxs(vs,{children:["Review financial details and calculate final settlement for ",l==null?void 0:l.dealerName]})]}),l&&e.jsxs(Pn,{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(Gt,{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(tt,{children:[e.jsxs(nt,{className:"text-base flex items-center gap-2",children:[e.jsx(bm,{className:"w-5 h-5 text-green-600"}),"Payables to Dealer"]}),e.jsx(Zt,{children:"Amounts company owes to dealer"})]}),e.jsxs(Me,{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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",(l.financialData.securityDeposit+l.financialData.inventoryValue+l.financialData.equipmentValue).toLocaleString()]})]})})]})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50",children:[e.jsxs(tt,{children:[e.jsxs(nt,{className:"text-base flex items-center gap-2",children:[e.jsx(rv,{className:"w-5 h-5 text-red-600"}),"Receivables from Dealer"]}),e.jsx(Zt,{children:"Amounts dealer owes to company"})]}),e.jsxs(Me,{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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",l.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(l.financialData).receivables.toLocaleString()]})]})})]})]})]}),e.jsxs(Le,{className:"border-amber-200 bg-amber-50",children:[e.jsxs(tt,{children:[e.jsxs(nt,{className:"text-base flex items-center gap-2",children:[e.jsx(Ks,{className:"w-5 h-5 text-amber-600"}),"Deductions"]}),e.jsx(Zt,{children:"Pending claims and deductions"})]}),e.jsx(Me,{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:["₹",l.financialData.warrantyPending.toLocaleString()]})]})})]})]}),e.jsx(Gt,{value:"calculation",className:"space-y-4",children:e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"Settlement Calculation"}),e.jsx(Zt,{children:"Step-by-step calculation of final settlement amount"})]}),e.jsx(Me,{className:"space-y-4",children:(()=>{const E=R(l.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:["+ ₹",E.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:["- ₹",E.receivables.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-amber-50 rounded",children:[e.jsx("span",{className:"text-slate-900",children:"Total Deductions"}),e.jsxs("span",{className:"text-amber-600 text-lg",children:["- ₹",E.deductions.toLocaleString()]})]})]}),e.jsx("div",{className:"h-px bg-slate-300"}),e.jsxs("div",{className:`p-4 rounded-lg ${E.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:["₹",E.settlementAmount.toLocaleString()]})]}),e.jsx("div",{className:"flex items-center gap-2",children:E.settlementType==="Payable to Dealer"?e.jsxs(e.Fragment,{children:[e.jsx(Po,{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(Wi,{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(Ks,{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:["= ₹",E.payables.toLocaleString()," - ₹",E.receivables.toLocaleString()," - ₹",E.deductions.toLocaleString()]})]})]})]})})()})]})}),e.jsxs(Gt,{value:"summary",className:"space-y-4",children:[e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Case Summary"})}),e.jsx(Me,{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:l.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:l.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:l.dealerCode})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Location"}),e.jsx("p",{className:"text-slate-900",children:l.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:l.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:l.submittedDate})]})]})})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Final Settlement"})}),e.jsxs(Me,{className:"space-y-4",children:[(()=>{const E=R(l.financialData);return e.jsxs("div",{className:`p-6 rounded-lg text-center ${E.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:[E.settlementType==="Payable to Dealer"?e.jsx(Po,{className:"w-8 h-8 text-red-600"}):e.jsx(Wi,{className:"w-8 h-8 text-green-600"}),e.jsx("span",{className:`text-lg ${E.settlementType==="Payable to Dealer"?"text-red-700":"text-green-700"}`,children:E.settlementType})]}),e.jsxs("div",{className:"text-4xl text-slate-900 mb-2",children:["₹",E.settlementAmount.toLocaleString()]}),e.jsx("p",{className:"text-slate-600",children:E.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(ce,{htmlFor:"adjustments",children:"Adjustments (if any)"}),e.jsx(ot,{id:"adjustments",value:m,onChange:E=>p(E.target.value),placeholder:"Enter any adjustments to the settlement amount"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"finalNotes",children:"Final Notes"}),e.jsx(Fs,{id:"finalNotes",value:u,onChange:E=>j(E.target.value),placeholder:"Enter any final notes or remarks for this settlement...",rows:4})]})]})]})]})]}),e.jsxs(rn,{children:[e.jsx(se,{variant:"outline",onClick:()=>h(!1),children:"Cancel"}),e.jsxs(se,{className:"bg-green-600 hover:bg-green-700",onClick:I,children:[e.jsx(Ys,{className:"w-4 h-4 mr-2"}),"Approve Settlement"]})]})]})}),e.jsx(os,{open:x,onOpenChange:f,children:e.jsxs(ls,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Settlement Details"}),e.jsxs(vs,{children:["Complete settlement information for ",l==null?void 0:l.dealerName]})]}),l&&e.jsxs(Pn,{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(Gt,{value:"info",className:"space-y-4 mt-4",children:e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{className:"text-base",children:"Case Details"})}),e.jsx(Me,{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:l.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:l.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:l.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Location"}),e.jsx("p",{className:"text-slate-900",children:l.location})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Termination Type"}),e.jsx(Ae,{variant:l.terminationType==="Resignation"?"default":"secondary",children:l.terminationType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Status"}),e.jsx(Ae,{variant:l.status==="Settlement Approved"?"default":"secondary",className:l.status==="Settlement Approved"?"bg-green-600 text-white":"bg-amber-600 text-white",children:l.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:l.submittedDate})]}),l.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:l.approvedDate})]})]})})]})}),e.jsx(Gt,{value:"financial",className:"space-y-4 mt-4",children:(()=>{const E=R(l.financialData);return e.jsxs(e.Fragment,{children:[e.jsxs(Le,{className:"border-green-200 bg-green-50",children:[e.jsx(tt,{children:e.jsxs(nt,{className:"text-base flex items-center gap-2",children:[e.jsx(bm,{className:"w-5 h-5 text-green-600"}),"Payables to Dealer"]})}),e.jsxs(Me,{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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",E.payables.toLocaleString()]})]})})]})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50",children:[e.jsx(tt,{children:e.jsxs(nt,{className:"text-base flex items-center gap-2",children:[e.jsx(rv,{className:"w-5 h-5 text-red-600"}),"Receivables from Dealer"]})}),e.jsxs(Me,{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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",E.receivables.toLocaleString()]})]})})]})]}),e.jsxs(Le,{className:"border-amber-200 bg-amber-50",children:[e.jsx(tt,{children:e.jsxs(nt,{className:"text-base flex items-center gap-2",children:[e.jsx(Ks,{className:"w-5 h-5 text-amber-600"}),"Deductions"]})}),e.jsx(Me,{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:["₹",l.financialData.warrantyPending.toLocaleString()]})]})})]}),e.jsxs(Le,{className:`${E.settlementType==="Payable to Dealer"?"border-red-300 bg-red-100":"border-green-300 bg-green-100"}`,children:[e.jsx(tt,{children:e.jsx(nt,{className:"text-base",children:"Net Settlement"})}),e.jsx(Me,{children:e.jsxs("div",{className:"text-center py-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-2",children:[E.settlementType==="Payable to Dealer"?e.jsx(Po,{className:"w-6 h-6 text-red-600"}):e.jsx(Wi,{className:"w-6 h-6 text-green-600"}),e.jsx("span",{className:`text-lg ${E.settlementType==="Payable to Dealer"?"text-red-700":"text-green-700"}`,children:E.settlementType})]}),e.jsxs("div",{className:"text-3xl text-slate-900",children:["₹",E.settlementAmount.toLocaleString()]})]})})]})]})})()})]}),e.jsxs(rn,{children:[e.jsx(se,{variant:"outline",onClick:()=>f(!1),children:"Close"}),(l==null?void 0:l.status)==="Pending Finance Review"&&e.jsx(se,{className:"bg-amber-600 hover:bg-amber-700",onClick:()=>{f(!1),P(l)},children:"Review & Settle"})]})]})})]})}const Co=(...t)=>t.filter(Boolean).join(" ");function A$({applicationId:t,onBack:s}){var I,$,T,E;const[n,r]=v.useState(null),[a,l]=v.useState([]),[c,d]=v.useState("SECURITY_DEPOSIT"),[h,x]=v.useState(!0),[f,m]=v.useState(!1),[p,u]=v.useState({}),[j,g]=v.useState({verificationTransactionId:"",receivedAmount:"",receivedDate:new Date().toISOString().split("T")[0],verificationRemarks:""}),[y,N]=v.useState(!1),[S,C]=v.useState(null),w=a.find(_=>_.depositType===c);v.useEffect(()=>{R()},[t]),v.useEffect(()=>{var _,M,q;if(w)g({verificationTransactionId:w.paymentReference||"",receivedAmount:((_=w.amount)==null?void 0:_.toString())||"",receivedDate:w.verifiedAt?new Date(w.verifiedAt).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],verificationRemarks:w.remarks||""});else{const G=((M=p.SECURITY_DEPOSIT)==null?void 0:M.amount)||5e5,Z=((q=p.FIRST_FILL)==null?void 0:q.amount)||15e5;g({verificationTransactionId:"",receivedAmount:c==="SECURITY_DEPOSIT"?G.toString():Z.toString(),receivedDate:new Date().toISOString().split("T")[0],verificationRemarks:""})}},[c,w,p]);const R=async()=>{try{x(!0);const[_,M,q]=await Promise.all([ds.getApplicationById(t),ds.getSecurityDeposit(t),ds.getSystemConfigs({category:"SECURITY_DEPOSIT",format:"map"})]);r(_),l(Array.isArray(M)?M:[M].filter(Boolean)),u(q||{})}catch(_){console.error("Fetch error:",_),ee.error("Failed to load payment data")}finally{x(!1)}},P=async()=>{if(!j.verificationTransactionId||!j.receivedDate){ee.error("Please fill in all required payment details");return}try{m(!0),await ds.updateSecurityDeposit({applicationId:t,depositType:c,amount:Number(j.receivedAmount),paymentReference:j.verificationTransactionId,status:"Verified"}),ee.success(`${c==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"} verified and approved`),await R()}catch{ee.error("Failed to verify payment")}finally{m(!1)}},A=async()=>{if(!j.verificationRemarks){ee.error("Please provide remarks for rejection");return}try{m(!0),await ds.updateSecurityDeposit({applicationId:t,depositType:c,status:"Rejected",remarks:j.verificationRemarks}),ee.error(`${c==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"} rejected`),await R()}catch{ee.error("Failed to reject payment")}finally{m(!1)}};return h?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-amber-600"})}):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($r,{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:c==="SECURITY_DEPOSIT"?"default":"outline",className:c==="SECURITY_DEPOSIT"?"bg-amber-600 hover:bg-amber-700":"",onClick:()=>d("SECURITY_DEPOSIT"),children:"Security Deposit"}),e.jsx(se,{size:"sm",variant:c==="FIRST_FILL"?"default":"outline",className:c==="FIRST_FILL"?"bg-amber-600 hover:bg-amber-700":"",onClick:()=>d("FIRST_FILL"),children:"First Fill"})]})]})]}),e.jsx(Le,{className:Co("border",(w==null?void 0:w.status)==="Verified"?"border-green-200 bg-green-50":(w==null?void 0:w.status)==="Rejected"?"border-red-200 bg-red-50":"border-amber-200 bg-amber-50"),children:e.jsx(Me,{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:Co("w-12 h-12 rounded-full flex items-center justify-center",(w==null?void 0:w.status)==="Verified"?"bg-green-100":(w==null?void 0:w.status)==="Rejected"?"bg-red-100":"bg-amber-100"),children:e.jsx(oa,{className:Co("w-6 h-6",(w==null?void 0:w.status)==="Verified"?"text-green-600":(w==null?void 0:w.status)==="Rejected"?"text-red-600":"text-amber-600")})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 font-bold",children:c==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"}),e.jsx("p",{className:"text-sm text-slate-600",children:(w==null?void 0:w.status)==="Verified"?`Verified on ${Ht(w.verifiedAt)}`:(w==null?void 0:w.status)==="Rejected"?"Payment Rejected":"Awaiting Verification"})]})]}),e.jsx(Ae,{className:Co((w==null?void 0:w.status)==="Verified"?"bg-green-600":(w==null?void 0:w.status)==="Rejected"?"bg-red-600":"bg-amber-600 text-white"),children:(w==null?void 0:w.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(tt,{children:e.jsxs(nt,{className:"flex items-center gap-2 text-xl",children:[e.jsx(kr,{className:"w-5 h-5 text-amber-600"}),"Applicant Information"]})}),e.jsxs(Me,{className:"grid grid-cols-2 gap-y-4 gap-x-8",children:[e.jsxs("div",{children:[e.jsx(ce,{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(ce,{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(ce,{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(ce,{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(tt,{children:e.jsxs(nt,{className:"flex items-center gap-2 text-xl",children:[e.jsx(mu,{className:"w-5 h-5 text-amber-600"}),"Deposit Tracking"]})}),e.jsxs(Me,{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(ce,{className:"text-slate-500 block mb-1",children:"Expected Amount"}),e.jsxs("p",{className:"text-2xl font-bold text-amber-900",children:["₹",(c==="SECURITY_DEPOSIT"?((I=p.SECURITY_DEPOSIT)==null?void 0:I.amount)||5e5:(($=p.FIRST_FILL)==null?void 0:$.amount)||15e5).toLocaleString()]})]}),e.jsxs("div",{className:Co("p-4 rounded-lg border",(w==null?void 0:w.status)==="Verified"?"bg-green-50 border-green-200":"bg-blue-50 border-blue-200"),children:[e.jsx(ce,{className:"text-slate-500 block mb-1",children:"Receipt Status"}),e.jsx("p",{className:Co("text-2xl font-bold",(w==null?void 0:w.status)==="Verified"?"text-green-700":"text-blue-700"),children:(w==null?void 0:w.status)||"Not Started"})]})]}),(w==null?void 0:w.paymentReference)&&e.jsxs("div",{className:"grid grid-cols-2 gap-4 pt-2",children:[e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-500",children:"Payment Reference"}),e.jsx("p",{className:"text-slate-900 font-mono",children:w.paymentReference})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-500",children:"Verified By"}),e.jsx("p",{className:"text-slate-900",children:((T=w.verifier)==null?void 0:T.fullName)||"N/A"})]})]})]})]}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsxs(nt,{className:"flex items-center gap-2 text-xl",children:[e.jsx(fs,{className:"w-5 h-5 text-amber-600"}),"Verification Evidence"]}),e.jsx(Zt,{children:"Documents uploaded by the applicant for payment proof"})]}),e.jsx(Me,{children:((E=n.uploadedDocuments)==null?void 0:E.filter(_=>{var M,q,G,Z;return c==="SECURITY_DEPOSIT"?((M=_.documentType)==null?void 0:M.toLowerCase().includes("security"))&&((q=_.documentType)==null?void 0:q.toLowerCase().includes("deposit")):((G=_.documentType)==null?void 0:G.toLowerCase().includes("first"))&&((Z=_.documentType)==null?void 0:Z.toLowerCase().includes("fill"))}).length)>0?e.jsx("div",{className:"space-y-3",children:n.uploadedDocuments.filter(_=>{var M,q,G,Z;return c==="SECURITY_DEPOSIT"?((M=_.documentType)==null?void 0:M.toLowerCase().includes("security"))&&((q=_.documentType)==null?void 0:q.toLowerCase().includes("deposit")):((G=_.documentType)==null?void 0:G.toLowerCase().includes("first"))&&((Z=_.documentType)==null?void 0:Z.toLowerCase().includes("fill"))}).map((_,M)=>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(fs,{className:"w-5 h-5 text-slate-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 font-medium",children:_.fileName||_.name}),e.jsxs("p",{className:"text-xs text-slate-500 uppercase",children:[_.documentType," • ",Ht(_.createdAt)]})]})]}),e.jsx(se,{variant:"ghost",size:"sm",className:"text-amber-600 hover:text-amber-700 hover:bg-amber-50",onClick:()=>{C(_),N(!0)},children:"View Receipt"})]},M))}):e.jsxs("div",{className:"text-center py-10 bg-slate-50 rounded-lg border-2 border-dashed border-slate-200",children:[e.jsx(Ks,{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-amber-100 shadow-sm",children:[e.jsx(tt,{className:"bg-amber-50/50",children:e.jsxs(nt,{className:"flex items-center gap-2 text-lg",children:[e.jsx(bm,{className:"w-5 h-5 text-amber-600"}),"Finance Action"]})}),e.jsxs(Me,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsxs(ce,{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(ot,{id:"verificationTxnId",placeholder:"Enter Bank UTR Number",disabled:(w==null?void 0:w.status)==="Verified",className:"mt-1",value:j.verificationTransactionId,onChange:_=>g({...j,verificationTransactionId:_.target.value})})]}),e.jsxs("div",{children:[e.jsxs(ce,{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(ot,{id:"receivedAmount",type:"number",placeholder:(c==="SECURITY_DEPOSIT"?5e5:15e5).toString(),disabled:(w==null?void 0:w.status)==="Verified",className:"mt-1",value:j.receivedAmount,onChange:_=>g({...j,receivedAmount:_.target.value})})]}),e.jsxs("div",{children:[e.jsxs(ce,{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(ot,{id:"receivedDate",type:"date",disabled:(w==null?void 0:w.status)==="Verified",className:"mt-1",value:j.receivedDate,onChange:_=>g({...j,receivedDate:_.target.value})})]}),e.jsxs("div",{children:[e.jsx(ce,{htmlFor:"remarks",className:"text-xs uppercase text-slate-500 font-bold tracking-wider",children:"Verification Remarks"}),e.jsx(Fs,{id:"remarks",placeholder:"Any internal notes for reconciliation...",rows:3,className:"mt-1",value:j.verificationRemarks,onChange:_=>g({...j,verificationRemarks:_.target.value})})]}),e.jsxs("div",{className:"pt-4 space-y-3",children:[e.jsx(se,{className:Co("w-full transition-all duration-200",(w==null?void 0:w.status)==="Verified"?"bg-green-600 hover:bg-green-600 opacity-90":"bg-amber-600 hover:bg-amber-700"),onClick:P,disabled:f||(w==null?void 0:w.status)==="Verified",children:(w==null?void 0:w.status)==="Verified"?e.jsxs(e.Fragment,{children:[e.jsx(Ys,{className:"w-4 h-4 mr-2"})," Verified Successfully"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ys,{className:"w-4 h-4 mr-2"})," Mark as Verified"]})}),(w==null?void 0:w.status)!=="Verified"&&(w==null?void 0:w.status)!=="Rejected"&&e.jsxs(se,{variant:"ghost",className:"w-full text-red-600 hover:text-red-700 hover:bg-red-50",onClick:A,disabled:f,children:[e.jsx(Za,{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(tt,{children:e.jsxs(nt,{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(Js,{className:"w-4 h-4 text-amber-400"}),"Next Steps"]})}),e.jsxs(Me,{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 ",c==="SECURITY_DEPOSIT"?"LOI Issuance":"LOA Approval"]}),e.jsx("li",{children:"Email notification will be sent to Applicant"}),e.jsxs("li",{children:["Digital ",c==="SECURITY_DEPOSIT"?"LOI":"LOA"," generation will be unlocked"]}),e.jsxs("li",{children:["This payment confirms the ",c==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"]})]})]})]})]})]}),e.jsx(Kl,{isOpen:y,onClose:()=>N(!1),document:S})]}):e.jsx("div",{className:"p-20 text-center",children:"Application not found"})}const zi=["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"],m1="[DEPARTMENT_CLAIM]",f1="[FINANCE_VALIDATED]",Qx=[{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 k$({fnfId:t,onBack:s}){const[n,r]=v.useState(null),[a,l]=v.useState(!0),[c,d]=v.useState("overview"),[h,x]=v.useState([]),[f,m]=v.useState([]),[p,u]=v.useState([]),[j,g]=v.useState(null),[y,N]=v.useState([]),[S,C]=v.useState(!1),[w,R]=v.useState(null),[P,A]=v.useState([]);v.useEffect(()=>{I(),q()},[t]);const I=async()=>{var ie;try{const Q=(await Te.getSettlementDepartments()).data;Q&&Q.success&&((ie=Q.departments)==null?void 0:ie.length)>0}catch(Fe){console.error("Fetch departments error:",Fe)}},$=ie=>{if(!ie)return ie;let Fe=ie.trim();const Q=zi.find(Ee=>Ee.toLowerCase()===Fe.toLowerCase());if(Q)return Q;const Ne={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"}[Fe.toLowerCase().replace(" department","")];return Ne||ie},T=(ie,Fe)=>Fe==="DepartmentClaim"||typeof ie=="string"&&(ie.startsWith(m1)||ie.includes("Clearance:")),E=ie=>(ie==null?void 0:ie.sourceType)==="FinanceValidated"&&typeof(ie==null?void 0:ie.description)=="string"&&ie.description.includes("Auto-seeded from department claim"),_=(ie,Fe)=>Fe==="FinanceValidated"||typeof ie=="string"&&ie.startsWith(f1),M=ie=>(ie||"").replace(m1,"").replace(f1,"").trim(),q=async(ie=!0)=>{var Fe,Q,pe,Ne,Ee,it,st,bt,Ue,Lt,ut,yt,kt,Ie,_t,ht,zt,rs,Yt,Os,Is,zs,en,he,Ge,at,pt,mt,Bt,Ds,as,Vs,Ls,Ts,ln,pn,hn,Ws,Qs,zn,on,Un,yr,Tr,er,tr,En;try{ie&&l(!0);const $t=(await Te.getFnFSettlementById(t)).data;if($t.success){const Ze=$t.fnf,Ut={id:Ze.id,caseNumber:Ze.settlementId||((Fe=Ze.resignation)==null?void 0:Fe.resignationId)||((Q=Ze.terminationRequest)==null?void 0:Q.requestId)||Ze.id.substring(0,8),dealerName:((Ne=(pe=Ze.outlet)==null?void 0:pe.dealer)==null?void 0:Ne.fullName)||((Ee=Ze.dealer)==null?void 0:Ee.fullName)||"N/A",dealerCode:((it=Ze.outlet)==null?void 0:it.code)||((bt=(st=Ze.dealer)==null?void 0:st.dealerCode)==null?void 0:bt.dealerCode)||"N/A",location:((Ue=Ze.outlet)==null?void 0:Ue.city)||((Lt=Ze.outlet)==null?void 0:Lt.location)||"N/A",terminationType:Ze.resignationId?"Resignation":"Termination",submittedDate:aa(Ze.createdAt),createdAt:Ze.createdAt,dueDate:Ze.settlementDate?aa(Ze.settlementDate):"TBD",status:Ze.status,dealerId:((yt=(ut=Ze.outlet)==null?void 0:ut.dealer)==null?void 0:yt.id)||Ze.dealerId,originalRequestId:((kt=Ze.resignation)==null?void 0:kt.resignationId)||((Ie=Ze.terminationRequest)==null?void 0:Ie.requestId)||((_t=Ze.terminationRequest)==null?void 0:_t.id)||"N/A",salesCode:((zt=(ht=Ze.dealer)==null?void 0:ht.dealerCode)==null?void 0:zt.salesCode)||((Is=(Os=(Yt=(rs=Ze.outlet)==null?void 0:rs.dealer)==null?void 0:Yt.dealerProfile)==null?void 0:Os.dealerCode)==null?void 0:Is.salesCode)||"N/A",serviceCode:((en=(zs=Ze.dealer)==null?void 0:zs.dealerCode)==null?void 0:en.serviceCode)||((pt=(at=(Ge=(he=Ze.outlet)==null?void 0:he.dealer)==null?void 0:Ge.dealerProfile)==null?void 0:at.dealerCode)==null?void 0:pt.serviceCode)||"N/A",gearCode:((Bt=(mt=Ze.dealer)==null?void 0:mt.dealerCode)==null?void 0:Bt.gearCode)||((Ls=(Vs=(as=(Ds=Ze.outlet)==null?void 0:Ds.dealer)==null?void 0:as.dealerProfile)==null?void 0:Vs.dealerCode)==null?void 0:Ls.gearCode)||"N/A",gmaCode:((ln=(Ts=Ze.dealer)==null?void 0:Ts.dealerCode)==null?void 0:ln.gmaCode)||((Qs=(Ws=(hn=(pn=Ze.outlet)==null?void 0:pn.dealer)==null?void 0:hn.dealerProfile)==null?void 0:Ws.dealerCode)==null?void 0:Qs.gmaCode)||"N/A",allLineItems:(Ze.lineItems||[]).filter(Tt=>Tt.isActive!==!1),departmentResponses:zi.map(Tt=>{const xs=(Ze.clearances||[]).find(wn=>$(wn.department)===Tt),Vr=(Ze.lineItems||[]).filter(wn=>wn.isActive!==!1),ta=Vr.filter(wn=>$(wn.department)===Tt&&T(wn.description,wn.sourceType)),ma=Vr.filter(wn=>$(wn.department)===Tt&&E(wn)),_r=ta.length>0?ta:ma;let sr=0,gn=0;_r.forEach(wn=>{const Da=Math.abs(parseFloat(wn.amount)||0);wn.itemType==="Payable"?sr+=Da:gn+=Da});const mn=sr-gn,Qn=Math.abs(mn)>0,fr=(xs==null?void 0:xs.status)||"Pending",pr=Qn?"Dues Pending":fr==="Cleared"?"NOC Submitted":fr,dn=mn>0?"payable":mn<0?"recovery":null;return{id:(xs==null?void 0:xs.id)||`dept-${Tt}`,departmentName:Tt,status:pr,remarks:(xs==null?void 0:xs.remarks)||"-",submittedDate:xs!=null&&xs.clearedAt?aa(xs.clearedAt):"-",amount:Math.abs(mn),duesFlow:dn,amountType:mn>0?"Payable to dealer":mn<0?"Receivable from dealer":null,supportingDocument:(xs==null?void 0:xs.supportingDocument)||null}}),documents:[{name:"Resignation Letter.pdf",size:"N/A",uploadedOn:aa(Ze.createdAt),type:"Resignation",url:"#"},...(Ze.clearances||[]).filter(Tt=>Tt.supportingDocument).map(Tt=>({name:Tt.supportingDocument.split("/").pop(),size:"N/A",uploadedOn:aa(Tt.clearedAt),type:`${Tt.department} Proof`,url:Tt.supportingDocument})),...(Ze.clearanceDocuments||[]).map(Tt=>{var xs;return{name:Tt.name||((xs=Tt.supportingDocument)==null?void 0:xs.split("/").pop())||"Document",size:"N/A",uploadedOn:aa(Tt.clearedAt||Ze.createdAt),type:"Finance Upload",url:Tt.supportingDocument}})]};r(Ut);const jt=Ze.bankDetails||((zn=Ze.dealer)==null?void 0:zn.bankDetails)||((yr=(Un=(on=Ze.outlet)==null?void 0:on.dealer)==null?void 0:Un.dealerProfile)==null?void 0:yr.bankDetails);jt&&jt.length>0?N(jt):((er=(Tr=Ze.outlet)==null?void 0:Tr.dealer)!=null&&er.id||Ze.dealerId)&&G(((En=(tr=Ze.outlet)==null?void 0:tr.dealer)==null?void 0:En.id)||Ze.dealerId);const In=[],jr=[],Pr=[],xn=(Ze.lineItems||[]).filter(Tt=>Tt.isActive!==!1);(xn.some(Tt=>_(Tt.description,Tt.sourceType))?xn.filter(Tt=>_(Tt.description,Tt.sourceType)):xn.filter(Tt=>!T(Tt.description,Tt.sourceType))).forEach(Tt=>{const xs={id:Tt.id,department:$(Tt.department),description:M(Tt.description||Tt.remarks||""),amount:Math.abs(Tt.amount)};Tt.itemType==="Payable"?In.push(xs):Tt.itemType==="Deduction"?Pr.push(xs):jr.push(xs)}),x(In),m(jr),u(Pr),qe({verificationTransactionId:Ze.transactionReference||"",settlementAmount:(Ze.settlementAmount||Ye().settlementAmount).toString(),settlementDate:Ze.settlementDate?new Date(Ze.settlementDate).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],paymentMode:Ze.paymentMode||"",bankReference:"",verificationRemarks:Ze.remarks||"",adjustments:"0"})}}catch(Xe){console.error("Fetch F&F error:",Xe),ee.error("Failed to fetch settlement details")}finally{ie&&l(!1)}},G=async ie=>{try{const Q=(await Te.getDealerBankDetails(ie)).data;Q.success&&N(Q.bankDetails||[])}catch(Fe){console.error("Fetch bank details error:",Fe)}},Z=async ie=>{ie.preventDefault();const Fe=new FormData(ie.currentTarget),Q=Object.fromEntries(Fe.entries());try{const pe=n==null?void 0:n.dealerId;(await Te.saveBankDetail(pe,{...Q,id:w==null?void 0:w.id,isPrimary:Fe.get("isPrimary")==="on"})).data.success&&(ee.success("Bank details saved"),G(pe),C(!1),R(null))}catch{ee.error("Failed to save bank details")}},W=async ie=>{if(confirm("Are you sure you want to delete this bank account?"))try{(await Te.deleteBankDetail(ie)).data.success&&(ee.success("Bank detail deleted"),G(n==null?void 0:n.dealerId))}catch{ee.error("Failed to delete bank details")}},z=ie=>{A(Fe=>Fe.includes(ie)?Fe.filter(Q=>Q!==ie):[...Fe,ie])},[F,B]=v.useState({department:"",description:"",amount:""}),[D,O]=v.useState({department:"",description:"",amount:""}),[V,K]=v.useState({department:"",description:"",amount:""}),[Y,U]=v.useState(null),[X,ne]=v.useState(null),[oe,re]=v.useState(null),[ge,ve]=v.useState({}),[Se,We]=v.useState({}),[Ce,fe]=v.useState({}),Ye=()=>{const ie=h.reduce((Ne,Ee)=>Ne+(Number(Ee.amount)||0),0),Fe=f.reduce((Ne,Ee)=>Ne+(Number(Ee.amount)||0),0),Q=p.reduce((Ne,Ee)=>Ne+(Number(Ee.amount)||0),0),pe=ie-Fe-Q;return{payables:ie,receivables:Fe,deductions:Q,netSettlement:pe,settlementAmount:Math.abs(pe),settlementType:pe>0?"Payable to Dealer":pe<0?"Receivable from Dealer":"No Settlement Required"}},be=Ye(),_e=zi.map(ie=>{const Fe=((n==null?void 0:n.departmentResponses)||[]).find(ut=>ut.departmentName===ie),Q=Number(Fe==null?void 0:Fe.amount)||0,pe=(Fe==null?void 0:Fe.amountType)||"-",Ne=h.filter(ut=>$(ut.department)===ie).reduce((ut,yt)=>ut+(Number(yt.amount)||0),0),Ee=f.filter(ut=>$(ut.department)===ie).reduce((ut,yt)=>ut+(Number(yt.amount)||0),0),it=p.filter(ut=>$(ut.department)===ie).reduce((ut,yt)=>ut+(Number(yt.amount)||0),0),st=Ne-Ee-it,bt=Math.abs(st),Ue=st>0?"Payable":st<0?"Receivable":"-",Lt=bt-Q;return{department:ie,claimAmount:Q,claimType:pe,validatedAmount:bt,validatedType:Ue,variance:Lt}}),[ke,qe]=v.useState({verificationTransactionId:"",settlementAmount:be.settlementAmount.toString(),settlementDate:new Date().toISOString().split("T")[0],paymentMode:"",bankReference:"",verificationRemarks:"",adjustments:"0"}),Ve=async()=>{var ie,Fe;if(!F.department||!F.description||!F.amount){ee.error("Please fill in all fields");return}try{const pe=(await Te.addLineItem(t,{department:F.department,description:F.description,amount:Math.abs(parseFloat(F.amount)),itemType:"Payable"})).data;pe.success&&(x([...h,{id:pe.lineItem.id,department:pe.lineItem.department,description:pe.lineItem.description,amount:Math.abs(pe.lineItem.amount)}]),B({department:"",description:"",amount:""}),ee.success("Payable item added"),q())}catch(Q){ee.error(((Fe=(ie=Q.response)==null?void 0:ie.data)==null?void 0:Fe.message)||"Failed to add payable item")}},dt=async(ie,Fe,Q)=>{ve(pe=>{const Ne=pe[ie]||h.find(Ee=>Ee.id===ie);return Ne?{...pe,[ie]:{...Ne,[Fe]:Fe==="amount"?Number(Q)||0:Q}}:pe})},xt=async ie=>{var Q,pe;const Fe=ge[ie];if(!Fe){U(null);return}x(Ne=>Ne.map(Ee=>Ee.id===ie?Fe:Ee));try{await Te.updateLineItem(ie,{department:Fe.department,description:Fe.description,amount:-Math.abs(Number(Fe.amount)||0)}),U(null),ve(Ne=>{const Ee={...Ne};return delete Ee[ie],Ee}),ee.success("Changes saved"),q(!1)}catch(Ne){ee.error(((pe=(Q=Ne.response)==null?void 0:Q.data)==null?void 0:pe.message)||"Failed to update item"),q(!1)}},ye=async ie=>{var Fe,Q;try{(await Te.deleteLineItem(ie)).data.success&&(x(h.filter(Ee=>Ee.id!==ie)),ee.info("Payable item removed"),q())}catch(pe){ee.error(((Q=(Fe=pe.response)==null?void 0:Fe.data)==null?void 0:Q.message)||"Failed to delete item")}},le=async()=>{var ie,Fe;if(!D.department||!D.description||!D.amount){ee.error("Please fill in all fields");return}try{const pe=(await Te.addLineItem(t,{department:D.department,description:D.description,amount:Math.abs(parseFloat(D.amount)),itemType:"Receivable"})).data;pe.success&&(m([...f,{id:pe.lineItem.id,department:pe.lineItem.department,description:pe.lineItem.description,amount:pe.lineItem.amount}]),O({department:"",description:"",amount:""}),ee.success("Receivable item added"),q())}catch(Q){ee.error(((Fe=(ie=Q.response)==null?void 0:ie.data)==null?void 0:Fe.message)||"Failed to add receivable item")}},Qe=async(ie,Fe,Q)=>{We(pe=>{const Ne=pe[ie]||f.find(Ee=>Ee.id===ie);return Ne?{...pe,[ie]:{...Ne,[Fe]:Fe==="amount"?Number(Q)||0:Q}}:pe})},rt=async ie=>{var Q,pe;const Fe=Se[ie];if(!Fe){ne(null);return}m(Ne=>Ne.map(Ee=>Ee.id===ie?Fe:Ee));try{await Te.updateLineItem(ie,{department:Fe.department,description:Fe.description,amount:Math.abs(Number(Fe.amount)||0)}),ne(null),We(Ne=>{const Ee={...Ne};return delete Ee[ie],Ee}),ee.success("Changes saved"),q(!1)}catch(Ne){ee.error(((pe=(Q=Ne.response)==null?void 0:Q.data)==null?void 0:pe.message)||"Failed to update item"),q(!1)}},Kt=async ie=>{var Fe,Q;try{await Te.deleteLineItem(ie),m(f.filter(pe=>pe.id!==ie)),ee.info("Receivable item removed"),q()}catch(pe){ee.error(((Q=(Fe=pe.response)==null?void 0:Fe.data)==null?void 0:Q.message)||"Failed to delete item")}},Rt=async()=>{var ie,Fe;if(!V.department||!V.description||!V.amount){ee.error("Please fill in all fields");return}try{const pe=(await Te.addLineItem(t,{department:V.department,description:V.description,amount:Math.abs(parseFloat(V.amount)),itemType:"Deduction"})).data;pe.success&&(u([...p,{id:pe.lineItem.id,department:pe.lineItem.department,description:pe.lineItem.description,amount:pe.lineItem.amount}]),K({department:"",description:"",amount:""}),ee.success("Deduction item added"),q())}catch(Q){ee.error(((Fe=(ie=Q.response)==null?void 0:ie.data)==null?void 0:Fe.message)||"Failed to add deduction item")}},Re=async(ie,Fe,Q)=>{fe(pe=>{const Ne=pe[ie]||p.find(Ee=>Ee.id===ie);return Ne?{...pe,[ie]:{...Ne,[Fe]:Fe==="amount"?Number(Q)||0:Q}}:pe})},Qt=async ie=>{var Q,pe;const Fe=Ce[ie];if(!Fe){re(null);return}u(Ne=>Ne.map(Ee=>Ee.id===ie?Fe:Ee));try{await Te.updateLineItem(ie,{department:Fe.department,description:Fe.description,amount:Math.abs(Number(Fe.amount)||0)}),re(null),fe(Ne=>{const Ee={...Ne};return delete Ee[ie],Ee}),ee.success("Changes saved"),q(!1)}catch(Ne){ee.error(((pe=(Q=Ne.response)==null?void 0:Q.data)==null?void 0:pe.message)||"Failed to update item"),q(!1)}},qt=async ie=>{try{await Te.deleteLineItem(ie),u(p.filter(Fe=>Fe.id!==ie)),ee.info("Deduction item removed"),q()}catch{ee.error("Failed to delete item")}},ws=async ie=>{var Q;const Fe=ie.target.files;if(Fe&&Fe.length>0){l(!0);try{let pe=0;for(let Ne=0;Ne<Fe.length;Ne++){const Ee=new FormData;Ee.append("file",Fe[Ne]),(Q=(await Te.uploadFnFDocument(t,Ee)).data)!=null&&Q.success&&pe++}ee.success(`${pe} document(s) uploaded successfully`),q(!1)}catch{ee.error("Failed to upload document(s)")}finally{l(!1)}}},[_s,ns]=v.useState(!1),Cs=async()=>{if(!ke.verificationTransactionId||!ke.settlementDate||!ke.paymentMode){ee.error("Please fill in all required settlement details");return}try{ns(!0);const ie=(be.settlementAmount||0)+parseFloat(ke.adjustments||"0");await QR.updateFnF(t,{status:"Completed",finalSettlementAmount:ie,settlementDate:ke.settlementDate,paymentMode:ke.paymentMode,transactionReference:ke.verificationTransactionId,remarks:ke.verificationRemarks||"Approved by Finance"}),ee.success(`F&F Settlement approved and completed for ${n.dealerName}`),setTimeout(()=>s(),1500)}catch(ie){console.error("Approve settlement error:",ie),ee.error(ie.message||"Failed to approve settlement")}finally{ns(!1)}},Bs=()=>{if(!ke.verificationRemarks){ee.error("Please provide remarks for rejection");return}ee.error(`F&F Settlement rejected for ${n.dealerName}`),setTimeout(()=>s(),1500)},Ft=()=>{if(!ke.verificationRemarks){ee.error("Please provide details for clarification request");return}ee.info(`Clarification request sent for ${n.dealerName}`),setTimeout(()=>s(),1500)};return a?e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(ss,{className:"w-8 h-8 animate-spin text-amber-600"})}):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($r,{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 ",n.dealerName]})]})]}),e.jsx(Le,{className:"border-amber-200 bg-amber-50",children:e.jsx(Me,{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-amber-100 flex items-center justify-center",children:e.jsx(oa,{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: ",n.caseNumber," • Due: ",n.dueDate]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ae,{className:"bg-amber-600",children:n.status}),e.jsx(Ae,{variant:n.terminationType==="Resignation"?"default":"secondary",children:n.terminationType})]})]})})}),e.jsx(Le,{className:`${be.settlementType==="Payable to Dealer"?"border-red-300 bg-red-50":be.settlementType==="Receivable from Dealer"?"border-green-300 bg-green-50":"border-slate-300 bg-slate-50"}`,children:e.jsx(Me,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[be.settlementType==="Payable to Dealer"?e.jsx(Po,{className:"w-12 h-12 text-red-600"}):be.settlementType==="Receivable from Dealer"?e.jsx(Wi,{className:"w-12 h-12 text-green-600"}):e.jsx(Ys,{className:"w-12 h-12 text-slate-600"}),e.jsxs("div",{children:[e.jsx("p",{className:`text-sm ${be.settlementType==="Payable to Dealer"?"text-red-700":be.settlementType==="Receivable from Dealer"?"text-green-700":"text-slate-700"}`,children:be.settlementType}),e.jsx("p",{className:"text-3xl text-slate-900",children:be.settlementType==="No Settlement Required"?"₹0":`₹${be.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:be.settlementType==="Payable to Dealer"?"Company will pay to dealer":be.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(Pn,{value:c,onValueChange:d,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(Gt,{value:"overview",className:"space-y-4",children:[e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsxs(nt,{className:"flex items-center gap-2",children:[e.jsx(kr,{className:"w-5 h-5"}),"Case Information"]})}),e.jsx(Me,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-500",children:"Case Number"}),e.jsx("p",{className:"text-slate-900",children:n.caseNumber})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-500",children:"Dealer Code"}),e.jsx("p",{className:"text-slate-900",children:n.dealerCode})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-500",children:"Dealer Name"}),e.jsx("p",{className:"text-slate-900",children:n.dealerName})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-500",children:"Location"}),e.jsx("p",{className:"text-slate-900",children:n.location})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-500",children:"Termination Type"}),e.jsx(Ae,{variant:n.terminationType==="Resignation"?"default":"secondary",children:n.terminationType})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-500",children:"Status"}),e.jsx(Ae,{className:"bg-amber-600",children:n.status})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-500",children:"Submitted Date"}),e.jsx("p",{className:"text-slate-900",children:n.submittedDate})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-500",children:"Due Date"}),e.jsx("p",{className:"text-slate-900",children:n.dueDate})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-500",children:"Request Age"}),e.jsx("p",{className:"text-slate-900",children:(()=>{const ie=new Date(n.createdAt),Q=Math.abs(new Date().getTime()-ie.getTime()),pe=Math.ceil(Q/(1e3*60*60*24));return`${pe} day${pe!==1?"s":""}`})()})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-500",children:"Sales Code"}),e.jsx("p",{className:"text-slate-900",children:n.salesCode})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-500",children:"Service Code"}),e.jsx("p",{className:"text-slate-900",children:n.serviceCode})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-500",children:"Gear Code"}),e.jsx("p",{className:"text-slate-900",children:n.gearCode})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-slate-500",children:"GMA Code"}),e.jsx("p",{className:"text-slate-900",children:n.gmaCode})]})]})})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsxs(nt,{className:"flex items-center gap-2",children:[e.jsx(oa,{className:"w-5 h-5"}),"Settlement Calculation Summary"]})}),e.jsxs(Me,{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:["+ ₹",be.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:["- ₹",be.receivables.toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-amber-50 rounded-lg",children:[e.jsx("span",{className:"text-slate-900",children:"Total Deductions"}),e.jsxs("span",{className:"text-amber-700 text-lg",children:["- ₹",be.deductions.toLocaleString("en-IN")]})]})]}),e.jsx("div",{className:"h-px bg-slate-300"}),e.jsx("div",{className:`p-4 rounded-lg border-2 ${be.settlementType==="Payable to Dealer"?"bg-red-100 border-red-300":be.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 ${be.settlementType==="Payable to Dealer"?"text-red-700":be.settlementType==="Receivable from Dealer"?"text-green-700":"text-slate-700"}`,children:be.settlementType})]}),e.jsx("span",{className:"text-2xl text-slate-900",children:be.settlementType==="No Settlement Required"?"₹0":`₹${be.settlementAmount.toLocaleString("en-IN")}`})]})}),e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-blue-50 border border-amber-200 rounded-lg",children:[e.jsx(Ks,{className:"w-5 h-5 text-amber-600 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(Gt,{value:"financial",className:"space-y-4",children:[e.jsxs(Le,{className:"border-blue-200 bg-blue-50",children:[e.jsxs(tt,{children:[e.jsx(nt,{className:"text-base",children:"Department Claim vs Finance Validation"}),e.jsx(Zt,{children:"Finance validated values are used for final settlement totals."})]}),e.jsx(Me,{children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Department"}),e.jsx(me,{children:"Department Claim"}),e.jsx(me,{children:"Finance Validated"}),e.jsx(me,{children:"Variance"})]})}),e.jsx(Es,{children:_e.map(ie=>e.jsxs(ct,{children:[e.jsx(de,{children:ie.department}),e.jsx(de,{children:ie.claimAmount>0?`${ie.claimType} ₹${ie.claimAmount.toLocaleString("en-IN")}`:"-"}),e.jsx(de,{children:ie.validatedAmount>0?`${ie.validatedType} ₹${ie.validatedAmount.toLocaleString("en-IN")}`:"-"}),e.jsx(de,{className:ie.variance===0?"text-slate-600":ie.variance>0?"text-red-600":"text-green-600",children:ie.claimAmount===0&&ie.validatedAmount===0?"-":`₹${ie.variance.toLocaleString("en-IN")}`})]},ie.department))})]})})]}),e.jsxs(Le,{className:"border-green-200 bg-green-50",children:[e.jsx(tt,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs(nt,{className:"text-base flex items-center gap-2",children:[e.jsx(bm,{className:"w-5 h-5 text-green-600"}),"Payables to Dealer (Editable)"]}),e.jsx(Zt,{children:"Add or modify amounts company owes to dealer"})]})})}),e.jsxs(Me,{className:"space-y-4",children:[e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Department"}),e.jsx(me,{children:"Description"}),e.jsx(me,{className:"text-right",children:"Amount (₹)"}),e.jsx(me,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Es,{children:h.map(ie=>{var Fe,Q,pe;return e.jsxs(ct,{children:[e.jsx(de,{children:Y===ie.id?e.jsxs(wt,{value:((Fe=ge[ie.id])==null?void 0:Fe.department)||ie.department,onValueChange:Ne=>dt(ie.id,"department",Ne),children:[e.jsx(Ct,{className:"h-8",children:e.jsx(St,{placeholder:"Department"})}),e.jsx(At,{children:zi.map(Ne=>e.jsx(Pe,{value:Ne,children:Ne},Ne))})]}):e.jsx("span",{className:"text-slate-900",children:$(ie.department)})}),e.jsx(de,{children:Y===ie.id?e.jsx(ot,{value:((Q=ge[ie.id])==null?void 0:Q.description)||ie.description,onChange:Ne=>dt(ie.id,"description",Ne.target.value),className:"h-8"}):e.jsx("span",{className:"text-slate-600",children:ie.description})}),e.jsx(de,{className:"text-right",children:Y===ie.id?e.jsx(ot,{type:"number",value:((pe=ge[ie.id])==null?void 0:pe.amount)??ie.amount,onChange:Ne=>dt(ie.id,"amount",Ne.target.value),className:"h-8 text-right"}):e.jsxs("span",{className:"text-slate-900",children:["₹",ie.amount.toLocaleString("en-IN")]})}),e.jsx(de,{children:e.jsxs("div",{className:"flex gap-1",children:[Y===ie.id?e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>xt(ie.id),children:e.jsx(Yi,{className:"w-4 h-4"})}):e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>{U(ie.id),ve(Ne=>({...Ne,[ie.id]:{...ie}}))},children:e.jsx(ur,{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:()=>ye(ie.id),children:e.jsx(Gn,{className:"w-4 h-4"})})]})})]},ie.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(wt,{value:F.department,onValueChange:ie=>B({...F,department:ie}),children:[e.jsx(Ct,{className:"col-span-3",children:e.jsx(St,{placeholder:"Department"})}),e.jsx(At,{children:zi.map(ie=>e.jsx(Pe,{value:ie,children:ie},ie))})]}),e.jsx(ot,{placeholder:"Description",value:F.description,onChange:ie=>B({...F,description:ie.target.value}),className:"col-span-5"}),e.jsx(ot,{type:"number",placeholder:"Amount",value:F.amount,onChange:ie=>B({...F,amount:ie.target.value}),className:"col-span-3"}),e.jsx(se,{onClick:Ve,className:"col-span-1 bg-green-600 hover:bg-green-700",children:e.jsx(cn,{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:["₹",be.payables.toLocaleString("en-IN")]})]})})]})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50",children:[e.jsx(tt,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs(nt,{className:"text-base flex items-center gap-2",children:[e.jsx(rv,{className:"w-5 h-5 text-red-600"}),"Receivables from Dealer (Editable)"]}),e.jsx(Zt,{children:"Add or modify amounts dealer owes to company"})]})})}),e.jsxs(Me,{className:"space-y-4",children:[e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Department"}),e.jsx(me,{children:"Description"}),e.jsx(me,{className:"text-right",children:"Amount (₹)"}),e.jsx(me,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Es,{children:f.map(ie=>{var Fe,Q,pe;return e.jsxs(ct,{children:[e.jsx(de,{children:X===ie.id?e.jsxs(wt,{value:((Fe=Se[ie.id])==null?void 0:Fe.department)||ie.department,onValueChange:Ne=>Qe(ie.id,"department",Ne),children:[e.jsx(Ct,{className:"h-8",children:e.jsx(St,{placeholder:"Department"})}),e.jsx(At,{children:zi.map(Ne=>e.jsx(Pe,{value:Ne,children:Ne},Ne))})]}):e.jsx("span",{className:"text-slate-900",children:$(ie.department)})}),e.jsx(de,{children:X===ie.id?e.jsx(ot,{value:((Q=Se[ie.id])==null?void 0:Q.description)||ie.description,onChange:Ne=>Qe(ie.id,"description",Ne.target.value),className:"h-8"}):e.jsx("span",{className:"text-slate-600",children:ie.description})}),e.jsx(de,{className:"text-right",children:X===ie.id?e.jsx(ot,{type:"number",value:((pe=Se[ie.id])==null?void 0:pe.amount)??ie.amount,onChange:Ne=>Qe(ie.id,"amount",Ne.target.value),className:"h-8 text-right"}):e.jsxs("span",{className:"text-slate-900",children:["₹",ie.amount.toLocaleString("en-IN")]})}),e.jsx(de,{children:e.jsxs("div",{className:"flex gap-1",children:[X===ie.id?e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>rt(ie.id),children:e.jsx(Yi,{className:"w-4 h-4"})}):e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>{ne(ie.id),We(Ne=>({...Ne,[ie.id]:{...ie}}))},children:e.jsx(ur,{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:()=>Kt(ie.id),children:e.jsx(Gn,{className:"w-4 h-4"})})]})})]},ie.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(wt,{value:D.department,onValueChange:ie=>O({...D,department:ie}),children:[e.jsx(Ct,{className:"col-span-3",children:e.jsx(St,{placeholder:"Department"})}),e.jsx(At,{children:zi.map(ie=>e.jsx(Pe,{value:ie,children:ie},ie))})]}),e.jsx(ot,{placeholder:"Description",value:D.description,onChange:ie=>O({...D,description:ie.target.value}),className:"col-span-5"}),e.jsx(ot,{type:"number",placeholder:"Amount",value:D.amount,onChange:ie=>O({...D,amount:ie.target.value}),className:"col-span-3"}),e.jsx(se,{onClick:le,className:"col-span-1 bg-red-600 hover:bg-red-700",children:e.jsx(cn,{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:["₹",be.receivables.toLocaleString("en-IN")]})]})})]})]}),e.jsxs(Le,{className:"border-amber-200 bg-amber-50",children:[e.jsx(tt,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs(nt,{className:"text-base flex items-center gap-2",children:[e.jsx(Ks,{className:"w-5 h-5 text-amber-600"}),"Deductions (Editable)"]}),e.jsx(Zt,{children:"Add or modify pending claims and deductions"})]})})}),e.jsxs(Me,{className:"space-y-4",children:[e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Department"}),e.jsx(me,{children:"Description"}),e.jsx(me,{className:"text-right",children:"Amount (₹)"}),e.jsx(me,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Es,{children:p.map(ie=>{var Fe,Q,pe;return e.jsxs(ct,{children:[e.jsx(de,{children:oe===ie.id?e.jsxs(wt,{value:((Fe=Ce[ie.id])==null?void 0:Fe.department)||ie.department,onValueChange:Ne=>Re(ie.id,"department",Ne),children:[e.jsx(Ct,{className:"h-8",children:e.jsx(St,{placeholder:"Department"})}),e.jsx(At,{children:zi.map(Ne=>e.jsx(Pe,{value:Ne,children:Ne},Ne))})]}):e.jsx("span",{className:"text-slate-900",children:$(ie.department)})}),e.jsx(de,{children:oe===ie.id?e.jsx(ot,{value:((Q=Ce[ie.id])==null?void 0:Q.description)||ie.description,onChange:Ne=>Re(ie.id,"description",Ne.target.value),className:"h-8"}):e.jsx("span",{className:"text-slate-600",children:ie.description})}),e.jsx(de,{className:"text-right",children:oe===ie.id?e.jsx(ot,{type:"number",value:((pe=Ce[ie.id])==null?void 0:pe.amount)??ie.amount,onChange:Ne=>Re(ie.id,"amount",Ne.target.value),className:"h-8 text-right"}):e.jsxs("span",{className:"text-slate-900",children:["₹",ie.amount.toLocaleString("en-IN")]})}),e.jsx(de,{children:e.jsxs("div",{className:"flex gap-1",children:[oe===ie.id?e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Qt(ie.id),children:e.jsx(Yi,{className:"w-4 h-4"})}):e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>{re(ie.id),fe(Ne=>({...Ne,[ie.id]:{...ie}}))},children:e.jsx(ur,{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:()=>qt(ie.id),children:e.jsx(Gn,{className:"w-4 h-4"})})]})})]},ie.id)})})]}),e.jsxs("div",{className:"border-t border-amber-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(wt,{value:V.department,onValueChange:ie=>K({...V,department:ie}),children:[e.jsx(Ct,{className:"col-span-3",children:e.jsx(St,{placeholder:"Department"})}),e.jsx(At,{children:zi.map(ie=>e.jsx(Pe,{value:ie,children:ie},ie))})]}),e.jsx(ot,{placeholder:"Description",value:V.description,onChange:ie=>K({...V,description:ie.target.value}),className:"col-span-5"}),e.jsx(ot,{type:"number",placeholder:"Amount",value:V.amount,onChange:ie=>K({...V,amount:ie.target.value}),className:"col-span-3"}),e.jsx(se,{onClick:Rt,className:"col-span-1 bg-amber-600 hover:bg-amber-700",children:e.jsx(cn,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"pt-3 border-t-2 border-amber-400",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-amber-700 text-xl",children:["₹",be.deductions.toLocaleString("en-IN")]})]})})]})]}),e.jsxs(Le,{className:"border-2 border-blue-300 bg-blue-50",children:[e.jsx(tt,{children:e.jsxs(nt,{className:"flex items-center gap-2",children:[e.jsx(Ys,{className:"w-5 h-5 text-amber-600"}),"Final Settlement Summary"]})}),e.jsxs(Me,{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:["+ ₹",be.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:["- ₹",be.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-amber-700 text-lg",children:["- ₹",be.deductions.toLocaleString("en-IN")]})]})]}),e.jsx("div",{className:"h-px bg-blue-300"}),e.jsx("div",{className:`p-4 rounded-lg border-2 ${be.settlementType==="Payable to Dealer"?"bg-red-100 border-red-400":be.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 ${be.settlementType==="Payable to Dealer"?"text-red-700":be.settlementType==="Receivable from Dealer"?"text-green-700":"text-slate-700"}`,children:be.settlementType})]}),e.jsx("span",{className:"text-3xl text-slate-900",children:be.settlementType==="No Settlement Required"?"₹0":`₹${be.settlementAmount.toLocaleString("en-IN")}`})]})}),e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-white border border-amber-200 rounded-lg",children:[e.jsx(Ks,{className:"w-5 h-5 text-amber-600 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",{}),be.netSettlement>0&&"Positive value means company pays to dealer",be.netSettlement<0&&"Negative value means dealer pays to company",be.netSettlement===0&&"Zero means no payment required from either party"]})]})]})]})]})]}),e.jsxs(Gt,{value:"departments",className:"space-y-4",children:[e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsxs(nt,{className:"flex items-center gap-2",children:[e.jsx(da,{className:"w-5 h-5"}),"Department Response Progress"]}),e.jsxs(Zt,{children:[n.departmentResponses.filter(ie=>ie.status!=="Pending").length," of ",n.departmentResponses.length," departments have responded"]})]}),e.jsxs(Me,{className:"space-y-4",children:[e.jsx(ji,{value:n.departmentResponses.filter(ie=>ie.status!=="Pending").length/n.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:n.departmentResponses.filter(ie=>ie.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:n.departmentResponses.filter(ie=>ie.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:n.departmentResponses.filter(ie=>ie.status==="Pending").length})]})]})]})]}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"All Department Responses"}),e.jsx(Zt,{children:"Status of NOC and dues clearance from all 16 departments (read-only for Finance; updates are done by department stakeholders)."})]}),e.jsx(Me,{children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Department"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Amount Type"}),e.jsx(me,{children:"Amount"}),e.jsx(me,{children:"Submitted Date"}),e.jsx(me,{children:"Remarks"})]})}),e.jsx(Es,{children:n.departmentResponses.map(ie=>e.jsxs(ct,{className:ie.duesFlow==="recovery"?"bg-red-50/40":ie.duesFlow==="payable"?"bg-emerald-50/40":"",children:[e.jsx(de,{children:ie.departmentName}),e.jsx(de,{children:e.jsx(Ae,{className:`border ${ie.status==="NOC Submitted"?"bg-green-100 text-green-700 border-green-300":ie.status==="Dues Pending"?"bg-red-100 text-red-700 border-red-300":"bg-slate-100 text-slate-700 border-slate-300"}`,children:ie.status})}),e.jsx(de,{children:ie.amountType?e.jsx(Ae,{variant:"outline",className:ie.duesFlow==="recovery"?"bg-red-100 text-red-900 border-red-400 font-semibold":ie.duesFlow==="payable"?"bg-emerald-100 text-emerald-900 border-emerald-400 font-semibold":"bg-slate-50 text-slate-700 border-slate-200",children:ie.amountType}):"-"}),e.jsx(de,{children:ie.amount?e.jsxs("span",{className:`rounded-md px-2 py-0.5 font-semibold tabular-nums ${ie.duesFlow==="recovery"?"bg-red-100 text-red-800 ring-1 ring-red-300/70":ie.duesFlow==="payable"?"bg-emerald-100 text-emerald-800 ring-1 ring-emerald-300/70":"text-slate-700"}`,children:["₹",ie.amount.toLocaleString("en-IN")]}):"-"}),e.jsx(de,{children:ie.submittedDate||"-"}),e.jsx(de,{className:"max-w-xs truncate",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{children:ie.remarks||"-"}),ie.supportingDocument&&e.jsxs("button",{onClick:()=>g({fileName:`${ie.departmentName}_Proof`,filePath:ie.supportingDocument,documentType:"Departmental Clearance Proof"}),className:"flex items-center gap-1 text-[10px] text-amber-600 hover:underline",children:[e.jsx(qd,{className:"w-3 h-3"}),"View Proof"]})]})})]},ie.id))})]})})]}),e.jsx(Le,{className:"bg-blue-50 border-amber-200",children:e.jsx(Me,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ks,{className:"w-5 h-5 text-amber-600 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(Gt,{value:"documents",className:"space-y-4",children:[e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsxs(nt,{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"w-5 h-5"}),"Submitted Documents"]})}),e.jsx(Me,{children:e.jsx("div",{className:"space-y-2",children:n.documents.map((ie,Fe)=>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(fs,{className:"w-5 h-5 text-slate-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900",children:ie.name}),e.jsxs("p",{className:"text-sm text-slate-500",children:[ie.size," • ",ie.type," • Uploaded on ",ie.uploadedOn]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[ie.url&&ie.url!=="#"&&e.jsxs("button",{onClick:()=>g({fileName:ie.name,filePath:ie.url,documentType:ie.type}),className:"text-amber-600 hover:text-amber-700 text-[10px] font-semibold flex items-center gap-1",children:[e.jsx(qd,{className:"w-3 h-3"})," PREVIEW"]}),e.jsx(se,{variant:"outline",size:"sm",onClick:async()=>{if(ie.url&&ie.url!=="#")try{const pe=await(await fetch(ie.url)).blob(),Ne=window.URL.createObjectURL(pe),Ee=document.createElement("a");Ee.href=Ne,Ee.download=ie.name||"download",document.body.appendChild(Ee),Ee.click(),document.body.removeChild(Ee),window.URL.revokeObjectURL(Ne)}catch{const pe=document.createElement("a");pe.href=ie.url,pe.download=ie.name||"download",document.body.appendChild(pe),pe.click(),document.body.removeChild(pe)}else ee.error("Document URL not available")},children:"Download"})]})]},Fe))})})]}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsxs(nt,{className:"flex items-center gap-2",children:[e.jsx(Dr,{className:"w-5 h-5"}),"Upload Settlement Verification Documents"]}),e.jsx(Zt,{children:"Upload bank receipts, settlement proofs, or any additional documents"})]}),e.jsx(Me,{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-amber-400 hover:bg-amber-50 transition-colors",children:[e.jsx(Dr,{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:ws,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(Gt,{value:"bank",className:"space-y-4",children:e.jsxs(Le,{children:[e.jsxs(tt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(nt,{className:"flex items-center gap-2",children:[e.jsx(Dc,{className:"w-5 h-5"}),"Dealer Bank Account Details"]}),e.jsx(Zt,{children:"Manage bank accounts for settlement transfer"})]}),e.jsxs(se,{size:"sm",className:"bg-amber-600",onClick:()=>{R(null),C(!0)},children:[e.jsx(cn,{className:"w-4 h-4 mr-2"}),"Add Bank Account"]})]}),e.jsx(Me,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:y.length>0?y.map(ie=>e.jsxs(Le,{className:`relative ${ie.isPrimary?"border-amber-500 bg-blue-50/30":""}`,children:[ie.isPrimary&&e.jsx("div",{className:"absolute top-0 right-0 p-1 bg-amber-600 text-white text-[10px] uppercase font-bold px-2 rounded-bl",children:"Primary"}),e.jsx(Me,{className:"p-4 pt-6",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(ce,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Account Holder"}),e.jsx("p",{className:"text-sm font-semibold",children:ie.accountHolderName})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(ce,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Bank"}),e.jsx("p",{className:"text-xs truncate",children:ie.bankName})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"IFSC"}),e.jsx("p",{className:"text-xs",children:ie.ifscCode})]})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Account Number"}),e.jsx("p",{className:"text-xs font-mono",children:ie.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-amber-600",onClick:()=>{R(ie),C(!0)},children:[e.jsx(ur,{className:"w-3 h-3 mr-1"}),"Edit"]}),e.jsxs(se,{variant:"ghost",size:"sm",className:"h-7 text-[11px] text-red-600",onClick:()=>W(ie.id),children:[e.jsx(Gn,{className:"w-3 h-3 mr-1"}),"Delete"]})]})]})})]},ie.id)):e.jsxs("div",{className:"col-span-full py-12 text-center border-2 border-dashed rounded-lg bg-slate-50",children:[e.jsx(Dc,{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(tt,{children:[e.jsxs(nt,{className:"flex items-center gap-2",children:[e.jsx(mu,{className:"w-5 h-5"}),"Settlement Verification"]}),e.jsx(Zt,{children:"Enter settlement transaction details"})]}),e.jsx(Me,{className:"space-y-4",children:n.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(Ys,{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:aa(ke.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:ke.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:ke.verificationTransactionId,children:ke.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(ke.settlementAmount).toLocaleString()]})]})]}),ke.verificationRemarks&&e.jsxs("div",{className:"mt-4",children:[e.jsx(ce,{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:ke.verificationRemarks})]}),e.jsxs(se,{variant:"outline",className:"w-full mt-4",onClick:()=>window.print(),children:[e.jsx(X5,{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(Ys,{className:"w-4 h-4 text-amber-600"}),"Compliance Checklist"]}),e.jsx("div",{className:"space-y-3",children:Qx.map(ie=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("input",{type:"checkbox",id:`check-${ie.id}`,checked:P.includes(ie.id),onChange:()=>z(ie.id),className:"w-4 h-4 mt-1 rounded border-slate-300 text-amber-600 focus:ring-amber-500"}),e.jsx("label",{htmlFor:`check-${ie.id}`,className:"text-sm text-slate-700 leading-tight",children:ie.label})]},ie.id))})]}),e.jsxs("div",{children:[e.jsxs(ce,{htmlFor:"paymentMode",children:["Payment Mode ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ot,{id:"paymentMode",placeholder:"e.g., NEFT, RTGS, Cheque",value:ke.paymentMode,onChange:ie=>qe({...ke,paymentMode:ie.target.value})})]}),e.jsxs("div",{children:[e.jsxs(ce,{htmlFor:"verificationTxnId",children:["Transaction ID / Reference ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ot,{id:"verificationTxnId",placeholder:"Enter transaction reference",value:ke.verificationTransactionId,onChange:ie=>qe({...ke,verificationTransactionId:ie.target.value})})]}),e.jsxs("div",{children:[e.jsx(ce,{htmlFor:"bankReference",children:"Bank Reference Number"}),e.jsx(ot,{id:"bankReference",placeholder:"Enter bank reference",value:ke.bankReference,onChange:ie=>qe({...ke,bankReference:ie.target.value})})]}),e.jsxs("div",{children:[e.jsxs(ce,{htmlFor:"settlementAmount",children:["Settlement Amount (₹) ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ot,{id:"settlementAmount",type:"number",placeholder:"Enter settlement amount",value:ke.settlementAmount,onChange:ie=>qe({...ke,settlementAmount:ie.target.value})})]}),e.jsxs("div",{children:[e.jsx(ce,{htmlFor:"adjustments",children:"Adjustments (₹)"}),e.jsx(ot,{id:"adjustments",type:"number",placeholder:"Enter any adjustments",value:ke.adjustments,onChange:ie=>{const Fe=ie.target.value,Q=be.settlementAmount+parseFloat(Fe||"0");qe({...ke,adjustments:Fe,settlementAmount:Q.toString()})}}),parseFloat(ke.adjustments)!==0&&e.jsxs("p",{className:"text-sm text-amber-600 mt-1 flex items-center gap-1",children:[e.jsx(Ks,{className:"w-3 h-3"}),"Adjusted amount: ₹",ke.settlementAmount]})]}),e.jsxs("div",{children:[e.jsxs(ce,{htmlFor:"settlementDate",children:["Settlement Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ot,{id:"settlementDate",type:"date",value:ke.settlementDate,onChange:ie=>qe({...ke,settlementDate:ie.target.value})})]}),e.jsxs("div",{children:[e.jsx(ce,{htmlFor:"verificationRemarks",children:"Verification Remarks"}),e.jsx(Fs,{id:"verificationRemarks",placeholder:"Enter any remarks or notes...",rows:4,value:ke.verificationRemarks,onChange:ie=>qe({...ke,verificationRemarks:ie.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:Cs,disabled:_s||P.length<Qx.length,children:[_s?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Ys,{className:"w-4 h-4 mr-2"}),"Complete Settlement"]}),P.length<Qx.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-amber-600 hover:bg-blue-50",onClick:Ft,disabled:_s,children:[e.jsx(fu,{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:Bs,disabled:_s,children:[e.jsx(Za,{className:"w-4 h-4 mr-2"}),"Reject Settlement"]})]})]})})]})})]}),e.jsx(fE,{isOpen:S,onClose:()=>{C(!1),R(null)},onSubmit:Z,editingBank:w,isSubmitting:!1}),e.jsx(Kl,{isOpen:!!j,onClose:()=>g(null),document:j})]}):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 R$=()=>{const t=su(),s=v.useCallback(async()=>{try{t(HN(!0));const[r,a,l,c,d,h,x,f,m,p,u,j,g]=await Promise.all([Ss.getRoles().catch(()=>({success:!1})),Ss.getZones().catch(()=>({success:!1})),Ss.getPermissions().catch(()=>({success:!1})),Ss.getRegions().catch(()=>({success:!1})),Ss.getUsers().catch(()=>({success:!1})),Ss.getStates().catch(()=>({success:!1})),Ss.getEmailTemplates().catch(()=>({success:!1})),Ss.getDistricts({limit:"all"}).catch(()=>({success:!1})),Ss.getAreas({limit:"all"}).catch(()=>({success:!1})),Ss.getSlaConfigs().catch(()=>({success:!1})),Ss.getASMs().catch(()=>({success:!1})),Ss.getZonalManagers().catch(()=>({success:!1})),Ss.getDDLeads().catch(()=>({success:!1}))]),y=U=>U.success?U:U.data?U.data:U,N=y(r),S=y(a),C=y(l),w=y(c),R=y(d),P=y(h),A=y(x),I=y(f),$=y(m),T=y(p),E=y(u),_=y(j),M=y(g),q=((R==null?void 0:R.users)||(R==null?void 0:R.data)||[]).map(U=>{var ve;const X=Array.isArray(U.territoryProfile)?U.territoryProfile:[],ne=X.filter(Se=>String(Se.locationType||"").toLowerCase()==="zone").map(Se=>Se.locationName||Se.zone).filter(Boolean),oe=X.filter(Se=>String(Se.locationType||"").toLowerCase()==="region").map(Se=>Se.locationName||Se.region).filter(Boolean),re=Array.from(new Set([...U.allZones||[],...ne])),ge=Array.from(new Set([...U.allRegions||[],...oe]));return{...U,name:U.fullName||U.name,role:((ve=U.role)==null?void 0:ve.roleName)||(Array.isArray(U.allRoles)&&U.allRoles.length>0?U.allRoles[0]:"System User"),zone:re.length>0?re.join(", "):"Global",region:ge.length>0?ge.join(", "):"Unassigned",status:U.isActive!==!1?"Active":"Inactive"}}),G=((N==null?void 0:N.roles)||(N==null?void 0:N.data)||[]).map(U=>{var X;return{id:U.id,name:U.roleName,permissions:((X=U.permissions)==null?void 0:X.map(ne=>ne.permissionCode))||[],userCount:U.userCount||0}}),Z=((S==null?void 0:S.zones)||(S==null?void 0:S.data)||[]).map(U=>{var ne,oe,re,ge,ve;const X=(U.name||U.zoneName||"").toUpperCase();return{id:U.id,name:X,description:U.description||"",code:U.name?U.name.substring(0,3).toUpperCase():"ZON",regionCount:U.regionCount||0,asmCount:U.asmCount||0,regionalOfficerCount:U.regionalOfficerCount||0,zmCount:U.zmCount||0,states:U.states||[],zonalBusinessHead:{name:((ne=U.zonalBusinessHead)==null?void 0:ne.name)||((oe=U.zonalBusinessHead)==null?void 0:oe.fullName)||"Not Assigned",email:((re=U.zonalBusinessHead)==null?void 0:re.email)||"",phone:((ge=U.zonalBusinessHead)==null?void 0:ge.mobileNumber)||((ve=U.zonalBusinessHead)==null?void 0:ve.phone)||""},zonalManagers:(U.zonalManagers||[]).map(Se=>({id:Se.id,name:Se.name||Se.fullName||"Unknown",email:Se.email||"",phone:Se.phone||Se.mobileNumber||"",regions:Se.regions||[]}))}}),W=((w==null?void 0:w.regions)||(w==null?void 0:w.data)||[]).map(U=>({id:U.id,code:U.code||(U.name?U.name.substring(0,3).toUpperCase():"REG"),name:U.name||U.regionName,zoneId:U.zoneId,zoneName:U.zoneName||"Unknown",states:U.states||[],cities:U.cities||[],districts:(U.districts||[]).map(X=>({id:X.id,name:X.name,stateId:X.stateId})),asmCount:U.asmCount||0,regionalOfficerCount:U.regionalOfficerCount||0,regionalManager:U.regionalManager?{id:U.regionalManager.id,name:U.regionalManager.fullName||U.regionalManager.name,email:U.regionalManager.email,phone:U.regionalManager.mobileNumber||U.regionalManager.phone}:void 0,status:U.isActive!==!1?"Active":"Inactive"})),z=Array.isArray(E==null?void 0:E.data)?E.data:Array.isArray(E)?E:[],F=Array.isArray(_==null?void 0:_.data)?_.data:Array.isArray(_)?_:[],B=F.length>0?F:q.filter(U=>{var X;return(X=U.allRoles)==null?void 0:X.some(ne=>(ne==="ZM"||ne==="DD-ZM"||ne.includes("ZONAL MANAGER"))&&!ne.includes("HEAD"))}).map(U=>{const X=(U.territoryProfile||[]).find(re=>re.roleCode==="ZM"||re.roleCode==="DD-ZM")||{},ne=(U.territoryProfile||[]).filter(re=>(re.roleCode==="ZM"||re.roleCode==="DD-ZM")&&re.locationType==="region").map(re=>re.locationName),oe=(U.territoryProfile||[]).filter(re=>(re.roleCode==="ZM"||re.roleCode==="DD-ZM")&&re.locationType==="region").map(re=>re.locationId);return{id:U.id,name:U.fullName,zmCode:U.employeeId||"N/A",email:U.email,phone:U.mobileNumber,zoneId:X.zoneId,zoneName:X.zone||U.zone||"Not Assigned",regionNames:ne,assignedRegionIds:oe,status:U.status}}),D=((P==null?void 0:P.states)||(P==null?void 0:P.data)||[]).map(U=>({...U,stateName:U.name})),O=((I==null?void 0:I.districts)||(I==null?void 0:I.data)||[]).map(U=>({...U,districtName:U.name,stateId:U.stateId,asmId:U.asmId,ddAmId:U.ddAmId,zmId:U.zmId})),V=($.areas||$.data||[]).map(U=>({...U,areaName:U.name,districtId:U.districtId})),K=(T.data||[]).map(U=>{var X,ne;return{id:U.id,stage:U.stageCode||"Unknown",days:U.tatValue||0,enabled:U.isActive!==!1,reminders:((X=U.reminderConfig)==null?void 0:X.reminders)||[],escalations:((ne=U.escalationConfig)==null?void 0:ne.escalations)||[]}}),Y=Array.isArray(M==null?void 0:M.data)?M.data:Array.isArray(M)?M:[];t(s2({zones:Z,regionalOffices:W,asms:z,zonalManagerMappings:B,zonalManagers:F,roles:G,allStates:D,allDistricts:O,allAreas:V,availablePermissions:(C==null?void 0:C.permissions)||(C==null?void 0:C.data)||[],emailTemplates:(A==null?void 0:A.data)||[],slaConfigs:K,users:q,ddLeads:Y,loading:!1}))}catch(r){console.error("[useMasterData] Error fetching data:",r),t(BO("Could not load configuration data")),ee.error("Could not load configuration data")}finally{t(HN(!1))}},[t]),n=v.useCallback(async r=>{try{t(WN(!0));const a=await Ss.getAreas(r);a.success&&t($O({data:a.data,pagination:a.pagination}))}catch(a){console.error("[useMasterData] Error fetching areas:",a),ee.error("Could not load locations")}finally{t(WN(!1))}},[t]);return{fetchInitialData:s,fetchAreas:n}},E$=({selectedZone:t,onZoneClick:s})=>{const{zones:n}=Nn(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-amber-600 shadow-lg":"hover:border-amber-400"}`,onClick:()=>s(r.id),children:[e.jsx(tt,{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(Zd,{className:"w-5 h-5 text-amber-600"}),e.jsx(nt,{className:"text-lg",children:r.name.toUpperCase().endsWith("ZONE")?r.name:`${r.name} Zone`})]}),e.jsx(Ae,{variant:"outline",className:"text-xs",children:r.code})]})}),e.jsxs(Me,{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(Ae,{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(Ae,{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(Ae,{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(Ae,{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(Ae,{className:"bg-blue-600",children:r.zmCount})]})]})]})]},r.id))})},D$=({selectedZone:t,onAddZone:s,onEditZone:n})=>{const{zones:r}=Nn(l=>l.master),a=r.filter(l=>t==="all"||l.id===t);return e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(nt,{children:"Zone Details"}),e.jsx(Zt,{children:"Geographical coverage and state mappings for each zone"})]}),e.jsxs(se,{onClick:s,className:"bg-amber-600 hover:bg-amber-700",children:[e.jsx(cn,{className:"w-4 h-4 mr-2"}),"Add Zone"]})]})}),e.jsx(Me,{children:e.jsx(kb,{className:"h-[400px]",children:e.jsx("div",{className:"space-y-4",children:a.map(l=>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-amber-500 to-amber-600 rounded-lg flex items-center justify-center shadow-md",children:e.jsx(Zd,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900",children:l.name}),e.jsx("p",{className:"text-slate-500 text-sm",children:l.code})]})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(se,{variant:"outline",size:"sm",onClick:()=>n(l),className:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",children:e.jsx(ur,{className:"w-4 h-4"})})})]}),l.description&&e.jsx("div",{className:"bg-slate-50 rounded-lg p-3",children:e.jsx("p",{className:"text-sm text-slate-600",children:l.description})}),e.jsxs("div",{children:[e.jsxs(ce,{className:"text-xs text-slate-600 mb-2 block",children:["States Covered (",l.states.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:l.states.map((c,d)=>e.jsx(Ae,{variant:"secondary",className:"text-xs border-transparent bg-secondary text-secondary-foreground",children:c},d))})]}),l.zonalBusinessHead&&e.jsxs("div",{className:"border-t pt-3",children:[e.jsx(ce,{className:"text-xs text-slate-600 mb-2 block",children:"Zonal Business Head (ZBH)"}),e.jsxs("div",{className:"bg-amber-50 border border-amber-100 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vo,{className:"w-4 h-4 text-amber-600"}),e.jsx("span",{className:"text-sm font-semibold text-slate-900",children:l.zonalBusinessHead.name}),e.jsx(Ae,{className:"bg-amber-600 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(qr,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:l.zonalBusinessHead.email})]})]})]}),l.zonalManagers&&l.zonalManagers.length>0&&e.jsxs("div",{className:"border-t pt-3",children:[e.jsxs(ce,{className:"text-xs text-slate-600 mb-2 block",children:["Zonal Managers (",l.zonalManagers.length,")"]}),e.jsx("div",{className:"space-y-2",children:l.zonalManagers.map((c,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(da,{className:"w-4 h-4 text-slate-600"}),e.jsx("span",{className:"text-sm text-slate-900",children:c.name}),e.jsxs(Ae,{variant:"outline",className:"text-xs ml-auto",children:["ZM-",d+1]})]}),c.email&&e.jsxs("div",{className:"flex items-center gap-2 ml-6",children:[e.jsx(qr,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-xs text-slate-600",children:c.email})]}),c.phone&&e.jsx("div",{className:"flex items-center gap-2 ml-6",children:e.jsx("span",{className:"text-xs text-slate-600",children:c.phone})}),c.regions&&c.regions.length>0&&e.jsxs("div",{className:"ml-6 mt-2",children:[e.jsxs(ce,{className:"text-xs text-slate-500 mb-1 block",children:["Managed Regions (",c.regions.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:c.regions.map((h,x)=>e.jsxs(Ae,{variant:"outline",className:"text-xs bg-white text-foreground",children:[e.jsx(Zd,{className:"w-2.5 h-2.5 mr-1"}),h]},x))})]})]},d))})]})]},l.id))})})})]})},T$=({selectedZone:t,onAddRegion:s,onEditRegion:n,onDeleteRegion:r})=>{const{regionalOffices:a}=Nn(c=>c.master),l=a.filter(c=>t==="all"||c.zoneId===t);return e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(nt,{children:"Regional Offices"}),e.jsx(Zt,{children:"Manage regional offices within zones"})]}),e.jsxs(se,{onClick:s,className:"bg-amber-600 hover:bg-amber-700",children:[e.jsx(cn,{className:"w-4 h-4 mr-2"}),"Add Regional Office"]})]})}),e.jsx(Me,{children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Region Code"}),e.jsx(me,{children:"Region Name"}),e.jsx(me,{children:"Zone"}),e.jsx(me,{children:"Regional Manager"}),e.jsx(me,{children:"Districts"}),e.jsx(me,{children:"Cities"}),e.jsx(me,{children:"Regional Officers"}),e.jsx(me,{children:"ASMs"}),e.jsx(me,{children:"Status"}),e.jsx(me,{className:"text-right",children:"Actions"})]})}),e.jsx(Es,{children:l.map(c=>e.jsxs(ct,{children:[e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ml,{className:"w-4 h-4 text-indigo-600"}),e.jsx("span",{className:"font-medium",children:c.code})]})}),e.jsx(de,{className:"font-medium",children:c.name}),e.jsx(de,{children:c.zoneName}),e.jsx(de,{children:c.regionalManager?e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm",children:c.regionalManager.name}),e.jsx("span",{className:"text-xs text-slate-500",children:c.regionalManager.email})]}):e.jsx("span",{className:"text-slate-400 italic",children:"Not Assigned"})}),e.jsx(de,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(c.districts||[]).slice(0,2).map((d,h)=>e.jsx(Ae,{variant:"secondary",className:"text-xs",children:d.name||d},h)),(c.districts||[]).length>2&&e.jsxs(Ae,{variant:"secondary",className:"text-xs",children:["+",(c.districts||[]).length-2]})]})}),e.jsx(de,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[c.cities.slice(0,3).map((d,h)=>e.jsxs("span",{className:"text-xs text-slate-600",children:[d,h<Math.min(c.cities.length,3)-1?",":""]},h)),c.cities.length>3&&e.jsxs("span",{className:"text-xs text-slate-500",children:["+",c.cities.length-3]})]})}),e.jsx(de,{children:e.jsx(Ae,{className:"bg-purple-600",children:c.regionalOfficerCount})}),e.jsx(de,{children:e.jsx(Ae,{className:"bg-green-600",children:c.asmCount})}),e.jsx(de,{children:e.jsx(Ae,{variant:c.status==="Active"?"default":"secondary",className:c.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:c.status})}),e.jsx(de,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>n(c),children:e.jsx(ur,{className:"w-4 h-4"})}),e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>r(c.id,c.name),className:"text-red-600 hover:text-red-700 hover:bg-red-50",children:e.jsx(Gn,{className:"w-4 h-4"})})]})})]},c.id))})]})})]})},P$=({selectedZone:t,onAddASM:s,onEditASM:n,onDeleteASM:r})=>{const{asms:a,zonalManagerMappings:l}=Nn(h=>h.master),c=a.filter(h=>t==="all"||h.zoneId===t),d=v.useMemo(()=>{const h={};return[...a,...l].forEach(x=>{(x.areasManaged||x.districts||[]).forEach(m=>{h[m]||(h[m]=[]),h[m].includes(x.name)||h[m].push(x.name)})}),h},[a,l]);return e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(nt,{children:"District Development Area Managers (DD-AM)"}),e.jsx(Zt,{children:"Manage DD-AM users across districts (multi-district)"})]}),e.jsxs(se,{onClick:s,className:"bg-amber-600 hover:bg-amber-700",children:[e.jsx(cn,{className:"w-4 h-4 mr-2"}),"Add DD-AM"]})]})}),e.jsx(Me,{children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"DD-AM Code"}),e.jsx(me,{children:"Name"}),e.jsx(me,{children:"Zone"}),e.jsx(me,{children:"Region"}),e.jsx(me,{children:"Districts Managed"}),e.jsx(me,{children:"Contact"}),e.jsx(me,{children:"Status"}),e.jsx(me,{className:"text-right",children:"Actions"})]})}),e.jsx(Es,{children:c.map(h=>e.jsxs(ct,{children:[e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vI,{className:"w-4 h-4 text-green-600"}),e.jsx("span",{className:"font-medium",children:h.asmCode||"N/A"})]})}),e.jsx(de,{children:h.name}),e.jsx(de,{children:e.jsx(Ae,{variant:"outline",children:h.zoneName})}),e.jsx(de,{className:"text-sm text-slate-600",children:h.regionName}),e.jsx(de,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:h.areasManaged.map((x,f)=>{const m=typeof x=="string"?x:x.id,p=typeof x=="string"?x:x.name,u=(d[m]||[]).filter(g=>g!==h.name),j=u.length>0;return e.jsxs(Ae,{variant:j?"outline":"secondary",className:`text-xs ${j?"border-amber-300 bg-amber-50 text-amber-700 font-medium":""}`,title:j?`Also managed by: ${u.join(", ")}`:void 0,children:[p,j&&e.jsx(da,{className:"w-2.5 h-2.5 ml-1 inline"})]},f)})})}),e.jsx(de,{children:e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-slate-900",children:h.email}),e.jsx("p",{className:"text-slate-500",children:h.phone})]})}),e.jsx(de,{children:e.jsx(Ae,{variant:h.status==="Active"?"default":"secondary",className:h.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:h.status})}),e.jsx(de,{className:"text-right",children:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>n(h),children:e.jsx(ur,{className:"w-4 h-4"})}),e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>r(h.id,h.name),className:"text-red-600 hover:text-red-700 hover:bg-red-50",children:e.jsx(Gn,{className:"w-4 h-4"})})]})})]},h.id))})]})})]})},_$=({selectedZone:t,onAddZM:s,onEditZM:n,onDeleteZM:r})=>{const{zonalManagers:a}=Nn(c=>c.master),l=(a||[]).filter(c=>t==="all"||c.zoneId===t||c.zones&&c.zones.includes(t));return e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(nt,{children:"Zonal Managers (DD-ZM)"}),e.jsx(Zt,{children:"Manage Zonal Managers and their region assignments"})]}),e.jsxs(se,{onClick:s,className:"bg-amber-600 hover:bg-amber-700",children:[e.jsx(cn,{className:"w-4 h-4 mr-2"}),"Add ZM"]})]})}),e.jsx(Me,{children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"ZM Code"}),e.jsx(me,{children:"Name"}),e.jsx(me,{children:"Zone"}),e.jsx(me,{children:"Regions Managed"}),e.jsx(me,{children:"Contact"}),e.jsx(me,{children:"Status"}),e.jsx(me,{className:"text-right",children:"Actions"})]})}),e.jsx(Es,{children:l.map(c=>e.jsxs(ct,{children:[e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(da,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"font-medium",children:c.zmCode||c.code})]})}),e.jsx(de,{children:c.name}),e.jsx(de,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:(c.zones||[c.zoneName]).map((d,h)=>e.jsx(Ae,{variant:"outline",children:d},h))})}),e.jsx(de,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(c.regionNames||[]).slice(0,3).map((d,h)=>e.jsx(Ae,{variant:"secondary",className:"text-xs",children:d},h)),(c.regionNames||[]).length>3&&e.jsxs(Ae,{variant:"secondary",className:"text-xs",children:["+",(c.regionNames||[]).length-3]})]})}),e.jsx(de,{children:e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-slate-900",children:c.email}),e.jsx("p",{className:"text-slate-500",children:c.phone})]})}),e.jsx(de,{children:e.jsx(Ae,{variant:c.status==="Active"?"default":"secondary",className:c.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:c.status})}),e.jsx(de,{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(c),children:e.jsx(ur,{className:"w-4 h-4"})}),e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>r(c.id,c.name),className:"text-red-600 hover:text-red-700 hover:bg-red-50",children:e.jsx(Gn,{className:"w-4 h-4"})})]})})]},c.id))})]})})]})},O$=({userAssignedData:t})=>e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{className:"text-xl",children:"System Users & Territory Assignments"})}),e.jsx(Me,{children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"User Details"}),e.jsx(me,{children:"Role"}),e.jsx(me,{children:"Assigned Zone"}),e.jsx(me,{children:"Assigned Region"}),e.jsx(me,{children:"Status"})]})}),e.jsx(Es,{children:t.map(s=>e.jsxs(ct,{children:[e.jsx(de,{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(kr,{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(qr,{className:"w-3 h-3"}),s.email]})]})]})}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vo,{className:"w-3 h-3 text-amber-600"}),e.jsx("span",{className:"text-sm font-medium",children:s.role})]})}),e.jsx(de,{children:e.jsx(Ae,{variant:"outline",children:s.zone})}),e.jsx(de,{children:e.jsx(Ae,{variant:"outline",className:"bg-indigo-50 text-indigo-700 border-indigo-200",children:s.region})}),e.jsx(de,{children:e.jsx(Ae,{variant:s.status==="Active"?"default":"secondary",className:s.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:s.status})})]},s.id))})]})})]}),I$=({onAddRole:t,onEditRole:s})=>{const{roles:n}=Nn(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(tt,{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(nt,{className:"leading-none text-xl font-bold",children:"Role Definitions"}),e.jsx(Zt,{className:"text-muted-foreground mt-1.5",children:"Overview of available roles and their access levels"})]}),e.jsxs(se,{onClick:t,className:"bg-amber-600 hover:bg-amber-700 h-9",children:[e.jsx(cn,{className:"w-4 h-4 mr-2"}),"Add Role"]})]})}),e.jsx(Me,{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(Vo,{className:"w-5 h-5 text-amber-600"}),e.jsx("h3",{className:"text-slate-900 font-bold",children:r.name})]}),e.jsxs(Ae,{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((l,c)=>e.jsx(Ae,{variant:"outline",className:"border px-2 py-0.5 font-medium text-foreground text-[10px] bg-white/50",children:l.replace(/_/g," ").toLowerCase()},c)),((a=r.permissions)==null?void 0:a.length)>3&&e.jsxs(Ae,{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(ur,{className:"w-3 h-3 mr-1"}),"Edit Permissions"]})]},r.id)})})})]})},L$=({isOpen:t,onOpenChange:s,role:n,onSave:r})=>{const[a,l]=v.useState([]);v.useEffect(()=>{n&&l(n.permissions||[])},[n,t]);const c=h=>{l(x=>x.includes(h)?x.filter(f=>f!==h):[...x,h])};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-amber-50 to-orange-50 border-amber-200",textColor:"text-amber-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(os,{open:t,onOpenChange:s,children:e.jsxs(ls,{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(ms,{className:"p-6 pb-2 space-y-2 text-left bg-white sticky top-0 z-10 border-b",children:[e.jsxs(us,{className:"text-xl font-bold tracking-tight",children:["Edit Role Permissions - ",n.name]}),e.jsxs(vs,{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(Vo,{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(Ae,{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-amber-500 rounded-full"}),"Configure Default Permissions"]}),e.jsx("div",{className:"space-y-4",children:d.map((h,x)=>e.jsxs("div",{className:`border rounded-xl p-5 bg-gradient-to-br ${h.color} shadow-sm transition-all hover:shadow-md`,children:[e.jsxs("h5",{className:`text-sm font-bold ${h.textColor} mb-4 flex items-center justify-between`,children:[h.title,e.jsxs("span",{className:"text-[10px] bg-white/50 px-2 py-0.5 rounded-full opacity-70 italic font-normal",children:["Section ",x+1]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-y-3 gap-x-6",children:h.permissions.map(f=>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(Rn,{id:`perm-${f.id}`,checked:a.includes(f.id),onCheckedChange:()=>c(f.id),className:"border-slate-300 data-[state=checked]:bg-purple-600 data-[state=checked]:border-purple-600"}),e.jsx("label",{htmlFor:`perm-${f.id}`,className:"text-sm font-medium text-slate-700 cursor-pointer group-hover:text-slate-900 transition-colors flex-1",children:f.label})]},f.id))})]},x))})]})]}),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(Yi,{className:"w-4 h-4 mr-2"}),"Save Role Permissions"]})]})]})})},M$=({isOpen:t,onOpenChange:s,onSave:n})=>{const[r,a]=v.useState(""),[l,c]=v.useState(""),[d,h]=v.useState(""),[x,f]=v.useState(!1);v.useEffect(()=>{t&&(a(""),c(""),h(""),f(!1))},[t]);const m=async()=>{if(!(!r.trim()||!l.trim())){f(!0);try{await n({roleName:r.trim(),roleCode:l.trim(),description:d.trim()||void 0}),s(!1)}finally{f(!1)}}};return e.jsx(os,{open:t,onOpenChange:s,children:e.jsxs(ls,{className:"sm:max-w-md",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Add Role"}),e.jsx(vs,{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(ce,{htmlFor:"role-name",children:"Role Name"}),e.jsx(ot,{id:"role-name",value:r,onChange:p=>a(p.target.value),placeholder:"e.g. Finance Admin"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"role-code",children:"Role Code"}),e.jsx(ot,{id:"role-code",value:l,onChange:p=>c(p.target.value),placeholder:"e.g. FINANCE_ADMIN"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"role-description",children:"Description"}),e.jsx(Fs,{id:"role-description",value:d,onChange:p=>h(p.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:x,children:"Cancel"}),e.jsx(se,{onClick:m,disabled:x||!r.trim()||!l.trim(),children:x?"Saving...":"Create Role"})]})]})})},F$=({onEditTemplate:t,onDeleteTemplate:s})=>{const{emailTemplates:n}=Nn(r=>r.master);return e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsxs("div",{children:[e.jsx(nt,{children:"Email & Letter Templates"}),e.jsx(Zt,{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(Me,{children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Template Name"}),e.jsx(me,{children:"Subject"}),e.jsx(me,{children:"Trigger Code"}),e.jsx(me,{children:"Modified Date"}),e.jsx(me,{className:"text-right",children:"Actions"})]})}),e.jsxs(Es,{children:[n.map(r=>e.jsxs(ct,{children:[e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-amber-50 rounded-lg flex items-center justify-center",children:e.jsx(qr,{className:"w-4 h-4 text-amber-600"})}),e.jsx("span",{className:"font-medium text-slate-900",children:r.name||r.templateCode})]})}),e.jsx(de,{className:"text-slate-600 max-w-xs truncate",children:r.subject}),e.jsx(de,{children:e.jsx(Ae,{variant:"outline",className:"bg-slate-50 text-[10px] font-mono",children:r.templateCode||"-"})}),e.jsx(de,{className:"text-slate-500 text-sm",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx($n,{className:"w-3.5 h-3.5"}),r.updatedAt?Ht(r.updatedAt):"-"]})}),e.jsx(de,{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(ur,{className:"w-4 h-4"})}),e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>s(r.id),className:"text-red-500 hover:text-red-600 hover:bg-red-50",children:e.jsx(Gn,{className:"w-4 h-4"})})]})})]},r.id)),n.length===0&&e.jsx(ct,{children:e.jsx(de,{colSpan:5,className:"text-center py-12",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(qr,{className:"w-8 h-8 text-slate-200"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"No templates configured yet"})]})})})]})]})})]})},B$=({onAddLocation:t,onEditLocation:s,onDeleteLocation:n,onSearch:r,onPageChange:a,searchTerm:l,states:c,stateFilter:d,onStateFilterChange:h,statusFilter:x,onStatusFilterChange:f})=>{const{allAreas:m,areasPagination:p,isAreasLoading:u}=Nn(j=>j.master);return e.jsx("div",{className:"space-y-4",children:e.jsxs(Le,{children:[e.jsx(tt,{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(nt,{children:"Dealership Locations"}),e.jsxs(Zt,{children:["Manage ",p.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(Zd,{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:l,onChange:j=>r(j.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-amber-500 w-64 transition-all"})]}),e.jsxs(wt,{value:d,onValueChange:h,children:[e.jsx(Ct,{className:"w-48",children:e.jsx(St,{placeholder:"All States"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"all",children:"All States"}),c.map(j=>e.jsx(Pe,{value:j.id,children:j.name||j.stateName},j.id))]})]}),e.jsxs(wt,{value:x,onValueChange:f,children:[e.jsx(Ct,{className:"w-44",children:e.jsx(St,{placeholder:"Opportunity Filter"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"all",children:"All Opportunities"}),e.jsx(Pe,{value:"active",children:"Opportunity: Yes"}),e.jsx(Pe,{value:"inactive",children:"Opportunity: No"})]})]}),e.jsxs(se,{onClick:t,className:"bg-amber-600 hover:bg-amber-700 whitespace-nowrap",children:[e.jsx(cn,{className:"w-4 h-4 mr-2"}),"Add Location"]})]})]})}),e.jsxs(Me,{children:[e.jsxs("div",{className:`relative ${u?"opacity-50 pointer-events-none":""}`,children:[e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"State"}),e.jsx(me,{children:"City"}),e.jsx(me,{children:"District"}),e.jsx(me,{children:"Active Period"}),e.jsx(me,{children:"Opportunity"}),e.jsx(me,{className:"text-right",children:"Actions"})]})}),e.jsx(Es,{children:m.length===0?e.jsx(ct,{children:e.jsx(de,{colSpan:6,className:"h-32 text-center text-slate-500 italic",children:l?"No locations found matching your search":"No locations available"})}):m.map(j=>e.jsxs(ct,{children:[e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Er,{className:"w-4 h-4 text-amber-600"}),e.jsx("span",{className:"font-medium",children:j.stateName||"N/A"})]})}),e.jsx(de,{className:"font-medium text-slate-900",children:j.city||"N/A"}),e.jsx(de,{className:"text-slate-600 text-sm",children:j.name}),e.jsx(de,{children:j.openFrom&&j.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(Ae,{variant:"outline",className:"text-xs font-medium",children:Ht(j.openFrom)})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-slate-600",children:"To:"}),e.jsx(Ae,{variant:"outline",className:"text-xs font-medium",children:Ht(j.openTo)})]})]}):e.jsx("span",{className:"text-slate-400 italic text-sm",children:"Not Defined"})}),e.jsx(de,{children:e.jsx(Ae,{variant:j.isOpportunity?"default":"secondary",className:j.isOpportunity?"bg-green-600 hover:bg-green-700 text-white border-transparent":"",children:j.isOpportunity?"Yes":"No"})}),e.jsx(de,{className:"text-right",children:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(se,{variant:"outline",size:"sm",onClick:()=>s(j),className:"h-8 w-8 p-0",children:e.jsx(ur,{className:"w-4 h-4"})}),e.jsx(se,{variant:"outline",size:"sm",onClick:()=>n(j.id),className:"h-8 w-8 p-0 text-red-600 hover:bg-red-50 hover:text-red-700",children:e.jsx(Gn,{className:"w-4 h-4"})})]})})]},j.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-amber-600"})})]}),p.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:(p.page-1)*p.limit+1})," to ",e.jsx("span",{className:"font-medium text-slate-900",children:Math.min(p.page*p.limit,p.total)})," of ",e.jsx("span",{className:"font-medium text-slate-900",children:p.total})," results"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{variant:"outline",size:"sm",onClick:()=>a(p.page-1),disabled:p.page<=1||u,className:"h-8",children:"Previous"}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,p.totalPages)},(j,g)=>{let y=p.page;return p.page<=3?y=g+1:p.page>=p.totalPages-2?y=p.totalPages-4+g:y=p.page-2+g,y<=0||y>p.totalPages?null:e.jsx(se,{variant:p.page===y?"default":"outline",size:"sm",onClick:()=>a(y),disabled:u,className:"h-8 w-8 p-0",children:y},y)})}),e.jsx(se,{variant:"outline",size:"sm",onClick:()=>a(p.page+1),disabled:p.page>=p.totalPages||u,className:"h-8",children:"Next"})]})]})]})]})})};var $$=Symbol("radix.slottable");function q$(t){const s=({children:n})=>e.jsx(e.Fragment,{children:n});return s.displayName=`${t}.Slottable`,s.__radixId=$$,s}var[wf]=ea("Tooltip",[Vl]),Sf=Vl(),pE="TooltipProvider",z$=700,Cv="tooltip.open",[U$,qb]=wf(pE),xE=t=>{const{__scopeTooltip:s,delayDuration:n=z$,skipDelayDuration:r=300,disableHoverableContent:a=!1,children:l}=t,c=v.useRef(!0),d=v.useRef(!1),h=v.useRef(0);return v.useEffect(()=>{const x=h.current;return()=>window.clearTimeout(x)},[]),e.jsx(U$,{scope:s,isOpenDelayedRef:c,delayDuration:n,onOpen:v.useCallback(()=>{window.clearTimeout(h.current),c.current=!1},[]),onClose:v.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>c.current=!0,r)},[r]),isPointerInTransitRef:d,onPointerInTransitChange:v.useCallback(x=>{d.current=x},[]),disableHoverableContent:a,children:l})};xE.displayName=pE;var tu="Tooltip",[V$,Su]=wf(tu),gE=t=>{const{__scopeTooltip:s,children:n,open:r,defaultOpen:a,onOpenChange:l,disableHoverableContent:c,delayDuration:d}=t,h=qb(tu,t.__scopeTooltip),x=Sf(s),[f,m]=v.useState(null),p=hr(),u=v.useRef(0),j=c??h.disableHoverableContent,g=d??h.delayDuration,y=v.useRef(!1),[N,S]=bi({prop:r,defaultProp:a??!1,onChange:A=>{A?(h.onOpen(),document.dispatchEvent(new CustomEvent(Cv))):h.onClose(),l==null||l(A)},caller:tu}),C=v.useMemo(()=>N?y.current?"delayed-open":"instant-open":"closed",[N]),w=v.useCallback(()=>{window.clearTimeout(u.current),u.current=0,y.current=!1,S(!0)},[S]),R=v.useCallback(()=>{window.clearTimeout(u.current),u.current=0,S(!1)},[S]),P=v.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>{y.current=!0,S(!0),u.current=0},g)},[g,S]);return v.useEffect(()=>()=>{u.current&&(window.clearTimeout(u.current),u.current=0)},[]),e.jsx(sf,{...x,children:e.jsx(V$,{scope:s,contentId:p,open:N,stateAttribute:C,trigger:f,onTriggerChange:m,onTriggerEnter:v.useCallback(()=>{h.isOpenDelayedRef.current?P():w()},[h.isOpenDelayedRef,P,w]),onTriggerLeave:v.useCallback(()=>{j?R():(window.clearTimeout(u.current),u.current=0)},[R,j]),onOpen:w,onClose:R,disableHoverableContent:j,children:n})})};gE.displayName=tu;var Av="TooltipTrigger",vE=v.forwardRef((t,s)=>{const{__scopeTooltip:n,...r}=t,a=Su(Av,n),l=qb(Av,n),c=Sf(n),d=v.useRef(null),h=Ms(s,d,a.onTriggerChange),x=v.useRef(!1),f=v.useRef(!1),m=v.useCallback(()=>x.current=!1,[]);return v.useEffect(()=>()=>document.removeEventListener("pointerup",m),[m]),e.jsx(vu,{asChild:!0,...c,children:e.jsx(ps.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:h,onPointerMove:Vt(t.onPointerMove,p=>{p.pointerType!=="touch"&&!f.current&&!l.isPointerInTransitRef.current&&(a.onTriggerEnter(),f.current=!0)}),onPointerLeave:Vt(t.onPointerLeave,()=>{a.onTriggerLeave(),f.current=!1}),onPointerDown:Vt(t.onPointerDown,()=>{a.open&&a.onClose(),x.current=!0,document.addEventListener("pointerup",m,{once:!0})}),onFocus:Vt(t.onFocus,()=>{x.current||a.onOpen()}),onBlur:Vt(t.onBlur,a.onClose),onClick:Vt(t.onClick,a.onClose)})})});vE.displayName=Av;var zb="TooltipPortal",[H$,W$]=wf(zb,{forceMount:void 0}),bE=t=>{const{__scopeTooltip:s,forceMount:n,children:r,container:a}=t,l=Su(zb,s);return e.jsx(H$,{scope:s,forceMount:n,children:e.jsx(mr,{present:n||l.open,children:e.jsx(Hc,{asChild:!0,container:a,children:r})})})};bE.displayName=zb;var Oc="TooltipContent",yE=v.forwardRef((t,s)=>{const n=W$(Oc,t.__scopeTooltip),{forceMount:r=n.forceMount,side:a="top",...l}=t,c=Su(Oc,t.__scopeTooltip);return e.jsx(mr,{present:r||c.open,children:c.disableHoverableContent?e.jsx(jE,{side:a,...l,ref:s}):e.jsx(G$,{side:a,...l,ref:s})})}),G$=v.forwardRef((t,s)=>{const n=Su(Oc,t.__scopeTooltip),r=qb(Oc,t.__scopeTooltip),a=v.useRef(null),l=Ms(s,a),[c,d]=v.useState(null),{trigger:h,onClose:x}=n,f=a.current,{onPointerInTransitChange:m}=r,p=v.useCallback(()=>{d(null),m(!1)},[m]),u=v.useCallback((j,g)=>{const y=j.currentTarget,N={x:j.clientX,y:j.clientY},S=Q$(N,y.getBoundingClientRect()),C=X$(N,S),w=J$(g.getBoundingClientRect()),R=tq([...C,...w]);d(R),m(!0)},[m]);return v.useEffect(()=>()=>p(),[p]),v.useEffect(()=>{if(h&&f){const j=y=>u(y,f),g=y=>u(y,h);return h.addEventListener("pointerleave",j),f.addEventListener("pointerleave",g),()=>{h.removeEventListener("pointerleave",j),f.removeEventListener("pointerleave",g)}}},[h,f,u,p]),v.useEffect(()=>{if(c){const j=g=>{const y=g.target,N={x:g.clientX,y:g.clientY},S=(h==null?void 0:h.contains(y))||(f==null?void 0:f.contains(y)),C=!eq(N,c);S?p():C&&(p(),x())};return document.addEventListener("pointermove",j),()=>document.removeEventListener("pointermove",j)}},[h,f,c,x,p]),e.jsx(jE,{...t,ref:l})}),[K$,Y$]=wf(tu,{isInside:!1}),Z$=q$("TooltipContent"),jE=v.forwardRef((t,s)=>{const{__scopeTooltip:n,children:r,"aria-label":a,onEscapeKeyDown:l,onPointerDownOutside:c,...d}=t,h=Su(Oc,n),x=Sf(n),{onClose:f}=h;return v.useEffect(()=>(document.addEventListener(Cv,f),()=>document.removeEventListener(Cv,f)),[f]),v.useEffect(()=>{if(h.trigger){const m=p=>{const u=p.target;u!=null&&u.contains(h.trigger)&&f()};return window.addEventListener("scroll",m,{capture:!0}),()=>window.removeEventListener("scroll",m,{capture:!0})}},[h.trigger,f]),e.jsx(zc,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:m=>m.preventDefault(),onDismiss:f,children:e.jsxs(nf,{"data-state":h.stateAttribute,...x,...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(Z$,{children:r}),e.jsx(K$,{scope:n,isInside:!0,children:e.jsx(cB,{id:h.contentId,role:"tooltip",children:a||r})})]})})});yE.displayName=Oc;var NE="TooltipArrow",wE=v.forwardRef((t,s)=>{const{__scopeTooltip:n,...r}=t,a=Sf(n);return Y$(NE,n).isInside?null:e.jsx(rf,{...a,...r,ref:s})});wE.displayName=NE;function Q$(t,s){const n=Math.abs(s.top-t.y),r=Math.abs(s.bottom-t.y),a=Math.abs(s.right-t.x),l=Math.abs(s.left-t.x);switch(Math.min(n,r,a,l)){case l:return"left";case a:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function X$(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 J$(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 eq(t,s){const{x:n,y:r}=t;let a=!1;for(let l=0,c=s.length-1;l<s.length;c=l++){const d=s[l],h=s[c],x=d.x,f=d.y,m=h.x,p=h.y;f>r!=p>r&&n<(m-x)*(r-f)/(p-f)+x&&(a=!a)}return a}function tq(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),sq(s)}function sq(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 l=s[s.length-1],c=s[s.length-2];if((l.x-c.x)*(a.y-c.y)>=(l.y-c.y)*(a.x-c.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 l=n[n.length-1],c=n[n.length-2];if((l.x-c.x)*(a.y-c.y)>=(l.y-c.y)*(a.x-c.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 nq=xE,rq=gE,aq=vE,iq=bE,lq=yE,oq=wE;function Cf({delayDuration:t=0,...s}){return e.jsx(nq,{"data-slot":"tooltip-provider",delayDuration:t,...s})}function Ub({...t}){return e.jsx(Cf,{children:e.jsx(rq,{"data-slot":"tooltip",...t})})}function Vb({...t}){return e.jsx(aq,{"data-slot":"tooltip-trigger",...t})}function Hb({className:t,sideOffset:s=0,children:n,...r}){return e.jsx(iq,{children:e.jsxs(lq,{"data-slot":"tooltip-content",sideOffset:s,className:Pt("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(oq,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const cq=({isOpen:t,onOpenChange:s,editingASMId:n,asmManagerId:r,setAsmManagerId:a,asmStatus:l,setAsmStatus:c,selectedASMZone:d,setSelectedASMZone:h,selectedASMRegion:x,setSelectedASMRegion:f,selectedASMStates:m,setSelectedASMStates:p,selectedASMDistricts:u,setSelectedASMDistricts:j,onSave:g,asmRoleCode:y,userAssignedData:N,districtsAssignedToOthers:S,getDistrictsForSelectedState:C})=>{const{zones:w,regionalOffices:R}=Nn(A=>A.master),P=N.filter(A=>{const I=(A.allRoles||[]).map(T=>String(T||"").toUpperCase()),$=String(A.roleCode||"").toUpperCase();return I.includes("DD-AM")||$==="DD-AM"});return gt.useEffect(()=>{if(r&&t){const A=N.find(I=>I.id===r);if(A&&A.territoryProfile){const I=A.territoryProfile.filter($=>$.roleCode===y&&$.locationType==="district").map($=>$.locationId);I.length>0&&j(I)}}},[r,y,t,N,j]),e.jsx(os,{open:t,onOpenChange:s,children:e.jsxs(ls,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ms,{children:[e.jsxs(us,{children:[n?"Edit":"Add"," DD Area Manager"]}),e.jsx(vs,{children:"Configure DD-AM details and district assignment"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ce,{children:"Zone"}),e.jsxs(wt,{value:d,onValueChange:A=>{h(A),f(""),p([]),j([])},children:[e.jsx(Ct,{className:"mt-2 text-slate-900",children:e.jsx(St,{placeholder:"Select zone"})}),e.jsx(At,{children:w.map(A=>e.jsx(Pe,{value:A.id,children:A.name},A.id))})]})]}),d&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ce,{children:"Regional Office"}),e.jsxs(wt,{value:x,onValueChange:A=>{f(A),p([]),j([])},children:[e.jsx(Ct,{className:"mt-2 text-slate-900",children:e.jsx(St,{placeholder:"Select regional office"})}),e.jsx(At,{children:R.filter(A=>A.zoneId===d).map(A=>e.jsx(Pe,{value:A.id,children:A.name},A.id))})]})]}),e.jsxs("div",{children:[e.jsx(ce,{children:"Select DD-AM User"}),e.jsxs(wt,{value:r,onValueChange:a,children:[e.jsx(Ct,{className:"mt-2 text-slate-900",children:e.jsx(St,{placeholder:"Select DD-AM"})}),e.jsx(At,{className:"max-h-64",children:P.map(A=>e.jsxs(Pe,{value:A.id,children:[A.name," (",A.employeeId||"No ID",")"]},A.id))})]})]})]}),x&&e.jsxs("div",{children:[e.jsx(ce,{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($=>$.id===x),I=((A==null?void 0:A.states)||[]).map($=>typeof $=="string"?$:$.name);return I.length>0?e.jsx("div",{className:"space-y-2",children:I.map($=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Rn,{id:`asm-state-${$}`,checked:m.some(T=>T.toLowerCase()===$.toLowerCase()),onCheckedChange:T=>{if(T)p([...m,$]);else{p(m.filter(_=>_.toLowerCase()!==$.toLowerCase()));const E=C($);j(u.filter(_=>!E.some(M=>M.id===_)))}}}),e.jsx("label",{htmlFor:`asm-state-${$}`,className:"text-sm cursor-pointer text-slate-900",children:$})]},$))}):e.jsx("p",{className:"text-sm text-slate-500",children:"No states available for this regional office"})})()})]}),m.length>0&&e.jsxs("div",{children:[e.jsx(ce,{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(Cf,{children:m.map(A=>{const I=C(A);return I.length===0?null:e.jsxs("div",{className:"mb-4 last:mb-0",children:[e.jsx("h4",{className:"text-sm text-amber-700 mb-2 pb-1 border-b border-slate-200",children:A}),e.jsx("div",{className:"space-y-2 ml-2",children:I.map($=>e.jsx("div",{children:e.jsxs(Ub,{children:[e.jsx(Vb,{asChild:!0,children:e.jsxs("div",{className:"flex items-center space-x-2 py-0.5",children:[e.jsx(Rn,{id:`asm-district-${$.id}`,checked:u.includes($.id),disabled:!!S[$.id],onCheckedChange:T=>{j(T?[...u,$.id]:u.filter(E=>E!==$.id))}}),e.jsx("label",{htmlFor:`asm-district-${$.id}`,className:`text-sm flex items-center gap-1.5 ${S[$.id]?"text-slate-400 cursor-not-allowed":"cursor-pointer text-slate-900"}`,children:$.name})]})}),S[$.id]&&e.jsx(Hb,{children:e.jsxs("p",{children:["Already managed by: ",S[$.id].join(", ")]})})]})},$.id))})]},A)})})})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs(ce,{children:["DD Area Manager ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(wt,{value:r,onValueChange:A=>{var $;a(A);const I=N.find(T=>T.id===A);if(I){const T=(I.territoryProfile||[]).find(E=>E.roleCode===y);T!=null&&T.zoneId&&h(T.zoneId),T!=null&&T.regionId&&f(T.regionId),j((($=I.areasManaged)==null?void 0:$.filter(E=>E.roleCode===y).map(E=>E.id))||[]),p(I.stateNames||[])}},disabled:!!n,children:[e.jsx(Ct,{className:"mt-2 w-full text-slate-900",children:e.jsx(St,{placeholder:"Select DD-AM User"})}),e.jsx(At,{className:"max-h-60",children:P.length>0?P.map(A=>e.jsx(Pe,{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(ce,{children:"Status"}),e.jsxs(wt,{value:l,onValueChange:A=>c(A),children:[e.jsx(Ct,{className:"mt-2 text-slate-900",children:e.jsx(St,{})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"active",children:"Active"}),e.jsx(Pe,{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-amber-600 hover:bg-amber-700",onClick:g,children:"Save DD-AM"})]})]})]})})};function dq(t){const s=uq(t),n=v.forwardRef((r,a)=>{const{children:l,...c}=r,d=v.Children.toArray(l),h=d.find(mq);if(h){const x=h.props.children,f=d.map(m=>m===h?v.Children.count(x)>1?v.Children.only(null):v.isValidElement(x)?x.props.children:null:m);return e.jsx(s,{...c,ref:a,children:v.isValidElement(x)?v.cloneElement(x,void 0,f):null})}return e.jsx(s,{...c,ref:a,children:l})});return n.displayName=`${t}.Slot`,n}function uq(t){const s=v.forwardRef((n,r)=>{const{children:a,...l}=n;if(v.isValidElement(a)){const c=pq(a),d=fq(l,a.props);return a.type!==v.Fragment&&(d.ref=r?Br(r,c):c),v.cloneElement(a,d)}return v.Children.count(a)>1?v.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var hq=Symbol("radix.slottable");function mq(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===hq}function fq(t,s){const n={...s};for(const r in s){const a=t[r],l=s[r];/^on[A-Z]/.test(r)?a&&l?n[r]=(...d)=>{const h=l(...d);return a(...d),h}:a&&(n[r]=a):r==="style"?n[r]={...a,...l}:r==="className"&&(n[r]=[a,l].filter(Boolean).join(" "))}return{...t,...n}}function pq(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 Af="Popover",[SE]=ea(Af,[Vl]),Cu=Vl(),[xq,eo]=SE(Af),CE=t=>{const{__scopePopover:s,children:n,open:r,defaultOpen:a,onOpenChange:l,modal:c=!1}=t,d=Cu(s),h=v.useRef(null),[x,f]=v.useState(!1),[m,p]=bi({prop:r,defaultProp:a??!1,onChange:l,caller:Af});return e.jsx(sf,{...d,children:e.jsx(xq,{scope:s,contentId:hr(),triggerRef:h,open:m,onOpenChange:p,onOpenToggle:v.useCallback(()=>p(u=>!u),[p]),hasCustomAnchor:x,onCustomAnchorAdd:v.useCallback(()=>f(!0),[]),onCustomAnchorRemove:v.useCallback(()=>f(!1),[]),modal:c,children:n})})};CE.displayName=Af;var AE="PopoverAnchor",gq=v.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=eo(AE,n),l=Cu(n),{onCustomAnchorAdd:c,onCustomAnchorRemove:d}=a;return v.useEffect(()=>(c(),()=>d()),[c,d]),e.jsx(vu,{...l,...r,ref:s})});gq.displayName=AE;var kE="PopoverTrigger",RE=v.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=eo(kE,n),l=Cu(n),c=Ms(s,a.triggerRef),d=e.jsx(ps.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":_E(a.open),...r,ref:c,onClick:Vt(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?d:e.jsx(vu,{asChild:!0,...l,children:d})});RE.displayName=kE;var Wb="PopoverPortal",[vq,bq]=SE(Wb,{forceMount:void 0}),EE=t=>{const{__scopePopover:s,forceMount:n,children:r,container:a}=t,l=eo(Wb,s);return e.jsx(vq,{scope:s,forceMount:n,children:e.jsx(mr,{present:n||l.open,children:e.jsx(Hc,{asChild:!0,container:a,children:r})})})};EE.displayName=Wb;var Ic="PopoverContent",DE=v.forwardRef((t,s)=>{const n=bq(Ic,t.__scopePopover),{forceMount:r=n.forceMount,...a}=t,l=eo(Ic,t.__scopePopover);return e.jsx(mr,{present:r||l.open,children:l.modal?e.jsx(jq,{...a,ref:s}):e.jsx(Nq,{...a,ref:s})})});DE.displayName=Ic;var yq=dq("PopoverContent.RemoveScroll"),jq=v.forwardRef((t,s)=>{const n=eo(Ic,t.__scopePopover),r=v.useRef(null),a=Ms(s,r),l=v.useRef(!1);return v.useEffect(()=>{const c=r.current;if(c)return lf(c)},[]),e.jsx(yu,{as:yq,allowPinchZoom:!0,children:e.jsx(TE,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Vt(t.onCloseAutoFocus,c=>{var d;c.preventDefault(),l.current||(d=n.triggerRef.current)==null||d.focus()}),onPointerDownOutside:Vt(t.onPointerDownOutside,c=>{const d=c.detail.originalEvent,h=d.button===0&&d.ctrlKey===!0,x=d.button===2||h;l.current=x},{checkForDefaultPrevented:!1}),onFocusOutside:Vt(t.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1})})})}),Nq=v.forwardRef((t,s)=>{const n=eo(Ic,t.__scopePopover),r=v.useRef(!1),a=v.useRef(!1);return e.jsx(TE,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:l=>{var c,d;(c=t.onCloseAutoFocus)==null||c.call(t,l),l.defaultPrevented||(r.current||(d=n.triggerRef.current)==null||d.focus(),l.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:l=>{var h,x;(h=t.onInteractOutside)==null||h.call(t,l),l.defaultPrevented||(r.current=!0,l.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const c=l.target;((x=n.triggerRef.current)==null?void 0:x.contains(c))&&l.preventDefault(),l.detail.originalEvent.type==="focusin"&&a.current&&l.preventDefault()}})}),TE=v.forwardRef((t,s)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:l,disableOutsidePointerEvents:c,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:x,onInteractOutside:f,...m}=t,p=eo(Ic,n),u=Cu(n);return Qm(),e.jsx(xu,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:l,children:e.jsx(zc,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:f,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:x,onDismiss:()=>p.onOpenChange(!1),children:e.jsx(nf,{"data-state":_E(p.open),role:"dialog",id:p.contentId,...u,...m,ref:s,style:{...m.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)"}})})})}),PE="PopoverClose",wq=v.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=eo(PE,n);return e.jsx(ps.button,{type:"button",...r,ref:s,onClick:Vt(t.onClick,()=>a.onOpenChange(!1))})});wq.displayName=PE;var Sq="PopoverArrow",Cq=v.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=Cu(n);return e.jsx(rf,{...a,...r,ref:s})});Cq.displayName=Sq;function _E(t){return t?"open":"closed"}var Aq=CE,kq=RE,Rq=EE,Eq=DE;function Dq({...t}){return e.jsx(Aq,{"data-slot":"popover",...t})}function Tq({...t}){return e.jsx(kq,{"data-slot":"popover-trigger",...t})}function Pq({className:t,align:s="center",sideOffset:n=4,...r}){return e.jsx(Rq,{children:e.jsx(Eq,{"data-slot":"popover-content",align:s,sideOffset:n,className:Pt("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 p1=1,_q=.9,Oq=.8,Iq=.17,Xx=.1,Jx=.999,Lq=.9999,Mq=.99,Fq=/[\\\/_+.#"@\[\(\{&]/,Bq=/[\\\/_+.#"@\[\(\{&]/g,$q=/[\s-]/,OE=/[\s-]/g;function kv(t,s,n,r,a,l,c){if(l===s.length)return a===t.length?p1:Mq;var d=`${a},${l}`;if(c[d]!==void 0)return c[d];for(var h=r.charAt(l),x=n.indexOf(h,a),f=0,m,p,u,j;x>=0;)m=kv(t,s,n,r,x+1,l+1,c),m>f&&(x===a?m*=p1:Fq.test(t.charAt(x-1))?(m*=Oq,u=t.slice(a,x-1).match(Bq),u&&a>0&&(m*=Math.pow(Jx,u.length))):$q.test(t.charAt(x-1))?(m*=_q,j=t.slice(a,x-1).match(OE),j&&a>0&&(m*=Math.pow(Jx,j.length))):(m*=Iq,a>0&&(m*=Math.pow(Jx,x-a))),t.charAt(x)!==s.charAt(l)&&(m*=Lq)),(m<Xx&&n.charAt(x-1)===r.charAt(l+1)||r.charAt(l+1)===r.charAt(l)&&n.charAt(x-1)!==r.charAt(l))&&(p=kv(t,s,n,r,x+1,l+2,c),p*Xx>m&&(m=p*Xx)),m>f&&(f=m),x=n.indexOf(h,x+1);return c[d]=f,f}function x1(t){return t.toLowerCase().replace(OE," ")}function qq(t,s,n){return t=n&&n.length>0?`${t+" "+n.join(" ")}`:t,kv(t,s,x1(t),x1(s),0,0,{})}var Rd='[cmdk-group=""]',eg='[cmdk-group-items=""]',zq='[cmdk-group-heading=""]',IE='[cmdk-item=""]',g1=`${IE}:not([aria-disabled="true"])`,Rv="cmdk-item-select",jc="data-value",Uq=(t,s,n)=>qq(t,s,n),LE=v.createContext(void 0),Au=()=>v.useContext(LE),ME=v.createContext(void 0),Gb=()=>v.useContext(ME),FE=v.createContext(void 0),BE=v.forwardRef((t,s)=>{let n=Nc(()=>{var O,V;return{search:"",value:(V=(O=t.value)!=null?O:t.defaultValue)!=null?V:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Nc(()=>new Set),a=Nc(()=>new Map),l=Nc(()=>new Map),c=Nc(()=>new Set),d=$E(t),{label:h,children:x,value:f,onValueChange:m,filter:p,shouldFilter:u,loop:j,disablePointerSelection:g=!1,vimBindings:y=!0,...N}=t,S=hr(),C=hr(),w=hr(),R=v.useRef(null),P=ez();Uo(()=>{if(f!==void 0){let O=f.trim();n.current.value=O,A.emit()}},[f]),Uo(()=>{P(6,M)},[]);let A=v.useMemo(()=>({subscribe:O=>(c.current.add(O),()=>c.current.delete(O)),snapshot:()=>n.current,setState:(O,V,K)=>{var Y,U,X,ne;if(!Object.is(n.current[O],V)){if(n.current[O]=V,O==="search")_(),T(),P(1,E);else if(O==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let oe=document.getElementById(w);oe?oe.focus():(Y=document.getElementById(S))==null||Y.focus()}if(P(7,()=>{var oe;n.current.selectedItemId=(oe=q())==null?void 0:oe.id,A.emit()}),K||P(5,M),((U=d.current)==null?void 0:U.value)!==void 0){let oe=V??"";(ne=(X=d.current).onValueChange)==null||ne.call(X,oe);return}}A.emit()}},emit:()=>{c.current.forEach(O=>O())}}),[]),I=v.useMemo(()=>({value:(O,V,K)=>{var Y;V!==((Y=l.current.get(O))==null?void 0:Y.value)&&(l.current.set(O,{value:V,keywords:K}),n.current.filtered.items.set(O,$(V,K)),P(2,()=>{T(),A.emit()}))},item:(O,V)=>(r.current.add(O),V&&(a.current.has(V)?a.current.get(V).add(O):a.current.set(V,new Set([O]))),P(3,()=>{_(),T(),n.current.value||E(),A.emit()}),()=>{l.current.delete(O),r.current.delete(O),n.current.filtered.items.delete(O);let K=q();P(4,()=>{_(),(K==null?void 0:K.getAttribute("id"))===O&&E(),A.emit()})}),group:O=>(a.current.has(O)||a.current.set(O,new Set),()=>{l.current.delete(O),a.current.delete(O)}),filter:()=>d.current.shouldFilter,label:h||t["aria-label"],getDisablePointerSelection:()=>d.current.disablePointerSelection,listId:S,inputId:w,labelId:C,listInnerRef:R}),[]);function $(O,V){var K,Y;let U=(Y=(K=d.current)==null?void 0:K.filter)!=null?Y:Uq;return O?U(O,n.current.search,V):0}function T(){if(!n.current.search||d.current.shouldFilter===!1)return;let O=n.current.filtered.items,V=[];n.current.filtered.groups.forEach(Y=>{let U=a.current.get(Y),X=0;U.forEach(ne=>{let oe=O.get(ne);X=Math.max(oe,X)}),V.push([Y,X])});let K=R.current;G().sort((Y,U)=>{var X,ne;let oe=Y.getAttribute("id"),re=U.getAttribute("id");return((X=O.get(re))!=null?X:0)-((ne=O.get(oe))!=null?ne:0)}).forEach(Y=>{let U=Y.closest(eg);U?U.appendChild(Y.parentElement===U?Y:Y.closest(`${eg} > *`)):K.appendChild(Y.parentElement===K?Y:Y.closest(`${eg} > *`))}),V.sort((Y,U)=>U[1]-Y[1]).forEach(Y=>{var U;let X=(U=R.current)==null?void 0:U.querySelector(`${Rd}[${jc}="${encodeURIComponent(Y[0])}"]`);X==null||X.parentElement.appendChild(X)})}function E(){let O=G().find(K=>K.getAttribute("aria-disabled")!=="true"),V=O==null?void 0:O.getAttribute(jc);A.setState("value",V||void 0)}function _(){var O,V,K,Y;if(!n.current.search||d.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let U=0;for(let X of r.current){let ne=(V=(O=l.current.get(X))==null?void 0:O.value)!=null?V:"",oe=(Y=(K=l.current.get(X))==null?void 0:K.keywords)!=null?Y:[],re=$(ne,oe);n.current.filtered.items.set(X,re),re>0&&U++}for(let[X,ne]of a.current)for(let oe of ne)if(n.current.filtered.items.get(oe)>0){n.current.filtered.groups.add(X);break}n.current.filtered.count=U}function M(){var O,V,K;let Y=q();Y&&(((O=Y.parentElement)==null?void 0:O.firstChild)===Y&&((K=(V=Y.closest(Rd))==null?void 0:V.querySelector(zq))==null||K.scrollIntoView({block:"nearest"})),Y.scrollIntoView({block:"nearest"}))}function q(){var O;return(O=R.current)==null?void 0:O.querySelector(`${IE}[aria-selected="true"]`)}function G(){var O;return Array.from(((O=R.current)==null?void 0:O.querySelectorAll(g1))||[])}function Z(O){let V=G()[O];V&&A.setState("value",V.getAttribute(jc))}function W(O){var V;let K=q(),Y=G(),U=Y.findIndex(ne=>ne===K),X=Y[U+O];(V=d.current)!=null&&V.loop&&(X=U+O<0?Y[Y.length-1]:U+O===Y.length?Y[0]:Y[U+O]),X&&A.setState("value",X.getAttribute(jc))}function z(O){let V=q(),K=V==null?void 0:V.closest(Rd),Y;for(;K&&!Y;)K=O>0?Xq(K,Rd):Jq(K,Rd),Y=K==null?void 0:K.querySelector(g1);Y?A.setState("value",Y.getAttribute(jc)):W(O)}let F=()=>Z(G().length-1),B=O=>{O.preventDefault(),O.metaKey?F():O.altKey?z(1):W(1)},D=O=>{O.preventDefault(),O.metaKey?Z(0):O.altKey?z(-1):W(-1)};return v.createElement(ps.div,{ref:s,tabIndex:-1,...N,"cmdk-root":"",onKeyDown:O=>{var V;(V=N.onKeyDown)==null||V.call(N,O);let K=O.nativeEvent.isComposing||O.keyCode===229;if(!(O.defaultPrevented||K))switch(O.key){case"n":case"j":{y&&O.ctrlKey&&B(O);break}case"ArrowDown":{B(O);break}case"p":case"k":{y&&O.ctrlKey&&D(O);break}case"ArrowUp":{D(O);break}case"Home":{O.preventDefault(),Z(0);break}case"End":{O.preventDefault(),F();break}case"Enter":{O.preventDefault();let Y=q();if(Y){let U=new Event(Rv);Y.dispatchEvent(U)}}}}},v.createElement("label",{"cmdk-label":"",htmlFor:I.inputId,id:I.labelId,style:sz},h),kf(t,O=>v.createElement(ME.Provider,{value:A},v.createElement(LE.Provider,{value:I},O))))}),Vq=v.forwardRef((t,s)=>{var n,r;let a=hr(),l=v.useRef(null),c=v.useContext(FE),d=Au(),h=$E(t),x=(r=(n=h.current)==null?void 0:n.forceMount)!=null?r:c==null?void 0:c.forceMount;Uo(()=>{if(!x)return d.item(a,c==null?void 0:c.id)},[x]);let f=qE(a,l,[t.value,t.children,l],t.keywords),m=Gb(),p=zl(P=>P.value&&P.value===f.current),u=zl(P=>x||d.filter()===!1?!0:P.search?P.filtered.items.get(a)>0:!0);v.useEffect(()=>{let P=l.current;if(!(!P||t.disabled))return P.addEventListener(Rv,j),()=>P.removeEventListener(Rv,j)},[u,t.onSelect,t.disabled]);function j(){var P,A;g(),(A=(P=h.current).onSelect)==null||A.call(P,f.current)}function g(){m.setState("value",f.current,!0)}if(!u)return null;let{disabled:y,value:N,onSelect:S,forceMount:C,keywords:w,...R}=t;return v.createElement(ps.div,{ref:Br(l,s),...R,id:a,"cmdk-item":"",role:"option","aria-disabled":!!y,"aria-selected":!!p,"data-disabled":!!y,"data-selected":!!p,onPointerMove:y||d.getDisablePointerSelection()?void 0:g,onClick:y?void 0:j},t.children)}),Hq=v.forwardRef((t,s)=>{let{heading:n,children:r,forceMount:a,...l}=t,c=hr(),d=v.useRef(null),h=v.useRef(null),x=hr(),f=Au(),m=zl(u=>a||f.filter()===!1?!0:u.search?u.filtered.groups.has(c):!0);Uo(()=>f.group(c),[]),qE(c,d,[t.value,t.heading,h]);let p=v.useMemo(()=>({id:c,forceMount:a}),[a]);return v.createElement(ps.div,{ref:Br(d,s),...l,"cmdk-group":"",role:"presentation",hidden:m?void 0:!0},n&&v.createElement("div",{ref:h,"cmdk-group-heading":"","aria-hidden":!0,id:x},n),kf(t,u=>v.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?x:void 0},v.createElement(FE.Provider,{value:p},u))))}),Wq=v.forwardRef((t,s)=>{let{alwaysRender:n,...r}=t,a=v.useRef(null),l=zl(c=>!c.search);return!n&&!l?null:v.createElement(ps.div,{ref:Br(a,s),...r,"cmdk-separator":"",role:"separator"})}),Gq=v.forwardRef((t,s)=>{let{onValueChange:n,...r}=t,a=t.value!=null,l=Gb(),c=zl(x=>x.search),d=zl(x=>x.selectedItemId),h=Au();return v.useEffect(()=>{t.value!=null&&l.setState("search",t.value)},[t.value]),v.createElement(ps.input,{ref:s,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":h.listId,"aria-labelledby":h.labelId,"aria-activedescendant":d,id:h.inputId,type:"text",value:a?t.value:c,onChange:x=>{a||l.setState("search",x.target.value),n==null||n(x.target.value)}})}),Kq=v.forwardRef((t,s)=>{let{children:n,label:r="Suggestions",...a}=t,l=v.useRef(null),c=v.useRef(null),d=zl(x=>x.selectedItemId),h=Au();return v.useEffect(()=>{if(c.current&&l.current){let x=c.current,f=l.current,m,p=new ResizeObserver(()=>{m=requestAnimationFrame(()=>{let u=x.offsetHeight;f.style.setProperty("--cmdk-list-height",u.toFixed(1)+"px")})});return p.observe(x),()=>{cancelAnimationFrame(m),p.unobserve(x)}}},[]),v.createElement(ps.div,{ref:Br(l,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":d,"aria-label":r,id:h.listId},kf(t,x=>v.createElement("div",{ref:Br(c,h.listInnerRef),"cmdk-list-sizer":""},x)))}),Yq=v.forwardRef((t,s)=>{let{open:n,onOpenChange:r,overlayClassName:a,contentClassName:l,container:c,...d}=t;return v.createElement(Pb,{open:n,onOpenChange:r},v.createElement(_b,{container:c},v.createElement(vf,{"cmdk-overlay":"",className:a}),v.createElement(bf,{"aria-label":t.label,"cmdk-dialog":"",className:l},v.createElement(BE,{ref:s,...d}))))}),Zq=v.forwardRef((t,s)=>zl(n=>n.filtered.count===0)?v.createElement(ps.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),Qq=v.forwardRef((t,s)=>{let{progress:n,children:r,label:a="Loading...",...l}=t;return v.createElement(ps.div,{ref:s,...l,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},kf(t,c=>v.createElement("div",{"aria-hidden":!0},c)))}),Kc=Object.assign(BE,{List:Kq,Item:Vq,Input:Gq,Group:Hq,Separator:Wq,Dialog:Yq,Empty:Zq,Loading:Qq});function Xq(t,s){let n=t.nextElementSibling;for(;n;){if(n.matches(s))return n;n=n.nextElementSibling}}function Jq(t,s){let n=t.previousElementSibling;for(;n;){if(n.matches(s))return n;n=n.previousElementSibling}}function $E(t){let s=v.useRef(t);return Uo(()=>{s.current=t}),s}var Uo=typeof window>"u"?v.useEffect:v.useLayoutEffect;function Nc(t){let s=v.useRef();return s.current===void 0&&(s.current=t()),s}function zl(t){let s=Gb(),n=()=>t(s.snapshot());return v.useSyncExternalStore(s.subscribe,n,n)}function qE(t,s,n,r=[]){let a=v.useRef(),l=Au();return Uo(()=>{var c;let d=(()=>{var x;for(let f of n){if(typeof f=="string")return f.trim();if(typeof f=="object"&&"current"in f)return f.current?(x=f.current.textContent)==null?void 0:x.trim():a.current}})(),h=r.map(x=>x.trim());l.value(t,d,h),(c=s.current)==null||c.setAttribute(jc,d),a.current=d}),a}var ez=()=>{let[t,s]=v.useState(),n=Nc(()=>new Map);return Uo(()=>{n.current.forEach(r=>r()),n.current=new Map},[t]),(r,a)=>{n.current.set(r,a),s({})}};function tz(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function kf({asChild:t,children:s},n){return t&&v.isValidElement(s)?v.cloneElement(tz(s),{ref:s.ref},n(s.props.children)):n(s)}var sz={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function nz({className:t,...s}){return e.jsx(Kc,{"data-slot":"command",className:Pt("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",t),...s})}function rz({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(Ra,{className:"size-4 shrink-0 opacity-50"}),e.jsx(Kc.Input,{"data-slot":"command-input",className:Pt("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 az({className:t,...s}){return e.jsx(Kc.List,{"data-slot":"command-list",className:Pt("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),...s})}function iz({...t}){return e.jsx(Kc.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...t})}function lz({className:t,...s}){return e.jsx(Kc.Group,{"data-slot":"command-group",className:Pt("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 v1({className:t,...s}){return e.jsx(Kc.Item,{"data-slot":"command-item",className:Pt("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 oz=({value:t,onChange:s,asmUsers:n,className:r})=>{const[a,l]=v.useState(!1),c=n.find(d=>d.id===t);return e.jsxs(Dq,{open:a,onOpenChange:l,children:[e.jsx(Tq,{asChild:!0,children:e.jsxs(se,{variant:"outline",role:"combobox","aria-expanded":a,className:Pt("w-full min-w-0 justify-between",r),children:[e.jsx("span",{className:"truncate text-left",children:t==="__none__"?"Unassign":c?`${c.fullName} (${c.employeeId||c.email})`:"Select ASM"}),e.jsx(Y5,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Pq,{className:"w-[360px] max-w-[90vw] p-0",children:e.jsxs(nz,{children:[e.jsx(rz,{placeholder:"Search ASM by name/email/id..."}),e.jsxs(az,{className:"max-h-64 overflow-y-auto custom-scrollbar-slim",children:[e.jsx(iz,{children:"No ASM found."}),e.jsxs(lz,{children:[e.jsxs(v1,{value:"Unassign __none__",onSelect:()=>{s("__none__"),l(!1)},children:[e.jsx(Bn,{className:Pt("mr-2 h-4 w-4",t==="__none__"?"opacity-100":"opacity-0")}),"Unassign"]}),n.map(d=>e.jsxs(v1,{value:`${d.fullName} ${d.email} ${d.employeeId||""}`,onSelect:()=>{s(d.id),l(!1)},children:[e.jsx(Bn,{className:Pt("mr-2 h-4 w-4",t===d.id?"opacity-100":"opacity-0")}),d.fullName," (",d.employeeId||d.email,")"]},d.id))]})]})]})})]})},cz=()=>{const[t,s]=v.useState(!1),[n,r]=v.useState([]),[a,l]=v.useState([]),[c,d]=v.useState({}),h=async()=>{var m,p,u,j;try{s(!0);const g=await Ss.getDealerAsmMappings();g!=null&&g.success&&(r(((m=g.data)==null?void 0:m.dealers)||[]),l(((p=g.data)==null?void 0:p.asmUsers)||[]))}catch(g){ee.error(((j=(u=g==null?void 0:g.response)==null?void 0:u.data)==null?void 0:j.message)||"Failed to load dealer ASM mappings")}finally{s(!1)}};v.useEffect(()=>{h()},[]);const x=v.useMemo(()=>[...n].sort((m,p)=>{const u=String(m.status||"").toLowerCase()==="active",j=String(p.status||"").toLowerCase()==="active";return u!==j?u?-1:1:String(m.dealerName||"").localeCompare(String(p.dealerName||""))}),[n]),f=async m=>{var u,j;const p=c[m]||"";try{const g=await Ss.saveDealerAsmMapping({dealerId:m,asmUserId:p==="__none__"?null:p||null});g!=null&&g.success?(ee.success(g.message||"Dealer ASM mapping updated"),await h()):ee.error((g==null?void 0:g.message)||"Failed to save mapping")}catch(g){ee.error(((j=(u=g==null?void 0:g.response)==null?void 0:u.data)==null?void 0:j.message)||"Failed to save mapping")}};return e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"Dealer-Level ASM Assignment"}),e.jsx(Zt,{children:"Assign Sales ASM to onboarded dealers. DD-AM remains district-level in the section above."})]}),e.jsx(Me,{children:t?e.jsx("p",{className:"text-sm text-slate-500",children:"Loading mappings..."}):e.jsxs(ks,{className:"w-full",children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Dealer"}),e.jsx(me,{children:"Dealer Code"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Current ASM"}),e.jsx(me,{children:"Assign ASM"})]})}),e.jsxs(Es,{children:[x.length===0&&e.jsx(ct,{children:e.jsx(de,{colSpan:5,className:"text-center text-slate-500 py-8",children:"No dealers available for ASM mapping yet."})}),x.map(m=>{var p;return e.jsxs(ct,{children:[e.jsx(de,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:m.dealerName}),e.jsx("span",{className:"text-xs text-slate-500",children:m.legalName})]})}),e.jsx(de,{children:m.dealerCode||"N/A"}),e.jsx(de,{children:e.jsx(Ae,{variant:String(m.status||"").toLowerCase()==="active"?"default":"secondary",children:m.status||"Unknown"})}),e.jsx(de,{children:m.assignedAsm?e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("span",{children:m.assignedAsm.fullName}),e.jsx("span",{className:"text-xs text-slate-500 truncate",children:m.assignedAsm.employeeId||m.assignedAsm.email})]}):e.jsx("span",{className:"text-slate-400 text-sm",children:"Unassigned"})}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx(oz,{asmUsers:a,value:c[m.dealerId]??((p=m.assignedAsm)==null?void 0:p.id)??"__none__",onChange:u=>d(j=>({...j,[m.dealerId]:u})),className:"flex-1 min-w-[180px]"}),e.jsx(se,{size:"sm",className:"shrink-0",onClick:()=>f(m.dealerId),children:"Assign"})]})})]},m.dealerId)})]})]})})]})},dz=({isOpen:t,onOpenChange:s,editingZMId:n,zmManagerId:r,setZmManagerId:a,zmStatus:l,setZmStatus:c,selectedZone:d,setSelectedZone:h,selectedRegions:x,setSelectedRegions:f,onSave:m,userAssignedData:p})=>{const{zones:u,regionalOffices:j}=Nn(N=>N.master),g=p.filter(N=>(N.allRoles||[]).some(C=>{const w=(C||"").toUpperCase();return["ZM","ZONAL MANAGER","ZBH","ZONE BUSINESS HEAD","RM","RBM","REGIONAL MANAGER"].includes(w)||w.includes("ZONAL")||w.includes("REGIONAL")})),y=j.filter(N=>N.zoneId===d);return e.jsx(os,{open:t,onOpenChange:s,children:e.jsxs(ls,{className:"max-w-xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ms,{children:[e.jsxs(us,{children:[n?"Edit":"Add"," Zonal Manager"]}),e.jsx(vs,{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(ce,{children:["Select Zonal Manager User ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(wt,{value:r,onValueChange:N=>{a(N);const S=p.find(C=>C.id===N);S&&(S.zoneId&&h(S.zoneId),S.assignedRegionIds&&f(S.assignedRegionIds))},disabled:!!n,children:[e.jsx(Ct,{className:"mt-2 w-full text-slate-900 border-slate-200",children:e.jsx(St,{placeholder:"Select ZM User"})}),e.jsx(At,{className:"max-h-60",children:g.map(N=>e.jsx(Pe,{value:N.id,children:e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("span",{className:"font-medium text-slate-900",children:N.name}),e.jsx("span",{className:"text-xs text-slate-500",children:N.email})]})},N.id))})]})]}),e.jsxs("div",{children:[e.jsxs(ce,{children:["Managed Zone ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(wt,{value:d,onValueChange:N=>{h(N),f([])},children:[e.jsx(Ct,{className:"mt-2",children:e.jsx(St,{placeholder:"Select zone"})}),e.jsx(At,{children:u.map(N=>e.jsx(Pe,{value:N.id,children:N.name},N.id))})]})]}),d&&e.jsxs("div",{children:[e.jsxs(ce,{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:[y.map(N=>e.jsxs("div",{className:"flex items-center space-x-3 p-2 rounded hover:bg-white transition-colors",children:[e.jsx(Rn,{id:`region-${N.id}`,checked:x.includes(N.id),onCheckedChange:S=>{f(S?[...x,N.id]:x.filter(C=>C!==N.id))}}),e.jsxs("label",{htmlFor:`region-${N.id}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer flex-1",children:[N.name,e.jsx("span",{className:"text-xs text-slate-500 block mt-1",children:N.code||"No Code"})]})]},N.id)),y.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(ce,{children:"Status"}),e.jsxs(wt,{value:l,onValueChange:N=>c(N),children:[e.jsx(Ct,{className:"mt-2",children:e.jsx(St,{})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"active",children:"Active"}),e.jsx(Pe,{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-amber-600 hover:bg-amber-700",onClick:m,children:"Save Zonal Manager"})]})]})]})})},uz=({isOpen:t,onOpenChange:s,editingZoneId:n,zoneName:r,setZoneName:a,zoneCode:l,setZoneCode:c,zoneDescription:d,setZoneDescription:h,zonalBusinessHeadId:x,setZonalBusinessHeadId:f,userAssignedData:m,onSave:p})=>{const u=(m||[]).filter(g=>{if(x!=="none"&&g.id===x)return!0;const y=(g.allRoles||[]).map(S=>String(S||"").toUpperCase()),N=String(g.roleCode||g.role||"").toUpperCase();return N==="ZBH"||N.includes("ZONAL BUSINESS HEAD")||y.some(S=>{const C=String(S||"").toUpperCase();return C==="ZBH"||C==="ZONE BUSINESS HEAD"||C==="ZONAL BUSINESS HEAD"})}),j=u.length>0?u:m||[];return gt.useEffect(()=>{},[n,t]),e.jsx(os,{open:t,onOpenChange:s,children:e.jsxs(ls,{className:"max-w-md",children:[e.jsxs(ms,{children:[e.jsxs(us,{children:[n?"Edit":"Add"," Zone"]}),e.jsx(vs,{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(ce,{children:"Zone Name"}),e.jsx(ot,{placeholder:"e.g., North Zone",className:"mt-2 text-slate-900",value:r,onChange:g=>a(g.target.value)})]}),e.jsxs("div",{children:[e.jsx(ce,{children:"Zone Code"}),e.jsx(ot,{placeholder:"e.g., NZ",className:"mt-2 text-slate-900",value:l,onChange:g=>c(g.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(ce,{children:"Zonal Business Head"}),e.jsxs(wt,{value:x,onValueChange:f,children:[e.jsx(Ct,{className:"mt-2 w-full text-slate-900",children:e.jsx(St,{placeholder:"Select Head"})}),e.jsxs(At,{className:"max-h-60",children:[e.jsx(Pe,{value:"none",children:"None / Unassigned"}),j.map(g=>e.jsxs(Pe,{value:g.id,children:[g.name," (",g.email,")"]},g.id))]})]})]}),e.jsxs("div",{children:[e.jsx(ce,{children:"Description"}),e.jsx(Fs,{placeholder:"Describe the zone's coverage...",className:"mt-2 text-slate-900",rows:3,value:d,onChange:g=>h(g.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-amber-600 hover:bg-amber-700",onClick:p,children:"Save Zone"})]})]})]})})},hz=({isOpen:t,onOpenChange:s,editingRegionId:n,regionName:r,setRegionName:a,regionDescription:l,setRegionDescription:c,selectedRegionZone:d,setSelectedRegionZone:h,regionalManagerId:x,setRegionalManagerId:f,selectedRegionStates:m,setSelectedRegionStates:p,onSave:u,userAssignedData:j})=>{const{zones:g,allStates:y,allDistricts:N,regionalOffices:S}=Nn(E=>E.master),[C,w]=gt.useState([]),R=gt.useMemo(()=>{const E={};return(S||[]).forEach(_=>{_.id!==n&&(_.districts||[]).forEach(M=>{E[M.id]=_.name})}),E},[S,n]),P=gt.useMemo(()=>{if(!d)return y;const E=new Set(N.filter(_=>_.zoneId===d||!_.zoneId||m.includes(_.id)).map(_=>_.stateId).filter(Boolean));return y.filter(_=>_.zoneId===d||E.has(_.id)||!_.zoneId)},[y,N,d,m]),A=gt.useMemo(()=>C.length===0?[]:N.filter(E=>C.includes(E.stateId)&&(!E.zoneId||E.zoneId===d||E.regionId===n)),[N,C,d,n]),I=gt.useMemo(()=>{const E={};return A.forEach(_=>{const M=y.find(G=>G.id===_.stateId),q=(M==null?void 0:M.name)||_.stateId;E[_.stateId]||(E[_.stateId]={stateName:q,districts:[]}),E[_.stateId].districts.push(_)}),Object.values(E)},[A,y]);gt.useEffect(()=>{if(!t){w([]);return}if(m.length>0){const E=Array.from(new Set(N.filter(_=>m.includes(_.id)).map(_=>_.stateId).filter(Boolean)));w(E)}},[t]);const $=E=>{h(E),w([]),p([])},T=(E,_)=>{if(_)w(M=>[...M,E]);else{w(q=>q.filter(G=>G!==E));const M=N.filter(q=>q.stateId===E).map(q=>q.id);p(m.filter(q=>!M.includes(q)))}};return e.jsx(os,{open:t,onOpenChange:s,children:e.jsxs(ls,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ms,{children:[e.jsxs(us,{children:[n?"Edit":"Add"," Regional Office"]}),e.jsx(vs,{children:"Configure regional office details and coverage area"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ce,{children:"Region Name"}),e.jsx(ot,{placeholder:"e.g., Delhi NCR Region",className:"mt-2 text-slate-900",value:r,onChange:E=>a(E.target.value)})]}),e.jsxs("div",{children:[e.jsx(ce,{children:"Zone"}),e.jsxs(wt,{value:d,onValueChange:$,children:[e.jsx(Ct,{className:"mt-2 text-slate-900",children:e.jsx(St,{placeholder:"Select zone"})}),e.jsx(At,{children:g.map(E=>e.jsx(Pe,{value:E.id,children:E.name},E.id))})]})]}),e.jsxs("div",{children:[e.jsx(ce,{children:"Regional Manager"}),e.jsxs(wt,{value:x,onValueChange:f,children:[e.jsx(Ct,{className:"mt-2 w-full text-slate-900",children:e.jsx(St,{placeholder:"Select from available users"})}),e.jsx(At,{className:"max-h-60",children:j.map(E=>e.jsxs(Pe,{value:E.id,children:[E.name||E.fullName,E.email?` — ${E.email}`:""]},E.id))})]})]}),e.jsxs("div",{children:[e.jsx(ce,{children:"Description"}),e.jsx(Fs,{placeholder:"Describe the region...",className:"mt-2 text-slate-900",rows:2,value:l,onChange:E=>c(E.target.value)})]}),e.jsxs("div",{children:[e.jsx(ce,{children:"States Covered"}),!d&&e.jsx("p",{className:"text-xs text-amber-600 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:P.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:P.map(E=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Rn,{id:`region-state-${E.id}`,checked:C.includes(E.id),disabled:!d,onCheckedChange:_=>T(E.id,!!_)}),e.jsx("label",{htmlFor:`region-state-${E.id}`,className:`text-sm cursor-pointer ${d?"text-slate-900":"text-slate-400"}`,children:E.name})]},E.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(ce,{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"}):I.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(Cf,{children:I.map(({stateName:E,districts:_})=>e.jsxs("div",{className:"mb-4 last:mb-0",children:[e.jsx("h4",{className:"text-xs font-semibold text-amber-700 uppercase tracking-wide mb-2 pb-1 border-b border-slate-200",children:E}),e.jsx("div",{className:"space-y-2 ml-1",children:_.map(M=>{const q=R[M.id],G=M.zoneId&&M.zoneId!==d&&M.regionId!==n,Z=!!(q||G),W=q?`Already assigned to region: ${q}`:G?"Belongs to a different zone":"";return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(Ub,{children:[e.jsx(Vb,{asChild:!0,children:e.jsxs("div",{className:"flex items-center space-x-2 w-full",children:[e.jsx(Rn,{id:`region-district-${M.id}`,disabled:Z,checked:m.includes(M.id),onCheckedChange:z=>{p(z?[...m,M.id]:m.filter(F=>F!==M.id))}}),e.jsxs("label",{htmlFor:`region-district-${M.id}`,className:`text-sm flex-1 ${Z?"text-slate-400 cursor-not-allowed line-through":"text-slate-900 cursor-pointer"}`,children:[M.name,q&&e.jsxs("span",{className:"ml-2 text-xs text-red-400 font-normal no-underline",style:{textDecoration:"none"},children:["(in ",q,")"]})]})]})}),Z&&W&&e.jsx(Hb,{children:e.jsx("p",{className:"text-xs",children:W})})]})},M.id)})})]},E))})}),e.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:[m.length," ",m.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-amber-600 hover:bg-amber-700",onClick:u,children:"Save Regional Office"})]})]})]})})};var Rf="Switch",[mz]=ea(Rf),[fz,pz]=mz(Rf),zE=v.forwardRef((t,s)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:l,required:c,disabled:d,value:h="on",onCheckedChange:x,form:f,...m}=t,[p,u]=v.useState(null),j=Ms(s,C=>u(C)),g=v.useRef(!1),y=p?f||!!p.closest("form"):!0,[N,S]=bi({prop:a,defaultProp:l??!1,onChange:x,caller:Rf});return e.jsxs(fz,{scope:n,checked:N,disabled:d,children:[e.jsx(ps.button,{type:"button",role:"switch","aria-checked":N,"aria-required":c,"data-state":WE(N),"data-disabled":d?"":void 0,disabled:d,value:h,...m,ref:j,onClick:Vt(t.onClick,C=>{S(w=>!w),y&&(g.current=C.isPropagationStopped(),g.current||C.stopPropagation())})}),y&&e.jsx(HE,{control:p,bubbles:!g.current,name:r,value:h,checked:N,required:c,disabled:d,form:f,style:{transform:"translateX(-100%)"}})]})});zE.displayName=Rf;var UE="SwitchThumb",VE=v.forwardRef((t,s)=>{const{__scopeSwitch:n,...r}=t,a=pz(UE,n);return e.jsx(ps.span,{"data-state":WE(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:s})});VE.displayName=UE;var xz="SwitchBubbleInput",HE=v.forwardRef(({__scopeSwitch:t,control:s,checked:n,bubbles:r=!0,...a},l)=>{const c=v.useRef(null),d=Ms(c,l),h=Wv(n),x=Gv(s);return v.useEffect(()=>{const f=c.current;if(!f)return;const m=window.HTMLInputElement.prototype,u=Object.getOwnPropertyDescriptor(m,"checked").set;if(h!==n&&u){const j=new Event("click",{bubbles:r});u.call(f,n),f.dispatchEvent(j)}},[h,n,r]),e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:d,style:{...a.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});HE.displayName=xz;function WE(t){return t?"checked":"unchecked"}var gz=zE,vz=VE;function Ef({className:t,...s}){return e.jsx(gz,{"data-slot":"switch",className:Pt("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(vz,{"data-slot":"switch-thumb",className:Pt("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 tg,b1;function bz(){if(b1)return tg;b1=1;function t(){this.__data__=[],this.size=0}return tg=t,tg}var sg,y1;function GE(){if(y1)return sg;y1=1;function t(s,n){return s===n||s!==s&&n!==n}return sg=t,sg}var ng,j1;function Df(){if(j1)return ng;j1=1;var t=GE();function s(n,r){for(var a=n.length;a--;)if(t(n[a][0],r))return a;return-1}return ng=s,ng}var rg,N1;function yz(){if(N1)return rg;N1=1;var t=Df(),s=Array.prototype,n=s.splice;function r(a){var l=this.__data__,c=t(l,a);if(c<0)return!1;var d=l.length-1;return c==d?l.pop():n.call(l,c,1),--this.size,!0}return rg=r,rg}var ag,w1;function jz(){if(w1)return ag;w1=1;var t=Df();function s(n){var r=this.__data__,a=t(r,n);return a<0?void 0:r[a][1]}return ag=s,ag}var ig,S1;function Nz(){if(S1)return ig;S1=1;var t=Df();function s(n){return t(this.__data__,n)>-1}return ig=s,ig}var lg,C1;function wz(){if(C1)return lg;C1=1;var t=Df();function s(n,r){var a=this.__data__,l=t(a,n);return l<0?(++this.size,a.push([n,r])):a[l][1]=r,this}return lg=s,lg}var og,A1;function Tf(){if(A1)return og;A1=1;var t=bz(),s=yz(),n=jz(),r=Nz(),a=wz();function l(c){var d=-1,h=c==null?0:c.length;for(this.clear();++d<h;){var x=c[d];this.set(x[0],x[1])}}return l.prototype.clear=t,l.prototype.delete=s,l.prototype.get=n,l.prototype.has=r,l.prototype.set=a,og=l,og}var cg,k1;function Sz(){if(k1)return cg;k1=1;var t=Tf();function s(){this.__data__=new t,this.size=0}return cg=s,cg}var dg,R1;function Cz(){if(R1)return dg;R1=1;function t(s){var n=this.__data__,r=n.delete(s);return this.size=n.size,r}return dg=t,dg}var ug,E1;function Az(){if(E1)return ug;E1=1;function t(s){return this.__data__.get(s)}return ug=t,ug}var hg,D1;function kz(){if(D1)return hg;D1=1;function t(s){return this.__data__.has(s)}return hg=t,hg}var mg,T1;function KE(){if(T1)return mg;T1=1;var t=typeof Eo=="object"&&Eo&&Eo.Object===Object&&Eo;return mg=t,mg}var fg,P1;function sl(){if(P1)return fg;P1=1;var t=KE(),s=typeof self=="object"&&self&&self.Object===Object&&self,n=t||s||Function("return this")();return fg=n,fg}var pg,_1;function Kb(){if(_1)return pg;_1=1;var t=sl(),s=t.Symbol;return pg=s,pg}var xg,O1;function Rz(){if(O1)return xg;O1=1;var t=Kb(),s=Object.prototype,n=s.hasOwnProperty,r=s.toString,a=t?t.toStringTag:void 0;function l(c){var d=n.call(c,a),h=c[a];try{c[a]=void 0;var x=!0}catch{}var f=r.call(c);return x&&(d?c[a]=h:delete c[a]),f}return xg=l,xg}var gg,I1;function Ez(){if(I1)return gg;I1=1;var t=Object.prototype,s=t.toString;function n(r){return s.call(r)}return gg=n,gg}var vg,L1;function Pf(){if(L1)return vg;L1=1;var t=Kb(),s=Rz(),n=Ez(),r="[object Null]",a="[object Undefined]",l=t?t.toStringTag:void 0;function c(d){return d==null?d===void 0?a:r:l&&l in Object(d)?s(d):n(d)}return vg=c,vg}var bg,M1;function YE(){if(M1)return bg;M1=1;function t(s){var n=typeof s;return s!=null&&(n=="object"||n=="function")}return bg=t,bg}var yg,F1;function ZE(){if(F1)return yg;F1=1;var t=Pf(),s=YE(),n="[object AsyncFunction]",r="[object Function]",a="[object GeneratorFunction]",l="[object Proxy]";function c(d){if(!s(d))return!1;var h=t(d);return h==r||h==a||h==n||h==l}return yg=c,yg}var jg,B1;function Dz(){if(B1)return jg;B1=1;var t=sl(),s=t["__core-js_shared__"];return jg=s,jg}var Ng,$1;function Tz(){if($1)return Ng;$1=1;var t=Dz(),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 Ng=n,Ng}var wg,q1;function QE(){if(q1)return wg;q1=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 wg=n,wg}var Sg,z1;function Pz(){if(z1)return Sg;z1=1;var t=ZE(),s=Tz(),n=YE(),r=QE(),a=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,c=Function.prototype,d=Object.prototype,h=c.toString,x=d.hasOwnProperty,f=RegExp("^"+h.call(x).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(p){if(!n(p)||s(p))return!1;var u=t(p)?f:l;return u.test(r(p))}return Sg=m,Sg}var Cg,U1;function _z(){if(U1)return Cg;U1=1;function t(s,n){return s==null?void 0:s[n]}return Cg=t,Cg}var Ag,V1;function Yc(){if(V1)return Ag;V1=1;var t=Pz(),s=_z();function n(r,a){var l=s(r,a);return t(l)?l:void 0}return Ag=n,Ag}var kg,H1;function Yb(){if(H1)return kg;H1=1;var t=Yc(),s=sl(),n=t(s,"Map");return kg=n,kg}var Rg,W1;function _f(){if(W1)return Rg;W1=1;var t=Yc(),s=t(Object,"create");return Rg=s,Rg}var Eg,G1;function Oz(){if(G1)return Eg;G1=1;var t=_f();function s(){this.__data__=t?t(null):{},this.size=0}return Eg=s,Eg}var Dg,K1;function Iz(){if(K1)return Dg;K1=1;function t(s){var n=this.has(s)&&delete this.__data__[s];return this.size-=n?1:0,n}return Dg=t,Dg}var Tg,Y1;function Lz(){if(Y1)return Tg;Y1=1;var t=_f(),s="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function a(l){var c=this.__data__;if(t){var d=c[l];return d===s?void 0:d}return r.call(c,l)?c[l]:void 0}return Tg=a,Tg}var Pg,Z1;function Mz(){if(Z1)return Pg;Z1=1;var t=_f(),s=Object.prototype,n=s.hasOwnProperty;function r(a){var l=this.__data__;return t?l[a]!==void 0:n.call(l,a)}return Pg=r,Pg}var _g,Q1;function Fz(){if(Q1)return _g;Q1=1;var t=_f(),s="__lodash_hash_undefined__";function n(r,a){var l=this.__data__;return this.size+=this.has(r)?0:1,l[r]=t&&a===void 0?s:a,this}return _g=n,_g}var Og,X1;function Bz(){if(X1)return Og;X1=1;var t=Oz(),s=Iz(),n=Lz(),r=Mz(),a=Fz();function l(c){var d=-1,h=c==null?0:c.length;for(this.clear();++d<h;){var x=c[d];this.set(x[0],x[1])}}return l.prototype.clear=t,l.prototype.delete=s,l.prototype.get=n,l.prototype.has=r,l.prototype.set=a,Og=l,Og}var Ig,J1;function $z(){if(J1)return Ig;J1=1;var t=Bz(),s=Tf(),n=Yb();function r(){this.size=0,this.__data__={hash:new t,map:new(n||s),string:new t}}return Ig=r,Ig}var Lg,eS;function qz(){if(eS)return Lg;eS=1;function t(s){var n=typeof s;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?s!=="__proto__":s===null}return Lg=t,Lg}var Mg,tS;function Of(){if(tS)return Mg;tS=1;var t=qz();function s(n,r){var a=n.__data__;return t(r)?a[typeof r=="string"?"string":"hash"]:a.map}return Mg=s,Mg}var Fg,sS;function zz(){if(sS)return Fg;sS=1;var t=Of();function s(n){var r=t(this,n).delete(n);return this.size-=r?1:0,r}return Fg=s,Fg}var Bg,nS;function Uz(){if(nS)return Bg;nS=1;var t=Of();function s(n){return t(this,n).get(n)}return Bg=s,Bg}var $g,rS;function Vz(){if(rS)return $g;rS=1;var t=Of();function s(n){return t(this,n).has(n)}return $g=s,$g}var qg,aS;function Hz(){if(aS)return qg;aS=1;var t=Of();function s(n,r){var a=t(this,n),l=a.size;return a.set(n,r),this.size+=a.size==l?0:1,this}return qg=s,qg}var zg,iS;function XE(){if(iS)return zg;iS=1;var t=$z(),s=zz(),n=Uz(),r=Vz(),a=Hz();function l(c){var d=-1,h=c==null?0:c.length;for(this.clear();++d<h;){var x=c[d];this.set(x[0],x[1])}}return l.prototype.clear=t,l.prototype.delete=s,l.prototype.get=n,l.prototype.has=r,l.prototype.set=a,zg=l,zg}var Ug,lS;function Wz(){if(lS)return Ug;lS=1;var t=Tf(),s=Yb(),n=XE(),r=200;function a(l,c){var d=this.__data__;if(d instanceof t){var h=d.__data__;if(!s||h.length<r-1)return h.push([l,c]),this.size=++d.size,this;d=this.__data__=new n(h)}return d.set(l,c),this.size=d.size,this}return Ug=a,Ug}var Vg,oS;function Gz(){if(oS)return Vg;oS=1;var t=Tf(),s=Sz(),n=Cz(),r=Az(),a=kz(),l=Wz();function c(d){var h=this.__data__=new t(d);this.size=h.size}return c.prototype.clear=s,c.prototype.delete=n,c.prototype.get=r,c.prototype.has=a,c.prototype.set=l,Vg=c,Vg}var Hg,cS;function Kz(){if(cS)return Hg;cS=1;var t="__lodash_hash_undefined__";function s(n){return this.__data__.set(n,t),this}return Hg=s,Hg}var Wg,dS;function Yz(){if(dS)return Wg;dS=1;function t(s){return this.__data__.has(s)}return Wg=t,Wg}var Gg,uS;function Zz(){if(uS)return Gg;uS=1;var t=XE(),s=Kz(),n=Yz();function r(a){var l=-1,c=a==null?0:a.length;for(this.__data__=new t;++l<c;)this.add(a[l])}return r.prototype.add=r.prototype.push=s,r.prototype.has=n,Gg=r,Gg}var Kg,hS;function Qz(){if(hS)return Kg;hS=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 Kg=t,Kg}var Yg,mS;function Xz(){if(mS)return Yg;mS=1;function t(s,n){return s.has(n)}return Yg=t,Yg}var Zg,fS;function JE(){if(fS)return Zg;fS=1;var t=Zz(),s=Qz(),n=Xz(),r=1,a=2;function l(c,d,h,x,f,m){var p=h&r,u=c.length,j=d.length;if(u!=j&&!(p&&j>u))return!1;var g=m.get(c),y=m.get(d);if(g&&y)return g==d&&y==c;var N=-1,S=!0,C=h&a?new t:void 0;for(m.set(c,d),m.set(d,c);++N<u;){var w=c[N],R=d[N];if(x)var P=p?x(R,w,N,d,c,m):x(w,R,N,c,d,m);if(P!==void 0){if(P)continue;S=!1;break}if(C){if(!s(d,function(A,I){if(!n(C,I)&&(w===A||f(w,A,h,x,m)))return C.push(I)})){S=!1;break}}else if(!(w===R||f(w,R,h,x,m))){S=!1;break}}return m.delete(c),m.delete(d),S}return Zg=l,Zg}var Qg,pS;function Jz(){if(pS)return Qg;pS=1;var t=sl(),s=t.Uint8Array;return Qg=s,Qg}var Xg,xS;function eU(){if(xS)return Xg;xS=1;function t(s){var n=-1,r=Array(s.size);return s.forEach(function(a,l){r[++n]=[l,a]}),r}return Xg=t,Xg}var Jg,gS;function tU(){if(gS)return Jg;gS=1;function t(s){var n=-1,r=Array(s.size);return s.forEach(function(a){r[++n]=a}),r}return Jg=t,Jg}var e0,vS;function sU(){if(vS)return e0;vS=1;var t=Kb(),s=Jz(),n=GE(),r=JE(),a=eU(),l=tU(),c=1,d=2,h="[object Boolean]",x="[object Date]",f="[object Error]",m="[object Map]",p="[object Number]",u="[object RegExp]",j="[object Set]",g="[object String]",y="[object Symbol]",N="[object ArrayBuffer]",S="[object DataView]",C=t?t.prototype:void 0,w=C?C.valueOf:void 0;function R(P,A,I,$,T,E,_){switch(I){case S:if(P.byteLength!=A.byteLength||P.byteOffset!=A.byteOffset)return!1;P=P.buffer,A=A.buffer;case N:return!(P.byteLength!=A.byteLength||!E(new s(P),new s(A)));case h:case x:case p:return n(+P,+A);case f:return P.name==A.name&&P.message==A.message;case u:case g:return P==A+"";case m:var M=a;case j:var q=$&c;if(M||(M=l),P.size!=A.size&&!q)return!1;var G=_.get(P);if(G)return G==A;$|=d,_.set(P,A);var Z=r(M(P),M(A),$,T,E,_);return _.delete(P),Z;case y:if(w)return w.call(P)==w.call(A)}return!1}return e0=R,e0}var t0,bS;function nU(){if(bS)return t0;bS=1;function t(s,n){for(var r=-1,a=n.length,l=s.length;++r<a;)s[l+r]=n[r];return s}return t0=t,t0}var s0,yS;function Zb(){if(yS)return s0;yS=1;var t=Array.isArray;return s0=t,s0}var n0,jS;function rU(){if(jS)return n0;jS=1;var t=nU(),s=Zb();function n(r,a,l){var c=a(r);return s(r)?c:t(c,l(r))}return n0=n,n0}var r0,NS;function aU(){if(NS)return r0;NS=1;function t(s,n){for(var r=-1,a=s==null?0:s.length,l=0,c=[];++r<a;){var d=s[r];n(d,r,s)&&(c[l++]=d)}return c}return r0=t,r0}var a0,wS;function iU(){if(wS)return a0;wS=1;function t(){return[]}return a0=t,a0}var i0,SS;function lU(){if(SS)return i0;SS=1;var t=aU(),s=iU(),n=Object.prototype,r=n.propertyIsEnumerable,a=Object.getOwnPropertySymbols,l=a?function(c){return c==null?[]:(c=Object(c),t(a(c),function(d){return r.call(c,d)}))}:s;return i0=l,i0}var l0,CS;function oU(){if(CS)return l0;CS=1;function t(s,n){for(var r=-1,a=Array(s);++r<s;)a[r]=n(r);return a}return l0=t,l0}var o0,AS;function If(){if(AS)return o0;AS=1;function t(s){return s!=null&&typeof s=="object"}return o0=t,o0}var c0,kS;function cU(){if(kS)return c0;kS=1;var t=Pf(),s=If(),n="[object Arguments]";function r(a){return s(a)&&t(a)==n}return c0=r,c0}var d0,RS;function dU(){if(RS)return d0;RS=1;var t=cU(),s=If(),n=Object.prototype,r=n.hasOwnProperty,a=n.propertyIsEnumerable,l=t((function(){return arguments})())?t:function(c){return s(c)&&r.call(c,"callee")&&!a.call(c,"callee")};return d0=l,d0}var Md={exports:{}},u0,ES;function uU(){if(ES)return u0;ES=1;function t(){return!1}return u0=t,u0}Md.exports;var DS;function eD(){return DS||(DS=1,(function(t,s){var n=sl(),r=uU(),a=s&&!s.nodeType&&s,l=a&&!0&&t&&!t.nodeType&&t,c=l&&l.exports===a,d=c?n.Buffer:void 0,h=d?d.isBuffer:void 0,x=h||r;t.exports=x})(Md,Md.exports)),Md.exports}var h0,TS;function hU(){if(TS)return h0;TS=1;var t=9007199254740991,s=/^(?:0|[1-9]\d*)$/;function n(r,a){var l=typeof r;return a=a??t,!!a&&(l=="number"||l!="symbol"&&s.test(r))&&r>-1&&r%1==0&&r<a}return h0=n,h0}var m0,PS;function tD(){if(PS)return m0;PS=1;var t=9007199254740991;function s(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=t}return m0=s,m0}var f0,_S;function mU(){if(_S)return f0;_S=1;var t=Pf(),s=tD(),n=If(),r="[object Arguments]",a="[object Array]",l="[object Boolean]",c="[object Date]",d="[object Error]",h="[object Function]",x="[object Map]",f="[object Number]",m="[object Object]",p="[object RegExp]",u="[object Set]",j="[object String]",g="[object WeakMap]",y="[object ArrayBuffer]",N="[object DataView]",S="[object Float32Array]",C="[object Float64Array]",w="[object Int8Array]",R="[object Int16Array]",P="[object Int32Array]",A="[object Uint8Array]",I="[object Uint8ClampedArray]",$="[object Uint16Array]",T="[object Uint32Array]",E={};E[S]=E[C]=E[w]=E[R]=E[P]=E[A]=E[I]=E[$]=E[T]=!0,E[r]=E[a]=E[y]=E[l]=E[N]=E[c]=E[d]=E[h]=E[x]=E[f]=E[m]=E[p]=E[u]=E[j]=E[g]=!1;function _(M){return n(M)&&s(M.length)&&!!E[t(M)]}return f0=_,f0}var p0,OS;function fU(){if(OS)return p0;OS=1;function t(s){return function(n){return s(n)}}return p0=t,p0}var Fd={exports:{}};Fd.exports;var IS;function pU(){return IS||(IS=1,(function(t,s){var n=KE(),r=s&&!s.nodeType&&s,a=r&&!0&&t&&!t.nodeType&&t,l=a&&a.exports===r,c=l&&n.process,d=(function(){try{var h=a&&a.require&&a.require("util").types;return h||c&&c.binding&&c.binding("util")}catch{}})();t.exports=d})(Fd,Fd.exports)),Fd.exports}var x0,LS;function sD(){if(LS)return x0;LS=1;var t=mU(),s=fU(),n=pU(),r=n&&n.isTypedArray,a=r?s(r):t;return x0=a,x0}var g0,MS;function xU(){if(MS)return g0;MS=1;var t=oU(),s=dU(),n=Zb(),r=eD(),a=hU(),l=sD(),c=Object.prototype,d=c.hasOwnProperty;function h(x,f){var m=n(x),p=!m&&s(x),u=!m&&!p&&r(x),j=!m&&!p&&!u&&l(x),g=m||p||u||j,y=g?t(x.length,String):[],N=y.length;for(var S in x)(f||d.call(x,S))&&!(g&&(S=="length"||u&&(S=="offset"||S=="parent")||j&&(S=="buffer"||S=="byteLength"||S=="byteOffset")||a(S,N)))&&y.push(S);return y}return g0=h,g0}var v0,FS;function gU(){if(FS)return v0;FS=1;var t=Object.prototype;function s(n){var r=n&&n.constructor,a=typeof r=="function"&&r.prototype||t;return n===a}return v0=s,v0}var b0,BS;function vU(){if(BS)return b0;BS=1;function t(s,n){return function(r){return s(n(r))}}return b0=t,b0}var y0,$S;function bU(){if($S)return y0;$S=1;var t=vU(),s=t(Object.keys,Object);return y0=s,y0}var j0,qS;function yU(){if(qS)return j0;qS=1;var t=gU(),s=bU(),n=Object.prototype,r=n.hasOwnProperty;function a(l){if(!t(l))return s(l);var c=[];for(var d in Object(l))r.call(l,d)&&d!="constructor"&&c.push(d);return c}return j0=a,j0}var N0,zS;function jU(){if(zS)return N0;zS=1;var t=ZE(),s=tD();function n(r){return r!=null&&s(r.length)&&!t(r)}return N0=n,N0}var w0,US;function NU(){if(US)return w0;US=1;var t=xU(),s=yU(),n=jU();function r(a){return n(a)?t(a):s(a)}return w0=r,w0}var S0,VS;function wU(){if(VS)return S0;VS=1;var t=rU(),s=lU(),n=NU();function r(a){return t(a,n,s)}return S0=r,S0}var C0,HS;function SU(){if(HS)return C0;HS=1;var t=wU(),s=1,n=Object.prototype,r=n.hasOwnProperty;function a(l,c,d,h,x,f){var m=d&s,p=t(l),u=p.length,j=t(c),g=j.length;if(u!=g&&!m)return!1;for(var y=u;y--;){var N=p[y];if(!(m?N in c:r.call(c,N)))return!1}var S=f.get(l),C=f.get(c);if(S&&C)return S==c&&C==l;var w=!0;f.set(l,c),f.set(c,l);for(var R=m;++y<u;){N=p[y];var P=l[N],A=c[N];if(h)var I=m?h(A,P,N,c,l,f):h(P,A,N,l,c,f);if(!(I===void 0?P===A||x(P,A,d,h,f):I)){w=!1;break}R||(R=N=="constructor")}if(w&&!R){var $=l.constructor,T=c.constructor;$!=T&&"constructor"in l&&"constructor"in c&&!(typeof $=="function"&&$ instanceof $&&typeof T=="function"&&T instanceof T)&&(w=!1)}return f.delete(l),f.delete(c),w}return C0=a,C0}var A0,WS;function CU(){if(WS)return A0;WS=1;var t=Yc(),s=sl(),n=t(s,"DataView");return A0=n,A0}var k0,GS;function AU(){if(GS)return k0;GS=1;var t=Yc(),s=sl(),n=t(s,"Promise");return k0=n,k0}var R0,KS;function kU(){if(KS)return R0;KS=1;var t=Yc(),s=sl(),n=t(s,"Set");return R0=n,R0}var E0,YS;function RU(){if(YS)return E0;YS=1;var t=Yc(),s=sl(),n=t(s,"WeakMap");return E0=n,E0}var D0,ZS;function EU(){if(ZS)return D0;ZS=1;var t=CU(),s=Yb(),n=AU(),r=kU(),a=RU(),l=Pf(),c=QE(),d="[object Map]",h="[object Object]",x="[object Promise]",f="[object Set]",m="[object WeakMap]",p="[object DataView]",u=c(t),j=c(s),g=c(n),y=c(r),N=c(a),S=l;return(t&&S(new t(new ArrayBuffer(1)))!=p||s&&S(new s)!=d||n&&S(n.resolve())!=x||r&&S(new r)!=f||a&&S(new a)!=m)&&(S=function(C){var w=l(C),R=w==h?C.constructor:void 0,P=R?c(R):"";if(P)switch(P){case u:return p;case j:return d;case g:return x;case y:return f;case N:return m}return w}),D0=S,D0}var T0,QS;function DU(){if(QS)return T0;QS=1;var t=Gz(),s=JE(),n=sU(),r=SU(),a=EU(),l=Zb(),c=eD(),d=sD(),h=1,x="[object Arguments]",f="[object Array]",m="[object Object]",p=Object.prototype,u=p.hasOwnProperty;function j(g,y,N,S,C,w){var R=l(g),P=l(y),A=R?f:a(g),I=P?f:a(y);A=A==x?m:A,I=I==x?m:I;var $=A==m,T=I==m,E=A==I;if(E&&c(g)){if(!c(y))return!1;R=!0,$=!1}if(E&&!$)return w||(w=new t),R||d(g)?s(g,y,N,S,C,w):n(g,y,A,N,S,C,w);if(!(N&h)){var _=$&&u.call(g,"__wrapped__"),M=T&&u.call(y,"__wrapped__");if(_||M){var q=_?g.value():g,G=M?y.value():y;return w||(w=new t),C(q,G,N,S,w)}}return E?(w||(w=new t),r(g,y,N,S,C,w)):!1}return T0=j,T0}var P0,XS;function TU(){if(XS)return P0;XS=1;var t=DU(),s=If();function n(r,a,l,c,d){return r===a?!0:r==null||a==null||!s(r)&&!s(a)?r!==r&&a!==a:t(r,a,l,c,n,d)}return P0=n,P0}var _0,JS;function PU(){if(JS)return _0;JS=1;var t=TU();function s(n,r){return t(n,r)}return _0=s,_0}var im={exports:{}};/*!
* Quill Editor v1.3.7
* https://quilljs.com/
* Copyright (c) 2014, Jason Chen
* Copyright (c) 2013, salesforce.com
*/var _U=im.exports,eC;function OU(){return eC||(eC=1,(function(t,s){(function(r,a){t.exports=a()})(typeof self<"u"?self:_U,function(){return(function(n){var r={};function a(l){if(r[l])return r[l].exports;var c=r[l]={i:l,l:!1,exports:{}};return n[l].call(c.exports,c,c.exports,a),c.l=!0,c.exports}return a.m=n,a.c=r,a.d=function(l,c,d){a.o(l,c)||Object.defineProperty(l,c,{configurable:!1,enumerable:!0,get:d})},a.n=function(l){var c=l&&l.__esModule?function(){return l.default}:function(){return l};return a.d(c,"a",c),c},a.o=function(l,c){return Object.prototype.hasOwnProperty.call(l,c)},a.p="",a(a.s=109)})([(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(17),c=a(18),d=a(19),h=a(45),x=a(46),f=a(47),m=a(48),p=a(49),u=a(12),j=a(32),g=a(33),y=a(31),N=a(1),S={Scope:N.Scope,create:N.create,find:N.find,query:N.query,register:N.register,Container:l.default,Format:c.default,Leaf:d.default,Embed:m.default,Scroll:h.default,Block:f.default,Inline:x.default,Text:p.default,Attributor:{Attribute:u.default,Class:j.default,Style:g.default,Store:y.default}};r.default=S}),(function(n,r,a){var l=this&&this.__extends||(function(){var y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(N,S){N.__proto__=S}||function(N,S){for(var C in S)S.hasOwnProperty(C)&&(N[C]=S[C])};return function(N,S){y(N,S);function C(){this.constructor=N}N.prototype=S===null?Object.create(S):(C.prototype=S.prototype,new C)}})();Object.defineProperty(r,"__esModule",{value:!0});var c=(function(y){l(N,y);function N(S){var C=this;return S="[Parchment] "+S,C=y.call(this,S)||this,C.message=S,C.name=C.constructor.name,C}return N})(Error);r.ParchmentError=c;var d={},h={},x={},f={};r.DATA_KEY="__blot";var m;(function(y){y[y.TYPE=3]="TYPE",y[y.LEVEL=12]="LEVEL",y[y.ATTRIBUTE=13]="ATTRIBUTE",y[y.BLOT=14]="BLOT",y[y.INLINE=7]="INLINE",y[y.BLOCK=11]="BLOCK",y[y.BLOCK_BLOT=10]="BLOCK_BLOT",y[y.INLINE_BLOT=6]="INLINE_BLOT",y[y.BLOCK_ATTRIBUTE=9]="BLOCK_ATTRIBUTE",y[y.INLINE_ATTRIBUTE=5]="INLINE_ATTRIBUTE",y[y.ANY=15]="ANY"})(m=r.Scope||(r.Scope={}));function p(y,N){var S=j(y);if(S==null)throw new c("Unable to create "+y+" blot");var C=S,w=y instanceof Node||y.nodeType===Node.TEXT_NODE?y:C.create(N);return new C(w,N)}r.create=p;function u(y,N){return N===void 0&&(N=!1),y==null?null:y[r.DATA_KEY]!=null?y[r.DATA_KEY].blot:N?u(y.parentNode,N):null}r.find=u;function j(y,N){N===void 0&&(N=m.ANY);var S;if(typeof y=="string")S=f[y]||d[y];else if(y instanceof Text||y.nodeType===Node.TEXT_NODE)S=f.text;else if(typeof y=="number")y&m.LEVEL&m.BLOCK?S=f.block:y&m.LEVEL&m.INLINE&&(S=f.inline);else if(y instanceof HTMLElement){var C=(y.getAttribute("class")||"").split(/\s+/);for(var w in C)if(S=h[C[w]],S)break;S=S||x[y.tagName]}return S==null?null:N&m.LEVEL&S.scope&&N&m.TYPE&S.scope?S:null}r.query=j;function g(){for(var y=[],N=0;N<arguments.length;N++)y[N]=arguments[N];if(y.length>1)return y.map(function(w){return g(w)});var S=y[0];if(typeof S.blotName!="string"&&typeof S.attrName!="string")throw new c("Invalid definition");if(S.blotName==="abstract")throw new c("Cannot register abstract class");if(f[S.blotName||S.attrName]=S,typeof S.keyName=="string")d[S.keyName]=S;else if(S.className!=null&&(h[S.className]=S),S.tagName!=null){Array.isArray(S.tagName)?S.tagName=S.tagName.map(function(w){return w.toUpperCase()}):S.tagName=S.tagName.toUpperCase();var C=Array.isArray(S.tagName)?S.tagName:[S.tagName];C.forEach(function(w){(x[w]==null||S.className==null)&&(x[w]=S)})}return S}r.register=g}),(function(n,r,a){var l=a(51),c=a(11),d=a(3),h=a(20),x="\0",f=function(m){Array.isArray(m)?this.ops=m:m!=null&&Array.isArray(m.ops)?this.ops=m.ops:this.ops=[]};f.prototype.insert=function(m,p){var u={};return m.length===0?this:(u.insert=m,p!=null&&typeof p=="object"&&Object.keys(p).length>0&&(u.attributes=p),this.push(u))},f.prototype.delete=function(m){return m<=0?this:this.push({delete:m})},f.prototype.retain=function(m,p){if(m<=0)return this;var u={retain:m};return p!=null&&typeof p=="object"&&Object.keys(p).length>0&&(u.attributes=p),this.push(u)},f.prototype.push=function(m){var p=this.ops.length,u=this.ops[p-1];if(m=d(!0,{},m),typeof u=="object"){if(typeof m.delete=="number"&&typeof u.delete=="number")return this.ops[p-1]={delete:u.delete+m.delete},this;if(typeof u.delete=="number"&&m.insert!=null&&(p-=1,u=this.ops[p-1],typeof u!="object"))return this.ops.unshift(m),this;if(c(m.attributes,u.attributes)){if(typeof m.insert=="string"&&typeof u.insert=="string")return this.ops[p-1]={insert:u.insert+m.insert},typeof m.attributes=="object"&&(this.ops[p-1].attributes=m.attributes),this;if(typeof m.retain=="number"&&typeof u.retain=="number")return this.ops[p-1]={retain:u.retain+m.retain},typeof m.attributes=="object"&&(this.ops[p-1].attributes=m.attributes),this}}return p===this.ops.length?this.ops.push(m):this.ops.splice(p,0,m),this},f.prototype.chop=function(){var m=this.ops[this.ops.length-1];return m&&m.retain&&!m.attributes&&this.ops.pop(),this},f.prototype.filter=function(m){return this.ops.filter(m)},f.prototype.forEach=function(m){this.ops.forEach(m)},f.prototype.map=function(m){return this.ops.map(m)},f.prototype.partition=function(m){var p=[],u=[];return this.forEach(function(j){var g=m(j)?p:u;g.push(j)}),[p,u]},f.prototype.reduce=function(m,p){return this.ops.reduce(m,p)},f.prototype.changeLength=function(){return this.reduce(function(m,p){return p.insert?m+h.length(p):p.delete?m-p.delete:m},0)},f.prototype.length=function(){return this.reduce(function(m,p){return m+h.length(p)},0)},f.prototype.slice=function(m,p){m=m||0,typeof p!="number"&&(p=1/0);for(var u=[],j=h.iterator(this.ops),g=0;g<p&&j.hasNext();){var y;g<m?y=j.next(m-g):(y=j.next(p-g),u.push(y)),g+=h.length(y)}return new f(u)},f.prototype.compose=function(m){var p=h.iterator(this.ops),u=h.iterator(m.ops),j=[],g=u.peek();if(g!=null&&typeof g.retain=="number"&&g.attributes==null){for(var y=g.retain;p.peekType()==="insert"&&p.peekLength()<=y;)y-=p.peekLength(),j.push(p.next());g.retain-y>0&&u.next(g.retain-y)}for(var N=new f(j);p.hasNext()||u.hasNext();)if(u.peekType()==="insert")N.push(u.next());else if(p.peekType()==="delete")N.push(p.next());else{var S=Math.min(p.peekLength(),u.peekLength()),C=p.next(S),w=u.next(S);if(typeof w.retain=="number"){var R={};typeof C.retain=="number"?R.retain=S:R.insert=C.insert;var P=h.attributes.compose(C.attributes,w.attributes,typeof C.retain=="number");if(P&&(R.attributes=P),N.push(R),!u.hasNext()&&c(N.ops[N.ops.length-1],R)){var A=new f(p.rest());return N.concat(A).chop()}}else typeof w.delete=="number"&&typeof C.retain=="number"&&N.push(w)}return N.chop()},f.prototype.concat=function(m){var p=new f(this.ops.slice());return m.ops.length>0&&(p.push(m.ops[0]),p.ops=p.ops.concat(m.ops.slice(1))),p},f.prototype.diff=function(m,p){if(this.ops===m.ops)return new f;var u=[this,m].map(function(S){return S.map(function(C){if(C.insert!=null)return typeof C.insert=="string"?C.insert:x;var w=S===m?"on":"with";throw new Error("diff() called "+w+" non-document")}).join("")}),j=new f,g=l(u[0],u[1],p),y=h.iterator(this.ops),N=h.iterator(m.ops);return g.forEach(function(S){for(var C=S[1].length;C>0;){var w=0;switch(S[0]){case l.INSERT:w=Math.min(N.peekLength(),C),j.push(N.next(w));break;case l.DELETE:w=Math.min(C,y.peekLength()),y.next(w),j.delete(w);break;case l.EQUAL:w=Math.min(y.peekLength(),N.peekLength(),C);var R=y.next(w),P=N.next(w);c(R.insert,P.insert)?j.retain(w,h.attributes.diff(R.attributes,P.attributes)):j.push(P).delete(w);break}C-=w}}),j.chop()},f.prototype.eachLine=function(m,p){p=p||`
`;for(var u=h.iterator(this.ops),j=new f,g=0;u.hasNext();){if(u.peekType()!=="insert")return;var y=u.peek(),N=h.length(y)-u.peekLength(),S=typeof y.insert=="string"?y.insert.indexOf(p,N)-N:-1;if(S<0)j.push(u.next());else if(S>0)j.push(u.next(S));else{if(m(j,u.next(1).attributes||{},g)===!1)return;g+=1,j=new f}}j.length()>0&&m(j,{},g)},f.prototype.transform=function(m,p){if(p=!!p,typeof m=="number")return this.transformPosition(m,p);for(var u=h.iterator(this.ops),j=h.iterator(m.ops),g=new f;u.hasNext()||j.hasNext();)if(u.peekType()==="insert"&&(p||j.peekType()!=="insert"))g.retain(h.length(u.next()));else if(j.peekType()==="insert")g.push(j.next());else{var y=Math.min(u.peekLength(),j.peekLength()),N=u.next(y),S=j.next(y);if(N.delete)continue;S.delete?g.push(S):g.retain(y,h.attributes.transform(N.attributes,S.attributes,p))}return g.chop()},f.prototype.transformPosition=function(m,p){p=!!p;for(var u=h.iterator(this.ops),j=0;u.hasNext()&&j<=m;){var g=u.peekLength(),y=u.peekType();if(u.next(),y==="delete"){m-=Math.min(g,m-j);continue}else y==="insert"&&(j<m||!p)&&(m+=g);j+=g}return m},n.exports=f}),(function(n,r){var a=Object.prototype.hasOwnProperty,l=Object.prototype.toString,c=Object.defineProperty,d=Object.getOwnPropertyDescriptor,h=function(u){return typeof Array.isArray=="function"?Array.isArray(u):l.call(u)==="[object Array]"},x=function(u){if(!u||l.call(u)!=="[object Object]")return!1;var j=a.call(u,"constructor"),g=u.constructor&&u.constructor.prototype&&a.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!j&&!g)return!1;var y;for(y in u);return typeof y>"u"||a.call(u,y)},f=function(u,j){c&&j.name==="__proto__"?c(u,j.name,{enumerable:!0,configurable:!0,value:j.newValue,writable:!0}):u[j.name]=j.newValue},m=function(u,j){if(j==="__proto__")if(a.call(u,j)){if(d)return d(u,j).value}else return;return u[j]};n.exports=function p(){var u,j,g,y,N,S,C=arguments[0],w=1,R=arguments.length,P=!1;for(typeof C=="boolean"&&(P=C,C=arguments[1]||{},w=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});w<R;++w)if(u=arguments[w],u!=null)for(j in u)g=m(C,j),y=m(u,j),C!==y&&(P&&y&&(x(y)||(N=h(y)))?(N?(N=!1,S=g&&h(g)?g:[]):S=g&&x(g)?g:{},f(C,{name:j,newValue:p(P,S,y)})):typeof y<"u"&&f(C,{name:j,newValue:y}));return C}}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.BlockEmbed=r.bubbleFormats=void 0;var l=(function(){function E(_,M){for(var q=0;q<M.length;q++){var G=M[q];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(_,G.key,G)}}return function(_,M,q){return M&&E(_.prototype,M),q&&E(_,q),_}})(),c=function E(_,M,q){_===null&&(_=Function.prototype);var G=Object.getOwnPropertyDescriptor(_,M);if(G===void 0){var Z=Object.getPrototypeOf(_);return Z===null?void 0:E(Z,M,q)}else{if("value"in G)return G.value;var W=G.get;return W===void 0?void 0:W.call(q)}},d=a(3),h=C(d),x=a(2),f=C(x),m=a(0),p=C(m),u=a(16),j=C(u),g=a(6),y=C(g),N=a(7),S=C(N);function C(E){return E&&E.__esModule?E:{default:E}}function w(E,_){if(!(E instanceof _))throw new TypeError("Cannot call a class as a function")}function R(E,_){if(!E)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return _&&(typeof _=="object"||typeof _=="function")?_:E}function P(E,_){if(typeof _!="function"&&_!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof _);E.prototype=Object.create(_&&_.prototype,{constructor:{value:E,enumerable:!1,writable:!0,configurable:!0}}),_&&(Object.setPrototypeOf?Object.setPrototypeOf(E,_):E.__proto__=_)}var A=1,I=(function(E){P(_,E);function _(){return w(this,_),R(this,(_.__proto__||Object.getPrototypeOf(_)).apply(this,arguments))}return l(_,[{key:"attach",value:function(){c(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"attach",this).call(this),this.attributes=new p.default.Attributor.Store(this.domNode)}},{key:"delta",value:function(){return new f.default().insert(this.value(),(0,h.default)(this.formats(),this.attributes.values()))}},{key:"format",value:function(q,G){var Z=p.default.query(q,p.default.Scope.BLOCK_ATTRIBUTE);Z!=null&&this.attributes.attribute(Z,G)}},{key:"formatAt",value:function(q,G,Z,W){this.format(Z,W)}},{key:"insertAt",value:function(q,G,Z){if(typeof G=="string"&&G.endsWith(`
`)){var W=p.default.create($.blotName);this.parent.insertBefore(W,q===0?this:this.next),W.insertAt(0,G.slice(0,-1))}else c(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"insertAt",this).call(this,q,G,Z)}}]),_})(p.default.Embed);I.scope=p.default.Scope.BLOCK_BLOT;var $=(function(E){P(_,E);function _(M){w(this,_);var q=R(this,(_.__proto__||Object.getPrototypeOf(_)).call(this,M));return q.cache={},q}return l(_,[{key:"delta",value:function(){return this.cache.delta==null&&(this.cache.delta=this.descendants(p.default.Leaf).reduce(function(q,G){return G.length()===0?q:q.insert(G.value(),T(G))},new f.default).insert(`
`,T(this))),this.cache.delta}},{key:"deleteAt",value:function(q,G){c(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"deleteAt",this).call(this,q,G),this.cache={}}},{key:"formatAt",value:function(q,G,Z,W){G<=0||(p.default.query(Z,p.default.Scope.BLOCK)?q+G===this.length()&&this.format(Z,W):c(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"formatAt",this).call(this,q,Math.min(G,this.length()-q-1),Z,W),this.cache={})}},{key:"insertAt",value:function(q,G,Z){if(Z!=null)return c(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"insertAt",this).call(this,q,G,Z);if(G.length!==0){var W=G.split(`
`),z=W.shift();z.length>0&&(q<this.length()-1||this.children.tail==null?c(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"insertAt",this).call(this,Math.min(q,this.length()-1),z):this.children.tail.insertAt(this.children.tail.length(),z),this.cache={});var F=this;W.reduce(function(B,D){return F=F.split(B,!0),F.insertAt(0,D),D.length},q+z.length)}}},{key:"insertBefore",value:function(q,G){var Z=this.children.head;c(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"insertBefore",this).call(this,q,G),Z instanceof j.default&&Z.remove(),this.cache={}}},{key:"length",value:function(){return this.cache.length==null&&(this.cache.length=c(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"length",this).call(this)+A),this.cache.length}},{key:"moveChildren",value:function(q,G){c(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"moveChildren",this).call(this,q,G),this.cache={}}},{key:"optimize",value:function(q){c(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"optimize",this).call(this,q),this.cache={}}},{key:"path",value:function(q){return c(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"path",this).call(this,q,!0)}},{key:"removeChild",value:function(q){c(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"removeChild",this).call(this,q),this.cache={}}},{key:"split",value:function(q){var G=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(G&&(q===0||q>=this.length()-A)){var Z=this.clone();return q===0?(this.parent.insertBefore(Z,this),this):(this.parent.insertBefore(Z,this.next),Z)}else{var W=c(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"split",this).call(this,q,G);return this.cache={},W}}}]),_})(p.default.Block);$.blotName="block",$.tagName="P",$.defaultChild="break",$.allowedChildren=[y.default,p.default.Embed,S.default];function T(E){var _=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return E==null||(typeof E.formats=="function"&&(_=(0,h.default)(_,E.formats())),E.parent==null||E.parent.blotName=="scroll"||E.parent.statics.scope!==E.statics.scope)?_:T(E.parent,_)}r.bubbleFormats=T,r.BlockEmbed=I,r.default=$}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.overload=r.expandConfig=void 0;var l=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(F){return typeof F}:function(F){return F&&typeof Symbol=="function"&&F.constructor===Symbol&&F!==Symbol.prototype?"symbol":typeof F},c=(function(){function F(B,D){var O=[],V=!0,K=!1,Y=void 0;try{for(var U=B[Symbol.iterator](),X;!(V=(X=U.next()).done)&&(O.push(X.value),!(D&&O.length===D));V=!0);}catch(ne){K=!0,Y=ne}finally{try{!V&&U.return&&U.return()}finally{if(K)throw Y}}return O}return function(B,D){if(Array.isArray(B))return B;if(Symbol.iterator in Object(B))return F(B,D);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function F(B,D){for(var O=0;O<D.length;O++){var V=D[O];V.enumerable=V.enumerable||!1,V.configurable=!0,"value"in V&&(V.writable=!0),Object.defineProperty(B,V.key,V)}}return function(B,D,O){return D&&F(B.prototype,D),O&&F(B,O),B}})();a(50);var h=a(2),x=T(h),f=a(14),m=T(f),p=a(8),u=T(p),j=a(9),g=T(j),y=a(0),N=T(y),S=a(15),C=T(S),w=a(3),R=T(w),P=a(10),A=T(P),I=a(34),$=T(I);function T(F){return F&&F.__esModule?F:{default:F}}function E(F,B,D){return B in F?Object.defineProperty(F,B,{value:D,enumerable:!0,configurable:!0,writable:!0}):F[B]=D,F}function _(F,B){if(!(F instanceof B))throw new TypeError("Cannot call a class as a function")}var M=(0,A.default)("quill"),q=(function(){d(F,null,[{key:"debug",value:function(D){D===!0&&(D="log"),A.default.level(D)}},{key:"find",value:function(D){return D.__quill||N.default.find(D)}},{key:"import",value:function(D){return this.imports[D]==null&&M.error("Cannot import "+D+". Are you sure it was registered?"),this.imports[D]}},{key:"register",value:function(D,O){var V=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(typeof D!="string"){var Y=D.attrName||D.blotName;typeof Y=="string"?this.register("formats/"+Y,D,O):Object.keys(D).forEach(function(U){V.register(U,D[U],O)})}else this.imports[D]!=null&&!K&&M.warn("Overwriting "+D+" with",O),this.imports[D]=O,(D.startsWith("blots/")||D.startsWith("formats/"))&&O.blotName!=="abstract"?N.default.register(O):D.startsWith("modules")&&typeof O.register=="function"&&O.register()}}]);function F(B){var D=this,O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(_(this,F),this.options=G(B,O),this.container=this.options.container,this.container==null)return M.error("Invalid Quill container",B);this.options.debug&&F.debug(this.options.debug);var V=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=N.default.create(this.root,{emitter:this.emitter,whitelist:this.options.formats}),this.editor=new m.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(Y){Y===u.default.events.TEXT_CHANGE&&D.root.classList.toggle("ql-blank",D.editor.isBlank())}),this.emitter.on(u.default.events.SCROLL_UPDATE,function(Y,U){var X=D.selection.lastRange,ne=X&&X.length===0?X.index:void 0;Z.call(D,function(){return D.editor.update(null,U,ne)},Y)});var K=this.clipboard.convert(`<div class='ql-editor' style="white-space: normal;">`+V+"<p><br></p></div>");this.setContents(K),this.history.clear(),this.options.placeholder&&this.root.setAttribute("data-placeholder",this.options.placeholder),this.options.readOnly&&this.disable()}return d(F,[{key:"addContainer",value:function(D){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(typeof D=="string"){var V=D;D=document.createElement("div"),D.classList.add(V)}return this.container.insertBefore(D,O),D}},{key:"blur",value:function(){this.selection.setRange(null)}},{key:"deleteText",value:function(D,O,V){var K=this,Y=W(D,O,V),U=c(Y,4);return D=U[0],O=U[1],V=U[3],Z.call(this,function(){return K.editor.deleteText(D,O)},V,D,-1*O)}},{key:"disable",value:function(){this.enable(!1)}},{key:"enable",value:function(){var D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.scroll.enable(D),this.container.classList.toggle("ql-disabled",!D)}},{key:"focus",value:function(){var D=this.scrollingContainer.scrollTop;this.selection.focus(),this.scrollingContainer.scrollTop=D,this.scrollIntoView()}},{key:"format",value:function(D,O){var V=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:u.default.sources.API;return Z.call(this,function(){var Y=V.getSelection(!0),U=new x.default;if(Y==null)return U;if(N.default.query(D,N.default.Scope.BLOCK))U=V.editor.formatLine(Y.index,Y.length,E({},D,O));else{if(Y.length===0)return V.selection.format(D,O),U;U=V.editor.formatText(Y.index,Y.length,E({},D,O))}return V.setSelection(Y,u.default.sources.SILENT),U},K)}},{key:"formatLine",value:function(D,O,V,K,Y){var U=this,X=void 0,ne=W(D,O,V,K,Y),oe=c(ne,4);return D=oe[0],O=oe[1],X=oe[2],Y=oe[3],Z.call(this,function(){return U.editor.formatLine(D,O,X)},Y,D,0)}},{key:"formatText",value:function(D,O,V,K,Y){var U=this,X=void 0,ne=W(D,O,V,K,Y),oe=c(ne,4);return D=oe[0],O=oe[1],X=oe[2],Y=oe[3],Z.call(this,function(){return U.editor.formatText(D,O,X)},Y,D,0)}},{key:"getBounds",value:function(D){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,V=void 0;typeof D=="number"?V=this.selection.getBounds(D,O):V=this.selection.getBounds(D.index,D.length);var K=this.container.getBoundingClientRect();return{bottom:V.bottom-K.top,height:V.height,left:V.left-K.left,right:V.right-K.left,top:V.top-K.top,width:V.width}}},{key:"getContents",value:function(){var D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getLength()-D,V=W(D,O),K=c(V,2);return D=K[0],O=K[1],this.editor.getContents(D,O)}},{key:"getFormat",value:function(){var D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.getSelection(!0),O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return typeof D=="number"?this.editor.getFormat(D,O):this.editor.getFormat(D.index,D.length)}},{key:"getIndex",value:function(D){return D.offset(this.scroll)}},{key:"getLength",value:function(){return this.scroll.length()}},{key:"getLeaf",value:function(D){return this.scroll.leaf(D)}},{key:"getLine",value:function(D){return this.scroll.line(D)}},{key:"getLines",value:function(){var D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE;return typeof D!="number"?this.scroll.lines(D.index,D.length):this.scroll.lines(D,O)}},{key:"getModule",value:function(D){return this.theme.modules[D]}},{key:"getSelection",value:function(){var D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;return D&&this.focus(),this.update(),this.selection.getRange()[0]}},{key:"getText",value:function(){var D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getLength()-D,V=W(D,O),K=c(V,2);return D=K[0],O=K[1],this.editor.getText(D,O)}},{key:"hasFocus",value:function(){return this.selection.hasFocus()}},{key:"insertEmbed",value:function(D,O,V){var K=this,Y=arguments.length>3&&arguments[3]!==void 0?arguments[3]:F.sources.API;return Z.call(this,function(){return K.editor.insertEmbed(D,O,V)},Y,D)}},{key:"insertText",value:function(D,O,V,K,Y){var U=this,X=void 0,ne=W(D,0,V,K,Y),oe=c(ne,4);return D=oe[0],X=oe[2],Y=oe[3],Z.call(this,function(){return U.editor.insertText(D,O,X)},Y,D,O.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(D,O,V){this.clipboard.dangerouslyPasteHTML(D,O,V)}},{key:"removeFormat",value:function(D,O,V){var K=this,Y=W(D,O,V),U=c(Y,4);return D=U[0],O=U[1],V=U[3],Z.call(this,function(){return K.editor.removeFormat(D,O)},V,D)}},{key:"scrollIntoView",value:function(){this.selection.scrollIntoView(this.scrollingContainer)}},{key:"setContents",value:function(D){var O=this,V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:u.default.sources.API;return Z.call(this,function(){D=new x.default(D);var K=O.getLength(),Y=O.editor.deleteText(0,K),U=O.editor.applyDelta(D),X=U.ops[U.ops.length-1];X!=null&&typeof X.insert=="string"&&X.insert[X.insert.length-1]===`
`&&(O.editor.deleteText(O.getLength()-1,1),U.delete(1));var ne=Y.compose(U);return ne},V)}},{key:"setSelection",value:function(D,O,V){if(D==null)this.selection.setRange(null,O||F.sources.API);else{var K=W(D,O,V),Y=c(K,4);D=Y[0],O=Y[1],V=Y[3],this.selection.setRange(new S.Range(D,O),V),V!==u.default.sources.SILENT&&this.selection.scrollIntoView(this.scrollingContainer)}}},{key:"setText",value:function(D){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:u.default.sources.API,V=new x.default().insert(D);return this.setContents(V,O)}},{key:"update",value:function(){var D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:u.default.sources.USER,O=this.scroll.update(D);return this.selection.update(D),O}},{key:"updateContents",value:function(D){var O=this,V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:u.default.sources.API;return Z.call(this,function(){return D=new x.default(D),O.editor.applyDelta(D,V)},V,!0)}}]),F})();q.DEFAULTS={bounds:null,formats:null,modules:{},placeholder:"",readOnly:!1,scrollingContainer:null,strict:!0,theme:"default"},q.events=u.default.events,q.sources=u.default.sources,q.version="1.3.7",q.imports={delta:x.default,parchment:N.default,"core/module":g.default,"core/theme":$.default};function G(F,B){if(B=(0,R.default)(!0,{container:F,modules:{clipboard:!0,keyboard:!0,history:!0}},B),!B.theme||B.theme===q.DEFAULTS.theme)B.theme=$.default;else if(B.theme=q.import("themes/"+B.theme),B.theme==null)throw new Error("Invalid theme "+B.theme+". Did you register it?");var D=(0,R.default)(!0,{},B.theme.DEFAULTS);[D,B].forEach(function(K){K.modules=K.modules||{},Object.keys(K.modules).forEach(function(Y){K.modules[Y]===!0&&(K.modules[Y]={})})});var O=Object.keys(D.modules).concat(Object.keys(B.modules)),V=O.reduce(function(K,Y){var U=q.import("modules/"+Y);return U==null?M.error("Cannot load "+Y+" module. Are you sure you registered it?"):K[Y]=U.DEFAULTS||{},K},{});return B.modules!=null&&B.modules.toolbar&&B.modules.toolbar.constructor!==Object&&(B.modules.toolbar={container:B.modules.toolbar}),B=(0,R.default)(!0,{},q.DEFAULTS,{modules:V},D,B),["bounds","container","scrollingContainer"].forEach(function(K){typeof B[K]=="string"&&(B[K]=document.querySelector(B[K]))}),B.modules=Object.keys(B.modules).reduce(function(K,Y){return B.modules[Y]&&(K[Y]=B.modules[Y]),K},{}),B}function Z(F,B,D,O){if(this.options.strict&&!this.isEnabled()&&B===u.default.sources.USER)return new x.default;var V=D==null?null:this.getSelection(),K=this.editor.delta,Y=F();if(V!=null&&(D===!0&&(D=V.index),O==null?V=z(V,Y,B):O!==0&&(V=z(V,D,O,B)),this.setSelection(V,u.default.sources.SILENT)),Y.length()>0){var U,X=[u.default.events.TEXT_CHANGE,Y,K,B];if((U=this.emitter).emit.apply(U,[u.default.events.EDITOR_CHANGE].concat(X)),B!==u.default.sources.SILENT){var ne;(ne=this.emitter).emit.apply(ne,X)}}return Y}function W(F,B,D,O,V){var K={};return typeof F.index=="number"&&typeof F.length=="number"?typeof B!="number"?(V=O,O=D,D=B,B=F.length,F=F.index):(B=F.length,F=F.index):typeof B!="number"&&(V=O,O=D,D=B,B=0),(typeof D>"u"?"undefined":l(D))==="object"?(K=D,V=O):typeof D=="string"&&(O!=null?K[D]=O:V=D),V=V||u.default.sources.API,[F,B,K,V]}function z(F,B,D,O){if(F==null)return null;var V=void 0,K=void 0;if(B instanceof x.default){var Y=[F.index,F.index+F.length].map(function(oe){return B.transformPosition(oe,O!==u.default.sources.USER)}),U=c(Y,2);V=U[0],K=U[1]}else{var X=[F.index,F.index+F.length].map(function(oe){return oe<B||oe===B&&O===u.default.sources.USER?oe:D>=0?oe+D:Math.max(B,oe+D)}),ne=c(X,2);V=ne[0],K=ne[1]}return new S.Range(V,K-V)}r.expandConfig=G,r.overload=W,r.default=q}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function y(N,S){for(var C=0;C<S.length;C++){var w=S[C];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(N,w.key,w)}}return function(N,S,C){return S&&y(N.prototype,S),C&&y(N,C),N}})(),c=function y(N,S,C){N===null&&(N=Function.prototype);var w=Object.getOwnPropertyDescriptor(N,S);if(w===void 0){var R=Object.getPrototypeOf(N);return R===null?void 0:y(R,S,C)}else{if("value"in w)return w.value;var P=w.get;return P===void 0?void 0:P.call(C)}},d=a(7),h=m(d),x=a(0),f=m(x);function m(y){return y&&y.__esModule?y:{default:y}}function p(y,N){if(!(y instanceof N))throw new TypeError("Cannot call a class as a function")}function u(y,N){if(!y)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return N&&(typeof N=="object"||typeof N=="function")?N:y}function j(y,N){if(typeof N!="function"&&N!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof N);y.prototype=Object.create(N&&N.prototype,{constructor:{value:y,enumerable:!1,writable:!0,configurable:!0}}),N&&(Object.setPrototypeOf?Object.setPrototypeOf(y,N):y.__proto__=N)}var g=(function(y){j(N,y);function N(){return p(this,N),u(this,(N.__proto__||Object.getPrototypeOf(N)).apply(this,arguments))}return l(N,[{key:"formatAt",value:function(C,w,R,P){if(N.compare(this.statics.blotName,R)<0&&f.default.query(R,f.default.Scope.BLOT)){var A=this.isolate(C,w);P&&A.wrap(R,P)}else c(N.prototype.__proto__||Object.getPrototypeOf(N.prototype),"formatAt",this).call(this,C,w,R,P)}},{key:"optimize",value:function(C){if(c(N.prototype.__proto__||Object.getPrototypeOf(N.prototype),"optimize",this).call(this,C),this.parent instanceof N&&N.compare(this.statics.blotName,this.parent.statics.blotName)>0){var w=this.parent.isolate(this.offset(),this.length());this.moveChildren(w),w.wrap(this)}}}],[{key:"compare",value:function(C,w){var R=N.order.indexOf(C),P=N.order.indexOf(w);return R>=0||P>=0?R-P:C===w?0:C<w?-1:1}}]),N})(f.default.Inline);g.allowedChildren=[g,f.default.Embed,h.default],g.order=["cursor","inline","underline","strike","italic","bold","script","link","code"],r.default=g}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(0),c=d(l);function d(p){return p&&p.__esModule?p:{default:p}}function h(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function x(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function f(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var m=(function(p){f(u,p);function u(){return h(this,u),x(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u})(c.default.Text);r.default=m}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function S(C,w){for(var R=0;R<w.length;R++){var P=w[R];P.enumerable=P.enumerable||!1,P.configurable=!0,"value"in P&&(P.writable=!0),Object.defineProperty(C,P.key,P)}}return function(C,w,R){return w&&S(C.prototype,w),R&&S(C,R),C}})(),c=function S(C,w,R){C===null&&(C=Function.prototype);var P=Object.getOwnPropertyDescriptor(C,w);if(P===void 0){var A=Object.getPrototypeOf(C);return A===null?void 0:S(A,w,R)}else{if("value"in P)return P.value;var I=P.get;return I===void 0?void 0:I.call(R)}},d=a(54),h=m(d),x=a(10),f=m(x);function m(S){return S&&S.__esModule?S:{default:S}}function p(S,C){if(!(S instanceof C))throw new TypeError("Cannot call a class as a function")}function u(S,C){if(!S)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return C&&(typeof C=="object"||typeof C=="function")?C:S}function j(S,C){if(typeof C!="function"&&C!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof C);S.prototype=Object.create(C&&C.prototype,{constructor:{value:S,enumerable:!1,writable:!0,configurable:!0}}),C&&(Object.setPrototypeOf?Object.setPrototypeOf(S,C):S.__proto__=C)}var g=(0,f.default)("quill:events"),y=["selectionchange","mousedown","mouseup","click"];y.forEach(function(S){document.addEventListener(S,function(){for(var C=arguments.length,w=Array(C),R=0;R<C;R++)w[R]=arguments[R];[].slice.call(document.querySelectorAll(".ql-container")).forEach(function(P){if(P.__quill&&P.__quill.emitter){var A;(A=P.__quill.emitter).handleDOM.apply(A,w)}})})});var N=(function(S){j(C,S);function C(){p(this,C);var w=u(this,(C.__proto__||Object.getPrototypeOf(C)).call(this));return w.listeners={},w.on("error",g.error),w}return l(C,[{key:"emit",value:function(){g.log.apply(g,arguments),c(C.prototype.__proto__||Object.getPrototypeOf(C.prototype),"emit",this).apply(this,arguments)}},{key:"handleDOM",value:function(R){for(var P=arguments.length,A=Array(P>1?P-1:0),I=1;I<P;I++)A[I-1]=arguments[I];(this.listeners[R.type]||[]).forEach(function($){var T=$.node,E=$.handler;(R.target===T||T.contains(R.target))&&E.apply(void 0,[R].concat(A))})}},{key:"listenDOM",value:function(R,P,A){this.listeners[R]||(this.listeners[R]=[]),this.listeners[R].push({node:P,handler:A})}}]),C})(h.default);N.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"},N.sources={API:"api",SILENT:"silent",USER:"user"},r.default=N}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});function l(d,h){if(!(d instanceof h))throw new TypeError("Cannot call a class as a function")}var c=function d(h){var x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};l(this,d),this.quill=h,this.options=x};c.DEFAULTS={},r.default=c}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=["error","warn","log","info"],c="warn";function d(x){if(l.indexOf(x)<=l.indexOf(c)){for(var f,m=arguments.length,p=Array(m>1?m-1:0),u=1;u<m;u++)p[u-1]=arguments[u];(f=console)[x].apply(f,p)}}function h(x){return l.reduce(function(f,m){return f[m]=d.bind(console,m,x),f},{})}d.level=h.level=function(x){c=x},r.default=h}),(function(n,r,a){var l=Array.prototype.slice,c=a(52),d=a(53),h=n.exports=function(p,u,j){return j||(j={}),p===u?!0:p instanceof Date&&u instanceof Date?p.getTime()===u.getTime():!p||!u||typeof p!="object"&&typeof u!="object"?j.strict?p===u:p==u:m(p,u,j)};function x(p){return p==null}function f(p){return!(!p||typeof p!="object"||typeof p.length!="number"||typeof p.copy!="function"||typeof p.slice!="function"||p.length>0&&typeof p[0]!="number")}function m(p,u,j){var g,y;if(x(p)||x(u)||p.prototype!==u.prototype)return!1;if(d(p))return d(u)?(p=l.call(p),u=l.call(u),h(p,u,j)):!1;if(f(p)){if(!f(u)||p.length!==u.length)return!1;for(g=0;g<p.length;g++)if(p[g]!==u[g])return!1;return!0}try{var N=c(p),S=c(u)}catch{return!1}if(N.length!=S.length)return!1;for(N.sort(),S.sort(),g=N.length-1;g>=0;g--)if(N[g]!=S[g])return!1;for(g=N.length-1;g>=0;g--)if(y=N[g],!h(p[y],u[y],j))return!1;return typeof p==typeof u}}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(1),c=(function(){function d(h,x,f){f===void 0&&(f={}),this.attrName=h,this.keyName=x;var m=l.Scope.TYPE&l.Scope.ATTRIBUTE;f.scope!=null?this.scope=f.scope&l.Scope.LEVEL|m:this.scope=l.Scope.ATTRIBUTE,f.whitelist!=null&&(this.whitelist=f.whitelist)}return d.keys=function(h){return[].map.call(h.attributes,function(x){return x.name})},d.prototype.add=function(h,x){return this.canAdd(h,x)?(h.setAttribute(this.keyName,x),!0):!1},d.prototype.canAdd=function(h,x){var f=l.query(h,l.Scope.BLOT&(this.scope|l.Scope.TYPE));return f==null?!1:this.whitelist==null?!0:typeof x=="string"?this.whitelist.indexOf(x.replace(/["']/g,""))>-1:this.whitelist.indexOf(x)>-1},d.prototype.remove=function(h){h.removeAttribute(this.keyName)},d.prototype.value=function(h){var x=h.getAttribute(this.keyName);return this.canAdd(h,x)&&x?x:""},d})();r.default=c}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.Code=void 0;var l=(function(){function I($,T){var E=[],_=!0,M=!1,q=void 0;try{for(var G=$[Symbol.iterator](),Z;!(_=(Z=G.next()).done)&&(E.push(Z.value),!(T&&E.length===T));_=!0);}catch(W){M=!0,q=W}finally{try{!_&&G.return&&G.return()}finally{if(M)throw q}}return E}return function($,T){if(Array.isArray($))return $;if(Symbol.iterator in Object($))return I($,T);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),c=(function(){function I($,T){for(var E=0;E<T.length;E++){var _=T[E];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty($,_.key,_)}}return function($,T,E){return T&&I($.prototype,T),E&&I($,E),$}})(),d=function I($,T,E){$===null&&($=Function.prototype);var _=Object.getOwnPropertyDescriptor($,T);if(_===void 0){var M=Object.getPrototypeOf($);return M===null?void 0:I(M,T,E)}else{if("value"in _)return _.value;var q=_.get;return q===void 0?void 0:q.call(E)}},h=a(2),x=S(h),f=a(0),m=S(f),p=a(4),u=S(p),j=a(6),g=S(j),y=a(7),N=S(y);function S(I){return I&&I.__esModule?I:{default:I}}function C(I,$){if(!(I instanceof $))throw new TypeError("Cannot call a class as a function")}function w(I,$){if(!I)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return $&&(typeof $=="object"||typeof $=="function")?$:I}function R(I,$){if(typeof $!="function"&&$!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof $);I.prototype=Object.create($&&$.prototype,{constructor:{value:I,enumerable:!1,writable:!0,configurable:!0}}),$&&(Object.setPrototypeOf?Object.setPrototypeOf(I,$):I.__proto__=$)}var P=(function(I){R($,I);function $(){return C(this,$),w(this,($.__proto__||Object.getPrototypeOf($)).apply(this,arguments))}return $})(g.default);P.blotName="code",P.tagName="CODE";var A=(function(I){R($,I);function $(){return C(this,$),w(this,($.__proto__||Object.getPrototypeOf($)).apply(this,arguments))}return c($,[{key:"delta",value:function(){var E=this,_=this.domNode.textContent;return _.endsWith(`
`)&&(_=_.slice(0,-1)),_.split(`
`).reduce(function(M,q){return M.insert(q).insert(`
`,E.formats())},new x.default)}},{key:"format",value:function(E,_){if(!(E===this.statics.blotName&&_)){var M=this.descendant(N.default,this.length()-1),q=l(M,1),G=q[0];G!=null&&G.deleteAt(G.length()-1,1),d($.prototype.__proto__||Object.getPrototypeOf($.prototype),"format",this).call(this,E,_)}}},{key:"formatAt",value:function(E,_,M,q){if(_!==0&&!(m.default.query(M,m.default.Scope.BLOCK)==null||M===this.statics.blotName&&q===this.statics.formats(this.domNode))){var G=this.newlineIndex(E);if(!(G<0||G>=E+_)){var Z=this.newlineIndex(E,!0)+1,W=G-Z+1,z=this.isolate(Z,W),F=z.next;z.format(M,q),F instanceof $&&F.formatAt(0,E-Z+_-W,M,q)}}}},{key:"insertAt",value:function(E,_,M){if(M==null){var q=this.descendant(N.default,E),G=l(q,2),Z=G[0],W=G[1];Z.insertAt(W,_)}}},{key:"length",value:function(){var E=this.domNode.textContent.length;return this.domNode.textContent.endsWith(`
`)?E:E+1}},{key:"newlineIndex",value:function(E){var _=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(_)return this.domNode.textContent.slice(0,E).lastIndexOf(`
`);var M=this.domNode.textContent.slice(E).indexOf(`
`);return M>-1?E+M:-1}},{key:"optimize",value:function(E){this.domNode.textContent.endsWith(`
`)||this.appendChild(m.default.create("text",`
`)),d($.prototype.__proto__||Object.getPrototypeOf($.prototype),"optimize",this).call(this,E);var _=this.next;_!=null&&_.prev===this&&_.statics.blotName===this.statics.blotName&&this.statics.formats(this.domNode)===_.statics.formats(_.domNode)&&(_.optimize(E),_.moveChildren(this),_.remove())}},{key:"replace",value:function(E){d($.prototype.__proto__||Object.getPrototypeOf($.prototype),"replace",this).call(this,E),[].slice.call(this.domNode.querySelectorAll("*")).forEach(function(_){var M=m.default.find(_);M==null?_.parentNode.removeChild(_):M instanceof m.default.Embed?M.remove():M.unwrap()})}}],[{key:"create",value:function(E){var _=d($.__proto__||Object.getPrototypeOf($),"create",this).call(this,E);return _.setAttribute("spellcheck",!1),_}},{key:"formats",value:function(){return!0}}]),$})(u.default);A.blotName="code-block",A.tagName="PRE",A.TAB=" ",r.Code=P,r.default=A}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(F){return typeof F}:function(F){return F&&typeof Symbol=="function"&&F.constructor===Symbol&&F!==Symbol.prototype?"symbol":typeof F},c=(function(){function F(B,D){var O=[],V=!0,K=!1,Y=void 0;try{for(var U=B[Symbol.iterator](),X;!(V=(X=U.next()).done)&&(O.push(X.value),!(D&&O.length===D));V=!0);}catch(ne){K=!0,Y=ne}finally{try{!V&&U.return&&U.return()}finally{if(K)throw Y}}return O}return function(B,D){if(Array.isArray(B))return B;if(Symbol.iterator in Object(B))return F(B,D);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function F(B,D){for(var O=0;O<D.length;O++){var V=D[O];V.enumerable=V.enumerable||!1,V.configurable=!0,"value"in V&&(V.writable=!0),Object.defineProperty(B,V.key,V)}}return function(B,D,O){return D&&F(B.prototype,D),O&&F(B,O),B}})(),h=a(2),x=_(h),f=a(20),m=_(f),p=a(0),u=_(p),j=a(13),g=_(j),y=a(24),N=_(y),S=a(4),C=_(S),w=a(16),R=_(w),P=a(21),A=_(P),I=a(11),$=_(I),T=a(3),E=_(T);function _(F){return F&&F.__esModule?F:{default:F}}function M(F,B,D){return B in F?Object.defineProperty(F,B,{value:D,enumerable:!0,configurable:!0,writable:!0}):F[B]=D,F}function q(F,B){if(!(F instanceof B))throw new TypeError("Cannot call a class as a function")}var G=/^[ -~]*$/,Z=(function(){function F(B){q(this,F),this.scroll=B,this.delta=this.getDelta()}return d(F,[{key:"applyDelta",value:function(D){var O=this,V=!1;this.scroll.update();var K=this.scroll.length();return this.scroll.batchStart(),D=z(D),D.reduce(function(Y,U){var X=U.retain||U.delete||U.insert.length||1,ne=U.attributes||{};if(U.insert!=null){if(typeof U.insert=="string"){var oe=U.insert;oe.endsWith(`
`)&&V&&(V=!1,oe=oe.slice(0,-1)),Y>=K&&!oe.endsWith(`
`)&&(V=!0),O.scroll.insertAt(Y,oe);var re=O.scroll.line(Y),ge=c(re,2),ve=ge[0],Se=ge[1],We=(0,E.default)({},(0,S.bubbleFormats)(ve));if(ve instanceof C.default){var Ce=ve.descendant(u.default.Leaf,Se),fe=c(Ce,1),Ye=fe[0];We=(0,E.default)(We,(0,S.bubbleFormats)(Ye))}ne=m.default.attributes.diff(We,ne)||{}}else if(l(U.insert)==="object"){var be=Object.keys(U.insert)[0];if(be==null)return Y;O.scroll.insertAt(Y,be,U.insert[be])}K+=X}return Object.keys(ne).forEach(function(_e){O.scroll.formatAt(Y,X,_e,ne[_e])}),Y+X},0),D.reduce(function(Y,U){return typeof U.delete=="number"?(O.scroll.deleteAt(Y,U.delete),Y):Y+(U.retain||U.insert.length||1)},0),this.scroll.batchEnd(),this.update(D)}},{key:"deleteText",value:function(D,O){return this.scroll.deleteAt(D,O),this.update(new x.default().retain(D).delete(O))}},{key:"formatLine",value:function(D,O){var V=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.scroll.update(),Object.keys(K).forEach(function(Y){if(!(V.scroll.whitelist!=null&&!V.scroll.whitelist[Y])){var U=V.scroll.lines(D,Math.max(O,1)),X=O;U.forEach(function(ne){var oe=ne.length();if(!(ne instanceof g.default))ne.format(Y,K[Y]);else{var re=D-ne.offset(V.scroll),ge=ne.newlineIndex(re+X)-re+1;ne.formatAt(re,ge,Y,K[Y])}X-=oe})}}),this.scroll.optimize(),this.update(new x.default().retain(D).retain(O,(0,A.default)(K)))}},{key:"formatText",value:function(D,O){var V=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return Object.keys(K).forEach(function(Y){V.scroll.formatAt(D,O,Y,K[Y])}),this.update(new x.default().retain(D).retain(O,(0,A.default)(K)))}},{key:"getContents",value:function(D,O){return this.delta.slice(D,D+O)}},{key:"getDelta",value:function(){return this.scroll.lines().reduce(function(D,O){return D.concat(O.delta())},new x.default)}},{key:"getFormat",value:function(D){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,V=[],K=[];O===0?this.scroll.path(D).forEach(function(U){var X=c(U,1),ne=X[0];ne instanceof C.default?V.push(ne):ne instanceof u.default.Leaf&&K.push(ne)}):(V=this.scroll.lines(D,O),K=this.scroll.descendants(u.default.Leaf,D,O));var Y=[V,K].map(function(U){if(U.length===0)return{};for(var X=(0,S.bubbleFormats)(U.shift());Object.keys(X).length>0;){var ne=U.shift();if(ne==null)return X;X=W((0,S.bubbleFormats)(ne),X)}return X});return E.default.apply(E.default,Y)}},{key:"getText",value:function(D,O){return this.getContents(D,O).filter(function(V){return typeof V.insert=="string"}).map(function(V){return V.insert}).join("")}},{key:"insertEmbed",value:function(D,O,V){return this.scroll.insertAt(D,O,V),this.update(new x.default().retain(D).insert(M({},O,V)))}},{key:"insertText",value:function(D,O){var V=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return O=O.replace(/\r\n/g,`
`).replace(/\r/g,`
`),this.scroll.insertAt(D,O),Object.keys(K).forEach(function(Y){V.scroll.formatAt(D,O.length,Y,K[Y])}),this.update(new x.default().retain(D).insert(O,(0,A.default)(K)))}},{key:"isBlank",value:function(){if(this.scroll.children.length==0)return!0;if(this.scroll.children.length>1)return!1;var D=this.scroll.children.head;return D.statics.blotName!==C.default.blotName||D.children.length>1?!1:D.children.head instanceof R.default}},{key:"removeFormat",value:function(D,O){var V=this.getText(D,O),K=this.scroll.line(D+O),Y=c(K,2),U=Y[0],X=Y[1],ne=0,oe=new x.default;U!=null&&(U instanceof g.default?ne=U.newlineIndex(X)-X+1:ne=U.length()-X,oe=U.delta().slice(X,X+ne-1).insert(`
`));var re=this.getContents(D,O+ne),ge=re.diff(new x.default().insert(V).concat(oe)),ve=new x.default().retain(D).concat(ge);return this.applyDelta(ve)}},{key:"update",value:function(D){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],V=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,K=this.delta;if(O.length===1&&O[0].type==="characterData"&&O[0].target.data.match(G)&&u.default.find(O[0].target)){var Y=u.default.find(O[0].target),U=(0,S.bubbleFormats)(Y),X=Y.offset(this.scroll),ne=O[0].oldValue.replace(N.default.CONTENTS,""),oe=new x.default().insert(ne),re=new x.default().insert(Y.value()),ge=new x.default().retain(X).concat(oe.diff(re,V));D=ge.reduce(function(ve,Se){return Se.insert?ve.insert(Se.insert,U):ve.push(Se)},new x.default),this.delta=K.compose(D)}else this.delta=this.getDelta(),(!D||!(0,$.default)(K.compose(D),this.delta))&&(D=K.diff(this.delta,V));return D}}]),F})();function W(F,B){return Object.keys(B).reduce(function(D,O){return F[O]==null||(B[O]===F[O]?D[O]=B[O]:Array.isArray(B[O])?B[O].indexOf(F[O])<0&&(D[O]=B[O].concat([F[O]])):D[O]=[B[O],F[O]]),D},{})}function z(F){return F.reduce(function(B,D){if(D.insert===1){var O=(0,A.default)(D.attributes);return delete O.image,B.insert({image:D.attributes.image},O)}if(D.attributes!=null&&(D.attributes.list===!0||D.attributes.bullet===!0)&&(D=(0,A.default)(D),D.attributes.list?D.attributes.list="ordered":(D.attributes.list="bullet",delete D.attributes.bullet)),typeof D.insert=="string"){var V=D.insert.replace(/\r\n/g,`
`).replace(/\r/g,`
`);return B.insert(V,D.attributes)}return B.push(D)},new x.default)}r.default=Z}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.Range=void 0;var l=(function(){function I($,T){var E=[],_=!0,M=!1,q=void 0;try{for(var G=$[Symbol.iterator](),Z;!(_=(Z=G.next()).done)&&(E.push(Z.value),!(T&&E.length===T));_=!0);}catch(W){M=!0,q=W}finally{try{!_&&G.return&&G.return()}finally{if(M)throw q}}return E}return function($,T){if(Array.isArray($))return $;if(Symbol.iterator in Object($))return I($,T);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),c=(function(){function I($,T){for(var E=0;E<T.length;E++){var _=T[E];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty($,_.key,_)}}return function($,T,E){return T&&I($.prototype,T),E&&I($,E),$}})(),d=a(0),h=N(d),x=a(21),f=N(x),m=a(11),p=N(m),u=a(8),j=N(u),g=a(10),y=N(g);function N(I){return I&&I.__esModule?I:{default:I}}function S(I){if(Array.isArray(I)){for(var $=0,T=Array(I.length);$<I.length;$++)T[$]=I[$];return T}else return Array.from(I)}function C(I,$){if(!(I instanceof $))throw new TypeError("Cannot call a class as a function")}var w=(0,y.default)("quill:selection"),R=function I($){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;C(this,I),this.index=$,this.length=T},P=(function(){function I($,T){var E=this;C(this,I),this.emitter=T,this.scroll=$,this.composing=!1,this.mouseDown=!1,this.root=this.scroll.domNode,this.cursor=h.default.create("cursor",this),this.lastRange=this.savedRange=new R(0,0),this.handleComposition(),this.handleDragging(),this.emitter.listenDOM("selectionchange",document,function(){E.mouseDown||setTimeout(E.update.bind(E,j.default.sources.USER),1)}),this.emitter.on(j.default.events.EDITOR_CHANGE,function(_,M){_===j.default.events.TEXT_CHANGE&&M.length()>0&&E.update(j.default.sources.SILENT)}),this.emitter.on(j.default.events.SCROLL_BEFORE_UPDATE,function(){if(E.hasFocus()){var _=E.getNativeRange();_!=null&&_.start.node!==E.cursor.textNode&&E.emitter.once(j.default.events.SCROLL_UPDATE,function(){try{E.setNativeRange(_.start.node,_.start.offset,_.end.node,_.end.offset)}catch{}})}}),this.emitter.on(j.default.events.SCROLL_OPTIMIZE,function(_,M){if(M.range){var q=M.range,G=q.startNode,Z=q.startOffset,W=q.endNode,z=q.endOffset;E.setNativeRange(G,Z,W,z)}}),this.update(j.default.sources.SILENT)}return c(I,[{key:"handleComposition",value:function(){var T=this;this.root.addEventListener("compositionstart",function(){T.composing=!0}),this.root.addEventListener("compositionend",function(){if(T.composing=!1,T.cursor.parent){var E=T.cursor.restore();if(!E)return;setTimeout(function(){T.setNativeRange(E.startNode,E.startOffset,E.endNode,E.endOffset)},1)}})}},{key:"handleDragging",value:function(){var T=this;this.emitter.listenDOM("mousedown",document.body,function(){T.mouseDown=!0}),this.emitter.listenDOM("mouseup",document.body,function(){T.mouseDown=!1,T.update(j.default.sources.USER)})}},{key:"focus",value:function(){this.hasFocus()||(this.root.focus(),this.setRange(this.savedRange))}},{key:"format",value:function(T,E){if(!(this.scroll.whitelist!=null&&!this.scroll.whitelist[T])){this.scroll.update();var _=this.getNativeRange();if(!(_==null||!_.native.collapsed||h.default.query(T,h.default.Scope.BLOCK))){if(_.start.node!==this.cursor.textNode){var M=h.default.find(_.start.node,!1);if(M==null)return;if(M instanceof h.default.Leaf){var q=M.split(_.start.offset);M.parent.insertBefore(this.cursor,q)}else M.insertBefore(this.cursor,_.start.node);this.cursor.attach()}this.cursor.format(T,E),this.scroll.optimize(),this.setNativeRange(this.cursor.textNode,this.cursor.textNode.data.length),this.update()}}}},{key:"getBounds",value:function(T){var E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,_=this.scroll.length();T=Math.min(T,_-1),E=Math.min(T+E,_-1)-T;var M=void 0,q=this.scroll.leaf(T),G=l(q,2),Z=G[0],W=G[1];if(Z==null)return null;var z=Z.position(W,!0),F=l(z,2);M=F[0],W=F[1];var B=document.createRange();if(E>0){B.setStart(M,W);var D=this.scroll.leaf(T+E),O=l(D,2);if(Z=O[0],W=O[1],Z==null)return null;var V=Z.position(W,!0),K=l(V,2);return M=K[0],W=K[1],B.setEnd(M,W),B.getBoundingClientRect()}else{var Y="left",U=void 0;return M instanceof Text?(W<M.data.length?(B.setStart(M,W),B.setEnd(M,W+1)):(B.setStart(M,W-1),B.setEnd(M,W),Y="right"),U=B.getBoundingClientRect()):(U=Z.domNode.getBoundingClientRect(),W>0&&(Y="right")),{bottom:U.top+U.height,height:U.height,left:U[Y],right:U[Y],top:U.top,width:0}}}},{key:"getNativeRange",value:function(){var T=document.getSelection();if(T==null||T.rangeCount<=0)return null;var E=T.getRangeAt(0);if(E==null)return null;var _=this.normalizeNative(E);return w.info("getNativeRange",_),_}},{key:"getRange",value:function(){var T=this.getNativeRange();if(T==null)return[null,null];var E=this.normalizedToRange(T);return[E,T]}},{key:"hasFocus",value:function(){return document.activeElement===this.root}},{key:"normalizedToRange",value:function(T){var E=this,_=[[T.start.node,T.start.offset]];T.native.collapsed||_.push([T.end.node,T.end.offset]);var M=_.map(function(Z){var W=l(Z,2),z=W[0],F=W[1],B=h.default.find(z,!0),D=B.offset(E.scroll);return F===0?D:B instanceof h.default.Container?D+B.length():D+B.index(z,F)}),q=Math.min(Math.max.apply(Math,S(M)),this.scroll.length()-1),G=Math.min.apply(Math,[q].concat(S(M)));return new R(G,q-G)}},{key:"normalizeNative",value:function(T){if(!A(this.root,T.startContainer)||!T.collapsed&&!A(this.root,T.endContainer))return null;var E={start:{node:T.startContainer,offset:T.startOffset},end:{node:T.endContainer,offset:T.endOffset},native:T};return[E.start,E.end].forEach(function(_){for(var M=_.node,q=_.offset;!(M instanceof Text)&&M.childNodes.length>0;)if(M.childNodes.length>q)M=M.childNodes[q],q=0;else if(M.childNodes.length===q)M=M.lastChild,q=M instanceof Text?M.data.length:M.childNodes.length+1;else break;_.node=M,_.offset=q}),E}},{key:"rangeToNative",value:function(T){var E=this,_=T.collapsed?[T.index]:[T.index,T.index+T.length],M=[],q=this.scroll.length();return _.forEach(function(G,Z){G=Math.min(q-1,G);var W=void 0,z=E.scroll.leaf(G),F=l(z,2),B=F[0],D=F[1],O=B.position(D,Z!==0),V=l(O,2);W=V[0],D=V[1],M.push(W,D)}),M.length<2&&(M=M.concat(M)),M}},{key:"scrollIntoView",value:function(T){var E=this.lastRange;if(E!=null){var _=this.getBounds(E.index,E.length);if(_!=null){var M=this.scroll.length()-1,q=this.scroll.line(Math.min(E.index,M)),G=l(q,1),Z=G[0],W=Z;if(E.length>0){var z=this.scroll.line(Math.min(E.index+E.length,M)),F=l(z,1);W=F[0]}if(!(Z==null||W==null)){var B=T.getBoundingClientRect();_.top<B.top?T.scrollTop-=B.top-_.top:_.bottom>B.bottom&&(T.scrollTop+=_.bottom-B.bottom)}}}}},{key:"setNativeRange",value:function(T,E){var _=arguments.length>2&&arguments[2]!==void 0?arguments[2]:T,M=arguments.length>3&&arguments[3]!==void 0?arguments[3]:E,q=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;if(w.info("setNativeRange",T,E,_,M),!(T!=null&&(this.root.parentNode==null||T.parentNode==null||_.parentNode==null))){var G=document.getSelection();if(G!=null)if(T!=null){this.hasFocus()||this.root.focus();var Z=(this.getNativeRange()||{}).native;if(Z==null||q||T!==Z.startContainer||E!==Z.startOffset||_!==Z.endContainer||M!==Z.endOffset){T.tagName=="BR"&&(E=[].indexOf.call(T.parentNode.childNodes,T),T=T.parentNode),_.tagName=="BR"&&(M=[].indexOf.call(_.parentNode.childNodes,_),_=_.parentNode);var W=document.createRange();W.setStart(T,E),W.setEnd(_,M),G.removeAllRanges(),G.addRange(W)}}else G.removeAllRanges(),this.root.blur(),document.body.focus()}}},{key:"setRange",value:function(T){var E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,_=arguments.length>2&&arguments[2]!==void 0?arguments[2]:j.default.sources.API;if(typeof E=="string"&&(_=E,E=!1),w.info("setRange",T),T!=null){var M=this.rangeToNative(T);this.setNativeRange.apply(this,S(M).concat([E]))}else this.setNativeRange(null);this.update(_)}},{key:"update",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:j.default.sources.USER,E=this.lastRange,_=this.getRange(),M=l(_,2),q=M[0],G=M[1];if(this.lastRange=q,this.lastRange!=null&&(this.savedRange=this.lastRange),!(0,p.default)(E,this.lastRange)){var Z;!this.composing&&G!=null&&G.native.collapsed&&G.start.node!==this.cursor.textNode&&this.cursor.restore();var W=[j.default.events.SELECTION_CHANGE,(0,f.default)(this.lastRange),(0,f.default)(E),T];if((Z=this.emitter).emit.apply(Z,[j.default.events.EDITOR_CHANGE].concat(W)),T!==j.default.sources.SILENT){var z;(z=this.emitter).emit.apply(z,W)}}}}]),I})();function A(I,$){try{$.parentNode}catch{return!1}return $ instanceof Text&&($=$.parentNode),I.contains($)}r.Range=R,r.default=P}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function j(g,y){for(var N=0;N<y.length;N++){var S=y[N];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(g,S.key,S)}}return function(g,y,N){return y&&j(g.prototype,y),N&&j(g,N),g}})(),c=function j(g,y,N){g===null&&(g=Function.prototype);var S=Object.getOwnPropertyDescriptor(g,y);if(S===void 0){var C=Object.getPrototypeOf(g);return C===null?void 0:j(C,y,N)}else{if("value"in S)return S.value;var w=S.get;return w===void 0?void 0:w.call(N)}},d=a(0),h=x(d);function x(j){return j&&j.__esModule?j:{default:j}}function f(j,g){if(!(j instanceof g))throw new TypeError("Cannot call a class as a function")}function m(j,g){if(!j)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:j}function p(j,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);j.prototype=Object.create(g&&g.prototype,{constructor:{value:j,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(j,g):j.__proto__=g)}var u=(function(j){p(g,j);function g(){return f(this,g),m(this,(g.__proto__||Object.getPrototypeOf(g)).apply(this,arguments))}return l(g,[{key:"insertInto",value:function(N,S){N.children.length===0?c(g.prototype.__proto__||Object.getPrototypeOf(g.prototype),"insertInto",this).call(this,N,S):this.remove()}},{key:"length",value:function(){return 0}},{key:"value",value:function(){return""}}],[{key:"value",value:function(){}}]),g})(h.default.Embed);u.blotName="break",u.tagName="BR",r.default=u}),(function(n,r,a){var l=this&&this.__extends||(function(){var m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,u){p.__proto__=u}||function(p,u){for(var j in u)u.hasOwnProperty(j)&&(p[j]=u[j])};return function(p,u){m(p,u);function j(){this.constructor=p}p.prototype=u===null?Object.create(u):(j.prototype=u.prototype,new j)}})();Object.defineProperty(r,"__esModule",{value:!0});var c=a(44),d=a(30),h=a(1),x=(function(m){l(p,m);function p(u){var j=m.call(this,u)||this;return j.build(),j}return p.prototype.appendChild=function(u){this.insertBefore(u)},p.prototype.attach=function(){m.prototype.attach.call(this),this.children.forEach(function(u){u.attach()})},p.prototype.build=function(){var u=this;this.children=new c.default,[].slice.call(this.domNode.childNodes).reverse().forEach(function(j){try{var g=f(j);u.insertBefore(g,u.children.head||void 0)}catch(y){if(y instanceof h.ParchmentError)return;throw y}})},p.prototype.deleteAt=function(u,j){if(u===0&&j===this.length())return this.remove();this.children.forEachAt(u,j,function(g,y,N){g.deleteAt(y,N)})},p.prototype.descendant=function(u,j){var g=this.children.find(j),y=g[0],N=g[1];return u.blotName==null&&u(y)||u.blotName!=null&&y instanceof u?[y,N]:y instanceof p?y.descendant(u,N):[null,-1]},p.prototype.descendants=function(u,j,g){j===void 0&&(j=0),g===void 0&&(g=Number.MAX_VALUE);var y=[],N=g;return this.children.forEachAt(j,g,function(S,C,w){(u.blotName==null&&u(S)||u.blotName!=null&&S instanceof u)&&y.push(S),S instanceof p&&(y=y.concat(S.descendants(u,C,N))),N-=w}),y},p.prototype.detach=function(){this.children.forEach(function(u){u.detach()}),m.prototype.detach.call(this)},p.prototype.formatAt=function(u,j,g,y){this.children.forEachAt(u,j,function(N,S,C){N.formatAt(S,C,g,y)})},p.prototype.insertAt=function(u,j,g){var y=this.children.find(u),N=y[0],S=y[1];if(N)N.insertAt(S,j,g);else{var C=g==null?h.create("text",j):h.create(j,g);this.appendChild(C)}},p.prototype.insertBefore=function(u,j){if(this.statics.allowedChildren!=null&&!this.statics.allowedChildren.some(function(g){return u instanceof g}))throw new h.ParchmentError("Cannot insert "+u.statics.blotName+" into "+this.statics.blotName);u.insertInto(this,j)},p.prototype.length=function(){return this.children.reduce(function(u,j){return u+j.length()},0)},p.prototype.moveChildren=function(u,j){this.children.forEach(function(g){u.insertBefore(g,j)})},p.prototype.optimize=function(u){if(m.prototype.optimize.call(this,u),this.children.length===0)if(this.statics.defaultChild!=null){var j=h.create(this.statics.defaultChild);this.appendChild(j),j.optimize(u)}else this.remove()},p.prototype.path=function(u,j){j===void 0&&(j=!1);var g=this.children.find(u,j),y=g[0],N=g[1],S=[[this,u]];return y instanceof p?S.concat(y.path(N,j)):(y!=null&&S.push([y,N]),S)},p.prototype.removeChild=function(u){this.children.remove(u)},p.prototype.replace=function(u){u instanceof p&&u.moveChildren(this),m.prototype.replace.call(this,u)},p.prototype.split=function(u,j){if(j===void 0&&(j=!1),!j){if(u===0)return this;if(u===this.length())return this.next}var g=this.clone();return this.parent.insertBefore(g,this.next),this.children.forEachAt(u,this.length(),function(y,N,S){y=y.split(N,j),g.appendChild(y)}),g},p.prototype.unwrap=function(){this.moveChildren(this.parent,this.next),this.remove()},p.prototype.update=function(u,j){var g=this,y=[],N=[];u.forEach(function(S){S.target===g.domNode&&S.type==="childList"&&(y.push.apply(y,S.addedNodes),N.push.apply(N,S.removedNodes))}),N.forEach(function(S){if(!(S.parentNode!=null&&S.tagName!=="IFRAME"&&document.body.compareDocumentPosition(S)&Node.DOCUMENT_POSITION_CONTAINED_BY)){var C=h.find(S);C!=null&&(C.domNode.parentNode==null||C.domNode.parentNode===g.domNode)&&C.detach()}}),y.filter(function(S){return S.parentNode==g.domNode}).sort(function(S,C){return S===C?0:S.compareDocumentPosition(C)&Node.DOCUMENT_POSITION_FOLLOWING?1:-1}).forEach(function(S){var C=null;S.nextSibling!=null&&(C=h.find(S.nextSibling));var w=f(S);(w.next!=C||w.next==null)&&(w.parent!=null&&w.parent.removeChild(g),g.insertBefore(w,C||void 0))})},p})(d.default);function f(m){var p=h.find(m);if(p==null)try{p=h.create(m)}catch{p=h.create(h.Scope.INLINE),[].slice.call(m.childNodes).forEach(function(j){p.domNode.appendChild(j)}),m.parentNode&&m.parentNode.replaceChild(p.domNode,m),p.attach()}return p}r.default=x}),(function(n,r,a){var l=this&&this.__extends||(function(){var m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,u){p.__proto__=u}||function(p,u){for(var j in u)u.hasOwnProperty(j)&&(p[j]=u[j])};return function(p,u){m(p,u);function j(){this.constructor=p}p.prototype=u===null?Object.create(u):(j.prototype=u.prototype,new j)}})();Object.defineProperty(r,"__esModule",{value:!0});var c=a(12),d=a(31),h=a(17),x=a(1),f=(function(m){l(p,m);function p(u){var j=m.call(this,u)||this;return j.attributes=new d.default(j.domNode),j}return p.formats=function(u){if(typeof this.tagName=="string")return!0;if(Array.isArray(this.tagName))return u.tagName.toLowerCase()},p.prototype.format=function(u,j){var g=x.query(u);g instanceof c.default?this.attributes.attribute(g,j):j&&g!=null&&(u!==this.statics.blotName||this.formats()[u]!==j)&&this.replaceWith(u,j)},p.prototype.formats=function(){var u=this.attributes.values(),j=this.statics.formats(this.domNode);return j!=null&&(u[this.statics.blotName]=j),u},p.prototype.replaceWith=function(u,j){var g=m.prototype.replaceWith.call(this,u,j);return this.attributes.copy(g),g},p.prototype.update=function(u,j){var g=this;m.prototype.update.call(this,u,j),u.some(function(y){return y.target===g.domNode&&y.type==="attributes"})&&this.attributes.build()},p.prototype.wrap=function(u,j){var g=m.prototype.wrap.call(this,u,j);return g instanceof p&&g.statics.scope===this.statics.scope&&this.attributes.move(g),g},p})(h.default);r.default=f}),(function(n,r,a){var l=this&&this.__extends||(function(){var x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,m){f.__proto__=m}||function(f,m){for(var p in m)m.hasOwnProperty(p)&&(f[p]=m[p])};return function(f,m){x(f,m);function p(){this.constructor=f}f.prototype=m===null?Object.create(m):(p.prototype=m.prototype,new p)}})();Object.defineProperty(r,"__esModule",{value:!0});var c=a(30),d=a(1),h=(function(x){l(f,x);function f(){return x!==null&&x.apply(this,arguments)||this}return f.value=function(m){return!0},f.prototype.index=function(m,p){return this.domNode===m||this.domNode.compareDocumentPosition(m)&Node.DOCUMENT_POSITION_CONTAINED_BY?Math.min(p,1):-1},f.prototype.position=function(m,p){var u=[].indexOf.call(this.parent.domNode.childNodes,this.domNode);return m>0&&(u+=1),[this.parent.domNode,u]},f.prototype.value=function(){var m;return m={},m[this.statics.blotName]=this.statics.value(this.domNode)||!0,m},f.scope=d.Scope.INLINE_BLOT,f})(c.default);r.default=h}),(function(n,r,a){var l=a(11),c=a(3),d={attributes:{compose:function(x,f,m){typeof x!="object"&&(x={}),typeof f!="object"&&(f={});var p=c(!0,{},f);m||(p=Object.keys(p).reduce(function(j,g){return p[g]!=null&&(j[g]=p[g]),j},{}));for(var u in x)x[u]!==void 0&&f[u]===void 0&&(p[u]=x[u]);return Object.keys(p).length>0?p:void 0},diff:function(x,f){typeof x!="object"&&(x={}),typeof f!="object"&&(f={});var m=Object.keys(x).concat(Object.keys(f)).reduce(function(p,u){return l(x[u],f[u])||(p[u]=f[u]===void 0?null:f[u]),p},{});return Object.keys(m).length>0?m:void 0},transform:function(x,f,m){if(typeof x!="object")return f;if(typeof f=="object"){if(!m)return f;var p=Object.keys(f).reduce(function(u,j){return x[j]===void 0&&(u[j]=f[j]),u},{});return Object.keys(p).length>0?p:void 0}}},iterator:function(x){return new h(x)},length:function(x){return typeof x.delete=="number"?x.delete:typeof x.retain=="number"?x.retain:typeof x.insert=="string"?x.insert.length:1}};function h(x){this.ops=x,this.index=0,this.offset=0}h.prototype.hasNext=function(){return this.peekLength()<1/0},h.prototype.next=function(x){x||(x=1/0);var f=this.ops[this.index];if(f){var m=this.offset,p=d.length(f);if(x>=p-m?(x=p-m,this.index+=1,this.offset=0):this.offset+=x,typeof f.delete=="number")return{delete:x};var u={};return f.attributes&&(u.attributes=f.attributes),typeof f.retain=="number"?u.retain=x:typeof f.insert=="string"?u.insert=f.insert.substr(m,x):u.insert=f.insert,u}else return{retain:1/0}},h.prototype.peek=function(){return this.ops[this.index]},h.prototype.peekLength=function(){return this.ops[this.index]?d.length(this.ops[this.index])-this.offset:1/0},h.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"},h.prototype.rest=function(){if(this.hasNext()){if(this.offset===0)return this.ops.slice(this.index);var x=this.offset,f=this.index,m=this.next(),p=this.ops.slice(this.index);return this.offset=x,this.index=f,[m].concat(p)}else return[]},n.exports=d}),(function(n,r){var a=(function(){function l(g,y){return y!=null&&g instanceof y}var c;try{c=Map}catch{c=function(){}}var d;try{d=Set}catch{d=function(){}}var h;try{h=Promise}catch{h=function(){}}function x(g,y,N,S,C){typeof y=="object"&&(N=y.depth,S=y.prototype,C=y.includeNonEnumerable,y=y.circular);var w=[],R=[],P=typeof Buffer<"u";typeof y>"u"&&(y=!0),typeof N>"u"&&(N=1/0);function A(I,$){if(I===null)return null;if($===0)return I;var T,E;if(typeof I!="object")return I;if(l(I,c))T=new c;else if(l(I,d))T=new d;else if(l(I,h))T=new h(function(B,D){I.then(function(O){B(A(O,$-1))},function(O){D(A(O,$-1))})});else if(x.__isArray(I))T=[];else if(x.__isRegExp(I))T=new RegExp(I.source,j(I)),I.lastIndex&&(T.lastIndex=I.lastIndex);else if(x.__isDate(I))T=new Date(I.getTime());else{if(P&&Buffer.isBuffer(I))return Buffer.allocUnsafe?T=Buffer.allocUnsafe(I.length):T=new Buffer(I.length),I.copy(T),T;l(I,Error)?T=Object.create(I):typeof S>"u"?(E=Object.getPrototypeOf(I),T=Object.create(E)):(T=Object.create(S),E=S)}if(y){var _=w.indexOf(I);if(_!=-1)return R[_];w.push(I),R.push(T)}l(I,c)&&I.forEach(function(B,D){var O=A(D,$-1),V=A(B,$-1);T.set(O,V)}),l(I,d)&&I.forEach(function(B){var D=A(B,$-1);T.add(D)});for(var M in I){var q;E&&(q=Object.getOwnPropertyDescriptor(E,M)),!(q&&q.set==null)&&(T[M]=A(I[M],$-1))}if(Object.getOwnPropertySymbols)for(var G=Object.getOwnPropertySymbols(I),M=0;M<G.length;M++){var Z=G[M],W=Object.getOwnPropertyDescriptor(I,Z);W&&!W.enumerable&&!C||(T[Z]=A(I[Z],$-1),W.enumerable||Object.defineProperty(T,Z,{enumerable:!1}))}if(C)for(var z=Object.getOwnPropertyNames(I),M=0;M<z.length;M++){var F=z[M],W=Object.getOwnPropertyDescriptor(I,F);W&&W.enumerable||(T[F]=A(I[F],$-1),Object.defineProperty(T,F,{enumerable:!1}))}return T}return A(g,N)}x.clonePrototype=function(y){if(y===null)return null;var N=function(){};return N.prototype=y,new N};function f(g){return Object.prototype.toString.call(g)}x.__objToStr=f;function m(g){return typeof g=="object"&&f(g)==="[object Date]"}x.__isDate=m;function p(g){return typeof g=="object"&&f(g)==="[object Array]"}x.__isArray=p;function u(g){return typeof g=="object"&&f(g)==="[object RegExp]"}x.__isRegExp=u;function j(g){var y="";return g.global&&(y+="g"),g.ignoreCase&&(y+="i"),g.multiline&&(y+="m"),y}return x.__getRegExpFlags=j,x})();typeof n=="object"&&n.exports&&(n.exports=a)}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function T(E,_){var M=[],q=!0,G=!1,Z=void 0;try{for(var W=E[Symbol.iterator](),z;!(q=(z=W.next()).done)&&(M.push(z.value),!(_&&M.length===_));q=!0);}catch(F){G=!0,Z=F}finally{try{!q&&W.return&&W.return()}finally{if(G)throw Z}}return M}return function(E,_){if(Array.isArray(E))return E;if(Symbol.iterator in Object(E))return T(E,_);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),c=(function(){function T(E,_){for(var M=0;M<_.length;M++){var q=_[M];q.enumerable=q.enumerable||!1,q.configurable=!0,"value"in q&&(q.writable=!0),Object.defineProperty(E,q.key,q)}}return function(E,_,M){return _&&T(E.prototype,_),M&&T(E,M),E}})(),d=function T(E,_,M){E===null&&(E=Function.prototype);var q=Object.getOwnPropertyDescriptor(E,_);if(q===void 0){var G=Object.getPrototypeOf(E);return G===null?void 0:T(G,_,M)}else{if("value"in q)return q.value;var Z=q.get;return Z===void 0?void 0:Z.call(M)}},h=a(0),x=w(h),f=a(8),m=w(f),p=a(4),u=w(p),j=a(16),g=w(j),y=a(13),N=w(y),S=a(25),C=w(S);function w(T){return T&&T.__esModule?T:{default:T}}function R(T,E){if(!(T instanceof E))throw new TypeError("Cannot call a class as a function")}function P(T,E){if(!T)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return E&&(typeof E=="object"||typeof E=="function")?E:T}function A(T,E){if(typeof E!="function"&&E!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof E);T.prototype=Object.create(E&&E.prototype,{constructor:{value:T,enumerable:!1,writable:!0,configurable:!0}}),E&&(Object.setPrototypeOf?Object.setPrototypeOf(T,E):T.__proto__=E)}function I(T){return T instanceof u.default||T instanceof p.BlockEmbed}var $=(function(T){A(E,T);function E(_,M){R(this,E);var q=P(this,(E.__proto__||Object.getPrototypeOf(E)).call(this,_));return q.emitter=M.emitter,Array.isArray(M.whitelist)&&(q.whitelist=M.whitelist.reduce(function(G,Z){return G[Z]=!0,G},{})),q.domNode.addEventListener("DOMNodeInserted",function(){}),q.optimize(),q.enable(),q}return c(E,[{key:"batchStart",value:function(){this.batch=!0}},{key:"batchEnd",value:function(){this.batch=!1,this.optimize()}},{key:"deleteAt",value:function(M,q){var G=this.line(M),Z=l(G,2),W=Z[0],z=Z[1],F=this.line(M+q),B=l(F,1),D=B[0];if(d(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"deleteAt",this).call(this,M,q),D!=null&&W!==D&&z>0){if(W instanceof p.BlockEmbed||D instanceof p.BlockEmbed){this.optimize();return}if(W instanceof N.default){var O=W.newlineIndex(W.length(),!0);if(O>-1&&(W=W.split(O+1),W===D)){this.optimize();return}}else if(D instanceof N.default){var V=D.newlineIndex(0);V>-1&&D.split(V+1)}var K=D.children.head instanceof g.default?null:D.children.head;W.moveChildren(D,K),W.remove()}this.optimize()}},{key:"enable",value:function(){var M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.domNode.setAttribute("contenteditable",M)}},{key:"formatAt",value:function(M,q,G,Z){this.whitelist!=null&&!this.whitelist[G]||(d(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"formatAt",this).call(this,M,q,G,Z),this.optimize())}},{key:"insertAt",value:function(M,q,G){if(!(G!=null&&this.whitelist!=null&&!this.whitelist[q])){if(M>=this.length())if(G==null||x.default.query(q,x.default.Scope.BLOCK)==null){var Z=x.default.create(this.statics.defaultChild);this.appendChild(Z),G==null&&q.endsWith(`
`)&&(q=q.slice(0,-1)),Z.insertAt(0,q,G)}else{var W=x.default.create(q,G);this.appendChild(W)}else d(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"insertAt",this).call(this,M,q,G);this.optimize()}}},{key:"insertBefore",value:function(M,q){if(M.statics.scope===x.default.Scope.INLINE_BLOT){var G=x.default.create(this.statics.defaultChild);G.appendChild(M),M=G}d(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"insertBefore",this).call(this,M,q)}},{key:"leaf",value:function(M){return this.path(M).pop()||[null,-1]}},{key:"line",value:function(M){return M===this.length()?this.line(M-1):this.descendant(I,M)}},{key:"lines",value:function(){var M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE,G=function Z(W,z,F){var B=[],D=F;return W.children.forEachAt(z,F,function(O,V,K){I(O)?B.push(O):O instanceof x.default.Container&&(B=B.concat(Z(O,V,D))),D-=K}),B};return G(this,M,q)}},{key:"optimize",value:function(){var M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.batch!==!0&&(d(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"optimize",this).call(this,M,q),M.length>0&&this.emitter.emit(m.default.events.SCROLL_OPTIMIZE,M,q))}},{key:"path",value:function(M){return d(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"path",this).call(this,M).slice(1)}},{key:"update",value:function(M){if(this.batch!==!0){var q=m.default.sources.USER;typeof M=="string"&&(q=M),Array.isArray(M)||(M=this.observer.takeRecords()),M.length>0&&this.emitter.emit(m.default.events.SCROLL_BEFORE_UPDATE,q,M),d(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"update",this).call(this,M.concat([])),M.length>0&&this.emitter.emit(m.default.events.SCROLL_UPDATE,q,M)}}}]),E})(x.default.Scroll);$.blotName="scroll",$.className="ql-editor",$.tagName="DIV",$.defaultChild="block",$.allowedChildren=[u.default,p.BlockEmbed,C.default],r.default=$}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.SHORTKEY=r.default=void 0;var l=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(U){return typeof U}:function(U){return U&&typeof Symbol=="function"&&U.constructor===Symbol&&U!==Symbol.prototype?"symbol":typeof U},c=(function(){function U(X,ne){var oe=[],re=!0,ge=!1,ve=void 0;try{for(var Se=X[Symbol.iterator](),We;!(re=(We=Se.next()).done)&&(oe.push(We.value),!(ne&&oe.length===ne));re=!0);}catch(Ce){ge=!0,ve=Ce}finally{try{!re&&Se.return&&Se.return()}finally{if(ge)throw ve}}return oe}return function(X,ne){if(Array.isArray(X))return X;if(Symbol.iterator in Object(X))return U(X,ne);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function U(X,ne){for(var oe=0;oe<ne.length;oe++){var re=ne[oe];re.enumerable=re.enumerable||!1,re.configurable=!0,"value"in re&&(re.writable=!0),Object.defineProperty(X,re.key,re)}}return function(X,ne,oe){return ne&&U(X.prototype,ne),oe&&U(X,oe),X}})(),h=a(21),x=T(h),f=a(11),m=T(f),p=a(3),u=T(p),j=a(2),g=T(j),y=a(20),N=T(y),S=a(0),C=T(S),w=a(5),R=T(w),P=a(10),A=T(P),I=a(9),$=T(I);function T(U){return U&&U.__esModule?U:{default:U}}function E(U,X,ne){return X in U?Object.defineProperty(U,X,{value:ne,enumerable:!0,configurable:!0,writable:!0}):U[X]=ne,U}function _(U,X){if(!(U instanceof X))throw new TypeError("Cannot call a class as a function")}function M(U,X){if(!U)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return X&&(typeof X=="object"||typeof X=="function")?X:U}function q(U,X){if(typeof X!="function"&&X!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof X);U.prototype=Object.create(X&&X.prototype,{constructor:{value:U,enumerable:!1,writable:!0,configurable:!0}}),X&&(Object.setPrototypeOf?Object.setPrototypeOf(U,X):U.__proto__=X)}var G=(0,A.default)("quill:keyboard"),Z=/Mac/i.test(navigator.platform)?"metaKey":"ctrlKey",W=(function(U){q(X,U),d(X,null,[{key:"match",value:function(oe,re){return re=Y(re),["altKey","ctrlKey","metaKey","shiftKey"].some(function(ge){return!!re[ge]!==oe[ge]&&re[ge]!==null})?!1:re.key===(oe.which||oe.keyCode)}}]);function X(ne,oe){_(this,X);var re=M(this,(X.__proto__||Object.getPrototypeOf(X)).call(this,ne,oe));return re.bindings={},Object.keys(re.options.bindings).forEach(function(ge){ge==="list autofill"&&ne.scroll.whitelist!=null&&!ne.scroll.whitelist.list||re.options.bindings[ge]&&re.addBinding(re.options.bindings[ge])}),re.addBinding({key:X.keys.ENTER,shiftKey:null},O),re.addBinding({key:X.keys.ENTER,metaKey:null,ctrlKey:null,altKey:null},function(){}),/Firefox/i.test(navigator.userAgent)?(re.addBinding({key:X.keys.BACKSPACE},{collapsed:!0},F),re.addBinding({key:X.keys.DELETE},{collapsed:!0},B)):(re.addBinding({key:X.keys.BACKSPACE},{collapsed:!0,prefix:/^.?$/},F),re.addBinding({key:X.keys.DELETE},{collapsed:!0,suffix:/^.?$/},B)),re.addBinding({key:X.keys.BACKSPACE},{collapsed:!1},D),re.addBinding({key:X.keys.DELETE},{collapsed:!1},D),re.addBinding({key:X.keys.BACKSPACE,altKey:null,ctrlKey:null,metaKey:null,shiftKey:null},{collapsed:!0,offset:0},F),re.listen(),re}return d(X,[{key:"addBinding",value:function(oe){var re=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ge=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},ve=Y(oe);if(ve==null||ve.key==null)return G.warn("Attempted to add invalid keyboard binding",ve);typeof re=="function"&&(re={handler:re}),typeof ge=="function"&&(ge={handler:ge}),ve=(0,u.default)(ve,re,ge),this.bindings[ve.key]=this.bindings[ve.key]||[],this.bindings[ve.key].push(ve)}},{key:"listen",value:function(){var oe=this;this.quill.root.addEventListener("keydown",function(re){if(!re.defaultPrevented){var ge=re.which||re.keyCode,ve=(oe.bindings[ge]||[]).filter(function(Rt){return X.match(re,Rt)});if(ve.length!==0){var Se=oe.quill.getSelection();if(!(Se==null||!oe.quill.hasFocus())){var We=oe.quill.getLine(Se.index),Ce=c(We,2),fe=Ce[0],Ye=Ce[1],be=oe.quill.getLeaf(Se.index),_e=c(be,2),ke=_e[0],qe=_e[1],Ve=Se.length===0?[ke,qe]:oe.quill.getLeaf(Se.index+Se.length),dt=c(Ve,2),xt=dt[0],ye=dt[1],le=ke instanceof C.default.Text?ke.value().slice(0,qe):"",Qe=xt instanceof C.default.Text?xt.value().slice(ye):"",rt={collapsed:Se.length===0,empty:Se.length===0&&fe.length()<=1,format:oe.quill.getFormat(Se),offset:Ye,prefix:le,suffix:Qe},Kt=ve.some(function(Rt){if(Rt.collapsed!=null&&Rt.collapsed!==rt.collapsed||Rt.empty!=null&&Rt.empty!==rt.empty||Rt.offset!=null&&Rt.offset!==rt.offset)return!1;if(Array.isArray(Rt.format)){if(Rt.format.every(function(Re){return rt.format[Re]==null}))return!1}else if(l(Rt.format)==="object"&&!Object.keys(Rt.format).every(function(Re){return Rt.format[Re]===!0?rt.format[Re]!=null:Rt.format[Re]===!1?rt.format[Re]==null:(0,m.default)(Rt.format[Re],rt.format[Re])}))return!1;return Rt.prefix!=null&&!Rt.prefix.test(rt.prefix)||Rt.suffix!=null&&!Rt.suffix.test(rt.suffix)?!1:Rt.handler.call(oe,Se,rt)!==!0});Kt&&re.preventDefault()}}}})}}]),X})($.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:K("bold"),italic:K("italic"),underline:K("underline"),indent:{key:W.keys.TAB,format:["blockquote","indent","list"],handler:function(X,ne){if(ne.collapsed&&ne.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,ne){if(ne.collapsed&&ne.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,ne){ne.format.indent!=null?this.quill.format("indent","-1",R.default.sources.USER):ne.format.list!=null&&this.quill.format("list",!1,R.default.sources.USER)}},"indent code-block":V(!0),"outdent code-block":V(!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 ne=new g.default().retain(X.index).delete(X.length).insert(" ");this.quill.updateContents(ne,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,ne){this.quill.format("list",!1,R.default.sources.USER),ne.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 ne=this.quill.getLine(X.index),oe=c(ne,2),re=oe[0],ge=oe[1],ve=(0,u.default)({},re.formats(),{list:"checked"}),Se=new g.default().retain(X.index).insert(`
`,ve).retain(re.length()-ge-1).retain(1,{list:"unchecked"});this.quill.updateContents(Se,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,ne){var oe=this.quill.getLine(X.index),re=c(oe,2),ge=re[0],ve=re[1],Se=new g.default().retain(X.index).insert(`
`,ne.format).retain(ge.length()-ve-1).retain(1,{header:null});this.quill.updateContents(Se,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,ne){var oe=ne.prefix.length,re=this.quill.getLine(X.index),ge=c(re,2),ve=ge[0],Se=ge[1];if(Se>oe)return!0;var We=void 0;switch(ne.prefix.trim()){case"[]":case"[ ]":We="unchecked";break;case"[x]":We="checked";break;case"-":case"*":We="bullet";break;default:We="ordered"}this.quill.insertText(X.index," ",R.default.sources.USER),this.quill.history.cutoff();var Ce=new g.default().retain(X.index-Se).delete(oe+1).retain(ve.length()-2-Se).retain(1,{list:We});this.quill.updateContents(Ce,R.default.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(X.index-oe,R.default.sources.SILENT)}},"code exit":{key:W.keys.ENTER,collapsed:!0,format:["code-block"],prefix:/\n\n$/,suffix:/^\s+$/,handler:function(X){var ne=this.quill.getLine(X.index),oe=c(ne,2),re=oe[0],ge=oe[1],ve=new g.default().retain(X.index+re.length()-ge-2).retain(1,{"code-block":null}).delete(1);this.quill.updateContents(ve,R.default.sources.USER)}},"embed left":z(W.keys.LEFT,!1),"embed left shift":z(W.keys.LEFT,!0),"embed right":z(W.keys.RIGHT,!1),"embed right shift":z(W.keys.RIGHT,!0)}};function z(U,X){var ne,oe=U===W.keys.LEFT?"prefix":"suffix";return ne={key:U,shiftKey:X,altKey:null},E(ne,oe,/^$/),E(ne,"handler",function(ge){var ve=ge.index;U===W.keys.RIGHT&&(ve+=ge.length+1);var Se=this.quill.getLeaf(ve),We=c(Se,1),Ce=We[0];return Ce instanceof C.default.Embed?(U===W.keys.LEFT?X?this.quill.setSelection(ge.index-1,ge.length+1,R.default.sources.USER):this.quill.setSelection(ge.index-1,R.default.sources.USER):X?this.quill.setSelection(ge.index,ge.length+1,R.default.sources.USER):this.quill.setSelection(ge.index+ge.length+1,R.default.sources.USER),!1):!0}),ne}function F(U,X){if(!(U.index===0||this.quill.getLength()<=1)){var ne=this.quill.getLine(U.index),oe=c(ne,1),re=oe[0],ge={};if(X.offset===0){var ve=this.quill.getLine(U.index-1),Se=c(ve,1),We=Se[0];if(We!=null&&We.length()>1){var Ce=re.formats(),fe=this.quill.getFormat(U.index-1,1);ge=N.default.attributes.diff(Ce,fe)||{}}}var Ye=/[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(X.prefix)?2:1;this.quill.deleteText(U.index-Ye,Ye,R.default.sources.USER),Object.keys(ge).length>0&&this.quill.formatLine(U.index-Ye,Ye,ge,R.default.sources.USER),this.quill.focus()}}function B(U,X){var ne=/^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(X.suffix)?2:1;if(!(U.index>=this.quill.getLength()-ne)){var oe={},re=0,ge=this.quill.getLine(U.index),ve=c(ge,1),Se=ve[0];if(X.offset>=Se.length()-1){var We=this.quill.getLine(U.index+1),Ce=c(We,1),fe=Ce[0];if(fe){var Ye=Se.formats(),be=this.quill.getFormat(U.index,1);oe=N.default.attributes.diff(Ye,be)||{},re=fe.length()}}this.quill.deleteText(U.index,ne,R.default.sources.USER),Object.keys(oe).length>0&&this.quill.formatLine(U.index+re-1,ne,oe,R.default.sources.USER)}}function D(U){var X=this.quill.getLines(U),ne={};if(X.length>1){var oe=X[0].formats(),re=X[X.length-1].formats();ne=N.default.attributes.diff(re,oe)||{}}this.quill.deleteText(U,R.default.sources.USER),Object.keys(ne).length>0&&this.quill.formatLine(U.index,1,ne,R.default.sources.USER),this.quill.setSelection(U.index,R.default.sources.SILENT),this.quill.focus()}function O(U,X){var ne=this;U.length>0&&this.quill.scroll.deleteAt(U.index,U.length);var oe=Object.keys(X.format).reduce(function(re,ge){return C.default.query(ge,C.default.Scope.BLOCK)&&!Array.isArray(X.format[ge])&&(re[ge]=X.format[ge]),re},{});this.quill.insertText(U.index,`
`,oe,R.default.sources.USER),this.quill.setSelection(U.index+1,R.default.sources.SILENT),this.quill.focus(),Object.keys(X.format).forEach(function(re){oe[re]==null&&(Array.isArray(X.format[re])||re!=="link"&&ne.quill.format(re,X.format[re],R.default.sources.USER))})}function V(U){return{key:W.keys.TAB,shiftKey:!U,format:{"code-block":!0},handler:function(ne){var oe=C.default.query("code-block"),re=ne.index,ge=ne.length,ve=this.quill.scroll.descendant(oe,re),Se=c(ve,2),We=Se[0],Ce=Se[1];if(We!=null){var fe=this.quill.getIndex(We),Ye=We.newlineIndex(Ce,!0)+1,be=We.newlineIndex(fe+Ce+ge),_e=We.domNode.textContent.slice(Ye,be).split(`
`);Ce=0,_e.forEach(function(ke,qe){U?(We.insertAt(Ye+Ce,oe.TAB),Ce+=oe.TAB.length,qe===0?re+=oe.TAB.length:ge+=oe.TAB.length):ke.startsWith(oe.TAB)&&(We.deleteAt(Ye+Ce,oe.TAB.length),Ce-=oe.TAB.length,qe===0?re-=oe.TAB.length:ge-=oe.TAB.length),Ce+=ke.length+1}),this.quill.update(R.default.sources.USER),this.quill.setSelection(re,ge,R.default.sources.SILENT)}}}}function K(U){return{key:U[0].toUpperCase(),shortKey:!0,handler:function(ne,oe){this.quill.format(U,!oe.format[U],R.default.sources.USER)}}}function Y(U){if(typeof U=="string"||typeof U=="number")return Y({key:U});if((typeof U>"u"?"undefined":l(U))==="object"&&(U=(0,x.default)(U,!1)),typeof U.key=="string")if(W.keys[U.key.toUpperCase()]!=null)U.key=W.keys[U.key.toUpperCase()];else if(U.key.length===1)U.key=U.key.toUpperCase().charCodeAt(0);else return null;return U.shortKey&&(U[Z]=U.shortKey,delete U.shortKey),U}r.default=W,r.SHORTKEY=Z}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function N(S,C){var w=[],R=!0,P=!1,A=void 0;try{for(var I=S[Symbol.iterator](),$;!(R=($=I.next()).done)&&(w.push($.value),!(C&&w.length===C));R=!0);}catch(T){P=!0,A=T}finally{try{!R&&I.return&&I.return()}finally{if(P)throw A}}return w}return function(S,C){if(Array.isArray(S))return S;if(Symbol.iterator in Object(S))return N(S,C);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),c=function N(S,C,w){S===null&&(S=Function.prototype);var R=Object.getOwnPropertyDescriptor(S,C);if(R===void 0){var P=Object.getPrototypeOf(S);return P===null?void 0:N(P,C,w)}else{if("value"in R)return R.value;var A=R.get;return A===void 0?void 0:A.call(w)}},d=(function(){function N(S,C){for(var w=0;w<C.length;w++){var R=C[w];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(S,R.key,R)}}return function(S,C,w){return C&&N(S.prototype,C),w&&N(S,w),S}})(),h=a(0),x=p(h),f=a(7),m=p(f);function p(N){return N&&N.__esModule?N:{default:N}}function u(N,S){if(!(N instanceof S))throw new TypeError("Cannot call a class as a function")}function j(N,S){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return S&&(typeof S=="object"||typeof S=="function")?S:N}function g(N,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof S);N.prototype=Object.create(S&&S.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),S&&(Object.setPrototypeOf?Object.setPrototypeOf(N,S):N.__proto__=S)}var y=(function(N){g(S,N),d(S,null,[{key:"value",value:function(){}}]);function S(C,w){u(this,S);var R=j(this,(S.__proto__||Object.getPrototypeOf(S)).call(this,C));return R.selection=w,R.textNode=document.createTextNode(S.CONTENTS),R.domNode.appendChild(R.textNode),R._length=0,R}return d(S,[{key:"detach",value:function(){this.parent!=null&&this.parent.removeChild(this)}},{key:"format",value:function(w,R){if(this._length!==0)return c(S.prototype.__proto__||Object.getPrototypeOf(S.prototype),"format",this).call(this,w,R);for(var P=this,A=0;P!=null&&P.statics.scope!==x.default.Scope.BLOCK_BLOT;)A+=P.offset(P.parent),P=P.parent;P!=null&&(this._length=S.CONTENTS.length,P.optimize(),P.formatAt(A,S.CONTENTS.length,w,R),this._length=0)}},{key:"index",value:function(w,R){return w===this.textNode?0:c(S.prototype.__proto__||Object.getPrototypeOf(S.prototype),"index",this).call(this,w,R)}},{key:"length",value:function(){return this._length}},{key:"position",value:function(){return[this.textNode,this.textNode.data.length]}},{key:"remove",value:function(){c(S.prototype.__proto__||Object.getPrototypeOf(S.prototype),"remove",this).call(this),this.parent=null}},{key:"restore",value:function(){if(!(this.selection.composing||this.parent==null)){var w=this.textNode,R=this.selection.getNativeRange(),P=void 0,A=void 0,I=void 0;if(R!=null&&R.start.node===w&&R.end.node===w){var $=[w,R.start.offset,R.end.offset];P=$[0],A=$[1],I=$[2]}for(;this.domNode.lastChild!=null&&this.domNode.lastChild!==this.textNode;)this.domNode.parentNode.insertBefore(this.domNode.lastChild,this.domNode);if(this.textNode.data!==S.CONTENTS){var T=this.textNode.data.split(S.CONTENTS).join("");this.next instanceof m.default?(P=this.next.domNode,this.next.insertAt(0,T),this.textNode.data=S.CONTENTS):(this.textNode.data=T,this.parent.insertBefore(x.default.create(this.textNode),this),this.textNode=document.createTextNode(S.CONTENTS),this.domNode.appendChild(this.textNode))}if(this.remove(),A!=null){var E=[A,I].map(function(M){return Math.max(0,Math.min(P.data.length,M-1))}),_=l(E,2);return A=_[0],I=_[1],{startNode:P,startOffset:A,endNode:P,endOffset:I}}}}},{key:"update",value:function(w,R){var P=this;if(w.some(function(I){return I.type==="characterData"&&I.target===P.textNode})){var A=this.restore();A&&(R.range=A)}}},{key:"value",value:function(){return""}}]),S})(x.default.Embed);y.blotName="cursor",y.className="ql-cursor",y.tagName="span",y.CONTENTS="\uFEFF",r.default=y}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(0),c=x(l),d=a(4),h=x(d);function x(j){return j&&j.__esModule?j:{default:j}}function f(j,g){if(!(j instanceof g))throw new TypeError("Cannot call a class as a function")}function m(j,g){if(!j)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:j}function p(j,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);j.prototype=Object.create(g&&g.prototype,{constructor:{value:j,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(j,g):j.__proto__=g)}var u=(function(j){p(g,j);function g(){return f(this,g),m(this,(g.__proto__||Object.getPrototypeOf(g)).apply(this,arguments))}return g})(c.default.Container);u.allowedChildren=[h.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 l=(function(){function y(N,S){for(var C=0;C<S.length;C++){var w=S[C];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(N,w.key,w)}}return function(N,S,C){return S&&y(N.prototype,S),C&&y(N,C),N}})(),c=function y(N,S,C){N===null&&(N=Function.prototype);var w=Object.getOwnPropertyDescriptor(N,S);if(w===void 0){var R=Object.getPrototypeOf(N);return R===null?void 0:y(R,S,C)}else{if("value"in w)return w.value;var P=w.get;return P===void 0?void 0:P.call(C)}},d=a(0),h=x(d);function x(y){return y&&y.__esModule?y:{default:y}}function f(y,N){if(!(y instanceof N))throw new TypeError("Cannot call a class as a function")}function m(y,N){if(!y)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return N&&(typeof N=="object"||typeof N=="function")?N:y}function p(y,N){if(typeof N!="function"&&N!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof N);y.prototype=Object.create(N&&N.prototype,{constructor:{value:y,enumerable:!1,writable:!0,configurable:!0}}),N&&(Object.setPrototypeOf?Object.setPrototypeOf(y,N):y.__proto__=N)}var u=(function(y){p(N,y);function N(){return f(this,N),m(this,(N.__proto__||Object.getPrototypeOf(N)).apply(this,arguments))}return l(N,[{key:"value",value:function(C){var w=c(N.prototype.__proto__||Object.getPrototypeOf(N.prototype),"value",this).call(this,C);return w.startsWith("rgb(")?(w=w.replace(/^[^\d]+/,"").replace(/[^\d]+$/,""),"#"+w.split(",").map(function(R){return("00"+parseInt(R).toString(16)).slice(-2)}).join("")):w}}]),N})(h.default.Attributor.Style),j=new h.default.Attributor.Class("color","ql-color",{scope:h.default.Scope.INLINE}),g=new u("color","color",{scope:h.default.Scope.INLINE});r.ColorAttributor=u,r.ColorClass=j,r.ColorStyle=g}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.sanitize=r.default=void 0;var l=(function(){function g(y,N){for(var S=0;S<N.length;S++){var C=N[S];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(y,C.key,C)}}return function(y,N,S){return N&&g(y.prototype,N),S&&g(y,S),y}})(),c=function g(y,N,S){y===null&&(y=Function.prototype);var C=Object.getOwnPropertyDescriptor(y,N);if(C===void 0){var w=Object.getPrototypeOf(y);return w===null?void 0:g(w,N,S)}else{if("value"in C)return C.value;var R=C.get;return R===void 0?void 0:R.call(S)}},d=a(6),h=x(d);function x(g){return g&&g.__esModule?g:{default:g}}function f(g,y){if(!(g instanceof y))throw new TypeError("Cannot call a class as a function")}function m(g,y){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return y&&(typeof y=="object"||typeof y=="function")?y:g}function p(g,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof y);g.prototype=Object.create(y&&y.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),y&&(Object.setPrototypeOf?Object.setPrototypeOf(g,y):g.__proto__=y)}var u=(function(g){p(y,g);function y(){return f(this,y),m(this,(y.__proto__||Object.getPrototypeOf(y)).apply(this,arguments))}return l(y,[{key:"format",value:function(S,C){if(S!==this.statics.blotName||!C)return c(y.prototype.__proto__||Object.getPrototypeOf(y.prototype),"format",this).call(this,S,C);C=this.constructor.sanitize(C),this.domNode.setAttribute("href",C)}}],[{key:"create",value:function(S){var C=c(y.__proto__||Object.getPrototypeOf(y),"create",this).call(this,S);return S=this.sanitize(S),C.setAttribute("href",S),C.setAttribute("rel","noopener noreferrer"),C.setAttribute("target","_blank"),C}},{key:"formats",value:function(S){return S.getAttribute("href")}},{key:"sanitize",value:function(S){return j(S,this.PROTOCOL_WHITELIST)?S:this.SANITIZED_URL}}]),y})(h.default);u.blotName="link",u.tagName="A",u.SANITIZED_URL="about:blank",u.PROTOCOL_WHITELIST=["http","https","mailto","tel"];function j(g,y){var N=document.createElement("a");N.href=g;var S=N.href.slice(0,N.href.indexOf(":"));return y.indexOf(S)>-1}r.default=u,r.sanitize=j}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(y){return typeof y}:function(y){return y&&typeof Symbol=="function"&&y.constructor===Symbol&&y!==Symbol.prototype?"symbol":typeof y},c=(function(){function y(N,S){for(var C=0;C<S.length;C++){var w=S[C];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(N,w.key,w)}}return function(N,S,C){return S&&y(N.prototype,S),C&&y(N,C),N}})(),d=a(23),h=m(d),x=a(107),f=m(x);function m(y){return y&&y.__esModule?y:{default:y}}function p(y,N){if(!(y instanceof N))throw new TypeError("Cannot call a class as a function")}var u=0;function j(y,N){y.setAttribute(N,y.getAttribute(N)!=="true")}var g=(function(){function y(N){var S=this;p(this,y),this.select=N,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(){S.togglePicker()}),this.label.addEventListener("keydown",function(C){switch(C.keyCode){case h.default.keys.ENTER:S.togglePicker();break;case h.default.keys.ESCAPE:S.escape(),C.preventDefault();break}}),this.select.addEventListener("change",this.update.bind(this))}return c(y,[{key:"togglePicker",value:function(){this.container.classList.toggle("ql-expanded"),j(this.label,"aria-expanded"),j(this.options,"aria-hidden")}},{key:"buildItem",value:function(S){var C=this,w=document.createElement("span");return w.tabIndex="0",w.setAttribute("role","button"),w.classList.add("ql-picker-item"),S.hasAttribute("value")&&w.setAttribute("data-value",S.getAttribute("value")),S.textContent&&w.setAttribute("data-label",S.textContent),w.addEventListener("click",function(){C.selectItem(w,!0)}),w.addEventListener("keydown",function(R){switch(R.keyCode){case h.default.keys.ENTER:C.selectItem(w,!0),R.preventDefault();break;case h.default.keys.ESCAPE:C.escape(),R.preventDefault();break}}),w}},{key:"buildLabel",value:function(){var S=document.createElement("span");return S.classList.add("ql-picker-label"),S.innerHTML=f.default,S.tabIndex="0",S.setAttribute("role","button"),S.setAttribute("aria-expanded","false"),this.container.appendChild(S),S}},{key:"buildOptions",value:function(){var S=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(w){var R=S.buildItem(w);C.appendChild(R),w.selected===!0&&S.selectItem(R)}),this.container.appendChild(C)}},{key:"buildPicker",value:function(){var S=this;[].slice.call(this.select.attributes).forEach(function(C){S.container.setAttribute(C.name,C.value)}),this.container.classList.add("ql-picker"),this.label=this.buildLabel(),this.buildOptions()}},{key:"escape",value:function(){var S=this;this.close(),setTimeout(function(){return S.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(S){var C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,w=this.container.querySelector(".ql-selected");if(S!==w&&(w!=null&&w.classList.remove("ql-selected"),S!=null&&(S.classList.add("ql-selected"),this.select.selectedIndex=[].indexOf.call(S.parentNode.children,S),S.hasAttribute("data-value")?this.label.setAttribute("data-value",S.getAttribute("data-value")):this.label.removeAttribute("data-value"),S.hasAttribute("data-label")?this.label.setAttribute("data-label",S.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":l(Event))==="object"){var R=document.createEvent("Event");R.initEvent("change",!0,!0),this.select.dispatchEvent(R)}this.close()}}},{key:"update",value:function(){var S=void 0;if(this.select.selectedIndex>-1){var C=this.container.querySelector(".ql-picker-options").children[this.select.selectedIndex];S=this.select.options[this.select.selectedIndex],this.selectItem(C)}else this.selectItem(null);var w=S!=null&&S!==this.select.querySelector("option[selected]");this.label.classList.toggle("ql-active",w)}}]),y})();r.default=g}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(0),c=G(l),d=a(5),h=G(d),x=a(4),f=G(x),m=a(16),p=G(m),u=a(25),j=G(u),g=a(24),y=G(g),N=a(35),S=G(N),C=a(6),w=G(C),R=a(22),P=G(R),A=a(7),I=G(A),$=a(55),T=G($),E=a(42),_=G(E),M=a(23),q=G(M);function G(Z){return Z&&Z.__esModule?Z:{default:Z}}h.default.register({"blots/block":f.default,"blots/block/embed":x.BlockEmbed,"blots/break":p.default,"blots/container":j.default,"blots/cursor":y.default,"blots/embed":S.default,"blots/inline":w.default,"blots/scroll":P.default,"blots/text":I.default,"modules/clipboard":T.default,"modules/history":_.default,"modules/keyboard":q.default}),c.default.register(f.default,p.default,y.default,w.default,P.default,I.default),r.default=h.default}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(1),c=(function(){function d(h){this.domNode=h,this.domNode[l.DATA_KEY]={blot:this}}return Object.defineProperty(d.prototype,"statics",{get:function(){return this.constructor},enumerable:!0,configurable:!0}),d.create=function(h){if(this.tagName==null)throw new l.ParchmentError("Blot definition missing tagName");var x;return Array.isArray(this.tagName)?(typeof h=="string"&&(h=h.toUpperCase(),parseInt(h).toString()===h&&(h=parseInt(h))),typeof h=="number"?x=document.createElement(this.tagName[h-1]):this.tagName.indexOf(h)>-1?x=document.createElement(h):x=document.createElement(this.tagName[0])):x=document.createElement(this.tagName),this.className&&x.classList.add(this.className),x},d.prototype.attach=function(){this.parent!=null&&(this.scroll=this.parent.scroll)},d.prototype.clone=function(){var h=this.domNode.cloneNode(!1);return l.create(h)},d.prototype.detach=function(){this.parent!=null&&this.parent.removeChild(this),delete this.domNode[l.DATA_KEY]},d.prototype.deleteAt=function(h,x){var f=this.isolate(h,x);f.remove()},d.prototype.formatAt=function(h,x,f,m){var p=this.isolate(h,x);if(l.query(f,l.Scope.BLOT)!=null&&m)p.wrap(f,m);else if(l.query(f,l.Scope.ATTRIBUTE)!=null){var u=l.create(this.statics.scope);p.wrap(u),u.format(f,m)}},d.prototype.insertAt=function(h,x,f){var m=f==null?l.create("text",x):l.create(x,f),p=this.split(h);this.parent.insertBefore(m,p)},d.prototype.insertInto=function(h,x){x===void 0&&(x=null),this.parent!=null&&this.parent.children.remove(this);var f=null;h.children.insertBefore(this,x),x!=null&&(f=x.domNode),(this.domNode.parentNode!=h.domNode||this.domNode.nextSibling!=f)&&h.domNode.insertBefore(this.domNode,f),this.parent=h,this.attach()},d.prototype.isolate=function(h,x){var f=this.split(h);return f.split(x),f},d.prototype.length=function(){return 1},d.prototype.offset=function(h){return h===void 0&&(h=this.parent),this.parent==null||this==h?0:this.parent.children.offset(this)+this.parent.offset(h)},d.prototype.optimize=function(h){this.domNode[l.DATA_KEY]!=null&&delete this.domNode[l.DATA_KEY].mutations},d.prototype.remove=function(){this.domNode.parentNode!=null&&this.domNode.parentNode.removeChild(this.domNode),this.detach()},d.prototype.replace=function(h){h.parent!=null&&(h.parent.insertBefore(this,h.next),h.remove())},d.prototype.replaceWith=function(h,x){var f=typeof h=="string"?l.create(h,x):h;return f.replace(this),f},d.prototype.split=function(h,x){return h===0?this:this.next},d.prototype.update=function(h,x){},d.prototype.wrap=function(h,x){var f=typeof h=="string"?l.create(h,x):h;return this.parent!=null&&this.parent.insertBefore(f,this.next),f.appendChild(this),f},d.blotName="abstract",d})();r.default=c}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(12),c=a(32),d=a(33),h=a(1),x=(function(){function f(m){this.attributes={},this.domNode=m,this.build()}return f.prototype.attribute=function(m,p){p?m.add(this.domNode,p)&&(m.value(this.domNode)!=null?this.attributes[m.attrName]=m:delete this.attributes[m.attrName]):(m.remove(this.domNode),delete this.attributes[m.attrName])},f.prototype.build=function(){var m=this;this.attributes={};var p=l.default.keys(this.domNode),u=c.default.keys(this.domNode),j=d.default.keys(this.domNode);p.concat(u).concat(j).forEach(function(g){var y=h.query(g,h.Scope.ATTRIBUTE);y instanceof l.default&&(m.attributes[y.attrName]=y)})},f.prototype.copy=function(m){var p=this;Object.keys(this.attributes).forEach(function(u){var j=p.attributes[u].value(p.domNode);m.format(u,j)})},f.prototype.move=function(m){var p=this;this.copy(m),Object.keys(this.attributes).forEach(function(u){p.attributes[u].remove(p.domNode)}),this.attributes={}},f.prototype.values=function(){var m=this;return Object.keys(this.attributes).reduce(function(p,u){return p[u]=m.attributes[u].value(m.domNode),p},{})},f})();r.default=x}),(function(n,r,a){var l=this&&this.__extends||(function(){var x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,m){f.__proto__=m}||function(f,m){for(var p in m)m.hasOwnProperty(p)&&(f[p]=m[p])};return function(f,m){x(f,m);function p(){this.constructor=f}f.prototype=m===null?Object.create(m):(p.prototype=m.prototype,new p)}})();Object.defineProperty(r,"__esModule",{value:!0});var c=a(12);function d(x,f){var m=x.getAttribute("class")||"";return m.split(/\s+/).filter(function(p){return p.indexOf(f+"-")===0})}var h=(function(x){l(f,x);function f(){return x!==null&&x.apply(this,arguments)||this}return f.keys=function(m){return(m.getAttribute("class")||"").split(/\s+/).map(function(p){return p.split("-").slice(0,-1).join("-")})},f.prototype.add=function(m,p){return this.canAdd(m,p)?(this.remove(m),m.classList.add(this.keyName+"-"+p),!0):!1},f.prototype.remove=function(m){var p=d(m,this.keyName);p.forEach(function(u){m.classList.remove(u)}),m.classList.length===0&&m.removeAttribute("class")},f.prototype.value=function(m){var p=d(m,this.keyName)[0]||"",u=p.slice(this.keyName.length+1);return this.canAdd(m,u)?u:""},f})(c.default);r.default=h}),(function(n,r,a){var l=this&&this.__extends||(function(){var x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,m){f.__proto__=m}||function(f,m){for(var p in m)m.hasOwnProperty(p)&&(f[p]=m[p])};return function(f,m){x(f,m);function p(){this.constructor=f}f.prototype=m===null?Object.create(m):(p.prototype=m.prototype,new p)}})();Object.defineProperty(r,"__esModule",{value:!0});var c=a(12);function d(x){var f=x.split("-"),m=f.slice(1).map(function(p){return p[0].toUpperCase()+p.slice(1)}).join("");return f[0]+m}var h=(function(x){l(f,x);function f(){return x!==null&&x.apply(this,arguments)||this}return f.keys=function(m){return(m.getAttribute("style")||"").split(";").map(function(p){var u=p.split(":");return u[0].trim()})},f.prototype.add=function(m,p){return this.canAdd(m,p)?(m.style[d(this.keyName)]=p,!0):!1},f.prototype.remove=function(m){m.style[d(this.keyName)]="",m.getAttribute("style")||m.removeAttribute("style")},f.prototype.value=function(m){var p=m.style[d(this.keyName)];return this.canAdd(m,p)?p:""},f})(c.default);r.default=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function h(x,f){for(var m=0;m<f.length;m++){var p=f[m];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(x,p.key,p)}}return function(x,f,m){return f&&h(x.prototype,f),m&&h(x,m),x}})();function c(h,x){if(!(h instanceof x))throw new TypeError("Cannot call a class as a function")}var d=(function(){function h(x,f){c(this,h),this.quill=x,this.options=f,this.modules={}}return l(h,[{key:"init",value:function(){var f=this;Object.keys(this.options.modules).forEach(function(m){f.modules[m]==null&&f.addModule(m)})}},{key:"addModule",value:function(f){var m=this.quill.constructor.import("modules/"+f);return this.modules[f]=new m(this.quill,this.options.modules[f]||{}),this.modules[f]}}]),h})();d.DEFAULTS={modules:{}},d.themes={default:d},r.default=d}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function N(S,C){for(var w=0;w<C.length;w++){var R=C[w];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(S,R.key,R)}}return function(S,C,w){return C&&N(S.prototype,C),w&&N(S,w),S}})(),c=function N(S,C,w){S===null&&(S=Function.prototype);var R=Object.getOwnPropertyDescriptor(S,C);if(R===void 0){var P=Object.getPrototypeOf(S);return P===null?void 0:N(P,C,w)}else{if("value"in R)return R.value;var A=R.get;return A===void 0?void 0:A.call(w)}},d=a(0),h=m(d),x=a(7),f=m(x);function m(N){return N&&N.__esModule?N:{default:N}}function p(N,S){if(!(N instanceof S))throw new TypeError("Cannot call a class as a function")}function u(N,S){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return S&&(typeof S=="object"||typeof S=="function")?S:N}function j(N,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof S);N.prototype=Object.create(S&&S.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),S&&(Object.setPrototypeOf?Object.setPrototypeOf(N,S):N.__proto__=S)}var g="\uFEFF",y=(function(N){j(S,N);function S(C){p(this,S);var w=u(this,(S.__proto__||Object.getPrototypeOf(S)).call(this,C));return w.contentNode=document.createElement("span"),w.contentNode.setAttribute("contenteditable",!1),[].slice.call(w.domNode.childNodes).forEach(function(R){w.contentNode.appendChild(R)}),w.leftGuard=document.createTextNode(g),w.rightGuard=document.createTextNode(g),w.domNode.appendChild(w.leftGuard),w.domNode.appendChild(w.contentNode),w.domNode.appendChild(w.rightGuard),w}return l(S,[{key:"index",value:function(w,R){return w===this.leftGuard?0:w===this.rightGuard?1:c(S.prototype.__proto__||Object.getPrototypeOf(S.prototype),"index",this).call(this,w,R)}},{key:"restore",value:function(w){var R=void 0,P=void 0,A=w.data.split(g).join("");if(w===this.leftGuard)if(this.prev instanceof f.default){var I=this.prev.length();this.prev.insertAt(I,A),R={startNode:this.prev.domNode,startOffset:I+A.length}}else P=document.createTextNode(A),this.parent.insertBefore(h.default.create(P),this),R={startNode:P,startOffset:A.length};else w===this.rightGuard&&(this.next instanceof f.default?(this.next.insertAt(0,A),R={startNode:this.next.domNode,startOffset:A.length}):(P=document.createTextNode(A),this.parent.insertBefore(h.default.create(P),this.next),R={startNode:P,startOffset:A.length}));return w.data=g,R}},{key:"update",value:function(w,R){var P=this;w.forEach(function(A){if(A.type==="characterData"&&(A.target===P.leftGuard||A.target===P.rightGuard)){var I=P.restore(A.target);I&&(R.range=I)}})}}]),S})(h.default.Embed);r.default=y}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.AlignStyle=r.AlignClass=r.AlignAttribute=void 0;var l=a(0),c=d(l);function d(p){return p&&p.__esModule?p:{default:p}}var h={scope:c.default.Scope.BLOCK,whitelist:["right","center","justify"]},x=new c.default.Attributor.Attribute("align","align",h),f=new c.default.Attributor.Class("align","ql-align",h),m=new c.default.Attributor.Style("align","text-align",h);r.AlignAttribute=x,r.AlignClass=f,r.AlignStyle=m}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.BackgroundStyle=r.BackgroundClass=void 0;var l=a(0),c=h(l),d=a(26);function h(m){return m&&m.__esModule?m:{default:m}}var x=new c.default.Attributor.Class("background","ql-bg",{scope:c.default.Scope.INLINE}),f=new d.ColorAttributor("background","background-color",{scope:c.default.Scope.INLINE});r.BackgroundClass=x,r.BackgroundStyle=f}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.DirectionStyle=r.DirectionClass=r.DirectionAttribute=void 0;var l=a(0),c=d(l);function d(p){return p&&p.__esModule?p:{default:p}}var h={scope:c.default.Scope.BLOCK,whitelist:["rtl"]},x=new c.default.Attributor.Attribute("direction","dir",h),f=new c.default.Attributor.Class("direction","ql-direction",h),m=new c.default.Attributor.Style("direction","direction",h);r.DirectionAttribute=x,r.DirectionClass=f,r.DirectionStyle=m}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.FontClass=r.FontStyle=void 0;var l=(function(){function N(S,C){for(var w=0;w<C.length;w++){var R=C[w];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(S,R.key,R)}}return function(S,C,w){return C&&N(S.prototype,C),w&&N(S,w),S}})(),c=function N(S,C,w){S===null&&(S=Function.prototype);var R=Object.getOwnPropertyDescriptor(S,C);if(R===void 0){var P=Object.getPrototypeOf(S);return P===null?void 0:N(P,C,w)}else{if("value"in R)return R.value;var A=R.get;return A===void 0?void 0:A.call(w)}},d=a(0),h=x(d);function x(N){return N&&N.__esModule?N:{default:N}}function f(N,S){if(!(N instanceof S))throw new TypeError("Cannot call a class as a function")}function m(N,S){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return S&&(typeof S=="object"||typeof S=="function")?S:N}function p(N,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof S);N.prototype=Object.create(S&&S.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),S&&(Object.setPrototypeOf?Object.setPrototypeOf(N,S):N.__proto__=S)}var u={scope:h.default.Scope.INLINE,whitelist:["serif","monospace"]},j=new h.default.Attributor.Class("font","ql-font",u),g=(function(N){p(S,N);function S(){return f(this,S),m(this,(S.__proto__||Object.getPrototypeOf(S)).apply(this,arguments))}return l(S,[{key:"value",value:function(w){return c(S.prototype.__proto__||Object.getPrototypeOf(S.prototype),"value",this).call(this,w).replace(/["']/g,"")}}]),S})(h.default.Attributor.Style),y=new g("font","font-family",u);r.FontStyle=y,r.FontClass=j}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.SizeStyle=r.SizeClass=void 0;var l=a(0),c=d(l);function d(f){return f&&f.__esModule?f:{default:f}}var h=new c.default.Attributor.Class("size","ql-size",{scope:c.default.Scope.INLINE,whitelist:["small","large","huge"]}),x=new c.default.Attributor.Style("size","font-size",{scope:c.default.Scope.INLINE,whitelist:["10px","18px","32px"]});r.SizeClass=h,r.SizeStyle=x}),(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 l=(function(){function C(w,R){for(var P=0;P<R.length;P++){var A=R[P];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(w,A.key,A)}}return function(w,R,P){return R&&C(w.prototype,R),P&&C(w,P),w}})(),c=a(0),d=p(c),h=a(5),x=p(h),f=a(9),m=p(f);function p(C){return C&&C.__esModule?C:{default:C}}function u(C,w){if(!(C instanceof w))throw new TypeError("Cannot call a class as a function")}function j(C,w){if(!C)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return w&&(typeof w=="object"||typeof w=="function")?w:C}function g(C,w){if(typeof w!="function"&&w!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof w);C.prototype=Object.create(w&&w.prototype,{constructor:{value:C,enumerable:!1,writable:!0,configurable:!0}}),w&&(Object.setPrototypeOf?Object.setPrototypeOf(C,w):C.__proto__=w)}var y=(function(C){g(w,C);function w(R,P){u(this,w);var A=j(this,(w.__proto__||Object.getPrototypeOf(w)).call(this,R,P));return A.lastRecorded=0,A.ignoreChange=!1,A.clear(),A.quill.on(x.default.events.EDITOR_CHANGE,function(I,$,T,E){I!==x.default.events.TEXT_CHANGE||A.ignoreChange||(!A.options.userOnly||E===x.default.sources.USER?A.record($,T):A.transform($))}),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 l(w,[{key:"change",value:function(P,A){if(this.stack[P].length!==0){var I=this.stack[P].pop();this.stack[A].push(I),this.lastRecorded=0,this.ignoreChange=!0,this.quill.updateContents(I[P],x.default.sources.USER),this.ignoreChange=!1;var $=S(I[P]);this.quill.setSelection($)}}},{key:"clear",value:function(){this.stack={undo:[],redo:[]}}},{key:"cutoff",value:function(){this.lastRecorded=0}},{key:"record",value:function(P,A){if(P.ops.length!==0){this.stack.redo=[];var I=this.quill.getContents().diff(A),$=Date.now();if(this.lastRecorded+this.options.delay>$&&this.stack.undo.length>0){var T=this.stack.undo.pop();I=I.compose(T.undo),P=T.redo.compose(P)}else this.lastRecorded=$;this.stack.undo.push({redo:P,undo:I}),this.stack.undo.length>this.options.maxStack&&this.stack.undo.shift()}}},{key:"redo",value:function(){this.change("redo","undo")}},{key:"transform",value:function(P){this.stack.undo.forEach(function(A){A.undo=P.transform(A.undo,!0),A.redo=P.transform(A.redo,!0)}),this.stack.redo.forEach(function(A){A.undo=P.transform(A.undo,!0),A.redo=P.transform(A.redo,!0)})}},{key:"undo",value:function(){this.change("undo","redo")}}]),w})(m.default);y.DEFAULTS={delay:1e3,maxStack:100,userOnly:!1};function N(C){var w=C.ops[C.ops.length-1];return w==null?!1:w.insert!=null?typeof w.insert=="string"&&w.insert.endsWith(`
`):w.attributes!=null?Object.keys(w.attributes).some(function(R){return d.default.query(R,d.default.Scope.BLOCK)!=null}):!1}function S(C){var w=C.reduce(function(P,A){return P+=A.delete||0,P},0),R=C.length()-w;return N(C)&&(R-=1),R}r.default=y,r.getLastChangeIndex=S}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.BaseTooltip=void 0;var l=(function(){function O(V,K){for(var Y=0;Y<K.length;Y++){var U=K[Y];U.enumerable=U.enumerable||!1,U.configurable=!0,"value"in U&&(U.writable=!0),Object.defineProperty(V,U.key,U)}}return function(V,K,Y){return K&&O(V.prototype,K),Y&&O(V,Y),V}})(),c=function O(V,K,Y){V===null&&(V=Function.prototype);var U=Object.getOwnPropertyDescriptor(V,K);if(U===void 0){var X=Object.getPrototypeOf(V);return X===null?void 0:O(X,K,Y)}else{if("value"in U)return U.value;var ne=U.get;return ne===void 0?void 0:ne.call(Y)}},d=a(3),h=$(d),x=a(2),f=$(x),m=a(8),p=$(m),u=a(23),j=$(u),g=a(34),y=$(g),N=a(59),S=$(N),C=a(60),w=$(C),R=a(28),P=$(R),A=a(61),I=$(A);function $(O){return O&&O.__esModule?O:{default:O}}function T(O,V){if(!(O instanceof V))throw new TypeError("Cannot call a class as a function")}function E(O,V){if(!O)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return V&&(typeof V=="object"||typeof V=="function")?V:O}function _(O,V){if(typeof V!="function"&&V!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof V);O.prototype=Object.create(V&&V.prototype,{constructor:{value:O,enumerable:!1,writable:!0,configurable:!0}}),V&&(Object.setPrototypeOf?Object.setPrototypeOf(O,V):O.__proto__=V)}var M=[!1,"center","right","justify"],q=["#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"],G=[!1,"serif","monospace"],Z=["1","2","3",!1],W=["small",!1,"large","huge"],z=(function(O){_(V,O);function V(K,Y){T(this,V);var U=E(this,(V.__proto__||Object.getPrototypeOf(V)).call(this,K,Y)),X=function ne(oe){if(!document.body.contains(K.root))return document.body.removeEventListener("click",ne);U.tooltip!=null&&!U.tooltip.root.contains(oe.target)&&document.activeElement!==U.tooltip.textbox&&!U.quill.hasFocus()&&U.tooltip.hide(),U.pickers!=null&&U.pickers.forEach(function(re){re.container.contains(oe.target)||re.close()})};return K.emitter.listenDOM("click",document.body,X),U}return l(V,[{key:"addModule",value:function(Y){var U=c(V.prototype.__proto__||Object.getPrototypeOf(V.prototype),"addModule",this).call(this,Y);return Y==="toolbar"&&this.extendToolbar(U),U}},{key:"buildButtons",value:function(Y,U){Y.forEach(function(X){var ne=X.getAttribute("class")||"";ne.split(/\s+/).forEach(function(oe){if(oe.startsWith("ql-")&&(oe=oe.slice(3),U[oe]!=null))if(oe==="direction")X.innerHTML=U[oe][""]+U[oe].rtl;else if(typeof U[oe]=="string")X.innerHTML=U[oe];else{var re=X.value||"";re!=null&&U[oe][re]&&(X.innerHTML=U[oe][re])}})})}},{key:"buildPickers",value:function(Y,U){var X=this;this.pickers=Y.map(function(oe){if(oe.classList.contains("ql-align"))return oe.querySelector("option")==null&&D(oe,M),new w.default(oe,U.align);if(oe.classList.contains("ql-background")||oe.classList.contains("ql-color")){var re=oe.classList.contains("ql-background")?"background":"color";return oe.querySelector("option")==null&&D(oe,q,re==="background"?"#ffffff":"#000000"),new S.default(oe,U[re])}else return oe.querySelector("option")==null&&(oe.classList.contains("ql-font")?D(oe,G):oe.classList.contains("ql-header")?D(oe,Z):oe.classList.contains("ql-size")&&D(oe,W)),new P.default(oe)});var ne=function(){X.pickers.forEach(function(re){re.update()})};this.quill.on(p.default.events.EDITOR_CHANGE,ne)}}]),V})(y.default);z.DEFAULTS=(0,h.default)(!0,{},y.default.DEFAULTS,{modules:{toolbar:{handlers:{formula:function(){this.quill.theme.tooltip.edit("formula")},image:function(){var V=this,K=this.container.querySelector("input.ql-image[type=file]");K==null&&(K=document.createElement("input"),K.setAttribute("type","file"),K.setAttribute("accept","image/png, image/gif, image/jpeg, image/bmp, image/x-icon"),K.classList.add("ql-image"),K.addEventListener("change",function(){if(K.files!=null&&K.files[0]!=null){var Y=new FileReader;Y.onload=function(U){var X=V.quill.getSelection(!0);V.quill.updateContents(new f.default().retain(X.index).delete(X.length).insert({image:U.target.result}),p.default.sources.USER),V.quill.setSelection(X.index+1,p.default.sources.SILENT),K.value=""},Y.readAsDataURL(K.files[0])}}),this.container.appendChild(K)),K.click()},video:function(){this.quill.theme.tooltip.edit("video")}}}}});var F=(function(O){_(V,O);function V(K,Y){T(this,V);var U=E(this,(V.__proto__||Object.getPrototypeOf(V)).call(this,K,Y));return U.textbox=U.root.querySelector('input[type="text"]'),U.listen(),U}return l(V,[{key:"listen",value:function(){var Y=this;this.textbox.addEventListener("keydown",function(U){j.default.match(U,"enter")?(Y.save(),U.preventDefault()):j.default.match(U,"escape")&&(Y.cancel(),U.preventDefault())})}},{key:"cancel",value:function(){this.hide()}},{key:"edit",value:function(){var Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"link",U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;this.root.classList.remove("ql-hidden"),this.root.classList.add("ql-editing"),U!=null?this.textbox.value=U:Y!==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-"+Y)||""),this.root.setAttribute("data-mode",Y)}},{key:"restoreFocus",value:function(){var Y=this.quill.scrollingContainer.scrollTop;this.quill.focus(),this.quill.scrollingContainer.scrollTop=Y}},{key:"save",value:function(){var Y=this.textbox.value;switch(this.root.getAttribute("data-mode")){case"link":{var U=this.quill.root.scrollTop;this.linkRange?(this.quill.formatText(this.linkRange,"link",Y,p.default.sources.USER),delete this.linkRange):(this.restoreFocus(),this.quill.format("link",Y,p.default.sources.USER)),this.quill.root.scrollTop=U;break}case"video":Y=B(Y);case"formula":{if(!Y)break;var X=this.quill.getSelection(!0);if(X!=null){var ne=X.index+X.length;this.quill.insertEmbed(ne,this.root.getAttribute("data-mode"),Y,p.default.sources.USER),this.root.getAttribute("data-mode")==="formula"&&this.quill.insertText(ne+1," ",p.default.sources.USER),this.quill.setSelection(ne+2,p.default.sources.USER)}break}}this.textbox.value="",this.hide()}}]),V})(I.default);function B(O){var V=O.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/)||O.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);return V?(V[1]||"https")+"://www.youtube.com/embed/"+V[2]+"?showinfo=0":(V=O.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/))?(V[1]||"https")+"://player.vimeo.com/video/"+V[2]+"/":O}function D(O,V){var K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;V.forEach(function(Y){var U=document.createElement("option");Y===K?U.setAttribute("selected","selected"):U.setAttribute("value",Y),O.appendChild(U)})}r.BaseTooltip=F,r.default=z}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function c(){this.head=this.tail=null,this.length=0}return c.prototype.append=function(){for(var d=[],h=0;h<arguments.length;h++)d[h]=arguments[h];this.insertBefore(d[0],null),d.length>1&&this.append.apply(this,d.slice(1))},c.prototype.contains=function(d){for(var h,x=this.iterator();h=x();)if(h===d)return!0;return!1},c.prototype.insertBefore=function(d,h){d&&(d.next=h,h!=null?(d.prev=h.prev,h.prev!=null&&(h.prev.next=d),h.prev=d,h===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)},c.prototype.offset=function(d){for(var h=0,x=this.head;x!=null;){if(x===d)return h;h+=x.length(),x=x.next}return-1},c.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)},c.prototype.iterator=function(d){return d===void 0&&(d=this.head),function(){var h=d;return d!=null&&(d=d.next),h}},c.prototype.find=function(d,h){h===void 0&&(h=!1);for(var x,f=this.iterator();x=f();){var m=x.length();if(d<m||h&&d===m&&(x.next==null||x.next.length()!==0))return[x,d];d-=m}return[null,0]},c.prototype.forEach=function(d){for(var h,x=this.iterator();h=x();)d(h)},c.prototype.forEachAt=function(d,h,x){if(!(h<=0))for(var f=this.find(d),m=f[0],p=f[1],u,j=d-p,g=this.iterator(m);(u=g())&&j<d+h;){var y=u.length();d>j?x(u,d-j,Math.min(h,j+y-d)):x(u,0,Math.min(y,d+h-j)),j+=y}},c.prototype.map=function(d){return this.reduce(function(h,x){return h.push(d(x)),h},[])},c.prototype.reduce=function(d,h){for(var x,f=this.iterator();x=f();)h=d(h,x);return h},c})();r.default=l}),(function(n,r,a){var l=this&&this.__extends||(function(){var m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,u){p.__proto__=u}||function(p,u){for(var j in u)u.hasOwnProperty(j)&&(p[j]=u[j])};return function(p,u){m(p,u);function j(){this.constructor=p}p.prototype=u===null?Object.create(u):(j.prototype=u.prototype,new j)}})();Object.defineProperty(r,"__esModule",{value:!0});var c=a(17),d=a(1),h={attributes:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0},x=100,f=(function(m){l(p,m);function p(u){var j=m.call(this,u)||this;return j.scroll=j,j.observer=new MutationObserver(function(g){j.update(g)}),j.observer.observe(j.domNode,h),j.attach(),j}return p.prototype.detach=function(){m.prototype.detach.call(this),this.observer.disconnect()},p.prototype.deleteAt=function(u,j){this.update(),u===0&&j===this.length()?this.children.forEach(function(g){g.remove()}):m.prototype.deleteAt.call(this,u,j)},p.prototype.formatAt=function(u,j,g,y){this.update(),m.prototype.formatAt.call(this,u,j,g,y)},p.prototype.insertAt=function(u,j,g){this.update(),m.prototype.insertAt.call(this,u,j,g)},p.prototype.optimize=function(u,j){var g=this;u===void 0&&(u=[]),j===void 0&&(j={}),m.prototype.optimize.call(this,j);for(var y=[].slice.call(this.observer.takeRecords());y.length>0;)u.push(y.pop());for(var N=function(R,P){P===void 0&&(P=!0),!(R==null||R===g)&&R.domNode.parentNode!=null&&(R.domNode[d.DATA_KEY].mutations==null&&(R.domNode[d.DATA_KEY].mutations=[]),P&&N(R.parent))},S=function(R){R.domNode[d.DATA_KEY]==null||R.domNode[d.DATA_KEY].mutations==null||(R instanceof c.default&&R.children.forEach(S),R.optimize(j))},C=u,w=0;C.length>0;w+=1){if(w>=x)throw new Error("[Parchment] Maximum optimize iterations reached");for(C.forEach(function(R){var P=d.find(R.target,!0);P!=null&&(P.domNode===R.target&&(R.type==="childList"?(N(d.find(R.previousSibling,!1)),[].forEach.call(R.addedNodes,function(A){var I=d.find(A,!1);N(I,!1),I instanceof c.default&&I.children.forEach(function($){N($,!1)})})):R.type==="attributes"&&N(P.prev)),N(P))}),this.children.forEach(S),C=[].slice.call(this.observer.takeRecords()),y=C.slice();y.length>0;)u.push(y.pop())}},p.prototype.update=function(u,j){var g=this;j===void 0&&(j={}),u=u||this.observer.takeRecords(),u.map(function(y){var N=d.find(y.target,!0);return N==null?null:N.domNode[d.DATA_KEY].mutations==null?(N.domNode[d.DATA_KEY].mutations=[y],N):(N.domNode[d.DATA_KEY].mutations.push(y),null)}).forEach(function(y){y==null||y===g||y.domNode[d.DATA_KEY]==null||y.update(y.domNode[d.DATA_KEY].mutations||[],j)}),this.domNode[d.DATA_KEY].mutations!=null&&m.prototype.update.call(this,this.domNode[d.DATA_KEY].mutations,j),this.optimize(u,j)},p.blotName="scroll",p.defaultChild="block",p.scope=d.Scope.BLOCK_BLOT,p.tagName="DIV",p})(c.default);r.default=f}),(function(n,r,a){var l=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,p){m.__proto__=p}||function(m,p){for(var u in p)p.hasOwnProperty(u)&&(m[u]=p[u])};return function(m,p){f(m,p);function u(){this.constructor=m}m.prototype=p===null?Object.create(p):(u.prototype=p.prototype,new u)}})();Object.defineProperty(r,"__esModule",{value:!0});var c=a(18),d=a(1);function h(f,m){if(Object.keys(f).length!==Object.keys(m).length)return!1;for(var p in f)if(f[p]!==m[p])return!1;return!0}var x=(function(f){l(m,f);function m(){return f!==null&&f.apply(this,arguments)||this}return m.formats=function(p){if(p.tagName!==m.tagName)return f.formats.call(this,p)},m.prototype.format=function(p,u){var j=this;p===this.statics.blotName&&!u?(this.children.forEach(function(g){g instanceof c.default||(g=g.wrap(m.blotName,!0)),j.attributes.copy(g)}),this.unwrap()):f.prototype.format.call(this,p,u)},m.prototype.formatAt=function(p,u,j,g){if(this.formats()[j]!=null||d.query(j,d.Scope.ATTRIBUTE)){var y=this.isolate(p,u);y.format(j,g)}else f.prototype.formatAt.call(this,p,u,j,g)},m.prototype.optimize=function(p){f.prototype.optimize.call(this,p);var u=this.formats();if(Object.keys(u).length===0)return this.unwrap();var j=this.next;j instanceof m&&j.prev===this&&h(u,j.formats())&&(j.moveChildren(this),j.remove())},m.blotName="inline",m.scope=d.Scope.INLINE_BLOT,m.tagName="SPAN",m})(c.default);r.default=x}),(function(n,r,a){var l=this&&this.__extends||(function(){var x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,m){f.__proto__=m}||function(f,m){for(var p in m)m.hasOwnProperty(p)&&(f[p]=m[p])};return function(f,m){x(f,m);function p(){this.constructor=f}f.prototype=m===null?Object.create(m):(p.prototype=m.prototype,new p)}})();Object.defineProperty(r,"__esModule",{value:!0});var c=a(18),d=a(1),h=(function(x){l(f,x);function f(){return x!==null&&x.apply(this,arguments)||this}return f.formats=function(m){var p=d.query(f.blotName).tagName;if(m.tagName!==p)return x.formats.call(this,m)},f.prototype.format=function(m,p){d.query(m,d.Scope.BLOCK)!=null&&(m===this.statics.blotName&&!p?this.replaceWith(f.blotName):x.prototype.format.call(this,m,p))},f.prototype.formatAt=function(m,p,u,j){d.query(u,d.Scope.BLOCK)!=null?this.format(u,j):x.prototype.formatAt.call(this,m,p,u,j)},f.prototype.insertAt=function(m,p,u){if(u==null||d.query(p,d.Scope.INLINE)!=null)x.prototype.insertAt.call(this,m,p,u);else{var j=this.split(m),g=d.create(p,u);j.parent.insertBefore(g,j)}},f.prototype.update=function(m,p){navigator.userAgent.match(/Trident/)?this.build():x.prototype.update.call(this,m,p)},f.blotName="block",f.scope=d.Scope.BLOCK_BLOT,f.tagName="P",f})(c.default);r.default=h}),(function(n,r,a){var l=this&&this.__extends||(function(){var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,f){x.__proto__=f}||function(x,f){for(var m in f)f.hasOwnProperty(m)&&(x[m]=f[m])};return function(x,f){h(x,f);function m(){this.constructor=x}x.prototype=f===null?Object.create(f):(m.prototype=f.prototype,new m)}})();Object.defineProperty(r,"__esModule",{value:!0});var c=a(19),d=(function(h){l(x,h);function x(){return h!==null&&h.apply(this,arguments)||this}return x.formats=function(f){},x.prototype.format=function(f,m){h.prototype.formatAt.call(this,0,this.length(),f,m)},x.prototype.formatAt=function(f,m,p,u){f===0&&m===this.length()?this.format(p,u):h.prototype.formatAt.call(this,f,m,p,u)},x.prototype.formats=function(){return this.statics.formats(this.domNode)},x})(c.default);r.default=d}),(function(n,r,a){var l=this&&this.__extends||(function(){var x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,m){f.__proto__=m}||function(f,m){for(var p in m)m.hasOwnProperty(p)&&(f[p]=m[p])};return function(f,m){x(f,m);function p(){this.constructor=f}f.prototype=m===null?Object.create(m):(p.prototype=m.prototype,new p)}})();Object.defineProperty(r,"__esModule",{value:!0});var c=a(19),d=a(1),h=(function(x){l(f,x);function f(m){var p=x.call(this,m)||this;return p.text=p.statics.value(p.domNode),p}return f.create=function(m){return document.createTextNode(m)},f.value=function(m){var p=m.data;return p.normalize&&(p=p.normalize()),p},f.prototype.deleteAt=function(m,p){this.domNode.data=this.text=this.text.slice(0,m)+this.text.slice(m+p)},f.prototype.index=function(m,p){return this.domNode===m?p:-1},f.prototype.insertAt=function(m,p,u){u==null?(this.text=this.text.slice(0,m)+p+this.text.slice(m),this.domNode.data=this.text):x.prototype.insertAt.call(this,m,p,u)},f.prototype.length=function(){return this.text.length},f.prototype.optimize=function(m){x.prototype.optimize.call(this,m),this.text=this.statics.value(this.domNode),this.text.length===0?this.remove():this.next instanceof f&&this.next.prev===this&&(this.insertAt(this.length(),this.next.value()),this.next.remove())},f.prototype.position=function(m,p){return[this.domNode,m]},f.prototype.split=function(m,p){if(p===void 0&&(p=!1),!p){if(m===0)return this;if(m===this.length())return this.next}var u=d.create(this.domNode.splitText(m));return this.parent.insertBefore(u,this.next),this.text=this.statics.value(this.domNode),u},f.prototype.update=function(m,p){var u=this;m.some(function(j){return j.type==="characterData"&&j.target===u.domNode})&&(this.text=this.statics.value(this.domNode))},f.prototype.value=function(){return this.text},f.blotName="text",f.scope=d.Scope.INLINE_BLOT,f})(c.default);r.default=h}),(function(n,r,a){var l=document.createElement("div");if(l.classList.toggle("test-class",!1),l.classList.contains("test-class")){var c=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(d,h){return arguments.length>1&&!this.contains(d)==!h?h:c.call(this,d)}}String.prototype.startsWith||(String.prototype.startsWith=function(d,h){return h=h||0,this.substr(h,d.length)===d}),String.prototype.endsWith||(String.prototype.endsWith=function(d,h){var x=this.toString();(typeof h!="number"||!isFinite(h)||Math.floor(h)!==h||h>x.length)&&(h=x.length),h-=d.length;var f=x.indexOf(d,h);return f!==-1&&f===h}),Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(h){if(this===null)throw new TypeError("Array.prototype.find called on null or undefined");if(typeof h!="function")throw new TypeError("predicate must be a function");for(var x=Object(this),f=x.length>>>0,m=arguments[1],p,u=0;u<f;u++)if(p=x[u],h.call(m,p,u,x))return p}}),document.addEventListener("DOMContentLoaded",function(){document.execCommand("enableObjectResizing",!1,!1),document.execCommand("autoUrlDetect",!1,!1)})}),(function(n,r){var a=-1,l=1,c=0;function d(w,R,P){if(w==R)return w?[[c,w]]:[];(P<0||w.length<P)&&(P=null);var A=m(w,R),I=w.substring(0,A);w=w.substring(A),R=R.substring(A),A=p(w,R);var $=w.substring(w.length-A);w=w.substring(0,w.length-A),R=R.substring(0,R.length-A);var T=h(w,R);return I&&T.unshift([c,I]),$&&T.push([c,$]),j(T),P!=null&&(T=N(T,P)),T=S(T),T}function h(w,R){var P;if(!w)return[[l,R]];if(!R)return[[a,w]];var A=w.length>R.length?w:R,I=w.length>R.length?R:w,$=A.indexOf(I);if($!=-1)return P=[[l,A.substring(0,$)],[c,I],[l,A.substring($+I.length)]],w.length>R.length&&(P[0][0]=P[2][0]=a),P;if(I.length==1)return[[a,w],[l,R]];var T=u(w,R);if(T){var E=T[0],_=T[1],M=T[2],q=T[3],G=T[4],Z=d(E,M),W=d(_,q);return Z.concat([[c,G]],W)}return x(w,R)}function x(w,R){for(var P=w.length,A=R.length,I=Math.ceil((P+A)/2),$=I,T=2*I,E=new Array(T),_=new Array(T),M=0;M<T;M++)E[M]=-1,_[M]=-1;E[$+1]=0,_[$+1]=0;for(var q=P-A,G=q%2!=0,Z=0,W=0,z=0,F=0,B=0;B<I;B++){for(var D=-B+Z;D<=B-W;D+=2){var O=$+D,V;D==-B||D!=B&&E[O-1]<E[O+1]?V=E[O+1]:V=E[O-1]+1;for(var K=V-D;V<P&&K<A&&w.charAt(V)==R.charAt(K);)V++,K++;if(E[O]=V,V>P)W+=2;else if(K>A)Z+=2;else if(G){var Y=$+q-D;if(Y>=0&&Y<T&&_[Y]!=-1){var U=P-_[Y];if(V>=U)return f(w,R,V,K)}}}for(var X=-B+z;X<=B-F;X+=2){var Y=$+X,U;X==-B||X!=B&&_[Y-1]<_[Y+1]?U=_[Y+1]:U=_[Y-1]+1;for(var ne=U-X;U<P&&ne<A&&w.charAt(P-U-1)==R.charAt(A-ne-1);)U++,ne++;if(_[Y]=U,U>P)F+=2;else if(ne>A)z+=2;else if(!G){var O=$+q-X;if(O>=0&&O<T&&E[O]!=-1){var V=E[O],K=$+V-O;if(U=P-U,V>=U)return f(w,R,V,K)}}}}return[[a,w],[l,R]]}function f(w,R,P,A){var I=w.substring(0,P),$=R.substring(0,A),T=w.substring(P),E=R.substring(A),_=d(I,$),M=d(T,E);return _.concat(M)}function m(w,R){if(!w||!R||w.charAt(0)!=R.charAt(0))return 0;for(var P=0,A=Math.min(w.length,R.length),I=A,$=0;P<I;)w.substring($,I)==R.substring($,I)?(P=I,$=P):A=I,I=Math.floor((A-P)/2+P);return I}function p(w,R){if(!w||!R||w.charAt(w.length-1)!=R.charAt(R.length-1))return 0;for(var P=0,A=Math.min(w.length,R.length),I=A,$=0;P<I;)w.substring(w.length-I,w.length-$)==R.substring(R.length-I,R.length-$)?(P=I,$=P):A=I,I=Math.floor((A-P)/2+P);return I}function u(w,R){var P=w.length>R.length?w:R,A=w.length>R.length?R:w;if(P.length<4||A.length*2<P.length)return null;function I(W,z,F){for(var B=W.substring(F,F+Math.floor(W.length/4)),D=-1,O="",V,K,Y,U;(D=z.indexOf(B,D+1))!=-1;){var X=m(W.substring(F),z.substring(D)),ne=p(W.substring(0,F),z.substring(0,D));O.length<ne+X&&(O=z.substring(D-ne,D)+z.substring(D,D+X),V=W.substring(0,F-ne),K=W.substring(F+X),Y=z.substring(0,D-ne),U=z.substring(D+X))}return O.length*2>=W.length?[V,K,Y,U,O]:null}var $=I(P,A,Math.ceil(P.length/4)),T=I(P,A,Math.ceil(P.length/2)),E;if(!$&&!T)return null;T?$?E=$[4].length>T[4].length?$:T:E=T:E=$;var _,M,q,G;w.length>R.length?(_=E[0],M=E[1],q=E[2],G=E[3]):(q=E[0],G=E[1],_=E[2],M=E[3]);var Z=E[4];return[_,M,q,G,Z]}function j(w){w.push([c,""]);for(var R=0,P=0,A=0,I="",$="",T;R<w.length;)switch(w[R][0]){case l:A++,$+=w[R][1],R++;break;case a:P++,I+=w[R][1],R++;break;case c:P+A>1?(P!==0&&A!==0&&(T=m($,I),T!==0&&(R-P-A>0&&w[R-P-A-1][0]==c?w[R-P-A-1][1]+=$.substring(0,T):(w.splice(0,0,[c,$.substring(0,T)]),R++),$=$.substring(T),I=I.substring(T)),T=p($,I),T!==0&&(w[R][1]=$.substring($.length-T)+w[R][1],$=$.substring(0,$.length-T),I=I.substring(0,I.length-T))),P===0?w.splice(R-A,P+A,[l,$]):A===0?w.splice(R-P,P+A,[a,I]):w.splice(R-P-A,P+A,[a,I],[l,$]),R=R-P-A+(P?1:0)+(A?1:0)+1):R!==0&&w[R-1][0]==c?(w[R-1][1]+=w[R][1],w.splice(R,1)):R++,A=0,P=0,I="",$="";break}w[w.length-1][1]===""&&w.pop();var E=!1;for(R=1;R<w.length-1;)w[R-1][0]==c&&w[R+1][0]==c&&(w[R][1].substring(w[R][1].length-w[R-1][1].length)==w[R-1][1]?(w[R][1]=w[R-1][1]+w[R][1].substring(0,w[R][1].length-w[R-1][1].length),w[R+1][1]=w[R-1][1]+w[R+1][1],w.splice(R-1,1),E=!0):w[R][1].substring(0,w[R+1][1].length)==w[R+1][1]&&(w[R-1][1]+=w[R+1][1],w[R][1]=w[R][1].substring(w[R+1][1].length)+w[R+1][1],w.splice(R+1,1),E=!0)),R++;E&&j(w)}var g=d;g.INSERT=l,g.DELETE=a,g.EQUAL=c,n.exports=g;function y(w,R){if(R===0)return[c,w];for(var P=0,A=0;A<w.length;A++){var I=w[A];if(I[0]===a||I[0]===c){var $=P+I[1].length;if(R===$)return[A+1,w];if(R<$){w=w.slice();var T=R-P,E=[I[0],I[1].slice(0,T)],_=[I[0],I[1].slice(T)];return w.splice(A,1,E,_),[A+1,w]}else P=$}}throw new Error("cursor_pos is out of bounds!")}function N(w,R){var P=y(w,R),A=P[1],I=P[0],$=A[I],T=A[I+1];if($==null)return w;if($[0]!==c)return w;if(T!=null&&$[1]+T[1]===T[1]+$[1])return A.splice(I,2,T,$),C(A,I,2);if(T!=null&&T[1].indexOf($[1])===0){A.splice(I,2,[T[0],$[1]],[0,$[1]]);var E=T[1].slice($[1].length);return E.length>0&&A.splice(I+2,0,[T[0],E]),C(A,I,3)}else return w}function S(w){for(var R=!1,P=function(T){return T.charCodeAt(0)>=56320&&T.charCodeAt(0)<=57343},A=function(T){return T.charCodeAt(T.length-1)>=55296&&T.charCodeAt(T.length-1)<=56319},I=2;I<w.length;I+=1)w[I-2][0]===c&&A(w[I-2][1])&&w[I-1][0]===a&&P(w[I-1][1])&&w[I][0]===l&&P(w[I][1])&&(R=!0,w[I-1][1]=w[I-2][1].slice(-1)+w[I-1][1],w[I][1]=w[I-2][1].slice(-1)+w[I][1],w[I-2][1]=w[I-2][1].slice(0,-1));if(!R)return w;for(var $=[],I=0;I<w.length;I+=1)w[I][1].length>0&&$.push(w[I]);return $}function C(w,R,P){for(var A=R+P-1;A>=0&&A>=R-1;A--)if(A+1<w.length){var I=w[A],$=w[A+1];I[0]===$[1]&&w.splice(A,2,[I[0],I[1]+$[1]])}return w}}),(function(n,r){r=n.exports=typeof Object.keys=="function"?Object.keys:a,r.shim=a;function a(l){var c=[];for(var d in l)c.push(d);return c}}),(function(n,r){var a=(function(){return Object.prototype.toString.call(arguments)})()=="[object Arguments]";r=n.exports=a?l:c,r.supported=l;function l(d){return Object.prototype.toString.call(d)=="[object Arguments]"}r.unsupported=c;function c(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,l="~";function c(){}Object.create&&(c.prototype=Object.create(null),new c().__proto__||(l=!1));function d(x,f,m){this.fn=x,this.context=f,this.once=m||!1}function h(){this._events=new c,this._eventsCount=0}h.prototype.eventNames=function(){var f=[],m,p;if(this._eventsCount===0)return f;for(p in m=this._events)a.call(m,p)&&f.push(l?p.slice(1):p);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(m)):f},h.prototype.listeners=function(f,m){var p=l?l+f:f,u=this._events[p];if(m)return!!u;if(!u)return[];if(u.fn)return[u.fn];for(var j=0,g=u.length,y=new Array(g);j<g;j++)y[j]=u[j].fn;return y},h.prototype.emit=function(f,m,p,u,j,g){var y=l?l+f:f;if(!this._events[y])return!1;var N=this._events[y],S=arguments.length,C,w;if(N.fn){switch(N.once&&this.removeListener(f,N.fn,void 0,!0),S){case 1:return N.fn.call(N.context),!0;case 2:return N.fn.call(N.context,m),!0;case 3:return N.fn.call(N.context,m,p),!0;case 4:return N.fn.call(N.context,m,p,u),!0;case 5:return N.fn.call(N.context,m,p,u,j),!0;case 6:return N.fn.call(N.context,m,p,u,j,g),!0}for(w=1,C=new Array(S-1);w<S;w++)C[w-1]=arguments[w];N.fn.apply(N.context,C)}else{var R=N.length,P;for(w=0;w<R;w++)switch(N[w].once&&this.removeListener(f,N[w].fn,void 0,!0),S){case 1:N[w].fn.call(N[w].context);break;case 2:N[w].fn.call(N[w].context,m);break;case 3:N[w].fn.call(N[w].context,m,p);break;case 4:N[w].fn.call(N[w].context,m,p,u);break;default:if(!C)for(P=1,C=new Array(S-1);P<S;P++)C[P-1]=arguments[P];N[w].fn.apply(N[w].context,C)}}return!0},h.prototype.on=function(f,m,p){var u=new d(m,p||this),j=l?l+f:f;return this._events[j]?this._events[j].fn?this._events[j]=[this._events[j],u]:this._events[j].push(u):(this._events[j]=u,this._eventsCount++),this},h.prototype.once=function(f,m,p){var u=new d(m,p||this,!0),j=l?l+f:f;return this._events[j]?this._events[j].fn?this._events[j]=[this._events[j],u]:this._events[j].push(u):(this._events[j]=u,this._eventsCount++),this},h.prototype.removeListener=function(f,m,p,u){var j=l?l+f:f;if(!this._events[j])return this;if(!m)return--this._eventsCount===0?this._events=new c:delete this._events[j],this;var g=this._events[j];if(g.fn)g.fn===m&&(!u||g.once)&&(!p||g.context===p)&&(--this._eventsCount===0?this._events=new c:delete this._events[j]);else{for(var y=0,N=[],S=g.length;y<S;y++)(g[y].fn!==m||u&&!g[y].once||p&&g[y].context!==p)&&N.push(g[y]);N.length?this._events[j]=N.length===1?N[0]:N:--this._eventsCount===0?this._events=new c:delete this._events[j]}return this},h.prototype.removeAllListeners=function(f){var m;return f?(m=l?l+f:f,this._events[m]&&(--this._eventsCount===0?this._events=new c:delete this._events[m])):(this._events=new c,this._eventsCount=0),this},h.prototype.off=h.prototype.removeListener,h.prototype.addListener=h.prototype.on,h.prototype.setMaxListeners=function(){return this},h.prefixed=l,h.EventEmitter=h,typeof n<"u"&&(n.exports=h)}),(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 l=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(be){return typeof be}:function(be){return be&&typeof Symbol=="function"&&be.constructor===Symbol&&be!==Symbol.prototype?"symbol":typeof be},c=(function(){function be(_e,ke){var qe=[],Ve=!0,dt=!1,xt=void 0;try{for(var ye=_e[Symbol.iterator](),le;!(Ve=(le=ye.next()).done)&&(qe.push(le.value),!(ke&&qe.length===ke));Ve=!0);}catch(Qe){dt=!0,xt=Qe}finally{try{!Ve&&ye.return&&ye.return()}finally{if(dt)throw xt}}return qe}return function(_e,ke){if(Array.isArray(_e))return _e;if(Symbol.iterator in Object(_e))return be(_e,ke);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function be(_e,ke){for(var qe=0;qe<ke.length;qe++){var Ve=ke[qe];Ve.enumerable=Ve.enumerable||!1,Ve.configurable=!0,"value"in Ve&&(Ve.writable=!0),Object.defineProperty(_e,Ve.key,Ve)}}return function(_e,ke,qe){return ke&&be(_e.prototype,ke),qe&&be(_e,qe),_e}})(),h=a(3),x=_(h),f=a(2),m=_(f),p=a(0),u=_(p),j=a(5),g=_(j),y=a(10),N=_(y),S=a(9),C=_(S),w=a(36),R=a(37),P=a(13),A=_(P),I=a(26),$=a(38),T=a(39),E=a(40);function _(be){return be&&be.__esModule?be:{default:be}}function M(be,_e,ke){return _e in be?Object.defineProperty(be,_e,{value:ke,enumerable:!0,configurable:!0,writable:!0}):be[_e]=ke,be}function q(be,_e){if(!(be instanceof _e))throw new TypeError("Cannot call a class as a function")}function G(be,_e){if(!be)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return _e&&(typeof _e=="object"||typeof _e=="function")?_e:be}function Z(be,_e){if(typeof _e!="function"&&_e!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof _e);be.prototype=Object.create(_e&&_e.prototype,{constructor:{value:be,enumerable:!1,writable:!0,configurable:!0}}),_e&&(Object.setPrototypeOf?Object.setPrototypeOf(be,_e):be.__proto__=_e)}var W=(0,N.default)("quill:clipboard"),z="__ql-matcher",F=[[Node.TEXT_NODE,Ye],[Node.TEXT_NODE,We],["br",ge],[Node.ELEMENT_NODE,We],[Node.ELEMENT_NODE,re],[Node.ELEMENT_NODE,Ce],[Node.ELEMENT_NODE,oe],[Node.ELEMENT_NODE,fe],["li",Se],["b",ne.bind(ne,"bold")],["i",ne.bind(ne,"italic")],["style",ve]],B=[w.AlignAttribute,$.DirectionAttribute].reduce(function(be,_e){return be[_e.keyName]=_e,be},{}),D=[w.AlignStyle,R.BackgroundStyle,I.ColorStyle,$.DirectionStyle,T.FontStyle,E.SizeStyle].reduce(function(be,_e){return be[_e.keyName]=_e,be},{}),O=(function(be){Z(_e,be);function _e(ke,qe){q(this,_e);var Ve=G(this,(_e.__proto__||Object.getPrototypeOf(_e)).call(this,ke,qe));return Ve.quill.root.addEventListener("paste",Ve.onPaste.bind(Ve)),Ve.container=Ve.quill.addContainer("ql-clipboard"),Ve.container.setAttribute("contenteditable",!0),Ve.container.setAttribute("tabindex",-1),Ve.matchers=[],F.concat(Ve.options.matchers).forEach(function(dt){var xt=c(dt,2),ye=xt[0],le=xt[1];!qe.matchVisual&&le===Ce||Ve.addMatcher(ye,le)}),Ve}return d(_e,[{key:"addMatcher",value:function(qe,Ve){this.matchers.push([qe,Ve])}},{key:"convert",value:function(qe){if(typeof qe=="string")return this.container.innerHTML=qe.replace(/\>\r?\n +\</g,"><"),this.convert();var Ve=this.quill.getFormat(this.quill.selection.savedRange.index);if(Ve[A.default.blotName]){var dt=this.container.innerText;return this.container.innerHTML="",new m.default().insert(dt,M({},A.default.blotName,Ve[A.default.blotName]))}var xt=this.prepareMatching(),ye=c(xt,2),le=ye[0],Qe=ye[1],rt=X(this.container,le,Qe);return Y(rt,`
`)&&rt.ops[rt.ops.length-1].attributes==null&&(rt=rt.compose(new m.default().retain(rt.length()-1).delete(1))),W.log("convert",this.container.innerHTML,rt),this.container.innerHTML="",rt}},{key:"dangerouslyPasteHTML",value:function(qe,Ve){var dt=arguments.length>2&&arguments[2]!==void 0?arguments[2]:g.default.sources.API;if(typeof qe=="string")this.quill.setContents(this.convert(qe),Ve),this.quill.setSelection(0,g.default.sources.SILENT);else{var xt=this.convert(Ve);this.quill.updateContents(new m.default().retain(qe).concat(xt),dt),this.quill.setSelection(qe+xt.length(),g.default.sources.SILENT)}}},{key:"onPaste",value:function(qe){var Ve=this;if(!(qe.defaultPrevented||!this.quill.isEnabled())){var dt=this.quill.getSelection(),xt=new m.default().retain(dt.index),ye=this.quill.scrollingContainer.scrollTop;this.container.focus(),this.quill.selection.update(g.default.sources.SILENT),setTimeout(function(){xt=xt.concat(Ve.convert()).delete(dt.length),Ve.quill.updateContents(xt,g.default.sources.USER),Ve.quill.setSelection(xt.length()-dt.length,g.default.sources.SILENT),Ve.quill.scrollingContainer.scrollTop=ye,Ve.quill.focus()},1)}}},{key:"prepareMatching",value:function(){var qe=this,Ve=[],dt=[];return this.matchers.forEach(function(xt){var ye=c(xt,2),le=ye[0],Qe=ye[1];switch(le){case Node.TEXT_NODE:dt.push(Qe);break;case Node.ELEMENT_NODE:Ve.push(Qe);break;default:[].forEach.call(qe.container.querySelectorAll(le),function(rt){rt[z]=rt[z]||[],rt[z].push(Qe)});break}}),[Ve,dt]}}]),_e})(C.default);O.DEFAULTS={matchers:[],matchVisual:!0};function V(be,_e,ke){return(typeof _e>"u"?"undefined":l(_e))==="object"?Object.keys(_e).reduce(function(qe,Ve){return V(qe,Ve,_e[Ve])},be):be.reduce(function(qe,Ve){return Ve.attributes&&Ve.attributes[_e]?qe.push(Ve):qe.insert(Ve.insert,(0,x.default)({},M({},_e,ke),Ve.attributes))},new m.default)}function K(be){if(be.nodeType!==Node.ELEMENT_NODE)return{};var _e="__ql-computed-style";return be[_e]||(be[_e]=window.getComputedStyle(be))}function Y(be,_e){for(var ke="",qe=be.ops.length-1;qe>=0&&ke.length<_e.length;--qe){var Ve=be.ops[qe];if(typeof Ve.insert!="string")break;ke=Ve.insert+ke}return ke.slice(-1*_e.length)===_e}function U(be){if(be.childNodes.length===0)return!1;var _e=K(be);return["block","list-item"].indexOf(_e.display)>-1}function X(be,_e,ke){return be.nodeType===be.TEXT_NODE?ke.reduce(function(qe,Ve){return Ve(be,qe)},new m.default):be.nodeType===be.ELEMENT_NODE?[].reduce.call(be.childNodes||[],function(qe,Ve){var dt=X(Ve,_e,ke);return Ve.nodeType===be.ELEMENT_NODE&&(dt=_e.reduce(function(xt,ye){return ye(Ve,xt)},dt),dt=(Ve[z]||[]).reduce(function(xt,ye){return ye(Ve,xt)},dt)),qe.concat(dt)},new m.default):new m.default}function ne(be,_e,ke){return V(ke,be,!0)}function oe(be,_e){var ke=u.default.Attributor.Attribute.keys(be),qe=u.default.Attributor.Class.keys(be),Ve=u.default.Attributor.Style.keys(be),dt={};return ke.concat(qe).concat(Ve).forEach(function(xt){var ye=u.default.query(xt,u.default.Scope.ATTRIBUTE);ye!=null&&(dt[ye.attrName]=ye.value(be),dt[ye.attrName])||(ye=B[xt],ye!=null&&(ye.attrName===xt||ye.keyName===xt)&&(dt[ye.attrName]=ye.value(be)||void 0),ye=D[xt],ye!=null&&(ye.attrName===xt||ye.keyName===xt)&&(ye=D[xt],dt[ye.attrName]=ye.value(be)||void 0))}),Object.keys(dt).length>0&&(_e=V(_e,dt)),_e}function re(be,_e){var ke=u.default.query(be);if(ke==null)return _e;if(ke.prototype instanceof u.default.Embed){var qe={},Ve=ke.value(be);Ve!=null&&(qe[ke.blotName]=Ve,_e=new m.default().insert(qe,ke.formats(be)))}else typeof ke.formats=="function"&&(_e=V(_e,ke.blotName,ke.formats(be)));return _e}function ge(be,_e){return Y(_e,`
`)||_e.insert(`
`),_e}function ve(){return new m.default}function Se(be,_e){var ke=u.default.query(be);if(ke==null||ke.blotName!=="list-item"||!Y(_e,`
`))return _e;for(var qe=-1,Ve=be.parentNode;!Ve.classList.contains("ql-clipboard");)(u.default.query(Ve)||{}).blotName==="list"&&(qe+=1),Ve=Ve.parentNode;return qe<=0?_e:_e.compose(new m.default().retain(_e.length()-1).retain(1,{indent:qe}))}function We(be,_e){return Y(_e,`
`)||(U(be)||_e.length()>0&&be.nextSibling&&U(be.nextSibling))&&_e.insert(`
`),_e}function Ce(be,_e){if(U(be)&&be.nextElementSibling!=null&&!Y(_e,`
`)){var ke=be.offsetHeight+parseFloat(K(be).marginTop)+parseFloat(K(be).marginBottom);be.nextElementSibling.offsetTop>be.offsetTop+ke*1.5&&_e.insert(`
`)}return _e}function fe(be,_e){var ke={},qe=be.style||{};return qe.fontStyle&&K(be).fontStyle==="italic"&&(ke.italic=!0),qe.fontWeight&&(K(be).fontWeight.startsWith("bold")||parseInt(K(be).fontWeight)>=700)&&(ke.bold=!0),Object.keys(ke).length>0&&(_e=V(_e,ke)),parseFloat(qe.textIndent||0)>0&&(_e=new m.default().insert(" ").concat(_e)),_e}function Ye(be,_e){var ke=be.data;if(be.parentNode.tagName==="O:P")return _e.insert(ke.trim());if(ke.trim().length===0&&be.parentNode.classList.contains("ql-clipboard"))return _e;if(!K(be.parentNode).whiteSpace.startsWith("pre")){var qe=function(dt,xt){return xt=xt.replace(/[^\u00a0]/g,""),xt.length<1&&dt?" ":xt};ke=ke.replace(/\r\n/g," ").replace(/\n/g," "),ke=ke.replace(/\s\s+/g,qe.bind(qe,!0)),(be.previousSibling==null&&U(be.parentNode)||be.previousSibling!=null&&U(be.previousSibling))&&(ke=ke.replace(/^\s+/,qe.bind(qe,!1))),(be.nextSibling==null&&U(be.parentNode)||be.nextSibling!=null&&U(be.nextSibling))&&(ke=ke.replace(/\s+$/,qe.bind(qe,!1)))}return _e.insert(ke)}r.default=O,r.matchAttributor=oe,r.matchBlot=re,r.matchNewline=We,r.matchSpacing=Ce,r.matchText=Ye}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function j(g,y){for(var N=0;N<y.length;N++){var S=y[N];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(g,S.key,S)}}return function(g,y,N){return y&&j(g.prototype,y),N&&j(g,N),g}})(),c=function j(g,y,N){g===null&&(g=Function.prototype);var S=Object.getOwnPropertyDescriptor(g,y);if(S===void 0){var C=Object.getPrototypeOf(g);return C===null?void 0:j(C,y,N)}else{if("value"in S)return S.value;var w=S.get;return w===void 0?void 0:w.call(N)}},d=a(6),h=x(d);function x(j){return j&&j.__esModule?j:{default:j}}function f(j,g){if(!(j instanceof g))throw new TypeError("Cannot call a class as a function")}function m(j,g){if(!j)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:j}function p(j,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);j.prototype=Object.create(g&&g.prototype,{constructor:{value:j,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(j,g):j.__proto__=g)}var u=(function(j){p(g,j);function g(){return f(this,g),m(this,(g.__proto__||Object.getPrototypeOf(g)).apply(this,arguments))}return l(g,[{key:"optimize",value:function(N){c(g.prototype.__proto__||Object.getPrototypeOf(g.prototype),"optimize",this).call(this,N),this.domNode.tagName!==this.statics.tagName[0]&&this.replaceWith(this.statics.blotName)}}],[{key:"create",value:function(){return c(g.__proto__||Object.getPrototypeOf(g),"create",this).call(this)}},{key:"formats",value:function(){return!0}}]),g})(h.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 l=(function(){function E(_,M){var q=[],G=!0,Z=!1,W=void 0;try{for(var z=_[Symbol.iterator](),F;!(G=(F=z.next()).done)&&(q.push(F.value),!(M&&q.length===M));G=!0);}catch(B){Z=!0,W=B}finally{try{!G&&z.return&&z.return()}finally{if(Z)throw W}}return q}return function(_,M){if(Array.isArray(_))return _;if(Symbol.iterator in Object(_))return E(_,M);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),c=(function(){function E(_,M){for(var q=0;q<M.length;q++){var G=M[q];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(_,G.key,G)}}return function(_,M,q){return M&&E(_.prototype,M),q&&E(_,q),_}})(),d=a(2),h=N(d),x=a(0),f=N(x),m=a(5),p=N(m),u=a(10),j=N(u),g=a(9),y=N(g);function N(E){return E&&E.__esModule?E:{default:E}}function S(E,_,M){return _ in E?Object.defineProperty(E,_,{value:M,enumerable:!0,configurable:!0,writable:!0}):E[_]=M,E}function C(E,_){if(!(E instanceof _))throw new TypeError("Cannot call a class as a function")}function w(E,_){if(!E)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return _&&(typeof _=="object"||typeof _=="function")?_:E}function R(E,_){if(typeof _!="function"&&_!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof _);E.prototype=Object.create(_&&_.prototype,{constructor:{value:E,enumerable:!1,writable:!0,configurable:!0}}),_&&(Object.setPrototypeOf?Object.setPrototypeOf(E,_):E.__proto__=_)}var P=(0,j.default)("quill:toolbar"),A=(function(E){R(_,E);function _(M,q){C(this,_);var G=w(this,(_.__proto__||Object.getPrototypeOf(_)).call(this,M,q));if(Array.isArray(G.options.container)){var Z=document.createElement("div");$(Z,G.options.container),M.container.parentNode.insertBefore(Z,M.container),G.container=Z}else typeof G.options.container=="string"?G.container=document.querySelector(G.options.container):G.container=G.options.container;if(!(G.container instanceof HTMLElement)){var W;return W=P.error("Container required for toolbar",G.options),w(G,W)}return G.container.classList.add("ql-toolbar"),G.controls=[],G.handlers={},Object.keys(G.options.handlers).forEach(function(z){G.addHandler(z,G.options.handlers[z])}),[].forEach.call(G.container.querySelectorAll("button, select"),function(z){G.attach(z)}),G.quill.on(p.default.events.EDITOR_CHANGE,function(z,F){z===p.default.events.SELECTION_CHANGE&&G.update(F)}),G.quill.on(p.default.events.SCROLL_OPTIMIZE,function(){var z=G.quill.selection.getRange(),F=l(z,1),B=F[0];G.update(B)}),G}return c(_,[{key:"addHandler",value:function(q,G){this.handlers[q]=G}},{key:"attach",value:function(q){var G=this,Z=[].find.call(q.classList,function(z){return z.indexOf("ql-")===0});if(Z){if(Z=Z.slice(3),q.tagName==="BUTTON"&&q.setAttribute("type","button"),this.handlers[Z]==null){if(this.quill.scroll.whitelist!=null&&this.quill.scroll.whitelist[Z]==null){P.warn("ignoring attaching to disabled format",Z,q);return}if(f.default.query(Z)==null){P.warn("ignoring attaching to nonexistent format",Z,q);return}}var W=q.tagName==="SELECT"?"change":"click";q.addEventListener(W,function(z){var F=void 0;if(q.tagName==="SELECT"){if(q.selectedIndex<0)return;var B=q.options[q.selectedIndex];B.hasAttribute("selected")?F=!1:F=B.value||!1}else q.classList.contains("ql-active")?F=!1:F=q.value||!q.hasAttribute("value"),z.preventDefault();G.quill.focus();var D=G.quill.selection.getRange(),O=l(D,1),V=O[0];if(G.handlers[Z]!=null)G.handlers[Z].call(G,F);else if(f.default.query(Z).prototype instanceof f.default.Embed){if(F=prompt("Enter "+Z),!F)return;G.quill.updateContents(new h.default().retain(V.index).delete(V.length).insert(S({},Z,F)),p.default.sources.USER)}else G.quill.format(Z,F,p.default.sources.USER);G.update(V)}),this.controls.push([Z,q])}}},{key:"update",value:function(q){var G=q==null?{}:this.quill.getFormat(q);this.controls.forEach(function(Z){var W=l(Z,2),z=W[0],F=W[1];if(F.tagName==="SELECT"){var B=void 0;if(q==null)B=null;else if(G[z]==null)B=F.querySelector("option[selected]");else if(!Array.isArray(G[z])){var D=G[z];typeof D=="string"&&(D=D.replace(/\"/g,'\\"')),B=F.querySelector('option[value="'+D+'"]')}B==null?(F.value="",F.selectedIndex=-1):B.selected=!0}else if(q==null)F.classList.remove("ql-active");else if(F.hasAttribute("value")){var O=G[z]===F.getAttribute("value")||G[z]!=null&&G[z].toString()===F.getAttribute("value")||G[z]==null&&!F.getAttribute("value");F.classList.toggle("ql-active",O)}else F.classList.toggle("ql-active",G[z]!=null)})}}]),_})(y.default);A.DEFAULTS={};function I(E,_,M){var q=document.createElement("button");q.setAttribute("type","button"),q.classList.add("ql-"+_),M!=null&&(q.value=M),E.appendChild(q)}function $(E,_){Array.isArray(_[0])||(_=[_]),_.forEach(function(M){var q=document.createElement("span");q.classList.add("ql-formats"),M.forEach(function(G){if(typeof G=="string")I(q,G);else{var Z=Object.keys(G)[0],W=G[Z];Array.isArray(W)?T(q,Z,W):I(q,Z,W)}}),E.appendChild(q)})}function T(E,_,M){var q=document.createElement("select");q.classList.add("ql-"+_),M.forEach(function(G){var Z=document.createElement("option");G!==!1?Z.setAttribute("value",G):Z.setAttribute("selected","selected"),q.appendChild(Z)}),E.appendChild(q)}A.DEFAULTS={container:null,handlers:{clean:function(){var _=this,M=this.quill.getSelection();if(M!=null)if(M.length==0){var q=this.quill.getFormat();Object.keys(q).forEach(function(G){f.default.query(G,f.default.Scope.INLINE)!=null&&_.quill.format(G,!1)})}else this.quill.removeFormat(M,p.default.sources.USER)},direction:function(_){var M=this.quill.getFormat().align;_==="rtl"&&M==null?this.quill.format("align","right",p.default.sources.USER):!_&&M==="right"&&this.quill.format("align",!1,p.default.sources.USER),this.quill.format("direction",_,p.default.sources.USER)},indent:function(_){var M=this.quill.getSelection(),q=this.quill.getFormat(M),G=parseInt(q.indent||0);if(_==="+1"||_==="-1"){var Z=_==="+1"?1:-1;q.direction==="rtl"&&(Z*=-1),this.quill.format("indent",G+Z,p.default.sources.USER)}},link:function(_){_===!0&&(_=prompt("Enter link URL:")),this.quill.format("link",_,p.default.sources.USER)},list:function(_){var M=this.quill.getSelection(),q=this.quill.getFormat(M);_==="check"?q.list==="checked"||q.list==="unchecked"?this.quill.format("list",!1,p.default.sources.USER):this.quill.format("list","unchecked",p.default.sources.USER):this.quill.format("list",_,p.default.sources.USER)}}},r.default=A,r.addControls=$}),(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 l=(function(){function j(g,y){for(var N=0;N<y.length;N++){var S=y[N];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(g,S.key,S)}}return function(g,y,N){return y&&j(g.prototype,y),N&&j(g,N),g}})(),c=function j(g,y,N){g===null&&(g=Function.prototype);var S=Object.getOwnPropertyDescriptor(g,y);if(S===void 0){var C=Object.getPrototypeOf(g);return C===null?void 0:j(C,y,N)}else{if("value"in S)return S.value;var w=S.get;return w===void 0?void 0:w.call(N)}},d=a(28),h=x(d);function x(j){return j&&j.__esModule?j:{default:j}}function f(j,g){if(!(j instanceof g))throw new TypeError("Cannot call a class as a function")}function m(j,g){if(!j)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:j}function p(j,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);j.prototype=Object.create(g&&g.prototype,{constructor:{value:j,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(j,g):j.__proto__=g)}var u=(function(j){p(g,j);function g(y,N){f(this,g);var S=m(this,(g.__proto__||Object.getPrototypeOf(g)).call(this,y));return S.label.innerHTML=N,S.container.classList.add("ql-color-picker"),[].slice.call(S.container.querySelectorAll(".ql-picker-item"),0,7).forEach(function(C){C.classList.add("ql-primary")}),S}return l(g,[{key:"buildItem",value:function(N){var S=c(g.prototype.__proto__||Object.getPrototypeOf(g.prototype),"buildItem",this).call(this,N);return S.style.backgroundColor=N.getAttribute("value")||"",S}},{key:"selectItem",value:function(N,S){c(g.prototype.__proto__||Object.getPrototypeOf(g.prototype),"selectItem",this).call(this,N,S);var C=this.label.querySelector(".ql-color-label"),w=N&&N.getAttribute("data-value")||"";C&&(C.tagName==="line"?C.style.stroke=w:C.style.fill=w)}}]),g})(h.default);r.default=u}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function j(g,y){for(var N=0;N<y.length;N++){var S=y[N];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(g,S.key,S)}}return function(g,y,N){return y&&j(g.prototype,y),N&&j(g,N),g}})(),c=function j(g,y,N){g===null&&(g=Function.prototype);var S=Object.getOwnPropertyDescriptor(g,y);if(S===void 0){var C=Object.getPrototypeOf(g);return C===null?void 0:j(C,y,N)}else{if("value"in S)return S.value;var w=S.get;return w===void 0?void 0:w.call(N)}},d=a(28),h=x(d);function x(j){return j&&j.__esModule?j:{default:j}}function f(j,g){if(!(j instanceof g))throw new TypeError("Cannot call a class as a function")}function m(j,g){if(!j)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:j}function p(j,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);j.prototype=Object.create(g&&g.prototype,{constructor:{value:j,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(j,g):j.__proto__=g)}var u=(function(j){p(g,j);function g(y,N){f(this,g);var S=m(this,(g.__proto__||Object.getPrototypeOf(g)).call(this,y));return S.container.classList.add("ql-icon-picker"),[].forEach.call(S.container.querySelectorAll(".ql-picker-item"),function(C){C.innerHTML=N[C.getAttribute("data-value")||""]}),S.defaultItem=S.container.querySelector(".ql-selected"),S.selectItem(S.defaultItem),S}return l(g,[{key:"selectItem",value:function(N,S){c(g.prototype.__proto__||Object.getPrototypeOf(g.prototype),"selectItem",this).call(this,N,S),N=N||this.defaultItem,this.label.innerHTML=N.innerHTML}}]),g})(h.default);r.default=u}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function h(x,f){for(var m=0;m<f.length;m++){var p=f[m];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(x,p.key,p)}}return function(x,f,m){return f&&h(x.prototype,f),m&&h(x,m),x}})();function c(h,x){if(!(h instanceof x))throw new TypeError("Cannot call a class as a function")}var d=(function(){function h(x,f){var m=this;c(this,h),this.quill=x,this.boundsContainer=f||document.body,this.root=x.addContainer("ql-tooltip"),this.root.innerHTML=this.constructor.TEMPLATE,this.quill.root===this.quill.scrollingContainer&&this.quill.root.addEventListener("scroll",function(){m.root.style.marginTop=-1*m.quill.root.scrollTop+"px"}),this.hide()}return l(h,[{key:"hide",value:function(){this.root.classList.add("ql-hidden")}},{key:"position",value:function(f){var m=f.left+f.width/2-this.root.offsetWidth/2,p=f.bottom+this.quill.root.scrollTop;this.root.style.left=m+"px",this.root.style.top=p+"px",this.root.classList.remove("ql-flip");var u=this.boundsContainer.getBoundingClientRect(),j=this.root.getBoundingClientRect(),g=0;if(j.right>u.right&&(g=u.right-j.right,this.root.style.left=m+g+"px"),j.left<u.left&&(g=u.left-j.left,this.root.style.left=m+g+"px"),j.bottom>u.bottom){var y=j.bottom-j.top,N=f.bottom-f.top+y;this.root.style.top=p-N+"px",this.root.classList.add("ql-flip")}return g}},{key:"show",value:function(){this.root.classList.remove("ql-editing"),this.root.classList.remove("ql-hidden")}}]),h})();r.default=d}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function T(E,_){var M=[],q=!0,G=!1,Z=void 0;try{for(var W=E[Symbol.iterator](),z;!(q=(z=W.next()).done)&&(M.push(z.value),!(_&&M.length===_));q=!0);}catch(F){G=!0,Z=F}finally{try{!q&&W.return&&W.return()}finally{if(G)throw Z}}return M}return function(E,_){if(Array.isArray(E))return E;if(Symbol.iterator in Object(E))return T(E,_);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),c=function T(E,_,M){E===null&&(E=Function.prototype);var q=Object.getOwnPropertyDescriptor(E,_);if(q===void 0){var G=Object.getPrototypeOf(E);return G===null?void 0:T(G,_,M)}else{if("value"in q)return q.value;var Z=q.get;return Z===void 0?void 0:Z.call(M)}},d=(function(){function T(E,_){for(var M=0;M<_.length;M++){var q=_[M];q.enumerable=q.enumerable||!1,q.configurable=!0,"value"in q&&(q.writable=!0),Object.defineProperty(E,q.key,q)}}return function(E,_,M){return _&&T(E.prototype,_),M&&T(E,M),E}})(),h=a(3),x=C(h),f=a(8),m=C(f),p=a(43),u=C(p),j=a(27),g=C(j),y=a(15),N=a(41),S=C(N);function C(T){return T&&T.__esModule?T:{default:T}}function w(T,E){if(!(T instanceof E))throw new TypeError("Cannot call a class as a function")}function R(T,E){if(!T)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return E&&(typeof E=="object"||typeof E=="function")?E:T}function P(T,E){if(typeof E!="function"&&E!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof E);T.prototype=Object.create(E&&E.prototype,{constructor:{value:T,enumerable:!1,writable:!0,configurable:!0}}),E&&(Object.setPrototypeOf?Object.setPrototypeOf(T,E):T.__proto__=E)}var A=[[{header:["1","2","3",!1]}],["bold","italic","underline","link"],[{list:"ordered"},{list:"bullet"}],["clean"]],I=(function(T){P(E,T);function E(_,M){w(this,E),M.modules.toolbar!=null&&M.modules.toolbar.container==null&&(M.modules.toolbar.container=A);var q=R(this,(E.__proto__||Object.getPrototypeOf(E)).call(this,_,M));return q.quill.container.classList.add("ql-snow"),q}return d(E,[{key:"extendToolbar",value:function(M){M.container.classList.add("ql-snow"),this.buildButtons([].slice.call(M.container.querySelectorAll("button")),S.default),this.buildPickers([].slice.call(M.container.querySelectorAll("select")),S.default),this.tooltip=new $(this.quill,this.options.bounds),M.container.querySelector(".ql-link")&&this.quill.keyboard.addBinding({key:"K",shortKey:!0},function(q,G){M.handlers.link.call(M,!G.format.link)})}}]),E})(u.default);I.DEFAULTS=(0,x.default)(!0,{},u.default.DEFAULTS,{modules:{toolbar:{handlers:{link:function(E){if(E){var _=this.quill.getSelection();if(_==null||_.length==0)return;var M=this.quill.getText(_);/^\S+@\S+\.\S+$/.test(M)&&M.indexOf("mailto:")!==0&&(M="mailto:"+M);var q=this.quill.theme.tooltip;q.edit("link",M)}else this.quill.format("link",!1)}}}}});var $=(function(T){P(E,T);function E(_,M){w(this,E);var q=R(this,(E.__proto__||Object.getPrototypeOf(E)).call(this,_,M));return q.preview=q.root.querySelector("a.ql-preview"),q}return d(E,[{key:"listen",value:function(){var M=this;c(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"listen",this).call(this),this.root.querySelector("a.ql-action").addEventListener("click",function(q){M.root.classList.contains("ql-editing")?M.save():M.edit("link",M.preview.textContent),q.preventDefault()}),this.root.querySelector("a.ql-remove").addEventListener("click",function(q){if(M.linkRange!=null){var G=M.linkRange;M.restoreFocus(),M.quill.formatText(G,"link",!1,m.default.sources.USER),delete M.linkRange}q.preventDefault(),M.hide()}),this.quill.on(m.default.events.SELECTION_CHANGE,function(q,G,Z){if(q!=null){if(q.length===0&&Z===m.default.sources.USER){var W=M.quill.scroll.descendant(g.default,q.index),z=l(W,2),F=z[0],B=z[1];if(F!=null){M.linkRange=new y.Range(q.index-B,F.length());var D=g.default.formats(F.domNode);M.preview.textContent=D,M.preview.setAttribute("href",D),M.show(),M.position(M.quill.getBounds(M.linkRange));return}}else delete M.linkRange;M.hide()}})}},{key:"show",value:function(){c(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"show",this).call(this),this.root.removeAttribute("data-mode")}}]),E})(p.BaseTooltip);$.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=I}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(29),c=Ve(l),d=a(36),h=a(38),x=a(64),f=a(65),m=Ve(f),p=a(66),u=Ve(p),j=a(67),g=Ve(j),y=a(37),N=a(26),S=a(39),C=a(40),w=a(56),R=Ve(w),P=a(68),A=Ve(P),I=a(27),$=Ve(I),T=a(69),E=Ve(T),_=a(70),M=Ve(_),q=a(71),G=Ve(q),Z=a(72),W=Ve(Z),z=a(73),F=Ve(z),B=a(13),D=Ve(B),O=a(74),V=Ve(O),K=a(75),Y=Ve(K),U=a(57),X=Ve(U),ne=a(41),oe=Ve(ne),re=a(28),ge=Ve(re),ve=a(59),Se=Ve(ve),We=a(60),Ce=Ve(We),fe=a(61),Ye=Ve(fe),be=a(108),_e=Ve(be),ke=a(62),qe=Ve(ke);function Ve(dt){return dt&&dt.__esModule?dt:{default:dt}}c.default.register({"attributors/attribute/direction":h.DirectionAttribute,"attributors/class/align":d.AlignClass,"attributors/class/background":y.BackgroundClass,"attributors/class/color":N.ColorClass,"attributors/class/direction":h.DirectionClass,"attributors/class/font":S.FontClass,"attributors/class/size":C.SizeClass,"attributors/style/align":d.AlignStyle,"attributors/style/background":y.BackgroundStyle,"attributors/style/color":N.ColorStyle,"attributors/style/direction":h.DirectionStyle,"attributors/style/font":S.FontStyle,"attributors/style/size":C.SizeStyle},!0),c.default.register({"formats/align":d.AlignClass,"formats/direction":h.DirectionClass,"formats/indent":x.IndentClass,"formats/background":y.BackgroundStyle,"formats/color":N.ColorStyle,"formats/font":S.FontClass,"formats/size":C.SizeClass,"formats/blockquote":m.default,"formats/code-block":D.default,"formats/header":u.default,"formats/list":g.default,"formats/bold":R.default,"formats/code":B.Code,"formats/italic":A.default,"formats/link":$.default,"formats/script":E.default,"formats/strike":M.default,"formats/underline":G.default,"formats/image":W.default,"formats/video":F.default,"formats/list/item":j.ListItem,"modules/formula":V.default,"modules/syntax":Y.default,"modules/toolbar":X.default,"themes/bubble":_e.default,"themes/snow":qe.default,"ui/icons":oe.default,"ui/picker":ge.default,"ui/icon-picker":Ce.default,"ui/color-picker":Se.default,"ui/tooltip":Ye.default},!0),r.default=c.default}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.IndentClass=void 0;var l=(function(){function g(y,N){for(var S=0;S<N.length;S++){var C=N[S];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(y,C.key,C)}}return function(y,N,S){return N&&g(y.prototype,N),S&&g(y,S),y}})(),c=function g(y,N,S){y===null&&(y=Function.prototype);var C=Object.getOwnPropertyDescriptor(y,N);if(C===void 0){var w=Object.getPrototypeOf(y);return w===null?void 0:g(w,N,S)}else{if("value"in C)return C.value;var R=C.get;return R===void 0?void 0:R.call(S)}},d=a(0),h=x(d);function x(g){return g&&g.__esModule?g:{default:g}}function f(g,y){if(!(g instanceof y))throw new TypeError("Cannot call a class as a function")}function m(g,y){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return y&&(typeof y=="object"||typeof y=="function")?y:g}function p(g,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof y);g.prototype=Object.create(y&&y.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),y&&(Object.setPrototypeOf?Object.setPrototypeOf(g,y):g.__proto__=y)}var u=(function(g){p(y,g);function y(){return f(this,y),m(this,(y.__proto__||Object.getPrototypeOf(y)).apply(this,arguments))}return l(y,[{key:"add",value:function(S,C){if(C==="+1"||C==="-1"){var w=this.value(S)||0;C=C==="+1"?w+1:w-1}return C===0?(this.remove(S),!0):c(y.prototype.__proto__||Object.getPrototypeOf(y.prototype),"add",this).call(this,S,C)}},{key:"canAdd",value:function(S,C){return c(y.prototype.__proto__||Object.getPrototypeOf(y.prototype),"canAdd",this).call(this,S,C)||c(y.prototype.__proto__||Object.getPrototypeOf(y.prototype),"canAdd",this).call(this,S,parseInt(C))}},{key:"value",value:function(S){return parseInt(c(y.prototype.__proto__||Object.getPrototypeOf(y.prototype),"value",this).call(this,S))||void 0}}]),y})(h.default.Attributor.Class),j=new u("indent","ql-indent",{scope:h.default.Scope.BLOCK,whitelist:[1,2,3,4,5,6,7,8]});r.IndentClass=j}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(4),c=d(l);function d(p){return p&&p.__esModule?p:{default:p}}function h(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function x(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function f(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var m=(function(p){f(u,p);function u(){return h(this,u),x(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u})(c.default);m.blotName="blockquote",m.tagName="blockquote",r.default=m}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function u(j,g){for(var y=0;y<g.length;y++){var N=g[y];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(j,N.key,N)}}return function(j,g,y){return g&&u(j.prototype,g),y&&u(j,y),j}})(),c=a(4),d=h(c);function h(u){return u&&u.__esModule?u:{default:u}}function x(u,j){if(!(u instanceof j))throw new TypeError("Cannot call a class as a function")}function f(u,j){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j&&(typeof j=="object"||typeof j=="function")?j:u}function m(u,j){if(typeof j!="function"&&j!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof j);u.prototype=Object.create(j&&j.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),j&&(Object.setPrototypeOf?Object.setPrototypeOf(u,j):u.__proto__=j)}var p=(function(u){m(j,u);function j(){return x(this,j),f(this,(j.__proto__||Object.getPrototypeOf(j)).apply(this,arguments))}return l(j,null,[{key:"formats",value:function(y){return this.tagName.indexOf(y.tagName)+1}}]),j})(d.default);p.blotName="header",p.tagName=["H1","H2","H3","H4","H5","H6"],r.default=p}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.ListItem=void 0;var l=(function(){function w(R,P){for(var A=0;A<P.length;A++){var I=P[A];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(R,I.key,I)}}return function(R,P,A){return P&&w(R.prototype,P),A&&w(R,A),R}})(),c=function w(R,P,A){R===null&&(R=Function.prototype);var I=Object.getOwnPropertyDescriptor(R,P);if(I===void 0){var $=Object.getPrototypeOf(R);return $===null?void 0:w($,P,A)}else{if("value"in I)return I.value;var T=I.get;return T===void 0?void 0:T.call(A)}},d=a(0),h=u(d),x=a(4),f=u(x),m=a(25),p=u(m);function u(w){return w&&w.__esModule?w:{default:w}}function j(w,R,P){return R in w?Object.defineProperty(w,R,{value:P,enumerable:!0,configurable:!0,writable:!0}):w[R]=P,w}function g(w,R){if(!(w instanceof R))throw new TypeError("Cannot call a class as a function")}function y(w,R){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return R&&(typeof R=="object"||typeof R=="function")?R:w}function N(w,R){if(typeof R!="function"&&R!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof R);w.prototype=Object.create(R&&R.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),R&&(Object.setPrototypeOf?Object.setPrototypeOf(w,R):w.__proto__=R)}var S=(function(w){N(R,w);function R(){return g(this,R),y(this,(R.__proto__||Object.getPrototypeOf(R)).apply(this,arguments))}return l(R,[{key:"format",value:function(A,I){A===C.blotName&&!I?this.replaceWith(h.default.create(this.statics.scope)):c(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"format",this).call(this,A,I)}},{key:"remove",value:function(){this.prev==null&&this.next==null?this.parent.remove():c(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"remove",this).call(this)}},{key:"replaceWith",value:function(A,I){return this.parent.isolate(this.offset(this.parent),this.length()),A===this.parent.statics.blotName?(this.parent.replaceWith(A,I),this):(this.parent.unwrap(),c(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"replaceWith",this).call(this,A,I))}}],[{key:"formats",value:function(A){return A.tagName===this.tagName?void 0:c(R.__proto__||Object.getPrototypeOf(R),"formats",this).call(this,A)}}]),R})(f.default);S.blotName="list-item",S.tagName="LI";var C=(function(w){N(R,w),l(R,null,[{key:"create",value:function(A){var I=A==="ordered"?"OL":"UL",$=c(R.__proto__||Object.getPrototypeOf(R),"create",this).call(this,I);return(A==="checked"||A==="unchecked")&&$.setAttribute("data-checked",A==="checked"),$}},{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(P){g(this,R);var A=y(this,(R.__proto__||Object.getPrototypeOf(R)).call(this,P)),I=function(T){if(T.target.parentNode===P){var E=A.statics.formats(P),_=h.default.find(T.target);E==="checked"?_.format("list","unchecked"):E==="unchecked"&&_.format("list","checked")}};return P.addEventListener("touchstart",I),P.addEventListener("mousedown",I),A}return l(R,[{key:"format",value:function(A,I){this.children.length>0&&this.children.tail.format(A,I)}},{key:"formats",value:function(){return j({},this.statics.blotName,this.statics.formats(this.domNode))}},{key:"insertBefore",value:function(A,I){if(A instanceof S)c(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"insertBefore",this).call(this,A,I);else{var $=I==null?this.length():I.offset(this),T=this.split($);T.parent.insertBefore(A,T)}}},{key:"optimize",value:function(A){c(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"optimize",this).call(this,A);var I=this.next;I!=null&&I.prev===this&&I.statics.blotName===this.statics.blotName&&I.domNode.tagName===this.domNode.tagName&&I.domNode.getAttribute("data-checked")===this.domNode.getAttribute("data-checked")&&(I.moveChildren(this),I.remove())}},{key:"replace",value:function(A){if(A.statics.blotName!==this.statics.blotName){var I=h.default.create(this.statics.defaultChild);A.moveChildren(I),this.appendChild(I)}c(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"replace",this).call(this,A)}}]),R})(p.default);C.blotName="list",C.scope=h.default.Scope.BLOCK_BLOT,C.tagName=["OL","UL"],C.defaultChild="list-item",C.allowedChildren=[S],r.ListItem=S,r.default=C}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(56),c=d(l);function d(p){return p&&p.__esModule?p:{default:p}}function h(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function x(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function f(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var m=(function(p){f(u,p);function u(){return h(this,u),x(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u})(c.default);m.blotName="italic",m.tagName=["EM","I"],r.default=m}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function j(g,y){for(var N=0;N<y.length;N++){var S=y[N];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(g,S.key,S)}}return function(g,y,N){return y&&j(g.prototype,y),N&&j(g,N),g}})(),c=function j(g,y,N){g===null&&(g=Function.prototype);var S=Object.getOwnPropertyDescriptor(g,y);if(S===void 0){var C=Object.getPrototypeOf(g);return C===null?void 0:j(C,y,N)}else{if("value"in S)return S.value;var w=S.get;return w===void 0?void 0:w.call(N)}},d=a(6),h=x(d);function x(j){return j&&j.__esModule?j:{default:j}}function f(j,g){if(!(j instanceof g))throw new TypeError("Cannot call a class as a function")}function m(j,g){if(!j)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:j}function p(j,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);j.prototype=Object.create(g&&g.prototype,{constructor:{value:j,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(j,g):j.__proto__=g)}var u=(function(j){p(g,j);function g(){return f(this,g),m(this,(g.__proto__||Object.getPrototypeOf(g)).apply(this,arguments))}return l(g,null,[{key:"create",value:function(N){return N==="super"?document.createElement("sup"):N==="sub"?document.createElement("sub"):c(g.__proto__||Object.getPrototypeOf(g),"create",this).call(this,N)}},{key:"formats",value:function(N){if(N.tagName==="SUB")return"sub";if(N.tagName==="SUP")return"super"}}]),g})(h.default);u.blotName="script",u.tagName=["SUB","SUP"],r.default=u}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(6),c=d(l);function d(p){return p&&p.__esModule?p:{default:p}}function h(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function x(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function f(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var m=(function(p){f(u,p);function u(){return h(this,u),x(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u})(c.default);m.blotName="strike",m.tagName="S",r.default=m}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(6),c=d(l);function d(p){return p&&p.__esModule?p:{default:p}}function h(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function x(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function f(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var m=(function(p){f(u,p);function u(){return h(this,u),x(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u})(c.default);m.blotName="underline",m.tagName="U",r.default=m}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function y(N,S){for(var C=0;C<S.length;C++){var w=S[C];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(N,w.key,w)}}return function(N,S,C){return S&&y(N.prototype,S),C&&y(N,C),N}})(),c=function y(N,S,C){N===null&&(N=Function.prototype);var w=Object.getOwnPropertyDescriptor(N,S);if(w===void 0){var R=Object.getPrototypeOf(N);return R===null?void 0:y(R,S,C)}else{if("value"in w)return w.value;var P=w.get;return P===void 0?void 0:P.call(C)}},d=a(0),h=f(d),x=a(27);function f(y){return y&&y.__esModule?y:{default:y}}function m(y,N){if(!(y instanceof N))throw new TypeError("Cannot call a class as a function")}function p(y,N){if(!y)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return N&&(typeof N=="object"||typeof N=="function")?N:y}function u(y,N){if(typeof N!="function"&&N!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof N);y.prototype=Object.create(N&&N.prototype,{constructor:{value:y,enumerable:!1,writable:!0,configurable:!0}}),N&&(Object.setPrototypeOf?Object.setPrototypeOf(y,N):y.__proto__=N)}var j=["alt","height","width"],g=(function(y){u(N,y);function N(){return m(this,N),p(this,(N.__proto__||Object.getPrototypeOf(N)).apply(this,arguments))}return l(N,[{key:"format",value:function(C,w){j.indexOf(C)>-1?w?this.domNode.setAttribute(C,w):this.domNode.removeAttribute(C):c(N.prototype.__proto__||Object.getPrototypeOf(N.prototype),"format",this).call(this,C,w)}}],[{key:"create",value:function(C){var w=c(N.__proto__||Object.getPrototypeOf(N),"create",this).call(this,C);return typeof C=="string"&&w.setAttribute("src",this.sanitize(C)),w}},{key:"formats",value:function(C){return j.reduce(function(w,R){return C.hasAttribute(R)&&(w[R]=C.getAttribute(R)),w},{})}},{key:"match",value:function(C){return/\.(jpe?g|gif|png)$/.test(C)||/^data:image\/.+;base64/.test(C)}},{key:"sanitize",value:function(C){return(0,x.sanitize)(C,["http","https","data"])?C:"//:0"}},{key:"value",value:function(C){return C.getAttribute("src")}}]),N})(h.default.Embed);g.blotName="image",g.tagName="IMG",r.default=g}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function y(N,S){for(var C=0;C<S.length;C++){var w=S[C];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(N,w.key,w)}}return function(N,S,C){return S&&y(N.prototype,S),C&&y(N,C),N}})(),c=function y(N,S,C){N===null&&(N=Function.prototype);var w=Object.getOwnPropertyDescriptor(N,S);if(w===void 0){var R=Object.getPrototypeOf(N);return R===null?void 0:y(R,S,C)}else{if("value"in w)return w.value;var P=w.get;return P===void 0?void 0:P.call(C)}},d=a(4),h=a(27),x=f(h);function f(y){return y&&y.__esModule?y:{default:y}}function m(y,N){if(!(y instanceof N))throw new TypeError("Cannot call a class as a function")}function p(y,N){if(!y)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return N&&(typeof N=="object"||typeof N=="function")?N:y}function u(y,N){if(typeof N!="function"&&N!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof N);y.prototype=Object.create(N&&N.prototype,{constructor:{value:y,enumerable:!1,writable:!0,configurable:!0}}),N&&(Object.setPrototypeOf?Object.setPrototypeOf(y,N):y.__proto__=N)}var j=["height","width"],g=(function(y){u(N,y);function N(){return m(this,N),p(this,(N.__proto__||Object.getPrototypeOf(N)).apply(this,arguments))}return l(N,[{key:"format",value:function(C,w){j.indexOf(C)>-1?w?this.domNode.setAttribute(C,w):this.domNode.removeAttribute(C):c(N.prototype.__proto__||Object.getPrototypeOf(N.prototype),"format",this).call(this,C,w)}}],[{key:"create",value:function(C){var w=c(N.__proto__||Object.getPrototypeOf(N),"create",this).call(this,C);return w.setAttribute("frameborder","0"),w.setAttribute("allowfullscreen",!0),w.setAttribute("src",this.sanitize(C)),w}},{key:"formats",value:function(C){return j.reduce(function(w,R){return C.hasAttribute(R)&&(w[R]=C.getAttribute(R)),w},{})}},{key:"sanitize",value:function(C){return x.default.sanitize(C)}},{key:"value",value:function(C){return C.getAttribute("src")}}]),N})(d.BlockEmbed);g.blotName="video",g.className="ql-video",g.tagName="IFRAME",r.default=g}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.FormulaBlot=void 0;var l=(function(){function C(w,R){for(var P=0;P<R.length;P++){var A=R[P];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(w,A.key,A)}}return function(w,R,P){return R&&C(w.prototype,R),P&&C(w,P),w}})(),c=function C(w,R,P){w===null&&(w=Function.prototype);var A=Object.getOwnPropertyDescriptor(w,R);if(A===void 0){var I=Object.getPrototypeOf(w);return I===null?void 0:C(I,R,P)}else{if("value"in A)return A.value;var $=A.get;return $===void 0?void 0:$.call(P)}},d=a(35),h=u(d),x=a(5),f=u(x),m=a(9),p=u(m);function u(C){return C&&C.__esModule?C:{default:C}}function j(C,w){if(!(C instanceof w))throw new TypeError("Cannot call a class as a function")}function g(C,w){if(!C)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return w&&(typeof w=="object"||typeof w=="function")?w:C}function y(C,w){if(typeof w!="function"&&w!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof w);C.prototype=Object.create(w&&w.prototype,{constructor:{value:C,enumerable:!1,writable:!0,configurable:!0}}),w&&(Object.setPrototypeOf?Object.setPrototypeOf(C,w):C.__proto__=w)}var N=(function(C){y(w,C);function w(){return j(this,w),g(this,(w.__proto__||Object.getPrototypeOf(w)).apply(this,arguments))}return l(w,null,[{key:"create",value:function(P){var A=c(w.__proto__||Object.getPrototypeOf(w),"create",this).call(this,P);return typeof P=="string"&&(window.katex.render(P,A,{throwOnError:!1,errorColor:"#f00"}),A.setAttribute("data-value",P)),A}},{key:"value",value:function(P){return P.getAttribute("data-value")}}]),w})(h.default);N.blotName="formula",N.className="ql-formula",N.tagName="SPAN";var S=(function(C){y(w,C),l(w,null,[{key:"register",value:function(){f.default.register(N,!0)}}]);function w(){j(this,w);var R=g(this,(w.__proto__||Object.getPrototypeOf(w)).call(this));if(window.katex==null)throw new Error("Formula module requires KaTeX.");return R}return w})(p.default);r.FormulaBlot=N,r.default=S}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.CodeToken=r.CodeBlock=void 0;var l=(function(){function P(A,I){for(var $=0;$<I.length;$++){var T=I[$];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(A,T.key,T)}}return function(A,I,$){return I&&P(A.prototype,I),$&&P(A,$),A}})(),c=function P(A,I,$){A===null&&(A=Function.prototype);var T=Object.getOwnPropertyDescriptor(A,I);if(T===void 0){var E=Object.getPrototypeOf(A);return E===null?void 0:P(E,I,$)}else{if("value"in T)return T.value;var _=T.get;return _===void 0?void 0:_.call($)}},d=a(0),h=g(d),x=a(5),f=g(x),m=a(9),p=g(m),u=a(13),j=g(u);function g(P){return P&&P.__esModule?P:{default:P}}function y(P,A){if(!(P instanceof A))throw new TypeError("Cannot call a class as a function")}function N(P,A){if(!P)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return A&&(typeof A=="object"||typeof A=="function")?A:P}function S(P,A){if(typeof A!="function"&&A!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof A);P.prototype=Object.create(A&&A.prototype,{constructor:{value:P,enumerable:!1,writable:!0,configurable:!0}}),A&&(Object.setPrototypeOf?Object.setPrototypeOf(P,A):P.__proto__=A)}var C=(function(P){S(A,P);function A(){return y(this,A),N(this,(A.__proto__||Object.getPrototypeOf(A)).apply(this,arguments))}return l(A,[{key:"replaceWith",value:function($){this.domNode.textContent=this.domNode.textContent,this.attach(),c(A.prototype.__proto__||Object.getPrototypeOf(A.prototype),"replaceWith",this).call(this,$)}},{key:"highlight",value:function($){var T=this.domNode.textContent;this.cachedText!==T&&((T.trim().length>0||this.cachedText==null)&&(this.domNode.innerHTML=$(T),this.domNode.normalize(),this.attach()),this.cachedText=T)}}]),A})(j.default);C.className="ql-syntax";var w=new h.default.Attributor.Class("token","hljs",{scope:h.default.Scope.INLINE}),R=(function(P){S(A,P),l(A,null,[{key:"register",value:function(){f.default.register(w,!0),f.default.register(C,!0)}}]);function A(I,$){y(this,A);var T=N(this,(A.__proto__||Object.getPrototypeOf(A)).call(this,I,$));if(typeof T.options.highlight!="function")throw new Error("Syntax module requires highlight.js. Please include the library on the page before Quill.");var E=null;return T.quill.on(f.default.events.SCROLL_OPTIMIZE,function(){clearTimeout(E),E=setTimeout(function(){T.highlight(),E=null},T.options.interval)}),T.highlight(),T}return l(A,[{key:"highlight",value:function(){var $=this;if(!this.quill.selection.composing){this.quill.update(f.default.sources.USER);var T=this.quill.getSelection();this.quill.scroll.descendants(C).forEach(function(E){E.highlight($.options.highlight)}),this.quill.update(f.default.sources.SILENT),T!=null&&this.quill.setSelection(T,f.default.sources.SILENT)}}}]),A})(p.default);R.DEFAULTS={highlight:(function(){return window.hljs==null?null:function(P){var A=window.hljs.highlightAuto(P);return A.value}})(),interval:1e3},r.CodeBlock=C,r.CodeToken=w,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 l=function A(I,$,T){I===null&&(I=Function.prototype);var E=Object.getOwnPropertyDescriptor(I,$);if(E===void 0){var _=Object.getPrototypeOf(I);return _===null?void 0:A(_,$,T)}else{if("value"in E)return E.value;var M=E.get;return M===void 0?void 0:M.call(T)}},c=(function(){function A(I,$){for(var T=0;T<$.length;T++){var E=$[T];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(I,E.key,E)}}return function(I,$,T){return $&&A(I.prototype,$),T&&A(I,T),I}})(),d=a(3),h=y(d),x=a(8),f=y(x),m=a(43),p=y(m),u=a(15),j=a(41),g=y(j);function y(A){return A&&A.__esModule?A:{default:A}}function N(A,I){if(!(A instanceof I))throw new TypeError("Cannot call a class as a function")}function S(A,I){if(!A)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return I&&(typeof I=="object"||typeof I=="function")?I:A}function C(A,I){if(typeof I!="function"&&I!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof I);A.prototype=Object.create(I&&I.prototype,{constructor:{value:A,enumerable:!1,writable:!0,configurable:!0}}),I&&(Object.setPrototypeOf?Object.setPrototypeOf(A,I):A.__proto__=I)}var w=[["bold","italic","link"],[{header:1},{header:2},"blockquote"]],R=(function(A){C(I,A);function I($,T){N(this,I),T.modules.toolbar!=null&&T.modules.toolbar.container==null&&(T.modules.toolbar.container=w);var E=S(this,(I.__proto__||Object.getPrototypeOf(I)).call(this,$,T));return E.quill.container.classList.add("ql-bubble"),E}return c(I,[{key:"extendToolbar",value:function(T){this.tooltip=new P(this.quill,this.options.bounds),this.tooltip.root.appendChild(T.container),this.buildButtons([].slice.call(T.container.querySelectorAll("button")),g.default),this.buildPickers([].slice.call(T.container.querySelectorAll("select")),g.default)}}]),I})(p.default);R.DEFAULTS=(0,h.default)(!0,{},p.default.DEFAULTS,{modules:{toolbar:{handlers:{link:function(I){I?this.quill.theme.tooltip.edit():this.quill.format("link",!1)}}}}});var P=(function(A){C(I,A);function I($,T){N(this,I);var E=S(this,(I.__proto__||Object.getPrototypeOf(I)).call(this,$,T));return E.quill.on(f.default.events.EDITOR_CHANGE,function(_,M,q,G){if(_===f.default.events.SELECTION_CHANGE)if(M!=null&&M.length>0&&G===f.default.sources.USER){E.show(),E.root.style.left="0px",E.root.style.width="",E.root.style.width=E.root.offsetWidth+"px";var Z=E.quill.getLines(M.index,M.length);if(Z.length===1)E.position(E.quill.getBounds(M));else{var W=Z[Z.length-1],z=E.quill.getIndex(W),F=Math.min(W.length()-1,M.index+M.length-z),B=E.quill.getBounds(new u.Range(z,F));E.position(B)}}else document.activeElement!==E.textbox&&E.quill.hasFocus()&&E.hide()}),E}return c(I,[{key:"listen",value:function(){var T=this;l(I.prototype.__proto__||Object.getPrototypeOf(I.prototype),"listen",this).call(this),this.root.querySelector(".ql-close").addEventListener("click",function(){T.root.classList.remove("ql-editing")}),this.quill.on(f.default.events.SCROLL_OPTIMIZE,function(){setTimeout(function(){if(!T.root.classList.contains("ql-hidden")){var E=T.quill.getSelection();E!=null&&T.position(T.quill.getBounds(E))}},1)})}},{key:"cancel",value:function(){this.show()}},{key:"position",value:function(T){var E=l(I.prototype.__proto__||Object.getPrototypeOf(I.prototype),"position",this).call(this,T),_=this.root.querySelector(".ql-tooltip-arrow");if(_.style.marginLeft="",E===0)return E;_.style.marginLeft=-1*E-_.offsetWidth/2+"px"}}]),I})(m.BaseTooltip);P.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=P,r.default=R}),(function(n,r,a){n.exports=a(63)})]).default})})(im)),im.exports}var Ha,tC;function IU(){if(tC)return Ha;tC=1;var t=Ha&&Ha.__extends||(function(){var f=function(m,p){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,j){u.__proto__=j}||function(u,j){for(var g in j)j.hasOwnProperty(g)&&(u[g]=j[g])},f(m,p)};return function(m,p){f(m,p);function u(){this.constructor=m}m.prototype=p===null?Object.create(p):(u.prototype=p.prototype,new u)}})(),s=Ha&&Ha.__assign||function(){return s=Object.assign||function(f){for(var m,p=1,u=arguments.length;p<u;p++){m=arguments[p];for(var j in m)Object.prototype.hasOwnProperty.call(m,j)&&(f[j]=m[j])}return f},s.apply(this,arguments)},n=Ha&&Ha.__spreadArrays||function(){for(var f=0,m=0,p=arguments.length;m<p;m++)f+=arguments[m].length;for(var u=Array(f),j=0,m=0;m<p;m++)for(var g=arguments[m],y=0,N=g.length;y<N;y++,j++)u[j]=g[y];return u},r=Ha&&Ha.__importDefault||function(f){return f&&f.__esModule?f:{default:f}},a=r(Lc()),l=r(Dv()),c=r(PU()),d=r(OU()),h=(function(f){t(m,f);function m(p){var u=f.call(this,p)||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(g,y,N,S){var C,w,R,P;g==="text-change"?(w=(C=u).onEditorChangeText)===null||w===void 0||w.call(C,u.editor.root.innerHTML,y,S,u.unprivilegedEditor):g==="selection-change"&&((P=(R=u).onEditorChangeSelection)===null||P===void 0||P.call(R,y,S,u.unprivilegedEditor))};var j=u.isControlled()?p.value:p.defaultValue;return u.value=j??"",u}return m.prototype.validateProps=function(p){var u;if(a.default.Children.count(p.children)>1)throw new Error("The Quill editing area can only be composed of a single React element.");if(a.default.Children.count(p.children)){var j=a.default.Children.only(p.children);if(((u=j)===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&&p.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")},m.prototype.shouldComponentUpdate=function(p,u){var j=this,g;if(this.validateProps(p),!this.editor||this.state.generation!==u.generation)return!0;if("value"in p){var y=this.getEditorContents(),N=(g=p.value,g??"");this.isEqualValue(N,y)||this.setEditorContents(this.editor,N)}return p.readOnly!==this.props.readOnly&&this.setEditorReadOnly(this.editor,p.readOnly),n(this.cleanProps,this.dirtyProps).some(function(S){return!c.default(p[S],j.props[S])})},m.prototype.shouldComponentRegenerate=function(p){var u=this;return this.dirtyProps.some(function(j){return!c.default(p[j],u.props[j])})},m.prototype.componentDidMount=function(){this.instantiateEditor(),this.setEditorContents(this.editor,this.getEditorContents())},m.prototype.componentWillUnmount=function(){this.destroyEditor()},m.prototype.componentDidUpdate=function(p,u){var j=this;if(this.editor&&this.shouldComponentRegenerate(p)){var g=this.editor.getContents(),y=this.editor.getSelection();this.regenerationSnapshot={delta:g,selection:y},this.setState({generation:this.state.generation+1}),this.destroyEditor()}if(this.state.generation!==u.generation){var N=this.regenerationSnapshot,g=N.delta,S=N.selection;delete this.regenerationSnapshot,this.instantiateEditor();var C=this.editor;C.setContents(g),x(function(){return j.setEditorSelection(C,S)})}},m.prototype.instantiateEditor=function(){this.editor?this.hookEditor(this.editor):this.editor=this.createEditor(this.getEditingArea(),this.getEditorConfig())},m.prototype.destroyEditor=function(){this.editor&&this.unhookEditor(this.editor)},m.prototype.isControlled=function(){return"value"in this.props},m.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}},m.prototype.getEditor=function(){if(!this.editor)throw new Error("Accessing non-instantiated editor");return this.editor},m.prototype.createEditor=function(p,u){var j=new d.default(p,u);return u.tabIndex!=null&&this.setEditorTabIndex(j,u.tabIndex),this.hookEditor(j),j},m.prototype.hookEditor=function(p){this.unprivilegedEditor=this.makeUnprivilegedEditor(p),p.on("editor-change",this.onEditorChange)},m.prototype.unhookEditor=function(p){p.off("editor-change",this.onEditorChange)},m.prototype.getEditorContents=function(){return this.value},m.prototype.getEditorSelection=function(){return this.selection},m.prototype.isDelta=function(p){return p&&p.ops},m.prototype.isEqualValue=function(p,u){return this.isDelta(p)&&this.isDelta(u)?c.default(p.ops,u.ops):c.default(p,u)},m.prototype.setEditorContents=function(p,u){var j=this;this.value=u;var g=this.getEditorSelection();typeof u=="string"?p.setContents(p.clipboard.convert(u)):p.setContents(u),x(function(){return j.setEditorSelection(p,g)})},m.prototype.setEditorSelection=function(p,u){if(this.selection=u,u){var j=p.getLength();u.index=Math.max(0,Math.min(u.index,j-1)),u.length=Math.max(0,Math.min(u.length,j-1-u.index)),p.setSelection(u)}},m.prototype.setEditorTabIndex=function(p,u){var j,g;!((g=(j=p)===null||j===void 0?void 0:j.scroll)===null||g===void 0)&&g.domNode&&(p.scroll.domNode.tabIndex=u)},m.prototype.setEditorReadOnly=function(p,u){u?p.disable():p.enable()},m.prototype.makeUnprivilegedEditor=function(p){var u=p;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)}},m.prototype.getEditingArea=function(){if(!this.editingArea)throw new Error("Instantiating on missing editing area");var p=l.default.findDOMNode(this.editingArea);if(!p)throw new Error("Cannot find element for editing area");if(p.nodeType===3)throw new Error("Editing area cannot be a text node");return p},m.prototype.renderEditingArea=function(){var p=this,u=this.props,j=u.children,g=u.preserveWhitespace,y=this.state.generation,N={key:y,ref:function(S){p.editingArea=S}};return a.default.Children.count(j)?a.default.cloneElement(a.default.Children.only(j),N):g?a.default.createElement("pre",s({},N)):a.default.createElement("div",s({},N))},m.prototype.render=function(){var p;return a.default.createElement("div",{id:this.props.id,style:this.props.style,key:this.state.generation,className:"quill "+(p=this.props.className,p??""),onKeyPress:this.props.onKeyPress,onKeyDown:this.props.onKeyDown,onKeyUp:this.props.onKeyUp},this.renderEditingArea())},m.prototype.onEditorChangeText=function(p,u,j,g){var y,N;if(this.editor){var S=this.isDelta(this.value)?g.getContents():g.getHTML();S!==this.getEditorContents()&&(this.lastDeltaChangeSet=u,this.value=S,(N=(y=this.props).onChange)===null||N===void 0||N.call(y,p,u,j,g))}},m.prototype.onEditorChangeSelection=function(p,u,j){var g,y,N,S,C,w;if(this.editor){var R=this.getEditorSelection(),P=!R&&p,A=R&&!p;c.default(p,R)||(this.selection=p,(y=(g=this.props).onChangeSelection)===null||y===void 0||y.call(g,p,u,j),P?(S=(N=this.props).onFocus)===null||S===void 0||S.call(N,p,u,j):A&&((w=(C=this.props).onBlur)===null||w===void 0||w.call(C,R,u,j)))}},m.prototype.focus=function(){this.editor&&this.editor.focus()},m.prototype.blur=function(){this.editor&&(this.selection=null,this.editor.blur())},m.displayName="React Quill",m.Quill=d.default,m.defaultProps={theme:"snow",modules:{},readOnly:!1},m})(a.default.Component);function x(f){Promise.resolve().then(f)}return Ha=h,Ha}var LU=IU();const MU=_m(LU),FU={toolbar:[[{header:[1,2,3,!1]}],["bold","italic","underline"],[{list:"ordered"},{list:"bullet"}],["link"],["blockquote"],["clean"]]},BU=["header","bold","italic","underline","list","bullet","link","blockquote"];function lm(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 nD=v.forwardRef(({value:t,onChange:s,tab:n,onTabChange:r,textareaRef:a},l)=>{const c=v.useRef(null),d=v.useMemo(()=>lm(t),[t]);return v.useImperativeHandle(l,()=>({insertPlaceholder:h=>{var u,j;const x=`{{${h}}}`;if(n==="html"&&a.current){const g=a.current,y=g.selectionStart??0,N=g.selectionEnd??0,S=t.slice(0,y)+x+t.slice(N);s(S),requestAnimationFrame(()=>{g.focus();const C=y+x.length;g.setSelectionRange(C,C)});return}const f=(j=(u=c.current)==null?void 0:u.getEditor)==null?void 0:j.call(u);if(!f)return;const m=f.getSelection(!0),p=(m==null?void 0:m.index)??f.getLength();f.insertText(p,x,"user")}})),e.jsx("div",{className:"flex flex-col gap-2 flex-1 min-h-0",children:e.jsxs(Pn,{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(mi,{className:"border-amber-200 bg-amber-50 py-2",children:[e.jsx(Xa,{className:"h-4 w-4 text-amber-700"}),e.jsxs(fi,{className:"text-[11px] text-amber-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(Gt,{value:"visual",className:"flex-1 flex flex-col gap-2 mt-2 min-h-[420px] data-[state=inactive]:hidden",children:[e.jsx("div",{className:Pt("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(MU,{ref:c,theme:"snow",value:t||"",onChange:s,modules:FU,formats:BU})}),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(Gt,{value:"html",className:"flex-1 flex flex-col mt-2 min-h-[420px] data-[state=inactive]:hidden",children:[e.jsx(Fs,{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:h=>s(h.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."]})]})]})})});nD.displayName="EmailTemplateBodyEditor";function $U(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 qU=/\{\{\s*>\s*email_header\s*\}\}/i,zU=/\{\{\s*>\s*email_footer\s*\}\}/i,UU=/\{\{\s*>\s*primary_cta\s*\}\}/i,VU=/^[\s\r\n]*(?:<(?:p|div)[^>]*>)?\s*\{\{\s*>\s*email_header\s*\}\}\s*(?:<\/(?:p|div)>)?[\s\r\n]*/i,HU=/[\s\r\n]*(?:<(?:p|div)[^>]*>)?\s*\{\{\s*>\s*email_footer\s*\}\}\s*(?:<\/(?:p|div)>)?[\s\r\n]*$/i,WU=/(?:<(?:p|div)[^>]*>)?\s*\{\{\s*>\s*primary_cta\s*\}\}\s*(?:<\/(?:p|div)>)?/gi;function GU(t){const s=t||"",n=$U(s);if(!qU.test(n)||!zU.test(n))return{isShellTemplate:!1,editableHtml:s,includesCta:!1};const r=UU.test(n);let a=n.replace(VU,"").replace(HU,"").replace(WU,"");return a=a.trim(),{isShellTemplate:!0,editableHtml:a,includesCta:r}}function KU(t,s){return`{{> email_header}}
${(t||"").trim()}${s?`
{{> primary_cta}}
`:`
`}{{> email_footer}}`}const YU=({isOpen:t,onOpenChange:s,editingTemplate:n,setEditingTemplate:r,testDataInput:a,setTestDataInput:l,previewLoading:c,handlePreviewTemplate:d,previewContent:h,handleSaveTemplate:x})=>{var $;const f=gt.useRef(null),m=gt.useRef(null),[p,u]=gt.useState("visual"),[j,g]=gt.useState(""),[y,N]=gt.useState(!1),[S,C]=gt.useState(!1);gt.useEffect(()=>{if(!t||!n)return;const T=GU(n.body||"");N(T.isShellTemplate),C(T.includesCta);const E=T.isShellTemplate?T.editableHtml:n.body||"";g(E);const _=lm(E);u(_?"html":"visual")},[t,n==null?void 0:n.id,n==null?void 0:n.body]);const w=gt.useCallback(()=>y?KU(j,S):(n==null?void 0:n.body)||"",[y,j,S,n==null?void 0:n.body]),R=T=>{var E;(E=m.current)==null||E.insertPlaceholder(T)},P=(n==null?void 0:n.placeholders)||[],A=y?j:(n==null?void 0:n.body)||"",I=T=>{y?(g(T),lm(T)&&u("html")):(r({...n,body:T}),lm(T)&&u("html"))};return e.jsx(os,{open:t,onOpenChange:s,children:e.jsxs(ls,{className:"sm:max-w-7xl w-full max-h-[95vh] overflow-y-auto",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Edit Email Template"}),e.jsx(vs,{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(Sc,{className:"w-4 h-4 text-amber-600"}),"General Settings"]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-xs uppercase tracking-wider text-slate-500",children:"Template Name"}),e.jsx(ot,{placeholder:"e.g., Application Received",className:"mt-1.5 bg-white",value:(n==null?void 0:n.name)||"",onChange:T=>r({...n,name:T.target.value})})]}),e.jsxs("div",{children:[e.jsx(ce,{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(Ae,{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(ce,{className:"text-xs uppercase tracking-wider text-slate-500",children:"Description"}),e.jsx(ot,{placeholder:"Brief purpose of this email",className:"mt-1.5 bg-white",value:(n==null?void 0:n.description)||"",onChange:T=>r({...n,description:T.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(Ef,{id:"active",checked:(n==null?void 0:n.isActive)??!0,onCheckedChange:T=>r({...n,isActive:T})}),e.jsx(ce,{htmlFor:"active",className:"text-sm cursor-pointer",children:"Active"})]}),e.jsx(Ae,{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-amber-50 p-4 rounded-lg border border-amber-100",children:[e.jsxs("h3",{className:"text-sm font-semibold text-amber-900 flex items-center gap-2 mb-3",children:[e.jsx(Xa,{className:"w-4 h-4"}),"Available Placeholders"]}),e.jsx("p",{className:"text-[10px] text-amber-700 mb-4 leading-relaxed",children:"Click a placeholder to insert it at the cursor."}),e.jsx("div",{className:"flex flex-wrap gap-2",children:P.length>0?P.map(T=>e.jsx("button",{type:"button",onClick:()=>R(T),className:"px-2 py-1 bg-white border border-amber-200 rounded text-[11px] font-mono text-amber-800 hover:bg-amber-600 hover:text-white hover:border-amber-600 transition-all flex items-center gap-1 shadow-sm",children:`{{${T}}}`},T)):e.jsx("div",{className:"w-full py-4 text-center border-2 border-dashed border-amber-200 rounded-lg",children:e.jsx("p",{className:"text-[10px] text-amber-600",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(ur,{className:"w-4 h-4 text-amber-600"}),"Template Designer"]})}),e.jsxs("div",{className:"flex-1 flex flex-col space-y-4",children:[e.jsxs("div",{children:[e.jsx(ce,{className:"text-xs font-semibold",children:"Subject Line"}),e.jsx(ot,{placeholder:"Subject line with {{variables}}",className:"mt-1.5 text-slate-900 font-medium",value:(n==null?void 0:n.subject)||"",onChange:T=>r({...n,subject:T.target.value})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-[480px]",children:[e.jsx(ce,{className:"text-xs font-semibold mb-1.5",children:"Email Body"}),e.jsx(nD,{ref:m,tab:p,onTabChange:T=>u(T),textareaRef:f,value:A,onChange:I})]})]})]}),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(Ax,{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(ce,{className:"text-xs font-semibold",children:"Mock Test Data (JSON)"}),e.jsx("button",{type:"button",onClick:()=>l('{"applicantName": "Rajesh Kumar", "location": "Mumbai South", "applicationId": "APP-2026-X12", "link": "https://example.com/app", "portalLink": "https://example.com/app"}'),className:"text-[10px] text-amber-600 hover:underline",children:"Reset to Sample"})]}),e.jsx(Fs,{placeholder:'{"applicant_name": "John Doe"}',className:"font-mono text-[11px] text-slate-900 bg-slate-50",rows:6,value:a,onChange:T=>l(T.target.value)})]}),e.jsxs(se,{variant:"default",type:"button",className:"w-full bg-green-600 hover:bg-green-700 shadow-md",onClick:()=>d(w()),disabled:c,children:[c?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Ax,{className:"w-4 h-4 mr-2"}),"Generate Mock Preview"]})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsx(ce,{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:h?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:"})," ",h.subject]}),e.jsxs(Ae,{variant:"outline",className:"bg-green-50 text-green-600 text-[9px] whitespace-nowrap ml-2",children:[e.jsx(Fn,{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:h.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(Ax,{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-amber-600 hover:bg-amber-700",type:"button",onClick:()=>x(w()),disabled:!(n!=null&&n.id)||!(($=n==null?void 0:n.templateCode)!=null&&$.trim()),children:"Save Template"})]})]})})},ZU=({isOpen:t,onOpenChange:s,editingLocationId:n,locationState:r,setLocationState:a,locationDistrict:l,setLocationDistrict:c,locationCity:d,setLocationCity:h,locationActiveFrom:x,setLocationActiveFrom:f,locationActiveTo:m,setLocationActiveTo:p,locationStatus:u,setLocationStatus:j,allStates:g,allDistricts:y,onSave:N})=>{const S=gt.useMemo(()=>r?(y||[]).filter(C=>C.stateId===r):[],[y,r]);return e.jsx(os,{open:t,onOpenChange:s,children:e.jsxs(ls,{children:[e.jsxs(ms,{children:[e.jsx(us,{children:n?"Edit Location":"Add Location"}),e.jsx(vs,{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(ce,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"State"}),e.jsxs(wt,{value:r,onValueChange:C=>{a(C),c("")},children:[e.jsx(Ct,{className:"mt-2 text-slate-900 border-slate-200 focus:ring-amber-500/30 focus:border-amber-500",children:e.jsx(St,{placeholder:"Select state"})}),e.jsx(At,{children:(g||[]).map(C=>e.jsx(Pe,{value:C.id,children:C.name||C.stateName},C.id))})]})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"City"}),e.jsx(ot,{placeholder:"Enter city name",className:"mt-2 text-slate-900 border-slate-200 focus-visible:ring-amber-500/30 focus-visible:border-amber-500",value:d,onChange:C=>h(C.target.value)})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"District"}),e.jsxs(wt,{value:l,onValueChange:c,disabled:!r,children:[e.jsx(Ct,{className:"mt-2 text-slate-900 border-slate-200 focus:ring-amber-500/30 focus:border-amber-500",children:e.jsx(St,{placeholder:r?"Select district":"Select state first"})}),e.jsx(At,{children:S.map(C=>e.jsx(Pe,{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(ce,{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(ce,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"Start Date"}),e.jsx(ot,{type:"date",className:"mt-2 text-slate-900 border-slate-200 focus-visible:ring-blue-500/30 focus-visible:border-blue-500",value:x,onChange:C=>f(C.target.value)})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"End Date"}),e.jsx(ot,{type:"date",className:"mt-2 text-slate-900 border-slate-200 focus-visible:ring-blue-500/30 focus-visible:border-blue-500",value:m,onChange:C=>p(C.target.value)})]})]})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"Opportunity"}),e.jsxs(wt,{value:u,onValueChange:j,children:[e.jsx(Ct,{className:"mt-2 text-slate-900 border-slate-200 focus:ring-amber-500/30 focus:border-amber-500",children:e.jsx(St,{placeholder:"Is this an active Opportunity?"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"active",children:"Yes"}),e.jsx(Pe,{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-amber-600 hover:bg-amber-700 text-white shadow-md hover:shadow-lg transition-all",onClick:N,children:"Save Location"})]})]})]})})},QU=()=>{const[t,s]=v.useState([]),[n,r]=v.useState(!0),[a,l]=v.useState(null),c=async()=>{try{r(!0);const x=await Ss.getSystemConfigs({category:"SECURITY_DEPOSIT"});x.success&&s(x.data)}catch(x){console.error("Fetch error:",x),ee.error("Failed to load deposit configurations")}finally{r(!1)}};v.useEffect(()=>{c()},[]);const d=(x,f)=>{s(m=>m.map(p=>p.id===x?{...p,value:{...p.value,amount:parseInt(f)||0}}:p))},h=async x=>{try{l(x.id),(await Ss.saveSystemConfig(x)).success&&ee.success(`Configuration for ${x.key} updated successfully`)}catch{ee.error("Failed to save configuration")}finally{l(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-amber-600 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(tt,{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-amber-100 flex items-center justify-center",children:e.jsx(Sc,{className:"w-5 h-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(nt,{className:"text-lg font-bold text-slate-900",children:"Global Payment Settings"}),e.jsx(Zt,{className:"text-xs",children:"Configure base security deposit amounts for onboarding workflows."})]})]})}),e.jsxs(Me,{className:"p-4",children:[e.jsx("div",{className:"grid gap-3",children:t.map(x=>{var f;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:[x.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:x.description})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(ce,{htmlFor:`amount-${x.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(oa,{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(ot,{id:`amount-${x.id}`,type:"number",className:"pl-8 h-9 text-base font-bold bg-slate-50/50 border-slate-200 focus:ring-amber-500 focus:border-amber-500 rounded-lg",value:((f=x.value)==null?void 0:f.amount)||"",onChange:m=>d(x.id,m.target.value)})]})]}),e.jsx("div",{className:"pt-4",children:e.jsx(se,{onClick:()=>h(x),disabled:a===x.id,className:"h-9 px-4 bg-amber-600 hover:bg-amber-700 text-white rounded-lg shadow-md shadow-amber-600/10 active:scale-95 transition-all flex items-center gap-1.5 group",children:a===x.id?e.jsx(Rr,{className:"w-4 h-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Yi,{className:"w-4 h-4 group-hover:scale-110 transition-transform"}),e.jsx("span",{className:"font-bold text-sm",children:"Update"})]})})})]})]},x.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(Sc,{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:c,children:[e.jsx(Rr,{className:"w-3.5 h-3.5 mr-1.5"})," Reload"]})]})]})]}),e.jsxs("div",{className:"bg-amber-50/50 rounded-xl p-4 border border-amber-100/50 flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-100 flex items-center justify-center flex-shrink-0",children:e.jsx(Sc,{className:"w-4 h-4 text-amber-700"})}),e.jsxs("div",{children:[e.jsx("h5",{className:"font-bold text-amber-900 text-sm",children:"Super Admin Notice"}),e.jsx("p",{className:"text-[11px] text-amber-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."})]})]})]})},XU=()=>{const[t,s]=v.useState([]),[n,r]=v.useState(!0),[a,l]=v.useState(!1),[c,d]=v.useState(!1),[h,x]=v.useState(null),[f,m]=v.useState([]),[p,u]=v.useState({}),[j,g]=v.useState(!0),[y,N]=v.useState(""),[S,C]=v.useState(1),[w]=v.useState(10),[R,P]=v.useState(""),[A,I]=v.useState({total:0,pages:1}),$=v.useRef(!0),[T,E]=v.useState({documentType:"",stageCode:"General",allowedRoles:[],isMandatory:!1,isActive:!0,module:""}),_=["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"];v.useEffect(()=>{(async()=>{var B;try{const D=await ds.getDocumentConfigMetadata();D&&(m(D.modules||[]),u(D.stages||{}),((B=D.modules)==null?void 0:B.length)>0&&(P(D.modules[0]),E(O=>({...O,module:D.modules[0]}))))}catch{ee.error("Failed to load system metadata")}finally{g(!1)}})()},[]);const M=v.useCallback(async()=>{if(R){$.current?r(!0):l(!0);try{const F=await ds.getDocumentConfigs({search:y,page:S,limit:w,module:R,isAdminView:!0});F&&F.pagination?(s(F.data||[]),I(F.pagination)):Array.isArray(F)&&(s(F),I({total:F.length,pages:1}))}catch(F){console.error("Fetch Configs Error:",F),$.current||ee.error("Failed to sync configuration database")}finally{r(!1),l(!1),$.current=!1}}},[y,S,w,R]);v.useEffect(()=>{const F=setTimeout(()=>{M()},300);return()=>clearTimeout(F)},[M]);const q=async()=>{try{h?(await ds.updateDocumentConfig(h.id,T),ee.success("Configuration updated")):(await ds.createDocumentConfig(T),ee.success("Configuration created")),d(!1),M()}catch{ee.error("Failed to save configuration")}},G=async F=>{if(window.confirm("Are you sure you want to delete this configuration?"))try{await ds.deleteDocumentConfig(F),ee.success("Configuration deleted"),M()}catch{ee.error("Failed to delete configuration")}},Z=()=>{x(null),E({documentType:"",stageCode:"General",allowedRoles:[],isMandatory:!1,isActive:!0,module:R}),d(!0)},W=F=>{x(F),E({documentType:F.documentType,stageCode:F.stageCode,allowedRoles:F.allowedRoles||[],isMandatory:F.isMandatory,isActive:F.isActive,module:F.module||"ONBOARDING"}),d(!0)},z=F=>{E(B=>({...B,allowedRoles:B.allowedRoles.includes(F)?B.allowedRoles.filter(D=>D!==F):[...B.allowedRoles,F]}))};return j?e.jsxs("div",{className:"h-96 flex flex-col items-center justify-center gap-4",children:[e.jsx(ev,{className:"w-10 h-10 text-amber-600 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(tt,{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-amber-100 overflow-hidden",children:[e.jsx("div",{className:"h-full bg-amber-600 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-amber-600",children:e.jsx(rI,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx(nt,{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(cn,{className:"w-4 h-4"})," Add Policy"]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-64",children:e.jsxs(wt,{value:R,onValueChange:F=>{P(F),C(1)},children:[e.jsx(Ct,{className:"h-10 rounded-xl bg-white border-slate-200 focus:ring-amber-500 font-bold text-slate-700 shadow-sm",children:e.jsx(St,{placeholder:"Target Module"})}),e.jsx(At,{className:"rounded-xl shadow-2xl border-none",children:f.map(F=>e.jsx(Pe,{value:F,className:"font-bold text-xs py-2.5 uppercase",children:F.replace(/_/g," ")},F))})]})}),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ra,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(ot,{placeholder:"Search policies, stages or documents...",value:y,onChange:F=>{N(F.target.value),C(1)},className:"pl-10 h-10 rounded-xl bg-white border-slate-200 focus:ring-amber-500 shadow-sm font-medium"})]})]})]}),e.jsxs(Me,{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(ss,{className:"w-8 h-8 text-amber-600 animate-spin"}),e.jsx("span",{className:"text-slate-500 text-sm font-bold animate-pulse",children:"Syncing Policies..."})]}):null,e.jsxs(ks,{children:[e.jsx(Rs,{className:"bg-slate-50/50",children:e.jsxs(ct,{className:"border-none",children:[e.jsx(me,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Policy Detail"}),e.jsx(me,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Process Stage"}),e.jsx(me,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Module"}),e.jsx(me,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Stakeholders"}),e.jsx(me,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Compliance Rules"}),e.jsx(me,{className:"text-right font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Action"})]})}),e.jsx(Es,{children:!n&&t.length===0?e.jsx(ct,{children:e.jsx(de,{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(Ra,{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(F=>{var B,D;return e.jsxs(ct,{className:"hover:bg-slate-50/80 transition-colors group h-14",children:[e.jsx(de,{children:e.jsx("div",{className:"font-bold text-slate-900 group-hover:text-amber-700 transition-colors uppercase text-[12px]",children:F.documentType})}),e.jsx(de,{children:e.jsx(Ae,{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:F.stageCode})}),e.jsx(de,{children:e.jsx("div",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-tighter",children:(B=F.module)==null?void 0:B.replace(/_/g," ")})}),e.jsx(de,{children:e.jsx("div",{className:"flex flex-wrap gap-1 max-w-[200px]",children:((D=F.allowedRoles)==null?void 0:D.length)>0?e.jsxs(e.Fragment,{children:[F.allowedRoles.slice(0,2).map(O=>e.jsx(Ae,{variant:"secondary",className:"bg-white text-slate-600 text-[9px] border-slate-200 font-bold uppercase",children:O},O)),F.allowedRoles.length>2&&e.jsxs(Ae,{variant:"outline",className:"text-[9px] text-slate-400 font-bold border-dashed",children:["+",F.allowedRoles.length-2]})]}):e.jsx(Ae,{variant:"secondary",className:"bg-slate-50 text-slate-400 text-[9px] border-slate-100 uppercase",children:"Inherited"})})}),e.jsx(de,{children:e.jsxs("div",{className:"flex gap-2",children:[F.isMandatory&&e.jsx(Ae,{className:"bg-red-600 text-white border-transparent text-[10px] font-bold h-5 px-1.5 rounded-sm uppercase tracking-tighter",children:"BLOCKING"}),!F.isActive&&e.jsx(Ae,{className:"bg-slate-200 text-slate-500 border-transparent text-[10px] h-5 px-1.5 rounded-sm uppercase tracking-tighter",children:"DORMANT"}),F.isActive&&!F.isMandatory&&e.jsx(Ae,{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(de,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(se,{variant:"ghost",size:"icon",onClick:()=>W(F),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(ur,{className:"w-4 h-4"})}),e.jsx(se,{variant:"ghost",size:"icon",onClick:()=>G(F.id),className:"h-8 w-8 text-slate-400 hover:text-red-600 hover:bg-red-50 rounded-lg transition-transform active:scale-90",children:e.jsx(Gn,{className:"w-4 h-4"})})]})})]},F.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?(S-1)*w+1:0," - ",Math.min(S*w,A.total)]})," Total Found ",e.jsx("span",{className:"text-amber-700 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:S===1,onClick:()=>{C(F=>Math.max(1,F-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(qc,{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-amber-600",children:S})," ",e.jsx("span",{className:"mx-2 text-slate-300",children:"/"})," ",A.pages]}),e.jsxs(se,{variant:"outline",size:"sm",disabled:S>=A.pages,onClick:()=>{C(F=>Math.min(A.pages,F+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(el,{className:"w-4 h-4 ml-1 text-slate-600"})]})]})]})]}),e.jsx(os,{open:c,onOpenChange:d,children:e.jsxs(ls,{className:"max-w-2xl rounded-2xl border-none shadow-2xl p-0 overflow-hidden ring-1 ring-black/5",children:[e.jsx(ms,{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(Zm,{className:"w-7 h-7 text-amber-400"})}),e.jsxs("div",{children:[e.jsx(us,{className:"text-2xl font-black tracking-tight uppercase",children:h?"Modify Policy":"Publish Rule"}),e.jsxs("p",{className:"text-xs text-slate-400 font-bold tracking-widest uppercase mt-1",children:["Configuring ",T.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(ce,{className:"text-slate-900 font-black px-1 text-[11px] uppercase tracking-wider",children:"Process Stream"}),e.jsxs(wt,{value:T.module,onValueChange:F=>E(B=>({...B,module:F,stageCode:"General"})),children:[e.jsx(Ct,{className:"h-12 rounded-xl border-slate-200 focus:ring-amber-500 shadow-sm bg-slate-50 font-black text-xs uppercase",children:e.jsx(St,{placeholder:"Module"})}),e.jsx(At,{className:"rounded-xl border-none shadow-2xl",children:f.map(F=>e.jsx(Pe,{value:F,className:"py-3 px-4 rounded-lg focus:bg-amber-50 font-black text-[10px] uppercase",children:F.replace(/_/g," ")},F))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{className:"text-slate-900 font-black px-1 text-[11px] uppercase tracking-wider",children:"Milestone Stage"}),e.jsxs(wt,{value:T.stageCode,onValueChange:F=>E(B=>({...B,stageCode:F})),children:[e.jsx(Ct,{className:"h-12 rounded-xl border-slate-200 focus:ring-amber-500 shadow-sm bg-white font-black text-xs uppercase",children:e.jsx(St,{placeholder:"Select Stage"})}),e.jsx(At,{className:"rounded-xl border-none shadow-2xl",children:(p[T.module]||["General"]).map(F=>e.jsx(Pe,{value:F,className:"py-3 px-4 rounded-lg focus:bg-amber-50 font-black text-[10px] uppercase",children:F},F))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{className:"text-slate-900 font-black px-1 text-[11px] uppercase tracking-wider",children:"Document Label Identifier"}),e.jsx(ot,{value:T.documentType,onChange:F=>E(B=>({...B,documentType:F.target.value})),placeholder:"e.g., PAN Card, Blueprint",className:"h-12 rounded-xl border-slate-200 focus:ring-amber-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(ce,{className:"text-slate-900 font-black flex items-center gap-2 mb-2 text-[11px] uppercase tracking-wider",children:[e.jsx(Fl,{className:"w-4 h-4 text-amber-600"})," Visibility Matrix"]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:_.map(F=>e.jsxs("div",{className:`flex items-center space-x-2 p-3 rounded-xl border transition-all cursor-pointer group active:scale-95 ${T.allowedRoles.includes(F)?"bg-amber-50 border-amber-300 shadow-sm":"bg-white border-slate-200 hover:border-amber-200 hover:shadow-sm"}`,onClick:()=>z(F),children:[e.jsx(Rn,{id:`role-${F}`,checked:T.allowedRoles.includes(F),onCheckedChange:()=>z(F),className:"w-4 h-4 data-[state=checked]:bg-amber-600 data-[state=checked]:border-amber-600 rounded"}),e.jsx(ce,{htmlFor:`role-${F}`,className:`text-[10px] font-black cursor-pointer uppercase truncate ${T.allowedRoles.includes(F)?"text-amber-800":"text-slate-500 group-hover:text-amber-700"}`,children:F})]},F))})]}),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 ${T.isMandatory?"bg-red-50 border-red-200 shadow-sm":"bg-slate-50 border-slate-100 hover:bg-red-50/30"}`,onClick:()=>E(F=>({...F,isMandatory:!F.isMandatory})),children:[e.jsx(Rn,{id:"mandatory",checked:T.isMandatory,onCheckedChange:F=>E(B=>({...B,isMandatory:!!F})),className:"w-5 h-5 border-slate-300 data-[state=checked]:bg-red-600 data-[state=checked]:border-red-600 rounded-md"}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ce,{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 ${T.isActive?"bg-emerald-50 border-emerald-200 shadow-sm":"bg-slate-50 border-slate-100 hover:bg-emerald-50/30"}`,onClick:()=>E(F=>({...F,isActive:!F.isActive})),children:[e.jsx(Rn,{id:"active",checked:T.isActive,onCheckedChange:F=>E(B=>({...B,isActive:!!F})),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(ce,{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(rn,{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:q,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:h?"Update Policy Database":"Publish New Policy"})]})]})})]})},JU=()=>{const[t,s]=v.useState([]),[n,r]=v.useState(!0),a=async()=>{r(!0);try{const h=await Ss.getSystemConfigs({category:"ASSIGNMENT"});h.success&&s(h.data)}catch{ee.error("Failed to load assignment configurations")}finally{r(!1)}};v.useEffect(()=>{a()},[]);const l=(h,x)=>{s(f=>f.map(m=>m.key===h?{...m,value:{...m.value,enabled:x}}:m))},c=async h=>{try{(await Ss.saveSystemConfig({key:h.key,value:h.value,category:h.category,description:h.description})).success&&ee.success(`${h.key.replace("AUTO_ASSIGN_","")} setting updated`)}catch{ee.error("Failed to save configuration")}},d=[{key:"AUTO_ASSIGN_ONBOARDING",label:"Onboarding",icon:Fo,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_RELOCATION",label:"Relocation",icon:pI,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_TERMINATION",label:"Termination",icon:J5,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_CONSTITUTIONAL",label:"Constitutional",icon:tI,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_RESIGNATION",label:"Resignation",icon:fs,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_FNF",label:"F&F Settlement",icon:G5,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(Ki,{className:"w-8 h-8 animate-spin text-amber-600"}),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(tt,{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-amber-500/20 rounded-lg",children:e.jsx(Zm,{className:"w-6 h-6 text-amber-400"})}),e.jsxs("div",{children:[e.jsx(nt,{className:"text-xl font-bold",children:"Auto-Assignment Governance"}),e.jsx(Zt,{className:"text-slate-300",children:"Control the automated mapping of participants across different business modules"})]})]})}),e.jsxs(Me,{className:"p-6",children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:d.map(h=>{var m;const x=t.find(p=>p.key===h.key),f=((m=x==null?void 0:x.value)==null?void 0:m.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:Pt("w-12 h-12 flex items-center justify-center rounded-full transition-colors",h.bg,h.color),children:e.jsx(h.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:h.label}),e.jsx(Cf,{children:e.jsxs(Ub,{children:[e.jsx(Vb,{children:e.jsx(Xa,{className:"w-3.5 h-3.5 text-slate-400"})}),e.jsx(Hb,{className:"max-w-xs",children:e.jsxs("p",{children:["When OFF, all participants for new ",h.label," requests must be assigned manually by authorized administrators."]})})]})})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(Ae,{variant:f?"default":"secondary",className:f?"bg-emerald-50 text-emerald-700 border-emerald-200 hover:bg-emerald-100":"bg-slate-50 text-slate-500 border-slate-200",children:f?"Auto-Assign ON":"Manual Mode"})})]})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsx(Ef,{checked:f,onCheckedChange:p=>{l(h.key,p);const u=t.find(j=>j.key===h.key);u&&c({...u,value:{enabled:p}})}})})]},h.key)})}),e.jsxs("div",{className:"mt-8 p-4 bg-amber-50 border border-amber-100 rounded-lg flex items-start gap-3",children:[e.jsx(Xa,{className:"w-5 h-5 text-amber-600 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-amber-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.'})]})]})]})]})})},Gs={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"},sC={ONBOARDING:{General:Gs.DD_ADMIN,KYC:Gs.DD_ADMIN,"Level 1 Interview":Gs.RBM,"Level 2 Interview":Gs.ZBH,"Level 3 Interview":Gs.NBH,FDD:Gs.FDD,"LOI Approval":`${Gs.DD_HEAD},${Gs.NBH}`,"LOA Approval":Gs.NBH,"LOI Issue":Gs.DD_ADMIN,"Architecture Team Assigned":Gs.ARCHITECTURE,"Architecture Document Upload":Gs.ARCHITECTURE,"Architecture Team Completion":Gs.ARCHITECTURE,EOR:Gs.DD_ADMIN,Inauguration:Gs.DD_ADMIN},RESIGNATION:{Submission:Gs.DEALER,"Regional Review":Gs.RBM,"ZM Review":Gs.DD_ZM,"ZBH Review":Gs.ZBH,"Finance Review":Gs.FINANCE,"DDL Review":Gs.DD_LEAD,Approved:Gs.DD_HEAD},RELOCATION:{Initiated:Gs.DEALER,"ASM Review":Gs.ASM,"ZM Review":Gs.DD_ZM,"ZBH Review":Gs.ZBH,Completed:Gs.DD_HEAD},CONSTITUTIONAL_CHANGE:{Draft:Gs.DEALER,"Legal Review":Gs.LEGAL_ADMIN,Approved:Gs.DD_HEAD},TERMINATION:{Hearing:Gs.NBH,Review:Gs.DD_LEAD,Closed:Gs.DD_HEAD}},nC={async getPolicies(){var t,s;try{return(await Te.getApprovalPolicies()).data}catch(n){return ee.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 l=await Te.upsertApprovalPolicy(t,s);return(n=l==null?void 0:l.data)!=null&&n.success&&ee.success("Approval policy updated"),l.data}catch(l){return ee.error(((a=(r=l==null?void 0:l.response)==null?void 0:r.data)==null?void 0:a.message)||"Failed to update approval policy"),{success:!1}}}},eV=Object.values(Gs).sort(),tV=[{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 rD(){const[t,s]=v.useState(!1),[n,r]=v.useState([]),[a,l]=v.useState(!1),[c,d]=v.useState(!1),[h,x]=v.useState(!1),[f,m]=v.useState({stageCode:"",minApprovals:1,approvalMode:"MIN_N",requiredRoles:[],isActive:!0}),p=v.useMemo(()=>[...n].sort((N,S)=>N.stageCode.localeCompare(S.stageCode)),[n]),u=async()=>{s(!0);try{const N=await nC.getPolicies();N!=null&&N.success&&r(N.data||[])}finally{s(!1)}};v.useEffect(()=>{u()},[]);const j=()=>{d(!1),x(!1),m({stageCode:"",minApprovals:1,approvalMode:"MIN_N",requiredRoles:[],isActive:!0}),l(!0)},g=N=>{d(!0),x(!0),m({stageCode:N.stageCode,minApprovals:N.minApprovals||1,approvalMode:N.approvalMode||"MIN_N",requiredRoles:Array.isArray(N.requiredRoles)?[...N.requiredRoles]:[],isActive:N.isActive!==!1}),l(!0)},y=async()=>{if(!f.stageCode.trim())return;if(f.approvalMode==="ROLE_MANDATORY"&&f.requiredRoles.length>0&&f.minApprovals>f.requiredRoles.length){alert("In ROLE_MANDATORY mode, min approvals cannot exceed the number of required roles.");return}const N={minApprovals:Number(f.minApprovals)||1,approvalMode:f.approvalMode,requiredRoles:f.requiredRoles,isActive:f.isActive},S=f.stageCode.trim().toUpperCase().replace(/\s+/g,"_"),C=await nC.savePolicy(S,N);C!=null&&C.success&&(await u(),l(!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(Zm,{className:"w-6 h-6 text-amber-600"}),"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(Rr,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"Refresh"]}),e.jsxs(se,{className:"bg-amber-600 hover:bg-amber-700",onClick:j,children:[e.jsx(cn,{className:"w-4 h-4 mr-2"}),"Add New Policy"]})]})]}),e.jsxs(Le,{className:"border-slate-200 overflow-hidden shadow-sm",children:[e.jsx(tt,{className:"bg-slate-50 px-6 py-4 border-b",children:e.jsx(nt,{className:"text-lg font-semibold text-slate-800",children:"Configured Stages"})}),e.jsx(Me,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ks,{children:[e.jsx(Rs,{className:"bg-slate-50/50",children:e.jsxs(ct,{children:[e.jsx(me,{className:"w-[200px]",children:"Stage Code"}),e.jsx(me,{children:"Approval Mode"}),e.jsx(me,{children:"Min Appr."}),e.jsx(me,{className:"min-w-[300px]",children:"Required Roles"}),e.jsx(me,{children:"Status"}),e.jsx(me,{className:"text-right",children:"Actions"})]})}),e.jsx(Es,{children:p.map(N=>e.jsxs(ct,{className:"hover:bg-slate-50/50 transition-colors",children:[e.jsx(de,{className:"font-mono text-xs font-semibold text-slate-700",children:N.stageCode}),e.jsx(de,{children:e.jsx(Ae,{variant:"outline",className:"font-medium px-2 py-0.5 text-slate-600 border-slate-300 uppercase",children:N.approvalMode})}),e.jsx(de,{children:e.jsx("span",{className:"font-medium text-slate-700 bg-slate-100 px-2.5 py-1 rounded-full text-xs",children:N.minApprovals})}),e.jsx(de,{children:e.jsx("div",{className:"flex flex-wrap gap-1.5 py-1",children:(N.requiredRoles||[]).map(S=>e.jsx(Ae,{variant:"secondary",className:"bg-slate-100 text-slate-600 border-transparent hover:bg-slate-200 text-[11px] font-normal",children:S},S))})}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${N.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 ${N.isActive?"text-green-700":"text-slate-500"}`,children:N.isActive?"Active":"Inactive"})]})}),e.jsx(de,{className:"text-right",children:e.jsxs(se,{size:"sm",variant:"ghost",className:"text-amber-600 hover:text-amber-700 hover:bg-amber-50 h-8 px-2",onClick:()=>g(N),children:[e.jsx(ur,{className:"w-4 h-4 mr-1.5"}),"Edit"]})})]},N.stageCode))})]})})})]}),e.jsx(os,{open:a,onOpenChange:l,children:e.jsxs(ls,{className:"sm:max-w-[480px] overflow-visible",children:[e.jsxs(ms,{className:"gap-1 pb-2 border-b",children:[e.jsxs(us,{className:"text-base flex items-center gap-2",children:[c?e.jsx(ur,{className:"w-4 h-4 text-amber-600"}):e.jsx(cn,{className:"w-4 h-4 text-amber-600"}),c?"Edit Policy":"Create New Policy"]}),e.jsx(vs,{className:"text-[11px]",children:c?`Update configuration for stage ${f.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(ce,{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:!h&&!c?e.jsx("div",{className:"space-y-2",children:e.jsxs(wt,{value:f.stageCode,onValueChange:N=>{N==="CUSTOM"?(x(!0),m({...f,stageCode:""})):m({...f,stageCode:N})},children:[e.jsx(Ct,{className:"w-full h-8 text-[11px] font-medium border-slate-200",children:e.jsx(St,{placeholder:"Select a workflow stage..."})}),e.jsxs(At,{className:"max-h-[300px]",children:[tV.map(N=>e.jsxs(Jw,{children:[e.jsx(HB,{className:"text-[10px] uppercase text-slate-400 font-bold bg-slate-50 px-2 py-1",children:N.label}),N.stages.map(S=>e.jsxs(Pe,{value:S.value,className:"text-xs",children:[S.label," ",e.jsxs("span",{className:"text-[10px] text-slate-400 font-mono ml-1",children:["(",S.value,")"]})]},S.value))]},N.label)),e.jsxs(Jw,{children:[e.jsx(aF,{}),e.jsx(Pe,{value:"CUSTOM",className:"text-xs font-semibold text-amber-600 italic",children:"+ Enter Custom Stage Code"})]})]})]})}):e.jsxs("div",{className:"relative",children:[e.jsx(ot,{className:"w-full font-mono text-xs h-8 pr-8",placeholder:"e.g. FNF_SETTLEMENT",disabled:c,value:f.stageCode,onChange:N=>m({...f,stageCode:N.target.value.toUpperCase()})}),!c&&e.jsx(Tc,{className:"w-3 h-3 absolute right-2.5 top-2.5 text-slate-400 cursor-pointer hover:text-slate-600",onClick:()=>{x(!1),m({...f,stageCode:""})}})]})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(ce,{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(wt,{value:f.approvalMode,onValueChange:N=>m({...f,approvalMode:N}),children:[e.jsx(Ct,{className:"w-full h-8 text-[11px] font-medium border-slate-200",children:e.jsx(St,{placeholder:"Select mode"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"ALL",className:"text-xs",children:"ALL (Everyone must approve)"}),e.jsx(Pe,{value:"MIN_N",className:"text-xs",children:"MIN_N (First N approvals count)"}),e.jsx(Pe,{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(ce,{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(ot,{type:"number",min:1,value:f.minApprovals,onChange:N=>m({...f,minApprovals:Number(N.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(ce,{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(xb,{children:[e.jsx(gb,{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(cn,{className:"w-3 h-3 text-amber-600"}),e.jsx("span",{children:"Add Roles..."})]}),e.jsx(Ae,{variant:"secondary",className:"bg-amber-50 text-amber-700 border-transparent text-[9px] px-1 h-4",children:f.requiredRoles.length})]})}),e.jsxs(vb,{className:"w-[280px] max-h-[250px] overflow-y-auto shadow-xl",align:"start",children:[e.jsx(rF,{className:"text-[10px] uppercase tracking-wider text-slate-400 font-bold px-2 py-1 border-b",children:"Available Roles"}),eV.map(N=>e.jsx(nF,{className:"text-xs",checked:f.requiredRoles.includes(N),onCheckedChange:S=>{m(S?{...f,requiredRoles:[...f.requiredRoles,N]}:{...f,requiredRoles:f.requiredRoles.filter(C=>C!==N)})},children:N},N))]})]}),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:[f.requiredRoles.map(N=>e.jsxs(Ae,{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:[N,e.jsx(Tc,{className:"w-2.5 h-2.5 cursor-pointer text-slate-400 hover:text-red-500",onClick:()=>m({...f,requiredRoles:f.requiredRoles.filter(S=>S!==N)})})]},N)),f.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(ce,{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(wt,{value:f.isActive?"active":"inactive",onValueChange:N=>m({...f,isActive:N==="active"}),children:[e.jsx(Ct,{className:"w-24 h-8 text-[11px] font-medium border-slate-200",children:e.jsx(St,{})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"active",className:"text-xs",children:"Active"}),e.jsx(Pe,{value:"inactive",className:"text-xs",children:"Inactive"})]})]})})]})]}),e.jsxs(rn,{className:"gap-2 pt-3 border-t",children:[e.jsx(se,{variant:"outline",size:"sm",className:"text-xs h-8",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(se,{className:"bg-amber-600 hover:bg-amber-700 h-8 text-xs font-semibold",onClick:y,children:[e.jsx(Yi,{className:"w-3 h-3 mr-1.5"}),c?"Save Changes":"Create Policy"]})]})]})})]})}const sV=()=>{const{fetchInitialData:t,fetchAreas:s}=R$(),{asms:n,zonalManagerMappings:r,allStates:a,allDistricts:l,users:c,roles:d,loading:h}=Nn(Xe=>Xe.master),[x,f]=v.useState("hierarchy"),[m,p]=v.useState("all"),[u,j]=v.useState(!1),[g,y]=v.useState(!1),[N,S]=v.useState(!1),[C,w]=v.useState(!1),[R,P]=v.useState(!1),[A,I]=v.useState(null),[$,T]=v.useState(""),[E,_]=v.useState("active"),[M,q]=v.useState(""),[G,Z]=v.useState(""),[W,z]=v.useState([]),[F,B]=v.useState([]),[D,O]=v.useState("DD-AM"),[V,K]=v.useState(!1),[Y,U]=v.useState(null),[X,ne]=v.useState(""),[oe,re]=v.useState("active"),[ge,ve]=v.useState(""),[Se,We]=v.useState([]),[Ce,fe]=v.useState(!1),[Ye,be]=v.useState(null),[_e,ke]=v.useState(!1),[qe,Ve]=v.useState(null),[dt,xt]=v.useState(""),[ye,le]=v.useState(""),[Qe,rt]=v.useState(""),[Kt,Rt]=v.useState("none"),[Re,Qt]=v.useState(null),[qt,ws]=v.useState(""),[_s,ns]=v.useState(""),[Cs,Bs]=v.useState(""),[Ft,ie]=v.useState(""),[Fe,Q]=v.useState([]),[pe,Ne]=v.useState(null),[Ee,it]=v.useState('{"applicant_name": "John Doe"}'),[st,bt]=v.useState(!1),[Ue,Lt]=v.useState(null),[ut,yt]=v.useState(null),[kt,Ie]=v.useState(""),[_t,ht]=v.useState(""),[zt,rs]=v.useState(""),[Yt,Os]=v.useState(""),[Is,zs]=v.useState(""),[en,he]=v.useState("active"),[Ge,at]=v.useState(""),[pt,mt]=v.useState(1),[Bt,Ds]=v.useState("all"),[as,Vs]=v.useState("all");v.useEffect(()=>{t()},[t]),v.useEffect(()=>{if(Ye&&d.length>0){const Xe=d.find($t=>$t.id===Ye.id);Xe&&be(Xe)}},[d,Ye==null?void 0:Ye.id]);const Ls=v.useMemo(()=>{const Xe={};return[...n,...r].forEach($t=>{($t.areasManaged||$t.districts||[]).forEach(Ut=>{const jt=typeof Ut=="string"?Ut:Ut.id;Xe[jt]||(Xe[jt]=[]),Xe[jt].includes($t.name)||Xe[jt].push($t.name)})}),Xe},[n,r]),Ts=v.useCallback((Xe,$t)=>l.filter(Ze=>{var Ut;return((Ut=Ze.stateName)==null?void 0:Ut.toUpperCase())===(Xe==null?void 0:Xe.toUpperCase())&&(!$t||Ze.regionId===$t)}).map(Ze=>({id:Ze.id,name:Ze.name})),[l]),ln=async()=>{var Xe,$t;if(!$){ee.error("Please select a DD-AM user");return}try{const Ze={userId:$,roleCode:D,districts:F,status:E},Ut=await Ss.saveASM(Ze);Ut.success?(ee.success(`DD Area Manager ${A?"updated":"assigned"} successfully`),j(!1),t()):ee.error(Ut.message||"Failed to save ASM")}catch(Ze){const Ut=(($t=(Xe=Ze==null?void 0:Ze.response)==null?void 0:Xe.data)==null?void 0:$t.message)||(Ze==null?void 0:Ze.message)||"Failed to save ASM";ee.error(Ut)}},pn=Xe=>{var $t;I(Xe.id),T(Xe.id),_(Xe.status.toLowerCase()),q(Xe.zoneId),Z(Xe.regionId),z(Xe.stateNames||[]),B((($t=Xe.areasManaged)==null?void 0:$t.map(Ze=>Ze.id))||[]),O("DD-AM"),j(!0)},hn=Xe=>{var $t;U(Xe.id),ne(Xe.id),re((($t=Xe.status)==null?void 0:$t.toLowerCase())==="active"?"active":"inactive"),ve(Xe.zoneId||""),We(Xe.assignedRegionIds||[]),K(!0)},Ws=async()=>{var Xe,$t;if(!X||!ge){ee.error("Manager and Zone are required");return}try{const Ze={userId:X,zoneId:ge,regionIds:Se,status:oe},Ut=await Ss.saveZonalManager(Ze);Ut.success?(ee.success(`Zonal Manager ${Y?"updated":"assigned"} successfully`),K(!1),t()):ee.error(Ut.message||"Failed to save Zonal Manager")}catch(Ze){const Ut=(($t=(Xe=Ze==null?void 0:Ze.response)==null?void 0:Xe.data)==null?void 0:$t.message)||(Ze==null?void 0:Ze.message)||"Failed to save Zonal Manager";ee.error(Ut)}},Qs=async()=>{var Xe,$t;try{const Ze={id:qe,name:dt,code:ye,description:Qe,managerId:Kt==="none"?null:Kt},Ut=await Ss.saveZone(Ze);Ut.success?(ee.success("Zone saved successfully"),y(!1),t()):ee.error(Ut.message||"Error saving zone")}catch(Ze){const Ut=(($t=(Xe=Ze==null?void 0:Ze.response)==null?void 0:Xe.data)==null?void 0:$t.message)||(Ze==null?void 0:Ze.message)||"Error saving zone";ee.error(Ut)}},zn=async()=>{var Xe,$t;try{const Ze={...Re?{id:Re}:{},name:qt,description:_s,parentId:Cs,managerId:Ft,districts:Fe,status:"Active"},Ut=await Ss.saveRegion(Ze);Ut.success?(ee.success("Region saved successfully"),S(!1),t()):ee.error(Ut.message||"Error saving region")}catch(Ze){const Ut=(($t=(Xe=Ze==null?void 0:Ze.response)==null?void 0:Xe.data)==null?void 0:$t.message)||(Ze==null?void 0:Ze.message)||"Error saving region";ee.error(Ut)}},on=async Xe=>{var $t,Ze;try{if(!(pe!=null&&pe.id)){ee.error("Open a template from the list to edit.");return}const Ut=await Ss.updateEmailTemplate(pe.id,{...pe,body:Xe});Ut.success?(ee.success("Template saved"),w(!1),t()):ee.error(Ut.message||"Error saving template")}catch(Ut){const jt=((Ze=($t=Ut==null?void 0:Ut.response)==null?void 0:$t.data)==null?void 0:Ze.message)||(Ut==null?void 0:Ut.message)||"Error saving template";ee.error(jt)}},Un=async Xe=>{var $t;bt(!0);try{let Ze;try{Ze=JSON.parse(Ee)}catch{ee.error("Mock test data must be valid JSON");return}const Ut=await Ss.previewEmailTemplate({subject:pe==null?void 0:pe.subject,body:Xe,data:Ze});Ut.success?Lt(Ut.data):ee.error(Ut.message||"Preview failed")}catch(Ze){const Ut=($t=Ze==null?void 0:Ze.response)==null?void 0:$t.data,jt=(Ut==null?void 0:Ut.error)||(Ut==null?void 0:Ut.message);ee.error(jt||(Ze==null?void 0:Ze.message)||"Preview failed")}finally{bt(!1)}},yr=async(Xe,$t)=>{var Ze,Ut;try{const jt=await Ss.updateRole(Xe,{permissions:$t});jt.success?(ee.success("Role permissions updated successfully"),fe(!1),t()):ee.error(jt.message||"Error saving role permissions")}catch(jt){const In=((Ut=(Ze=jt==null?void 0:jt.response)==null?void 0:Ze.data)==null?void 0:Ut.message)||(jt==null?void 0:jt.message)||"Error saving role permissions";ee.error(In)}},Tr=Xe=>{be(Xe),fe(!0)},er=async Xe=>{var $t,Ze;try{const Ut={...Xe,permissionIds:[]},jt=await Ss.createRole(Ut);if(jt!=null&&jt.success){ee.success("Role created successfully"),t();return}throw new Error((jt==null?void 0:jt.message)||"Failed to create role")}catch(Ut){const jt=((Ze=($t=Ut==null?void 0:Ut.response)==null?void 0:$t.data)==null?void 0:Ze.message)||(Ut==null?void 0:Ut.message)||"Failed to create role";throw ee.error(jt),Ut}},tr=Xe=>{const $t=l.find(Ze=>Ze.id===Xe.districtId);yt(Xe.id),Ie(($t==null?void 0:$t.stateId)||Xe.stateId||""),rs(Xe.city||""),ht(Xe.districtId||""),Os(Xe.openFrom?new Date(Xe.openFrom).toISOString().split("T")[0]:""),zs(Xe.openTo?new Date(Xe.openTo).toISOString().split("T")[0]:""),he(Xe.isOpportunity?"active":"inactive"),P(!0)},En=async()=>{try{if(!kt){ee.error("Please select a state");return}if(!_t){ee.error("Please select a district");return}const Xe=a.find(jt=>jt.id===kt),$t=l.find(jt=>jt.id===_t),Ze={id:ut,stateId:kt,stateName:(Xe==null?void 0:Xe.name)||(Xe==null?void 0:Xe.stateName)||"",districtId:_t,name:zt||($t==null?void 0:$t.name)||"New Location",city:zt,status:en,openFrom:Yt,openTo:Is,isOpportunity:en==="active"};(await(ut?Ss.updateArea(ut,Ze):Ss.createArea(Ze))).success&&(ee.success("Location saved"),P(!1),s({search:Ge,page:pt}))}catch{ee.error("Error saving location")}};return v.useEffect(()=>{const Xe=setTimeout(()=>{s({search:Ge,page:pt,stateId:Bt==="all"?void 0:Bt,isOpportunity:as==="all"?void 0:as==="active"?"true":"false"})},500);return()=>clearTimeout(Xe)},[Ge,pt,Bt,as,s]),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 font-bold text-2xl",children:"Master Configuration"}),e.jsx("p",{className:"text-slate-600",children:"Centralized governance for locations, roles, and operational policies"})]}),e.jsx(Ae,{className:"bg-gradient-to-r from-purple-600 to-indigo-600 px-4 py-1",children:"Admin Control Panel"})]}),h?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-amber-600 border-t-transparent rounded-full animate-spin"}),e.jsx("p",{className:"text-slate-600 font-medium animate-pulse",children:"Synchronizing Global Settings..."})]}):e.jsxs(Pn,{value:x,onValueChange:f,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-amber-600 data-[state=active]:text-white",children:[e.jsx(Zd,{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-amber-600 data-[state=active]:text-white",children:[e.jsx(Vo,{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-amber-600 data-[state=active]:text-white",children:[e.jsx(qr,{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-amber-600 data-[state=active]:text-white",children:[e.jsx(Er,{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-amber-600 data-[state=active]:text-white transition-all transform hover:scale-[1.02]",children:[e.jsx(dI,{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-amber-600 data-[state=active]:text-white transition-all transform hover:scale-[1.02]",children:[e.jsx(fs,{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-amber-600 data-[state=active]:text-white transition-all transform hover:scale-[1.02]",children:[e.jsx(Zm,{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-amber-600 data-[state=active]:text-white transition-all transform hover:scale-[1.02]",children:[e.jsx(Sc,{className:"w-4 h-4"})," App Settings"]})]}),e.jsxs(Gt,{value:"hierarchy",className:"space-y-8 animate-in fade-in slide-in-from-bottom-2 duration-300",children:[e.jsx(E$,{selectedZone:m,onZoneClick:Xe=>p(m===Xe?"all":Xe)}),e.jsx(D$,{selectedZone:m,onAddZone:()=>{Ve(null),xt(""),le(""),rt(""),Rt("none"),y(!0)},onEditZone:Xe=>{var $t;Ve(Xe.id),xt(Xe.name),le(Xe.code),rt(Xe.description),Rt((($t=Xe.zonalBusinessHead)==null?void 0:$t.id)||"none"),y(!0)}}),e.jsx(T$,{selectedZone:m,onAddRegion:()=>{Qt(null),ws(""),Bs(m==="all"?"":m),ie(""),Q([]),S(!0)},onEditRegion:Xe=>{var $t,Ze;Qt(Xe.id),ws(Xe.name),Bs(Xe.zoneId),ie((($t=Xe.regionalManager)==null?void 0:$t.id)||""),Q(((Ze=Xe.districts)==null?void 0:Ze.map(Ut=>Ut.id))||[]),S(!0)},onDeleteRegion:()=>ee.error("Regional office deletion is restricted via portal")}),e.jsx(_$,{selectedZone:m,onAddZM:()=>{U(null),ne(""),re("active"),ve(m==="all"?"":m),We([]),K(!0)},onEditZM:hn,onDeleteZM:()=>ee.error("ZM deletion restricted")}),e.jsx(P$,{selectedZone:m,onAddASM:()=>{I(null),T(""),q(m==="all"?"":m),Z(""),z([]),B([]),O("DD-AM"),j(!0)},onEditASM:pn,onDeleteASM:()=>ee.error("ASM deletion restricted")}),e.jsx(cz,{}),e.jsx(O$,{userAssignedData:c.length>0?c:n})]}),e.jsx(Gt,{value:"roles",className:"animate-in fade-in duration-300",children:e.jsx(I$,{onAddRole:()=>ke(!0),onEditRole:Tr})}),e.jsx(Gt,{value:"templates",className:"animate-in fade-in duration-300",children:e.jsx(F$,{onEditTemplate:Xe=>{if(Ne(Xe),Xe.placeholders&&Array.isArray(Xe.placeholders)){const $t=Xe.placeholders.reduce((Ze,Ut)=>(Ze[Ut]=`[${Ut}]`,Ze),{});it(JSON.stringify($t,null,2))}else it("{}");w(!0)},onDeleteTemplate:()=>ee.error("Delete Template restricted")})}),e.jsx(Gt,{value:"locations",className:"animate-in fade-in duration-300",children:e.jsx(B$,{states:a,stateFilter:Bt,onStateFilterChange:Xe=>{Ds(Xe),mt(1)},statusFilter:as,onStatusFilterChange:Xe=>{Vs(Xe),mt(1)},onAddLocation:()=>{yt(null),Ie(""),rs(""),ht(""),Os(""),zs(""),he("active"),P(!0)},onEditLocation:tr,onDeleteLocation:Xe=>{window.confirm("Are you sure you want to delete this location?")&&Ss.deleteArea(Xe).then($t=>{$t.success&&(ee.success("Location deleted"),s({search:Ge,page:pt,stateId:Bt==="all"?void 0:Bt}))})},onSearch:Xe=>{at(Xe),mt(1)},onPageChange:mt,searchTerm:Ge})}),e.jsx(Gt,{value:"approvals",className:"animate-in fade-in duration-300",children:e.jsx(rD,{})}),e.jsx(Gt,{value:"documents",className:"animate-in fade-in duration-300",children:e.jsx(XU,{})}),e.jsx(Gt,{value:"governance",className:"animate-in fade-in duration-300",children:e.jsx(JU,{})}),e.jsx(Gt,{value:"settings",className:"animate-in fade-in duration-300",children:e.jsx(QU,{})})]}),e.jsx(uz,{isOpen:g,onOpenChange:y,editingZoneId:qe,zoneName:dt,setZoneName:xt,zoneCode:ye,setZoneCode:le,zoneDescription:Qe,setZoneDescription:rt,zonalBusinessHeadId:Kt,setZonalBusinessHeadId:Rt,onSave:Qs,userAssignedData:c.length>0?c.map(Xe=>{var $t,Ze;return{...Xe,name:Xe.fullName||Xe.name,role:($t=Xe.role)==null?void 0:$t.roleName,roleCode:(Ze=Xe.role)==null?void 0:Ze.roleCode,allRoles:Xe.allRoles}}):n}),e.jsx(hz,{isOpen:N,onOpenChange:S,editingRegionId:Re,regionName:qt,setRegionName:ws,regionDescription:_s,setRegionDescription:ns,selectedRegionZone:Cs,setSelectedRegionZone:Bs,regionalManagerId:Ft,setRegionalManagerId:ie,selectedRegionStates:Fe,setSelectedRegionStates:Q,onSave:zn,userAssignedData:c.length>0?c.map(Xe=>{var $t,Ze;return{...Xe,name:Xe.fullName||Xe.name,role:($t=Xe.role)==null?void 0:$t.roleName,roleCode:(Ze=Xe.role)==null?void 0:Ze.roleCode,allRoles:Xe.allRoles}}):n}),e.jsx(cq,{isOpen:u,onOpenChange:j,editingASMId:A,asmManagerId:$,setAsmManagerId:T,asmStatus:E,setAsmStatus:_,selectedASMZone:M,setSelectedASMZone:q,selectedASMRegion:G,setSelectedASMRegion:Z,selectedASMStates:W,setSelectedASMStates:z,selectedASMDistricts:F,setSelectedASMDistricts:B,onSave:ln,asmRoleCode:D,setAsmRoleCode:O,userAssignedData:c.length>0?c.map(Xe=>{var $t,Ze;return{...Xe,name:Xe.fullName||Xe.name,role:($t=Xe.role)==null?void 0:$t.roleName,roleCode:(Ze=Xe.role)==null?void 0:Ze.roleCode,allRoles:Xe.allRoles}}):n,districtsAssignedToOthers:Ls,getDistrictsForSelectedState:Xe=>Ts(Xe,G||void 0)}),e.jsx(dz,{isOpen:V,onOpenChange:K,editingZMId:Y,zmManagerId:X,setZmManagerId:ne,zmStatus:oe,setZmStatus:re,selectedZone:ge,setSelectedZone:ve,selectedRegions:Se,setSelectedRegions:We,onSave:Ws,userAssignedData:c.length>0?c.map(Xe=>{var $t,Ze;return{...Xe,name:Xe.fullName||Xe.name,role:($t=Xe.role)==null?void 0:$t.roleName,roleCode:(Ze=Xe.role)==null?void 0:Ze.roleCode,allRoles:Xe.allRoles}}):n}),e.jsx(YU,{isOpen:C,onOpenChange:w,editingTemplate:pe,setEditingTemplate:Ne,testDataInput:Ee,setTestDataInput:it,previewLoading:st,handlePreviewTemplate:Un,previewContent:Ue,handleSaveTemplate:on}),e.jsx(ZU,{isOpen:R,onOpenChange:P,editingLocationId:ut,locationState:kt,setLocationState:Ie,locationDistrict:_t,setLocationDistrict:ht,locationCity:zt,setLocationCity:rs,locationActiveFrom:Yt,setLocationActiveFrom:Os,locationActiveTo:Is,setLocationActiveTo:zs,locationStatus:en,setLocationStatus:he,allStates:a,allDistricts:l,onSave:En}),e.jsx(L$,{isOpen:Ce,onOpenChange:fe,role:Ye,onSave:yr}),e.jsx(M$,{isOpen:_e,onOpenChange:ke,onSave:er})]})},zh={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 Te.getUsers(t)).data}catch(r){return console.error("Error fetching users:",r),ee.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 Te.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 ee.error(r),{success:!1,message:r}}},async updateUser(t,s){var n,r,a;try{const l=await Te.updateUser(t,s);return l.ok&&((n=l.data)!=null&&n.success)&&ee.success(l.data.message||"User updated successfully"),l.data}catch(l){return console.error("Error updating user:",l),ee.error(((a=(r=l.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,l;try{const c=await Te.updateUserStatus(t,{status:s,isActive:n});return c.ok&&((r=c.data)!=null&&r.success)&&ee.success(c.data.message||"User status updated"),c.data}catch(c){return console.error("Error updating status:",c),ee.error(((l=(a=c.response)==null?void 0:a.data)==null?void 0:l.message)||"Failed to update status"),{success:!1}}}};function nV(){const t=(W,z)=>{if(!(W!=null&&W.parents)||!Array.isArray(W.parents))return"";const F=W.parents.find(B=>(B==null?void 0:B.type)===z);return(F==null?void 0:F.id)||""},s=(W,z)=>W?Array.isArray(W[z])?W[z]:Array.isArray(W.data)?W.data:[]:[],[n,r]=v.useState([]),[a,l]=v.useState([]),[c,d]=v.useState([]),[h,x]=v.useState([]),[f,m]=v.useState([]),[p,u]=v.useState([]),[j,g]=v.useState(!0),[y,N]=v.useState(""),[S,C]=v.useState("all"),[w,R]=v.useState("all"),[P,A]=v.useState(!1),[I,$]=v.useState(null),[T,E]=v.useState({fullName:"",email:"",roleCode:"",status:"active",isActive:!0,mobileNumber:"",department:"",designation:"",employeeId:"",zoneId:"",regionId:"",stateId:"",districtId:""});v.useEffect(()=>{_()},[]);const _=async()=>{g(!0);try{const[W,z,F,B]=await Promise.all([zh.getAllUsers(),Ss.getRoles(),Ss.getZones(),Ss.getRegions()]);W.success&&r(W.data),z.success&&l(z.data),F.success&&d(F.data),B.success&&x(B.data)}catch{ee.error("Failed to load user management data")}finally{g(!1)}};v.useEffect(()=>{T.zoneId?Ss.getStates(T.zoneId).then(W=>{W&&W.success&&m(s(W,"states"))}):m([])},[T.zoneId]),v.useEffect(()=>{T.stateId?Ss.getDistricts(T.stateId).then(W=>{W&&W.success&&u(s(W,"districts"))}):u([])},[T.stateId]),v.useEffect(()=>{},[T.districtId]);const M=W=>{const z=W.location,F=z==null?void 0:z.type,B=W.zoneId||(F==="zone"?z==null?void 0:z.id:t(z,"zone")),D=W.regionId||(F==="region"?z==null?void 0:z.id:t(z,"region")),O=W.stateId||(F==="state"?z==null?void 0:z.id:t(z,"state")),V=W.districtId||(F==="district"?z==null?void 0:z.id:t(z,"district"));$(W),E({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:B||"",regionId:D||"",stateId:O||"",districtId:V||""}),A(!0)},q=async()=>{var W,z;if(!T.fullName||!T.email||!T.roleCode){ee.error("Please fill in all required fields");return}try{const F=T.districtId||T.stateId||T.regionId||T.zoneId||null,B={...T,locationId:F};if(I)(await zh.updateUser(I.id,B)).success&&(A(!1),_());else{const D=await zh.createUser(B);D.success?(ee.success("User created successfully"),E({fullName:"",email:"",roleCode:"",status:"active",isActive:!0,mobileNumber:"",department:"",designation:"",employeeId:"",zoneId:"",regionId:"",stateId:"",districtId:""}),A(!1),_()):ee.error(D.message||"Failed to create user")}}catch(F){const B=((z=(W=F==null?void 0:F.response)==null?void 0:W.data)==null?void 0:z.message)||(F==null?void 0:F.message)||"Operation failed";ee.error(B)}},G=async W=>{const z=W.status==="active"?"inactive":"active",F=!W.isActive;(await zh.updateUserStatus(W.id,z,F)).success&&_()},Z=n.filter(W=>{var D,O,V;const z=((D=W.fullName)==null?void 0:D.toLowerCase().includes(y.toLowerCase()))||((O=W.email)==null?void 0:O.toLowerCase().includes(y.toLowerCase()))||((V=W.employeeId)==null?void 0:V.toLowerCase().includes(y.toLowerCase())),F=S==="all"||W.roleCode===S,B=w==="all"||W.status===w;return z&&F&&B});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(da,{className:"w-6 h-6 text-amber-600"}),"User Management"]}),e.jsx("p",{className:"text-slate-500",children:"Manage system users, roles, and access permissions."})]}),e.jsxs(se,{onClick:()=>{$(null),E({fullName:"",email:"",roleCode:"",status:"active",isActive:!0,mobileNumber:"",department:"",designation:"",employeeId:"",zoneId:"",regionId:"",stateId:"",districtId:""}),A(!0)},className:"bg-amber-600 hover:bg-amber-700 text-white shrink-0",children:[e.jsx(Jv,{className:"w-4 h-4 mr-2"}),"Add New User"]})]}),e.jsx(Le,{className:"border-slate-200",children:e.jsx(Me,{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(Ra,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(ot,{placeholder:"Search by name, email, ID...",className:"pl-10",value:y,onChange:W=>N(W.target.value)})]}),e.jsxs(wt,{value:S,onValueChange:C,children:[e.jsxs(Ct,{children:[e.jsx(I2,{className:"w-4 h-4 mr-2 text-slate-400"}),e.jsx(St,{placeholder:"Filter by Role"})]}),e.jsxs(At,{children:[e.jsx(Pe,{value:"all",children:"All Roles"}),a.map(W=>e.jsx(Pe,{value:W.roleCode,children:W.roleName},W.id))]})]}),e.jsxs(wt,{value:w,onValueChange:R,children:[e.jsx(Ct,{children:e.jsx(St,{placeholder:"Filter by Status"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"all",children:"All Status"}),e.jsx(Pe,{value:"active",children:"Active"}),e.jsx(Pe,{value:"inactive",children:"Inactive"})]})]}),e.jsxs(se,{variant:"outline",onClick:_,disabled:j,children:[e.jsx(Rr,{className:`w-4 h-4 mr-2 ${j?"animate-spin":""}`}),"Refresh"]})]})})}),e.jsx(Le,{className:"border-slate-200 overflow-hidden",children:e.jsx(Me,{className:"p-0",children:e.jsxs(ks,{children:[e.jsx(Rs,{className:"bg-slate-50",children:e.jsxs(ct,{children:[e.jsx(me,{children:"User Information"}),e.jsx(me,{children:"Geographical Mapping"}),e.jsx(me,{children:"Account Details"}),e.jsx(me,{children:"Role & Department"}),e.jsx(me,{children:"Status"}),e.jsx(me,{className:"text-right",children:"Actions"})]})}),e.jsx(Es,{children:j?e.jsx(ct,{children:e.jsx(de,{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(Rr,{className:"w-8 h-8 animate-spin"}),e.jsx("p",{children:"Loading users..."})]})})}):Z.length===0?e.jsx(ct,{children:e.jsxs(de,{colSpan:5,className:"h-40 text-center text-slate-500",children:[e.jsx(da,{className:"w-12 h-12 mx-auto mb-2 opacity-20"}),"No users found matching your criteria."]})}):Z.map(W=>{var z,F,B,D;return e.jsxs(ct,{className:"hover:bg-slate-50/50",children:[e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-100 text-amber-700 flex items-center justify-center font-bold",children:((z=W.fullName)==null?void 0:z.charAt(0))||((F=W.email)==null?void 0:F.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(qr,{className:"w-3 h-3"}),W.email]})]})]})}),e.jsx(de,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(Ae,{variant:"outline",className:"bg-blue-50 text-blue-700 border-blue-200",children:["Location: ",((B=W.location)==null?void 0:B.name)||"N/A"]})}),e.jsxs("div",{className:"text-xs text-slate-500",children:["Type: ",(D=W.location)!=null&&D.type?W.location.type.toUpperCase():"N/A"]})]})}),e.jsx(de,{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(Zv,{className:"w-3 h-3"}),W.mobileNumber||"No phone"]})]})}),e.jsx(de,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Ae,{variant:"outline",className:"bg-purple-50 text-purple-700 border-purple-200",children:[e.jsx(Vo,{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(de,{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(Ae,{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(Ys,{className:"w-3 h-3 mr-1"}):e.jsx(Za,{className:"w-3 h-3 mr-1"}),W.status]})}),e.jsx(Ef,{checked:W.isActive,onCheckedChange:()=>G(W)})]})}),e.jsx(de,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(se,{variant:"ghost",size:"icon",onClick:()=>M(W),children:e.jsx(ur,{className:"w-4 h-4 text-slate-400 hover:text-amber-600"})}),e.jsx(se,{variant:"ghost",size:"icon",children:e.jsx(Gn,{className:"w-4 h-4 text-slate-400 hover:text-red-600"})})]})})]},W.id)})})]})})}),e.jsx(os,{open:P,onOpenChange:A,children:e.jsxs(ls,{className:"max-w-2xl bg-white",children:[e.jsxs(ms,{children:[e.jsx(us,{children:I?"Edit User":"Add New User"}),e.jsx(vs,{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(ce,{htmlFor:"fullName",children:"Full Name *"}),e.jsx(ot,{id:"fullName",value:T.fullName,onChange:W=>E({...T,fullName:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(ce,{htmlFor:"email",children:"Email Address *"}),e.jsx(ot,{id:"email",type:"email",value:T.email,onChange:W=>E({...T,email:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(ce,{htmlFor:"employeeId",children:"Employee ID"}),e.jsx(ot,{id:"employeeId",value:T.employeeId,onChange:W=>E({...T,employeeId:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(ce,{htmlFor:"roleCode",children:"Role *"}),e.jsxs(wt,{value:T.roleCode,onValueChange:W=>E({...T,roleCode:W}),children:[e.jsx(Ct,{id:"roleCode",children:e.jsx(St,{placeholder:"Select a role"})}),e.jsx(At,{children:a.map(W=>e.jsx(Pe,{value:W.roleCode,children:W.roleName},W.id))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(ce,{htmlFor:"department",children:"Department"}),e.jsx(ot,{id:"department",value:T.department,onChange:W=>E({...T,department:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(ce,{htmlFor:"designation",children:"Designation"}),e.jsx(ot,{id:"designation",value:T.designation,onChange:W=>E({...T,designation:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(ce,{htmlFor:"mobileNumber",children:"Mobile Number"}),e.jsx(ot,{id:"mobileNumber",value:T.mobileNumber,onChange:W=>E({...T,mobileNumber:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(ce,{htmlFor:"status",children:"Account Status"}),e.jsxs(wt,{value:T.status,onValueChange:W=>E({...T,status:W}),children:[e.jsx(Ct,{id:"status",children:e.jsx(St,{placeholder:"Select status"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"active",children:"Active"}),e.jsx(Pe,{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(ce,{htmlFor:"zoneId",children:"Zone (Top Level)"}),e.jsxs(wt,{value:T.zoneId,onValueChange:W=>E({...T,zoneId:W,regionId:"",stateId:"",districtId:""}),children:[e.jsx(Ct,{id:"zoneId",children:e.jsx(St,{placeholder:"Select Zone"})}),e.jsx(At,{children:c.map(W=>e.jsx(Pe,{value:W.id,children:W.name||W.zoneName},W.id))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(ce,{htmlFor:"regionId",children:"Region"}),e.jsxs(wt,{value:T.regionId,onValueChange:W=>E({...T,regionId:W}),disabled:!T.zoneId,children:[e.jsx(Ct,{id:"regionId",children:e.jsx(St,{placeholder:"Select Region"})}),e.jsx(At,{children:h.filter(W=>W.parents&&W.parents.some(z=>z.id===T.zoneId)||W.zoneId===T.zoneId).map(W=>e.jsx(Pe,{value:W.id,children:W.name||W.regionName},W.id))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(ce,{htmlFor:"stateId",children:"State"}),e.jsxs(wt,{value:T.stateId,onValueChange:W=>E({...T,stateId:W,districtId:""}),disabled:!T.zoneId,children:[e.jsx(Ct,{id:"stateId",children:e.jsx(St,{placeholder:"Select State"})}),e.jsx(At,{children:f.filter(W=>W.parents&&W.parents.some(z=>z.id===T.zoneId)||W.zoneId===T.zoneId).map(W=>e.jsx(Pe,{value:W.id,children:W.name||W.stateName},W.id))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(ce,{htmlFor:"districtId",children:"District"}),e.jsxs(wt,{value:T.districtId,onValueChange:W=>E({...T,districtId:W}),disabled:!T.stateId,children:[e.jsx(Ct,{id:"districtId",children:e.jsx(St,{placeholder:"Select District"})}),e.jsx(At,{children:p.filter(W=>W.parents&&W.parents.some(z=>z.id===T.stateId)||W.stateId===T.stateId).map(W=>e.jsx(Pe,{value:W.id,children:W.name||W.districtName},W.id))})]})]})]})]})]}),e.jsxs(rn,{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-amber-600 hover:bg-amber-700 text-white",onClick:q,children:I?"Save Changes":"Create User"})]})]})})]})}const rV=({isOpen:t,onClose:s,sla:n,onSave:r})=>{const[a,l]=v.useState({activityName:"",tatHours:24,tatUnit:"hours",isActive:!0,reminders:[],escalationConfigs:[]}),[c,d]=v.useState(!1);v.useEffect(()=>{n&&l({...n,reminders:n.reminders||[],escalationConfigs:n.escalationConfigs||[]})},[n]);const h=()=>{l({...a,reminders:[...a.reminders,{timeValue:1,timeUnit:"days",isEnabled:!0}]})},x=u=>{const j=[...a.reminders];j.splice(u,1),l({...a,reminders:j})},f=()=>{l({...a,escalationConfigs:[...a.escalationConfigs,{level:a.escalationConfigs.length+1,timeValue:1,timeUnit:"days",notifyEmail:""}]})},m=u=>{const j=[...a.escalationConfigs];j.splice(u,1);const g=j.map((y,N)=>({...y,level:N+1}));l({...a,escalationConfigs:g})},p=async u=>{if(u.preventDefault(),!a.activityName||!a.ownerRole){ee.error("Activity Name and Owner Role are required");return}try{d(!0),await Ss.saveSlaConfig(a),ee.success(n!=null&&n.id?"SLA Configuration updated":"New SLA Configuration created"),r(),s()}catch(j){console.error("Save SLA error:",j),ee.error("Failed to save SLA configuration")}finally{d(!1)}};return e.jsx(os,{open:t,onOpenChange:s,children:e.jsxs(ls,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ms,{children:[e.jsxs(us,{children:[n!=null&&n.id?"Configure SLA":"Add New SLA",": ",a.activityName||"New Activity"]}),e.jsx(vs,{children:"Define the Turn Around Time and notification rules for this stage."})]}),e.jsxs("form",{onSubmit:p,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(ce,{htmlFor:"activityName",children:"Activity Name (Workflow Stage)"}),e.jsxs(wt,{value:a.activityName,onValueChange:u=>{let j=a.ownerRole;for(const g of Object.values(sC))if(g[u]){j=g[u];break}l({...a,activityName:u,ownerRole:j})},disabled:!!(n!=null&&n.id),children:[e.jsx(Ct,{id:"activityName",children:e.jsx(St,{placeholder:"Select Stage"})}),e.jsx(At,{children:Object.entries(sC).map(([u,j])=>e.jsxs(gt.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(j).map(g=>e.jsx(Pe,{value:g,children:g},g))]},u))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"ownerRole",children:"Owner Role (Auto-resolved)"}),e.jsxs(wt,{value:a.ownerRole,onValueChange:u=>l({...a,ownerRole:u}),disabled:!!(n!=null&&n.id),children:[e.jsx(Ct,{id:"ownerRole",children:e.jsx(St,{placeholder:"Select Role"})}),e.jsx(At,{children:Object.values(Gs).map(u=>e.jsx(Pe,{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(ce,{htmlFor:"tatHours",children:"Target TAT"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ot,{id:"tatHours",type:"number",value:a.tatHours,onChange:u=>l({...a,tatHours:parseInt(u.target.value)})}),e.jsxs(wt,{value:a.tatUnit,onValueChange:u=>l({...a,tatUnit:u}),children:[e.jsx(Ct,{className:"w-32",children:e.jsx(St,{})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"hours",children:"Hours"}),e.jsx(Pe,{value:"days",children:"Days"})]})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2 pt-8",children:[e.jsx(Ef,{id:"isActive",checked:a.isActive,onCheckedChange:u=>l({...a,isActive:u})}),e.jsx(ce,{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(Yd,{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:h,className:"h-7 text-xs",children:[e.jsx(cn,{className:"w-3 h-3 mr-1"})," Add Reminder"]})]}),e.jsxs("div",{className:"space-y-3",children:[a.reminders.map((u,j)=>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(ot,{type:"number",className:"w-20 h-8",value:u.timeValue,onChange:g=>{const y=[...a.reminders];y[j].timeValue=parseInt(g.target.value),l({...a,reminders:y})}}),e.jsxs(wt,{value:u.timeUnit,onValueChange:g=>{const y=[...a.reminders];y[j].timeUnit=g,l({...a,reminders:y})},children:[e.jsx(Ct,{className:"w-24 h-8 text-xs",children:e.jsx(St,{})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"hours",children:"Hours"}),e.jsx(Pe,{value:"days",children:"Days"})]})]}),e.jsx(se,{type:"button",variant:"ghost",size:"sm",onClick:()=>x(j),className:"h-8 w-8 p-0 text-slate-400 hover:text-red-500",children:e.jsx(Gn,{className:"w-4 h-4"})})]},j)),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(Ya,{className:"w-4 h-4 text-red-600"}),e.jsx("h4",{className:"font-medium text-sm",children:"Escalation Levels"})]}),e.jsxs(se,{type:"button",variant:"outline",size:"sm",onClick:f,className:"h-7 text-xs",children:[e.jsx(cn,{className:"w-3 h-3 mr-1"})," Add Level"]})]}),e.jsxs("div",{className:"space-y-3",children:[a.escalationConfigs.map((u,j)=>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(Ae,{variant:"outline",className:"bg-red-50 text-red-700 border-red-100",children:["Level ",u.level]}),e.jsx(se,{type:"button",variant:"ghost",size:"sm",onClick:()=>m(j),className:"h-7 w-7 p-0 text-slate-400 hover:text-red-500",children:e.jsx(Gn,{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(ce,{className:"text-[10px] uppercase text-slate-500",children:"Escalate After Breaching By"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ot,{type:"number",className:"h-8",value:u.timeValue,onChange:g=>{const y=[...a.escalationConfigs];y[j].timeValue=parseInt(g.target.value),l({...a,escalationConfigs:y})}}),e.jsxs(wt,{value:u.timeUnit,onValueChange:g=>{const y=[...a.escalationConfigs];y[j].timeUnit=g,l({...a,escalationConfigs:y})},children:[e.jsx(Ct,{className:"w-24 h-8 text-xs",children:e.jsx(St,{})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"hours",children:"Hours"}),e.jsx(Pe,{value:"days",children:"Days"})]})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ce,{className:"text-[10px] uppercase text-slate-500",children:"Notification Recipient (Role)"}),e.jsxs(wt,{value:u.notifyRole||"",onValueChange:g=>{const y=[...a.escalationConfigs];y[j].notifyRole=g,y[j].notifyEmail="",l({...a,escalationConfigs:y})},children:[e.jsx(Ct,{className:"h-8 text-xs",children:e.jsx(St,{placeholder:"Select Recipient Role"})}),e.jsx(At,{children:Object.values(Gs).map(g=>e.jsx(Pe,{value:g,children:g},g))})]})]})]})]},j)),a.escalationConfigs.length===0&&e.jsx("p",{className:"text-center text-xs text-slate-400 py-2",children:"No escalation levels defined"})]})]}),e.jsxs(rn,{className:"pt-4 border-t",children:[e.jsx(se,{type:"button",variant:"outline",onClick:s,disabled:c,children:"Cancel"}),e.jsx(se,{type:"submit",disabled:c,children:c?"Saving...":"Save Configuration"})]})]})]})})},aV=()=>{const t=su(),{slaConfigs:s,loading:n}=Nn(u=>u.master),[r,a]=v.useState(!1),[l,c]=v.useState(null),d=async()=>{try{const u=await Ss.getSlaConfigs();u&&u.success&&t(s2({slaConfigs:u.data}))}catch{ee.error("Failed to fetch SLA configurations")}};v.useEffect(()=>{d()},[]);const h=async()=>{try{p(!0);const u=await Ss.initializeDefaultSlas();u&&u.success&&(ee.success("Default SLAs initialized successfully"),d())}catch{ee.error("Failed to initialize default SLAs")}finally{p(!1)}},x=u=>{c(u),a(!0)},f=()=>{c(null),a(!0)},[m,p]=v.useState(!1);return e.jsxs("div",{className:"space-y-6 max-w-7xl mx-auto",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(Js,{className:"w-6 h-6 text-amber-600"}),"SLA & Escalation Matrix"]}),e.jsx("p",{className:"text-slate-500",children:"Configure Turn Around Time (TAT) and escalation rules for each process stage"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(se,{variant:"outline",onClick:h,disabled:n||m,children:[e.jsx(Rr,{className:`w-4 h-4 mr-2 ${m?"animate-spin":""}`}),"Initialize Defaults"]}),e.jsxs(se,{onClick:f,disabled:n,children:[e.jsx(cn,{className:"w-4 h-4 mr-2"}),"Add Manual SLA"]}),e.jsx(se,{variant:"ghost",size:"icon",onClick:d,disabled:n,children:e.jsx(Rr,{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(u=>{var j,g;return e.jsxs(Le,{className:"border-slate-200 hover:shadow-md transition-shadow group overflow-hidden",children:[e.jsx(tt,{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-amber-50 border border-amber-100 flex items-center justify-center",children:e.jsx(Js,{className:"w-5 h-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(nt,{className:"text-lg",children:u.activityName}),e.jsx(Zt,{className:"flex items-center gap-1.5 mt-0.5",children:e.jsxs("span",{className:"font-semibold text-amber-700",children:["Target TAT: ",u.tatHours," ",u.tatUnit]})})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae,{variant:u.isActive?"default":"secondary",className:u.isActive?"bg-emerald-600":"bg-slate-400",children:u.isActive?e.jsxs(e.Fragment,{children:[e.jsx(Ys,{className:"w-3 h-3 mr-1"})," Active"]}):"Disabled"}),e.jsx(se,{variant:"ghost",size:"icon",onClick:()=>x(u),className:"h-8 w-8 text-slate-400 hover:text-amber-600",children:e.jsx(ur,{className:"w-4 h-4"})})]})]})}),e.jsxs(Me,{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(Yd,{className:"w-4 h-4 text-blue-600"}),e.jsxs("span",{className:"text-xs font-bold text-slate-700 uppercase tracking-wider",children:["Reminders (",((j=u.reminders)==null?void 0:j.length)||0,")"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[(u.reminders||[]).map((y,N)=>e.jsxs("div",{className:"text-xs text-slate-600 flex items-center gap-1",children:[e.jsxs(Ae,{variant:"outline",className:"text-[10px] h-4.5 bg-blue-50 border-blue-200",children:[y.timeValue," ",y.timeUnit]}),e.jsx("span",{children:"before SLA"})]},N)),(!u.reminders||u.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(Ya,{className:"w-4 h-4 text-red-600"}),e.jsxs("span",{className:"text-xs font-bold text-slate-700 uppercase tracking-wider",children:["Escalations (",((g=u.escalationConfigs)==null?void 0:g.length)||0,")"]})]}),e.jsxs("div",{className:"space-y-2",children:[(u.escalationConfigs||[]).map((y,N)=>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(Ae,{variant:"outline",className:"text-[9px] h-4 px-1 bg-red-50 border-red-200 text-red-700",children:["L",y.level]}),e.jsxs("span",{children:["after ",y.timeValue," ",y.timeUnit]})]}),e.jsx("p",{className:"text-slate-500 ml-8 font-mono truncate",children:y.notifyEmail})]},N)),(!u.escalationConfigs||u.escalationConfigs.length===0)&&e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"None configured"})]})]})]})]},u.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(Js,{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(rV,{isOpen:r,onClose:()=>a(!1),sla:l,onSave:d})]})},aD="Private Limited",iD="LLP",lD="LLP Conversion",oD="Partnership",cD="Partnership Change",Qb="Proprietorship",dD="Director Change",uD="Ownership Transfer",hD="Company Formation",mD=[Qb,oD,lD,iD,aD,hD,uD,cD,dD];function iV(t){return mD.includes(t)}function lV(t){const s=String(t||"").trim();if(!s)return null;if(iV(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"?aD:n.includes("llp")&&n.includes("conversion")?lD:n.includes("llp")?iD:n.includes("partnership")&&n.includes("change")?cD:n.includes("partnership")?oD:n.includes("proprietorship")||n==="sole proprietorship"?Qb:n.includes("director")?dD:n.includes("ownership")&&n.includes("transfer")?uD:n.includes("company")&&n.includes("formation")?hD:mD.find(a=>a.toLowerCase()===s.toLowerCase())||null}function fD(t){return lV(t)||Qb}const oV={Partnership:[1,2,3,4,8,9,10,16],LLP:[1,2,3,7,8,9,10,16],"Private Limited":[1,2,3,5,6,7,8,10,16],Proprietorship:[1,2,3,10,16]},cV=99,dV={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",[cV]:"Other"},rC=t=>t==="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":t.includes("Collection")?"bg-blue-100 text-blue-700 border-blue-300":"bg-slate-100 text-slate-700 border-slate-300",Ui=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":case"LLP Conversion":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"}};function uV({onViewDetails:t}){var ve,Se,We,Ce;const[s,n]=v.useState(!1),[r,a]=v.useState([]),[l,c]=v.useState([]),[d,h]=v.useState([]),[x,f]=v.useState(""),[m,p]=v.useState(""),[u,j]=v.useState([]),[g,y]=v.useState(null),[N,S]=v.useState(""),[C,w]=v.useState(""),[R,P]=v.useState([]),[A,I]=v.useState([]),[$,T]=v.useState(!0),[E,_]=v.useState(1),[M,q]=v.useState(null),[G,Z]=v.useState("all"),W=10,[z,F]=v.useState(!1),[B,D]=v.useState(!1),O=fe=>fe.status==="Completed"||fe.status==="Closed"||fe.currentStage==="Completed",V=fe=>fe.status==="Rejected"||fe.status==="Revoked"||fe.currentStage==="Rejected"||fe.currentStage==="Revoked",K=fe=>!O(fe)&&!V(fe)&&fe.status!=="Submitted",Y=fe=>fe.status==="Submitted"||fe.currentStage==="Submitted",U=fe=>{Z(fe),_(1)};v.useEffect(()=>{X()},[E,G]),v.useEffect(()=>{if(!s)return;let fe=!1;return(async()=>{var Ye,be,_e,ke;try{D(!0);const[qe,Ve,dt]=await Promise.all([Te.getConstitutionalChangeMeta(),Te.getDealers({onboarded:"true"}),Te.getOutlets()]);if(fe)return;(Ye=qe.data)!=null&&Ye.success&&Array.isArray(qe.data.structureTargets)&&a(qe.data.structureTargets);const xt=((be=Ve.data)==null?void 0:be.data)??((_e=Ve.data)==null?void 0:_e.dealers)??[];c(Array.isArray(xt)?xt:[]);const ye=((ke=dt.data)==null?void 0:ke.outlets)??[];h(Array.isArray(ye)?ye:[])}catch(qe){console.error(qe),ee.error("Failed to load dealers or form options")}finally{fe||D(!1)}})(),()=>{fe=!0}},[s]);const X=async()=>{try{T(!0);const fe=await Te.getConstitutionalChanges({page:E,limit:W,status:G==="all"?void 0:G});fe.data.success&&(I(fe.data.requests||[]),q(fe.meta))}catch(fe){console.error("Fetch requests error:",fe),ee.error("Failed to fetch requests")}finally{T(!1)}},ne=fe=>{var ke,qe,Ve;if(f(fe),p(""),S(""),P([]),!fe){y(null),j([]);return}const Ye=l.find(dt=>{var xt;return((xt=dt.user)==null?void 0:xt.id)===fe});if(!((ke=Ye==null?void 0:Ye.user)!=null&&ke.id)){y(null),j([]);return}const be=fD(Ye.constitutionType),_e=d.filter(dt=>String(dt.dealerId)===String(fe));j(_e),_e.length===1&&p(_e[0].id),y({dealerUserId:Ye.user.id,dealerName:Ye.businessName,dealershipName:Ye.legalName||Ye.businessName,address:Ye.registeredAddress||((qe=Ye.application)==null?void 0:qe.preferredLocation)||"—",gst:Ye.gstNumber||"N/A",currentType:be,dealerCode:((Ve=Ye.dealerCode)==null?void 0:Ve.dealerCode)||"—",region:"—",zone:"—"})},oe=fe=>{S(fe),P(oV[fe]||[])},re=async fe=>{var Ye,be;if(fe.preventDefault(),!(g!=null&&g.dealerUserId)){ee.error("Please select a dealer");return}if(u.length>1&&!m){ee.error("Please select an outlet for this dealer");return}if(!N){ee.error("Please select proposed constitution type");return}if(!C.trim()){ee.error("Please provide a reason for constitutional change");return}if(g.currentType===N){ee.error("Proposed type cannot be the same as the current constitution");return}try{F(!0);const _e={forDealerUserId:g.dealerUserId,outletId:m||void 0,changeType:N,reason:C.trim(),currentConstitution:g.currentType};(await Te.createConstitutionalChange(_e)).data.success&&(ee.success("Constitutional change request submitted successfully"),n(!1),X(),f(""),p(""),j([]),y(null),S(""),w(""),P([]))}catch(_e){console.error("Submit request error:",_e);const ke=((be=(Ye=_e==null?void 0:_e.response)==null?void 0:Ye.data)==null?void 0:be.message)||"Failed to submit request";ee.error(ke)}finally{F(!1)}},ge=[{title:"Total Requests",value:((ve=M==null?void 0:M.stats)==null?void 0:ve.total)||0,icon:fs,color:"bg-blue-500"},{title:"Submitted / Review",value:((Se=M==null?void 0:M.stats)==null?void 0:Se.pending)||0,icon:$n,color:"bg-yellow-500"},{title:"Completed",value:((We=M==null?void 0:M.stats)==null?void 0:We.completed)||0,icon:Vo,color:"bg-green-500"},{title:"Rejected / Revoked",value:((Ce=M==null?void 0:M.stats)==null?void 0:Ce.rejected)||0,icon:Dc,color:"bg-red-500"}];return e.jsxs("div",{className:"space-y-6",children:[$&&e.jsx("div",{className:"fixed inset-0 bg-slate-900/20 backdrop-blur-sm z-50 flex items-center justify-center",children:e.jsx(ss,{className:"w-8 h-8 text-amber-600 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(os,{open:s,onOpenChange:n,children:[e.jsx(Hl,{asChild:!0,children:e.jsxs(se,{className:"bg-amber-600 hover:bg-amber-700",children:[e.jsx(cn,{className:"w-4 h-4 mr-2"}),"New Request"]})}),e.jsxs(ls,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Create Constitutional Change Request"}),e.jsx(vs,{children:"Submit a request for dealership constitutional change. All fields are mandatory."})]}),e.jsxs("form",{onSubmit:re,className:"space-y-4",children:[B&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500 py-2",children:[e.jsx(ss,{className:"h-4 w-4 animate-spin"}),"Loading dealers and options…"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"dealerUser",children:"Dealer *"}),e.jsxs(wt,{value:x,onValueChange:ne,disabled:B,required:!0,children:[e.jsx(Ct,{id:"dealerUser",children:e.jsx(St,{placeholder:"Select dealer account"})}),e.jsx(At,{className:"max-h-72",children:l.filter(fe=>{var Ye;return(Ye=fe.user)==null?void 0:Ye.id}).map(fe=>{var Ye;return e.jsx(Pe,{value:fe.user.id,children:(((Ye=fe.dealerCode)==null?void 0:Ye.dealerCode)||"No code")+" — "+(fe.businessName||fe.legalName||"Dealer")},fe.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(ce,{htmlFor:"outletPick",children:"Outlet *"}),e.jsxs(wt,{value:m,onValueChange:p,required:!0,children:[e.jsx(Ct,{id:"outletPick",children:e.jsx(St,{placeholder:"Select outlet"})}),e.jsx(At,{children:u.map(fe=>e.jsxs(Pe,{value:fe.id,children:[fe.code," — ",fe.name]},fe.id))})]})]}),g&&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:g.dealerCode})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Dealer Name:"}),e.jsx("p",{className:"text-slate-900",children:g.dealerName})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Legal / display name:"}),e.jsx("p",{className:"text-slate-900",children:g.dealershipName})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Address:"}),e.jsx("p",{className:"text-slate-900",children:g.address})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"GST:"}),e.jsx("p",{className:"text-slate-900",children:g.gst})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Current constitution (from profile):"}),e.jsx(Ae,{className:Ui(g.currentType),children:g.currentType})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"targetType",children:"Proposed constitution *"}),e.jsxs(wt,{value:N,onValueChange:oe,required:!0,children:[e.jsx(Ct,{children:e.jsx(St,{placeholder:"Select proposed constitution"})}),e.jsx(At,{children:r.filter(fe=>fe.value!==(g==null?void 0:g.currentType)).map(fe=>e.jsx(Pe,{value:fe.value,children:fe.label},fe.value))})]}),g&&N&&g.currentType===N&&e.jsx("p",{className:"text-red-600 text-sm",children:"Target type cannot be same as current type"})]}),N&&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 ",N]}),e.jsx("div",{className:"grid grid-cols-1 gap-2",children:R.map(fe=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsxs("span",{className:"text-blue-600 font-medium",children:[fe,"."]}),e.jsx("span",{className:"text-blue-800",children:dV[fe]})]},fe))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"reason",children:"Reason for Constitutional Change *"}),e.jsx(Fs,{id:"reason",placeholder:"Provide detailed reason for the constitutional change request...",value:C,onChange:fe=>w(fe.target.value),rows:4,required:!0})]}),e.jsxs(rn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(se,{type:"submit",className:"bg-amber-600 hover:bg-amber-700",disabled:!g||!N||g&&g.currentType===N||u.length>1&&!m||B||z,children:z?e.jsxs(e.Fragment,{children:[e.jsx(ss,{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:ge.map((fe,Ye)=>{const be=fe.icon;return e.jsx(Le,{children:e.jsx(Me,{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:fe.title}),e.jsx("p",{className:"text-slate-900 text-2xl mt-1",children:fe.value})]}),e.jsx("div",{className:`${fe.color} w-12 h-12 rounded-lg flex items-center justify-center`,children:e.jsx(be,{className:"w-6 h-6 text-white"})})]})})},Ye)})}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"Constitutional Change Requests"}),e.jsx(Zt,{children:"Track and manage all constitutional change requests across all stages"})]}),e.jsxs(Me,{children:[e.jsxs(Pn,{value:G,onValueChange:U,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(Gt,{value:"all",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{className:"bg-slate-50",children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Constitutional Change"}),e.jsx(me,{children:"Current Stage"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Submitted On"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Es,{children:A.length===0?e.jsx(ct,{children:e.jsx(de,{colSpan:7,className:"text-center py-8 text-slate-500",children:"No constitutional change requests found"})}):A.map(fe=>{var Ye,be,_e,ke,qe,Ve,dt,xt,ye,le,Qe,rt,Kt,Rt,Re,Qt;return e.jsxs(ct,{children:[e.jsxs(de,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:fe.requestId}),e.jsx("div",{className:"text-slate-600 text-sm",children:((_e=(be=(Ye=fe.dealer)==null?void 0:Ye.dealerProfile)==null?void 0:be.dealerCode)==null?void 0:_e.dealerCode)||((ke=fe.outlet)==null?void 0:ke.code)||"N/A"})]}),e.jsxs(de,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:((Ve=(qe=fe.dealer)==null?void 0:qe.dealerProfile)==null?void 0:Ve.businessName)||((dt=fe.outlet)==null?void 0:dt.name)||"N/A"}),e.jsx("div",{className:"text-slate-600 text-sm",children:((ye=(xt=fe.dealer)==null?void 0:xt.dealerProfile)==null?void 0:ye.registeredAddress)||((le=fe.outlet)!=null&&le.city&&((Qe=fe.outlet)!=null&&Qe.state)?`${fe.outlet.city}, ${fe.outlet.state}`:((Rt=(Kt=(rt=fe.dealer)==null?void 0:rt.dealerProfile)==null?void 0:Kt.application)==null?void 0:Rt.city)||((Re=fe.outlet)==null?void 0:Re.address)||"N/A")})]}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae,{className:Ui(fe.currentConstitution||"Proprietorship"),children:fe.currentConstitution||"—"}),e.jsx(To,{className:"w-4 h-4 text-slate-400"}),e.jsx(Ae,{className:Ui(fe.changeType),children:fe.changeType})]})}),e.jsx(de,{children:e.jsx(Ae,{variant:"outline",className:"border-slate-300 text-slate-700",children:fe.currentStage})}),e.jsx(de,{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 bg-amber-600 transition-all duration-300",style:{width:`${fe.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-slate-600 text-sm",children:[fe.progressPercentage||0,"%"]})]})}),e.jsxs(de,{children:[e.jsx("div",{className:"text-slate-900",children:Ht(fe.createdAt)}),e.jsxs("div",{className:"text-slate-600 text-sm",children:["By ",((Qt=fe.dealer)==null?void 0:Qt.fullName)||"Dealer"]})]}),e.jsx(de,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(fe.requestId),children:[e.jsx(nn,{className:"w-4 h-4 mr-1"}),"View"]})})]},fe.requestId)})})]})})}),e.jsx(Gt,{value:"pending",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{className:"bg-slate-50",children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Constitutional Change"}),e.jsx(me,{children:"Current Stage"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Actions"})]})}),e.jsxs(Es,{children:[A.filter(fe=>Y(fe)||K(fe)).map(fe=>{var Ye,be,_e,ke,qe,Ve,dt,xt,ye,le,Qe,rt;return e.jsxs(ct,{children:[e.jsxs(de,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:fe.requestId}),e.jsx("div",{className:"text-slate-600 text-sm",children:((_e=(be=(Ye=fe.dealer)==null?void 0:Ye.dealerProfile)==null?void 0:be.dealerCode)==null?void 0:_e.dealerCode)||((ke=fe.outlet)==null?void 0:ke.code)||"N/A"})]}),e.jsxs(de,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:((Ve=(qe=fe.dealer)==null?void 0:qe.dealerProfile)==null?void 0:Ve.businessName)||((dt=fe.outlet)==null?void 0:dt.name)||"N/A"}),e.jsx("div",{className:"text-slate-600 text-sm",children:((ye=(xt=fe.dealer)==null?void 0:xt.dealerProfile)==null?void 0:ye.registeredAddress)||((le=fe.outlet)!=null&&le.city&&((Qe=fe.outlet)!=null&&Qe.state)?`${fe.outlet.city}, ${fe.outlet.state}`:((rt=fe.outlet)==null?void 0:rt.address)||"N/A")})]}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae,{className:Ui(fe.currentConstitution||"Proprietorship"),children:fe.currentConstitution||"—"}),e.jsx(To,{className:"w-4 h-4 text-slate-400"}),e.jsx(Ae,{className:Ui(fe.changeType),children:fe.changeType})]})}),e.jsx(de,{children:e.jsx(Ae,{variant:"outline",className:"border-slate-300 text-slate-700",children:fe.currentStage})}),e.jsx(de,{children:e.jsx(Ae,{className:rC(fe.status),children:fe.status})}),e.jsx(de,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(fe.requestId),children:[e.jsx(nn,{className:"w-4 h-4 mr-1"}),"View"]})})]},fe.requestId)}),A.filter(fe=>Y(fe)||K(fe)).length===0&&e.jsx(ct,{children:e.jsx(de,{colSpan:6,className:"text-center py-8 text-slate-500",children:"No pending requests found"})})]})]})})}),e.jsx(Gt,{value:"in-progress",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{className:"bg-slate-50",children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Constitutional Change"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Current Stage"}),e.jsx(me,{children:"Actions"})]})}),e.jsxs(Es,{children:[A.filter(fe=>V(fe)).map(fe=>{var Ye,be,_e,ke,qe,Ve,dt,xt,ye,le,Qe,rt,Kt,Rt,Re;return e.jsxs(ct,{children:[e.jsxs(de,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:fe.requestId}),e.jsx("div",{className:"text-slate-600 text-sm",children:((_e=(be=(Ye=fe.dealer)==null?void 0:Ye.dealerProfile)==null?void 0:be.dealerCode)==null?void 0:_e.dealerCode)||((ke=fe.outlet)==null?void 0:ke.code)||"N/A"})]}),e.jsxs(de,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:((Ve=(qe=fe.dealer)==null?void 0:qe.dealerProfile)==null?void 0:Ve.businessName)||((dt=fe.outlet)==null?void 0:dt.name)||"N/A"}),e.jsx("div",{className:"text-slate-600 text-sm",children:((ye=(xt=fe.dealer)==null?void 0:xt.dealerProfile)==null?void 0:ye.registeredAddress)||((le=fe.outlet)!=null&&le.city&&((Qe=fe.outlet)!=null&&Qe.state)?`${fe.outlet.city}, ${fe.outlet.state}`:((Rt=(Kt=(rt=fe.dealer)==null?void 0:rt.dealerProfile)==null?void 0:Kt.application)==null?void 0:Rt.city)||((Re=fe.outlet)==null?void 0:Re.address)||"N/A")})]}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae,{className:Ui(fe.currentConstitution||"Proprietorship"),children:fe.currentConstitution||"—"}),e.jsx(To,{className:"w-4 h-4 text-slate-400"}),e.jsx(Ae,{className:Ui(fe.changeType),children:fe.changeType})]})}),e.jsx(de,{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 bg-amber-600 transition-all duration-300",style:{width:`${fe.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-slate-600 text-sm",children:[fe.progressPercentage||0,"%"]})]})}),e.jsx(de,{children:e.jsx(Ae,{variant:"outline",className:"border-slate-300 text-slate-700",children:fe.currentStage})}),e.jsx(de,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(fe.requestId),children:[e.jsx(nn,{className:"w-4 h-4 mr-1"}),"View"]})})]},fe.requestId)}),A.filter(fe=>V(fe)).length===0&&e.jsx(ct,{children:e.jsx(de,{colSpan:6,className:"text-center py-8 text-slate-500",children:"No in-progress requests found"})})]})]})})}),e.jsx(Gt,{value:"completed",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{className:"bg-slate-50",children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Constitutional Change"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Submitted On"}),e.jsx(me,{children:"Actions"})]})}),e.jsxs(Es,{children:[A.filter(fe=>O(fe)).map(fe=>{var Ye,be,_e,ke,qe,Ve,dt,xt,ye,le,Qe,rt;return e.jsxs(ct,{children:[e.jsxs(de,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:fe.requestId}),e.jsx("div",{className:"text-slate-600 text-sm",children:((_e=(be=(Ye=fe.dealer)==null?void 0:Ye.dealerProfile)==null?void 0:be.dealerCode)==null?void 0:_e.dealerCode)||((ke=fe.outlet)==null?void 0:ke.code)||"N/A"})]}),e.jsxs(de,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:((Ve=(qe=fe.dealer)==null?void 0:qe.dealerProfile)==null?void 0:Ve.businessName)||((dt=fe.outlet)==null?void 0:dt.name)||"N/A"}),e.jsx("div",{className:"text-slate-600 text-sm",children:((ye=(xt=fe.dealer)==null?void 0:xt.dealerProfile)==null?void 0:ye.registeredAddress)||((le=fe.outlet)!=null&&le.city&&((Qe=fe.outlet)!=null&&Qe.state)?`${fe.outlet.city}, ${fe.outlet.state}`:((rt=fe.outlet)==null?void 0:rt.address)||"N/A")})]}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae,{className:Ui(fe.currentConstitution||"Proprietorship"),children:fe.currentConstitution||"—"}),e.jsx(To,{className:"w-4 h-4 text-slate-400"}),e.jsx(Ae,{className:Ui(fe.changeType),children:fe.changeType})]})}),e.jsx(de,{children:e.jsx(Ae,{className:rC(fe.status),children:fe.status})}),e.jsx(de,{children:e.jsx("div",{className:"text-slate-900",children:Ht(fe.createdAt)})}),e.jsx(de,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(fe.requestId),children:[e.jsx(nn,{className:"w-4 h-4 mr-1"}),"View"]})})]},fe.requestId)}),A.filter(fe=>O(fe)).length===0&&e.jsx(ct,{children:e.jsx(de,{colSpan:6,className:"text-center py-8 text-slate-500",children:"No completed requests found"})})]})]})})})]}),M&&M.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center bg-white rounded-b-lg",children:e.jsx(Yl,{children:e.jsxs(Zl,{children:[e.jsx(an,{children:e.jsx(Ql,{onClick:()=>_(fe=>Math.max(1,fe-1)),className:E===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(M.totalPages)].map((fe,Ye)=>{const be=Ye+1;return be===1||be===M.totalPages||be>=E-1&&be<=E+1?e.jsx(an,{children:e.jsx(Ci,{isActive:E===be,onClick:()=>_(be),className:"cursor-pointer",children:be})},be):be===2&&E>3||be===M.totalPages-1&&E<M.totalPages-2?e.jsx(an,{children:e.jsx(Jl,{})},be):null}),e.jsx(an,{children:e.jsx(Xl,{onClick:()=>_(fe=>Math.min(M.totalPages,fe+1)),className:E===M.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})]})}const Uh={APPROVE:"approve",SEND_BACK:"sendBack",REVOKE:"revoke",REJECT:"reject",WITHDRAWAL:"withdrawal",ASSIGN:"assign",PUSH_FNF:"pushfnf",RECONSIDER:"reconsider",ISSUE_SCN:"issueSCN",SCN_RESPONSE:"scnResponse"},Vh=[{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"}],aC=t=>t==="ZM/RBM Review"?"ZM+RBM Review":t,iC=t=>t==="ZM/RBM"?"ZM+RBM":t,lC={Partnership:[1,2,3,4,8,9,10,16],LLP:[1,2,3,7,8,9,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]},Ro=99,Ed={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",[Ro]:"Other"},oC=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"}},Hh=t=>{const s=String(t||"");return s==="Completed"||s==="Verified"||s==="APPROVED"||s==="COMPLETED"||s==="CREATED"||/^DOCUMENT/i.test(s)?"bg-green-100 text-green-700 border-green-300":s.includes("Revoked")||s==="REVOKED"?"bg-orange-100 text-orange-800 border-orange-300":s.includes("Rejected")||s==="REJECTED"?"bg-red-100 text-red-700 border-red-300":s==="SENT BACK"||s.includes("Review")||s.includes("Pending")||s==="In Progress"||s==="Submitted"?"bg-yellow-100 text-yellow-700 border-yellow-300":"bg-slate-100 text-slate-700 border-slate-300"},hV=t=>{const s=String(t.action||"").toUpperCase(),n=String(t.description||"").toUpperCase(),r=String(t.remarks||"").toUpperCase(),a=t.details||t.newData||{},l=String(a.targetStage||"").toUpperCase(),c=String(a.action||"").toUpperCase(),d=`${s} ${n} ${r} ${c}`.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"}:l==="COMPLETED"||d.includes("COMPLET")?{variant:"success",badge:"COMPLETED"}:l?{variant:"success",badge:"APPROVED"}:{variant:"neutral",badge:s.replace(/_/g," ")||"EVENT"}},cC=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 mV({requestId:t,onBack:s,currentUser:n}){var rt,Kt,Rt,Re,Qt,qt,ws,_s,ns,Cs,Bs,Ft,ie,Fe,Q,pe,Ne,Ee,it,st,bt,Ue,Lt,ut,yt,kt,Ie,_t,ht,zt,rs,Yt,Os,Is,zs,en;const r=qn(),[a,l]=v.useState(!1),[c,d]=v.useState("approve"),[h,x]=v.useState(""),[f,m]=v.useState(!1),[p,u]=v.useState(null),[j,g]=v.useState(null),[y,N]=v.useState("workflow"),[S,C]=v.useState("required"),[w,R]=v.useState(null),[P,A]=v.useState([]),[I,$]=v.useState(!0),[T,E]=v.useState(!1),[_,M]=v.useState(!1),[q,G]=v.useState(!1),[Z,W]=v.useState(null),[z,F]=v.useState(""),[B,D]=v.useState(!1),O=async he=>{if(he)try{const Ge=await Te.getAuditLogs("constitutional_change",he);Ge.data&&Ge.data.success&&A(Ge.data.data||[])}catch(Ge){console.error("Error fetching audit logs:",Ge)}},V=async he=>{try{he!=null&&he.silent||$(!0);const Ge=await Te.getConstitutionalChangeById(t);if(Ge.data.success){const at=Ge.data.request;R(at),await O((at==null?void 0:at.id)||t)}else ee.error("Failed to fetch request details")}catch(Ge){console.error("Fetch request details error:",Ge),ee.error("Error loading request details")}finally{he!=null&&he.silent||$(!1)}};v.useEffect(()=>{V()},[t]);const K=v.useMemo(()=>P.length>0?P:((w==null?void 0:w.timeline)||[]).map((Ge,at)=>({id:`timeline-${at}`,action:String(Ge.action||"UPDATED"),description:Ge.remarks||Ge.action||"Updated",stage:Ge.stage||null,userName:Ge.user||Ge.userName||"System",remarks:Ge.remarks,timestamp:Ge.timestamp||Ge.createdAt})),[P,w==null?void 0:w.timeline]),Y=v.useMemo(()=>{const he=cC(String((w==null?void 0:w.changeType)||"")),at=[...lC[he]||[]];return at.includes(Ro)||at.push(Ro),at.sort((pt,mt)=>pt===Ro?1:mt===Ro?-1:pt-mt)},[w==null?void 0:w.changeType]);if(I)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:[e.jsx(ss,{className:"w-8 h-8 text-amber-600 animate-spin"}),e.jsx("p",{className:"text-slate-600",children:"Loading request details..."})]});if(!w)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 U=cC(w.changeType),X=lC[U]||[],ne=he=>{const Ge=w.documents||[],at=Ed[he];return Ge.find(pt=>{const mt=Number(pt==null?void 0:pt.docNumber);return!!(!Number.isNaN(mt)&&mt===he||at&&typeof(pt==null?void 0:pt.name)=="string"&&pt.name.includes(at))})},oe=he=>{const Ge=ne(he);return!!Ge&&String(Ge.status||"")!=="Rejected"},ge=(()=>{let he=w.currentStage||"";if(["Rejected","Revoked","Withdrawn"].includes(w.status)&&(he==="Rejected"||he==="Revoked"||!he)){const pt=[...w.timeline||[]].reverse().find(mt=>mt.stage&&!["Rejected","Revoked","REJECTED","REVOKED"].includes(mt.stage));pt&&(he=pt.stage)}const Ge={"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(Ge[he])return Ge[he];const at=he.trim().toLowerCase();for(const[pt,mt]of Object.entries(Ge))if(pt.toLowerCase()===at||pt.toLowerCase().includes(at)||at.includes(pt.toLowerCase()))return mt;return 1})(),ve=w.currentStage==="Completed"||String(w.status||"")==="Completed"&&!["Rejected","Revoked"].includes(String(w.currentStage||"")),Se=["Rejected","Revoked"].includes(String(w.status||""))||["Rejected","Revoked"].includes(String(w.currentStage||"")),We=he=>{const at={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"]}[he]||[he],pt=(w.timeline||[]).filter(mt=>{const Bt=String(mt.stage||mt.targetStage||"").trim();return at.includes(Bt)});return pt.length?pt[pt.length-1]:null},fe=(()=>{var Qs,zn;if(!w||!n)return{canApprove:!1,canReject:!1,canSendBack:!1,canRevoke:!1,isFinalState:!1,hasCurrentUserApprovedZmRbm:!1};const he=w.currentStage,Ge=w.status,at=n.role||n.roleCode,pt=String(n.roleCode||n.role||"").trim().toUpperCase(),mt=["Completed","Rejected","Revoked"].includes(String(Ge||""))||["Rejected","Revoked","Completed"].includes(String(he||"")),Bt=Vh.find(on=>on.name===he||on.key===he),Ds=he==="Submitted",as=n.roleCode==="SUPER_ADMIN"||Ds&&(at==="ASM"||n.roleCode==="ASM")||!Ds&&((Bt==null?void 0:Bt.role)==="ASM"&&at==="ASM"||((Bt==null?void 0:Bt.role)==="ZM/RBM"||(Bt==null?void 0:Bt.role)==="ZM+RBM")&&(at==="DD-ZM"||at==="RBM")||(Bt==null?void 0:Bt.role)==="ZBH"&&at==="ZBH"||(Bt==null?void 0:Bt.role)==="DD Lead"&&at==="DD Lead"||(Bt==null?void 0:Bt.role)==="DD Head"&&at==="DD Head"||(Bt==null?void 0:Bt.role)==="NBH"&&at==="NBH"||(Bt==null?void 0:Bt.role)==="Legal Team"&&at==="Legal Admin"),Vs=["ZBH","DD Lead","DD Head","NBH"],Ls=as&&!mt&&(n.roleCode==="SUPER_ADMIN"||Vs.includes(at))&&he!=="Legal Review"&&he!=="Submitted";let Ts=w.metadata||{};if(typeof Ts=="string")try{Ts=JSON.parse(Ts)}catch(on){console.error("Failed to parse metadata",on),Ts={}}const ln=((Qs=Ts==null?void 0:Ts.jointApprovals)==null?void 0:Qs.zmRbm)||{},pn=he==="ZM/RBM Review"||he==="ZM+RBM Review",hn=pt==="RBM"?"RBM":pt==="DD-ZM"||pt==="DD ZM"||pt==="ZM"?"DD-ZM":null,Ws=pn&&hn&&!!((zn=ln==null?void 0:ln[hn])!=null&&zn.approvedByUserId);return{canApprove:as&&!mt&&!Ws,canReject:as&&!mt&&!Ws,canSendBack:Ls,canRevoke:Ls,isFinalState:mt,hasCurrentUserApprovedZmRbm:Ws}})(),Ye=(rt=w.dealer)==null?void 0:rt.dealerProfile,be=Ye==null?void 0:Ye.application,_e=((be==null?void 0:be.loiRequests)||[]).find(he=>/approved/i.test(String((he==null?void 0:he.status)||""))),ke=((be==null?void 0:be.loaRequests)||[]).find(he=>/approved/i.test(String((he==null?void 0:he.status)||""))),qe=(Ye==null?void 0:Ye.loiDate)??(_e==null?void 0:_e.approvedAt),Ve=(Ye==null?void 0:Ye.loaDate)??(ke==null?void 0:ke.approvedAt),dt=he=>{d(he),l(!0)},xt=async he=>{var pt,mt;he.preventDefault();const Ge=String(h||"").trim();if((c==="sendBack"||c==="revoke")&&Ge.length<5){ee.error("Detailed remarks (minimum 5 characters) are required for Send Back and Revoke actions.");return}if(!Ge&&c!=="approve"){ee.error("Remarks are required for this action.");return}try{E(!0);const Bt=c==="approve"?Uh.APPROVE:c==="reject"?Uh.REJECT:c==="sendBack"?Uh.SEND_BACK:Uh.REVOKE;if((await Te.updateConstitutionalChange(t,Bt,{comments:h})).data.success){const as=c==="approve"?"approved":c==="reject"?"rejected":c==="sendBack"?"sent back":"revoked";ee.success(`Request ${as} successfully`),l(!1),x(""),await V()}}catch(Bt){console.error("Submit action error:",Bt);const Ds=((mt=(pt=Bt==null?void 0:Bt.response)==null?void 0:pt.data)==null?void 0:mt.message)||"Failed to submit action";ee.error(Ds)}finally{E(!1)}},ye=async()=>{var he;if(!p||!j){ee.error("Please select document type and file");return}try{M(!0);const Ge=Array.isArray(w.documents)?[...w.documents]:[],pt=p!==Ro?Ge.findIndex(Ds=>Number(Ds==null?void 0:Ds.docNumber)===p):-1,mt={docNumber:p,name:Ed[p]||"Other",fileName:j.name,status:"Pending Verification",uploadedOn:new Date().toISOString(),uploadedBy:(n==null?void 0:n.name)||"Dealer"};pt>=0?Ge[pt]={...Ge[pt],...mt}:Ge.push(mt),(he=(await Te.uploadConstitutionalDocuments(t,Ge)).data)!=null&&he.success?(ee.success("Document uploaded successfully"),m(!1),u(null),g(null),await V({silent:!0})):ee.error("Failed to upload document")}catch(Ge){console.error("Upload document error:",Ge),ee.error("Failed to upload document")}finally{M(!1)}},le=async(he,Ge)=>{var at;try{const mt=(Array.isArray(w.documents)?[...w.documents]:[]).map((Ds,as)=>{const Vs=as===Ge,Ls=he.docNumber&&Ds.docNumber===he.docNumber;return Vs||Ls?{...Ds,status:"Verified",verifiedOn:new Date().toISOString(),verifiedBy:(n==null?void 0:n.name)||"System"}:Ds});(at=(await Te.uploadConstitutionalDocuments(t,mt)).data)!=null&&at.success?(ee.success("Document verified successfully"),V()):ee.error("Failed to verify document")}catch(pt){console.error("Verify document error:",pt),ee.error("Failed to verify document")}},Qe=async()=>{var he;if(Z==null||!String(z).trim()){ee.error("Please enter a rejection reason (SRS document verification).");return}try{D(!0);const at=(Array.isArray(w.documents)?[...w.documents]:[]).map((mt,Bt)=>Bt!==Z?mt:{...mt,status:"Rejected",rejectedOn:new Date().toISOString(),rejectedBy:(n==null?void 0:n.fullName)||"System",rejectionReason:z.trim()});(he=(await Te.uploadConstitutionalDocuments(t,at)).data)!=null&&he.success?(ee.success("Document marked as rejected"),G(!1),W(null),F(""),await V({silent:!0})):ee.error("Failed to reject document")}catch(Ge){console.error("Reject document error:",Ge),ee.error("Failed to reject document")}finally{D(!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($r,{className:"w-4 h-4"}),"Back"]}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-slate-900",children:[w.requestId," - Constitutional Change Details"]}),e.jsxs("p",{className:"text-slate-600",children:[((Rt=(Kt=w.dealer)==null?void 0:Kt.dealerProfile)==null?void 0:Rt.businessName)||((Re=w.outlet)==null?void 0:Re.name)||"N/A"," (",((ws=(qt=(Qt=w.dealer)==null?void 0:Qt.dealerProfile)==null?void 0:qt.dealerCode)==null?void 0:ws.dealerCode)||((_s=w.outlet)==null?void 0:_s.code)||"N/A",")"]})]})]}),e.jsx(Ae,{className:Hh(w.status),children:w.status})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Request Overview"})}),e.jsxs(Me,{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:((Cs=(ns=w.dealer)==null?void 0:ns.dealerProfile)==null?void 0:Cs.businessName)||((Bs=w.outlet)==null?void 0:Bs.name)||"N/A"}),e.jsx("p",{className:"text-slate-600 text-sm",children:((Fe=(ie=(Ft=w.dealer)==null?void 0:Ft.dealerProfile)==null?void 0:ie.dealerCode)==null?void 0:Fe.dealerCode)||((Q=w.outlet)==null?void 0:Q.code)||"N/A"}),e.jsx("p",{className:"text-slate-600 text-sm",children:((Ne=(pe=w.dealer)==null?void 0:pe.dealerProfile)==null?void 0:Ne.registeredAddress)||((Ee=w.outlet)==null?void 0:Ee.city)||((it=w.outlet)==null?void 0:it.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(Ae,{className:oC(w.oldValue||w.currentConstitution||((st=w.outlet)==null?void 0:st.type)||"Proprietorship"),children:w.oldValue||w.currentConstitution||((bt=w.outlet)==null?void 0:bt.type)||"Proprietorship"}),e.jsx(To,{className:"w-4 h-4 text-slate-400"}),e.jsx(Ae,{className:oC(w.newValue||w.changeType),children:w.newValue||w.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: ",Ht(w.createdAt)]}),e.jsxs("p",{className:"text-slate-600 text-sm",children:["By: ",((Ue=w.dealer)==null?void 0:Ue.fullName)||"Dealer"]}),e.jsxs("p",{className:"text-slate-900 text-sm mt-2",children:["Current Stage: ",w.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:w.description})]})]})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Establishment & Dealer Codes"})}),e.jsx(Me,{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=(ut=(Lt=w.dealer)==null?void 0:Lt.dealerProfile)==null?void 0:ut.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:((_t=(Ie=(kt=w.dealer)==null?void 0:kt.dealerProfile)==null?void 0:Ie.dealerCode)==null?void 0:_t.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:((rs=(zt=(ht=w.dealer)==null?void 0:ht.dealerProfile)==null?void 0:zt.dealerCode)==null?void 0:rs.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:((Is=(Os=(Yt=w.dealer)==null?void 0:Yt.dealerProfile)==null?void 0:Os.dealerCode)==null?void 0:Is.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:(en=(zs=w.dealer)==null?void 0:zs.dealerProfile)!=null&&en.onboardedAt?Ht(w.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:qe?Ht(qe,"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:Ve?Ht(Ve,"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(Pn,{value:y,onValueChange:N,className:"w-full",children:[e.jsx(tt,{className:"pb-4",children:e.jsx("div",{className:"overflow-x-auto -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(Me,{children:[e.jsxs(Gt,{value:"workflow",className:"mt-0",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("span",{className:"text-slate-600",children:[w.progressPercentage,"%"]})]}),e.jsx("div",{className:"h-3 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-amber-600 transition-all duration-500",style:{width:`${w.progressPercentage}%`}})})]}),Se&&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(w.status)}),". The approval path below is for reference only."]}),e.jsx("div",{className:"space-y-4",children:Se?e.jsx("ul",{className:"list-disc space-y-1 pl-5 text-sm text-slate-600",children:Vh.map(he=>e.jsxs("li",{children:[e.jsx("span",{className:"text-slate-900",children:aC(he.name)})," — ",iC(he.role)]},he.id))}):Vh.map((he,Ge)=>{var hn;const at=ve||Ge<ge-1,pt=!ve&&Ge===ge-1,mt=We(he.name),Bt=(mt==null?void 0:mt.comments)||(mt==null?void 0:mt.feedback)||(mt==null?void 0:mt.remarks),Ds=he.name==="ZM/RBM Review";let as=w.metadata||{};if(typeof as=="string")try{as=JSON.parse(as)}catch{as={}}const Vs=((hn=as==null?void 0:as.jointApprovals)==null?void 0:hn.zmRbm)||{},Ls=Vs==null?void 0:Vs.RBM,Ts=Vs==null?void 0:Vs["DD-ZM"],ln=String((n==null?void 0:n.roleCode)||(n==null?void 0:n.role)||"").toUpperCase(),pn=ln==="RBM"?Ls:ln==="DD-ZM"||ln==="DD ZM"||ln==="ZM"?Ts: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 ${at?"bg-green-100":pt?"bg-amber-100":"bg-slate-100"}`,children:at?e.jsx(Fn,{className:"w-5 h-5 text-green-600"}):pt?e.jsx(Js,{className:"w-5 h-5 text-amber-600"}):e.jsx(Ks,{className:"w-5 h-5 text-slate-400"})}),Ge<Vh.length-1&&e.jsx("div",{className:`w-0.5 h-12 ${at?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:`flex-1 pb-8 ${pt?"bg-amber-50 -ml-4 pl-4 pr-4 py-3 rounded-lg border border-amber-200":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:`${pt?"text-amber-900":"text-slate-900"}`,children:aC(he.name)}),e.jsx("p",{className:`text-sm ${pt?"text-amber-700":"text-slate-600"}`,children:`Responsible: ${iC(he.role)}`})]}),e.jsx(Ae,{className:at?"bg-green-100 text-green-700 border-green-300":pt?"bg-amber-100 text-amber-700 border-amber-300":"bg-slate-100 text-slate-500 border-slate-300",children:at?"Completed":pt?"In Progress":"Pending"})]}),mt&&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(Ae,{variant:"outline",className:"text-[11px] normal-case",children:["Last updated by: ",mt.user||mt.userName||"System"]}),e.jsx("span",{children:Ht(mt.timestamp||mt.createdAt)})]}),Bt&&e.jsx("div",{className:"p-2 rounded border border-slate-200 bg-slate-50 text-sm text-slate-700",children:Bt})]}),Ds&&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(Ae,{className:Ls!=null&&Ls.approvedByUserId?"bg-green-100 text-green-700 border-green-300":"bg-slate-100 text-slate-500 border-slate-300",children:["RBM: ",Ls!=null&&Ls.approvedByUserId?"Approved":"Pending"]}),e.jsxs(Ae,{className:Ts!=null&&Ts.approvedByUserId?"bg-green-100 text-green-700 border-green-300":"bg-slate-100 text-slate-500 border-slate-300",children:["DD-ZM: ",Ts!=null&&Ts.approvedByUserId?"Approved":"Pending"]}),(pn==null?void 0:pn.approvedByUserId)&&e.jsx(Ae,{className:"bg-blue-100 text-blue-700 border-blue-300",children:"Approved by you"})]}),((Ls==null?void 0:Ls.remarks)||(Ts==null?void 0:Ts.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:(Ls==null?void 0:Ls.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:(Ts==null?void 0:Ts.remarks)||"-"})]})]})]})]})]},he.id)})})]}),e.jsx(Gt,{value:"documents",className:"mt-0",children:e.jsxs(Pn,{value:S,onValueChange:C,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(Gt,{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(os,{open:f,onOpenChange:m,children:[e.jsx(Hl,{asChild:!0,children:e.jsxs(se,{size:"sm",className:"bg-amber-600 hover:bg-amber-700",children:[e.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Upload Document"]})}),e.jsxs(ls,{children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Upload Document"}),e.jsx(vs,{children:"Select the document type and upload the file"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ce,{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-amber-500 focus-visible:ring-offset-2",value:p!=null?String(p):"",onChange:he=>{const Ge=he.target.value;u(Ge?Number(Ge):null)},children:[e.jsx("option",{value:"",children:"Select document type"}),Y.map(he=>e.jsxs("option",{value:String(he),children:[he!==Ro&&oe(he)?"✓ ":"",Ed[he]||`Document ${he}`]},he))]})]}),e.jsxs("div",{children:[e.jsx(ce,{children:"Upload File"}),e.jsx(ot,{type:"file",className:"mt-1",onChange:he=>{var Ge;return g(((Ge=he.target.files)==null?void 0:Ge[0])||null)}})]})]}),e.jsxs(rn,{children:[e.jsx(se,{variant:"outline",onClick:()=>m(!1),children:"Cancel"}),e.jsx(se,{className:"bg-amber-600 hover:bg-amber-700",onClick:ye,disabled:_,children:_?"Uploading...":"Upload"})]})]})]})]}),e.jsx("div",{className:"space-y-2",children:X.map(he=>{const Ge=ne(he),at=Ge&&String(Ge.status)==="Rejected",pt=Ge&&!at;return e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${at?"bg-red-50 border-red-200":pt?"bg-green-50 border-green-200":"bg-slate-50 border-slate-200"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[at?e.jsx(Ks,{className:"w-5 h-5 text-red-600"}):pt?e.jsx(Fn,{className:"w-5 h-5 text-green-600"}):e.jsx(Ks,{className:"w-5 h-5 text-slate-400"}),e.jsxs("div",{children:[e.jsx("p",{className:at?"text-red-900":pt?"text-green-900":"text-slate-900",children:Ed[he]}),Ge&&e.jsxs("p",{className:at?"text-red-700 text-sm":pt?"text-green-700 text-sm":"text-slate-600 text-sm",children:[Ge.fileName||Ge.name,at&&Ge.rejectionReason?` — ${Ge.rejectionReason}`:""]})]})]}),Ge?e.jsx(Ae,{className:Hh(Ge.status),children:Ge.status}):e.jsx(Ae,{className:"bg-slate-100 text-slate-600 border-slate-300",children:"Not Uploaded"})]},he)})})]})}),e.jsx(Gt,{value:"existing",className:"mt-0",children:(w.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(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{className:"bg-slate-50",children:[e.jsx(me,{children:"Document Name"}),e.jsx(me,{children:"File Name"}),e.jsx(me,{children:"Uploaded On"}),e.jsx(me,{children:"Uploaded By"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Es,{children:(w.documents||[]).map((he,Ge)=>{var at;return e.jsxs(ct,{children:[e.jsx(de,{className:"text-slate-900",children:he.docNumber?Ed[he.docNumber]:he.name}),e.jsx(de,{className:"text-slate-600",children:he.fileName||he.name}),e.jsx(de,{className:"text-slate-600",children:Ht(he.uploadedOn||he.createdAt)}),e.jsx(de,{className:"text-slate-600",children:typeof he.uploadedBy=="string"?he.uploadedBy:((at=he.uploadedBy)==null?void 0:at.fullName)||"Dealer"}),e.jsx(de,{children:e.jsx(Ae,{className:Hh(he.status),children:he.status})}),e.jsx(de,{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(nn,{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(Ni,{className:"w-4 h-4"})}),he.status!=="Verified"&&he.status!=="Rejected"&&(()=>{const pt=(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(pt)})()&&e.jsxs(e.Fragment,{children:[e.jsx(se,{size:"sm",className:"bg-green-600 hover:bg-green-700",onClick:()=>le(he,Ge),children:"Verify"}),e.jsx(se,{size:"sm",variant:"outline",className:"border-red-300 text-red-700 hover:bg-red-50",onClick:()=>{W(Ge),F(""),G(!0)},children:"Reject"})]})]})})]},Ge)})})]})})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded yet"})})]})}),e.jsx(Gt,{value:"history",className:"mt-0",children:e.jsxs("div",{className:"space-y-4",children:[K.map((he,Ge)=>{var Ws;const at=hV(he),mt=(((Ws=he.actor)==null?void 0:Ws.name)||he.userName||"System").split("·").map(Qs=>Qs.trim()),Bt=[...new Set(mt)].join(", "),Vs=String(he.stage||he.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()||at.badge||"Action",Ls=String(he.remarks||"").trim(),Ts=String(he.description||"").trim(),pn=[/^Approval\s*-\s*Stage:/i,/^Record (created|updated)/i,/^Document (uploaded|verified|rejected)/i].some(Qs=>Qs.test(Ts)),hn=Ls||(pn?"":Ts)||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 ${at.variant==="success"?"bg-green-100":at.variant==="danger"?"bg-red-100":at.variant==="pending"?"bg-amber-100":"bg-slate-100"}`,children:at.variant==="success"?e.jsx(Fn,{className:"w-5 h-5 text-green-600"}):at.variant==="danger"?e.jsx(Ks,{className:"w-5 h-5 text-red-600"}):at.variant==="pending"?e.jsx(Js,{className:"w-5 h-5 text-amber-600"}):e.jsx(Js,{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:Vs}),e.jsxs("p",{className:"text-slate-500 text-sm",children:["by ",e.jsx("span",{className:"font-medium text-slate-700",children:Bt})]})]}),e.jsx(Ae,{className:Hh(at.badge),children:at.badge.replace(/_/g," ")})]}),hn&&e.jsx("div",{className:"mt-2 p-3 bg-slate-50 rounded border border-slate-100 text-slate-700 text-sm",children:hn}),e.jsx("p",{className:"text-slate-400 text-xs mt-2 font-medium uppercase tracking-wider",children:Ht(he.timestamp||he.createdAt)})]})]},he.id||Ge)}),K.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(tt,{children:e.jsx(nt,{children:"Current Status"})}),e.jsx(Me,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Current Stage"}),e.jsx("p",{className:"text-slate-900",children:w.currentStage})]})})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Actions"})}),e.jsxs(Me,{className:"space-y-3",children:[fe.canApprove&&e.jsxs(se,{className:"w-full bg-green-600 hover:bg-green-700",onClick:()=>dt("approve"),disabled:T,children:[T&&c==="approve"?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Fn,{className:"w-4 h-4 mr-2"}),"Approve Request"]}),!fe.canApprove&&fe.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(Fn,{className:"w-4 h-4 mr-2"}),"Approved by you"]}),fe.canReject&&e.jsxs(se,{variant:"destructive",className:"w-full",onClick:()=>dt("reject"),disabled:T,children:[T&&c==="reject"?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Ks,{className:"w-4 h-4 mr-2"}),"Reject proposal"]}),fe.canSendBack&&e.jsxs(se,{variant:"outline",className:"w-full border-amber-300 text-amber-900 hover:bg-amber-50",onClick:()=>dt("sendBack"),disabled:T,children:[T&&c==="sendBack"?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(xI,{className:"w-4 h-4 mr-2"}),"Send back"]}),fe.canRevoke&&e.jsxs(se,{variant:"outline",className:"w-full border-orange-300 text-orange-900 hover:bg-orange-50",onClick:()=>dt("revoke"),disabled:T,children:[T&&c==="revoke"?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Yv,{className:"w-4 h-4 mr-2"}),"Revoke request"]}),!fe.canApprove&&!fe.canReject&&!fe.canSendBack&&!fe.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:fe.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 he;return r(`/worknotes/constitutional/${(w==null?void 0:w.id)||t}`,{state:{requestType:"constitutional",applicationName:((he=w==null?void 0:w.outlet)==null?void 0:he.name)||"Constitutional Change",registrationNumber:(w==null?void 0:w.requestId)||t||"",participants:(w==null?void 0:w.participants)||[]}})},children:[e.jsx(zr,{className:"w-4 h-4 mr-2"}),"Worknotes (",((w==null?void 0:w.worknotes)||[]).length,")"]})})]})]})]})]}),e.jsx(os,{open:a,onOpenChange:l,children:e.jsxs(ls,{children:[e.jsxs(ms,{children:[e.jsx(us,{children:c==="approve"?"Approve request":c==="reject"?"Reject proposal":c==="sendBack"?"Send back to previous stage":"Revoke request"}),e.jsx(vs,{children:c==="sendBack"||c==="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:xt,className:"space-y-4",children:[e.jsx("div",{children:e.jsx(ce,{htmlFor:"comments",children:c==="sendBack"||c==="revoke"?"Remarks (required) *":"Comments *"})}),e.jsx(Fs,{id:"comments",value:h,onChange:he=>x(he.target.value),placeholder:c==="sendBack"||c==="revoke"?"Enter mandatory remarks for Work Notes…":"Enter your comments…",rows:4,required:c!=="approve"}),e.jsxs(rn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(se,{type:"submit",className:c==="approve"?"bg-green-600 hover:bg-green-700":c==="reject"?"bg-red-600 hover:bg-red-700":c==="sendBack"?"bg-amber-600 hover:bg-amber-700":"bg-orange-600 hover:bg-orange-700",disabled:T,children:T?e.jsxs(e.Fragment,{children:[e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}),"Processing..."]}):c==="approve"?"Approve":c==="reject"?"Reject":c==="sendBack"?"Send back":"Revoke"})]})]})]})}),e.jsx(os,{open:q,onOpenChange:G,children:e.jsxs(ls,{children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Reject document"}),e.jsx(vs,{children:"Per SRS relocation-style verification states, mark this upload as Rejected and provide a reason for the dealer."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ce,{htmlFor:"rejectReason",children:"Rejection reason *"}),e.jsx(Fs,{id:"rejectReason",rows:4,value:z,onChange:he=>F(he.target.value),placeholder:"Explain what must be corrected or re-uploaded…"})]}),e.jsxs(rn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>G(!1),children:"Cancel"}),e.jsx(se,{type:"button",variant:"destructive",disabled:B,onClick:()=>void Qe(),children:B?e.jsx(ss,{className:"w-4 h-4 animate-spin"}):"Confirm reject"})]})]})})]})}const fV=(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},O0=t=>t==="Completed"||t==="Closed"?"bg-green-100 text-green-700 border-green-300":t.includes("Review")||t.includes("Pending")||t==="In Progress"?"bg-yellow-100 text-yellow-700 border-yellow-300":t.includes("Rejected")||t.includes("Revoked")?"bg-red-100 text-red-700 border-red-300":t.includes("Collection")||t.includes("Completion")||t.includes("Infra")?"bg-blue-100 text-blue-700 border-blue-300":"bg-slate-100 text-slate-700 border-slate-300";function pV({currentUser:t,onViewDetails:s}){const[n,r]=v.useState([]),[a,l]=v.useState(!0),[c,d]=v.useState(1),[h,x]=v.useState(null),[f,m]=v.useState("all"),p=10,[u,j]=v.useState(!1),[g,y]=v.useState([]),[N,S]=v.useState(null),[C,w]=v.useState(""),[R,P]=v.useState(""),[A,I]=v.useState(""),[$,T]=v.useState(""),[E,_]=v.useState(""),[M,q]=v.useState(""),[G,Z]=v.useState(""),[W,z]=v.useState(""),[F,B]=v.useState(""),[D,O]=v.useState(!1),[V,K]=v.useState([]),[Y,U]=v.useState([]),[X,ne]=v.useState(""),[oe,re]=v.useState(""),[ge,ve]=v.useState(!1),Se=(t==null?void 0:t.role)==="Super Admin"||(t==null?void 0:t.roleCode)==="Super Admin",We=le=>le.status==="Completed"||le.status==="Closed"||le.currentStage==="Completed",Ce=le=>le.status==="Rejected"||le.status==="Revoked"||le.currentStage==="Rejected",fe=le=>!We(le)&&!Ce(le)&&String(le.status||"").startsWith("Pending");v.useEffect(()=>{xt()},[c,f]),v.useEffect(()=>{Se&&(be(),_e())},[Se]);const Ye=le=>{m(le),d(1)},be=async()=>{var le;try{const Qe=await Te.getOutlets();Qe.data.success&&y(Qe.data.outlets||((le=Qe.data.data)==null?void 0:le.outlets)||Qe.data.data||[])}catch(Qe){console.error("Fetch outlets error:",Qe)}},_e=async()=>{var le,Qe,rt,Kt;try{ve(!0);const[Rt,Re]=await Promise.all([Te.getStates().catch(()=>({success:!1})),Te.getDistricts({limit:"all"}).catch(()=>({success:!1}))]),Qt=(le=Rt==null?void 0:Rt.data)!=null&&le.success?((Qe=Rt.data.data)==null?void 0:Qe.states)||Rt.data.data||[]:[],qt=(rt=Re==null?void 0:Re.data)!=null&&rt.success?((Kt=Re.data.data)==null?void 0:Kt.districts)||Re.data.data||[]:[];K(Qt),U(qt)}catch(Rt){console.error("Fetch master data error:",Rt)}finally{ve(!1)}},ke=le=>{ne(le),re("");const Qe=V.find(rt=>rt.id===le);Qe&&P(Qe.name)},qe=le=>{re(le);const Qe=Y.find(rt=>rt.id===le);Qe&&w(Qe.name)},Ve=async le=>{if(le.preventDefault(),!N||!C||!R||!A||!$||!E||!M||!G){ee.error("Please fill all mandatory fields");return}try{O(!0);const Qe={outletId:N.id,relocationType:"Intercity",currentAddress:N.address||"",currentCity:N.city||"",currentState:N.state||"",newAddress:A,newCity:C,newState:R,newDistrictId:oe||null,newStateId:X||null,reason:$,distance:E,propertyType:M,proposedDate:G,newLatitude:W?parseFloat(W):null,newLongitude:F?parseFloat(F):null,currentLatitude:N.latitude||null,currentLongitude:N.longitude||null};(await Te.createRelocationRequest(Qe)).data.success&&(ee.success(`Relocation request submitted successfully for ${N.name}`),j(!1),xt(),S(null),w(""),P(""),I(""),T(""),_(""),q(""),Z(""),z(""),B(""))}catch(Qe){console.error("Submit relocation error:",Qe),ee.error(fV(Qe,"Failed to submit relocation request"))}finally{O(!1)}},dt=X?Y.filter(le=>le.stateId===X):Y,xt=async()=>{try{l(!0);const le=await Te.getRelocationRequests({page:c,limit:p,status:f==="all"?void 0:f});le.data.success&&(r(le.data.requests),x(le.meta))}catch(le){console.error("Fetch relocation requests error:",le),ee.error("Failed to fetch relocation requests")}finally{l(!1)}},ye=[{title:"Total Requests",value:n.length,icon:fs,color:"bg-blue-500"},{title:"Pending Review",value:n.filter(le=>fe(le)).length,icon:$n,color:"bg-yellow-500"},{title:"Completed",value:n.filter(le=>We(le)).length,icon:Er,color:"bg-green-500"},{title:"Rejected / Revoked",value:n.filter(le=>Ce(le)).length,icon:Dc,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."})]}),Se&&e.jsxs(os,{open:u,onOpenChange:j,children:[e.jsx(Hl,{asChild:!0,children:e.jsxs(se,{className:"bg-amber-600 hover:bg-amber-700 text-white",children:[e.jsx(cn,{className:"w-4 h-4 mr-2"}),"New Relocation Request"]})}),e.jsxs(ls,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Submit Relocation Request"}),e.jsx(vs,{children:"Create a new relocation request on behalf of a dealer"})]}),e.jsxs("form",{onSubmit:Ve,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"outlet",children:"Select Outlet to Relocate *"}),e.jsxs(wt,{value:N==null?void 0:N.id,onValueChange:le=>S(g.find(Qe=>Qe.id===le)),required:!0,children:[e.jsx(Ct,{children:e.jsx(St,{placeholder:"Select an outlet"})}),e.jsx(At,{children:g.map(le=>e.jsxs(Pe,{value:le.id,children:[le.name," (",le.code,")"]},le.id))})]})]}),N&&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:[N.address,", ",N.city,", ",N.state," - ",N.pincode]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"newState",children:"Proposed State *"}),e.jsxs(wt,{value:X,onValueChange:ke,required:!0,disabled:ge,children:[e.jsx(Ct,{id:"newState",children:e.jsx(St,{placeholder:ge?"Loading...":"Select state"})}),e.jsx(At,{children:V.map(le=>e.jsx(Pe,{value:le.id,children:le.name},le.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"newCity",children:"Proposed City/District *"}),e.jsxs(wt,{value:oe,onValueChange:qe,required:!0,disabled:!X||ge,children:[e.jsx(Ct,{id:"newCity",children:e.jsx(St,{placeholder:X?ge?"Loading...":"Select district":"Select state first"})}),e.jsx(At,{children:dt.map(le=>e.jsx(Pe,{value:le.id,children:le.name},le.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"newAddress",children:"Proposed Full Address *"}),e.jsx(Fs,{id:"newAddress",placeholder:"Enter detailed address of the proposed new location...",value:A,onChange:le=>I(le.target.value),rows:3,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"distance",children:"Estimated Distance from Current Location (in km) *"}),e.jsx(ot,{id:"distance",type:"text",placeholder:"e.g. 5.5 km",value:E,onChange:le=>_(le.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(ce,{htmlFor:"propertyType",children:"Property Type *"}),e.jsxs(wt,{value:M,onValueChange:q,required:!0,children:[e.jsx(Ct,{id:"propertyType",children:e.jsx(St,{placeholder:"Select type"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"Owned",children:"Owned"}),e.jsx(Pe,{value:"Leased",children:"Leased"}),e.jsx(Pe,{value:"Rented",children:"Rented"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"expectedDate",children:"Expected Relocation Date *"}),e.jsx(ot,{id:"expectedDate",type:"date",value:G,onChange:le=>Z(le.target.value),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"reason",children:"Reason for Relocation *"}),e.jsx(Fs,{id:"reason",placeholder:"Why is this relocation requested?",value:$,onChange:le=>T(le.target.value),rows:4,required:!0})]}),e.jsxs(rn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>j(!1),children:"Cancel"}),e.jsx(se,{type:"submit",className:"bg-amber-600 hover:bg-amber-700 text-white",disabled:D,children:D?e.jsxs(e.Fragment,{children:[e.jsx(ss,{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:ye.map((le,Qe)=>{const rt=le.icon;return e.jsx(Le,{children:e.jsx(Me,{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:le.title}),e.jsx("p",{className:"text-slate-900 text-2xl mt-1",children:le.value})]}),e.jsx("div",{className:`${le.color} w-12 h-12 rounded-lg flex items-center justify-center`,children:e.jsx(rt,{className:"w-6 h-6 text-white"})})]})})},Qe)})}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"Relocation Requests"}),e.jsx(Zt,{children:"Track and manage all dealership relocation requests across all stages"})]}),e.jsxs(Me,{children:[e.jsxs(Pn,{value:f,onValueChange:Ye,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(Gt,{value:"all",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{className:"bg-slate-50",children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Relocation Details"}),e.jsx(me,{children:"Distance"}),e.jsx(me,{children:"Current Stage"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Submitted On"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Es,{children:a?e.jsx(ct,{children:e.jsx(de,{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(ss,{className:"w-6 h-6 text-amber-600 animate-spin"}),e.jsx("p",{className:"text-slate-500 text-sm",children:"Loading requests..."})]})})}):n.length===0?e.jsx(ct,{children:e.jsx(de,{colSpan:8,className:"h-32 text-center text-slate-500",children:"No relocation requests found"})}):n.map(le=>{var Qe,rt,Kt;return e.jsxs(ct,{children:[e.jsxs(de,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:le.requestId||le.id}),e.jsx("div",{className:"text-slate-600 text-sm",children:((Qe=le.outlet)==null?void 0:Qe.code)||le.dealerCode})]}),e.jsx(de,{children:e.jsx("div",{className:"font-medium text-slate-900",children:((rt=le.outlet)==null?void 0:rt.name)||le.dealerName})}),e.jsx(de,{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:le.currentLocation})]}),e.jsxs("div",{className:"flex items-center gap-1 text-slate-900 text-sm",children:[e.jsx(q2,{className:"w-3 h-3 text-amber-600"}),e.jsx("span",{className:"text-slate-500",children:"To:"}),e.jsx("span",{children:le.proposedLocation})]})]})}),e.jsx(de,{children:e.jsx(Ae,{variant:"outline",className:"border-slate-300 text-slate-700",children:le.distance})}),e.jsx(de,{children:e.jsx(Ae,{className:`border ${O0(le.currentStage)}`,children:le.currentStage})}),e.jsx(de,{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 bg-amber-600 transition-all duration-300",style:{width:`${le.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-slate-600 text-sm",children:[le.progressPercentage||0,"%"]})]})}),e.jsxs(de,{children:[e.jsx("div",{className:"text-slate-900",children:Ht(le.createdAt)}),e.jsxs("div",{className:"text-slate-600 text-sm",children:["By ",((Kt=le.dealer)==null?void 0:Kt.fullName)||"Dealer"]})]}),e.jsx(de,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(le.id),children:[e.jsx(nn,{className:"w-4 h-4 mr-1"}),"View"]})})]},le.id)})})]})})}),e.jsx(Gt,{value:"pending",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{className:"bg-slate-50",children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Relocation Details"}),e.jsx(me,{children:"Current Stage"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Es,{children:a?e.jsx(ct,{children:e.jsx(de,{colSpan:5,className:"h-32 text-center",children:e.jsx(ss,{className:"w-6 h-6 text-amber-600 animate-spin mx-auto"})})}):n.filter(le=>fe(le)).map(le=>{var Qe,rt;return e.jsxs(ct,{children:[e.jsxs(de,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:le.requestId||le.id}),e.jsx("div",{className:"text-slate-600 text-sm",children:((Qe=le.outlet)==null?void 0:Qe.code)||le.dealerCode})]}),e.jsx(de,{children:e.jsx("div",{className:"font-medium text-slate-900",children:((rt=le.outlet)==null?void 0:rt.name)||le.dealerName})}),e.jsx(de,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-slate-600 text-sm",children:["From: ",le.currentLocation]}),e.jsxs("div",{className:"text-slate-900 text-sm",children:["To: ",le.proposedLocation]})]})}),e.jsx(de,{children:e.jsx(Ae,{className:`border ${O0(le.currentStage)}`,children:le.currentStage})}),e.jsx(de,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(le.id),children:[e.jsx(nn,{className:"w-4 h-4 mr-1"}),"View"]})})]},le.id)})})]})})}),e.jsx(Gt,{value:"in-progress",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{className:"bg-slate-50",children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Relocation Details"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Current Stage"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Es,{children:a?e.jsx(ct,{children:e.jsx(de,{colSpan:6,className:"h-32 text-center",children:e.jsx(ss,{className:"w-6 h-6 text-amber-600 animate-spin mx-auto"})})}):n.filter(le=>Ce(le)).map(le=>{var Qe,rt;return e.jsxs(ct,{children:[e.jsxs(de,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:le.requestId||le.id}),e.jsx("div",{className:"text-slate-600 text-sm",children:((Qe=le.outlet)==null?void 0:Qe.code)||le.dealerCode})]}),e.jsx(de,{children:e.jsx("div",{className:"font-medium text-slate-900",children:((rt=le.outlet)==null?void 0:rt.name)||le.dealerName})}),e.jsx(de,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-slate-600 text-sm",children:["From: ",le.currentLocation]}),e.jsxs("div",{className:"text-slate-900 text-sm",children:["To: ",le.proposedLocation]})]})}),e.jsx(de,{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 bg-red-500 transition-all duration-300",style:{width:`${le.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-slate-600 text-sm",children:[le.progressPercentage||0,"%"]})]})}),e.jsx(de,{children:e.jsx(Ae,{className:`border ${O0(le.currentStage)}`,children:le.currentStage})}),e.jsx(de,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(le.id),children:[e.jsx(nn,{className:"w-4 h-4 mr-1"}),"View"]})})]},le.id)})})]})})}),e.jsx(Gt,{value:"completed",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{className:"bg-slate-50",children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Relocation Details"}),e.jsx(me,{children:"Submitted On"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Es,{children:a?e.jsx(ct,{children:e.jsx(de,{colSpan:5,className:"h-32 text-center",children:e.jsx(ss,{className:"w-6 h-6 text-amber-600 animate-spin mx-auto"})})}):n.filter(le=>We(le)).map(le=>{var Qe,rt;return e.jsxs(ct,{children:[e.jsxs(de,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:le.requestId||le.id}),e.jsx("div",{className:"text-slate-600 text-sm",children:((Qe=le.outlet)==null?void 0:Qe.code)||le.dealerCode})]}),e.jsx(de,{children:e.jsx("div",{className:"font-medium text-slate-900",children:((rt=le.outlet)==null?void 0:rt.name)||le.dealerName})}),e.jsx(de,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-slate-600 text-sm",children:["From: ",le.currentLocation]}),e.jsxs("div",{className:"text-slate-900 text-sm",children:["To: ",le.proposedLocation]})]})}),e.jsx(de,{children:e.jsx("div",{className:"text-slate-900",children:Ht(le.createdAt)})}),e.jsx(de,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(le.id),children:[e.jsx(nn,{className:"w-4 h-4 mr-1"}),"View"]})})]},le.id)})})]})})})]}),h&&h.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center bg-white rounded-b-lg",children:e.jsx(Yl,{children:e.jsxs(Zl,{children:[e.jsx(an,{children:e.jsx(Ql,{onClick:()=>d(le=>Math.max(1,le-1)),className:c===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(h.totalPages)].map((le,Qe)=>{const rt=Qe+1;return rt===1||rt===h.totalPages||rt>=c-1&&rt<=c+1?e.jsx(an,{children:e.jsx(Ci,{isActive:c===rt,onClick:()=>d(rt),className:"cursor-pointer",children:rt})},rt):rt===2&&c>3||rt===h.totalPages-1&&c<h.totalPages-2?e.jsx(an,{children:e.jsx(Jl,{})},rt):null}),e.jsx(an,{children:e.jsx(Xl,{onClick:()=>d(le=>Math.min(h.totalPages,le+1)),className:c===h.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})]})}const Ca=[{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:"DD Head Approval",key:"DD_HEAD_APPROVAL",role:"DD Head"},{id:7,name:"NBH Approval",key:"NBH_APPROVAL",role:"NBH"},{id:8,name:"Legal Clearance",key:"LEGAL_CLEARANCE",role:"Legal Admin"},{id:9,name:"NBH Clearance with EOR",key:"NBH_CLEARANCE_EOR",role:"NBH"},{id:10,name:"Relocation Complete",key:"COMPLETED",role:"System"}];function Ev(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 Ca.length+1;const r=s.match(/^pending\s+(.+)$/i),a=(r?r[1]:s).trim();let l=Ca.findIndex(c=>c.name===a||c.name===s||c.key===a||c.key===s);return l<0&&(l=Ca.findIndex(c=>a.toLowerCase().includes(c.name.toLowerCase())||c.name.toLowerCase().includes(a.toLowerCase()))),l>=0?l+1:0}function xV(t){const s=String(t||"").toLowerCase();return!!(s.includes("sent back")||s.includes("send")&&s.includes("back"))}function gV(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 pD(t,s){if(gV(s))return t;const n=String((s==null?void 0:s.action)||"");if(xV(n)){const a=Ev(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 l=Ev(String(a));l>r&&(r=l)}return r}function vV(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=pD(n,r);return n}function bV(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 l=(r==null?void 0:r.details)||(r==null?void 0:r.newData)||{},c=[a,l==null?void 0:l.action,String((l==null?void 0:l.type)||"")].filter(Boolean).join(" ");n=pD(n,{action:c,stage:(l==null?void 0:l.stage)!==void 0?String(l.stage):(r==null?void 0:r.stage)!==void 0?String(r.stage):void 0,targetStage:(l==null?void 0:l.targetStage)!==void 0?String(l.targetStage):void 0})}return n}function yV(t,s,n){const a=(Array.isArray(t)?[...t]:[]).filter(l=>{const c=String((l==null?void 0:l.stage)||"").trim();return c===s.name||c===s.key||n===0&&(c==="Submitted"||c==="Request submitted")});return a.sort((l,c)=>{const d=new Date((l==null?void 0:l.timestamp)||(l==null?void 0:l.createdAt)||0).getTime(),h=new Date((c==null?void 0:c.timestamp)||(c==null?void 0:c.createdAt)||0).getTime();return d-h}),a}const Dd=["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"],I0=t=>t==="Completed"||t==="Verified"||t==="Closed"?"bg-green-100 text-green-700 border-green-300":t.includes("Review")||t.includes("Pending")||t==="In Progress"?"bg-yellow-100 text-yellow-700 border-yellow-300":t.includes("Rejected")||t.includes("Revoked")?"bg-red-100 text-red-700 border-red-300":t.includes("Collection")||t.includes("Completion")||t.includes("Infra")?"bg-blue-100 text-blue-700 border-blue-300":"bg-slate-100 text-slate-700 border-slate-300",Ao=(t,s)=>{var r,a,l;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 c=((a=n.readiness)==null?void 0:a.missingUploads)||[],d=((l=n.readiness)==null?void 0:l.pendingVerification)||[],h=[c.length?`Missing: ${c.join(", ")}`:"",d.length?`Pending verification: ${d.join(", ")}`:""].filter(Boolean).join(" | ");return h?`${n.message||s} (${h})`:n.message||s}return(n==null?void 0:n.message)||(t==null?void 0:t.message)||s};function jV({requestId:t,onBack:s,currentUser:n}){var Qt,qt,ws,_s,ns,Cs,Bs,Ft,ie,Fe;const r=qn(),[a,l]=v.useState(null),[c,d]=v.useState([]),[h,x]=v.useState(!0),[f,m]=v.useState(!1),[p,u]=v.useState(!1),[j,g]=v.useState("approve"),[y,N]=v.useState(""),[S,C]=v.useState(!1),[w,R]=v.useState(null),[P,A]=v.useState(!1),[I,$]=v.useState(!1),[T,E]=v.useState(null),[_,M]=v.useState(Dd[0]),[q,G]=v.useState(!1),[Z,W]=v.useState("workflow"),[z,F]=v.useState(!1),[B,D]=v.useState(null);v.useEffect(()=>{U(),O()},[t]);const O=async()=>{try{const Q=await Te.getAuditLogs("relocation",t);Q.data&&Q.data.success&&d(Q.data.data||[])}catch(Q){console.error("Error fetching audit logs:",Q)}},V=async Q=>{try{A(!0);const pe=Q||(a==null?void 0:a.id)||t,Ne=await Te.getEorChecklistForRelocation(pe);Ne.data.success&&R(Ne.data.data)}catch(pe){console.error("Fetch EOR checklist error:",pe)}finally{A(!1)}},K=async(Q,pe,Ne)=>{if(w)try{(await Te.updateEorChecklistItem(w.id,{description:Q,isCompliant:pe,itemType:Ne,remarks:""})).data.success&&V()}catch(Ee){console.error("Update EOR item error:",Ee),ee.error(Ao(Ee,"Failed to update item"))}},Y=async()=>{if(w)try{$(!0),(await Te.submitEorAudit(w.id,{status:"Completed",overallComments:"Relocation EOR Audit Completed"})).data.success&&(ee.success("EOR Audit submitted successfully"),U(),V())}catch(Q){console.error("Submit EOR audit error:",Q),ee.error(Ao(Q,"Failed to submit EOR audit"))}finally{$(!1)}},U=async(Q=!1)=>{try{Q||x(!0);const pe=await Te.getRelocationRequestById(t);if(pe.data.success){const Ne=pe.data.request;l(Ne);const Ee=Ne.currentStage;(Ee==="NBH_CLEARANCE_EOR"||Ee==="NBH Clearance with EOR"||Ne.status==="Completed")&&V(Ne.id)}}catch(pe){console.error("Fetch relocation request details error:",pe),ee.error(Ao(pe,"Failed to fetch request details"))}finally{x(!1)}},X=()=>{if(!a)return 1;if(a.status==="Completed"||a.currentStage==="Completed")return Ca.length+1;if(a.status==="Rejected"||a.status==="Revoked"||a.status==="Withdrawn"){const Ee=[...a.timeline||[]].filter(Boolean).reverse();for(const it of Ee){const st=String(it.stage||"").trim(),bt=String(it.targetStage||"").trim(),Ue=Ca.findIndex(Lt=>Lt.name===st||Lt.key===bt||Lt.key===st||Lt.name===bt);if(Ue>=0)return Ue+1}return 1}const Q=a.currentStage,pe=Ca.findIndex(Ee=>Ee.name===Q||Ee.key===Q||Ee.name.replace(/\s+/g," ")===String(Q||"").replace(/\s+/g," "));if(pe>=0)return pe+1;const Ne=Ev(String(a.status||""));return Ne>0?Ne:1},ne=Array.isArray(a==null?void 0:a.timeline)?a.timeline:[],oe=vV(ne),re=bV(c),ge=a?X():1,ve=!!a&&Math.max(oe,re)>ge&&(ne.length>0||c.length>0),Se=a?Ca[Math.min(Math.max(ge,1),Ca.length)-1]:void 0,We=(a==null?void 0:a.status)==="Completed"||(a==null?void 0:a.currentStage)==="Completed"||ge>=Ca.length+1,Ce=We?100:Math.min(100,Math.round(ge/Ca.length*100)),fe=We?100:Ce,Ye=a?Dd.filter(Q=>{var pe;return!((pe=a.documents)!=null&&pe.some(Ne=>Ne.type===Q||Ne.name&&Ne.name.toLowerCase().includes(Q.toLowerCase().split(" ")[0])))}):[],be=a?Dd.filter(Q=>{var Ne;const pe=((Ne=a.documents)==null?void 0:Ne.filter(Ee=>Ee.type===Q||Ee.name&&Ee.name.toLowerCase().includes(Q.toLowerCase().split(" ")[0])))||[];return pe.length>0&&!pe.some(Ee=>Ee.status==="Verified")}):[],_e=Q=>{var Ne,Ee,it;if(!a||!a.participants||a.participants.length===0)return null;const pe=a.participants.find(st=>{var bt,Ue;return((bt=st.metadata)==null?void 0:bt.stage)===Q||((Ue=st.metadata)==null?void 0:Ue.stage)===Q.toUpperCase().replace(/ /g,"_")});return pe&&(((Ne=pe.user)==null?void 0:Ne.fullName)||((Ee=pe.user)==null?void 0:Ee.name)||((it=pe.user)==null?void 0:it.role))||null},qe=(!a||!n?!1:(n==null?void 0:n.role)==="Super Admin"||n.role==="Super Admin"?!0:!!(Se!=null&&Se.role&&n.role===Se.role))&&a.status!=="Completed"&&a.status!=="Rejected"&&a.status!=="Revoked",Ve=qe&&a.currentStage&&a.currentStage!=="ASM Review"&&a.currentStage!=="Rejected",dt=qe&&["ZBH","DD Lead","DD Head","NBH","Legal Admin","Super Admin"].includes((n==null?void 0:n.role)||""),xt=(a==null?void 0:a.currentStage)==="NBH Approval"||(a==null?void 0:a.currentStage)==="Legal Clearance",ye=qe&&(!xt||Ye.length===0&&be.length===0),le=Q=>{g(Q),u(!0)},Qe=async Q=>{Q.preventDefault();const pe=String(y||"").trim();if((j==="sendBack"||j==="revoke")&&pe.length<5){ee.error(`Remarks are required for ${j==="sendBack"?"Send Back":"Revoke"} (minimum 5 characters).`);return}try{m(!0);const st={approve:"approve",reject:"reject",hold:"hold",sendBack:"sendBack",revoke:"revoke"}[j]||"approve";if((await Te.updateRelocationRequest(t,st,{remarks:pe})).data.success){const Ue=j==="sendBack"?"sent back":j==="revoke"?"revoked":`${j}ed`;ee.success(`Request ${Ue} successfully`),u(!1),N(""),U(),O(),j==="approve"&&(Se==null?void 0:Se.key)==="LEGAL_CLEARANCE"&&(a!=null&&a.id)&&V(a.id)}}catch(it){console.error("Submit action error:",it),ee.error(Ao(it,"Failed to submit action"))}finally{m(!1)}},rt=async()=>{if(!T||!_){ee.error("Please select both a document type and a file");return}try{G(!0);const Q=new FormData;Q.append("file",T),Q.append("documentType",_),Q.append("stage",a.currentStage),(await Te.uploadRelocationDocument(t,Q)).data.success&&(ee.success("Document uploaded successfully"),C(!1),E(null),U(!0),O())}catch(Q){console.error("Upload document error:",Q),ee.error(Ao(Q,"Failed to upload document"))}finally{G(!1)}},Kt=async Q=>{try{(await Te.verifyRelocationDocument(t,Q)).data.success&&(ee.success("Document verified successfully"),U(!0),O())}catch(pe){console.error("Verify document error:",pe),ee.error(Ao(pe,"Failed to verify document"))}},Rt=async Q=>{try{(await Te.rejectRelocationDocument(t,Q,{remarks:"Rejected by reviewer"})).data.success&&(ee.success("Document rejected successfully"),U(!0),O())}catch(pe){console.error("Reject document error:",pe),ee.error(Ao(pe,"Failed to reject document"))}},Re=Q=>{D({fileName:Q.name,filePath:Q.url,documentType:Q.type,createdAt:Q.uploadedOn,mimeType:Q.mimeType}),F(!0)};return h?e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:[e.jsx(ss,{className:"w-10 h-10 text-amber-600 animate-spin"}),e.jsx("p",{className:"text-slate-500 font-medium",children:"Loading request details..."})]}):a?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($r,{className:"w-4 h-4"}),"Back"]}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-slate-900",children:[a.requestId," - Relocation Request Details"]}),e.jsxs("p",{className:"text-slate-600",children:[(Qt=a.outlet)==null?void 0:Qt.name," (",(qt=a.outlet)==null?void 0:qt.code,")"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(se,{variant:"outline",className:"relative hover:bg-amber-50 hover:border-amber-300 hover:text-amber-700 transition-all shadow-sm",onClick:()=>{var Q;return r(`/worknotes/relocation/${t}`,{state:{applicationName:((Q=a==null?void 0:a.outlet)==null?void 0:Q.name)||"Relocation",registrationNumber:(a==null?void 0:a.requestId)||"",participants:(a==null?void 0:a.participants)||[]}})},children:[e.jsx(zr,{className:"w-4 h-4 mr-2"}),"View Work Notes",((ws=a==null?void 0:a.worknotes)==null?void 0:ws.length)>0&&e.jsx(Ae,{className:"ml-2 bg-amber-600 hover:bg-amber-700 text-white h-5 px-2",children:a.worknotes.length})]}),e.jsx(Ae,{className:I0(a.status),children:a.status})]})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Relocation Overview"})}),e.jsxs(Me,{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:(_s=a.outlet)==null?void 0:_s.name}),e.jsx("p",{className:"text-slate-600 text-sm",children:(ns=a.outlet)==null?void 0:ns.code}),e.jsx("p",{className:"text-slate-600 text-xs mt-1",children:(Cs=a.dealer)==null?void 0:Cs.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(Er,{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:a.currentLocation||(a.outlet?`${a.outlet.address}, ${a.outlet.city}`:"N/A")})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q2,{className:"w-4 h-4 text-amber-600"}),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:a.proposedLocation||`${a.newAddress}, ${a.newCity}`})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(Ae,{variant:"outline",className:"border-slate-300 text-slate-700",children:["Type: ",a.relocationType]}),a.distance&&e.jsxs(Ae,{variant:"outline",className:"border-amber-200 bg-amber-50 text-amber-700",children:["Distance: ",a.distance]}),a.propertyType&&e.jsxs(Ae,{variant:"outline",className:"border-blue-200 bg-blue-50 text-blue-700",children:["Property: ",a.propertyType]}),a.expectedRelocationDate&&e.jsxs(Ae,{variant:"outline",className:"border-purple-200 bg-purple-50 text-purple-700",children:["Expected Date: ",a.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: ",Ht(a.createdAt)]}),e.jsxs("p",{className:"text-slate-600 text-sm",children:["By: ",(Bs=a.dealer)==null?void 0:Bs.fullName]}),e.jsxs("p",{className:"text-slate-900 text-sm mt-2",children:["Current Stage: ",String(a.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:a.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(Pn,{value:Z,onValueChange:W,className:"w-full",children:[e.jsx(tt,{className:"pb-4",children:e.jsx("div",{className:"overflow-x-auto -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"}),(a.currentStage==="NBH Clearance with EOR"||a.status==="Completed"||a.currentStage==="NBH_CLEARANCE_EOR")&&e.jsx(Wt,{value:"eor",children:"EOR Checklist"}),e.jsx(Wt,{value:"history",children:"History & Audit Trail"})]})})}),e.jsxs(Me,{children:[e.jsxs(Gt,{value:"workflow",className:"mt-0",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("span",{className:"text-slate-600",children:[fe,"%"]})]}),e.jsx("div",{className:"h-3 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-amber-600 transition-all duration-500",style:{width:`${fe}%`}})})]}),ve&&e.jsxs("div",{className:"mb-6 rounded-lg border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-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(a.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(Zt,{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:Ca.map((Q,pe)=>{const Ne=We||pe<ge-1,Ee=!We&&pe===ge-1,it=yV(ne,Q,pe),st=it.length>0?it[it.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 ${Ne?"bg-green-100 text-green-600":Ee?"bg-amber-100 text-amber-600":"bg-slate-100 text-slate-400"}`,children:Ne?e.jsx(Fn,{className:"w-5 h-5"}):Ee?e.jsx(Js,{className:"w-5 h-5"}):e.jsx("span",{className:"text-xs font-semibold",children:Q.id})}),pe<Ca.length-1&&e.jsx("div",{className:`w-0.5 h-16 ${Ne?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:`flex-1 pb-8 ${Ee?"bg-amber-50 -ml-4 pl-4 pr-4 py-3 rounded-lg border border-amber-200":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1 gap-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:Ne?"text-green-700":Ee?"text-amber-900":"text-slate-900",children:Q.name}),e.jsxs("p",{className:`text-sm ${Ee?"text-amber-700":"text-slate-600"}`,children:["Responsible: ",Q.role]}),_e(Q.name)&&e.jsxs("p",{className:"text-xs text-blue-600 font-medium mt-1",children:["Assigned: ",_e(Q.name)]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx(Ae,{className:Ne?"bg-green-100 text-green-700 border-green-300":Ee?"bg-amber-100 text-amber-700 border-amber-300":"bg-slate-100 text-slate-500 border-slate-300",children:Ne?"Completed":Ee?"In Progress":"Pending"}),st&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-slate-600",children:[e.jsx($n,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:Ht(st.timestamp||st.createdAt)})]})]})]}),st&&e.jsxs("div",{className:"space-y-2 mt-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Ae,{variant:"secondary",className:"bg-slate-100 text-[10px] font-bold uppercase",children:st.user||"System"}),e.jsx("span",{className:"text-[10px] text-slate-500 italic",children:st.action||"Update"}),st.targetStage&&st.targetStage!==st.stage&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["→ ",String(st.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:st.remarks||st.comments||"No remarks provided."}),it.length>1&&e.jsxs("p",{className:"text-[10px] text-slate-500",children:[it.length," events at this stage; showing the latest."]})]})]})]},Q.id)})})]}),e.jsx(Gt,{value:"documents",className:"mt-0",children:e.jsxs(Pn,{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(Gt,{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(os,{open:S,onOpenChange:C,children:[e.jsx(Hl,{asChild:!0,children:e.jsxs(se,{size:"sm",className:"bg-amber-600 hover:bg-amber-700",children:[e.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Upload Document"]})}),e.jsxs(ls,{children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Upload Document"}),e.jsx(vs,{children:"Select the document type and upload the file"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ce,{children:"Document Type"}),e.jsx("select",{className:"w-full mt-1 px-3 py-2 border border-slate-300 rounded-md",value:_,onChange:Q=>M(Q.target.value),children:Dd.map((Q,pe)=>{var Ee;const Ne=(Ee=a.documents)==null?void 0:Ee.some(it=>it.type===Q||it.name.toLowerCase().includes(Q.toLowerCase().split(" ")[0]));return e.jsx("option",{value:Q,children:Ne?`✅ ${Q}`:Q},pe)})})]}),e.jsxs("div",{children:[e.jsx(ce,{children:"Upload File"}),e.jsx(ot,{type:"file",className:"mt-1",onChange:Q=>{var pe;return E(((pe=Q.target.files)==null?void 0:pe[0])||null)}})]})]}),e.jsxs(rn,{children:[e.jsx(se,{variant:"outline",onClick:()=>C(!1),disabled:q,children:"Cancel"}),e.jsx(se,{className:"bg-amber-600 hover:bg-amber-700",onClick:rt,disabled:q,children:q?e.jsxs(e.Fragment,{children:[e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}),"Uploading..."]}):"Upload"})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Dd.map((Q,pe)=>{var Ee;const Ne=(Ee=a.documents)==null?void 0:Ee.find(it=>it.type===Q||it.name.toLowerCase().includes(Q.toLowerCase().split(" ")[0]));return e.jsxs("div",{className:`flex items-center gap-2 p-2 rounded border text-sm ${Ne?"bg-green-50 border-green-200":"bg-slate-50 border-slate-200"}`,children:[Ne?e.jsx(Fn,{className:"w-4 h-4 text-green-600 flex-shrink-0"}):e.jsx(Ks,{className:"w-4 h-4 text-slate-400 flex-shrink-0"}),e.jsx("span",{className:Ne?"text-green-900":"text-slate-700",children:Q})]},pe)})})]})}),e.jsx(Gt,{value:"existing",className:"mt-0",children:a.documents&&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(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{className:"bg-slate-50",children:[e.jsx(me,{children:"Document Name"}),e.jsx(me,{children:"Category"}),e.jsx(me,{children:"Uploaded On"}),e.jsx(me,{children:"Uploaded By"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Es,{children:a.documents.map(Q=>e.jsxs(ct,{children:[e.jsx(de,{className:"text-slate-900",children:Q.name}),e.jsx(de,{children:e.jsx(Ae,{variant:"outline",className:"border-slate-300",children:Q.category||"General"})}),e.jsx(de,{className:"text-slate-600",children:Ht(Q.uploadedOn)}),e.jsx(de,{className:"text-slate-600",children:Q.uploadedBy}),e.jsx(de,{children:e.jsx(Ae,{className:I0(Q.status),children:Q.status})}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{size:"icon",variant:"outline",className:"h-8 w-8",onClick:()=>Q.url&&Re(Q),disabled:!Q.url,title:Q.url?"View Document":"File path not available",children:e.jsx(nn,{className:"w-4 h-4"})}),e.jsx(se,{size:"icon",variant:"outline",className:"h-8 w-8",onClick:()=>Q.url&&window.open(`http://localhost:5000/${Q.url}`,"_blank"),disabled:!Q.url,title:Q.url?"Download Document":"File path not available",children:e.jsx(Ni,{className:"w-4 h-4"})}),Q.status==="Pending Verification"&&(()=>{const pe=(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(pe)})()&&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:()=>Kt(Q.id),title:"Verify Document",children:[e.jsx(Fn,{className:"w-4 h-4"}),"Verify"]}),e.jsxs(se,{size:"sm",variant:"destructive",className:"h-8 gap-1",onClick:()=>Rt(Q.id),title:"Reject Document",children:[e.jsx(Ks,{className:"w-4 h-4"}),"Reject"]})]})]})})]},Q.id))})]})})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded yet"})})]})}),e.jsx(Gt,{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)."})]}),w&&e.jsx(Ae,{className:I0(w.status),children:w.status})]}),w?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{className:"bg-slate-50",children:[e.jsx(me,{className:"w-[50px]"}),e.jsx(me,{children:"Category"}),e.jsx(me,{children:"Checklist Item"}),e.jsx(me,{children:"Proof & Documents"})]})}),e.jsx(Es,{children:!w.items||w.items.length===0?e.jsx(ct,{children:e.jsx(de,{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; rows are created when the request enters NBH Clearance with EOR.'})}):w.items.map(Q=>e.jsxs(ct,{children:[e.jsx(de,{children:e.jsx("input",{type:"checkbox",checked:Q.isCompliant,onChange:pe=>K(Q.description,pe.target.checked,Q.itemType),disabled:w.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-amber-600"})}),e.jsx(de,{children:e.jsx(Ae,{variant:"outline",className:"border-slate-300 capitalize text-xs",children:Q.itemType})}),e.jsx(de,{className:"text-slate-900 font-medium text-sm",children:Q.description}),e.jsx(de,{children:e.jsx("div",{className:"flex flex-col items-start gap-1",children:Q.proofDocumentId&&Q.proofDocument?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-slate-600 truncate max-w-[220px]",title:Q.proofDocument.fileName,children:Q.proofDocument.fileName}),e.jsxs(se,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-blue-600 px-0",onClick:()=>Re({name:Q.proofDocument.fileName,url:Q.proofDocument.filePath,type:Q.proofDocument.documentType,uploadedOn:Q.proofDocument.updatedAt||Q.proofDocument.createdAt,mimeType:Q.proofDocument.mimeType}),children:[e.jsx(nn,{className:"w-3.5 h-3.5 mr-1"}),"View"]})]}):Q.proofDocumentId?e.jsx("span",{className:"text-xs text-amber-700",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:w.status==="Completed",children:[e.jsx(Dr,{className:"w-3.5 h-3.5 mr-1"}),"Upload"]})})})]},Q.id))})]})}),((n==null?void 0:n.role)==="NBH"||(n==null?void 0:n.role)==="Super Admin")&&w.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:Y,disabled:I||!((Ft=w.items)!=null&&Ft.length)||!w.items.every(Q=>Q.isCompliant),children:[I?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Fn,{className:"w-4 h-4 mr-2"}),"Finalize EOR & Complete Relocation"]})}),!((ie=w.items)!=null&&ie.every(Q=>Q.isCompliant))&&e.jsx("p",{className:"text-right text-xs text-amber-600 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:P?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(ss,{className:"w-8 h-8 text-amber-600 animate-spin"}),e.jsx("p",{className:"text-slate-500",children:"Fetching checklist..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ks,{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:()=>V(a==null?void 0:a.id),children:"Try Refreshing"})]})})]})}),e.jsx(Gt,{value:"history",className:"mt-0",children:e.jsx("div",{className:"space-y-4",children:c.length>0?c.map((Q,pe)=>{var Ne,Ee,it,st,bt,Ue,Lt,ut,yt,kt,Ie,_t;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(Ae,{className:`
${(Q.description||Q.action||((Ne=Q.details)==null?void 0:Ne.action)||"").toLowerCase().includes("reject")||(Q.description||Q.action||((Ee=Q.details)==null?void 0:Ee.action)||"").toLowerCase().includes("revok")?"bg-red-100 text-red-700 border-red-200":(Q.description||Q.action||((it=Q.details)==null?void 0:it.action)||"").toLowerCase().includes("sent back")||(Q.description||Q.action||((st=Q.details)==null?void 0:st.action)||"").toLowerCase().includes("send back")?"bg-amber-100 text-amber-700 border-amber-200":(Q.description||Q.action||((bt=Q.details)==null?void 0:bt.action)||"").toLowerCase().includes("approv")||(Q.description||Q.action||((Ue=Q.details)==null?void 0:Ue.action)||"").toLowerCase().includes("initi")||(Q.action||"").toLowerCase().includes("complete")?"bg-emerald-100 text-emerald-700 border-emerald-200":"bg-slate-100 text-slate-700 border-slate-200"}
`,children:Q.action}),e.jsxs("span",{className:"text-xs text-slate-500 font-medium italic",children:["by ",((Lt=Q.actor)==null?void 0:Lt.name)||Q.userName||"System"]}),((ut=Q.details)==null?void 0:ut.stage)&&e.jsxs("span",{className:"text-[10px] text-slate-400 font-normal",children:["at ",Q.details.stage]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:Ht(Q.timestamp||Q.createdAt)})]}),(Q.remarks||Q.description||((yt=Q.newData)==null?void 0:yt.remarks)||((kt=Q.details)==null?void 0:kt.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:Q.remarks||Q.description||((Ie=Q.newData)==null?void 0:Ie.remarks)||((_t=Q.details)==null?void 0:_t.remarks)})]})]},pe)}):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(tt,{children:e.jsx(nt,{children:"Current Status"})}),e.jsxs(Me,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Current Stage"}),e.jsx("p",{className:"text-slate-900",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 bg-amber-600 transition-all duration-300",style:{width:`${fe}%`}})}),e.jsxs("span",{className:"text-slate-900",children:[fe,"%"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Distance"}),e.jsx("p",{className:"text-slate-900",children:a.distance})]})]})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Actions"})}),e.jsxs(Me,{className:"space-y-3",children:[qe&&e.jsxs(e.Fragment,{children:[e.jsxs(se,{className:"w-full bg-green-600 hover:bg-green-700",onClick:()=>le("approve"),disabled:f||!ye,children:[f&&j==="approve"?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Fn,{className:"w-4 h-4 mr-2"}),"Approve Request"]}),!ye&&e.jsx("p",{className:"text-xs text-amber-700",children:"Approval is blocked until mandatory documents are uploaded and verified for this stage."}),e.jsxs(se,{variant:"destructive",className:"w-full",onClick:()=>le("reject"),disabled:f,children:[f&&j==="reject"?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Ks,{className:"w-4 h-4 mr-2"}),"Reject Request"]}),Ve&&e.jsxs(se,{variant:"outline",className:"w-full border-amber-400 text-amber-900 hover:bg-amber-50",onClick:()=>le("sendBack"),disabled:f,children:[f&&j==="sendBack"?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(oI,{className:"w-4 h-4 mr-2"}),"Send Back"]}),dt&&e.jsxs(se,{variant:"outline",className:"w-full border-red-300 text-red-800 hover:bg-red-50",onClick:()=>le("revoke"),disabled:f,children:[f&&j==="revoke"?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Yv,{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 Q;return r(`/worknotes/relocation/${t}`,{state:{applicationName:((Q=a==null?void 0:a.outlet)==null?void 0:Q.name)||"Relocation",registrationNumber:(a==null?void 0:a.requestId)||"",participants:(a==null?void 0:a.participants)||[]}})},children:[e.jsx(zr,{className:"w-4 h-4 mr-2"}),"Worknotes (",((Fe=a==null?void 0:a.worknotes)==null?void 0:Fe.length)||0,")"]})]})]}),a.participants&&a.participants.length>0&&e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(nt,{children:"Assigned Evaluators"})}),e.jsx(Me,{className:"space-y-3",children:a.participants.map(Q=>{var pe,Ne,Ee,it;return e.jsxs("div",{className:"flex items-center justify-between p-2 bg-slate-50 rounded-lg",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 text-sm font-medium",children:((pe=Q.user)==null?void 0:pe.fullName)||"Unknown"}),e.jsx("p",{className:"text-slate-600 text-xs",children:((Ne=Q.user)==null?void 0:Ne.roleCode)||"User"}),((Ee=Q.metadata)==null?void 0:Ee.stage)&&e.jsx(Ae,{variant:"outline",className:"mt-1 text-xs",children:Q.metadata.stage.replace(/_/g," ")})]}),((it=Q.metadata)==null?void 0:it.autoAssigned)&&e.jsx(Ae,{className:"bg-blue-100 text-blue-700 border-blue-300 text-xs",children:"Auto-assigned"})]},Q.id)})})]})]})]}),e.jsx(os,{open:p,onOpenChange:u,children:e.jsxs(ls,{children:[e.jsxs(ms,{children:[e.jsx(us,{children:j==="approve"?"Approve Request":j==="reject"?"Reject Request":j==="sendBack"?"Send Back Request":j==="revoke"?"Revoke Request":"Put Request on Hold"}),e.jsx(vs,{children:j==="sendBack"||j==="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:Qe,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ce,{htmlFor:"comments",children:j==="sendBack"||j==="revoke"?"Remarks *":"Comments *"}),e.jsx("div",{className:"space-y-2"})]}),e.jsx(Fs,{id:"comments",value:y,onChange:Q=>N(Q.target.value),placeholder:j==="sendBack"?"Explain what needs to be corrected at the previous stage…":j==="revoke"?"Document why this relocation request is being revoked…":"Enter your comments...",rows:4,required:!0}),e.jsxs(rn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>u(!1),disabled:f,children:"Cancel"}),e.jsxs(se,{type:"submit",className:j==="approve"?"bg-green-600 hover:bg-green-700":j==="reject"?"bg-red-600 hover:bg-red-700":j==="sendBack"?"bg-amber-600 hover:bg-amber-700":j==="revoke"?"bg-red-700 hover:bg-red-800":"bg-amber-600 hover:bg-amber-700",disabled:f,children:[f?e.jsx(ss,{className:"w-4 h-4 mr-2 animate-spin"}):null,j==="approve"?"Approve":j==="reject"?"Reject":j==="sendBack"?"Send Back":j==="revoke"?"Revoke":"Put on Hold"]})]})]})]})}),e.jsx(Kl,{isOpen:z,onClose:()=>F(!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"})]})}const NV=t=>t==="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-slate-100 text-slate-700 border-slate-300";function wV({onViewDetails:t}){const[s,n]=v.useState(!1),[r,a]=v.useState(null),[l,c]=v.useState(""),[d,h]=v.useState(""),[x,f]=v.useState(""),[m,p]=v.useState(""),[u,j]=v.useState(""),[g,y]=v.useState([]),[N,S]=v.useState([]),[C,w]=v.useState(!0),[R,P]=v.useState(!1),[A,I]=v.useState(null);v.useEffect(()=>{$()},[]);const $=async()=>{try{w(!0);const M=await Il.getDashboardData(),q=await Pl.getResignations();y(M.outlets||[]),I(M.profile),S(q.resignations||[])}catch(M){console.error("Fetch resignation data error:",M),ee.error("Failed to load outlets and requests")}finally{w(!1)}},T=M=>{a(M),n(!0)},E=async M=>{if(M.preventDefault(),!l){ee.error("Please select resignation type");return}if(!d||!x){ee.error("Please enter last operational dates");return}if(!m.trim()){ee.error("Please provide a reason for resignation");return}try{P(!0);const q={outletId:r==null?void 0:r.id,resignationType:l,lastOperationalDateSales:d,lastOperationalDateServices:x,reason:m,additionalInfo:u};await Pl.createResignation(q),ee.success(`Resignation request submitted successfully for ${r==null?void 0:r.name}`),n(!1),$(),a(null),c(""),h(""),f(""),p(""),j("")}catch(q){console.error("Submit resignation error:",q),ee.error("Failed to submit resignation request")}finally{P(!1)}},_=[{title:"Total Outlets",value:g.length,icon:Ml,color:"bg-blue-500"},{title:"Active Outlets",value:g.filter(M=>M.status==="Active").length,icon:Ys,color:"bg-green-500"},{title:"Pending Resignations",value:g.filter(M=>M.status==="Pending Resignation").length,icon:Js,color:"bg-amber-500"}];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(ss,{className:"w-8 h-8 text-amber-600 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:_.map((M,q)=>{const G=M.icon;return e.jsxs(Le,{children:[e.jsxs(tt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(nt,{className:"text-sm",children:M.title}),e.jsx("div",{className:`${M.color} p-2 rounded-lg`,children:e.jsx(G,{className:"h-4 w-4 text-white"})})]}),e.jsx(Me,{children:e.jsx("div",{className:"text-slate-900 text-2xl",children:M.value})})]},q)})}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"My Outlets"}),e.jsx(Zt,{children:"Select an outlet to request resignation"})]}),e.jsx(Me,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:g.map(M=>{const q=M.type==="Dealership"?Ml:fI,G=M.status==="Pending Resignation",Z=N.find(W=>W.outletId===M.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:`${M.type==="Dealership"?"bg-blue-100":"bg-purple-100"} p-2 rounded-lg`,children:e.jsx(q,{className:`w-5 h-5 ${M.type==="Dealership"?"text-blue-600":"text-purple-600"}`})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900",children:M.name}),e.jsx("p",{className:"text-slate-600 text-sm",children:M.code})]})]}),e.jsx(Ae,{className:`border ${M.status==="Active"?"bg-green-100 text-green-700 border-green-300":M.status==="Pending Resignation"?"bg-amber-100 text-amber-700 border-amber-300":"bg-slate-100 text-slate-700 border-slate-300"}`,children:M.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(Er,{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:M.location})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx($n,{className:"w-4 h-4 text-slate-400"}),e.jsxs("span",{className:"text-slate-600",children:["Outlet Code: ",M.code]})]})]}),G?e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded p-3 text-sm",children:e.jsxs("p",{className:"text-amber-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:()=>T(M),children:[e.jsx(fs,{className:"w-4 h-4 mr-2"}),"Request Resignation"]})]},M.id)})})})]}),e.jsx(os,{open:s,onOpenChange:n,children:e.jsxs(ls,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Submit Resignation Request"}),e.jsx(vs,{children:"Fill in the details for your resignation request. All fields are mandatory."})]}),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:"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(ce,{htmlFor:"resignationType",children:"Resignation Type *"}),e.jsxs(wt,{value:l,onValueChange:c,required:!0,children:[e.jsx(Ct,{children:e.jsx(St,{placeholder:"Select resignation type"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"Voluntary",children:"Voluntary"}),e.jsx(Pe,{value:"Retirement",children:"Retirement"}),e.jsx(Pe,{value:"Health Issues",children:"Health Issues"}),e.jsx(Pe,{value:"Business Closure",children:"Business Closure"}),e.jsx(Pe,{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(ce,{htmlFor:"lastOpDateSales",children:"Last Operational Date - Sales *"}),e.jsx(ot,{id:"lastOpDateSales",type:"date",value:d,onChange:M=>h(M.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"lastOpDateServices",children:"Last Operational Date - Services *"}),e.jsx(ot,{id:"lastOpDateServices",type:"date",value:x,onChange:M=>f(M.target.value),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"reason",children:"Reason for Resignation *"}),e.jsx(Fs,{id:"reason",placeholder:"Please provide detailed reason for resignation...",value:m,onChange:M=>p(M.target.value),rows:4,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"additionalInfo",children:"Additional Information (Optional)"}),e.jsx(Fs,{id:"additionalInfo",placeholder:"Any additional details...",value:u,onChange:M=>j(M.target.value),rows:3})]}),e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4",children:[e.jsx("h4",{className:"text-amber-900 mb-2",children:"Important Information"}),e.jsxs("ul",{className:"text-amber-800 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(rn,{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(ss,{className:"w-4 h-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Resignation Request"})]})]})]})}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"My Resignation Requests"}),e.jsx(Zt,{children:"Track the progress of your resignation requests"})]}),e.jsx(Me,{children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Outlet"}),e.jsx(me,{children:"Type"}),e.jsx(me,{children:"Submitted On"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Es,{children:N.length===0?e.jsx(ct,{children:e.jsx(de,{colSpan:7,className:"text-center py-4 text-slate-500",children:"No resignation requests found"})}):N.map(M=>{var q;return e.jsxs(ct,{children:[e.jsx(de,{className:"font-medium text-slate-900",children:M.resignationId}),e.jsx(de,{children:(q=M.outlet)==null?void 0:q.name}),e.jsx(de,{children:M.resignationType}),e.jsx(de,{children:Ht(M.submittedOn)}),e.jsx(de,{children:e.jsx(Ae,{className:`border ${NV(M.status)}`,children:M.status})}),e.jsx(de,{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-red-600 h-2 rounded-full",style:{width:`${M.progressPercentage}%`}})}),e.jsxs("span",{className:"text-xs text-slate-600",children:[M.progressPercentage,"%"]})]})}),e.jsx(de,{children:e.jsxs(se,{variant:"ghost",size:"sm",onClick:()=>t&&t(M.resignationId),children:[e.jsx(nn,{className:"w-4 h-4 mr-1"}),"View"]})})]},M.id)})})]})})]})]})]})}var SV=Symbol("radix.slottable");function CV(t){const s=({children:n})=>e.jsx(e.Fragment,{children:n});return s.displayName=`${t}.Slottable`,s.__radixId=SV,s}var xD="AlertDialog",[AV]=ea(xD,[tR]),nl=tR(),gD=t=>{const{__scopeAlertDialog:s,...n}=t,r=nl(s);return e.jsx(Pb,{...r,...n,modal:!0})};gD.displayName=xD;var kV="AlertDialogTrigger",RV=v.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=nl(n);return e.jsx(gR,{...a,...r,ref:s})});RV.displayName=kV;var EV="AlertDialogPortal",vD=t=>{const{__scopeAlertDialog:s,...n}=t,r=nl(s);return e.jsx(_b,{...r,...n})};vD.displayName=EV;var DV="AlertDialogOverlay",bD=v.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=nl(n);return e.jsx(vf,{...a,...r,ref:s})});bD.displayName=DV;var kc="AlertDialogContent",[TV,PV]=AV(kc),_V=CV("AlertDialogContent"),yD=v.forwardRef((t,s)=>{const{__scopeAlertDialog:n,children:r,...a}=t,l=nl(n),c=v.useRef(null),d=Ms(s,c),h=v.useRef(null);return e.jsx(Q9,{contentName:kc,titleName:jD,docsSlug:"alert-dialog",children:e.jsx(TV,{scope:n,cancelRef:h,children:e.jsxs(bf,{role:"alertdialog",...l,...a,ref:d,onOpenAutoFocus:Vt(a.onOpenAutoFocus,x=>{var f;x.preventDefault(),(f=h.current)==null||f.focus({preventScroll:!0})}),onPointerDownOutside:x=>x.preventDefault(),onInteractOutside:x=>x.preventDefault(),children:[e.jsx(_V,{children:r}),e.jsx(IV,{contentRef:c})]})})})});yD.displayName=kc;var jD="AlertDialogTitle",ND=v.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=nl(n);return e.jsx(vR,{...a,...r,ref:s})});ND.displayName=jD;var wD="AlertDialogDescription",SD=v.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=nl(n);return e.jsx(bR,{...a,...r,ref:s})});SD.displayName=wD;var OV="AlertDialogAction",CD=v.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=nl(n);return e.jsx(Ob,{...a,...r,ref:s})});CD.displayName=OV;var AD="AlertDialogCancel",kD=v.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,{cancelRef:a}=PV(AD,n),l=nl(n),c=Ms(s,a);return e.jsx(Ob,{...l,...r,ref:c})});kD.displayName=AD;var IV=({contentRef:t})=>{const s=`\`${kc}\` requires a description for the component to be accessible for screen reader users.
You can add a description to the \`${kc}\` by passing a \`${wD}\` 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 \`${kc}\`. 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 v.useEffect(()=>{var r;document.getElementById((r=t.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},LV=gD,MV=vD,FV=bD,BV=yD,$V=CD,qV=kD,zV=ND,UV=SD;function VV({...t}){return e.jsx(LV,{"data-slot":"alert-dialog",...t})}function HV({...t}){return e.jsx(MV,{"data-slot":"alert-dialog-portal",...t})}function WV({className:t,...s}){return e.jsx(FV,{"data-slot":"alert-dialog-overlay",className:Pt("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 GV({className:t,...s}){return e.jsxs(HV,{children:[e.jsx(WV,{}),e.jsx(BV,{"data-slot":"alert-dialog-content",className:Pt("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 KV({className:t,...s}){return e.jsx("div",{"data-slot":"alert-dialog-header",className:Pt("flex flex-col gap-2 text-center sm:text-left",t),...s})}function YV({className:t,...s}){return e.jsx("div",{"data-slot":"alert-dialog-footer",className:Pt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...s})}function ZV({className:t,...s}){return e.jsx(zV,{"data-slot":"alert-dialog-title",className:Pt("text-lg font-semibold",t),...s})}function QV({className:t,...s}){return e.jsx(UV,{"data-slot":"alert-dialog-description",className:Pt("text-muted-foreground text-sm",t),...s})}function XV({className:t,...s}){return e.jsx($V,{className:Pt(Km(),t),...s})}function JV({className:t,...s}){return e.jsx(qV,{className:Pt(Km({variant:"outline"}),t),...s})}const eH=t=>t==="Completed"?"bg-green-100 text-green-700 border-green-300":t==="Rejected"||t==="Withdrawn"?"bg-red-100 text-red-700 border-red-300":t.includes("Review")||t.includes("Pending")?"bg-yellow-100 text-yellow-700 border-yellow-300":"bg-slate-100 text-slate-700 border-slate-300";function tH({resignationId:t,onBack:s}){var M,q,G;const n=qn(),[r,a]=v.useState(!0),[l,c]=v.useState(null),[d,h]=v.useState(!1),[x,f]=v.useState(null),[m,p]=v.useState(Ud[0]),[u,j]=v.useState(""),[g,y]=v.useState([]),[N,S]=v.useState(!1),[C,w]=v.useState(!1),[R,P]=v.useState("User requested withdrawal");v.useEffect(()=>{t&&(async()=>{try{a(!0);const[W,z]=await Promise.all([Pl.getResignationById(t),A(t)]);c(W),y(z)}catch(W){console.error("Failed to fetch resignation details:",W),ee.error("Unable to load resignation details")}finally{a(!1)}})()},[t]);const A=async Z=>{var W;try{const{API:z}=await Tl(async()=>{const{API:B}=await Promise.resolve().then(()=>Pd);return{API:B}},void 0),F=await z.getAuditLogs("resignation",Z);return(W=F==null?void 0:F.data)!=null&&W.success?F.data.data||[]:[]}catch{return[]}},I=async()=>{try{const[Z,W]=await Promise.all([Pl.getResignationById(t),A(t)]);c(Z),y(W)}catch{ee.error("Unable to refresh resignation details")}},$=async()=>{var Z,W;if(!x){ee.error("Please choose a file");return}try{h(!0);const z=new FormData;z.append("file",x),z.append("documentType",m),u&&z.append("stage",u),await Pl.uploadDocument(t,z),ee.success("Document uploaded successfully"),f(null),await I()}catch(z){ee.error(((W=(Z=z==null?void 0:z.response)==null?void 0:Z.data)==null?void 0:W.message)||"Document upload failed")}finally{h(!1)}},T=async()=>{var Z,W;try{S(!0),await Pl.withdraw(t,R),ee.success("Resignation request withdrawn successfully"),w(!1),await I()}catch(z){ee.error(((W=(Z=z==null?void 0:z.response)==null?void 0:Z.data)==null?void 0:W.message)||"Failed to withdraw resignation")}finally{S(!1)}};if(r)return e.jsx("div",{className:"min-h-[320px] flex items-center justify-center",children:e.jsx(Js,{className:"w-8 h-8 animate-spin text-amber-600"})});if(!l)return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(se,{variant:"outline",onClick:s,children:[e.jsx($r,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsx(Le,{children:e.jsx(Me,{className:"py-8 text-center text-slate-600",children:"Resignation details not found."})})]});const E=l.uploadedDocuments||[],_=Array.isArray(l.timeline)?l.timeline:[];return 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($r,{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:"Track your request progress and uploaded documents"})]}),l.status!=="Withdrawn"&&l.status!=="Completed"&&l.status!=="Rejected"&&!["NBH","DD Admin","Legal","F&F Initiated"].includes(l.currentStage)&&e.jsxs(se,{variant:"destructive",className:"bg-red-600 hover:bg-red-700",onClick:()=>w(!0),disabled:N,children:[e.jsx(Za,{className:"w-4 h-4 mr-2"}),N?"Withdrawing...":"Withdraw Request"]})]}),e.jsx(VV,{open:C,onOpenChange:w,children:e.jsxs(GV,{children:[e.jsxs(KV,{children:[e.jsx(ZV,{children:"Are you absolutely sure?"}),e.jsx(QV,{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(ce,{htmlFor:"withdrawal-reason",children:"Reason for withdrawal"}),e.jsx(ot,{id:"withdrawal-reason",placeholder:"Please enter a reason...",value:R,onChange:Z=>P(Z.target.value)})]})]}),e.jsxs(YV,{children:[e.jsx(JV,{disabled:N,children:"Cancel"}),e.jsx(XV,{onClick:Z=>{Z.preventDefault(),T()},className:"bg-red-600 hover:bg-red-700 text-white",disabled:N,children:N?"Withdrawing...":"Yes, Withdraw Request"})]})]})}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsxs(nt,{className:"flex items-center gap-2",children:[e.jsx(Fn,{className:"w-5 h-5 text-amber-600"}),"Request Summary"]}),e.jsx(Zt,{children:"Current request status and key metadata"})]}),e.jsxs(Me,{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:l.resignationId||l.id})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Status"}),e.jsx(Ae,{className:`border ${eH(l.status||"Pending")}`,children:l.status||"Pending"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Current Stage"}),e.jsx("p",{className:"text-slate-900",children:l.currentStage||"Submitted"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Submitted On"}),e.jsx("p",{className:"text-slate-900",children:Ht(l.submittedOn||l.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:l.resignationType||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Progress"}),e.jsxs("p",{className:"text-slate-900",children:[l.progressPercentage||0,"%"]})]})]})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsxs(nt,{className:"flex items-center gap-2",children:[e.jsx(kr,{className:"w-5 h-5 text-blue-600"}),"Outlet and Dates"]})}),e.jsxs(Me,{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:((M=l.outlet)==null?void 0:M.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:((q=l.outlet)==null?void 0:q.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:l.lastOperationalDateSales?Ht(l.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:l.lastOperationalDateServices?Ht(l.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:l.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(Er,{className:"w-3 h-3"}),"Outlet Address"]}),e.jsx("p",{className:"text-slate-900",children:((G=l.outlet)==null?void 0:G.address)||"-"})]})]})]}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsxs(nt,{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"w-5 h-5 text-purple-600"}),"Uploaded Documents"]}),e.jsx(Zt,{children:"Dealer can upload resignation-related documents for review"})]}),e.jsxs(Me,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-3 mb-4 p-3 border rounded-lg bg-slate-50",children:[e.jsxs("div",{children:[e.jsx(ce,{className:"text-xs",children:"Document Type"}),e.jsxs(wt,{value:m,onValueChange:p,children:[e.jsx(Ct,{children:e.jsx(St,{})}),e.jsx(At,{children:Ud.map(Z=>e.jsx(Pe,{value:Z,children:Z},Z))})]})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-xs",children:"Stage (Optional)"}),e.jsxs(wt,{value:u||"none",onValueChange:Z=>j(Z==="none"?"":Z),children:[e.jsx(Ct,{children:e.jsx(St,{placeholder:"Select stage"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"none",children:"No Stage"}),mE.map(Z=>e.jsx(Pe,{value:Z,children:Z},Z))]})]})]}),e.jsxs("div",{children:[e.jsx(ce,{className:"text-xs",children:"File"}),e.jsx("input",{type:"file",className:"h-10 w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm",onChange:Z=>{var W;return f(((W=Z.target.files)==null?void 0:W[0])||null)}})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs(se,{className:"w-full",onClick:$,disabled:d,children:[e.jsx(Dr,{className:"w-4 h-4 mr-2"}),d?"Uploading...":"Upload"]})})]}),e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Document Type"}),e.jsx(me,{children:"File"}),e.jsx(me,{children:"Uploaded By"}),e.jsx(me,{children:"Uploaded On"})]})}),e.jsx(Es,{children:E.length===0?e.jsx(ct,{children:e.jsx(de,{colSpan:4,className:"text-center text-slate-500 py-6",children:"No documents uploaded yet."})}):E.map(Z=>{var W;return e.jsxs(ct,{children:[e.jsx(de,{children:Z.documentType||"-"}),e.jsx(de,{children:Z.fileName||"-"}),e.jsx(de,{children:((W=Z.uploader)==null?void 0:W.fullName)||"-"}),e.jsx(de,{children:Ht(Z.createdAt)})]},Z.id)})})]})]})]}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsxs(nt,{className:"flex items-center gap-2",children:[e.jsx(zr,{className:"w-5 h-5 text-blue-600"}),"Work Notes Communication"]}),e.jsx(Zt,{children:"Official channel for internal-dealer clarifications"})]}),e.jsx(Me,{children:e.jsxs(se,{variant:"outline",onClick:()=>{var Z;return n(`/worknotes/resignation/${t}`,{state:{applicationName:((Z=l==null?void 0:l.dealer)==null?void 0:Z.fullName)||"Resignation Request",registrationNumber:(l==null?void 0:l.resignationId)||t}})},children:[e.jsx(zr,{className:"w-4 h-4 mr-2"}),"Open Work Notes"]})})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsxs(nt,{className:"flex items-center gap-2",children:[e.jsx($n,{className:"w-5 h-5 text-amber-600"}),"Progress Timeline"]})}),e.jsx(Me,{children:_.length===0?e.jsx("p",{className:"text-sm text-slate-500",children:"No timeline events available yet."}):e.jsx("div",{className:"space-y-2",children:_.slice().reverse().map((Z,W)=>e.jsxs("div",{className:"p-3 border rounded-lg bg-slate-50",children:[e.jsx("p",{className:"text-sm text-slate-900",children:Z.action||Z.stage||"Stage Update"}),e.jsx("p",{className:"text-xs text-slate-500",children:Ht(Z.timestamp||Z.createdAt)}),e.jsx("p",{className:"text-xs text-slate-600",children:Z.comments||Z.remarks||"No remarks"})]},`${Z.timestamp||Z.createdAt}-${W}`))})})]}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"Audit Trail"}),e.jsx(Zt,{children:"Traceability of status/actions on this request"})]}),e.jsx(Me,{children:g.length===0?e.jsx("p",{className:"text-sm text-slate-500",children:"No audit records found."}):e.jsx("div",{className:"space-y-2",children:g.map(Z=>e.jsxs("div",{className:"p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-slate-900",children:Z.action||"Action"}),e.jsx("p",{className:"text-xs text-slate-500",children:Ht(Z.createdAt||Z.timestamp)})]}),e.jsx("p",{className:"text-xs text-slate-600 mt-1",children:Z.remarks||Z.description||"No remarks"})]},Z.id))})})]})]})}const sH=t=>t==="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-slate-100 text-slate-700 border-slate-300";function nH({onViewDetails:t}){const[s,n]=v.useState(!1),[r,a]=v.useState(""),[l,c]=v.useState(""),[d,h]=v.useState(""),[x,f]=v.useState(""),[m,p]=v.useState(""),[u,j]=v.useState([]),[g,y]=v.useState(!0),[N,S]=v.useState(!1),[C,w]=v.useState(null),[R,P]=v.useState([]);v.useEffect(()=>{A()},[]);const A=async()=>{var T,E;try{y(!0);const[_,M,q]=await Promise.all([Il.getDashboardData(),Il.getConstitutionalChanges(),Te.getConstitutionalChangeMeta()]);w(_.profile);const G=fD((T=_.profile)==null?void 0:T.constitutionType);a(G),j(M.requests||[]),(E=q.data)!=null&&E.success&&Array.isArray(q.data.structureTargets)&&P(q.data.structureTargets)}catch(_){console.error("Fetch constitutional data error:",_),ee.error("Failed to load requests")}finally{y(!1)}},I=async T=>{var E,_;if(T.preventDefault(),!l){ee.error("Please select proposed constitution type");return}if(r===l){ee.error("Proposed constitution must be different from current");return}if(!d.trim()){ee.error("Please provide a reason for constitutional change");return}try{S(!0);const M={currentConstitution:r,changeType:l,reason:d.trim(),newPartnersDetails:x,shareholdingPattern:m};await Il.submitConstitutionalChange(M),ee.success("Constitutional change request submitted successfully"),n(!1),A(),c(""),h(""),f(""),p("")}catch(M){console.error("Submit constitutional change error:",M);const q=((_=(E=M==null?void 0:M.response)==null?void 0:E.data)==null?void 0:_.message)||"Failed to submit constitutional change request";ee.error(q)}finally{S(!1)}},$=[{title:"Total Requests",value:u.length,icon:Ki,color:"bg-blue-500"},{title:"Pending",value:u.filter(T=>T.status!=="Completed"&&T.status!=="Rejected").length,icon:$n,color:"bg-yellow-500"},{title:"Completed",value:u.filter(T=>T.status==="Completed").length,icon:fs,color:"bg-green-500"}];return e.jsxs("div",{className:"space-y-6",children:[g&&e.jsx("div",{className:"min-h-[400px] flex items-center justify-center",children:e.jsx(ss,{className:"w-8 h-8 text-blue-600 animate-spin"})}),!g&&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(os,{open:s,onOpenChange:n,children:[e.jsx(Hl,{asChild:!0,children:e.jsxs(se,{className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(cn,{className:"w-4 h-4 mr-2"}),"New Constitutional Change"]})}),e.jsxs(ls,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Submit Constitutional Change Request"}),e.jsx(vs,{children:"Request to change your dealership's business constitution structure"})]}),e.jsxs("form",{onSubmit:I,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(ce,{htmlFor:"currentConstitution",children:"Current Constitution *"}),e.jsx(ot,{id:"currentConstitution",value:r,disabled:!0,className:"bg-slate-100"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"proposedConstitution",children:"Proposed Constitution *"}),e.jsxs(wt,{value:l,onValueChange:c,required:!0,children:[e.jsx(Ct,{children:e.jsx(St,{placeholder:"Select new constitution"})}),e.jsx(At,{children:R.filter(T=>T.value!==r).map(T=>e.jsx(Pe,{value:T.value,children:T.label},T.value))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"reason",children:"Reason for Change *"}),e.jsx(Fs,{id:"reason",placeholder:"Please provide detailed reason for constitutional change...",value:d,onChange:T=>h(T.target.value),rows:4,required:!0})]}),(l==="Partnership"||l==="LLP")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"newPartners",children:"Details of New Partners/Members"}),e.jsx(Fs,{id:"newPartners",placeholder:"Name, relationship, and experience of new partners...",value:x,onChange:T=>f(T.target.value),rows:3})]}),(l==="Private Limited"||l==="LLP")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"shareholdingPattern",children:"Proposed Shareholding Pattern"}),e.jsx(Fs,{id:"shareholdingPattern",placeholder:"Details of share distribution among partners/directors...",value:m,onChange:T=>p(T.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:"• Partnership Deed (if applicable)"}),e.jsx("li",{children:"• LLP Agreement (if applicable)"}),e.jsx("li",{children:"• Certificate of Incorporation (if applicable)"}),e.jsx("li",{children:"• MOA & AOA (if applicable)"}),e.jsx("li",{children:"• Board Resolution"}),e.jsx("li",{children:"• Aadhaar & PAN of all partners/directors"})]})]}),e.jsxs(rn,{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:N,children:N?e.jsxs(e.Fragment,{children:[e.jsx(ss,{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:$.map((T,E)=>{const _=T.icon;return e.jsxs(Le,{children:[e.jsxs(tt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(nt,{className:"text-sm",children:T.title}),e.jsx("div",{className:`${T.color} p-2 rounded-lg`,children:e.jsx(_,{className:"h-4 w-4 text-white"})})]}),e.jsx(Me,{children:e.jsx("div",{className:"text-slate-900 text-2xl",children:T.value})})]},E)})}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"My Constitutional Change Requests"}),e.jsx(Zt,{children:"View and track all your constitutional change requests"})]}),e.jsx(Me,{children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Current"}),e.jsx(me,{children:"Proposed"}),e.jsx(me,{children:"Submitted On"}),e.jsx(me,{children:"Current Status"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Es,{children:u.length===0?e.jsx(ct,{children:e.jsx(de,{colSpan:7,className:"text-center py-4 text-slate-500",children:"No constitutional change requests found"})}):u.map(T=>e.jsxs(ct,{children:[e.jsx(de,{children:e.jsx("span",{className:"text-slate-900",children:T.requestId})}),e.jsx(de,{children:e.jsx(Ae,{variant:"outline",children:T.currentConstitution})}),e.jsx(de,{children:e.jsx(Ae,{className:"bg-blue-100 text-blue-700 border-blue-300",children:T.changeType})}),e.jsx(de,{className:"text-slate-600",children:Ht(T.createdAt)}),e.jsx(de,{children:e.jsx(Ae,{className:`border ${sH(T.status)}`,children:T.status})}),e.jsx(de,{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:`${T.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-xs text-slate-600",children:[T.progressPercentage||0,"%"]})]})}),e.jsx(de,{children:e.jsxs(se,{variant:"ghost",size:"sm",onClick:()=>t&&t(T.requestId),children:[e.jsx(nn,{className:"w-4 h-4 mr-1"}),"View"]})})]},T.id))})]})})]})]})]})}const rH=t=>t==="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")||t.includes("Revoked")?"bg-red-100 text-red-700 border-red-300":"bg-slate-100 text-slate-700 border-slate-300",L0=(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 aH({onViewDetails:t}){const[s,n]=v.useState(!1),[r,a]=v.useState(null),[l,c]=v.useState(""),[d,h]=v.useState(""),[x,f]=v.useState(""),[m,p]=v.useState(""),[u,j]=v.useState(""),[g,y]=v.useState(""),[N,S]=v.useState(""),[C,w]=v.useState(""),[R,P]=v.useState(""),[A,I]=v.useState([]),[$,T]=v.useState([]),[E,_]=v.useState(""),[M,q]=v.useState(""),[G,Z]=v.useState(!1),[W,z]=v.useState([]),[F,B]=v.useState([]),[D,O]=v.useState(!0),[V,K]=v.useState(!1);v.useEffect(()=>{U(),X()},[]);const Y=E?$.filter(ve=>ve.stateId===E):$,U=async()=>{try{O(!0);const ve=await Il.getDashboardData(),Se=await Il.getRelocationRequests();z(ve.outlets||[]),B(Se.requests||[])}catch(ve){console.error("Fetch relocation data error:",ve),ee.error(L0(ve,"Failed to load outlets and requests"))}finally{O(!1)}},X=async()=>{var ve,Se;try{Z(!0);const[We,Ce]=await Promise.all([Ss.getStates().catch(()=>({success:!1})),Ss.getDistricts({limit:"all"}).catch(()=>({success:!1}))]),fe=We!=null&&We.success?((ve=We.data)==null?void 0:ve.states)||We.data||[]:[],Ye=Ce!=null&&Ce.success?((Se=Ce.data)==null?void 0:Se.districts)||Ce.data||[]:[];I(fe),T(Ye)}catch(We){console.error("Fetch master data error:",We),ee.error(L0(We,"Failed to load master data"))}finally{Z(!1)}},ne=ve=>{_(ve),q("");const Se=A.find(We=>We.id===ve);Se&&h(Se.name)},oe=ve=>{q(ve);const Se=$.find(We=>We.id===ve);Se&&c(Se.name)},re=async ve=>{if(ve.preventDefault(),!r){ee.error("Please select an outlet");return}if(!l.trim()||!d.trim()||!x.trim()){ee.error("Please provide complete relocation details");return}if(!m.trim()){ee.error("Please provide a reason for relocation");return}if(!u.trim()||!g||!N){ee.error("Please fill all mandatory fields (Distance, Property Type, Date)");return}try{K(!0);const Se={outletId:r.id,relocationType:"Intercity",currentAddress:r.address||"",currentCity:r.city||"",currentState:r.state||"",newAddress:x,newCity:l,newState:d,newDistrictId:M||null,newStateId:E||null,distance:u,reason:m,propertyType:g,proposedDate:N,proposedLatitude:C?parseFloat(C):null,proposedLongitude:R?parseFloat(R):null,currentLatitude:r.latitude||null,currentLongitude:r.longitude||null};await Il.submitRelocationRequest(Se),ee.success(`Relocation request submitted successfully for ${r.name}`),n(!1),U(),a(null),c(""),h(""),f(""),p(""),j(""),y(""),S(""),w(""),P(""),t&&U()}catch(Se){console.error("Submit relocation error:",Se),ee.error(L0(Se,"Failed to submit relocation request"))}finally{K(!1)}},ge=[{title:"Total Requests",value:F.length,icon:Er,color:"bg-blue-500"},{title:"Pending",value:F.filter(ve=>ve.status!=="Completed"&&ve.status!=="Rejected").length,icon:$n,color:"bg-yellow-500"},{title:"Approved",value:F.filter(ve=>ve.status==="Completed").length,icon:Ml,color:"bg-green-500"}];return e.jsxs("div",{className:"space-y-6",children:[D&&e.jsx("div",{className:"min-h-[400px] flex items-center justify-center",children:e.jsx(ss,{className:"w-8 h-8 text-amber-600 animate-spin"})}),!D&&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(os,{open:s,onOpenChange:n,children:[e.jsx(Hl,{asChild:!0,children:e.jsxs(se,{className:"bg-amber-600 hover:bg-amber-700 text-white",children:[e.jsx(cn,{className:"w-4 h-4 mr-2"}),"New Relocation Request"]})}),e.jsxs(ls,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ms,{children:[e.jsx(us,{children:"Submit Relocation Request"}),e.jsx(vs,{children:"Provide details about the outlet you want to relocate and its proposed new location"})]}),e.jsxs("form",{onSubmit:re,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"outlet",children:"Select Outlet to Relocate *"}),e.jsxs(wt,{value:r==null?void 0:r.id,onValueChange:ve=>a(W.find(Se=>Se.id===ve)),required:!0,children:[e.jsx(Ct,{children:e.jsx(St,{placeholder:"Select an outlet"})}),e.jsx(At,{children:W.map(ve=>e.jsxs(Pe,{value:ve.id,children:[ve.name," (",ve.code,")"]},ve.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(ce,{htmlFor:"newState",children:"Proposed State *"}),e.jsxs(wt,{value:E,onValueChange:ne,required:!0,disabled:G,children:[e.jsx(Ct,{id:"newState",children:e.jsx(St,{placeholder:G?"Loading...":"Select state"})}),e.jsx(At,{children:A.map(ve=>e.jsx(Pe,{value:ve.id,children:ve.name},ve.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"newCity",children:"Proposed City/District *"}),e.jsxs(wt,{value:M,onValueChange:oe,required:!0,disabled:!E||G,children:[e.jsx(Ct,{id:"newCity",children:e.jsx(St,{placeholder:E?G?"Loading...":"Select district":"Select state first"})}),e.jsx(At,{children:Y.map(ve=>e.jsx(Pe,{value:ve.id,children:ve.name},ve.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"newAddress",children:"Proposed Full Address *"}),e.jsx(Fs,{id:"newAddress",placeholder:"Enter detailed address of the proposed new location...",value:x,onChange:ve=>f(ve.target.value),rows:3,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"distance",children:"Estimated Distance from Current Location (in km) *"}),e.jsx(ot,{id:"distance",placeholder:"e.g. 5.5 km",value:u,onChange:ve=>j(ve.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(ce,{htmlFor:"propertyType",children:"Property Type *"}),e.jsxs(wt,{value:g,onValueChange:y,required:!0,children:[e.jsx(Ct,{id:"propertyType",children:e.jsx(St,{placeholder:"Select type"})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"Owned",children:"Owned"}),e.jsx(Pe,{value:"Leased",children:"Leased"}),e.jsx(Pe,{value:"Rented",children:"Rented"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"expectedDate",children:"Expected Relocation Date *"}),e.jsx(ot,{id:"expectedDate",type:"date",value:N,onChange:ve=>S(ve.target.value),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{htmlFor:"reason",children:"Reason for Relocation *"}),e.jsx(Fs,{id:"reason",placeholder:"Why do you want to relocate this outlet?",value:m,onChange:ve=>p(ve.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(rn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(se,{type:"submit",className:"bg-amber-600 hover:bg-amber-700 text-white",disabled:V,children:V?e.jsxs(e.Fragment,{children:[e.jsx(ss,{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:ge.map((ve,Se)=>{const We=ve.icon;return e.jsxs(Le,{children:[e.jsxs(tt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(nt,{className:"text-sm",children:ve.title}),e.jsx("div",{className:`${ve.color} p-2 rounded-lg`,children:e.jsx(We,{className:"h-4 w-4 text-white"})})]}),e.jsx(Me,{children:e.jsx("div",{className:"text-slate-900 text-2xl",children:ve.value})})]},Se)})}),e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(nt,{children:"My Relocation Requests"}),e.jsx(Zt,{children:"Track the status of your relocation applications"})]}),e.jsx(Me,{children:e.jsxs(ks,{children:[e.jsx(Rs,{children:e.jsxs(ct,{children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Outlet"}),e.jsx(me,{children:"Target Location"}),e.jsx(me,{children:"Submitted On"}),e.jsx(me,{children:"Current Status"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Es,{children:F.length===0?e.jsx(ct,{children:e.jsx(de,{colSpan:7,className:"text-center py-4 text-slate-500",children:"No relocation requests found"})}):F.map(ve=>{var Se;return e.jsxs(ct,{children:[e.jsx(de,{children:e.jsx("span",{className:"text-slate-900 font-medium",children:ve.requestId})}),e.jsx(de,{children:(Se=ve.outlet)==null?void 0:Se.name}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[e.jsx("span",{className:"text-slate-500",children:ve.currentCity}),e.jsx(To,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:ve.newCity})]})}),e.jsx(de,{className:"text-slate-600",children:Ht(ve.createdAt)}),e.jsx(de,{children:e.jsx(Ae,{className:`border ${rH(ve.status)}`,children:ve.status})}),e.jsx(de,{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-amber-500 h-2 rounded-full",style:{width:`${ve.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-xs text-slate-600",children:[ve.progressPercentage||0,"%"]})]})}),e.jsx(de,{children:e.jsxs(se,{variant:"ghost",size:"sm",onClick:()=>t&&t(ve.requestId),children:[e.jsx(nn,{className:"w-4 h-4 mr-1"}),"View"]})})]},ve.id)})})]})})]})]})]})}const iH=["Personal Information","Financial Information","Location & Background","Motivation","Business Structure","Professional Background","Infrastructure","Financial Planning","Growth & Expansion","Brand Affinity","Vision & Strategy"],dC=()=>{const{id:t}=Bc(),s=qn(),[n,r]=v.useState(`v${new Date().toISOString().split("T")[0]}`),[a,l]=v.useState([{sectionName:"Personal Information",questionText:"",inputType:"text",weight:0,order:1,isMandatory:!0}]),[c,d]=v.useState(!1),[h,x]=v.useState(!!t);v.useEffect(()=>{t&&f(t)},[t]);const f=async C=>{var w;try{x(!0);const R=await Te.getQuestionnaireById(C);if((w=R.data)!=null&&w.success){const P=R.data.data;r(`${P.version} (Copy)`),P.questions&&P.questions.length>0&&l(P.questions.map(A=>{var T,E;let I=(T=A.inputType)==null?void 0:T.toLowerCase().trim();return I==="mcq"&&(I="select"),["text","number","file","yesno","select","radio","textarea","email","mcq"].includes(I)||(I="text"),{...A,inputType:I,weight:parseFloat(A.weight),options:((E=A.questionOptions)==null?void 0:E.map(_=>({text:_.optionText,score:_.score})))||[]}}))}else ee.error("Failed to load questionnaire"),s("/questionnaires")}catch(R){console.error(R),ee.error("Error fetching questionnaire")}finally{x(!1)}},m=a.reduce((C,w)=>C+(w.weight||0),0),p=()=>{l([...a,{sectionName:"Personal Information",questionText:"",inputType:"text",weight:0,order:a.length+1,isMandatory:!0}])},u=C=>{const R=a.filter((P,A)=>A!==C).map((P,A)=>({...P,order:A+1}));l(R)},j=(C,w,R)=>{var A;const P=[...a];if(w==="weight"){const I=parseFloat(R)||0;P[C].options&&(P[C].options=P[C].options.map($=>({...$,score:Math.min($.score,I)})))}w==="inputType"&&R==="yesno"&&(!P[C].options||((A=P[C].options)==null?void 0:A.length)===0)?P[C].options=[{text:"Yes",score:P[C].weight||5},{text:"No",score:0}]:w==="inputType"&&R==="select"&&!P[C].options&&(P[C].options=[]),P[C]={...P[C],[w]:R},l(P)},g=C=>{const w=[...a];w[C].options||(w[C].options=[]),w[C].options.push({text:"",score:0}),l(w)},y=(C,w,R,P)=>{const A=[...a];if(A[C].options){let I=P;if(R==="score"){const $=A[C].weight||0;I=Math.min(parseFloat(P)||0,$)}A[C].options[w]={...A[C].options[w],[R]:I},l(A)}},N=(C,w)=>{const R=[...a];R[C].options&&(R[C].options=R[C].options.filter((P,A)=>A!==w),l(R))},S=async()=>{var C;if(a.some(w=>!w.questionText)){ee.error("All questions must have text");return}for(let w=0;w<a.length;w++){const R=a[w];if(R.inputType==="select"||R.inputType==="yesno"){const P=(C=R.options)==null?void 0:C.find(A=>A.score>R.weight);if(P){ee.error(`Question ${w+1}: Option "${P.text}" score (${P.score}) exceeds question weightage (${R.weight})`);return}}}if(m!==100){ee.error(`Total weightage must be exactly 100. Current total: ${m}`);return}try{d(!0),await Te.createQuestionnaireVersion({version:n,questions:a}),ee.success("Questionnaire version created successfully"),s("/questionnaires")}catch(w){console.error(w),ee.error("Failed to create questionnaire")}finally{d(!1)}};return h?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-amber-600"})}):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($r,{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 ${m===100?"bg-green-50 border-green-200 text-green-700":"bg-amber-50 border-amber-200 text-amber-700"}`,children:[m!==100&&e.jsx(Ks,{size:16}),e.jsxs("span",{className:"text-sm font-semibold",children:["Total Score: ",m,"/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-amber-500 outline-none",placeholder:"Version Name (e.g. v2.0)"}),e.jsxs("button",{onClick:S,disabled:c,className:"bg-amber-600 text-white px-6 py-2 rounded-lg flex items-center gap-2 hover:bg-amber-700 disabled:bg-slate-300 disabled:cursor-not-allowed transition shadow-sm font-medium whitespace-nowrap",children:[e.jsx(Yi,{size:18})," ",c?"Saving...":"Publish"]})]})]})]}),e.jsx("div",{className:"space-y-4",children:a.map((C,w)=>{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:w+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:P=>j(w,"questionText",P.target.value),className:"w-full border border-slate-300 p-2.5 rounded-lg focus:ring-2 focus:ring-amber-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:P=>j(w,"sectionName",P.target.value),className:"w-full border border-slate-300 p-2.5 rounded-lg focus:ring-2 focus:ring-amber-500 outline-none bg-white",children:iH.map(P=>e.jsx("option",{value:P,children:P},P))})]}),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:P=>j(w,"inputType",P.target.value),className:"w-full border border-slate-300 p-2.5 rounded-lg focus:ring-2 focus:ring-amber-500 outline-none bg-white",children:[e.jsx("option",{value:"text",children:"Text Input"}),e.jsx("option",{value:"email",children:"Email Address"}),e.jsx("option",{value:"textarea",children:"Long Text (Textarea)"}),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:"Multiple Choice (Dropdown)"}),e.jsx("option",{value:"radio",children:"Multiple Choice (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:P=>j(w,"weight",parseFloat(P.target.value)||0),className:"w-full border border-slate-300 p-2.5 rounded-lg focus:ring-2 focus:ring-amber-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((P,A)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"text",value:P.text,onChange:I=>y(w,A,"text",I.target.value),className:"flex-1 border border-slate-300 p-2 rounded-md text-sm focus:ring-1 focus:ring-amber-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(P.score)?0:P.score,max:isNaN(C.weight)?0:C.weight,min:0,onChange:I=>y(w,A,"score",I.target.value),className:`w-20 border ${P.score>C.weight||isNaN(P.score)?"border-red-500 text-red-600":"border-slate-300"} p-2 rounded-md text-sm focus:ring-1 focus:ring-amber-500 outline-none`})]}),e.jsx("button",{onClick:()=>N(w,A),className:"p-1.5 text-slate-400 hover:text-red-500 transition-colors",title:"Remove Option",children:e.jsx(Gn,{size:16})})]},A))}),e.jsxs("button",{onClick:()=>g(w),className:"mt-3 text-sm flex items-center gap-1 text-amber-600 hover:text-amber-700 font-medium",children:[e.jsx(cn,{size:16})," Add Option"]})]})]}),e.jsx("button",{onClick:()=>u(w),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(Gn,{size:18})})]},w)})}),e.jsxs("button",{onClick:p,className:"mt-8 w-full border-2 border-dashed border-slate-300 p-4 rounded-xl text-slate-500 hover:border-amber-500 hover:text-amber-600 hover:bg-amber-50/30 flex justify-center items-center gap-2 transition-all font-medium",children:[e.jsx(cn,{size:20})," Add Another Question"]})]})},uC=()=>{const[t,s]=v.useState([]),[n,r]=v.useState(!0),a=qn();v.useEffect(()=>{l()},[]);const l=async()=>{var c;try{r(!0);const d=await Te.getAllQuestionnaires();(c=d.data)!=null&&c.success?s(d.data.data):ee.error("Failed to load questionnaire versions")}catch(d){console.error(d),ee.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-amber-600 text-white px-4 py-2 rounded-lg flex items-center gap-2 hover:bg-amber-700 transition",children:[e.jsx(cn,{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-amber-600"})}):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-amber-600 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(c=>e.jsxs("tr",{className:"hover:bg-slate-50 transition",children:[e.jsx("td",{className:"p-4 font-medium text-slate-900",children:c.version}),e.jsx("td",{className:"p-4",children:c.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(Ys,{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(Za,{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($n,{size:14,className:"text-slate-400"}),m9(new Date(c.createdAt),"MMM dd, yyyy HH:mm")]})}),e.jsx("td",{className:"p-4 text-right",children:e.jsxs("button",{onClick:()=>a(`/questionnaire-builder/${c.id}`),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded text-sm font-medium text-slate-600 hover:text-amber-600 hover:bg-amber-50 transition border border-slate-200 hover:border-amber-200",children:[e.jsx(ur,{size:14})," Edit / Clone"]})})]},c.id))})]})})]})},M0=[{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"}],lH=()=>{const[t,s]=v.useState([]),[,n]=v.useState(!1),[r,a]=v.useState("KT_MATRIX"),[l,c]=v.useState(!1),[d,h]=v.useState(null),[x,f]=v.useState(!1),[m,p]=v.useState(!1),u=v.useCallback(async()=>{var E;try{n(!0);const _=await Te.getInterviewConfigs();(E=_.data)!=null&&E.success&&s(_.data.data||[])}catch(_){console.error("Fetch configs error:",_),ee.error("Failed to load interview configurations")}finally{n(!1)}},[]);v.useEffect(()=>{u()},[u]);const j=E=>t.find(_=>_.configType===E&&_.isActive),g=E=>{var M;const _={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}]};h({configType:E,name:`${((M=M0.find(q=>q.value===E))==null?void 0:M.label)||"New Config"}`,version:`v${new Date().toISOString().split("T")[0]}`,isActive:!0,items:_[E]||[]}),c(!0)},y=async E=>{var _;try{n(!0);const M=await Te.getInterviewConfigById(E);(_=M.data)!=null&&_.success&&(h(M.data.data),c(!0))}catch{ee.error("Failed to load configuration for editing")}finally{n(!1)}},N=async()=>{var E,_;if(d){if(!d.name||!d.version){ee.error("Name and version are required");return}if(!d.items||d.items.length===0){ee.error("Add at least one item");return}if(d.configType==="KT_MATRIX"){const M=d.items.reduce((q,G)=>q+(Number(G.weight)||0),0);if(Math.abs(M-100)>.01){ee.error(`KT Matrix total weight must be 100. Current: ${M}`);return}for(const q of d.items)if(q.type==="select"&&(!q.options||q.options.length===0)){ee.error(`Select item "${q.label}" must have options`);return}}try{f(!0);const M={configType:d.configType,name:d.name,version:d.version,items:d.items.map((q,G)=>{var Z;return{...q,order:q.order||G+1,options:(Z=q.options)==null?void 0:Z.map((W,z)=>({...W,order:W.order||z+1}))}})};d.id?(await Te.updateInterviewConfig(d.id,M),ee.success("Configuration updated successfully")):(await Te.createInterviewConfig(M),ee.success("New configuration published successfully")),c(!1),h(null),await u()}catch(M){console.error("Save error:",M),ee.error(((_=(E=M==null?void 0:M.response)==null?void 0:E.data)==null?void 0:_.message)||"Failed to save configuration")}finally{f(!1)}}},S=async E=>{if(confirm("Are you sure you want to delete this configuration?"))try{await Te.deleteInterviewConfig(E),ee.success("Configuration deleted"),await u()}catch{ee.error("Failed to delete configuration")}},C=async()=>{if(confirm("This will reset all interview configurations to system defaults. Continue?"))try{p(!0),await Te.initializeDefaultInterviewConfigs(),ee.success("Default configurations initialized"),await u()}catch{ee.error("Failed to initialize defaults")}finally{p(!1)}},w=()=>{var _,M;if(!d)return;const E={itemKey:`field_${(((_=d.items)==null?void 0:_.length)||0)+1}`,label:"",type:d.configType==="KT_MATRIX"?"select":"textarea",order:(((M=d.items)==null?void 0:M.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};h({...d,items:[...d.items||[],E]})},R=E=>{var q;if(!d)return;const M=(((q=d.items)==null?void 0:q.filter((G,Z)=>Z!==E))||[]).map((G,Z)=>({...G,order:Z+1}));h({...d,items:M})},P=(E,_,M)=>{if(!d)return;const q=[...d.items||[]];q[E]={...q[E],[_]:M},h({...d,items:q})},A=E=>{if(!d)return;const _=[...d.items||[]],M=_[E];M.options||(M.options=[]),M.options.push({optionLabel:"",optionValue:"",score:0,order:M.options.length+1}),h({...d,items:_})},I=(E,_,M,q)=>{if(!d)return;const G=[...d.items||[]];G[E].options&&(G[E].options[_]={...G[E].options[_],[M]:q},h({...d,items:G}))},$=(E,_)=>{if(!d)return;const M=[...d.items||[]];M[E].options&&(M[E].options=M[E].options.filter((q,G)=>G!==_),h({...d,items:M}))},T=(d==null?void 0:d.configType)==="KT_MATRIX"?(d.items||[]).reduce((E,_)=>E+(Number(_.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:m,className:"gap-2",children:[e.jsx(Qv,{size:16})," ",m?"Initializing...":"Reset to Defaults"]})]}),e.jsxs(Pn,{value:r,onValueChange:a,children:[e.jsx(_n,{className:"grid w-full grid-cols-3",children:M0.map(E=>e.jsx(Wt,{value:E.value,children:E.label},E.value))}),M0.map(E=>{var q;const _=j(E.value),M=t.filter(G=>G.configType===E.value);return e.jsx(Gt,{value:E.value,children:e.jsxs(Le,{children:[e.jsxs(tt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(nt,{className:"text-lg",children:E.label}),e.jsx("p",{className:"text-sm text-slate-500",children:E.description})]}),e.jsxs(se,{onClick:()=>g(E.value),className:"gap-2",children:[e.jsx(cn,{size:16})," Publish New Version"]})]}),e.jsxs(Me,{children:[_?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: ",_.name]}),e.jsxs("p",{className:"text-sm text-green-700",children:["Version ",_.version," • ",((q=_.items)==null?void 0:q.length)||0," items"]})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>_.id&&y(_.id),children:e.jsx(uw,{size:16})})})]})}):e.jsx("div",{className:"mb-6 p-4 bg-amber-50 border border-amber-200 rounded-lg text-amber-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"}),M.length===0?e.jsx("p",{className:"text-sm text-slate-500",children:"No versions found."}):e.jsx("div",{className:"space-y-2",children:M.map(G=>{var Z;return e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${G.isActive?"bg-green-50 border-green-200":"bg-white border-slate-200"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[G.isActive&&e.jsx(Ae,{className:"bg-green-600",children:"Active"}),e.jsx("span",{className:"font-medium text-sm",children:G.name}),e.jsx("span",{className:"text-xs text-slate-500",children:G.version}),e.jsxs("span",{className:"text-xs text-slate-400",children:[((Z=G.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:()=>G.id&&y(G.id),children:e.jsx(uw,{size:14})}),e.jsx(se,{variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",onClick:()=>G.id&&S(G.id),children:e.jsx(Gn,{size:14})})]})]},G.id)})})]})]})},E.value)})]})," ",e.jsx(os,{open:l,onOpenChange:c,children:e.jsxs(ls,{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(us,{className:"text-lg font-bold text-slate-900 leading-none",children:d!=null&&d.id?"Edit Configuration":"New Configuration"}),e.jsxs(vs,{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 ${T===100?"bg-emerald-50 text-emerald-700 border border-emerald-100":"bg-amber-50 text-amber-700 border border-amber-100"}`,children:["Weight: ",T,"% / 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(ce,{className:"text-[10px] font-bold text-slate-400 uppercase tracking-widest pl-1",children:"Name"}),e.jsx(ot,{value:d.name,onChange:E=>h({...d,name:E.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(ce,{className:"text-[10px] font-bold text-slate-400 uppercase tracking-widest pl-1",children:"Version"}),e.jsx(ot,{value:d.version,onChange:E=>h({...d,version:E.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:w,className:"h-full border-dashed border-slate-300 text-slate-500 hover:text-slate-900 text-xs font-bold px-4",children:[e.jsx(cn,{size:14,className:"mr-2"})," Add Criteria"]})})]}),e.jsx("div",{className:"overflow-x-auto 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((E,_)=>e.jsxs(gt.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(_+1).padStart(2,"0")}),e.jsx("td",{className:"px-4 py-3 align-top",children:e.jsx(ot,{value:E.label,onChange:M=>P(_,"label",M.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(ot,{value:E.itemKey,onChange:M=>P(_,"itemKey",M.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(wt,{value:E.type,onValueChange:M=>P(_,"type",M),children:[e.jsx(Ct,{className:"h-10 border-slate-100 hover:border-slate-300 bg-slate-50/30 text-xs focus:ring-0",children:e.jsx(St,{})}),e.jsxs(At,{children:[e.jsx(Pe,{value:"select",children:"Selection"}),e.jsx(Pe,{value:"text",children:"Text"}),e.jsx(Pe,{value:"textarea",children:"Comment"}),e.jsx(Pe,{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(ot,{type:"number",value:E.weight||"",onChange:M=>P(_,"weight",parseFloat(M.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",(E.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($d,{size:10,className:"text-slate-600"})}),e.jsx("button",{type:"button",onClick:()=>P(_,"weight",Math.max(0,(E.weight||0)-1)),className:"flex-1 px-1.5 hover:bg-slate-200/50 flex items-center justify-center",children:e.jsx(la,{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(ot,{type:"number",value:E.maxScore||"",onChange:M=>P(_,"maxScore",parseFloat(M.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",(E.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($d,{size:10,className:"text-slate-600"})}),e.jsx("button",{type:"button",onClick:()=>P(_,"maxScore",Math.max(0,(E.maxScore||0)-1)),className:"flex-1 px-1.5 hover:bg-slate-200/50 flex items-center justify-center",children:e.jsx(la,{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:E.isRequired,onChange:M=>P(_,"isRequired",M.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(_),children:e.jsx(Gn,{size:16})})})]}),E.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-amber-400 rounded-full"})," Selection Choices Profile"]}),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(_),children:[e.jsx(cn,{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:(E.options||[]).map((M,q)=>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(ot,{placeholder:"Label",value:M.optionLabel,onChange:G=>I(_,q,"optionLabel",G.target.value),className:"h-9 border-slate-200 bg-white text-xs font-normal"})}),e.jsx("div",{className:"col-span-3",children:e.jsx(ot,{placeholder:"Value",value:M.optionValue,onChange:G=>I(_,q,"optionValue",G.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(ot,{type:"number",placeholder:"0",value:M.score,onChange:G=>I(_,q,"score",parseFloat(G.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:()=>I(_,q,"score",(M.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($d,{size:8})}),e.jsx("button",{onClick:()=>I(_,q,"score",(M.score||0)-1),className:"flex-1 px-1 hover:bg-slate-200 flex items-center justify-center",children:e.jsx(la,{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),children:e.jsx(Gn,{size:13})})})]},q))})]})})]})]},_))})]})})})]})}),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:()=>c(!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:N,disabled:x,children:[x?e.jsx(ss,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx(Yi,{className:"w-4 h-4 mr-2"}),"Commit Changes"]})]})]})})]})},oH=()=>{const[t,s]=v.useState([]),[n,r]=v.useState(!0),[a,l]=v.useState(1),[c,d]=v.useState(1),h=15,x=qn(),f=async j=>{try{r(!0);const g=await _o.getNotifications(j,h);g.success&&(s(g.data),g.pagination&&d(g.pagination.totalPages))}catch(g){console.error("Failed to fetch notifications",g)}finally{r(!1)}};v.useEffect(()=>{f(a)},[a]);const m=async(j,g)=>{g.stopPropagation(),await _o.markAsRead(j),f(a)},p=async()=>{await _o.markAllAsRead(),f(a)},u=async j=>{if(j.isRead||await _o.markAsRead(j.id),j.link){const g=j.link;try{const y=new URL(g);y.origin===window.location.origin?x(y.pathname+y.search+y.hash):window.open(g,"_blank")}catch{x(g)}}else f(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(Yd,{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:p,disabled:n||!t.some(j=>!j.isRead),children:[e.jsx(Bn,{className:"w-4 h-4 mr-2"}),"Mark all as read"]})]}),e.jsx(Le,{className:"shadow-sm border-gray-200",children:e.jsx(Me,{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(Yd,{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(j=>e.jsxs("div",{className:`p-4 hover:bg-gray-50 transition-colors flex items-start gap-4 cursor-pointer ${j.isRead?"":"bg-blue-50/50"}`,onClick:()=>u(j),children:[e.jsx("div",{className:"mt-1 flex-shrink-0 cursor-pointer",onClick:g=>m(j.id,g),children:j.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 ${j.isRead?"text-gray-700":"text-gray-900"}`,children:j.title}),e.jsxs("div",{className:"flex items-center text-xs text-gray-500 whitespace-nowrap ml-4",children:[e.jsx(Js,{className:"w-3 h-3 mr-1"}),Dk(new Date(j.createdAt),{addSuffix:!0})]})]}),e.jsx("p",{className:"text-sm text-gray-600 line-clamp-2",children:j.message})]})]},j.id))})})}),!n&&c>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:c})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(se,{variant:"outline",size:"sm",disabled:a===1,onClick:()=>l(j=>Math.max(1,j-1)),children:[e.jsx(qc,{className:"w-4 h-4"}),"Previous"]}),e.jsxs(se,{variant:"outline",size:"sm",disabled:a===c,onClick:()=>l(j=>Math.min(c,j+1)),children:["Next",e.jsx(el,{className:"w-4 h-4"})]})]})]})]})},hC=({...t})=>e.jsx(HI,{theme:"light",className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...t}),cH=({onLogout:t,title:s})=>e.jsxs("div",{className:"flex h-screen bg-slate-50 overflow-hidden",children:[e.jsx(tL,{onLogout:t}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(x9,{title:s,onRefresh:()=>window.location.reload()}),e.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:e.jsx(O4,{})})]})]});function dH(){const t=su(),{user:s,isAuthenticated:n,loading:r}=Nn(S=>S.auth),[a,l]=v.useState(!1),c=qn(),d=Ul(),h=(s==null?void 0:s.role)||(s==null?void 0:s.roleCode)||"",x=String(h).trim().toLowerCase(),f=S=>S.map(C=>C.toLowerCase()).includes(x),m=["DD Admin","ASM","RBM","DD Lead","ZBH","NBH","Legal","Legal Admin","Super Admin"],p=["ASM","RBM","ZBH","DD Lead","DD Head","NBH","Legal Admin","Legal","DD Admin","CCO","CEO","Super Admin"],u=["DD Admin","DD Lead","NBH","Finance","Finance Admin","Super Admin"],j=["Finance","Finance Admin"];v.useEffect(()=>{t(Qh())},[t]);const g=async(S,C)=>{var w;try{const R=await Te.login({email:S,password:C});if(R.ok&&R.data){const{token:P,user:A}=R.data;localStorage.setItem("token",P);const I={id:A.id,name:A.fullName||S.split("@")[0],email:A.email,password:C,role:typeof A.role=="string"?A.role:A.roleCode||"User"};t(JC({user:I,token:P})),ee.success(`Welcome back, ${I.name}!`),l(!1)}else{const P=((w=R.data)==null?void 0:w.message)||"Invalid credentials";ee.error(P)}}catch(R){console.error("Login error:",R),ee.error("Something went wrong. Please try again.")}},y=()=>{t(e2()),l(!1),ee.info("Logged out successfully"),c("/")};v.useEffect(()=>{const S=()=>{y(),ee.error("Session expired. Please login again.")};return window.addEventListener("auth:logout",S),()=>window.removeEventListener("auth:logout",S)},[t,c]);const N=S=>S.startsWith("/applications/")&&S.length>14?"Application Details":S.includes("/resignation/")&&S.length>13?"Resignation Details":{"/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","/notifications":"Notifications"}[S]||"Dashboard";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(e8,{children:[e.jsxs(Q0,{children:[e.jsx(Ns,{path:"/prospective-dashboard/*",element:e.jsx(sw,{allowedRoles:["Prospective Dealer"],children:e.jsx(QB,{})})}),e.jsxs(Ns,{element:e.jsx(sw,{excludeRoles:["Prospective Dealer"],redirectTo:"/prospective-dashboard",children:e.jsx(cH,{onLogout:y,title:N(d.pathname)})}),children:[e.jsx(Ns,{path:"/",element:e.jsx(Mn,{to:"/dashboard",replace:!0})}),e.jsx(Ns,{path:"/dashboard",element:f(j)?e.jsx(KB,{currentUser:s,onNavigate:S=>c(`/${S}`),onViewPaymentDetails:S=>c(`/finance-onboarding/${S}`),onViewAuditDetails:S=>c(`/finance-audit/${S}`),onViewFnFDetails:S=>c(`/finance-fnf/${S}`)}):f(["Dealer"])?e.jsx(YB,{currentUser:s,onNavigate:S=>c(`/${S}`)}):e.jsx(P9,{onNavigate:S=>c(`/${S}`)})}),e.jsx(Ns,{path:"/applications",element:e.jsx(_7,{onViewDetails:S=>c(`/applications/${S}`),initialFilter:"all"})}),e.jsx(Ns,{path:"/applications/:id",element:e.jsx(o1,{})}),e.jsx(Ns,{path:"/worknotes/:type/:id",element:e.jsx(nE,{onBack:()=>window.history.back()})}),e.jsx(Ns,{path:"/all-applications",element:f(["DD","DD Admin","Super Admin"])?e.jsx(O7,{onViewDetails:S=>c(`/applications/${S}`),initialFilter:"all"}):e.jsx(Mn,{to:"/dashboard"})}),e.jsx(Ns,{path:"/fdd-dashboard",element:e.jsx(e7,{})}),e.jsx(Ns,{path:"/fdd-details/:id",element:e.jsx(j7,{})}),e.jsx(Ns,{path:"/opportunity-requests",element:e.jsx(I7,{onViewDetails:S=>c(`/applications/${S}`)})}),e.jsx(Ns,{path:"/non-opportunities",element:e.jsx(L7,{onViewDetails:S=>c(`/applications/${S}`)})}),e.jsx(Ns,{path:"/users",element:e.jsx(nV,{})}),e.jsx(Ns,{path:"/notifications",element:e.jsx(oH,{})}),e.jsx(Ns,{path:"/approval-policies",element:f(["Super Admin","DD Admin"])?e.jsx(rD,{}):e.jsx(Mn,{to:"/dashboard"})}),e.jsx(Ns,{path:"/sla-configurations",element:f(["Super Admin","DD Admin","DD Lead"])?e.jsx(aV,{}):e.jsx(Mn,{to:"/dashboard"})}),e.jsx(Ns,{path:"/master",element:e.jsx(sV,{})}),e.jsx(Ns,{path:"/questions",element:e.jsx(uC,{})}),e.jsx(Ns,{path:"/questionnaire-builder",element:e.jsx(dC,{})}),e.jsx(Ns,{path:"/questionnaire-builder/:id",element:e.jsx(dC,{})}),e.jsx(Ns,{path:"/questionnaires",element:e.jsx(uC,{})}),e.jsx(Ns,{path:"/interview-configs",element:f(["Super Admin","DD Admin","DD Head"])?e.jsx(lH,{}):e.jsx(Mn,{to:"/dashboard"})}),e.jsx(Ns,{path:"/resignation",element:f(m)?e.jsx(m$,{currentUser:s,onViewDetails:S=>c(`/resignation/${S}`)}):e.jsx(Mn,{to:"/dashboard"})}),e.jsx(Ns,{path:"/resignation/:id",element:f(m)?e.jsx(b$,{resignationId:window.location.pathname.split("/").pop()||"",onBack:()=>c("/resignation"),currentUser:s}):e.jsx(Mn,{to:"/dashboard"})}),e.jsx(Ns,{path:"/termination",element:f(p)?e.jsx(p$,{currentUser:s,onViewDetails:S=>c(`/termination/${S}`)}):e.jsx(Mn,{to:"/dashboard"})}),e.jsx(Ns,{path:"/termination/:id",element:f(p)?e.jsx(y$,{terminationId:window.location.pathname.split("/").pop()||"",onBack:()=>c("/termination"),currentUser:s}):e.jsx(Mn,{to:"/dashboard"})}),e.jsx(Ns,{path:"/fnf",element:f(u)?e.jsx(x$,{currentUser:s,onViewDetails:S=>c(`/fnf/${S}`)}):e.jsx(Mn,{to:"/dashboard"})}),e.jsx(Ns,{path:"/fnf/:id",element:f(u)?e.jsx(w$,{fnfId:window.location.pathname.split("/").pop()||"",onBack:()=>c("/fnf"),currentUser:s}):e.jsx(Mn,{to:"/dashboard"})}),e.jsx(Ns,{path:"/finance-onboarding",element:f(j)?e.jsx(S$,{onViewPaymentDetails:S=>c(`/finance-onboarding/${S}`),onViewAuditDetails:S=>c(`/finance-audit/${S}`)}):e.jsx(Mn,{to:"/dashboard"})}),e.jsx(Ns,{path:"/finance-onboarding/:id",element:f(j)?e.jsx(A$,{applicationId:window.location.pathname.split("/").pop()||"",onBack:()=>c("/finance-onboarding")}):e.jsx(Mn,{to:"/dashboard"})}),e.jsx(Ns,{path:"/finance-audit/:id",element:e.jsx(o1,{})}),e.jsx(Ns,{path:"/finance-fnf",element:f(j)?e.jsx(C$,{onViewFnFDetails:S=>c(`/finance-fnf/${S}`)}):e.jsx(Mn,{to:"/dashboard"})}),e.jsx(Ns,{path:"/finance-fnf/:id",element:f(j)?e.jsx(k$,{fnfId:window.location.pathname.split("/").pop()||"",onBack:()=>c("/finance-fnf")}):e.jsx(Mn,{to:"/dashboard"})}),e.jsx(Ns,{path:"/constitutional-change",element:e.jsx(uV,{currentUser:s,onViewDetails:S=>c(`/constitutional-change/${S}`)})}),e.jsx(Ns,{path:"/constitutional-change/:id",element:e.jsx(mV,{requestId:window.location.pathname.split("/").pop()||"",onBack:()=>c("/constitutional-change"),currentUser:s})}),e.jsx(Ns,{path:"/relocation-requests",element:e.jsx(pV,{currentUser:s,onViewDetails:S=>c(`/relocation-requests/${S}`)})}),e.jsx(Ns,{path:"/relocation-requests/:id",element:e.jsx(jV,{requestId:window.location.pathname.split("/").pop()||"",onBack:()=>c("/relocation-requests"),currentUser:s})}),e.jsx(Ns,{path:"/dealer-resignation",element:e.jsx(wV,{currentUser:s,onViewDetails:S=>c(`/dealer-resignation/${S}`)})}),e.jsx(Ns,{path:"/dealer-resignation/:id",element:f(["Dealer"])?e.jsx(tH,{resignationId:window.location.pathname.split("/").pop()||"",onBack:()=>c("/dealer-resignation")}):e.jsx(Mn,{to:"/dashboard"})}),e.jsx(Ns,{path:"/dealer-constitutional",element:e.jsx(nH,{currentUser:s,onViewDetails:S=>c(`/constitutional-change/${S}`)})}),e.jsx(Ns,{path:"/dealer-relocation",element:e.jsx(aH,{currentUser:s,onViewDetails:S=>c(`/relocation-requests/${S}`)})}),e.jsx(Ns,{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(Ns,{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(Ns,{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(Ns,{path:"*",element:e.jsx(Mn,{to:"/dashboard",replace:!0})})]})]}),e.jsx(hC,{})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Q0,{children:[e.jsx(Ns,{path:"/admin-login",element:e.jsx(pw,{onLogin:g})}),e.jsx(Ns,{path:"/prospective-login",element:e.jsx(eL,{})}),e.jsx(Ns,{path:"/questionnaire/:applicationId",element:e.jsx(GI,{})}),e.jsx(Ns,{path:"*",element:a?e.jsx(pw,{onLogin:g}):e.jsx(WI,{onAdminLogin:()=>l(!0)})})]}),e.jsx(hC,{})]})}MT.createRoot(document.getElementById("root")).render(e.jsx(gt.StrictMode,{children:e.jsx(XT,{store:zO,children:e.jsx(F4,{children:e.jsx(dH,{})})})}));