var hP=Object.defineProperty;var mP=(t,s,n)=>s in t?hP(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var Kx=(t,s,n)=>mP(t,typeof s!="symbol"?s+"":s,n);function fP(t,s){for(var n=0;nr[a]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=n(a);fetch(a.href,i)}})();var Vo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Nf(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Yx={exports:{}},Xd={},Zx={exports:{}},en={};/** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var pw;function pP(){if(pw)return en;pw=1;var t=Symbol.for("react.element"),s=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),o=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),h=Symbol.iterator;function x(T){return T===null||typeof T!="object"?null:(T=h&&T[h]||T["@@iterator"],typeof T=="function"?T:null)}var u={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,v={};function w(T,F,I){this.props=T,this.context=F,this.refs=v,this.updater=I||u}w.prototype.isReactComponent={},w.prototype.setState=function(T,F){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,F,"setState")},w.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function j(){}j.prototype=w.prototype;function b(T,F,I){this.props=T,this.context=F,this.refs=v,this.updater=I||u}var C=b.prototype=new j;C.constructor=b,N(C,w.prototype),C.isPureReactComponent=!0;var S=Array.isArray,D=Object.prototype.hasOwnProperty,_={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function E(T,F,I){var K,G={},V=null,Y=null;if(F!=null)for(K in F.ref!==void 0&&(Y=F.ref),F.key!==void 0&&(V=""+F.key),F)D.call(F,K)&&!A.hasOwnProperty(K)&&(G[K]=F[K]);var re=arguments.length-2;if(re===1)G.children=I;else if(1>>1,F=U[T];if(0>>1;Ta(G,z))Va(Y,G)?(U[T]=Y,U[V]=z,T=V):(U[T]=G,U[K]=z,T=K);else if(Va(Y,z))U[T]=Y,U[V]=z,T=V;else break e}}return M}function a(U,M){var z=U.sortIndex-M.sortIndex;return z!==0?z:U.id-M.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,d=o.now();t.unstable_now=function(){return o.now()-d}}var m=[],f=[],p=1,h=null,x=3,u=!1,N=!1,v=!1,w=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(U){for(var M=n(f);M!==null;){if(M.callback===null)r(f);else if(M.startTime<=U)r(f),M.sortIndex=M.expirationTime,s(m,M);else break;M=n(f)}}function S(U){if(v=!1,C(U),!N)if(n(m)!==null)N=!0,Q(D);else{var M=n(f);M!==null&&W(S,M.startTime-U)}}function D(U,M){N=!1,v&&(v=!1,j(E),E=-1),u=!0;var z=x;try{for(C(M),h=n(m);h!==null&&(!(h.expirationTime>M)||U&&!R());){var T=h.callback;if(typeof T=="function"){h.callback=null,x=h.priorityLevel;var F=T(h.expirationTime<=M);M=t.unstable_now(),typeof F=="function"?h.callback=F:h===n(m)&&r(m),C(M)}else r(m);h=n(m)}if(h!==null)var I=!0;else{var K=n(f);K!==null&&W(S,K.startTime-M),I=!1}return I}finally{h=null,x=z,u=!1}}var _=!1,A=null,E=-1,q=5,O=-1;function R(){return!(t.unstable_now()-OU||125T?(U.sortIndex=z,s(f,U),n(m)===null&&U===n(f)&&(v?(j(E),E=-1):v=!0,W(S,z-T))):(U.sortIndex=F,s(m,U),N||u||(N=!0,Q(D))),U},t.unstable_shouldYield=R,t.unstable_wrapCallback=function(U){var M=x;return function(){var z=x;x=M;try{return U.apply(this,arguments)}finally{x=z}}}})(Jx)),Jx}var bw;function yP(){return bw||(bw=1,Xx.exports=vP()),Xx.exports}/** * @license React * react-dom.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var jw;function bP(){if(jw)return ta;jw=1;var t=fd(),s=yP();function n(l){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+l,y=1;y"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},h={};function x(l){return m.call(h,l)?!0:m.call(p,l)?!1:f.test(l)?h[l]=!0:(p[l]=!0,!1)}function u(l,c,y,k){if(y!==null&&y.type===0)return!1;switch(typeof c){case"function":case"symbol":return!0;case"boolean":return k?!1:y!==null?!y.acceptsBooleans:(l=l.toLowerCase().slice(0,5),l!=="data-"&&l!=="aria-");default:return!1}}function N(l,c,y,k){if(c===null||typeof c>"u"||u(l,c,y,k))return!0;if(k)return!1;if(y!==null)switch(y.type){case 3:return!c;case 4:return c===!1;case 5:return isNaN(c);case 6:return isNaN(c)||1>c}return!1}function v(l,c,y,k,B,H,ne){this.acceptsBooleans=c===2||c===3||c===4,this.attributeName=k,this.attributeNamespace=B,this.mustUseProperty=y,this.propertyName=l,this.type=c,this.sanitizeURL=H,this.removeEmptyString=ne}var w={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){w[l]=new v(l,0,!1,l,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var c=l[0];w[c]=new v(c,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){w[l]=new v(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){w[l]=new v(l,2,!1,l,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(l){w[l]=new v(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){w[l]=new v(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){w[l]=new v(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){w[l]=new v(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){w[l]=new v(l,5,!1,l.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function b(l){return l[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(l){var c=l.replace(j,b);w[c]=new v(c,1,!1,l,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(l){var c=l.replace(j,b);w[c]=new v(c,1,!1,l,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(l){var c=l.replace(j,b);w[c]=new v(c,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){w[l]=new v(l,1,!1,l.toLowerCase(),null,!1,!1)}),w.xlinkHref=new v("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){w[l]=new v(l,1,!1,l.toLowerCase(),null,!0,!0)});function C(l,c,y,k){var B=w.hasOwnProperty(c)?w[c]:null;(B!==null?B.type!==0:k||!(2ve||B[ne]!==H[ve]){var De=` `+B[ne].replace(" at new "," at ");return l.displayName&&De.includes("")&&(De=De.replace("",l.displayName)),De}while(1<=ne&&0<=ve);break}}}finally{I=!1,Error.prepareStackTrace=y}return(l=l?l.displayName||l.name:"")?F(l):""}function G(l){switch(l.tag){case 5:return F(l.type);case 16:return F("Lazy");case 13:return F("Suspense");case 19:return F("SuspenseList");case 0:case 2:case 15:return l=K(l.type,!1),l;case 11:return l=K(l.type.render,!1),l;case 1:return l=K(l.type,!0),l;default:return""}}function V(l){if(l==null)return null;if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case A:return"Fragment";case _:return"Portal";case q:return"Profiler";case E:return"StrictMode";case L:return"Suspense";case $:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case R:return(l.displayName||"Context")+".Consumer";case O:return(l._context.displayName||"Context")+".Provider";case P:var c=l.render;return l=l.displayName,l||(l=c.displayName||c.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case Z:return c=l.displayName||null,c!==null?c:V(l.type)||"Memo";case Q:c=l._payload,l=l._init;try{return V(l(c))}catch{}}return null}function Y(l){var c=l.type;switch(l.tag){case 24:return"Cache";case 9:return(c.displayName||"Context")+".Consumer";case 10:return(c._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return l=c.render,l=l.displayName||l.name||"",c.displayName||(l!==""?"ForwardRef("+l+")":"ForwardRef");case 7:return"Fragment";case 5:return c;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return V(c);case 8:return c===E?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c}return null}function re(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function ae(l){var c=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function ue(l){var c=ae(l)?"checked":"value",y=Object.getOwnPropertyDescriptor(l.constructor.prototype,c),k=""+l[c];if(!l.hasOwnProperty(c)&&typeof y<"u"&&typeof y.get=="function"&&typeof y.set=="function"){var B=y.get,H=y.set;return Object.defineProperty(l,c,{configurable:!0,get:function(){return B.call(this)},set:function(ne){k=""+ne,H.call(this,ne)}}),Object.defineProperty(l,c,{enumerable:y.enumerable}),{getValue:function(){return k},setValue:function(ne){k=""+ne},stopTracking:function(){l._valueTracker=null,delete l[c]}}}}function ye(l){l._valueTracker||(l._valueTracker=ue(l))}function ce(l){if(!l)return!1;var c=l._valueTracker;if(!c)return!0;var y=c.getValue(),k="";return l&&(k=ae(l)?l.checked?"true":"false":l.value),l=k,l!==y?(c.setValue(l),!0):!1}function je(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch{return l.body}}function Me(l,c){var y=c.checked;return z({},c,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:y??l._wrapperState.initialChecked})}function ut(l,c){var y=c.defaultValue==null?"":c.defaultValue,k=c.checked!=null?c.checked:c.defaultChecked;y=re(c.value!=null?c.value:y),l._wrapperState={initialChecked:k,initialValue:y,controlled:c.type==="checkbox"||c.type==="radio"?c.checked!=null:c.value!=null}}function jt(l,c){c=c.checked,c!=null&&C(l,"checked",c,!1)}function ft(l,c){jt(l,c);var y=re(c.value),k=c.type;if(y!=null)k==="number"?(y===0&&l.value===""||l.value!=y)&&(l.value=""+y):l.value!==""+y&&(l.value=""+y);else if(k==="submit"||k==="reset"){l.removeAttribute("value");return}c.hasOwnProperty("value")?Ce(l,c.type,y):c.hasOwnProperty("defaultValue")&&Ce(l,c.type,re(c.defaultValue)),c.checked==null&&c.defaultChecked!=null&&(l.defaultChecked=!!c.defaultChecked)}function X(l,c,y){if(c.hasOwnProperty("value")||c.hasOwnProperty("defaultValue")){var k=c.type;if(!(k!=="submit"&&k!=="reset"||c.value!==void 0&&c.value!==null))return;c=""+l._wrapperState.initialValue,y||c===l.value||(l.value=c),l.defaultValue=c}y=l.name,y!==""&&(l.name=""),l.defaultChecked=!!l._wrapperState.initialChecked,y!==""&&(l.name=y)}function Ce(l,c,y){(c!=="number"||je(l.ownerDocument)!==l)&&(y==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+y&&(l.defaultValue=""+y))}var xe=Array.isArray;function We(l,c,y,k){if(l=l.options,c){c={};for(var B=0;B"+c.valueOf().toString()+"",c=de.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;c.firstChild;)l.appendChild(c.firstChild)}});function ot(l,c){if(c){var y=l.firstChild;if(y&&y===l.lastChild&&y.nodeType===3){y.nodeValue=c;return}}l.textContent=c}var ke={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},Zt=["Webkit","ms","Moz","O"];Object.keys(ke).forEach(function(l){Zt.forEach(function(c){c=c+l.charAt(0).toUpperCase()+l.substring(1),ke[c]=ke[l]})});function Bt(l,c,y){return c==null||typeof c=="boolean"||c===""?"":y||typeof c!="number"||c===0||ke.hasOwnProperty(l)&&ke[l]?(""+c).trim():c+"px"}function _s(l,c){l=l.style;for(var y in c)if(c.hasOwnProperty(y)){var k=y.indexOf("--")===0,B=Bt(y,c[y],k);y==="float"&&(y="cssFloat"),k?l.setProperty(y,B):l[y]=B}}var Us=z({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function fs(l,c){if(c){if(Us[l]&&(c.children!=null||c.dangerouslySetInnerHTML!=null))throw Error(n(137,l));if(c.dangerouslySetInnerHTML!=null){if(c.children!=null)throw Error(n(60));if(typeof c.dangerouslySetInnerHTML!="object"||!("__html"in c.dangerouslySetInnerHTML))throw Error(n(61))}if(c.style!=null&&typeof c.style!="object")throw Error(n(62))}}function Vs(l,c){if(l.indexOf("-")===-1)return typeof c.is=="string";switch(l){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Qs=null;function Xs(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var ie=null,nt=null,fe=null;function Ae(l){if(l=Md(l)){if(typeof ie!="function")throw Error(n(280));var c=l.stateNode;c&&(c=yh(c),ie(l.stateNode,l.type,c))}}function Fe(l){nt?fe?fe.push(l):fe=[l]:nt=l}function Ke(){if(nt){var l=nt,c=fe;if(fe=nt=null,Ae(l),c)for(l=0;l>>=0,l===0?32:31-(js(l)/tn|0)|0}var jn=64,xn=4194304;function gn(l){switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return l&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return l}}function Ye(l,c){var y=l.pendingLanes;if(y===0)return 0;var k=0,B=l.suspendedLanes,H=l.pingedLanes,ne=y&268435455;if(ne!==0){var ve=ne&~B;ve!==0?k=gn(ve):(H&=ne,H!==0&&(k=gn(H)))}else ne=y&~B,ne!==0?k=gn(ne):H!==0&&(k=gn(H));if(k===0)return 0;if(c!==0&&c!==k&&(c&B)===0&&(B=k&-k,H=c&-c,B>=H||B===16&&(H&4194240)!==0))return c;if((k&4)!==0&&(k|=y&16),c=l.entangledLanes,c!==0)for(l=l.entanglements,c&=k;0y;y++)c.push(l);return c}function Er(l,c,y){l.pendingLanes|=c,c!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,c=31-ts(c),l[c]=y}function Fr(l,c){var y=l.pendingLanes&~c;l.pendingLanes=c,l.suspendedLanes=0,l.pingedLanes=0,l.expiredLanes&=c,l.mutableReadLanes&=c,l.entangledLanes&=c,c=l.entanglements;var k=l.eventTimes;for(l=l.expirationTimes;0=Hi),kl=" ",Wi=!1;function wo(l,c){switch(l){case"keyup":return Ra.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function oh(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Dl=!1;function Ap(l,c){switch(l){case"compositionend":return oh(c);case"keypress":return c.which!==32?null:(Wi=!0,kl);case"textInput":return l=c.data,l===kl&&Wi?null:l;default:return null}}function kp(l,c){if(Dl)return l==="compositionend"||!Al&&wo(l,c)?(l=bo(),Ui=yo=Br=null,Dl=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1=c)return{node:y,offset:c-l};l=k}e:{for(;y;){if(y.nextSibling){y=y.nextSibling;break e}y=y.parentNode}y=void 0}y=vj(y)}}function bj(l,c){return l&&c?l===c?!0:l&&l.nodeType===3?!1:c&&c.nodeType===3?bj(l,c.parentNode):"contains"in l?l.contains(c):l.compareDocumentPosition?!!(l.compareDocumentPosition(c)&16):!1:!1}function jj(){for(var l=window,c=je();c instanceof l.HTMLIFrameElement;){try{var y=typeof c.contentWindow.location.href=="string"}catch{y=!1}if(y)l=c.contentWindow;else break;c=je(l.document)}return c}function _p(l){var c=l&&l.nodeName&&l.nodeName.toLowerCase();return c&&(c==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||c==="textarea"||l.contentEditable==="true")}function yT(l){var c=jj(),y=l.focusedElem,k=l.selectionRange;if(c!==y&&y&&y.ownerDocument&&bj(y.ownerDocument.documentElement,y)){if(k!==null&&_p(y)){if(c=k.start,l=k.end,l===void 0&&(l=c),"selectionStart"in y)y.selectionStart=c,y.selectionEnd=Math.min(l,y.value.length);else if(l=(c=y.ownerDocument||document)&&c.defaultView||window,l.getSelection){l=l.getSelection();var B=y.textContent.length,H=Math.min(k.start,B);k=k.end===void 0?H:Math.min(k.end,B),!l.extend&&H>k&&(B=k,k=H,H=B),B=yj(y,H);var ne=yj(y,k);B&&ne&&(l.rangeCount!==1||l.anchorNode!==B.node||l.anchorOffset!==B.offset||l.focusNode!==ne.node||l.focusOffset!==ne.offset)&&(c=c.createRange(),c.setStart(B.node,B.offset),l.removeAllRanges(),H>k?(l.addRange(c),l.extend(ne.node,ne.offset)):(c.setEnd(ne.node,ne.offset),l.addRange(c)))}}for(c=[],l=y;l=l.parentNode;)l.nodeType===1&&c.push({element:l,left:l.scrollLeft,top:l.scrollTop});for(typeof y.focus=="function"&&y.focus(),y=0;y=document.documentMode,bc=null,Tp=null,Td=null,Pp=!1;function Nj(l,c,y){var k=y.window===y?y.document:y.nodeType===9?y:y.ownerDocument;Pp||bc==null||bc!==je(k)||(k=bc,"selectionStart"in k&&_p(k)?k={start:k.selectionStart,end:k.selectionEnd}:(k=(k.ownerDocument&&k.ownerDocument.defaultView||window).getSelection(),k={anchorNode:k.anchorNode,anchorOffset:k.anchorOffset,focusNode:k.focusNode,focusOffset:k.focusOffset}),Td&&_d(Td,k)||(Td=k,k=xh(Tp,"onSelect"),0Cc||(l.current=Hp[Cc],Hp[Cc]=null,Cc--)}function Cn(l,c){Cc++,Hp[Cc]=l.current,l.current=c}var Pl={},Tr=Tl(Pl),Zr=Tl(!1),ko=Pl;function Ac(l,c){var y=l.type.contextTypes;if(!y)return Pl;var k=l.stateNode;if(k&&k.__reactInternalMemoizedUnmaskedChildContext===c)return k.__reactInternalMemoizedMaskedChildContext;var B={},H;for(H in y)B[H]=c[H];return k&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=c,l.__reactInternalMemoizedMaskedChildContext=B),B}function Qr(l){return l=l.childContextTypes,l!=null}function bh(){En(Zr),En(Tr)}function Mj(l,c,y){if(Tr.current!==Pl)throw Error(n(168));Cn(Tr,c),Cn(Zr,y)}function Fj(l,c,y){var k=l.stateNode;if(c=c.childContextTypes,typeof k.getChildContext!="function")return y;k=k.getChildContext();for(var B in k)if(!(B in c))throw Error(n(108,Y(l)||"Unknown",B));return z({},y,k)}function jh(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||Pl,ko=Tr.current,Cn(Tr,l),Cn(Zr,Zr.current),!0}function Bj(l,c,y){var k=l.stateNode;if(!k)throw Error(n(169));y?(l=Fj(l,c,ko),k.__reactInternalMemoizedMergedChildContext=l,En(Zr),En(Tr),Cn(Tr,l)):En(Zr),Cn(Zr,y)}var Ki=null,Nh=!1,Wp=!1;function $j(l){Ki===null?Ki=[l]:Ki.push(l)}function _T(l){Nh=!0,$j(l)}function Ol(){if(!Wp&&Ki!==null){Wp=!0;var l=0,c=Js;try{var y=Ki;for(Js=1;l>=ne,B-=ne,Yi=1<<32-ts(c)+B|y<Hs?(fr=Is,Is=null):fr=Is.sibling;var fn=At(He,Is,Ge[Hs],Ut);if(fn===null){Is===null&&(Is=fr);break}l&&Is&&fn.alternate===null&&c(He,Is),Te=H(fn,Te,Hs),Ls===null?Ns=fn:Ls.sibling=fn,Ls=fn,Is=fr}if(Hs===Ge.length)return y(He,Is),Ln&&Ro(He,Hs),Ns;if(Is===null){for(;HsHs?(fr=Is,Is=null):fr=Is.sibling;var Ul=At(He,Is,fn.value,Ut);if(Ul===null){Is===null&&(Is=fr);break}l&&Is&&Ul.alternate===null&&c(He,Is),Te=H(Ul,Te,Hs),Ls===null?Ns=Ul:Ls.sibling=Ul,Ls=Ul,Is=fr}if(fn.done)return y(He,Is),Ln&&Ro(He,Hs),Ns;if(Is===null){for(;!fn.done;Hs++,fn=Ge.next())fn=Lt(He,fn.value,Ut),fn!==null&&(Te=H(fn,Te,Hs),Ls===null?Ns=fn:Ls.sibling=fn,Ls=fn);return Ln&&Ro(He,Hs),Ns}for(Is=k(He,Is);!fn.done;Hs++,fn=Ge.next())fn=ls(Is,He,Hs,fn.value,Ut),fn!==null&&(l&&fn.alternate!==null&&Is.delete(fn.key===null?Hs:fn.key),Te=H(fn,Te,Hs),Ls===null?Ns=fn:Ls.sibling=fn,Ls=fn);return l&&Is.forEach(function(uP){return c(He,uP)}),Ln&&Ro(He,Hs),Ns}function Gn(He,Te,Ge,Ut){if(typeof Ge=="object"&&Ge!==null&&Ge.type===A&&Ge.key===null&&(Ge=Ge.props.children),typeof Ge=="object"&&Ge!==null){switch(Ge.$$typeof){case D:e:{for(var Ns=Ge.key,Ls=Te;Ls!==null;){if(Ls.key===Ns){if(Ns=Ge.type,Ns===A){if(Ls.tag===7){y(He,Ls.sibling),Te=B(Ls,Ge.props.children),Te.return=He,He=Te;break e}}else if(Ls.elementType===Ns||typeof Ns=="object"&&Ns!==null&&Ns.$$typeof===Q&&Wj(Ns)===Ls.type){y(He,Ls.sibling),Te=B(Ls,Ge.props),Te.ref=Fd(He,Ls,Ge),Te.return=He,He=Te;break e}y(He,Ls);break}else c(He,Ls);Ls=Ls.sibling}Ge.type===A?(Te=Mo(Ge.props.children,He.mode,Ut,Ge.key),Te.return=He,He=Te):(Ut=Zh(Ge.type,Ge.key,Ge.props,null,He.mode,Ut),Ut.ref=Fd(He,Te,Ge),Ut.return=He,He=Ut)}return ne(He);case _:e:{for(Ls=Ge.key;Te!==null;){if(Te.key===Ls)if(Te.tag===4&&Te.stateNode.containerInfo===Ge.containerInfo&&Te.stateNode.implementation===Ge.implementation){y(He,Te.sibling),Te=B(Te,Ge.children||[]),Te.return=He,He=Te;break e}else{y(He,Te);break}else c(He,Te);Te=Te.sibling}Te=Ux(Ge,He.mode,Ut),Te.return=He,He=Te}return ne(He);case Q:return Ls=Ge._init,Gn(He,Te,Ls(Ge._payload),Ut)}if(xe(Ge))return xs(He,Te,Ge,Ut);if(M(Ge))return vs(He,Te,Ge,Ut);Ah(He,Ge)}return typeof Ge=="string"&&Ge!==""||typeof Ge=="number"?(Ge=""+Ge,Te!==null&&Te.tag===6?(y(He,Te.sibling),Te=B(Te,Ge),Te.return=He,He=Te):(y(He,Te),Te=zx(Ge,He.mode,Ut),Te.return=He,He=Te),ne(He)):y(He,Te)}return Gn}var Ec=Gj(!0),Kj=Gj(!1),kh=Tl(null),Dh=null,_c=null,Xp=null;function Jp(){Xp=_c=Dh=null}function ex(l){var c=kh.current;En(kh),l._currentValue=c}function tx(l,c,y){for(;l!==null;){var k=l.alternate;if((l.childLanes&c)!==c?(l.childLanes|=c,k!==null&&(k.childLanes|=c)):k!==null&&(k.childLanes&c)!==c&&(k.childLanes|=c),l===y)break;l=l.return}}function Tc(l,c){Dh=l,Xp=_c=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&c)!==0&&(Xr=!0),l.firstContext=null)}function Pa(l){var c=l._currentValue;if(Xp!==l)if(l={context:l,memoizedValue:c,next:null},_c===null){if(Dh===null)throw Error(n(308));_c=l,Dh.dependencies={lanes:0,firstContext:l}}else _c=_c.next=l;return c}var Eo=null;function sx(l){Eo===null?Eo=[l]:Eo.push(l)}function Yj(l,c,y,k){var B=c.interleaved;return B===null?(y.next=y,sx(c)):(y.next=B.next,B.next=y),c.interleaved=y,Qi(l,k)}function Qi(l,c){l.lanes|=c;var y=l.alternate;for(y!==null&&(y.lanes|=c),y=l,l=l.return;l!==null;)l.childLanes|=c,y=l.alternate,y!==null&&(y.childLanes|=c),y=l,l=l.return;return y.tag===3?y.stateNode:null}var Ll=!1;function nx(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Zj(l,c){l=l.updateQueue,c.updateQueue===l&&(c.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,effects:l.effects})}function Xi(l,c){return{eventTime:l,lane:c,tag:0,payload:null,callback:null,next:null}}function Il(l,c,y){var k=l.updateQueue;if(k===null)return null;if(k=k.shared,(hn&2)!==0){var B=k.pending;return B===null?c.next=c:(c.next=B.next,B.next=c),k.pending=c,Qi(l,y)}return B=k.interleaved,B===null?(c.next=c,sx(k)):(c.next=B.next,B.next=c),k.interleaved=c,Qi(l,y)}function Rh(l,c,y){if(c=c.updateQueue,c!==null&&(c=c.shared,(y&4194240)!==0)){var k=c.lanes;k&=l.pendingLanes,y|=k,c.lanes=y,wn(l,y)}}function Qj(l,c){var y=l.updateQueue,k=l.alternate;if(k!==null&&(k=k.updateQueue,y===k)){var B=null,H=null;if(y=y.firstBaseUpdate,y!==null){do{var ne={eventTime:y.eventTime,lane:y.lane,tag:y.tag,payload:y.payload,callback:y.callback,next:null};H===null?B=H=ne:H=H.next=ne,y=y.next}while(y!==null);H===null?B=H=c:H=H.next=c}else B=H=c;y={baseState:k.baseState,firstBaseUpdate:B,lastBaseUpdate:H,shared:k.shared,effects:k.effects},l.updateQueue=y;return}l=y.lastBaseUpdate,l===null?y.firstBaseUpdate=c:l.next=c,y.lastBaseUpdate=c}function Eh(l,c,y,k){var B=l.updateQueue;Ll=!1;var H=B.firstBaseUpdate,ne=B.lastBaseUpdate,ve=B.shared.pending;if(ve!==null){B.shared.pending=null;var De=ve,Qe=De.next;De.next=null,ne===null?H=Qe:ne.next=Qe,ne=De;var Dt=l.alternate;Dt!==null&&(Dt=Dt.updateQueue,ve=Dt.lastBaseUpdate,ve!==ne&&(ve===null?Dt.firstBaseUpdate=Qe:ve.next=Qe,Dt.lastBaseUpdate=De))}if(H!==null){var Lt=B.baseState;ne=0,Dt=Qe=De=null,ve=H;do{var At=ve.lane,ls=ve.eventTime;if((k&At)===At){Dt!==null&&(Dt=Dt.next={eventTime:ls,lane:0,tag:ve.tag,payload:ve.payload,callback:ve.callback,next:null});e:{var xs=l,vs=ve;switch(At=c,ls=y,vs.tag){case 1:if(xs=vs.payload,typeof xs=="function"){Lt=xs.call(ls,Lt,At);break e}Lt=xs;break e;case 3:xs.flags=xs.flags&-65537|128;case 0:if(xs=vs.payload,At=typeof xs=="function"?xs.call(ls,Lt,At):xs,At==null)break e;Lt=z({},Lt,At);break e;case 2:Ll=!0}}ve.callback!==null&&ve.lane!==0&&(l.flags|=64,At=B.effects,At===null?B.effects=[ve]:At.push(ve))}else ls={eventTime:ls,lane:At,tag:ve.tag,payload:ve.payload,callback:ve.callback,next:null},Dt===null?(Qe=Dt=ls,De=Lt):Dt=Dt.next=ls,ne|=At;if(ve=ve.next,ve===null){if(ve=B.shared.pending,ve===null)break;At=ve,ve=At.next,At.next=null,B.lastBaseUpdate=At,B.shared.pending=null}}while(!0);if(Dt===null&&(De=Lt),B.baseState=De,B.firstBaseUpdate=Qe,B.lastBaseUpdate=Dt,c=B.shared.interleaved,c!==null){B=c;do ne|=B.lane,B=B.next;while(B!==c)}else H===null&&(B.shared.lanes=0);Po|=ne,l.lanes=ne,l.memoizedState=Lt}}function Xj(l,c,y){if(l=c.effects,c.effects=null,l!==null)for(c=0;cy?y:4,l(!0);var k=ox.transition;ox.transition={};try{l(!1),c()}finally{Js=y,ox.transition=k}}function gN(){return Oa().memoizedState}function LT(l,c,y){var k=$l(l);if(y={lane:k,action:y,hasEagerState:!1,eagerState:null,next:null},vN(l))yN(c,y);else if(y=Yj(l,c,y,k),y!==null){var B=zr();Ja(y,l,k,B),bN(y,c,k)}}function IT(l,c,y){var k=$l(l),B={lane:k,action:y,hasEagerState:!1,eagerState:null,next:null};if(vN(l))yN(c,B);else{var H=l.alternate;if(l.lanes===0&&(H===null||H.lanes===0)&&(H=c.lastRenderedReducer,H!==null))try{var ne=c.lastRenderedState,ve=H(ne,y);if(B.hasEagerState=!0,B.eagerState=ve,Ka(ve,ne)){var De=c.interleaved;De===null?(B.next=B,sx(c)):(B.next=De.next,De.next=B),c.interleaved=B;return}}catch{}finally{}y=Yj(l,c,B,k),y!==null&&(B=zr(),Ja(y,l,k,B),bN(y,c,k))}}function vN(l){var c=l.alternate;return l===Bn||c!==null&&c===Bn}function yN(l,c){zd=Ph=!0;var y=l.pending;y===null?c.next=c:(c.next=y.next,y.next=c),l.pending=c}function bN(l,c,y){if((y&4194240)!==0){var k=c.lanes;k&=l.pendingLanes,y|=k,c.lanes=y,wn(l,y)}}var Ih={readContext:Pa,useCallback:Pr,useContext:Pr,useEffect:Pr,useImperativeHandle:Pr,useInsertionEffect:Pr,useLayoutEffect:Pr,useMemo:Pr,useReducer:Pr,useRef:Pr,useState:Pr,useDebugValue:Pr,useDeferredValue:Pr,useTransition:Pr,useMutableSource:Pr,useSyncExternalStore:Pr,useId:Pr,unstable_isNewReconciler:!1},MT={readContext:Pa,useCallback:function(l,c){return wi().memoizedState=[l,c===void 0?null:c],l},useContext:Pa,useEffect:cN,useImperativeHandle:function(l,c,y){return y=y!=null?y.concat([l]):null,Oh(4194308,4,hN.bind(null,c,l),y)},useLayoutEffect:function(l,c){return Oh(4194308,4,l,c)},useInsertionEffect:function(l,c){return Oh(4,2,l,c)},useMemo:function(l,c){var y=wi();return c=c===void 0?null:c,l=l(),y.memoizedState=[l,c],l},useReducer:function(l,c,y){var k=wi();return c=y!==void 0?y(c):c,k.memoizedState=k.baseState=c,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:c},k.queue=l,l=l.dispatch=LT.bind(null,Bn,l),[k.memoizedState,l]},useRef:function(l){var c=wi();return l={current:l},c.memoizedState=l},useState:lN,useDebugValue:px,useDeferredValue:function(l){return wi().memoizedState=l},useTransition:function(){var l=lN(!1),c=l[0];return l=OT.bind(null,l[1]),wi().memoizedState=l,[c,l]},useMutableSource:function(){},useSyncExternalStore:function(l,c,y){var k=Bn,B=wi();if(Ln){if(y===void 0)throw Error(n(407));y=y()}else{if(y=c(),mr===null)throw Error(n(349));(To&30)!==0||sN(k,c,y)}B.memoizedState=y;var H={value:y,getSnapshot:c};return B.queue=H,cN(rN.bind(null,k,H,l),[l]),k.flags|=2048,Hd(9,nN.bind(null,k,H,y,c),void 0,null),y},useId:function(){var l=wi(),c=mr.identifierPrefix;if(Ln){var y=Zi,k=Yi;y=(k&~(1<<32-ts(k)-1)).toString(32)+y,c=":"+c+"R"+y,y=Ud++,0<\/script>",l=l.removeChild(l.firstChild)):typeof k.is=="string"?l=ne.createElement(y,{is:k.is}):(l=ne.createElement(y),y==="select"&&(ne=l,k.multiple?ne.multiple=!0:k.size&&(ne.size=k.size))):l=ne.createElementNS(l,y),l[ji]=c,l[Id]=k,$N(l,c,!1,!1),c.stateNode=l;e:{switch(ne=Vs(y,k),y){case"dialog":Rn("cancel",l),Rn("close",l),B=k;break;case"iframe":case"object":case"embed":Rn("load",l),B=k;break;case"video":case"audio":for(B=0;BMc&&(c.flags|=128,k=!0,Wd(H,!1),c.lanes=4194304)}else{if(!k)if(l=_h(ne),l!==null){if(c.flags|=128,k=!0,y=l.updateQueue,y!==null&&(c.updateQueue=y,c.flags|=4),Wd(H,!0),H.tail===null&&H.tailMode==="hidden"&&!ne.alternate&&!Ln)return Or(c),null}else 2*Mt()-H.renderingStartTime>Mc&&y!==1073741824&&(c.flags|=128,k=!0,Wd(H,!1),c.lanes=4194304);H.isBackwards?(ne.sibling=c.child,c.child=ne):(y=H.last,y!==null?y.sibling=ne:c.child=ne,H.last=ne)}return H.tail!==null?(c=H.tail,H.rendering=c,H.tail=c.sibling,H.renderingStartTime=Mt(),c.sibling=null,y=Fn.current,Cn(Fn,k?y&1|2:y&1),c):(Or(c),null);case 22:case 23:return Bx(),k=c.memoizedState!==null,l!==null&&l.memoizedState!==null!==k&&(c.flags|=8192),k&&(c.mode&1)!==0?(fa&1073741824)!==0&&(Or(c),c.subtreeFlags&6&&(c.flags|=8192)):Or(c),null;case 24:return null;case 25:return null}throw Error(n(156,c.tag))}function HT(l,c){switch(Kp(c),c.tag){case 1:return Qr(c.type)&&bh(),l=c.flags,l&65536?(c.flags=l&-65537|128,c):null;case 3:return Pc(),En(Zr),En(Tr),lx(),l=c.flags,(l&65536)!==0&&(l&128)===0?(c.flags=l&-65537|128,c):null;case 5:return ax(c),null;case 13:if(En(Fn),l=c.memoizedState,l!==null&&l.dehydrated!==null){if(c.alternate===null)throw Error(n(340));Rc()}return l=c.flags,l&65536?(c.flags=l&-65537|128,c):null;case 19:return En(Fn),null;case 4:return Pc(),null;case 10:return ex(c.type._context),null;case 22:case 23:return Bx(),null;case 24:return null;default:return null}}var $h=!1,Lr=!1,WT=typeof WeakSet=="function"?WeakSet:Set,hs=null;function Lc(l,c){var y=l.ref;if(y!==null)if(typeof y=="function")try{y(null)}catch(k){Un(l,c,k)}else y.current=null}function kx(l,c,y){try{y()}catch(k){Un(l,c,k)}}var UN=!1;function GT(l,c){if(Bp=Va,l=jj(),_p(l)){if("selectionStart"in l)var y={start:l.selectionStart,end:l.selectionEnd};else e:{y=(y=l.ownerDocument)&&y.defaultView||window;var k=y.getSelection&&y.getSelection();if(k&&k.rangeCount!==0){y=k.anchorNode;var B=k.anchorOffset,H=k.focusNode;k=k.focusOffset;try{y.nodeType,H.nodeType}catch{y=null;break e}var ne=0,ve=-1,De=-1,Qe=0,Dt=0,Lt=l,At=null;t:for(;;){for(var ls;Lt!==y||B!==0&&Lt.nodeType!==3||(ve=ne+B),Lt!==H||k!==0&&Lt.nodeType!==3||(De=ne+k),Lt.nodeType===3&&(ne+=Lt.nodeValue.length),(ls=Lt.firstChild)!==null;)At=Lt,Lt=ls;for(;;){if(Lt===l)break t;if(At===y&&++Qe===B&&(ve=ne),At===H&&++Dt===k&&(De=ne),(ls=Lt.nextSibling)!==null)break;Lt=At,At=Lt.parentNode}Lt=ls}y=ve===-1||De===-1?null:{start:ve,end:De}}else y=null}y=y||{start:0,end:0}}else y=null;for($p={focusedElem:l,selectionRange:y},Va=!1,hs=c;hs!==null;)if(c=hs,l=c.child,(c.subtreeFlags&1028)!==0&&l!==null)l.return=c,hs=l;else for(;hs!==null;){c=hs;try{var xs=c.alternate;if((c.flags&1024)!==0)switch(c.tag){case 0:case 11:case 15:break;case 1:if(xs!==null){var vs=xs.memoizedProps,Gn=xs.memoizedState,He=c.stateNode,Te=He.getSnapshotBeforeUpdate(c.elementType===c.type?vs:Za(c.type,vs),Gn);He.__reactInternalSnapshotBeforeUpdate=Te}break;case 3:var Ge=c.stateNode.containerInfo;Ge.nodeType===1?Ge.textContent="":Ge.nodeType===9&&Ge.documentElement&&Ge.removeChild(Ge.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ut){Un(c,c.return,Ut)}if(l=c.sibling,l!==null){l.return=c.return,hs=l;break}hs=c.return}return xs=UN,UN=!1,xs}function Gd(l,c,y){var k=c.updateQueue;if(k=k!==null?k.lastEffect:null,k!==null){var B=k=k.next;do{if((B.tag&l)===l){var H=B.destroy;B.destroy=void 0,H!==void 0&&kx(c,y,H)}B=B.next}while(B!==k)}}function qh(l,c){if(c=c.updateQueue,c=c!==null?c.lastEffect:null,c!==null){var y=c=c.next;do{if((y.tag&l)===l){var k=y.create;y.destroy=k()}y=y.next}while(y!==c)}}function Dx(l){var c=l.ref;if(c!==null){var y=l.stateNode;switch(l.tag){case 5:l=y;break;default:l=y}typeof c=="function"?c(l):c.current=l}}function VN(l){var c=l.alternate;c!==null&&(l.alternate=null,VN(c)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(c=l.stateNode,c!==null&&(delete c[ji],delete c[Id],delete c[Vp],delete c[RT],delete c[ET])),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function HN(l){return l.tag===5||l.tag===3||l.tag===4}function WN(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||HN(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function Rx(l,c,y){var k=l.tag;if(k===5||k===6)l=l.stateNode,c?y.nodeType===8?y.parentNode.insertBefore(l,c):y.insertBefore(l,c):(y.nodeType===8?(c=y.parentNode,c.insertBefore(l,y)):(c=y,c.appendChild(l)),y=y._reactRootContainer,y!=null||c.onclick!==null||(c.onclick=vh));else if(k!==4&&(l=l.child,l!==null))for(Rx(l,c,y),l=l.sibling;l!==null;)Rx(l,c,y),l=l.sibling}function Ex(l,c,y){var k=l.tag;if(k===5||k===6)l=l.stateNode,c?y.insertBefore(l,c):y.appendChild(l);else if(k!==4&&(l=l.child,l!==null))for(Ex(l,c,y),l=l.sibling;l!==null;)Ex(l,c,y),l=l.sibling}var Ar=null,Qa=!1;function Ml(l,c,y){for(y=y.child;y!==null;)GN(l,c,y),y=y.sibling}function GN(l,c,y){if(ns&&typeof ns.onCommitFiberUnmount=="function")try{ns.onCommitFiberUnmount(bs,y)}catch{}switch(y.tag){case 5:Lr||Lc(y,c);case 6:var k=Ar,B=Qa;Ar=null,Ml(l,c,y),Ar=k,Qa=B,Ar!==null&&(Qa?(l=Ar,y=y.stateNode,l.nodeType===8?l.parentNode.removeChild(y):l.removeChild(y)):Ar.removeChild(y.stateNode));break;case 18:Ar!==null&&(Qa?(l=Ar,y=y.stateNode,l.nodeType===8?Up(l.parentNode,y):l.nodeType===1&&Up(l,y),Da(l)):Up(Ar,y.stateNode));break;case 4:k=Ar,B=Qa,Ar=y.stateNode.containerInfo,Qa=!0,Ml(l,c,y),Ar=k,Qa=B;break;case 0:case 11:case 14:case 15:if(!Lr&&(k=y.updateQueue,k!==null&&(k=k.lastEffect,k!==null))){B=k=k.next;do{var H=B,ne=H.destroy;H=H.tag,ne!==void 0&&((H&2)!==0||(H&4)!==0)&&kx(y,c,ne),B=B.next}while(B!==k)}Ml(l,c,y);break;case 1:if(!Lr&&(Lc(y,c),k=y.stateNode,typeof k.componentWillUnmount=="function"))try{k.props=y.memoizedProps,k.state=y.memoizedState,k.componentWillUnmount()}catch(ve){Un(y,c,ve)}Ml(l,c,y);break;case 21:Ml(l,c,y);break;case 22:y.mode&1?(Lr=(k=Lr)||y.memoizedState!==null,Ml(l,c,y),Lr=k):Ml(l,c,y);break;default:Ml(l,c,y)}}function KN(l){var c=l.updateQueue;if(c!==null){l.updateQueue=null;var y=l.stateNode;y===null&&(y=l.stateNode=new WT),c.forEach(function(k){var B=sP.bind(null,l,k);y.has(k)||(y.add(k),k.then(B,B))})}}function Xa(l,c){var y=c.deletions;if(y!==null)for(var k=0;kB&&(B=ne),k&=~H}if(k=B,k=Mt()-k,k=(120>k?120:480>k?480:1080>k?1080:1920>k?1920:3e3>k?3e3:4320>k?4320:1960*YT(k/1960))-k,10l?16:l,Bl===null)var k=!1;else{if(l=Bl,Bl=null,Wh=0,(hn&6)!==0)throw Error(n(331));var B=hn;for(hn|=4,hs=l.current;hs!==null;){var H=hs,ne=H.child;if((hs.flags&16)!==0){var ve=H.deletions;if(ve!==null){for(var De=0;DeMt()-Px?Lo(l,0):Tx|=y),ea(l,c)}function lw(l,c){c===0&&((l.mode&1)===0?c=1:(c=xn,xn<<=1,(xn&130023424)===0&&(xn=4194304)));var y=zr();l=Qi(l,c),l!==null&&(Er(l,c,y),ea(l,y))}function tP(l){var c=l.memoizedState,y=0;c!==null&&(y=c.retryLane),lw(l,y)}function sP(l,c){var y=0;switch(l.tag){case 13:var k=l.stateNode,B=l.memoizedState;B!==null&&(y=B.retryLane);break;case 19:k=l.stateNode;break;default:throw Error(n(314))}k!==null&&k.delete(c),lw(l,y)}var ow;ow=function(l,c,y){if(l!==null)if(l.memoizedProps!==c.pendingProps||Zr.current)Xr=!0;else{if((l.lanes&y)===0&&(c.flags&128)===0)return Xr=!1,UT(l,c,y);Xr=(l.flags&131072)!==0}else Xr=!1,Ln&&(c.flags&1048576)!==0&&qj(c,Sh,c.index);switch(c.lanes=0,c.tag){case 2:var k=c.type;Bh(l,c),l=c.pendingProps;var B=Ac(c,Tr.current);Tc(c,y),B=dx(null,c,k,l,B,y);var H=ux();return c.flags|=1,typeof B=="object"&&B!==null&&typeof B.render=="function"&&B.$$typeof===void 0?(c.tag=1,c.memoizedState=null,c.updateQueue=null,Qr(k)?(H=!0,jh(c)):H=!1,c.memoizedState=B.state!==null&&B.state!==void 0?B.state:null,nx(c),B.updater=Mh,c.stateNode=B,B._reactInternals=c,gx(c,k,l,y),c=jx(null,c,k,!0,H,y)):(c.tag=0,Ln&&H&&Gp(c),qr(null,c,B,y),c=c.child),c;case 16:k=c.elementType;e:{switch(Bh(l,c),l=c.pendingProps,B=k._init,k=B(k._payload),c.type=k,B=c.tag=rP(k),l=Za(k,l),B){case 0:c=bx(null,c,k,l,y);break e;case 1:c=ON(null,c,k,l,y);break e;case 11:c=RN(null,c,k,l,y);break e;case 14:c=EN(null,c,k,Za(k.type,l),y);break e}throw Error(n(306,k,""))}return c;case 0:return k=c.type,B=c.pendingProps,B=c.elementType===k?B:Za(k,B),bx(l,c,k,B,y);case 1:return k=c.type,B=c.pendingProps,B=c.elementType===k?B:Za(k,B),ON(l,c,k,B,y);case 3:e:{if(LN(c),l===null)throw Error(n(387));k=c.pendingProps,H=c.memoizedState,B=H.element,Zj(l,c),Eh(c,k,null,y);var ne=c.memoizedState;if(k=ne.element,H.isDehydrated)if(H={element:k,isDehydrated:!1,cache:ne.cache,pendingSuspenseBoundaries:ne.pendingSuspenseBoundaries,transitions:ne.transitions},c.updateQueue.baseState=H,c.memoizedState=H,c.flags&256){B=Oc(Error(n(423)),c),c=IN(l,c,k,y,B);break e}else if(k!==B){B=Oc(Error(n(424)),c),c=IN(l,c,k,y,B);break e}else for(ma=_l(c.stateNode.containerInfo.firstChild),ha=c,Ln=!0,Ya=null,y=Kj(c,null,k,y),c.child=y;y;)y.flags=y.flags&-3|4096,y=y.sibling;else{if(Rc(),k===B){c=Ji(l,c,y);break e}qr(l,c,k,y)}c=c.child}return c;case 5:return Jj(c),l===null&&Zp(c),k=c.type,B=c.pendingProps,H=l!==null?l.memoizedProps:null,ne=B.children,qp(k,B)?ne=null:H!==null&&qp(k,H)&&(c.flags|=32),PN(l,c),qr(l,c,ne,y),c.child;case 6:return l===null&&Zp(c),null;case 13:return MN(l,c,y);case 4:return rx(c,c.stateNode.containerInfo),k=c.pendingProps,l===null?c.child=Ec(c,null,k,y):qr(l,c,k,y),c.child;case 11:return k=c.type,B=c.pendingProps,B=c.elementType===k?B:Za(k,B),RN(l,c,k,B,y);case 7:return qr(l,c,c.pendingProps,y),c.child;case 8:return qr(l,c,c.pendingProps.children,y),c.child;case 12:return qr(l,c,c.pendingProps.children,y),c.child;case 10:e:{if(k=c.type._context,B=c.pendingProps,H=c.memoizedProps,ne=B.value,Cn(kh,k._currentValue),k._currentValue=ne,H!==null)if(Ka(H.value,ne)){if(H.children===B.children&&!Zr.current){c=Ji(l,c,y);break e}}else for(H=c.child,H!==null&&(H.return=c);H!==null;){var ve=H.dependencies;if(ve!==null){ne=H.child;for(var De=ve.firstContext;De!==null;){if(De.context===k){if(H.tag===1){De=Xi(-1,y&-y),De.tag=2;var Qe=H.updateQueue;if(Qe!==null){Qe=Qe.shared;var Dt=Qe.pending;Dt===null?De.next=De:(De.next=Dt.next,Dt.next=De),Qe.pending=De}}H.lanes|=y,De=H.alternate,De!==null&&(De.lanes|=y),tx(H.return,y,c),ve.lanes|=y;break}De=De.next}}else if(H.tag===10)ne=H.type===c.type?null:H.child;else if(H.tag===18){if(ne=H.return,ne===null)throw Error(n(341));ne.lanes|=y,ve=ne.alternate,ve!==null&&(ve.lanes|=y),tx(ne,y,c),ne=H.sibling}else ne=H.child;if(ne!==null)ne.return=H;else for(ne=H;ne!==null;){if(ne===c){ne=null;break}if(H=ne.sibling,H!==null){H.return=ne.return,ne=H;break}ne=ne.return}H=ne}qr(l,c,B.children,y),c=c.child}return c;case 9:return B=c.type,k=c.pendingProps.children,Tc(c,y),B=Pa(B),k=k(B),c.flags|=1,qr(l,c,k,y),c.child;case 14:return k=c.type,B=Za(k,c.pendingProps),B=Za(k.type,B),EN(l,c,k,B,y);case 15:return _N(l,c,c.type,c.pendingProps,y);case 17:return k=c.type,B=c.pendingProps,B=c.elementType===k?B:Za(k,B),Bh(l,c),c.tag=1,Qr(k)?(l=!0,jh(c)):l=!1,Tc(c,y),NN(c,k,B),gx(c,k,B,y),jx(null,c,k,!0,l,y);case 19:return BN(l,c,y);case 22:return TN(l,c,y)}throw Error(n(156,c.tag))};function cw(l,c){return Ee(l,c)}function nP(l,c,y,k){this.tag=l,this.key=y,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=c,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=k,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ia(l,c,y,k){return new nP(l,c,y,k)}function qx(l){return l=l.prototype,!(!l||!l.isReactComponent)}function rP(l){if(typeof l=="function")return qx(l)?1:0;if(l!=null){if(l=l.$$typeof,l===P)return 11;if(l===Z)return 14}return 2}function zl(l,c){var y=l.alternate;return y===null?(y=Ia(l.tag,c,l.key,l.mode),y.elementType=l.elementType,y.type=l.type,y.stateNode=l.stateNode,y.alternate=l,l.alternate=y):(y.pendingProps=c,y.type=l.type,y.flags=0,y.subtreeFlags=0,y.deletions=null),y.flags=l.flags&14680064,y.childLanes=l.childLanes,y.lanes=l.lanes,y.child=l.child,y.memoizedProps=l.memoizedProps,y.memoizedState=l.memoizedState,y.updateQueue=l.updateQueue,c=l.dependencies,y.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},y.sibling=l.sibling,y.index=l.index,y.ref=l.ref,y}function Zh(l,c,y,k,B,H){var ne=2;if(k=l,typeof l=="function")qx(l)&&(ne=1);else if(typeof l=="string")ne=5;else e:switch(l){case A:return Mo(y.children,B,H,c);case E:ne=8,B|=8;break;case q:return l=Ia(12,y,c,B|2),l.elementType=q,l.lanes=H,l;case L:return l=Ia(13,y,c,B),l.elementType=L,l.lanes=H,l;case $:return l=Ia(19,y,c,B),l.elementType=$,l.lanes=H,l;case W:return Qh(y,B,H,c);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case O:ne=10;break e;case R:ne=9;break e;case P:ne=11;break e;case Z:ne=14;break e;case Q:ne=16,k=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return c=Ia(ne,y,c,B),c.elementType=l,c.type=k,c.lanes=H,c}function Mo(l,c,y,k){return l=Ia(7,l,k,c),l.lanes=y,l}function Qh(l,c,y,k){return l=Ia(22,l,k,c),l.elementType=W,l.lanes=y,l.stateNode={isHidden:!1},l}function zx(l,c,y){return l=Ia(6,l,null,c),l.lanes=y,l}function Ux(l,c,y){return c=Ia(4,l.children!==null?l.children:[],l.key,c),c.lanes=y,c.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},c}function aP(l,c,y,k,B){this.tag=c,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=qn(0),this.expirationTimes=qn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=qn(0),this.identifierPrefix=k,this.onRecoverableError=B,this.mutableSourceEagerHydrationData=null}function Vx(l,c,y,k,B,H,ne,ve,De){return l=new aP(l,c,y,ve,De),c===1?(c=1,H===!0&&(c|=8)):c=0,H=Ia(3,null,null,c),l.current=H,H.stateNode=l,H.memoizedState={element:k,isDehydrated:y,cache:null,transitions:null,pendingSuspenseBoundaries:null},nx(H),l}function iP(l,c,y){var k=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(s){console.error(s)}}return t(),Qx.exports=bP(),Qx.exports}var ww;function jP(){if(ww)return rm;ww=1;var t=Oy();return rm.createRoot=t.createRoot,rm.hydrateRoot=t.hydrateRoot,rm}var NP=jP();const wP=Nf(NP);var eg={exports:{}},tg={};/** * @license React * use-sync-external-store-with-selector.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Sw;function SP(){if(Sw)return tg;Sw=1;var t=fd();function s(m,f){return m===f&&(m!==0||1/m===1/f)||m!==m&&f!==f}var n=typeof Object.is=="function"?Object.is:s,r=t.useSyncExternalStore,a=t.useRef,i=t.useEffect,o=t.useMemo,d=t.useDebugValue;return tg.useSyncExternalStoreWithSelector=function(m,f,p,h,x){var u=a(null);if(u.current===null){var N={hasValue:!1,value:null};u.current=N}else N=u.current;u=o(function(){function w(D){if(!j){if(j=!0,b=D,D=h(D),x!==void 0&&N.hasValue){var _=N.value;if(x(_,D))return C=_}return C=D}if(_=C,n(b,D))return _;var A=h(D);return x!==void 0&&x(_,A)?(b=D,_):(b=D,C=A)}var j=!1,b,C,S=p===void 0?null:p;return[function(){return w(f())},S===null?void 0:function(){return w(S())}]},[f,p,h,x]);var v=r(m,u[0],u[1]);return i(function(){N.hasValue=!0,N.value=v},[v]),d(v),v},tg}var Cw;function CP(){return Cw||(Cw=1,eg.exports=SP()),eg.exports}var AP=CP();function kP(t){t()}function DP(){let t=null,s=null;return{clear(){t=null,s=null},notify(){kP(()=>{let n=t;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=t;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const a=s={callback:n,next:null,prev:s};return a.prev?a.prev.next=a:t=a,function(){!r||t===null||(r=!1,a.next?a.next.prev=a.prev:s=a.prev,a.prev?a.prev.next=a.next:t=a.next)}}}}var Aw={notify(){},get:()=>[]};function RP(t,s){let n,r=Aw,a=0,i=!1;function o(v){p();const w=r.subscribe(v);let j=!1;return()=>{j||(j=!0,w(),h())}}function d(){r.notify()}function m(){N.onStateChange&&N.onStateChange()}function f(){return i}function p(){a++,n||(n=t.subscribe(m),r=DP())}function h(){a--,n&&a===0&&(n(),n=void 0,r.clear(),r=Aw)}function x(){i||(i=!0,p())}function u(){i&&(i=!1,h())}const N={addNestedSub:o,notifyNestedSubs:d,handleChangeWrapper:m,isSubscribed:f,trySubscribe:x,tryUnsubscribe:u,getListeners:()=>r};return N}var EP=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",_P=EP(),TP=()=>typeof navigator<"u"&&navigator.product==="ReactNative",PP=TP(),OP=()=>_P||PP?g.useLayoutEffect:g.useEffect,LP=OP(),sg=Symbol.for("react-redux-context"),ng=typeof globalThis<"u"?globalThis:{};function IP(){if(!g.createContext)return{};const t=ng[sg]??(ng[sg]=new Map);let s=t.get(g.createContext);return s||(s=g.createContext(null),t.set(g.createContext,s)),s}var eo=IP();function MP(t){const{children:s,context:n,serverState:r,store:a}=t,i=g.useMemo(()=>{const m=RP(a);return{store:a,subscription:m,getServerState:r?()=>r:void 0}},[a,r]),o=g.useMemo(()=>a.getState(),[a]);LP(()=>{const{subscription:m}=i;return m.onStateChange=m.notifyNestedSubs,m.trySubscribe(),o!==a.getState()&&m.notifyNestedSubs(),()=>{m.tryUnsubscribe(),m.onStateChange=void 0}},[i,o]);const d=n||eo;return g.createElement(d.Provider,{value:i},s)}var FP=MP;function Ly(t=eo){return function(){return g.useContext(t)}}var M2=Ly();function F2(t=eo){const s=t===eo?M2:Ly(t),n=()=>{const{store:r}=s();return r};return Object.assign(n,{withTypes:()=>n}),n}var BP=F2();function $P(t=eo){const s=t===eo?BP:F2(t),n=()=>s().dispatch;return Object.assign(n,{withTypes:()=>n}),n}var Lu=$P(),qP=(t,s)=>t===s;function zP(t=eo){const s=t===eo?M2:Ly(t),n=(r,a={})=>{const{equalityFn:i=qP}=typeof a=="function"?{equalityFn:a}:a,o=s(),{store:d,subscription:m,getServerState:f}=o;g.useRef(!0);const p=g.useCallback({[r.name](x){return r(x)}}[r.name],[r]),h=AP.useSyncExternalStoreWithSelector(m.addNestedSub,d.getState,f||d.getState,p,i);return g.useDebugValue(h),h};return Object.assign(n,{withTypes:()=>n}),n}var Pn=zP();function Dr(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 UP=typeof Symbol=="function"&&Symbol.observable||"@@observable",kw=UP,rg=()=>Math.random().toString(36).substring(7).split("").join("."),VP={INIT:`@@redux/INIT${rg()}`,REPLACE:`@@redux/REPLACE${rg()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${rg()}`},Km=VP;function Iy(t){if(typeof t!="object"||t===null)return!1;let s=t;for(;Object.getPrototypeOf(s)!==null;)s=Object.getPrototypeOf(s);return Object.getPrototypeOf(t)===s||Object.getPrototypeOf(t)===null}function B2(t,s,n){if(typeof t!="function")throw new Error(Dr(2));if(typeof s=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Dr(0));if(typeof s=="function"&&typeof n>"u"&&(n=s,s=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Dr(1));return n(B2)(t,s)}let r=t,a=s,i=new Map,o=i,d=0,m=!1;function f(){o===i&&(o=new Map,i.forEach((w,j)=>{o.set(j,w)}))}function p(){if(m)throw new Error(Dr(3));return a}function h(w){if(typeof w!="function")throw new Error(Dr(4));if(m)throw new Error(Dr(5));let j=!0;f();const b=d++;return o.set(b,w),function(){if(j){if(m)throw new Error(Dr(6));j=!1,f(),o.delete(b),i=null}}}function x(w){if(!Iy(w))throw new Error(Dr(7));if(typeof w.type>"u")throw new Error(Dr(8));if(typeof w.type!="string")throw new Error(Dr(17));if(m)throw new Error(Dr(9));try{m=!0,a=r(a,w)}finally{m=!1}return(i=o).forEach(b=>{b()}),w}function u(w){if(typeof w!="function")throw new Error(Dr(10));r=w,x({type:Km.REPLACE})}function N(){const w=h;return{subscribe(j){if(typeof j!="object"||j===null)throw new Error(Dr(11));function b(){const S=j;S.next&&S.next(p())}return b(),{unsubscribe:w(b)}},[kw](){return this}}}return x({type:Km.INIT}),{dispatch:x,subscribe:h,getState:p,replaceReducer:u,[kw]:N}}function HP(t){Object.keys(t).forEach(s=>{const n=t[s];if(typeof n(void 0,{type:Km.INIT})>"u")throw new Error(Dr(12));if(typeof n(void 0,{type:Km.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Dr(13))})}function WP(t){const s=Object.keys(t),n={};for(let i=0;i"u")throw d&&d.type,new Error(Dr(14));f[h]=N,m=m||N!==u}return m=m||r.length!==Object.keys(o).length,m?f:o}}function Ym(...t){return t.length===0?s=>s:t.length===1?t[0]:t.reduce((s,n)=>(...r)=>s(n(...r)))}function GP(...t){return s=>(n,r)=>{const a=s(n,r);let i=()=>{throw new Error(Dr(15))};const o={getState:a.getState,dispatch:(m,...f)=>i(m,...f)},d=t.map(m=>m(o));return i=Ym(...d)(a.dispatch),{...a,dispatch:i}}}function KP(t){return Iy(t)&&"type"in t&&typeof t.type=="string"}var $2=Symbol.for("immer-nothing"),Dw=Symbol.for("immer-draftable"),Vr=Symbol.for("immer-state");function ri(t,...s){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var ba=Object,td=ba.getPrototypeOf,Zm="constructor",Sf="prototype",Bv="configurable",Qm="enumerable",_m="writable",ju="value",ul=t=>!!t&&!!t[Vr];function ii(t){var s;return t?q2(t)||Af(t)||!!t[Dw]||!!((s=t[Zm])!=null&&s[Dw])||kf(t)||Df(t):!1}var YP=ba[Sf][Zm].toString(),Rw=new WeakMap;function q2(t){if(!t||!My(t))return!1;const s=td(t);if(s===null||s===ba[Sf])return!0;const n=ba.hasOwnProperty.call(s,Zm)&&s[Zm];if(n===Object)return!0;if(!Gc(n))return!1;let r=Rw.get(n);return r===void 0&&(r=Function.toString.call(n),Rw.set(n,r)),r===YP}function Cf(t,s,n=!0){Iu(t)===0?(n?Reflect.ownKeys(t):ba.keys(t)).forEach(a=>{s(a,t[a],t)}):t.forEach((r,a)=>s(a,r,t))}function Iu(t){const s=t[Vr];return s?s.type_:Af(t)?1:kf(t)?2:Df(t)?3:0}var Ew=(t,s,n=Iu(t))=>n===2?t.has(s):ba[Sf].hasOwnProperty.call(t,s),$v=(t,s,n=Iu(t))=>n===2?t.get(s):t[s],Xm=(t,s,n,r=Iu(t))=>{r===2?t.set(s,n):r===3?t.add(n):t[s]=n};function ZP(t,s){return t===s?t!==0||1/t===1/s:t!==t&&s!==s}var Af=Array.isArray,kf=t=>t instanceof Map,Df=t=>t instanceof Set,My=t=>typeof t=="object",Gc=t=>typeof t=="function",ag=t=>typeof t=="boolean";function QP(t){const s=+t;return Number.isInteger(s)&&String(s)===t}var al=t=>t.copy_||t.base_,Fy=t=>t.modified_?t.copy_:t.base_;function qv(t,s){if(kf(t))return new Map(t);if(Df(t))return new Set(t);if(Af(t))return Array[Sf].slice.call(t);const n=q2(t);if(s===!0||s==="class_only"&&!n){const r=ba.getOwnPropertyDescriptors(t);delete r[Vr];let a=Reflect.ownKeys(r);for(let i=0;i1&&ba.defineProperties(t,{set:am,add:am,clear:am,delete:am}),ba.freeze(t),s&&Cf(t,(n,r)=>{By(r,!0)},!1)),t}function XP(){ri(2)}var am={[ju]:XP};function Rf(t){return t===null||!My(t)?!0:ba.isFrozen(t)}var Jm="MapSet",zv="Patches",_w="ArrayMethods",z2={};function ec(t){const s=z2[t];return s||ri(0,t),s}var Tw=t=>!!z2[t],Nu,U2=()=>Nu,JP=(t,s)=>({drafts_:[],parent_:t,immer_:s,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Tw(Jm)?ec(Jm):void 0,arrayMethodsPlugin_:Tw(_w)?ec(_w):void 0});function Pw(t,s){s&&(t.patchPlugin_=ec(zv),t.patches_=[],t.inversePatches_=[],t.patchListener_=s)}function Uv(t){Vv(t),t.drafts_.forEach(e4),t.drafts_=null}function Vv(t){t===Nu&&(Nu=t.parent_)}var Ow=t=>Nu=JP(Nu,t);function e4(t){const s=t[Vr];s.type_===0||s.type_===1?s.revoke_():s.revoked_=!0}function Lw(t,s){s.unfinalizedDrafts_=s.drafts_.length;const n=s.drafts_[0];if(t!==void 0&&t!==n){n[Vr].modified_&&(Uv(s),ri(4)),ii(t)&&(t=Iw(s,t));const{patchPlugin_:a}=s;a&&a.generateReplacementPatches_(n[Vr].base_,t,s)}else t=Iw(s,n);return t4(s,t,!0),Uv(s),s.patches_&&s.patchListener_(s.patches_,s.inversePatches_),t!==$2?t:void 0}function Iw(t,s){if(Rf(s))return s;const n=s[Vr];if(!n)return ef(s,t.handledSet_,t);if(!Ef(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);W2(n,t)}return n.copy_}function t4(t,s,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&By(s,n)}function V2(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var Ef=(t,s)=>t.scope_===s,s4=[];function H2(t,s,n,r){const a=al(t),i=t.type_;if(r!==void 0&&$v(a,r,i)===s){Xm(a,r,n,i);return}if(!t.draftLocations_){const d=t.draftLocations_=new Map;Cf(a,(m,f)=>{if(ul(f)){const p=d.get(f)||[];p.push(m),d.set(f,p)}})}const o=t.draftLocations_.get(s)??s4;for(const d of o)Xm(a,d,n,i)}function n4(t,s,n){t.callbacks_.push(function(a){var d;const i=s;if(!i||!Ef(i,a))return;(d=a.mapSetPlugin_)==null||d.fixSetContents(i);const o=Fy(i);H2(t,i.draft_??i,o,n),W2(i,a)})}function W2(t,s){var r;if(t.modified_&&!t.finalized_&&(t.type_===3||t.type_===1&&t.allIndicesReassigned_||(((r=t.assigned_)==null?void 0:r.size)??0)>0)){const{patchPlugin_:a}=s;if(a){const i=a.getPath(t);i&&a.generatePatches_(t,i,s)}V2(t)}}function r4(t,s,n){const{scope_:r}=t;if(ul(n)){const a=n[Vr];Ef(a,r)&&a.callbacks_.push(function(){Tm(t);const o=Fy(a);H2(t,n,o,s)})}else ii(n)&&t.callbacks_.push(function(){const i=al(t);t.type_===3?i.has(n)&&ef(n,r.handledSet_,r):$v(i,s,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(s)??!1)===!0&&t.copy_&&ef($v(t.copy_,s,t.type_),r.handledSet_,r)})}function ef(t,s,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||ul(t)||s.has(t)||!ii(t)||Rf(t)||(s.add(t),Cf(t,(r,a)=>{if(ul(a)){const i=a[Vr];if(Ef(i,n)){const o=Fy(i);Xm(t,r,o,t.type_),V2(i)}}else ii(a)&&ef(a,s,n)})),t}function a4(t,s){const n=Af(t),r={type_:n?1:0,scope_:s?s.scope_:U2(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:s,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let a=r,i=tf;n&&(a=[r],i=wu);const{revoke:o,proxy:d}=Proxy.revocable(a,i);return r.draft_=d,r.revoke_=o,[d,r]}var tf={get(t,s){if(s===Vr)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=al(t);if(!Ew(a,s,t.type_))return i4(t,a,s);const i=a[s];if(t.finalized_||!ii(i)||r&&t.operationMethod&&(n!=null&&n.isMutatingArrayMethod(t.operationMethod))&&QP(s))return i;if(i===ig(t.base_,s)){Tm(t);const o=t.type_===1?+s:s,d=Wv(t.scope_,i,t,o);return t.copy_[o]=d}return i},has(t,s){return s in al(t)},ownKeys(t){return Reflect.ownKeys(al(t))},set(t,s,n){const r=G2(al(t),s);if(r!=null&&r.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const a=ig(al(t),s),i=a==null?void 0:a[Vr];if(i&&i.base_===n)return t.copy_[s]=n,t.assigned_.set(s,!1),!0;if(ZP(n,a)&&(n!==void 0||Ew(t.base_,s,t.type_)))return!0;Tm(t),Hv(t)}return t.copy_[s]===n&&(n!==void 0||s in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[s])||(t.copy_[s]=n,t.assigned_.set(s,!0),r4(t,s,n)),!0},deleteProperty(t,s){return Tm(t),ig(t.base_,s)!==void 0||s in t.base_?(t.assigned_.set(s,!1),Hv(t)):t.assigned_.delete(s),t.copy_&&delete t.copy_[s],!0},getOwnPropertyDescriptor(t,s){const n=al(t),r=Reflect.getOwnPropertyDescriptor(n,s);return r&&{[_m]:!0,[Bv]:t.type_!==1||s!=="length",[Qm]:r[Qm],[ju]:n[s]}},defineProperty(){ri(11)},getPrototypeOf(t){return td(t.base_)},setPrototypeOf(){ri(12)}},wu={};for(let t in tf){let s=tf[t];wu[t]=function(){const n=arguments;return n[0]=n[0][0],s.apply(this,n)}}wu.deleteProperty=function(t,s){return wu.set.call(this,t,s,void 0)};wu.set=function(t,s,n){return tf.set.call(this,t[0],s,n,t[0])};function ig(t,s){const n=t[Vr];return(n?al(n):t)[s]}function i4(t,s,n){var a;const r=G2(s,n);return r?ju in r?r[ju]:(a=r.get)==null?void 0:a.call(t.draft_):void 0}function G2(t,s){if(!(s in t))return;let n=td(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,s);if(r)return r;n=td(n)}}function Hv(t){t.modified_||(t.modified_=!0,t.parent_&&Hv(t.parent_))}function Tm(t){t.copy_||(t.assigned_=new Map,t.copy_=qv(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var l4=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(s,n,r)=>{if(Gc(s)&&!Gc(n)){const i=n;n=s;const o=this;return function(m=i,...f){return o.produce(m,p=>n.call(this,p,...f))}}Gc(n)||ri(6),r!==void 0&&!Gc(r)&&ri(7);let a;if(ii(s)){const i=Ow(this),o=Wv(i,s,void 0);let d=!0;try{a=n(o),d=!1}finally{d?Uv(i):Vv(i)}return Pw(i,r),Lw(a,i)}else if(!s||!My(s)){if(a=n(s),a===void 0&&(a=s),a===$2&&(a=void 0),this.autoFreeze_&&By(a,!0),r){const i=[],o=[];ec(zv).generateReplacementPatches_(s,a,{patches_:i,inversePatches_:o}),r(i,o)}return a}else ri(1,s)},this.produceWithPatches=(s,n)=>{if(Gc(s))return(o,...d)=>this.produceWithPatches(o,m=>s(m,...d));let r,a;return[this.produce(s,n,(o,d)=>{r=o,a=d}),r,a]},ag(t==null?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),ag(t==null?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),ag(t==null?void 0:t.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){ii(t)||ri(8),ul(t)&&(t=o4(t));const s=Ow(this),n=Wv(s,t,void 0);return n[Vr].isManual_=!0,Vv(s),n}finishDraft(t,s){const n=t&&t[Vr];(!n||!n.isManual_)&&ri(9);const{scope_:r}=n;return Pw(r,s),Lw(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,s){let n;for(n=s.length-1;n>=0;n--){const a=s[n];if(a.path.length===0&&a.op==="replace"){t=a.value;break}}n>-1&&(s=s.slice(n+1));const r=ec(zv).applyPatches_;return ul(t)?r(t,s):this.produce(t,a=>r(a,s))}};function Wv(t,s,n,r){const[a,i]=kf(s)?ec(Jm).proxyMap_(s,n):Df(s)?ec(Jm).proxySet_(s,n):a4(s,n);return((n==null?void 0:n.scope_)??U2()).drafts_.push(a),i.callbacks_=(n==null?void 0:n.callbacks_)??[],i.key_=r,n&&r!==void 0?n4(n,i,r):i.callbacks_.push(function(m){var p;(p=m.mapSetPlugin_)==null||p.fixSetContents(i);const{patchPlugin_:f}=m;i.modified_&&f&&f.generatePatches_(i,[],m)}),a}function o4(t){return ul(t)||ri(10,t),K2(t)}function K2(t){if(!ii(t)||Rf(t))return t;const s=t[Vr];let n,r=!0;if(s){if(!s.modified_)return s.base_;s.finalized_=!0,n=qv(t,s.scope_.immer_.useStrictShallowCopy_),r=s.scope_.immer_.shouldUseStrictIteration()}else n=qv(t,!0);return Cf(n,(a,i)=>{Xm(n,a,K2(i))},r),s&&(s.finalized_=!1),n}var c4=new l4,Y2=c4.produce;function Z2(t){return({dispatch:n,getState:r})=>a=>i=>typeof i=="function"?i(n,r,t):a(i)}var d4=Z2(),u4=Z2,h4=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Ym:Ym.apply(null,arguments)},m4=t=>t&&typeof t.match=="function";function vu(t,s){function n(...r){if(s){let a=s(...r);if(!a)throw new Error(ol(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=>KP(r)&&r.type===t,n}var Q2=class uu extends Array{constructor(...s){super(...s),Object.setPrototypeOf(this,uu.prototype)}static get[Symbol.species](){return uu}concat(...s){return super.concat.apply(this,s)}prepend(...s){return s.length===1&&Array.isArray(s[0])?new uu(...s[0].concat(this)):new uu(...s.concat(this))}};function Mw(t){return ii(t)?Y2(t,()=>{}):t}function im(t,s,n){return t.has(s)?t.get(s):t.set(s,n(s)).get(s)}function f4(t){return typeof t=="boolean"}var p4=()=>function(s){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:a=!0,actionCreatorCheck:i=!0}=s??{};let o=new Q2;return n&&(f4(n)?o.push(d4):o.push(u4(n.extraArgument))),o},x4="RTK_autoBatch",Fw=t=>s=>{setTimeout(s,t)},g4=(t={type:"raf"})=>s=>(...n)=>{const r=s(...n);let a=!0,i=!1,o=!1;const d=new Set,m=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:Fw(10):t.type==="callback"?t.queueNotification:Fw(t.timeout),f=()=>{o=!1,i&&(i=!1,d.forEach(p=>p()))};return Object.assign({},r,{subscribe(p){const h=()=>a&&p(),x=r.subscribe(h);return d.add(p),()=>{x(),d.delete(p)}},dispatch(p){var h;try{return a=!((h=p==null?void 0:p.meta)!=null&&h[x4]),i=!a,i&&(o||(o=!0,m(f))),r.dispatch(p)}finally{a=!0}}})},v4=t=>function(n){const{autoBatch:r=!0}=n??{};let a=new Q2(t);return r&&a.push(g4(typeof r=="object"?r:void 0)),a};function y4(t){const s=p4(),{reducer:n=void 0,middleware:r,devTools:a=!0,preloadedState:i=void 0,enhancers:o=void 0}=t||{};let d;if(typeof n=="function")d=n;else if(Iy(n))d=WP(n);else throw new Error(ol(1));let m;typeof r=="function"?m=r(s):m=s();let f=Ym;a&&(f=h4({trace:!1,...typeof a=="object"&&a}));const p=GP(...m),h=v4(p);let x=typeof o=="function"?o(h):h();const u=f(...x);return B2(d,i,u)}function X2(t){const s={},n=[];let r;const a={addCase(i,o){const d=typeof i=="string"?i:i.type;if(!d)throw new Error(ol(28));if(d in s)throw new Error(ol(29));return s[d]=o,a},addAsyncThunk(i,o){return o.pending&&(s[i.pending.type]=o.pending),o.rejected&&(s[i.rejected.type]=o.rejected),o.fulfilled&&(s[i.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:i.settled,reducer:o.settled}),a},addMatcher(i,o){return n.push({matcher:i,reducer:o}),a},addDefaultCase(i){return r=i,a}};return t(a),[s,n,r]}function b4(t){return typeof t=="function"}function j4(t,s){let[n,r,a]=X2(s),i;if(b4(t))i=()=>Mw(t());else{const d=Mw(t);i=()=>d}function o(d=i(),m){let f=[n[m.type],...r.filter(({matcher:p})=>p(m)).map(({reducer:p})=>p)];return f.filter(p=>!!p).length===0&&(f=[a]),f.reduce((p,h)=>{if(h)if(ul(p)){const u=h(p,m);return u===void 0?p:u}else{if(ii(p))return Y2(p,x=>h(x,m));{const x=h(p,m);if(x===void 0){if(p===null)return p;throw Error("A case reducer on a non-draftable value must not return undefined")}return x}}return p},d)}return o.getInitialState=i,o}var N4=(t,s)=>m4(t)?t.match(s):t(s);function w4(...t){return s=>t.some(n=>N4(n,s))}var S4="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",C4=(t=21)=>{let s="",n=t;for(;n--;)s+=S4[Math.random()*64|0];return s},A4=["name","message","stack","code"],lg=class{constructor(t,s){Kx(this,"_type");this.payload=t,this.meta=s}},Bw=class{constructor(t,s){Kx(this,"_type");this.payload=t,this.meta=s}},k4=t=>{if(typeof t=="object"&&t!==null){const s={};for(const n of A4)typeof t[n]=="string"&&(s[n]=t[n]);return s}return{message:String(t)}},$w="External signal was aborted",D4=(()=>{function t(s,n,r){const a=vu(s+"/fulfilled",(m,f,p,h)=>({payload:m,meta:{...h||{},arg:p,requestId:f,requestStatus:"fulfilled"}})),i=vu(s+"/pending",(m,f,p)=>({payload:void 0,meta:{...p||{},arg:f,requestId:m,requestStatus:"pending"}})),o=vu(s+"/rejected",(m,f,p,h,x)=>({payload:h,error:(r&&r.serializeError||k4)(m||"Rejected"),meta:{...x||{},arg:p,requestId:f,rejectedWithValue:!!h,requestStatus:"rejected",aborted:(m==null?void 0:m.name)==="AbortError",condition:(m==null?void 0:m.name)==="ConditionError"}}));function d(m,{signal:f}={}){return(p,h,x)=>{const u=r!=null&&r.idGenerator?r.idGenerator(m):C4(),N=new AbortController;let v,w;function j(C){w=C,N.abort()}f&&(f.aborted?j($w):f.addEventListener("abort",()=>j($w),{once:!0}));const b=(async function(){var D,_;let C;try{let A=(D=r==null?void 0:r.condition)==null?void 0:D.call(r,m,{getState:h,extra:x});if(E4(A)&&(A=await A),A===!1||N.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const E=new Promise((q,O)=>{v=()=>{O({name:"AbortError",message:w||"Aborted"})},N.signal.addEventListener("abort",v,{once:!0})});p(i(u,m,(_=r==null?void 0:r.getPendingMeta)==null?void 0:_.call(r,{requestId:u,arg:m},{getState:h,extra:x}))),C=await Promise.race([E,Promise.resolve(n(m,{dispatch:p,getState:h,extra:x,requestId:u,signal:N.signal,abort:j,rejectWithValue:(q,O)=>new lg(q,O),fulfillWithValue:(q,O)=>new Bw(q,O)})).then(q=>{if(q instanceof lg)throw q;return q instanceof Bw?a(q.payload,u,m,q.meta):a(q,u,m)})])}catch(A){C=A instanceof lg?o(null,u,m,A.payload,A.meta):o(A,u,m)}finally{v&&N.signal.removeEventListener("abort",v)}return r&&!r.dispatchConditionRejection&&o.match(C)&&C.meta.condition||p(C),C})();return Object.assign(b,{abort:j,requestId:u,arg:m,unwrap(){return b.then(R4)}})}}return Object.assign(d,{pending:i,rejected:o,fulfilled:a,settled:w4(o,a),typePrefix:s})}return t.withTypes=()=>t,t})();function R4(t){if(t.meta&&t.meta.rejectedWithValue)throw t.payload;if(t.error)throw t.error;return t.payload}function E4(t){return t!==null&&typeof t=="object"&&typeof t.then=="function"}var _4=Symbol.for("rtk-slice-createasyncthunk");function T4(t,s){return`${t}/${s}`}function P4({creators:t}={}){var n;const s=(n=t==null?void 0:t.asyncThunk)==null?void 0:n[_4];return function(a){const{name:i,reducerPath:o=i}=a;if(!i)throw new Error(ol(11));const d=(typeof a.reducers=="function"?a.reducers(L4()):a.reducers)||{},m=Object.keys(d),f={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},p={addCase(S,D){const _=typeof S=="string"?S:S.type;if(!_)throw new Error(ol(12));if(_ in f.sliceCaseReducersByType)throw new Error(ol(13));return f.sliceCaseReducersByType[_]=D,p},addMatcher(S,D){return f.sliceMatchers.push({matcher:S,reducer:D}),p},exposeAction(S,D){return f.actionCreators[S]=D,p},exposeCaseReducer(S,D){return f.sliceCaseReducersByName[S]=D,p}};m.forEach(S=>{const D=d[S],_={reducerName:S,type:T4(i,S),createNotation:typeof a.reducers=="function"};M4(D)?B4(_,D,p,s):I4(_,D,p)});function h(){const[S={},D=[],_=void 0]=typeof a.extraReducers=="function"?X2(a.extraReducers):[a.extraReducers],A={...S,...f.sliceCaseReducersByType};return j4(a.initialState,E=>{for(let q in A)E.addCase(q,A[q]);for(let q of f.sliceMatchers)E.addMatcher(q.matcher,q.reducer);for(let q of D)E.addMatcher(q.matcher,q.reducer);_&&E.addDefaultCase(_)})}const x=S=>S,u=new Map,N=new WeakMap;let v;function w(S,D){return v||(v=h()),v(S,D)}function j(){return v||(v=h()),v.getInitialState()}function b(S,D=!1){function _(E){let q=E[S];return typeof q>"u"&&D&&(q=im(N,_,j)),q}function A(E=x){const q=im(u,D,()=>new WeakMap);return im(q,E,()=>{const O={};for(const[R,P]of Object.entries(a.selectors??{}))O[R]=O4(P,E,()=>im(N,E,j),D);return O})}return{reducerPath:S,getSelectors:A,get selectors(){return A(_)},selectSlice:_}}const C={name:i,reducer:w,actions:f.actionCreators,caseReducers:f.sliceCaseReducersByName,getInitialState:j,...b(o),injectInto(S,{reducerPath:D,..._}={}){const A=D??o;return S.inject({reducerPath:A,reducer:w},_),{...C,...b(A,!0)}}};return C}}function O4(t,s,n,r){function a(i,...o){let d=s(i);return typeof d>"u"&&r&&(d=n()),t(d,...o)}return a.unwrapped=t,a}var J2=P4();function L4(){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 I4({type:t,reducerName:s,createNotation:n},r,a){let i,o;if("reducer"in r){if(n&&!F4(r))throw new Error(ol(17));i=r.reducer,o=r.prepare}else i=r;a.addCase(t,i).exposeCaseReducer(s,i).exposeAction(s,o?vu(t,o):vu(t))}function M4(t){return t._reducerDefinitionType==="asyncThunk"}function F4(t){return t._reducerDefinitionType==="reducerWithPrepare"}function B4({type:t,reducerName:s},n,r,a){if(!a)throw new Error(ol(18));const{payloadCreator:i,fulfilled:o,pending:d,rejected:m,settled:f,options:p}=n,h=a(t,i,p);r.exposeAction(s,h),o&&r.addCase(h.fulfilled,o),d&&r.addCase(h.pending,d),m&&r.addCase(h.rejected,m),f&&r.addMatcher(h.settled,f),r.exposeCaseReducer(s,{fulfilled:o||lm,pending:d||lm,rejected:m||lm,settled:f||lm})}function lm(){}function ol(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 pr={};/*! Axios v1.13.6 Copyright (c) 2026 Matt Zabriskie and contributors */var og,qw;function $4(){if(qw)return og;qw=1;function t(ee,se){return function(){return ee.apply(se,arguments)}}const{toString:s}=Object.prototype,{getPrototypeOf:n}=Object,{iterator:r,toStringTag:a}=Symbol,i=(ee=>se=>{const he=s.call(se);return ee[he]||(ee[he]=he.slice(8,-1).toLowerCase())})(Object.create(null)),o=ee=>(ee=ee.toLowerCase(),se=>i(se)===ee),d=ee=>se=>typeof se===ee,{isArray:m}=Array,f=d("undefined");function p(ee){return ee!==null&&!f(ee)&&ee.constructor!==null&&!f(ee.constructor)&&N(ee.constructor.isBuffer)&&ee.constructor.isBuffer(ee)}const h=o("ArrayBuffer");function x(ee){let se;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?se=ArrayBuffer.isView(ee):se=ee&&ee.buffer&&h(ee.buffer),se}const u=d("string"),N=d("function"),v=d("number"),w=ee=>ee!==null&&typeof ee=="object",j=ee=>ee===!0||ee===!1,b=ee=>{if(i(ee)!=="object")return!1;const se=n(ee);return(se===null||se===Object.prototype||Object.getPrototypeOf(se)===null)&&!(a in ee)&&!(r in ee)},C=ee=>{if(!w(ee)||p(ee))return!1;try{return Object.keys(ee).length===0&&Object.getPrototypeOf(ee)===Object.prototype}catch{return!1}},S=o("Date"),D=o("File"),_=ee=>!!(ee&&typeof ee.uri<"u"),A=ee=>ee&&typeof ee.getParts<"u",E=o("Blob"),q=o("FileList"),O=ee=>w(ee)&&N(ee.pipe);function R(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof Vo<"u"?Vo:{}}const P=R(),L=typeof P.FormData<"u"?P.FormData:void 0,$=ee=>{let se;return ee&&(L&&ee instanceof L||N(ee.append)&&((se=i(ee))==="formdata"||se==="object"&&N(ee.toString)&&ee.toString()==="[object FormData]"))},Z=o("URLSearchParams"),[Q,W,U,M]=["ReadableStream","Request","Response","Headers"].map(o),z=ee=>ee.trim?ee.trim():ee.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function T(ee,se,{allOwnKeys:he=!1}={}){if(ee===null||typeof ee>"u")return;let pe,Ne;if(typeof ee!="object"&&(ee=[ee]),m(ee))for(pe=0,Ne=ee.length;pe0;)if(Ne=he[pe],se===Ne.toLowerCase())return Ne;return null}const I=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:Vo,K=ee=>!f(ee)&&ee!==I;function G(){const{caseless:ee,skipUndefined:se}=K(this)&&this||{},he={},pe=(Ne,$e)=>{if($e==="__proto__"||$e==="constructor"||$e==="prototype")return;const qe=ee&&F(he,$e)||$e;b(he[qe])&&b(Ne)?he[qe]=G(he[qe],Ne):b(Ne)?he[qe]=G({},Ne):m(Ne)?he[qe]=Ne.slice():(!se||!f(Ne))&&(he[qe]=Ne)};for(let Ne=0,$e=arguments.length;Ne<$e;Ne++)arguments[Ne]&&T(arguments[Ne],pe);return he}const V=(ee,se,he,{allOwnKeys:pe}={})=>(T(se,(Ne,$e)=>{he&&N(Ne)?Object.defineProperty(ee,$e,{value:t(Ne,he),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(ee,$e,{value:Ne,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:pe}),ee),Y=ee=>(ee.charCodeAt(0)===65279&&(ee=ee.slice(1)),ee),re=(ee,se,he,pe)=>{ee.prototype=Object.create(se.prototype,pe),Object.defineProperty(ee.prototype,"constructor",{value:ee,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(ee,"super",{value:se.prototype}),he&&Object.assign(ee.prototype,he)},ae=(ee,se,he,pe)=>{let Ne,$e,qe;const ct={};if(se=se||{},ee==null)return se;do{for(Ne=Object.getOwnPropertyNames(ee),$e=Ne.length;$e-- >0;)qe=Ne[$e],(!pe||pe(qe,ee,se))&&!ct[qe]&&(se[qe]=ee[qe],ct[qe]=!0);ee=he!==!1&&n(ee)}while(ee&&(!he||he(ee,se))&&ee!==Object.prototype);return se},ue=(ee,se,he)=>{ee=String(ee),(he===void 0||he>ee.length)&&(he=ee.length),he-=se.length;const pe=ee.indexOf(se,he);return pe!==-1&&pe===he},ye=ee=>{if(!ee)return null;if(m(ee))return ee;let se=ee.length;if(!v(se))return null;const he=new Array(se);for(;se-- >0;)he[se]=ee[se];return he},ce=(ee=>se=>ee&&se instanceof ee)(typeof Uint8Array<"u"&&n(Uint8Array)),je=(ee,se)=>{const pe=(ee&&ee[r]).call(ee);let Ne;for(;(Ne=pe.next())&&!Ne.done;){const $e=Ne.value;se.call(ee,$e[0],$e[1])}},Me=(ee,se)=>{let he;const pe=[];for(;(he=ee.exec(se))!==null;)pe.push(he);return pe},ut=o("HTMLFormElement"),jt=ee=>ee.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(he,pe,Ne){return pe.toUpperCase()+Ne}),ft=(({hasOwnProperty:ee})=>(se,he)=>ee.call(se,he))(Object.prototype),X=o("RegExp"),Ce=(ee,se)=>{const he=Object.getOwnPropertyDescriptors(ee),pe={};T(he,(Ne,$e)=>{let qe;(qe=se(Ne,$e,ee))!==!1&&(pe[$e]=qe||Ne)}),Object.defineProperties(ee,pe)},xe=ee=>{Ce(ee,(se,he)=>{if(N(ee)&&["arguments","caller","callee"].indexOf(he)!==-1)return!1;const pe=ee[he];if(N(pe)){if(se.enumerable=!1,"writable"in se){se.writable=!1;return}se.set||(se.set=()=>{throw Error("Can not rewrite read-only method '"+he+"'")})}})},We=(ee,se)=>{const he={},pe=Ne=>{Ne.forEach($e=>{he[$e]=!0})};return m(ee)?pe(ee):pe(String(ee).split(se)),he},Be=()=>{},rt=(ee,se)=>ee!=null&&Number.isFinite(ee=+ee)?ee:se;function ht(ee){return!!(ee&&N(ee.append)&&ee[a]==="FormData"&&ee[r])}const ge=ee=>{const se=new Array(10),he=(pe,Ne)=>{if(w(pe)){if(se.indexOf(pe)>=0)return;if(p(pe))return pe;if(!("toJSON"in pe)){se[Ne]=pe;const $e=m(pe)?[]:{};return T(pe,(qe,ct)=>{const ds=he(qe,Ne+1);!f(ds)&&($e[ct]=ds)}),se[Ne]=void 0,$e}}return pe};return he(ee,0)},Je=o("AsyncFunction"),mt=ee=>ee&&(w(ee)||N(ee))&&N(ee.then)&&N(ee.catch),de=((ee,se)=>ee?setImmediate:se?((he,pe)=>(I.addEventListener("message",({source:Ne,data:$e})=>{Ne===I&&$e===he&&pe.length&&pe.shift()()},!1),Ne=>{pe.push(Ne),I.postMessage(he,"*")}))(`axios@${Math.random()}`,[]):he=>setTimeout(he))(typeof setImmediate=="function",N(I.postMessage)),at=typeof queueMicrotask<"u"?queueMicrotask.bind(I):typeof process<"u"&&process.nextTick||de;var ke={isArray:m,isArrayBuffer:h,isBuffer:p,isFormData:$,isArrayBufferView:x,isString:u,isNumber:v,isBoolean:j,isObject:w,isPlainObject:b,isEmptyObject:C,isReadableStream:Q,isRequest:W,isResponse:U,isHeaders:M,isUndefined:f,isDate:S,isFile:D,isReactNativeBlob:_,isReactNative:A,isBlob:E,isRegExp:X,isFunction:N,isStream:O,isURLSearchParams:Z,isTypedArray:ce,isFileList:q,forEach:T,merge:G,extend:V,trim:z,stripBOM:Y,inherits:re,toFlatObject:ae,kindOf:i,kindOfTest:o,endsWith:ue,toArray:ye,forEachEntry:je,matchAll:Me,isHTMLForm:ut,hasOwnProperty:ft,hasOwnProp:ft,reduceDescriptors:Ce,freezeMethods:xe,toObjectSet:We,toCamelCase:jt,noop:Be,toFiniteNumber:rt,findKey:F,global:I,isContextDefined:K,isSpecCompliantForm:ht,toJSONObject:ge,isAsyncFn:Je,isThenable:mt,setImmediate:de,asap:at,isIterable:ee=>ee!=null&&N(ee[r])};class Zt extends Error{static from(se,he,pe,Ne,$e,qe){const ct=new Zt(se.message,he||se.code,pe,Ne,$e);return ct.cause=se,ct.name=se.name,se.status!=null&&ct.status==null&&(ct.status=se.status),qe&&Object.assign(ct,qe),ct}constructor(se,he,pe,Ne,$e){super(se),Object.defineProperty(this,"message",{value:se,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,he&&(this.code=he),pe&&(this.config=pe),Ne&&(this.request=Ne),$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:ke.toJSONObject(this.config),code:this.code,status:this.status}}}Zt.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",Zt.ERR_BAD_OPTION="ERR_BAD_OPTION",Zt.ECONNABORTED="ECONNABORTED",Zt.ETIMEDOUT="ETIMEDOUT",Zt.ERR_NETWORK="ERR_NETWORK",Zt.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",Zt.ERR_DEPRECATED="ERR_DEPRECATED",Zt.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",Zt.ERR_BAD_REQUEST="ERR_BAD_REQUEST",Zt.ERR_CANCELED="ERR_CANCELED",Zt.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",Zt.ERR_INVALID_URL="ERR_INVALID_URL";var Bt=Zt,_s=null;function Us(ee){return ke.isPlainObject(ee)||ke.isArray(ee)}function fs(ee){return ke.endsWith(ee,"[]")?ee.slice(0,-2):ee}function Vs(ee,se,he){return ee?ee.concat(se).map(function(Ne,$e){return Ne=fs(Ne),!he&&$e?"["+Ne+"]":Ne}).join(he?".":""):se}function Qs(ee){return ke.isArray(ee)&&!ee.some(Us)}const Xs=ke.toFlatObject(ke,{},null,function(se){return/^is[A-Z]/.test(se)});function ie(ee,se,he){if(!ke.isObject(ee))throw new TypeError("target must be an object");se=se||new FormData,he=ke.toFlatObject(he,{metaTokens:!0,dots:!1,indexes:!1},!1,function(Es,os){return!ke.isUndefined(os[Es])});const pe=he.metaTokens,Ne=he.visitor||Ft,$e=he.dots,qe=he.indexes,ds=(he.Blob||typeof Blob<"u"&&Blob)&&ke.isSpecCompliantForm(se);if(!ke.isFunction(Ne))throw new TypeError("visitor must be a function");function Kt(zt){if(zt===null)return"";if(ke.isDate(zt))return zt.toISOString();if(ke.isBoolean(zt))return zt.toString();if(!ds&&ke.isBlob(zt))throw new Bt("Blob is not supported. Use a Buffer instead.");return ke.isArrayBuffer(zt)||ke.isTypedArray(zt)?ds&&typeof Blob=="function"?new Blob([zt]):Buffer.from(zt):zt}function Ft(zt,Es,os){let On=zt;if(ke.isReactNative(se)&&ke.isReactNativeBlob(zt))return se.append(Vs(os,Es,$e),Kt(zt)),!1;if(zt&&!os&&typeof zt=="object"){if(ke.endsWith(Es,"{}"))Es=pe?Es:Es.slice(0,-2),zt=JSON.stringify(zt);else if(ke.isArray(zt)&&Qs(zt)||(ke.isFileList(zt)||ke.endsWith(Es,"[]"))&&(On=ke.toArray(zt)))return Es=fs(Es),On.forEach(function(zn,cr){!(ke.isUndefined(zn)||zn===null)&&se.append(qe===!0?Vs([Es],cr,$e):qe===null?Es:Es+"[]",Kt(zn))}),!1}return Us(zt)?!0:(se.append(Vs(os,Es,$e),Kt(zt)),!1)}const Rs=[],cn=Object.assign(Xs,{defaultVisitor:Ft,convertValue:Kt,isVisitable:Us});function Kn(zt,Es){if(!ke.isUndefined(zt)){if(Rs.indexOf(zt)!==-1)throw Error("Circular reference detected in "+Es.join("."));Rs.push(zt),ke.forEach(zt,function(On,Cr){(!(ke.isUndefined(On)||On===null)&&Ne.call(se,On,ke.isString(Cr)?Cr.trim():Cr,Es,cn))===!0&&Kn(On,Es?Es.concat(Cr):[Cr])}),Rs.pop()}}if(!ke.isObject(ee))throw new TypeError("data must be an object");return Kn(ee),se}function nt(ee){const se={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(ee).replace(/[!'()~]|%20|%00/g,function(pe){return se[pe]})}function fe(ee,se){this._pairs=[],ee&&ie(ee,this,se)}const Ae=fe.prototype;Ae.append=function(se,he){this._pairs.push([se,he])},Ae.toString=function(se){const he=se?function(pe){return se.call(this,pe,nt)}:nt;return this._pairs.map(function(Ne){return he(Ne[0])+"="+he(Ne[1])},"").join("&")};function Fe(ee){return encodeURIComponent(ee).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Ke(ee,se,he){if(!se)return ee;const pe=he&&he.encode||Fe,Ne=ke.isFunction(he)?{serialize:he}:he,$e=Ne&&Ne.serialize;let qe;if($e?qe=$e(se,Ne):qe=ke.isURLSearchParams(se)?se.toString():new fe(se,Ne).toString(pe),qe){const ct=ee.indexOf("#");ct!==-1&&(ee=ee.slice(0,ct)),ee+=(ee.indexOf("?")===-1?"?":"&")+qe}return ee}class Le{constructor(){this.handlers=[]}use(se,he,pe){return this.handlers.push({fulfilled:se,rejected:he,synchronous:pe?pe.synchronous:!1,runWhen:pe?pe.runWhen:null}),this.handlers.length-1}eject(se){this.handlers[se]&&(this.handlers[se]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(se){ke.forEach(this.handlers,function(pe){pe!==null&&se(pe)})}}var Ue=Le,et={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},dt=typeof URLSearchParams<"u"?URLSearchParams:fe,ss=typeof FormData<"u"?FormData:null,Wt=typeof Blob<"u"?Blob:null,kt={isBrowser:!0,classes:{URLSearchParams:dt,FormData:ss,Blob:Wt},protocols:["http","https","file","blob","url","data"]};const wt=typeof window<"u"&&typeof document<"u",Os=typeof navigator=="object"&&navigator||void 0,as=wt&&(!Os||["ReactNative","NativeScript","NS"].indexOf(Os.product)<0),Se=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",be=wt&&window.location.href||"http://localhost";var pt=Object.freeze({__proto__:null,hasBrowserEnv:wt,hasStandardBrowserWebWorkerEnv:Se,hasStandardBrowserEnv:as,navigator:Os,origin:be}),Ve={...pt,...kt};function bt(ee,se){return ie(ee,new Ve.classes.URLSearchParams,{visitor:function(he,pe,Ne,$e){return Ve.isNode&&ke.isBuffer(he)?(this.append(pe,he.toString("base64")),!1):$e.defaultVisitor.apply(this,arguments)},...se})}function gt(ee){return ke.matchAll(/\w+|\[(\w*)]/g,ee).map(se=>se[0]==="[]"?"":se[1]||se[0])}function rs(ee){const se={},he=Object.keys(ee);let pe;const Ne=he.length;let $e;for(pe=0;pe=he.length;return qe=!qe&&ke.isArray(Ne)?Ne.length:qe,ds?(ke.hasOwnProp(Ne,qe)?Ne[qe]=[Ne[qe],pe]:Ne[qe]=pe,!ct):((!Ne[qe]||!ke.isObject(Ne[qe]))&&(Ne[qe]=[]),se(he,pe,Ne[qe],$e)&&ke.isArray(Ne[qe])&&(Ne[qe]=rs(Ne[qe])),!ct)}if(ke.isFormData(ee)&&ke.isFunction(ee.entries)){const he={};return ke.forEachEntry(ee,(pe,Ne)=>{se(gt(pe),Ne,he,0)}),he}return null}function Ts(ee,se,he){if(ke.isString(ee))try{return(se||JSON.parse)(ee),ke.trim(ee)}catch(pe){if(pe.name!=="SyntaxError")throw pe}return(he||JSON.stringify)(ee)}const Ws={transitional:et,adapter:["xhr","http","fetch"],transformRequest:[function(se,he){const pe=he.getContentType()||"",Ne=pe.indexOf("application/json")>-1,$e=ke.isObject(se);if($e&&ke.isHTMLForm(se)&&(se=new FormData(se)),ke.isFormData(se))return Ne?JSON.stringify(is(se)):se;if(ke.isArrayBuffer(se)||ke.isBuffer(se)||ke.isStream(se)||ke.isFile(se)||ke.isBlob(se)||ke.isReadableStream(se))return se;if(ke.isArrayBufferView(se))return se.buffer;if(ke.isURLSearchParams(se))return he.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),se.toString();let ct;if($e){if(pe.indexOf("application/x-www-form-urlencoded")>-1)return bt(se,this.formSerializer).toString();if((ct=ke.isFileList(se))||pe.indexOf("multipart/form-data")>-1){const ds=this.env&&this.env.FormData;return ie(ct?{"files[]":se}:se,ds&&new ds,this.formSerializer)}}return $e||Ne?(he.setContentType("application/json",!1),Ts(se)):se}],transformResponse:[function(se){const he=this.transitional||Ws.transitional,pe=he&&he.forcedJSONParsing,Ne=this.responseType==="json";if(ke.isResponse(se)||ke.isReadableStream(se))return se;if(se&&ke.isString(se)&&(pe&&!this.responseType||Ne)){const qe=!(he&&he.silentJSONParsing)&&Ne;try{return JSON.parse(se,this.parseReviver)}catch(ct){if(qe)throw ct.name==="SyntaxError"?Bt.from(ct,Bt.ERR_BAD_RESPONSE,this,null,this.response):ct}}return se}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ve.classes.FormData,Blob:Ve.classes.Blob},validateStatus:function(se){return se>=200&&se<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ke.forEach(["delete","get","head","post","put","patch"],ee=>{Ws.headers[ee]={}});var nn=Ws;const Ee=ke.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 $t=ee=>{const se={};let he,pe,Ne;return ee&&ee.split(` `).forEach(function(qe){Ne=qe.indexOf(":"),he=qe.substring(0,Ne).trim().toLowerCase(),pe=qe.substring(Ne+1).trim(),!(!he||se[he]&&Ee[he])&&(he==="set-cookie"?se[he]?se[he].push(pe):se[he]=[pe]:se[he]=se[he]?se[he]+", "+pe:pe)}),se};const Xt=Symbol("internals");function Cs(ee){return ee&&String(ee).trim().toLowerCase()}function Mt(ee){return ee===!1||ee==null?ee:ke.isArray(ee)?ee.map(Mt):String(ee)}function ze(ee){const se=Object.create(null),he=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let pe;for(;pe=he.exec(ee);)se[pe[1]]=pe[2];return se}const xt=ee=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(ee.trim());function yt(ee,se,he,pe,Ne){if(ke.isFunction(pe))return pe.call(this,se,he);if(Ne&&(se=he),!!ke.isString(se)){if(ke.isString(pe))return se.indexOf(pe)!==-1;if(ke.isRegExp(pe))return pe.test(se)}}function Ot(ee){return ee.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(se,he,pe)=>he.toUpperCase()+pe)}function Pt(ee,se){const he=ke.toCamelCase(" "+se);["get","set","has"].forEach(pe=>{Object.defineProperty(ee,pe+he,{value:function(Ne,$e,qe){return this[pe].call(this,se,Ne,$e,qe)},configurable:!0})})}class Jt{constructor(se){se&&this.set(se)}set(se,he,pe){const Ne=this;function $e(ct,ds,Kt){const Ft=Cs(ds);if(!Ft)throw new Error("header name must be a non-empty string");const Rs=ke.findKey(Ne,Ft);(!Rs||Ne[Rs]===void 0||Kt===!0||Kt===void 0&&Ne[Rs]!==!1)&&(Ne[Rs||ds]=Mt(ct))}const qe=(ct,ds)=>ke.forEach(ct,(Kt,Ft)=>$e(Kt,Ft,ds));if(ke.isPlainObject(se)||se instanceof this.constructor)qe(se,he);else if(ke.isString(se)&&(se=se.trim())&&!xt(se))qe($t(se),he);else if(ke.isObject(se)&&ke.isIterable(se)){let ct={},ds,Kt;for(const Ft of se){if(!ke.isArray(Ft))throw TypeError("Object iterator must return a key-value pair");ct[Kt=Ft[0]]=(ds=ct[Kt])?ke.isArray(ds)?[...ds,Ft[1]]:[ds,Ft[1]]:Ft[1]}qe(ct,he)}else se!=null&&$e(he,se,pe);return this}get(se,he){if(se=Cs(se),se){const pe=ke.findKey(this,se);if(pe){const Ne=this[pe];if(!he)return Ne;if(he===!0)return ze(Ne);if(ke.isFunction(he))return he.call(this,Ne,pe);if(ke.isRegExp(he))return he.exec(Ne);throw new TypeError("parser must be boolean|regexp|function")}}}has(se,he){if(se=Cs(se),se){const pe=ke.findKey(this,se);return!!(pe&&this[pe]!==void 0&&(!he||yt(this,this[pe],pe,he)))}return!1}delete(se,he){const pe=this;let Ne=!1;function $e(qe){if(qe=Cs(qe),qe){const ct=ke.findKey(pe,qe);ct&&(!he||yt(pe,pe[ct],ct,he))&&(delete pe[ct],Ne=!0)}}return ke.isArray(se)?se.forEach($e):$e(se),Ne}clear(se){const he=Object.keys(this);let pe=he.length,Ne=!1;for(;pe--;){const $e=he[pe];(!se||yt(this,this[$e],$e,se,!0))&&(delete this[$e],Ne=!0)}return Ne}normalize(se){const he=this,pe={};return ke.forEach(this,(Ne,$e)=>{const qe=ke.findKey(pe,$e);if(qe){he[qe]=Mt(Ne),delete he[$e];return}const ct=se?Ot($e):String($e).trim();ct!==$e&&delete he[$e],he[ct]=Mt(Ne),pe[ct]=!0}),this}concat(...se){return this.constructor.concat(this,...se)}toJSON(se){const he=Object.create(null);return ke.forEach(this,(pe,Ne)=>{pe!=null&&pe!==!1&&(he[Ne]=se&&ke.isArray(pe)?pe.join(", "):pe)}),he}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([se,he])=>se+": "+he).join(` `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(se){return se instanceof this?se:new this(se)}static concat(se,...he){const pe=new this(se);return he.forEach(Ne=>pe.set(Ne)),pe}static accessor(se){const pe=(this[Xt]=this[Xt]={accessors:{}}).accessors,Ne=this.prototype;function $e(qe){const ct=Cs(qe);pe[ct]||(Pt(Ne,qe),pe[ct]=!0)}return ke.isArray(se)?se.forEach($e):$e(se),this}}Jt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),ke.reduceDescriptors(Jt.prototype,({value:ee},se)=>{let he=se[0].toUpperCase()+se.slice(1);return{get:()=>ee,set(pe){this[he]=pe}}}),ke.freezeMethods(Jt);var bs=Jt;function ns(ee,se){const he=this||nn,pe=se||he,Ne=bs.from(pe.headers);let $e=pe.data;return ke.forEach(ee,function(ct){$e=ct.call(he,$e,Ne.normalize(),se?se.status:void 0)}),Ne.normalize(),$e}function Ds(ee){return!!(ee&&ee.__CANCEL__)}class ts extends Bt{constructor(se,he,pe){super(se??"canceled",Bt.ERR_CANCELED,he,pe),this.name="CanceledError",this.__CANCEL__=!0}}var js=ts;function tn(ee,se,he){const pe=he.config.validateStatus;!he.status||!pe||pe(he.status)?ee(he):se(new Bt("Request failed with status code "+he.status,[Bt.ERR_BAD_REQUEST,Bt.ERR_BAD_RESPONSE][Math.floor(he.status/100)-4],he.config,he.request,he))}function vn(ee){const se=/^([-+\w]{1,25})(:?\/\/|:)/.exec(ee);return se&&se[1]||""}function jn(ee,se){ee=ee||10;const he=new Array(ee),pe=new Array(ee);let Ne=0,$e=0,qe;return se=se!==void 0?se:1e3,function(ds){const Kt=Date.now(),Ft=pe[$e];qe||(qe=Kt),he[Ne]=ds,pe[Ne]=Kt;let Rs=$e,cn=0;for(;Rs!==Ne;)cn+=he[Rs++],Rs=Rs%ee;if(Ne=(Ne+1)%ee,Ne===$e&&($e=($e+1)%ee),Kt-qe{he=Ft,Ne=null,$e&&(clearTimeout($e),$e=null),ee(...Kt)};return[(...Kt)=>{const Ft=Date.now(),Rs=Ft-he;Rs>=pe?qe(Kt,Ft):(Ne=Kt,$e||($e=setTimeout(()=>{$e=null,qe(Ne)},pe-Rs)))},()=>Ne&&qe(Ne)]}const gn=(ee,se,he=3)=>{let pe=0;const Ne=jn(50,250);return xn($e=>{const qe=$e.loaded,ct=$e.lengthComputable?$e.total:void 0,ds=qe-pe,Kt=Ne(ds),Ft=qe<=ct;pe=qe;const Rs={loaded:qe,total:ct,progress:ct?qe/ct:void 0,bytes:ds,rate:Kt||void 0,estimated:Kt&&ct&&Ft?(ct-qe)/Kt:void 0,event:$e,lengthComputable:ct!=null,[se?"download":"upload"]:!0};ee(Rs)},he)},Ye=(ee,se)=>{const he=ee!=null;return[pe=>se[0]({lengthComputable:he,total:ee,loaded:pe}),se[1]]},qt=ee=>(...se)=>ke.asap(()=>ee(...se));var Ze=Ve.hasStandardBrowserEnv?((ee,se)=>he=>(he=new URL(he,Ve.origin),ee.protocol===he.protocol&&ee.host===he.host&&(se||ee.port===he.port)))(new URL(Ve.origin),Ve.navigator&&/(msie|trident)/i.test(Ve.navigator.userAgent)):()=>!0,Gt=Ve.hasStandardBrowserEnv?{write(ee,se,he,pe,Ne,$e,qe){if(typeof document>"u")return;const ct=[`${ee}=${encodeURIComponent(se)}`];ke.isNumber(he)&&ct.push(`expires=${new Date(he).toUTCString()}`),ke.isString(pe)&&ct.push(`path=${pe}`),ke.isString(Ne)&&ct.push(`domain=${Ne}`),$e===!0&&ct.push("secure"),ke.isString(qe)&&ct.push(`SameSite=${qe}`),document.cookie=ct.join("; ")},read(ee){if(typeof document>"u")return null;const se=document.cookie.match(new RegExp("(?:^|; )"+ee+"=([^;]*)"));return se?decodeURIComponent(se[1]):null},remove(ee){this.write(ee,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function St(ee){return typeof ee!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(ee)}function qn(ee,se){return se?ee.replace(/\/?\/$/,"")+"/"+se.replace(/^\/+/,""):ee}function Er(ee,se,he){let pe=!St(se);return ee&&(pe||he==!1)?qn(ee,se):se}const Fr=ee=>ee instanceof bs?{...ee}:ee;function wn(ee,se){se=se||{};const he={};function pe(Kt,Ft,Rs,cn){return ke.isPlainObject(Kt)&&ke.isPlainObject(Ft)?ke.merge.call({caseless:cn},Kt,Ft):ke.isPlainObject(Ft)?ke.merge({},Ft):ke.isArray(Ft)?Ft.slice():Ft}function Ne(Kt,Ft,Rs,cn){if(ke.isUndefined(Ft)){if(!ke.isUndefined(Kt))return pe(void 0,Kt,Rs,cn)}else return pe(Kt,Ft,Rs,cn)}function $e(Kt,Ft){if(!ke.isUndefined(Ft))return pe(void 0,Ft)}function qe(Kt,Ft){if(ke.isUndefined(Ft)){if(!ke.isUndefined(Kt))return pe(void 0,Kt)}else return pe(void 0,Ft)}function ct(Kt,Ft,Rs){if(Rs in se)return pe(Kt,Ft);if(Rs in ee)return pe(void 0,Kt)}const ds={url:$e,method:$e,data:$e,baseURL:qe,transformRequest:qe,transformResponse:qe,paramsSerializer:qe,timeout:qe,timeoutMessage:qe,withCredentials:qe,withXSRFToken:qe,adapter:qe,responseType:qe,xsrfCookieName:qe,xsrfHeaderName:qe,onUploadProgress:qe,onDownloadProgress:qe,decompress:qe,maxContentLength:qe,maxBodyLength:qe,beforeRedirect:qe,transport:qe,httpAgent:qe,httpsAgent:qe,cancelToken:qe,socketPath:qe,responseEncoding:qe,validateStatus:ct,headers:(Kt,Ft,Rs)=>Ne(Fr(Kt),Fr(Ft),Rs,!0)};return ke.forEach(Object.keys({...ee,...se}),function(Ft){if(Ft==="__proto__"||Ft==="constructor"||Ft==="prototype")return;const Rs=ke.hasOwnProp(ds,Ft)?ds[Ft]:Ne,cn=Rs(ee[Ft],se[Ft],Ft);ke.isUndefined(cn)&&Rs!==ct||(he[Ft]=cn)}),he}var Js=ee=>{const se=wn({},ee);let{data:he,withXSRFToken:pe,xsrfHeaderName:Ne,xsrfCookieName:$e,headers:qe,auth:ct}=se;if(se.headers=qe=bs.from(qe),se.url=Ke(Er(se.baseURL,se.url,se.allowAbsoluteUrls),ee.params,ee.paramsSerializer),ct&&qe.set("Authorization","Basic "+btoa((ct.username||"")+":"+(ct.password?unescape(encodeURIComponent(ct.password)):""))),ke.isFormData(he)){if(Ve.hasStandardBrowserEnv||Ve.hasStandardBrowserWebWorkerEnv)qe.setContentType(void 0);else if(ke.isFunction(he.getHeaders)){const ds=he.getHeaders(),Kt=["content-type","content-length"];Object.entries(ds).forEach(([Ft,Rs])=>{Kt.includes(Ft.toLowerCase())&&qe.set(Ft,Rs)})}}if(Ve.hasStandardBrowserEnv&&(pe&&ke.isFunction(pe)&&(pe=pe(se)),pe||pe!==!1&&Ze(se.url))){const ds=Ne&&$e&&Gt.read($e);ds&&qe.set(Ne,ds)}return se},It=typeof XMLHttpRequest<"u"&&function(ee){return new Promise(function(he,pe){const Ne=Js(ee);let $e=Ne.data;const qe=bs.from(Ne.headers).normalize();let{responseType:ct,onUploadProgress:ds,onDownloadProgress:Kt}=Ne,Ft,Rs,cn,Kn,zt;function Es(){Kn&&Kn(),zt&&zt(),Ne.cancelToken&&Ne.cancelToken.unsubscribe(Ft),Ne.signal&&Ne.signal.removeEventListener("abort",Ft)}let os=new XMLHttpRequest;os.open(Ne.method.toUpperCase(),Ne.url,!0),os.timeout=Ne.timeout;function On(){if(!os)return;const zn=bs.from("getAllResponseHeaders"in os&&os.getAllResponseHeaders()),$r={data:!ct||ct==="text"||ct==="json"?os.responseText:os.response,status:os.status,statusText:os.statusText,headers:zn,config:ee,request:os};tn(function(dr){he(dr),Es()},function(dr){pe(dr),Es()},$r),os=null}"onloadend"in os?os.onloadend=On:os.onreadystatechange=function(){!os||os.readyState!==4||os.status===0&&!(os.responseURL&&os.responseURL.indexOf("file:")===0)||setTimeout(On)},os.onabort=function(){os&&(pe(new Bt("Request aborted",Bt.ECONNABORTED,ee,os)),os=null)},os.onerror=function(cr){const $r=cr&&cr.message?cr.message:"Network Error",Ha=new Bt($r,Bt.ERR_NETWORK,ee,os);Ha.event=cr||null,pe(Ha),os=null},os.ontimeout=function(){let cr=Ne.timeout?"timeout of "+Ne.timeout+"ms exceeded":"timeout exceeded";const $r=Ne.transitional||et;Ne.timeoutErrorMessage&&(cr=Ne.timeoutErrorMessage),pe(new Bt(cr,$r.clarifyTimeoutError?Bt.ETIMEDOUT:Bt.ECONNABORTED,ee,os)),os=null},$e===void 0&&qe.setContentType(null),"setRequestHeader"in os&&ke.forEach(qe.toJSON(),function(cr,$r){os.setRequestHeader($r,cr)}),ke.isUndefined(Ne.withCredentials)||(os.withCredentials=!!Ne.withCredentials),ct&&ct!=="json"&&(os.responseType=Ne.responseType),Kt&&([cn,zt]=gn(Kt,!0),os.addEventListener("progress",cn)),ds&&os.upload&&([Rs,Kn]=gn(ds),os.upload.addEventListener("progress",Rs),os.upload.addEventListener("loadend",Kn)),(Ne.cancelToken||Ne.signal)&&(Ft=zn=>{os&&(pe(!zn||zn.type?new js(null,ee,os):zn),os.abort(),os=null)},Ne.cancelToken&&Ne.cancelToken.subscribe(Ft),Ne.signal&&(Ne.signal.aborted?Ft():Ne.signal.addEventListener("abort",Ft)));const Cr=vn(Ne.url);if(Cr&&Ve.protocols.indexOf(Cr)===-1){pe(new Bt("Unsupported protocol "+Cr+":",Bt.ERR_BAD_REQUEST,ee));return}os.send($e||null)})},_r=(ee,se)=>{const{length:he}=ee=ee?ee.filter(Boolean):[];if(se||he){let pe=new AbortController,Ne;const $e=function(Kt){if(!Ne){Ne=!0,ct();const Ft=Kt instanceof Error?Kt:this.reason;pe.abort(Ft instanceof Bt?Ft:new js(Ft instanceof Error?Ft.message:Ft))}};let qe=se&&setTimeout(()=>{qe=null,$e(new Bt(`timeout of ${se}ms exceeded`,Bt.ETIMEDOUT))},se);const ct=()=>{ee&&(qe&&clearTimeout(qe),qe=null,ee.forEach(Kt=>{Kt.unsubscribe?Kt.unsubscribe($e):Kt.removeEventListener("abort",$e)}),ee=null)};ee.forEach(Kt=>Kt.addEventListener("abort",$e));const{signal:ds}=pe;return ds.unsubscribe=()=>ke.asap(ct),ds}};const ca=function*(ee,se){let he=ee.byteLength;if(he{const Ne=Ca(ee,se);let $e=0,qe,ct=ds=>{qe||(qe=!0,pe&&pe(ds))};return new ReadableStream({async pull(ds){try{const{done:Kt,value:Ft}=await Ne.next();if(Kt){ct(),ds.close();return}let Rs=Ft.byteLength;if(he){let cn=$e+=Rs;he(cn)}ds.enqueue(new Uint8Array(Ft))}catch(Kt){throw ct(Kt),Kt}},cancel(ds){return ct(ds),Ne.return()}},{highWaterMark:2})},kn=64*1024,{isFunction:Sn}=ke,sr=(({Request:ee,Response:se})=>({Request:ee,Response:se}))(ke.global),{ReadableStream:wr,TextEncoder:Sr}=ke.global,yn=(ee,...se)=>{try{return!!ee(...se)}catch{return!1}},Dn=ee=>{ee=ke.merge.call({skipUndefined:!0},sr,ee);const{fetch:se,Request:he,Response:pe}=ee,Ne=se?Sn(se):typeof fetch=="function",$e=Sn(he),qe=Sn(pe);if(!Ne)return!1;const ct=Ne&&Sn(wr),ds=Ne&&(typeof Sr=="function"?(zt=>Es=>zt.encode(Es))(new Sr):async zt=>new Uint8Array(await new he(zt).arrayBuffer())),Kt=$e&&ct&&yn(()=>{let zt=!1;const Es=new he(Ve.origin,{body:new wr,method:"POST",get duplex(){return zt=!0,"half"}}).headers.has("Content-Type");return zt&&!Es}),Ft=qe&&ct&&yn(()=>ke.isReadableStream(new pe("").body)),Rs={stream:Ft&&(zt=>zt.body)};Ne&&["text","arrayBuffer","blob","formData","stream"].forEach(zt=>{!Rs[zt]&&(Rs[zt]=(Es,os)=>{let On=Es&&Es[zt];if(On)return On.call(Es);throw new Bt(`Response type '${zt}' is not supported`,Bt.ERR_NOT_SUPPORT,os)})});const cn=async zt=>{if(zt==null)return 0;if(ke.isBlob(zt))return zt.size;if(ke.isSpecCompliantForm(zt))return(await new he(Ve.origin,{method:"POST",body:zt}).arrayBuffer()).byteLength;if(ke.isArrayBufferView(zt)||ke.isArrayBuffer(zt))return zt.byteLength;if(ke.isURLSearchParams(zt)&&(zt=zt+""),ke.isString(zt))return(await ds(zt)).byteLength},Kn=async(zt,Es)=>{const os=ke.toFiniteNumber(zt.getContentLength());return os??cn(Es)};return async zt=>{let{url:Es,method:os,data:On,signal:Cr,cancelToken:zn,timeout:cr,onDownloadProgress:$r,onUploadProgress:Ha,responseType:dr,headers:jo,withCredentials:Sl="same-origin",fetchOptions:pc}=Js(zt),No=se||fetch;dr=dr?(dr+"").toLowerCase():"text";let Cl=_r([Cr,zn&&zn.toAbortSignal()],cr),Vi=null;const Wa=Cl&&Cl.unsubscribe&&(()=>{Cl.unsubscribe()});let xc;try{if(Ha&&Kt&&os!=="get"&&os!=="head"&&(xc=await Kn(jo,On))!==0){let Ea=new he(Es,{method:"POST",body:On,duplex:"half"}),Ga;if(ke.isFormData(On)&&(Ga=Ea.headers.get("content-type"))&&jo.setContentType(Ga),Ea.body){const[kl,Wi]=Ye(xc,gn(qt(Ha)));On=Nr(Ea.body,kn,kl,Wi)}}ke.isString(Sl)||(Sl=Sl?"include":"omit");const rr=$e&&"credentials"in he.prototype,gc={...pc,signal:Cl,method:os.toUpperCase(),headers:jo.normalize().toJSON(),body:On,duplex:"half",credentials:rr?Sl:void 0};Vi=$e&&new he(Es,gc);let Ra=await($e?No(Vi,pc):No(Es,gc));const Al=Ft&&(dr==="stream"||dr==="response");if(Ft&&($r||Al&&Wa)){const Ea={};["status","statusText","headers"].forEach(wo=>{Ea[wo]=Ra[wo]});const Ga=ke.toFiniteNumber(Ra.headers.get("content-length")),[kl,Wi]=$r&&Ye(Ga,gn(qt($r),!0))||[];Ra=new pe(Nr(Ra.body,kn,kl,()=>{Wi&&Wi(),Wa&&Wa()}),Ea)}dr=dr||"text";let Hi=await Rs[ke.findKey(Rs,dr)||"text"](Ra,zt);return!Al&&Wa&&Wa(),await new Promise((Ea,Ga)=>{tn(Ea,Ga,{data:Hi,headers:bs.from(Ra.headers),status:Ra.status,statusText:Ra.statusText,config:zt,request:Vi})})}catch(rr){throw Wa&&Wa(),rr&&rr.name==="TypeError"&&/Load failed|fetch/i.test(rr.message)?Object.assign(new Bt("Network Error",Bt.ERR_NETWORK,zt,Vi,rr&&rr.response),{cause:rr.cause||rr}):Bt.from(rr,rr&&rr.code,zt,Vi,rr&&rr.response)}}},Aa=new Map,ka=ee=>{let se=ee&&ee.env||{};const{fetch:he,Request:pe,Response:Ne}=se,$e=[pe,Ne,he];let qe=$e.length,ct=qe,ds,Kt,Ft=Aa;for(;ct--;)ds=$e[ct],Kt=Ft.get(ds),Kt===void 0&&Ft.set(ds,Kt=ct?new Map:Dn(se)),Ft=Kt;return Kt};ka();const qi={http:_s,xhr:It,fetch:{get:ka}};ke.forEach(qi,(ee,se)=>{if(ee){try{Object.defineProperty(ee,"name",{value:se})}catch{}Object.defineProperty(ee,"adapterName",{value:se})}});const xi=ee=>`- ${ee}`,gi=ee=>ke.isFunction(ee)||ee===null||ee===!1;function bl(ee,se){ee=ke.isArray(ee)?ee:[ee];const{length:he}=ee;let pe,Ne;const $e={};for(let qe=0;qe`adapter ${ds} `+(Kt===!1?"is not supported by the environment":"is not available in the build"));let ct=he?qe.length>1?`since : `+qe.map(xi).join(` `):" "+xi(qe[0]):"as no adapter specified";throw new Bt("There is no suitable adapter to dispatch the request "+ct,"ERR_NOT_SUPPORT")}return Ne}var jl={getAdapter:bl,adapters:qi};function da(ee){if(ee.cancelToken&&ee.cancelToken.throwIfRequested(),ee.signal&&ee.signal.aborted)throw new js(null,ee)}function Da(ee){return da(ee),ee.headers=bs.from(ee.headers),ee.data=ns.call(ee,ee.transformRequest),["post","put","patch"].indexOf(ee.method)!==-1&&ee.headers.setContentType("application/x-www-form-urlencoded",!1),jl.getAdapter(ee.adapter||nn.adapter,ee)(ee).then(function(pe){return da(ee),pe.data=ns.call(ee,ee.transformResponse,pe),pe.headers=bs.from(pe.headers),pe},function(pe){return Ds(pe)||(da(ee),pe&&pe.response&&(pe.response.data=ns.call(ee,ee.transformResponse,pe.response),pe.response.headers=bs.from(pe.response.headers))),Promise.reject(pe)})}const ua="1.13.6",Va={};["object","boolean","number","function","string","symbol"].forEach((ee,se)=>{Va[ee]=function(pe){return typeof pe===ee||"a"+(se<1?"n ":" ")+ee}});const fc={};Va.transitional=function(se,he,pe){function Ne($e,qe){return"[Axios v"+ua+"] Transitional option '"+$e+"'"+qe+(pe?". "+pe:"")}return($e,qe,ct)=>{if(se===!1)throw new Bt(Ne(qe," has been removed"+(he?" in "+he:"")),Bt.ERR_DEPRECATED);return he&&!fc[qe]&&(fc[qe]=!0,console.warn(Ne(qe," has been deprecated since v"+he+" and will be removed in the near future"))),se?se($e,qe,ct):!0}},Va.spelling=function(se){return(he,pe)=>(console.warn(`${pe} is likely a misspelling of ${se}`),!0)};function Rd(ee,se,he){if(typeof ee!="object")throw new Bt("options must be an object",Bt.ERR_BAD_OPTION_VALUE);const pe=Object.keys(ee);let Ne=pe.length;for(;Ne-- >0;){const $e=pe[Ne],qe=se[$e];if(qe){const ct=ee[$e],ds=ct===void 0||qe(ct,$e,ee);if(ds!==!0)throw new Bt("option "+$e+" must be "+ds,Bt.ERR_BAD_OPTION_VALUE);continue}if(he!==!0)throw new Bt("Unknown option "+$e,Bt.ERR_BAD_OPTION)}}var vi={assertOptions:Rd,validators:Va};const nr=vi.validators;class yi{constructor(se){this.defaults=se||{},this.interceptors={request:new Ue,response:new Ue}}async request(se,he){try{return await this._request(se,he)}catch(pe){if(pe instanceof Error){let Ne={};Error.captureStackTrace?Error.captureStackTrace(Ne):Ne=new Error;const $e=Ne.stack?Ne.stack.replace(/^.+\n/,""):"";try{pe.stack?$e&&!String(pe.stack).endsWith($e.replace(/^.+\n.+\n/,""))&&(pe.stack+=` `+$e):pe.stack=$e}catch{}}throw pe}}_request(se,he){typeof se=="string"?(he=he||{},he.url=se):he=se||{},he=wn(this.defaults,he);const{transitional:pe,paramsSerializer:Ne,headers:$e}=he;pe!==void 0&&vi.assertOptions(pe,{silentJSONParsing:nr.transitional(nr.boolean),forcedJSONParsing:nr.transitional(nr.boolean),clarifyTimeoutError:nr.transitional(nr.boolean),legacyInterceptorReqResOrdering:nr.transitional(nr.boolean)},!1),Ne!=null&&(ke.isFunction(Ne)?he.paramsSerializer={serialize:Ne}:vi.assertOptions(Ne,{encode:nr.function,serialize:nr.function},!0)),he.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?he.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:he.allowAbsoluteUrls=!0),vi.assertOptions(he,{baseUrl:nr.spelling("baseURL"),withXsrfToken:nr.spelling("withXSRFToken")},!0),he.method=(he.method||this.defaults.method||"get").toLowerCase();let qe=$e&&ke.merge($e.common,$e[he.method]);$e&&ke.forEach(["delete","get","head","post","put","patch","common"],zt=>{delete $e[zt]}),he.headers=bs.concat(qe,$e);const ct=[];let ds=!0;this.interceptors.request.forEach(function(Es){if(typeof Es.runWhen=="function"&&Es.runWhen(he)===!1)return;ds=ds&&Es.synchronous;const os=he.transitional||et;os&&os.legacyInterceptorReqResOrdering?ct.unshift(Es.fulfilled,Es.rejected):ct.push(Es.fulfilled,Es.rejected)});const Kt=[];this.interceptors.response.forEach(function(Es){Kt.push(Es.fulfilled,Es.rejected)});let Ft,Rs=0,cn;if(!ds){const zt=[Da.bind(this),void 0];for(zt.unshift(...ct),zt.push(...Kt),cn=zt.length,Ft=Promise.resolve(he);Rs{if(!pe._listeners)return;let $e=pe._listeners.length;for(;$e-- >0;)pe._listeners[$e](Ne);pe._listeners=null}),this.promise.then=Ne=>{let $e;const qe=new Promise(ct=>{pe.subscribe(ct),$e=ct}).then(Ne);return qe.cancel=function(){pe.unsubscribe($e)},qe},se(function($e,qe,ct){pe.reason||(pe.reason=new js($e,qe,ct),he(pe.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(se){if(this.reason){se(this.reason);return}this._listeners?this._listeners.push(se):this._listeners=[se]}unsubscribe(se){if(!this._listeners)return;const he=this._listeners.indexOf(se);he!==-1&&this._listeners.splice(he,1)}toAbortSignal(){const se=new AbortController,he=pe=>{se.abort(pe)};return this.subscribe(he),se.signal.unsubscribe=()=>this.unsubscribe(he),se.signal}static source(){let se;return{token:new Br(function(Ne){se=Ne}),cancel:se}}}var yo=Br;function Ui(ee){return function(he){return ee.apply(null,he)}}function bo(ee){return ke.isObject(ee)&&ee.isAxiosError===!0}const bi={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(bi).forEach(([ee,se])=>{bi[se]=ee});var Nl=bi;function wl(ee){const se=new zi(ee),he=t(zi.prototype.request,se);return ke.extend(he,zi.prototype,se,{allOwnKeys:!0}),ke.extend(he,se,null,{allOwnKeys:!0}),he.create=function(Ne){return wl(wn(ee,Ne))},he}const rn=wl(nn);return rn.Axios=zi,rn.CanceledError=js,rn.CancelToken=yo,rn.isCancel=Ds,rn.VERSION=ua,rn.toFormData=ie,rn.AxiosError=Bt,rn.Cancel=rn.CanceledError,rn.all=function(se){return Promise.all(se)},rn.spread=Ui,rn.isAxiosError=bo,rn.mergeConfig=wn,rn.AxiosHeaders=bs,rn.formToJSON=ee=>is(ke.isHTMLForm(ee)?new FormData(ee):ee),rn.getAdapter=jl.getAdapter,rn.HttpStatusCode=Nl,rn.default=rn,og=rn,og}var zw;function q4(){if(zw)return pr;zw=1;function t($){return $&&typeof $=="object"&&"default"in $?$.default:$}Object.defineProperty(pr,"__esModule",{value:!0});var s=t($4()),n=function(){return(n=Object.assign||function($){for(var Z,Q=1,W=arguments.length;Q0&&U[U.length-1])&&(K[0]===6||K[0]===2)){z=0;continue}if(K[0]===3&&(!U||K[1]>U[0]&&K[1]=$&&Q<=Z},d=function($){return!!$&&(typeof $=="object"||typeof $=="function")&&typeof $.then=="function"},m={Accept:"application/json","Content-Type":"application/json"},f={timeout:0},p=null,h="CLIENT_ERROR",x="SERVER_ERROR",u="TIMEOUT_ERROR",N="CONNECTION_ERROR",v="NETWORK_ERROR",w="UNKNOWN_ERROR",j="CANCEL_ERROR",b=["ECONNABORTED"],C=["ENOTFOUND","ECONNREFUSED","ECONNRESET"],S=["ERR_BAD_REQUEST","ERR_BAD_RESPONSE"],D=function($){return o(200,299,$)},_=function($){return o(400,499,$)},A=function($){return o(500,599,$)},E=function($){return $.message==="Network Error"?v:s.isCancel($)?j:$.code?S.includes($.code)?q($.response.status):b.includes($.code)?u:C.includes($.code)?N:w:q($.response?$.response.status:null)},q=function($){return $?D($)?p:_($)?h:A($)?x:w:w},O=function($){var Z,Q=n(n({},m),$.headers||{});if($.axiosInstance)Z=$.axiosInstance;else{var W=n(n({},$),{headers:void 0}),U=n(n({},f),W);Z=s.create(U)}var M=[],z=[],T=[],F=[],I=[],K=function(ue,ye){return Q[ue]=ye,Z},G=function(ue){return function(ye,ce,je){return ce===void 0&&(ce={}),je===void 0&&(je={}),Y(n(n({},je),{url:ye,params:ce,method:ue}))}},V=function(ue){return function(ye,ce,je){return je===void 0&&(je={}),Y(n(n({},je),{url:ye,method:ue,data:ce}))}},Y=function(ue){return r(void 0,void 0,void 0,function(){var ye,ce,je,Me;return a(this,function(ut){switch(ut.label){case 0:if(ue.headers=n(n({},Q),ue.headers),z.length>0&&z.forEach(function(jt){return jt(ue)}),!(T.length>0))return[3,6];ye=0,ut.label=1;case 1:return ye0&&F.forEach(function(ot){return ot(ge)}),!(I.length>0))return[3,6];Je=0,at.label=1;case 1:return Je{const s=localStorage.getItem("token");s&&t.headers&&(t.headers.Authorization=`Bearer ${s}`)});Ie.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 eA(t,s){return function(){return t.apply(s,arguments)}}const{toString:V4}=Object.prototype,{getPrototypeOf:$y}=Object,{iterator:_f,toStringTag:tA}=Symbol,Tf=(t=>s=>{const n=V4.call(s);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),hi=t=>(t=t.toLowerCase(),s=>Tf(s)===t),Pf=t=>s=>typeof s===t,{isArray:pd}=Array,sd=Pf("undefined");function Mu(t){return t!==null&&!sd(t)&&t.constructor!==null&&!sd(t.constructor)&&ra(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const sA=hi("ArrayBuffer");function H4(t){let s;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?s=ArrayBuffer.isView(t):s=t&&t.buffer&&sA(t.buffer),s}const W4=Pf("string"),ra=Pf("function"),nA=Pf("number"),Fu=t=>t!==null&&typeof t=="object",G4=t=>t===!0||t===!1,Pm=t=>{if(Tf(t)!=="object")return!1;const s=$y(t);return(s===null||s===Object.prototype||Object.getPrototypeOf(s)===null)&&!(tA in t)&&!(_f in t)},K4=t=>{if(!Fu(t)||Mu(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Y4=hi("Date"),Z4=hi("File"),Q4=t=>!!(t&&typeof t.uri<"u"),X4=t=>t&&typeof t.getParts<"u",J4=hi("Blob"),eO=hi("FileList"),tO=t=>Fu(t)&&ra(t.pipe);function sO(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Uw=sO(),Vw=typeof Uw.FormData<"u"?Uw.FormData:void 0,nO=t=>{let s;return t&&(Vw&&t instanceof Vw||ra(t.append)&&((s=Tf(t))==="formdata"||s==="object"&&ra(t.toString)&&t.toString()==="[object FormData]"))},rO=hi("URLSearchParams"),[aO,iO,lO,oO]=["ReadableStream","Request","Response","Headers"].map(hi),cO=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Bu(t,s,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let r,a;if(typeof t!="object"&&(t=[t]),pd(t))for(r=0,a=t.length;r0;)if(a=n[r],s===a.toLowerCase())return a;return null}const Ho=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,aA=t=>!sd(t)&&t!==Ho;function Gv(){const{caseless:t,skipUndefined:s}=aA(this)&&this||{},n={},r=(a,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;const o=t&&rA(n,i)||i;Pm(n[o])&&Pm(a)?n[o]=Gv(n[o],a):Pm(a)?n[o]=Gv({},a):pd(a)?n[o]=a.slice():(!s||!sd(a))&&(n[o]=a)};for(let a=0,i=arguments.length;a(Bu(s,(a,i)=>{n&&ra(a)?Object.defineProperty(t,i,{value:eA(a,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,i,{value:a,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),uO=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),hO=(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)},mO=(t,s,n,r)=>{let a,i,o;const d={};if(s=s||{},t==null)return s;do{for(a=Object.getOwnPropertyNames(t),i=a.length;i-- >0;)o=a[i],(!r||r(o,t,s))&&!d[o]&&(s[o]=t[o],d[o]=!0);t=n!==!1&&$y(t)}while(t&&(!n||n(t,s))&&t!==Object.prototype);return s},fO=(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},pO=t=>{if(!t)return null;if(pd(t))return t;let s=t.length;if(!nA(s))return null;const n=new Array(s);for(;s-- >0;)n[s]=t[s];return n},xO=(t=>s=>t&&s instanceof t)(typeof Uint8Array<"u"&&$y(Uint8Array)),gO=(t,s)=>{const r=(t&&t[_f]).call(t);let a;for(;(a=r.next())&&!a.done;){const i=a.value;s.call(t,i[0],i[1])}},vO=(t,s)=>{let n;const r=[];for(;(n=t.exec(s))!==null;)r.push(n);return r},yO=hi("HTMLFormElement"),bO=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,a){return r.toUpperCase()+a}),Hw=(({hasOwnProperty:t})=>(s,n)=>t.call(s,n))(Object.prototype),jO=hi("RegExp"),iA=(t,s)=>{const n=Object.getOwnPropertyDescriptors(t),r={};Bu(n,(a,i)=>{let o;(o=s(a,i,t))!==!1&&(r[i]=o||a)}),Object.defineProperties(t,r)},NO=t=>{iA(t,(s,n)=>{if(ra(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=t[n];if(ra(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+"'")})}})},wO=(t,s)=>{const n={},r=a=>{a.forEach(i=>{n[i]=!0})};return pd(t)?r(t):r(String(t).split(s)),n},SO=()=>{},CO=(t,s)=>t!=null&&Number.isFinite(t=+t)?t:s;function AO(t){return!!(t&&ra(t.append)&&t[tA]==="FormData"&&t[_f])}const kO=t=>{const s=new Array(10),n=(r,a)=>{if(Fu(r)){if(s.indexOf(r)>=0)return;if(Mu(r))return r;if(!("toJSON"in r)){s[a]=r;const i=pd(r)?[]:{};return Bu(r,(o,d)=>{const m=n(o,a+1);!sd(m)&&(i[d]=m)}),s[a]=void 0,i}}return r};return n(t,0)},DO=hi("AsyncFunction"),RO=t=>t&&(Fu(t)||ra(t))&&ra(t.then)&&ra(t.catch),lA=((t,s)=>t?setImmediate:s?((n,r)=>(Ho.addEventListener("message",({source:a,data:i})=>{a===Ho&&i===n&&r.length&&r.shift()()},!1),a=>{r.push(a),Ho.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",ra(Ho.postMessage)),EO=typeof queueMicrotask<"u"?queueMicrotask.bind(Ho):typeof process<"u"&&process.nextTick||lA,_O=t=>t!=null&&ra(t[_f]),tt={isArray:pd,isArrayBuffer:sA,isBuffer:Mu,isFormData:nO,isArrayBufferView:H4,isString:W4,isNumber:nA,isBoolean:G4,isObject:Fu,isPlainObject:Pm,isEmptyObject:K4,isReadableStream:aO,isRequest:iO,isResponse:lO,isHeaders:oO,isUndefined:sd,isDate:Y4,isFile:Z4,isReactNativeBlob:Q4,isReactNative:X4,isBlob:J4,isRegExp:jO,isFunction:ra,isStream:tO,isURLSearchParams:rO,isTypedArray:xO,isFileList:eO,forEach:Bu,merge:Gv,extend:dO,trim:cO,stripBOM:uO,inherits:hO,toFlatObject:mO,kindOf:Tf,kindOfTest:hi,endsWith:fO,toArray:pO,forEachEntry:gO,matchAll:vO,isHTMLForm:yO,hasOwnProperty:Hw,hasOwnProp:Hw,reduceDescriptors:iA,freezeMethods:NO,toObjectSet:wO,toCamelCase:bO,noop:SO,toFiniteNumber:CO,findKey:rA,global:Ho,isContextDefined:aA,isSpecCompliantForm:AO,toJSONObject:kO,isAsyncFn:DO,isThenable:RO,setImmediate:lA,asap:EO,isIterable:_O};let zs=class oA extends Error{static from(s,n,r,a,i,o){const d=new oA(s.message,n||s.code,r,a,i);return d.cause=s,d.name=s.name,s.status!=null&&d.status==null&&(d.status=s.status),o&&Object.assign(d,o),d}constructor(s,n,r,a,i){super(s),Object.defineProperty(this,"message",{value:s,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),a&&(this.request=a),i&&(this.response=i,this.status=i.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:tt.toJSONObject(this.config),code:this.code,status:this.status}}};zs.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";zs.ERR_BAD_OPTION="ERR_BAD_OPTION";zs.ECONNABORTED="ECONNABORTED";zs.ETIMEDOUT="ETIMEDOUT";zs.ERR_NETWORK="ERR_NETWORK";zs.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";zs.ERR_DEPRECATED="ERR_DEPRECATED";zs.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";zs.ERR_BAD_REQUEST="ERR_BAD_REQUEST";zs.ERR_CANCELED="ERR_CANCELED";zs.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";zs.ERR_INVALID_URL="ERR_INVALID_URL";const TO=null;function Kv(t){return tt.isPlainObject(t)||tt.isArray(t)}function cA(t){return tt.endsWith(t,"[]")?t.slice(0,-2):t}function cg(t,s,n){return t?t.concat(s).map(function(a,i){return a=cA(a),!n&&i?"["+a+"]":a}).join(n?".":""):s}function PO(t){return tt.isArray(t)&&!t.some(Kv)}const OO=tt.toFlatObject(tt,{},null,function(s){return/^is[A-Z]/.test(s)});function Of(t,s,n){if(!tt.isObject(t))throw new TypeError("target must be an object");s=s||new FormData,n=tt.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,w){return!tt.isUndefined(w[v])});const r=n.metaTokens,a=n.visitor||p,i=n.dots,o=n.indexes,m=(n.Blob||typeof Blob<"u"&&Blob)&&tt.isSpecCompliantForm(s);if(!tt.isFunction(a))throw new TypeError("visitor must be a function");function f(N){if(N===null)return"";if(tt.isDate(N))return N.toISOString();if(tt.isBoolean(N))return N.toString();if(!m&&tt.isBlob(N))throw new zs("Blob is not supported. Use a Buffer instead.");return tt.isArrayBuffer(N)||tt.isTypedArray(N)?m&&typeof Blob=="function"?new Blob([N]):Buffer.from(N):N}function p(N,v,w){let j=N;if(tt.isReactNative(s)&&tt.isReactNativeBlob(N))return s.append(cg(w,v,i),f(N)),!1;if(N&&!w&&typeof N=="object"){if(tt.endsWith(v,"{}"))v=r?v:v.slice(0,-2),N=JSON.stringify(N);else if(tt.isArray(N)&&PO(N)||(tt.isFileList(N)||tt.endsWith(v,"[]"))&&(j=tt.toArray(N)))return v=cA(v),j.forEach(function(C,S){!(tt.isUndefined(C)||C===null)&&s.append(o===!0?cg([v],S,i):o===null?v:v+"[]",f(C))}),!1}return Kv(N)?!0:(s.append(cg(w,v,i),f(N)),!1)}const h=[],x=Object.assign(OO,{defaultVisitor:p,convertValue:f,isVisitable:Kv});function u(N,v){if(!tt.isUndefined(N)){if(h.indexOf(N)!==-1)throw Error("Circular reference detected in "+v.join("."));h.push(N),tt.forEach(N,function(j,b){(!(tt.isUndefined(j)||j===null)&&a.call(s,j,tt.isString(b)?b.trim():b,v,x))===!0&&u(j,v?v.concat(b):[b])}),h.pop()}}if(!tt.isObject(t))throw new TypeError("data must be an object");return u(t),s}function Ww(t){const s={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return s[r]})}function qy(t,s){this._pairs=[],t&&Of(t,this,s)}const dA=qy.prototype;dA.append=function(s,n){this._pairs.push([s,n])};dA.toString=function(s){const n=s?function(r){return s.call(this,r,Ww)}:Ww;return this._pairs.map(function(a){return n(a[0])+"="+n(a[1])},"").join("&")};function LO(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function uA(t,s,n){if(!s)return t;const r=n&&n.encode||LO,a=tt.isFunction(n)?{serialize:n}:n,i=a&&a.serialize;let o;if(i?o=i(s,a):o=tt.isURLSearchParams(s)?s.toString():new qy(s,a).toString(r),o){const d=t.indexOf("#");d!==-1&&(t=t.slice(0,d)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}class Gw{constructor(){this.handlers=[]}use(s,n,r){return this.handlers.push({fulfilled:s,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(s){this.handlers[s]&&(this.handlers[s]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(s){tt.forEach(this.handlers,function(r){r!==null&&s(r)})}}const zy={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},IO=typeof URLSearchParams<"u"?URLSearchParams:qy,MO=typeof FormData<"u"?FormData:null,FO=typeof Blob<"u"?Blob:null,BO={isBrowser:!0,classes:{URLSearchParams:IO,FormData:MO,Blob:FO},protocols:["http","https","file","blob","url","data"]},Uy=typeof window<"u"&&typeof document<"u",Yv=typeof navigator=="object"&&navigator||void 0,$O=Uy&&(!Yv||["ReactNative","NativeScript","NS"].indexOf(Yv.product)<0),qO=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",zO=Uy&&window.location.href||"http://localhost",UO=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Uy,hasStandardBrowserEnv:$O,hasStandardBrowserWebWorkerEnv:qO,navigator:Yv,origin:zO},Symbol.toStringTag,{value:"Module"})),Ir={...UO,...BO};function VO(t,s){return Of(t,new Ir.classes.URLSearchParams,{visitor:function(n,r,a,i){return Ir.isNode&&tt.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...s})}function HO(t){return tt.matchAll(/\w+|\[(\w*)]/g,t).map(s=>s[0]==="[]"?"":s[1]||s[0])}function WO(t){const s={},n=Object.keys(t);let r;const a=n.length;let i;for(r=0;r=n.length;return o=!o&&tt.isArray(a)?a.length:o,m?(tt.hasOwnProp(a,o)?a[o]=[a[o],r]:a[o]=r,!d):((!a[o]||!tt.isObject(a[o]))&&(a[o]=[]),s(n,r,a[o],i)&&tt.isArray(a[o])&&(a[o]=WO(a[o])),!d)}if(tt.isFormData(t)&&tt.isFunction(t.entries)){const n={};return tt.forEachEntry(t,(r,a)=>{s(HO(r),a,n,0)}),n}return null}function GO(t,s,n){if(tt.isString(t))try{return(s||JSON.parse)(t),tt.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}const $u={transitional:zy,adapter:["xhr","http","fetch"],transformRequest:[function(s,n){const r=n.getContentType()||"",a=r.indexOf("application/json")>-1,i=tt.isObject(s);if(i&&tt.isHTMLForm(s)&&(s=new FormData(s)),tt.isFormData(s))return a?JSON.stringify(hA(s)):s;if(tt.isArrayBuffer(s)||tt.isBuffer(s)||tt.isStream(s)||tt.isFile(s)||tt.isBlob(s)||tt.isReadableStream(s))return s;if(tt.isArrayBufferView(s))return s.buffer;if(tt.isURLSearchParams(s))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),s.toString();let d;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return VO(s,this.formSerializer).toString();if((d=tt.isFileList(s))||r.indexOf("multipart/form-data")>-1){const m=this.env&&this.env.FormData;return Of(d?{"files[]":s}:s,m&&new m,this.formSerializer)}}return i||a?(n.setContentType("application/json",!1),GO(s)):s}],transformResponse:[function(s){const n=this.transitional||$u.transitional,r=n&&n.forcedJSONParsing,a=this.responseType==="json";if(tt.isResponse(s)||tt.isReadableStream(s))return s;if(s&&tt.isString(s)&&(r&&!this.responseType||a)){const o=!(n&&n.silentJSONParsing)&&a;try{return JSON.parse(s,this.parseReviver)}catch(d){if(o)throw d.name==="SyntaxError"?zs.from(d,zs.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:Ir.classes.FormData,Blob:Ir.classes.Blob},validateStatus:function(s){return s>=200&&s<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};tt.forEach(["delete","get","head","post","put","patch"],t=>{$u.headers[t]={}});const KO=tt.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"]),YO=t=>{const s={};let n,r,a;return t&&t.split(` `).forEach(function(o){a=o.indexOf(":"),n=o.substring(0,a).trim().toLowerCase(),r=o.substring(a+1).trim(),!(!n||s[n]&&KO[n])&&(n==="set-cookie"?s[n]?s[n].push(r):s[n]=[r]:s[n]=s[n]?s[n]+", "+r:r)}),s},Kw=Symbol("internals");function Jd(t){return t&&String(t).trim().toLowerCase()}function Om(t){return t===!1||t==null?t:tt.isArray(t)?t.map(Om):String(t)}function ZO(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 QO=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function dg(t,s,n,r,a){if(tt.isFunction(r))return r.call(this,s,n);if(a&&(s=n),!!tt.isString(s)){if(tt.isString(r))return s.indexOf(r)!==-1;if(tt.isRegExp(r))return r.test(s)}}function XO(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(s,n,r)=>n.toUpperCase()+r)}function JO(t,s){const n=tt.toCamelCase(" "+s);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{value:function(a,i,o){return this[r].call(this,s,a,i,o)},configurable:!0})})}let aa=class{constructor(s){s&&this.set(s)}set(s,n,r){const a=this;function i(d,m,f){const p=Jd(m);if(!p)throw new Error("header name must be a non-empty string");const h=tt.findKey(a,p);(!h||a[h]===void 0||f===!0||f===void 0&&a[h]!==!1)&&(a[h||m]=Om(d))}const o=(d,m)=>tt.forEach(d,(f,p)=>i(f,p,m));if(tt.isPlainObject(s)||s instanceof this.constructor)o(s,n);else if(tt.isString(s)&&(s=s.trim())&&!QO(s))o(YO(s),n);else if(tt.isObject(s)&&tt.isIterable(s)){let d={},m,f;for(const p of s){if(!tt.isArray(p))throw TypeError("Object iterator must return a key-value pair");d[f=p[0]]=(m=d[f])?tt.isArray(m)?[...m,p[1]]:[m,p[1]]:p[1]}o(d,n)}else s!=null&&i(n,s,r);return this}get(s,n){if(s=Jd(s),s){const r=tt.findKey(this,s);if(r){const a=this[r];if(!n)return a;if(n===!0)return ZO(a);if(tt.isFunction(n))return n.call(this,a,r);if(tt.isRegExp(n))return n.exec(a);throw new TypeError("parser must be boolean|regexp|function")}}}has(s,n){if(s=Jd(s),s){const r=tt.findKey(this,s);return!!(r&&this[r]!==void 0&&(!n||dg(this,this[r],r,n)))}return!1}delete(s,n){const r=this;let a=!1;function i(o){if(o=Jd(o),o){const d=tt.findKey(r,o);d&&(!n||dg(r,r[d],d,n))&&(delete r[d],a=!0)}}return tt.isArray(s)?s.forEach(i):i(s),a}clear(s){const n=Object.keys(this);let r=n.length,a=!1;for(;r--;){const i=n[r];(!s||dg(this,this[i],i,s,!0))&&(delete this[i],a=!0)}return a}normalize(s){const n=this,r={};return tt.forEach(this,(a,i)=>{const o=tt.findKey(r,i);if(o){n[o]=Om(a),delete n[i];return}const d=s?XO(i):String(i).trim();d!==i&&delete n[i],n[d]=Om(a),r[d]=!0}),this}concat(...s){return this.constructor.concat(this,...s)}toJSON(s){const n=Object.create(null);return tt.forEach(this,(r,a)=>{r!=null&&r!==!1&&(n[a]=s&&tt.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([s,n])=>s+": "+n).join(` `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(s){return s instanceof this?s:new this(s)}static concat(s,...n){const r=new this(s);return n.forEach(a=>r.set(a)),r}static accessor(s){const r=(this[Kw]=this[Kw]={accessors:{}}).accessors,a=this.prototype;function i(o){const d=Jd(o);r[d]||(JO(a,o),r[d]=!0)}return tt.isArray(s)?s.forEach(i):i(s),this}};aa.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);tt.reduceDescriptors(aa.prototype,({value:t},s)=>{let n=s[0].toUpperCase()+s.slice(1);return{get:()=>t,set(r){this[n]=r}}});tt.freezeMethods(aa);function ug(t,s){const n=this||$u,r=s||n,a=aa.from(r.headers);let i=r.data;return tt.forEach(t,function(d){i=d.call(n,i,a.normalize(),s?s.status:void 0)}),a.normalize(),i}function mA(t){return!!(t&&t.__CANCEL__)}let qu=class extends zs{constructor(s,n,r){super(s??"canceled",zs.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}};function fA(t,s,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):s(new zs("Request failed with status code "+n.status,[zs.ERR_BAD_REQUEST,zs.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function e5(t){const s=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return s&&s[1]||""}function t5(t,s){t=t||10;const n=new Array(t),r=new Array(t);let a=0,i=0,o;return s=s!==void 0?s:1e3,function(m){const f=Date.now(),p=r[i];o||(o=f),n[a]=m,r[a]=f;let h=i,x=0;for(;h!==a;)x+=n[h++],h=h%t;if(a=(a+1)%t,a===i&&(i=(i+1)%t),f-o{n=p,a=null,i&&(clearTimeout(i),i=null),t(...f)};return[(...f)=>{const p=Date.now(),h=p-n;h>=r?o(f,p):(a=f,i||(i=setTimeout(()=>{i=null,o(a)},r-h)))},()=>a&&o(a)]}const sf=(t,s,n=3)=>{let r=0;const a=t5(50,250);return s5(i=>{const o=i.loaded,d=i.lengthComputable?i.total:void 0,m=o-r,f=a(m),p=o<=d;r=o;const h={loaded:o,total:d,progress:d?o/d:void 0,bytes:m,rate:f||void 0,estimated:f&&d&&p?(d-o)/f:void 0,event:i,lengthComputable:d!=null,[s?"download":"upload"]:!0};t(h)},n)},Yw=(t,s)=>{const n=t!=null;return[r=>s[0]({lengthComputable:n,total:t,loaded:r}),s[1]]},Zw=t=>(...s)=>tt.asap(()=>t(...s)),n5=Ir.hasStandardBrowserEnv?((t,s)=>n=>(n=new URL(n,Ir.origin),t.protocol===n.protocol&&t.host===n.host&&(s||t.port===n.port)))(new URL(Ir.origin),Ir.navigator&&/(msie|trident)/i.test(Ir.navigator.userAgent)):()=>!0,r5=Ir.hasStandardBrowserEnv?{write(t,s,n,r,a,i,o){if(typeof document>"u")return;const d=[`${t}=${encodeURIComponent(s)}`];tt.isNumber(n)&&d.push(`expires=${new Date(n).toUTCString()}`),tt.isString(r)&&d.push(`path=${r}`),tt.isString(a)&&d.push(`domain=${a}`),i===!0&&d.push("secure"),tt.isString(o)&&d.push(`SameSite=${o}`),document.cookie=d.join("; ")},read(t){if(typeof document>"u")return null;const s=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return s?decodeURIComponent(s[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function a5(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function i5(t,s){return s?t.replace(/\/?\/$/,"")+"/"+s.replace(/^\/+/,""):t}function pA(t,s,n){let r=!a5(s);return t&&(r||n==!1)?i5(t,s):s}const Qw=t=>t instanceof aa?{...t}:t;function tc(t,s){s=s||{};const n={};function r(f,p,h,x){return tt.isPlainObject(f)&&tt.isPlainObject(p)?tt.merge.call({caseless:x},f,p):tt.isPlainObject(p)?tt.merge({},p):tt.isArray(p)?p.slice():p}function a(f,p,h,x){if(tt.isUndefined(p)){if(!tt.isUndefined(f))return r(void 0,f,h,x)}else return r(f,p,h,x)}function i(f,p){if(!tt.isUndefined(p))return r(void 0,p)}function o(f,p){if(tt.isUndefined(p)){if(!tt.isUndefined(f))return r(void 0,f)}else return r(void 0,p)}function d(f,p,h){if(h in s)return r(f,p);if(h in t)return r(void 0,f)}const m={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:d,headers:(f,p,h)=>a(Qw(f),Qw(p),h,!0)};return tt.forEach(Object.keys({...t,...s}),function(p){if(p==="__proto__"||p==="constructor"||p==="prototype")return;const h=tt.hasOwnProp(m,p)?m[p]:a,x=h(t[p],s[p],p);tt.isUndefined(x)&&h!==d||(n[p]=x)}),n}const xA=t=>{const s=tc({},t);let{data:n,withXSRFToken:r,xsrfHeaderName:a,xsrfCookieName:i,headers:o,auth:d}=s;if(s.headers=o=aa.from(o),s.url=uA(pA(s.baseURL,s.url,s.allowAbsoluteUrls),t.params,t.paramsSerializer),d&&o.set("Authorization","Basic "+btoa((d.username||"")+":"+(d.password?unescape(encodeURIComponent(d.password)):""))),tt.isFormData(n)){if(Ir.hasStandardBrowserEnv||Ir.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(tt.isFunction(n.getHeaders)){const m=n.getHeaders(),f=["content-type","content-length"];Object.entries(m).forEach(([p,h])=>{f.includes(p.toLowerCase())&&o.set(p,h)})}}if(Ir.hasStandardBrowserEnv&&(r&&tt.isFunction(r)&&(r=r(s)),r||r!==!1&&n5(s.url))){const m=a&&i&&r5.read(i);m&&o.set(a,m)}return s},l5=typeof XMLHttpRequest<"u",o5=l5&&function(t){return new Promise(function(n,r){const a=xA(t);let i=a.data;const o=aa.from(a.headers).normalize();let{responseType:d,onUploadProgress:m,onDownloadProgress:f}=a,p,h,x,u,N;function v(){u&&u(),N&&N(),a.cancelToken&&a.cancelToken.unsubscribe(p),a.signal&&a.signal.removeEventListener("abort",p)}let w=new XMLHttpRequest;w.open(a.method.toUpperCase(),a.url,!0),w.timeout=a.timeout;function j(){if(!w)return;const C=aa.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),D={data:!d||d==="text"||d==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:C,config:t,request:w};fA(function(A){n(A),v()},function(A){r(A),v()},D),w=null}"onloadend"in w?w.onloadend=j:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(j)},w.onabort=function(){w&&(r(new zs("Request aborted",zs.ECONNABORTED,t,w)),w=null)},w.onerror=function(S){const D=S&&S.message?S.message:"Network Error",_=new zs(D,zs.ERR_NETWORK,t,w);_.event=S||null,r(_),w=null},w.ontimeout=function(){let S=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const D=a.transitional||zy;a.timeoutErrorMessage&&(S=a.timeoutErrorMessage),r(new zs(S,D.clarifyTimeoutError?zs.ETIMEDOUT:zs.ECONNABORTED,t,w)),w=null},i===void 0&&o.setContentType(null),"setRequestHeader"in w&&tt.forEach(o.toJSON(),function(S,D){w.setRequestHeader(D,S)}),tt.isUndefined(a.withCredentials)||(w.withCredentials=!!a.withCredentials),d&&d!=="json"&&(w.responseType=a.responseType),f&&([x,N]=sf(f,!0),w.addEventListener("progress",x)),m&&w.upload&&([h,u]=sf(m),w.upload.addEventListener("progress",h),w.upload.addEventListener("loadend",u)),(a.cancelToken||a.signal)&&(p=C=>{w&&(r(!C||C.type?new qu(null,t,w):C),w.abort(),w=null)},a.cancelToken&&a.cancelToken.subscribe(p),a.signal&&(a.signal.aborted?p():a.signal.addEventListener("abort",p)));const b=e5(a.url);if(b&&Ir.protocols.indexOf(b)===-1){r(new zs("Unsupported protocol "+b+":",zs.ERR_BAD_REQUEST,t));return}w.send(i||null)})},c5=(t,s)=>{const{length:n}=t=t?t.filter(Boolean):[];if(s||n){let r=new AbortController,a;const i=function(f){if(!a){a=!0,d();const p=f instanceof Error?f:this.reason;r.abort(p instanceof zs?p:new qu(p instanceof Error?p.message:p))}};let o=s&&setTimeout(()=>{o=null,i(new zs(`timeout of ${s}ms exceeded`,zs.ETIMEDOUT))},s);const d=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(f=>{f.unsubscribe?f.unsubscribe(i):f.removeEventListener("abort",i)}),t=null)};t.forEach(f=>f.addEventListener("abort",i));const{signal:m}=r;return m.unsubscribe=()=>tt.asap(d),m}},d5=function*(t,s){let n=t.byteLength;if(n{const a=u5(t,s);let i=0,o,d=m=>{o||(o=!0,r&&r(m))};return new ReadableStream({async pull(m){try{const{done:f,value:p}=await a.next();if(f){d(),m.close();return}let h=p.byteLength;if(n){let x=i+=h;n(x)}m.enqueue(new Uint8Array(p))}catch(f){throw d(f),f}},cancel(m){return d(m),a.return()}},{highWaterMark:2})},Jw=64*1024,{isFunction:om}=tt,m5=(({Request:t,Response:s})=>({Request:t,Response:s}))(tt.global),{ReadableStream:e1,TextEncoder:t1}=tt.global,s1=(t,...s)=>{try{return!!t(...s)}catch{return!1}},f5=t=>{t=tt.merge.call({skipUndefined:!0},m5,t);const{fetch:s,Request:n,Response:r}=t,a=s?om(s):typeof fetch=="function",i=om(n),o=om(r);if(!a)return!1;const d=a&&om(e1),m=a&&(typeof t1=="function"?(N=>v=>N.encode(v))(new t1):async N=>new Uint8Array(await new n(N).arrayBuffer())),f=i&&d&&s1(()=>{let N=!1;const v=new n(Ir.origin,{body:new e1,method:"POST",get duplex(){return N=!0,"half"}}).headers.has("Content-Type");return N&&!v}),p=o&&d&&s1(()=>tt.isReadableStream(new r("").body)),h={stream:p&&(N=>N.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(N=>{!h[N]&&(h[N]=(v,w)=>{let j=v&&v[N];if(j)return j.call(v);throw new zs(`Response type '${N}' is not supported`,zs.ERR_NOT_SUPPORT,w)})});const x=async N=>{if(N==null)return 0;if(tt.isBlob(N))return N.size;if(tt.isSpecCompliantForm(N))return(await new n(Ir.origin,{method:"POST",body:N}).arrayBuffer()).byteLength;if(tt.isArrayBufferView(N)||tt.isArrayBuffer(N))return N.byteLength;if(tt.isURLSearchParams(N)&&(N=N+""),tt.isString(N))return(await m(N)).byteLength},u=async(N,v)=>{const w=tt.toFiniteNumber(N.getContentLength());return w??x(v)};return async N=>{let{url:v,method:w,data:j,signal:b,cancelToken:C,timeout:S,onDownloadProgress:D,onUploadProgress:_,responseType:A,headers:E,withCredentials:q="same-origin",fetchOptions:O}=xA(N),R=s||fetch;A=A?(A+"").toLowerCase():"text";let P=c5([b,C&&C.toAbortSignal()],S),L=null;const $=P&&P.unsubscribe&&(()=>{P.unsubscribe()});let Z;try{if(_&&f&&w!=="get"&&w!=="head"&&(Z=await u(E,j))!==0){let T=new n(v,{method:"POST",body:j,duplex:"half"}),F;if(tt.isFormData(j)&&(F=T.headers.get("content-type"))&&E.setContentType(F),T.body){const[I,K]=Yw(Z,sf(Zw(_)));j=Xw(T.body,Jw,I,K)}}tt.isString(q)||(q=q?"include":"omit");const Q=i&&"credentials"in n.prototype,W={...O,signal:P,method:w.toUpperCase(),headers:E.normalize().toJSON(),body:j,duplex:"half",credentials:Q?q:void 0};L=i&&new n(v,W);let U=await(i?R(L,O):R(v,W));const M=p&&(A==="stream"||A==="response");if(p&&(D||M&&$)){const T={};["status","statusText","headers"].forEach(G=>{T[G]=U[G]});const F=tt.toFiniteNumber(U.headers.get("content-length")),[I,K]=D&&Yw(F,sf(Zw(D),!0))||[];U=new r(Xw(U.body,Jw,I,()=>{K&&K(),$&&$()}),T)}A=A||"text";let z=await h[tt.findKey(h,A)||"text"](U,N);return!M&&$&&$(),await new Promise((T,F)=>{fA(T,F,{data:z,headers:aa.from(U.headers),status:U.status,statusText:U.statusText,config:N,request:L})})}catch(Q){throw $&&$(),Q&&Q.name==="TypeError"&&/Load failed|fetch/i.test(Q.message)?Object.assign(new zs("Network Error",zs.ERR_NETWORK,N,L,Q&&Q.response),{cause:Q.cause||Q}):zs.from(Q,Q&&Q.code,N,L,Q&&Q.response)}}},p5=new Map,gA=t=>{let s=t&&t.env||{};const{fetch:n,Request:r,Response:a}=s,i=[r,a,n];let o=i.length,d=o,m,f,p=p5;for(;d--;)m=i[d],f=p.get(m),f===void 0&&p.set(m,f=d?new Map:f5(s)),p=f;return f};gA();const Vy={http:TO,xhr:o5,fetch:{get:gA}};tt.forEach(Vy,(t,s)=>{if(t){try{Object.defineProperty(t,"name",{value:s})}catch{}Object.defineProperty(t,"adapterName",{value:s})}});const n1=t=>`- ${t}`,x5=t=>tt.isFunction(t)||t===null||t===!1;function g5(t,s){t=tt.isArray(t)?t:[t];const{length:n}=t;let r,a;const i={};for(let o=0;o`adapter ${m} `+(f===!1?"is not supported by the environment":"is not available in the build"));let d=n?o.length>1?`since : `+o.map(n1).join(` `):" "+n1(o[0]):"as no adapter specified";throw new zs("There is no suitable adapter to dispatch the request "+d,"ERR_NOT_SUPPORT")}return a}const vA={getAdapter:g5,adapters:Vy};function hg(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new qu(null,t)}function r1(t){return hg(t),t.headers=aa.from(t.headers),t.data=ug.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),vA.getAdapter(t.adapter||$u.adapter,t)(t).then(function(r){return hg(t),r.data=ug.call(t,t.transformResponse,r),r.headers=aa.from(r.headers),r},function(r){return mA(r)||(hg(t),r&&r.response&&(r.response.data=ug.call(t,t.transformResponse,r.response),r.response.headers=aa.from(r.response.headers))),Promise.reject(r)})}const yA="1.13.6",Lf={};["object","boolean","number","function","string","symbol"].forEach((t,s)=>{Lf[t]=function(r){return typeof r===t||"a"+(s<1?"n ":" ")+t}});const a1={};Lf.transitional=function(s,n,r){function a(i,o){return"[Axios v"+yA+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,d)=>{if(s===!1)throw new zs(a(o," has been removed"+(n?" in "+n:"")),zs.ERR_DEPRECATED);return n&&!a1[o]&&(a1[o]=!0,console.warn(a(o," has been deprecated since v"+n+" and will be removed in the near future"))),s?s(i,o,d):!0}};Lf.spelling=function(s){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${s}`),!0)};function v5(t,s,n){if(typeof t!="object")throw new zs("options must be an object",zs.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let a=r.length;for(;a-- >0;){const i=r[a],o=s[i];if(o){const d=t[i],m=d===void 0||o(d,i,t);if(m!==!0)throw new zs("option "+i+" must be "+m,zs.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new zs("Unknown option "+i,zs.ERR_BAD_OPTION)}}const Lm={assertOptions:v5,validators:Lf},Ma=Lm.validators;let Zo=class{constructor(s){this.defaults=s||{},this.interceptors={request:new Gw,response:new Gw}}async request(s,n){try{return await this._request(s,n)}catch(r){if(r instanceof Error){let a={};Error.captureStackTrace?Error.captureStackTrace(a):a=new Error;const i=a.stack?a.stack.replace(/^.+\n/,""):"";try{r.stack?i&&!String(r.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(r.stack+=` `+i):r.stack=i}catch{}}throw r}}_request(s,n){typeof s=="string"?(n=n||{},n.url=s):n=s||{},n=tc(this.defaults,n);const{transitional:r,paramsSerializer:a,headers:i}=n;r!==void 0&&Lm.assertOptions(r,{silentJSONParsing:Ma.transitional(Ma.boolean),forcedJSONParsing:Ma.transitional(Ma.boolean),clarifyTimeoutError:Ma.transitional(Ma.boolean),legacyInterceptorReqResOrdering:Ma.transitional(Ma.boolean)},!1),a!=null&&(tt.isFunction(a)?n.paramsSerializer={serialize:a}:Lm.assertOptions(a,{encode:Ma.function,serialize:Ma.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Lm.assertOptions(n,{baseUrl:Ma.spelling("baseURL"),withXsrfToken:Ma.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=i&&tt.merge(i.common,i[n.method]);i&&tt.forEach(["delete","get","head","post","put","patch","common"],N=>{delete i[N]}),n.headers=aa.concat(o,i);const d=[];let m=!0;this.interceptors.request.forEach(function(v){if(typeof v.runWhen=="function"&&v.runWhen(n)===!1)return;m=m&&v.synchronous;const w=n.transitional||zy;w&&w.legacyInterceptorReqResOrdering?d.unshift(v.fulfilled,v.rejected):d.push(v.fulfilled,v.rejected)});const f=[];this.interceptors.response.forEach(function(v){f.push(v.fulfilled,v.rejected)});let p,h=0,x;if(!m){const N=[r1.bind(this),void 0];for(N.unshift(...d),N.push(...f),x=N.length,p=Promise.resolve(n);h{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](a);r._listeners=null}),this.promise.then=a=>{let i;const o=new Promise(d=>{r.subscribe(d),i=d}).then(a);return o.cancel=function(){r.unsubscribe(i)},o},s(function(i,o,d){r.reason||(r.reason=new qu(i,o,d),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(s){if(this.reason){s(this.reason);return}this._listeners?this._listeners.push(s):this._listeners=[s]}unsubscribe(s){if(!this._listeners)return;const n=this._listeners.indexOf(s);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const s=new AbortController,n=r=>{s.abort(r)};return this.subscribe(n),s.signal.unsubscribe=()=>this.unsubscribe(n),s.signal}static source(){let s;return{token:new bA(function(a){s=a}),cancel:s}}};function b5(t){return function(n){return t.apply(null,n)}}function j5(t){return tt.isObject(t)&&t.isAxiosError===!0}const Zv={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Zv).forEach(([t,s])=>{Zv[s]=t});function jA(t){const s=new Zo(t),n=eA(Zo.prototype.request,s);return tt.extend(n,Zo.prototype,s,{allOwnKeys:!0}),tt.extend(n,s,null,{allOwnKeys:!0}),n.create=function(a){return jA(tc(t,a))},n}const Wn=jA($u);Wn.Axios=Zo;Wn.CanceledError=qu;Wn.CancelToken=y5;Wn.isCancel=mA;Wn.VERSION=yA;Wn.toFormData=Of;Wn.AxiosError=zs;Wn.Cancel=Wn.CanceledError;Wn.all=function(s){return Promise.all(s)};Wn.spread=b5;Wn.isAxiosError=j5;Wn.mergeConfig=tc;Wn.AxiosHeaders=aa;Wn.formToJSON=t=>hA(tt.isHTMLForm(t)?new FormData(t):t);Wn.getAdapter=vA.getAdapter;Wn.HttpStatusCode=Zv;Wn.default=Wn;const{Axios:tY,AxiosError:sY,CanceledError:nY,isCancel:rY,CancelToken:aY,VERSION:iY,all:lY,Cancel:oY,isAxiosError:cY,spread:dY,toFormData:uY,AxiosHeaders:hY,HttpStatusCode:mY,formToJSON:fY,getAdapter:pY,mergeConfig:xY}=Wn,i1="https://dealeronboarding-uat.royalenfield.com/api",Re={login:t=>Ie.post("/auth/login",t),logout:()=>Ie.post("/auth/logout"),getCurrentUser:()=>Ie.get("/auth/me"),getRoles:()=>Ie.get("/admin/roles"),createRole:t=>Ie.post("/admin/roles",t),getPermissions:()=>Ie.get("/admin/permissions"),updateRole:(t,s)=>Ie.put(`/admin/roles/${t}`,s),getZones:()=>Ie.get("/master/zones"),createZone:t=>Ie.post("/master/zones",t),updateZone:(t,s)=>Ie.put(`/master/zones/${t}`,s),createRegion:t=>Ie.post("/master/regions",t),updateRegion:(t,s)=>Ie.put(`/master/regions/${t}`,s),getRegions:()=>Ie.get("/master/regions"),getOutlets:()=>Ie.get("/outlets"),getOutletByCode:t=>Ie.get(`/master/outlets/code/${t}`),getStates:t=>Ie.get("/master/states",typeof t=="string"?{zoneId:t}:t),getDistricts:t=>Ie.get("/master/districts",typeof t=="string"?{stateId:t}:t),getAreas:t=>Ie.get("/master/areas",t),updateArea:(t,s)=>Ie.put(`/master/areas/${t}`,s),createArea:t=>Ie.post("/master/areas",t),getAreaManagers:()=>Ie.get("/master/area-managers"),getASMs:()=>Ie.get("/master/asms"),getZonalManagers:()=>Ie.get("/master/zonal-managers"),saveZonalManager:t=>Ie.post("/master/zonal-managers",t),getDDLeads:()=>Ie.get("/master/dd-leads"),saveDDLead:t=>Ie.post("/master/dd-leads",t),getManagersByRole:t=>Ie.get("/master/managers",t),submitApplication:t=>Ie.post("/onboarding/apply",t),exportApplicationResponses:t=>Ie.get("/onboarding/applications/export-responses",t),getApplications:t=>Ie.get("/onboarding/applications",t),shortlistApplications:t=>Ie.post("/onboarding/applications/shortlist",t),sendBulkReminders:t=>Ie.post("/onboarding/applications/reminders",t),getApplicationById:t=>Ie.get(`/onboarding/applications/${t}`),updateApplication:(t,s)=>Ie.put(`/onboarding/applications/${t}`,s),getLatestQuestionnaire:()=>Ie.get("/questionnaire/latest"),createQuestionnaireVersion:t=>Ie.post("/questionnaire/version",t),submitQuestionnaireResponse:t=>Ie.post("/questionnaire/response",t),getAllQuestionnaires:()=>Ie.get("/onboarding/questionnaires"),getQuestionnaireById:t=>Ie.get(`/onboarding/questionnaires/${t}`),assignArchitectureTeam:(t,s)=>Ie.post(`/onboarding/applications/${t}/assign-architecture`,{assignedTo:s}),updateArchitectureStatus:(t,s,n)=>Ie.post(`/onboarding/applications/${t}/architecture-status`,{status:s,remarks:n}),generateDealerCodes:t=>Ie.post(`/onboarding/applications/${t}/generate-codes`),updateApplicationStatus:(t,s)=>Ie.put(`/onboarding/applications/${t}/status`,s),convertToOpportunity:(t,s)=>Ie.post(`/onboarding/applications/${t}/convert-to-opportunity`,s),bulkConvertToOpportunity:t=>Ie.post("/onboarding/applications/bulk-convert-to-opportunity",t),retriggerEvaluators:t=>Ie.post(`/onboarding/applications/${t}/retrigger-evaluators`),getSecurityDeposit:t=>Ie.get(`/loa/security-deposit/${t}`),updateSecurityDeposit:t=>Ie.post("/loa/security-deposit",t),uploadDocument:(t,s)=>Ie.post(`/onboarding/applications/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),getDocuments:t=>Ie.get(`/onboarding/applications/${t}/documents`),getDocumentConfigMetadata:()=>Ie.get("/onboarding/document-configs/metadata"),getDocumentConfigs:t=>Ie.get("/onboarding/document-configs",t),createDocumentConfig:t=>Ie.post("/onboarding/document-configs",t),updateDocumentConfig:(t,s)=>Ie.put(`/onboarding/document-configs/${t}`,s),deleteDocumentConfig:t=>Ie.delete(`/onboarding/document-configs/${t}`),getPublicQuestionnaire:t=>Wn.get(`${i1}/questionnaire/public/${t}`),submitPublicResponse:t=>Wn.post(`${i1}/questionnaire/public/submit`,t),getAiSummary:t=>Ie.get(`/assessment/ai-summary/${t}`),scheduleInterview:t=>Ie.post("/assessment/interviews",t),updateInterview:(t,s)=>Ie.put(`/assessment/interviews/${t}`,s),submitEvaluation:(t,s)=>Ie.post(`/assessment/interviews/${t}/evaluation`,s),submitKTMatrix:t=>Ie.post("/assessment/kt-matrix",t),submitLevel2Feedback:t=>Ie.post("/assessment/level2-feedback",t),getInterviews:t=>Ie.get(`/assessment/interviews/${t}`),updateRecommendation:t=>Ie.post("/assessment/recommendation",t),updateInterviewDecision:t=>Ie.post("/assessment/decision",t),submitStageDecision:t=>Ie.post("/assessment/stage-decision",t),getInterviewApprovalStatus:t=>Ie.get(`/assessment/interviews/${t}/approval-status`),getApprovalPolicies:()=>Ie.get("/assessment/approval-policies"),upsertApprovalPolicy:(t,s)=>Ie.put(`/assessment/approval-policies/${t}`,s),getWorknotes:(t,s)=>Ie.get("/collaboration/worknotes",{requestId:t,requestType:s}),addWorknote:t=>Ie.post("/collaboration/worknotes",t),addParticipant:t=>Ie.post("/collaboration/participants",t),removeParticipant:t=>Ie.delete(`/collaboration/participants/${t}`),getUsers:t=>Ie.get("/admin/users",t),createUser:t=>Ie.post("/admin/users",t),updateUser:(t,s)=>Ie.put(`/admin/users/${t}`,s),updateUserStatus:(t,s)=>Ie.patch(`/admin/users/${t}/status`,s),deleteUser:t=>Ie.delete(`/admin/users/${t}`),getDealers:t=>Ie.get("/dealer",t),createDealer:t=>Ie.post("/dealer",t),getDealerById:t=>Ie.get(`/dealer/${t}`),updateDealer:(t,s)=>Ie.put(`/dealer/${t}`,s),getDealerDashboard:()=>Ie.get("/dealer/dashboard"),getDealerBankDetails:t=>Ie.get(`/dealer/${t}/bank-details`),saveBankDetail:(t,s)=>Ie.post(`/dealer/${t}/bank-details`,s),deleteBankDetail:t=>Ie.delete(`/dealer/bank-details/${t}`),getEmailTemplates:()=>Ie.get("/admin/email-templates"),getEmailTemplate:t=>Ie.get(`/admin/email-templates/${t}`),createEmailTemplate:t=>Ie.post("/admin/email-templates",t),updateEmailTemplate:(t,s)=>Ie.put(`/admin/email-templates/${t}`,s),deleteEmailTemplate:t=>Ie.delete(`/admin/email-templates/${t}`),previewEmailTemplate:t=>Ie.post("/admin/email-templates/preview",t),getAuditLogs:(t,s,n=1,r=50)=>Ie.get("/audit/logs",{entityType:t,entityId:s,page:n,limit:r}),getAuditSummary:(t,s)=>Ie.get("/audit/summary",{entityType:t,entityId:s}),sendOtp:t=>Ie.post("/prospective-login/send-otp",{phone:t}),verifyOtp:(t,s)=>Ie.post("/prospective-login/verify-otp",{phone:t,otp:s}),getResignationById:t=>Ie.get(`/resignation/${t}`),uploadResignationDocument:(t,s)=>Ie.post(`/resignation/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),updateClearance:(t,s)=>Ie.put(`/resignation/${t}/clearance`,s,{headers:s instanceof FormData?{"Content-Type":"multipart/form-data"}:{}}),updateResignationStatus:(t,s)=>Ie.post(`/resignation/${t}/status`,s),getTerminationById:t=>Ie.get(`/termination/${t}`),uploadTerminationDocument:(t,s)=>Ie.post(`/termination/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),updateTerminationStatus:(t,s)=>Ie.post(`/termination/${t}/status`,s),issueSCN:(t,s)=>Ie.post(`/termination/${t}/scn`,s),uploadSCNResponse:(t,s)=>Ie.post(`/termination/${t}/scn-response`,s,{headers:{"Content-Type":"multipart/form-data"}}),finalizeTermination:(t,s)=>Ie.post(`/termination/${t}/finalize`,s),getResignations:t=>Ie.get("/resignation",t),createResignation:t=>Ie.post("/resignation",t),approveResignation:(t,s)=>Ie.post(`/resignation/${t}/approve`,s),rejectResignation:(t,s)=>Ie.post(`/resignation/${t}/reject`,s),withdrawResignation:(t,s)=>Ie.post(`/resignation/${t}/withdraw`,{reason:s}),getTerminations:t=>Ie.get("/termination",t),createTermination:t=>Ie.post("/termination",t),updateTermination:(t,s)=>Ie.post(`/termination/${t}/status`,s),getOnboardingPayments:()=>Ie.get("/settlement/onboarding"),updatePayment:(t,s)=>Ie.put(`/settlement/payments/${t}`,s),getFnFSettlements:()=>Ie.get("/settlement/fnf"),getFnFSettlementById:t=>Ie.get(`/settlement/fnf/${t}`),calculateFnF:t=>Ie.post(`/settlement/fnf/${t}/calculate`),updateFnF:(t,s)=>Ie.put(`/settlement/fnf/${t}`,s),uploadFnFDocument:(t,s)=>Ie.post(`/settlement/fnf/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),getSettlementDepartments:()=>Ie.get("/settlement/departments"),addLineItem:(t,s)=>Ie.post(`/settlement/fnf/${t}/line-items`,s),updateFnFClearance:(t,s,n)=>Ie.put(`/settlement/fnf/${t}/clearances/${s}`,n,{headers:{"Content-Type":"multipart/form-data"}}),updateLineItem:(t,s)=>Ie.put(`/settlement/fnf/line-items/${t}`,s),deleteLineItem:t=>Ie.delete(`/settlement/fnf/line-items/${t}`),getRelocationRequests:t=>Ie.get("/relocation",t),getRelocationRequestById:t=>Ie.get(`/relocation/${t}`),createRelocationRequest:t=>Ie.post("/relocation",t),updateRelocationRequest:(t,s,n)=>Ie.post(`/relocation/${t}/action`,{action:s,...n}),uploadRelocationDocument:(t,s)=>Ie.post(`/relocation/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),verifyRelocationDocument:(t,s)=>Ie.post(`/relocation/${t}/documents/${s}/verify`),rejectRelocationDocument:(t,s,n)=>Ie.post(`/relocation/${t}/documents/${s}/reject`,n||{}),getConstitutionalChanges:t=>Ie.get("/constitutional-change",t),getConstitutionalChangeMeta:()=>Ie.get("/constitutional-change/meta"),getConstitutionalChangeById:t=>Ie.get(`/constitutional-change/${t}`),createConstitutionalChange:t=>Ie.post("/constitutional-change",t),updateConstitutionalChange:(t,s,n)=>Ie.post(`/constitutional-change/${t}/action`,{action:s,...n}),uploadConstitutionalDocuments:(t,s)=>Ie.post(`/constitutional-change/${t}/documents`,{documents:s}),verifyConstitutionalDocument:(t,s)=>Ie.post(`/constitutional-change/${t}/documents/${s}/verify`),rejectConstitutionalDocument:(t,s,n)=>Ie.post(`/constitutional-change/${t}/documents/${s}/reject`,n||{}),getSlaConfigs:()=>Ie.get("/master/sla-configs"),saveSlaConfig:t=>Ie.post("/master/sla-configs",t),initializeDefaultSlas:()=>Ie.post("/master/sla-configs/initialize"),getSlaOperationsDashboard:t=>Ie.get("/sla/operations/dashboard",t),postSlaBatchStatus:t=>Ie.post("/sla/status/batch",t),getQuestionnaireReminderSettings:()=>Ie.get("/sla/settings/questionnaire-reminder"),updateQuestionnaireReminderSettings:t=>Ie.put("/sla/settings/questionnaire-reminder",t),getInterviewConfigs:t=>Ie.get("/master/interview-configs",t),getInterviewConfigById:t=>Ie.get(`/master/interview-configs/${t}`),getInterviewConfigByType:t=>Ie.get(`/master/interview-configs/active/${t}`),createInterviewConfig:t=>Ie.post("/master/interview-configs",t),updateInterviewConfig:(t,s)=>Ie.put(`/master/interview-configs/${t}`,s),deleteInterviewConfig:t=>Ie.delete(`/master/interview-configs/${t}`),initializeDefaultInterviewConfigs:()=>Ie.post("/master/interview-configs/initialize"),getSystemConfigs:t=>Ie.get("/master/system-configs",t),saveSystemConfig:t=>Ie.post("/master/system-configs",t),getDealerAsmMappings:()=>Ie.get("/master/dealer-asm-mappings"),saveDealerAsmMapping:t=>Ie.post("/master/dealer-asm-mappings",t),getEorChecklistForApplication:t=>Ie.get(`/eor/application/${t}`),getEorChecklistForRelocation:t=>Ie.get(`/eor/relocation/${t}`),updateEorChecklistItem:(t,s)=>Ie.post(`/eor/item/${t}`,s),submitEorAudit:(t,s)=>Ie.post(`/eor/audit/${t}`,s),submitFddReport:t=>Ie.post("/fdd/report",t),getFddAssignment:t=>Ie.get(`/fdd/${t}`),assignFddAgency:t=>Ie.post("/fdd/assign",t),flagNonResponsive:t=>Ie.post("/flag",t),getSystemAuditLogs:t=>Ie.get("/audit/system-logs",t),getSystemAuditSummary:()=>Ie.get("/audit/system-summary")},cm=Object.freeze(Object.defineProperty({__proto__:null,API:Re,default:Re},Symbol.toStringTag,{value:"Module"})),N5={user:null,token:localStorage.getItem("token"),isAuthenticated:!1,loading:!0,error:null},Im=D4("auth/initializeAuth",async(t,{rejectWithValue:s})=>{const n=localStorage.getItem("token");if(!n)return s("No token found");try{const r=await Re.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")}}),NA=J2({name:"auth",initialState:N5,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(Im.pending,s=>{s.loading=!0}).addCase(Im.fulfilled,(s,n)=>{s.user=n.payload.user,s.token=n.payload.token,s.isAuthenticated=!0,s.loading=!1}).addCase(Im.rejected,s=>{s.user=null,s.token=null,s.isAuthenticated=!1,s.loading=!1,localStorage.removeItem("token")})}}),{setCredentials:wA,logout:SA,setLoading:gY}=NA.actions,w5=NA.reducer,S5={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},CA=J2({name:"master",initialState:S5,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:AA,setZones:vY,setRegionalOffices:yY,setAsms:bY,setZonalManagerMappings:jY,setUsers:NY,setLoading:l1,setError:C5,setAreasData:A5,setAreasLoading:o1,setDdLeads:wY}=CA.actions,k5=CA.reducer,D5=y4({reducer:{auth:w5,master:k5}});var zu=Oy();const Hy=Nf(zu);/** * @remix-run/router v1.23.2 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Su(){return Su=Object.assign?Object.assign.bind():function(t){for(var s=1;s"u")throw new Error(s)}function Wy(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function E5(){return Math.random().toString(36).substr(2,8)}function d1(t,s){return{usr:t.state,key:t.key,idx:s}}function Qv(t,s,n,r){return n===void 0&&(n=null),Su({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?xd(s):s,{state:n,key:s&&s.key||r||E5()})}function kA(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 xd(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 _5(t,s,n,r){r===void 0&&(r={});let{window:a=document.defaultView,v5Compat:i=!1}=r,o=a.history,d=Kl.Pop,m=null,f=p();f==null&&(f=0,o.replaceState(Su({},o.state,{idx:f}),""));function p(){return(o.state||{idx:null}).idx}function h(){d=Kl.Pop;let w=p(),j=w==null?null:w-f;f=w,m&&m({action:d,location:v.location,delta:j})}function x(w,j){d=Kl.Push;let b=Qv(v.location,w,j);f=p()+1;let C=d1(b,f),S=v.createHref(b);try{o.pushState(C,"",S)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;a.location.assign(S)}i&&m&&m({action:d,location:v.location,delta:1})}function u(w,j){d=Kl.Replace;let b=Qv(v.location,w,j);f=p();let C=d1(b,f),S=v.createHref(b);o.replaceState(C,"",S),i&&m&&m({action:d,location:v.location,delta:0})}function N(w){let j=a.location.origin!=="null"?a.location.origin:a.location.href,b=typeof w=="string"?w:kA(w);return b=b.replace(/ $/,"%20"),Xn(j,"No window.location.(origin|href) available to create URL for href: "+b),new URL(b,j)}let v={get action(){return d},get location(){return t(a,o)},listen(w){if(m)throw new Error("A history only accepts one active listener");return a.addEventListener(c1,h),m=w,()=>{a.removeEventListener(c1,h),m=null}},createHref(w){return s(a,w)},createURL:N,encodeLocation(w){let j=N(w);return{pathname:j.pathname,search:j.search,hash:j.hash}},push:x,replace:u,go(w){return o.go(w)}};return v}var u1;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(u1||(u1={}));function T5(t,s,n){return n===void 0&&(n="/"),P5(t,s,n)}function P5(t,s,n,r){let a=typeof s=="string"?xd(s):s,i=EA(a.pathname||"/",n);if(i==null)return null;let o=DA(t);O5(o);let d=null;for(let m=0;d==null&&m{let m={relativePath:d===void 0?i.path||"":d,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};m.relativePath.startsWith("/")&&(Xn(m.relativePath.startsWith(r),'Absolute route path "'+m.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),m.relativePath=m.relativePath.slice(r.length));let f=Qo([r,m.relativePath]),p=n.concat(m);i.children&&i.children.length>0&&(Xn(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+f+'".')),DA(i.children,s,p,f)),!(i.path==null&&!i.index)&&s.push({path:f,score:q5(f,i.index),routesMeta:p})};return t.forEach((i,o)=>{var d;if(i.path===""||!((d=i.path)!=null&&d.includes("?")))a(i,o);else for(let m of RA(i.path))a(i,o,m)}),s}function RA(t){let s=t.split("/");if(s.length===0)return[];let[n,...r]=s,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let o=RA(r.join("/")),d=[];return d.push(...o.map(m=>m===""?i:[i,m].join("/"))),a&&d.push(...o),d.map(m=>t.startsWith("/")&&m===""?"/":m)}function O5(t){t.sort((s,n)=>s.score!==n.score?n.score-s.score:z5(s.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const L5=/^:[\w-]+$/,I5=3,M5=2,F5=1,B5=10,$5=-2,h1=t=>t==="*";function q5(t,s){let n=t.split("/"),r=n.length;return n.some(h1)&&(r+=$5),s&&(r+=M5),n.filter(a=>!h1(a)).reduce((a,i)=>a+(L5.test(i)?I5:i===""?F5:B5),r)}function z5(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 U5(t,s,n){let{routesMeta:r}=t,a={},i="/",o=[];for(let d=0;d{let{paramName:x,isOptional:u}=p;if(x==="*"){let v=d[h]||"";o=i.slice(0,i.length-v.length).replace(/(.)\/+$/,"$1")}const N=d[h];return u&&!N?f[x]=void 0:f[x]=(N||"").replace(/%2F/g,"/"),f},{}),pathname:i,pathnameBase:o,pattern:t}}function H5(t,s,n){s===void 0&&(s=!1),n===void 0&&(n=!0),Wy(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let r=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,d,m)=>(r.push({paramName:d,isOptional:m!=null}),m?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(r.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,s?void 0:"i"),r]}function W5(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return Wy(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+s+").")),t}}function EA(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 G5=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,K5=t=>G5.test(t);function Y5(t,s){s===void 0&&(s="/");let{pathname:n,search:r="",hash:a=""}=typeof t=="string"?xd(t):t,i;if(n)if(K5(n))i=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Wy(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?i=m1(n.substring(1),"/"):i=m1(n,s)}else i=s;return{pathname:i,search:X5(r),hash:J5(a)}}function m1(t,s){let n=s.replace(/\/+$/,"").split("/");return t.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function mg(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 and the router will parse it for you.'}function Z5(t){return t.filter((s,n)=>n===0||s.route.path&&s.route.path.length>0)}function _A(t,s){let n=Z5(t);return s?n.map((r,a)=>a===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function TA(t,s,n,r){r===void 0&&(r=!1);let a;typeof t=="string"?a=xd(t):(a=Su({},t),Xn(!a.pathname||!a.pathname.includes("?"),mg("?","pathname","search",a)),Xn(!a.pathname||!a.pathname.includes("#"),mg("#","pathname","hash",a)),Xn(!a.search||!a.search.includes("#"),mg("#","search","hash",a)));let i=t===""||a.pathname==="",o=i?"/":a.pathname,d;if(o==null)d=n;else{let h=s.length-1;if(!r&&o.startsWith("..")){let x=o.split("/");for(;x[0]==="..";)x.shift(),h-=1;a.pathname=x.join("/")}d=h>=0?s[h]:"/"}let m=Y5(a,d),f=o&&o!=="/"&&o.endsWith("/"),p=(i||o===".")&&n.endsWith("/");return!m.pathname.endsWith("/")&&(f||p)&&(m.pathname+="/"),m}const Qo=t=>t.join("/").replace(/\/\/+/g,"/"),Q5=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),X5=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,J5=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function eL(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const PA=["post","put","patch","delete"];new Set(PA);const tL=["get",...PA];new Set(tL);/** * React Router v6.30.3 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Cu(){return Cu=Object.assign?Object.assign.bind():function(t){for(var s=1;s{d.current=!0}),g.useCallback(function(f,p){if(p===void 0&&(p={}),!d.current)return;if(typeof f=="number"){r.go(f);return}let h=TA(f,JSON.parse(o),i,p.relative==="path");t==null&&s!=="/"&&(h.pathname=h.pathname==="/"?s:Qo([s,h.pathname])),(p.replace?r.replace:r.push)(h,p.state,p)},[s,r,o,i,t])}const rL=g.createContext(null);function aL(t){let s=g.useContext(pl).outlet;return s&&g.createElement(rL.Provider,{value:t},s)}function gd(){let{matches:t}=g.useContext(pl),s=t[t.length-1];return s?s.params:{}}function iL(t,s){return lL(t,s)}function lL(t,s,n,r){Vu()||Xn(!1);let{navigator:a}=g.useContext(Uu),{matches:i}=g.useContext(pl),o=i[i.length-1],d=o?o.params:{};o&&o.pathname;let m=o?o.pathnameBase:"/";o&&o.route;let f=xl(),p;if(s){var h;let w=typeof s=="string"?xd(s):s;m==="/"||(h=w.pathname)!=null&&h.startsWith(m)||Xn(!1),p=w}else p=f;let x=p.pathname||"/",u=x;if(m!=="/"){let w=m.replace(/^\//,"").split("/");u="/"+x.replace(/^\//,"").split("/").slice(w.length).join("/")}let N=T5(t,{pathname:u}),v=hL(N&&N.map(w=>Object.assign({},w,{params:Object.assign({},d,w.params),pathname:Qo([m,a.encodeLocation?a.encodeLocation(w.pathname).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?m:Qo([m,a.encodeLocation?a.encodeLocation(w.pathnameBase).pathname:w.pathnameBase])})),i,n,r);return s&&v?g.createElement(If.Provider,{value:{location:Cu({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:Kl.Pop}},v):v}function oL(){let t=xL(),s=eL(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return g.createElement(g.Fragment,null,g.createElement("h2",null,"Unexpected Application Error!"),g.createElement("h3",{style:{fontStyle:"italic"}},s),n?g.createElement("pre",{style:a},n):null,null)}const cL=g.createElement(oL,null);class dL extends g.Component{constructor(s){super(s),this.state={location:s.location,revalidation:s.revalidation,error:s.error}}static getDerivedStateFromError(s){return{error:s}}static getDerivedStateFromProps(s,n){return n.location!==s.location||n.revalidation!=="idle"&&s.revalidation==="idle"?{error:s.error,location:s.location,revalidation:s.revalidation}:{error:s.error!==void 0?s.error:n.error,location:n.location,revalidation:s.revalidation||n.revalidation}}componentDidCatch(s,n){console.error("React Router caught the following error during render",s,n)}render(){return this.state.error!==void 0?g.createElement(pl.Provider,{value:this.props.routeContext},g.createElement(OA.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function uL(t){let{routeContext:s,match:n,children:r}=t,a=g.useContext(Gy);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),g.createElement(pl.Provider,{value:s},r)}function hL(t,s,n,r){var a;if(s===void 0&&(s=[]),n===void 0&&(n=null),r===void 0&&(r=null),t==null){var i;if(!n)return null;if(n.errors)t=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&s.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let o=t,d=(a=n)==null?void 0:a.errors;if(d!=null){let p=o.findIndex(h=>h.route.id&&(d==null?void 0:d[h.route.id])!==void 0);p>=0||Xn(!1),o=o.slice(0,Math.min(o.length,p+1))}let m=!1,f=-1;if(n&&r&&r.v7_partialHydration)for(let p=0;p=0?o=o.slice(0,f+1):o=[o[0]];break}}}return o.reduceRight((p,h,x)=>{let u,N=!1,v=null,w=null;n&&(u=d&&h.route.id?d[h.route.id]:void 0,v=h.route.errorElement||cL,m&&(f<0&&x===0?(vL("route-fallback"),N=!0,w=null):f===x&&(N=!0,w=h.route.hydrateFallbackElement||null)));let j=s.concat(o.slice(0,x+1)),b=()=>{let C;return u?C=v:N?C=w:h.route.Component?C=g.createElement(h.route.Component,null):h.route.element?C=h.route.element:C=p,g.createElement(uL,{match:h,routeContext:{outlet:p,matches:j,isDataRoute:n!=null},children:C})};return n&&(h.route.ErrorBoundary||h.route.errorElement||x===0)?g.createElement(dL,{location:n.location,revalidation:n.revalidation,component:v,error:u,children:b(),routeContext:{outlet:null,matches:j,isDataRoute:!0}}):b()},null)}var IA=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(IA||{}),MA=(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})(MA||{});function mL(t){let s=g.useContext(Gy);return s||Xn(!1),s}function fL(t){let s=g.useContext(sL);return s||Xn(!1),s}function pL(t){let s=g.useContext(pl);return s||Xn(!1),s}function FA(t){let s=pL(),n=s.matches[s.matches.length-1];return n.route.id||Xn(!1),n.route.id}function xL(){var t;let s=g.useContext(OA),n=fL(),r=FA();return s!==void 0?s:(t=n.errors)==null?void 0:t[r]}function gL(){let{router:t}=mL(IA.UseNavigateStable),s=FA(MA.UseNavigateStable),n=g.useRef(!1);return LA(()=>{n.current=!0}),g.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,Cu({fromRouteId:s},i)))},[t,s])}const f1={};function vL(t,s,n){f1[t]||(f1[t]=!0)}function yL(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Vn(t){let{to:s,replace:n,state:r,relative:a}=t;Vu()||Xn(!1);let{future:i,static:o}=g.useContext(Uu),{matches:d}=g.useContext(pl),{pathname:m}=xl(),f=tr(),p=TA(s,_A(d,i.v7_relativeSplatPath),m,a==="path"),h=JSON.stringify(p);return g.useEffect(()=>f(JSON.parse(h),{replace:n,state:r,relative:a}),[f,h,a,n,r]),null}function bL(t){return aL(t.context)}function Ps(t){Xn(!1)}function jL(t){let{basename:s="/",children:n=null,location:r,navigationType:a=Kl.Pop,navigator:i,static:o=!1,future:d}=t;Vu()&&Xn(!1);let m=s.replace(/^\/*/,"/"),f=g.useMemo(()=>({basename:m,navigator:i,static:o,future:Cu({v7_relativeSplatPath:!1},d)}),[m,d,i,o]);typeof r=="string"&&(r=xd(r));let{pathname:p="/",search:h="",hash:x="",state:u=null,key:N="default"}=r,v=g.useMemo(()=>{let w=EA(p,m);return w==null?null:{location:{pathname:w,search:h,hash:x,state:u,key:N},navigationType:a}},[m,p,h,x,u,N,a]);return v==null?null:g.createElement(Uu.Provider,{value:f},g.createElement(If.Provider,{children:n,value:v}))}function Xv(t){let{children:s,location:n}=t;return iL(Jv(s),n)}new Promise(()=>{});function Jv(t,s){s===void 0&&(s=[]);let n=[];return g.Children.forEach(t,(r,a)=>{if(!g.isValidElement(r))return;let i=[...s,a];if(r.type===g.Fragment){n.push.apply(n,Jv(r.props.children,i));return}r.type!==Ps&&Xn(!1),!r.props.index||!r.props.children||Xn(!1);let o={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=Jv(r.props.children,i)),n.push(o)}),n}/** * React Router DOM v6.30.3 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */const NL="6";try{window.__reactRouterVersion=NL}catch{}const wL="startTransition",p1=wf[wL];function SL(t){let{basename:s,children:n,future:r,window:a}=t,i=g.useRef();i.current==null&&(i.current=R5({window:a,v5Compat:!0}));let o=i.current,[d,m]=g.useState({action:o.action,location:o.location}),{v7_startTransition:f}=r||{},p=g.useCallback(h=>{f&&p1?p1(()=>m(h)):m(h)},[m,f]);return g.useLayoutEffect(()=>o.listen(p),[o,p]),g.useEffect(()=>yL(r),[r]),g.createElement(jL,{basename:s,children:n,location:d.location,navigationType:d.action,navigator:o,future:r})}var x1;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(x1||(x1={}));var g1;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(g1||(g1={}));const v1=({children:t,allowedRoles:s,excludeRoles:n,redirectTo:r})=>{const{user:a,isAuthenticated:i,loading:o}=Pn(h=>h.auth),d=xl(),m=String((a==null?void 0:a.role)||(a==null?void 0:a.roleCode)||"").trim().toLowerCase(),f=(s||[]).map(h=>String(h).trim().toLowerCase()),p=(n||[]).map(h=>String(h).trim().toLowerCase());return o?e.jsx("div",{className:"flex h-screen items-center justify-center",children:"Loading..."}):i?n&&a&&p.includes(m)?m==="prospective dealer"?e.jsx(Vn,{to:"/prospective-dashboard",replace:!0}):e.jsx(Vn,{to:r||"/dashboard",replace:!0}):s&&a&&!f.includes(m)?e.jsx(Vn,{to:r||"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t}):e.jsx(Vn,{to:"/admin-login",state:{from:d},replace:!0})};function y1(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function Hr(...t){return s=>{let n=!1;const r=t.map(a=>{const i=y1(a,s);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a{let{children:i,...o}=r;BA(i)&&typeof nf=="function"&&(i=nf(i._payload));const d=g.Children.toArray(i),m=d.find(RL);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}var $A=Hu("Slot");function kL(t){const s=g.forwardRef((n,r)=>{let{children:a,...i}=n;if(BA(a)&&typeof nf=="function"&&(a=nf(a._payload)),g.isValidElement(a)){const o=_L(a),d=EL(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Hr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var DL=Symbol("radix.slottable");function RL(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===DL}function EL(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function _L(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 qA(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;stypeof t=="boolean"?`${t}`:t===0?"0":t,j1=zA,Ky=(t,s)=>n=>{var r;if((s==null?void 0:s.variants)==null)return j1(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:a,defaultVariants:i}=s,o=Object.keys(a).map(f=>{const p=n==null?void 0:n[f],h=i==null?void 0:i[f];if(p===null)return null;const x=b1(p)||b1(h);return a[f][x]}),d=n&&Object.entries(n).reduce((f,p)=>{let[h,x]=p;return x===void 0||(f[h]=x),f},{}),m=s==null||(r=s.compoundVariants)===null||r===void 0?void 0:r.reduce((f,p)=>{let{class:h,className:x,...u}=p;return Object.entries(u).every(N=>{let[v,w]=N;return Array.isArray(w)?w.includes({...i,...d}[v]):{...i,...d}[v]===w})?[...f,h,x]:f},[]);return j1(t,o,m,n==null?void 0:n.class,n==null?void 0:n.className)},Yy="-",TL=t=>{const s=OL(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const d=o.split(Yy);return d[0]===""&&d.length!==1&&d.shift(),UA(d,s)||PL(o)},getConflictingClassGroupIds:(o,d)=>{const m=n[o]||[];return d&&r[o]?[...m,...r[o]]:m}}},UA=(t,s)=>{var o;if(t.length===0)return s.classGroupId;const n=t[0],r=s.nextPart.get(n),a=r?UA(t.slice(1),r):void 0;if(a)return a;if(s.validators.length===0)return;const i=t.join(Yy);return(o=s.validators.find(({validator:d})=>d(i)))==null?void 0:o.classGroupId},N1=/^\[(.+)\]$/,PL=t=>{if(N1.test(t)){const s=N1.exec(t)[1],n=s==null?void 0:s.substring(0,s.indexOf(":"));if(n)return"arbitrary.."+n}},OL=t=>{const{theme:s,prefix:n}=t,r={nextPart:new Map,validators:[]};return IL(Object.entries(t.classGroups),n).forEach(([i,o])=>{ey(o,r,i,s)}),r},ey=(t,s,n,r)=>{t.forEach(a=>{if(typeof a=="string"){const i=a===""?s:w1(s,a);i.classGroupId=n;return}if(typeof a=="function"){if(LL(a)){ey(a(r),s,n,r);return}s.validators.push({validator:a,classGroupId:n});return}Object.entries(a).forEach(([i,o])=>{ey(o,w1(s,i),n,r)})})},w1=(t,s)=>{let n=t;return s.split(Yy).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},LL=t=>t.isThemeGetter,IL=(t,s)=>s?t.map(([n,r])=>{const a=r.map(i=>typeof i=="string"?s+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([o,d])=>[s+o,d])):i);return[n,a]}):t,ML=t=>{if(t<1)return{get:()=>{},set:()=>{}};let s=0,n=new Map,r=new Map;const a=(i,o)=>{n.set(i,o),s++,s>t&&(s=0,r=n,n=new Map)};return{get(i){let o=n.get(i);if(o!==void 0)return o;if((o=r.get(i))!==void 0)return a(i,o),o},set(i,o){n.has(i)?n.set(i,o):a(i,o)}}},VA="!",FL=t=>{const{separator:s,experimentalParseClassName:n}=t,r=s.length===1,a=s[0],i=s.length,o=d=>{const m=[];let f=0,p=0,h;for(let w=0;wp?h-p:void 0;return{modifiers:m,hasImportantModifier:u,baseClassName:N,maybePostfixModifierPosition:v}};return n?d=>n({className:d,parseClassName:o}):o},BL=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},$L=t=>({cache:ML(t.cacheSize),parseClassName:FL(t),...TL(t)}),qL=/\s+/,zL=(t,s)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a}=s,i=[],o=t.trim().split(qL);let d="";for(let m=o.length-1;m>=0;m-=1){const f=o[m],{modifiers:p,hasImportantModifier:h,baseClassName:x,maybePostfixModifierPosition:u}=n(f);let N=!!u,v=r(N?x.substring(0,u):x);if(!v){if(!N){d=f+(d.length>0?" "+d:d);continue}if(v=r(x),!v){d=f+(d.length>0?" "+d:d);continue}N=!1}const w=BL(p).join(":"),j=h?w+VA:w,b=j+v;if(i.includes(b))continue;i.push(b);const C=a(v,N);for(let S=0;S0?" "+d:d)}return d};function UL(){let t=0,s,n,r="";for(;t{if(typeof t=="string")return t;let s,n="";for(let r=0;rh(p),t());return n=$L(f),r=n.cache.get,a=n.cache.set,i=d,d(m)}function d(m){const f=r(m);if(f)return f;const p=zL(m,n);return a(m,p),p}return function(){return i(UL.apply(null,arguments))}}const _n=t=>{const s=n=>n[t]||[];return s.isThemeGetter=!0,s},WA=/^\[(?:([a-z-]+):)?(.+)\]$/i,HL=/^\d+\/\d+$/,WL=new Set(["px","full","screen"]),GL=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,KL=/\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$/,YL=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ZL=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,QL=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,tl=t=>Zc(t)||WL.has(t)||HL.test(t),Vl=t=>vd(t,"length",aI),Zc=t=>!!t&&!Number.isNaN(Number(t)),fg=t=>vd(t,"number",Zc),eu=t=>!!t&&Number.isInteger(Number(t)),XL=t=>t.endsWith("%")&&Zc(t.slice(0,-1)),Zs=t=>WA.test(t),Hl=t=>GL.test(t),JL=new Set(["length","size","percentage"]),eI=t=>vd(t,JL,GA),tI=t=>vd(t,"position",GA),sI=new Set(["image","url"]),nI=t=>vd(t,sI,lI),rI=t=>vd(t,"",iI),tu=()=>!0,vd=(t,s,n)=>{const r=WA.exec(t);return r?r[1]?typeof s=="string"?r[1]===s:s.has(r[1]):n(r[2]):!1},aI=t=>KL.test(t)&&!YL.test(t),GA=()=>!1,iI=t=>ZL.test(t),lI=t=>QL.test(t),oI=()=>{const t=_n("colors"),s=_n("spacing"),n=_n("blur"),r=_n("brightness"),a=_n("borderColor"),i=_n("borderRadius"),o=_n("borderSpacing"),d=_n("borderWidth"),m=_n("contrast"),f=_n("grayscale"),p=_n("hueRotate"),h=_n("invert"),x=_n("gap"),u=_n("gradientColorStops"),N=_n("gradientColorStopPositions"),v=_n("inset"),w=_n("margin"),j=_n("opacity"),b=_n("padding"),C=_n("saturate"),S=_n("scale"),D=_n("sepia"),_=_n("skew"),A=_n("space"),E=_n("translate"),q=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],R=()=>["auto",Zs,s],P=()=>[Zs,s],L=()=>["",tl,Vl],$=()=>["auto",Zc,Zs],Z=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Q=()=>["solid","dashed","dotted","double","none"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],U=()=>["start","end","center","between","around","evenly","stretch"],M=()=>["","0",Zs],z=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>[Zc,Zs];return{cacheSize:500,separator:":",theme:{colors:[tu],spacing:[tl,Vl],blur:["none","",Hl,Zs],brightness:T(),borderColor:[t],borderRadius:["none","","full",Hl,Zs],borderSpacing:P(),borderWidth:L(),contrast:T(),grayscale:M(),hueRotate:T(),invert:M(),gap:P(),gradientColorStops:[t],gradientColorStopPositions:[XL,Vl],inset:R(),margin:R(),opacity:T(),padding:P(),saturate:T(),scale:T(),sepia:M(),skew:T(),space:P(),translate:P()},classGroups:{aspect:[{aspect:["auto","square","video",Zs]}],container:["container"],columns:[{columns:[Hl]}],"break-after":[{"break-after":z()}],"break-before":[{"break-before":z()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...Z(),Zs]}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:q()}],"overscroll-x":[{"overscroll-x":q()}],"overscroll-y":[{"overscroll-y":q()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[v]}],"inset-x":[{"inset-x":[v]}],"inset-y":[{"inset-y":[v]}],start:[{start:[v]}],end:[{end:[v]}],top:[{top:[v]}],right:[{right:[v]}],bottom:[{bottom:[v]}],left:[{left:[v]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",eu,Zs]}],basis:[{basis:R()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Zs]}],grow:[{grow:M()}],shrink:[{shrink:M()}],order:[{order:["first","last","none",eu,Zs]}],"grid-cols":[{"grid-cols":[tu]}],"col-start-end":[{col:["auto",{span:["full",eu,Zs]},Zs]}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":[tu]}],"row-start-end":[{row:["auto",{span:[eu,Zs]},Zs]}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Zs]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Zs]}],gap:[{gap:[x]}],"gap-x":[{"gap-x":[x]}],"gap-y":[{"gap-y":[x]}],"justify-content":[{justify:["normal",...U()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...U(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...U(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[b]}],px:[{px:[b]}],py:[{py:[b]}],ps:[{ps:[b]}],pe:[{pe:[b]}],pt:[{pt:[b]}],pr:[{pr:[b]}],pb:[{pb:[b]}],pl:[{pl:[b]}],m:[{m:[w]}],mx:[{mx:[w]}],my:[{my:[w]}],ms:[{ms:[w]}],me:[{me:[w]}],mt:[{mt:[w]}],mr:[{mr:[w]}],mb:[{mb:[w]}],ml:[{ml:[w]}],"space-x":[{"space-x":[A]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[A]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Zs,s]}],"min-w":[{"min-w":[Zs,s,"min","max","fit"]}],"max-w":[{"max-w":[Zs,s,"none","full","min","max","fit","prose",{screen:[Hl]},Hl]}],h:[{h:[Zs,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Zs,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Zs,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Zs,s,"auto","min","max","fit"]}],"font-size":[{text:["base",Hl,Vl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",fg]}],"font-family":[{font:[tu]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Zs]}],"line-clamp":[{"line-clamp":["none",Zc,fg]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",tl,Zs]}],"list-image":[{"list-image":["none",Zs]}],"list-style-type":[{list:["none","disc","decimal",Zs]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[j]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[j]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Q(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",tl,Vl]}],"underline-offset":[{"underline-offset":["auto",tl,Zs]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Zs]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Zs]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[j]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Z(),tI]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",eI]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},nI]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[N]}],"gradient-via-pos":[{via:[N]}],"gradient-to-pos":[{to:[N]}],"gradient-from":[{from:[u]}],"gradient-via":[{via:[u]}],"gradient-to":[{to:[u]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[d]}],"border-w-x":[{"border-x":[d]}],"border-w-y":[{"border-y":[d]}],"border-w-s":[{"border-s":[d]}],"border-w-e":[{"border-e":[d]}],"border-w-t":[{"border-t":[d]}],"border-w-r":[{"border-r":[d]}],"border-w-b":[{"border-b":[d]}],"border-w-l":[{"border-l":[d]}],"border-opacity":[{"border-opacity":[j]}],"border-style":[{border:[...Q(),"hidden"]}],"divide-x":[{"divide-x":[d]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[d]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[j]}],"divide-style":[{divide:Q()}],"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:["",...Q()]}],"outline-offset":[{"outline-offset":[tl,Zs]}],"outline-w":[{outline:[tl,Vl]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:L()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[j]}],"ring-offset-w":[{"ring-offset":[tl,Vl]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Hl,rI]}],"shadow-color":[{shadow:[tu]}],opacity:[{opacity:[j]}],"mix-blend":[{"mix-blend":[...W(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":W()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[m]}],"drop-shadow":[{"drop-shadow":["","none",Hl,Zs]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[h]}],saturate:[{saturate:[C]}],sepia:[{sepia:[D]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[m]}],"backdrop-grayscale":[{"backdrop-grayscale":[f]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[p]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[j]}],"backdrop-saturate":[{"backdrop-saturate":[C]}],"backdrop-sepia":[{"backdrop-sepia":[D]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Zs]}],duration:[{duration:T()}],ease:[{ease:["linear","in","out","in-out",Zs]}],delay:[{delay:T()}],animate:[{animate:["none","spin","ping","pulse","bounce",Zs]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[S]}],"scale-x":[{"scale-x":[S]}],"scale-y":[{"scale-y":[S]}],rotate:[{rotate:[eu,Zs]}],"translate-x":[{"translate-x":[E]}],"translate-y":[{"translate-y":[E]}],"skew-x":[{"skew-x":[_]}],"skew-y":[{"skew-y":[_]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Zs]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Zs]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Zs]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[tl,Vl,fg]}],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"]}}},cI=VL(oI);function Nt(...t){return cI(zA(t))}function Qt(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 nd=Ky("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background text-foreground hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9 rounded-md"}},defaultVariants:{variant:"default",size:"default"}}),te=g.forwardRef(({className:t,variant:s,size:n,asChild:r=!1,...a},i)=>{const o=r?$A:"button";return e.jsx(o,{"data-slot":"button",className:Nt(nd({variant:s,size:n,className:t})),ref:i,...a})});te.displayName="Button";const it=g.forwardRef(({className:t,type:s,...n},r)=>e.jsx("input",{type:s,ref:r,"data-slot":"input",className:Nt("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border px-3 py-1 text-base bg-input-background transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...n}));it.displayName="Input";function Ks({className:t,...s}){return e.jsx("textarea",{"data-slot":"textarea",className:Nt("resize-none border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-input-background px-3 py-2 text-base transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),...s})}function dI(t,s){const n=g.createContext(s),r=i=>{const{children:o,...d}=i,m=g.useMemo(()=>d,Object.values(d));return e.jsx(n.Provider,{value:m,children:o})};r.displayName=t+"Provider";function a(i){const o=g.useContext(n);if(o)return o;if(s!==void 0)return s;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[r,a]}function oa(t,s=[]){let n=[];function r(i,o){const d=g.createContext(o),m=n.length;n=[...n,o];const f=h=>{var j;const{scope:x,children:u,...N}=h,v=((j=x==null?void 0:x[t])==null?void 0:j[m])||d,w=g.useMemo(()=>N,Object.values(N));return e.jsx(v.Provider,{value:w,children:u})};f.displayName=i+"Provider";function p(h,x){var v;const u=((v=x==null?void 0:x[t])==null?void 0:v[m])||d,N=g.useContext(u);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[f,p]}const a=()=>{const i=n.map(o=>g.createContext(o));return function(d){const m=(d==null?void 0:d[t])||i;return g.useMemo(()=>({[`__scope${t}`]:{...d,[t]:m}}),[d,m])}};return a.scopeName=t,[r,uI(a,...s)]}function uI(...t){const s=t[0];if(t.length===1)return s;const n=()=>{const r=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((d,{useScope:m,scopeName:f})=>{const h=m(i)[`__scope${f}`];return{...d,...h}},{});return g.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return n.scopeName=s.scopeName,n}function Yt(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 Jn=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},hI=wf[" useInsertionEffect ".trim().toString()]||Jn;function Li({prop:t,defaultProp:s,onChange:n=()=>{},caller:r}){const[a,i,o]=mI({defaultProp:s,onChange:n}),d=t!==void 0,m=d?t:a;{const p=g.useRef(t!==void 0);g.useEffect(()=>{const h=p.current;h!==d&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${d?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=d},[d,r])}const f=g.useCallback(p=>{var h;if(d){const x=fI(p)?p(t):p;x!==t&&((h=o.current)==null||h.call(o,x))}else i(p)},[d,t,i,o]);return[m,f]}function mI({defaultProp:t,onChange:s}){const[n,r]=g.useState(t),a=g.useRef(n),i=g.useRef(s);return hI(()=>{i.current=s},[s]),g.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,r,i]}function fI(t){return typeof t=="function"}function Zy(t){const s=g.useRef({value:t,previous:t});return g.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}function Qy(t){const[s,n]=g.useState(void 0);return Jn(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const i=a[0];let o,d;if("borderBoxSize"in i){const m=i.borderBoxSize,f=Array.isArray(m)?m[0]:m;o=f.inlineSize,d=f.blockSize}else o=t.offsetWidth,d=t.offsetHeight;n({width:o,height:d})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),s}function pI(t,s){return g.useReducer((n,r)=>s[n][r]??n,t)}var jr=t=>{const{present:s,children:n}=t,r=xI(s),a=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),i=Ys(r.ref,gI(a));return typeof n=="function"||r.isPresent?g.cloneElement(a,{ref:i}):null};jr.displayName="Presence";function xI(t){const[s,n]=g.useState(),r=g.useRef(null),a=g.useRef(t),i=g.useRef("none"),o=t?"mounted":"unmounted",[d,m]=pI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const f=dm(r.current);i.current=d==="mounted"?f:"none"},[d]),Jn(()=>{const f=r.current,p=a.current;if(p!==t){const x=i.current,u=dm(f);t?m("MOUNT"):u==="none"||(f==null?void 0:f.display)==="none"?m("UNMOUNT"):m(p&&x!==u?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,m]),Jn(()=>{if(s){let f;const p=s.ownerDocument.defaultView??window,h=u=>{const v=dm(r.current).includes(CSS.escape(u.animationName));if(u.target===s&&v&&(m("ANIMATION_END"),!a.current)){const w=s.style.animationFillMode;s.style.animationFillMode="forwards",f=p.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=w)})}},x=u=>{u.target===s&&(i.current=dm(r.current))};return s.addEventListener("animationstart",x),s.addEventListener("animationcancel",h),s.addEventListener("animationend",h),()=>{p.clearTimeout(f),s.removeEventListener("animationstart",x),s.removeEventListener("animationcancel",h),s.removeEventListener("animationend",h)}}else m("ANIMATION_END")},[s,m]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:g.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function dm(t){return(t==null?void 0:t.animationName)||"none"}function gI(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 vI(t){const s=yI(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find(jI);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function yI(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=wI(a),d=NI(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Hr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var bI=Symbol("radix.slottable");function jI(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===bI}function NI(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function wI(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 SI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ss=SI.reduce((t,s)=>{const n=vI(`Primitive.${s}`),r=g.forwardRef((a,i)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{});function KA(t,s){t&&zu.flushSync(()=>t.dispatchEvent(s))}var Mf="Checkbox",[CI]=oa(Mf),[AI,Xy]=CI(Mf);function kI(t){const{__scopeCheckbox:s,checked:n,children:r,defaultChecked:a,disabled:i,form:o,name:d,onCheckedChange:m,required:f,value:p="on",internal_do_not_use_render:h}=t,[x,u]=Li({prop:n,defaultProp:a??!1,onChange:m,caller:Mf}),[N,v]=g.useState(null),[w,j]=g.useState(null),b=g.useRef(!1),C=N?!!o||!!N.closest("form"):!0,S={checked:x,disabled:i,setChecked:u,control:N,setControl:v,name:d,form:o,value:p,hasConsumerStoppedPropagationRef:b,required:f,defaultChecked:Zl(a)?!1:a,isFormControl:C,bubbleInput:w,setBubbleInput:j};return e.jsx(AI,{scope:s,...S,children:DI(h)?h(S):r})}var YA="CheckboxTrigger",ZA=g.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:n,...r},a)=>{const{control:i,value:o,disabled:d,checked:m,required:f,setControl:p,setChecked:h,hasConsumerStoppedPropagationRef:x,isFormControl:u,bubbleInput:N}=Xy(YA,t),v=Ys(a,p),w=g.useRef(m);return g.useEffect(()=>{const j=i==null?void 0:i.form;if(j){const b=()=>h(w.current);return j.addEventListener("reset",b),()=>j.removeEventListener("reset",b)}},[i,h]),e.jsx(Ss.button,{type:"button",role:"checkbox","aria-checked":Zl(m)?"mixed":m,"aria-required":f,"data-state":sk(m),"data-disabled":d?"":void 0,disabled:d,value:o,...r,ref:v,onKeyDown:Yt(s,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:Yt(n,j=>{h(b=>Zl(b)?!0:!b),N&&u&&(x.current=j.isPropagationStopped(),x.current||j.stopPropagation())})})});ZA.displayName=YA;var QA=g.forwardRef((t,s)=>{const{__scopeCheckbox:n,name:r,checked:a,defaultChecked:i,required:o,disabled:d,value:m,onCheckedChange:f,form:p,...h}=t;return e.jsx(kI,{__scopeCheckbox:n,checked:a,defaultChecked:i,disabled:d,required:o,onCheckedChange:f,name:r,form:p,value:m,internal_do_not_use_render:({isFormControl:x})=>e.jsxs(e.Fragment,{children:[e.jsx(ZA,{...h,ref:s,__scopeCheckbox:n}),x&&e.jsx(tk,{__scopeCheckbox:n})]})})});QA.displayName=Mf;var XA="CheckboxIndicator",JA=g.forwardRef((t,s)=>{const{__scopeCheckbox:n,forceMount:r,...a}=t,i=Xy(XA,n);return e.jsx(jr,{present:r||Zl(i.checked)||i.checked===!0,children:e.jsx(Ss.span,{"data-state":sk(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});JA.displayName=XA;var ek="CheckboxBubbleInput",tk=g.forwardRef(({__scopeCheckbox:t,...s},n)=>{const{control:r,hasConsumerStoppedPropagationRef:a,checked:i,defaultChecked:o,required:d,disabled:m,name:f,value:p,form:h,bubbleInput:x,setBubbleInput:u}=Xy(ek,t),N=Ys(n,u),v=Zy(i),w=Qy(r);g.useEffect(()=>{const b=x;if(!b)return;const C=window.HTMLInputElement.prototype,D=Object.getOwnPropertyDescriptor(C,"checked").set,_=!a.current;if(v!==i&&D){const A=new Event("click",{bubbles:_});b.indeterminate=Zl(i),D.call(b,Zl(i)?!1:i),b.dispatchEvent(A)}},[x,v,i,a]);const j=g.useRef(Zl(i)?!1:i);return e.jsx(Ss.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??j.current,required:d,disabled:m,name:f,value:p,form:h,...s,tabIndex:-1,ref:N,style:{...s.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});tk.displayName=ek;function DI(t){return typeof t=="function"}function Zl(t){return t==="indeterminate"}function sk(t){return Zl(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 RI={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 EI=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),vt=(t,s)=>{const n=g.forwardRef(({color:r="currentColor",size:a=24,strokeWidth:i=2,absoluteStrokeWidth:o,className:d="",children:m,...f},p)=>g.createElement("svg",{ref:p,...RI,width:a,height:a,stroke:r,strokeWidth:o?Number(i)*24/Number(a):i,className:["lucide",`lucide-${EI(t)}`,d].join(" "),...f},[...s.map(([h,x])=>g.createElement(h,x)),...Array.isArray(m)?m:[m]]));return n.displayName=`${t}`,n};/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rd=vt("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sn=vt("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 Ba=vt("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 Wr=vt("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 Wo=vt("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 _I=vt("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 nk=vt("Award",[["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}],["path",{d:"M15.477 12.89 17 22l-5-3-5 3 1.523-9.11",key:"em7aur"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jy=vt("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 TI=vt("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 PI=vt("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Au=vt("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S1=vt("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 to=vt("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 ad=vt("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 rk=vt("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 er=vt("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 Hn=vt("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 ln=vt("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 OI=vt("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 $n=vt("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 va=vt("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 io=vt("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 mi=vt("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yu=vt("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 LI=vt("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 ak=vt("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 sc=vt("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 dn=vt("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C1=vt("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wu=vt("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ty=vt("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 fi=vt("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 ik=vt("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const II=vt("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 un=vt("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 hu=vt("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 MI=vt("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 ks=vt("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 FI=vt("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 rf=vt("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eb=vt("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 BI=vt("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 $I=vt("Gavel",[["path",{d:"m14.5 12.5-8 8a2.119 2.119 0 1 1-3-3l8-8",key:"15492f"}],["path",{d:"m16 16 6-6",key:"vzrcl6"}],["path",{d:"m8 8 6-6",key:"18bi4p"}],["path",{d:"m9 7 8 8",key:"5jnvq1"}],["path",{d:"m21 11-8-8",key:"z4y7zo"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sy=vt("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ku=vt("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 qI=vt("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 lk=vt("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 ok=vt("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 A1=vt("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 zI=vt("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 ya=vt("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 qa=vt("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 ck=vt("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 UI=vt("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const um=vt("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 VI=vt("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 dk=vt("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 cs=vt("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ny=vt("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 HI=vt("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 uk=vt("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 Gr=vt("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 Mr=vt("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 li=vt("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 WI=vt("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 hk=vt("Navigation",[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bu=vt("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 GI=vt("PauseCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k1=vt("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 gr=vt("Pen",[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ry=vt("Pencil",[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tb=vt("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 pg=vt("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 bn=vt("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ay=vt("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 cl=vt("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 or=vt("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 KI=vt("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sb=vt("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 dl=vt("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 wa=vt("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gu=vt("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 YI=vt("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ff=vt("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 Qc=vt("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 mk=vt("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 so=vt("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 dc=vt("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 ZI=vt("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 QI=vt("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 XI=vt("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 JI=vt("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 eM=vt("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 tM=vt("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 sM=vt("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zn=vt("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 Go=vt("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 ll=vt("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 nM=vt("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 rM=vt("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 vr=vt("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 aM=vt("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 iM=vt("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 xg=vt("UserMinus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nb=vt("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 gg=vt("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 Rr=vt("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 ja=vt("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 af=vt("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 ai=vt("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 id=vt("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 D1=vt("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]);function Tn({className:t,...s}){return e.jsx(QA,{"data-slot":"checkbox",className:Nt("peer border bg-input-background dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(JA,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:e.jsx($n,{className:"size-3.5"})})})}var lM=t=>{switch(t){case"success":return dM;case"info":return hM;case"warning":return uM;case"error":return mM;default:return null}},oM=Array(12).fill(0),cM=({visible:t,className:s})=>Ct.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},Ct.createElement("div",{className:"sonner-spinner"},oM.map((n,r)=>Ct.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),dM=Ct.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Ct.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"})),uM=Ct.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},Ct.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"})),hM=Ct.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Ct.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"})),mM=Ct.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Ct.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"})),fM=Ct.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"},Ct.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Ct.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),pM=()=>{let[t,s]=Ct.useState(document.hidden);return Ct.useEffect(()=>{let n=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),t},iy=1,xM=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let s=this.subscribers.indexOf(t);this.subscribers.splice(s,1)}),this.publish=t=>{this.subscribers.forEach(s=>s(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var s;let{message:n,...r}=t,a=typeof(t==null?void 0:t.id)=="number"||((s=t.id)==null?void 0:s.length)>0?t.id:iy++,i=this.toasts.find(d=>d.id===a),o=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),i?this.toasts=this.toasts.map(d=>d.id===a?(this.publish({...d,...t,id:a,title:n}),{...d,...t,id:a,dismissible:o,title:n}):d):this.addToast({title:n,...r,dismissible:o,id:a}),a},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(s=>{this.subscribers.forEach(n=>n({id:s.id,dismiss:!0}))}),this.subscribers.forEach(s=>s({id:t,dismiss:!0})),t),this.message=(t,s)=>this.create({...s,message:t}),this.error=(t,s)=>this.create({...s,message:t,type:"error"}),this.success=(t,s)=>this.create({...s,type:"success",message:t}),this.info=(t,s)=>this.create({...s,type:"info",message:t}),this.warning=(t,s)=>this.create({...s,type:"warning",message:t}),this.loading=(t,s)=>this.create({...s,type:"loading",message:t}),this.promise=(t,s)=>{if(!s)return;let n;s.loading!==void 0&&(n=this.create({...s,promise:t,type:"loading",message:s.loading,description:typeof s.description!="function"?s.description:void 0}));let r=t instanceof Promise?t:t(),a=n!==void 0,i,o=r.then(async m=>{if(i=["resolve",m],Ct.isValidElement(m))a=!1,this.create({id:n,type:"default",message:m});else if(vM(m)&&!m.ok){a=!1;let f=typeof s.error=="function"?await s.error(`HTTP error! status: ${m.status}`):s.error,p=typeof s.description=="function"?await s.description(`HTTP error! status: ${m.status}`):s.description;this.create({id:n,type:"error",message:f,description:p})}else if(s.success!==void 0){a=!1;let f=typeof s.success=="function"?await s.success(m):s.success,p=typeof s.description=="function"?await s.description(m):s.description;this.create({id:n,type:"success",message:f,description:p})}}).catch(async m=>{if(i=["reject",m],s.error!==void 0){a=!1;let f=typeof s.error=="function"?await s.error(m):s.error,p=typeof s.description=="function"?await s.description(m):s.description;this.create({id:n,type:"error",message:f,description:p})}}).finally(()=>{var m;a&&(this.dismiss(n),n=void 0),(m=s.finally)==null||m.call(s)}),d=()=>new Promise((m,f)=>o.then(()=>i[0]==="reject"?f(i[1]):m(i[1])).catch(f));return typeof n!="string"&&typeof n!="number"?{unwrap:d}:Object.assign(n,{unwrap:d})},this.custom=(t,s)=>{let n=(s==null?void 0:s.id)||iy++;return this.create({jsx:t(n),id:n,...s}),n},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},sa=new xM,gM=(t,s)=>{let n=(s==null?void 0:s.id)||iy++;return sa.addToast({title:t,...s,id:n}),n},vM=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",yM=gM,bM=()=>sa.toasts,jM=()=>sa.getActiveToasts(),J=Object.assign(yM,{success:sa.success,info:sa.info,warning:sa.warning,error:sa.error,custom:sa.custom,message:sa.message,promise:sa.promise,dismiss:sa.dismiss,loading:sa.loading},{getHistory:bM,getToasts:jM});function NM(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))}NM(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)} `);function hm(t){return t.label!==void 0}var wM=3,SM="32px",CM="16px",R1=4e3,AM=356,kM=14,DM=20,RM=200;function ei(...t){return t.filter(Boolean).join(" ")}function EM(t){let[s,n]=t.split("-"),r=[];return s&&r.push(s),n&&r.push(n),r}var _M=t=>{var s,n,r,a,i,o,d,m,f,p,h;let{invert:x,toast:u,unstyled:N,interacting:v,setHeights:w,visibleToasts:j,heights:b,index:C,toasts:S,expanded:D,removeToast:_,defaultRichColors:A,closeButton:E,style:q,cancelButtonStyle:O,actionButtonStyle:R,className:P="",descriptionClassName:L="",duration:$,position:Z,gap:Q,loadingIcon:W,expandByDefault:U,classNames:M,icons:z,closeButtonAriaLabel:T="Close toast",pauseWhenPageIsHidden:F}=t,[I,K]=Ct.useState(null),[G,V]=Ct.useState(null),[Y,re]=Ct.useState(!1),[ae,ue]=Ct.useState(!1),[ye,ce]=Ct.useState(!1),[je,Me]=Ct.useState(!1),[ut,jt]=Ct.useState(!1),[ft,X]=Ct.useState(0),[Ce,xe]=Ct.useState(0),We=Ct.useRef(u.duration||$||R1),Be=Ct.useRef(null),rt=Ct.useRef(null),ht=C===0,ge=C+1<=j,Je=u.type,mt=u.dismissible!==!1,de=u.className||"",at=u.descriptionClassName||"",ot=Ct.useMemo(()=>b.findIndex(Ke=>Ke.toastId===u.id)||0,[b,u.id]),ke=Ct.useMemo(()=>{var Ke;return(Ke=u.closeButton)!=null?Ke:E},[u.closeButton,E]),Zt=Ct.useMemo(()=>u.duration||$||R1,[u.duration,$]),Bt=Ct.useRef(0),_s=Ct.useRef(0),Us=Ct.useRef(0),fs=Ct.useRef(null),[Vs,Qs]=Z.split("-"),Xs=Ct.useMemo(()=>b.reduce((Ke,Le,Ue)=>Ue>=ot?Ke:Ke+Le.height,0),[b,ot]),ie=pM(),nt=u.invert||x,fe=Je==="loading";_s.current=Ct.useMemo(()=>ot*Q+Xs,[ot,Xs]),Ct.useEffect(()=>{We.current=Zt},[Zt]),Ct.useEffect(()=>{re(!0)},[]),Ct.useEffect(()=>{let Ke=rt.current;if(Ke){let Le=Ke.getBoundingClientRect().height;return xe(Le),w(Ue=>[{toastId:u.id,height:Le,position:u.position},...Ue]),()=>w(Ue=>Ue.filter(et=>et.toastId!==u.id))}},[w,u.id]),Ct.useLayoutEffect(()=>{if(!Y)return;let Ke=rt.current,Le=Ke.style.height;Ke.style.height="auto";let Ue=Ke.getBoundingClientRect().height;Ke.style.height=Le,xe(Ue),w(et=>et.find(dt=>dt.toastId===u.id)?et.map(dt=>dt.toastId===u.id?{...dt,height:Ue}:dt):[{toastId:u.id,height:Ue,position:u.position},...et])},[Y,u.title,u.description,w,u.id]);let Ae=Ct.useCallback(()=>{ue(!0),X(_s.current),w(Ke=>Ke.filter(Le=>Le.toastId!==u.id)),setTimeout(()=>{_(u)},RM)},[u,_,w,_s]);Ct.useEffect(()=>{if(u.promise&&Je==="loading"||u.duration===1/0||u.type==="loading")return;let Ke;return D||v||F&&ie?(()=>{if(Us.current{var Le;(Le=u.onAutoClose)==null||Le.call(u,u),Ae()},We.current)),()=>clearTimeout(Ke)},[D,v,u,Je,F,ie,Ae]),Ct.useEffect(()=>{u.delete&&Ae()},[Ae,u.delete]);function Fe(){var Ke,Le,Ue;return z!=null&&z.loading?Ct.createElement("div",{className:ei(M==null?void 0:M.loader,(Ke=u==null?void 0:u.classNames)==null?void 0:Ke.loader,"sonner-loader"),"data-visible":Je==="loading"},z.loading):W?Ct.createElement("div",{className:ei(M==null?void 0:M.loader,(Le=u==null?void 0:u.classNames)==null?void 0:Le.loader,"sonner-loader"),"data-visible":Je==="loading"},W):Ct.createElement(cM,{className:ei(M==null?void 0:M.loader,(Ue=u==null?void 0:u.classNames)==null?void 0:Ue.loader),visible:Je==="loading"})}return Ct.createElement("li",{tabIndex:0,ref:rt,className:ei(P,de,M==null?void 0:M.toast,(s=u==null?void 0:u.classNames)==null?void 0:s.toast,M==null?void 0:M.default,M==null?void 0:M[Je],(n=u==null?void 0:u.classNames)==null?void 0:n[Je]),"data-sonner-toast":"","data-rich-colors":(r=u.richColors)!=null?r:A,"data-styled":!(u.jsx||u.unstyled||N),"data-mounted":Y,"data-promise":!!u.promise,"data-swiped":ut,"data-removed":ae,"data-visible":ge,"data-y-position":Vs,"data-x-position":Qs,"data-index":C,"data-front":ht,"data-swiping":ye,"data-dismissible":mt,"data-type":Je,"data-invert":nt,"data-swipe-out":je,"data-swipe-direction":G,"data-expanded":!!(D||U&&Y),style:{"--index":C,"--toasts-before":C,"--z-index":S.length-C,"--offset":`${ae?ft:_s.current}px`,"--initial-height":U?"auto":`${Ce}px`,...q,...u.style},onDragEnd:()=>{ce(!1),K(null),fs.current=null},onPointerDown:Ke=>{fe||!mt||(Be.current=new Date,X(_s.current),Ke.target.setPointerCapture(Ke.pointerId),Ke.target.tagName!=="BUTTON"&&(ce(!0),fs.current={x:Ke.clientX,y:Ke.clientY}))},onPointerUp:()=>{var Ke,Le,Ue,et;if(je||!mt)return;fs.current=null;let dt=Number(((Ke=rt.current)==null?void 0:Ke.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ss=Number(((Le=rt.current)==null?void 0:Le.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Wt=new Date().getTime()-((Ue=Be.current)==null?void 0:Ue.getTime()),kt=I==="x"?dt:ss,wt=Math.abs(kt)/Wt;if(Math.abs(kt)>=DM||wt>.11){X(_s.current),(et=u.onDismiss)==null||et.call(u,u),V(I==="x"?dt>0?"right":"left":ss>0?"down":"up"),Ae(),Me(!0),jt(!1);return}ce(!1),K(null)},onPointerMove:Ke=>{var Le,Ue,et,dt;if(!fs.current||!mt||((Le=window.getSelection())==null?void 0:Le.toString().length)>0)return;let ss=Ke.clientY-fs.current.y,Wt=Ke.clientX-fs.current.x,kt=(Ue=t.swipeDirections)!=null?Ue:EM(Z);!I&&(Math.abs(Wt)>1||Math.abs(ss)>1)&&K(Math.abs(Wt)>Math.abs(ss)?"x":"y");let wt={x:0,y:0};I==="y"?(kt.includes("top")||kt.includes("bottom"))&&(kt.includes("top")&&ss<0||kt.includes("bottom")&&ss>0)&&(wt.y=ss):I==="x"&&(kt.includes("left")||kt.includes("right"))&&(kt.includes("left")&&Wt<0||kt.includes("right")&&Wt>0)&&(wt.x=Wt),(Math.abs(wt.x)>0||Math.abs(wt.y)>0)&&jt(!0),(et=rt.current)==null||et.style.setProperty("--swipe-amount-x",`${wt.x}px`),(dt=rt.current)==null||dt.style.setProperty("--swipe-amount-y",`${wt.y}px`)}},ke&&!u.jsx?Ct.createElement("button",{"aria-label":T,"data-disabled":fe,"data-close-button":!0,onClick:fe||!mt?()=>{}:()=>{var Ke;Ae(),(Ke=u.onDismiss)==null||Ke.call(u,u)},className:ei(M==null?void 0:M.closeButton,(a=u==null?void 0:u.classNames)==null?void 0:a.closeButton)},(i=z==null?void 0:z.close)!=null?i:fM):null,u.jsx||g.isValidElement(u.title)?u.jsx?u.jsx:typeof u.title=="function"?u.title():u.title:Ct.createElement(Ct.Fragment,null,Je||u.icon||u.promise?Ct.createElement("div",{"data-icon":"",className:ei(M==null?void 0:M.icon,(o=u==null?void 0:u.classNames)==null?void 0:o.icon)},u.promise||u.type==="loading"&&!u.icon?u.icon||Fe():null,u.type!=="loading"?u.icon||(z==null?void 0:z[Je])||lM(Je):null):null,Ct.createElement("div",{"data-content":"",className:ei(M==null?void 0:M.content,(d=u==null?void 0:u.classNames)==null?void 0:d.content)},Ct.createElement("div",{"data-title":"",className:ei(M==null?void 0:M.title,(m=u==null?void 0:u.classNames)==null?void 0:m.title)},typeof u.title=="function"?u.title():u.title),u.description?Ct.createElement("div",{"data-description":"",className:ei(L,at,M==null?void 0:M.description,(f=u==null?void 0:u.classNames)==null?void 0:f.description)},typeof u.description=="function"?u.description():u.description):null),g.isValidElement(u.cancel)?u.cancel:u.cancel&&hm(u.cancel)?Ct.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||O,onClick:Ke=>{var Le,Ue;hm(u.cancel)&&mt&&((Ue=(Le=u.cancel).onClick)==null||Ue.call(Le,Ke),Ae())},className:ei(M==null?void 0:M.cancelButton,(p=u==null?void 0:u.classNames)==null?void 0:p.cancelButton)},u.cancel.label):null,g.isValidElement(u.action)?u.action:u.action&&hm(u.action)?Ct.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||R,onClick:Ke=>{var Le,Ue;hm(u.action)&&((Ue=(Le=u.action).onClick)==null||Ue.call(Le,Ke),!Ke.defaultPrevented&&Ae())},className:ei(M==null?void 0:M.actionButton,(h=u==null?void 0:u.classNames)==null?void 0:h.actionButton)},u.action.label):null))};function E1(){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 TM(t,s){let n={};return[t,s].forEach((r,a)=>{let i=a===1,o=i?"--mobile-offset":"--offset",d=i?CM:SM;function m(f){["top","right","bottom","left"].forEach(p=>{n[`${o}-${p}`]=typeof f=="number"?`${f}px`:f})}typeof r=="number"||typeof r=="string"?m(r):typeof r=="object"?["top","right","bottom","left"].forEach(f=>{r[f]===void 0?n[`${o}-${f}`]=d:n[`${o}-${f}`]=typeof r[f]=="number"?`${r[f]}px`:r[f]}):m(d)}),n}var PM=g.forwardRef(function(t,s){let{invert:n,position:r="bottom-right",hotkey:a=["altKey","KeyT"],expand:i,closeButton:o,className:d,offset:m,mobileOffset:f,theme:p="light",richColors:h,duration:x,style:u,visibleToasts:N=wM,toastOptions:v,dir:w=E1(),gap:j=kM,loadingIcon:b,icons:C,containerAriaLabel:S="Notifications",pauseWhenPageIsHidden:D}=t,[_,A]=Ct.useState([]),E=Ct.useMemo(()=>Array.from(new Set([r].concat(_.filter(F=>F.position).map(F=>F.position)))),[_,r]),[q,O]=Ct.useState([]),[R,P]=Ct.useState(!1),[L,$]=Ct.useState(!1),[Z,Q]=Ct.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),W=Ct.useRef(null),U=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),M=Ct.useRef(null),z=Ct.useRef(!1),T=Ct.useCallback(F=>{A(I=>{var K;return(K=I.find(G=>G.id===F.id))!=null&&K.delete||sa.dismiss(F.id),I.filter(({id:G})=>G!==F.id)})},[]);return Ct.useEffect(()=>sa.subscribe(F=>{if(F.dismiss){A(I=>I.map(K=>K.id===F.id?{...K,delete:!0}:K));return}setTimeout(()=>{Hy.flushSync(()=>{A(I=>{let K=I.findIndex(G=>G.id===F.id);return K!==-1?[...I.slice(0,K),{...I[K],...F},...I.slice(K+1)]:[F,...I]})})})}),[]),Ct.useEffect(()=>{if(p!=="system"){Q(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Q("dark"):Q("light")),typeof window>"u")return;let F=window.matchMedia("(prefers-color-scheme: dark)");try{F.addEventListener("change",({matches:I})=>{Q(I?"dark":"light")})}catch{F.addListener(({matches:K})=>{try{Q(K?"dark":"light")}catch(G){console.error(G)}})}},[p]),Ct.useEffect(()=>{_.length<=1&&P(!1)},[_]),Ct.useEffect(()=>{let F=I=>{var K,G;a.every(V=>I[V]||I.code===V)&&(P(!0),(K=W.current)==null||K.focus()),I.code==="Escape"&&(document.activeElement===W.current||(G=W.current)!=null&&G.contains(document.activeElement))&&P(!1)};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[a]),Ct.useEffect(()=>{if(W.current)return()=>{M.current&&(M.current.focus({preventScroll:!0}),M.current=null,z.current=!1)}},[W.current]),Ct.createElement("section",{ref:s,"aria-label":`${S} ${U}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},E.map((F,I)=>{var K;let[G,V]=F.split("-");return _.length?Ct.createElement("ol",{key:F,dir:w==="auto"?E1():w,tabIndex:-1,ref:W,className:d,"data-sonner-toaster":!0,"data-theme":Z,"data-y-position":G,"data-lifted":R&&_.length>1&&!i,"data-x-position":V,style:{"--front-toast-height":`${((K=q[0])==null?void 0:K.height)||0}px`,"--width":`${AM}px`,"--gap":`${j}px`,...u,...TM(m,f)},onBlur:Y=>{z.current&&!Y.currentTarget.contains(Y.relatedTarget)&&(z.current=!1,M.current&&(M.current.focus({preventScroll:!0}),M.current=null))},onFocus:Y=>{Y.target instanceof HTMLElement&&Y.target.dataset.dismissible==="false"||z.current||(z.current=!0,M.current=Y.relatedTarget)},onMouseEnter:()=>P(!0),onMouseMove:()=>P(!0),onMouseLeave:()=>{L||P(!1)},onDragEnd:()=>P(!1),onPointerDown:Y=>{Y.target instanceof HTMLElement&&Y.target.dataset.dismissible==="false"||$(!0)},onPointerUp:()=>$(!1)},_.filter(Y=>!Y.position&&I===0||Y.position===F).map((Y,re)=>{var ae,ue;return Ct.createElement(_M,{key:Y.id,icons:C,index:re,toast:Y,defaultRichColors:h,duration:(ae=v==null?void 0:v.duration)!=null?ae:x,className:v==null?void 0:v.className,descriptionClassName:v==null?void 0:v.descriptionClassName,invert:n,visibleToasts:N,closeButton:(ue=v==null?void 0:v.closeButton)!=null?ue:o,interacting:L,position:F,style:v==null?void 0:v.style,unstyled:v==null?void 0:v.unstyled,classNames:v==null?void 0:v.classNames,cancelButtonStyle:v==null?void 0:v.cancelButtonStyle,actionButtonStyle:v==null?void 0:v.actionButtonStyle,removeToast:T,toasts:_.filter(ye=>ye.position==Y.position),heights:q.filter(ye=>ye.position==Y.position),setHeights:O,expandByDefault:i,gap:j,loadingIcon:b,expanded:R,pauseWhenPageIsHidden:D,swipeDirections:t.swipeDirections})})):null}))});const ps={submitApplication:async t=>{var n;const s=await Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.bulkConvertToOpportunity(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to perform bulk conversion");return s.data},sendBulkReminders:async t=>{var n;const s=await Re.sendBulkReminders({applicationIds:t});if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to send reminders");return s.data},createDealer:async t=>{var n;const s=await Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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)||[]}},$s={getRoles:async()=>(await Re.getRoles()).data,getPermissions:async()=>(await Re.getPermissions()).data,updateRole:async(t,s)=>(await Re.updateRole(t,s)).data,createRole:async t=>(await Re.createRole(t)).data,getZones:async()=>(await Re.getZones()).data,updateZone:async(t,s)=>(await Re.updateZone(t,s)).data,createZone:async t=>(await Re.createZone(t)).data,createRegion:async t=>(await Re.createRegion(t)).data,updateRegion:async(t,s)=>(await Re.updateRegion(t,s)).data,getRegions:async()=>(await Re.getRegions()).data,getStates:async t=>(await Re.getStates(t)).data,getDistricts:async t=>{const s=typeof t=="string"?{stateId:t,limit:"all"}:{limit:"all",...t};return(await Re.getDistricts(s)).data},getAreas:async t=>(await Re.getAreas(t)).data,updateArea:async(t,s)=>(await Re.updateArea(t,s)).data,createArea:async t=>(await Re.createArea(t)).data,deleteArea:async t=>(await Re.deleteArea(t)).data,getAreaManagers:async()=>(await Re.getAreaManagers()).data,getASMs:async()=>(await Re.getASMs()).data,getZonalManagers:async()=>(await Re.getZonalManagers()).data,saveZonalManager:async t=>Re.saveZonalManager(t).then(s=>s.data),getDDLeads:async()=>(await Re.getDDLeads()).data,saveDDLead:async t=>Re.saveDDLead(t).then(s=>s.data),getUsers:async()=>(await Re.getUsers()).data,updateUser:async(t,s)=>(await Re.updateUser(t,s)).data,getEmailTemplates:async()=>(await Re.getEmailTemplates()).data,getEmailTemplate:async t=>(await Re.getEmailTemplate(t)).data,createEmailTemplate:async t=>(await Re.createEmailTemplate(t)).data,updateEmailTemplate:async(t,s)=>(await Re.updateEmailTemplate(t,s)).data,deleteEmailTemplate:async t=>(await Re.deleteEmailTemplate(t)).data,previewEmailTemplate:async t=>(await Re.previewEmailTemplate(t)).data,getSlaConfigs:async()=>(await Re.getSlaConfigs()).data,saveSlaConfig:async t=>(await Re.saveSlaConfig(t)).data,initializeDefaultSlas:async()=>(await Re.initializeDefaultSlas()).data,saveZone:async t=>t.id?$s.updateZone(t.id,t):$s.createZone(t),saveRegion:async t=>t.id?$s.updateRegion(t.id,t):$s.createRegion(t),saveASM:async t=>Re.updateUser(t.userId,t).then(s=>s.data),getSystemConfigs:async t=>(await Re.getSystemConfigs(t)).data,saveSystemConfig:async t=>(await Re.saveSystemConfig(t)).data,getDealerAsmMappings:async()=>(await Re.getDealerAsmMappings()).data,saveDealerAsmMapping:async t=>(await Re.saveDealerAsmMapping(t)).data};function OM({onAdminLogin:t}){const[s,n]=g.useState({country:"India",stateId:"",districtId:"",name:"",interestedCity:"",email:"",pincode:"",mobile:"",ownRoyalEnfield:"",royalEnfieldModel:"",age:"",education:"",companyName:"",source:"",existingDealer:"",description:"",address:"",acceptTerms:!1}),[r,a]=g.useState(!1),[i,o]=g.useState([]),[d,m]=g.useState([]);g.useEffect(()=>{f()},[]);const f=async()=>{try{const C=await $s.getStates(),S=Array.isArray(C)?C:(C==null?void 0:C.data)||(C==null?void 0:C.states)||[];o(S)}catch(C){console.error("Error fetching states:",C)}},p=async C=>{if(C){n(S=>({...S,stateId:C,districtId:""})),m([]);try{const S=await $s.getDistricts(C),D=Array.isArray(S)?S:(S==null?void 0:S.data)||(S==null?void 0:S.districts)||[];m(D)}catch(S){console.error("Error fetching districts:",S)}}},h=C=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(C),x=C=>/^[0-9]{10}$/.test(C),u=C=>/^[0-9]{6}$/.test(C),N=!!(s.country&&s.stateId&&s.districtId&&s.name&&s.interestedCity&&s.email&&s.pincode&&s.mobile&&s.ownRoyalEnfield&&s.age&&s.education&&s.companyName&&s.source&&s.existingDealer&&s.description&&s.address&&s.acceptTerms&&r&&h(s.email)&&x(s.mobile)&&u(s.pincode)&&(s.ownRoyalEnfield==="no"||s.ownRoyalEnfield==="yes"&&s.royalEnfieldModel)),v=()=>{if(!s.mobile||s.mobile.length<10){J.error("Please enter a valid mobile number");return}J.success("OTP sent to "+s.mobile),setTimeout(()=>{a(!0),J.success("Mobile number verified")},1500)},w=async C=>{var S,D;if(C.preventDefault(),!s.country||!s.stateId||!s.districtId||!s.name||!s.interestedCity||!s.email||!s.pincode||!s.mobile||!s.ownRoyalEnfield||!s.age||!s.education||!s.companyName||!s.source||!s.existingDealer||!s.description||!s.address){J.error("Please fill in all required fields");return}if(!r){J.error("Please verify your mobile number");return}if(s.ownRoyalEnfield==="yes"&&!s.royalEnfieldModel){J.error("Please select your motorcycle model");return}if(!s.acceptTerms){J.error("Please accept the terms and conditions");return}try{const _=i.find(R=>R.id===s.stateId),A=d.find(R=>R.id===s.districtId),E=(_==null?void 0:_.name)||(_==null?void 0:_.stateName)||"",q=(A==null?void 0:A.name)||(A==null?void 0:A.districtName)||"",O={applicantName:s.name,email:s.email,phone:s.mobile,state:E,city:s.interestedCity,district:q,preferredLocation:`${s.interestedCity}, ${E}`,businessType:"Dealership",locationType:"district",locationId:s.districtId,address:s.address,pincode:s.pincode,age:s.age,education:s.education,companyName:s.companyName,source:s.source,existingDealer:s.existingDealer==="yes",ownRoyalEnfield:s.ownRoyalEnfield==="yes",royalEnfieldModel:s.royalEnfieldModel,description:s.description,experienceYears:0,investmentCapacity:"Unknown"};await ps.submitApplication(O),J.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(_){J.error(((D=(S=_.response)==null?void 0:S.data)==null?void 0:D.message)||"Failed to submit application.")}},j=["Continental GT","Interceptor 650","Himalayan","Classic 350","Classic 500","Thunderbird 350","Thunderbird 500","Thunderbird X 350","Thunderbird X 500","Bullet 350","Bullet 500","Bullet ES","Bullet Trials 350","Bullet Trials 500","Other Royal Enfield motorcycle"],b=["Existing RE dealer","Customer","RE Employee","News Paper","Website","Friends","Others"];return e.jsxs("div",{className:"min-h-screen relative flex flex-col",children:[e.jsxs("div",{className:"fixed inset-0 z-0",children:[e.jsx("img",{src:"/assets/images/become_a_dealer.webp",alt:"Royal Enfield Background",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/20"})]}),e.jsxs("nav",{className:"relative z-10 bg-black px-6 md:px-12 py-4 flex items-center justify-between border-b border-white/10",children:[e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"h-10 md:h-12 w-auto"}),e.jsxs(te,{variant:"ghost",onClick:t,className:"text-[10px] uppercase tracking-widest font-bold text-slate-400 hover:text-white transition-colors",children:[e.jsx(HI,{className:"w-3.5 h-3.5 mr-2"}),"Login"]})]}),e.jsx("main",{className:"relative z-10 flex-grow flex flex-col items-center pt-24 pb-24 px-6",children:e.jsxs("div",{className:"w-full max-w-[1240px] bg-white shadow-2xl p-8 md:p-16",children:[e.jsxs("section",{className:"text-[#333333] mb-12",children:[e.jsx("h1",{className:"text-[28px] font-bold mb-8 uppercase tracking-wide text-black",children:"Become a Dealer"}),e.jsxs("div",{className:"space-y-6 text-[15px] leading-relaxed",children:[e.jsx("p",{children:"At Royal Enfield, we endeavour to partner our patrons and customers in their journeys of exploration. Our main objective is to provide an immersive brand and retail experience in addition to ensuring a superior product experience. Our dealers, distributors and network teams are our extended partners in this task."}),e.jsx("p",{children:"Royal Enfield employs a comprehensive and professional process for Dealership allotment. Dealer selection is done based on a variety of criteria including a personal meeting with the applicant. It is only post completion of the evaluation and selection process, that other formalities are considered."}),e.jsx("p",{children:"Royal Enfield does not accept or demand money / deposits from prospective partners prior to processing the application or candidature of the Dealership."}),e.jsxs("p",{children:["If you receive any communication offering allotment of Royal Enfield Dealership against payment / transfer of money and / or otherwise, we advise you to seek information / clarifications by writing to us at ",e.jsx("b",{children:e.jsx("a",{href:"mailto:support@royalenfield.com",className:"text-red-600",children:"support@royalenfield.com"})})," or by contacting us on our customer care toll-free number ",e.jsx("b",{children:e.jsx("a",{href:"tel:18002100008",className:"text-red-600",children:"1800 210 0008"})}),"."]}),e.jsx("p",{className:"font-bold py-1 mt-8 text-black text-[15px]",children:"*This is the ONLY official website and central number for dealership enquiries for Royal Enfield and we do not have any other partner website(s)."})]})]}),e.jsxs("form",{onSubmit:w,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("select",{className:"w-full h-[44px] px-4 border border-[#cccccc] appearance-none bg-white text-[14px] outline-none",value:s.country,onChange:C=>n({...s,country:C.target.value}),children:[e.jsx("option",{value:"India",children:"India"}),e.jsx("option",{value:"Other",children:"Others"})]}),e.jsx(va,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{className:"w-full h-[44px] px-4 border border-[#cccccc] appearance-none bg-white text-[14px] outline-none",value:s.stateId,onChange:C=>p(C.target.value),children:[e.jsx("option",{value:"",children:"Select State*"}),i.map(C=>e.jsx("option",{value:C.id,children:C.name||C.stateName},C.id))]}),e.jsx(va,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{className:"w-full h-[44px] px-4 border border-[#cccccc] appearance-none bg-white text-[14px] outline-none",value:s.districtId,onChange:C=>n({...s,districtId:C.target.value}),children:[e.jsx("option",{value:"",children:"Select District*"}),d.map(C=>e.jsx("option",{value:C.id,children:C.name||C.districtName},C.id))]}),e.jsx(va,{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(it,{placeholder:"Name*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.name,onChange:C=>n({...s,name:C.target.value})}),e.jsx(it,{placeholder:"Interested city for Dealership*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.interestedCity,onChange:C=>n({...s,interestedCity:C.target.value})}),e.jsx(it,{type:"email",placeholder:"Email Id*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.email,onChange:C=>n({...s,email:C.target.value})}),e.jsx(it,{type:"text",maxLength:6,placeholder:"Pincode*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.pincode,onChange:C=>{const S=C.target.value.replace(/\D/g,"");n({...s,pincode:S})}}),e.jsxs("div",{className:"relative",children:[e.jsx(it,{type:"text",maxLength:10,placeholder:"Mobile No.*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.mobile,onChange:C=>{const S=C.target.value.replace(/\D/g,"");n({...s,mobile:S})}}),r?e.jsx("span",{className:"absolute right-4 top-1/2 -translate-y-1/2 text-[12px] font-bold text-green-600",children:"Verified"}):e.jsx("button",{type:"button",onClick:v,className:"absolute right-4 top-1/2 -translate-y-1/2 text-[12px] font-bold text-red-600 hover:text-black transition-colors",children:"Verify"})]}),e.jsxs("div",{className:"flex items-center gap-10 h-[44px]",children:[e.jsxs("span",{className:"text-[14px] font-medium text-[#333333]",children:["Own a Royal Enfield? ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"flex gap-8",children:["yes","no"].map(C=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("div",{className:`w-5 h-5 rounded-full border flex items-center justify-center ${s.ownRoyalEnfield===C?"border-red-600":"border-[#cccccc]"}`,children:s.ownRoyalEnfield===C&&e.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-600"})}),e.jsx("input",{type:"radio",className:"hidden",checked:s.ownRoyalEnfield===C,onChange:()=>{n({...s,ownRoyalEnfield:C,royalEnfieldModel:C==="no"?"":s.royalEnfieldModel})}}),e.jsx("span",{className:"text-[14px] capitalize",children:C})]},C))})]}),e.jsx(it,{placeholder:"Age*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.age,onChange:C=>n({...s,age:C.target.value})}),s.ownRoyalEnfield==="yes"&&e.jsxs("div",{className:"relative",children:[e.jsxs("select",{className:"w-full h-[44px] px-4 border border-[#cccccc] appearance-none bg-white text-[14px] outline-none",value:s.royalEnfieldModel,onChange:C=>n({...s,royalEnfieldModel:C.target.value}),children:[e.jsx("option",{value:"",children:"Select Motorcycle*"}),j.map(C=>e.jsx("option",{value:C,children:C},C))]}),e.jsx(va,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"})]}),e.jsx(it,{placeholder:"Education Qualification*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.education,onChange:C=>n({...s,education:C.target.value})}),e.jsx(it,{placeholder:"Company Name*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.companyName,onChange:C=>n({...s,companyName:C.target.value})}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{className:"w-full h-[44px] px-4 border border-[#cccccc] appearance-none bg-white text-[14px] outline-none",value:s.source,onChange:C=>n({...s,source:C.target.value}),children:[e.jsx("option",{value:"",children:"Select Source*"}),b.map(C=>e.jsx("option",{value:C,children:C},C))]}),e.jsx(va,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"})]}),e.jsxs("div",{className:"flex flex-col justify-center h-auto min-h-[44px] space-y-1",children:[e.jsxs("span",{className:"text-[13px] font-medium text-[#333333]",children:["Are you an existing Dealer / Vendor of Royal Enfield? ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"flex gap-8",children:["yes","no"].map(C=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("div",{className:`w-5 h-5 rounded-full border flex items-center justify-center ${s.existingDealer===C?"border-red-600":"border-[#cccccc]"}`,children:s.existingDealer===C&&e.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-600"})}),e.jsx("input",{type:"radio",className:"hidden",checked:s.existingDealer===C,onChange:()=>n({...s,existingDealer:C})}),e.jsx("span",{className:"text-[14px] capitalize",children:C})]},C))})]})]}),e.jsxs("div",{className:"space-y-6 pt-4",children:[e.jsx(Ks,{placeholder:"Description*",className:"min-h-[120px] border-[#cccccc] rounded-none px-4 py-3 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999] resize-none",value:s.description,onChange:C=>n({...s,description:C.target.value})}),e.jsx(Ks,{placeholder:"Address*",className:"min-h-[120px] border-[#cccccc] rounded-none px-4 py-3 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999] resize-none",value:s.address,onChange:C=>n({...s,address:C.target.value})})]}),e.jsxs("div",{className:"pt-6 space-y-8",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("p",{className:"text-[14px] text-[#666666] leading-relaxed",children:["Disclaimer: By signing this form/checking this box, you acknowledge and agree that we may use the information you share with us, to communicate with you through e-mails, text messages, WhatsApp and calls, in order to provide our product or service related information and/or for promotional and marketing purposes. All information provided will be secured and processed as per our ",e.jsx("b",{children:"privacy policy"}),"."]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Tn,{id:"terms",className:"w-5 h-5 border-[#cccccc] rounded-none data-[state=checked]:bg-black data-[state=checked]:border-black",checked:s.acceptTerms,onCheckedChange:C=>n({...s,acceptTerms:C})}),e.jsxs("label",{htmlFor:"terms",className:"text-[14px] font-medium cursor-pointer",children:["I accept the ",e.jsx("b",{children:"terms and conditions"})," as well as ",e.jsx("b",{children:"privacy policy"}),".",e.jsx("span",{className:"text-red-500",children:"*"})]})]})]}),e.jsxs("button",{type:"submit",disabled:!N,className:"h-12 px-10 bg-black text-white flex items-center gap-3 hover:bg-slate-900 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("span",{className:"font-bold uppercase tracking-wider text-[14px]",children:"Submit"}),e.jsx(mi,{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 LM=()=>{const{applicationId:t}=gd(),s=tr(),{user:n}=Pn(A=>A.auth),[r,a]=g.useState(!0),[i,o]=g.useState([]),[d,m]=g.useState([]),[f,p]=g.useState(""),[h,x]=g.useState({}),[u,N]=g.useState(!1),[v,w]=g.useState("none");g.useEffect(()=>{(async()=>{var E,q;if(t)try{const O=await Re.getPublicQuestionnaire(t);if(O.data.success){const R=O.data.data.questions||[];o(R);const P=Array.from(new Set(R.map(L=>L.sectionName)));m(P),P.length>0&&p(P[0])}}catch(O){console.error("Error fetching questionnaire:",O),((q=(E=O.response)==null?void 0:E.data)==null?void 0:q.code)==="ALREADY_SUBMITTED"?w("already"):J.error("Failed to load questionnaire")}finally{a(!1)}})()},[t]);const j=(A,E)=>{x(q=>({...q,[A]:E}))},b=()=>{const A=d.indexOf(f);A{const A=d.indexOf(f);A>0&&(p(d[A-1]),window.scrollTo({top:0,behavior:"smooth"}))},S=async()=>{const A=i.filter(E=>E.isMandatory&&!h[E.id]);if(A.length>0){J.error(`Please answer all mandatory questions. Missing: ${A.length}`);return}try{N(!0);const E=Object.entries(h).map(([q,O])=>({questionId:q,value:O}));await Re.submitPublicResponse({applicationId:t,responses:E}),J.success("Responses submitted successfully"),w("success")}catch(E){console.error(E),J.error("Failed to submit responses")}finally{N(!1)}};if(r)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-slate-50",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-re-red"})});if(v!=="none"){const A=v==="already";return e.jsx("div",{className:"min-h-screen bg-slate-50 flex flex-col items-center justify-center p-6",children:e.jsxs("div",{className:"bg-white p-8 rounded-lg shadow-lg max-w-md w-full text-center border-t-4 border-re-red",children:[e.jsx("div",{className:`w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4 ${A?"bg-slate-100 text-slate-600":"bg-green-100 text-green-600"}`,children:A?e.jsx(qa,{className:"w-8 h-8"}):e.jsx(ln,{className:"w-8 h-8"})}),e.jsx("h2",{className:"text-2xl font-bold mb-2 text-slate-900",children:A?"Already submitted":"Thank you"}),e.jsx("p",{className:"text-slate-600 leading-relaxed",children:A?e.jsx(e.Fragment,{children:"This questionnaire has already been submitted for your application. You do not need to complete it again. If you think this is a mistake, contact support using the same email you used to apply. You may close this page when you are done."}):e.jsx(e.Fragment,{children:"Your assessment has been submitted successfully. We have received your responses and will review them as part of your application. You may close this page when you are done."})})]})})}const D=i.filter(A=>A.sectionName===f),_=d.indexOf(f);return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden h-screen bg-slate-50",children:[e.jsx("header",{className:"bg-white border-b border-slate-200 px-6 py-4 flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 font-bold text-xl",children:"Dealer Questionnaire Form"}),e.jsx("p",{className:"text-slate-600 text-sm max-w-2xl leading-snug",children:"Answer each section accurately. Your responses are part of the dealership application assessment and may be verified."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[n&&e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-slate-100 rounded-lg",children:[e.jsx("div",{className:"w-8 h-8 bg-re-red rounded-full flex items-center justify-center",children:e.jsx(Rr,{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(or,{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(ok,{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(Wr,{className:"w-4 h-4"}),"Back to Applicant Portal"]})})}),e.jsxs("div",{className:"max-w-5xl mx-auto py-8 px-6",children:[e.jsxs("div",{className:"bg-re-black rounded-t-lg overflow-hidden shadow-xl",children:[e.jsx("div",{className:"relative px-8 py-12",children:e.jsxs("div",{className:"relative z-10 text-center",children:[e.jsx("div",{className:"flex items-center justify-center mb-7",children:e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"h-12 w-auto"})}),e.jsx("div",{className:"h-1 w-24 bg-re-red mx-auto mb-4"}),e.jsx("h2",{className:"text-re-red text-xl mb-4 font-light",children:"Dealership Partner Application"}),e.jsx("p",{className:"text-slate-300 max-w-2xl mx-auto leading-relaxed text-sm",children:"Thank you for your interest in becoming a Royal Enfield business partner. Please complete this questionnaire to help us understand your profile and aspirations."}),e.jsxs("div",{className:"flex items-center justify-center gap-8 mt-8 border-t border-slate-700/50 pt-6 inline-flex mx-auto",children:[e.jsxs("div",{className:"text-center px-4",children:[e.jsx("div",{className:"text-re-red text-2xl font-bold",children:i.length}),e.jsx("div",{className:"text-slate-400 text-xs uppercase tracking-wider",children:"Questions"})]}),e.jsx("div",{className:"h-10 w-px bg-slate-700"}),e.jsxs("div",{className:"text-center px-4",children:[e.jsx("div",{className:"text-re-red text-2xl font-bold",children:d.length}),e.jsx("div",{className:"text-slate-400 text-xs uppercase tracking-wider",children:"Sections"})]})]})]})}),e.jsx("div",{className:"bg-slate-800/50 backdrop-blur-sm border-t border-slate-700",children:e.jsx("div",{className:"flex items-center gap-2 overflow-x-auto scrollbar-hide px-8 py-4 no-scrollbar",children:d.map(A=>e.jsxs("button",{onClick:()=>p(A),className:`flex items-center gap-2 px-4 py-2 rounded-lg whitespace-nowrap transition-all text-sm font-medium ${f===A?"bg-re-red text-white shadow-lg":"bg-slate-700/50 text-slate-300 hover:bg-slate-700 hover:text-white"}`,children:[e.jsx(ks,{className:"w-4 h-4"}),e.jsx("span",{children:A}),f===A&&e.jsx("span",{className:"ml-2 bg-white/20 px-2 py-0.5 rounded text-xs",children:i.filter(E=>E.sectionName===A).length})]},A))})})]}),e.jsx("div",{className:"bg-white rounded-b-lg shadow-xl border border-slate-200 border-t-0 min-h-[400px]",children:e.jsxs("div",{className:"p-8",children:[e.jsxs("div",{className:"flex items-start gap-4 pb-6 border-b-2 border-red-100 mb-8",children:[e.jsx("div",{className:"w-12 h-12 bg-red-50 rounded-lg flex items-center justify-center flex-shrink-0 text-re-red",children:e.jsx(ja,{className:"w-6 h-6"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-slate-900 text-xl font-bold mb-1",children:f}),e.jsxs("p",{className:"text-slate-500 text-sm",children:["Section ",_+1," of ",d.length," • ",D.length," questions"]})]})]}),e.jsxs("div",{className:"space-y-10",children:[D.map((A,E)=>e.jsx("div",{className:"group animate-in fade-in duration-500",style:{animationDelay:`${E*100}ms`},children:e.jsxs("div",{className:"flex items-start gap-5",children:[e.jsx("div",{className:"w-8 h-8 bg-slate-100 rounded-full flex items-center justify-center flex-shrink-0 group-hover:bg-red-50 transition-colors text-slate-600 group-hover:text-re-red-hover font-semibold text-sm",children:E+1}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"flex items-start justify-between gap-4",children:e.jsxs("label",{className:"text-sm font-medium text-slate-900 leading-relaxed block",children:[A.questionText,A.isMandatory&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]})}),e.jsxs("div",{className:"max-w-xl",children:[(A.inputType==="text"||A.inputType==="email"||A.inputType==="number")&&e.jsx("input",{type:A.inputType,className:"w-full h-10 px-3 rounded-lg border border-slate-300 focus:border-re-red focus:ring-2 focus:ring-red-200 outline-none transition-all placeholder:text-slate-400",placeholder:"Type your answer here...",value:h[A.id]||"",onChange:q=>j(A.id,q.target.value)}),A.inputType==="textarea"&&e.jsx("textarea",{className:"w-full h-32 p-3 rounded-lg border border-slate-300 focus:border-re-red focus:ring-2 focus:ring-red-200 outline-none transition-all placeholder:text-slate-400",placeholder:"Type your answer here...",value:h[A.id]||"",onChange:q=>j(A.id,q.target.value)}),(A.inputType==="select"||A.inputType==="yesno"||A.inputType==="radio"||A.inputType==="mcq")&&e.jsx("div",{className:"space-y-2",children:(A.questionOptions||(A.inputType==="yesno"?[{optionText:"Yes"},{optionText:"No"}]:[])).map((q,O)=>{const R=q.optionText||q.text;return e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer group/opt",children:[e.jsx("input",{type:"radio",name:`q-${A.id}`,className:"w-4 h-4 text-re-red focus:ring-re-red border-slate-300",checked:h[A.id]===R,onChange:()=>j(A.id,R)}),e.jsx("span",{className:"text-slate-700 group-hover/opt:text-slate-900 transition-colors",children:R})]},O)})})]})]})]})},A.id)),D.length===0&&e.jsx("div",{className:"text-center py-10 text-slate-500 italic",children:"No questions in this section."})]}),e.jsxs("div",{className:"flex items-center justify-between pt-10 mt-10 border-t border-slate-100",children:[e.jsx("button",{onClick:C,disabled:_===0,className:"px-6 py-2.5 rounded-lg text-sm font-medium border border-slate-300 text-slate-700 hover:bg-slate-50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Previous Section"}),_{const n=Hu(`Primitive.${s}`),r=g.forwardRef((a,i)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),FM="Label",fk=g.forwardRef((t,s)=>e.jsx(MM.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())}}));fk.displayName=FM;var BM=fk;function le({className:t,...s}){return e.jsx(BM,{"data-slot":"label",className:Nt("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...s})}const $M=[{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"}],Ci={totalApplications:0,loaIssued:0,level1Pending:0,level2Pending:0,level3Pending:0,eorInProgress:0,disqualified:0,pendingReminders:0,shortlistedToday:0,pendingShortlisting:0},qM=[];function _1({onLogin:t}){const[s,n]=g.useState(""),[r,a]=g.useState(""),[i,o]=g.useState(!1),[d,m]=g.useState(""),[f,p]=g.useState(!1),[h,x]=g.useState(!1),[u,N]=g.useState(!1),[v,w]=g.useState(null),j=async(D,_)=>{try{if(navigator.clipboard&&navigator.clipboard.writeText){await navigator.clipboard.writeText(D),w(_),setTimeout(()=>w(null),2e3);return}}catch{}try{const A=document.createElement("textarea");A.value=D,A.style.position="fixed",A.style.left="-999999px",A.style.top="-999999px",document.body.appendChild(A),A.focus(),A.select();const E=document.execCommand("copy");document.body.removeChild(A),E&&(w(_),setTimeout(()=>w(null),2e3))}catch{}},b=async(D,_)=>{var A,E;n(D),a(_),m(""),x(!0);try{await t(D,_)}catch(q){const O=((E=(A=q.response)==null?void 0:A.data)==null?void 0:E.message)||q.message||"Auto-login failed";m(O),J.error(O)}finally{x(!1)}},C=async D=>{var _,A;if(D.preventDefault(),!h){if(m(""),!s||!r){m("Please enter both email and password");return}x(!0);try{await t(s,r)}catch(E){const q=((A=(_=E.response)==null?void 0:_.data)==null?void 0:A.message)||E.message||"Login failed";m(q),J.error(q)}finally{x(!1)}}},S=D=>{D.preventDefault(),alert("Password reset link sent to "+s),p(!1)};return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-black p-4 overflow-y-auto",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute -top-40 -right-40 w-80 h-80 bg-red-700/15 rounded-full blur-3xl"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-80 h-80 bg-red-700/15 rounded-full blur-3xl"})]}),e.jsxs("div",{className:"relative w-full max-w-6xl grid md:grid-cols-2 gap-8 my-8",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"h-16 w-auto object-contain"})}),e.jsx("p",{className:"text-slate-400",children:"Dealership Onboarding System"})]}),e.jsx("div",{className:"bg-white rounded-lg shadow-2xl p-8",children:f?e.jsxs("form",{onSubmit:S,className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"mb-2",children:"Reset Password"}),e.jsx("p",{className:"text-slate-600",children:"Enter your email to receive a password reset link"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"reset-email",children:"Email Address"}),e.jsx(it,{id:"reset-email",type:"email",placeholder:"you@royalenfield.com",value:s,onChange:D=>n(D.target.value),required:!0,className:"w-full"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{type:"button",variant:"outline",onClick:()=>p(!1),className:"flex-1",children:"Back to Login"}),e.jsx(te,{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(le,{htmlFor:"email",children:"Email Address"}),e.jsx(it,{id:"email",type:"email",placeholder:"you@royalenfield.com",value:s,onChange:D=>n(D.target.value),className:"w-full",disabled:h})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(it,{id:"password",type:u?"text":"password",placeholder:"Enter your password",value:r,onChange:D=>a(D.target.value),className:"no-native-password-reveal w-full pr-10",autoComplete:"current-password",disabled:h}),e.jsx("button",{type:"button",onClick:()=>N(!u),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 focus:outline-none",disabled:h,children:u?e.jsx(II,{className:"w-5 h-5"}):e.jsx(un,{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(Tn,{id:"remember",checked:i,onCheckedChange:D=>o(D),disabled:h}),e.jsx(le,{htmlFor:"remember",className:"cursor-pointer",children:"Remember Me"})]}),e.jsx("button",{type:"button",onClick:()=>p(!0),className:"text-re-red hover:text-re-red-hover disabled:opacity-50",disabled:h,children:"Forgot Password?"})]}),d&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-md",children:[e.jsx(sn,{className:"w-4 h-4 text-red-600"}),e.jsx("span",{className:"text-red-600 font-medium text-sm",children:d})]}),e.jsx(te,{type:"submit",className:"w-full bg-re-red hover:bg-re-red-hover h-11 text-white",disabled:h,children:h?e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),e.jsx("span",{children:"Logging in..."})]}):"Login"}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"relative my-4",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-slate-200"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-white px-2 text-slate-500",children:"Or"})})]}),e.jsx(te,{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:$M.map((D,_)=>e.jsxs("div",{className:"border border-slate-200 rounded-lg p-4 hover:border-re-red hover:bg-red-50 transition-all cursor-pointer",onClick:()=>b(D.email,D.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:D.role})}),e.jsx("p",{className:"text-slate-900",children:D.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:D.email})]}),e.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),j(D.email,_*2)},className:"p-2 hover:bg-slate-100 rounded",children:v===_*2?e.jsx($n,{className:"w-4 h-4 text-green-600"}):e.jsx(C1,{className:"w-4 h-4 text-slate-400"})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-slate-500",children:"Password:"}),e.jsx("p",{className:"text-slate-900 font-mono",children:D.password})]}),e.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),j(D.password,_*2+1)},className:"p-2 hover:bg-slate-100 rounded",children:v===_*2+1?e.jsx($n,{className:"w-4 h-4 text-green-600"}):e.jsx(C1,{className:"w-4 h-4 text-slate-400"})})]})]}),e.jsx("div",{className:"mt-3 pt-3 border-t border-slate-200",children:e.jsxs("p",{className:"text-re-red text-center",children:["Click to login as ",D.role]})})]},D.email))})]})]})]})}function zM(){const t=tr(),s=Lu(),[n,r]=g.useState("PHONE"),[a,i]=g.useState(""),[o,d]=g.useState(""),[m,f]=g.useState(!1),[p,h]=g.useState(""),x=async N=>{var v;if(N.preventDefault(),!a||a.length<10){h("Please enter a valid 10-digit phone number");return}f(!0),h("");try{const w=await Re.sendOtp(a);if(w.ok)r("OTP"),J.success("OTP sent successfully!");else{console.error("Send OTP error response:",w);const j=((v=w.data)==null?void 0:v.message)||"Failed to send OTP";h(j),J.error(j)}}catch(w){console.error("Send OTP network error:",w),h("Network error. Please try again."),J.error("Network error. Please try again.")}finally{f(!1)}},u=async N=>{var v;if(N.preventDefault(),!o||o.length<6){h("Please enter a valid 6-digit OTP");return}f(!0),h("");try{const w=await Re.verifyOtp(a,o);if(w.ok&&w.data){const{token:j,user:b}=w.data.data||w.data;if(!j||!b)throw new Error("Invalid response format");s(wA({user:b,token:j})),localStorage.setItem("token",j),J.success("Logged in successfully!"),t("/prospective-dashboard")}else{const j=((v=w.data)==null?void 0:v.message)||"Invalid OTP";h(j),J.error(j)}}catch(w){console.error("Verify OTP error:",w),h("An unexpected error occurred"),J.error("An unexpected error occurred")}finally{f(!1)}};return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 p-4 overflow-y-auto",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute -top-40 -right-40 w-80 h-80 bg-re-red/10 rounded-full blur-3xl"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-80 h-80 bg-re-red/10 rounded-full blur-3xl"})]}),e.jsxs("div",{className:"relative w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-20 h-20 bg-re-red rounded-full mb-4",children:e.jsxs("svg",{viewBox:"0 0 24 24",className:"w-12 h-12 text-white",fill:"currentColor",children:[e.jsx("path",{d:"M12 2L4 6v6c0 5.5 3.8 10.7 8 12 4.2-1.3 8-6.5 8-12V6l-8-4zm0 2.2l6 3v4.8c0 4.5-3.1 8.7-6 10-2.9-1.3-6-5.5-6-10V7.2l6-3z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),e.jsx("h1",{className:"text-white mb-2",children:"Royal Enfield"}),e.jsx("p",{className:"text-slate-400",children:"Dealer Login"})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow-2xl p-8",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs(te,{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(Wr,{className:"w-4 h-4"}),n==="OTP"?"Change Phone Number":"Back to Login"]}),e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"p-2 bg-red-50 rounded-lg",children:e.jsx(XI,{className:"w-6 h-6 text-re-red"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-slate-900 text-lg font-semibold",children:"Dealer Login"}),e.jsx("p",{className:"text-slate-600 text-sm",children:"Login with your registered phone number"})]})]})]}),n==="PHONE"?e.jsxs("form",{onSubmit:x,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"phone",children:"Registered Phone Number"}),e.jsx(it,{id:"phone",type:"tel",placeholder:"Enter 10-digit phone number",maxLength:10,value:a,onChange:N=>i(N.target.value.replace(/\D/g,"")),className:"w-full",disabled:m}),e.jsx("p",{className:"text-slate-500 text-xs",children:"Enter the phone number you used during application"})]}),p&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-md",children:[e.jsx(sn,{className:"w-4 h-4 text-red-600"}),e.jsx("span",{className:"text-red-600 font-medium text-sm",children:p})]}),e.jsx(te,{type:"submit",className:"w-full bg-re-red hover:bg-re-red-hover h-9",disabled:m||a.length<10,children:m?"Sending...":"Send OTP"}),e.jsx("div",{className:"text-center text-slate-500 text-xs",children:e.jsx("p",{children:"You will receive a 6-digit OTP on your registered mobile number"})})]}):e.jsxs("form",{onSubmit:u,className:"space-y-6",children:[e.jsx("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:e.jsxs("p",{className:"text-green-800 text-center text-sm",children:["OTP sent to +91 ",a]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"otp",children:"Enter OTP"}),e.jsx(it,{id:"otp",type:"text",placeholder:"Enter 6-digit OTP",maxLength:6,value:o,onChange:N=>d(N.target.value.replace(/\D/g,"")),className:"w-full text-center text-2xl tracking-widest",disabled:m}),e.jsx("p",{className:"text-slate-500 text-xs text-center",children:"Check your SMS for the OTP"})]}),p&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-md",children:[e.jsx(sn,{className:"w-4 h-4 text-red-600"}),e.jsx("span",{className:"text-red-600 font-medium text-sm",children:p})]}),e.jsx(te,{type:"submit",className:"w-full bg-re-red hover:bg-re-red-hover h-9",disabled:m||o.length<6,children:m?"Verifying...":"Verify OTP"}),e.jsxs("div",{className:"text-center text-sm",children:[e.jsx("button",{type:"button",className:"text-re-red hover:text-re-red-hover font-medium",onClick:()=>r("PHONE"),children:"Change Phone Number"}),e.jsx("span",{className:"mx-2 text-slate-400",children:"|"}),e.jsx("button",{type:"button",className:"text-re-red hover:text-re-red-hover font-medium",onClick:x,disabled:m,children:"Resend OTP"})]})]})]}),e.jsx("div",{className:"text-center mt-6 text-slate-400",children:e.jsx("p",{children:"© 2025 Royal Enfield. All rights reserved."})})]})]})}function UM({onLogout:t}){const s=tr(),r=xl().pathname.substring(1)||"dashboard",{user:a}=Pn(L=>L.auth),[i,o]=g.useState(!1),[d,m]=g.useState(""),[f,p]=g.useState(!1),[h,x]=g.useState(!1),[u,N]=g.useState(null),v=g.useRef(null),w=L=>{const $=L.map(W=>W.toLowerCase()),Z=String((a==null?void 0:a.role)||"").toLowerCase(),Q=String((a==null?void 0:a.roleCode)||"").toLowerCase();return $.includes(Z)||$.includes(Q)},j=["DD Admin","DD_ADMIN","ASM","RBM","DD-ZM","DD_ZM","DD Lead","DD_LEAD","DD Head","DD_HEAD","ZBH","NBH","Legal","Legal Admin","LEGAL_ADMIN","Super Admin","SUPER_ADMIN"],b=["ASM","RBM","DD-ZM","DD_ZM","ZBH","DD Lead","DD_LEAD","DD Head","DD_HEAD","NBH","Legal Admin","LEGAL_ADMIN","Legal","DD Admin","DD_ADMIN","CCO","CEO","Super Admin","SUPER_ADMIN"],C=["DD Admin","DD_ADMIN","DD-ZM","DD_ZM","DD Lead","DD_LEAD","DD Head","DD_HEAD","NBH","Finance","Finance Admin","FINANCE_ADMIN","Super Admin","SUPER_ADMIN"],S=w(j),D=w(b),_=w(C),A=[S?{id:"resignation",label:"Resignation"}:null,D?{id:"termination",label:"Termination"}:null,_?{id:"fnf",label:"F&F"}:null].filter(Boolean),E=w(["Finance","Finance Admin"])?[{id:"dashboard",label:"Dashboard",icon:um},{id:"finance-onboarding",label:"Onboarding",icon:ks},{id:"finance-fnf",label:"F&F",icon:xg}]:w(["Dealer"])?[{id:"dashboard",label:"Dashboard",icon:um},{id:"dealer-resignation",label:"My Resignations",icon:xg},{id:"dealer-constitutional",label:"Constitutional Change",icon:cl},{id:"dealer-relocation",label:"Relocation Requests",icon:Mr}]:w(["FDD"])?[{id:"fdd-dashboard",label:"FDD Dashboard",icon:um}]:[{id:"dashboard",label:"Dashboard",icon:um},{id:"applications",label:"Dealership Requests",icon:ks},...A.length>0?[{id:"offboarding",label:"Offboarding",icon:xg,hasSubmenu:!0,submenuKey:"offboarding",submenu:A}]:[],{id:"constitutional-change",label:"Constitutional Change",icon:cl},{id:"relocation-requests",label:"Relocation Requests",icon:Mr}];w(["DD Lead","DD Admin","Super Admin"])&&E.splice(1,0,{id:"all-requests",label:"All Requests",icon:BI,hasSubmenu:!0,submenuKey:"allRequests",submenu:[{id:"opportunity-requests",label:"Opportunity Requests"},{id:"non-opportunities",label:"Non-opportunities"}]}),w(["Super Admin","DD Admin","DD Lead"])&&(E.push({id:"master",label:"Master",icon:Qc}),E.push({id:"sla-configurations",label:"SLA Matrix",icon:cl})),w(["Super Admin"])&&(E.push({id:"users",label:"User Management",icon:ja}),E.push({id:"questionnaires",label:"Questionnaire Templates",icon:sc}),E.push({id:"interview-configs",label:"Interview Configs",icon:VI}),E.push({id:"system-logs",label:"System Logs",icon:rd}));const q=L=>{L.preventDefault(),d.trim()&&s("/applications")},O=g.useCallback((L,$)=>{v.current&&clearTimeout(v.current);const Z=$.getBoundingClientRect();N({submenuKey:L,top:Z.top,left:Z.right+8})},[]),R=g.useCallback((L=!1)=>{L?(v.current&&clearTimeout(v.current),N(null)):v.current=setTimeout(()=>N(null),150)},[]),P=g.useCallback(()=>{v.current&&clearTimeout(v.current)},[]);return g.useEffect(()=>{i||N(null)},[i]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`bg-black text-white h-screen flex flex-col transition-all duration-300 overflow-hidden relative flex-shrink-0 ${i?"w-20":"w-64"}`,children:[e.jsx("div",{className:"border-b border-white/10",children:i?e.jsxs("div",{className:"flex flex-col items-center py-3 gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-white flex items-center justify-center p-1 shadow-md",children:e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"RE",className:"w-full h-full object-contain"})}),e.jsx("button",{onClick:()=>o(!1),className:"p-1.5 hover:bg-white/10 rounded-lg transition-colors text-slate-400 hover:text-white",title:"Expand sidebar",children:e.jsx(mi,{className:"w-4 h-4"})})]}):e.jsxs("div",{className:"flex items-center justify-between px-4 py-4",children:[e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"h-6 w-auto"}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.2em] font-bold text-slate-400 mt-1 whitespace-nowrap",children:"Dealer Network"})]}),e.jsx("button",{onClick:()=>o(!0),className:"p-1.5 hover:bg-white/10 rounded-lg transition-colors text-slate-400 hover:text-white flex-shrink-0 ml-2",title:"Collapse sidebar",children:e.jsx(io,{className:"w-4 h-4"})})]})}),!i&&e.jsx("div",{className:"p-4 border-b border-white/10",children:e.jsxs("form",{onSubmit:q,className:"relative",children:[e.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(it,{type:"text",placeholder:"Search applications...",value:d,onChange:L=>m(L.target.value),className:"w-full pl-10 bg-white/5 border-white/10 text-white placeholder:text-slate-500"})]})}),e.jsx("nav",{className:"flex-1 p-3 space-y-1 overflow-y-auto custom-scrollbar",children:E.map(L=>{var z,T;const $=L.icon,Z=r===L.id,Q=!!L.hasSubmenu,W=Q&&((z=L.submenu)==null?void 0:z.some(F=>r===F.id)),U=L.submenuKey,M=U==="offboarding"?f:U==="allRequests"?h:!1;return e.jsxs("div",{children:[e.jsxs("button",{onMouseEnter:F=>{i&&Q&&U&&O(U,F.currentTarget)},onMouseLeave:()=>{i&&Q&&R()},onClick:()=>{Q?i?(o(!1),U==="offboarding"?p(!0):U==="allRequests"&&x(!0)):U==="offboarding"?p(!f):U==="allRequests"&&x(!h):s(`/${L.id}`)},className:`w-full flex items-center gap-3 px-3 py-3 rounded-lg transition-colors ${i?"justify-center":""} ${Z||W?"bg-re-red text-white shadow-lg shadow-re-red/20":"text-slate-400 hover:bg-white/5 hover:text-white"}`,title:i?L.label:void 0,children:[e.jsx($,{className:"w-5 h-5 flex-shrink-0"}),!i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-left text-sm",children:L.label}),Q&&(M?e.jsx(yu,{className:"w-4 h-4 flex-shrink-0"}):e.jsx(va,{className:"w-4 h-4 flex-shrink-0"}))]})]}),Q&&M&&!i&&e.jsx("div",{className:"ml-3 mt-1 space-y-1 border-l border-white/10 pl-3",children:(T=L.submenu)==null?void 0:T.map(F=>{const I=r===F.id;return e.jsxs("button",{onClick:()=>s(`/${F.id}`),className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg transition-colors text-sm ${I?"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:F.label})]},F.id)})})]},L.id)})}),e.jsxs("div",{className:"p-4 border-t border-white/10 space-y-2",children:[!i&&a&&e.jsx("div",{className:"px-4 py-2 bg-white/5 rounded-lg mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-re-red rounded-full flex items-center justify-center font-bold flex-shrink-0",children:e.jsx("span",{children:a.name.charAt(0)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold",children:a.name}),e.jsx("p",{className:"text-slate-500 truncate text-[11px] uppercase tracking-wider",children:a.role})]})]})}),i&&a&&e.jsx("div",{className:"flex justify-center mb-2",children:e.jsx("div",{className:"w-9 h-9 bg-re-red rounded-full flex items-center justify-center font-bold text-sm",title:a.name,children:e.jsx("span",{children:a.name.charAt(0)})})}),e.jsxs(te,{onClick:t,variant:"ghost",className:`w-full ${i?"px-2 justify-center":"justify-start"} text-slate-400 hover:bg-white/5 hover:text-white`,title:i?"Logout":void 0,children:[e.jsx(uk,{className:"w-5 h-5 flex-shrink-0"}),!i&&e.jsx("span",{className:"ml-3",children:"Logout"})]})]})]}),u&&i&&(()=>{const L=E.find($=>$.submenuKey===u.submenuKey);return!L||!L.submenu?null:Hy.createPortal(e.jsxs("div",{style:{top:u.top,left:u.left},className:"fixed z-[9999] min-w-[200px] bg-gray-900 border border-white/10 rounded-xl shadow-2xl py-2",onMouseEnter:P,onMouseLeave:()=>R(),children:[e.jsx("div",{className:"px-4 py-1.5 text-xs font-bold uppercase tracking-widest text-slate-400 border-b border-white/10 mb-1",children:L.label}),L.submenu.map($=>{const Z=r===$.id;return e.jsxs("button",{onClick:()=>{s(`/${$.id}`),R(!0)},className:`w-full flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors ${Z?"bg-re-red/20 text-re-red font-semibold":"text-slate-300 hover:bg-white/10 hover:text-white"}`,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current flex-shrink-0"}),e.jsx("span",{children:$.label})]},$.id)})]}),document.body)})()]})}function T1(t){const s=VM(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find(WM);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function VM(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=KM(a),d=GM(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Hr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var HM=Symbol("radix.slottable");function WM(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===HM}function GM(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function KM(t){var r,a;let s=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function rb(t){const s=t+"CollectionProvider",[n,r]=oa(s),[a,i]=n(s,{collectionRef:{current:null},itemMap:new Map}),o=v=>{const{scope:w,children:j}=v,b=Ct.useRef(null),C=Ct.useRef(new Map).current;return e.jsx(a,{scope:w,itemMap:C,collectionRef:b,children:j})};o.displayName=s;const d=t+"CollectionSlot",m=T1(d),f=Ct.forwardRef((v,w)=>{const{scope:j,children:b}=v,C=i(d,j),S=Ys(w,C.collectionRef);return e.jsx(m,{ref:S,children:b})});f.displayName=d;const p=t+"CollectionItemSlot",h="data-radix-collection-item",x=T1(p),u=Ct.forwardRef((v,w)=>{const{scope:j,children:b,...C}=v,S=Ct.useRef(null),D=Ys(w,S),_=i(p,j);return Ct.useEffect(()=>(_.itemMap.set(S,{ref:S,...C}),()=>void _.itemMap.delete(S))),e.jsx(x,{[h]:"",ref:D,children:b})});u.displayName=p;function N(v){const w=i(t+"CollectionConsumer",v);return Ct.useCallback(()=>{const b=w.collectionRef.current;if(!b)return[];const C=Array.from(b.querySelectorAll(`[${h}]`));return Array.from(w.itemMap.values()).sort((_,A)=>C.indexOf(_.ref.current)-C.indexOf(A.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:o,Slot:f,ItemSlot:u},N,r]}var YM=g.createContext(void 0);function Ku(t){const s=g.useContext(YM);return t||s||"ltr"}function xr(t){const s=g.useRef(t);return g.useEffect(()=>{s.current=t}),g.useMemo(()=>(...n)=>{var r;return(r=s.current)==null?void 0:r.call(s,...n)},[])}function ZM(t,s=globalThis==null?void 0:globalThis.document){const n=xr(t);g.useEffect(()=>{const r=a=>{a.key==="Escape"&&n(a)};return s.addEventListener("keydown",r,{capture:!0}),()=>s.removeEventListener("keydown",r,{capture:!0})},[n,s])}var QM="DismissableLayer",ly="dismissableLayer.update",XM="dismissableLayer.pointerDownOutside",JM="dismissableLayer.focusOutside",P1,pk=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),yd=g.forwardRef((t,s)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:d,...m}=t,f=g.useContext(pk),[p,h]=g.useState(null),x=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,u]=g.useState({}),N=Ys(s,A=>h(A)),v=Array.from(f.layers),[w]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),j=v.indexOf(w),b=p?v.indexOf(p):-1,C=f.layersWithOutsidePointerEventsDisabled.size>0,S=b>=j,D=s3(A=>{const E=A.target,q=[...f.branches].some(O=>O.contains(E));!S||q||(a==null||a(A),o==null||o(A),A.defaultPrevented||d==null||d())},x),_=n3(A=>{const E=A.target;[...f.branches].some(O=>O.contains(E))||(i==null||i(A),o==null||o(A),A.defaultPrevented||d==null||d())},x);return ZM(A=>{b===f.layers.size-1&&(r==null||r(A),!A.defaultPrevented&&d&&(A.preventDefault(),d()))},x),g.useEffect(()=>{if(p)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(P1=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(p)),f.layers.add(p),O1(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=P1)}},[p,x,n,f]),g.useEffect(()=>()=>{p&&(f.layers.delete(p),f.layersWithOutsidePointerEventsDisabled.delete(p),O1())},[p,f]),g.useEffect(()=>{const A=()=>u({});return document.addEventListener(ly,A),()=>document.removeEventListener(ly,A)},[]),e.jsx(Ss.div,{...m,ref:N,style:{pointerEvents:C?S?"auto":"none":void 0,...t.style},onFocusCapture:Yt(t.onFocusCapture,_.onFocusCapture),onBlurCapture:Yt(t.onBlurCapture,_.onBlurCapture),onPointerDownCapture:Yt(t.onPointerDownCapture,D.onPointerDownCapture)})});yd.displayName=QM;var e3="DismissableLayerBranch",t3=g.forwardRef((t,s)=>{const n=g.useContext(pk),r=g.useRef(null),a=Ys(s,r);return g.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),e.jsx(Ss.div,{...t,ref:a})});t3.displayName=e3;function s3(t,s=globalThis==null?void 0:globalThis.document){const n=xr(t),r=g.useRef(!1),a=g.useRef(()=>{});return g.useEffect(()=>{const i=d=>{if(d.target&&!r.current){let m=function(){xk(XM,n,f,{discrete:!0})};const f={originalEvent:d};d.pointerType==="touch"?(s.removeEventListener("click",a.current),a.current=m,s.addEventListener("click",a.current,{once:!0})):m()}else s.removeEventListener("click",a.current);r.current=!1},o=window.setTimeout(()=>{s.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),s.removeEventListener("pointerdown",i),s.removeEventListener("click",a.current)}},[s,n]),{onPointerDownCapture:()=>r.current=!0}}function n3(t,s=globalThis==null?void 0:globalThis.document){const n=xr(t),r=g.useRef(!1);return g.useEffect(()=>{const a=i=>{i.target&&!r.current&&xk(JM,n,{originalEvent:i},{discrete:!1})};return s.addEventListener("focusin",a),()=>s.removeEventListener("focusin",a)},[s,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function O1(){const t=new CustomEvent(ly);document.dispatchEvent(t)}function xk(t,s,n,{discrete:r}){const a=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});s&&a.addEventListener(t,s,{once:!0}),r?KA(a,i):a.dispatchEvent(i)}var vg=0;function Bf(){g.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??L1()),document.body.insertAdjacentElement("beforeend",t[1]??L1()),vg++,()=>{vg===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),vg--}},[])}function L1(){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 yg="focusScope.autoFocusOnMount",bg="focusScope.autoFocusOnUnmount",I1={bubbles:!1,cancelable:!0},r3="FocusScope",Yu=g.forwardRef((t,s)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[d,m]=g.useState(null),f=xr(a),p=xr(i),h=g.useRef(null),x=Ys(s,v=>m(v)),u=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let v=function(C){if(u.paused||!d)return;const S=C.target;d.contains(S)?h.current=S:Gl(h.current,{select:!0})},w=function(C){if(u.paused||!d)return;const S=C.relatedTarget;S!==null&&(d.contains(S)||Gl(h.current,{select:!0}))},j=function(C){if(document.activeElement===document.body)for(const D of C)D.removedNodes.length>0&&Gl(d)};document.addEventListener("focusin",v),document.addEventListener("focusout",w);const b=new MutationObserver(j);return d&&b.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",w),b.disconnect()}}},[r,d,u.paused]),g.useEffect(()=>{if(d){F1.add(u);const v=document.activeElement;if(!d.contains(v)){const j=new CustomEvent(yg,I1);d.addEventListener(yg,f),d.dispatchEvent(j),j.defaultPrevented||(a3(d3(gk(d)),{select:!0}),document.activeElement===v&&Gl(d))}return()=>{d.removeEventListener(yg,f),setTimeout(()=>{const j=new CustomEvent(bg,I1);d.addEventListener(bg,p),d.dispatchEvent(j),j.defaultPrevented||Gl(v??document.body,{select:!0}),d.removeEventListener(bg,p),F1.remove(u)},0)}}},[d,f,p,u]);const N=g.useCallback(v=>{if(!n&&!r||u.paused)return;const w=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,j=document.activeElement;if(w&&j){const b=v.currentTarget,[C,S]=i3(b);C&&S?!v.shiftKey&&j===S?(v.preventDefault(),n&&Gl(C,{select:!0})):v.shiftKey&&j===C&&(v.preventDefault(),n&&Gl(S,{select:!0})):j===b&&v.preventDefault()}},[n,r,u.paused]);return e.jsx(Ss.div,{tabIndex:-1,...o,ref:x,onKeyDown:N})});Yu.displayName=r3;function a3(t,{select:s=!1}={}){const n=document.activeElement;for(const r of t)if(Gl(r,{select:s}),document.activeElement!==n)return}function i3(t){const s=gk(t),n=M1(s,t),r=M1(s.reverse(),t);return[n,r]}function gk(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 M1(t,s){for(const n of t)if(!l3(n,{upTo:s}))return n}function l3(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 o3(t){return t instanceof HTMLInputElement&&"select"in t}function Gl(t,{select:s=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&o3(t)&&s&&t.select()}}var F1=c3();function c3(){let t=[];return{add(s){const n=t[0];s!==n&&(n==null||n.pause()),t=B1(t,s),t.unshift(s)},remove(s){var n;t=B1(t,s),(n=t[0])==null||n.resume()}}}function B1(t,s){const n=[...t],r=n.indexOf(s);return r!==-1&&n.splice(r,1),n}function d3(t){return t.filter(s=>s.tagName!=="A")}var u3=wf[" useId ".trim().toString()]||(()=>{}),h3=0;function yr(t){const[s,n]=g.useState(u3());return Jn(()=>{n(r=>r??String(h3++))},[t]),t||(s?`radix-${s}`:"")}const m3=["top","right","bottom","left"],no=Math.min,ga=Math.max,lf=Math.round,mm=Math.floor,Pi=t=>({x:t,y:t}),f3={left:"right",right:"left",bottom:"top",top:"bottom"};function oy(t,s,n){return ga(t,no(s,n))}function hl(t,s){return typeof t=="function"?t(s):t}function ml(t){return t.split("-")[0]}function bd(t){return t.split("-")[1]}function ab(t){return t==="x"?"y":"x"}function ib(t){return t==="y"?"height":"width"}function _i(t){const s=t[0];return s==="t"||s==="b"?"y":"x"}function lb(t){return ab(_i(t))}function p3(t,s,n){n===void 0&&(n=!1);const r=bd(t),a=lb(t),i=ib(a);let o=a==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return s.reference[i]>s.floating[i]&&(o=of(o)),[o,of(o)]}function x3(t){const s=of(t);return[cy(t),s,cy(s)]}function cy(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const $1=["left","right"],q1=["right","left"],g3=["top","bottom"],v3=["bottom","top"];function y3(t,s,n){switch(t){case"top":case"bottom":return n?s?q1:$1:s?$1:q1;case"left":case"right":return s?g3:v3;default:return[]}}function b3(t,s,n,r){const a=bd(t);let i=y3(ml(t),n==="start",r);return a&&(i=i.map(o=>o+"-"+a),s&&(i=i.concat(i.map(cy)))),i}function of(t){const s=ml(t);return f3[s]+t.slice(s.length)}function j3(t){return{top:0,right:0,bottom:0,left:0,...t}}function vk(t){return typeof t!="number"?j3(t):{top:t,right:t,bottom:t,left:t}}function cf(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 z1(t,s,n){let{reference:r,floating:a}=t;const i=_i(s),o=lb(s),d=ib(o),m=ml(s),f=i==="y",p=r.x+r.width/2-a.width/2,h=r.y+r.height/2-a.height/2,x=r[d]/2-a[d]/2;let u;switch(m){case"top":u={x:p,y:r.y-a.height};break;case"bottom":u={x:p,y:r.y+r.height};break;case"right":u={x:r.x+r.width,y:h};break;case"left":u={x:r.x-a.width,y:h};break;default:u={x:r.x,y:r.y}}switch(bd(s)){case"start":u[o]-=x*(n&&f?-1:1);break;case"end":u[o]+=x*(n&&f?-1:1);break}return u}async function N3(t,s){var n;s===void 0&&(s={});const{x:r,y:a,platform:i,rects:o,elements:d,strategy:m}=t,{boundary:f="clippingAncestors",rootBoundary:p="viewport",elementContext:h="floating",altBoundary:x=!1,padding:u=0}=hl(s,t),N=vk(u),w=d[x?h==="floating"?"reference":"floating":h],j=cf(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(w)))==null||n?w:w.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(d.floating)),boundary:f,rootBoundary:p,strategy:m})),b=h==="floating"?{x:r,y:a,width:o.floating.width,height:o.floating.height}:o.reference,C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d.floating)),S=await(i.isElement==null?void 0:i.isElement(C))?await(i.getScale==null?void 0:i.getScale(C))||{x:1,y:1}:{x:1,y:1},D=cf(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:b,offsetParent:C,strategy:m}):b);return{top:(j.top-D.top+N.top)/S.y,bottom:(D.bottom-j.bottom+N.bottom)/S.y,left:(j.left-D.left+N.left)/S.x,right:(D.right-j.right+N.right)/S.x}}const w3=50,S3=async(t,s,n)=>{const{placement:r="bottom",strategy:a="absolute",middleware:i=[],platform:o}=n,d=o.detectOverflow?o:{...o,detectOverflow:N3},m=await(o.isRTL==null?void 0:o.isRTL(s));let f=await o.getElementRects({reference:t,floating:s,strategy:a}),{x:p,y:h}=z1(f,r,m),x=r,u=0;const N={};for(let v=0;v({name:"arrow",options:t,async fn(s){const{x:n,y:r,placement:a,rects:i,platform:o,elements:d,middlewareData:m}=s,{element:f,padding:p=0}=hl(t,s)||{};if(f==null)return{};const h=vk(p),x={x:n,y:r},u=lb(a),N=ib(u),v=await o.getDimensions(f),w=u==="y",j=w?"top":"left",b=w?"bottom":"right",C=w?"clientHeight":"clientWidth",S=i.reference[N]+i.reference[u]-x[u]-i.floating[N],D=x[u]-i.reference[u],_=await(o.getOffsetParent==null?void 0:o.getOffsetParent(f));let A=_?_[C]:0;(!A||!await(o.isElement==null?void 0:o.isElement(_)))&&(A=d.floating[C]||i.floating[N]);const E=S/2-D/2,q=A/2-v[N]/2-1,O=no(h[j],q),R=no(h[b],q),P=O,L=A-v[N]-R,$=A/2-v[N]/2+E,Z=oy(P,$,L),Q=!m.arrow&&bd(a)!=null&&$!==Z&&i.reference[N]/2-($$<=0)){var R,P;const $=(((R=i.flip)==null?void 0:R.index)||0)+1,Z=A[$];if(Z&&(!(h==="alignment"?b!==_i(Z):!1)||O.every(U=>_i(U.placement)===b?U.overflows[0]>0:!0)))return{data:{index:$,overflows:O},reset:{placement:Z}};let Q=(P=O.filter(W=>W.overflows[0]<=0).sort((W,U)=>W.overflows[1]-U.overflows[1])[0])==null?void 0:P.placement;if(!Q)switch(u){case"bestFit":{var L;const W=(L=O.filter(U=>{if(_){const M=_i(U.placement);return M===b||M==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(M=>M>0).reduce((M,z)=>M+z,0)]).sort((U,M)=>U[1]-M[1])[0])==null?void 0:L[0];W&&(Q=W);break}case"initialPlacement":Q=d;break}if(a!==Q)return{reset:{placement:Q}}}return{}}}};function U1(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function V1(t){return m3.some(s=>t[s]>=0)}const k3=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:n,platform:r}=s,{strategy:a="referenceHidden",...i}=hl(t,s);switch(a){case"referenceHidden":{const o=await r.detectOverflow(s,{...i,elementContext:"reference"}),d=U1(o,n.reference);return{data:{referenceHiddenOffsets:d,referenceHidden:V1(d)}}}case"escaped":{const o=await r.detectOverflow(s,{...i,altBoundary:!0}),d=U1(o,n.floating);return{data:{escapedOffsets:d,escaped:V1(d)}}}default:return{}}}}},yk=new Set(["left","top"]);async function D3(t,s){const{placement:n,platform:r,elements:a}=t,i=await(r.isRTL==null?void 0:r.isRTL(a.floating)),o=ml(n),d=bd(n),m=_i(n)==="y",f=yk.has(o)?-1:1,p=i&&m?-1:1,h=hl(s,t);let{mainAxis:x,crossAxis:u,alignmentAxis:N}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return d&&typeof N=="number"&&(u=d==="end"?N*-1:N),m?{x:u*p,y:x*f}:{x:x*f,y:u*p}}const R3=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(s){var n,r;const{x:a,y:i,placement:o,middlewareData:d}=s,m=await D3(s,t);return o===((n=d.offset)==null?void 0:n.placement)&&(r=d.arrow)!=null&&r.alignmentOffset?{}:{x:a+m.x,y:i+m.y,data:{...m,placement:o}}}}},E3=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:n,y:r,placement:a,platform:i}=s,{mainAxis:o=!0,crossAxis:d=!1,limiter:m={fn:j=>{let{x:b,y:C}=j;return{x:b,y:C}}},...f}=hl(t,s),p={x:n,y:r},h=await i.detectOverflow(s,f),x=_i(ml(a)),u=ab(x);let N=p[u],v=p[x];if(o){const j=u==="y"?"top":"left",b=u==="y"?"bottom":"right",C=N+h[j],S=N-h[b];N=oy(C,N,S)}if(d){const j=x==="y"?"top":"left",b=x==="y"?"bottom":"right",C=v+h[j],S=v-h[b];v=oy(C,v,S)}const w=m.fn({...s,[u]:N,[x]:v});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[u]:o,[x]:d}}}}}},_3=function(t){return t===void 0&&(t={}),{options:t,fn(s){const{x:n,y:r,placement:a,rects:i,middlewareData:o}=s,{offset:d=0,mainAxis:m=!0,crossAxis:f=!0}=hl(t,s),p={x:n,y:r},h=_i(a),x=ab(h);let u=p[x],N=p[h];const v=hl(d,s),w=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(m){const C=x==="y"?"height":"width",S=i.reference[x]-i.floating[C]+w.mainAxis,D=i.reference[x]+i.reference[C]-w.mainAxis;uD&&(u=D)}if(f){var j,b;const C=x==="y"?"width":"height",S=yk.has(ml(a)),D=i.reference[h]-i.floating[C]+(S&&((j=o.offset)==null?void 0:j[h])||0)+(S?0:w.crossAxis),_=i.reference[h]+i.reference[C]+(S?0:((b=o.offset)==null?void 0:b[h])||0)-(S?w.crossAxis:0);N_&&(N=_)}return{[x]:u,[h]:N}}}},T3=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(s){var n,r;const{placement:a,rects:i,platform:o,elements:d}=s,{apply:m=()=>{},...f}=hl(t,s),p=await o.detectOverflow(s,f),h=ml(a),x=bd(a),u=_i(a)==="y",{width:N,height:v}=i.floating;let w,j;h==="top"||h==="bottom"?(w=h,j=x===(await(o.isRTL==null?void 0:o.isRTL(d.floating))?"start":"end")?"left":"right"):(j=h,w=x==="end"?"top":"bottom");const b=v-p.top-p.bottom,C=N-p.left-p.right,S=no(v-p[w],b),D=no(N-p[j],C),_=!s.middlewareData.shift;let A=S,E=D;if((n=s.middlewareData.shift)!=null&&n.enabled.x&&(E=C),(r=s.middlewareData.shift)!=null&&r.enabled.y&&(A=b),_&&!x){const O=ga(p.left,0),R=ga(p.right,0),P=ga(p.top,0),L=ga(p.bottom,0);u?E=N-2*(O!==0||R!==0?O+R:ga(p.left,p.right)):A=v-2*(P!==0||L!==0?P+L:ga(p.top,p.bottom))}await m({...s,availableWidth:E,availableHeight:A});const q=await o.getDimensions(d.floating);return N!==q.width||v!==q.height?{reset:{rects:!0}}:{}}}};function $f(){return typeof window<"u"}function jd(t){return bk(t)?(t.nodeName||"").toLowerCase():"#document"}function Na(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function Fi(t){var s;return(s=(bk(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function bk(t){return $f()?t instanceof Node||t instanceof Na(t).Node:!1}function oi(t){return $f()?t instanceof Element||t instanceof Na(t).Element:!1}function gl(t){return $f()?t instanceof HTMLElement||t instanceof Na(t).HTMLElement:!1}function H1(t){return!$f()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Na(t).ShadowRoot}function Zu(t){const{overflow:s,overflowX:n,overflowY:r,display:a}=ci(t);return/auto|scroll|overlay|hidden|clip/.test(s+r+n)&&a!=="inline"&&a!=="contents"}function P3(t){return/^(table|td|th)$/.test(jd(t))}function qf(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const O3=/transform|translate|scale|rotate|perspective|filter/,L3=/paint|layout|strict|content/,Fo=t=>!!t&&t!=="none";let jg;function ob(t){const s=oi(t)?ci(t):t;return Fo(s.transform)||Fo(s.translate)||Fo(s.scale)||Fo(s.rotate)||Fo(s.perspective)||!cb()&&(Fo(s.backdropFilter)||Fo(s.filter))||O3.test(s.willChange||"")||L3.test(s.contain||"")}function I3(t){let s=ro(t);for(;gl(s)&&!ld(s);){if(ob(s))return s;if(qf(s))return null;s=ro(s)}return null}function cb(){return jg==null&&(jg=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),jg}function ld(t){return/^(html|body|#document)$/.test(jd(t))}function ci(t){return Na(t).getComputedStyle(t)}function zf(t){return oi(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function ro(t){if(jd(t)==="html")return t;const s=t.assignedSlot||t.parentNode||H1(t)&&t.host||Fi(t);return H1(s)?s.host:s}function jk(t){const s=ro(t);return ld(s)?t.ownerDocument?t.ownerDocument.body:t.body:gl(s)&&Zu(s)?s:jk(s)}function Du(t,s,n){var r;s===void 0&&(s=[]),n===void 0&&(n=!0);const a=jk(t),i=a===((r=t.ownerDocument)==null?void 0:r.body),o=Na(a);if(i){const d=dy(o);return s.concat(o,o.visualViewport||[],Zu(a)?a:[],d&&n?Du(d):[])}else return s.concat(a,Du(a,[],n))}function dy(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Nk(t){const s=ci(t);let n=parseFloat(s.width)||0,r=parseFloat(s.height)||0;const a=gl(t),i=a?t.offsetWidth:n,o=a?t.offsetHeight:r,d=lf(n)!==i||lf(r)!==o;return d&&(n=i,r=o),{width:n,height:r,$:d}}function db(t){return oi(t)?t:t.contextElement}function Xc(t){const s=db(t);if(!gl(s))return Pi(1);const n=s.getBoundingClientRect(),{width:r,height:a,$:i}=Nk(s);let o=(i?lf(n.width):n.width)/r,d=(i?lf(n.height):n.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!d||!Number.isFinite(d))&&(d=1),{x:o,y:d}}const M3=Pi(0);function wk(t){const s=Na(t);return!cb()||!s.visualViewport?M3:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function F3(t,s,n){return s===void 0&&(s=!1),!n||s&&n!==Na(t)?!1:s}function nc(t,s,n,r){s===void 0&&(s=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),i=db(t);let o=Pi(1);s&&(r?oi(r)&&(o=Xc(r)):o=Xc(t));const d=F3(i,n,r)?wk(i):Pi(0);let m=(a.left+d.x)/o.x,f=(a.top+d.y)/o.y,p=a.width/o.x,h=a.height/o.y;if(i){const x=Na(i),u=r&&oi(r)?Na(r):r;let N=x,v=dy(N);for(;v&&r&&u!==N;){const w=Xc(v),j=v.getBoundingClientRect(),b=ci(v),C=j.left+(v.clientLeft+parseFloat(b.paddingLeft))*w.x,S=j.top+(v.clientTop+parseFloat(b.paddingTop))*w.y;m*=w.x,f*=w.y,p*=w.x,h*=w.y,m+=C,f+=S,N=Na(v),v=dy(N)}}return cf({width:p,height:h,x:m,y:f})}function Uf(t,s){const n=zf(t).scrollLeft;return s?s.left+n:nc(Fi(t)).left+n}function Sk(t,s){const n=t.getBoundingClientRect(),r=n.left+s.scrollLeft-Uf(t,n),a=n.top+s.scrollTop;return{x:r,y:a}}function B3(t){let{elements:s,rect:n,offsetParent:r,strategy:a}=t;const i=a==="fixed",o=Fi(r),d=s?qf(s.floating):!1;if(r===o||d&&i)return n;let m={scrollLeft:0,scrollTop:0},f=Pi(1);const p=Pi(0),h=gl(r);if((h||!h&&!i)&&((jd(r)!=="body"||Zu(o))&&(m=zf(r)),h)){const u=nc(r);f=Xc(r),p.x=u.x+r.clientLeft,p.y=u.y+r.clientTop}const x=o&&!h&&!i?Sk(o,m):Pi(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-m.scrollLeft*f.x+p.x+x.x,y:n.y*f.y-m.scrollTop*f.y+p.y+x.y}}function $3(t){return Array.from(t.getClientRects())}function q3(t){const s=Fi(t),n=zf(t),r=t.ownerDocument.body,a=ga(s.scrollWidth,s.clientWidth,r.scrollWidth,r.clientWidth),i=ga(s.scrollHeight,s.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Uf(t);const d=-n.scrollTop;return ci(r).direction==="rtl"&&(o+=ga(s.clientWidth,r.clientWidth)-a),{width:a,height:i,x:o,y:d}}const W1=25;function z3(t,s){const n=Na(t),r=Fi(t),a=n.visualViewport;let i=r.clientWidth,o=r.clientHeight,d=0,m=0;if(a){i=a.width,o=a.height;const p=cb();(!p||p&&s==="fixed")&&(d=a.offsetLeft,m=a.offsetTop)}const f=Uf(r);if(f<=0){const p=r.ownerDocument,h=p.body,x=getComputedStyle(h),u=p.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,N=Math.abs(r.clientWidth-h.clientWidth-u);N<=W1&&(i-=N)}else f<=W1&&(i+=f);return{width:i,height:o,x:d,y:m}}function U3(t,s){const n=nc(t,!0,s==="fixed"),r=n.top+t.clientTop,a=n.left+t.clientLeft,i=gl(t)?Xc(t):Pi(1),o=t.clientWidth*i.x,d=t.clientHeight*i.y,m=a*i.x,f=r*i.y;return{width:o,height:d,x:m,y:f}}function G1(t,s,n){let r;if(s==="viewport")r=z3(t,n);else if(s==="document")r=q3(Fi(t));else if(oi(s))r=U3(s,n);else{const a=wk(t);r={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return cf(r)}function Ck(t,s){const n=ro(t);return n===s||!oi(n)||ld(n)?!1:ci(n).position==="fixed"||Ck(n,s)}function V3(t,s){const n=s.get(t);if(n)return n;let r=Du(t,[],!1).filter(d=>oi(d)&&jd(d)!=="body"),a=null;const i=ci(t).position==="fixed";let o=i?ro(t):t;for(;oi(o)&&!ld(o);){const d=ci(o),m=ob(o);!m&&d.position==="fixed"&&(a=null),(i?!m&&!a:!m&&d.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||Zu(o)&&!m&&Ck(t,o))?r=r.filter(p=>p!==o):a=d,o=ro(o)}return s.set(t,r),r}function H3(t){let{element:s,boundary:n,rootBoundary:r,strategy:a}=t;const o=[...n==="clippingAncestors"?qf(s)?[]:V3(s,this._c):[].concat(n),r],d=G1(s,o[0],a);let m=d.top,f=d.right,p=d.bottom,h=d.left;for(let x=1;x{o(!1,1e-7)},1e3)}A===1&&!kk(f,t.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(D,{...C,root:a.ownerDocument})}catch{n=new IntersectionObserver(D,C)}n.observe(t)}return o(!0),i}function X3(t,s,n,r){r===void 0&&(r={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:m=!1}=r,f=db(t),p=a||i?[...f?Du(f):[],...s?Du(s):[]]:[];p.forEach(j=>{a&&j.addEventListener("scroll",n,{passive:!0}),i&&j.addEventListener("resize",n)});const h=f&&d?Q3(f,n):null;let x=-1,u=null;o&&(u=new ResizeObserver(j=>{let[b]=j;b&&b.target===f&&u&&s&&(u.unobserve(s),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var C;(C=u)==null||C.observe(s)})),n()}),f&&!m&&u.observe(f),s&&u.observe(s));let N,v=m?nc(t):null;m&&w();function w(){const j=nc(t);v&&!kk(v,j)&&n(),v=j,N=requestAnimationFrame(w)}return n(),()=>{var j;p.forEach(b=>{a&&b.removeEventListener("scroll",n),i&&b.removeEventListener("resize",n)}),h==null||h(),(j=u)==null||j.disconnect(),u=null,m&&cancelAnimationFrame(N)}}const J3=R3,eF=E3,tF=A3,sF=T3,nF=k3,Y1=C3,rF=_3,aF=(t,s,n)=>{const r=new Map,a={platform:Z3,...n},i={...a.platform,_c:r};return S3(t,s,{...a,platform:i})};var iF=typeof document<"u",lF=function(){},Mm=iF?g.useLayoutEffect:lF;function df(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(!df(t[r],s[r]))return!1;return!0}if(a=Object.keys(t),n=a.length,n!==Object.keys(s).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(s,a[r]))return!1;for(r=n;r--!==0;){const i=a[r];if(!(i==="_owner"&&t.$$typeof)&&!df(t[i],s[i]))return!1}return!0}return t!==t&&s!==s}function Dk(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Z1(t,s){const n=Dk(t);return Math.round(s*n)/n}function wg(t){const s=g.useRef(t);return Mm(()=>{s.current=t}),s}function oF(t){t===void 0&&(t={});const{placement:s="bottom",strategy:n="absolute",middleware:r=[],platform:a,elements:{reference:i,floating:o}={},transform:d=!0,whileElementsMounted:m,open:f}=t,[p,h]=g.useState({x:0,y:0,strategy:n,placement:s,middlewareData:{},isPositioned:!1}),[x,u]=g.useState(r);df(x,r)||u(r);const[N,v]=g.useState(null),[w,j]=g.useState(null),b=g.useCallback(U=>{U!==_.current&&(_.current=U,v(U))},[]),C=g.useCallback(U=>{U!==A.current&&(A.current=U,j(U))},[]),S=i||N,D=o||w,_=g.useRef(null),A=g.useRef(null),E=g.useRef(p),q=m!=null,O=wg(m),R=wg(a),P=wg(f),L=g.useCallback(()=>{if(!_.current||!A.current)return;const U={placement:s,strategy:n,middleware:x};R.current&&(U.platform=R.current),aF(_.current,A.current,U).then(M=>{const z={...M,isPositioned:P.current!==!1};$.current&&!df(E.current,z)&&(E.current=z,zu.flushSync(()=>{h(z)}))})},[x,s,n,R,P]);Mm(()=>{f===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,h(U=>({...U,isPositioned:!1})))},[f]);const $=g.useRef(!1);Mm(()=>($.current=!0,()=>{$.current=!1}),[]),Mm(()=>{if(S&&(_.current=S),D&&(A.current=D),S&&D){if(O.current)return O.current(S,D,L);L()}},[S,D,L,O,q]);const Z=g.useMemo(()=>({reference:_,floating:A,setReference:b,setFloating:C}),[b,C]),Q=g.useMemo(()=>({reference:S,floating:D}),[S,D]),W=g.useMemo(()=>{const U={position:n,left:0,top:0};if(!Q.floating)return U;const M=Z1(Q.floating,p.x),z=Z1(Q.floating,p.y);return d?{...U,transform:"translate("+M+"px, "+z+"px)",...Dk(Q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:z}},[n,d,Q.floating,p.x,p.y]);return g.useMemo(()=>({...p,update:L,refs:Z,elements:Q,floatingStyles:W}),[p,L,Z,Q,W])}const cF=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?Y1({element:r.current,padding:a}).fn(n):{}:r?Y1({element:r,padding:a}).fn(n):{}}}},dF=(t,s)=>{const n=J3(t);return{name:n.name,fn:n.fn,options:[t,s]}},uF=(t,s)=>{const n=eF(t);return{name:n.name,fn:n.fn,options:[t,s]}},hF=(t,s)=>({fn:rF(t).fn,options:[t,s]}),mF=(t,s)=>{const n=tF(t);return{name:n.name,fn:n.fn,options:[t,s]}},fF=(t,s)=>{const n=sF(t);return{name:n.name,fn:n.fn,options:[t,s]}},pF=(t,s)=>{const n=nF(t);return{name:n.name,fn:n.fn,options:[t,s]}},xF=(t,s)=>{const n=cF(t);return{name:n.name,fn:n.fn,options:[t,s]}};var gF="Arrow",Rk=g.forwardRef((t,s)=>{const{children:n,width:r=10,height:a=5,...i}=t;return e.jsx(Ss.svg,{...i,ref:s,width:r,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:e.jsx("polygon",{points:"0,0 30,0 15,10"})})});Rk.displayName=gF;var vF=Rk,ub="Popper",[Ek,lo]=oa(ub),[yF,_k]=Ek(ub),Tk=t=>{const{__scopePopper:s,children:n}=t,[r,a]=g.useState(null);return e.jsx(yF,{scope:s,anchor:r,onAnchorChange:a,children:n})};Tk.displayName=ub;var Pk="PopperAnchor",Ok=g.forwardRef((t,s)=>{const{__scopePopper:n,virtualRef:r,...a}=t,i=_k(Pk,n),o=g.useRef(null),d=Ys(s,o),m=g.useRef(null);return g.useEffect(()=>{const f=m.current;m.current=(r==null?void 0:r.current)||o.current,f!==m.current&&i.onAnchorChange(m.current)}),r?null:e.jsx(Ss.div,{...a,ref:d})});Ok.displayName=Pk;var hb="PopperContent",[bF,jF]=Ek(hb),Lk=g.forwardRef((t,s)=>{var Y,re,ae,ue,ye,ce;const{__scopePopper:n,side:r="bottom",sideOffset:a=0,align:i="center",alignOffset:o=0,arrowPadding:d=0,avoidCollisions:m=!0,collisionBoundary:f=[],collisionPadding:p=0,sticky:h="partial",hideWhenDetached:x=!1,updatePositionStrategy:u="optimized",onPlaced:N,...v}=t,w=_k(hb,n),[j,b]=g.useState(null),C=Ys(s,je=>b(je)),[S,D]=g.useState(null),_=Qy(S),A=(_==null?void 0:_.width)??0,E=(_==null?void 0:_.height)??0,q=r+(i!=="center"?"-"+i:""),O=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},R=Array.isArray(f)?f:[f],P=R.length>0,L={padding:O,boundary:R.filter(wF),altBoundary:P},{refs:$,floatingStyles:Z,placement:Q,isPositioned:W,middlewareData:U}=oF({strategy:"fixed",placement:q,whileElementsMounted:(...je)=>X3(...je,{animationFrame:u==="always"}),elements:{reference:w.anchor},middleware:[dF({mainAxis:a+E,alignmentAxis:o}),m&&uF({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?hF():void 0,...L}),m&&mF({...L}),fF({...L,apply:({elements:je,rects:Me,availableWidth:ut,availableHeight:jt})=>{const{width:ft,height:X}=Me.reference,Ce=je.floating.style;Ce.setProperty("--radix-popper-available-width",`${ut}px`),Ce.setProperty("--radix-popper-available-height",`${jt}px`),Ce.setProperty("--radix-popper-anchor-width",`${ft}px`),Ce.setProperty("--radix-popper-anchor-height",`${X}px`)}}),S&&xF({element:S,padding:d}),SF({arrowWidth:A,arrowHeight:E}),x&&pF({strategy:"referenceHidden",...L})]}),[M,z]=Fk(Q),T=xr(N);Jn(()=>{W&&(T==null||T())},[W,T]);const F=(Y=U.arrow)==null?void 0:Y.x,I=(re=U.arrow)==null?void 0:re.y,K=((ae=U.arrow)==null?void 0:ae.centerOffset)!==0,[G,V]=g.useState();return Jn(()=>{j&&V(window.getComputedStyle(j).zIndex)},[j]),e.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...Z,transform:W?Z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:G,"--radix-popper-transform-origin":[(ue=U.transformOrigin)==null?void 0:ue.x,(ye=U.transformOrigin)==null?void 0:ye.y].join(" "),...((ce=U.hide)==null?void 0:ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(bF,{scope:n,placedSide:M,onArrowChange:D,arrowX:F,arrowY:I,shouldHideArrow:K,children:e.jsx(Ss.div,{"data-side":M,"data-align":z,...v,ref:C,style:{...v.style,animation:W?void 0:"none"}})})})});Lk.displayName=hb;var Ik="PopperArrow",NF={top:"bottom",right:"left",bottom:"top",left:"right"},Mk=g.forwardRef(function(s,n){const{__scopePopper:r,...a}=s,i=jF(Ik,r),o=NF[i.placedSide];return e.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:e.jsx(vF,{...a,ref:n,style:{...a.style,display:"block"}})})});Mk.displayName=Ik;function wF(t){return t!==null}var SF=t=>({name:"transformOrigin",options:t,fn(s){var w,j,b;const{placement:n,rects:r,middlewareData:a}=s,o=((w=a.arrow)==null?void 0:w.centerOffset)!==0,d=o?0:t.arrowWidth,m=o?0:t.arrowHeight,[f,p]=Fk(n),h={start:"0%",center:"50%",end:"100%"}[p],x=(((j=a.arrow)==null?void 0:j.x)??0)+d/2,u=(((b=a.arrow)==null?void 0:b.y)??0)+m/2;let N="",v="";return f==="bottom"?(N=o?h:`${x}px`,v=`${-m}px`):f==="top"?(N=o?h:`${x}px`,v=`${r.floating.height+m}px`):f==="right"?(N=`${-m}px`,v=o?h:`${u}px`):f==="left"&&(N=`${r.floating.width+m}px`,v=o?h:`${u}px`),{data:{x:N,y:v}}}});function Fk(t){const[s,n="center"]=t.split("-");return[s,n]}var Vf=Tk,Qu=Ok,Hf=Lk,Wf=Mk,CF="Portal",Nd=g.forwardRef((t,s)=>{var d;const{container:n,...r}=t,[a,i]=g.useState(!1);Jn(()=>i(!0),[]);const o=n||a&&((d=globalThis==null?void 0:globalThis.document)==null?void 0:d.body);return o?Hy.createPortal(e.jsx(Ss.div,{...r,ref:s}),o):null});Nd.displayName=CF;var Sg="rovingFocusGroup.onEntryFocus",AF={bubbles:!1,cancelable:!0},Xu="RovingFocusGroup",[uy,Bk,kF]=rb(Xu),[DF,Gf]=oa(Xu,[kF]),[RF,EF]=DF(Xu),$k=g.forwardRef((t,s)=>e.jsx(uy.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(uy.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(_F,{...t,ref:s})})}));$k.displayName=Xu;var _F=g.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:d,onCurrentTabStopIdChange:m,onEntryFocus:f,preventScrollOnEntryFocus:p=!1,...h}=t,x=g.useRef(null),u=Ys(s,x),N=Ku(i),[v,w]=Li({prop:o,defaultProp:d??null,onChange:m,caller:Xu}),[j,b]=g.useState(!1),C=xr(f),S=Bk(n),D=g.useRef(!1),[_,A]=g.useState(0);return g.useEffect(()=>{const E=x.current;if(E)return E.addEventListener(Sg,C),()=>E.removeEventListener(Sg,C)},[C]),e.jsx(RF,{scope:n,orientation:r,dir:N,loop:a,currentTabStopId:v,onItemFocus:g.useCallback(E=>w(E),[w]),onItemShiftTab:g.useCallback(()=>b(!0),[]),onFocusableItemAdd:g.useCallback(()=>A(E=>E+1),[]),onFocusableItemRemove:g.useCallback(()=>A(E=>E-1),[]),children:e.jsx(Ss.div,{tabIndex:j||_===0?-1:0,"data-orientation":r,...h,ref:u,style:{outline:"none",...t.style},onMouseDown:Yt(t.onMouseDown,()=>{D.current=!0}),onFocus:Yt(t.onFocus,E=>{const q=!D.current;if(E.target===E.currentTarget&&q&&!j){const O=new CustomEvent(Sg,AF);if(E.currentTarget.dispatchEvent(O),!O.defaultPrevented){const R=S().filter(Q=>Q.focusable),P=R.find(Q=>Q.active),L=R.find(Q=>Q.id===v),Z=[P,L,...R].filter(Boolean).map(Q=>Q.ref.current);Uk(Z,p)}}D.current=!1}),onBlur:Yt(t.onBlur,()=>b(!1))})})}),qk="RovingFocusGroupItem",zk=g.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...d}=t,m=yr(),f=i||m,p=EF(qk,n),h=p.currentTabStopId===f,x=Bk(n),{onFocusableItemAdd:u,onFocusableItemRemove:N,currentTabStopId:v}=p;return g.useEffect(()=>{if(r)return u(),()=>N()},[r,u,N]),e.jsx(uy.ItemSlot,{scope:n,id:f,focusable:r,active:a,children:e.jsx(Ss.span,{tabIndex:h?0:-1,"data-orientation":p.orientation,...d,ref:s,onMouseDown:Yt(t.onMouseDown,w=>{r?p.onItemFocus(f):w.preventDefault()}),onFocus:Yt(t.onFocus,()=>p.onItemFocus(f)),onKeyDown:Yt(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const j=OF(w,p.orientation,p.dir);if(j!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let C=x().filter(S=>S.focusable).map(S=>S.ref.current);if(j==="last")C.reverse();else if(j==="prev"||j==="next"){j==="prev"&&C.reverse();const S=C.indexOf(w.currentTarget);C=p.loop?LF(C,S+1):C.slice(S+1)}setTimeout(()=>Uk(C))}}),children:typeof o=="function"?o({isCurrentTabStop:h,hasTabStop:v!=null}):o})})});zk.displayName=qk;var TF={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function PF(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function OF(t,s,n){const r=PF(t.key,n);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return TF[r]}function Uk(t,s=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:s}),document.activeElement!==n))return}function LF(t,s){return t.map((n,r)=>t[(s+r)%t.length])}var Vk=$k,Hk=zk;function IF(t){const s=MF(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find(BF);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function MF(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=qF(a),d=$F(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Hr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var FF=Symbol("radix.slottable");function BF(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===FF}function $F(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function qF(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 zF=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},Bc=new WeakMap,fm=new WeakMap,pm={},Cg=0,Wk=function(t){return t&&(t.host||Wk(t.parentNode))},UF=function(t,s){return s.map(function(n){if(t.contains(n))return n;var r=Wk(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})},VF=function(t,s,n,r){var a=UF(s,Array.isArray(t)?t:[t]);pm[n]||(pm[n]=new WeakMap);var i=pm[n],o=[],d=new Set,m=new Set(a),f=function(h){!h||d.has(h)||(d.add(h),f(h.parentNode))};a.forEach(f);var p=function(h){!h||m.has(h)||Array.prototype.forEach.call(h.children,function(x){if(d.has(x))p(x);else try{var u=x.getAttribute(r),N=u!==null&&u!=="false",v=(Bc.get(x)||0)+1,w=(i.get(x)||0)+1;Bc.set(x,v),i.set(x,w),o.push(x),v===1&&N&&fm.set(x,!0),w===1&&x.setAttribute(n,"true"),N||x.setAttribute(r,"true")}catch(j){console.error("aria-hidden: cannot operate on ",x,j)}})};return p(s),d.clear(),Cg++,function(){o.forEach(function(h){var x=Bc.get(h)-1,u=i.get(h)-1;Bc.set(h,x),i.set(h,u),x||(fm.has(h)||h.removeAttribute(r),fm.delete(h)),u||h.removeAttribute(n)}),Cg--,Cg||(Bc=new WeakMap,Bc=new WeakMap,fm=new WeakMap,pm={})}},Kf=function(t,s,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),a=zF(t);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),VF(r,a,n,"aria-hidden")):function(){return null}},Di=function(){return Di=Object.assign||function(s){for(var n,r=1,a=arguments.length;r"u")return l6;var s=o6(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])}},d6=Zk(),Jc="data-scroll-locked",u6=function(t,s,n,r){var a=t.left,i=t.top,o=t.right,d=t.gap;return n===void 0&&(n="margin"),` .`.concat(WF,` { overflow: hidden `).concat(r,`; padding-right: `).concat(d,"px ").concat(r,`; } body[`).concat(Jc,`] { overflow: hidden `).concat(r,`; overscroll-behavior: contain; `).concat([s&&"position: relative ".concat(r,";"),n==="margin"&&` padding-left: `.concat(a,`px; padding-top: `).concat(i,`px; padding-right: `).concat(o,`px; margin-left:0; margin-top:0; margin-right: `).concat(d,"px ").concat(r,`; `),n==="padding"&&"padding-right: ".concat(d,"px ").concat(r,";")].filter(Boolean).join(""),` } .`).concat(Fm,` { right: `).concat(d,"px ").concat(r,`; } .`).concat(Bm,` { margin-right: `).concat(d,"px ").concat(r,`; } .`).concat(Fm," .").concat(Fm,` { right: 0 `).concat(r,`; } .`).concat(Bm," .").concat(Bm,` { margin-right: 0 `).concat(r,`; } body[`).concat(Jc,`] { `).concat(GF,": ").concat(d,`px; } `)},X1=function(){var t=parseInt(document.body.getAttribute(Jc)||"0",10);return isFinite(t)?t:0},h6=function(){g.useEffect(function(){return document.body.setAttribute(Jc,(X1()+1).toString()),function(){var t=X1()-1;t<=0?document.body.removeAttribute(Jc):document.body.setAttribute(Jc,t.toString())}},[])},m6=function(t){var s=t.noRelative,n=t.noImportant,r=t.gapMode,a=r===void 0?"margin":r;h6();var i=g.useMemo(function(){return c6(a)},[a]);return g.createElement(d6,{styles:u6(i,!s,a,n?"":"!important")})},hy=!1;if(typeof window<"u")try{var xm=Object.defineProperty({},"passive",{get:function(){return hy=!0,!0}});window.addEventListener("test",xm,xm),window.removeEventListener("test",xm,xm)}catch{hy=!1}var $c=hy?{passive:!1}:!1,f6=function(t){return t.tagName==="TEXTAREA"},Qk=function(t,s){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[s]!=="hidden"&&!(n.overflowY===n.overflowX&&!f6(t)&&n[s]==="visible")},p6=function(t){return Qk(t,"overflowY")},x6=function(t){return Qk(t,"overflowX")},J1=function(t,s){var n=s.ownerDocument,r=s;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=Xk(t,r);if(a){var i=Jk(t,r),o=i[1],d=i[2];if(o>d)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},g6=function(t){var s=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[s,n,r]},v6=function(t){var s=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[s,n,r]},Xk=function(t,s){return t==="v"?p6(s):x6(s)},Jk=function(t,s){return t==="v"?g6(s):v6(s)},y6=function(t,s){return t==="h"&&s==="rtl"?-1:1},b6=function(t,s,n,r,a){var i=y6(t,window.getComputedStyle(s).direction),o=i*r,d=n.target,m=s.contains(d),f=!1,p=o>0,h=0,x=0;do{if(!d)break;var u=Jk(t,d),N=u[0],v=u[1],w=u[2],j=v-w-i*N;(N||j)&&Xk(t,d)&&(h+=j,x+=N);var b=d.parentNode;d=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!m&&d!==document.body||m&&(s.contains(d)||s===d));return(p&&Math.abs(h)<1||!p&&Math.abs(x)<1)&&(f=!0),f},gm=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},eS=function(t){return[t.deltaX,t.deltaY]},tS=function(t){return t&&"current"in t?t.current:t},j6=function(t,s){return t[0]===s[0]&&t[1]===s[1]},N6=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},w6=0,qc=[];function S6(t){var s=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),a=g.useState(w6++)[0],i=g.useState(Zk)[0],o=g.useRef(t);g.useEffect(function(){o.current=t},[t]),g.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var v=HF([t.lockRef.current],(t.shards||[]).map(tS),!0).filter(Boolean);return v.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),v.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var d=g.useCallback(function(v,w){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var j=gm(v),b=n.current,C="deltaX"in v?v.deltaX:b[0]-j[0],S="deltaY"in v?v.deltaY:b[1]-j[1],D,_=v.target,A=Math.abs(C)>Math.abs(S)?"h":"v";if("touches"in v&&A==="h"&&_.type==="range")return!1;var E=window.getSelection(),q=E&&E.anchorNode,O=q?q===_||q.contains(_):!1;if(O)return!1;var R=J1(A,_);if(!R)return!0;if(R?D=A:(D=A==="v"?"h":"v",R=J1(A,_)),!R)return!1;if(!r.current&&"changedTouches"in v&&(C||S)&&(r.current=D),!D)return!0;var P=r.current||D;return b6(P,w,v,P==="h"?C:S)},[]),m=g.useCallback(function(v){var w=v;if(!(!qc.length||qc[qc.length-1]!==i)){var j="deltaY"in w?eS(w):gm(w),b=s.current.filter(function(D){return D.name===w.type&&(D.target===w.target||w.target===D.shadowParent)&&j6(D.delta,j)})[0];if(b&&b.should){w.cancelable&&w.preventDefault();return}if(!b){var C=(o.current.shards||[]).map(tS).filter(Boolean).filter(function(D){return D.contains(w.target)}),S=C.length>0?d(w,C[0]):!o.current.noIsolation;S&&w.cancelable&&w.preventDefault()}}},[]),f=g.useCallback(function(v,w,j,b){var C={name:v,delta:w,target:j,should:b,shadowParent:C6(j)};s.current.push(C),setTimeout(function(){s.current=s.current.filter(function(S){return S!==C})},1)},[]),p=g.useCallback(function(v){n.current=gm(v),r.current=void 0},[]),h=g.useCallback(function(v){f(v.type,eS(v),v.target,d(v,t.lockRef.current))},[]),x=g.useCallback(function(v){f(v.type,gm(v),v.target,d(v,t.lockRef.current))},[]);g.useEffect(function(){return qc.push(i),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:x}),document.addEventListener("wheel",m,$c),document.addEventListener("touchmove",m,$c),document.addEventListener("touchstart",p,$c),function(){qc=qc.filter(function(v){return v!==i}),document.removeEventListener("wheel",m,$c),document.removeEventListener("touchmove",m,$c),document.removeEventListener("touchstart",p,$c)}},[]);var u=t.removeScrollBar,N=t.inert;return g.createElement(g.Fragment,null,N?g.createElement(i,{styles:N6(a)}):null,u?g.createElement(m6,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function C6(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const A6=e6(Yk,S6);var Ju=g.forwardRef(function(t,s){return g.createElement(Yf,Di({},t,{ref:s,sideCar:A6}))});Ju.classNames=Yf.classNames;var my=["Enter"," "],k6=["ArrowDown","PageUp","Home"],eD=["ArrowUp","PageDown","End"],D6=[...k6,...eD],R6={ltr:[...my,"ArrowRight"],rtl:[...my,"ArrowLeft"]},E6={ltr:["ArrowLeft"],rtl:["ArrowRight"]},eh="Menu",[Ru,_6,T6]=rb(eh),[uc,tD]=oa(eh,[T6,lo,Gf]),Zf=lo(),sD=Gf(),[P6,hc]=uc(eh),[O6,th]=uc(eh),nD=t=>{const{__scopeMenu:s,open:n=!1,children:r,dir:a,onOpenChange:i,modal:o=!0}=t,d=Zf(s),[m,f]=g.useState(null),p=g.useRef(!1),h=xr(i),x=Ku(a);return g.useEffect(()=>{const u=()=>{p.current=!0,document.addEventListener("pointerdown",N,{capture:!0,once:!0}),document.addEventListener("pointermove",N,{capture:!0,once:!0})},N=()=>p.current=!1;return document.addEventListener("keydown",u,{capture:!0}),()=>{document.removeEventListener("keydown",u,{capture:!0}),document.removeEventListener("pointerdown",N,{capture:!0}),document.removeEventListener("pointermove",N,{capture:!0})}},[]),e.jsx(Vf,{...d,children:e.jsx(P6,{scope:s,open:n,onOpenChange:h,content:m,onContentChange:f,children:e.jsx(O6,{scope:s,onClose:g.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:p,dir:x,modal:o,children:r})})})};nD.displayName=eh;var L6="MenuAnchor",mb=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t,a=Zf(n);return e.jsx(Qu,{...a,...r,ref:s})});mb.displayName=L6;var fb="MenuPortal",[I6,rD]=uc(fb,{forceMount:void 0}),aD=t=>{const{__scopeMenu:s,forceMount:n,children:r,container:a}=t,i=hc(fb,s);return e.jsx(I6,{scope:s,forceMount:n,children:e.jsx(jr,{present:n||i.open,children:e.jsx(Nd,{asChild:!0,container:a,children:r})})})};aD.displayName=fb;var $a="MenuContent",[M6,pb]=uc($a),iD=g.forwardRef((t,s)=>{const n=rD($a,t.__scopeMenu),{forceMount:r=n.forceMount,...a}=t,i=hc($a,t.__scopeMenu),o=th($a,t.__scopeMenu);return e.jsx(Ru.Provider,{scope:t.__scopeMenu,children:e.jsx(jr,{present:r||i.open,children:e.jsx(Ru.Slot,{scope:t.__scopeMenu,children:o.modal?e.jsx(F6,{...a,ref:s}):e.jsx(B6,{...a,ref:s})})})})}),F6=g.forwardRef((t,s)=>{const n=hc($a,t.__scopeMenu),r=g.useRef(null),a=Ys(s,r);return g.useEffect(()=>{const i=r.current;if(i)return Kf(i)},[]),e.jsx(xb,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Yt(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),B6=g.forwardRef((t,s)=>{const n=hc($a,t.__scopeMenu);return e.jsx(xb,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),$6=IF("MenuContent.ScrollLock"),xb=g.forwardRef((t,s)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:a,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:d,onEntryFocus:m,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:h,onInteractOutside:x,onDismiss:u,disableOutsideScroll:N,...v}=t,w=hc($a,n),j=th($a,n),b=Zf(n),C=sD(n),S=_6(n),[D,_]=g.useState(null),A=g.useRef(null),E=Ys(s,A,w.onContentChange),q=g.useRef(0),O=g.useRef(""),R=g.useRef(0),P=g.useRef(null),L=g.useRef("right"),$=g.useRef(0),Z=N?Ju:g.Fragment,Q=N?{as:$6,allowPinchZoom:!0}:void 0,W=M=>{var Y,re;const z=O.current+M,T=S().filter(ae=>!ae.disabled),F=document.activeElement,I=(Y=T.find(ae=>ae.ref.current===F))==null?void 0:Y.textValue,K=T.map(ae=>ae.textValue),G=X6(K,z,I),V=(re=T.find(ae=>ae.textValue===G))==null?void 0:re.ref.current;(function ae(ue){O.current=ue,window.clearTimeout(q.current),ue!==""&&(q.current=window.setTimeout(()=>ae(""),1e3))})(z),V&&setTimeout(()=>V.focus())};g.useEffect(()=>()=>window.clearTimeout(q.current),[]),Bf();const U=g.useCallback(M=>{var T,F;return L.current===((T=P.current)==null?void 0:T.side)&&e8(M,(F=P.current)==null?void 0:F.area)},[]);return e.jsx(M6,{scope:n,searchRef:O,onItemEnter:g.useCallback(M=>{U(M)&&M.preventDefault()},[U]),onItemLeave:g.useCallback(M=>{var z;U(M)||((z=A.current)==null||z.focus(),_(null))},[U]),onTriggerLeave:g.useCallback(M=>{U(M)&&M.preventDefault()},[U]),pointerGraceTimerRef:R,onPointerGraceIntentChange:g.useCallback(M=>{P.current=M},[]),children:e.jsx(Z,{...Q,children:e.jsx(Yu,{asChild:!0,trapped:a,onMountAutoFocus:Yt(i,M=>{var z;M.preventDefault(),(z=A.current)==null||z.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:e.jsx(yd,{asChild:!0,disableOutsidePointerEvents:d,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:h,onInteractOutside:x,onDismiss:u,children:e.jsx(Vk,{asChild:!0,...C,dir:j.dir,orientation:"vertical",loop:r,currentTabStopId:D,onCurrentTabStopIdChange:_,onEntryFocus:Yt(m,M=>{j.isUsingKeyboardRef.current||M.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(Hf,{role:"menu","aria-orientation":"vertical","data-state":ND(w.open),"data-radix-menu-content":"",dir:j.dir,...b,...v,ref:E,style:{outline:"none",...v.style},onKeyDown:Yt(v.onKeyDown,M=>{const T=M.target.closest("[data-radix-menu-content]")===M.currentTarget,F=M.ctrlKey||M.altKey||M.metaKey,I=M.key.length===1;T&&(M.key==="Tab"&&M.preventDefault(),!F&&I&&W(M.key));const K=A.current;if(M.target!==K||!D6.includes(M.key))return;M.preventDefault();const V=S().filter(Y=>!Y.disabled).map(Y=>Y.ref.current);eD.includes(M.key)&&V.reverse(),Z6(V)}),onBlur:Yt(t.onBlur,M=>{M.currentTarget.contains(M.target)||(window.clearTimeout(q.current),O.current="")}),onPointerMove:Yt(t.onPointerMove,Eu(M=>{const z=M.target,T=$.current!==M.clientX;if(M.currentTarget.contains(z)&&T){const F=M.clientX>$.current?"right":"left";L.current=F,$.current=M.clientX}}))})})})})})})});iD.displayName=$a;var q6="MenuGroup",gb=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t;return e.jsx(Ss.div,{role:"group",...r,ref:s})});gb.displayName=q6;var z6="MenuLabel",lD=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t;return e.jsx(Ss.div,{...r,ref:s})});lD.displayName=z6;var uf="MenuItem",sS="menu.itemSelect",Qf=g.forwardRef((t,s)=>{const{disabled:n=!1,onSelect:r,...a}=t,i=g.useRef(null),o=th(uf,t.__scopeMenu),d=pb(uf,t.__scopeMenu),m=Ys(s,i),f=g.useRef(!1),p=()=>{const h=i.current;if(!n&&h){const x=new CustomEvent(sS,{bubbles:!0,cancelable:!0});h.addEventListener(sS,u=>r==null?void 0:r(u),{once:!0}),KA(h,x),x.defaultPrevented?f.current=!1:o.onClose()}};return e.jsx(oD,{...a,ref:m,disabled:n,onClick:Yt(t.onClick,p),onPointerDown:h=>{var x;(x=t.onPointerDown)==null||x.call(t,h),f.current=!0},onPointerUp:Yt(t.onPointerUp,h=>{var x;f.current||(x=h.currentTarget)==null||x.click()}),onKeyDown:Yt(t.onKeyDown,h=>{const x=d.searchRef.current!=="";n||x&&h.key===" "||my.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Qf.displayName=uf;var oD=g.forwardRef((t,s)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...i}=t,o=pb(uf,n),d=sD(n),m=g.useRef(null),f=Ys(s,m),[p,h]=g.useState(!1),[x,u]=g.useState("");return g.useEffect(()=>{const N=m.current;N&&u((N.textContent??"").trim())},[i.children]),e.jsx(Ru.ItemSlot,{scope:n,disabled:r,textValue:a??x,children:e.jsx(Hk,{asChild:!0,...d,focusable:!r,children:e.jsx(Ss.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:f,onPointerMove:Yt(t.onPointerMove,Eu(N=>{r?o.onItemLeave(N):(o.onItemEnter(N),N.defaultPrevented||N.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Yt(t.onPointerLeave,Eu(N=>o.onItemLeave(N))),onFocus:Yt(t.onFocus,()=>h(!0)),onBlur:Yt(t.onBlur,()=>h(!1))})})})}),U6="MenuCheckboxItem",cD=g.forwardRef((t,s)=>{const{checked:n=!1,onCheckedChange:r,...a}=t;return e.jsx(fD,{scope:t.__scopeMenu,checked:n,children:e.jsx(Qf,{role:"menuitemcheckbox","aria-checked":hf(n)?"mixed":n,...a,ref:s,"data-state":yb(n),onSelect:Yt(a.onSelect,()=>r==null?void 0:r(hf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});cD.displayName=U6;var dD="MenuRadioGroup",[V6,H6]=uc(dD,{value:void 0,onValueChange:()=>{}}),uD=g.forwardRef((t,s)=>{const{value:n,onValueChange:r,...a}=t,i=xr(r);return e.jsx(V6,{scope:t.__scopeMenu,value:n,onValueChange:i,children:e.jsx(gb,{...a,ref:s})})});uD.displayName=dD;var hD="MenuRadioItem",mD=g.forwardRef((t,s)=>{const{value:n,...r}=t,a=H6(hD,t.__scopeMenu),i=n===a.value;return e.jsx(fD,{scope:t.__scopeMenu,checked:i,children:e.jsx(Qf,{role:"menuitemradio","aria-checked":i,...r,ref:s,"data-state":yb(i),onSelect:Yt(r.onSelect,()=>{var o;return(o=a.onValueChange)==null?void 0:o.call(a,n)},{checkForDefaultPrevented:!1})})})});mD.displayName=hD;var vb="MenuItemIndicator",[fD,W6]=uc(vb,{checked:!1}),pD=g.forwardRef((t,s)=>{const{__scopeMenu:n,forceMount:r,...a}=t,i=W6(vb,n);return e.jsx(jr,{present:r||hf(i.checked)||i.checked===!0,children:e.jsx(Ss.span,{...a,ref:s,"data-state":yb(i.checked)})})});pD.displayName=vb;var G6="MenuSeparator",xD=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t;return e.jsx(Ss.div,{role:"separator","aria-orientation":"horizontal",...r,ref:s})});xD.displayName=G6;var K6="MenuArrow",gD=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t,a=Zf(n);return e.jsx(Wf,{...a,...r,ref:s})});gD.displayName=K6;var Y6="MenuSub",[SY,vD]=uc(Y6),mu="MenuSubTrigger",yD=g.forwardRef((t,s)=>{const n=hc(mu,t.__scopeMenu),r=th(mu,t.__scopeMenu),a=vD(mu,t.__scopeMenu),i=pb(mu,t.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:d,onPointerGraceIntentChange:m}=i,f={__scopeMenu:t.__scopeMenu},p=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>p,[p]),g.useEffect(()=>{const h=d.current;return()=>{window.clearTimeout(h),m(null)}},[d,m]),e.jsx(mb,{asChild:!0,...f,children:e.jsx(oD,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":ND(n.open),...t,ref:Hr(s,a.onTriggerChange),onClick:h=>{var x;(x=t.onClick)==null||x.call(t,h),!(t.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Yt(t.onPointerMove,Eu(h=>{i.onItemEnter(h),!h.defaultPrevented&&!t.disabled&&!n.open&&!o.current&&(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),p()},100))})),onPointerLeave:Yt(t.onPointerLeave,Eu(h=>{var u,N;p();const x=(u=n.content)==null?void 0:u.getBoundingClientRect();if(x){const v=(N=n.content)==null?void 0:N.dataset.side,w=v==="right",j=w?-5:5,b=x[w?"left":"right"],C=x[w?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+j,y:h.clientY},{x:b,y:x.top},{x:C,y:x.top},{x:C,y:x.bottom},{x:b,y:x.bottom}],side:v}),window.clearTimeout(d.current),d.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Yt(t.onKeyDown,h=>{var u;const x=i.searchRef.current!=="";t.disabled||x&&h.key===" "||R6[r.dir].includes(h.key)&&(n.onOpenChange(!0),(u=n.content)==null||u.focus(),h.preventDefault())})})})});yD.displayName=mu;var bD="MenuSubContent",jD=g.forwardRef((t,s)=>{const n=rD($a,t.__scopeMenu),{forceMount:r=n.forceMount,...a}=t,i=hc($a,t.__scopeMenu),o=th($a,t.__scopeMenu),d=vD(bD,t.__scopeMenu),m=g.useRef(null),f=Ys(s,m);return e.jsx(Ru.Provider,{scope:t.__scopeMenu,children:e.jsx(jr,{present:r||i.open,children:e.jsx(Ru.Slot,{scope:t.__scopeMenu,children:e.jsx(xb,{id:d.contentId,"aria-labelledby":d.triggerId,...a,ref:f,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{var h;o.isUsingKeyboardRef.current&&((h=m.current)==null||h.focus()),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:Yt(t.onFocusOutside,p=>{p.target!==d.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Yt(t.onEscapeKeyDown,p=>{o.onClose(),p.preventDefault()}),onKeyDown:Yt(t.onKeyDown,p=>{var u;const h=p.currentTarget.contains(p.target),x=E6[o.dir].includes(p.key);h&&x&&(i.onOpenChange(!1),(u=d.trigger)==null||u.focus(),p.preventDefault())})})})})})});jD.displayName=bD;function ND(t){return t?"open":"closed"}function hf(t){return t==="indeterminate"}function yb(t){return hf(t)?"indeterminate":t?"checked":"unchecked"}function Z6(t){const s=document.activeElement;for(const n of t)if(n===s||(n.focus(),document.activeElement!==s))return}function Q6(t,s){return t.map((n,r)=>t[(s+r)%t.length])}function X6(t,s,n){const a=s.length>1&&Array.from(s).every(f=>f===s[0])?s[0]:s,i=n?t.indexOf(n):-1;let o=Q6(t,Math.max(i,0));a.length===1&&(o=o.filter(f=>f!==n));const m=o.find(f=>f.toLowerCase().startsWith(a.toLowerCase()));return m!==n?m:void 0}function J6(t,s){const{x:n,y:r}=t;let a=!1;for(let i=0,o=s.length-1;ir!=x>r&&n<(h-f)*(r-p)/(x-p)+f&&(a=!a)}return a}function e8(t,s){if(!s)return!1;const n={x:t.clientX,y:t.clientY};return J6(n,s)}function Eu(t){return s=>s.pointerType==="mouse"?t(s):void 0}var t8=nD,s8=mb,n8=aD,r8=iD,a8=gb,i8=lD,l8=Qf,o8=cD,c8=uD,d8=mD,u8=pD,h8=xD,m8=gD,f8=yD,p8=jD,Xf="DropdownMenu",[x8]=oa(Xf,[tD]),Kr=tD(),[g8,wD]=x8(Xf),SD=t=>{const{__scopeDropdownMenu:s,children:n,dir:r,open:a,defaultOpen:i,onOpenChange:o,modal:d=!0}=t,m=Kr(s),f=g.useRef(null),[p,h]=Li({prop:a,defaultProp:i??!1,onChange:o,caller:Xf});return e.jsx(g8,{scope:s,triggerId:yr(),triggerRef:f,contentId:yr(),open:p,onOpenChange:h,onOpenToggle:g.useCallback(()=>h(x=>!x),[h]),modal:d,children:e.jsx(t8,{...m,open:p,onOpenChange:h,dir:r,modal:d,children:n})})};SD.displayName=Xf;var CD="DropdownMenuTrigger",AD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=t,i=wD(CD,n),o=Kr(n);return e.jsx(s8,{asChild:!0,...o,children:e.jsx(Ss.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:Hr(s,i.triggerRef),onPointerDown:Yt(t.onPointerDown,d=>{!r&&d.button===0&&d.ctrlKey===!1&&(i.onOpenToggle(),i.open||d.preventDefault())}),onKeyDown:Yt(t.onKeyDown,d=>{r||(["Enter"," "].includes(d.key)&&i.onOpenToggle(),d.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(d.key)&&d.preventDefault())})})})});AD.displayName=CD;var v8="DropdownMenuPortal",kD=t=>{const{__scopeDropdownMenu:s,...n}=t,r=Kr(s);return e.jsx(n8,{...r,...n})};kD.displayName=v8;var DD="DropdownMenuContent",RD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=wD(DD,n),i=Kr(n),o=g.useRef(!1);return e.jsx(r8,{id:a.contentId,"aria-labelledby":a.triggerId,...i,...r,ref:s,onCloseAutoFocus:Yt(t.onCloseAutoFocus,d=>{var m;o.current||(m=a.triggerRef.current)==null||m.focus(),o.current=!1,d.preventDefault()}),onInteractOutside:Yt(t.onInteractOutside,d=>{const m=d.detail.originalEvent,f=m.button===0&&m.ctrlKey===!0,p=m.button===2||f;(!a.modal||p)&&(o.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});RD.displayName=DD;var y8="DropdownMenuGroup",b8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(a8,{...a,...r,ref:s})});b8.displayName=y8;var j8="DropdownMenuLabel",ED=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(i8,{...a,...r,ref:s})});ED.displayName=j8;var N8="DropdownMenuItem",_D=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(l8,{...a,...r,ref:s})});_D.displayName=N8;var w8="DropdownMenuCheckboxItem",TD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(o8,{...a,...r,ref:s})});TD.displayName=w8;var S8="DropdownMenuRadioGroup",C8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(c8,{...a,...r,ref:s})});C8.displayName=S8;var A8="DropdownMenuRadioItem",k8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(d8,{...a,...r,ref:s})});k8.displayName=A8;var D8="DropdownMenuItemIndicator",PD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(u8,{...a,...r,ref:s})});PD.displayName=D8;var R8="DropdownMenuSeparator",OD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(h8,{...a,...r,ref:s})});OD.displayName=R8;var E8="DropdownMenuArrow",_8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(m8,{...a,...r,ref:s})});_8.displayName=E8;var T8="DropdownMenuSubTrigger",P8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(f8,{...a,...r,ref:s})});P8.displayName=T8;var O8="DropdownMenuSubContent",L8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(p8,{...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)"}})});L8.displayName=O8;var I8=SD,M8=AD,F8=kD,B8=RD,$8=ED,q8=_D,z8=TD,U8=PD,V8=OD;function bb({...t}){return e.jsx(I8,{"data-slot":"dropdown-menu",...t})}function jb({...t}){return e.jsx(M8,{"data-slot":"dropdown-menu-trigger",...t})}function Nb({className:t,sideOffset:s=4,...n}){return e.jsx(F8,{children:e.jsx(B8,{"data-slot":"dropdown-menu-content",sideOffset:s,className:Nt("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",t),...n})})}function LD({className:t,inset:s,variant:n="default",...r}){return e.jsx(q8,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":n,className:Nt("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r})}function H8({className:t,children:s,checked:n,...r}){return e.jsxs(z8,{"data-slot":"dropdown-menu-checkbox-item",className:Nt("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),checked:n,...r,children:[e.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:e.jsx(U8,{children:e.jsx($n,{className:"size-4"})})}),s]})}function W8({className:t,inset:s,...n}){return e.jsx($8,{"data-slot":"dropdown-menu-label","data-inset":s,className:Nt("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",t),...n})}function G8({className:t,...s}){return e.jsx(V8,{"data-slot":"dropdown-menu-separator",className:Nt("bg-border -mx-1 my-1 h-px",t),...s})}const K8=Ky("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function we({className:t,variant:s,asChild:n=!1,...r}){const a=n?$A:"span";return e.jsx(a,{"data-slot":"badge",className:Nt(K8({variant:s}),t),...r})}const vm="/communication",Ko={getNotifications:async(t,s)=>{let n=`${vm}/notifications`;return t&&s&&(n+=`?page=${t}&limit=${s}`),(await Ie.get(n)).data},markAsRead:async t=>(await Ie.patch(`${vm}/notifications/${t}/read`)).data,markAllAsRead:async()=>(await Ie.patch(`${vm}/notifications/read-all`)).data,updatePushSubscription:async t=>(await Ie.post(`${vm}/notifications/subscribe`,{subscription:t})).data},Ii=Object.create(null);Ii.open="0";Ii.close="1";Ii.ping="2";Ii.pong="3";Ii.message="4";Ii.upgrade="5";Ii.noop="6";const $m=Object.create(null);Object.keys(Ii).forEach(t=>{$m[Ii[t]]=t});const fy={type:"error",data:"parser error"},ID=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",MD=typeof ArrayBuffer=="function",FD=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,wb=({type:t,data:s},n,r)=>ID&&s instanceof Blob?n?r(s):nS(s,r):MD&&(s instanceof ArrayBuffer||FD(s))?n?r(s):nS(new Blob([s]),r):r(Ii[t]+(s||"")),nS=(t,s)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];s("b"+(r||""))},n.readAsDataURL(t)};function rS(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let Rg;function Y8(t,s){if(ID&&t.data instanceof Blob)return t.data.arrayBuffer().then(rS).then(s);if(MD&&(t.data instanceof ArrayBuffer||FD(t.data)))return s(rS(t.data));wb(t,!1,n=>{Rg||(Rg=new TextEncoder),s(Rg.encode(n))})}const aS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fu=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t{let s=t.length*.75,n=t.length,r,a=0,i,o,d,m;t[t.length-1]==="="&&(s--,t[t.length-2]==="="&&s--);const f=new ArrayBuffer(s),p=new Uint8Array(f);for(r=0;r>4,p[a++]=(o&15)<<4|d>>2,p[a++]=(d&3)<<6|m&63;return f},Q8=typeof ArrayBuffer=="function",Sb=(t,s)=>{if(typeof t!="string")return{type:"message",data:BD(t,s)};const n=t.charAt(0);return n==="b"?{type:"message",data:X8(t.substring(1),s)}:$m[n]?t.length>1?{type:$m[n],data:t.substring(1)}:{type:$m[n]}:fy},X8=(t,s)=>{if(Q8){const n=Z8(t);return BD(n,s)}else return{base64:!0,data:t}},BD=(t,s)=>{switch(s){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},$D="",J8=(t,s)=>{const n=t.length,r=new Array(n);let a=0;t.forEach((i,o)=>{wb(i,!1,d=>{r[o]=d,++a===n&&s(r.join($D))})})},eB=(t,s)=>{const n=t.split($D),r=[];for(let a=0;a{const r=n.length;let a;if(r<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,r);else if(r<65536){a=new Uint8Array(3);const i=new DataView(a.buffer);i.setUint8(0,126),i.setUint16(1,r)}else{a=new Uint8Array(9);const i=new DataView(a.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(r))}t.data&&typeof t.data!="string"&&(a[0]|=128),s.enqueue(a),s.enqueue(n)})}})}let Eg;function ym(t){return t.reduce((s,n)=>s+n.length,0)}function bm(t,s){if(t[0].length===s)return t.shift();const n=new Uint8Array(s);let r=0;for(let a=0;aMath.pow(2,21)-1){d.enqueue(fy);break}a=p*Math.pow(2,32)+f.getUint32(4),r=3}else{if(ym(n)t){d.enqueue(fy);break}}}})}const qD=4;function Qn(t){if(t)return nB(t)}function nB(t){for(var s in Qn.prototype)t[s]=Qn.prototype[s];return t}Qn.prototype.on=Qn.prototype.addEventListener=function(t,s){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(s),this};Qn.prototype.once=function(t,s){function n(){this.off(t,n),s.apply(this,arguments)}return n.fn=s,this.on(t,n),this};Qn.prototype.off=Qn.prototype.removeListener=Qn.prototype.removeAllListeners=Qn.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;aPromise.resolve().then(s):(s,n)=>n(s,0),Fa=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),rB="arraybuffer";function zD(t,...s){return s.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{})}const aB=Fa.setTimeout,iB=Fa.clearTimeout;function ep(t,s){s.useNativeTimers?(t.setTimeoutFn=aB.bind(Fa),t.clearTimeoutFn=iB.bind(Fa)):(t.setTimeoutFn=Fa.setTimeout.bind(Fa),t.clearTimeoutFn=Fa.clearTimeout.bind(Fa))}const lB=1.33;function oB(t){return typeof t=="string"?cB(t):Math.ceil((t.byteLength||t.size)*lB)}function cB(t){let s=0,n=0;for(let r=0,a=t.length;r=57344?n+=3:(r++,n+=4);return n}function UD(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function dB(t){let s="";for(let n in t)t.hasOwnProperty(n)&&(s.length&&(s+="&"),s+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return s}function uB(t){let s={},n=t.split("&");for(let r=0,a=n.length;r{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)};eB(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,J8(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]=UD()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(s,n)}}let VD=!1;try{VD=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const fB=VD;function pB(){}class xB extends mB{constructor(s){if(super(s),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&s.hostname!==location.hostname||r!==s.port}}doWrite(s,n){const r=this.request({method:"POST",data:s});r.on("success",n),r.on("error",(a,i)=>{this.onError("xhr post error",a,i)})}doPoll(){const s=this.request();s.on("data",this.onData.bind(this)),s.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=s}}class Oi extends Qn{constructor(s,n,r){super(),this.createRequest=s,ep(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=zD(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=Oi.requestsCount++,Oi.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=pB,s)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Oi.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()}}Oi.requestsCount=0;Oi.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",iS);else if(typeof addEventListener=="function"){const t="onpagehide"in Fa?"pagehide":"unload";addEventListener(t,iS,!1)}}function iS(){for(let t in Oi.requests)Oi.requests.hasOwnProperty(t)&&Oi.requests[t].abort()}const gB=(function(){const t=HD({xdomain:!1});return t&&t.responseType!==null})();class vB extends xB{constructor(s){super(s);const n=s&&s.forceBase64;this.supportsBinary=gB&&!n}request(s={}){return Object.assign(s,{xd:this.xd},this.opts),new Oi(HD,this.uri(),s)}}function HD(t){const s=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!s||fB))return new XMLHttpRequest}catch{}if(!s)try{return new Fa[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const WD=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class yB extends Cb{get name(){return"websocket"}doOpen(){const s=this.uri(),n=this.opts.protocols,r=WD?{}:zD(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{try{this.doWrite(r,i)}catch{}a&&Jf(()=>{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]=UD()),this.supportsBinary||(n.b64=1),this.createUri(s,n)}}const _g=Fa.WebSocket||Fa.MozWebSocket;class bB extends yB{createSocket(s,n,r){return WD?new _g(s,n,r):n?new _g(s,n):new _g(s)}doWrite(s,n){this.ws.send(n)}}class jB extends Cb{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(s){return this.emitReserved("error",s)}this._transport.closed.then(()=>{this.onClose()}).catch(s=>{this.onError("webtransport error",s)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(s=>{const n=sB(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=s.readable.pipeThrough(n).getReader(),a=tB();a.readable.pipeTo(s.writable),this._writer=a.writable.getWriter();const i=()=>{r.read().then(({done:d,value:m})=>{d||(this.onPacket(m),i())}).catch(d=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(s){this.writable=!1;for(let n=0;n{a&&Jf(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var s;(s=this._transport)===null||s===void 0||s.close()}}const NB={websocket:bB,webtransport:jB,polling:vB},wB=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,SB=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function py(t){if(t.length>8e3)throw"URI too long";const s=t,n=t.indexOf("["),r=t.indexOf("]");n!=-1&&r!=-1&&(t=t.substring(0,n)+t.substring(n,r).replace(/:/g,";")+t.substring(r,t.length));let a=wB.exec(t||""),i={},o=14;for(;o--;)i[SB[o]]=a[o]||"";return n!=-1&&r!=-1&&(i.source=s,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=CB(i,i.path),i.queryKey=AB(i,i.query),i}function CB(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 AB(t,s){const n={};return s.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,a,i){a&&(n[a]=i)}),n}const xy=typeof addEventListener=="function"&&typeof removeEventListener=="function",qm=[];xy&&addEventListener("offline",()=>{qm.forEach(t=>t())},!1);class Ql extends Qn{constructor(s,n){if(super(),this.binaryType=rB,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,s&&typeof s=="object"&&(n=s,s=null),s){const r=py(s);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=py(n.host).host);ep(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=uB(this.opts.query)),xy&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},qm.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(s){const n=Object.assign({},this.opts.query);n.EIO=qD,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&&Ql.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",Ql.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;r0&&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,Jf(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),s}write(s,n,r){return this._sendPacket("message",s,n,r),this}send(s,n,r){return this._sendPacket("message",s,n,r),this}_sendPacket(s,n,r,a){if(typeof n=="function"&&(a=n,n=void 0),typeof r=="function"&&(a=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const i={type:s,data:n,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),a&&this.once("flush",a),this.flush()}close(){const s=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),s()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():s()}):this.upgrading?r():s()),this}_onError(s){if(Ql.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",s),this._onClose("transport error",s)}_onClose(s,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),xy&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=qm.indexOf(this._offlineEventListener);r!==-1&&qm.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",s,n),this.writeBuffer=[],this._prevBufferLen=0}}}Ql.protocol=qD;class kB extends Ql{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let s=0;s{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",h=>{if(!r)if(h.type==="pong"&&h.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Ql.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(p(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const x=new Error("probe error");x.transport=n.name,this.emitReserved("upgradeError",x)}}))};function i(){r||(r=!0,p(),n.close(),n=null)}const o=h=>{const x=new Error("probe error: "+h);x.transport=n.name,i(),this.emitReserved("upgradeError",x)};function d(){o("transport closed")}function m(){o("socket closed")}function f(h){n&&h.name!==n.name&&i()}const p=()=>{n.removeListener("open",a),n.removeListener("error",o),n.removeListener("close",d),this.off("close",m),this.off("upgrading",f)};n.once("open",a),n.once("error",o),n.once("close",d),this.once("close",m),this.once("upgrading",f),this._upgrades.indexOf("webtransport")!==-1&&s!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(s){this._upgrades=this._filterUpgrades(s.upgrades),super.onHandshake(s)}_filterUpgrades(s){const n=[];for(let r=0;rNB[a]).filter(a=>!!a)),super(s,r)}};function RB(t,s="",n){let r=t;n=n||typeof location<"u"&&location,t==null&&(t=n.protocol+"//"+n.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=n.protocol+t:t=n.host+t),/^(https?|wss?):\/\//.test(t)||(typeof n<"u"?t=n.protocol+"//"+t:t="https://"+t),r=py(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+s,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}const EB=typeof ArrayBuffer=="function",_B=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,GD=Object.prototype.toString,TB=typeof Blob=="function"||typeof Blob<"u"&&GD.call(Blob)==="[object BlobConstructor]",PB=typeof File=="function"||typeof File<"u"&&GD.call(File)==="[object FileConstructor]";function Ab(t){return EB&&(t instanceof ArrayBuffer||_B(t))||TB&&t instanceof Blob||PB&&t instanceof File}function zm(t,s){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n=0&&t.numthis.opts.maxAttachments)throw new Error("too many attachments");r.attachments=d}if(s.charAt(n+1)==="/"){const i=n+1;for(;++n&&!(s.charAt(n)===","||n===s.length););r.nsp=s.substring(i,n)}else r.nsp="/";const a=s.charAt(n+1);if(a!==""&&Number(a)==a){const i=n+1;for(;++n;){const o=s.charAt(n);if(o==null||Number(o)!=o){--n;break}if(n===s.length)break}r.id=Number(s.substring(i,n+1))}if(s.charAt(++n)){const i=this.tryParse(s.substr(n));if(kb.isPayloadValid(r.type,i))r.data=i;else throw new Error("invalid payload")}return r}tryParse(s){try{return JSON.parse(s,this.opts.reviver)}catch{return!1}}static isPayloadValid(s,n){switch(s){case on.CONNECT:return lS(n);case on.DISCONNECT:return n===void 0;case on.CONNECT_ERROR:return typeof n=="string"||lS(n);case on.EVENT:case on.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&IB.indexOf(n[0])===-1);case on.ACK:case on.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class FB{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=LB(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const BB=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};function lS(t){return Object.prototype.toString.call(t)==="[object Object]"}const $B=Object.freeze(Object.defineProperty({__proto__:null,Decoder:kb,Encoder:MB,get PacketType(){return on}},Symbol.toStringTag,{value:"Module"}));function ni(t,s,n){return t.on(s,n),function(){t.off(s,n)}}const qB=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class KD extends Qn{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=[ni(s,"open",this.onopen.bind(this)),ni(s,"packet",this.onpacket.bind(this)),ni(s,"error",this.onerror.bind(this)),ni(s,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...s){return s.unshift("message"),this.emit.apply(this,s),this}emit(s,...n){var r,a,i;if(qB.hasOwnProperty(s))throw new Error('"'+s.toString()+'" is a reserved event name');if(n.unshift(s),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const o={type:on.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const p=this.ids++,h=n.pop();this._registerAckCallback(p,h),o.id=p}const d=(a=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||a===void 0?void 0:a.writable,m=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!d||(m?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(s,n){var r;const a=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(a===void 0){this.acks[s]=n;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[s];for(let d=0;d{this.io.clearTimeoutFn(i),n.apply(this,d)};o.withError=!0,this.acks[s]=o}emitWithAck(s,...n){return new Promise((r,a)=>{const i=(o,d)=>o?a(o):r(d);i.withError=!0,n.push(i),this.emit(s,...n)})}_addToQueue(s){let n;typeof s[s.length-1]=="function"&&(n=s.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:s,flags:Object.assign({fromQueue:!0},this.flags)};s.push((a,...i)=>(this._queue[0],a!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(a)):(this._queue.shift(),n&&n(null,...i)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(s=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!s||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(s){s.nsp=this.nsp,this.io._packet(s)}onopen(){typeof this.auth=="function"?this.auth(s=>{this._sendConnectPacket(s)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(s){this.packet({type:on.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 on.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 on.EVENT:case on.BINARY_EVENT:this.onevent(s);break;case on.ACK:case on.BINARY_ACK:this.onack(s);break;case on.DISCONNECT:this.ondisconnect();break;case on.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:on.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:on.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;r0&&t.jitter<=1?t.jitter:0,this.attempts=0}wd.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};wd.prototype.reset=function(){this.attempts=0};wd.prototype.setMin=function(t){this.ms=t};wd.prototype.setMax=function(t){this.max=t};wd.prototype.setJitter=function(t){this.jitter=t};class yy extends Qn{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,ep(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 wd({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||$B;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 DB(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const a=ni(n,"open",function(){r.onopen(),s&&s()}),i=d=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",d),s?s(d):this.maybeReconnectOnOpen()},o=ni(n,"error",i);if(this._timeout!==!1){const d=this._timeout,m=this.setTimeoutFn(()=>{a(),i(new Error("timeout")),n.close()},d);this.opts.autoUnref&&m.unref(),this.subs.push(()=>{this.clearTimeoutFn(m)})}return this.subs.push(a),this.subs.push(o),this}connect(s){return this.open(s)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const s=this.engine;this.subs.push(ni(s,"ping",this.onping.bind(this)),ni(s,"data",this.ondata.bind(this)),ni(s,"error",this.onerror.bind(this)),ni(s,"close",this.onclose.bind(this)),ni(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){Jf(()=>{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 KD(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;rs()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(s,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",s,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const s=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{s.skipReconnect||(this.emitReserved("reconnect_attempt",s.backoff.attempts),!s.skipReconnect&&s.open(a=>{a?(s._reconnecting=!1,s.reconnect(),this.emitReserved("reconnect_error",a)):s.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const s=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",s)}}const su={};function Um(t,s){typeof t=="object"&&(s=t,t=void 0),s=s||{};const n=RB(t,s.path||"/socket.io"),r=n.source,a=n.id,i=n.path,o=su[a]&&i in su[a].nsps,d=s.forceNew||s["force new connection"]||s.multiplex===!1||o;let m;return d?m=new yy(r,s):(su[a]||(su[a]=new yy(r,s)),m=su[a]),n.query&&!s.query&&(s.query=n.queryKey),m.socket(n.path,s)}Object.assign(Um,{Manager:yy,Socket:KD,io:Um,connect:Um});const YD=g.createContext({socket:null,isConnected:!1}),ZD=()=>g.useContext(YD),zB=({children:t})=>{const[s,n]=g.useState(null),[r,a]=g.useState(!1),{user:i}=Pn(o=>o.auth);return g.useEffect(()=>{let o="https://dealeronboarding-uat.royalenfield.com/api";o.endsWith("/api")&&(o=o.replace(/\/api$/,""));const d=Um(o,{withCredentials:!0});return d.on("connect",()=>{console.log("Socket connected:",d.id),a(!0)}),d.on("disconnect",()=>{console.log("Socket disconnected"),a(!1)}),n(d),()=>{d.close()}},[]),g.useEffect(()=>{if(s&&r&&(i!=null&&i.id))return s.emit("join_room",`user_${i.id}`),console.log(`Joined private notification room: user_${i.id}`),()=>{s.emit("leave_room",`user_${i.id}`)}},[s,r,i==null?void 0:i.id]),e.jsx(YD.Provider,{value:{socket:s,isConnected:r},children:t})};function Gs(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 la(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function Ur(t,s){const n=Gs(t);return isNaN(s)?la(t,NaN):(s&&n.setDate(n.getDate()+s),n)}function di(t,s){const n=Gs(t);if(isNaN(s))return la(t,NaN);if(!s)return n;const r=n.getDate(),a=la(t,n.getTime());a.setMonth(n.getMonth()+s+1,0);const i=a.getDate();return r>=i?a:(n.setFullYear(a.getFullYear(),a.getMonth(),r),n)}const Db=6048e5,UB=864e5,jm=43200,oS=1440;let VB={};function Sd(){return VB}function Mi(t,s){var d,m,f,p;const n=Sd(),r=(s==null?void 0:s.weekStartsOn)??((m=(d=s==null?void 0:s.locale)==null?void 0:d.options)==null?void 0:m.weekStartsOn)??n.weekStartsOn??((p=(f=n.locale)==null?void 0:f.options)==null?void 0:p.weekStartsOn)??0,a=Gs(t),i=a.getDay(),o=(i=a.getTime()?n+1:s.getTime()>=o.getTime()?n:n-1}function od(t){const s=Gs(t);return s.setHours(0,0,0,0),s}function cd(t){const s=Gs(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 Ti(t,s){const n=od(t),r=od(s),a=+n-cd(n),i=+r-cd(r);return Math.round((a-i)/UB)}function HB(t){const s=QD(t),n=la(t,0);return n.setFullYear(s,0,4),n.setHours(0,0,0,0),rc(n)}function by(t,s){const n=s*7;return Ur(t,n)}function WB(t,s){return di(t,s*12)}function GB(t){let s;return t.forEach(function(n){const r=Gs(n);(s===void 0||s{const r=Gs(n);(!s||s>r||isNaN(+r))&&(s=r)}),s||new Date(NaN)}function Vm(t,s){const n=Gs(t),r=Gs(s),a=n.getTime()-r.getTime();return a<0?-1:a>0?1:a}function YB(t){return la(t,Date.now())}function na(t,s){const n=od(t),r=od(s);return+n==+r}function Rb(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function ZB(t){if(!Rb(t)&&typeof t!="number")return!1;const s=Gs(t);return!isNaN(Number(s))}function dd(t,s){const n=Gs(t),r=Gs(s),a=n.getFullYear()-r.getFullYear(),i=n.getMonth()-r.getMonth();return a*12+i}function QB(t,s,n){const r=Mi(t,n),a=Mi(s,n),i=+r-cd(r),o=+a-cd(a);return Math.round((i-o)/Db)}function XB(t){return s=>{const r=(t?Math[t]:Math.trunc)(s);return r===0?0:r}}function JB(t,s){return+Gs(t)-+Gs(s)}function e9(t){const s=Gs(t);return s.setHours(23,59,59,999),s}function tp(t){const s=Gs(t),n=s.getMonth();return s.setFullYear(s.getFullYear(),n+1,0),s.setHours(23,59,59,999),s}function t9(t){const s=Gs(t);return+e9(s)==+tp(s)}function s9(t,s){const n=Gs(t),r=Gs(s),a=Vm(n,r),i=Math.abs(dd(n,r));let o;if(i<1)o=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-a*i);let d=Vm(n,r)===-a;t9(Gs(t))&&i===1&&Vm(t,r)===1&&(d=!1),o=a*(i-Number(d))}return o===0?0:o}function n9(t,s,n){const r=JB(t,s)/1e3;return XB(n==null?void 0:n.roundingMethod)(r)}function ia(t){const s=Gs(t);return s.setDate(1),s.setHours(0,0,0,0),s}function XD(t){const s=Gs(t),n=la(t,0);return n.setFullYear(s.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Eb(t,s){var d,m,f,p;const n=Sd(),r=(s==null?void 0:s.weekStartsOn)??((m=(d=s==null?void 0:s.locale)==null?void 0:d.options)==null?void 0:m.weekStartsOn)??n.weekStartsOn??((p=(f=n.locale)==null?void 0:f.options)==null?void 0:p.weekStartsOn)??0,a=Gs(t),i=a.getDay(),o=(i{let r;const a=r9[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 Tg(t){return(s={})=>{const n=s.width?String(s.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const i9={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},l9={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},o9={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},c9={date:Tg({formats:i9,defaultWidth:"full"}),time:Tg({formats:l9,defaultWidth:"full"}),dateTime:Tg({formats:o9,defaultWidth:"full"})},d9={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},u9=(t,s,n,r)=>d9[t];function nu(t){return(s,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let a;if(r==="formatting"&&t.formattingValues){const o=t.defaultFormattingWidth||t.defaultWidth,d=n!=null&&n.width?String(n.width):o;a=t.formattingValues[d]||t.formattingValues[o]}else{const o=t.defaultWidth,d=n!=null&&n.width?String(n.width):t.defaultWidth;a=t.values[d]||t.values[o]}const i=t.argumentCallback?t.argumentCallback(s):s;return a[i]}}const h9={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},m9={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},f9={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"]},p9={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"]},x9={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"}},g9={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"}},v9=(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"},y9={ordinalNumber:v9,era:nu({values:h9,defaultWidth:"wide"}),quarter:nu({values:m9,defaultWidth:"wide",argumentCallback:t=>t-1}),month:nu({values:f9,defaultWidth:"wide"}),day:nu({values:p9,defaultWidth:"wide"}),dayPeriod:nu({values:x9,defaultWidth:"wide",formattingValues:g9,defaultFormattingWidth:"wide"})};function ru(t){return(s,n={})=>{const r=n.width,a=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],i=s.match(a);if(!i)return null;const o=i[0],d=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],m=Array.isArray(d)?j9(d,h=>h.test(o)):b9(d,h=>h.test(o));let f;f=t.valueCallback?t.valueCallback(m):m,f=n.valueCallback?n.valueCallback(f):f;const p=s.slice(o.length);return{value:f,rest:p}}}function b9(t,s){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&s(t[n]))return n}function j9(t,s){for(let n=0;n{const r=s.match(t.matchPattern);if(!r)return null;const a=r[0],i=s.match(t.parsePattern);if(!i)return null;let o=t.valueCallback?t.valueCallback(i[0]):i[0];o=n.valueCallback?n.valueCallback(o):o;const d=s.slice(a.length);return{value:o,rest:d}}}const w9=/^(\d+)(th|st|nd|rd)?/i,S9=/\d+/i,C9={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},A9={any:[/^b/i,/^(a|c)/i]},k9={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},D9={any:[/1/i,/2/i,/3/i,/4/i]},R9={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},E9={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]},_9={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},T9={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]},P9={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},O9={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}},L9={ordinalNumber:N9({matchPattern:w9,parsePattern:S9,valueCallback:t=>parseInt(t,10)}),era:ru({matchPatterns:C9,defaultMatchWidth:"wide",parsePatterns:A9,defaultParseWidth:"any"}),quarter:ru({matchPatterns:k9,defaultMatchWidth:"wide",parsePatterns:D9,defaultParseWidth:"any",valueCallback:t=>t+1}),month:ru({matchPatterns:R9,defaultMatchWidth:"wide",parsePatterns:E9,defaultParseWidth:"any"}),day:ru({matchPatterns:_9,defaultMatchWidth:"wide",parsePatterns:T9,defaultParseWidth:"any"}),dayPeriod:ru({matchPatterns:P9,defaultMatchWidth:"any",parsePatterns:O9,defaultParseWidth:"any"})},_b={code:"en-US",formatDistance:a9,formatLong:c9,formatRelative:u9,localize:y9,match:L9,options:{weekStartsOn:0,firstWeekContainsDate:1}};function I9(t){const s=Gs(t);return Ti(s,XD(s))+1}function eR(t){const s=Gs(t),n=+rc(s)-+HB(s);return Math.round(n/Db)+1}function tR(t,s){var p,h,x,u;const n=Gs(t),r=n.getFullYear(),a=Sd(),i=(s==null?void 0:s.firstWeekContainsDate)??((h=(p=s==null?void 0:s.locale)==null?void 0:p.options)==null?void 0:h.firstWeekContainsDate)??a.firstWeekContainsDate??((u=(x=a.locale)==null?void 0:x.options)==null?void 0:u.firstWeekContainsDate)??1,o=la(t,0);o.setFullYear(r+1,0,i),o.setHours(0,0,0,0);const d=Mi(o,s),m=la(t,0);m.setFullYear(r,0,i),m.setHours(0,0,0,0);const f=Mi(m,s);return n.getTime()>=d.getTime()?r+1:n.getTime()>=f.getTime()?r:r-1}function M9(t,s){var d,m,f,p;const n=Sd(),r=(s==null?void 0:s.firstWeekContainsDate)??((m=(d=s==null?void 0:s.locale)==null?void 0:d.options)==null?void 0:m.firstWeekContainsDate)??n.firstWeekContainsDate??((p=(f=n.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??1,a=tR(t,s),i=la(t,0);return i.setFullYear(a,0,r),i.setHours(0,0,0,0),Mi(i,s)}function sR(t,s){const n=Gs(t),r=+Mi(n,s)-+M9(n,s);return Math.round(r/Db)+1}function Nn(t,s){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(s,"0");return n+r}const Wl={y(t,s){const n=t.getFullYear(),r=n>0?n:1-n;return Nn(s==="yy"?r%100:r,s.length)},M(t,s){const n=t.getMonth();return s==="M"?String(n+1):Nn(n+1,2)},d(t,s){return Nn(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 Nn(t.getHours()%12||12,s.length)},H(t,s){return Nn(t.getHours(),s.length)},m(t,s){return Nn(t.getMinutes(),s.length)},s(t,s){return Nn(t.getSeconds(),s.length)},S(t,s){const n=s.length,r=t.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return Nn(a,s.length)}},zc={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},cS={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 Wl.y(t,s)},Y:function(t,s,n,r){const a=tR(t,r),i=a>0?a:1-a;if(s==="YY"){const o=i%100;return Nn(o,2)}return s==="Yo"?n.ordinalNumber(i,{unit:"year"}):Nn(i,s.length)},R:function(t,s){const n=QD(t);return Nn(n,s.length)},u:function(t,s){const n=t.getFullYear();return Nn(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 Nn(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 Nn(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 Wl.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 Nn(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=sR(t,r);return s==="wo"?n.ordinalNumber(a,{unit:"week"}):Nn(a,s.length)},I:function(t,s,n){const r=eR(t);return s==="Io"?n.ordinalNumber(r,{unit:"week"}):Nn(r,s.length)},d:function(t,s,n){return s==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):Wl.d(t,s)},D:function(t,s,n){const r=I9(t);return s==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):Nn(r,s.length)},E:function(t,s,n){const r=t.getDay();switch(s){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,s,n,r){const a=t.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(s){case"e":return String(i);case"ee":return Nn(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(t,s,n,r){const a=t.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(s){case"c":return String(i);case"cc":return Nn(i,s.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(t,s,n){const r=t.getDay(),a=r===0?7:r;switch(s){case"i":return String(a);case"ii":return Nn(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=zc.noon:r===0?a=zc.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=zc.evening:r>=12?a=zc.afternoon:r>=4?a=zc.morning:a=zc.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 Wl.h(t,s)},H:function(t,s,n){return s==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):Wl.H(t,s)},K:function(t,s,n){const r=t.getHours()%12;return s==="Ko"?n.ordinalNumber(r,{unit:"hour"}):Nn(r,s.length)},k:function(t,s,n){let r=t.getHours();return r===0&&(r=24),s==="ko"?n.ordinalNumber(r,{unit:"hour"}):Nn(r,s.length)},m:function(t,s,n){return s==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):Wl.m(t,s)},s:function(t,s,n){return s==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):Wl.s(t,s)},S:function(t,s){return Wl.S(t,s)},X:function(t,s,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(s){case"X":return uS(r);case"XXXX":case"XX":return zo(r);case"XXXXX":case"XXX":default:return zo(r,":")}},x:function(t,s,n){const r=t.getTimezoneOffset();switch(s){case"x":return uS(r);case"xxxx":case"xx":return zo(r);case"xxxxx":case"xxx":default:return zo(r,":")}},O:function(t,s,n){const r=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+dS(r,":");case"OOOO":default:return"GMT"+zo(r,":")}},z:function(t,s,n){const r=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+dS(r,":");case"zzzz":default:return"GMT"+zo(r,":")}},t:function(t,s,n){const r=Math.trunc(t.getTime()/1e3);return Nn(r,s.length)},T:function(t,s,n){const r=t.getTime();return Nn(r,s.length)}};function dS(t,s=""){const n=t>0?"-":"+",r=Math.abs(t),a=Math.trunc(r/60),i=r%60;return i===0?n+String(a):n+String(a)+s+Nn(i,2)}function uS(t,s){return t%60===0?(t>0?"-":"+")+Nn(Math.abs(t)/60,2):zo(t,s)}function zo(t,s=""){const n=t>0?"-":"+",r=Math.abs(t),a=Nn(Math.trunc(r/60),2),i=Nn(r%60,2);return n+a+s+i}const hS=(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"})}},nR=(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"})}},F9=(t,s)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return hS(t,s);let i;switch(r){case"P":i=s.dateTime({width:"short"});break;case"PP":i=s.dateTime({width:"medium"});break;case"PPP":i=s.dateTime({width:"long"});break;case"PPPP":default:i=s.dateTime({width:"full"});break}return i.replace("{{date}}",hS(r,s)).replace("{{time}}",nR(a,s))},B9={p:nR,P:F9},$9=/^D+$/,q9=/^Y+$/,z9=["D","DD","YY","YYYY"];function U9(t){return $9.test(t)}function V9(t){return q9.test(t)}function H9(t,s,n){const r=W9(t,s,n);if(console.warn(r),z9.includes(t))throw new RangeError(r)}function W9(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 G9=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,K9=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Y9=/^'([^]*?)'?$/,Z9=/''/g,Q9=/[a-zA-Z]/;function za(t,s,n){var p,h,x,u,N,v,w,j;const r=Sd(),a=(n==null?void 0:n.locale)??r.locale??_b,i=(n==null?void 0:n.firstWeekContainsDate)??((h=(p=n==null?void 0:n.locale)==null?void 0:p.options)==null?void 0:h.firstWeekContainsDate)??r.firstWeekContainsDate??((u=(x=r.locale)==null?void 0:x.options)==null?void 0:u.firstWeekContainsDate)??1,o=(n==null?void 0:n.weekStartsOn)??((v=(N=n==null?void 0:n.locale)==null?void 0:N.options)==null?void 0:v.weekStartsOn)??r.weekStartsOn??((j=(w=r.locale)==null?void 0:w.options)==null?void 0:j.weekStartsOn)??0,d=Gs(t);if(!ZB(d))throw new RangeError("Invalid time value");let m=s.match(K9).map(b=>{const C=b[0];if(C==="p"||C==="P"){const S=B9[C];return S(b,a.formatLong)}return b}).join("").match(G9).map(b=>{if(b==="''")return{isToken:!1,value:"'"};const C=b[0];if(C==="'")return{isToken:!1,value:X9(b)};if(cS[C])return{isToken:!0,value:b};if(C.match(Q9))throw new RangeError("Format string contains an unescaped latin alphabet character `"+C+"`");return{isToken:!1,value:b}});a.localize.preprocessor&&(m=a.localize.preprocessor(d,m));const f={firstWeekContainsDate:i,weekStartsOn:o,locale:a};return m.map(b=>{if(!b.isToken)return b.value;const C=b.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&V9(C)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&U9(C))&&H9(C,s,String(t));const S=cS[C[0]];return S(d,C,a.localize,f)}).join("")}function X9(t){const s=t.match(Y9);return s?s[1].replace(Z9,"'"):t}function J9(t,s,n){const r=Sd(),a=(n==null?void 0:n.locale)??r.locale??_b,i=2520,o=Vm(t,s);if(isNaN(o))throw new RangeError("Invalid time value");const d=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:o});let m,f;o>0?(m=Gs(s),f=Gs(t)):(m=Gs(t),f=Gs(s));const p=n9(f,m),h=(cd(f)-cd(m))/1e3,x=Math.round((p-h)/60);let u;if(x<2)return n!=null&&n.includeSeconds?p<5?a.formatDistance("lessThanXSeconds",5,d):p<10?a.formatDistance("lessThanXSeconds",10,d):p<20?a.formatDistance("lessThanXSeconds",20,d):p<40?a.formatDistance("halfAMinute",0,d):p<60?a.formatDistance("lessThanXMinutes",1,d):a.formatDistance("xMinutes",1,d):x===0?a.formatDistance("lessThanXMinutes",1,d):a.formatDistance("xMinutes",x,d);if(x<45)return a.formatDistance("xMinutes",x,d);if(x<90)return a.formatDistance("aboutXHours",1,d);if(xr.getTime()}function aR(t,s){const n=Gs(t),r=Gs(s);return+n<+r}function Tb(t,s){const n=Gs(t),r=Gs(s);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()}function r7(t,s){const n=Gs(t),r=Gs(s);return n.getFullYear()===r.getFullYear()}function Pg(t,s){return Ur(t,-s)}function Og(t,s){const n=Gs(t),r=n.getFullYear(),a=n.getDate(),i=la(t,0);i.setFullYear(r,s,15),i.setHours(0,0,0,0);const o=e7(i);return n.setMonth(s,Math.min(a,o)),n}function mS(t,s){const n=Gs(t);return isNaN(+n)?la(t,NaN):(n.setFullYear(s),n)}function a7({title:t,subtitle:s,onRefresh:n}){const{user:r}=Pn(h=>h.auth),{socket:a}=ZD(),[i,o]=g.useState([]),[d,m]=g.useState(0);g.useEffect(()=>{(async()=>{try{const x=await Ko.getNotifications(1,15);x.success&&(o(x.data),x.pagination&&x.pagination.unreadCount!==void 0?m(x.pagination.unreadCount):m(x.data.filter(u=>!u.isRead).length))}catch(x){console.error("Fetch notifications error:",x)}})()},[]),g.useEffect(()=>{if(a)return a.on("notification",h=>{o(x=>[h,...x].slice(0,15)),m(x=>x+1),J(h.title,{description:h.message,action:h.link?{label:"View",onClick:()=>window.location.href=h.link}:void 0})}),()=>{a.off("notification")}},[a]);const f=async h=>{try{h.isRead||(await Ko.markAsRead(h.id)).success&&(o(u=>u.map(N=>N.id===h.id?{...N,isRead:!0}:N)),m(u=>Math.max(0,u-1))),h.link&&(window.location.href=h.link)}catch(x){console.error("Notification click error:",x)}},p=async()=>{try{(await Ko.markAllAsRead()).success&&(o(x=>x.map(u=>({...u,isRead:!0}))),m(0))}catch(h){console.error("Mark all as read error:",h)}};return e.jsx("header",{className:"bg-white border-b border-slate-200 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900",children:t}),e.jsx("p",{className:"text-slate-600 text-sm leading-snug max-w-3xl",children:s})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-slate-100 rounded-lg",children:[e.jsx("div",{className:"w-8 h-8 bg-re-red rounded-full flex items-center justify-center",children:e.jsx(Rr,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-slate-900",children:r.name}),e.jsx("p",{className:"text-slate-600",children:r.role})]})]}),n&&e.jsx(te,{variant:"outline",size:"icon",onClick:n,title:"Refresh",children:e.jsx(or,{className:"w-4 h-4"})}),e.jsx(te,{variant:"outline",size:"icon",title:"Help",children:e.jsx(ok,{className:"w-4 h-4"})}),e.jsxs(bb,{children:[e.jsx(jb,{asChild:!0,children:e.jsxs(te,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(Au,{className:"w-4 h-4"}),d>0&&e.jsx(we,{variant:"destructive",className:"absolute -top-1 -right-1 w-5 h-5 p-0 flex items-center justify-center text-xs",children:d})]})}),e.jsxs(Nb,{align:"end",className:"w-80",children:[e.jsxs("div",{className:"p-3 border-b flex items-center justify-between",children:[e.jsx("p",{className:"font-semibold text-slate-900",children:"Notifications"}),d>0&&e.jsx("button",{onClick:p,className:"text-xs text-blue-600 hover:underline",children:"Mark all read"})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto custom-scrollbar",children:i.length===0?e.jsx("div",{className:"p-8 text-center text-slate-500",children:"No notifications yet"}):i.map(h=>e.jsxs(LD,{className:`p-3 cursor-pointer flex items-start gap-3 ${h.isRead?"":"bg-blue-50/50"}`,onClick:()=>f(h),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-slate-900 text-sm font-medium",children:h.title}),e.jsx("p",{className:"text-slate-600 text-xs mt-1 leading-relaxed",children:h.message}),e.jsx("p",{className:"text-slate-400 text-[10px] mt-2",children:rR(new Date(h.createdAt),{addSuffix:!0})})]}),!h.isRead&&e.jsx("div",{className:"w-2 h-2 bg-blue-600 rounded-full mt-1.5 flex-shrink-0"})]},h.id))}),e.jsx("div",{className:"p-3 border-t text-center",children:e.jsx("button",{onClick:()=>window.location.href="/notifications",className:"text-xs font-medium text-blue-600 hover:text-blue-800 transition-colors",children:"View All Notifications"})})]})]})]})]})})}function _e({className:t,...s}){return e.jsx("div",{"data-slot":"card",className:Nt("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border",t),...s})}function Xe({className:t,...s}){return e.jsx("div",{"data-slot":"card-header",className:Nt("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 pt-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...s})}function st({className:t,...s}){return e.jsx("h4",{"data-slot":"card-title",className:Nt("leading-none",t),...s})}function es({className:t,...s}){return e.jsx("p",{"data-slot":"card-description",className:Nt("text-muted-foreground",t),...s})}function Oe({className:t,...s}){return e.jsx("div",{"data-slot":"card-content",className:Nt("px-6 [&:last-child]:pb-6",t),...s})}function Ny(t,[s,n]){return Math.min(n,Math.max(s,t))}function i7(t,s){return g.useReducer((n,r)=>s[n][r]??n,t)}var Pb="ScrollArea",[iR]=oa(Pb),[l7,Ua]=iR(Pb),lR=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,type:r="hover",dir:a,scrollHideDelay:i=600,...o}=t,[d,m]=g.useState(null),[f,p]=g.useState(null),[h,x]=g.useState(null),[u,N]=g.useState(null),[v,w]=g.useState(null),[j,b]=g.useState(0),[C,S]=g.useState(0),[D,_]=g.useState(!1),[A,E]=g.useState(!1),q=Ys(s,R=>m(R)),O=Ku(a);return e.jsx(l7,{scope:n,type:r,dir:O,scrollHideDelay:i,scrollArea:d,viewport:f,onViewportChange:p,content:h,onContentChange:x,scrollbarX:u,onScrollbarXChange:N,scrollbarXEnabled:D,onScrollbarXEnabledChange:_,scrollbarY:v,onScrollbarYChange:w,scrollbarYEnabled:A,onScrollbarYEnabledChange:E,onCornerWidthChange:b,onCornerHeightChange:S,children:e.jsx(Ss.div,{dir:O,...o,ref:q,style:{position:"relative","--radix-scroll-area-corner-width":j+"px","--radix-scroll-area-corner-height":C+"px",...t.style}})})});lR.displayName=Pb;var oR="ScrollAreaViewport",cR=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,children:r,nonce:a,...i}=t,o=Ua(oR,n),d=g.useRef(null),m=Ys(s,d,o.onViewportChange);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),e.jsx(Ss.div,{"data-radix-scroll-area-viewport":"",...i,ref:m,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...t.style},children:e.jsx("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});cR.displayName=oR;var Bi="ScrollAreaScrollbar",dR=g.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=Ua(Bi,t.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:o}=a,d=t.orientation==="horizontal";return g.useEffect(()=>(d?i(!0):o(!0),()=>{d?i(!1):o(!1)}),[d,i,o]),a.type==="hover"?e.jsx(o7,{...r,ref:s,forceMount:n}):a.type==="scroll"?e.jsx(c7,{...r,ref:s,forceMount:n}):a.type==="auto"?e.jsx(uR,{...r,ref:s,forceMount:n}):a.type==="always"?e.jsx(Ob,{...r,ref:s}):null});dR.displayName=Bi;var o7=g.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=Ua(Bi,t.__scopeScrollArea),[i,o]=g.useState(!1);return g.useEffect(()=>{const d=a.scrollArea;let m=0;if(d){const f=()=>{window.clearTimeout(m),o(!0)},p=()=>{m=window.setTimeout(()=>o(!1),a.scrollHideDelay)};return d.addEventListener("pointerenter",f),d.addEventListener("pointerleave",p),()=>{window.clearTimeout(m),d.removeEventListener("pointerenter",f),d.removeEventListener("pointerleave",p)}}},[a.scrollArea,a.scrollHideDelay]),e.jsx(jr,{present:n||i,children:e.jsx(uR,{"data-state":i?"visible":"hidden",...r,ref:s})})}),c7=g.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=Ua(Bi,t.__scopeScrollArea),i=t.orientation==="horizontal",o=np(()=>m("SCROLL_END"),100),[d,m]=i7("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return g.useEffect(()=>{if(d==="idle"){const f=window.setTimeout(()=>m("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(f)}},[d,a.scrollHideDelay,m]),g.useEffect(()=>{const f=a.viewport,p=i?"scrollLeft":"scrollTop";if(f){let h=f[p];const x=()=>{const u=f[p];h!==u&&(m("SCROLL"),o()),h=u};return f.addEventListener("scroll",x),()=>f.removeEventListener("scroll",x)}},[a.viewport,i,m,o]),e.jsx(jr,{present:n||d!=="hidden",children:e.jsx(Ob,{"data-state":d==="hidden"?"hidden":"visible",...r,ref:s,onPointerEnter:Yt(t.onPointerEnter,()=>m("POINTER_ENTER")),onPointerLeave:Yt(t.onPointerLeave,()=>m("POINTER_LEAVE"))})})}),uR=g.forwardRef((t,s)=>{const n=Ua(Bi,t.__scopeScrollArea),{forceMount:r,...a}=t,[i,o]=g.useState(!1),d=t.orientation==="horizontal",m=np(()=>{if(n.viewport){const f=n.viewport.offsetWidth{const{orientation:n="vertical",...r}=t,a=Ua(Bi,t.__scopeScrollArea),i=g.useRef(null),o=g.useRef(0),[d,m]=g.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=xR(d.viewport,d.content),p={...r,sizes:d,onSizesChange:m,hasThumb:f>0&&f<1,onThumbChange:x=>i.current=x,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:x=>o.current=x};function h(x,u){return p7(x,o.current,d,u)}return n==="horizontal"?e.jsx(d7,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&i.current){const x=a.viewport.scrollLeft,u=fS(x,d,a.dir);i.current.style.transform=`translate3d(${u}px, 0, 0)`}},onWheelScroll:x=>{a.viewport&&(a.viewport.scrollLeft=x)},onDragScroll:x=>{a.viewport&&(a.viewport.scrollLeft=h(x,a.dir))}}):n==="vertical"?e.jsx(u7,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&i.current){const x=a.viewport.scrollTop,u=fS(x,d);i.current.style.transform=`translate3d(0, ${u}px, 0)`}},onWheelScroll:x=>{a.viewport&&(a.viewport.scrollTop=x)},onDragScroll:x=>{a.viewport&&(a.viewport.scrollTop=h(x))}}):null}),d7=g.forwardRef((t,s)=>{const{sizes:n,onSizesChange:r,...a}=t,i=Ua(Bi,t.__scopeScrollArea),[o,d]=g.useState(),m=g.useRef(null),f=Ys(s,m,i.onScrollbarXChange);return g.useEffect(()=>{m.current&&d(getComputedStyle(m.current))},[m]),e.jsx(mR,{"data-orientation":"horizontal",...a,ref:f,sizes:n,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":sp(n)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.x),onDragScroll:p=>t.onDragScroll(p.x),onWheelScroll:(p,h)=>{if(i.viewport){const x=i.viewport.scrollLeft+p.deltaX;t.onWheelScroll(x),vR(x,h)&&p.preventDefault()}},onResize:()=>{m.current&&i.viewport&&o&&r({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:m.current.clientWidth,paddingStart:ff(o.paddingLeft),paddingEnd:ff(o.paddingRight)}})}})}),u7=g.forwardRef((t,s)=>{const{sizes:n,onSizesChange:r,...a}=t,i=Ua(Bi,t.__scopeScrollArea),[o,d]=g.useState(),m=g.useRef(null),f=Ys(s,m,i.onScrollbarYChange);return g.useEffect(()=>{m.current&&d(getComputedStyle(m.current))},[m]),e.jsx(mR,{"data-orientation":"vertical",...a,ref:f,sizes:n,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":sp(n)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.y),onDragScroll:p=>t.onDragScroll(p.y),onWheelScroll:(p,h)=>{if(i.viewport){const x=i.viewport.scrollTop+p.deltaY;t.onWheelScroll(x),vR(x,h)&&p.preventDefault()}},onResize:()=>{m.current&&i.viewport&&o&&r({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:m.current.clientHeight,paddingStart:ff(o.paddingTop),paddingEnd:ff(o.paddingBottom)}})}})}),[h7,hR]=iR(Bi),mR=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:a,onThumbChange:i,onThumbPointerUp:o,onThumbPointerDown:d,onThumbPositionChange:m,onDragScroll:f,onWheelScroll:p,onResize:h,...x}=t,u=Ua(Bi,n),[N,v]=g.useState(null),w=Ys(s,q=>v(q)),j=g.useRef(null),b=g.useRef(""),C=u.viewport,S=r.content-r.viewport,D=xr(p),_=xr(m),A=np(h,10);function E(q){if(j.current){const O=q.clientX-j.current.left,R=q.clientY-j.current.top;f({x:O,y:R})}}return g.useEffect(()=>{const q=O=>{const R=O.target;(N==null?void 0:N.contains(R))&&D(O,S)};return document.addEventListener("wheel",q,{passive:!1}),()=>document.removeEventListener("wheel",q,{passive:!1})},[C,N,S,D]),g.useEffect(_,[r,_]),ud(N,A),ud(u.content,A),e.jsx(h7,{scope:n,scrollbar:N,hasThumb:a,onThumbChange:xr(i),onThumbPointerUp:xr(o),onThumbPositionChange:_,onThumbPointerDown:xr(d),children:e.jsx(Ss.div,{...x,ref:w,style:{position:"absolute",...x.style},onPointerDown:Yt(t.onPointerDown,q=>{q.button===0&&(q.target.setPointerCapture(q.pointerId),j.current=N.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",u.viewport&&(u.viewport.style.scrollBehavior="auto"),E(q))}),onPointerMove:Yt(t.onPointerMove,E),onPointerUp:Yt(t.onPointerUp,q=>{const O=q.target;O.hasPointerCapture(q.pointerId)&&O.releasePointerCapture(q.pointerId),document.body.style.webkitUserSelect=b.current,u.viewport&&(u.viewport.style.scrollBehavior=""),j.current=null})})})}),mf="ScrollAreaThumb",fR=g.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=hR(mf,t.__scopeScrollArea);return e.jsx(jr,{present:n||a.hasThumb,children:e.jsx(m7,{ref:s,...r})})}),m7=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,style:r,...a}=t,i=Ua(mf,n),o=hR(mf,n),{onThumbPositionChange:d}=o,m=Ys(s,h=>o.onThumbChange(h)),f=g.useRef(void 0),p=np(()=>{f.current&&(f.current(),f.current=void 0)},100);return g.useEffect(()=>{const h=i.viewport;if(h){const x=()=>{if(p(),!f.current){const u=x7(h,d);f.current=u,d()}};return d(),h.addEventListener("scroll",x),()=>h.removeEventListener("scroll",x)}},[i.viewport,p,d]),e.jsx(Ss.div,{"data-state":o.hasThumb?"visible":"hidden",...a,ref:m,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Yt(t.onPointerDownCapture,h=>{const u=h.target.getBoundingClientRect(),N=h.clientX-u.left,v=h.clientY-u.top;o.onThumbPointerDown({x:N,y:v})}),onPointerUp:Yt(t.onPointerUp,o.onThumbPointerUp)})});fR.displayName=mf;var Lb="ScrollAreaCorner",pR=g.forwardRef((t,s)=>{const n=Ua(Lb,t.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?e.jsx(f7,{...t,ref:s}):null});pR.displayName=Lb;var f7=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,...r}=t,a=Ua(Lb,n),[i,o]=g.useState(0),[d,m]=g.useState(0),f=!!(i&&d);return ud(a.scrollbarX,()=>{var h;const p=((h=a.scrollbarX)==null?void 0:h.offsetHeight)||0;a.onCornerHeightChange(p),m(p)}),ud(a.scrollbarY,()=>{var h;const p=((h=a.scrollbarY)==null?void 0:h.offsetWidth)||0;a.onCornerWidthChange(p),o(p)}),f?e.jsx(Ss.div,{...r,ref:s,style:{width:i,height:d,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function ff(t){return t?parseInt(t,10):0}function xR(t,s){const n=t/s;return isNaN(n)?0:n}function sp(t){const s=xR(t.viewport,t.content),n=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,r=(t.scrollbar.size-n)*s;return Math.max(r,18)}function p7(t,s,n,r="ltr"){const a=sp(n),i=a/2,o=s||i,d=a-o,m=n.scrollbar.paddingStart+o,f=n.scrollbar.size-n.scrollbar.paddingEnd-d,p=n.content-n.viewport,h=r==="ltr"?[0,p]:[p*-1,0];return gR([m,f],h)(t)}function fS(t,s,n="ltr"){const r=sp(s),a=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,i=s.scrollbar.size-a,o=s.content-s.viewport,d=i-r,m=n==="ltr"?[0,o]:[o*-1,0],f=Ny(t,m);return gR([0,o],[0,d])(f)}function gR(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 vR(t,s){return t>0&&t{})=>{let n={left:t.scrollLeft,top:t.scrollTop},r=0;return(function a(){const i={left:t.scrollLeft,top:t.scrollTop},o=n.left!==i.left,d=n.top!==i.top;(o||d)&&s(),n=i,r=window.requestAnimationFrame(a)})(),()=>window.cancelAnimationFrame(r)};function np(t,s){const n=xr(t),r=g.useRef(0);return g.useEffect(()=>()=>window.clearTimeout(r.current),[]),g.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,s)},[n,s])}function ud(t,s){const n=xr(s);Jn(()=>{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 g7=lR,v7=cR,y7=pR;function Ib({className:t,children:s,...n}){return e.jsxs(g7,{"data-slot":"scroll-area",className:Nt("relative",t),...n,children:[e.jsx(v7,{"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(b7,{}),e.jsx(y7,{})]})}function b7({className:t,orientation:s="vertical",...n}){return e.jsx(dR,{"data-slot":"scroll-area-scrollbar",orientation:s,className:Nt("flex touch-none p-px transition-colors select-none",s==="vertical"&&"h-full w-2.5 border-l border-l-transparent",s==="horizontal"&&"h-1 flex-col border-t border-t-transparent",t),...n,children:e.jsx(fR,{"data-slot":"scroll-area-thumb",className:Nt("relative flex-1 rounded-full",s==="vertical"&&"bg-border",s==="horizontal"&&"bg-slate-200/70")})})}function j7({onNavigate:t}){const s=[{title:"Total Applications",value:Ci.totalApplications,icon:ks,color:"bg-blue-500",trend:{value:12,isPositive:!0},filter:"all"},{title:"LOA Issued",value:Ci.loaIssued,icon:ln,color:"bg-green-500",trend:{value:8,isPositive:!0},filter:"Approved"},{title:"Level 1 Pending",value:Ci.level1Pending,icon:dn,color:"bg-red-500",trend:{value:3,isPositive:!1},filter:"Level 1 Pending"},{title:"Level 2 Pending",value:Ci.level2Pending,icon:aM,color:"bg-purple-500",trend:{value:5,isPositive:!0},filter:"Level 2 Pending"},{title:"Level 3 Pending",value:Ci.level3Pending,icon:ak,color:"bg-indigo-500",trend:{value:2,isPositive:!1},filter:"Level 3 Pending"},{title:"EOR In Progress",value:Ci.eorInProgress,icon:sn,color:"bg-cyan-500",trend:{value:1,isPositive:!0},filter:"EOR In Progress"},{title:"Disqualified",value:Ci.disqualified,icon:ai,color:"bg-red-500",trend:{value:4,isPositive:!1},filter:"Disqualified"},{title:"Pending Reminders",value:Ci.pendingReminders,icon:Gr,color:"bg-orange-500",trend:{value:7,isPositive:!1},filter:"Questionnaire Pending"},{title:"Shortlisted Today",value:Ci.shortlistedToday,icon:ln,color:"bg-teal-500",trend:{value:5,isPositive:!0},filter:"Shortlisted"},{title:"Pending Shortlisting",value:Ci.pendingShortlisting,icon:zI,color:"bg-yellow-500",trend:{value:2,isPositive:!1},filter:"all",action:"opportunity-requests"}],n=[{status:"Pending",count:45,color:"#f59e0b"},{status:"In Progress",count:68,color:"#3b82f6"},{status:"Approved",count:25,color:"#10b981"},{status:"Rejected",count:12,color:"#ef4444"}],r=[{location:"Mumbai",count:23},{location:"Delhi",count:18},{location:"Bangalore",count:21},{location:"Chennai",count:15},{location:"Kolkata",count:12},{location:"Others",count:61}],a=Math.max(...r.map(i=>i.count));return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:s.map(i=>{const o=i.icon,d=i.trend.isPositive?ll:Go;return e.jsxs(_e,{className:"cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>t(i.action||"applications",i.filter),children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(st,{className:"text-slate-600",children:i.title}),e.jsx("div",{className:`${i.color} p-2 rounded-lg`,children:e.jsx(o,{className:"w-5 h-5 text-white"})})]}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-end justify-between",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-slate-900",children:i.value}),e.jsxs("div",{className:`flex items-center gap-1 mt-1 ${i.trend.isPositive?"text-green-600":"text-red-600"}`,children:[e.jsx(d,{className:"w-3 h-3"}),e.jsxs("span",{children:[i.trend.value,"% from last month"]})]})]})})})]},i.title)})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Application Status Distribution"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:n.map(i=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:i.color}}),e.jsx("span",{className:"text-slate-700",children:i.status})]}),e.jsx("span",{className:"text-slate-900",children:i.count})]}),e.jsx("div",{className:"w-full bg-slate-200 rounded-full h-2",children:e.jsx("div",{className:"h-2 rounded-full transition-all",style:{width:`${i.count/150*100}%`,backgroundColor:i.color}})})]},i.status))})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Applications by Location"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:r.map(i=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-24 text-slate-700",children:i.location}),e.jsx("div",{className:"flex-1 bg-slate-200 rounded-full h-8 relative overflow-hidden",children:e.jsx("div",{className:"bg-re-red h-full rounded-full transition-all flex items-center justify-end px-3",style:{width:`${i.count/a*100}%`},children:e.jsx("span",{className:"text-white",children:i.count})})})]},i.location))})})]})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Recent Activity"})}),e.jsx(Oe,{children:e.jsx(Ib,{className:"h-80",children:e.jsx("div",{className:"space-y-4",children:qM.map(i=>e.jsxs("div",{className:"flex items-start gap-4 p-3 hover:bg-slate-50 rounded-lg cursor-pointer transition-colors",onClick:()=>t("applications"),children:[e.jsxs("div",{className:"w-10 h-10 bg-red-50 rounded-full flex items-center justify-center flex-shrink-0",children:[i.action==="Approved"&&e.jsx(ln,{className:"w-5 h-5 text-green-600"}),i.action==="Interview Scheduled"&&e.jsx(dn,{className:"w-5 h-5 text-blue-600"}),i.action==="Document Uploaded"&&e.jsx(ks,{className:"w-5 h-5 text-purple-600"}),i.action==="Reminder Sent"&&e.jsx(Gr,{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(we,{variant:"outline",children:i.applicationId}),e.jsx("span",{className:"text-slate-700",children:i.action})]}),e.jsxs("p",{className:"text-slate-500 mt-1",children:["by ",i.user]})]}),e.jsx("div",{className:"text-slate-500 flex-shrink-0",children:i.timestamp})]},i.id))})})})]})]})}var rp="Tabs",[N7]=oa(rp,[Gf]),yR=Gf(),[w7,Mb]=N7(rp),bR=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:d,activationMode:m="automatic",...f}=t,p=Ku(d),[h,x]=Li({prop:r,onChange:a,defaultProp:i??"",caller:rp});return e.jsx(w7,{scope:n,baseId:yr(),value:h,onValueChange:x,orientation:o,dir:p,activationMode:m,children:e.jsx(Ss.div,{dir:p,"data-orientation":o,...f,ref:s})})});bR.displayName=rp;var jR="TabsList",NR=g.forwardRef((t,s)=>{const{__scopeTabs:n,loop:r=!0,...a}=t,i=Mb(jR,n),o=yR(n);return e.jsx(Vk,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:e.jsx(Ss.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:s})})});NR.displayName=jR;var wR="TabsTrigger",SR=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...i}=t,o=Mb(wR,n),d=yR(n),m=kR(o.baseId,r),f=DR(o.baseId,r),p=r===o.value;return e.jsx(Hk,{asChild:!0,...d,focusable:!a,active:p,children:e.jsx(Ss.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":f,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:m,...i,ref:s,onMouseDown:Yt(t.onMouseDown,h=>{!a&&h.button===0&&h.ctrlKey===!1?o.onValueChange(r):h.preventDefault()}),onKeyDown:Yt(t.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&o.onValueChange(r)}),onFocus:Yt(t.onFocus,()=>{const h=o.activationMode!=="manual";!p&&!a&&h&&o.onValueChange(r)})})})});SR.displayName=wR;var CR="TabsContent",AR=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:r,forceMount:a,children:i,...o}=t,d=Mb(CR,n),m=kR(d.baseId,r),f=DR(d.baseId,r),p=r===d.value,h=g.useRef(p);return g.useEffect(()=>{const x=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(x)},[]),e.jsx(jr,{present:a||p,children:({present:x})=>e.jsx(Ss.div,{"data-state":p?"active":"inactive","data-orientation":d.orientation,role:"tabpanel","aria-labelledby":m,hidden:!x,id:f,tabIndex:0,...o,ref:s,style:{...t.style,animationDuration:h.current?"0s":void 0},children:x&&i})})});AR.displayName=CR;function kR(t,s){return`${t}-trigger-${s}`}function DR(t,s){return`${t}-content-${s}`}var S7=bR,C7=NR,A7=SR,k7=AR;function In({className:t,...s}){return e.jsx(S7,{"data-slot":"tabs",className:Nt("flex flex-col gap-2",t),...s})}function Mn({className:t,...s}){return e.jsx(C7,{"data-slot":"tabs-list",className:Nt("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-xl p-[3px] flex",t),...s})}function Ht({className:t,...s}){return e.jsx(A7,{"data-slot":"tabs-trigger",className:Nt("data-[state=active]:bg-card dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-xl border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...s})}function Vt({className:t,...s}){return e.jsx(k7,{"data-slot":"tabs-content",className:Nt("flex-1 outline-none",t),...s})}function D7(t){const s=R7(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find(_7);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function R7(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=P7(a),d=T7(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Hr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var E7=Symbol("radix.slottable");function _7(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===E7}function T7(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function P7(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 ap="Dialog",[RR,ER]=oa(ap),[O7,pi]=RR(ap),_R=t=>{const{__scopeDialog:s,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,d=g.useRef(null),m=g.useRef(null),[f,p]=Li({prop:r,defaultProp:a??!1,onChange:i,caller:ap});return e.jsx(O7,{scope:s,triggerRef:d,contentRef:m,contentId:yr(),titleId:yr(),descriptionId:yr(),open:f,onOpenChange:p,onOpenToggle:g.useCallback(()=>p(h=>!h),[p]),modal:o,children:n})};_R.displayName=ap;var TR="DialogTrigger",PR=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=pi(TR,n),i=Ys(s,a.triggerRef);return e.jsx(Ss.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":$b(a.open),...r,ref:i,onClick:Yt(t.onClick,a.onOpenToggle)})});PR.displayName=TR;var Fb="DialogPortal",[L7,OR]=RR(Fb,{forceMount:void 0}),LR=t=>{const{__scopeDialog:s,forceMount:n,children:r,container:a}=t,i=pi(Fb,s);return e.jsx(L7,{scope:s,forceMount:n,children:g.Children.map(r,o=>e.jsx(jr,{present:n||i.open,children:e.jsx(Nd,{asChild:!0,container:a,children:o})}))})};LR.displayName=Fb;var pf="DialogOverlay",IR=g.forwardRef((t,s)=>{const n=OR(pf,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=pi(pf,t.__scopeDialog);return i.modal?e.jsx(jr,{present:r||i.open,children:e.jsx(M7,{...a,ref:s})}):null});IR.displayName=pf;var I7=D7("DialogOverlay.RemoveScroll"),M7=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=pi(pf,n);return e.jsx(Ju,{as:I7,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(Ss.div,{"data-state":$b(a.open),...r,ref:s,style:{pointerEvents:"auto",...r.style}})})}),ac="DialogContent",MR=g.forwardRef((t,s)=>{const n=OR(ac,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=pi(ac,t.__scopeDialog);return e.jsx(jr,{present:r||i.open,children:i.modal?e.jsx(F7,{...a,ref:s}):e.jsx(B7,{...a,ref:s})})});MR.displayName=ac;var F7=g.forwardRef((t,s)=>{const n=pi(ac,t.__scopeDialog),r=g.useRef(null),a=Ys(s,n.contentRef,r);return g.useEffect(()=>{const i=r.current;if(i)return Kf(i)},[]),e.jsx(FR,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Yt(t.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Yt(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,d=o.button===0&&o.ctrlKey===!0;(o.button===2||d)&&i.preventDefault()}),onFocusOutside:Yt(t.onFocusOutside,i=>i.preventDefault())})}),B7=g.forwardRef((t,s)=>{const n=pi(ac,t.__scopeDialog),r=g.useRef(!1),a=g.useRef(!1);return e.jsx(FR,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,d;(o=t.onCloseAutoFocus)==null||o.call(t,i),i.defaultPrevented||(r.current||(d=n.triggerRef.current)==null||d.focus(),i.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:i=>{var m,f;(m=t.onInteractOutside)==null||m.call(t,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((f=n.triggerRef.current)==null?void 0:f.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),FR=g.forwardRef((t,s)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,d=pi(ac,n),m=g.useRef(null),f=Ys(s,m);return Bf(),e.jsxs(e.Fragment,{children:[e.jsx(Yu,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:e.jsx(yd,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":$b(d.open),...o,ref:f,onDismiss:()=>d.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(q7,{titleId:d.titleId}),e.jsx(U7,{contentRef:m,descriptionId:d.descriptionId})]})]})}),Bb="DialogTitle",BR=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=pi(Bb,n);return e.jsx(Ss.h2,{id:a.titleId,...r,ref:s})});BR.displayName=Bb;var $R="DialogDescription",qR=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=pi($R,n);return e.jsx(Ss.p,{id:a.descriptionId,...r,ref:s})});qR.displayName=$R;var zR="DialogClose",UR=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=pi(zR,n);return e.jsx(Ss.button,{type:"button",...r,ref:s,onClick:Yt(t.onClick,()=>a.onOpenChange(!1))})});UR.displayName=zR;function $b(t){return t?"open":"closed"}var VR="DialogTitleWarning",[$7,HR]=dI(VR,{contentName:ac,titleName:Bb,docsSlug:"dialog"}),q7=({titleId:t})=>{const s=HR(VR),n=`\`${s.contentName}\` requires a \`${s.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${s.titleName}\`, you can wrap it with our VisuallyHidden component. For more information, see https://radix-ui.com/primitives/docs/components/${s.docsSlug}`;return g.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},z7="DialogDescriptionWarning",U7=({contentRef:t,descriptionId:s})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${HR(z7).contentName}}.`;return g.useEffect(()=>{var i;const a=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");s&&a&&(document.getElementById(s)||console.warn(r))},[r,t,s]),null},qb=_R,WR=PR,zb=LR,ip=IR,lp=MR,GR=BR,KR=qR,Ub=UR;function ms({...t}){return e.jsx(qb,{"data-slot":"dialog",...t})}function oo({...t}){return e.jsx(WR,{"data-slot":"dialog-trigger",...t})}function V7({...t}){return e.jsx(zb,{"data-slot":"dialog-portal",...t})}const YR=g.forwardRef(({className:t,...s},n)=>e.jsx(ip,{ref:n,"data-slot":"dialog-overlay",className:Nt("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...s}));YR.displayName=ip.displayName;const us=g.forwardRef(({className:t,children:s,...n},r)=>e.jsxs(V7,{"data-slot":"dialog-portal",children:[e.jsx(YR,{}),e.jsxs(lp,{ref:r,"data-slot":"dialog-content",className:Nt("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...n,children:[s,e.jsxs(Ub,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[e.jsx(id,{}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));us.displayName=lp.displayName;function ys({className:t,...s}){return e.jsx("div",{"data-slot":"dialog-header",className:Nt("flex flex-col gap-2 text-center sm:text-left",t),...s})}function mn({className:t,...s}){return e.jsx("div",{"data-slot":"dialog-footer",className:Nt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...s})}function gs({className:t,...s}){return e.jsx(GR,{"data-slot":"dialog-title",className:Nt("text-lg leading-none font-semibold",t),...s})}function ws({className:t,...s}){return e.jsx(KR,{"data-slot":"dialog-description",className:Nt("text-muted-foreground text-sm",t),...s})}function H7(t){const s=W7(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find(K7);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function W7(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=Z7(a),d=Y7(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Hr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var G7=Symbol("radix.slottable");function K7(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===G7}function Y7(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function Z7(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 ZR=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"}),Q7="VisuallyHidden",QR=g.forwardRef((t,s)=>e.jsx(Ss.span,{...t,ref:s,style:{...ZR,...t.style}}));QR.displayName=Q7;var X7=QR,J7=[" ","Enter","ArrowUp","ArrowDown"],e$=[" ","Enter"],ic="Select",[op,cp,t$]=rb(ic),[Cd]=oa(ic,[t$,lo]),dp=lo(),[s$,co]=Cd(ic),[n$,r$]=Cd(ic),XR=t=>{const{__scopeSelect:s,children:n,open:r,defaultOpen:a,onOpenChange:i,value:o,defaultValue:d,onValueChange:m,dir:f,name:p,autoComplete:h,disabled:x,required:u,form:N}=t,v=dp(s),[w,j]=g.useState(null),[b,C]=g.useState(null),[S,D]=g.useState(!1),_=Ku(f),[A,E]=Li({prop:r,defaultProp:a??!1,onChange:i,caller:ic}),[q,O]=Li({prop:o,defaultProp:d,onChange:m,caller:ic}),R=g.useRef(null),P=w?N||!!w.closest("form"):!0,[L,$]=g.useState(new Set),Z=Array.from(L).map(Q=>Q.props.value).join(";");return e.jsx(Vf,{...v,children:e.jsxs(s$,{required:u,scope:s,trigger:w,onTriggerChange:j,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:S,onValueNodeHasChildrenChange:D,contentId:yr(),value:q,onValueChange:O,open:A,onOpenChange:E,dir:_,triggerPointerDownPosRef:R,disabled:x,children:[e.jsx(op.Provider,{scope:s,children:e.jsx(n$,{scope:t.__scopeSelect,onNativeOptionAdd:g.useCallback(Q=>{$(W=>new Set(W).add(Q))},[]),onNativeOptionRemove:g.useCallback(Q=>{$(W=>{const U=new Set(W);return U.delete(Q),U})},[]),children:n})}),P?e.jsxs(NE,{"aria-hidden":!0,required:u,tabIndex:-1,name:p,autoComplete:h,value:q,onChange:Q=>O(Q.target.value),disabled:x,form:N,children:[q===void 0?e.jsx("option",{value:""}):null,Array.from(L)]},Z):null]})})};XR.displayName=ic;var JR="SelectTrigger",eE=g.forwardRef((t,s)=>{const{__scopeSelect:n,disabled:r=!1,...a}=t,i=dp(n),o=co(JR,n),d=o.disabled||r,m=Ys(s,o.onTriggerChange),f=cp(n),p=g.useRef("touch"),[h,x,u]=SE(v=>{const w=f().filter(C=>!C.disabled),j=w.find(C=>C.value===o.value),b=CE(w,v,j);b!==void 0&&o.onValueChange(b.value)}),N=v=>{d||(o.onOpenChange(!0),u()),v&&(o.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return e.jsx(Qu,{asChild:!0,...i,children:e.jsx(Ss.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:d,"data-disabled":d?"":void 0,"data-placeholder":wE(o.value)?"":void 0,...a,ref:m,onClick:Yt(a.onClick,v=>{v.currentTarget.focus(),p.current!=="mouse"&&N(v)}),onPointerDown:Yt(a.onPointerDown,v=>{p.current=v.pointerType;const w=v.target;w.hasPointerCapture(v.pointerId)&&w.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(N(v),v.preventDefault())}),onKeyDown:Yt(a.onKeyDown,v=>{const w=h.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&x(v.key),!(w&&v.key===" ")&&J7.includes(v.key)&&(N(),v.preventDefault())})})})});eE.displayName=JR;var tE="SelectValue",sE=g.forwardRef((t,s)=>{const{__scopeSelect:n,className:r,style:a,children:i,placeholder:o="",...d}=t,m=co(tE,n),{onValueNodeHasChildrenChange:f}=m,p=i!==void 0,h=Ys(s,m.onValueNodeChange);return Jn(()=>{f(p)},[f,p]),e.jsx(Ss.span,{...d,ref:h,style:{pointerEvents:"none"},children:wE(m.value)?e.jsx(e.Fragment,{children:o}):i})});sE.displayName=tE;var a$="SelectIcon",nE=g.forwardRef((t,s)=>{const{__scopeSelect:n,children:r,...a}=t;return e.jsx(Ss.span,{"aria-hidden":!0,...a,ref:s,children:r||"▼"})});nE.displayName=a$;var i$="SelectPortal",rE=t=>e.jsx(Nd,{asChild:!0,...t});rE.displayName=i$;var lc="SelectContent",aE=g.forwardRef((t,s)=>{const n=co(lc,t.__scopeSelect),[r,a]=g.useState();if(Jn(()=>{a(new DocumentFragment)},[]),!n.open){const i=r;return i?zu.createPortal(e.jsx(iE,{scope:t.__scopeSelect,children:e.jsx(op.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),i):null}return e.jsx(lE,{...t,ref:s})});aE.displayName=lc;var si=10,[iE,uo]=Cd(lc),l$="SelectContentImpl",o$=H7("SelectContent.RemoveScroll"),lE=g.forwardRef((t,s)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:i,onPointerDownOutside:o,side:d,sideOffset:m,align:f,alignOffset:p,arrowPadding:h,collisionBoundary:x,collisionPadding:u,sticky:N,hideWhenDetached:v,avoidCollisions:w,...j}=t,b=co(lc,n),[C,S]=g.useState(null),[D,_]=g.useState(null),A=Ys(s,Y=>S(Y)),[E,q]=g.useState(null),[O,R]=g.useState(null),P=cp(n),[L,$]=g.useState(!1),Z=g.useRef(!1);g.useEffect(()=>{if(C)return Kf(C)},[C]),Bf();const Q=g.useCallback(Y=>{const[re,...ae]=P().map(ce=>ce.ref.current),[ue]=ae.slice(-1),ye=document.activeElement;for(const ce of Y)if(ce===ye||(ce==null||ce.scrollIntoView({block:"nearest"}),ce===re&&D&&(D.scrollTop=0),ce===ue&&D&&(D.scrollTop=D.scrollHeight),ce==null||ce.focus(),document.activeElement!==ye))return},[P,D]),W=g.useCallback(()=>Q([E,C]),[Q,E,C]);g.useEffect(()=>{L&&W()},[L,W]);const{onOpenChange:U,triggerPointerDownPosRef:M}=b;g.useEffect(()=>{if(C){let Y={x:0,y:0};const re=ue=>{var ye,ce;Y={x:Math.abs(Math.round(ue.pageX)-(((ye=M.current)==null?void 0:ye.x)??0)),y:Math.abs(Math.round(ue.pageY)-(((ce=M.current)==null?void 0:ce.y)??0))}},ae=ue=>{Y.x<=10&&Y.y<=10?ue.preventDefault():C.contains(ue.target)||U(!1),document.removeEventListener("pointermove",re),M.current=null};return M.current!==null&&(document.addEventListener("pointermove",re),document.addEventListener("pointerup",ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",re),document.removeEventListener("pointerup",ae,{capture:!0})}}},[C,U,M]),g.useEffect(()=>{const Y=()=>U(!1);return window.addEventListener("blur",Y),window.addEventListener("resize",Y),()=>{window.removeEventListener("blur",Y),window.removeEventListener("resize",Y)}},[U]);const[z,T]=SE(Y=>{const re=P().filter(ye=>!ye.disabled),ae=re.find(ye=>ye.ref.current===document.activeElement),ue=CE(re,Y,ae);ue&&setTimeout(()=>ue.ref.current.focus())}),F=g.useCallback((Y,re,ae)=>{const ue=!Z.current&&!ae;(b.value!==void 0&&b.value===re||ue)&&(q(Y),ue&&(Z.current=!0))},[b.value]),I=g.useCallback(()=>C==null?void 0:C.focus(),[C]),K=g.useCallback((Y,re,ae)=>{const ue=!Z.current&&!ae;(b.value!==void 0&&b.value===re||ue)&&R(Y)},[b.value]),G=r==="popper"?wy:oE,V=G===wy?{side:d,sideOffset:m,align:f,alignOffset:p,arrowPadding:h,collisionBoundary:x,collisionPadding:u,sticky:N,hideWhenDetached:v,avoidCollisions:w}:{};return e.jsx(iE,{scope:n,content:C,viewport:D,onViewportChange:_,itemRefCallback:F,selectedItem:E,onItemLeave:I,itemTextRefCallback:K,focusSelectedItem:W,selectedItemText:O,position:r,isPositioned:L,searchRef:z,children:e.jsx(Ju,{as:o$,allowPinchZoom:!0,children:e.jsx(Yu,{asChild:!0,trapped:b.open,onMountAutoFocus:Y=>{Y.preventDefault()},onUnmountAutoFocus:Yt(a,Y=>{var re;(re=b.trigger)==null||re.focus({preventScroll:!0}),Y.preventDefault()}),children:e.jsx(yd,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:Y=>Y.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:e.jsx(G,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:Y=>Y.preventDefault(),...j,...V,onPlaced:()=>$(!0),ref:A,style:{display:"flex",flexDirection:"column",outline:"none",...j.style},onKeyDown:Yt(j.onKeyDown,Y=>{const re=Y.ctrlKey||Y.altKey||Y.metaKey;if(Y.key==="Tab"&&Y.preventDefault(),!re&&Y.key.length===1&&T(Y.key),["ArrowUp","ArrowDown","Home","End"].includes(Y.key)){let ue=P().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);if(["ArrowUp","End"].includes(Y.key)&&(ue=ue.slice().reverse()),["ArrowUp","ArrowDown"].includes(Y.key)){const ye=Y.target,ce=ue.indexOf(ye);ue=ue.slice(ce+1)}setTimeout(()=>Q(ue)),Y.preventDefault()}})})})})})})});lE.displayName=l$;var c$="SelectItemAlignedPosition",oE=g.forwardRef((t,s)=>{const{__scopeSelect:n,onPlaced:r,...a}=t,i=co(lc,n),o=uo(lc,n),[d,m]=g.useState(null),[f,p]=g.useState(null),h=Ys(s,A=>p(A)),x=cp(n),u=g.useRef(!1),N=g.useRef(!0),{viewport:v,selectedItem:w,selectedItemText:j,focusSelectedItem:b}=o,C=g.useCallback(()=>{if(i.trigger&&i.valueNode&&d&&f&&v&&w&&j){const A=i.trigger.getBoundingClientRect(),E=f.getBoundingClientRect(),q=i.valueNode.getBoundingClientRect(),O=j.getBoundingClientRect();if(i.dir!=="rtl"){const ye=O.left-E.left,ce=q.left-ye,je=A.left-ce,Me=A.width+je,ut=Math.max(Me,E.width),jt=window.innerWidth-si,ft=Ny(ce,[si,Math.max(si,jt-ut)]);d.style.minWidth=Me+"px",d.style.left=ft+"px"}else{const ye=E.right-O.right,ce=window.innerWidth-q.right-ye,je=window.innerWidth-A.right-ce,Me=A.width+je,ut=Math.max(Me,E.width),jt=window.innerWidth-si,ft=Ny(ce,[si,Math.max(si,jt-ut)]);d.style.minWidth=Me+"px",d.style.right=ft+"px"}const R=x(),P=window.innerHeight-si*2,L=v.scrollHeight,$=window.getComputedStyle(f),Z=parseInt($.borderTopWidth,10),Q=parseInt($.paddingTop,10),W=parseInt($.borderBottomWidth,10),U=parseInt($.paddingBottom,10),M=Z+Q+L+U+W,z=Math.min(w.offsetHeight*5,M),T=window.getComputedStyle(v),F=parseInt(T.paddingTop,10),I=parseInt(T.paddingBottom,10),K=A.top+A.height/2-si,G=P-K,V=w.offsetHeight/2,Y=w.offsetTop+V,re=Z+Q+Y,ae=M-re;if(re<=K){const ye=R.length>0&&w===R[R.length-1].ref.current;d.style.bottom="0px";const ce=f.clientHeight-v.offsetTop-v.offsetHeight,je=Math.max(G,V+(ye?I:0)+ce+W),Me=re+je;d.style.height=Me+"px"}else{const ye=R.length>0&&w===R[0].ref.current;d.style.top="0px";const je=Math.max(K,Z+v.offsetTop+(ye?F:0)+V)+ae;d.style.height=je+"px",v.scrollTop=re-K+v.offsetTop}d.style.margin=`${si}px 0`,d.style.minHeight=z+"px",d.style.maxHeight=P+"px",r==null||r(),requestAnimationFrame(()=>u.current=!0)}},[x,i.trigger,i.valueNode,d,f,v,w,j,i.dir,r]);Jn(()=>C(),[C]);const[S,D]=g.useState();Jn(()=>{f&&D(window.getComputedStyle(f).zIndex)},[f]);const _=g.useCallback(A=>{A&&N.current===!0&&(C(),b==null||b(),N.current=!1)},[C,b]);return e.jsx(u$,{scope:n,contentWrapper:d,shouldExpandOnScrollRef:u,onScrollButtonChange:_,children:e.jsx("div",{ref:m,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:e.jsx(Ss.div,{...a,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});oE.displayName=c$;var d$="SelectPopperPosition",wy=g.forwardRef((t,s)=>{const{__scopeSelect:n,align:r="start",collisionPadding:a=si,...i}=t,o=dp(n);return e.jsx(Hf,{...o,...i,ref:s,align:r,collisionPadding:a,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});wy.displayName=d$;var[u$,Vb]=Cd(lc,{}),Sy="SelectViewport",cE=g.forwardRef((t,s)=>{const{__scopeSelect:n,nonce:r,...a}=t,i=uo(Sy,n),o=Vb(Sy,n),d=Ys(s,i.onViewportChange),m=g.useRef(0);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),e.jsx(op.Slot,{scope:n,children:e.jsx(Ss.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:d,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Yt(a.onScroll,f=>{const p=f.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:x}=o;if(x!=null&&x.current&&h){const u=Math.abs(m.current-p.scrollTop);if(u>0){const N=window.innerHeight-si*2,v=parseFloat(h.style.minHeight),w=parseFloat(h.style.height),j=Math.max(v,w);if(j0?S:0,h.style.justifyContent="flex-end")}}}m.current=p.scrollTop})})})]})});cE.displayName=Sy;var dE="SelectGroup",[h$,m$]=Cd(dE),uE=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t,a=yr();return e.jsx(h$,{scope:n,id:a,children:e.jsx(Ss.div,{role:"group","aria-labelledby":a,...r,ref:s})})});uE.displayName=dE;var hE="SelectLabel",mE=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t,a=m$(hE,n);return e.jsx(Ss.div,{id:a.id,...r,ref:s})});mE.displayName=hE;var xf="SelectItem",[f$,fE]=Cd(xf),pE=g.forwardRef((t,s)=>{const{__scopeSelect:n,value:r,disabled:a=!1,textValue:i,...o}=t,d=co(xf,n),m=uo(xf,n),f=d.value===r,[p,h]=g.useState(i??""),[x,u]=g.useState(!1),N=Ys(s,b=>{var C;return(C=m.itemRefCallback)==null?void 0:C.call(m,b,r,a)}),v=yr(),w=g.useRef("touch"),j=()=>{a||(d.onValueChange(r),d.onOpenChange(!1))};if(r==="")throw new Error("A 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(f$,{scope:n,value:r,disabled:a,textId:v,isSelected:f,onItemTextChange:g.useCallback(b=>{h(C=>C||((b==null?void 0:b.textContent)??"").trim())},[]),children:e.jsx(op.ItemSlot,{scope:n,value:r,disabled:a,textValue:p,children:e.jsx(Ss.div,{role:"option","aria-labelledby":v,"data-highlighted":x?"":void 0,"aria-selected":f&&x,"data-state":f?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...o,ref:N,onFocus:Yt(o.onFocus,()=>u(!0)),onBlur:Yt(o.onBlur,()=>u(!1)),onClick:Yt(o.onClick,()=>{w.current!=="mouse"&&j()}),onPointerUp:Yt(o.onPointerUp,()=>{w.current==="mouse"&&j()}),onPointerDown:Yt(o.onPointerDown,b=>{w.current=b.pointerType}),onPointerMove:Yt(o.onPointerMove,b=>{var C;w.current=b.pointerType,a?(C=m.onItemLeave)==null||C.call(m):w.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Yt(o.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=m.onItemLeave)==null||C.call(m))}),onKeyDown:Yt(o.onKeyDown,b=>{var S;((S=m.searchRef)==null?void 0:S.current)!==""&&b.key===" "||(e$.includes(b.key)&&j(),b.key===" "&&b.preventDefault())})})})})});pE.displayName=xf;var pu="SelectItemText",xE=g.forwardRef((t,s)=>{const{__scopeSelect:n,className:r,style:a,...i}=t,o=co(pu,n),d=uo(pu,n),m=fE(pu,n),f=r$(pu,n),[p,h]=g.useState(null),x=Ys(s,j=>h(j),m.onItemTextChange,j=>{var b;return(b=d.itemTextRefCallback)==null?void 0:b.call(d,j,m.value,m.disabled)}),u=p==null?void 0:p.textContent,N=g.useMemo(()=>e.jsx("option",{value:m.value,disabled:m.disabled,children:u},m.value),[m.disabled,m.value,u]),{onNativeOptionAdd:v,onNativeOptionRemove:w}=f;return Jn(()=>(v(N),()=>w(N)),[v,w,N]),e.jsxs(e.Fragment,{children:[e.jsx(Ss.span,{id:m.textId,...i,ref:x}),m.isSelected&&o.valueNode&&!o.valueNodeHasChildren?zu.createPortal(i.children,o.valueNode):null]})});xE.displayName=pu;var gE="SelectItemIndicator",vE=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t;return fE(gE,n).isSelected?e.jsx(Ss.span,{"aria-hidden":!0,...r,ref:s}):null});vE.displayName=gE;var Cy="SelectScrollUpButton",yE=g.forwardRef((t,s)=>{const n=uo(Cy,t.__scopeSelect),r=Vb(Cy,t.__scopeSelect),[a,i]=g.useState(!1),o=Ys(s,r.onScrollButtonChange);return Jn(()=>{if(n.viewport&&n.isPositioned){let d=function(){const f=m.scrollTop>0;i(f)};const m=n.viewport;return d(),m.addEventListener("scroll",d),()=>m.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),a?e.jsx(jE,{...t,ref:o,onAutoScroll:()=>{const{viewport:d,selectedItem:m}=n;d&&m&&(d.scrollTop=d.scrollTop-m.offsetHeight)}}):null});yE.displayName=Cy;var Ay="SelectScrollDownButton",bE=g.forwardRef((t,s)=>{const n=uo(Ay,t.__scopeSelect),r=Vb(Ay,t.__scopeSelect),[a,i]=g.useState(!1),o=Ys(s,r.onScrollButtonChange);return Jn(()=>{if(n.viewport&&n.isPositioned){let d=function(){const f=m.scrollHeight-m.clientHeight,p=Math.ceil(m.scrollTop)m.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),a?e.jsx(jE,{...t,ref:o,onAutoScroll:()=>{const{viewport:d,selectedItem:m}=n;d&&m&&(d.scrollTop=d.scrollTop+m.offsetHeight)}}):null});bE.displayName=Ay;var jE=g.forwardRef((t,s)=>{const{__scopeSelect:n,onAutoScroll:r,...a}=t,i=uo("SelectScrollButton",n),o=g.useRef(null),d=cp(n),m=g.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return g.useEffect(()=>()=>m(),[m]),Jn(()=>{var p;const f=d().find(h=>h.ref.current===document.activeElement);(p=f==null?void 0:f.ref.current)==null||p.scrollIntoView({block:"nearest"})},[d]),e.jsx(Ss.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Yt(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Yt(a.onPointerMove,()=>{var f;(f=i.onItemLeave)==null||f.call(i),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Yt(a.onPointerLeave,()=>{m()})})}),p$="SelectSeparator",x$=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t;return e.jsx(Ss.div,{"aria-hidden":!0,...r,ref:s})});x$.displayName=p$;var ky="SelectArrow",g$=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t,a=dp(n),i=co(ky,n),o=uo(ky,n);return i.open&&o.position==="popper"?e.jsx(Wf,{...a,...r,ref:s}):null});g$.displayName=ky;var v$="SelectBubbleInput",NE=g.forwardRef(({__scopeSelect:t,value:s,...n},r)=>{const a=g.useRef(null),i=Ys(r,a),o=Zy(s);return g.useEffect(()=>{const d=a.current;if(!d)return;const m=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(m,"value").set;if(o!==s&&p){const h=new Event("change",{bubbles:!0});p.call(d,s),d.dispatchEvent(h)}},[o,s]),e.jsx(Ss.select,{...n,style:{...ZR,...n.style},ref:i,defaultValue:s})});NE.displayName=v$;function wE(t){return t===""||t===void 0}function SE(t){const s=xr(t),n=g.useRef(""),r=g.useRef(0),a=g.useCallback(o=>{const d=n.current+o;s(d),(function m(f){n.current=f,window.clearTimeout(r.current),f!==""&&(r.current=window.setTimeout(()=>m(""),1e3))})(d)},[s]),i=g.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return g.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,a,i]}function CE(t,s,n){const a=s.length>1&&Array.from(s).every(f=>f===s[0])?s[0]:s,i=n?t.indexOf(n):-1;let o=y$(t,Math.max(i,0));a.length===1&&(o=o.filter(f=>f!==n));const m=o.find(f=>f.textValue.toLowerCase().startsWith(a.toLowerCase()));return m!==n?m:void 0}function y$(t,s){return t.map((n,r)=>t[(s+r)%t.length])}var b$=XR,j$=eE,N$=sE,w$=nE,S$=rE,C$=aE,A$=cE,k$=uE,D$=mE,AE=pE,kE=xE,DE=vE,R$=yE,E$=bE;function Rt({...t}){return e.jsx(b$,{"data-slot":"select",...t})}function pS({...t}){return e.jsx(k$,{"data-slot":"select-group",...t})}function Et({...t}){return e.jsx(N$,{"data-slot":"select-value",...t})}function _t({className:t,size:s="default",children:n,...r}){return e.jsxs(j$,{"data-slot":"select-trigger","data-size":s,className:Nt("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-full items-center justify-between gap-2 rounded-md border bg-input-background px-3 py-2 text-sm whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r,children:[n,e.jsx(w$,{asChild:!0,children:e.jsx(va,{className:"size-4 opacity-50"})})]})}function Tt({className:t,children:s,position:n="popper",...r}){return e.jsx(S$,{children:e.jsxs(C$,{"data-slot":"select-content",className:Nt("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,...r,children:[e.jsx(T$,{}),e.jsx(A$,{className:Nt("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:s}),e.jsx(P$,{})]})})}function _$({className:t,...s}){return e.jsx(D$,{"data-slot":"select-label",className:Nt("text-muted-foreground px-2 py-1.5 text-xs",t),...s})}function Pe({className:t,children:s,...n}){return e.jsxs(AE,{"data-slot":"select-item",className:Nt("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...n,children:[e.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:e.jsx(DE,{children:e.jsx($n,{className:"size-4"})})}),e.jsx(kE,{children:s})]})}function T$({className:t,...s}){return e.jsx(R$,{"data-slot":"select-scroll-up-button",className:Nt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(yu,{className:"size-4"})})}function P$({className:t,...s}){return e.jsx(E$,{"data-slot":"select-scroll-down-button",className:Nt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(va,{className:"size-4"})})}function Ms({className:t,...s}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto custom-scrollbar-x-slim",children:e.jsx("table",{"data-slot":"table",className:Nt("w-full caption-bottom text-sm",t),...s})})}function Fs({className:t,...s}){return e.jsx("thead",{"data-slot":"table-header",className:Nt("[&_tr]:border-b",t),...s})}function Bs({className:t,...s}){return e.jsx("tbody",{"data-slot":"table-body",className:Nt("[&_tr:last-child]:border-0",t),...s})}function lt({className:t,...s}){return e.jsx("tr",{"data-slot":"table-row",className:Nt("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",t),...s})}function me({className:t,...s}){return e.jsx("th",{"data-slot":"table-head",className:Nt("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}function oe({className:t,...s}){return e.jsx("td",{"data-slot":"table-cell",className:Nt("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}const RE={getOnboardingPayments:async()=>{var s,n;const t=await Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 Re.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 O$({onNavigate:t,onViewPaymentDetails:s,onViewAuditDetails:n,onViewFnFDetails:r}){var T,F,I,K;const[a,i]=g.useState([]),[o,d]=g.useState([]),[m,f]=g.useState([]),[p,h]=g.useState(!0);g.useEffect(()=>{x()},[]);const x=async()=>{try{h(!0);const[G,V]=await Promise.all([RE.getFnFSettlements(),ps.getApplications()]),Y=V.data||[],re=[];Y.forEach(ue=>{const ye=ue.overallStatus||ue.status,ce=["Payment Pending","Security Deposit","Security Details","LOI In Progress","LOI Issued","LOA Pending","Dealer Code Generation","LOA_APPROVAL"].includes(ye),je=ue.securityDeposits||[];je.length>0?je.forEach(Me=>{re.push({...Me,application:ue,paymentStatus:Me.status,paymentType:Me.depositType,amount:Me.amount,id:Me.id,applicationId:ue.applicationId||ue.id,createdAt:Me.createdAt,verificationDate:Me.verifiedAt})}):ce&&(["Payment Pending","Security Deposit","Security Details","LOI In Progress"].includes(ye)?re.push({id:`virtual-${ue.id}-sd`,applicationId:ue.applicationId||ue.id,application:ue,paymentStatus:"Pending",paymentType:"SECURITY_DEPOSIT",amount:5e5,createdAt:ue.updatedAt,isVirtual:!0}):["LOA Pending","Dealer Code Generation","LOA_APPROVAL"].includes(ye)&&re.push({id:`virtual-${ue.id}-ff`,applicationId:ue.applicationId||ue.id,application:ue,paymentStatus:"Pending",paymentType:"FIRST_FILL",amount:15e5,createdAt:ue.updatedAt,isVirtual:!0}))}),i(re),d(G);const ae=Y.filter(ue=>ue.status==="FDD_VERIFICATION"||ue.overallStatus==="FDD Verification"||ue.currentStage==="FDD");f(ae)}catch(G){console.error("Fetch error:",G),J.error("Failed to load dashboard data")}finally{h(!1)}},[u,N]=g.useState(!1),[v,w]=g.useState(!1),[j,b]=g.useState(null),[C,S]=g.useState([]),[D,_]=g.useState({department:"",description:"",type:"receivable",amount:""}),[A,E]=g.useState(""),q=()=>{const G=C.filter(re=>re.type==="receivable").reduce((re,ae)=>re+ae.amount,0),V=C.filter(re=>re.type==="payable").reduce((re,ae)=>re+ae.amount,0),Y=V-G;return{totalReceivable:G,totalPayable:V,netAmount:Y}},O=async()=>{if(C.length===0){J.error("Please add at least one line item");return}if(!A){J.error("Please add final remarks");return}try{h(!0),J.success("Finance summary submitted successfully"),N(!1),b(null),S([]),E(""),x()}catch{J.error("Failed to submit summary")}finally{h(!1)}},R=G=>{const V=String(G||"").trim().toLowerCase();return V==="paid"||V==="verified"},P=a.filter(G=>!R(G.paymentStatus)),L=a.filter(G=>R(G.paymentStatus)),$=o.filter(G=>G.status==="Initiated"||G.status==="Calculated"),Z=o.filter(G=>G.status==="Completed"||G.status==="Cleared"),Q=()=>{if(!D.department||!D.description||!D.amount){J.error("Please fill in all line item fields");return}const G={id:Date.now().toString(),department:D.department,description:D.description,type:D.type,amount:parseFloat(D.amount)};S([...C,G]),_({department:"",description:"",type:"receivable",amount:""}),J.success("Line item added")},W=G=>{S(C.filter(V=>V.id!==G)),J.info("Line item removed")},{totalReceivable:U,totalPayable:M,netAmount:z}=q();return p?e.jsxs("div",{className:"flex items-center justify-center p-20 text-re-red",children:[e.jsx(dn,{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(_e,{className:"cursor-pointer hover:shadow-lg transition-shadow border-red-200 bg-red-50/20",onClick:()=>{m.length>0&&n?n(m[0].applicationId||m[0].id):t==null||t("finance-onboarding")},children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{className:"text-re-red font-bold",children:"Pending Audits"}),e.jsx(st,{className:"text-3xl text-re-red",children:m.length})]}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-slate-600 text-xs font-medium",children:"FDD Sign-offs"}),e.jsx(te,{variant:"link",className:"p-0 h-auto text-re-red mt-2 text-xs",children:"Review Now →"})]})]}),e.jsxs(_e,{className:"cursor-pointer hover:shadow-lg transition-shadow border-yellow-200",onClick:()=>t==null?void 0:t("finance-onboarding"),children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Pending Verification"}),e.jsx(st,{className:"text-3xl text-yellow-600",children:P.length})]}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-slate-600",children:"Onboarding Payments"}),e.jsx(te,{variant:"link",className:"p-0 h-auto text-re-red mt-2",children:"View All →"})]})]}),e.jsxs(_e,{className:"cursor-pointer hover:shadow-lg transition-shadow border-green-200",onClick:()=>t==null?void 0:t("finance-onboarding"),children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Verified"}),e.jsx(st,{className:"text-3xl text-green-600",children:L.length})]}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-slate-600",children:"Total Validated"}),e.jsx(te,{variant:"link",className:"p-0 h-auto text-re-red mt-2",children:"View All →"})]})]}),e.jsxs(_e,{className:"cursor-pointer hover:shadow-lg transition-shadow border-orange-200",onClick:()=>t==null?void 0:t("finance-fnf"),children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Pending F&F Summary"}),e.jsx(st,{className:"text-3xl text-orange-600",children:$.length})]}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-slate-600",children:"Offboarding Cases"}),e.jsx(te,{variant:"link",className:"p-0 h-auto text-re-red mt-2",children:"View All →"})]})]}),e.jsxs(_e,{className:"cursor-pointer hover:shadow-lg transition-shadow border-green-200",onClick:()=>t==null?void 0:t("finance-fnf"),children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"F&F Completed"}),e.jsx(st,{className:"text-3xl text-green-600",children:Z.length})]}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-slate-600",children:"Settlements Done"}),e.jsx(te,{variant:"link",className:"p-0 h-auto text-re-red mt-2",children:"View All →"})]})]})]}),e.jsxs(In,{defaultValue:"onboarding",className:"w-full",children:[e.jsxs(Mn,{className:"grid w-full grid-cols-2",children:[e.jsxs(Ht,{value:"onboarding",children:[e.jsx(ya,{className:"w-4 h-4 mr-2"}),"Onboarding"]}),e.jsxs(Ht,{value:"fnf",children:[e.jsx(ks,{className:"w-4 h-4 mr-2"}),"F&F Settlement"]})]}),e.jsx(Vt,{value:"onboarding",className:"space-y-4",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Payment Verification"}),e.jsx(es,{children:"Verify dealer advance payments for onboarding applications"})]}),e.jsx(Oe,{children:e.jsxs(In,{defaultValue:"pending",className:"w-full",children:[e.jsxs(Mn,{children:[e.jsxs(Ht,{value:"pending",children:["Pending (",P.length,")"]}),e.jsxs(Ht,{value:"verified",children:["Verified (",L.length,")"]})]}),e.jsx(Vt,{value:"pending",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[P.map(G=>{var V,Y;return e.jsx(_e,{className:"border-yellow-200 bg-yellow-50/30",children:e.jsx(Oe,{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:((V=G.application)==null?void 0:V.applicationId)||"N/A"}),e.jsx(we,{className:"bg-yellow-100 text-yellow-700 border-yellow-300",children:G.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:(Y=G.application)==null?void 0:Y.applicantName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Type"}),e.jsx("p",{children:G.paymentType==="SECURITY_DEPOSIT"?"Security Deposit":G.paymentType==="FIRST_FILL"?"First Fill":G.paymentType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Amount"}),e.jsxs("p",{className:"text-re-red-hover font-bold",children:["₹",parseFloat(G.amount).toLocaleString("en-IN")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Created On"}),e.jsx("p",{children:Qt(G.createdAt)})]})]})]}),e.jsxs("div",{className:"ml-4 flex flex-col gap-2",children:[e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>{s&&s(G.applicationId||G.id)},children:[e.jsx(ks,{className:"w-4 h-4 mr-2"}),"View Details"]}),e.jsxs(te,{size:"sm",className:"bg-green-600 hover:bg-green-700 font-bold",onClick:()=>{s&&s(G.applicationId||G.id)},children:[e.jsx(ln,{className:"w-4 h-4 mr-2"}),"Verify Payment"]})]})]})})},G.id)}),P.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(ln,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No pending payment verifications"})]})]})}),e.jsx(Vt,{value:"verified",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:L.map(G=>{var V,Y;return e.jsx(_e,{className:"border-green-200 bg-green-50/30",children:e.jsx(Oe,{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:((V=G.application)==null?void 0:V.applicationId)||"N/A"}),e.jsx(we,{className:"bg-green-100 text-green-700 border-green-300",children:G.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:(Y=G.application)==null?void 0:Y.applicantName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Type"}),e.jsx("p",{children:G.paymentType==="SECURITY_DEPOSIT"?"Security Deposit":G.paymentType==="FIRST_FILL"?"First Fill":G.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(G.amount).toLocaleString("en-IN")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Verified On"}),e.jsx("p",{children:G.verificationDate?Qt(G.verificationDate):"N/A"})]})]})]}),e.jsx("div",{className:"ml-4",children:e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>{s&&s(G.applicationId||G.id)},children:[e.jsx(ks,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},G.id)})})})]})})]})}),e.jsx(Vt,{value:"fnf",className:"space-y-4",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"F&F Financial Summary"}),e.jsx(es,{children:"Create financial settlement summaries for resignation and termination cases"})]}),e.jsx(Oe,{children:e.jsxs(In,{defaultValue:"pending",className:"w-full",children:[e.jsxs(Mn,{children:[e.jsxs(Ht,{value:"pending",children:["Pending Summary (",$.length,")"]}),e.jsxs(Ht,{value:"completed",children:["Completed (",Z.length,")"]})]}),e.jsx(Vt,{value:"pending",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[$.map(G=>{var V,Y,re,ae,ue,ye,ce;return e.jsx(_e,{className:"border-orange-200 bg-orange-50/30",children:e.jsx(Oe,{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:((V=G.resignation)==null?void 0:V.resignationId)||G.id}),e.jsx(we,{variant:"outline",children:G.resignation?"Resignation":G.terminationRequest?"Termination":"General"}),e.jsx(we,{className:"bg-orange-100 text-orange-700 border-orange-300",children:G.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:((re=(Y=G.outlet)==null?void 0:Y.dealer)==null?void 0:re.fullName)||((ae=G.outlet)==null?void 0:ae.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 font-medium text-[10px] uppercase tracking-wider mb-1",children:"Dealer Code"}),e.jsx("p",{className:"font-mono text-xs font-bold text-blue-600",children:((ue=G.outlet)==null?void 0:ue.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:[((ye=G.outlet)==null?void 0:ye.city)||"N/A",", ",((ce=G.outlet)==null?void 0:ce.state)||""]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-white/50 p-2 rounded-lg border border-slate-100",children:[e.jsx(ln,{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:(G.clearances||[]).filter(je=>je.status==="NOC Submitted"||je.status==="Dues Pending").length}),"/16 Departments Cleared"]})]})]})]}),e.jsxs("div",{className:"ml-4 flex flex-col gap-2",children:[e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>{b(G),w(!0)},children:[e.jsx(ks,{className:"w-4 h-4 mr-2"}),"View Details"]}),e.jsxs(te,{size:"sm",className:"bg-blue-600 hover:bg-blue-700",onClick:()=>{b(G),S([]),E(""),N(!0)},children:[e.jsx(rk,{className:"w-4 h-4 mr-2"}),"Create Summary"]})]})]})})},G.id)}),$.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(ks,{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(Vt,{value:"completed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:Z.map(G=>e.jsx(_e,{className:"border-green-200 bg-green-50/30",children:e.jsx(Oe,{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:G.id}),e.jsx(we,{variant:"outline",children:G.type}),e.jsx(we,{className:"bg-green-100 text-green-700 border-green-300",children:G.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:G.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:G.dealerCode})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Net Settlement"}),e.jsxs("p",{className:G.netAmount&&G.netAmount>=0?"text-green-700":"text-red-700",children:["₹",G.netAmount?Math.abs(G.netAmount).toLocaleString("en-IN"):"0"]}),e.jsx("p",{className:"text-xs text-slate-500",children:G.netAmount&&G.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:G.completedOn})]})]})]}),e.jsx("div",{className:"ml-4",children:e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>{r&&r(G.id)},children:[e.jsx(ks,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},G.id))})})]})})]})})]}),e.jsx(ms,{open:u,onOpenChange:N,children:e.jsxs(us,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Create Financial Settlement Summary"}),e.jsxs(ws,{children:[((T=j==null?void 0:j.resignation)==null?void 0:T.resignationId)||(j==null?void 0:j.id)," - ",j==null?void 0:j.dealerName," (",j==null?void 0:j.dealerCode,")"]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"border rounded-lg p-4 bg-slate-50",children:[e.jsx("h3",{className:"text-sm font-bold mb-4",children:"Add Financial Line Item"}),e.jsxs("div",{className:"grid grid-cols-12 gap-3",children:[e.jsxs("div",{className:"col-span-3",children:[e.jsx(le,{className:"text-xs",children:"Department"}),e.jsx(it,{placeholder:"e.g., Warranty",value:D.department,onChange:G=>_({...D,department:G.target.value})})]}),e.jsxs("div",{className:"col-span-4",children:[e.jsx(le,{className:"text-xs",children:"Description"}),e.jsx(it,{placeholder:"e.g., Pending warranty claims",value:D.description,onChange:G=>_({...D,description:G.target.value})})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(le,{className:"text-xs",children:"Type"}),e.jsxs(Rt,{value:D.type,onValueChange:G=>_({...D,type:G}),children:[e.jsx(_t,{children:e.jsx(Et,{})}),e.jsxs(Tt,{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(le,{className:"text-xs",children:"Amount (₹)"}),e.jsx(it,{type:"number",placeholder:"0",value:D.amount,onChange:G=>_({...D,amount:G.target.value})})]}),e.jsx("div",{className:"col-span-1 flex items-end",children:e.jsx(te,{size:"sm",onClick:Q,className:"w-full bg-re-red hover:bg-re-red-hover",children:e.jsx(bn,{className:"w-4 h-4"})})})]})]}),C.length>0&&e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:C.map(G=>e.jsxs(lt,{children:[e.jsx(oe,{children:G.department}),e.jsx(oe,{children:G.description}),e.jsx(oe,{className:"text-center",children:e.jsx(we,{className:G.type==="receivable"?"bg-red-100 text-red-700 border-red-200":"bg-green-100 text-green-700 border-green-200",children:G.type==="receivable"?"Receivable":"Payable"})}),e.jsxs(oe,{className:`text-right font-medium ${G.type==="receivable"?"text-red-700":"text-green-700"}`,children:["₹",G.amount.toLocaleString("en-IN")]}),e.jsx(oe,{children:e.jsx(te,{size:"sm",variant:"ghost",onClick:()=>W(G.id),children:e.jsx(Zn,{className:"w-4 h-4 text-red-600"})})})]},G.id))})]})}),C.length>0&&e.jsxs("div",{className:"border rounded-lg p-4 bg-slate-900 text-white",children:[e.jsx("h3",{className:"text-sm font-bold mb-4",children:"Financial Settlement Summary"}),e.jsxs("div",{className:"grid grid-cols-3 gap-8",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wider mb-1",children:"Total Payable"}),e.jsxs("p",{className:"text-3xl font-bold text-green-400",children:["₹",M.toLocaleString("en-IN")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wider mb-1",children:"Total receivable"}),e.jsxs("p",{className:"text-3xl font-bold text-red-400",children:["₹",U.toLocaleString("en-IN")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wider mb-1",children:"Net Settlement"}),e.jsxs("p",{className:`text-3xl font-bold ${z>=0?"text-green-400":"text-red-400"}`,children:["₹",Math.abs(z).toLocaleString("en-IN")]}),e.jsx("p",{className:"text-xs text-slate-400 mt-1 italic",children:z>=0?"Payable to Dealer":"Receivable from Dealer"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(le,{className:"font-bold",children:["Summary Remarks ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ks,{placeholder:"Add your final reconciliation remarks here...",rows:4,value:A,onChange:G=>E(G.target.value)})]})]}),e.jsxs(mn,{className:"border-t pt-4",children:[e.jsx(te,{variant:"outline",onClick:()=>N(!1),children:"Discard"}),e.jsxs(te,{className:"bg-green-600 hover:bg-green-700",onClick:O,disabled:C.length===0,children:[e.jsx(dl,{className:"w-4 h-4 mr-2"}),"Finalize & Submit Summary"]})]})]})}),e.jsx(ms,{open:v,onOpenChange:w,children:e.jsxs(us,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Full Settlement Details"}),e.jsxs(ws,{children:[((F=j==null?void 0:j.resignation)==null?void 0:F.resignationId)||(j==null?void 0:j.id)," - ",j==null?void 0:j.dealerName]})]}),j&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(_e,{className:"bg-slate-50 border-none",children:e.jsxs(Oe,{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:((I=j.outlet)==null?void 0:I.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=j.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(we,{variant:"outline",className:"bg-red-50 text-re-red-hover border-red-200",children:j.status})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(_e,{className:"border-blue-100",children:[e.jsx(Xe,{className:"bg-blue-50/50 pb-2",children:e.jsxs(st,{className:"text-sm font-bold flex items-center gap-2",children:[e.jsx(ll,{className:"w-4 h-4 text-blue-600"}),"Receivables Check"]})}),e.jsxs(Oe,{className:"pt-4 space-y-3",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-500",children:"Security Deposit Credits"}),e.jsxs("span",{className:"font-bold text-slate-900",children:["₹",parseFloat(j.totalPayables||0).toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-500",children:"Other Payable Credits"}),e.jsx("span",{className:"font-bold text-slate-900",children:"₹0"})]}),e.jsxs("div",{className:"border-t pt-2 flex justify-between font-bold text-blue-700",children:[e.jsx("span",{children:"Total Payables"}),e.jsxs("span",{children:["₹",parseFloat(j.totalPayables||0).toLocaleString("en-IN")]})]})]})]}),e.jsxs(_e,{className:"border-red-100 shadow-sm",children:[e.jsx(Xe,{className:"bg-red-50/30 pb-2 border-b border-red-50",children:e.jsxs(st,{className:"text-sm font-bold flex items-center gap-2 text-red-700",children:[e.jsx(Go,{className:"w-4 h-4"}),"Receivables Check"]})}),e.jsxs(Oe,{className:"pt-4 space-y-3",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-500",children:"Departmental Dues (Recoverable)"}),e.jsxs("span",{className:"font-bold text-red-600",children:["₹",parseFloat(j.totalReceivables||0).toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-500",children:"Outstanding Invoices"}),e.jsx("span",{className:"font-bold text-slate-900",children:"₹0"})]}),e.jsxs("div",{className:"border-t pt-2 flex justify-between font-bold text-red-700",children:[e.jsx("span",{children:"Total Recoveries"}),e.jsxs("span",{children:["₹",parseFloat(j.totalReceivables||0).toLocaleString("en-IN")]})]})]})]})]}),e.jsxs("div",{className:"p-5 bg-slate-900 text-white rounded-xl flex items-center justify-between shadow-lg",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:`p-3 rounded-lg ${parseFloat(j.netAmount||0)>=0?"bg-emerald-500/20":"bg-rose-500/20"}`,children:e.jsx(ya,{className:`w-6 h-6 ${parseFloat(j.netAmount||0)>=0?"text-emerald-400":"text-rose-400"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-400 uppercase font-bold tracking-widest mb-1",children:"Final Net Financial Position"}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("p",{className:`text-3xl font-bold tracking-tight ${parseFloat(j.netAmount||0)>=0?"text-emerald-400":"text-rose-400"}`,children:["₹",Math.abs(parseFloat(j.netAmount||0)).toLocaleString("en-IN")]}),e.jsxs("span",{className:"text-xs font-medium text-slate-400",children:["(",parseFloat(j.netAmount||0)>=0?"Payable to Dealer":"Recoverable from Dealer",")"]})]})]})]}),e.jsx(te,{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(mn,{children:e.jsx(te,{onClick:()=>w(!1),children:"Close Overview"})})]})})]})}const Xl={getDashboardData:async()=>{var t;try{const s=await Re.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 Re.getConstitutionalChanges()).data}catch(t){throw console.error("Get constitutional changes error:",t),t}},submitConstitutionalChange:async t=>{try{return(await Re.createConstitutionalChange(t)).data}catch(s){throw console.error("Submit constitutional change error:",s),s}},getRelocationRequests:async()=>{try{return(await Re.getRelocationRequests()).data}catch(t){throw console.error("Get relocation requests error:",t),t}},submitRelocationRequest:async t=>{try{return(await Re.createRelocationRequest(t)).data}catch(s){throw console.error("Submit relocation request error:",s),s}}};function L$({currentUser:t,onNavigate:s}){var u,N;const[n,r]=g.useState(!0),[a,i]=g.useState(null);if(g.useEffect(()=>{(async()=>{try{const w=await Xl.getDashboardData();i(w)}catch(w){console.error("Failed to fetch dashboard:",w)}finally{r(!1)}})()},[]),n)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px]",children:[e.jsx(cs,{className:"w-10 h-10 text-re-red animate-spin mb-4"}),e.jsx("p",{className:"text-slate-600",children:"Loading your dashboard..."})]});const o=a||{},d=o.profile||{},m=o.stats||{constitutional:0,relocation:0,total:0},f=o.recentRequests||[],p=((u=o.outlets)==null?void 0:u[0])||{},h=[{title:"Constitutional Changes",value:m.constitutional,icon:cl,color:"bg-blue-500",change:"Active Requests",onClick:()=>s("dealer-constitutional")},{title:"Relocation Requests",value:m.relocation,icon:Mr,color:"bg-re-red",change:"Active Requests",onClick:()=>s("dealer-relocation")},{title:"My Outlets",value:((N=o.outlets)==null?void 0:N.length)||0,icon:ZI,color:"bg-purple-500",change:"Registered",onClick:()=>{}},{title:"Total Requests",value:m.total,icon:ll,color:"bg-green-500",change:"All time",onClick:()=>{}}],x=[{title:"Constitutional Change",description:"Request change in business structure",icon:cl,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:Mr,color:"bg-red-50 hover:bg-red-100 border-red-200",textColor:"text-re-red",onClick:()=>s("dealer-relocation")}];return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg bg-gradient-to-r from-re-red to-re-red-hover p-6 text-white",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-white mb-2",children:["Welcome back, ",d.name||(t==null?void 0:t.name),"!"]}),e.jsxs("p",{className:"text-white/90",children:["Dealer Code: ",d.dealerCode," • ",d.businessName]}),e.jsxs("p",{className:"text-white/90 text-sm mt-1",children:[p.name," • ",p.location]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-white",children:"Active Dealership"}),e.jsxs(we,{className:"bg-green-500 text-white border-0 mt-2",children:[e.jsx(ln,{className:"w-3 h-3 mr-1"}),"Operational"]})]})]})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:h.map((v,w)=>{const j=v.icon;return e.jsxs(_e,{className:"cursor-pointer hover:shadow-lg transition-shadow",onClick:v.onClick,children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(st,{className:"text-sm",children:v.title}),e.jsx("div",{className:`${v.color} p-2 rounded-lg`,children:e.jsx(j,{className:"h-4 w-4 text-white"})})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-slate-900 text-2xl",children:v.value}),e.jsx("p",{className:"text-xs text-slate-600 mt-1",children:v.change})]})]},w)})}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Quick Actions"}),e.jsx(es,{children:"Submit new requests and manage your dealership"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:x.map((v,w)=>{const j=v.icon;return e.jsx("button",{onClick:v.onClick,className:`${v.color} border-2 rounded-lg p-4 text-left transition-all`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`${v.textColor} p-2 bg-white rounded-lg`,children:e.jsx(j,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:`${v.textColor} mb-1`,children:v.title}),e.jsx("p",{className:"text-slate-600 text-sm",children:v.description})]})]})},w)})})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"My Recent Requests"}),e.jsx(es,{children:"Track the status of your submitted requests"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:f.map(v=>e.jsxs("div",{className:"flex items-center justify-between p-4 border border-slate-200 rounded-lg hover:bg-slate-50 transition-colors",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-slate-900",children:v.id}),e.jsx(we,{variant:"outline",className:"text-xs",children:v.type})]}),e.jsx("p",{className:"text-slate-600 text-sm",children:v.title}),e.jsxs("p",{className:"text-slate-500 text-xs mt-1",children:["Submitted on ",v.date]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(we,{className:`border ${v.color}`,children:v.status}),e.jsx(te,{variant:"ghost",size:"sm",children:"View"})]})]},v.id))})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(dn,{className:"w-5 h-5 text-re-red"}),"Important Reminders"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(sn,{className:"w-4 h-4 text-re-red mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 text-sm",children:"GST Filing Due"}),e.jsx("p",{className:"text-slate-600 text-xs",children:"Due by Jan 15, 2026"})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(sn,{className:"w-4 h-4 text-re-red mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 text-sm",children:"Inventory Audit Scheduled"}),e.jsx("p",{className:"text-slate-600 text-xs",children:"Jan 20, 2026"})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ln,{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(_e,{children:[e.jsx(Xe,{children:e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(ja,{className:"w-5 h-5 text-blue-600"}),"Support & Help"]})}),e.jsx(Oe,{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(te,{variant:"outline",className:"w-full mt-2",children:"Contact Support"})]})})]})]})]})}function I$({id:t,onBack:s}){const n=["PAN Card","GST Certificate","Aadhaar Card","Security Deposit Receipt","First Fill Receipt","Partnership Deed","LLP Agreement","Certificate of Incorporation","MOA","AOA","Firm Registration","Rental Agreement","Property Documents","Nodal Agreement","Cancelled Check","LOI Acknowledgement","Architecture Blueprint","Site Plan","Other"],[r,a]=g.useState(null),[i,o]=g.useState(!0),[d,m]=g.useState([]),[f,p]=g.useState(""),[h,x]=g.useState(null),[u,N]=g.useState(!1),[v,w]=g.useState(!1),j={panNumber:"",gstNumber:"",registeredAddress:"",bankName:"",accountNumber:"",ifscCode:"",branchName:"",accountHolderName:""},[b,C]=g.useState(j),[S,D]=g.useState(j),_=JSON.stringify(b)!==JSON.stringify(S),A=new Set(d.map(L=>String(L.documentType||"").trim().toLowerCase())),E=f?A.has(f.toLowerCase()):!1;g.useEffect(()=>{q()},[t]);const q=async()=>{var L,$;o(!0);try{const[Z,Q]=await Promise.all([Re.getApplicationById(t),Re.getDocuments(t)]);if((L=Z.data)!=null&&L.success){const W=Z.data.data,U={panNumber:W.panNumber||"",gstNumber:W.gstNumber||"",registeredAddress:W.registeredAddress||W.address||"",bankName:W.bankName||"",accountNumber:W.accountNumber||"",ifscCode:W.ifscCode||"",branchName:W.branchName||"",accountHolderName:W.accountHolderName||W.applicantName||""};a(W),C(U),D(U)}(($=Q.data)!=null&&$.success||Q.ok)&&m(Q.data.data||[])}catch(Z){console.error("Failed to fetch details:",Z),J.error("Failed to load application details")}finally{o(!1)}},O=async()=>{var L;w(!0);try{console.log("Saving business details for:",t,b);const $=await Re.updateApplication(t,b);if($.ok)J.success("Business details saved successfully"),await q();else{const Z=((L=$.data)==null?void 0:L.message)||"Failed to update business details";J.error(Z),console.error("Update failed:",$)}}catch($){console.error("Save details fatal error:",$),J.error($.message||"A network error occurred while saving")}finally{w(!1)}},R=L=>{L.target.files&&L.target.files[0]&&x(L.target.files[0])},P=async()=>{var $,Z,Q;if(!h||!f){J.error("Please select a document type and file");return}const L=new FormData;L.append("file",h),L.append("documentType",f),N(!0);try{const W=await Re.uploadDocument(t,L);if(($=W.data)!=null&&$.success||W.ok){J.success("Document uploaded successfully"),x(null),p("");const U=document.getElementById("file-upload");U&&(U.value="");const M=await Re.getDocuments(t);((Z=M.data)!=null&&Z.success||M.ok)&&m(M.data.data||[])}else J.error(((Q=W.data)==null?void 0:Q.message)||"Upload failed")}catch(W){console.error("Upload error:",W),J.error("Upload failed")}finally{N(!1)}};return i?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(or,{className:"w-8 h-8 animate-spin text-re-red"})}):r?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("button",{onClick:s,className:"mr-3 p-1.5 rounded-full hover:bg-slate-200 text-slate-600 transition-colors","data-testid":"onboarding-prospective-details-back-btn",children:e.jsx(io,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 text-2xl font-bold mb-1",children:"Application Details"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-slate-600 font-medium","data-testid":"onboarding-prospective-details-app-id",children:r.applicationId||"Loading..."}),r.districtId?e.jsx("span",{className:"text-[10px] bg-green-100 text-green-700 font-bold px-1.5 py-0.5 rounded uppercase tracking-wider","data-testid":"onboarding-prospective-details-type-badge",children:"Opportunity"}):e.jsx("span",{className:"text-[10px] bg-blue-100 text-blue-700 font-bold px-1.5 py-0.5 rounded uppercase tracking-wider","data-testid":"onboarding-prospective-details-type-badge",children:"Future Reference"})]})]})]})}),e.jsxs("div",{className:"animate-in fade-in duration-500 space-y-6",children:[e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 shadow-sm p-6","data-testid":"onboarding-prospective-details-summary-card",children:[e.jsx("div",{className:"mb-4 border-b pb-2",children:e.jsxs("h4",{className:"text-lg font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(qa,{className:"w-5 h-5 text-re-red"})," Application Summary"]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3","data-testid":"onboarding-prospective-details-applicant-info",children:[e.jsx("div",{className:"p-2 bg-blue-50 rounded-lg",children:e.jsx(Rr,{className:"w-4 h-4 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Applicant"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900","data-testid":"onboarding-prospective-details-name",children:r.applicantName}),e.jsxs("p",{className:"text-xs text-slate-600",children:[r.email," | ",r.phone]})]})]}),e.jsxs("div",{className:"flex items-start gap-3","data-testid":"onboarding-prospective-details-location-info",children:[e.jsx("div",{className:"p-2 bg-red-50 rounded-lg",children:e.jsx(Mr,{className:"w-4 h-4 text-re-red"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Proposed Location"}),e.jsxs("p",{className:"text-sm font-semibold text-slate-900",children:[r.city,", ",r.state]}),e.jsx("p",{className:"text-xs text-slate-600",children:r.preferredLocation||"Standard Area"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3","data-testid":"onboarding-prospective-details-concept-info",children:[e.jsx("div",{className:"p-2 bg-green-50 rounded-lg",children:e.jsx(ad,{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(dn,{className:"w-4 h-4 text-slate-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Applied On"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:r.createdAt?new Date(r.createdAt).toLocaleDateString("en-IN",{day:"numeric",month:"long",year:"numeric"}):"-"})]})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:e.jsxs("div",{className:"lg:col-span-3 space-y-6",children:[e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 shadow-sm overflow-hidden","data-testid":"onboarding-prospective-details-statutory-card",children:[e.jsxs("div",{className:"p-4 bg-slate-900 text-white flex justify-between items-center",children:[e.jsxs("h4",{className:"flex items-center gap-2 text-sm font-bold uppercase tracking-widest",children:[e.jsx(Wu,{className:"w-4 h-4 text-re-red"})," Statutory & Bank Details"]}),e.jsxs("button",{onClick:O,disabled:v,className:`text-xs text-white px-3 py-1 rounded font-bold transition-all flex items-center gap-1 disabled:opacity-50 ${_?"bg-emerald-600 hover:bg-emerald-700 ring-2 ring-emerald-300 animate-pulse":"bg-re-red hover:bg-re-red-hover"}`,"data-testid":"onboarding-prospective-details-save-statutory-btn",children:[v?e.jsx(or,{className:"w-3 h-3 animate-spin"}):e.jsx(Hn,{className:"w-3 h-3"}),"Save Business Info"]})]}),e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-x-6 gap-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Registered Business Name"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all",value:b.accountHolderName,onChange:L=>C({...b,accountHolderName:L.target.value}),placeholder:"As per legal documents","data-testid":"onboarding-prospective-details-input-biz-name"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Permanent Account Number (PAN)"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all uppercase",value:b.panNumber,onChange:L=>C({...b,panNumber:L.target.value.toUpperCase()}),placeholder:"ABCDE1234F",maxLength:10,"data-testid":"onboarding-prospective-details-input-pan"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"GST Identification Number (GSTIN)"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all uppercase",value:b.gstNumber,onChange:L=>C({...b,gstNumber:L.target.value.toUpperCase()}),placeholder:"27ABCDE1234F1Z5",maxLength:15,"data-testid":"onboarding-prospective-details-input-gst"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Registered Office Address"}),e.jsx("textarea",{rows:1,className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all",value:b.registeredAddress,onChange:L=>C({...b,registeredAddress:L.target.value}),placeholder:"Full legal address","data-testid":"onboarding-prospective-details-input-address"})]}),e.jsx("div",{className:"md:col-span-2 border-t pt-2 mt-2",children:e.jsxs("h5",{className:"text-xs font-black text-slate-900 uppercase flex items-center gap-2 mb-3",children:[e.jsx(ck,{className:"w-3.5 h-3.5 text-blue-600"})," Primary Bank Information"]})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Bank Name"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all",value:b.bankName,onChange:L=>C({...b,bankName:L.target.value}),placeholder:"e.g. HDFC Bank","data-testid":"onboarding-prospective-details-input-bank"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Account Number"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all",value:b.accountNumber,onChange:L=>C({...b,accountNumber:L.target.value}),placeholder:"Bank account number","data-testid":"onboarding-prospective-details-input-acc-num"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"IFSC Code"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all uppercase",value:b.ifscCode,onChange:L=>C({...b,ifscCode:L.target.value.toUpperCase()}),placeholder:"HDFC0001234",maxLength:11,"data-testid":"onboarding-prospective-details-input-ifsc"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Branch Name"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all",value:b.branchName,onChange:L=>C({...b,branchName:L.target.value}),placeholder:"e.g. South Mumbai","data-testid":"onboarding-prospective-details-input-branch"})]})]})})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 shadow-sm overflow-hidden","data-testid":"onboarding-prospective-details-upload-card",children:[e.jsx("div",{className:"p-4 border-b border-slate-200 bg-slate-50 flex justify-between items-center",children:e.jsxs("h4",{className:"flex items-center gap-2 text-sm font-bold uppercase tracking-widest text-slate-900",children:[e.jsx(vr,{className:"w-4 h-4 text-re-red"})," Required Documents"]})}),e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-4 bg-slate-50 rounded-lg border border-slate-100",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Document Category"}),f&&e.jsx("span",{className:"rounded-full bg-red-50 px-2 py-0.5 text-[10px] font-bold text-re-red",children:E?"Already uploaded":"Pending upload"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Hn,{className:`pointer-events-none absolute left-3 top-1/2 z-10 h-4 w-4 -translate-y-1/2 ${E?"text-green-600":"text-slate-300"}`}),e.jsxs(Rt,{value:f,onValueChange:p,disabled:u,children:[e.jsx(_t,{className:"h-12 rounded-xl border-slate-200 bg-gradient-to-r from-white to-slate-50 pl-10 pr-3 text-sm font-medium text-slate-700 shadow-sm focus:border-re-red/40 focus:ring-2 focus:ring-re-red","data-testid":"onboarding-prospective-details-doc-type-select",children:e.jsx(Et,{placeholder:"Choose document type"})}),e.jsx(Tt,{className:"rounded-xl border-slate-200 shadow-lg","data-testid":"onboarding-prospective-details-doc-type-content",children:n.map(L=>{const $=A.has(L.toLowerCase());return e.jsxs(AE,{value:L,textValue:L,className:Nt("relative flex w-full cursor-default select-none items-center gap-2 rounded-lg py-2 pl-2 pr-8 text-sm text-slate-700 outline-none","focus:bg-red-50 focus:text-slate-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50"),"data-testid":`onboarding-prospective-details-doc-type-item-${L.replace(/\s+/g,"-").toLowerCase()}`,children:[e.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:e.jsx(DE,{children:e.jsx($n,{className:"size-4"})})}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx(Hn,{className:Nt("h-4 w-4 shrink-0",$?"text-green-600":"text-slate-300"),"aria-hidden":!0}),e.jsx(kE,{children:L})]})]},L)})})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Select File"}),e.jsx("input",{type:"file",id:"file-upload",className:"w-full text-xs text-slate-600 file:mr-4 file:py-1 file:px-4 file:rounded-full file:border-0 file:text-xs file:font-semibold file:bg-red-50 file:text-re-red hover:file:bg-red-100",onChange:R,disabled:u,"data-testid":"onboarding-prospective-details-file-input"})]}),e.jsx("div",{className:"md:col-span-2 flex justify-end",children:e.jsxs("button",{onClick:P,disabled:!h||!f||u,className:"bg-re-red text-white px-5 py-2 rounded-md hover:bg-re-red-hover disabled:opacity-50 text-xs font-bold transition-all shadow-sm flex items-center gap-2","data-testid":"onboarding-prospective-details-upload-btn",children:[u?e.jsx(or,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(vr,{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(rf,{className:"w-4 h-4 text-blue-600"}),e.jsxs("h3",{className:"text-xs font-black uppercase tracking-tighter",children:["Uploaded Library (",d.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3","data-testid":"onboarding-prospective-details-doc-library",children:d.length>0?d.map((L,$)=>e.jsxs("div",{className:"flex justify-between items-center p-3 border border-slate-100 rounded-xl bg-slate-50 group hover:border-red-200 transition-all","data-testid":`onboarding-prospective-details-doc-item-${$}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-white flex items-center justify-center border border-slate-200 group-hover:bg-blue-50",children:e.jsx(rf,{className:"w-4 h-4 text-slate-400 group-hover:text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-bold text-slate-900","data-testid":`onboarding-prospective-details-doc-type-${$}`,children:L.documentType}),e.jsx("p",{className:"text-[10px] text-slate-400 truncate w-32",children:L.fileName})]})]}),e.jsx("span",{className:`text-[9px] px-2 py-0.5 rounded-full font-black uppercase tracking-tighter ${L.status==="Approved"?"bg-green-100 text-green-700":"bg-red-50 text-re-red"}`,"data-testid":`onboarding-prospective-details-doc-status-${$}`,children:L.status||"Pending"})]},L.id)):e.jsxs("div",{className:"col-span-2 py-8 text-center bg-slate-50 rounded-xl border border-dashed border-slate-200","data-testid":"onboarding-prospective-details-doc-empty",children:[e.jsx(qa,{className:"w-6 h-6 text-slate-300 mx-auto mb-2"}),e.jsx("p",{className:"text-xs text-slate-500 font-medium",children:"No documents in your library yet"})]})})]})]})]})]})})]})]}):e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 p-8 text-center",children:[e.jsx("p",{className:"text-slate-600 mb-4",children:"Application details not found."}),e.jsx("button",{onClick:s,className:"bg-re-red text-white px-4 py-2 rounded-md hover:bg-re-red-hover",children:"Go Back"})]})}function M$(){var f;const t=Lu(),s=tr(),n=xl(),{user:r}=Pn(p=>p.auth),[a,i]=g.useState(!1),[o,d]=g.useState("applicant"),m=()=>{t(SA()),J.info("Logged out successfully"),s("/")};return e.jsxs("div",{className:"flex h-screen bg-slate-50",children:[e.jsxs("div",{className:`bg-slate-900 text-white h-screen flex flex-col transition-all duration-300 ${a?"w-20":"w-64"}`,children:[e.jsx("div",{className:"p-4 border-b border-slate-800",children:a?e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-full",children:e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"block h-auto w-full max-h-10 object-contain"})}),e.jsx("button",{onClick:()=>i(!1),className:"p-1 hover:bg-slate-800 rounded transition-colors",title:"Expand sidebar",children:e.jsx(mi,{className:"w-5 h-5"})})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:()=>i(!0),className:"p-1 hover:bg-slate-800 rounded transition-colors",title:"Collapse sidebar",children:e.jsx(io,{className:"w-5 h-5"})})}),e.jsx("div",{className:"w-full",children:e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"mx-auto block h-auto w-full max-h-14 object-contain"})}),e.jsx("p",{className:"text-center text-[10px] font-bold uppercase tracking-[0.2em] text-slate-400",children:"Applicant Portal"})]})}),e.jsx("nav",{className:"flex-1 p-4 space-y-2",children:e.jsx("div",{children:e.jsxs("button",{onClick:()=>{d("applicant"),s("/prospective-dashboard")},className:`w-full flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${o==="applicant"?"bg-re-red text-white hover:bg-re-red-hover":"text-slate-300 hover:bg-slate-800 hover:text-white"}`,children:[e.jsx(ks,{className:"w-5 h-5 flex-shrink-0"}),!a&&e.jsx("span",{className:"flex-1 text-left",children:"My Applications"})]})})}),e.jsxs("div",{className:"p-4 border-t border-slate-800 space-y-2",children:[!a&&e.jsx("div",{className:"px-4 py-2 bg-slate-800 rounded-lg mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-re-red rounded-full flex items-center justify-center text-white ring-2 ring-white/20",children:e.jsx("span",{className:"font-bold",children:((f=r==null?void 0:r.name)==null?void 0:f.charAt(0))||"A"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:(r==null?void 0:r.name)||"Applicant"}),e.jsx("p",{className:"text-slate-400 truncate text-xs",children:(r==null?void 0:r.role)||"Prospective"})]})]})}),e.jsxs("button",{onClick:m,className:`w-full flex items-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all h-9 px-4 py-2 text-slate-300 hover:bg-slate-800 hover:text-white ${a?"justify-center":"justify-start"}`,children:[e.jsx(uk,{className:"w-5 h-5 flex-shrink-0"}),!a&&e.jsx("span",{className:"ml-3",children:"Logout"})]})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx("header",{className:"bg-white border-b border-slate-200 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 text-xl font-semibold",children:n.pathname.includes("/application/")?"Application details":"Applicant management"}),e.jsx("p",{className:"text-slate-600 text-sm max-w-2xl leading-snug",children:n.pathname.includes("/application/")?"Review and update statutory information and required documents for this application. Progress is coordinated by Royal Enfield after you submit.":"Start or continue your dealership application, upload documents, and use links we email you (for example the questionnaire)."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-slate-100 rounded-lg",children:[e.jsx("div",{className:"w-8 h-8 bg-re-red rounded-full flex items-center justify-center ring-2 ring-re-red/20",children:e.jsx(Rr,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-slate-900 text-sm font-medium",children:(r==null?void 0:r.name)||"Applicant"}),e.jsx("p",{className:"text-slate-600 text-xs",children:(r==null?void 0:r.role)||"User"})]})]}),e.jsx("button",{className:"p-2 rounded-md hover:bg-slate-100",title:"Refresh",onClick:()=>window.location.reload(),children:e.jsx(or,{className:"w-4 h-4 text-slate-600"})})]})]})}),e.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:e.jsxs(Xv,{children:[e.jsx(Ps,{path:"/",element:e.jsx(F$,{})}),e.jsx(Ps,{path:"/application/:id",element:e.jsx(B$,{})})]})})]})]})}function F$(){const t=tr(),{user:s}=Pn(i=>i.auth),[n,r]=g.useState([]);g.useEffect(()=>{s!=null&&s.id&&a()},[s==null?void 0:s.id]);const a=async()=>{var i;try{const o=await Re.getApplications();(i=o.data)!=null&&i.success&&r(o.data.data)}catch(o){console.error("Failed to fetch applications",o)}};return e.jsx("div",{className:"max-w-7xl mx-auto",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-8",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 text-3xl font-bold mb-2",children:"My Applications"}),e.jsx("p",{className:"text-slate-500 font-medium",children:"Track and manage your dealership applications"})]})}),n.length===0?e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 border-dashed p-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-50 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(ks,{className:"w-8 h-8 text-slate-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-slate-900 mb-1",children:"No applications found"}),e.jsx("p",{className:"text-slate-500 max-w-sm mx-auto mb-6",children:"You haven't submitted any dealership applications yet."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:n.map(i=>e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 p-6 shadow-sm hover:shadow-md hover:border-re-red cursor-pointer transition-all group",onClick:()=>t(`/prospective-dashboard/application/${i.id}`),children:[e.jsx("div",{className:"mb-4",children:e.jsx("div",{className:"w-12 h-12 bg-red-50 rounded-xl flex items-center justify-center group-hover:bg-re-red transition-colors",children:e.jsx(ks,{className:"w-6 h-6 text-re-red group-hover:text-white"})})}),e.jsx("h3",{className:"text-xl font-bold text-slate-900 mb-1 truncate",children:i.applicationId}),e.jsxs("p",{className:"text-slate-500 text-sm mb-4 font-medium",children:[i.city,", ",i.state]}),e.jsx("div",{className:"space-y-4 pt-6 border-t border-slate-100",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-slate-500 font-medium",children:"Applied"}),e.jsx("span",{className:"text-xs font-bold text-slate-600",children:Qt(i.createdAt)})]})})]},i.id))})]})})}function B$(){const{id:t}=gd(),s=tr();return t?e.jsx("div",{className:"max-w-7xl mx-auto",children:e.jsx(I$,{id:t,onBack:()=>s("/prospective-dashboard")})}):null}function $$(){const t=tr(),[s,n]=g.useState([]),[r,a]=g.useState(!0),[i,o]=g.useState("");g.useEffect(()=>{d()},[]);const d=async()=>{var f;a(!0);try{const p=await Re.getApplications();(f=p.data)!=null&&f.success&&n(p.data.data)}catch(p){console.error("Failed to fetch FDD applications:",p),J.error("Failed to load assigned applications")}finally{a(!1)}},m=s.filter(f=>{var p;return f.applicationId.toLowerCase().includes(i.toLowerCase())||f.applicantName.toLowerCase().includes(i.toLowerCase())||((p=f.city)==null?void 0:p.toLowerCase().includes(i.toLowerCase()))});return e.jsxs("div",{className:"space-y-6 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-slate-900 tracking-tight",children:"FDD Dashboard"}),e.jsx("p",{className:"text-slate-500",children:"Manage financial due diligence for assigned dealer applications"})]}),e.jsxs("button",{onClick:d,className:"flex items-center gap-2 px-4 py-2 bg-white border border-slate-200 rounded-lg hover:bg-slate-50 transition-colors text-sm font-medium",children:[e.jsx(or,{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(_e,{className:"bg-white border-slate-200 shadow-sm",children:e.jsx(Oe,{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(ks,{className:"w-5 h-5"})})]})})}),e.jsx(_e,{className:"bg-white border-slate-200 shadow-sm",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"Pending Reports"}),e.jsx("h3",{className:"text-2xl font-bold text-slate-900",children:s.filter(f=>f.currentStage==="FDD"||f.overallStatus==="Active").length})]}),e.jsx("div",{className:"p-2 bg-slate-100 rounded-lg text-slate-600",children:e.jsx(dn,{className:"w-5 h-5"})})]})})}),e.jsx(_e,{className:"bg-white border-slate-200 shadow-sm",children:e.jsx(Oe,{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(Hn,{className:"w-5 h-5"})})]})})})]}),e.jsxs(_e,{className:"shadow-sm border-slate-200 overflow-hidden",children:[e.jsxs(Xe,{className:"bg-white border-b border-slate-100 px-6 py-4 flex flex-row items-center justify-between",children:[e.jsxs(st,{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(ks,{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(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx("input",{type:"text",placeholder:"Search by ID or Name...",className:"pl-9 pr-4 py-2 bg-slate-50 border-slate-200 rounded-lg text-sm focus:ring-2 focus:ring-blue-500 transition-all outline-none",value:i,onChange:f=>o(f.target.value)})]}),e.jsx("button",{className:"p-2 border border-slate-200 rounded-lg hover:bg-slate-50 transition-colors",children:e.jsx(eb,{className:"w-4 h-4 text-slate-600"})})]})]}),e.jsx(Oe,{className:"p-0",children:r?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-6",children:[e.jsx(or,{className:"w-10 h-10 animate-spin text-blue-600 mb-4"}),e.jsx("p",{className:"text-slate-500 font-medium",children:"Synchronizing application data..."})]}):m.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-6 text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-slate-50 rounded-full flex items-center justify-center mb-6",children:e.jsx(sn,{className:"w-10 h-10 text-slate-200"})}),e.jsx("h3",{className:"text-xl font-bold text-slate-900 mb-2",children:"No Applications Found"}),e.jsx("p",{className:"text-slate-500 max-w-md mx-auto",children:"You don't have any applications assigned for Financial Due Diligence at this time."})]}):e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{className:"bg-slate-50 border-b border-slate-200",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider",children:"Application Details"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider",children:"Location"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider",children:"Current Stage"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider text-right",children:"Action"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:m.map(f=>e.jsxs("tr",{className:"hover:bg-slate-50 transition-colors cursor-pointer group",onClick:()=>t(`/fdd-details/${f.id}`),children:[e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 text-blue-600 rounded-lg flex items-center justify-center font-bold",children:f.applicantName.charAt(0)}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-slate-900 group-hover:text-blue-600 transition-colors",children:f.applicationId}),e.jsx("p",{className:"text-xs text-slate-500",children:f.applicantName})]})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-slate-700",children:[f.city,", ",f.state]}),e.jsx("p",{className:"text-xs text-slate-400 capitalize",children:f.locationType||"New Market"})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx(we,{className:`px-3 py-1 rounded-full text-[10px] uppercase font-bold tracking-wider ${f.overallStatus==="Completed"?"bg-green-100 text-green-700":"bg-red-50 text-re-red-hover"}`,children:f.overallStatus==="Active"?"FDD Pending":f.overallStatus})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("button",{className:"p-2 text-slate-400 hover:text-blue-600 hover:bg-blue-50 rounded-lg transition-all",children:e.jsx(Wo,{className:"w-5 h-5"})})})]},f.id))})]})})})]})]})}const q$="modulepreload",z$=function(t){return"/"+t},xS={},Yo=function(s,n,r){let a=Promise.resolve();if(n&&n.length>0){let o=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),m=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));a=o(n.map(f=>{if(f=z$(f),f in xS)return;xS[f]=!0;const p=f.endsWith(".css"),h=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${h}`))return;const x=document.createElement("link");if(x.rel=p?"stylesheet":q$,p||(x.as="script"),x.crossOrigin="",x.href=f,m&&x.setAttribute("nonce",m),document.head.appendChild(x),p)return new Promise((u,N)=>{x.addEventListener("load",u),x.addEventListener("error",()=>N(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(o){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=o,window.dispatchEvent(d),!d.defaultPrevented)throw o}return a.then(o=>{for(const d of o||[])d.status==="rejected"&&i(d.reason);return s().catch(i)})};function U$(t,s=[]){let n=[];function r(i,o){const d=g.createContext(o);d.displayName=i+"Context";const m=n.length;n=[...n,o];const f=h=>{var j;const{scope:x,children:u,...N}=h,v=((j=x==null?void 0:x[t])==null?void 0:j[m])||d,w=g.useMemo(()=>N,Object.values(N));return e.jsx(v.Provider,{value:w,children:u})};f.displayName=i+"Provider";function p(h,x){var v;const u=((v=x==null?void 0:x[t])==null?void 0:v[m])||d,N=g.useContext(u);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[f,p]}const a=()=>{const i=n.map(o=>g.createContext(o));return function(d){const m=(d==null?void 0:d[t])||i;return g.useMemo(()=>({[`__scope${t}`]:{...d,[t]:m}}),[d,m])}};return a.scopeName=t,[r,V$(a,...s)]}function V$(...t){const s=t[0];if(t.length===1)return s;const n=()=>{const r=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((d,{useScope:m,scopeName:f})=>{const h=m(i)[`__scope${f}`];return{...d,...h}},{});return g.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return n.scopeName=s.scopeName,n}var H$=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Hb=H$.reduce((t,s)=>{const n=Hu(`Primitive.${s}`),r=g.forwardRef((a,i)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),Lg={exports:{}},Ig={};/** * @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 gS;function W$(){if(gS)return Ig;gS=1;var t=fd();function s(h,x){return h===x&&(h!==0||1/h===1/x)||h!==h&&x!==x}var n=typeof Object.is=="function"?Object.is:s,r=t.useState,a=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function d(h,x){var u=x(),N=r({inst:{value:u,getSnapshot:x}}),v=N[0].inst,w=N[1];return i(function(){v.value=u,v.getSnapshot=x,m(v)&&w({inst:v})},[h,u,x]),a(function(){return m(v)&&w({inst:v}),h(function(){m(v)&&w({inst:v})})},[h]),o(u),u}function m(h){var x=h.getSnapshot;h=h.value;try{var u=x();return!n(h,u)}catch{return!0}}function f(h,x){return x()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:d;return Ig.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,Ig}var vS;function G$(){return vS||(vS=1,Lg.exports=W$()),Lg.exports}var K$=G$();function Y$(){return K$.useSyncExternalStore(Z$,()=>!0,()=>!1)}function Z$(){return()=>{}}var Wb="Avatar",[Q$]=U$(Wb),[X$,EE]=Q$(Wb),_E=g.forwardRef((t,s)=>{const{__scopeAvatar:n,...r}=t,[a,i]=g.useState("idle");return e.jsx(X$,{scope:n,imageLoadingStatus:a,onImageLoadingStatusChange:i,children:e.jsx(Hb.span,{...r,ref:s})})});_E.displayName=Wb;var TE="AvatarImage",J$=g.forwardRef((t,s)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:a=()=>{},...i}=t,o=EE(TE,n),d=eq(r,i),m=xr(f=>{a(f),o.onImageLoadingStatusChange(f)});return Jn(()=>{d!=="idle"&&m(d)},[d,m]),d==="loaded"?e.jsx(Hb.img,{...i,ref:s,src:r}):null});J$.displayName=TE;var PE="AvatarFallback",OE=g.forwardRef((t,s)=>{const{__scopeAvatar:n,delayMs:r,...a}=t,i=EE(PE,n),[o,d]=g.useState(r===void 0);return g.useEffect(()=>{if(r!==void 0){const m=window.setTimeout(()=>d(!0),r);return()=>window.clearTimeout(m)}},[r]),o&&i.imageLoadingStatus!=="loaded"?e.jsx(Hb.span,{...a,ref:s}):null});OE.displayName=PE;function yS(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function eq(t,{referrerPolicy:s,crossOrigin:n}){const r=Y$(),a=g.useRef(null),i=r?(a.current||(a.current=new window.Image),a.current):null,[o,d]=g.useState(()=>yS(i,t));return Jn(()=>{d(yS(i,t))},[i,t]),Jn(()=>{const m=h=>()=>{d(h)};if(!i)return;const f=m("loaded"),p=m("error");return i.addEventListener("load",f),i.addEventListener("error",p),s&&(i.referrerPolicy=s),typeof n=="string"&&(i.crossOrigin=n),()=>{i.removeEventListener("load",f),i.removeEventListener("error",p)}},[i,n,s]),o}var tq=_E,sq=OE;function Nm({className:t,...s}){return e.jsx(tq,{"data-slot":"avatar",className:Nt("relative flex size-10 shrink-0 overflow-hidden rounded-full",t),...s})}function wm({className:t,...s}){return e.jsx(sq,{"data-slot":"avatar-fallback",className:Nt("bg-muted flex size-full items-center justify-center rounded-full",t),...s})}const Sm="/collaboration",Cm={getWorknotes:async(t,s)=>(await Ie.get(`${Sm}/worknotes`,{requestId:t,requestType:s})).data,addWorknote:async t=>(await Ie.post(`${Sm}/worknotes`,t)).data,uploadAttachment:async(t,s,n)=>{const r=new FormData;return r.append("file",t),s&&r.append("requestId",s),n&&r.append("requestType",n),(await Ie.post(`${Sm}/upload`,r,{headers:{"Content-Type":"multipart/form-data"}})).data},revokeParticipant:async(t,s)=>(await Ie.delete(`${Sm}/participants/${t}`,{data:{reason:s}})).data},au=t=>[...t].sort((s,n)=>new Date(s.createdAt).getTime()-new Date(n.createdAt).getTime()),Mg=t=>{var s,n,r,a,i;return{name:((s=t==null?void 0:t.author)==null?void 0:s.name)||((n=t==null?void 0:t.author)==null?void 0:n.fullName)||"System",email:((r=t==null?void 0:t.author)==null?void 0:r.email)||"",role:String(((a=t==null?void 0:t.author)==null?void 0:a.role)||((i=t==null?void 0:t.author)==null?void 0:i.roleCode)||"")}},nq=new Set(["internal","workflow","system","audit","status"]),rq=t=>nq.has(String(t.noteType||"").toLowerCase()),aq=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"},iq=t=>{const s=String(t.noteType||"").toLowerCase();return s==="internal"?"APPROVAL":s==="workflow"?"WORKFLOW":s==="system"?"SYSTEM":s==="audit"?"AUDIT":s==="status"?"STATUS":"ACTIVITY"},bS=t=>t?new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}):"",Uc="https://dealeronboarding-uat.royalenfield.com/api".replace("/api","")||"http://localhost:5000";function LE(t){var Vs,Qs,Xs,ie,nt;const{user:s}=Pn(fe=>fe.auth),{id:n,type:r}=gd(),a=xl(),i=tr(),o=t.requestId||n||"",d=t.requestType||r||((Vs=a.state)==null?void 0:Vs.requestType)||"application",m=t.mode||((Qs=a.state)==null?void 0:Qs.mode)||"page",[f,p]=g.useState(t.applicationName||((Xs=a.state)==null?void 0:Xs.applicationName)||"Application"),[h,x]=g.useState(t.registrationNumber||((ie=a.state)==null?void 0:ie.registrationNumber)||""),u=t.onBack||(()=>i(-1)),N=t.participants||((nt=a.state)==null?void 0:nt.participants)||[],[v,w]=g.useState(N),[j,b]=g.useState([]),[C,S]=g.useState(""),[D,_]=g.useState(!1),[A,E]=g.useState(""),[q,O]=g.useState(0),[R,P]=g.useState(!0),[L,$]=g.useState(!1),[Z,Q]=g.useState([]),[W,U]=g.useState(!1),[M,z]=g.useState(!0),[T,F]=g.useState(""),[I,K]=g.useState(""),[G,V]=g.useState(null),[Y,re]=g.useState(""),[ae,ue]=g.useState(!1),{socket:ye}=ZD(),ce=g.useRef(null),je=g.useRef(null),[Me,ut]=g.useState(null),jt=(fe,Ae)=>fe.startsWith("image/")&&Ae?e.jsx("img",{src:`${Uc}/${Ae.replace(/\\/g,"/")}`,className:"w-full h-full object-cover rounded",alt:"Thumbnail"}):fe.startsWith("image/")?e.jsx(A1,{className:"w-5 h-5 text-blue-500"}):fe==="application/pdf"?e.jsx(ks,{className:"w-5 h-5 text-red-500"}):e.jsx(rf,{className:"w-5 h-5 text-slate-500"}),ft=["😊","😂","🤣","❤️","👍","🙏","🔥","✨","😍","🥰","😎","🤔","😅","🙌","👏","🎉","✅","❌","📌","📎","📍","💡","🔔","📢","⭐","🌟","💪","🚀","👀","💯","🌈","☀️","😢","😭","😞","😔","😟","😕","😠","😡","🤬","😤","😲","🙄","🤨","😓","😩","😫","🤐","😴","🤢","🤮","😱","🤡","💀","👻","🤝","👋","✌️","👌","✋","🍎","🍕","☕","💻","📱","⌚","📁","📄","📅","🔒","🔑","🛠️","⚙️","💬","💭","🌊","🍀","✈️","🏠"],X=fe=>fe.split(" ").map(Ae=>Ae[0]).join("").toUpperCase().substring(0,2),Ce=fe=>{const Ae=["bg-green-600","bg-blue-600","bg-purple-600","bg-re-red","bg-pink-600","bg-indigo-600","bg-teal-600"],Fe=fe.length%Ae.length;return Ae[Fe]},xe=[],We=new Set;v.forEach(fe=>{var Ke,Le,Ue,et,dt,ss,Wt;const Ae=((Ke=fe.user)==null?void 0:Ke.id)||fe.userId||"",Fe=fe.id;if(Ae&&!We.has(Ae)){We.add(Ae);const kt=((Le=fe.user)==null?void 0:Le.fullName)||((Ue=fe.user)==null?void 0:Ue.name)||fe.fullName||fe.name||"Unknown User",wt=((et=fe.user)==null?void 0:et.email)||fe.email||"",Os=((dt=fe.user)==null?void 0:dt.roleCode)||fe.roleCode||((ss=fe.user)==null?void 0:ss.role)||fe.role||"Participant";xe.push({id:Ae,recordId:Fe,name:kt,email:wt,initials:X(kt),color:Ce(kt),role:Os,isOnline:!1,revokedAt:(Wt=fe.metadata)==null?void 0:Wt.revokedAt})}});const Be=async()=>{try{P(!0);const fe=await Cm.getWorknotes(o,d);if(fe.success){const Ae=fe.data.map(Fe=>({id:Fe.id,noteText:Fe.noteText,noteType:Fe.noteType,createdAt:Fe.createdAt,userId:Fe.userId,author:Fe.author?Mg(Fe):{name:"System",email:"",role:"system"},attachments:Fe.attachments||[]}));b(au(Ae))}}catch(fe){console.error("Fetch notes error:",fe),J.error("Failed to load work notes")}finally{P(!1)}};g.useEffect(()=>{if(Be(),ye)return ye.emit("join_room",o),ye.on("new_worknote",fe=>{const Ae={id:fe.id,noteText:fe.noteText,noteType:fe.noteType,createdAt:fe.createdAt,userId:fe.userId,author:fe.author?Mg(fe):{name:"System",email:"",role:"system"},attachments:fe.attachments||[]};b(Fe=>{if(Fe.some(Ue=>Ue.id===Ae.id))return Fe;const Le=Fe.findIndex(Ue=>{var et,dt;return Ue.id.startsWith("temp-")&&Ue.noteText===Ae.noteText&&((et=Ue.author.email)==null?void 0:et.toLowerCase())===((dt=Ae.author.email)==null?void 0:dt.toLowerCase())});if(Le!==-1){const Ue=[...Fe];return Ue[Le]=Ae,au(Ue)}return au([...Fe,Ae])})}),()=>{ye.emit("leave_room",o),ye.off("new_worknote")}},[o,d,ye]),g.useEffect(()=>{if(!o||!d)return;(async()=>{var Ae,Fe,Ke,Le,Ue,et,dt,ss,Wt,kt;try{let wt=null;if(d==="application")wt=await ps.getApplicationById(o),wt&&(v.length===0&&wt.participants&&w(wt.participants),(!f||f==="Application")&&p(wt.companyName||"Application"),h||x(wt.registrationNumber||""));else if(d==="termination"){const{API:Os}=await Yo(async()=>{const{API:Se}=await Promise.resolve().then(()=>cm);return{API:Se}},void 0),as=await Os.getTerminationById(o);(Ae=as.data)!=null&&Ae.success&&(wt=as.data.termination,v.length===0&&wt.participants&&w(wt.participants),(!f||f==="Application"||f==="Termination")&&p(((Fe=wt.dealer)==null?void 0:Fe.businessName)||"Termination"),h||x(wt.requestId||""))}else if(d==="constitutional"||d==="constitutional-change"){const{API:Os}=await Yo(async()=>{const{API:Se}=await Promise.resolve().then(()=>cm);return{API:Se}},void 0),as=await Os.getConstitutionalChangeById(o);(Ke=as.data)!=null&&Ke.success&&(wt=as.data.request,v.length===0&&wt.participants&&w(wt.participants),(!f||f==="Application"||f==="Constitutional Change")&&p(((Le=wt.outlet)==null?void 0:Le.name)||"Constitutional Change"),h||x(wt.requestId||""))}else if(d==="resignation"){const{API:Os}=await Yo(async()=>{const{API:Se}=await Promise.resolve().then(()=>cm);return{API:Se}},void 0),as=await Os.getResignationById(o);(Ue=as.data)!=null&&Ue.success&&(wt=as.data.resignation,v.length===0&&wt.participants&&w(wt.participants),(!f||f==="Application"||f==="Resignation")&&p(((et=wt.dealer)==null?void 0:et.businessName)||"Resignation"),h||x(wt.resignationId||""))}else if(d==="fnf"){const{API:Os}=await Yo(async()=>{const{API:Se}=await Promise.resolve().then(()=>cm);return{API:Se}},void 0),as=await Os.getFnFSettlementById(o);if((dt=as.data)!=null&&dt.success){wt=as.data.fnf,v.length===0&&wt.participants&&w(wt.participants||[]);const Se=((Wt=(ss=wt.outlet)==null?void 0:ss.dealer)==null?void 0:Wt.fullName)||((kt=wt.dealer)==null?void 0:kt.fullName)||"F&F Settlement";(!f||f==="Application"||f==="F&F Settlement")&&p(Se),h||x(wt.settlementId||"")}}}catch(wt){console.error(`Failed to fetch ${d} details:`,wt)}})()},[o,d,v.length,f,h]);const rt=g.useRef(null);g.useEffect(()=>{rt.current&&rt.current.scrollIntoView({behavior:"smooth"})},[j]);const ht=fe=>{const Ae=fe.target.value,Fe=fe.target.selectionStart||0;S(Ae),O(Fe);const Ke=Ae.substring(0,Fe),Le=Ke.lastIndexOf("@");if(Le!==-1&&Le===Ke.length-1)_(!0),E("");else if(Le!==-1){const Ue=Ke.substring(Le+1);Ue.includes(" ")?_(!1):(_(!0),E(Ue))}else _(!1)},ge=fe=>{var et;const Fe=C.substring(0,q).lastIndexOf("@"),Ke=C.substring(q),Le=`@${fe.name}`,Ue=C.substring(0,Fe)+Le+" "+Ke;S(Ue),_(!1),(et=ce.current)==null||et.focus()},Je=fe=>{var Ke,Le;const Ae=((Ke=ce.current)==null?void 0:Ke.selectionStart)||C.length,Fe=C.substring(0,Ae)+fe+C.substring(Ae);S(Fe),$(!1),(Le=ce.current)==null||Le.focus()},mt=async fe=>{const Ae=fe.target.files;if(!(!Ae||Ae.length===0)){U(!0);try{for(const Fe of Array.from(Ae)){const Ke=await Cm.uploadAttachment(Fe,o,d);Ke.success&&Q(Le=>[...Le,Ke.data])}}catch(Fe){console.error("File upload error:",Fe),J.error("Failed to upload attachment")}finally{U(!1),je.current&&(je.current.value="")}}},de=fe=>{Q(Ae=>Ae.filter(Fe=>Fe.id!==fe))},at=async()=>{if(!C.trim()&&Z.length===0)return;const fe=C,Ae=Z;S(""),Q([]);let Fe=fe;const Ke=[];xe.forEach(Le=>{if(Le.id&&Le.name){const Ue=Le.name.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),et=new RegExp(`@${Ue}\\b`,"gi");Fe.match(et)&&(Ke.push(Le.id),Fe=Fe.replace(et,`@[${Le.name}](user:${Le.id})`))}});try{const Le=`temp-${Date.now()}`,Ue={id:Le,noteText:Fe,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:Ae};b(dt=>au([...dt,Ue]));const et=await Cm.addWorknote({requestId:o,requestType:d,noteText:Fe,noteType:"General",tags:Ke,attachmentDocIds:Ae.map(dt=>dt.id)});if(et.success&&et.data){const dt=et.data,ss={id:dt.id,noteText:dt.noteText,noteType:dt.noteType,createdAt:dt.createdAt,userId:dt.userId,author:dt.author?Mg(dt):{name:"System",email:"",role:"system"},attachments:dt.attachments||[]};b(Wt=>au(Wt.map(kt=>kt.id===Le?ss:kt)))}}catch(Le){console.error("Send message error:",Le),J.error("Failed to send message")}},ot=fe=>{if(!["DD Lead","DD Head","NBH","DD Admin","Super Admin"].includes((s==null?void 0:s.roleCode)||"")){J.error("Only authorized roles can revoke participants");return}V(fe),re("")},ke=async()=>{if(G){ue(!0);try{const fe=await Cm.revokeParticipant(G.recordId,Y);fe.success&&(J.success(fe.message),V(null),w([]))}catch{J.error("Error revoking participant")}finally{ue(!1)}}},Zt=fe=>{fe.key==="Enter"&&!fe.shiftKey&&(fe.preventDefault(),at())},Bt=fe=>{if(!fe)return"";const Ae=/(@\[[^\]]+\]\([^\)]+\))/g;return fe.split(Ae).map((Ke,Le)=>{const Ue=Ke.match(/@\[([^\]]+)\]\(([^\)]+)\)/);if(Ue){const et=Ue[1];return e.jsxs("span",{className:"text-blue-600 font-medium hover:underline cursor-pointer",children:["@",et]},Le)}return Ke})},_s=I.trim().toLowerCase(),Us=_s?j.filter(fe=>{var Ae;return(fe.noteText||"").toLowerCase().includes(_s)||(((Ae=fe.author)==null?void 0:Ae.name)||"").toLowerCase().includes(_s)||(fe.noteType||"").toLowerCase().includes(_s)}):j,fs=xe.filter(fe=>{const Ae=fe.name.toLowerCase().includes(A.toLowerCase()),Fe=fe.id&&(s==null?void 0:s.id)&&String(fe.id)===String(s.id)||fe.email&&(s==null?void 0:s.email)&&fe.email.toLowerCase()===s.email.toLowerCase();return Ae&&!Fe});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(te,{variant:"ghost",size:"icon",onClick:u,className:"hover:bg-slate-100","data-testid":"onboarding-worknotes-back-btn",children:e.jsx(Wr,{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(li,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900","data-testid":"onboarding-worknotes-title",children:"Work Notes"}),e.jsxs("div",{className:"flex items-center gap-2 text-slate-600","data-testid":"onboarding-worknotes-meta",children:[e.jsx("span",{"data-testid":"onboarding-worknotes-app-name",children:f}),e.jsx("span",{className:"text-slate-400",children:"|"}),e.jsx("span",{className:"text-slate-500","data-testid":"onboarding-worknotes-reg-num",children:h})]})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"hidden sm:flex items-center -space-x-2 mr-2","data-testid":"onboarding-worknotes-participant-avatars",children:[xe.slice(0,3).map((fe,Ae)=>e.jsx(Nm,{className:"w-8 h-8 border-2 border-white ring-1 ring-slate-100","data-testid":`onboarding-worknotes-avatar-${Ae}`,children:e.jsx(wm,{className:`${fe.color} text-white text-[10px]`,children:fe.initials})},Ae)),xe.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:["+",xe.length-3]})})]}),e.jsxs(te,{variant:"ghost",size:"sm",onClick:Be,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:R,"data-testid":"onboarding-worknotes-sync-btn",children:[e.jsx(cl,{className:`w-4 h-4 ${R?"animate-spin":""}`}),e.jsx("span",{className:"text-xs font-medium hidden md:inline",children:"Sync"})]}),e.jsxs(te,{variant:M?"secondary":"ghost",size:"sm",onClick:()=>z(!M),className:`flex items-center gap-1.5 px-2 h-9 rounded-lg transition-all ${M?"bg-blue-50 text-blue-600 hover:bg-blue-100":"text-slate-500 hover:bg-slate-50"}`,"data-testid":"onboarding-worknotes-toggle-sidebar-btn",children:[e.jsx(ja,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs font-medium hidden md:inline",children:"Participants"})]})]})]})}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-white min-h-0 relative",children:[e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4 custom-scrollbar bg-slate-50 relative z-0","data-testid":"onboarding-worknotes-chat-area",children:e.jsxs("div",{className:`max-w-4xl mx-auto flex flex-col py-4 gap-4 ${m==="modal"?"":"px-4"}`,children:[e.jsx("div",{className:"sticky top-0 z-[1] -mx-1 px-1 pb-1 bg-slate-50/95 backdrop-blur-sm",children:e.jsxs("div",{className:"relative",children:[e.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400 pointer-events-none"}),e.jsx(it,{type:"search",value:I,onChange:fe=>K(fe.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"})]})}),Us.map((fe,Ae)=>{var Ke,Le,Ue,et,dt,ss,Wt;if(rq(fe)){const kt=((Ke=fe.author)==null?void 0:Ke.name)||"System",wt=(Le=fe.author)!=null&&Le.role&&fe.author.role!=="0"&&fe.author.role!==""?fe.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-${Ae}`,children:e.jsxs("div",{role:"status",title:aq(fe),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(rd,{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-${Ae}`,children:iq(fe)}),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-${Ae}`,children:kt}),wt?e.jsxs("span",{className:"text-xs font-normal text-slate-500",children:[" · ",wt]}):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-${Ae}`,children:Bt(fe.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:fe.createdAt,"data-testid":`onboarding-worknotes-activity-time-${Ae}`,children:bS(fe.createdAt)})]})},fe.id)}const Fe=((Ue=fe==null?void 0:fe.author)==null?void 0:Ue.email)&&(s==null?void 0:s.email)&&fe.author.email.toLowerCase()===s.email.toLowerCase()||(fe==null?void 0:fe.userId)&&(s==null?void 0:s.id)&&String(fe.userId)===String(s.id)||fe.id.startsWith("temp-");return e.jsx("div",{className:`flex w-full ${Fe?"justify-end":"justify-start"}`,"data-testid":`onboarding-worknotes-message-row-${Ae}`,children:e.jsxs("div",{className:`flex gap-3 max-w-[min(85%,36rem)] ${Fe?"flex-row-reverse":""}`,children:[e.jsx(Nm,{className:"w-10 h-10 flex-shrink-0 mt-1","data-testid":`onboarding-worknotes-message-avatar-${Ae}`,children:e.jsx(wm,{className:`${Ce(((et=fe==null?void 0:fe.author)==null?void 0:et.name)||"System")} text-white`,children:X(((dt=fe==null?void 0:fe.author)==null?void 0:dt.name)||"S")})}),e.jsxs("div",{className:`flex flex-col min-w-0 ${Fe?"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 ${Fe?"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-${Ae}`,children:Fe?"You":((ss=fe==null?void 0:fe.author)==null?void 0:ss.name)||"Unknown"}),e.jsx("span",{className:"text-slate-400 text-[10px] uppercase tracking-wide",children:(Wt=fe==null?void 0:fe.author)!=null&&Wt.role&&fe.author.role!=="0"&&fe.author.role!==""?`(${fe.author.role})`:""}),e.jsx("span",{className:"text-slate-400 text-[10px] tabular-nums","data-testid":`onboarding-worknotes-message-time-${Ae}`,children:bS(fe.createdAt)})]}),e.jsxs("div",{className:`rounded-2xl border px-4 py-2.5 shadow-sm relative text-left ${Fe?"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-${Ae}`,children:[e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap break-words","data-testid":`onboarding-worknotes-message-text-${Ae}`,children:Bt(fe.noteText)}),fe.attachments&&fe.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-${Ae}`,children:fe.attachments.map((kt,wt)=>{const Os=kt.mimeType.startsWith("image/");return e.jsx("div",{className:"flex items-center gap-2","data-testid":`onboarding-worknotes-message-attachment-${Ae}-${wt}`,children:Os?e.jsx("div",{className:"rounded-lg overflow-hidden border border-slate-100 max-w-[200px]",children:e.jsx("img",{src:`${Uc}/${kt.filePath.replace(/\\/g,"/")}`,alt:kt.fileName,className:"w-full h-auto cursor-pointer",onClick:()=>ut(kt),"data-testid":`onboarding-worknotes-message-attachment-img-${Ae}-${wt}`})}):kt.mimeType==="application/pdf"?e.jsxs("button",{type:"button",onClick:()=>ut(kt),className:"flex items-center gap-2 text-xs text-blue-600 hover:underline","data-testid":`onboarding-worknotes-message-attachment-preview-${Ae}-${wt}`,children:[e.jsx(bu,{className:"w-3 h-3"}),kt.fileName," (Preview)"]}):e.jsxs("a",{href:`${Uc}/${kt.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-${Ae}-${wt}`,children:[e.jsx(bu,{className:"w-3 h-3"}),kt.fileName]})},kt.id)})})]})]})]})},fe.id)}),j.length===0&&!R&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center","data-testid":"onboarding-worknotes-empty-state",children:[e.jsx(li,{className:"w-16 h-16 text-slate-300 mb-4"}),e.jsx("h3",{className:"text-slate-900 mb-2",children:"No messages yet"}),e.jsx("p",{className:"text-slate-600",children:"Start the conversation by sending a message below"})]}),j.length>0&&Us.length===0&&!R&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center text-slate-500 text-sm",children:['No messages match "',I.trim(),'". Clear the search box to see the full thread.']}),R&&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:rt})]})}),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:[Z.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3 mb-3","data-testid":"onboarding-worknotes-attached-files",children:Z.map((fe,Ae)=>{const Fe=fe.mimeType.startsWith("image/")||fe.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-${Ae}`,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:jt(fe.mimeType,fe.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 ${Fe?"hover:text-blue-600 cursor-pointer hover:underline":""}`,onClick:()=>Fe&&ut(fe),children:fe.fileName}),e.jsx("button",{onClick:()=>de(fe.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-${Ae}`,children:e.jsx(id,{className:"w-3 h-3"})})]})]},fe.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:[D&&fs.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:fs.map((fe,Ae)=>e.jsxs("button",{onClick:()=>ge(fe),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-${Ae}`,children:[e.jsx(Nm,{className:"w-8 h-8",children:e.jsx(wm,{className:`${fe.color} text-white text-xs`,children:fe.initials})}),e.jsx("div",{className:"flex flex-col",children:e.jsx("span",{className:"text-slate-900 text-sm font-medium",children:fe.name})})]},fe.id))}),e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx("input",{type:"file",ref:je,className:"hidden",multiple:!0,onChange:mt}),e.jsx(te,{variant:"ghost",size:"icon",className:"w-9 h-9 text-slate-400 hover:text-blue-600 hover:bg-blue-50 rounded-xl",onClick:()=>{var fe;return(fe=je.current)==null?void 0:fe.click()},"data-testid":"onboarding-worknotes-attachment-btn",children:e.jsx(bu,{className:"w-5 h-5"})}),e.jsxs(te,{variant:"ghost",size:"icon",className:`w-9 h-9 text-slate-400 hover:text-blue-600 hover:bg-blue-50 rounded-xl relative ${L?"bg-blue-50 text-blue-600":""}`,onClick:()=>$(!L),"data-testid":"onboarding-worknotes-emoji-btn",children:[e.jsx(JI,{className:"w-5 h-5"}),L&&e.jsxs("div",{className:"absolute bottom-12 left-0 z-50 bg-white border border-slate-200 rounded-xl shadow-2xl w-72 animate-in fade-in slide-in-from-bottom-2 overflow-hidden","data-testid":"onboarding-worknotes-emoji-picker",children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-100 bg-slate-50 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"Emojis"}),e.jsx("button",{onClick:()=>$(!1),className:"text-slate-400 hover:text-slate-600 text-lg leading-none",children:"×"})]}),e.jsx("div",{className:"p-2 grid grid-cols-8 gap-1 max-h-60 overflow-y-auto custom-scrollbar",children:ft.map((fe,Ae)=>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:Fe=>{Fe.stopPropagation(),Je(fe)},"data-testid":`onboarding-worknotes-emoji-item-${Ae}`,children:fe},fe))})]})]}),e.jsx(te,{variant:"ghost",size:"icon",className:"w-9 h-9 text-slate-400 hover:text-blue-600 hover:bg-blue-50 rounded-xl",onClick:()=>{var fe;return(fe=je.current)==null?void 0:fe.click()},children:e.jsx(A1,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 relative",children:e.jsx(it,{ref:ce,type:"text",placeholder:"Type your message... Use @username to mention someone",value:C,onChange:ht,onKeyPress:Zt,className:"w-full pr-4 border-none focus-visible:ring-0 px-0"})}),e.jsx(te,{onClick:at,disabled:!C.trim()&&Z.length===0||W,className:"bg-blue-600 hover:bg-blue-700 text-white rounded-xl h-10 w-10 p-0",children:W?e.jsx("div",{className:"h-4 w-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):e.jsx(Gu,{className:"w-5 h-5"})})]}),e.jsxs("p",{className:"text-slate-400 text-[10px] px-1 flex items-center gap-1",children:[e.jsx(qa,{className:"w-3 h-3"}),e.jsxs("span",{children:["Press Enter to send • Use @ to mention • ",W?"Uploading files...":"Files attached appear above"]})]})]})})]}),M&&e.jsxs("div",{className:`w-[280px] lg:w-[320px] bg-slate-50 border-l border-slate-200 flex flex-col transition-all animate-in slide-in-from-right-full ${m==="modal"?"hidden lg:flex":"flex"}`,children:[e.jsxs("div",{className:"p-4 border-b border-slate-200 bg-white",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(ja,{className:"w-4 h-4 text-blue-600"}),"Participants",e.jsx(we,{variant:"secondary",className:"bg-slate-100 text-slate-600 ml-1",children:xe.length})]}),e.jsx(te,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-slate-600",onClick:()=>z(!1),children:e.jsx(id,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(it,{type:"text",placeholder:"Search people...",value:T,onChange:fe=>F(fe.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:[xe.filter(fe=>{var Ae;return fe.name.toLowerCase().includes(T.toLowerCase())||((Ae=fe.role)==null?void 0:Ae.toLowerCase().includes(T.toLowerCase()))}).map(fe=>{const Ae=!!fe.revokedAt,Fe=["DD Lead","DD Head","NBH","DD Admin","Super Admin"].includes((s==null?void 0:s.roleCode)||"")&&!Ae&&fe.id!==(s==null?void 0:s.id);return e.jsxs("div",{className:Nt("group flex items-start gap-3 p-3 rounded-xl transition-all cursor-default border border-transparent",Ae?"opacity-50 bg-slate-100 grayscale-[0.5]":"hover:bg-white hover:shadow-sm hover:border-slate-100"),children:[e.jsxs("div",{className:"relative",children:[e.jsx(Nm,{className:Nt("w-10 h-10 ring-2 ring-transparent transition-all",!Ae&&"group-hover:ring-blue-100"),children:e.jsx(wm,{className:`${fe.color} text-white text-xs font-bold`,children:fe.initials})}),fe.isOnline&&!Ae&&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"}),Ae&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-red-100 rounded-full p-0.5 border border-white",children:e.jsx(gg,{className:"w-2.5 h-2.5 text-red-600"})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("p",{className:Nt("text-sm font-semibold truncate",Ae?"text-slate-500 line-through":"text-slate-900"),children:fe.name}),Ae&&e.jsx(we,{variant:"outline",className:"text-[8px] h-3.5 px-1 bg-red-50 text-red-600 border-red-100",children:"Revoked"})]}),fe.id===(s==null?void 0:s.id)&&e.jsx(we,{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:fe.role}),e.jsx("p",{className:"text-[11px] text-slate-400 truncate italic",children:fe.email})]}),Fe&&e.jsx(te,{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:()=>ot(fe),children:e.jsx(gg,{className:"w-3.5 h-3.5"})}),!Fe&&!Ae&&e.jsx(mi,{className:"w-4 h-4 text-slate-300 group-hover:text-slate-400 opacity-0 group-hover:opacity-100 transition-all self-center"})]},fe.id)}),xe.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center opacity-50",children:[e.jsx(ja,{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(dn,{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(ms,{open:!!Me,onOpenChange:fe=>!fe&&ut(null),children:e.jsxs(us,{className:"max-w-6xl h-[90vh] flex flex-col p-4",children:[e.jsx(ys,{children:e.jsxs(gs,{className:"flex items-center gap-2",children:[Me&&jt(Me.mimeType),e.jsx("span",{className:"truncate",children:Me==null?void 0:Me.fileName})]})}),e.jsx("div",{className:"flex-1 overflow-hidden rounded-lg bg-slate-100 flex items-center justify-center p-4",children:Me!=null&&Me.mimeType.startsWith("image/")?e.jsx("img",{src:`${Uc}/${Me.filePath.replace(/\\/g,"/")}`,className:"max-w-full max-h-full object-contain",alt:"Preview"}):(Me==null?void 0:Me.mimeType)==="application/pdf"?e.jsx("iframe",{src:`${Uc}/${Me.filePath.replace(/\\/g,"/")}`,className:"w-full h-full border-none",title:"PDF Preview"}):e.jsxs("div",{className:"text-center",children:[e.jsx(rf,{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:`${Uc}/${Me==null?void 0:Me.filePath.replace(/\\/g,"/")}`,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline text-sm",children:"Open in new tab"})]})})]})}),e.jsx(ms,{open:!!G,onOpenChange:fe=>!fe&&V(null),children:e.jsxs(us,{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(gg,{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:G==null?void 0:G.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(it,{value:Y,onChange:fe=>re(fe.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(te,{variant:"outline",className:"flex-1 h-11 border-slate-200 text-slate-600 hover:bg-slate-50",onClick:()=>V(null),children:"Cancel"}),e.jsxs(te,{className:"flex-1 h-11 bg-red-600 hover:bg-red-700 text-white font-bold shadow-lg shadow-red-200",onClick:ke,disabled:ae,children:[ae?e.jsx(cl,{className:"w-4 h-4 animate-spin mr-2"}):null,"Revoke Access"]})]})]})]})})]})}const Gb="!w-[80vw] !max-w-[80vw] sm:!max-w-[80vw]",ho=({isOpen:t,onClose:s,document:n})=>{var i;const a=n?`http://localhost:5000${n.filePath.startsWith("/")?"":"/"}${n.filePath}`:"";return e.jsx(ms,{open:t,onOpenChange:s,children:e.jsx(us,{className:`${Gb} h-[85vh] flex flex-col p-0 overflow-hidden bg-white shadow-2xl border-none`,children:n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b bg-slate-50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-red-50 flex items-center justify-center border border-red-200",children:e.jsx(un,{className:"w-5 h-5 text-re-red"})}),e.jsxs("div",{children:[e.jsx(gs,{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(te,{variant:"outline",size:"sm",className:"h-8 gap-2",onClick:()=>window.open(a,"_blank"),children:[e.jsx(fi,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Download"})]})})]}),e.jsx("div",{className:"flex-1 bg-slate-100 relative overflow-hidden flex items-center justify-center p-4",children:(i=n.fileName)!=null&&i.toLowerCase().endsWith(".pdf")?e.jsx("iframe",{src:`${a}#toolbar=0`,className:"w-full h-full bg-white shadow-inner rounded-sm",title:"Preview"}):e.jsx("img",{src:a,className:"max-h-full max-w-full object-contain shadow-lg rounded-sm",alt:"Preview"})})]}):e.jsx("div",{className:"flex items-center justify-center h-full text-slate-400",children:"Loading document..."})})})};function lq(){var W,U,M,z;const{id:t}=gd(),s=tr(),[n,r]=g.useState(null),[a,i]=g.useState(null),[o,d]=g.useState(!0),[m,f]=g.useState(!1),[p,h]=g.useState(""),[x,u]=g.useState("details"),[N,v]=g.useState(!1),[w,j]=g.useState(null),[b,C]=g.useState(!1),[S,D]=g.useState(!1),[_,A]=g.useState(""),E=Pn(T=>T.auth.user),q=(E==null?void 0:E.role)==="FDD";g.useEffect(()=>{t&&O()},[t]);const O=async()=>{var T,F,I,K;d(!0);try{const[G,V]=await Promise.all([Re.getApplicationById(t),Re.getFddAssignment(t)]);(T=G.data)!=null&&T.success&&r(G.data.data),(F=V.data)!=null&&F.success&&i(V.data.data)}catch(G){console.error("Error fetching application:",G);const V=((K=(I=G.response)==null?void 0:I.data)==null?void 0:K.message)||"Access Denied: Not authorized for FDD access";J.error(V),s("/fdd-dashboard")}finally{d(!1)}},R=async T=>{var K,G,V;const F=(K=T.target.files)==null?void 0:K[0];if(!F||!p){p||J.error("Please select a document type first");return}f(!0);const I=new FormData;I.append("file",F),I.append("documentType",p),I.append("stage","FDD"),I.append("applicationId",t),I.append("requestType","application");try{const Y=await Re.uploadDocument(t,I);if((G=Y.data)!=null&&G.success){if(p==="FDD Final Audit Report"){const re=((V=Y.data.data)==null?void 0:V.id)||Y.data.id;await Re.submitFddReport({assignmentId:a==null?void 0:a.id,applicationId:t,reportDocumentId:re,findings:"Final Audit Report submitted.",recommendation:"REVIEW_PENDING"})}J.success(`${p} uploaded successfully`),O(),h("")}}catch{J.error("Failed to upload document")}finally{f(!1)}},P=T=>{if(!T||!T.filePath){J.error("Document source file not found");return}j({fileName:T.originalName||T.fileName||"Document",filePath:T.filePath,documentType:T.documentType,createdAt:T.createdAt,mimeType:T.mimeType}),v(!0)};if(o)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-[70vh] bg-slate-50/50 rounded-2xl border border-slate-200 border-dashed",children:[e.jsx(cs,{className:"w-12 h-12 animate-spin text-blue-600 mb-4"}),e.jsx("p",{className:"text-slate-500 font-medium",children:"Authenticating and loading secure data..."})]});if(!n)return null;const L=n.currentStage==="FDD_VERIFICATION"||n.currentStage==="FDD",$=(a==null?void 0:a.status)==="Report Submitted",Z=!L&&(n.overallStatus!=="Active"||n.currentProgress>=75)||$,Q=!L&&n.currentProgress<70&&!$;return e.jsxs("div",{className:"flex flex-col gap-6 max-w-7xl mx-auto mb-10",children:[(n==null?void 0:n.statutoryStatus)==="Flagged"&&e.jsxs("div",{className:"bg-red-50 border border-red-200 p-4 rounded-xl flex items-center gap-4 animate-in fade-in slide-in-from-top-4 duration-500","data-testid":"onboarding-fdd-details-flag-banner",children:[e.jsx("div",{className:"bg-red-100 p-2 rounded-lg",children:e.jsx(Ba,{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(Wr,{className:"w-5 h-5"})}),"Back to Dashboard"]}),e.jsx("div",{className:"flex items-center gap-3",children:Q?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(dn,{className:"w-4 h-4"}),"Awaiting Previous Stages"]}):Z?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(Hn,{className:"w-4 h-4"}),"Final Audit Report Submitted"]}):e.jsx(e.Fragment,{children:q&&e.jsxs("button",{disabled:m,onClick:()=>D(!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(Ba,{className:"w-4 h-4"}),"Flag Non-Responsive"]})})})]}),e.jsx(_e,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-header",children:e.jsx(Oe,{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(we,{variant:"outline",className:"text-slate-500 font-medium px-2 py-0","data-testid":"onboarding-fdd-details-id-badge",children:n.applicationId})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-slate-500","data-testid":"onboarding-fdd-details-meta",children:[e.jsxs("span",{children:[n.city,", ",n.state]}),e.jsx("span",{className:"text-slate-300",children:"•"}),e.jsx("span",{children:n.businessType||"Dealership"})]})]})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"text-right hidden md:block",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Status"}),e.jsx("p",{className:"text-sm font-bold text-slate-700",children:"Financial Due Diligence"})]})})]})})}),e.jsxs("div",{className:"flex items-center gap-8 border-b border-slate-200","data-testid":"onboarding-fdd-details-tabs",children:[e.jsxs("button",{onClick:()=>u("details"),className:`pb-3 text-sm font-semibold transition-all relative ${x==="details"?"text-blue-600":"text-slate-500 hover:text-slate-700"}`,"data-testid":"onboarding-fdd-details-tab-workspace",children:["Workspace",x==="details"&&e.jsx("div",{className:"absolute bottom-[-1px] left-0 right-0 h-0.5 bg-blue-600"})]}),e.jsxs("button",{onClick:()=>u("worknotes"),className:`pb-3 text-sm font-semibold transition-all relative ${x==="worknotes"?"text-blue-600":"text-slate-500 hover:text-slate-700"}`,"data-testid":"onboarding-fdd-details-tab-worknotes",children:[e.jsx("div",{className:"flex items-center gap-2",children:"Work Notes"}),x==="worknotes"&&e.jsx("div",{className:"absolute bottom-[-1px] left-0 right-0 h-0.5 bg-blue-600"})]})]}),x==="details"?e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx("div",{className:"lg:col-span-2 space-y-6",children:e.jsxs(_e,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-workspace-card",children:[e.jsx(Xe,{className:"border-b border-slate-100 px-6 py-4",children:e.jsxs(st,{className:"text-base font-bold flex items-center gap-2 text-slate-800",children:[e.jsx(vr,{className:"w-4 h-4 text-slate-500"}),Z?"Finalized Financial Reports":Q?"Audit Workspace":"Financial Report Submission"]})}),e.jsxs(Oe,{className:"p-6",children:[Q&&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(dn,{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"]})]}),Z&&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(Hn,{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."})]})]}),!Z&&!Q&&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(ks,{className:"w-6 h-6"})}),e.jsx("p",{className:"text-slate-600 font-medium mb-1","data-testid":"onboarding-fdd-details-upload-title",children:q?"Select and upload the due diligence report":"View Authorized Documents"}),e.jsx("p",{className:"text-slate-400 text-xs mb-6","data-testid":"onboarding-fdd-details-upload-hint",children:q?"PDF or JPG formats accepted (Max 10MB)":"You are in View-Only mode for this Audit"}),q&&e.jsxs("div",{className:"w-full max-w-sm space-y-4",children:[e.jsxs("select",{value:p,onChange:T=>h(T.target.value),className:"w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded text-sm font-medium text-slate-700 outline-none focus:ring-1 focus:ring-blue-500 transition-all","data-testid":"onboarding-fdd-details-doc-type-select",children:[e.jsx("option",{value:"",children:"Select Document Category..."}),e.jsx("option",{value:"FDD Final Audit Report",children:"FDD Final Audit Report"}),e.jsx("option",{value:"Bank Statement",children:"Bank Statement"}),e.jsx("option",{value:"Income Tax Returns (ITR)",children:"Income Tax Returns (ITR)"}),e.jsx("option",{value:"CIBIL Report",children:"CIBIL Report"}),e.jsx("option",{value:"Business Valuation Report",children:"Business Valuation Report"}),e.jsx("option",{value:"Property Documents",children:"Property Documents"})]}),e.jsx("div",{className:"relative",children:m?e.jsxs("div",{className:"w-full py-2.5 bg-slate-100 rounded flex items-center justify-center gap-2","data-testid":"onboarding-fdd-details-uploading-state",children:[e.jsx(cs,{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:R,disabled:!p,"data-testid":"onboarding-fdd-details-file-input"}),e.jsx("div",{className:`w-full py-2.5 text-center font-bold uppercase tracking-wider text-xs rounded transition-all ${p?"bg-slate-900 text-white hover:bg-slate-800":"bg-slate-100 text-slate-300"}`,"data-testid":"onboarding-fdd-details-browse-btn",children:"Browse & Upload"})]})})]})]}),e.jsxs("div",{className:"mt-8 border-t border-slate-100 pt-8","data-testid":"onboarding-fdd-details-documents-section",children:[e.jsx("h3",{className:"text-sm font-bold text-slate-800 mb-4 px-1",children:"Submitted Documentation"}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{"data-testid":"onboarding-fdd-details-applicant-docs",children:[e.jsxs("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider mb-2 flex items-center gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-blue-500"}),"Applicant's KYC & Financials"]}),e.jsxs("div",{className:"space-y-2",children:[(W=n.uploadedDocuments)==null?void 0:W.filter(T=>!T.uploader||T.uploader.roleCode!=="FDD").map((T,F)=>{var I;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-${F}`,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(ks,{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-${F}`,children:T.originalName||T.fileName}),e.jsx("span",{className:"text-[8px] bg-slate-100 text-slate-500 px-1 py-0.5 rounded uppercase font-bold tracking-tighter",children:"APPLICANT"})]}),e.jsxs("p",{className:"text-[10px] text-slate-400 font-medium","data-testid":`onboarding-fdd-details-applicant-doc-meta-${F}`,children:[T.documentType," • ",Qt(T.createdAt),((I=T.uploader)==null?void 0:I.fullName)&&` • by ${T.uploader.fullName}`]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:()=>P(T),className:"p-1.5 hover:bg-white rounded text-slate-400 hover:text-blue-600 transition-all","data-testid":`onboarding-fdd-details-applicant-doc-preview-${F}`,children:e.jsx(un,{className:"w-4 h-4"})})})]},F)}),((U=n.uploadedDocuments)==null?void 0:U.filter(T=>!T.uploader||T.uploader.roleCode!=="FDD").length)===0&&e.jsx("p",{className:"text-[10px] text-slate-400 italic px-1","data-testid":"onboarding-fdd-details-applicant-docs-empty",children:"No documents from applicant yet."})]})]}),e.jsxs("div",{"data-testid":"onboarding-fdd-details-my-submissions",children:[e.jsxs("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider mb-2 flex items-center gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"My Uploaded Reports"]}),e.jsxs("div",{className:"space-y-2",children:[(M=n.uploadedDocuments)==null?void 0:M.filter(T=>{var F;return((F=T.uploader)==null?void 0:F.roleCode)==="FDD"}).map((T,F)=>{var I;return e.jsxs("div",{className:"p-3 border border-red-100 bg-red-50/30 rounded flex items-center justify-between hover:bg-red-50 transition-all group","data-testid":`onboarding-fdd-details-my-report-row-${F}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-red-50 flex items-center justify-center text-re-red",children:e.jsx(ks,{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-${F}`,children:T.originalName||T.fileName}),e.jsx("span",{className:"text-[8px] bg-red-500 text-white px-1 py-0.5 rounded uppercase font-bold tracking-tighter",children:"YOUR AUDIT REPORT"})]}),e.jsxs("p",{className:"text-[10px] text-slate-400 font-medium","data-testid":`onboarding-fdd-details-my-report-meta-${F}`,children:[T.documentType," • ",Qt(T.createdAt),((I=T.uploader)==null?void 0:I.fullName)&&` • by ${T.uploader.fullName}`]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:()=>P(T),className:"p-1.5 hover:bg-white rounded text-slate-400 hover:text-re-red transition-all","data-testid":`onboarding-fdd-details-my-report-preview-${F}`,children:e.jsx(un,{className:"w-4 h-4"})})})]},F)}),((z=n.uploadedDocuments)==null?void 0:z.filter(T=>{var F;return((F=T.uploader)==null?void 0:F.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(_e,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-profile-card",children:[e.jsx(Xe,{className:"border-b border-slate-100 px-6 pt-4 pb-2.5",children:e.jsx(st,{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Applicant Profile"})}),e.jsxs(Oe,{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(_e,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-statutory-card",children:[e.jsx(Xe,{className:"border-b border-slate-100 px-6 pt-4 pb-2.5",children:e.jsx(st,{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Statutory Details"})}),e.jsx(Oe,{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(_e,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-bank-card",children:[e.jsx(Xe,{className:"border-b border-slate-100 px-6 pt-4 pb-2.5",children:e.jsx(st,{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Bank Details"})}),e.jsx(Oe,{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(LE,{onBack:()=>u("details"),requestId:t,requestType:"application"})}),e.jsx(ho,{isOpen:N,onClose:()=>v(!1),document:w}),e.jsx(ms,{open:b,onOpenChange:C,children:e.jsxs(us,{className:"max-w-md p-0 overflow-hidden border-none shadow-2xl","data-testid":"onboarding-fdd-details-finalize-modal",children:[e.jsxs("div",{className:"bg-slate-950 p-6 flex items-center justify-center relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-re-red/20 to-transparent"}),e.jsx("div",{className:"w-16 h-16 bg-re-red/20 rounded-full flex items-center justify-center animate-pulse relative z-10",children:e.jsx(so,{className:"w-8 h-8 text-re-red"})})]}),e.jsxs("div",{className:"p-8 space-y-4",children:[e.jsxs(ys,{children:[e.jsx(gs,{className:"text-2xl font-bold text-slate-900 text-center","data-testid":"onboarding-fdd-details-finalize-title",children:"Submit Audit Report"}),e.jsxs(ws,{className:"text-slate-500 text-center pt-2 leading-relaxed text-base","data-testid":"onboarding-fdd-details-finalize-desc",children:["You are about to submit your final findings. This action will ",e.jsx("span",{className:"font-bold text-slate-800 underline decoration-re-red decoration-2",children:"notify the Admin"})," for review and approval."]})]}),e.jsxs("div",{className:"bg-red-50 p-4 rounded-xl flex gap-3 border border-red-100 italic","data-testid":"onboarding-fdd-details-finalize-info",children:[e.jsx(qa,{className:"w-5 h-5 text-re-red shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-red-800 leading-normal",children:"Once submitted, you cannot edit the findings. Ensure all documents are uploaded."})]}),e.jsx("div",{className:"space-y-4 pt-2",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] font-black uppercase tracking-widest text-slate-400",children:"Detailed Audit Findings & Remarks"}),e.jsx(Ks,{placeholder:"Enter detailed financial observations...",className:"min-h-[120px] bg-slate-50 border-slate-200 rounded-xl focus:ring-re-red text-sm resize-none",value:_,onChange:T=>A(T.target.value),"data-testid":"onboarding-fdd-details-finalize-remarks"})]})}),e.jsxs(mn,{className:"flex flex-col sm:flex-row gap-3 pt-4 sm:pt-6",children:[e.jsx(te,{variant:"outline",className:"w-full sm:flex-1 h-12 rounded-xl font-bold text-slate-600 hover:bg-slate-50 border-slate-200",onClick:()=>C(!1),disabled:m,"data-testid":"onboarding-fdd-details-finalize-cancel",children:"Cancel"}),e.jsx(te,{className:"w-full sm:flex-1 h-12 rounded-xl font-bold bg-slate-950 hover:bg-slate-900 text-white shadow-lg shadow-slate-200 transition-all active:scale-95 border-b-2 border-re-red","data-testid":"onboarding-fdd-details-finalize-confirm",onClick:async()=>{var T,F;try{if(!_.trim()){J.error("Please provide findings.");return}f(!0);const I=(T=a==null?void 0:a.reports)==null?void 0:T[0];(F=(await Re.submitFddReport({assignmentId:a==null?void 0:a.id,applicationId:t,reportDocumentId:I==null?void 0:I.reportDocumentId,findings:_,recommendation:null})).data)!=null&&F.success&&(J.success("FDD Report submitted successfully."),C(!1),O())}catch{J.error("Failed to submit report")}finally{f(!1)}},disabled:m,children:m?e.jsx(cs,{className:"w-5 h-5 animate-spin"}):"Confirm & Submit"})]})]})]})}),e.jsx(ms,{open:S,onOpenChange:D,children:e.jsxs(us,{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(Ba,{className:"w-8 h-8 text-red-500"})})]}),e.jsxs("div",{className:"p-8 space-y-4",children:[e.jsxs(ys,{children:[e.jsx(gs,{className:"text-2xl font-bold text-slate-900 text-center","data-testid":"onboarding-fdd-details-flag-modal-title",children:"Flag Applicant"}),e.jsxs(ws,{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(mn,{className:"flex flex-col sm:flex-row gap-3 pt-4 sm:pt-6",children:[e.jsx(te,{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:()=>D(!1),disabled:m,"data-testid":"onboarding-fdd-details-flag-modal-cancel",children:"Go Back"}),e.jsx(te,{className:"w-full sm:flex-1 h-12 rounded-xl font-bold bg-slate-950 hover:bg-slate-900 text-white shadow-lg shadow-slate-200 transition-all active:scale-95 border-b-2 border-red-600","data-testid":"onboarding-fdd-details-flag-modal-confirm",onClick:async()=>{try{f(!0),await Re.flagNonResponsive({applicationId:t,remarks:"Applicant is non-responsive to FDD queries."}),J.error("Application flagged for non-responsiveness."),D(!1),O()}catch{J.error("Action failed")}finally{f(!1)}},disabled:m,children:m?e.jsx(cs,{className:"w-5 h-5 animate-spin"}):"Flag Applicant"})]})]})]})})]})}const Yl={getOperationsDashboard:async t=>(await Re.getSlaOperationsDashboard(t)).data,getBatchStatus:async t=>(await Re.postSlaBatchStatus({items:t})).data,exportOperationsCsv:async t=>{const s="https://dealeronboarding-uat.royalenfield.com/api",n=new URLSearchParams;t!=null&&t.module&&n.set("module",t.module),t!=null&&t.mineOnly&&n.set("mineOnly","true");const r=localStorage.getItem("token"),a=await fetch(`${s}/sla/operations/export?${n.toString()}`,{headers:r?{Authorization:`Bearer ${r}`}:{}});if(!a.ok)throw new Error("Export failed");const i=await a.blob(),o=URL.createObjectURL(i),d=document.createElement("a");d.href=o,d.download=`sla-queue-${Date.now()}.csv`,d.click(),URL.revokeObjectURL(o)},getQuestionnaireReminderSettings:async()=>(await Re.getQuestionnaireReminderSettings()).data,updateQuestionnaireReminderSettings:async t=>(await Re.updateQuestionnaireReminderSettings(t)).data},oq={healthy:"bg-emerald-100 text-emerald-800 border-emerald-200",warning:"bg-red-50 text-red-800 border-red-200",critical:"bg-orange-100 text-orange-800 border-orange-200",breached:"bg-red-100 text-red-800 border-red-200"},cq={healthy:"On track",warning:"Due soon",critical:"At risk",breached:"Breached"};function br({status:t,compact:s}){if(!t)return null;const n=t.isPaused?"warning":t.bucket,r=t.isPaused?"Paused":cq[t.bucket];return e.jsx(we,{variant:"outline",className:`text-[10px] font-semibold ${oq[n]} ${s?"px-1.5":""}`,title:`${t.stageName} · ${t.remainingLabel} (${t.percentUsed}% of TAT)`,children:s?r:`${r} · ${t.remainingLabel}`})}function dq(t,s=[]){let n=[];function r(i,o){const d=g.createContext(o);d.displayName=i+"Context";const m=n.length;n=[...n,o];const f=h=>{var j;const{scope:x,children:u,...N}=h,v=((j=x==null?void 0:x[t])==null?void 0:j[m])||d,w=g.useMemo(()=>N,Object.values(N));return e.jsx(v.Provider,{value:w,children:u})};f.displayName=i+"Provider";function p(h,x){var v;const u=((v=x==null?void 0:x[t])==null?void 0:v[m])||d,N=g.useContext(u);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[f,p]}const a=()=>{const i=n.map(o=>g.createContext(o));return function(d){const m=(d==null?void 0:d[t])||i;return g.useMemo(()=>({[`__scope${t}`]:{...d,[t]:m}}),[d,m])}};return a.scopeName=t,[r,uq(a,...s)]}function uq(...t){const s=t[0];if(t.length===1)return s;const n=()=>{const r=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((d,{useScope:m,scopeName:f})=>{const h=m(i)[`__scope${f}`];return{...d,...h}},{});return g.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return n.scopeName=s.scopeName,n}var hq=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],IE=hq.reduce((t,s)=>{const n=Hu(`Primitive.${s}`),r=g.forwardRef((a,i)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),Kb="Progress",Yb=100,[mq]=dq(Kb),[fq,pq]=mq(Kb),ME=g.forwardRef((t,s)=>{const{__scopeProgress:n,value:r=null,max:a,getValueLabel:i=xq,...o}=t;(a||a===0)&&!jS(a)&&console.error(gq(`${a}`,"Progress"));const d=jS(a)?a:Yb;r!==null&&!NS(r,d)&&console.error(vq(`${r}`,"Progress"));const m=NS(r,d)?r:null,f=gf(m)?i(m,d):void 0;return e.jsx(fq,{scope:n,value:m,max:d,children:e.jsx(IE.div,{"aria-valuemax":d,"aria-valuemin":0,"aria-valuenow":gf(m)?m:void 0,"aria-valuetext":f,role:"progressbar","data-state":$E(m,d),"data-value":m??void 0,"data-max":d,...o,ref:s})})});ME.displayName=Kb;var FE="ProgressIndicator",BE=g.forwardRef((t,s)=>{const{__scopeProgress:n,...r}=t,a=pq(FE,n);return e.jsx(IE.div,{"data-state":$E(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...r,ref:s})});BE.displayName=FE;function xq(t,s){return`${Math.round(t/s*100)}%`}function $E(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function gf(t){return typeof t=="number"}function jS(t){return gf(t)&&!isNaN(t)&&t>0}function NS(t,s){return gf(t)&&!isNaN(t)&&t<=s&&t>=0}function gq(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${Yb}\`.`}function vq(t,s){return`Invalid prop \`value\` of value \`${t}\` supplied to \`${s}\`. The \`value\` prop must be: - a positive number - less than the value passed to \`max\` (or ${Yb} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var yq=ME,bq=BE;function oc({className:t,indicatorClassName:s,value:n,...r}){return e.jsx(yq,{"data-slot":"progress",className:Nt("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",t),...r,children:e.jsx(bq,{"data-slot":"progress-indicator",className:Nt("bg-primary h-full w-full flex-1 transition-all",s),style:{transform:`translateX(-${100-(n||0)}%)`}})})}const jq=["Rejected","Revoked","Withdrawn"];function Ad(t,s){const n=String(t||""),r=String(s||"");return jq.some(a=>n.includes(a)||r===a)}function Zb(t,s){const n=String(t||""),r=String(s||"");return n==="Completed"||r==="Completed"||n==="Settled"||n==="Onboarded"||n==="Verified"||n==="Closed"}function Nq(t,s){return Zb(t,s)?"success":Ad(t,s)?"negative":"inProgress"}const lr={inProgress:{bar:"bg-status-progress",barBadge:"bg-status-progress hover:bg-status-progress-hover text-white border-transparent",badge:"bg-status-progress-soft text-status-progress-strong border-status-progress",badgeSolid:"bg-status-progress hover:bg-status-progress-hover text-white border-transparent",text:"text-status-progress-muted",textStrong:"text-status-progress-strong",icon:"text-status-progress",workflowIcon:"bg-status-workflow-icon",workflowPanel:"bg-status-workflow-panel -ml-4 pl-4 pr-4 py-3 rounded-lg border border-status-workflow-panel",workflowTitle:"text-status-progress-strong",workflowSubtitle:"text-status-progress-muted",workflowStageBadge:"bg-status-workflow-badge border",panel:"bg-status-workflow-panel -ml-4 pl-4 pr-4 py-3 rounded-lg border border-status-workflow-panel",title:"text-status-progress-strong",subtitle:"text-status-progress-muted",stageBadge:"bg-status-workflow-badge border",progress:"bg-status-progress",workflowActive:"bg-status-workflow-active"},success:{bar:"bg-green-600",barBadge:"bg-green-600 hover:bg-green-700 text-white border-transparent",badge:"bg-green-100 text-green-800 border-green-200",badgeSolid:"bg-green-600 hover:bg-green-700 text-white border-transparent",text:"text-green-700",textStrong:"text-green-900",icon:"text-green-600",workflowIcon:"bg-green-100 text-green-600",workflowPanel:"bg-green-50 border border-green-200",workflowTitle:"text-green-900",workflowSubtitle:"text-green-700",workflowStageBadge:"bg-green-100 text-green-700 border-green-300",panel:"bg-green-50 border border-green-200",title:"text-green-900",subtitle:"text-green-700",stageBadge:"bg-green-100 text-green-700 border-green-300",progress:"bg-green-600",workflowActive:"bg-green-600 border-green-600"},negative:{bar:"bg-re-red",barBadge:"bg-re-red hover:bg-re-red-hover text-white border-transparent",badge:"bg-red-50 text-re-red border-red-200",badgeSolid:"bg-re-red hover:bg-re-red-hover text-white border-transparent",text:"text-re-red-hover",textStrong:"text-red-900",icon:"text-re-red",workflowIcon:"bg-red-100 text-re-red",workflowPanel:"bg-red-50 border border-red-200",workflowTitle:"text-red-900",workflowSubtitle:"text-re-red-hover",workflowStageBadge:"bg-red-50 text-re-red border-red-200",panel:"bg-red-50 border border-red-200",title:"text-red-900",subtitle:"text-re-red-hover",stageBadge:"bg-red-50 text-re-red border-red-200",progress:"bg-re-red",workflowActive:"bg-re-red border-re-red"},neutral:{bar:"bg-slate-300",barBadge:"bg-slate-500 text-white border-transparent",badge:"bg-slate-100 text-slate-700 border-slate-200",badgeSolid:"bg-slate-600 hover:bg-slate-700 text-white border-transparent",text:"text-slate-600",textStrong:"text-slate-900",icon:"text-slate-500",workflowIcon:"bg-slate-100 text-slate-400",workflowPanel:"",workflowTitle:"text-slate-900",workflowSubtitle:"text-slate-600",workflowStageBadge:"bg-slate-100 text-slate-500 border-slate-300",panel:"",title:"text-slate-900",subtitle:"text-slate-600",stageBadge:"bg-slate-100 text-slate-500 border-slate-300",progress:"bg-slate-300",workflowActive:"bg-slate-400 border-slate-400"}};function qE(t,s){return lr[Nq(t,s)]}function fl(t,s){return qE(t,s).bar}function wq(t,s){return qE(t,s).barBadge}function Sq(t){return t>=100?lr.success.bar:lr.inProgress.bar}function Cq(t){return t>=100?lr.success.barBadge:lr.inProgress.barBadge}function zE(t){const s=String(t||""),n=s.toUpperCase();return s.includes("Rejected")||n.includes("DOCUMENT_REJECTED")?lr.negative.badge:s==="Verified"||s==="Completed"||n.includes("DOCUMENT_VERIFIED")?lr.success.badge:s.includes("Pending")||s.includes("Review")||s==="In Progress"?lr.inProgress.badge:lr.neutral.badge}function Qb(t,s){return Zb(t,s)?lr.success.badge:(Ad(t,s),lr.negative.badge)}function Xb(t,s){return Zb(t,s)?lr.success.badgeSolid:(Ad(t,s),lr.negative.badgeSolid)}function Jl(t,s){const n=String(t||""),r=String(s||"");return Ad(r,n)||/rejected|revoked/i.test(n)?lr.negative.badge:n==="Completed"||r==="Completed"||n==="Closed"?lr.success.badge:lr.negative.badge}function up({value:t,status:s,currentStage:n,barClassName:r="h-2 w-20 bg-status-progress-soft",showPercent:a=!1,percentClassName:i="text-slate-600 shrink-0","data-testid":o}){return e.jsxs("div",{className:Nt("flex items-center gap-2 min-w-0",a&&"w-full max-w-[8rem]"),"data-testid":o?`${o}-container`:void 0,children:[e.jsx(oc,{value:t,className:r,indicatorClassName:fl(s,n),"data-testid":o}),a&&e.jsxs("span",{className:i,"data-testid":o?`${o}-text`:void 0,children:[t,"%"]})]})}function mo({className:t,...s}){return e.jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:Nt("mx-auto flex w-full justify-center",t),...s})}function fo({className:t,...s}){return e.jsx("ul",{"data-slot":"pagination-content",className:Nt("flex flex-row items-center gap-1",t),...s})}function pn({...t}){return e.jsx("li",{"data-slot":"pagination-item",...t})}function $i({className:t,isActive:s,size:n="icon",...r}){return e.jsx("a",{"aria-current":s?"page":void 0,"data-slot":"pagination-link","data-active":s,className:Nt(nd({variant:s?"outline":"ghost",size:n}),t),...r})}function po({className:t,...s}){return e.jsxs($i,{"aria-label":"Go to previous page",size:"default",className:Nt("gap-1 px-2.5 sm:pl-2.5",t),...s,children:[e.jsx(io,{}),e.jsx("span",{className:"hidden sm:block",children:"Previous"})]})}function xo({className:t,...s}){return e.jsxs($i,{"aria-label":"Go to next page",size:"default",className:Nt("gap-1 px-2.5 sm:pr-2.5",t),...s,children:[e.jsx("span",{className:"hidden sm:block",children:"Next"}),e.jsx(mi,{})]})}function go({className:t,...s}){return e.jsxs("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:Nt("flex size-9 items-center justify-center",t),...s,children:[e.jsx(WI,{className:"size-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]})}function Aq({onViewDetails:t,initialFilter:s}){const{user:n}=Pn(z=>z.auth),[r,a]=g.useState(""),[i,o]=g.useState("all"),[d,m]=g.useState(s||"all"),[f,p]=g.useState([]),[h,x]=g.useState(!1),[u]=g.useState("date"),[N,v]=g.useState(!1),[w,j]=g.useState(!1),[b,C]=g.useState([]),[S,D]=g.useState({}),[_,A]=g.useState([]),[E,q]=g.useState(1),[O,R]=g.useState(null),P=10;g.useEffect(()=>{L()},[E,i,d,r]);const L=async()=>{try{const z=await ps.getApplications({page:E,limit:P,status:d!=="all"?d:void 0,location:i!=="all"?i:void 0,search:r||void 0,ddLeadShortlisted:"true",isShortlisted:"true",assignedTo:w?n==null?void 0:n.id:void 0}),T=z.data||[];R(z.meta);const F=T.map(I=>({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:0,rank:0,totalApplicantsAtLocation:0,submissionDate:I.createdAt,assignedUsers:[],assignedTo:I.assignedTo,progress:I.progressPercentage||0,isShortlisted:I.ddLeadShortlisted||I.isShortlisted||!1,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}));if(C(F),F.length>0?Yl.getBatchStatus(F.map(I=>({entityType:"application",entityId:I.id}))).then(I=>{if(I!=null&&I.success){const K={};F.forEach(G=>{K[G.id]=I.data[`application:${G.id}`]??null}),D(K)}}).catch(()=>D({})):D({}),_.length===0){const I=Array.from(new Set(F.map(K=>K.preferredLocation))).filter(Boolean);A(I)}}catch(z){console.error("Failed to fetch applications",z)}finally{}},$=b.sort((z,T)=>u==="date"?new Date(T.submissionDate).getTime()-new Date(z.submissionDate).getTime():0),Z=z=>{p(T=>T.includes(z)?T.filter(F=>F!==z):[...T,z])},Q=()=>{f.length===$.length?p([]):p($.map(z=>z.id))},W=async()=>{if(f.length!==0)try{x(!0);const z=await ps.sendBulkReminders(f);z.success&&(J.success(z.message||`Reminder emails sent to ${f.length} applicant(s)`),p([]))}catch(z){console.error("Failed to send reminders:",z),J.error(z.message||"Failed to send reminders")}finally{x(!1)}},U=()=>{alert("Exporting applications to CSV...")},M=z=>({Submitted:"bg-slate-500","Questionnaire Pending":"bg-orange-500","Questionnaire Completed":"bg-blue-500",Shortlisted:"bg-cyan-500","Level 1 Pending":"bg-red-500","Level 1 Approved":"bg-green-500","Level 2 Pending":"bg-purple-500","Level 2 Approved":"bg-green-600","Level 2 Recommended":"bg-teal-500","Level 3 Pending":"bg-indigo-500","FDD Verification":"bg-violet-500","Payment Pending":"bg-yellow-500","LOI Issued":"bg-lime-500","Dealer Code Generation":"bg-fuchsia-500","Architecture Team Assigned":"bg-blue-500","Architecture Document Upload":"bg-blue-500","Architecture Team Completion":"bg-blue-500","Statutory GST":"bg-emerald-500","Statutory PAN":"bg-emerald-500","Statutory Nodal":"bg-emerald-500","Statutory Check":"bg-emerald-500","Statutory Partnership":"bg-emerald-500","Statutory Firm Reg":"bg-emerald-500","Statutory Virtual Code":"bg-emerald-500","Statutory Domain":"bg-emerald-500","Statutory MSD":"bg-emerald-500","Statutory LOI Ack":"bg-emerald-500","EOR In Progress":"bg-sky-500","LOA Pending":"bg-emerald-500",Approved:"bg-green-700",Rejected:"bg-red-500",Disqualified:"bg-red-700"})[z]||"bg-slate-500";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-4",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(it,{type:"text",placeholder:"Search by name, ID, or email...",value:r,onChange:z=>a(z.target.value),className:"pl-10","data-testid":"onboarding-applications-search-input"})]}),e.jsxs(Rt,{value:i,onValueChange:o,children:[e.jsx(_t,{className:"w-full lg:w-48","data-testid":"onboarding-applications-location-filter",children:e.jsx(Et,{placeholder:"All Locations"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All Locations"}),_.map(z=>e.jsx(Pe,{value:z,children:z},z))]})]}),e.jsxs(Rt,{value:d,onValueChange:m,children:[e.jsx(_t,{className:"w-full lg:w-48","data-testid":"onboarding-applications-status-filter",children:e.jsx(Et,{placeholder:"All Statuses"})}),e.jsxs(Tt,{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(Tn,{id:"my-assignments",checked:w,onCheckedChange:z=>j(z),"data-testid":"onboarding-applications-assignments-checkbox"}),e.jsx(le,{htmlFor:"my-assignments","data-testid":"onboarding-applications-assignments-label",children:"My Assignments Only"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mt-4",children:[e.jsxs(te,{variant:"outline",size:"sm",onClick:U,"data-testid":"onboarding-applications-export-button",children:[e.jsx(fi,{className:"w-4 h-4 mr-2"}),"Export"]}),f.length>0&&e.jsxs(te,{variant:"outline",size:"sm",onClick:W,disabled:h,"data-testid":"onboarding-applications-reminders-button",children:[h?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Gr,{className:"w-4 h-4 mr-2"}),"Send Reminders (",f.length,")"]}),e.jsxs("div",{className:"ml-auto text-slate-600","data-testid":"onboarding-applications-count-text",children:[O?O.total:$.length," application",(O==null?void 0:O.total)!==1?"s":""]})]})]}),e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200",children:[e.jsxs(Ms,{"data-testid":"onboarding-applications-table",children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{className:"w-12",children:e.jsx(Tn,{checked:f.length===$.length&&$.length>0,onCheckedChange:Q,"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:"SLA"}),e.jsx(me,{children:"Applicant Location"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Applied On"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:$.map((z,T)=>e.jsxs(lt,{"data-testid":`onboarding-application-row-${T}`,children:[e.jsx(oe,{children:e.jsx(Tn,{checked:f.includes(z.id),onCheckedChange:()=>Z(z.id),"data-testid":`onboarding-application-checkbox-${T}`})}),e.jsx(oe,{"data-testid":`onboarding-application-id-${T}`,children:z.registrationNumber}),e.jsx(oe,{"data-testid":`onboarding-application-name-${T}`,children:z.name}),e.jsx(oe,{"data-testid":`onboarding-application-pref-location-${T}`,children:z.preferredLocation}),e.jsx(oe,{children:e.jsx(we,{className:M(z.status),"data-testid":`onboarding-application-status-${T}`,children:z.status})}),e.jsx(oe,{children:e.jsx(br,{status:S[z.id],compact:!0})}),e.jsx(oe,{className:"text-slate-600 max-w-xs truncate","data-testid":`onboarding-application-addr-${T}`,children:z.residentialAddress}),e.jsx(oe,{children:e.jsx(up,{value:z.progress,status:z.status,showPercent:!0,"data-testid":`onboarding-application-progress-bar-${T}`})}),e.jsx(oe,{"data-testid":`onboarding-application-date-${T}`,children:Qt(z.submissionDate)}),e.jsx(oe,{children:e.jsx(te,{size:"sm",variant:"outline",onClick:()=>t(z.id),"data-testid":`onboarding-application-view-btn-${T}`,children:"View"})})]},z.id))})]}),O&&O.totalPages>1&&e.jsx("div",{className:"py-4 border-t px-4 flex justify-center",children:e.jsx(mo,{children:e.jsxs(fo,{children:[e.jsx(pn,{children:e.jsx(po,{onClick:()=>q(z=>Math.max(1,z-1)),className:E===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(O.totalPages)].map((z,T)=>{const F=T+1;return F===1||F===O.totalPages||F>=E-1&&F<=E+1?e.jsx(pn,{children:e.jsx($i,{isActive:E===F,onClick:()=>q(F),className:"cursor-pointer",children:F})},F):F===2&&E>3||F===O.totalPages-1&&Eq(z=>Math.min(O.totalPages,z+1)),className:E===O.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]}),e.jsx(ms,{open:N,onOpenChange:v,children:e.jsxs(us,{className:"max-w-2xl","data-testid":"onboarding-new-app-modal",children:[e.jsx(ys,{children:e.jsx(gs,{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(le,{children:"Name"}),e.jsx(it,{placeholder:"Full Name","data-testid":"onboarding-new-app-name"})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Email"}),e.jsx(it,{type:"email",placeholder:"email@example.com","data-testid":"onboarding-new-app-email"})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Phone"}),e.jsx(it,{placeholder:"+91 XXXXX XXXXX","data-testid":"onboarding-new-app-phone"})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Preferred Location"}),e.jsxs(Rt,{children:[e.jsx(_t,{"data-testid":"onboarding-new-app-location-select",children:e.jsx(Et,{placeholder:"Select location"})}),e.jsx(Tt,{children:_.map(z=>e.jsx(Pe,{value:z,children:z},z))})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(te,{variant:"outline",onClick:()=>v(!1),"data-testid":"onboarding-new-app-cancel",children:"Cancel"}),e.jsx(te,{className:"bg-re-red hover:bg-re-red-hover","data-testid":"onboarding-new-app-submit",children:"Create Application"})]})]})]})})]})}function UE({application:t,onViewDetails:s}){var r;const n=a=>({Submitted:"bg-slate-500","Questionnaire Pending":"bg-orange-500","Questionnaire Completed":"bg-blue-500",Shortlisted:"bg-cyan-500","Level 1 Pending":"bg-red-500","Level 1 Approved":"bg-green-500","Level 2 Pending":"bg-purple-500","Level 2 Approved":"bg-green-600","Level 2 Recommended":"bg-teal-500","Level 3 Pending":"bg-indigo-500","FDD Verification":"bg-violet-500","Payment Pending":"bg-yellow-500","LOI Issued":"bg-lime-500","Dealer Code Generation":"bg-fuchsia-500","Architecture Team Assigned":"bg-blue-500","Architecture Document Upload":"bg-blue-500","Architecture Team Completion":"bg-blue-500","Statutory GST":"bg-emerald-500","Statutory PAN":"bg-emerald-500","Statutory Nodal":"bg-emerald-500","Statutory Check":"bg-emerald-500","Statutory Partnership":"bg-emerald-500","Statutory Firm Reg":"bg-emerald-500","Statutory Virtual Code":"bg-emerald-500","Statutory Domain":"bg-emerald-500","Statutory MSD":"bg-emerald-500","Statutory LOI Ack":"bg-emerald-500","EOR In Progress":"bg-sky-500","LOA Pending":"bg-emerald-500",Approved:"bg-green-700",Rejected:"bg-red-500",Disqualified:"bg-red-700"})[a]||"bg-slate-500";return e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-6 hover:shadow-lg transition-shadow","data-testid":`onboarding-application-card-${t.id}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"text-slate-900","data-testid":"onboarding-application-card-name",children:t.name}),(r=t.tags)==null?void 0:r.map(a=>e.jsx(we,{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(we,{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(Mr,{className:"w-4 h-4"}),e.jsx("span",{"data-testid":"onboarding-application-card-location",children:t.preferredLocation}),t.rank&&t.totalApplicantsAtLocation&&e.jsxs(we,{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(ad,{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(Gr,{className:"w-4 h-4"}),e.jsx("span",{"data-testid":"onboarding-application-card-email",children:t.email})]}),e.jsxs("div",{className:"flex items-center gap-2 text-slate-600",children:[e.jsx(tb,{className:"w-4 h-4"}),e.jsx("span",{"data-testid":"onboarding-application-card-phone",children:t.phone})]}),t.questionnaireMarks!==void 0&&e.jsxs("div",{className:"flex items-center gap-2 text-slate-600",children:[e.jsx(nk,{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(er,{className:"w-4 h-4"}),e.jsxs("span",{"data-testid":"onboarding-application-card-submission-date",children:["Submitted: ",Qt(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(up,{value:t.progress,status:t.status,barClassName:"h-2 w-full bg-status-progress-soft","data-testid":"onboarding-application-card-progress-bar"})]}),t.deadline&&t.status==="Questionnaire Pending"&&e.jsx("div",{className:"mb-4 p-3 bg-orange-50 border border-orange-200 rounded-md","data-testid":"onboarding-application-card-deadline-warning",children:e.jsxs("p",{className:"text-orange-800",children:["Deadline: ",Qt(t.deadline)]})}),e.jsx(te,{onClick:()=>s(t.id),className:"w-full bg-re-red hover:bg-re-red-hover","data-testid":"onboarding-application-card-view-button",children:"View Details"})]})}function kq({onViewDetails:t,initialFilter:s="all"}){const[n,r]=g.useState("grid"),[a,i]=g.useState(""),[o,d]=g.useState(s),[m,f]=g.useState("all"),[p,h]=g.useState("all"),[x,u]=g.useState([]),[N,v]=g.useState(!1),[w,j]=g.useState(""),[b,C]=g.useState([]),[S,D]=g.useState(!0),[_,A]=g.useState([]),[E,q]=g.useState([]),[O,R]=g.useState(1),[P,L]=g.useState(null);g.useEffect(()=>{Z()},[O,a,o,m,p]),g.useEffect(()=>{R(1)},[a,o,m,p]),g.useEffect(()=>{$()},[]);const $=async()=>{try{const I=await $s.getStates(),G=(Array.isArray(I)?I:(I==null?void 0:I.data)||(I==null?void 0:I.states)||[]).map(V=>typeof V=="string"?V:V.name||V.stateName).filter(Boolean);A(G)}catch(I){console.error("Failed to fetch states:",I)}},Z=async()=>{try{D(!0);const I=await ps.getApplications({page:O,limit:10,search:a,status:o==="all"?void 0:o,location:m!=="all"?m:void 0,state:p!=="all"?p:void 0,isShortlisted:void 0}),K=I.data||[];L(I.meta);const G=K.map(Y=>({id:Y.id,registrationNumber:Y.applicationId||"N/A",name:Y.applicantName,email:Y.email,phone:Y.phone,age:Y.age,education:Y.education,residentialAddress:Y.address||Y.city||"",businessAddress:Y.address||"",preferredLocation:Y.preferredLocation,state:Y.state,ownsBike:Y.ownRoyalEnfield==="yes",pastExperience:Y.experienceYears?`${Y.experienceYears} years`:Y.description||"",status:Y.overallStatus,questionnaireMarks:Y.score||Y.questionnaireMarks||0,rank:0,totalApplicantsAtLocation:0,submissionDate:Y.createdAt,assignedUsers:[],progress:Y.progressPercentage||0,isShortlisted:Y.isShortlisted||Y.ddLeadShortlisted,companyName:Y.companyName,source:Y.source,existingDealer:Y.existingDealer,royalEnfieldModel:Y.royalEnfieldModel,description:Y.description,pincode:Y.pincode,locationType:Y.locationType,ownRoyalEnfield:Y.ownRoyalEnfield,address:Y.address}));C(G);const V=Array.from(new Set(G.map(Y=>Y.preferredLocation))).filter(Boolean);q(V)}catch(I){console.error("Failed to fetch applications:",I),J.error("Failed to load applications")}finally{D(!1)}},Q=b,W=I=>{u(I?Q.map(K=>K.id):[])},U=(I,K)=>{u(K?[...x,I]:x.filter(G=>G!==I))},M=()=>{if(x.length===0){J.error("Please select at least one application to shortlist");return}v(!0)},z=async()=>{try{J.success(`${x.length} application(s) shortlisted successfully!`),v(!1),Z()}catch{J.error("Failed to shortlist")}},T=["Submitted","Questionnaire Pending","Questionnaire Completed"],F=I=>({Submitted:"bg-blue-100 text-blue-800","Questionnaire Pending":"bg-yellow-100 text-yellow-800","Questionnaire Completed":"bg-cyan-100 text-cyan-800",Shortlisted:"bg-purple-100 text-purple-800","Level 1 Interview Pending":"bg-orange-100 text-orange-800","Level 1 Approved":"bg-green-100 text-green-800","Level 2 Interview Pending":"bg-orange-100 text-orange-800","Level 2 Approved":"bg-green-100 text-green-800","Level 2 Recommended":"bg-teal-100 text-teal-800","Level 3 Interview Pending":"bg-orange-100 text-orange-800","In Review":"bg-slate-100 text-slate-800","Level 3 Approved":"bg-green-100 text-green-800","FDD Verification":"bg-indigo-100 text-indigo-800","Payment Pending":"bg-red-50 text-red-800","LOI In Progress":"bg-sky-100 text-sky-800","LOI Issued":"bg-sky-100 text-sky-800","Dealer Code Generation":"bg-purple-100 text-purple-800","Architecture Team Assigned":"bg-blue-100 text-blue-800","Architecture Document Upload":"bg-blue-100 text-blue-800","Architecture Team Completion":"bg-blue-100 text-blue-800","Statutory GST":"bg-emerald-100 text-emerald-800","Statutory PAN":"bg-emerald-100 text-emerald-800","Statutory Nodal":"bg-emerald-100 text-emerald-800","Statutory Check":"bg-emerald-100 text-emerald-800","Statutory Partnership":"bg-emerald-100 text-emerald-800","Statutory Firm Reg":"bg-emerald-100 text-emerald-800","Statutory Rental":"bg-emerald-100 text-emerald-800","Statutory Virtual Code":"bg-emerald-100 text-emerald-800","Statutory Domain":"bg-emerald-100 text-emerald-800","Statutory MSD":"bg-emerald-100 text-emerald-800","Statutory LOI Ack":"bg-emerald-100 text-emerald-800","EOR In Progress":"bg-violet-100 text-violet-800","EOR Complete":"bg-violet-100 text-violet-800","LOA Pending":"bg-pink-100 text-pink-800",Inauguration:"bg-red-50 text-red-800",Approved:"bg-green-100 text-green-800",Rejected:"bg-red-100 text-red-800",Disqualified:"bg-gray-100 text-gray-800",Onboarded:"bg-emerald-100 text-emerald-800","LOI Approved":"bg-sky-100 text-sky-800","Security Deposit In Progress":"bg-red-50 text-red-800","Security Deposit Approved":"bg-green-100 text-green-800","Security Deposit":"bg-red-50 text-red-800","Security Details In Progress":"bg-red-50 text-red-800","Security Details Approved":"bg-green-100 text-green-800","Security Details":"bg-red-50 text-red-800","LOA Issued":"bg-pink-100 text-pink-800"})[I]||"bg-gray-100 text-gray-800";return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4","data-testid":"onboarding-all-apps-banner",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-red-900 mb-1",children:"DD Workflow - Initial Application Review"}),e.jsxs("p",{className:"text-red-800",children:["This page shows ",e.jsx("strong",{children:"only applications that haven't been shortlisted yet"}),". Review and select promising candidates using the ",e.jsx("strong",{children:"Shortlist"})," button. Once shortlisted, applications will be removed from here and moved to the ",e.jsx("strong",{children:"Dealership Requests"})," page for further processing."]})]})]})}),e.jsx("div",{className:"bg-white rounded-lg border border-slate-200 p-6",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(it,{type:"text",placeholder:"Search by name or registration number...",value:a,onChange:I=>i(I.target.value),className:"pl-10","data-testid":"onboarding-all-apps-search-input"})]}),e.jsxs(Rt,{value:o,onValueChange:d,children:[e.jsx(_t,{className:"w-full md:w-48","data-testid":"onboarding-all-apps-status-filter",children:e.jsx(Et,{placeholder:"Filter by status"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All Statuses"}),T.map(I=>e.jsx(Pe,{value:I,children:I},I))]})]}),e.jsxs(Rt,{value:p,onValueChange:h,children:[e.jsx(_t,{className:"w-full md:w-48","data-testid":"onboarding-all-apps-state-filter",children:e.jsx(Et,{placeholder:"Filter by state"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All States"}),_.map(I=>e.jsx(Pe,{value:I,children:I},I))]})]}),e.jsxs(Rt,{value:m,onValueChange:f,children:[e.jsx(_t,{className:"w-full md:w-48","data-testid":"onboarding-all-apps-location-filter",children:e.jsx(Et,{placeholder:"Filter by location"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All Locations"}),E.map(I=>e.jsx(Pe,{value:I,children:I},I))]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(te,{variant:n==="grid"?"default":"outline",size:"sm",onClick:()=>r("grid"),className:n==="grid"?"bg-re-red hover:bg-re-red-hover":"","data-testid":"onboarding-all-apps-grid-view-btn",children:[e.jsx(lk,{className:"w-4 h-4 mr-2"}),"Grid"]}),e.jsxs(te,{variant:n==="table"?"default":"outline",size:"sm",onClick:()=>r("table"),className:n==="table"?"bg-re-red hover:bg-re-red-hover":"","data-testid":"onboarding-all-apps-table-view-btn",children:[e.jsx(dk,{className:"w-4 h-4 mr-2"}),"Table"]})]}),e.jsxs(te,{variant:"outline",size:"sm","data-testid":"onboarding-all-apps-export-btn",children:[e.jsx(fi,{className:"w-4 h-4 mr-2"}),"Export"]}),x.length>0&&e.jsx(e.Fragment,{children:e.jsxs(te,{size:"sm",onClick:M,className:"bg-green-600 hover:bg-green-700","data-testid":"onboarding-all-apps-shortlist-btn",children:[e.jsx(ln,{className:"w-4 h-4 mr-2"}),"Shortlist (",x.length,")"]})}),e.jsx("div",{className:"ml-auto",children:e.jsxs(we,{variant:"outline",className:"text-slate-600","data-testid":"onboarding-all-apps-pending-badge",children:[(P==null?void 0:P.total)||Q.length," pending shortlisting"]})})]})]})}),S?e.jsx("div",{className:"flex justify-center items-center h-96 bg-white rounded-lg border border-slate-200",children:e.jsx(cs,{className:"w-8 h-8 animate-spin text-re-red"})}):n==="grid"?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4","data-testid":"onboarding-all-apps-grid-container",children:Q.map((I,K)=>e.jsxs("div",{className:"relative","data-testid":`onboarding-all-apps-grid-item-${K}`,children:[e.jsx("div",{className:"absolute top-4 left-4 z-10",children:e.jsx(Tn,{checked:x.includes(I.id),onCheckedChange:G=>U(I.id,G),className:"bg-white","data-testid":`onboarding-all-apps-grid-checkbox-${K}`})}),I.isShortlisted&&e.jsx("div",{className:"absolute top-4 right-4 z-10",children:e.jsx(we,{className:"bg-green-600","data-testid":`onboarding-all-apps-grid-shortlisted-badge-${K}`,children:"Shortlisted"})}),e.jsx(UE,{application:I,onViewDetails:t})]},I.id))}):e.jsx("div",{className:"bg-white rounded-lg border border-slate-200",children:e.jsxs(Ms,{"data-testid":"onboarding-all-apps-table",children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{className:"w-12",children:e.jsx(Tn,{checked:x.length===Q.length&&Q.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(Bs,{children:Q.map((I,K)=>e.jsxs(lt,{className:"cursor-pointer hover:bg-slate-50",onClick:()=>t(I.id),"data-testid":`onboarding-all-apps-row-${K}`,children:[e.jsx(oe,{onClick:G=>G.stopPropagation(),children:e.jsx(Tn,{checked:x.includes(I.id),onCheckedChange:G=>U(I.id,G),"data-testid":`onboarding-all-apps-checkbox-${K}`})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-all-apps-reg-id-${K}`,children:I.registrationNumber})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-all-apps-name-${K}`,children:I.name})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-all-apps-location-${K}`,children:I.preferredLocation})}),e.jsx(oe,{children:e.jsx(we,{className:F(I.status),"data-testid":`onboarding-all-apps-status-${K}`,children:I.status})}),e.jsx(oe,{children:I.isShortlisted?e.jsx(we,{className:"bg-green-600","data-testid":`onboarding-all-apps-shortlisted-yes-${K}`,children:"Yes"}):e.jsx(we,{variant:"outline","data-testid":`onboarding-all-apps-shortlisted-no-${K}`,children:"No"})}),e.jsx(oe,{children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(up,{value:I.progress,status:I.status,showPercent:!0,"data-testid":`onboarding-all-apps-progress-bar-${K}`})})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-all-apps-date-${K}`,children:Qt(I.submissionDate)})})]},I.id))})]})}),P&&P.totalPages>1&&e.jsx("div",{className:"py-6 border-t border-slate-200 bg-white rounded-b-lg",children:e.jsx(mo,{children:e.jsxs(fo,{children:[e.jsx(pn,{children:e.jsx(po,{onClick:()=>R(I=>Math.max(1,I-1)),className:O===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(P.totalPages)].map((I,K)=>{const G=K+1;return G===1||G===P.totalPages||G>=O-1&&G<=O+1?e.jsx(pn,{children:e.jsx($i,{isActive:O===G,onClick:()=>R(G),className:"cursor-pointer",children:G})},G):G===O-2||G===O+2?e.jsx(pn,{children:e.jsx(go,{})},G):null}),e.jsx(pn,{children:e.jsx(xo,{onClick:()=>R(I=>Math.min(P.totalPages,I+1)),className:O===P.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})}),e.jsx(ms,{open:N,onOpenChange:v,children:e.jsxs(us,{"data-testid":"onboarding-all-apps-shortlist-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{"data-testid":"onboarding-all-apps-shortlist-title",children:"Shortlist Applications"}),e.jsxs(ws,{"data-testid":"onboarding-all-apps-shortlist-desc",children:["You are about to shortlist ",x.length," application(s). These applications will be moved to the Dealership Requests page."]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{htmlFor:"shortlist-remark",children:"Shortlisting Remark (Optional)"}),e.jsx(Ks,{id:"shortlist-remark",placeholder:"Enter reason for shortlisting these applications...",value:w,onChange:I=>j(I.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-all-apps-shortlist-remark"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>v(!1),"data-testid":"onboarding-all-apps-shortlist-cancel",children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-green-600 hover:bg-green-700",onClick:z,"data-testid":"onboarding-all-apps-shortlist-confirm",children:"Confirm Shortlist"})]})]})]})})]})}function Dq(t){const s=Rq(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find(_q);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function Rq(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=Pq(a),d=Tq(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Hr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var Eq=Symbol("radix.slottable");function _q(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Eq}function Tq(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function 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 hp="Popover",[VE]=oa(hp,[lo]),sh=lo(),[Oq,vo]=VE(hp),HE=t=>{const{__scopePopover:s,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!1}=t,d=sh(s),m=g.useRef(null),[f,p]=g.useState(!1),[h,x]=Li({prop:r,defaultProp:a??!1,onChange:i,caller:hp});return e.jsx(Vf,{...d,children:e.jsx(Oq,{scope:s,contentId:yr(),triggerRef:m,open:h,onOpenChange:x,onOpenToggle:g.useCallback(()=>x(u=>!u),[x]),hasCustomAnchor:f,onCustomAnchorAdd:g.useCallback(()=>p(!0),[]),onCustomAnchorRemove:g.useCallback(()=>p(!1),[]),modal:o,children:n})})};HE.displayName=hp;var WE="PopoverAnchor",Lq=g.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=vo(WE,n),i=sh(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:d}=a;return g.useEffect(()=>(o(),()=>d()),[o,d]),e.jsx(Qu,{...i,...r,ref:s})});Lq.displayName=WE;var GE="PopoverTrigger",KE=g.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=vo(GE,n),i=sh(n),o=Ys(s,a.triggerRef),d=e.jsx(Ss.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":JE(a.open),...r,ref:o,onClick:Yt(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?d:e.jsx(Qu,{asChild:!0,...i,children:d})});KE.displayName=GE;var Jb="PopoverPortal",[Iq,Mq]=VE(Jb,{forceMount:void 0}),YE=t=>{const{__scopePopover:s,forceMount:n,children:r,container:a}=t,i=vo(Jb,s);return e.jsx(Iq,{scope:s,forceMount:n,children:e.jsx(jr,{present:n||i.open,children:e.jsx(Nd,{asChild:!0,container:a,children:r})})})};YE.displayName=Jb;var hd="PopoverContent",ZE=g.forwardRef((t,s)=>{const n=Mq(hd,t.__scopePopover),{forceMount:r=n.forceMount,...a}=t,i=vo(hd,t.__scopePopover);return e.jsx(jr,{present:r||i.open,children:i.modal?e.jsx(Bq,{...a,ref:s}):e.jsx($q,{...a,ref:s})})});ZE.displayName=hd;var Fq=Dq("PopoverContent.RemoveScroll"),Bq=g.forwardRef((t,s)=>{const n=vo(hd,t.__scopePopover),r=g.useRef(null),a=Ys(s,r),i=g.useRef(!1);return g.useEffect(()=>{const o=r.current;if(o)return Kf(o)},[]),e.jsx(Ju,{as:Fq,allowPinchZoom:!0,children:e.jsx(QE,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Yt(t.onCloseAutoFocus,o=>{var d;o.preventDefault(),i.current||(d=n.triggerRef.current)==null||d.focus()}),onPointerDownOutside:Yt(t.onPointerDownOutside,o=>{const d=o.detail.originalEvent,m=d.button===0&&d.ctrlKey===!0,f=d.button===2||m;i.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:Yt(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),$q=g.forwardRef((t,s)=>{const n=vo(hd,t.__scopePopover),r=g.useRef(!1),a=g.useRef(!1);return e.jsx(QE,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,d;(o=t.onCloseAutoFocus)==null||o.call(t,i),i.defaultPrevented||(r.current||(d=n.triggerRef.current)==null||d.focus(),i.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:i=>{var m,f;(m=t.onInteractOutside)==null||m.call(t,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((f=n.triggerRef.current)==null?void 0:f.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),QE=g.forwardRef((t,s)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:f,onInteractOutside:p,...h}=t,x=vo(hd,n),u=sh(n);return Bf(),e.jsx(Yu,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:e.jsx(yd,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:p,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:f,onDismiss:()=>x.onOpenChange(!1),children:e.jsx(Hf,{"data-state":JE(x.open),role:"dialog",id:x.contentId,...u,...h,ref:s,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),XE="PopoverClose",qq=g.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=vo(XE,n);return e.jsx(Ss.button,{type:"button",...r,ref:s,onClick:Yt(t.onClick,()=>a.onOpenChange(!1))})});qq.displayName=XE;var zq="PopoverArrow",Uq=g.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=sh(n);return e.jsx(Wf,{...a,...r,ref:s})});Uq.displayName=zq;function JE(t){return t?"open":"closed"}var Vq=HE,Hq=KE,Wq=YE,Gq=ZE;function _u({...t}){return e.jsx(Vq,{"data-slot":"popover",...t})}function Tu({...t}){return e.jsx(Hq,{"data-slot":"popover-trigger",...t})}function Pu({className:t,align:s="center",sideOffset:n=4,...r}){return e.jsx(Wq,{children:e.jsx(Gq,{"data-slot":"popover-content",align:s,sideOffset:n,className:Nt("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...r})})}var qs=function(){return qs=Object.assign||function(s){for(var n,r=1,a=arguments.length;r1&&(m||!f),h=s>1&&(f||!m),x=function(){r&&i(r)},u=function(){a&&i(a)};return e.jsx(Az,{displayMonth:t.displayMonth,hideNext:p,hidePrevious:h,nextMonth:a,previousMonth:r,onPreviousClick:x,onNextClick:u})}function kz(t){var s,n=An(),r=n.classNames,a=n.disableNavigation,i=n.styles,o=n.captionLayout,d=n.components,m=(s=d==null?void 0:d.CaptionLabel)!==null&&s!==void 0?s:s_,f;return a?f=e.jsx(m,{id:t.id,displayMonth:t.displayMonth}):o==="dropdown"?f=e.jsx(wS,{displayMonth:t.displayMonth,id:t.id}):o==="dropdown-buttons"?f=e.jsxs(e.Fragment,{children:[e.jsx(wS,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(SS,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id})]}):f=e.jsxs(e.Fragment,{children:[e.jsx(m,{id:t.id,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(SS,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:r.caption,style:i.caption,children:f})}function Dz(t){var s=An(),n=s.footer,r=s.styles,a=s.classNames.tfoot;return n?e.jsx("tfoot",{className:a,style:r.tfoot,children:e.jsx("tr",{children:e.jsx("td",{colSpan:8,children:n})})}):e.jsx(e.Fragment,{})}function Rz(t,s,n){for(var r=n?rc(new Date):Mi(new Date,{locale:t,weekStartsOn:s}),a=[],i=0;i<7;i++){var o=Ur(r,i);a.push(o)}return a}function Ez(){var t=An(),s=t.classNames,n=t.styles,r=t.showWeekNumber,a=t.locale,i=t.weekStartsOn,o=t.ISOWeek,d=t.formatters.formatWeekdayName,m=t.labels.labelWeekday,f=Rz(a,i,o);return e.jsxs("tr",{style:n.head_row,className:s.head_row,children:[r&&e.jsx("td",{style:n.head_cell,className:s.head_cell}),f.map(function(p,h){return e.jsx("th",{scope:"col",className:s.head_cell,style:n.head_cell,"aria-label":m(p,{locale:a}),children:d(p,{locale:a})},h)})]})}function _z(){var t,s=An(),n=s.classNames,r=s.styles,a=s.components,i=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:Ez;return e.jsx("thead",{style:r.head,className:n.head,children:e.jsx(i,{})})}function Tz(t){var s=An(),n=s.locale,r=s.formatters.formatDay;return e.jsx(e.Fragment,{children:r(t.date,{locale:n})})}var ej=g.createContext(void 0);function Pz(t){if(!nh(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(ej.Provider,{value:s,children:t.children})}return e.jsx(Oz,{initialProps:t.initialProps,children:t.children})}function Oz(t){var s=t.initialProps,n=t.children,r=s.selected,a=s.min,i=s.max,o=function(f,p,h){var x,u;(x=s.onDayClick)===null||x===void 0||x.call(s,f,p,h);var N=!!(p.selected&&a&&(r==null?void 0:r.length)===a);if(!N){var v=!!(!p.selected&&i&&(r==null?void 0:r.length)===i);if(!v){var w=r?e_([],r):[];if(p.selected){var j=w.findIndex(function(b){return na(f,b)});w.splice(j,1)}else w.push(f);(u=s.onSelect)===null||u===void 0||u.call(s,w,f,p,h)}}},d={disabled:[]};r&&d.disabled.push(function(f){var p=i&&r.length>i-1,h=r.some(function(x){return na(x,f)});return!!(p&&!h)});var m={selected:r,onDayClick:o,modifiers:d};return e.jsx(ej.Provider,{value:m,children:n})}function tj(){var t=g.useContext(ej);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function Lz(t,s){var n=s||{},r=n.from,a=n.to;return r&&a?na(a,t)&&na(r,t)?void 0:na(a,t)?{from:a,to:void 0}:na(r,t)?void 0:jy(r,t)?{from:t,to:a}:{from:r,to:t}:a?jy(t,a)?{from:a,to:t}:{from:t,to:a}:r?aR(t,r)?{from:t,to:r}:{from:r,to:t}:{from:t,to:void 0}}var sj=g.createContext(void 0);function Iz(t){if(!rh(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(sj.Provider,{value:s,children:t.children})}return e.jsx(Mz,{initialProps:t.initialProps,children:t.children})}function Mz(t){var s=t.initialProps,n=t.children,r=s.selected,a=r||{},i=a.from,o=a.to,d=s.min,m=s.max,f=function(u,N,v){var w,j;(w=s.onDayClick)===null||w===void 0||w.call(s,u,N,v);var b=Lz(u,r);(j=s.onSelect)===null||j===void 0||j.call(s,b,u,N,v)},p={range_start:[],range_end:[],range_middle:[],disabled:[]};if(i?(p.range_start=[i],o?(p.range_end=[o],na(i,o)||(p.range_middle=[{after:i,before:o}])):p.range_end=[i]):o&&(p.range_start=[o],p.range_end=[o]),d&&(i&&!o&&p.disabled.push({after:Pg(i,d-1),before:Ur(i,d-1)}),i&&o&&p.disabled.push({after:i,before:Ur(i,d-1)}),!i&&o&&p.disabled.push({after:Pg(o,d-1),before:Ur(o,d-1)})),m){if(i&&!o&&(p.disabled.push({before:Ur(i,-m+1)}),p.disabled.push({after:Ur(i,m-1)})),i&&o){var h=Ti(o,i)+1,x=m-h;p.disabled.push({before:Pg(i,x)}),p.disabled.push({after:Ur(o,x)})}!i&&o&&(p.disabled.push({before:Ur(o,-m+1)}),p.disabled.push({after:Ur(o,m-1)}))}return e.jsx(sj.Provider,{value:{selected:r,onDayClick:f,modifiers:p},children:n})}function nj(){var t=g.useContext(sj);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function Hm(t){return Array.isArray(t)?e_([],t):t!==void 0?[t]:[]}function Fz(t){var s={};return Object.entries(t).forEach(function(n){var r=n[0],a=n[1];s[r]=Hm(a)}),s}var ui;(function(t){t.Outside="outside",t.Disabled="disabled",t.Selected="selected",t.Hidden="hidden",t.Today="today",t.RangeStart="range_start",t.RangeEnd="range_end",t.RangeMiddle="range_middle"})(ui||(ui={}));var Bz=ui.Selected,sl=ui.Disabled,$z=ui.Hidden,qz=ui.Today,Fg=ui.RangeEnd,Bg=ui.RangeMiddle,$g=ui.RangeStart,zz=ui.Outside;function Uz(t,s,n){var r,a=(r={},r[Bz]=Hm(t.selected),r[sl]=Hm(t.disabled),r[$z]=Hm(t.hidden),r[qz]=[t.today],r[Fg]=[],r[Bg]=[],r[$g]=[],r[zz]=[],r);return t.fromDate&&a[sl].push({before:t.fromDate}),t.toDate&&a[sl].push({after:t.toDate}),nh(t)?a[sl]=a[sl].concat(s.modifiers[sl]):rh(t)&&(a[sl]=a[sl].concat(n.modifiers[sl]),a[$g]=n.modifiers[$g],a[Bg]=n.modifiers[Bg],a[Fg]=n.modifiers[Fg]),a}var a_=g.createContext(void 0);function Vz(t){var s=An(),n=tj(),r=nj(),a=Uz(s,n,r),i=Fz(s.modifiers),o=qs(qs({},a),i);return e.jsx(a_.Provider,{value:o,children:t.children})}function i_(){var t=g.useContext(a_);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function Hz(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function Wz(t){return!!(t&&typeof t=="object"&&"from"in t)}function Gz(t){return!!(t&&typeof t=="object"&&"after"in t)}function Kz(t){return!!(t&&typeof t=="object"&&"before"in t)}function Yz(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function Zz(t,s){var n,r=s.from,a=s.to;if(r&&a){var i=Ti(a,r)<0;i&&(n=[a,r],r=n[0],a=n[1]);var o=Ti(t,r)>=0&&Ti(a,t)>=0;return o}return a?na(a,t):r?na(r,t):!1}function Qz(t){return Rb(t)}function Xz(t){return Array.isArray(t)&&t.every(Rb)}function Jz(t,s){return s.some(function(n){if(typeof n=="boolean")return n;if(Qz(n))return na(t,n);if(Xz(n))return n.includes(t);if(Wz(n))return Zz(t,n);if(Yz(n))return n.dayOfWeek.includes(t.getDay());if(Hz(n)){var r=Ti(n.before,t),a=Ti(n.after,t),i=r>0,o=a<0,d=jy(n.before,n.after);return d?o&&i:i||o}return Gz(n)?Ti(t,n.after)>0:Kz(n)?Ti(n.before,t)>0:typeof n=="function"?n(t):!1})}function rj(t,s,n){var r=Object.keys(s).reduce(function(i,o){var d=s[o];return Jz(t,d)&&i.push(o),i},[]),a={};return r.forEach(function(i){return a[i]=!0}),n&&!Tb(t,n)&&(a.outside=!0),a}function eU(t,s){for(var n=ia(t[0]),r=tp(t[t.length-1]),a,i,o=n;o<=r;){var d=rj(o,s),m=!d.disabled&&!d.hidden;if(!m){o=Ur(o,1);continue}if(d.selected)return o;d.today&&!i&&(i=o),a||(a=o),o=Ur(o,1)}return i||a}var tU=365;function l_(t,s){var n=s.moveBy,r=s.direction,a=s.context,i=s.modifiers,o=s.retry,d=o===void 0?{count:0,lastFocused:t}:o,m=a.weekStartsOn,f=a.fromDate,p=a.toDate,h=a.locale,x={day:Ur,week:by,month:di,year:WB,startOfWeek:function(w){return a.ISOWeek?rc(w):Mi(w,{locale:h,weekStartsOn:m})},endOfWeek:function(w){return a.ISOWeek?JD(w):Eb(w,{locale:h,weekStartsOn:m})}},u=x[n](t,r==="after"?1:-1);r==="before"&&f?u=GB([f,u]):r==="after"&&p&&(u=KB([p,u]));var N=!0;if(i){var v=rj(u,i);N=!v.disabled&&!v.hidden}return N?u:d.count>tU?d.lastFocused:l_(u,{moveBy:n,direction:r,context:a,modifiers:i,retry:qs(qs({},d),{count:d.count+1})})}var o_=g.createContext(void 0);function sU(t){var s=ah(),n=i_(),r=g.useState(),a=r[0],i=r[1],o=g.useState(),d=o[0],m=o[1],f=eU(s.displayMonths,n),p=a??(d&&s.isDateDisplayed(d))?d:f,h=function(){m(a),i(void 0)},x=function(w){i(w)},u=An(),N=function(w,j){if(a){var b=l_(a,{moveBy:w,direction:j,context:u,modifiers:n});na(a,b)||(s.goToDate(b,a),x(b))}},v={focusedDay:a,focusTarget:p,blur:h,focus:x,focusDayAfter:function(){return N("day","after")},focusDayBefore:function(){return N("day","before")},focusWeekAfter:function(){return N("week","after")},focusWeekBefore:function(){return N("week","before")},focusMonthBefore:function(){return N("month","before")},focusMonthAfter:function(){return N("month","after")},focusYearBefore:function(){return N("year","before")},focusYearAfter:function(){return N("year","after")},focusStartOfWeek:function(){return N("startOfWeek","before")},focusEndOfWeek:function(){return N("endOfWeek","after")}};return e.jsx(o_.Provider,{value:v,children:t.children})}function aj(){var t=g.useContext(o_);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function nU(t,s){var n=i_(),r=rj(t,n,s);return r}var ij=g.createContext(void 0);function rU(t){if(!mp(t.initialProps)){var s={selected:void 0};return e.jsx(ij.Provider,{value:s,children:t.children})}return e.jsx(aU,{initialProps:t.initialProps,children:t.children})}function aU(t){var s=t.initialProps,n=t.children,r=function(i,o,d){var m,f,p;if((m=s.onDayClick)===null||m===void 0||m.call(s,i,o,d),o.selected&&!s.required){(f=s.onSelect)===null||f===void 0||f.call(s,void 0,i,o,d);return}(p=s.onSelect)===null||p===void 0||p.call(s,i,i,o,d)},a={selected:s.selected,onDayClick:r};return e.jsx(ij.Provider,{value:a,children:n})}function c_(){var t=g.useContext(ij);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function iU(t,s){var n=An(),r=c_(),a=tj(),i=nj(),o=aj(),d=o.focusDayAfter,m=o.focusDayBefore,f=o.focusWeekAfter,p=o.focusWeekBefore,h=o.blur,x=o.focus,u=o.focusMonthBefore,N=o.focusMonthAfter,v=o.focusYearBefore,w=o.focusYearAfter,j=o.focusStartOfWeek,b=o.focusEndOfWeek,C=function(W){var U,M,z,T;mp(n)?(U=r.onDayClick)===null||U===void 0||U.call(r,t,s,W):nh(n)?(M=a.onDayClick)===null||M===void 0||M.call(a,t,s,W):rh(n)?(z=i.onDayClick)===null||z===void 0||z.call(i,t,s,W):(T=n.onDayClick)===null||T===void 0||T.call(n,t,s,W)},S=function(W){var U;x(t),(U=n.onDayFocus)===null||U===void 0||U.call(n,t,s,W)},D=function(W){var U;h(),(U=n.onDayBlur)===null||U===void 0||U.call(n,t,s,W)},_=function(W){var U;(U=n.onDayMouseEnter)===null||U===void 0||U.call(n,t,s,W)},A=function(W){var U;(U=n.onDayMouseLeave)===null||U===void 0||U.call(n,t,s,W)},E=function(W){var U;(U=n.onDayPointerEnter)===null||U===void 0||U.call(n,t,s,W)},q=function(W){var U;(U=n.onDayPointerLeave)===null||U===void 0||U.call(n,t,s,W)},O=function(W){var U;(U=n.onDayTouchCancel)===null||U===void 0||U.call(n,t,s,W)},R=function(W){var U;(U=n.onDayTouchEnd)===null||U===void 0||U.call(n,t,s,W)},P=function(W){var U;(U=n.onDayTouchMove)===null||U===void 0||U.call(n,t,s,W)},L=function(W){var U;(U=n.onDayTouchStart)===null||U===void 0||U.call(n,t,s,W)},$=function(W){var U;(U=n.onDayKeyUp)===null||U===void 0||U.call(n,t,s,W)},Z=function(W){var U;switch(W.key){case"ArrowLeft":W.preventDefault(),W.stopPropagation(),n.dir==="rtl"?d():m();break;case"ArrowRight":W.preventDefault(),W.stopPropagation(),n.dir==="rtl"?m():d();break;case"ArrowDown":W.preventDefault(),W.stopPropagation(),f();break;case"ArrowUp":W.preventDefault(),W.stopPropagation(),p();break;case"PageUp":W.preventDefault(),W.stopPropagation(),W.shiftKey?v():u();break;case"PageDown":W.preventDefault(),W.stopPropagation(),W.shiftKey?w():N();break;case"Home":W.preventDefault(),W.stopPropagation(),j();break;case"End":W.preventDefault(),W.stopPropagation(),b();break}(U=n.onDayKeyDown)===null||U===void 0||U.call(n,t,s,W)},Q={onClick:C,onFocus:S,onBlur:D,onKeyDown:Z,onKeyUp:$,onMouseEnter:_,onMouseLeave:A,onPointerEnter:E,onPointerLeave:q,onTouchCancel:O,onTouchEnd:R,onTouchMove:P,onTouchStart:L};return Q}function lU(){var t=An(),s=c_(),n=tj(),r=nj(),a=mp(t)?s.selected:nh(t)?n.selected:rh(t)?r.selected:void 0;return a}function oU(t){return Object.values(ui).includes(t)}function cU(t,s){var n=[t.classNames.day];return Object.keys(s).forEach(function(r){var a=t.modifiersClassNames[r];if(a)n.push(a);else if(oU(r)){var i=t.classNames["day_".concat(r)];i&&n.push(i)}}),n}function dU(t,s){var n=qs({},t.styles.day);return Object.keys(s).forEach(function(r){var a;n=qs(qs({},n),(a=t.modifiersStyles)===null||a===void 0?void 0:a[r])}),n}function uU(t,s,n){var r,a,i,o=An(),d=aj(),m=nU(t,s),f=iU(t,m),p=lU(),h=!!(o.onDayClick||o.mode!=="default");g.useEffect(function(){var _;m.outside||d.focusedDay&&h&&na(d.focusedDay,t)&&((_=n.current)===null||_===void 0||_.focus())},[d.focusedDay,t,n,h,m.outside]);var x=cU(o,m).join(" "),u=dU(o,m),N=!!(m.outside&&!o.showOutsideDays||m.hidden),v=(i=(a=o.components)===null||a===void 0?void 0:a.DayContent)!==null&&i!==void 0?i:Tz,w=e.jsx(v,{date:t,displayMonth:s,activeModifiers:m}),j={style:u,className:x,children:w,role:"gridcell"},b=d.focusTarget&&na(d.focusTarget,t)&&!m.outside,C=d.focusedDay&&na(d.focusedDay,t),S=qs(qs(qs({},j),(r={disabled:m.disabled,role:"gridcell"},r["aria-selected"]=m.selected,r.tabIndex=C||b?0:-1,r)),f),D={isButton:h,isHidden:N,activeModifiers:m,selectedDays:p,buttonProps:S,divProps:j};return D}function hU(t){var s=g.useRef(null),n=uU(t.date,t.displayMonth,s);return n.isHidden?e.jsx("div",{role:"gridcell"}):n.isButton?e.jsx(vf,qs({name:"day",ref:s},n.buttonProps)):e.jsx("div",qs({},n.divProps))}function mU(t){var s=t.number,n=t.dates,r=An(),a=r.onWeekNumberClick,i=r.styles,o=r.classNames,d=r.locale,m=r.labels.labelWeekNumber,f=r.formatters.formatWeekNumber,p=f(Number(s),{locale:d});if(!a)return e.jsx("span",{className:o.weeknumber,style:i.weeknumber,children:p});var h=m(Number(s),{locale:d}),x=function(u){a(s,n,u)};return e.jsx(vf,{name:"week-number","aria-label":h,className:o.weeknumber,style:i.weeknumber,onClick:x,children:p})}function fU(t){var s,n,r=An(),a=r.styles,i=r.classNames,o=r.showWeekNumber,d=r.components,m=(s=d==null?void 0:d.Day)!==null&&s!==void 0?s:hU,f=(n=d==null?void 0:d.WeekNumber)!==null&&n!==void 0?n:mU,p;return o&&(p=e.jsx("td",{className:i.cell,style:a.cell,children:e.jsx(f,{number:t.weekNumber,dates:t.dates})})),e.jsxs("tr",{className:i.row,style:a.row,children:[p,t.dates.map(function(h){return e.jsx("td",{className:i.cell,style:a.cell,role:"presentation",children:e.jsx(m,{displayMonth:t.displayMonth,date:h})},t7(h))})]})}function CS(t,s,n){for(var r=n!=null&&n.ISOWeek?JD(s):Eb(s,n),a=n!=null&&n.ISOWeek?rc(t):Mi(t,n),i=Ti(r,a),o=[],d=0;d<=i;d++)o.push(Ur(a,d));var m=o.reduce(function(f,p){var h=n!=null&&n.ISOWeek?eR(p):sR(p,n),x=f.find(function(u){return u.weekNumber===h});return x?(x.dates.push(p),f):(f.push({weekNumber:h,dates:[p]}),f)},[]);return m}function pU(t,s){var n=CS(ia(t),tp(t),s);if(s!=null&&s.useFixedWeeks){var r=n7(t,s);if(r<6){var a=n[n.length-1],i=a.dates[a.dates.length-1],o=by(i,6-r),d=CS(by(i,1),o,s);n.push.apply(n,d)}}return n}function xU(t){var s,n,r,a=An(),i=a.locale,o=a.classNames,d=a.styles,m=a.hideHead,f=a.fixedWeeks,p=a.components,h=a.weekStartsOn,x=a.firstWeekContainsDate,u=a.ISOWeek,N=pU(t.displayMonth,{useFixedWeeks:!!f,ISOWeek:u,locale:i,weekStartsOn:h,firstWeekContainsDate:x}),v=(s=p==null?void 0:p.Head)!==null&&s!==void 0?s:_z,w=(n=p==null?void 0:p.Row)!==null&&n!==void 0?n:fU,j=(r=p==null?void 0:p.Footer)!==null&&r!==void 0?r:Dz;return e.jsxs("table",{id:t.id,className:o.table,style:d.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!m&&e.jsx(v,{}),e.jsx("tbody",{className:o.tbody,style:d.tbody,children:N.map(function(b){return e.jsx(w,{displayMonth:t.displayMonth,dates:b.dates,weekNumber:b.weekNumber},b.weekNumber)})}),e.jsx(j,{displayMonth:t.displayMonth})]})}function gU(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var vU=gU()?g.useLayoutEffect:g.useEffect,qg=!1,yU=0;function AS(){return"react-day-picker-".concat(++yU)}function bU(t){var s,n=t??(qg?AS():null),r=g.useState(n),a=r[0],i=r[1];return vU(function(){a===null&&i(AS())},[]),g.useEffect(function(){qg===!1&&(qg=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function jU(t){var s,n,r=An(),a=r.dir,i=r.classNames,o=r.styles,d=r.components,m=ah().displayMonths,f=bU(r.id?"".concat(r.id,"-").concat(t.displayIndex):void 0),p=r.id?"".concat(r.id,"-grid-").concat(t.displayIndex):void 0,h=[i.month],x=o.month,u=t.displayIndex===0,N=t.displayIndex===m.length-1,v=!u&&!N;a==="rtl"&&(s=[u,N],N=s[0],u=s[1]),u&&(h.push(i.caption_start),x=qs(qs({},x),o.caption_start)),N&&(h.push(i.caption_end),x=qs(qs({},x),o.caption_end)),v&&(h.push(i.caption_between),x=qs(qs({},x),o.caption_between));var w=(n=d==null?void 0:d.Caption)!==null&&n!==void 0?n:kz;return e.jsxs("div",{className:h.join(" "),style:x,children:[e.jsx(w,{id:f,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(xU,{id:p,"aria-labelledby":f,displayMonth:t.displayMonth})]},t.displayIndex)}function NU(t){var s=An(),n=s.classNames,r=s.styles;return e.jsx("div",{className:n.months,style:r.months,children:t.children})}function wU(t){var s,n,r=t.initialProps,a=An(),i=aj(),o=ah(),d=g.useState(!1),m=d[0],f=d[1];g.useEffect(function(){a.initialFocus&&i.focusTarget&&(m||(i.focus(i.focusTarget),f(!0)))},[a.initialFocus,m,i.focus,i.focusTarget,i]);var p=[a.classNames.root,a.className];a.numberOfMonths>1&&p.push(a.classNames.multiple_months),a.showWeekNumber&&p.push(a.classNames.with_weeknumber);var h=qs(qs({},a.styles.root),a.style),x=Object.keys(r).filter(function(N){return N.startsWith("data-")}).reduce(function(N,v){var w;return qs(qs({},N),(w={},w[v]=r[v],w))},{}),u=(n=(s=r.components)===null||s===void 0?void 0:s.Months)!==null&&n!==void 0?n:NU;return e.jsx("div",qs({className:p.join(" "),style:h,dir:a.dir,id:a.id,nonce:r.nonce,title:r.title,lang:r.lang},x,{children:e.jsx(u,{children:o.displayMonths.map(function(N,v){return e.jsx(jU,{displayIndex:v,displayMonth:N},v)})})}))}function SU(t){var s=t.children,n=Kq(t,["children"]);return e.jsx(mz,{initialProps:n,children:e.jsx(wz,{children:e.jsx(rU,{initialProps:n,children:e.jsx(Pz,{initialProps:n,children:e.jsx(Iz,{initialProps:n,children:e.jsx(Vz,{children:e.jsx(sU,{children:s})})})})})})})}function CU(t){return e.jsx(SU,qs({},t,{children:e.jsx(wU,{initialProps:t})}))}function yf({className:t,classNames:s,showOutsideDays:n=!0,...r}){return e.jsx(CU,{showOutsideDays:n,className:Nt("p-3",t),classNames:{months:"flex flex-col sm:flex-row gap-2",month:"flex flex-col gap-4",caption:"flex justify-center pt-1 relative items-center w-full",caption_label:"text-sm font-medium",nav:"flex items-center gap-1",nav_button:Nt(nd({variant:"outline"}),"size-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-x-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:Nt("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md",r.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:Nt(nd({variant:"ghost"}),"size-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground",day_range_end:"day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...s},components:{IconLeft:({className:a,...i})=>e.jsx(io,{className:Nt("size-4",a),...i}),IconRight:({className:a,...i})=>e.jsx(mi,{className:Nt("size-4",a),...i})},...r})}function AU({onViewDetails:t}){const[s,n]=g.useState("table"),[r,a]=g.useState(""),[i,o]=g.useState("all"),[d,m]=g.useState("all"),[f,p]=g.useState("all"),[h,x]=g.useState(""),[u,N]=g.useState(""),[v,w]=g.useState("date-desc"),[j,b]=g.useState(1),[C,S]=g.useState(null),[D,_]=g.useState([]),[A,E]=g.useState(!1),[q,O]=g.useState(!1),[R,P]=g.useState(""),[L,$]=g.useState([]),[Z,Q]=g.useState([]),[W,U]=g.useState([]),[M,z]=g.useState(!0);g.useEffect(()=>{F()},[h,u,i,r,j,d,f]),g.useEffect(()=>{b(1)},[h,u,i,r,d,f]),g.useEffect(()=>{T()},[]);const T=async()=>{try{const ce=await $s.getStates(),Me=(Array.isArray(ce)?ce:(ce==null?void 0:ce.data)||(ce==null?void 0:ce.states)||[]).map(ut=>typeof ut=="string"?ut:ut.name||ut.stateName).filter(Boolean);$(Me)}catch(ce){console.error("Failed to fetch states:",ce)}},F=async()=>{try{z(!0);const ce=["Questionnaire Pending","Questionnaire Completed","Shortlisted"],je=await ps.getApplications({fromDate:h,toDate:u,status:i==="all"?ce.join(","):i,location:d!=="all"?d:void 0,state:f!=="all"?f:void 0,ddLeadShortlisted:"false",isShortlisted:"true",search:r,page:j,limit:10}),Me=je.data||[];S(je.meta);const ut=Me.map(X=>({id:X.id,registrationNumber:X.applicationId||"N/A",name:X.applicantName,email:X.email,phone:X.phone,age:X.age,education:X.education,residentialAddress:X.address||X.city||"",businessAddress:X.address||"",preferredLocation:X.preferredLocation,state:X.state,ownsBike:X.ownRoyalEnfield==="yes",pastExperience:X.experienceYears?`${X.experienceYears} years`:X.description||"",status:X.overallStatus,questionnaireMarks:X.score||X.questionnaireMarks||0,rank:0,totalApplicantsAtLocation:0,submissionDate:X.createdAt,assignedUsers:[],progress:X.progressPercentage||0,isShortlisted:X.isShortlisted,ddLeadShortlisted:X.ddLeadShortlisted,companyName:X.companyName,source:X.source,existingDealer:X.existingDealer,royalEnfieldModel:X.royalEnfieldModel,description:X.description,pincode:X.pincode,locationType:X.locationType,ownRoyalEnfield:X.ownRoyalEnfield,address:X.address}));U(ut);const jt=Array.from(new Set(ut.map(X=>X.preferredLocation))).filter(Boolean);Q(X=>Array.from(new Set([...X,...jt])));const ft=Array.from(new Set(ut.map(X=>X.state))).filter(Boolean);$(X=>Array.from(new Set([...X,...ft])))}catch(ce){console.error("Failed to fetch applications:",ce),J.error("Failed to load opportunity requests")}finally{z(!1)}},I=W.sort((ce,je)=>v==="score-desc"?(je.questionnaireMarks||0)-(ce.questionnaireMarks||0):v==="score-asc"?(ce.questionnaireMarks||0)-(je.questionnaireMarks||0):v==="date-desc"?new Date(je.submissionDate).getTime()-new Date(ce.submissionDate).getTime():v==="date-asc"?new Date(ce.submissionDate).getTime()-new Date(je.submissionDate).getTime():0),K=ce=>{_(ce?I.map(je=>je.id):[])},G=(ce,je)=>{_(je?[...D,ce]:D.filter(Me=>Me!==ce))},V=()=>{if(D.length===0){J.error("Please select at least one application to shortlist");return}O(!0)},Y=async()=>{try{const ce=await ps.shortlistApplications(D,[],R);if(ce&&ce.success)await F(),_([]),O(!1),P(""),J.success(`${D.length} application(s) shortlisted successfully. Users will be assigned automatically.`);else throw new Error((ce==null?void 0:ce.message)||"Failed to process shortlisting")}catch(ce){console.error("Failed to shortlist applications:",ce),J.error(ce.message||"Failed to process shortlisting")}},re=async()=>{if(D.length===0){J.error("Please select at least one application");return}try{E(!0);const ce=await ps.sendBulkReminders(D);ce.success&&(J.success(ce.message||`Reminder emails sent to ${D.length} applicant(s)`),_([]))}catch(ce){console.error("Failed to send reminders:",ce),J.error(ce.message||"Failed to send reminders")}finally{E(!1)}},ae=async()=>{const ce=I.filter(ut=>ut.status!=="Questionnaire Pending"),je=ce.filter(ut=>D.includes(ut.id));let Me=[];if(D.length>0){if(je.length===0){J.error('Selected applications are in "Questionnaire Pending" status and cannot be exported.');return}Me=je.map(ut=>ut.id),je.lengthut.id);if(Me.length===0){J.error("No applications with completed questionnaires available for export");return}try{const ut=J.loading("Preparing Excel export..."),jt=await ps.exportResponses(Me);if(J.dismiss(ut),!jt||jt.length===0){J.error("No response data found");return}const ft=Object.keys(jt[0]),Ce=[ft.join(","),...jt.map(rt=>ft.map(ht=>{const ge=rt[ht]??"";return`"${String(ge).replace(/"/g,'""')}"`}).join(","))].join(` `),xe=new Blob([Ce],{type:"text/csv;charset=utf-8;"}),We=URL.createObjectURL(xe),Be=document.createElement("a");Be.setAttribute("href",We),Be.setAttribute("download",`onboarding_responses_${new Date().toISOString().split("T")[0]}.xlsx`),document.body.appendChild(Be),Be.click(),document.body.removeChild(Be),J.success(`Exported ${Me.length} records to Excel successfully`)}catch(ut){console.error("Export failed:",ut),J.error(ut.message||"Failed to export responses")}},ue=["Questionnaire Pending","Questionnaire Completed","Shortlisted"],ye=ce=>({Submitted:"bg-blue-100 text-blue-800","Questionnaire Pending":"bg-yellow-100 text-yellow-800","Questionnaire Completed":"bg-cyan-100 text-cyan-800",Shortlisted:"bg-purple-100 text-purple-800","Level 1 Interview Pending":"bg-orange-100 text-orange-800","Level 1 Approved":"bg-green-100 text-green-800","Level 2 Interview Pending":"bg-orange-100 text-orange-800","Level 2 Approved":"bg-green-100 text-green-800","Level 2 Recommended":"bg-teal-100 text-teal-800","Level 3 Interview Pending":"bg-orange-100 text-orange-800","FDD Verification":"bg-indigo-100 text-indigo-800","Payment Pending":"bg-red-50 text-red-800","LOI Issued":"bg-sky-100 text-sky-800","Dealer Code Generation":"bg-purple-100 text-purple-800","Architecture Team Assigned":"bg-blue-100 text-blue-800","Architecture Document Upload":"bg-blue-100 text-blue-800","Architecture Team Completion":"bg-blue-100 text-blue-800","Statutory GST":"bg-emerald-100 text-emerald-800","Statutory PAN":"bg-emerald-100 text-emerald-800","Statutory Nodal":"bg-emerald-100 text-emerald-800","Statutory Check":"bg-emerald-100 text-emerald-800","Statutory Partnership":"bg-emerald-100 text-emerald-800","Statutory Firm Reg":"bg-emerald-100 text-emerald-800","Statutory Rental":"bg-emerald-100 text-emerald-800","Statutory Virtual Code":"bg-emerald-100 text-emerald-800","Statutory Domain":"bg-emerald-100 text-emerald-800","Statutory MSD":"bg-emerald-100 text-emerald-800","Statutory LOI Ack":"bg-emerald-100 text-emerald-800","EOR In Progress":"bg-violet-100 text-violet-800","LOA Pending":"bg-pink-100 text-pink-800",Inauguration:"bg-green-100 text-green-800",Approved:"bg-green-100 text-green-800",Rejected:"bg-red-100 text-red-800",Disqualified:"bg-gray-100 text-gray-800","In Review":"bg-slate-100 text-slate-800","Level 3 Approved":"bg-green-100 text-green-800","LOI In Progress":"bg-sky-50 text-sky-700","LOI Approved":"bg-green-100 text-green-800","Security Deposit In Progress":"bg-blue-50 text-blue-700","Security Deposit Approved":"bg-green-100 text-green-800","Security Deposit":"bg-blue-100 text-blue-800","Security Details In Progress":"bg-blue-50 text-blue-700","Security Details Approved":"bg-green-100 text-green-800","Security Details":"bg-blue-100 text-blue-800","LOI Issued In Progress":"bg-sky-50 text-sky-700","Statutory Work In Progress":"bg-emerald-50 text-emerald-700","Statutory Work Completed":"bg-green-100 text-green-800","Architecture Work In Progress":"bg-blue-50 text-blue-700","Architecture Work Completed":"bg-green-100 text-green-800","Dealer Code Generation In Progress":"bg-purple-50 text-purple-700","Dealer Code Generated":"bg-green-100 text-green-800","LOA Issued":"bg-pink-100 text-pink-800","EOR Complete":"bg-violet-100 text-violet-800",Onboarded:"bg-green-200 text-green-900"})[ce]||"bg-gray-100 text-gray-800";return M?e.jsx("div",{className:"flex justify-center items-center h-96",children:e.jsx(cs,{className:"w-8 h-8 animate-spin text-re-red"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-white rounded-lg border border-slate-200 p-6",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(it,{type:"text",placeholder:"Search by name or registration number...",value:r,onChange:ce=>a(ce.target.value),className:"pl-10","data-testid":"onboarding-opp-requests-search-input"})]}),e.jsxs(Rt,{value:i,onValueChange:o,children:[e.jsx(_t,{className:"w-full md:w-48","data-testid":"onboarding-opp-requests-status-select",children:e.jsx(Et,{placeholder:"Filter by status"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All Statuses"}),ue.map(ce=>e.jsx(Pe,{value:ce,children:ce},ce))]})]}),e.jsx(te,{variant:"ghost",size:"sm",className:"text-slate-500 hover:text-slate-700 h-9",onClick:()=>{x(""),N(""),o("all"),m("all"),p("all"),a("")},"data-testid":"onboarding-opp-requests-clear-filters",children:"Clear Filters"}),e.jsxs(Rt,{value:f,onValueChange:p,children:[e.jsx(_t,{className:"w-full md:w-48","data-testid":"onboarding-opp-requests-state-select",children:e.jsx(Et,{placeholder:"Filter by state"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All States"}),L.map(ce=>e.jsx(Pe,{value:ce,children:ce},ce))]})]}),e.jsxs(Rt,{value:d,onValueChange:m,children:[e.jsx(_t,{className:"w-full md:w-48","data-testid":"onboarding-opp-requests-location-select",children:e.jsx(Et,{placeholder:"Filter by location"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All Locations"}),Z.map(ce=>e.jsx(Pe,{value:ce,children:ce},ce))]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 md:flex-none",children:[e.jsxs(_u,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(te,{variant:"outline",className:Nt("w-full md:w-40 justify-start text-left font-normal h-9 px-3",!h&&"text-muted-foreground"),"data-testid":"onboarding-opp-requests-from-date-trigger",children:[e.jsx(er,{className:"mr-2 h-4 w-4 text-slate-400"}),h?za(new Date(h),"PPP"):e.jsx("span",{className:"text-xs",children:"From Date"})]})}),e.jsx(Pu,{className:"w-auto p-0",align:"start",children:e.jsx(yf,{mode:"single",selected:h?new Date(h):void 0,onSelect:ce=>x(ce?ce.toISOString().split("T")[0]:""),initialFocus:!0})})]}),e.jsx("span",{className:"text-slate-400",children:"to"}),e.jsxs(_u,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(te,{variant:"outline",className:Nt("w-full md:w-40 justify-start text-left font-normal h-9 px-3",!u&&"text-muted-foreground"),"data-testid":"onboarding-opp-requests-to-date-trigger",children:[e.jsx(er,{className:"mr-2 h-4 w-4 text-slate-400"}),u?za(new Date(u),"PPP"):e.jsx("span",{className:"text-xs",children:"To Date"})]})}),e.jsx(Pu,{className:"w-auto p-0",align:"start",children:e.jsx(yf,{mode:"single",selected:u?new Date(u):void 0,onSelect:ce=>N(ce?ce.toISOString().split("T")[0]:""),initialFocus:!0})})]})]}),e.jsxs(Rt,{value:v,onValueChange:w,children:[e.jsx(_t,{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(_I,{className:"w-4 h-4 text-slate-400"}),e.jsx(Et,{placeholder:"Sort by"})]})}),e.jsxs(Tt,{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(te,{variant:s==="grid"?"default":"outline",size:"sm",onClick:()=>n("grid"),className:s==="grid"?"bg-re-red hover:bg-re-red-hover":"","data-testid":"onboarding-opp-requests-view-grid-btn",children:[e.jsx(lk,{className:"w-4 h-4 mr-2"}),"Grid"]}),e.jsxs(te,{variant:s==="table"?"default":"outline",size:"sm",onClick:()=>n("table"),className:s==="table"?"bg-re-red hover:bg-re-red-hover":"","data-testid":"onboarding-opp-requests-view-table-btn",children:[e.jsx(dk,{className:"w-4 h-4 mr-2"}),"Table"]})]}),e.jsxs(te,{variant:"outline",size:"sm",onClick:ae,"data-testid":"onboarding-opp-requests-export-btn",children:[e.jsx(fi,{className:"w-4 h-4 mr-2"}),"Export"]}),D.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(te,{variant:"outline",size:"sm",onClick:re,disabled:A,"data-testid":"onboarding-opp-requests-bulk-reminder-btn",children:[A?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Gr,{className:"w-4 h-4 mr-2"}),"Send Reminders (",D.length,")"]}),e.jsxs(te,{size:"sm",onClick:V,className:"bg-green-600 hover:bg-green-700","data-testid":"onboarding-opp-requests-bulk-shortlist-btn",children:[e.jsx(ln,{className:"w-4 h-4 mr-2"}),"Shortlist (",D.length,")"]})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs(we,{variant:"outline",className:"text-slate-600","data-testid":"onboarding-opp-requests-pending-count",children:[(C==null?void 0:C.total)||I.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:[I.map((ce,je)=>e.jsxs("div",{className:"relative","data-testid":`onboarding-opp-requests-grid-item-${je}`,children:[e.jsx("div",{className:"absolute top-4 left-4 z-10",children:e.jsx(Tn,{checked:D.includes(ce.id),onCheckedChange:Me=>G(ce.id,Me),className:"bg-white","data-testid":`onboarding-opp-requests-grid-checkbox-${je}`})}),e.jsx(UE,{application:ce,onViewDetails:t})]},ce.id)),I.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(ln,{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(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{className:"w-12",children:e.jsx(Tn,{checked:D.length===I.length&&I.length>0,onCheckedChange:K,"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(Bs,{children:[I.map((ce,je)=>e.jsxs(lt,{className:"cursor-pointer hover:bg-slate-50",onClick:()=>t(ce.id),"data-testid":`onboarding-opp-requests-row-${je}`,children:[e.jsx(oe,{onClick:Me=>Me.stopPropagation(),children:e.jsx(Tn,{checked:D.includes(ce.id),onCheckedChange:Me=>G(ce.id,Me),"data-testid":`onboarding-opp-requests-table-select-item-${ce.id}`})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-opp-requests-reg-${je}`,children:ce.registrationNumber})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-opp-requests-name-${je}`,children:ce.name})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-opp-requests-pref-loc-${je}`,children:ce.preferredLocation})}),e.jsx(oe,{children:e.jsx(we,{className:ye(ce.status),"data-testid":`onboarding-opp-requests-status-${je}`,children:ce.status})}),e.jsx(oe,{children:e.jsx("span",{className:"font-semibold text-slate-900","data-testid":`onboarding-opp-requests-score-${je}`,children:ce.questionnaireMarks})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-opp-requests-app-loc-${je}`,children:ce.businessAddress})}),e.jsx(oe,{children:e.jsx(we,{variant:"outline","data-testid":`onboarding-opp-requests-shortlisted-badge-${je}`,children:"No"})}),e.jsx(oe,{children:e.jsx(up,{value:ce.progress,status:ce.status,showPercent:!0,"data-testid":`onboarding-opp-requests-progress-${je}`})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-opp-requests-date-${je}`,children:Qt(ce.submissionDate)})})]},ce.id)),I.length===0&&e.jsx(lt,{children:e.jsxs(oe,{colSpan:9,className:"text-center py-12 text-slate-500","data-testid":"onboarding-opp-requests-table-empty",children:[e.jsx(ln,{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(mo,{children:e.jsxs(fo,{children:[e.jsx(pn,{children:e.jsx(po,{onClick:()=>b(ce=>Math.max(1,ce-1)),className:j===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(C.totalPages)].map((ce,je)=>{const Me=je+1;return Me===1||Me===C.totalPages||Me>=j-1&&Me<=j+1?e.jsx(pn,{children:e.jsx($i,{isActive:j===Me,onClick:()=>b(Me),className:"cursor-pointer",children:Me})},Me):Me===j-2||Me===j+2?e.jsx(pn,{children:e.jsx(go,{})},Me):null}),e.jsx(pn,{children:e.jsx(xo,{onClick:()=>b(ce=>Math.min(C.totalPages,ce+1)),className:j===C.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]}),e.jsx(ms,{open:q,onOpenChange:O,children:e.jsxs(us,{className:"overflow-visible","data-testid":"onboarding-opp-requests-shortlist-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{"data-testid":"onboarding-opp-requests-shortlist-modal-title",children:"Shortlist Applications"}),e.jsxs(ws,{children:["You are about to shortlist ",D.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(le,{children:"Shortlisting Remark (Optional)"}),e.jsx(Ks,{placeholder:"Enter reason for shortlisting these applications...",value:R,onChange:ce=>P(ce.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-opp-requests-remark-textarea"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>{O(!1),P("")},"data-testid":"onboarding-opp-requests-shortlist-cancel-btn",children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-green-600 hover:bg-green-700",onClick:Y,"data-testid":"onboarding-opp-requests-shortlist-confirm-btn",children:"Confirm Shortlist"})]})]})]})})]})}function kU({onViewDetails:t}){var W,U;const[s,n]=g.useState(""),[r,a]=g.useState("all"),[i,o]=g.useState("all"),[d,m]=g.useState(""),[f,p]=g.useState(""),[h,x]=g.useState(1),[u,N]=g.useState(null),[v,w]=g.useState([]),[j,b]=g.useState(!0),[C,S]=g.useState([]),[D,_]=g.useState([]),[A,E]=g.useState([]),[q,O]=g.useState(!1),R=async()=>{var M,z,T,F;if(A.length!==0)try{O(!0);const I=await ps.bulkConvertToOpportunity({ids:A});I!=null&&I.success&&((((M=I.data)==null?void 0:M.success)>0||!I.data)&&J.success(I.message||`Successfully converted ${((z=I.data)==null?void 0:z.success)||A.length} leads.`),((T=I.data)==null?void 0:T.failed)>0&&((F=I.data)!=null&&F.errors)&&I.data.errors.forEach(K=>{J.error(K,{duration:5e3})}),E([]),await Z())}catch(I){console.error("Bulk conversion error:",I),J.error(I.message||"Failed to perform bulk conversion")}finally{O(!1)}},P=()=>{A.length===Q.length?E([]):E(Q.map(M=>M.id))},L=M=>{E(z=>z.includes(M)?z.filter(T=>T!==M):[...z,M])};g.useEffect(()=>{Z()},[d,f,s,h,r,i]),g.useEffect(()=>{x(1)},[d,f,s,r,i]),g.useEffect(()=>{$()},[]);const $=async()=>{try{const M=await $s.getStates(),T=(Array.isArray(M)?M:(M==null?void 0:M.data)||(M==null?void 0:M.states)||[]).map(F=>typeof F=="string"?F:F.name||F.stateName).filter(Boolean);S(T)}catch(M){console.error("Failed to fetch states:",M)}},Z=async()=>{try{b(!0);const M=await ps.getApplications({fromDate:d,toDate:f,search:s,status:"Submitted",isShortlisted:"false",location:r!=="all"?r:void 0,state:i!=="all"?i:void 0,page:h,limit:10}),z=M.data||[];N(M.meta);const T=z.map(K=>({id:K.id,registrationNumber:K.applicationId||"N/A",name:K.applicantName,email:K.email,phone:K.phone,age:K.age,education:K.education,residentialAddress:K.address||K.city||"",businessAddress:K.address||"",preferredLocation:K.preferredLocation,state:K.state,ownsBike:K.ownRoyalEnfield==="yes",pastExperience:K.experienceYears?`${K.experienceYears} years`:K.description||"",status:K.overallStatus,questionnaireMarks:K.score||K.questionnaireMarks||0,rank:0,totalApplicantsAtLocation:0,submissionDate:K.createdAt,assignedUsers:[],progress:K.progressPercentage||0,isShortlisted:K.isShortlisted,companyName:K.companyName,source:K.source,existingDealer:K.existingDealer,royalEnfieldModel:K.royalEnfieldModel,description:K.description,pincode:K.pincode,locationType:K.locationType,ownRoyalEnfield:K.ownRoyalEnfield,address:K.address}));w(T);const F=Array.from(new Set(T.map(K=>K.preferredLocation))).filter(Boolean);_(K=>Array.from(new Set([...K,...F])));const I=Array.from(new Set(T.map(K=>K.state))).filter(Boolean);S(K=>Array.from(new Set([...K,...I])))}catch(M){console.error("Failed to fetch applications:",M),J.error("Failed to load non-opportunity requests")}finally{b(!1)}},Q=v;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl mb-2",children:"Non-opportunities (Lead Generation)"}),e.jsx("p",{className:"text-slate-600",children:"Interest submissions from regions where dealerships are currently not being offered. These leads received non-opportunity notification and are stored for future reference."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx("div",{className:"bg-white rounded-lg border border-slate-200 p-4","data-testid":"onboarding-non-opps-stat-total",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Total Leads"}),e.jsx("p",{className:"text-2xl text-slate-900 mt-1",children:(u==null?void 0:u.total)||v.length})]}),e.jsx("div",{className:"p-3 bg-blue-100 rounded-lg",children:e.jsx(ty,{className:"w-6 h-6 text-blue-600"})})]})}),e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-4","data-testid":"onboarding-non-opps-stat-locations",children:[e.jsx("p",{className:"text-slate-600",children:"Unique Locations"}),e.jsx("p",{className:"text-2xl text-slate-900 mt-1",children:((W=u==null?void 0:u.stats)==null?void 0:W.uniqueLocations)||0})]}),e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-4","data-testid":"onboarding-non-opps-stat-exp",children:[e.jsx("p",{className:"text-slate-600",children:"With Experience"}),e.jsx("p",{className:"text-2xl text-re-red mt-1",children:((U=u==null?void 0:u.stats)==null?void 0:U.withExperience)||0})]})]}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(it,{type:"text",placeholder:"Search by name, email, phone, or registration number...",value:s,onChange:M=>n(M.target.value),className:"pl-10","data-testid":"onboarding-non-opps-search-input"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(_u,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(te,{variant:"outline",className:Nt("w-full md:w-36 justify-start text-left font-normal h-10 px-3",!d&&"text-muted-foreground"),"data-testid":"onboarding-non-opps-from-date-trigger",children:[e.jsx(er,{className:"mr-2 h-4 w-4 text-slate-400"}),d?za(new Date(d),"PP"):e.jsx("span",{className:"text-xs text-slate-500",children:"From Date"})]})}),e.jsx(Pu,{className:"w-auto p-0",align:"start",children:e.jsx(yf,{mode:"single",selected:d?new Date(d):void 0,onSelect:M=>m(M?M.toISOString().split("T")[0]:""),initialFocus:!0})})]}),e.jsx("span",{className:"text-slate-400",children:"to"}),e.jsxs(_u,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(te,{variant:"outline",className:Nt("w-full md:w-36 justify-start text-left font-normal h-10 px-3",!f&&"text-muted-foreground"),"data-testid":"onboarding-non-opps-to-date-trigger",children:[e.jsx(er,{className:"mr-2 h-4 w-4 text-slate-400"}),f?za(new Date(f),"PP"):e.jsx("span",{className:"text-xs text-slate-500",children:"To Date"})]})}),e.jsx(Pu,{className:"w-auto p-0",align:"start",children:e.jsx(yf,{mode:"single",selected:f?new Date(f):void 0,onSelect:M=>p(M?M.toISOString().split("T")[0]:""),initialFocus:!0})})]})]}),e.jsxs(Rt,{value:r,onValueChange:a,children:[e.jsx(_t,{className:"w-full lg:w-48","data-testid":"onboarding-non-opps-location-select",children:e.jsx(Et,{placeholder:"All Locations"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All Locations"}),D.map(M=>e.jsx(Pe,{value:M,children:M},M))]})]}),e.jsx(te,{variant:"ghost",size:"sm",className:"text-slate-500 hover:text-slate-700 h-10 px-3",onClick:()=>{m(""),p(""),a("all"),o("all"),n("")},"data-testid":"onboarding-non-opps-clear-filters",children:"Clear Filters"}),e.jsxs(Rt,{value:i,onValueChange:o,children:[e.jsx(_t,{className:"w-full lg:w-48","data-testid":"onboarding-non-opps-state-select",children:e.jsx(Et,{placeholder:"All States"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All States"}),C.map(M=>e.jsx(Pe,{value:M,children:M},M))]})]}),e.jsx(te,{variant:"outline",size:"icon","data-testid":"onboarding-non-opps-export-btn",children:e.jsx(fi,{className:"w-4 h-4"})}),A.length>0&&e.jsxs(te,{className:"bg-re-red hover:bg-re-red-hover font-bold",onClick:R,disabled:q,children:[q?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(OI,{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(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{className:"w-12",children:e.jsx(Tn,{checked:Q.length>0&&A.length===Q.length,onCheckedChange:P})}),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(Bs,{children:j?e.jsx(lt,{children:e.jsxs(oe,{colSpan:11,className:"text-center py-20",children:[e.jsx(cs,{className:"w-8 h-8 mx-auto animate-spin text-re-red mb-2"}),e.jsx("p",{className:"text-slate-500 text-sm",children:"Loading applications..."})]})}):Q.length===0?e.jsx(lt,{children:e.jsxs(oe,{colSpan:11,className:"text-center py-12 text-slate-500","data-testid":"onboarding-non-opps-empty-state",children:[e.jsx(ty,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{className:"text-lg mb-2",children:"No lead generation data found"}),e.jsx("p",{className:"text-sm",children:"Try adjusting your filters"})]})}):Q.map((M,z)=>e.jsxs(lt,{"data-testid":`onboarding-non-opps-row-${z}`,className:A.includes(M.id)?"bg-red-50/50":"",children:[e.jsx(oe,{children:e.jsx(Tn,{checked:A.includes(M.id),onCheckedChange:()=>L(M.id)})}),e.jsx(oe,{children:e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900","data-testid":`onboarding-non-opps-name-${z}`,children:M.name}),e.jsx("p",{className:"text-slate-500 text-sm","data-testid":`onboarding-non-opps-id-${z}`,children:M.registrationNumber})]})}),e.jsx(oe,{className:"text-slate-900","data-testid":`onboarding-non-opps-phone-${z}`,children:M.phone}),e.jsx(oe,{className:"text-slate-600","data-testid":`onboarding-non-opps-email-${z}`,children:M.email}),e.jsx(oe,{children:e.jsxs("div",{"data-testid":`onboarding-non-opps-pref-loc-${z}`,children:[e.jsx("p",{className:"text-slate-900",children:M.preferredLocation}),e.jsx("p",{className:"text-slate-500 text-sm",children:M.state})]})}),e.jsx(oe,{className:"text-slate-600 max-w-xs truncate","data-testid":`onboarding-non-opps-address-${z}`,children:M.residentialAddress}),e.jsx(oe,{className:"text-slate-900","data-testid":`onboarding-non-opps-age-${z}`,children:M.age}),e.jsx(oe,{className:"text-slate-600","data-testid":`onboarding-non-opps-experience-${z}`,children:M.pastExperience}),e.jsx(oe,{className:"text-slate-900","data-testid":`onboarding-non-opps-education-${z}`,children:M.education}),e.jsx(oe,{className:"text-slate-600","data-testid":`onboarding-non-opps-date-${z}`,children:Qt(M.submissionDate)}),e.jsx(oe,{className:"text-right",children:e.jsx("div",{className:"flex justify-end gap-2",children:e.jsx(te,{variant:"outline",size:"sm",onClick:()=>t(M.id),"data-testid":`onboarding-non-opps-view-btn-${z}`,children:"View"})})})]},M.id))})]}),u&&u.totalPages>1&&e.jsx("div",{className:"py-4 border-t border-slate-200",children:e.jsx(mo,{children:e.jsxs(fo,{children:[e.jsx(pn,{children:e.jsx(po,{onClick:()=>x(M=>Math.max(1,M-1)),className:h===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(u.totalPages)].map((M,z)=>{const T=z+1;return T===1||T===u.totalPages||T>=h-1&&T<=h+1?e.jsx(pn,{children:e.jsx($i,{isActive:h===T,onClick:()=>x(T),className:"cursor-pointer",children:T})},T):T===h-2||T===h+2?e.jsx(pn,{children:e.jsx(go,{})},T):null}),e.jsx(pn,{children:e.jsx(xo,{onClick:()=>x(M=>Math.min(u.totalPages,M+1)),className:h===u.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})}function DU({application:t,slaStatus:s,isNonResponsive:n,isAdmin:r,onBack:a,onOpenWorknotes:i}){return e.jsxs(e.Fragment,{children:[n&&e.jsxs("div",{className:"bg-red-50 border border-red-200 p-4 rounded-2xl flex items-center justify-between animate-in fade-in slide-in-from-top-4 duration-500","data-testid":"onboarding-details-non-responsive-banner",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"bg-red-100 p-2 rounded-xl",children:e.jsx(mk,{className:"w-6 h-6 text-red-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-black text-red-900 tracking-tight leading-none uppercase",children:"Applicant Flagged Non-Responsive"}),e.jsx("p",{className:"text-red-700 text-[11px] font-bold uppercase tracking-widest mt-1 opacity-80",children:"Audit process is currently on hold due to missing cooperation"})]})]}),r&&e.jsx(te,{variant:"outline",size:"sm",className:"bg-white border-red-200 text-red-600 hover:bg-red-50 font-black text-[10px] uppercase tracking-widest hidden sm:block h-9","data-testid":"onboarding-details-review-audit-button",onClick:()=>{const o=document.querySelector('[value="worknotes"]');o==null||o.click()},children:"Review Audit"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(te,{variant:"outline",size:"icon",onClick:a,className:"shrink-0","data-testid":"onboarding-details-back-button",children:e.jsx(Wr,{className:"w-4 h-4"})}),e.jsxs("div",{className:"truncate",children:[e.jsx("h1",{className:"text-slate-900 truncate leading-tight","data-testid":"onboarding-details-application-name",children:t.name}),e.jsx("p",{className:"text-slate-600 truncate text-sm","data-testid":"onboarding-details-registration-number",children:t.registrationNumber}),s&&e.jsx("div",{className:"mt-1",children:e.jsx(br,{status:s})})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsxs(te,{variant:"outline",className:"relative hover:bg-red-50 hover:border-red-300 hover:text-re-red-hover transition-all shadow-sm",onClick:i,"data-testid":"onboarding-details-view-work-notes",children:[e.jsx(li,{className:"w-4 h-4 mr-2"}),"View Work Notes"]})})]})]})}var RU=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],EU=RU.reduce((t,s)=>{const n=Hu(`Primitive.${s}`),r=g.forwardRef((a,i)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),_U="Separator",kS="horizontal",TU=["horizontal","vertical"],d_=g.forwardRef((t,s)=>{const{decorative:n,orientation:r=kS,...a}=t,i=PU(r)?r:kS,d=n?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return e.jsx(EU.div,{"data-orientation":i,...d,...a,ref:s})});d_.displayName=_U;function PU(t){return TU.includes(t)}var OU=d_;function Xo({className:t,orientation:s="horizontal",decorative:n=!0,...r}){return e.jsx(OU,{"data-slot":"separator-root",decorative:n,orientation:s,className:Nt("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...r})}function LU({application:t,canEditStatutory:s,isEditingStatutory:n,isSavingStatutory:r,statutoryForm:a,onEditFirmType:i,onEditStatutory:o,onCancelEditStatutory:d,onSaveStatutory:m,onStatutoryFormChange:f}){return e.jsxs(_e,{"data-testid":"onboarding-applicant-info-card",children:[e.jsx(Xe,{children:e.jsx(st,{children:"Applicant Information"})}),e.jsxs(Oe,{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(Rr,{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(Gr,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Email"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-email",children:t.email})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(tb,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Phone"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-phone",children:t.phone})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Rr,{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(qI,{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(Mr,{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(Mr,{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(to,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"text-slate-600 flex items-center justify-between group cursor-pointer",onClick:i,"data-testid":"onboarding-applicant-info-edit-firm-type",children:["Proposed Firm Type",e.jsx(ry,{className:"w-3 h-3 text-slate-300 group-hover:text-re-red transition-colors"})]}),e.jsx("p",{className:"text-slate-900 font-black text-re-red-hover tracking-tight leading-none mt-1","data-testid":"onboarding-applicant-info-firm-type",children:t.constitutionType||"Not Provided"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(S1,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Owns Bike"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-owns-bike",children:t.ownRoyalEnfield==="yes"?"Yes":"No"})]})]}),t.ownRoyalEnfield==="yes"&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(S1,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Bike Model"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-bike-model",children:t.royalEnfieldModel||"N/A"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Rr,{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(Rr,{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(sc,{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(nk,{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(Xo,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 mb-2",children:"Address"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-address",children:t.address||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 mb-2",children:"Pincode"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-pincode",children:t.pincode||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 mb-2",children:"Description"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-description",children:t.description||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 mb-2",children:"Past Experience"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-experience",children:t.pastExperience||"N/A"})]}),e.jsxs("div",{className:"pt-6 border-t mt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-sm font-black text-slate-900 uppercase tracking-widest flex items-center gap-2",children:[e.jsx(Wu,{className:"w-4 h-4 text-re-red"})," Statutory & Bank Information"]}),s&&!n&&e.jsxs(te,{variant:"ghost",size:"sm",onClick:o,className:"h-8 text-re-red hover:text-re-red-hover hover:bg-red-50 gap-1.5","data-testid":"onboarding-applicant-info-edit-statutory",children:[e.jsx(ry,{className:"w-3.5 h-3.5"}),"Edit Details"]})]}),n?e.jsxs("div",{className:"bg-slate-50/50 p-6 rounded-xl border-2 border-red-100 space-y-4","data-testid":"onboarding-applicant-info-statutory-edit-form",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Legal Entity Name"}),e.jsx(it,{value:a.accountHolderName,onChange:p=>f({...a,accountHolderName:p.target.value}),placeholder:"Enter Legal Entity Name",className:"bg-white border-slate-200","data-testid":"onboarding-applicant-info-input-legal-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] uppercase font-bold text-slate-500",children:"PAN Number"}),e.jsx(it,{value:a.panNumber,onChange:p=>f({...a,panNumber:p.target.value.toUpperCase()}),placeholder:"10-digit PAN",maxLength:10,className:"bg-white border-slate-200 uppercase","data-testid":"onboarding-applicant-info-input-pan"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] uppercase font-bold text-slate-500",children:"GST Number"}),e.jsx(it,{value:a.gstNumber,onChange:p=>f({...a,gstNumber:p.target.value.toUpperCase()}),placeholder:"15-digit GSTIN",maxLength:15,className:"bg-white border-slate-200 uppercase","data-testid":"onboarding-applicant-info-input-gst"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Registered Address"}),e.jsx(it,{value:a.registeredAddress,onChange:p=>f({...a,registeredAddress:p.target.value}),placeholder:"Enter Registered Office Address",className:"bg-white border-slate-200","data-testid":"onboarding-applicant-info-input-registered-address"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Bank Name"}),e.jsx(it,{value:a.bankName,onChange:p=>f({...a,bankName:p.target.value}),placeholder:"Enter Bank Name",className:"bg-white border-slate-200","data-testid":"onboarding-applicant-info-input-bank-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Account Number"}),e.jsx(it,{value:a.accountNumber,onChange:p=>f({...a,accountNumber:p.target.value}),placeholder:"Enter Account Number",className:"bg-white border-slate-200","data-testid":"onboarding-applicant-info-input-account-number"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] uppercase font-bold text-slate-500",children:"IFSC Code"}),e.jsx(it,{value:a.ifscCode,onChange:p=>f({...a,ifscCode:p.target.value.toUpperCase()}),placeholder:"11-digit IFSC",maxLength:11,className:"bg-white border-slate-200 uppercase","data-testid":"onboarding-applicant-info-input-ifsc-code"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[e.jsx(te,{variant:"outline",size:"sm",onClick:d,disabled:r,"data-testid":"onboarding-applicant-info-statutory-cancel",children:"Cancel"}),e.jsx(te,{size:"sm",onClick:m,disabled:r,className:"bg-re-red hover:bg-re-red-hover","data-testid":"onboarding-applicant-info-statutory-save",children:r?e.jsx(cs,{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 IU=({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(sc,{className:"w-12 h-12 mb-3 text-slate-300"}),e.jsx("h3",{className:"text-lg font-medium text-slate-700",children:"Response is Pending"}),e.jsx("p",{className:"text-sm",children:"The applicant has not submitted the questionnaire yet."})]});const s=[...t.questionnaireResponses].sort((r,a)=>{var i,o;return(((i=r.question)==null?void 0:i.order)||0)-(((o=a.question)==null?void 0:o.order)||0)}),n=t.score||t.questionnaireMarks||0;return e.jsxs("div",{className:"space-y-6","data-testid":"onboarding-questionnaire-view",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(sc,{className:"w-5 h-5 text-re-red"}),e.jsx("h3",{className:"text-slate-900",children:"Questionnaire Responses"})]}),n!==void 0&&e.jsxs(we,{className:"bg-re-red","data-testid":"onboarding-questionnaire-total-score",children:["Score: ",n,"/100"]})]}),e.jsx("div",{className:"space-y-6",children:s.map((r,a)=>{const i=r.question,o=(i==null?void 0:i.questionText)||"Unknown Question",d=r.responseValue||"No Answer",m=(i==null?void 0:i.sectionName)||"General",f=(i==null?void 0:i.questionOptions)||[],p=f.find(v=>v.optionText===d),h=p?p.score:0,x=Math.max(...f.map(v=>v.score||0),0),u=typeof d=="string"&&d.startsWith("data:"),N=u&&d.startsWith("data:image");return e.jsxs("div",{className:"border border-slate-200 rounded-lg p-5 hover:border-red-300 transition-colors","data-testid":`onboarding-questionnaire-item-${a}`,children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-red-50 flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-re-red",children:a+1})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(we,{variant:"outline",className:"text-slate-600 bg-slate-50","data-testid":`onboarding-questionnaire-item-section-${a}`,children:m}),f.length>0&&x>0&&e.jsxs(we,{className:h>0?"bg-green-600":"bg-slate-400","data-testid":`onboarding-questionnaire-item-score-${a}`,children:[h,"/",x]})]}),e.jsx("h4",{className:"text-slate-900 font-medium","data-testid":`onboarding-questionnaire-item-text-${a}`,children:o})]})]}),e.jsx("div",{className:"ml-11",children:N?e.jsx("div",{className:"mt-2","data-testid":`onboarding-questionnaire-item-image-${a}`,children:e.jsx("img",{src:d,alt:"Response Attachment",className:"max-w-full h-auto max-h-64 rounded border p-1 object-contain"})}):u?e.jsx("a",{href:d,download:`upload_${a}.pdf`,className:"text-blue-600 underline text-sm break-all","data-testid":`onboarding-questionnaire-item-download-${a}`,children:"Download Attachment"}):e.jsx("div",{className:"text-slate-600 leading-relaxed break-words whitespace-pre-wrap","data-testid":`onboarding-questionnaire-item-answer-${a}`,children:r.attachmentUrl?e.jsx("a",{href:r.attachmentUrl,target:"_blank",rel:"noreferrer",className:"text-blue-600 underline","data-testid":`onboarding-questionnaire-item-attachment-${a}`,children:"View Attachment"}):d})})]},r.id)})})]})},MU=Ky("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function Ai({className:t,variant:s,...n}){return e.jsx("div",{"data-slot":"alert",role:"alert",className:Nt(MU({variant:s}),t),...n})}function il({className:t,...s}){return e.jsx("div",{"data-slot":"alert-title",className:Nt("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...s})}function ki({className:t,...s}){return e.jsx("div",{"data-slot":"alert-description",className:Nt("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...s})}var FU={};function BU(t){const{application:s,activeTab:n,setActiveTab:r,processStages:a,documents:i,interviews:o,expandedBranches:d,setExpandedBranches:m,setSelectedStage:f,setShowDocumentsModal:p,setShowUploadForm:h,handleRetriggerEvaluators:x,handleRescheduleInterview:u,setSelectedEvaluationForView:N,setShowFeedbackDetailsModal:v,renderFddAuditContent:w,eorProgress:j,eorData:b,eorChecklist:C,setUploadDocType:S,isAdmin:D,fetchApplication:_,fetchEorData:A,deposits:E,getDeposit:q,paymentConfigs:O,setPreviewDoc:R,setShowPreviewModal:P,auditLoading:L,auditLogs:$,auditLogActionBadgeClass:Z}=t,Q=U=>String(U||"").trim().toLowerCase().replace(/[_\s-]+/g," "),W=(U,M)=>{var F,I,K;const z=[(F=U==null?void 0:U.user)==null?void 0:F.role,(I=U==null?void 0:U.user)==null?void 0:I.roleCode,(K=U==null?void 0:U.metadata)==null?void 0:K.role].map(Q),T=M.map(Q);return z.some(G=>T.includes(G))};return e.jsx(_e,{"data-testid":"onboarding-details-tabs-container",children:e.jsxs(In,{value:n,onValueChange:r,children:[e.jsx(Xe,{className:"pb-4 px-4 sm:px-6",children:e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim -mx-4 px-4 sm:-mx-6 sm:px-6",children:e.jsxs(Mn,{className:"w-max min-w-full justify-start h-11 bg-slate-100/80 p-1","data-testid":"onboarding-tabs-list",children:[e.jsx(Ht,{value:"questionnaire",className:"min-w-[120px]","data-testid":"onboarding-tab-trigger-questionnaire",children:"Questionnaire"}),e.jsx(Ht,{value:"progress",className:"min-w-[80px]","data-testid":"onboarding-tab-trigger-progress",children:"Progress"}),e.jsx(Ht,{value:"documents",className:"min-w-[100px]","data-testid":"onboarding-tab-trigger-documents",children:"Documents"}),e.jsx(Ht,{value:"interviews",className:"min-w-[100px]","data-testid":"onboarding-tab-trigger-interviews",children:"Interviews"}),e.jsx(Ht,{value:"fdd",className:"min-w-[120px]","data-testid":"onboarding-tab-trigger-fdd",children:"FDD Audit"}),e.jsx(Ht,{value:"eor",className:"min-w-[120px]","data-testid":"onboarding-tab-trigger-eor",children:"EOR Checklist"}),e.jsx(Ht,{value:"payments",className:"min-w-[100px]","data-testid":"onboarding-tab-trigger-payments",children:"Payments"}),e.jsx(Ht,{value:"audit",className:"min-w-[100px]","data-testid":"onboarding-tab-trigger-audit",children:"Audit Trail"})]})})}),e.jsxs(Oe,{children:[e.jsx(Vt,{value:"questionnaire",className:"space-y-6","data-testid":"onboarding-tab-content-questionnaire",children:e.jsx(IU,{application:s})}),e.jsxs(Vt,{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(we,{className:wq(s.status),"data-testid":"onboarding-progress-percentage-badge",children:[s.progress,"% Complete"]})]}),e.jsx(oc,{value:s.progress,className:"h-3 mb-6 bg-status-progress-soft",indicatorClassName:fl(s.status),"data-testid":"onboarding-progress-bar"})]}),e.jsx("div",{className:"relative status-progress-ui","data-testid":"onboarding-progress-stages-container",children:(()=>{const U={1:["DD-ZM","RBM"],2:["DD Lead","ZBH"],3:["NBH","DD Head"]},M={LOI_APPROVAL:["DD Head","NBH"],LOA_APPROVAL:["DD Head","NBH"]},z=F=>(s.participants||[]).filter(K=>{var V,Y,re,ae,ue,ye,ce,je,Me,ut,jt,ft;return((V=K.metadata)==null?void 0:V.stageCode)===F||((re=(Y=K.metadata)==null?void 0:Y.allAssignments)==null?void 0:re.includes(F))||typeof F=="number"&&(((ae=K.metadata)==null?void 0:ae.interviewLevel)===F||((ue=K.metadata)==null?void 0:ue.interviewLevel)===String(F)||((ce=(ye=K.metadata)==null?void 0:ye.allAssignments)==null?void 0:ce.includes(F))||((Me=(je=K.metadata)==null?void 0:je.allAssignments)==null?void 0:Me.includes(String(F))))||typeof F=="string"&&!isNaN(Number(F))&&(((ut=K.metadata)==null?void 0:ut.interviewLevel)===Number(F)||((ft=(jt=K.metadata)==null?void 0:jt.allAssignments)==null?void 0:ft.includes(Number(F))))?!0:typeof F=="number"?W(K,U[F]||[]):W(K,M[F]||[])}).map(K=>{var Y,re,ae,ue,ye;const G=typeof F=="number"?`INTERVIEW_LEVEL_${F}`:F,V=(s.stageApprovals||[]).find(ce=>ce.stageCode===G&&String(ce.actorUserId)===String(K.userId));return{name:((Y=K.user)==null?void 0:Y.name)||((re=K.user)==null?void 0:re.fullName)||"Unknown",role:((ae=K.user)==null?void 0:ae.role)||((ue=K.user)==null?void 0:ue.roleCode)||((ye=K.metadata)==null?void 0:ye.role)||"Reviewer",status:V?V.decision==="Approved"?"approved":"rejected":"pending"}}),T=(F,I)=>{const G={"1st Level Interview":1,"2nd Level Interview":2,"3rd Level Interview":3,"LOI Approval":"LOI_APPROVAL",LOA:"LOA_APPROVAL"}[F];if(!G)return null;const V=z(G);return V.length===0?null:e.jsx("div",{className:"flex flex-wrap gap-2 mt-3","data-testid":`onboarding-stage-approvers-${I}`,children:V.map((Y,re)=>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-${I}-${re}`,children:[e.jsx("div",{className:Nt("w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold text-white",Y.status==="approved"?"bg-green-500":Y.status==="rejected"?"bg-red-500":"bg-slate-300"),children:Y.name.split(" ").map(ae=>ae[0]).join("").substring(0,2).toUpperCase()}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-700 leading-none",children:Y.name}),e.jsx("span",{className:"text-[8px] text-slate-500 leading-none mt-0.5",children:Y.role})]}),e.jsx("div",{className:Nt("absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full border border-white",Y.status==="approved"?"bg-green-500":Y.status==="rejected"?"bg-red-500":"bg-status-progress"),"data-testid":`onboarding-stage-approver-status-dot-${I}-${re}`}),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:[Y.role,": ",Y.status.toUpperCase()]})]},re))})};return a.map((F,I)=>e.jsxs("div",{"data-testid":`onboarding-progress-stage-${I}`,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 ${F.status==="completed"?"bg-green-500 border-green-500 text-white shadow-md":F.status==="active"?F.isLocked?"bg-slate-400 border-slate-400 text-white":"bg-status-workflow-active border-status-workflow-active text-white animate-pulse-subtle":"bg-white border-slate-300 text-slate-400 shadow-none"}`,"data-testid":`onboarding-progress-stage-icon-${I}`,children:F.isParallel?e.jsx(sy,{className:"w-5 h-5"}):F.isLocked?e.jsxs("div",{className:"group relative",children:[e.jsx(ny,{className:"w-5 h-5 text-white cursor-help"}),e.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-3 py-1.5 bg-slate-900 text-white text-[10px] rounded shadow-xl opacity-0 group-hover:opacity-100 pointer-events-none transition-all duration-200 whitespace-nowrap z-[100] border border-slate-700",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"font-bold text-status-progress flex items-center gap-1",children:[e.jsx(sn,{className:"w-3 h-3"})," Stage Locked"]}),e.jsx("span",{children:F.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:F.status==="completed"?e.jsx(Hn,{className:"w-6 h-6"}):F.status==="active"?e.jsx(dn,{className:"w-5 h-5 text-white"}):e.jsx("div",{className:"w-3 h-3 bg-slate-300 rounded-full"})})}),I0&&!["LOI Approval","LOA","1st Level Interview","2nd Level Interview","3rd Level Interview"].includes(F.name)&&e.jsxs("p",{className:"text-status-progress text-xs mt-1.5 flex items-center gap-1 bg-status-progress-soft w-fit px-2 py-0.5 rounded border border-status-progress","data-testid":`onboarding-progress-stage-evaluators-${I}`,children:[e.jsx(Rr,{className:"w-3 h-3"}),"Evaluators: ",F.evaluators.join(" + ")]}),(()=>{var ye;const K={3:2,4:2,5:2,6:2,8:2,12:2},G=Number(F.id),V=K[G],re={3:1,4:1,5:2,6:3,8:"LOI_APPROVAL",12:"LOA_APPROVAL"}[G],ae=re?z(re).length:((ye=F.evaluators)==null?void 0:ye.length)||0,ue=G===3?F.status==="completed":F.status!=="pending";return V&&ae{const K=i.filter(V=>{var Y;return V.stage===F.name||!V.stage&&((Y=V.documentType)==null?void 0:Y.toLowerCase().includes(F.name.toLowerCase().split(" ")[0]))}).length,G=F.status==="active"&&!F.isLocked;return K===0&&!G?null:e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("button",{onClick:()=>{f(F.name),p(!0),K===0&&G&&h(!0)},className:"text-xs font-semibold text-blue-600 hover:text-blue-800 flex items-center gap-1.5 px-3 py-1 rounded-full bg-blue-50 border border-blue-100 hover:bg-blue-100 transition-all shadow-sm","data-testid":`onboarding-progress-stage-docs-${I}`,children:[e.jsx(ks,{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-${I}`,children:[F.status==="completed"&&F.date&&`Completed: ${Qt(F.date)}`,F.status==="active"&&"In Progress",F.status==="pending"&&"Pending"]})]})]}),F.isParallel&&F.branches&&e.jsxs("div",{className:"ml-5 mb-8","data-testid":`onboarding-progress-parallel-branches-${I}`,children:[F.branches.map((K,G)=>{const V=K.name.toLowerCase().replace(/\s+/g,"-"),Y=d[V],re=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:()=>m(ae=>({...ae,[V]:!ae[V]})),className:`flex-1 flex items-center gap-3 p-4 rounded-lg border-2 transition-all hover:shadow-md ${re==="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-${V}`,children:[Y?e.jsx(va,{className:`w-5 h-5 ${re==="blue"?"text-blue-600":"text-green-600"}`}):e.jsx(mi,{className:`w-5 h-5 ${re==="blue"?"text-blue-600":"text-green-600"}`}),e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center ${re==="blue"?"bg-blue-200":"bg-green-200"}`,children:e.jsx(sy,{className:`w-4 h-4 ${re==="blue"?"text-blue-700":"text-green-700"}`})}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsx("p",{className:`${re==="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 ${re==="blue"?"text-blue-500":"text-green-500"}`,children:[K.stages.length," SUB-STEPS"]})]})]})}),Y&&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-${V}`,children:K.stages.map((ae,ue)=>e.jsx("div",{className:"relative",children:e.jsx("div",{className:"flex gap-4 text-xs","data-testid":`onboarding-progress-branch-stage-${V}-${ue}`,children:(()=>{const ye=i.filter(je=>{var Me;return((Me=je.documentType)==null?void 0:Me.toLowerCase().includes(ae.name.toLowerCase().split(" ")[0]))||je.stage===ae.name}),ce=ae.status==="completed"||ye.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center border-2 ${ce?`${re==="blue"?"bg-blue-500 border-blue-500":"bg-green-500 border-green-500"}`:ae.status==="active"?"bg-status-workflow-active border-status-workflow-active text-white shadow-sm":"bg-white border-slate-300 text-slate-400"}`,"data-testid":`onboarding-progress-branch-stage-icon-${V}-${ue}`,children:ce?e.jsx($n,{className:"w-4 h-4 text-white",strokeWidth:3}):ae.status==="active"?e.jsx(dn,{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-${V}-${ue}`,children:ae.name}),ae.description&&e.jsx("p",{className:"text-slate-500 text-xs mt-0.5",children:ae.description}),(()=>{const je=ae.status==="active";return ye.length===0&&!je?null:e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("button",{onClick:()=>{f(ae.name),p(!0),ye.length===0&&je&&h(!0)},className:Nt("text-[10px] font-medium flex items-center gap-1 transition-colors",re==="blue"?"text-blue-600 hover:text-blue-800":"text-green-600 hover:text-green-800"),"data-testid":`onboarding-progress-branch-stage-docs-${V}-${ue}`,children:[e.jsx(ks,{className:"w-2.5 h-2.5"}),ye.length>0?`${ye.length} Docs`:"Upload"]})})})(),e.jsx("p",{className:"text-slate-400 text-[10px] mt-1","data-testid":`onboarding-progress-branch-stage-status-${V}-${ue}`,children:ce&&ae.date?`Done: ${Qt(ae.date)}`:ce&&ye.length>0?`Uploaded: ${Qt(ye[0].updatedAt||ye[0].createdAt)}`:"Pending"})]})]})})()})},ae.id))})]},G)}),e.jsx("div",{className:"h-8 w-0.5 bg-slate-300 ml-5 opacity-50"})]})]},F.id))})()})]}),e.jsxs(Vt,{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(te,{size:"sm",className:"bg-re-red hover:bg-re-red-hover","data-testid":"onboarding-documents-upload-tab-button",onClick:()=>{f(null),p(!0),h(!0)},children:[e.jsx(vr,{className:"w-4 h-4 mr-2"}),"Upload Document"]})]}),e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim",children:e.jsxs(Ms,{"data-testid":"onboarding-documents-table",children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:i.length===0?e.jsx(lt,{"data-testid":"onboarding-documents-empty-row",children:e.jsx(oe,{colSpan:5,className:"text-center py-8 text-slate-500",children:"No documents uploaded yet"})}):i.map((U,M)=>{var z;return e.jsxs(lt,{"data-testid":`onboarding-document-row-${M}`,children:[e.jsxs(oe,{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"truncate max-w-[150px] md:max-w-[300px]","data-testid":`onboarding-document-name-${M}`,children:U.fileName})]}),e.jsx(oe,{"data-testid":`onboarding-document-type-${M}`,children:U.documentType}),e.jsx(oe,{children:Qt(U.createdAt)}),e.jsx(oe,{"data-testid":`onboarding-document-uploader-${M}`,children:((z=U.uploader)==null?void 0:z.fullName)||(U.uploadedBy?"Unknown User":"Applicant")}),e.jsx(oe,{children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(te,{size:"sm",variant:"outline","data-testid":`onboarding-document-preview-${M}`,onClick:()=>{R(U),P(!0)},children:e.jsx(un,{className:"w-3 h-3 text-slate-500"})}),e.jsx(te,{size:"sm",variant:"outline","data-testid":`onboarding-document-download-${M}`,onClick:()=>{const T=FU.NEXT_PUBLIC_API_URL||"http://localhost:5000";window.open(`${T}/${U.filePath}`,"_blank")},children:e.jsx(fi,{className:"w-3 h-3 text-slate-500"})})]})})]},U.id)})})]})})]}),e.jsxs(Vt,{value:"interviews",className:"space-y-6","data-testid":"onboarding-tab-content-interviews",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900 mb-4",children:"Scheduled Interviews"}),e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim",children:e.jsxs(Ms,{"data-testid":"onboarding-interviews-scheduled-table",children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:!o||o.length===0?e.jsx(lt,{"data-testid":"onboarding-interviews-empty-row",children:e.jsx(oe,{colSpan:7,className:"text-center py-8 text-slate-500",children:"No interviews scheduled yet"})}):(Array.isArray(o)?o:[]).map((U,M)=>{var z,T;return e.jsxs(lt,{"data-testid":`onboarding-interview-row-${M}`,children:[e.jsxs(oe,{className:"font-medium",children:["Level ",U.level]}),e.jsx(oe,{children:U.scheduleDate?new Date(U.scheduleDate).toLocaleString():"N/A"}),e.jsx(oe,{className:"capitalize",children:U.interviewType}),e.jsx(oe,{children:(z=U.interviewType)!=null&&z.toLowerCase().includes("virtual")?e.jsx("a",{href:U.linkOrLocation,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline","data-testid":`onboarding-interview-link-${M}`,children:"Join Meeting"}):e.jsx("span",{"data-testid":`onboarding-interview-location-${M}`,children:U.linkOrLocation})}),e.jsx(oe,{children:e.jsx(we,{variant:U.status==="Completed"?"default":"secondary","data-testid":`onboarding-interview-status-${M}`,children:U.status})}),e.jsx(oe,{children:((T=U.scheduler)==null?void 0:T.fullName)||U.scheduledBy||"N/A"}),e.jsx(oe,{className:"text-right",children:(U.status==="Scheduled"||U.status==="scheduled")&&e.jsx(te,{variant:"ghost",size:"sm",className:"text-primary-600 hover:text-primary-700 hover:bg-primary-50 h-8 px-2","data-testid":`onboarding-interview-reschedule-${M}`,onClick:()=>u(U),children:"Reschedule"})})]},U.id)})})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900 mb-4",children:"Interview Feedback"}),!o||o.length===0?e.jsx("p",{className:"text-slate-500 italic","data-testid":"onboarding-interviews-no-feedback",children:"No interviews scheduled."}):(Array.isArray(o)?o:[]).map((U,M)=>e.jsxs("div",{className:"mb-6 border p-4 rounded-lg bg-slate-50/50","data-testid":`onboarding-interview-feedback-block-${M}`,children:[e.jsxs("h4",{className:"font-semibold text-slate-800 mb-2",children:["Level ",U.level," Interview",e.jsxs("span",{className:"font-normal text-slate-500 text-sm ml-2",children:["(",Qt(U.scheduleDate)," - ",U.interviewType,")"]})]}),U.evaluations&&U.evaluations.length>0?e.jsxs(Ms,{"data-testid":`onboarding-interview-evaluations-table-${M}`,children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Interviewer"}),e.jsx(me,{children:"Role"}),e.jsx(me,{children:U.level===1?"Score (KT Matrix)":"Overall Score"}),e.jsx(me,{children:"Remarks"}),e.jsx(me,{children:"Recommendation"})]})}),e.jsx(Bs,{children:U.evaluations.map((z,T)=>{var F,I,K;return e.jsxs(lt,{"data-testid":`onboarding-interview-evaluation-row-${M}-${T}`,children:[e.jsx(oe,{className:"font-medium",children:(F=z.evaluator)==null?void 0:F.fullName}),e.jsx(oe,{children:((K=(I=z.evaluator)==null?void 0:I.role)==null?void 0:K.roleName)||"N/A"}),e.jsx(oe,{children:z.ktMatrixScore?e.jsxs(we,{variant:U.level===1?Number(z.ktMatrixScore)>=50?"outline":"destructive":Number(z.ktMatrixScore)>=5?"outline":"destructive","data-testid":`onboarding-interview-evaluation-score-${M}-${T}`,children:[z.ktMatrixScore,"/",U.level===1?"100":"10"]}):"N/A"}),e.jsx(oe,{className:"max-w-xs truncate",title:z.remarks||z.qualitativeFeedback,children:z.remarks?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"font-medium text-slate-800",children:z.remarks}),z.feedbackDetails&&z.feedbackDetails.length>0&&e.jsx(te,{variant:"link",className:"p-0 h-auto font-normal text-blue-600 text-xs w-fit","data-testid":`onboarding-interview-evaluation-details-btn-${M}-${T}`,onClick:()=>{N({...z,interview:U}),v(!0)},children:"View Detailed Feedback"})]}):z.feedbackDetails&&z.feedbackDetails.length>0?e.jsx(te,{variant:"link",className:"p-0 h-auto font-normal text-blue-600","data-testid":`onboarding-interview-evaluation-details-btn-${M}-${T}`,onClick:()=>{N({...z,interview:U}),v(!0)},children:"View Detailed Feedback"}):z.qualitativeFeedback||"-"}),e.jsx(oe,{"data-testid":`onboarding-interview-evaluation-rec-${M}-${T}`,children:z.recommendation||"-"})]},z.id)})})]}):e.jsx("p",{className:"text-sm text-slate-500 italic pl-2",children:"No feedback recorded yet."})]},U.id))]}),["Level 2 Approved","Level 3 Interview Pending","Approved","Onboarded"].includes(s.status)&&e.jsxs("div",{"data-testid":"onboarding-interviews-summary-l2",children:[e.jsx("h3",{className:"text-slate-900 mb-4",children:"Level 2 Interview Summary"}),e.jsxs("div",{className:"p-4 bg-slate-50 rounded-lg",children:[e.jsx("p",{className:"text-slate-600",children:"Decision: Approved by both ZBH and DD Lead"}),e.jsx("p",{className:"text-slate-600 mt-2",children:"Overall Assessment: Strong candidate with excellent business plan"})]})]})]}),e.jsx(Vt,{value:"fdd",className:"space-y-6","data-testid":"onboarding-tab-content-fdd",children:w()}),e.jsxs(Vt,{value:"eor",className:"space-y-4 status-progress-ui","data-testid":"onboarding-tab-content-eor",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-slate-900",children:"Essential Operating Requirements"}),e.jsxs(we,{className:Cq(j),"data-testid":"onboarding-eor-progress-badge",children:[Math.round(j),"% Complete"]})]}),e.jsx(oc,{value:j,className:"h-3 mb-6 bg-status-progress-soft",indicatorClassName:Sq(j),"data-testid":"onboarding-eor-progress-bar"}),e.jsx("div",{className:"space-y-3","data-testid":"onboarding-eor-checklist",children:((b==null?void 0:b.items)||C).map((U,M)=>{const z=U.description||U.item,T=!!U.proofDocument;return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-slate-50 rounded-xl transition-all border border-transparent hover:border-slate-200 group","data-testid":`onboarding-eor-item-${M}`,children:[e.jsx(Tn,{checked:U.isCompliant||U.completed,className:"pointer-events-none shrink-0","data-testid":`onboarding-eor-checkbox-${M}`}),e.jsxs("div",{className:"flex flex-col flex-1 min-w-0 cursor-pointer","data-testid":`onboarding-eor-clickable-${M}`,onClick:()=>{f(`EOR: ${z}`),S(z),p(!0),h(!T)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:U.isCompliant||U.completed?"text-slate-900 font-bold":"text-slate-600 font-medium",children:z}),T&&!U.isCompliant&&e.jsx(we,{variant:"outline",className:"text-[10px] h-4 px-1.5 bg-red-50 text-re-red border-red-200 uppercase tracking-wider font-bold",children:"Needs Verification"})]}),T&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-blue-600 font-semibold mt-1",children:[e.jsx(ks,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"truncate",children:U.proofDocument.fileName})]}),!T&&e.jsx("span",{className:"text-[10px] text-slate-400 mt-1 uppercase tracking-tighter",children:"Click to upload proof"})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[T&&!U.isCompliant&&D&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(te,{size:"sm",className:"h-8 px-3 bg-green-600 hover:bg-green-700 text-white font-bold rounded-lg shadow-sm","data-testid":`onboarding-eor-verify-btn-${M}`,onClick:async()=>{await(await Yo(async()=>{const{eorService:F}=await Promise.resolve().then(()=>Ug);return{eorService:F}},void 0)).eorService.updateItem(b.id,{...U,isCompliant:!0}),A(),J.success(`${z} verified!`)},children:"Verify"}),e.jsx(te,{size:"sm",variant:"outline",className:"h-8 px-3 border-red-200 text-red-600 hover:bg-red-50 font-bold rounded-lg","data-testid":`onboarding-eor-reject-btn-${M}`,onClick:async()=>{await(await Yo(async()=>{const{eorService:F}=await Promise.resolve().then(()=>Ug);return{eorService:F}},void 0)).eorService.updateItem(b.id,{...U,isCompliant:!1,proofDocumentId:null}),A(),J.success(`${z} rejected.`)},children:"Reject"})]}),(U.isCompliant||U.completed)&&e.jsx("div",{className:"bg-green-100 p-1.5 rounded-full","data-testid":`onboarding-eor-done-icon-${M}`,children:e.jsx(ln,{className:"w-4 h-4 text-green-600"})}),!T&&e.jsx("div",{className:"p-2 text-slate-300 group-hover:text-re-red transition-colors","data-testid":`onboarding-eor-upload-hint-${M}`,children:e.jsx(vr,{className:"w-4 h-4"})})]})]},U.id)})}),j===100&&D&&(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(so,{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(te,{className:"w-full sm:w-auto bg-green-600 hover:bg-green-700 text-white font-bold h-12 px-8 rounded-xl shadow-lg shadow-green-600/20 transition-all hover:scale-[1.02] active:scale-[0.98]","data-testid":"onboarding-eor-submit-audit",onClick:async()=>{try{const U=b==null?void 0:b.id;if(!U)throw new Error("Checklist ID not found");await(await Yo(async()=>{const{eorService:M}=await Promise.resolve().then(()=>Ug);return{eorService:M}},void 0)).eorService.submitAudit(U,{status:"Completed",overallComments:"EOR Checklist verified and audit completed."}),J.success("EOR Audit completed successfully!"),_(),A()}catch(U){J.error(U.message||"Failed to complete EOR audit")}},children:"Complete Audit & Proceed"})]})})]}),e.jsxs(Vt,{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(we,{variant:"outline",className:"bg-slate-50 text-slate-500 border-slate-200","data-testid":"onboarding-payments-count-badge",children:[E.length," Payment Record(s)"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(()=>{const U=q("SECURITY_DEPOSIT"),M=O.SECURITY_DEPOSIT,z=(M==null?void 0:M.amount)||5e5;return e.jsx(_e,{className:Nt("border-l-4",(U==null?void 0:U.status)==="Verified"?"border-l-green-500":(U==null?void 0:U.status)==="Rejected"?"border-l-red-500":"border-l-re-red"),"data-testid":"onboarding-payment-card-security",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-red-50 flex items-center justify-center text-re-red",children:e.jsx(sc,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-semibold text-slate-700",children:"Security Deposit"})]}),e.jsx(we,{className:Nt((U==null?void 0:U.status)==="Verified"?"bg-green-100 text-green-700 hover:bg-green-100":(U==null?void 0:U.status)==="Rejected"?"bg-red-100 text-red-700 hover:bg-red-100":"bg-red-50 text-re-red-hover hover:bg-red-50"),"data-testid":"onboarding-payment-status-security",children:(U==null?void 0:U.status)||"Awaiting"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-baseline",children:[e.jsx("span",{className:"text-xs text-slate-500 uppercase font-bold tracking-wider",children:"Amount Received"}),e.jsxs("span",{className:"text-lg font-bold text-slate-900","data-testid":"onboarding-payment-amount-security",children:["₹",Number((U==null?void 0:U.amount)||0).toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-baseline border-t border-slate-100 pt-2",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Expected Total"}),e.jsxs("span",{className:"text-sm font-medium text-slate-600",children:["₹",z.toLocaleString()]})]}),(U==null?void 0:U.paymentReference)&&e.jsxs("div",{className:"bg-slate-50 p-2 rounded text-xs font-mono text-slate-600 flex justify-between items-center","data-testid":"onboarding-payment-ref-security",children:[e.jsxs("span",{children:["Ref: ",U.paymentReference]}),U.verifiedAt&&e.jsx("span",{children:Qt(U.verifiedAt)})]}),(U==null?void 0:U.remarks)&&e.jsxs("div",{className:"text-[11px] text-slate-500 bg-red-50/50 p-2 rounded border border-red-100 italic","data-testid":"onboarding-payment-remarks-security",children:['"',U.remarks,'"']}),e.jsxs("div",{className:"pt-4 mt-2 border-t border-slate-100",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider mb-2",children:"Verification Documents"}),e.jsxs("div",{className:"space-y-2",children:[i.filter(T=>{var F,I;return((F=T.documentType)==null?void 0:F.toLowerCase().includes("security"))&&((I=T.documentType)==null?void 0:I.toLowerCase().includes("deposit"))}).map((T,F)=>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-${F}`,children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.jsx(ks,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-[10px] font-medium text-slate-700 truncate",children:T.fileName||T.name})]}),e.jsx(te,{variant:"ghost",size:"sm",className:"h-6 px-2 text-[10px] text-re-red hover:text-re-red-hover hover:bg-red-50","data-testid":`onboarding-payment-doc-view-security-${F}`,onClick:()=>{R(T),P(!0)},children:"View"})]},F)),i.filter(T=>{var F,I;return((F=T.documentType)==null?void 0:F.toLowerCase().includes("security"))&&((I=T.documentType)==null?void 0:I.toLowerCase().includes("deposit"))}).length===0&&e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"No proof uploaded"})]})]})]})]})})})(),(()=>{const U=q("FIRST_FILL"),M=O.FIRST_FILL,z=(M==null?void 0:M.amount)||15e5;return e.jsx(_e,{className:Nt("border-l-4",(U==null?void 0:U.status)==="Verified"?"border-l-green-500":(U==null?void 0:U.status)==="Rejected"?"border-l-red-500":"border-l-re-red"),"data-testid":"onboarding-payment-card-first-fill",children:e.jsxs(Oe,{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(so,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-semibold text-slate-700",children:"First Fill"})]}),e.jsx(we,{className:Nt((U==null?void 0:U.status)==="Verified"?"bg-green-100 text-green-700 hover:bg-green-100":(U==null?void 0:U.status)==="Rejected"?"bg-red-100 text-red-700 hover:bg-red-100":"bg-red-50 text-re-red-hover hover:bg-red-50"),"data-testid":"onboarding-payment-status-first-fill",children:(U==null?void 0:U.status)||"Awaiting"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-baseline",children:[e.jsx("span",{className:"text-xs text-slate-500 uppercase font-bold tracking-wider",children:"Amount Received"}),e.jsxs("span",{className:"text-lg font-bold text-slate-900","data-testid":"onboarding-payment-amount-first-fill",children:["₹",Number((U==null?void 0:U.amount)||0).toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-baseline border-t border-slate-100 pt-2",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Expected Total"}),e.jsxs("span",{className:"text-sm font-medium text-slate-600",children:["₹",z.toLocaleString()]})]}),(U==null?void 0:U.paymentReference)&&e.jsxs("div",{className:"bg-slate-50 p-2 rounded text-xs font-mono text-slate-600 flex justify-between items-center","data-testid":"onboarding-payment-ref-first-fill",children:[e.jsxs("span",{children:["Ref: ",U.paymentReference]}),U.verifiedAt&&e.jsx("span",{children:Qt(U.verifiedAt)})]}),(U==null?void 0:U.remarks)&&e.jsxs("div",{className:"text-[11px] text-slate-500 bg-red-50/50 p-2 rounded border border-red-100 italic","data-testid":"onboarding-payment-remarks-first-fill",children:['"',U.remarks,'"']}),e.jsxs("div",{className:"pt-4 mt-2 border-t border-slate-100",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider mb-2",children:"Verification Documents"}),e.jsxs("div",{className:"space-y-2",children:[i.filter(T=>{var F,I;return((F=T.documentType)==null?void 0:F.toLowerCase().includes("first"))&&((I=T.documentType)==null?void 0:I.toLowerCase().includes("fill"))}).map((T,F)=>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-${F}`,children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.jsx(ks,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-[10px] font-medium text-slate-700 truncate",children:T.fileName||T.name})]}),e.jsx(te,{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-${F}`,onClick:()=>{R(T),P(!0)},children:"View"})]},F)),i.filter(T=>{var F,I;return((F=T.documentType)==null?void 0:F.toLowerCase().includes("first"))&&((I=T.documentType)==null?void 0:I.toLowerCase().includes("fill"))}).length===0&&e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"No proof uploaded"})]})]})]})]})})})()]})]}),e.jsx(Vt,{value:"audit","data-testid":"onboarding-tab-content-audit",children:e.jsx(Ib,{className:"h-[30rem] rounded-md border border-slate-100 bg-slate-50/50",children:e.jsx("div",{className:"space-y-2.5 p-3 pr-4","data-testid":"onboarding-audit-logs-container",children:L?e.jsxs("div",{className:"flex items-center justify-center py-10","data-testid":"onboarding-audit-loading",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-re-red"}),e.jsx("span",{className:"ml-2 text-sm text-slate-500",children:"Loading audit trail…"})]}):$.length===0?e.jsx("div",{className:"rounded-lg border border-dashed border-slate-200 bg-white py-10 text-center text-sm text-slate-500","data-testid":"onboarding-audit-empty",children:"No audit logs recorded yet for this application."}):$.map((U,M)=>e.jsxs("div",{className:"rounded-lg border border-slate-200/90 bg-white p-3 text-sm shadow-sm","data-testid":`onboarding-audit-log-item-${M}`,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-x-3 gap-y-1.5",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx(we,{variant:"outline",className:Nt("shrink-0 text-[10px] font-semibold uppercase tracking-wide",Z(U.action)),"data-testid":`onboarding-audit-log-action-${M}`,children:String(U.action||"EVENT").replace(/_/g," ")}),U.stage?e.jsx("span",{className:"max-w-[200px] truncate text-[11px] text-slate-500",title:U.stage,"data-testid":`onboarding-audit-log-stage-${M}`,children:U.stage}):null]}),e.jsx("time",{className:"shrink-0 text-xs tabular-nums text-slate-400",dateTime:U.timestamp,"data-testid":`onboarding-audit-log-time-${M}`,children:Qt(U.timestamp)})]}),e.jsx("p",{className:"mt-2 text-[13px] leading-relaxed text-slate-800","data-testid":`onboarding-audit-log-desc-${M}`,children:U.description||"—"}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-slate-500",children:[e.jsx(Rr,{className:"h-3.5 w-3.5 shrink-0 text-slate-400","aria-hidden":!0}),e.jsxs("span",{className:"min-w-0 truncate",children:[e.jsx("span",{className:"font-medium text-slate-600","data-testid":`onboarding-audit-log-user-${M}`,children:U.userName||"System"}),U.userEmail?e.jsxs("span",{className:"text-slate-400","data-testid":`onboarding-audit-log-email-${M}`,children:[" · ",U.userEmail]}):null]})]})]},U.id))})})})]})]})})}function $U(t){var I;const{application:s,permissions:n,getDeposit:r,isNonResponsive:a,isAdmin:i,currentUserStageAction:o,currentUserEvaluation:d,onOpenApproveModal:m,onOpenRejectModal:f,onOpenWorknote:p,onOpenScheduleModal:h,currentUser:x,handleGenerateDealerCodes:u,onOpenAssignArchitectureModal:N,onOpenAssignFdd:v,showAssignFddModal:w,setShowAssignFddModal:j,fddAgencies:b,selectedAgencyId:C,setSelectedAgencyId:S,isAssigningAgency:D,handleAssignAgency:_,activeInterviewForUser:A,hasSubmittedFeedback:E,setSelectedInterviewForFeedback:q,setShowKTMatrixModal:O,setShowLevel2FeedbackModal:R,setShowLevel3FeedbackModal:P,onGoToDashboard:L,showAssignModal:$,setShowAssignModal:Z,selectedUser:Q,setSelectedUser:W,users:U,participantType:M,setParticipantType:z,handleAddParticipant:T,isAssigningParticipant:F}=t;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(_e,{"data-testid":"onboarding-details-summary-card",children:[e.jsx(Xe,{children:e.jsx(st,{children:"Summary"})}),e.jsxs(Oe,{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(we,{className:Nt("mt-1",Xb(s.status)),"data-testid":"onboarding-details-summary-status",children:s.status})]}),s.rank&&e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Rank"}),e.jsxs("p",{className:"text-slate-900","data-testid":"onboarding-details-summary-rank",children:[s.rank," of ",s.totalApplicantsAtLocation,e.jsxs("span",{className:"text-slate-500",children:[" in ",s.preferredLocation]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Progress"}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(oc,{value:s.progress,className:"flex-1 bg-red-50",indicatorClassName:fl(s.status),"data-testid":"onboarding-details-summary-progress-bar"}),e.jsxs("span",{className:"text-slate-900","data-testid":"onboarding-details-summary-progress-text",children:[s.progress,"%"]})]})]}),s.deadline&&e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Questionnaire Deadline"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-details-summary-deadline",children:Qt(s.deadline)})]})]})]}),(s.isShortlisted!==!1||s.status==="Submitted")&&e.jsxs(_e,{"data-testid":"onboarding-details-actions-card",children:[e.jsx(Xe,{children:e.jsx(st,{children:"Actions"})}),e.jsxs(Oe,{className:"space-y-3",children:[n.isLoaLocked&&e.jsxs(Ai,{variant:"destructive",className:"mb-4 bg-red-50 border-red-200 text-red-800","data-testid":"onboarding-details-loa-locked-alert",children:[e.jsx(ny,{className:"w-4 h-4 text-re-red"}),e.jsx(il,{className:"text-red-900 font-semibold",children:"LOA approval locked"}),e.jsxs(ki,{className:"text-red-800",children:[e.jsx("span",{className:"font-medium",children:"First Fill"})," (later-stage payment) must be verified by Finance before LOA approval can proceed. This is separate from the initial Security Deposit before LOI Issued."]})]}),((I=r("FIRST_FILL"))==null?void 0:I.status)==="Verified"&&s.status!=="LOA Pending"&&!["LOA Issued","EOR In Progress","EOR Complete","Inauguration","Approved","Onboarded","Rejected"].includes(s.status)&&e.jsxs(Ai,{className:"mb-4 border-violet-200 bg-violet-50/90 text-violet-950","data-testid":"onboarding-details-first-fill-verified-alert",children:[e.jsx(qa,{className:"h-4 w-4 text-violet-700"}),e.jsx(il,{className:"font-semibold",children:"First Fill verified on file"}),e.jsxs(ki,{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(Ai,{variant:"destructive",className:"mb-4 bg-red-50 border-red-200 text-red-800","data-testid":"onboarding-details-security-locked-alert",children:[e.jsx(ny,{className:"w-4 h-4 text-re-red"}),e.jsx(il,{className:"text-red-900 font-semibold",children:"Security Deposit approval locked"}),e.jsxs(ki,{className:"text-red-800",children:["Finance must verify the ",e.jsx("span",{className:"font-medium",children:"Security Deposit"})," before this stage can be approved. You can still use ",e.jsx("span",{className:"font-medium",children:"Reject"})," if needed."]})]}),["Security Deposit","Security Details","Payment Pending"].includes(s.status)&&e.jsxs(Ai,{className:"mb-4 border-sky-200 bg-sky-50/90 text-sky-900","data-testid":"onboarding-details-security-review-alert",children:[e.jsx(qa,{className:"h-4 w-4 text-sky-700"}),e.jsx(il,{className:"text-sky-950 font-semibold",children:"Security Deposit review"}),e.jsxs(ki,{className:"text-sm text-sky-900/90 leading-relaxed",children:["Check the initial Security Deposit on the ",e.jsx("span",{className:"font-medium",children:"Payments"})," tab (Finance may have already marked it verified). When satisfied, use ",e.jsx("span",{className:"font-medium",children:"Approve"})," ","to move to ",e.jsx("span",{className:"font-medium",children:"LOI Issued"}),"."]})]}),a&&i&&e.jsxs(Ai,{variant:"destructive",className:"mb-4 bg-red-50 border-red-200 text-red-800","data-testid":"onboarding-details-non-responsive-alert",children:[e.jsx(sn,{className:"w-4 h-4 text-red-600"}),e.jsx(il,{className:"text-red-900 font-black uppercase tracking-tighter",children:"⚠️ Non-Responsive Flag"}),e.jsx(ki,{className:"text-red-800 text-xs font-bold leading-tight",children:"FDD Audit has flagged this applicant. Review audit logs before approval."})]}),i&&(s.status==="Level 3 Approved"||s.status==="FDD Verification")&&(!s.fddAssignments||s.fddAssignments.length===0)&&e.jsxs(Ai,{className:"mb-4 bg-red-50 border-red-200 text-red-800","data-testid":"onboarding-details-fdd-assignment-alert",children:[e.jsx(sn,{className:"w-4 h-4 text-re-red"}),e.jsx(il,{className:"text-red-900 font-bold",children:"FDD Assignment Required"}),e.jsx(ki,{className:"text-red-800 font-medium",children:"This application is pending financial due diligence. Please assign an FDD Agency to proceed with the audit."})]}),n.canApprove&&e.jsxs(te,{className:"w-full bg-green-600 hover:bg-green-700 font-bold",onClick:m,"data-testid":"onboarding-details-approve-button",children:[e.jsx(ln,{className:"w-4 h-4 mr-2"}),["Inauguration","Approved"].includes(s.status)?"Onboard Dealer":"Approve"]}),n.canReject&&e.jsxs(te,{variant:"destructive",className:"w-full font-bold",onClick:f,"data-testid":"onboarding-details-reject-button",children:[e.jsx(ai,{className:"w-4 h-4 mr-2"}),"Reject"]}),n.showDecisionMessage&&e.jsxs("div",{className:`w-full p-2 text-center rounded border ${(o==null?void 0:o.decision)==="Approved"||(d==null?void 0:d.decision)==="Approved"||(d==null?void 0:d.recommendation)==="Approved"||(d==null?void 0:d.decision)==="Selected"?"bg-green-50 border-green-200 text-green-700":"bg-red-50 border-red-200 text-red-700"}`,"data-testid":"onboarding-details-decision-message",children:["You have ",(o==null?void 0:o.decision)==="Approved"||(d==null?void 0:d.decision)==="Approved"||(d==null?void 0:d.recommendation)==="Approved"||(d==null?void 0:d.decision)==="Selected"?"Approved":"Rejected"]}),e.jsx(Xo,{}),e.jsxs(te,{variant:"outline",className:"w-full",onClick:p,"data-testid":"onboarding-details-worknote-button",children:[e.jsx(li,{className:"w-4 h-4 mr-2"}),"Work Note"]}),n.canSchedule&&e.jsxs(te,{variant:"outline",className:"w-full",onClick:h,"data-testid":"onboarding-details-schedule-button",children:[e.jsx(er,{className:"w-4 h-4 mr-2"}),"Schedule Interview"]}),x&&["DD Admin","Super Admin"].includes(x.role)&&["Dealer Code Generation","LOA Pending","Architecture Team Assigned","Architecture Document Upload","Architecture Team Completion"].includes(s.status)&&e.jsxs(e.Fragment,{children:[!s.dealerCode&&e.jsxs(te,{className:"w-full bg-blue-600 hover:bg-blue-700",onClick:u,"data-testid":"onboarding-details-generate-dealer-codes",children:[e.jsx(D1,{className:"w-4 h-4 mr-2"}),"Generate Dealer Codes"]}),s.dealerCode&&!s.architectureAssignedTo&&e.jsxs(te,{variant:"outline",className:"w-full border-blue-200 hover:bg-blue-50 text-blue-700",onClick:N,"data-testid":"onboarding-details-assign-architecture",children:[e.jsx(sy,{className:"w-4 h-4 mr-2"}),"Assign Architecture Team"]})]}),i&&["Level 3 Approved","Level 3 Recommended","FDD Verification","FDD In Progress"].includes(s.status)&&(!s.fddAssignments||s.fddAssignments.length===0)&&e.jsxs(ms,{open:w,onOpenChange:j,children:[e.jsxs(te,{variant:"outline",className:"w-full border-purple-200 hover:bg-purple-50 text-purple-700",onClick:v,"data-testid":"onboarding-details-assign-fdd",children:[e.jsx(ak,{className:"w-4 h-4 mr-2"}),"Assign FDD"]}),e.jsxs(us,{"data-testid":"onboarding-details-assign-fdd-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Assign FDD Agency"}),e.jsx(ws,{children:"Select an FDD partner agency to perform the financial due diligence audit for this application."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{children:"FDD Agency"}),e.jsxs(Rt,{value:C,onValueChange:S,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-details-assign-fdd-select",children:e.jsx(Et,{placeholder:b!=null&&b.length?"Choose partner agency...":"No agencies available"})}),e.jsx(Tt,{children:(b||[]).map(K=>e.jsxs(Pe,{value:K.id,children:[K.fullName||K.name," (",K.email,")"]},K.id))})]})]}),e.jsx(te,{className:"w-full bg-re-red hover:bg-re-red-hover font-bold h-11",onClick:_,disabled:D||!C,"data-testid":"onboarding-details-assign-fdd-submit",children:D?"Assigning...":"Assign Agency"})]})]})]}),A&&!E&&e.jsxs(bb,{children:[e.jsx(jb,{asChild:!0,children:e.jsxs(te,{variant:"outline",className:"w-full","data-testid":"onboarding-details-feedback-dropdown-trigger",children:[e.jsx(eM,{className:"w-4 h-4 mr-2"}),"Interview Feedback",e.jsx(va,{className:"w-4 h-4 ml-auto"})]})}),e.jsx(Nb,{className:"w-56","data-testid":"onboarding-details-feedback-dropdown-content",children:e.jsxs(LD,{"data-testid":`onboarding-details-feedback-item-${A.id}`,onClick:()=>{q(A),A.level===1?O(!0):A.level===2?R(!0):P(!0)},children:["Level ",A.level," - ",A.interviewType]},A.id)})]}),s.status==="Questionnaire Pending"&&e.jsxs(e.Fragment,{children:[e.jsxs(te,{variant:"outline",className:"w-full","data-testid":"onboarding-details-send-reminder",children:[e.jsx(Gr,{className:"w-4 h-4 mr-2"}),"Send Reminder"]}),e.jsxs(te,{variant:"outline",className:"w-full","data-testid":"onboarding-details-extend-deadline",children:[e.jsx(dn,{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(ln,{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(te,{className:"w-full bg-green-600 hover:bg-green-700 text-white",onClick:L,"data-testid":"onboarding-details-goto-dashboard",children:[e.jsx(D1,{className:"w-4 h-4 mr-2"}),"Go to Dealer Dashboard"]})]}),x&&["DD Admin","Super Admin"].includes(x.role)&&e.jsxs(ms,{open:$,onOpenChange:Z,children:[e.jsx(oo,{asChild:!0,children:e.jsxs(te,{variant:"outline",className:"w-full","data-testid":"onboarding-details-assign-user-trigger",children:[e.jsx(Rr,{className:"w-4 h-4 mr-2"}),"Assign User"]})}),e.jsxs(us,{"data-testid":"onboarding-details-assign-user-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Assign User to Application"}),e.jsx(ws,{children:"Select a user and their role for this application."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{children:"Select User"}),e.jsxs(Rt,{value:Q,onValueChange:W,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-details-assign-user-select",children:e.jsx(Et,{placeholder:"Search users..."})}),e.jsx(Tt,{children:U.map(K=>e.jsxs(Pe,{value:K.id,children:[K.fullName," (",K.email,")"]},K.id))})]})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Assignment Role"}),e.jsxs(Rt,{value:M,onValueChange:z,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-details-assign-role-select",children:e.jsx(Et,{placeholder:"Select role"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"owner",children:"Owner"}),e.jsx(Pe,{value:"contributor",children:"Contributor"}),e.jsx(Pe,{value:"reviewer",children:"Reviewer"})]})]})]}),e.jsx(te,{className:"w-full bg-re-red hover:bg-re-red-hover font-bold h-11",onClick:T,disabled:F,"data-testid":"onboarding-details-assign-user-submit",children:F?"Assigning...":"Assign User"})]})]})]})]})]})]})}function qU(t){const{application:s,fetchApplication:n,showApproveModal:r,setShowApproveModal:a,approvalRemark:i,setApprovalRemark:o,setApprovalFile:d,isApproving:m,handleApprove:f,showOnboardModal:p,setShowOnboardModal:h,isOnboarding:x,setIsOnboarding:u,showRejectModal:N,setShowRejectModal:v,rejectionReason:w,setRejectionReason:j,isRejecting:b,handleReject:C,showScheduleModal:S,setShowScheduleModal:D,showCancelInterviewModal:_,setShowCancelInterviewModal:A,setInterviewIdToCancel:E,isCancellingInterview:q,handleConfirmCancelInterview:O,interviewToReschedule:R,setInterviewToReschedule:P,interviewType:L,setInterviewType:$,interviewMode:Z,setInterviewMode:Q,interviewDate:W,setInterviewDate:U,meetingLink:M,setMeetingLink:z,location:T,setLocation:F,isInterviewCompleted:I,isInterviewActive:K,users:G,selectedInterviewerId:V,setSelectedInterviewerId:Y,handleAddInterviewer:re,scheduledInterviewParticipants:ae,handleRemoveInterviewer:ue,isScheduling:ye,handleScheduleInterview:ce,showAssignArchitectureModal:je,setShowAssignArchitectureModal:Me,architectureLeadId:ut,setArchitectureLeadId:jt,isAssigningArchitecture:ft,handleAssignArchitecture:X,showArchitectureStatusModal:Ce,setShowArchitectureStatusModal:xe,architectureStatus:We,setArchitectureStatus:Be,architectureRemarks:rt,setArchitectureRemarks:ht,isUpdatingArchitecture:ge,handleUpdateArchitectureStatus:Je}=t,mt=de=>{var at,ot;return(de==null?void 0:de.__stageRole)||((at=de==null?void 0:de.role)==null?void 0:at.roleName)||((ot=de==null?void 0:de.role)==null?void 0:ot.roleCode)||(de==null?void 0:de.roleCode)||(de==null?void 0:de.role)||"Panelist"};return e.jsxs(e.Fragment,{children:[e.jsx(ms,{open:r,onOpenChange:a,children:e.jsxs(us,{"data-testid":"onboarding-approve-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Approve Application"}),e.jsx(ws,{children:"Provide approval remarks and optionally attach supporting documents."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(le,{children:["Remark ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ks,{placeholder:"Enter approval remarks...",value:i,onChange:de=>o(de.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-approve-remark-textarea"})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Attach File (Optional)"}),e.jsx(it,{type:"file",className:"mt-2",onChange:de=>d(de.target.files?de.target.files[0]:null),"data-testid":"onboarding-approve-file-input"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>a(!1),disabled:m,"data-testid":"onboarding-approve-cancel-button",children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-green-600 hover:bg-green-700",onClick:f,disabled:m,"data-testid":"onboarding-approve-submit-button",children:m?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}),"Approving..."]}):"Submit Approval"})]})]})]})}),e.jsx(ms,{open:p,onOpenChange:h,children:e.jsxs(us,{className:"max-w-md","data-testid":"onboarding-onboard-modal",children:[e.jsxs(ys,{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(ln,{className:"w-8 h-8 text-green-600"})}),e.jsx(gs,{className:"text-center text-xl font-bold",children:"Finalize Onboarding"}),e.jsxs(ws,{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($n,{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($n,{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($n,{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(te,{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 ps.createDealer({applicationId:s.id}),J.success("Dealer profile and login account created successfully!"),h(!1),n()}catch{J.error("Failed to create dealer profile")}finally{u(!1)}},disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-5 h-5 mr-2 animate-spin"}),"Processing Onboarding..."]}):"Confirm & Onboard Dealer"}),e.jsx(te,{variant:"ghost",className:"w-full text-slate-500 hover:text-slate-700",onClick:()=>h(!1),disabled:x,"data-testid":"onboarding-onboard-cancel-button",children:"Cancel"})]})]})}),e.jsx(ms,{open:N,onOpenChange:v,children:e.jsxs(us,{"data-testid":"onboarding-reject-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Reject Application"}),e.jsx(ws,{children:"Please provide a clear reason for rejecting this application."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(le,{children:["Reason for Rejection ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ks,{placeholder:"Enter rejection reason...",value:w,onChange:de=>j(de.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-reject-remark-textarea"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>v(!1),disabled:b,"data-testid":"onboarding-reject-cancel-button",children:"Cancel"}),e.jsx(te,{variant:"destructive",className:"flex-1",onClick:C,disabled:b,"data-testid":"onboarding-reject-submit-button",children:b?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}),"Rejecting..."]}):"Confirm Rejection"})]})]})]})}),e.jsx(ms,{open:S,onOpenChange:de=>{D(de),de||P(null)},children:e.jsxs(us,{"data-testid":"onboarding-schedule-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:R?"Reschedule Interview":"Schedule Interview"}),e.jsx(ws,{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(le,{children:"Interview Type"}),e.jsxs(Rt,{value:L,onValueChange:$,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-schedule-type-select",children:e.jsx(Et,{placeholder:"Select interview type"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"level1",disabled:I(1)||K(1),children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("span",{children:"Level 1"}),I(1)&&e.jsx(ln,{className:"w-4 h-4 text-green-500 ml-2 inline"}),K(1)&&e.jsx(dn,{className:"w-4 h-4 text-re-red ml-2 inline"})]})}),e.jsx(Pe,{value:"level2",disabled:!I(1)||I(2)||K(2),children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("span",{children:"Level 2"}),!I(1)&&e.jsx("span",{className:"text-[10px] text-slate-400 ml-2",children:"(Prerequisite: L1)"}),I(2)&&e.jsx(ln,{className:"w-4 h-4 text-green-500 ml-2 inline"}),K(2)&&e.jsx(dn,{className:"w-4 h-4 text-re-red ml-2 inline"})]})}),e.jsx(Pe,{value:"level3",disabled:!I(2)||I(3)||K(3),children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("span",{children:"Level 3"}),!I(2)&&e.jsx("span",{className:"text-[10px] text-slate-400 ml-2",children:"(Prerequisite: L2)"}),I(3)&&e.jsx(ln,{className:"w-4 h-4 text-green-500 ml-2 inline"}),K(3)&&e.jsx(dn,{className:"w-4 h-4 text-re-red ml-2 inline"})]})})]})]})]}),e.jsxs("div",{children:[e.jsxs(le,{children:["Interview Mode ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:Z,onValueChange:Q,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-schedule-mode-select",children:e.jsx(Et,{placeholder:"Select interview mode"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"virtual",children:"Virtual"}),e.jsx(Pe,{value:"physical",children:"Physical"})]})]})]}),e.jsxs("div",{children:[e.jsxs(le,{children:["Date & Time ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{type:"datetime-local",className:"mt-2",value:W,onChange:de=>U(de.target.value),"data-testid":"onboarding-schedule-date-input"})]}),Z==="virtual"&&e.jsxs("div",{children:[e.jsx(le,{children:"Meeting Link"}),e.jsx(it,{placeholder:"https://meet.google.com/...",className:"mt-2",value:M,onChange:de=>z(de.target.value),"data-testid":"onboarding-schedule-link-input"})]}),Z==="physical"&&e.jsxs("div",{children:[e.jsx(le,{children:"Location"}),e.jsx(it,{placeholder:"Enter interview location address",className:"mt-2",value:T,onChange:de=>F(de.target.value),"data-testid":"onboarding-schedule-location-input"})]}),e.jsxs("div",{children:[e.jsxs(le,{children:["Interviewers ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsxs(Rt,{value:V,onValueChange:Y,children:[e.jsx(_t,{className:"flex-1","data-testid":"onboarding-schedule-interviewer-select",children:e.jsx(Et,{placeholder:"Select interviewer"})}),e.jsx(Tt,{children:G.map(de=>{var at;return e.jsxs(Pe,{value:de.id,children:[de.fullName||de.name," (",((at=de.role)==null?void 0:at.roleName)||de.roleCode,")"]},de.id)})})]}),e.jsx(te,{onClick:re,type:"button",variant:"secondary","data-testid":"onboarding-schedule-add-interviewer-button",children:"Add"})]}),ae.length>0&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsx(le,{className:"text-xs text-muted-foreground",children:"Selected Interviewers:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ae.map(de=>e.jsxs("div",{className:"flex items-center gap-1 bg-secondary px-2 py-1 rounded text-sm","data-testid":`onboarding-schedule-participant-${de.id}`,children:[e.jsx("span",{children:de.fullName||de.name||"Unknown"}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["(",mt(de),")"]}),e.jsx("button",{onClick:()=>ue(de.id),className:"text-muted-foreground hover:text-destructive","data-testid":`onboarding-schedule-remove-participant-${de.id}`,children:"×"})]},de.id))})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>{D(!1),P(null)},disabled:ye,"data-testid":"onboarding-schedule-cancel-button",children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-primary-600 hover:bg-primary-700",onClick:ce,disabled:ye,"data-testid":"onboarding-schedule-submit-button",children:ye?R?"Rescheduling...":"Scheduling...":R?"Reschedule":"Schedule"})]})]})]})}),e.jsx(ms,{open:_,onOpenChange:de=>{A(de),de||E("")},children:e.jsxs(us,{"data-testid":"onboarding-cancel-interview-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Cancel Interview"}),e.jsx(ws,{children:"Are you sure you want to cancel this interview?"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>{A(!1),E("")},disabled:q,"data-testid":"onboarding-cancel-interview-close",children:"No"}),e.jsx(te,{variant:"destructive",className:"flex-1",onClick:O,disabled:q,"data-testid":"onboarding-cancel-interview-confirm",children:q?"Cancelling...":"Yes, Cancel"})]})]})}),e.jsx(ms,{open:je,onOpenChange:Me,children:e.jsxs(us,{"data-testid":"onboarding-architecture-assign-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Assign Architecture Team"}),e.jsx(ws,{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(le,{children:["Select Architecture Lead ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:ut,onValueChange:jt,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-architecture-lead-select",children:e.jsx(Et,{placeholder:"Search users..."})}),e.jsxs(Tt,{children:[G.filter(de=>{var at;return de.roleCode==="ARCHITECTURE"||((at=de.role)==null?void 0:at.roleCode)==="ARCHITECTURE"||de.role==="Architecture"||de.role==="Architecture Team"}).map(de=>e.jsxs(Pe,{value:de.id,children:[de.fullName," (",de.email,")"]},de.id)),G.filter(de=>{var at;return de.roleCode==="ARCHITECTURE"||((at=de.role)==null?void 0:at.roleCode)==="ARCHITECTURE"||de.role==="Architecture"||de.role==="Architecture Team"}).length===0&&G.map(de=>e.jsxs(Pe,{value:de.id,children:[de.fullName," (",de.roleCode||de.role,")"]},de.id))]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>Me(!1),disabled:ft,"data-testid":"onboarding-architecture-assign-cancel",children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-blue-600 hover:bg-blue-700",onClick:X,disabled:ft,"data-testid":"onboarding-architecture-assign-submit",children:ft?"Assigning...":"Assign Team"})]})]})]})}),e.jsx(ms,{open:Ce,onOpenChange:xe,children:e.jsxs(us,{"data-testid":"onboarding-architecture-status-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Update Architecture Status"}),e.jsx(ws,{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(le,{children:["Status ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:We,onValueChange:Be,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-architecture-status-select",children:e.jsx(Et,{placeholder:"Select status"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"COMPLETED",children:"Completed"}),e.jsx(Pe,{value:"REJECTED",children:"Rejected / Needs Revision"})]})]})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Remarks (Optional)"}),e.jsx(Ks,{placeholder:"Enter any planning or site-visit remarks...",value:rt,onChange:de=>ht(de.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-architecture-remarks-textarea"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>xe(!1),disabled:ge,"data-testid":"onboarding-architecture-status-cancel",children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-blue-600 hover:bg-blue-700",onClick:Je,disabled:ge,"data-testid":"onboarding-architecture-status-submit",children:ge?"Updating...":"Update Status"})]})]})]})})]})}function zU(t){var Qs,Xs,ie,nt,fe,Ae,Fe,Ke;const{application:s,ktCriteria:n,l2Fields:r,l3Fields:a,showKTMatrixModal:i,setShowKTMatrixModal:o,ktMatrixSelectedValues:d,handleKTMatrixChange:m,ktMatrixRemarks:f,setKtMatrixRemarks:p,ktMatrixRecommendation:h,setKtMatrixRecommendation:x,calculateKTScore:u,handleSubmitKTMatrix:N,isSubmittingKT:v,showLevel2FeedbackModal:w,setShowLevel2FeedbackModal:j,level2Feedback:b,handleLevel2Change:C,level2Recommendation:S,setLevel2Recommendation:D,handleSubmitLevel2Feedback:_,isSubmittingLevel2:A,showFeedbackDetailsModal:E,setShowFeedbackDetailsModal:q,selectedEvaluationForView:O,selectedInterviewForFeedback:R,showLevel3FeedbackModal:P,setShowLevel3FeedbackModal:L,level3Feedback:$,handleLevel3Change:Z,level3Recommendation:Q,setLevel3Recommendation:W,handleSubmitLevel3Feedback:U,isSubmittingLevel3:M,showDocumentsModal:z,setShowDocumentsModal:T,showUploadForm:F,setShowUploadForm:I,selectedStage:K,getDocumentsForStage:G,setPreviewDoc:V,setShowPreviewModal:Y,uploadDocType:re,setUploadDocType:ae,setUploadFile:ue,isUploading:ye,handleUpload:ce,uploadFile:je,showPreviewModal:Me,previewDoc:ut,showFddFinalizeModal:jt,setShowFddFinalizeModal:ft,currentUser:X,fddAuditRecommendation:Ce,setFddAuditRecommendation:xe,fddAuditFindings:We,setFddAuditFindings:Be,isFinalizingFdd:rt,setIsFinalizingFdd:ht,fetchApplication:ge,showFddFlagModal:Je,setShowFddFlagModal:mt,isFddFlagging:de,setIsFddFlagging:at,showFirmTypeModal:ot,setShowFirmTypeModal:ke,tempFirmType:Zt,setTempFirmType:Bt,updatingFirmType:_s,handleUpdateFirmType:Us}=t,fs=R!=null&&R.scheduleDate?new Date(R.scheduleDate).toISOString().split("T")[0]:"",Vs=(X==null?void 0:X.fullName)||(X==null?void 0:X.name)||"";return e.jsxs(e.Fragment,{children:[e.jsx(ms,{open:i,onOpenChange:o,children:e.jsxs(us,{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(ys,{className:"shrink-0 space-y-2 border-b px-5 py-4 text-left",children:[e.jsx(gs,{className:"text-base",children:"KT matrix"}),e.jsxs(ws,{className:"text-sm leading-relaxed",children:["Level 1 interview · ",s.name,e.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[Object.keys(d).length," of ",n.length," criteria answered"]})]})]}),e.jsx("div",{className:"custom-scrollbar-slim min-h-0 flex-1 overflow-y-auto px-5 py-5",children:e.jsxs("div",{className:"space-y-6",children:[n.length===0&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800",children:"KT Matrix configuration is not available. Configure it in Master > Interview Configurations."}),n.map((Le,Ue)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs(le,{htmlFor:`kt-matrix-${Ue}`,className:"block text-sm font-medium leading-relaxed text-foreground",children:[e.jsxs("span",{className:"text-muted-foreground",children:[Ue+1,"."]})," ",Le.name," ",e.jsx("span",{className:"text-red-500",children:"*"})," ",e.jsxs("span",{className:"font-normal text-muted-foreground",children:["(",Le.weight,"%)"]})]}),e.jsxs(Rt,{value:d[Le.name]??void 0,onValueChange:et=>{const dt=Le.options.find(ss=>ss.value===et);dt&&m(Le.name,dt.value,dt.score)},children:[e.jsx(_t,{id:`kt-matrix-${Ue}`,className:"h-10 w-full text-left text-sm font-normal","data-testid":`onboarding-kt-matrix-select-${Ue}`,children:e.jsx(Et,{placeholder:"Choose an option…"})}),e.jsx(Tt,{position:"popper",className:"max-h-72 w-[var(--radix-select-trigger-width)]",children:Le.options.map(et=>e.jsxs(Pe,{value:et.value,className:"py-2.5 text-sm leading-snug","data-testid":`onboarding-kt-matrix-option-${Ue}-${et.value}`,children:[et.label," ",e.jsxs("span",{className:"text-muted-foreground",children:["(",et.score,")"]})]},et.value))})]})]},Le.name)),e.jsxs("div",{className:"space-y-2 border-t border-border pt-6",children:[e.jsxs(le,{htmlFor:"kt-matrix-remarks",className:"text-sm font-medium",children:["Remarks ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ks,{id:"kt-matrix-remarks",placeholder:"Enter remarks...",className:"min-h-[96px] resize-y text-sm leading-relaxed",value:f,onChange:Le=>p(Le.target.value),"data-testid":"onboarding-kt-matrix-remarks-textarea"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(le,{className:"text-sm font-medium",children:["Recommendation ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:h,onValueChange:x,children:[e.jsx(_t,{"data-testid":"onboarding-kt-matrix-recommendation-select",children:e.jsx(Et,{placeholder:"Select recommendation"})}),e.jsxs(Tt,{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(te,{variant:"outline",onClick:()=>o(!1),"data-testid":"onboarding-kt-matrix-cancel",children:"Cancel"}),e.jsx(te,{onClick:N,disabled:v||n.length===0||Object.keys(d).lengthC("overallScore",Le),children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-level2-overall-score-select",children:e.jsx(Et,{placeholder:"Select score"})}),e.jsxs(Tt,{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.jsx(Xo,{}),r.length===0&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800",children:"Level 2 feedback configuration is not available. Configure it in Master > Interview Configurations."}),(r||[]).map((Le,Ue)=>e.jsxs("div",{children:[e.jsxs(le,{children:[Le.label,Le.isRequired&&e.jsx("span",{className:"text-red-500",children:"*"})]}),Le.type==="select"?e.jsxs(Rt,{value:b[Le.itemKey]||"",onValueChange:et=>C(Le.itemKey,et),children:[e.jsx(_t,{className:"mt-2",children:e.jsx(Et,{placeholder:`Select ${Le.label}...`})}),e.jsx(Tt,{children:(Le.options||[]).map((et,dt)=>e.jsx(Pe,{value:et.optionValue||et.value,children:et.optionLabel||et.label},dt))})]}):Le.type==="number"?e.jsx(it,{type:"number",className:"mt-2",value:b[Le.itemKey]||"",onChange:et=>C(Le.itemKey,et.target.value)}):e.jsx(Ks,{placeholder:`Enter ${Le.label.toLowerCase()}...`,className:"mt-2",rows:3,value:b[Le.itemKey]||"",onChange:et=>C(Le.itemKey,et.target.value)})]},Le.itemKey||Ue)),e.jsxs("div",{children:[e.jsxs(le,{children:["Recommendation ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:S,onValueChange:D,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-level2-recommendation-select",children:e.jsx(Et,{placeholder:"Select recommendation"})}),e.jsxs(Tt,{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 gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>j(!1),"data-testid":"onboarding-level2-feedback-cancel",children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-black hover:bg-zinc-800 text-white",onClick:_,disabled:A||r.length===0,"data-testid":"onboarding-level2-feedback-submit",children:A?"Submitting...":"Submit Feedback"})]})]})]})}),e.jsx(ms,{open:E,onOpenChange:q,children:e.jsxs(us,{className:"max-w-2xl max-h-[90vh] overflow-y-auto","data-testid":"onboarding-feedback-details-modal",children:[e.jsx(ys,{children:e.jsx(gs,{children:"Interview Feedback Details"})}),O&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 bg-slate-50 p-4 rounded-lg",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-500",children:"Interviewer"}),e.jsx("p",{className:"font-semibold","data-testid":"onboarding-feedback-details-interviewer",children:(Qs=O.evaluator)==null?void 0:Qs.fullName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-500",children:"Role"}),e.jsx("p",{"data-testid":"onboarding-feedback-details-role",children:((ie=(Xs=O.evaluator)==null?void 0:Xs.role)==null?void 0:ie.roleName)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-500",children:((nt=O.interview)==null?void 0:nt.level)===1?"Score (KT Matrix)":"Overall Score"}),e.jsx("p",{className:"font-bold text-lg","data-testid":"onboarding-feedback-details-score",children:O.ktMatrixScore?`${O.ktMatrixScore}/${((fe=O.interview)==null?void 0:fe.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(we,{variant:(Ae=O.recommendation)!=null&&Ae.toLowerCase().includes("reject")?"destructive":(Fe=O.recommendation)!=null&&Fe.toLowerCase().includes("hold")?"secondary":"default","data-testid":"onboarding-feedback-details-recommendation",children:O.recommendation||"N/A"})]})]}),e.jsx(Xo,{}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold mb-3",children:"Detailed Feedback"}),((Ke=O.feedbackDetails)==null?void 0:Ke.length)>0?e.jsx("div",{className:"space-y-4",children:O.feedbackDetails.map((Le,Ue)=>e.jsxs("div",{className:"border-b last:border-0 pb-3 last:pb-0","data-testid":`onboarding-feedback-detail-item-${Ue}`,children:[e.jsx("p",{className:"font-medium text-slate-900",children:Le.feedbackType}),e.jsx("p",{className:"text-slate-700 mt-1 whitespace-pre-wrap text-sm",children:Le.comments})]},Ue))}):e.jsx("p",{className:"text-slate-500 italic",children:"No detailed feedback available."})]})]})]})}),e.jsx(ms,{open:P,onOpenChange:L,children:e.jsxs(us,{className:"max-w-2xl max-h-[90vh] overflow-y-auto","data-testid":"onboarding-level3-feedback-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Level 3 Interview Feedback"}),e.jsx(ws,{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(le,{children:["Interview Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{type:"date",className:"mt-2",value:$.interviewDate||fs,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(le,{children:["Interviewer Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{placeholder:"Enter your name",className:"mt-2",value:$.interviewerName||Vs,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(le,{children:["Overall Performance Score ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:$.overallScore,onValueChange:Le=>Z("overallScore",Le),children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-level3-overall-score-select",children:e.jsx(Et,{placeholder:"Select score"})}),e.jsxs(Tt,{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.jsx(Xo,{}),a.length===0&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800",children:"Level 3 feedback configuration is not available. Configure it in Master > Interview Configurations."}),(a||[]).map((Le,Ue)=>e.jsxs("div",{children:[e.jsxs(le,{children:[Le.label,Le.isRequired&&e.jsx("span",{className:"text-red-500",children:"*"})]}),Le.type==="select"?e.jsxs(Rt,{value:$[Le.itemKey]||"",onValueChange:et=>Z(Le.itemKey,et),children:[e.jsx(_t,{className:"mt-2",children:e.jsx(Et,{placeholder:`Select ${Le.label}...`})}),e.jsx(Tt,{children:(Le.options||[]).map((et,dt)=>e.jsx(Pe,{value:et.optionValue||et.value,children:et.optionLabel||et.label},dt))})]}):Le.type==="number"?e.jsx(it,{type:"number",className:"mt-2",value:$[Le.itemKey]||"",onChange:et=>Z(Le.itemKey,et.target.value)}):e.jsx(Ks,{placeholder:`Enter ${Le.label.toLowerCase()}...`,className:"mt-2",rows:3,value:$[Le.itemKey]||"",onChange:et=>Z(Le.itemKey,et.target.value)})]},Le.itemKey||Ue)),e.jsxs("div",{children:[e.jsxs(le,{children:["Recommendation ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:Q,onValueChange:W,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-level3-recommendation-select",children:e.jsx(Et,{placeholder:"Select recommendation"})}),e.jsxs(Tt,{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 gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>L(!1),"data-testid":"onboarding-level3-feedback-cancel",children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-black hover:bg-zinc-800 text-white",onClick:U,disabled:M||a.length===0,"data-testid":"onboarding-level3-feedback-submit",children:M?"Submitting...":"Submit Feedback"})]})]})]})}),e.jsx(ms,{open:z,onOpenChange:Le=>{T(Le),Le||I(!1)},children:e.jsxs(us,{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(ys,{className:"pb-4",children:[e.jsxs(gs,{className:"text-xl font-bold flex items-center gap-2",children:[e.jsx(ks,{className:"w-5 h-5 text-re-red"}),"Documents - ",K||"General"]}),e.jsx(ws,{className:"text-slate-500",children:"View and manage documents uploaded for this stage."})]}),F?e.jsxs("div",{className:"space-y-6 py-4","data-testid":"onboarding-documents-upload-form",children:[e.jsx("div",{className:"bg-slate-50/50 p-4 sm:p-6 rounded-2xl border border-slate-200",children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(le,{className:"text-slate-700 font-semibold px-1",children:["Document Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{type:"text",placeholder:"Enter document name",value:re,onChange:Le=>ae(Le.target.value),className:"bg-white border-slate-200 h-12 rounded-xl focus:ring-re-red shadow-sm","data-testid":"onboarding-documents-name-input"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(le,{className:"text-slate-700 font-semibold px-1",children:["Select File ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{type:"file",className:"bg-white border-slate-200 h-12 rounded-xl focus:ring-re-red shadow-sm file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-sm file:font-semibold file:bg-red-50 file:text-re-red-hover hover:file:bg-red-50 cursor-pointer",onChange:Le=>{const Ue=Le.target.files?Le.target.files[0]:null;if(ue(Ue),Ue){const et=Ue.name.replace(/\.[^/.]+$/,"");ae(et)}},"data-testid":"onboarding-documents-file-input"})]})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 pt-4",children:[e.jsx(te,{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:()=>I(!1),disabled:ye,"data-testid":"onboarding-documents-upload-cancel",children:"Cancel"}),e.jsx(te,{className:"flex-1 order-1 sm:order-2 bg-re-red hover:bg-re-red-hover text-white font-bold py-3 sm:py-5 rounded-xl shadow-lg shadow-re-red/15 transition-all hover:scale-[1.01] active:scale-[0.99]",onClick:async()=>{await ce(),I(!1)},disabled:!je||!re||ye,"data-testid":"onboarding-documents-upload-submit",children:ye?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(vr,{className:"w-5 h-5"}),"Confirm Upload"]})})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 space-y-4",children:[G(K||"").length>0?e.jsx("div",{className:"custom-scrollbar-x-slim flex-1 overflow-auto border rounded-lg border-slate-200","data-testid":"onboarding-documents-table-container",children:e.jsxs(Ms,{className:"w-full table-auto",children:[e.jsx(Fs,{className:"bg-slate-50/80 sticky top-0 z-10",children:e.jsxs(lt,{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(Bs,{children:G(K||"").map((Le,Ue)=>{var et,dt;return e.jsxs(lt,{className:"hover:bg-slate-50/50 transition-colors","data-testid":`onboarding-document-row-${Ue}`,children:[e.jsx(oe,{className:"py-3",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(ks,{className:"w-4 h-4 text-slate-400 shrink-0"}),e.jsx("span",{className:"truncate font-medium text-slate-700",title:Le.fileName,"data-testid":`onboarding-document-name-${Ue}`,children:Le.fileName})]})}),e.jsx(oe,{className:"py-3",children:e.jsx(we,{variant:"outline",className:"capitalize whitespace-nowrap font-normal border-slate-200 bg-white","data-testid":`onboarding-document-type-${Ue}`,children:((et=Le.documentType)==null?void 0:et.toLowerCase())||"Other"})}),e.jsx(oe,{className:"py-3 whitespace-nowrap text-slate-600",children:Qt(Le.createdAt)}),e.jsx(oe,{className:"py-3 text-slate-600",children:((dt=Le.uploader)==null?void 0:dt.fullName)||(Le.uploadedBy?"System User":"Applicant")}),e.jsx(oe,{className:"text-right py-3",children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(te,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 rounded-full",onClick:()=>{V(Le),Y(!0)},"data-testid":`onboarding-document-preview-${Ue}`,children:e.jsx(un,{className:"w-4 h-4"})}),e.jsx(te,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-re-red hover:bg-red-50 rounded-full",onClick:()=>{window.open(`https://dealeronboarding-uat.royalenfield.com/api/${Le.filePath}`,"_blank")},"data-testid":`onboarding-document-download-${Ue}`,children:e.jsx(fi,{className:"w-4 h-4"})})]})})]},Le.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(ks,{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(te,{className:"flex-1 bg-re-red hover:bg-re-red-hover text-white font-bold py-3 sm:py-5 rounded-xl shadow-lg shadow-re-red/15 transition-all hover:scale-[1.01] active:scale-[0.99]",onClick:()=>I(!0),"data-testid":"onboarding-documents-upload-button",children:[e.jsx(vr,{className:"w-5 h-5 mr-3"}),"Upload Document"]}),e.jsx(te,{variant:"outline",className:"flex-1 sm:flex-none py-3 sm:py-5 px-8 rounded-xl border-slate-200 font-semibold text-slate-600 hover:bg-slate-50",onClick:()=>T(!1),"data-testid":"onboarding-documents-close-button",children:"Close"})]})]})]})}),e.jsx(ho,{isOpen:Me,onClose:()=>Y(!1),document:ut}),e.jsx(ms,{open:jt,onOpenChange:ft,children:e.jsxs(us,{className:"max-w-md p-0 overflow-hidden border-none shadow-2xl rounded-3xl","data-testid":"onboarding-fdd-finalize-modal",children:[e.jsxs("div",{className:"bg-slate-950 p-8 flex items-center justify-center relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-re-red/20 to-transparent"}),e.jsx("div",{className:"w-20 h-20 bg-re-red/20 rounded-full flex items-center justify-center animate-pulse relative z-10 shadow-[0_0_40px_rgba(218,41,28,0.2)]",children:e.jsx(so,{className:"w-10 h-10 text-re-red"})})]}),e.jsxs("div",{className:"p-8 space-y-6 bg-white",children:[e.jsxs(ys,{children:[e.jsx(gs,{className:"text-2xl font-black text-slate-900 text-center tracking-tight",children:"Finalize FDD Audit"}),e.jsxs(ws,{className:"text-slate-500 text-center pt-2 leading-relaxed text-sm font-medium",children:["You are about to submit your final findings. This action will ",e.jsx("span",{className:"font-bold text-slate-900 underline decoration-re-red decoration-2",children:"lock the audit session"})," and trigger the LOI approval workflow."]})]}),e.jsxs("div",{className:"space-y-4",children:[(X==null?void 0:X.role)!=="FDD"&&(X==null?void 0:X.roleCode)!=="FDD"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(le,{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(Le=>e.jsx(te,{variant:Ce===Le?"default":"outline",className:Nt("flex-1 h-10 font-bold text-[9px] uppercase tracking-wider rounded-xl transition-all",Ce===Le&&Le==="Recommended"&&"bg-emerald-600 hover:bg-emerald-700",Ce===Le&&Le==="Qualified with Observations"&&"bg-red-500 hover:bg-re-red",Ce===Le&&Le==="Not Recommended"&&"bg-red-600 hover:bg-red-700"),onClick:()=>xe(Le),"data-testid":`onboarding-fdd-recommendation-${Le.replace(/\s+/g,"-").toLowerCase()}`,children:Le},Le))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] font-black uppercase tracking-widest text-slate-400",children:"Findings Summary"}),e.jsx(Ks,{placeholder:"Summarize key financial findings or discrepancies...",className:"min-h-[100px] rounded-xl border-slate-200 focus:ring-re-red text-sm",value:We,onChange:Le=>Be(Le.target.value),"data-testid":"onboarding-fdd-findings-textarea"})]})]}),e.jsxs("div",{className:"bg-red-50 p-4 rounded-2xl flex gap-3 border border-red-100",children:[e.jsx(qa,{className:"w-5 h-5 text-re-red shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-red-800 font-medium italic",children:"Ensure the final PDF report is uploaded first. This satisfies the FDD statutory requirement."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 pt-2",children:[e.jsx(te,{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:()=>ft(!1),disabled:rt,"data-testid":"onboarding-fdd-finalize-cancel",children:"Cancel"}),e.jsx(te,{className:"w-full sm:flex-1 h-12 rounded-2xl font-bold bg-slate-950 hover:bg-slate-900 text-white shadow-lg shadow-slate-200 transition-all active:scale-95 border-b-4 border-re-red",disabled:rt||!We,"data-testid":"onboarding-fdd-finalize-submit",onClick:async()=>{try{ht(!0),await ps.submitStageDecision({applicationId:s.id,stageCode:"FDD_VERIFICATION",decision:"Approved",remarks:(X==null?void 0:X.role)==="FDD"||(X==null?void 0:X.roleCode)==="FDD"?`Findings: ${We}`:`[RECOMMENDATION: ${Ce}] Findings: ${We}`,nextStatus:"LOI In Progress",nextProgress:65}),J.success("FDD Audit finalized and submitted."),ft(!1),ge()}catch{J.error("Submission failed")}finally{ht(!1)}},children:rt?e.jsx(cs,{className:"w-5 h-5 animate-spin"}):"Confirm & Submit"})]})]})]})}),e.jsx(ms,{open:Je,onOpenChange:mt,children:e.jsxs(us,{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(mk,{className:"w-10 h-10 text-red-500"})})]}),e.jsxs("div",{className:"p-8 space-y-6 bg-white text-center",children:[e.jsxs(ys,{children:[e.jsx(gs,{className:"text-2xl font-black text-slate-900 tracking-tight",children:"Flag Non-Responsive"}),e.jsx(ws,{className:"text-slate-500 pt-2 leading-relaxed text-sm font-medium",children:"Are you sure you want to flag this applicant? This will notify the DD Admin that the audit cannot proceed due to applicant's non-cooperation."})]}),e.jsxs("div",{className:"bg-red-50 p-4 rounded-2xl flex gap-3 border border-red-100",children:[e.jsx(sn,{className:"w-5 h-5 text-red-600 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-red-800 text-left font-medium",children:'"Applicant is unresponsive to multiple queries and financial document requests."'})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 pt-2",children:[e.jsx(te,{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:()=>mt(!1),disabled:de,"data-testid":"onboarding-fdd-flag-cancel",children:"Go Back"}),e.jsx(te,{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:de,"data-testid":"onboarding-fdd-flag-submit",onClick:async()=>{try{at(!0),await ps.submitStageDecision({applicationId:s.id,stageCode:"FDD_VERIFICATION",decision:"Rejected",remarks:"Applicant is non-responsive to FDD queries."}),J.error("Applicant flagged as non-responsive."),mt(!1),ge()}catch{J.error("Action failed")}finally{at(!1)}},children:de?e.jsx(cs,{className:"w-5 h-5 animate-spin"}):"Confirm Flag"})]})]})]})}),e.jsx(ms,{open:ot,onOpenChange:ke,children:e.jsxs(us,{className:"max-w-md p-0 overflow-hidden rounded-3xl border-none shadow-2xl","data-testid":"onboarding-firm-type-modal",children:[e.jsxs("div",{className:"bg-re-red p-8 text-white",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-white/20 flex items-center justify-center mb-6 backdrop-blur-sm border border-white/30 shadow-inner",children:e.jsx(to,{className:"w-8 h-8 text-white"})}),e.jsx("h3",{className:"text-2xl font-black tracking-tight mb-2",children:"Update Firm Type"}),e.jsx("p",{className:"text-red-100/80 text-sm font-medium leading-relaxed",children:"Select the proposed legal constitution for this dealership application."})]}),e.jsxs("div",{className:"p-8 space-y-6 bg-white",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(le,{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(Rt,{value:Zt,onValueChange:Bt,children:[e.jsx(_t,{className:"h-12 rounded-xl border-slate-200 focus:ring-re-red","data-testid":"onboarding-firm-type-select",children:e.jsx(Et,{placeholder:"Select Firm Type"})}),e.jsxs(Tt,{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(te,{variant:"outline",className:"flex-1 h-12 rounded-xl font-bold text-slate-600 border-slate-200",onClick:()=>ke(!1),disabled:_s,"data-testid":"onboarding-firm-type-cancel",children:"Cancel"}),e.jsx(te,{className:"flex-1 h-12 rounded-xl font-bold bg-re-red hover:bg-re-red-hover text-white shadow-lg shadow-red-200 transition-all active:scale-95",disabled:_s||!Zt,onClick:Us,"data-testid":"onboarding-firm-type-submit",children:_s?e.jsx(cs,{className:"w-5 h-5 animate-spin"}):"Update Type"})]})]})]})})]})}var UU={};function VU({application:t,documents:s,setPreviewDoc:n,setShowPreviewModal:r,setIsUploading:a,fetchApplication:i,refreshDocuments:o}){var N,v;const d=(t==null?void 0:t.fddAssignments)||[],m=((N=t==null?void 0:t.participants)==null?void 0:N.filter(w=>{var j,b,C,S;return((j=w.user)==null?void 0:j.role)==="FDD"||((b=w.user)==null?void 0:b.roleCode)==="FDD"||((S=(C=w.user)==null?void 0:C.allRoles)==null?void 0:S.includes("FDD"))}))||[],f=d.length>0||m.length>0,p=(v=m[0])==null?void 0:v.user,h=[{type:"Bank Statement",label:"Bank Statements"},{type:"Income Tax Returns (ITR)",label:"ITR (Last 3 Years)"},{type:"CIBIL Report",label:"CIBIL / Credit Reports"},{type:"Property Documents",label:"Property Documents"},{type:"Business Valuation Report",label:"Valuation Reports"},{type:"FDD Final Audit Report",label:"Final Audit Report"}],x=w=>{const j=w.toLowerCase();return(s||[]).find(b=>{const C=(b.documentType||"").toLowerCase(),S=(b.fileName||"").toLowerCase();return!!(C===j||j.includes("itr")&&(C.includes("itr")||S.includes("itr"))||j.includes("bank statement")&&(C.includes("bank")||S.includes("bank"))||j.includes("cibil")&&(C.includes("cibil")||S.includes("cibil")||C.includes("credit")))})},u=w=>{const j=(w.documentType||"").toLowerCase();return(w.stage||"").toLowerCase()==="fdd"||j.includes("report")||j.includes("itr")||j.includes("bank")||j.includes("cibil")||j.includes("valuation")};return!f&&!["FDD Verification","LOI In Progress","Payment Pending"].includes(t.status)?e.jsx("div",{className:"space-y-6","data-testid":"onboarding-fdd-no-assignment",children:e.jsxs("div",{className:"flex flex-col items-center justify-center p-12 bg-slate-50 rounded-2xl border-2 border-dashed border-slate-200",children:[e.jsx(so,{className:"w-12 h-12 text-slate-300 mb-4"}),e.jsx("h3",{className:"text-slate-900 font-semibold uppercase tracking-widest text-xs",children:"No FDD Assignment"}),e.jsx("p",{className:"text-slate-500 text-[10px] text-center max-w-xs mt-2 font-medium leading-relaxed uppercase tracking-tight",children:"The Financial Due Diligence process has not been initiated for this application yet."})]})}):e.jsxs("div",{className:"space-y-8","data-testid":"onboarding-fdd-audit-content",children:[f&&e.jsx("div",{className:"flex items-center justify-between p-4 bg-slate-50 border border-slate-200 rounded-xl mb-6","data-testid":"onboarding-fdd-assignment-banner",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-red-50 rounded-lg",children:e.jsx(so,{className:"w-5 h-5 text-re-red"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-slate-900",children:"FDD Assignment Active"}),p&&e.jsxs("p",{className:"text-xs text-slate-500 font-medium","data-testid":"onboarding-fdd-assigned-user",children:["Assigned to: ",p.name]})]})]})}),e.jsxs(_e,{className:"border-slate-200 shadow-sm overflow-hidden rounded-2xl","data-testid":"onboarding-fdd-checklist-card",children:[e.jsx(Xe,{className:"bg-slate-50/50 border-b border-slate-100 py-4",children:e.jsxs(st,{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(sc,{className:"w-4 h-4"})," Financial Artefacts Checklist"]}),e.jsx(we,{variant:"outline",className:"text-[10px] bg-white",children:"Verify before sign-off"})]})}),e.jsx(Oe,{className:"p-0",children:e.jsx("div",{className:"divide-y divide-slate-100",children:h.map((w,j)=>{const b=x(w.type);return e.jsxs("div",{className:"flex items-center justify-between p-4 px-6 hover:bg-slate-50/50 transition-colors","data-testid":`onboarding-fdd-checklist-item-${j}`,children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:Nt("w-8 h-8 rounded-lg flex items-center justify-center",b?"bg-emerald-50 text-emerald-600":"bg-slate-50 text-slate-300"),children:b?e.jsx(ln,{className:"w-5 h-5"}):e.jsx(sn,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-slate-800",children:w.label}),e.jsx("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-tighter","data-testid":`onboarding-fdd-checklist-status-${j}`,children:b?`Uploaded: ${Qt(b.createdAt)}`:"Missing in Documentation"})]})]}),b?e.jsxs(te,{variant:"ghost",size:"sm",className:"h-8 text-blue-600 font-black text-[10px] uppercase tracking-widest hover:bg-blue-50",onClick:()=>{n(b),r(!0)},"data-testid":`onboarding-fdd-checklist-preview-${j}`,children:[e.jsx(un,{className:"w-4 h-4 mr-1"})," Preview"]}):e.jsxs(te,{variant:"outline",size:"sm",className:"h-8 border-slate-200 text-slate-500 font-black text-[10px] uppercase tracking-widest hover:bg-slate-50 hover:text-blue-600","data-testid":`onboarding-fdd-checklist-upload-${j}`,onClick:()=>{const C=document.createElement("input");C.type="file",C.onchange=async S=>{var _;const D=S.target.files[0];if(D)try{a(!0);const A=new FormData;A.append("file",D),A.append("documentType",w.type),A.append("stage","FDD"),A.append("applicationId",t.id);const E=await ps.uploadDocument(t.id,A);w.type==="FDD Final Audit Report"&&(await ps.submitFddReport({applicationId:t.id,reportDocumentId:((_=E.data)==null?void 0:_.id)||E.id,findings:"Final Audit Report uploaded via checklist.",recommendation:"REVIEW_PENDING"}),i()),J.success(`${w.label} uploaded successfully`),o()}catch{J.error("Upload failed")}finally{a(!1)}},C.click()},children:[e.jsx(vr,{className:"w-4 h-4 mr-1 text-slate-300"})," Upload"]})]},w.type)})})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-900",children:"Supporting Audit Documents"}),e.jsxs(we,{variant:"outline",className:"bg-slate-50 text-slate-500 border-slate-200","data-testid":"onboarding-fdd-support-docs-count",children:[(s||[]).filter(u).length," Document(s)"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4","data-testid":"onboarding-fdd-support-docs-grid",children:[(s||[]).filter(u).map((w,j)=>e.jsxs("div",{className:"group bg-white border border-slate-200 rounded-xl p-4 flex items-center justify-between hover:border-red-300 transition-all hover:shadow-md","data-testid":`onboarding-fdd-support-doc-${j}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-slate-50 flex items-center justify-center",children:e.jsx(ks,{className:"w-5 h-5 text-slate-400"})}),e.jsxs("div",{className:"overflow-hidden",children:[e.jsx("p",{className:"text-slate-900 font-bold text-sm truncate max-w-[150px]",title:w.fileName,"data-testid":`onboarding-fdd-support-doc-name-${j}`,children:w.fileName}),e.jsx("p",{className:"text-slate-500 text-[10px] font-medium uppercase",children:w.documentType})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(te,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-re-red hover:bg-red-50",onClick:()=>{const b=UU.NEXT_PUBLIC_API_URL||"http://localhost:5000";window.open(`${b}/${w.filePath}`,"_blank")},"data-testid":`onboarding-fdd-support-doc-download-${j}`,children:e.jsx(fi,{className:"w-4 h-4"})}),e.jsx(te,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-re-red hover:bg-red-50",onClick:()=>{n(w),r(!0)},"data-testid":`onboarding-fdd-support-doc-preview-${j}`,children:e.jsx(un,{className:"w-4 h-4"})})]})]},w.id)),(s||[]).filter(u).length===0&&e.jsx("div",{className:"col-span-full p-8 text-center bg-slate-50 rounded-xl border border-dashed border-slate-200","data-testid":"onboarding-fdd-support-docs-empty",children:e.jsx("p",{className:"text-slate-400 text-sm",children:"No supporting audit documents uploaded yet."})})]})]})]})}function HU(t){const s=String(t||"").toUpperCase();return s.includes("REJECT")||s.includes("DELET")||s.includes("DISQUALIF")?"border-red-200 bg-red-50/90 text-red-800":s==="CREATED"||s.includes("APPROV")||s.includes("COMPLETE")?"border-emerald-200 bg-emerald-50/90 text-emerald-900":s.includes("DOCUMENT")||s.includes("UPLOAD")||s.includes("ATTACHMENT")?"border-sky-200 bg-sky-50/80 text-sky-900":s.includes("PAYMENT")||s.includes("SECURITY")||s.includes("DEPOSIT")?"border-violet-200 bg-violet-50/80 text-violet-900":s.includes("FDD")||s.includes("QUESTIONNAIRE")||s.includes("INTERVIEW")?"border-red-200 bg-red-50/80 text-red-900":"border-slate-200 bg-slate-50 text-slate-700"}function bf(t,s){return t==null||s==null?!1:String(t).trim()===String(s).trim()}function u_(t){return String(t??"").trim().toLowerCase().replace(/\s+/g," ")}function Am(t){const s=u_(t);return s?s==="scheduled"||s==="rescheduled"||s==="pending"||s==="in progress"||s==="inprogress":!1}function WU(t){return u_(t)==="completed"}function zg(t,s){var n;return!s||!((n=t==null?void 0:t.participants)!=null&&n.length)?!1:t.participants.some(r=>{var a;return bf(r.userId,s)||bf((a=r.user)==null?void 0:a.id,s)})}function GU(t){const s=String(t??"").trim();return{"Level 1 Interview Pending":1,"Level 1 Recommended":1,"Level 2 Interview Pending":2,"Level 2 Recommended":2,"Level 3 Interview Pending":3,"Level 3 Recommended":3}[s]}function DS(t){return String(t??"").trim().toLowerCase().replace(/[_\s-]+/g,"")}function KU(t,s){var d,m;if(!t)return!1;const n=["Super Admin","DD Admin"];if(n.includes(String(t.role??""))||n.includes(String(t.roleCode??"")))return!0;const a={1:["DD-ZM","DD ZM","RBM"],2:["DD Lead","ZBH"],3:["NBH","DD Head"]}[s];if(!(a!=null&&a.length))return!1;const i=a.map(DS),o=[t.role,t.roleCode,t.roleName,(d=t.role)==null?void 0:d.roleCode,(m=t.role)==null?void 0:m.roleName].filter(Boolean).map(DS);for(const f of o)if(f){for(const p of i)if(p&&(f===p||f.includes(p)||p.includes(f)))return!0}return!1}function YU({application:t,interviews:s,currentUser:n,getDeposit:r,eorProgress:a}){var C,S,D;const i=Array.isArray(s)?s:[],o=GU(t==null?void 0:t.status),d=(o!=null?i.find(_=>Am(_.status)&&zg(_,n==null?void 0:n.id)&&Number(_.level)===o):void 0)??i.find(_=>Am(_.status)&&zg(_,n==null?void 0:n.id)),m=o!=null&&n&&KU(n,o)?i.find(_=>Number(_.level)===o&&Am(_.status)):void 0,f=d??m,p=i.find(_=>zg(_,n==null?void 0:n.id)),h=((C=f==null?void 0:f.evaluations)==null?void 0:C.find(_=>bf(_.evaluatorId,n==null?void 0:n.id)))??((S=p==null?void 0:p.evaluations)==null?void 0:S.find(_=>bf(_.evaluatorId,n==null?void 0:n.id))),x=_=>i.some(A=>Number(A.level)===_&&WU(A.status)),u=_=>i.some(A=>Number(A.level)===_&&Am(A.status)),N=!!h,v={"Level 1 Interview Pending":"INTERVIEW_LEVEL_1","Level 2 Interview Pending":"INTERVIEW_LEVEL_2","Level 2 Recommended":"INTERVIEW_LEVEL_2","Level 3 Interview Pending":"INTERVIEW_LEVEL_3","LOI In Progress":"LOI_APPROVAL","LOA Pending":"LOA_APPROVAL"},w=v[t==null?void 0:t.status],j=(D=t==null?void 0:t.stageApprovals)==null?void 0:D.find(_=>_.stageCode===w&&String(_.actorUserId)===String(n==null?void 0:n.id));return{activeInterviewForUser:f,lastInterviewForUser:p,currentUserEvaluation:h,hasSubmittedFeedback:N,currentUserStageAction:j,isInterviewCompleted:x,isInterviewActive:u,permissions:(()=>{var U,M,z,T,F;if(!t||!n)return{canApprove:!1,canReject:!1,canSchedule:!1,canAssign:!1,isLoaLocked:!1,isSecurityDetailsLocked:!1,showDecisionMessage:!1};const _=["DD Admin","Super Admin","NBH","DD Lead","DD Head","Finance","Finance Admin","FDD","ZBH","RBM"].includes(n.role),A=["Level 3 Approved","FDD Verification","LOI In Progress","Security Deposit","Security Details","Payment Pending","LOI Issued","Statutory LOI Ack","Architecture Team Assigned","Architecture Document Upload","Architecture Team Completion","Statutory GST","Statutory PAN","Statutory Nodal","Statutory Check","Statutory Partnership","Statutory Firm Reg","Statutory Rental","Statutory Virtual Code","Statutory Domain","Statutory MSD","LOA Pending","EOR In Progress","EOR Complete","Inauguration","Approved"].includes(t.status),E=t.status==="LOA Pending"&&((U=r("FIRST_FILL"))==null?void 0:U.status)!=="Verified",q=["Security Deposit","Security Details","Payment Pending"].includes(t.status)&&((M=r("SECURITY_DEPOSIT"))==null?void 0:M.status)!=="Verified",O=t.status==="Onboarded"||t.status==="Rejected",R=(z=t.stageApprovals)==null?void 0:z.some(I=>I.stageCode==="LOI_APPROVAL"&&I.actorRole==="DD Head"&&I.decision==="Approved"),P=(T=t.stageApprovals)==null?void 0:T.some(I=>I.stageCode==="LOA_APPROVAL"&&I.actorRole==="DD Head"&&I.decision==="Approved");let L=!0;["Super Admin","DD Admin","DD Lead","DD Head"].includes(n.role)||((t.status==="FDD Verification"||t.status==="Level 3 Approved")&&(L=!1),t.status==="LOI In Progress"&&(L=n.role==="NBH"?!!R:n.role==="DD Head"),t.status==="LOA Pending"&&(L=n.role==="NBH"?!!P:n.role==="DD Head"));const $=!!((F=t.stageApprovals)!=null&&F.find(I=>v[t.status]===I.stageCode&&String(I.actorUserId)===String(n.id))),Z=["Approved","Rejected","Selected"].includes((h==null?void 0:h.decision)||(h==null?void 0:h.recommendation)||""),Q=(f?Z:!1)||$,W=!O&&!Q&&_&&A&&L&&(!["EOR In Progress","Inauguration","Approved"].includes(t.status)||a===100);return{canApprove:W&&!E&&!q,canReject:W&&!E,isLoaLocked:E,isSecurityDetailsLocked:q,showDecisionMessage:Q&&(!A||$),canSchedule:["DD Admin","Super Admin","DD AM","ASM"].includes(n.role)&&!O&&![1,2,3].every(I=>i.some(K=>K.level===I)),canAssign:["DD Admin","Super Admin","DD AM"].includes(n.role)}})()}}function ZU({initialTab:t="questionnaire"}){const[s,n]=g.useState(!1),[r,a]=g.useState(!1),[i,o]=g.useState(""),[d,m]=g.useState(t),[f,p]=g.useState(!1),[h,x]=g.useState(!1),[u,N]=g.useState(!1),[v,w]=g.useState(!1),[j,b]=g.useState(""),[C,S]=g.useState([]),[D,_]=g.useState(!1),[A,E]=g.useState(!1),[q,O]=g.useState(""),[R,P]=g.useState(null),[L,$]=g.useState(!1),[Z,Q]=g.useState(!1),[W,U]=g.useState(!1),[M,z]=g.useState(!1),[T,F]=g.useState(!1),[I,K]=g.useState(null),[G,V]=g.useState("virtual"),[Y,re]=g.useState(""),[ae,ue]=g.useState({}),[ye,ce]=g.useState([]),[je,Me]=g.useState(""),[ut,jt]=g.useState("contributor"),[ft,X]=g.useState(""),[Ce,xe]=g.useState("level1"),[We,Be]=g.useState(""),[rt,ht]=g.useState(""),[ge,Je]=g.useState(!1),[mt,de]=g.useState(null),[at,ot]=g.useState(""),[ke,Zt]=g.useState(null),[Bt,_s]=g.useState(!1),[Us,fs]=g.useState(null),[Vs,Qs]=g.useState(!1),[Xs,ie]=g.useState(""),[nt,fe]=g.useState(!1),[Ae,Fe]=g.useState({}),[Ke,Le]=g.useState(!1),[Ue,et]=g.useState([]),[dt,ss]=g.useState(!1),[Wt,kt]=g.useState(!1),[wt,Os]=g.useState(!1),[as,Se]=g.useState(""),[be,pt]=g.useState(!1),[Ve,bt]=g.useState(!1),[gt,rs]=g.useState(""),[is,Ts]=g.useState(""),[Ws,nn]=g.useState(!1),[Ee,$t]=g.useState(!1),[Xt,Cs]=g.useState([]),[Mt,ze]=g.useState([]),[xt,yt]=g.useState(""),[Ot,Pt]=g.useState(!1),[Jt,bs]=g.useState(!1),[ns,Ds]=g.useState(!1),[ts,js]=g.useState(!1),[tn,vn]=g.useState({}),[jn,xn]=g.useState({}),[gn,Ye]=g.useState(""),[qt,Ze]=g.useState("Approve"),[Gt,St]=g.useState(!1),[qn,Er]=g.useState(null),[Fr,wn]=g.useState(!1),[Js,Sa]=g.useState(!1),[It,As]=g.useState("Recommended"),[_r,ca]=g.useState(""),[Ca,Yr]=g.useState(!1),[Nr,kn]=g.useState(!1),[Sn,sr]=g.useState({}),[wr,Sr]=g.useState("Approve"),[yn,Dn]=g.useState(!1),[Aa,ka]=g.useState({}),[qi,xi]=g.useState("Approve"),[gi,bl]=g.useState(!1),[jl,da]=g.useState(null),[Da,ua]=g.useState(!1);return{showFirmTypeModal:s,setShowFirmTypeModal:n,updatingFirmType:r,setUpdatingFirmType:a,tempFirmType:i,setTempFirmType:o,activeTab:d,setActiveTab:m,showApproveModal:f,setShowApproveModal:p,showOnboardModal:h,setShowOnboardModal:x,isOnboarding:u,setIsOnboarding:N,showRejectModal:v,setShowRejectModal:w,rejectionReason:j,setRejectionReason:b,scheduledInterviewParticipants:C,setScheduledInterviewParticipants:S,showScheduleModal:D,setShowScheduleModal:_,showCancelInterviewModal:A,setShowCancelInterviewModal:E,interviewIdToCancel:q,setInterviewIdToCancel:O,interviewToReschedule:R,setInterviewToReschedule:P,showKTMatrixModal:L,setShowKTMatrixModal:$,showLevel2FeedbackModal:Z,setShowLevel2FeedbackModal:Q,showLevel3FeedbackModal:W,setShowLevel3FeedbackModal:U,showDocumentsModal:M,setShowDocumentsModal:z,showAssignModal:T,setShowAssignModal:F,selectedStage:I,setSelectedStage:K,interviewMode:G,setInterviewMode:V,approvalRemark:Y,setApprovalRemark:re,expandedBranches:ae,setExpandedBranches:ue,users:ye,setUsers:ce,selectedUser:je,setSelectedUser:Me,participantType:ut,setParticipantType:jt,interviewDate:ft,setInterviewDate:X,interviewType:Ce,setInterviewType:xe,meetingLink:We,setMeetingLink:Be,location:rt,setLocation:ht,showUploadForm:ge,setShowUploadForm:Je,uploadFile:mt,setUploadFile:de,uploadDocType:at,setUploadDocType:ot,approvalFile:ke,setApprovalFile:Zt,isUploading:Bt,setIsUploading:_s,previewDoc:Us,setPreviewDoc:fs,showPreviewModal:Vs,setShowPreviewModal:Qs,selectedInterviewerId:Xs,setSelectedInterviewerId:ie,isEditingStatutory:nt,setIsEditingStatutory:fe,statutoryForm:Ae,setStatutoryForm:Fe,isSavingStatutory:Ke,setIsSavingStatutory:Le,interviews:Ue,setInterviews:et,isScheduling:dt,setIsScheduling:ss,isCancellingInterview:Wt,setIsCancellingInterview:kt,showAssignArchitectureModal:wt,setShowAssignArchitectureModal:Os,architectureLeadId:as,setArchitectureLeadId:Se,isAssigningArchitecture:be,setIsAssigningArchitecture:pt,showArchitectureStatusModal:Ve,setShowArchitectureStatusModal:bt,architectureStatus:gt,setArchitectureStatus:rs,architectureRemarks:is,setArchitectureRemarks:Ts,isUpdatingArchitecture:Ws,setIsUpdatingArchitecture:nn,isAssigningParticipant:Ee,setIsAssigningParticipant:$t,documentConfigs:Xt,setDocumentConfigs:Cs,fddAgencies:Mt,setFddAgencies:ze,selectedAgencyId:xt,setSelectedAgencyId:yt,isAssigningAgency:Ot,setIsAssigningAgency:Pt,showAssignFddModal:Jt,setShowAssignFddModal:bs,isApproving:ns,setIsApproving:Ds,isRejecting:ts,setIsRejecting:js,ktMatrixScores:tn,setKtMatrixScores:vn,ktMatrixSelectedValues:jn,setKtMatrixSelectedValues:xn,ktMatrixRemarks:gn,setKtMatrixRemarks:Ye,ktMatrixRecommendation:qt,setKtMatrixRecommendation:Ze,isSubmittingKT:Gt,setIsSubmittingKT:St,selectedInterviewForFeedback:qn,setSelectedInterviewForFeedback:Er,showFddFinalizeModal:Fr,setShowFddFinalizeModal:wn,showFddFlagModal:Js,setShowFddFlagModal:Sa,fddAuditRecommendation:It,setFddAuditRecommendation:As,fddAuditFindings:_r,setFddAuditFindings:ca,isFinalizingFdd:Ca,setIsFinalizingFdd:Yr,isFddFlagging:Nr,setIsFddFlagging:kn,level2Feedback:Sn,setLevel2Feedback:sr,level2Recommendation:wr,setLevel2Recommendation:Sr,isSubmittingLevel2:yn,setIsSubmittingLevel2:Dn,level3Feedback:Aa,setLevel3Feedback:ka,level3Recommendation:qi,setLevel3Recommendation:xi,isSubmittingLevel3:gi,setIsSubmittingLevel3:bl,selectedEvaluationForView:jl,setSelectedEvaluationForView:da,showFeedbackDetailsModal:Da,setShowFeedbackDetailsModal:ua}}const h_=()=>new Date().toISOString().split("T")[0],QU=t=>({strategicVision:"",managementCapabilities:"",operationalUnderstanding:"",keyStrengths:"",areasOfConcern:"",additionalComments:"",overallScore:"",interviewerName:(t==null?void 0:t.name)||"",interviewDate:h_()}),XU=t=>({strategicVision:"",managementCapabilities:"",operationalUnderstanding:"",brandAlignment:"",executiveSummary:"",keyStrengths:"",areasOfConcern:"",additionalComments:"",overallScore:"",interviewerName:(t==null?void 0:t.name)||"",interviewDate:h_()});function JU({ktMatrixScores:t,setKtMatrixScores:s,setKtMatrixSelectedValues:n,ktMatrixRemarks:r,setKtMatrixRemarks:a,ktMatrixRecommendation:i,setKtMatrixRecommendation:o,selectedInterviewForFeedback:d,interviews:m,setIsSubmittingKT:f,setShowKTMatrixModal:p,level2Feedback:h,setLevel2Feedback:x,level2Recommendation:u,setLevel2Recommendation:N,setIsSubmittingLevel2:v,setShowLevel2FeedbackModal:w,level3Feedback:j,setLevel3Feedback:b,level3Recommendation:C,setLevel3Recommendation:S,setIsSubmittingLevel3:D,setShowLevel3FeedbackModal:_,currentUser:A,fetchInterviews:E,fetchApplication:q,ktMatrixConfig:O,level2Config:R,level3Config:P}){const L=re=>re==="Approve"?"Recommended":re==="Reject"?"Not Recommended":"Hold",$=re=>re==="Approve"?"Approved":re==="Reject"?"Rejected":null,Z=()=>O!=null&&O.items&&O.items.length>0?O.items.map(re=>({name:re.label,weight:Number(re.weight)||0,maxScore:Number(re.maxScore)||10,options:(re.options||[]).map(ae=>({label:ae.optionLabel,value:ae.optionValue,score:Number(ae.score)||0}))})):[],Q=()=>R!=null&&R.items&&R.items.length>0?R.items:[],W=()=>P!=null&&P.items&&P.items.length>0?P.items:[],U=Z(),M=Q(),z=W();return{handleKTMatrixChange:(re,ae,ue)=>{s(ye=>({...ye,[re]:ue})),n(ye=>({...ye,[re]:ae}))},calculateKTScore:()=>{let re=0;return U.forEach(ae=>{const ue=t[ae.name||ae.label]||0,ye=ae.maxScore||10,ce=ae.weight||0;re+=ue/ye*ce}),re.toFixed(2)},handleSubmitKTMatrix:async()=>{var ae,ue;if(U.length===0){J.error("KT Matrix configuration is missing. Please configure it in Master > Interview Configurations.");return}if(Object.keys(t).lengthye.status!=="Completed"))==null?void 0:ae.id)||((ue=m[0])==null?void 0:ue.id);if(!re){J.error("No active interview found to link this KT Matrix to.");return}try{f(!0);const ye=U.map(je=>({criterionName:je.name||je.label,score:t[je.name||je.label]||0,maxScore:je.maxScore||10,weightage:je.weight||0}));await ps.submitKTMatrix({interviewId:re,criteriaScores:ye,feedback:r,recommendation:L(i)});const ce=$(i);ce&&await ps.updateInterviewDecision({interviewId:re,decision:ce,remarks:r||`Level 1 ${ce.toLowerCase()} via KT Matrix`}),J.success(ce?`KT Matrix submitted and interview ${ce.toLowerCase()}`:"KT Matrix submitted and interview kept on hold"),p(!1),s({}),n({}),a(""),o("Approve"),await E(),await q()}catch{J.error("Failed to submit KT Matrix")}finally{f(!1)}},handleLevel2Change:(re,ae)=>{x(ue=>({...ue,[re]:ae}))},handleSubmitLevel2Feedback:async()=>{var ae;if(M.length===0){J.error("Level 2 feedback configuration is missing. Please configure it in Master > Interview Configurations.");return}if(!h.overallScore){J.warning("Please provide an overall score.");return}const re=(d==null?void 0:d.id)||((ae=m.find(ue=>ue.status!=="Completed"&&ue.level===2))==null?void 0:ae.id);if(!re){J.error("No active Level 2 interview found to link this feedback to.");return}try{v(!0);const ue=M.map(je=>({type:je.label,comments:h[je.itemKey]||""})).filter(je=>je.comments.trim()!=="");await ps.submitLevel2Feedback({interviewId:re,overallScore:Number(h.overallScore),feedbackItems:ue,recommendation:L(u)});const ye=$(u),ce=h.additionalComments||"Level 2 decision submitted via feedback modal";ye&&await ps.updateInterviewDecision({interviewId:re,decision:ye,remarks:ce}),J.success(ye?`Level 2 feedback submitted and interview ${ye.toLowerCase()}`:"Level 2 feedback submitted and interview kept on hold"),w(!1),x(QU(A)),N("Approve"),await E(),await q()}catch{J.error("Failed to submit Level 2 Feedback")}finally{v(!1)}},handleLevel3Change:(re,ae)=>{b(ue=>({...ue,[re]:ae}))},handleSubmitLevel3Feedback:async()=>{var ae;if(z.length===0){J.error("Level 3 feedback configuration is missing. Please configure it in Master > Interview Configurations.");return}if(!j.overallScore){J.warning("Please provide an overall score.");return}const re=(d==null?void 0:d.id)||((ae=m.find(ue=>ue.status!=="Completed"&&ue.level===3))==null?void 0:ae.id);if(!re){J.error("No active Level 3 interview found to link this feedback to.");return}try{D(!0);const ue=z.map(je=>({type:je.label,comments:j[je.itemKey]||""})).filter(je=>je.comments.trim()!=="");await ps.submitLevel2Feedback({interviewId:re,overallScore:Number(j.overallScore),feedbackItems:ue,recommendation:L(C)});const ye=$(C),ce=j.executiveSummary||j.additionalComments||"Level 3 decision submitted via feedback modal";ye&&await ps.updateInterviewDecision({interviewId:re,decision:ye,remarks:ce}),J.success(ye?`Level 3 feedback submitted and interview ${ye.toLowerCase()}`:"Level 3 feedback submitted and interview kept on hold"),_(!1),b(XU(A)),S("Approve"),await E(),await q()}catch{J.error("Failed to submit Level 3 Feedback")}finally{D(!1)}},ktCriteria:U,l2Fields:M,l3Fields:z}}function eV(){const[t,s]=g.useState(null),[n,r]=g.useState(null),[a,i]=g.useState(null),[o,d]=g.useState(!1),[m,f]=g.useState(null),p=g.useCallback(async x=>{var u,N;try{const v=await Re.getInterviewConfigByType(x);if((u=v.data)!=null&&u.success)return v.data.data}catch(v){((N=v==null?void 0:v.response)==null?void 0:N.status)!==404&&console.warn(`Failed to fetch ${x} config:`,v)}return null},[]),h=g.useCallback(async()=>{d(!0),f(null);try{const[x,u,N]=await Promise.all([p("KT_MATRIX"),p("LEVEL2_FEEDBACK"),p("LEVEL3_FEEDBACK")]);s(x),r(u),i(N)}catch{f("Failed to load interview configurations"),J.error("Failed to load interview configurations")}finally{d(!1)}},[p]);return g.useEffect(()=>{h()},[h]),{ktMatrixConfig:t,level2Config:n,level3Config:a,loading:o,error:m,refresh:h}}function tV(t){const{application:s,applicationId:n,currentUser:r,interviews:a,approvalFile:i,approvalRemark:o,rejectionReason:d,architectureLeadId:m,architectureStatus:f,architectureRemarks:p,selectedUser:h,participantType:x,users:u,interviewDate:N,setInterviewDate:v,interviewType:w,setInterviewType:j,interviewMode:b,setInterviewMode:C,meetingLink:S,setMeetingLink:D,location:_,setLocation:A,scheduledInterviewParticipants:E,uploadFile:q,uploadDocType:O,selectedStage:R,setIsApproving:P,setShowApproveModal:L,setApprovalRemark:$,setApprovalFile:Z,setIsRejecting:Q,setShowRejectModal:W,setRejectionReason:U,setIsAssigningArchitecture:M,setShowAssignArchitectureModal:z,setIsUpdatingArchitecture:T,setShowArchitectureStatusModal:F,setIsAssigningParticipant:I,setSelectedUser:K,setShowAssignModal:G,setLoading:V,setIsScheduling:Y,setShowScheduleModal:re,setShowCancelInterviewModal:ae,interviewIdToCancel:ue,setInterviewIdToCancel:ye,interviewToReschedule:ce,setInterviewToReschedule:je,setIsCancellingInterview:Me,setIsUploading:ut,setShowUploadForm:jt,setUploadFile:ft,setUploadDocType:X,setDocuments:Ce,selectedInterviewerId:xe,setSelectedInterviewerId:We,setScheduledInterviewParticipants:Be,setUsers:rt,showScheduleModal:ht,showAssignArchitectureModal:ge,showAssignModal:Je,fetchApplication:mt,fetchInterviews:de,fetchEorData:at}=t,ot=()=>{if(!xe)return;const et=(Array.isArray(u)?u:[]).find(dt=>dt.id===xe);et&&!E.find(dt=>dt.id===et.id)&&(Be([...E,et]),We(""))},ke=Ue=>{Be(E.filter(et=>et.id!==Ue))},Zt=g.useCallback(async Ue=>{if(!(!r||!["DD Admin","Super Admin","DD Lead","DD Head","NBH"].includes(r.role)))try{const et={};if(Ue){const kt={level1:["DD-ZM","RBM"],level2:["DD Lead","ZBH"],level3:["NBH","DD Head"]};kt[Ue]&&(et.preferredRoleCode=kt[Ue]),s&&(et.locationId=s.districtId||s.areaId||s.regionId||s.zoneId)}et.isExternal=!1;const dt=await ps.getUsers(et),Wt=(Array.isArray(dt)?dt:dt&&Array.isArray(dt.data)?dt.data:dt&&Array.isArray(dt.users)?dt.users:[]).filter(kt=>(kt.status||"").toLowerCase()!=="inactive");rt(Wt.sort((kt,wt)=>String(kt.fullName||kt.name||"").localeCompare(String(wt.fullName||wt.name||""))))}catch{rt([])}},[r,s,rt]),Bt=g.useCallback(()=>{if(!ht||!s||ce)return;const Ue=parseInt(w.replace("level",""))||1,et={1:["DD-ZM","RBM"],2:["DD Lead","ZBH"],3:["NBH","DD Head"]},dt=as=>String(as||"").trim().toLowerCase().replace(/[_\s-]+/g," "),ss=(et[Ue]||[]).map(dt),Wt=(as,Se)=>{var Ve,bt,gt;const be=[(Ve=as==null?void 0:as.metadata)==null?void 0:Ve.role,(bt=Se==null?void 0:Se.role)==null?void 0:bt.roleName,(gt=Se==null?void 0:Se.role)==null?void 0:gt.roleCode,Se==null?void 0:Se.roleCode,Se==null?void 0:Se.role].filter(Boolean),pt=be.find(rs=>ss.includes(dt(rs)));return String(pt||be[0]||"Panelist")},kt=((s==null?void 0:s.participants)||[]).filter(as=>{var Se,be,pt,Ve,bt,gt,rs,is,Ts;return((Se=as.metadata)==null?void 0:Se.interviewLevel)===Ue||((be=as.metadata)==null?void 0:be.interviewLevel)===String(Ue)||((Ve=(pt=as.metadata)==null?void 0:pt.allAssignments)==null?void 0:Ve.includes(Ue))||((gt=(bt=as.metadata)==null?void 0:bt.allAssignments)==null?void 0:gt.includes(String(Ue)))||ss.includes(dt((rs=as.user)==null?void 0:rs.role))||ss.includes(dt((is=as.user)==null?void 0:is.roleCode))||ss.includes(dt((Ts=as.metadata)==null?void 0:Ts.role))}).map(as=>{const Se=as.user||{};return{...Se,__stageRole:Wt(as,Se)}}).filter(as=>!!(as!=null&&as.id));if(kt.length===0){Be([]);return}const wt=[],Os=new Set;kt.forEach(as=>{as.id&&!Os.has(as.id)&&(Os.add(as.id),wt.push(as))}),Be(wt)},[ht,s,w,ce,Be]),_s=async()=>{if(!N){J.warning("Please select date and time");return}try{Y(!0);const Ue={applicationId:s==null?void 0:s.id,level:w,scheduledAt:N,type:b==="virtual"?"Virtual Interview":"Physical Interview",location:b==="virtual"?S:_,participants:E.map(et=>et.id)};ce?(await ps.updateInterview(ce.id,{...Ue,status:"Scheduled"}),J.success("Interview rescheduled successfully")):(await ps.scheduleInterview(Ue),J.success("Interview scheduled successfully")),re(!1),je(null),await de(),await mt()}catch{J.error(ce?"Failed to reschedule interview":"Failed to schedule interview")}finally{Y(!1)}},Us=async Ue=>{ye(Ue),ae(!0)},fs=async Ue=>{var dt,ss;je(Ue),j(`level${Ue.level}`),C((dt=Ue.interviewType)!=null&&dt.toLowerCase().includes("virtual")?"virtual":"physical"),v(Ue.scheduleDate?(()=>{const Wt=new Date(Ue.scheduleDate);return new Date(Wt.getTime()-Wt.getTimezoneOffset()*6e4).toISOString().slice(0,16)})():""),(ss=Ue.interviewType)!=null&&ss.toLowerCase().includes("virtual")?D(Ue.linkOrLocation||""):A(Ue.linkOrLocation||"");const et=(Ue.participants||[]).map(Wt=>Wt.user||Wt).filter(Boolean);Be(et),re(!0)},Vs=async()=>{if(ue)try{Me(!0),await ps.updateInterview(ue,{status:"Cancelled"}),J.success("Interview cancelled successfully"),ae(!1),ye(""),await de()}catch{J.error("Failed to cancel interview")}finally{Me(!1)}},Qs=async()=>{var Ue;if(!q||!O){J.warning("Please enter a document name and select a file");return}try{ut(!0);const et=new FormData,dt=((Ue=q.name.match(/\.[^/.]+$/))==null?void 0:Ue[0])||"",ss=O.trim(),Wt=ss.toLowerCase().endsWith(dt.toLowerCase())?ss:`${ss}${dt}`;et.append("file",q,Wt);const kt=R!=null&&R.startsWith("EOR: ")?R.replace(/^EOR:\s*/,""):null;et.append("documentType",kt||"Other"),R&&et.append("stage",R),await ps.uploadDocument(n,et),J.success("Document uploaded successfully"),jt(!1),ft(null),X("");const wt=await ps.getDocuments(n);Ce(wt||[]),await at()}catch{J.error("Failed to upload document")}finally{ut(!1)}},Xs=async()=>{var Ue;try{P(!0);const et=a.find(kt=>{var wt;return kt.status!=="Completed"&&kt.status!=="Cancelled"&&((wt=kt.participants)==null?void 0:wt.some(Os=>Os.userId===(r==null?void 0:r.id)))});if(i&&n)try{const kt=new FormData;kt.append("file",i),kt.append("documentType","Approval Attachment");let wt=null;et&&(et.level===1||et.level==="1"?wt="1st Level Interview":et.level===2||et.level==="2"?wt="2nd Level Interview":(et.level===3||et.level==="3")&&(wt="3rd Level Interview")),wt||(s.status==="Shortlisted"||s.status==="Level 1 Interview Pending"?wt="1st Level Interview":s.status==="Level 1 Approved"||s.status==="Level 2 Interview Pending"?wt="2nd Level Interview":(s.status==="Level 2 Approved"||s.status==="Level 3 Interview Pending")&&(wt="3rd Level Interview")),wt&&kt.append("stage",wt),await ps.uploadDocument(n,kt)}catch{J.error("Failed to upload document")}if(et)try{await ps.updateInterviewDecision({interviewId:et.id,decision:"Approved",remarks:o}),J.success("Interview approved successfully"),L(!1),$(""),Z(null),await de(),await mt();return}catch{J.error("Failed to approve interview");return}if(!o.trim()){J.warning("Please enter a remark");return}let dt=s.status;switch(s.status){case"Shortlisted":case"Level 1 Interview Pending":dt="Level 1 Approved";break;case"Level 1 Approved":case"Level 2 Interview Pending":dt="Level 2 Approved";break;case"Level 2 Approved":case"Level 3 Interview Pending":dt="Level 3 Approved";break;case"Level 3 Approved":dt="FDD Verification";break;case"FDD Verification":dt="LOI In Progress";break;case"LOI In Progress":dt="Security Deposit";break;case"Security Deposit":case"Security Details":case"Payment Pending":dt="LOI Issued";break;case"LOI Issued":dt="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":dt="LOA Pending";break;case"LOA Pending":dt="EOR In Progress";break;case"EOR In Progress":dt="EOR Complete";break;case"EOR Complete":dt="Inauguration";break;case"Inauguration":case"Approved":dt="Onboarded";break;default:dt="Onboarded"}const Wt={"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(Wt){const kt=await ps.submitStageDecision({applicationId:s.id,stageCode:Wt,decision:"Approved",remarks:o,nextStatus:dt});(Ue=kt.data)!=null&&Ue.statusUpdated?J.success(kt.message||"Stage completed and moved to next step"):J.info(kt.message||"Approval recorded. Waiting for other mandatory approvers.")}else await ps.updateApplicationStatus(n,{status:dt,remarks:o});dt==="Onboarded"?(await ps.createDealer({applicationId:n}),J.success("Application finalized and Dealer profile created!")):J.success(`Application moved to ${dt}`),L(!1),$(""),Z(null),await mt()}catch(et){J.error(et.message||"Failed to process approval")}finally{P(!1)}},ie=async()=>{try{Q(!0);const Ue=a.find(ss=>{var Wt;return ss.status!=="Completed"&&ss.status!=="Cancelled"&&((Wt=ss.participants)==null?void 0:Wt.some(kt=>kt.userId===(r==null?void 0:r.id)))});if(Ue)try{await ps.updateInterviewDecision({interviewId:Ue.id,decision:"Rejected",remarks:d}),J.success("Interview rejected"),W(!1),U(""),await de(),await mt();return}catch{J.error("Failed to reject interview");return}if(!d.trim()){J.warning("Please enter a reason for rejection");return}const dt={"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];dt?await ps.submitStageDecision({applicationId:s.id,stageCode:dt,decision:"Rejected",remarks:d,interviewId:Ue==null?void 0:Ue.id}):await ps.updateApplicationStatus(n,{status:"Rejected",remarks:d}),J.success("Application rejected"),W(!1),U(""),await mt()}catch(Ue){J.error(Ue.message||"Failed to process rejection")}finally{Q(!1)}},nt=async()=>{try{await ps.generateDealerCodes(n),J.success("Dealer codes generated successfully"),await mt()}catch(Ue){J.error(Ue.message||"Failed to generate dealer codes")}},fe=async()=>{if(!m){J.warning("Please select an architecture lead");return}try{M(!0),await ps.assignArchitectureTeam(n,m),J.success("Architecture team assigned successfully"),z(!1),await mt()}catch(Ue){J.error(Ue.message||"Failed to assign architecture team")}finally{M(!1)}},Ae=async()=>{try{T(!0),await ps.updateArchitectureStatus(n,f,p),J.success("Architecture status updated successfully"),F(!1),await mt()}catch{J.error("Failed to update architecture status")}finally{T(!1)}},Fe=async()=>{if(!h){J.warning("Please select a user");return}try{I(!0);const Ue=Array.isArray(u)?u.find(et=>et.id===h):null;Ue&&(Ue.role==="FDD"||Ue.roleCode==="FDD")&&(await ps.assignFddAgency({applicationId:n,assignedToAgency:h}),J.info(`${Ue.fullName||Ue.name} assigned as FDD Agency based on role.`)),await ps.addParticipant({requestId:n,requestType:"application",userId:h,participantType:x||"contributor"}),J.success("User assigned successfully!"),await mt(),K(""),G(!1)}catch{J.error("Failed to assign user")}finally{I(!1)}},Ke=async()=>{try{V(!0),await ps.retriggerEvaluators(n),J.success("Evaluators re-assigned successfully"),await mt()}catch{J.error("Failed to re-assign evaluators")}finally{V(!1)}},Le=g.useCallback(async()=>{if(ht&&s){await Zt(w),Bt();return}(ge||Je)&&s&&await Zt()},[ht,ge,Je,s,w,Zt,Bt]);return{handleAddInterviewer:ot,handleRemoveInterviewer:ke,fetchUsers:Zt,maybeFetchUsersForModal:Le,handleScheduleInterview:_s,handleRescheduleInterview:fs,handleCancelInterview:Us,handleConfirmCancelInterview:Vs,handleUpload:Qs,handleApprove:Xs,handleReject:ie,handleGenerateDealerCodes:nt,handleAssignArchitecture:fe,handleUpdateArchitectureStatus:Ae,handleAddParticipant:Fe,handleRetriggerEvaluators:Ke}}const m_={getChecklist:async(t,s)=>{const n=s?`/eor/relocation/${s}`:`/eor/application/${t}`;return(await Ie.get(n)).data},createChecklist:async t=>(await Ie.post("/eor",t)).data,updateItem:async(t,s)=>(await Ie.post(`/eor/item/${t}`,s)).data,submitAudit:async(t,s)=>(await Ie.post(`/eor/audit/${t}`,s)).data},Ug=Object.freeze(Object.defineProperty({__proto__:null,eorService:m_},Symbol.toStringTag,{value:"Module"})),sV={getAuditLogs:async(t,s,n=1,r=50)=>{var a;try{const i=await Re.getAuditLogs(t,s,n,r);return((a=i.data)==null?void 0:a.data)||i.data||[]}catch(i){throw console.error("Get audit logs error:",i),i}},getAuditSummary:async(t,s)=>{var n;try{const r=await Re.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}}},nV={getWorknotes:async(t,s)=>{var r,a;const n=await Re.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 Re.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 Re.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 Re.removeParticipant(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to remove participant");return s.data}};function rV({applicationId:t}){const[s,n]=g.useState(null),[r,a]=g.useState(!0),[i,o]=g.useState([]),[d,m]=g.useState(null),[f,p]=g.useState([]),[h,x]=g.useState(!1),[u,N]=g.useState([]),[v,w]=g.useState([]),[j,b]=g.useState({}),C=g.useCallback(async()=>{try{const A=await ps.getDocuments(t);o(A||[])}catch(A){console.error("Failed to refresh documents:",A)}},[t]),S=g.useCallback(async(A=!1)=>{try{A||a(!0);const E=await ps.getApplicationById(t),q=(R,P)=>{var $;const L=($=E.progressTracking)==null?void 0:$.find(Z=>Z.stageName===R);if(L!=null&&L.stageCompletedAt)return new Date(L.stageCompletedAt).toISOString();if(L!=null&&L.stageStartedAt)return new Date(L.stageStartedAt).toISOString();if(P){const Z=(E.statusHistory||[]).find(Q=>Q.newStatus===P);if(Z)return new Date(Z.createdAt).toISOString()}},O={id:E.id,registrationNumber:E.applicationId||"N/A",name:E.applicantName,email:E.email,phone:E.phone,age:E.age,education:E.education,residentialAddress:E.address||E.city||"",businessAddress:E.address||"",preferredLocation:E.preferredLocation,state:E.state,ownsBike:E.ownRoyalEnfield==="yes",pastExperience:E.experienceYears?`${E.experienceYears} years`:E.description||"",status:E.overallStatus,questionnaireMarks:E.score||E.questionnaireMarks||0,questionnaireResponses:E.questionnaireResponses||[],rank:0,totalApplicantsAtLocation:0,assignedUsers:[],progress:E.progressPercentage||0,isShortlisted:E.isShortlisted||!0,companyName:E.companyName,source:E.source,existingDealer:E.existingDealer,royalEnfieldModel:E.royalEnfieldModel,description:E.description,pincode:E.pincode,locationType:E.locationType,ownRoyalEnfield:E.ownRoyalEnfield,address:E.address,submissionDate:E.createdAt?new Date(E.createdAt).toISOString():"",questionnaireDate:q("Questionnaire","Questionnaire Completed")||q("Questionnaire","Questionnaire Pending"),shortlistDate:q("Shortlist","Shortlisted"),level1InterviewDate:q("1st Level Interview","Level 1 Approved"),level2InterviewDate:q("2nd Level Interview","Level 2 Approved"),level3InterviewDate:q("3rd Level Interview","Level 3 Approved"),fddDate:q("FDD","FDD Verification"),loiApprovalDate:q("LOI Approval","LOI In Progress"),securityDetailsDate:q("Security Deposit","Security Deposit")||q("Security Details","Security Details"),loiIssueDate:q("LOI Issue","LOI Issued"),dealerCodeDate:q("Dealer Code Generation","Dealer Code Generation"),architectureAssignedDate:q("Architecture Team Assigned","Architecture Team Assigned"),architectureDocumentDate:q("Architecture Document Upload","Architecture Document Upload"),architectureCompletionDate:q("Architecture Team Completion","Architecture Team Completion"),loaDate:q("LOA","LOA Pending"),eorCompleteDate:q("EOR Complete","EOR Complete"),inaugurationDate:q("Inauguration","Inauguration"),onboardedDate:E.overallStatus==="Onboarded"?E.updatedAt?new Date(E.updatedAt).toISOString():new Date().toISOString():void 0,progressTracking:E.progressTracking||[],participants:E.participants||[],dealerCode:E.dealerCode,zoneId:E.zoneId,regionId:E.regionId,areaId:E.areaId,districtId:E.districtId,stageApprovals:E.stageApprovals||[],fddAssignments:E.fddAssignments||[],constitutionType:E.constitutionType,architectureStatus:E.architectureStatus,statutoryStatus:E.statutoryStatus,panNumber:E.panNumber,gstNumber:E.gstNumber,bankName:E.bankName,accountNumber:E.accountNumber,ifscCode:E.ifscCode,branchName:E.branchName,accountHolderName:E.accountHolderName,registeredAddress:E.registeredAddress};n(O),E.uploadedDocuments&&o(E.uploadedDocuments||[])}catch(E){console.error("Failed to fetch application details",E)}finally{a(!1)}},[t]),D=g.useCallback(async()=>{if(t)try{const A=await m_.getChecklist(t);A.success&&A.data&&m(A.data)}catch{m(null)}},[t]),_=A=>v.find(E=>E.depositType===A);return g.useEffect(()=>{t&&(S(),C())},[t]),g.useEffect(()=>{t&&D()},[t,s==null?void 0:s.status]),g.useEffect(()=>{if(!(s!=null&&s.id))return;(async()=>{x(!0);try{const E=await sV.getAuditLogs("application",s.id,1,100);p(Array.isArray(E)?E:[])}catch{p([])}finally{x(!1)}try{const E=await nV.getWorknotes("application",s.id);N(E.data||[])}catch{N([])}})()},[s==null?void 0:s.id]),g.useEffect(()=>{if(!t)return;(async()=>{try{const[E,q]=await Promise.all([ps.getSecurityDeposit(t),ps.getSystemConfigs({category:"SECURITY_DEPOSIT",format:"map"})]);w(Array.isArray(E)?E:[E].filter(Boolean)),b(q||{})}catch(E){console.error("Failed to fetch payment data",E)}})()},[t]),{application:s,loading:r,setLoading:a,documents:i,setDocuments:o,eorData:d,auditLogs:f,auditLoading:h,worknotes:u,deposits:v,paymentConfigs:j,refreshDocuments:C,fetchApplication:S,fetchEorData:D,getDeposit:_}}function aV({application:t,applicationId:s,tempFirmType:n,setUpdatingFirmType:r,setShowFirmTypeModal:a,setStatutoryForm:i,setIsEditingStatutory:o,setIsSavingStatutory:d,statutoryForm:m,setFddAgencies:f,selectedAgencyId:p,setIsAssigningAgency:h,fetchApplication:x}){const u=async()=>{try{r(!0),await ps.updateApplication(s,{constitutionType:n}),J.success("Firm type updated successfully"),a(!1),await x()}catch{J.error("Failed to update firm type")}finally{r(!1)}},N=()=>{t&&(i({accountHolderName:t.accountHolderName||"",panNumber:t.panNumber||"",gstNumber:t.gstNumber||"",bankName:t.bankName||"",accountNumber:t.accountNumber||"",ifscCode:t.ifscCode||"",registeredAddress:t.registeredAddress||""}),o(!0))},v=async()=>{try{d(!0),await ps.updateApplication(s,m),J.success("Statutory & Bank details updated successfully"),o(!1),await x(!0)}catch{J.error("Failed to update details")}finally{d(!1)}},w=g.useCallback(async()=>{try{const b=await ps.getUsers({roleCode:"FDD"});f(Array.isArray(b)?b:[])}catch{f([])}},[f]);return{handleUpdateFirmType:u,handleEditStatutory:N,handleSaveStatutory:v,fetchFddAgencies:w,handleAssignAgency:async()=>{if(!p){J.warning("Please select an agency");return}try{h(!0),await ps.assignFddAgency({applicationId:(t==null?void 0:t.id)||s,assignedToAgency:p}),await ps.addParticipant({requestId:(t==null?void 0:t.id)||s,requestType:"application",userId:p,participantType:"contributor"}),J.success("FDD Agency assigned and added as participant"),await x()}catch{J.error("Failed to assign agency")}finally{h(!1)}}}}function iV({application:t,documents:s,interviews:n,eorData:r,getDeposit:a,documentConfigs:i=[]}){var w;const o=j=>String(j||"").trim().toLowerCase().replace(/[_\s-]+/g," "),d=(j,b)=>{var D,_,A;const C=[(D=j==null?void 0:j.user)==null?void 0:D.role,(_=j==null?void 0:j.user)==null?void 0:_.roleCode,(A=j==null?void 0:j.metadata)==null?void 0:A.role].map(o),S=b.map(o);return C.some(E=>S.includes(E))},m=j=>{var b,C,S,D,_;return`${((b=j==null?void 0:j.user)==null?void 0:b.fullName)||((C=j==null?void 0:j.user)==null?void 0:C.name)||"User"} (${((S=j==null?void 0:j.user)==null?void 0:S.role)||((D=j==null?void 0:j.user)==null?void 0:D.roleCode)||((_=j==null?void 0:j.metadata)==null?void 0:_.role)||(j==null?void 0:j.participantType)||"participant"})`},f=j=>(s||[]).some(b=>b.documentType===j),p=()=>{const j=t.progressTracking||[],b=j.find(C=>C.stageName==="Security Deposit")||j.find(C=>C.stageName==="Security Details");return b!=null&&b.status?b.status:"pending"},h=(j,b="pending")=>{const C=(t.progressTracking||[]).find(S=>S.stageName===j);return C!=null&&C.status?C.status:b},x=[{id:1,name:"Submitted",status:"completed",date:t.submissionDate,description:"Application submitted",documentsUploaded:3},{id:2,name:"Questionnaire",status:h("Questionnaire"),date:t.questionnaireDate,description:"Questionnaire completed",documentsUploaded:0},{id:3,name:"Shortlist",status:h("Shortlist"),date:t.shortlistDate,description:"Application shortlisted by DD",evaluators:Array.from(new Set((t.participants||[]).filter(j=>j.participantType==="assignee").map(j=>{var b,C,S;return`${((b=j.user)==null?void 0:b.fullName)||((C=j.user)==null?void 0:C.name)||"User"} (${((S=j.user)==null?void 0:S.roleCode)||j.participantType})`}))),documentsUploaded:2},{id:4,name:"1st Level Interview",status:h("1st Level Interview"),date:t.level1InterviewDate,description:"DD-ZM + RBM evaluation",evaluators:Array.from(new Set((t.participants||[]).filter(j=>{var b,C,S,D,_,A;return((b=j.metadata)==null?void 0:b.interviewLevel)===1||((C=j.metadata)==null?void 0:C.interviewLevel)==="1"||((D=(S=j.metadata)==null?void 0:S.allAssignments)==null?void 0:D.includes(1))||((A=(_=j.metadata)==null?void 0:_.allAssignments)==null?void 0:A.includes("1"))||d(j,["DD-ZM","RBM"])}).map(m))),documentsUploaded:1},{id:5,name:"2nd Level Interview",status:h("2nd Level Interview"),date:t.level2InterviewDate,description:"DD Lead + ZBH evaluation",evaluators:Array.from(new Set((t.participants||[]).filter(j=>{var b,C,S,D,_,A;return((b=j.metadata)==null?void 0:b.interviewLevel)===2||((C=j.metadata)==null?void 0:C.interviewLevel)==="2"||((D=(S=j.metadata)==null?void 0:S.allAssignments)==null?void 0:D.includes(2))||((A=(_=j.metadata)==null?void 0:_.allAssignments)==null?void 0:A.includes("2"))||d(j,["DD Lead","ZBH"])}).map(m))),documentsUploaded:1},{id:6,name:"3rd Level Interview",status:h("3rd Level Interview"),date:t.level3InterviewDate,description:"NBH + DD Head evaluation",evaluators:Array.from(new Set((t.participants||[]).filter(j=>{var b,C,S,D,_,A;return((b=j.metadata)==null?void 0:b.interviewLevel)===3||((C=j.metadata)==null?void 0:C.interviewLevel)==="3"||((D=(S=j.metadata)==null?void 0:S.allAssignments)==null?void 0:D.includes(3))||((A=(_=j.metadata)==null?void 0:_.allAssignments)==null?void 0:A.includes("3"))||d(j,["NBH","DD Head"])}).map(m))),documentsUploaded:2},{id:7,name:"FDD",status:h("FDD"),date:t.fddDate,description:"Financial Due Diligence",documentsUploaded:5},{id:8,name:"LOI Approval",status:h("LOI Approval"),date:t.loiApprovalDate,description:"Letter of Intent approval",evaluators:Array.from(new Set((t.participants||[]).filter(j=>{var b,C,S;return((b=j.metadata)==null?void 0:b.stageCode)==="LOI_APPROVAL"||((S=(C=j.metadata)==null?void 0:C.allAssignments)==null?void 0:S.includes("LOI_APPROVAL"))}).map(m))),documentsUploaded:1},{id:9,name:"Security Deposit",status:p(),date:t.securityDetailsDate,description:"Security Deposit verification",documentsUploaded:3},{id:10,name:"LOI Issue",status:h("LOI Issue"),date:t.loiIssueDate,description:"Letter of Intent issued",isParallel:!0,branches:[{name:"LOI Documents",color:"green",stages:i.some(j=>j.stageCode==="LOI Issue")?i.filter(j=>j.stageCode==="LOI Issue").map((j,b)=>({id:`10a-${b}`,name:j.documentType,status:f(j.documentType)?"completed":"active",description:j.isMandatory?`Upload ${j.documentType} (Mandatory)`:`Upload ${j.documentType}`})):[{id:"10a-1",name:"Letter of Intent",status:f("Letter of Intent")||f("LOI")?"completed":"active",description:"Letter of Intent document"},{id:"10a-2",name:"Signed LOI",status:f("Signed LOI")||f("LOI Signed Copy")?"completed":"active",description:"Signed Letter of Intent"}]}]},{id:11,name:"Dealer Code Generation",status:h("Dealer Code Generation"),date:t.dealerCodeDate,description:"Dealer code generated and assigned",isParallel:!0,branches:[{name:"Architectural Work",color:"green",stages:[{id:"11a-1",name:"Architecture Assignment",status:t.architectureAssignedTo?"completed":t.status==="Architecture Team Assigned"?"active":"pending",description:"Assigned to architecture team"},{id:"11a-2",name:"Site Plan Blueprint",status:f("Architecture Blueprint")?"completed":t.architectureAssignedTo?"active":"pending",description:"Blueprints and site plans"},{id:"11a-3",name:"Architecture Work",status:t.architectureStatus==="COMPLETED"?"completed":t.architectureStatus==="IN_PROGRESS"||f("Architecture Blueprint")?"active":"pending",description:"Final architecture approval"}]},{name:"Statutory Documents",color:"green",stages:[{id:"11b-1",name:"GST",status:f("GST Certificate")||f("GST")?"completed":"active",description:"GST certificate"},{id:"11b-2",name:"PAN",status:f("PAN Card")||f("PAN")?"completed":"active",description:"PAN card"},{id:"11b-3",name:"Nodal Agreement",status:f("Nodal Agreement")?"completed":"active",description:"Nodal agreement document"},{id:"11b-4",name:"Cancelled Check",status:f("Cancelled Check")?"completed":"active",description:"Cancelled check copy"},{id:"11b-5",name:"Partnership Deed/LLP/MOA/AOA/COI",status:f("Partnership Deed/LLP/MOA/AOA/COI")||f("Partnership Deed")?"completed":"active",description:"Business entity documents"},{id:"11b-6",name:"Firm Registration Certificate",status:f("Firm Registration Certificate")||f("Firm Registration")?"completed":"active",description:"Firm registration certificate"},{id:"11b-7",name:"Rental agreement/ Lease agreement / Own/ Land agreement",status:f("Rental agreement/ Lease agreement / Own/ Land agreement")||f("Property Document")?"completed":"active",description:"Property agreement document"},{id:"11b-8",name:"Virtual Code",status:f("Virtual Code")||f("Virtual Code Confirmation")?"completed":"active",description:"Virtual code availability"},{id:"11b-9",name:"Domain ID",status:f("Domain ID")||f("Domain ID Setup")?"completed":"active",description:"Domain ID setup"},{id:"11b-10",name:"MSD Configuration",status:f("MSD Configuration")?"completed":"active",description:"Microsoft Dynamics configuration"},{id:"11b-11",name:"LOI Acknowledgement Copy",status:f("LOI Acknowledgement Copy")||f("LOI Acknowledgement")?"completed":"active",description:"LOI acknowledgement copy"}]}]},{id:12,name:"LOA",status:h("LOA"),isLocked:t.status==="LOA Pending"&&((w=a("FIRST_FILL"))==null?void 0:w.status)!=="Verified",lockMessage:"First Fill (₹15L) must be verified by Finance before LOA Approval.",evaluators:Array.from(new Set((t.participants||[]).filter(j=>{var b,C,S;return((b=j.metadata)==null?void 0:b.stageCode)==="LOA_APPROVAL"||((S=(C=j.metadata)==null?void 0:C.allAssignments)==null?void 0:S.includes("LOA_APPROVAL"))}).map(m))),description:"Letter of Authorization"},{id:13,name:"EOR Complete",status:h("EOR Complete"),description:"Essential Operating Requirements"},{id:14,name:"Inauguration",status:h("Inauguration"),description:"Dealership inauguration"},{id:15,name:"Dealership Active",status:h("Onboarded"),description:"Dealer profile active"}],u=[{id:1,item:"Sales Standards",completed:!1},{id:2,item:"Service & Spares",completed:!1},{id:3,item:"DMS infra",completed:!1},{id:4,item:"Manpower Training",completed:!1},{id:5,item:"Trade certificate with test ride bikes registration",completed:!1},{id:6,item:"GST certificate including Accessories & Apparels billing",completed:!1},{id:7,item:"Inventory Funding",completed:!1},{id:8,item:"Virtual code availability",completed:!1},{id:9,item:"Vendor payments",completed:!1},{id:10,item:"Details for website submission",completed:!1},{id:11,item:"Infra Insurance both Showroom and Service center",completed:!1},{id:12,item:"Auto ordering",completed:!1}],N=x.reduce((j,b)=>(j.push({name:b.name}),b.branches&&b.branches.forEach(C=>C.stages.forEach(S=>j.push({name:S.name,parentBranch:C.name}))),(b.name==="EOR In Progress"||b.name==="EOR Complete")&&((r==null?void 0:r.items)||u).forEach(C=>j.push({name:`EOR: ${C.description||C.item}`,parentBranch:"EOR"})),j),[]);return{processStages:x,eorChecklist:u,flattenedStages:N,getDocumentsForStage:j=>s.filter(b=>{var C;return b.stage===j||!b.stage&&((C=b.documentType)==null?void 0:C.toLowerCase().includes(j.toLowerCase().split(" ")[0]))})}}const RS=()=>{var yc;const{id:t}=gd(),s=tr(),{user:n}=Pn(ur=>ur.auth),r=t||"",a=()=>s(-1),[i,o]=g.useState(null);g.useEffect(()=>{r&&Yl.getBatchStatus([{entityType:"application",entityId:r}]).then(ur=>{ur!=null&&ur.success&&o(ur.data[`application:${r}`]??null)}).catch(()=>o(null))},[r]);const{application:d,loading:m,setLoading:f,documents:p,setDocuments:h,eorData:x,auditLogs:u,auditLoading:N,worknotes:v,deposits:w,paymentConfigs:j,refreshDocuments:b,fetchApplication:C,fetchEorData:S,getDeposit:D}=rV({applicationId:r}),_=x!=null&&x.items?x.items.filter(ur=>ur.isCompliant).length/x.items.length*100:0,A=xl(),{showFirmTypeModal:E,setShowFirmTypeModal:q,updatingFirmType:O,setUpdatingFirmType:R,tempFirmType:P,setTempFirmType:L,activeTab:$,setActiveTab:Z,showApproveModal:Q,setShowApproveModal:W,showOnboardModal:U,setShowOnboardModal:M,isOnboarding:z,setIsOnboarding:T,showRejectModal:F,setShowRejectModal:I,rejectionReason:K,setRejectionReason:G,scheduledInterviewParticipants:V,setScheduledInterviewParticipants:Y,showScheduleModal:re,setShowScheduleModal:ae,showCancelInterviewModal:ue,setShowCancelInterviewModal:ye,interviewIdToCancel:ce,setInterviewIdToCancel:je,interviewToReschedule:Me,setInterviewToReschedule:ut,showKTMatrixModal:jt,setShowKTMatrixModal:ft,showLevel2FeedbackModal:X,setShowLevel2FeedbackModal:Ce,showLevel3FeedbackModal:xe,setShowLevel3FeedbackModal:We,showDocumentsModal:Be,setShowDocumentsModal:rt,showAssignModal:ht,setShowAssignModal:ge,selectedStage:Je,setSelectedStage:mt,interviewMode:de,setInterviewMode:at,approvalRemark:ot,setApprovalRemark:ke,expandedBranches:Zt,setExpandedBranches:Bt,users:_s,setUsers:Us,selectedUser:fs,setSelectedUser:Vs,participantType:Qs,setParticipantType:Xs,interviewDate:ie,setInterviewDate:nt,interviewType:fe,setInterviewType:Ae,meetingLink:Fe,setMeetingLink:Ke,location:Le,setLocation:Ue,showUploadForm:et,setShowUploadForm:dt,uploadFile:ss,setUploadFile:Wt,uploadDocType:kt,setUploadDocType:wt,approvalFile:Os,setApprovalFile:as,isUploading:Se,setIsUploading:be,previewDoc:pt,setPreviewDoc:Ve,showPreviewModal:bt,setShowPreviewModal:gt,selectedInterviewerId:rs,setSelectedInterviewerId:is,isEditingStatutory:Ts,setIsEditingStatutory:Ws,statutoryForm:nn,setStatutoryForm:Ee,isSavingStatutory:$t,setIsSavingStatutory:Xt,interviews:Cs,setInterviews:Mt,isScheduling:ze,setIsScheduling:xt,isCancellingInterview:yt,setIsCancellingInterview:Ot,showAssignArchitectureModal:Pt,setShowAssignArchitectureModal:Jt,architectureLeadId:bs,setArchitectureLeadId:ns,isAssigningArchitecture:Ds,setIsAssigningArchitecture:ts,showArchitectureStatusModal:js,setShowArchitectureStatusModal:tn,architectureStatus:vn,setArchitectureStatus:jn,architectureRemarks:xn,setArchitectureRemarks:gn,isUpdatingArchitecture:Ye,setIsUpdatingArchitecture:qt,isAssigningParticipant:Ze,setIsAssigningParticipant:Gt,documentConfigs:St,setDocumentConfigs:qn,fddAgencies:Er,setFddAgencies:Fr,selectedAgencyId:wn,setSelectedAgencyId:Js,isAssigningAgency:Sa,setIsAssigningAgency:It,showAssignFddModal:As,setShowAssignFddModal:_r,isApproving:ca,setIsApproving:Ca,isRejecting:Yr,setIsRejecting:Nr,ktMatrixScores:kn,setKtMatrixScores:Sn,ktMatrixSelectedValues:sr,setKtMatrixSelectedValues:wr,ktMatrixRemarks:Sr,setKtMatrixRemarks:yn,ktMatrixRecommendation:Dn,setKtMatrixRecommendation:Aa,isSubmittingKT:ka,setIsSubmittingKT:qi,selectedInterviewForFeedback:xi,setSelectedInterviewForFeedback:gi,showFddFinalizeModal:bl,setShowFddFinalizeModal:jl,showFddFlagModal:da,setShowFddFlagModal:Da,fddAuditRecommendation:ua,setFddAuditRecommendation:Va,fddAuditFindings:fc,setFddAuditFindings:Rd,isFinalizingFdd:vi,setIsFinalizingFdd:nr,isFddFlagging:yi,setIsFddFlagging:zi,level2Feedback:Br,setLevel2Feedback:yo,level2Recommendation:Ui,setLevel2Recommendation:bo,isSubmittingLevel2:bi,setIsSubmittingLevel2:Nl,level3Feedback:wl,setLevel3Feedback:rn,level3Recommendation:ee,setLevel3Recommendation:se,isSubmittingLevel3:he,setIsSubmittingLevel3:pe,showFeedbackDetailsModal:Ne,setShowFeedbackDetailsModal:$e,selectedEvaluationForView:qe,setSelectedEvaluationForView:ct}=ZU({initialTab:((yc=A.state)==null?void 0:yc.activeTab)||"questionnaire"}),ds=(v||[]).some(ur=>(ur.noteText||"").includes("FLAGGED:"))||(d==null?void 0:d.statutoryStatus)==="Flagged",{handleUpdateFirmType:Kt,handleEditStatutory:Ft,handleSaveStatutory:Rs,fetchFddAgencies:cn,handleAssignAgency:Kn}=aV({application:d,applicationId:r,tempFirmType:P,setUpdatingFirmType:R,setShowFirmTypeModal:q,setStatutoryForm:Ee,setIsEditingStatutory:Ws,setIsSavingStatutory:Xt,statutoryForm:nn,setFddAgencies:Fr,selectedAgencyId:wn,setIsAssigningAgency:It,fetchApplication:C}),zt=(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",Es=(n==null?void 0:n.roleCode)==="Super Admin"||(n==null?void 0:n.roleCode)==="DD Admin"||(n==null?void 0:n.role)==="Super Admin"||(n==null?void 0:n.role)==="DD Admin"||(n==null?void 0:n.role)==="NBH"||(n==null?void 0:n.role)==="DD Head"||(n==null?void 0:n.roleCode)==="NBH"||(n==null?void 0:n.roleCode)==="DD_HEAD";g.useEffect(()=>{(async()=>{try{const Rl=await ps.getDocumentConfigs({limit:1e3}),hh=Rl.data||(Array.isArray(Rl)?Rl:[]);qn(hh)}catch(Rl){console.error("Failed to fetch document configs:",Rl)}})()},[qn]),g.useEffect(()=>{re&&d&&(d.status==="Shortlisted"||d.status==="Questionnaire Completed"?Ae("level1"):d.status==="Level 1 Approved"?Ae("level2"):(d.status==="Level 2 Approved"||d.status==="Level 2 Recommended")&&Ae("level3"))},[re,d==null?void 0:d.status,Ae]);const os=async()=>{if(r)try{const ur=await ps.getInterviews(r);Mt(ur||[])}catch(ur){console.error("Failed to fetch interviews",ur)}};g.useEffect(()=>{os()},[r]);const{ktMatrixConfig:On,level2Config:Cr,level3Config:zn}=eV(),{handleKTMatrixChange:cr,calculateKTScore:$r,handleSubmitKTMatrix:Ha,handleLevel2Change:dr,handleSubmitLevel2Feedback:jo,handleLevel3Change:Sl,handleSubmitLevel3Feedback:pc,ktCriteria:No,l2Fields:Cl,l3Fields:Vi}=JU({ktMatrixScores:kn,setKtMatrixScores:Sn,setKtMatrixSelectedValues:wr,ktMatrixRemarks:Sr,setKtMatrixRemarks:yn,ktMatrixRecommendation:Dn,setKtMatrixRecommendation:Aa,selectedInterviewForFeedback:xi,interviews:Cs,setIsSubmittingKT:qi,setShowKTMatrixModal:ft,level2Feedback:Br,setLevel2Feedback:yo,level2Recommendation:Ui,setLevel2Recommendation:bo,setIsSubmittingLevel2:Nl,setShowLevel2FeedbackModal:Ce,level3Feedback:wl,setLevel3Feedback:rn,level3Recommendation:ee,setLevel3Recommendation:se,setIsSubmittingLevel3:pe,setShowLevel3FeedbackModal:We,currentUser:n,fetchInterviews:os,fetchApplication:C,ktMatrixConfig:On,level2Config:Cr,level3Config:zn});g.useEffect(()=>{["documents","progress","fdd","eor"].includes($)&&r&&b(),$==="fdd"&&((n==null?void 0:n.role)==="DD Admin"||(n==null?void 0:n.role)==="Super Admin")&&cn()},[$,r,b,cn,n==null?void 0:n.role]);const{handleAddInterviewer:Wa,handleRemoveInterviewer:xc,maybeFetchUsersForModal:rr,handleScheduleInterview:gc,handleRescheduleInterview:Ra,handleConfirmCancelInterview:Al,handleUpload:Hi,handleApprove:Ea,handleReject:Ga,handleGenerateDealerCodes:kl,handleAssignArchitecture:Wi,handleUpdateArchitectureStatus:wo,handleAddParticipant:oh,handleRetriggerEvaluators:Dl}=tV({application:d,applicationId:r,currentUser:n,interviews:Cs,approvalFile:Os,approvalRemark:ot,rejectionReason:K,architectureLeadId:bs,architectureStatus:vn,architectureRemarks:xn,selectedUser:fs,participantType:Qs,users:_s,interviewDate:ie,setInterviewDate:nt,interviewType:fe,setInterviewType:Ae,interviewMode:de,setInterviewMode:at,meetingLink:Fe,setMeetingLink:Ke,location:Le,setLocation:Ue,scheduledInterviewParticipants:V,uploadFile:ss,uploadDocType:kt,selectedStage:Je,setIsApproving:Ca,setShowApproveModal:W,setApprovalRemark:ke,setApprovalFile:as,setIsRejecting:Nr,setShowRejectModal:I,setRejectionReason:G,setIsAssigningArchitecture:ts,setShowAssignArchitectureModal:Jt,setIsUpdatingArchitecture:qt,setShowArchitectureStatusModal:tn,setIsAssigningParticipant:Gt,setSelectedUser:Vs,setShowAssignModal:ge,setLoading:f,setIsScheduling:xt,setShowScheduleModal:ae,setShowCancelInterviewModal:ye,interviewIdToCancel:ce,setInterviewIdToCancel:je,interviewToReschedule:Me,setInterviewToReschedule:ut,setIsCancellingInterview:Ot,setIsUploading:be,setShowUploadForm:dt,setUploadFile:Wt,setUploadDocType:wt,setDocuments:h,selectedInterviewerId:rs,setSelectedInterviewerId:is,setScheduledInterviewParticipants:Y,setUsers:Us,showScheduleModal:re,showAssignArchitectureModal:Pt,showAssignModal:ht,fetchApplication:C,fetchInterviews:os,fetchEorData:S});if(g.useEffect(()=>{rr()},[re,Pt,ht,fe,d==null?void 0:d.id,rr]),m&&!d)return e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx(cs,{className:"w-10 h-10 animate-spin text-re-red"})});if(!d)return e.jsx("div",{className:"flex justify-center items-center h-96",children:"Application not found"});const{processStages:Ap,eorChecklist:kp,flattenedStages:Dp,getDocumentsForStage:ch}=iV({application:d,documents:p,interviews:Cs,eorData:x,getDeposit:D,documentConfigs:St}),{activeInterviewForUser:dh,currentUserEvaluation:So,hasSubmittedFeedback:Co,currentUserStageAction:Rp,isInterviewCompleted:vc,isInterviewActive:Ep,permissions:uh}=YU({application:d,interviews:Cs,currentUser:n,getDeposit:D,eorProgress:_}),Ed=()=>e.jsx(VU,{application:d,documents:p,setPreviewDoc:Ve,setShowPreviewModal:gt,setIsUploading:be,fetchApplication:C,refreshDocuments:b});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(DU,{application:d,slaStatus:i,isNonResponsive:ds,isAdmin:Es,onBack:a,onOpenWorknotes:()=>s(`/worknotes/application/${d.id}`,{state:{applicationName:d.name,registrationNumber:d.registrationNumber,participants:d.participants}})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsx(LU,{application:d,canEditStatutory:zt,isEditingStatutory:Ts,isSavingStatutory:$t,statutoryForm:nn,onEditFirmType:()=>{L(d.constitutionType||""),q(!0)},onEditStatutory:Ft,onCancelEditStatutory:()=>Ws(!1),onSaveStatutory:Rs,onStatutoryFormChange:Ee}),d.isShortlisted!==!1&&e.jsx(BU,{application:d,activeTab:$,setActiveTab:Z,processStages:Ap,documents:p,interviews:Cs,expandedBranches:Zt,setExpandedBranches:Bt,setSelectedStage:mt,setShowDocumentsModal:rt,setShowUploadForm:dt,handleRetriggerEvaluators:Dl,handleRescheduleInterview:Ra,setSelectedEvaluationForView:ct,setShowFeedbackDetailsModal:$e,renderFddAuditContent:Ed,eorProgress:_,eorData:x,eorChecklist:kp,setUploadDocType:wt,isAdmin:Es,fetchApplication:C,fetchEorData:S,deposits:w,getDeposit:D,paymentConfigs:j,setPreviewDoc:Ve,setShowPreviewModal:gt,auditLoading:N,auditLogs:u,auditLogActionBadgeClass:HU})]}),e.jsx($U,{application:d,permissions:uh,getDeposit:D,isNonResponsive:ds,isAdmin:Es,currentUserStageAction:Rp,currentUserEvaluation:So,onOpenApproveModal:()=>W(!0),onOpenRejectModal:()=>I(!0),onOpenWorknote:()=>s(`/worknotes/application/${d.id}`,{state:{applicationName:d.name,registrationNumber:d.registrationNumber,participants:d.participants}}),onOpenScheduleModal:()=>ae(!0),currentUser:n,handleGenerateDealerCodes:kl,onOpenAssignArchitectureModal:()=>Jt(!0),onOpenAssignFdd:()=>{Js(""),cn(),_r(!0)},showAssignFddModal:As,setShowAssignFddModal:_r,fddAgencies:Er,selectedAgencyId:wn,setSelectedAgencyId:Js,isAssigningAgency:Sa,handleAssignAgency:async()=>{await Kn(),_r(!1)},activeInterviewForUser:dh,hasSubmittedFeedback:Co,setSelectedInterviewForFeedback:gi,setShowKTMatrixModal:ft,setShowLevel2FeedbackModal:Ce,setShowLevel3FeedbackModal:We,onGoToDashboard:()=>s("/dashboard"),showAssignModal:ht,setShowAssignModal:ge,selectedUser:fs,setSelectedUser:Vs,users:_s,participantType:Qs,setParticipantType:Xs,handleAddParticipant:oh,isAssigningParticipant:Ze}),e.jsx(qU,{application:d,fetchApplication:C,showApproveModal:Q,setShowApproveModal:W,approvalRemark:ot,setApprovalRemark:ke,setApprovalFile:as,isApproving:ca,handleApprove:Ea,showOnboardModal:U,setShowOnboardModal:M,isOnboarding:z,setIsOnboarding:T,showRejectModal:F,setShowRejectModal:I,rejectionReason:K,setRejectionReason:G,isRejecting:Yr,handleReject:Ga,showScheduleModal:re,setShowScheduleModal:ae,showCancelInterviewModal:ue,setShowCancelInterviewModal:ye,setInterviewIdToCancel:je,isCancellingInterview:yt,handleConfirmCancelInterview:Al,interviewToReschedule:Me,setInterviewToReschedule:ut,interviewType:fe,setInterviewType:Ae,interviewMode:de,setInterviewMode:at,interviewDate:ie,setInterviewDate:nt,meetingLink:Fe,setMeetingLink:Ke,location:Le,setLocation:Ue,isInterviewCompleted:vc,isInterviewActive:Ep,users:_s,selectedInterviewerId:rs,setSelectedInterviewerId:is,handleAddInterviewer:Wa,scheduledInterviewParticipants:V,handleRemoveInterviewer:xc,isScheduling:ze,handleScheduleInterview:gc,showAssignArchitectureModal:Pt,setShowAssignArchitectureModal:Jt,architectureLeadId:bs,setArchitectureLeadId:ns,isAssigningArchitecture:Ds,handleAssignArchitecture:Wi,showArchitectureStatusModal:js,setShowArchitectureStatusModal:tn,architectureStatus:vn,setArchitectureStatus:jn,architectureRemarks:xn,setArchitectureRemarks:gn,isUpdatingArchitecture:Ye,handleUpdateArchitectureStatus:wo}),e.jsx(zU,{application:d,ktCriteria:No,l2Fields:Cl,l3Fields:Vi,showKTMatrixModal:jt,setShowKTMatrixModal:ft,ktMatrixSelectedValues:sr,handleKTMatrixChange:cr,ktMatrixRemarks:Sr,setKtMatrixRemarks:yn,ktMatrixRecommendation:Dn,setKtMatrixRecommendation:Aa,calculateKTScore:$r,handleSubmitKTMatrix:Ha,isSubmittingKT:ka,showLevel2FeedbackModal:X,setShowLevel2FeedbackModal:Ce,level2Feedback:Br,handleLevel2Change:dr,level2Recommendation:Ui,setLevel2Recommendation:bo,handleSubmitLevel2Feedback:jo,isSubmittingLevel2:bi,showFeedbackDetailsModal:Ne,setShowFeedbackDetailsModal:$e,selectedEvaluationForView:qe,selectedInterviewForFeedback:xi,showLevel3FeedbackModal:xe,setShowLevel3FeedbackModal:We,level3Feedback:wl,handleLevel3Change:Sl,level3Recommendation:ee,setLevel3Recommendation:se,handleSubmitLevel3Feedback:pc,isSubmittingLevel3:he,showDocumentsModal:Be,setShowDocumentsModal:rt,showUploadForm:et,setShowUploadForm:dt,selectedStage:Je,getDocumentsForStage:ch,setPreviewDoc:Ve,setShowPreviewModal:gt,flattenedStages:Dp,setSelectedStage:mt,uploadDocType:kt,setUploadDocType:wt,setUploadFile:Wt,isUploading:Se,handleUpload:Hi,uploadFile:ss,documentConfigs:St,showPreviewModal:bt,previewDoc:pt,showFddFinalizeModal:bl,setShowFddFinalizeModal:jl,currentUser:n,fddAuditRecommendation:ua,setFddAuditRecommendation:Va,fddAuditFindings:fc,setFddAuditFindings:Rd,isFinalizingFdd:vi,setIsFinalizingFdd:nr,fetchApplication:C,showFddFlagModal:da,setShowFddFlagModal:Da,isFddFlagging:yi,setIsFddFlagging:zi,showFirmTypeModal:E,setShowFirmTypeModal:q,tempFirmType:P,setTempFirmType:L,updatingFirmType:O,handleUpdateFirmType:Kt})]})]})};function mc(t,s=!0){const[n,r]=g.useState({});return g.useEffect(()=>{if(!s||t.length===0){r({});return}Yl.getBatchStatus(t).then(i=>{i!=null&&i.success&&r(i.data)}).catch(()=>r({}))},[s,JSON.stringify(t.map(i=>`${i.entityType}:${i.entityId}`).sort())]),{byKey:n,get:(i,o)=>n[`${i}:${o}`]??null}}const Vg=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 lV({onViewDetails:t}){const[s,n]=g.useState([]),[r,a]=g.useState(!0),[i,o]=g.useState(1),[d,m]=g.useState("all"),[f,p]=g.useState(null),h=10,x=async()=>{var b;a(!0);try{const S=(await Re.getResignations({page:i,limit:h,status:d==="all"?void 0:d==="open"?"open":"Completed,Closed"})).data;S!=null&&S.success&&(n(S.requests||((b=S.resignations)==null?void 0:b.rows)||S.resignations||[]),p(S.meta))}catch(C){console.error("Error fetching resignations:",C),J.error("Failed to fetch resignation requests")}finally{a(!1)}};g.useEffect(()=>{x()},[i,d]);const u=b=>{m(b),o(1)},N=d==="open"?s:[],v=d==="completed"?s:[],w=s.map(b=>({entityType:"resignation",entityId:b.id})),{get:j}=mc(w,s.length>0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"All Requests"}),e.jsx(st,{className:"text-3xl",children:(f==null?void 0:f.total)||0})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Total Requests"})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Open"}),e.jsx(st,{className:"text-3xl text-yellow-600",children:d==="open"?(f==null?void 0:f.total)||0:"..."})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Requires Your Action"})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Completed"}),e.jsx(st,{className:"text-3xl text-green-600",children:d==="completed"?(f==null?void 0:f.total)||0:"..."})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Finalized"})})]})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(st,{children:"Resignation Requests"}),e.jsxs(es,{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(Oe,{children:e.jsxs(In,{value:d,onValueChange:u,className:"w-full",children:[e.jsxs(Mn,{children:[e.jsx(Ht,{value:"all",children:"All Requests"}),e.jsx(Ht,{value:"open",children:"Open"}),e.jsx(Ht,{value:"completed",children:"Completed"})]}),e.jsx(Vt,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4 text-center py-1",children:r?e.jsx("div",{className:"text-center py-12",children:"Loading requests..."}):s.length>0?e.jsxs(e.Fragment,{children:[s.map(b=>{var C,S,D,_,A,E,q,O,R,P,L;return e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-red-50 rounded-lg",children:e.jsx(ks,{className:"w-6 h-6 text-re-red"})}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:b.resignationId}),e.jsx(we,{className:Vg(b.status),children:b.status}),e.jsx(br,{status:j("resignation",b.id),compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((S=(C=b.dealer)==null?void 0:C.dealerProfile)==null?void 0:S.businessName)||((D=b.outlet)==null?void 0:D.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:((E=(A=(_=b.dealer)==null?void 0:_.dealerProfile)==null?void 0:A.dealerCode)==null?void 0:E.dealerCode)||((q=b.outlet)==null?void 0:q.code)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:((R=(O=b.dealer)==null?void 0:O.dealerProfile)==null?void 0:R.registeredAddress)||((P=b.outlet)!=null&&P.city&&((L=b.outlet)!=null&&L.state)?`${b.outlet.city}, ${b.outlet.state}`:"N/A")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Type"}),e.jsx("p",{children:b.resignationType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Reason"}),e.jsx("p",{className:"truncate max-w-[200px]",children:b.reason})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:b.currentStage})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(er,{className:"w-4 h-4 text-slate-500"}),e.jsx("p",{children:Qt(b.submittedOn)})]})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>t(b.id),className:"ml-4",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},b.id)}),f&&f.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center",children:e.jsx(mo,{children:e.jsxs(fo,{children:[e.jsx(pn,{children:e.jsx(po,{onClick:()=>o(b=>Math.max(1,b-1)),className:i===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(f.totalPages)].map((b,C)=>{const S=C+1;return S===1||S===f.totalPages||S>=i-1&&S<=i+1?e.jsx(pn,{children:e.jsx($i,{isActive:i===S,onClick:()=>o(S),className:"cursor-pointer",children:S})},S):S===2&&i>3||S===f.totalPages-1&&io(b=>Math.min(f.totalPages,b+1)),className:i===f.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]}):e.jsx("div",{className:"text-center py-12 text-slate-500",children:e.jsx("p",{children:"No resignation requests found"})})})}),e.jsx(Vt,{value:"open",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:N.length>0?N.map(b=>{var C,S,D,_,A,E,q;return e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{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(ks,{className:"w-6 h-6 text-yellow-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:b.resignationId}),e.jsx(we,{className:Vg(b.status),children:b.status}),e.jsx(br,{status:j("resignation",b.id),compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((S=(C=b.dealer)==null?void 0:C.dealerProfile)==null?void 0:S.businessName)||((D=b.outlet)==null?void 0:D.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:((A=(_=b.dealer)==null?void 0:_.dealerProfile)==null?void 0:A.registeredAddress)||((E=b.outlet)!=null&&E.city&&((q=b.outlet)!=null&&q.state)?`${b.outlet.city}, ${b.outlet.state}`:"N/A")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:b.currentStage})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Qt(b.submittedOn)})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>t(b.id),className:"ml-4",children:[e.jsx(un,{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(ks,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No requests requiring your action"})]})})}),e.jsx(Vt,{value:"completed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:v.length>0?v.map(b=>{var C,S,D,_,A,E;return e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{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(ks,{className:"w-6 h-6 text-green-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:b.resignationId}),e.jsx(we,{className:Vg(b.status),children:b.status}),e.jsx(br,{status:j("resignation",b.id),compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((S=(C=b.dealer)==null?void 0:C.dealerProfile)==null?void 0:S.businessName)||((D=b.outlet)==null?void 0:D.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:((A=(_=b.dealer)==null?void 0:_.dealerProfile)==null?void 0:A.registeredAddress)||((E=b.outlet)==null?void 0:E.city)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Final Stage"}),e.jsx("p",{children:b.currentStage})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Qt(b.submittedOn)})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>t(b.id),className:"ml-4",children:[e.jsx(un,{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(ks,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No completed resignations to display"})]})})})]})})]})]})}const Ri="Last Working Day",ES="Proposed Last Working Day",Vc={AWAITING_FNF:"Awaiting F&F",AWAITING_FNF_LWD_PENDING:"Awaiting F&F (LWD Pending)"},Ei=lr.inProgress;function lj(t){if(!t)return"Pending";let s=t;return s=s.replace(/Personal Hearing/gi,"SCN Response Evaluation"),s=s.replace(/\(LWD Pending\)/gi,"(Last Working Day Pending)"),s=s.replace(/\bLWD\b/g,Ri),s}const oV=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"}},Hg=t=>t.includes("Approved")||t.includes("Terminated")?"bg-green-100 text-green-700 border-green-300":t.includes("Review")||t.includes("Pending")?"bg-yellow-100 text-yellow-700 border-yellow-300":t.includes("Rejected")?"bg-red-100 text-red-700 border-red-300":"bg-blue-100 text-blue-700 border-blue-300",iu=lj;function cV({currentUser:t,onViewDetails:s}){const[n,r]=g.useState(!1),[a,i]=g.useState([]),[o,d]=g.useState(""),[m,f]=g.useState(!1),[p,h]=g.useState(""),[x,u]=g.useState(null),[N,v]=g.useState([]),[w,j]=g.useState({}),[b,C]=g.useState(!0),[S,D]=g.useState(1),[_,A]=g.useState(null),[E,q]=g.useState("all"),O=10,[R,P]=g.useState({terminationCategory:"",reason:"",proposedLwd:"",comments:"",document:null}),L=async()=>{C(!0);try{const K=(await Re.getTerminations({page:S,limit:O,status:E==="all"?void 0:E})).data;if(K!=null&&K.success){v(K.terminations),A(K.meta);const G=K.terminations||[];G.length?Yl.getBatchStatus(G.map(V=>({entityType:"termination",entityId:V.id}))).then(V=>{if(V!=null&&V.success){const Y={};G.forEach(re=>{Y[re.id]=V.data[`termination:${re.id}`]??null}),j(Y)}}).catch(()=>j({})):j({})}}catch(I){console.error("Error fetching terminations:",I),J.error("Failed to fetch termination requests")}finally{C(!1)}};g.useEffect(()=>{L()},[S,E]);const $=I=>{q(I),D(1)};g.useEffect(()=>{if(!n||!z)return;let I=!1;return(async()=>{try{f(!0);const G=(await Re.getDealers({onboarded:"true",activeOnly:"true"})).data;if(!I&&(G!=null&&G.success)){const V=(Array.isArray(G.data)?G.data:[]).filter(Y=>{var ue,ye;const re=String((Y==null?void 0:Y.status)||"").toLowerCase(),ae=String(((ue=Y==null?void 0:Y.user)==null?void 0:ue.status)||"").toLowerCase();return re==="active"&&((ye=Y==null?void 0:Y.user)==null?void 0:ye.isActive)&&ae==="active"});i(V)}}catch(K){I||(console.error("Error fetching dealers:",K),J.error("Failed to load dealer list"))}finally{I||f(!1)}})(),()=>{I=!0}},[n]);const Z=I=>{var K,G,V,Y,re,ae;return{id:I.id,dealerId:I.id,dealerCode:((K=I.dealerCode)==null?void 0:K.dealerCode)||"",legalName:I.legalName||"N/A",businessName:I.businessName||"N/A",gstNumber:I.gstNumber||"N/A",address:I.registeredAddress||((G=I.application)==null?void 0:G.preferredLocation)||"N/A",city:((V=I.application)==null?void 0:V.city)||"N/A",state:((Y=I.application)==null?void 0:Y.state)||"N/A",email:((re=I.user)==null?void 0:re.email)||"N/A",phoneNumber:((ae=I.user)==null?void 0:ae.mobileNumber)||"N/A"}},Q=I=>{d(I);const K=a.find(V=>String(V.id)===String(I));if(!K){h(""),u(null);return}const G=Z(K);h(G.dealerCode),u(G)},W=I=>{h(I);const K=I.trim().toLowerCase();if(!K){d(""),u(null);return}const G=a.find(V=>{var Y;return String(((Y=V.dealerCode)==null?void 0:Y.dealerCode)||"").toLowerCase()===K});if(!G){d(""),u(null);return}d(String(G.id)),u(Z(G))},U=async I=>{var K,G,V;if(I.preventDefault(),!x){J.error("Please select a dealer");return}try{const Y={dealerId:x.dealerId||x.id,category:R.terminationCategory,reason:R.reason,proposedLwd:R.proposedLwd,comments:R.comments};if(!Y.dealerId){J.error("Dealer record not found for the selected dealer");return}const ae=(await Re.createTermination(Y)).data;if(ae!=null&&ae.success){const ue=(K=ae.termination)==null?void 0:K.id;if(ue&&R.document){const ye=new FormData;ye.append("file",R.document),ye.append("documentType","Termination Recommendation"),ye.append("stage","Submitted");try{await Re.uploadTerminationDocument(ue,ye),J.success("Termination request and supporting document submitted")}catch(ce){console.error("Error uploading supporting document:",ce),J.warning("Termination created, but document upload failed. You can upload it from the details page.")}}else J.success("Termination request submitted successfully");r(!1),L(),d(""),h(""),i([]),u(null),P({terminationCategory:"",reason:"",proposedLwd:"",comments:"",document:null})}}catch(Y){console.error("Error submitting termination:",Y),J.error(((V=(G=Y.response)==null?void 0:G.data)==null?void 0:V.message)||"Failed to submit termination request")}},M=["DD Lead","ASM","DD Admin","DD AM","Super Admin"],z=(t==null?void 0:t.role)&&M.includes(t.role),T=E==="open"||E==="all"?N:[],F=E==="completed"||E==="all"?N:[];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"All Cases"}),e.jsx(st,{className:"text-3xl",children:(_==null?void 0:_.total)||0})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Total Cases"})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Open"}),e.jsx(st,{className:"text-3xl text-orange-600",children:E==="open"?(_==null?void 0:_.total)||0:"..."})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Requires Your Action"})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Completed"}),e.jsx(st,{className:"text-3xl text-green-600",children:E==="completed"?(_==null?void 0:_.total)||0:"..."})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Finalized"})})]})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"Termination Requests"}),e.jsx(es,{children:"Manage dealer termination proceedings and legal compliance"})]}),z&&e.jsxs(ms,{open:n,onOpenChange:r,children:[e.jsx(oo,{asChild:!0,children:e.jsxs(te,{className:"bg-red-600 hover:bg-red-700",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Create Termination Request"]})}),e.jsxs(us,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Create Termination Request"}),e.jsx(ws,{children:"Fill in the details to create a new termination request"})]}),e.jsxs("form",{onSubmit:U,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Select Dealer *"}),e.jsxs(Rt,{value:o,onValueChange:Q,disabled:m,children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:m?"Loading dealers...":"Select dealer"})}),e.jsx(Tt,{children:a.map(I=>{var K;return e.jsxs(Pe,{value:String(I.id),children:[I.legalName||I.businessName||"Unnamed Dealer"," - ",((K=I.dealerCode)==null?void 0:K.dealerCode)||"No Code"]},I.id)})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"dealerCode",children:"Dealer Code *"}),e.jsx(it,{id:"dealerCode",value:p,onChange:I=>W(I.target.value),placeholder:"Type dealer code to auto-select",required:!0})]}),x&&e.jsxs("div",{className:"grid grid-cols-2 gap-4 p-4 bg-slate-50 rounded-lg",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Name (Legal)"}),e.jsx("p",{children:x.legalName||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Business Name"}),e.jsx("p",{children:x.businessName||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:x.gstNumber||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Address"}),e.jsx("p",{children:x.address})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"City/State"}),e.jsxs("p",{children:[x.city,", ",x.state]})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:x.dealerCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Contact"}),e.jsxs("p",{children:[x.email," / ",x.phoneNumber]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Termination Category *"}),e.jsxs(Rt,{value:R.terminationCategory,onValueChange:I=>P({...R,terminationCategory:I}),children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Select termination category"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"Working Capital",children:"Working Capital"}),e.jsx(Pe,{value:"Performance Issues",children:"Performance Issues"}),e.jsx(Pe,{value:"Unethical Practice",children:"Unethical Practice"}),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.jsxs(le,{children:[ES," *"]}),e.jsx(it,{type:"date",value:R.proposedLwd,onChange:I=>P({...R,proposedLwd:I.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"reason",children:"Termination Reason *"}),e.jsx(it,{id:"reason",value:R.reason,onChange:I=>P({...R,reason:I.target.value}),placeholder:"Primary reason for termination",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"comments",children:"Additional Comments *"}),e.jsx(Ks,{id:"comments",value:R.comments,onChange:I=>P({...R,comments:I.target.value}),placeholder:"Detailed observations and justification",rows:4,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"document",children:"Upload Supporting Document"}),e.jsx(it,{id:"document",type:"file",onChange:I=>{var K;return P({...R,document:((K=I.target.files)==null?void 0:K[0])||null})}})]}),e.jsxs(mn,{children:[e.jsx(te,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(te,{type:"submit",className:"bg-red-600 hover:bg-red-700",children:"Submit Request"})]})]})]})]})]})}),e.jsxs(Oe,{children:[e.jsxs(In,{value:E,onValueChange:$,className:"w-full",children:[e.jsxs(Mn,{children:[e.jsx(Ht,{value:"all",children:"All Cases"}),e.jsx(Ht,{value:"open",children:"Open"}),e.jsx(Ht,{value:"completed",children:"Completed"})]}),e.jsx(Vt,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:b?e.jsx("div",{className:"text-center py-12",children:"Loading requests..."}):N.length>0?N.map(I=>{var K,G,V,Y;return e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{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(ai,{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:I.requestId||((G=(K=I.dealer)==null?void 0:K.dealerCode)==null?void 0:G.code)||"N/A"}),e.jsx(we,{className:oV(I.severity||"Medium"),children:I.severity||"Normal"}),e.jsx(we,{className:Hg(I.status),children:iu(I.status)}),e.jsx(br,{status:w[I.id],compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((V=I.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:((Y=I.dealer)==null?void 0:Y.registeredAddress)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Category"}),e.jsx("p",{children:I.category})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:iu(I.currentStage)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:ES}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(er,{className:"w-4 h-4 text-slate-500"}),e.jsx("p",{children:I.proposedLwd})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Qt(I.createdAt)})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(I.id),className:"ml-4",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},I.id)}):e.jsx("div",{className:"text-center py-12 text-slate-500",children:e.jsx("p",{children:"No termination requests found"})})})}),e.jsx(Vt,{value:"open",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:T.length>0?T.map(I=>{var K,G,V;return e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{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(Ba,{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:I.requestId||((G=(K=I.dealer)==null?void 0:K.dealerCode)==null?void 0:G.code)||"N/A"}),e.jsx(we,{className:Hg(I.status),children:iu(I.status)}),e.jsx(br,{status:w[I.id],compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:(V=I.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:I.reason})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:iu(I.currentStage)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Qt(I.createdAt)})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(I.id),className:"ml-4",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},I.id)}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(ai,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No requests requiring your action"})]})})}),e.jsx(Vt,{value:"completed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:F.length>0?F.map(I=>{var K,G,V;return e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{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(ai,{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:I.requestId||((G=(K=I.dealer)==null?void 0:K.dealerCode)==null?void 0:G.code)||"N/A"}),e.jsx(we,{className:Hg(I.status),children:iu(I.status)}),e.jsx(br,{status:w[I.id],compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:(V=I.dealer)==null?void 0:V.businessName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Closed On"}),e.jsx("p",{children:Qt(I.updatedAt)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Termination Category"}),e.jsx("p",{children:I.category})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:Ri}),e.jsx("p",{children:I.proposedLwd})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(I.id),className:"ml-4",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},I.id)}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(ai,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No completed terminations to display"})]})})})]}),_&&_.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center bg-white rounded-b-lg",children:e.jsx(mo,{children:e.jsxs(fo,{children:[e.jsx(pn,{children:e.jsx(po,{onClick:()=>D(I=>Math.max(1,I-1)),className:S===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(_.totalPages)].map((I,K)=>{const G=K+1;return G===1||G===_.totalPages||G>=S-1&&G<=S+1?e.jsx(pn,{children:e.jsx($i,{isActive:S===G,onClick:()=>D(G),className:"cursor-pointer",children:G})},G):G===2&&S>3||G===_.totalPages-1&&S<_.totalPages-2?e.jsx(pn,{children:e.jsx(go,{})},G):null}),e.jsx(pn,{children:e.jsx(xo,{onClick:()=>D(I=>Math.min(_.totalPages,I+1)),className:S===_.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})]})}const lu=t=>{switch(t){case"Initiated":return"bg-blue-100 text-blue-700 border-blue-300";case"DD Clearance":case"Legal Clearance":return"bg-yellow-100 text-yellow-700 border-yellow-300";case"Finance Approval":case"Calculated":return"bg-orange-100 text-orange-700 border-orange-300";case"Completed":case"Settled":return"bg-green-100 text-green-700 border-green-300";default:return"bg-slate-100 text-slate-700 border-slate-300"}},ou=t=>t==="Resignation"?"bg-red-50 text-re-red-hover border-red-300":"bg-red-100 text-red-700 border-red-300";function dV({currentUser:t,onViewDetails:s}){const[n,r]=g.useState([]),[a,i]=g.useState(!0);g.useEffect(()=>{o()},[]);const o=async()=>{try{i(!0);const N=(await Re.getFnFSettlements()).data;N.success&&r(N.settlements||[])}catch(u){console.error("Fetch settlements error:",u),J.error("Failed to fetch settlement cases")}finally{i(!1)}};if(a)return e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(cs,{className:"w-8 h-8 animate-spin text-blue-600"})});const d=u=>{var N,v,w,j,b,C,S,D,_,A,E,q,O,R,P,L;return{id:u.id,caseNumber:u.settlementId||((N=u.resignation)==null?void 0:N.resignationId)||((v=u.terminationRequest)==null?void 0:v.requestId)||u.id.substring(0,8).toUpperCase(),status:u.status,requestType:u.resignationId?"Resignation":"Termination",dealerName:((j=(w=u.outlet)==null?void 0:w.dealer)==null?void 0:j.fullName)||((b=u.dealer)==null?void 0:b.legalName)||((C=u.dealer)==null?void 0:C.businessName)||((S=u.dealer)==null?void 0:S.fullName)||"N/A",dealerCode:((D=u.outlet)==null?void 0:D.code)||((A=(_=u.dealer)==null?void 0:_.dealerCode)==null?void 0:A.dealerCode)||"N/A",dealershipName:((E=u.outlet)==null?void 0:E.name)||"N/A",location:((q=u.outlet)==null?void 0:q.city)||((O=u.outlet)==null?void 0:O.location)||"N/A",originalRequestId:((R=u.resignation)==null?void 0:R.resignationId)||((P=u.terminationRequest)==null?void 0:P.requestId)||((L=u.terminationRequest)==null?void 0:L.id)||"N/A",submittedOn:Qt(u.createdAt),financeReportStatus:u.status==="Calculated"||u.status==="Settled"?"Completed":"Pending",totalRecoveryAmount:parseFloat(u.totalReceivables)||0,totalPayableAmount:parseFloat(u.totalPayables)||0,completedOn:u.settlementDate?Qt(u.settlementDate):null,departmentResponses:u.lineItems||[]}},m=n.map(d),f=m.filter(u=>u.status==="Initiated"),p=m.filter(u=>u.status==="DD Clearance"||u.status==="Legal Clearance"),h=m.filter(u=>u.status==="Finance Approval"||u.status==="Calculated"),x=m.filter(u=>u.status==="Completed"||u.status==="Settled");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:[e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Initiated"}),e.jsx(st,{className:"text-3xl text-blue-600",children:f.length})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Newly created"})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Clearance"}),e.jsx(st,{className:"text-3xl text-yellow-600",children:p.length})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Department / legal stage"})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Finance Approval"}),e.jsx(st,{className:"text-3xl text-orange-600",children:h.length})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Ready for finance review"})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Completed"}),e.jsx(st,{className:"text-3xl text-green-600",children:m.filter(u=>u.status==="Completed"||u.status==="Settled").length})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Finalized"})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"All Cases"}),e.jsx(st,{className:"text-3xl",children:m.length})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Total"})})]})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Full & Final Settlement Cases"}),e.jsxs(es,{children:["Manage dealer exit dues clearance and settlement",t&&` • Current Role: ${t.role}`]})]}),e.jsx(Oe,{children:e.jsxs(In,{defaultValue:"all",className:"w-full",children:[e.jsxs(Mn,{children:[e.jsx(Ht,{value:"all",children:"All Cases"}),e.jsx(Ht,{value:"initiated",children:"Initiated"}),e.jsx(Ht,{value:"clearance",children:"Clearance"}),e.jsx(Ht,{value:"finance",children:"Finance Approval"}),e.jsx(Ht,{value:"completed",children:"Completed"})]}),e.jsx(Vt,{value:"initiated",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[f.map(u=>e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-blue-100 rounded-lg",children:e.jsx(hu,{className:"w-6 h-6 text-blue-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:u.caseNumber}),e.jsx(we,{className:lu(u.status),children:u.status}),e.jsx(we,{className:ou(u.requestType),children:u.requestType})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:u.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:u.dealerCode})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealership Name"}),e.jsx("p",{children:u.dealershipName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:u.location})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Original Request ID"}),e.jsx("p",{children:u.originalRequestId})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(er,{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(te,{size:"sm",variant:"outline",onClick:()=>s(u.id),children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},u.id)),f.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(hu,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No initiated cases to display"})]})]})}),e.jsx(Vt,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:m.map(u=>e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{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(ya,{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(we,{className:lu(u.status),children:u.status}),e.jsx(we,{className:ou(u.requestType),children:u.requestType})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:u.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealership Name"}),e.jsx("p",{children:u.dealershipName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:u.location})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:u.submittedOn})]})]})]})]}),e.jsx("div",{className:"flex items-center gap-2 ml-4",children:e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(u.id),children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},u.id))})}),e.jsx(Vt,{value:"clearance",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[p.map(u=>e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{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(ya,{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(we,{className:lu(u.status),children:u.status}),e.jsx(we,{className:ou(u.requestType),children:u.requestType})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:u.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Departments Responded"}),e.jsxs("p",{children:[u.departmentResponses.filter(N=>N.status!=="Pending").length," / ",u.departmentResponses.length]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:u.submittedOn})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(u.id),className:"ml-4",children:[e.jsx(un,{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(ya,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No clearance-stage cases"})]})]})}),e.jsx(Vt,{value:"finance",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[h.map(u=>{var N,v;return e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{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",children:u.caseNumber}),e.jsx(we,{className:lu(u.status),children:u.status}),e.jsx(we,{className:ou(u.requestType),children:u.requestType})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:u.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Receivable amount"}),e.jsxs("p",{className:"text-red-600",children:["₹",(N=u.totalRecoveryAmount)==null?void 0:N.toLocaleString()]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Payable Amount"}),e.jsxs("p",{className:"text-green-600",children:["₹",(v=u.totalPayableAmount)==null?void 0:v.toLocaleString()]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Finance Status"}),e.jsx("p",{children:u.financeReportStatus})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(u.id),className:"ml-4",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},u.id)}),h.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(ya,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No finance-approval cases"})]})]})}),e.jsx(Vt,{value:"completed",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[x.map(u=>e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-green-100 rounded-lg",children:e.jsx(hu,{className:"w-6 h-6 text-green-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:u.caseNumber}),e.jsx(we,{className:lu(u.status),children:u.status}),e.jsx(we,{className:ou(u.requestType),children:u.requestType})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:u.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Completed On"}),e.jsx("p",{children:u.completedOn||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:u.submittedOn})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(u.id),className:"ml-4",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},u.id)),x.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(hu,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No completed cases"})]})]})})]})})]})]})}const Jo={getResignations:async()=>{try{return(await Re.getResignations()).data}catch(t){throw console.error("Get resignations error:",t),t}},createResignation:async t=>{try{return(await Re.createResignation(t)).data}catch(s){throw console.error("Create resignation error:",s),s}},getResignationById:async t=>{var s,n;try{const r=await Re.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 Re.updateClearance(t,s)).data}catch(n){throw console.error("Update clearance error:",n),n}},uploadDocument:async(t,s)=>{try{return(await Re.uploadResignationDocument(t,s)).data}catch(n){throw console.error("Upload resignation document error:",n),n}},withdraw:async(t,s)=>{try{return(await Re.withdrawResignation(t,s)).data}catch(n){throw console.error("Withdraw resignation error:",n),n}}},Wg=["Resignation Letter","Dealer Undertaking","Approval Note","Resignation Acceptance Letter","Handover Document","Settlement Supporting Document","PPT Presentation","Other"],uV=["Request Submitted","ASM","RBM","ZBH","DD Lead","NBH","DD Admin","Legal","F&F Initiated"],Gg=["Termination Recommendation","Show Cause Notice","SCN Response","Hearing Record","Approval Note","Termination Letter","Settlement Supporting Document","Other"],hV=["Submitted","RBM + DD-ZM Review","ZBH Review","DD Lead Review","Legal Verification","NBH Evaluation","Show Cause Notice","Personal Hearing","NBH Final Approval","CCO Approval","CEO Final Approval","Legal - Termination Letter"],mV={ASM:"ASM",RBM:"RBM",ZBH:"ZBH","DD Lead":"DD Lead",NBH:"NBH","DD Admin":"DD Admin",Legal:"Legal Admin"},_S=["REJECTED","Rejected","REVOKED","Revoked","WITHDRAWN","Withdrawn"],Kg={"Request Submitted":["Submission","Submitted","Initiation"],ASM:["ASM","ASM Review"],RBM:["RBM","RBM Review","Regional Review","RBM + DD-ZM Review"],ZBH:["ZBH","ZBH Review","ZM Review"],"DD Lead":["DD Lead","DD Lead Review","DDL Review"],NBH:["NBH","NBH Approval","NBH Review"],"DD Admin":["DD Admin","DD Admin Review"],"Awaiting F&F":["Awaiting F&F","Awaiting F&F — manual initiation"],Legal:["Legal","Legal - Resignation Letter"],"F&F Initiated":["F&F Initiated","FNF_INITIATED","FNF Initiated"],Completed:["Completed"]};function fV({resignationId:t,onBack:s,currentUser:n}){var Be,rt,ht,ge,Je,mt,de,at,ot,ke,Zt,Bt,_s,Us,fs,Vs,Qs,Xs,ie,nt,fe,Ae,Fe,Ke,Le,Ue,et,dt,ss,Wt,kt,wt,Os,as,Se;const{get:r}=mc(t?[{entityType:"resignation",entityId:t}]:[],!!t),a=(be,pt)=>{const Ve=[...(E==null?void 0:E.documents)||[],...(E==null?void 0:E.uploadedDocuments)||[]],bt=[be,pt,...pt?Kg[pt]||[]:[],...Kg[be]||[]].filter(gt=>!!gt).map(gt=>gt.trim().toLowerCase());return Ve.filter(gt=>{if(!(gt!=null&>.stage))return!1;const rs=String(gt.stage).trim().toLowerCase();return bt.includes(rs)})},i=tr(),[o,d]=g.useState({open:!1,type:null}),[m,f]=g.useState(""),[p,h]=g.useState(""),[x,u]=g.useState(""),[N,v]=g.useState(""),[w,j]=g.useState([]),[b,C]=g.useState(!1),[S,D]=g.useState(!1),[_,A]=g.useState({open:!1,stageName:"",documents:[]}),[E,q]=g.useState(null),[O,R]=g.useState(!1),[P,L]=g.useState([]),[$,Z]=g.useState(!1),[Q,W]=g.useState(null),[U,M]=g.useState(!1),[z,T]=g.useState(null),[F,I]=g.useState(Wg[0]),[K,G]=g.useState(""),V=g.useMemo(()=>[...(E==null?void 0:E.documents)||[],...(E==null?void 0:E.uploadedDocuments)||[]].some(pt=>(pt.documentType||pt.type)==="PPT Presentation"),[E]),Y=async()=>{try{R(!0);const be=await Jo.getResignationById(t);q(be),re()}catch(be){console.error("Error fetching resignation:",be)}finally{R(!1)}},re=async()=>{try{const be=await Re.getAuditLogs("resignation",t);be.data&&be.data.success&&L(be.data.data||[])}catch(be){console.error("Error fetching audit logs:",be)}};g.useEffect(()=>{Y()},[t]);const ae=[{id:1,name:"Request Submitted",key:"Request Submitted",description:"Dealer submitted the resignation request"},{id:2,name:"ASM Review",key:"ASM",description:"Area Sales Manager review"},{id:3,name:"RBM + DD-ZM Review",key:"RBM",description:"Joint approval by Regional Business Manager and DD-ZM"},{id:4,name:"ZBH Review",key:"ZBH",description:"Zonal Business Head approval"},{id:5,name:"DD Lead Review",key:"DD Lead",description:"DD Lead final review"},{id:6,name:"NBH Approval",key:"NBH",description:"National Business Head approval"},{id:7,name:"Legal - Resignation Letter",key:"Legal",description:"Legal team issues resignation approval letter"},{id:8,name:"DD Admin Review",key:"DD Admin",description:"DD Admin verification and final closure"},{id:9,name:"Awaiting F&F",key:"Awaiting F&F",description:"Internal review complete — start Full & Final using Push to F&F when ready"},{id:10,name:"F&F Settlement",key:"F&F Initiated",description:"Full & Final settlement process"},{id:11,name:"Completed",key:"Completed",description:"Resignation process finalized"}],ue=["Request Submitted","ASM","RBM","ZBH","DD Lead","NBH","Legal","DD Admin","Awaiting F&F","F&F Initiated","Completed"],ye=E?["F&F Initiated","Completed","Settled","FNF_INITIATED"].includes(String(E.status||E.currentStage||""))?!0:(Array.isArray(E.timeline)?E.timeline:[]).some(Ve=>{const bt=String((Ve==null?void 0:Ve.stage)||"").trim().toLowerCase(),gt=String((Ve==null?void 0:Ve.targetStage)||"").trim().toLowerCase(),rs=String((Ve==null?void 0:Ve.action)||"").trim().toLowerCase(),is=bt==="legal"||bt==="legal - resignation letter",Ts=gt==="legal"||gt==="dd admin"||gt==="awaiting f&f"||gt==="f&f initiated"||gt==="fnf_initiated"||rs.includes("approved");return is&&Ts}):!1,je=(()=>{if(!E||!n)return{canApprove:!1,canWithdraw:!1,canSendBack:!1,canPushToFnF:!1,canAssign:!1};const be=E.currentStage,pt=E.status,Ve=n.role,bt=be==="RBM"||be==="RBM Review"||be==="RBM + DD-ZM Review",gt=String(n.roleCode||n.role||"").trim().toUpperCase(),rs=bt&&P.some(Ds=>{var ts,js,tn,vn;return Ds.action==="PARTIAL_APPROVE"&&(((ts=Ds.actor)==null?void 0:ts.id)===n.id||Ds.actorId===n.id||((js=Ds.actor)==null?void 0:js.email)===n.email||Ds.userEmail===n.email)&&(((tn=Ds.details)==null?void 0:tn.roleCode)===gt||((vn=Ds.details)==null?void 0:vn.roleCode)==="DD-ZM"&>==="DD ZM")}),is=["Completed","Rejected","Withdrawn","Revoked"].includes(pt),Ts=pt==="F&F Initiated"||be==="F&F Initiated"||pt==="Settled"||pt==="FNF_INITIATED",Ws=ue.indexOf(be),nn=ue.indexOf("NBH"),Ee=Ws!==-1&&nn!==-1&&Ws>=nn,$t=gt==="SUPER_ADMIN"||bt&&(gt==="RBM"||gt==="DD-ZM"||gt==="DD ZM")||Ve===mV[be],Xt=be==="DD Lead"||be==="DD Lead Review",Cs=gt==="DD_LEAD"||gt==="DD LEAD",Mt=(()=>{const Ds=new Date;Ds.setHours(0,0,0,0);const ts=E.lastOperationalDateServices||E.lastOperationalDateSales;if(!ts)return!0;const js=new Date(ts);return js.setHours(0,0,0,0),Ds>=js})(),ze=be==="Awaiting F&F",xt=(()=>{const Ds=String(be||"").trim();return ue.find(js=>js===Ds||(Kg[js]||[]).includes(Ds))||Ds})(),yt=xt==="NBH",Ot=xt==="Awaiting F&F",Pt=xt==="Legal",Jt=["DD Lead","DD Head","DD Admin","Super Admin"],bs=["DD Lead","DD Head","DD Admin","Super Admin"];return{canApprove:$t&&!is&&!Ts&&!rs&&!(be==="Legal"&&ye)&&!(Cs&&Xt&&!V)&&!(be==="DD Admin"&&!Mt)&&!ze,canSendBack:$t&&!is&&!Ts&&Ws>0&&Ve!=="Legal Admin"&>!=="LEGAL_ADMIN",canWithdraw:Ve==="Dealer"&&!Ee&&!is,canRevoke:(gt==="SUPER_ADMIN"||Ve==="DD Admin")&&!is&&!Ts,canPushToFnF:Jt.includes(Ve)&&!Ts&&!is&&!yt&&Mt&&(Ot||Pt&&bs.includes(Ve)),canAssign:Ve!=="Dealer"&&!is}})(),Me=["Super Admin","DD Lead","DD Head","NBH","DD Admin","Legal Admin","DD-ZM"].includes((n==null?void 0:n.role)||""),ut={ASM:["ASM","ASM Review","Request Initiated"],RBM:["RBM","RBM Review","RBM + DD-ZM Review"],ZBH:["ZBH","ZBH Review"],"DD Lead":["DD Lead","DD Lead Review","Lead Review"],NBH:["NBH","NBH Approval","NBH Review"],"DD Admin":["DD Admin","DD Admin Review"],"Awaiting F&F":["Awaiting F&F","Awaiting F&F — manual initiation"],Legal:["Legal","Legal - Resignation Letter","Legal Review"],"F&F Initiated":["F&F Initiated","FNF_INITIATED","F&F Settlement","Settled"],Completed:["Completed","Finalized"]},jt=be=>{if(!be)return"";const pt=String(be).trim();return ue.find(bt=>bt===pt||(ut[bt]||[]).includes(pt))||pt},ft=be=>{if(!E)return"pending";const pt=["Rejected","Revoked","Withdrawn"].includes(E.status);let Ve=E.currentStage;if(pt&&(!Ve||_S.includes(String(Ve)))){const is=[...E.timeline||[]].reverse().find(Ts=>(Ts==null?void 0:Ts.stage)&&!_S.includes(String(Ts.stage)));is!=null&&is.stage&&(Ve=is.stage)}const bt=ue.indexOf(jt(Ve)),gt=ue.indexOf(be);if((E.status==="Completed"||E.status==="Settled")&><=bt)return"completed";const rs=["Rejected","Revoked","Withdrawn"].includes(E.status);return be==="Legal"&&ye&&!rs?"completed":bt===-1?be==="ASM"?"completed":"pending":gt{d({open:!0,type:be})},Ce=(be,pt)=>{const Ve=a(be,pt).map((bt,gt)=>{var rs;return{id:bt.id||`${be}-${gt}`,name:bt.name||bt.fileName||"Document",type:bt.type||bt.documentType||"Document",uploadDate:bt.uploadDate||(bt.createdAt?Qt(bt.createdAt):"N/A"),uploader:typeof bt.uploader=="string"?bt.uploader:((rs=bt.uploader)==null?void 0:rs.fullName)||bt.uploadedBy||"System",filePath:bt.filePath||bt.path}});A({open:!0,stageName:be,documents:Ve})},xe=async()=>{var be,pt,Ve,bt,gt,rs,is,Ts;if(!m&&!["assign","pushfnf"].includes(o.type||"")){J.error("Please provide remarks (min 5 characters)");return}if(["sendBack","revoke"].includes(o.type||"")&&m.trim().length<5){J.error("Remarks are required for this action (min 5 characters).");return}if(o.type==="assign"&&!p){J.error("Please select a designation");return}try{Z(!0);const nn={action:o.type==="sendBack"?"sendBack":o.type,remarks:m,assignTo:N||p,force:S},Ee=await Re.updateResignationStatus(t,nn);if((be=Ee.data)!=null&&be.success)J.success(((pt=Ee.data)==null?void 0:pt.message)||"Action completed successfully"),d({open:!1,type:null}),f(""),h(""),v(""),j([]),D(!1),Y();else{const $t=((Ve=Ee.data)==null?void 0:Ve.message)||"Failed to submit action";J.error($t),(bt=Ee.data)!=null&&bt.canForce&&J.info(`${Ri} restriction: use "Push to F&F" and enable "Force Initiate F&F Settlement Immediately" if urgent.`)}}catch(Ws){console.error("Error submitting action:",Ws),J.error(((rs=(gt=Ws.response)==null?void 0:gt.data)==null?void 0:rs.message)||"Failed to submit action"),(Ts=(is=Ws==null?void 0:Ws.response)==null?void 0:is.data)!=null&&Ts.canForce&&J.info(`${Ri} restriction: use "Push to F&F" with the force option if business-approved.`)}finally{Z(!1)}},We=async()=>{var be,pt;if(!z){J.error("Please select a file to upload");return}try{Z(!0);const Ve=new FormData;Ve.append("file",z),Ve.append("documentType",F),K&&Ve.append("stage",K),await Jo.uploadDocument(t,Ve),J.success("Document uploaded successfully"),M(!1),T(null),I(Wg[0]),G(""),Y()}catch(Ve){J.error(((pt=(be=Ve==null?void 0:Ve.response)==null?void 0:be.data)==null?void 0:pt.message)||"Failed to upload document")}finally{Z(!1)}};return g.useEffect(()=>{(async()=>{if(o.type==="assign"&&(p||x)){const pt=setTimeout(async()=>{var Ve;try{C(!0);const bt={asm:"ASM",rbm:"RBM",zbh:"ZBH",nbh:"NBH",legal:"Legal Admin"},gt={limit:20,search:x};p&&(gt.roleCode=bt[p]||p);const rs=await Re.getUsers(gt);(Ve=rs.data)!=null&&Ve.success&&j(rs.data.data)}catch(bt){console.error("Error fetching users:",bt)}finally{C(!1)}},300);return()=>clearTimeout(pt)}})()},[p,x,o.type]),O&&!E?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(cs,{className:"w-8 h-8 animate-spin text-re-red"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(te,{variant:"outline",size:"icon",onClick:s,className:"hover:bg-slate-100 transition-colors",children:e.jsx(Wr,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl",children:(E==null?void 0:E.resignationId)||t}),e.jsx("p",{className:"text-slate-600",children:(Be=E==null?void 0:E.outlet)==null?void 0:Be.name})]}),e.jsx(we,{className:(E==null?void 0:E.status)==="Completed"||(E==null?void 0:E.status)==="Settled"?"bg-green-100 text-green-700 border-green-300":(E==null?void 0:E.status)==="Rejected"||(E==null?void 0:E.status)==="Withdrawn"||(E==null?void 0:E.status)==="Revoked"?"bg-red-100 text-red-700 border-red-300":"bg-yellow-100 text-yellow-700 border-yellow-300",children:(E==null?void 0:E.status)==="Settled"?"Completed":lj((E==null?void 0:E.status)||"Pending")}),e.jsx(br,{status:r("resignation",t)})]})}),e.jsxs(In,{defaultValue:"details",className:"w-full",children:[e.jsxs(Mn,{className:"bg-slate-100 p-1",children:[e.jsx(Ht,{value:"details",className:"data-[state=active]:bg-white",children:"Details"}),e.jsx(Ht,{value:"progress",className:"data-[state=active]:bg-white",children:"Progress"}),e.jsx(Ht,{value:"documents",className:"data-[state=active]:bg-white",children:"Documents"}),e.jsx(Ht,{value:"audit",className:"data-[state=active]:bg-white",children:"Audit Trail"}),Me&&e.jsx(Ht,{value:"approvals",className:"data-[state=active]:bg-white",children:"Approval Summary"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 mt-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(Vt,{value:"details",className:"space-y-6",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Resignation Details"})}),e.jsx(Oe,{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(le,{className:"text-slate-600",children:"Resignation Type"}),e.jsx("p",{children:E==null?void 0:E.resignationType})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Reason"}),e.jsx("p",{children:E==null?void 0:E.reason})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Last Operational Date (Sales)"}),e.jsx("p",{children:E!=null&&E.lastOperationalDateSales?Qt(E.lastOperationalDateSales,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Last Operational Date (Services)"}),e.jsx("p",{children:E!=null&&E.lastOperationalDateServices?Qt(E.lastOperationalDateServices,"date"):"N/A"})]})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Additional Info / Dealer Voice"}),e.jsx("p",{children:(E==null?void 0:E.additionalInfo)||"No additional info provided"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:E!=null&&E.submittedOn?Qt(E.submittedOn):"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:E==null?void 0:E.currentStage})]})]})]})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Request Information"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((rt=E==null?void 0:E.dealer)==null?void 0:rt.fullName)||((ht=E==null?void 0:E.outlet)==null?void 0:ht.name)})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:((Je=(ge=E==null?void 0:E.dealer)==null?void 0:ge.dealerProfile)==null?void 0:Je.gstNumber)||((mt=E==null?void 0:E.outlet)==null?void 0:mt.gstNumber)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Email"}),e.jsx("p",{children:((de=E==null?void 0:E.dealer)==null?void 0:de.email)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Sales Code"}),e.jsx("p",{children:((ke=(ot=(at=E==null?void 0:E.dealer)==null?void 0:at.dealerProfile)==null?void 0:ot.dealerCode)==null?void 0:ke.salesCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Service Code"}),e.jsx("p",{children:((_s=(Bt=(Zt=E==null?void 0:E.dealer)==null?void 0:Zt.dealerProfile)==null?void 0:Bt.dealerCode)==null?void 0:_s.serviceCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:((Vs=(fs=(Us=E==null?void 0:E.dealer)==null?void 0:Us.dealerProfile)==null?void 0:fs.dealerCode)==null?void 0:Vs.gmaCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Gear Code"}),e.jsx("p",{children:((ie=(Xs=(Qs=E==null?void 0:E.dealer)==null?void 0:Qs.dealerProfile)==null?void 0:Xs.dealerCode)==null?void 0:ie.gearCode)||"N/A"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(le,{className:"text-slate-600",children:"Address"}),e.jsx("p",{children:((fe=(nt=E==null?void 0:E.dealer)==null?void 0:nt.dealerProfile)==null?void 0:fe.registeredAddress)||((Ae=E==null?void 0:E.outlet)==null?void 0:Ae.address)})]})]})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Operational Details"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Inauguration"}),e.jsx("p",{children:(Ke=(Fe=E==null?void 0:E.dealer)==null?void 0:Fe.dealerProfile)!=null&&Ke.onboardedAt?Qt(E.dealer.dealerProfile.onboardedAt,"date"):(Le=E==null?void 0:E.outlet)!=null&&Le.inaugurationDate?Qt(E.outlet.inaugurationDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"LOA Date"}),e.jsx("p",{children:(et=(Ue=E==null?void 0:E.dealer)==null?void 0:Ue.dealerProfile)!=null&&et.loaDate?Qt(E.dealer.dealerProfile.loaDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"LOI Date"}),e.jsx("p",{children:(ss=(dt=E==null?void 0:E.dealer)==null?void 0:dt.dealerProfile)!=null&&ss.loiDate?Qt(E.dealer.dealerProfile.loiDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealership Type"}),e.jsx("p",{children:((wt=(kt=(Wt=E==null?void 0:E.dealer)==null?void 0:Wt.dealerProfile)==null?void 0:kt.application)==null?void 0:wt.businessType)||((Os=E==null?void 0:E.outlet)==null?void 0:Os.type)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"City Category"}),e.jsx("p",{children:((as=E==null?void 0:E.outlet)==null?void 0:as.cityCategory)||"N/A"})]})]})})]})]}),e.jsx(Vt,{value:"progress",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Progress Timeline"}),e.jsx(es,{children:"Track the resignation request approval process"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:ae.map((be,pt)=>{const Ve=ft(be.key),bt=a(be.name,be.key).length,gt=((E==null?void 0:E.timeline)||[]).filter(is=>is.stage===be.key||is.stage===be.name),rs=gt.length>0?gt[gt.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 ${Ve==="completed"?"bg-green-100 text-green-600":Ve==="active"?"bg-blue-100 text-re-red":"bg-slate-100 text-slate-400"}`,children:Ve==="completed"?e.jsx($n,{className:"w-5 h-5"}):e.jsx("span",{children:be.id})}),pt0&&e.jsxs("button",{onClick:()=>Ce(be.name,be.key),className:"flex items-center gap-1 px-2 py-1 rounded-full bg-red-50 hover:bg-red-100 text-re-red-hover text-xs transition-colors cursor-pointer",children:[e.jsx(ks,{className:"w-3 h-3"}),e.jsxs("span",{children:[bt," ",bt===1?"doc":"docs"]})]})]}),rs&&e.jsxs("div",{className:"flex items-center gap-1 text-sm text-slate-600",children:[e.jsx(er,{className:"w-4 h-4"}),e.jsx("span",{children:Qt(rs.timestamp||rs.createdAt)})]})]}),e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:be.description}),gt.length>0&&e.jsx("div",{className:"space-y-4 mt-3",children:gt.map((is,Ts)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{variant:"secondary",className:"bg-slate-100 text-[10px] font-bold uppercase",children:is.user||"System"}),e.jsx("span",{className:"text-[10px] text-slate-500 italic",children:is.action}),e.jsx("span",{className:"text-[10px] text-slate-400 ml-auto",children:Qt(is.timestamp||is.createdAt)})]}),e.jsx("div",{className:"bg-slate-50 p-3 rounded-lg border border-slate-100 text-sm text-slate-700 shadow-sm",children:is.comments||is.remarks||"No remarks provided."})]},Ts))})]})]},be.id)})})})]})}),e.jsx(Vt,{value:"documents",children:e.jsxs(_e,{children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"Documents"}),e.jsx(es,{children:"View and manage resignation documents"})]}),e.jsxs(te,{size:"sm",onClick:()=>M(!0),className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(vr,{className:"w-4 h-4 mr-2"}),"Upload Document"]})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:(()=>{var pt;const be=[...(E==null?void 0:E.documents)||[],...(E==null?void 0:E.uploadedDocuments)||[]];return E!=null&&E.departmentalClearances&&Object.entries(E.departmentalClearances).forEach(([Ve,bt])=>{bt.supportingDocument&&be.push({name:`${Ve} Clearance Proof`,type:"Clearance NOC",path:bt.supportingDocument,createdAt:bt.updatedAt,uploadedBy:bt.updatedBy||"Department Admin"})}),(pt=E==null?void 0:E.settlement)!=null&&pt.clearances&&E.settlement.clearances.forEach(Ve=>{Ve.supportingDocument&&be.push({name:`${Ve.department} Clearance NOC`,type:"Live NOC",path:Ve.supportingDocument,createdAt:Ve.clearedAt||Ve.updatedAt,uploadedBy:"Department Admin"})}),be.length===0?e.jsx(lt,{children:e.jsx(oe,{colSpan:5,className:"text-center py-4 text-slate-500",children:"No documents found"})}):be.map((Ve,bt)=>{var gt;return e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"w-4 h-4 text-slate-500"}),e.jsx("span",{children:Ve.name||Ve.fileName})]})}),e.jsx(oe,{children:Ve.documentType||Ve.type||"Document"}),e.jsx(oe,{children:Ve.createdAt?Qt(Ve.createdAt):"N/A"}),e.jsx(oe,{children:((gt=Ve.uploader)==null?void 0:gt.fullName)||Ve.uploadedBy||"Dealer"}),e.jsx(oe,{children:e.jsx(te,{size:"sm",variant:"outline",onClick:()=>{const rs=Ve.filePath||Ve.path,is=rs!=null&&rs.startsWith("/uploads/")&&!rs.startsWith("/uploads/documents/")?rs.replace("/uploads/","/uploads/documents/"):rs;W({fileName:Ve.fileName||Ve.name,filePath:is,documentType:Ve.documentType||Ve.type})},children:"View"})})]},bt)})})()})]})})]})}),e.jsx(Vt,{value:"audit",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Audit Trail"}),e.jsx(es,{children:"Complete history of actions on this resignation request"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:P.length>0?P.map((be,pt)=>{var Ve,bt,gt,rs,is,Ts,Ws,nn,Ee,$t,Xt;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(we,{className:` ${(be.description||be.action||((Ve=be.details)==null?void 0:Ve.action)||"").toLowerCase().includes("reject")||(be.description||be.action||((bt=be.details)==null?void 0:bt.action)||"").toLowerCase().includes("revok")?"bg-red-100 text-red-700 border-red-200":(be.description||be.action||((gt=be.details)==null?void 0:gt.action)||"").toLowerCase().includes("sent back")||(be.description||be.action||((rs=be.details)==null?void 0:rs.action)||"").toLowerCase().includes("send back")?"bg-red-50 text-re-red-hover border-red-200":(be.description||be.action||((is=be.details)==null?void 0:is.action)||"").toLowerCase().includes("approv")||(be.description||be.action||((Ts=be.details)==null?void 0:Ts.action)||"").toLowerCase().includes("initi")?"bg-emerald-100 text-emerald-700 border-emerald-200":"bg-slate-100 text-slate-700 border-slate-200"} `,children:be.description||be.action}),e.jsxs("span",{className:"text-xs text-slate-500 font-medium italic",children:["by ",((Ws=be.actor)==null?void 0:Ws.name)||be.userName||"System"]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:Qt(be.timestamp||be.createdAt)})]}),(be.remarks||((nn=be.newData)==null?void 0:nn.remarks)||((Ee=be.details)==null?void 0:Ee.remarks))&&e.jsx("div",{className:"p-3 bg-slate-50 border border-slate-100 rounded-lg text-sm text-slate-700 shadow-sm ml-1",children:be.remarks||(($t=be.newData)==null?void 0:$t.remarks)||((Xt=be.details)==null?void 0:Xt.remarks)})]})]},pt)}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:e.jsx("p",{children:"No activity logs found for this case."})})})})]})}),Me&&e.jsx(Vt,{value:"approvals",children:e.jsxs(_e,{children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"Approval Summary"}),e.jsx(es,{children:"Comprehensive view of all approvals and remarks"})]}),je.canApprove&&e.jsxs(te,{onClick:()=>X("approve"),className:"bg-green-600 hover:bg-green-700",children:[e.jsx($n,{className:"w-4 h-4 mr-2"}),"Approve Request"]})]}),e.jsx(Oe,{children:e.jsxs(Ms,{className:"w-full border-collapse",children:[e.jsx(Fs,{children:e.jsxs(lt,{className:"bg-slate-50/50",children:[e.jsx(me,{className:"min-w-[120px]",children:"Stage"}),e.jsx(me,{className:"min-w-[120px]",children:"Approver"}),e.jsx(me,{className:"min-w-[200px]",children:"Action"}),e.jsx(me,{className:"w-full min-w-[300px]",children:"Remarks"}),e.jsx(me,{className:"min-w-[180px] text-right",children:"Date"})]})}),e.jsx(Bs,{children:((E==null?void 0:E.timeline)||[]).length>0?E.timeline.map((be,pt)=>e.jsxs(lt,{children:[e.jsx(oe,{className:"font-medium",children:be.stage}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",children:be.user||"System"})}),e.jsx(oe,{className:"whitespace-normal break-words",children:be.action}),e.jsx(oe,{className:"whitespace-normal break-words",children:be.remarks||be.comments||"-"}),e.jsx(oe,{className:"text-slate-500 whitespace-nowrap text-right",children:Qt(be.timestamp||be.createdAt)})]},pt)):e.jsx(lt,{children:e.jsx(oe,{colSpan:5,className:"text-center py-6 text-slate-500",children:"No approval records found"})})})]})})]})})]}),e.jsx("div",{className:"space-y-6",children:e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Actions"})}),e.jsxs(Oe,{className:"space-y-3",children:[(()=>{const be=String((n==null?void 0:n.roleCode)||(n==null?void 0:n.role)||"").trim().toUpperCase(),pt=be==="DD LEAD"||be==="DD_LEAD",Ve=["DD Lead","DD Lead Review","DDL Review"].includes(E==null?void 0:E.currentStage);return pt&&Ve?e.jsxs(te,{variant:"outline",className:"w-full text-re-red-hover border-red-300 hover:bg-red-50",onClick:()=>{I("PPT Presentation"),G("DD Lead"),M(!0)},children:[e.jsx(vr,{className:"w-4 h-4 mr-2"}),"Upload PPT"]}):null})(),je.canApprove&&e.jsxs(te,{disabled:$,className:"w-full bg-green-600 hover:bg-green-700 font-bold",onClick:()=>X("approve"),children:[$&&o.type==="approve"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx($n,{className:"w-4 h-4 mr-2"}),"Approve"]}),je.canSendBack&&e.jsxs(te,{variant:"outline",disabled:$,className:"w-full font-bold",onClick:()=>X("sendBack"),children:[$&&o.type==="sendBack"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(sb,{className:"w-4 h-4 mr-2"}),"Send Back"]}),je.canWithdraw&&e.jsxs(te,{variant:"outline",disabled:$,className:"w-full text-red-600 border-red-300 hover:bg-red-50 font-bold",onClick:()=>X("withdrawal"),children:[$&&o.type==="withdrawal"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(id,{className:"w-4 h-4 mr-2"}),"Withdrawal"]}),je.canRevoke&&e.jsxs(te,{variant:"outline",disabled:$,className:"w-full text-orange-600 border-orange-300 hover:bg-orange-50 font-bold",onClick:()=>X("revoke"),children:[$&&o.type==="revoke"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Jy,{className:"w-4 h-4 mr-2"}),"Revoke"]}),je.canPushToFnF&&e.jsxs(te,{variant:"outline",disabled:$,className:"w-full text-re-red-hover border-red-300 hover:bg-red-50",onClick:()=>X("pushfnf"),children:[$&&o.type==="pushfnf"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Gu,{className:"w-4 h-4 mr-2"}),"Push to F&F"]}),je.canAssign&&e.jsxs(te,{variant:"outline",disabled:$,className:"w-full",onClick:()=>X("assign"),children:[$&&o.type==="assign"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(nb,{className:"w-4 h-4 mr-2"}),"Assign User"]}),e.jsx(Xo,{}),e.jsxs(te,{variant:"outline",className:"w-full",onClick:()=>{var be;return i(`/worknotes/resignation/${t}`,{state:{applicationName:((be=E==null?void 0:E.outlet)==null?void 0:be.name)||"Resignation",registrationNumber:(E==null?void 0:E.resignationId)||"",participants:(E==null?void 0:E.participants)||[]}})},children:[e.jsx(li,{className:"w-4 h-4 mr-2"}),"View Work Notes",((Se=E==null?void 0:E.worknotes)==null?void 0:Se.length)>0&&e.jsx(we,{className:"ml-auto bg-re-red hover:bg-re-red-hover text-white h-5 px-2",children:E.worknotes.length})]})]})]})})]})]}),e.jsx(ms,{open:o.open,onOpenChange:be=>d({open:be,type:null}),children:e.jsxs(us,{children:[e.jsxs(ys,{children:[e.jsxs(gs,{children:[o.type==="approve"&&"Approve Resignation Request",o.type==="withdrawal"&&"Withdraw Resignation Request",o.type==="sendBack"&&"Send Back for Clarification",o.type==="revoke"&&"Revoke Resignation Request",o.type==="assign"&&"Assign to User",o.type==="pushfnf"&&"Push to Full & Final Settlement"]}),e.jsx(ws,{children:o.type==="assign"?"Select a user to assign this request to":o.type==="pushfnf"?"This will move the resignation request to F&F for dues clearance":"Please provide remarks for this action"})]}),e.jsx("div",{className:"space-y-4",children:o.type==="assign"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Designation Filter"}),e.jsxs(Rt,{value:p,onValueChange:be=>{h(be),v("")},children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"All Roles"})}),e.jsxs(Tt,{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(le,{children:"Search Name/Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(it,{placeholder:"Search...",value:x,onChange:be=>u(be.target.value),className:"pr-8"}),b&&e.jsx(cs,{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(le,{children:"Select Specific Person *"}),e.jsxs(Rt,{value:N,onValueChange:v,children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:w.length>0?"Choose a user":"No users found"})}),e.jsx(Tt,{className:"max-h-60",children:w.map(be=>e.jsx(Pe,{value:be.id,children:e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("span",{className:"font-medium",children:be.fullName}),e.jsxs("span",{className:"text-[10px] text-slate-500",children:[be.roleCode," • ",be.email]})]})},be.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Assignment Remarks *"}),e.jsx(Ks,{value:m,onChange:be=>f(be.target.value),placeholder:"Why are you assigning this user?",rows:2})]})]}):o.type==="pushfnf"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-3 bg-red-50 border border-red-200 rounded-lg flex items-start gap-3",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red mt-0.5"}),e.jsxs("div",{className:"text-sm text-red-800",children:[e.jsx("p",{className:"font-bold",children:"Manual Trigger Notice"}),e.jsxs("p",{children:["Normally F&F is triggered after the ",Ri.toLowerCase(),". Use manual trigger only if urgent clearance is required."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"forceFnF",checked:S,onChange:be=>D(be.target.checked),className:"w-4 h-4 rounded border-slate-300"}),e.jsx(le,{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(le,{children:"Remarks (Optional)"}),e.jsx(Ks,{value:m,onChange:be=>f(be.target.value),placeholder:"Add any additional notes...",rows:3})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Remarks *"}),e.jsx(Ks,{value:m,onChange:be=>f(be.target.value),placeholder:"Enter your remarks here...",rows:4})]})}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>d({open:!1,type:null}),disabled:$,children:"Cancel"}),e.jsx(te,{onClick:xe,disabled:$,className:o.type==="approve"?"bg-green-600 hover:bg-green-700":o.type==="withdrawal"?"bg-red-600 hover:bg-red-700":"bg-re-red hover:bg-re-red-hover",children:$?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:[o.type==="approve"&&"Approve",o.type==="withdrawal"&&"Withdraw",o.type==="sendBack"&&"Send Back",o.type==="revoke"&&"Revoke",o.type==="assign"&&"Assign",o.type==="pushfnf"&&"Push to F&F"]})})]})]})}),e.jsx(ms,{open:_.open,onOpenChange:be=>A({open:be,stageName:"",documents:[]}),children:e.jsxs(us,{className:Gb,children:[e.jsxs(ys,{children:[e.jsxs(gs,{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"w-5 h-5 text-re-red"}),"Documents - ",_.stageName]}),e.jsxs(ws,{children:["Documents uploaded for this stage (",_.documents.length," ",_.documents.length===1?"document":"documents",")"]})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto",children:_.documents.length>0?e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:_.documents.map(be=>e.jsxs(lt,{children:[e.jsx(oe,{children:be.name}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",children:be.type})}),e.jsx(oe,{children:be.uploadDate}),e.jsx(oe,{children:be.uploader}),e.jsx(oe,{children:e.jsxs(te,{size:"sm",variant:"outline",className:"text-re-red hover:text-blue-700",onClick:()=>{if(!be.filePath)return;const pt=be.filePath.startsWith("/uploads/")&&!be.filePath.startsWith("/uploads/documents/")?be.filePath.replace("/uploads/","/uploads/documents/"):be.filePath;W({fileName:be.name,filePath:pt,documentType:be.type})},children:[e.jsx(ks,{className:"w-4 h-4 mr-1"}),"View"]})})]},be.id))})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded for this stage yet"})}),e.jsx(mn,{children:e.jsx(te,{variant:"outline",onClick:()=>A({open:!1,stageName:"",documents:[]}),children:"Close"})})]})}),e.jsx(ms,{open:U,onOpenChange:M,children:e.jsxs(us,{children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Upload Resignation Document"}),e.jsx(ws,{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(le,{children:"Document Type"}),e.jsxs(Rt,{value:F,onValueChange:I,children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Select document type"})}),e.jsx(Tt,{children:Wg.map(be=>e.jsx(Pe,{value:be,children:be},be))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Stage (Optional)"}),e.jsxs(Rt,{value:K||"none",onValueChange:be=>G(be==="none"?"":be),children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Select stage"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"none",children:"No Stage Mapping"}),uV.map(be=>e.jsx(Pe,{value:be,children:be},be))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"File"}),e.jsx(it,{type:"file",onChange:be=>{var pt;return T(((pt=be.target.files)==null?void 0:pt[0])||null)}})]})]}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>M(!1),disabled:$,children:"Cancel"}),e.jsx(te,{onClick:We,disabled:$,children:$?"Uploading...":"Upload"})]})]})}),e.jsx(ho,{isOpen:!!Q,onClose:()=>W(null),document:Q})]})}const Bo={getTerminationById:async t=>{const n=(await Re.getTerminationById(t)).data;return(n==null?void 0:n.termination)||(n==null?void 0:n.data)||n},updateTerminationStatus:async(t,s,n,r)=>(await Re.updateTerminationStatus(t,{action:s,remarks:n,...r!=null&&r.force?{force:!0}:{}})).data,issueSCN:async(t,s)=>(await Re.issueSCN(t,s)).data,uploadSCNResponse:async(t,s,n)=>{const r=new FormData;return r.append("file",s),n&&r.append("remarks",n),(await Re.uploadSCNResponse(t,r)).data},uploadDocument:async(t,s)=>(await Re.uploadTerminationDocument(t,s)).data,finalizeTermination:async(t,s,n)=>(await Re.finalizeTermination(t,{decision:s,remarks:n})).data},jf=t=>String(t||"").toLowerCase().replace(/\s+/g," ").trim(),pV="Evaluation of Dealer SCN Response",xV=t=>{const s=jf(t);return s?!!(s===jf(pV)||s.includes("evaluation")&&s.includes("scn")&&s.includes("response")||s.includes("personal hearing")):!1},gV=t=>{const s=jf(t);return s.includes("rbm")&&(s.includes("dd-zm")||s.includes("dd zm"))};function vV(t){const s=jf(t);return s.includes("sent back")||s.includes("send back")||s.includes("reconsider")||s.includes("reconsideration")}function TS(t,s){if(!Array.isArray(t)||t.length===0)return null;const n=s==="scn_response_eval"?xV:gV,r=t;for(let a=r.length-1;a>=0;a--){const i=r[a];if(!vV(i==null?void 0:i.action)||!n(i==null?void 0:i.targetStage))continue;const o=(i==null?void 0:i.timestamp)!=null?new Date(i.timestamp).getTime():NaN;if(!Number.isNaN(o))return o}return null}function yV(t){const s=t.createdAt??t.timestamp;if(s==null)return 0;const n=new Date(s).getTime();return Number.isNaN(n)?0:n}function bV(t,s){return s==null?!0:yV(t)>=s}function jV({terminationId:t,onBack:s,currentUser:n}){var Bt,_s,Us,fs,Vs,Qs,Xs,ie,nt,fe,Ae,Fe,Ke,Le,Ue,et,dt,ss,Wt,kt,wt,Os,as,Se,be,pt,Ve,bt,gt,rs,is,Ts,Ws,nn;const r=tr(),{get:a}=mc(t?[{entityType:"termination",entityId:t}]:[],!!t),[i,o]=g.useState({open:!1,type:null}),[d,m]=g.useState(""),[f,p]=g.useState(""),[h,x]=g.useState(!1),[u,N]=g.useState({open:!1,stageName:"",documents:[]}),[v,w]=g.useState(!0),[j,b]=g.useState(null),[C,S]=g.useState([]),[D,_]=g.useState(!1),[A,E]=g.useState(null),[q,O]=g.useState(""),[R,P]=g.useState(!1),[L,$]=g.useState(!1),[Z,Q]=g.useState("Approve"),[W,U]=g.useState(""),[M,z]=g.useState(!1),[T,F]=g.useState(null),[I,K]=g.useState(Gg[0]),[G,V]=g.useState(""),[Y,re]=g.useState(null),ae=async()=>{try{w(!0);const Ee=await Bo.getTerminationById(t);b(Ee),ue()}catch(Ee){console.error("Error fetching termination:",Ee)}finally{w(!1)}},ue=async()=>{try{const Ee=await Re.getAuditLogs("termination",t);Ee.data&&Ee.data.success&&S(Ee.data.data||[])}catch(Ee){console.error("Error fetching audit logs:",Ee)}};if(g.useEffect(()=>{ae()},[t]),v)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:[e.jsx(cs,{className:"w-8 h-8 text-re-red animate-spin"}),e.jsx("p",{className:"text-slate-600",children:"Loading termination details..."})]});const ye=async()=>{try{P(!0),await Bo.issueSCN(t,{remarks:q}),J.success("SCN issued successfully"),_(!1),ae()}catch{J.error("Failed to issue SCN")}finally{P(!1)}},ce=async()=>{if(A)try{P(!0),await Bo.uploadSCNResponse(t,A,q),J.success("SCN response uploaded"),_(!1),ae()}catch{J.error("Failed to upload response")}finally{P(!1)}},je=async()=>{try{P(!0),await Bo.finalizeTermination(t,Z,W),J.success(`Termination ${Z.toLowerCase()}ed`),$(!1),ae()}catch{J.error("Failed to finalize termination")}finally{P(!1)}},Me=async()=>{if(!T){J.error("Please select a file to upload");return}try{P(!0);const Ee=new FormData;Ee.append("file",T),Ee.append("documentType",I),G&&Ee.append("stage",G),await Bo.uploadDocument(t,Ee),J.success("Document uploaded successfully"),z(!1),F(null),K(Gg[0]),V(""),ae()}catch{J.error("Failed to upload document")}finally{P(!1)}},ut=n&&["DD Lead","DD Head","DD_HEAD","NBH","DD Admin","Super Admin"].includes(n.role||n.roleCode),jt={Submitted:["Submitted"],"RBM + DD-ZM Review":["RBM + DD-ZM Review"],"ZBH Review":["ZBH Review"],"DD Lead Review":["DD Lead Review"],"Legal Verification":["Legal Verification"],"DD Head Review":["DD Head Review"],"NBH Evaluation":["NBH Evaluation"],"Show Cause Notice (SCN)":["Show Cause Notice","Show Cause Notice (SCN)","SCN"],"Evaluation of Dealer SCN Response":["Evaluation of Dealer SCN Response","Personal Hearing"],"NBH Final Approval":["NBH Final Approval"],"CCO Approval":["CCO Approval"],"CEO Final Approval":["CEO Final Approval"],"Legal - Termination Letter":["Legal - Termination Letter"],"Dealer Terminated":["Terminated","Dealer Terminated"]},ft=["Submitted","RBM + DD-ZM Review","ZBH Review","DD Lead Review","Legal Verification","DD Head Review","NBH Evaluation","Show Cause Notice (SCN)","Evaluation of Dealer SCN Response","NBH Final Approval","CCO Approval","CEO Final Approval","Legal - Termination Letter","Dealer Terminated"],Ce=(()=>{if(!j||!n)return{canApprove:!1,canWithdraw:!1,canIssueSCN:!1,canUploadSCNResponse:!1,canFinalize:!1,canPushToFnF:!1};const Ee=j.currentStage,$t=j.status,Xt=n.role||n.roleCode,Cs=["Show Cause Notice (SCN)","SCN"].includes(Ee),Mt=["Completed","Rejected","Withdrawn","Terminated"].includes($t)||Ee==="Terminated",ze=$t==="F&F Initiated"||Ee==="F&F Initiated"||$t==="Settled"||$t==="FNF_INITIATED",xt=(()=>{const ts=new Date;ts.setHours(0,0,0,0);const js=j.proposedLwd;if(!js)return!0;const tn=new Date(js);return tn.setHours(0,0,0,0),ts>=tn})(),yt=TS(j.timeline,"scn_response_eval"),Ot=TS(j.timeline,"rbm_review"),Pt=Ee==="Evaluation of Dealer SCN Response"||Ee==="Personal Hearing",Jt=Ee==="RBM + DD-ZM Review"?Ot:Pt?yt:null,bs=C.some(ts=>{var Ze,Gt,St;if(!bV(ts,Jt))return!1;const js=ts.userId||((Ze=ts.user)==null?void 0:Ze.id)||((Gt=ts.actor)==null?void 0:Gt.id)||ts.actorId,tn=String(js)===String(n.id),vn=(ts.action||ts.description||"").toUpperCase(),jn=vn.includes("PARTIAL_APPROVE")||vn.includes("PARTIAL APPROVED"),xn=((St=ts.details)==null?void 0:St.stage)||ts.stage||"",gn=xn==="RBM + DD-ZM Review"||(ts.remarks||"").includes("Partial approval by"),Ye=xn==="Evaluation of Dealer SCN Response"||xn==="Personal Hearing"||(ts.remarks||"").includes("SCN Response Review by");return tn&&jn&&(Ee==="RBM + DD-ZM Review"&&gn||Pt&&Ye)}),ns=ts=>(jt[ts]||[ts]).includes(Ee);return{canApprove:(Xt==="Super Admin"||Xt==="DD Admin"||ns("RBM + DD-ZM Review")&&(Xt==="RBM"||Xt==="DD-ZM")&&!bs||ns("ZBH Review")&&Xt==="ZBH"||ns("DD Lead Review")&&Xt==="DD Lead"||ns("Legal Verification")&&Xt==="Legal Admin"||ns("DD Head Review")&&(Xt==="DD Head"||Xt==="DD_HEAD")||ns("NBH Evaluation")&&Xt==="NBH"||ns("Evaluation of Dealer SCN Response")&&["DD Lead","ZBH","RBM","DD Head","DD_HEAD"].includes(Xt)&&!bs||ns("NBH Final Approval")&&Xt==="NBH"||ns("CCO Approval")&&Xt==="CCO"||ns("CEO Final Approval")&&Xt==="CEO"||ns("Legal - Termination Letter")&&Xt==="Legal Admin")&&!Mt&&!ze&&!["NBH Final Approval","CCO Approval","CEO Final Approval","Show Cause Notice (SCN)","SCN"].includes(Ee),canIssueSCN:Ee==="NBH Evaluation"&&(Xt==="NBH"||Xt==="Super Admin")&&!Mt,canUploadSCNResponse:Cs&&["Legal Admin","DD Admin","DD Lead","Super Admin"].includes(Xt)&&!Mt,canHold:(ns("NBH Evaluation")||ns("NBH Final Approval"))&&(Xt==="NBH"||Xt==="Super Admin")&&$t!=="On Hold"&&!Mt,canFinalize:(Ee==="NBH Final Approval"&&Xt==="NBH"||Ee==="CCO Approval"&&Xt==="CCO"||Ee==="CEO Final Approval"&&Xt==="CEO"||Xt==="Super Admin")&&["NBH Final Approval","CCO Approval","CEO Final Approval"].includes(Ee)&&!Mt,canPushToFnF:ut&&!ze&&!j.fnfSettlement&&(Ee==="Terminated"||$t===Vc.AWAITING_FNF||$t===Vc.AWAITING_FNF_LWD_PENDING)&&xt,isLwdReached:xt,canWithdraw:Xt==="ASM"&&Ee==="Request Initiated"&&!Mt,isFinalState:Mt,isSettlementPhase:ze}})(),xe=j||{},We=["Show Cause Notice","Show Cause Notice (SCN)","SCN"].includes(xe.currentStage),Be=Ee=>{if(!Ee)return"";const $t=String(Ee).trim();return ft.find(Cs=>(jt[Cs]||[Cs]).includes($t))||$t},rt=Ee=>{const $t=["Rejected","Revoked","Withdrawn"].includes(xe.status),Xt=["Completed","Terminated","Settled","F&F Initiated","FNF_INITIATED",Vc.AWAITING_FNF,Vc.AWAITING_FNF_LWD_PENDING].includes(xe.status)||xe.currentStage==="Terminated";let Cs=xe.currentStage||xe.status;if($t&&(xe.currentStage==="Rejected"||xe.currentStage==="Revoked"||!xe.currentStage)){const yt=[...xe.timeline||[]].reverse().find(Ot=>Ot.stage&&Ot.stage!=="Rejected"&&Ot.stage!=="Revoked");yt&&(Cs=yt.stage)}const Mt=Be(Cs),ze=ft.indexOf(Mt),xt=ft.indexOf(Ee);return Xt&&xt<=ze?"completed":xt===-1?"pending":ze===-1?Ee==="Submitted"?"completed":"pending":xt{const Xt=jt[$t]||[$t],Cs=ht.filter(Mt=>!Mt.stage||Xt.includes(Mt.stage)).map(Mt=>{var ze;return{id:Mt.id||`${$t}-${Mt.fileName||Mt.name}`,name:Mt.fileName||Mt.name||"Document",type:Mt.documentType||Mt.type||"Document",uploadDate:Mt.uploadDate||Mt.createdAt?Qt(Mt.uploadDate||Mt.createdAt):"N/A",uploader:((ze=Mt.uploader)==null?void 0:ze.fullName)||Mt.uploader||"-",path:Mt.filePath||Mt.path||Mt.url}});return Ee[$t]=Cs,Ee},{}),Je=Ee=>{const $t=jt[Ee]||[Ee];return(xe.timeline||[]).filter(Cs=>$t.includes(Cs.stage)||Ee==="Submitted"&&(Cs.stage==="Submitted"||Cs.stage==="Request Initiated")).sort((Cs,Mt)=>new Date(Cs.timestamp).getTime()-new Date(Mt.timestamp).getTime())},mt=[{id:1,name:"Submitted",status:rt("Submitted"),description:"Termination request initiated",date:"",actionType:"",actionBy:"",remarks:"",feedback:""},{id:2,name:"RBM + DD-ZM Review",status:rt("RBM + DD-ZM Review"),description:"Joint review and approval by RBM and DD-ZM"},{id:3,name:"ZBH Review",status:rt("ZBH Review"),description:"Zonal Business Head evaluation"},{id:4,name:"DD Lead Review",status:rt("DD Lead Review"),description:"DD Lead validation"},{id:5,name:"Legal Verification",status:rt("Legal Verification"),description:"Legal team validates termination grounds"},{id:6,name:"DD Head Review",status:rt("DD Head Review"),description:"DD Head strategic review"},{id:7,name:"NBH Evaluation",status:rt("NBH Evaluation"),description:"National Business Head decision"},{id:8,name:"Show Cause Notice (SCN)",status:rt("Show Cause Notice (SCN)"),description:"SCN sent to dealer, awaiting response"},{id:9,name:"Evaluation of Dealer SCN Response",status:rt("Evaluation of Dealer SCN Response"),description:"Joint evaluation of SCN response by DD-Lead, ZBH, RBM, and DD-Head"},{id:10,name:"NBH Final Approval",status:rt("NBH Final Approval"),description:"NBH final termination decision"},{id:11,name:"CCO Approval",status:rt("CCO Approval"),description:"Chief Commercial Officer approval"},{id:12,name:"CEO Final Approval",status:rt("CEO Final Approval"),description:"CEO final authorization"},{id:13,name:"Legal - Termination Letter",status:rt("Legal - Termination Letter"),description:"Legal team issues final termination letter"},{id:14,name:"Dealer Terminated",status:rt("Dealer Terminated"),description:"Dealership termination effective",date:"",actionType:"",actionBy:"",remarks:"",feedback:""}],de=Ee=>{const $t=ge[Ee]||[];N({open:!0,stageName:Ee,documents:$t})},at=Ee=>{o({open:!0,type:Ee})},ot=async()=>{var Cs,Mt,ze,xt,yt,Ot;const Ee=i.type,$t=Ee==="sendBack"?"sendBack":Ee||"approve",Xt=d.trim();if(["sendBack","revoke"].includes(Ee||"")&&Xt.length<5){J.error("Please provide detailed remarks (minimum 5 characters required for Send Back / Revoke)");return}if(!Xt&&!["assign","pushfnf"].includes(Ee||"")){J.error("Please provide remarks/comments for this action");return}if(Ee==="assign"&&!f){J.error("Please select a user");return}P(!0);try{let Pt;if(Ee==="approve"||Ee==="sendBack"||Ee==="withdrawal"||Ee==="revoke"||Ee==="hold")Pt=await Bo.updateTerminationStatus(t,$t,d);else if(Ee==="pushfnf")Pt=await Bo.updateTerminationStatus(t,"pushfnf",d,{force:h});else{J.error("Action logic not fully implemented for this type"),P(!1);return}if(Pt&&(Pt.success===!1||Pt.ok===!1)){console.error("[TerminationDetails] Action failed:",Pt);const bs=Pt.message||((Cs=Pt.data)==null?void 0:Cs.message)||"Failed to perform action";J.error(bs),(Pt.canForce||(Mt=Pt.data)!=null&&Mt.canForce)&&J.info('Enable "Force initiate F&F" in the dialog if an exception is approved.'),P(!1);return}const Jt={approve:"Request approved and forwarded",withdrawal:"Request withdrawn successfully",sendBack:"Request sent back for clarification",assign:"Request assigned successfully",pushfnf:"Request pushed to F&F successfully",revoke:"Request revoked and withdrawn"};J.success(Jt[Ee]||(Pt==null?void 0:Pt.message)||"Action completed"),o({open:!1,type:null}),m(""),p(""),x(!1),ae()}catch(Pt){const Jt=((xt=(ze=Pt.response)==null?void 0:ze.data)==null?void 0:xt.message)||"Failed to perform action";J.error(Jt),(Ot=(yt=Pt==null?void 0:Pt.response)==null?void 0:yt.data)!=null&&Ot.canForce&&J.info('Enable "Force initiate F&F" in the dialog if an exception is approved.')}finally{P(!1)}},ke=Ee=>{switch(Ee){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"}},Zt=(xe.worknotes||[]).length;return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(te,{variant:"outline",size:"icon",onClick:s,className:"hover:bg-slate-100 transition-colors",children:e.jsx(Wr,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl",children:xe.requestId||t}),e.jsx("p",{className:"text-slate-600",children:((Bt=xe.dealer)==null?void 0:Bt.businessName)||((_s=xe.dealer)==null?void 0:_s.legalName)||"Termination"})]}),e.jsx(we,{className:ke(xe.severity),children:xe.severity}),e.jsx(we,{className:xe.status==="Completed"||xe.status==="Terminated"||xe.status==="Settled"?"bg-green-100 text-green-700 border-green-300":xe.status==="Rejected"||xe.status==="Withdrawn"?"bg-red-100 text-red-700 border-red-300":"bg-yellow-100 text-yellow-700 border-yellow-300",children:xe.status==="Settled"?"Completed":lj(xe.status||"Pending")}),e.jsx(br,{status:a("termination",t)})]})}),e.jsxs(In,{defaultValue:"details",className:"w-full",children:[e.jsxs(Mn,{className:"bg-slate-100 p-1",children:[e.jsx(Ht,{value:"details",className:"data-[state=active]:bg-white",children:"Details"}),e.jsx(Ht,{value:"progress",className:"data-[state=active]:bg-white",children:"Progress"}),e.jsx(Ht,{value:"documents",className:"data-[state=active]:bg-white",children:"Documents"}),e.jsx(Ht,{value:"audit",className:"data-[state=active]:bg-white",children:"Audit Trail"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 mt-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(Vt,{value:"details",className:"space-y-6",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Dealer Information"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:((fs=(Us=xe.dealer)==null?void 0:Us.dealerCode)==null?void 0:fs.dealerCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((Vs=xe.dealer)==null?void 0:Vs.businessName)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:((Qs=xe.dealer)==null?void 0:Qs.gstNumber)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Email"}),e.jsx("p",{children:((ie=(Xs=xe.dealer)==null?void 0:Xs.user)==null?void 0:ie.email)||"N/A"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(le,{className:"text-slate-600",children:"Address"}),e.jsx("p",{children:((nt=xe.dealer)==null?void 0:nt.registeredAddress)||((Ae=(fe=xe.dealer)==null?void 0:fe.application)==null?void 0:Ae.address)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"City"}),e.jsx("p",{children:((Ke=(Fe=xe.dealer)==null?void 0:Fe.application)==null?void 0:Ke.city)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"District"}),e.jsx("p",{children:((et=(Ue=(Le=xe.dealer)==null?void 0:Le.application)==null?void 0:Ue.district)==null?void 0:et.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealership Name"}),e.jsx("p",{children:((dt=xe.dealer)==null?void 0:dt.businessName)||xe.dealershipName})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Sales Code"}),e.jsx("p",{children:((Wt=(ss=xe.dealer)==null?void 0:ss.dealerCode)==null?void 0:Wt.salesCode)||xe.salesCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Service Code"}),e.jsx("p",{children:((wt=(kt=xe.dealer)==null?void 0:kt.dealerCode)==null?void 0:wt.serviceCode)||xe.serviceCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:((as=(Os=xe.dealer)==null?void 0:Os.dealerCode)==null?void 0:as.gmaCode)||xe.accessoriesCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:((be=(Se=xe.dealer)==null?void 0:Se.dealerCode)==null?void 0:be.gmaCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Gear Code"}),e.jsx("p",{children:((Ve=(pt=xe.dealer)==null?void 0:pt.dealerCode)==null?void 0:Ve.gearCode)||"N/A"})]})]})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Operational Details"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Inauguration"}),e.jsx("p",{children:(bt=xe.dealer)!=null&&bt.onboardedAt?Qt(xe.dealer.onboardedAt,"date"):xe.inauguration||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"LOA Date"}),e.jsx("p",{children:(gt=xe.dealer)!=null&>.loaDate?Qt(xe.dealer.loaDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"LOI Date"}),e.jsx("p",{children:(rs=xe.dealer)!=null&&rs.loiDate?Qt(xe.dealer.loiDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Last 6 Months Sales"}),e.jsx("p",{children:xe.lastSixMonthsSales})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Number of Dealerships"}),e.jsx("p",{children:xe.numberOfDealerships})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Number of Studios"}),e.jsx("p",{children:xe.numberOfStudios})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Constitution"}),e.jsx("p",{children:((is=xe.dealer)==null?void 0:is.constitutionType)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealership Type"}),e.jsx("p",{children:((Ws=(Ts=xe.dealer)==null?void 0:Ts.application)==null?void 0:Ws.businessType)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Type of Closure"}),e.jsx("p",{children:xe.typeOfClosure||"Complete"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Format Category"}),e.jsx("p",{children:xe.formatCategory||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Score Card Band"}),e.jsx("p",{children:xe.dealerScoreCardBand||"N/A"})]})]})})]}),e.jsxs(_e,{className:"border-red-200 bg-red-50/30",children:[e.jsx(Xe,{children:e.jsxs(st,{className:"text-red-900 flex items-center gap-2",children:[e.jsx(Ba,{className:"w-5 h-5"}),"Termination Details"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Termination Category"}),e.jsx("p",{className:"text-red-900",children:xe.category})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Sub Category"}),e.jsx("p",{children:xe.subCategory||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Description"}),e.jsx("p",{children:xe.reason})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Severity"}),e.jsx("div",{className:"mt-1",children:e.jsx(we,{className:ke(xe.severity),children:xe.severity})})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Submitted By"}),e.jsx("p",{children:((nn=xe.initiator)==null?void 0:nn.fullName)||"System"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Qt(xe.createdAt)})]})]})]})})]})]}),e.jsx(Vt,{value:"progress",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Termination Progress Timeline"}),e.jsx(es,{children:"Track the termination request approval process"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:mt.map((Ee,$t)=>{var Mt,ze,xt;const Xt=((Mt=ge[Ee.name])==null?void 0:Mt.length)||0,Cs=Je(Ee.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 ${Ee.status==="completed"?"bg-green-100 text-green-600":Ee.status==="active"?"bg-red-50 text-re-red":"bg-slate-100 text-slate-400"}`,children:Ee.status==="completed"?e.jsx($n,{className:"w-5 h-5"}):Ee.status==="active"?e.jsx(Ba,{className:"w-5 h-5"}):e.jsx("span",{children:Ee.id})}),$t0&&e.jsxs("button",{onClick:()=>de(Ee.name),className:"flex items-center gap-1 px-2 py-1 rounded-full bg-red-50 hover:bg-red-100 text-re-red-hover text-xs transition-colors cursor-pointer",children:[e.jsx(ks,{className:"w-3 h-3"}),e.jsxs("span",{children:[Xt," ",Xt===1?"doc":"docs"]})]})]}),(((ze=Cs[0])==null?void 0:ze.timestamp)||Ee.date)&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-slate-500 bg-slate-50 px-2 py-0.5 rounded-full border border-slate-100",children:[e.jsx(er,{className:"w-3 h-3"}),e.jsx("span",{children:Qt(((xt=Cs[0])==null?void 0:xt.timestamp)||Ee.date)})]})]}),e.jsx("p",{className:"text-slate-600 text-sm",children:Ee.description}),Cs.length>0&&e.jsx("div",{className:"mt-3 space-y-3",children:Cs.map((yt,Ot)=>{var ns,Ds,ts;const Pt=yt.remarks||yt.comments||"",Jt=Pt==null?void 0:Pt.startsWith("Attachment:"),bs=Jt?Pt.replace("Attachment:","").trim():Pt;return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(we,{className:` text-[10px] h-4 px-1.5 ${(ns=yt.action)!=null&&ns.toLowerCase().includes("rejected")||(Ds=yt.action)!=null&&Ds.toLowerCase().includes("revoked")?"bg-red-100 text-red-700":(ts=yt.action)!=null&&ts.toLowerCase().includes("approved")?"bg-emerald-100 text-emerald-700":"bg-blue-100 text-blue-700"} `,children:yt.action||"Action"}),e.jsxs("span",{className:"text-[10px] text-slate-500 font-medium",children:["by ",yt.user||"System",yt.role?` (${yt.role})`:""," • ",Qt(yt.timestamp)]})]}),e.jsx("div",{className:` p-2.5 rounded-lg border text-sm ${Jt?"bg-red-50/50 border-red-100 text-red-900":"bg-slate-50 border-slate-100 text-slate-700"} `,children:Jt?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"w-3.5 h-3.5 text-re-red"}),e.jsx("span",{className:"font-medium truncate",children:bs})]}):e.jsx("p",{className:"leading-relaxed",children:bs||"No remarks provided."})})]},Ot)})})]})]},Ee.id)})})})]})}),e.jsx(Vt,{value:"documents",children:e.jsxs(_e,{children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"Documents"}),e.jsx(es,{children:"View and manage termination case documents"})]}),e.jsxs(te,{size:"sm",onClick:()=>z(!0),className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(vr,{className:"w-4 h-4 mr-2"}),"Upload Document"]})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:(()=>{const Ee=[...xe.documents||[],...xe.uploadedDocuments||[]];return Ee.length===0?e.jsx(lt,{children:e.jsx(oe,{colSpan:5,className:"text-center py-4 text-slate-500",children:"No documents found"})}):Ee.map(($t,Xt)=>{var Cs;return e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"w-4 h-4 text-slate-500"}),e.jsx("span",{children:$t.name||$t.fileName})]})}),e.jsx(oe,{children:$t.documentType||$t.type||"Document"}),e.jsx(oe,{children:Qt($t.uploadDate||$t.createdAt)}),e.jsx(oe,{children:((Cs=$t.uploader)==null?void 0:Cs.fullName)||$t.uploader||"-"}),e.jsx(oe,{children:e.jsx(te,{size:"sm",variant:"outline",onClick:()=>{const Mt=$t.filePath||$t.path||$t.url;if(!Mt)return;const ze=Mt.startsWith("/uploads/")&&!Mt.startsWith("/uploads/documents/")?Mt.replace("/uploads/","/uploads/documents/"):Mt;re({fileName:$t.name||$t.fileName||"Document",filePath:ze,documentType:$t.documentType||$t.type||"Document"})},children:"View"})})]},$t.id||Xt)})})()})]})})]})}),e.jsx(Vt,{value:"audit",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Audit Trail"}),e.jsx(es,{children:"Complete history of actions on this termination case"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:C.length>0?C.map((Ee,$t)=>{var Xt,Cs,Mt,ze,xt,yt,Ot,Pt,Jt,bs,ns;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(we,{className:` ${(Ee.description||Ee.action||((Xt=Ee.details)==null?void 0:Xt.action)||"").toLowerCase().includes("reject")||(Ee.description||Ee.action||((Cs=Ee.details)==null?void 0:Cs.action)||"").toLowerCase().includes("revok")?"bg-red-100 text-red-700 border-red-200":(Ee.description||Ee.action||((Mt=Ee.details)==null?void 0:Mt.action)||"").toLowerCase().includes("sent back")||(Ee.description||Ee.action||((ze=Ee.details)==null?void 0:ze.action)||"").toLowerCase().includes("send back")?"bg-red-50 text-re-red-hover border-red-200":(Ee.description||Ee.action||((xt=Ee.details)==null?void 0:xt.action)||"").toLowerCase().includes("approv")||(Ee.description||Ee.action||((yt=Ee.details)==null?void 0:yt.action)||"").toLowerCase().includes("initi")?"bg-emerald-100 text-emerald-700 border-emerald-200":"bg-slate-100 text-slate-700 border-slate-200"} `,children:Ee.description||Ee.action}),e.jsxs("span",{className:"text-xs text-slate-500 font-medium italic",children:["by ",((Ot=Ee.actor)==null?void 0:Ot.name)||Ee.userName||"System"]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:Qt(Ee.timestamp||Ee.createdAt)})]}),(Ee.remarks||((Pt=Ee.newData)==null?void 0:Pt.remarks)||((Jt=Ee.details)==null?void 0:Jt.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:Ee.remarks||((bs=Ee.newData)==null?void 0:bs.remarks)||((ns=Ee.details)==null?void 0:ns.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("div",{className:"space-y-6",children:e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Actions"})}),e.jsxs(Oe,{className:"space-y-3",children:[(xe.currentStage==="Evaluation of Dealer SCN Response"||xe.currentStage==="Personal Hearing")&&e.jsxs(Ai,{className:"mb-2 bg-blue-50 border-blue-200",children:[e.jsx(il,{className:"text-blue-800 text-sm font-semibold",children:"Joint Review Stage"}),e.jsxs(ki,{className:"text-blue-700 text-xs",children:["Joint evaluation by ",e.jsx("strong",{children:"DD-Lead, ZBH, RBM, and DD-Head"})," required before advancing to NBH Final Approval."]})]}),(n==null?void 0:n.role)!=="Dealer"&&e.jsxs(e.Fragment,{children:[!Ce.canFinalize&&e.jsxs(e.Fragment,{children:[Ce.canApprove&&e.jsxs(te,{className:"w-full bg-green-600 hover:bg-green-700 font-bold",onClick:()=>at("approve"),children:[e.jsx($n,{className:"w-4 h-4 mr-2"}),"Approve"]}),Ce.canIssueSCN&&e.jsxs(te,{className:"w-full bg-purple-600 hover:bg-purple-700",onClick:()=>_(!0),children:[e.jsx(Ba,{className:"w-4 h-4 mr-2"}),"Issue SCN"]}),Ce.canUploadSCNResponse&&e.jsxs(te,{className:"w-full bg-re-red hover:bg-re-red-hover",onClick:()=>{E(null),_(!0)},children:[e.jsx(ks,{className:"w-4 h-4 mr-2"}),"Upload SCN Response"]}),Ce.canApprove&&e.jsxs(te,{variant:"outline",className:"w-full",onClick:()=>at("sendBack"),children:[e.jsx(sb,{className:"w-4 h-4 mr-2"}),"Send Back"]})]}),Ce.canHold&&e.jsxs(te,{variant:"outline",className:"w-full border-orange-200 text-orange-700 hover:bg-orange-50",onClick:()=>at("hold"),children:[e.jsx(GI,{className:"w-4 h-4 mr-2"}),"Hold Decision"]}),Ce.canFinalize&&e.jsxs(te,{className:"w-full bg-indigo-600 hover:bg-indigo-700",onClick:()=>$(!0),children:[e.jsx(so,{className:"w-4 h-4 mr-2"}),"Final Authorization"]})]}),Ce.canPushToFnF&&e.jsxs(te,{variant:"outline",className:"w-full text-blue-600 border-blue-300 hover:bg-blue-50",onClick:()=>at("pushfnf"),children:[e.jsx(Gu,{className:"w-4 h-4 mr-2"}),"Push to F&F"]}),ut&&!Ce.isSettlementPhase&&!Ce.canPushToFnF&&!xe.fnfSettlement&&(xe.currentStage==="Terminated"||xe.status===Vc.AWAITING_FNF||xe.status===Vc.AWAITING_FNF_LWD_PENDING)&&!Ce.isLwdReached&&e.jsxs(Ai,{className:"border-red-200 bg-red-50",children:[e.jsx(Ba,{className:"h-4 w-4 text-re-red-hover"}),e.jsxs(il,{className:"text-red-900",children:["Push to F&F locked until ",Ri]}),e.jsxs(ki,{className:"text-red-800 text-sm",children:[Ri," is"," ",xe.proposedLwd?new Date(xe.proposedLwd).toLocaleDateString("en-IN",{dateStyle:"medium"}):"not set",". Admins are notified by email when the ",Ri.toLowerCase()," is reached."]})]}),!Ce.isFinalState&&e.jsxs(te,{variant:"outline",className:"w-full",onClick:()=>at("assign"),children:[e.jsx(nb,{className:"w-4 h-4 mr-2"}),"Assign User"]}),e.jsx(Xo,{}),e.jsxs(te,{variant:"outline",className:"w-full",onClick:()=>{var Ee;return r(`/worknotes/termination/${t}`,{state:{applicationName:((Ee=xe==null?void 0:xe.dealer)==null?void 0:Ee.businessName)||"Termination",registrationNumber:t||"",participants:(xe==null?void 0:xe.participants)||[]}})},children:[e.jsx(li,{className:"w-4 h-4 mr-2"}),"View Work Notes",Zt>0&&e.jsx(we,{className:"ml-auto bg-re-red hover:bg-re-red-hover text-white h-5 px-2",children:Zt})]})]})]})})]})]}),e.jsx(ms,{open:i.open,onOpenChange:Ee=>o({open:Ee,type:null}),children:e.jsxs(us,{children:[e.jsxs(ys,{children:[e.jsxs(gs,{children:[i.type==="approve"&&"Approve Termination Request",i.type==="withdrawal"&&"Withdraw Termination Request",i.type==="sendBack"&&"Send Back for Clarification",i.type==="revoke"&&"Revoke Termination Request",i.type==="assign"&&"Assign to User",i.type==="pushfnf"&&"Push to Full & Final Settlement",i.type==="hold"&&"Hold Termination Case"]}),e.jsx(ws,{children:i.type==="assign"?"Select a user to assign this request to":i.type==="pushfnf"?"This creates the F&F settlement record and starts departmental clearance (manual step only).":"Please provide remarks for this action"})]}),e.jsx("div",{className:"space-y-4",children:i.type==="assign"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Select User"}),e.jsxs(Rt,{value:f,onValueChange:p,children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Choose a user"})}),e.jsxs(Tt,{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"})]})]})]}):i.type==="pushfnf"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-slate-600",children:["F&F can be started on or after the ",Ri,xe.proposedLwd?` (${new Date(xe.proposedLwd).toLocaleDateString("en-IN",{dateStyle:"medium"})})`:"","."]}),e.jsx(le,{children:"Remarks (Optional)"}),e.jsx(Ks,{value:d,onChange:Ee=>m(Ee.target.value),placeholder:"Add any additional notes...",rows:3}),e.jsxs("label",{className:"flex items-start gap-2 text-sm text-slate-700 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"mt-1",checked:h,onChange:Ee=>x(Ee.target.checked)}),e.jsxs("span",{children:["Force initiate F&F before ",Ri," (requires business approval; exception use only)"]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Remarks *"}),e.jsx(Ks,{value:d,onChange:Ee=>m(Ee.target.value),placeholder:"Enter your remarks here...",rows:4})]})}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>o({open:!1,type:null}),children:"Cancel"}),e.jsx(te,{onClick:ot,className:i.type==="approve"?"bg-green-600 hover:bg-green-700":i.type==="withdrawal"?"bg-red-600 hover:bg-red-700":i.type==="hold"?"bg-orange-600 hover:bg-orange-700":"bg-blue-600 hover:bg-blue-700",children:"Confirm"})]})]})}),e.jsx(ms,{open:u.open,onOpenChange:Ee=>N({open:Ee,stageName:"",documents:[]}),children:e.jsxs(us,{className:Gb,children:[e.jsxs(ys,{children:[e.jsxs(gs,{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"w-5 h-5 text-re-red"}),"Documents - ",u.stageName]}),e.jsxs(ws,{children:["Documents uploaded for this stage (",u.documents.length," ",u.documents.length===1?"document":"documents",")"]})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto",children:u.documents.length>0?e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:u.documents.map(Ee=>e.jsxs(lt,{children:[e.jsx(oe,{children:Ee.name}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",children:Ee.type})}),e.jsx(oe,{children:Ee.uploadDate}),e.jsx(oe,{children:Ee.uploader}),e.jsx(oe,{children:e.jsxs(te,{size:"sm",variant:"outline",className:"text-re-red hover:text-re-red-hover",onClick:()=>{const $t=Ee.path;if(!$t)return;const Xt=$t.startsWith("/uploads/")&&!$t.startsWith("/uploads/documents/")?$t.replace("/uploads/","/uploads/documents/"):$t;re({fileName:Ee.name||"Document",filePath:Xt,documentType:Ee.type||"Document"})},children:[e.jsx(ks,{className:"w-4 h-4 mr-1"}),"View"]})})]},Ee.id))})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded for this stage yet"})}),e.jsx(mn,{children:e.jsx(te,{variant:"outline",onClick:()=>N({open:!1,stageName:"",documents:[]}),children:"Close"})})]})}),e.jsx(ms,{open:D,onOpenChange:_,children:e.jsxs(us,{className:"bg-white",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:We?"Upload SCN Response":"Issue Show Cause Notice (SCN)"}),e.jsx(ws,{children:We?"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:[We&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{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:Ee=>{var $t;return E((($t=Ee.target.files)==null?void 0:$t[0])||null)}}),e.jsx(te,{variant:"outline",className:"w-full border-dashed",onClick:()=>{var Ee;return(Ee=document.getElementById("scn-file-upload"))==null?void 0:Ee.click()},children:A?A.name:"Select PDF or Image"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Remarks/Details"}),e.jsx(Ks,{placeholder:"Add any internal remarks or justification...",value:q,onChange:Ee=>O(Ee.target.value),rows:4})]}),e.jsxs(mn,{className:"gap-2 sm:gap-0",children:[e.jsx(te,{variant:"outline",onClick:()=>_(!1),disabled:R,children:"Cancel"}),e.jsx(te,{className:We?"bg-re-red hover:bg-re-red-hover":"bg-purple-600 hover:bg-purple-700",onClick:We?ce:ye,disabled:R||We&&!A,children:R?"Processing...":We?"Upload Response":"Issue SCN"})]})]})]})}),e.jsx(ms,{open:L,onOpenChange:$,children:e.jsxs(us,{className:"bg-white",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Final Termination Authorization"}),e.jsx(ws,{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(le,{children:"Final Decision"}),e.jsxs(Rt,{value:Z,onValueChange:Ee=>Q(Ee),children:[e.jsx(_t,{className:"mt-2 text-slate-900 border-slate-300",children:e.jsx(Et,{placeholder:"Select decision"})}),e.jsxs(Tt,{className:"bg-white border-slate-200 shadow-xl overflow-visible z-[9999]",children:[e.jsx(Pe,{value:"Approve",className:"text-re-red-hover focus:bg-red-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-re-red focus:bg-red-50",children:"Reconsider / Give More Time"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Authorization Remarks"}),e.jsx(Ks,{placeholder:"Provide your rationale for this decision...",value:W,onChange:Ee=>U(Ee.target.value),rows:4})]}),e.jsxs(mn,{className:"gap-2 sm:gap-0",children:[e.jsx(te,{variant:"outline",onClick:()=>$(!1),disabled:R,children:"Cancel"}),e.jsx(te,{className:"bg-indigo-600 hover:bg-indigo-700",onClick:je,disabled:R||!W,children:R?"Authorizing...":"Submit Decision"})]})]})]})}),e.jsx(ms,{open:M,onOpenChange:z,children:e.jsxs(us,{children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Upload Termination Document"}),e.jsx(ws,{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(le,{children:"Document Type"}),e.jsxs(Rt,{value:I,onValueChange:K,children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Select document type"})}),e.jsx(Tt,{children:Gg.map(Ee=>e.jsx(Pe,{value:Ee,children:Ee},Ee))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Stage (Optional)"}),e.jsxs(Rt,{value:G||"none",onValueChange:Ee=>V(Ee==="none"?"":Ee),children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Select stage"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"none",children:"No Stage Mapping"}),hV.map(Ee=>e.jsx(Pe,{value:Ee,children:Ee},Ee))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"File"}),e.jsx("input",{type:"file",onChange:Ee=>{var $t;return F((($t=Ee.target.files)==null?void 0:$t[0])||null)}})]})]}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>z(!1),disabled:R,children:"Cancel"}),e.jsx(te,{onClick:Me,disabled:R,children:R?"Uploading...":"Upload"})]})]})}),e.jsx(ho,{isOpen:!!Y,onClose:()=>re(null),document:Y})]})}const xa=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"-"}},PS=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"-"}},f_=({isOpen:t,onClose:s,onSubmit:n,editingBank:r,isSubmitting:a})=>e.jsx(ms,{open:t,onOpenChange:s,children:e.jsxs(us,{className:"sm:max-w-[500px]",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:r?"Edit Bank Details":"Add Bank Account"}),e.jsx(ws,{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(le,{htmlFor:"bankName",className:"text-right text-xs",children:"Bank Name"}),e.jsx("div",{className:"col-span-3",children:e.jsx(it,{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(le,{htmlFor:"accountHolderName",className:"text-right text-xs",children:"Holder Name"}),e.jsx("div",{className:"col-span-3",children:e.jsx(it,{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(le,{htmlFor:"accountNumber",className:"text-right text-xs",children:"A/C Number"}),e.jsx("div",{className:"col-span-3",children:e.jsx(it,{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(le,{htmlFor:"ifscCode",className:"text-right text-xs",children:"IFSC Code"}),e.jsx("div",{className:"col-span-3",children:e.jsx(it,{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(le,{htmlFor:"branchName",className:"text-right text-xs",children:"Branch"}),e.jsx("div",{className:"col-span-3",children:e.jsx(it,{id:"branchName",name:"branchName",defaultValue:r==null?void 0:r.branchName,required:!0,placeholder:"Branch location",className:"h-9","data-testid":"onboarding-branch-name-input"})})]}),e.jsx("div",{className:"grid grid-cols-4 items-center gap-4",children:e.jsxs("div",{className:"flex items-center gap-2 col-start-2 col-span-3",children:[e.jsx("input",{type:"checkbox",id:"isPrimaryModal",name:"isPrimary",defaultChecked:r==null?void 0:r.isPrimary,className:"w-4 h-4 rounded border-slate-300 text-re-red focus:ring-re-red","data-testid":"onboarding-is-primary-checkbox"}),e.jsx(le,{htmlFor:"isPrimaryModal",className:"text-xs font-medium cursor-pointer",children:"Set as primary account"})]})})]}),e.jsxs(mn,{children:[e.jsx(te,{type:"button",variant:"outline",size:"sm",onClick:s,"data-testid":"onboarding-bank-details-cancel",children:"Cancel"}),e.jsxs(te,{type:"submit",disabled:a,size:"sm",className:"bg-re-red","data-testid":"onboarding-bank-details-submit",children:[a?e.jsx(cs,{className:"w-4 h-4 animate-spin mr-2"}):null,r?"Update Account":"Save Bank Details"]})]})]})]})}),OS=["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"],NV="[DEPARTMENT_CLAIM]",wV="[FINANCE_VALIDATED]";function SV({fnfId:t,onBack:s,currentUser:n}){var xe,We,Be,rt,ht;const r=tr(),[a,i]=g.useState(null),[o,d]=g.useState(!0),[m,f]=g.useState("details"),[p,h]=g.useState(!1),[x,u]=g.useState(null),[N,v]=g.useState([]),[w,j]=g.useState([]),[b,C]=g.useState(!1),[S,D]=g.useState(null),[_,A]=g.useState(!1),[E,q]=g.useState(!1),[O,R]=g.useState(null),[P,L]=g.useState(!1),[$,Z]=g.useState({remarks:"",amount:0,type:"Receivable"}),[Q,W]=g.useState(null);g.useEffect(()=>{I(),K()},[t]);const U=ge=>{if(!ge)return ge;let Je=ge.trim();const mt=OS.find(ot=>ot.toLowerCase()===Je.toLowerCase());if(mt)return mt;const at={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"}[Je.toLowerCase().replace(" department","")];return at||ge},M=(ge,Je)=>Je==="DepartmentClaim"||typeof ge=="string"&&(ge.startsWith(NV)||ge.includes("Clearance:")),z=ge=>(ge==null?void 0:ge.sourceType)==="FinanceValidated"&&typeof(ge==null?void 0:ge.description)=="string"&&ge.description.includes("Auto-seeded from department claim"),T=(ge,Je)=>Je==="FinanceValidated"||typeof ge=="string"&&ge.startsWith(wV),F=ge=>ge?{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"}[ge]||ge.split("_").map(mt=>mt.charAt(0).toUpperCase()+mt.slice(1).toLowerCase()).join(" "):"Action",I=async(ge=!0)=>{var Je,mt,de,at,ot,ke,Zt,Bt,_s,Us,fs,Vs,Qs,Xs,ie,nt,fe,Ae,Fe,Ke,Le,Ue,et,dt,ss,Wt,kt,wt,Os,as,Se,be,pt,Ve,bt,gt,rs,is,Ts,Ws,nn,Ee,$t,Xt,Cs,Mt,ze,xt,yt,Ot,Pt,Jt,bs,ns,Ds,ts,js,tn,vn,jn,xn,gn,Ye,qt;try{ge&&d(!0);const Gt=(await Re.getFnFSettlementById(t)).data;if(Gt.success){const St=Gt.fnf,qn=(St.lineItems||[]).filter(It=>It.isActive!==!1),Fr=qn.some(It=>T(It.description,It.sourceType))?qn.filter(It=>T(It.description,It.sourceType)):qn.filter(It=>!M(It.description,It.sourceType)),wn={id:St.id,caseNumber:St.settlementId||((Je=St.resignation)==null?void 0:Je.resignationId)||((mt=St.terminationRequest)==null?void 0:mt.requestId)||St.id.substring(0,8),status:St.status,requestType:St.resignationId?"Resignation":"Termination",dealerName:((at=(de=St.outlet)==null?void 0:de.dealer)==null?void 0:at.fullName)||((ot=St.dealer)==null?void 0:ot.fullName)||"N/A",dealerCode:((ke=St.outlet)==null?void 0:ke.code)||((Bt=(Zt=St.dealer)==null?void 0:Zt.dealerCode)==null?void 0:Bt.dealerCode)||"N/A",dealershipName:((_s=St.outlet)==null?void 0:_s.name)||((Us=St.dealer)==null?void 0:Us.businessName)||"N/A",location:((fs=St.outlet)==null?void 0:fs.city)||((Vs=St.outlet)==null?void 0:Vs.location)||"N/A",originalRequestId:((Qs=St.resignation)==null?void 0:Qs.resignationId)||((Xs=St.terminationRequest)==null?void 0:Xs.requestId)||((ie=St.terminationRequest)==null?void 0:ie.id)||"N/A",submittedOn:xa(St.createdAt),lastOperationalDateSales:(nt=St.resignation)!=null&&nt.lastOperationalDateSales||(fe=St.terminationRequest)!=null&&fe.proposedLwd?PS(((Ae=St.resignation)==null?void 0:Ae.lastOperationalDateSales)||((Fe=St.terminationRequest)==null?void 0:Fe.proposedLwd)):"N/A",lastOperationalDateServices:(Ke=St.resignation)!=null&&Ke.lastOperationalDateServices||(Le=St.terminationRequest)!=null&&Le.proposedLwd?PS(((Ue=St.resignation)==null?void 0:Ue.lastOperationalDateServices)||((et=St.terminationRequest)==null?void 0:et.proposedLwd)):"N/A",typeOfClosure:St.resignationId?"Voluntary":"Involuntary",gst:((Wt=(ss=(dt=St.outlet)==null?void 0:dt.dealer)==null?void 0:ss.dealerProfile)==null?void 0:Wt.gstNumber)||((kt=St.dealer)==null?void 0:kt.gstNumber)||"N/A",pan:((as=(Os=(wt=St.outlet)==null?void 0:wt.dealer)==null?void 0:Os.dealerProfile)==null?void 0:as.panNumber)||((Se=St.dealer)==null?void 0:Se.panNumber)||"N/A",salesCode:((pt=(be=St.dealer)==null?void 0:be.dealerCode)==null?void 0:pt.salesCode)||((rs=(gt=(bt=(Ve=St.outlet)==null?void 0:Ve.dealer)==null?void 0:bt.dealerProfile)==null?void 0:gt.dealerCode)==null?void 0:rs.salesCode)||"N/A",serviceCode:((Ts=(is=St.dealer)==null?void 0:is.dealerCode)==null?void 0:Ts.serviceCode)||(($t=(Ee=(nn=(Ws=St.outlet)==null?void 0:Ws.dealer)==null?void 0:nn.dealerProfile)==null?void 0:Ee.dealerCode)==null?void 0:$t.serviceCode)||"N/A",gearCode:((Cs=(Xt=St.dealer)==null?void 0:Xt.dealerCode)==null?void 0:Cs.gearCode)||((yt=(xt=(ze=(Mt=St.outlet)==null?void 0:Mt.dealer)==null?void 0:ze.dealerProfile)==null?void 0:xt.dealerCode)==null?void 0:yt.gearCode)||"N/A",gmaCode:((Pt=(Ot=St.dealer)==null?void 0:Ot.dealerCode)==null?void 0:Pt.gmaCode)||((Ds=(ns=(bs=(Jt=St.outlet)==null?void 0:Jt.dealer)==null?void 0:bs.dealerProfile)==null?void 0:ns.dealerCode)==null?void 0:Ds.gmaCode)||"N/A",financeReportStatus:St.status==="Finance Approval"?"In Progress":St.status==="Completed"?"Completed":"Pending",totalPayableAmount:Fr.filter(It=>It.itemType==="Payable").reduce((It,As)=>It+(parseFloat(As.amount)||0),0),totalRecoveryAmount:Fr.filter(It=>It.itemType==="Receivable"||It.itemType==="Recovery").reduce((It,As)=>It+(parseFloat(As.amount)||0),0),totalDeductions:Fr.filter(It=>It.itemType==="Deduction").reduce((It,As)=>It+(parseFloat(As.amount)||0),0),allLineItems:qn,netAmount:0,departmentResponses:[]};wn.netAmount=wn.totalPayableAmount-wn.totalRecoveryAmount-wn.totalDeductions,wn.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(It=>{const As=(St.clearances||[]).find(yn=>U(yn.department)===It),_r=qn.filter(yn=>U(yn.department)===It&&M(yn.description,yn.sourceType)),ca=qn.filter(yn=>U(yn.department)===It&&z(yn)),Ca=_r.length>0?_r:ca;let Yr=0,Nr=0;Ca.forEach(yn=>{const Dn=Math.abs(parseFloat(yn.amount)||0);yn.itemType==="Payable"?Yr+=Dn:Nr+=Dn});const kn=Yr-Nr,Sn=Math.abs(kn)>0,sr=(As==null?void 0:As.status)||"Pending",wr=Sn?"Dues Pending":sr==="Cleared"?"NOC Submitted":sr,Sr=kn>0?"payable":kn<0?"recovery":null;return{id:(As==null?void 0:As.id)||`dept-${It}`,clearanceId:(As==null?void 0:As.id)||null,departmentName:It,status:wr,duesFlow:Sr,amountType:kn>0?"Payable to dealer":kn<0?"Receivable from dealer":null,amount:Math.abs(kn),submittedDate:As!=null&&As.clearedAt?xa(As.clearedAt):"-",remarks:(As==null?void 0:As.remarks)||"-",supportingDocument:(As==null?void 0:As.supportingDocument)||null}});const Js={...wn,documents:[...(((ts=St.resignation)==null?void 0:ts.uploadedDocuments)||[]).map(It=>({id:`res-${It.id}`,name:It.fileName,type:"Resignation",uploadDate:xa(It.createdAt),status:"Verified",url:It.filePath})),...(St.clearances||[]).filter(It=>It.supportingDocument).map(It=>({id:`clr-${It.id}`,name:It.supportingDocument.split("/").pop(),type:`${It.department} Proof`,uploadDate:xa(It.clearedAt),status:"Attached",url:It.supportingDocument})),...(St.settlementDocs||[]).map(It=>({id:`set-${It.id}`,name:It.fileName,type:"Settlement Proof",uploadDate:xa(It.createdAt),status:"Finance",url:It.filePath}))],participants:St.participants||[]};i(Js);const Sa=St.bankDetails||((js=St.dealer)==null?void 0:js.bankDetails)||((jn=(vn=(tn=St.outlet)==null?void 0:tn.dealer)==null?void 0:vn.dealerProfile)==null?void 0:jn.bankDetails);Sa&&Sa.length>0?j(Sa):((gn=(xn=St.outlet)==null?void 0:xn.dealer)!=null&&gn.id||St.dealerId)&&G(((qt=(Ye=St.outlet)==null?void 0:Ye.dealer)==null?void 0:qt.id)||St.dealerId)}}catch(Ze){console.error("Fetch F&F details error:",Ze),J.error("Failed to fetch settlement details")}finally{ge&&d(!1)}},K=async()=>{try{const Je=(await Re.getAuditLogs("fnf",t)).data;Je.success&&v(Je.data||[])}catch(ge){console.error("Fetch audit logs error:",ge)}},G=async ge=>{try{const mt=(await Re.getDealerBankDetails(ge)).data;mt.success&&j(mt.bankDetails||[])}catch(Je){console.error("Fetch bank details error:",Je)}},V=async ge=>{var de,at;ge.preventDefault();const Je=new FormData(ge.currentTarget),mt=Object.fromEntries(Je.entries());try{A(!0);const ot=((at=(de=a==null?void 0:a.outlet)==null?void 0:de.dealer)==null?void 0:at.id)||(a==null?void 0:a.dealerId);if(!ot){J.error("Dealer information missing");return}(await Re.saveBankDetail(ot,{...mt,id:S==null?void 0:S.id,isPrimary:Je.get("isPrimary")==="on"})).data.success&&(J.success("Bank details saved successfully"),G(ot),C(!1),D(null))}catch{J.error("Failed to save bank details")}finally{A(!1)}},Y=async ge=>{var Je,mt;if(confirm("Are you sure you want to delete this bank account?"))try{if((await Re.deleteBankDetail(ge)).data.success){J.success("Bank detail deleted");const at=((mt=(Je=a==null?void 0:a.outlet)==null?void 0:Je.dealer)==null?void 0:mt.id)||(a==null?void 0:a.dealerId);at&&G(at)}}catch{J.error("Failed to delete bank detail")}};if(o)return e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(cs,{className:"w-8 h-8 animate-spin text-re-red"})});if(!a)return e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-slate-600",children:"Case not found"}),e.jsx(te,{onClick:s,className:"mt-4",children:"Go Back"})]});const ae=(ge=>{const Je=new Date(ge),de=Math.abs(new Date().getTime()-Je.getTime());return Math.ceil(de/(1e3*60*60*24))})(a.submittedOn),ue=ge=>{if(!a||!ge)return!1;const Je=String((n==null?void 0:n.role)||"").toLowerCase();if(!Je||ge.status!=="Pending")return!1;const de=["Finance Approval","Completed"].includes(a.status),at=Je.includes("super admin")||Je.includes("finance")||Je.includes("dd admin");if(de&&!at)return!1;if(at)return!0;const ot=ge.departmentName.replace(" Department","").toLowerCase();return Je.includes(ot)},ye=((a==null?void 0:a.departmentResponses)||[]).some(ge=>ue(ge)),ce=async()=>{var ge;if(!(O!=null&&O.clearanceId)||!t){J.error("Clearance record not available for this department");return}try{L(!0);const Je=new FormData,mt=Number($.amount)>0?"Dues Pending":"NOC Submitted";Je.append("status",mt),Je.append("remarks",$.remarks),Je.append("amount",String($.amount)),Je.append("type",$.type),Q&&Je.append("file",Q);const de=await Re.updateFnFClearance(t,O.clearanceId,Je);if(!de.ok){J.error(((ge=de.data)==null?void 0:ge.message)||"Failed to update department clearance"),L(!1);return}J.success(`Clearance updated for ${O.departmentName}`),q(!1),W(null),f("departments"),I(!1)}catch(Je){console.error("Update clearance error:",Je),J.error("Failed to update department clearance")}finally{L(!1)}},je=()=>{J.success("Notifications sent to all 16 departments"),h(!1)},Me=ge=>{switch(ge){case"New":return"bg-red-50 text-blue-700 border-blue-300";case"In Progress":return"bg-yellow-100 text-yellow-700 border-yellow-300";case"Under Review":return"bg-orange-100 text-orange-700 border-orange-300";case"Completed":return"bg-green-100 text-green-700 border-green-300";default:return"bg-slate-100 text-slate-700 border-slate-300"}},ut=ge=>{switch(ge){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"}},jt=a.departmentResponses.filter(ge=>ge.status!=="Pending").length,ft=a.departmentResponses.length,X=jt/ft*100,Ce=OS.map(ge=>{const Je=(a.departmentResponses||[]).find(fs=>fs.departmentName===ge),mt=Number(Je==null?void 0:Je.amount)||0,de=(Je==null?void 0:Je.amountType)||"-",at=(a.allLineItems||[]).filter(fs=>U(fs.department)===ge),ot=at.filter(fs=>fs.sourceType==="FinanceValidated"&&fs.itemType==="Payable").reduce((fs,Vs)=>fs+Math.abs(parseFloat(Vs.amount)||0),0),ke=at.filter(fs=>fs.sourceType==="FinanceValidated"&&(fs.itemType==="Receivable"||fs.itemType==="Recovery")).reduce((fs,Vs)=>fs+Math.abs(parseFloat(Vs.amount)||0),0),Zt=at.filter(fs=>fs.sourceType==="FinanceValidated"&&fs.itemType==="Deduction").reduce((fs,Vs)=>fs+Math.abs(parseFloat(Vs.amount)||0),0),Bt=ot-ke-Zt,_s=Math.abs(Bt),Us=Bt>0?"Payable":Bt<0?"Receivable":"-";return{department:ge,claimAmount:mt,claimType:de,validatedAmount:_s,validatedType:Us,variance:_s-mt}});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(_e,{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(Oe,{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(ck,{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(we,{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(te,{variant:"outline",size:"icon",onClick:s,children:e.jsx(Wr,{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(we,{className:Me(a.status),children:a.status}),e.jsx(we,{className:a.requestType==="Resignation"?"bg-red-50 text-re-red-hover border-red-300":"bg-red-100 text-red-700 border-red-300",children:a.requestType})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs(te,{variant:"outline",onClick:()=>r(`/worknotes/fnf/${t}`,{state:{applicationName:a.dealerName||"F&F Settlement",registrationNumber:a.caseNumber||"",participants:a.participants||[]}}),children:[e.jsx(li,{className:"w-4 h-4 mr-2"}),"View Work Notes"]})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Overall Progress"}),e.jsxs(es,{children:["Department responses: ",jt," / ",ft]})]}),e.jsxs(Oe,{children:[e.jsx(oc,{value:X,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(ge=>ge.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(ge=>ge.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(ge=>ge.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(In,{value:m,onValueChange:f,className:"w-full",children:[e.jsxs(Mn,{children:[e.jsx(Ht,{value:"progress",children:"Progress"}),e.jsx(Ht,{value:"details",children:"Case Details"}),e.jsx(Ht,{value:"departments",children:"Department Responses"}),e.jsx(Ht,{value:"documents",children:"Documents"}),e.jsx(Ht,{value:"audit",children:"Audit Trail"})]}),e.jsx(Vt,{value:"progress",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"F&F Settlement Progress"}),e.jsx(es,{children:"Track the complete journey from initiation to completion"})]}),e.jsx(Oe,{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($n,{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(we,{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(_e,{className:"bg-green-50 border-green-200",children:e.jsx(Oe,{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 ${jt===ft||["Finance Approval","Completed"].includes(a.status)?"bg-green-100 border-green-600":jt>0?"bg-red-50 border-re-red":"bg-slate-100 border-slate-300"}`,children:jt===ft||["Finance Approval","Completed"].includes(a.status)?e.jsx($n,{className:"w-6 h-6 text-green-600"}):jt>0?e.jsx(ja,{className:"w-6 h-6 text-re-red"}):e.jsx(dn,{className:"w-6 h-6 text-slate-400"})}),e.jsx("div",{className:`w-0.5 h-full mt-2 ${jt===ft||["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(we,{className:jt===ft||["Finance Approval","Completed"].includes(a.status)?"bg-green-600":jt>0?"bg-re-red":"bg-slate-400",children:jt===ft||["Finance Approval","Completed"].includes(a.status)?"Completed":jt>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.",jt>0&&` (${jt}/${ft} responses received)`]}),jt>0&&e.jsx(_e,{className:jt===ft||["Finance Approval","Completed"].includes(a.status)?"bg-green-50 border-green-200":"bg-blue-50 border-red-200",children:e.jsx(Oe,{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:[jt," / ",ft," ","departments"]})]}),e.jsx(oc,{value:X,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(ge=>ge.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(ge=>ge.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(ge=>ge.status==="Pending").length})]})]})]})})})]})]}),e.jsxs("div",{className:"flex gap-4 items-start",children:[e.jsxs("div",{className:"flex shrink-0 flex-col items-center",children:[e.jsx("div",{className:`size-12 shrink-0 aspect-square rounded-full flex items-center justify-center border-2 ${a.status==="Completed"?"bg-green-100 border-green-600":a.status==="Finance Approval"?"bg-red-50 border-re-red":"bg-slate-100 border-slate-300"}`,children:a.status==="Completed"?e.jsx($n,{className:"w-6 h-6 text-green-600"}):a.status==="Finance Approval"?e.jsx(hu,{className:"w-6 h-6 text-re-red"}):e.jsx(dn,{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(we,{className:a.status==="Completed"?"bg-green-600":a.status==="Finance Approval"?"bg-re-red":"bg-slate-400",children:a.status==="Completed"?"Completed":a.status==="Finance Approval"?"In Progress":"Pending"})]})}),e.jsx("p",{className:"text-slate-600 text-sm mb-3",children:"Finance department consolidates all department responses and prepares final settlement summary with total payable and recovery amounts."}),["Finance Approval","Completed"].includes(a.status)&&e.jsx(_e,{className:a.status==="Completed"?"bg-green-50 border-green-200":"bg-blue-50 border-red-200",children:e.jsx(Oe,{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:["₹",((xe=a.totalPayableAmount)==null?void 0:xe.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:["₹",((We=a.totalRecoveryAmount)==null?void 0:We.toLocaleString())||"0"]})]}),e.jsxs("div",{className:"text-center p-3 bg-red-50 rounded-lg",children:[e.jsx("p",{className:"text-xs text-blue-700 mb-1",children:"Net Amount"}),e.jsxs("p",{className:(a.totalRecoveryAmount||0)>(a.totalPayableAmount||0)?"text-red-900":"text-green-900",children:["₹",Math.abs((a.totalRecoveryAmount||0)-(a.totalPayableAmount||0)).toLocaleString()]})]})]})})})]})]}),e.jsxs("div",{className:"flex gap-4 items-start",children:[e.jsxs("div",{className:"flex shrink-0 flex-col items-center",children:[e.jsx("div",{className:`size-12 shrink-0 aspect-square rounded-full flex items-center justify-center border-2 ${a.status==="Completed"?"bg-green-100 border-green-600":a.status==="Finance Approval"?"bg-red-50 border-re-red":"bg-slate-100 border-slate-300"}`,children:a.status==="Completed"?e.jsx($n,{className:"w-6 h-6 text-green-600"}):a.status==="Finance Approval"?e.jsx(li,{className:"w-6 h-6 text-re-red"}):e.jsx(dn,{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(we,{className:a.status==="Completed"?"bg-green-600":a.status==="Finance Approval"?"bg-re-red":"bg-slate-400",children:a.status==="Completed"?"Completed":a.status==="Finance Approval"?"In Progress":"Pending"})]})}),e.jsx("p",{className:"text-slate-600 text-sm mb-3",children:"Finance team, legal team, and relevant departments discuss final settlement with the dealer. Dealer reviews and agrees to the financial terms."}),a.status==="Finance Approval"&&e.jsx(_e,{className:"bg-orange-50 border-orange-200",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(sn,{className:"w-5 h-5 text-orange-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-orange-900 mb-1",children:"Ongoing Discussions"}),e.jsx("p",{className:"text-xs text-orange-700",children:"Negotiations in progress regarding recovery/payable amounts. Finance team is working with departments and dealer to resolve discrepancies."})]})]})})})]})]}),e.jsxs("div",{className:"flex gap-4 items-start",children:[e.jsxs("div",{className:"flex shrink-0 flex-col items-center",children:[e.jsx("div",{className:`size-12 shrink-0 aspect-square rounded-full flex items-center justify-center border-2 ${a.status==="Completed"?"bg-green-100 border-green-600":"bg-slate-100 border-slate-300"}`,children:a.status==="Completed"?e.jsx($n,{className:"w-6 h-6 text-green-600"}):e.jsx(dn,{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(we,{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(Hn,{className:"w-6 h-6 text-green-600"}):e.jsx(dn,{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(we,{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(_e,{className:"bg-gradient-to-r from-green-50 to-blue-50 border-green-300",children:e.jsx(Oe,{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(Hn,{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(Vt,{value:"details",className:"space-y-6",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Basic Information"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Case Number"}),e.jsx("p",{children:a.caseNumber})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:a.dealerCode})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:a.dealerName})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealership Name"}),e.jsx("p",{children:a.dealershipName})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:a.location})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Request Type"}),e.jsx("p",{children:a.requestType})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Original Request ID"}),e.jsx("p",{children:a.originalRequestId})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:a.submittedOn})]})]})})]}),e.jsxs(_e,{className:"border-red-200 bg-blue-50/30",children:[e.jsx(Xe,{children:e.jsx(st,{className:"text-blue-900",children:"F&F Settlement Information"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Last Operational Date (Sales)"}),e.jsx("p",{children:a.lastOperationalDateSales})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Last Operational Date (Services)"}),e.jsx("p",{children:a.lastOperationalDateServices})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Submitted Date (F&F Start)"}),e.jsx("p",{children:a.submittedOn})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Days Elapsed since Submission"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{children:[ae," days"]}),e.jsx(we,{variant:"outline",className:ae<30?"bg-green-100 text-green-700 border-green-300":ae<60?"bg-yellow-100 text-yellow-700 border-yellow-300":"bg-red-100 text-red-700 border-red-300",children:ae<30?"Recent":ae<60?"In Progress":"Overdue"})]})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Type of Closure"}),e.jsx("p",{children:a.typeOfClosure})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:a.gst})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Sales Code"}),e.jsx("p",{children:a.salesCode})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Service Code"}),e.jsx("p",{children:a.serviceCode})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Gear Code"}),e.jsx("p",{children:a.gearCode})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:a.gmaCode})]})]})})]}),a.status==="Under Review"&&e.jsxs(_e,{className:"border-orange-200 bg-orange-50",children:[e.jsxs(Xe,{children:[e.jsx(st,{className:"text-orange-900",children:"Under Review"}),e.jsx(es,{className:"text-orange-700",children:"This case is under negotiation/discussion with the dealer, finance team, legal team, and relevant departments"})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-sm text-orange-800",children:"Discussions ongoing regarding recovery/payable amounts. Finance team is working with departments to resolve discrepancies."})})]})]}),e.jsxs(Vt,{value:"departments",children:[e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsxs(st,{children:["Department Responses (",jt," / ",ft,")"]}),e.jsx(es,{children:"Status of NOC and dues from all departments"})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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"}),ye&&e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:a.departmentResponses.map(ge=>e.jsxs(lt,{children:[e.jsx(oe,{children:ge.departmentName}),e.jsx(oe,{children:e.jsx(we,{className:ut(ge.status),children:ge.status})}),e.jsx(oe,{children:ge.amountType?e.jsx(we,{variant:"outline",className:ge.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:ge.amountType}):"-"}),e.jsx(oe,{children:ge.amount?e.jsxs("span",{className:`font-semibold tabular-nums ${ge.duesFlow==="recovery"?"text-red-700":"text-emerald-700"}`,children:["₹",ge.amount.toLocaleString()]}):"-"}),e.jsx(oe,{children:ge.submittedDate||"-"}),e.jsx(oe,{className:"max-w-xs truncate",children:ge.remarks||"-"}),ye&&e.jsx(oe,{children:ue(ge)?e.jsx(te,{variant:"ghost",size:"sm",className:"text-re-red hover:text-blue-700",onClick:()=>{R(ge),Z({remarks:ge.remarks==="-"?"":ge.remarks,amount:ge.amount||0,type:ge.duesFlow==="payable"?"Payable":"Receivable"}),W(null),q(!0)},children:"Action"}):e.jsx("span",{className:"text-slate-400 text-sm",children:"-"})})]},ge.id))})]})})]}),e.jsxs(_e,{className:"border-blue-200 bg-blue-50 mt-6",children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Department Claim vs Finance Validation"}),e.jsx(es,{children:"Final settlement totals are based on finance validated values."})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:Ce.map(ge=>e.jsxs(lt,{children:[e.jsx(oe,{children:ge.department}),e.jsx(oe,{children:ge.claimAmount>0?`${ge.claimType} ₹${ge.claimAmount.toLocaleString()}`:"-"}),e.jsx(oe,{children:ge.validatedAmount>0?`${ge.validatedType} ₹${ge.validatedAmount.toLocaleString()}`:"-"}),e.jsx(oe,{className:ge.variance===0?"text-slate-600":ge.variance>0?"text-red-600":"text-green-600",children:ge.claimAmount===0&&ge.validatedAmount===0?"-":`₹${ge.variance.toLocaleString()}`})]},ge.department))})]})})]}),e.jsxs(_e,{className:"mt-6",children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Financial Summary"}),e.jsx(es,{children:"Consolidated view of all payable and receivable amounts"})]}),e.jsx(Oe,{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:["₹",((Be=a.totalPayableAmount)==null?void 0:Be.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:["₹",((rt=a.totalRecoveryAmount)==null?void 0:rt.toLocaleString())||"0"]}),e.jsx("p",{className:"text-xs text-red-600 mt-1",children:"Amount receivable from dealer"})]}),e.jsxs("div",{className:"p-6 bg-red-50 rounded-lg border border-red-200",children:[e.jsx("p",{className:"text-sm text-re-red-hover mb-2",children:"Total Deductions"}),e.jsxs("p",{className:"text-3xl text-re-red font-bold",children:["₹",((ht=a.totalDeductions)==null?void 0:ht.toLocaleString())||"0"]}),e.jsx("p",{className:"text-xs text-re-red mt-1",children:"Warranty holdbacks / Policy penalties"})]}),e.jsxs("div",{className:"p-6 bg-blue-50 rounded-lg border border-blue-200",children:[e.jsx("p",{className:"text-sm text-blue-700 mb-2",children:"Net Settlement Amount"}),e.jsxs("p",{className:`text-3xl font-extrabold ${(a.netAmount||0)<0?"text-red-600":"text-green-600"}`,children:["₹",Math.abs(a.netAmount||0).toLocaleString()]}),e.jsx("p",{className:"text-xs text-blue-600 mt-1",children:(a.netAmount||0)<0?"Receivable from dealer":"Payment to dealer"})]})]})})]}),e.jsxs(_e,{className:"mt-6",children:[e.jsx(Xe,{children:e.jsx(st,{children:"Finance Report Status"})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(we,{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(le,{className:"text-slate-600",children:"Finance Remarks"}),e.jsx("p",{className:"mt-1",children:a.financeRemarks})]})]})]})]}),e.jsx(Vt,{value:"documents",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Documents"}),e.jsx(es,{children:"All NOC documents and due statements from departments"})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:a.documents.map(ge=>e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"w-4 h-4 text-slate-500"}),e.jsx("span",{children:ge.name})]})}),e.jsx(oe,{children:ge.type}),e.jsx(oe,{children:ge.uploadDate}),e.jsx(oe,{children:e.jsx(we,{variant:ge.status==="Verified"?"default":"secondary",children:ge.status})}),e.jsx(oe,{children:e.jsx(te,{size:"sm",variant:"outline",onClick:()=>{const Je=ge.url,mt=Je.startsWith("/uploads/")&&!Je.startsWith("/uploads/documents/")?Je.replace("/uploads/","/uploads/documents/"):Je;u({fileName:ge.name,filePath:mt,documentType:ge.type})},children:"View"})})]},ge.id))})]})})]})}),e.jsx(Vt,{value:"bank",children:e.jsxs(_e,{children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"Bank Details"}),e.jsx(es,{children:"Dealer bank accounts for settlement disbursement"})]}),e.jsxs(te,{onClick:()=>{D(null),C(!0)},className:"bg-re-red",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add Account"]})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:w.length>0?w.map(ge=>e.jsxs(_e,{className:`relative overflow-hidden ${ge.isPrimary?"border-re-red bg-blue-50/30":""}`,children:[ge.isPrimary&&e.jsx("div",{className:"absolute top-0 right-0 p-1 bg-re-red text-white text-[10px] uppercase font-bold px-2 rounded-bl",children:"Primary"}),e.jsxs(Oe,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 bg-red-50 rounded-lg",children:e.jsx(to,{className:"w-5 h-5 text-re-red"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-slate-900",children:ge.bankName}),e.jsx("p",{className:"text-xs text-slate-500",children:ge.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:ge.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:ge.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:ge.ifscCode})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-slate-100",children:[e.jsxs(te,{variant:"ghost",size:"sm",className:"h-8 text-re-red",onClick:()=>{D(ge),C(!0)},children:[e.jsx(ry,{className:"w-3 h-3 mr-1"}),"Edit"]}),e.jsxs(te,{variant:"ghost",size:"sm",className:"h-8 text-red-600",onClick:()=>Y(ge.id),children:[e.jsx(Zn,{className:"w-3 h-3 mr-1"}),"Delete"]})]})]})]},ge.id)):e.jsxs("div",{className:"col-span-full py-12 text-center border-2 border-dashed rounded-lg bg-slate-50",children:[e.jsx(to,{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(te,{variant:"link",onClick:()=>C(!0),children:"Add first bank account"})]})})})]})}),e.jsx(Vt,{value:"audit",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Audit Trail"}),e.jsx(es,{children:"Complete history of actions on this F&F case"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:N.length>0?N.map(ge=>{var Je,mt,de,at,ot,ke;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:[ge.action==="FNF_CREATED"&&e.jsx(we,{className:"bg-re-red h-2 w-2 p-0 rounded-full"}),ge.description&&!((Je=ge.newData)!=null&&Je.action)?ge.description:e.jsxs(e.Fragment,{children:[F(((mt=ge.newData)==null?void 0:mt.action)||ge.action),((de=ge.newData)==null?void 0:de.department)&&e.jsxs("span",{className:"text-re-red ml-1 font-bold",children:["- ",ge.newData.department]})]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:xa(ge.createdAt||ge.timestamp)})]}),e.jsx("div",{className:"flex items-center gap-2 text-sm text-slate-600 mb-2",children:e.jsx(we,{variant:"outline",className:"text-[10px] uppercase",children:((at=ge.actor)==null?void 0:at.name)||ge.userName||"System"})}),(((ot=ge.newData)==null?void 0:ot.remarks)||ge.remarks)&&e.jsx("div",{className:"mt-2 p-3 bg-slate-50 border border-slate-200 rounded text-sm text-slate-700",children:((ke=ge.newData)==null?void 0:ke.remarks)||ge.remarks}),ge.newData&&Object.keys(ge.newData).filter(Zt=>Zt!=="remarks"&&Zt!=="status"&&Zt!=="action"&&Zt!=="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(ge.newData).filter(([Zt])=>Zt!=="remarks"&&Zt!=="action"&&Zt!=="department").map(([Zt,Bt])=>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:[Zt,":"]}),e.jsx("span",{className:"text-slate-900 font-medium",children:String(Bt)})]},Zt))})]})]})]},ge.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(ms,{open:p,onOpenChange:h,children:e.jsxs(us,{children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Send to All Stakeholders"}),e.jsx(ws,{children:"This will send notifications to all 16 departments to submit their NOC or dues information"})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"p-4 bg-blue-50 rounded-lg border border-red-200",children:[e.jsx("p",{className:"text-sm text-blue-900 mb-2",children:"Notifications will be sent to:"}),e.jsxs("ul",{className:"text-sm text-blue-800 space-y-1 ml-4",children:[e.jsx("li",{children:"• All 16 departments"}),e.jsxs("li",{children:["• Case Number: ",a.caseNumber]}),e.jsxs("li",{children:["• Dealer: ",a.dealerName]}),e.jsxs("li",{children:["• Type: ",a.requestType]})]})]})}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>h(!1),children:"Cancel"}),e.jsxs(te,{onClick:je,className:"bg-re-red hover:bg-blue-700",children:[e.jsx(Gu,{className:"w-4 h-4 mr-2"}),"Send Notifications"]})]})]})}),e.jsx(ms,{open:E,onOpenChange:q,children:e.jsxs(us,{className:"sm:max-w-[460px]",children:[e.jsxs(ys,{children:[e.jsxs(gs,{children:["Update ",O==null?void 0:O.departmentName," Response"]}),e.jsx(ws,{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(le,{htmlFor:"type",className:"text-right",children:"Type"}),e.jsxs("select",{id:"type",className:"col-span-3 flex h-10 w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm",value:$.type,onChange:ge=>Z({...$,type:ge.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(le,{htmlFor:"amount",className:"text-right",children:"Amount"}),e.jsxs("div",{className:"col-span-3 relative",children:[e.jsx("span",{className:"absolute left-3 top-2.5 text-slate-500 font-medium",children:"₹"}),e.jsx("input",{id:"amount",type:"number",className:"flex h-10 w-full rounded-md border border-slate-200 bg-white pl-7 pr-3 py-2 text-sm",value:$.amount,onChange:ge=>Z({...$,amount:Number(ge.target.value)})})]})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(le,{htmlFor:"remarks",className:"text-right",children:"Remarks"}),e.jsx("textarea",{id:"remarks",className:"col-span-3 flex min-h-[80px] w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm",placeholder:"Add response details...",value:$.remarks,onChange:ge=>Z({...$,remarks:ge.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(le,{htmlFor:"proof",className:"text-right",children:"Proof"}),e.jsx("input",{id:"proof",type:"file",className:"col-span-3 text-sm",onChange:ge=>{var Je;return W(((Je=ge.target.files)==null?void 0:Je[0])||null)}})]})]}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>q(!1),children:"Cancel"}),e.jsx(te,{className:"bg-re-red hover:bg-blue-700",onClick:ce,disabled:P,children:P?"Saving...":"Submit Response"})]})]})}),e.jsx(f_,{isOpen:b,onClose:()=>{C(!1),D(null)},onSubmit:V,editingBank:S,isSubmitting:_}),e.jsx(ho,{isOpen:!!x,onClose:()=>u(null),document:x})]})}function CV({onViewPaymentDetails:t}={}){const[s,n]=g.useState([]),[r,a]=g.useState(!0),[i,o]=g.useState("pending");g.useEffect(()=>{d()},[]);const d=async()=>{try{a(!0);const u=await ps.getApplications();n(u.data||[])}catch(u){console.error("Fetch error:",u),J.error("Failed to fetch applications")}finally{a(!1)}},m=u=>String(u||"").trim().toLowerCase(),f=u=>{const N=m(u);return N==="verified"||N==="paid"},p=s.flatMap(u=>{const N=u.overallStatus||u.status,v=["Payment Pending","Security Deposit","Security Details","LOI In Progress","LOI Issued","LOA Pending","Dealer Code Generation","LOA_APPROVAL"].includes(N),w=u.securityDeposits||[];return w.length>0?w.map(j=>({id:j.id,applicationId:u.applicationId||u.id,application:u,paymentStatus:j.status,paymentType:j.depositType,amount:j.amount,createdAt:j.createdAt,verificationDate:j.verifiedAt,isVirtual:!1})):v?["Payment Pending","Security Deposit","Security Details","LOI In Progress"].includes(N)?[{id:`virtual-${u.id}-sd`,applicationId:u.applicationId||u.id,application:u,paymentStatus:"Pending",paymentType:"SECURITY_DEPOSIT",amount:5e5,createdAt:u.updatedAt,verificationDate:null,isVirtual:!0}]:[{id:`virtual-${u.id}-ff`,applicationId:u.applicationId||u.id,application:u,paymentStatus:"Pending",paymentType:"FIRST_FILL",amount:15e5,createdAt:u.updatedAt,verificationDate:null,isVirtual:!0}]:[]}),h=p.filter(u=>i==="all"?!0:i==="pending"?!f(u.paymentStatus):i==="verified"?f(u.paymentStatus):!0),x=u=>{t&&t(u)};return r?e.jsxs("div",{className:"flex items-center justify-center p-20 text-blue-600",children:[e.jsx(dn,{className:"w-8 h-8 animate-spin mr-3"}),e.jsx("span",{children:"Loading Finance Queue..."})]}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between bg-white p-6 rounded-2xl border border-slate-100 shadow-sm",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-slate-900 tracking-tight mb-1",children:"Payment Verification"}),e.jsx("p",{className:"text-slate-500",children:"Review and verify Security Deposit and First Fill payments for dealers"})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs(te,{onClick:d,variant:"outline",size:"sm",className:"bg-white hover:bg-slate-50","data-testid":"onboarding-finance-queue-sync-btn",children:[e.jsx(dn,{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(ya,{className:"w-4 h-4 mr-2 text-blue-600"}),"Pending Payments (",p.filter(u=>!f(u.paymentStatus)).length,")"]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(te,{variant:i==="pending"?"secondary":"ghost",size:"sm",onClick:()=>o("pending"),className:i==="pending"?"bg-slate-200 text-slate-900":"text-slate-500","data-testid":"onboarding-finance-queue-filter-pending",children:"Pending"}),e.jsx(te,{variant:i==="verified"?"secondary":"ghost",size:"sm",onClick:()=>o("verified"),className:i==="verified"?"bg-slate-200 text-slate-900":"text-slate-500","data-testid":"onboarding-finance-queue-filter-verified",children:"Verified"}),e.jsx(te,{variant:i==="all"?"secondary":"ghost",size:"sm",onClick:()=>o("all"),className:i==="all"?"bg-slate-200 text-slate-900":"text-slate-500","data-testid":"onboarding-finance-queue-filter-all",children:"All"})]})]}),e.jsx(_e,{className:"border-none shadow-xl overflow-hidden rounded-2xl bg-white","data-testid":"onboarding-finance-queue-table-card",children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Ms,{children:[e.jsx(Fs,{className:"bg-slate-50/50",children:e.jsxs(lt,{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(Bs,{children:h.length>0?h.map((u,N)=>{const v=u.paymentStatus||"Awaiting Payment",w=u.application||{};return e.jsxs(lt,{className:"hover:bg-blue-50/20 group transition-all","data-testid":`onboarding-finance-queue-row-${N}`,children:[e.jsx(oe,{className:"py-4 pl-6",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-mono text-xs font-bold text-blue-600 mb-1","data-testid":`onboarding-finance-queue-app-id-${N}`,children:w.applicationId||w.id}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"font-semibold text-slate-900","data-testid":`onboarding-finance-queue-name-${N}`,children:w.applicantName})})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex flex-col text-sm","data-testid":`onboarding-finance-queue-location-${N}`,children:[e.jsx("span",{className:"text-slate-600 leading-none",children:w.city}),e.jsx("span",{className:"text-slate-400 text-xs mt-1",children:w.state})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2","data-testid":`onboarding-finance-queue-type-${N}`,children:[e.jsx(Wu,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-sm font-medium",children:u.paymentType==="SECURITY_DEPOSIT"?"Security Deposit (₹5L)":"First Fill (₹15L)"})]})}),e.jsx(oe,{children:e.jsx(we,{className:v==="Verified"?"bg-emerald-50 text-emerald-700 border-emerald-100 px-3 py-1 rounded-full":v==="Rejected"?"bg-rose-50 text-rose-700 border-rose-100 px-3 py-1 rounded-full":"bg-red-50 text-re-red-hover border-red-100 px-3 py-1 rounded-full",variant:"outline","data-testid":`onboarding-finance-queue-status-${N}`,children:v})}),e.jsx(oe,{className:"text-right pr-6",children:e.jsx(te,{size:"sm",variant:f(v)?"outline":"default",className:f(v)?"bg-white text-slate-600 border-slate-200":"bg-blue-600 hover:bg-blue-700 shadow-md",onClick:()=>x(u.applicationId||w.id),"data-testid":`onboarding-finance-queue-action-btn-${N}`,children:e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"w-4 h-4 mr-2"}),f(v)?"View Receipt":"Record Payment"]})})})]},u.id)}):e.jsx(lt,{children:e.jsx(oe,{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(ln,{className:"w-6 h-6 text-slate-200"})}),e.jsx("p",{className:"text-sm",children:i==="verified"?"No verified payments found":i==="pending"?"No pending payments in the queue":"No onboarding payments found"})]})})})})]})})})]})}function AV({onViewFnFDetails:t}={}){const[s,n]=g.useState([]),[r,a]=g.useState(!0),[i,o]=g.useState(null),[d,m]=g.useState(!1),[f,p]=g.useState(!1),[h,x]=g.useState(""),[u,N]=g.useState(""),[v,w]=g.useState("all");g.useEffect(()=>{j()},[]);const j=async()=>{try{a(!0);const P=(await Re.getFnFSettlements()).data;P.success&&n(P.settlements||[])}catch(R){console.error("Fetch settlements error:",R),J.error("Failed to fetch settlement cases")}finally{a(!1)}},b=R=>{var P,L,$,Z,Q,W,U,M,z,T,F,I;return{id:R.id,caseId:R.settlementId||((P=R.resignation)==null?void 0:P.resignationId)||((L=R.terminationRequest)==null?void 0:L.requestId)||R.id.substring(0,8),dealerCode:(($=R.outlet)==null?void 0:$.code)||((Q=(Z=R.dealer)==null?void 0:Z.dealerCode)==null?void 0:Q.dealerCode)||"N/A",dealerName:((U=(W=R.outlet)==null?void 0:W.dealer)==null?void 0:U.fullName)||((M=R.dealer)==null?void 0:M.legalName)||((z=R.dealer)==null?void 0:z.businessName)||((T=R.dealer)==null?void 0:T.fullName)||"N/A",location:((F=R.outlet)==null?void 0:F.city)||((I=R.outlet)==null?void 0:I.location)||"N/A",terminationType:R.resignationId?"Resignation":"Termination",submittedDate:Qt(R.createdAt),status:R.status==="Calculated"?"Pending Finance Review":R.status==="Settled"?"Settled":R.status,financialData:{totalPayables:parseFloat(R.totalPayables)||0,totalReceivables:parseFloat(R.totalReceivables)||0,netAmount:parseFloat(R.netAmount)||0},settlementAmount:Math.abs(parseFloat(R.netAmount)||0),settlementType:parseFloat(R.netAmount)>0?"Payable to Dealer":"Receivable from Dealer",approvedDate:R.settlementDate?Qt(R.settlementDate):null}},C=s.map(b),S=C.filter(R=>v==="all"?!0:v==="pending"?R.status==="Pending Finance Review"||R.status==="Calculated"||R.status==="Initiated"||R.status==="Under Review":v==="approved"?R.status==="Settled"||R.status==="Completed":!0),D=R=>({receivables:R.totalReceivables||0,payables:R.totalPayables||0,deductions:0,netSettlement:R.netAmount||0,settlementType:(R.netAmount||0)>0?"Payable to Dealer":"Receivable from Dealer",settlementAmount:Math.abs(R.netAmount||0)}),_=R=>{t?t(R.id):(o(R),m(!0))},A=R=>{t?t(R.id):(o(R),p(!0))},E=()=>{const R=D(i.financialData);J.success(`Settlement approved: ${R.settlementType} - ₹${R.settlementAmount.toLocaleString()}`),m(!1),x(""),N(""),o(null)},q=C.filter(R=>R.status==="Pending Finance Review"||R.status==="Calculated"||R.status==="Initiated"||R.status==="Under Review").length,O=C.filter(R=>R.status==="Settled"||R.status==="Completed").length;return r?e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(cs,{className:"w-8 h-8 animate-spin text-re-red"})}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 mb-2",children:"F&F Financial Settlement"}),e.jsx("p",{className:"text-slate-600",children:"Review and process full & final settlements for dealerships"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs(_e,{children:[e.jsx(Xe,{className:"pb-3",children:e.jsx(st,{className:"text-sm text-slate-600",children:"Pending Review"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-slate-900 text-2xl",children:q}),e.jsx(rk,{className:"w-8 h-8 text-re-red"})]})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{className:"pb-3",children:e.jsx(st,{className:"text-sm text-slate-600",children:"Approved Settlements"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-slate-900 text-2xl",children:O}),e.jsx(ln,{className:"w-8 h-8 text-green-600"})]})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{className:"pb-3",children:e.jsx(st,{className:"text-sm text-slate-600",children:"Total Cases"})}),e.jsx(Oe,{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(ks,{className:"w-8 h-8 text-blue-600"})]})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{className:"pb-3",children:e.jsx(st,{className:"text-sm text-slate-600",children:"Net Financial Position"})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:`text-2xl ${C.reduce((R,P)=>R+(P.financialData.netAmount||0),0)<0?"text-green-600":"text-red-600"}`,children:["₹",Math.abs(C.reduce((R,P)=>R+(P.financialData.netAmount||0),0)).toLocaleString("en-IN")]}),e.jsx(ll,{className:"w-8 h-8 text-purple-600"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:C.reduce((R,P)=>R+(P.financialData.netAmount||0),0)<0?"Net Receivable":"Net Payable"})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(te,{variant:v==="all"?"default":"outline",onClick:()=>w("all"),className:v==="all"?"bg-re-red hover:bg-re-red-hover":"",children:["All Cases (",C.length,")"]}),e.jsxs(te,{variant:v==="pending"?"default":"outline",onClick:()=>w("pending"),className:v==="pending"?"bg-re-red hover:bg-re-red-hover":"",children:["Pending Review (",q,")"]}),e.jsxs(te,{variant:v==="approved"?"default":"outline",onClick:()=>w("approved"),className:v==="approved"?"bg-re-red hover:bg-re-red-hover":"",children:["Approved (",O,")"]})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"F&F Settlement Queue"}),e.jsx(es,{children:"Review financial status and calculate settlements"})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:S.map(R=>{const P=D(R.financialData);return e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{children:[e.jsx("div",{className:"text-slate-900",children:R.caseId}),e.jsx("div",{className:"text-sm text-slate-500",children:R.dealerCode})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rr,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:R.dealerName})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mr,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:R.location})]})}),e.jsx(oe,{children:e.jsx(we,{variant:R.terminationType==="Resignation"?"default":"secondary",children:R.terminationType})}),e.jsx(oe,{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:R.submittedDate})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[P.settlementType==="Payable to Dealer"?e.jsx(Go,{className:"w-4 h-4 text-red-600"}):e.jsx(ll,{className:"w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-slate-900",children:["₹",P.settlementAmount.toLocaleString()]}),e.jsx("div",{className:"text-xs text-slate-500",children:P.settlementType})]})]})}),e.jsx(oe,{children:e.jsx(we,{variant:R.status==="Settlement Approved"?"default":"secondary",className:R.status==="Settlement Approved"?"bg-green-600 text-white":"bg-re-red text-white",children:R.status})}),e.jsx(oe,{children:e.jsxs(te,{size:"sm",variant:R.status==="Pending Finance Review"?"default":"outline",className:R.status==="Pending Finance Review"?"bg-re-red hover:bg-re-red-hover":"",onClick:()=>A(R),children:[e.jsx(ks,{className:"w-4 h-4 mr-2"}),"View Details"]})})]},R.id)})})]})})]}),e.jsx(ms,{open:d,onOpenChange:m,children:e.jsxs(us,{className:"max-w-5xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Financial Settlement Review"}),e.jsxs(ws,{children:["Review financial details and calculate final settlement for ",i==null?void 0:i.dealerName]})]}),i&&e.jsxs(In,{defaultValue:"breakdown",className:"w-full",children:[e.jsxs(Mn,{className:"grid w-full grid-cols-3",children:[e.jsx(Ht,{value:"breakdown",children:"Financial Breakdown"}),e.jsx(Ht,{value:"calculation",children:"Settlement Calculation"}),e.jsx(Ht,{value:"summary",children:"Final Summary"})]}),e.jsxs(Vt,{value:"breakdown",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(_e,{className:"border-green-200 bg-green-50",children:[e.jsxs(Xe,{children:[e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(af,{className:"w-5 h-5 text-green-600"}),"Payables to Dealer"]}),e.jsx(es,{children:"Amounts company owes to dealer"})]}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Security Deposit"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.securityDeposit.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Inventory Value"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.inventoryValue.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Equipment Value"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.equipmentValue.toLocaleString()]})]}),e.jsx("div",{className:"pt-3 border-t border-green-300",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-900",children:"Total Payables"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",(i.financialData.securityDeposit+i.financialData.inventoryValue+i.financialData.equipmentValue).toLocaleString()]})]})})]})]}),e.jsxs(_e,{className:"border-red-200 bg-red-50",children:[e.jsxs(Xe,{children:[e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(ay,{className:"w-5 h-5 text-red-600"}),"Receivables from Dealer"]}),e.jsx(es,{children:"Amounts dealer owes to company"})]}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Outstanding Invoices"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.outstandingInvoices.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Service Dues"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.serviceDues.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Parts Dues"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.partsDues.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Advances Given"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.advancesGiven.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Penalties"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.penalties.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Other Charges"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.otherCharges.toLocaleString()]})]}),e.jsx("div",{className:"pt-3 border-t border-red-300",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-900",children:"Total Receivables"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",D(i.financialData).receivables.toLocaleString()]})]})})]})]})]}),e.jsxs(_e,{className:"border-red-200 bg-red-50",children:[e.jsxs(Xe,{children:[e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red"}),"Deductions"]}),e.jsx(es,{children:"Pending claims and deductions"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Warranty Claims Pending"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",i.financialData.warrantyPending.toLocaleString()]})]})})]})]}),e.jsx(Vt,{value:"calculation",className:"space-y-4",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Settlement Calculation"}),e.jsx(es,{children:"Step-by-step calculation of final settlement amount"})]}),e.jsx(Oe,{className:"space-y-4",children:(()=>{const R=D(i.financialData);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center p-3 bg-green-50 rounded",children:[e.jsx("span",{className:"text-slate-900",children:"Total Payables (to Dealer)"}),e.jsxs("span",{className:"text-green-600 text-lg",children:["+ ₹",R.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:["- ₹",R.receivables.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-red-50 rounded",children:[e.jsx("span",{className:"text-slate-900",children:"Total Deductions"}),e.jsxs("span",{className:"text-re-red text-lg",children:["- ₹",R.deductions.toLocaleString()]})]})]}),e.jsx("div",{className:"h-px bg-slate-300"}),e.jsxs("div",{className:`p-4 rounded-lg ${R.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:["₹",R.settlementAmount.toLocaleString()]})]}),e.jsx("div",{className:"flex items-center gap-2",children:R.settlementType==="Payable to Dealer"?e.jsxs(e.Fragment,{children:[e.jsx(Go,{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(ll,{className:"w-5 h-5 text-green-600"}),e.jsx("span",{className:"text-green-700",children:"Dealer needs to pay company"})]})})]}),e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-blue-50 border border-blue-200 rounded-lg",children:[e.jsx(sn,{className:"w-5 h-5 text-blue-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-900 mb-1",children:"Calculation Formula"}),e.jsx("p",{className:"text-sm text-slate-600",children:"Net Settlement = Total Payables - Total Receivables - Total Deductions"}),e.jsxs("p",{className:"text-sm text-slate-600 mt-2",children:["= ₹",R.payables.toLocaleString()," - ₹",R.receivables.toLocaleString()," - ₹",R.deductions.toLocaleString()]})]})]})]})})()})]})}),e.jsxs(Vt,{value:"summary",className:"space-y-4",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Case Summary"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Case ID"}),e.jsx("p",{className:"text-slate-900",children:i.id})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Dealer Name"}),e.jsx("p",{className:"text-slate-900",children:i.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Dealer Code"}),e.jsx("p",{className:"text-slate-900",children:i.dealerCode})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Location"}),e.jsx("p",{className:"text-slate-900",children:i.location})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Termination Type"}),e.jsx("p",{className:"text-slate-900",children:i.terminationType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Submitted Date"}),e.jsx("p",{className:"text-slate-900",children:i.submittedDate})]})]})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Final Settlement"})}),e.jsxs(Oe,{className:"space-y-4",children:[(()=>{const R=D(i.financialData);return e.jsxs("div",{className:`p-6 rounded-lg text-center ${R.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:[R.settlementType==="Payable to Dealer"?e.jsx(Go,{className:"w-8 h-8 text-red-600"}):e.jsx(ll,{className:"w-8 h-8 text-green-600"}),e.jsx("span",{className:`text-lg ${R.settlementType==="Payable to Dealer"?"text-red-700":"text-green-700"}`,children:R.settlementType})]}),e.jsxs("div",{className:"text-4xl text-slate-900 mb-2",children:["₹",R.settlementAmount.toLocaleString()]}),e.jsx("p",{className:"text-slate-600",children:R.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(le,{htmlFor:"adjustments",children:"Adjustments (if any)"}),e.jsx(it,{id:"adjustments",value:h,onChange:R=>x(R.target.value),placeholder:"Enter any adjustments to the settlement amount"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"finalNotes",children:"Final Notes"}),e.jsx(Ks,{id:"finalNotes",value:u,onChange:R=>N(R.target.value),placeholder:"Enter any final notes or remarks for this settlement...",rows:4})]})]})]})]})]}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>m(!1),children:"Cancel"}),e.jsxs(te,{className:"bg-green-600 hover:bg-green-700",onClick:E,children:[e.jsx(ln,{className:"w-4 h-4 mr-2"}),"Approve Settlement"]})]})]})}),e.jsx(ms,{open:f,onOpenChange:p,children:e.jsxs(us,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Settlement Details"}),e.jsxs(ws,{children:["Complete settlement information for ",i==null?void 0:i.dealerName]})]}),i&&e.jsxs(In,{defaultValue:"info",className:"w-full",children:[e.jsxs(Mn,{className:"grid w-full grid-cols-2",children:[e.jsx(Ht,{value:"info",children:"Case Information"}),e.jsx(Ht,{value:"financial",children:"Financial Breakdown"})]}),e.jsx(Vt,{value:"info",className:"space-y-4 mt-4",children:e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{className:"text-base",children:"Case Details"})}),e.jsx(Oe,{className:"space-y-3",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Case ID"}),e.jsx("p",{className:"text-slate-900",children:i.id})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Dealer Code"}),e.jsx("p",{className:"text-slate-900",children:i.dealerCode})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Dealer Name"}),e.jsx("p",{className:"text-slate-900",children:i.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Location"}),e.jsx("p",{className:"text-slate-900",children:i.location})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Termination Type"}),e.jsx(we,{variant:i.terminationType==="Resignation"?"default":"secondary",children:i.terminationType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Status"}),e.jsx(we,{variant:i.status==="Settlement Approved"?"default":"secondary",className:i.status==="Settlement Approved"?"bg-green-600 text-white":"bg-re-red text-white",children:i.status})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Submitted Date"}),e.jsx("p",{className:"text-slate-900",children:i.submittedDate})]}),i.approvedDate&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Approved Date"}),e.jsx("p",{className:"text-slate-900",children:i.approvedDate})]})]})})]})}),e.jsx(Vt,{value:"financial",className:"space-y-4 mt-4",children:(()=>{const R=D(i.financialData);return e.jsxs(e.Fragment,{children:[e.jsxs(_e,{className:"border-green-200 bg-green-50",children:[e.jsx(Xe,{children:e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(af,{className:"w-5 h-5 text-green-600"}),"Payables to Dealer"]})}),e.jsxs(Oe,{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Security Deposit"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.securityDeposit.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Inventory Value"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.inventoryValue.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Equipment Value"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.equipmentValue.toLocaleString()]})]}),e.jsx("div",{className:"pt-2 border-t border-green-300",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-900",children:"Total Payables"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",R.payables.toLocaleString()]})]})})]})]}),e.jsxs(_e,{className:"border-red-200 bg-red-50",children:[e.jsx(Xe,{children:e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(ay,{className:"w-5 h-5 text-red-600"}),"Receivables from Dealer"]})}),e.jsxs(Oe,{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Outstanding Invoices"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.outstandingInvoices.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Service Dues"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.serviceDues.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Parts Dues"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.partsDues.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Advances Given"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.advancesGiven.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Penalties"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.penalties.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Other Charges"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.otherCharges.toLocaleString()]})]}),e.jsx("div",{className:"pt-2 border-t border-red-300",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-900",children:"Total Receivables"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",R.receivables.toLocaleString()]})]})})]})]}),e.jsxs(_e,{className:"border-red-200 bg-red-50",children:[e.jsx(Xe,{children:e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red"}),"Deductions"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Warranty Claims Pending"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",i.financialData.warrantyPending.toLocaleString()]})]})})]}),e.jsxs(_e,{className:`${R.settlementType==="Payable to Dealer"?"border-red-300 bg-red-100":"border-green-300 bg-green-100"}`,children:[e.jsx(Xe,{children:e.jsx(st,{className:"text-base",children:"Net Settlement"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"text-center py-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-2",children:[R.settlementType==="Payable to Dealer"?e.jsx(Go,{className:"w-6 h-6 text-red-600"}):e.jsx(ll,{className:"w-6 h-6 text-green-600"}),e.jsx("span",{className:`text-lg ${R.settlementType==="Payable to Dealer"?"text-red-700":"text-green-700"}`,children:R.settlementType})]}),e.jsxs("div",{className:"text-3xl text-slate-900",children:["₹",R.settlementAmount.toLocaleString()]})]})})]})]})})()})]}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>p(!1),children:"Close"}),(i==null?void 0:i.status)==="Pending Finance Review"&&e.jsx(te,{className:"bg-re-red hover:bg-re-red-hover",onClick:()=>{p(!1),_(i)},children:"Review & Settle"})]})]})})]})}const $o=(...t)=>t.filter(Boolean).join(" ");function kV({applicationId:t,onBack:s}){var E,q,O,R;const[n,r]=g.useState(null),[a,i]=g.useState([]),[o,d]=g.useState("SECURITY_DEPOSIT"),[m,f]=g.useState(!0),[p,h]=g.useState(!1),[x,u]=g.useState({}),[N,v]=g.useState({verificationTransactionId:"",receivedAmount:"",receivedDate:new Date().toISOString().split("T")[0],verificationRemarks:""}),[w,j]=g.useState(!1),[b,C]=g.useState(null),S=a.find(P=>P.depositType===o);g.useEffect(()=>{D()},[t]),g.useEffect(()=>{var P,L,$;if(S)v({verificationTransactionId:S.paymentReference||"",receivedAmount:((P=S.amount)==null?void 0:P.toString())||"",receivedDate:S.verifiedAt?new Date(S.verifiedAt).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],verificationRemarks:S.remarks||""});else{const Z=((L=x.SECURITY_DEPOSIT)==null?void 0:L.amount)||5e5,Q=(($=x.FIRST_FILL)==null?void 0:$.amount)||15e5;v({verificationTransactionId:"",receivedAmount:o==="SECURITY_DEPOSIT"?Z.toString():Q.toString(),receivedDate:new Date().toISOString().split("T")[0],verificationRemarks:""})}},[o,S,x]);const D=async()=>{try{f(!0);const[P,L,$]=await Promise.all([ps.getApplicationById(t),ps.getSecurityDeposit(t),ps.getSystemConfigs({category:"SECURITY_DEPOSIT",format:"map"})]);r(P),i(Array.isArray(L)?L:[L].filter(Boolean)),u($||{})}catch(P){console.error("Fetch error:",P),J.error("Failed to load payment data")}finally{f(!1)}},_=async()=>{if(!N.verificationTransactionId||!N.receivedDate){J.error("Please fill in all required payment details");return}try{h(!0),await ps.updateSecurityDeposit({applicationId:t,depositType:o,amount:Number(N.receivedAmount),paymentReference:N.verificationTransactionId,status:"Verified"}),J.success(`${o==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"} verified and approved`),await D()}catch{J.error("Failed to verify payment")}finally{h(!1)}},A=async()=>{if(!N.verificationRemarks){J.error("Please provide remarks for rejection");return}try{h(!0),await ps.updateSecurityDeposit({applicationId:t,depositType:o,status:"Rejected",remarks:N.verificationRemarks}),J.error(`${o==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"} rejected`),await D()}catch{J.error("Failed to reject payment")}finally{h(!1)}};return m?e.jsx("div",{className:"flex items-center justify-center p-20",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-re-red"})}):n?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(te,{variant:"outline",size:"icon",onClick:s,children:e.jsx(Wr,{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(te,{size:"sm",variant:o==="SECURITY_DEPOSIT"?"default":"outline",className:o==="SECURITY_DEPOSIT"?"bg-re-red hover:bg-re-red-hover":"",onClick:()=>d("SECURITY_DEPOSIT"),children:"Security Deposit"}),e.jsx(te,{size:"sm",variant:o==="FIRST_FILL"?"default":"outline",className:o==="FIRST_FILL"?"bg-re-red hover:bg-re-red-hover":"",onClick:()=>d("FIRST_FILL"),children:"First Fill"})]})]})]}),e.jsx(_e,{className:$o("border",(S==null?void 0:S.status)==="Verified"?"border-green-200 bg-green-50":((S==null?void 0:S.status)==="Rejected","border-red-200 bg-red-50")),children:e.jsx(Oe,{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:$o("w-12 h-12 rounded-full flex items-center justify-center",(S==null?void 0:S.status)==="Verified"?"bg-green-100":(S==null?void 0:S.status)==="Rejected"?"bg-red-100":"bg-red-50"),children:e.jsx(ya,{className:$o("w-6 h-6",(S==null?void 0:S.status)==="Verified"?"text-green-600":(S==null?void 0:S.status)==="Rejected"?"text-red-600":"text-re-red")})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 font-bold",children:o==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"}),e.jsx("p",{className:"text-sm text-slate-600",children:(S==null?void 0:S.status)==="Verified"?`Verified on ${Qt(S.verifiedAt)}`:(S==null?void 0:S.status)==="Rejected"?"Payment Rejected":"Awaiting Verification"})]})]}),e.jsx(we,{className:$o((S==null?void 0:S.status)==="Verified"?"bg-green-600":(S==null?void 0:S.status)==="Rejected"?"bg-red-600":"bg-re-red text-white"),children:(S==null?void 0:S.status)||"No Record"})]})})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs(st,{className:"flex items-center gap-2 text-xl",children:[e.jsx(Rr,{className:"w-5 h-5 text-re-red"}),"Applicant Information"]})}),e.jsxs(Oe,{className:"grid grid-cols-2 gap-y-4 gap-x-8",children:[e.jsxs("div",{children:[e.jsx(le,{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(le,{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(le,{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(le,{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(_e,{children:[e.jsx(Xe,{children:e.jsxs(st,{className:"flex items-center gap-2 text-xl",children:[e.jsx(Wu,{className:"w-5 h-5 text-re-red"}),"Deposit Tracking"]})}),e.jsxs(Oe,{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(le,{className:"text-slate-500 block mb-1",children:"Expected Amount"}),e.jsxs("p",{className:"text-2xl font-bold text-red-900",children:["₹",(o==="SECURITY_DEPOSIT"?((E=x.SECURITY_DEPOSIT)==null?void 0:E.amount)||5e5:((q=x.FIRST_FILL)==null?void 0:q.amount)||15e5).toLocaleString()]})]}),e.jsxs("div",{className:$o("p-4 rounded-lg border",(S==null?void 0:S.status)==="Verified"?"bg-green-50 border-green-200":"bg-blue-50 border-blue-200"),children:[e.jsx(le,{className:"text-slate-500 block mb-1",children:"Receipt Status"}),e.jsx("p",{className:$o("text-2xl font-bold",(S==null?void 0:S.status)==="Verified"?"text-green-700":"text-blue-700"),children:(S==null?void 0:S.status)||"Not Started"})]})]}),(S==null?void 0:S.paymentReference)&&e.jsxs("div",{className:"grid grid-cols-2 gap-4 pt-2",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Payment Reference"}),e.jsx("p",{className:"text-slate-900 font-mono",children:S.paymentReference})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Verified By"}),e.jsx("p",{className:"text-slate-900",children:((O=S.verifier)==null?void 0:O.fullName)||"N/A"})]})]})]})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsxs(st,{className:"flex items-center gap-2 text-xl",children:[e.jsx(ks,{className:"w-5 h-5 text-re-red"}),"Verification Evidence"]}),e.jsx(es,{children:"Documents uploaded by the applicant for payment proof"})]}),e.jsx(Oe,{children:((R=n.uploadedDocuments)==null?void 0:R.filter(P=>{var L,$,Z,Q;return o==="SECURITY_DEPOSIT"?((L=P.documentType)==null?void 0:L.toLowerCase().includes("security"))&&(($=P.documentType)==null?void 0:$.toLowerCase().includes("deposit")):((Z=P.documentType)==null?void 0:Z.toLowerCase().includes("first"))&&((Q=P.documentType)==null?void 0:Q.toLowerCase().includes("fill"))}).length)>0?e.jsx("div",{className:"space-y-3",children:n.uploadedDocuments.filter(P=>{var L,$,Z,Q;return o==="SECURITY_DEPOSIT"?((L=P.documentType)==null?void 0:L.toLowerCase().includes("security"))&&(($=P.documentType)==null?void 0:$.toLowerCase().includes("deposit")):((Z=P.documentType)==null?void 0:Z.toLowerCase().includes("first"))&&((Q=P.documentType)==null?void 0:Q.toLowerCase().includes("fill"))}).map((P,L)=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-white rounded-lg border border-slate-200 hover:shadow-sm transition-shadow",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded bg-slate-100 flex items-center justify-center",children:e.jsx(ks,{className:"w-5 h-5 text-slate-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 font-medium",children:P.fileName||P.name}),e.jsxs("p",{className:"text-xs text-slate-500 uppercase",children:[P.documentType," • ",Qt(P.createdAt)]})]})]}),e.jsx(te,{variant:"ghost",size:"sm",className:"text-re-red hover:text-re-red-hover hover:bg-red-50",onClick:()=>{C(P),j(!0)},children:"View Receipt"})]},L))}):e.jsxs("div",{className:"text-center py-10 bg-slate-50 rounded-lg border-2 border-dashed border-slate-200",children:[e.jsx(sn,{className:"w-8 h-8 text-slate-300 mx-auto mb-2"}),e.jsx("p",{className:"text-slate-500",children:"No payment documents found in this application."})]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(_e,{className:"border-red-100 shadow-sm",children:[e.jsx(Xe,{className:"bg-red-50/50",children:e.jsxs(st,{className:"flex items-center gap-2 text-lg",children:[e.jsx(af,{className:"w-5 h-5 text-re-red"}),"Finance Action"]})}),e.jsxs(Oe,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsxs(le,{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(it,{id:"verificationTxnId",placeholder:"Enter Bank UTR Number",disabled:(S==null?void 0:S.status)==="Verified",className:"mt-1",value:N.verificationTransactionId,onChange:P=>v({...N,verificationTransactionId:P.target.value})})]}),e.jsxs("div",{children:[e.jsxs(le,{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(it,{id:"receivedAmount",type:"number",placeholder:(o==="SECURITY_DEPOSIT"?5e5:15e5).toString(),disabled:(S==null?void 0:S.status)==="Verified",className:"mt-1",value:N.receivedAmount,onChange:P=>v({...N,receivedAmount:P.target.value})})]}),e.jsxs("div",{children:[e.jsxs(le,{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(it,{id:"receivedDate",type:"date",disabled:(S==null?void 0:S.status)==="Verified",className:"mt-1",value:N.receivedDate,onChange:P=>v({...N,receivedDate:P.target.value})})]}),e.jsxs("div",{children:[e.jsx(le,{htmlFor:"remarks",className:"text-xs uppercase text-slate-500 font-bold tracking-wider",children:"Verification Remarks"}),e.jsx(Ks,{id:"remarks",placeholder:"Any internal notes for reconciliation...",rows:3,className:"mt-1",value:N.verificationRemarks,onChange:P=>v({...N,verificationRemarks:P.target.value})})]}),e.jsxs("div",{className:"pt-4 space-y-3",children:[e.jsx(te,{className:$o("w-full transition-all duration-200",(S==null?void 0:S.status)==="Verified"?"bg-green-600 hover:bg-green-600 opacity-90":"bg-re-red hover:bg-re-red-hover"),onClick:_,disabled:p||(S==null?void 0:S.status)==="Verified",children:(S==null?void 0:S.status)==="Verified"?e.jsxs(e.Fragment,{children:[e.jsx(ln,{className:"w-4 h-4 mr-2"})," Verified Successfully"]}):e.jsxs(e.Fragment,{children:[e.jsx(ln,{className:"w-4 h-4 mr-2"})," Mark as Verified"]})}),(S==null?void 0:S.status)!=="Verified"&&(S==null?void 0:S.status)!=="Rejected"&&e.jsxs(te,{variant:"ghost",className:"w-full text-red-600 hover:text-red-700 hover:bg-red-50",onClick:A,disabled:p,children:[e.jsx(ai,{className:"w-4 h-4 mr-2"}),"Reject / Flag Discrepancy"]})]})]})]}),e.jsxs(_e,{className:"bg-slate-900 text-white border-none shadow-xl",children:[e.jsx(Xe,{children:e.jsxs(st,{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(dn,{className:"w-4 h-4 text-re-red"}),"Next Steps"]})}),e.jsxs(Oe,{className:"text-xs text-slate-300 space-y-3",children:[e.jsx("p",{children:"Once verified, the following will occur:"}),e.jsxs("ul",{className:"list-disc pl-4 space-y-2",children:[e.jsxs("li",{children:["Applicant status will advance to ",o==="SECURITY_DEPOSIT"?"LOI Issuance":"LOA Approval"]}),e.jsx("li",{children:"Email notification will be sent to Applicant"}),e.jsxs("li",{children:["Digital ",o==="SECURITY_DEPOSIT"?"LOI":"LOA"," generation will be unlocked"]}),e.jsxs("li",{children:["This payment confirms the ",o==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"]})]})]})]})]})]}),e.jsx(ho,{isOpen:w,onClose:()=>j(!1),document:b})]}):e.jsx("div",{className:"p-20 text-center",children:"Application not found"})}const nl=["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"],LS="[DEPARTMENT_CLAIM]",IS="[FINANCE_VALIDATED]",Yg=[{id:"calculations",label:"Verified All Department Calculations"},{id:"bank",label:"Confirmed Bank Account Details"},{id:"docs",label:"Reviewed All Supporting Documents"},{id:"sap",label:"Synced Final Dues with SAP"},{id:"noc",label:"Received All Mandatory NOCs"}];function DV({fnfId:t,onBack:s}){const[n,r]=g.useState(null),[a,i]=g.useState(!0),[o,d]=g.useState("overview"),[m,f]=g.useState([]),[p,h]=g.useState([]),[x,u]=g.useState([]),[N,v]=g.useState(null),[w,j]=g.useState([]),[b,C]=g.useState(!1),[S,D]=g.useState(null),[_,A]=g.useState([]);g.useEffect(()=>{E(),$()},[t]);const E=async()=>{var ie;try{const fe=(await Re.getSettlementDepartments()).data;fe&&fe.success&&((ie=fe.departments)==null?void 0:ie.length)>0}catch(nt){console.error("Fetch departments error:",nt)}},q=ie=>{if(!ie)return ie;let nt=ie.trim();const fe=nl.find(Ke=>Ke.toLowerCase()===nt.toLowerCase());if(fe)return fe;const Fe={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"}[nt.toLowerCase().replace(" department","")];return Fe||ie},O=(ie,nt)=>nt==="DepartmentClaim"||typeof ie=="string"&&(ie.startsWith(LS)||ie.includes("Clearance:")),R=ie=>(ie==null?void 0:ie.sourceType)==="FinanceValidated"&&typeof(ie==null?void 0:ie.description)=="string"&&ie.description.includes("Auto-seeded from department claim"),P=(ie,nt)=>nt==="FinanceValidated"||typeof ie=="string"&&ie.startsWith(IS),L=ie=>(ie||"").replace(LS,"").replace(IS,"").trim(),$=async(ie=!0)=>{var nt,fe,Ae,Fe,Ke,Le,Ue,et,dt,ss,Wt,kt,wt,Os,as,Se,be,pt,Ve,bt,gt,rs,is,Ts,Ws,nn,Ee,$t,Xt,Cs,Mt,ze,xt,yt,Ot,Pt,Jt,bs,ns,Ds,ts,js,tn,vn,jn,xn,gn;try{ie&&i(!0);const qt=(await Re.getFnFSettlementById(t)).data;if(qt.success){const Ze=qt.fnf,Gt={id:Ze.id,caseNumber:Ze.settlementId||((nt=Ze.resignation)==null?void 0:nt.resignationId)||((fe=Ze.terminationRequest)==null?void 0:fe.requestId)||Ze.id.substring(0,8),dealerName:((Fe=(Ae=Ze.outlet)==null?void 0:Ae.dealer)==null?void 0:Fe.fullName)||((Ke=Ze.dealer)==null?void 0:Ke.fullName)||"N/A",dealerCode:((Le=Ze.outlet)==null?void 0:Le.code)||((et=(Ue=Ze.dealer)==null?void 0:Ue.dealerCode)==null?void 0:et.dealerCode)||"N/A",location:((dt=Ze.outlet)==null?void 0:dt.city)||((ss=Ze.outlet)==null?void 0:ss.location)||"N/A",terminationType:Ze.resignationId?"Resignation":"Termination",submittedDate:xa(Ze.createdAt),createdAt:Ze.createdAt,dueDate:Ze.settlementDate?xa(Ze.settlementDate):"TBD",status:Ze.status,dealerId:((kt=(Wt=Ze.outlet)==null?void 0:Wt.dealer)==null?void 0:kt.id)||Ze.dealerId,originalRequestId:((wt=Ze.resignation)==null?void 0:wt.resignationId)||((Os=Ze.terminationRequest)==null?void 0:Os.requestId)||((as=Ze.terminationRequest)==null?void 0:as.id)||"N/A",salesCode:((be=(Se=Ze.dealer)==null?void 0:Se.dealerCode)==null?void 0:be.salesCode)||((gt=(bt=(Ve=(pt=Ze.outlet)==null?void 0:pt.dealer)==null?void 0:Ve.dealerProfile)==null?void 0:bt.dealerCode)==null?void 0:gt.salesCode)||"N/A",serviceCode:((is=(rs=Ze.dealer)==null?void 0:rs.dealerCode)==null?void 0:is.serviceCode)||((Ee=(nn=(Ws=(Ts=Ze.outlet)==null?void 0:Ts.dealer)==null?void 0:Ws.dealerProfile)==null?void 0:nn.dealerCode)==null?void 0:Ee.serviceCode)||"N/A",gearCode:((Xt=($t=Ze.dealer)==null?void 0:$t.dealerCode)==null?void 0:Xt.gearCode)||((xt=(ze=(Mt=(Cs=Ze.outlet)==null?void 0:Cs.dealer)==null?void 0:Mt.dealerProfile)==null?void 0:ze.dealerCode)==null?void 0:xt.gearCode)||"N/A",gmaCode:((Ot=(yt=Ze.dealer)==null?void 0:yt.dealerCode)==null?void 0:Ot.gmaCode)||((ns=(bs=(Jt=(Pt=Ze.outlet)==null?void 0:Pt.dealer)==null?void 0:Jt.dealerProfile)==null?void 0:bs.dealerCode)==null?void 0:ns.gmaCode)||"N/A",allLineItems:(Ze.lineItems||[]).filter(It=>It.isActive!==!1),departmentResponses:nl.map(It=>{const As=(Ze.clearances||[]).find(Dn=>q(Dn.department)===It),_r=(Ze.lineItems||[]).filter(Dn=>Dn.isActive!==!1),ca=_r.filter(Dn=>q(Dn.department)===It&&O(Dn.description,Dn.sourceType)),Ca=_r.filter(Dn=>q(Dn.department)===It&&R(Dn)),Yr=ca.length>0?ca:Ca;let Nr=0,kn=0;Yr.forEach(Dn=>{const Aa=Math.abs(parseFloat(Dn.amount)||0);Dn.itemType==="Payable"?Nr+=Aa:kn+=Aa});const Sn=Nr-kn,sr=Math.abs(Sn)>0,wr=(As==null?void 0:As.status)||"Pending",Sr=sr?"Dues Pending":wr==="Cleared"?"NOC Submitted":wr,yn=Sn>0?"payable":Sn<0?"recovery":null;return{id:(As==null?void 0:As.id)||`dept-${It}`,departmentName:It,status:Sr,remarks:(As==null?void 0:As.remarks)||"-",submittedDate:As!=null&&As.clearedAt?xa(As.clearedAt):"-",amount:Math.abs(Sn),duesFlow:yn,amountType:Sn>0?"Payable to dealer":Sn<0?"Receivable from dealer":null,supportingDocument:(As==null?void 0:As.supportingDocument)||null}}),documents:[{name:"Resignation Letter.pdf",size:"N/A",uploadedOn:xa(Ze.createdAt),type:"Resignation",url:"#"},...(Ze.clearances||[]).filter(It=>It.supportingDocument).map(It=>({name:It.supportingDocument.split("/").pop(),size:"N/A",uploadedOn:xa(It.clearedAt),type:`${It.department} Proof`,url:It.supportingDocument})),...(Ze.clearanceDocuments||[]).map(It=>{var As;return{name:It.name||((As=It.supportingDocument)==null?void 0:As.split("/").pop())||"Document",size:"N/A",uploadedOn:xa(It.clearedAt||Ze.createdAt),type:"Finance Upload",url:It.supportingDocument}})]};r(Gt);const St=Ze.bankDetails||((Ds=Ze.dealer)==null?void 0:Ds.bankDetails)||((tn=(js=(ts=Ze.outlet)==null?void 0:ts.dealer)==null?void 0:js.dealerProfile)==null?void 0:tn.bankDetails);St&&St.length>0?j(St):((jn=(vn=Ze.outlet)==null?void 0:vn.dealer)!=null&&jn.id||Ze.dealerId)&&Z(((gn=(xn=Ze.outlet)==null?void 0:xn.dealer)==null?void 0:gn.id)||Ze.dealerId);const qn=[],Er=[],Fr=[],wn=(Ze.lineItems||[]).filter(It=>It.isActive!==!1);(wn.some(It=>P(It.description,It.sourceType))?wn.filter(It=>P(It.description,It.sourceType)):wn.filter(It=>!O(It.description,It.sourceType))).forEach(It=>{const As={id:It.id,department:q(It.department),description:L(It.description||It.remarks||""),amount:Math.abs(It.amount)};It.itemType==="Payable"?qn.push(As):It.itemType==="Deduction"?Fr.push(As):Er.push(As)}),f(qn),h(Er),u(Fr),We({verificationTransactionId:Ze.transactionReference||"",settlementAmount:(Ze.settlementAmount||ft().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(Ye){console.error("Fetch F&F error:",Ye),J.error("Failed to fetch settlement details")}finally{ie&&i(!1)}},Z=async ie=>{try{const fe=(await Re.getDealerBankDetails(ie)).data;fe.success&&j(fe.bankDetails||[])}catch(nt){console.error("Fetch bank details error:",nt)}},Q=async ie=>{ie.preventDefault();const nt=new FormData(ie.currentTarget),fe=Object.fromEntries(nt.entries());try{const Ae=n==null?void 0:n.dealerId;(await Re.saveBankDetail(Ae,{...fe,id:S==null?void 0:S.id,isPrimary:nt.get("isPrimary")==="on"})).data.success&&(J.success("Bank details saved"),Z(Ae),C(!1),D(null))}catch{J.error("Failed to save bank details")}},W=async ie=>{if(confirm("Are you sure you want to delete this bank account?"))try{(await Re.deleteBankDetail(ie)).data.success&&(J.success("Bank detail deleted"),Z(n==null?void 0:n.dealerId))}catch{J.error("Failed to delete bank details")}},U=ie=>{A(nt=>nt.includes(ie)?nt.filter(fe=>fe!==ie):[...nt,ie])},[M,z]=g.useState({department:"",description:"",amount:""}),[T,F]=g.useState({department:"",description:"",amount:""}),[I,K]=g.useState({department:"",description:"",amount:""}),[G,V]=g.useState(null),[Y,re]=g.useState(null),[ae,ue]=g.useState(null),[ye,ce]=g.useState({}),[je,Me]=g.useState({}),[ut,jt]=g.useState({}),ft=()=>{const ie=m.reduce((Fe,Ke)=>Fe+(Number(Ke.amount)||0),0),nt=p.reduce((Fe,Ke)=>Fe+(Number(Ke.amount)||0),0),fe=x.reduce((Fe,Ke)=>Fe+(Number(Ke.amount)||0),0),Ae=ie-nt-fe;return{payables:ie,receivables:nt,deductions:fe,netSettlement:Ae,settlementAmount:Math.abs(Ae),settlementType:Ae>0?"Payable to Dealer":Ae<0?"Receivable from Dealer":"No Settlement Required"}},X=ft(),Ce=nl.map(ie=>{const nt=((n==null?void 0:n.departmentResponses)||[]).find(Wt=>Wt.departmentName===ie),fe=Number(nt==null?void 0:nt.amount)||0,Ae=(nt==null?void 0:nt.amountType)||"-",Fe=m.filter(Wt=>q(Wt.department)===ie).reduce((Wt,kt)=>Wt+(Number(kt.amount)||0),0),Ke=p.filter(Wt=>q(Wt.department)===ie).reduce((Wt,kt)=>Wt+(Number(kt.amount)||0),0),Le=x.filter(Wt=>q(Wt.department)===ie).reduce((Wt,kt)=>Wt+(Number(kt.amount)||0),0),Ue=Fe-Ke-Le,et=Math.abs(Ue),dt=Ue>0?"Payable":Ue<0?"Receivable":"-",ss=et-fe;return{department:ie,claimAmount:fe,claimType:Ae,validatedAmount:et,validatedType:dt,variance:ss}}),[xe,We]=g.useState({verificationTransactionId:"",settlementAmount:X.settlementAmount.toString(),settlementDate:new Date().toISOString().split("T")[0],paymentMode:"",bankReference:"",verificationRemarks:"",adjustments:"0"}),Be=async()=>{var ie,nt;if(!M.department||!M.description||!M.amount){J.error("Please fill in all fields");return}try{const Ae=(await Re.addLineItem(t,{department:M.department,description:M.description,amount:Math.abs(parseFloat(M.amount)),itemType:"Payable"})).data;Ae.success&&(f([...m,{id:Ae.lineItem.id,department:Ae.lineItem.department,description:Ae.lineItem.description,amount:Math.abs(Ae.lineItem.amount)}]),z({department:"",description:"",amount:""}),J.success("Payable item added"),$())}catch(fe){J.error(((nt=(ie=fe.response)==null?void 0:ie.data)==null?void 0:nt.message)||"Failed to add payable item")}},rt=async(ie,nt,fe)=>{ce(Ae=>{const Fe=Ae[ie]||m.find(Ke=>Ke.id===ie);return Fe?{...Ae,[ie]:{...Fe,[nt]:nt==="amount"?Number(fe)||0:fe}}:Ae})},ht=async ie=>{var fe,Ae;const nt=ye[ie];if(!nt){V(null);return}f(Fe=>Fe.map(Ke=>Ke.id===ie?nt:Ke));try{await Re.updateLineItem(ie,{department:nt.department,description:nt.description,amount:-Math.abs(Number(nt.amount)||0)}),V(null),ce(Fe=>{const Ke={...Fe};return delete Ke[ie],Ke}),J.success("Changes saved"),$(!1)}catch(Fe){J.error(((Ae=(fe=Fe.response)==null?void 0:fe.data)==null?void 0:Ae.message)||"Failed to update item"),$(!1)}},ge=async ie=>{var nt,fe;try{(await Re.deleteLineItem(ie)).data.success&&(f(m.filter(Ke=>Ke.id!==ie)),J.info("Payable item removed"),$())}catch(Ae){J.error(((fe=(nt=Ae.response)==null?void 0:nt.data)==null?void 0:fe.message)||"Failed to delete item")}},Je=async()=>{var ie,nt;if(!T.department||!T.description||!T.amount){J.error("Please fill in all fields");return}try{const Ae=(await Re.addLineItem(t,{department:T.department,description:T.description,amount:Math.abs(parseFloat(T.amount)),itemType:"Receivable"})).data;Ae.success&&(h([...p,{id:Ae.lineItem.id,department:Ae.lineItem.department,description:Ae.lineItem.description,amount:Ae.lineItem.amount}]),F({department:"",description:"",amount:""}),J.success("Receivable item added"),$())}catch(fe){J.error(((nt=(ie=fe.response)==null?void 0:ie.data)==null?void 0:nt.message)||"Failed to add receivable item")}},mt=async(ie,nt,fe)=>{Me(Ae=>{const Fe=Ae[ie]||p.find(Ke=>Ke.id===ie);return Fe?{...Ae,[ie]:{...Fe,[nt]:nt==="amount"?Number(fe)||0:fe}}:Ae})},de=async ie=>{var fe,Ae;const nt=je[ie];if(!nt){re(null);return}h(Fe=>Fe.map(Ke=>Ke.id===ie?nt:Ke));try{await Re.updateLineItem(ie,{department:nt.department,description:nt.description,amount:Math.abs(Number(nt.amount)||0)}),re(null),Me(Fe=>{const Ke={...Fe};return delete Ke[ie],Ke}),J.success("Changes saved"),$(!1)}catch(Fe){J.error(((Ae=(fe=Fe.response)==null?void 0:fe.data)==null?void 0:Ae.message)||"Failed to update item"),$(!1)}},at=async ie=>{var nt,fe;try{await Re.deleteLineItem(ie),h(p.filter(Ae=>Ae.id!==ie)),J.info("Receivable item removed"),$()}catch(Ae){J.error(((fe=(nt=Ae.response)==null?void 0:nt.data)==null?void 0:fe.message)||"Failed to delete item")}},ot=async()=>{var ie,nt;if(!I.department||!I.description||!I.amount){J.error("Please fill in all fields");return}try{const Ae=(await Re.addLineItem(t,{department:I.department,description:I.description,amount:Math.abs(parseFloat(I.amount)),itemType:"Deduction"})).data;Ae.success&&(u([...x,{id:Ae.lineItem.id,department:Ae.lineItem.department,description:Ae.lineItem.description,amount:Ae.lineItem.amount}]),K({department:"",description:"",amount:""}),J.success("Deduction item added"),$())}catch(fe){J.error(((nt=(ie=fe.response)==null?void 0:ie.data)==null?void 0:nt.message)||"Failed to add deduction item")}},ke=async(ie,nt,fe)=>{jt(Ae=>{const Fe=Ae[ie]||x.find(Ke=>Ke.id===ie);return Fe?{...Ae,[ie]:{...Fe,[nt]:nt==="amount"?Number(fe)||0:fe}}:Ae})},Zt=async ie=>{var fe,Ae;const nt=ut[ie];if(!nt){ue(null);return}u(Fe=>Fe.map(Ke=>Ke.id===ie?nt:Ke));try{await Re.updateLineItem(ie,{department:nt.department,description:nt.description,amount:Math.abs(Number(nt.amount)||0)}),ue(null),jt(Fe=>{const Ke={...Fe};return delete Ke[ie],Ke}),J.success("Changes saved"),$(!1)}catch(Fe){J.error(((Ae=(fe=Fe.response)==null?void 0:fe.data)==null?void 0:Ae.message)||"Failed to update item"),$(!1)}},Bt=async ie=>{try{await Re.deleteLineItem(ie),u(x.filter(nt=>nt.id!==ie)),J.info("Deduction item removed"),$()}catch{J.error("Failed to delete item")}},_s=async ie=>{var fe;const nt=ie.target.files;if(nt&&nt.length>0){i(!0);try{let Ae=0;for(let Fe=0;Fe{if(!xe.verificationTransactionId||!xe.settlementDate||!xe.paymentMode){J.error("Please fill in all required settlement details");return}try{fs(!0);const ie=(X.settlementAmount||0)+parseFloat(xe.adjustments||"0");await RE.updateFnF(t,{status:"Completed",finalSettlementAmount:ie,settlementDate:xe.settlementDate,paymentMode:xe.paymentMode,transactionReference:xe.verificationTransactionId,remarks:xe.verificationRemarks||"Approved by Finance"}),J.success(`F&F Settlement approved and completed for ${n.dealerName}`),setTimeout(()=>s(),1500)}catch(ie){console.error("Approve settlement error:",ie),J.error(ie.message||"Failed to approve settlement")}finally{fs(!1)}},Qs=()=>{if(!xe.verificationRemarks){J.error("Please provide remarks for rejection");return}J.error(`F&F Settlement rejected for ${n.dealerName}`),setTimeout(()=>s(),1500)},Xs=()=>{if(!xe.verificationRemarks){J.error("Please provide details for clarification request");return}J.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(cs,{className:"w-8 h-8 animate-spin text-re-red"})}):n?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(te,{variant:"outline",size:"icon",onClick:s,children:e.jsx(Wr,{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(_e,{className:"border-red-200 bg-red-50",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-12 shrink-0 aspect-square rounded-full bg-red-50 flex items-center justify-center",children:e.jsx(ya,{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(we,{className:"bg-re-red",children:n.status}),e.jsx(we,{variant:n.terminationType==="Resignation"?"default":"secondary",children:n.terminationType})]})]})})}),e.jsx(_e,{className:`${X.settlementType==="Payable to Dealer"?"border-red-300 bg-red-50":X.settlementType==="Receivable from Dealer"?"border-green-300 bg-green-50":"border-slate-300 bg-slate-50"}`,children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[X.settlementType==="Payable to Dealer"?e.jsx(Go,{className:"w-12 h-12 text-red-600"}):X.settlementType==="Receivable from Dealer"?e.jsx(ll,{className:"w-12 h-12 text-green-600"}):e.jsx(ln,{className:"w-12 h-12 text-slate-600"}),e.jsxs("div",{children:[e.jsx("p",{className:`text-sm ${X.settlementType==="Payable to Dealer"?"text-red-700":X.settlementType==="Receivable from Dealer"?"text-green-700":"text-slate-700"}`,children:X.settlementType}),e.jsx("p",{className:"text-3xl text-slate-900",children:X.settlementType==="No Settlement Required"?"₹0":`₹${X.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:X.settlementType==="Payable to Dealer"?"Company will pay to dealer":X.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(In,{value:o,onValueChange:d,className:"w-full",children:[e.jsxs(Mn,{className:"grid w-full grid-cols-5",children:[e.jsx(Ht,{value:"overview",children:"Overview"}),e.jsx(Ht,{value:"financial",children:"Financial"}),e.jsx(Ht,{value:"departments",children:"Departments"}),e.jsx(Ht,{value:"documents",children:"Documents"}),e.jsx(Ht,{value:"bank",children:"Bank Details"})]}),e.jsxs(Vt,{value:"overview",className:"space-y-4",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(Rr,{className:"w-5 h-5"}),"Case Information"]})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Case Number"}),e.jsx("p",{className:"text-slate-900",children:n.caseNumber})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Dealer Code"}),e.jsx("p",{className:"text-slate-900",children:n.dealerCode})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Dealer Name"}),e.jsx("p",{className:"text-slate-900",children:n.dealerName})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Location"}),e.jsx("p",{className:"text-slate-900",children:n.location})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Termination Type"}),e.jsx(we,{variant:n.terminationType==="Resignation"?"default":"secondary",children:n.terminationType})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Status"}),e.jsx(we,{className:"bg-re-red",children:n.status})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Submitted Date"}),e.jsx("p",{className:"text-slate-900",children:n.submittedDate})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Due Date"}),e.jsx("p",{className:"text-slate-900",children:n.dueDate})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Request Age"}),e.jsx("p",{className:"text-slate-900",children:(()=>{const ie=new Date(n.createdAt),fe=Math.abs(new Date().getTime()-ie.getTime()),Ae=Math.ceil(fe/(1e3*60*60*24));return`${Ae} day${Ae!==1?"s":""}`})()})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Sales Code"}),e.jsx("p",{className:"text-slate-900",children:n.salesCode})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Service Code"}),e.jsx("p",{className:"text-slate-900",children:n.serviceCode})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Gear Code"}),e.jsx("p",{className:"text-slate-900",children:n.gearCode})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"GMA Code"}),e.jsx("p",{className:"text-slate-900",children:n.gmaCode})]})]})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(ya,{className:"w-5 h-5"}),"Settlement Calculation Summary"]})}),e.jsxs(Oe,{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:["+ ₹",X.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:["- ₹",X.receivables.toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-red-50 rounded-lg",children:[e.jsx("span",{className:"text-slate-900",children:"Total Deductions"}),e.jsxs("span",{className:"text-re-red-hover text-lg",children:["- ₹",X.deductions.toLocaleString("en-IN")]})]})]}),e.jsx("div",{className:"h-px bg-slate-300"}),e.jsx("div",{className:`p-4 rounded-lg border-2 ${X.settlementType==="Payable to Dealer"?"bg-red-100 border-red-300":X.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 ${X.settlementType==="Payable to Dealer"?"text-red-700":X.settlementType==="Receivable from Dealer"?"text-green-700":"text-slate-700"}`,children:X.settlementType})]}),e.jsx("span",{className:"text-2xl text-slate-900",children:X.settlementType==="No Settlement Required"?"₹0":`₹${X.settlementAmount.toLocaleString("en-IN")}`})]})}),e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-blue-50 border border-red-200 rounded-lg",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-900 mb-1",children:"Calculation Formula"}),e.jsxs("p",{className:"text-sm text-slate-600",children:["Net Settlement = Payables - Receivables - Deductions",e.jsx("br",{}),e.jsx("span",{className:"text-xs",children:"All amounts are editable in the Financial tab"})]})]})]})]})]})]}),e.jsxs(Vt,{value:"financial",className:"space-y-4",children:[e.jsxs(_e,{className:"border-blue-200 bg-blue-50",children:[e.jsxs(Xe,{children:[e.jsx(st,{className:"text-base",children:"Department Claim vs Finance Validation"}),e.jsx(es,{children:"Finance validated values are used for final settlement totals."})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:Ce.map(ie=>e.jsxs(lt,{children:[e.jsx(oe,{children:ie.department}),e.jsx(oe,{children:ie.claimAmount>0?`${ie.claimType} ₹${ie.claimAmount.toLocaleString("en-IN")}`:"-"}),e.jsx(oe,{children:ie.validatedAmount>0?`${ie.validatedType} ₹${ie.validatedAmount.toLocaleString("en-IN")}`:"-"}),e.jsx(oe,{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(_e,{className:"border-green-200 bg-green-50",children:[e.jsx(Xe,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(af,{className:"w-5 h-5 text-green-600"}),"Payables to Dealer (Editable)"]}),e.jsx(es,{children:"Add or modify amounts company owes to dealer"})]})})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:m.map(ie=>{var nt,fe,Ae;return e.jsxs(lt,{children:[e.jsx(oe,{children:G===ie.id?e.jsxs(Rt,{value:((nt=ye[ie.id])==null?void 0:nt.department)||ie.department,onValueChange:Fe=>rt(ie.id,"department",Fe),children:[e.jsx(_t,{className:"h-8",children:e.jsx(Et,{placeholder:"Department"})}),e.jsx(Tt,{children:nl.map(Fe=>e.jsx(Pe,{value:Fe,children:Fe},Fe))})]}):e.jsx("span",{className:"text-slate-900",children:q(ie.department)})}),e.jsx(oe,{children:G===ie.id?e.jsx(it,{value:((fe=ye[ie.id])==null?void 0:fe.description)||ie.description,onChange:Fe=>rt(ie.id,"description",Fe.target.value),className:"h-8"}):e.jsx("span",{className:"text-slate-600",children:ie.description})}),e.jsx(oe,{className:"text-right",children:G===ie.id?e.jsx(it,{type:"number",value:((Ae=ye[ie.id])==null?void 0:Ae.amount)??ie.amount,onChange:Fe=>rt(ie.id,"amount",Fe.target.value),className:"h-8 text-right"}):e.jsxs("span",{className:"text-slate-900",children:["₹",ie.amount.toLocaleString("en-IN")]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex gap-1",children:[G===ie.id?e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>ht(ie.id),children:e.jsx(dl,{className:"w-4 h-4"})}):e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>{V(ie.id),ce(Fe=>({...Fe,[ie.id]:{...ie}}))},children:e.jsx(gr,{className:"w-4 h-4"})}),e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8 text-red-600 hover:text-red-700",onClick:()=>ge(ie.id),children:e.jsx(Zn,{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(Rt,{value:M.department,onValueChange:ie=>z({...M,department:ie}),children:[e.jsx(_t,{className:"col-span-3",children:e.jsx(Et,{placeholder:"Department"})}),e.jsx(Tt,{children:nl.map(ie=>e.jsx(Pe,{value:ie,children:ie},ie))})]}),e.jsx(it,{placeholder:"Description",value:M.description,onChange:ie=>z({...M,description:ie.target.value}),className:"col-span-5"}),e.jsx(it,{type:"number",placeholder:"Amount",value:M.amount,onChange:ie=>z({...M,amount:ie.target.value}),className:"col-span-3"}),e.jsx(te,{onClick:Be,className:"col-span-1 bg-green-600 hover:bg-green-700",children:e.jsx(bn,{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:["₹",X.payables.toLocaleString("en-IN")]})]})})]})]}),e.jsxs(_e,{className:"border-red-200 bg-red-50",children:[e.jsx(Xe,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(ay,{className:"w-5 h-5 text-red-600"}),"Receivables from Dealer (Editable)"]}),e.jsx(es,{children:"Add or modify amounts dealer owes to company"})]})})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:p.map(ie=>{var nt,fe,Ae;return e.jsxs(lt,{children:[e.jsx(oe,{children:Y===ie.id?e.jsxs(Rt,{value:((nt=je[ie.id])==null?void 0:nt.department)||ie.department,onValueChange:Fe=>mt(ie.id,"department",Fe),children:[e.jsx(_t,{className:"h-8",children:e.jsx(Et,{placeholder:"Department"})}),e.jsx(Tt,{children:nl.map(Fe=>e.jsx(Pe,{value:Fe,children:Fe},Fe))})]}):e.jsx("span",{className:"text-slate-900",children:q(ie.department)})}),e.jsx(oe,{children:Y===ie.id?e.jsx(it,{value:((fe=je[ie.id])==null?void 0:fe.description)||ie.description,onChange:Fe=>mt(ie.id,"description",Fe.target.value),className:"h-8"}):e.jsx("span",{className:"text-slate-600",children:ie.description})}),e.jsx(oe,{className:"text-right",children:Y===ie.id?e.jsx(it,{type:"number",value:((Ae=je[ie.id])==null?void 0:Ae.amount)??ie.amount,onChange:Fe=>mt(ie.id,"amount",Fe.target.value),className:"h-8 text-right"}):e.jsxs("span",{className:"text-slate-900",children:["₹",ie.amount.toLocaleString("en-IN")]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex gap-1",children:[Y===ie.id?e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>de(ie.id),children:e.jsx(dl,{className:"w-4 h-4"})}):e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>{re(ie.id),Me(Fe=>({...Fe,[ie.id]:{...ie}}))},children:e.jsx(gr,{className:"w-4 h-4"})}),e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8 text-red-600 hover:text-red-700",onClick:()=>at(ie.id),children:e.jsx(Zn,{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(Rt,{value:T.department,onValueChange:ie=>F({...T,department:ie}),children:[e.jsx(_t,{className:"col-span-3",children:e.jsx(Et,{placeholder:"Department"})}),e.jsx(Tt,{children:nl.map(ie=>e.jsx(Pe,{value:ie,children:ie},ie))})]}),e.jsx(it,{placeholder:"Description",value:T.description,onChange:ie=>F({...T,description:ie.target.value}),className:"col-span-5"}),e.jsx(it,{type:"number",placeholder:"Amount",value:T.amount,onChange:ie=>F({...T,amount:ie.target.value}),className:"col-span-3"}),e.jsx(te,{onClick:Je,className:"col-span-1 bg-red-600 hover:bg-red-700",children:e.jsx(bn,{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:["₹",X.receivables.toLocaleString("en-IN")]})]})})]})]}),e.jsxs(_e,{className:"border-red-200 bg-red-50",children:[e.jsx(Xe,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red"}),"Deductions (Editable)"]}),e.jsx(es,{children:"Add or modify pending claims and deductions"})]})})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:x.map(ie=>{var nt,fe,Ae;return e.jsxs(lt,{children:[e.jsx(oe,{children:ae===ie.id?e.jsxs(Rt,{value:((nt=ut[ie.id])==null?void 0:nt.department)||ie.department,onValueChange:Fe=>ke(ie.id,"department",Fe),children:[e.jsx(_t,{className:"h-8",children:e.jsx(Et,{placeholder:"Department"})}),e.jsx(Tt,{children:nl.map(Fe=>e.jsx(Pe,{value:Fe,children:Fe},Fe))})]}):e.jsx("span",{className:"text-slate-900",children:q(ie.department)})}),e.jsx(oe,{children:ae===ie.id?e.jsx(it,{value:((fe=ut[ie.id])==null?void 0:fe.description)||ie.description,onChange:Fe=>ke(ie.id,"description",Fe.target.value),className:"h-8"}):e.jsx("span",{className:"text-slate-600",children:ie.description})}),e.jsx(oe,{className:"text-right",children:ae===ie.id?e.jsx(it,{type:"number",value:((Ae=ut[ie.id])==null?void 0:Ae.amount)??ie.amount,onChange:Fe=>ke(ie.id,"amount",Fe.target.value),className:"h-8 text-right"}):e.jsxs("span",{className:"text-slate-900",children:["₹",ie.amount.toLocaleString("en-IN")]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex gap-1",children:[ae===ie.id?e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Zt(ie.id),children:e.jsx(dl,{className:"w-4 h-4"})}):e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>{ue(ie.id),jt(Fe=>({...Fe,[ie.id]:{...ie}}))},children:e.jsx(gr,{className:"w-4 h-4"})}),e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8 text-red-600 hover:text-red-700",onClick:()=>Bt(ie.id),children:e.jsx(Zn,{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 Deduction Item:"}),e.jsxs("div",{className:"grid grid-cols-12 gap-2",children:[e.jsxs(Rt,{value:I.department,onValueChange:ie=>K({...I,department:ie}),children:[e.jsx(_t,{className:"col-span-3",children:e.jsx(Et,{placeholder:"Department"})}),e.jsx(Tt,{children:nl.map(ie=>e.jsx(Pe,{value:ie,children:ie},ie))})]}),e.jsx(it,{placeholder:"Description",value:I.description,onChange:ie=>K({...I,description:ie.target.value}),className:"col-span-5"}),e.jsx(it,{type:"number",placeholder:"Amount",value:I.amount,onChange:ie=>K({...I,amount:ie.target.value}),className:"col-span-3"}),e.jsx(te,{onClick:ot,className:"col-span-1 bg-re-red hover:bg-re-red-hover",children:e.jsx(bn,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"pt-3 border-t-2 border-red-300",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-900",children:"Total Deductions"}),e.jsxs("span",{className:"text-re-red-hover text-xl",children:["₹",X.deductions.toLocaleString("en-IN")]})]})})]})]}),e.jsxs(_e,{className:"border-2 border-blue-300 bg-blue-50",children:[e.jsx(Xe,{children:e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(ln,{className:"w-5 h-5 text-re-red"}),"Final Settlement Summary"]})}),e.jsxs(Oe,{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:["+ ₹",X.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:["- ₹",X.receivables.toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-white rounded-lg",children:[e.jsx("span",{className:"text-slate-900",children:"Total Deductions"}),e.jsxs("span",{className:"text-re-red-hover text-lg",children:["- ₹",X.deductions.toLocaleString("en-IN")]})]})]}),e.jsx("div",{className:"h-px bg-blue-300"}),e.jsx("div",{className:`p-4 rounded-lg border-2 ${X.settlementType==="Payable to Dealer"?"bg-red-100 border-red-400":X.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 ${X.settlementType==="Payable to Dealer"?"text-red-700":X.settlementType==="Receivable from Dealer"?"text-green-700":"text-slate-700"}`,children:X.settlementType})]}),e.jsx("span",{className:"text-3xl text-slate-900",children:X.settlementType==="No Settlement Required"?"₹0":`₹${X.settlementAmount.toLocaleString("en-IN")}`})]})}),e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-white border border-red-200 rounded-lg",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-900 mb-1",children:"Calculation Formula"}),e.jsxs("p",{className:"text-sm text-slate-600",children:["Net Settlement = Payables - Receivables - Deductions",e.jsx("br",{}),X.netSettlement>0&&"Positive value means company pays to dealer",X.netSettlement<0&&"Negative value means dealer pays to company",X.netSettlement===0&&"Zero means no payment required from either party"]})]})]})]})]})]}),e.jsxs(Vt,{value:"departments",className:"space-y-4",children:[e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(ja,{className:"w-5 h-5"}),"Department Response Progress"]}),e.jsxs(es,{children:[n.departmentResponses.filter(ie=>ie.status!=="Pending").length," of ",n.departmentResponses.length," departments have responded"]})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(oc,{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(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"All Department Responses"}),e.jsx(es,{children:"Status of NOC and dues clearance from all 16 departments (read-only for Finance; updates are done by department stakeholders)."})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:n.departmentResponses.map(ie=>e.jsxs(lt,{className:ie.duesFlow==="recovery"?"bg-red-50/40":ie.duesFlow==="payable"?"bg-emerald-50/40":"",children:[e.jsx(oe,{children:ie.departmentName}),e.jsx(oe,{children:e.jsx(we,{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(oe,{children:ie.amountType?e.jsx(we,{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(oe,{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(oe,{children:ie.submittedDate||"-"}),e.jsx(oe,{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:()=>v({fileName:`${ie.departmentName}_Proof`,filePath:ie.supportingDocument,documentType:"Departmental Clearance Proof"}),className:"flex items-center gap-1 text-[10px] text-re-red hover:underline",children:[e.jsx(bu,{className:"w-3 h-3"}),"View Proof"]})]})})]},ie.id))})]})})]}),e.jsx(_e,{className:"bg-blue-50 border-red-200",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-900 mb-1",children:"Department Response Guidelines"}),e.jsxs("ul",{className:"text-sm text-slate-700 space-y-1",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{children:"NOC Submitted:"})," Department has no outstanding dues and provided clearance"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Dues Pending:"})," Department has identified amounts to be recovered or paid"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Pending:"})," Department has not yet responded to the F&F request"]})]})]})]})})})]}),e.jsxs(Vt,{value:"documents",className:"space-y-4",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"w-5 h-5"}),"Submitted Documents"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:n.documents.map((ie,nt)=>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(ks,{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:()=>v({fileName:ie.name,filePath:ie.url,documentType:ie.type}),className:"text-re-red hover:text-re-red-hover text-[10px] font-semibold flex items-center gap-1",children:[e.jsx(bu,{className:"w-3 h-3"})," PREVIEW"]}),e.jsx(te,{variant:"outline",size:"sm",onClick:async()=>{if(ie.url&&ie.url!=="#")try{const Ae=await(await fetch(ie.url)).blob(),Fe=window.URL.createObjectURL(Ae),Ke=document.createElement("a");Ke.href=Fe,Ke.download=ie.name||"download",document.body.appendChild(Ke),Ke.click(),document.body.removeChild(Ke),window.URL.revokeObjectURL(Fe)}catch{const Ae=document.createElement("a");Ae.href=ie.url,Ae.download=ie.name||"download",document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae)}else J.error("Document URL not available")},children:"Download"})]})]},nt))})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(vr,{className:"w-5 h-5"}),"Upload Settlement Verification Documents"]}),e.jsx(es,{children:"Upload bank receipts, settlement proofs, or any additional documents"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"border-2 border-dashed border-slate-300 rounded-lg p-8 text-center hover:border-red-300 hover:bg-red-50 transition-colors",children:[e.jsx(vr,{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:_s,accept:".pdf,.doc,.docx,.png,.jpg,.jpeg,.xlsx,.xls"}),e.jsx("label",{htmlFor:"file-upload",children:e.jsx(te,{variant:"outline",className:"mt-4",asChild:!0,children:e.jsx("span",{children:"Choose Files"})})})]})})})]})]}),e.jsx(Vt,{value:"bank",className:"space-y-4",children:e.jsxs(_e,{children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(ad,{className:"w-5 h-5"}),"Dealer Bank Account Details"]}),e.jsx(es,{children:"Manage bank accounts for settlement transfer"})]}),e.jsxs(te,{size:"sm",className:"bg-re-red",onClick:()=>{D(null),C(!0)},children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add Bank Account"]})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:w.length>0?w.map(ie=>e.jsxs(_e,{className:`relative ${ie.isPrimary?"border-re-red bg-blue-50/30":""}`,children:[ie.isPrimary&&e.jsx("div",{className:"absolute top-0 right-0 p-1 bg-re-red text-white text-[10px] uppercase font-bold px-2 rounded-bl",children:"Primary"}),e.jsx(Oe,{className:"p-4 pt-6",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(le,{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(le,{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(le,{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(le,{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(te,{variant:"ghost",size:"sm",className:"h-7 text-[11px] text-re-red",onClick:()=>{D(ie),C(!0)},children:[e.jsx(gr,{className:"w-3 h-3 mr-1"}),"Edit"]}),e.jsxs(te,{variant:"ghost",size:"sm",className:"h-7 text-[11px] text-red-600",onClick:()=>W(ie.id),children:[e.jsx(Zn,{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(ad,{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(_e,{className:"sticky top-6",children:[e.jsxs(Xe,{children:[e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(Wu,{className:"w-5 h-5"}),"Settlement Verification"]}),e.jsx(es,{children:"Enter settlement transaction details"})]}),e.jsx(Oe,{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(ln,{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:xa(xe.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:xe.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:xe.verificationTransactionId,children:xe.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(xe.settlementAmount).toLocaleString()]})]})]}),xe.verificationRemarks&&e.jsxs("div",{className:"mt-4",children:[e.jsx(le,{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:xe.verificationRemarks})]}),e.jsxs(te,{variant:"outline",className:"w-full mt-4",onClick:()=>window.print(),children:[e.jsx(MI,{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(ln,{className:"w-4 h-4 text-re-red"}),"Compliance Checklist"]}),e.jsx("div",{className:"space-y-3",children:Yg.map(ie=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("input",{type:"checkbox",id:`check-${ie.id}`,checked:_.includes(ie.id),onChange:()=>U(ie.id),className:"w-4 h-4 mt-1 rounded border-slate-300 text-re-red focus:ring-re-red"}),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(le,{htmlFor:"paymentMode",children:["Payment Mode ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{id:"paymentMode",placeholder:"e.g., NEFT, RTGS, Cheque",value:xe.paymentMode,onChange:ie=>We({...xe,paymentMode:ie.target.value})})]}),e.jsxs("div",{children:[e.jsxs(le,{htmlFor:"verificationTxnId",children:["Transaction ID / Reference ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{id:"verificationTxnId",placeholder:"Enter transaction reference",value:xe.verificationTransactionId,onChange:ie=>We({...xe,verificationTransactionId:ie.target.value})})]}),e.jsxs("div",{children:[e.jsx(le,{htmlFor:"bankReference",children:"Bank Reference Number"}),e.jsx(it,{id:"bankReference",placeholder:"Enter bank reference",value:xe.bankReference,onChange:ie=>We({...xe,bankReference:ie.target.value})})]}),e.jsxs("div",{children:[e.jsxs(le,{htmlFor:"settlementAmount",children:["Settlement Amount (₹) ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{id:"settlementAmount",type:"number",placeholder:"Enter settlement amount",value:xe.settlementAmount,onChange:ie=>We({...xe,settlementAmount:ie.target.value})})]}),e.jsxs("div",{children:[e.jsx(le,{htmlFor:"adjustments",children:"Adjustments (₹)"}),e.jsx(it,{id:"adjustments",type:"number",placeholder:"Enter any adjustments",value:xe.adjustments,onChange:ie=>{const nt=ie.target.value,fe=X.settlementAmount+parseFloat(nt||"0");We({...xe,adjustments:nt,settlementAmount:fe.toString()})}}),parseFloat(xe.adjustments)!==0&&e.jsxs("p",{className:"text-sm text-re-red mt-1 flex items-center gap-1",children:[e.jsx(sn,{className:"w-3 h-3"}),"Adjusted amount: ₹",xe.settlementAmount]})]}),e.jsxs("div",{children:[e.jsxs(le,{htmlFor:"settlementDate",children:["Settlement Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{id:"settlementDate",type:"date",value:xe.settlementDate,onChange:ie=>We({...xe,settlementDate:ie.target.value})})]}),e.jsxs("div",{children:[e.jsx(le,{htmlFor:"verificationRemarks",children:"Verification Remarks"}),e.jsx(Ks,{id:"verificationRemarks",placeholder:"Enter any remarks or notes...",rows:4,value:xe.verificationRemarks,onChange:ie=>We({...xe,verificationRemarks:ie.target.value})})]}),e.jsxs("div",{className:"pt-4 space-y-3 border-t",children:[e.jsxs(te,{className:"w-full bg-green-600 hover:bg-green-700",onClick:Vs,disabled:Us||_.length{C(!1),D(null)},onSubmit:Q,editingBank:S,isSubmitting:!1}),e.jsx(ho,{isOpen:!!N,onClose:()=>v(null),document:N})]}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx("p",{children:"Settlement case not found"}),e.jsx(te,{onClick:s,className:"mt-4",children:"Go Back"})]})}const RV=()=>{const t=Lu(),s=g.useCallback(async()=>{try{t(l1(!0));const[r,a,i,o,d,m,f,p,h,x,u,N,v]=await Promise.all([$s.getRoles().catch(()=>({success:!1})),$s.getZones().catch(()=>({success:!1})),$s.getPermissions().catch(()=>({success:!1})),$s.getRegions().catch(()=>({success:!1})),$s.getUsers().catch(()=>({success:!1})),$s.getStates().catch(()=>({success:!1})),$s.getEmailTemplates().catch(()=>({success:!1})),$s.getDistricts({limit:"all"}).catch(()=>({success:!1})),$s.getAreas({limit:"all"}).catch(()=>({success:!1})),$s.getSlaConfigs().catch(()=>({success:!1})),$s.getASMs().catch(()=>({success:!1})),$s.getZonalManagers().catch(()=>({success:!1})),$s.getDDLeads().catch(()=>({success:!1}))]),w=V=>V.success?V:V.data?V.data:V,j=w(r),b=w(a),C=w(i),S=w(o),D=w(d),_=w(m),A=w(f),E=w(p),q=w(h),O=w(x),R=w(u),P=w(N),L=w(v),$=((D==null?void 0:D.users)||(D==null?void 0:D.data)||[]).map(V=>{var ce;const Y=Array.isArray(V.territoryProfile)?V.territoryProfile:[],re=Y.filter(je=>String(je.locationType||"").toLowerCase()==="zone").map(je=>je.locationName||je.zone).filter(Boolean),ae=Y.filter(je=>String(je.locationType||"").toLowerCase()==="region").map(je=>je.locationName||je.region).filter(Boolean),ue=Array.from(new Set([...V.allZones||[],...re])),ye=Array.from(new Set([...V.allRegions||[],...ae]));return{...V,name:V.fullName||V.name,role:((ce=V.role)==null?void 0:ce.roleName)||(Array.isArray(V.allRoles)&&V.allRoles.length>0?V.allRoles[0]:"System User"),zone:ue.length>0?ue.join(", "):"Global",region:ye.length>0?ye.join(", "):"Unassigned",status:V.isActive!==!1?"Active":"Inactive"}}),Z=((j==null?void 0:j.roles)||(j==null?void 0:j.data)||[]).map(V=>{var Y;return{id:V.id,name:V.roleName,permissions:((Y=V.permissions)==null?void 0:Y.map(re=>re.permissionCode))||[],userCount:V.userCount||0}}),Q=((b==null?void 0:b.zones)||(b==null?void 0:b.data)||[]).map(V=>{var re,ae,ue,ye,ce;const Y=(V.name||V.zoneName||"").toUpperCase();return{id:V.id,name:Y,description:V.description||"",code:V.name?V.name.substring(0,3).toUpperCase():"ZON",regionCount:V.regionCount||0,asmCount:V.asmCount||0,regionalOfficerCount:V.regionalOfficerCount||0,zmCount:V.zmCount||0,states:V.states||[],zonalBusinessHead:{name:((re=V.zonalBusinessHead)==null?void 0:re.name)||((ae=V.zonalBusinessHead)==null?void 0:ae.fullName)||"Not Assigned",email:((ue=V.zonalBusinessHead)==null?void 0:ue.email)||"",phone:((ye=V.zonalBusinessHead)==null?void 0:ye.mobileNumber)||((ce=V.zonalBusinessHead)==null?void 0:ce.phone)||""},zonalManagers:(V.zonalManagers||[]).map(je=>({id:je.id,name:je.name||je.fullName||"Unknown",email:je.email||"",phone:je.phone||je.mobileNumber||"",regions:je.regions||[]}))}}),W=((S==null?void 0:S.regions)||(S==null?void 0:S.data)||[]).map(V=>({id:V.id,code:V.code||(V.name?V.name.substring(0,3).toUpperCase():"REG"),name:V.name||V.regionName,zoneId:V.zoneId,zoneName:V.zoneName||"Unknown",states:V.states||[],cities:V.cities||[],districts:(V.districts||[]).map(Y=>({id:Y.id,name:Y.name,stateId:Y.stateId})),asmCount:V.asmCount||0,regionalOfficerCount:V.regionalOfficerCount||0,regionalManager:V.regionalManager?{id:V.regionalManager.id,name:V.regionalManager.fullName||V.regionalManager.name,email:V.regionalManager.email,phone:V.regionalManager.mobileNumber||V.regionalManager.phone}:void 0,status:V.isActive!==!1?"Active":"Inactive"})),U=Array.isArray(R==null?void 0:R.data)?R.data:Array.isArray(R)?R:[],M=Array.isArray(P==null?void 0:P.data)?P.data:Array.isArray(P)?P:[],z=M.length>0?M:$.filter(V=>{var Y;return(Y=V.allRoles)==null?void 0:Y.some(re=>(re==="ZM"||re==="DD-ZM"||re.includes("ZONAL MANAGER"))&&!re.includes("HEAD"))}).map(V=>{const Y=(V.territoryProfile||[]).find(ue=>ue.roleCode==="ZM"||ue.roleCode==="DD-ZM")||{},re=(V.territoryProfile||[]).filter(ue=>(ue.roleCode==="ZM"||ue.roleCode==="DD-ZM")&&ue.locationType==="region").map(ue=>ue.locationName),ae=(V.territoryProfile||[]).filter(ue=>(ue.roleCode==="ZM"||ue.roleCode==="DD-ZM")&&ue.locationType==="region").map(ue=>ue.locationId);return{id:V.id,name:V.fullName,zmCode:V.employeeId||"N/A",email:V.email,phone:V.mobileNumber,zoneId:Y.zoneId,zoneName:Y.zone||V.zone||"Not Assigned",regionNames:re,assignedRegionIds:ae,status:V.status}}),T=((_==null?void 0:_.states)||(_==null?void 0:_.data)||[]).map(V=>({...V,stateName:V.name})),F=((E==null?void 0:E.districts)||(E==null?void 0:E.data)||[]).map(V=>({...V,districtName:V.name,stateId:V.stateId,asmId:V.asmId,ddAmId:V.ddAmId,zmId:V.zmId})),I=(q.areas||q.data||[]).map(V=>({...V,areaName:V.name,districtId:V.districtId})),K=(O.data||[]).map(V=>{var Y,re;return{id:V.id,stage:V.stageCode||"Unknown",days:V.tatValue||0,enabled:V.isActive!==!1,reminders:((Y=V.reminderConfig)==null?void 0:Y.reminders)||[],escalations:((re=V.escalationConfig)==null?void 0:re.escalations)||[]}}),G=Array.isArray(L==null?void 0:L.data)?L.data:Array.isArray(L)?L:[];t(AA({zones:Q,regionalOffices:W,asms:U,zonalManagerMappings:z,zonalManagers:M,roles:Z,allStates:T,allDistricts:F,allAreas:I,availablePermissions:(C==null?void 0:C.permissions)||(C==null?void 0:C.data)||[],emailTemplates:(A==null?void 0:A.data)||[],slaConfigs:K,users:$,ddLeads:G,loading:!1}))}catch(r){console.error("[useMasterData] Error fetching data:",r),t(C5("Could not load configuration data")),J.error("Could not load configuration data")}finally{t(l1(!1))}},[t]),n=g.useCallback(async r=>{try{t(o1(!0));const a=await $s.getAreas(r);a.success&&t(A5({data:a.data,pagination:a.pagination}))}catch(a){console.error("[useMasterData] Error fetching areas:",a),J.error("Could not load locations")}finally{t(o1(!1))}},[t]);return{fetchInitialData:s,fetchAreas:n}},EV=({selectedZone:t,onZoneClick:s})=>{const{zones:n}=Pn(r=>r.master);return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:n.map(r=>e.jsxs(_e,{className:`border-2 transition-all cursor-pointer ${t===r.id?"border-re-red shadow-lg":"hover:border-red-400"}`,onClick:()=>s(r.id),children:[e.jsx(Xe,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ku,{className:"w-5 h-5 text-re-red"}),e.jsx(st,{className:"text-lg",children:r.name.toUpperCase().endsWith("ZONE")?r.name:`${r.name} Zone`})]}),e.jsx(we,{variant:"outline",className:"text-xs",children:r.code})]})}),e.jsxs(Oe,{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(we,{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(we,{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(we,{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(we,{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(we,{className:"bg-blue-600",children:r.zmCount})]})]})]})]},r.id))})},_V=({selectedZone:t,onAddZone:s,onEditZone:n})=>{const{zones:r}=Pn(i=>i.master),a=r.filter(i=>t==="all"||i.id===t);return e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"Zone Details"}),e.jsx(es,{children:"Geographical coverage and state mappings for each zone"})]}),e.jsxs(te,{onClick:s,className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add Zone"]})]})}),e.jsx(Oe,{children:e.jsx(Ib,{className:"h-[400px]",children:e.jsx("div",{className:"space-y-4",children:a.map(i=>e.jsxs("div",{className:"border rounded-lg p-5 space-y-4 bg-gradient-to-br from-white to-slate-50",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-gradient-to-br from-red-500 to-re-red rounded-lg flex items-center justify-center shadow-md",children:e.jsx(ku,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900",children:i.name}),e.jsx("p",{className:"text-slate-500 text-sm",children:i.code})]})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(te,{variant:"outline",size:"sm",onClick:()=>n(i),className:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",children:e.jsx(gr,{className:"w-4 h-4"})})})]}),i.description&&e.jsx("div",{className:"bg-slate-50 rounded-lg p-3",children:e.jsx("p",{className:"text-sm text-slate-600",children:i.description})}),e.jsxs("div",{children:[e.jsxs(le,{className:"text-xs text-slate-600 mb-2 block",children:["States Covered (",i.states.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.states.map((o,d)=>e.jsx(we,{variant:"secondary",className:"text-xs border-transparent bg-secondary text-secondary-foreground",children:o},d))})]}),i.zonalBusinessHead&&e.jsxs("div",{className:"border-t pt-3",children:[e.jsx(le,{className:"text-xs text-slate-600 mb-2 block",children:"Zonal Business Head (ZBH)"}),e.jsxs("div",{className:"bg-red-50 border border-red-100 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dc,{className:"w-4 h-4 text-re-red"}),e.jsx("span",{className:"text-sm font-semibold text-slate-900",children:i.zonalBusinessHead.name}),e.jsx(we,{className:"bg-re-red text-white text-[10px] ml-auto",children:"ZBH"})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-6 text-slate-600",children:[e.jsx(Gr,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:i.zonalBusinessHead.email})]})]})]}),i.zonalManagers&&i.zonalManagers.length>0&&e.jsxs("div",{className:"border-t pt-3",children:[e.jsxs(le,{className:"text-xs text-slate-600 mb-2 block",children:["Zonal Managers (",i.zonalManagers.length,")"]}),e.jsx("div",{className:"space-y-2",children:i.zonalManagers.map((o,d)=>e.jsxs("div",{className:"bg-slate-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ja,{className:"w-4 h-4 text-slate-600"}),e.jsx("span",{className:"text-sm text-slate-900",children:o.name}),e.jsxs(we,{variant:"outline",className:"text-xs ml-auto",children:["ZM-",d+1]})]}),o.email&&e.jsxs("div",{className:"flex items-center gap-2 ml-6",children:[e.jsx(Gr,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-xs text-slate-600",children:o.email})]}),o.phone&&e.jsx("div",{className:"flex items-center gap-2 ml-6",children:e.jsx("span",{className:"text-xs text-slate-600",children:o.phone})}),o.regions&&o.regions.length>0&&e.jsxs("div",{className:"ml-6 mt-2",children:[e.jsxs(le,{className:"text-xs text-slate-500 mb-1 block",children:["Managed Regions (",o.regions.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:o.regions.map((m,f)=>e.jsxs(we,{variant:"outline",className:"text-xs bg-white text-foreground",children:[e.jsx(ku,{className:"w-2.5 h-2.5 mr-1"}),m]},f))})]})]},d))})]})]},i.id))})})})]})},TV=({selectedZone:t,onAddRegion:s,onEditRegion:n,onDeleteRegion:r})=>{const{regionalOffices:a}=Pn(o=>o.master),i=a.filter(o=>t==="all"||o.zoneId===t);return e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"Regional Offices"}),e.jsx(es,{children:"Manage regional offices within zones"})]}),e.jsxs(te,{onClick:s,className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add Regional Office"]})]})}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:i.map(o=>e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(to,{className:"w-4 h-4 text-indigo-600"}),e.jsx("span",{className:"font-medium",children:o.code})]})}),e.jsx(oe,{className:"font-medium",children:o.name}),e.jsx(oe,{children:o.zoneName}),e.jsx(oe,{children:o.regionalManager?e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm",children:o.regionalManager.name}),e.jsx("span",{className:"text-xs text-slate-500",children:o.regionalManager.email})]}):e.jsx("span",{className:"text-slate-400 italic",children:"Not Assigned"})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(o.districts||[]).slice(0,2).map((d,m)=>e.jsx(we,{variant:"secondary",className:"text-xs",children:d.name||d},m)),(o.districts||[]).length>2&&e.jsxs(we,{variant:"secondary",className:"text-xs",children:["+",(o.districts||[]).length-2]})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[o.cities.slice(0,3).map((d,m)=>e.jsxs("span",{className:"text-xs text-slate-600",children:[d,m3&&e.jsxs("span",{className:"text-xs text-slate-500",children:["+",o.cities.length-3]})]})}),e.jsx(oe,{children:e.jsx(we,{className:"bg-purple-600",children:o.regionalOfficerCount})}),e.jsx(oe,{children:e.jsx(we,{className:"bg-green-600",children:o.asmCount})}),e.jsx(oe,{children:e.jsx(we,{variant:o.status==="Active"?"default":"secondary",className:o.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:o.status})}),e.jsx(oe,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>n(o),children:e.jsx(gr,{className:"w-4 h-4"})}),e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>r(o.id,o.name),className:"text-re-red hover:text-re-red-hover hover:bg-red-50",children:e.jsx(Zn,{className:"w-4 h-4"})})]})})]},o.id))})]})})]})},PV=({selectedZone:t,onAddASM:s,onEditASM:n,onDeleteASM:r})=>{const{asms:a,zonalManagerMappings:i}=Pn(m=>m.master),o=a.filter(m=>t==="all"||m.zoneId===t),d=g.useMemo(()=>{const m={};return[...a,...i].forEach(f=>{(f.areasManaged||f.districts||[]).forEach(h=>{m[h]||(m[h]=[]),m[h].includes(f.name)||m[h].push(f.name)})}),m},[a,i]);return e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"District Development Area Managers (DD-AM)"}),e.jsx(es,{children:"Manage DD-AM users across districts (multi-district)"})]}),e.jsxs(te,{onClick:s,className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add DD-AM"]})]})}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:o.map(m=>e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(iM,{className:"w-4 h-4 text-green-600"}),e.jsx("span",{className:"font-medium",children:m.asmCode||"N/A"})]})}),e.jsx(oe,{children:m.name}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",children:m.zoneName})}),e.jsx(oe,{className:"text-sm text-slate-600",children:m.regionName}),e.jsx(oe,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:m.areasManaged.map((f,p)=>{const h=typeof f=="string"?f:f.id,x=typeof f=="string"?f:f.name,u=(d[h]||[]).filter(v=>v!==m.name),N=u.length>0;return e.jsxs(we,{variant:N?"outline":"secondary",className:`text-xs ${N?"border-red-300 bg-red-50 text-re-red-hover font-medium":""}`,title:N?`Also managed by: ${u.join(", ")}`:void 0,children:[x,N&&e.jsx(ja,{className:"w-2.5 h-2.5 ml-1 inline"})]},p)})})}),e.jsx(oe,{children:e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-slate-900",children:m.email}),e.jsx("p",{className:"text-slate-500",children:m.phone})]})}),e.jsx(oe,{children:e.jsx(we,{variant:m.status==="Active"?"default":"secondary",className:m.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:m.status})}),e.jsx(oe,{className:"text-right",children:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>n(m),children:e.jsx(gr,{className:"w-4 h-4"})}),e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>r(m.id,m.name),className:"text-re-red hover:text-re-red-hover hover:bg-red-50",children:e.jsx(Zn,{className:"w-4 h-4"})})]})})]},m.id))})]})})]})},OV=({selectedZone:t,onAddZM:s,onEditZM:n,onDeleteZM:r})=>{const{zonalManagers:a}=Pn(o=>o.master),i=(a||[]).filter(o=>t==="all"||o.zoneId===t||o.zones&&o.zones.includes(t));return e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"Zonal Managers (DD-ZM)"}),e.jsx(es,{children:"Manage Zonal Managers and their region assignments"})]}),e.jsxs(te,{onClick:s,className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add ZM"]})]})}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:i.map(o=>e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ja,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"font-medium",children:o.zmCode||o.code})]})}),e.jsx(oe,{children:o.name}),e.jsx(oe,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:(o.zones||[o.zoneName]).map((d,m)=>e.jsx(we,{variant:"outline",children:d},m))})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(o.regionNames||[]).slice(0,3).map((d,m)=>e.jsx(we,{variant:"secondary",className:"text-xs",children:d},m)),(o.regionNames||[]).length>3&&e.jsxs(we,{variant:"secondary",className:"text-xs",children:["+",(o.regionNames||[]).length-3]})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-slate-900",children:o.email}),e.jsx("p",{className:"text-slate-500",children:o.phone})]})}),e.jsx(oe,{children:e.jsx(we,{variant:o.status==="Active"?"default":"secondary",className:o.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:o.status})}),e.jsx(oe,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>n(o),children:e.jsx(gr,{className:"w-4 h-4"})}),e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>r(o.id,o.name),className:"text-re-red hover:text-re-red-hover hover:bg-red-50",children:e.jsx(Zn,{className:"w-4 h-4"})})]})})]},o.id))})]})})]})},LV=({userAssignedData:t})=>e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{className:"text-xl",children:"System Users & Territory Assignments"})}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:t.map(s=>e.jsxs(lt,{children:[e.jsx(oe,{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(Rr,{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(Gr,{className:"w-3 h-3"}),s.email]})]})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dc,{className:"w-3 h-3 text-re-red"}),e.jsx("span",{className:"text-sm font-medium",children:s.role})]})}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",children:s.zone})}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",className:"bg-indigo-50 text-indigo-700 border-indigo-200",children:s.region})}),e.jsx(oe,{children:e.jsx(we,{variant:s.status==="Active"?"default":"secondary",className:s.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:s.status})})]},s.id))})]})})]}),IV=({onAddRole:t,onEditRole:s})=>{const{roles:n}=Pn(r=>r.master);return e.jsxs(_e,{className:"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border shadow-sm",children:[e.jsx(Xe,{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(st,{className:"leading-none text-xl font-bold",children:"Role Definitions"}),e.jsx(es,{className:"text-muted-foreground mt-1.5",children:"Overview of available roles and their access levels"})]}),e.jsxs(te,{onClick:t,className:"bg-re-red hover:bg-re-red-hover h-9",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add Role"]})]})}),e.jsx(Oe,{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(dc,{className:"w-5 h-5 text-re-red"}),e.jsx("h3",{className:"text-slate-900 font-bold",children:r.name})]}),e.jsxs(we,{variant:"secondary",className:"border-transparent bg-secondary text-secondary-foreground text-xs font-medium",children:[r.userCount||0," users"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"items-center gap-2 font-medium text-xs text-slate-600 mb-2 block",children:"Key Permissions"}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(r.permissions||[]).slice(0,3).map((i,o)=>e.jsx(we,{variant:"outline",className:"border px-2 py-0.5 font-medium text-foreground text-[10px] bg-white/50",children:i.replace(/_/g," ").toLowerCase()},o)),((a=r.permissions)==null?void 0:a.length)>3&&e.jsxs(we,{variant:"outline",className:"text-[10px] border-slate-200",children:["+",r.permissions.length-3]})]})]}),e.jsxs(te,{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(gr,{className:"w-3 h-3 mr-1"}),"Edit Permissions"]})]},r.id)})})})]})},MV=({isOpen:t,onOpenChange:s,role:n,onSave:r})=>{const[a,i]=g.useState([]);g.useEffect(()=>{n&&i(n.permissions||[])},[n,t]);const o=m=>{i(f=>f.includes(m)?f.filter(p=>p!==m):[...f,m])};if(!n)return null;const d=[{title:"Action Permissions",color:"from-green-50 to-emerald-50 border-green-200",textColor:"text-green-900",permissions:[{id:"action:approve",label:"Approve Applications"},{id:"action:reject",label:"Reject Applications"},{id:"action:upload_docs",label:"Upload Documents"},{id:"action:request_changes",label:"Request Changes"},{id:"action:forward",label:"Forward to Others"},{id:"action:reassign",label:"Reassign Applications"},{id:"action:schedule_interview",label:"Schedule Interviews"},{id:"action:add_comments",label:"Add Comments/Notes"},{id:"action:rank_applicants",label:"Rank Applicants"},{id:"action:final_approval",label:"Final Approval"}]},{title:"View/Access Permissions",color:"from-blue-50 to-cyan-50 border-blue-200",textColor:"text-blue-900",permissions:[{id:"view:view_details",label:"Application Details"},{id:"view:view_financial",label:"Financial Information"},{id:"view:view_discussions",label:"Discussion Notes"},{id:"view:view_progress",label:"Progress Tracking"},{id:"view:view_audit",label:"Audit Logs"},{id:"view:view_documents",label:"All Documents"},{id:"view:view_personal",label:"Personal Information"},{id:"view:view_business",label:"Business Details"},{id:"view:view_reports",label:"Reports & Analytics"},{id:"view:view_history",label:"Application History"}]},{title:"Application Stage Access",color:"from-red-50 to-orange-50 border-red-200",textColor:"text-red-900",permissions:[{id:"stage:initial_review",label:"Initial Review"},{id:"stage:field_verification",label:"Field Verification"},{id:"stage:level1_interview",label:"Level 1 Interview"},{id:"stage:level2_interview",label:"Level 2 Interview"},{id:"stage:ranking",label:"Ranking & Selection"},{id:"stage:legal_review",label:"Legal Review"},{id:"stage:financial_review",label:"Financial Review"},{id:"stage:final_approval",label:"Final Approval"},{id:"stage:payment",label:"Payment Verification"},{id:"stage:onboarding",label:"Onboarding"}]}];return e.jsx(ms,{open:t,onOpenChange:s,children:e.jsxs(us,{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(ys,{className:"p-6 pb-2 space-y-2 text-left bg-white sticky top-0 z-10 border-b",children:[e.jsxs(gs,{className:"text-xl font-bold tracking-tight",children:["Edit Role Permissions - ",n.name]}),e.jsxs(ws,{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(dc,{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(we,{className:"bg-purple-600 hover:bg-purple-700 px-3 py-1 rounded-full text-[10px] font-bold tracking-wider uppercase",children:"Role Configuration"})]})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("h4",{className:"text-sm font-bold text-slate-800 flex items-center gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-red-500 rounded-full"}),"Configure Default Permissions"]}),e.jsx("div",{className:"space-y-4",children:d.map((m,f)=>e.jsxs("div",{className:`border rounded-xl p-5 bg-gradient-to-br ${m.color} shadow-sm transition-all hover:shadow-md`,children:[e.jsxs("h5",{className:`text-sm font-bold ${m.textColor} mb-4 flex items-center justify-between`,children:[m.title,e.jsxs("span",{className:"text-[10px] bg-white/50 px-2 py-0.5 rounded-full opacity-70 italic font-normal",children:["Section ",f+1]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-y-3 gap-x-6",children:m.permissions.map(p=>e.jsxs("div",{className:"flex items-center space-x-3 group cursor-pointer p-1 rounded-md hover:bg-white/40 transition-colors",children:[e.jsx(Tn,{id:`perm-${p.id}`,checked:a.includes(p.id),onCheckedChange:()=>o(p.id),className:"border-slate-300 data-[state=checked]:bg-purple-600 data-[state=checked]:border-purple-600"}),e.jsx("label",{htmlFor:`perm-${p.id}`,className:"text-sm font-medium text-slate-700 cursor-pointer group-hover:text-slate-900 transition-colors flex-1",children:p.label})]},p.id))})]},f))})]})]}),e.jsxs("div",{className:"flex gap-3 p-6 pt-4 border-t sticky bottom-0 bg-white/80 backdrop-blur-md z-10",children:[e.jsx(te,{variant:"ghost",onClick:()=>s(!1),className:"flex-1 h-11 font-bold text-slate-600 hover:bg-slate-100",children:"Cancel"}),e.jsxs(te,{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(dl,{className:"w-4 h-4 mr-2"}),"Save Role Permissions"]})]})]})})},FV=({isOpen:t,onOpenChange:s,onSave:n})=>{const[r,a]=g.useState(""),[i,o]=g.useState(""),[d,m]=g.useState(""),[f,p]=g.useState(!1);g.useEffect(()=>{t&&(a(""),o(""),m(""),p(!1))},[t]);const h=async()=>{if(!(!r.trim()||!i.trim())){p(!0);try{await n({roleName:r.trim(),roleCode:i.trim(),description:d.trim()||void 0}),s(!1)}finally{p(!1)}}};return e.jsx(ms,{open:t,onOpenChange:s,children:e.jsxs(us,{className:"sm:max-w-md",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Add Role"}),e.jsx(ws,{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(le,{htmlFor:"role-name",children:"Role Name"}),e.jsx(it,{id:"role-name",value:r,onChange:x=>a(x.target.value),placeholder:"e.g. Finance Admin"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"role-code",children:"Role Code"}),e.jsx(it,{id:"role-code",value:i,onChange:x=>o(x.target.value),placeholder:"e.g. FINANCE_ADMIN"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"role-description",children:"Description"}),e.jsx(Ks,{id:"role-description",value:d,onChange:x=>m(x.target.value),placeholder:"Optional",rows:3})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(te,{variant:"outline",onClick:()=>s(!1),disabled:f,children:"Cancel"}),e.jsx(te,{onClick:h,disabled:f||!r.trim()||!i.trim(),children:f?"Saving...":"Create Role"})]})]})})},BV=({onEditTemplate:t,onDeleteTemplate:s})=>{const{emailTemplates:n}=Pn(r=>r.master);return e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs("div",{children:[e.jsx(st,{children:"Email & Letter Templates"}),e.jsx(es,{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(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:[n.map(r=>e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-red-50 rounded-lg flex items-center justify-center",children:e.jsx(Gr,{className:"w-4 h-4 text-re-red"})}),e.jsx("span",{className:"font-medium text-slate-900",children:r.name||r.templateCode})]})}),e.jsx(oe,{className:"text-slate-600 max-w-xs truncate",children:r.subject}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",className:"bg-slate-50 text-[10px] font-mono",children:r.templateCode||"-"})}),e.jsx(oe,{className:"text-slate-500 text-sm",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(er,{className:"w-3.5 h-3.5"}),r.updatedAt?Qt(r.updatedAt):"-"]})}),e.jsx(oe,{className:"text-right",children:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>t(r),children:e.jsx(gr,{className:"w-4 h-4"})}),e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>s(r.id),className:"text-red-500 hover:text-re-red hover:bg-red-50",children:e.jsx(Zn,{className:"w-4 h-4"})})]})})]},r.id)),n.length===0&&e.jsx(lt,{children:e.jsx(oe,{colSpan:5,className:"text-center py-12",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(Gr,{className:"w-8 h-8 text-slate-200"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"No templates configured yet"})]})})})]})]})})]})},$V=({onAddLocation:t,onEditLocation:s,onDeleteLocation:n,onSearch:r,onPageChange:a,searchTerm:i,states:o,stateFilter:d,onStateFilterChange:m,statusFilter:f,onStatusFilterChange:p})=>{const{allAreas:h,areasPagination:x,isAreasLoading:u}=Pn(N=>N.master);return e.jsx("div",{className:"space-y-4",children:e.jsxs(_e,{children:[e.jsx(Xe,{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(st,{children:"Dealership Locations"}),e.jsxs(es,{children:["Manage ",x.total," geographical locations and their operational status"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ku,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx("input",{type:"text",placeholder:"Search locations...",value:i,onChange:N=>r(N.target.value),className:"pl-9 pr-4 py-2 bg-slate-50 border border-slate-200 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-red-500 w-64 transition-all"})]}),e.jsxs(Rt,{value:d,onValueChange:m,children:[e.jsx(_t,{className:"w-48",children:e.jsx(Et,{placeholder:"All States"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All States"}),o.map(N=>e.jsx(Pe,{value:N.id,children:N.name||N.stateName},N.id))]})]}),e.jsxs(Rt,{value:f,onValueChange:p,children:[e.jsx(_t,{className:"w-44",children:e.jsx(Et,{placeholder:"Opportunity Filter"})}),e.jsxs(Tt,{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(te,{onClick:t,className:"bg-re-red hover:bg-re-red-hover whitespace-nowrap",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add Location"]})]})]})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:`relative ${u?"opacity-50 pointer-events-none":""}`,children:[e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:h.length===0?e.jsx(lt,{children:e.jsx(oe,{colSpan:6,className:"h-32 text-center text-slate-500 italic",children:i?"No locations found matching your search":"No locations available"})}):h.map(N=>e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mr,{className:"w-4 h-4 text-re-red"}),e.jsx("span",{className:"font-medium",children:N.stateName||"N/A"})]})}),e.jsx(oe,{className:"font-medium text-slate-900",children:N.city||"N/A"}),e.jsx(oe,{className:"text-slate-600 text-sm",children:N.name}),e.jsx(oe,{children:N.openFrom&&N.openTo?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-slate-600",children:"From:"}),e.jsx(we,{variant:"outline",className:"text-xs font-medium",children:Qt(N.openFrom)})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-slate-600",children:"To:"}),e.jsx(we,{variant:"outline",className:"text-xs font-medium",children:Qt(N.openTo)})]})]}):e.jsx("span",{className:"text-slate-400 italic text-sm",children:"Not Defined"})}),e.jsx(oe,{children:e.jsx(we,{variant:N.isOpportunity?"default":"secondary",className:N.isOpportunity?"bg-green-600 hover:bg-green-700 text-white border-transparent":"",children:N.isOpportunity?"Yes":"No"})}),e.jsx(oe,{className:"text-right",children:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(te,{variant:"outline",size:"sm",onClick:()=>s(N),className:"h-8 w-8 p-0",children:e.jsx(gr,{className:"w-4 h-4"})}),e.jsx(te,{variant:"outline",size:"sm",onClick:()=>n(N.id),className:"h-8 w-8 p-0 text-re-red hover:bg-red-50 hover:text-re-red-hover",children:e.jsx(Zn,{className:"w-4 h-4"})})]})})]},N.id))})]}),u&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-white/10 backdrop-blur-[1px]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-re-red"})})]}),x.totalPages>1&&e.jsxs("div",{className:"flex items-center justify-between mt-6 pt-4 border-t border-slate-100",children:[e.jsxs("div",{className:"text-sm text-slate-500",children:["Showing ",e.jsx("span",{className:"font-medium text-slate-900",children:(x.page-1)*x.limit+1})," to ",e.jsx("span",{className:"font-medium text-slate-900",children:Math.min(x.page*x.limit,x.total)})," of ",e.jsx("span",{className:"font-medium text-slate-900",children:x.total})," results"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{variant:"outline",size:"sm",onClick:()=>a(x.page-1),disabled:x.page<=1||u,className:"h-8",children:"Previous"}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,x.totalPages)},(N,v)=>{let w=x.page;return x.page<=3?w=v+1:x.page>=x.totalPages-2?w=x.totalPages-4+v:w=x.page-2+v,w<=0||w>x.totalPages?null:e.jsx(te,{variant:x.page===w?"default":"outline",size:"sm",onClick:()=>a(w),disabled:u,className:"h-8 w-8 p-0",children:w},w)})}),e.jsx(te,{variant:"outline",size:"sm",onClick:()=>a(x.page+1),disabled:x.page>=x.totalPages||u,className:"h-8",children:"Next"})]})]})]})]})})};var qV=Symbol("radix.slottable");function zV(t){const s=({children:n})=>e.jsx(e.Fragment,{children:n});return s.displayName=`${t}.Slottable`,s.__radixId=qV,s}var[fp]=oa("Tooltip",[lo]),pp=lo(),p_="TooltipProvider",UV=700,Dy="tooltip.open",[VV,oj]=fp(p_),x_=t=>{const{__scopeTooltip:s,delayDuration:n=UV,skipDelayDuration:r=300,disableHoverableContent:a=!1,children:i}=t,o=g.useRef(!0),d=g.useRef(!1),m=g.useRef(0);return g.useEffect(()=>{const f=m.current;return()=>window.clearTimeout(f)},[]),e.jsx(VV,{scope:s,isOpenDelayedRef:o,delayDuration:n,onOpen:g.useCallback(()=>{window.clearTimeout(m.current),o.current=!1},[]),onClose:g.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:d,onPointerInTransitChange:g.useCallback(f=>{d.current=f},[]),disableHoverableContent:a,children:i})};x_.displayName=p_;var Ou="Tooltip",[HV,ih]=fp(Ou),g_=t=>{const{__scopeTooltip:s,children:n,open:r,defaultOpen:a,onOpenChange:i,disableHoverableContent:o,delayDuration:d}=t,m=oj(Ou,t.__scopeTooltip),f=pp(s),[p,h]=g.useState(null),x=yr(),u=g.useRef(0),N=o??m.disableHoverableContent,v=d??m.delayDuration,w=g.useRef(!1),[j,b]=Li({prop:r,defaultProp:a??!1,onChange:A=>{A?(m.onOpen(),document.dispatchEvent(new CustomEvent(Dy))):m.onClose(),i==null||i(A)},caller:Ou}),C=g.useMemo(()=>j?w.current?"delayed-open":"instant-open":"closed",[j]),S=g.useCallback(()=>{window.clearTimeout(u.current),u.current=0,w.current=!1,b(!0)},[b]),D=g.useCallback(()=>{window.clearTimeout(u.current),u.current=0,b(!1)},[b]),_=g.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>{w.current=!0,b(!0),u.current=0},v)},[v,b]);return g.useEffect(()=>()=>{u.current&&(window.clearTimeout(u.current),u.current=0)},[]),e.jsx(Vf,{...f,children:e.jsx(HV,{scope:s,contentId:x,open:j,stateAttribute:C,trigger:p,onTriggerChange:h,onTriggerEnter:g.useCallback(()=>{m.isOpenDelayedRef.current?_():S()},[m.isOpenDelayedRef,_,S]),onTriggerLeave:g.useCallback(()=>{N?D():(window.clearTimeout(u.current),u.current=0)},[D,N]),onOpen:S,onClose:D,disableHoverableContent:N,children:n})})};g_.displayName=Ou;var Ry="TooltipTrigger",v_=g.forwardRef((t,s)=>{const{__scopeTooltip:n,...r}=t,a=ih(Ry,n),i=oj(Ry,n),o=pp(n),d=g.useRef(null),m=Ys(s,d,a.onTriggerChange),f=g.useRef(!1),p=g.useRef(!1),h=g.useCallback(()=>f.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),e.jsx(Qu,{asChild:!0,...o,children:e.jsx(Ss.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:m,onPointerMove:Yt(t.onPointerMove,x=>{x.pointerType!=="touch"&&!p.current&&!i.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:Yt(t.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:Yt(t.onPointerDown,()=>{a.open&&a.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Yt(t.onFocus,()=>{f.current||a.onOpen()}),onBlur:Yt(t.onBlur,a.onClose),onClick:Yt(t.onClick,a.onClose)})})});v_.displayName=Ry;var cj="TooltipPortal",[WV,GV]=fp(cj,{forceMount:void 0}),y_=t=>{const{__scopeTooltip:s,forceMount:n,children:r,container:a}=t,i=ih(cj,s);return e.jsx(WV,{scope:s,forceMount:n,children:e.jsx(jr,{present:n||i.open,children:e.jsx(Nd,{asChild:!0,container:a,children:r})})})};y_.displayName=cj;var md="TooltipContent",b_=g.forwardRef((t,s)=>{const n=GV(md,t.__scopeTooltip),{forceMount:r=n.forceMount,side:a="top",...i}=t,o=ih(md,t.__scopeTooltip);return e.jsx(jr,{present:r||o.open,children:o.disableHoverableContent?e.jsx(j_,{side:a,...i,ref:s}):e.jsx(KV,{side:a,...i,ref:s})})}),KV=g.forwardRef((t,s)=>{const n=ih(md,t.__scopeTooltip),r=oj(md,t.__scopeTooltip),a=g.useRef(null),i=Ys(s,a),[o,d]=g.useState(null),{trigger:m,onClose:f}=n,p=a.current,{onPointerInTransitChange:h}=r,x=g.useCallback(()=>{d(null),h(!1)},[h]),u=g.useCallback((N,v)=>{const w=N.currentTarget,j={x:N.clientX,y:N.clientY},b=XV(j,w.getBoundingClientRect()),C=JV(j,b),S=eH(v.getBoundingClientRect()),D=sH([...C,...S]);d(D),h(!0)},[h]);return g.useEffect(()=>()=>x(),[x]),g.useEffect(()=>{if(m&&p){const N=w=>u(w,p),v=w=>u(w,m);return m.addEventListener("pointerleave",N),p.addEventListener("pointerleave",v),()=>{m.removeEventListener("pointerleave",N),p.removeEventListener("pointerleave",v)}}},[m,p,u,x]),g.useEffect(()=>{if(o){const N=v=>{const w=v.target,j={x:v.clientX,y:v.clientY},b=(m==null?void 0:m.contains(w))||(p==null?void 0:p.contains(w)),C=!tH(j,o);b?x():C&&(x(),f())};return document.addEventListener("pointermove",N),()=>document.removeEventListener("pointermove",N)}},[m,p,o,f,x]),e.jsx(j_,{...t,ref:i})}),[YV,ZV]=fp(Ou,{isInside:!1}),QV=zV("TooltipContent"),j_=g.forwardRef((t,s)=>{const{__scopeTooltip:n,children:r,"aria-label":a,onEscapeKeyDown:i,onPointerDownOutside:o,...d}=t,m=ih(md,n),f=pp(n),{onClose:p}=m;return g.useEffect(()=>(document.addEventListener(Dy,p),()=>document.removeEventListener(Dy,p)),[p]),g.useEffect(()=>{if(m.trigger){const h=x=>{const u=x.target;u!=null&&u.contains(m.trigger)&&p()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[m.trigger,p]),e.jsx(yd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:h=>h.preventDefault(),onDismiss:p,children:e.jsxs(Hf,{"data-state":m.stateAttribute,...f,...d,ref:s,style:{...d.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(QV,{children:r}),e.jsx(YV,{scope:n,isInside:!0,children:e.jsx(X7,{id:m.contentId,role:"tooltip",children:a||r})})]})})});b_.displayName=md;var N_="TooltipArrow",w_=g.forwardRef((t,s)=>{const{__scopeTooltip:n,...r}=t,a=pp(n);return ZV(N_,n).isInside?null:e.jsx(Wf,{...a,...r,ref:s})});w_.displayName=N_;function XV(t,s){const n=Math.abs(s.top-t.y),r=Math.abs(s.bottom-t.y),a=Math.abs(s.right-t.x),i=Math.abs(s.left-t.x);switch(Math.min(n,r,a,i)){case i:return"left";case a:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function JV(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 eH(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 tH(t,s){const{x:n,y:r}=t;let a=!1;for(let i=0,o=s.length-1;ir!=x>r&&n<(h-f)*(r-p)/(x-p)+f&&(a=!a)}return a}function sH(t){const s=t.slice();return s.sort((n,r)=>n.xr.x?1:n.yr.y?1:0),nH(s)}function nH(t){if(t.length<=1)return t.slice();const s=[];for(let r=0;r=2;){const i=s[s.length-1],o=s[s.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))s.pop();else break}s.push(a)}s.pop();const n=[];for(let r=t.length-1;r>=0;r--){const a=t[r];for(;n.length>=2;){const i=n[n.length-1],o=n[n.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))n.pop();else break}n.push(a)}return n.pop(),s.length===1&&n.length===1&&s[0].x===n[0].x&&s[0].y===n[0].y?s:s.concat(n)}var rH=x_,aH=g_,iH=v_,lH=y_,oH=b_,cH=w_;function xp({delayDuration:t=0,...s}){return e.jsx(rH,{"data-slot":"tooltip-provider",delayDuration:t,...s})}function dj({...t}){return e.jsx(xp,{children:e.jsx(aH,{"data-slot":"tooltip",...t})})}function uj({...t}){return e.jsx(iH,{"data-slot":"tooltip-trigger",...t})}function hj({className:t,sideOffset:s=0,children:n,...r}){return e.jsx(lH,{children:e.jsxs(oH,{"data-slot":"tooltip-content",sideOffset:s,className:Nt("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...r,children:[n,e.jsx(cH,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const dH=({isOpen:t,onOpenChange:s,editingASMId:n,asmManagerId:r,setAsmManagerId:a,asmStatus:i,setAsmStatus:o,selectedASMZone:d,setSelectedASMZone:m,selectedASMRegion:f,setSelectedASMRegion:p,selectedASMStates:h,setSelectedASMStates:x,selectedASMDistricts:u,setSelectedASMDistricts:N,onSave:v,asmRoleCode:w,userAssignedData:j,districtsAssignedToOthers:b,getDistrictsForSelectedState:C})=>{const{zones:S,regionalOffices:D}=Pn(A=>A.master),_=j.filter(A=>{const E=(A.allRoles||[]).map(O=>String(O||"").toUpperCase()),q=String(A.roleCode||"").toUpperCase();return E.includes("DD-AM")||q==="DD-AM"});return Ct.useEffect(()=>{if(r&&t){const A=j.find(E=>E.id===r);if(A&&A.territoryProfile){const E=A.territoryProfile.filter(q=>q.roleCode===w&&q.locationType==="district").map(q=>q.locationId);E.length>0&&N(E)}}},[r,w,t,j,N]),e.jsx(ms,{open:t,onOpenChange:s,children:e.jsxs(us,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsxs(gs,{children:[n?"Edit":"Add"," DD Area Manager"]}),e.jsx(ws,{children:"Configure DD-AM details and district assignment"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{children:"Zone"}),e.jsxs(Rt,{value:d,onValueChange:A=>{m(A),p(""),x([]),N([])},children:[e.jsx(_t,{className:"mt-2 text-slate-900",children:e.jsx(Et,{placeholder:"Select zone"})}),e.jsx(Tt,{children:S.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(le,{children:"Regional Office"}),e.jsxs(Rt,{value:f,onValueChange:A=>{p(A),x([]),N([])},children:[e.jsx(_t,{className:"mt-2 text-slate-900",children:e.jsx(Et,{placeholder:"Select regional office"})}),e.jsx(Tt,{children:D.filter(A=>A.zoneId===d).map(A=>e.jsx(Pe,{value:A.id,children:A.name},A.id))})]})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Select DD-AM User"}),e.jsxs(Rt,{value:r,onValueChange:a,children:[e.jsx(_t,{className:"mt-2 text-slate-900",children:e.jsx(Et,{placeholder:"Select DD-AM"})}),e.jsx(Tt,{className:"max-h-64",children:_.map(A=>e.jsxs(Pe,{value:A.id,children:[A.name," (",A.employeeId||"No ID",")"]},A.id))})]})]})]}),f&&e.jsxs("div",{children:[e.jsx(le,{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=D.find(q=>q.id===f),E=((A==null?void 0:A.states)||[]).map(q=>typeof q=="string"?q:q.name);return E.length>0?e.jsx("div",{className:"space-y-2",children:E.map(q=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Tn,{id:`asm-state-${q}`,checked:h.some(O=>O.toLowerCase()===q.toLowerCase()),onCheckedChange:O=>{if(O)x([...h,q]);else{x(h.filter(P=>P.toLowerCase()!==q.toLowerCase()));const R=C(q);N(u.filter(P=>!R.some(L=>L.id===P)))}}}),e.jsx("label",{htmlFor:`asm-state-${q}`,className:"text-sm cursor-pointer text-slate-900",children:q})]},q))}):e.jsx("p",{className:"text-sm text-slate-500",children:"No states available for this regional office"})})()})]}),h.length>0&&e.jsxs("div",{children:[e.jsx(le,{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(xp,{children:h.map(A=>{const E=C(A);return E.length===0?null:e.jsxs("div",{className:"mb-4 last:mb-0",children:[e.jsx("h4",{className:"text-sm text-re-red-hover mb-2 pb-1 border-b border-slate-200",children:A}),e.jsx("div",{className:"space-y-2 ml-2",children:E.map(q=>e.jsx("div",{children:e.jsxs(dj,{children:[e.jsx(uj,{asChild:!0,children:e.jsxs("div",{className:"flex items-center space-x-2 py-0.5",children:[e.jsx(Tn,{id:`asm-district-${q.id}`,checked:u.includes(q.id),disabled:!!b[q.id],onCheckedChange:O=>{N(O?[...u,q.id]:u.filter(R=>R!==q.id))}}),e.jsx("label",{htmlFor:`asm-district-${q.id}`,className:`text-sm flex items-center gap-1.5 ${b[q.id]?"text-slate-400 cursor-not-allowed":"cursor-pointer text-slate-900"}`,children:q.name})]})}),b[q.id]&&e.jsx(hj,{children:e.jsxs("p",{children:["Already managed by: ",b[q.id].join(", ")]})})]})},q.id))})]},A)})})})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs(le,{children:["DD Area Manager ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:r,onValueChange:A=>{var q;a(A);const E=j.find(O=>O.id===A);if(E){const O=(E.territoryProfile||[]).find(R=>R.roleCode===w);O!=null&&O.zoneId&&m(O.zoneId),O!=null&&O.regionId&&p(O.regionId),N(((q=E.areasManaged)==null?void 0:q.filter(R=>R.roleCode===w).map(R=>R.id))||[]),x(E.stateNames||[])}},disabled:!!n,children:[e.jsx(_t,{className:"mt-2 w-full text-slate-900",children:e.jsx(Et,{placeholder:"Select DD-AM User"})}),e.jsx(Tt,{className:"max-h-60",children:_.length>0?_.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(le,{children:"Status"}),e.jsxs(Rt,{value:i,onValueChange:A=>o(A),children:[e.jsx(_t,{className:"mt-2 text-slate-900",children:e.jsx(Et,{})}),e.jsxs(Tt,{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(te,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-re-red hover:bg-re-red-hover",onClick:v,children:"Save DD-AM"})]})]})]})})};var MS=1,uH=.9,hH=.8,mH=.17,Zg=.1,Qg=.999,fH=.9999,pH=.99,xH=/[\\\/_+.#"@\[\(\{&]/,gH=/[\\\/_+.#"@\[\(\{&]/g,vH=/[\s-]/,S_=/[\s-]/g;function Ey(t,s,n,r,a,i,o){if(i===s.length)return a===t.length?MS:pH;var d=`${a},${i}`;if(o[d]!==void 0)return o[d];for(var m=r.charAt(i),f=n.indexOf(m,a),p=0,h,x,u,N;f>=0;)h=Ey(t,s,n,r,f+1,i+1,o),h>p&&(f===a?h*=MS:xH.test(t.charAt(f-1))?(h*=hH,u=t.slice(a,f-1).match(gH),u&&a>0&&(h*=Math.pow(Qg,u.length))):vH.test(t.charAt(f-1))?(h*=uH,N=t.slice(a,f-1).match(S_),N&&a>0&&(h*=Math.pow(Qg,N.length))):(h*=mH,a>0&&(h*=Math.pow(Qg,f-a))),t.charAt(f)!==s.charAt(i)&&(h*=fH)),(hh&&(h=x*Zg)),h>p&&(p=h),f=n.indexOf(m,f+1);return o[d]=p,p}function FS(t){return t.toLowerCase().replace(S_," ")}function yH(t,s,n){return t=n&&n.length>0?`${t+" "+n.join(" ")}`:t,Ey(t,s,FS(t),FS(s),0,0,{})}var cu='[cmdk-group=""]',Xg='[cmdk-group-items=""]',bH='[cmdk-group-heading=""]',C_='[cmdk-item=""]',BS=`${C_}:not([aria-disabled="true"])`,_y="cmdk-item-select",Kc="data-value",jH=(t,s,n)=>yH(t,s,n),A_=g.createContext(void 0),lh=()=>g.useContext(A_),k_=g.createContext(void 0),mj=()=>g.useContext(k_),D_=g.createContext(void 0),R_=g.forwardRef((t,s)=>{let n=Yc(()=>{var F,I;return{search:"",value:(I=(F=t.value)!=null?F:t.defaultValue)!=null?I:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Yc(()=>new Set),a=Yc(()=>new Map),i=Yc(()=>new Map),o=Yc(()=>new Set),d=E_(t),{label:m,children:f,value:p,onValueChange:h,filter:x,shouldFilter:u,loop:N,disablePointerSelection:v=!1,vimBindings:w=!0,...j}=t,b=yr(),C=yr(),S=yr(),D=g.useRef(null),_=TH();cc(()=>{if(p!==void 0){let F=p.trim();n.current.value=F,A.emit()}},[p]),cc(()=>{_(6,L)},[]);let A=g.useMemo(()=>({subscribe:F=>(o.current.add(F),()=>o.current.delete(F)),snapshot:()=>n.current,setState:(F,I,K)=>{var G,V,Y,re;if(!Object.is(n.current[F],I)){if(n.current[F]=I,F==="search")P(),O(),_(1,R);else if(F==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ae=document.getElementById(S);ae?ae.focus():(G=document.getElementById(b))==null||G.focus()}if(_(7,()=>{var ae;n.current.selectedItemId=(ae=$())==null?void 0:ae.id,A.emit()}),K||_(5,L),((V=d.current)==null?void 0:V.value)!==void 0){let ae=I??"";(re=(Y=d.current).onValueChange)==null||re.call(Y,ae);return}}A.emit()}},emit:()=>{o.current.forEach(F=>F())}}),[]),E=g.useMemo(()=>({value:(F,I,K)=>{var G;I!==((G=i.current.get(F))==null?void 0:G.value)&&(i.current.set(F,{value:I,keywords:K}),n.current.filtered.items.set(F,q(I,K)),_(2,()=>{O(),A.emit()}))},item:(F,I)=>(r.current.add(F),I&&(a.current.has(I)?a.current.get(I).add(F):a.current.set(I,new Set([F]))),_(3,()=>{P(),O(),n.current.value||R(),A.emit()}),()=>{i.current.delete(F),r.current.delete(F),n.current.filtered.items.delete(F);let K=$();_(4,()=>{P(),(K==null?void 0:K.getAttribute("id"))===F&&R(),A.emit()})}),group:F=>(a.current.has(F)||a.current.set(F,new Set),()=>{i.current.delete(F),a.current.delete(F)}),filter:()=>d.current.shouldFilter,label:m||t["aria-label"],getDisablePointerSelection:()=>d.current.disablePointerSelection,listId:b,inputId:S,labelId:C,listInnerRef:D}),[]);function q(F,I){var K,G;let V=(G=(K=d.current)==null?void 0:K.filter)!=null?G:jH;return F?V(F,n.current.search,I):0}function O(){if(!n.current.search||d.current.shouldFilter===!1)return;let F=n.current.filtered.items,I=[];n.current.filtered.groups.forEach(G=>{let V=a.current.get(G),Y=0;V.forEach(re=>{let ae=F.get(re);Y=Math.max(ae,Y)}),I.push([G,Y])});let K=D.current;Z().sort((G,V)=>{var Y,re;let ae=G.getAttribute("id"),ue=V.getAttribute("id");return((Y=F.get(ue))!=null?Y:0)-((re=F.get(ae))!=null?re:0)}).forEach(G=>{let V=G.closest(Xg);V?V.appendChild(G.parentElement===V?G:G.closest(`${Xg} > *`)):K.appendChild(G.parentElement===K?G:G.closest(`${Xg} > *`))}),I.sort((G,V)=>V[1]-G[1]).forEach(G=>{var V;let Y=(V=D.current)==null?void 0:V.querySelector(`${cu}[${Kc}="${encodeURIComponent(G[0])}"]`);Y==null||Y.parentElement.appendChild(Y)})}function R(){let F=Z().find(K=>K.getAttribute("aria-disabled")!=="true"),I=F==null?void 0:F.getAttribute(Kc);A.setState("value",I||void 0)}function P(){var F,I,K,G;if(!n.current.search||d.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let V=0;for(let Y of r.current){let re=(I=(F=i.current.get(Y))==null?void 0:F.value)!=null?I:"",ae=(G=(K=i.current.get(Y))==null?void 0:K.keywords)!=null?G:[],ue=q(re,ae);n.current.filtered.items.set(Y,ue),ue>0&&V++}for(let[Y,re]of a.current)for(let ae of re)if(n.current.filtered.items.get(ae)>0){n.current.filtered.groups.add(Y);break}n.current.filtered.count=V}function L(){var F,I,K;let G=$();G&&(((F=G.parentElement)==null?void 0:F.firstChild)===G&&((K=(I=G.closest(cu))==null?void 0:I.querySelector(bH))==null||K.scrollIntoView({block:"nearest"})),G.scrollIntoView({block:"nearest"}))}function $(){var F;return(F=D.current)==null?void 0:F.querySelector(`${C_}[aria-selected="true"]`)}function Z(){var F;return Array.from(((F=D.current)==null?void 0:F.querySelectorAll(BS))||[])}function Q(F){let I=Z()[F];I&&A.setState("value",I.getAttribute(Kc))}function W(F){var I;let K=$(),G=Z(),V=G.findIndex(re=>re===K),Y=G[V+F];(I=d.current)!=null&&I.loop&&(Y=V+F<0?G[G.length-1]:V+F===G.length?G[0]:G[V+F]),Y&&A.setState("value",Y.getAttribute(Kc))}function U(F){let I=$(),K=I==null?void 0:I.closest(cu),G;for(;K&&!G;)K=F>0?EH(K,cu):_H(K,cu),G=K==null?void 0:K.querySelector(BS);G?A.setState("value",G.getAttribute(Kc)):W(F)}let M=()=>Q(Z().length-1),z=F=>{F.preventDefault(),F.metaKey?M():F.altKey?U(1):W(1)},T=F=>{F.preventDefault(),F.metaKey?Q(0):F.altKey?U(-1):W(-1)};return g.createElement(Ss.div,{ref:s,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:F=>{var I;(I=j.onKeyDown)==null||I.call(j,F);let K=F.nativeEvent.isComposing||F.keyCode===229;if(!(F.defaultPrevented||K))switch(F.key){case"n":case"j":{w&&F.ctrlKey&&z(F);break}case"ArrowDown":{z(F);break}case"p":case"k":{w&&F.ctrlKey&&T(F);break}case"ArrowUp":{T(F);break}case"Home":{F.preventDefault(),Q(0);break}case"End":{F.preventDefault(),M();break}case"Enter":{F.preventDefault();let G=$();if(G){let V=new Event(_y);G.dispatchEvent(V)}}}}},g.createElement("label",{"cmdk-label":"",htmlFor:E.inputId,id:E.labelId,style:OH},m),gp(t,F=>g.createElement(k_.Provider,{value:A},g.createElement(A_.Provider,{value:E},F))))}),NH=g.forwardRef((t,s)=>{var n,r;let a=yr(),i=g.useRef(null),o=g.useContext(D_),d=lh(),m=E_(t),f=(r=(n=m.current)==null?void 0:n.forceMount)!=null?r:o==null?void 0:o.forceMount;cc(()=>{if(!f)return d.item(a,o==null?void 0:o.id)},[f]);let p=__(a,i,[t.value,t.children,i],t.keywords),h=mj(),x=ao(_=>_.value&&_.value===p.current),u=ao(_=>f||d.filter()===!1?!0:_.search?_.filtered.items.get(a)>0:!0);g.useEffect(()=>{let _=i.current;if(!(!_||t.disabled))return _.addEventListener(_y,N),()=>_.removeEventListener(_y,N)},[u,t.onSelect,t.disabled]);function N(){var _,A;v(),(A=(_=m.current).onSelect)==null||A.call(_,p.current)}function v(){h.setState("value",p.current,!0)}if(!u)return null;let{disabled:w,value:j,onSelect:b,forceMount:C,keywords:S,...D}=t;return g.createElement(Ss.div,{ref:Hr(i,s),...D,id:a,"cmdk-item":"",role:"option","aria-disabled":!!w,"aria-selected":!!x,"data-disabled":!!w,"data-selected":!!x,onPointerMove:w||d.getDisablePointerSelection()?void 0:v,onClick:w?void 0:N},t.children)}),wH=g.forwardRef((t,s)=>{let{heading:n,children:r,forceMount:a,...i}=t,o=yr(),d=g.useRef(null),m=g.useRef(null),f=yr(),p=lh(),h=ao(u=>a||p.filter()===!1?!0:u.search?u.filtered.groups.has(o):!0);cc(()=>p.group(o),[]),__(o,d,[t.value,t.heading,m]);let x=g.useMemo(()=>({id:o,forceMount:a}),[a]);return g.createElement(Ss.div,{ref:Hr(d,s),...i,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&g.createElement("div",{ref:m,"cmdk-group-heading":"","aria-hidden":!0,id:f},n),gp(t,u=>g.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?f:void 0},g.createElement(D_.Provider,{value:x},u))))}),SH=g.forwardRef((t,s)=>{let{alwaysRender:n,...r}=t,a=g.useRef(null),i=ao(o=>!o.search);return!n&&!i?null:g.createElement(Ss.div,{ref:Hr(a,s),...r,"cmdk-separator":"",role:"separator"})}),CH=g.forwardRef((t,s)=>{let{onValueChange:n,...r}=t,a=t.value!=null,i=mj(),o=ao(f=>f.search),d=ao(f=>f.selectedItemId),m=lh();return g.useEffect(()=>{t.value!=null&&i.setState("search",t.value)},[t.value]),g.createElement(Ss.input,{ref:s,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":m.listId,"aria-labelledby":m.labelId,"aria-activedescendant":d,id:m.inputId,type:"text",value:a?t.value:o,onChange:f=>{a||i.setState("search",f.target.value),n==null||n(f.target.value)}})}),AH=g.forwardRef((t,s)=>{let{children:n,label:r="Suggestions",...a}=t,i=g.useRef(null),o=g.useRef(null),d=ao(f=>f.selectedItemId),m=lh();return g.useEffect(()=>{if(o.current&&i.current){let f=o.current,p=i.current,h,x=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let u=f.offsetHeight;p.style.setProperty("--cmdk-list-height",u.toFixed(1)+"px")})});return x.observe(f),()=>{cancelAnimationFrame(h),x.unobserve(f)}}},[]),g.createElement(Ss.div,{ref:Hr(i,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":d,"aria-label":r,id:m.listId},gp(t,f=>g.createElement("div",{ref:Hr(o,m.listInnerRef),"cmdk-list-sizer":""},f)))}),kH=g.forwardRef((t,s)=>{let{open:n,onOpenChange:r,overlayClassName:a,contentClassName:i,container:o,...d}=t;return g.createElement(qb,{open:n,onOpenChange:r},g.createElement(zb,{container:o},g.createElement(ip,{"cmdk-overlay":"",className:a}),g.createElement(lp,{"aria-label":t.label,"cmdk-dialog":"",className:i},g.createElement(R_,{ref:s,...d}))))}),DH=g.forwardRef((t,s)=>ao(n=>n.filtered.count===0)?g.createElement(Ss.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),RH=g.forwardRef((t,s)=>{let{progress:n,children:r,label:a="Loading...",...i}=t;return g.createElement(Ss.div,{ref:s,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},gp(t,o=>g.createElement("div",{"aria-hidden":!0},o)))}),kd=Object.assign(R_,{List:AH,Item:NH,Input:CH,Group:wH,Separator:SH,Dialog:kH,Empty:DH,Loading:RH});function EH(t,s){let n=t.nextElementSibling;for(;n;){if(n.matches(s))return n;n=n.nextElementSibling}}function _H(t,s){let n=t.previousElementSibling;for(;n;){if(n.matches(s))return n;n=n.previousElementSibling}}function E_(t){let s=g.useRef(t);return cc(()=>{s.current=t}),s}var cc=typeof window>"u"?g.useEffect:g.useLayoutEffect;function Yc(t){let s=g.useRef();return s.current===void 0&&(s.current=t()),s}function ao(t){let s=mj(),n=()=>t(s.snapshot());return g.useSyncExternalStore(s.subscribe,n,n)}function __(t,s,n,r=[]){let a=g.useRef(),i=lh();return cc(()=>{var o;let d=(()=>{var f;for(let p of n){if(typeof p=="string")return p.trim();if(typeof p=="object"&&"current"in p)return p.current?(f=p.current.textContent)==null?void 0:f.trim():a.current}})(),m=r.map(f=>f.trim());i.value(t,d,m),(o=s.current)==null||o.setAttribute(Kc,d),a.current=d}),a}var TH=()=>{let[t,s]=g.useState(),n=Yc(()=>new Map);return cc(()=>{n.current.forEach(r=>r()),n.current=new Map},[t]),(r,a)=>{n.current.set(r,a),s({})}};function PH(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function gp({asChild:t,children:s},n){return t&&g.isValidElement(s)?g.cloneElement(PH(s),{ref:s.ref},n(s.props.children)):n(s)}var OH={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function LH({className:t,...s}){return e.jsx(kd,{"data-slot":"command",className:Nt("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",t),...s})}function IH({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(wa,{className:"size-4 shrink-0 opacity-50"}),e.jsx(kd.Input,{"data-slot":"command-input",className:Nt("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",t),...s})]})}function MH({className:t,...s}){return e.jsx(kd.List,{"data-slot":"command-list",className:Nt("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),...s})}function FH({...t}){return e.jsx(kd.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...t})}function BH({className:t,...s}){return e.jsx(kd.Group,{"data-slot":"command-group",className:Nt("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",t),...s})}function $S({className:t,...s}){return e.jsx(kd.Item,{"data-slot":"command-item",className:Nt("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...s})}const $H=({value:t,onChange:s,asmUsers:n,className:r})=>{const[a,i]=g.useState(!1),o=n.find(d=>d.id===t);return e.jsxs(_u,{open:a,onOpenChange:i,children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(te,{variant:"outline",role:"combobox","aria-expanded":a,className:Nt("w-full min-w-0 justify-between",r),children:[e.jsx("span",{className:"truncate text-left",children:t==="__none__"?"Unassign":o?`${o.fullName} (${o.employeeId||o.email})`:"Select ASM"}),e.jsx(LI,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Pu,{className:"w-[360px] max-w-[90vw] p-0",children:e.jsxs(LH,{children:[e.jsx(IH,{placeholder:"Search ASM by name/email/id..."}),e.jsxs(MH,{className:"max-h-64 overflow-y-auto custom-scrollbar-slim",children:[e.jsx(FH,{children:"No ASM found."}),e.jsxs(BH,{children:[e.jsxs($S,{value:"Unassign __none__",onSelect:()=>{s("__none__"),i(!1)},children:[e.jsx($n,{className:Nt("mr-2 h-4 w-4",t==="__none__"?"opacity-100":"opacity-0")}),"Unassign"]}),n.map(d=>e.jsxs($S,{value:`${d.fullName} ${d.email} ${d.employeeId||""}`,onSelect:()=>{s(d.id),i(!1)},children:[e.jsx($n,{className:Nt("mr-2 h-4 w-4",t===d.id?"opacity-100":"opacity-0")}),d.fullName," (",d.employeeId||d.email,")"]},d.id))]})]})]})})]})},qH=()=>{const[t,s]=g.useState(!1),[n,r]=g.useState([]),[a,i]=g.useState([]),[o,d]=g.useState({}),m=async()=>{var h,x,u,N;try{s(!0);const v=await $s.getDealerAsmMappings();v!=null&&v.success&&(r(((h=v.data)==null?void 0:h.dealers)||[]),i(((x=v.data)==null?void 0:x.asmUsers)||[]))}catch(v){J.error(((N=(u=v==null?void 0:v.response)==null?void 0:u.data)==null?void 0:N.message)||"Failed to load dealer ASM mappings")}finally{s(!1)}};g.useEffect(()=>{m()},[]);const f=g.useMemo(()=>[...n].sort((h,x)=>{const u=String(h.status||"").toLowerCase()==="active",N=String(x.status||"").toLowerCase()==="active";return u!==N?u?-1:1:String(h.dealerName||"").localeCompare(String(x.dealerName||""))}),[n]),p=async h=>{var u,N;const x=o[h]||"";try{const v=await $s.saveDealerAsmMapping({dealerId:h,asmUserId:x==="__none__"?null:x||null});v!=null&&v.success?(J.success(v.message||"Dealer ASM mapping updated"),await m()):J.error((v==null?void 0:v.message)||"Failed to save mapping")}catch(v){J.error(((N=(u=v==null?void 0:v.response)==null?void 0:u.data)==null?void 0:N.message)||"Failed to save mapping")}};return e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Dealer-Level ASM Assignment"}),e.jsx(es,{children:"Assign Sales ASM to onboarded dealers. DD-AM remains district-level in the section above."})]}),e.jsx(Oe,{children:t?e.jsx("p",{className:"text-sm text-slate-500",children:"Loading mappings..."}):e.jsxs(Ms,{className:"w-full",children:[e.jsx(Fs,{children:e.jsxs(lt,{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(Bs,{children:[f.length===0&&e.jsx(lt,{children:e.jsx(oe,{colSpan:5,className:"text-center text-slate-500 py-8",children:"No dealers available for ASM mapping yet."})}),f.map(h=>{var x;return e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:h.dealerName}),e.jsx("span",{className:"text-xs text-slate-500",children:h.legalName})]})}),e.jsx(oe,{children:h.dealerCode||"N/A"}),e.jsx(oe,{children:e.jsx(we,{variant:String(h.status||"").toLowerCase()==="active"?"default":"secondary",className:String(h.status||"").toLowerCase()==="active"?"bg-emerald-100 text-emerald-700 hover:bg-emerald-200":"",children:h.status||"Unknown"})}),e.jsx(oe,{children:h.assignedAsm?e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("span",{children:h.assignedAsm.fullName}),e.jsx("span",{className:"text-xs text-slate-500 truncate",children:h.assignedAsm.employeeId||h.assignedAsm.email})]}):e.jsx("span",{className:"text-slate-400 text-sm",children:"Unassigned"})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx($H,{asmUsers:a,value:o[h.dealerId]??((x=h.assignedAsm)==null?void 0:x.id)??"__none__",onChange:u=>d(N=>({...N,[h.dealerId]:u})),className:"flex-1 min-w-[180px]"}),e.jsx(te,{size:"sm",className:"shrink-0 bg-re-red hover:bg-re-red-hover text-white",onClick:()=>p(h.dealerId),children:"Assign"})]})})]},h.dealerId)})]})]})})]})},zH=({isOpen:t,onOpenChange:s,editingZMId:n,zmManagerId:r,setZmManagerId:a,zmStatus:i,setZmStatus:o,selectedZone:d,setSelectedZone:m,selectedRegions:f,setSelectedRegions:p,onSave:h,userAssignedData:x})=>{const{zones:u,regionalOffices:N}=Pn(j=>j.master),v=x.filter(j=>(j.allRoles||[]).some(C=>{const S=(C||"").toUpperCase();return["ZM","ZONAL MANAGER","ZBH","ZONE BUSINESS HEAD","RM","RBM","REGIONAL MANAGER"].includes(S)||S.includes("ZONAL")||S.includes("REGIONAL")})),w=N.filter(j=>j.zoneId===d);return e.jsx(ms,{open:t,onOpenChange:s,children:e.jsxs(us,{className:"max-w-xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsxs(gs,{children:[n?"Edit":"Add"," Zonal Manager"]}),e.jsx(ws,{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(le,{children:["Select Zonal Manager User ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:r,onValueChange:j=>{a(j);const b=x.find(C=>C.id===j);b&&(b.zoneId&&m(b.zoneId),b.assignedRegionIds&&p(b.assignedRegionIds))},disabled:!!n,children:[e.jsx(_t,{className:"mt-2 w-full text-slate-900 border-slate-200",children:e.jsx(Et,{placeholder:"Select ZM User"})}),e.jsx(Tt,{className:"max-h-60",children:v.map(j=>e.jsx(Pe,{value:j.id,children:e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("span",{className:"font-medium text-slate-900",children:j.name}),e.jsx("span",{className:"text-xs text-slate-500",children:j.email})]})},j.id))})]})]}),e.jsxs("div",{children:[e.jsxs(le,{children:["Managed Zone ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:d,onValueChange:j=>{m(j),p([])},children:[e.jsx(_t,{className:"mt-2",children:e.jsx(Et,{placeholder:"Select zone"})}),e.jsx(Tt,{children:u.map(j=>e.jsx(Pe,{value:j.id,children:j.name},j.id))})]})]}),d&&e.jsxs("div",{children:[e.jsxs(le,{className:"mb-2 block",children:["Assigned Regions ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"border border-slate-200 rounded-lg p-4 bg-slate-50/50 max-h-60 overflow-y-auto",children:e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[w.map(j=>e.jsxs("div",{className:"flex items-center space-x-3 p-2 rounded hover:bg-white transition-colors",children:[e.jsx(Tn,{id:`region-${j.id}`,checked:f.includes(j.id),onCheckedChange:b=>{p(b?[...f,j.id]:f.filter(C=>C!==j.id))}}),e.jsxs("label",{htmlFor:`region-${j.id}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer flex-1",children:[j.name,e.jsx("span",{className:"text-xs text-slate-500 block mt-1",children:j.code||"No Code"})]})]},j.id)),w.length===0&&e.jsx("p",{className:"text-sm text-slate-500 italic text-center py-4",children:"No regions found for this zone"})]})})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Status"}),e.jsxs(Rt,{value:i,onValueChange:j=>o(j),children:[e.jsx(_t,{className:"mt-2",children:e.jsx(Et,{})}),e.jsxs(Tt,{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(te,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-re-red hover:bg-re-red-hover",onClick:h,children:"Save Zonal Manager"})]})]})]})})},UH=({isOpen:t,onOpenChange:s,editingZoneId:n,zoneName:r,setZoneName:a,zoneCode:i,setZoneCode:o,zoneDescription:d,setZoneDescription:m,zonalBusinessHeadId:f,setZonalBusinessHeadId:p,userAssignedData:h,onSave:x})=>{const u=(h||[]).filter(v=>{if(f!=="none"&&v.id===f)return!0;const w=(v.allRoles||[]).map(b=>String(b||"").toUpperCase()),j=String(v.roleCode||v.role||"").toUpperCase();return j==="ZBH"||j.includes("ZONAL BUSINESS HEAD")||w.some(b=>{const C=String(b||"").toUpperCase();return C==="ZBH"||C==="ZONE BUSINESS HEAD"||C==="ZONAL BUSINESS HEAD"})}),N=u.length>0?u:h||[];return Ct.useEffect(()=>{},[n,t]),e.jsx(ms,{open:t,onOpenChange:s,children:e.jsxs(us,{className:"max-w-md",children:[e.jsxs(ys,{children:[e.jsxs(gs,{children:[n?"Edit":"Add"," Zone"]}),e.jsx(ws,{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(le,{children:"Zone Name"}),e.jsx(it,{placeholder:"e.g., North Zone",className:"mt-2 text-slate-900",value:r,onChange:v=>a(v.target.value)})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Zone Code"}),e.jsx(it,{placeholder:"e.g., NZ",className:"mt-2 text-slate-900",value:i,onChange:v=>o(v.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Zonal Business Head"}),e.jsxs(Rt,{value:f,onValueChange:p,children:[e.jsx(_t,{className:"mt-2 w-full text-slate-900",children:e.jsx(Et,{placeholder:"Select Head"})}),e.jsxs(Tt,{className:"max-h-60",children:[e.jsx(Pe,{value:"none",children:"None / Unassigned"}),N.map(v=>e.jsxs(Pe,{value:v.id,children:[v.name," (",v.email,")"]},v.id))]})]})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Description"}),e.jsx(Ks,{placeholder:"Describe the zone's coverage...",className:"mt-2 text-slate-900",rows:3,value:d,onChange:v=>m(v.target.value)})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-re-red hover:bg-re-red-hover",onClick:x,children:"Save Zone"})]})]})]})})},VH=({isOpen:t,onOpenChange:s,editingRegionId:n,regionName:r,setRegionName:a,regionDescription:i,setRegionDescription:o,selectedRegionZone:d,setSelectedRegionZone:m,regionalManagerId:f,setRegionalManagerId:p,selectedRegionStates:h,setSelectedRegionStates:x,onSave:u,userAssignedData:N})=>{const{zones:v,allStates:w,allDistricts:j,regionalOffices:b}=Pn(R=>R.master),[C,S]=Ct.useState([]),D=Ct.useMemo(()=>{const R={};return(b||[]).forEach(P=>{P.id!==n&&(P.districts||[]).forEach(L=>{R[L.id]=P.name})}),R},[b,n]),_=Ct.useMemo(()=>{if(!d)return w;const R=new Set(j.filter(P=>P.zoneId===d||!P.zoneId||h.includes(P.id)).map(P=>P.stateId).filter(Boolean));return w.filter(P=>P.zoneId===d||R.has(P.id)||!P.zoneId)},[w,j,d,h]),A=Ct.useMemo(()=>C.length===0?[]:j.filter(R=>C.includes(R.stateId)&&(!R.zoneId||R.zoneId===d||R.regionId===n)),[j,C,d,n]),E=Ct.useMemo(()=>{const R={};return A.forEach(P=>{const L=w.find(Z=>Z.id===P.stateId),$=(L==null?void 0:L.name)||P.stateId;R[P.stateId]||(R[P.stateId]={stateName:$,districts:[]}),R[P.stateId].districts.push(P)}),Object.values(R)},[A,w]);Ct.useEffect(()=>{if(!t){S([]);return}if(h.length>0){const R=Array.from(new Set(j.filter(P=>h.includes(P.id)).map(P=>P.stateId).filter(Boolean)));S(R)}},[t]);const q=R=>{m(R),S([]),x([])},O=(R,P)=>{if(P)S(L=>[...L,R]);else{S($=>$.filter(Z=>Z!==R));const L=j.filter($=>$.stateId===R).map($=>$.id);x(h.filter($=>!L.includes($)))}};return e.jsx(ms,{open:t,onOpenChange:s,children:e.jsxs(us,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsxs(gs,{children:[n?"Edit":"Add"," Regional Office"]}),e.jsx(ws,{children:"Configure regional office details and coverage area"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{children:"Region Name"}),e.jsx(it,{placeholder:"e.g., Delhi NCR Region",className:"mt-2 text-slate-900",value:r,onChange:R=>a(R.target.value)})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Zone"}),e.jsxs(Rt,{value:d,onValueChange:q,children:[e.jsx(_t,{className:"mt-2 text-slate-900",children:e.jsx(Et,{placeholder:"Select zone"})}),e.jsx(Tt,{children:v.map(R=>e.jsx(Pe,{value:R.id,children:R.name},R.id))})]})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Regional Manager"}),e.jsxs(Rt,{value:f,onValueChange:p,children:[e.jsx(_t,{className:"mt-2 w-full text-slate-900",children:e.jsx(Et,{placeholder:"Select from available users"})}),e.jsx(Tt,{className:"max-h-60",children:N.map(R=>e.jsxs(Pe,{value:R.id,children:[R.name||R.fullName,R.email?` — ${R.email}`:""]},R.id))})]})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Description"}),e.jsx(Ks,{placeholder:"Describe the region...",className:"mt-2 text-slate-900",rows:2,value:i,onChange:R=>o(R.target.value)})]}),e.jsxs("div",{children:[e.jsx(le,{children:"States Covered"}),!d&&e.jsx("p",{className:"text-xs text-re-red mt-1",children:"Select a zone first to see available states"}),e.jsx("div",{className:"mt-2 border rounded-lg p-3 max-h-40 overflow-y-auto bg-slate-50",children:_.length===0?e.jsx("p",{className:"text-xs text-slate-400 italic",children:d?"No states with available districts in this zone":"Select a zone to load states"}):e.jsx("div",{className:"space-y-2",children:_.map(R=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Tn,{id:`region-state-${R.id}`,checked:C.includes(R.id),disabled:!d,onCheckedChange:P=>O(R.id,!!P)}),e.jsx("label",{htmlFor:`region-state-${R.id}`,className:`text-sm cursor-pointer ${d?"text-slate-900":"text-slate-400"}`,children:R.name})]},R.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(le,{children:"Districts Covered"}),e.jsx("div",{className:"mt-2 border rounded-lg p-3 max-h-56 overflow-y-auto bg-slate-50",children:C.length===0?e.jsx("p",{className:"text-xs text-slate-400 italic",children:"Select one or more states above to see districts"}):E.length===0?e.jsx("p",{className:"text-xs text-slate-400 italic",children:"No available districts in the selected states for this zone"}):e.jsx(xp,{children:E.map(({stateName:R,districts:P})=>e.jsxs("div",{className:"mb-4 last:mb-0",children:[e.jsx("h4",{className:"text-xs font-semibold text-re-red-hover uppercase tracking-wide mb-2 pb-1 border-b border-slate-200",children:R}),e.jsx("div",{className:"space-y-2 ml-1",children:P.map(L=>{const $=D[L.id],Z=L.zoneId&&L.zoneId!==d&&L.regionId!==n,Q=!!($||Z),W=$?`Already assigned to region: ${$}`:Z?"Belongs to a different zone":"";return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(dj,{children:[e.jsx(uj,{asChild:!0,children:e.jsxs("div",{className:"flex items-center space-x-2 w-full",children:[e.jsx(Tn,{id:`region-district-${L.id}`,disabled:Q,checked:h.includes(L.id),onCheckedChange:U=>{x(U?[...h,L.id]:h.filter(M=>M!==L.id))}}),e.jsxs("label",{htmlFor:`region-district-${L.id}`,className:`text-sm flex-1 ${Q?"text-slate-400 cursor-not-allowed line-through":"text-slate-900 cursor-pointer"}`,children:[L.name,$&&e.jsxs("span",{className:"ml-2 text-xs text-red-400 font-normal no-underline",style:{textDecoration:"none"},children:["(in ",$,")"]})]})]})}),Q&&W&&e.jsx(hj,{children:e.jsx("p",{className:"text-xs",children:W})})]})},L.id)})})]},R))})}),e.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:[h.length," ",h.length===1?"district":"districts"," selected"]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-re-red hover:bg-re-red-hover",onClick:u,children:"Save Regional Office"})]})]})]})})};var vp="Switch",[HH]=oa(vp),[WH,GH]=HH(vp),T_=g.forwardRef((t,s)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:i,required:o,disabled:d,value:m="on",onCheckedChange:f,form:p,...h}=t,[x,u]=g.useState(null),N=Ys(s,C=>u(C)),v=g.useRef(!1),w=x?p||!!x.closest("form"):!0,[j,b]=Li({prop:a,defaultProp:i??!1,onChange:f,caller:vp});return e.jsxs(WH,{scope:n,checked:j,disabled:d,children:[e.jsx(Ss.button,{type:"button",role:"switch","aria-checked":j,"aria-required":o,"data-state":I_(j),"data-disabled":d?"":void 0,disabled:d,value:m,...h,ref:N,onClick:Yt(t.onClick,C=>{b(S=>!S),w&&(v.current=C.isPropagationStopped(),v.current||C.stopPropagation())})}),w&&e.jsx(L_,{control:x,bubbles:!v.current,name:r,value:m,checked:j,required:o,disabled:d,form:p,style:{transform:"translateX(-100%)"}})]})});T_.displayName=vp;var P_="SwitchThumb",O_=g.forwardRef((t,s)=>{const{__scopeSwitch:n,...r}=t,a=GH(P_,n);return e.jsx(Ss.span,{"data-state":I_(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:s})});O_.displayName=P_;var KH="SwitchBubbleInput",L_=g.forwardRef(({__scopeSwitch:t,control:s,checked:n,bubbles:r=!0,...a},i)=>{const o=g.useRef(null),d=Ys(o,i),m=Zy(n),f=Qy(s);return g.useEffect(()=>{const p=o.current;if(!p)return;const h=window.HTMLInputElement.prototype,u=Object.getOwnPropertyDescriptor(h,"checked").set;if(m!==n&&u){const N=new Event("click",{bubbles:r});u.call(p,n),p.dispatchEvent(N)}},[m,n,r]),e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:d,style:{...a.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});L_.displayName=KH;function I_(t){return t?"checked":"unchecked"}var YH=T_,ZH=O_;function yp({className:t,...s}){return e.jsx(YH,{"data-slot":"switch",className:Nt("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-switch-background focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(ZH,{"data-slot":"switch-thumb",className:Nt("bg-card dark:data-[state=unchecked]:bg-card-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}var Jg,qS;function QH(){if(qS)return Jg;qS=1;function t(){this.__data__=[],this.size=0}return Jg=t,Jg}var e0,zS;function M_(){if(zS)return e0;zS=1;function t(s,n){return s===n||s!==s&&n!==n}return e0=t,e0}var t0,US;function bp(){if(US)return t0;US=1;var t=M_();function s(n,r){for(var a=n.length;a--;)if(t(n[a][0],r))return a;return-1}return t0=s,t0}var s0,VS;function XH(){if(VS)return s0;VS=1;var t=bp(),s=Array.prototype,n=s.splice;function r(a){var i=this.__data__,o=t(i,a);if(o<0)return!1;var d=i.length-1;return o==d?i.pop():n.call(i,o,1),--this.size,!0}return s0=r,s0}var n0,HS;function JH(){if(HS)return n0;HS=1;var t=bp();function s(n){var r=this.__data__,a=t(r,n);return a<0?void 0:r[a][1]}return n0=s,n0}var r0,WS;function eW(){if(WS)return r0;WS=1;var t=bp();function s(n){return t(this.__data__,n)>-1}return r0=s,r0}var a0,GS;function tW(){if(GS)return a0;GS=1;var t=bp();function s(n,r){var a=this.__data__,i=t(a,n);return i<0?(++this.size,a.push([n,r])):a[i][1]=r,this}return a0=s,a0}var i0,KS;function jp(){if(KS)return i0;KS=1;var t=QH(),s=XH(),n=JH(),r=eW(),a=tW();function i(o){var d=-1,m=o==null?0:o.length;for(this.clear();++du))return!1;var v=h.get(o),w=h.get(d);if(v&&w)return v==d&&w==o;var j=-1,b=!0,C=m&a?new t:void 0;for(h.set(o,d),h.set(d,o);++j-1&&r%1==0&&r-1&&n%1==0&&n<=t}return uv=s,uv}var hv,t2;function HW(){if(t2)return hv;t2=1;var t=Np(),s=H_(),n=Cp(),r="[object Arguments]",a="[object Array]",i="[object Boolean]",o="[object Date]",d="[object Error]",m="[object Function]",f="[object Map]",p="[object Number]",h="[object Object]",x="[object RegExp]",u="[object Set]",N="[object String]",v="[object WeakMap]",w="[object ArrayBuffer]",j="[object DataView]",b="[object Float32Array]",C="[object Float64Array]",S="[object Int8Array]",D="[object Int16Array]",_="[object Int32Array]",A="[object Uint8Array]",E="[object Uint8ClampedArray]",q="[object Uint16Array]",O="[object Uint32Array]",R={};R[b]=R[C]=R[S]=R[D]=R[_]=R[A]=R[E]=R[q]=R[O]=!0,R[r]=R[a]=R[w]=R[i]=R[j]=R[o]=R[d]=R[m]=R[f]=R[p]=R[h]=R[x]=R[u]=R[N]=R[v]=!1;function P(L){return n(L)&&s(L.length)&&!!R[t(L)]}return hv=P,hv}var mv,s2;function WW(){if(s2)return mv;s2=1;function t(s){return function(n){return s(n)}}return mv=t,mv}var gu={exports:{}};gu.exports;var n2;function GW(){return n2||(n2=1,(function(t,s){var n=F_(),r=s&&!s.nodeType&&s,a=r&&!0&&t&&!t.nodeType&&t,i=a&&a.exports===r,o=i&&n.process,d=(function(){try{var m=a&&a.require&&a.require("util").types;return m||o&&o.binding&&o.binding("util")}catch{}})();t.exports=d})(gu,gu.exports)),gu.exports}var fv,r2;function W_(){if(r2)return fv;r2=1;var t=HW(),s=WW(),n=GW(),r=n&&n.isTypedArray,a=r?s(r):t;return fv=a,fv}var pv,a2;function KW(){if(a2)return pv;a2=1;var t=$W(),s=zW(),n=xj(),r=V_(),a=VW(),i=W_(),o=Object.prototype,d=o.hasOwnProperty;function m(f,p){var h=n(f),x=!h&&s(f),u=!h&&!x&&r(f),N=!h&&!x&&!u&&i(f),v=h||x||u||N,w=v?t(f.length,String):[],j=w.length;for(var b in f)(p||d.call(f,b))&&!(v&&(b=="length"||u&&(b=="offset"||b=="parent")||N&&(b=="buffer"||b=="byteLength"||b=="byteOffset")||a(b,j)))&&w.push(b);return w}return pv=m,pv}var xv,i2;function YW(){if(i2)return xv;i2=1;var t=Object.prototype;function s(n){var r=n&&n.constructor,a=typeof r=="function"&&r.prototype||t;return n===a}return xv=s,xv}var gv,l2;function ZW(){if(l2)return gv;l2=1;function t(s,n){return function(r){return s(n(r))}}return gv=t,gv}var vv,o2;function QW(){if(o2)return vv;o2=1;var t=ZW(),s=t(Object.keys,Object);return vv=s,vv}var yv,c2;function XW(){if(c2)return yv;c2=1;var t=YW(),s=QW(),n=Object.prototype,r=n.hasOwnProperty;function a(i){if(!t(i))return s(i);var o=[];for(var d in Object(i))r.call(i,d)&&d!="constructor"&&o.push(d);return o}return yv=a,yv}var bv,d2;function JW(){if(d2)return bv;d2=1;var t=$_(),s=H_();function n(r){return r!=null&&s(r.length)&&!t(r)}return bv=n,bv}var jv,u2;function eG(){if(u2)return jv;u2=1;var t=KW(),s=XW(),n=JW();function r(a){return n(a)?t(a):s(a)}return jv=r,jv}var Nv,h2;function tG(){if(h2)return Nv;h2=1;var t=IW(),s=BW(),n=eG();function r(a){return t(a,n,s)}return Nv=r,Nv}var wv,m2;function sG(){if(m2)return wv;m2=1;var t=tG(),s=1,n=Object.prototype,r=n.hasOwnProperty;function a(i,o,d,m,f,p){var h=d&s,x=t(i),u=x.length,N=t(o),v=N.length;if(u!=v&&!h)return!1;for(var w=u;w--;){var j=x[w];if(!(h?j in o:r.call(o,j)))return!1}var b=p.get(i),C=p.get(o);if(b&&C)return b==o&&C==i;var S=!0;p.set(i,o),p.set(o,i);for(var D=h;++w1)return w.map(function(S){return v(S)});var b=w[0];if(typeof b.blotName!="string"&&typeof b.attrName!="string")throw new o("Invalid definition");if(b.blotName==="abstract")throw new o("Cannot register abstract class");if(p[b.blotName||b.attrName]=b,typeof b.keyName=="string")d[b.keyName]=b;else if(b.className!=null&&(m[b.className]=b),b.tagName!=null){Array.isArray(b.tagName)?b.tagName=b.tagName.map(function(S){return S.toUpperCase()}):b.tagName=b.tagName.toUpperCase();var C=Array.isArray(b.tagName)?b.tagName:[b.tagName];C.forEach(function(S){(f[S]==null||b.className==null)&&(f[S]=b)})}return b}r.register=v}),(function(n,r,a){var i=a(51),o=a(11),d=a(3),m=a(20),f="\0",p=function(h){Array.isArray(h)?this.ops=h:h!=null&&Array.isArray(h.ops)?this.ops=h.ops:this.ops=[]};p.prototype.insert=function(h,x){var u={};return h.length===0?this:(u.insert=h,x!=null&&typeof x=="object"&&Object.keys(x).length>0&&(u.attributes=x),this.push(u))},p.prototype.delete=function(h){return h<=0?this:this.push({delete:h})},p.prototype.retain=function(h,x){if(h<=0)return this;var u={retain:h};return x!=null&&typeof x=="object"&&Object.keys(x).length>0&&(u.attributes=x),this.push(u)},p.prototype.push=function(h){var x=this.ops.length,u=this.ops[x-1];if(h=d(!0,{},h),typeof u=="object"){if(typeof h.delete=="number"&&typeof u.delete=="number")return this.ops[x-1]={delete:u.delete+h.delete},this;if(typeof u.delete=="number"&&h.insert!=null&&(x-=1,u=this.ops[x-1],typeof u!="object"))return this.ops.unshift(h),this;if(o(h.attributes,u.attributes)){if(typeof h.insert=="string"&&typeof u.insert=="string")return this.ops[x-1]={insert:u.insert+h.insert},typeof h.attributes=="object"&&(this.ops[x-1].attributes=h.attributes),this;if(typeof h.retain=="number"&&typeof u.retain=="number")return this.ops[x-1]={retain:u.retain+h.retain},typeof h.attributes=="object"&&(this.ops[x-1].attributes=h.attributes),this}}return x===this.ops.length?this.ops.push(h):this.ops.splice(x,0,h),this},p.prototype.chop=function(){var h=this.ops[this.ops.length-1];return h&&h.retain&&!h.attributes&&this.ops.pop(),this},p.prototype.filter=function(h){return this.ops.filter(h)},p.prototype.forEach=function(h){this.ops.forEach(h)},p.prototype.map=function(h){return this.ops.map(h)},p.prototype.partition=function(h){var x=[],u=[];return this.forEach(function(N){var v=h(N)?x:u;v.push(N)}),[x,u]},p.prototype.reduce=function(h,x){return this.ops.reduce(h,x)},p.prototype.changeLength=function(){return this.reduce(function(h,x){return x.insert?h+m.length(x):x.delete?h-x.delete:h},0)},p.prototype.length=function(){return this.reduce(function(h,x){return h+m.length(x)},0)},p.prototype.slice=function(h,x){h=h||0,typeof x!="number"&&(x=1/0);for(var u=[],N=m.iterator(this.ops),v=0;v0&&u.next(v.retain-w)}for(var j=new p(N);x.hasNext()||u.hasNext();)if(u.peekType()==="insert")j.push(u.next());else if(x.peekType()==="delete")j.push(x.next());else{var b=Math.min(x.peekLength(),u.peekLength()),C=x.next(b),S=u.next(b);if(typeof S.retain=="number"){var D={};typeof C.retain=="number"?D.retain=b:D.insert=C.insert;var _=m.attributes.compose(C.attributes,S.attributes,typeof C.retain=="number");if(_&&(D.attributes=_),j.push(D),!u.hasNext()&&o(j.ops[j.ops.length-1],D)){var A=new p(x.rest());return j.concat(A).chop()}}else typeof S.delete=="number"&&typeof C.retain=="number"&&j.push(S)}return j.chop()},p.prototype.concat=function(h){var x=new p(this.ops.slice());return h.ops.length>0&&(x.push(h.ops[0]),x.ops=x.ops.concat(h.ops.slice(1))),x},p.prototype.diff=function(h,x){if(this.ops===h.ops)return new p;var u=[this,h].map(function(b){return b.map(function(C){if(C.insert!=null)return typeof C.insert=="string"?C.insert:f;var S=b===h?"on":"with";throw new Error("diff() called "+S+" non-document")}).join("")}),N=new p,v=i(u[0],u[1],x),w=m.iterator(this.ops),j=m.iterator(h.ops);return v.forEach(function(b){for(var C=b[1].length;C>0;){var S=0;switch(b[0]){case i.INSERT:S=Math.min(j.peekLength(),C),N.push(j.next(S));break;case i.DELETE:S=Math.min(C,w.peekLength()),w.next(S),N.delete(S);break;case i.EQUAL:S=Math.min(w.peekLength(),j.peekLength(),C);var D=w.next(S),_=j.next(S);o(D.insert,_.insert)?N.retain(S,m.attributes.diff(D.attributes,_.attributes)):N.push(_).delete(S);break}C-=S}}),N.chop()},p.prototype.eachLine=function(h,x){x=x||` `;for(var u=m.iterator(this.ops),N=new p,v=0;u.hasNext();){if(u.peekType()!=="insert")return;var w=u.peek(),j=m.length(w)-u.peekLength(),b=typeof w.insert=="string"?w.insert.indexOf(x,j)-j:-1;if(b<0)N.push(u.next());else if(b>0)N.push(u.next(b));else{if(h(N,u.next(1).attributes||{},v)===!1)return;v+=1,N=new p}}N.length()>0&&h(N,{},v)},p.prototype.transform=function(h,x){if(x=!!x,typeof h=="number")return this.transformPosition(h,x);for(var u=m.iterator(this.ops),N=m.iterator(h.ops),v=new p;u.hasNext()||N.hasNext();)if(u.peekType()==="insert"&&(x||N.peekType()!=="insert"))v.retain(m.length(u.next()));else if(N.peekType()==="insert")v.push(N.next());else{var w=Math.min(u.peekLength(),N.peekLength()),j=u.next(w),b=N.next(w);if(j.delete)continue;b.delete?v.push(b):v.retain(w,m.attributes.transform(j.attributes,b.attributes,x))}return v.chop()},p.prototype.transformPosition=function(h,x){x=!!x;for(var u=m.iterator(this.ops),N=0;u.hasNext()&&N<=h;){var v=u.peekLength(),w=u.peekType();if(u.next(),w==="delete"){h-=Math.min(v,h-N);continue}else w==="insert"&&(N"u"||a.call(u,w)},p=function(u,N){o&&N.name==="__proto__"?o(u,N.name,{enumerable:!0,configurable:!0,value:N.newValue,writable:!0}):u[N.name]=N.newValue},h=function(u,N){if(N==="__proto__")if(a.call(u,N)){if(d)return d(u,N).value}else return;return u[N]};n.exports=function x(){var u,N,v,w,j,b,C=arguments[0],S=1,D=arguments.length,_=!1;for(typeof C=="boolean"&&(_=C,C=arguments[1]||{},S=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});S0&&($1&&arguments[1]!==void 0?arguments[1]:!1;if(Z&&($===0||$>=this.length()-A)){var Q=this.clone();return $===0?(this.parent.insertBefore(Q,this),this):(this.parent.insertBefore(Q,this.next),Q)}else{var W=o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"split",this).call(this,$,Z);return this.cache={},W}}}]),P})(x.default.Block);q.blotName="block",q.tagName="P",q.defaultChild="break",q.allowedChildren=[w.default,x.default.Embed,b.default];function O(R){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return R==null||(typeof R.formats=="function"&&(P=(0,m.default)(P,R.formats())),R.parent==null||R.parent.blotName=="scroll"||R.parent.statics.scope!==R.statics.scope)?P:O(R.parent,P)}r.bubbleFormats=O,r.BlockEmbed=E,r.default=q}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.overload=r.expandConfig=void 0;var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(M){return typeof M}:function(M){return M&&typeof Symbol=="function"&&M.constructor===Symbol&&M!==Symbol.prototype?"symbol":typeof M},o=(function(){function M(z,T){var F=[],I=!0,K=!1,G=void 0;try{for(var V=z[Symbol.iterator](),Y;!(I=(Y=V.next()).done)&&(F.push(Y.value),!(T&&F.length===T));I=!0);}catch(re){K=!0,G=re}finally{try{!I&&V.return&&V.return()}finally{if(K)throw G}}return F}return function(z,T){if(Array.isArray(z))return z;if(Symbol.iterator in Object(z))return M(z,T);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function M(z,T){for(var F=0;F2&&arguments[2]!==void 0?arguments[2]:!1;if(typeof T!="string"){var G=T.attrName||T.blotName;typeof G=="string"?this.register("formats/"+G,T,F):Object.keys(T).forEach(function(V){I.register(V,T[V],F)})}else this.imports[T]!=null&&!K&&L.warn("Overwriting "+T+" with",F),this.imports[T]=F,(T.startsWith("blots/")||T.startsWith("formats/"))&&F.blotName!=="abstract"?j.default.register(F):T.startsWith("modules")&&typeof F.register=="function"&&F.register()}}]);function M(z){var T=this,F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(P(this,M),this.options=Z(z,F),this.container=this.options.container,this.container==null)return L.error("Invalid Quill container",z);this.options.debug&&M.debug(this.options.debug);var I=this.container.innerHTML.trim();this.container.classList.add("ql-container"),this.container.innerHTML="",this.container.__quill=this,this.root=this.addContainer("ql-editor"),this.root.classList.add("ql-blank"),this.root.setAttribute("data-gramm",!1),this.scrollingContainer=this.options.scrollingContainer||this.root,this.emitter=new u.default,this.scroll=j.default.create(this.root,{emitter:this.emitter,whitelist:this.options.formats}),this.editor=new h.default(this.scroll),this.selection=new C.default(this.scroll,this.emitter),this.theme=new this.options.theme(this,this.options),this.keyboard=this.theme.addModule("keyboard"),this.clipboard=this.theme.addModule("clipboard"),this.history=this.theme.addModule("history"),this.theme.init(),this.emitter.on(u.default.events.EDITOR_CHANGE,function(G){G===u.default.events.TEXT_CHANGE&&T.root.classList.toggle("ql-blank",T.editor.isBlank())}),this.emitter.on(u.default.events.SCROLL_UPDATE,function(G,V){var Y=T.selection.lastRange,re=Y&&Y.length===0?Y.index:void 0;Q.call(T,function(){return T.editor.update(null,V,re)},G)});var K=this.clipboard.convert(`
`+I+"


");this.setContents(K),this.history.clear(),this.options.placeholder&&this.root.setAttribute("data-placeholder",this.options.placeholder),this.options.readOnly&&this.disable()}return d(M,[{key:"addContainer",value:function(T){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(typeof T=="string"){var I=T;T=document.createElement("div"),T.classList.add(I)}return this.container.insertBefore(T,F),T}},{key:"blur",value:function(){this.selection.setRange(null)}},{key:"deleteText",value:function(T,F,I){var K=this,G=W(T,F,I),V=o(G,4);return T=V[0],F=V[1],I=V[3],Q.call(this,function(){return K.editor.deleteText(T,F)},I,T,-1*F)}},{key:"disable",value:function(){this.enable(!1)}},{key:"enable",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.scroll.enable(T),this.container.classList.toggle("ql-disabled",!T)}},{key:"focus",value:function(){var T=this.scrollingContainer.scrollTop;this.selection.focus(),this.scrollingContainer.scrollTop=T,this.scrollIntoView()}},{key:"format",value:function(T,F){var I=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:u.default.sources.API;return Q.call(this,function(){var G=I.getSelection(!0),V=new f.default;if(G==null)return V;if(j.default.query(T,j.default.Scope.BLOCK))V=I.editor.formatLine(G.index,G.length,R({},T,F));else{if(G.length===0)return I.selection.format(T,F),V;V=I.editor.formatText(G.index,G.length,R({},T,F))}return I.setSelection(G,u.default.sources.SILENT),V},K)}},{key:"formatLine",value:function(T,F,I,K,G){var V=this,Y=void 0,re=W(T,F,I,K,G),ae=o(re,4);return T=ae[0],F=ae[1],Y=ae[2],G=ae[3],Q.call(this,function(){return V.editor.formatLine(T,F,Y)},G,T,0)}},{key:"formatText",value:function(T,F,I,K,G){var V=this,Y=void 0,re=W(T,F,I,K,G),ae=o(re,4);return T=ae[0],F=ae[1],Y=ae[2],G=ae[3],Q.call(this,function(){return V.editor.formatText(T,F,Y)},G,T,0)}},{key:"getBounds",value:function(T){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,I=void 0;typeof T=="number"?I=this.selection.getBounds(T,F):I=this.selection.getBounds(T.index,T.length);var K=this.container.getBoundingClientRect();return{bottom:I.bottom-K.top,height:I.height,left:I.left-K.left,right:I.right-K.left,top:I.top-K.top,width:I.width}}},{key:"getContents",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getLength()-T,I=W(T,F),K=o(I,2);return T=K[0],F=K[1],this.editor.getContents(T,F)}},{key:"getFormat",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.getSelection(!0),F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return typeof T=="number"?this.editor.getFormat(T,F):this.editor.getFormat(T.index,T.length)}},{key:"getIndex",value:function(T){return T.offset(this.scroll)}},{key:"getLength",value:function(){return this.scroll.length()}},{key:"getLeaf",value:function(T){return this.scroll.leaf(T)}},{key:"getLine",value:function(T){return this.scroll.line(T)}},{key:"getLines",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE;return typeof T!="number"?this.scroll.lines(T.index,T.length):this.scroll.lines(T,F)}},{key:"getModule",value:function(T){return this.theme.modules[T]}},{key:"getSelection",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;return T&&this.focus(),this.update(),this.selection.getRange()[0]}},{key:"getText",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getLength()-T,I=W(T,F),K=o(I,2);return T=K[0],F=K[1],this.editor.getText(T,F)}},{key:"hasFocus",value:function(){return this.selection.hasFocus()}},{key:"insertEmbed",value:function(T,F,I){var K=this,G=arguments.length>3&&arguments[3]!==void 0?arguments[3]:M.sources.API;return Q.call(this,function(){return K.editor.insertEmbed(T,F,I)},G,T)}},{key:"insertText",value:function(T,F,I,K,G){var V=this,Y=void 0,re=W(T,0,I,K,G),ae=o(re,4);return T=ae[0],Y=ae[2],G=ae[3],Q.call(this,function(){return V.editor.insertText(T,F,Y)},G,T,F.length)}},{key:"isEnabled",value:function(){return!this.container.classList.contains("ql-disabled")}},{key:"off",value:function(){return this.emitter.off.apply(this.emitter,arguments)}},{key:"on",value:function(){return this.emitter.on.apply(this.emitter,arguments)}},{key:"once",value:function(){return this.emitter.once.apply(this.emitter,arguments)}},{key:"pasteHTML",value:function(T,F,I){this.clipboard.dangerouslyPasteHTML(T,F,I)}},{key:"removeFormat",value:function(T,F,I){var K=this,G=W(T,F,I),V=o(G,4);return T=V[0],F=V[1],I=V[3],Q.call(this,function(){return K.editor.removeFormat(T,F)},I,T)}},{key:"scrollIntoView",value:function(){this.selection.scrollIntoView(this.scrollingContainer)}},{key:"setContents",value:function(T){var F=this,I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:u.default.sources.API;return Q.call(this,function(){T=new f.default(T);var K=F.getLength(),G=F.editor.deleteText(0,K),V=F.editor.applyDelta(T),Y=V.ops[V.ops.length-1];Y!=null&&typeof Y.insert=="string"&&Y.insert[Y.insert.length-1]===` `&&(F.editor.deleteText(F.getLength()-1,1),V.delete(1));var re=G.compose(V);return re},I)}},{key:"setSelection",value:function(T,F,I){if(T==null)this.selection.setRange(null,F||M.sources.API);else{var K=W(T,F,I),G=o(K,4);T=G[0],F=G[1],I=G[3],this.selection.setRange(new b.Range(T,F),I),I!==u.default.sources.SILENT&&this.selection.scrollIntoView(this.scrollingContainer)}}},{key:"setText",value:function(T){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:u.default.sources.API,I=new f.default().insert(T);return this.setContents(I,F)}},{key:"update",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:u.default.sources.USER,F=this.scroll.update(T);return this.selection.update(T),F}},{key:"updateContents",value:function(T){var F=this,I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:u.default.sources.API;return Q.call(this,function(){return T=new f.default(T),F.editor.applyDelta(T,I)},I,!0)}}]),M})();$.DEFAULTS={bounds:null,formats:null,modules:{},placeholder:"",readOnly:!1,scrollingContainer:null,strict:!0,theme:"default"},$.events=u.default.events,$.sources=u.default.sources,$.version="1.3.7",$.imports={delta:f.default,parchment:j.default,"core/module":v.default,"core/theme":q.default};function Z(M,z){if(z=(0,D.default)(!0,{container:M,modules:{clipboard:!0,keyboard:!0,history:!0}},z),!z.theme||z.theme===$.DEFAULTS.theme)z.theme=q.default;else if(z.theme=$.import("themes/"+z.theme),z.theme==null)throw new Error("Invalid theme "+z.theme+". Did you register it?");var T=(0,D.default)(!0,{},z.theme.DEFAULTS);[T,z].forEach(function(K){K.modules=K.modules||{},Object.keys(K.modules).forEach(function(G){K.modules[G]===!0&&(K.modules[G]={})})});var F=Object.keys(T.modules).concat(Object.keys(z.modules)),I=F.reduce(function(K,G){var V=$.import("modules/"+G);return V==null?L.error("Cannot load "+G+" module. Are you sure you registered it?"):K[G]=V.DEFAULTS||{},K},{});return z.modules!=null&&z.modules.toolbar&&z.modules.toolbar.constructor!==Object&&(z.modules.toolbar={container:z.modules.toolbar}),z=(0,D.default)(!0,{},$.DEFAULTS,{modules:I},T,z),["bounds","container","scrollingContainer"].forEach(function(K){typeof z[K]=="string"&&(z[K]=document.querySelector(z[K]))}),z.modules=Object.keys(z.modules).reduce(function(K,G){return z.modules[G]&&(K[G]=z.modules[G]),K},{}),z}function Q(M,z,T,F){if(this.options.strict&&!this.isEnabled()&&z===u.default.sources.USER)return new f.default;var I=T==null?null:this.getSelection(),K=this.editor.delta,G=M();if(I!=null&&(T===!0&&(T=I.index),F==null?I=U(I,G,z):F!==0&&(I=U(I,T,F,z)),this.setSelection(I,u.default.sources.SILENT)),G.length()>0){var V,Y=[u.default.events.TEXT_CHANGE,G,K,z];if((V=this.emitter).emit.apply(V,[u.default.events.EDITOR_CHANGE].concat(Y)),z!==u.default.sources.SILENT){var re;(re=this.emitter).emit.apply(re,Y)}}return G}function W(M,z,T,F,I){var K={};return typeof M.index=="number"&&typeof M.length=="number"?typeof z!="number"?(I=F,F=T,T=z,z=M.length,M=M.index):(z=M.length,M=M.index):typeof z!="number"&&(I=F,F=T,T=z,z=0),(typeof T>"u"?"undefined":i(T))==="object"?(K=T,I=F):typeof T=="string"&&(F!=null?K[T]=F:I=T),I=I||u.default.sources.API,[M,z,K,I]}function U(M,z,T,F){if(M==null)return null;var I=void 0,K=void 0;if(z instanceof f.default){var G=[M.index,M.index+M.length].map(function(ae){return z.transformPosition(ae,F!==u.default.sources.USER)}),V=o(G,2);I=V[0],K=V[1]}else{var Y=[M.index,M.index+M.length].map(function(ae){return ae=0?ae+T:Math.max(z,ae+T)}),re=o(Y,2);I=re[0],K=re[1]}return new b.Range(I,K-I)}r.expandConfig=Z,r.overload=W,r.default=$}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function w(j,b){for(var C=0;C0){var S=this.parent.isolate(this.offset(),this.length());this.moveChildren(S),S.wrap(this)}}}],[{key:"compare",value:function(C,S){var D=j.order.indexOf(C),_=j.order.indexOf(S);return D>=0||_>=0?D-_:C===S?0:C1?_-1:0),E=1;E<_;E++)A[E-1]=arguments[E];(this.listeners[D.type]||[]).forEach(function(q){var O=q.node,R=q.handler;(D.target===O||O.contains(D.target))&&R.apply(void 0,[D].concat(A))})}},{key:"listenDOM",value:function(D,_,A){this.listeners[D]||(this.listeners[D]=[]),this.listeners[D].push({node:_,handler:A})}}]),C})(m.default);j.events={EDITOR_CHANGE:"editor-change",SCROLL_BEFORE_UPDATE:"scroll-before-update",SCROLL_OPTIMIZE:"scroll-optimize",SCROLL_UPDATE:"scroll-update",SELECTION_CHANGE:"selection-change",TEXT_CHANGE:"text-change"},j.sources={API:"api",SILENT:"silent",USER:"user"},r.default=j}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});function i(d,m){if(!(d instanceof m))throw new TypeError("Cannot call a class as a function")}var o=function d(m){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};i(this,d),this.quill=m,this.options=f};o.DEFAULTS={},r.default=o}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=["error","warn","log","info"],o="warn";function d(f){if(i.indexOf(f)<=i.indexOf(o)){for(var p,h=arguments.length,x=Array(h>1?h-1:0),u=1;u0&&typeof x[0]!="number")}function h(x,u,N){var v,w;if(f(x)||f(u)||x.prototype!==u.prototype)return!1;if(d(x))return d(u)?(x=i.call(x),u=i.call(u),m(x,u,N)):!1;if(p(x)){if(!p(u)||x.length!==u.length)return!1;for(v=0;v=0;v--)if(j[v]!=b[v])return!1;for(v=j.length-1;v>=0;v--)if(w=j[v],!m(x[w],u[w],N))return!1;return typeof x==typeof u}}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(1),o=(function(){function d(m,f,p){p===void 0&&(p={}),this.attrName=m,this.keyName=f;var h=i.Scope.TYPE&i.Scope.ATTRIBUTE;p.scope!=null?this.scope=p.scope&i.Scope.LEVEL|h:this.scope=i.Scope.ATTRIBUTE,p.whitelist!=null&&(this.whitelist=p.whitelist)}return d.keys=function(m){return[].map.call(m.attributes,function(f){return f.name})},d.prototype.add=function(m,f){return this.canAdd(m,f)?(m.setAttribute(this.keyName,f),!0):!1},d.prototype.canAdd=function(m,f){var p=i.query(m,i.Scope.BLOT&(this.scope|i.Scope.TYPE));return p==null?!1:this.whitelist==null?!0:typeof f=="string"?this.whitelist.indexOf(f.replace(/["']/g,""))>-1:this.whitelist.indexOf(f)>-1},d.prototype.remove=function(m){m.removeAttribute(this.keyName)},d.prototype.value=function(m){var f=m.getAttribute(this.keyName);return this.canAdd(m,f)&&f?f:""},d})();r.default=o}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.Code=void 0;var i=(function(){function E(q,O){var R=[],P=!0,L=!1,$=void 0;try{for(var Z=q[Symbol.iterator](),Q;!(P=(Q=Z.next()).done)&&(R.push(Q.value),!(O&&R.length===O));P=!0);}catch(W){L=!0,$=W}finally{try{!P&&Z.return&&Z.return()}finally{if(L)throw $}}return R}return function(q,O){if(Array.isArray(q))return q;if(Symbol.iterator in Object(q))return E(q,O);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=(function(){function E(q,O){for(var R=0;R=R+P)){var Q=this.newlineIndex(R,!0)+1,W=Z-Q+1,U=this.isolate(Q,W),M=U.next;U.format(L,$),M instanceof q&&M.formatAt(0,R-Q+P-W,L,$)}}}},{key:"insertAt",value:function(R,P,L){if(L==null){var $=this.descendant(j.default,R),Z=i($,2),Q=Z[0],W=Z[1];Q.insertAt(W,P)}}},{key:"length",value:function(){var R=this.domNode.textContent.length;return this.domNode.textContent.endsWith(` `)?R:R+1}},{key:"newlineIndex",value:function(R){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(P)return this.domNode.textContent.slice(0,R).lastIndexOf(` `);var L=this.domNode.textContent.slice(R).indexOf(` `);return L>-1?R+L:-1}},{key:"optimize",value:function(R){this.domNode.textContent.endsWith(` `)||this.appendChild(h.default.create("text",` `)),d(q.prototype.__proto__||Object.getPrototypeOf(q.prototype),"optimize",this).call(this,R);var P=this.next;P!=null&&P.prev===this&&P.statics.blotName===this.statics.blotName&&this.statics.formats(this.domNode)===P.statics.formats(P.domNode)&&(P.optimize(R),P.moveChildren(this),P.remove())}},{key:"replace",value:function(R){d(q.prototype.__proto__||Object.getPrototypeOf(q.prototype),"replace",this).call(this,R),[].slice.call(this.domNode.querySelectorAll("*")).forEach(function(P){var L=h.default.find(P);L==null?P.parentNode.removeChild(P):L instanceof h.default.Embed?L.remove():L.unwrap()})}}],[{key:"create",value:function(R){var P=d(q.__proto__||Object.getPrototypeOf(q),"create",this).call(this,R);return P.setAttribute("spellcheck",!1),P}},{key:"formats",value:function(){return!0}}]),q})(u.default);A.blotName="code-block",A.tagName="PRE",A.TAB=" ",r.Code=_,r.default=A}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(M){return typeof M}:function(M){return M&&typeof Symbol=="function"&&M.constructor===Symbol&&M!==Symbol.prototype?"symbol":typeof M},o=(function(){function M(z,T){var F=[],I=!0,K=!1,G=void 0;try{for(var V=z[Symbol.iterator](),Y;!(I=(Y=V.next()).done)&&(F.push(Y.value),!(T&&F.length===T));I=!0);}catch(re){K=!0,G=re}finally{try{!I&&V.return&&V.return()}finally{if(K)throw G}}return F}return function(z,T){if(Array.isArray(z))return z;if(Symbol.iterator in Object(z))return M(z,T);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function M(z,T){for(var F=0;F=K&&!ae.endsWith(` `)&&(I=!0),F.scroll.insertAt(G,ae);var ue=F.scroll.line(G),ye=o(ue,2),ce=ye[0],je=ye[1],Me=(0,R.default)({},(0,b.bubbleFormats)(ce));if(ce instanceof C.default){var ut=ce.descendant(u.default.Leaf,je),jt=o(ut,1),ft=jt[0];Me=(0,R.default)(Me,(0,b.bubbleFormats)(ft))}re=h.default.attributes.diff(Me,re)||{}}else if(i(V.insert)==="object"){var X=Object.keys(V.insert)[0];if(X==null)return G;F.scroll.insertAt(G,X,V.insert[X])}K+=Y}return Object.keys(re).forEach(function(Ce){F.scroll.formatAt(G,Y,Ce,re[Ce])}),G+Y},0),T.reduce(function(G,V){return typeof V.delete=="number"?(F.scroll.deleteAt(G,V.delete),G):G+(V.retain||V.insert.length||1)},0),this.scroll.batchEnd(),this.update(T)}},{key:"deleteText",value:function(T,F){return this.scroll.deleteAt(T,F),this.update(new f.default().retain(T).delete(F))}},{key:"formatLine",value:function(T,F){var I=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.scroll.update(),Object.keys(K).forEach(function(G){if(!(I.scroll.whitelist!=null&&!I.scroll.whitelist[G])){var V=I.scroll.lines(T,Math.max(F,1)),Y=F;V.forEach(function(re){var ae=re.length();if(!(re instanceof v.default))re.format(G,K[G]);else{var ue=T-re.offset(I.scroll),ye=re.newlineIndex(ue+Y)-ue+1;re.formatAt(ue,ye,G,K[G])}Y-=ae})}}),this.scroll.optimize(),this.update(new f.default().retain(T).retain(F,(0,A.default)(K)))}},{key:"formatText",value:function(T,F){var I=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return Object.keys(K).forEach(function(G){I.scroll.formatAt(T,F,G,K[G])}),this.update(new f.default().retain(T).retain(F,(0,A.default)(K)))}},{key:"getContents",value:function(T,F){return this.delta.slice(T,T+F)}},{key:"getDelta",value:function(){return this.scroll.lines().reduce(function(T,F){return T.concat(F.delta())},new f.default)}},{key:"getFormat",value:function(T){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,I=[],K=[];F===0?this.scroll.path(T).forEach(function(V){var Y=o(V,1),re=Y[0];re instanceof C.default?I.push(re):re instanceof u.default.Leaf&&K.push(re)}):(I=this.scroll.lines(T,F),K=this.scroll.descendants(u.default.Leaf,T,F));var G=[I,K].map(function(V){if(V.length===0)return{};for(var Y=(0,b.bubbleFormats)(V.shift());Object.keys(Y).length>0;){var re=V.shift();if(re==null)return Y;Y=W((0,b.bubbleFormats)(re),Y)}return Y});return R.default.apply(R.default,G)}},{key:"getText",value:function(T,F){return this.getContents(T,F).filter(function(I){return typeof I.insert=="string"}).map(function(I){return I.insert}).join("")}},{key:"insertEmbed",value:function(T,F,I){return this.scroll.insertAt(T,F,I),this.update(new f.default().retain(T).insert(L({},F,I)))}},{key:"insertText",value:function(T,F){var I=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return F=F.replace(/\r\n/g,` `).replace(/\r/g,` `),this.scroll.insertAt(T,F),Object.keys(K).forEach(function(G){I.scroll.formatAt(T,F.length,G,K[G])}),this.update(new f.default().retain(T).insert(F,(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 T=this.scroll.children.head;return T.statics.blotName!==C.default.blotName||T.children.length>1?!1:T.children.head instanceof D.default}},{key:"removeFormat",value:function(T,F){var I=this.getText(T,F),K=this.scroll.line(T+F),G=o(K,2),V=G[0],Y=G[1],re=0,ae=new f.default;V!=null&&(V instanceof v.default?re=V.newlineIndex(Y)-Y+1:re=V.length()-Y,ae=V.delta().slice(Y,Y+re-1).insert(` `));var ue=this.getContents(T,F+re),ye=ue.diff(new f.default().insert(I).concat(ae)),ce=new f.default().retain(T).concat(ye);return this.applyDelta(ce)}},{key:"update",value:function(T){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],I=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,K=this.delta;if(F.length===1&&F[0].type==="characterData"&&F[0].target.data.match(Z)&&u.default.find(F[0].target)){var G=u.default.find(F[0].target),V=(0,b.bubbleFormats)(G),Y=G.offset(this.scroll),re=F[0].oldValue.replace(j.default.CONTENTS,""),ae=new f.default().insert(re),ue=new f.default().insert(G.value()),ye=new f.default().retain(Y).concat(ae.diff(ue,I));T=ye.reduce(function(ce,je){return je.insert?ce.insert(je.insert,V):ce.push(je)},new f.default),this.delta=K.compose(T)}else this.delta=this.getDelta(),(!T||!(0,q.default)(K.compose(T),this.delta))&&(T=K.diff(this.delta,I));return T}}]),M})();function W(M,z){return Object.keys(z).reduce(function(T,F){return M[F]==null||(z[F]===M[F]?T[F]=z[F]:Array.isArray(z[F])?z[F].indexOf(M[F])<0&&(T[F]=z[F].concat([M[F]])):T[F]=[z[F],M[F]]),T},{})}function U(M){return M.reduce(function(z,T){if(T.insert===1){var F=(0,A.default)(T.attributes);return delete F.image,z.insert({image:T.attributes.image},F)}if(T.attributes!=null&&(T.attributes.list===!0||T.attributes.bullet===!0)&&(T=(0,A.default)(T),T.attributes.list?T.attributes.list="ordered":(T.attributes.list="bullet",delete T.attributes.bullet)),typeof T.insert=="string"){var I=T.insert.replace(/\r\n/g,` `).replace(/\r/g,` `);return z.insert(I,T.attributes)}return z.push(T)},new f.default)}r.default=Q}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.Range=void 0;var i=(function(){function E(q,O){var R=[],P=!0,L=!1,$=void 0;try{for(var Z=q[Symbol.iterator](),Q;!(P=(Q=Z.next()).done)&&(R.push(Q.value),!(O&&R.length===O));P=!0);}catch(W){L=!0,$=W}finally{try{!P&&Z.return&&Z.return()}finally{if(L)throw $}}return R}return function(q,O){if(Array.isArray(q))return q;if(Symbol.iterator in Object(q))return E(q,O);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=(function(){function E(q,O){for(var R=0;R1&&arguments[1]!==void 0?arguments[1]:0;C(this,E),this.index=q,this.length=O},_=(function(){function E(q,O){var R=this;C(this,E),this.emitter=O,this.scroll=q,this.composing=!1,this.mouseDown=!1,this.root=this.scroll.domNode,this.cursor=m.default.create("cursor",this),this.lastRange=this.savedRange=new D(0,0),this.handleComposition(),this.handleDragging(),this.emitter.listenDOM("selectionchange",document,function(){R.mouseDown||setTimeout(R.update.bind(R,N.default.sources.USER),1)}),this.emitter.on(N.default.events.EDITOR_CHANGE,function(P,L){P===N.default.events.TEXT_CHANGE&&L.length()>0&&R.update(N.default.sources.SILENT)}),this.emitter.on(N.default.events.SCROLL_BEFORE_UPDATE,function(){if(R.hasFocus()){var P=R.getNativeRange();P!=null&&P.start.node!==R.cursor.textNode&&R.emitter.once(N.default.events.SCROLL_UPDATE,function(){try{R.setNativeRange(P.start.node,P.start.offset,P.end.node,P.end.offset)}catch{}})}}),this.emitter.on(N.default.events.SCROLL_OPTIMIZE,function(P,L){if(L.range){var $=L.range,Z=$.startNode,Q=$.startOffset,W=$.endNode,U=$.endOffset;R.setNativeRange(Z,Q,W,U)}}),this.update(N.default.sources.SILENT)}return o(E,[{key:"handleComposition",value:function(){var O=this;this.root.addEventListener("compositionstart",function(){O.composing=!0}),this.root.addEventListener("compositionend",function(){if(O.composing=!1,O.cursor.parent){var R=O.cursor.restore();if(!R)return;setTimeout(function(){O.setNativeRange(R.startNode,R.startOffset,R.endNode,R.endOffset)},1)}})}},{key:"handleDragging",value:function(){var O=this;this.emitter.listenDOM("mousedown",document.body,function(){O.mouseDown=!0}),this.emitter.listenDOM("mouseup",document.body,function(){O.mouseDown=!1,O.update(N.default.sources.USER)})}},{key:"focus",value:function(){this.hasFocus()||(this.root.focus(),this.setRange(this.savedRange))}},{key:"format",value:function(O,R){if(!(this.scroll.whitelist!=null&&!this.scroll.whitelist[O])){this.scroll.update();var P=this.getNativeRange();if(!(P==null||!P.native.collapsed||m.default.query(O,m.default.Scope.BLOCK))){if(P.start.node!==this.cursor.textNode){var L=m.default.find(P.start.node,!1);if(L==null)return;if(L instanceof m.default.Leaf){var $=L.split(P.start.offset);L.parent.insertBefore(this.cursor,$)}else L.insertBefore(this.cursor,P.start.node);this.cursor.attach()}this.cursor.format(O,R),this.scroll.optimize(),this.setNativeRange(this.cursor.textNode,this.cursor.textNode.data.length),this.update()}}}},{key:"getBounds",value:function(O){var R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,P=this.scroll.length();O=Math.min(O,P-1),R=Math.min(O+R,P-1)-O;var L=void 0,$=this.scroll.leaf(O),Z=i($,2),Q=Z[0],W=Z[1];if(Q==null)return null;var U=Q.position(W,!0),M=i(U,2);L=M[0],W=M[1];var z=document.createRange();if(R>0){z.setStart(L,W);var T=this.scroll.leaf(O+R),F=i(T,2);if(Q=F[0],W=F[1],Q==null)return null;var I=Q.position(W,!0),K=i(I,2);return L=K[0],W=K[1],z.setEnd(L,W),z.getBoundingClientRect()}else{var G="left",V=void 0;return L instanceof Text?(W0&&(G="right")),{bottom:V.top+V.height,height:V.height,left:V[G],right:V[G],top:V.top,width:0}}}},{key:"getNativeRange",value:function(){var O=document.getSelection();if(O==null||O.rangeCount<=0)return null;var R=O.getRangeAt(0);if(R==null)return null;var P=this.normalizeNative(R);return S.info("getNativeRange",P),P}},{key:"getRange",value:function(){var O=this.getNativeRange();if(O==null)return[null,null];var R=this.normalizedToRange(O);return[R,O]}},{key:"hasFocus",value:function(){return document.activeElement===this.root}},{key:"normalizedToRange",value:function(O){var R=this,P=[[O.start.node,O.start.offset]];O.native.collapsed||P.push([O.end.node,O.end.offset]);var L=P.map(function(Q){var W=i(Q,2),U=W[0],M=W[1],z=m.default.find(U,!0),T=z.offset(R.scroll);return M===0?T:z instanceof m.default.Container?T+z.length():T+z.index(U,M)}),$=Math.min(Math.max.apply(Math,b(L)),this.scroll.length()-1),Z=Math.min.apply(Math,[$].concat(b(L)));return new D(Z,$-Z)}},{key:"normalizeNative",value:function(O){if(!A(this.root,O.startContainer)||!O.collapsed&&!A(this.root,O.endContainer))return null;var R={start:{node:O.startContainer,offset:O.startOffset},end:{node:O.endContainer,offset:O.endOffset},native:O};return[R.start,R.end].forEach(function(P){for(var L=P.node,$=P.offset;!(L instanceof Text)&&L.childNodes.length>0;)if(L.childNodes.length>$)L=L.childNodes[$],$=0;else if(L.childNodes.length===$)L=L.lastChild,$=L instanceof Text?L.data.length:L.childNodes.length+1;else break;P.node=L,P.offset=$}),R}},{key:"rangeToNative",value:function(O){var R=this,P=O.collapsed?[O.index]:[O.index,O.index+O.length],L=[],$=this.scroll.length();return P.forEach(function(Z,Q){Z=Math.min($-1,Z);var W=void 0,U=R.scroll.leaf(Z),M=i(U,2),z=M[0],T=M[1],F=z.position(T,Q!==0),I=i(F,2);W=I[0],T=I[1],L.push(W,T)}),L.length<2&&(L=L.concat(L)),L}},{key:"scrollIntoView",value:function(O){var R=this.lastRange;if(R!=null){var P=this.getBounds(R.index,R.length);if(P!=null){var L=this.scroll.length()-1,$=this.scroll.line(Math.min(R.index,L)),Z=i($,1),Q=Z[0],W=Q;if(R.length>0){var U=this.scroll.line(Math.min(R.index+R.length,L)),M=i(U,1);W=M[0]}if(!(Q==null||W==null)){var z=O.getBoundingClientRect();P.topz.bottom&&(O.scrollTop+=P.bottom-z.bottom)}}}}},{key:"setNativeRange",value:function(O,R){var P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:O,L=arguments.length>3&&arguments[3]!==void 0?arguments[3]:R,$=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;if(S.info("setNativeRange",O,R,P,L),!(O!=null&&(this.root.parentNode==null||O.parentNode==null||P.parentNode==null))){var Z=document.getSelection();if(Z!=null)if(O!=null){this.hasFocus()||this.root.focus();var Q=(this.getNativeRange()||{}).native;if(Q==null||$||O!==Q.startContainer||R!==Q.startOffset||P!==Q.endContainer||L!==Q.endOffset){O.tagName=="BR"&&(R=[].indexOf.call(O.parentNode.childNodes,O),O=O.parentNode),P.tagName=="BR"&&(L=[].indexOf.call(P.parentNode.childNodes,P),P=P.parentNode);var W=document.createRange();W.setStart(O,R),W.setEnd(P,L),Z.removeAllRanges(),Z.addRange(W)}}else Z.removeAllRanges(),this.root.blur(),document.body.focus()}}},{key:"setRange",value:function(O){var R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:N.default.sources.API;if(typeof R=="string"&&(P=R,R=!1),S.info("setRange",O),O!=null){var L=this.rangeToNative(O);this.setNativeRange.apply(this,b(L).concat([R]))}else this.setNativeRange(null);this.update(P)}},{key:"update",value:function(){var O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:N.default.sources.USER,R=this.lastRange,P=this.getRange(),L=i(P,2),$=L[0],Z=L[1];if(this.lastRange=$,this.lastRange!=null&&(this.savedRange=this.lastRange),!(0,x.default)(R,this.lastRange)){var Q;!this.composing&&Z!=null&&Z.native.collapsed&&Z.start.node!==this.cursor.textNode&&this.cursor.restore();var W=[N.default.events.SELECTION_CHANGE,(0,p.default)(this.lastRange),(0,p.default)(R),O];if((Q=this.emitter).emit.apply(Q,[N.default.events.EDITOR_CHANGE].concat(W)),O!==N.default.sources.SILENT){var U;(U=this.emitter).emit.apply(U,W)}}}}]),E})();function A(E,q){try{q.parentNode}catch{return!1}return q instanceof Text&&(q=q.parentNode),E.contains(q)}r.Range=D,r.default=_}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function N(v,w){for(var j=0;j0&&(u+=1),[this.parent.domNode,u]},p.prototype.value=function(){var h;return h={},h[this.statics.blotName]=this.statics.value(this.domNode)||!0,h},p.scope=d.Scope.INLINE_BLOT,p})(o.default);r.default=m}),(function(n,r,a){var i=a(11),o=a(3),d={attributes:{compose:function(f,p,h){typeof f!="object"&&(f={}),typeof p!="object"&&(p={});var x=o(!0,{},p);h||(x=Object.keys(x).reduce(function(N,v){return x[v]!=null&&(N[v]=x[v]),N},{}));for(var u in f)f[u]!==void 0&&p[u]===void 0&&(x[u]=f[u]);return Object.keys(x).length>0?x:void 0},diff:function(f,p){typeof f!="object"&&(f={}),typeof p!="object"&&(p={});var h=Object.keys(f).concat(Object.keys(p)).reduce(function(x,u){return i(f[u],p[u])||(x[u]=p[u]===void 0?null:p[u]),x},{});return Object.keys(h).length>0?h:void 0},transform:function(f,p,h){if(typeof f!="object")return p;if(typeof p=="object"){if(!h)return p;var x=Object.keys(p).reduce(function(u,N){return f[N]===void 0&&(u[N]=p[N]),u},{});return Object.keys(x).length>0?x:void 0}}},iterator:function(f){return new m(f)},length:function(f){return typeof f.delete=="number"?f.delete:typeof f.retain=="number"?f.retain:typeof f.insert=="string"?f.insert.length:1}};function m(f){this.ops=f,this.index=0,this.offset=0}m.prototype.hasNext=function(){return this.peekLength()<1/0},m.prototype.next=function(f){f||(f=1/0);var p=this.ops[this.index];if(p){var h=this.offset,x=d.length(p);if(f>=x-h?(f=x-h,this.index+=1,this.offset=0):this.offset+=f,typeof p.delete=="number")return{delete:f};var u={};return p.attributes&&(u.attributes=p.attributes),typeof p.retain=="number"?u.retain=f:typeof p.insert=="string"?u.insert=p.insert.substr(h,f):u.insert=p.insert,u}else return{retain:1/0}},m.prototype.peek=function(){return this.ops[this.index]},m.prototype.peekLength=function(){return this.ops[this.index]?d.length(this.ops[this.index])-this.offset:1/0},m.prototype.peekType=function(){return this.ops[this.index]?typeof this.ops[this.index].delete=="number"?"delete":typeof this.ops[this.index].retain=="number"?"retain":"insert":"retain"},m.prototype.rest=function(){if(this.hasNext()){if(this.offset===0)return this.ops.slice(this.index);var f=this.offset,p=this.index,h=this.next(),x=this.ops.slice(this.index);return this.offset=f,this.index=p,[h].concat(x)}else return[]},n.exports=d}),(function(n,r){var a=(function(){function i(v,w){return w!=null&&v instanceof w}var o;try{o=Map}catch{o=function(){}}var d;try{d=Set}catch{d=function(){}}var m;try{m=Promise}catch{m=function(){}}function f(v,w,j,b,C){typeof w=="object"&&(j=w.depth,b=w.prototype,C=w.includeNonEnumerable,w=w.circular);var S=[],D=[],_=typeof Buffer<"u";typeof w>"u"&&(w=!0),typeof j>"u"&&(j=1/0);function A(E,q){if(E===null)return null;if(q===0)return E;var O,R;if(typeof E!="object")return E;if(i(E,o))O=new o;else if(i(E,d))O=new d;else if(i(E,m))O=new m(function(z,T){E.then(function(F){z(A(F,q-1))},function(F){T(A(F,q-1))})});else if(f.__isArray(E))O=[];else if(f.__isRegExp(E))O=new RegExp(E.source,N(E)),E.lastIndex&&(O.lastIndex=E.lastIndex);else if(f.__isDate(E))O=new Date(E.getTime());else{if(_&&Buffer.isBuffer(E))return Buffer.allocUnsafe?O=Buffer.allocUnsafe(E.length):O=new Buffer(E.length),E.copy(O),O;i(E,Error)?O=Object.create(E):typeof b>"u"?(R=Object.getPrototypeOf(E),O=Object.create(R)):(O=Object.create(b),R=b)}if(w){var P=S.indexOf(E);if(P!=-1)return D[P];S.push(E),D.push(O)}i(E,o)&&E.forEach(function(z,T){var F=A(T,q-1),I=A(z,q-1);O.set(F,I)}),i(E,d)&&E.forEach(function(z){var T=A(z,q-1);O.add(T)});for(var L in E){var $;R&&($=Object.getOwnPropertyDescriptor(R,L)),!($&&$.set==null)&&(O[L]=A(E[L],q-1))}if(Object.getOwnPropertySymbols)for(var Z=Object.getOwnPropertySymbols(E),L=0;L0){if(W instanceof x.BlockEmbed||T instanceof x.BlockEmbed){this.optimize();return}if(W instanceof j.default){var F=W.newlineIndex(W.length(),!0);if(F>-1&&(W=W.split(F+1),W===T)){this.optimize();return}}else if(T instanceof j.default){var I=T.newlineIndex(0);I>-1&&T.split(I+1)}var K=T.children.head instanceof v.default?null:T.children.head;W.moveChildren(T,K),W.remove()}this.optimize()}},{key:"enable",value:function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.domNode.setAttribute("contenteditable",L)}},{key:"formatAt",value:function(L,$,Z,Q){this.whitelist!=null&&!this.whitelist[Z]||(d(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"formatAt",this).call(this,L,$,Z,Q),this.optimize())}},{key:"insertAt",value:function(L,$,Z){if(!(Z!=null&&this.whitelist!=null&&!this.whitelist[$])){if(L>=this.length())if(Z==null||f.default.query($,f.default.Scope.BLOCK)==null){var Q=f.default.create(this.statics.defaultChild);this.appendChild(Q),Z==null&&$.endsWith(` `)&&($=$.slice(0,-1)),Q.insertAt(0,$,Z)}else{var W=f.default.create($,Z);this.appendChild(W)}else d(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"insertAt",this).call(this,L,$,Z);this.optimize()}}},{key:"insertBefore",value:function(L,$){if(L.statics.scope===f.default.Scope.INLINE_BLOT){var Z=f.default.create(this.statics.defaultChild);Z.appendChild(L),L=Z}d(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"insertBefore",this).call(this,L,$)}},{key:"leaf",value:function(L){return this.path(L).pop()||[null,-1]}},{key:"line",value:function(L){return L===this.length()?this.line(L-1):this.descendant(E,L)}},{key:"lines",value:function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,$=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE,Z=function Q(W,U,M){var z=[],T=M;return W.children.forEachAt(U,M,function(F,I,K){E(F)?z.push(F):F instanceof f.default.Container&&(z=z.concat(Q(F,I,T))),T-=K}),z};return Z(this,L,$)}},{key:"optimize",value:function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],$=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.batch!==!0&&(d(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"optimize",this).call(this,L,$),L.length>0&&this.emitter.emit(h.default.events.SCROLL_OPTIMIZE,L,$))}},{key:"path",value:function(L){return d(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"path",this).call(this,L).slice(1)}},{key:"update",value:function(L){if(this.batch!==!0){var $=h.default.sources.USER;typeof L=="string"&&($=L),Array.isArray(L)||(L=this.observer.takeRecords()),L.length>0&&this.emitter.emit(h.default.events.SCROLL_BEFORE_UPDATE,$,L),d(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"update",this).call(this,L.concat([])),L.length>0&&this.emitter.emit(h.default.events.SCROLL_UPDATE,$,L)}}}]),R})(f.default.Scroll);q.blotName="scroll",q.className="ql-editor",q.tagName="DIV",q.defaultChild="block",q.allowedChildren=[u.default,x.BlockEmbed,C.default],r.default=q}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.SHORTKEY=r.default=void 0;var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(V){return typeof V}:function(V){return V&&typeof Symbol=="function"&&V.constructor===Symbol&&V!==Symbol.prototype?"symbol":typeof V},o=(function(){function V(Y,re){var ae=[],ue=!0,ye=!1,ce=void 0;try{for(var je=Y[Symbol.iterator](),Me;!(ue=(Me=je.next()).done)&&(ae.push(Me.value),!(re&&ae.length===re));ue=!0);}catch(ut){ye=!0,ce=ut}finally{try{!ue&&je.return&&je.return()}finally{if(ye)throw ce}}return ae}return function(Y,re){if(Array.isArray(Y))return Y;if(Symbol.iterator in Object(Y))return V(Y,re);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function V(Y,re){for(var ae=0;ae1&&arguments[1]!==void 0?arguments[1]:{},ye=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},ce=G(ae);if(ce==null||ce.key==null)return Z.warn("Attempted to add invalid keyboard binding",ce);typeof ue=="function"&&(ue={handler:ue}),typeof ye=="function"&&(ye={handler:ye}),ce=(0,u.default)(ce,ue,ye),this.bindings[ce.key]=this.bindings[ce.key]||[],this.bindings[ce.key].push(ce)}},{key:"listen",value:function(){var ae=this;this.quill.root.addEventListener("keydown",function(ue){if(!ue.defaultPrevented){var ye=ue.which||ue.keyCode,ce=(ae.bindings[ye]||[]).filter(function(ot){return Y.match(ue,ot)});if(ce.length!==0){var je=ae.quill.getSelection();if(!(je==null||!ae.quill.hasFocus())){var Me=ae.quill.getLine(je.index),ut=o(Me,2),jt=ut[0],ft=ut[1],X=ae.quill.getLeaf(je.index),Ce=o(X,2),xe=Ce[0],We=Ce[1],Be=je.length===0?[xe,We]:ae.quill.getLeaf(je.index+je.length),rt=o(Be,2),ht=rt[0],ge=rt[1],Je=xe instanceof C.default.Text?xe.value().slice(0,We):"",mt=ht instanceof C.default.Text?ht.value().slice(ge):"",de={collapsed:je.length===0,empty:je.length===0&&jt.length()<=1,format:ae.quill.getFormat(je),offset:ft,prefix:Je,suffix:mt},at=ce.some(function(ot){if(ot.collapsed!=null&&ot.collapsed!==de.collapsed||ot.empty!=null&&ot.empty!==de.empty||ot.offset!=null&&ot.offset!==de.offset)return!1;if(Array.isArray(ot.format)){if(ot.format.every(function(ke){return de.format[ke]==null}))return!1}else if(i(ot.format)==="object"&&!Object.keys(ot.format).every(function(ke){return ot.format[ke]===!0?de.format[ke]!=null:ot.format[ke]===!1?de.format[ke]==null:(0,h.default)(ot.format[ke],de.format[ke])}))return!1;return ot.prefix!=null&&!ot.prefix.test(de.prefix)||ot.suffix!=null&&!ot.suffix.test(de.suffix)?!1:ot.handler.call(ae,je,de)!==!0});at&&ue.preventDefault()}}}})}}]),Y})(q.default);W.keys={BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46},W.DEFAULTS={bindings:{bold:K("bold"),italic:K("italic"),underline:K("underline"),indent:{key:W.keys.TAB,format:["blockquote","indent","list"],handler:function(Y,re){if(re.collapsed&&re.offset!==0)return!0;this.quill.format("indent","+1",D.default.sources.USER)}},outdent:{key:W.keys.TAB,shiftKey:!0,format:["blockquote","indent","list"],handler:function(Y,re){if(re.collapsed&&re.offset!==0)return!0;this.quill.format("indent","-1",D.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(Y,re){re.format.indent!=null?this.quill.format("indent","-1",D.default.sources.USER):re.format.list!=null&&this.quill.format("list",!1,D.default.sources.USER)}},"indent code-block":I(!0),"outdent code-block":I(!1),"remove tab":{key:W.keys.TAB,shiftKey:!0,collapsed:!0,prefix:/\t$/,handler:function(Y){this.quill.deleteText(Y.index-1,1,D.default.sources.USER)}},tab:{key:W.keys.TAB,handler:function(Y){this.quill.history.cutoff();var re=new v.default().retain(Y.index).delete(Y.length).insert(" ");this.quill.updateContents(re,D.default.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(Y.index+1,D.default.sources.SILENT)}},"list empty enter":{key:W.keys.ENTER,collapsed:!0,format:["list"],empty:!0,handler:function(Y,re){this.quill.format("list",!1,D.default.sources.USER),re.format.indent&&this.quill.format("indent",!1,D.default.sources.USER)}},"checklist enter":{key:W.keys.ENTER,collapsed:!0,format:{list:"checked"},handler:function(Y){var re=this.quill.getLine(Y.index),ae=o(re,2),ue=ae[0],ye=ae[1],ce=(0,u.default)({},ue.formats(),{list:"checked"}),je=new v.default().retain(Y.index).insert(` `,ce).retain(ue.length()-ye-1).retain(1,{list:"unchecked"});this.quill.updateContents(je,D.default.sources.USER),this.quill.setSelection(Y.index+1,D.default.sources.SILENT),this.quill.scrollIntoView()}},"header enter":{key:W.keys.ENTER,collapsed:!0,format:["header"],suffix:/^$/,handler:function(Y,re){var ae=this.quill.getLine(Y.index),ue=o(ae,2),ye=ue[0],ce=ue[1],je=new v.default().retain(Y.index).insert(` `,re.format).retain(ye.length()-ce-1).retain(1,{header:null});this.quill.updateContents(je,D.default.sources.USER),this.quill.setSelection(Y.index+1,D.default.sources.SILENT),this.quill.scrollIntoView()}},"list autofill":{key:" ",collapsed:!0,format:{list:!1},prefix:/^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,handler:function(Y,re){var ae=re.prefix.length,ue=this.quill.getLine(Y.index),ye=o(ue,2),ce=ye[0],je=ye[1];if(je>ae)return!0;var Me=void 0;switch(re.prefix.trim()){case"[]":case"[ ]":Me="unchecked";break;case"[x]":Me="checked";break;case"-":case"*":Me="bullet";break;default:Me="ordered"}this.quill.insertText(Y.index," ",D.default.sources.USER),this.quill.history.cutoff();var ut=new v.default().retain(Y.index-je).delete(ae+1).retain(ce.length()-2-je).retain(1,{list:Me});this.quill.updateContents(ut,D.default.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(Y.index-ae,D.default.sources.SILENT)}},"code exit":{key:W.keys.ENTER,collapsed:!0,format:["code-block"],prefix:/\n\n$/,suffix:/^\s+$/,handler:function(Y){var re=this.quill.getLine(Y.index),ae=o(re,2),ue=ae[0],ye=ae[1],ce=new v.default().retain(Y.index+ue.length()-ye-2).retain(1,{"code-block":null}).delete(1);this.quill.updateContents(ce,D.default.sources.USER)}},"embed left":U(W.keys.LEFT,!1),"embed left shift":U(W.keys.LEFT,!0),"embed right":U(W.keys.RIGHT,!1),"embed right shift":U(W.keys.RIGHT,!0)}};function U(V,Y){var re,ae=V===W.keys.LEFT?"prefix":"suffix";return re={key:V,shiftKey:Y,altKey:null},R(re,ae,/^$/),R(re,"handler",function(ye){var ce=ye.index;V===W.keys.RIGHT&&(ce+=ye.length+1);var je=this.quill.getLeaf(ce),Me=o(je,1),ut=Me[0];return ut instanceof C.default.Embed?(V===W.keys.LEFT?Y?this.quill.setSelection(ye.index-1,ye.length+1,D.default.sources.USER):this.quill.setSelection(ye.index-1,D.default.sources.USER):Y?this.quill.setSelection(ye.index,ye.length+1,D.default.sources.USER):this.quill.setSelection(ye.index+ye.length+1,D.default.sources.USER),!1):!0}),re}function M(V,Y){if(!(V.index===0||this.quill.getLength()<=1)){var re=this.quill.getLine(V.index),ae=o(re,1),ue=ae[0],ye={};if(Y.offset===0){var ce=this.quill.getLine(V.index-1),je=o(ce,1),Me=je[0];if(Me!=null&&Me.length()>1){var ut=ue.formats(),jt=this.quill.getFormat(V.index-1,1);ye=j.default.attributes.diff(ut,jt)||{}}}var ft=/[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(Y.prefix)?2:1;this.quill.deleteText(V.index-ft,ft,D.default.sources.USER),Object.keys(ye).length>0&&this.quill.formatLine(V.index-ft,ft,ye,D.default.sources.USER),this.quill.focus()}}function z(V,Y){var re=/^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(Y.suffix)?2:1;if(!(V.index>=this.quill.getLength()-re)){var ae={},ue=0,ye=this.quill.getLine(V.index),ce=o(ye,1),je=ce[0];if(Y.offset>=je.length()-1){var Me=this.quill.getLine(V.index+1),ut=o(Me,1),jt=ut[0];if(jt){var ft=je.formats(),X=this.quill.getFormat(V.index,1);ae=j.default.attributes.diff(ft,X)||{},ue=jt.length()}}this.quill.deleteText(V.index,re,D.default.sources.USER),Object.keys(ae).length>0&&this.quill.formatLine(V.index+ue-1,re,ae,D.default.sources.USER)}}function T(V){var Y=this.quill.getLines(V),re={};if(Y.length>1){var ae=Y[0].formats(),ue=Y[Y.length-1].formats();re=j.default.attributes.diff(ue,ae)||{}}this.quill.deleteText(V,D.default.sources.USER),Object.keys(re).length>0&&this.quill.formatLine(V.index,1,re,D.default.sources.USER),this.quill.setSelection(V.index,D.default.sources.SILENT),this.quill.focus()}function F(V,Y){var re=this;V.length>0&&this.quill.scroll.deleteAt(V.index,V.length);var ae=Object.keys(Y.format).reduce(function(ue,ye){return C.default.query(ye,C.default.Scope.BLOCK)&&!Array.isArray(Y.format[ye])&&(ue[ye]=Y.format[ye]),ue},{});this.quill.insertText(V.index,` `,ae,D.default.sources.USER),this.quill.setSelection(V.index+1,D.default.sources.SILENT),this.quill.focus(),Object.keys(Y.format).forEach(function(ue){ae[ue]==null&&(Array.isArray(Y.format[ue])||ue!=="link"&&re.quill.format(ue,Y.format[ue],D.default.sources.USER))})}function I(V){return{key:W.keys.TAB,shiftKey:!V,format:{"code-block":!0},handler:function(re){var ae=C.default.query("code-block"),ue=re.index,ye=re.length,ce=this.quill.scroll.descendant(ae,ue),je=o(ce,2),Me=je[0],ut=je[1];if(Me!=null){var jt=this.quill.getIndex(Me),ft=Me.newlineIndex(ut,!0)+1,X=Me.newlineIndex(jt+ut+ye),Ce=Me.domNode.textContent.slice(ft,X).split(` `);ut=0,Ce.forEach(function(xe,We){V?(Me.insertAt(ft+ut,ae.TAB),ut+=ae.TAB.length,We===0?ue+=ae.TAB.length:ye+=ae.TAB.length):xe.startsWith(ae.TAB)&&(Me.deleteAt(ft+ut,ae.TAB.length),ut-=ae.TAB.length,We===0?ue-=ae.TAB.length:ye-=ae.TAB.length),ut+=xe.length+1}),this.quill.update(D.default.sources.USER),this.quill.setSelection(ue,ye,D.default.sources.SILENT)}}}}function K(V){return{key:V[0].toUpperCase(),shortKey:!0,handler:function(re,ae){this.quill.format(V,!ae.format[V],D.default.sources.USER)}}}function G(V){if(typeof V=="string"||typeof V=="number")return G({key:V});if((typeof V>"u"?"undefined":i(V))==="object"&&(V=(0,f.default)(V,!1)),typeof V.key=="string")if(W.keys[V.key.toUpperCase()]!=null)V.key=W.keys[V.key.toUpperCase()];else if(V.key.length===1)V.key=V.key.toUpperCase().charCodeAt(0);else return null;return V.shortKey&&(V[Q]=V.shortKey,delete V.shortKey),V}r.default=W,r.SHORTKEY=Q}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function j(b,C){var S=[],D=!0,_=!1,A=void 0;try{for(var E=b[Symbol.iterator](),q;!(D=(q=E.next()).done)&&(S.push(q.value),!(C&&S.length===C));D=!0);}catch(O){_=!0,A=O}finally{try{!D&&E.return&&E.return()}finally{if(_)throw A}}return S}return function(b,C){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return j(b,C);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=function j(b,C,S){b===null&&(b=Function.prototype);var D=Object.getOwnPropertyDescriptor(b,C);if(D===void 0){var _=Object.getPrototypeOf(b);return _===null?void 0:j(_,C,S)}else{if("value"in D)return D.value;var A=D.get;return A===void 0?void 0:A.call(S)}},d=(function(){function j(b,C){for(var S=0;S-1}r.default=u,r.sanitize=N}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(w){return typeof w}:function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},o=(function(){function w(j,b){for(var C=0;C1&&arguments[1]!==void 0?arguments[1]:!1,S=this.container.querySelector(".ql-selected");if(b!==S&&(S!=null&&S.classList.remove("ql-selected"),b!=null&&(b.classList.add("ql-selected"),this.select.selectedIndex=[].indexOf.call(b.parentNode.children,b),b.hasAttribute("data-value")?this.label.setAttribute("data-value",b.getAttribute("data-value")):this.label.removeAttribute("data-value"),b.hasAttribute("data-label")?this.label.setAttribute("data-label",b.getAttribute("data-label")):this.label.removeAttribute("data-label"),C))){if(typeof Event=="function")this.select.dispatchEvent(new Event("change"));else if((typeof Event>"u"?"undefined":i(Event))==="object"){var D=document.createEvent("Event");D.initEvent("change",!0,!0),this.select.dispatchEvent(D)}this.close()}}},{key:"update",value:function(){var b=void 0;if(this.select.selectedIndex>-1){var C=this.container.querySelector(".ql-picker-options").children[this.select.selectedIndex];b=this.select.options[this.select.selectedIndex],this.selectItem(C)}else this.selectItem(null);var S=b!=null&&b!==this.select.querySelector("option[selected]");this.label.classList.toggle("ql-active",S)}}]),w})();r.default=v}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(0),o=Z(i),d=a(5),m=Z(d),f=a(4),p=Z(f),h=a(16),x=Z(h),u=a(25),N=Z(u),v=a(24),w=Z(v),j=a(35),b=Z(j),C=a(6),S=Z(C),D=a(22),_=Z(D),A=a(7),E=Z(A),q=a(55),O=Z(q),R=a(42),P=Z(R),L=a(23),$=Z(L);function Z(Q){return Q&&Q.__esModule?Q:{default:Q}}m.default.register({"blots/block":p.default,"blots/block/embed":f.BlockEmbed,"blots/break":x.default,"blots/container":N.default,"blots/cursor":w.default,"blots/embed":b.default,"blots/inline":S.default,"blots/scroll":_.default,"blots/text":E.default,"modules/clipboard":O.default,"modules/history":P.default,"modules/keyboard":$.default}),o.default.register(p.default,x.default,w.default,S.default,_.default,E.default),r.default=m.default}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(1),o=(function(){function d(m){this.domNode=m,this.domNode[i.DATA_KEY]={blot:this}}return Object.defineProperty(d.prototype,"statics",{get:function(){return this.constructor},enumerable:!0,configurable:!0}),d.create=function(m){if(this.tagName==null)throw new i.ParchmentError("Blot definition missing tagName");var f;return Array.isArray(this.tagName)?(typeof m=="string"&&(m=m.toUpperCase(),parseInt(m).toString()===m&&(m=parseInt(m))),typeof m=="number"?f=document.createElement(this.tagName[m-1]):this.tagName.indexOf(m)>-1?f=document.createElement(m):f=document.createElement(this.tagName[0])):f=document.createElement(this.tagName),this.className&&f.classList.add(this.className),f},d.prototype.attach=function(){this.parent!=null&&(this.scroll=this.parent.scroll)},d.prototype.clone=function(){var m=this.domNode.cloneNode(!1);return i.create(m)},d.prototype.detach=function(){this.parent!=null&&this.parent.removeChild(this),delete this.domNode[i.DATA_KEY]},d.prototype.deleteAt=function(m,f){var p=this.isolate(m,f);p.remove()},d.prototype.formatAt=function(m,f,p,h){var x=this.isolate(m,f);if(i.query(p,i.Scope.BLOT)!=null&&h)x.wrap(p,h);else if(i.query(p,i.Scope.ATTRIBUTE)!=null){var u=i.create(this.statics.scope);x.wrap(u),u.format(p,h)}},d.prototype.insertAt=function(m,f,p){var h=p==null?i.create("text",f):i.create(f,p),x=this.split(m);this.parent.insertBefore(h,x)},d.prototype.insertInto=function(m,f){f===void 0&&(f=null),this.parent!=null&&this.parent.children.remove(this);var p=null;m.children.insertBefore(this,f),f!=null&&(p=f.domNode),(this.domNode.parentNode!=m.domNode||this.domNode.nextSibling!=p)&&m.domNode.insertBefore(this.domNode,p),this.parent=m,this.attach()},d.prototype.isolate=function(m,f){var p=this.split(m);return p.split(f),p},d.prototype.length=function(){return 1},d.prototype.offset=function(m){return m===void 0&&(m=this.parent),this.parent==null||this==m?0:this.parent.children.offset(this)+this.parent.offset(m)},d.prototype.optimize=function(m){this.domNode[i.DATA_KEY]!=null&&delete this.domNode[i.DATA_KEY].mutations},d.prototype.remove=function(){this.domNode.parentNode!=null&&this.domNode.parentNode.removeChild(this.domNode),this.detach()},d.prototype.replace=function(m){m.parent!=null&&(m.parent.insertBefore(this,m.next),m.remove())},d.prototype.replaceWith=function(m,f){var p=typeof m=="string"?i.create(m,f):m;return p.replace(this),p},d.prototype.split=function(m,f){return m===0?this:this.next},d.prototype.update=function(m,f){},d.prototype.wrap=function(m,f){var p=typeof m=="string"?i.create(m,f):m;return this.parent!=null&&this.parent.insertBefore(p,this.next),p.appendChild(this),p},d.blotName="abstract",d})();r.default=o}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(12),o=a(32),d=a(33),m=a(1),f=(function(){function p(h){this.attributes={},this.domNode=h,this.build()}return p.prototype.attribute=function(h,x){x?h.add(this.domNode,x)&&(h.value(this.domNode)!=null?this.attributes[h.attrName]=h:delete this.attributes[h.attrName]):(h.remove(this.domNode),delete this.attributes[h.attrName])},p.prototype.build=function(){var h=this;this.attributes={};var x=i.default.keys(this.domNode),u=o.default.keys(this.domNode),N=d.default.keys(this.domNode);x.concat(u).concat(N).forEach(function(v){var w=m.query(v,m.Scope.ATTRIBUTE);w instanceof i.default&&(h.attributes[w.attrName]=w)})},p.prototype.copy=function(h){var x=this;Object.keys(this.attributes).forEach(function(u){var N=x.attributes[u].value(x.domNode);h.format(u,N)})},p.prototype.move=function(h){var x=this;this.copy(h),Object.keys(this.attributes).forEach(function(u){x.attributes[u].remove(x.domNode)}),this.attributes={}},p.prototype.values=function(){var h=this;return Object.keys(this.attributes).reduce(function(x,u){return x[u]=h.attributes[u].value(h.domNode),x},{})},p})();r.default=f}),(function(n,r,a){var i=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,h){p.__proto__=h}||function(p,h){for(var x in h)h.hasOwnProperty(x)&&(p[x]=h[x])};return function(p,h){f(p,h);function x(){this.constructor=p}p.prototype=h===null?Object.create(h):(x.prototype=h.prototype,new x)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(12);function d(f,p){var h=f.getAttribute("class")||"";return h.split(/\s+/).filter(function(x){return x.indexOf(p+"-")===0})}var m=(function(f){i(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.keys=function(h){return(h.getAttribute("class")||"").split(/\s+/).map(function(x){return x.split("-").slice(0,-1).join("-")})},p.prototype.add=function(h,x){return this.canAdd(h,x)?(this.remove(h),h.classList.add(this.keyName+"-"+x),!0):!1},p.prototype.remove=function(h){var x=d(h,this.keyName);x.forEach(function(u){h.classList.remove(u)}),h.classList.length===0&&h.removeAttribute("class")},p.prototype.value=function(h){var x=d(h,this.keyName)[0]||"",u=x.slice(this.keyName.length+1);return this.canAdd(h,u)?u:""},p})(o.default);r.default=m}),(function(n,r,a){var i=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,h){p.__proto__=h}||function(p,h){for(var x in h)h.hasOwnProperty(x)&&(p[x]=h[x])};return function(p,h){f(p,h);function x(){this.constructor=p}p.prototype=h===null?Object.create(h):(x.prototype=h.prototype,new x)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(12);function d(f){var p=f.split("-"),h=p.slice(1).map(function(x){return x[0].toUpperCase()+x.slice(1)}).join("");return p[0]+h}var m=(function(f){i(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.keys=function(h){return(h.getAttribute("style")||"").split(";").map(function(x){var u=x.split(":");return u[0].trim()})},p.prototype.add=function(h,x){return this.canAdd(h,x)?(h.style[d(this.keyName)]=x,!0):!1},p.prototype.remove=function(h){h.style[d(this.keyName)]="",h.getAttribute("style")||h.removeAttribute("style")},p.prototype.value=function(h){var x=h.style[d(this.keyName)];return this.canAdd(h,x)?x:""},p})(o.default);r.default=m}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function m(f,p){for(var h=0;hq&&this.stack.undo.length>0){var O=this.stack.undo.pop();E=E.compose(O.undo),_=O.redo.compose(_)}else this.lastRecorded=q;this.stack.undo.push({redo:_,undo:E}),this.stack.undo.length>this.options.maxStack&&this.stack.undo.shift()}}},{key:"redo",value:function(){this.change("redo","undo")}},{key:"transform",value:function(_){this.stack.undo.forEach(function(A){A.undo=_.transform(A.undo,!0),A.redo=_.transform(A.redo,!0)}),this.stack.redo.forEach(function(A){A.undo=_.transform(A.undo,!0),A.redo=_.transform(A.redo,!0)})}},{key:"undo",value:function(){this.change("undo","redo")}}]),S})(h.default);w.DEFAULTS={delay:1e3,maxStack:100,userOnly:!1};function j(C){var S=C.ops[C.ops.length-1];return S==null?!1:S.insert!=null?typeof S.insert=="string"&&S.insert.endsWith(` `):S.attributes!=null?Object.keys(S.attributes).some(function(D){return d.default.query(D,d.default.Scope.BLOCK)!=null}):!1}function b(C){var S=C.reduce(function(_,A){return _+=A.delete||0,_},0),D=C.length()-S;return j(C)&&(D-=1),D}r.default=w,r.getLastChangeIndex=b}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.BaseTooltip=void 0;var i=(function(){function F(I,K){for(var G=0;G0&&arguments[0]!==void 0?arguments[0]:"link",V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;this.root.classList.remove("ql-hidden"),this.root.classList.add("ql-editing"),V!=null?this.textbox.value=V:G!==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-"+G)||""),this.root.setAttribute("data-mode",G)}},{key:"restoreFocus",value:function(){var G=this.quill.scrollingContainer.scrollTop;this.quill.focus(),this.quill.scrollingContainer.scrollTop=G}},{key:"save",value:function(){var G=this.textbox.value;switch(this.root.getAttribute("data-mode")){case"link":{var V=this.quill.root.scrollTop;this.linkRange?(this.quill.formatText(this.linkRange,"link",G,x.default.sources.USER),delete this.linkRange):(this.restoreFocus(),this.quill.format("link",G,x.default.sources.USER)),this.quill.root.scrollTop=V;break}case"video":G=z(G);case"formula":{if(!G)break;var Y=this.quill.getSelection(!0);if(Y!=null){var re=Y.index+Y.length;this.quill.insertEmbed(re,this.root.getAttribute("data-mode"),G,x.default.sources.USER),this.root.getAttribute("data-mode")==="formula"&&this.quill.insertText(re+1," ",x.default.sources.USER),this.quill.setSelection(re+2,x.default.sources.USER)}break}}this.textbox.value="",this.hide()}}]),I})(E.default);function z(F){var I=F.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/)||F.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);return I?(I[1]||"https")+"://www.youtube.com/embed/"+I[2]+"?showinfo=0":(I=F.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/))?(I[1]||"https")+"://player.vimeo.com/video/"+I[2]+"/":F}function T(F,I){var K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;I.forEach(function(G){var V=document.createElement("option");G===K?V.setAttribute("selected","selected"):V.setAttribute("value",G),F.appendChild(V)})}r.BaseTooltip=M,r.default=U}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function o(){this.head=this.tail=null,this.length=0}return o.prototype.append=function(){for(var d=[],m=0;m1&&this.append.apply(this,d.slice(1))},o.prototype.contains=function(d){for(var m,f=this.iterator();m=f();)if(m===d)return!0;return!1},o.prototype.insertBefore=function(d,m){d&&(d.next=m,m!=null?(d.prev=m.prev,m.prev!=null&&(m.prev.next=d),m.prev=d,m===this.head&&(this.head=d)):this.tail!=null?(this.tail.next=d,d.prev=this.tail,this.tail=d):(d.prev=null,this.head=this.tail=d),this.length+=1)},o.prototype.offset=function(d){for(var m=0,f=this.head;f!=null;){if(f===d)return m;m+=f.length(),f=f.next}return-1},o.prototype.remove=function(d){this.contains(d)&&(d.prev!=null&&(d.prev.next=d.next),d.next!=null&&(d.next.prev=d.prev),d===this.head&&(this.head=d.next),d===this.tail&&(this.tail=d.prev),this.length-=1)},o.prototype.iterator=function(d){return d===void 0&&(d=this.head),function(){var m=d;return d!=null&&(d=d.next),m}},o.prototype.find=function(d,m){m===void 0&&(m=!1);for(var f,p=this.iterator();f=p();){var h=f.length();if(dN?f(u,d-N,Math.min(m,N+w-d)):f(u,0,Math.min(w,d+m-N)),N+=w}},o.prototype.map=function(d){return this.reduce(function(m,f){return m.push(d(f)),m},[])},o.prototype.reduce=function(d,m){for(var f,p=this.iterator();f=p();)m=d(m,f);return m},o})();r.default=i}),(function(n,r,a){var i=this&&this.__extends||(function(){var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,u){x.__proto__=u}||function(x,u){for(var N in u)u.hasOwnProperty(N)&&(x[N]=u[N])};return function(x,u){h(x,u);function N(){this.constructor=x}x.prototype=u===null?Object.create(u):(N.prototype=u.prototype,new N)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(17),d=a(1),m={attributes:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0},f=100,p=(function(h){i(x,h);function x(u){var N=h.call(this,u)||this;return N.scroll=N,N.observer=new MutationObserver(function(v){N.update(v)}),N.observer.observe(N.domNode,m),N.attach(),N}return x.prototype.detach=function(){h.prototype.detach.call(this),this.observer.disconnect()},x.prototype.deleteAt=function(u,N){this.update(),u===0&&N===this.length()?this.children.forEach(function(v){v.remove()}):h.prototype.deleteAt.call(this,u,N)},x.prototype.formatAt=function(u,N,v,w){this.update(),h.prototype.formatAt.call(this,u,N,v,w)},x.prototype.insertAt=function(u,N,v){this.update(),h.prototype.insertAt.call(this,u,N,v)},x.prototype.optimize=function(u,N){var v=this;u===void 0&&(u=[]),N===void 0&&(N={}),h.prototype.optimize.call(this,N);for(var w=[].slice.call(this.observer.takeRecords());w.length>0;)u.push(w.pop());for(var j=function(D,_){_===void 0&&(_=!0),!(D==null||D===v)&&D.domNode.parentNode!=null&&(D.domNode[d.DATA_KEY].mutations==null&&(D.domNode[d.DATA_KEY].mutations=[]),_&&j(D.parent))},b=function(D){D.domNode[d.DATA_KEY]==null||D.domNode[d.DATA_KEY].mutations==null||(D instanceof o.default&&D.children.forEach(b),D.optimize(N))},C=u,S=0;C.length>0;S+=1){if(S>=f)throw new Error("[Parchment] Maximum optimize iterations reached");for(C.forEach(function(D){var _=d.find(D.target,!0);_!=null&&(_.domNode===D.target&&(D.type==="childList"?(j(d.find(D.previousSibling,!1)),[].forEach.call(D.addedNodes,function(A){var E=d.find(A,!1);j(E,!1),E instanceof o.default&&E.children.forEach(function(q){j(q,!1)})})):D.type==="attributes"&&j(_.prev)),j(_))}),this.children.forEach(b),C=[].slice.call(this.observer.takeRecords()),w=C.slice();w.length>0;)u.push(w.pop())}},x.prototype.update=function(u,N){var v=this;N===void 0&&(N={}),u=u||this.observer.takeRecords(),u.map(function(w){var j=d.find(w.target,!0);return j==null?null:j.domNode[d.DATA_KEY].mutations==null?(j.domNode[d.DATA_KEY].mutations=[w],j):(j.domNode[d.DATA_KEY].mutations.push(w),null)}).forEach(function(w){w==null||w===v||w.domNode[d.DATA_KEY]==null||w.update(w.domNode[d.DATA_KEY].mutations||[],N)}),this.domNode[d.DATA_KEY].mutations!=null&&h.prototype.update.call(this,this.domNode[d.DATA_KEY].mutations,N),this.optimize(u,N)},x.blotName="scroll",x.defaultChild="block",x.scope=d.Scope.BLOCK_BLOT,x.tagName="DIV",x})(o.default);r.default=p}),(function(n,r,a){var i=this&&this.__extends||(function(){var p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,x){h.__proto__=x}||function(h,x){for(var u in x)x.hasOwnProperty(u)&&(h[u]=x[u])};return function(h,x){p(h,x);function u(){this.constructor=h}h.prototype=x===null?Object.create(x):(u.prototype=x.prototype,new u)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(18),d=a(1);function m(p,h){if(Object.keys(p).length!==Object.keys(h).length)return!1;for(var x in p)if(p[x]!==h[x])return!1;return!0}var f=(function(p){i(h,p);function h(){return p!==null&&p.apply(this,arguments)||this}return h.formats=function(x){if(x.tagName!==h.tagName)return p.formats.call(this,x)},h.prototype.format=function(x,u){var N=this;x===this.statics.blotName&&!u?(this.children.forEach(function(v){v instanceof o.default||(v=v.wrap(h.blotName,!0)),N.attributes.copy(v)}),this.unwrap()):p.prototype.format.call(this,x,u)},h.prototype.formatAt=function(x,u,N,v){if(this.formats()[N]!=null||d.query(N,d.Scope.ATTRIBUTE)){var w=this.isolate(x,u);w.format(N,v)}else p.prototype.formatAt.call(this,x,u,N,v)},h.prototype.optimize=function(x){p.prototype.optimize.call(this,x);var u=this.formats();if(Object.keys(u).length===0)return this.unwrap();var N=this.next;N instanceof h&&N.prev===this&&m(u,N.formats())&&(N.moveChildren(this),N.remove())},h.blotName="inline",h.scope=d.Scope.INLINE_BLOT,h.tagName="SPAN",h})(o.default);r.default=f}),(function(n,r,a){var i=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,h){p.__proto__=h}||function(p,h){for(var x in h)h.hasOwnProperty(x)&&(p[x]=h[x])};return function(p,h){f(p,h);function x(){this.constructor=p}p.prototype=h===null?Object.create(h):(x.prototype=h.prototype,new x)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(18),d=a(1),m=(function(f){i(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.formats=function(h){var x=d.query(p.blotName).tagName;if(h.tagName!==x)return f.formats.call(this,h)},p.prototype.format=function(h,x){d.query(h,d.Scope.BLOCK)!=null&&(h===this.statics.blotName&&!x?this.replaceWith(p.blotName):f.prototype.format.call(this,h,x))},p.prototype.formatAt=function(h,x,u,N){d.query(u,d.Scope.BLOCK)!=null?this.format(u,N):f.prototype.formatAt.call(this,h,x,u,N)},p.prototype.insertAt=function(h,x,u){if(u==null||d.query(x,d.Scope.INLINE)!=null)f.prototype.insertAt.call(this,h,x,u);else{var N=this.split(h),v=d.create(x,u);N.parent.insertBefore(v,N)}},p.prototype.update=function(h,x){navigator.userAgent.match(/Trident/)?this.build():f.prototype.update.call(this,h,x)},p.blotName="block",p.scope=d.Scope.BLOCK_BLOT,p.tagName="P",p})(o.default);r.default=m}),(function(n,r,a){var i=this&&this.__extends||(function(){var m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,p){f.__proto__=p}||function(f,p){for(var h in p)p.hasOwnProperty(h)&&(f[h]=p[h])};return function(f,p){m(f,p);function h(){this.constructor=f}f.prototype=p===null?Object.create(p):(h.prototype=p.prototype,new h)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(19),d=(function(m){i(f,m);function f(){return m!==null&&m.apply(this,arguments)||this}return f.formats=function(p){},f.prototype.format=function(p,h){m.prototype.formatAt.call(this,0,this.length(),p,h)},f.prototype.formatAt=function(p,h,x,u){p===0&&h===this.length()?this.format(x,u):m.prototype.formatAt.call(this,p,h,x,u)},f.prototype.formats=function(){return this.statics.formats(this.domNode)},f})(o.default);r.default=d}),(function(n,r,a){var i=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,h){p.__proto__=h}||function(p,h){for(var x in h)h.hasOwnProperty(x)&&(p[x]=h[x])};return function(p,h){f(p,h);function x(){this.constructor=p}p.prototype=h===null?Object.create(h):(x.prototype=h.prototype,new x)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(19),d=a(1),m=(function(f){i(p,f);function p(h){var x=f.call(this,h)||this;return x.text=x.statics.value(x.domNode),x}return p.create=function(h){return document.createTextNode(h)},p.value=function(h){var x=h.data;return x.normalize&&(x=x.normalize()),x},p.prototype.deleteAt=function(h,x){this.domNode.data=this.text=this.text.slice(0,h)+this.text.slice(h+x)},p.prototype.index=function(h,x){return this.domNode===h?x:-1},p.prototype.insertAt=function(h,x,u){u==null?(this.text=this.text.slice(0,h)+x+this.text.slice(h),this.domNode.data=this.text):f.prototype.insertAt.call(this,h,x,u)},p.prototype.length=function(){return this.text.length},p.prototype.optimize=function(h){f.prototype.optimize.call(this,h),this.text=this.statics.value(this.domNode),this.text.length===0?this.remove():this.next instanceof p&&this.next.prev===this&&(this.insertAt(this.length(),this.next.value()),this.next.remove())},p.prototype.position=function(h,x){return[this.domNode,h]},p.prototype.split=function(h,x){if(x===void 0&&(x=!1),!x){if(h===0)return this;if(h===this.length())return this.next}var u=d.create(this.domNode.splitText(h));return this.parent.insertBefore(u,this.next),this.text=this.statics.value(this.domNode),u},p.prototype.update=function(h,x){var u=this;h.some(function(N){return N.type==="characterData"&&N.target===u.domNode})&&(this.text=this.statics.value(this.domNode))},p.prototype.value=function(){return this.text},p.blotName="text",p.scope=d.Scope.INLINE_BLOT,p})(o.default);r.default=m}),(function(n,r,a){var i=document.createElement("div");if(i.classList.toggle("test-class",!1),i.classList.contains("test-class")){var o=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(d,m){return arguments.length>1&&!this.contains(d)==!m?m:o.call(this,d)}}String.prototype.startsWith||(String.prototype.startsWith=function(d,m){return m=m||0,this.substr(m,d.length)===d}),String.prototype.endsWith||(String.prototype.endsWith=function(d,m){var f=this.toString();(typeof m!="number"||!isFinite(m)||Math.floor(m)!==m||m>f.length)&&(m=f.length),m-=d.length;var p=f.indexOf(d,m);return p!==-1&&p===m}),Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(m){if(this===null)throw new TypeError("Array.prototype.find called on null or undefined");if(typeof m!="function")throw new TypeError("predicate must be a function");for(var f=Object(this),p=f.length>>>0,h=arguments[1],x,u=0;uD.length?S:D,E=S.length>D.length?D:S,q=A.indexOf(E);if(q!=-1)return _=[[i,A.substring(0,q)],[o,E],[i,A.substring(q+E.length)]],S.length>D.length&&(_[0][0]=_[2][0]=a),_;if(E.length==1)return[[a,S],[i,D]];var O=u(S,D);if(O){var R=O[0],P=O[1],L=O[2],$=O[3],Z=O[4],Q=d(R,L),W=d(P,$);return Q.concat([[o,Z]],W)}return f(S,D)}function f(S,D){for(var _=S.length,A=D.length,E=Math.ceil((_+A)/2),q=E,O=2*E,R=new Array(O),P=new Array(O),L=0;L_)W+=2;else if(K>A)Q+=2;else if(Z){var G=q+$-T;if(G>=0&&G=V)return p(S,D,I,K)}}}for(var Y=-z+U;Y<=z-M;Y+=2){var G=q+Y,V;Y==-z||Y!=z&&P[G-1]_)M+=2;else if(re>A)U+=2;else if(!Z){var F=q+$-Y;if(F>=0&&F=V)return p(S,D,I,K)}}}}return[[a,S],[i,D]]}function p(S,D,_,A){var E=S.substring(0,_),q=D.substring(0,A),O=S.substring(_),R=D.substring(A),P=d(E,q),L=d(O,R);return P.concat(L)}function h(S,D){if(!S||!D||S.charAt(0)!=D.charAt(0))return 0;for(var _=0,A=Math.min(S.length,D.length),E=A,q=0;_D.length?S:D,A=S.length>D.length?D:S;if(_.length<4||A.length*2<_.length)return null;function E(W,U,M){for(var z=W.substring(M,M+Math.floor(W.length/4)),T=-1,F="",I,K,G,V;(T=U.indexOf(z,T+1))!=-1;){var Y=h(W.substring(M),U.substring(T)),re=x(W.substring(0,M),U.substring(0,T));F.length=W.length?[I,K,G,V,F]:null}var q=E(_,A,Math.ceil(_.length/4)),O=E(_,A,Math.ceil(_.length/2)),R;if(!q&&!O)return null;O?q?R=q[4].length>O[4].length?q:O:R=O:R=q;var P,L,$,Z;S.length>D.length?(P=R[0],L=R[1],$=R[2],Z=R[3]):($=R[0],Z=R[1],P=R[2],L=R[3]);var Q=R[4];return[P,L,$,Z,Q]}function N(S){S.push([o,""]);for(var D=0,_=0,A=0,E="",q="",O;D1?(_!==0&&A!==0&&(O=h(q,E),O!==0&&(D-_-A>0&&S[D-_-A-1][0]==o?S[D-_-A-1][1]+=q.substring(0,O):(S.splice(0,0,[o,q.substring(0,O)]),D++),q=q.substring(O),E=E.substring(O)),O=x(q,E),O!==0&&(S[D][1]=q.substring(q.length-O)+S[D][1],q=q.substring(0,q.length-O),E=E.substring(0,E.length-O))),_===0?S.splice(D-A,_+A,[i,q]):A===0?S.splice(D-_,_+A,[a,E]):S.splice(D-_-A,_+A,[a,E],[i,q]),D=D-_-A+(_?1:0)+(A?1:0)+1):D!==0&&S[D-1][0]==o?(S[D-1][1]+=S[D][1],S.splice(D,1)):D++,A=0,_=0,E="",q="";break}S[S.length-1][1]===""&&S.pop();var R=!1;for(D=1;D0&&A.splice(E+2,0,[O[0],R]),C(A,E,3)}else return S}function b(S){for(var D=!1,_=function(O){return O.charCodeAt(0)>=56320&&O.charCodeAt(0)<=57343},A=function(O){return O.charCodeAt(O.length-1)>=55296&&O.charCodeAt(O.length-1)<=56319},E=2;E0&&q.push(S[E]);return q}function C(S,D,_){for(var A=D+_-1;A>=0&&A>=D-1;A--)if(A+1\r?\n +\<"),this.convert();var Be=this.quill.getFormat(this.quill.selection.savedRange.index);if(Be[A.default.blotName]){var rt=this.container.innerText;return this.container.innerHTML="",new h.default().insert(rt,L({},A.default.blotName,Be[A.default.blotName]))}var ht=this.prepareMatching(),ge=o(ht,2),Je=ge[0],mt=ge[1],de=Y(this.container,Je,mt);return G(de,` `)&&de.ops[de.ops.length-1].attributes==null&&(de=de.compose(new h.default().retain(de.length()-1).delete(1))),W.log("convert",this.container.innerHTML,de),this.container.innerHTML="",de}},{key:"dangerouslyPasteHTML",value:function(We,Be){var rt=arguments.length>2&&arguments[2]!==void 0?arguments[2]:v.default.sources.API;if(typeof We=="string")this.quill.setContents(this.convert(We),Be),this.quill.setSelection(0,v.default.sources.SILENT);else{var ht=this.convert(Be);this.quill.updateContents(new h.default().retain(We).concat(ht),rt),this.quill.setSelection(We+ht.length(),v.default.sources.SILENT)}}},{key:"onPaste",value:function(We){var Be=this;if(!(We.defaultPrevented||!this.quill.isEnabled())){var rt=this.quill.getSelection(),ht=new h.default().retain(rt.index),ge=this.quill.scrollingContainer.scrollTop;this.container.focus(),this.quill.selection.update(v.default.sources.SILENT),setTimeout(function(){ht=ht.concat(Be.convert()).delete(rt.length),Be.quill.updateContents(ht,v.default.sources.USER),Be.quill.setSelection(ht.length()-rt.length,v.default.sources.SILENT),Be.quill.scrollingContainer.scrollTop=ge,Be.quill.focus()},1)}}},{key:"prepareMatching",value:function(){var We=this,Be=[],rt=[];return this.matchers.forEach(function(ht){var ge=o(ht,2),Je=ge[0],mt=ge[1];switch(Je){case Node.TEXT_NODE:rt.push(mt);break;case Node.ELEMENT_NODE:Be.push(mt);break;default:[].forEach.call(We.container.querySelectorAll(Je),function(de){de[U]=de[U]||[],de[U].push(mt)});break}}),[Be,rt]}}]),Ce})(C.default);F.DEFAULTS={matchers:[],matchVisual:!0};function I(X,Ce,xe){return(typeof Ce>"u"?"undefined":i(Ce))==="object"?Object.keys(Ce).reduce(function(We,Be){return I(We,Be,Ce[Be])},X):X.reduce(function(We,Be){return Be.attributes&&Be.attributes[Ce]?We.push(Be):We.insert(Be.insert,(0,f.default)({},L({},Ce,xe),Be.attributes))},new h.default)}function K(X){if(X.nodeType!==Node.ELEMENT_NODE)return{};var Ce="__ql-computed-style";return X[Ce]||(X[Ce]=window.getComputedStyle(X))}function G(X,Ce){for(var xe="",We=X.ops.length-1;We>=0&&xe.length-1}function Y(X,Ce,xe){return X.nodeType===X.TEXT_NODE?xe.reduce(function(We,Be){return Be(X,We)},new h.default):X.nodeType===X.ELEMENT_NODE?[].reduce.call(X.childNodes||[],function(We,Be){var rt=Y(Be,Ce,xe);return Be.nodeType===X.ELEMENT_NODE&&(rt=Ce.reduce(function(ht,ge){return ge(Be,ht)},rt),rt=(Be[U]||[]).reduce(function(ht,ge){return ge(Be,ht)},rt)),We.concat(rt)},new h.default):new h.default}function re(X,Ce,xe){return I(xe,X,!0)}function ae(X,Ce){var xe=u.default.Attributor.Attribute.keys(X),We=u.default.Attributor.Class.keys(X),Be=u.default.Attributor.Style.keys(X),rt={};return xe.concat(We).concat(Be).forEach(function(ht){var ge=u.default.query(ht,u.default.Scope.ATTRIBUTE);ge!=null&&(rt[ge.attrName]=ge.value(X),rt[ge.attrName])||(ge=z[ht],ge!=null&&(ge.attrName===ht||ge.keyName===ht)&&(rt[ge.attrName]=ge.value(X)||void 0),ge=T[ht],ge!=null&&(ge.attrName===ht||ge.keyName===ht)&&(ge=T[ht],rt[ge.attrName]=ge.value(X)||void 0))}),Object.keys(rt).length>0&&(Ce=I(Ce,rt)),Ce}function ue(X,Ce){var xe=u.default.query(X);if(xe==null)return Ce;if(xe.prototype instanceof u.default.Embed){var We={},Be=xe.value(X);Be!=null&&(We[xe.blotName]=Be,Ce=new h.default().insert(We,xe.formats(X)))}else typeof xe.formats=="function"&&(Ce=I(Ce,xe.blotName,xe.formats(X)));return Ce}function ye(X,Ce){return G(Ce,` `)||Ce.insert(` `),Ce}function ce(){return new h.default}function je(X,Ce){var xe=u.default.query(X);if(xe==null||xe.blotName!=="list-item"||!G(Ce,` `))return Ce;for(var We=-1,Be=X.parentNode;!Be.classList.contains("ql-clipboard");)(u.default.query(Be)||{}).blotName==="list"&&(We+=1),Be=Be.parentNode;return We<=0?Ce:Ce.compose(new h.default().retain(Ce.length()-1).retain(1,{indent:We}))}function Me(X,Ce){return G(Ce,` `)||(V(X)||Ce.length()>0&&X.nextSibling&&V(X.nextSibling))&&Ce.insert(` `),Ce}function ut(X,Ce){if(V(X)&&X.nextElementSibling!=null&&!G(Ce,` `)){var xe=X.offsetHeight+parseFloat(K(X).marginTop)+parseFloat(K(X).marginBottom);X.nextElementSibling.offsetTop>X.offsetTop+xe*1.5&&Ce.insert(` `)}return Ce}function jt(X,Ce){var xe={},We=X.style||{};return We.fontStyle&&K(X).fontStyle==="italic"&&(xe.italic=!0),We.fontWeight&&(K(X).fontWeight.startsWith("bold")||parseInt(K(X).fontWeight)>=700)&&(xe.bold=!0),Object.keys(xe).length>0&&(Ce=I(Ce,xe)),parseFloat(We.textIndent||0)>0&&(Ce=new h.default().insert(" ").concat(Ce)),Ce}function ft(X,Ce){var xe=X.data;if(X.parentNode.tagName==="O:P")return Ce.insert(xe.trim());if(xe.trim().length===0&&X.parentNode.classList.contains("ql-clipboard"))return Ce;if(!K(X.parentNode).whiteSpace.startsWith("pre")){var We=function(rt,ht){return ht=ht.replace(/[^\u00a0]/g,""),ht.length<1&&rt?" ":ht};xe=xe.replace(/\r\n/g," ").replace(/\n/g," "),xe=xe.replace(/\s\s+/g,We.bind(We,!0)),(X.previousSibling==null&&V(X.parentNode)||X.previousSibling!=null&&V(X.previousSibling))&&(xe=xe.replace(/^\s+/,We.bind(We,!1))),(X.nextSibling==null&&V(X.parentNode)||X.nextSibling!=null&&V(X.nextSibling))&&(xe=xe.replace(/\s+$/,We.bind(We,!1)))}return Ce.insert(xe)}r.default=F,r.matchAttributor=ae,r.matchBlot=ue,r.matchNewline=Me,r.matchSpacing=ut,r.matchText=ft}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function N(v,w){for(var j=0;j '}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function N(v,w){for(var j=0;ju.right&&(v=u.right-N.right,this.root.style.left=h+v+"px"),N.leftu.bottom){var w=N.bottom-N.top,j=p.bottom-p.top+w;this.root.style.top=x-j+"px",this.root.classList.add("ql-flip")}return v}},{key:"show",value:function(){this.root.classList.remove("ql-editing"),this.root.classList.remove("ql-hidden")}}]),m})();r.default=d}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function O(R,P){var L=[],$=!0,Z=!1,Q=void 0;try{for(var W=R[Symbol.iterator](),U;!($=(U=W.next()).done)&&(L.push(U.value),!(P&&L.length===P));$=!0);}catch(M){Z=!0,Q=M}finally{try{!$&&W.return&&W.return()}finally{if(Z)throw Q}}return L}return function(R,P){if(Array.isArray(R))return R;if(Symbol.iterator in Object(R))return O(R,P);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=function O(R,P,L){R===null&&(R=Function.prototype);var $=Object.getOwnPropertyDescriptor(R,P);if($===void 0){var Z=Object.getPrototypeOf(R);return Z===null?void 0:O(Z,P,L)}else{if("value"in $)return $.value;var Q=$.get;return Q===void 0?void 0:Q.call(L)}},d=(function(){function O(R,P){for(var L=0;L','','',''].join(""),r.default=E}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(29),o=Be(i),d=a(36),m=a(38),f=a(64),p=a(65),h=Be(p),x=a(66),u=Be(x),N=a(67),v=Be(N),w=a(37),j=a(26),b=a(39),C=a(40),S=a(56),D=Be(S),_=a(68),A=Be(_),E=a(27),q=Be(E),O=a(69),R=Be(O),P=a(70),L=Be(P),$=a(71),Z=Be($),Q=a(72),W=Be(Q),U=a(73),M=Be(U),z=a(13),T=Be(z),F=a(74),I=Be(F),K=a(75),G=Be(K),V=a(57),Y=Be(V),re=a(41),ae=Be(re),ue=a(28),ye=Be(ue),ce=a(59),je=Be(ce),Me=a(60),ut=Be(Me),jt=a(61),ft=Be(jt),X=a(108),Ce=Be(X),xe=a(62),We=Be(xe);function Be(rt){return rt&&rt.__esModule?rt:{default:rt}}o.default.register({"attributors/attribute/direction":m.DirectionAttribute,"attributors/class/align":d.AlignClass,"attributors/class/background":w.BackgroundClass,"attributors/class/color":j.ColorClass,"attributors/class/direction":m.DirectionClass,"attributors/class/font":b.FontClass,"attributors/class/size":C.SizeClass,"attributors/style/align":d.AlignStyle,"attributors/style/background":w.BackgroundStyle,"attributors/style/color":j.ColorStyle,"attributors/style/direction":m.DirectionStyle,"attributors/style/font":b.FontStyle,"attributors/style/size":C.SizeStyle},!0),o.default.register({"formats/align":d.AlignClass,"formats/direction":m.DirectionClass,"formats/indent":f.IndentClass,"formats/background":w.BackgroundStyle,"formats/color":j.ColorStyle,"formats/font":b.FontClass,"formats/size":C.SizeClass,"formats/blockquote":h.default,"formats/code-block":T.default,"formats/header":u.default,"formats/list":v.default,"formats/bold":D.default,"formats/code":z.Code,"formats/italic":A.default,"formats/link":q.default,"formats/script":R.default,"formats/strike":L.default,"formats/underline":Z.default,"formats/image":W.default,"formats/video":M.default,"formats/list/item":N.ListItem,"modules/formula":I.default,"modules/syntax":G.default,"modules/toolbar":Y.default,"themes/bubble":Ce.default,"themes/snow":We.default,"ui/icons":ae.default,"ui/picker":ye.default,"ui/icon-picker":ut.default,"ui/color-picker":je.default,"ui/tooltip":ft.default},!0),r.default=o.default}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.IndentClass=void 0;var i=(function(){function v(w,j){for(var b=0;b0&&this.children.tail.format(A,E)}},{key:"formats",value:function(){return N({},this.statics.blotName,this.statics.formats(this.domNode))}},{key:"insertBefore",value:function(A,E){if(A instanceof b)o(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"insertBefore",this).call(this,A,E);else{var q=E==null?this.length():E.offset(this),O=this.split(q);O.parent.insertBefore(A,O)}}},{key:"optimize",value:function(A){o(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"optimize",this).call(this,A);var E=this.next;E!=null&&E.prev===this&&E.statics.blotName===this.statics.blotName&&E.domNode.tagName===this.domNode.tagName&&E.domNode.getAttribute("data-checked")===this.domNode.getAttribute("data-checked")&&(E.moveChildren(this),E.remove())}},{key:"replace",value:function(A){if(A.statics.blotName!==this.statics.blotName){var E=m.default.create(this.statics.defaultChild);A.moveChildren(E),this.appendChild(E)}o(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"replace",this).call(this,A)}}]),D})(x.default);C.blotName="list",C.scope=m.default.Scope.BLOCK_BLOT,C.tagName=["OL","UL"],C.defaultChild="list-item",C.allowedChildren=[b],r.ListItem=b,r.default=C}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(56),o=d(i);function d(x){return x&&x.__esModule?x:{default:x}}function m(x,u){if(!(x instanceof u))throw new TypeError("Cannot call a class as a function")}function f(x,u){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:x}function p(x,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);x.prototype=Object.create(u&&u.prototype,{constructor:{value:x,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(x,u):x.__proto__=u)}var h=(function(x){p(u,x);function u(){return m(this,u),f(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u})(o.default);h.blotName="italic",h.tagName=["EM","I"],r.default=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function N(v,w){for(var j=0;j-1?S?this.domNode.setAttribute(C,S):this.domNode.removeAttribute(C):o(j.prototype.__proto__||Object.getPrototypeOf(j.prototype),"format",this).call(this,C,S)}}],[{key:"create",value:function(C){var S=o(j.__proto__||Object.getPrototypeOf(j),"create",this).call(this,C);return typeof C=="string"&&S.setAttribute("src",this.sanitize(C)),S}},{key:"formats",value:function(C){return N.reduce(function(S,D){return C.hasAttribute(D)&&(S[D]=C.getAttribute(D)),S},{})}},{key:"match",value:function(C){return/\.(jpe?g|gif|png)$/.test(C)||/^data:image\/.+;base64/.test(C)}},{key:"sanitize",value:function(C){return(0,f.sanitize)(C,["http","https","data"])?C:"//:0"}},{key:"value",value:function(C){return C.getAttribute("src")}}]),j})(m.default.Embed);v.blotName="image",v.tagName="IMG",r.default=v}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function w(j,b){for(var C=0;C-1?S?this.domNode.setAttribute(C,S):this.domNode.removeAttribute(C):o(j.prototype.__proto__||Object.getPrototypeOf(j.prototype),"format",this).call(this,C,S)}}],[{key:"create",value:function(C){var S=o(j.__proto__||Object.getPrototypeOf(j),"create",this).call(this,C);return S.setAttribute("frameborder","0"),S.setAttribute("allowfullscreen",!0),S.setAttribute("src",this.sanitize(C)),S}},{key:"formats",value:function(C){return N.reduce(function(S,D){return C.hasAttribute(D)&&(S[D]=C.getAttribute(D)),S},{})}},{key:"sanitize",value:function(C){return f.default.sanitize(C)}},{key:"value",value:function(C){return C.getAttribute("src")}}]),j})(d.BlockEmbed);v.blotName="video",v.className="ql-video",v.tagName="IFRAME",r.default=v}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.FormulaBlot=void 0;var i=(function(){function C(S,D){for(var _=0;_0||this.cachedText==null)&&(this.domNode.innerHTML=q(O),this.domNode.normalize(),this.attach()),this.cachedText=O)}}]),A})(N.default);C.className="ql-syntax";var S=new m.default.Attributor.Class("token","hljs",{scope:m.default.Scope.INLINE}),D=(function(_){b(A,_),i(A,null,[{key:"register",value:function(){p.default.register(S,!0),p.default.register(C,!0)}}]);function A(E,q){w(this,A);var O=j(this,(A.__proto__||Object.getPrototypeOf(A)).call(this,E,q));if(typeof O.options.highlight!="function")throw new Error("Syntax module requires highlight.js. Please include the library on the page before Quill.");var R=null;return O.quill.on(p.default.events.SCROLL_OPTIMIZE,function(){clearTimeout(R),R=setTimeout(function(){O.highlight(),R=null},O.options.interval)}),O.highlight(),O}return i(A,[{key:"highlight",value:function(){var q=this;if(!this.quill.selection.composing){this.quill.update(p.default.sources.USER);var O=this.quill.getSelection();this.quill.scroll.descendants(C).forEach(function(R){R.highlight(q.options.highlight)}),this.quill.update(p.default.sources.SILENT),O!=null&&this.quill.setSelection(O,p.default.sources.SILENT)}}}]),A})(x.default);D.DEFAULTS={highlight:(function(){return window.hljs==null?null:function(_){var A=window.hljs.highlightAuto(_);return A.value}})(),interval:1e3},r.CodeBlock=C,r.CodeToken=S,r.default=D}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r){n.exports=' '}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.BubbleTooltip=void 0;var i=function A(E,q,O){E===null&&(E=Function.prototype);var R=Object.getOwnPropertyDescriptor(E,q);if(R===void 0){var P=Object.getPrototypeOf(E);return P===null?void 0:A(P,q,O)}else{if("value"in R)return R.value;var L=R.get;return L===void 0?void 0:L.call(O)}},o=(function(){function A(E,q){for(var O=0;O0&&Z===p.default.sources.USER){R.show(),R.root.style.left="0px",R.root.style.width="",R.root.style.width=R.root.offsetWidth+"px";var Q=R.quill.getLines(L.index,L.length);if(Q.length===1)R.position(R.quill.getBounds(L));else{var W=Q[Q.length-1],U=R.quill.getIndex(W),M=Math.min(W.length()-1,L.index+L.length-U),z=R.quill.getBounds(new u.Range(U,M));R.position(z)}}else document.activeElement!==R.textbox&&R.quill.hasFocus()&&R.hide()}),R}return o(E,[{key:"listen",value:function(){var O=this;i(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"listen",this).call(this),this.root.querySelector(".ql-close").addEventListener("click",function(){O.root.classList.remove("ql-editing")}),this.quill.on(p.default.events.SCROLL_OPTIMIZE,function(){setTimeout(function(){if(!O.root.classList.contains("ql-hidden")){var R=O.quill.getSelection();R!=null&&O.position(O.quill.getBounds(R))}},1)})}},{key:"cancel",value:function(){this.show()}},{key:"position",value:function(O){var R=i(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"position",this).call(this,O),P=this.root.querySelector(".ql-tooltip-arrow");if(P.style.marginLeft="",R===0)return R;P.style.marginLeft=-1*R-P.offsetWidth/2+"px"}}]),E})(h.BaseTooltip);_.TEMPLATE=['','
','','',"
"].join(""),r.BubbleTooltip=_,r.default=D}),(function(n,r,a){n.exports=a(63)})]).default})})(Wm)),Wm.exports}var ti,w2;function mG(){if(w2)return ti;w2=1;var t=ti&&ti.__extends||(function(){var p=function(h,x){return p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,N){u.__proto__=N}||function(u,N){for(var v in N)N.hasOwnProperty(v)&&(u[v]=N[v])},p(h,x)};return function(h,x){p(h,x);function u(){this.constructor=h}h.prototype=x===null?Object.create(x):(u.prototype=x.prototype,new u)}})(),s=ti&&ti.__assign||function(){return s=Object.assign||function(p){for(var h,x=1,u=arguments.length;x1)throw new Error("The Quill editing area can only be composed of a single React element.");if(a.default.Children.count(x.children)){var N=a.default.Children.only(x.children);if(((u=N)===null||u===void 0?void 0:u.type)==="textarea")throw new Error("Quill does not support editing on a