var lA=e=>{throw TypeError(e)};var R0=(e,t,r)=>t.has(e)||lA("Cannot "+r);var Q=(e,t,r)=>(R0(e,t,"read from private field"),r?r.call(e):t.get(e)),it=(e,t,r)=>t.has(e)?lA("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),ze=(e,t,r,s)=>(R0(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r),Nt=(e,t,r)=>(R0(e,t,"access private method"),r);var $x=(e,t,r,s)=>({set _(a){ze(e,t,a,r)},get _(){return Q(e,t,s)}});function GW(e,t){for(var r=0;rs[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(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"&&s(o)}).observe(document,{childList:!0,subtree:!0});function r(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 s(a){if(a.ep)return;a.ep=!0;const i=r(a);fetch(a.href,i)}})();var Ix=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Gt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Y$={exports:{}},aj={},X$={exports:{}},At={};/** * @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 Wp=Symbol.for("react.element"),HW=Symbol.for("react.portal"),QW=Symbol.for("react.fragment"),YW=Symbol.for("react.strict_mode"),XW=Symbol.for("react.profiler"),ZW=Symbol.for("react.provider"),JW=Symbol.for("react.context"),eU=Symbol.for("react.forward_ref"),tU=Symbol.for("react.suspense"),nU=Symbol.for("react.memo"),rU=Symbol.for("react.lazy"),cA=Symbol.iterator;function sU(e){return e===null||typeof e!="object"?null:(e=cA&&e[cA]||e["@@iterator"],typeof e=="function"?e:null)}var Z$={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},J$=Object.assign,eI={};function Rf(e,t,r){this.props=e,this.context=t,this.refs=eI,this.updater=r||Z$}Rf.prototype.isReactComponent={};Rf.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Rf.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function tI(){}tI.prototype=Rf.prototype;function lC(e,t,r){this.props=e,this.context=t,this.refs=eI,this.updater=r||Z$}var cC=lC.prototype=new tI;cC.constructor=lC;J$(cC,Rf.prototype);cC.isPureReactComponent=!0;var dA=Array.isArray,nI=Object.prototype.hasOwnProperty,dC={current:null},rI={key:!0,ref:!0,__self:!0,__source:!0};function sI(e,t,r){var s,a={},i=null,o=null;if(t!=null)for(s in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(i=""+t.key),t)nI.call(t,s)&&!rI.hasOwnProperty(s)&&(a[s]=t[s]);var l=arguments.length-2;if(l===1)a.children=r;else if(1>>1,re=k[X];if(0>>1;Xa(xe,K))mea(ne,xe)?(k[X]=ne,k[me]=K,X=me):(k[X]=xe,k[te]=K,X=te);else if(mea(ne,K))k[X]=ne,k[me]=K,X=me;else break e}}return M}function a(k,M){var K=k.sortIndex-M.sortIndex;return K!==0?K:k.id-M.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,l=o.now();e.unstable_now=function(){return o.now()-l}}var c=[],d=[],u=1,f=null,h=3,m=!1,y=!1,x=!1,j=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function b(k){for(var M=r(d);M!==null;){if(M.callback===null)s(d);else if(M.startTime<=k)s(d),M.sortIndex=M.expirationTime,t(c,M);else break;M=r(d)}}function N(k){if(x=!1,b(k),!y)if(r(c)!==null)y=!0,B(w);else{var M=r(d);M!==null&&I(N,M.startTime-k)}}function w(k,M){y=!1,x&&(x=!1,v(C),C=-1),m=!0;var K=h;try{for(b(M),f=r(c);f!==null&&(!(f.expirationTime>M)||k&&!z());){var X=f.callback;if(typeof X=="function"){f.callback=null,h=f.priorityLevel;var re=X(f.expirationTime<=M);M=e.unstable_now(),typeof re=="function"?f.callback=re:f===r(c)&&s(c),b(M)}else s(c);f=r(c)}if(f!==null)var Z=!0;else{var te=r(d);te!==null&&I(N,te.startTime-M),Z=!1}return Z}finally{f=null,h=K,m=!1}}var S=!1,_=null,C=-1,P=5,D=-1;function z(){return!(e.unstable_now()-Dk||125X?(k.sortIndex=K,t(d,k),r(c)===null&&k===r(d)&&(x?(v(C),C=-1):x=!0,I(N,K-X))):(k.sortIndex=re,t(c,k),y||m||(y=!0,B(w))),k},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(k){var M=h;return function(){var K=h;h=M;try{return k.apply(this,arguments)}finally{h=K}}}})(cI);lI.exports=cI;var pU=lI.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 xU=p,Fs=pU;function Ce(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),RN=Object.prototype.hasOwnProperty,gU=/^[: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]*$/,fA={},mA={};function vU(e){return RN.call(mA,e)?!0:RN.call(fA,e)?!1:gU.test(e)?mA[e]=!0:(fA[e]=!0,!1)}function yU(e,t,r,s){if(r!==null&&r.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return s?!1:r!==null?!r.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function jU(e,t,r,s){if(t===null||typeof t>"u"||yU(e,t,r,s))return!0;if(s)return!1;if(r!==null)switch(r.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function ss(e,t,r,s,a,i,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=s,this.attributeNamespace=a,this.mustUseProperty=r,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=o}var Cr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Cr[e]=new ss(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Cr[t]=new ss(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Cr[e]=new ss(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Cr[e]=new ss(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Cr[e]=new ss(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Cr[e]=new ss(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Cr[e]=new ss(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Cr[e]=new ss(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Cr[e]=new ss(e,5,!1,e.toLowerCase(),null,!1,!1)});var fC=/[\-:]([a-z])/g;function mC(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(fC,mC);Cr[t]=new ss(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(fC,mC);Cr[t]=new ss(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(fC,mC);Cr[t]=new ss(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Cr[e]=new ss(e,1,!1,e.toLowerCase(),null,!1,!1)});Cr.xlinkHref=new ss("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Cr[e]=new ss(e,1,!1,e.toLowerCase(),null,!0,!0)});function hC(e,t,r,s){var a=Cr.hasOwnProperty(t)?Cr[t]:null;(a!==null?a.type!==0:s||!(2l||a[o]!==i[l]){var c=` `+a[o].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=o&&0<=l);break}}}finally{D0=!1,Error.prepareStackTrace=r}return(e=e?e.displayName||e.name:"")?Hm(e):""}function bU(e){switch(e.tag){case 5:return Hm(e.type);case 16:return Hm("Lazy");case 13:return Hm("Suspense");case 19:return Hm("SuspenseList");case 0:case 2:case 15:return e=L0(e.type,!1),e;case 11:return e=L0(e.type.render,!1),e;case 1:return e=L0(e.type,!0),e;default:return""}}function LN(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Hd:return"Fragment";case Gd:return"Portal";case $N:return"Profiler";case pC:return"StrictMode";case IN:return"Suspense";case DN:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case fI:return(e.displayName||"Context")+".Consumer";case uI:return(e._context.displayName||"Context")+".Provider";case xC:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case gC:return t=e.displayName||null,t!==null?t:LN(e.type)||"Memo";case Bo:t=e._payload,e=e._init;try{return LN(e(t))}catch{}}return null}function wU(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return LN(t);case 8:return t===pC?"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 t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Cl(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function hI(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function NU(e){var t=hI(e)?"checked":"value",r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),s=""+e[t];if(!e.hasOwnProperty(t)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var a=r.get,i=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(o){s=""+o,i.call(this,o)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return s},setValue:function(o){s=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Fx(e){e._valueTracker||(e._valueTracker=NU(e))}function pI(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var r=t.getValue(),s="";return e&&(s=hI(e)?e.checked?"true":"false":e.value),e=s,e!==r?(t.setValue(e),!0):!1}function Jg(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function FN(e,t){var r=t.checked;return Tn({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??e._wrapperState.initialChecked})}function pA(e,t){var r=t.defaultValue==null?"":t.defaultValue,s=t.checked!=null?t.checked:t.defaultChecked;r=Cl(t.value!=null?t.value:r),e._wrapperState={initialChecked:s,initialValue:r,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function xI(e,t){t=t.checked,t!=null&&hC(e,"checked",t,!1)}function BN(e,t){xI(e,t);var r=Cl(t.value),s=t.type;if(r!=null)s==="number"?(r===0&&e.value===""||e.value!=r)&&(e.value=""+r):e.value!==""+r&&(e.value=""+r);else if(s==="submit"||s==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?zN(e,t.type,r):t.hasOwnProperty("defaultValue")&&zN(e,t.type,Cl(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function xA(e,t,r){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var s=t.type;if(!(s!=="submit"&&s!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,r||t===e.value||(e.value=t),e.defaultValue=t}r=e.name,r!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,r!==""&&(e.name=r)}function zN(e,t,r){(t!=="number"||Jg(e.ownerDocument)!==e)&&(r==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+r&&(e.defaultValue=""+r))}var Qm=Array.isArray;function mu(e,t,r,s){if(e=e.options,t){t={};for(var a=0;a"+t.valueOf().toString()+"",t=Bx.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function wh(e,t){if(t){var r=e.firstChild;if(r&&r===e.lastChild&&r.nodeType===3){r.nodeValue=t;return}}e.textContent=t}var sh={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},SU=["Webkit","ms","Moz","O"];Object.keys(sh).forEach(function(e){SU.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),sh[t]=sh[e]})});function jI(e,t,r){return t==null||typeof t=="boolean"||t===""?"":r||typeof t!="number"||t===0||sh.hasOwnProperty(e)&&sh[e]?(""+t).trim():t+"px"}function bI(e,t){e=e.style;for(var r in t)if(t.hasOwnProperty(r)){var s=r.indexOf("--")===0,a=jI(r,t[r],s);r==="float"&&(r="cssFloat"),s?e.setProperty(r,a):e[r]=a}}var _U=Tn({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 WN(e,t){if(t){if(_U[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Ce(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Ce(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Ce(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Ce(62))}}function UN(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var KN=null;function vC(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var GN=null,hu=null,pu=null;function yA(e){if(e=Gp(e)){if(typeof GN!="function")throw Error(Ce(280));var t=e.stateNode;t&&(t=uj(t),GN(e.stateNode,e.type,t))}}function wI(e){hu?pu?pu.push(e):pu=[e]:hu=e}function NI(){if(hu){var e=hu,t=pu;if(pu=hu=null,yA(e),t)for(e=0;e>>=0,e===0?32:31-(IU(e)/DU|0)|0}var zx=64,Vx=4194304;function Ym(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function rv(e,t){var r=e.pendingLanes;if(r===0)return 0;var s=0,a=e.suspendedLanes,i=e.pingedLanes,o=r&268435455;if(o!==0){var l=o&~a;l!==0?s=Ym(l):(i&=o,i!==0&&(s=Ym(i)))}else o=r&~a,o!==0?s=Ym(o):i!==0&&(s=Ym(i));if(s===0)return 0;if(t!==0&&t!==s&&!(t&a)&&(a=s&-s,i=t&-t,a>=i||a===16&&(i&4194240)!==0))return t;if(s&4&&(s|=r&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=s;0r;r++)t.push(e);return t}function Up(e,t,r){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-$a(t),e[t]=r}function zU(e,t){var r=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var s=e.eventTimes;for(e=e.expirationTimes;0=ih),PA=" ",AA=!1;function qI(e,t){switch(e){case"keyup":return p7.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function WI(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Qd=!1;function g7(e,t){switch(e){case"compositionend":return WI(t);case"keypress":return t.which!==32?null:(AA=!0,PA);case"textInput":return e=t.data,e===PA&&AA?null:e;default:return null}}function v7(e,t){if(Qd)return e==="compositionend"||!CC&&qI(e,t)?(e=zI(),Rg=NC=al=null,Qd=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:r,offset:t-e};e=s}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=MA(r)}}function HI(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?HI(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function QI(){for(var e=window,t=Jg();t instanceof e.HTMLIFrameElement;){try{var r=typeof t.contentWindow.location.href=="string"}catch{r=!1}if(r)e=t.contentWindow;else break;t=Jg(e.document)}return t}function kC(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function k7(e){var t=QI(),r=e.focusedElem,s=e.selectionRange;if(t!==r&&r&&r.ownerDocument&&HI(r.ownerDocument.documentElement,r)){if(s!==null&&kC(r)){if(t=s.start,e=s.end,e===void 0&&(e=t),"selectionStart"in r)r.selectionStart=t,r.selectionEnd=Math.min(e,r.value.length);else if(e=(t=r.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var a=r.textContent.length,i=Math.min(s.start,a);s=s.end===void 0?i:Math.min(s.end,a),!e.extend&&i>s&&(a=s,s=i,i=a),a=RA(r,i);var o=RA(r,s);a&&o&&(e.rangeCount!==1||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(a.node,a.offset),e.removeAllRanges(),i>s?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=r;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r=document.documentMode,Yd=null,JN=null,lh=null,e1=!1;function $A(e,t,r){var s=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;e1||Yd==null||Yd!==Jg(s)||(s=Yd,"selectionStart"in s&&kC(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),lh&&Ph(lh,s)||(lh=s,s=iv(JN,"onSelect"),0Jd||(e.current=i1[Jd],i1[Jd]=null,Jd--)}function mn(e,t){Jd++,i1[Jd]=e.current,e.current=t}var kl={},Br=Rl(kl),xs=Rl(!1),Bc=kl;function Fu(e,t){var r=e.type.contextTypes;if(!r)return kl;var s=e.stateNode;if(s&&s.__reactInternalMemoizedUnmaskedChildContext===t)return s.__reactInternalMemoizedMaskedChildContext;var a={},i;for(i in r)a[i]=t[i];return s&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=a),a}function gs(e){return e=e.childContextTypes,e!=null}function lv(){Nn(xs),Nn(Br)}function VA(e,t,r){if(Br.current!==kl)throw Error(Ce(168));mn(Br,t),mn(xs,r)}function sD(e,t,r){var s=e.stateNode;if(t=t.childContextTypes,typeof s.getChildContext!="function")return r;s=s.getChildContext();for(var a in s)if(!(a in t))throw Error(Ce(108,wU(e)||"Unknown",a));return Tn({},r,s)}function cv(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||kl,Bc=Br.current,mn(Br,e),mn(xs,xs.current),!0}function qA(e,t,r){var s=e.stateNode;if(!s)throw Error(Ce(169));r?(e=sD(e,t,Bc),s.__reactInternalMemoizedMergedChildContext=e,Nn(xs),Nn(Br),mn(Br,e)):Nn(xs),mn(xs,r)}var zi=null,fj=!1,Z0=!1;function aD(e){zi===null?zi=[e]:zi.push(e)}function F7(e){fj=!0,aD(e)}function $l(){if(!Z0&&zi!==null){Z0=!0;var e=0,t=Jt;try{var r=zi;for(Jt=1;e>=o,a-=o,Gi=1<<32-$a(t)+a|r<C?(P=_,_=null):P=_.sibling;var D=h(v,_,b[C],N);if(D===null){_===null&&(_=P);break}e&&_&&D.alternate===null&&t(v,_),g=i(D,g,C),S===null?w=D:S.sibling=D,S=D,_=P}if(C===b.length)return r(v,_),_n&&cc(v,C),w;if(_===null){for(;CC?(P=_,_=null):P=_.sibling;var z=h(v,_,D.value,N);if(z===null){_===null&&(_=P);break}e&&_&&z.alternate===null&&t(v,_),g=i(z,g,C),S===null?w=z:S.sibling=z,S=z,_=P}if(D.done)return r(v,_),_n&&cc(v,C),w;if(_===null){for(;!D.done;C++,D=b.next())D=f(v,D.value,N),D!==null&&(g=i(D,g,C),S===null?w=D:S.sibling=D,S=D);return _n&&cc(v,C),w}for(_=s(v,_);!D.done;C++,D=b.next())D=m(_,v,C,D.value,N),D!==null&&(e&&D.alternate!==null&&_.delete(D.key===null?C:D.key),g=i(D,g,C),S===null?w=D:S.sibling=D,S=D);return e&&_.forEach(function(O){return t(v,O)}),_n&&cc(v,C),w}function j(v,g,b,N){if(typeof b=="object"&&b!==null&&b.type===Hd&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case Lx:e:{for(var w=b.key,S=g;S!==null;){if(S.key===w){if(w=b.type,w===Hd){if(S.tag===7){r(v,S.sibling),g=a(S,b.props.children),g.return=v,v=g;break e}}else if(S.elementType===w||typeof w=="object"&&w!==null&&w.$$typeof===Bo&&KA(w)===S.type){r(v,S.sibling),g=a(S,b.props),g.ref=Sm(v,S,b),g.return=v,v=g;break e}r(v,S);break}else t(v,S);S=S.sibling}b.type===Hd?(g=Dc(b.props.children,v.mode,N,b.key),g.return=v,v=g):(N=Vg(b.type,b.key,b.props,null,v.mode,N),N.ref=Sm(v,g,b),N.return=v,v=N)}return o(v);case Gd:e:{for(S=b.key;g!==null;){if(g.key===S)if(g.tag===4&&g.stateNode.containerInfo===b.containerInfo&&g.stateNode.implementation===b.implementation){r(v,g.sibling),g=a(g,b.children||[]),g.return=v,v=g;break e}else{r(v,g);break}else t(v,g);g=g.sibling}g=iw(b,v.mode,N),g.return=v,v=g}return o(v);case Bo:return S=b._init,j(v,g,S(b._payload),N)}if(Qm(b))return y(v,g,b,N);if(ym(b))return x(v,g,b,N);Qx(v,b)}return typeof b=="string"&&b!==""||typeof b=="number"?(b=""+b,g!==null&&g.tag===6?(r(v,g.sibling),g=a(g,b),g.return=v,v=g):(r(v,g),g=aw(b,v.mode,N),g.return=v,v=g),o(v)):r(v,g)}return j}var zu=cD(!0),dD=cD(!1),fv=Rl(null),mv=null,nu=null,OC=null;function TC(){OC=nu=mv=null}function MC(e){var t=fv.current;Nn(fv),e._currentValue=t}function c1(e,t,r){for(;e!==null;){var s=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,s!==null&&(s.childLanes|=t)):s!==null&&(s.childLanes&t)!==t&&(s.childLanes|=t),e===r)break;e=e.return}}function gu(e,t){mv=e,OC=nu=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(fs=!0),e.firstContext=null)}function la(e){var t=e._currentValue;if(OC!==e)if(e={context:e,memoizedValue:t,next:null},nu===null){if(mv===null)throw Error(Ce(308));nu=e,mv.dependencies={lanes:0,firstContext:e}}else nu=nu.next=e;return t}var vc=null;function RC(e){vc===null?vc=[e]:vc.push(e)}function uD(e,t,r,s){var a=t.interleaved;return a===null?(r.next=r,RC(t)):(r.next=a.next,a.next=r),t.interleaved=r,ao(e,s)}function ao(e,t){e.lanes|=t;var r=e.alternate;for(r!==null&&(r.lanes|=t),r=e,e=e.return;e!==null;)e.childLanes|=t,r=e.alternate,r!==null&&(r.childLanes|=t),r=e,e=e.return;return r.tag===3?r.stateNode:null}var zo=!1;function $C(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function fD(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Zi(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ml(e,t,r){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,It&2){var a=s.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),s.pending=t,ao(e,r)}return a=s.interleaved,a===null?(t.next=t,RC(s)):(t.next=a.next,a.next=t),s.interleaved=t,ao(e,r)}function Ig(e,t,r){if(t=t.updateQueue,t!==null&&(t=t.shared,(r&4194240)!==0)){var s=t.lanes;s&=e.pendingLanes,r|=s,t.lanes=r,jC(e,r)}}function GA(e,t){var r=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,r===s)){var a=null,i=null;if(r=r.firstBaseUpdate,r!==null){do{var o={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};i===null?a=i=o:i=i.next=o,r=r.next}while(r!==null);i===null?a=i=t:i=i.next=t}else a=i=t;r={baseState:s.baseState,firstBaseUpdate:a,lastBaseUpdate:i,shared:s.shared,effects:s.effects},e.updateQueue=r;return}e=r.lastBaseUpdate,e===null?r.firstBaseUpdate=t:e.next=t,r.lastBaseUpdate=t}function hv(e,t,r,s){var a=e.updateQueue;zo=!1;var i=a.firstBaseUpdate,o=a.lastBaseUpdate,l=a.shared.pending;if(l!==null){a.shared.pending=null;var c=l,d=c.next;c.next=null,o===null?i=d:o.next=d,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,l=u.lastBaseUpdate,l!==o&&(l===null?u.firstBaseUpdate=d:l.next=d,u.lastBaseUpdate=c))}if(i!==null){var f=a.baseState;o=0,u=d=c=null,l=i;do{var h=l.lane,m=l.eventTime;if((s&h)===h){u!==null&&(u=u.next={eventTime:m,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var y=e,x=l;switch(h=t,m=r,x.tag){case 1:if(y=x.payload,typeof y=="function"){f=y.call(m,f,h);break e}f=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=x.payload,h=typeof y=="function"?y.call(m,f,h):y,h==null)break e;f=Tn({},f,h);break e;case 2:zo=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,h=a.effects,h===null?a.effects=[l]:h.push(l))}else m={eventTime:m,lane:h,tag:l.tag,payload:l.payload,callback:l.callback,next:null},u===null?(d=u=m,c=f):u=u.next=m,o|=h;if(l=l.next,l===null){if(l=a.shared.pending,l===null)break;h=l,l=h.next,h.next=null,a.lastBaseUpdate=h,a.shared.pending=null}}while(!0);if(u===null&&(c=f),a.baseState=c,a.firstBaseUpdate=d,a.lastBaseUpdate=u,t=a.shared.interleaved,t!==null){a=t;do o|=a.lane,a=a.next;while(a!==t)}else i===null&&(a.shared.lanes=0);qc|=o,e.lanes=o,e.memoizedState=f}}function HA(e,t,r){if(e=t.effects,t.effects=null,e!==null)for(t=0;tr?r:4,e(!0);var s=ew.transition;ew.transition={};try{e(!1),t()}finally{Jt=r,ew.transition=s}}function AD(){return ca().memoizedState}function q7(e,t,r){var s=pl(e);if(r={lane:s,action:r,hasEagerState:!1,eagerState:null,next:null},ED(e))OD(t,r);else if(r=uD(e,t,r,s),r!==null){var a=Jr();Ia(r,e,s,a),TD(r,t,s)}}function W7(e,t,r){var s=pl(e),a={lane:s,action:r,hasEagerState:!1,eagerState:null,next:null};if(ED(e))OD(t,a);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var o=t.lastRenderedState,l=i(o,r);if(a.hasEagerState=!0,a.eagerState=l,Fa(l,o)){var c=t.interleaved;c===null?(a.next=a,RC(t)):(a.next=c.next,c.next=a),t.interleaved=a;return}}catch{}finally{}r=uD(e,t,a,s),r!==null&&(a=Jr(),Ia(r,e,s,a),TD(r,t,s))}}function ED(e){var t=e.alternate;return e===En||t!==null&&t===En}function OD(e,t){ch=xv=!0;var r=e.pending;r===null?t.next=t:(t.next=r.next,r.next=t),e.pending=t}function TD(e,t,r){if(r&4194240){var s=t.lanes;s&=e.pendingLanes,r|=s,t.lanes=r,jC(e,r)}}var gv={readContext:la,useCallback:Or,useContext:Or,useEffect:Or,useImperativeHandle:Or,useInsertionEffect:Or,useLayoutEffect:Or,useMemo:Or,useReducer:Or,useRef:Or,useState:Or,useDebugValue:Or,useDeferredValue:Or,useTransition:Or,useMutableSource:Or,useSyncExternalStore:Or,useId:Or,unstable_isNewReconciler:!1},U7={readContext:la,useCallback:function(e,t){return ei().memoizedState=[e,t===void 0?null:t],e},useContext:la,useEffect:YA,useImperativeHandle:function(e,t,r){return r=r!=null?r.concat([e]):null,Lg(4194308,4,SD.bind(null,t,e),r)},useLayoutEffect:function(e,t){return Lg(4194308,4,e,t)},useInsertionEffect:function(e,t){return Lg(4,2,e,t)},useMemo:function(e,t){var r=ei();return t=t===void 0?null:t,e=e(),r.memoizedState=[e,t],e},useReducer:function(e,t,r){var s=ei();return t=r!==void 0?r(t):t,s.memoizedState=s.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},s.queue=e,e=e.dispatch=q7.bind(null,En,e),[s.memoizedState,e]},useRef:function(e){var t=ei();return e={current:e},t.memoizedState=e},useState:QA,useDebugValue:qC,useDeferredValue:function(e){return ei().memoizedState=e},useTransition:function(){var e=QA(!1),t=e[0];return e=V7.bind(null,e[1]),ei().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,r){var s=En,a=ei();if(_n){if(r===void 0)throw Error(Ce(407));r=r()}else{if(r=t(),yr===null)throw Error(Ce(349));Vc&30||xD(s,t,r)}a.memoizedState=r;var i={value:r,getSnapshot:t};return a.queue=i,YA(vD.bind(null,s,i,e),[e]),s.flags|=2048,Ih(9,gD.bind(null,s,i,r,t),void 0,null),r},useId:function(){var e=ei(),t=yr.identifierPrefix;if(_n){var r=Hi,s=Gi;r=(s&~(1<<32-$a(s)-1)).toString(32)+r,t=":"+t+"R"+r,r=Rh++,0<\/script>",e=e.removeChild(e.firstChild)):typeof s.is=="string"?e=o.createElement(r,{is:s.is}):(e=o.createElement(r),r==="select"&&(o=e,s.multiple?o.multiple=!0:s.size&&(o.size=s.size))):e=o.createElementNS(e,r),e[si]=t,e[Oh]=s,VD(e,t,!1,!1),t.stateNode=e;e:{switch(o=UN(r,s),r){case"dialog":vn("cancel",e),vn("close",e),a=s;break;case"iframe":case"object":case"embed":vn("load",e),a=s;break;case"video":case"audio":for(a=0;aWu&&(t.flags|=128,s=!0,_m(i,!1),t.lanes=4194304)}else{if(!s)if(e=pv(o),e!==null){if(t.flags|=128,s=!0,r=e.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),_m(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!_n)return Tr(t),null}else 2*zn()-i.renderingStartTime>Wu&&r!==1073741824&&(t.flags|=128,s=!0,_m(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(r=i.last,r!==null?r.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=zn(),t.sibling=null,r=An.current,mn(An,s?r&1|2:r&1),t):(Tr(t),null);case 22:case 23:return QC(),s=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==s&&(t.flags|=8192),s&&t.mode&1?Cs&1073741824&&(Tr(t),t.subtreeFlags&6&&(t.flags|=8192)):Tr(t),null;case 24:return null;case 25:return null}throw Error(Ce(156,t.tag))}function J7(e,t){switch(AC(t),t.tag){case 1:return gs(t.type)&&lv(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Vu(),Nn(xs),Nn(Br),LC(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return DC(t),null;case 13:if(Nn(An),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Ce(340));Bu()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Nn(An),null;case 4:return Vu(),null;case 10:return MC(t.type._context),null;case 22:case 23:return QC(),null;case 24:return null;default:return null}}var Xx=!1,Dr=!1,eK=typeof WeakSet=="function"?WeakSet:Set,Xe=null;function ru(e,t){var r=e.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(s){$n(e,t,s)}else r.current=null}function v1(e,t,r){try{r()}catch(s){$n(e,t,s)}}var oE=!1;function tK(e,t){if(t1=sv,e=QI(),kC(e)){if("selectionStart"in e)var r={start:e.selectionStart,end:e.selectionEnd};else e:{r=(r=e.ownerDocument)&&r.defaultView||window;var s=r.getSelection&&r.getSelection();if(s&&s.rangeCount!==0){r=s.anchorNode;var a=s.anchorOffset,i=s.focusNode;s=s.focusOffset;try{r.nodeType,i.nodeType}catch{r=null;break e}var o=0,l=-1,c=-1,d=0,u=0,f=e,h=null;t:for(;;){for(var m;f!==r||a!==0&&f.nodeType!==3||(l=o+a),f!==i||s!==0&&f.nodeType!==3||(c=o+s),f.nodeType===3&&(o+=f.nodeValue.length),(m=f.firstChild)!==null;)h=f,f=m;for(;;){if(f===e)break t;if(h===r&&++d===a&&(l=o),h===i&&++u===s&&(c=o),(m=f.nextSibling)!==null)break;f=h,h=f.parentNode}f=m}r=l===-1||c===-1?null:{start:l,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;for(n1={focusedElem:e,selectionRange:r},sv=!1,Xe=t;Xe!==null;)if(t=Xe,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Xe=e;else for(;Xe!==null;){t=Xe;try{var y=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var x=y.memoizedProps,j=y.memoizedState,v=t.stateNode,g=v.getSnapshotBeforeUpdate(t.elementType===t.type?x:_a(t.type,x),j);v.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var b=t.stateNode.containerInfo;b.nodeType===1?b.textContent="":b.nodeType===9&&b.documentElement&&b.removeChild(b.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ce(163))}}catch(N){$n(t,t.return,N)}if(e=t.sibling,e!==null){e.return=t.return,Xe=e;break}Xe=t.return}return y=oE,oE=!1,y}function dh(e,t,r){var s=t.updateQueue;if(s=s!==null?s.lastEffect:null,s!==null){var a=s=s.next;do{if((a.tag&e)===e){var i=a.destroy;a.destroy=void 0,i!==void 0&&v1(t,r,i)}a=a.next}while(a!==s)}}function pj(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var r=t=t.next;do{if((r.tag&e)===e){var s=r.create;r.destroy=s()}r=r.next}while(r!==t)}}function y1(e){var t=e.ref;if(t!==null){var r=e.stateNode;switch(e.tag){case 5:e=r;break;default:e=r}typeof t=="function"?t(e):t.current=e}}function UD(e){var t=e.alternate;t!==null&&(e.alternate=null,UD(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[si],delete t[Oh],delete t[a1],delete t[D7],delete t[L7])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function KD(e){return e.tag===5||e.tag===3||e.tag===4}function lE(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||KD(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function j1(e,t,r){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?r.nodeType===8?r.parentNode.insertBefore(e,t):r.insertBefore(e,t):(r.nodeType===8?(t=r.parentNode,t.insertBefore(e,r)):(t=r,t.appendChild(e)),r=r._reactRootContainer,r!=null||t.onclick!==null||(t.onclick=ov));else if(s!==4&&(e=e.child,e!==null))for(j1(e,t,r),e=e.sibling;e!==null;)j1(e,t,r),e=e.sibling}function b1(e,t,r){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?r.insertBefore(e,t):r.appendChild(e);else if(s!==4&&(e=e.child,e!==null))for(b1(e,t,r),e=e.sibling;e!==null;)b1(e,t,r),e=e.sibling}var wr=null,ka=!1;function Mo(e,t,r){for(r=r.child;r!==null;)GD(e,t,r),r=r.sibling}function GD(e,t,r){if(di&&typeof di.onCommitFiberUnmount=="function")try{di.onCommitFiberUnmount(oj,r)}catch{}switch(r.tag){case 5:Dr||ru(r,t);case 6:var s=wr,a=ka;wr=null,Mo(e,t,r),wr=s,ka=a,wr!==null&&(ka?(e=wr,r=r.stateNode,e.nodeType===8?e.parentNode.removeChild(r):e.removeChild(r)):wr.removeChild(r.stateNode));break;case 18:wr!==null&&(ka?(e=wr,r=r.stateNode,e.nodeType===8?X0(e.parentNode,r):e.nodeType===1&&X0(e,r),Ch(e)):X0(wr,r.stateNode));break;case 4:s=wr,a=ka,wr=r.stateNode.containerInfo,ka=!0,Mo(e,t,r),wr=s,ka=a;break;case 0:case 11:case 14:case 15:if(!Dr&&(s=r.updateQueue,s!==null&&(s=s.lastEffect,s!==null))){a=s=s.next;do{var i=a,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&v1(r,t,o),a=a.next}while(a!==s)}Mo(e,t,r);break;case 1:if(!Dr&&(ru(r,t),s=r.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=r.memoizedProps,s.state=r.memoizedState,s.componentWillUnmount()}catch(l){$n(r,t,l)}Mo(e,t,r);break;case 21:Mo(e,t,r);break;case 22:r.mode&1?(Dr=(s=Dr)||r.memoizedState!==null,Mo(e,t,r),Dr=s):Mo(e,t,r);break;default:Mo(e,t,r)}}function cE(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var r=e.stateNode;r===null&&(r=e.stateNode=new eK),t.forEach(function(s){var a=dK.bind(null,e,s);r.has(s)||(r.add(s),s.then(a,a))})}}function ja(e,t){var r=t.deletions;if(r!==null)for(var s=0;sa&&(a=o),s&=~i}if(s=a,s=zn()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*rK(s/1960))-s,10e?16:e,il===null)var s=!1;else{if(e=il,il=null,jv=0,It&6)throw Error(Ce(331));var a=It;for(It|=4,Xe=e.current;Xe!==null;){var i=Xe,o=i.child;if(Xe.flags&16){var l=i.deletions;if(l!==null){for(var c=0;czn()-GC?Ic(e,0):KC|=r),vs(e,t)}function tL(e,t){t===0&&(e.mode&1?(t=Vx,Vx<<=1,!(Vx&130023424)&&(Vx=4194304)):t=1);var r=Jr();e=ao(e,t),e!==null&&(Up(e,t,r),vs(e,r))}function cK(e){var t=e.memoizedState,r=0;t!==null&&(r=t.retryLane),tL(e,r)}function dK(e,t){var r=0;switch(e.tag){case 13:var s=e.stateNode,a=e.memoizedState;a!==null&&(r=a.retryLane);break;case 19:s=e.stateNode;break;default:throw Error(Ce(314))}s!==null&&s.delete(t),tL(e,r)}var nL;nL=function(e,t,r){if(e!==null)if(e.memoizedProps!==t.pendingProps||xs.current)fs=!0;else{if(!(e.lanes&r)&&!(t.flags&128))return fs=!1,X7(e,t,r);fs=!!(e.flags&131072)}else fs=!1,_n&&t.flags&1048576&&iD(t,uv,t.index);switch(t.lanes=0,t.tag){case 2:var s=t.type;Fg(e,t),e=t.pendingProps;var a=Fu(t,Br.current);gu(t,r),a=BC(null,t,s,e,a,r);var i=zC();return t.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,gs(s)?(i=!0,cv(t)):i=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,$C(t),a.updater=hj,t.stateNode=a,a._reactInternals=t,u1(t,s,e,r),t=h1(null,t,s,!0,i,r)):(t.tag=0,_n&&i&&PC(t),Wr(null,t,a,r),t=t.child),t;case 16:s=t.elementType;e:{switch(Fg(e,t),e=t.pendingProps,a=s._init,s=a(s._payload),t.type=s,a=t.tag=fK(s),e=_a(s,e),a){case 0:t=m1(null,t,s,e,r);break e;case 1:t=sE(null,t,s,e,r);break e;case 11:t=nE(null,t,s,e,r);break e;case 14:t=rE(null,t,s,_a(s.type,e),r);break e}throw Error(Ce(306,s,""))}return t;case 0:return s=t.type,a=t.pendingProps,a=t.elementType===s?a:_a(s,a),m1(e,t,s,a,r);case 1:return s=t.type,a=t.pendingProps,a=t.elementType===s?a:_a(s,a),sE(e,t,s,a,r);case 3:e:{if(FD(t),e===null)throw Error(Ce(387));s=t.pendingProps,i=t.memoizedState,a=i.element,fD(e,t),hv(t,s,null,r);var o=t.memoizedState;if(s=o.element,i.isDehydrated)if(i={element:s,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){a=qu(Error(Ce(423)),t),t=aE(e,t,s,r,a);break e}else if(s!==a){a=qu(Error(Ce(424)),t),t=aE(e,t,s,r,a);break e}else for(Rs=fl(t.stateNode.containerInfo.firstChild),$s=t,_n=!0,Ea=null,r=dD(t,null,s,r),t.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(Bu(),s===a){t=io(e,t,r);break e}Wr(e,t,s,r)}t=t.child}return t;case 5:return mD(t),e===null&&l1(t),s=t.type,a=t.pendingProps,i=e!==null?e.memoizedProps:null,o=a.children,r1(s,a)?o=null:i!==null&&r1(s,i)&&(t.flags|=32),LD(e,t),Wr(e,t,o,r),t.child;case 6:return e===null&&l1(t),null;case 13:return BD(e,t,r);case 4:return IC(t,t.stateNode.containerInfo),s=t.pendingProps,e===null?t.child=zu(t,null,s,r):Wr(e,t,s,r),t.child;case 11:return s=t.type,a=t.pendingProps,a=t.elementType===s?a:_a(s,a),nE(e,t,s,a,r);case 7:return Wr(e,t,t.pendingProps,r),t.child;case 8:return Wr(e,t,t.pendingProps.children,r),t.child;case 12:return Wr(e,t,t.pendingProps.children,r),t.child;case 10:e:{if(s=t.type._context,a=t.pendingProps,i=t.memoizedProps,o=a.value,mn(fv,s._currentValue),s._currentValue=o,i!==null)if(Fa(i.value,o)){if(i.children===a.children&&!xs.current){t=io(e,t,r);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var l=i.dependencies;if(l!==null){o=i.child;for(var c=l.firstContext;c!==null;){if(c.context===s){if(i.tag===1){c=Zi(-1,r&-r),c.tag=2;var d=i.updateQueue;if(d!==null){d=d.shared;var u=d.pending;u===null?c.next=c:(c.next=u.next,u.next=c),d.pending=c}}i.lanes|=r,c=i.alternate,c!==null&&(c.lanes|=r),c1(i.return,r,t),l.lanes|=r;break}c=c.next}}else if(i.tag===10)o=i.type===t.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(Ce(341));o.lanes|=r,l=o.alternate,l!==null&&(l.lanes|=r),c1(o,r,t),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===t){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}Wr(e,t,a.children,r),t=t.child}return t;case 9:return a=t.type,s=t.pendingProps.children,gu(t,r),a=la(a),s=s(a),t.flags|=1,Wr(e,t,s,r),t.child;case 14:return s=t.type,a=_a(s,t.pendingProps),a=_a(s.type,a),rE(e,t,s,a,r);case 15:return ID(e,t,t.type,t.pendingProps,r);case 17:return s=t.type,a=t.pendingProps,a=t.elementType===s?a:_a(s,a),Fg(e,t),t.tag=1,gs(s)?(e=!0,cv(t)):e=!1,gu(t,r),MD(t,s,a),u1(t,s,a,r),h1(null,t,s,!0,e,r);case 19:return zD(e,t,r);case 22:return DD(e,t,r)}throw Error(Ce(156,t.tag))};function rL(e,t){return EI(e,t)}function uK(e,t,r,s){this.tag=e,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function na(e,t,r,s){return new uK(e,t,r,s)}function XC(e){return e=e.prototype,!(!e||!e.isReactComponent)}function fK(e){if(typeof e=="function")return XC(e)?1:0;if(e!=null){if(e=e.$$typeof,e===xC)return 11;if(e===gC)return 14}return 2}function xl(e,t){var r=e.alternate;return r===null?(r=na(e.tag,t,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=t,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&14680064,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,t=e.dependencies,r.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r}function Vg(e,t,r,s,a,i){var o=2;if(s=e,typeof e=="function")XC(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Hd:return Dc(r.children,a,i,t);case pC:o=8,a|=8;break;case $N:return e=na(12,r,t,a|2),e.elementType=$N,e.lanes=i,e;case IN:return e=na(13,r,t,a),e.elementType=IN,e.lanes=i,e;case DN:return e=na(19,r,t,a),e.elementType=DN,e.lanes=i,e;case mI:return gj(r,a,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case uI:o=10;break e;case fI:o=9;break e;case xC:o=11;break e;case gC:o=14;break e;case Bo:o=16,s=null;break e}throw Error(Ce(130,e==null?e:typeof e,""))}return t=na(o,r,t,a),t.elementType=e,t.type=s,t.lanes=i,t}function Dc(e,t,r,s){return e=na(7,e,s,t),e.lanes=r,e}function gj(e,t,r,s){return e=na(22,e,s,t),e.elementType=mI,e.lanes=r,e.stateNode={isHidden:!1},e}function aw(e,t,r){return e=na(6,e,null,t),e.lanes=r,e}function iw(e,t,r){return t=na(4,e.children!==null?e.children:[],e.key,t),t.lanes=r,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function mK(e,t,r,s,a){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=B0(0),this.expirationTimes=B0(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=B0(0),this.identifierPrefix=s,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function ZC(e,t,r,s,a,i,o,l,c){return e=new mK(e,t,r,l,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=na(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:s,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},$C(i),e}function hK(e,t,r){var s=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(oL)}catch(e){console.error(e)}}oL(),oI.exports=zs;var md=oI.exports;const lL=Gt(md);var cL,gE=md;cL=gE.createRoot,gE.hydrateRoot;const yK=1,jK=1e6;let ow=0;function bK(){return ow=(ow+1)%Number.MAX_SAFE_INTEGER,ow.toString()}const lw=new Map,vE=e=>{if(lw.has(e))return;const t=setTimeout(()=>{lw.delete(e),mh({type:"REMOVE_TOAST",toastId:e})},jK);lw.set(e,t)},wK=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,yK)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(r=>r.id===t.toast.id?{...r,...t.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=t;return r?vE(r):e.toasts.forEach(s=>{vE(s.id)}),{...e,toasts:e.toasts.map(s=>s.id===r||r===void 0?{...s,open:!1}:s)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(r=>r.id!==t.toastId)}}},qg=[];let Wg={toasts:[]};function mh(e){Wg=wK(Wg,e),qg.forEach(t=>{t(Wg)})}function NK({...e}){const t=bK(),r=a=>mh({type:"UPDATE_TOAST",toast:{...a,id:t}}),s=()=>mh({type:"DISMISS_TOAST",toastId:t});return mh({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:a=>{a||s()}}}),{id:t,dismiss:s,update:r}}function He(){const[e,t]=p.useState(Wg);return p.useEffect(()=>(qg.push(t),()=>{const r=qg.indexOf(t);r>-1&&qg.splice(r,1)}),[e]),{...e,toast:NK,dismiss:r=>mh({type:"DISMISS_TOAST",toastId:r})}}function be(e,t,{checkForDefaultPrevented:r=!0}={}){return function(a){if(e==null||e(a),r===!1||!a.defaultPrevented)return t==null?void 0:t(a)}}function yE(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ni(...e){return t=>{let r=!1;const s=e.map(a=>{const i=yE(a,t);return!r&&typeof i=="function"&&(r=!0),i});if(r)return()=>{for(let a=0;a{const{children:o,...l}=i,c=p.useMemo(()=>l,Object.values(l));return n.jsx(r.Provider,{value:c,children:o})};s.displayName=e+"Provider";function a(i){const o=p.useContext(r);if(o)return o;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[s,a]}function lr(e,t=[]){let r=[];function s(i,o){const l=p.createContext(o),c=r.length;r=[...r,o];const d=f=>{var v;const{scope:h,children:m,...y}=f,x=((v=h==null?void 0:h[e])==null?void 0:v[c])||l,j=p.useMemo(()=>y,Object.values(y));return n.jsx(x.Provider,{value:j,children:m})};d.displayName=i+"Provider";function u(f,h){var x;const m=((x=h==null?void 0:h[e])==null?void 0:x[c])||l,y=p.useContext(m);if(y)return y;if(o!==void 0)return o;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[d,u]}const a=()=>{const i=r.map(o=>p.createContext(o));return function(l){const c=(l==null?void 0:l[e])||i;return p.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return a.scopeName=e,[s,_K(a,...t)]}function _K(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const s=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=s.reduce((l,{useScope:c,scopeName:d})=>{const f=c(i)[`__scope${d}`];return{...l,...f}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return r.scopeName=t.scopeName,r}function jE(e){const t=CK(e),r=p.forwardRef((s,a)=>{const{children:i,...o}=s,l=p.Children.toArray(i),c=l.find(PK);if(c){const d=c.props.children,u=l.map(f=>f===c?p.Children.count(d)>1?p.Children.only(null):p.isValidElement(d)?d.props.children:null:f);return n.jsx(t,{...o,ref:a,children:p.isValidElement(d)?p.cloneElement(d,void 0,u):null})}return n.jsx(t,{...o,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function CK(e){const t=p.forwardRef((r,s)=>{const{children:a,...i}=r;if(p.isValidElement(a)){const o=EK(a),l=AK(i,a.props);return a.type!==p.Fragment&&(l.ref=s?Ni(s,o):o),p.cloneElement(a,l)}return p.Children.count(a)>1?p.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var kK=Symbol("radix.slottable");function PK(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===kK}function AK(e,t){const r={...t};for(const s in t){const a=e[s],i=t[s];/^on[A-Z]/.test(s)?a&&i?r[s]=(...l)=>{const c=i(...l);return a(...l),c}:a&&(r[s]=a):s==="style"?r[s]={...a,...i}:s==="className"&&(r[s]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function EK(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function Df(e){const t=e+"CollectionProvider",[r,s]=lr(t),[a,i]=r(t,{collectionRef:{current:null},itemMap:new Map}),o=x=>{const{scope:j,children:v}=x,g=F.useRef(null),b=F.useRef(new Map).current;return n.jsx(a,{scope:j,itemMap:b,collectionRef:g,children:v})};o.displayName=t;const l=e+"CollectionSlot",c=jE(l),d=F.forwardRef((x,j)=>{const{scope:v,children:g}=x,b=i(l,v),N=dt(j,b.collectionRef);return n.jsx(c,{ref:N,children:g})});d.displayName=l;const u=e+"CollectionItemSlot",f="data-radix-collection-item",h=jE(u),m=F.forwardRef((x,j)=>{const{scope:v,children:g,...b}=x,N=F.useRef(null),w=dt(j,N),S=i(u,v);return F.useEffect(()=>(S.itemMap.set(N,{ref:N,...b}),()=>void S.itemMap.delete(N))),n.jsx(h,{[f]:"",ref:w,children:g})});m.displayName=u;function y(x){const j=i(e+"CollectionConsumer",x);return F.useCallback(()=>{const g=j.collectionRef.current;if(!g)return[];const b=Array.from(g.querySelectorAll(`[${f}]`));return Array.from(j.itemMap.values()).sort((S,_)=>b.indexOf(S.ref.current)-b.indexOf(_.ref.current))},[j.collectionRef,j.itemMap])}return[{Provider:o,Slot:d,ItemSlot:m},y,s]}function OK(e){const t=TK(e),r=p.forwardRef((s,a)=>{const{children:i,...o}=s,l=p.Children.toArray(i),c=l.find(RK);if(c){const d=c.props.children,u=l.map(f=>f===c?p.Children.count(d)>1?p.Children.only(null):p.isValidElement(d)?d.props.children:null:f);return n.jsx(t,{...o,ref:a,children:p.isValidElement(d)?p.cloneElement(d,void 0,u):null})}return n.jsx(t,{...o,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function TK(e){const t=p.forwardRef((r,s)=>{const{children:a,...i}=r;if(p.isValidElement(a)){const o=IK(a),l=$K(i,a.props);return a.type!==p.Fragment&&(l.ref=s?Ni(s,o):o),p.cloneElement(a,l)}return p.Children.count(a)>1?p.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var MK=Symbol("radix.slottable");function RK(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===MK}function $K(e,t){const r={...t};for(const s in t){const a=e[s],i=t[s];/^on[A-Z]/.test(s)?a&&i?r[s]=(...l)=>{const c=i(...l);return a(...l),c}:a&&(r[s]=a):s==="style"?r[s]={...a,...i}:s==="className"&&(r[s]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function IK(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var DK=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],We=DK.reduce((e,t)=>{const r=OK(`Primitive.${t}`),s=p.forwardRef((a,i)=>{const{asChild:o,...l}=a,c=o?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(c,{...l,ref:i})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function nk(e,t){e&&md.flushSync(()=>e.dispatchEvent(t))}function Dn(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...r)=>{var s;return(s=t.current)==null?void 0:s.call(t,...r)},[])}function LK(e,t=globalThis==null?void 0:globalThis.document){const r=Dn(e);p.useEffect(()=>{const s=a=>{a.key==="Escape"&&r(a)};return t.addEventListener("keydown",s,{capture:!0}),()=>t.removeEventListener("keydown",s,{capture:!0})},[r,t])}var FK="DismissableLayer",C1="dismissableLayer.update",BK="dismissableLayer.pointerDownOutside",zK="dismissableLayer.focusOutside",bE,dL=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),hd=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:l,...c}=e,d=p.useContext(dL),[u,f]=p.useState(null),h=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=p.useState({}),y=dt(t,_=>f(_)),x=Array.from(d.layers),[j]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),v=x.indexOf(j),g=u?x.indexOf(u):-1,b=d.layersWithOutsidePointerEventsDisabled.size>0,N=g>=v,w=qK(_=>{const C=_.target,P=[...d.branches].some(D=>D.contains(C));!N||P||(a==null||a(_),o==null||o(_),_.defaultPrevented||l==null||l())},h),S=WK(_=>{const C=_.target;[...d.branches].some(D=>D.contains(C))||(i==null||i(_),o==null||o(_),_.defaultPrevented||l==null||l())},h);return LK(_=>{g===d.layers.size-1&&(s==null||s(_),!_.defaultPrevented&&l&&(_.preventDefault(),l()))},h),p.useEffect(()=>{if(u)return r&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(bE=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(u)),d.layers.add(u),wE(),()=>{r&&d.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=bE)}},[u,h,r,d]),p.useEffect(()=>()=>{u&&(d.layers.delete(u),d.layersWithOutsidePointerEventsDisabled.delete(u),wE())},[u,d]),p.useEffect(()=>{const _=()=>m({});return document.addEventListener(C1,_),()=>document.removeEventListener(C1,_)},[]),n.jsx(We.div,{...c,ref:y,style:{pointerEvents:b?N?"auto":"none":void 0,...e.style},onFocusCapture:be(e.onFocusCapture,S.onFocusCapture),onBlurCapture:be(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:be(e.onPointerDownCapture,w.onPointerDownCapture)})});hd.displayName=FK;var VK="DismissableLayerBranch",uL=p.forwardRef((e,t)=>{const r=p.useContext(dL),s=p.useRef(null),a=dt(t,s);return p.useEffect(()=>{const i=s.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),n.jsx(We.div,{...e,ref:a})});uL.displayName=VK;function qK(e,t=globalThis==null?void 0:globalThis.document){const r=Dn(e),s=p.useRef(!1),a=p.useRef(()=>{});return p.useEffect(()=>{const i=l=>{if(l.target&&!s.current){let c=function(){fL(BK,r,d,{discrete:!0})};const d={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",a.current),a.current=c,t.addEventListener("click",a.current,{once:!0})):c()}else t.removeEventListener("click",a.current);s.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",i),t.removeEventListener("click",a.current)}},[t,r]),{onPointerDownCapture:()=>s.current=!0}}function WK(e,t=globalThis==null?void 0:globalThis.document){const r=Dn(e),s=p.useRef(!1);return p.useEffect(()=>{const a=i=>{i.target&&!s.current&&fL(zK,r,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,r]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function wE(){const e=new CustomEvent(C1);document.dispatchEvent(e)}function fL(e,t,r,{discrete:s}){const a=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&a.addEventListener(e,t,{once:!0}),s?nk(a,i):a.dispatchEvent(i)}var UK=hd,KK=uL,Ln=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},GK="Portal",Lf=p.forwardRef((e,t)=>{var l;const{container:r,...s}=e,[a,i]=p.useState(!1);Ln(()=>i(!0),[]);const o=r||a&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return o?lL.createPortal(n.jsx(We.div,{...s,ref:t}),o):null});Lf.displayName=GK;function HK(e,t){return p.useReducer((r,s)=>t[r][s]??r,e)}var Jn=e=>{const{present:t,children:r}=e,s=QK(t),a=typeof r=="function"?r({present:s.isPresent}):p.Children.only(r),i=dt(s.ref,YK(a));return typeof r=="function"||s.isPresent?p.cloneElement(a,{ref:i}):null};Jn.displayName="Presence";function QK(e){const[t,r]=p.useState(),s=p.useRef(null),a=p.useRef(e),i=p.useRef("none"),o=e?"mounted":"unmounted",[l,c]=HK(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const d=eg(s.current);i.current=l==="mounted"?d:"none"},[l]),Ln(()=>{const d=s.current,u=a.current;if(u!==e){const h=i.current,m=eg(d);e?c("MOUNT"):m==="none"||(d==null?void 0:d.display)==="none"?c("UNMOUNT"):c(u&&h!==m?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,c]),Ln(()=>{if(t){let d;const u=t.ownerDocument.defaultView??window,f=m=>{const x=eg(s.current).includes(CSS.escape(m.animationName));if(m.target===t&&x&&(c("ANIMATION_END"),!a.current)){const j=t.style.animationFillMode;t.style.animationFillMode="forwards",d=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=j)})}},h=m=>{m.target===t&&(i.current=eg(s.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{u.clearTimeout(d),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:p.useCallback(d=>{s.current=d?getComputedStyle(d):null,r(d)},[])}}function eg(e){return(e==null?void 0:e.animationName)||"none"}function YK(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var XK=ij[" useInsertionEffect ".trim().toString()]||Ln;function zr({prop:e,defaultProp:t,onChange:r=()=>{},caller:s}){const[a,i,o]=ZK({defaultProp:t,onChange:r}),l=e!==void 0,c=l?e:a;{const u=p.useRef(e!==void 0);p.useEffect(()=>{const f=u.current;f!==l&&console.warn(`${s} is changing from ${f?"controlled":"uncontrolled"} to ${l?"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.`),u.current=l},[l,s])}const d=p.useCallback(u=>{var f;if(l){const h=JK(u)?u(e):u;h!==e&&((f=o.current)==null||f.call(o,h))}else i(u)},[l,e,i,o]);return[c,d]}function ZK({defaultProp:e,onChange:t}){const[r,s]=p.useState(e),a=p.useRef(r),i=p.useRef(t);return XK(()=>{i.current=t},[t]),p.useEffect(()=>{var o;a.current!==r&&((o=i.current)==null||o.call(i,r),a.current=r)},[r,a]),[r,s,i]}function JK(e){return typeof e=="function"}var mL=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"}),eG="VisuallyHidden",wj=p.forwardRef((e,t)=>n.jsx(We.span,{...e,ref:t,style:{...mL,...e.style}}));wj.displayName=eG;var tG=wj,rk="ToastProvider",[sk,nG,rG]=Df("Toast"),[hL]=lr("Toast",[rG]),[sG,Nj]=hL(rk),pL=e=>{const{__scopeToast:t,label:r="Notification",duration:s=5e3,swipeDirection:a="right",swipeThreshold:i=50,children:o}=e,[l,c]=p.useState(null),[d,u]=p.useState(0),f=p.useRef(!1),h=p.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${rk}\`. Expected non-empty \`string\`.`),n.jsx(sk.Provider,{scope:t,children:n.jsx(sG,{scope:t,label:r,duration:s,swipeDirection:a,swipeThreshold:i,toastCount:d,viewport:l,onViewportChange:c,onToastAdd:p.useCallback(()=>u(m=>m+1),[]),onToastRemove:p.useCallback(()=>u(m=>m-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:h,children:o})})};pL.displayName=rk;var xL="ToastViewport",aG=["F8"],k1="toast.viewportPause",P1="toast.viewportResume",gL=p.forwardRef((e,t)=>{const{__scopeToast:r,hotkey:s=aG,label:a="Notifications ({hotkey})",...i}=e,o=Nj(xL,r),l=nG(r),c=p.useRef(null),d=p.useRef(null),u=p.useRef(null),f=p.useRef(null),h=dt(t,f,o.onViewportChange),m=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),y=o.toastCount>0;p.useEffect(()=>{const j=v=>{var b;s.length!==0&&s.every(N=>v[N]||v.code===N)&&((b=f.current)==null||b.focus())};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[s]),p.useEffect(()=>{const j=c.current,v=f.current;if(y&&j&&v){const g=()=>{if(!o.isClosePausedRef.current){const S=new CustomEvent(k1);v.dispatchEvent(S),o.isClosePausedRef.current=!0}},b=()=>{if(o.isClosePausedRef.current){const S=new CustomEvent(P1);v.dispatchEvent(S),o.isClosePausedRef.current=!1}},N=S=>{!j.contains(S.relatedTarget)&&b()},w=()=>{j.contains(document.activeElement)||b()};return j.addEventListener("focusin",g),j.addEventListener("focusout",N),j.addEventListener("pointermove",g),j.addEventListener("pointerleave",w),window.addEventListener("blur",g),window.addEventListener("focus",b),()=>{j.removeEventListener("focusin",g),j.removeEventListener("focusout",N),j.removeEventListener("pointermove",g),j.removeEventListener("pointerleave",w),window.removeEventListener("blur",g),window.removeEventListener("focus",b)}}},[y,o.isClosePausedRef]);const x=p.useCallback(({tabbingDirection:j})=>{const g=l().map(b=>{const N=b.ref.current,w=[N,...vG(N)];return j==="forwards"?w:w.reverse()});return(j==="forwards"?g.reverse():g).flat()},[l]);return p.useEffect(()=>{const j=f.current;if(j){const v=g=>{var w,S,_;const b=g.altKey||g.ctrlKey||g.metaKey;if(g.key==="Tab"&&!b){const C=document.activeElement,P=g.shiftKey;if(g.target===j&&P){(w=d.current)==null||w.focus();return}const O=x({tabbingDirection:P?"backwards":"forwards"}),V=O.findIndex(A=>A===C);cw(O.slice(V+1))?g.preventDefault():P?(S=d.current)==null||S.focus():(_=u.current)==null||_.focus()}};return j.addEventListener("keydown",v),()=>j.removeEventListener("keydown",v)}},[l,x]),n.jsxs(KK,{ref:c,role:"region","aria-label":a.replace("{hotkey}",m),tabIndex:-1,style:{pointerEvents:y?void 0:"none"},children:[y&&n.jsx(A1,{ref:d,onFocusFromOutsideViewport:()=>{const j=x({tabbingDirection:"forwards"});cw(j)}}),n.jsx(sk.Slot,{scope:r,children:n.jsx(We.ol,{tabIndex:-1,...i,ref:h})}),y&&n.jsx(A1,{ref:u,onFocusFromOutsideViewport:()=>{const j=x({tabbingDirection:"backwards"});cw(j)}})]})});gL.displayName=xL;var vL="ToastFocusProxy",A1=p.forwardRef((e,t)=>{const{__scopeToast:r,onFocusFromOutsideViewport:s,...a}=e,i=Nj(vL,r);return n.jsx(wj,{tabIndex:0,...a,ref:t,style:{position:"fixed"},onFocus:o=>{var d;const l=o.relatedTarget;!((d=i.viewport)!=null&&d.contains(l))&&s()}})});A1.displayName=vL;var Qp="Toast",iG="toast.swipeStart",oG="toast.swipeMove",lG="toast.swipeCancel",cG="toast.swipeEnd",yL=p.forwardRef((e,t)=>{const{forceMount:r,open:s,defaultOpen:a,onOpenChange:i,...o}=e,[l,c]=zr({prop:s,defaultProp:a??!0,onChange:i,caller:Qp});return n.jsx(Jn,{present:r||l,children:n.jsx(fG,{open:l,...o,ref:t,onClose:()=>c(!1),onPause:Dn(e.onPause),onResume:Dn(e.onResume),onSwipeStart:be(e.onSwipeStart,d=>{d.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:be(e.onSwipeMove,d=>{const{x:u,y:f}=d.detail.delta;d.currentTarget.setAttribute("data-swipe","move"),d.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${u}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${f}px`)}),onSwipeCancel:be(e.onSwipeCancel,d=>{d.currentTarget.setAttribute("data-swipe","cancel"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),d.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:be(e.onSwipeEnd,d=>{const{x:u,y:f}=d.detail.delta;d.currentTarget.setAttribute("data-swipe","end"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),d.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${u}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${f}px`),c(!1)})})})});yL.displayName=Qp;var[dG,uG]=hL(Qp,{onClose(){}}),fG=p.forwardRef((e,t)=>{const{__scopeToast:r,type:s="foreground",duration:a,open:i,onClose:o,onEscapeKeyDown:l,onPause:c,onResume:d,onSwipeStart:u,onSwipeMove:f,onSwipeCancel:h,onSwipeEnd:m,...y}=e,x=Nj(Qp,r),[j,v]=p.useState(null),g=dt(t,A=>v(A)),b=p.useRef(null),N=p.useRef(null),w=a||x.duration,S=p.useRef(0),_=p.useRef(w),C=p.useRef(0),{onToastAdd:P,onToastRemove:D}=x,z=Dn(()=>{var $;(j==null?void 0:j.contains(document.activeElement))&&(($=x.viewport)==null||$.focus()),o()}),O=p.useCallback(A=>{!A||A===1/0||(window.clearTimeout(C.current),S.current=new Date().getTime(),C.current=window.setTimeout(z,A))},[z]);p.useEffect(()=>{const A=x.viewport;if(A){const $=()=>{O(_.current),d==null||d()},B=()=>{const I=new Date().getTime()-S.current;_.current=_.current-I,window.clearTimeout(C.current),c==null||c()};return A.addEventListener(k1,B),A.addEventListener(P1,$),()=>{A.removeEventListener(k1,B),A.removeEventListener(P1,$)}}},[x.viewport,w,c,d,O]),p.useEffect(()=>{i&&!x.isClosePausedRef.current&&O(w)},[i,w,x.isClosePausedRef,O]),p.useEffect(()=>(P(),()=>D()),[P,D]);const V=p.useMemo(()=>j?CL(j):null,[j]);return x.viewport?n.jsxs(n.Fragment,{children:[V&&n.jsx(mG,{__scopeToast:r,role:"status","aria-live":s==="foreground"?"assertive":"polite",children:V}),n.jsx(dG,{scope:r,onClose:z,children:md.createPortal(n.jsx(sk.ItemSlot,{scope:r,children:n.jsx(UK,{asChild:!0,onEscapeKeyDown:be(l,()=>{x.isFocusedToastEscapeKeyDownRef.current||z(),x.isFocusedToastEscapeKeyDownRef.current=!1}),children:n.jsx(We.li,{tabIndex:0,"data-state":i?"open":"closed","data-swipe-direction":x.swipeDirection,...y,ref:g,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:be(e.onKeyDown,A=>{A.key==="Escape"&&(l==null||l(A.nativeEvent),A.nativeEvent.defaultPrevented||(x.isFocusedToastEscapeKeyDownRef.current=!0,z()))}),onPointerDown:be(e.onPointerDown,A=>{A.button===0&&(b.current={x:A.clientX,y:A.clientY})}),onPointerMove:be(e.onPointerMove,A=>{if(!b.current)return;const $=A.clientX-b.current.x,B=A.clientY-b.current.y,I=!!N.current,k=["left","right"].includes(x.swipeDirection),M=["left","up"].includes(x.swipeDirection)?Math.min:Math.max,K=k?M(0,$):0,X=k?0:M(0,B),re=A.pointerType==="touch"?10:2,Z={x:K,y:X},te={originalEvent:A,delta:Z};I?(N.current=Z,tg(oG,f,te,{discrete:!1})):NE(Z,x.swipeDirection,re)?(N.current=Z,tg(iG,u,te,{discrete:!1}),A.target.setPointerCapture(A.pointerId)):(Math.abs($)>re||Math.abs(B)>re)&&(b.current=null)}),onPointerUp:be(e.onPointerUp,A=>{const $=N.current,B=A.target;if(B.hasPointerCapture(A.pointerId)&&B.releasePointerCapture(A.pointerId),N.current=null,b.current=null,$){const I=A.currentTarget,k={originalEvent:A,delta:$};NE($,x.swipeDirection,x.swipeThreshold)?tg(cG,m,k,{discrete:!0}):tg(lG,h,k,{discrete:!0}),I.addEventListener("click",M=>M.preventDefault(),{once:!0})}})})})}),x.viewport)})]}):null}),mG=e=>{const{__scopeToast:t,children:r,...s}=e,a=Nj(Qp,t),[i,o]=p.useState(!1),[l,c]=p.useState(!1);return xG(()=>o(!0)),p.useEffect(()=>{const d=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(d)},[]),l?null:n.jsx(Lf,{asChild:!0,children:n.jsx(wj,{...s,children:i&&n.jsxs(n.Fragment,{children:[a.label," ",r]})})})},hG="ToastTitle",jL=p.forwardRef((e,t)=>{const{__scopeToast:r,...s}=e;return n.jsx(We.div,{...s,ref:t})});jL.displayName=hG;var pG="ToastDescription",bL=p.forwardRef((e,t)=>{const{__scopeToast:r,...s}=e;return n.jsx(We.div,{...s,ref:t})});bL.displayName=pG;var wL="ToastAction",NL=p.forwardRef((e,t)=>{const{altText:r,...s}=e;return r.trim()?n.jsx(_L,{altText:r,asChild:!0,children:n.jsx(ak,{...s,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${wL}\`. Expected non-empty \`string\`.`),null)});NL.displayName=wL;var SL="ToastClose",ak=p.forwardRef((e,t)=>{const{__scopeToast:r,...s}=e,a=uG(SL,r);return n.jsx(_L,{asChild:!0,children:n.jsx(We.button,{type:"button",...s,ref:t,onClick:be(e.onClick,a.onClose)})})});ak.displayName=SL;var _L=p.forwardRef((e,t)=>{const{__scopeToast:r,altText:s,...a}=e;return n.jsx(We.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":s||void 0,...a,ref:t})});function CL(e){const t=[];return Array.from(e.childNodes).forEach(s=>{if(s.nodeType===s.TEXT_NODE&&s.textContent&&t.push(s.textContent),gG(s)){const a=s.ariaHidden||s.hidden||s.style.display==="none",i=s.dataset.radixToastAnnounceExclude==="";if(!a)if(i){const o=s.dataset.radixToastAnnounceAlt;o&&t.push(o)}else t.push(...CL(s))}}),t}function tg(e,t,r,{discrete:s}){const a=r.originalEvent.currentTarget,i=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:r});t&&a.addEventListener(e,t,{once:!0}),s?nk(a,i):a.dispatchEvent(i)}var NE=(e,t,r=0)=>{const s=Math.abs(e.x),a=Math.abs(e.y),i=s>a;return t==="left"||t==="right"?i&&s>r:!i&&a>r};function xG(e=()=>{}){const t=Dn(e);Ln(()=>{let r=0,s=0;return r=window.requestAnimationFrame(()=>s=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(s)}},[t])}function gG(e){return e.nodeType===e.ELEMENT_NODE}function vG(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const a=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||a?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function cw(e){const t=document.activeElement;return e.some(r=>r===t?!0:(r.focus(),document.activeElement!==t))}var yG=pL,kL=gL,PL=yL,AL=jL,EL=bL,OL=NL,TL=ak;function ML(e){var t,r,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;ttypeof e=="boolean"?`${e}`:e===0?"0":e,_E=gt,pd=(e,t)=>r=>{var s;if((t==null?void 0:t.variants)==null)return _E(e,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:a,defaultVariants:i}=t,o=Object.keys(a).map(d=>{const u=r==null?void 0:r[d],f=i==null?void 0:i[d];if(u===null)return null;const h=SE(u)||SE(f);return a[d][h]}),l=r&&Object.entries(r).reduce((d,u)=>{let[f,h]=u;return h===void 0||(d[f]=h),d},{}),c=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((d,u)=>{let{class:f,className:h,...m}=u;return Object.entries(m).every(y=>{let[x,j]=y;return Array.isArray(j)?j.includes({...i,...l}[x]):{...i,...l}[x]===j})?[...d,f,h]:d},[]);return _E(e,o,c,r==null?void 0:r.class,r==null?void 0:r.className)};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jG=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),RL=(...e)=>e.filter((t,r,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===r).join(" ").trim();/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var bG={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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wG=p.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:s,className:a="",children:i,iconNode:o,...l},c)=>p.createElement("svg",{ref:c,...bG,width:t,height:t,stroke:e,strokeWidth:s?Number(r)*24/Number(t):r,className:RL("lucide",a),...l},[...o.map(([d,u])=>p.createElement(d,u)),...Array.isArray(i)?i:[i]]));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ge=(e,t)=>{const r=p.forwardRef(({className:s,...a},i)=>p.createElement(wG,{ref:i,iconNode:t,className:RL(`lucide-${jG(e)}`,s),...a}));return r.displayName=`${e}`,r};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sj=ge("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NG=ge("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xd=ge("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Da=ge("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SG=ge("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.462.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=ge("Award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]);/** * @license lucide-react v0.462.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=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _G=ge("BookA",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m8 13 4-7 4 7",key:"4rari8"}],["path",{d:"M9.1 11h5.7",key:"1gkovt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $L=ge("BookMarked",[["path",{d:"M10 2v8l3-3 3 3V2",key:"sqw3rj"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kt=ge("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CG=ge("Book",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kG=ge("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/** * @license lucide-react v0.462.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=ge("Briefcase",[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lh=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IL=ge("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.462.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=ge("CalendarCheck",[["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"}],["path",{d:"m9 16 2 2 4-4",key:"19s6y9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AG=ge("CalendarDays",[["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"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EG=ge("CalendarOff",[["path",{d:"M4.2 4.2A2 2 0 0 0 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 1.82-1.18",key:"16swn3"}],["path",{d:"M21 15.5V6a2 2 0 0 0-2-2H9.5",key:"yhw86o"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h7",key:"1wap6i"}],["path",{d:"M21 10h-5.5",key:"quycpq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yp=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OG=ge("ChartBar",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16h8",key:"srdodz"}],["path",{d:"M7 11h12",key:"127s9w"}],["path",{d:"M7 6h3",key:"w9rmul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Il=ge("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aa=ge("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** * @license lucide-react v0.462.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=ge("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** * @license lucide-react v0.462.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=ge("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Si=ge("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** * @license lucide-react v0.462.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=ge("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nv=ge("CircleAlert",[["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.462.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=ge("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.462.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=ge("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FL=ge("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fh=ge("CircleHelp",[["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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TG=ge("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bf=ge("CircleX",[["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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _j=ge("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MG=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gd=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vd=ge("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RG=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BL=ge("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.462.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=ge("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $G=ge("Dot",[["circle",{cx:"12.1",cy:"12.1",r:"1",key:"18d7e5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yd=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CE=ge("Ellipsis",[["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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IG=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E1=ge("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uc=ge("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zL=ge("FileSpreadsheet",[["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:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yn=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DG=ge("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/** * @license lucide-react v0.462.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=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LG=ge("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FG=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BG=ge("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.462.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=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kE=ge("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.462.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=ge("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cj=ge("Headphones",[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zG=ge("History",[["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"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VL=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VG=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fk=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jc=ge("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qG=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WG=ge("Languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oo=ge("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.462.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=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UG=ge("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KG=ge("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kj=ge("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.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=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Re=ge("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HG=ge("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zf=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qL=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WL=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bh=ge("Megaphone",[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]]);/** * @license lucide-react v0.462.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=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pj=ge("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UL=ge("Music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QG=ge("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YG=ge("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/** * @license lucide-react v0.462.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=ge("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KL=ge("PenTool",[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uu=ge("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.462.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=ge("Percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O1=ge("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pk=ge("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mt=ge("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xk=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GL=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZG=ge("School",[["path",{d:"M14 22v-4a2 2 0 1 0-4 0v4",key:"hhkicm"}],["path",{d:"m18 10 3.447 1.724a1 1 0 0 1 .553.894V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-7.382a1 1 0 0 1 .553-.894L6 10",key:"1xqip1"}],["path",{d:"M18 5v17",key:"1sw6gf"}],["path",{d:"m4 6 7.106-3.553a2 2 0 0 1 1.788 0L20 6",key:"9d2mlk"}],["path",{d:"M6 5v17",key:"1xfsm0"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JG=ge("ScrollText",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const en=ge("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gl=ge("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PE=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gk=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Os=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eH=ge("SkipForward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lt=ge("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HL=ge("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vk=ge("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aj=ge("Ticket",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $t=ge("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.462.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=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pl=ge("TriangleAlert",[["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-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tH=ge("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]]);/** * @license lucide-react v0.462.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=ge("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.462.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=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nH=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ej=ge("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.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const as=ge("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.462.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=ge("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QL=ge("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rH=ge("Warehouse",[["path",{d:"M22 8.35V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8.35A2 2 0 0 1 3.26 6.5l8-3.2a2 2 0 0 1 1.48 0l8 3.2A2 2 0 0 1 22 8.35Z",key:"gksnxg"}],["path",{d:"M6 18h12",key:"9pbo8z"}],["path",{d:"M6 14h12",key:"4cwo0f"}],["rect",{width:"12",height:"12",x:"6",y:"10",key:"apd30q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YL=ge("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ts=ge("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),yk="-",sH=e=>{const t=iH(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:o=>{const l=o.split(yk);return l[0]===""&&l.length!==1&&l.shift(),XL(l,t)||aH(o)},getConflictingClassGroupIds:(o,l)=>{const c=r[o]||[];return l&&s[o]?[...c,...s[o]]:c}}},XL=(e,t)=>{var o;if(e.length===0)return t.classGroupId;const r=e[0],s=t.nextPart.get(r),a=s?XL(e.slice(1),s):void 0;if(a)return a;if(t.validators.length===0)return;const i=e.join(yk);return(o=t.validators.find(({validator:l})=>l(i)))==null?void 0:o.classGroupId},AE=/^\[(.+)\]$/,aH=e=>{if(AE.test(e)){const t=AE.exec(e)[1],r=t==null?void 0:t.substring(0,t.indexOf(":"));if(r)return"arbitrary.."+r}},iH=e=>{const{theme:t,prefix:r}=e,s={nextPart:new Map,validators:[]};return lH(Object.entries(e.classGroups),r).forEach(([i,o])=>{T1(o,s,i,t)}),s},T1=(e,t,r,s)=>{e.forEach(a=>{if(typeof a=="string"){const i=a===""?t:EE(t,a);i.classGroupId=r;return}if(typeof a=="function"){if(oH(a)){T1(a(s),t,r,s);return}t.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([i,o])=>{T1(o,EE(t,i),r,s)})})},EE=(e,t)=>{let r=e;return t.split(yk).forEach(s=>{r.nextPart.has(s)||r.nextPart.set(s,{nextPart:new Map,validators:[]}),r=r.nextPart.get(s)}),r},oH=e=>e.isThemeGetter,lH=(e,t)=>t?e.map(([r,s])=>{const a=s.map(i=>typeof i=="string"?t+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([o,l])=>[t+o,l])):i);return[r,a]}):e,cH=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=new Map,s=new Map;const a=(i,o)=>{r.set(i,o),t++,t>e&&(t=0,s=r,r=new Map)};return{get(i){let o=r.get(i);if(o!==void 0)return o;if((o=s.get(i))!==void 0)return a(i,o),o},set(i,o){r.has(i)?r.set(i,o):a(i,o)}}},ZL="!",dH=e=>{const{separator:t,experimentalParseClassName:r}=e,s=t.length===1,a=t[0],i=t.length,o=l=>{const c=[];let d=0,u=0,f;for(let j=0;ju?f-u:void 0;return{modifiers:c,hasImportantModifier:m,baseClassName:y,maybePostfixModifierPosition:x}};return r?l=>r({className:l,parseClassName:o}):o},uH=e=>{if(e.length<=1)return e;const t=[];let r=[];return e.forEach(s=>{s[0]==="["?(t.push(...r.sort(),s),r=[]):r.push(s)}),t.push(...r.sort()),t},fH=e=>({cache:cH(e.cacheSize),parseClassName:dH(e),...sH(e)}),mH=/\s+/,hH=(e,t)=>{const{parseClassName:r,getClassGroupId:s,getConflictingClassGroupIds:a}=t,i=[],o=e.trim().split(mH);let l="";for(let c=o.length-1;c>=0;c-=1){const d=o[c],{modifiers:u,hasImportantModifier:f,baseClassName:h,maybePostfixModifierPosition:m}=r(d);let y=!!m,x=s(y?h.substring(0,m):h);if(!x){if(!y){l=d+(l.length>0?" "+l:l);continue}if(x=s(h),!x){l=d+(l.length>0?" "+l:l);continue}y=!1}const j=uH(u).join(":"),v=f?j+ZL:j,g=v+x;if(i.includes(g))continue;i.push(g);const b=a(x,y);for(let N=0;N0?" "+l:l)}return l};function pH(){let e=0,t,r,s="";for(;e{if(typeof e=="string")return e;let t,r="";for(let s=0;sf(u),e());return r=fH(d),s=r.cache.get,a=r.cache.set,i=l,l(c)}function l(c){const d=s(c);if(d)return d;const u=hH(c,r);return a(c,u),u}return function(){return i(pH.apply(null,arguments))}}const gn=e=>{const t=r=>r[e]||[];return t.isThemeGetter=!0,t},e3=/^\[(?:([a-z-]+):)?(.+)\]$/i,gH=/^\d+\/\d+$/,vH=new Set(["px","full","screen"]),yH=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,jH=/\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$/,bH=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,wH=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,NH=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Mi=e=>yu(e)||vH.has(e)||gH.test(e),Ro=e=>Vf(e,"length",OH),yu=e=>!!e&&!Number.isNaN(Number(e)),dw=e=>Vf(e,"number",yu),km=e=>!!e&&Number.isInteger(Number(e)),SH=e=>e.endsWith("%")&&yu(e.slice(0,-1)),St=e=>e3.test(e),$o=e=>yH.test(e),_H=new Set(["length","size","percentage"]),CH=e=>Vf(e,_H,t3),kH=e=>Vf(e,"position",t3),PH=new Set(["image","url"]),AH=e=>Vf(e,PH,MH),EH=e=>Vf(e,"",TH),Pm=()=>!0,Vf=(e,t,r)=>{const s=e3.exec(e);return s?s[1]?typeof t=="string"?s[1]===t:t.has(s[1]):r(s[2]):!1},OH=e=>jH.test(e)&&!bH.test(e),t3=()=>!1,TH=e=>wH.test(e),MH=e=>NH.test(e),RH=()=>{const e=gn("colors"),t=gn("spacing"),r=gn("blur"),s=gn("brightness"),a=gn("borderColor"),i=gn("borderRadius"),o=gn("borderSpacing"),l=gn("borderWidth"),c=gn("contrast"),d=gn("grayscale"),u=gn("hueRotate"),f=gn("invert"),h=gn("gap"),m=gn("gradientColorStops"),y=gn("gradientColorStopPositions"),x=gn("inset"),j=gn("margin"),v=gn("opacity"),g=gn("padding"),b=gn("saturate"),N=gn("scale"),w=gn("sepia"),S=gn("skew"),_=gn("space"),C=gn("translate"),P=()=>["auto","contain","none"],D=()=>["auto","hidden","clip","visible","scroll"],z=()=>["auto",St,t],O=()=>[St,t],V=()=>["",Mi,Ro],A=()=>["auto",yu,St],$=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],B=()=>["solid","dashed","dotted","double","none"],I=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],k=()=>["start","end","center","between","around","evenly","stretch"],M=()=>["","0",St],K=()=>["auto","avoid","all","avoid-page","page","left","right","column"],X=()=>[yu,St];return{cacheSize:500,separator:":",theme:{colors:[Pm],spacing:[Mi,Ro],blur:["none","",$o,St],brightness:X(),borderColor:[e],borderRadius:["none","","full",$o,St],borderSpacing:O(),borderWidth:V(),contrast:X(),grayscale:M(),hueRotate:X(),invert:M(),gap:O(),gradientColorStops:[e],gradientColorStopPositions:[SH,Ro],inset:z(),margin:z(),opacity:X(),padding:O(),saturate:X(),scale:X(),sepia:M(),skew:X(),space:O(),translate:O()},classGroups:{aspect:[{aspect:["auto","square","video",St]}],container:["container"],columns:[{columns:[$o]}],"break-after":[{"break-after":K()}],"break-before":[{"break-before":K()}],"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:[...$(),St]}],overflow:[{overflow:D()}],"overflow-x":[{"overflow-x":D()}],"overflow-y":[{"overflow-y":D()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[x]}],"inset-x":[{"inset-x":[x]}],"inset-y":[{"inset-y":[x]}],start:[{start:[x]}],end:[{end:[x]}],top:[{top:[x]}],right:[{right:[x]}],bottom:[{bottom:[x]}],left:[{left:[x]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",km,St]}],basis:[{basis:z()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",St]}],grow:[{grow:M()}],shrink:[{shrink:M()}],order:[{order:["first","last","none",km,St]}],"grid-cols":[{"grid-cols":[Pm]}],"col-start-end":[{col:["auto",{span:["full",km,St]},St]}],"col-start":[{"col-start":A()}],"col-end":[{"col-end":A()}],"grid-rows":[{"grid-rows":[Pm]}],"row-start-end":[{row:["auto",{span:[km,St]},St]}],"row-start":[{"row-start":A()}],"row-end":[{"row-end":A()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",St]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",St]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"justify-content":[{justify:["normal",...k()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...k(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...k(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[g]}],px:[{px:[g]}],py:[{py:[g]}],ps:[{ps:[g]}],pe:[{pe:[g]}],pt:[{pt:[g]}],pr:[{pr:[g]}],pb:[{pb:[g]}],pl:[{pl:[g]}],m:[{m:[j]}],mx:[{mx:[j]}],my:[{my:[j]}],ms:[{ms:[j]}],me:[{me:[j]}],mt:[{mt:[j]}],mr:[{mr:[j]}],mb:[{mb:[j]}],ml:[{ml:[j]}],"space-x":[{"space-x":[_]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[_]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",St,t]}],"min-w":[{"min-w":[St,t,"min","max","fit"]}],"max-w":[{"max-w":[St,t,"none","full","min","max","fit","prose",{screen:[$o]},$o]}],h:[{h:[St,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[St,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[St,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[St,t,"auto","min","max","fit"]}],"font-size":[{text:["base",$o,Ro]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",dw]}],"font-family":[{font:[Pm]}],"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",St]}],"line-clamp":[{"line-clamp":["none",yu,dw]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Mi,St]}],"list-image":[{"list-image":["none",St]}],"list-style-type":[{list:["none","disc","decimal",St]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[v]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[v]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...B(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Mi,Ro]}],"underline-offset":[{"underline-offset":["auto",Mi,St]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:O()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",St]}],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",St]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[v]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...$(),kH]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",CH]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},AH]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[y]}],"gradient-via-pos":[{via:[y]}],"gradient-to-pos":[{to:[y]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],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:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[v]}],"border-style":[{border:[...B(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[v]}],"divide-style":[{divide:B()}],"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:["",...B()]}],"outline-offset":[{"outline-offset":[Mi,St]}],"outline-w":[{outline:[Mi,Ro]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:V()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[v]}],"ring-offset-w":[{"ring-offset":[Mi,Ro]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",$o,EH]}],"shadow-color":[{shadow:[Pm]}],opacity:[{opacity:[v]}],"mix-blend":[{"mix-blend":[...I(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":I()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[s]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",$o,St]}],grayscale:[{grayscale:[d]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[f]}],saturate:[{saturate:[b]}],sepia:[{sepia:[w]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[s]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[d]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[v]}],"backdrop-saturate":[{"backdrop-saturate":[b]}],"backdrop-sepia":[{"backdrop-sepia":[w]}],"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",St]}],duration:[{duration:X()}],ease:[{ease:["linear","in","out","in-out",St]}],delay:[{delay:X()}],animate:[{animate:["none","spin","ping","pulse","bounce",St]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[N]}],"scale-x":[{"scale-x":[N]}],"scale-y":[{"scale-y":[N]}],rotate:[{rotate:[km,St]}],"translate-x":[{"translate-x":[C]}],"translate-y":[{"translate-y":[C]}],"skew-x":[{"skew-x":[S]}],"skew-y":[{"skew-y":[S]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",St]}],accent:[{accent:["auto",e]}],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",St]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"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",St]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Mi,Ro,dw]}],stroke:[{stroke:[e,"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"]}}},$H=xH(RH);function he(...e){return $H(gt(e))}const IH=yG,n3=p.forwardRef(({className:e,...t},r)=>n.jsx(kL,{ref:r,className:he("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...t}));n3.displayName=kL.displayName;const DH=pd("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),r3=p.forwardRef(({className:e,variant:t,...r},s)=>n.jsx(PL,{ref:s,className:he(DH({variant:t}),e),...r}));r3.displayName=PL.displayName;const LH=p.forwardRef(({className:e,...t},r)=>n.jsx(OL,{ref:r,className:he("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",e),...t}));LH.displayName=OL.displayName;const s3=p.forwardRef(({className:e,...t},r)=>n.jsx(TL,{ref:r,className:he("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:n.jsx(ts,{className:"h-4 w-4"})}));s3.displayName=TL.displayName;const a3=p.forwardRef(({className:e,...t},r)=>n.jsx(AL,{ref:r,className:he("text-sm font-semibold",e),...t}));a3.displayName=AL.displayName;const i3=p.forwardRef(({className:e,...t},r)=>n.jsx(EL,{ref:r,className:he("text-sm opacity-90",e),...t}));i3.displayName=EL.displayName;function FH(){const{toasts:e}=He();return n.jsxs(IH,{children:[e.map(function({id:t,title:r,description:s,action:a,...i}){return n.jsxs(r3,{...i,children:[n.jsxs("div",{className:"grid gap-1",children:[r&&n.jsx(a3,{children:r}),s&&n.jsx(i3,{children:s})]}),a,n.jsx(s3,{})]},t)}),n.jsx(n3,{})]})}var OE=["light","dark"],BH="(prefers-color-scheme: dark)",zH=p.createContext(void 0),VH={setTheme:e=>{},themes:[]},qH=()=>{var e;return(e=p.useContext(zH))!=null?e:VH};p.memo(({forcedTheme:e,storageKey:t,attribute:r,enableSystem:s,enableColorScheme:a,defaultTheme:i,value:o,attrs:l,nonce:c})=>{let d=i==="system",u=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${l.map(y=>`'${y}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,f=a?OE.includes(i)&&i?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${i}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",h=(y,x=!1,j=!0)=>{let v=o?o[y]:y,g=x?y+"|| ''":`'${v}'`,b="";return a&&j&&!x&&OE.includes(y)&&(b+=`d.style.colorScheme = '${y}';`),r==="class"?x||v?b+=`c.add(${g})`:b+="null":v&&(b+=`d[s](n,${g})`),b},m=e?`!function(){${u}${h(e)}}()`:s?`!function(){try{${u}var e=localStorage.getItem('${t}');if('system'===e||(!e&&${d})){var t='${BH}',m=window.matchMedia(t);if(m.media!==t||m.matches){${h("dark")}}else{${h("light")}}}else if(e){${o?`var x=${JSON.stringify(o)};`:""}${h(o?"x[e]":"e",!0)}}${d?"":"else{"+h(i,!1,!1)+"}"}${f}}catch(e){}}()`:`!function(){try{${u}var e=localStorage.getItem('${t}');if(e){${o?`var x=${JSON.stringify(o)};`:""}${h(o?"x[e]":"e",!0)}}else{${h(i,!1,!1)};}${f}}catch(t){}}();`;return p.createElement("script",{nonce:c,dangerouslySetInnerHTML:{__html:m}})});var WH=e=>{switch(e){case"success":return GH;case"info":return QH;case"warning":return HH;case"error":return YH;default:return null}},UH=Array(12).fill(0),KH=({visible:e,className:t})=>F.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},F.createElement("div",{className:"sonner-spinner"},UH.map((r,s)=>F.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),GH=F.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},F.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"})),HH=F.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},F.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"})),QH=F.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},F.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"})),YH=F.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},F.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"})),XH=F.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"},F.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),F.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),ZH=()=>{let[e,t]=F.useState(document.hidden);return F.useEffect(()=>{let r=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),e},M1=1,JH=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:r,...s}=e,a=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:M1++,i=this.toasts.find(l=>l.id===a),o=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),i?this.toasts=this.toasts.map(l=>l.id===a?(this.publish({...l,...e,id:a,title:r}),{...l,...e,id:a,dismissible:o,title:r}):l):this.addToast({title:r,...s,dismissible:o,id:a}),a},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(r=>r({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let r;t.loading!==void 0&&(r=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let s=e instanceof Promise?e:e(),a=r!==void 0,i,o=s.then(async c=>{if(i=["resolve",c],F.isValidElement(c))a=!1,this.create({id:r,type:"default",message:c});else if(tQ(c)&&!c.ok){a=!1;let d=typeof t.error=="function"?await t.error(`HTTP error! status: ${c.status}`):t.error,u=typeof t.description=="function"?await t.description(`HTTP error! status: ${c.status}`):t.description;this.create({id:r,type:"error",message:d,description:u})}else if(t.success!==void 0){a=!1;let d=typeof t.success=="function"?await t.success(c):t.success,u=typeof t.description=="function"?await t.description(c):t.description;this.create({id:r,type:"success",message:d,description:u})}}).catch(async c=>{if(i=["reject",c],t.error!==void 0){a=!1;let d=typeof t.error=="function"?await t.error(c):t.error,u=typeof t.description=="function"?await t.description(c):t.description;this.create({id:r,type:"error",message:d,description:u})}}).finally(()=>{var c;a&&(this.dismiss(r),r=void 0),(c=t.finally)==null||c.call(t)}),l=()=>new Promise((c,d)=>o.then(()=>i[0]==="reject"?d(i[1]):c(i[1])).catch(d));return typeof r!="string"&&typeof r!="number"?{unwrap:l}:Object.assign(r,{unwrap:l})},this.custom=(e,t)=>{let r=(t==null?void 0:t.id)||M1++;return this.create({jsx:e(r),id:r,...t}),r},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},cs=new JH,eQ=(e,t)=>{let r=(t==null?void 0:t.id)||M1++;return cs.addToast({title:e,...t,id:r}),r},tQ=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",nQ=eQ,rQ=()=>cs.toasts,sQ=()=>cs.getActiveToasts(),ct=Object.assign(nQ,{success:cs.success,info:cs.info,warning:cs.warning,error:cs.error,custom:cs.custom,message:cs.message,promise:cs.promise,dismiss:cs.dismiss,loading:cs.loading},{getHistory:rQ,getToasts:sQ});function aQ(e,{insertAt:t}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",t==="top"&&r.firstChild?r.insertBefore(s,r.firstChild):r.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}aQ(`: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 ng(e){return e.label!==void 0}var iQ=3,oQ="32px",lQ="16px",TE=4e3,cQ=356,dQ=14,uQ=20,fQ=200;function ba(...e){return e.filter(Boolean).join(" ")}function mQ(e){let[t,r]=e.split("-"),s=[];return t&&s.push(t),r&&s.push(r),s}var hQ=e=>{var t,r,s,a,i,o,l,c,d,u,f;let{invert:h,toast:m,unstyled:y,interacting:x,setHeights:j,visibleToasts:v,heights:g,index:b,toasts:N,expanded:w,removeToast:S,defaultRichColors:_,closeButton:C,style:P,cancelButtonStyle:D,actionButtonStyle:z,className:O="",descriptionClassName:V="",duration:A,position:$,gap:B,loadingIcon:I,expandByDefault:k,classNames:M,icons:K,closeButtonAriaLabel:X="Close toast",pauseWhenPageIsHidden:re}=e,[Z,te]=F.useState(null),[xe,me]=F.useState(null),[ne,_e]=F.useState(!1),[ue,we]=F.useState(!1),[ve,le]=F.useState(!1),[ut,Se]=F.useState(!1),[Ve,pt]=F.useState(!1),[Pt,Qt]=F.useState(0),[kt,Pn]=F.useState(0),er=F.useRef(m.duration||A||TE),pn=F.useRef(null),H=F.useRef(null),J=b===0,ce=b+1<=v,Ne=m.type,ke=m.dismissible!==!1,Ie=m.className||"",Ye=m.descriptionClassName||"",jt=F.useMemo(()=>g.findIndex(wt=>wt.toastId===m.id)||0,[g,m.id]),Rt=F.useMemo(()=>{var wt;return(wt=m.closeButton)!=null?wt:C},[m.closeButton,C]),Kn=F.useMemo(()=>m.duration||A||TE,[m.duration,A]),Mn=F.useRef(0),xn=F.useRef(0),Td=F.useRef(0),Za=F.useRef(null),[gm,T0]=$.split("-"),vm=F.useMemo(()=>g.reduce((wt,nn,Sn)=>Sn>=jt?wt:wt+nn.height,0),[g,jt]),Mx=ZH(),Rx=m.invert||h,M0=Ne==="loading";xn.current=F.useMemo(()=>jt*B+vm,[jt,vm]),F.useEffect(()=>{er.current=Kn},[Kn]),F.useEffect(()=>{_e(!0)},[]),F.useEffect(()=>{let wt=H.current;if(wt){let nn=wt.getBoundingClientRect().height;return Pn(nn),j(Sn=>[{toastId:m.id,height:nn,position:m.position},...Sn]),()=>j(Sn=>Sn.filter(ga=>ga.toastId!==m.id))}},[j,m.id]),F.useLayoutEffect(()=>{if(!ne)return;let wt=H.current,nn=wt.style.height;wt.style.height="auto";let Sn=wt.getBoundingClientRect().height;wt.style.height=nn,Pn(Sn),j(ga=>ga.find(va=>va.toastId===m.id)?ga.map(va=>va.toastId===m.id?{...va,height:Sn}:va):[{toastId:m.id,height:Sn,position:m.position},...ga])},[ne,m.title,m.description,j,m.id]);let Eo=F.useCallback(()=>{we(!0),Qt(xn.current),j(wt=>wt.filter(nn=>nn.toastId!==m.id)),setTimeout(()=>{S(m)},fQ)},[m,S,j,xn]);F.useEffect(()=>{if(m.promise&&Ne==="loading"||m.duration===1/0||m.type==="loading")return;let wt;return w||x||re&&Mx?(()=>{if(Td.current{var nn;(nn=m.onAutoClose)==null||nn.call(m,m),Eo()},er.current)),()=>clearTimeout(wt)},[w,x,m,Ne,re,Mx,Eo]),F.useEffect(()=>{m.delete&&Eo()},[Eo,m.delete]);function KW(){var wt,nn,Sn;return K!=null&&K.loading?F.createElement("div",{className:ba(M==null?void 0:M.loader,(wt=m==null?void 0:m.classNames)==null?void 0:wt.loader,"sonner-loader"),"data-visible":Ne==="loading"},K.loading):I?F.createElement("div",{className:ba(M==null?void 0:M.loader,(nn=m==null?void 0:m.classNames)==null?void 0:nn.loader,"sonner-loader"),"data-visible":Ne==="loading"},I):F.createElement(KH,{className:ba(M==null?void 0:M.loader,(Sn=m==null?void 0:m.classNames)==null?void 0:Sn.loader),visible:Ne==="loading"})}return F.createElement("li",{tabIndex:0,ref:H,className:ba(O,Ie,M==null?void 0:M.toast,(t=m==null?void 0:m.classNames)==null?void 0:t.toast,M==null?void 0:M.default,M==null?void 0:M[Ne],(r=m==null?void 0:m.classNames)==null?void 0:r[Ne]),"data-sonner-toast":"","data-rich-colors":(s=m.richColors)!=null?s:_,"data-styled":!(m.jsx||m.unstyled||y),"data-mounted":ne,"data-promise":!!m.promise,"data-swiped":Ve,"data-removed":ue,"data-visible":ce,"data-y-position":gm,"data-x-position":T0,"data-index":b,"data-front":J,"data-swiping":ve,"data-dismissible":ke,"data-type":Ne,"data-invert":Rx,"data-swipe-out":ut,"data-swipe-direction":xe,"data-expanded":!!(w||k&&ne),style:{"--index":b,"--toasts-before":b,"--z-index":N.length-b,"--offset":`${ue?Pt:xn.current}px`,"--initial-height":k?"auto":`${kt}px`,...P,...m.style},onDragEnd:()=>{le(!1),te(null),Za.current=null},onPointerDown:wt=>{M0||!ke||(pn.current=new Date,Qt(xn.current),wt.target.setPointerCapture(wt.pointerId),wt.target.tagName!=="BUTTON"&&(le(!0),Za.current={x:wt.clientX,y:wt.clientY}))},onPointerUp:()=>{var wt,nn,Sn,ga;if(ut||!ke)return;Za.current=null;let va=Number(((wt=H.current)==null?void 0:wt.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Oo=Number(((nn=H.current)==null?void 0:nn.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),rc=new Date().getTime()-((Sn=pn.current)==null?void 0:Sn.getTime()),ya=Z==="x"?va:Oo,To=Math.abs(ya)/rc;if(Math.abs(ya)>=uQ||To>.11){Qt(xn.current),(ga=m.onDismiss)==null||ga.call(m,m),me(Z==="x"?va>0?"right":"left":Oo>0?"down":"up"),Eo(),Se(!0),pt(!1);return}le(!1),te(null)},onPointerMove:wt=>{var nn,Sn,ga,va;if(!Za.current||!ke||((nn=window.getSelection())==null?void 0:nn.toString().length)>0)return;let Oo=wt.clientY-Za.current.y,rc=wt.clientX-Za.current.x,ya=(Sn=e.swipeDirections)!=null?Sn:mQ($);!Z&&(Math.abs(rc)>1||Math.abs(Oo)>1)&&te(Math.abs(rc)>Math.abs(Oo)?"x":"y");let To={x:0,y:0};Z==="y"?(ya.includes("top")||ya.includes("bottom"))&&(ya.includes("top")&&Oo<0||ya.includes("bottom")&&Oo>0)&&(To.y=Oo):Z==="x"&&(ya.includes("left")||ya.includes("right"))&&(ya.includes("left")&&rc<0||ya.includes("right")&&rc>0)&&(To.x=rc),(Math.abs(To.x)>0||Math.abs(To.y)>0)&&pt(!0),(ga=H.current)==null||ga.style.setProperty("--swipe-amount-x",`${To.x}px`),(va=H.current)==null||va.style.setProperty("--swipe-amount-y",`${To.y}px`)}},Rt&&!m.jsx?F.createElement("button",{"aria-label":X,"data-disabled":M0,"data-close-button":!0,onClick:M0||!ke?()=>{}:()=>{var wt;Eo(),(wt=m.onDismiss)==null||wt.call(m,m)},className:ba(M==null?void 0:M.closeButton,(a=m==null?void 0:m.classNames)==null?void 0:a.closeButton)},(i=K==null?void 0:K.close)!=null?i:XH):null,m.jsx||p.isValidElement(m.title)?m.jsx?m.jsx:typeof m.title=="function"?m.title():m.title:F.createElement(F.Fragment,null,Ne||m.icon||m.promise?F.createElement("div",{"data-icon":"",className:ba(M==null?void 0:M.icon,(o=m==null?void 0:m.classNames)==null?void 0:o.icon)},m.promise||m.type==="loading"&&!m.icon?m.icon||KW():null,m.type!=="loading"?m.icon||(K==null?void 0:K[Ne])||WH(Ne):null):null,F.createElement("div",{"data-content":"",className:ba(M==null?void 0:M.content,(l=m==null?void 0:m.classNames)==null?void 0:l.content)},F.createElement("div",{"data-title":"",className:ba(M==null?void 0:M.title,(c=m==null?void 0:m.classNames)==null?void 0:c.title)},typeof m.title=="function"?m.title():m.title),m.description?F.createElement("div",{"data-description":"",className:ba(V,Ye,M==null?void 0:M.description,(d=m==null?void 0:m.classNames)==null?void 0:d.description)},typeof m.description=="function"?m.description():m.description):null),p.isValidElement(m.cancel)?m.cancel:m.cancel&&ng(m.cancel)?F.createElement("button",{"data-button":!0,"data-cancel":!0,style:m.cancelButtonStyle||D,onClick:wt=>{var nn,Sn;ng(m.cancel)&&ke&&((Sn=(nn=m.cancel).onClick)==null||Sn.call(nn,wt),Eo())},className:ba(M==null?void 0:M.cancelButton,(u=m==null?void 0:m.classNames)==null?void 0:u.cancelButton)},m.cancel.label):null,p.isValidElement(m.action)?m.action:m.action&&ng(m.action)?F.createElement("button",{"data-button":!0,"data-action":!0,style:m.actionButtonStyle||z,onClick:wt=>{var nn,Sn;ng(m.action)&&((Sn=(nn=m.action).onClick)==null||Sn.call(nn,wt),!wt.defaultPrevented&&Eo())},className:ba(M==null?void 0:M.actionButton,(f=m==null?void 0:m.classNames)==null?void 0:f.actionButton)},m.action.label):null))};function ME(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function pQ(e,t){let r={};return[e,t].forEach((s,a)=>{let i=a===1,o=i?"--mobile-offset":"--offset",l=i?lQ:oQ;function c(d){["top","right","bottom","left"].forEach(u=>{r[`${o}-${u}`]=typeof d=="number"?`${d}px`:d})}typeof s=="number"||typeof s=="string"?c(s):typeof s=="object"?["top","right","bottom","left"].forEach(d=>{s[d]===void 0?r[`${o}-${d}`]=l:r[`${o}-${d}`]=typeof s[d]=="number"?`${s[d]}px`:s[d]}):c(l)}),r}var xQ=p.forwardRef(function(e,t){let{invert:r,position:s="bottom-right",hotkey:a=["altKey","KeyT"],expand:i,closeButton:o,className:l,offset:c,mobileOffset:d,theme:u="light",richColors:f,duration:h,style:m,visibleToasts:y=iQ,toastOptions:x,dir:j=ME(),gap:v=dQ,loadingIcon:g,icons:b,containerAriaLabel:N="Notifications",pauseWhenPageIsHidden:w}=e,[S,_]=F.useState([]),C=F.useMemo(()=>Array.from(new Set([s].concat(S.filter(re=>re.position).map(re=>re.position)))),[S,s]),[P,D]=F.useState([]),[z,O]=F.useState(!1),[V,A]=F.useState(!1),[$,B]=F.useState(u!=="system"?u:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),I=F.useRef(null),k=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),M=F.useRef(null),K=F.useRef(!1),X=F.useCallback(re=>{_(Z=>{var te;return(te=Z.find(xe=>xe.id===re.id))!=null&&te.delete||cs.dismiss(re.id),Z.filter(({id:xe})=>xe!==re.id)})},[]);return F.useEffect(()=>cs.subscribe(re=>{if(re.dismiss){_(Z=>Z.map(te=>te.id===re.id?{...te,delete:!0}:te));return}setTimeout(()=>{lL.flushSync(()=>{_(Z=>{let te=Z.findIndex(xe=>xe.id===re.id);return te!==-1?[...Z.slice(0,te),{...Z[te],...re},...Z.slice(te+1)]:[re,...Z]})})})}),[]),F.useEffect(()=>{if(u!=="system"){B(u);return}if(u==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?B("dark"):B("light")),typeof window>"u")return;let re=window.matchMedia("(prefers-color-scheme: dark)");try{re.addEventListener("change",({matches:Z})=>{B(Z?"dark":"light")})}catch{re.addListener(({matches:te})=>{try{B(te?"dark":"light")}catch(xe){console.error(xe)}})}},[u]),F.useEffect(()=>{S.length<=1&&O(!1)},[S]),F.useEffect(()=>{let re=Z=>{var te,xe;a.every(me=>Z[me]||Z.code===me)&&(O(!0),(te=I.current)==null||te.focus()),Z.code==="Escape"&&(document.activeElement===I.current||(xe=I.current)!=null&&xe.contains(document.activeElement))&&O(!1)};return document.addEventListener("keydown",re),()=>document.removeEventListener("keydown",re)},[a]),F.useEffect(()=>{if(I.current)return()=>{M.current&&(M.current.focus({preventScroll:!0}),M.current=null,K.current=!1)}},[I.current]),F.createElement("section",{ref:t,"aria-label":`${N} ${k}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},C.map((re,Z)=>{var te;let[xe,me]=re.split("-");return S.length?F.createElement("ol",{key:re,dir:j==="auto"?ME():j,tabIndex:-1,ref:I,className:l,"data-sonner-toaster":!0,"data-theme":$,"data-y-position":xe,"data-lifted":z&&S.length>1&&!i,"data-x-position":me,style:{"--front-toast-height":`${((te=P[0])==null?void 0:te.height)||0}px`,"--width":`${cQ}px`,"--gap":`${v}px`,...m,...pQ(c,d)},onBlur:ne=>{K.current&&!ne.currentTarget.contains(ne.relatedTarget)&&(K.current=!1,M.current&&(M.current.focus({preventScroll:!0}),M.current=null))},onFocus:ne=>{ne.target instanceof HTMLElement&&ne.target.dataset.dismissible==="false"||K.current||(K.current=!0,M.current=ne.relatedTarget)},onMouseEnter:()=>O(!0),onMouseMove:()=>O(!0),onMouseLeave:()=>{V||O(!1)},onDragEnd:()=>O(!1),onPointerDown:ne=>{ne.target instanceof HTMLElement&&ne.target.dataset.dismissible==="false"||A(!0)},onPointerUp:()=>A(!1)},S.filter(ne=>!ne.position&&Z===0||ne.position===re).map((ne,_e)=>{var ue,we;return F.createElement(hQ,{key:ne.id,icons:b,index:_e,toast:ne,defaultRichColors:f,duration:(ue=x==null?void 0:x.duration)!=null?ue:h,className:x==null?void 0:x.className,descriptionClassName:x==null?void 0:x.descriptionClassName,invert:r,visibleToasts:y,closeButton:(we=x==null?void 0:x.closeButton)!=null?we:o,interacting:V,position:re,style:x==null?void 0:x.style,unstyled:x==null?void 0:x.unstyled,classNames:x==null?void 0:x.classNames,cancelButtonStyle:x==null?void 0:x.cancelButtonStyle,actionButtonStyle:x==null?void 0:x.actionButtonStyle,removeToast:X,toasts:S.filter(ve=>ve.position==ne.position),heights:P.filter(ve=>ve.position==ne.position),setHeights:D,expandByDefault:i,gap:v,loadingIcon:g,expanded:z,pauseWhenPageIsHidden:w,swipeDirections:e.swipeDirections})})):null}))});const gQ=({...e})=>{const{theme:t="system"}=qH();return n.jsx(xQ,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};var vQ=ij[" useId ".trim().toString()]||(()=>{}),yQ=0;function ys(e){const[t,r]=p.useState(vQ());return Ln(()=>{r(s=>s??String(yQ++))},[e]),e||(t?`radix-${t}`:"")}const jQ=["top","right","bottom","left"],Al=Math.min,Es=Math.max,Sv=Math.round,rg=Math.floor,mi=e=>({x:e,y:e}),bQ={left:"right",right:"left",bottom:"top",top:"bottom"};function R1(e,t,r){return Es(e,Al(t,r))}function lo(e,t){return typeof e=="function"?e(t):e}function co(e){return e.split("-")[0]}function qf(e){return e.split("-")[1]}function jk(e){return e==="x"?"y":"x"}function bk(e){return e==="y"?"height":"width"}function ii(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function wk(e){return jk(ii(e))}function wQ(e,t,r){r===void 0&&(r=!1);const s=qf(e),a=wk(e),i=bk(a);let o=a==="x"?s===(r?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(o=_v(o)),[o,_v(o)]}function NQ(e){const t=_v(e);return[$1(e),t,$1(t)]}function $1(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const RE=["left","right"],$E=["right","left"],SQ=["top","bottom"],_Q=["bottom","top"];function CQ(e,t,r){switch(e){case"top":case"bottom":return r?t?$E:RE:t?RE:$E;case"left":case"right":return t?SQ:_Q;default:return[]}}function kQ(e,t,r,s){const a=qf(e);let i=CQ(co(e),r==="start",s);return a&&(i=i.map(o=>o+"-"+a),t&&(i=i.concat(i.map($1)))),i}function _v(e){const t=co(e);return bQ[t]+e.slice(t.length)}function PQ(e){return{top:0,right:0,bottom:0,left:0,...e}}function o3(e){return typeof e!="number"?PQ(e):{top:e,right:e,bottom:e,left:e}}function Cv(e){const{x:t,y:r,width:s,height:a}=e;return{width:s,height:a,top:r,left:t,right:t+s,bottom:r+a,x:t,y:r}}function IE(e,t,r){let{reference:s,floating:a}=e;const i=ii(t),o=wk(t),l=bk(o),c=co(t),d=i==="y",u=s.x+s.width/2-a.width/2,f=s.y+s.height/2-a.height/2,h=s[l]/2-a[l]/2;let m;switch(c){case"top":m={x:u,y:s.y-a.height};break;case"bottom":m={x:u,y:s.y+s.height};break;case"right":m={x:s.x+s.width,y:f};break;case"left":m={x:s.x-a.width,y:f};break;default:m={x:s.x,y:s.y}}switch(qf(t)){case"start":m[o]-=h*(r&&d?-1:1);break;case"end":m[o]+=h*(r&&d?-1:1);break}return m}async function AQ(e,t){var r;t===void 0&&(t={});const{x:s,y:a,platform:i,rects:o,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:h=!1,padding:m=0}=lo(t,e),y=o3(m),j=l[h?f==="floating"?"reference":"floating":f],v=Cv(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(j)))==null||r?j:j.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:d,rootBoundary:u,strategy:c})),g=f==="floating"?{x:s,y:a,width:o.floating.width,height:o.floating.height}:o.reference,b=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),N=await(i.isElement==null?void 0:i.isElement(b))?await(i.getScale==null?void 0:i.getScale(b))||{x:1,y:1}:{x:1,y:1},w=Cv(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:g,offsetParent:b,strategy:c}):g);return{top:(v.top-w.top+y.top)/N.y,bottom:(w.bottom-v.bottom+y.bottom)/N.y,left:(v.left-w.left+y.left)/N.x,right:(w.right-v.right+y.right)/N.x}}const EQ=50,OQ=async(e,t,r)=>{const{placement:s="bottom",strategy:a="absolute",middleware:i=[],platform:o}=r,l=o.detectOverflow?o:{...o,detectOverflow:AQ},c=await(o.isRTL==null?void 0:o.isRTL(t));let d=await o.getElementRects({reference:e,floating:t,strategy:a}),{x:u,y:f}=IE(d,s,c),h=s,m=0;const y={};for(let x=0;x({name:"arrow",options:e,async fn(t){const{x:r,y:s,placement:a,rects:i,platform:o,elements:l,middlewareData:c}=t,{element:d,padding:u=0}=lo(e,t)||{};if(d==null)return{};const f=o3(u),h={x:r,y:s},m=wk(a),y=bk(m),x=await o.getDimensions(d),j=m==="y",v=j?"top":"left",g=j?"bottom":"right",b=j?"clientHeight":"clientWidth",N=i.reference[y]+i.reference[m]-h[m]-i.floating[y],w=h[m]-i.reference[m],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(d));let _=S?S[b]:0;(!_||!await(o.isElement==null?void 0:o.isElement(S)))&&(_=l.floating[b]||i.floating[y]);const C=N/2-w/2,P=_/2-x[y]/2-1,D=Al(f[v],P),z=Al(f[g],P),O=D,V=_-x[y]-z,A=_/2-x[y]/2+C,$=R1(O,A,V),B=!c.arrow&&qf(a)!=null&&A!==$&&i.reference[y]/2-(AA<=0)){var z,O;const A=(((z=i.flip)==null?void 0:z.index)||0)+1,$=_[A];if($&&(!(f==="alignment"?g!==ii($):!1)||D.every(k=>ii(k.placement)===g?k.overflows[0]>0:!0)))return{data:{index:A,overflows:D},reset:{placement:$}};let B=(O=D.filter(I=>I.overflows[0]<=0).sort((I,k)=>I.overflows[1]-k.overflows[1])[0])==null?void 0:O.placement;if(!B)switch(m){case"bestFit":{var V;const I=(V=D.filter(k=>{if(S){const M=ii(k.placement);return M===g||M==="y"}return!0}).map(k=>[k.placement,k.overflows.filter(M=>M>0).reduce((M,K)=>M+K,0)]).sort((k,M)=>k[1]-M[1])[0])==null?void 0:V[0];I&&(B=I);break}case"initialPlacement":B=l;break}if(a!==B)return{reset:{placement:B}}}return{}}}};function DE(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function LE(e){return jQ.some(t=>e[t]>=0)}const RQ=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r,platform:s}=t,{strategy:a="referenceHidden",...i}=lo(e,t);switch(a){case"referenceHidden":{const o=await s.detectOverflow(t,{...i,elementContext:"reference"}),l=DE(o,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:LE(l)}}}case"escaped":{const o=await s.detectOverflow(t,{...i,altBoundary:!0}),l=DE(o,r.floating);return{data:{escapedOffsets:l,escaped:LE(l)}}}default:return{}}}}},l3=new Set(["left","top"]);async function $Q(e,t){const{placement:r,platform:s,elements:a}=e,i=await(s.isRTL==null?void 0:s.isRTL(a.floating)),o=co(r),l=qf(r),c=ii(r)==="y",d=l3.has(o)?-1:1,u=i&&c?-1:1,f=lo(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:y}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof y=="number"&&(m=l==="end"?y*-1:y),c?{x:m*u,y:h*d}:{x:h*d,y:m*u}}const IQ=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,s;const{x:a,y:i,placement:o,middlewareData:l}=t,c=await $Q(t,e);return o===((r=l.offset)==null?void 0:r.placement)&&(s=l.arrow)!=null&&s.alignmentOffset?{}:{x:a+c.x,y:i+c.y,data:{...c,placement:o}}}}},DQ=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:s,placement:a,platform:i}=t,{mainAxis:o=!0,crossAxis:l=!1,limiter:c={fn:v=>{let{x:g,y:b}=v;return{x:g,y:b}}},...d}=lo(e,t),u={x:r,y:s},f=await i.detectOverflow(t,d),h=ii(co(a)),m=jk(h);let y=u[m],x=u[h];if(o){const v=m==="y"?"top":"left",g=m==="y"?"bottom":"right",b=y+f[v],N=y-f[g];y=R1(b,y,N)}if(l){const v=h==="y"?"top":"left",g=h==="y"?"bottom":"right",b=x+f[v],N=x-f[g];x=R1(b,x,N)}const j=c.fn({...t,[m]:y,[h]:x});return{...j,data:{x:j.x-r,y:j.y-s,enabled:{[m]:o,[h]:l}}}}}},LQ=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:s,placement:a,rects:i,middlewareData:o}=t,{offset:l=0,mainAxis:c=!0,crossAxis:d=!0}=lo(e,t),u={x:r,y:s},f=ii(a),h=jk(f);let m=u[h],y=u[f];const x=lo(l,t),j=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(c){const b=h==="y"?"height":"width",N=i.reference[h]-i.floating[b]+j.mainAxis,w=i.reference[h]+i.reference[b]-j.mainAxis;mw&&(m=w)}if(d){var v,g;const b=h==="y"?"width":"height",N=l3.has(co(a)),w=i.reference[f]-i.floating[b]+(N&&((v=o.offset)==null?void 0:v[f])||0)+(N?0:j.crossAxis),S=i.reference[f]+i.reference[b]+(N?0:((g=o.offset)==null?void 0:g[f])||0)-(N?j.crossAxis:0);yS&&(y=S)}return{[h]:m,[f]:y}}}},FQ=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,s;const{placement:a,rects:i,platform:o,elements:l}=t,{apply:c=()=>{},...d}=lo(e,t),u=await o.detectOverflow(t,d),f=co(a),h=qf(a),m=ii(a)==="y",{width:y,height:x}=i.floating;let j,v;f==="top"||f==="bottom"?(j=f,v=h===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(v=f,j=h==="end"?"top":"bottom");const g=x-u.top-u.bottom,b=y-u.left-u.right,N=Al(x-u[j],g),w=Al(y-u[v],b),S=!t.middlewareData.shift;let _=N,C=w;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(C=b),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(_=g),S&&!h){const D=Es(u.left,0),z=Es(u.right,0),O=Es(u.top,0),V=Es(u.bottom,0);m?C=y-2*(D!==0||z!==0?D+z:Es(u.left,u.right)):_=x-2*(O!==0||V!==0?O+V:Es(u.top,u.bottom))}await c({...t,availableWidth:C,availableHeight:_});const P=await o.getDimensions(l.floating);return y!==P.width||x!==P.height?{reset:{rects:!0}}:{}}}};function Oj(){return typeof window<"u"}function Wf(e){return c3(e)?(e.nodeName||"").toLowerCase():"#document"}function Is(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ci(e){var t;return(t=(c3(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function c3(e){return Oj()?e instanceof Node||e instanceof Is(e).Node:!1}function Ba(e){return Oj()?e instanceof Element||e instanceof Is(e).Element:!1}function jo(e){return Oj()?e instanceof HTMLElement||e instanceof Is(e).HTMLElement:!1}function FE(e){return!Oj()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Is(e).ShadowRoot}function Xp(e){const{overflow:t,overflowX:r,overflowY:s,display:a}=za(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+r)&&a!=="inline"&&a!=="contents"}function BQ(e){return/^(table|td|th)$/.test(Wf(e))}function Tj(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const zQ=/transform|translate|scale|rotate|perspective|filter/,VQ=/paint|layout|strict|content/,sc=e=>!!e&&e!=="none";let uw;function Nk(e){const t=Ba(e)?za(e):e;return sc(t.transform)||sc(t.translate)||sc(t.scale)||sc(t.rotate)||sc(t.perspective)||!Sk()&&(sc(t.backdropFilter)||sc(t.filter))||zQ.test(t.willChange||"")||VQ.test(t.contain||"")}function qQ(e){let t=El(e);for(;jo(t)&&!Gu(t);){if(Nk(t))return t;if(Tj(t))return null;t=El(t)}return null}function Sk(){return uw==null&&(uw=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),uw}function Gu(e){return/^(html|body|#document)$/.test(Wf(e))}function za(e){return Is(e).getComputedStyle(e)}function Mj(e){return Ba(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function El(e){if(Wf(e)==="html")return e;const t=e.assignedSlot||e.parentNode||FE(e)&&e.host||Ci(e);return FE(t)?t.host:t}function d3(e){const t=El(e);return Gu(t)?e.ownerDocument?e.ownerDocument.body:e.body:jo(t)&&Xp(t)?t:d3(t)}function zh(e,t,r){var s;t===void 0&&(t=[]),r===void 0&&(r=!0);const a=d3(e),i=a===((s=e.ownerDocument)==null?void 0:s.body),o=Is(a);if(i){const l=I1(o);return t.concat(o,o.visualViewport||[],Xp(a)?a:[],l&&r?zh(l):[])}else return t.concat(a,zh(a,[],r))}function I1(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function u3(e){const t=za(e);let r=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const a=jo(e),i=a?e.offsetWidth:r,o=a?e.offsetHeight:s,l=Sv(r)!==i||Sv(s)!==o;return l&&(r=i,s=o),{width:r,height:s,$:l}}function _k(e){return Ba(e)?e:e.contextElement}function ju(e){const t=_k(e);if(!jo(t))return mi(1);const r=t.getBoundingClientRect(),{width:s,height:a,$:i}=u3(t);let o=(i?Sv(r.width):r.width)/s,l=(i?Sv(r.height):r.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const WQ=mi(0);function f3(e){const t=Is(e);return!Sk()||!t.visualViewport?WQ:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function UQ(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Is(e)?!1:t}function Kc(e,t,r,s){t===void 0&&(t=!1),r===void 0&&(r=!1);const a=e.getBoundingClientRect(),i=_k(e);let o=mi(1);t&&(s?Ba(s)&&(o=ju(s)):o=ju(e));const l=UQ(i,r,s)?f3(i):mi(0);let c=(a.left+l.x)/o.x,d=(a.top+l.y)/o.y,u=a.width/o.x,f=a.height/o.y;if(i){const h=Is(i),m=s&&Ba(s)?Is(s):s;let y=h,x=I1(y);for(;x&&s&&m!==y;){const j=ju(x),v=x.getBoundingClientRect(),g=za(x),b=v.left+(x.clientLeft+parseFloat(g.paddingLeft))*j.x,N=v.top+(x.clientTop+parseFloat(g.paddingTop))*j.y;c*=j.x,d*=j.y,u*=j.x,f*=j.y,c+=b,d+=N,y=Is(x),x=I1(y)}}return Cv({width:u,height:f,x:c,y:d})}function Rj(e,t){const r=Mj(e).scrollLeft;return t?t.left+r:Kc(Ci(e)).left+r}function m3(e,t){const r=e.getBoundingClientRect(),s=r.left+t.scrollLeft-Rj(e,r),a=r.top+t.scrollTop;return{x:s,y:a}}function KQ(e){let{elements:t,rect:r,offsetParent:s,strategy:a}=e;const i=a==="fixed",o=Ci(s),l=t?Tj(t.floating):!1;if(s===o||l&&i)return r;let c={scrollLeft:0,scrollTop:0},d=mi(1);const u=mi(0),f=jo(s);if((f||!f&&!i)&&((Wf(s)!=="body"||Xp(o))&&(c=Mj(s)),f)){const m=Kc(s);d=ju(s),u.x=m.x+s.clientLeft,u.y=m.y+s.clientTop}const h=o&&!f&&!i?m3(o,c):mi(0);return{width:r.width*d.x,height:r.height*d.y,x:r.x*d.x-c.scrollLeft*d.x+u.x+h.x,y:r.y*d.y-c.scrollTop*d.y+u.y+h.y}}function GQ(e){return Array.from(e.getClientRects())}function HQ(e){const t=Ci(e),r=Mj(e),s=e.ownerDocument.body,a=Es(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),i=Es(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let o=-r.scrollLeft+Rj(e);const l=-r.scrollTop;return za(s).direction==="rtl"&&(o+=Es(t.clientWidth,s.clientWidth)-a),{width:a,height:i,x:o,y:l}}const BE=25;function QQ(e,t){const r=Is(e),s=Ci(e),a=r.visualViewport;let i=s.clientWidth,o=s.clientHeight,l=0,c=0;if(a){i=a.width,o=a.height;const u=Sk();(!u||u&&t==="fixed")&&(l=a.offsetLeft,c=a.offsetTop)}const d=Rj(s);if(d<=0){const u=s.ownerDocument,f=u.body,h=getComputedStyle(f),m=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,y=Math.abs(s.clientWidth-f.clientWidth-m);y<=BE&&(i-=y)}else d<=BE&&(i+=d);return{width:i,height:o,x:l,y:c}}function YQ(e,t){const r=Kc(e,!0,t==="fixed"),s=r.top+e.clientTop,a=r.left+e.clientLeft,i=jo(e)?ju(e):mi(1),o=e.clientWidth*i.x,l=e.clientHeight*i.y,c=a*i.x,d=s*i.y;return{width:o,height:l,x:c,y:d}}function zE(e,t,r){let s;if(t==="viewport")s=QQ(e,r);else if(t==="document")s=HQ(Ci(e));else if(Ba(t))s=YQ(t,r);else{const a=f3(e);s={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return Cv(s)}function h3(e,t){const r=El(e);return r===t||!Ba(r)||Gu(r)?!1:za(r).position==="fixed"||h3(r,t)}function XQ(e,t){const r=t.get(e);if(r)return r;let s=zh(e,[],!1).filter(l=>Ba(l)&&Wf(l)!=="body"),a=null;const i=za(e).position==="fixed";let o=i?El(e):e;for(;Ba(o)&&!Gu(o);){const l=za(o),c=Nk(o);!c&&l.position==="fixed"&&(a=null),(i?!c&&!a:!c&&l.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||Xp(o)&&!c&&h3(e,o))?s=s.filter(u=>u!==o):a=l,o=El(o)}return t.set(e,s),s}function ZQ(e){let{element:t,boundary:r,rootBoundary:s,strategy:a}=e;const o=[...r==="clippingAncestors"?Tj(t)?[]:XQ(t,this._c):[].concat(r),s],l=zE(t,o[0],a);let c=l.top,d=l.right,u=l.bottom,f=l.left;for(let h=1;h{o(!1,1e-7)},1e3)}_===1&&!x3(d,e.getBoundingClientRect())&&o(),N=!1}try{r=new IntersectionObserver(w,{...b,root:a.ownerDocument})}catch{r=new IntersectionObserver(w,b)}r.observe(e)}return o(!0),i}function aY(e,t,r,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=s,d=_k(e),u=a||i?[...d?zh(d):[],...t?zh(t):[]]:[];u.forEach(v=>{a&&v.addEventListener("scroll",r,{passive:!0}),i&&v.addEventListener("resize",r)});const f=d&&l?sY(d,r):null;let h=-1,m=null;o&&(m=new ResizeObserver(v=>{let[g]=v;g&&g.target===d&&m&&t&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var b;(b=m)==null||b.observe(t)})),r()}),d&&!c&&m.observe(d),t&&m.observe(t));let y,x=c?Kc(e):null;c&&j();function j(){const v=Kc(e);x&&!x3(x,v)&&r(),x=v,y=requestAnimationFrame(j)}return r(),()=>{var v;u.forEach(g=>{a&&g.removeEventListener("scroll",r),i&&g.removeEventListener("resize",r)}),f==null||f(),(v=m)==null||v.disconnect(),m=null,c&&cancelAnimationFrame(y)}}const iY=IQ,oY=DQ,lY=MQ,cY=FQ,dY=RQ,qE=TQ,uY=LQ,fY=(e,t,r)=>{const s=new Map,a={platform:rY,...r},i={...a.platform,_c:s};return OQ(e,t,{...a,platform:i})};var mY=typeof document<"u",hY=function(){},Ug=mY?p.useLayoutEffect:hY;function kv(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,s,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(s=r;s--!==0;)if(!kv(e[s],t[s]))return!1;return!0}if(a=Object.keys(e),r=a.length,r!==Object.keys(t).length)return!1;for(s=r;s--!==0;)if(!{}.hasOwnProperty.call(t,a[s]))return!1;for(s=r;s--!==0;){const i=a[s];if(!(i==="_owner"&&e.$$typeof)&&!kv(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function g3(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function WE(e,t){const r=g3(e);return Math.round(t*r)/r}function mw(e){const t=p.useRef(e);return Ug(()=>{t.current=e}),t}function pY(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:s=[],platform:a,elements:{reference:i,floating:o}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[u,f]=p.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=p.useState(s);kv(h,s)||m(s);const[y,x]=p.useState(null),[j,v]=p.useState(null),g=p.useCallback(k=>{k!==S.current&&(S.current=k,x(k))},[]),b=p.useCallback(k=>{k!==_.current&&(_.current=k,v(k))},[]),N=i||y,w=o||j,S=p.useRef(null),_=p.useRef(null),C=p.useRef(u),P=c!=null,D=mw(c),z=mw(a),O=mw(d),V=p.useCallback(()=>{if(!S.current||!_.current)return;const k={placement:t,strategy:r,middleware:h};z.current&&(k.platform=z.current),fY(S.current,_.current,k).then(M=>{const K={...M,isPositioned:O.current!==!1};A.current&&!kv(C.current,K)&&(C.current=K,md.flushSync(()=>{f(K)}))})},[h,t,r,z,O]);Ug(()=>{d===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,f(k=>({...k,isPositioned:!1})))},[d]);const A=p.useRef(!1);Ug(()=>(A.current=!0,()=>{A.current=!1}),[]),Ug(()=>{if(N&&(S.current=N),w&&(_.current=w),N&&w){if(D.current)return D.current(N,w,V);V()}},[N,w,V,D,P]);const $=p.useMemo(()=>({reference:S,floating:_,setReference:g,setFloating:b}),[g,b]),B=p.useMemo(()=>({reference:N,floating:w}),[N,w]),I=p.useMemo(()=>{const k={position:r,left:0,top:0};if(!B.floating)return k;const M=WE(B.floating,u.x),K=WE(B.floating,u.y);return l?{...k,transform:"translate("+M+"px, "+K+"px)",...g3(B.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:M,top:K}},[r,l,B.floating,u.x,u.y]);return p.useMemo(()=>({...u,update:V,refs:$,elements:B,floatingStyles:I}),[u,V,$,B,I])}const xY=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:s,padding:a}=typeof e=="function"?e(r):e;return s&&t(s)?s.current!=null?qE({element:s.current,padding:a}).fn(r):{}:s?qE({element:s,padding:a}).fn(r):{}}}},gY=(e,t)=>{const r=iY(e);return{name:r.name,fn:r.fn,options:[e,t]}},vY=(e,t)=>{const r=oY(e);return{name:r.name,fn:r.fn,options:[e,t]}},yY=(e,t)=>({fn:uY(e).fn,options:[e,t]}),jY=(e,t)=>{const r=lY(e);return{name:r.name,fn:r.fn,options:[e,t]}},bY=(e,t)=>{const r=cY(e);return{name:r.name,fn:r.fn,options:[e,t]}},wY=(e,t)=>{const r=dY(e);return{name:r.name,fn:r.fn,options:[e,t]}},NY=(e,t)=>{const r=xY(e);return{name:r.name,fn:r.fn,options:[e,t]}};var SY="Arrow",v3=p.forwardRef((e,t)=>{const{children:r,width:s=10,height:a=5,...i}=e;return n.jsx(We.svg,{...i,ref:t,width:s,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:n.jsx("polygon",{points:"0,0 30,0 15,10"})})});v3.displayName=SY;var _Y=v3;function Zp(e){const[t,r]=p.useState(void 0);return Ln(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const i=a[0];let o,l;if("borderBoxSize"in i){const c=i.borderBoxSize,d=Array.isArray(c)?c[0]:c;o=d.inlineSize,l=d.blockSize}else o=e.offsetWidth,l=e.offsetHeight;r({width:o,height:l})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else r(void 0)},[e]),t}var Ck="Popper",[y3,Fl]=lr(Ck),[CY,j3]=y3(Ck),b3=e=>{const{__scopePopper:t,children:r}=e,[s,a]=p.useState(null);return n.jsx(CY,{scope:t,anchor:s,onAnchorChange:a,children:r})};b3.displayName=Ck;var w3="PopperAnchor",N3=p.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:s,...a}=e,i=j3(w3,r),o=p.useRef(null),l=dt(t,o),c=p.useRef(null);return p.useEffect(()=>{const d=c.current;c.current=(s==null?void 0:s.current)||o.current,d!==c.current&&i.onAnchorChange(c.current)}),s?null:n.jsx(We.div,{...a,ref:l})});N3.displayName=w3;var kk="PopperContent",[kY,PY]=y3(kk),S3=p.forwardRef((e,t)=>{var ne,_e,ue,we,ve,le;const{__scopePopper:r,side:s="bottom",sideOffset:a=0,align:i="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:u=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:m="optimized",onPlaced:y,...x}=e,j=j3(kk,r),[v,g]=p.useState(null),b=dt(t,ut=>g(ut)),[N,w]=p.useState(null),S=Zp(N),_=(S==null?void 0:S.width)??0,C=(S==null?void 0:S.height)??0,P=s+(i!=="center"?"-"+i:""),D=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},z=Array.isArray(d)?d:[d],O=z.length>0,V={padding:D,boundary:z.filter(EY),altBoundary:O},{refs:A,floatingStyles:$,placement:B,isPositioned:I,middlewareData:k}=pY({strategy:"fixed",placement:P,whileElementsMounted:(...ut)=>aY(...ut,{animationFrame:m==="always"}),elements:{reference:j.anchor},middleware:[gY({mainAxis:a+C,alignmentAxis:o}),c&&vY({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?yY():void 0,...V}),c&&jY({...V}),bY({...V,apply:({elements:ut,rects:Se,availableWidth:Ve,availableHeight:pt})=>{const{width:Pt,height:Qt}=Se.reference,kt=ut.floating.style;kt.setProperty("--radix-popper-available-width",`${Ve}px`),kt.setProperty("--radix-popper-available-height",`${pt}px`),kt.setProperty("--radix-popper-anchor-width",`${Pt}px`),kt.setProperty("--radix-popper-anchor-height",`${Qt}px`)}}),N&&NY({element:N,padding:l}),OY({arrowWidth:_,arrowHeight:C}),h&&wY({strategy:"referenceHidden",...V})]}),[M,K]=k3(B),X=Dn(y);Ln(()=>{I&&(X==null||X())},[I,X]);const re=(ne=k.arrow)==null?void 0:ne.x,Z=(_e=k.arrow)==null?void 0:_e.y,te=((ue=k.arrow)==null?void 0:ue.centerOffset)!==0,[xe,me]=p.useState();return Ln(()=>{v&&me(window.getComputedStyle(v).zIndex)},[v]),n.jsx("div",{ref:A.setFloating,"data-radix-popper-content-wrapper":"",style:{...$,transform:I?$.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:xe,"--radix-popper-transform-origin":[(we=k.transformOrigin)==null?void 0:we.x,(ve=k.transformOrigin)==null?void 0:ve.y].join(" "),...((le=k.hide)==null?void 0:le.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:n.jsx(kY,{scope:r,placedSide:M,onArrowChange:w,arrowX:re,arrowY:Z,shouldHideArrow:te,children:n.jsx(We.div,{"data-side":M,"data-align":K,...x,ref:b,style:{...x.style,animation:I?void 0:"none"}})})})});S3.displayName=kk;var _3="PopperArrow",AY={top:"bottom",right:"left",bottom:"top",left:"right"},C3=p.forwardRef(function(t,r){const{__scopePopper:s,...a}=t,i=PY(_3,s),o=AY[i.placedSide];return n.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:n.jsx(_Y,{...a,ref:r,style:{...a.style,display:"block"}})})});C3.displayName=_3;function EY(e){return e!==null}var OY=e=>({name:"transformOrigin",options:e,fn(t){var j,v,g;const{placement:r,rects:s,middlewareData:a}=t,o=((j=a.arrow)==null?void 0:j.centerOffset)!==0,l=o?0:e.arrowWidth,c=o?0:e.arrowHeight,[d,u]=k3(r),f={start:"0%",center:"50%",end:"100%"}[u],h=(((v=a.arrow)==null?void 0:v.x)??0)+l/2,m=(((g=a.arrow)==null?void 0:g.y)??0)+c/2;let y="",x="";return d==="bottom"?(y=o?f:`${h}px`,x=`${-c}px`):d==="top"?(y=o?f:`${h}px`,x=`${s.floating.height+c}px`):d==="right"?(y=`${-c}px`,x=o?f:`${m}px`):d==="left"&&(y=`${s.floating.width+c}px`,x=o?f:`${m}px`),{data:{x:y,y:x}}}});function k3(e){const[t,r="center"]=e.split("-");return[t,r]}var $j=b3,Jp=N3,Ij=S3,Dj=C3,TY=Symbol("radix.slottable");function MY(e){const t=({children:r})=>n.jsx(n.Fragment,{children:r});return t.displayName=`${e}.Slottable`,t.__radixId=TY,t}var[Lj]=lr("Tooltip",[Fl]),Fj=Fl(),P3="TooltipProvider",RY=700,D1="tooltip.open",[$Y,Pk]=Lj(P3),A3=e=>{const{__scopeTooltip:t,delayDuration:r=RY,skipDelayDuration:s=300,disableHoverableContent:a=!1,children:i}=e,o=p.useRef(!0),l=p.useRef(!1),c=p.useRef(0);return p.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),n.jsx($Y,{scope:t,isOpenDelayedRef:o,delayDuration:r,onOpen:p.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,s)},[s]),isPointerInTransitRef:l,onPointerInTransitChange:p.useCallback(d=>{l.current=d},[]),disableHoverableContent:a,children:i})};A3.displayName=P3;var Vh="Tooltip",[IY,Bj]=Lj(Vh),E3=e=>{const{__scopeTooltip:t,children:r,open:s,defaultOpen:a,onOpenChange:i,disableHoverableContent:o,delayDuration:l}=e,c=Pk(Vh,e.__scopeTooltip),d=Fj(t),[u,f]=p.useState(null),h=ys(),m=p.useRef(0),y=o??c.disableHoverableContent,x=l??c.delayDuration,j=p.useRef(!1),[v,g]=zr({prop:s,defaultProp:a??!1,onChange:_=>{_?(c.onOpen(),document.dispatchEvent(new CustomEvent(D1))):c.onClose(),i==null||i(_)},caller:Vh}),b=p.useMemo(()=>v?j.current?"delayed-open":"instant-open":"closed",[v]),N=p.useCallback(()=>{window.clearTimeout(m.current),m.current=0,j.current=!1,g(!0)},[g]),w=p.useCallback(()=>{window.clearTimeout(m.current),m.current=0,g(!1)},[g]),S=p.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{j.current=!0,g(!0),m.current=0},x)},[x,g]);return p.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),n.jsx($j,{...d,children:n.jsx(IY,{scope:t,contentId:h,open:v,stateAttribute:b,trigger:u,onTriggerChange:f,onTriggerEnter:p.useCallback(()=>{c.isOpenDelayedRef.current?S():N()},[c.isOpenDelayedRef,S,N]),onTriggerLeave:p.useCallback(()=>{y?w():(window.clearTimeout(m.current),m.current=0)},[w,y]),onOpen:N,onClose:w,disableHoverableContent:y,children:r})})};E3.displayName=Vh;var L1="TooltipTrigger",O3=p.forwardRef((e,t)=>{const{__scopeTooltip:r,...s}=e,a=Bj(L1,r),i=Pk(L1,r),o=Fj(r),l=p.useRef(null),c=dt(t,l,a.onTriggerChange),d=p.useRef(!1),u=p.useRef(!1),f=p.useCallback(()=>d.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),n.jsx(Jp,{asChild:!0,...o,children:n.jsx(We.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...s,ref:c,onPointerMove:be(e.onPointerMove,h=>{h.pointerType!=="touch"&&!u.current&&!i.isPointerInTransitRef.current&&(a.onTriggerEnter(),u.current=!0)}),onPointerLeave:be(e.onPointerLeave,()=>{a.onTriggerLeave(),u.current=!1}),onPointerDown:be(e.onPointerDown,()=>{a.open&&a.onClose(),d.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:be(e.onFocus,()=>{d.current||a.onOpen()}),onBlur:be(e.onBlur,a.onClose),onClick:be(e.onClick,a.onClose)})})});O3.displayName=L1;var DY="TooltipPortal",[q5e,LY]=Lj(DY,{forceMount:void 0}),Hu="TooltipContent",T3=p.forwardRef((e,t)=>{const r=LY(Hu,e.__scopeTooltip),{forceMount:s=r.forceMount,side:a="top",...i}=e,o=Bj(Hu,e.__scopeTooltip);return n.jsx(Jn,{present:s||o.open,children:o.disableHoverableContent?n.jsx(M3,{side:a,...i,ref:t}):n.jsx(FY,{side:a,...i,ref:t})})}),FY=p.forwardRef((e,t)=>{const r=Bj(Hu,e.__scopeTooltip),s=Pk(Hu,e.__scopeTooltip),a=p.useRef(null),i=dt(t,a),[o,l]=p.useState(null),{trigger:c,onClose:d}=r,u=a.current,{onPointerInTransitChange:f}=s,h=p.useCallback(()=>{l(null),f(!1)},[f]),m=p.useCallback((y,x)=>{const j=y.currentTarget,v={x:y.clientX,y:y.clientY},g=WY(v,j.getBoundingClientRect()),b=UY(v,g),N=KY(x.getBoundingClientRect()),w=HY([...b,...N]);l(w),f(!0)},[f]);return p.useEffect(()=>()=>h(),[h]),p.useEffect(()=>{if(c&&u){const y=j=>m(j,u),x=j=>m(j,c);return c.addEventListener("pointerleave",y),u.addEventListener("pointerleave",x),()=>{c.removeEventListener("pointerleave",y),u.removeEventListener("pointerleave",x)}}},[c,u,m,h]),p.useEffect(()=>{if(o){const y=x=>{const j=x.target,v={x:x.clientX,y:x.clientY},g=(c==null?void 0:c.contains(j))||(u==null?void 0:u.contains(j)),b=!GY(v,o);g?h():b&&(h(),d())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[c,u,o,d,h]),n.jsx(M3,{...e,ref:i})}),[BY,zY]=Lj(Vh,{isInside:!1}),VY=MY("TooltipContent"),M3=p.forwardRef((e,t)=>{const{__scopeTooltip:r,children:s,"aria-label":a,onEscapeKeyDown:i,onPointerDownOutside:o,...l}=e,c=Bj(Hu,r),d=Fj(r),{onClose:u}=c;return p.useEffect(()=>(document.addEventListener(D1,u),()=>document.removeEventListener(D1,u)),[u]),p.useEffect(()=>{if(c.trigger){const f=h=>{const m=h.target;m!=null&&m.contains(c.trigger)&&u()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,u]),n.jsx(hd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:f=>f.preventDefault(),onDismiss:u,children:n.jsxs(Ij,{"data-state":c.stateAttribute,...d,...l,ref:t,style:{...l.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:[n.jsx(VY,{children:s}),n.jsx(BY,{scope:r,isInside:!0,children:n.jsx(tG,{id:c.contentId,role:"tooltip",children:a||s})})]})})});T3.displayName=Hu;var R3="TooltipArrow",qY=p.forwardRef((e,t)=>{const{__scopeTooltip:r,...s}=e,a=Fj(r);return zY(R3,r).isInside?null:n.jsx(Dj,{...a,...s,ref:t})});qY.displayName=R3;function WY(e,t){const r=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(r,s,a,i)){case i:return"left";case a:return"right";case r:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function UY(e,t,r=5){const s=[];switch(t){case"top":s.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":s.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":s.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":s.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return s}function KY(e){const{top:t,right:r,bottom:s,left:a}=e;return[{x:a,y:t},{x:r,y:t},{x:r,y:s},{x:a,y:s}]}function GY(e,t){const{x:r,y:s}=e;let a=!1;for(let i=0,o=t.length-1;is!=h>s&&r<(f-d)*(s-u)/(h-u)+d&&(a=!a)}return a}function HY(e){const t=e.slice();return t.sort((r,s)=>r.xs.x?1:r.ys.y?1:0),QY(t)}function QY(e){if(e.length<=1)return e.slice();const t=[];for(let s=0;s=2;){const i=t[t.length-1],o=t[t.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))t.pop();else break}t.push(a)}t.pop();const r=[];for(let s=e.length-1;s>=0;s--){const a=e[s];for(;r.length>=2;){const i=r[r.length-1],o=r[r.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))r.pop();else break}r.push(a)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}var YY=A3,XY=E3,ZY=O3,$3=T3;const I3=YY,uo=XY,fo=ZY,vi=p.forwardRef(({className:e,sideOffset:t=4,...r},s)=>n.jsx($3,{ref:s,sideOffset:t,className:he("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md 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",e),...r}));vi.displayName=$3.displayName;var Uf=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},kc,Yo,Cu,F$,JY=(F$=class extends Uf{constructor(){super();it(this,kc);it(this,Yo);it(this,Cu);ze(this,Cu,t=>{if(typeof window<"u"&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){Q(this,Yo)||this.setEventListener(Q(this,Cu))}onUnsubscribe(){var t;this.hasListeners()||((t=Q(this,Yo))==null||t.call(this),ze(this,Yo,void 0))}setEventListener(t){var r;ze(this,Cu,t),(r=Q(this,Yo))==null||r.call(this),ze(this,Yo,t(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(t){Q(this,kc)!==t&&(ze(this,kc,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof Q(this,kc)=="boolean"?Q(this,kc):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},kc=new WeakMap,Yo=new WeakMap,Cu=new WeakMap,F$),Ak=new JY,eX={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Xo,oC,B$,tX=(B$=class{constructor(){it(this,Xo,eX);it(this,oC,!1)}setTimeoutProvider(e){ze(this,Xo,e)}setTimeout(e,t){return Q(this,Xo).setTimeout(e,t)}clearTimeout(e){Q(this,Xo).clearTimeout(e)}setInterval(e,t){return Q(this,Xo).setInterval(e,t)}clearInterval(e){Q(this,Xo).clearInterval(e)}},Xo=new WeakMap,oC=new WeakMap,B$),bc=new tX;function nX(e){setTimeout(e,0)}var rX=typeof window>"u"||"Deno"in globalThis;function Ur(){}function sX(e,t){return typeof e=="function"?e(t):e}function F1(e){return typeof e=="number"&&e>=0&&e!==1/0}function D3(e,t){return Math.max(e+(t||0)-Date.now(),0)}function vl(e,t){return typeof e=="function"?e(t):e}function Ys(e,t){return typeof e=="function"?e(t):e}function UE(e,t){const{type:r="all",exact:s,fetchStatus:a,predicate:i,queryKey:o,stale:l}=e;if(o){if(s){if(t.queryHash!==Ek(o,t.options))return!1}else if(!qh(t.queryKey,o))return!1}if(r!=="all"){const c=t.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||a&&a!==t.state.fetchStatus||i&&!i(t))}function KE(e,t){const{exact:r,status:s,predicate:a,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(r){if(Gc(t.options.mutationKey)!==Gc(i))return!1}else if(!qh(t.options.mutationKey,i))return!1}return!(s&&t.state.status!==s||a&&!a(t))}function Ek(e,t){return((t==null?void 0:t.queryKeyHashFn)||Gc)(e)}function Gc(e){return JSON.stringify(e,(t,r)=>B1(r)?Object.keys(r).sort().reduce((s,a)=>(s[a]=r[a],s),{}):r)}function qh(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>qh(e[r],t[r])):!1}var aX=Object.prototype.hasOwnProperty;function L3(e,t,r=0){if(e===t)return e;if(r>500)return t;const s=GE(e)&&GE(t);if(!s&&!(B1(e)&&B1(t)))return t;const i=(s?e:Object.keys(e)).length,o=s?t:Object.keys(t),l=o.length,c=s?new Array(l):{};let d=0;for(let u=0;u{bc.setTimeout(t,e)})}function z1(e,t,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,t):r.structuralSharing!==!1?L3(e,t):t}function oX(e,t,r=0){const s=[...e,t];return r&&s.length>r?s.slice(1):s}function lX(e,t,r=0){const s=[t,...e];return r&&s.length>r?s.slice(0,-1):s}var Ok=Symbol();function F3(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Ok?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Tk(e,t){return typeof e=="function"?e(...t):!!e}function cX(e,t,r){let s=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),s||(s=!0,a.aborted?r():a.addEventListener("abort",r,{once:!0})),a)}),e}var Wh=(()=>{let e=()=>rX;return{isServer(){return e()},setIsServer(t){e=t}}})();function V1(){let e,t;const r=new Promise((a,i)=>{e=a,t=i});r.status="pending",r.catch(()=>{});function s(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{s({status:"fulfilled",value:a}),e(a)},r.reject=a=>{s({status:"rejected",reason:a}),t(a)},r}var dX=nX;function uX(){let e=[],t=0,r=l=>{l()},s=l=>{l()},a=dX;const i=l=>{t?e.push(l):a(()=>{r(l)})},o=()=>{const l=e;e=[],l.length&&a(()=>{s(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||o()}return c},batchCalls:l=>(...c)=>{i(()=>{l(...c)})},schedule:i,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{s=l},setScheduler:l=>{a=l}}}var ar=uX(),ku,Zo,Pu,z$,fX=(z$=class extends Uf{constructor(){super();it(this,ku,!0);it(this,Zo);it(this,Pu);ze(this,Pu,t=>{if(typeof window<"u"&&window.addEventListener){const r=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",s)}}})}onSubscribe(){Q(this,Zo)||this.setEventListener(Q(this,Pu))}onUnsubscribe(){var t;this.hasListeners()||((t=Q(this,Zo))==null||t.call(this),ze(this,Zo,void 0))}setEventListener(t){var r;ze(this,Pu,t),(r=Q(this,Zo))==null||r.call(this),ze(this,Zo,t(this.setOnline.bind(this)))}setOnline(t){Q(this,ku)!==t&&(ze(this,ku,t),this.listeners.forEach(s=>{s(t)}))}isOnline(){return Q(this,ku)}},ku=new WeakMap,Zo=new WeakMap,Pu=new WeakMap,z$),Av=new fX;function mX(e){return Math.min(1e3*2**e,3e4)}function B3(e){return(e??"online")==="online"?Av.isOnline():!0}var q1=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function z3(e){let t=!1,r=0,s;const a=V1(),i=()=>a.status!=="pending",o=x=>{var j;if(!i()){const v=new q1(x);h(v),(j=e.onCancel)==null||j.call(e,v)}},l=()=>{t=!0},c=()=>{t=!1},d=()=>Ak.isFocused()&&(e.networkMode==="always"||Av.isOnline())&&e.canRun(),u=()=>B3(e.networkMode)&&e.canRun(),f=x=>{i()||(s==null||s(),a.resolve(x))},h=x=>{i()||(s==null||s(),a.reject(x))},m=()=>new Promise(x=>{var j;s=v=>{(i()||d())&&x(v)},(j=e.onPause)==null||j.call(e)}).then(()=>{var x;s=void 0,i()||(x=e.onContinue)==null||x.call(e)}),y=()=>{if(i())return;let x;const j=r===0?e.initialPromise:void 0;try{x=j??e.fn()}catch(v){x=Promise.reject(v)}Promise.resolve(x).then(f).catch(v=>{var S;if(i())return;const g=e.retry??(Wh.isServer()?0:3),b=e.retryDelay??mX,N=typeof b=="function"?b(r,v):b,w=g===!0||typeof g=="number"&&rd()?void 0:m()).then(()=>{t?h(v):y()})})};return{promise:a,status:()=>a.status,cancel:o,continue:()=>(s==null||s(),a),cancelRetry:l,continueRetry:c,canStart:u,start:()=>(u()?y():m().then(y),a)}}var Pc,V$,V3=(V$=class{constructor(){it(this,Pc)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),F1(this.gcTime)&&ze(this,Pc,bc.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Wh.isServer()?1/0:5*60*1e3))}clearGcTimeout(){Q(this,Pc)!==void 0&&(bc.clearTimeout(Q(this,Pc)),ze(this,Pc,void 0))}},Pc=new WeakMap,V$),Ac,Au,Qs,Ec,ur,Fp,Oc,Ps,q3,Di,q$,hX=(q$=class extends V3{constructor(t){super();it(this,Ps);it(this,Ac);it(this,Au);it(this,Qs);it(this,Ec);it(this,ur);it(this,Fp);it(this,Oc);ze(this,Oc,!1),ze(this,Fp,t.defaultOptions),this.setOptions(t.options),this.observers=[],ze(this,Ec,t.client),ze(this,Qs,Q(this,Ec).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,ze(this,Ac,YE(this.options)),this.state=t.state??Q(this,Ac),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=Q(this,ur))==null?void 0:t.promise}setOptions(t){if(this.options={...Q(this,Fp),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=YE(this.options);r.data!==void 0&&(this.setState(QE(r.data,r.dataUpdatedAt)),ze(this,Ac,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&Q(this,Qs).remove(this)}setData(t,r){const s=z1(this.state.data,t,this.options);return Nt(this,Ps,Di).call(this,{data:s,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),s}setState(t,r){Nt(this,Ps,Di).call(this,{type:"setState",state:t,setStateOptions:r})}cancel(t){var s,a;const r=(s=Q(this,ur))==null?void 0:s.promise;return(a=Q(this,ur))==null||a.cancel(t),r?r.then(Ur).catch(Ur):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return Q(this,Ac)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>Ys(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ok||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>vl(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!D3(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=this.observers.find(s=>s.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=Q(this,ur))==null||r.continue()}onOnline(){var r;const t=this.observers.find(s=>s.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=Q(this,ur))==null||r.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),Q(this,Qs).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(Q(this,ur)&&(Q(this,Oc)||Nt(this,Ps,q3).call(this)?Q(this,ur).cancel({revert:!0}):Q(this,ur).cancelRetry()),this.scheduleGc()),Q(this,Qs).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Nt(this,Ps,Di).call(this,{type:"invalidate"})}async fetch(t,r){var c,d,u,f,h,m,y,x,j,v,g,b;if(this.state.fetchStatus!=="idle"&&((c=Q(this,ur))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(Q(this,ur))return Q(this,ur).continueRetry(),Q(this,ur).promise}if(t&&this.setOptions(t),!this.options.queryFn){const N=this.observers.find(w=>w.options.queryFn);N&&this.setOptions(N.options)}const s=new AbortController,a=N=>{Object.defineProperty(N,"signal",{enumerable:!0,get:()=>(ze(this,Oc,!0),s.signal)})},i=()=>{const N=F3(this.options,r),S=(()=>{const _={client:Q(this,Ec),queryKey:this.queryKey,meta:this.meta};return a(_),_})();return ze(this,Oc,!1),this.options.persister?this.options.persister(N,S,this):N(S)},l=(()=>{const N={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:Q(this,Ec),state:this.state,fetchFn:i};return a(N),N})();(d=this.options.behavior)==null||d.onFetch(l,this),ze(this,Au,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=l.fetchOptions)==null?void 0:u.meta))&&Nt(this,Ps,Di).call(this,{type:"fetch",meta:(f=l.fetchOptions)==null?void 0:f.meta}),ze(this,ur,z3({initialPromise:r==null?void 0:r.initialPromise,fn:l.fetchFn,onCancel:N=>{N instanceof q1&&N.revert&&this.setState({...Q(this,Au),fetchStatus:"idle"}),s.abort()},onFail:(N,w)=>{Nt(this,Ps,Di).call(this,{type:"failed",failureCount:N,error:w})},onPause:()=>{Nt(this,Ps,Di).call(this,{type:"pause"})},onContinue:()=>{Nt(this,Ps,Di).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const N=await Q(this,ur).start();if(N===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(N),(m=(h=Q(this,Qs).config).onSuccess)==null||m.call(h,N,this),(x=(y=Q(this,Qs).config).onSettled)==null||x.call(y,N,this.state.error,this),N}catch(N){if(N instanceof q1){if(N.silent)return Q(this,ur).promise;if(N.revert){if(this.state.data===void 0)throw N;return this.state.data}}throw Nt(this,Ps,Di).call(this,{type:"error",error:N}),(v=(j=Q(this,Qs).config).onError)==null||v.call(j,N,this),(b=(g=Q(this,Qs).config).onSettled)==null||b.call(g,this.state.data,N,this),N}finally{this.scheduleGc()}}},Ac=new WeakMap,Au=new WeakMap,Qs=new WeakMap,Ec=new WeakMap,ur=new WeakMap,Fp=new WeakMap,Oc=new WeakMap,Ps=new WeakSet,q3=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Di=function(t){const r=s=>{switch(t.type){case"failed":return{...s,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...W3(s.data,this.options),fetchMeta:t.meta??null};case"success":const a={...s,...QE(t.data,t.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return ze(this,Au,t.manual?a:void 0),a;case"error":const i=t.error;return{...s,error:i,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...t.state}}};this.state=r(this.state),ar.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),Q(this,Qs).notify({query:this,type:"updated",action:t})})},q$);function W3(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:B3(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function QE(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function YE(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,s=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var os,Ot,Bp,Vr,Tc,Eu,Vi,Jo,zp,Ou,Tu,Mc,Rc,el,Mu,Xt,Zm,W1,U1,K1,G1,H1,Q1,Y1,U3,W$,pX=(W$=class extends Uf{constructor(t,r){super();it(this,Xt);it(this,os);it(this,Ot);it(this,Bp);it(this,Vr);it(this,Tc);it(this,Eu);it(this,Vi);it(this,Jo);it(this,zp);it(this,Ou);it(this,Tu);it(this,Mc);it(this,Rc);it(this,el);it(this,Mu,new Set);this.options=r,ze(this,os,t),ze(this,Jo,null),ze(this,Vi,V1()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(Q(this,Ot).addObserver(this),XE(Q(this,Ot),this.options)?Nt(this,Xt,Zm).call(this):this.updateResult(),Nt(this,Xt,G1).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return X1(Q(this,Ot),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return X1(Q(this,Ot),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Nt(this,Xt,H1).call(this),Nt(this,Xt,Q1).call(this),Q(this,Ot).removeObserver(this)}setOptions(t){const r=this.options,s=Q(this,Ot);if(this.options=Q(this,os).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ys(this.options.enabled,Q(this,Ot))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Nt(this,Xt,Y1).call(this),Q(this,Ot).setOptions(this.options),r._defaulted&&!Pv(this.options,r)&&Q(this,os).getQueryCache().notify({type:"observerOptionsUpdated",query:Q(this,Ot),observer:this});const a=this.hasListeners();a&&ZE(Q(this,Ot),s,this.options,r)&&Nt(this,Xt,Zm).call(this),this.updateResult(),a&&(Q(this,Ot)!==s||Ys(this.options.enabled,Q(this,Ot))!==Ys(r.enabled,Q(this,Ot))||vl(this.options.staleTime,Q(this,Ot))!==vl(r.staleTime,Q(this,Ot)))&&Nt(this,Xt,W1).call(this);const i=Nt(this,Xt,U1).call(this);a&&(Q(this,Ot)!==s||Ys(this.options.enabled,Q(this,Ot))!==Ys(r.enabled,Q(this,Ot))||i!==Q(this,el))&&Nt(this,Xt,K1).call(this,i)}getOptimisticResult(t){const r=Q(this,os).getQueryCache().build(Q(this,os),t),s=this.createResult(r,t);return gX(this,s)&&(ze(this,Vr,s),ze(this,Eu,this.options),ze(this,Tc,Q(this,Ot).state)),s}getCurrentResult(){return Q(this,Vr)}trackResult(t,r){return new Proxy(t,{get:(s,a)=>(this.trackProp(a),r==null||r(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&Q(this,Vi).status==="pending"&&Q(this,Vi).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,a))})}trackProp(t){Q(this,Mu).add(t)}getCurrentQuery(){return Q(this,Ot)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=Q(this,os).defaultQueryOptions(t),s=Q(this,os).getQueryCache().build(Q(this,os),r);return s.fetch().then(()=>this.createResult(s,r))}fetch(t){return Nt(this,Xt,Zm).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),Q(this,Vr)))}createResult(t,r){var P;const s=Q(this,Ot),a=this.options,i=Q(this,Vr),o=Q(this,Tc),l=Q(this,Eu),d=t!==s?t.state:Q(this,Bp),{state:u}=t;let f={...u},h=!1,m;if(r._optimisticResults){const D=this.hasListeners(),z=!D&&XE(t,r),O=D&&ZE(t,s,r,a);(z||O)&&(f={...f,...W3(u.data,t.options)}),r._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:y,errorUpdatedAt:x,status:j}=f;m=f.data;let v=!1;if(r.placeholderData!==void 0&&m===void 0&&j==="pending"){let D;i!=null&&i.isPlaceholderData&&r.placeholderData===(l==null?void 0:l.placeholderData)?(D=i.data,v=!0):D=typeof r.placeholderData=="function"?r.placeholderData((P=Q(this,Tu))==null?void 0:P.state.data,Q(this,Tu)):r.placeholderData,D!==void 0&&(j="success",m=z1(i==null?void 0:i.data,D,r),h=!0)}if(r.select&&m!==void 0&&!v)if(i&&m===(o==null?void 0:o.data)&&r.select===Q(this,zp))m=Q(this,Ou);else try{ze(this,zp,r.select),m=r.select(m),m=z1(i==null?void 0:i.data,m,r),ze(this,Ou,m),ze(this,Jo,null)}catch(D){ze(this,Jo,D)}Q(this,Jo)&&(y=Q(this,Jo),m=Q(this,Ou),x=Date.now(),j="error");const g=f.fetchStatus==="fetching",b=j==="pending",N=j==="error",w=b&&g,S=m!==void 0,C={status:j,fetchStatus:f.fetchStatus,isPending:b,isSuccess:j==="success",isError:N,isInitialLoading:w,isLoading:w,data:m,dataUpdatedAt:f.dataUpdatedAt,error:y,errorUpdatedAt:x,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:f.dataUpdateCount>d.dataUpdateCount||f.errorUpdateCount>d.errorUpdateCount,isFetching:g,isRefetching:g&&!b,isLoadingError:N&&!S,isPaused:f.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:N&&S,isStale:Mk(t,r),refetch:this.refetch,promise:Q(this,Vi),isEnabled:Ys(r.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const D=C.data!==void 0,z=C.status==="error"&&!D,O=$=>{z?$.reject(C.error):D&&$.resolve(C.data)},V=()=>{const $=ze(this,Vi,C.promise=V1());O($)},A=Q(this,Vi);switch(A.status){case"pending":t.queryHash===s.queryHash&&O(A);break;case"fulfilled":(z||C.data!==A.value)&&V();break;case"rejected":(!z||C.error!==A.reason)&&V();break}}return C}updateResult(){const t=Q(this,Vr),r=this.createResult(Q(this,Ot),this.options);if(ze(this,Tc,Q(this,Ot).state),ze(this,Eu,this.options),Q(this,Tc).data!==void 0&&ze(this,Tu,Q(this,Ot)),Pv(r,t))return;ze(this,Vr,r);const s=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!Q(this,Mu).size)return!0;const o=new Set(i??Q(this,Mu));return this.options.throwOnError&&o.add("error"),Object.keys(Q(this,Vr)).some(l=>{const c=l;return Q(this,Vr)[c]!==t[c]&&o.has(c)})};Nt(this,Xt,U3).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Nt(this,Xt,G1).call(this)}},os=new WeakMap,Ot=new WeakMap,Bp=new WeakMap,Vr=new WeakMap,Tc=new WeakMap,Eu=new WeakMap,Vi=new WeakMap,Jo=new WeakMap,zp=new WeakMap,Ou=new WeakMap,Tu=new WeakMap,Mc=new WeakMap,Rc=new WeakMap,el=new WeakMap,Mu=new WeakMap,Xt=new WeakSet,Zm=function(t){Nt(this,Xt,Y1).call(this);let r=Q(this,Ot).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(Ur)),r},W1=function(){Nt(this,Xt,H1).call(this);const t=vl(this.options.staleTime,Q(this,Ot));if(Wh.isServer()||Q(this,Vr).isStale||!F1(t))return;const s=D3(Q(this,Vr).dataUpdatedAt,t)+1;ze(this,Mc,bc.setTimeout(()=>{Q(this,Vr).isStale||this.updateResult()},s))},U1=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(Q(this,Ot)):this.options.refetchInterval)??!1},K1=function(t){Nt(this,Xt,Q1).call(this),ze(this,el,t),!(Wh.isServer()||Ys(this.options.enabled,Q(this,Ot))===!1||!F1(Q(this,el))||Q(this,el)===0)&&ze(this,Rc,bc.setInterval(()=>{(this.options.refetchIntervalInBackground||Ak.isFocused())&&Nt(this,Xt,Zm).call(this)},Q(this,el)))},G1=function(){Nt(this,Xt,W1).call(this),Nt(this,Xt,K1).call(this,Nt(this,Xt,U1).call(this))},H1=function(){Q(this,Mc)!==void 0&&(bc.clearTimeout(Q(this,Mc)),ze(this,Mc,void 0))},Q1=function(){Q(this,Rc)!==void 0&&(bc.clearInterval(Q(this,Rc)),ze(this,Rc,void 0))},Y1=function(){const t=Q(this,os).getQueryCache().build(Q(this,os),this.options);if(t===Q(this,Ot))return;const r=Q(this,Ot);ze(this,Ot,t),ze(this,Bp,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},U3=function(t){ar.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(Q(this,Vr))}),Q(this,os).getQueryCache().notify({query:Q(this,Ot),type:"observerResultsUpdated"})})},W$);function xX(e,t){return Ys(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function XE(e,t){return xX(e,t)||e.state.data!==void 0&&X1(e,t,t.refetchOnMount)}function X1(e,t,r){if(Ys(t.enabled,e)!==!1&&vl(t.staleTime,e)!=="static"){const s=typeof r=="function"?r(e):r;return s==="always"||s!==!1&&Mk(e,t)}return!1}function ZE(e,t,r,s){return(e!==t||Ys(s.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&Mk(e,r)}function Mk(e,t){return Ys(t.enabled,e)!==!1&&e.isStaleByTime(vl(t.staleTime,e))}function gX(e,t){return!Pv(e.getCurrentResult(),t)}function JE(e){return{onFetch:(t,r)=>{var u,f,h,m,y;const s=t.options,a=(h=(f=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:f.fetchMore)==null?void 0:h.direction,i=((m=t.state.data)==null?void 0:m.pages)||[],o=((y=t.state.data)==null?void 0:y.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const d=async()=>{let x=!1;const j=b=>{cX(b,()=>t.signal,()=>x=!0)},v=F3(t.options,t.fetchOptions),g=async(b,N,w)=>{if(x)return Promise.reject();if(N==null&&b.pages.length)return Promise.resolve(b);const _=(()=>{const z={client:t.client,queryKey:t.queryKey,pageParam:N,direction:w?"backward":"forward",meta:t.options.meta};return j(z),z})(),C=await v(_),{maxPages:P}=t.options,D=w?lX:oX;return{pages:D(b.pages,C,P),pageParams:D(b.pageParams,N,P)}};if(a&&i.length){const b=a==="backward",N=b?vX:eO,w={pages:i,pageParams:o},S=N(s,w);l=await g(w,S,b)}else{const b=e??i.length;do{const N=c===0?o[0]??s.initialPageParam:eO(s,l);if(c>0&&N==null)break;l=await g(l,N),c++}while(c{var x,j;return(j=(x=t.options).persister)==null?void 0:j.call(x,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r)}:t.fetchFn=d}}}function eO(e,{pages:t,pageParams:r}){const s=t.length-1;return t.length>0?e.getNextPageParam(t[s],t,r[s],r):void 0}function vX(e,{pages:t,pageParams:r}){var s;return t.length>0?(s=e.getPreviousPageParam)==null?void 0:s.call(e,t[0],t,r[0],r):void 0}var Vp,ti,Mr,$c,ni,Lo,U$,yX=(U$=class extends V3{constructor(t){super();it(this,ni);it(this,Vp);it(this,ti);it(this,Mr);it(this,$c);ze(this,Vp,t.client),this.mutationId=t.mutationId,ze(this,Mr,t.mutationCache),ze(this,ti,[]),this.state=t.state||K3(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){Q(this,ti).includes(t)||(Q(this,ti).push(t),this.clearGcTimeout(),Q(this,Mr).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){ze(this,ti,Q(this,ti).filter(r=>r!==t)),this.scheduleGc(),Q(this,Mr).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){Q(this,ti).length||(this.state.status==="pending"?this.scheduleGc():Q(this,Mr).remove(this))}continue(){var t;return((t=Q(this,$c))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,c,d,u,f,h,m,y,x,j,v,g,b,N,w,S,_;const r=()=>{Nt(this,ni,Lo).call(this,{type:"continue"})},s={client:Q(this,Vp),meta:this.options.meta,mutationKey:this.options.mutationKey};ze(this,$c,z3({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(C,P)=>{Nt(this,ni,Lo).call(this,{type:"failed",failureCount:C,error:P})},onPause:()=>{Nt(this,ni,Lo).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>Q(this,Mr).canRun(this)}));const a=this.state.status==="pending",i=!Q(this,$c).canStart();try{if(a)r();else{Nt(this,ni,Lo).call(this,{type:"pending",variables:t,isPaused:i}),Q(this,Mr).config.onMutate&&await Q(this,Mr).config.onMutate(t,this,s);const P=await((l=(o=this.options).onMutate)==null?void 0:l.call(o,t,s));P!==this.state.context&&Nt(this,ni,Lo).call(this,{type:"pending",context:P,variables:t,isPaused:i})}const C=await Q(this,$c).start();return await((d=(c=Q(this,Mr).config).onSuccess)==null?void 0:d.call(c,C,t,this.state.context,this,s)),await((f=(u=this.options).onSuccess)==null?void 0:f.call(u,C,t,this.state.context,s)),await((m=(h=Q(this,Mr).config).onSettled)==null?void 0:m.call(h,C,null,this.state.variables,this.state.context,this,s)),await((x=(y=this.options).onSettled)==null?void 0:x.call(y,C,null,t,this.state.context,s)),Nt(this,ni,Lo).call(this,{type:"success",data:C}),C}catch(C){try{await((v=(j=Q(this,Mr).config).onError)==null?void 0:v.call(j,C,t,this.state.context,this,s))}catch(P){Promise.reject(P)}try{await((b=(g=this.options).onError)==null?void 0:b.call(g,C,t,this.state.context,s))}catch(P){Promise.reject(P)}try{await((w=(N=Q(this,Mr).config).onSettled)==null?void 0:w.call(N,void 0,C,this.state.variables,this.state.context,this,s))}catch(P){Promise.reject(P)}try{await((_=(S=this.options).onSettled)==null?void 0:_.call(S,void 0,C,t,this.state.context,s))}catch(P){Promise.reject(P)}throw Nt(this,ni,Lo).call(this,{type:"error",error:C}),C}finally{Q(this,Mr).runNext(this)}}},Vp=new WeakMap,ti=new WeakMap,Mr=new WeakMap,$c=new WeakMap,ni=new WeakSet,Lo=function(t){const r=s=>{switch(t.type){case"failed":return{...s,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...s,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:t.error,failureCount:s.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=r(this.state),ar.batch(()=>{Q(this,ti).forEach(s=>{s.onMutationUpdate(t)}),Q(this,Mr).notify({mutation:this,type:"updated",action:t})})},U$);function K3(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var qi,Ca,qp,K$,jX=(K$=class extends Uf{constructor(t={}){super();it(this,qi);it(this,Ca);it(this,qp);this.config=t,ze(this,qi,new Set),ze(this,Ca,new Map),ze(this,qp,0)}build(t,r,s){const a=new yX({client:t,mutationCache:this,mutationId:++$x(this,qp)._,options:t.defaultMutationOptions(r),state:s});return this.add(a),a}add(t){Q(this,qi).add(t);const r=sg(t);if(typeof r=="string"){const s=Q(this,Ca).get(r);s?s.push(t):Q(this,Ca).set(r,[t])}this.notify({type:"added",mutation:t})}remove(t){if(Q(this,qi).delete(t)){const r=sg(t);if(typeof r=="string"){const s=Q(this,Ca).get(r);if(s)if(s.length>1){const a=s.indexOf(t);a!==-1&&s.splice(a,1)}else s[0]===t&&Q(this,Ca).delete(r)}}this.notify({type:"removed",mutation:t})}canRun(t){const r=sg(t);if(typeof r=="string"){const s=Q(this,Ca).get(r),a=s==null?void 0:s.find(i=>i.state.status==="pending");return!a||a===t}else return!0}runNext(t){var s;const r=sg(t);if(typeof r=="string"){const a=(s=Q(this,Ca).get(r))==null?void 0:s.find(i=>i!==t&&i.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ar.batch(()=>{Q(this,qi).forEach(t=>{this.notify({type:"removed",mutation:t})}),Q(this,qi).clear(),Q(this,Ca).clear()})}getAll(){return Array.from(Q(this,qi))}find(t){const r={exact:!0,...t};return this.getAll().find(s=>KE(r,s))}findAll(t={}){return this.getAll().filter(r=>KE(t,r))}notify(t){ar.batch(()=>{this.listeners.forEach(r=>{r(t)})})}resumePausedMutations(){const t=this.getAll().filter(r=>r.state.isPaused);return ar.batch(()=>Promise.all(t.map(r=>r.continue().catch(Ur))))}},qi=new WeakMap,Ca=new WeakMap,qp=new WeakMap,K$);function sg(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Wi,tl,ls,Ui,no,Kg,Z1,G$,bX=(G$=class extends Uf{constructor(r,s){super();it(this,no);it(this,Wi);it(this,tl);it(this,ls);it(this,Ui);ze(this,Wi,r),this.setOptions(s),this.bindMethods(),Nt(this,no,Kg).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(r){var a;const s=this.options;this.options=Q(this,Wi).defaultMutationOptions(r),Pv(this.options,s)||Q(this,Wi).getMutationCache().notify({type:"observerOptionsUpdated",mutation:Q(this,ls),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&Gc(s.mutationKey)!==Gc(this.options.mutationKey)?this.reset():((a=Q(this,ls))==null?void 0:a.state.status)==="pending"&&Q(this,ls).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=Q(this,ls))==null||r.removeObserver(this)}onMutationUpdate(r){Nt(this,no,Kg).call(this),Nt(this,no,Z1).call(this,r)}getCurrentResult(){return Q(this,tl)}reset(){var r;(r=Q(this,ls))==null||r.removeObserver(this),ze(this,ls,void 0),Nt(this,no,Kg).call(this),Nt(this,no,Z1).call(this)}mutate(r,s){var a;return ze(this,Ui,s),(a=Q(this,ls))==null||a.removeObserver(this),ze(this,ls,Q(this,Wi).getMutationCache().build(Q(this,Wi),this.options)),Q(this,ls).addObserver(this),Q(this,ls).execute(r)}},Wi=new WeakMap,tl=new WeakMap,ls=new WeakMap,Ui=new WeakMap,no=new WeakSet,Kg=function(){var s;const r=((s=Q(this,ls))==null?void 0:s.state)??K3();ze(this,tl,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},Z1=function(r){ar.batch(()=>{var s,a,i,o,l,c,d,u;if(Q(this,Ui)&&this.hasListeners()){const f=Q(this,tl).variables,h=Q(this,tl).context,m={client:Q(this,Wi),meta:this.options.meta,mutationKey:this.options.mutationKey};if((r==null?void 0:r.type)==="success"){try{(a=(s=Q(this,Ui)).onSuccess)==null||a.call(s,r.data,f,h,m)}catch(y){Promise.reject(y)}try{(o=(i=Q(this,Ui)).onSettled)==null||o.call(i,r.data,null,f,h,m)}catch(y){Promise.reject(y)}}else if((r==null?void 0:r.type)==="error"){try{(c=(l=Q(this,Ui)).onError)==null||c.call(l,r.error,f,h,m)}catch(y){Promise.reject(y)}try{(u=(d=Q(this,Ui)).onSettled)==null||u.call(d,void 0,r.error,f,h,m)}catch(y){Promise.reject(y)}}}this.listeners.forEach(f=>{f(Q(this,tl))})})},G$),ri,H$,wX=(H$=class extends Uf{constructor(t={}){super();it(this,ri);this.config=t,ze(this,ri,new Map)}build(t,r,s){const a=r.queryKey,i=r.queryHash??Ek(a,r);let o=this.get(i);return o||(o=new hX({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(r),state:s,defaultOptions:t.getQueryDefaults(a)}),this.add(o)),o}add(t){Q(this,ri).has(t.queryHash)||(Q(this,ri).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=Q(this,ri).get(t.queryHash);r&&(t.destroy(),r===t&&Q(this,ri).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ar.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return Q(this,ri).get(t)}getAll(){return[...Q(this,ri).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(s=>UE(r,s))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(s=>UE(t,s)):r}notify(t){ar.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){ar.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ar.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},ri=new WeakMap,H$),Rn,nl,rl,Ru,$u,sl,Iu,Du,Q$,NX=(Q$=class{constructor(e={}){it(this,Rn);it(this,nl);it(this,rl);it(this,Ru);it(this,$u);it(this,sl);it(this,Iu);it(this,Du);ze(this,Rn,e.queryCache||new wX),ze(this,nl,e.mutationCache||new jX),ze(this,rl,e.defaultOptions||{}),ze(this,Ru,new Map),ze(this,$u,new Map),ze(this,sl,0)}mount(){$x(this,sl)._++,Q(this,sl)===1&&(ze(this,Iu,Ak.subscribe(async e=>{e&&(await this.resumePausedMutations(),Q(this,Rn).onFocus())})),ze(this,Du,Av.subscribe(async e=>{e&&(await this.resumePausedMutations(),Q(this,Rn).onOnline())})))}unmount(){var e,t;$x(this,sl)._--,Q(this,sl)===0&&((e=Q(this,Iu))==null||e.call(this),ze(this,Iu,void 0),(t=Q(this,Du))==null||t.call(this),ze(this,Du,void 0))}isFetching(e){return Q(this,Rn).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return Q(this,nl).findAll({...e,status:"pending"}).length}getQueryData(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=Q(this,Rn).get(t.queryHash))==null?void 0:r.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=Q(this,Rn).build(this,t),s=r.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(vl(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return Q(this,Rn).findAll(e).map(({queryKey:t,state:r})=>{const s=r.data;return[t,s]})}setQueryData(e,t,r){const s=this.defaultQueryOptions({queryKey:e}),a=Q(this,Rn).get(s.queryHash),i=a==null?void 0:a.state.data,o=sX(t,i);if(o!==void 0)return Q(this,Rn).build(this,s).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return ar.batch(()=>Q(this,Rn).findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,r)]))}getQueryState(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=Q(this,Rn).get(t.queryHash))==null?void 0:r.state}removeQueries(e){const t=Q(this,Rn);ar.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=Q(this,Rn);return ar.batch(()=>(r.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const r={revert:!0,...t},s=ar.batch(()=>Q(this,Rn).findAll(e).map(a=>a.cancel(r)));return Promise.all(s).then(Ur).catch(Ur)}invalidateQueries(e,t={}){return ar.batch(()=>(Q(this,Rn).findAll(e).forEach(r=>{r.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const r={...t,cancelRefetch:t.cancelRefetch??!0},s=ar.batch(()=>Q(this,Rn).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,r);return r.throwOnError||(i=i.catch(Ur)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(s).then(Ur)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=Q(this,Rn).build(this,t);return r.isStaleByTime(vl(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ur).catch(Ur)}fetchInfiniteQuery(e){return e.behavior=JE(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ur).catch(Ur)}ensureInfiniteQueryData(e){return e.behavior=JE(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Av.isOnline()?Q(this,nl).resumePausedMutations():Promise.resolve()}getQueryCache(){return Q(this,Rn)}getMutationCache(){return Q(this,nl)}getDefaultOptions(){return Q(this,rl)}setDefaultOptions(e){ze(this,rl,e)}setQueryDefaults(e,t){Q(this,Ru).set(Gc(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...Q(this,Ru).values()],r={};return t.forEach(s=>{qh(e,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(e,t){Q(this,$u).set(Gc(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...Q(this,$u).values()],r={};return t.forEach(s=>{qh(e,s.mutationKey)&&Object.assign(r,s.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...Q(this,rl).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Ek(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Ok&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...Q(this,rl).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){Q(this,Rn).clear(),Q(this,nl).clear()}},Rn=new WeakMap,nl=new WeakMap,rl=new WeakMap,Ru=new WeakMap,$u=new WeakMap,sl=new WeakMap,Iu=new WeakMap,Du=new WeakMap,Q$),G3=p.createContext(void 0),je=e=>{const t=p.useContext(G3);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},SX=({client:e,children:t})=>(p.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),n.jsx(G3.Provider,{value:e,children:t})),H3=p.createContext(!1),_X=()=>p.useContext(H3);H3.Provider;function CX(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var kX=p.createContext(CX()),PX=()=>p.useContext(kX),AX=(e,t,r)=>{const s=r!=null&&r.state.error&&typeof e.throwOnError=="function"?Tk(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||s)&&(t.isReset()||(e.retryOnMount=!1))},EX=e=>{p.useEffect(()=>{e.clearReset()},[e])},OX=({result:e,errorResetBoundary:t,throwOnError:r,query:s,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(a&&e.data===void 0||Tk(r,[e.error,s])),TX=e=>{if(e.suspense){const r=a=>a==="static"?a:Math.max(a??1e3,1e3),s=e.staleTime;e.staleTime=typeof s=="function"?(...a)=>r(s(...a)):r(s),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},MX=(e,t)=>e.isLoading&&e.isFetching&&!t,RX=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,tO=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function $X(e,t,r){var h,m,y,x;const s=_X(),a=PX(),i=je(),o=i.defaultQueryOptions(e);(m=(h=i.getDefaultOptions().queries)==null?void 0:h._experimental_beforeQuery)==null||m.call(h,o);const l=i.getQueryCache().get(o.queryHash);o._optimisticResults=s?"isRestoring":"optimistic",TX(o),AX(o,a,l),EX(a);const c=!i.getQueryCache().get(o.queryHash),[d]=p.useState(()=>new t(i,o)),u=d.getOptimisticResult(o),f=!s&&e.subscribed!==!1;if(p.useSyncExternalStore(p.useCallback(j=>{const v=f?d.subscribe(ar.batchCalls(j)):Ur;return d.updateResult(),v},[d,f]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),p.useEffect(()=>{d.setOptions(o)},[o,d]),RX(o,u))throw tO(o,d,a);if(OX({result:u,errorResetBoundary:a,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw u.error;if((x=(y=i.getDefaultOptions().queries)==null?void 0:y._experimental_afterQuery)==null||x.call(y,o,u),o.experimental_prefetchInRender&&!Wh.isServer()&&MX(u,s)){const j=c?tO(o,d,a):l==null?void 0:l.promise;j==null||j.catch(Ur).finally(()=>{d.updateResult()})}return o.notifyOnChangeProps?u:d.trackResult(u)}function ye(e,t){return $X(e,pX)}function ae(e,t){const r=je(),[s]=p.useState(()=>new bX(r,e));p.useEffect(()=>{s.setOptions(e)},[s,e]);const a=p.useSyncExternalStore(p.useCallback(o=>s.subscribe(ar.batchCalls(o)),[s]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),i=p.useCallback((o,l)=>{s.mutate(o,l).catch(Ur)},[s]);if(a.error&&Tk(s.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}/** * @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 Uh(){return Uh=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function Rk(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function DX(){return Math.random().toString(36).substr(2,8)}function rO(e,t){return{usr:e.state,key:e.key,idx:t}}function J1(e,t,r,s){return r===void 0&&(r=null),Uh({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?Kf(t):t,{state:r,key:t&&t.key||s||DX()})}function Ev(e){let{pathname:t="/",search:r="",hash:s=""}=e;return r&&r!=="?"&&(t+=r.charAt(0)==="?"?r:"?"+r),s&&s!=="#"&&(t+=s.charAt(0)==="#"?s:"#"+s),t}function Kf(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substr(r),e=e.substr(0,r));let s=e.indexOf("?");s>=0&&(t.search=e.substr(s),e=e.substr(0,s)),e&&(t.pathname=e)}return t}function LX(e,t,r,s){s===void 0&&(s={});let{window:a=document.defaultView,v5Compat:i=!1}=s,o=a.history,l=ol.Pop,c=null,d=u();d==null&&(d=0,o.replaceState(Uh({},o.state,{idx:d}),""));function u(){return(o.state||{idx:null}).idx}function f(){l=ol.Pop;let j=u(),v=j==null?null:j-d;d=j,c&&c({action:l,location:x.location,delta:v})}function h(j,v){l=ol.Push;let g=J1(x.location,j,v);d=u()+1;let b=rO(g,d),N=x.createHref(g);try{o.pushState(b,"",N)}catch(w){if(w instanceof DOMException&&w.name==="DataCloneError")throw w;a.location.assign(N)}i&&c&&c({action:l,location:x.location,delta:1})}function m(j,v){l=ol.Replace;let g=J1(x.location,j,v);d=u();let b=rO(g,d),N=x.createHref(g);o.replaceState(b,"",N),i&&c&&c({action:l,location:x.location,delta:0})}function y(j){let v=a.location.origin!=="null"?a.location.origin:a.location.href,g=typeof j=="string"?j:Ev(j);return g=g.replace(/ $/,"%20"),On(v,"No window.location.(origin|href) available to create URL for href: "+g),new URL(g,v)}let x={get action(){return l},get location(){return e(a,o)},listen(j){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(nO,f),c=j,()=>{a.removeEventListener(nO,f),c=null}},createHref(j){return t(a,j)},createURL:y,encodeLocation(j){let v=y(j);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:h,replace:m,go(j){return o.go(j)}};return x}var sO;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(sO||(sO={}));function FX(e,t,r){return r===void 0&&(r="/"),BX(e,t,r)}function BX(e,t,r,s){let a=typeof t=="string"?Kf(t):t,i=Qu(a.pathname||"/",r);if(i==null)return null;let o=Q3(e);zX(o);let l=null;for(let c=0;l==null&&c{let c={relativePath:l===void 0?i.path||"":l,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};c.relativePath.startsWith("/")&&(On(c.relativePath.startsWith(s),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+s+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(s.length));let d=yl([s,c.relativePath]),u=r.concat(c);i.children&&i.children.length>0&&(On(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),Q3(i.children,t,u,d)),!(i.path==null&&!i.index)&&t.push({path:d,score:HX(d,i.index),routesMeta:u})};return e.forEach((i,o)=>{var l;if(i.path===""||!((l=i.path)!=null&&l.includes("?")))a(i,o);else for(let c of Y3(i.path))a(i,o,c)}),t}function Y3(e){let t=e.split("/");if(t.length===0)return[];let[r,...s]=t,a=r.endsWith("?"),i=r.replace(/\?$/,"");if(s.length===0)return a?[i,""]:[i];let o=Y3(s.join("/")),l=[];return l.push(...o.map(c=>c===""?i:[i,c].join("/"))),a&&l.push(...o),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function zX(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:QX(t.routesMeta.map(s=>s.childrenIndex),r.routesMeta.map(s=>s.childrenIndex)))}const VX=/^:[\w-]+$/,qX=3,WX=2,UX=1,KX=10,GX=-2,aO=e=>e==="*";function HX(e,t){let r=e.split("/"),s=r.length;return r.some(aO)&&(s+=GX),t&&(s+=WX),r.filter(a=>!aO(a)).reduce((a,i)=>a+(VX.test(i)?qX:i===""?UX:KX),s)}function QX(e,t){return e.length===t.length&&e.slice(0,-1).every((s,a)=>s===t[a])?e[e.length-1]-t[t.length-1]:0}function YX(e,t,r){let{routesMeta:s}=e,a={},i="/",o=[];for(let l=0;l{let{paramName:h,isOptional:m}=u;if(h==="*"){let x=l[f]||"";o=i.slice(0,i.length-x.length).replace(/(.)\/+$/,"$1")}const y=l[f];return m&&!y?d[h]=void 0:d[h]=(y||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:o,pattern:e}}function XX(e,t,r){t===void 0&&(t=!1),r===void 0&&(r=!0),Rk(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let s=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c)=>(s.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(s.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),s]}function ZX(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Rk(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Qu(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,s=e.charAt(r);return s&&s!=="/"?null:e.slice(r)||"/"}const JX=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,eZ=e=>JX.test(e);function tZ(e,t){t===void 0&&(t="/");let{pathname:r,search:s="",hash:a=""}=typeof e=="string"?Kf(e):e,i;if(r)if(eZ(r))i=r;else{if(r.includes("//")){let o=r;r=r.replace(/\/\/+/g,"/"),Rk(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+r))}r.startsWith("/")?i=iO(r.substring(1),"/"):i=iO(r,t)}else i=t;return{pathname:i,search:sZ(s),hash:aZ(a)}}function iO(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?r.length>1&&r.pop():a!=="."&&r.push(a)}),r.length>1?r.join("/"):"/"}function hw(e,t,r,s){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(s)+"]. Please separate it out to the ")+("`to."+r+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function nZ(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function $k(e,t){let r=nZ(e);return t?r.map((s,a)=>a===r.length-1?s.pathname:s.pathnameBase):r.map(s=>s.pathnameBase)}function Ik(e,t,r,s){s===void 0&&(s=!1);let a;typeof e=="string"?a=Kf(e):(a=Uh({},e),On(!a.pathname||!a.pathname.includes("?"),hw("?","pathname","search",a)),On(!a.pathname||!a.pathname.includes("#"),hw("#","pathname","hash",a)),On(!a.search||!a.search.includes("#"),hw("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,l;if(o==null)l=r;else{let f=t.length-1;if(!s&&o.startsWith("..")){let h=o.split("/");for(;h[0]==="..";)h.shift(),f-=1;a.pathname=h.join("/")}l=f>=0?t[f]:"/"}let c=tZ(a,l),d=o&&o!=="/"&&o.endsWith("/"),u=(i||o===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(d||u)&&(c.pathname+="/"),c}const yl=e=>e.join("/").replace(/\/\/+/g,"/"),rZ=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),sZ=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,aZ=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function iZ(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const X3=["post","put","patch","delete"];new Set(X3);const oZ=["get",...X3];new Set(oZ);/** * 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 Kh(){return Kh=Object.assign?Object.assign.bind():function(e){for(var t=1;t{l.current=!0}),p.useCallback(function(d,u){if(u===void 0&&(u={}),!l.current)return;if(typeof d=="number"){s.go(d);return}let f=Ik(d,JSON.parse(o),i,u.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:yl([t,f.pathname])),(u.replace?s.replace:s.push)(f,u.state,u)},[t,s,o,i,e])}const dZ=p.createContext(null);function uZ(e){let t=p.useContext(ki).outlet;return t&&p.createElement(dZ.Provider,{value:e},t)}function Ht(){let{matches:e}=p.useContext(ki),t=e[e.length-1];return t?t.params:{}}function qj(e,t){let{relative:r}=t===void 0?{}:t,{future:s}=p.useContext(bo),{matches:a}=p.useContext(ki),{pathname:i}=Ka(),o=JSON.stringify($k(a,s.v7_relativeSplatPath));return p.useMemo(()=>Ik(e,JSON.parse(o),i,r==="path"),[e,o,i,r])}function fZ(e,t){return mZ(e,t)}function mZ(e,t,r,s){Gf()||On(!1);let{navigator:a}=p.useContext(bo),{matches:i}=p.useContext(ki),o=i[i.length-1],l=o?o.params:{};o&&o.pathname;let c=o?o.pathnameBase:"/";o&&o.route;let d=Ka(),u;if(t){var f;let j=typeof t=="string"?Kf(t):t;c==="/"||(f=j.pathname)!=null&&f.startsWith(c)||On(!1),u=j}else u=d;let h=u.pathname||"/",m=h;if(c!=="/"){let j=c.replace(/^\//,"").split("/");m="/"+h.replace(/^\//,"").split("/").slice(j.length).join("/")}let y=FX(e,{pathname:m}),x=vZ(y&&y.map(j=>Object.assign({},j,{params:Object.assign({},l,j.params),pathname:yl([c,a.encodeLocation?a.encodeLocation(j.pathname).pathname:j.pathname]),pathnameBase:j.pathnameBase==="/"?c:yl([c,a.encodeLocation?a.encodeLocation(j.pathnameBase).pathname:j.pathnameBase])})),i,r,s);return t&&x?p.createElement(Vj.Provider,{value:{location:Kh({pathname:"/",search:"",hash:"",state:null,key:"default"},u),navigationType:ol.Pop}},x):x}function hZ(){let e=wZ(),t=iZ(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return p.createElement(p.Fragment,null,p.createElement("h2",null,"Unexpected Application Error!"),p.createElement("h3",{style:{fontStyle:"italic"}},t),r?p.createElement("pre",{style:a},r):null,null)}const pZ=p.createElement(hZ,null);class xZ extends p.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,r){return r.location!==t.location||r.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:r.error,location:r.location,revalidation:t.revalidation||r.revalidation}}componentDidCatch(t,r){console.error("React Router caught the following error during render",t,r)}render(){return this.state.error!==void 0?p.createElement(ki.Provider,{value:this.props.routeContext},p.createElement(J3.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function gZ(e){let{routeContext:t,match:r,children:s}=e,a=p.useContext(zj);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),p.createElement(ki.Provider,{value:t},s)}function vZ(e,t,r,s){var a;if(t===void 0&&(t=[]),r===void 0&&(r=null),s===void 0&&(s=null),e==null){var i;if(!r)return null;if(r.errors)e=r.matches;else if((i=s)!=null&&i.v7_partialHydration&&t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let o=e,l=(a=r)==null?void 0:a.errors;if(l!=null){let u=o.findIndex(f=>f.route.id&&(l==null?void 0:l[f.route.id])!==void 0);u>=0||On(!1),o=o.slice(0,Math.min(o.length,u+1))}let c=!1,d=-1;if(r&&s&&s.v7_partialHydration)for(let u=0;u=0?o=o.slice(0,d+1):o=[o[0]];break}}}return o.reduceRight((u,f,h)=>{let m,y=!1,x=null,j=null;r&&(m=l&&f.route.id?l[f.route.id]:void 0,x=f.route.errorElement||pZ,c&&(d<0&&h===0?(SZ("route-fallback"),y=!0,j=null):d===h&&(y=!0,j=f.route.hydrateFallbackElement||null)));let v=t.concat(o.slice(0,h+1)),g=()=>{let b;return m?b=x:y?b=j:f.route.Component?b=p.createElement(f.route.Component,null):f.route.element?b=f.route.element:b=u,p.createElement(gZ,{match:f,routeContext:{outlet:u,matches:v,isDataRoute:r!=null},children:b})};return r&&(f.route.ErrorBoundary||f.route.errorElement||h===0)?p.createElement(xZ,{location:r.location,revalidation:r.revalidation,component:x,error:m,children:g(),routeContext:{outlet:null,matches:v,isDataRoute:!0}}):g()},null)}var tF=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(tF||{}),nF=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(nF||{});function yZ(e){let t=p.useContext(zj);return t||On(!1),t}function jZ(e){let t=p.useContext(Z3);return t||On(!1),t}function bZ(e){let t=p.useContext(ki);return t||On(!1),t}function rF(e){let t=bZ(),r=t.matches[t.matches.length-1];return r.route.id||On(!1),r.route.id}function wZ(){var e;let t=p.useContext(J3),r=jZ(),s=rF();return t!==void 0?t:(e=r.errors)==null?void 0:e[s]}function NZ(){let{router:e}=yZ(tF.UseNavigateStable),t=rF(nF.UseNavigateStable),r=p.useRef(!1);return eF(()=>{r.current=!0}),p.useCallback(function(a,i){i===void 0&&(i={}),r.current&&(typeof a=="number"?e.navigate(a):e.navigate(a,Kh({fromRouteId:t},i)))},[e,t])}const oO={};function SZ(e,t,r){oO[e]||(oO[e]=!0)}function _Z(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function jl(e){let{to:t,replace:r,state:s,relative:a}=e;Gf()||On(!1);let{future:i,static:o}=p.useContext(bo),{matches:l}=p.useContext(ki),{pathname:c}=Ka(),d=Bt(),u=Ik(t,$k(l,i.v7_relativeSplatPath),c,a==="path"),f=JSON.stringify(u);return p.useEffect(()=>d(JSON.parse(f),{replace:r,state:s,relative:a}),[d,f,a,r,s]),null}function Dk(e){return uZ(e.context)}function fe(e){On(!1)}function CZ(e){let{basename:t="/",children:r=null,location:s,navigationType:a=ol.Pop,navigator:i,static:o=!1,future:l}=e;Gf()&&On(!1);let c=t.replace(/^\/*/,"/"),d=p.useMemo(()=>({basename:c,navigator:i,static:o,future:Kh({v7_relativeSplatPath:!1},l)}),[c,l,i,o]);typeof s=="string"&&(s=Kf(s));let{pathname:u="/",search:f="",hash:h="",state:m=null,key:y="default"}=s,x=p.useMemo(()=>{let j=Qu(u,c);return j==null?null:{location:{pathname:j,search:f,hash:h,state:m,key:y},navigationType:a}},[c,u,f,h,m,y,a]);return x==null?null:p.createElement(bo.Provider,{value:d},p.createElement(Vj.Provider,{children:r,value:x}))}function kZ(e){let{children:t,location:r}=e;return fZ(tS(t),r)}new Promise(()=>{});function tS(e,t){t===void 0&&(t=[]);let r=[];return p.Children.forEach(e,(s,a)=>{if(!p.isValidElement(s))return;let i=[...t,a];if(s.type===p.Fragment){r.push.apply(r,tS(s.props.children,i));return}s.type!==fe&&On(!1),!s.props.index||!s.props.children||On(!1);let o={id:s.props.id||i.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,loader:s.props.loader,action:s.props.action,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(o.children=tS(s.props.children,i)),r.push(o)}),r}/** * 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 */function Ov(){return Ov=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(r[a]=e[a]);return r}function PZ(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function AZ(e,t){return e.button===0&&(!t||t==="_self")&&!PZ(e)}function nS(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,r)=>{let s=e[r];return t.concat(Array.isArray(s)?s.map(a=>[r,a]):[[r,s]])},[]))}function EZ(e,t){let r=nS(e);return t&&t.forEach((s,a)=>{r.has(a)||t.getAll(a).forEach(i=>{r.append(a,i)})}),r}const OZ=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],TZ=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],MZ="6";try{window.__reactRouterVersion=MZ}catch{}const RZ=p.createContext({isTransitioning:!1}),$Z="startTransition",lO=ij[$Z];function IZ(e){let{basename:t,children:r,future:s,window:a}=e,i=p.useRef();i.current==null&&(i.current=IX({window:a,v5Compat:!0}));let o=i.current,[l,c]=p.useState({action:o.action,location:o.location}),{v7_startTransition:d}=s||{},u=p.useCallback(f=>{d&&lO?lO(()=>c(f)):c(f)},[c,d]);return p.useLayoutEffect(()=>o.listen(u),[o,u]),p.useEffect(()=>_Z(s),[s]),p.createElement(CZ,{basename:t,children:r,location:l.location,navigationType:l.action,navigator:o,future:s})}const DZ=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",LZ=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Dt=p.forwardRef(function(t,r){let{onClick:s,relative:a,reloadDocument:i,replace:o,state:l,target:c,to:d,preventScrollReset:u,viewTransition:f}=t,h=sF(t,OZ),{basename:m}=p.useContext(bo),y,x=!1;if(typeof d=="string"&&LZ.test(d)&&(y=d,DZ))try{let b=new URL(window.location.href),N=d.startsWith("//")?new URL(b.protocol+d):new URL(d),w=Qu(N.pathname,m);N.origin===b.origin&&w!=null?d=w+N.search+N.hash:x=!0}catch{}let j=lZ(d,{relative:a}),v=zZ(d,{replace:o,state:l,target:c,preventScrollReset:u,relative:a,viewTransition:f});function g(b){s&&s(b),b.defaultPrevented||v(b)}return p.createElement("a",Ov({},h,{href:y||j,onClick:x||i?s:g,ref:r,target:c}))}),FZ=p.forwardRef(function(t,r){let{"aria-current":s="page",caseSensitive:a=!1,className:i="",end:o=!1,style:l,to:c,viewTransition:d,children:u}=t,f=sF(t,TZ),h=qj(c,{relative:f.relative}),m=Ka(),y=p.useContext(Z3),{navigator:x,basename:j}=p.useContext(bo),v=y!=null&&VZ(h)&&d===!0,g=x.encodeLocation?x.encodeLocation(h).pathname:h.pathname,b=m.pathname,N=y&&y.navigation&&y.navigation.location?y.navigation.location.pathname:null;a||(b=b.toLowerCase(),N=N?N.toLowerCase():null,g=g.toLowerCase()),N&&j&&(N=Qu(N,j)||N);const w=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let S=b===g||!o&&b.startsWith(g)&&b.charAt(w)==="/",_=N!=null&&(N===g||!o&&N.startsWith(g)&&N.charAt(g.length)==="/"),C={isActive:S,isPending:_,isTransitioning:v},P=S?s:void 0,D;typeof i=="function"?D=i(C):D=[i,S?"active":null,_?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let z=typeof l=="function"?l(C):l;return p.createElement(Dt,Ov({},f,{"aria-current":P,className:D,ref:r,style:z,to:c,viewTransition:d}),typeof u=="function"?u(C):u)});var rS;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(rS||(rS={}));var cO;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(cO||(cO={}));function BZ(e){let t=p.useContext(zj);return t||On(!1),t}function zZ(e,t){let{target:r,replace:s,state:a,preventScrollReset:i,relative:o,viewTransition:l}=t===void 0?{}:t,c=Bt(),d=Ka(),u=qj(e,{relative:o});return p.useCallback(f=>{if(AZ(f,r)){f.preventDefault();let h=s!==void 0?s:Ev(d)===Ev(u);c(e,{replace:h,state:a,preventScrollReset:i,relative:o,viewTransition:l})}},[d,c,u,s,a,r,e,i,o,l])}function wo(e){let t=p.useRef(nS(e)),r=p.useRef(!1),s=Ka(),a=p.useMemo(()=>EZ(s.search,r.current?null:t.current),[s.search]),i=Bt(),o=p.useCallback((l,c)=>{const d=nS(typeof l=="function"?l(a):l);r.current=!0,i("?"+d,c)},[i,a]);return[a,o]}function VZ(e,t){t===void 0&&(t={});let r=p.useContext(RZ);r==null&&On(!1);let{basename:s}=BZ(rS.useViewTransitionState),a=qj(e,{relative:t.relative});if(!r.isTransitioning)return!1;let i=Qu(r.currentLocation.pathname,s)||r.currentLocation.pathname,o=Qu(r.nextLocation.pathname,s)||r.nextLocation.pathname;return eS(a.pathname,o)!=null||eS(a.pathname,i)!=null}const Wj="/api".replace(/\/$/,""),qZ=Wj;function WZ(e,t,r){if(e&&typeof e=="object"&&e!==null&&"error"in e){const s=e.error;if(s!=null&&String(s).trim())return String(s)}return`${t} ${r}`}class Va extends Error{constructor(t,r,s){super(WZ(s,t,r)),this.status=t,this.statusText=r,this.data=s,this.name="ApiError"}}function Lk(){return localStorage.getItem("encoach_token")}function UZ(e){localStorage.setItem("encoach_token",e)}function Fk(){localStorage.removeItem("encoach_token")}async function Rd(e){const t=await e.json().catch(()=>null);if(e.status===401){const r=!!Lk();throw Fk(),r&&(window.location.href="/login"),new Va(401,e.statusText,t)}if(!e.ok)throw new Va(e.status,e.statusText,t);return t}function Am(e){const t={"Content-Type":"application/json",...e},r=Lk();return r&&(t.Authorization=`Bearer ${r}`),t}function $d(e,t){const r=new URL(`${qZ}${e}`,window.location.origin);return t&&Object.entries(t).forEach(([s,a])=>{a!==void 0&&r.searchParams.set(s,String(a))}),r.toString()}const R={async get(e,t){const r=await fetch($d(e,t),{method:"GET",headers:Am()});return Rd(r)},async post(e,t){const r=await fetch($d(e),{method:"POST",headers:Am(),body:t?JSON.stringify(t):void 0});return Rd(r)},async patch(e,t){const r=await fetch($d(e),{method:"PATCH",headers:Am(),body:t?JSON.stringify(t):void 0});return Rd(r)},async put(e,t){const r=await fetch($d(e),{method:"PUT",headers:Am(),body:t?JSON.stringify(t):void 0});return Rd(r)},async delete(e){const t=await fetch($d(e),{method:"DELETE",headers:Am()});return Rd(t)},async upload(e,t){const r=Lk(),s={};r&&(s.Authorization=`Bearer ${r}`);const a=await fetch($d(e),{method:"POST",headers:s,body:t});return Rd(a)}},Gg={async login(e){const t=await R.post("/login",{...e,email:e.login});return UZ(t.token),t},async logout(){await R.post("/logout").catch(()=>{}),Fk()},async getUser(){return(await R.get("/user")).user},async resetPassword(e){return R.post("/reset/sendVerification",e)},async setInvitePassword(e){return R.post("/auth/invite/set-password",e)}},aF=p.createContext(void 0);function KZ({children:e}){const[t,r]=p.useState(null),[s,a]=p.useState(!0);p.useEffect(()=>{if(!localStorage.getItem("encoach_token")){a(!1);return}Gg.getUser().then(r).catch(()=>{Fk()}).finally(()=>a(!1))},[]);const i=p.useCallback(async(l,c)=>{const d=await Gg.login({login:l,password:c});return r(d.user),d.user},[]),o=p.useCallback(async()=>{await Gg.logout(),r(null)},[]);return n.jsx(aF.Provider,{value:{user:t,isAuthenticated:!!t,isLoading:s,login:i,logout:o},children:e})}function Ga(){const e=p.useContext(aF);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}function iu(e){const t=e,r=t.items??t.data??[],s=t.total??r.length,a=t.page??1,i=t.size??(r.length||20),o=i>0?Math.max(1,Math.ceil(s/i)):1;return{items:r,total:s,page:a,size:i,pages:o}}function $r(e){return e&&typeof e=="object"&&"data"in e&&e.data!==void 0?e.data:e}const iF={async list(e){const t=await R.get("/entities",e);return iu(t)},async getById(e){const t=await R.get(`/entities/${e}`);return $r(t)},async create(e){const t=await R.post("/entities",e);return $r(t)},async update(e,t){const r=await R.patch(`/entities/${e}`,t);return $r(r)},async delete(e){return R.delete(`/entities/${e}`)},async getRoles(e){return R.get(`/entities/${e}/roles`)},async createRole(e,t){return R.post(`/entities/${e}/roles`,t)},async updateRolePermissions(e,t){return R.patch(`/roles/${e}/permissions`,{permissions:t})},async getPermissions(e){return R.get("/permissions",{entity_id:e})}};function oF(e){var u,f;const{user:t}=Ga(),r=(f=(u=t==null?void 0:t.entities)==null?void 0:u[0])==null?void 0:f.id,{data:s=[],isLoading:a}=ye({queryKey:["permissions",r],queryFn:()=>iF.getPermissions(r),enabled:!!r&&!!t,staleTime:10*60*1e3}),i=(t==null?void 0:t.user_type)==="admin"||(t==null?void 0:t.user_type)==="developer",o=(t==null?void 0:t.user_type)==="developer";return{permissions:s,isLoading:a,hasPermission:h=>i?!0:s.includes(h),hasAnyPermission:h=>i?!0:h.some(m=>s.includes(m)),hasAllPermissions:h=>i?!0:h.every(m=>s.includes(m)),isAdmin:i,isDeveloper:o}}function dO(e){switch(e){case"student":return"/student/dashboard";case"teacher":return"/teacher/dashboard";case"admin":case"developer":return"/admin/dashboard";case"corporate":case"mastercorporate":case"agent":return"/admin/platform";default:return"/login"}}function ag({allowedRoles:e,requiredPermissions:t}){const{user:r,isAuthenticated:s,isLoading:a}=Ga(),{hasAllPermissions:i,isLoading:o}=oF();if(a)return n.jsx("div",{className:"min-h-screen flex items-center justify-center",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});if(!s||!r)return n.jsx(jl,{to:"/login",replace:!0});if(e&&!e.includes(r.user_type))return n.jsx(jl,{to:dO(r.user_type),replace:!0});if(t&&t.length>0){if(o)return n.jsx("div",{className:"min-h-screen flex items-center justify-center",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});if(!i(t))return n.jsx(jl,{to:dO(r.user_type),replace:!0})}return n.jsx(Dk,{})}var GZ=Symbol.for("react.lazy"),Tv=ij[" use ".trim().toString()];function HZ(e){return typeof e=="object"&&e!==null&&"then"in e}function lF(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===GZ&&"_payload"in e&&HZ(e._payload)}function ex(e){const t=QZ(e),r=p.forwardRef((s,a)=>{let{children:i,...o}=s;lF(i)&&typeof Tv=="function"&&(i=Tv(i._payload));const l=p.Children.toArray(i),c=l.find(XZ);if(c){const d=c.props.children,u=l.map(f=>f===c?p.Children.count(d)>1?p.Children.only(null):p.isValidElement(d)?d.props.children:null:f);return n.jsx(t,{...o,ref:a,children:p.isValidElement(d)?p.cloneElement(d,void 0,u):null})}return n.jsx(t,{...o,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}var Bl=ex("Slot");function QZ(e){const t=p.forwardRef((r,s)=>{let{children:a,...i}=r;if(lF(a)&&typeof Tv=="function"&&(a=Tv(a._payload)),p.isValidElement(a)){const o=JZ(a),l=ZZ(i,a.props);return a.type!==p.Fragment&&(l.ref=s?Ni(s,o):o),p.cloneElement(a,l)}return p.Children.count(a)>1?p.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var YZ=Symbol("radix.slottable");function XZ(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===YZ}function ZZ(e,t){const r={...t};for(const s in t){const a=e[s],i=t[s];/^on[A-Z]/.test(s)?a&&i?r[s]=(...l)=>{const c=i(...l);return a(...l),c}:a&&(r[s]=a):s==="style"?r[s]={...a,...i}:s==="className"&&(r[s]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function JZ(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}const pw=768;function eJ(){const[e,t]=p.useState(void 0);return p.useEffect(()=>{const r=window.matchMedia(`(max-width: ${pw-1}px)`),s=()=>{t(window.innerWidthr.removeEventListener("change",s)},[]),!!e}const sS=pd("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),E=p.forwardRef(({className:e,variant:t,size:r,asChild:s=!1,...a},i)=>{const o=s?Bl:"button";return n.jsx(o,{className:he(sS({variant:t,size:r,className:e})),ref:i,...a})});E.displayName="Button";const G=p.forwardRef(({className:e,type:t,...r},s)=>n.jsx("input",{type:t,className:he("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:s,...r}));G.displayName="Input";var tJ=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],nJ=tJ.reduce((e,t)=>{const r=ex(`Primitive.${t}`),s=p.forwardRef((a,i)=>{const{asChild:o,...l}=a,c=o?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(c,{...l,ref:i})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),rJ="Separator",uO="horizontal",sJ=["horizontal","vertical"],cF=p.forwardRef((e,t)=>{const{decorative:r,orientation:s=uO,...a}=e,i=aJ(s)?s:uO,l=r?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return n.jsx(nJ.div,{"data-orientation":i,...l,...a,ref:t})});cF.displayName=rJ;function aJ(e){return sJ.includes(e)}var dF=cF;const qs=p.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...s},a)=>n.jsx(dF,{ref:a,decorative:r,orientation:t,className:he("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...s}));qs.displayName=dF.displayName;var xw="focusScope.autoFocusOnMount",gw="focusScope.autoFocusOnUnmount",fO={bubbles:!1,cancelable:!0},iJ="FocusScope",tx=p.forwardRef((e,t)=>{const{loop:r=!1,trapped:s=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=e,[l,c]=p.useState(null),d=Dn(a),u=Dn(i),f=p.useRef(null),h=dt(t,x=>c(x)),m=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(s){let x=function(b){if(m.paused||!l)return;const N=b.target;l.contains(N)?f.current=N:Fo(f.current,{select:!0})},j=function(b){if(m.paused||!l)return;const N=b.relatedTarget;N!==null&&(l.contains(N)||Fo(f.current,{select:!0}))},v=function(b){if(document.activeElement===document.body)for(const w of b)w.removedNodes.length>0&&Fo(l)};document.addEventListener("focusin",x),document.addEventListener("focusout",j);const g=new MutationObserver(v);return l&&g.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",j),g.disconnect()}}},[s,l,m.paused]),p.useEffect(()=>{if(l){hO.add(m);const x=document.activeElement;if(!l.contains(x)){const v=new CustomEvent(xw,fO);l.addEventListener(xw,d),l.dispatchEvent(v),v.defaultPrevented||(oJ(fJ(uF(l)),{select:!0}),document.activeElement===x&&Fo(l))}return()=>{l.removeEventListener(xw,d),setTimeout(()=>{const v=new CustomEvent(gw,fO);l.addEventListener(gw,u),l.dispatchEvent(v),v.defaultPrevented||Fo(x??document.body,{select:!0}),l.removeEventListener(gw,u),hO.remove(m)},0)}}},[l,d,u,m]);const y=p.useCallback(x=>{if(!r&&!s||m.paused)return;const j=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,v=document.activeElement;if(j&&v){const g=x.currentTarget,[b,N]=lJ(g);b&&N?!x.shiftKey&&v===N?(x.preventDefault(),r&&Fo(b,{select:!0})):x.shiftKey&&v===b&&(x.preventDefault(),r&&Fo(N,{select:!0})):v===g&&x.preventDefault()}},[r,s,m.paused]);return n.jsx(We.div,{tabIndex:-1,...o,ref:h,onKeyDown:y})});tx.displayName=iJ;function oJ(e,{select:t=!1}={}){const r=document.activeElement;for(const s of e)if(Fo(s,{select:t}),document.activeElement!==r)return}function lJ(e){const t=uF(e),r=mO(t,e),s=mO(t.reverse(),e);return[r,s]}function uF(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const a=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||a?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function mO(e,t){for(const r of e)if(!cJ(r,{upTo:t}))return r}function cJ(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function dJ(e){return e instanceof HTMLInputElement&&"select"in e}function Fo(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&dJ(e)&&t&&e.select()}}var hO=uJ();function uJ(){let e=[];return{add(t){const r=e[0];t!==r&&(r==null||r.pause()),e=pO(e,t),e.unshift(t)},remove(t){var r;e=pO(e,t),(r=e[0])==null||r.resume()}}}function pO(e,t){const r=[...e],s=r.indexOf(t);return s!==-1&&r.splice(s,1),r}function fJ(e){return e.filter(t=>t.tagName!=="A")}var vw=0;function Uj(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??xO()),document.body.insertAdjacentElement("beforeend",e[1]??xO()),vw++,()=>{vw===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),vw--}},[])}function xO(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var ai=function(){return ai=Object.assign||function(t){for(var r,s=1,a=arguments.length;s"u")return AJ;var t=EJ(e),r=document.documentElement.clientWidth,s=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,s-r+t[2]-t[0])}},TJ=pF(),bu="data-scroll-locked",MJ=function(e,t,r,s){var a=e.left,i=e.top,o=e.right,l=e.gap;return r===void 0&&(r="margin"),` .`.concat(hJ,` { overflow: hidden `).concat(s,`; padding-right: `).concat(l,"px ").concat(s,`; } body[`).concat(bu,`] { overflow: hidden `).concat(s,`; overscroll-behavior: contain; `).concat([t&&"position: relative ".concat(s,";"),r==="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(l,"px ").concat(s,`; `),r==="padding"&&"padding-right: ".concat(l,"px ").concat(s,";")].filter(Boolean).join(""),` } .`).concat(Hg,` { right: `).concat(l,"px ").concat(s,`; } .`).concat(Qg,` { margin-right: `).concat(l,"px ").concat(s,`; } .`).concat(Hg," .").concat(Hg,` { right: 0 `).concat(s,`; } .`).concat(Qg," .").concat(Qg,` { margin-right: 0 `).concat(s,`; } body[`).concat(bu,`] { `).concat(pJ,": ").concat(l,`px; } `)},vO=function(){var e=parseInt(document.body.getAttribute(bu)||"0",10);return isFinite(e)?e:0},RJ=function(){p.useEffect(function(){return document.body.setAttribute(bu,(vO()+1).toString()),function(){var e=vO()-1;e<=0?document.body.removeAttribute(bu):document.body.setAttribute(bu,e.toString())}},[])},$J=function(e){var t=e.noRelative,r=e.noImportant,s=e.gapMode,a=s===void 0?"margin":s;RJ();var i=p.useMemo(function(){return OJ(a)},[a]);return p.createElement(TJ,{styles:MJ(i,!t,a,r?"":"!important")})},aS=!1;if(typeof window<"u")try{var ig=Object.defineProperty({},"passive",{get:function(){return aS=!0,!0}});window.addEventListener("test",ig,ig),window.removeEventListener("test",ig,ig)}catch{aS=!1}var Id=aS?{passive:!1}:!1,IJ=function(e){return e.tagName==="TEXTAREA"},xF=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!IJ(e)&&r[t]==="visible")},DJ=function(e){return xF(e,"overflowY")},LJ=function(e){return xF(e,"overflowX")},yO=function(e,t){var r=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var a=gF(e,s);if(a){var i=vF(e,s),o=i[1],l=i[2];if(o>l)return!0}s=s.parentNode}while(s&&s!==r.body);return!1},FJ=function(e){var t=e.scrollTop,r=e.scrollHeight,s=e.clientHeight;return[t,r,s]},BJ=function(e){var t=e.scrollLeft,r=e.scrollWidth,s=e.clientWidth;return[t,r,s]},gF=function(e,t){return e==="v"?DJ(t):LJ(t)},vF=function(e,t){return e==="v"?FJ(t):BJ(t)},zJ=function(e,t){return e==="h"&&t==="rtl"?-1:1},VJ=function(e,t,r,s,a){var i=zJ(e,window.getComputedStyle(t).direction),o=i*s,l=r.target,c=t.contains(l),d=!1,u=o>0,f=0,h=0;do{if(!l)break;var m=vF(e,l),y=m[0],x=m[1],j=m[2],v=x-j-i*y;(y||v)&&gF(e,l)&&(f+=v,h+=y);var g=l.parentNode;l=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(u&&Math.abs(f)<1||!u&&Math.abs(h)<1)&&(d=!0),d},og=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},jO=function(e){return[e.deltaX,e.deltaY]},bO=function(e){return e&&"current"in e?e.current:e},qJ=function(e,t){return e[0]===t[0]&&e[1]===t[1]},WJ=function(e){return` .block-interactivity-`.concat(e,` {pointer-events: none;} .allow-interactivity-`).concat(e,` {pointer-events: all;} `)},UJ=0,Dd=[];function KJ(e){var t=p.useRef([]),r=p.useRef([0,0]),s=p.useRef(),a=p.useState(UJ++)[0],i=p.useState(pF)[0],o=p.useRef(e);p.useEffect(function(){o.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var x=mJ([e.lockRef.current],(e.shards||[]).map(bO),!0).filter(Boolean);return x.forEach(function(j){return j.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),x.forEach(function(j){return j.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var l=p.useCallback(function(x,j){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!o.current.allowPinchZoom;var v=og(x),g=r.current,b="deltaX"in x?x.deltaX:g[0]-v[0],N="deltaY"in x?x.deltaY:g[1]-v[1],w,S=x.target,_=Math.abs(b)>Math.abs(N)?"h":"v";if("touches"in x&&_==="h"&&S.type==="range")return!1;var C=window.getSelection(),P=C&&C.anchorNode,D=P?P===S||P.contains(S):!1;if(D)return!1;var z=yO(_,S);if(!z)return!0;if(z?w=_:(w=_==="v"?"h":"v",z=yO(_,S)),!z)return!1;if(!s.current&&"changedTouches"in x&&(b||N)&&(s.current=w),!w)return!0;var O=s.current||w;return VJ(O,j,x,O==="h"?b:N)},[]),c=p.useCallback(function(x){var j=x;if(!(!Dd.length||Dd[Dd.length-1]!==i)){var v="deltaY"in j?jO(j):og(j),g=t.current.filter(function(w){return w.name===j.type&&(w.target===j.target||j.target===w.shadowParent)&&qJ(w.delta,v)})[0];if(g&&g.should){j.cancelable&&j.preventDefault();return}if(!g){var b=(o.current.shards||[]).map(bO).filter(Boolean).filter(function(w){return w.contains(j.target)}),N=b.length>0?l(j,b[0]):!o.current.noIsolation;N&&j.cancelable&&j.preventDefault()}}},[]),d=p.useCallback(function(x,j,v,g){var b={name:x,delta:j,target:v,should:g,shadowParent:GJ(v)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(N){return N!==b})},1)},[]),u=p.useCallback(function(x){r.current=og(x),s.current=void 0},[]),f=p.useCallback(function(x){d(x.type,jO(x),x.target,l(x,e.lockRef.current))},[]),h=p.useCallback(function(x){d(x.type,og(x),x.target,l(x,e.lockRef.current))},[]);p.useEffect(function(){return Dd.push(i),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",c,Id),document.addEventListener("touchmove",c,Id),document.addEventListener("touchstart",u,Id),function(){Dd=Dd.filter(function(x){return x!==i}),document.removeEventListener("wheel",c,Id),document.removeEventListener("touchmove",c,Id),document.removeEventListener("touchstart",u,Id)}},[]);var m=e.removeScrollBar,y=e.inert;return p.createElement(p.Fragment,null,y?p.createElement(i,{styles:WJ(a)}):null,m?p.createElement($J,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function GJ(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const HJ=wJ(hF,KJ);var nx=p.forwardRef(function(e,t){return p.createElement(Kj,ai({},e,{ref:t,sideCar:HJ}))});nx.classNames=Kj.classNames;var QJ=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ld=new WeakMap,lg=new WeakMap,cg={},ww=0,yF=function(e){return e&&(e.host||yF(e.parentNode))},YJ=function(e,t){return t.map(function(r){if(e.contains(r))return r;var s=yF(r);return s&&e.contains(s)?s:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},XJ=function(e,t,r,s){var a=YJ(t,Array.isArray(e)?e:[e]);cg[r]||(cg[r]=new WeakMap);var i=cg[r],o=[],l=new Set,c=new Set(a),d=function(f){!f||l.has(f)||(l.add(f),d(f.parentNode))};a.forEach(d);var u=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(h){if(l.has(h))u(h);else try{var m=h.getAttribute(s),y=m!==null&&m!=="false",x=(Ld.get(h)||0)+1,j=(i.get(h)||0)+1;Ld.set(h,x),i.set(h,j),o.push(h),x===1&&y&&lg.set(h,!0),j===1&&h.setAttribute(r,"true"),y||h.setAttribute(s,"true")}catch(v){console.error("aria-hidden: cannot operate on ",h,v)}})};return u(t),l.clear(),ww++,function(){o.forEach(function(f){var h=Ld.get(f)-1,m=i.get(f)-1;Ld.set(f,h),i.set(f,m),h||(lg.has(f)||f.removeAttribute(s),lg.delete(f)),m||f.removeAttribute(r)}),ww--,ww||(Ld=new WeakMap,Ld=new WeakMap,lg=new WeakMap,cg={})}},Gj=function(e,t,r){r===void 0&&(r="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),a=QJ(e);return a?(s.push.apply(s,Array.from(a.querySelectorAll("[aria-live], script"))),XJ(s,a,r,"aria-hidden")):function(){return null}};function ZJ(e){const t=JJ(e),r=p.forwardRef((s,a)=>{const{children:i,...o}=s,l=p.Children.toArray(i),c=l.find(tee);if(c){const d=c.props.children,u=l.map(f=>f===c?p.Children.count(d)>1?p.Children.only(null):p.isValidElement(d)?d.props.children:null:f);return n.jsx(t,{...o,ref:a,children:p.isValidElement(d)?p.cloneElement(d,void 0,u):null})}return n.jsx(t,{...o,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function JJ(e){const t=p.forwardRef((r,s)=>{const{children:a,...i}=r;if(p.isValidElement(a)){const o=ree(a),l=nee(i,a.props);return a.type!==p.Fragment&&(l.ref=s?Ni(s,o):o),p.cloneElement(a,l)}return p.Children.count(a)>1?p.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var eee=Symbol("radix.slottable");function tee(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===eee}function nee(e,t){const r={...t};for(const s in t){const a=e[s],i=t[s];/^on[A-Z]/.test(s)?a&&i?r[s]=(...l)=>{const c=i(...l);return a(...l),c}:a&&(r[s]=a):s==="style"?r[s]={...a,...i}:s==="className"&&(r[s]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function ree(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Hj="Dialog",[jF]=lr(Hj),[see,Ha]=jF(Hj),bF=e=>{const{__scopeDialog:t,children:r,open:s,defaultOpen:a,onOpenChange:i,modal:o=!0}=e,l=p.useRef(null),c=p.useRef(null),[d,u]=zr({prop:s,defaultProp:a??!1,onChange:i,caller:Hj});return n.jsx(see,{scope:t,triggerRef:l,contentRef:c,contentId:ys(),titleId:ys(),descriptionId:ys(),open:d,onOpenChange:u,onOpenToggle:p.useCallback(()=>u(f=>!f),[u]),modal:o,children:r})};bF.displayName=Hj;var wF="DialogTrigger",NF=p.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,a=Ha(wF,r),i=dt(t,a.triggerRef);return n.jsx(We.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":Vk(a.open),...s,ref:i,onClick:be(e.onClick,a.onOpenToggle)})});NF.displayName=wF;var Bk="DialogPortal",[aee,SF]=jF(Bk,{forceMount:void 0}),_F=e=>{const{__scopeDialog:t,forceMount:r,children:s,container:a}=e,i=Ha(Bk,t);return n.jsx(aee,{scope:t,forceMount:r,children:p.Children.map(s,o=>n.jsx(Jn,{present:r||i.open,children:n.jsx(Lf,{asChild:!0,container:a,children:o})}))})};_F.displayName=Bk;var Mv="DialogOverlay",CF=p.forwardRef((e,t)=>{const r=SF(Mv,e.__scopeDialog),{forceMount:s=r.forceMount,...a}=e,i=Ha(Mv,e.__scopeDialog);return i.modal?n.jsx(Jn,{present:s||i.open,children:n.jsx(oee,{...a,ref:t})}):null});CF.displayName=Mv;var iee=ZJ("DialogOverlay.RemoveScroll"),oee=p.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,a=Ha(Mv,r);return n.jsx(nx,{as:iee,allowPinchZoom:!0,shards:[a.contentRef],children:n.jsx(We.div,{"data-state":Vk(a.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),Hc="DialogContent",kF=p.forwardRef((e,t)=>{const r=SF(Hc,e.__scopeDialog),{forceMount:s=r.forceMount,...a}=e,i=Ha(Hc,e.__scopeDialog);return n.jsx(Jn,{present:s||i.open,children:i.modal?n.jsx(lee,{...a,ref:t}):n.jsx(cee,{...a,ref:t})})});kF.displayName=Hc;var lee=p.forwardRef((e,t)=>{const r=Ha(Hc,e.__scopeDialog),s=p.useRef(null),a=dt(t,r.contentRef,s);return p.useEffect(()=>{const i=s.current;if(i)return Gj(i)},[]),n.jsx(PF,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:be(e.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=r.triggerRef.current)==null||o.focus()}),onPointerDownOutside:be(e.onPointerDownOutside,i=>{const o=i.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0;(o.button===2||l)&&i.preventDefault()}),onFocusOutside:be(e.onFocusOutside,i=>i.preventDefault())})}),cee=p.forwardRef((e,t)=>{const r=Ha(Hc,e.__scopeDialog),s=p.useRef(!1),a=p.useRef(!1);return n.jsx(PF,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,l;(o=e.onCloseAutoFocus)==null||o.call(e,i),i.defaultPrevented||(s.current||(l=r.triggerRef.current)==null||l.focus(),i.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:i=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,i),i.defaultPrevented||(s.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((d=r.triggerRef.current)==null?void 0:d.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),PF=p.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=e,l=Ha(Hc,r),c=p.useRef(null),d=dt(t,c);return Uj(),n.jsxs(n.Fragment,{children:[n.jsx(tx,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:i,children:n.jsx(hd,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Vk(l.open),...o,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),n.jsxs(n.Fragment,{children:[n.jsx(dee,{titleId:l.titleId}),n.jsx(fee,{contentRef:c,descriptionId:l.descriptionId})]})]})}),zk="DialogTitle",AF=p.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,a=Ha(zk,r);return n.jsx(We.h2,{id:a.titleId,...s,ref:t})});AF.displayName=zk;var EF="DialogDescription",OF=p.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,a=Ha(EF,r);return n.jsx(We.p,{id:a.descriptionId,...s,ref:t})});OF.displayName=EF;var TF="DialogClose",MF=p.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,a=Ha(TF,r);return n.jsx(We.button,{type:"button",...s,ref:t,onClick:be(e.onClick,()=>a.onOpenChange(!1))})});MF.displayName=TF;function Vk(e){return e?"open":"closed"}var RF="DialogTitleWarning",[U5e,$F]=SK(RF,{contentName:Hc,titleName:zk,docsSlug:"dialog"}),dee=({titleId:e})=>{const t=$F(RF),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component. For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return p.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},uee="DialogDescriptionWarning",fee=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${$F(uee).contentName}}.`;return p.useEffect(()=>{var i;const a=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},IF=bF,mee=NF,DF=_F,Qj=CF,Yj=kF,Xj=AF,Zj=OF,LF=MF;const Jj=IF,hee=DF,FF=p.forwardRef(({className:e,...t},r)=>n.jsx(Qj,{className:he("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:r}));FF.displayName=Qj.displayName;const pee=pd("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),rx=p.forwardRef(({side:e="right",className:t,children:r,...s},a)=>n.jsxs(hee,{children:[n.jsx(FF,{}),n.jsxs(Yj,{ref:a,className:he(pee({side:e}),t),...s,children:[r,n.jsxs(LF,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[n.jsx(ts,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));rx.displayName=Yj.displayName;const eb=({className:e,...t})=>n.jsx("div",{className:he("flex flex-col space-y-2 text-center sm:text-left",e),...t});eb.displayName="SheetHeader";const tb=p.forwardRef(({className:e,...t},r)=>n.jsx(Xj,{ref:r,className:he("text-lg font-semibold text-foreground",e),...t}));tb.displayName=Xj.displayName;const xee=p.forwardRef(({className:e,...t},r)=>n.jsx(Zj,{ref:r,className:he("text-sm text-muted-foreground",e),...t}));xee.displayName=Zj.displayName;function Wt({className:e,...t}){return n.jsx("div",{className:he("animate-pulse rounded-md bg-muted",e),...t})}const gee="sidebar:state",vee=60*60*24*7,yee="16rem",jee="18rem",bee="3rem",wee="b",BF=p.createContext(null);function jd(){const e=p.useContext(BF);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const qk=p.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:r,className:s,style:a,children:i,...o},l)=>{const c=eJ(),[d,u]=p.useState(!1),[f,h]=p.useState(e),m=t??f,y=p.useCallback(g=>{const b=typeof g=="function"?g(m):g;r?r(b):h(b),document.cookie=`${gee}=${b}; path=/; max-age=${vee}`},[r,m]),x=p.useCallback(()=>c?u(g=>!g):y(g=>!g),[c,y,u]);p.useEffect(()=>{const g=b=>{b.key===wee&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),x())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[x]);const j=m?"expanded":"collapsed",v=p.useMemo(()=>({state:j,open:m,setOpen:y,isMobile:c,openMobile:d,setOpenMobile:u,toggleSidebar:x}),[j,m,y,c,d,u,x]);return n.jsx(BF.Provider,{value:v,children:n.jsx(I3,{delayDuration:0,children:n.jsx("div",{style:{"--sidebar-width":yee,"--sidebar-width-icon":bee,...a},className:he("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",s),ref:l,...o,children:i})})})});qk.displayName="SidebarProvider";const Wk=p.forwardRef(({side:e="left",variant:t="sidebar",collapsible:r="offcanvas",className:s,children:a,...i},o)=>{const{isMobile:l,state:c,openMobile:d,setOpenMobile:u}=jd();return r==="none"?n.jsx("div",{className:he("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",s),ref:o,...i,children:a}):l?n.jsx(Jj,{open:d,onOpenChange:u,...i,children:n.jsx(rx,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":jee},side:e,children:n.jsx("div",{className:"flex h-full w-full flex-col",children:a})})}):n.jsxs("div",{ref:o,className:"group peer hidden text-sidebar-foreground md:block","data-state":c,"data-collapsible":c==="collapsed"?r:"","data-variant":t,"data-side":e,children:[n.jsx("div",{className:he("relative h-svh w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),n.jsx("div",{className:he("fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",s),...i,children:n.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",children:a})})]})});Wk.displayName="Sidebar";const Uk=p.forwardRef(({className:e,onClick:t,...r},s)=>{const{toggleSidebar:a}=jd();return n.jsxs(E,{ref:s,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:he("h-7 w-7",e),onClick:i=>{t==null||t(i),a()},...r,children:[n.jsx(QG,{}),n.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Uk.displayName="SidebarTrigger";const Nee=p.forwardRef(({className:e,...t},r)=>{const{toggleSidebar:s}=jd();return n.jsx("button",{ref:r,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:s,title:"Toggle Sidebar",className:he("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] group-data-[side=left]:-right-4 group-data-[side=right]:left-0 hover:after:bg-sidebar-border sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});Nee.displayName="SidebarRail";const See=p.forwardRef(({className:e,...t},r)=>n.jsx("main",{ref:r,className:he("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),...t}));See.displayName="SidebarInset";const _ee=p.forwardRef(({className:e,...t},r)=>n.jsx(G,{ref:r,"data-sidebar":"input",className:he("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));_ee.displayName="SidebarInput";const Kk=p.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,"data-sidebar":"header",className:he("flex flex-col gap-2 p-2",e),...t}));Kk.displayName="SidebarHeader";const Gk=p.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,"data-sidebar":"footer",className:he("flex flex-col gap-2 p-2",e),...t}));Gk.displayName="SidebarFooter";const Gh=p.forwardRef(({className:e,...t},r)=>n.jsx(qs,{ref:r,"data-sidebar":"separator",className:he("mx-2 w-auto bg-sidebar-border",e),...t}));Gh.displayName="SidebarSeparator";const Hk=p.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,"data-sidebar":"content",className:he("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Hk.displayName="SidebarContent";const nb=p.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,"data-sidebar":"group",className:he("relative flex w-full min-w-0 flex-col p-2",e),...t}));nb.displayName="SidebarGroup";const rb=p.forwardRef(({className:e,asChild:t=!1,...r},s)=>{const a=t?Bl:"div";return n.jsx(a,{ref:s,"data-sidebar":"group-label",className:he("flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...r})});rb.displayName="SidebarGroupLabel";const Cee=p.forwardRef(({className:e,asChild:t=!1,...r},s)=>{const a=t?Bl:"button";return n.jsx(a,{ref:s,"data-sidebar":"group-action",className:he("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...r})});Cee.displayName="SidebarGroupAction";const sb=p.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,"data-sidebar":"group-content",className:he("w-full text-sm",e),...t}));sb.displayName="SidebarGroupContent";const ab=p.forwardRef(({className:e,...t},r)=>n.jsx("ul",{ref:r,"data-sidebar":"menu",className:he("flex w-full min-w-0 flex-col gap-1",e),...t}));ab.displayName="SidebarMenu";const ib=p.forwardRef(({className:e,...t},r)=>n.jsx("li",{ref:r,"data-sidebar":"menu-item",className:he("group/menu-item relative",e),...t}));ib.displayName="SidebarMenuItem";const kee=pd("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),ob=p.forwardRef(({asChild:e=!1,isActive:t=!1,variant:r="default",size:s="default",tooltip:a,className:i,...o},l)=>{const c=e?Bl:"button",{isMobile:d,state:u}=jd(),f=n.jsx(c,{ref:l,"data-sidebar":"menu-button","data-size":s,"data-active":t,className:he(kee({variant:r,size:s}),i),...o});return a?(typeof a=="string"&&(a={children:a}),n.jsxs(uo,{children:[n.jsx(fo,{asChild:!0,children:f}),n.jsx(vi,{side:"right",align:"center",hidden:u!=="collapsed"||d,...a})]})):f});ob.displayName="SidebarMenuButton";const Pee=p.forwardRef(({className:e,asChild:t=!1,showOnHover:r=!1,...s},a)=>{const i=t?Bl:"button";return n.jsx(i,{ref:a,"data-sidebar":"menu-action",className:he("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform peer-hover/menu-button:text-sidebar-accent-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",r&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",e),...s})});Pee.displayName="SidebarMenuAction";const Aee=p.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,"data-sidebar":"menu-badge",className:he("pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));Aee.displayName="SidebarMenuBadge";const Eee=p.forwardRef(({className:e,showIcon:t=!1,...r},s)=>{const a=p.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return n.jsxs("div",{ref:s,"data-sidebar":"menu-skeleton",className:he("flex h-8 items-center gap-2 rounded-md px-2",e),...r,children:[t&&n.jsx(Wt,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),n.jsx(Wt,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":a}})]})});Eee.displayName="SidebarMenuSkeleton";const Oee=p.forwardRef(({className:e,...t},r)=>n.jsx("ul",{ref:r,"data-sidebar":"menu-sub",className:he("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));Oee.displayName="SidebarMenuSub";const Tee=p.forwardRef(({...e},t)=>n.jsx("li",{ref:t,...e}));Tee.displayName="SidebarMenuSubItem";const Mee=p.forwardRef(({asChild:e=!1,size:t="md",isActive:r,className:s,...a},i)=>{const o=e?Bl:"a";return n.jsx(o,{ref:i,"data-sidebar":"menu-sub-button","data-size":t,"data-active":r,className:he("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",s),...a})});Mee.displayName="SidebarMenuSubButton";const lb=p.forwardRef(({className:e,activeClassName:t,pendingClassName:r,to:s,...a},i)=>n.jsx(FZ,{ref:i,to:s,className:({isActive:o,isPending:l})=>he(e,o&&t,l&&r),...a}));lb.displayName="NavLink";var Ree=p.createContext(void 0);function zl(e){const t=p.useContext(Ree);return e||t||"ltr"}var Nw="rovingFocusGroup.onEntryFocus",$ee={bubbles:!1,cancelable:!0},sx="RovingFocusGroup",[iS,zF,Iee]=Df(sx),[Dee,Hf]=lr(sx,[Iee]),[Lee,Fee]=Dee(sx),VF=p.forwardRef((e,t)=>n.jsx(iS.Provider,{scope:e.__scopeRovingFocusGroup,children:n.jsx(iS.Slot,{scope:e.__scopeRovingFocusGroup,children:n.jsx(Bee,{...e,ref:t})})}));VF.displayName=sx;var Bee=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:s,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:u=!1,...f}=e,h=p.useRef(null),m=dt(t,h),y=zl(i),[x,j]=zr({prop:o,defaultProp:l??null,onChange:c,caller:sx}),[v,g]=p.useState(!1),b=Dn(d),N=zF(r),w=p.useRef(!1),[S,_]=p.useState(0);return p.useEffect(()=>{const C=h.current;if(C)return C.addEventListener(Nw,b),()=>C.removeEventListener(Nw,b)},[b]),n.jsx(Lee,{scope:r,orientation:s,dir:y,loop:a,currentTabStopId:x,onItemFocus:p.useCallback(C=>j(C),[j]),onItemShiftTab:p.useCallback(()=>g(!0),[]),onFocusableItemAdd:p.useCallback(()=>_(C=>C+1),[]),onFocusableItemRemove:p.useCallback(()=>_(C=>C-1),[]),children:n.jsx(We.div,{tabIndex:v||S===0?-1:0,"data-orientation":s,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:be(e.onMouseDown,()=>{w.current=!0}),onFocus:be(e.onFocus,C=>{const P=!w.current;if(C.target===C.currentTarget&&P&&!v){const D=new CustomEvent(Nw,$ee);if(C.currentTarget.dispatchEvent(D),!D.defaultPrevented){const z=N().filter(B=>B.focusable),O=z.find(B=>B.active),V=z.find(B=>B.id===x),$=[O,V,...z].filter(Boolean).map(B=>B.ref.current);UF($,u)}}w.current=!1}),onBlur:be(e.onBlur,()=>g(!1))})})}),qF="RovingFocusGroupItem",WF=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:s=!0,active:a=!1,tabStopId:i,children:o,...l}=e,c=ys(),d=i||c,u=Fee(qF,r),f=u.currentTabStopId===d,h=zF(r),{onFocusableItemAdd:m,onFocusableItemRemove:y,currentTabStopId:x}=u;return p.useEffect(()=>{if(s)return m(),()=>y()},[s,m,y]),n.jsx(iS.ItemSlot,{scope:r,id:d,focusable:s,active:a,children:n.jsx(We.span,{tabIndex:f?0:-1,"data-orientation":u.orientation,...l,ref:t,onMouseDown:be(e.onMouseDown,j=>{s?u.onItemFocus(d):j.preventDefault()}),onFocus:be(e.onFocus,()=>u.onItemFocus(d)),onKeyDown:be(e.onKeyDown,j=>{if(j.key==="Tab"&&j.shiftKey){u.onItemShiftTab();return}if(j.target!==j.currentTarget)return;const v=qee(j,u.orientation,u.dir);if(v!==void 0){if(j.metaKey||j.ctrlKey||j.altKey||j.shiftKey)return;j.preventDefault();let b=h().filter(N=>N.focusable).map(N=>N.ref.current);if(v==="last")b.reverse();else if(v==="prev"||v==="next"){v==="prev"&&b.reverse();const N=b.indexOf(j.currentTarget);b=u.loop?Wee(b,N+1):b.slice(N+1)}setTimeout(()=>UF(b))}}),children:typeof o=="function"?o({isCurrentTabStop:f,hasTabStop:x!=null}):o})})});WF.displayName=qF;var zee={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Vee(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function qee(e,t,r){const s=Vee(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return zee[s]}function UF(e,t=!1){const r=document.activeElement;for(const s of e)if(s===r||(s.focus({preventScroll:t}),document.activeElement!==r))return}function Wee(e,t){return e.map((r,s)=>e[(t+s)%e.length])}var Qk=VF,Yk=WF;function Uee(e){const t=Kee(e),r=p.forwardRef((s,a)=>{const{children:i,...o}=s,l=p.Children.toArray(i),c=l.find(Hee);if(c){const d=c.props.children,u=l.map(f=>f===c?p.Children.count(d)>1?p.Children.only(null):p.isValidElement(d)?d.props.children:null:f);return n.jsx(t,{...o,ref:a,children:p.isValidElement(d)?p.cloneElement(d,void 0,u):null})}return n.jsx(t,{...o,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function Kee(e){const t=p.forwardRef((r,s)=>{const{children:a,...i}=r;if(p.isValidElement(a)){const o=Yee(a),l=Qee(i,a.props);return a.type!==p.Fragment&&(l.ref=s?Ni(s,o):o),p.cloneElement(a,l)}return p.Children.count(a)>1?p.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Gee=Symbol("radix.slottable");function Hee(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Gee}function Qee(e,t){const r={...t};for(const s in t){const a=e[s],i=t[s];/^on[A-Z]/.test(s)?a&&i?r[s]=(...l)=>{const c=i(...l);return a(...l),c}:a&&(r[s]=a):s==="style"?r[s]={...a,...i}:s==="className"&&(r[s]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function Yee(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var oS=["Enter"," "],Xee=["ArrowDown","PageUp","Home"],KF=["ArrowUp","PageDown","End"],Zee=[...Xee,...KF],Jee={ltr:[...oS,"ArrowRight"],rtl:[...oS,"ArrowLeft"]},ete={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ax="Menu",[Hh,tte,nte]=Df(ax),[bd,GF]=lr(ax,[nte,Fl,Hf]),cb=Fl(),HF=Hf(),[rte,wd]=bd(ax),[ste,ix]=bd(ax),QF=e=>{const{__scopeMenu:t,open:r=!1,children:s,dir:a,onOpenChange:i,modal:o=!0}=e,l=cb(t),[c,d]=p.useState(null),u=p.useRef(!1),f=Dn(i),h=zl(a);return p.useEffect(()=>{const m=()=>{u.current=!0,document.addEventListener("pointerdown",y,{capture:!0,once:!0}),document.addEventListener("pointermove",y,{capture:!0,once:!0})},y=()=>u.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",y,{capture:!0}),document.removeEventListener("pointermove",y,{capture:!0})}},[]),n.jsx($j,{...l,children:n.jsx(rte,{scope:t,open:r,onOpenChange:f,content:c,onContentChange:d,children:n.jsx(ste,{scope:t,onClose:p.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:u,dir:h,modal:o,children:s})})})};QF.displayName=ax;var ate="MenuAnchor",Xk=p.forwardRef((e,t)=>{const{__scopeMenu:r,...s}=e,a=cb(r);return n.jsx(Jp,{...a,...s,ref:t})});Xk.displayName=ate;var Zk="MenuPortal",[ite,YF]=bd(Zk,{forceMount:void 0}),XF=e=>{const{__scopeMenu:t,forceMount:r,children:s,container:a}=e,i=wd(Zk,t);return n.jsx(ite,{scope:t,forceMount:r,children:n.jsx(Jn,{present:r||i.open,children:n.jsx(Lf,{asChild:!0,container:a,children:s})})})};XF.displayName=Zk;var ia="MenuContent",[ote,Jk]=bd(ia),ZF=p.forwardRef((e,t)=>{const r=YF(ia,e.__scopeMenu),{forceMount:s=r.forceMount,...a}=e,i=wd(ia,e.__scopeMenu),o=ix(ia,e.__scopeMenu);return n.jsx(Hh.Provider,{scope:e.__scopeMenu,children:n.jsx(Jn,{present:s||i.open,children:n.jsx(Hh.Slot,{scope:e.__scopeMenu,children:o.modal?n.jsx(lte,{...a,ref:t}):n.jsx(cte,{...a,ref:t})})})})}),lte=p.forwardRef((e,t)=>{const r=wd(ia,e.__scopeMenu),s=p.useRef(null),a=dt(t,s);return p.useEffect(()=>{const i=s.current;if(i)return Gj(i)},[]),n.jsx(e2,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:be(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),cte=p.forwardRef((e,t)=>{const r=wd(ia,e.__scopeMenu);return n.jsx(e2,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),dte=Uee("MenuContent.ScrollLock"),e2=p.forwardRef((e,t)=>{const{__scopeMenu:r,loop:s=!1,trapFocus:a,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:h,onDismiss:m,disableOutsideScroll:y,...x}=e,j=wd(ia,r),v=ix(ia,r),g=cb(r),b=HF(r),N=tte(r),[w,S]=p.useState(null),_=p.useRef(null),C=dt(t,_,j.onContentChange),P=p.useRef(0),D=p.useRef(""),z=p.useRef(0),O=p.useRef(null),V=p.useRef("right"),A=p.useRef(0),$=y?nx:p.Fragment,B=y?{as:dte,allowPinchZoom:!0}:void 0,I=M=>{var ne,_e;const K=D.current+M,X=N().filter(ue=>!ue.disabled),re=document.activeElement,Z=(ne=X.find(ue=>ue.ref.current===re))==null?void 0:ne.textValue,te=X.map(ue=>ue.textValue),xe=wte(te,K,Z),me=(_e=X.find(ue=>ue.textValue===xe))==null?void 0:_e.ref.current;(function ue(we){D.current=we,window.clearTimeout(P.current),we!==""&&(P.current=window.setTimeout(()=>ue(""),1e3))})(K),me&&setTimeout(()=>me.focus())};p.useEffect(()=>()=>window.clearTimeout(P.current),[]),Uj();const k=p.useCallback(M=>{var X,re;return V.current===((X=O.current)==null?void 0:X.side)&&Ste(M,(re=O.current)==null?void 0:re.area)},[]);return n.jsx(ote,{scope:r,searchRef:D,onItemEnter:p.useCallback(M=>{k(M)&&M.preventDefault()},[k]),onItemLeave:p.useCallback(M=>{var K;k(M)||((K=_.current)==null||K.focus(),S(null))},[k]),onTriggerLeave:p.useCallback(M=>{k(M)&&M.preventDefault()},[k]),pointerGraceTimerRef:z,onPointerGraceIntentChange:p.useCallback(M=>{O.current=M},[]),children:n.jsx($,{...B,children:n.jsx(tx,{asChild:!0,trapped:a,onMountAutoFocus:be(i,M=>{var K;M.preventDefault(),(K=_.current)==null||K.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:n.jsx(hd,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:h,onDismiss:m,children:n.jsx(Qk,{asChild:!0,...b,dir:v.dir,orientation:"vertical",loop:s,currentTabStopId:w,onCurrentTabStopIdChange:S,onEntryFocus:be(c,M=>{v.isUsingKeyboardRef.current||M.preventDefault()}),preventScrollOnEntryFocus:!0,children:n.jsx(Ij,{role:"menu","aria-orientation":"vertical","data-state":h5(j.open),"data-radix-menu-content":"",dir:v.dir,...g,...x,ref:C,style:{outline:"none",...x.style},onKeyDown:be(x.onKeyDown,M=>{const X=M.target.closest("[data-radix-menu-content]")===M.currentTarget,re=M.ctrlKey||M.altKey||M.metaKey,Z=M.key.length===1;X&&(M.key==="Tab"&&M.preventDefault(),!re&&Z&&I(M.key));const te=_.current;if(M.target!==te||!Zee.includes(M.key))return;M.preventDefault();const me=N().filter(ne=>!ne.disabled).map(ne=>ne.ref.current);KF.includes(M.key)&&me.reverse(),jte(me)}),onBlur:be(e.onBlur,M=>{M.currentTarget.contains(M.target)||(window.clearTimeout(P.current),D.current="")}),onPointerMove:be(e.onPointerMove,Qh(M=>{const K=M.target,X=A.current!==M.clientX;if(M.currentTarget.contains(K)&&X){const re=M.clientX>A.current?"right":"left";V.current=re,A.current=M.clientX}}))})})})})})})});ZF.displayName=ia;var ute="MenuGroup",t2=p.forwardRef((e,t)=>{const{__scopeMenu:r,...s}=e;return n.jsx(We.div,{role:"group",...s,ref:t})});t2.displayName=ute;var fte="MenuLabel",JF=p.forwardRef((e,t)=>{const{__scopeMenu:r,...s}=e;return n.jsx(We.div,{...s,ref:t})});JF.displayName=fte;var Rv="MenuItem",wO="menu.itemSelect",db=p.forwardRef((e,t)=>{const{disabled:r=!1,onSelect:s,...a}=e,i=p.useRef(null),o=ix(Rv,e.__scopeMenu),l=Jk(Rv,e.__scopeMenu),c=dt(t,i),d=p.useRef(!1),u=()=>{const f=i.current;if(!r&&f){const h=new CustomEvent(wO,{bubbles:!0,cancelable:!0});f.addEventListener(wO,m=>s==null?void 0:s(m),{once:!0}),nk(f,h),h.defaultPrevented?d.current=!1:o.onClose()}};return n.jsx(e5,{...a,ref:c,disabled:r,onClick:be(e.onClick,u),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),d.current=!0},onPointerUp:be(e.onPointerUp,f=>{var h;d.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:be(e.onKeyDown,f=>{const h=l.searchRef.current!=="";r||h&&f.key===" "||oS.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});db.displayName=Rv;var e5=p.forwardRef((e,t)=>{const{__scopeMenu:r,disabled:s=!1,textValue:a,...i}=e,o=Jk(Rv,r),l=HF(r),c=p.useRef(null),d=dt(t,c),[u,f]=p.useState(!1),[h,m]=p.useState("");return p.useEffect(()=>{const y=c.current;y&&m((y.textContent??"").trim())},[i.children]),n.jsx(Hh.ItemSlot,{scope:r,disabled:s,textValue:a??h,children:n.jsx(Yk,{asChild:!0,...l,focusable:!s,children:n.jsx(We.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...i,ref:d,onPointerMove:be(e.onPointerMove,Qh(y=>{s?o.onItemLeave(y):(o.onItemEnter(y),y.defaultPrevented||y.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:be(e.onPointerLeave,Qh(y=>o.onItemLeave(y))),onFocus:be(e.onFocus,()=>f(!0)),onBlur:be(e.onBlur,()=>f(!1))})})})}),mte="MenuCheckboxItem",t5=p.forwardRef((e,t)=>{const{checked:r=!1,onCheckedChange:s,...a}=e;return n.jsx(i5,{scope:e.__scopeMenu,checked:r,children:n.jsx(db,{role:"menuitemcheckbox","aria-checked":$v(r)?"mixed":r,...a,ref:t,"data-state":r2(r),onSelect:be(a.onSelect,()=>s==null?void 0:s($v(r)?!0:!r),{checkForDefaultPrevented:!1})})})});t5.displayName=mte;var n5="MenuRadioGroup",[hte,pte]=bd(n5,{value:void 0,onValueChange:()=>{}}),r5=p.forwardRef((e,t)=>{const{value:r,onValueChange:s,...a}=e,i=Dn(s);return n.jsx(hte,{scope:e.__scopeMenu,value:r,onValueChange:i,children:n.jsx(t2,{...a,ref:t})})});r5.displayName=n5;var s5="MenuRadioItem",a5=p.forwardRef((e,t)=>{const{value:r,...s}=e,a=pte(s5,e.__scopeMenu),i=r===a.value;return n.jsx(i5,{scope:e.__scopeMenu,checked:i,children:n.jsx(db,{role:"menuitemradio","aria-checked":i,...s,ref:t,"data-state":r2(i),onSelect:be(s.onSelect,()=>{var o;return(o=a.onValueChange)==null?void 0:o.call(a,r)},{checkForDefaultPrevented:!1})})})});a5.displayName=s5;var n2="MenuItemIndicator",[i5,xte]=bd(n2,{checked:!1}),o5=p.forwardRef((e,t)=>{const{__scopeMenu:r,forceMount:s,...a}=e,i=xte(n2,r);return n.jsx(Jn,{present:s||$v(i.checked)||i.checked===!0,children:n.jsx(We.span,{...a,ref:t,"data-state":r2(i.checked)})})});o5.displayName=n2;var gte="MenuSeparator",l5=p.forwardRef((e,t)=>{const{__scopeMenu:r,...s}=e;return n.jsx(We.div,{role:"separator","aria-orientation":"horizontal",...s,ref:t})});l5.displayName=gte;var vte="MenuArrow",c5=p.forwardRef((e,t)=>{const{__scopeMenu:r,...s}=e,a=cb(r);return n.jsx(Dj,{...a,...s,ref:t})});c5.displayName=vte;var yte="MenuSub",[K5e,d5]=bd(yte),Jm="MenuSubTrigger",u5=p.forwardRef((e,t)=>{const r=wd(Jm,e.__scopeMenu),s=ix(Jm,e.__scopeMenu),a=d5(Jm,e.__scopeMenu),i=Jk(Jm,e.__scopeMenu),o=p.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=i,d={__scopeMenu:e.__scopeMenu},u=p.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return p.useEffect(()=>u,[u]),p.useEffect(()=>{const f=l.current;return()=>{window.clearTimeout(f),c(null)}},[l,c]),n.jsx(Xk,{asChild:!0,...d,children:n.jsx(e5,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":h5(r.open),...e,ref:Ni(t,a.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:be(e.onPointerMove,Qh(f=>{i.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!r.open&&!o.current&&(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{r.onOpenChange(!0),u()},100))})),onPointerLeave:be(e.onPointerLeave,Qh(f=>{var m,y;u();const h=(m=r.content)==null?void 0:m.getBoundingClientRect();if(h){const x=(y=r.content)==null?void 0:y.dataset.side,j=x==="right",v=j?-5:5,g=h[j?"left":"right"],b=h[j?"right":"left"];i.onPointerGraceIntentChange({area:[{x:f.clientX+v,y:f.clientY},{x:g,y:h.top},{x:b,y:h.top},{x:b,y:h.bottom},{x:g,y:h.bottom}],side:x}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(f),f.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:be(e.onKeyDown,f=>{var m;const h=i.searchRef.current!=="";e.disabled||h&&f.key===" "||Jee[s.dir].includes(f.key)&&(r.onOpenChange(!0),(m=r.content)==null||m.focus(),f.preventDefault())})})})});u5.displayName=Jm;var f5="MenuSubContent",m5=p.forwardRef((e,t)=>{const r=YF(ia,e.__scopeMenu),{forceMount:s=r.forceMount,...a}=e,i=wd(ia,e.__scopeMenu),o=ix(ia,e.__scopeMenu),l=d5(f5,e.__scopeMenu),c=p.useRef(null),d=dt(t,c);return n.jsx(Hh.Provider,{scope:e.__scopeMenu,children:n.jsx(Jn,{present:s||i.open,children:n.jsx(Hh.Slot,{scope:e.__scopeMenu,children:n.jsx(e2,{id:l.contentId,"aria-labelledby":l.triggerId,...a,ref:d,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var f;o.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:be(e.onFocusOutside,u=>{u.target!==l.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:be(e.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:be(e.onKeyDown,u=>{var m;const f=u.currentTarget.contains(u.target),h=ete[o.dir].includes(u.key);f&&h&&(i.onOpenChange(!1),(m=l.trigger)==null||m.focus(),u.preventDefault())})})})})})});m5.displayName=f5;function h5(e){return e?"open":"closed"}function $v(e){return e==="indeterminate"}function r2(e){return $v(e)?"indeterminate":e?"checked":"unchecked"}function jte(e){const t=document.activeElement;for(const r of e)if(r===t||(r.focus(),document.activeElement!==t))return}function bte(e,t){return e.map((r,s)=>e[(t+s)%e.length])}function wte(e,t,r){const a=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,i=r?e.indexOf(r):-1;let o=bte(e,Math.max(i,0));a.length===1&&(o=o.filter(d=>d!==r));const c=o.find(d=>d.toLowerCase().startsWith(a.toLowerCase()));return c!==r?c:void 0}function Nte(e,t){const{x:r,y:s}=e;let a=!1;for(let i=0,o=t.length-1;is!=h>s&&r<(f-d)*(s-u)/(h-u)+d&&(a=!a)}return a}function Ste(e,t){if(!t)return!1;const r={x:e.clientX,y:e.clientY};return Nte(r,t)}function Qh(e){return t=>t.pointerType==="mouse"?e(t):void 0}var _te=QF,Cte=Xk,kte=XF,Pte=ZF,Ate=t2,Ete=JF,Ote=db,Tte=t5,Mte=r5,Rte=a5,$te=o5,Ite=l5,Dte=c5,Lte=u5,Fte=m5,ub="DropdownMenu",[Bte]=lr(ub,[GF]),is=GF(),[zte,p5]=Bte(ub),x5=e=>{const{__scopeDropdownMenu:t,children:r,dir:s,open:a,defaultOpen:i,onOpenChange:o,modal:l=!0}=e,c=is(t),d=p.useRef(null),[u,f]=zr({prop:a,defaultProp:i??!1,onChange:o,caller:ub});return n.jsx(zte,{scope:t,triggerId:ys(),triggerRef:d,contentId:ys(),open:u,onOpenChange:f,onOpenToggle:p.useCallback(()=>f(h=>!h),[f]),modal:l,children:n.jsx(_te,{...c,open:u,onOpenChange:f,dir:s,modal:l,children:r})})};x5.displayName=ub;var g5="DropdownMenuTrigger",v5=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,disabled:s=!1,...a}=e,i=p5(g5,r),o=is(r);return n.jsx(Cte,{asChild:!0,...o,children:n.jsx(We.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":s?"":void 0,disabled:s,...a,ref:Ni(t,i.triggerRef),onPointerDown:be(e.onPointerDown,l=>{!s&&l.button===0&&l.ctrlKey===!1&&(i.onOpenToggle(),i.open||l.preventDefault())}),onKeyDown:be(e.onKeyDown,l=>{s||(["Enter"," "].includes(l.key)&&i.onOpenToggle(),l.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});v5.displayName=g5;var Vte="DropdownMenuPortal",y5=e=>{const{__scopeDropdownMenu:t,...r}=e,s=is(t);return n.jsx(kte,{...s,...r})};y5.displayName=Vte;var j5="DropdownMenuContent",b5=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=p5(j5,r),i=is(r),o=p.useRef(!1);return n.jsx(Pte,{id:a.contentId,"aria-labelledby":a.triggerId,...i,...s,ref:t,onCloseAutoFocus:be(e.onCloseAutoFocus,l=>{var c;o.current||(c=a.triggerRef.current)==null||c.focus(),o.current=!1,l.preventDefault()}),onInteractOutside:be(e.onInteractOutside,l=>{const c=l.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,u=c.button===2||d;(!a.modal||u)&&(o.current=!0)}),style:{...e.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)"}})});b5.displayName=j5;var qte="DropdownMenuGroup",Wte=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=is(r);return n.jsx(Ate,{...a,...s,ref:t})});Wte.displayName=qte;var Ute="DropdownMenuLabel",w5=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=is(r);return n.jsx(Ete,{...a,...s,ref:t})});w5.displayName=Ute;var Kte="DropdownMenuItem",N5=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=is(r);return n.jsx(Ote,{...a,...s,ref:t})});N5.displayName=Kte;var Gte="DropdownMenuCheckboxItem",S5=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=is(r);return n.jsx(Tte,{...a,...s,ref:t})});S5.displayName=Gte;var Hte="DropdownMenuRadioGroup",Qte=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=is(r);return n.jsx(Mte,{...a,...s,ref:t})});Qte.displayName=Hte;var Yte="DropdownMenuRadioItem",_5=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=is(r);return n.jsx(Rte,{...a,...s,ref:t})});_5.displayName=Yte;var Xte="DropdownMenuItemIndicator",C5=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=is(r);return n.jsx($te,{...a,...s,ref:t})});C5.displayName=Xte;var Zte="DropdownMenuSeparator",k5=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=is(r);return n.jsx(Ite,{...a,...s,ref:t})});k5.displayName=Zte;var Jte="DropdownMenuArrow",ene=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=is(r);return n.jsx(Dte,{...a,...s,ref:t})});ene.displayName=Jte;var tne="DropdownMenuSubTrigger",P5=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=is(r);return n.jsx(Lte,{...a,...s,ref:t})});P5.displayName=tne;var nne="DropdownMenuSubContent",A5=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=is(r);return n.jsx(Fte,{...a,...s,ref:t,style:{...e.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)"}})});A5.displayName=nne;var rne=x5,sne=v5,ane=y5,E5=b5,O5=w5,T5=N5,M5=S5,R5=_5,$5=C5,I5=k5,D5=P5,L5=A5;const Yh=rne,Xh=sne,ine=p.forwardRef(({className:e,inset:t,children:r,...s},a)=>n.jsxs(D5,{ref:a,className:he("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",t&&"pl-8",e),...s,children:[r,n.jsx(Si,{className:"ml-auto h-4 w-4"})]}));ine.displayName=D5.displayName;const one=p.forwardRef(({className:e,...t},r)=>n.jsx(L5,{ref:r,className:he("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",e),...t}));one.displayName=L5.displayName;const Yu=p.forwardRef(({className:e,sideOffset:t=4,...r},s)=>n.jsx(ane,{children:n.jsx(E5,{ref:s,sideOffset:t,className:he("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",e),...r})}));Yu.displayName=E5.displayName;const Ji=p.forwardRef(({className:e,inset:t,...r},s)=>n.jsx(T5,{ref:s,className:he("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t&&"pl-8",e),...r}));Ji.displayName=T5.displayName;const lne=p.forwardRef(({className:e,children:t,checked:r,...s},a)=>n.jsxs(M5,{ref:a,className:he("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),checked:r,...s,children:[n.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx($5,{children:n.jsx(aa,{className:"h-4 w-4"})})}),t]}));lne.displayName=M5.displayName;const cne=p.forwardRef(({className:e,children:t,...r},s)=>n.jsxs(R5,{ref:s,className:he("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...r,children:[n.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx($5,{children:n.jsx(_j,{className:"h-2 w-2 fill-current"})})}),t]}));cne.displayName=R5.displayName;const dne=p.forwardRef(({className:e,inset:t,...r},s)=>n.jsx(O5,{ref:s,className:he("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...r}));dne.displayName=O5.displayName;const Xu=p.forwardRef(({className:e,...t},r)=>n.jsx(I5,{ref:r,className:he("-mx-1 my-1 h-px bg-muted",e),...t}));Xu.displayName=I5.displayName;function F5(){const e=[],t=e.filter(r=>!r.read).length;return n.jsxs(Yh,{children:[n.jsx(Xh,{asChild:!0,children:n.jsxs(E,{variant:"ghost",size:"icon",className:"relative text-muted-foreground hover:text-foreground",children:[n.jsx(ok,{className:"h-4 w-4"}),t>0&&n.jsx("span",{className:"absolute -top-0.5 -right-0.5 h-4 w-4 rounded-full bg-destructive text-[10px] font-bold text-destructive-foreground flex items-center justify-center",children:t})]})}),n.jsxs(Yu,{align:"end",className:"w-80",children:[n.jsx("div",{className:"px-3 py-2 font-semibold text-sm",children:"Notifications"}),n.jsx(Xu,{}),e.slice(0,4).map(r=>n.jsxs(Ji,{className:"flex flex-col items-start gap-0.5 py-2.5 cursor-pointer",children:[n.jsx("span",{className:`text-sm font-medium ${r.read?"text-muted-foreground":"text-foreground"}`,children:r.title}),n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-1",children:r.message}),n.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:r.time})]},r.id))]})]})}function une({navGroups:e}){const{state:t}=jd(),r=t==="collapsed";return n.jsx(n.Fragment,{children:e.map(s=>n.jsxs(nb,{children:[n.jsx(rb,{children:s.label}),n.jsx(sb,{children:n.jsx(ab,{children:s.items.map(a=>n.jsx(ib,{children:n.jsx(ob,{asChild:!0,tooltip:a.title,children:n.jsxs(lb,{to:a.url,end:a.url.endsWith("/dashboard"),className:"flex items-center gap-2 px-2 py-1.5 rounded-md text-sm text-sidebar-foreground hover:bg-sidebar-accent transition-colors",activeClassName:"bg-sidebar-accent text-sidebar-accent-foreground font-medium",children:[n.jsx(a.icon,{className:"h-4 w-4 shrink-0"}),!r&&n.jsx("span",{children:a.title})]})})},a.url))})})]},s.label))})}function B5({navGroups:e,role:t}){var l;const{user:r,logout:s}=Ga(),a=Bt(),i=((l=r==null?void 0:r.name)==null?void 0:l.split(" ").map(c=>c[0]).join("").slice(0,2).toUpperCase())??"??",o=async()=>{await s(),a("/login")};return n.jsx(qk,{children:n.jsxs("div",{className:"min-h-screen flex w-full",children:[n.jsxs(Wk,{collapsible:"icon",children:[n.jsx(Kk,{className:"p-4",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("img",{src:"/logo.png",alt:"EnCoach",className:"h-8 w-8 rounded-lg shrink-0 object-contain"}),n.jsxs("span",{className:"text-lg font-bold tracking-tight text-sidebar-foreground group-data-[collapsible=icon]:hidden",children:[n.jsx("span",{className:"text-[hsl(42,40%,62%)]",children:"En"}),n.jsx("span",{children:"Coach"})]})]})}),n.jsx(Gh,{}),n.jsx(Hk,{children:n.jsx(une,{navGroups:e})}),n.jsx(Gh,{}),n.jsx(Gk,{className:"p-3",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:n.jsx("span",{className:"text-xs font-semibold text-primary",children:i})}),n.jsxs("div",{className:"flex flex-col min-w-0 group-data-[collapsible=icon]:hidden",children:[n.jsx("span",{className:"text-sm font-medium truncate text-sidebar-foreground",children:r==null?void 0:r.name}),n.jsx("span",{className:"text-xs text-muted-foreground truncate",children:r==null?void 0:r.email})]})]})})]}),n.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[n.jsxs("header",{className:"h-14 border-b bg-card flex items-center justify-between px-4 shrink-0",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Uk,{}),n.jsxs("span",{className:"text-sm font-medium text-muted-foreground capitalize",children:[t," Portal"]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(F5,{}),n.jsxs(Yh,{children:[n.jsx(Xh,{asChild:!0,children:n.jsx(E,{variant:"ghost",size:"icon",className:"rounded-full",children:n.jsx("div",{className:"h-8 w-8 rounded-full bg-primary flex items-center justify-center",children:n.jsx("span",{className:"text-xs font-semibold text-primary-foreground",children:i})})})}),n.jsxs(Yu,{align:"end",className:"w-48",children:[n.jsxs("div",{className:"px-3 py-2",children:[n.jsx("p",{className:"text-sm font-medium",children:r==null?void 0:r.name}),n.jsx("p",{className:"text-xs text-muted-foreground",children:r==null?void 0:r.email})]}),n.jsx(Xu,{}),n.jsxs(Ji,{onClick:()=>a(`/${t}/profile`),children:[n.jsx(Ej,{className:"mr-2 h-4 w-4"})," Profile"]}),n.jsx(Xu,{}),n.jsxs(Ji,{onClick:o,children:[n.jsx(qL,{className:"mr-2 h-4 w-4"})," Logout"]})]})]})]})]}),n.jsx("main",{className:"flex-1 overflow-auto p-6",children:n.jsx(Dk,{})})]})]})})}const fne=[{label:"Learning",items:[{title:"Dashboard",url:"/student/dashboard",icon:mk},{title:"My Courses",url:"/student/courses",icon:Kt},{title:"Subject Registration",url:"/student/subject-registration",icon:GG},{title:"Assignments",url:"/student/assignments",icon:gd}]},{label:"Adaptive Learning",items:[{title:"My Subjects",url:"/student/subjects",icon:vk}]},{label:"Progress",items:[{title:"Grades",url:"/student/grades",icon:Il},{title:"Attendance",url:"/student/attendance",icon:lk},{title:"Timetable",url:"/student/timetable",icon:Yp},{title:"My Journey",url:"/student/journey",icon:Dl}]},{label:"Communication",items:[{title:"Discussions",url:"/student/discussions",icon:fi},{title:"Messages",url:"/student/messages",icon:WL},{title:"Announcements",url:"/student/announcements",icon:Bh}]},{label:"Account",items:[{title:"Profile",url:"/student/profile",icon:Ej}]}];function mne(){return n.jsx(B5,{navGroups:fne,role:"student"})}const hne=[{label:"Teaching",items:[{title:"Dashboard",url:"/teacher/dashboard",icon:mk},{title:"Courses",url:"/teacher/courses",icon:Kt},{title:"Assignments",url:"/teacher/assignments",icon:gd}]},{label:"Management",items:[{title:"Attendance",url:"/teacher/attendance",icon:lk},{title:"Students",url:"/teacher/students",icon:as},{title:"Timetable",url:"/teacher/timetable",icon:Yp}]},{label:"Communication",items:[{title:"Discussions",url:"/teacher/discussions",icon:fi},{title:"Announcements",url:"/teacher/announcements",icon:Bh}]},{label:"Account",items:[{title:"Profile",url:"/teacher/profile",icon:Ej}]}];function pne(){return n.jsx(B5,{navGroups:hne,role:"teacher"})}var fb="Collapsible",[xne,z5]=lr(fb),[gne,s2]=xne(fb),V5=p.forwardRef((e,t)=>{const{__scopeCollapsible:r,open:s,defaultOpen:a,disabled:i,onOpenChange:o,...l}=e,[c,d]=zr({prop:s,defaultProp:a??!1,onChange:o,caller:fb});return n.jsx(gne,{scope:r,disabled:i,contentId:ys(),open:c,onOpenToggle:p.useCallback(()=>d(u=>!u),[d]),children:n.jsx(We.div,{"data-state":l2(c),"data-disabled":i?"":void 0,...l,ref:t})})});V5.displayName=fb;var q5="CollapsibleTrigger",a2=p.forwardRef((e,t)=>{const{__scopeCollapsible:r,...s}=e,a=s2(q5,r);return n.jsx(We.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":l2(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...s,ref:t,onClick:be(e.onClick,a.onOpenToggle)})});a2.displayName=q5;var i2="CollapsibleContent",o2=p.forwardRef((e,t)=>{const{forceMount:r,...s}=e,a=s2(i2,e.__scopeCollapsible);return n.jsx(Jn,{present:r||a.open,children:({present:i})=>n.jsx(vne,{...s,ref:t,present:i})})});o2.displayName=i2;var vne=p.forwardRef((e,t)=>{const{__scopeCollapsible:r,present:s,children:a,...i}=e,o=s2(i2,r),[l,c]=p.useState(s),d=p.useRef(null),u=dt(t,d),f=p.useRef(0),h=f.current,m=p.useRef(0),y=m.current,x=o.open||l,j=p.useRef(x),v=p.useRef(void 0);return p.useEffect(()=>{const g=requestAnimationFrame(()=>j.current=!1);return()=>cancelAnimationFrame(g)},[]),Ln(()=>{const g=d.current;if(g){v.current=v.current||{transitionDuration:g.style.transitionDuration,animationName:g.style.animationName},g.style.transitionDuration="0s",g.style.animationName="none";const b=g.getBoundingClientRect();f.current=b.height,m.current=b.width,j.current||(g.style.transitionDuration=v.current.transitionDuration,g.style.animationName=v.current.animationName),c(s)}},[o.open,s]),n.jsx(We.div,{"data-state":l2(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!x,...i,ref:u,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":y?`${y}px`:void 0,...e.style},children:x&&a})});function l2(e){return e?"open":"closed"}var W5=V5,yne=a2,jne=o2;const fr=W5,mr=a2,hr=o2,ox={async chat(e){return R.post("/coach/chat",e)},async getHint(e){return R.post("/coach/hint",e)},async explain(e){return R.post("/coach/explain",e)},async suggest(e){return R.post("/coach/suggest",e)},async writingHelp(e){return R.post("/coach/writing-help",e)},async getTip(e){return R.get("/coach/tip",{context:e})}},bne=["Platform health summary","Show dropout risks","Compare course performance","Suggest batch improvements"];function wne(){const[e,t]=p.useState(!1),[r,s]=p.useState([]),[a,i]=p.useState(""),o=Ka(),{toast:l}=He(),c=ae({mutationFn:u=>ox.chat({message:u,context:{page:o.pathname}}),onSuccess:u=>{s(f=>[...f,{role:"ai",text:u.reply}])},onError:u=>{l({variant:"destructive",title:"Could not get a reply",description:u.message||"Something went wrong. Try again."}),s(f=>[...f,{role:"ai",text:"Sorry, I could not reach the assistant. Please try again in a moment."}])}}),d=u=>{if(!u.trim()||c.isPending)return;const f=u.trim();s(h=>[...h,{role:"user",text:f}]),i(""),c.mutate(f)};return n.jsxs(n.Fragment,{children:[n.jsx("button",{onClick:()=>t(!0),className:"fixed bottom-20 right-6 z-50 flex h-12 w-12 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-lg hover:opacity-90 transition-opacity","aria-label":"AI Assistant",children:n.jsx(lt,{className:"h-5 w-5"})}),n.jsx(Jj,{open:e,onOpenChange:t,children:n.jsxs(rx,{className:"w-[400px] sm:w-[440px] flex flex-col",children:[n.jsx(eb,{children:n.jsxs(tb,{className:"flex items-center gap-2",children:[n.jsx(lt,{className:"h-5 w-5 text-primary"}),"EnCoach AI Assistant"]})}),n.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:bne.map(u=>n.jsx(E,{variant:"outline",size:"sm",className:"text-xs",disabled:c.isPending,onClick:()=>d(u),children:u},u))}),n.jsxs("div",{className:"flex-1 overflow-y-auto mt-4 space-y-3 min-h-0",children:[r.length===0&&n.jsxs("div",{className:"text-center text-muted-foreground text-sm py-8",children:[n.jsx(lt,{className:"h-8 w-8 mx-auto mb-3 text-primary/40"}),n.jsx("p",{children:"Ask me anything about the platform,"}),n.jsx("p",{children:"or click a quick action above."})]}),r.map((u,f)=>n.jsxs("div",{className:`rounded-lg p-3 text-sm ${u.role==="user"?"bg-primary text-primary-foreground ml-8":"bg-muted mr-8"}`,children:[u.role==="ai"&&n.jsx(lt,{className:"h-3 w-3 text-primary inline mr-1.5 -mt-0.5"}),u.text]},f)),c.isPending&&n.jsxs("div",{className:"bg-muted rounded-lg p-3 text-sm mr-8 flex items-center gap-2",children:[n.jsx(Re,{className:"h-4 w-4 animate-spin text-primary"}),n.jsx("span",{className:"text-muted-foreground",children:"Thinking..."})]})]}),n.jsxs("div",{className:"flex gap-2 pt-3 border-t mt-auto",children:[n.jsx(G,{placeholder:"Ask anything...",value:a,onChange:u=>i(u.target.value),onKeyDown:u=>u.key==="Enter"&&d(a)}),n.jsx(E,{size:"icon",onClick:()=>d(a),disabled:!a.trim()||c.isPending,children:n.jsx(gl,{className:"h-4 w-4"})})]})]})})]})}const Ol={async getStudentAnalytics(e){return R.get("/analytics/student",e)},async getClassAnalytics(e){return R.get("/analytics/class",e)},async getSubjectAnalytics(e){return R.get("/analytics/subject",e)},async getContentGaps(e){return R.get("/analytics/content-gaps",e)},async search(e){return R.post("/ai/search",{query:e})},async getInsights(e){return R.post("/ai/insights",{data:e,type:"general"})},async getAlerts(){return R.get("/ai/alerts")},async getReportNarrative(e){return R.post("/ai/report-narrative",e)},async getBatchOptimization(e,t=[],r="schedule"){return R.post("/ai/batch-optimize",{items:t,type:r})},async getGradingSuggestion(e){return R.post("/ai/grade-suggest",e)},async applyBatchOptimization(e,t){return R.post("/ai/batch-optimize/apply",{batch_id:e,optimized:t})},async vectorSearch(e,t){return R.get("/ai/vector-search",{q:e,...t})}};function Nne(){var l,c;const[e,t]=p.useState(""),r=Bt(),{toast:s}=He(),a=ae({mutationFn:d=>Ol.search(d),onError:d=>{s({variant:"destructive",title:"Search failed",description:d.message||"Could not complete AI search."})}}),i=()=>{!e.trim()||a.isPending||a.mutate(e.trim())},o=a.data;return n.jsxs("div",{className:"relative max-w-md w-full",children:[n.jsxs("div",{className:"relative",children:[n.jsx(lt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-primary"}),n.jsx(en,{className:"absolute left-7 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),n.jsx(G,{placeholder:"Ask anything... e.g. 'Show students with low attendance'",className:"pl-12 pr-8 h-9 text-sm bg-muted/50 border-0 focus-visible:ring-1",value:e,onChange:d=>{t(d.target.value),a.reset()},onKeyDown:d=>d.key==="Enter"&&i()}),e&&n.jsx("button",{onClick:()=>{t(""),a.reset()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:n.jsx(ts,{className:"h-3.5 w-3.5"})})]}),(a.isPending||o!==void 0)&&n.jsx("div",{className:"absolute top-full mt-1 left-0 right-0 z-50 rounded-lg border bg-popover p-3 shadow-md",children:a.isPending?n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[n.jsx(Re,{className:"h-4 w-4 animate-spin text-primary"}),"AI is searching..."]}):o!=null&&o.answer?n.jsxs("div",{className:"text-sm space-y-2 max-h-64 overflow-y-auto",children:[n.jsxs("div",{className:"flex items-start gap-2 pb-2",children:[n.jsx(lt,{className:"h-4 w-4 text-primary shrink-0 mt-0.5"}),n.jsx("p",{className:"text-muted-foreground",children:o.answer})]}),((l=o.suggestions)==null?void 0:l.length)>0&&n.jsxs("div",{className:"border-t pt-2 space-y-1",children:[n.jsx("p",{className:"text-xs font-semibold text-primary",children:"Related queries"}),o.suggestions.map((d,u)=>n.jsx("button",{type:"button",className:"block text-xs text-primary hover:underline",onClick:()=>{t(d),a.mutate(d)},children:d},u))]}),(c=o.related_actions)==null?void 0:c.map((d,u)=>n.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>r(d.action),children:d.label},u))]}):n.jsxs("div",{className:"text-sm flex items-start gap-2",children:[n.jsx(lt,{className:"h-4 w-4 text-primary shrink-0 mt-0.5"}),n.jsxs("p",{children:['No results for "',e,'". Try a different question or keyword.']})]})})]})}const U5=p.forwardRef(({...e},t)=>n.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));U5.displayName="Breadcrumb";const K5=p.forwardRef(({className:e,...t},r)=>n.jsx("ol",{ref:r,className:he("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...t}));K5.displayName="BreadcrumbList";const lS=p.forwardRef(({className:e,...t},r)=>n.jsx("li",{ref:r,className:he("inline-flex items-center gap-1.5",e),...t}));lS.displayName="BreadcrumbItem";const cS=p.forwardRef(({asChild:e,className:t,...r},s)=>{const a=e?Bl:"a";return n.jsx(a,{ref:s,className:he("transition-colors hover:text-foreground",t),...r})});cS.displayName="BreadcrumbLink";const G5=p.forwardRef(({className:e,...t},r)=>n.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:he("font-normal text-foreground",e),...t}));G5.displayName="BreadcrumbPage";const H5=({children:e,className:t,...r})=>n.jsx("li",{role:"presentation","aria-hidden":"true",className:he("[&>svg]:size-3.5",t),...r,children:e??n.jsx(Si,{})});H5.displayName="BreadcrumbSeparator";const Sne=[{title:"Admin Dashboard",url:"/admin/dashboard",icon:mk},{title:"Platform Dashboard",url:"/admin/platform",icon:Il}],_ne=[{title:"Courses",url:"/admin/courses",icon:Kt},{title:"Students",url:"/admin/students",icon:as},{title:"Teachers",url:"/admin/teachers",icon:_i},{title:"Batches",url:"/admin/batches",icon:oo},{title:"Timetable",url:"/admin/timetable",icon:Yp},{title:"Reports",url:"/admin/reports",icon:Il}],Cne=[{title:"Assignments",url:"/admin/assignments",icon:gd},{title:"Exams List",url:"/admin/examsList",icon:Yn},{title:"Exam Structures",url:"/admin/exam-structures",icon:oo},{title:"Rubrics",url:"/admin/rubrics",icon:Kt},{title:"Generation",url:"/admin/generation",icon:QL},{title:"Approval Workflows",url:"/admin/approval-workflows",icon:FG}],kne=[{title:"Taxonomy",url:"/admin/taxonomy",icon:vk},{title:"Resources",url:"/admin/resources",icon:dk}],Pne=[{title:"Academic Years",url:"/admin/academic-years",icon:AG},{title:"Departments",url:"/admin/departments",icon:qG},{title:"Admissions",url:"/admin/admissions",icon:nH},{title:"Admission Register",url:"/admin/admission-register",icon:JG},{title:"Exam Sessions",url:"/admin/exam-sessions",icon:Yn},{title:"Marksheets",url:"/admin/marksheets",icon:ik},{title:"Student Leave",url:"/admin/student-leave",icon:EG},{title:"Fees & Payments",url:"/admin/fees",icon:ck},{title:"Lessons",url:"/admin/lessons",icon:$L},{title:"Gradebook",url:"/admin/gradebook",icon:OG},{title:"Student Progress",url:"/admin/student-progress",icon:Dl},{title:"Library",url:"/admin/library",icon:UG},{title:"Activities",url:"/admin/activities",icon:Sj},{title:"Facilities",url:"/admin/facilities",icon:rH}],Ane=[{title:"Users",url:"/admin/users",icon:as},{title:"Entities",url:"/admin/entities",icon:Lh},{title:"Classrooms",url:"/admin/classrooms",icon:_i},{title:"User Roles",url:"/admin/user-roles",icon:au},{title:"Roles & Permissions",url:"/admin/roles-permissions",icon:gk},{title:"Authority Matrix",url:"/admin/authority-matrix",icon:YL}],Ene=[{title:"Student Performance",url:"/admin/student-performance",icon:Il},{title:"Stats Corporate",url:"/admin/stats-corporate",icon:Lh},{title:"Record",url:"/admin/record",icon:zG}],One=[{title:"Vocabulary",url:"/admin/training/vocabulary",icon:_G},{title:"Grammar",url:"/admin/training/grammar",icon:KL}],Tne=[{title:"FAQ Manager",url:"/admin/faq",icon:Fh},{title:"Notification Rules",url:"/admin/notification-rules",icon:ok},{title:"Approval Config",url:"/admin/approval-config",icon:YL}],NO=[{title:"Payment Record",url:"/admin/payment-record",icon:BL},{title:"Tickets",url:"/admin/tickets",icon:Aj},{title:"Settings",url:"/admin/settings-platform",icon:gk}];function Ri({label:e,items:t}){const{state:r}=jd(),s=r==="collapsed";return n.jsxs(nb,{children:[n.jsx(rb,{children:e}),n.jsx(sb,{children:n.jsx(ab,{children:t.map(a=>n.jsx(ib,{children:n.jsx(ob,{asChild:!0,tooltip:a.title,children:n.jsxs(lb,{to:a.url,end:a.url.endsWith("/dashboard")||a.url.endsWith("/platform"),className:"flex items-center gap-2 px-2 py-1.5 rounded-md text-sm text-sidebar-foreground hover:bg-sidebar-accent transition-colors",activeClassName:"bg-sidebar-accent text-sidebar-accent-foreground font-medium",children:[n.jsx(a.icon,{className:"h-4 w-4 shrink-0"}),!s&&n.jsx("span",{children:a.title})]})})},a.url))})})]})}const Mne={admin:"Admin",dashboard:"Dashboard",platform:"Platform",courses:"Courses",students:"Students",teachers:"Teachers",batches:"Batches",timetable:"Timetable",reports:"Reports",assignments:"Assignments",examsList:"Exams List","exam-structures":"Exam Structures",rubrics:"Rubrics",generation:"Generation","approval-workflows":"Approval Workflows",users:"Users",entities:"Entities",classrooms:"Classrooms","student-performance":"Student Performance","stats-corporate":"Stats Corporate",record:"Record",training:"Training",vocabulary:"Vocabulary",grammar:"Grammar","payment-record":"Payment Record",tickets:"Tickets","settings-platform":"Settings",settings:"Settings",profile:"Profile",exam:"Exam","academic-years":"Academic Years",departments:"Departments",admissions:"Admissions","admission-register":"Admission Register","exam-sessions":"Exam Sessions",marksheets:"Marksheets",faq:"FAQ Manager","notification-rules":"Notification Rules","approval-config":"Approval Config","student-leave":"Student Leave",fees:"Fees & Payments",lessons:"Lessons",gradebook:"Gradebook","student-progress":"Student Progress",library:"Library",activities:"Activities",facilities:"Facilities"};function Rne(){const t=Ka().pathname.split("/").filter(Boolean);return n.jsx(U5,{children:n.jsxs(K5,{children:[n.jsx(lS,{children:n.jsx(cS,{asChild:!0,children:n.jsx(Dt,{to:"/admin/dashboard",children:"Home"})})}),t.map((r,s)=>{const a="/"+t.slice(0,s+1).join("/"),i=Mne[r]||r.charAt(0).toUpperCase()+r.slice(1),o=s===t.length-1;return n.jsxs(F.Fragment,{children:[n.jsx(H5,{}),n.jsx(lS,{children:o?n.jsx(G5,{children:i}):n.jsx(cS,{asChild:!0,children:n.jsx(Dt,{to:a,children:i})})})]},a)})]})})}function $ne(){var i;const{user:e,logout:t}=Ga(),r=Bt(),s=((i=e==null?void 0:e.name)==null?void 0:i.split(" ").map(o=>o[0]).join("").slice(0,2).toUpperCase())??"??",a=async()=>{await t(),r("/login")};return n.jsxs(qk,{children:[n.jsxs("div",{className:"min-h-screen flex w-full",children:[n.jsx(Ine,{}),n.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[n.jsxs("header",{className:"h-14 border-b bg-card flex items-center justify-between px-4 shrink-0",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Uk,{}),n.jsx(Rne,{})]}),n.jsx(Nne,{}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(F5,{}),n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>r("/admin/tickets"),className:"text-muted-foreground hover:text-foreground",children:n.jsx(Aj,{className:"h-4 w-4"})}),n.jsxs(Yh,{children:[n.jsx(Xh,{asChild:!0,children:n.jsx(E,{variant:"ghost",size:"icon",className:"rounded-full",children:n.jsx("div",{className:"h-8 w-8 rounded-full bg-primary flex items-center justify-center",children:n.jsx("span",{className:"text-xs font-semibold text-primary-foreground",children:s})})})}),n.jsxs(Yu,{align:"end",className:"w-48",children:[n.jsxs("div",{className:"px-3 py-2",children:[n.jsx("p",{className:"text-sm font-medium",children:(e==null?void 0:e.name)??"User"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:(e==null?void 0:e.email)??""})]}),n.jsx(Xu,{}),n.jsxs(Ji,{onClick:()=>r("/admin/profile"),children:[n.jsx(Ej,{className:"mr-2 h-4 w-4"})," Profile"]}),n.jsxs(Ji,{onClick:()=>r("/admin/settings-platform"),children:[n.jsx(gk,{className:"mr-2 h-4 w-4"})," Settings"]}),n.jsx(Xu,{}),n.jsxs(Ji,{onClick:a,children:[n.jsx(qL,{className:"mr-2 h-4 w-4"})," Logout"]})]})]})]})]}),n.jsx("main",{className:"flex-1 overflow-auto p-6",children:n.jsx(Dk,{})})]})]}),n.jsx(wne,{}),n.jsxs(Dt,{to:"/admin/tickets",className:"fixed bottom-6 right-6 z-50 flex items-center gap-2 rounded-full bg-primary px-4 py-2.5 text-primary-foreground shadow-lg hover:opacity-90 transition-opacity",children:[n.jsx(Fh,{className:"h-4 w-4"}),n.jsx("span",{className:"text-sm font-medium",children:"Need help?"})]})]})}function Ine(){var c;const{state:e}=jd(),t=e==="collapsed",{user:r}=Ga(),{hasAnyPermission:s,isAdmin:a}=oF(),i=a||s(["view_entities","view_students","view_teachers"]),o=a||s(["view_statistics","view_student_performance","view_entity_statistics"]),l=a||s(["view_payment_record","pay_entity"]);return n.jsxs(Wk,{collapsible:"icon",children:[n.jsx(Kk,{className:"p-4",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("img",{src:"/logo.png",alt:"EnCoach",className:"h-8 w-8 rounded-lg shrink-0 object-contain"}),!t&&n.jsxs("span",{className:"text-lg font-bold tracking-tight text-sidebar-foreground",children:[n.jsx("span",{className:"text-[hsl(42,40%,62%)]",children:"En"}),n.jsx("span",{children:"Coach"})]})]})}),n.jsx(Gh,{}),n.jsxs(Hk,{children:[n.jsx(Ri,{label:"Overview",items:Sne}),n.jsx(Ri,{label:"LMS",items:_ne}),n.jsx(Ri,{label:"Adaptive Learning",items:kne}),n.jsx(Ri,{label:"Institutional",items:Pne}),n.jsx(Ri,{label:"Academic",items:Cne}),i&&n.jsx(Ri,{label:"Management",items:Ane}),o&&n.jsx(Ri,{label:"Reports",items:Ene}),n.jsx(Ri,{label:"Configuration",items:Tne}),n.jsx(nb,{children:n.jsxs(fr,{defaultOpen:!0,className:"group/collapsible",children:[n.jsx(rb,{asChild:!0,children:n.jsxs(mr,{className:"flex w-full items-center justify-between",children:["Training",!t&&n.jsx(rr,{className:"h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-180"})]})}),n.jsx(hr,{children:n.jsx(sb,{children:n.jsx(ab,{children:One.map(d=>n.jsx(ib,{children:n.jsx(ob,{asChild:!0,tooltip:d.title,children:n.jsxs(lb,{to:d.url,className:"flex items-center gap-2 px-2 py-1.5 rounded-md text-sm text-sidebar-foreground hover:bg-sidebar-accent transition-colors",activeClassName:"bg-sidebar-accent text-sidebar-accent-foreground font-medium",children:[n.jsx(d.icon,{className:"h-4 w-4 shrink-0"}),!t&&n.jsx("span",{children:d.title})]})})},d.url))})})})]})}),n.jsx(Ri,{label:"Support",items:l?NO:NO.filter(d=>d.url!=="/admin/payment-record")})]}),n.jsx(Gh,{}),n.jsx(Gk,{className:"p-3",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:n.jsx("span",{className:"text-xs font-semibold text-primary",children:((c=r==null?void 0:r.name)==null?void 0:c.split(" ").map(d=>d[0]).join("").slice(0,2).toUpperCase())??"??"})}),!t&&n.jsxs("div",{className:"flex flex-col min-w-0",children:[n.jsx("span",{className:"text-sm font-medium truncate text-sidebar-foreground",children:(r==null?void 0:r.name)??"User"}),n.jsx("span",{className:"text-xs text-muted-foreground truncate",children:(r==null?void 0:r.email)??""})]})]})})]})}var Dne=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Lne=Dne.reduce((e,t)=>{const r=ex(`Primitive.${t}`),s=p.forwardRef((a,i)=>{const{asChild:o,...l}=a,c=o?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(c,{...l,ref:i})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),Fne="Label",Q5=p.forwardRef((e,t)=>n.jsx(Lne.label,{...e,ref:t,onMouseDown:r=>{var a;r.target.closest("button, input, select, textarea")||((a=e.onMouseDown)==null||a.call(e,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));Q5.displayName=Fne;var Y5=Q5;const Bne=pd("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),q=p.forwardRef(({className:e,...t},r)=>n.jsx(Y5,{ref:r,className:he(Bne(),e),...t}));q.displayName=Y5.displayName;const W=p.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:he("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));W.displayName="Card";const se=p.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:he("flex flex-col space-y-1.5 p-6",e),...t}));se.displayName="CardHeader";const ie=p.forwardRef(({className:e,...t},r)=>n.jsx("h3",{ref:r,className:he("text-2xl font-semibold leading-none tracking-tight",e),...t}));ie.displayName="CardTitle";const $e=p.forwardRef(({className:e,...t},r)=>n.jsx("p",{ref:r,className:he("text-sm text-muted-foreground",e),...t}));$e.displayName="CardDescription";const U=p.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:he("p-6 pt-0",e),...t}));U.displayName="CardContent";const Yg=p.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:he("flex items-center p-6 pt-0",e),...t}));Yg.displayName="CardFooter";function lx(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var mb="Checkbox",[zne]=lr(mb),[Vne,c2]=zne(mb);function qne(e){const{__scopeCheckbox:t,checked:r,children:s,defaultChecked:a,disabled:i,form:o,name:l,onCheckedChange:c,required:d,value:u="on",internal_do_not_use_render:f}=e,[h,m]=zr({prop:r,defaultProp:a??!1,onChange:c,caller:mb}),[y,x]=p.useState(null),[j,v]=p.useState(null),g=p.useRef(!1),b=y?!!o||!!y.closest("form"):!0,N={checked:h,disabled:i,setChecked:m,control:y,setControl:x,name:l,form:o,value:u,hasConsumerStoppedPropagationRef:g,required:d,defaultChecked:bl(a)?!1:a,isFormControl:b,bubbleInput:j,setBubbleInput:v};return n.jsx(Vne,{scope:t,...N,children:Wne(f)?f(N):s})}var X5="CheckboxTrigger",Z5=p.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...s},a)=>{const{control:i,value:o,disabled:l,checked:c,required:d,setControl:u,setChecked:f,hasConsumerStoppedPropagationRef:h,isFormControl:m,bubbleInput:y}=c2(X5,e),x=dt(a,u),j=p.useRef(c);return p.useEffect(()=>{const v=i==null?void 0:i.form;if(v){const g=()=>f(j.current);return v.addEventListener("reset",g),()=>v.removeEventListener("reset",g)}},[i,f]),n.jsx(We.button,{type:"button",role:"checkbox","aria-checked":bl(c)?"mixed":c,"aria-required":d,"data-state":r6(c),"data-disabled":l?"":void 0,disabled:l,value:o,...s,ref:x,onKeyDown:be(t,v=>{v.key==="Enter"&&v.preventDefault()}),onClick:be(r,v=>{f(g=>bl(g)?!0:!g),y&&m&&(h.current=v.isPropagationStopped(),h.current||v.stopPropagation())})})});Z5.displayName=X5;var d2=p.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:s,checked:a,defaultChecked:i,required:o,disabled:l,value:c,onCheckedChange:d,form:u,...f}=e;return n.jsx(qne,{__scopeCheckbox:r,checked:a,defaultChecked:i,disabled:l,required:o,onCheckedChange:d,name:s,form:u,value:c,internal_do_not_use_render:({isFormControl:h})=>n.jsxs(n.Fragment,{children:[n.jsx(Z5,{...f,ref:t,__scopeCheckbox:r}),h&&n.jsx(n6,{__scopeCheckbox:r})]})})});d2.displayName=mb;var J5="CheckboxIndicator",e6=p.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:s,...a}=e,i=c2(J5,r);return n.jsx(Jn,{present:s||bl(i.checked)||i.checked===!0,children:n.jsx(We.span,{"data-state":r6(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});e6.displayName=J5;var t6="CheckboxBubbleInput",n6=p.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:s,hasConsumerStoppedPropagationRef:a,checked:i,defaultChecked:o,required:l,disabled:c,name:d,value:u,form:f,bubbleInput:h,setBubbleInput:m}=c2(t6,e),y=dt(r,m),x=lx(i),j=Zp(s);p.useEffect(()=>{const g=h;if(!g)return;const b=window.HTMLInputElement.prototype,w=Object.getOwnPropertyDescriptor(b,"checked").set,S=!a.current;if(x!==i&&w){const _=new Event("click",{bubbles:S});g.indeterminate=bl(i),w.call(g,bl(i)?!1:i),g.dispatchEvent(_)}},[h,x,i,a]);const v=p.useRef(bl(i)?!1:i);return n.jsx(We.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??v.current,required:l,disabled:c,name:d,value:u,form:f,...t,tabIndex:-1,ref:y,style:{...t.style,...j,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});n6.displayName=t6;function Wne(e){return typeof e=="function"}function bl(e){return e==="indeterminate"}function r6(e){return bl(e)?"indeterminate":e?"checked":"unchecked"}const an=p.forwardRef(({className:e,...t},r)=>n.jsx(d2,{ref:r,className:he("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:n.jsx(e6,{className:he("flex items-center justify-center text-current"),children:n.jsx(aa,{className:"h-4 w-4"})})}));an.displayName=d2.displayName;function Une(e){switch(e){case"student":return"/student/dashboard";case"teacher":return"/teacher/dashboard";case"admin":case"developer":return"/admin/dashboard";case"corporate":case"mastercorporate":case"agent":return"/admin/platform";default:return"/admin/dashboard"}}function Kne(e){return e instanceof Va&&e.data&&typeof e.data=="object"&&e.data!==null&&"error"in e.data?String(e.data.error):e instanceof Error?e.message:"Login failed"}function Gne(){const[e,t]=p.useState(""),[r,s]=p.useState(""),[a,i]=p.useState(!1),[o,l]=p.useState(!1),c=Bt(),{login:d}=Ga(),{toast:u}=He(),f=async h=>{if(h.preventDefault(),!e||!r){u({title:"Error",description:"Please enter email and password",variant:"destructive"});return}l(!0);try{const m=await d(e,r);c(Une(m.user_type))}catch(m){u({title:"Login Failed",description:Kne(m),variant:"destructive"})}finally{l(!1)}};return n.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:n.jsxs("div",{className:"w-full max-w-md",children:[n.jsxs("div",{className:"flex items-center justify-center gap-3 mb-8",children:[n.jsx("img",{src:"/logo.png",alt:"EnCoach",className:"h-12 w-12 rounded-xl object-contain"}),n.jsxs("h1",{className:"text-2xl font-bold tracking-tight",children:[n.jsx("span",{className:"text-[hsl(42,40%,62%)]",children:"En"}),n.jsx("span",{className:"text-[hsl(240,20%,30%)]",children:"Coach"})]})]}),n.jsxs(W,{className:"shadow-lg border-0 bg-card",children:[n.jsxs(se,{className:"text-center pb-4",children:[n.jsx(ie,{className:"text-xl",children:"Welcome back"}),n.jsx($e,{children:"Sign in to your account to continue"})]}),n.jsxs(U,{children:[n.jsxs("form",{onSubmit:f,className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"email",children:"Email"}),n.jsx(G,{id:"email",type:"email",placeholder:"you@example.com",value:e,onChange:h=>t(h.target.value),disabled:o})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"password",children:"Password"}),n.jsxs("div",{className:"relative",children:[n.jsx(G,{id:"password",type:a?"text":"password",placeholder:"••••••••",value:r,onChange:h=>s(h.target.value),disabled:o}),n.jsx("button",{type:"button",onClick:()=>i(!a),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:a?n.jsx(E1,{className:"h-4 w-4"}):n.jsx(Uc,{className:"h-4 w-4"})})]})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(an,{id:"remember"}),n.jsx(q,{htmlFor:"remember",className:"text-sm font-normal cursor-pointer",children:"Remember me"})]}),n.jsx(Dt,{to:"/forgot-password",className:"text-sm text-primary hover:underline",children:"Forgot password?"})]}),n.jsxs(E,{type:"submit",className:"w-full",disabled:o,children:[o&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Sign in"]})]}),n.jsxs("p",{className:"mt-6 text-center text-sm text-muted-foreground",children:["Don't have an account?"," ",n.jsx(Dt,{to:"/register",className:"text-primary font-medium hover:underline",children:"Sign up"})]})]})]})]})})}var cx=e=>e.type==="checkbox",wc=e=>e instanceof Date,ds=e=>e==null;const s6=e=>typeof e=="object";var qn=e=>!ds(e)&&!Array.isArray(e)&&s6(e)&&!wc(e),a6=e=>qn(e)&&e.target?cx(e.target)?e.target.checked:e.target.value:e,i6=(e,t)=>t.split(".").some((r,s,a)=>!isNaN(Number(r))&&e.has(a.slice(0,s).join("."))),Hne=e=>{const t=e.constructor&&e.constructor.prototype;return qn(t)&&t.hasOwnProperty("isPrototypeOf")},u2=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function cn(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(u2&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(qn(e)&&Hne(e)))return e;const s=r?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(s[a]=cn(e[a]));return s}var hb=e=>/^\w*$/.test(e),rn=e=>e===void 0,pb=e=>Array.isArray(e)?e.filter(Boolean):[],f2=e=>pb(e.replace(/["|']|\]/g,"").split(/\.|\[/)),De=(e,t,r)=>{if(!t||!qn(e))return r;const s=(hb(t)?[t]:f2(t)).reduce((a,i)=>ds(a)?a:a[i],e);return rn(s)||s===e?rn(e[t])?r:e[t]:s},As=e=>typeof e=="boolean",Hr=e=>typeof e=="function",zt=(e,t,r)=>{let s=-1;const a=hb(t)?[t]:f2(t),i=a.length,o=i-1;for(;++sF.useContext(m2);var l6=(e,t,r,s=!0)=>{const a={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return t._proxyFormState[o]!==ea.all&&(t._proxyFormState[o]=!s||ea.all),r&&(r[o]=!0),e[o]}});return a};const gb=typeof window<"u"?F.useLayoutEffect:F.useEffect;function Qne(e){const t=xb(),{control:r=t,disabled:s,name:a,exact:i}=e||{},[o,l]=F.useState(r._formState),c=F.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return gb(()=>r._subscribe({name:a,formState:c.current,exact:i,callback:d=>{!s&&l({...r._formState,...d})}}),[a,s,i]),F.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),F.useMemo(()=>l6(o,r,c.current,!1),[o,r])}var Qr=e=>typeof e=="string",dS=(e,t,r,s,a)=>Qr(e)?(s&&t.watch.add(e),De(r,e,a)):Array.isArray(e)?e.map(i=>(s&&t.watch.add(i),De(r,i))):(s&&(t.watchAll=!0),r),uS=e=>ds(e)||!s6(e);function Oa(e,t,r=new WeakSet){if(uS(e)||uS(t))return Object.is(e,t);if(wc(e)&&wc(t))return Object.is(e.getTime(),t.getTime());const s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;if(r.has(e)||r.has(t))return!0;r.add(e),r.add(t);for(const i of s){const o=e[i];if(!a.includes(i))return!1;if(i!=="ref"){const l=t[i];if(wc(o)&&wc(l)||(qn(o)||Array.isArray(o))&&(qn(l)||Array.isArray(l))?!Oa(o,l,r):!Object.is(o,l))return!1}}return!0}function fS(e){const t=xb(),{control:r=t,name:s,defaultValue:a,disabled:i,exact:o,compute:l}=e||{},c=F.useRef(a),d=F.useRef(l),u=F.useRef(void 0),f=F.useRef(r),h=F.useRef(s);d.current=l;const[m,y]=F.useState(()=>{const N=r._getWatch(s,c.current);return d.current?d.current(N):N}),x=F.useCallback(N=>{const w=dS(s,r._names,N||r._formValues,!1,c.current);return d.current?d.current(w):w},[r._formValues,r._names,s]),j=F.useCallback(N=>{if(!i){const w=dS(s,r._names,N||r._formValues,!1,c.current);if(d.current){const S=d.current(w);Oa(S,u.current)||(y(S),u.current=S)}else y(w)}},[r._formValues,r._names,i,s]);gb(()=>((f.current!==r||!Oa(h.current,s))&&(f.current=r,h.current=s,j()),r._subscribe({name:s,formState:{values:!0},exact:o,callback:N=>{j(N.values)}})),[r,o,s,j]),F.useEffect(()=>r._removeUnmounted());const v=f.current!==r,g=h.current,b=F.useMemo(()=>{if(i)return null;const N=!v&&!Oa(g,s);return v||N?x():null},[i,v,s,g,x]);return b!==null?b:m}function Yne(e){const t=xb(),{name:r,disabled:s,control:a=t,shouldUnregister:i,defaultValue:o,exact:l=!0}=e,c=i6(a._names.array,r),d=F.useMemo(()=>De(a._formValues,r,De(a._defaultValues,r,o)),[a,r,o]),u=fS({control:a,name:r,defaultValue:d,exact:l}),f=Qne({control:a,name:r,exact:l}),h=F.useRef(e),m=F.useRef(void 0),y=F.useRef(a.register(r,{...e.rules,value:u,...As(e.disabled)?{disabled:e.disabled}:{}}));h.current=e;const x=F.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!De(f.errors,r)},isDirty:{enumerable:!0,get:()=>!!De(f.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!De(f.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!De(f.validatingFields,r)},error:{enumerable:!0,get:()=>De(f.errors,r)}}),[f,r]),j=F.useCallback(N=>y.current.onChange({target:{value:a6(N),name:r},type:Vo.CHANGE}),[r]),v=F.useCallback(()=>y.current.onBlur({target:{value:De(a._formValues,r),name:r},type:Vo.BLUR}),[r,a._formValues]),g=F.useCallback(N=>{const w=De(a._fields,r);w&&w._f&&N&&(w._f.ref={focus:()=>Hr(N.focus)&&N.focus(),select:()=>Hr(N.select)&&N.select(),setCustomValidity:S=>Hr(N.setCustomValidity)&&N.setCustomValidity(S),reportValidity:()=>Hr(N.reportValidity)&&N.reportValidity()})},[a._fields,r]),b=F.useMemo(()=>({name:r,value:u,...As(s)||f.disabled?{disabled:f.disabled||s}:{},onChange:j,onBlur:v,ref:g}),[r,s,f.disabled,j,v,g,u]);return F.useEffect(()=>{const N=a._options.shouldUnregister||i,w=m.current;w&&w!==r&&!c&&a.unregister(w),a.register(r,{...h.current.rules,...As(h.current.disabled)?{disabled:h.current.disabled}:{}});const S=(_,C)=>{const P=De(a._fields,_);P&&P._f&&(P._f.mount=C)};if(S(r,!0),N){const _=cn(De(a._options.defaultValues,r,h.current.defaultValue));zt(a._defaultValues,r,_),rn(De(a._formValues,r))&&zt(a._formValues,r,_)}return!c&&a.register(r),m.current=r,()=>{(c?N&&!a._state.action:N)?a.unregister(r):S(r,!1)}},[r,a,c,i]),F.useEffect(()=>{a._setDisabledField({disabled:s,name:r})},[s,r,a]),F.useMemo(()=>({field:b,formState:f,fieldState:x}),[b,f,x])}const Xne=e=>e.render(Yne(e)),h2=F.createContext(null);h2.displayName="HookFormContext";const Zne=()=>F.useContext(h2),Jne=e=>{const{children:t,watch:r,getValues:s,getFieldState:a,setError:i,clearErrors:o,setValue:l,trigger:c,formState:d,resetField:u,reset:f,handleSubmit:h,unregister:m,control:y,register:x,setFocus:j,subscribe:v}=e,g=F.useMemo(()=>({watch:r,getValues:s,getFieldState:a,setError:i,clearErrors:o,setValue:l,trigger:c,formState:d,resetField:u,reset:f,handleSubmit:h,unregister:m,control:y,register:x,setFocus:j,subscribe:v}),[o,y,d,a,s,h,x,f,u,i,j,l,v,c,m,r]);return F.createElement(h2.Provider,{value:g},F.createElement(m2.Provider,{value:g.control},t))};var c6=(e,t,r,s,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[s]:a||!0}}:{},ms=e=>Array.isArray(e)?e:[e],SO=()=>{let e=[];return{get observers(){return e},next:a=>{for(const i of e)i.next&&i.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(i=>i!==a)}}),unsubscribe:()=>{e=[]}}};function d6(e,t){const r={};for(const s in e)if(e.hasOwnProperty(s)){const a=e[s],i=t[s];if(a&&qn(a)&&i){const o=d6(a,i);qn(o)&&(r[s]=o)}else e[s]&&(r[s]=i)}return r}var Rr=e=>qn(e)&&!Object.keys(e).length,p2=e=>e.type==="file",Iv=e=>{if(!u2)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},u6=e=>e.type==="select-multiple",x2=e=>e.type==="radio",ere=e=>x2(e)||cx(e),_w=e=>Iv(e)&&e.isConnected;function tre(e,t){const r=t.slice(0,-1).length;let s=0;for(;s{for(const t in e)if(Hr(e[t]))return!0;return!1};function f6(e){return Array.isArray(e)||qn(e)&&!rre(e)}function mS(e,t={}){for(const r in e){const s=e[r];f6(s)?(t[r]=Array.isArray(s)?[]:{},mS(s,t[r])):rn(s)||(t[r]=!0)}return t}function eh(e,t,r){r||(r=mS(t));for(const s in e){const a=e[s];if(f6(a))rn(t)||uS(r[s])?r[s]=mS(a,Array.isArray(a)?[]:{}):eh(a,ds(t)?{}:t[s],r[s]);else{const i=t[s];r[s]=!Oa(a,i)}}return r}const _O={value:!1,isValid:!1},CO={value:!0,isValid:!0};var m6=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!rn(e[0].attributes.value)?rn(e[0].value)||e[0].value===""?CO:{value:e[0].value,isValid:!0}:CO:_O}return _O},h6=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>rn(e)?e:t?e===""?NaN:e&&+e:r&&Qr(e)?new Date(e):s?s(e):e;const kO={isValid:!1,value:null};var p6=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,kO):kO;function PO(e){const t=e.ref;return p2(t)?t.files:x2(t)?p6(e.refs).value:u6(t)?[...t.selectedOptions].map(({value:r})=>r):cx(t)?m6(e.refs).value:h6(rn(t.value)?e.ref.value:t.value,e)}var sre=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,are=(e,t,r,s)=>{const a={};for(const i of e){const o=De(t,i);o&&zt(a,i,o._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:s}},Dv=e=>e instanceof RegExp,Em=e=>rn(e)?e:Dv(e)?e.source:qn(e)?Dv(e.value)?e.value.source:e.value:e,ou=e=>({isOnSubmit:!e||e===ea.onSubmit,isOnBlur:e===ea.onBlur,isOnChange:e===ea.onChange,isOnAll:e===ea.all,isOnTouch:e===ea.onTouched});const AO="AsyncFunction";var ire=e=>!!e&&!!e.validate&&!!(Hr(e.validate)&&e.validate.constructor.name===AO||qn(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===AO)),ore=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),hS=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some(s=>e.startsWith(s)&&/^\.\w+/.test(e.slice(s.length))));const wu=(e,t,r,s)=>{for(const a of r||Object.keys(e)){const i=De(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],a)&&!s)return!0;if(o.ref&&t(o.ref,o.name)&&!s)return!0;if(wu(l,t))break}else if(qn(l)&&wu(l,t))break}}};function EO(e,t,r){const s=De(e,r);if(s||hb(r))return{error:s,name:r};const a=r.split(".");for(;a.length;){const i=a.join("."),o=De(t,i),l=De(e,i);if(o&&!Array.isArray(o)&&r!==i)return{name:r};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};a.pop()}return{name:r}}var lre=(e,t,r,s)=>{r(e);const{name:a,...i}=e;return Rr(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(o=>t[o]===(!s||ea.all))},cre=(e,t,r)=>!e||!t||e===t||ms(e).some(s=>s&&(r?s===t:s.startsWith(t)||t.startsWith(s))),dre=(e,t,r,s,a)=>a.isOnAll?!1:!r&&a.isOnTouch?!(t||e):(r?s.isOnBlur:a.isOnBlur)?!e:(r?s.isOnChange:a.isOnChange)?e:!0,ure=(e,t)=>!pb(De(e,t)).length&&Fn(e,t),x6=(e,t,r)=>{const s=ms(De(e,r));return zt(s,o6,t[r]),zt(e,r,s),e};function OO(e,t,r="validate"){if(Qr(e)||Array.isArray(e)&&e.every(Qr)||As(e)&&!e)return{type:r,message:Qr(e)?e:"",ref:t}}var Fd=e=>qn(e)&&!Dv(e)?e:{value:e,message:""},pS=async(e,t,r,s,a,i)=>{const{ref:o,refs:l,required:c,maxLength:d,minLength:u,min:f,max:h,pattern:m,validate:y,name:x,valueAsNumber:j,mount:v}=e._f,g=De(r,x);if(!v||t.has(x))return{};const b=l?l[0]:o,N=O=>{a&&b.reportValidity&&(b.setCustomValidity(As(O)?"":O||""),b.reportValidity())},w={},S=x2(o),_=cx(o),C=S||_,P=(j||p2(o))&&rn(o.value)&&rn(g)||Iv(o)&&o.value===""||g===""||Array.isArray(g)&&!g.length,D=c6.bind(null,x,s,w),z=(O,V,A,$=Na.maxLength,B=Na.minLength)=>{const I=O?V:A;w[x]={type:O?$:B,message:I,ref:o,...D(O?$:B,I)}};if(i?!Array.isArray(g)||!g.length:c&&(!C&&(P||ds(g))||As(g)&&!g||_&&!m6(l).isValid||S&&!p6(l).isValid)){const{value:O,message:V}=Qr(c)?{value:!!c,message:c}:Fd(c);if(O&&(w[x]={type:Na.required,message:V,ref:b,...D(Na.required,V)},!s))return N(V),w}if(!P&&(!ds(f)||!ds(h))){let O,V;const A=Fd(h),$=Fd(f);if(!ds(g)&&!isNaN(g)){const B=o.valueAsNumber||g&&+g;ds(A.value)||(O=B>A.value),ds($.value)||(V=B<$.value)}else{const B=o.valueAsDate||new Date(g),I=K=>new Date(new Date().toDateString()+" "+K),k=o.type=="time",M=o.type=="week";Qr(A.value)&&g&&(O=k?I(g)>I(A.value):M?g>A.value:B>new Date(A.value)),Qr($.value)&&g&&(V=k?I(g)+O.value,$=!ds(V.value)&&g.length<+V.value;if((A||$)&&(z(A,O.message,V.message),!s))return N(w[x].message),w}if(m&&!P&&Qr(g)){const{value:O,message:V}=Fd(m);if(Dv(O)&&!g.match(O)&&(w[x]={type:Na.pattern,message:V,ref:o,...D(Na.pattern,V)},!s))return N(V),w}if(y){if(Hr(y)){const O=await y(g,r),V=OO(O,b);if(V&&(w[x]={...V,...D(Na.validate,V.message)},!s))return N(V.message),w}else if(qn(y)){let O={};for(const V in y){if(!Rr(O)&&!s)break;const A=OO(await y[V](g,r),b,V);A&&(O={...A,...D(V,A.message)},N(A.message),s&&(w[x]=O))}if(!Rr(O)&&(w[x]={ref:b,...O},!s))return w}}return N(!0),w};const fre={mode:ea.onSubmit,reValidateMode:ea.onChange,shouldFocusError:!0};function mre(e={}){let t={...fre,...e},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:Hr(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},s={},a=qn(t.defaultValues)||qn(t.values)?cn(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:cn(a),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set},c,d=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={...u};let h={...f};const m={array:SO(),state:SO()},y=t.criteriaMode===ea.all,x=H=>J=>{clearTimeout(d),d=setTimeout(H,J)},j=async H=>{if(!o.keepIsValid&&!t.disabled&&(f.isValid||h.isValid||H)){let J;t.resolver?(J=Rr((await P()).errors),v()):J=await O({fields:s,onlyCheckValid:!0,eventType:Vo.VALID}),J!==r.isValid&&m.state.next({isValid:J})}},v=(H,J)=>{!t.disabled&&(f.isValidating||f.validatingFields||h.isValidating||h.validatingFields)&&((H||Array.from(l.mount)).forEach(ce=>{ce&&(J?zt(r.validatingFields,ce,J):Fn(r.validatingFields,ce))}),m.state.next({validatingFields:r.validatingFields,isValidating:!Rr(r.validatingFields)}))},g=H=>{const J=eh(a,i),ce=sre(H);zt(r.dirtyFields,ce,De(J,ce))},b=(H,J=[],ce,Ne,ke=!0,Ie=!0)=>{if(Ne&&ce&&!t.disabled){if(o.action=!0,Ie&&Array.isArray(De(s,H))){const Ye=ce(De(s,H),Ne.argA,Ne.argB);ke&&zt(s,H,Ye)}if(Ie&&Array.isArray(De(r.errors,H))){const Ye=ce(De(r.errors,H),Ne.argA,Ne.argB);ke&&zt(r.errors,H,Ye),ure(r.errors,H)}if((f.touchedFields||h.touchedFields)&&Ie&&Array.isArray(De(r.touchedFields,H))){const Ye=ce(De(r.touchedFields,H),Ne.argA,Ne.argB);ke&&zt(r.touchedFields,H,Ye)}(f.dirtyFields||h.dirtyFields)&&g(H),m.state.next({name:H,isDirty:A(H,J),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else zt(i,H,J)},N=(H,J)=>{zt(r.errors,H,J),m.state.next({errors:r.errors})},w=H=>{r.errors=H,m.state.next({errors:r.errors,isValid:!1})},S=(H,J,ce,Ne)=>{const ke=De(s,H);if(ke){const Ie=De(i,H,rn(ce)?De(a,H):ce);rn(Ie)||Ne&&Ne.defaultChecked||J?zt(i,H,J?Ie:PO(ke._f)):I(H,Ie),o.mount&&!o.action&&j()}},_=(H,J,ce,Ne,ke)=>{let Ie=!1,Ye=!1;const jt={name:H};if(!t.disabled){if(!ce||Ne){(f.isDirty||h.isDirty)&&(Ye=r.isDirty,r.isDirty=jt.isDirty=A(),Ie=Ye!==jt.isDirty);const Rt=Oa(De(a,H),J);Ye=!!De(r.dirtyFields,H),Rt?Fn(r.dirtyFields,H):zt(r.dirtyFields,H,!0),jt.dirtyFields=r.dirtyFields,Ie=Ie||(f.dirtyFields||h.dirtyFields)&&Ye!==!Rt}if(ce){const Rt=De(r.touchedFields,H);Rt||(zt(r.touchedFields,H,ce),jt.touchedFields=r.touchedFields,Ie=Ie||(f.touchedFields||h.touchedFields)&&Rt!==ce)}Ie&&ke&&m.state.next(jt)}return Ie?jt:{}},C=(H,J,ce,Ne)=>{const ke=De(r.errors,H),Ie=(f.isValid||h.isValid)&&As(J)&&r.isValid!==J;if(t.delayError&&ce?(c=x(()=>N(H,ce)),c(t.delayError)):(clearTimeout(d),c=null,ce?zt(r.errors,H,ce):Fn(r.errors,H)),(ce?!Oa(ke,ce):ke)||!Rr(Ne)||Ie){const Ye={...Ne,...Ie&&As(J)?{isValid:J}:{},errors:r.errors,name:H};r={...r,...Ye},m.state.next(Ye)}},P=async H=>(v(H,!0),await t.resolver(i,t.context,are(H||l.mount,s,t.criteriaMode,t.shouldUseNativeValidation))),D=async H=>{const{errors:J}=await P(H);if(v(H),H)for(const ce of H){const Ne=De(J,ce);Ne?zt(r.errors,ce,Ne):Fn(r.errors,ce)}else r.errors=J;return J},z=async({name:H,eventType:J})=>{if(e.validate){const ce=await e.validate({formValues:i,formState:r,name:H,eventType:J});if(qn(ce))for(const Ne in ce)ce[Ne]&&me(`${Sw}.${Ne}`,{message:Qr(ce.message)?ce.message:"",type:Na.validate});else Qr(ce)||!ce?me(Sw,{message:ce||"",type:Na.validate}):xe(Sw);return ce}return!0},O=async({fields:H,onlyCheckValid:J,name:ce,eventType:Ne,context:ke={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(ke.runRootValidation=!0,!await z({name:ce,eventType:Ne})&&(ke.valid=!1,J)))return ke.valid;for(const Ie in H){const Ye=H[Ie];if(Ye){const{_f:jt,...Rt}=Ye;if(jt){const Kn=l.array.has(jt.name),Mn=Ye._f&&ire(Ye._f);Mn&&f.validatingFields&&v([jt.name],!0);const xn=await pS(Ye,l.disabled,i,y,t.shouldUseNativeValidation&&!J,Kn);if(Mn&&f.validatingFields&&v([jt.name]),xn[jt.name]&&(ke.valid=!1,J)||(!J&&(De(xn,jt.name)?Kn?x6(r.errors,xn,jt.name):zt(r.errors,jt.name,xn[jt.name]):Fn(r.errors,jt.name)),e.shouldUseNativeValidation&&xn[jt.name]))break}!Rr(Rt)&&await O({context:ke,onlyCheckValid:J,fields:Rt,name:Ie,eventType:Ne})}}return ke.valid},V=()=>{for(const H of l.unMount){const J=De(s,H);J&&(J._f.refs?J._f.refs.every(ce=>!_w(ce)):!_w(J._f.ref))&&we(H)}l.unMount=new Set},A=(H,J)=>!t.disabled&&(H&&J&&zt(i,H,J),!Oa(Z(),a)),$=(H,J,ce)=>dS(H,l,{...o.mount?i:rn(J)?a:Qr(H)?{[H]:J}:J},ce,J),B=H=>pb(De(o.mount?i:a,H,t.shouldUnregister?De(a,H,[]):[])),I=(H,J,ce={})=>{const Ne=De(s,H);let ke=J;if(Ne){const Ie=Ne._f;Ie&&(!Ie.disabled&&zt(i,H,h6(J,Ie)),ke=Iv(Ie.ref)&&ds(J)?"":J,u6(Ie.ref)?[...Ie.ref.options].forEach(Ye=>Ye.selected=ke.includes(Ye.value)):Ie.refs?cx(Ie.ref)?Ie.refs.forEach(Ye=>{(!Ye.defaultChecked||!Ye.disabled)&&(Array.isArray(ke)?Ye.checked=!!ke.find(jt=>jt===Ye.value):Ye.checked=ke===Ye.value||!!ke)}):Ie.refs.forEach(Ye=>Ye.checked=Ye.value===ke):p2(Ie.ref)?Ie.ref.value="":(Ie.ref.value=ke,Ie.ref.type||m.state.next({name:H,values:cn(i)})))}(ce.shouldDirty||ce.shouldTouch)&&_(H,ke,ce.shouldTouch,ce.shouldDirty,!0),ce.shouldValidate&&re(H)},k=(H,J,ce)=>{for(const Ne in J){if(!J.hasOwnProperty(Ne))return;const ke=J[Ne],Ie=H+"."+Ne,Ye=De(s,Ie);(l.array.has(H)||qn(ke)||Ye&&!Ye._f)&&!wc(ke)?k(Ie,ke,ce):I(Ie,ke,ce)}},M=(H,J,ce={})=>{const Ne=De(s,H),ke=l.array.has(H),Ie=cn(J);zt(i,H,Ie),ke?(m.array.next({name:H,values:cn(i)}),(f.isDirty||f.dirtyFields||h.isDirty||h.dirtyFields)&&ce.shouldDirty&&(g(H),m.state.next({name:H,dirtyFields:r.dirtyFields,isDirty:A(H,Ie)}))):Ne&&!Ne._f&&!ds(Ie)?k(H,Ie,ce):I(H,Ie,ce),hS(H,l)?m.state.next({...r,name:H,values:cn(i)}):m.state.next({name:o.mount?H:void 0,values:cn(i)})},K=async H=>{o.mount=!0;const J=H.target;let ce=J.name,Ne=!0;const ke=De(s,ce),Ie=Rt=>{Ne=Number.isNaN(Rt)||wc(Rt)&&isNaN(Rt.getTime())||Oa(Rt,De(i,ce,Rt))},Ye=ou(t.mode),jt=ou(t.reValidateMode);if(ke){let Rt,Kn;const Mn=J.type?PO(ke._f):a6(H),xn=H.type===Vo.BLUR||H.type===Vo.FOCUS_OUT,Td=!ore(ke._f)&&!e.validate&&!t.resolver&&!De(r.errors,ce)&&!ke._f.deps||dre(xn,De(r.touchedFields,ce),r.isSubmitted,jt,Ye),Za=hS(ce,l,xn);zt(i,ce,Mn),xn?(!J||!J.readOnly)&&(ke._f.onBlur&&ke._f.onBlur(H),c&&c(0)):ke._f.onChange&&ke._f.onChange(H);const gm=_(ce,Mn,xn),T0=!Rr(gm)||Za;if(!xn&&m.state.next({name:ce,type:H.type,values:cn(i)}),Td)return(f.isValid||h.isValid)&&(t.mode==="onBlur"?xn&&j():xn||j()),T0&&m.state.next({name:ce,...Za?{}:gm});if(!t.resolver&&e.validate&&await z({name:ce,eventType:H.type}),!xn&&Za&&m.state.next({...r}),t.resolver){const{errors:vm}=await P([ce]);if(v([ce]),Ie(Mn),Ne){const Mx=EO(r.errors,s,ce),Rx=EO(vm,s,Mx.name||ce);Rt=Rx.error,ce=Rx.name,Kn=Rr(vm)}}else v([ce],!0),Rt=(await pS(ke,l.disabled,i,y,t.shouldUseNativeValidation))[ce],v([ce]),Ie(Mn),Ne&&(Rt?Kn=!1:(f.isValid||h.isValid)&&(Kn=await O({fields:s,onlyCheckValid:!0,name:ce,eventType:H.type})));Ne&&(ke._f.deps&&(!Array.isArray(ke._f.deps)||ke._f.deps.length>0)&&re(ke._f.deps),C(ce,Kn,Rt,gm))}},X=(H,J)=>{if(De(r.errors,J)&&H.focus)return H.focus(),1},re=async(H,J={})=>{let ce,Ne;const ke=ms(H);if(t.resolver){const Ie=await D(rn(H)?H:ke);ce=Rr(Ie),Ne=H?!ke.some(Ye=>De(Ie,Ye)):ce}else H?(Ne=(await Promise.all(ke.map(async Ie=>{const Ye=De(s,Ie);return await O({fields:Ye&&Ye._f?{[Ie]:Ye}:Ye,eventType:Vo.TRIGGER})}))).every(Boolean),!(!Ne&&!r.isValid)&&j()):Ne=ce=await O({fields:s,name:H,eventType:Vo.TRIGGER});return m.state.next({...!Qr(H)||(f.isValid||h.isValid)&&ce!==r.isValid?{}:{name:H},...t.resolver||!H?{isValid:ce}:{},errors:r.errors}),J.shouldFocus&&!Ne&&wu(s,X,H?ke:l.mount),Ne},Z=(H,J)=>{let ce={...o.mount?i:a};return J&&(ce=d6(J.dirtyFields?r.dirtyFields:r.touchedFields,ce)),rn(H)?ce:Qr(H)?De(ce,H):H.map(Ne=>De(ce,Ne))},te=(H,J)=>({invalid:!!De((J||r).errors,H),isDirty:!!De((J||r).dirtyFields,H),error:De((J||r).errors,H),isValidating:!!De(r.validatingFields,H),isTouched:!!De((J||r).touchedFields,H)}),xe=H=>{const J=H?ms(H):void 0;J==null||J.forEach(ce=>Fn(r.errors,ce)),J?J.forEach(ce=>{m.state.next({name:ce,errors:r.errors})}):m.state.next({errors:{}})},me=(H,J,ce)=>{const Ne=(De(s,H,{_f:{}})._f||{}).ref,ke=De(r.errors,H)||{},{ref:Ie,message:Ye,type:jt,...Rt}=ke;zt(r.errors,H,{...Rt,...J,ref:Ne}),m.state.next({name:H,errors:r.errors,isValid:!1}),ce&&ce.shouldFocus&&Ne&&Ne.focus&&Ne.focus()},ne=(H,J)=>Hr(H)?m.state.subscribe({next:ce=>"values"in ce&&H($(void 0,J),ce)}):$(H,J,!0),_e=H=>m.state.subscribe({next:J=>{cre(H.name,J.name,H.exact)&&lre(J,H.formState||f,Pn,H.reRenderRoot)&&H.callback({values:{...i},...r,...J,defaultValues:a})}}).unsubscribe,ue=H=>(o.mount=!0,h={...h,...H.formState},_e({...H,formState:{...u,...H.formState}})),we=(H,J={})=>{for(const ce of H?ms(H):l.mount)l.mount.delete(ce),l.array.delete(ce),J.keepValue||(Fn(s,ce),Fn(i,ce)),!J.keepError&&Fn(r.errors,ce),!J.keepDirty&&Fn(r.dirtyFields,ce),!J.keepTouched&&Fn(r.touchedFields,ce),!J.keepIsValidating&&Fn(r.validatingFields,ce),!t.shouldUnregister&&!J.keepDefaultValue&&Fn(a,ce);m.state.next({values:cn(i)}),m.state.next({...r,...J.keepDirty?{isDirty:A()}:{}}),!J.keepIsValid&&j()},ve=({disabled:H,name:J})=>{if(As(H)&&o.mount||H||l.disabled.has(J)){const ke=l.disabled.has(J)!==!!H;H?l.disabled.add(J):l.disabled.delete(J),ke&&o.mount&&!o.action&&j()}},le=(H,J={})=>{let ce=De(s,H);const Ne=As(J.disabled)||As(t.disabled),ke=!l.registerName.has(H)&&ce&&!ce._f.mount;return zt(s,H,{...ce||{},_f:{...ce&&ce._f?ce._f:{ref:{name:H}},name:H,mount:!0,...J}}),l.mount.add(H),ce&&!ke?ve({disabled:As(J.disabled)?J.disabled:t.disabled,name:H}):S(H,!0,J.value),{...Ne?{disabled:J.disabled||t.disabled}:{},...t.progressive?{required:!!J.required,min:Em(J.min),max:Em(J.max),minLength:Em(J.minLength),maxLength:Em(J.maxLength),pattern:Em(J.pattern)}:{},name:H,onChange:K,onBlur:K,ref:Ie=>{if(Ie){l.registerName.add(H),le(H,J),l.registerName.delete(H),ce=De(s,H);const Ye=rn(Ie.value)&&Ie.querySelectorAll&&Ie.querySelectorAll("input,select,textarea")[0]||Ie,jt=ere(Ye),Rt=ce._f.refs||[];if(jt?Rt.find(Kn=>Kn===Ye):Ye===ce._f.ref)return;zt(s,H,{_f:{...ce._f,...jt?{refs:[...Rt.filter(_w),Ye,...Array.isArray(De(a,H))?[{}]:[]],ref:{type:Ye.type,name:H}}:{ref:Ye}}}),S(H,!1,void 0,Ye)}else ce=De(s,H,{}),ce._f&&(ce._f.mount=!1),(t.shouldUnregister||J.shouldUnregister)&&!(i6(l.array,H)&&o.action)&&l.unMount.add(H)}}},ut=()=>t.shouldFocusError&&wu(s,X,l.mount),Se=H=>{As(H)&&(m.state.next({disabled:H}),wu(s,(J,ce)=>{const Ne=De(s,ce);Ne&&(J.disabled=Ne._f.disabled||H,Array.isArray(Ne._f.refs)&&Ne._f.refs.forEach(ke=>{ke.disabled=Ne._f.disabled||H}))},0,!1))},Ve=(H,J)=>async ce=>{let Ne;ce&&(ce.preventDefault&&ce.preventDefault(),ce.persist&&ce.persist());let ke=cn(i);if(m.state.next({isSubmitting:!0}),t.resolver){const{errors:Ie,values:Ye}=await P();v(),r.errors=Ie,ke=cn(Ye)}else await O({fields:s,eventType:Vo.SUBMIT});if(l.disabled.size)for(const Ie of l.disabled)Fn(ke,Ie);if(Fn(r.errors,o6),Rr(r.errors)){m.state.next({errors:{}});try{await H(ke,ce)}catch(Ie){Ne=Ie}}else J&&await J({...r.errors},ce),ut(),setTimeout(ut);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Rr(r.errors)&&!Ne,submitCount:r.submitCount+1,errors:r.errors}),Ne)throw Ne},pt=(H,J={})=>{De(s,H)&&(rn(J.defaultValue)?M(H,cn(De(a,H))):(M(H,J.defaultValue),zt(a,H,cn(J.defaultValue))),J.keepTouched||Fn(r.touchedFields,H),J.keepDirty||(Fn(r.dirtyFields,H),r.isDirty=J.defaultValue?A(H,cn(De(a,H))):A()),J.keepError||(Fn(r.errors,H),f.isValid&&j()),m.state.next({...r}))},Pt=(H,J={})=>{const ce=H?cn(H):a,Ne=cn(ce),ke=Rr(H),Ie=ke?a:Ne;if(J.keepDefaultValues||(a=ce),!J.keepValues){if(J.keepDirtyValues){const Ye=new Set([...l.mount,...Object.keys(eh(a,i))]);for(const jt of Array.from(Ye)){const Rt=De(r.dirtyFields,jt),Kn=De(i,jt),Mn=De(Ie,jt);Rt&&!rn(Kn)?zt(Ie,jt,Kn):!Rt&&!rn(Mn)&&M(jt,Mn)}}else{if(u2&&rn(H))for(const Ye of l.mount){const jt=De(s,Ye);if(jt&&jt._f){const Rt=Array.isArray(jt._f.refs)?jt._f.refs[0]:jt._f.ref;if(Iv(Rt)){const Kn=Rt.closest("form");if(Kn){Kn.reset();break}}}}if(J.keepFieldsRef)for(const Ye of l.mount)M(Ye,De(Ie,Ye));else s={}}i=t.shouldUnregister?J.keepDefaultValues?cn(a):{}:cn(Ie),m.array.next({values:{...Ie}}),m.state.next({values:{...Ie}})}l={mount:J.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!f.isValid||!!J.keepIsValid||!!J.keepDirtyValues||!t.shouldUnregister&&!Rr(Ie),o.watch=!!t.shouldUnregister,o.keepIsValid=!!J.keepIsValid,o.action=!1,J.keepErrors||(r.errors={}),m.state.next({submitCount:J.keepSubmitCount?r.submitCount:0,isDirty:ke?!1:J.keepDirty?r.isDirty:!!(J.keepDefaultValues&&!Oa(H,a)),isSubmitted:J.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:ke?{}:J.keepDirtyValues?J.keepDefaultValues&&i?eh(a,i):r.dirtyFields:J.keepDefaultValues&&H?eh(a,H):J.keepDirty?r.dirtyFields:{},touchedFields:J.keepTouched?r.touchedFields:{},errors:J.keepErrors?r.errors:{},isSubmitSuccessful:J.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},Qt=(H,J)=>Pt(Hr(H)?H(i):H,{...t.resetOptions,...J}),kt=(H,J={})=>{const ce=De(s,H),Ne=ce&&ce._f;if(Ne){const ke=Ne.refs?Ne.refs[0]:Ne.ref;ke.focus&&setTimeout(()=>{ke.focus(),J.shouldSelect&&Hr(ke.select)&&ke.select()})}},Pn=H=>{r={...r,...H}},pn={control:{register:le,unregister:we,getFieldState:te,handleSubmit:Ve,setError:me,_subscribe:_e,_runSchema:P,_updateIsValidating:v,_focusError:ut,_getWatch:$,_getDirty:A,_setValid:j,_setFieldArray:b,_setDisabledField:ve,_setErrors:w,_getFieldArray:B,_reset:Pt,_resetDefaultValues:()=>Hr(t.defaultValues)&&t.defaultValues().then(H=>{Qt(H,t.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:V,_disableForm:Se,_subjects:m,_proxyFormState:f,get _fields(){return s},get _formValues(){return i},get _state(){return o},set _state(H){o=H},get _defaultValues(){return a},get _names(){return l},set _names(H){l=H},get _formState(){return r},get _options(){return t},set _options(H){t={...t,...H}}},subscribe:ue,trigger:re,register:le,handleSubmit:Ve,watch:ne,setValue:M,getValues:Z,reset:Qt,resetField:pt,clearErrors:xe,unregister:we,setError:me,setFocus:kt,getFieldState:te};return{...pn,formControl:pn}}var Io=()=>{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID();const e=typeof performance>"u"?Date.now():performance.now()*1e3;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const r=(Math.random()*16+e)%16|0;return(t=="x"?r:r&3|8).toString(16)})},Cw=(e,t,r={})=>r.shouldFocus||rn(r.shouldFocus)?r.focusName||`${e}.${rn(r.focusIndex)?t:r.focusIndex}.`:"",kw=(e,t)=>[...e,...ms(t)],Pw=e=>Array.isArray(e)?e.map(()=>{}):void 0;function Aw(e,t,r){return[...e.slice(0,t),...ms(r),...e.slice(t)]}var Ew=(e,t,r)=>Array.isArray(e)?(rn(e[r])&&(e[r]=void 0),e.splice(r,0,e.splice(t,1)[0]),e):[],Ow=(e,t)=>[...ms(t),...ms(e)];function hre(e,t){let r=0;const s=[...e];for(const a of t)s.splice(a-r,1),r++;return pb(s).length?s:[]}var Tw=(e,t)=>rn(t)?[]:hre(e,ms(t).sort((r,s)=>r-s)),Mw=(e,t,r)=>{[e[t],e[r]]=[e[r],e[t]]},TO=(e,t,r)=>(e[t]=r,e);function pre(e){const t=xb(),{control:r=t,name:s,keyName:a="id",shouldUnregister:i,rules:o}=e,[l,c]=F.useState(r._getFieldArray(s)),d=F.useRef(r._getFieldArray(s).map(Io)),u=F.useRef(!1);r._names.array.add(s),F.useMemo(()=>o&&l.length>=0&&r.register(s,o),[r,s,l.length,o]),gb(()=>r._subjects.array.subscribe({next:({values:N,name:w})=>{if(w===s||!w){const S=De(N,s);Array.isArray(S)&&(c(S),d.current=S.map(Io))}}}).unsubscribe,[r,s]);const f=F.useCallback(N=>{u.current=!0,r._setFieldArray(s,N)},[r,s]),h=(N,w)=>{const S=ms(cn(N)),_=kw(r._getFieldArray(s),S);r._names.focus=Cw(s,_.length-1,w),d.current=kw(d.current,S.map(Io)),f(_),c(_),r._setFieldArray(s,_,kw,{argA:Pw(N)})},m=(N,w)=>{const S=ms(cn(N)),_=Ow(r._getFieldArray(s),S);r._names.focus=Cw(s,0,w),d.current=Ow(d.current,S.map(Io)),f(_),c(_),r._setFieldArray(s,_,Ow,{argA:Pw(N)})},y=N=>{const w=Tw(r._getFieldArray(s),N);d.current=Tw(d.current,N),f(w),c(w),!Array.isArray(De(r._fields,s))&&zt(r._fields,s,void 0),r._setFieldArray(s,w,Tw,{argA:N})},x=(N,w,S)=>{const _=ms(cn(w)),C=Aw(r._getFieldArray(s),N,_);r._names.focus=Cw(s,N,S),d.current=Aw(d.current,N,_.map(Io)),f(C),c(C),r._setFieldArray(s,C,Aw,{argA:N,argB:Pw(w)})},j=(N,w)=>{const S=r._getFieldArray(s);Mw(S,N,w),Mw(d.current,N,w),f(S),c(S),r._setFieldArray(s,S,Mw,{argA:N,argB:w},!1)},v=(N,w)=>{const S=r._getFieldArray(s);Ew(S,N,w),Ew(d.current,N,w),f(S),c(S),r._setFieldArray(s,S,Ew,{argA:N,argB:w},!1)},g=(N,w)=>{const S=cn(w),_=TO(r._getFieldArray(s),N,S);d.current=[..._].map((C,P)=>!C||P===N?Io():d.current[P]),f(_),c([..._]),r._setFieldArray(s,_,TO,{argA:N,argB:S},!0,!1)},b=N=>{const w=ms(cn(N));d.current=w.map(Io),f([...w]),c([...w]),r._setFieldArray(s,[...w],S=>S,{},!0,!1)};return F.useEffect(()=>{if(r._state.action=!1,hS(s,r._names)&&r._subjects.state.next({...r._formState}),u.current&&(!ou(r._options.mode).isOnSubmit||r._formState.isSubmitted)&&!ou(r._options.reValidateMode).isOnSubmit)if(r._options.resolver)r._runSchema([s]).then(N=>{r._updateIsValidating([s]);const w=De(N.errors,s),S=De(r._formState.errors,s);(S?!w&&S.type||w&&(S.type!==w.type||S.message!==w.message):w&&w.type)&&(w?zt(r._formState.errors,s,w):Fn(r._formState.errors,s),r._subjects.state.next({errors:r._formState.errors}))});else{const N=De(r._fields,s);N&&N._f&&!(ou(r._options.reValidateMode).isOnSubmit&&ou(r._options.mode).isOnSubmit)&&pS(N,r._names.disabled,r._formValues,r._options.criteriaMode===ea.all,r._options.shouldUseNativeValidation,!0).then(w=>!Rr(w)&&r._subjects.state.next({errors:x6(r._formState.errors,w,s)}))}r._subjects.state.next({name:s,values:cn(r._formValues)}),r._names.focus&&wu(r._fields,(N,w)=>{if(r._names.focus&&w.startsWith(r._names.focus)&&N.focus)return N.focus(),1}),r._names.focus="",r._setValid(),u.current=!1},[l,s,r]),F.useEffect(()=>(!De(r._formValues,s)&&r._setFieldArray(s),()=>{const N=(w,S)=>{const _=De(r._fields,w);_&&_._f&&(_._f.mount=S)};r._options.shouldUnregister||i?r.unregister(s):N(s,!1)}),[s,r,a,i]),{swap:F.useCallback(j,[f,s,r]),move:F.useCallback(v,[f,s,r]),prepend:F.useCallback(m,[f,s,r]),append:F.useCallback(h,[f,s,r]),remove:F.useCallback(y,[f,s,r]),insert:F.useCallback(x,[f,s,r]),update:F.useCallback(g,[f,s,r]),replace:F.useCallback(b,[f,s,r]),fields:F.useMemo(()=>l.map((N,w)=>({...N,[a]:d.current[w]||Io()})),[l,a])}}function Vl(e={}){const t=F.useRef(void 0),r=F.useRef(void 0),[s,a]=F.useState({isDirty:!1,isValidating:!1,isLoading:Hr(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:Hr(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:s},e.defaultValues&&!Hr(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:o,...l}=mre(e);t.current={...l,formState:s}}const i=t.current.control;return i._options=e,gb(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>a({...i._formState}),reRenderRoot:!0});return a(l=>({...l,isReady:!0})),i._formState.isReady=!0,o},[i]),F.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),F.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),F.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),F.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),F.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==s.isDirty&&i._subjects.state.next({isDirty:o})}},[i,s.isDirty]),F.useEffect(()=>{var o;e.values&&!Oa(e.values,r.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((o=i._options.resetOptions)===null||o===void 0)&&o.keepIsValid||i._setValid(),r.current=e.values,a(l=>({...l}))):i._resetDefaultValues()},[i,e.values]),F.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),t.current.formState=F.useMemo(()=>l6(s,i),[i,s]),t.current}const MO=(e,t,r)=>{if(e&&"reportValidity"in e){const s=De(r,t);e.setCustomValidity(s&&s.message||""),e.reportValidity()}},g6=(e,t)=>{for(const r in t.fields){const s=t.fields[r];s&&s.ref&&"reportValidity"in s.ref?MO(s.ref,r,e):s.refs&&s.refs.forEach(a=>MO(a,r,e))}},xre=(e,t)=>{t.shouldUseNativeValidation&&g6(e,t);const r={};for(const s in e){const a=De(t.fields,s),i=Object.assign(e[s]||{},{ref:a&&a.ref});if(gre(t.names||Object.keys(e),s)){const o=Object.assign({},De(r,s));zt(o,"root",i),zt(r,s,o)}else zt(r,s,i)}return r},gre=(e,t)=>e.some(r=>r.startsWith(t+"."));var vre=function(e,t){for(var r={};e.length;){var s=e[0],a=s.code,i=s.message,o=s.path.join(".");if(!r[o])if("unionErrors"in s){var l=s.unionErrors[0].errors[0];r[o]={message:l.message,type:l.code}}else r[o]={message:i,type:a};if("unionErrors"in s&&s.unionErrors.forEach(function(u){return u.errors.forEach(function(f){return e.push(f)})}),t){var c=r[o].types,d=c&&c[s.code];r[o]=c6(o,t,r,a,d?[].concat(d,s.message):s.message)}e.shift()}return r},ql=function(e,t,r){return r===void 0&&(r={}),function(s,a,i){try{return Promise.resolve(function(o,l){try{var c=Promise.resolve(e[r.mode==="sync"?"parse":"parseAsync"](s,t)).then(function(d){return i.shouldUseNativeValidation&&g6({},i),{errors:{},values:r.raw?s:d}})}catch(d){return l(d)}return c&&c.then?c.then(void 0,l):c}(0,function(o){if(function(l){return Array.isArray(l==null?void 0:l.errors)}(o))return{values:{},errors:xre(vre(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}}},Vt;(function(e){e.assertEqual=a=>{};function t(a){}e.assertIs=t;function r(a){throw new Error}e.assertNever=r,e.arrayToEnum=a=>{const i={};for(const o of a)i[o]=o;return i},e.getValidEnumValues=a=>{const i=e.objectKeys(a).filter(l=>typeof a[a[l]]!="number"),o={};for(const l of i)o[l]=a[l];return e.objectValues(o)},e.objectValues=a=>e.objectKeys(a).map(function(i){return a[i]}),e.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const i=[];for(const o in a)Object.prototype.hasOwnProperty.call(a,o)&&i.push(o);return i},e.find=(a,i)=>{for(const o of a)if(i(o))return o},e.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function s(a,i=" | "){return a.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}e.joinValues=s,e.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(Vt||(Vt={}));var RO;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(RO||(RO={}));const Je=Vt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),qo=e=>{switch(typeof e){case"undefined":return Je.undefined;case"string":return Je.string;case"number":return Number.isNaN(e)?Je.nan:Je.number;case"boolean":return Je.boolean;case"function":return Je.function;case"bigint":return Je.bigint;case"symbol":return Je.symbol;case"object":return Array.isArray(e)?Je.array:e===null?Je.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Je.promise:typeof Map<"u"&&e instanceof Map?Je.map:typeof Set<"u"&&e instanceof Set?Je.set:typeof Date<"u"&&e instanceof Date?Je.date:Je.object;default:return Je.unknown}},Pe=Vt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class mo extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){const r=t||function(i){return i.message},s={_errors:[]},a=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(a);else if(o.code==="invalid_return_type")a(o.returnTypeError);else if(o.code==="invalid_arguments")a(o.argumentsError);else if(o.path.length===0)s._errors.push(r(o));else{let l=s,c=0;for(;cr.message){const r={},s=[];for(const a of this.issues)if(a.path.length>0){const i=a.path[0];r[i]=r[i]||[],r[i].push(t(a))}else s.push(t(a));return{formErrors:s,fieldErrors:r}}get formErrors(){return this.flatten()}}mo.create=e=>new mo(e);const xS=(e,t)=>{let r;switch(e.code){case Pe.invalid_type:e.received===Je.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case Pe.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Vt.jsonStringifyReplacer)}`;break;case Pe.unrecognized_keys:r=`Unrecognized key(s) in object: ${Vt.joinValues(e.keys,", ")}`;break;case Pe.invalid_union:r="Invalid input";break;case Pe.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Vt.joinValues(e.options)}`;break;case Pe.invalid_enum_value:r=`Invalid enum value. Expected ${Vt.joinValues(e.options)}, received '${e.received}'`;break;case Pe.invalid_arguments:r="Invalid function arguments";break;case Pe.invalid_return_type:r="Invalid function return type";break;case Pe.invalid_date:r="Invalid date";break;case Pe.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:Vt.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case Pe.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case Pe.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case Pe.custom:r="Invalid input";break;case Pe.invalid_intersection_types:r="Intersection results could not be merged";break;case Pe.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case Pe.not_finite:r="Number must be finite";break;default:r=t.defaultError,Vt.assertNever(e)}return{message:r}};let yre=xS;function jre(){return yre}const bre=e=>{const{data:t,path:r,errorMaps:s,issueData:a}=e,i=[...r,...a.path||[]],o={...a,path:i};if(a.message!==void 0)return{...a,path:i,message:a.message};let l="";const c=s.filter(d=>!!d).slice().reverse();for(const d of c)l=d(o,{data:t,defaultError:l}).message;return{...a,path:i,message:l}};function qe(e,t){const r=jre(),s=bre({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===xS?void 0:xS].filter(a=>!!a)});e.common.issues.push(s)}class ns{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){const s=[];for(const a of r){if(a.status==="aborted")return bt;a.status==="dirty"&&t.dirty(),s.push(a.value)}return{status:t.value,value:s}}static async mergeObjectAsync(t,r){const s=[];for(const a of r){const i=await a.key,o=await a.value;s.push({key:i,value:o})}return ns.mergeObjectSync(t,s)}static mergeObjectSync(t,r){const s={};for(const a of r){const{key:i,value:o}=a;if(i.status==="aborted"||o.status==="aborted")return bt;i.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||a.alwaysSet)&&(s[i.value]=o.value)}return{status:t.value,value:s}}}const bt=Object.freeze({status:"aborted"}),th=e=>({status:"dirty",value:e}),fa=e=>({status:"valid",value:e}),$O=e=>e.status==="aborted",IO=e=>e.status==="dirty",Zu=e=>e.status==="valid",Lv=e=>typeof Promise<"u"&&e instanceof Promise;var nt;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(nt||(nt={}));class yi{constructor(t,r,s,a){this._cachedPath=[],this.parent=t,this.data=r,this._path=s,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const DO=(e,t)=>{if(Zu(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new mo(e.common.issues);return this._error=r,this._error}}};function _t(e){if(!e)return{};const{errorMap:t,invalid_type_error:r,required_error:s,description:a}=e;if(t&&(r||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:a}:{errorMap:(o,l)=>{const{message:c}=e;return o.code==="invalid_enum_value"?{message:c??l.defaultError}:typeof l.data>"u"?{message:c??s??l.defaultError}:o.code!=="invalid_type"?{message:l.defaultError}:{message:c??r??l.defaultError}},description:a}}class Mt{get description(){return this._def.description}_getType(t){return qo(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:qo(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ns,ctx:{common:t.parent.common,data:t.data,parsedType:qo(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const r=this._parse(t);if(Lv(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){const r=this._parse(t);return Promise.resolve(r)}parse(t,r){const s=this.safeParse(t,r);if(s.success)return s.data;throw s.error}safeParse(t,r){const s={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qo(t)},a=this._parseSync({data:t,path:s.path,parent:s});return DO(s,a)}"~validate"(t){var s,a;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qo(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:r});return Zu(i)?{value:i.value}:{issues:r.common.issues}}catch(i){(a=(s=i==null?void 0:i.message)==null?void 0:s.toLowerCase())!=null&&a.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(i=>Zu(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(t,r){const s=await this.safeParseAsync(t,r);if(s.success)return s.data;throw s.error}async safeParseAsync(t,r){const s={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qo(t)},a=this._parse({data:t,path:s.path,parent:s}),i=await(Lv(a)?a:Promise.resolve(a));return DO(s,i)}refine(t,r){const s=a=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(a):r;return this._refinement((a,i)=>{const o=t(a),l=()=>i.addIssue({code:Pe.custom,...s(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(t,r){return this._refinement((s,a)=>t(s)?!0:(a.addIssue(typeof r=="function"?r(s,a):r),!1))}_refinement(t){return new tf({schema:this,typeName:vt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return wl.create(this,this._def)}nullable(){return nf.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return hi.create(this)}promise(){return qv.create(this,this._def)}or(t){return Bv.create([this,t],this._def)}and(t){return zv.create(this,t,this._def)}transform(t){return new tf({..._t(this._def),schema:this,typeName:vt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const r=typeof t=="function"?t:()=>t;return new vS({..._t(this._def),innerType:this,defaultValue:r,typeName:vt.ZodDefault})}brand(){return new Wre({typeName:vt.ZodBranded,type:this,..._t(this._def)})}catch(t){const r=typeof t=="function"?t:()=>t;return new yS({..._t(this._def),innerType:this,catchValue:r,typeName:vt.ZodCatch})}describe(t){const r=this.constructor;return new r({...this._def,description:t})}pipe(t){return g2.create(this,t)}readonly(){return jS.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const wre=/^c[^\s-]{8,}$/i,Nre=/^[0-9a-z]+$/,Sre=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_re=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Cre=/^[a-z0-9_-]{21}$/i,kre=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Pre=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Are=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ere="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Rw;const Ore=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Tre=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Mre=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Rre=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,$re=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ire=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,v6="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Dre=new RegExp(`^${v6}$`);function y6(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function Lre(e){return new RegExp(`^${y6(e)}$`)}function Fre(e){let t=`${v6}T${y6(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function Bre(e,t){return!!((t==="v4"||!t)&&Ore.test(e)||(t==="v6"||!t)&&Mre.test(e))}function zre(e,t){if(!kre.test(e))return!1;try{const[r]=e.split(".");if(!r)return!1;const s=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),a=JSON.parse(atob(s));return!(typeof a!="object"||a===null||"typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||t&&a.alg!==t)}catch{return!1}}function Vre(e,t){return!!((t==="v4"||!t)&&Tre.test(e)||(t==="v6"||!t)&&Rre.test(e))}class oi extends Mt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Je.string){const i=this._getOrReturnCtx(t);return qe(i,{code:Pe.invalid_type,expected:Je.string,received:i.parsedType}),bt}const s=new ns;let a;for(const i of this._def.checks)if(i.kind==="min")t.data.lengthi.value&&(a=this._getOrReturnCtx(t,a),qe(a,{code:Pe.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),s.dirty());else if(i.kind==="length"){const o=t.data.length>i.value,l=t.data.lengtht.test(a),{validation:r,code:Pe.invalid_string,...nt.errToObj(s)})}_addCheck(t){return new oi({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...nt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...nt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...nt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...nt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...nt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...nt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...nt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...nt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...nt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...nt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...nt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...nt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...nt.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...nt.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...nt.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...nt.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...nt.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r==null?void 0:r.position,...nt.errToObj(r==null?void 0:r.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...nt.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...nt.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...nt.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...nt.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...nt.errToObj(r)})}nonempty(t){return this.min(1,nt.errToObj(t))}trim(){return new oi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new oi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new oi({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.valuenew oi({checks:[],typeName:vt.ZodString,coerce:(e==null?void 0:e.coerce)??!1,..._t(e)});function qre(e,t){const r=(e.toString().split(".")[1]||"").length,s=(t.toString().split(".")[1]||"").length,a=r>s?r:s,i=Number.parseInt(e.toFixed(a).replace(".","")),o=Number.parseInt(t.toFixed(a).replace(".",""));return i%o/10**a}class Qc extends Mt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Je.number){const i=this._getOrReturnCtx(t);return qe(i,{code:Pe.invalid_type,expected:Je.number,received:i.parsedType}),bt}let s;const a=new ns;for(const i of this._def.checks)i.kind==="int"?Vt.isInteger(t.data)||(s=this._getOrReturnCtx(t,s),qe(s,{code:Pe.invalid_type,expected:"integer",received:"float",message:i.message}),a.dirty()):i.kind==="min"?(i.inclusive?t.datai.value:t.data>=i.value)&&(s=this._getOrReturnCtx(t,s),qe(s,{code:Pe.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="multipleOf"?qre(t.data,i.value)!==0&&(s=this._getOrReturnCtx(t,s),qe(s,{code:Pe.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(s=this._getOrReturnCtx(t,s),qe(s,{code:Pe.not_finite,message:i.message}),a.dirty()):Vt.assertNever(i);return{status:a.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,nt.toString(r))}gt(t,r){return this.setLimit("min",t,!1,nt.toString(r))}lte(t,r){return this.setLimit("max",t,!0,nt.toString(r))}lt(t,r){return this.setLimit("max",t,!1,nt.toString(r))}setLimit(t,r,s,a){return new Qc({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:s,message:nt.toString(a)}]})}_addCheck(t){return new Qc({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:nt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:nt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:nt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:nt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:nt.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:nt.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:nt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:nt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:nt.toString(t)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.valuet.kind==="int"||t.kind==="multipleOf"&&Vt.isInteger(t.value))}get isFinite(){let t=null,r=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(r===null||s.value>r)&&(r=s.value):s.kind==="max"&&(t===null||s.valuenew Qc({checks:[],typeName:vt.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,..._t(e)});class Yc extends Mt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Je.bigint)return this._getInvalidInput(t);let s;const a=new ns;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.datai.value:t.data>=i.value)&&(s=this._getOrReturnCtx(t,s),qe(s,{code:Pe.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(s=this._getOrReturnCtx(t,s),qe(s,{code:Pe.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):Vt.assertNever(i);return{status:a.value,value:t.data}}_getInvalidInput(t){const r=this._getOrReturnCtx(t);return qe(r,{code:Pe.invalid_type,expected:Je.bigint,received:r.parsedType}),bt}gte(t,r){return this.setLimit("min",t,!0,nt.toString(r))}gt(t,r){return this.setLimit("min",t,!1,nt.toString(r))}lte(t,r){return this.setLimit("max",t,!0,nt.toString(r))}lt(t,r){return this.setLimit("max",t,!1,nt.toString(r))}setLimit(t,r,s,a){return new Yc({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:s,message:nt.toString(a)}]})}_addCheck(t){return new Yc({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:nt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:nt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:nt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:nt.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:nt.toString(r)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.valuenew Yc({checks:[],typeName:vt.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,..._t(e)});class Fv extends Mt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Je.boolean){const s=this._getOrReturnCtx(t);return qe(s,{code:Pe.invalid_type,expected:Je.boolean,received:s.parsedType}),bt}return fa(t.data)}}Fv.create=e=>new Fv({typeName:vt.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,..._t(e)});class Ju extends Mt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Je.date){const i=this._getOrReturnCtx(t);return qe(i,{code:Pe.invalid_type,expected:Je.date,received:i.parsedType}),bt}if(Number.isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return qe(i,{code:Pe.invalid_date}),bt}const s=new ns;let a;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()i.value&&(a=this._getOrReturnCtx(t,a),qe(a,{code:Pe.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),s.dirty()):Vt.assertNever(i);return{status:s.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Ju({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:nt.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:nt.toString(r)})}get minDate(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.valuenew Ju({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:vt.ZodDate,..._t(e)});class LO extends Mt{_parse(t){if(this._getType(t)!==Je.symbol){const s=this._getOrReturnCtx(t);return qe(s,{code:Pe.invalid_type,expected:Je.symbol,received:s.parsedType}),bt}return fa(t.data)}}LO.create=e=>new LO({typeName:vt.ZodSymbol,..._t(e)});class FO extends Mt{_parse(t){if(this._getType(t)!==Je.undefined){const s=this._getOrReturnCtx(t);return qe(s,{code:Pe.invalid_type,expected:Je.undefined,received:s.parsedType}),bt}return fa(t.data)}}FO.create=e=>new FO({typeName:vt.ZodUndefined,..._t(e)});class BO extends Mt{_parse(t){if(this._getType(t)!==Je.null){const s=this._getOrReturnCtx(t);return qe(s,{code:Pe.invalid_type,expected:Je.null,received:s.parsedType}),bt}return fa(t.data)}}BO.create=e=>new BO({typeName:vt.ZodNull,..._t(e)});class zO extends Mt{constructor(){super(...arguments),this._any=!0}_parse(t){return fa(t.data)}}zO.create=e=>new zO({typeName:vt.ZodAny,..._t(e)});class VO extends Mt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return fa(t.data)}}VO.create=e=>new VO({typeName:vt.ZodUnknown,..._t(e)});class Tl extends Mt{_parse(t){const r=this._getOrReturnCtx(t);return qe(r,{code:Pe.invalid_type,expected:Je.never,received:r.parsedType}),bt}}Tl.create=e=>new Tl({typeName:vt.ZodNever,..._t(e)});class qO extends Mt{_parse(t){if(this._getType(t)!==Je.undefined){const s=this._getOrReturnCtx(t);return qe(s,{code:Pe.invalid_type,expected:Je.void,received:s.parsedType}),bt}return fa(t.data)}}qO.create=e=>new qO({typeName:vt.ZodVoid,..._t(e)});class hi extends Mt{_parse(t){const{ctx:r,status:s}=this._processInputParams(t),a=this._def;if(r.parsedType!==Je.array)return qe(r,{code:Pe.invalid_type,expected:Je.array,received:r.parsedType}),bt;if(a.exactLength!==null){const o=r.data.length>a.exactLength.value,l=r.data.lengtha.maxLength.value&&(qe(r,{code:Pe.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),s.dirty()),r.common.async)return Promise.all([...r.data].map((o,l)=>a.type._parseAsync(new yi(r,o,r.path,l)))).then(o=>ns.mergeArray(s,o));const i=[...r.data].map((o,l)=>a.type._parseSync(new yi(r,o,r.path,l)));return ns.mergeArray(s,i)}get element(){return this._def.type}min(t,r){return new hi({...this._def,minLength:{value:t,message:nt.toString(r)}})}max(t,r){return new hi({...this._def,maxLength:{value:t,message:nt.toString(r)}})}length(t,r){return new hi({...this._def,exactLength:{value:t,message:nt.toString(r)}})}nonempty(t){return this.min(1,t)}}hi.create=(e,t)=>new hi({type:e,minLength:null,maxLength:null,exactLength:null,typeName:vt.ZodArray,..._t(t)});function Ud(e){if(e instanceof Hn){const t={};for(const r in e.shape){const s=e.shape[r];t[r]=wl.create(Ud(s))}return new Hn({...e._def,shape:()=>t})}else return e instanceof hi?new hi({...e._def,type:Ud(e.element)}):e instanceof wl?wl.create(Ud(e.unwrap())):e instanceof nf?nf.create(Ud(e.unwrap())):e instanceof Xc?Xc.create(e.items.map(t=>Ud(t))):e}class Hn extends Mt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),r=Vt.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==Je.object){const d=this._getOrReturnCtx(t);return qe(d,{code:Pe.invalid_type,expected:Je.object,received:d.parsedType}),bt}const{status:s,ctx:a}=this._processInputParams(t),{shape:i,keys:o}=this._getCached(),l=[];if(!(this._def.catchall instanceof Tl&&this._def.unknownKeys==="strip"))for(const d in a.data)o.includes(d)||l.push(d);const c=[];for(const d of o){const u=i[d],f=a.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new yi(a,f,a.path,d)),alwaysSet:d in a.data})}if(this._def.catchall instanceof Tl){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of l)c.push({key:{status:"valid",value:u},value:{status:"valid",value:a.data[u]}});else if(d==="strict")l.length>0&&(qe(a,{code:Pe.unrecognized_keys,keys:l}),s.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const u of l){const f=a.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new yi(a,f,a.path,u)),alwaysSet:u in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of c){const f=await u.key,h=await u.value;d.push({key:f,value:h,alwaysSet:u.alwaysSet})}return d}).then(d=>ns.mergeObjectSync(s,d)):ns.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(t){return nt.errToObj,new Hn({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,s)=>{var i,o;const a=((o=(i=this._def).errorMap)==null?void 0:o.call(i,r,s).message)??s.defaultError;return r.code==="unrecognized_keys"?{message:nt.errToObj(t).message??a}:{message:a}}}:{}})}strip(){return new Hn({...this._def,unknownKeys:"strip"})}passthrough(){return new Hn({...this._def,unknownKeys:"passthrough"})}extend(t){return new Hn({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Hn({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:vt.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new Hn({...this._def,catchall:t})}pick(t){const r={};for(const s of Vt.objectKeys(t))t[s]&&this.shape[s]&&(r[s]=this.shape[s]);return new Hn({...this._def,shape:()=>r})}omit(t){const r={};for(const s of Vt.objectKeys(this.shape))t[s]||(r[s]=this.shape[s]);return new Hn({...this._def,shape:()=>r})}deepPartial(){return Ud(this)}partial(t){const r={};for(const s of Vt.objectKeys(this.shape)){const a=this.shape[s];t&&!t[s]?r[s]=a:r[s]=a.optional()}return new Hn({...this._def,shape:()=>r})}required(t){const r={};for(const s of Vt.objectKeys(this.shape))if(t&&!t[s])r[s]=this.shape[s];else{let i=this.shape[s];for(;i instanceof wl;)i=i._def.innerType;r[s]=i}return new Hn({...this._def,shape:()=>r})}keyof(){return j6(Vt.objectKeys(this.shape))}}Hn.create=(e,t)=>new Hn({shape:()=>e,unknownKeys:"strip",catchall:Tl.create(),typeName:vt.ZodObject,..._t(t)});Hn.strictCreate=(e,t)=>new Hn({shape:()=>e,unknownKeys:"strict",catchall:Tl.create(),typeName:vt.ZodObject,..._t(t)});Hn.lazycreate=(e,t)=>new Hn({shape:e,unknownKeys:"strip",catchall:Tl.create(),typeName:vt.ZodObject,..._t(t)});class Bv extends Mt{_parse(t){const{ctx:r}=this._processInputParams(t),s=this._def.options;function a(i){for(const l of i)if(l.result.status==="valid")return l.result;for(const l of i)if(l.result.status==="dirty")return r.common.issues.push(...l.ctx.common.issues),l.result;const o=i.map(l=>new mo(l.ctx.common.issues));return qe(r,{code:Pe.invalid_union,unionErrors:o}),bt}if(r.common.async)return Promise.all(s.map(async i=>{const o={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(a);{let i;const o=[];for(const c of s){const d={...r,common:{...r.common,issues:[]},parent:null},u=c._parseSync({data:r.data,path:r.path,parent:d});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:d}),d.common.issues.length&&o.push(d.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;const l=o.map(c=>new mo(c));return qe(r,{code:Pe.invalid_union,unionErrors:l}),bt}}get options(){return this._def.options}}Bv.create=(e,t)=>new Bv({options:e,typeName:vt.ZodUnion,..._t(t)});function gS(e,t){const r=qo(e),s=qo(t);if(e===t)return{valid:!0,data:e};if(r===Je.object&&s===Je.object){const a=Vt.objectKeys(t),i=Vt.objectKeys(e).filter(l=>a.indexOf(l)!==-1),o={...e,...t};for(const l of i){const c=gS(e[l],t[l]);if(!c.valid)return{valid:!1};o[l]=c.data}return{valid:!0,data:o}}else if(r===Je.array&&s===Je.array){if(e.length!==t.length)return{valid:!1};const a=[];for(let i=0;i{if($O(i)||$O(o))return bt;const l=gS(i.value,o.value);return l.valid?((IO(i)||IO(o))&&r.dirty(),{status:r.value,value:l.data}):(qe(s,{code:Pe.invalid_intersection_types}),bt)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([i,o])=>a(i,o)):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}zv.create=(e,t,r)=>new zv({left:e,right:t,typeName:vt.ZodIntersection,..._t(r)});class Xc extends Mt{_parse(t){const{status:r,ctx:s}=this._processInputParams(t);if(s.parsedType!==Je.array)return qe(s,{code:Pe.invalid_type,expected:Je.array,received:s.parsedType}),bt;if(s.data.lengththis._def.items.length&&(qe(s,{code:Pe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...s.data].map((o,l)=>{const c=this._def.items[l]||this._def.rest;return c?c._parse(new yi(s,o,s.path,l)):null}).filter(o=>!!o);return s.common.async?Promise.all(i).then(o=>ns.mergeArray(r,o)):ns.mergeArray(r,i)}get items(){return this._def.items}rest(t){return new Xc({...this._def,rest:t})}}Xc.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Xc({items:e,typeName:vt.ZodTuple,rest:null,..._t(t)})};class Vv extends Mt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:r,ctx:s}=this._processInputParams(t);if(s.parsedType!==Je.object)return qe(s,{code:Pe.invalid_type,expected:Je.object,received:s.parsedType}),bt;const a=[],i=this._def.keyType,o=this._def.valueType;for(const l in s.data)a.push({key:i._parse(new yi(s,l,s.path,l)),value:o._parse(new yi(s,s.data[l],s.path,l)),alwaysSet:l in s.data});return s.common.async?ns.mergeObjectAsync(r,a):ns.mergeObjectSync(r,a)}get element(){return this._def.valueType}static create(t,r,s){return r instanceof Mt?new Vv({keyType:t,valueType:r,typeName:vt.ZodRecord,..._t(s)}):new Vv({keyType:oi.create(),valueType:t,typeName:vt.ZodRecord,..._t(r)})}}class WO extends Mt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:r,ctx:s}=this._processInputParams(t);if(s.parsedType!==Je.map)return qe(s,{code:Pe.invalid_type,expected:Je.map,received:s.parsedType}),bt;const a=this._def.keyType,i=this._def.valueType,o=[...s.data.entries()].map(([l,c],d)=>({key:a._parse(new yi(s,l,s.path,[d,"key"])),value:i._parse(new yi(s,c,s.path,[d,"value"]))}));if(s.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const c of o){const d=await c.key,u=await c.value;if(d.status==="aborted"||u.status==="aborted")return bt;(d.status==="dirty"||u.status==="dirty")&&r.dirty(),l.set(d.value,u.value)}return{status:r.value,value:l}})}else{const l=new Map;for(const c of o){const d=c.key,u=c.value;if(d.status==="aborted"||u.status==="aborted")return bt;(d.status==="dirty"||u.status==="dirty")&&r.dirty(),l.set(d.value,u.value)}return{status:r.value,value:l}}}}WO.create=(e,t,r)=>new WO({valueType:t,keyType:e,typeName:vt.ZodMap,..._t(r)});class Zh extends Mt{_parse(t){const{status:r,ctx:s}=this._processInputParams(t);if(s.parsedType!==Je.set)return qe(s,{code:Pe.invalid_type,expected:Je.set,received:s.parsedType}),bt;const a=this._def;a.minSize!==null&&s.data.sizea.maxSize.value&&(qe(s,{code:Pe.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());const i=this._def.valueType;function o(c){const d=new Set;for(const u of c){if(u.status==="aborted")return bt;u.status==="dirty"&&r.dirty(),d.add(u.value)}return{status:r.value,value:d}}const l=[...s.data.values()].map((c,d)=>i._parse(new yi(s,c,s.path,d)));return s.common.async?Promise.all(l).then(c=>o(c)):o(l)}min(t,r){return new Zh({...this._def,minSize:{value:t,message:nt.toString(r)}})}max(t,r){return new Zh({...this._def,maxSize:{value:t,message:nt.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}}Zh.create=(e,t)=>new Zh({valueType:e,minSize:null,maxSize:null,typeName:vt.ZodSet,..._t(t)});class UO extends Mt{get schema(){return this._def.getter()}_parse(t){const{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}UO.create=(e,t)=>new UO({getter:e,typeName:vt.ZodLazy,..._t(t)});class KO extends Mt{_parse(t){if(t.data!==this._def.value){const r=this._getOrReturnCtx(t);return qe(r,{received:r.data,code:Pe.invalid_literal,expected:this._def.value}),bt}return{status:"valid",value:t.data}}get value(){return this._def.value}}KO.create=(e,t)=>new KO({value:e,typeName:vt.ZodLiteral,..._t(t)});function j6(e,t){return new ef({values:e,typeName:vt.ZodEnum,..._t(t)})}class ef extends Mt{_parse(t){if(typeof t.data!="string"){const r=this._getOrReturnCtx(t),s=this._def.values;return qe(r,{expected:Vt.joinValues(s),received:r.parsedType,code:Pe.invalid_type}),bt}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const r=this._getOrReturnCtx(t),s=this._def.values;return qe(r,{received:r.data,code:Pe.invalid_enum_value,options:s}),bt}return fa(t.data)}get options(){return this._def.values}get enum(){const t={};for(const r of this._def.values)t[r]=r;return t}get Values(){const t={};for(const r of this._def.values)t[r]=r;return t}get Enum(){const t={};for(const r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return ef.create(t,{...this._def,...r})}exclude(t,r=this._def){return ef.create(this.options.filter(s=>!t.includes(s)),{...this._def,...r})}}ef.create=j6;class GO extends Mt{_parse(t){const r=Vt.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(t);if(s.parsedType!==Je.string&&s.parsedType!==Je.number){const a=Vt.objectValues(r);return qe(s,{expected:Vt.joinValues(a),received:s.parsedType,code:Pe.invalid_type}),bt}if(this._cache||(this._cache=new Set(Vt.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const a=Vt.objectValues(r);return qe(s,{received:s.data,code:Pe.invalid_enum_value,options:a}),bt}return fa(t.data)}get enum(){return this._def.values}}GO.create=(e,t)=>new GO({values:e,typeName:vt.ZodNativeEnum,..._t(t)});class qv extends Mt{unwrap(){return this._def.type}_parse(t){const{ctx:r}=this._processInputParams(t);if(r.parsedType!==Je.promise&&r.common.async===!1)return qe(r,{code:Pe.invalid_type,expected:Je.promise,received:r.parsedType}),bt;const s=r.parsedType===Je.promise?r.data:Promise.resolve(r.data);return fa(s.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}qv.create=(e,t)=>new qv({type:e,typeName:vt.ZodPromise,..._t(t)});class tf extends Mt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===vt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:r,ctx:s}=this._processInputParams(t),a=this._def.effect||null,i={addIssue:o=>{qe(s,o),o.fatal?r.abort():r.dirty()},get path(){return s.path}};if(i.addIssue=i.addIssue.bind(i),a.type==="preprocess"){const o=a.transform(s.data,i);if(s.common.async)return Promise.resolve(o).then(async l=>{if(r.value==="aborted")return bt;const c=await this._def.schema._parseAsync({data:l,path:s.path,parent:s});return c.status==="aborted"?bt:c.status==="dirty"||r.value==="dirty"?th(c.value):c});{if(r.value==="aborted")return bt;const l=this._def.schema._parseSync({data:o,path:s.path,parent:s});return l.status==="aborted"?bt:l.status==="dirty"||r.value==="dirty"?th(l.value):l}}if(a.type==="refinement"){const o=l=>{const c=a.refinement(l,i);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(s.common.async===!1){const l=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return l.status==="aborted"?bt:(l.status==="dirty"&&r.dirty(),o(l.value),{status:r.value,value:l.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(l=>l.status==="aborted"?bt:(l.status==="dirty"&&r.dirty(),o(l.value).then(()=>({status:r.value,value:l.value}))))}if(a.type==="transform")if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Zu(o))return bt;const l=a.transform(o.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:l}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>Zu(o)?Promise.resolve(a.transform(o.value,i)).then(l=>({status:r.value,value:l})):bt);Vt.assertNever(a)}}tf.create=(e,t,r)=>new tf({schema:e,typeName:vt.ZodEffects,effect:t,..._t(r)});tf.createWithPreprocess=(e,t,r)=>new tf({schema:t,effect:{type:"preprocess",transform:e},typeName:vt.ZodEffects,..._t(r)});class wl extends Mt{_parse(t){return this._getType(t)===Je.undefined?fa(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}wl.create=(e,t)=>new wl({innerType:e,typeName:vt.ZodOptional,..._t(t)});class nf extends Mt{_parse(t){return this._getType(t)===Je.null?fa(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}nf.create=(e,t)=>new nf({innerType:e,typeName:vt.ZodNullable,..._t(t)});class vS extends Mt{_parse(t){const{ctx:r}=this._processInputParams(t);let s=r.data;return r.parsedType===Je.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}vS.create=(e,t)=>new vS({innerType:e,typeName:vt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,..._t(t)});class yS extends Mt{_parse(t){const{ctx:r}=this._processInputParams(t),s={...r,common:{...r.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return Lv(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new mo(s.common.issues)},input:s.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new mo(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}yS.create=(e,t)=>new yS({innerType:e,typeName:vt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,..._t(t)});class HO extends Mt{_parse(t){if(this._getType(t)!==Je.nan){const s=this._getOrReturnCtx(t);return qe(s,{code:Pe.invalid_type,expected:Je.nan,received:s.parsedType}),bt}return{status:"valid",value:t.data}}}HO.create=e=>new HO({typeName:vt.ZodNaN,..._t(e)});class Wre extends Mt{_parse(t){const{ctx:r}=this._processInputParams(t),s=r.data;return this._def.type._parse({data:s,path:r.path,parent:r})}unwrap(){return this._def.type}}class g2 extends Mt{_parse(t){const{status:r,ctx:s}=this._processInputParams(t);if(s.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?bt:i.status==="dirty"?(r.dirty(),th(i.value)):this._def.out._parseAsync({data:i.value,path:s.path,parent:s})})();{const a=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?bt:a.status==="dirty"?(r.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:s.path,parent:s})}}static create(t,r){return new g2({in:t,out:r,typeName:vt.ZodPipeline})}}class jS extends Mt{_parse(t){const r=this._def.innerType._parse(t),s=a=>(Zu(a)&&(a.value=Object.freeze(a.value)),a);return Lv(r)?r.then(a=>s(a)):s(r)}unwrap(){return this._def.innerType}}jS.create=(e,t)=>new jS({innerType:e,typeName:vt.ZodReadonly,..._t(t)});var vt;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(vt||(vt={}));const wn=oi.create,Js=Qc.create;Yc.create;const Ho=Fv.create,Ure=Ju.create;Tl.create;const vb=hi.create,No=Hn.create;Bv.create;zv.create;Xc.create;const Kre=Vv.create,Ta=ef.create;qv.create;wl.create;nf.create;const Nl={string:e=>oi.create({...e,coerce:!0}),number:e=>Qc.create({...e,coerce:!0}),boolean:e=>Fv.create({...e,coerce:!0}),bigint:e=>Yc.create({...e,coerce:!0}),date:e=>Ju.create({...e,coerce:!0})},Wl=Jne,b6=p.createContext({}),et=({...e})=>n.jsx(b6.Provider,{value:{name:e.name},children:n.jsx(Xne,{...e})}),yb=()=>{const e=p.useContext(b6),t=p.useContext(w6),{getFieldState:r,formState:s}=Zne(),a=r(e.name,s);if(!e)throw new Error("useFormField should be used within ");const{id:i}=t;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...a}},w6=p.createContext({}),tt=p.forwardRef(({className:e,...t},r)=>{const s=p.useId();return n.jsx(w6.Provider,{value:{id:s},children:n.jsx("div",{ref:r,className:he("space-y-2",e),...t})})});tt.displayName="FormItem";const at=p.forwardRef(({className:e,...t},r)=>{const{error:s,formItemId:a}=yb();return n.jsx(q,{ref:r,className:he(s&&"text-destructive",e),htmlFor:a,...t})});at.displayName="FormLabel";const rt=p.forwardRef(({...e},t)=>{const{error:r,formItemId:s,formDescriptionId:a,formMessageId:i}=yb();return n.jsx(Bl,{ref:t,id:s,"aria-describedby":r?`${a} ${i}`:`${a}`,"aria-invalid":!!r,...e})});rt.displayName="FormControl";const Jh=p.forwardRef(({className:e,...t},r)=>{const{formDescriptionId:s}=yb();return n.jsx("p",{ref:r,id:s,className:he("text-sm text-muted-foreground",e),...t})});Jh.displayName="FormDescription";const ot=p.forwardRef(({className:e,children:t,...r},s)=>{const{error:a,formMessageId:i}=yb(),o=a?String(a==null?void 0:a.message):t;return o?n.jsx("p",{ref:s,id:i,className:he("text-sm font-medium text-destructive",e),...r,children:o}):null});ot.displayName="FormMessage";var v2="Radio",[Gre,N6]=lr(v2),[Hre,Qre]=Gre(v2),S6=p.forwardRef((e,t)=>{const{__scopeRadio:r,name:s,checked:a=!1,required:i,disabled:o,value:l="on",onCheck:c,form:d,...u}=e,[f,h]=p.useState(null),m=dt(t,j=>h(j)),y=p.useRef(!1),x=f?d||!!f.closest("form"):!0;return n.jsxs(Hre,{scope:r,checked:a,disabled:o,children:[n.jsx(We.button,{type:"button",role:"radio","aria-checked":a,"data-state":P6(a),"data-disabled":o?"":void 0,disabled:o,value:l,...u,ref:m,onClick:be(e.onClick,j=>{a||c==null||c(),x&&(y.current=j.isPropagationStopped(),y.current||j.stopPropagation())})}),x&&n.jsx(k6,{control:f,bubbles:!y.current,name:s,value:l,checked:a,required:i,disabled:o,form:d,style:{transform:"translateX(-100%)"}})]})});S6.displayName=v2;var _6="RadioIndicator",C6=p.forwardRef((e,t)=>{const{__scopeRadio:r,forceMount:s,...a}=e,i=Qre(_6,r);return n.jsx(Jn,{present:s||i.checked,children:n.jsx(We.span,{"data-state":P6(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:t})})});C6.displayName=_6;var Yre="RadioBubbleInput",k6=p.forwardRef(({__scopeRadio:e,control:t,checked:r,bubbles:s=!0,...a},i)=>{const o=p.useRef(null),l=dt(o,i),c=lx(r),d=Zp(t);return p.useEffect(()=>{const u=o.current;if(!u)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==r&&m){const y=new Event("click",{bubbles:s});m.call(u,r),u.dispatchEvent(y)}},[c,r,s]),n.jsx(We.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:l,style:{...a.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});k6.displayName=Yre;function P6(e){return e?"checked":"unchecked"}var Xre=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],jb="RadioGroup",[Zre]=lr(jb,[Hf,N6]),A6=Hf(),E6=N6(),[Jre,ese]=Zre(jb),O6=p.forwardRef((e,t)=>{const{__scopeRadioGroup:r,name:s,defaultValue:a,value:i,required:o=!1,disabled:l=!1,orientation:c,dir:d,loop:u=!0,onValueChange:f,...h}=e,m=A6(r),y=zl(d),[x,j]=zr({prop:i,defaultProp:a??null,onChange:f,caller:jb});return n.jsx(Jre,{scope:r,name:s,required:o,disabled:l,value:x,onValueChange:j,children:n.jsx(Qk,{asChild:!0,...m,orientation:c,dir:y,loop:u,children:n.jsx(We.div,{role:"radiogroup","aria-required":o,"aria-orientation":c,"data-disabled":l?"":void 0,dir:y,...h,ref:t})})})});O6.displayName=jb;var T6="RadioGroupItem",M6=p.forwardRef((e,t)=>{const{__scopeRadioGroup:r,disabled:s,...a}=e,i=ese(T6,r),o=i.disabled||s,l=A6(r),c=E6(r),d=p.useRef(null),u=dt(t,d),f=i.value===a.value,h=p.useRef(!1);return p.useEffect(()=>{const m=x=>{Xre.includes(x.key)&&(h.current=!0)},y=()=>h.current=!1;return document.addEventListener("keydown",m),document.addEventListener("keyup",y),()=>{document.removeEventListener("keydown",m),document.removeEventListener("keyup",y)}},[]),n.jsx(Yk,{asChild:!0,...l,focusable:!o,active:f,children:n.jsx(S6,{disabled:o,required:i.required,checked:f,...c,...a,name:i.name,ref:u,onCheck:()=>i.onValueChange(a.value),onKeyDown:be(m=>{m.key==="Enter"&&m.preventDefault()}),onFocus:be(a.onFocus,()=>{var m;h.current&&((m=d.current)==null||m.click())})})})});M6.displayName=T6;var tse="RadioGroupIndicator",R6=p.forwardRef((e,t)=>{const{__scopeRadioGroup:r,...s}=e,a=E6(r);return n.jsx(C6,{...a,...s,ref:t})});R6.displayName=tse;var $6=O6,I6=M6,nse=R6;const es=p.forwardRef(({className:e,...t},r)=>n.jsx($6,{className:he("grid gap-2",e),...t,ref:r}));es.displayName=$6.displayName;const Bn=p.forwardRef(({className:e,...t},r)=>n.jsx(I6,{ref:r,className:he("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:n.jsx(nse,{className:"flex items-center justify-center",children:n.jsx(_j,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Bn.displayName=I6.displayName;function rse(e,t=[]){let r=[];function s(i,o){const l=p.createContext(o);l.displayName=i+"Context";const c=r.length;r=[...r,o];const d=f=>{var v;const{scope:h,children:m,...y}=f,x=((v=h==null?void 0:h[e])==null?void 0:v[c])||l,j=p.useMemo(()=>y,Object.values(y));return n.jsx(x.Provider,{value:j,children:m})};d.displayName=i+"Provider";function u(f,h){var x;const m=((x=h==null?void 0:h[e])==null?void 0:x[c])||l,y=p.useContext(m);if(y)return y;if(o!==void 0)return o;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[d,u]}const a=()=>{const i=r.map(o=>p.createContext(o));return function(l){const c=(l==null?void 0:l[e])||i;return p.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return a.scopeName=e,[s,sse(a,...t)]}function sse(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const s=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=s.reduce((l,{useScope:c,scopeName:d})=>{const f=c(i)[`__scope${d}`];return{...l,...f}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return r.scopeName=t.scopeName,r}var ase=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],D6=ase.reduce((e,t)=>{const r=ex(`Primitive.${t}`),s=p.forwardRef((a,i)=>{const{asChild:o,...l}=a,c=o?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(c,{...l,ref:i})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),y2="Progress",j2=100,[ise]=rse(y2),[ose,lse]=ise(y2),L6=p.forwardRef((e,t)=>{const{__scopeProgress:r,value:s=null,max:a,getValueLabel:i=cse,...o}=e;(a||a===0)&&!QO(a)&&console.error(dse(`${a}`,"Progress"));const l=QO(a)?a:j2;s!==null&&!YO(s,l)&&console.error(use(`${s}`,"Progress"));const c=YO(s,l)?s:null,d=Wv(c)?i(c,l):void 0;return n.jsx(ose,{scope:r,value:c,max:l,children:n.jsx(D6.div,{"aria-valuemax":l,"aria-valuemin":0,"aria-valuenow":Wv(c)?c:void 0,"aria-valuetext":d,role:"progressbar","data-state":z6(c,l),"data-value":c??void 0,"data-max":l,...o,ref:t})})});L6.displayName=y2;var F6="ProgressIndicator",B6=p.forwardRef((e,t)=>{const{__scopeProgress:r,...s}=e,a=lse(F6,r);return n.jsx(D6.div,{"data-state":z6(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...s,ref:t})});B6.displayName=F6;function cse(e,t){return`${Math.round(e/t*100)}%`}function z6(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function Wv(e){return typeof e=="number"}function QO(e){return Wv(e)&&!isNaN(e)&&e>0}function YO(e,t){return Wv(e)&&!isNaN(e)&&e<=t&&e>=0}function dse(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${j2}\`.`}function use(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be: - a positive number - less than the value passed to \`max\` (or ${j2} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var V6=L6,fse=B6;const kn=p.forwardRef(({className:e,value:t,...r},s)=>n.jsx(V6,{ref:s,className:he("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...r,children:n.jsx(fse,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));kn.displayName=V6.displayName;const de={auth:{user:["auth","user"]},users:{all:["users"],list:e=>["users","list",e],detail:e=>["users",e]},entities:{all:["entities"],list:e=>["entities","list",e],detail:e=>["entities",e],roles:e=>["entities",e,"roles"],permissions:e=>["entities",e,"permissions"]},exams:{all:["exams"],list:(e,t)=>["exams",e,t],detail:(e,t)=>["exams",e,t],rubrics:e=>["exams","rubrics",e],rubricGroups:e=>["exams","rubric-groups",e],structures:e=>["exams","structures",e],avatars:["exams","avatars"]},assignments:{all:["assignments"],list:e=>["assignments","list",e],detail:e=>["assignments",e]},classrooms:{all:["classrooms"],list:e=>["classrooms","list",e],detail:e=>["classrooms",e]},stats:{sessions:e=>["stats","sessions",e],stats:e=>["stats","stats",e],statistical:e=>["stats","statistical",e],performance:e=>["stats","performance",e]},training:{all:["training"],tips:e=>["training","tips",e],walkthroughs:e=>["training","walkthroughs",e]},subscriptions:{packages:["subscriptions","packages"],payments:e=>["subscriptions","payments",e],discounts:e=>["subscriptions","discounts",e]},tickets:{all:["tickets"],list:e=>["tickets","list",e],assigned:["tickets","assigned"]},approvals:{all:["approvals"],list:e=>["approvals","list",e]},taxonomy:{subjects:["taxonomy","subjects"],subject:e=>["taxonomy","subjects",e],tree:e=>["taxonomy","tree",e],domains:e=>["taxonomy","domains",e],topics:e=>["taxonomy","topics",e]},adaptive:{proficiency:e=>["adaptive","proficiency",e],summary:["adaptive","proficiency","summary"],plan:e=>["adaptive","plan",e],topicContent:e=>["adaptive","topic",e,"content"],diagnostic:e=>["adaptive","diagnostic",e]},resources:{all:["resources"],list:e=>["resources","list",e]},lms:{courses:e=>["lms","courses",e],course:e=>["lms","courses",e],students:e=>["lms","students",e],teachers:e=>["lms","teachers",e],batches:e=>["lms","batches",e],batch:e=>["lms","batches",e],timetable:e=>["lms","timetable",e],attendance:e=>["lms","attendance",e],grades:e=>["lms","grades",e]},analytics:{student:e=>["analytics","student",e],class:e=>["analytics","class",e],subject:e=>["analytics","subject",e],contentGaps:e=>["analytics","content-gaps",e],alerts:["analytics","alerts"]},academicYears:{all:["academic-years"],list:e=>["academic-years","list",e],detail:e=>["academic-years",e]},academicTerms:{all:["academic-terms"],list:e=>["academic-terms","list",e],detail:e=>["academic-terms",e]},departments:{all:["departments"],list:e=>["departments","list",e],detail:e=>["departments",e]},admissionRegisters:{all:["admission-registers"],list:e=>["admission-registers","list",e],detail:e=>["admission-registers",e]},admissions:{all:["admissions"],list:e=>["admissions","list",e],detail:e=>["admissions",e]},instExamSessions:{all:["inst-exam-sessions"],list:e=>["inst-exam-sessions","list",e],detail:e=>["inst-exam-sessions",e]},examTypes:{all:["exam-types"],list:e=>["exam-types","list",e]},gradeConfigs:{all:["grade-configs"],list:e=>["grade-configs","list",e]},resultTemplates:{all:["result-templates"],list:e=>["result-templates","list",e]},marksheets:{all:["marksheets"],list:e=>["marksheets","list",e],detail:e=>["marksheets",e]},courseAssignments:{all:["course-assignments"],list:e=>["course-assignments","list",e],detail:e=>["course-assignments",e]},assignmentTypes:{all:["assignment-types"],list:e=>["assignment-types","list",e]},subjectRegistrations:{all:["subject-registrations"],list:e=>["subject-registrations","list",e],available:e=>["subject-registrations","available",e]},chapters:e=>["chapters","list",e],chapter:e=>["chapters","detail",e],chapterMaterials:e=>["chapter-materials",e],chapterProgress:e=>["chapter-progress",e],discussionBoards:e=>["discussion-boards",e],posts:(e,t)=>["posts",e,t],announcements:e=>["announcements",e],messages:e=>["messages",e],sentMessages:e=>["messages","sent",e],unreadMessages:["messages","unread-count"],notifications:e=>["notifications",e],unreadNotifications:["notifications","unread-count"],notificationRules:["notification-rules"],notificationPreferences:["notification-preferences"],faqCategories:e=>["faq","categories",e],faqItems:e=>["faq","items",e],studentLeaves:{all:["student-leaves"],list:e=>["student-leaves","list",e]},studentLeaveTypes:{all:["student-leave-types"],list:e=>["student-leave-types","list",e]},feesPlans:{all:["fees-plans"],list:e=>["fees-plans","list",e],detail:e=>["fees-plans",e]},studentFees:{all:["student-fees"],list:e=>["student-fees","list",e]},feesTerms:{all:["fees-terms"],list:e=>["fees-terms","list",e]},lessons:{all:["lessons"],list:e=>["lessons","list",e]},gradebooks:{all:["gradebooks"],list:e=>["gradebooks","list",e]},gradebookLines:{all:["gradebook-lines"],list:e=>["gradebook-lines","list",e]},gradingAssignments:{all:["grading-assignments"],list:e=>["grading-assignments","list",e]},studentProgress:{all:["student-progress"],list:e=>["student-progress","list",e]},libraryMedia:{all:["library-media"],list:e=>["library-media","list",e]},libraryMovements:{all:["library-movements"],list:e=>["library-movements","list",e]},libraryCards:{all:["library-cards"],list:e=>["library-cards","list",e]},activities:{all:["activities"],list:e=>["activities","list",e]},activityTypes:{all:["activity-types"],list:e=>["activity-types","list",e]},facilities:{all:["facilities"],list:e=>["facilities","list",e]},assets:{all:["assets"],list:e=>["assets","list",e]},signup:{goals:["signup","goals"]},placement:{results:e=>["placement","results",e],speakingStatus:e=>["placement","speaking-status",e],learningPath:e=>["placement","learning-path",e]},examTemplates:{international:["exam-templates","international"],custom:["exam-templates","custom"],detail:e=>["exam-templates",e]},ieltsExam:{skills:e=>["ielts-exam",e,"skills"],contentPool:(e,t)=>["ielts-exam",e,"content-pool",t],validation:e=>["ielts-exam",e,"validation"]},examSession:{session:e=>["exam-session",e],status:e=>["exam-session",e,"status"]},grading:{queue:e=>["grading","queue",e],response:(e,t)=>["grading",e,"response",t],rubric:(e,t)=>["grading",e,"rubric",t]},courseGeneration:{gapAnalysis:(e,t)=>["course-gen","gap",e,t],course:e=>["course-gen","course",e]},aiCourse:{course:e=>["ai-course",e],tracks:e=>["ai-course",e,"tracks"],quality:e=>["ai-course",e,"quality"],ieltsValidation:e=>["ai-course",e,"ielts-validation"],englishTaxonomy:["ai-course","english","taxonomy"]},entityOnboarding:{credentials:e=>["entity-onboarding","credentials",e]},adaptiveEngine:{dashboard:["adaptive-engine","dashboard"],students:e=>["adaptive-engine","students",e],signals:e=>["adaptive-engine","signals",e],ability:e=>["adaptive-engine","ability",e],settings:["adaptive-engine","settings"]},levelMapping:{get:e=>["level-mapping",e]},branding:{get:e=>["branding",e],current:["branding","current"]},scoreRelease:{pending:e=>["score-release","pending",e]},verification:{verify:e=>["verification",e]}},Qf={register:e=>R.post("/auth/register",e),verifyEmail:e=>R.post("/auth/verify-email",e),resendOtp:e=>R.post("/auth/resend-otp",e),checkEmail:e=>R.post("/auth/check-email",{email:e}),getGoals:()=>R.get("/onboarding/goals"),completeOnboarding:e=>R.post("/onboarding/complete",e)};function mse(){return ye({queryKey:de.signup.goals,queryFn:Qf.getGoals})}function hse(){return ae({mutationFn:e=>Qf.register(e)})}function pse(){return ae({mutationFn:e=>Qf.verifyEmail(e)})}function xse(){return ae({mutationFn:e=>Qf.resendOtp({email:e})})}function gse(){return ae({mutationFn:e=>Qf.checkEmail(e)})}function vse(){return ae({mutationFn:e=>Qf.completeOnboarding(e)})}const yse=e=>{let t=0;return e.length>=8&&(t+=1),e.length>=12&&(t+=1),/[a-z]/.test(e)&&/[A-Z]/.test(e)&&(t+=1),/\d/.test(e)&&(t+=1),/[^A-Za-z0-9]/.test(e)&&(t+=1),Math.min(100,t*25)},jse=No({name:wn().min(2,"Enter your full name"),email:wn().email("Enter a valid email"),password:wn().min(8,"At least 8 characters").regex(/[A-Za-z]/,"Include letters").regex(/\d/,"Include a number"),confirm:wn(),role:Ta(["academic_student","self_learner","teacher"])}).refine(e=>e.password===e.confirm,{message:"Passwords do not match",path:["confirm"]});function bse(){const e=Bt(),t=hse(),r=gse(),[s,a]=p.useState(!1),[i,o]=p.useState(!1),l=Vl({resolver:ql(jse),defaultValues:{name:"",email:"",password:"",confirm:"",role:"self_learner"},mode:"onBlur"}),c=l.watch("password"),d=yse(c||""),u=async h=>{const m={name:h.name.trim(),email:h.email.trim(),password:h.password,role:h.role,captcha_token:"demo-placeholder"};try{await t.mutateAsync(m),e(`/verify-email?email=${encodeURIComponent(h.email.trim())}`)}catch(y){l.setError("root",{message:y instanceof Va?y.message:"Registration failed"})}},f=async()=>{if(!await l.trigger("email"))return;const m=l.getValues("email").trim();if(m)try{(await r.mutateAsync(m)).exists?l.setError("email",{message:"This email is already registered"}):l.clearErrors("email")}catch{l.setError("email",{message:"Could not verify email"})}};return n.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-b from-muted/40 to-background p-4",children:n.jsxs("div",{className:"w-full max-w-md",children:[n.jsxs("div",{className:"flex items-center justify-center gap-2 mb-8",children:[n.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center shadow-sm",children:n.jsx(_i,{className:"h-6 w-6 text-primary-foreground"})}),n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"EnCoach"})]}),n.jsxs(W,{className:"shadow-lg border-0 bg-card/90 backdrop-blur-sm",children:[n.jsxs(se,{className:"text-center pb-4",children:[n.jsx(ie,{className:"text-xl",children:"Create an account"}),n.jsx($e,{children:"Start your IELTS preparation journey"})]}),n.jsxs(U,{children:[n.jsx(Wl,{...l,children:n.jsxs("form",{className:"space-y-5",onSubmit:l.handleSubmit(u),children:[n.jsx(et,{control:l.control,name:"name",render:({field:h})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Full name"}),n.jsx(rt,{children:n.jsx(G,{placeholder:"Jane Doe",autoComplete:"name",...h})}),n.jsx(ot,{})]})}),n.jsx(et,{control:l.control,name:"email",render:({field:h})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Email"}),n.jsx(rt,{children:n.jsx(G,{type:"email",placeholder:"you@example.com",autoComplete:"email",...h,onBlur:m=>{h.onBlur(),f()}})}),n.jsx(ot,{})]})}),n.jsx(et,{control:l.control,name:"password",render:({field:h})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Password"}),n.jsx(rt,{children:n.jsxs("div",{className:"relative",children:[n.jsx(G,{type:s?"text":"password",placeholder:"••••••••",autoComplete:"new-password",className:"pr-10",...h}),n.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>a(m=>!m),"aria-label":s?"Hide password":"Show password",children:s?n.jsx(E1,{className:"h-4 w-4"}):n.jsx(Uc,{className:"h-4 w-4"})})]})}),n.jsxs("div",{className:"space-y-1 pt-1",children:[n.jsx(kn,{value:d,className:"h-1.5"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Strength: ",d,"%"]})]}),n.jsx(ot,{})]})}),n.jsx(et,{control:l.control,name:"confirm",render:({field:h})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Confirm password"}),n.jsx(rt,{children:n.jsxs("div",{className:"relative",children:[n.jsx(G,{type:i?"text":"password",placeholder:"••••••••",autoComplete:"new-password",className:"pr-10",...h}),n.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>o(m=>!m),"aria-label":i?"Hide password":"Show password",children:i?n.jsx(E1,{className:"h-4 w-4"}):n.jsx(Uc,{className:"h-4 w-4"})})]})}),n.jsx(ot,{})]})}),n.jsx(et,{control:l.control,name:"role",render:({field:h})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Role"}),n.jsx(rt,{children:n.jsx(es,{onValueChange:h.onChange,value:h.value,className:"grid gap-2",children:[["academic_student","Academic student"],["self_learner","Self learner"],["teacher","Teacher"]].map(([m,y])=>n.jsxs("label",{className:he("flex items-center gap-3 rounded-lg border p-3 cursor-pointer transition-colors",h.value===m&&"border-primary bg-primary/5"),children:[n.jsx(Bn,{value:m,id:`role-${m}`}),n.jsx("span",{className:"text-sm font-medium",children:y})]},m))})}),n.jsx(ot,{})]})}),n.jsxs("div",{className:"rounded-lg border border-dashed bg-muted/30 p-4 space-y-2",children:[n.jsx("p",{className:"text-sm font-medium",children:"CAPTCHA"}),n.jsx("div",{className:"h-16 rounded-md bg-muted flex items-center justify-center text-xs text-muted-foreground",children:"Verification widget placeholder"})]}),l.formState.errors.root&&n.jsx("p",{className:"text-sm text-destructive text-center bg-destructive/10 rounded-md py-2 px-3",children:l.formState.errors.root.message}),n.jsx(E,{type:"submit",className:"w-full",size:"lg",disabled:t.isPending,children:t.isPending?n.jsxs(n.Fragment,{children:[n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating account"]}):"Create account"})]})}),n.jsxs("p",{className:"text-center text-sm text-muted-foreground mt-6",children:["Already have an account?"," ",n.jsx(Dt,{to:"/login",className:"text-primary font-medium hover:underline",children:"Sign in"})]})]})]})]})})}var wse=Object.defineProperty,Nse=Object.defineProperties,Sse=Object.getOwnPropertyDescriptors,Uv=Object.getOwnPropertySymbols,q6=Object.prototype.hasOwnProperty,W6=Object.prototype.propertyIsEnumerable,XO=(e,t,r)=>t in e?wse(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,_se=(e,t)=>{for(var r in t||(t={}))q6.call(t,r)&&XO(e,r,t[r]);if(Uv)for(var r of Uv(t))W6.call(t,r)&&XO(e,r,t[r]);return e},Cse=(e,t)=>Nse(e,Sse(t)),kse=(e,t)=>{var r={};for(var s in e)q6.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Uv)for(var s of Uv(e))t.indexOf(s)<0&&W6.call(e,s)&&(r[s]=e[s]);return r};function Pse(e){let t=setTimeout(e,0),r=setTimeout(e,10),s=setTimeout(e,50);return[t,r,s]}function Ase(e){let t=p.useRef();return p.useEffect(()=>{t.current=e}),t.current}var Ese=18,U6=40,Ose=`${U6}px`,Tse=["[data-lastpass-icon-root]","com-1password-button","[data-dashlanecreated]",'[style$="2147483647 !important;"]'].join(",");function Mse({containerRef:e,inputRef:t,pushPasswordManagerStrategy:r,isFocused:s}){let[a,i]=p.useState(!1),[o,l]=p.useState(!1),[c,d]=p.useState(!1),u=p.useMemo(()=>r==="none"?!1:(r==="increase-width"||r==="experimental-no-flickering")&&a&&o,[a,o,r]),f=p.useCallback(()=>{let h=e.current,m=t.current;if(!h||!m||c||r==="none")return;let y=h,x=y.getBoundingClientRect().left+y.offsetWidth,j=y.getBoundingClientRect().top+y.offsetHeight/2,v=x-Ese,g=j;document.querySelectorAll(Tse).length===0&&document.elementFromPoint(v,g)===h||(i(!0),d(!0))},[e,t,c,r]);return p.useEffect(()=>{let h=e.current;if(!h||r==="none")return;function m(){let x=window.innerWidth-h.getBoundingClientRect().right;l(x>=U6)}m();let y=setInterval(m,1e3);return()=>{clearInterval(y)}},[e,r]),p.useEffect(()=>{let h=s||document.activeElement===t.current;if(r==="none"||!h)return;let m=setTimeout(f,0),y=setTimeout(f,2e3),x=setTimeout(f,5e3),j=setTimeout(()=>{d(!0)},6e3);return()=>{clearTimeout(m),clearTimeout(y),clearTimeout(x),clearTimeout(j)}},[t,s,r,f]),{hasPWMBadge:a,willPushPWMBadge:u,PWM_BADGE_SPACE_WIDTH:Ose}}var K6=p.createContext({}),G6=p.forwardRef((e,t)=>{var r=e,{value:s,onChange:a,maxLength:i,textAlign:o="left",pattern:l,placeholder:c,inputMode:d="numeric",onComplete:u,pushPasswordManagerStrategy:f="increase-width",pasteTransformer:h,containerClassName:m,noScriptCSSFallback:y=Rse,render:x,children:j}=r,v=kse(r,["value","onChange","maxLength","textAlign","pattern","placeholder","inputMode","onComplete","pushPasswordManagerStrategy","pasteTransformer","containerClassName","noScriptCSSFallback","render","children"]),g,b,N,w,S;let[_,C]=p.useState(typeof v.defaultValue=="string"?v.defaultValue:""),P=s??_,D=Ase(P),z=p.useCallback(Se=>{a==null||a(Se),C(Se)},[a]),O=p.useMemo(()=>l?typeof l=="string"?new RegExp(l):l:null,[l]),V=p.useRef(null),A=p.useRef(null),$=p.useRef({value:P,onChange:z,isIOS:typeof window<"u"&&((b=(g=window==null?void 0:window.CSS)==null?void 0:g.supports)==null?void 0:b.call(g,"-webkit-touch-callout","none"))}),B=p.useRef({prev:[(N=V.current)==null?void 0:N.selectionStart,(w=V.current)==null?void 0:w.selectionEnd,(S=V.current)==null?void 0:S.selectionDirection]});p.useImperativeHandle(t,()=>V.current,[]),p.useEffect(()=>{let Se=V.current,Ve=A.current;if(!Se||!Ve)return;$.current.value!==Se.value&&$.current.onChange(Se.value),B.current.prev=[Se.selectionStart,Se.selectionEnd,Se.selectionDirection];function pt(){if(document.activeElement!==Se){re(null),te(null);return}let kt=Se.selectionStart,Pn=Se.selectionEnd,er=Se.selectionDirection,pn=Se.maxLength,H=Se.value,J=B.current.prev,ce=-1,Ne=-1,ke;if(H.length!==0&&kt!==null&&Pn!==null){let Rt=kt===Pn,Kn=kt===H.length&&H.length1&&H.length>1){let xn=0;if(J[0]!==null&&J[1]!==null){ke=Mn{Ve&&Ve.style.setProperty("--root-height",`${Se.clientHeight}px`)};Pt();let Qt=new ResizeObserver(Pt);return Qt.observe(Se),()=>{document.removeEventListener("selectionchange",pt,{capture:!0}),Qt.disconnect()}},[]);let[I,k]=p.useState(!1),[M,K]=p.useState(!1),[X,re]=p.useState(null),[Z,te]=p.useState(null);p.useEffect(()=>{Pse(()=>{var Se,Ve,pt,Pt;(Se=V.current)==null||Se.dispatchEvent(new Event("input"));let Qt=(Ve=V.current)==null?void 0:Ve.selectionStart,kt=(pt=V.current)==null?void 0:pt.selectionEnd,Pn=(Pt=V.current)==null?void 0:Pt.selectionDirection;Qt!==null&&kt!==null&&(re(Qt),te(kt),B.current.prev=[Qt,kt,Pn])})},[P,M]),p.useEffect(()=>{D!==void 0&&P!==D&&D.length{let Ve=Se.currentTarget.value.slice(0,i);if(Ve.length>0&&O&&!O.test(Ve)){Se.preventDefault();return}typeof D=="string"&&Ve.length{var Se;if(V.current){let Ve=Math.min(V.current.value.length,i-1),pt=V.current.value.length;(Se=V.current)==null||Se.setSelectionRange(Ve,pt),re(Ve),te(pt)}K(!0)},[i]),_e=p.useCallback(Se=>{var Ve,pt;let Pt=V.current;if(!h&&(!$.current.isIOS||!Se.clipboardData||!Pt))return;let Qt=Se.clipboardData.getData("text/plain"),kt=h?h(Qt):Qt;Se.preventDefault();let Pn=(Ve=V.current)==null?void 0:Ve.selectionStart,er=(pt=V.current)==null?void 0:pt.selectionEnd,pn=(Pn!==er?P.slice(0,Pn)+kt+P.slice(er):P.slice(0,Pn)+kt+P.slice(Pn)).slice(0,i);if(pn.length>0&&O&&!O.test(pn))return;Pt.value=pn,z(pn);let H=Math.min(pn.length,i-1),J=pn.length;Pt.setSelectionRange(H,J),re(H),te(J)},[i,z,O,P]),ue=p.useMemo(()=>({position:"relative",cursor:v.disabled?"default":"text",userSelect:"none",WebkitUserSelect:"none",pointerEvents:"none"}),[v.disabled]),we=p.useMemo(()=>({position:"absolute",inset:0,width:xe.willPushPWMBadge?`calc(100% + ${xe.PWM_BADGE_SPACE_WIDTH})`:"100%",clipPath:xe.willPushPWMBadge?`inset(0 ${xe.PWM_BADGE_SPACE_WIDTH} 0 0)`:void 0,height:"100%",display:"flex",textAlign:o,opacity:"1",color:"transparent",pointerEvents:"all",background:"transparent",caretColor:"transparent",border:"0 solid transparent",outline:"0 solid transparent",boxShadow:"none",lineHeight:"1",letterSpacing:"-.5em",fontSize:"var(--root-height)",fontFamily:"monospace",fontVariantNumeric:"tabular-nums"}),[xe.PWM_BADGE_SPACE_WIDTH,xe.willPushPWMBadge,o]),ve=p.useMemo(()=>p.createElement("input",Cse(_se({autoComplete:v.autoComplete||"one-time-code"},v),{"data-input-otp":!0,"data-input-otp-placeholder-shown":P.length===0||void 0,"data-input-otp-mss":X,"data-input-otp-mse":Z,inputMode:d,pattern:O==null?void 0:O.source,"aria-placeholder":c,style:we,maxLength:i,value:P,ref:V,onPaste:Se=>{var Ve;_e(Se),(Ve=v.onPaste)==null||Ve.call(v,Se)},onChange:me,onMouseOver:Se=>{var Ve;k(!0),(Ve=v.onMouseOver)==null||Ve.call(v,Se)},onMouseLeave:Se=>{var Ve;k(!1),(Ve=v.onMouseLeave)==null||Ve.call(v,Se)},onFocus:Se=>{var Ve;ne(),(Ve=v.onFocus)==null||Ve.call(v,Se)},onBlur:Se=>{var Ve;K(!1),(Ve=v.onBlur)==null||Ve.call(v,Se)}})),[me,ne,_e,d,we,i,Z,X,v,O==null?void 0:O.source,P]),le=p.useMemo(()=>({slots:Array.from({length:i}).map((Se,Ve)=>{var pt;let Pt=M&&X!==null&&Z!==null&&(X===Z&&Ve===X||Ve>=X&&Vex?x(le):p.createElement(K6.Provider,{value:le},j),[j,le,x]);return p.createElement(p.Fragment,null,y!==null&&p.createElement("noscript",null,p.createElement("style",null,y)),p.createElement("div",{ref:A,"data-input-otp-container":!0,style:ue,className:m},ut,p.createElement("div",{style:{position:"absolute",inset:0,pointerEvents:"none"}},ve)))});G6.displayName="Input";function Om(e,t){try{e.insertRule(t)}catch{console.error("input-otp could not insert CSS rule:",t)}}var Rse=` [data-input-otp] { --nojs-bg: white !important; --nojs-fg: black !important; background-color: var(--nojs-bg) !important; color: var(--nojs-fg) !important; caret-color: var(--nojs-fg) !important; letter-spacing: .25em !important; text-align: center !important; border: 1px solid var(--nojs-fg) !important; border-radius: 4px !important; width: 100% !important; } @media (prefers-color-scheme: dark) { [data-input-otp] { --nojs-bg: black !important; --nojs-fg: white !important; } }`;const H6=p.forwardRef(({className:e,containerClassName:t,...r},s)=>n.jsx(G6,{ref:s,containerClassName:he("flex items-center gap-2 has-[:disabled]:opacity-50",t),className:he("disabled:cursor-not-allowed",e),...r}));H6.displayName="InputOTP";const Q6=p.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:he("flex items-center",e),...t}));Q6.displayName="InputOTPGroup";const uc=p.forwardRef(({index:e,className:t,...r},s)=>{const a=p.useContext(K6),{char:i,hasFakeCaret:o,isActive:l}=a.slots[e];return n.jsxs("div",{ref:s,className:he("relative flex h-10 w-10 items-center justify-center border-y border-r border-input text-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md",l&&"z-10 ring-2 ring-ring ring-offset-background",t),...r,children:[i,o&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:n.jsx("div",{className:"animate-caret-blink h-4 w-px bg-foreground duration-1000"})})]})});uc.displayName="InputOTPSlot";const $se=p.forwardRef(({...e},t)=>n.jsx("div",{ref:t,role:"separator",...e,children:n.jsx($G,{})}));$se.displayName="InputOTPSeparator";const $w=3,Ise=60;function ZO(e){return e instanceof Va||e instanceof Error?e.message:"Verification failed"}function Dse(){var v;const[e]=wo(),t=((v=e.get("email"))==null?void 0:v.trim())||"",r=Bt(),s=pse(),a=xse(),[i,o]=p.useState(""),[l,c]=p.useState(null),[d,u]=p.useState(0),[f,h]=p.useState(0),m=p.useRef(!1),y=p.useRef(null);p.useEffect(()=>{i.length<6&&(y.current=null)},[i]),p.useEffect(()=>{if(f<=0)return;const g=window.setInterval(()=>{h(b=>b<=1?0:b-1)},1e3);return()=>window.clearInterval(g)},[f]);const x=p.useCallback(async g=>{if(!(!t||g.length!==6)){c(null),m.current=!0;try{await s.mutateAsync({email:t,otp:g}),r("/onboarding",{replace:!0})}catch(b){y.current=null,c(ZO(b))}finally{m.current=!1}}},[t,r,s]);p.useEffect(()=>{i.length!==6||m.current||s.isPending||y.current!==i&&(y.current=i,x(i))},[i,x,s.isPending]);const j=async()=>{if(!(!t||f>0||d>=$w||a.isPending)){c(null);try{await a.mutateAsync(t),u(g=>g+1),h(Ise)}catch(g){c(ZO(g))}}};return t?n.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-b from-muted/40 to-background p-4",children:n.jsxs("div",{className:"w-full max-w-md space-y-8",children:[n.jsxs("div",{className:"flex items-center justify-center gap-2",children:[n.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center shadow-sm",children:n.jsx(_i,{className:"h-6 w-6 text-primary-foreground"})}),n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Verify your email"})]}),n.jsxs(W,{className:"border-0 shadow-xl bg-card/80 backdrop-blur-sm",children:[n.jsxs(se,{className:"text-center space-y-2",children:[n.jsx(ie,{className:"text-lg",children:"Check your inbox"}),n.jsxs($e,{className:"text-base leading-relaxed",children:["We've sent a 6-digit verification code to"," ",n.jsx("span",{className:"font-medium text-foreground",children:t})]})]}),n.jsxs(U,{className:"space-y-6",children:[n.jsxs("div",{className:"flex flex-col items-center gap-4",children:[n.jsx(H6,{maxLength:6,value:i,onChange:o,disabled:s.isPending,children:n.jsxs(Q6,{children:[n.jsx(uc,{index:0}),n.jsx(uc,{index:1}),n.jsx(uc,{index:2}),n.jsx(uc,{index:3}),n.jsx(uc,{index:4}),n.jsx(uc,{index:5})]})}),s.isPending&&n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[n.jsx(Re,{className:"h-4 w-4 animate-spin"}),"Verifying…"]})]}),l&&n.jsx("p",{className:"text-center text-sm text-destructive bg-destructive/10 rounded-md py-2 px-3",children:l}),n.jsx(E,{className:"w-full",size:"lg",onClick:()=>void x(i),disabled:i.length!==6||s.isPending,children:s.isPending?n.jsxs(n.Fragment,{children:[n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying"]}):"Verify"}),n.jsxs("div",{className:"text-center text-sm space-y-2",children:[n.jsxs("p",{className:"text-muted-foreground",children:["Resend attempts:"," ",n.jsxs("span",{className:"font-medium text-foreground",children:[d,"/",$w]})]}),n.jsx("button",{type:"button",onClick:()=>void j(),disabled:f>0||d>=$w||a.isPending,className:"text-primary font-medium hover:underline disabled:opacity-50 disabled:no-underline",children:a.isPending?"Sending…":f>0?`Resend code in ${f}s`:"Resend code"})]}),n.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["Wrong address?"," ",n.jsx(Dt,{to:"/register",className:"text-primary font-medium hover:underline",children:"Change email"})]})]})]})]})}):n.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-b from-muted/40 to-background p-4",children:n.jsxs(W,{className:"w-full max-w-md border-0 shadow-lg",children:[n.jsxs(se,{className:"text-center",children:[n.jsx(ie,{children:"Missing email"}),n.jsx($e,{children:"Add an email query parameter or return to registration."})]}),n.jsx(U,{className:"flex justify-center",children:n.jsx(E,{asChild:!0,variant:"outline",children:n.jsx(Dt,{to:"/register",children:"Back to registration"})})})]})})}function Ft(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function Bs(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function Kr(e,t){const r=Ft(e);return isNaN(t)?Bs(e,NaN):(t&&r.setDate(r.getDate()+t),r)}function qa(e,t){const r=Ft(e);if(isNaN(t))return Bs(e,NaN);if(!t)return r;const s=r.getDate(),a=Bs(e,r.getTime());a.setMonth(r.getMonth()+t+1,0);const i=a.getDate();return s>=i?a:(r.setFullYear(a.getFullYear(),a.getMonth(),s),r)}const b2=6048e5,Lse=864e5;let Fse={};function dx(){return Fse}function ji(e,t){var l,c,d,u;const r=dx(),s=(t==null?void 0:t.weekStartsOn)??((c=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((u=(d=r.locale)==null?void 0:d.options)==null?void 0:u.weekStartsOn)??0,a=Ft(e),i=a.getDay(),o=(i=a.getTime()?r+1:t.getTime()>=o.getTime()?r:r-1}function rf(e){const t=Ft(e);return t.setHours(0,0,0,0),t}function Kv(e){const t=Ft(e),r=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return r.setUTCFullYear(t.getFullYear()),+e-+r}function li(e,t){const r=rf(e),s=rf(t),a=+r-Kv(r),i=+s-Kv(s);return Math.round((a-i)/Lse)}function Bse(e){const t=Y6(e),r=Bs(e,0);return r.setFullYear(t,0,4),r.setHours(0,0,0,0),Zc(r)}function bS(e,t){const r=t*7;return Kr(e,r)}function zse(e,t){return qa(e,t*12)}function Vse(e){let t;return e.forEach(function(r){const s=Ft(r);(t===void 0||t{const s=Ft(r);(!t||t>s||isNaN(+s))&&(t=s)}),t||new Date(NaN)}function hs(e,t){const r=rf(e),s=rf(t);return+r==+s}function w2(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Wse(e){if(!w2(e)&&typeof e!="number")return!1;const t=Ft(e);return!isNaN(Number(t))}function ep(e,t){const r=Ft(e),s=Ft(t),a=r.getFullYear()-s.getFullYear(),i=r.getMonth()-s.getMonth();return a*12+i}function Use(e,t,r){const s=ji(e,r),a=ji(t,r),i=+s-Kv(s),o=+a-Kv(a);return Math.round((i-o)/b2)}function N2(e){const t=Ft(e),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(23,59,59,999),t}function js(e){const t=Ft(e);return t.setDate(1),t.setHours(0,0,0,0),t}function X6(e){const t=Ft(e),r=Bs(e,0);return r.setFullYear(t.getFullYear(),0,1),r.setHours(0,0,0,0),r}function S2(e,t){var l,c,d,u;const r=dx(),s=(t==null?void 0:t.weekStartsOn)??((c=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((u=(d=r.locale)==null?void 0:d.options)==null?void 0:u.weekStartsOn)??0,a=Ft(e),i=a.getDay(),o=(i{let s;const a=Kse[e];return typeof a=="string"?s=a:t===1?s=a.one:s=a.other.replace("{{count}}",t.toString()),r!=null&&r.addSuffix?r.comparison&&r.comparison>0?"in "+s:s+" ago":s};function Iw(e){return(t={})=>{const r=t.width?String(t.width):e.defaultWidth;return e.formats[r]||e.formats[e.defaultWidth]}}const Hse={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Qse={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Yse={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Xse={date:Iw({formats:Hse,defaultWidth:"full"}),time:Iw({formats:Qse,defaultWidth:"full"}),dateTime:Iw({formats:Yse,defaultWidth:"full"})},Zse={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Jse=(e,t,r,s)=>Zse[e];function Tm(e){return(t,r)=>{const s=r!=null&&r.context?String(r.context):"standalone";let a;if(s==="formatting"&&e.formattingValues){const o=e.defaultFormattingWidth||e.defaultWidth,l=r!=null&&r.width?String(r.width):o;a=e.formattingValues[l]||e.formattingValues[o]}else{const o=e.defaultWidth,l=r!=null&&r.width?String(r.width):e.defaultWidth;a=e.values[l]||e.values[o]}const i=e.argumentCallback?e.argumentCallback(t):t;return a[i]}}const eae={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},tae={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},nae={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"]},rae={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"]},sae={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"}},aae={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"}},iae=(e,t)=>{const r=Number(e),s=r%100;if(s>20||s<10)switch(s%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},oae={ordinalNumber:iae,era:Tm({values:eae,defaultWidth:"wide"}),quarter:Tm({values:tae,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Tm({values:nae,defaultWidth:"wide"}),day:Tm({values:rae,defaultWidth:"wide"}),dayPeriod:Tm({values:sae,defaultWidth:"wide",formattingValues:aae,defaultFormattingWidth:"wide"})};function Mm(e){return(t,r={})=>{const s=r.width,a=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],i=t.match(a);if(!i)return null;const o=i[0],l=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(l)?cae(l,f=>f.test(o)):lae(l,f=>f.test(o));let d;d=e.valueCallback?e.valueCallback(c):c,d=r.valueCallback?r.valueCallback(d):d;const u=t.slice(o.length);return{value:d,rest:u}}}function lae(e,t){for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t(e[r]))return r}function cae(e,t){for(let r=0;r{const s=t.match(e.matchPattern);if(!s)return null;const a=s[0],i=t.match(e.parsePattern);if(!i)return null;let o=e.valueCallback?e.valueCallback(i[0]):i[0];o=r.valueCallback?r.valueCallback(o):o;const l=t.slice(a.length);return{value:o,rest:l}}}const uae=/^(\d+)(th|st|nd|rd)?/i,fae=/\d+/i,mae={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},hae={any:[/^b/i,/^(a|c)/i]},pae={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},xae={any:[/1/i,/2/i,/3/i,/4/i]},gae={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},vae={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]},yae={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},jae={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]},bae={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},wae={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}},Nae={ordinalNumber:dae({matchPattern:uae,parsePattern:fae,valueCallback:e=>parseInt(e,10)}),era:Mm({matchPatterns:mae,defaultMatchWidth:"wide",parsePatterns:hae,defaultParseWidth:"any"}),quarter:Mm({matchPatterns:pae,defaultMatchWidth:"wide",parsePatterns:xae,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Mm({matchPatterns:gae,defaultMatchWidth:"wide",parsePatterns:vae,defaultParseWidth:"any"}),day:Mm({matchPatterns:yae,defaultMatchWidth:"wide",parsePatterns:jae,defaultParseWidth:"any"}),dayPeriod:Mm({matchPatterns:bae,defaultMatchWidth:"any",parsePatterns:wae,defaultParseWidth:"any"})},J6={code:"en-US",formatDistance:Gse,formatLong:Xse,formatRelative:Jse,localize:oae,match:Nae,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Sae(e){const t=Ft(e);return li(t,X6(t))+1}function e8(e){const t=Ft(e),r=+Zc(t)-+Bse(t);return Math.round(r/b2)+1}function t8(e,t){var u,f,h,m;const r=Ft(e),s=r.getFullYear(),a=dx(),i=(t==null?void 0:t.firstWeekContainsDate)??((f=(u=t==null?void 0:t.locale)==null?void 0:u.options)==null?void 0:f.firstWeekContainsDate)??a.firstWeekContainsDate??((m=(h=a.locale)==null?void 0:h.options)==null?void 0:m.firstWeekContainsDate)??1,o=Bs(e,0);o.setFullYear(s+1,0,i),o.setHours(0,0,0,0);const l=ji(o,t),c=Bs(e,0);c.setFullYear(s,0,i),c.setHours(0,0,0,0);const d=ji(c,t);return r.getTime()>=l.getTime()?s+1:r.getTime()>=d.getTime()?s:s-1}function _ae(e,t){var l,c,d,u;const r=dx(),s=(t==null?void 0:t.firstWeekContainsDate)??((c=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:c.firstWeekContainsDate)??r.firstWeekContainsDate??((u=(d=r.locale)==null?void 0:d.options)==null?void 0:u.firstWeekContainsDate)??1,a=t8(e,t),i=Bs(e,0);return i.setFullYear(a,0,s),i.setHours(0,0,0,0),ji(i,t)}function n8(e,t){const r=Ft(e),s=+ji(r,t)-+_ae(r,t);return Math.round(s/b2)+1}function Zt(e,t){const r=e<0?"-":"",s=Math.abs(e).toString().padStart(t,"0");return r+s}const Do={y(e,t){const r=e.getFullYear(),s=r>0?r:1-r;return Zt(t==="yy"?s%100:s,t.length)},M(e,t){const r=e.getMonth();return t==="M"?String(r+1):Zt(r+1,2)},d(e,t){return Zt(e.getDate(),t.length)},a(e,t){const r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(e,t){return Zt(e.getHours()%12||12,t.length)},H(e,t){return Zt(e.getHours(),t.length)},m(e,t){return Zt(e.getMinutes(),t.length)},s(e,t){return Zt(e.getSeconds(),t.length)},S(e,t){const r=t.length,s=e.getMilliseconds(),a=Math.trunc(s*Math.pow(10,r-3));return Zt(a,t.length)}},Bd={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},JO={G:function(e,t,r){const s=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return r.era(s,{width:"abbreviated"});case"GGGGG":return r.era(s,{width:"narrow"});case"GGGG":default:return r.era(s,{width:"wide"})}},y:function(e,t,r){if(t==="yo"){const s=e.getFullYear(),a=s>0?s:1-s;return r.ordinalNumber(a,{unit:"year"})}return Do.y(e,t)},Y:function(e,t,r,s){const a=t8(e,s),i=a>0?a:1-a;if(t==="YY"){const o=i%100;return Zt(o,2)}return t==="Yo"?r.ordinalNumber(i,{unit:"year"}):Zt(i,t.length)},R:function(e,t){const r=Y6(e);return Zt(r,t.length)},u:function(e,t){const r=e.getFullYear();return Zt(r,t.length)},Q:function(e,t,r){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(s);case"QQ":return Zt(s,2);case"Qo":return r.ordinalNumber(s,{unit:"quarter"});case"QQQ":return r.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(s,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(s,{width:"wide",context:"formatting"})}},q:function(e,t,r){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(s);case"qq":return Zt(s,2);case"qo":return r.ordinalNumber(s,{unit:"quarter"});case"qqq":return r.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(s,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(s,{width:"wide",context:"standalone"})}},M:function(e,t,r){const s=e.getMonth();switch(t){case"M":case"MM":return Do.M(e,t);case"Mo":return r.ordinalNumber(s+1,{unit:"month"});case"MMM":return r.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(s,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(s,{width:"wide",context:"formatting"})}},L:function(e,t,r){const s=e.getMonth();switch(t){case"L":return String(s+1);case"LL":return Zt(s+1,2);case"Lo":return r.ordinalNumber(s+1,{unit:"month"});case"LLL":return r.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(s,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(s,{width:"wide",context:"standalone"})}},w:function(e,t,r,s){const a=n8(e,s);return t==="wo"?r.ordinalNumber(a,{unit:"week"}):Zt(a,t.length)},I:function(e,t,r){const s=e8(e);return t==="Io"?r.ordinalNumber(s,{unit:"week"}):Zt(s,t.length)},d:function(e,t,r){return t==="do"?r.ordinalNumber(e.getDate(),{unit:"date"}):Do.d(e,t)},D:function(e,t,r){const s=Sae(e);return t==="Do"?r.ordinalNumber(s,{unit:"dayOfYear"}):Zt(s,t.length)},E:function(e,t,r){const s=e.getDay();switch(t){case"E":case"EE":case"EEE":return r.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(s,{width:"short",context:"formatting"});case"EEEE":default:return r.day(s,{width:"wide",context:"formatting"})}},e:function(e,t,r,s){const a=e.getDay(),i=(a-s.weekStartsOn+8)%7||7;switch(t){case"e":return String(i);case"ee":return Zt(i,2);case"eo":return r.ordinalNumber(i,{unit:"day"});case"eee":return r.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(a,{width:"short",context:"formatting"});case"eeee":default:return r.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,r,s){const a=e.getDay(),i=(a-s.weekStartsOn+8)%7||7;switch(t){case"c":return String(i);case"cc":return Zt(i,t.length);case"co":return r.ordinalNumber(i,{unit:"day"});case"ccc":return r.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(a,{width:"narrow",context:"standalone"});case"cccccc":return r.day(a,{width:"short",context:"standalone"});case"cccc":default:return r.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,r){const s=e.getDay(),a=s===0?7:s;switch(t){case"i":return String(a);case"ii":return Zt(a,t.length);case"io":return r.ordinalNumber(a,{unit:"day"});case"iii":return r.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(s,{width:"short",context:"formatting"});case"iiii":default:return r.day(s,{width:"wide",context:"formatting"})}},a:function(e,t,r){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,t,r){const s=e.getHours();let a;switch(s===12?a=Bd.noon:s===0?a=Bd.midnight:a=s/12>=1?"pm":"am",t){case"b":case"bb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,r){const s=e.getHours();let a;switch(s>=17?a=Bd.evening:s>=12?a=Bd.afternoon:s>=4?a=Bd.morning:a=Bd.night,t){case"B":case"BB":case"BBB":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,r){if(t==="ho"){let s=e.getHours()%12;return s===0&&(s=12),r.ordinalNumber(s,{unit:"hour"})}return Do.h(e,t)},H:function(e,t,r){return t==="Ho"?r.ordinalNumber(e.getHours(),{unit:"hour"}):Do.H(e,t)},K:function(e,t,r){const s=e.getHours()%12;return t==="Ko"?r.ordinalNumber(s,{unit:"hour"}):Zt(s,t.length)},k:function(e,t,r){let s=e.getHours();return s===0&&(s=24),t==="ko"?r.ordinalNumber(s,{unit:"hour"}):Zt(s,t.length)},m:function(e,t,r){return t==="mo"?r.ordinalNumber(e.getMinutes(),{unit:"minute"}):Do.m(e,t)},s:function(e,t,r){return t==="so"?r.ordinalNumber(e.getSeconds(),{unit:"second"}):Do.s(e,t)},S:function(e,t){return Do.S(e,t)},X:function(e,t,r){const s=e.getTimezoneOffset();if(s===0)return"Z";switch(t){case"X":return tT(s);case"XXXX":case"XX":return fc(s);case"XXXXX":case"XXX":default:return fc(s,":")}},x:function(e,t,r){const s=e.getTimezoneOffset();switch(t){case"x":return tT(s);case"xxxx":case"xx":return fc(s);case"xxxxx":case"xxx":default:return fc(s,":")}},O:function(e,t,r){const s=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+eT(s,":");case"OOOO":default:return"GMT"+fc(s,":")}},z:function(e,t,r){const s=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+eT(s,":");case"zzzz":default:return"GMT"+fc(s,":")}},t:function(e,t,r){const s=Math.trunc(e.getTime()/1e3);return Zt(s,t.length)},T:function(e,t,r){const s=e.getTime();return Zt(s,t.length)}};function eT(e,t=""){const r=e>0?"-":"+",s=Math.abs(e),a=Math.trunc(s/60),i=s%60;return i===0?r+String(a):r+String(a)+t+Zt(i,2)}function tT(e,t){return e%60===0?(e>0?"-":"+")+Zt(Math.abs(e)/60,2):fc(e,t)}function fc(e,t=""){const r=e>0?"-":"+",s=Math.abs(e),a=Zt(Math.trunc(s/60),2),i=Zt(s%60,2);return r+a+t+i}const nT=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},r8=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},Cae=(e,t)=>{const r=e.match(/(P+)(p+)?/)||[],s=r[1],a=r[2];if(!a)return nT(e,t);let i;switch(s){case"P":i=t.dateTime({width:"short"});break;case"PP":i=t.dateTime({width:"medium"});break;case"PPP":i=t.dateTime({width:"long"});break;case"PPPP":default:i=t.dateTime({width:"full"});break}return i.replace("{{date}}",nT(s,t)).replace("{{time}}",r8(a,t))},kae={p:r8,P:Cae},Pae=/^D+$/,Aae=/^Y+$/,Eae=["D","DD","YY","YYYY"];function Oae(e){return Pae.test(e)}function Tae(e){return Aae.test(e)}function Mae(e,t,r){const s=Rae(e,t,r);if(console.warn(s),Eae.includes(e))throw new RangeError(s)}function Rae(e,t,r){const s=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${s} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const $ae=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Iae=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Dae=/^'([^]*?)'?$/,Lae=/''/g,Fae=/[a-zA-Z]/;function Pi(e,t,r){var u,f,h,m,y,x,j,v;const s=dx(),a=(r==null?void 0:r.locale)??s.locale??J6,i=(r==null?void 0:r.firstWeekContainsDate)??((f=(u=r==null?void 0:r.locale)==null?void 0:u.options)==null?void 0:f.firstWeekContainsDate)??s.firstWeekContainsDate??((m=(h=s.locale)==null?void 0:h.options)==null?void 0:m.firstWeekContainsDate)??1,o=(r==null?void 0:r.weekStartsOn)??((x=(y=r==null?void 0:r.locale)==null?void 0:y.options)==null?void 0:x.weekStartsOn)??s.weekStartsOn??((v=(j=s.locale)==null?void 0:j.options)==null?void 0:v.weekStartsOn)??0,l=Ft(e);if(!Wse(l))throw new RangeError("Invalid time value");let c=t.match(Iae).map(g=>{const b=g[0];if(b==="p"||b==="P"){const N=kae[b];return N(g,a.formatLong)}return g}).join("").match($ae).map(g=>{if(g==="''")return{isToken:!1,value:"'"};const b=g[0];if(b==="'")return{isToken:!1,value:Bae(g)};if(JO[b])return{isToken:!0,value:g};if(b.match(Fae))throw new RangeError("Format string contains an unescaped latin alphabet character `"+b+"`");return{isToken:!1,value:g}});a.localize.preprocessor&&(c=a.localize.preprocessor(l,c));const d={firstWeekContainsDate:i,weekStartsOn:o,locale:a};return c.map(g=>{if(!g.isToken)return g.value;const b=g.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&Tae(b)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&Oae(b))&&Mae(b,t,String(e));const N=JO[b[0]];return N(l,b,a.localize,d)}).join("")}function Bae(e){const t=e.match(Dae);return t?t[1].replace(Lae,"'"):e}function zae(e){const t=Ft(e),r=t.getFullYear(),s=t.getMonth(),a=Bs(e,0);return a.setFullYear(r,s+1,0),a.setHours(0,0,0,0),a.getDate()}function Vae(e){return Math.trunc(+Ft(e)/1e3)}function qae(e){const t=Ft(e),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(0,0,0,0),t}function Wae(e,t){return Use(qae(e),js(e),t)+1}function wS(e,t){const r=Ft(e),s=Ft(t);return r.getTime()>s.getTime()}function s8(e,t){const r=Ft(e),s=Ft(t);return+r<+s}function _2(e,t){const r=Ft(e),s=Ft(t);return r.getFullYear()===s.getFullYear()&&r.getMonth()===s.getMonth()}function Uae(e,t){const r=Ft(e),s=Ft(t);return r.getFullYear()===s.getFullYear()}function Dw(e,t){return Kr(e,-t)}function Lw(e,t){const r=Ft(e),s=r.getFullYear(),a=r.getDate(),i=Bs(e,0);i.setFullYear(s,t,15),i.setHours(0,0,0,0);const o=zae(i);return r.setMonth(t,Math.min(a,o)),r}function rT(e,t){const r=Ft(e);return isNaN(+r)?Bs(e,NaN):(r.setFullYear(t),r)}function tp(e,[t,r]){return Math.min(r,Math.max(t,e))}var a8=["PageUp","PageDown"],i8=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],o8={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Yf="Slider",[NS,Kae,Gae]=Df(Yf),[l8]=lr(Yf,[Gae]),[Hae,bb]=l8(Yf),c8=p.forwardRef((e,t)=>{const{name:r,min:s=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:l=!1,minStepsBetweenThumbs:c=0,defaultValue:d=[s],value:u,onValueChange:f=()=>{},onValueCommit:h=()=>{},inverted:m=!1,form:y,...x}=e,j=p.useRef(new Set),v=p.useRef(0),b=o==="horizontal"?Qae:Yae,[N=[],w]=zr({prop:u,defaultProp:d,onChange:z=>{var V;(V=[...j.current][v.current])==null||V.focus(),f(z)}}),S=p.useRef(N);function _(z){const O=tie(N,z);D(z,O)}function C(z){D(z,v.current)}function P(){const z=S.current[v.current];N[v.current]!==z&&h(N)}function D(z,O,{commit:V}={commit:!1}){const A=aie(i),$=iie(Math.round((z-s)/i)*i+s,A),B=tp($,[s,a]);w((I=[])=>{const k=Jae(I,B,O);if(sie(k,c*i)){v.current=k.indexOf(B);const M=String(k)!==String(I);return M&&V&&h(k),M?k:I}else return I})}return n.jsx(Hae,{scope:e.__scopeSlider,name:r,disabled:l,min:s,max:a,valueIndexToChangeRef:v,thumbs:j.current,values:N,orientation:o,form:y,children:n.jsx(NS.Provider,{scope:e.__scopeSlider,children:n.jsx(NS.Slot,{scope:e.__scopeSlider,children:n.jsx(b,{"aria-disabled":l,"data-disabled":l?"":void 0,...x,ref:t,onPointerDown:be(x.onPointerDown,()=>{l||(S.current=N)}),min:s,max:a,inverted:m,onSlideStart:l?void 0:_,onSlideMove:l?void 0:C,onSlideEnd:l?void 0:P,onHomeKeyDown:()=>!l&&D(s,0,{commit:!0}),onEndKeyDown:()=>!l&&D(a,N.length-1,{commit:!0}),onStepKeyDown:({event:z,direction:O})=>{if(!l){const $=a8.includes(z.key)||z.shiftKey&&i8.includes(z.key)?10:1,B=v.current,I=N[B],k=i*$*O;D(I+k,B,{commit:!0})}}})})})})});c8.displayName=Yf;var[d8,u8]=l8(Yf,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Qae=p.forwardRef((e,t)=>{const{min:r,max:s,dir:a,inverted:i,onSlideStart:o,onSlideMove:l,onSlideEnd:c,onStepKeyDown:d,...u}=e,[f,h]=p.useState(null),m=dt(t,b=>h(b)),y=p.useRef(void 0),x=zl(a),j=x==="ltr",v=j&&!i||!j&&i;function g(b){const N=y.current||f.getBoundingClientRect(),w=[0,N.width],_=C2(w,v?[r,s]:[s,r]);return y.current=N,_(b-N.left)}return n.jsx(d8,{scope:e.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:n.jsx(f8,{dir:x,"data-orientation":"horizontal",...u,ref:m,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:b=>{const N=g(b.clientX);o==null||o(N)},onSlideMove:b=>{const N=g(b.clientX);l==null||l(N)},onSlideEnd:()=>{y.current=void 0,c==null||c()},onStepKeyDown:b=>{const w=o8[v?"from-left":"from-right"].includes(b.key);d==null||d({event:b,direction:w?-1:1})}})})}),Yae=p.forwardRef((e,t)=>{const{min:r,max:s,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:l,onStepKeyDown:c,...d}=e,u=p.useRef(null),f=dt(t,u),h=p.useRef(void 0),m=!a;function y(x){const j=h.current||u.current.getBoundingClientRect(),v=[0,j.height],b=C2(v,m?[s,r]:[r,s]);return h.current=j,b(x-j.top)}return n.jsx(d8,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:n.jsx(f8,{"data-orientation":"vertical",...d,ref:f,style:{...d.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:x=>{const j=y(x.clientY);i==null||i(j)},onSlideMove:x=>{const j=y(x.clientY);o==null||o(j)},onSlideEnd:()=>{h.current=void 0,l==null||l()},onStepKeyDown:x=>{const v=o8[m?"from-bottom":"from-top"].includes(x.key);c==null||c({event:x,direction:v?-1:1})}})})}),f8=p.forwardRef((e,t)=>{const{__scopeSlider:r,onSlideStart:s,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:l,onStepKeyDown:c,...d}=e,u=bb(Yf,r);return n.jsx(We.span,{...d,ref:t,onKeyDown:be(e.onKeyDown,f=>{f.key==="Home"?(o(f),f.preventDefault()):f.key==="End"?(l(f),f.preventDefault()):a8.concat(i8).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:be(e.onPointerDown,f=>{const h=f.target;h.setPointerCapture(f.pointerId),f.preventDefault(),u.thumbs.has(h)?h.focus():s(f)}),onPointerMove:be(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&a(f)}),onPointerUp:be(e.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),i(f))})})}),m8="SliderTrack",h8=p.forwardRef((e,t)=>{const{__scopeSlider:r,...s}=e,a=bb(m8,r);return n.jsx(We.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...s,ref:t})});h8.displayName=m8;var SS="SliderRange",p8=p.forwardRef((e,t)=>{const{__scopeSlider:r,...s}=e,a=bb(SS,r),i=u8(SS,r),o=p.useRef(null),l=dt(t,o),c=a.values.length,d=a.values.map(h=>v8(h,a.min,a.max)),u=c>1?Math.min(...d):0,f=100-Math.max(...d);return n.jsx(We.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...s,ref:l,style:{...e.style,[i.startEdge]:u+"%",[i.endEdge]:f+"%"}})});p8.displayName=SS;var _S="SliderThumb",x8=p.forwardRef((e,t)=>{const r=Kae(e.__scopeSlider),[s,a]=p.useState(null),i=dt(t,l=>a(l)),o=p.useMemo(()=>s?r().findIndex(l=>l.ref.current===s):-1,[r,s]);return n.jsx(Xae,{...e,ref:i,index:o})}),Xae=p.forwardRef((e,t)=>{const{__scopeSlider:r,index:s,name:a,...i}=e,o=bb(_S,r),l=u8(_S,r),[c,d]=p.useState(null),u=dt(t,g=>d(g)),f=c?o.form||!!c.closest("form"):!0,h=Zp(c),m=o.values[s],y=m===void 0?0:v8(m,o.min,o.max),x=eie(s,o.values.length),j=h==null?void 0:h[l.size],v=j?nie(j,y,l.direction):0;return p.useEffect(()=>{if(c)return o.thumbs.add(c),()=>{o.thumbs.delete(c)}},[c,o.thumbs]),n.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[l.startEdge]:`calc(${y}% + ${v}px)`},children:[n.jsx(NS.ItemSlot,{scope:e.__scopeSlider,children:n.jsx(We.span,{role:"slider","aria-label":e["aria-label"]||x,"aria-valuemin":o.min,"aria-valuenow":m,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:u,style:m===void 0?{display:"none"}:e.style,onFocus:be(e.onFocus,()=>{o.valueIndexToChangeRef.current=s})})}),f&&n.jsx(g8,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:m},s)]})});x8.displayName=_S;var Zae="RadioBubbleInput",g8=p.forwardRef(({__scopeSlider:e,value:t,...r},s)=>{const a=p.useRef(null),i=dt(a,s),o=lx(t);return p.useEffect(()=>{const l=a.current;if(!l)return;const c=window.HTMLInputElement.prototype,u=Object.getOwnPropertyDescriptor(c,"value").set;if(o!==t&&u){const f=new Event("input",{bubbles:!0});u.call(l,t),l.dispatchEvent(f)}},[o,t]),n.jsx(We.input,{style:{display:"none"},...r,ref:i,defaultValue:t})});g8.displayName=Zae;function Jae(e=[],t,r){const s=[...e];return s[r]=t,s.sort((a,i)=>a-i)}function v8(e,t,r){const i=100/(r-t)*(e-t);return tp(i,[0,100])}function eie(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function tie(e,t){if(e.length===1)return 0;const r=e.map(a=>Math.abs(a-t)),s=Math.min(...r);return r.indexOf(s)}function nie(e,t,r){const s=e/2,i=C2([0,50],[0,s]);return(s-i(t)*r)*r}function rie(e){return e.slice(0,-1).map((t,r)=>e[r+1]-t)}function sie(e,t){if(t>0){const r=rie(e);return Math.min(...r)>=t}return!0}function C2(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const s=(t[1]-t[0])/(e[1]-e[0]);return t[0]+s*(r-e[0])}}function aie(e){return(String(e).split(".")[1]||"").length}function iie(e,t){const r=Math.pow(10,t);return Math.round(e*r)/r}var y8=c8,oie=h8,lie=p8,cie=x8;const oa=p.forwardRef(({className:e,...t},r)=>n.jsxs(y8,{ref:r,className:he("relative flex w-full touch-none select-none items-center",e),...t,children:[n.jsx(oie,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:n.jsx(lie,{className:"absolute h-full bg-primary"})}),n.jsx(cie,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));oa.displayName=y8.displayName;function die(e){const t=uie(e),r=p.forwardRef((s,a)=>{const{children:i,...o}=s,l=p.Children.toArray(i),c=l.find(mie);if(c){const d=c.props.children,u=l.map(f=>f===c?p.Children.count(d)>1?p.Children.only(null):p.isValidElement(d)?d.props.children:null:f);return n.jsx(t,{...o,ref:a,children:p.isValidElement(d)?p.cloneElement(d,void 0,u):null})}return n.jsx(t,{...o,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function uie(e){const t=p.forwardRef((r,s)=>{const{children:a,...i}=r;if(p.isValidElement(a)){const o=pie(a),l=hie(i,a.props);return a.type!==p.Fragment&&(l.ref=s?Ni(s,o):o),p.cloneElement(a,l)}return p.Children.count(a)>1?p.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var fie=Symbol("radix.slottable");function mie(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===fie}function hie(e,t){const r={...t};for(const s in t){const a=e[s],i=t[s];/^on[A-Z]/.test(s)?a&&i?r[s]=(...l)=>{const c=i(...l);return a(...l),c}:a&&(r[s]=a):s==="style"?r[s]={...a,...i}:s==="className"&&(r[s]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function pie(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var xie=[" ","Enter","ArrowUp","ArrowDown"],gie=[" ","Enter"],Jc="Select",[wb,Nb,vie]=Df(Jc),[Xf]=lr(Jc,[vie,Fl]),Sb=Fl(),[yie,Ul]=Xf(Jc),[jie,bie]=Xf(Jc),j8=e=>{const{__scopeSelect:t,children:r,open:s,defaultOpen:a,onOpenChange:i,value:o,defaultValue:l,onValueChange:c,dir:d,name:u,autoComplete:f,disabled:h,required:m,form:y}=e,x=Sb(t),[j,v]=p.useState(null),[g,b]=p.useState(null),[N,w]=p.useState(!1),S=zl(d),[_,C]=zr({prop:s,defaultProp:a??!1,onChange:i,caller:Jc}),[P,D]=zr({prop:o,defaultProp:l,onChange:c,caller:Jc}),z=p.useRef(null),O=j?y||!!j.closest("form"):!0,[V,A]=p.useState(new Set),$=Array.from(V).map(B=>B.props.value).join(";");return n.jsx($j,{...x,children:n.jsxs(yie,{required:m,scope:t,trigger:j,onTriggerChange:v,valueNode:g,onValueNodeChange:b,valueNodeHasChildren:N,onValueNodeHasChildrenChange:w,contentId:ys(),value:P,onValueChange:D,open:_,onOpenChange:C,dir:S,triggerPointerDownPosRef:z,disabled:h,children:[n.jsx(wb.Provider,{scope:t,children:n.jsx(jie,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(B=>{A(I=>new Set(I).add(B))},[]),onNativeOptionRemove:p.useCallback(B=>{A(I=>{const k=new Set(I);return k.delete(B),k})},[]),children:r})}),O?n.jsxs(W8,{"aria-hidden":!0,required:m,tabIndex:-1,name:u,autoComplete:f,value:P,onChange:B=>D(B.target.value),disabled:h,form:y,children:[P===void 0?n.jsx("option",{value:""}):null,Array.from(V)]},$):null]})})};j8.displayName=Jc;var b8="SelectTrigger",w8=p.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:s=!1,...a}=e,i=Sb(r),o=Ul(b8,r),l=o.disabled||s,c=dt(t,o.onTriggerChange),d=Nb(r),u=p.useRef("touch"),[f,h,m]=K8(x=>{const j=d().filter(b=>!b.disabled),v=j.find(b=>b.value===o.value),g=G8(j,x,v);g!==void 0&&o.onValueChange(g.value)}),y=x=>{l||(o.onOpenChange(!0),m()),x&&(o.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return n.jsx(Jp,{asChild:!0,...i,children:n.jsx(We.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:l,"data-disabled":l?"":void 0,"data-placeholder":U8(o.value)?"":void 0,...a,ref:c,onClick:be(a.onClick,x=>{x.currentTarget.focus(),u.current!=="mouse"&&y(x)}),onPointerDown:be(a.onPointerDown,x=>{u.current=x.pointerType;const j=x.target;j.hasPointerCapture(x.pointerId)&&j.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(y(x),x.preventDefault())}),onKeyDown:be(a.onKeyDown,x=>{const j=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(j&&x.key===" ")&&xie.includes(x.key)&&(y(),x.preventDefault())})})})});w8.displayName=b8;var N8="SelectValue",S8=p.forwardRef((e,t)=>{const{__scopeSelect:r,className:s,style:a,children:i,placeholder:o="",...l}=e,c=Ul(N8,r),{onValueNodeHasChildrenChange:d}=c,u=i!==void 0,f=dt(t,c.onValueNodeChange);return Ln(()=>{d(u)},[d,u]),n.jsx(We.span,{...l,ref:f,style:{pointerEvents:"none"},children:U8(c.value)?n.jsx(n.Fragment,{children:o}):i})});S8.displayName=N8;var wie="SelectIcon",_8=p.forwardRef((e,t)=>{const{__scopeSelect:r,children:s,...a}=e;return n.jsx(We.span,{"aria-hidden":!0,...a,ref:t,children:s||"▼"})});_8.displayName=wie;var Nie="SelectPortal",C8=e=>n.jsx(Lf,{asChild:!0,...e});C8.displayName=Nie;var ed="SelectContent",k8=p.forwardRef((e,t)=>{const r=Ul(ed,e.__scopeSelect),[s,a]=p.useState();if(Ln(()=>{a(new DocumentFragment)},[]),!r.open){const i=s;return i?md.createPortal(n.jsx(P8,{scope:e.__scopeSelect,children:n.jsx(wb.Slot,{scope:e.__scopeSelect,children:n.jsx("div",{children:e.children})})}),i):null}return n.jsx(A8,{...e,ref:t})});k8.displayName=ed;var Sa=10,[P8,Kl]=Xf(ed),Sie="SelectContentImpl",_ie=die("SelectContent.RemoveScroll"),A8=p.forwardRef((e,t)=>{const{__scopeSelect:r,position:s="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:i,onPointerDownOutside:o,side:l,sideOffset:c,align:d,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:y,hideWhenDetached:x,avoidCollisions:j,...v}=e,g=Ul(ed,r),[b,N]=p.useState(null),[w,S]=p.useState(null),_=dt(t,ne=>N(ne)),[C,P]=p.useState(null),[D,z]=p.useState(null),O=Nb(r),[V,A]=p.useState(!1),$=p.useRef(!1);p.useEffect(()=>{if(b)return Gj(b)},[b]),Uj();const B=p.useCallback(ne=>{const[_e,...ue]=O().map(le=>le.ref.current),[we]=ue.slice(-1),ve=document.activeElement;for(const le of ne)if(le===ve||(le==null||le.scrollIntoView({block:"nearest"}),le===_e&&w&&(w.scrollTop=0),le===we&&w&&(w.scrollTop=w.scrollHeight),le==null||le.focus(),document.activeElement!==ve))return},[O,w]),I=p.useCallback(()=>B([C,b]),[B,C,b]);p.useEffect(()=>{V&&I()},[V,I]);const{onOpenChange:k,triggerPointerDownPosRef:M}=g;p.useEffect(()=>{if(b){let ne={x:0,y:0};const _e=we=>{var ve,le;ne={x:Math.abs(Math.round(we.pageX)-(((ve=M.current)==null?void 0:ve.x)??0)),y:Math.abs(Math.round(we.pageY)-(((le=M.current)==null?void 0:le.y)??0))}},ue=we=>{ne.x<=10&&ne.y<=10?we.preventDefault():b.contains(we.target)||k(!1),document.removeEventListener("pointermove",_e),M.current=null};return M.current!==null&&(document.addEventListener("pointermove",_e),document.addEventListener("pointerup",ue,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",_e),document.removeEventListener("pointerup",ue,{capture:!0})}}},[b,k,M]),p.useEffect(()=>{const ne=()=>k(!1);return window.addEventListener("blur",ne),window.addEventListener("resize",ne),()=>{window.removeEventListener("blur",ne),window.removeEventListener("resize",ne)}},[k]);const[K,X]=K8(ne=>{const _e=O().filter(ve=>!ve.disabled),ue=_e.find(ve=>ve.ref.current===document.activeElement),we=G8(_e,ne,ue);we&&setTimeout(()=>we.ref.current.focus())}),re=p.useCallback((ne,_e,ue)=>{const we=!$.current&&!ue;(g.value!==void 0&&g.value===_e||we)&&(P(ne),we&&($.current=!0))},[g.value]),Z=p.useCallback(()=>b==null?void 0:b.focus(),[b]),te=p.useCallback((ne,_e,ue)=>{const we=!$.current&&!ue;(g.value!==void 0&&g.value===_e||we)&&z(ne)},[g.value]),xe=s==="popper"?CS:E8,me=xe===CS?{side:l,sideOffset:c,align:d,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:y,hideWhenDetached:x,avoidCollisions:j}:{};return n.jsx(P8,{scope:r,content:b,viewport:w,onViewportChange:S,itemRefCallback:re,selectedItem:C,onItemLeave:Z,itemTextRefCallback:te,focusSelectedItem:I,selectedItemText:D,position:s,isPositioned:V,searchRef:K,children:n.jsx(nx,{as:_ie,allowPinchZoom:!0,children:n.jsx(tx,{asChild:!0,trapped:g.open,onMountAutoFocus:ne=>{ne.preventDefault()},onUnmountAutoFocus:be(a,ne=>{var _e;(_e=g.trigger)==null||_e.focus({preventScroll:!0}),ne.preventDefault()}),children:n.jsx(hd,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:ne=>ne.preventDefault(),onDismiss:()=>g.onOpenChange(!1),children:n.jsx(xe,{role:"listbox",id:g.contentId,"data-state":g.open?"open":"closed",dir:g.dir,onContextMenu:ne=>ne.preventDefault(),...v,...me,onPlaced:()=>A(!0),ref:_,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:be(v.onKeyDown,ne=>{const _e=ne.ctrlKey||ne.altKey||ne.metaKey;if(ne.key==="Tab"&&ne.preventDefault(),!_e&&ne.key.length===1&&X(ne.key),["ArrowUp","ArrowDown","Home","End"].includes(ne.key)){let we=O().filter(ve=>!ve.disabled).map(ve=>ve.ref.current);if(["ArrowUp","End"].includes(ne.key)&&(we=we.slice().reverse()),["ArrowUp","ArrowDown"].includes(ne.key)){const ve=ne.target,le=we.indexOf(ve);we=we.slice(le+1)}setTimeout(()=>B(we)),ne.preventDefault()}})})})})})})});A8.displayName=Sie;var Cie="SelectItemAlignedPosition",E8=p.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:s,...a}=e,i=Ul(ed,r),o=Kl(ed,r),[l,c]=p.useState(null),[d,u]=p.useState(null),f=dt(t,_=>u(_)),h=Nb(r),m=p.useRef(!1),y=p.useRef(!0),{viewport:x,selectedItem:j,selectedItemText:v,focusSelectedItem:g}=o,b=p.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&d&&x&&j&&v){const _=i.trigger.getBoundingClientRect(),C=d.getBoundingClientRect(),P=i.valueNode.getBoundingClientRect(),D=v.getBoundingClientRect();if(i.dir!=="rtl"){const ve=D.left-C.left,le=P.left-ve,ut=_.left-le,Se=_.width+ut,Ve=Math.max(Se,C.width),pt=window.innerWidth-Sa,Pt=tp(le,[Sa,Math.max(Sa,pt-Ve)]);l.style.minWidth=Se+"px",l.style.left=Pt+"px"}else{const ve=C.right-D.right,le=window.innerWidth-P.right-ve,ut=window.innerWidth-_.right-le,Se=_.width+ut,Ve=Math.max(Se,C.width),pt=window.innerWidth-Sa,Pt=tp(le,[Sa,Math.max(Sa,pt-Ve)]);l.style.minWidth=Se+"px",l.style.right=Pt+"px"}const z=h(),O=window.innerHeight-Sa*2,V=x.scrollHeight,A=window.getComputedStyle(d),$=parseInt(A.borderTopWidth,10),B=parseInt(A.paddingTop,10),I=parseInt(A.borderBottomWidth,10),k=parseInt(A.paddingBottom,10),M=$+B+V+k+I,K=Math.min(j.offsetHeight*5,M),X=window.getComputedStyle(x),re=parseInt(X.paddingTop,10),Z=parseInt(X.paddingBottom,10),te=_.top+_.height/2-Sa,xe=O-te,me=j.offsetHeight/2,ne=j.offsetTop+me,_e=$+B+ne,ue=M-_e;if(_e<=te){const ve=z.length>0&&j===z[z.length-1].ref.current;l.style.bottom="0px";const le=d.clientHeight-x.offsetTop-x.offsetHeight,ut=Math.max(xe,me+(ve?Z:0)+le+I),Se=_e+ut;l.style.height=Se+"px"}else{const ve=z.length>0&&j===z[0].ref.current;l.style.top="0px";const ut=Math.max(te,$+x.offsetTop+(ve?re:0)+me)+ue;l.style.height=ut+"px",x.scrollTop=_e-te+x.offsetTop}l.style.margin=`${Sa}px 0`,l.style.minHeight=K+"px",l.style.maxHeight=O+"px",s==null||s(),requestAnimationFrame(()=>m.current=!0)}},[h,i.trigger,i.valueNode,l,d,x,j,v,i.dir,s]);Ln(()=>b(),[b]);const[N,w]=p.useState();Ln(()=>{d&&w(window.getComputedStyle(d).zIndex)},[d]);const S=p.useCallback(_=>{_&&y.current===!0&&(b(),g==null||g(),y.current=!1)},[b,g]);return n.jsx(Pie,{scope:r,contentWrapper:l,shouldExpandOnScrollRef:m,onScrollButtonChange:S,children:n.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:N},children:n.jsx(We.div,{...a,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});E8.displayName=Cie;var kie="SelectPopperPosition",CS=p.forwardRef((e,t)=>{const{__scopeSelect:r,align:s="start",collisionPadding:a=Sa,...i}=e,o=Sb(r);return n.jsx(Ij,{...o,...i,ref:t,align:s,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)"}})});CS.displayName=kie;var[Pie,k2]=Xf(ed,{}),kS="SelectViewport",O8=p.forwardRef((e,t)=>{const{__scopeSelect:r,nonce:s,...a}=e,i=Kl(kS,r),o=k2(kS,r),l=dt(t,i.onViewportChange),c=p.useRef(0);return n.jsxs(n.Fragment,{children:[n.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:s}),n.jsx(wb.Slot,{scope:r,children:n.jsx(We.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:be(a.onScroll,d=>{const u=d.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=o;if(h!=null&&h.current&&f){const m=Math.abs(c.current-u.scrollTop);if(m>0){const y=window.innerHeight-Sa*2,x=parseFloat(f.style.minHeight),j=parseFloat(f.style.height),v=Math.max(x,j);if(v0?N:0,f.style.justifyContent="flex-end")}}}c.current=u.scrollTop})})})]})});O8.displayName=kS;var T8="SelectGroup",[Aie,Eie]=Xf(T8),Oie=p.forwardRef((e,t)=>{const{__scopeSelect:r,...s}=e,a=ys();return n.jsx(Aie,{scope:r,id:a,children:n.jsx(We.div,{role:"group","aria-labelledby":a,...s,ref:t})})});Oie.displayName=T8;var M8="SelectLabel",R8=p.forwardRef((e,t)=>{const{__scopeSelect:r,...s}=e,a=Eie(M8,r);return n.jsx(We.div,{id:a.id,...s,ref:t})});R8.displayName=M8;var Gv="SelectItem",[Tie,$8]=Xf(Gv),I8=p.forwardRef((e,t)=>{const{__scopeSelect:r,value:s,disabled:a=!1,textValue:i,...o}=e,l=Ul(Gv,r),c=Kl(Gv,r),d=l.value===s,[u,f]=p.useState(i??""),[h,m]=p.useState(!1),y=dt(t,g=>{var b;return(b=c.itemRefCallback)==null?void 0:b.call(c,g,s,a)}),x=ys(),j=p.useRef("touch"),v=()=>{a||(l.onValueChange(s),l.onOpenChange(!1))};if(s==="")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 n.jsx(Tie,{scope:r,value:s,disabled:a,textId:x,isSelected:d,onItemTextChange:p.useCallback(g=>{f(b=>b||((g==null?void 0:g.textContent)??"").trim())},[]),children:n.jsx(wb.ItemSlot,{scope:r,value:s,disabled:a,textValue:u,children:n.jsx(We.div,{role:"option","aria-labelledby":x,"data-highlighted":h?"":void 0,"aria-selected":d&&h,"data-state":d?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...o,ref:y,onFocus:be(o.onFocus,()=>m(!0)),onBlur:be(o.onBlur,()=>m(!1)),onClick:be(o.onClick,()=>{j.current!=="mouse"&&v()}),onPointerUp:be(o.onPointerUp,()=>{j.current==="mouse"&&v()}),onPointerDown:be(o.onPointerDown,g=>{j.current=g.pointerType}),onPointerMove:be(o.onPointerMove,g=>{var b;j.current=g.pointerType,a?(b=c.onItemLeave)==null||b.call(c):j.current==="mouse"&&g.currentTarget.focus({preventScroll:!0})}),onPointerLeave:be(o.onPointerLeave,g=>{var b;g.currentTarget===document.activeElement&&((b=c.onItemLeave)==null||b.call(c))}),onKeyDown:be(o.onKeyDown,g=>{var N;((N=c.searchRef)==null?void 0:N.current)!==""&&g.key===" "||(gie.includes(g.key)&&v(),g.key===" "&&g.preventDefault())})})})})});I8.displayName=Gv;var nh="SelectItemText",D8=p.forwardRef((e,t)=>{const{__scopeSelect:r,className:s,style:a,...i}=e,o=Ul(nh,r),l=Kl(nh,r),c=$8(nh,r),d=bie(nh,r),[u,f]=p.useState(null),h=dt(t,v=>f(v),c.onItemTextChange,v=>{var g;return(g=l.itemTextRefCallback)==null?void 0:g.call(l,v,c.value,c.disabled)}),m=u==null?void 0:u.textContent,y=p.useMemo(()=>n.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:x,onNativeOptionRemove:j}=d;return Ln(()=>(x(y),()=>j(y)),[x,j,y]),n.jsxs(n.Fragment,{children:[n.jsx(We.span,{id:c.textId,...i,ref:h}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?md.createPortal(i.children,o.valueNode):null]})});D8.displayName=nh;var L8="SelectItemIndicator",F8=p.forwardRef((e,t)=>{const{__scopeSelect:r,...s}=e;return $8(L8,r).isSelected?n.jsx(We.span,{"aria-hidden":!0,...s,ref:t}):null});F8.displayName=L8;var PS="SelectScrollUpButton",B8=p.forwardRef((e,t)=>{const r=Kl(PS,e.__scopeSelect),s=k2(PS,e.__scopeSelect),[a,i]=p.useState(!1),o=dt(t,s.onScrollButtonChange);return Ln(()=>{if(r.viewport&&r.isPositioned){let l=function(){const d=c.scrollTop>0;i(d)};const c=r.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),a?n.jsx(V8,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=r;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});B8.displayName=PS;var AS="SelectScrollDownButton",z8=p.forwardRef((e,t)=>{const r=Kl(AS,e.__scopeSelect),s=k2(AS,e.__scopeSelect),[a,i]=p.useState(!1),o=dt(t,s.onScrollButtonChange);return Ln(()=>{if(r.viewport&&r.isPositioned){let l=function(){const d=c.scrollHeight-c.clientHeight,u=Math.ceil(c.scrollTop)c.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),a?n.jsx(V8,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=r;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});z8.displayName=AS;var V8=p.forwardRef((e,t)=>{const{__scopeSelect:r,onAutoScroll:s,...a}=e,i=Kl("SelectScrollButton",r),o=p.useRef(null),l=Nb(r),c=p.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return p.useEffect(()=>()=>c(),[c]),Ln(()=>{var u;const d=l().find(f=>f.ref.current===document.activeElement);(u=d==null?void 0:d.ref.current)==null||u.scrollIntoView({block:"nearest"})},[l]),n.jsx(We.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:be(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(s,50))}),onPointerMove:be(a.onPointerMove,()=>{var d;(d=i.onItemLeave)==null||d.call(i),o.current===null&&(o.current=window.setInterval(s,50))}),onPointerLeave:be(a.onPointerLeave,()=>{c()})})}),Mie="SelectSeparator",q8=p.forwardRef((e,t)=>{const{__scopeSelect:r,...s}=e;return n.jsx(We.div,{"aria-hidden":!0,...s,ref:t})});q8.displayName=Mie;var ES="SelectArrow",Rie=p.forwardRef((e,t)=>{const{__scopeSelect:r,...s}=e,a=Sb(r),i=Ul(ES,r),o=Kl(ES,r);return i.open&&o.position==="popper"?n.jsx(Dj,{...a,...s,ref:t}):null});Rie.displayName=ES;var $ie="SelectBubbleInput",W8=p.forwardRef(({__scopeSelect:e,value:t,...r},s)=>{const a=p.useRef(null),i=dt(s,a),o=lx(t);return p.useEffect(()=>{const l=a.current;if(!l)return;const c=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(c,"value").set;if(o!==t&&u){const f=new Event("change",{bubbles:!0});u.call(l,t),l.dispatchEvent(f)}},[o,t]),n.jsx(We.select,{...r,style:{...mL,...r.style},ref:i,defaultValue:t})});W8.displayName=$ie;function U8(e){return e===""||e===void 0}function K8(e){const t=Dn(e),r=p.useRef(""),s=p.useRef(0),a=p.useCallback(o=>{const l=r.current+o;t(l),function c(d){r.current=d,window.clearTimeout(s.current),d!==""&&(s.current=window.setTimeout(()=>c(""),1e3))}(l)},[t]),i=p.useCallback(()=>{r.current="",window.clearTimeout(s.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(s.current),[]),[r,a,i]}function G8(e,t,r){const a=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,i=r?e.indexOf(r):-1;let o=Iie(e,Math.max(i,0));a.length===1&&(o=o.filter(d=>d!==r));const c=o.find(d=>d.textValue.toLowerCase().startsWith(a.toLowerCase()));return c!==r?c:void 0}function Iie(e,t){return e.map((r,s)=>e[(t+s)%e.length])}var Die=j8,H8=w8,Lie=S8,Fie=_8,Bie=C8,Q8=k8,zie=O8,Y8=R8,X8=I8,Vie=D8,qie=F8,Z8=B8,J8=z8,eB=q8;const Oe=Die,Me=Lie,Ae=p.forwardRef(({className:e,children:t,...r},s)=>n.jsxs(H8,{ref:s,className:he("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...r,children:[t,n.jsx(Fie,{asChild:!0,children:n.jsx(rr,{className:"h-4 w-4 opacity-50"})})]}));Ae.displayName=H8.displayName;const tB=p.forwardRef(({className:e,...t},r)=>n.jsx(Z8,{ref:r,className:he("flex cursor-default items-center justify-center py-1",e),...t,children:n.jsx(LL,{className:"h-4 w-4"})}));tB.displayName=Z8.displayName;const nB=p.forwardRef(({className:e,...t},r)=>n.jsx(J8,{ref:r,className:he("flex cursor-default items-center justify-center py-1",e),...t,children:n.jsx(rr,{className:"h-4 w-4"})}));nB.displayName=J8.displayName;const Ee=p.forwardRef(({className:e,children:t,position:r="popper",...s},a)=>n.jsx(Bie,{children:n.jsxs(Q8,{ref:a,className:he("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",r==="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",e),position:r,...s,children:[n.jsx(tB,{}),n.jsx(zie,{className:he("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),n.jsx(nB,{})]})}));Ee.displayName=Q8.displayName;const Wie=p.forwardRef(({className:e,...t},r)=>n.jsx(Y8,{ref:r,className:he("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Wie.displayName=Y8.displayName;const Y=p.forwardRef(({className:e,children:t,...r},s)=>n.jsxs(X8,{ref:s,className:he("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...r,children:[n.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx(qie,{children:n.jsx(aa,{className:"h-4 w-4"})})}),n.jsx(Vie,{children:t})]}));Y.displayName=X8.displayName;const Uie=p.forwardRef(({className:e,...t},r)=>n.jsx(eB,{ref:r,className:he("-mx-1 my-1 h-px bg-muted",e),...t}));Uie.displayName=eB.displayName;function Kie(e){const t=Gie(e),r=p.forwardRef((s,a)=>{const{children:i,...o}=s,l=p.Children.toArray(i),c=l.find(Qie);if(c){const d=c.props.children,u=l.map(f=>f===c?p.Children.count(d)>1?p.Children.only(null):p.isValidElement(d)?d.props.children:null:f);return n.jsx(t,{...o,ref:a,children:p.isValidElement(d)?p.cloneElement(d,void 0,u):null})}return n.jsx(t,{...o,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function Gie(e){const t=p.forwardRef((r,s)=>{const{children:a,...i}=r;if(p.isValidElement(a)){const o=Xie(a),l=Yie(i,a.props);return a.type!==p.Fragment&&(l.ref=s?Ni(s,o):o),p.cloneElement(a,l)}return p.Children.count(a)>1?p.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Hie=Symbol("radix.slottable");function Qie(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Hie}function Yie(e,t){const r={...t};for(const s in t){const a=e[s],i=t[s];/^on[A-Z]/.test(s)?a&&i?r[s]=(...l)=>{const c=i(...l);return a(...l),c}:a&&(r[s]=a):s==="style"?r[s]={...a,...i}:s==="className"&&(r[s]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function Xie(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var _b="Popover",[rB]=lr(_b,[Fl]),ux=Fl(),[Zie,Gl]=rB(_b),sB=e=>{const{__scopePopover:t,children:r,open:s,defaultOpen:a,onOpenChange:i,modal:o=!1}=e,l=ux(t),c=p.useRef(null),[d,u]=p.useState(!1),[f,h]=zr({prop:s,defaultProp:a??!1,onChange:i,caller:_b});return n.jsx($j,{...l,children:n.jsx(Zie,{scope:t,contentId:ys(),triggerRef:c,open:f,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(m=>!m),[h]),hasCustomAnchor:d,onCustomAnchorAdd:p.useCallback(()=>u(!0),[]),onCustomAnchorRemove:p.useCallback(()=>u(!1),[]),modal:o,children:r})})};sB.displayName=_b;var aB="PopoverAnchor",Jie=p.forwardRef((e,t)=>{const{__scopePopover:r,...s}=e,a=Gl(aB,r),i=ux(r),{onCustomAnchorAdd:o,onCustomAnchorRemove:l}=a;return p.useEffect(()=>(o(),()=>l()),[o,l]),n.jsx(Jp,{...i,...s,ref:t})});Jie.displayName=aB;var iB="PopoverTrigger",oB=p.forwardRef((e,t)=>{const{__scopePopover:r,...s}=e,a=Gl(iB,r),i=ux(r),o=dt(t,a.triggerRef),l=n.jsx(We.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":fB(a.open),...s,ref:o,onClick:be(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?l:n.jsx(Jp,{asChild:!0,...i,children:l})});oB.displayName=iB;var P2="PopoverPortal",[eoe,toe]=rB(P2,{forceMount:void 0}),lB=e=>{const{__scopePopover:t,forceMount:r,children:s,container:a}=e,i=Gl(P2,t);return n.jsx(eoe,{scope:t,forceMount:r,children:n.jsx(Jn,{present:r||i.open,children:n.jsx(Lf,{asChild:!0,container:a,children:s})})})};lB.displayName=P2;var sf="PopoverContent",cB=p.forwardRef((e,t)=>{const r=toe(sf,e.__scopePopover),{forceMount:s=r.forceMount,...a}=e,i=Gl(sf,e.__scopePopover);return n.jsx(Jn,{present:s||i.open,children:i.modal?n.jsx(roe,{...a,ref:t}):n.jsx(soe,{...a,ref:t})})});cB.displayName=sf;var noe=Kie("PopoverContent.RemoveScroll"),roe=p.forwardRef((e,t)=>{const r=Gl(sf,e.__scopePopover),s=p.useRef(null),a=dt(t,s),i=p.useRef(!1);return p.useEffect(()=>{const o=s.current;if(o)return Gj(o)},[]),n.jsx(nx,{as:noe,allowPinchZoom:!0,children:n.jsx(dB,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:be(e.onCloseAutoFocus,o=>{var l;o.preventDefault(),i.current||(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:be(e.onPointerDownOutside,o=>{const l=o.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;i.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:be(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),soe=p.forwardRef((e,t)=>{const r=Gl(sf,e.__scopePopover),s=p.useRef(!1),a=p.useRef(!1);return n.jsx(dB,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,l;(o=e.onCloseAutoFocus)==null||o.call(e,i),i.defaultPrevented||(s.current||(l=r.triggerRef.current)==null||l.focus(),i.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:i=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,i),i.defaultPrevented||(s.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((d=r.triggerRef.current)==null?void 0:d.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),dB=p.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:u,...f}=e,h=Gl(sf,r),m=ux(r);return Uj(),n.jsx(tx,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:i,children:n.jsx(hd,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>h.onOpenChange(!1),children:n.jsx(Ij,{"data-state":fB(h.open),role:"dialog",id:h.contentId,...m,...f,ref:t,style:{...f.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)"}})})})}),uB="PopoverClose",aoe=p.forwardRef((e,t)=>{const{__scopePopover:r,...s}=e,a=Gl(uB,r);return n.jsx(We.button,{type:"button",...s,ref:t,onClick:be(e.onClick,()=>a.onOpenChange(!1))})});aoe.displayName=uB;var ioe="PopoverArrow",ooe=p.forwardRef((e,t)=>{const{__scopePopover:r,...s}=e,a=ux(r);return n.jsx(Dj,{...a,...s,ref:t})});ooe.displayName=ioe;function fB(e){return e?"open":"closed"}var loe=sB,coe=oB,doe=lB,mB=cB;const uoe=loe,foe=coe,hB=p.forwardRef(({className:e,align:t="center",sideOffset:r=4,...s},a)=>n.jsx(doe,{children:n.jsx(mB,{ref:a,align:t,sideOffset:r,className:he("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",e),...s})}));hB.displayName=mB.displayName;var xt=function(){return xt=Object.assign||function(t){for(var r,s=1,a=arguments.length;s1&&(c||!d),f=t>1&&(d||!c),h=function(){s&&i(s)},m=function(){a&&i(a)};return n.jsx(Uoe,{displayMonth:e.displayMonth,hideNext:u,hidePrevious:f,nextMonth:a,previousMonth:s,onPreviousClick:h,onNextClick:m})}function Koe(e){var t,r=hn(),s=r.classNames,a=r.disableNavigation,i=r.styles,o=r.captionLayout,l=r.components,c=(t=l==null?void 0:l.CaptionLabel)!==null&&t!==void 0?t:gB,d;return a?d=n.jsx(c,{id:e.id,displayMonth:e.displayMonth}):o==="dropdown"?d=n.jsx(sT,{displayMonth:e.displayMonth,id:e.id}):o==="dropdown-buttons"?d=n.jsxs(n.Fragment,{children:[n.jsx(sT,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),n.jsx(aT,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}):d=n.jsxs(n.Fragment,{children:[n.jsx(c,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),n.jsx(aT,{displayMonth:e.displayMonth,id:e.id})]}),n.jsx("div",{className:s.caption,style:i.caption,children:d})}function Goe(e){var t=hn(),r=t.footer,s=t.styles,a=t.classNames.tfoot;return r?n.jsx("tfoot",{className:a,style:s.tfoot,children:n.jsx("tr",{children:n.jsx("td",{colSpan:8,children:r})})}):n.jsx(n.Fragment,{})}function Hoe(e,t,r){for(var s=r?Zc(new Date):ji(new Date,{locale:e,weekStartsOn:t}),a=[],i=0;i<7;i++){var o=Kr(s,i);a.push(o)}return a}function Qoe(){var e=hn(),t=e.classNames,r=e.styles,s=e.showWeekNumber,a=e.locale,i=e.weekStartsOn,o=e.ISOWeek,l=e.formatters.formatWeekdayName,c=e.labels.labelWeekday,d=Hoe(a,i,o);return n.jsxs("tr",{style:r.head_row,className:t.head_row,children:[s&&n.jsx("td",{style:r.head_cell,className:t.head_cell}),d.map(function(u,f){return n.jsx("th",{scope:"col",className:t.head_cell,style:r.head_cell,"aria-label":c(u,{locale:a}),children:l(u,{locale:a})},f)})]})}function Yoe(){var e,t=hn(),r=t.classNames,s=t.styles,a=t.components,i=(e=a==null?void 0:a.HeadRow)!==null&&e!==void 0?e:Qoe;return n.jsx("thead",{style:s.head,className:r.head,children:n.jsx(i,{})})}function Xoe(e){var t=hn(),r=t.locale,s=t.formatters.formatDay;return n.jsx(n.Fragment,{children:s(e.date,{locale:r})})}var A2=p.createContext(void 0);function Zoe(e){if(!fx(e.initialProps)){var t={selected:void 0,modifiers:{disabled:[]}};return n.jsx(A2.Provider,{value:t,children:e.children})}return n.jsx(Joe,{initialProps:e.initialProps,children:e.children})}function Joe(e){var t=e.initialProps,r=e.children,s=t.selected,a=t.min,i=t.max,o=function(d,u,f){var h,m;(h=t.onDayClick)===null||h===void 0||h.call(t,d,u,f);var y=!!(u.selected&&a&&(s==null?void 0:s.length)===a);if(!y){var x=!!(!u.selected&&i&&(s==null?void 0:s.length)===i);if(!x){var j=s?pB([],s):[];if(u.selected){var v=j.findIndex(function(g){return hs(d,g)});j.splice(v,1)}else j.push(d);(m=t.onSelect)===null||m===void 0||m.call(t,j,d,u,f)}}},l={disabled:[]};s&&l.disabled.push(function(d){var u=i&&s.length>i-1,f=s.some(function(h){return hs(h,d)});return!!(u&&!f)});var c={selected:s,onDayClick:o,modifiers:l};return n.jsx(A2.Provider,{value:c,children:r})}function E2(){var e=p.useContext(A2);if(!e)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}function ele(e,t){var r=t||{},s=r.from,a=r.to;return s&&a?hs(a,e)&&hs(s,e)?void 0:hs(a,e)?{from:a,to:void 0}:hs(s,e)?void 0:wS(s,e)?{from:e,to:a}:{from:s,to:e}:a?wS(e,a)?{from:a,to:e}:{from:e,to:a}:s?s8(e,s)?{from:e,to:s}:{from:s,to:e}:{from:e,to:void 0}}var O2=p.createContext(void 0);function tle(e){if(!mx(e.initialProps)){var t={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return n.jsx(O2.Provider,{value:t,children:e.children})}return n.jsx(nle,{initialProps:e.initialProps,children:e.children})}function nle(e){var t=e.initialProps,r=e.children,s=t.selected,a=s||{},i=a.from,o=a.to,l=t.min,c=t.max,d=function(m,y,x){var j,v;(j=t.onDayClick)===null||j===void 0||j.call(t,m,y,x);var g=ele(m,s);(v=t.onSelect)===null||v===void 0||v.call(t,g,m,y,x)},u={range_start:[],range_end:[],range_middle:[],disabled:[]};if(i?(u.range_start=[i],o?(u.range_end=[o],hs(i,o)||(u.range_middle=[{after:i,before:o}])):u.range_end=[i]):o&&(u.range_start=[o],u.range_end=[o]),l&&(i&&!o&&u.disabled.push({after:Dw(i,l-1),before:Kr(i,l-1)}),i&&o&&u.disabled.push({after:i,before:Kr(i,l-1)}),!i&&o&&u.disabled.push({after:Dw(o,l-1),before:Kr(o,l-1)})),c){if(i&&!o&&(u.disabled.push({before:Kr(i,-c+1)}),u.disabled.push({after:Kr(i,c-1)})),i&&o){var f=li(o,i)+1,h=c-f;u.disabled.push({before:Dw(i,h)}),u.disabled.push({after:Kr(o,h)})}!i&&o&&(u.disabled.push({before:Kr(o,-c+1)}),u.disabled.push({after:Kr(o,c-1)}))}return n.jsx(O2.Provider,{value:{selected:s,onDayClick:d,modifiers:u},children:r})}function T2(){var e=p.useContext(O2);if(!e)throw new Error("useSelectRange must be used within a SelectRangeProvider");return e}function Xg(e){return Array.isArray(e)?pB([],e):e!==void 0?[e]:[]}function rle(e){var t={};return Object.entries(e).forEach(function(r){var s=r[0],a=r[1];t[s]=Xg(a)}),t}var Wa;(function(e){e.Outside="outside",e.Disabled="disabled",e.Selected="selected",e.Hidden="hidden",e.Today="today",e.RangeStart="range_start",e.RangeEnd="range_end",e.RangeMiddle="range_middle"})(Wa||(Wa={}));var sle=Wa.Selected,$i=Wa.Disabled,ale=Wa.Hidden,ile=Wa.Today,Fw=Wa.RangeEnd,Bw=Wa.RangeMiddle,zw=Wa.RangeStart,ole=Wa.Outside;function lle(e,t,r){var s,a=(s={},s[sle]=Xg(e.selected),s[$i]=Xg(e.disabled),s[ale]=Xg(e.hidden),s[ile]=[e.today],s[Fw]=[],s[Bw]=[],s[zw]=[],s[ole]=[],s);return e.fromDate&&a[$i].push({before:e.fromDate}),e.toDate&&a[$i].push({after:e.toDate}),fx(e)?a[$i]=a[$i].concat(t.modifiers[$i]):mx(e)&&(a[$i]=a[$i].concat(r.modifiers[$i]),a[zw]=r.modifiers[zw],a[Bw]=r.modifiers[Bw],a[Fw]=r.modifiers[Fw]),a}var jB=p.createContext(void 0);function cle(e){var t=hn(),r=E2(),s=T2(),a=lle(t,r,s),i=rle(t.modifiers),o=xt(xt({},a),i);return n.jsx(jB.Provider,{value:o,children:e.children})}function bB(){var e=p.useContext(jB);if(!e)throw new Error("useModifiers must be used within a ModifiersProvider");return e}function dle(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function ule(e){return!!(e&&typeof e=="object"&&"from"in e)}function fle(e){return!!(e&&typeof e=="object"&&"after"in e)}function mle(e){return!!(e&&typeof e=="object"&&"before"in e)}function hle(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function ple(e,t){var r,s=t.from,a=t.to;if(s&&a){var i=li(a,s)<0;i&&(r=[a,s],s=r[0],a=r[1]);var o=li(e,s)>=0&&li(a,e)>=0;return o}return a?hs(a,e):s?hs(s,e):!1}function xle(e){return w2(e)}function gle(e){return Array.isArray(e)&&e.every(w2)}function vle(e,t){return t.some(function(r){if(typeof r=="boolean")return r;if(xle(r))return hs(e,r);if(gle(r))return r.includes(e);if(ule(r))return ple(e,r);if(hle(r))return r.dayOfWeek.includes(e.getDay());if(dle(r)){var s=li(r.before,e),a=li(r.after,e),i=s>0,o=a<0,l=wS(r.before,r.after);return l?o&&i:i||o}return fle(r)?li(e,r.after)>0:mle(r)?li(r.before,e)>0:typeof r=="function"?r(e):!1})}function M2(e,t,r){var s=Object.keys(t).reduce(function(i,o){var l=t[o];return vle(e,l)&&i.push(o),i},[]),a={};return s.forEach(function(i){return a[i]=!0}),r&&!_2(e,r)&&(a.outside=!0),a}function yle(e,t){for(var r=js(e[0]),s=N2(e[e.length-1]),a,i,o=r;o<=s;){var l=M2(o,t),c=!l.disabled&&!l.hidden;if(!c){o=Kr(o,1);continue}if(l.selected)return o;l.today&&!i&&(i=o),a||(a=o),o=Kr(o,1)}return i||a}var jle=365;function wB(e,t){var r=t.moveBy,s=t.direction,a=t.context,i=t.modifiers,o=t.retry,l=o===void 0?{count:0,lastFocused:e}:o,c=a.weekStartsOn,d=a.fromDate,u=a.toDate,f=a.locale,h={day:Kr,week:bS,month:qa,year:zse,startOfWeek:function(j){return a.ISOWeek?Zc(j):ji(j,{locale:f,weekStartsOn:c})},endOfWeek:function(j){return a.ISOWeek?Z6(j):S2(j,{locale:f,weekStartsOn:c})}},m=h[r](e,s==="after"?1:-1);s==="before"&&d?m=Vse([d,m]):s==="after"&&u&&(m=qse([u,m]));var y=!0;if(i){var x=M2(m,i);y=!x.disabled&&!x.hidden}return y?m:l.count>jle?l.lastFocused:wB(m,{moveBy:r,direction:s,context:a,modifiers:i,retry:xt(xt({},l),{count:l.count+1})})}var NB=p.createContext(void 0);function ble(e){var t=hx(),r=bB(),s=p.useState(),a=s[0],i=s[1],o=p.useState(),l=o[0],c=o[1],d=yle(t.displayMonths,r),u=a??(l&&t.isDateDisplayed(l))?l:d,f=function(){c(a),i(void 0)},h=function(j){i(j)},m=hn(),y=function(j,v){if(a){var g=wB(a,{moveBy:j,direction:v,context:m,modifiers:r});hs(a,g)||(t.goToDate(g,a),h(g))}},x={focusedDay:a,focusTarget:u,blur:f,focus:h,focusDayAfter:function(){return y("day","after")},focusDayBefore:function(){return y("day","before")},focusWeekAfter:function(){return y("week","after")},focusWeekBefore:function(){return y("week","before")},focusMonthBefore:function(){return y("month","before")},focusMonthAfter:function(){return y("month","after")},focusYearBefore:function(){return y("year","before")},focusYearAfter:function(){return y("year","after")},focusStartOfWeek:function(){return y("startOfWeek","before")},focusEndOfWeek:function(){return y("endOfWeek","after")}};return n.jsx(NB.Provider,{value:x,children:e.children})}function R2(){var e=p.useContext(NB);if(!e)throw new Error("useFocusContext must be used within a FocusProvider");return e}function wle(e,t){var r=bB(),s=M2(e,r,t);return s}var $2=p.createContext(void 0);function Nle(e){if(!Cb(e.initialProps)){var t={selected:void 0};return n.jsx($2.Provider,{value:t,children:e.children})}return n.jsx(Sle,{initialProps:e.initialProps,children:e.children})}function Sle(e){var t=e.initialProps,r=e.children,s=function(i,o,l){var c,d,u;if((c=t.onDayClick)===null||c===void 0||c.call(t,i,o,l),o.selected&&!t.required){(d=t.onSelect)===null||d===void 0||d.call(t,void 0,i,o,l);return}(u=t.onSelect)===null||u===void 0||u.call(t,i,i,o,l)},a={selected:t.selected,onDayClick:s};return n.jsx($2.Provider,{value:a,children:r})}function SB(){var e=p.useContext($2);if(!e)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return e}function _le(e,t){var r=hn(),s=SB(),a=E2(),i=T2(),o=R2(),l=o.focusDayAfter,c=o.focusDayBefore,d=o.focusWeekAfter,u=o.focusWeekBefore,f=o.blur,h=o.focus,m=o.focusMonthBefore,y=o.focusMonthAfter,x=o.focusYearBefore,j=o.focusYearAfter,v=o.focusStartOfWeek,g=o.focusEndOfWeek,b=function(I){var k,M,K,X;Cb(r)?(k=s.onDayClick)===null||k===void 0||k.call(s,e,t,I):fx(r)?(M=a.onDayClick)===null||M===void 0||M.call(a,e,t,I):mx(r)?(K=i.onDayClick)===null||K===void 0||K.call(i,e,t,I):(X=r.onDayClick)===null||X===void 0||X.call(r,e,t,I)},N=function(I){var k;h(e),(k=r.onDayFocus)===null||k===void 0||k.call(r,e,t,I)},w=function(I){var k;f(),(k=r.onDayBlur)===null||k===void 0||k.call(r,e,t,I)},S=function(I){var k;(k=r.onDayMouseEnter)===null||k===void 0||k.call(r,e,t,I)},_=function(I){var k;(k=r.onDayMouseLeave)===null||k===void 0||k.call(r,e,t,I)},C=function(I){var k;(k=r.onDayPointerEnter)===null||k===void 0||k.call(r,e,t,I)},P=function(I){var k;(k=r.onDayPointerLeave)===null||k===void 0||k.call(r,e,t,I)},D=function(I){var k;(k=r.onDayTouchCancel)===null||k===void 0||k.call(r,e,t,I)},z=function(I){var k;(k=r.onDayTouchEnd)===null||k===void 0||k.call(r,e,t,I)},O=function(I){var k;(k=r.onDayTouchMove)===null||k===void 0||k.call(r,e,t,I)},V=function(I){var k;(k=r.onDayTouchStart)===null||k===void 0||k.call(r,e,t,I)},A=function(I){var k;(k=r.onDayKeyUp)===null||k===void 0||k.call(r,e,t,I)},$=function(I){var k;switch(I.key){case"ArrowLeft":I.preventDefault(),I.stopPropagation(),r.dir==="rtl"?l():c();break;case"ArrowRight":I.preventDefault(),I.stopPropagation(),r.dir==="rtl"?c():l();break;case"ArrowDown":I.preventDefault(),I.stopPropagation(),d();break;case"ArrowUp":I.preventDefault(),I.stopPropagation(),u();break;case"PageUp":I.preventDefault(),I.stopPropagation(),I.shiftKey?x():m();break;case"PageDown":I.preventDefault(),I.stopPropagation(),I.shiftKey?j():y();break;case"Home":I.preventDefault(),I.stopPropagation(),v();break;case"End":I.preventDefault(),I.stopPropagation(),g();break}(k=r.onDayKeyDown)===null||k===void 0||k.call(r,e,t,I)},B={onClick:b,onFocus:N,onBlur:w,onKeyDown:$,onKeyUp:A,onMouseEnter:S,onMouseLeave:_,onPointerEnter:C,onPointerLeave:P,onTouchCancel:D,onTouchEnd:z,onTouchMove:O,onTouchStart:V};return B}function Cle(){var e=hn(),t=SB(),r=E2(),s=T2(),a=Cb(e)?t.selected:fx(e)?r.selected:mx(e)?s.selected:void 0;return a}function kle(e){return Object.values(Wa).includes(e)}function Ple(e,t){var r=[e.classNames.day];return Object.keys(t).forEach(function(s){var a=e.modifiersClassNames[s];if(a)r.push(a);else if(kle(s)){var i=e.classNames["day_".concat(s)];i&&r.push(i)}}),r}function Ale(e,t){var r=xt({},e.styles.day);return Object.keys(t).forEach(function(s){var a;r=xt(xt({},r),(a=e.modifiersStyles)===null||a===void 0?void 0:a[s])}),r}function Ele(e,t,r){var s,a,i,o=hn(),l=R2(),c=wle(e,t),d=_le(e,c),u=Cle(),f=!!(o.onDayClick||o.mode!=="default");p.useEffect(function(){var S;c.outside||l.focusedDay&&f&&hs(l.focusedDay,e)&&((S=r.current)===null||S===void 0||S.focus())},[l.focusedDay,e,r,f,c.outside]);var h=Ple(o,c).join(" "),m=Ale(o,c),y=!!(c.outside&&!o.showOutsideDays||c.hidden),x=(i=(a=o.components)===null||a===void 0?void 0:a.DayContent)!==null&&i!==void 0?i:Xoe,j=n.jsx(x,{date:e,displayMonth:t,activeModifiers:c}),v={style:m,className:h,children:j,role:"gridcell"},g=l.focusTarget&&hs(l.focusTarget,e)&&!c.outside,b=l.focusedDay&&hs(l.focusedDay,e),N=xt(xt(xt({},v),(s={disabled:c.disabled,role:"gridcell"},s["aria-selected"]=c.selected,s.tabIndex=b||g?0:-1,s)),d),w={isButton:f,isHidden:y,activeModifiers:c,selectedDays:u,buttonProps:N,divProps:v};return w}function Ole(e){var t=p.useRef(null),r=Ele(e.date,e.displayMonth,t);return r.isHidden?n.jsx("div",{role:"gridcell"}):r.isButton?n.jsx(Hv,xt({name:"day",ref:t},r.buttonProps)):n.jsx("div",xt({},r.divProps))}function Tle(e){var t=e.number,r=e.dates,s=hn(),a=s.onWeekNumberClick,i=s.styles,o=s.classNames,l=s.locale,c=s.labels.labelWeekNumber,d=s.formatters.formatWeekNumber,u=d(Number(t),{locale:l});if(!a)return n.jsx("span",{className:o.weeknumber,style:i.weeknumber,children:u});var f=c(Number(t),{locale:l}),h=function(m){a(t,r,m)};return n.jsx(Hv,{name:"week-number","aria-label":f,className:o.weeknumber,style:i.weeknumber,onClick:h,children:u})}function Mle(e){var t,r,s=hn(),a=s.styles,i=s.classNames,o=s.showWeekNumber,l=s.components,c=(t=l==null?void 0:l.Day)!==null&&t!==void 0?t:Ole,d=(r=l==null?void 0:l.WeekNumber)!==null&&r!==void 0?r:Tle,u;return o&&(u=n.jsx("td",{className:i.cell,style:a.cell,children:n.jsx(d,{number:e.weekNumber,dates:e.dates})})),n.jsxs("tr",{className:i.row,style:a.row,children:[u,e.dates.map(function(f){return n.jsx("td",{className:i.cell,style:a.cell,role:"presentation",children:n.jsx(c,{displayMonth:e.displayMonth,date:f})},Vae(f))})]})}function iT(e,t,r){for(var s=r!=null&&r.ISOWeek?Z6(t):S2(t,r),a=r!=null&&r.ISOWeek?Zc(e):ji(e,r),i=li(s,a),o=[],l=0;l<=i;l++)o.push(Kr(a,l));var c=o.reduce(function(d,u){var f=r!=null&&r.ISOWeek?e8(u):n8(u,r),h=d.find(function(m){return m.weekNumber===f});return h?(h.dates.push(u),d):(d.push({weekNumber:f,dates:[u]}),d)},[]);return c}function Rle(e,t){var r=iT(js(e),N2(e),t);if(t!=null&&t.useFixedWeeks){var s=Wae(e,t);if(s<6){var a=r[r.length-1],i=a.dates[a.dates.length-1],o=bS(i,6-s),l=iT(bS(i,1),o,t);r.push.apply(r,l)}}return r}function $le(e){var t,r,s,a=hn(),i=a.locale,o=a.classNames,l=a.styles,c=a.hideHead,d=a.fixedWeeks,u=a.components,f=a.weekStartsOn,h=a.firstWeekContainsDate,m=a.ISOWeek,y=Rle(e.displayMonth,{useFixedWeeks:!!d,ISOWeek:m,locale:i,weekStartsOn:f,firstWeekContainsDate:h}),x=(t=u==null?void 0:u.Head)!==null&&t!==void 0?t:Yoe,j=(r=u==null?void 0:u.Row)!==null&&r!==void 0?r:Mle,v=(s=u==null?void 0:u.Footer)!==null&&s!==void 0?s:Goe;return n.jsxs("table",{id:e.id,className:o.table,style:l.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!c&&n.jsx(x,{}),n.jsx("tbody",{className:o.tbody,style:l.tbody,children:y.map(function(g){return n.jsx(j,{displayMonth:e.displayMonth,dates:g.dates,weekNumber:g.weekNumber},g.weekNumber)})}),n.jsx(v,{displayMonth:e.displayMonth})]})}function Ile(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Dle=Ile()?p.useLayoutEffect:p.useEffect,Vw=!1,Lle=0;function oT(){return"react-day-picker-".concat(++Lle)}function Fle(e){var t,r=e??(Vw?oT():null),s=p.useState(r),a=s[0],i=s[1];return Dle(function(){a===null&&i(oT())},[]),p.useEffect(function(){Vw===!1&&(Vw=!0)},[]),(t=e??a)!==null&&t!==void 0?t:void 0}function Ble(e){var t,r,s=hn(),a=s.dir,i=s.classNames,o=s.styles,l=s.components,c=hx().displayMonths,d=Fle(s.id?"".concat(s.id,"-").concat(e.displayIndex):void 0),u=s.id?"".concat(s.id,"-grid-").concat(e.displayIndex):void 0,f=[i.month],h=o.month,m=e.displayIndex===0,y=e.displayIndex===c.length-1,x=!m&&!y;a==="rtl"&&(t=[m,y],y=t[0],m=t[1]),m&&(f.push(i.caption_start),h=xt(xt({},h),o.caption_start)),y&&(f.push(i.caption_end),h=xt(xt({},h),o.caption_end)),x&&(f.push(i.caption_between),h=xt(xt({},h),o.caption_between));var j=(r=l==null?void 0:l.Caption)!==null&&r!==void 0?r:Koe;return n.jsxs("div",{className:f.join(" "),style:h,children:[n.jsx(j,{id:d,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),n.jsx($le,{id:u,"aria-labelledby":d,displayMonth:e.displayMonth})]},e.displayIndex)}function zle(e){var t=hn(),r=t.classNames,s=t.styles;return n.jsx("div",{className:r.months,style:s.months,children:e.children})}function Vle(e){var t,r,s=e.initialProps,a=hn(),i=R2(),o=hx(),l=p.useState(!1),c=l[0],d=l[1];p.useEffect(function(){a.initialFocus&&i.focusTarget&&(c||(i.focus(i.focusTarget),d(!0)))},[a.initialFocus,c,i.focus,i.focusTarget,i]);var u=[a.classNames.root,a.className];a.numberOfMonths>1&&u.push(a.classNames.multiple_months),a.showWeekNumber&&u.push(a.classNames.with_weeknumber);var f=xt(xt({},a.styles.root),a.style),h=Object.keys(s).filter(function(y){return y.startsWith("data-")}).reduce(function(y,x){var j;return xt(xt({},y),(j={},j[x]=s[x],j))},{}),m=(r=(t=s.components)===null||t===void 0?void 0:t.Months)!==null&&r!==void 0?r:zle;return n.jsx("div",xt({className:u.join(" "),style:f,dir:a.dir,id:a.id,nonce:s.nonce,title:s.title,lang:s.lang},h,{children:n.jsx(m,{children:o.displayMonths.map(function(y,x){return n.jsx(Ble,{displayIndex:x,displayMonth:y},x)})})}))}function qle(e){var t=e.children,r=moe(e,["children"]);return n.jsx(Toe,{initialProps:r,children:n.jsx(Voe,{children:n.jsx(Nle,{initialProps:r,children:n.jsx(Zoe,{initialProps:r,children:n.jsx(tle,{initialProps:r,children:n.jsx(cle,{children:n.jsx(ble,{children:t})})})})})})})}function Wle(e){return n.jsx(qle,xt({},e,{children:n.jsx(Vle,{initialProps:e})}))}function _B({className:e,classNames:t,showOutsideDays:r=!0,...s}){return n.jsx(Wle,{showOutsideDays:r,className:he("p-3",e),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:he(sS({variant:"outline"}),"h-7 w-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-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:he(sS({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",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 opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...t},components:{IconLeft:({...a})=>n.jsx(DL,{className:"h-4 w-4"}),IconRight:({...a})=>n.jsx(Si,{className:"h-4 w-4"})},...s})}_B.displayName="Calendar";const Ule=pd("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),td=p.forwardRef(({className:e,variant:t,...r},s)=>n.jsx("div",{ref:s,role:"alert",className:he(Ule({variant:t}),e),...r}));td.displayName="Alert";const nd=p.forwardRef(({className:e,...t},r)=>n.jsx("h5",{ref:r,className:he("mb-1 font-medium leading-none tracking-tight",e),...t}));nd.displayName="AlertTitle";const rd=p.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:he("text-sm [&_p]:leading-relaxed",e),...t}));rd.displayName="AlertDescription";const ac=["Goal","Target","Study","Placement"],Kle=[{value:"pre_a1",label:"Pre-A1"},{value:"a1",label:"A1"},{value:"a2",label:"A2"},{value:"b1",label:"B1"},{value:"b2",label:"B2"},{value:"c1",label:"C1"},{value:"c2",label:"C2"}],Gle=No({goal:wn().min(1,"Choose a goal"),targetBand:Js().min(4).max(9),targetLevel:wn().min(1,"Select a CEFR level"),examDate:Ure().optional(),noExamDate:Ho(),hoursPerWeek:Js().min(1).max(40),studyMode:Ta(["self_study","with_teacher"]),learningVisual:Ho(),learningAudio:Ho(),learningReading:Ho(),learningMixed:Ho(),placementDecision:Ta(["take_now","skip"])}),Hle={BookOpen:Kt,Sparkles:lt,GraduationCap:_i,Layers:oo,Mic:Pj,Headphones:Cj,PenLine:hk,Users:as};function Qle({name:e}){const t=Hle[e]||Kt;return n.jsx(t,{className:"h-6 w-6"})}function Yle(e){switch(e){case"student":return"/student/dashboard";case"teacher":return"/teacher/dashboard";case"admin":case"developer":return"/admin/dashboard";case"corporate":case"mastercorporate":case"agent":return"/admin/platform";default:return"/student/dashboard"}}function Xle(e){const t=[];return e.learningVisual&&t.push("visual"),e.learningAudio&&t.push("audio"),e.learningReading&&t.push("reading"),e.learningMixed&&t.push("mixed"),{goal:e.goal,target_band:e.targetBand,target_level:e.targetLevel,exam_date:e.noExamDate?void 0:e.examDate?Pi(e.examDate,"yyyy-MM-dd"):void 0,hours_per_week:e.hoursPerWeek,study_mode:e.studyMode,learning_style:t,placement_decision:e.placementDecision}}function Zle(){const{user:e,isLoading:t}=Ga(),r=Bt(),{data:s,isLoading:a,error:i}=mse(),o=vse(),[l,c]=p.useState(0),d=Vl({resolver:ql(Gle),defaultValues:{goal:"",targetBand:6.5,targetLevel:"b2",examDate:void 0,noExamDate:!1,hoursPerWeek:8,studyMode:"self_study",learningVisual:!0,learningAudio:!1,learningReading:!1,learningMixed:!0,placementDecision:"take_now"},mode:"onChange"}),u=p.useMemo(()=>(l+1)/ac.length*100,[l]),f=async()=>{const m=[["goal"],["targetBand","targetLevel","examDate","noExamDate"],["hoursPerWeek","studyMode","learningVisual","learningAudio","learningReading","learningMixed"],["placementDecision"]];if(l===1){const x=d.getValues("noExamDate"),j=d.getValues("examDate");if(!x&&!j){d.setError("examDate",{message:"Pick a date or check no exam date"});return}x&&d.clearErrors("examDate")}if(l===2){const x=d.getValues();if([x.learningVisual,x.learningAudio,x.learningReading,x.learningMixed].filter(Boolean).length===0){d.setError("learningVisual",{message:"Select at least one learning style"});return}}if(l===ac.length-1?await d.trigger(void 0,{shouldFocus:!0}):await d.trigger(m[l],{shouldFocus:!0}))if(lx+1);else{const x=d.getValues();try{await o.mutateAsync(Xle(x)),x.placementDecision==="take_now"&&e.user_type==="student"?r("/student/placement"):r(Yle(e.user_type))}catch(j){d.setError("root",{message:j instanceof Va?j.message:"Could not save onboarding"})}}},h=()=>{l>0&&c(m=>m-1)};return t?n.jsx("div",{className:"min-h-screen flex items-center justify-center",children:n.jsx(Re,{className:"h-8 w-8 animate-spin text-primary"})}):e?e.is_verified?n.jsx("div",{className:"min-h-screen bg-gradient-to-b from-muted/30 to-background py-10 px-4",children:n.jsxs("div",{className:"max-w-2xl mx-auto space-y-8",children:[n.jsxs("div",{className:"text-center space-y-2",children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Welcome to EnCoach"}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Tailor your learning path in a few steps."})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-between text-xs font-medium text-muted-foreground uppercase tracking-wide",children:[n.jsxs("span",{children:["Step ",l+1," of ",ac.length]}),n.jsx("span",{children:ac[l]})]}),n.jsx(kn,{value:u,className:"h-2"})]}),n.jsxs(W,{className:"border-0 shadow-lg",children:[n.jsxs(se,{children:[n.jsx(ie,{children:ac[l]}),n.jsxs($e,{children:[l===0&&"What is your primary learning goal?",l===1&&"Set your target band, level, and exam timeline.",l===2&&"How do you prefer to study?",l===3&&"Start with a placement test or jump in later."]})]}),n.jsx(U,{children:n.jsx(Wl,{...d,children:n.jsxs("form",{className:"space-y-6",onSubmit:m=>m.preventDefault(),children:[i&&n.jsxs(td,{variant:"destructive",children:[n.jsx(nd,{children:"Could not load goals"}),n.jsx(rd,{children:"Refresh the page or try again shortly."})]}),l===0&&n.jsx(et,{control:d.control,name:"goal",render:({field:m})=>n.jsxs(tt,{children:[n.jsx(rt,{children:a?n.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:[1,2,3,4].map(y=>n.jsx("div",{className:"h-24 rounded-xl bg-muted animate-pulse"},y))}):n.jsx(es,{onValueChange:m.onChange,value:m.value,className:"grid gap-3 sm:grid-cols-2",children:s==null?void 0:s.goals.map(y=>n.jsxs("label",{className:he("flex cursor-pointer items-start gap-3 rounded-xl border p-4 transition-colors hover:bg-muted/50",m.value===y.id&&"border-primary ring-2 ring-primary/20 bg-primary/5"),children:[n.jsx(Bn,{value:y.id,className:"mt-1"}),n.jsxs("div",{className:"flex gap-3 flex-1",children:[n.jsx("div",{className:"rounded-lg bg-primary/10 p-2 text-primary",children:n.jsx(Qle,{name:y.icon})}),n.jsxs("div",{children:[n.jsx("div",{className:"font-medium leading-tight",children:y.title}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:y.description})]})]})]},y.id))})}),n.jsx(ot,{})]})}),l===1&&n.jsxs("div",{className:"space-y-8",children:[n.jsx(et,{control:d.control,name:"targetBand",render:({field:m})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Target band (IELTS)"}),n.jsx("div",{className:"pt-4 pb-2",children:n.jsx(oa,{min:4,max:9,step:.5,value:[m.value],onValueChange:y=>m.onChange(y[0])})}),n.jsx("p",{className:"text-sm text-muted-foreground text-center font-medium tabular-nums",children:m.value.toFixed(1)}),n.jsx(ot,{})]})}),n.jsx(et,{control:d.control,name:"targetLevel",render:({field:m})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Target CEFR level"}),n.jsxs(Oe,{onValueChange:m.onChange,value:m.value,children:[n.jsx(rt,{children:n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select level"})})}),n.jsx(Ee,{children:Kle.map(y=>n.jsx(Y,{value:y.value,children:y.label},y.value))})]}),n.jsx(ot,{})]})}),n.jsx(et,{control:d.control,name:"noExamDate",render:({field:m})=>n.jsxs(tt,{className:"flex flex-row items-center gap-2 space-y-0",children:[n.jsx(rt,{children:n.jsx(an,{checked:m.value,onCheckedChange:y=>m.onChange(!!y)})}),n.jsx(at,{className:"font-normal",children:"I don't have an exam date yet"})]})}),!d.watch("noExamDate")&&n.jsx(et,{control:d.control,name:"examDate",render:({field:m})=>n.jsxs(tt,{className:"flex flex-col",children:[n.jsx(at,{children:"Exam date"}),n.jsxs(uoe,{children:[n.jsx(foe,{asChild:!0,children:n.jsx(rt,{children:n.jsx(E,{variant:"outline",className:"w-full justify-start text-left font-normal",children:m.value?Pi(m.value,"PPP"):"Pick a date"})})}),n.jsx(hB,{className:"w-auto p-0",align:"start",children:n.jsx(_B,{mode:"single",selected:m.value,onSelect:m.onChange,disabled:y=>yn.jsxs(tt,{children:[n.jsx(at,{children:"Hours per week"}),n.jsx("div",{className:"pt-4 pb-2",children:n.jsx(oa,{min:1,max:40,step:1,value:[m.value],onValueChange:y=>m.onChange(y[0])})}),n.jsxs("p",{className:"text-sm text-muted-foreground text-center font-medium",children:[m.value," h"]}),n.jsx(ot,{})]})}),n.jsx(et,{control:d.control,name:"studyMode",render:({field:m})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Study mode"}),n.jsx(rt,{children:n.jsxs(es,{onValueChange:m.onChange,value:m.value,className:"grid gap-3 sm:grid-cols-2",children:[n.jsxs("label",{className:he("flex cursor-pointer items-center gap-3 rounded-xl border p-4",m.value==="self_study"&&"border-primary ring-2 ring-primary/20"),children:[n.jsx(Bn,{value:"self_study"}),n.jsx("span",{children:"Self-study"})]}),n.jsxs("label",{className:he("flex cursor-pointer items-center gap-3 rounded-xl border p-4",m.value==="with_teacher"&&"border-primary ring-2 ring-primary/20"),children:[n.jsx(Bn,{value:"with_teacher"}),n.jsx("span",{children:"With a teacher"})]})]})}),n.jsx(ot,{})]})}),n.jsxs("div",{className:"space-y-3",children:[n.jsx(at,{children:"Learning style"}),n.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:[["learningVisual","Visual"],["learningAudio","Audio"],["learningReading","Reading"],["learningMixed","Mixed"]].map(([m,y])=>n.jsx(et,{control:d.control,name:m,render:({field:x})=>n.jsxs(tt,{className:"flex flex-row items-center gap-2 space-y-0 rounded-lg border p-3",children:[n.jsx(rt,{children:n.jsx(an,{checked:x.value,onCheckedChange:x.onChange})}),n.jsx(at,{className:"font-normal cursor-pointer",children:y})]})},m))}),n.jsx(et,{control:d.control,name:"learningVisual",render:()=>n.jsx(ot,{})})]})]}),l===3&&n.jsxs("div",{className:"space-y-6",children:[n.jsx(et,{control:d.control,name:"placementDecision",render:({field:m})=>n.jsxs(tt,{children:[n.jsx(rt,{children:n.jsxs(es,{onValueChange:m.onChange,value:m.value,className:"grid gap-4",children:[n.jsxs("label",{className:he("flex cursor-pointer flex-col gap-2 rounded-xl border p-5 transition-colors",m.value==="take_now"&&"border-primary bg-primary/5 ring-2 ring-primary/20"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Bn,{value:"take_now"}),n.jsx("span",{className:"font-semibold",children:"Take Placement Test Now"})]}),n.jsx("p",{className:"text-sm text-muted-foreground pl-7",children:"Get a precise starting level across grammar, vocabulary, reading, and speaking."})]}),n.jsxs("label",{className:he("flex cursor-pointer flex-col gap-2 rounded-xl border p-5 transition-colors",m.value==="skip"&&"border-primary bg-primary/5 ring-2 ring-primary/20"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Bn,{value:"skip"}),n.jsx("span",{className:"font-semibold",children:"Skip for Now"})]}),n.jsx("p",{className:"text-sm text-muted-foreground pl-7",children:"You can take the placement test later from your dashboard. Your path may be less personalized until you do."})]})]})}),n.jsx(ot,{})]})}),d.watch("placementDecision")==="skip"&&n.jsxs(td,{children:[n.jsx(nd,{children:"Heads up"}),n.jsx(rd,{children:"Skipping the placement test means we estimate your level from your profile only. You can always start the test when you are ready."})]})]}),d.formState.errors.root&&n.jsx("p",{className:"text-sm text-destructive text-center",children:d.formState.errors.root.message}),n.jsxs("div",{className:"flex justify-between gap-3 pt-2",children:[n.jsx(E,{type:"button",variant:"outline",onClick:h,disabled:l===0||o.isPending,children:"Back"}),n.jsx(E,{type:"button",onClick:()=>void f(),disabled:o.isPending,children:o.isPending?n.jsxs(n.Fragment,{children:[n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving"]}):l===ac.length-1?"Finish":"Next"})]})]})})})]})]})}):n.jsx(jl,{to:`/verify-email?email=${encodeURIComponent(e.email)}`,replace:!0}):n.jsx(jl,{to:"/login",replace:!0})}function Jle(){const[e,t]=p.useState(!1);return n.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:n.jsxs("div",{className:"w-full max-w-md",children:[n.jsxs("div",{className:"flex items-center justify-center gap-2 mb-8",children:[n.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center",children:n.jsx(_i,{className:"h-6 w-6 text-primary-foreground"})}),n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"EnCoach"})]}),n.jsxs(W,{className:"shadow-lg border-0 bg-card",children:[n.jsx(se,{className:"text-center pb-4",children:e?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mx-auto mb-2 h-12 w-12 rounded-full bg-success/10 flex items-center justify-center",children:n.jsx(Ff,{className:"h-6 w-6 text-success"})}),n.jsx(ie,{className:"text-xl",children:"Check your email"}),n.jsx($e,{children:"We've sent a password reset link to your email address."})]}):n.jsxs(n.Fragment,{children:[n.jsx(ie,{className:"text-xl",children:"Forgot password?"}),n.jsx($e,{children:"Enter your email and we'll send you a reset link."})]})}),n.jsxs(U,{children:[e?null:n.jsxs("form",{onSubmit:r=>{r.preventDefault(),t(!0)},className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"email",children:"Email"}),n.jsx(G,{id:"email",type:"email",placeholder:"your@email.com"})]}),n.jsx(E,{type:"submit",className:"w-full",children:"Send Reset Link"})]}),n.jsx("div",{className:"mt-6 text-center",children:n.jsxs(Dt,{to:"/login",className:"inline-flex items-center gap-1 text-sm text-primary hover:underline",children:[n.jsx(xd,{className:"h-3 w-3"})," Back to sign in"]})})]})]})]})})}const Kd={get:e=>R.get(`/entity/${e}/branding`),update:(e,t)=>R.put(`/entity/${e}/branding`,t),resetToDefault:e=>R.post(`/entity/${e}/branding/reset`),getCurrentBranding:()=>R.get("/entity/branding"),uploadLogo:(e,t)=>{const r=new FormData;return r.append("logo",t),R.upload(`/entity/${e}/branding/logo`,r)},uploadFavicon:(e,t)=>{const r=new FormData;return r.append("favicon",t),R.upload(`/entity/${e}/branding/favicon`,r)}},ece=No({password:wn().min(8,"At least 8 characters"),confirm:wn()}).refine(e=>e.password===e.confirm,{message:"Passwords must match",path:["confirm"]});function tce(e){let t=0;return e.length>=8&&t++,e.length>=12&&t++,/[A-Z]/.test(e)&&/[a-z]/.test(e)&&t++,/\d/.test(e)&&t++,/[^A-Za-z0-9]/.test(e)&&t++,t<=2?"weak":t<=4?"medium":"strong"}function nce(){const[e]=wo(),t=e.get("token")??"",r=Bt(),{data:s}=ye({queryKey:["branding","current"],queryFn:()=>Kd.getCurrentBranding()}),a=(s==null?void 0:s.entity_name)??"your organization",i=Vl({resolver:ql(ece),defaultValues:{password:"",confirm:""}}),o=i.watch("password"),l=p.useMemo(()=>tce(o),[o]);p.useEffect(()=>{const u=document.documentElement;return s!=null&&s.primary_color&&u.style.setProperty("--encoach-brand-primary",s.primary_color),s!=null&&s.secondary_color&&u.style.setProperty("--encoach-brand-secondary",s.secondary_color),s!=null&&s.background_color&&u.style.setProperty("--encoach-brand-bg",s.background_color),()=>{u.style.removeProperty("--encoach-brand-primary"),u.style.removeProperty("--encoach-brand-secondary"),u.style.removeProperty("--encoach-brand-bg")}},[s]);const c=ae({mutationFn:u=>Gg.setInvitePassword({token:t,password:u.password}),onSuccess:()=>{ct.success("Password saved."),r("/student/placement",{replace:!0})},onError:u=>ct.error(u instanceof Error?u.message:"Could not set password")}),d=u=>{if(!t){ct.error("Missing invite token.");return}c.mutate(u)};return n.jsx("div",{className:"min-h-screen flex items-center justify-center p-6",style:{backgroundColor:"var(--encoach-brand-bg, hsl(var(--background)))"},children:n.jsxs(W,{className:"w-full max-w-md border shadow-lg",children:[n.jsxs(se,{className:"text-center space-y-1",children:[n.jsxs(ie,{style:{color:"var(--encoach-brand-primary, hsl(var(--primary)))"},children:["Welcome to ",a,"'s Learning Platform"]}),n.jsx($e,{children:"Set a new password"})]}),n.jsx(U,{children:n.jsx(Wl,{...i,children:n.jsxs("form",{onSubmit:i.handleSubmit(d),className:"space-y-4",children:[n.jsx(et,{control:i.control,name:"password",render:({field:u})=>n.jsxs(tt,{children:[n.jsx(at,{children:"New password"}),n.jsx(rt,{children:n.jsx(G,{type:"password",autoComplete:"new-password",...u})}),n.jsx("div",{className:he("text-xs font-medium",l==="weak"&&"text-red-600",l==="medium"&&"text-amber-600",l==="strong"&&"text-green-600"),children:o?`${l.charAt(0).toUpperCase()+l.slice(1)} password`:" "}),n.jsx(ot,{})]})}),n.jsx(et,{control:i.control,name:"confirm",render:({field:u})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Confirm password"}),n.jsx(rt,{children:n.jsx(G,{type:"password",autoComplete:"new-password",...u})}),n.jsx(ot,{})]})}),n.jsx(E,{type:"submit",className:"w-full",disabled:c.isPending,children:"Set Password & Continue"})]})})})]})})}const rce={verify:e=>R.get(`/verify/${encodeURIComponent(e)}`)};function sce(){const{verificationHash:e}=Ht(),t=e??"",{data:r,isLoading:s,isError:a}=ye({queryKey:de.verification.verify(t),queryFn:()=>rce.verify(t),enabled:!!t,retry:!1}),i=(r==null?void 0:r.valid)===!0;return n.jsx("div",{className:"min-h-screen flex items-center justify-center p-6 bg-muted/40",children:n.jsx(W,{className:"w-full max-w-md border shadow-md",children:n.jsxs(U,{className:"pt-8 pb-8 space-y-6",children:[n.jsx("div",{className:"text-center font-semibold tracking-tight text-lg",children:"EnCoach"}),s?n.jsx("p",{className:"text-center text-muted-foreground text-sm",children:"Verifying…"}):a||!i?n.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[n.jsx(Bf,{className:"h-14 w-14 text-destructive"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"This verification code is invalid or has expired."})]}):n.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[n.jsx(Un,{className:"h-14 w-14 text-green-600"}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{className:"font-medium text-lg",children:r.student_name}),n.jsx("p",{className:"text-sm text-muted-foreground capitalize",children:r.exam_type}),n.jsx("p",{className:"text-2xl font-bold",children:r.overall_score}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Issued ",r.issued_at?new Date(r.issued_at).toLocaleDateString():"—"]})]})]})]})})})}const ace=pd("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function oe({className:e,variant:t,...r}){return n.jsx("div",{className:he(ace({variant:t}),e),...r})}const ice=()=>({Authorization:`Bearer ${localStorage.getItem("encoach_token")??""}`}),Ar={async listChapters(e){return R.get(`/courses/${e}/chapters`)},async createChapter(e,t){return R.post(`/courses/${e}/chapters`,t)},async getChapter(e){return R.get(`/chapters/${e}`)},async updateChapter(e,t){return R.patch(`/chapters/${e}`,t)},async deleteChapter(e){return R.delete(`/chapters/${e}`)},async unlockChapter(e){return R.post(`/chapters/${e}/unlock`)},async lockChapter(e){return R.post(`/chapters/${e}/lock`)},async reorderChapters(e,t){return R.patch(`/courses/${e}/chapters/reorder`,t)},async getChapterProgress(e){return R.get(`/chapters/${e}/progress`)},async markChapterComplete(e){return R.post(`/chapters/${e}/progress/complete`)},async listMaterials(e){return R.get(`/chapters/${e}/materials`)},async uploadMaterial(e,t){return R.upload(`/chapters/${e}/materials`,t)},async updateMaterial(e,t){return R.patch(`/materials/${e}`,t)},async deleteMaterial(e){return R.delete(`/materials/${e}`)},async downloadMaterial(e){const t=await fetch(`${Wj}/materials/${e}/download`,{headers:ice()});if(!t.ok)throw new Error(`Download failed: ${t.status} ${t.statusText}`);return t.blob()},async markMaterialViewed(e){return R.post(`/materials/${e}/viewed`)},async reorderMaterials(e,t){return R.patch(`/chapters/${e}/materials/reorder`,t)},async generateOutline(e){return R.post("/workbench/generate-outline",e)},async generateChapterContent(e){return R.post("/workbench/generate-chapter",e)},async generateRubric(e){return R.post("/workbench/generate-rubric",e)},async regenerateSection(e){return R.post("/workbench/regenerate",e)},async suggestMaterials(e){return R.post("/workbench/suggest-materials",e)},async publishWorkbench(e){return R.post("/workbench/publish",e)}};function oce(e){return ye({queryKey:de.chapters(e),queryFn:()=>Ar.listChapters(e),enabled:!!e})}function CB(e){return ye({queryKey:de.chapter(e),queryFn:()=>Ar.getChapter(e),enabled:!!e})}function kB(e){return ye({queryKey:de.chapterMaterials(e),queryFn:()=>Ar.listMaterials(e),enabled:!!e})}function lce(e){return ye({queryKey:de.chapterProgress(e),queryFn:()=>Ar.getChapterProgress(e),enabled:!!e})}function cce(){const e=je();return ae({mutationFn:({courseId:t,data:r})=>Ar.createChapter(t,r),onSuccess:(t,{courseId:r})=>{e.invalidateQueries({queryKey:de.chapters(r)})}})}function dce(){const e=je();return ae({mutationFn:({id:t,courseId:r})=>Ar.deleteChapter(t),onSuccess:(t,{courseId:r})=>{e.invalidateQueries({queryKey:de.chapters(r)})}})}function uce(){const e=je();return ae({mutationFn:({id:t,courseId:r})=>Ar.unlockChapter(t),onSuccess:(t,{id:r,courseId:s})=>{e.invalidateQueries({queryKey:de.chapter(r)}),e.invalidateQueries({queryKey:de.chapters(s)})}})}function fce(){const e=je();return ae({mutationFn:({id:t,courseId:r})=>Ar.lockChapter(t),onSuccess:(t,{id:r,courseId:s})=>{e.invalidateQueries({queryKey:de.chapter(r)}),e.invalidateQueries({queryKey:de.chapters(s)})}})}function mce(){const e=je();return ae({mutationFn:({chapterId:t,formData:r})=>Ar.uploadMaterial(t,r),onSuccess:(t,{chapterId:r})=>{e.invalidateQueries({queryKey:de.chapterMaterials(r)}),e.invalidateQueries({queryKey:de.chapterProgress(r)}),e.invalidateQueries({queryKey:de.chapter(r)})}})}function hce(){const e=je();return ae({mutationFn:({id:t,chapterId:r})=>Ar.deleteMaterial(t),onSuccess:(t,{chapterId:r})=>{e.invalidateQueries({queryKey:de.chapterMaterials(r)}),e.invalidateQueries({queryKey:de.chapterProgress(r)}),e.invalidateQueries({queryKey:de.chapter(r)})}})}function pce(){const e=je();return ae({mutationFn:({id:t,chapterId:r})=>Ar.markMaterialViewed(t),onSuccess:(t,{chapterId:r})=>{e.invalidateQueries({queryKey:de.chapterMaterials(r)}),e.invalidateQueries({queryKey:de.chapterProgress(r)})}})}function xce(){const e=je();return ae({mutationFn:t=>Ar.markChapterComplete(t),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:de.chapterProgress(r)}),e.invalidateQueries({queryKey:de.chapter(r)})}})}function gce(){const e=je();return ae({mutationFn:t=>Ar.generateOutline(t),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:de.chapters(r.course_id)}),e.invalidateQueries({queryKey:de.lms.course(r.course_id)})}})}function vce(){const e=je();return ae({mutationFn:t=>Ar.generateChapterContent(t),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:de.chapters(r.course_id)}),e.invalidateQueries({queryKey:de.lms.course(r.course_id)})}})}function yce(){const e=je();return ae({mutationFn:t=>Ar.publishWorkbench(t),onSuccess:(t,r)=>{const s=r.course_id;typeof s=="number"&&(e.invalidateQueries({queryKey:de.chapters(s)}),e.invalidateQueries({queryKey:de.lms.course(s)}))}})}const Ws={async listDiscussionBoards(e){return R.get("/discussion-boards",e)},async createDiscussionBoard(e){return R.post("/discussion-boards",e)},async updateDiscussionBoard(e,t){return R.patch(`/discussion-boards/${e}`,t)},async listPosts(e,t){return R.get(`/discussion-boards/${e}/posts`,t)},async createPost(e,t){return R.post(`/discussion-boards/${e}/posts`,t)},async updatePost(e,t){return R.patch(`/posts/${e}`,t)},async deletePost(e){return R.delete(`/posts/${e}`)},async pinPost(e,t){return R.post(`/posts/${e}/pin`,t)},async resolvePost(e){return R.post(`/posts/${e}/resolve`)},async listAnnouncements(e){return R.get("/announcements",e)},async createAnnouncement(e){return R.post("/announcements",e)},async updateAnnouncement(e,t){return R.patch(`/announcements/${e}`,t)},async deleteAnnouncement(e){return R.delete(`/announcements/${e}`)},async publishAnnouncement(e){return R.post(`/announcements/${e}/publish`)},async listMessages(e){return R.get("/messages",e)},async listSentMessages(e){return R.get("/messages/sent",e)},async sendMessage(e){return R.post("/messages",e)},async getMessage(e){return R.get(`/messages/${e}`)},async deleteMessage(e){return R.delete(`/messages/${e}`)},async getUnreadMessageCount(){return R.get("/messages/unread-count")}};function PB(e){return ye({queryKey:de.discussionBoards(e),queryFn:()=>Ws.listDiscussionBoards(e)})}function AB(e,t){return ye({queryKey:de.posts(e,t),queryFn:()=>Ws.listPosts(e,t),enabled:!!e})}function EB(e){return ye({queryKey:de.announcements(e),queryFn:()=>Ws.listAnnouncements(e)})}function jce(e){return ye({queryKey:de.messages(e),queryFn:()=>Ws.listMessages(e)})}function bce(e){return ye({queryKey:de.sentMessages(e),queryFn:()=>Ws.listSentMessages(e)})}function wce(){return ye({queryKey:de.unreadMessages,queryFn:()=>Ws.getUnreadMessageCount()})}function kb(){const e=je();return ae({mutationFn:({boardId:t,data:r})=>Ws.createPost(t,r),onSuccess:(t,{boardId:r})=>{e.invalidateQueries({queryKey:["posts",r]}),e.invalidateQueries({queryKey:["discussion-boards"]})}})}function Nce(){const e=je();return ae({mutationFn:({id:t,body:r})=>Ws.pinPost(t,r),onSuccess:t=>{e.invalidateQueries({queryKey:["posts",t.board_id]})}})}function Sce(){const e=je();return ae({mutationFn:t=>Ws.resolvePost(t),onSuccess:t=>{e.invalidateQueries({queryKey:["posts",t.board_id]})}})}function _ce(){const e=je();return ae({mutationFn:t=>Ws.createAnnouncement(t),onSuccess:()=>{e.invalidateQueries({queryKey:["announcements"]})}})}function Cce(){const e=je();return ae({mutationFn:t=>Ws.publishAnnouncement(t),onSuccess:()=>{e.invalidateQueries({queryKey:["announcements"]})}})}function kce(){const e=je();return ae({mutationFn:t=>Ws.sendMessage(t),onSuccess:()=>{e.invalidateQueries({queryKey:["messages"]}),e.invalidateQueries({queryKey:de.unreadMessages})}})}const Pb={async listNotifications(e){return R.get("/notifications",e)},async markNotificationRead(e){return R.post(`/notifications/${e}/read`)},async markAllNotificationsRead(){return R.post("/notifications/read-all")},async getUnreadNotificationCount(){return R.get("/notifications/unread-count")},async listNotificationRules(){return R.get("/notification-rules")},async createNotificationRule(e){return R.post("/notification-rules",e)},async updateNotificationRule(e,t){return R.patch(`/notification-rules/${e}`,t)},async deleteNotificationRule(e){return R.delete(`/notification-rules/${e}`)},async getNotificationPreferences(){return R.get("/notification-preferences")},async updateNotificationPreferences(e){return R.patch("/notification-preferences",e)}};function Pce(){return ye({queryKey:de.notificationRules,queryFn:()=>Pb.listNotificationRules()})}function Ace(){const e=je();return ae({mutationFn:t=>Pb.createNotificationRule(t),onSuccess:()=>{e.invalidateQueries({queryKey:de.notificationRules})}})}function Ece(){const e=je();return ae({mutationFn:({id:t,data:r})=>Pb.updateNotificationRule(t,r),onSuccess:()=>{e.invalidateQueries({queryKey:de.notificationRules})}})}function Oce(){const e=je();return ae({mutationFn:t=>Pb.deleteNotificationRule(t),onSuccess:()=>{e.invalidateQueries({queryKey:de.notificationRules})}})}const Hl={async listCategories(e){return R.get("/faq/categories",e)},async createCategory(e){return R.post("/faq/categories",e)},async updateCategory(e,t){return R.patch(`/faq/categories/${e}`,t)},async deleteCategory(e){return R.delete(`/faq/categories/${e}`)},async listItems(e){return R.get("/faq/items",e)},async createItem(e){return R.post("/faq/items",e)},async updateItem(e,t){return R.patch(`/faq/items/${e}`,t)},async deleteItem(e){return R.delete(`/faq/items/${e}`)}};function OB(e){return ye({queryKey:de.faqCategories(e),queryFn:()=>Hl.listCategories(void 0)})}function TB(e){return ye({queryKey:de.faqItems(e),queryFn:()=>Hl.listItems(e)})}function Tce(){const e=je();return ae({mutationFn:t=>Hl.createCategory(t),onSuccess:()=>{e.invalidateQueries({queryKey:["faq","categories"]})}})}function Mce(){const e=je();return ae({mutationFn:({id:t,data:r})=>Hl.updateCategory(t,r),onSuccess:()=>{e.invalidateQueries({queryKey:["faq","categories"]}),e.invalidateQueries({queryKey:["faq","items"]})}})}function Rce(){const e=je();return ae({mutationFn:t=>Hl.deleteCategory(t),onSuccess:()=>{e.invalidateQueries({queryKey:["faq","categories"]}),e.invalidateQueries({queryKey:["faq","items"]})}})}function $ce(){const e=je();return ae({mutationFn:t=>Hl.createItem(t),onSuccess:()=>{e.invalidateQueries({queryKey:["faq","items"]}),e.invalidateQueries({queryKey:["faq","categories"]})}})}function Ice(){const e=je();return ae({mutationFn:({id:t,data:r})=>Hl.updateItem(t,r),onSuccess:()=>{e.invalidateQueries({queryKey:["faq","items"]}),e.invalidateQueries({queryKey:["faq","categories"]})}})}function Dce(){const e=je();return ae({mutationFn:t=>Hl.deleteItem(t),onSuccess:()=>{e.invalidateQueries({queryKey:["faq","items"]}),e.invalidateQueries({queryKey:["faq","categories"]})}})}const qw={async list(e,t){return R.get(`/exam/${e}`,t)},async getById(e,t){return R.get(`/exam/${e}/${t}`)},async create(e){return R.post("/exam",e)},async update(e,t){return R.patch(`/exam/${e}`,t)},async delete(e){return R.delete(`/exam/${e}`)},async setAccess(e,t){return R.patch(`/exam/${e}/access`,{access:t})},async listRubrics(e){return R.get("/rubrics",e)},async createRubric(e){return R.post("/rubrics",e)},async listRubricGroups(e){return R.get("/rubric-groups",e)},async listStructures(e){return R.get("/exam-structures",e)},async createStructure(e){return R.post("/exam-structures",e)},async deleteStructure(e){return R.delete(`/exam-structures/${e}`)},async getAvatars(){return R.get("/exam/avatars")}},MB={async list(e){return R.get("/assignments",e)},async getById(e){return R.get(`/assignments/${e}`)},async create(e){return R.post("/assignments",e)},async update(e,t){return R.patch(`/assignments/${e}`,t)},async delete(e){return R.delete(`/assignments/${e}`)},async archive(e){return R.post(`/assignments/${e}/archive`)},async start(e){return R.post(`/assignments/${e}/start`)}},Wo={generate(e,t){return R.post(`/exam/${e}/generate`,t)},saveGenerated(e,t){const r=Array.isArray(t)?{questions:t}:t;return R.post(`/exam/${e}/generate/save`,r)},generatePassage(e){return R.post("/exam/reading/generate",{...e,generate_passage:!0})},generateExercises(e,t){return R.post(`/exam/${e}/generate`,{...t,generate_exercises:!0})},generateWritingInstructions(e){return R.post("/exam/writing/generate",{...e,generate_instructions:!0})},generateSpeakingScript(e){return R.post("/exam/speaking/generate",{...e,generate_script:!0})},generateListeningContext(e){return R.post("/exam/listening/generate",{...e,generate_context:!0})},submitExam(e){return R.post("/exam/generation/submit",e)}},lT={generateListeningAudio(e){return R.post("/exam/listening/media",e)},generateSpeakingAudio(e){return R.post("/exam/speaking/media",e)},getAvatars(){return R.get("/exam/avatars")},createAvatarVideo(e){return R.post("/exam/avatar/video",e)},getVideoStatus(e){return R.get(`/exam/avatar/video/${e}`)}},cT={async list(e){return R.get("/tickets",e)},async create(e){return R.post("/tickets",e)},async update(e,t){return R.patch(`/tickets/${e}`,t)},async getAssignedToUser(){return R.get("/tickets/assignedToUser")}},dg={async list(e){return R.get("/approval-workflows",e)},async create(e){return R.post("/approval-workflows",e)},async update(e,t){return R.patch(`/approval-workflows/${e}`,t)},async delete(e){return R.delete(`/approval-workflows/${e}`)}},Fi={async listSubjects(){const e=await R.get("/subjects");return Array.isArray(e)?e:e.data??[]},async getSubject(e){const t=await R.get(`/subjects/${e}`);return t.data??t},async createSubject(e){return R.post("/subjects",e)},async updateSubject(e,t){return R.patch(`/subjects/${e}`,t)},async deleteSubject(e){return R.delete(`/subjects/${e}`)},async getTaxonomyTree(e){const t=await R.get(`/subjects/${e}/taxonomy`);return t.data??t},async importTaxonomy(e,t){return R.upload(`/subjects/${e}/taxonomy/import`,t)},async listDomains(e){const t=await R.get("/domains",e);return Array.isArray(t)?t:t.data??[]},async createDomain(e){return R.post("/domains",e)},async updateDomain(e,t){return R.patch(`/domains/${e}`,t)},async deleteDomain(e){return R.delete(`/domains/${e}`)},async aiSuggestTopics(e){return R.post(`/domains/${e}/ai-suggest`)},async listTopics(e){const t=await R.get("/topics",e);return Array.isArray(t)?t:t.data??[]},async createTopic(e){return R.post("/topics",e)},async updateTopic(e,t){return R.patch(`/topics/${e}`,t)},async deleteTopic(e){return R.delete(`/topics/${e}`)}},Ql={async startDiagnostic(e){return R.post("/diagnostic/start",{subject_id:e})},async answerDiagnostic(e){return R.post("/diagnostic/answer",e)},async getDiagnosticResult(e){return R.get(`/diagnostic/${e}/result`)},async getProficiency(e){const t=await R.get("/proficiency",e);return Array.isArray(t)?t:t.data??[]},async getProficiencySummary(){const e=await R.get("/proficiency/summary");return Array.isArray(e)?e:e.data??[]},async getClassProficiency(e){return R.get("/proficiency/class",e)},async getLearningPlan(e){return R.get("/learning-plan",e)},async generateLearningPlan(e){return R.post("/learning-plan/generate",e)},async updateLearningPlan(e,t){return R.patch(`/learning-plan/${e}`,t)},async pauseLearningPlan(e){return R.post(`/learning-plan/${e}/pause`)},async resumeLearningPlan(e){return R.post(`/learning-plan/${e}/resume`)},async getTopicContent(e){return R.get(`/topics/${e}/content`)},async generateTopicContent(e){return R.post(`/topics/${e}/generate-content`)},async getPracticeQuestions(e){return R.post(`/topics/${e}/practice`)},async gradePractice(e,t){return R.post(`/topics/${e}/practice/grade`,{answers:t})},async startMasteryQuiz(e){return R.post(`/topics/${e}/mastery-quiz`)},async submitMasteryQuiz(e,t){return R.post(`/topics/${e}/mastery-quiz/submit`,{answers:t})}},ug={async list(e){const t=await R.get("/resources",e);return iu(t)},async upload(e){const t=await R.upload("/resources",e);return $r(t)},async update(e,t){const r=await R.patch(`/resources/${e}`,t);return $r(r)},async delete(e){return R.delete(`/resources/${e}`)},async markComplete(e){const t=await R.post(`/resources/${e}/complete`);return $r(t)},async rate(e,t){return R.post(`/resources/${e}/rate`,{rating:t})},async download(e){const t=await fetch(`${Wj}/resources/${e}/download`,{headers:{Authorization:`Bearer ${localStorage.getItem("encoach_token")??""}`}});if(!t.ok)throw new Error(`Download failed: ${t.status} ${t.statusText}`);return t.blob()}};function fg(e){const t=e.status||"draft",r=Number(e.student_count??0),s=Number(e.max_capacity??0);return{id:e.id,title:e.title||e.name||"",code:e.code||"",subject_id:Array.isArray(e.subject_ids)&&e.subject_ids.length?e.subject_ids[0]:void 0,subject_name:Array.isArray(e.subject_names)?String(e.subject_names[0]||""):"",instructor_id:0,instructor_name:"",description:e.description||"",level:"Beginner",modules:[],enrolled:r,max_capacity:s,status:t,start_date:"",end_date:""}}function mg(e){const t=String(e.status||"draft"),r={draft:"upcoming",active:"active",completed:"completed"};return{id:e.id,name:String(e.name||""),course_id:Number(e.course_id||0),course_name:String(e.course_name||""),teacher_id:0,teacher_name:"",student_ids:[],student_count:0,start_date:String(e.start_date||""),end_date:String(e.end_date||""),schedule:"",status:r[t]||"upcoming",capacity:Number(e.max_students??0)}}function RB(e){const t=e.status==="active";return{id:e.id,name:e.name,email:e.email||"",login:e.email||"",user_type:"student",phone:e.phone||void 0,gender:e.gender||void 0,student_id:String(e.id),is_verified:t,entities:e.batch_id!=null?[{id:e.batch_id,name:e.batch_name||"Batch"}]:[],classrooms:[]}}const bn={async listCourses(e){const t=await R.get("/courses",e),r=iu(t);return{...r,items:r.items.map(fg)}},async getCourse(e){const t=await R.get(`/courses/${e}`);return fg($r(t))},async createCourse(e){const t=await R.post("/courses",{name:e.title,code:e.code,description:e.description,max_capacity:e.max_capacity,status:"draft"});return fg($r(t))},async updateCourse(e,t){const r={};t.title!=null&&(r.name=t.title),t.code!=null&&(r.code=t.code),t.description!=null&&(r.description=t.description),t.max_capacity!=null&&(r.max_capacity=t.max_capacity);const s=await R.patch(`/courses/${e}`,r);return fg($r(s))},async deleteCourse(e){return R.delete(`/courses/${e}`)},async aiGenerateCourse(e){return R.post("/courses/ai-generate",e)},async listBatches(e){const t=await R.get("/batches",e),r=iu(t);return{...r,items:r.items.map(mg)}},async getBatch(e){const t=await R.get(`/batches/${e}`);return mg($r(t))},async createBatch(e){const t=await R.post("/batches",e);return mg($r(t))},async updateBatch(e,t){const r=await R.patch(`/batches/${e}`,t);return mg($r(r))},async deleteBatch(e){return R.delete(`/batches/${e}`)},async listStudents(e){const t=await R.get("/students",e);return iu(t)},async getStudent(e){const t=await R.get(`/students/${e}`);return $r(t)},async createStudent(e){const t=await R.post("/students",e);return $r(t)},async updateStudent(e,t){const r=await R.patch(`/students/${e}`,t);return $r(r)},async listTeachers(e){const t=await R.get("/teachers",e);return iu(t)},async createTeacher(e){const t=await R.post("/teachers",e);return $r(t)},async getTimetable(e){const t=await R.get("/timetable",e);return Array.isArray(t)?t:t.data??[]},async createTimetableSession(e){return R.post("/timetable",e)},async deleteTimetableSession(e){return R.delete(`/timetable/${e}`)},async getAttendance(e){const t=await R.get("/attendance",e);return Array.isArray(t)?t:t.data??[]},async recordAttendance(e){return R.post("/attendance",e)},async getGrades(e){const t=await R.get("/grades",e);return Array.isArray(t)?t:t.data??[]}},So={async listAcademicYears(e){return R.get("/academic-years",e)},async getAcademicYear(e){return R.get(`/academic-years/${e}`)},async createAcademicYear(e){return R.post("/academic-years",e)},async updateAcademicYear(e,t){return R.patch(`/academic-years/${e}`,t)},async deleteAcademicYear(e){return R.delete(`/academic-years/${e}`)},async generateTerms(e){return R.post(`/academic-years/${e}/generate-terms`)},async listTerms(e){return R.get("/academic-terms",e)},async createTerm(e){return R.post("/academic-terms",e)},async updateTerm(e,t){return R.patch(`/academic-terms/${e}`,t)},async deleteTerm(e){return R.delete(`/academic-terms/${e}`)},async listDepartments(e){return R.get("/departments",e)},async createDepartment(e){return R.post("/departments",e)},async updateDepartment(e,t){return R.patch(`/departments/${e}`,t)},async deleteDepartment(e){return R.delete(`/departments/${e}`)}},Ts={async listRegisters(e){return R.get("/admission-registers",e)},async createRegister(e){return R.post("/admission-registers",e)},async updateRegister(e,t){return R.patch(`/admission-registers/${e}`,t)},async confirmRegister(e){return R.post(`/admission-registers/${e}/confirm`)},async closeRegister(e){return R.post(`/admission-registers/${e}/close`)},async listAdmissions(e){return R.get("/admissions",e)},async getAdmission(e){return R.get(`/admissions/${e}`)},async createAdmission(e){return R.post("/admissions",e)},async submitAdmission(e){return R.post(`/admissions/${e}/submit`)},async confirmAdmission(e){return R.post(`/admissions/${e}/confirm`)},async admitAdmission(e){return R.post(`/admissions/${e}/admit`)},async rejectAdmission(e){return R.post(`/admissions/${e}/reject`)}},gr={async listSessions(e){return R.get("/inst-exam-sessions",e)},async getSession(e){return R.get(`/inst-exam-sessions/${e}`)},async createSession(e){return R.post("/inst-exam-sessions",e)},async updateSession(e,t){return R.patch(`/inst-exam-sessions/${e}`,t)},async deleteSession(e){return R.delete(`/inst-exam-sessions/${e}`)},async scheduleSession(e){return R.post(`/inst-exam-sessions/${e}/schedule`)},async markSessionDone(e){return R.post(`/inst-exam-sessions/${e}/done`)},async createExam(e){return R.post("/inst-exams",e)},async updateExam(e,t){return R.patch(`/inst-exams/${e}`,t)},async addAttendees(e,t){return R.post(`/inst-exams/${e}/attendees`,t)},async enterMarks(e,t){return R.patch(`/inst-exams/${e}/marks`,t)},async listExamTypes(e){return R.get("/exam-types",e)},async createExamType(e){return R.post("/exam-types",e)},async listGradeConfigs(e){return R.get("/grade-config",e)},async createGradeConfig(e){return R.post("/grade-config",e)},async listResultTemplates(e){return R.get("/result-templates",e)},async createResultTemplate(e){return R.post("/result-templates",e)},async generateMarksheets(e){return R.post(`/result-templates/${e}/generate`)},async listMarksheets(e){return R.get("/marksheets",e)},async getMarksheet(e){return R.get(`/marksheets/${e}`)},async validateMarksheet(e){return R.post(`/marksheets/${e}/validate`)},async listCourseAssignments(e){return R.get("/course-assignments",e)},async createCourseAssignment(e){return R.post("/course-assignments",e)},async getCourseAssignment(e){return R.get(`/course-assignments/${e}`)},async updateCourseAssignment(e,t){return R.patch(`/course-assignments/${e}`,t)},async publishCourseAssignment(e){return R.post(`/course-assignments/${e}/publish`)},async finishCourseAssignment(e){return R.post(`/course-assignments/${e}/finish`)},async listSubmissions(e,t){return R.get(`/course-assignments/${e}/submissions`,t)},async submitAssignment(e,t){const r=new FormData;return r.append("file",t),R.upload(`/course-assignments/${e}/submit`,r)},async gradeSubmission(e,t){return R.patch(`/submissions/${e}`,t)},async listAssignmentTypes(e){return R.get("/assignment-types",e)},async createAssignmentType(e){return R.post("/assignment-types",e)},async listSubjectRegistrations(e){return R.get("/subject-registrations",e)},async createSubjectRegistration(e){return R.post("/subject-registrations",e)},async updateSubjectRegistration(e,t){return R.patch(`/subject-registrations/${e}`,t)},async confirmSubjectRegistration(e){return R.post(`/subject-registrations/${e}/confirm`)},async rejectSubjectRegistration(e){return R.post(`/subject-registrations/${e}/reject`)},async getAvailableSubjects(e){return R.get("/subject-registrations/available",e)}},px={async listLeaves(e){return R.get("/student-leaves",e)},async createLeave(e){return R.post("/student-leaves",e)},async updateLeave(e,t){return R.patch(`/student-leaves/${e}`,t)},async approveLeave(e){return R.post(`/student-leaves/${e}/approve`)},async rejectLeave(e){return R.post(`/student-leaves/${e}/reject`)},async listLeaveTypes(e){return R.get("/student-leave-types",e)},async createLeaveType(e){return R.post("/student-leave-types",e)}},I2={async listFeesPlans(e){return R.get("/fees-plans",e)},async getFeesPlan(e){return R.get(`/fees-plans/${e}`)},async listStudentFees(e){return R.get("/student-fees",e)},async listFeesTerms(e){return R.get("/fees-terms",e)}},Ab={async listLessons(e){return R.get("/lessons",e)},async createLesson(e){return R.post("/lessons",e)},async updateLesson(e,t){return R.patch(`/lessons/${e}`,t)},async deleteLesson(e){return R.delete(`/lessons/${e}`)}},xx={async listGradebooks(e){return R.get("/gradebooks",e)},async listGradebookLines(e){return R.get("/gradebook-lines",e)},async listGradingAssignments(e){return R.get("/grading-assignments",e)},async createGradingAssignment(e){return R.post("/grading-assignments",e)},async updateGradingAssignment(e,t){return R.patch(`/grading-assignments/${e}`,t)},async deleteGradingAssignment(e){return R.delete(`/grading-assignments/${e}`)}},Lce={async listProgress(e){return R.get("/student-progress",e)}},Yl={async listMedia(e){return R.get("/library/media",e)},async createMedia(e){return R.post("/library/media",e)},async listMovements(e){return R.get("/library/movements",e)},async createMovement(e){return R.post("/library/movements",e)},async updateMovement(e,t){return R.patch(`/library/movements/${e}`,t)},async deleteMedia(e){return R.delete(`/library/media/${e}`)},async returnMovement(e){return R.post(`/library/movements/${e}/return`)},async listCards(e){return R.get("/library/cards",e)},async createCard(e){return R.post("/library/cards",e)}},Zf={async listActivities(e){return R.get("/activities",e)},async createActivity(e){return R.post("/activities",e)},async updateActivity(e,t){return R.patch(`/activities/${e}`,t)},async deleteActivity(e){return R.delete(`/activities/${e}`)},async listActivityTypes(e){return R.get("/activity-types",e)},async createActivityType(e){return R.post("/activity-types",e)},async deleteActivityType(e){return R.delete(`/activity-types/${e}`)}},Jf={async listFacilities(e){return R.get("/facilities",e)},async createFacility(e){return R.post("/facilities",e)},async updateFacility(e,t){return R.patch(`/facilities/${e}`,t)},async deleteFacility(e){return R.delete(`/facilities/${e}`)},async listAssets(e){return R.get("/assets",e)},async createAsset(e){return R.post("/assets",e)},async deleteAsset(e){return R.delete(`/assets/${e}`)}};function Er(e){return ye({queryKey:de.lms.courses(e),queryFn:()=>bn.listCourses(e)})}function $B(){const e=je();return ae({mutationFn:t=>bn.createCourse(t),onSuccess:()=>e.invalidateQueries({queryKey:["lms","courses"]})})}function Qa(e){return ye({queryKey:de.lms.students(e),queryFn:()=>bn.listStudents(e)})}function IB(){const e=je();return ae({mutationFn:t=>bn.createStudent(t),onSuccess:()=>{e.invalidateQueries({queryKey:["lms","students"]})}})}function Eb(e){return ye({queryKey:de.lms.teachers(e),queryFn:()=>bn.listTeachers(e)})}function DB(){const e=je();return ae({mutationFn:t=>bn.createTeacher(t),onSuccess:()=>{e.invalidateQueries({queryKey:["lms","teachers"]})}})}function _o(e){return ye({queryKey:de.lms.batches(e),queryFn:()=>bn.listBatches(e)})}function Ob(e){return ye({queryKey:de.lms.timetable(e),queryFn:()=>bn.getTimetable(e)})}function LB(e){return ye({queryKey:de.lms.attendance(e),queryFn:()=>bn.getAttendance(e)})}function D2(e){return ye({queryKey:de.lms.grades(e),queryFn:()=>bn.getGrades(e)})}function Nd(e){return ye({queryKey:de.assignments.list(e),queryFn:()=>MB.list(e)})}function Fce(){const e=je();return ae({mutationFn:t=>MB.create(t),onSuccess:()=>e.invalidateQueries({queryKey:["assignments"]})})}function Bce(e){return ye({queryKey:de.entities.list(e),queryFn:()=>iF.list(e)})}function gx(){return ye({queryKey:de.taxonomy.subjects,queryFn:()=>Fi.listSubjects()})}function zce(e){return ye({queryKey:de.taxonomy.tree(e),queryFn:()=>Fi.getTaxonomyTree(e),enabled:!!e})}function Vce(e){return ye({queryKey:de.adaptive.proficiency(e),queryFn:()=>Ql.getProficiency(e??{})})}function FB(){return ye({queryKey:de.adaptive.summary,queryFn:()=>Ql.getProficiencySummary()})}function qce(e){return ye({queryKey:de.adaptive.plan(e),queryFn:()=>Ql.getLearningPlan(e??{}),enabled:!!(e!=null&&e.subject_id)})}function Wce(e){return ye({queryKey:de.adaptive.topicContent(e),queryFn:()=>Ql.getTopicContent(e),enabled:!!e})}function Uce(){return ae({mutationFn:e=>Ql.startDiagnostic(e)})}function Kce(){return ae({mutationFn:Ql.answerDiagnostic})}function Gce(){const e=je();return ae({mutationFn:t=>Ql.generateLearningPlan(t),onSuccess:()=>e.invalidateQueries({queryKey:["adaptive","plan"]})})}function Hce(e){return ye({queryKey:de.academicYears.list(e),queryFn:()=>So.listAcademicYears(e)})}function Qce(e){return ye({queryKey:de.academicTerms.list({year_id:e}),queryFn:()=>So.listTerms({year_id:e})})}function BB(e){return ye({queryKey:de.departments.list(e),queryFn:()=>So.listDepartments(e)})}function Yce(){const e=je();return ae({mutationFn:t=>So.createAcademicYear(t),onSuccess:()=>e.invalidateQueries({queryKey:de.academicYears.all})})}function Xce(){const e=je();return ae({mutationFn:t=>So.deleteAcademicYear(t),onSuccess:()=>e.invalidateQueries({queryKey:de.academicYears.all})})}function Zce(){const e=je();return ae({mutationFn:t=>So.generateTerms(t),onSuccess:()=>e.invalidateQueries({queryKey:de.academicTerms.all})})}function zB(){const e=je();return ae({mutationFn:t=>So.createDepartment(t),onSuccess:()=>e.invalidateQueries({queryKey:de.departments.all})})}function Jce(){const e=je();return ae({mutationFn:({id:t,data:r})=>So.updateDepartment(t,r),onSuccess:()=>e.invalidateQueries({queryKey:de.departments.all})})}function VB(){const e=je();return ae({mutationFn:t=>So.deleteDepartment(t),onSuccess:()=>e.invalidateQueries({queryKey:de.departments.all})})}function ede(e){return ye({queryKey:de.instExamSessions.list(e),queryFn:()=>gr.listSessions(e)})}function tde(e){return ye({queryKey:de.studentLeaves.list(e),queryFn:()=>px.listLeaves(e)})}function nde(e){return ye({queryKey:de.studentLeaveTypes.list(e),queryFn:()=>px.listLeaveTypes(e)})}function rde(){const e=je();return ae({mutationFn:t=>px.createLeave(t),onSuccess:()=>e.invalidateQueries({queryKey:de.studentLeaves.all})})}function sde(){const e=je();return ae({mutationFn:t=>px.approveLeave(t),onSuccess:()=>e.invalidateQueries({queryKey:de.studentLeaves.all})})}function ade(){const e=je();return ae({mutationFn:t=>px.rejectLeave(t),onSuccess:()=>e.invalidateQueries({queryKey:de.studentLeaves.all})})}function ide(e){return ye({queryKey:de.feesPlans.list(e),queryFn:()=>I2.listFeesPlans(e)})}function ode(e){return ye({queryKey:de.feesPlans.detail(e),queryFn:()=>I2.getFeesPlan(e),enabled:!!e})}function lde(e){return ye({queryKey:de.studentFees.list(e),queryFn:()=>I2.listStudentFees(e)})}function cde(e){return ye({queryKey:de.lessons.list(e),queryFn:()=>Ab.listLessons(e)})}function dde(){const e=je();return ae({mutationFn:t=>Ab.createLesson(t),onSuccess:()=>e.invalidateQueries({queryKey:de.lessons.all})})}function ude(){const e=je();return ae({mutationFn:({id:t,data:r})=>Ab.updateLesson(t,r),onSuccess:()=>e.invalidateQueries({queryKey:de.lessons.all})})}function fde(){const e=je();return ae({mutationFn:t=>Ab.deleteLesson(t),onSuccess:()=>e.invalidateQueries({queryKey:de.lessons.all})})}function mde(e){return ye({queryKey:de.gradebooks.list(e),queryFn:()=>xx.listGradebooks(e)})}function hde(e){return ye({queryKey:de.gradingAssignments.list(e),queryFn:()=>xx.listGradingAssignments(e)})}function pde(){const e=je();return ae({mutationFn:t=>xx.createGradingAssignment(t),onSuccess:()=>e.invalidateQueries({queryKey:de.gradingAssignments.all})})}function xde(){const e=je();return ae({mutationFn:({id:t,data:r})=>xx.updateGradingAssignment(t,r),onSuccess:()=>e.invalidateQueries({queryKey:de.gradingAssignments.all})})}function gde(){const e=je();return ae({mutationFn:t=>xx.deleteGradingAssignment(t),onSuccess:()=>e.invalidateQueries({queryKey:de.gradingAssignments.all})})}function vde(e){return ye({queryKey:de.studentProgress.list(e),queryFn:()=>Lce.listProgress(e)})}function yde(e){return ye({queryKey:de.libraryMedia.list(e),queryFn:()=>Yl.listMedia(e)})}function jde(){const e=je();return ae({mutationFn:t=>Yl.createMedia(t),onSuccess:()=>e.invalidateQueries({queryKey:de.libraryMedia.all})})}function bde(e){return ye({queryKey:de.libraryMovements.list(e),queryFn:()=>Yl.listMovements(e)})}function wde(){const e=je();return ae({mutationFn:t=>Yl.createMovement(t),onSuccess:()=>e.invalidateQueries({queryKey:de.libraryMovements.all})})}function Nde(){const e=je();return ae({mutationFn:t=>Yl.deleteMedia(t),onSuccess:()=>e.invalidateQueries({queryKey:de.libraryMedia.all})})}function Sde(){const e=je();return ae({mutationFn:t=>Yl.returnMovement(t),onSuccess:()=>e.invalidateQueries({queryKey:de.libraryMovements.all})})}function _de(e){return ye({queryKey:de.libraryCards.list(e),queryFn:()=>Yl.listCards(e)})}function Cde(){const e=je();return ae({mutationFn:t=>Yl.createCard(t),onSuccess:()=>e.invalidateQueries({queryKey:de.libraryCards.all})})}function kde(e){return ye({queryKey:de.activities.list(e),queryFn:()=>Zf.listActivities(e)})}function Pde(e){return ye({queryKey:de.activityTypes.list(e),queryFn:()=>Zf.listActivityTypes(e)})}function Ade(){const e=je();return ae({mutationFn:t=>Zf.createActivity(t),onSuccess:()=>e.invalidateQueries({queryKey:de.activities.all})})}function Ede(){const e=je();return ae({mutationFn:t=>Zf.deleteActivity(t),onSuccess:()=>e.invalidateQueries({queryKey:de.activities.all})})}function Ode(){const e=je();return ae({mutationFn:t=>Zf.createActivityType(t),onSuccess:()=>e.invalidateQueries({queryKey:de.activityTypes.all})})}function Tde(){const e=je();return ae({mutationFn:t=>Zf.deleteActivityType(t),onSuccess:()=>e.invalidateQueries({queryKey:de.activityTypes.all})})}function Mde(e){return ye({queryKey:de.facilities.list(e),queryFn:()=>Jf.listFacilities(e)})}function Rde(){const e=je();return ae({mutationFn:t=>Jf.createFacility(t),onSuccess:()=>e.invalidateQueries({queryKey:de.facilities.all})})}function $de(){const e=je();return ae({mutationFn:t=>Jf.deleteFacility(t),onSuccess:()=>e.invalidateQueries({queryKey:de.facilities.all})})}function Ide(e){return ye({queryKey:de.assets.list(e),queryFn:()=>Jf.listAssets(e)})}function Dde(){const e=je();return ae({mutationFn:t=>Jf.createAsset(t),onSuccess:()=>e.invalidateQueries({queryKey:de.assets.all})})}function Lde(){const e=je();return ae({mutationFn:t=>Jf.deleteAsset(t),onSuccess:()=>e.invalidateQueries({queryKey:de.assets.all})})}const L2={listInternational:()=>R.get("/exam/templates",{type:"international"}),listCustom:()=>R.get("/exam/templates",{type:"custom"}),getById:e=>R.get(`/exam/templates/${e}`),saveCustomTemplate:e=>R.post("/exam/templates/custom",e)},bi={create:e=>R.post("/exam/ielts/create",e),getSkills:e=>R.get(`/exam/ielts/${e}/skills`),getContentPoolCount:e=>R.get(`/exam/ielts/${e}/content-pool-count`),getContentPool:(e,t)=>R.get(`/exam/ielts/${e}/content-pool`,t),autoAssemble:e=>R.post(`/exam/ielts/${e}/auto-assemble`),suggest:e=>R.post(`/exam/ielts/${e}/suggest`),saveQuestions:(e,t,r)=>R.put(`/exam/ielts/${e}/sections/${t}/questions`,{question_ids:r}),validate:e=>R.get(`/exam/ielts/${e}/validate`),update:(e,t)=>R.put(`/exam/ielts/${e}`,t),assign:(e,t)=>R.post(`/exam/ielts/${e}/assign`,t)},Fde={create:e=>R.post("/exam/custom/create",e),getById:e=>R.get(`/exam/custom/${e}`),update:(e,t)=>R.put(`/exam/custom/${e}`,t),delete:e=>R.delete(`/exam/custom/${e}`)};function Bde(){return ye({queryKey:de.examTemplates.international,queryFn:L2.listInternational})}function zde(){return ye({queryKey:de.examTemplates.custom,queryFn:L2.listCustom})}function Vde(){return ae({mutationFn:e=>bi.create(e)})}function qB(e){return ye({queryKey:de.ieltsExam.skills(e),queryFn:()=>bi.getSkills(e),enabled:!!e})}function qde(e,t){return ye({queryKey:de.ieltsExam.contentPool(e,t),queryFn:()=>bi.getContentPool(e,t),enabled:!!e})}function Wde(){return ae({mutationFn:e=>bi.autoAssemble(e)})}function Ude(e){return ye({queryKey:de.ieltsExam.validation(e),queryFn:()=>bi.validate(e),enabled:!!e})}function Kde(){const e=je();return ae({mutationFn:t=>bi.update(t,{status:"published"}),onSuccess:()=>e.invalidateQueries({queryKey:["ielts-exam"]})})}function Gde(){return ae({mutationFn:e=>bi.assign(e.examId,e.assignment)})}function Hde(){return ae({mutationFn:e=>Fde.create(e)})}function Qde(){const e=je();return ae({mutationFn:t=>L2.saveCustomTemplate(t),onSuccess:()=>e.invalidateQueries({queryKey:de.examTemplates.custom})})}const em={validateCsv:e=>{const t=new FormData;return t.append("file",e),R.upload("/entity/students/csv/validate",t)},bulkCreate:e=>R.post("/entity/students/bulk-create",e),sendCredentials:e=>R.post("/entity/students/send-credentials",{student_ids:e}),getCredentialStatuses:e=>R.get("/entity/students/credentials",e),resendCredential:e=>R.post(`/entity/students/${e}/resend-credential`),resendAllPending:()=>R.post("/entity/students/resend-credentials/pending")};function Yde(){return ae({mutationFn:e=>em.validateCsv(e)})}function Xde(){const e=je();return ae({mutationFn:t=>em.bulkCreate(t),onSuccess:()=>{e.invalidateQueries({queryKey:["entity-onboarding"]})}})}function Zde(){const e=je();return ae({mutationFn:t=>em.sendCredentials(t),onSuccess:()=>{e.invalidateQueries({queryKey:de.entityOnboarding.credentials()})}})}function Jde(e){return ye({queryKey:de.entityOnboarding.credentials(e),queryFn:()=>em.getCredentialStatuses(e)})}function eue(){const e=je();return ae({mutationFn:t=>em.resendCredential(t),onSuccess:()=>{e.invalidateQueries({queryKey:["entity-onboarding","credentials"]})}})}function tue(){const e=je();return ae({mutationFn:()=>em.resendAllPending(),onSuccess:()=>{e.invalidateQueries({queryKey:["entity-onboarding","credentials"]})}})}const Ai={createEnglish:e=>R.post("/ai-course/english/create",e),createIelts:e=>R.post("/ai-course/ielts/create",e),getCourse:e=>R.get(`/ai-course/${e}`),getTracks:e=>R.get(`/ai-course/${e}/tracks`),getQualityGate:e=>R.get(`/ai-course/${e}/quality`),approveQuality:e=>R.post(`/ai-course/${e}/approve`),rejectQuality:(e,t)=>R.post(`/ai-course/${e}/reject`,{reason:t}),getIeltsValidation:e=>R.get(`/ai-course/${e}/validation`),submitExaminerReview:(e,t)=>R.post(`/ai-course/ielts-review/${e}`,t),getEnglishTaxonomy:()=>R.get("/ai-course/english/taxonomy"),getReviewQueue:(e=1,t=20)=>R.get("/ai-course/review-queue",{page:e,size:t}),getIeltsReviewQueue:(e=1,t=20)=>R.get("/ai-course/ielts-review-queue",{page:e,size:t})};function WB(e){return ye({queryKey:de.aiCourse.course(e??0),queryFn:()=>Ai.getCourse(e),enabled:!!e&&e>0})}function UB(e){return ye({queryKey:de.aiCourse.tracks(e??0),queryFn:()=>Ai.getTracks(e),enabled:!!e&&e>0})}function nue(){const e=je();return ae({mutationFn:t=>Ai.createEnglish(t),onSuccess:()=>{e.invalidateQueries({queryKey:["ai-course"]})}})}function rue(){const e=je();return ae({mutationFn:t=>Ai.createIelts(t),onSuccess:()=>{e.invalidateQueries({queryKey:["ai-course"]})}})}function sue(e){return ye({queryKey:de.aiCourse.quality(e??0),queryFn:()=>Ai.getQualityGate(e),enabled:!!e&&e>0})}function aue(){const e=je();return ae({mutationFn:t=>Ai.approveQuality(t),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:de.aiCourse.quality(r)}),e.invalidateQueries({queryKey:de.aiCourse.course(r)})}})}function iue(){const e=je();return ae({mutationFn:({courseId:t,reason:r})=>Ai.rejectQuality(t,r),onSuccess:(t,{courseId:r})=>{e.invalidateQueries({queryKey:de.aiCourse.quality(r)})}})}function oue(){return ye({queryKey:de.aiCourse.englishTaxonomy,queryFn:()=>Ai.getEnglishTaxonomy()})}function lue(e){return ye({queryKey:de.aiCourse.ieltsValidation(e??0),queryFn:()=>Ai.getIeltsValidation(e),enabled:!!e&&e>0})}function cue(){const e=je();return ae({mutationFn:t=>Ai.submitExaminerReview(t.logId,{action:t.action,examiner_notes:t.examiner_notes}),onSuccess:()=>{e.invalidateQueries({queryKey:["ai-course"]})}})}const tm={getDashboard:()=>R.get("/adaptive-engine/dashboard"),getStudents:e=>R.get("/adaptive-engine/students",e),getStudentSignals:e=>R.get(`/adaptive-engine/students/${e}/signals`),getStudentAbility:e=>R.get(`/adaptive-engine/students/${e}/ability`),getSettings:()=>R.get("/adaptive-engine/settings"),updateSettings:e=>R.put("/adaptive-engine/settings",e)};function due(){return ye({queryKey:de.adaptiveEngine.dashboard,queryFn:()=>tm.getDashboard()})}function uue(e){return ye({queryKey:de.adaptiveEngine.students(e),queryFn:()=>tm.getStudents(e)})}function fue(e){return ye({queryKey:de.adaptiveEngine.signals(e??0),queryFn:()=>tm.getStudentSignals(e),enabled:!!e&&e>0})}function mue(e){return ye({queryKey:de.adaptiveEngine.ability(e??0),queryFn:()=>tm.getStudentAbility(e),enabled:!!e&&e>0})}function hue(){return ye({queryKey:de.adaptiveEngine.settings,queryFn:()=>tm.getSettings()})}function pue(){const e=je();return ae({mutationFn:t=>tm.updateSettings(t),onSuccess:()=>{e.invalidateQueries({queryKey:de.adaptiveEngine.settings})}})}const Tb={getPending:e=>R.get("/scores/pending",e),release:e=>R.post(`/scores/${e}/release`),reject:(e,t)=>R.post(`/scores/${e}/reject`,{reason:t}),bulkRelease:e=>R.post("/scores/bulk-release",{attempt_ids:e})};function xue(e){return ye({queryKey:de.scoreRelease.pending(e),queryFn:()=>Tb.getPending(e)})}function gue(){const e=je();return ae({mutationFn:t=>Tb.release(t),onSuccess:()=>{e.invalidateQueries({queryKey:["score-release","pending"]})}})}function vue(){const e=je();return ae({mutationFn:({attemptId:t,reason:r})=>Tb.reject(t,r),onSuccess:()=>{e.invalidateQueries({queryKey:["score-release","pending"]})}})}function yue(){const e=je();return ae({mutationFn:t=>Tb.bulkRelease(t),onSuccess:()=>{e.invalidateQueries({queryKey:["score-release","pending"]})}})}const jue={};function bue(e){switch(e){case"critical":return Pl;case"warning":return Dl;default:return fk}}function wue(e){switch(e){case"critical":return"text-destructive";case"warning":return"text-warning";default:return"text-primary"}}function F2({data:e=jue}){var i;const{toast:t}=He(),r=p.useMemo(()=>JSON.stringify(e),[e]),s=ae({mutationFn:o=>Ol.getInsights(o),onError:o=>{t({title:"Insights unavailable",description:o.message||"Could not load AI insights.",variant:"destructive"})}});p.useEffect(()=>{s.mutate(e)},[r]);const a=((i=s.data)==null?void 0:i.insights)??[];return n.jsxs(W,{className:"border-0 shadow-sm",children:[n.jsx(se,{className:"pb-3",children:n.jsxs(ie,{className:"text-base font-semibold flex items-center gap-2",children:[n.jsx(lt,{className:"h-4 w-4 text-primary"}),"AI Platform Insights"]})}),n.jsxs(U,{children:[s.isPending&&n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-8 justify-center",children:[n.jsx(Re,{className:"h-5 w-5 animate-spin text-primary"}),"Loading insights…"]}),s.isError&&!s.isPending&&n.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"Could not load insights."}),s.isSuccess&&a.length===0&&n.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No insights available for this view."}),!s.isPending&&a.length>0&&n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:a.map((o,l)=>{const c=bue(o.severity),d=wue(o.severity);return n.jsxs("div",{className:"rounded-lg border bg-muted/30 p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx(c,{className:`h-4 w-4 ${d}`}),n.jsx("span",{className:"text-sm font-semibold",children:o.title})]}),n.jsx("p",{className:"text-sm text-muted-foreground",children:o.description}),o.recommendation&&n.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:o.recommendation})]},l)})})]})]})}function Nue(){const{data:e}=ye({queryKey:["platform","stats"],queryFn:async()=>{const m=await R.get("/stats");return m.data??m},staleTime:3e4}),{data:t,isLoading:r}=Qa({size:5}),{data:s,isLoading:a}=Eb({size:5}),{data:i,isLoading:o}=Bce({size:50}),l=(t==null?void 0:t.items)??[],c=(s==null?void 0:s.items)??[],d=(i==null?void 0:i.items)??[],u=r||a||o,f=[{label:"Students",count:(e==null?void 0:e.total_students)??0,icon:_i,color:"bg-primary/10 text-primary"},{label:"Teachers",count:(e==null?void 0:e.total_teachers)??0,icon:au,color:"bg-info/10 text-info"},{label:"Entities",count:(e==null?void 0:e.total_entities)??0,icon:Lh,color:"bg-warning/10 text-warning"},{label:"Active Courses",count:(e==null?void 0:e.active_courses)??0,icon:Kt,color:"bg-success/10 text-success"}],h=[{label:"Exams",count:(e==null?void 0:e.total_exams)??0,url:"/admin/exams",icon:Il},{label:"Classrooms",count:(e==null?void 0:e.total_classrooms)??0,url:"/admin/classrooms",icon:ZG},{label:"Entities",count:(e==null?void 0:e.total_entities)??0,url:"/admin/entities",icon:Lh},{label:"Tickets",count:`${(e==null?void 0:e.open_tickets)??0} open`,url:"/admin/tickets",icon:Aj}];return u?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Platform Dashboard"}),n.jsx("p",{className:"text-muted-foreground",children:"Overview of platform activity and user statistics."})]}),n.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:f.map(m=>n.jsx(W,{className:"border-0 shadow-sm",children:n.jsxs(U,{className:"p-5 flex items-center gap-4",children:[n.jsx("div",{className:`h-12 w-12 rounded-xl flex items-center justify-center ${m.color}`,children:n.jsx(m.icon,{className:"h-6 w-6"})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl font-bold",children:m.count.toLocaleString()}),n.jsx("p",{className:"text-sm text-muted-foreground",children:m.label})]})]})},m.label))}),n.jsx(F2,{}),n.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:h.map(m=>n.jsx(Dt,{to:m.url,children:n.jsx(W,{className:"border-0 shadow-sm hover:shadow-md transition-shadow cursor-pointer",children:n.jsxs(U,{className:"p-5 flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(m.icon,{className:"h-5 w-5 text-muted-foreground"}),n.jsx("span",{className:"text-sm font-medium",children:m.label})]}),n.jsx(oe,{variant:"secondary",children:m.count})]})})},m.label))}),n.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[{label:"Batches",value:`${(e==null?void 0:e.active_batches)??0} / ${(e==null?void 0:e.total_batches)??0}`},{label:"Subjects",value:(e==null?void 0:e.total_subjects)??0},{label:"Resources",value:(e==null?void 0:e.total_resources)??0},{label:"Revenue",value:`$${((e==null?void 0:e.total_revenue)??0).toLocaleString()}`}].map(m=>n.jsx(W,{className:"border-0 shadow-sm",children:n.jsxs(U,{className:"p-4",children:[n.jsx("p",{className:"text-lg font-bold",children:m.value}),n.jsx("p",{className:"text-xs text-muted-foreground",children:m.label})]})},m.label))}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[n.jsxs(W,{className:"border-0 shadow-sm",children:[n.jsx(se,{className:"pb-3",children:n.jsx(ie,{className:"text-base font-semibold",children:"Recent Students"})}),n.jsxs(U,{className:"space-y-3",children:[l.length===0&&n.jsx("p",{className:"text-sm text-muted-foreground",children:"No students found."}),l.map(m=>n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center text-xs font-semibold text-primary",children:(m.name||"?").split(" ").map(y=>y[0]).join("").slice(0,2).toUpperCase()}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:m.name}),n.jsx("p",{className:"text-xs text-muted-foreground",children:m.email||"—"})]})]}),n.jsx(oe,{variant:"outline",children:m.status||"active"})]},m.id))]})]}),n.jsxs(W,{className:"border-0 shadow-sm",children:[n.jsx(se,{className:"pb-3",children:n.jsx(ie,{className:"text-base font-semibold",children:"Recent Teachers"})}),n.jsxs(U,{className:"space-y-3",children:[c.length===0&&n.jsx("p",{className:"text-sm text-muted-foreground",children:"No teachers found."}),c.map(m=>n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"h-8 w-8 rounded-full bg-info/10 flex items-center justify-center text-xs font-semibold text-info",children:(m.name||"?").split(" ").map(y=>y[0]).join("").slice(0,2).toUpperCase()}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:m.name}),n.jsx("p",{className:"text-xs text-muted-foreground",children:m.email||"—"})]})]}),n.jsx(oe,{variant:"outline",children:m.department_name||"—"})]},m.id))]})]}),n.jsxs(W,{className:"border-0 shadow-sm",children:[n.jsx(se,{className:"pb-3",children:n.jsx(ie,{className:"text-base font-semibold",children:"Entities"})}),n.jsxs(U,{className:"space-y-3",children:[d.length===0&&n.jsx("p",{className:"text-sm text-muted-foreground",children:"No entities found."}),d.map(m=>n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(IL,{className:"h-4 w-4 text-muted-foreground"}),n.jsx("p",{className:"text-sm font-medium",children:m.name})]}),n.jsx(oe,{variant:"outline",children:m.entity_type||m.type||"—"})]},m.id))]})]}),n.jsxs(W,{className:"border-0 shadow-sm",children:[n.jsx(se,{className:"pb-3",children:n.jsx(ie,{className:"text-base font-semibold",children:"Platform Summary"})}),n.jsx(U,{className:"space-y-3",children:[{label:"Exam Sessions",value:(e==null?void 0:e.total_exam_sessions)??0},{label:"Assignments",value:(e==null?void 0:e.total_assignments)??0},{label:"Total Tickets",value:(e==null?void 0:e.total_tickets)??0},{label:"Completed Payments",value:(e==null?void 0:e.total_payments)??0}].map(m=>n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:m.label}),n.jsx("p",{className:"text-sm font-semibold",children:m.value})]},m.label))})]})]})]})}var Mb="Tabs",[Sue]=lr(Mb,[Hf]),KB=Hf(),[_ue,B2]=Sue(Mb),GB=p.forwardRef((e,t)=>{const{__scopeTabs:r,value:s,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:l,activationMode:c="automatic",...d}=e,u=zl(l),[f,h]=zr({prop:s,onChange:a,defaultProp:i??"",caller:Mb});return n.jsx(_ue,{scope:r,baseId:ys(),value:f,onValueChange:h,orientation:o,dir:u,activationMode:c,children:n.jsx(We.div,{dir:u,"data-orientation":o,...d,ref:t})})});GB.displayName=Mb;var HB="TabsList",QB=p.forwardRef((e,t)=>{const{__scopeTabs:r,loop:s=!0,...a}=e,i=B2(HB,r),o=KB(r);return n.jsx(Qk,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:s,children:n.jsx(We.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:t})})});QB.displayName=HB;var YB="TabsTrigger",XB=p.forwardRef((e,t)=>{const{__scopeTabs:r,value:s,disabled:a=!1,...i}=e,o=B2(YB,r),l=KB(r),c=ez(o.baseId,s),d=tz(o.baseId,s),u=s===o.value;return n.jsx(Yk,{asChild:!0,...l,focusable:!a,active:u,children:n.jsx(We.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":d,"data-state":u?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:c,...i,ref:t,onMouseDown:be(e.onMouseDown,f=>{!a&&f.button===0&&f.ctrlKey===!1?o.onValueChange(s):f.preventDefault()}),onKeyDown:be(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&o.onValueChange(s)}),onFocus:be(e.onFocus,()=>{const f=o.activationMode!=="manual";!u&&!a&&f&&o.onValueChange(s)})})})});XB.displayName=YB;var ZB="TabsContent",JB=p.forwardRef((e,t)=>{const{__scopeTabs:r,value:s,forceMount:a,children:i,...o}=e,l=B2(ZB,r),c=ez(l.baseId,s),d=tz(l.baseId,s),u=s===l.value,f=p.useRef(u);return p.useEffect(()=>{const h=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(h)},[]),n.jsx(Jn,{present:a||u,children:({present:h})=>n.jsx(We.div,{"data-state":u?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!h,id:d,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:h&&i})})});JB.displayName=ZB;function ez(e,t){return`${e}-trigger-${t}`}function tz(e,t){return`${e}-content-${t}`}var Cue=GB,nz=QB,rz=XB,sz=JB;const Us=Cue,ws=p.forwardRef(({className:e,...t},r)=>n.jsx(nz,{ref:r,className:he("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));ws.displayName=nz.displayName;const Et=p.forwardRef(({className:e,...t},r)=>n.jsx(rz,{ref:r,className:he("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",e),...t}));Et.displayName=rz.displayName;const Lt=p.forwardRef(({className:e,...t},r)=>n.jsx(sz,{ref:r,className:he("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Lt.displayName=sz.displayName;const Le=p.forwardRef(({className:e,...t},r)=>n.jsx("div",{className:"relative w-full overflow-auto",children:n.jsx("table",{ref:r,className:he("w-full caption-bottom text-sm",e),...t})}));Le.displayName="Table";const Fe=p.forwardRef(({className:e,...t},r)=>n.jsx("thead",{ref:r,className:he("[&_tr]:border-b",e),...t}));Fe.displayName="TableHeader";const Be=p.forwardRef(({className:e,...t},r)=>n.jsx("tbody",{ref:r,className:he("[&_tr:last-child]:border-0",e),...t}));Be.displayName="TableBody";const kue=p.forwardRef(({className:e,...t},r)=>n.jsx("tfoot",{ref:r,className:he("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));kue.displayName="TableFooter";const ee=p.forwardRef(({className:e,...t},r)=>n.jsx("tr",{ref:r,className:he("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",e),...t}));ee.displayName="TableRow";const L=p.forwardRef(({className:e,...t},r)=>n.jsx("th",{ref:r,className:he("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));L.displayName="TableHead";const T=p.forwardRef(({className:e,...t},r)=>n.jsx("td",{ref:r,className:he("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));T.displayName="TableCell";const Pue=p.forwardRef(({className:e,...t},r)=>n.jsx("caption",{ref:r,className:he("mt-4 text-sm text-muted-foreground",e),...t}));Pue.displayName="TableCaption";const Qe=IF,cr=mee,Aue=DF,az=p.forwardRef(({className:e,...t},r)=>n.jsx(Qj,{ref:r,className:he("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));az.displayName=Qj.displayName;const Ue=p.forwardRef(({className:e,children:t,...r},s)=>n.jsxs(Aue,{children:[n.jsx(az,{}),n.jsxs(Yj,{ref:s,className:he("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...r,children:[t,n.jsxs(LF,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[n.jsx(ts,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ue.displayName=Yj.displayName;const Ke=({className:e,...t})=>n.jsx("div",{className:he("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ke.displayName="DialogHeader";const Ct=({className:e,...t})=>n.jsx("div",{className:he("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ct.displayName="DialogFooter";const Ge=p.forwardRef(({className:e,...t},r)=>n.jsx(Xj,{ref:r,className:he("text-lg font-semibold leading-none tracking-tight",e),...t}));Ge.displayName=Xj.displayName;const Qv=p.forwardRef(({className:e,...t},r)=>n.jsx(Zj,{ref:r,className:he("text-sm text-muted-foreground",e),...t}));Qv.displayName=Zj.displayName;function Ww(e){if(e instanceof Va&&e.data&&typeof e.data=="object"&&e.data!==null&&"error"in e.data){const t=e.data.error;if(t!=null&&String(t).trim())return String(t)}return e instanceof Error?e.message:"Something went wrong."}function Eue(e){const t=Ww(e).toLowerCase();return t.includes("already exists")||t.includes("duplicate")||t.includes("unique")||t.includes("already registered")?{title:"Email already in use",description:Ww(e)+" Try another address, or find the existing user in the Students or Teachers tab.",variant:"destructive"}:{title:"Could not create user",description:Ww(e),variant:"destructive"}}function Oue(){var N,w;const[e,t]=p.useState(""),[r,s]=p.useState(!1),[a,i]=p.useState({first_name:"",last_name:"",email:"",role:"student",phone:"",gender:""}),{toast:o}=He(),l=je(),c=Qa({search:e||void 0,size:200}),d=Eb({search:e||void 0,size:200}),u=IB(),f=DB(),h=((N=c.data)==null?void 0:N.items)??[],m=((w=d.data)==null?void 0:w.items)??[],y=ae({mutationFn:async({type:S,id:_})=>{var C,P;return S==="student"?((C=bn.deleteStudent)==null?void 0:C.call(bn,_))??bn.updateStudent(_,{status:"inactive"}):((P=bn.updateTeacher)==null?void 0:P.call(bn,_,{}))??Promise.resolve()},onSuccess:()=>{l.invalidateQueries({queryKey:["lms"]}),o({title:"Done"})},onError:S=>o({title:"Error",description:S.message,variant:"destructive"})});function x(){var V,A;const S=a.email.trim(),_=a.first_name.trim(),C=a.last_name.trim(),P=S.toLowerCase(),D=h.some($=>($.email||"").trim().toLowerCase()===P),z=m.some($=>($.email||"").trim().toLowerCase()===P);if(D||z){o({title:"Email already in use",description:"That address matches someone already listed on this page (search may hide them). Use another email or clear search to find the user.",variant:"destructive"});return}const O={onSuccess:()=>{s(!1),j(),o({title:"User created successfully"})},onError:$=>o(Eue($))};a.role==="teacher"?f.mutate({first_name:_,last_name:C,email:S,phone:((V=a.phone)==null?void 0:V.trim())||void 0,gender:a.gender||void 0},O):u.mutate({first_name:_,last_name:C,email:S,phone:((A=a.phone)==null?void 0:A.trim())||void 0,gender:a.gender||void 0,create_portal_user:!0},O)}function j(){i({first_name:"",last_name:"",email:"",role:"student",phone:"",gender:""})}function v(){const S=[["Name","Email","Role","Status"]];h.forEach(z=>S.push([z.name,z.email,"Student",z.status||"active"])),m.forEach(z=>S.push([z.name,z.email,"Teacher","active"]));const _=S.map(z=>z.join(",")).join(` `),C=new Blob([_],{type:"text/csv"}),P=URL.createObjectURL(C),D=document.createElement("a");D.href=P,D.download="users_export.csv",D.click(),URL.revokeObjectURL(P)}const g=u.isPending||f.isPending,b=c.isLoading||d.isLoading;return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Users"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage platform users across all roles."})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(E,{variant:"outline",size:"sm",onClick:v,children:[n.jsx(yd,{className:"h-4 w-4 mr-1"})," Export"]}),n.jsxs(E,{size:"sm",onClick:()=>s(!0),children:[n.jsx(mt,{className:"h-4 w-4 mr-1"})," Create User"]})]})]}),n.jsx("div",{className:"flex gap-3 items-center",children:n.jsxs("div",{className:"relative flex-1 max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search users...",className:"pl-9",value:e,onChange:S=>t(S.target.value)})]})}),b?n.jsx("div",{className:"flex items-center justify-center min-h-[300px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs(Us,{defaultValue:"students",children:[n.jsxs(ws,{children:[n.jsxs(Et,{value:"students",children:["Students (",h.length,")"]}),n.jsxs(Et,{value:"teachers",children:["Teachers (",m.length,")"]})]}),n.jsx(Lt,{value:"students",className:"mt-4",children:n.jsx(W,{className:"border-0 shadow-sm",children:n.jsx(U,{className:"p-0",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Email"}),n.jsx(L,{children:"Phone"}),n.jsx(L,{children:"Batch"}),n.jsx(L,{children:"Status"}),n.jsx(L,{children:"Enrollment"}),n.jsx(L,{className:"w-10"})]})}),n.jsxs(Be,{children:[h.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:7,className:"text-center text-muted-foreground py-8",children:"No students found."})}),h.map(S=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:S.name}),n.jsx(T,{children:S.email}),n.jsx(T,{children:S.phone||"—"}),n.jsx(T,{children:S.batch_name||"—"}),n.jsx(T,{children:n.jsx(oe,{variant:S.status==="active"?"default":"secondary",className:"capitalize",children:S.status||"active"})}),n.jsx(T,{children:S.enrollment_date||"—"}),n.jsx(T,{children:n.jsxs(Yh,{children:[n.jsx(Xh,{asChild:!0,children:n.jsx(E,{variant:"ghost",size:"icon",className:"h-8 w-8",children:n.jsx(CE,{className:"h-4 w-4"})})}),n.jsx(Yu,{align:"end",children:n.jsx(Ji,{className:"text-destructive",onClick:()=>{window.confirm(`Deactivate student "${S.name}"?`)&&y.mutate({type:"student",id:S.id})},children:"Deactivate"})})]})})]},S.id))]})]})})})}),n.jsx(Lt,{value:"teachers",className:"mt-4",children:n.jsx(W,{className:"border-0 shadow-sm",children:n.jsx(U,{className:"p-0",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Email"}),n.jsx(L,{children:"Phone"}),n.jsx(L,{children:"Department"}),n.jsx(L,{children:"Specialization"}),n.jsx(L,{className:"w-10"})]})}),n.jsxs(Be,{children:[m.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No teachers found."})}),m.map(S=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:S.name}),n.jsx(T,{children:S.email}),n.jsx(T,{children:S.phone||"—"}),n.jsx(T,{children:S.department_name||"—"}),n.jsx(T,{children:S.specialization||"—"}),n.jsx(T,{children:n.jsxs(Yh,{children:[n.jsx(Xh,{asChild:!0,children:n.jsx(E,{variant:"ghost",size:"icon",className:"h-8 w-8",children:n.jsx(CE,{className:"h-4 w-4"})})}),n.jsx(Yu,{align:"end",children:n.jsx(Ji,{className:"text-destructive",onClick:()=>{window.confirm(`Remove teacher "${S.name}"?`)&&y.mutate({type:"teacher",id:S.id})},children:"Remove"})})]})})]},S.id))]})]})})})})]}),n.jsx(Qe,{open:r,onOpenChange:S=>{s(S),S||j()},children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create New User"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"First Name"}),n.jsx(G,{value:a.first_name,onChange:S=>i(_=>({..._,first_name:S.target.value})),placeholder:"John"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Last Name"}),n.jsx(G,{value:a.last_name,onChange:S=>i(_=>({..._,last_name:S.target.value})),placeholder:"Doe"})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Email"}),n.jsx(G,{type:"email",value:a.email,onChange:S=>i(_=>({..._,email:S.target.value})),placeholder:"john@email.com"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Must be unique in Odoo for students and teachers. If create fails, the address may already exist outside the current list."})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Phone"}),n.jsx(G,{value:a.phone,onChange:S=>i(_=>({..._,phone:S.target.value})),placeholder:"+1234567890"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Role"}),n.jsxs(Oe,{value:a.role,onValueChange:S=>i(_=>({..._,role:S})),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"student",children:"Student"}),n.jsx(Y,{value:"teacher",children:"Teacher"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Gender"}),n.jsxs(Oe,{value:a.gender,onValueChange:S=>i(_=>({..._,gender:S})),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"male",children:"Male"}),n.jsx(Y,{value:"female",children:"Female"})]})]})]})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>{s(!1),j()},children:"Cancel"}),n.jsx(E,{disabled:g||!a.first_name.trim()||!a.last_name.trim()||!a.email.trim(),onClick:x,children:g?"Creating...":"Create"})]})]})})]})}function Tue(){var x,j;const[e,t]=p.useState(""),[r,s]=p.useState(!1),[a,i]=p.useState({name:"",code:""}),{toast:o}=He(),l=BB({size:200}),c=zB(),d=VB(),u=((x=l.data)==null?void 0:x.items)??((j=l.data)==null?void 0:j.data)??[],h=(Array.isArray(u)?u:[]).filter(v=>{var g;return(g=v.name)==null?void 0:g.toLowerCase().includes(e.toLowerCase())}),m=l.isLoading;function y(){c.mutate({name:a.name,code:a.code||void 0},{onSuccess:()=>{s(!1),i({name:"",code:""}),o({title:"Department created"})},onError:v=>o({title:"Error",description:v.message,variant:"destructive"})})}return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Entities / Departments"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage organizational departments."})]}),n.jsxs(E,{size:"sm",onClick:()=>s(!0),children:[n.jsx(mt,{className:"h-4 w-4 mr-1"})," Create Department"]})]}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search departments...",className:"pl-9",value:e,onChange:v=>t(v.target.value)})]}),m?n.jsx("div",{className:"flex items-center justify-center min-h-[300px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[h.length===0&&n.jsx("p",{className:"col-span-full text-center text-muted-foreground py-8",children:"No departments found."}),h.map(v=>n.jsxs(W,{className:"border-0 shadow-sm",children:[n.jsxs(se,{className:"flex flex-row items-center justify-between pb-2",children:[n.jsxs(ie,{className:"text-base flex items-center gap-2",children:[n.jsx(Lh,{className:"h-4 w-4 text-primary"}),v.name]}),n.jsx(E,{size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>{window.confirm(`Delete "${v.name}"?`)&&d.mutate(v.id,{onSuccess:()=>o({title:"Deleted"}),onError:g=>o({title:"Error",description:g.message,variant:"destructive"})})},children:n.jsx($t,{className:"h-4 w-4"})})]}),n.jsx(U,{children:n.jsx("p",{className:"text-sm text-muted-foreground",children:v.code||"No code"})})]},v.id))]}),n.jsx(Qe,{open:r,onOpenChange:s,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create Department"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{value:a.name,onChange:v=>i(g=>({...g,name:v.target.value})),placeholder:"Department name"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Code"}),n.jsx(G,{value:a.code,onChange:v=>i(g=>({...g,code:v.target.value})),placeholder:"DEPT01"})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),n.jsx(E,{disabled:c.isPending||!a.name,onClick:y,children:c.isPending?"Creating...":"Create"})]})]})})]})}function Mue(){var x,j;const[e,t]=p.useState(""),[r,s]=p.useState(!1),[a,i]=p.useState({title:"",entity_id:"",start_date:"",end_date:""}),{toast:o}=He(),l=Nd({size:200}),c=Fce(),d=((x=l.data)==null?void 0:x.items)??((j=l.data)==null?void 0:j.data)??[],u=Array.isArray(d)?d:[],f=e.toLowerCase(),h=u.filter(v=>{var g,b;return((g=v.title)==null?void 0:g.toLowerCase().includes(f))||((b=v.entity_name)==null?void 0:b.toLowerCase().includes(f))}),m=l.isLoading;function y(){c.mutate({title:a.title,entity_id:Number(a.entity_id)||0,start_date:a.start_date,end_date:a.end_date},{onSuccess:()=>{s(!1),i({title:"",entity_id:"",start_date:"",end_date:""}),o({title:"Assignment created"})},onError:v=>o({title:"Error",description:v.message,variant:"destructive"})})}return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Assignments"}),n.jsx("p",{className:"text-muted-foreground",children:"Create and manage assignments."})]}),n.jsxs(E,{size:"sm",onClick:()=>s(!0),children:[n.jsx(mt,{className:"h-4 w-4 mr-1"})," Create Assignment"]})]}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search assignments...",className:"pl-9",value:e,onChange:v=>t(v.target.value)})]}),m?n.jsx("div",{className:"flex items-center justify-center min-h-[300px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsx(W,{className:"border-0 shadow-sm",children:n.jsx(U,{className:"p-0",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Title"}),n.jsx(L,{children:"Entity"}),n.jsx(L,{children:"Start"}),n.jsx(L,{children:"End"}),n.jsx(L,{children:"State"}),n.jsx(L,{children:"Assignees"}),n.jsx(L,{children:"Completed"})]})}),n.jsxs(Be,{children:[h.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:7,className:"text-center text-muted-foreground py-8",children:"No assignments found."})}),h.map(v=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:v.title}),n.jsx(T,{children:v.entity_name||"—"}),n.jsx(T,{children:v.start_date||"—"}),n.jsx(T,{children:v.end_date||"—"}),n.jsx(T,{children:n.jsx(oe,{variant:v.state==="active"?"default":"secondary",className:"capitalize",children:v.state})}),n.jsx(T,{children:v.assignee_count??0}),n.jsx(T,{children:v.completed_count??0})]},v.id))]})]})})}),n.jsx(Qe,{open:r,onOpenChange:s,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create Assignment"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Title"}),n.jsx(G,{value:a.title,onChange:v=>i(g=>({...g,title:v.target.value})),placeholder:"e.g. IELTS Prep Q2"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Entity ID"}),n.jsx(G,{type:"number",value:a.entity_id,onChange:v=>i(g=>({...g,entity_id:v.target.value}))})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Start Date"}),n.jsx(G,{type:"date",value:a.start_date,onChange:v=>i(g=>({...g,start_date:v.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"End Date"}),n.jsx(G,{type:"date",value:a.end_date,onChange:v=>i(g=>({...g,end_date:v.target.value}))})]})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),n.jsx(E,{disabled:c.isPending||!a.title,onClick:y,children:c.isPending?"Creating...":"Create"})]})]})})]})}function Rue(){var l,c;const[e,t]=p.useState(""),r=ede(),s=((l=r.data)==null?void 0:l.data)??((c=r.data)==null?void 0:c.items)??[],a=Array.isArray(s)?s:[],i=e.toLowerCase(),o=a.filter(d=>{var u,f;return((u=d.name)==null?void 0:u.toLowerCase().includes(i))||((f=d.course_name)==null?void 0:f.toLowerCase().includes(i))});return n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Exams List"}),n.jsx("p",{className:"text-muted-foreground",children:"Browse and manage all exam sessions."})]})}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search exams...",className:"pl-9",value:e,onChange:d=>t(d.target.value)})]}),r.isLoading?n.jsx("div",{className:"flex items-center justify-center min-h-[300px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsx(W,{className:"border-0 shadow-sm",children:n.jsx(U,{className:"p-0",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"#"}),n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Course"}),n.jsx(L,{children:"Batch"}),n.jsx(L,{children:"Start"}),n.jsx(L,{children:"End"}),n.jsx(L,{children:"State"})]})}),n.jsxs(Be,{children:[o.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:7,className:"text-center text-muted-foreground py-8",children:"No exam sessions found."})}),o.map((d,u)=>n.jsxs(ee,{children:[n.jsx(T,{children:u+1}),n.jsx(T,{className:"font-medium",children:d.name}),n.jsx(T,{children:d.course_name||"—"}),n.jsx(T,{children:d.batch_name||"—"}),n.jsx(T,{children:d.start_date||"—"}),n.jsx(T,{children:d.end_date||"—"}),n.jsx(T,{children:n.jsx(oe,{variant:d.state==="done"?"default":d.state==="schedule"?"secondary":"outline",className:"capitalize",children:d.state})})]},d.id))]})]})})})]})}function Wn({context:e="dashboard",variant:t="tip",dismissible:r=!0}){var f;const[s,a]=p.useState(!1),{data:i,isLoading:o,isError:l,error:c}=ye({queryKey:["ai","tip",e],queryFn:()=>ox.getTip(e)});if(s)return null;const d=t==="recommendation"?"bg-accent/50 border-accent":t==="insight"?"bg-primary/5 border-primary/20":"bg-muted/50 border-muted-foreground/10";if(o)return n.jsxs("div",{className:`rounded-lg border ${d} p-3 flex items-center gap-3`,children:[n.jsx(Re,{className:"h-4 w-4 animate-spin text-primary shrink-0"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading AI tip…"})]});if(l||!i)return n.jsxs("div",{className:`rounded-lg border ${d} p-3 flex items-start gap-3`,children:[n.jsx(lt,{className:"h-4 w-4 text-primary shrink-0 mt-0.5"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("span",{className:"text-xs font-semibold text-primary",children:"AI Tip"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:l?c instanceof Error?c.message:"Could not load tip.":"No tip available."})]}),r&&n.jsx(E,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0",onClick:()=>a(!0),children:n.jsx(ts,{className:"h-3 w-3"})})]});if(!((f=i.tip)!=null&&f.trim()))return n.jsxs("div",{className:`rounded-lg border ${d} p-3 flex items-start gap-3`,children:[n.jsx(lt,{className:"h-4 w-4 text-primary shrink-0 mt-0.5"}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("span",{className:"text-xs font-semibold text-primary",children:["AI ",t==="tip"?"Tip":t==="insight"?"Insight":"Recommendation"]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"No tip for this context yet."})]})]});const u=i.category&&i.category!=="general"?`AI ${i.category.charAt(0).toUpperCase()+i.category.slice(1)} Tip`:`AI ${t==="tip"?"Tip":t==="insight"?"Insight":"Recommendation"}`;return n.jsxs("div",{className:`rounded-lg border ${d} p-3 flex items-start gap-3 animate-in fade-in slide-in-from-top-2 duration-300`,children:[n.jsx(lt,{className:"h-4 w-4 text-primary shrink-0 mt-0.5"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("span",{className:"text-xs font-semibold text-primary",children:u}),n.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:i.tip})]}),r&&n.jsx(E,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0",onClick:()=>a(!0),children:n.jsx(ts,{className:"h-3 w-3"})})]})}const $ue=["Reading","Listening","Writing","Speaking"];function Iue(){const{toast:e}=He(),t=je(),[r,s]=p.useState(""),[a,i]=p.useState("all"),[o,l]=p.useState(!1),[c,d]=p.useState(""),[u,f]=p.useState(""),[h,m]=p.useState([]),{data:y,isLoading:x,error:j}=ye({queryKey:["exam-structures",a],queryFn:()=>qw.listStructures(a!=="all"?{entity_id:Number(a)}:{})}),v=(y==null?void 0:y.items)??[],g=ae({mutationFn:w=>qw.createStructure(w),onSuccess:()=>{t.invalidateQueries({queryKey:["exam-structures"]}),l(!1),d(""),f(""),m([]),e({title:"Structure created"})},onError:w=>e({variant:"destructive",title:"Failed",description:w.message})}),b=ae({mutationFn:w=>qw.deleteStructure(w),onSuccess:()=>{t.invalidateQueries({queryKey:["exam-structures"]}),e({title:"Structure deleted"})},onError:w=>e({variant:"destructive",title:"Failed",description:w.message})}),N=v.filter(w=>{var S,_;if(r){const C=r.toLowerCase();return((S=w.name)==null?void 0:S.toLowerCase().includes(C))||((_=w.industry)==null?void 0:_.toString().toLowerCase().includes(C))}return!0});return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Exam Structures"}),n.jsx("p",{className:"text-muted-foreground",children:"Define exam structure templates by entity and industry."})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(Qe,{open:o,onOpenChange:l,children:[n.jsx(cr,{asChild:!0,children:n.jsxs(E,{size:"sm",children:[n.jsx(mt,{className:"h-4 w-4 mr-1"})," Create Structure"]})}),n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create Exam Structure"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Structure Name"}),n.jsx(G,{placeholder:"e.g. Corporate Writing Test",value:c,onChange:w=>d(w.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Industry"}),n.jsxs(Oe,{value:u,onValueChange:f,children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select Industry"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"General",children:"General"}),n.jsx(Y,{value:"Technology",children:"Technology"}),n.jsx(Y,{value:"Healthcare",children:"Healthcare"}),n.jsx(Y,{value:"Hospitality",children:"Hospitality"}),n.jsx(Y,{value:"Education",children:"Education"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Modules"}),n.jsx("div",{className:"flex flex-wrap gap-3",children:$ue.map(w=>n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(an,{id:`new-mod-${w}`,checked:h.includes(w.toLowerCase()),onCheckedChange:S=>{m(_=>S?[..._,w.toLowerCase()]:_.filter(C=>C!==w.toLowerCase()))}}),n.jsx(q,{htmlFor:`new-mod-${w}`,className:"text-sm",children:w})]},w))})]}),n.jsxs(E,{className:"w-full",disabled:!c||g.isPending,onClick:()=>g.mutate({name:c,industry:u,modules:h}),children:[g.isPending?n.jsx(Re,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Create"]})]})]})]}),n.jsxs(E,{size:"sm",variant:"destructive",disabled:!0,children:[n.jsx($t,{className:"h-4 w-4 mr-1"})," Delete"]})]})]}),n.jsx(Wn,{context:"exam-structures",variant:"insight"}),n.jsxs("div",{className:"flex gap-3 items-center",children:[n.jsxs("div",{className:"relative flex-1 max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search structures...",className:"pl-9",value:r,onChange:w=>s(w.target.value)})]}),n.jsxs(Oe,{value:a,onValueChange:i,children:[n.jsx(Ae,{className:"w-[140px]",children:n.jsx(Me,{placeholder:"Entity"})}),n.jsx(Ee,{children:n.jsx(Y,{value:"all",children:"All Entities"})})]})]}),x&&n.jsx("div",{className:"flex items-center justify-center py-12",children:n.jsx(Re,{className:"h-6 w-6 animate-spin text-muted-foreground"})}),j&&n.jsx(W,{className:"border-destructive",children:n.jsx(U,{className:"p-4 text-sm text-destructive",children:"Failed to load structures. The backend endpoint may not be available yet."})}),!x&&!j&&N.length===0&&n.jsx(W,{className:"border-dashed",children:n.jsx(U,{className:"p-8 text-center text-muted-foreground",children:"No exam structures found. Create one to get started."})}),n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:N.map(w=>n.jsxs(W,{className:"border-0 shadow-sm",children:[n.jsx(se,{className:"pb-3",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(ie,{className:"text-base font-semibold flex items-center gap-2",children:[n.jsx(oo,{className:"h-4 w-4 text-primary"}),w.name]}),n.jsx(E,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>b.mutate(w.id),disabled:b.isPending,children:n.jsx($t,{className:"h-4 w-4"})})]})}),n.jsxs(U,{children:[n.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[w.entity_name&&n.jsxs("span",{children:["Entity: ",n.jsx("span",{className:"text-foreground font-medium",children:String(w.entity_name)})]}),w.industry&&n.jsxs("span",{children:["Industry: ",n.jsx("span",{className:"text-foreground font-medium",children:String(w.industry)})]})]}),n.jsx("div",{className:"flex gap-1.5 flex-wrap",children:(Array.isArray(w.modules)?w.modules:[]).map(S=>n.jsx(oe,{variant:"outline",className:"capitalize",children:S},S))})]})]},w.id))})]})}const on=p.forwardRef(({className:e,...t},r)=>n.jsx("textarea",{className:he("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...t}));on.displayName="Textarea";const hg={course:"Course",assignment:"Assignment",batch:"Batch",rubric:"Rubric",exam:"Exam",student:"Student Plan",teacher:"Teacher Assignment"};function vx({type:e,trigger:t,onGenerated:r}){var x,j;const[s,a]=p.useState(!1),[i,o]=p.useState(""),[l,c]=p.useState("b2"),[d,u]=p.useState(""),{toast:f}=He(),h=ae({mutationFn:v=>bn.aiGenerateCourse(v),onError:v=>{f({variant:"destructive",title:"Generation failed",description:v.message||"Could not generate course outline."})}}),m=()=>{if(e!=="course"){f({variant:"destructive",title:"Not available",description:"Live AI generation is wired for courses only. Use the course type to generate an outline."});return}const v=i.trim()||"Untitled course",g=d.trim()?Number(d):void 0;h.mutate({title:v,...g!==void 0&&!Number.isNaN(g)?{subject_id:g}:{},level:l})},y=()=>{h.data&&(r==null||r(h.data),f({title:`AI ${hg[e]} Applied`,description:`The AI-generated ${e} has been applied to your form.`}),a(!1),h.reset())};return n.jsxs(n.Fragment,{children:[t?n.jsx("div",{onClick:()=>a(!0),children:t}):n.jsxs(E,{variant:"outline",size:"sm",onClick:()=>a(!0),children:[n.jsx(lt,{className:"h-3.5 w-3.5 mr-1 text-primary"})," AI Generate ",hg[e]]}),n.jsx(Qe,{open:s,onOpenChange:v=>{a(v),v||h.reset()},children:n.jsxs(Ue,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[n.jsx(Ke,{children:n.jsxs(Ge,{className:"flex items-center gap-2",children:[n.jsx(lt,{className:"h-4 w-4 text-primary"})," AI ",hg[e]," Generator"]})}),e==="course"&&h.isSuccess?n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"rounded-lg bg-muted/30 p-4 space-y-3",children:[n.jsxs("p",{className:"text-xs font-semibold text-primary flex items-center gap-1",children:[n.jsx(lt,{className:"h-3 w-3"})," AI Generated ",hg[e]]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Outline"}),n.jsx("pre",{className:"text-sm mt-1 whitespace-pre-wrap break-words rounded-md border bg-background p-3 max-h-[40vh] overflow-y-auto",children:typeof((x=h.data)==null?void 0:x.outline)=="string"?h.data.outline:JSON.stringify((j=h.data)==null?void 0:j.outline,null,2)})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(E,{className:"flex-1",onClick:y,children:"Apply to Form"}),n.jsx(E,{variant:"outline",onClick:()=>h.reset(),children:"Regenerate"})]})]}):n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Describe what you need"}),n.jsx(on,{placeholder:`Describe the ${e} you want to create... (e.g. "An intermediate IELTS writing course focusing on Task 2 essays")`,rows:3,value:i,onChange:v=>o(v.target.value)})]}),e==="course"&&n.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Level"}),n.jsxs(Oe,{value:l,onValueChange:c,children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsx(Ee,{children:["A1","A2","B1","B2","C1","C2"].map(v=>n.jsx(Y,{value:v.toLowerCase(),children:v},v))})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Subject ID (optional)"}),n.jsx(G,{inputMode:"numeric",placeholder:"e.g. 12",value:d,onChange:v=>u(v.target.value)})]})]}),(e==="assignment"||e==="exam")&&n.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Level"}),n.jsxs(Oe,{defaultValue:"b2",children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsx(Ee,{children:["A1","A2","B1","B2","C1","C2"].map(v=>n.jsx(Y,{value:v.toLowerCase(),children:v},v))})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Focus Area"}),n.jsxs(Oe,{defaultValue:"general",children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"general",children:"General"}),n.jsx(Y,{value:"reading",children:"Reading"}),n.jsx(Y,{value:"writing",children:"Writing"}),n.jsx(Y,{value:"speaking",children:"Speaking"}),n.jsx(Y,{value:"listening",children:"Listening"})]})]})]})]}),n.jsx(E,{className:"w-full",onClick:m,disabled:h.isPending,children:h.isPending?n.jsxs(n.Fragment,{children:[n.jsx(Re,{className:"h-4 w-4 mr-2 animate-spin"})," Generating..."]}):n.jsxs(n.Fragment,{children:[n.jsx(lt,{className:"h-4 w-4 mr-2"})," Generate with AI"]})})]})]})})]})}const Due=[{id:1,name:"IELTS Writing Task 2",levels:["A1","A2","B1","B2","C1","C2"],criteria:4,created:"2025-01-05"},{id:2,name:"Speaking Fluency",levels:["A1","A2","B1","B2","C1","C2"],criteria:3,created:"2025-01-10"},{id:3,name:"Reading Comprehension",levels:["A1","A2","B1","B2","C1"],criteria:5,created:"2025-02-01"}],Lue=[{id:1,name:"Academic IELTS Full",rubrics:["IELTS Writing Task 2","Speaking Fluency","Reading Comprehension"],created:"2025-02-15"},{id:2,name:"Business English",rubrics:["Speaking Fluency"],created:"2025-03-01"}];function Fue(){const[e,t]=p.useState("");return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Rubrics"}),n.jsx("p",{className:"text-muted-foreground",children:"Create and manage evaluation rubrics with level-based descriptors."})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(vx,{type:"rubric"}),n.jsxs(Qe,{children:[n.jsx(cr,{asChild:!0,children:n.jsxs(E,{size:"sm",children:[n.jsx(mt,{className:"h-4 w-4 mr-1"})," Create Rubric"]})}),n.jsxs(Ue,{className:"max-w-2xl",children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create Rubric"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Rubric Name"}),n.jsx(G,{placeholder:"e.g. IELTS Writing Task 1"})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsx(q,{children:"Level Descriptors"}),["A1","A2","B1","B2","C1","C2"].map(r=>n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs text-muted-foreground",children:r}),n.jsx(on,{placeholder:`Descriptor for level ${r}...`,className:"h-16"})]},r))]}),n.jsx(E,{className:"w-full",children:"Create Rubric"})]})]})]})]})]}),n.jsx(Wn,{context:"rubrics",variant:"recommendation"}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search rubrics...",className:"pl-9",value:e,onChange:r=>t(r.target.value)})]}),n.jsxs(Us,{defaultValue:"rubrics",children:[n.jsxs(ws,{children:[n.jsx(Et,{value:"rubrics",children:"Rubrics List"}),n.jsx(Et,{value:"groups",children:"Rubric Groups"})]}),n.jsx(Lt,{value:"rubrics",className:"mt-4",children:n.jsx(W,{className:"border-0 shadow-sm",children:n.jsx(U,{className:"p-0",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Levels"}),n.jsx(L,{children:"Criteria"}),n.jsx(L,{children:"Created"})]})}),n.jsx(Be,{children:Due.map(r=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:r.name}),n.jsx(T,{children:n.jsx("div",{className:"flex gap-1",children:r.levels.map(s=>n.jsx(oe,{variant:"outline",className:"text-xs",children:s},s))})}),n.jsx(T,{children:r.criteria}),n.jsx(T,{children:r.created})]},r.id))})]})})})}),n.jsx(Lt,{value:"groups",className:"mt-4",children:n.jsx(W,{className:"border-0 shadow-sm",children:n.jsx(U,{className:"p-0",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Group Name"}),n.jsx(L,{children:"Rubrics"}),n.jsx(L,{children:"Created"})]})}),n.jsx(Be,{children:Lue.map(r=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:r.name}),n.jsx(T,{children:n.jsx("div",{className:"flex gap-1 flex-wrap",children:r.rubrics.map(s=>n.jsx(oe,{variant:"secondary",className:"text-xs",children:s},s))})}),n.jsx(T,{children:r.created})]},r.id))})]})})})})]})]})}var Rb="Switch",[Bue]=lr(Rb),[zue,Vue]=Bue(Rb),iz=p.forwardRef((e,t)=>{const{__scopeSwitch:r,name:s,checked:a,defaultChecked:i,required:o,disabled:l,value:c="on",onCheckedChange:d,form:u,...f}=e,[h,m]=p.useState(null),y=dt(t,b=>m(b)),x=p.useRef(!1),j=h?u||!!h.closest("form"):!0,[v,g]=zr({prop:a,defaultProp:i??!1,onChange:d,caller:Rb});return n.jsxs(zue,{scope:r,checked:v,disabled:l,children:[n.jsx(We.button,{type:"button",role:"switch","aria-checked":v,"aria-required":o,"data-state":dz(v),"data-disabled":l?"":void 0,disabled:l,value:c,...f,ref:y,onClick:be(e.onClick,b=>{g(N=>!N),j&&(x.current=b.isPropagationStopped(),x.current||b.stopPropagation())})}),j&&n.jsx(cz,{control:h,bubbles:!x.current,name:s,value:c,checked:v,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});iz.displayName=Rb;var oz="SwitchThumb",lz=p.forwardRef((e,t)=>{const{__scopeSwitch:r,...s}=e,a=Vue(oz,r);return n.jsx(We.span,{"data-state":dz(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:t})});lz.displayName=oz;var que="SwitchBubbleInput",cz=p.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:s=!0,...a},i)=>{const o=p.useRef(null),l=dt(o,i),c=lx(r),d=Zp(t);return p.useEffect(()=>{const u=o.current;if(!u)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==r&&m){const y=new Event("click",{bubbles:s});m.call(u,r),u.dispatchEvent(y)}},[c,r,s]),n.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:l,style:{...a.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});cz.displayName=que;function dz(e){return e?"checked":"unchecked"}var uz=iz,Wue=lz;const Fr=p.forwardRef(({className:e,...t},r)=>n.jsx(uz,{className:he("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",e),...t,ref:r,children:n.jsx(Wue,{className:he("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Fr.displayName=uz.displayName;const dT=[{key:"reading",label:"Reading",icon:n.jsx(Kt,{className:"h-4 w-4"}),color:"text-blue-600",bgColor:"bg-blue-50 border-blue-200"},{key:"listening",label:"Listening",icon:n.jsx(Cj,{className:"h-4 w-4"}),color:"text-orange-600",bgColor:"bg-orange-50 border-orange-200"},{key:"writing",label:"Writing",icon:n.jsx(KL,{className:"h-4 w-4"}),color:"text-green-600",bgColor:"bg-green-50 border-green-200"},{key:"speaking",label:"Speaking",icon:n.jsx(Pj,{className:"h-4 w-4"}),color:"text-pink-600",bgColor:"bg-pink-50 border-pink-200"},{key:"level",label:"Level",icon:n.jsx(oo,{className:"h-4 w-4"}),color:"text-purple-600",bgColor:"bg-purple-50 border-purple-200"},{key:"industry",label:"Industry",icon:n.jsx(PG,{className:"h-4 w-4"}),color:"text-amber-700",bgColor:"bg-amber-50 border-amber-200"}],Uw=["A1","A2","B1","B2","C1","C2"],Uue=[{key:"mcq",label:"Multiple Choice"},{key:"fill_blanks",label:"Fill Blanks"},{key:"write_blanks",label:"Write Blanks"},{key:"true_false",label:"True False"},{key:"paragraph_match",label:"Paragraph Match"}],Kw=[{key:"social_conversation",label:"Social Conversation"},{key:"social_monologue",label:"Social Monologue"},{key:"academic_discussion",label:"Academic Discussion"},{key:"academic_monologue",label:"Academic Monologue"}],Kue=[{key:"mcq",label:"Multiple Choice"},{key:"write_blanks_questions",label:"Write Blanks: Questions"},{key:"true_false",label:"True False"},{key:"write_blanks_fill",label:"Write Blanks: Fill"},{key:"write_blanks_form",label:"Write Blanks: Form"}],Gue=[{id:"gia",name:"Gia",gender:"female"},{id:"vadim",name:"Vadim",gender:"male"},{id:"orhan",name:"Orhan",gender:"male"},{id:"flora",name:"Flora",gender:"female"},{id:"scarlett",name:"Scarlett",gender:"female"},{id:"parker",name:"Parker",gender:"male"},{id:"ethan",name:"Ethan",gender:"male"}];function Gw(e){return{timer:5,difficulty:[e==="reading"?"B2":e==="listening"?"A2":e==="writing"?"A1":"B1"],accessType:"private",entity:"",approvalWorkflow:"",rubricGroup:"",rubricCriteria:"",totalMarks:0,gradingSystem:"",shuffling:!1,passages:[{text:"",category:"",type:"general",divider:"",exerciseTypes:[],exercises:[],editing:!1}],listeningSections:[{type:"social_conversation",category:"",divider:"",context:"",audioUrl:"",exerciseTypes:[],exercises:[],editing:!1}],writingTasks:[{instructions:"",category:"",type:"",divider:"",wordLimit:150,marks:0,editing:!1}],speakingParts:[{type:"speaking_1",category:"",divider:"",script:"",videoUrl:"",avatarId:"",marks:0,topics:["",""],editing:!1}]}}function Hue(){const{toast:e}=He(),[t,r]=p.useState(""),[s,a]=p.useState(""),[i,o]=p.useState(""),[l,c]=p.useState(new Set),[d,u]=p.useState(null),[f,h]=p.useState({}),m=p.useCallback(A=>f[A]??Gw(A),[f]),y=p.useCallback((A,$)=>{h(B=>({...B,[A]:{...B[A]??Gw(A),...$}}))},[]),x=A=>{c($=>{const B=new Set($);return B.has(A)?(B.delete(A),d===A&&u(null)):(B.add(A),u(A)),B})};d&&m(d);const j=ae({mutationFn:A=>Wo.generatePassage({topic:A.topic,difficulty:A.difficulty,word_count:A.wordCount}),onSuccess:(A,$)=>{if(!d)return;const I=[...m(d).passages],k=A,M=k.passage??k.text??JSON.stringify(A);I[$.index]={...I[$.index],text:M},y(d,{passages:I}),e({title:"Passage generated",description:`${M.length} characters`})},onError:A=>e({variant:"destructive",title:"Generation failed",description:A.message})}),v=ae({mutationFn:A=>Wo.generate(A.module==="level"||A.module==="industry"?"reading":A.module,{topic:A.passageText.slice(0,200),difficulty:m(A.module).difficulty[0]??"B2",question_count:5}),onSuccess:(A,$)=>{const B=m($.module),I=Array.isArray(A.questions)?A.questions:[];if($.module==="reading"){const k=[...B.passages];k[$.passageIndex]={...k[$.passageIndex],exercises:I},y($.module,{passages:k})}e({title:`${I.length} exercises generated`})},onError:A=>e({variant:"destructive",title:"Generation failed",description:A.message})}),g=ae({mutationFn:A=>lT.generateListeningAudio({text:A.text}),onSuccess:(A,$)=>{if(d!=="listening")return;const I=[...m("listening").listeningSections];I[$.sectionIndex]={...I[$.sectionIndex],audioUrl:A.audio_url||""},y("listening",{listeningSections:I}),e({title:"Audio generated"})},onError:A=>e({variant:"destructive",title:"Audio generation failed",description:A.message})}),b=ae({mutationFn:A=>Wo.generateWritingInstructions({topic:A.topic,difficulty:A.difficulty,task_type:"letter"}),onSuccess:(A,$)=>{const I=[...m("writing").writingTasks],k=A,M=k.instructions??JSON.stringify(k.questions??A);I[$.taskIndex]={...I[$.taskIndex],instructions:M},y("writing",{writingTasks:I}),e({title:"Instructions generated"})},onError:A=>e({variant:"destructive",title:"Generation failed",description:A.message})}),N=ae({mutationFn:A=>Wo.generateSpeakingScript({topics:A.topics.filter(Boolean),difficulty:A.difficulty,part:"speaking_1"}),onSuccess:(A,$)=>{const I=[...m("speaking").speakingParts],k=A,M=k.script??JSON.stringify(k.questions??A);I[$.partIndex]={...I[$.partIndex],script:M},y("speaking",{speakingParts:I}),e({title:"Script generated"})},onError:A=>e({variant:"destructive",title:"Generation failed",description:A.message})}),w=ae({mutationFn:A=>lT.createAvatarVideo({script:A.script,avatar_id:A.avatarId,title:t||"Speaking Video"}),onSuccess:(A,$)=>{const I=[...m("speaking").speakingParts];I[$.partIndex]={...I[$.partIndex],videoUrl:`pending:${A.video_id}`},y("speaking",{speakingParts:I}),e({title:"Video generation started",description:`Job ID: ${A.video_id}`})},onError:A=>e({variant:"destructive",title:"Video generation failed",description:A.message})}),S=ae({mutationFn:A=>{const $={};for(const B of l){const I=m(B);$[B]={timer:I.timer,difficulty:I.difficulty,accessType:I.accessType,shuffling:I.shuffling,gradingSystem:I.gradingSystem,passages:B==="reading"?I.passages.map(k=>({text:k.text,category:k.category,type:k.type,exercises:k.exercises})):void 0,sections:B==="listening"?I.listeningSections.map(k=>({type:k.type,context:k.context,audioUrl:k.audioUrl})):void 0,tasks:B==="writing"?I.writingTasks.map(k=>({instructions:k.instructions,wordLimit:k.wordLimit,marks:k.marks})):void 0,parts:B==="speaking"?I.speakingParts.map(k=>({type:k.type,script:k.script,videoUrl:k.videoUrl,marks:k.marks})):void 0}}return Wo.submitExam({title:t,label:s,modules:$,skip_approval:A})},onSuccess:A=>e({title:"Exam submitted",description:`Exam #${A.exam_id} created (${A.status})`}),onError:A=>e({variant:"destructive",title:"Submit failed",description:A.message})}),_=j.isPending||v.isPending||g.isPending||b.isPending||N.isPending||w.isPending||S.isPending,C=A=>{const $=m(A);return n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs",children:"Difficulty"}),n.jsxs("div",{className:"flex flex-wrap gap-1",children:[$.difficulty.map(B=>n.jsxs(oe,{variant:"secondary",className:"text-xs gap-1",children:[B,n.jsx("button",{onClick:()=>y(A,{difficulty:$.difficulty.filter(I=>I!==B)}),className:"ml-0.5 hover:text-destructive",children:n.jsx(ts,{className:"h-3 w-3"})})]},B)),n.jsxs(Oe,{onValueChange:B=>{$.difficulty.includes(B)||y(A,{difficulty:[...$.difficulty,B]})},children:[n.jsx(Ae,{className:"h-6 w-16 text-xs",children:n.jsx(mt,{className:"h-3 w-3"})}),n.jsx(Ee,{children:Uw.filter(B=>!$.difficulty.includes(B)).map(B=>n.jsx(Y,{value:B,children:B},B))})]})]})]})},P=A=>{const $=m(A);return n.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3 text-sm",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs",children:"Timer (minutes)"}),n.jsx(G,{type:"number",value:$.timer,min:1,onChange:B=>y(A,{timer:Number(B.target.value)||1}),className:"h-8 text-xs"})]}),C(A),n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs",children:"Access Type"}),n.jsxs(Oe,{value:$.accessType,onValueChange:B=>y(A,{accessType:B}),children:[n.jsx(Ae,{className:"h-8 text-xs",children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"private",children:"Private"}),n.jsx(Y,{value:"public",children:"Public"})]})]})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs",children:"Entities"}),n.jsxs(Oe,{value:$.entity,onValueChange:B=>y(A,{entity:B}),children:[n.jsx(Ae,{className:"h-8 text-xs",children:n.jsx(Me,{placeholder:"Select..."})}),n.jsx(Ee,{children:n.jsx(Y,{value:"none",children:"None"})})]})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs",children:"Approval Workflow"}),n.jsxs(Oe,{value:$.approvalWorkflow,onValueChange:B=>y(A,{approvalWorkflow:B}),children:[n.jsx(Ae,{className:"h-8 text-xs",children:n.jsx(Me,{placeholder:"Select..."})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"default",children:"Default"}),n.jsx(Y,{value:"none",children:"None"})]})]})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs",children:"Grading System"}),n.jsxs(Oe,{value:$.gradingSystem,onValueChange:B=>y(A,{gradingSystem:B}),children:[n.jsx(Ae,{className:"h-8 text-xs",children:n.jsx(Me,{placeholder:"System Select"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"ielts",children:"IELTS Band"}),n.jsx(Y,{value:"percentage",children:"Percentage"})]})]})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs",children:"Total Marks"}),n.jsx("div",{className:"h-8 flex items-center text-xs font-medium",children:$.totalMarks})]}),n.jsxs("div",{className:"flex items-center gap-2 col-span-2 md:col-span-1",children:[n.jsx(Fr,{checked:$.shuffling,onCheckedChange:B=>y(A,{shuffling:B})}),n.jsx(q,{className:"text-xs",children:"Shuffling Enabled"})]})]})},D=()=>{if(!d||d!=="reading")return null;const A=m("reading");return n.jsxs("div",{className:"space-y-4",children:[P("reading"),n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs font-medium",children:"Passages"}),n.jsxs("div",{className:"flex gap-2 flex-wrap",children:[A.passages.map(($,B)=>n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(an,{checked:!0,id:`p-${B}`}),n.jsxs(q,{htmlFor:`p-${B}`,className:"text-xs",children:["Passage ",B+1]})]},B)),n.jsxs(E,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{const $={text:"",category:"",type:"general",divider:"",exerciseTypes:[],exercises:[],editing:!1};y("reading",{passages:[...A.passages,$]})},children:[n.jsx(mt,{className:"h-3 w-3 mr-1"})," Add"]})]})]}),n.jsxs(E,{variant:"ghost",size:"sm",onClick:()=>h($=>({...$,reading:Gw("reading")})),className:"text-xs",children:[n.jsx(GL,{className:"h-3 w-3 mr-1"})," Reset Module"]}),n.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:A.passages.map(($,B)=>n.jsxs("div",{className:"space-y-3",children:[n.jsx(W,{className:"border-blue-200 bg-blue-50/50",children:n.jsxs(U,{className:"p-4 space-y-3",children:[n.jsxs("h4",{className:"text-sm font-semibold text-blue-700",children:["Passage ",B+1," Settings"]}),n.jsxs(fr,{children:[n.jsxs(mr,{className:"flex items-center gap-1 text-xs font-medium w-full justify-between bg-blue-100 rounded px-2 py-1",children:["Category ",n.jsx(rr,{className:"h-3 w-3"})]}),n.jsx(hr,{className:"pt-2",children:n.jsx(G,{value:$.category,placeholder:"Category",className:"h-8 text-xs",onChange:I=>{const k=[...A.passages];k[B]={...k[B],category:I.target.value},y("reading",{passages:k})}})})]}),n.jsxs(fr,{children:[n.jsxs(mr,{className:"flex items-center gap-1 text-xs font-medium w-full justify-between bg-blue-100 rounded px-2 py-1",children:["Type ",n.jsx(rr,{className:"h-3 w-3"})]}),n.jsx(hr,{className:"pt-2",children:n.jsxs(Oe,{value:$.type,onValueChange:I=>{const k=[...A.passages];k[B]={...k[B],type:I},y("reading",{passages:k})},children:[n.jsx(Ae,{className:"h-8 text-xs",children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"general",children:"General"}),n.jsx(Y,{value:"academic",children:"Academic"}),n.jsx(Y,{value:"technical",children:"Technical"})]})]})})]}),n.jsxs(fr,{children:[n.jsxs(mr,{className:"flex items-center gap-1 text-xs font-medium w-full justify-between bg-blue-100 rounded px-2 py-1",children:["Generate Passage ",n.jsx(rr,{className:"h-3 w-3"})]}),n.jsxs(hr,{className:"pt-2 space-y-2",children:[n.jsxs(Oe,{children:[n.jsx(Ae,{className:"h-8 text-xs",children:n.jsx(Me,{placeholder:"Passage Difficulty (Optional)"})}),n.jsx(Ee,{children:Uw.map(I=>n.jsx(Y,{value:I,children:I},I))})]}),n.jsx(G,{placeholder:"Topic (Optional)",className:"h-8 text-xs",id:`topic-${B}`}),n.jsx(G,{placeholder:"Approximate Word Count (Optional)",className:"h-8 text-xs",type:"number",id:`wc-${B}`}),n.jsxs(E,{size:"sm",className:"w-full text-xs",disabled:j.isPending,onClick:()=>{const I=document.getElementById(`topic-${B}`);j.mutate({index:B,topic:(I==null?void 0:I.value)||"",difficulty:A.difficulty[0]||"B2",wordCount:300})},children:[j.isPending?n.jsx(Re,{className:"h-3 w-3 mr-1 animate-spin"}):n.jsx(lt,{className:"h-3 w-3 mr-1"}),"Generate"]})]})]}),n.jsxs(fr,{children:[n.jsxs(mr,{className:"flex items-center gap-1 text-xs font-medium w-full justify-between bg-blue-100 rounded px-2 py-1",children:["Add Exercises ",n.jsx(rr,{className:"h-3 w-3"})]}),n.jsxs(hr,{className:"pt-2 space-y-1",children:[Uue.map(I=>n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(an,{id:`ex-${B}-${I.key}`,disabled:!$.text,checked:$.exerciseTypes.includes(I.key),onCheckedChange:k=>{const M=[...A.passages],K=k?[...M[B].exerciseTypes,I.key]:M[B].exerciseTypes.filter(X=>X!==I.key);M[B]={...M[B],exerciseTypes:K},y("reading",{passages:M})}}),n.jsxs(q,{htmlFor:`ex-${B}-${I.key}`,className:"text-xs",children:["Passage ",B+1," - ",I.label]})]},I.key)),n.jsxs(E,{size:"sm",className:"w-full mt-2 text-xs",disabled:!$.text||$.exerciseTypes.length===0||v.isPending,onClick:()=>v.mutate({module:"reading",passageIndex:B,types:$.exerciseTypes,passageText:$.text}),children:["Set Up Exercises (",$.exercises.length,")"]})]})]})]})}),n.jsx(W,{className:"border-blue-200",children:n.jsxs(U,{className:"p-4 space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h4",{className:"text-sm font-semibold",children:"Reading Passage"}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(E,{size:"sm",variant:"outline",className:"h-6 text-xs",disabled:!$.text,children:"Save"}),n.jsx(E,{size:"sm",variant:"outline",className:"h-6 text-xs",children:"Discard"}),n.jsx(E,{size:"sm",variant:"outline",className:"h-6 text-xs",onClick:()=>{const I=[...A.passages];I[B]={...I[B],editing:!I[B].editing},y("reading",{passages:I})},children:"Edit"})]})]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"The reading passage that the exercises will refer to."}),n.jsx(on,{value:$.text,onChange:I=>{const k=[...A.passages];k[B]={...k[B],text:I.target.value},y("reading",{passages:k})},placeholder:"Generate or edit the passage to add exercises!",className:"min-h-[150px] text-xs",readOnly:!$.editing})]})})]},B))})]})},z=()=>{if(d!=="listening")return null;const A=m("listening");return n.jsxs("div",{className:"space-y-4",children:[P("listening"),n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs font-medium",children:"Sections"}),n.jsxs("div",{className:"flex gap-2 flex-wrap",children:[A.listeningSections.map(($,B)=>{var I;return n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(an,{checked:!0,id:`ls-${B}`}),n.jsx(q,{htmlFor:`ls-${B}`,className:"text-xs",children:((I=Kw.find(k=>k.key===$.type))==null?void 0:I.label)||$.type})]},B)}),n.jsxs(E,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{const $={type:"social_monologue",category:"",divider:"",context:"",audioUrl:"",exerciseTypes:[],exercises:[],editing:!1};y("listening",{listeningSections:[...A.listeningSections,$]})},children:[n.jsx(mt,{className:"h-3 w-3 mr-1"})," Add"]})]})]}),n.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:A.listeningSections.map(($,B)=>{var I,k;return n.jsxs("div",{className:"space-y-3",children:[n.jsx(W,{className:"border-orange-200 bg-orange-50/50",children:n.jsxs(U,{className:"p-4 space-y-3",children:[n.jsxs("h4",{className:"text-sm font-semibold text-orange-700",children:[(I=Kw.find(M=>M.key===$.type))==null?void 0:I.label," Settings"]}),n.jsxs(fr,{children:[n.jsxs(mr,{className:"flex items-center gap-1 text-xs font-medium w-full justify-between bg-orange-100 rounded px-2 py-1",children:["Audio Context ",n.jsx(rr,{className:"h-3 w-3"})]}),n.jsxs(hr,{className:"pt-2 space-y-2",children:[n.jsx(G,{placeholder:"Topic",className:"h-8 text-xs",id:`ltopic-${B}`}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(E,{size:"sm",className:"flex-1 text-xs",onClick:()=>{const M=document.getElementById(`ltopic-${B}`);Wo.generateListeningContext({topic:(M==null?void 0:M.value)||"general conversation",section_type:$.type}).then(K=>{const X=K,re=[...A.listeningSections];re[B]={...re[B],context:X.context??JSON.stringify(X)},y("listening",{listeningSections:re}),e({title:"Context generated"})}).catch(K=>e({variant:"destructive",title:"Failed",description:String(K)}))},children:[n.jsx(lt,{className:"h-3 w-3 mr-1"})," Generate"]}),n.jsxs(E,{size:"sm",variant:"outline",className:"text-xs",children:[n.jsx(Ku,{className:"h-3 w-3 mr-1"})," Upload"]})]})]})]}),n.jsxs(fr,{children:[n.jsxs(mr,{className:"flex items-center gap-1 text-xs font-medium w-full justify-between bg-orange-100 rounded px-2 py-1",children:["Add Exercises ",n.jsx(rr,{className:"h-3 w-3"})]}),n.jsx(hr,{className:"pt-2 space-y-1",children:Kue.map(M=>n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(an,{id:`lex-${B}-${M.key}`,disabled:!$.context,checked:$.exerciseTypes.includes(M.key),onCheckedChange:K=>{const X=[...A.listeningSections],re=K?[...X[B].exerciseTypes,M.key]:X[B].exerciseTypes.filter(Z=>Z!==M.key);X[B]={...X[B],exerciseTypes:re},y("listening",{listeningSections:X})}}),n.jsxs(q,{htmlFor:`lex-${B}-${M.key}`,className:"text-xs",children:["Section ",B+1," - ",M.label]})]},M.key))})]}),n.jsxs(fr,{children:[n.jsxs(mr,{className:"flex items-center gap-1 text-xs font-medium w-full justify-between bg-orange-100 rounded px-2 py-1",children:["Generate Audio ",n.jsx(rr,{className:"h-3 w-3"})]}),n.jsxs(hr,{className:"pt-2",children:[n.jsxs(E,{size:"sm",className:"w-full text-xs",disabled:!$.context||g.isPending,onClick:()=>g.mutate({text:$.context,sectionIndex:B}),children:[g.isPending?n.jsx(Re,{className:"h-3 w-3 mr-1 animate-spin"}):n.jsx(pk,{className:"h-3 w-3 mr-1"}),"Generate Audio"]}),$.audioUrl&&n.jsx("p",{className:"text-xs text-green-600 mt-1",children:"Audio ready"})]})]})]})}),n.jsx(W,{className:"border-orange-200",children:n.jsxs(U,{className:"p-4 space-y-2",children:[n.jsx("h4",{className:"text-sm font-semibold",children:(k=Kw.find(M=>M.key===$.type))==null?void 0:k.label}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter the section's conversation or import your own"}),n.jsx(on,{value:$.context,placeholder:"Generate or type the conversation context...",onChange:M=>{const K=[...A.listeningSections];K[B]={...K[B],context:M.target.value},y("listening",{listeningSections:K})},className:"min-h-[120px] text-xs"})]})})]},B)})})]})},O=()=>{if(d!=="writing")return null;const A=m("writing");return n.jsxs("div",{className:"space-y-4",children:[P("writing"),n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs font-medium",children:"Tasks"}),n.jsxs("div",{className:"flex gap-2 flex-wrap",children:[A.writingTasks.map(($,B)=>n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(an,{checked:!0,id:`wt-${B}`}),n.jsxs(q,{htmlFor:`wt-${B}`,className:"text-xs",children:["Task ",B+1]})]},B)),A.writingTasks.length<2&&n.jsxs(E,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{const $={instructions:"",category:"",type:"",divider:"",wordLimit:250,marks:0,editing:!1};y("writing",{writingTasks:[...A.writingTasks,$]})},children:[n.jsx(mt,{className:"h-3 w-3 mr-1"})," Add Task 2"]})]})]}),n.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:A.writingTasks.map(($,B)=>n.jsxs("div",{className:"space-y-3",children:[n.jsx(W,{className:"border-green-200 bg-green-50/50",children:n.jsxs(U,{className:"p-4 space-y-3",children:[n.jsxs("h4",{className:"text-sm font-semibold text-green-700",children:["Task ",B+1," Settings"]}),n.jsxs(fr,{children:[n.jsxs(mr,{className:"flex items-center gap-1 text-xs font-medium w-full justify-between bg-green-100 rounded px-2 py-1",children:["Generate Instructions ",n.jsx(rr,{className:"h-3 w-3"})]}),n.jsxs(hr,{className:"pt-2 space-y-2",children:[n.jsx(G,{placeholder:"Topic",className:"h-8 text-xs",id:`wtopic-${B}`}),n.jsxs(Oe,{children:[n.jsx(Ae,{className:"h-8 text-xs",children:n.jsx(Me,{placeholder:"Difficulty (Optional)"})}),n.jsx(Ee,{children:Uw.map(I=>n.jsx(Y,{value:I,children:I},I))})]}),n.jsxs(E,{size:"sm",className:"w-full text-xs",disabled:b.isPending,onClick:()=>{const I=document.getElementById(`wtopic-${B}`);b.mutate({topic:(I==null?void 0:I.value)||"general",difficulty:A.difficulty[0]||"A1",taskIndex:B})},children:[b.isPending?n.jsx(Re,{className:"h-3 w-3 mr-1 animate-spin"}):n.jsx(lt,{className:"h-3 w-3 mr-1"}),"Generate"]})]})]})]})}),n.jsx(W,{className:"border-green-200",children:n.jsxs(U,{className:"p-4 space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h4",{className:"text-sm font-semibold",children:B===0?"Letter Instructions":"Essay Instructions"}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(E,{size:"sm",variant:"outline",className:"h-6 text-xs",children:"Save"}),n.jsx(E,{size:"sm",variant:"outline",className:"h-6 text-xs",children:"Edit"}),n.jsx(E,{size:"sm",variant:"outline",className:"h-6 text-xs",children:"Graded"})]})]}),n.jsx(on,{value:$.instructions,placeholder:"Instructions ...",className:"min-h-[120px] text-xs",onChange:I=>{const k=[...A.writingTasks];k[B]={...k[B],instructions:I.target.value},y("writing",{writingTasks:k})}}),n.jsxs("div",{className:"flex gap-4",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs",children:"Word Limit"}),n.jsx(G,{type:"number",value:$.wordLimit,className:"h-8 text-xs w-24",onChange:I=>{const k=[...A.writingTasks];k[B]={...k[B],wordLimit:Number(I.target.value)},y("writing",{writingTasks:k})}})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs",children:"Marks"}),n.jsx(G,{type:"number",value:$.marks,className:"h-8 text-xs w-24",onChange:I=>{const k=[...A.writingTasks];k[B]={...k[B],marks:Number(I.target.value)},y("writing",{writingTasks:k})}})]})]})]})})]},B))})]})},V=()=>{if(d!=="speaking")return null;const A=m("speaking"),$=[{key:"speaking_1",label:"Speaking 1"},{key:"speaking_2",label:"Speaking 2"},{key:"interactive",label:"Interactive Speaking"}];return n.jsxs("div",{className:"space-y-4",children:[P("speaking"),n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs font-medium",children:"Speaking Parts"}),n.jsxs("div",{className:"flex gap-2 flex-wrap",children:[A.speakingParts.map((B,I)=>{var k;return n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(an,{checked:!0,id:`sp-${I}`}),n.jsx(q,{htmlFor:`sp-${I}`,className:"text-xs",children:((k=$.find(M=>M.key===B.type))==null?void 0:k.label)||B.type})]},I)}),n.jsxs(E,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{const B=A.speakingParts.map(k=>k.type),I=$.find(k=>!B.includes(k.key));if(I){const k={type:I.key,category:"",divider:"",script:"",videoUrl:"",avatarId:"",marks:0,topics:["",""],editing:!1};y("speaking",{speakingParts:[...A.speakingParts,k]})}},children:[n.jsx(mt,{className:"h-3 w-3 mr-1"})," Add"]})]})]}),n.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:A.speakingParts.map((B,I)=>{var k,M;return n.jsxs("div",{className:"space-y-3",children:[n.jsx(W,{className:"border-pink-200 bg-pink-50/50",children:n.jsxs(U,{className:"p-4 space-y-3",children:[n.jsxs("h4",{className:"text-sm font-semibold text-pink-700",children:[(k=$.find(K=>K.key===B.type))==null?void 0:k.label," Settings"]}),n.jsxs(fr,{children:[n.jsxs(mr,{className:"flex items-center gap-1 text-xs font-medium w-full justify-between bg-pink-100 rounded px-2 py-1",children:["Generate Script ",n.jsx(rr,{className:"h-3 w-3"})]}),n.jsxs(hr,{className:"pt-2 space-y-2",children:[n.jsx(G,{placeholder:"First Topic (Optional)",className:"h-8 text-xs",value:B.topics[0]||"",onChange:K=>{const X=[...A.speakingParts];X[I]={...X[I],topics:[K.target.value,X[I].topics[1]||""]},y("speaking",{speakingParts:X})}}),n.jsx(G,{placeholder:"Second Topic (Optional)",className:"h-8 text-xs",value:B.topics[1]||"",onChange:K=>{const X=[...A.speakingParts];X[I]={...X[I],topics:[X[I].topics[0]||"",K.target.value]},y("speaking",{speakingParts:X})}}),n.jsxs(E,{size:"sm",className:"w-full text-xs",disabled:N.isPending,onClick:()=>N.mutate({topics:B.topics,difficulty:A.difficulty[0]||"B1",partIndex:I}),children:[N.isPending?n.jsx(Re,{className:"h-3 w-3 mr-1 animate-spin"}):n.jsx(lt,{className:"h-3 w-3 mr-1"}),"Generate"]})]})]}),n.jsxs(fr,{children:[n.jsxs(mr,{className:"flex items-center gap-1 text-xs font-medium w-full justify-between bg-pink-100 rounded px-2 py-1",children:["Generate Video ",n.jsx(rr,{className:"h-3 w-3"})]}),n.jsxs(hr,{className:"pt-2 space-y-2",children:[n.jsxs(Oe,{value:B.avatarId,onValueChange:K=>{const X=[...A.speakingParts];X[I]={...X[I],avatarId:K},y("speaking",{speakingParts:X})},children:[n.jsx(Ae,{className:"h-8 text-xs",children:n.jsx(Me,{placeholder:"Select an avatar (Optional)"})}),n.jsx(Ee,{children:Gue.map(K=>n.jsxs(Y,{value:String(K.id),children:[K.name," (",K.gender,")"]},String(K.id)))})]}),n.jsxs(E,{size:"sm",className:"w-full text-xs",disabled:!B.script||!B.avatarId||w.isPending,onClick:()=>w.mutate({script:B.script,avatarId:B.avatarId,partIndex:I}),children:[w.isPending?n.jsx(Re,{className:"h-3 w-3 mr-1 animate-spin"}):n.jsx(Ll,{className:"h-3 w-3 mr-1"}),"Generate Video"]}),B.videoUrl&&n.jsxs("p",{className:"text-xs text-green-600",children:["Video: ",B.videoUrl.startsWith("pending:")?"Processing...":"Ready"]})]})]})]})}),n.jsx(W,{className:"border-pink-200",children:n.jsxs(U,{className:"p-4 space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("h4",{className:"text-sm font-semibold",children:[(M=$.find(K=>K.key===B.type))==null?void 0:M.label," Script"]}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(E,{size:"sm",variant:"outline",className:"h-6 text-xs",children:"Save"}),n.jsx(E,{size:"sm",variant:"outline",className:"h-6 text-xs",children:"Edit"}),n.jsx(E,{size:"sm",variant:"outline",className:"h-6 text-xs",children:"Graded"})]})]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Generate or write the scripts for the videos."}),n.jsx(on,{value:B.script,placeholder:"Generate or edit the questions!",className:"min-h-[120px] text-xs",onChange:K=>{const X=[...A.speakingParts];X[I]={...X[I],script:K.target.value},y("speaking",{speakingParts:X})}}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs",children:"Marks"}),n.jsx(G,{type:"number",value:B.marks,className:"h-8 text-xs w-24",onChange:K=>{const X=[...A.speakingParts];X[I]={...X[I],marks:Number(K.target.value)},y("speaking",{speakingParts:X})}})]})]})})]},I)})})]})};return n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsx("div",{children:n.jsxs("h1",{className:"text-2xl font-bold tracking-tight flex items-center gap-2",children:[n.jsx(QL,{className:"h-6 w-6 text-primary"})," Generation"]})})}),n.jsx(Wn,{context:"generation",variant:"recommendation"}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsxs(q,{children:["Title ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsx(G,{value:t,onChange:A=>r(A.target.value),placeholder:"Insert title"})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{children:"Exam Label"}),n.jsx(G,{value:s,onChange:A=>a(A.target.value),placeholder:"Exam Label"})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{children:"Exam Structure"}),n.jsxs(Oe,{value:i,onValueChange:o,children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select an exam structure"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"standard_ielts",children:"Standard IELTS Academic"}),n.jsx(Y,{value:"corporate",children:"Corporate English Assessment"}),n.jsx(Y,{value:"hospitality",children:"Hospitality English Test"}),n.jsx(Y,{value:"medical",children:"Medical English Proficiency"})]})]})]})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Please select which subjects the exam is about"}),n.jsx("div",{className:"flex flex-wrap gap-3",children:dT.map(A=>n.jsxs("button",{className:`flex items-center gap-2 rounded-lg border-2 px-4 py-3 transition-all ${l.has(A.key)?`${A.bgColor} border-current ${A.color} shadow-sm`:"border-muted bg-background hover:bg-muted/50"}`,onClick:()=>x(A.key),children:[n.jsx("span",{className:A.color,children:A.icon}),n.jsx("span",{className:"text-sm font-medium",children:A.label}),l.has(A.key)&&n.jsx(oe,{variant:"default",className:"ml-1 h-5 text-[10px]",children:"Select"})]},A.key))})]}),d&&l.has(d)&&n.jsx("div",{className:"flex gap-3",children:dT.filter(A=>l.has(A.key)).map(A=>n.jsxs(E,{variant:d===A.key?"default":"outline",size:"sm",onClick:()=>u(A.key),className:"text-xs",children:[A.icon," ",n.jsx("span",{className:"ml-1",children:A.label})]},A.key))}),!d&&l.size>0&&n.jsx(W,{className:"border-dashed",children:n.jsx(U,{className:"p-8 text-center space-y-4",children:n.jsxs("div",{className:"grid grid-cols-2 gap-4 max-w-md mx-auto",children:[n.jsx(W,{className:"cursor-pointer hover:shadow-md transition-shadow border-2 hover:border-primary",onClick:()=>u(Array.from(l)[0]),children:n.jsxs(U,{className:"p-6 text-center",children:[n.jsx(Yn,{className:"h-8 w-8 mx-auto mb-2 text-primary"}),n.jsx("p",{className:"text-sm font-medium",children:"Start from Scratch"})]})}),n.jsx(W,{className:"cursor-pointer hover:shadow-md transition-shadow border-2 hover:border-primary",children:n.jsxs(U,{className:"p-6 text-center",children:[n.jsx(Ku,{className:"h-8 w-8 mx-auto mb-2 text-primary"}),n.jsx("p",{className:"text-sm font-medium",children:"Upload Exam"})]})})]})})}),d==="reading"&&D(),d==="listening"&&z(),d==="writing"&&O(),d==="speaking"&&V(),l.size>0&&d&&n.jsxs("div",{className:"flex flex-wrap gap-3 pt-4 border-t",children:[n.jsxs(E,{variant:"outline",disabled:_||!t,onClick:()=>S.mutate(!1),children:[S.isPending?n.jsx(Re,{className:"h-4 w-4 mr-2 animate-spin"}):n.jsx(gl,{className:"h-4 w-4 mr-2"}),"Submit module as exam for approval"]}),n.jsxs(E,{variant:"outline",disabled:_||!t,onClick:()=>S.mutate(!0),children:[n.jsx(eH,{className:"h-4 w-4 mr-2"})," Submit module as exam and skip approval"]}),n.jsxs(E,{variant:"outline",disabled:!0,children:[n.jsx(Uc,{className:"h-4 w-4 mr-2"})," Preview module"]})]})]})}const Que="Sample submission for AI grading suggestion. Replace by passing submissionText when integrating with real submissions.";function Yue({onAccept:e,submissionId:t=1,submissionText:r=Que,rubricId:s}){var d;const{toast:a}=He(),i=ae({mutationFn:()=>Ol.getGradingSuggestion({submission_text:r,skill:"writing"}),onError:u=>{a({variant:"destructive",title:"Could not load AI grade",description:u.message||"Try again later."})}});p.useEffect(()=>{i.mutate()},[t,r,s]);const o=i.data,l=o?Math.round(o.overall_band*100/9):0,c=o?[o.feedback,(d=o.suggestions)!=null&&d.length?`Suggestions: ${o.suggestions.map(u=>`• ${u}`).join(` `)}`:""].filter(Boolean).join(` `):"";return n.jsxs("div",{className:"rounded-lg border bg-muted/30 p-4 space-y-3",children:[n.jsxs("p",{className:"text-xs font-semibold text-primary flex items-center gap-1",children:[n.jsx(lt,{className:"h-3 w-3"})," AI Suggested Grade"]}),i.isPending?n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-2",children:[n.jsx(Re,{className:"h-4 w-4 animate-spin text-primary"})," Analyzing submission..."]}):i.isError?n.jsx("p",{className:"text-sm text-destructive",children:"Could not load a suggestion. Check the console or try again."}):o?n.jsxs(n.Fragment,{children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"Suggested marks"}),n.jsxs("p",{className:"text-2xl font-bold",children:[l,"/100"]})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Suggested feedback"}),n.jsx("p",{className:"text-sm whitespace-pre-wrap",children:c})]}),o.scores&&Object.keys(o.scores).length>0&&n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"Rubric scores"}),n.jsx("ul",{className:"text-xs text-muted-foreground space-y-0.5",children:Object.entries(o.scores).map(([u,f])=>n.jsxs("li",{children:[u,": ",f]},u))})]}),n.jsxs(E,{size:"sm",onClick:()=>e(l,c),children:[n.jsx(lt,{className:"h-3.5 w-3.5 mr-1"})," Accept AI Grade"]})]}):null]})}const Xue=[{id:1,name:"Exam Content Review",status:"In Progress",steps:[{name:"Initial Review",assignee:"Dr. Smith",status:"Approved"},{name:"Quality Check",assignee:"Prof. Lee",status:"Pending"},{name:"Final Approval",assignee:"Admin",status:"Waiting"}]},{id:2,name:"Rubric Approval",status:"Completed",steps:[{name:"Draft Review",assignee:"Mr. Kim",status:"Approved"},{name:"Academic Board",assignee:"Dr. Smith",status:"Approved"}]},{id:3,name:"New Exam Structure",status:"Rejected",steps:[{name:"Content Review",assignee:"Prof. Lee",status:"Approved"},{name:"Standards Check",assignee:"Dr. Smith",status:"Rejected"}]}],Zue=e=>e==="Approved"?n.jsx(Ff,{className:"h-4 w-4 text-success"}):e==="Rejected"?n.jsx(Bf,{className:"h-4 w-4 text-destructive"}):n.jsx(vd,{className:"h-4 w-4 text-warning"});function Jue(){const{toast:e}=He();return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Approval Workflows"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage multi-step approval processes for exam content."})]}),n.jsxs(Qe,{children:[n.jsx(cr,{asChild:!0,children:n.jsxs(E,{size:"sm",children:[n.jsx(mt,{className:"h-4 w-4 mr-1"})," Create Workflow"]})}),n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create Workflow"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Workflow Name"}),n.jsx(G,{placeholder:"e.g. Exam Content Review"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Step 1 — Assignee"}),n.jsxs(Oe,{children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select assignee"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"smith",children:"Dr. Smith"}),n.jsx(Y,{value:"lee",children:"Prof. Lee"}),n.jsx(Y,{value:"kim",children:"Mr. Kim"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Step 2 — Assignee"}),n.jsxs(Oe,{children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select assignee"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"smith",children:"Dr. Smith"}),n.jsx(Y,{value:"lee",children:"Prof. Lee"}),n.jsx(Y,{value:"admin",children:"Admin"})]})]})]}),n.jsx(E,{className:"w-full",children:"Create"})]})]})]})]}),n.jsx("div",{className:"space-y-4",children:Xue.map(t=>n.jsxs(W,{className:"border-0 shadow-sm",children:[n.jsx(se,{className:"pb-3",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(ie,{className:"text-base font-semibold",children:t.name}),n.jsx(oe,{variant:t.status==="Completed"?"default":t.status==="Rejected"?"destructive":"secondary",children:t.status})]})}),n.jsxs(U,{children:[n.jsx("div",{className:"flex items-center gap-2",children:t.steps.map((r,s)=>n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"flex items-center gap-2 rounded-lg border p-3 bg-muted/30 min-w-[160px]",children:[Zue(r.status),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:r.name}),n.jsx("p",{className:"text-xs text-muted-foreground",children:r.assignee})]})]}),s{e({title:"AI Grade Accepted",description:`Marks: ${r}/100 applied with AI feedback.`})}}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(E,{size:"sm",variant:"default",children:"Approve"}),n.jsx(E,{size:"sm",variant:"outline",children:"Reject"})]})]})]})]},t.id))})]})}function efe(){var v,g;const[e,t]=p.useState(""),[r,s]=p.useState(!1),[a,i]=p.useState({name:"",course_id:"",start_date:"",end_date:"",max_students:""}),{toast:o}=He(),l=je(),c=_o({size:200}),d=Er({size:200}),u=((v=c.data)==null?void 0:v.items)??[],f=((g=d.data)==null?void 0:g.items)??[],h=ae({mutationFn:b=>bn.createBatch(b),onSuccess:()=>{l.invalidateQueries({queryKey:["lms","batches"]}),s(!1),i({name:"",course_id:"",start_date:"",end_date:"",max_students:""}),o({title:"Classroom created"})},onError:b=>o({title:"Error",description:b.message,variant:"destructive"})}),m=ae({mutationFn:b=>bn.deleteBatch(b),onSuccess:()=>{l.invalidateQueries({queryKey:["lms","batches"]}),o({title:"Deleted"})},onError:b=>o({title:"Error",description:b.message,variant:"destructive"})}),y=e.toLowerCase(),x=u.filter(b=>{var N;return b.name.toLowerCase().includes(y)||((N=b.course_name)==null?void 0:N.toLowerCase().includes(y))}),j=c.isLoading;return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Classrooms"}),n.jsx("p",{className:"text-muted-foreground",children:"Create and manage batches (classrooms)."})]}),n.jsxs(E,{size:"sm",onClick:()=>s(!0),children:[n.jsx(mt,{className:"h-4 w-4 mr-1"})," Create Classroom"]})]}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search classrooms...",className:"pl-9",value:e,onChange:b=>t(b.target.value)})]}),j?n.jsx("div",{className:"flex items-center justify-center min-h-[300px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsx(W,{className:"border-0 shadow-sm",children:n.jsx(U,{className:"p-0",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Course"}),n.jsx(L,{children:"Students"}),n.jsx(L,{children:"Capacity"}),n.jsx(L,{children:"Dates"}),n.jsx(L,{children:"Status"}),n.jsx(L,{className:"w-10"})]})}),n.jsxs(Be,{children:[x.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:7,className:"text-center text-muted-foreground py-8",children:"No classrooms found."})}),x.map(b=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:b.name}),n.jsx(T,{children:b.course_name}),n.jsx(T,{children:n.jsxs(oe,{variant:"secondary",children:[n.jsx(as,{className:"h-3 w-3 mr-1"}),b.student_count]})}),n.jsx(T,{children:b.capacity}),n.jsxs(T,{className:"text-sm",children:[b.start_date," — ",b.end_date]}),n.jsx(T,{children:n.jsx(oe,{variant:b.status==="active"?"default":"secondary",className:"capitalize",children:b.status})}),n.jsx(T,{children:n.jsx(E,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>{window.confirm(`Delete "${b.name}"?`)&&m.mutate(b.id)},children:n.jsx($t,{className:"h-4 w-4"})})})]},b.id))]})]})})}),n.jsx(Qe,{open:r,onOpenChange:s,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create Classroom"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{value:a.name,onChange:b=>i(N=>({...N,name:b.target.value})),placeholder:"e.g. IELTS Prep Group A"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Course"}),n.jsxs(Oe,{value:a.course_id,onValueChange:b=>i(N=>({...N,course_id:b})),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select course"})}),n.jsx(Ee,{children:f.map(b=>n.jsx(Y,{value:String(b.id),children:b.title||b.code},b.id))})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Start Date"}),n.jsx(G,{type:"date",value:a.start_date,onChange:b=>i(N=>({...N,start_date:b.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"End Date"}),n.jsx(G,{type:"date",value:a.end_date,onChange:b=>i(N=>({...N,end_date:b.target.value}))})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Max Students"}),n.jsx(G,{type:"number",value:a.max_students,onChange:b=>i(N=>({...N,max_students:b.target.value})),placeholder:"30"})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),n.jsx(E,{disabled:h.isPending||!a.name,onClick:()=>h.mutate({name:a.name,course_id:Number(a.course_id)||void 0,start_date:a.start_date||void 0,end_date:a.end_date||void 0,capacity:Number(a.max_students)||void 0}),children:h.isPending?"Creating...":"Create"})]})]})})]})}function z2(){var o;const{toast:e}=He(),t=ae({mutationFn:()=>ox.suggest(),onError:l=>{e({variant:"destructive",title:"Could not load coach tips",description:l.message||"Try refreshing in a moment."})}});p.useEffect(()=>{t.mutate()},[]);const r=()=>{t.mutate()},s=t.data,a=s?[s.suggestion,...(s.focus_areas??[]).map(l=>`Focus area: ${l}`)].filter(Boolean):[],i=(o=s==null?void 0:s.daily_plan)!=null&&o.length?s.daily_plan.map(l=>`${l.activity} (${l.duration_min}min — ${l.skill})`):s!=null&&s.motivation?[s.motivation]:[];return n.jsxs(W,{className:"border-0 shadow-sm bg-primary/5",children:[n.jsx(se,{className:"pb-3",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(ie,{className:"text-base font-semibold flex items-center gap-2",children:[n.jsx(lt,{className:"h-4 w-4 text-primary"}),"Your AI Study Coach"]}),n.jsx(E,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:r,disabled:t.isPending,children:n.jsx(xk,{className:`h-4 w-4 ${t.isPending?"animate-spin":""}`})})]})}),n.jsx(U,{children:t.isPending&&!t.data?n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-4 justify-center",children:[n.jsx(Re,{className:"h-5 w-5 animate-spin text-primary"})," Analyzing your performance..."]}):n.jsxs(n.Fragment,{children:[a.length>0&&n.jsxs("div",{className:"mb-4",children:[n.jsxs("p",{className:"text-xs font-semibold text-primary mb-2 flex items-center gap-1",children:[n.jsx(KG,{className:"h-3.5 w-3.5"})," Suggestions"]}),n.jsx("ul",{className:"text-sm text-muted-foreground space-y-2 list-disc list-inside",children:a.map((l,c)=>n.jsx("li",{children:l},c))})]}),i.length>0&&n.jsxs("div",{children:[n.jsxs("p",{className:"text-xs font-semibold text-primary mb-2 flex items-center gap-1",children:[n.jsx(lt,{className:"h-3.5 w-3.5"})," Study plan tips"]}),n.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:i.map((l,c)=>n.jsx("div",{className:"rounded-lg border bg-card p-3 hover:shadow-sm transition-shadow",children:n.jsx("p",{className:"text-sm",children:l})},c))})]}),!t.isPending&&a.length===0&&i.length===0&&n.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No suggestions yet. Try refreshing."})]})})]})}function V2({studentName:e,scores:t}){var l;const[r,s]=p.useState(!1),{toast:a}=He(),i=ae({mutationFn:()=>ox.explain({score_data:t??{},student_context:`IELTS / course grades for student: ${e}. Summarize what the scores mean and what to focus on next.`}),onError:c=>{a({variant:"destructive",title:"Could not explain grades",description:c.message||"Try again in a moment."})}}),o=()=>{s(!0),i.reset(),i.mutate()};return n.jsxs(n.Fragment,{children:[n.jsx(E,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:o,title:"AI Explain Grade",children:n.jsx(lt,{className:"h-3.5 w-3.5 text-primary"})}),n.jsx(Qe,{open:r,onOpenChange:c=>{s(c),c||i.reset()},children:n.jsxs(Ue,{className:"max-w-md",children:[n.jsx(Ke,{children:n.jsxs(Ge,{className:"flex items-center gap-2",children:[n.jsx(lt,{className:"h-4 w-4 text-primary"}),"AI Grade Explanation — ",e]})}),i.isPending?n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-6 justify-center",children:[n.jsx(Re,{className:"h-5 w-5 animate-spin text-primary"})," Analyzing grades..."]}):i.isError?n.jsx("p",{className:"text-sm text-destructive text-center py-4",children:"Something went wrong. Close and try again."}):n.jsx("div",{className:"rounded-lg bg-muted/30 p-4",children:n.jsx("p",{className:"text-sm leading-relaxed",children:(l=i.data)==null?void 0:l.explanation})})]})})]})}const tfe=[{name:"Sarah Johnson",entity:"Acme Corp",reading:7.5,listening:8,writing:7,speaking:7.5,overall:7.5,level:"B2"},{name:"Ahmed Hassan",entity:"Global Ltd",reading:5.5,listening:6,writing:5,speaking:5.5,overall:5.5,level:"A2"},{name:"Maria Garcia",entity:"Acme Corp",reading:8.5,listening:8,writing:8,speaking:8.5,overall:8.25,level:"C1"},{name:"Li Wei",entity:"Tech Co",reading:6.5,listening:6,writing:6,speaking:6.5,overall:6.25,level:"B1"},{name:"Emma Brown",entity:"Acme Corp",reading:4.5,listening:5,writing:4,speaking:4.5,overall:4.5,level:"A1"},{name:"John Park",entity:"Global Ltd",reading:7,listening:7.5,writing:6.5,speaking:7,overall:7,level:"B2"}];function Rm({score:e}){const t=e>=7.5?"bg-success/10 text-success":e>=6?"bg-warning/10 text-warning":"bg-destructive/10 text-destructive";return n.jsx("span",{className:`inline-flex items-center rounded-md px-2 py-0.5 text-xs font-semibold ${t}`,children:e.toFixed(1)})}function nfe(){const[e,t]=p.useState(!1);return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Student Performance"}),n.jsx("p",{className:"text-muted-foreground",children:"Track student scores across all IELTS modules."})]}),n.jsx(z2,{}),n.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[n.jsxs(Oe,{children:[n.jsx(Ae,{className:"w-[160px]",children:n.jsx(Me,{placeholder:"All Entities"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"all",children:"All Entities"}),n.jsx(Y,{value:"acme",children:"Acme Corp"}),n.jsx(Y,{value:"global",children:"Global Ltd"})]})]}),n.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[n.jsx(Fr,{id:"util",checked:e,onCheckedChange:t}),n.jsx(q,{htmlFor:"util",className:"text-sm",children:"Show Utilisation"})]})]}),n.jsx(W,{className:"border-0 shadow-sm",children:n.jsx(U,{className:"p-0",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Student"}),n.jsx(L,{children:"Entity"}),n.jsx(L,{children:"Level"}),n.jsx(L,{className:"text-center",children:"Reading"}),n.jsx(L,{className:"text-center",children:"Listening"}),n.jsx(L,{className:"text-center",children:"Writing"}),n.jsx(L,{className:"text-center",children:"Speaking"}),n.jsx(L,{className:"text-center",children:"Overall"}),n.jsx(L,{className:"w-10",children:"AI"})]})}),n.jsx(Be,{children:tfe.map(r=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:r.name}),n.jsx(T,{children:r.entity}),n.jsx(T,{children:n.jsx(oe,{variant:"outline",children:r.level})}),n.jsx(T,{className:"text-center",children:n.jsx(Rm,{score:r.reading})}),n.jsx(T,{className:"text-center",children:n.jsx(Rm,{score:r.listening})}),n.jsx(T,{className:"text-center",children:n.jsx(Rm,{score:r.writing})}),n.jsx(T,{className:"text-center",children:n.jsx(Rm,{score:r.speaking})}),n.jsx(T,{className:"text-center",children:n.jsx(Rm,{score:r.overall})}),n.jsx(T,{children:n.jsx(V2,{studentName:r.name})})]},r.name))})]})})})]})}var rfe=Array.isArray,Ns=rfe,sfe=typeof Ix=="object"&&Ix&&Ix.Object===Object&&Ix,fz=sfe,afe=fz,ife=typeof self=="object"&&self&&self.Object===Object&&self,ofe=afe||ife||Function("return this")(),Ei=ofe,lfe=Ei,cfe=lfe.Symbol,yx=cfe,uT=yx,mz=Object.prototype,dfe=mz.hasOwnProperty,ufe=mz.toString,$m=uT?uT.toStringTag:void 0;function ffe(e){var t=dfe.call(e,$m),r=e[$m];try{e[$m]=void 0;var s=!0}catch{}var a=ufe.call(e);return s&&(t?e[$m]=r:delete e[$m]),a}var mfe=ffe,hfe=Object.prototype,pfe=hfe.toString;function xfe(e){return pfe.call(e)}var gfe=xfe,fT=yx,vfe=mfe,yfe=gfe,jfe="[object Null]",bfe="[object Undefined]",mT=fT?fT.toStringTag:void 0;function wfe(e){return e==null?e===void 0?bfe:jfe:mT&&mT in Object(e)?vfe(e):yfe(e)}var Co=wfe;function Nfe(e){return e!=null&&typeof e=="object"}var ko=Nfe,Sfe=Co,_fe=ko,Cfe="[object Symbol]";function kfe(e){return typeof e=="symbol"||_fe(e)&&Sfe(e)==Cfe}var nm=kfe,Pfe=Ns,Afe=nm,Efe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ofe=/^\w*$/;function Tfe(e,t){if(Pfe(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||Afe(e)?!0:Ofe.test(e)||!Efe.test(e)||t!=null&&e in Object(t)}var q2=Tfe;function Mfe(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Xl=Mfe;const rm=Gt(Xl);var Rfe=Co,$fe=Xl,Ife="[object AsyncFunction]",Dfe="[object Function]",Lfe="[object GeneratorFunction]",Ffe="[object Proxy]";function Bfe(e){if(!$fe(e))return!1;var t=Rfe(e);return t==Dfe||t==Lfe||t==Ife||t==Ffe}var W2=Bfe;const ft=Gt(W2);var zfe=Ei,Vfe=zfe["__core-js_shared__"],qfe=Vfe,Hw=qfe,hT=function(){var e=/[^.]+$/.exec(Hw&&Hw.keys&&Hw.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Wfe(e){return!!hT&&hT in e}var Ufe=Wfe,Kfe=Function.prototype,Gfe=Kfe.toString;function Hfe(e){if(e!=null){try{return Gfe.call(e)}catch{}try{return e+""}catch{}}return""}var hz=Hfe,Qfe=W2,Yfe=Ufe,Xfe=Xl,Zfe=hz,Jfe=/[\\^$.*+?()[\]{}|]/g,eme=/^\[object .+?Constructor\]$/,tme=Function.prototype,nme=Object.prototype,rme=tme.toString,sme=nme.hasOwnProperty,ame=RegExp("^"+rme.call(sme).replace(Jfe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ime(e){if(!Xfe(e)||Yfe(e))return!1;var t=Qfe(e)?ame:eme;return t.test(Zfe(e))}var ome=ime;function lme(e,t){return e==null?void 0:e[t]}var cme=lme,dme=ome,ume=cme;function fme(e,t){var r=ume(e,t);return dme(r)?r:void 0}var Sd=fme,mme=Sd,hme=mme(Object,"create"),$b=hme,pT=$b;function pme(){this.__data__=pT?pT(null):{},this.size=0}var xme=pme;function gme(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var vme=gme,yme=$b,jme="__lodash_hash_undefined__",bme=Object.prototype,wme=bme.hasOwnProperty;function Nme(e){var t=this.__data__;if(yme){var r=t[e];return r===jme?void 0:r}return wme.call(t,e)?t[e]:void 0}var Sme=Nme,_me=$b,Cme=Object.prototype,kme=Cme.hasOwnProperty;function Pme(e){var t=this.__data__;return _me?t[e]!==void 0:kme.call(t,e)}var Ame=Pme,Eme=$b,Ome="__lodash_hash_undefined__";function Tme(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Eme&&t===void 0?Ome:t,this}var Mme=Tme,Rme=xme,$me=vme,Ime=Sme,Dme=Ame,Lme=Mme;function sm(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t-1}var the=ehe,nhe=Ib;function rhe(e,t){var r=this.__data__,s=nhe(r,e);return s<0?(++this.size,r.push([e,t])):r[s][1]=t,this}var she=rhe,ahe=zme,ihe=Qme,ohe=Zme,lhe=the,che=she;function am(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t0?1:-1},Nc=function(t){return sd(t)&&t.indexOf("%")===t.length-1},Te=function(t){return Ape(t)&&!jx(t)},Mpe=function(t){return yt(t)},or=function(t){return Te(t)||sd(t)},Rpe=0,om=function(t){var r=++Rpe;return"".concat(t||"").concat(r)},Xr=function(t,r){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Te(t)&&!sd(t))return s;var i;if(Nc(t)){var o=t.indexOf("%");i=r*parseFloat(t.slice(0,o))/100}else i=+t;return jx(i)&&(i=s),a&&i>r&&(i=r),i},Qo=function(t){if(!t)return null;var r=Object.keys(t);return r&&r.length?t[r[0]]:null},$pe=function(t){if(!Array.isArray(t))return!1;for(var r=t.length,s={},a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function Vpe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function TS(e){"@babel/helpers - typeof";return TS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},TS(e)}var wT={click:"onClick",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",touchcancel:"onTouchCancel",touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart",contextmenu:"onContextMenu",dblclick:"onDoubleClick"},eo=function(t){return typeof t=="string"?t:t?t.displayName||t.name||"Component":""},NT=null,Yw=null,eP=function e(t){if(t===NT&&Array.isArray(Yw))return Yw;var r=[];return p.Children.forEach(t,function(s){yt(s)||(Spe.isFragment(s)?r=r.concat(e(s.props.children)):r.push(s))}),Yw=r,NT=t,r};function Ls(e,t){var r=[],s=[];return Array.isArray(t)?s=t.map(function(a){return eo(a)}):s=[eo(t)],eP(e).forEach(function(a){var i=Ds(a,"type.displayName")||Ds(a,"type.name");s.indexOf(i)!==-1&&r.push(a)}),r}function ks(e,t){var r=Ls(e,t);return r&&r[0]}var ST=function(t){if(!t||!t.props)return!1;var r=t.props,s=r.width,a=r.height;return!(!Te(s)||s<=0||!Te(a)||a<=0)},qpe=["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColormatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-url","foreignObject","g","glyph","glyphRef","hkern","image","line","lineGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"],Wpe=function(t){return t&&t.type&&sd(t.type)&&qpe.indexOf(t.type)>=0},Upe=function(t){return t&&TS(t)==="object"&&"clipDot"in t},Kpe=function(t,r,s,a){var i,o=(i=Qw==null?void 0:Qw[a])!==null&&i!==void 0?i:[];return r.startsWith("data-")||!ft(t)&&(a&&o.includes(r)||Lpe.includes(r))||s&&J2.includes(r)},st=function(t,r,s){if(!t||typeof t=="function"||typeof t=="boolean")return null;var a=t;if(p.isValidElement(t)&&(a=t.props),!rm(a))return null;var i={};return Object.keys(a).forEach(function(o){var l;Kpe((l=a)===null||l===void 0?void 0:l[o],o,r,s)&&(i[o]=a[o])}),i},MS=function e(t,r){if(t===r)return!0;var s=p.Children.count(t);if(s!==p.Children.count(r))return!1;if(s===0)return!0;if(s===1)return _T(Array.isArray(t)?t[0]:t,Array.isArray(r)?r[0]:r);for(var a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function Xpe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function $S(e){var t=e.children,r=e.width,s=e.height,a=e.viewBox,i=e.className,o=e.style,l=e.title,c=e.desc,d=Ype(e,Qpe),u=a||{width:r,height:s,x:0,y:0},f=gt("recharts-surface",i);return F.createElement("svg",RS({},st(d,!0,"svg"),{className:f,width:r,height:s,style:o,viewBox:"".concat(u.x," ").concat(u.y," ").concat(u.width," ").concat(u.height)}),F.createElement("title",null,l),F.createElement("desc",null,c),t)}var Zpe=["children","className"];function IS(){return IS=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function exe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}var Tt=F.forwardRef(function(e,t){var r=e.children,s=e.className,a=Jpe(e,Zpe),i=gt("recharts-layer",s);return F.createElement("g",IS({className:i},st(a,!0),{ref:t}),r)}),La=function(t,r){for(var s=arguments.length,a=new Array(s>2?s-2:0),i=2;ia?0:a+t),r=r>a?a:r,r<0&&(r+=a),a=t>r?0:r-t>>>0,t>>>=0;for(var i=Array(a);++s=s?e:rxe(e,t,r)}var axe=sxe,ixe="\\ud800-\\udfff",oxe="\\u0300-\\u036f",lxe="\\ufe20-\\ufe2f",cxe="\\u20d0-\\u20ff",dxe=oxe+lxe+cxe,uxe="\\ufe0e\\ufe0f",fxe="\\u200d",mxe=RegExp("["+fxe+ixe+dxe+uxe+"]");function hxe(e){return mxe.test(e)}var Sz=hxe;function pxe(e){return e.split("")}var xxe=pxe,_z="\\ud800-\\udfff",gxe="\\u0300-\\u036f",vxe="\\ufe20-\\ufe2f",yxe="\\u20d0-\\u20ff",jxe=gxe+vxe+yxe,bxe="\\ufe0e\\ufe0f",wxe="["+_z+"]",DS="["+jxe+"]",LS="\\ud83c[\\udffb-\\udfff]",Nxe="(?:"+DS+"|"+LS+")",Cz="[^"+_z+"]",kz="(?:\\ud83c[\\udde6-\\uddff]){2}",Pz="[\\ud800-\\udbff][\\udc00-\\udfff]",Sxe="\\u200d",Az=Nxe+"?",Ez="["+bxe+"]?",_xe="(?:"+Sxe+"(?:"+[Cz,kz,Pz].join("|")+")"+Ez+Az+")*",Cxe=Ez+Az+_xe,kxe="(?:"+[Cz+DS+"?",DS,kz,Pz,wxe].join("|")+")",Pxe=RegExp(LS+"(?="+LS+")|"+kxe+Cxe,"g");function Axe(e){return e.match(Pxe)||[]}var Exe=Axe,Oxe=xxe,Txe=Sz,Mxe=Exe;function Rxe(e){return Txe(e)?Mxe(e):Oxe(e)}var $xe=Rxe,Ixe=axe,Dxe=Sz,Lxe=$xe,Fxe=vz;function Bxe(e){return function(t){t=Fxe(t);var r=Dxe(t)?Lxe(t):void 0,s=r?r[0]:t.charAt(0),a=r?Ixe(r,1).join(""):t.slice(1);return s[e]()+a}}var zxe=Bxe,Vxe=zxe,qxe=Vxe("toUpperCase"),Wxe=qxe;const Yb=Gt(Wxe);function un(e){return function(){return e}}const Oz=Math.cos,Zv=Math.sin,Ya=Math.sqrt,Jv=Math.PI,Xb=2*Jv,FS=Math.PI,BS=2*FS,mc=1e-6,Uxe=BS-mc;function Tz(e){this._+=e[0];for(let t=1,r=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return Tz;const r=10**t;return function(s){this._+=s[0];for(let a=1,i=s.length;amc)if(!(Math.abs(f*c-d*u)>mc)||!i)this._append`L${this._x1=t},${this._y1=r}`;else{let m=s-o,y=a-l,x=c*c+d*d,j=m*m+y*y,v=Math.sqrt(x),g=Math.sqrt(h),b=i*Math.tan((FS-Math.acos((x+h-j)/(2*v*g)))/2),N=b/g,w=b/v;Math.abs(N-1)>mc&&this._append`L${t+N*u},${r+N*f}`,this._append`A${i},${i},0,0,${+(f*m>u*y)},${this._x1=t+w*c},${this._y1=r+w*d}`}}arc(t,r,s,a,i,o){if(t=+t,r=+r,s=+s,o=!!o,s<0)throw new Error(`negative radius: ${s}`);let l=s*Math.cos(a),c=s*Math.sin(a),d=t+l,u=r+c,f=1^o,h=o?a-i:i-a;this._x1===null?this._append`M${d},${u}`:(Math.abs(this._x1-d)>mc||Math.abs(this._y1-u)>mc)&&this._append`L${d},${u}`,s&&(h<0&&(h=h%BS+BS),h>Uxe?this._append`A${s},${s},0,1,${f},${t-l},${r-c}A${s},${s},0,1,${f},${this._x1=d},${this._y1=u}`:h>mc&&this._append`A${s},${s},0,${+(h>=FS)},${f},${this._x1=t+s*Math.cos(i)},${this._y1=r+s*Math.sin(i)}`)}rect(t,r,s,a){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+r}h${s=+s}v${+a}h${-s}Z`}toString(){return this._}}function tP(e){let t=3;return e.digits=function(r){if(!arguments.length)return t;if(r==null)t=null;else{const s=Math.floor(r);if(!(s>=0))throw new RangeError(`invalid digits: ${r}`);t=s}return e},()=>new Gxe(t)}function nP(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Mz(e){this._context=e}Mz.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function Zb(e){return new Mz(e)}function Rz(e){return e[0]}function $z(e){return e[1]}function Iz(e,t){var r=un(!0),s=null,a=Zb,i=null,o=tP(l);e=typeof e=="function"?e:e===void 0?Rz:un(e),t=typeof t=="function"?t:t===void 0?$z:un(t);function l(c){var d,u=(c=nP(c)).length,f,h=!1,m;for(s==null&&(i=a(m=o())),d=0;d<=u;++d)!(d=m;--y)l.point(b[y],N[y]);l.lineEnd(),l.areaEnd()}v&&(b[h]=+e(j,h,f),N[h]=+t(j,h,f),l.point(s?+s(j,h,f):b[h],r?+r(j,h,f):N[h]))}if(g)return l=null,g+""||null}function u(){return Iz().defined(a).curve(o).context(i)}return d.x=function(f){return arguments.length?(e=typeof f=="function"?f:un(+f),s=null,d):e},d.x0=function(f){return arguments.length?(e=typeof f=="function"?f:un(+f),d):e},d.x1=function(f){return arguments.length?(s=f==null?null:typeof f=="function"?f:un(+f),d):s},d.y=function(f){return arguments.length?(t=typeof f=="function"?f:un(+f),r=null,d):t},d.y0=function(f){return arguments.length?(t=typeof f=="function"?f:un(+f),d):t},d.y1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:un(+f),d):r},d.lineX0=d.lineY0=function(){return u().x(e).y(t)},d.lineY1=function(){return u().x(e).y(r)},d.lineX1=function(){return u().x(s).y(t)},d.defined=function(f){return arguments.length?(a=typeof f=="function"?f:un(!!f),d):a},d.curve=function(f){return arguments.length?(o=f,i!=null&&(l=o(i)),d):o},d.context=function(f){return arguments.length?(f==null?i=l=null:l=o(i=f),d):i},d}class Dz{constructor(t,r){this._context=t,this._x=r}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,r){switch(t=+t,r=+r,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,r):this._context.moveTo(t,r);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,r,t,r):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+r)/2,t,this._y0,t,r);break}}this._x0=t,this._y0=r}}function Hxe(e){return new Dz(e,!0)}function Qxe(e){return new Dz(e,!1)}const rP={draw(e,t){const r=Ya(t/Jv);e.moveTo(r,0),e.arc(0,0,r,0,Xb)}},Yxe={draw(e,t){const r=Ya(t/5)/2;e.moveTo(-3*r,-r),e.lineTo(-r,-r),e.lineTo(-r,-3*r),e.lineTo(r,-3*r),e.lineTo(r,-r),e.lineTo(3*r,-r),e.lineTo(3*r,r),e.lineTo(r,r),e.lineTo(r,3*r),e.lineTo(-r,3*r),e.lineTo(-r,r),e.lineTo(-3*r,r),e.closePath()}},Lz=Ya(1/3),Xxe=Lz*2,Zxe={draw(e,t){const r=Ya(t/Xxe),s=r*Lz;e.moveTo(0,-r),e.lineTo(s,0),e.lineTo(0,r),e.lineTo(-s,0),e.closePath()}},Jxe={draw(e,t){const r=Ya(t),s=-r/2;e.rect(s,s,r,r)}},ege=.8908130915292852,Fz=Zv(Jv/10)/Zv(7*Jv/10),tge=Zv(Xb/10)*Fz,nge=-Oz(Xb/10)*Fz,rge={draw(e,t){const r=Ya(t*ege),s=tge*r,a=nge*r;e.moveTo(0,-r),e.lineTo(s,a);for(let i=1;i<5;++i){const o=Xb*i/5,l=Oz(o),c=Zv(o);e.lineTo(c*r,-l*r),e.lineTo(l*s-c*a,c*s+l*a)}e.closePath()}},Xw=Ya(3),sge={draw(e,t){const r=-Ya(t/(Xw*3));e.moveTo(0,r*2),e.lineTo(-Xw*r,-r),e.lineTo(Xw*r,-r),e.closePath()}},Ks=-.5,Gs=Ya(3)/2,zS=1/Ya(12),age=(zS/2+1)*3,ige={draw(e,t){const r=Ya(t/age),s=r/2,a=r*zS,i=s,o=r*zS+r,l=-i,c=o;e.moveTo(s,a),e.lineTo(i,o),e.lineTo(l,c),e.lineTo(Ks*s-Gs*a,Gs*s+Ks*a),e.lineTo(Ks*i-Gs*o,Gs*i+Ks*o),e.lineTo(Ks*l-Gs*c,Gs*l+Ks*c),e.lineTo(Ks*s+Gs*a,Ks*a-Gs*s),e.lineTo(Ks*i+Gs*o,Ks*o-Gs*i),e.lineTo(Ks*l+Gs*c,Ks*c-Gs*l),e.closePath()}};function oge(e,t){let r=null,s=tP(a);e=typeof e=="function"?e:un(e||rP),t=typeof t=="function"?t:un(t===void 0?64:+t);function a(){let i;if(r||(r=i=s()),e.apply(this,arguments).draw(r,+t.apply(this,arguments)),i)return r=null,i+""||null}return a.type=function(i){return arguments.length?(e=typeof i=="function"?i:un(i),a):e},a.size=function(i){return arguments.length?(t=typeof i=="function"?i:un(+i),a):t},a.context=function(i){return arguments.length?(r=i??null,a):r},a}function ey(){}function ty(e,t,r){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+r)/6)}function Bz(e){this._context=e}Bz.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:ty(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:ty(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function lge(e){return new Bz(e)}function zz(e){this._context=e}zz.prototype={areaStart:ey,areaEnd:ey,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:ty(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function cge(e){return new zz(e)}function Vz(e){this._context=e}Vz.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var r=(this._x0+4*this._x1+e)/6,s=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(r,s):this._context.moveTo(r,s);break;case 3:this._point=4;default:ty(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function dge(e){return new Vz(e)}function qz(e){this._context=e}qz.prototype={areaStart:ey,areaEnd:ey,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function uge(e){return new qz(e)}function kT(e){return e<0?-1:1}function PT(e,t,r){var s=e._x1-e._x0,a=t-e._x1,i=(e._y1-e._y0)/(s||a<0&&-0),o=(r-e._y1)/(a||s<0&&-0),l=(i*a+o*s)/(s+a);return(kT(i)+kT(o))*Math.min(Math.abs(i),Math.abs(o),.5*Math.abs(l))||0}function AT(e,t){var r=e._x1-e._x0;return r?(3*(e._y1-e._y0)/r-t)/2:t}function Zw(e,t,r){var s=e._x0,a=e._y0,i=e._x1,o=e._y1,l=(i-s)/3;e._context.bezierCurveTo(s+l,a+l*t,i-l,o-l*r,i,o)}function ny(e){this._context=e}ny.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:Zw(this,this._t0,AT(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var r=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,Zw(this,AT(this,r=PT(this,e,t)),r);break;default:Zw(this,this._t0,r=PT(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=r}}};function Wz(e){this._context=new Uz(e)}(Wz.prototype=Object.create(ny.prototype)).point=function(e,t){ny.prototype.point.call(this,t,e)};function Uz(e){this._context=e}Uz.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,r,s,a,i){this._context.bezierCurveTo(t,e,s,r,i,a)}};function fge(e){return new ny(e)}function mge(e){return new Wz(e)}function Kz(e){this._context=e}Kz.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,r=e.length;if(r)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),r===2)this._context.lineTo(e[1],t[1]);else for(var s=ET(e),a=ET(t),i=0,o=1;o=0;--t)a[t]=(o[t]-a[t+1])/i[t];for(i[r-1]=(e[r]+a[r-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var r=this._x*(1-this._t)+e*this._t;this._context.lineTo(r,this._y),this._context.lineTo(r,t)}break}}this._x=e,this._y=t}};function pge(e){return new Jb(e,.5)}function xge(e){return new Jb(e,0)}function gge(e){return new Jb(e,1)}function af(e,t){if((o=e.length)>1)for(var r=1,s,a,i=e[t[0]],o,l=i.length;r=0;)r[t]=t;return r}function vge(e,t){return e[t]}function yge(e){const t=[];return t.key=e,t}function jge(){var e=un([]),t=VS,r=af,s=vge;function a(i){var o=Array.from(e.apply(this,arguments),yge),l,c=o.length,d=-1,u;for(const f of i)for(l=0,++d;l0){for(var r,s,a=0,i=e[0].length,o;a0){for(var r=0,s=e[t[0]],a,i=s.length;r0)||!((i=(a=e[t[0]]).length)>0))){for(var r=0,s=1,a,i,o;s=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function Age(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}var Gz={symbolCircle:rP,symbolCross:Yxe,symbolDiamond:Zxe,symbolSquare:Jxe,symbolStar:rge,symbolTriangle:sge,symbolWye:ige},Ege=Math.PI/180,Oge=function(t){var r="symbol".concat(Yb(t));return Gz[r]||rP},Tge=function(t,r,s){if(r==="area")return t;switch(s){case"cross":return 5*t*t/9;case"diamond":return .5*t*t/Math.sqrt(3);case"square":return t*t;case"star":{var a=18*Ege;return 1.25*t*t*(Math.tan(a)-Math.tan(a*2)*Math.pow(Math.tan(a),2))}case"triangle":return Math.sqrt(3)*t*t/4;case"wye":return(21-10*Math.sqrt(3))*t*t/8;default:return Math.PI*t*t/4}},Mge=function(t,r){Gz["symbol".concat(Yb(t))]=r},sP=function(t){var r=t.type,s=r===void 0?"circle":r,a=t.size,i=a===void 0?64:a,o=t.sizeType,l=o===void 0?"area":o,c=Pge(t,Sge),d=TT(TT({},c),{},{type:s,size:i,sizeType:l}),u=function(){var j=Oge(s),v=oge().type(j).size(Tge(i,l,s));return v()},f=d.className,h=d.cx,m=d.cy,y=st(d,!0);return h===+h&&m===+m&&i===+i?F.createElement("path",qS({},y,{className:gt("recharts-symbols",f),transform:"translate(".concat(h,", ").concat(m,")"),d:u()})):null};sP.registerSymbol=Mge;function of(e){"@babel/helpers - typeof";return of=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},of(e)}function WS(){return WS=Object.assign?Object.assign.bind():function(e){for(var t=1;t`);var g=m.inactive?d:m.color;return F.createElement("li",WS({className:j,style:f,key:"legend-item-".concat(y)},ad(s.props,m,y)),F.createElement($S,{width:o,height:o,viewBox:u,style:h},s.renderIcon(m)),F.createElement("span",{className:"recharts-legend-item-text",style:{color:g}},x?x(v,m,y):v))})}},{key:"render",value:function(){var s=this.props,a=s.payload,i=s.layout,o=s.align;if(!a||!a.length)return null;var l={padding:0,margin:0,textAlign:i==="horizontal"?o:"left"};return F.createElement("ul",{className:"recharts-default-legend",style:l},this.renderItems())}}])}(p.PureComponent);rp(aP,"displayName","Legend");rp(aP,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var qge=Db;function Wge(){this.__data__=new qge,this.size=0}var Uge=Wge;function Kge(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var Gge=Kge;function Hge(e){return this.__data__.get(e)}var Qge=Hge;function Yge(e){return this.__data__.has(e)}var Xge=Yge,Zge=Db,Jge=K2,eve=G2,tve=200;function nve(e,t){var r=this.__data__;if(r instanceof Zge){var s=r.__data__;if(!Jge||s.lengthl))return!1;var d=i.get(e),u=i.get(t);if(d&&u)return d==t&&u==e;var f=-1,h=!0,m=r&Sve?new jve:void 0;for(i.set(e,t),i.set(t,e);++f-1&&e%1==0&&e-1&&e%1==0&&e<=Pye}var cP=Aye,Eye=Co,Oye=cP,Tye=ko,Mye="[object Arguments]",Rye="[object Array]",$ye="[object Boolean]",Iye="[object Date]",Dye="[object Error]",Lye="[object Function]",Fye="[object Map]",Bye="[object Number]",zye="[object Object]",Vye="[object RegExp]",qye="[object Set]",Wye="[object String]",Uye="[object WeakMap]",Kye="[object ArrayBuffer]",Gye="[object DataView]",Hye="[object Float32Array]",Qye="[object Float64Array]",Yye="[object Int8Array]",Xye="[object Int16Array]",Zye="[object Int32Array]",Jye="[object Uint8Array]",eje="[object Uint8ClampedArray]",tje="[object Uint16Array]",nje="[object Uint32Array]",yn={};yn[Hye]=yn[Qye]=yn[Yye]=yn[Xye]=yn[Zye]=yn[Jye]=yn[eje]=yn[tje]=yn[nje]=!0;yn[Mye]=yn[Rye]=yn[Kye]=yn[$ye]=yn[Gye]=yn[Iye]=yn[Dye]=yn[Lye]=yn[Fye]=yn[Bye]=yn[zye]=yn[Vye]=yn[qye]=yn[Wye]=yn[Uye]=!1;function rje(e){return Tye(e)&&Oye(e.length)&&!!yn[Eye(e)]}var sje=rje;function aje(e){return function(t){return e(t)}}var sV=aje,iy={exports:{}};iy.exports;(function(e,t){var r=fz,s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===s,o=i&&r.process,l=function(){try{var c=a&&a.require&&a.require("util").types;return c||o&&o.binding&&o.binding("util")}catch{}}();e.exports=l})(iy,iy.exports);var ije=iy.exports,oje=sje,lje=sV,FT=ije,BT=FT&&FT.isTypedArray,cje=BT?lje(BT):oje,aV=cje,dje=mye,uje=oP,fje=Ns,mje=rV,hje=lP,pje=aV,xje=Object.prototype,gje=xje.hasOwnProperty;function vje(e,t){var r=fje(e),s=!r&&uje(e),a=!r&&!s&&mje(e),i=!r&&!s&&!a&&pje(e),o=r||s||a||i,l=o?dje(e.length,String):[],c=l.length;for(var d in e)(t||gje.call(e,d))&&!(o&&(d=="length"||a&&(d=="offset"||d=="parent")||i&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||hje(d,c)))&&l.push(d);return l}var yje=vje,jje=Object.prototype;function bje(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||jje;return e===r}var wje=bje;function Nje(e,t){return function(r){return e(t(r))}}var iV=Nje,Sje=iV,_je=Sje(Object.keys,Object),Cje=_je,kje=wje,Pje=Cje,Aje=Object.prototype,Eje=Aje.hasOwnProperty;function Oje(e){if(!kje(e))return Pje(e);var t=[];for(var r in Object(e))Eje.call(e,r)&&r!="constructor"&&t.push(r);return t}var Tje=Oje,Mje=W2,Rje=cP;function $je(e){return e!=null&&Rje(e.length)&&!Mje(e)}var bx=$je,Ije=yje,Dje=Tje,Lje=bx;function Fje(e){return Lje(e)?Ije(e):Dje(e)}var e0=Fje,Bje=tye,zje=uye,Vje=e0;function qje(e){return Bje(e,Vje,zje)}var Wje=qje,zT=Wje,Uje=1,Kje=Object.prototype,Gje=Kje.hasOwnProperty;function Hje(e,t,r,s,a,i){var o=r&Uje,l=zT(e),c=l.length,d=zT(t),u=d.length;if(c!=u&&!o)return!1;for(var f=c;f--;){var h=l[f];if(!(o?h in t:Gje.call(t,h)))return!1}var m=i.get(e),y=i.get(t);if(m&&y)return m==t&&y==e;var x=!0;i.set(e,t),i.set(t,e);for(var j=o;++f-1}var K0e=U0e;function G0e(e,t,r){for(var s=-1,a=e==null?0:e.length;++s=lwe){var d=t?null:iwe(e);if(d)return owe(d);o=!1,a=awe,c=new nwe}else c=t?[]:l;e:for(;++s=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function Swe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function _we(e){return e.value}function Cwe(e,t){if(F.isValidElement(e))return F.cloneElement(e,t);if(typeof e=="function")return F.createElement(e,t);t.ref;var r=Nwe(t,pwe);return F.createElement(aP,r)}var rM=1,Sl=function(e){function t(){var r;xwe(this,t);for(var s=arguments.length,a=new Array(s),i=0;irM||Math.abs(a.height-this.lastBoundingBox.height)>rM)&&(this.lastBoundingBox.width=a.width,this.lastBoundingBox.height=a.height,s&&s(a)):(this.lastBoundingBox.width!==-1||this.lastBoundingBox.height!==-1)&&(this.lastBoundingBox.width=-1,this.lastBoundingBox.height=-1,s&&s(null))}},{key:"getBBoxSnapshot",value:function(){return this.lastBoundingBox.width>=0&&this.lastBoundingBox.height>=0?Ii({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(s){var a=this.props,i=a.layout,o=a.align,l=a.verticalAlign,c=a.margin,d=a.chartWidth,u=a.chartHeight,f,h;if(!s||(s.left===void 0||s.left===null)&&(s.right===void 0||s.right===null))if(o==="center"&&i==="vertical"){var m=this.getBBoxSnapshot();f={left:((d||0)-m.width)/2}}else f=o==="right"?{right:c&&c.right||0}:{left:c&&c.left||0};if(!s||(s.top===void 0||s.top===null)&&(s.bottom===void 0||s.bottom===null))if(l==="middle"){var y=this.getBBoxSnapshot();h={top:((u||0)-y.height)/2}}else h=l==="bottom"?{bottom:c&&c.bottom||0}:{top:c&&c.top||0};return Ii(Ii({},f),h)}},{key:"render",value:function(){var s=this,a=this.props,i=a.content,o=a.width,l=a.height,c=a.wrapperStyle,d=a.payloadUniqBy,u=a.payload,f=Ii(Ii({position:"absolute",width:o||"auto",height:l||"auto"},this.getDefaultPosition(c)),c);return F.createElement("div",{className:"recharts-legend-wrapper",style:f,ref:function(m){s.wrapperNode=m}},Cwe(i,Ii(Ii({},this.props),{},{payload:mV(u,d,_we)})))}}],[{key:"getWithHeight",value:function(s,a){var i=Ii(Ii({},this.defaultProps),s.props),o=i.layout;return o==="vertical"&&Te(s.props.height)?{height:s.props.height}:o==="horizontal"?{width:s.props.width||a}:null}}])}(p.PureComponent);t0(Sl,"displayName","Legend");t0(Sl,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var sM=yx,kwe=oP,Pwe=Ns,aM=sM?sM.isConcatSpreadable:void 0;function Awe(e){return Pwe(e)||kwe(e)||!!(aM&&e&&e[aM])}var Ewe=Awe,Owe=tV,Twe=Ewe;function xV(e,t,r,s,a){var i=-1,o=e.length;for(r||(r=Twe),a||(a=[]);++i0&&r(l)?t>1?xV(l,t-1,r,s,a):Owe(a,l):s||(a[a.length]=l)}return a}var gV=xV;function Mwe(e){return function(t,r,s){for(var a=-1,i=Object(t),o=s(t),l=o.length;l--;){var c=o[e?l:++a];if(r(i[c],c,i)===!1)break}return t}}var Rwe=Mwe,$we=Rwe,Iwe=$we(),Dwe=Iwe,Lwe=Dwe,Fwe=e0;function Bwe(e,t){return e&&Lwe(e,t,Fwe)}var vV=Bwe,zwe=bx;function Vwe(e,t){return function(r,s){if(r==null)return r;if(!zwe(r))return e(r,s);for(var a=r.length,i=t?a:-1,o=Object(r);(t?i--:++it||i&&o&&c&&!l&&!d||s&&o&&c||!r&&c||!a)return 1;if(!s&&!i&&!d&&e=l)return c;var d=r[s];return c*(d=="desc"?-1:1)}}return e.index-t.index}var nNe=tNe,nN=Q2,rNe=Y2,sNe=Oi,aNe=yV,iNe=Xwe,oNe=sV,lNe=nNe,cNe=dm,dNe=Ns;function uNe(e,t,r){t.length?t=nN(t,function(i){return dNe(i)?function(o){return rNe(o,i.length===1?i[0]:i)}:i}):t=[cNe];var s=-1;t=nN(t,oNe(sNe));var a=aNe(e,function(i,o,l){var c=nN(t,function(d){return d(i)});return{criteria:c,index:++s,value:i}});return iNe(a,function(i,o){return lNe(i,o,r)})}var fNe=uNe;function mNe(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var hNe=mNe,pNe=hNe,oM=Math.max;function xNe(e,t,r){return t=oM(t===void 0?e.length-1:t,0),function(){for(var s=arguments,a=-1,i=oM(s.length-t,0),o=Array(i);++a0){if(++t>=CNe)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var ENe=ANe,ONe=_Ne,TNe=ENe,MNe=TNe(ONe),RNe=MNe,$Ne=dm,INe=gNe,DNe=RNe;function LNe(e,t){return DNe(INe(e,t,$Ne),e+"")}var FNe=LNe,BNe=U2,zNe=bx,VNe=lP,qNe=Xl;function WNe(e,t,r){if(!qNe(r))return!1;var s=typeof t;return(s=="number"?zNe(r)&&VNe(t,r.length):s=="string"&&t in r)?BNe(r[t],e):!1}var n0=WNe,UNe=gV,KNe=fNe,GNe=FNe,cM=n0,HNe=GNe(function(e,t){if(e==null)return[];var r=t.length;return r>1&&cM(e,t[0],t[1])?t=[]:r>2&&cM(t[0],t[1],t[2])&&(t=[t[0]]),KNe(e,UNe(t,1),[])}),QNe=HNe;const fP=Gt(QNe);function sp(e){"@babel/helpers - typeof";return sp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},sp(e)}function ZS(){return ZS=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,s=new Array(t);r=t.x),"".concat(Im,"-left"),Te(r)&&t&&Te(t.x)&&r=t.y),"".concat(Im,"-top"),Te(s)&&t&&Te(t.y)&&sx?Math.max(u,c[s]):Math.max(f,c[s])}function d1e(e){var t=e.translateX,r=e.translateY,s=e.useTranslate3d;return{transform:s?"translate3d(".concat(t,"px, ").concat(r,"px, 0)"):"translate(".concat(t,"px, ").concat(r,"px)")}}function u1e(e){var t=e.allowEscapeViewBox,r=e.coordinate,s=e.offsetTopLeft,a=e.position,i=e.reverseDirection,o=e.tooltipBox,l=e.useTranslate3d,c=e.viewBox,d,u,f;return o.height>0&&o.width>0&&r?(u=fM({allowEscapeViewBox:t,coordinate:r,key:"x",offsetTopLeft:s,position:a,reverseDirection:i,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),f=fM({allowEscapeViewBox:t,coordinate:r,key:"y",offsetTopLeft:s,position:a,reverseDirection:i,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),d=d1e({translateX:u,translateY:f,useTranslate3d:l})):d=l1e,{cssProperties:d,cssClasses:c1e({translateX:u,translateY:f,coordinate:r})}}function cf(e){"@babel/helpers - typeof";return cf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},cf(e)}function mM(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function hM(e){for(var t=1;tpM||Math.abs(s.height-this.state.lastBoundingBox.height)>pM)&&this.setState({lastBoundingBox:{width:s.width,height:s.height}})}else(this.state.lastBoundingBox.width!==-1||this.state.lastBoundingBox.height!==-1)&&this.setState({lastBoundingBox:{width:-1,height:-1}})}},{key:"componentDidMount",value:function(){document.addEventListener("keydown",this.handleKeyDown),this.updateBBox()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleKeyDown)}},{key:"componentDidUpdate",value:function(){var s,a;this.props.active&&this.updateBBox(),this.state.dismissed&&(((s=this.props.coordinate)===null||s===void 0?void 0:s.x)!==this.state.dismissedAtCoordinate.x||((a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}},{key:"render",value:function(){var s=this,a=this.props,i=a.active,o=a.allowEscapeViewBox,l=a.animationDuration,c=a.animationEasing,d=a.children,u=a.coordinate,f=a.hasPayload,h=a.isAnimationActive,m=a.offset,y=a.position,x=a.reverseDirection,j=a.useTranslate3d,v=a.viewBox,g=a.wrapperStyle,b=u1e({allowEscapeViewBox:o,coordinate:u,offsetTopLeft:m,position:y,reverseDirection:x,tooltipBox:this.state.lastBoundingBox,useTranslate3d:j,viewBox:v}),N=b.cssClasses,w=b.cssProperties,S=hM(hM({transition:h&&i?"transform ".concat(l,"ms ").concat(c):void 0},w),{},{pointerEvents:"none",visibility:!this.state.dismissed&&i&&f?"visible":"hidden",position:"absolute",top:0,left:0},g);return F.createElement("div",{tabIndex:-1,className:N,style:S,ref:function(C){s.wrapperNode=C}},d)}}])}(p.PureComponent),b1e=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},Zl={isSsr:b1e()};function df(e){"@babel/helpers - typeof";return df=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},df(e)}function xM(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function gM(e){for(var t=1;t0;return F.createElement(j1e,{allowEscapeViewBox:o,animationDuration:l,animationEasing:c,isAnimationActive:h,active:i,coordinate:u,hasPayload:S,offset:m,position:j,reverseDirection:v,useTranslate3d:g,viewBox:b,wrapperStyle:N},O1e(d,gM(gM({},this.props),{},{payload:w})))}}])}(p.PureComponent);mP(fn,"displayName","Tooltip");mP(fn,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!Zl.isSsr,itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,viewBox:{x:0,y:0,height:0,width:0},wrapperStyle:{}});var T1e=Ei,M1e=function(){return T1e.Date.now()},R1e=M1e,$1e=/\s/;function I1e(e){for(var t=e.length;t--&&$1e.test(e.charAt(t)););return t}var D1e=I1e,L1e=D1e,F1e=/^\s+/;function B1e(e){return e&&e.slice(0,L1e(e)+1).replace(F1e,"")}var z1e=B1e,V1e=z1e,vM=Xl,q1e=nm,yM=NaN,W1e=/^[-+]0x[0-9a-f]+$/i,U1e=/^0b[01]+$/i,K1e=/^0o[0-7]+$/i,G1e=parseInt;function H1e(e){if(typeof e=="number")return e;if(q1e(e))return yM;if(vM(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=vM(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=V1e(e);var r=U1e.test(e);return r||K1e.test(e)?G1e(e.slice(2),r?2:8):W1e.test(e)?yM:+e}var _V=H1e,Q1e=Xl,sN=R1e,jM=_V,Y1e="Expected a function",X1e=Math.max,Z1e=Math.min;function J1e(e,t,r){var s,a,i,o,l,c,d=0,u=!1,f=!1,h=!0;if(typeof e!="function")throw new TypeError(Y1e);t=jM(t)||0,Q1e(r)&&(u=!!r.leading,f="maxWait"in r,i=f?X1e(jM(r.maxWait)||0,t):i,h="trailing"in r?!!r.trailing:h);function m(S){var _=s,C=a;return s=a=void 0,d=S,o=e.apply(C,_),o}function y(S){return d=S,l=setTimeout(v,t),u?m(S):o}function x(S){var _=S-c,C=S-d,P=t-_;return f?Z1e(P,i-C):P}function j(S){var _=S-c,C=S-d;return c===void 0||_>=t||_<0||f&&C>=i}function v(){var S=sN();if(j(S))return g(S);l=setTimeout(v,x(S))}function g(S){return l=void 0,h&&s?m(S):(s=a=void 0,o)}function b(){l!==void 0&&clearTimeout(l),d=0,s=c=a=l=void 0}function N(){return l===void 0?o:g(sN())}function w(){var S=sN(),_=j(S);if(s=arguments,a=this,c=S,_){if(l===void 0)return y(c);if(f)return clearTimeout(l),l=setTimeout(v,t),m(c)}return l===void 0&&(l=setTimeout(v,t)),o}return w.cancel=b,w.flush=N,w}var eSe=J1e,tSe=eSe,nSe=Xl,rSe="Expected a function";function sSe(e,t,r){var s=!0,a=!0;if(typeof e!="function")throw new TypeError(rSe);return nSe(r)&&(s="leading"in r?!!r.leading:s,a="trailing"in r?!!r.trailing:a),tSe(e,t,{leading:s,maxWait:t,trailing:a})}var aSe=sSe;const CV=Gt(aSe);function ip(e){"@babel/helpers - typeof";return ip=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ip(e)}function bM(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function vg(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,s=new Array(t);r0&&(V=CV(V,x,{trailing:!0,leading:!1}));var A=new ResizeObserver(V),$=w.current.getBoundingClientRect(),B=$.width,I=$.height;return z(B,I),A.observe(w.current),function(){A.disconnect()}},[z,x]);var O=p.useMemo(function(){var V=P.containerWidth,A=P.containerHeight;if(V<0||A<0)return null;La(Nc(o)||Nc(c),`The width(%s) and height(%s) are both fixed numbers, maybe you don't need to use a ResponsiveContainer.`,o,c),La(!r||r>0,"The aspect(%s) must be greater than zero.",r);var $=Nc(o)?V:o,B=Nc(c)?A:c;r&&r>0&&($?B=$/r:B&&($=B*r),h&&B>h&&(B=h)),La($>0||B>0,`The width(%s) and height(%s) of chart should be greater than 0, please check the style of container, or the props width(%s) and height(%s), or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the height and width.`,$,B,o,c,u,f,r);var I=!Array.isArray(m)&&eo(m.type).endsWith("Chart");return F.Children.map(m,function(k){return F.isValidElement(k)?p.cloneElement(k,vg({width:$,height:B},I?{style:vg({height:"100%",width:"100%",maxHeight:B,maxWidth:$},k.props.style)}:{})):k})},[r,m,c,h,f,u,P,o]);return F.createElement("div",{id:j?"".concat(j):void 0,className:gt("recharts-responsive-container",v),style:vg(vg({},N),{},{width:o,height:c,minWidth:u,minHeight:f,maxHeight:h}),ref:w},O)}),_d=function(t){return null};_d.displayName="Cell";function op(e){"@babel/helpers - typeof";return op=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},op(e)}function NM(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function n_(e){for(var t=1;t1&&arguments[1]!==void 0?arguments[1]:{};if(t==null||Zl.isSsr)return{width:0,height:0};var s=ySe(r),a=JSON.stringify({text:t,copyStyle:s});if(zd.widthCache[a])return zd.widthCache[a];try{var i=document.getElementById(SM);i||(i=document.createElement("span"),i.setAttribute("id",SM),i.setAttribute("aria-hidden","true"),document.body.appendChild(i));var o=n_(n_({},vSe),s);Object.assign(i.style,o),i.textContent="".concat(t);var l=i.getBoundingClientRect(),c={width:l.width,height:l.height};return zd.widthCache[a]=c,++zd.cacheCount>gSe&&(zd.cacheCount=0,zd.widthCache={}),c}catch{return{width:0,height:0}}},jSe=function(t){return{top:t.top+window.scrollY-document.documentElement.clientTop,left:t.left+window.scrollX-document.documentElement.clientLeft}};function lp(e){"@babel/helpers - typeof";return lp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lp(e)}function dy(e,t){return SSe(e)||NSe(e,t)||wSe(e,t)||bSe()}function bSe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wSe(e,t){if(e){if(typeof e=="string")return _M(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _M(e,t)}}function _M(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function LSe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function OM(e,t){return VSe(e)||zSe(e,t)||BSe(e,t)||FSe()}function FSe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function BSe(e,t){if(e){if(typeof e=="string")return TM(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return TM(e,t)}}function TM(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r0&&arguments[0]!==void 0?arguments[0]:[];return $.reduce(function(B,I){var k=I.word,M=I.width,K=B[B.length-1];if(K&&(a==null||i||K.width+M+sI.width?B:I})};if(!u)return m;for(var x="…",j=function($){var B=f.slice(0,$),I=EV({breakAll:d,style:c,children:B+x}).wordsWithComputedWidth,k=h(I),M=k.length>o||y(k).width>Number(a);return[M,k]},v=0,g=f.length-1,b=0,N;v<=g&&b<=f.length-1;){var w=Math.floor((v+g)/2),S=w-1,_=j(S),C=OM(_,2),P=C[0],D=C[1],z=j(w),O=OM(z,1),V=O[0];if(!P&&!V&&(v=w+1),P&&V&&(g=w-1),!P&&V){N=D;break}b++}return N||m},MM=function(t){var r=yt(t)?[]:t.toString().split(AV);return[{words:r}]},WSe=function(t){var r=t.width,s=t.scaleToFit,a=t.children,i=t.style,o=t.breakAll,l=t.maxLines;if((r||s)&&!Zl.isSsr){var c,d,u=EV({breakAll:o,children:a,style:i});if(u){var f=u.wordsWithComputedWidth,h=u.spaceWidth;c=f,d=h}else return MM(a);return qSe({breakAll:o,children:a,maxLines:l,style:i},c,d,r,s)}return MM(a)},RM="#808080",od=function(t){var r=t.x,s=r===void 0?0:r,a=t.y,i=a===void 0?0:a,o=t.lineHeight,l=o===void 0?"1em":o,c=t.capHeight,d=c===void 0?"0.71em":c,u=t.scaleToFit,f=u===void 0?!1:u,h=t.textAnchor,m=h===void 0?"start":h,y=t.verticalAnchor,x=y===void 0?"end":y,j=t.fill,v=j===void 0?RM:j,g=EM(t,ISe),b=p.useMemo(function(){return WSe({breakAll:g.breakAll,children:g.children,maxLines:g.maxLines,scaleToFit:f,style:g.style,width:g.width})},[g.breakAll,g.children,g.maxLines,f,g.style,g.width]),N=g.dx,w=g.dy,S=g.angle,_=g.className,C=g.breakAll,P=EM(g,DSe);if(!or(s)||!or(i))return null;var D=s+(Te(N)?N:0),z=i+(Te(w)?w:0),O;switch(x){case"start":O=aN("calc(".concat(d,")"));break;case"middle":O=aN("calc(".concat((b.length-1)/2," * -").concat(l," + (").concat(d," / 2))"));break;default:O=aN("calc(".concat(b.length-1," * -").concat(l,")"));break}var V=[];if(f){var A=b[0].width,$=g.width;V.push("scale(".concat((Te($)?$/A:1)/A,")"))}return S&&V.push("rotate(".concat(S,", ").concat(D,", ").concat(z,")")),V.length&&(P.transform=V.join(" ")),F.createElement("text",r_({},st(P,!0),{x:D,y:z,className:gt("recharts-text",_),textAnchor:m,fill:v.includes("url")?RM:v}),b.map(function(B,I){var k=B.words.join(C?"":" ");return F.createElement("tspan",{x:D,dy:I===0?O:l,key:"".concat(k,"-").concat(I)},k)}))};function _l(e,t){return e==null||t==null?NaN:et?1:e>=t?0:NaN}function USe(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function hP(e){let t,r,s;e.length!==2?(t=_l,r=(l,c)=>_l(e(l),c),s=(l,c)=>e(l)-c):(t=e===_l||e===USe?e:KSe,r=e,s=e);function a(l,c,d=0,u=l.length){if(d>>1;r(l[f],c)<0?d=f+1:u=f}while(d>>1;r(l[f],c)<=0?d=f+1:u=f}while(dd&&s(l[f-1],c)>-s(l[f],c)?f-1:f}return{left:a,center:o,right:i}}function KSe(){return 0}function OV(e){return e===null?NaN:+e}function*GSe(e,t){for(let r of e)r!=null&&(r=+r)>=r&&(yield r)}const HSe=hP(_l),wx=HSe.right;hP(OV).center;class $M extends Map{constructor(t,r=XSe){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:r}}),t!=null)for(const[s,a]of t)this.set(s,a)}get(t){return super.get(IM(this,t))}has(t){return super.has(IM(this,t))}set(t,r){return super.set(QSe(this,t),r)}delete(t){return super.delete(YSe(this,t))}}function IM({_intern:e,_key:t},r){const s=t(r);return e.has(s)?e.get(s):r}function QSe({_intern:e,_key:t},r){const s=t(r);return e.has(s)?e.get(s):(e.set(s,r),r)}function YSe({_intern:e,_key:t},r){const s=t(r);return e.has(s)&&(r=e.get(s),e.delete(s)),r}function XSe(e){return e!==null&&typeof e=="object"?e.valueOf():e}function ZSe(e=_l){if(e===_l)return TV;if(typeof e!="function")throw new TypeError("compare is not a function");return(t,r)=>{const s=e(t,r);return s||s===0?s:(e(r,r)===0)-(e(t,t)===0)}}function TV(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et?1:0)}const JSe=Math.sqrt(50),e_e=Math.sqrt(10),t_e=Math.sqrt(2);function uy(e,t,r){const s=(t-e)/Math.max(0,r),a=Math.floor(Math.log10(s)),i=s/Math.pow(10,a),o=i>=JSe?10:i>=e_e?5:i>=t_e?2:1;let l,c,d;return a<0?(d=Math.pow(10,-a)/o,l=Math.round(e*d),c=Math.round(t*d),l/dt&&--c,d=-d):(d=Math.pow(10,a)*o,l=Math.round(e/d),c=Math.round(t/d),l*dt&&--c),c0))return[];if(e===t)return[e];const s=t=a))return[];const l=i-a+1,c=new Array(l);if(s)if(o<0)for(let d=0;d=s)&&(r=s);return r}function LM(e,t){let r;for(const s of e)s!=null&&(r>s||r===void 0&&s>=s)&&(r=s);return r}function MV(e,t,r=0,s=1/0,a){if(t=Math.floor(t),r=Math.floor(Math.max(0,r)),s=Math.floor(Math.min(e.length-1,s)),!(r<=t&&t<=s))return e;for(a=a===void 0?TV:ZSe(a);s>r;){if(s-r>600){const c=s-r+1,d=t-r+1,u=Math.log(c),f=.5*Math.exp(2*u/3),h=.5*Math.sqrt(u*f*(c-f)/c)*(d-c/2<0?-1:1),m=Math.max(r,Math.floor(t-d*f/c+h)),y=Math.min(s,Math.floor(t+(c-d)*f/c+h));MV(e,t,m,y,a)}const i=e[t];let o=r,l=s;for(Dm(e,r,t),a(e[s],i)>0&&Dm(e,r,s);o0;)--l}a(e[r],i)===0?Dm(e,r,l):(++l,Dm(e,l,s)),l<=t&&(r=l+1),t<=l&&(s=l-1)}return e}function Dm(e,t,r){const s=e[t];e[t]=e[r],e[r]=s}function n_e(e,t,r){if(e=Float64Array.from(GSe(e)),!(!(s=e.length)||isNaN(t=+t))){if(t<=0||s<2)return LM(e);if(t>=1)return DM(e);var s,a=(s-1)*t,i=Math.floor(a),o=DM(MV(e,i).subarray(0,i+1)),l=LM(e.subarray(i+1));return o+(l-o)*(a-i)}}function r_e(e,t,r=OV){if(!(!(s=e.length)||isNaN(t=+t))){if(t<=0||s<2)return+r(e[0],0,e);if(t>=1)return+r(e[s-1],s-1,e);var s,a=(s-1)*t,i=Math.floor(a),o=+r(e[i],i,e),l=+r(e[i+1],i+1,e);return o+(l-o)*(a-i)}}function s_e(e,t,r){e=+e,t=+t,r=(a=arguments.length)<2?(t=e,e=0,1):a<3?1:+r;for(var s=-1,a=Math.max(0,Math.ceil((t-e)/r))|0,i=new Array(a);++s>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?jg(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?jg(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=i_e.exec(e))?new ps(t[1],t[2],t[3],1):(t=o_e.exec(e))?new ps(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=l_e.exec(e))?jg(t[1],t[2],t[3],t[4]):(t=c_e.exec(e))?jg(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=d_e.exec(e))?UM(t[1],t[2]/100,t[3]/100,1):(t=u_e.exec(e))?UM(t[1],t[2]/100,t[3]/100,t[4]):FM.hasOwnProperty(e)?VM(FM[e]):e==="transparent"?new ps(NaN,NaN,NaN,0):null}function VM(e){return new ps(e>>16&255,e>>8&255,e&255,1)}function jg(e,t,r,s){return s<=0&&(e=t=r=NaN),new ps(e,t,r,s)}function h_e(e){return e instanceof Nx||(e=fp(e)),e?(e=e.rgb(),new ps(e.r,e.g,e.b,e.opacity)):new ps}function l_(e,t,r,s){return arguments.length===1?h_e(e):new ps(e,t,r,s??1)}function ps(e,t,r,s){this.r=+e,this.g=+t,this.b=+r,this.opacity=+s}xP(ps,l_,$V(Nx,{brighter(e){return e=e==null?fy:Math.pow(fy,e),new ps(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?dp:Math.pow(dp,e),new ps(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ps(Lc(this.r),Lc(this.g),Lc(this.b),my(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:qM,formatHex:qM,formatHex8:p_e,formatRgb:WM,toString:WM}));function qM(){return`#${Sc(this.r)}${Sc(this.g)}${Sc(this.b)}`}function p_e(){return`#${Sc(this.r)}${Sc(this.g)}${Sc(this.b)}${Sc((isNaN(this.opacity)?1:this.opacity)*255)}`}function WM(){const e=my(this.opacity);return`${e===1?"rgb(":"rgba("}${Lc(this.r)}, ${Lc(this.g)}, ${Lc(this.b)}${e===1?")":`, ${e})`}`}function my(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Lc(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Sc(e){return e=Lc(e),(e<16?"0":"")+e.toString(16)}function UM(e,t,r,s){return s<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new Ma(e,t,r,s)}function IV(e){if(e instanceof Ma)return new Ma(e.h,e.s,e.l,e.opacity);if(e instanceof Nx||(e=fp(e)),!e)return new Ma;if(e instanceof Ma)return e;e=e.rgb();var t=e.r/255,r=e.g/255,s=e.b/255,a=Math.min(t,r,s),i=Math.max(t,r,s),o=NaN,l=i-a,c=(i+a)/2;return l?(t===i?o=(r-s)/l+(r0&&c<1?0:o,new Ma(o,l,c,e.opacity)}function x_e(e,t,r,s){return arguments.length===1?IV(e):new Ma(e,t,r,s??1)}function Ma(e,t,r,s){this.h=+e,this.s=+t,this.l=+r,this.opacity=+s}xP(Ma,x_e,$V(Nx,{brighter(e){return e=e==null?fy:Math.pow(fy,e),new Ma(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?dp:Math.pow(dp,e),new Ma(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,s=r+(r<.5?r:1-r)*t,a=2*r-s;return new ps(iN(e>=240?e-240:e+120,a,s),iN(e,a,s),iN(e<120?e+240:e-120,a,s),this.opacity)},clamp(){return new Ma(KM(this.h),bg(this.s),bg(this.l),my(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=my(this.opacity);return`${e===1?"hsl(":"hsla("}${KM(this.h)}, ${bg(this.s)*100}%, ${bg(this.l)*100}%${e===1?")":`, ${e})`}`}}));function KM(e){return e=(e||0)%360,e<0?e+360:e}function bg(e){return Math.max(0,Math.min(1,e||0))}function iN(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}const gP=e=>()=>e;function g_e(e,t){return function(r){return e+r*t}}function v_e(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(s){return Math.pow(e+s*t,r)}}function y_e(e){return(e=+e)==1?DV:function(t,r){return r-t?v_e(t,r,e):gP(isNaN(t)?r:t)}}function DV(e,t){var r=t-e;return r?g_e(e,r):gP(isNaN(e)?t:e)}const GM=function e(t){var r=y_e(t);function s(a,i){var o=r((a=l_(a)).r,(i=l_(i)).r),l=r(a.g,i.g),c=r(a.b,i.b),d=DV(a.opacity,i.opacity);return function(u){return a.r=o(u),a.g=l(u),a.b=c(u),a.opacity=d(u),a+""}}return s.gamma=e,s}(1);function j_e(e,t){t||(t=[]);var r=e?Math.min(t.length,e.length):0,s=t.slice(),a;return function(i){for(a=0;ar&&(i=t.slice(r,i),l[o]?l[o]+=i:l[++o]=i),(s=s[0])===(a=a[0])?l[o]?l[o]+=a:l[++o]=a:(l[++o]=null,c.push({i:o,x:hy(s,a)})),r=oN.lastIndex;return rt&&(r=e,e=t,t=r),function(s){return Math.max(e,Math.min(t,s))}}function O_e(e,t,r){var s=e[0],a=e[1],i=t[0],o=t[1];return a2?T_e:O_e,c=d=null,f}function f(h){return h==null||isNaN(h=+h)?i:(c||(c=l(e.map(s),t,r)))(s(o(h)))}return f.invert=function(h){return o(a((d||(d=l(t,e.map(s),hy)))(h)))},f.domain=function(h){return arguments.length?(e=Array.from(h,py),u()):e.slice()},f.range=function(h){return arguments.length?(t=Array.from(h),u()):t.slice()},f.rangeRound=function(h){return t=Array.from(h),r=vP,u()},f.clamp=function(h){return arguments.length?(o=h?!0:Zr,u()):o!==Zr},f.interpolate=function(h){return arguments.length?(r=h,u()):r},f.unknown=function(h){return arguments.length?(i=h,f):i},function(h,m){return s=h,a=m,u()}}function yP(){return r0()(Zr,Zr)}function M_e(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function xy(e,t){if(!isFinite(e)||e===0)return null;var r=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"),s=e.slice(0,r);return[s.length>1?s[0]+s.slice(2):s,+e.slice(r+1)]}function uf(e){return e=xy(Math.abs(e)),e?e[1]:NaN}function R_e(e,t){return function(r,s){for(var a=r.length,i=[],o=0,l=e[0],c=0;a>0&&l>0&&(c+l+1>s&&(l=Math.max(1,s-c)),i.push(r.substring(a-=l,a+l)),!((c+=l+1)>s));)l=e[o=(o+1)%e.length];return i.reverse().join(t)}}function $_e(e){return function(t){return t.replace(/[0-9]/g,function(r){return e[+r]})}}var I_e=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function mp(e){if(!(t=I_e.exec(e)))throw new Error("invalid format: "+e);var t;return new jP({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}mp.prototype=jP.prototype;function jP(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}jP.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function D_e(e){e:for(var t=e.length,r=1,s=-1,a;r0&&(s=0);break}return s>0?e.slice(0,s)+e.slice(a+1):e}var gy;function L_e(e,t){var r=xy(e,t);if(!r)return gy=void 0,e.toPrecision(t);var s=r[0],a=r[1],i=a-(gy=Math.max(-8,Math.min(8,Math.floor(a/3)))*3)+1,o=s.length;return i===o?s:i>o?s+new Array(i-o+1).join("0"):i>0?s.slice(0,i)+"."+s.slice(i):"0."+new Array(1-i).join("0")+xy(e,Math.max(0,t+i-1))[0]}function QM(e,t){var r=xy(e,t);if(!r)return e+"";var s=r[0],a=r[1];return a<0?"0."+new Array(-a).join("0")+s:s.length>a+1?s.slice(0,a+1)+"."+s.slice(a+1):s+new Array(a-s.length+2).join("0")}const YM={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:M_e,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>QM(e*100,t),r:QM,s:L_e,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function XM(e){return e}var ZM=Array.prototype.map,JM=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function F_e(e){var t=e.grouping===void 0||e.thousands===void 0?XM:R_e(ZM.call(e.grouping,Number),e.thousands+""),r=e.currency===void 0?"":e.currency[0]+"",s=e.currency===void 0?"":e.currency[1]+"",a=e.decimal===void 0?".":e.decimal+"",i=e.numerals===void 0?XM:$_e(ZM.call(e.numerals,String)),o=e.percent===void 0?"%":e.percent+"",l=e.minus===void 0?"−":e.minus+"",c=e.nan===void 0?"NaN":e.nan+"";function d(f,h){f=mp(f);var m=f.fill,y=f.align,x=f.sign,j=f.symbol,v=f.zero,g=f.width,b=f.comma,N=f.precision,w=f.trim,S=f.type;S==="n"?(b=!0,S="g"):YM[S]||(N===void 0&&(N=12),w=!0,S="g"),(v||m==="0"&&y==="=")&&(v=!0,m="0",y="=");var _=(h&&h.prefix!==void 0?h.prefix:"")+(j==="$"?r:j==="#"&&/[boxX]/.test(S)?"0"+S.toLowerCase():""),C=(j==="$"?s:/[%p]/.test(S)?o:"")+(h&&h.suffix!==void 0?h.suffix:""),P=YM[S],D=/[defgprs%]/.test(S);N=N===void 0?6:/[gprs]/.test(S)?Math.max(1,Math.min(21,N)):Math.max(0,Math.min(20,N));function z(O){var V=_,A=C,$,B,I;if(S==="c")A=P(O)+A,O="";else{O=+O;var k=O<0||1/O<0;if(O=isNaN(O)?c:P(Math.abs(O),N),w&&(O=D_e(O)),k&&+O==0&&x!=="+"&&(k=!1),V=(k?x==="("?x:l:x==="-"||x==="("?"":x)+V,A=(S==="s"&&!isNaN(O)&&gy!==void 0?JM[8+gy/3]:"")+A+(k&&x==="("?")":""),D){for($=-1,B=O.length;++$I||I>57){A=(I===46?a+O.slice($+1):O.slice($))+A,O=O.slice(0,$);break}}}b&&!v&&(O=t(O,1/0));var M=V.length+O.length+A.length,K=M>1)+V+O+A+K.slice(M);break;default:O=K+V+O+A;break}return i(O)}return z.toString=function(){return f+""},z}function u(f,h){var m=Math.max(-8,Math.min(8,Math.floor(uf(h)/3)))*3,y=Math.pow(10,-m),x=d((f=mp(f),f.type="f",f),{suffix:JM[8+m/3]});return function(j){return x(y*j)}}return{format:d,formatPrefix:u}}var wg,bP,LV;B_e({thousands:",",grouping:[3],currency:["$",""]});function B_e(e){return wg=F_e(e),bP=wg.format,LV=wg.formatPrefix,wg}function z_e(e){return Math.max(0,-uf(Math.abs(e)))}function V_e(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(uf(t)/3)))*3-uf(Math.abs(e)))}function q_e(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,uf(t)-uf(e))+1}function FV(e,t,r,s){var a=i_(e,t,r),i;switch(s=mp(s??",f"),s.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(t));return s.precision==null&&!isNaN(i=V_e(a,o))&&(s.precision=i),LV(s,o)}case"":case"e":case"g":case"p":case"r":{s.precision==null&&!isNaN(i=q_e(a,Math.max(Math.abs(e),Math.abs(t))))&&(s.precision=i-(s.type==="e"));break}case"f":case"%":{s.precision==null&&!isNaN(i=z_e(a))&&(s.precision=i-(s.type==="%")*2);break}}return bP(s)}function Jl(e){var t=e.domain;return e.ticks=function(r){var s=t();return s_(s[0],s[s.length-1],r??10)},e.tickFormat=function(r,s){var a=t();return FV(a[0],a[a.length-1],r??10,s)},e.nice=function(r){r==null&&(r=10);var s=t(),a=0,i=s.length-1,o=s[a],l=s[i],c,d,u=10;for(l0;){if(d=a_(o,l,r),d===c)return s[a]=o,s[i]=l,t(s);if(d>0)o=Math.floor(o/d)*d,l=Math.ceil(l/d)*d;else if(d<0)o=Math.ceil(o*d)/d,l=Math.floor(l*d)/d;else break;c=d}return e},e}function vy(){var e=yP();return e.copy=function(){return Sx(e,vy())},ha.apply(e,arguments),Jl(e)}function BV(e){var t;function r(s){return s==null||isNaN(s=+s)?t:s}return r.invert=r,r.domain=r.range=function(s){return arguments.length?(e=Array.from(s,py),r):e.slice()},r.unknown=function(s){return arguments.length?(t=s,r):t},r.copy=function(){return BV(e).unknown(t)},e=arguments.length?Array.from(e,py):[0,1],Jl(r)}function zV(e,t){e=e.slice();var r=0,s=e.length-1,a=e[r],i=e[s],o;return iMath.pow(e,t)}function H_e(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function n4(e){return(t,r)=>-e(-t,r)}function wP(e){const t=e(e4,t4),r=t.domain;let s=10,a,i;function o(){return a=H_e(s),i=G_e(s),r()[0]<0?(a=n4(a),i=n4(i),e(W_e,U_e)):e(e4,t4),t}return t.base=function(l){return arguments.length?(s=+l,o()):s},t.domain=function(l){return arguments.length?(r(l),o()):r()},t.ticks=l=>{const c=r();let d=c[0],u=c[c.length-1];const f=u0){for(;h<=m;++h)for(y=1;yu)break;v.push(x)}}else for(;h<=m;++h)for(y=s-1;y>=1;--y)if(x=h>0?y/i(-h):y*i(h),!(xu)break;v.push(x)}v.length*2{if(l==null&&(l=10),c==null&&(c=s===10?"s":","),typeof c!="function"&&(!(s%1)&&(c=mp(c)).precision==null&&(c.trim=!0),c=bP(c)),l===1/0)return c;const d=Math.max(1,s*l/t.ticks().length);return u=>{let f=u/i(Math.round(a(u)));return f*sr(zV(r(),{floor:l=>i(Math.floor(a(l))),ceil:l=>i(Math.ceil(a(l)))})),t}function VV(){const e=wP(r0()).domain([1,10]);return e.copy=()=>Sx(e,VV()).base(e.base()),ha.apply(e,arguments),e}function r4(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function s4(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function NP(e){var t=1,r=e(r4(t),s4(t));return r.constant=function(s){return arguments.length?e(r4(t=+s),s4(t)):t},Jl(r)}function qV(){var e=NP(r0());return e.copy=function(){return Sx(e,qV()).constant(e.constant())},ha.apply(e,arguments)}function a4(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function Q_e(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function Y_e(e){return e<0?-e*e:e*e}function SP(e){var t=e(Zr,Zr),r=1;function s(){return r===1?e(Zr,Zr):r===.5?e(Q_e,Y_e):e(a4(r),a4(1/r))}return t.exponent=function(a){return arguments.length?(r=+a,s()):r},Jl(t)}function _P(){var e=SP(r0());return e.copy=function(){return Sx(e,_P()).exponent(e.exponent())},ha.apply(e,arguments),e}function X_e(){return _P.apply(null,arguments).exponent(.5)}function i4(e){return Math.sign(e)*e*e}function Z_e(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function WV(){var e=yP(),t=[0,1],r=!1,s;function a(i){var o=Z_e(e(i));return isNaN(o)?s:r?Math.round(o):o}return a.invert=function(i){return e.invert(i4(i))},a.domain=function(i){return arguments.length?(e.domain(i),a):e.domain()},a.range=function(i){return arguments.length?(e.range((t=Array.from(i,py)).map(i4)),a):t.slice()},a.rangeRound=function(i){return a.range(i).round(!0)},a.round=function(i){return arguments.length?(r=!!i,a):r},a.clamp=function(i){return arguments.length?(e.clamp(i),a):e.clamp()},a.unknown=function(i){return arguments.length?(s=i,a):s},a.copy=function(){return WV(e.domain(),t).round(r).clamp(e.clamp()).unknown(s)},ha.apply(a,arguments),Jl(a)}function UV(){var e=[],t=[],r=[],s;function a(){var o=0,l=Math.max(1,t.length);for(r=new Array(l-1);++o0?r[l-1]:e[0],l=r?[s[r-1],t]:[s[d-1],s[d]]},o.unknown=function(c){return arguments.length&&(i=c),o},o.thresholds=function(){return s.slice()},o.copy=function(){return KV().domain([e,t]).range(a).unknown(i)},ha.apply(Jl(o),arguments)}function GV(){var e=[.5],t=[0,1],r,s=1;function a(i){return i!=null&&i<=i?t[wx(e,i,0,s)]:r}return a.domain=function(i){return arguments.length?(e=Array.from(i),s=Math.min(e.length,t.length-1),a):e.slice()},a.range=function(i){return arguments.length?(t=Array.from(i),s=Math.min(e.length,t.length-1),a):t.slice()},a.invertExtent=function(i){var o=t.indexOf(i);return[e[o-1],e[o]]},a.unknown=function(i){return arguments.length?(r=i,a):r},a.copy=function(){return GV().domain(e).range(t).unknown(r)},ha.apply(a,arguments)}const lN=new Date,cN=new Date;function dr(e,t,r,s){function a(i){return e(i=arguments.length===0?new Date:new Date(+i)),i}return a.floor=i=>(e(i=new Date(+i)),i),a.ceil=i=>(e(i=new Date(i-1)),t(i,1),e(i),i),a.round=i=>{const o=a(i),l=a.ceil(i);return i-o(t(i=new Date(+i),o==null?1:Math.floor(o)),i),a.range=(i,o,l)=>{const c=[];if(i=a.ceil(i),l=l==null?1:Math.floor(l),!(i0))return c;let d;do c.push(d=new Date(+i)),t(i,l),e(i);while(ddr(o=>{if(o>=o)for(;e(o),!i(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;t(o,-1),!i(o););else for(;--l>=0;)for(;t(o,1),!i(o););}),r&&(a.count=(i,o)=>(lN.setTime(+i),cN.setTime(+o),e(lN),e(cN),Math.floor(r(lN,cN))),a.every=i=>(i=Math.floor(i),!isFinite(i)||!(i>0)?null:i>1?a.filter(s?o=>s(o)%i===0:o=>a.count(0,o)%i===0):a)),a}const yy=dr(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);yy.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?dr(t=>{t.setTime(Math.floor(t/e)*e)},(t,r)=>{t.setTime(+t+r*e)},(t,r)=>(r-t)/e):yy);yy.range;const Qi=1e3,ra=Qi*60,Yi=ra*60,ho=Yi*24,CP=ho*7,o4=ho*30,dN=ho*365,_c=dr(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*Qi)},(e,t)=>(t-e)/Qi,e=>e.getUTCSeconds());_c.range;const kP=dr(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Qi)},(e,t)=>{e.setTime(+e+t*ra)},(e,t)=>(t-e)/ra,e=>e.getMinutes());kP.range;const PP=dr(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*ra)},(e,t)=>(t-e)/ra,e=>e.getUTCMinutes());PP.range;const AP=dr(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Qi-e.getMinutes()*ra)},(e,t)=>{e.setTime(+e+t*Yi)},(e,t)=>(t-e)/Yi,e=>e.getHours());AP.range;const EP=dr(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*Yi)},(e,t)=>(t-e)/Yi,e=>e.getUTCHours());EP.range;const _x=dr(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*ra)/ho,e=>e.getDate()-1);_x.range;const s0=dr(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/ho,e=>e.getUTCDate()-1);s0.range;const HV=dr(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/ho,e=>Math.floor(e/ho));HV.range;function Cd(e){return dr(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,r)=>{t.setDate(t.getDate()+r*7)},(t,r)=>(r-t-(r.getTimezoneOffset()-t.getTimezoneOffset())*ra)/CP)}const a0=Cd(0),jy=Cd(1),J_e=Cd(2),eCe=Cd(3),ff=Cd(4),tCe=Cd(5),nCe=Cd(6);a0.range;jy.range;J_e.range;eCe.range;ff.range;tCe.range;nCe.range;function kd(e){return dr(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,r)=>{t.setUTCDate(t.getUTCDate()+r*7)},(t,r)=>(r-t)/CP)}const i0=kd(0),by=kd(1),rCe=kd(2),sCe=kd(3),mf=kd(4),aCe=kd(5),iCe=kd(6);i0.range;by.range;rCe.range;sCe.range;mf.range;aCe.range;iCe.range;const OP=dr(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());OP.range;const TP=dr(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());TP.range;const po=dr(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());po.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:dr(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,r)=>{t.setFullYear(t.getFullYear()+r*e)});po.range;const xo=dr(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());xo.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:dr(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,r)=>{t.setUTCFullYear(t.getUTCFullYear()+r*e)});xo.range;function QV(e,t,r,s,a,i){const o=[[_c,1,Qi],[_c,5,5*Qi],[_c,15,15*Qi],[_c,30,30*Qi],[i,1,ra],[i,5,5*ra],[i,15,15*ra],[i,30,30*ra],[a,1,Yi],[a,3,3*Yi],[a,6,6*Yi],[a,12,12*Yi],[s,1,ho],[s,2,2*ho],[r,1,CP],[t,1,o4],[t,3,3*o4],[e,1,dN]];function l(d,u,f){const h=uj).right(o,h);if(m===o.length)return e.every(i_(d/dN,u/dN,f));if(m===0)return yy.every(Math.max(i_(d,u,f),1));const[y,x]=o[h/o[m-1][2]53)return null;"w"in le||(le.w=1),"Z"in le?(Se=fN(Lm(le.y,0,1)),Ve=Se.getUTCDay(),Se=Ve>4||Ve===0?by.ceil(Se):by(Se),Se=s0.offset(Se,(le.V-1)*7),le.y=Se.getUTCFullYear(),le.m=Se.getUTCMonth(),le.d=Se.getUTCDate()+(le.w+6)%7):(Se=uN(Lm(le.y,0,1)),Ve=Se.getDay(),Se=Ve>4||Ve===0?jy.ceil(Se):jy(Se),Se=_x.offset(Se,(le.V-1)*7),le.y=Se.getFullYear(),le.m=Se.getMonth(),le.d=Se.getDate()+(le.w+6)%7)}else("W"in le||"U"in le)&&("w"in le||(le.w="u"in le?le.u%7:"W"in le?1:0),Ve="Z"in le?fN(Lm(le.y,0,1)).getUTCDay():uN(Lm(le.y,0,1)).getDay(),le.m=0,le.d="W"in le?(le.w+6)%7+le.W*7-(Ve+5)%7:le.w+le.U*7-(Ve+6)%7);return"Z"in le?(le.H+=le.Z/100|0,le.M+=le.Z%100,fN(le)):uN(le)}}function C(ue,we,ve,le){for(var ut=0,Se=we.length,Ve=ve.length,pt,Pt;ut=Ve)return-1;if(pt=we.charCodeAt(ut++),pt===37){if(pt=we.charAt(ut++),Pt=w[pt in l4?we.charAt(ut++):pt],!Pt||(le=Pt(ue,ve,le))<0)return-1}else if(pt!=ve.charCodeAt(le++))return-1}return le}function P(ue,we,ve){var le=d.exec(we.slice(ve));return le?(ue.p=u.get(le[0].toLowerCase()),ve+le[0].length):-1}function D(ue,we,ve){var le=m.exec(we.slice(ve));return le?(ue.w=y.get(le[0].toLowerCase()),ve+le[0].length):-1}function z(ue,we,ve){var le=f.exec(we.slice(ve));return le?(ue.w=h.get(le[0].toLowerCase()),ve+le[0].length):-1}function O(ue,we,ve){var le=v.exec(we.slice(ve));return le?(ue.m=g.get(le[0].toLowerCase()),ve+le[0].length):-1}function V(ue,we,ve){var le=x.exec(we.slice(ve));return le?(ue.m=j.get(le[0].toLowerCase()),ve+le[0].length):-1}function A(ue,we,ve){return C(ue,t,we,ve)}function $(ue,we,ve){return C(ue,r,we,ve)}function B(ue,we,ve){return C(ue,s,we,ve)}function I(ue){return o[ue.getDay()]}function k(ue){return i[ue.getDay()]}function M(ue){return c[ue.getMonth()]}function K(ue){return l[ue.getMonth()]}function X(ue){return a[+(ue.getHours()>=12)]}function re(ue){return 1+~~(ue.getMonth()/3)}function Z(ue){return o[ue.getUTCDay()]}function te(ue){return i[ue.getUTCDay()]}function xe(ue){return c[ue.getUTCMonth()]}function me(ue){return l[ue.getUTCMonth()]}function ne(ue){return a[+(ue.getUTCHours()>=12)]}function _e(ue){return 1+~~(ue.getUTCMonth()/3)}return{format:function(ue){var we=S(ue+="",b);return we.toString=function(){return ue},we},parse:function(ue){var we=_(ue+="",!1);return we.toString=function(){return ue},we},utcFormat:function(ue){var we=S(ue+="",N);return we.toString=function(){return ue},we},utcParse:function(ue){var we=_(ue+="",!0);return we.toString=function(){return ue},we}}}var l4={"-":"",_:" ",0:"0"},jr=/^\s*\d+/,fCe=/^%/,mCe=/[\\^$*+?|[\]().{}]/g;function qt(e,t,r){var s=e<0?"-":"",a=(s?-e:e)+"",i=a.length;return s+(i[t.toLowerCase(),r]))}function pCe(e,t,r){var s=jr.exec(t.slice(r,r+1));return s?(e.w=+s[0],r+s[0].length):-1}function xCe(e,t,r){var s=jr.exec(t.slice(r,r+1));return s?(e.u=+s[0],r+s[0].length):-1}function gCe(e,t,r){var s=jr.exec(t.slice(r,r+2));return s?(e.U=+s[0],r+s[0].length):-1}function vCe(e,t,r){var s=jr.exec(t.slice(r,r+2));return s?(e.V=+s[0],r+s[0].length):-1}function yCe(e,t,r){var s=jr.exec(t.slice(r,r+2));return s?(e.W=+s[0],r+s[0].length):-1}function c4(e,t,r){var s=jr.exec(t.slice(r,r+4));return s?(e.y=+s[0],r+s[0].length):-1}function d4(e,t,r){var s=jr.exec(t.slice(r,r+2));return s?(e.y=+s[0]+(+s[0]>68?1900:2e3),r+s[0].length):-1}function jCe(e,t,r){var s=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(r,r+6));return s?(e.Z=s[1]?0:-(s[2]+(s[3]||"00")),r+s[0].length):-1}function bCe(e,t,r){var s=jr.exec(t.slice(r,r+1));return s?(e.q=s[0]*3-3,r+s[0].length):-1}function wCe(e,t,r){var s=jr.exec(t.slice(r,r+2));return s?(e.m=s[0]-1,r+s[0].length):-1}function u4(e,t,r){var s=jr.exec(t.slice(r,r+2));return s?(e.d=+s[0],r+s[0].length):-1}function NCe(e,t,r){var s=jr.exec(t.slice(r,r+3));return s?(e.m=0,e.d=+s[0],r+s[0].length):-1}function f4(e,t,r){var s=jr.exec(t.slice(r,r+2));return s?(e.H=+s[0],r+s[0].length):-1}function SCe(e,t,r){var s=jr.exec(t.slice(r,r+2));return s?(e.M=+s[0],r+s[0].length):-1}function _Ce(e,t,r){var s=jr.exec(t.slice(r,r+2));return s?(e.S=+s[0],r+s[0].length):-1}function CCe(e,t,r){var s=jr.exec(t.slice(r,r+3));return s?(e.L=+s[0],r+s[0].length):-1}function kCe(e,t,r){var s=jr.exec(t.slice(r,r+6));return s?(e.L=Math.floor(s[0]/1e3),r+s[0].length):-1}function PCe(e,t,r){var s=fCe.exec(t.slice(r,r+1));return s?r+s[0].length:-1}function ACe(e,t,r){var s=jr.exec(t.slice(r));return s?(e.Q=+s[0],r+s[0].length):-1}function ECe(e,t,r){var s=jr.exec(t.slice(r));return s?(e.s=+s[0],r+s[0].length):-1}function m4(e,t){return qt(e.getDate(),t,2)}function OCe(e,t){return qt(e.getHours(),t,2)}function TCe(e,t){return qt(e.getHours()%12||12,t,2)}function MCe(e,t){return qt(1+_x.count(po(e),e),t,3)}function YV(e,t){return qt(e.getMilliseconds(),t,3)}function RCe(e,t){return YV(e,t)+"000"}function $Ce(e,t){return qt(e.getMonth()+1,t,2)}function ICe(e,t){return qt(e.getMinutes(),t,2)}function DCe(e,t){return qt(e.getSeconds(),t,2)}function LCe(e){var t=e.getDay();return t===0?7:t}function FCe(e,t){return qt(a0.count(po(e)-1,e),t,2)}function XV(e){var t=e.getDay();return t>=4||t===0?ff(e):ff.ceil(e)}function BCe(e,t){return e=XV(e),qt(ff.count(po(e),e)+(po(e).getDay()===4),t,2)}function zCe(e){return e.getDay()}function VCe(e,t){return qt(jy.count(po(e)-1,e),t,2)}function qCe(e,t){return qt(e.getFullYear()%100,t,2)}function WCe(e,t){return e=XV(e),qt(e.getFullYear()%100,t,2)}function UCe(e,t){return qt(e.getFullYear()%1e4,t,4)}function KCe(e,t){var r=e.getDay();return e=r>=4||r===0?ff(e):ff.ceil(e),qt(e.getFullYear()%1e4,t,4)}function GCe(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+qt(t/60|0,"0",2)+qt(t%60,"0",2)}function h4(e,t){return qt(e.getUTCDate(),t,2)}function HCe(e,t){return qt(e.getUTCHours(),t,2)}function QCe(e,t){return qt(e.getUTCHours()%12||12,t,2)}function YCe(e,t){return qt(1+s0.count(xo(e),e),t,3)}function ZV(e,t){return qt(e.getUTCMilliseconds(),t,3)}function XCe(e,t){return ZV(e,t)+"000"}function ZCe(e,t){return qt(e.getUTCMonth()+1,t,2)}function JCe(e,t){return qt(e.getUTCMinutes(),t,2)}function eke(e,t){return qt(e.getUTCSeconds(),t,2)}function tke(e){var t=e.getUTCDay();return t===0?7:t}function nke(e,t){return qt(i0.count(xo(e)-1,e),t,2)}function JV(e){var t=e.getUTCDay();return t>=4||t===0?mf(e):mf.ceil(e)}function rke(e,t){return e=JV(e),qt(mf.count(xo(e),e)+(xo(e).getUTCDay()===4),t,2)}function ske(e){return e.getUTCDay()}function ake(e,t){return qt(by.count(xo(e)-1,e),t,2)}function ike(e,t){return qt(e.getUTCFullYear()%100,t,2)}function oke(e,t){return e=JV(e),qt(e.getUTCFullYear()%100,t,2)}function lke(e,t){return qt(e.getUTCFullYear()%1e4,t,4)}function cke(e,t){var r=e.getUTCDay();return e=r>=4||r===0?mf(e):mf.ceil(e),qt(e.getUTCFullYear()%1e4,t,4)}function dke(){return"+0000"}function p4(){return"%"}function x4(e){return+e}function g4(e){return Math.floor(+e/1e3)}var Vd,eq,tq;uke({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function uke(e){return Vd=uCe(e),eq=Vd.format,Vd.parse,tq=Vd.utcFormat,Vd.utcParse,Vd}function fke(e){return new Date(e)}function mke(e){return e instanceof Date?+e:+new Date(+e)}function MP(e,t,r,s,a,i,o,l,c,d){var u=yP(),f=u.invert,h=u.domain,m=d(".%L"),y=d(":%S"),x=d("%I:%M"),j=d("%I %p"),v=d("%a %d"),g=d("%b %d"),b=d("%B"),N=d("%Y");function w(S){return(c(S)t(a/(e.length-1)))},r.quantiles=function(s){return Array.from({length:s+1},(a,i)=>n_e(e,i/s))},r.copy=function(){return aq(t).domain(e)},Po.apply(r,arguments)}function l0(){var e=0,t=.5,r=1,s=1,a,i,o,l,c,d=Zr,u,f=!1,h;function m(x){return isNaN(x=+x)?h:(x=.5+((x=+u(x))-i)*(s*xt}var cq=jke,bke=c0,wke=cq,Nke=dm;function Ske(e){return e&&e.length?bke(e,Nke,wke):void 0}var _ke=Ske;const d0=Gt(_ke);function Cke(e,t){return ee.e^i.s<0?1:-1;for(s=i.d.length,a=e.d.length,t=0,r=se.d[t]^i.s<0?1:-1;return s===a?0:s>a^i.s<0?1:-1};Ze.decimalPlaces=Ze.dp=function(){var e=this,t=e.d.length-1,r=(t-e.e)*jn;if(t=e.d[t],t)for(;t%10==0;t/=10)r--;return r<0?0:r};Ze.dividedBy=Ze.div=function(e){return to(this,new this.constructor(e))};Ze.dividedToIntegerBy=Ze.idiv=function(e){var t=this,r=t.constructor;return ln(to(t,new r(e),0,1),r.precision)};Ze.equals=Ze.eq=function(e){return!this.cmp(e)};Ze.exponent=function(){return Zn(this)};Ze.greaterThan=Ze.gt=function(e){return this.cmp(e)>0};Ze.greaterThanOrEqualTo=Ze.gte=function(e){return this.cmp(e)>=0};Ze.isInteger=Ze.isint=function(){return this.e>this.d.length-2};Ze.isNegative=Ze.isneg=function(){return this.s<0};Ze.isPositive=Ze.ispos=function(){return this.s>0};Ze.isZero=function(){return this.s===0};Ze.lessThan=Ze.lt=function(e){return this.cmp(e)<0};Ze.lessThanOrEqualTo=Ze.lte=function(e){return this.cmp(e)<1};Ze.logarithm=Ze.log=function(e){var t,r=this,s=r.constructor,a=s.precision,i=a+5;if(e===void 0)e=new s(10);else if(e=new s(e),e.s<1||e.eq(Ms))throw Error(da+"NaN");if(r.s<1)throw Error(da+(r.s?"NaN":"-Infinity"));return r.eq(Ms)?new s(0):(Cn=!1,t=to(hp(r,i),hp(e,i),i),Cn=!0,ln(t,a))};Ze.minus=Ze.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?hq(t,e):fq(t,(e.s=-e.s,e))};Ze.modulo=Ze.mod=function(e){var t,r=this,s=r.constructor,a=s.precision;if(e=new s(e),!e.s)throw Error(da+"NaN");return r.s?(Cn=!1,t=to(r,e,0,1).times(e),Cn=!0,r.minus(t)):ln(new s(r),a)};Ze.naturalExponential=Ze.exp=function(){return mq(this)};Ze.naturalLogarithm=Ze.ln=function(){return hp(this)};Ze.negated=Ze.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};Ze.plus=Ze.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?fq(t,e):hq(t,(e.s=-e.s,e))};Ze.precision=Ze.sd=function(e){var t,r,s,a=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Fc+e);if(t=Zn(a)+1,s=a.d.length-1,r=s*jn+1,s=a.d[s],s){for(;s%10==0;s/=10)r--;for(s=a.d[0];s>=10;s/=10)r++}return e&&t>r?t:r};Ze.squareRoot=Ze.sqrt=function(){var e,t,r,s,a,i,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(da+"NaN")}for(e=Zn(l),Cn=!1,a=Math.sqrt(+l),a==0||a==1/0?(t=ci(l.d),(t.length+e)%2==0&&(t+="0"),a=Math.sqrt(t),e=hm((e+1)/2)-(e<0||e%2),a==1/0?t="5e"+e:(t=a.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),s=new c(t)):s=new c(a.toString()),r=c.precision,a=o=r+3;;)if(i=s,s=i.plus(to(l,i,o+2)).times(.5),ci(i.d).slice(0,o)===(t=ci(s.d)).slice(0,o)){if(t=t.slice(o-3,o+1),a==o&&t=="4999"){if(ln(i,r+1,0),i.times(i).eq(l)){s=i;break}}else if(t!="9999")break;o+=4}return Cn=!0,ln(s,r)};Ze.times=Ze.mul=function(e){var t,r,s,a,i,o,l,c,d,u=this,f=u.constructor,h=u.d,m=(e=new f(e)).d;if(!u.s||!e.s)return new f(0);for(e.s*=u.s,r=u.e+e.e,c=h.length,d=m.length,c=0;){for(t=0,a=c+s;a>s;)l=i[a]+m[s]*h[a-s-1]+t,i[a--]=l%pr|0,t=l/pr|0;i[a]=(i[a]+t)%pr|0}for(;!i[--o];)i.pop();return t?++r:i.shift(),e.d=i,e.e=r,Cn?ln(e,f.precision):e};Ze.toDecimalPlaces=Ze.todp=function(e,t){var r=this,s=r.constructor;return r=new s(r),e===void 0?r:(wi(e,0,mm),t===void 0?t=s.rounding:wi(t,0,8),ln(r,e+Zn(r)+1,t))};Ze.toExponential=function(e,t){var r,s=this,a=s.constructor;return e===void 0?r=ld(s,!0):(wi(e,0,mm),t===void 0?t=a.rounding:wi(t,0,8),s=ln(new a(s),e+1,t),r=ld(s,!0,e+1)),r};Ze.toFixed=function(e,t){var r,s,a=this,i=a.constructor;return e===void 0?ld(a):(wi(e,0,mm),t===void 0?t=i.rounding:wi(t,0,8),s=ln(new i(a),e+Zn(a)+1,t),r=ld(s.abs(),!1,e+Zn(s)+1),a.isneg()&&!a.isZero()?"-"+r:r)};Ze.toInteger=Ze.toint=function(){var e=this,t=e.constructor;return ln(new t(e),Zn(e)+1,t.rounding)};Ze.toNumber=function(){return+this};Ze.toPower=Ze.pow=function(e){var t,r,s,a,i,o,l=this,c=l.constructor,d=12,u=+(e=new c(e));if(!e.s)return new c(Ms);if(l=new c(l),!l.s){if(e.s<1)throw Error(da+"Infinity");return l}if(l.eq(Ms))return l;if(s=c.precision,e.eq(Ms))return ln(l,s);if(t=e.e,r=e.d.length-1,o=t>=r,i=l.s,o){if((r=u<0?-u:u)<=uq){for(a=new c(Ms),t=Math.ceil(s/jn+4),Cn=!1;r%2&&(a=a.times(l),j4(a.d,t)),r=hm(r/2),r!==0;)l=l.times(l),j4(l.d,t);return Cn=!0,e.s<0?new c(Ms).div(a):ln(a,s)}}else if(i<0)throw Error(da+"NaN");return i=i<0&&e.d[Math.max(t,r)]&1?-1:1,l.s=1,Cn=!1,a=e.times(hp(l,s+d)),Cn=!0,a=mq(a),a.s=i,a};Ze.toPrecision=function(e,t){var r,s,a=this,i=a.constructor;return e===void 0?(r=Zn(a),s=ld(a,r<=i.toExpNeg||r>=i.toExpPos)):(wi(e,1,mm),t===void 0?t=i.rounding:wi(t,0,8),a=ln(new i(a),e,t),r=Zn(a),s=ld(a,e<=r||r<=i.toExpNeg,e)),s};Ze.toSignificantDigits=Ze.tosd=function(e,t){var r=this,s=r.constructor;return e===void 0?(e=s.precision,t=s.rounding):(wi(e,1,mm),t===void 0?t=s.rounding:wi(t,0,8)),ln(new s(r),e,t)};Ze.toString=Ze.valueOf=Ze.val=Ze.toJSON=Ze[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,t=Zn(e),r=e.constructor;return ld(e,t<=r.toExpNeg||t>=r.toExpPos)};function fq(e,t){var r,s,a,i,o,l,c,d,u=e.constructor,f=u.precision;if(!e.s||!t.s)return t.s||(t=new u(e)),Cn?ln(t,f):t;if(c=e.d,d=t.d,o=e.e,a=t.e,c=c.slice(),i=o-a,i){for(i<0?(s=c,i=-i,l=d.length):(s=d,a=o,l=c.length),o=Math.ceil(f/jn),l=o>l?o+1:l+1,i>l&&(i=l,s.length=1),s.reverse();i--;)s.push(0);s.reverse()}for(l=c.length,i=d.length,l-i<0&&(i=l,s=d,d=c,c=s),r=0;i;)r=(c[--i]=c[i]+d[i]+r)/pr|0,c[i]%=pr;for(r&&(c.unshift(r),++a),l=c.length;c[--l]==0;)c.pop();return t.d=c,t.e=a,Cn?ln(t,f):t}function wi(e,t,r){if(e!==~~e||er)throw Error(Fc+e)}function ci(e){var t,r,s,a=e.length-1,i="",o=e[0];if(a>0){for(i+=o,t=1;to?1:-1;else for(l=c=0;la[l]?1:-1;break}return c}function r(s,a,i){for(var o=0;i--;)s[i]-=o,o=s[i]1;)s.shift()}return function(s,a,i,o){var l,c,d,u,f,h,m,y,x,j,v,g,b,N,w,S,_,C,P=s.constructor,D=s.s==a.s?1:-1,z=s.d,O=a.d;if(!s.s)return new P(s);if(!a.s)throw Error(da+"Division by zero");for(c=s.e-a.e,_=O.length,w=z.length,m=new P(D),y=m.d=[],d=0;O[d]==(z[d]||0);)++d;if(O[d]>(z[d]||0)&&--c,i==null?g=i=P.precision:o?g=i+(Zn(s)-Zn(a))+1:g=i,g<0)return new P(0);if(g=g/jn+2|0,d=0,_==1)for(u=0,O=O[0],g++;(d1&&(O=e(O,u),z=e(z,u),_=O.length,w=z.length),N=_,x=z.slice(0,_),j=x.length;j<_;)x[j++]=0;C=O.slice(),C.unshift(0),S=O[0],O[1]>=pr/2&&++S;do u=0,l=t(O,x,_,j),l<0?(v=x[0],_!=j&&(v=v*pr+(x[1]||0)),u=v/S|0,u>1?(u>=pr&&(u=pr-1),f=e(O,u),h=f.length,j=x.length,l=t(f,x,h,j),l==1&&(u--,r(f,_16)throw Error(IP+Zn(e));if(!e.s)return new u(Ms);for(Cn=!1,l=f,o=new u(.03125);e.abs().gte(.1);)e=e.times(o),d+=5;for(s=Math.log(pc(2,d))/Math.LN10*2+5|0,l+=s,r=a=i=new u(Ms),u.precision=l;;){if(a=ln(a.times(e),l),r=r.times(++c),o=i.plus(to(a,r,l)),ci(o.d).slice(0,l)===ci(i.d).slice(0,l)){for(;d--;)i=ln(i.times(i),l);return u.precision=f,t==null?(Cn=!0,ln(i,f)):i}i=o}}function Zn(e){for(var t=e.e*jn,r=e.d[0];r>=10;r/=10)t++;return t}function mN(e,t,r){if(t>e.LN10.sd())throw Cn=!0,r&&(e.precision=r),Error(da+"LN10 precision limit exceeded");return ln(new e(e.LN10),t)}function Uo(e){for(var t="";e--;)t+="0";return t}function hp(e,t){var r,s,a,i,o,l,c,d,u,f=1,h=10,m=e,y=m.d,x=m.constructor,j=x.precision;if(m.s<1)throw Error(da+(m.s?"NaN":"-Infinity"));if(m.eq(Ms))return new x(0);if(t==null?(Cn=!1,d=j):d=t,m.eq(10))return t==null&&(Cn=!0),mN(x,d);if(d+=h,x.precision=d,r=ci(y),s=r.charAt(0),i=Zn(m),Math.abs(i)<15e14){for(;s<7&&s!=1||s==1&&r.charAt(1)>3;)m=m.times(e),r=ci(m.d),s=r.charAt(0),f++;i=Zn(m),s>1?(m=new x("0."+r),i++):m=new x(s+"."+r.slice(1))}else return c=mN(x,d+2,j).times(i+""),m=hp(new x(s+"."+r.slice(1)),d-h).plus(c),x.precision=j,t==null?(Cn=!0,ln(m,j)):m;for(l=o=m=to(m.minus(Ms),m.plus(Ms),d),u=ln(m.times(m),d),a=3;;){if(o=ln(o.times(u),d),c=l.plus(to(o,new x(a),d)),ci(c.d).slice(0,d)===ci(l.d).slice(0,d))return l=l.times(2),i!==0&&(l=l.plus(mN(x,d+2,j).times(i+""))),l=to(l,new x(f),d),x.precision=j,t==null?(Cn=!0,ln(l,j)):l;l=c,a+=2}}function y4(e,t){var r,s,a;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(s=t.search(/e/i))>0?(r<0&&(r=s),r+=+t.slice(s+1),t=t.substring(0,s)):r<0&&(r=t.length),s=0;t.charCodeAt(s)===48;)++s;for(a=t.length;t.charCodeAt(a-1)===48;)--a;if(t=t.slice(s,a),t){if(a-=s,r=r-s-1,e.e=hm(r/jn),e.d=[],s=(r+1)%jn,r<0&&(s+=jn),swy||e.e<-wy))throw Error(IP+r)}else e.s=0,e.e=0,e.d=[0];return e}function ln(e,t,r){var s,a,i,o,l,c,d,u,f=e.d;for(o=1,i=f[0];i>=10;i/=10)o++;if(s=t-o,s<0)s+=jn,a=t,d=f[u=0];else{if(u=Math.ceil((s+1)/jn),i=f.length,u>=i)return e;for(d=i=f[u],o=1;i>=10;i/=10)o++;s%=jn,a=s-jn+o}if(r!==void 0&&(i=pc(10,o-a-1),l=d/i%10|0,c=t<0||f[u+1]!==void 0||d%i,c=r<4?(l||c)&&(r==0||r==(e.s<0?3:2)):l>5||l==5&&(r==4||c||r==6&&(s>0?a>0?d/pc(10,o-a):0:f[u-1])%10&1||r==(e.s<0?8:7))),t<1||!f[0])return c?(i=Zn(e),f.length=1,t=t-i-1,f[0]=pc(10,(jn-t%jn)%jn),e.e=hm(-t/jn)||0):(f.length=1,f[0]=e.e=e.s=0),e;if(s==0?(f.length=u,i=1,u--):(f.length=u+1,i=pc(10,jn-s),f[u]=a>0?(d/pc(10,o-a)%pc(10,a)|0)*i:0),c)for(;;)if(u==0){(f[0]+=i)==pr&&(f[0]=1,++e.e);break}else{if(f[u]+=i,f[u]!=pr)break;f[u--]=0,i=1}for(s=f.length;f[--s]===0;)f.pop();if(Cn&&(e.e>wy||e.e<-wy))throw Error(IP+Zn(e));return e}function hq(e,t){var r,s,a,i,o,l,c,d,u,f,h=e.constructor,m=h.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new h(e),Cn?ln(t,m):t;if(c=e.d,f=t.d,s=t.e,d=e.e,c=c.slice(),o=d-s,o){for(u=o<0,u?(r=c,o=-o,l=f.length):(r=f,s=d,l=c.length),a=Math.max(Math.ceil(m/jn),l)+2,o>a&&(o=a,r.length=1),r.reverse(),a=o;a--;)r.push(0);r.reverse()}else{for(a=c.length,l=f.length,u=a0;--a)c[l++]=0;for(a=f.length;a>o;){if(c[--a]0?i=i.charAt(0)+"."+i.slice(1)+Uo(s):o>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(a<0?"e":"e+")+a):a<0?(i="0."+Uo(-a-1)+i,r&&(s=r-o)>0&&(i+=Uo(s))):a>=o?(i+=Uo(a+1-o),r&&(s=r-a-1)>0&&(i=i+"."+Uo(s))):((s=a+1)0&&(a+1===o&&(i+="."),i+=Uo(s))),e.s<0?"-"+i:i}function j4(e,t){if(e.length>t)return e.length=t,!0}function pq(e){var t,r,s;function a(i){var o=this;if(!(o instanceof a))return new a(i);if(o.constructor=a,i instanceof a){o.s=i.s,o.e=i.e,o.d=(i=i.d)?i.slice():i;return}if(typeof i=="number"){if(i*0!==0)throw Error(Fc+i);if(i>0)o.s=1;else if(i<0)i=-i,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(i===~~i&&i<1e7){o.e=0,o.d=[i];return}return y4(o,i.toString())}else if(typeof i!="string")throw Error(Fc+i);if(i.charCodeAt(0)===45?(i=i.slice(1),o.s=-1):o.s=1,Gke.test(i))y4(o,i);else throw Error(Fc+i)}if(a.prototype=Ze,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.clone=pq,a.config=a.set=Hke,e===void 0&&(e={}),e)for(s=["precision","rounding","toExpNeg","toExpPos","LN10"],t=0;t=a[t+1]&&s<=a[t+2])this[r]=s;else throw Error(Fc+r+": "+s);if((s=e[r="LN10"])!==void 0)if(s==Math.LN10)this[r]=new this(s);else throw Error(Fc+r+": "+s);return this}var DP=pq(Kke);Ms=new DP(1);const sn=DP;function Qke(e){return Jke(e)||Zke(e)||Xke(e)||Yke()}function Yke(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Xke(e,t){if(e){if(typeof e=="string")return u_(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u_(e,t)}}function Zke(e){if(typeof Symbol<"u"&&Symbol.iterator in Object(e))return Array.from(e)}function Jke(e){if(Array.isArray(e))return u_(e)}function u_(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r=t?r.apply(void 0,a):e(t-o,b4(function(){for(var l=arguments.length,c=new Array(l),d=0;de.length)&&(t=e.length);for(var r=0,s=new Array(t);r"u"||!(Symbol.iterator in Object(e)))){var r=[],s=!0,a=!1,i=void 0;try{for(var o=e[Symbol.iterator](),l;!(s=(l=o.next()).done)&&(r.push(l.value),!(t&&r.length===t));s=!0);}catch(c){a=!0,i=c}finally{try{!s&&o.return!=null&&o.return()}finally{if(a)throw i}}return r}}function h2e(e){if(Array.isArray(e))return e}function jq(e){var t=pp(e,2),r=t[0],s=t[1],a=r,i=s;return r>s&&(a=s,i=r),[a,i]}function bq(e,t,r){if(e.lte(0))return new sn(0);var s=m0.getDigitCount(e.toNumber()),a=new sn(10).pow(s),i=e.div(a),o=s!==1?.05:.1,l=new sn(Math.ceil(i.div(o).toNumber())).add(r).mul(o),c=l.mul(a);return t?c:new sn(Math.ceil(c))}function p2e(e,t,r){var s=1,a=new sn(e);if(!a.isint()&&r){var i=Math.abs(e);i<1?(s=new sn(10).pow(m0.getDigitCount(e)-1),a=new sn(Math.floor(a.div(s).toNumber())).mul(s)):i>1&&(a=new sn(Math.floor(e)))}else e===0?a=new sn(Math.floor((t-1)/2)):r||(a=new sn(Math.floor(e)));var o=Math.floor((t-1)/2),l=r2e(n2e(function(c){return a.add(new sn(c-o).mul(s)).toNumber()}),f_);return l(0,t)}function wq(e,t,r,s){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((t-e)/(r-1)))return{step:new sn(0),tickMin:new sn(0),tickMax:new sn(0)};var i=bq(new sn(t).sub(e).div(r-1),s,a),o;e<=0&&t>=0?o=new sn(0):(o=new sn(e).add(t).div(2),o=o.sub(new sn(o).mod(i)));var l=Math.ceil(o.sub(e).div(i).toNumber()),c=Math.ceil(new sn(t).sub(o).div(i).toNumber()),d=l+c+1;return d>r?wq(e,t,r,s,a+1):(d0?c+(r-d):c,l=t>0?l:l+(r-d)),{step:i,tickMin:o.sub(new sn(l).mul(i)),tickMax:o.add(new sn(c).mul(i))})}function x2e(e){var t=pp(e,2),r=t[0],s=t[1],a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=Math.max(a,2),l=jq([r,s]),c=pp(l,2),d=c[0],u=c[1];if(d===-1/0||u===1/0){var f=u===1/0?[d].concat(h_(f_(0,a-1).map(function(){return 1/0}))):[].concat(h_(f_(0,a-1).map(function(){return-1/0})),[u]);return r>s?m_(f):f}if(d===u)return p2e(d,a,i);var h=wq(d,u,o,i),m=h.step,y=h.tickMin,x=h.tickMax,j=m0.rangeStep(y,x.add(new sn(.1).mul(m)),m);return r>s?m_(j):j}function g2e(e,t){var r=pp(e,2),s=r[0],a=r[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=jq([s,a]),l=pp(o,2),c=l[0],d=l[1];if(c===-1/0||d===1/0)return[s,a];if(c===d)return[c];var u=Math.max(t,2),f=bq(new sn(d).sub(c).div(u-1),i,0),h=[].concat(h_(m0.rangeStep(new sn(c),new sn(d).sub(new sn(.99).mul(f)),f)),[d]);return s>a?m_(h):h}var v2e=vq(x2e),y2e=vq(g2e),j2e="Invariant failed";function cd(e,t){throw new Error(j2e)}var b2e=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function hf(e){"@babel/helpers - typeof";return hf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hf(e)}function Ny(){return Ny=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,s=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function P2e(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function A2e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function E2e(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,s=new Array(t);r1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,o=-1,l=(r=s==null?void 0:s.length)!==null&&r!==void 0?r:0;if(l<=1)return 0;if(i&&i.axisType==="angleAxis"&&Math.abs(Math.abs(i.range[1]-i.range[0])-360)<=1e-6)for(var c=i.range,d=0;d0?a[d-1].coordinate:a[l-1].coordinate,f=a[d].coordinate,h=d>=l-1?a[0].coordinate:a[d+1].coordinate,m=void 0;if(Yr(f-u)!==Yr(h-f)){var y=[];if(Yr(h-f)===Yr(c[1]-c[0])){m=h;var x=f+c[1]-c[0];y[0]=Math.min(x,(x+u)/2),y[1]=Math.max(x,(x+u)/2)}else{m=u;var j=h+c[1]-c[0];y[0]=Math.min(f,(j+f)/2),y[1]=Math.max(f,(j+f)/2)}var v=[Math.min(f,(m+f)/2),Math.max(f,(m+f)/2)];if(t>v[0]&&t<=v[1]||t>=y[0]&&t<=y[1]){o=a[d].index;break}}else{var g=Math.min(u,h),b=Math.max(u,h);if(t>(g+f)/2&&t<=(b+f)/2){o=a[d].index;break}}}else for(var N=0;N0&&N(s[N].coordinate+s[N-1].coordinate)/2&&t<=(s[N].coordinate+s[N+1].coordinate)/2||N===l-1&&t>(s[N].coordinate+s[N-1].coordinate)/2){o=s[N].index;break}return o},LP=function(t){var r,s=t,a=s.type.displayName,i=(r=t.type)!==null&&r!==void 0&&r.defaultProps?In(In({},t.type.defaultProps),t.props):t.props,o=i.stroke,l=i.fill,c;switch(a){case"Line":c=o;break;case"Area":case"Radar":c=o&&o!=="none"?o:l;break;default:c=l;break}return c},G2e=function(t){var r=t.barSize,s=t.totalSize,a=t.stackGroups,i=a===void 0?{}:a;if(!i)return{};for(var o={},l=Object.keys(i),c=0,d=l.length;c=0});if(v&&v.length){var g=v[0].type.defaultProps,b=g!==void 0?In(In({},g),v[0].props):v[0].props,N=b.barSize,w=b[j];o[w]||(o[w]=[]);var S=yt(N)?r:N;o[w].push({item:v[0],stackList:v.slice(1),barSize:yt(S)?void 0:Xr(S,s,0)})}}return o},H2e=function(t){var r=t.barGap,s=t.barCategoryGap,a=t.bandSize,i=t.sizeList,o=i===void 0?[]:i,l=t.maxBarSize,c=o.length;if(c<1)return null;var d=Xr(r,a,0,!0),u,f=[];if(o[0].barSize===+o[0].barSize){var h=!1,m=a/c,y=o.reduce(function(N,w){return N+w.barSize||0},0);y+=(c-1)*d,y>=a&&(y-=(c-1)*d,d=0),y>=a&&m>0&&(h=!0,m*=.9,y=c*m);var x=(a-y)/2>>0,j={offset:x-d,size:0};u=o.reduce(function(N,w){var S={item:w.item,position:{offset:j.offset+j.size+d,size:h?m:w.barSize}},_=[].concat(S4(N),[S]);return j=_[_.length-1].position,w.stackList&&w.stackList.length&&w.stackList.forEach(function(C){_.push({item:C,position:j})}),_},f)}else{var v=Xr(s,a,0,!0);a-2*v-(c-1)*d<=0&&(d=0);var g=(a-2*v-(c-1)*d)/c;g>1&&(g>>=0);var b=l===+l?Math.min(g,l):g;u=o.reduce(function(N,w,S){var _=[].concat(S4(N),[{item:w.item,position:{offset:v+(g+d)*S+(g-b)/2,size:b}}]);return w.stackList&&w.stackList.length&&w.stackList.forEach(function(C){_.push({item:C,position:_[_.length-1].position})}),_},f)}return u},Q2e=function(t,r,s,a){var i=s.children,o=s.width,l=s.margin,c=o-(l.left||0)-(l.right||0),d=Cq({children:i,legendWidth:c});if(d){var u=a||{},f=u.width,h=u.height,m=d.align,y=d.verticalAlign,x=d.layout;if((x==="vertical"||x==="horizontal"&&y==="middle")&&m!=="center"&&Te(t[m]))return In(In({},t),{},_u({},m,t[m]+(f||0)));if((x==="horizontal"||x==="vertical"&&m==="center")&&y!=="middle"&&Te(t[y]))return In(In({},t),{},_u({},y,t[y]+(h||0)))}return t},Y2e=function(t,r,s){return yt(r)?!0:t==="horizontal"?r==="yAxis":t==="vertical"||s==="x"?r==="xAxis":s==="y"?r==="yAxis":!0},kq=function(t,r,s,a,i){var o=r.props.children,l=Ls(o,Cx).filter(function(d){return Y2e(a,i,d.props.direction)});if(l&&l.length){var c=l.map(function(d){return d.props.dataKey});return t.reduce(function(d,u){var f=Vn(u,s);if(yt(f))return d;var h=Array.isArray(f)?[u0(f),d0(f)]:[f,f],m=c.reduce(function(y,x){var j=Vn(u,x,0),v=h[0]-Math.abs(Array.isArray(j)?j[0]:j),g=h[1]+Math.abs(Array.isArray(j)?j[1]:j);return[Math.min(v,y[0]),Math.max(g,y[1])]},[1/0,-1/0]);return[Math.min(m[0],d[0]),Math.max(m[1],d[1])]},[1/0,-1/0])}return null},X2e=function(t,r,s,a,i){var o=r.map(function(l){return kq(t,l,s,i,a)}).filter(function(l){return!yt(l)});return o&&o.length?o.reduce(function(l,c){return[Math.min(l[0],c[0]),Math.max(l[1],c[1])]},[1/0,-1/0]):null},Pq=function(t,r,s,a,i){var o=r.map(function(c){var d=c.props.dataKey;return s==="number"&&d&&kq(t,c,d,a)||xh(t,d,s,i)});if(s==="number")return o.reduce(function(c,d){return[Math.min(c[0],d[0]),Math.max(c[1],d[1])]},[1/0,-1/0]);var l={};return o.reduce(function(c,d){for(var u=0,f=d.length;u=2?Yr(l[0]-l[1])*2*d:d,r&&(t.ticks||t.niceTicks)){var u=(t.ticks||t.niceTicks).map(function(f){var h=i?i.indexOf(f):f;return{coordinate:a(h)+d,value:f,offset:d}});return u.filter(function(f){return!jx(f.coordinate)})}return t.isCategorical&&t.categoricalDomain?t.categoricalDomain.map(function(f,h){return{coordinate:a(f)+d,value:f,index:h,offset:d}}):a.ticks&&!s?a.ticks(t.tickCount).map(function(f){return{coordinate:a(f)+d,value:f,offset:d}}):a.domain().map(function(f,h){return{coordinate:a(f)+d,value:i?i[f]:f,index:h,offset:d}})},hN=new WeakMap,Ng=function(t,r){if(typeof r!="function")return t;hN.has(t)||hN.set(t,new WeakMap);var s=hN.get(t);if(s.has(r))return s.get(r);var a=function(){t.apply(void 0,arguments),r.apply(void 0,arguments)};return s.set(r,a),a},Oq=function(t,r,s){var a=t.scale,i=t.type,o=t.layout,l=t.axisType;if(a==="auto")return o==="radial"&&l==="radiusAxis"?{scale:cp(),realScaleType:"band"}:o==="radial"&&l==="angleAxis"?{scale:vy(),realScaleType:"linear"}:i==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!s)?{scale:ph(),realScaleType:"point"}:i==="category"?{scale:cp(),realScaleType:"band"}:{scale:vy(),realScaleType:"linear"};if(sd(a)){var c="scale".concat(Yb(a));return{scale:(v4[c]||ph)(),realScaleType:v4[c]?c:"point"}}return ft(a)?{scale:a}:{scale:ph(),realScaleType:"point"}},C4=1e-4,Tq=function(t){var r=t.domain();if(!(!r||r.length<=2)){var s=r.length,a=t.range(),i=Math.min(a[0],a[1])-C4,o=Math.max(a[0],a[1])+C4,l=t(r[0]),c=t(r[s-1]);(lo||co)&&t.domain([r[0],r[s-1]])}},Z2e=function(t,r){if(!t)return null;for(var s=0,a=t.length;sa)&&(i[1]=a),i[0]>a&&(i[0]=a),i[1]=0?(t[l][s][0]=i,t[l][s][1]=i+c,i=t[l][s][1]):(t[l][s][0]=o,t[l][s][1]=o+c,o=t[l][s][1])}},tPe=function(t){var r=t.length;if(!(r<=0))for(var s=0,a=t[0].length;s=0?(t[o][s][0]=i,t[o][s][1]=i+l,i=t[o][s][1]):(t[o][s][0]=0,t[o][s][1]=0)}},nPe={sign:ePe,expand:bge,none:af,silhouette:wge,wiggle:Nge,positive:tPe},rPe=function(t,r,s){var a=r.map(function(l){return l.props.dataKey}),i=nPe[s],o=jge().keys(a).value(function(l,c){return+Vn(l,c,0)}).order(VS).offset(i);return o(t)},sPe=function(t,r,s,a,i,o){if(!t)return null;var l=o?r.reverse():r,c={},d=l.reduce(function(f,h){var m,y=(m=h.type)!==null&&m!==void 0&&m.defaultProps?In(In({},h.type.defaultProps),h.props):h.props,x=y.stackId,j=y.hide;if(j)return f;var v=y[s],g=f[v]||{hasStack:!1,stackGroups:{}};if(or(x)){var b=g.stackGroups[x]||{numericAxisId:s,cateAxisId:a,items:[]};b.items.push(h),g.hasStack=!0,g.stackGroups[x]=b}else g.stackGroups[om("_stackId_")]={numericAxisId:s,cateAxisId:a,items:[h]};return In(In({},f),{},_u({},v,g))},c),u={};return Object.keys(d).reduce(function(f,h){var m=d[h];if(m.hasStack){var y={};m.stackGroups=Object.keys(m.stackGroups).reduce(function(x,j){var v=m.stackGroups[j];return In(In({},x),{},_u({},j,{numericAxisId:s,cateAxisId:a,items:v.items,stackedData:rPe(t,v.items,i)}))},y)}return In(In({},f),{},_u({},h,m))},u)},Mq=function(t,r){var s=r.realScaleType,a=r.type,i=r.tickCount,o=r.originalDomain,l=r.allowDecimals,c=s||r.scale;if(c!=="auto"&&c!=="linear")return null;if(i&&a==="number"&&o&&(o[0]==="auto"||o[1]==="auto")){var d=t.domain();if(!d.length)return null;var u=v2e(d,i,l);return t.domain([u0(u),d0(u)]),{niceTicks:u}}if(i&&a==="number"){var f=t.domain(),h=y2e(f,i,l);return{niceTicks:h}}return null};function k4(e){var t=e.axis,r=e.ticks,s=e.bandSize,a=e.entry,i=e.index,o=e.dataKey;if(t.type==="category"){if(!t.allowDuplicatedCategory&&t.dataKey&&!yt(a[t.dataKey])){var l=Yv(r,"value",a[t.dataKey]);if(l)return l.coordinate+s/2}return r[i]?r[i].coordinate+s/2:null}var c=Vn(a,yt(o)?t.dataKey:o);return yt(c)?null:t.scale(c)}var P4=function(t){var r=t.axis,s=t.ticks,a=t.offset,i=t.bandSize,o=t.entry,l=t.index;if(r.type==="category")return s[l]?s[l].coordinate+a:null;var c=Vn(o,r.dataKey,r.domain[l]);return yt(c)?null:r.scale(c)-i/2+a},aPe=function(t){var r=t.numericAxis,s=r.scale.domain();if(r.type==="number"){var a=Math.min(s[0],s[1]),i=Math.max(s[0],s[1]);return a<=0&&i>=0?0:i<0?i:a}return s[0]},iPe=function(t,r){var s,a=(s=t.type)!==null&&s!==void 0&&s.defaultProps?In(In({},t.type.defaultProps),t.props):t.props,i=a.stackId;if(or(i)){var o=r[i];if(o){var l=o.items.indexOf(t);return l>=0?o.stackedData[l]:null}}return null},oPe=function(t){return t.reduce(function(r,s){return[u0(s.concat([r[0]]).filter(Te)),d0(s.concat([r[1]]).filter(Te))]},[1/0,-1/0])},Rq=function(t,r,s){return Object.keys(t).reduce(function(a,i){var o=t[i],l=o.stackedData,c=l.reduce(function(d,u){var f=oPe(u.slice(r,s+1));return[Math.min(d[0],f[0]),Math.max(d[1],f[1])]},[1/0,-1/0]);return[Math.min(c[0],a[0]),Math.max(c[1],a[1])]},[1/0,-1/0]).map(function(a){return a===1/0||a===-1/0?0:a})},A4=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,E4=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,v_=function(t,r,s){if(ft(t))return t(r,s);if(!Array.isArray(t))return r;var a=[];if(Te(t[0]))a[0]=s?t[0]:Math.min(t[0],r[0]);else if(A4.test(t[0])){var i=+A4.exec(t[0])[1];a[0]=r[0]-i}else ft(t[0])?a[0]=t[0](r[0]):a[0]=r[0];if(Te(t[1]))a[1]=s?t[1]:Math.max(t[1],r[1]);else if(E4.test(t[1])){var o=+E4.exec(t[1])[1];a[1]=r[1]+o}else ft(t[1])?a[1]=t[1](r[1]):a[1]=r[1];return a},_y=function(t,r,s){if(t&&t.scale&&t.scale.bandwidth){var a=t.scale.bandwidth();if(!s||a>0)return a}if(t&&r&&r.length>=2){for(var i=fP(r,function(f){return f.coordinate}),o=1/0,l=1,c=i.length;le.length)&&(t=e.length);for(var r=0,s=new Array(t);r2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(t-(s.left||0)-(s.right||0)),Math.abs(r-(s.top||0)-(s.bottom||0)))/2},Lq=function(t,r,s,a,i){var o=t.width,l=t.height,c=t.startAngle,d=t.endAngle,u=Xr(t.cx,o,o/2),f=Xr(t.cy,l,l/2),h=Dq(o,l,s),m=Xr(t.innerRadius,h,0),y=Xr(t.outerRadius,h,h*.8),x=Object.keys(r);return x.reduce(function(j,v){var g=r[v],b=g.domain,N=g.reversed,w;if(yt(g.range))a==="angleAxis"?w=[c,d]:a==="radiusAxis"&&(w=[m,y]),N&&(w=[w[1],w[0]]);else{w=g.range;var S=w,_=dPe(S,2);c=_[0],d=_[1]}var C=Oq(g,i),P=C.realScaleType,D=C.scale;D.domain(b).range(w),Tq(D);var z=Mq(D,Bi(Bi({},g),{},{realScaleType:P})),O=Bi(Bi(Bi({},g),z),{},{range:w,radius:y,realScaleType:P,scale:D,cx:u,cy:f,innerRadius:m,outerRadius:y,startAngle:c,endAngle:d});return Bi(Bi({},j),{},Iq({},v,O))},{})},xPe=function(t,r){var s=t.x,a=t.y,i=r.x,o=r.y;return Math.sqrt(Math.pow(s-i,2)+Math.pow(a-o,2))},gPe=function(t,r){var s=t.x,a=t.y,i=r.cx,o=r.cy,l=xPe({x:s,y:a},{x:i,y:o});if(l<=0)return{radius:l};var c=(s-i)/l,d=Math.acos(c);return a>o&&(d=2*Math.PI-d),{radius:l,angle:pPe(d),angleInRadian:d}},vPe=function(t){var r=t.startAngle,s=t.endAngle,a=Math.floor(r/360),i=Math.floor(s/360),o=Math.min(a,i);return{startAngle:r-o*360,endAngle:s-o*360}},yPe=function(t,r){var s=r.startAngle,a=r.endAngle,i=Math.floor(s/360),o=Math.floor(a/360),l=Math.min(i,o);return t+l*360},R4=function(t,r){var s=t.x,a=t.y,i=gPe({x:s,y:a},r),o=i.radius,l=i.angle,c=r.innerRadius,d=r.outerRadius;if(od)return!1;if(o===0)return!0;var u=vPe(r),f=u.startAngle,h=u.endAngle,m=l,y;if(f<=h){for(;m>h;)m-=360;for(;m=f&&m<=h}else{for(;m>f;)m-=360;for(;m=h&&m<=f}return y?Bi(Bi({},r),{},{radius:o,angle:yPe(m,r)}):null},Fq=function(t){return!p.isValidElement(t)&&!ft(t)&&typeof t!="boolean"?t.className:""};function yp(e){"@babel/helpers - typeof";return yp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yp(e)}var jPe=["offset"];function bPe(e){return _Pe(e)||SPe(e)||NPe(e)||wPe()}function wPe(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function NPe(e,t){if(e){if(typeof e=="string")return y_(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return y_(e,t)}}function SPe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function _Pe(e){if(Array.isArray(e))return y_(e)}function y_(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function kPe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function $4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function nr(e){for(var t=1;t=0?1:-1,b,N;a==="insideStart"?(b=m+g*o,N=x):a==="insideEnd"?(b=y-g*o,N=!x):a==="end"&&(b=y+g*o,N=x),N=v<=0?N:!N;var w=Ut(d,u,j,b),S=Ut(d,u,j,b+(N?1:-1)*359),_="M".concat(w.x,",").concat(w.y,` A`).concat(j,",").concat(j,",0,1,").concat(N?0:1,`, `).concat(S.x,",").concat(S.y),C=yt(t.id)?om("recharts-radial-line-"):t.id;return F.createElement("text",jp({},s,{dominantBaseline:"central",className:gt("recharts-radial-bar-label",l)}),F.createElement("defs",null,F.createElement("path",{id:C,d:_})),F.createElement("textPath",{xlinkHref:"#".concat(C)},r))},RPe=function(t){var r=t.viewBox,s=t.offset,a=t.position,i=r,o=i.cx,l=i.cy,c=i.innerRadius,d=i.outerRadius,u=i.startAngle,f=i.endAngle,h=(u+f)/2;if(a==="outside"){var m=Ut(o,l,d+s,h),y=m.x,x=m.y;return{x:y,y:x,textAnchor:y>=o?"start":"end",verticalAnchor:"middle"}}if(a==="center")return{x:o,y:l,textAnchor:"middle",verticalAnchor:"middle"};if(a==="centerTop")return{x:o,y:l,textAnchor:"middle",verticalAnchor:"start"};if(a==="centerBottom")return{x:o,y:l,textAnchor:"middle",verticalAnchor:"end"};var j=(c+d)/2,v=Ut(o,l,j,h),g=v.x,b=v.y;return{x:g,y:b,textAnchor:"middle",verticalAnchor:"middle"}},$Pe=function(t){var r=t.viewBox,s=t.parentViewBox,a=t.offset,i=t.position,o=r,l=o.x,c=o.y,d=o.width,u=o.height,f=u>=0?1:-1,h=f*a,m=f>0?"end":"start",y=f>0?"start":"end",x=d>=0?1:-1,j=x*a,v=x>0?"end":"start",g=x>0?"start":"end";if(i==="top"){var b={x:l+d/2,y:c-f*a,textAnchor:"middle",verticalAnchor:m};return nr(nr({},b),s?{height:Math.max(c-s.y,0),width:d}:{})}if(i==="bottom"){var N={x:l+d/2,y:c+u+h,textAnchor:"middle",verticalAnchor:y};return nr(nr({},N),s?{height:Math.max(s.y+s.height-(c+u),0),width:d}:{})}if(i==="left"){var w={x:l-j,y:c+u/2,textAnchor:v,verticalAnchor:"middle"};return nr(nr({},w),s?{width:Math.max(w.x-s.x,0),height:u}:{})}if(i==="right"){var S={x:l+d+j,y:c+u/2,textAnchor:g,verticalAnchor:"middle"};return nr(nr({},S),s?{width:Math.max(s.x+s.width-S.x,0),height:u}:{})}var _=s?{width:d,height:u}:{};return i==="insideLeft"?nr({x:l+j,y:c+u/2,textAnchor:g,verticalAnchor:"middle"},_):i==="insideRight"?nr({x:l+d-j,y:c+u/2,textAnchor:v,verticalAnchor:"middle"},_):i==="insideTop"?nr({x:l+d/2,y:c+h,textAnchor:"middle",verticalAnchor:y},_):i==="insideBottom"?nr({x:l+d/2,y:c+u-h,textAnchor:"middle",verticalAnchor:m},_):i==="insideTopLeft"?nr({x:l+j,y:c+h,textAnchor:g,verticalAnchor:y},_):i==="insideTopRight"?nr({x:l+d-j,y:c+h,textAnchor:v,verticalAnchor:y},_):i==="insideBottomLeft"?nr({x:l+j,y:c+u-h,textAnchor:g,verticalAnchor:m},_):i==="insideBottomRight"?nr({x:l+d-j,y:c+u-h,textAnchor:v,verticalAnchor:m},_):rm(i)&&(Te(i.x)||Nc(i.x))&&(Te(i.y)||Nc(i.y))?nr({x:l+Xr(i.x,d),y:c+Xr(i.y,u),textAnchor:"end",verticalAnchor:"end"},_):nr({x:l+d/2,y:c+u/2,textAnchor:"middle",verticalAnchor:"middle"},_)},IPe=function(t){return"cx"in t&&Te(t.cx)};function vr(e){var t=e.offset,r=t===void 0?5:t,s=CPe(e,jPe),a=nr({offset:r},s),i=a.viewBox,o=a.position,l=a.value,c=a.children,d=a.content,u=a.className,f=u===void 0?"":u,h=a.textBreakAll;if(!i||yt(l)&&yt(c)&&!p.isValidElement(d)&&!ft(d))return null;if(p.isValidElement(d))return p.cloneElement(d,a);var m;if(ft(d)){if(m=p.createElement(d,a),p.isValidElement(m))return m}else m=OPe(a);var y=IPe(i),x=st(a,!0);if(y&&(o==="insideStart"||o==="insideEnd"||o==="end"))return MPe(a,m,x);var j=y?RPe(a):$Pe(a);return F.createElement(od,jp({className:gt("recharts-label",f)},x,j,{breakAll:h}),m)}vr.displayName="Label";var Bq=function(t){var r=t.cx,s=t.cy,a=t.angle,i=t.startAngle,o=t.endAngle,l=t.r,c=t.radius,d=t.innerRadius,u=t.outerRadius,f=t.x,h=t.y,m=t.top,y=t.left,x=t.width,j=t.height,v=t.clockWise,g=t.labelViewBox;if(g)return g;if(Te(x)&&Te(j)){if(Te(f)&&Te(h))return{x:f,y:h,width:x,height:j};if(Te(m)&&Te(y))return{x:m,y,width:x,height:j}}return Te(f)&&Te(h)?{x:f,y:h,width:0,height:0}:Te(r)&&Te(s)?{cx:r,cy:s,startAngle:i||a||0,endAngle:o||a||0,innerRadius:d||0,outerRadius:u||c||l||0,clockWise:v}:t.viewBox?t.viewBox:{}},DPe=function(t,r){return t?t===!0?F.createElement(vr,{key:"label-implicit",viewBox:r}):or(t)?F.createElement(vr,{key:"label-implicit",viewBox:r,value:t}):p.isValidElement(t)?t.type===vr?p.cloneElement(t,{key:"label-implicit",viewBox:r}):F.createElement(vr,{key:"label-implicit",content:t,viewBox:r}):ft(t)?F.createElement(vr,{key:"label-implicit",content:t,viewBox:r}):rm(t)?F.createElement(vr,jp({viewBox:r},t,{key:"label-implicit"})):null:null},LPe=function(t,r){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!t||!t.children&&s&&!t.label)return null;var a=t.children,i=Bq(t),o=Ls(a,vr).map(function(c,d){return p.cloneElement(c,{viewBox:r||i,key:"label-".concat(d)})});if(!s)return o;var l=DPe(t.label,r||i);return[l].concat(bPe(o))};vr.parseViewBox=Bq;vr.renderCallByParent=LPe;function FPe(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var BPe=FPe;const zq=Gt(BPe);function bp(e){"@babel/helpers - typeof";return bp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bp(e)}var zPe=["valueAccessor"],VPe=["data","dataKey","clockWise","id","textBreakAll"];function qPe(e){return GPe(e)||KPe(e)||UPe(e)||WPe()}function WPe(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function UPe(e,t){if(e){if(typeof e=="string")return j_(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return j_(e,t)}}function KPe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function GPe(e){if(Array.isArray(e))return j_(e)}function j_(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function XPe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}var ZPe=function(t){return Array.isArray(t.value)?zq(t.value):t.value};function xi(e){var t=e.valueAccessor,r=t===void 0?ZPe:t,s=L4(e,zPe),a=s.data,i=s.dataKey,o=s.clockWise,l=s.id,c=s.textBreakAll,d=L4(s,VPe);return!a||!a.length?null:F.createElement(Tt,{className:"recharts-label-list"},a.map(function(u,f){var h=yt(i)?r(u,f):Vn(u&&u.payload,i),m=yt(l)?{}:{id:"".concat(l,"-").concat(f)};return F.createElement(vr,ky({},st(u,!0),d,m,{parentViewBox:u.parentViewBox,value:h,textBreakAll:c,viewBox:vr.parseViewBox(yt(o)?u:D4(D4({},u),{},{clockWise:o})),key:"label-".concat(f),index:f}))}))}xi.displayName="LabelList";function JPe(e,t){return e?e===!0?F.createElement(xi,{key:"labelList-implicit",data:t}):F.isValidElement(e)||ft(e)?F.createElement(xi,{key:"labelList-implicit",data:t,content:e}):rm(e)?F.createElement(xi,ky({data:t},e,{key:"labelList-implicit"})):null:null}function eAe(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e||!e.children&&r&&!e.label)return null;var s=e.children,a=Ls(s,xi).map(function(o,l){return p.cloneElement(o,{data:t,key:"labelList-".concat(l)})});if(!r)return a;var i=JPe(e.label,t);return[i].concat(qPe(a))}xi.renderCallByParent=eAe;function wp(e){"@babel/helpers - typeof";return wp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wp(e)}function b_(){return b_=Object.assign?Object.assign.bind():function(e){for(var t=1;t180),",").concat(+(o>d),`, `).concat(f.x,",").concat(f.y,` `);if(a>0){var m=Ut(r,s,a,o),y=Ut(r,s,a,d);h+="L ".concat(y.x,",").concat(y.y,` A `).concat(a,",").concat(a,`,0, `).concat(+(Math.abs(c)>180),",").concat(+(o<=d),`, `).concat(m.x,",").concat(m.y," Z")}else h+="L ".concat(r,",").concat(s," Z");return h},aAe=function(t){var r=t.cx,s=t.cy,a=t.innerRadius,i=t.outerRadius,o=t.cornerRadius,l=t.forceCornerRadius,c=t.cornerIsExternal,d=t.startAngle,u=t.endAngle,f=Yr(u-d),h=Sg({cx:r,cy:s,radius:i,angle:d,sign:f,cornerRadius:o,cornerIsExternal:c}),m=h.circleTangency,y=h.lineTangency,x=h.theta,j=Sg({cx:r,cy:s,radius:i,angle:u,sign:-f,cornerRadius:o,cornerIsExternal:c}),v=j.circleTangency,g=j.lineTangency,b=j.theta,N=c?Math.abs(d-u):Math.abs(d-u)-x-b;if(N<0)return l?"M ".concat(y.x,",").concat(y.y,` a`).concat(o,",").concat(o,",0,0,1,").concat(o*2,`,0 a`).concat(o,",").concat(o,",0,0,1,").concat(-o*2,`,0 `):Vq({cx:r,cy:s,innerRadius:a,outerRadius:i,startAngle:d,endAngle:u});var w="M ".concat(y.x,",").concat(y.y,` A`).concat(o,",").concat(o,",0,0,").concat(+(f<0),",").concat(m.x,",").concat(m.y,` A`).concat(i,",").concat(i,",0,").concat(+(N>180),",").concat(+(f<0),",").concat(v.x,",").concat(v.y,` A`).concat(o,",").concat(o,",0,0,").concat(+(f<0),",").concat(g.x,",").concat(g.y,` `);if(a>0){var S=Sg({cx:r,cy:s,radius:a,angle:d,sign:f,isExternal:!0,cornerRadius:o,cornerIsExternal:c}),_=S.circleTangency,C=S.lineTangency,P=S.theta,D=Sg({cx:r,cy:s,radius:a,angle:u,sign:-f,isExternal:!0,cornerRadius:o,cornerIsExternal:c}),z=D.circleTangency,O=D.lineTangency,V=D.theta,A=c?Math.abs(d-u):Math.abs(d-u)-P-V;if(A<0&&o===0)return"".concat(w,"L").concat(r,",").concat(s,"Z");w+="L".concat(O.x,",").concat(O.y,` A`).concat(o,",").concat(o,",0,0,").concat(+(f<0),",").concat(z.x,",").concat(z.y,` A`).concat(a,",").concat(a,",0,").concat(+(A>180),",").concat(+(f>0),",").concat(_.x,",").concat(_.y,` A`).concat(o,",").concat(o,",0,0,").concat(+(f<0),",").concat(C.x,",").concat(C.y,"Z")}else w+="L".concat(r,",").concat(s,"Z");return w},iAe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},qq=function(t){var r=B4(B4({},iAe),t),s=r.cx,a=r.cy,i=r.innerRadius,o=r.outerRadius,l=r.cornerRadius,c=r.forceCornerRadius,d=r.cornerIsExternal,u=r.startAngle,f=r.endAngle,h=r.className;if(o0&&Math.abs(u-f)<360?j=aAe({cx:s,cy:a,innerRadius:i,outerRadius:o,cornerRadius:Math.min(x,y/2),forceCornerRadius:c,cornerIsExternal:d,startAngle:u,endAngle:f}):j=Vq({cx:s,cy:a,innerRadius:i,outerRadius:o,startAngle:u,endAngle:f}),F.createElement("path",b_({},st(r,!0),{className:m,d:j,role:"img"}))};function Np(e){"@babel/helpers - typeof";return Np=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Np(e)}function w_(){return w_=Object.assign?Object.assign.bind():function(e){for(var t=1;tyAe.call(e,t));function Pd(e,t){return e===t||!e&&!t&&e!==e&&t!==t}const wAe="__v",NAe="__o",SAe="_owner",{getOwnPropertyDescriptor:U4,keys:K4}=Object;function _Ae(e,t){return e.byteLength===t.byteLength&&Ay(new Uint8Array(e),new Uint8Array(t))}function CAe(e,t,r){let s=e.length;if(t.length!==s)return!1;for(;s-- >0;)if(!r.equals(e[s],t[s],s,s,e,t,r))return!1;return!0}function kAe(e,t){return e.byteLength===t.byteLength&&Ay(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function PAe(e,t){return Pd(e.getTime(),t.getTime())}function AAe(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function EAe(e,t){return e===t}function G4(e,t,r){const s=e.size;if(s!==t.size)return!1;if(!s)return!0;const a=new Array(s),i=e.entries();let o,l,c=0;for(;(o=i.next())&&!o.done;){const d=t.entries();let u=!1,f=0;for(;(l=d.next())&&!l.done;){if(a[f]){f++;continue}const h=o.value,m=l.value;if(r.equals(h[0],m[0],c,f,e,t,r)&&r.equals(h[1],m[1],h[0],m[0],e,t,r)){u=a[f]=!0;break}f++}if(!u)return!1;c++}return!0}const OAe=Pd;function TAe(e,t,r){const s=K4(e);let a=s.length;if(K4(t).length!==a)return!1;for(;a-- >0;)if(!Gq(e,t,r,s[a]))return!1;return!0}function qm(e,t,r){const s=W4(e);let a=s.length;if(W4(t).length!==a)return!1;let i,o,l;for(;a-- >0;)if(i=s[a],!Gq(e,t,r,i)||(o=U4(e,i),l=U4(t,i),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function MAe(e,t){return Pd(e.valueOf(),t.valueOf())}function RAe(e,t){return e.source===t.source&&e.flags===t.flags}function H4(e,t,r){const s=e.size;if(s!==t.size)return!1;if(!s)return!0;const a=new Array(s),i=e.values();let o,l;for(;(o=i.next())&&!o.done;){const c=t.values();let d=!1,u=0;for(;(l=c.next())&&!l.done;){if(!a[u]&&r.equals(o.value,l.value,o.value,l.value,e,t,r)){d=a[u]=!0;break}u++}if(!d)return!1}return!0}function Ay(e,t){let r=e.byteLength;if(t.byteLength!==r||e.byteOffset!==t.byteOffset)return!1;for(;r-- >0;)if(e[r]!==t[r])return!1;return!0}function $Ae(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function Gq(e,t,r,s){return(s===SAe||s===NAe||s===wAe)&&(e.$$typeof||t.$$typeof)?!0:bAe(t,s)&&r.equals(e[s],t[s],s,s,e,t,r)}const IAe="[object ArrayBuffer]",DAe="[object Arguments]",LAe="[object Boolean]",FAe="[object DataView]",BAe="[object Date]",zAe="[object Error]",VAe="[object Map]",qAe="[object Number]",WAe="[object Object]",UAe="[object RegExp]",KAe="[object Set]",GAe="[object String]",HAe={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},QAe="[object URL]",YAe=Object.prototype.toString;function XAe({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:r,areDatesEqual:s,areErrorsEqual:a,areFunctionsEqual:i,areMapsEqual:o,areNumbersEqual:l,areObjectsEqual:c,arePrimitiveWrappersEqual:d,areRegExpsEqual:u,areSetsEqual:f,areTypedArraysEqual:h,areUrlsEqual:m,unknownTagComparators:y}){return function(j,v,g){if(j===v)return!0;if(j==null||v==null)return!1;const b=typeof j;if(b!==typeof v)return!1;if(b!=="object")return b==="number"?l(j,v,g):b==="function"?i(j,v,g):!1;const N=j.constructor;if(N!==v.constructor)return!1;if(N===Object)return c(j,v,g);if(Array.isArray(j))return t(j,v,g);if(N===Date)return s(j,v,g);if(N===RegExp)return u(j,v,g);if(N===Map)return o(j,v,g);if(N===Set)return f(j,v,g);const w=YAe.call(j);if(w===BAe)return s(j,v,g);if(w===UAe)return u(j,v,g);if(w===VAe)return o(j,v,g);if(w===KAe)return f(j,v,g);if(w===WAe)return typeof j.then!="function"&&typeof v.then!="function"&&c(j,v,g);if(w===QAe)return m(j,v,g);if(w===zAe)return a(j,v,g);if(w===DAe)return c(j,v,g);if(HAe[w])return h(j,v,g);if(w===IAe)return e(j,v,g);if(w===FAe)return r(j,v,g);if(w===LAe||w===qAe||w===GAe)return d(j,v,g);if(y){let S=y[w];if(!S){const _=jAe(j);_&&(S=y[_])}if(S)return S(j,v,g)}return!1}}function ZAe({circular:e,createCustomConfig:t,strict:r}){let s={areArrayBuffersEqual:_Ae,areArraysEqual:r?qm:CAe,areDataViewsEqual:kAe,areDatesEqual:PAe,areErrorsEqual:AAe,areFunctionsEqual:EAe,areMapsEqual:r?pN(G4,qm):G4,areNumbersEqual:OAe,areObjectsEqual:r?qm:TAe,arePrimitiveWrappersEqual:MAe,areRegExpsEqual:RAe,areSetsEqual:r?pN(H4,qm):H4,areTypedArraysEqual:r?pN(Ay,qm):Ay,areUrlsEqual:$Ae,unknownTagComparators:void 0};if(t&&(s=Object.assign({},s,t(s))),e){const a=Cg(s.areArraysEqual),i=Cg(s.areMapsEqual),o=Cg(s.areObjectsEqual),l=Cg(s.areSetsEqual);s=Object.assign({},s,{areArraysEqual:a,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:l})}return s}function JAe(e){return function(t,r,s,a,i,o,l){return e(t,r,l)}}function eEe({circular:e,comparator:t,createState:r,equals:s,strict:a}){if(r)return function(l,c){const{cache:d=e?new WeakMap:void 0,meta:u}=r();return t(l,c,{cache:d,equals:s,meta:u,strict:a})};if(e)return function(l,c){return t(l,c,{cache:new WeakMap,equals:s,meta:void 0,strict:a})};const i={cache:void 0,equals:s,meta:void 0,strict:a};return function(l,c){return t(l,c,i)}}const tEe=tc();tc({strict:!0});tc({circular:!0});tc({circular:!0,strict:!0});tc({createInternalComparator:()=>Pd});tc({strict:!0,createInternalComparator:()=>Pd});tc({circular:!0,createInternalComparator:()=>Pd});tc({circular:!0,createInternalComparator:()=>Pd,strict:!0});function tc(e={}){const{circular:t=!1,createInternalComparator:r,createState:s,strict:a=!1}=e,i=ZAe(e),o=XAe(i),l=r?r(o):JAe(o);return eEe({circular:t,comparator:o,createState:s,equals:l,strict:a})}function nEe(e){typeof requestAnimationFrame<"u"&&requestAnimationFrame(e)}function Q4(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=-1,s=function a(i){r<0&&(r=i),i-r>t?(e(i),r=-1):nEe(a)};requestAnimationFrame(s)}function N_(e){"@babel/helpers - typeof";return N_=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N_(e)}function rEe(e){return oEe(e)||iEe(e)||aEe(e)||sEe()}function sEe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function aEe(e,t){if(e){if(typeof e=="string")return Y4(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Y4(e,t)}}function Y4(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);re.length)&&(t=e.length);for(var r=0,s=new Array(t);r1?1:v<0?0:v},x=function(v){for(var g=v>1?1:v,b=g,N=0;N<8;++N){var w=f(b)-g,S=m(b);if(Math.abs(w-g)0&&arguments[0]!==void 0?arguments[0]:{},r=t.stiff,s=r===void 0?100:r,a=t.damping,i=a===void 0?8:a,o=t.dt,l=o===void 0?17:o,c=function(u,f,h){var m=-(u-f)*s,y=h*i,x=h+(m-y)*l/1e3,j=h*l/1e3+u;return Math.abs(j-f)e.length)&&(t=e.length);for(var r=0,s=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function LEe(e,t){if(e==null)return{};var r={},s=Object.keys(e),a,i;for(i=0;i=0)&&(r[a]=e[a]);return r}function xN(e){return VEe(e)||zEe(e)||BEe(e)||FEe()}function FEe(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function BEe(e,t){if(e){if(typeof e=="string")return P_(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return P_(e,t)}}function zEe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function VEe(e){if(Array.isArray(e))return P_(e)}function P_(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Ty(e){return Ty=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Ty(e)}var Ua=function(e){GEe(r,e);var t=HEe(r);function r(s,a){var i;qEe(this,r),i=t.call(this,s,a);var o=i.props,l=o.isActive,c=o.attributeName,d=o.from,u=o.to,f=o.steps,h=o.children,m=o.duration;if(i.handleStyleChange=i.handleStyleChange.bind(O_(i)),i.changeStyle=i.changeStyle.bind(O_(i)),!l||m<=0)return i.state={style:{}},typeof h=="function"&&(i.state={style:u}),E_(i);if(f&&f.length)i.state={style:f[0].style};else if(d){if(typeof h=="function")return i.state={style:d},E_(i);i.state={style:c?rh({},c,d):d}}else i.state={style:{}};return i}return UEe(r,[{key:"componentDidMount",value:function(){var a=this.props,i=a.isActive,o=a.canBegin;this.mounted=!0,!(!i||!o)&&this.runAnimation(this.props)}},{key:"componentDidUpdate",value:function(a){var i=this.props,o=i.isActive,l=i.canBegin,c=i.attributeName,d=i.shouldReAnimate,u=i.to,f=i.from,h=this.state.style;if(l){if(!o){var m={style:c?rh({},c,u):u};this.state&&h&&(c&&h[c]!==u||!c&&h!==u)&&this.setState(m);return}if(!(tEe(a.to,u)&&a.canBegin&&a.isActive)){var y=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var x=y||d?f:a.to;if(this.state&&h){var j={style:c?rh({},c,x):x};(c&&h[c]!==x||!c&&h!==x)&&this.setState(j)}this.runAnimation(wa(wa({},this.props),{},{from:x,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var a=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),a&&a()}},{key:"handleStyleChange",value:function(a){this.changeStyle(a)}},{key:"changeStyle",value:function(a){this.mounted&&this.setState({style:a})}},{key:"runJSAnimation",value:function(a){var i=this,o=a.from,l=a.to,c=a.duration,d=a.easing,u=a.begin,f=a.onAnimationEnd,h=a.onAnimationStart,m=$Ee(o,l,SEe(d),c,this.changeStyle),y=function(){i.stopJSAnimation=m()};this.manager.start([h,u,y,c,f])}},{key:"runStepAnimation",value:function(a){var i=this,o=a.steps,l=a.begin,c=a.onAnimationStart,d=o[0],u=d.style,f=d.duration,h=f===void 0?0:f,m=function(x,j,v){if(v===0)return x;var g=j.duration,b=j.easing,N=b===void 0?"ease":b,w=j.style,S=j.properties,_=j.onAnimationEnd,C=v>0?o[v-1]:j,P=S||Object.keys(w);if(typeof N=="function"||N==="spring")return[].concat(xN(x),[i.runJSAnimation.bind(i,{from:C.style,to:w,duration:g,easing:N}),g]);var D=J4(P,g,N),z=wa(wa(wa({},C.style),w),{},{transition:D});return[].concat(xN(x),[z,g,_]).filter(fEe)};return this.manager.start([c].concat(xN(o.reduce(m,[u,Math.max(h,l)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=lEe());var i=a.begin,o=a.duration,l=a.attributeName,c=a.to,d=a.easing,u=a.onAnimationStart,f=a.onAnimationEnd,h=a.steps,m=a.children,y=this.manager;if(this.unSubscribe=y.subscribe(this.handleStyleChange),typeof d=="function"||typeof m=="function"||d==="spring"){this.runJSAnimation(a);return}if(h.length>1){this.runStepAnimation(a);return}var x=l?rh({},l,c):c,j=J4(Object.keys(x),o,d);y.start([u,i,wa(wa({},x),{},{transition:j}),o,f])}},{key:"render",value:function(){var a=this.props,i=a.children;a.begin;var o=a.duration;a.attributeName,a.easing;var l=a.isActive;a.steps,a.from,a.to,a.canBegin,a.onAnimationEnd,a.shouldReAnimate,a.onAnimationReStart;var c=DEe(a,IEe),d=p.Children.count(i),u=this.state.style;if(typeof i=="function")return i(u);if(!l||d===0||o<=0)return i;var f=function(m){var y=m.props,x=y.style,j=x===void 0?{}:x,v=y.className,g=p.cloneElement(m,wa(wa({},c),{},{style:wa(wa({},j),u),className:v}));return g};return d===1?f(p.Children.only(i)):F.createElement("div",null,p.Children.map(i,function(h){return f(h)}))}}]),r}(p.PureComponent);Ua.displayName="Animate";Ua.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};Ua.propTypes={from:Yt.oneOfType([Yt.object,Yt.string]),to:Yt.oneOfType([Yt.object,Yt.string]),attributeName:Yt.string,duration:Yt.number,begin:Yt.number,easing:Yt.oneOfType([Yt.string,Yt.func]),steps:Yt.arrayOf(Yt.shape({duration:Yt.number.isRequired,style:Yt.object.isRequired,easing:Yt.oneOfType([Yt.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),Yt.func]),properties:Yt.arrayOf("string"),onAnimationEnd:Yt.func})),children:Yt.oneOfType([Yt.node,Yt.func]),isActive:Yt.bool,canBegin:Yt.bool,onAnimationEnd:Yt.func,shouldReAnimate:Yt.bool,onAnimationStart:Yt.func,onAnimationReStart:Yt.func};function Cp(e){"@babel/helpers - typeof";return Cp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Cp(e)}function My(){return My=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,s=new Array(t);r=0?1:-1,c=s>=0?1:-1,d=a>=0&&s>=0||a<0&&s<0?1:0,u;if(o>0&&i instanceof Array){for(var f=[0,0,0,0],h=0,m=4;ho?o:i[h];u="M".concat(t,",").concat(r+l*f[0]),f[0]>0&&(u+="A ".concat(f[0],",").concat(f[0],",0,0,").concat(d,",").concat(t+c*f[0],",").concat(r)),u+="L ".concat(t+s-c*f[1],",").concat(r),f[1]>0&&(u+="A ".concat(f[1],",").concat(f[1],",0,0,").concat(d,`, `).concat(t+s,",").concat(r+l*f[1])),u+="L ".concat(t+s,",").concat(r+a-l*f[2]),f[2]>0&&(u+="A ".concat(f[2],",").concat(f[2],",0,0,").concat(d,`, `).concat(t+s-c*f[2],",").concat(r+a)),u+="L ".concat(t+c*f[3],",").concat(r+a),f[3]>0&&(u+="A ".concat(f[3],",").concat(f[3],",0,0,").concat(d,`, `).concat(t,",").concat(r+a-l*f[3])),u+="Z"}else if(o>0&&i===+i&&i>0){var y=Math.min(o,i);u="M ".concat(t,",").concat(r+l*y,` A `).concat(y,",").concat(y,",0,0,").concat(d,",").concat(t+c*y,",").concat(r,` L `).concat(t+s-c*y,",").concat(r,` A `).concat(y,",").concat(y,",0,0,").concat(d,",").concat(t+s,",").concat(r+l*y,` L `).concat(t+s,",").concat(r+a-l*y,` A `).concat(y,",").concat(y,",0,0,").concat(d,",").concat(t+s-c*y,",").concat(r+a,` L `).concat(t+c*y,",").concat(r+a,` A `).concat(y,",").concat(y,",0,0,").concat(d,",").concat(t,",").concat(r+a-l*y," Z")}else u="M ".concat(t,",").concat(r," h ").concat(s," v ").concat(a," h ").concat(-s," Z");return u},sOe=function(t,r){if(!t||!r)return!1;var s=t.x,a=t.y,i=r.x,o=r.y,l=r.width,c=r.height;if(Math.abs(l)>0&&Math.abs(c)>0){var d=Math.min(i,i+l),u=Math.max(i,i+l),f=Math.min(o,o+c),h=Math.max(o,o+c);return s>=d&&s<=u&&a>=f&&a<=h}return!1},aOe={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},FP=function(t){var r=oR(oR({},aOe),t),s=p.useRef(),a=p.useState(-1),i=YEe(a,2),o=i[0],l=i[1];p.useEffect(function(){if(s.current&&s.current.getTotalLength)try{var N=s.current.getTotalLength();N&&l(N)}catch{}},[]);var c=r.x,d=r.y,u=r.width,f=r.height,h=r.radius,m=r.className,y=r.animationEasing,x=r.animationDuration,j=r.animationBegin,v=r.isAnimationActive,g=r.isUpdateAnimationActive;if(c!==+c||d!==+d||u!==+u||f!==+f||u===0||f===0)return null;var b=gt("recharts-rectangle",m);return g?F.createElement(Ua,{canBegin:o>0,from:{width:u,height:f,x:c,y:d},to:{width:u,height:f,x:c,y:d},duration:x,animationEasing:y,isActive:g},function(N){var w=N.width,S=N.height,_=N.x,C=N.y;return F.createElement(Ua,{canBegin:o>0,from:"0px ".concat(o===-1?1:o,"px"),to:"".concat(o,"px 0px"),attributeName:"strokeDasharray",begin:j,duration:x,isActive:v,easing:y},F.createElement("path",My({},st(r,!0),{className:b,d:lR(_,C,w,S,h),ref:s})))}):F.createElement("path",My({},st(r,!0),{className:b,d:lR(c,d,u,f,h)}))},iOe=["points","className","baseLinePoints","connectNulls"];function cu(){return cu=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function lOe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function cR(e){return fOe(e)||uOe(e)||dOe(e)||cOe()}function cOe(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dOe(e,t){if(e){if(typeof e=="string")return T_(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return T_(e,t)}}function uOe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function fOe(e){if(Array.isArray(e))return T_(e)}function T_(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return t.forEach(function(s){dR(s)?r[r.length-1].push(s):r[r.length-1].length>0&&r.push([])}),dR(t[0])&&r[r.length-1].push(t[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},vh=function(t,r){var s=mOe(t);r&&(s=[s.reduce(function(i,o){return[].concat(cR(i),cR(o))},[])]);var a=s.map(function(i){return i.reduce(function(o,l,c){return"".concat(o).concat(c===0?"M":"L").concat(l.x,",").concat(l.y)},"")}).join("");return s.length===1?"".concat(a,"Z"):a},hOe=function(t,r,s){var a=vh(t,s);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(vh(r.reverse(),s).slice(1))},e9=function(t){var r=t.points,s=t.className,a=t.baseLinePoints,i=t.connectNulls,o=oOe(t,iOe);if(!r||!r.length)return null;var l=gt("recharts-polygon",s);if(a&&a.length){var c=o.stroke&&o.stroke!=="none",d=hOe(r,a,i);return F.createElement("g",{className:l},F.createElement("path",cu({},st(o,!0),{fill:d.slice(-1)==="Z"?o.fill:"none",stroke:"none",d})),c?F.createElement("path",cu({},st(o,!0),{fill:"none",d:vh(r,i)})):null,c?F.createElement("path",cu({},st(o,!0),{fill:"none",d:vh(a,i)})):null)}var u=vh(r,i);return F.createElement("path",cu({},st(o,!0),{fill:u.slice(-1)==="Z"?o.fill:"none",className:l,d:u}))};function M_(){return M_=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function bOe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}var wOe=function(t,r,s,a,i,o){return"M".concat(t,",").concat(i,"v").concat(a,"M").concat(o,",").concat(r,"h").concat(s)},NOe=function(t){var r=t.x,s=r===void 0?0:r,a=t.y,i=a===void 0?0:a,o=t.top,l=o===void 0?0:o,c=t.left,d=c===void 0?0:c,u=t.width,f=u===void 0?0:u,h=t.height,m=h===void 0?0:h,y=t.className,x=jOe(t,pOe),j=xOe({x:s,y:i,top:l,left:d,width:f,height:m},x);return!Te(s)||!Te(i)||!Te(f)||!Te(m)||!Te(l)||!Te(d)?null:F.createElement("path",R_({},st(j,!0),{className:gt("recharts-cross",y),d:wOe(s,i,f,m,l,d)}))},SOe=["cx","cy","innerRadius","outerRadius","gridType","radialLines"];function Pp(e){"@babel/helpers - typeof";return Pp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pp(e)}function _Oe(e,t){if(e==null)return{};var r=COe(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function COe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function go(){return go=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function QOe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function YOe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function pR(e,t){for(var r=0;rvR?o=a==="outer"?"start":"end":i<-vR?o=a==="outer"?"end":"start":o="middle",o}},{key:"renderAxisLine",value:function(){var s=this.props,a=s.cx,i=s.cy,o=s.radius,l=s.axisLine,c=s.axisLineType,d=lc(lc({},st(this.props,!1)),{},{fill:"none"},st(l,!1));if(c==="circle")return F.createElement(kx,xc({className:"recharts-polar-angle-axis-line"},d,{cx:a,cy:i,r:o}));var u=this.props.ticks,f=u.map(function(h){return Ut(a,i,o,h.coordinate)});return F.createElement(e9,xc({className:"recharts-polar-angle-axis-line"},d,{points:f}))}},{key:"renderTicks",value:function(){var s=this,a=this.props,i=a.ticks,o=a.tick,l=a.tickLine,c=a.tickFormatter,d=a.stroke,u=st(this.props,!1),f=st(o,!1),h=lc(lc({},u),{},{fill:"none"},st(l,!1)),m=i.map(function(y,x){var j=s.getTickLineCoord(y),v=s.getTickTextAnchor(y),g=lc(lc(lc({textAnchor:v},u),{},{stroke:"none",fill:d},f),{},{index:x,payload:y,x:j.x2,y:j.y2});return F.createElement(Tt,xc({className:gt("recharts-polar-angle-axis-tick",Fq(o)),key:"tick-".concat(y.coordinate)},ad(s.props,y,x)),l&&F.createElement("line",xc({className:"recharts-polar-angle-axis-tick-line"},h,j)),o&&t.renderTickItem(o,g,c?c(y.value,x):y.value))});return F.createElement(Tt,{className:"recharts-polar-angle-axis-ticks"},m)}},{key:"render",value:function(){var s=this.props,a=s.ticks,i=s.radius,o=s.axisLine;return i<=0||!a||!a.length?null:F.createElement(Tt,{className:gt("recharts-polar-angle-axis",this.props.className)},o&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(s,a,i){var o;return F.isValidElement(s)?o=F.cloneElement(s,a):ft(s)?o=s(a):o=F.createElement(od,xc({},a,{className:"recharts-polar-angle-axis-tick-value"}),i),o}}])}(p.PureComponent);p0(Ed,"displayName","PolarAngleAxis");p0(Ed,"axisType","angleAxis");p0(Ed,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var uTe=iV,fTe=uTe(Object.getPrototypeOf,Object),mTe=fTe,hTe=Co,pTe=mTe,xTe=ko,gTe="[object Object]",vTe=Function.prototype,yTe=Object.prototype,a9=vTe.toString,jTe=yTe.hasOwnProperty,bTe=a9.call(Object);function wTe(e){if(!xTe(e)||hTe(e)!=gTe)return!1;var t=pTe(e);if(t===null)return!0;var r=jTe.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&a9.call(r)==bTe}var NTe=wTe;const STe=Gt(NTe);var _Te=Co,CTe=ko,kTe="[object Boolean]";function PTe(e){return e===!0||e===!1||CTe(e)&&_Te(e)==kTe}var ATe=PTe;const ETe=Gt(ATe);function Ep(e){"@babel/helpers - typeof";return Ep=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ep(e)}function Iy(){return Iy=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,s=new Array(t);r0,from:{upperWidth:0,lowerWidth:0,height:h,x:c,y:d},to:{upperWidth:u,lowerWidth:f,height:h,x:c,y:d},duration:x,animationEasing:y,isActive:v},function(b){var N=b.upperWidth,w=b.lowerWidth,S=b.height,_=b.x,C=b.y;return F.createElement(Ua,{canBegin:o>0,from:"0px ".concat(o===-1?1:o,"px"),to:"".concat(o,"px 0px"),attributeName:"strokeDasharray",begin:j,duration:x,easing:y},F.createElement("path",Iy({},st(r,!0),{className:g,d:wR(_,C,N,w,S),ref:s})))}):F.createElement("g",null,F.createElement("path",Iy({},st(r,!0),{className:g,d:wR(c,d,u,f,h)})))},zTe=["option","shapeType","propTransformer","activeClassName","isActive"];function Op(e){"@babel/helpers - typeof";return Op=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Op(e)}function VTe(e,t){if(e==null)return{};var r=qTe(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function qTe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function NR(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function Dy(e){for(var t=1;t0?Ds(b,"paddingAngle",0):0;if(w){var _=Nr(w.endAngle-w.startAngle,b.endAngle-b.startAngle),C=dn(dn({},b),{},{startAngle:g+S,endAngle:g+_(x)+S});j.push(C),g=C.endAngle}else{var P=b.endAngle,D=b.startAngle,z=Nr(0,P-D),O=z(x),V=dn(dn({},b),{},{startAngle:g+S,endAngle:g+O+S});j.push(V),g=V.endAngle}}),F.createElement(Tt,null,s.renderSectorsStatically(j))})}},{key:"attachKeyboardHandlers",value:function(s){var a=this;s.onkeydown=function(i){if(!i.altKey)switch(i.key){case"ArrowLeft":{var o=++a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[o].focus(),a.setState({sectorToFocus:o});break}case"ArrowRight":{var l=--a.state.sectorToFocus<0?a.sectorRefs.length-1:a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[l].focus(),a.setState({sectorToFocus:l});break}case"Escape":{a.sectorRefs[a.state.sectorToFocus].blur(),a.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var s=this.props,a=s.sectors,i=s.isAnimationActive,o=this.state.prevSectors;return i&&a&&a.length&&(!o||!fm(o,a))?this.renderSectorsWithAnimation():this.renderSectorsStatically(a)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var s=this,a=this.props,i=a.hide,o=a.sectors,l=a.className,c=a.label,d=a.cx,u=a.cy,f=a.innerRadius,h=a.outerRadius,m=a.isAnimationActive,y=this.state.isAnimationFinished;if(i||!o||!o.length||!Te(d)||!Te(u)||!Te(f)||!Te(h))return null;var x=gt("recharts-pie",l);return F.createElement(Tt,{tabIndex:this.props.rootTabIndex,className:x,ref:function(v){s.pieRef=v}},this.renderSectors(),c&&this.renderLabels(o),vr.renderCallByParent(this.props,null,!1),(!m||y)&&xi.renderCallByParent(this.props,o,!1))}}],[{key:"getDerivedStateFromProps",value:function(s,a){return a.prevIsAnimationActive!==s.isAnimationActive?{prevIsAnimationActive:s.isAnimationActive,prevAnimationId:s.animationId,curSectors:s.sectors,prevSectors:[],isAnimationFinished:!0}:s.isAnimationActive&&s.animationId!==a.prevAnimationId?{prevAnimationId:s.animationId,curSectors:s.sectors,prevSectors:a.curSectors,isAnimationFinished:!0}:s.sectors!==a.curSectors?{curSectors:s.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(s,a){return s>a?"start":s=360?g:g-1)*c,N=j-g*m-b,w=a.reduce(function(C,P){var D=Vn(P,v,0);return C+(Te(D)?D:0)},0),S;if(w>0){var _;S=a.map(function(C,P){var D=Vn(C,v,0),z=Vn(C,u,P),O=(Te(D)?D:0)/w,V;P?V=_.endAngle+Yr(x)*c*(D!==0?1:0):V=o;var A=V+Yr(x)*((D!==0?m:0)+O*N),$=(V+A)/2,B=(y.innerRadius+y.outerRadius)/2,I=[{name:z,value:D,payload:C,dataKey:v,type:h}],k=Ut(y.cx,y.cy,B,$);return _=dn(dn(dn({percent:O,cornerRadius:i,name:z,tooltipPayload:I,midAngle:$,middleRadius:B,tooltipPosition:k},C),y),{},{value:Vn(C,v),startAngle:V,endAngle:A,payload:C,paddingAngle:Yr(x)*c}),_})}return dn(dn({},y),{},{sectors:S,data:a})});function dMe(e){return e&&e.length?e[0]:void 0}var uMe=dMe,fMe=uMe;const mMe=Gt(fMe);var hMe=["key"];function yf(e){"@babel/helpers - typeof";return yf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yf(e)}function pMe(e,t){if(e==null)return{};var r=xMe(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function xMe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function Fy(){return Fy=Object.assign?Object.assign.bind():function(e){for(var t=1;t=2&&(c=!0),d.push(qr(qr({},Ut(o,l,g,j)),{},{name:y,value:x,cx:o,cy:l,radius:g,angle:j,payload:h}))});var f=[];return c&&d.forEach(function(h){if(Array.isArray(h.value)){var m=mMe(h.value),y=yt(m)?void 0:t.scale(m);f.push(qr(qr({},h),{},{radius:y},Ut(o,l,y,h.angle)))}else f.push(h)}),{points:d,isRange:c,baseLinePoints:f}});var SMe=Math.ceil,_Me=Math.max;function CMe(e,t,r,s){for(var a=-1,i=_Me(SMe((t-e)/(r||1)),0),o=Array(i);i--;)o[s?i:++a]=e,e+=r;return o}var kMe=CMe,PMe=_V,AR=1/0,AMe=17976931348623157e292;function EMe(e){if(!e)return e===0?e:0;if(e=PMe(e),e===AR||e===-AR){var t=e<0?-1:1;return t*AMe}return e===e?e:0}var u9=EMe,OMe=kMe,TMe=n0,gN=u9;function MMe(e){return function(t,r,s){return s&&typeof s!="number"&&TMe(t,r,s)&&(r=s=void 0),t=gN(t),r===void 0?(r=t,t=0):r=gN(r),s=s===void 0?t0&&s.handleDrag(a.changedTouches[0])}),_s(s,"handleDragEnd",function(){s.setState({isTravellerMoving:!1,isSlideMoving:!1},function(){var a=s.props,i=a.endIndex,o=a.onDragEnd,l=a.startIndex;o==null||o({endIndex:i,startIndex:l})}),s.detachDragEndListener()}),_s(s,"handleLeaveWrapper",function(){(s.state.isTravellerMoving||s.state.isSlideMoving)&&(s.leaveTimer=window.setTimeout(s.handleDragEnd,s.props.leaveTimeOut))}),_s(s,"handleEnterSlideOrTraveller",function(){s.setState({isTextActive:!0})}),_s(s,"handleLeaveSlideOrTraveller",function(){s.setState({isTextActive:!1})}),_s(s,"handleSlideDragStart",function(a){var i=RR(a)?a.changedTouches[0]:a;s.setState({isTravellerMoving:!1,isSlideMoving:!0,slideMoveStartX:i.pageX}),s.attachDragEndListener()}),s.travellerDragStartHandlers={startX:s.handleTravellerDragStart.bind(s,"startX"),endX:s.handleTravellerDragStart.bind(s,"endX")},s.state={},s}return GMe(t,e),qMe(t,[{key:"componentWillUnmount",value:function(){this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),this.detachDragEndListener()}},{key:"getIndex",value:function(s){var a=s.startX,i=s.endX,o=this.state.scaleValues,l=this.props,c=l.gap,d=l.data,u=d.length-1,f=Math.min(a,i),h=Math.max(a,i),m=t.getIndexInRange(o,f),y=t.getIndexInRange(o,h);return{startIndex:m-m%c,endIndex:y===u?u:y-y%c}}},{key:"getTextOfTick",value:function(s){var a=this.props,i=a.data,o=a.tickFormatter,l=a.dataKey,c=Vn(i[s],l,s);return ft(o)?o(c,s):c}},{key:"attachDragEndListener",value:function(){window.addEventListener("mouseup",this.handleDragEnd,!0),window.addEventListener("touchend",this.handleDragEnd,!0),window.addEventListener("mousemove",this.handleDrag,!0)}},{key:"detachDragEndListener",value:function(){window.removeEventListener("mouseup",this.handleDragEnd,!0),window.removeEventListener("touchend",this.handleDragEnd,!0),window.removeEventListener("mousemove",this.handleDrag,!0)}},{key:"handleSlideDrag",value:function(s){var a=this.state,i=a.slideMoveStartX,o=a.startX,l=a.endX,c=this.props,d=c.x,u=c.width,f=c.travellerWidth,h=c.startIndex,m=c.endIndex,y=c.onChange,x=s.pageX-i;x>0?x=Math.min(x,d+u-f-l,d+u-f-o):x<0&&(x=Math.max(x,d-o,d-l));var j=this.getIndex({startX:o+x,endX:l+x});(j.startIndex!==h||j.endIndex!==m)&&y&&y(j),this.setState({startX:o+x,endX:l+x,slideMoveStartX:s.pageX})}},{key:"handleTravellerDragStart",value:function(s,a){var i=RR(a)?a.changedTouches[0]:a;this.setState({isSlideMoving:!1,isTravellerMoving:!0,movingTravellerId:s,brushMoveStartX:i.pageX}),this.attachDragEndListener()}},{key:"handleTravellerMove",value:function(s){var a=this.state,i=a.brushMoveStartX,o=a.movingTravellerId,l=a.endX,c=a.startX,d=this.state[o],u=this.props,f=u.x,h=u.width,m=u.travellerWidth,y=u.onChange,x=u.gap,j=u.data,v={startX:this.state.startX,endX:this.state.endX},g=s.pageX-i;g>0?g=Math.min(g,f+h-m-d):g<0&&(g=Math.max(g,f-d)),v[o]=d+g;var b=this.getIndex(v),N=b.startIndex,w=b.endIndex,S=function(){var C=j.length-1;return o==="startX"&&(l>c?N%x===0:w%x===0)||lc?w%x===0:N%x===0)||l>c&&w===C};this.setState(_s(_s({},o,d+g),"brushMoveStartX",s.pageX),function(){y&&S()&&y(b)})}},{key:"handleTravellerMoveKeyboard",value:function(s,a){var i=this,o=this.state,l=o.scaleValues,c=o.startX,d=o.endX,u=this.state[a],f=l.indexOf(u);if(f!==-1){var h=f+s;if(!(h===-1||h>=l.length)){var m=l[h];a==="startX"&&m>=d||a==="endX"&&m<=c||this.setState(_s({},a,m),function(){i.props.onChange(i.getIndex({startX:i.state.startX,endX:i.state.endX}))})}}}},{key:"renderBackground",value:function(){var s=this.props,a=s.x,i=s.y,o=s.width,l=s.height,c=s.fill,d=s.stroke;return F.createElement("rect",{stroke:d,fill:c,x:a,y:i,width:o,height:l})}},{key:"renderPanorama",value:function(){var s=this.props,a=s.x,i=s.y,o=s.width,l=s.height,c=s.data,d=s.children,u=s.padding,f=p.Children.only(d);return f?F.cloneElement(f,{x:a,y:i,width:o,height:l,margin:u,compact:!0,data:c}):null}},{key:"renderTravellerLayer",value:function(s,a){var i,o,l=this,c=this.props,d=c.y,u=c.travellerWidth,f=c.height,h=c.traveller,m=c.ariaLabel,y=c.data,x=c.startIndex,j=c.endIndex,v=Math.max(s,this.props.x),g=vN(vN({},st(this.props,!1)),{},{x:v,y:d,width:u,height:f}),b=m||"Min value: ".concat((i=y[x])===null||i===void 0?void 0:i.name,", Max value: ").concat((o=y[j])===null||o===void 0?void 0:o.name);return F.createElement(Tt,{tabIndex:0,role:"slider","aria-label":b,"aria-valuenow":s,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[a],onTouchStart:this.travellerDragStartHandlers[a],onKeyDown:function(w){["ArrowLeft","ArrowRight"].includes(w.key)&&(w.preventDefault(),w.stopPropagation(),l.handleTravellerMoveKeyboard(w.key==="ArrowRight"?1:-1,a))},onFocus:function(){l.setState({isTravellerFocused:!0})},onBlur:function(){l.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},t.renderTraveller(h,g))}},{key:"renderSlide",value:function(s,a){var i=this.props,o=i.y,l=i.height,c=i.stroke,d=i.travellerWidth,u=Math.min(s,a)+d,f=Math.max(Math.abs(a-s)-d,0);return F.createElement("rect",{className:"recharts-brush-slide",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.handleSlideDragStart,onTouchStart:this.handleSlideDragStart,style:{cursor:"move"},stroke:"none",fill:c,fillOpacity:.2,x:u,y:o,width:f,height:l})}},{key:"renderText",value:function(){var s=this.props,a=s.startIndex,i=s.endIndex,o=s.y,l=s.height,c=s.travellerWidth,d=s.stroke,u=this.state,f=u.startX,h=u.endX,m=5,y={pointerEvents:"none",fill:d};return F.createElement(Tt,{className:"recharts-brush-texts"},F.createElement(od,Vy({textAnchor:"end",verticalAnchor:"middle",x:Math.min(f,h)-m,y:o+l/2},y),this.getTextOfTick(a)),F.createElement(od,Vy({textAnchor:"start",verticalAnchor:"middle",x:Math.max(f,h)+c+m,y:o+l/2},y),this.getTextOfTick(i)))}},{key:"render",value:function(){var s=this.props,a=s.data,i=s.className,o=s.children,l=s.x,c=s.y,d=s.width,u=s.height,f=s.alwaysShowText,h=this.state,m=h.startX,y=h.endX,x=h.isTextActive,j=h.isSlideMoving,v=h.isTravellerMoving,g=h.isTravellerFocused;if(!a||!a.length||!Te(l)||!Te(c)||!Te(d)||!Te(u)||d<=0||u<=0)return null;var b=gt("recharts-brush",i),N=F.Children.count(o)===1,w=zMe("userSelect","none");return F.createElement(Tt,{className:b,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:w},this.renderBackground(),N&&this.renderPanorama(),this.renderSlide(m,y),this.renderTravellerLayer(m,"startX"),this.renderTravellerLayer(y,"endX"),(x||j||v||g||f)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(s){var a=s.x,i=s.y,o=s.width,l=s.height,c=s.stroke,d=Math.floor(i+l/2)-1;return F.createElement(F.Fragment,null,F.createElement("rect",{x:a,y:i,width:o,height:l,fill:c,stroke:"none"}),F.createElement("line",{x1:a+1,y1:d,x2:a+o-1,y2:d,fill:"none",stroke:"#fff"}),F.createElement("line",{x1:a+1,y1:d+2,x2:a+o-1,y2:d+2,fill:"none",stroke:"#fff"}))}},{key:"renderTraveller",value:function(s,a){var i;return F.isValidElement(s)?i=F.cloneElement(s,a):ft(s)?i=s(a):i=t.renderDefaultTraveller(a),i}},{key:"getDerivedStateFromProps",value:function(s,a){var i=s.data,o=s.width,l=s.x,c=s.travellerWidth,d=s.updateId,u=s.startIndex,f=s.endIndex;if(i!==a.prevData||d!==a.prevUpdateId)return vN({prevData:i,prevTravellerWidth:c,prevUpdateId:d,prevX:l,prevWidth:o},i&&i.length?QMe({data:i,width:o,x:l,travellerWidth:c,startIndex:u,endIndex:f}):{scale:null,scaleValues:null});if(a.scale&&(o!==a.prevWidth||l!==a.prevX||c!==a.prevTravellerWidth)){a.scale.range([l,l+o-c]);var h=a.scale.domain().map(function(m){return a.scale(m)});return{prevData:i,prevTravellerWidth:c,prevUpdateId:d,prevX:l,prevWidth:o,startX:a.scale(s.startIndex),endX:a.scale(s.endIndex),scaleValues:h}}return null}},{key:"getIndexInRange",value:function(s,a){for(var i=s.length,o=0,l=i-1;l-o>1;){var c=Math.floor((o+l)/2);s[c]>a?l=c:o=c}return a>=s[l]?l:o}}])}(p.PureComponent);_s(bf,"displayName","Brush");_s(bf,"defaultProps",{height:40,travellerWidth:5,gap:1,fill:"#fff",stroke:"#666",padding:{top:1,right:1,bottom:1,left:1},leaveTimeOut:1e3,alwaysShowText:!1});var YMe=uP;function XMe(e,t){var r;return YMe(e,function(s,a,i){return r=t(s,a,i),!r}),!!r}var ZMe=XMe,JMe=Zz,e4e=Oi,t4e=ZMe,n4e=Ns,r4e=n0;function s4e(e,t,r){var s=n4e(e)?JMe:t4e;return r&&r4e(e,t,r)&&(t=void 0),s(e,e4e(t))}var a4e=s4e;const i4e=Gt(a4e);var gi=function(t,r){var s=t.alwaysShow,a=t.ifOverflow;return s&&(a="extendDomain"),a===r},$R=jV;function o4e(e,t,r){t=="__proto__"&&$R?$R(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var l4e=o4e,c4e=l4e,d4e=vV,u4e=Oi;function f4e(e,t){var r={};return t=u4e(t),d4e(e,function(s,a,i){c4e(r,a,t(s,a,i))}),r}var m4e=f4e;const h4e=Gt(m4e);function p4e(e,t){for(var r=-1,s=e==null?0:e.length;++r=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function T4e(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function M4e(e,t){var r=e.x,s=e.y,a=O4e(e,k4e),i="".concat(r),o=parseInt(i,10),l="".concat(s),c=parseInt(l,10),d="".concat(t.height||a.height),u=parseInt(d,10),f="".concat(t.width||a.width),h=parseInt(f,10);return Wm(Wm(Wm(Wm(Wm({},t),a),o?{x:o}:{}),c?{y:c}:{}),{},{height:u,width:h,name:t.name,radius:t.radius})}function DR(e){return F.createElement(i9,B_({shapeType:"rectangle",propTransformer:M4e,activeClassName:"recharts-active-bar"},e))}var R4e=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return function(s,a){if(typeof t=="number")return t;var i=Te(s)||Mpe(s);return i?t(s,a):(i||cd(),r)}},$4e=["value","background"],x9;function wf(e){"@babel/helpers - typeof";return wf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wf(e)}function I4e(e,t){if(e==null)return{};var r=D4e(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function D4e(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function Wy(){return Wy=Object.assign?Object.assign.bind():function(e){for(var t=1;t0&&Math.abs($)0&&Math.abs(A)0&&(V=Math.min((te||0)-(A[xe-1]||0),V))}),Number.isFinite(V)){var $=V/O,B=x.layout==="vertical"?s.height:s.width;if(x.padding==="gap"&&(_=$*B/2),x.padding==="no-gap"){var I=Xr(t.barCategoryGap,$*B),k=$*B/2;_=k-I-(k-I)/B*I}}}a==="xAxis"?C=[s.left+(b.left||0)+(_||0),s.left+s.width-(b.right||0)-(_||0)]:a==="yAxis"?C=c==="horizontal"?[s.top+s.height-(b.bottom||0),s.top+(b.top||0)]:[s.top+(b.top||0)+(_||0),s.top+s.height-(b.bottom||0)-(_||0)]:C=x.range,w&&(C=[C[1],C[0]]);var M=Oq(x,i,h),K=M.scale,X=M.realScaleType;K.domain(v).range(C),Tq(K);var re=Mq(K,Pa(Pa({},x),{},{realScaleType:X}));a==="xAxis"?(z=j==="top"&&!N||j==="bottom"&&N,P=s.left,D=f[S]-z*x.height):a==="yAxis"&&(z=j==="left"&&!N||j==="right"&&N,P=f[S]-z*x.width,D=s.top);var Z=Pa(Pa(Pa({},x),re),{},{realScaleType:X,x:P,y:D,scale:K,width:a==="xAxis"?s.width:x.width,height:a==="yAxis"?s.height:x.height});return Z.bandSize=_y(Z,re),!x.hide&&a==="xAxis"?f[S]+=(z?-1:1)*Z.height:x.hide||(f[S]+=(z?-1:1)*Z.width),Pa(Pa({},m),{},v0({},y,Z))},{})},b9=function(t,r){var s=t.x,a=t.y,i=r.x,o=r.y;return{x:Math.min(s,i),y:Math.min(a,o),width:Math.abs(i-s),height:Math.abs(o-a)}},H4e=function(t){var r=t.x1,s=t.y1,a=t.x2,i=t.y2;return b9({x:r,y:s},{x:a,y:i})},w9=function(){function e(t){U4e(this,e),this.scale=t}return K4e(e,[{key:"domain",get:function(){return this.scale.domain}},{key:"range",get:function(){return this.scale.range}},{key:"rangeMin",get:function(){return this.range()[0]}},{key:"rangeMax",get:function(){return this.range()[1]}},{key:"bandwidth",get:function(){return this.scale.bandwidth}},{key:"apply",value:function(r){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=s.bandAware,i=s.position;if(r!==void 0){if(i)switch(i){case"start":return this.scale(r);case"middle":{var o=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+o}case"end":{var l=this.bandwidth?this.bandwidth():0;return this.scale(r)+l}default:return this.scale(r)}if(a){var c=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+c}return this.scale(r)}}},{key:"isInRange",value:function(r){var s=this.range(),a=s[0],i=s[s.length-1];return a<=i?r>=a&&r<=i:r>=i&&r<=a}}],[{key:"create",value:function(r){return new e(r)}}])}();v0(w9,"EPS",1e-4);var zP=function(t){var r=Object.keys(t).reduce(function(s,a){return Pa(Pa({},s),{},v0({},a,w9.create(t[a])))},{});return Pa(Pa({},r),{},{apply:function(a){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.bandAware,l=i.position;return h4e(a,function(c,d){return r[d].apply(c,{bandAware:o,position:l})})},isInRange:function(a){return p9(a,function(i,o){return r[o].isInRange(i)})}})};function Q4e(e){return(e%180+180)%180}var Y4e=function(t){var r=t.width,s=t.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=Q4e(a),o=i*Math.PI/180,l=Math.atan(s/r),c=o>l&&o-1?a[i?t[o]:o]:void 0}}var tRe=eRe,nRe=u9;function rRe(e){var t=nRe(e),r=t%1;return t===t?r?t-r:t:0}var sRe=rRe,aRe=fV,iRe=Oi,oRe=sRe,lRe=Math.max;function cRe(e,t,r){var s=e==null?0:e.length;if(!s)return-1;var a=r==null?0:oRe(r);return a<0&&(a=lRe(s+a,0)),aRe(e,iRe(t),a)}var dRe=cRe,uRe=tRe,fRe=dRe,mRe=uRe(fRe),hRe=mRe;const pRe=Gt(hRe);var xRe=Fhe(function(e){return{x:e.left,y:e.top,width:e.width,height:e.height}},function(e){return["l",e.left,"t",e.top,"w",e.width,"h",e.height].join("")}),VP=p.createContext(void 0),qP=p.createContext(void 0),N9=p.createContext(void 0),S9=p.createContext({}),_9=p.createContext(void 0),C9=p.createContext(0),k9=p.createContext(0),VR=function(t){var r=t.state,s=r.xAxisMap,a=r.yAxisMap,i=r.offset,o=t.clipPathId,l=t.children,c=t.width,d=t.height,u=xRe(i);return F.createElement(VP.Provider,{value:s},F.createElement(qP.Provider,{value:a},F.createElement(S9.Provider,{value:i},F.createElement(N9.Provider,{value:u},F.createElement(_9.Provider,{value:o},F.createElement(C9.Provider,{value:d},F.createElement(k9.Provider,{value:c},l)))))))},gRe=function(){return p.useContext(_9)},P9=function(t){var r=p.useContext(VP);r==null&&cd();var s=r[t];return s==null&&cd(),s},vRe=function(){var t=p.useContext(VP);return Qo(t)},yRe=function(){var t=p.useContext(qP),r=pRe(t,function(s){return p9(s.domain,Number.isFinite)});return r||Qo(t)},A9=function(t){var r=p.useContext(qP);r==null&&cd();var s=r[t];return s==null&&cd(),s},jRe=function(){var t=p.useContext(N9);return t},bRe=function(){return p.useContext(S9)},WP=function(){return p.useContext(k9)},UP=function(){return p.useContext(C9)};function Nf(e){"@babel/helpers - typeof";return Nf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Nf(e)}function wRe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function NRe(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,s=new Array(t);re*a)return!1;var i=r();return e*(t-e*i/2-s)>=0&&e*(t+e*i/2-a)<=0}function s$e(e,t){return I9(e,t+1)}function a$e(e,t,r,s,a){for(var i=(s||[]).slice(),o=t.start,l=t.end,c=0,d=1,u=o,f=function(){var y=s==null?void 0:s[c];if(y===void 0)return{v:I9(s,d)};var x=c,j,v=function(){return j===void 0&&(j=r(y,x)),j},g=y.coordinate,b=c===0||Qy(e,g,v,u,l);b||(c=0,u=o,d+=1),b&&(u=g+e*(v()/2+a),c+=d)},h;d<=i.length;)if(h=f(),h)return h.v;return[]}function Ip(e){"@babel/helpers - typeof";return Ip=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ip(e)}function YR(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function Ir(e){for(var t=1;t0?m.coordinate-j*e:m.coordinate})}else i[h]=m=Ir(Ir({},m),{},{tickCoord:m.coordinate});var v=Qy(e,m.tickCoord,x,l,c);v&&(c=m.tickCoord-e*(x()/2+a),i[h]=Ir(Ir({},m),{},{isShow:!0}))},u=o-1;u>=0;u--)d(u);return i}function d$e(e,t,r,s,a,i){var o=(s||[]).slice(),l=o.length,c=t.start,d=t.end;if(i){var u=s[l-1],f=r(u,l-1),h=e*(u.coordinate+e*f/2-d);o[l-1]=u=Ir(Ir({},u),{},{tickCoord:h>0?u.coordinate-h*e:u.coordinate});var m=Qy(e,u.tickCoord,function(){return f},c,d);m&&(d=u.tickCoord-e*(f/2+a),o[l-1]=Ir(Ir({},u),{},{isShow:!0}))}for(var y=i?l-1:l,x=function(g){var b=o[g],N,w=function(){return N===void 0&&(N=r(b,g)),N};if(g===0){var S=e*(b.coordinate-e*w()/2-c);o[g]=b=Ir(Ir({},b),{},{tickCoord:S<0?b.coordinate-S*e:b.coordinate})}else o[g]=b=Ir(Ir({},b),{},{tickCoord:b.coordinate});var _=Qy(e,b.tickCoord,w,c,d);_&&(c=b.tickCoord+e*(w()/2+a),o[g]=Ir(Ir({},b),{},{isShow:!0}))},j=0;j=2?Yr(a[1].coordinate-a[0].coordinate):1,v=r$e(i,j,m);return c==="equidistantPreserveStart"?a$e(j,v,x,a,o):(c==="preserveStart"||c==="preserveStartEnd"?h=d$e(j,v,x,a,o,c==="preserveStartEnd"):h=c$e(j,v,x,a,o),h.filter(function(g){return g.isShow}))}var u$e=["viewBox"],f$e=["viewBox"],m$e=["ticks"];function Cf(e){"@babel/helpers - typeof";return Cf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Cf(e)}function uu(){return uu=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function h$e(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function p$e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ZR(e,t){for(var r=0;r0?c(this.props):c(m)),o<=0||l<=0||!y||!y.length?null:F.createElement(Tt,{className:gt("recharts-cartesian-axis",d),ref:function(j){s.layerReference=j}},i&&this.renderAxisLine(),this.renderTicks(y,this.state.fontSize,this.state.letterSpacing),vr.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(s,a,i){var o,l=gt(a.className,"recharts-cartesian-axis-tick-value");return F.isValidElement(s)?o=F.cloneElement(s,tr(tr({},a),{},{className:l})):ft(s)?o=s(tr(tr({},a),{},{className:l})):o=F.createElement(od,uu({},a,{className:"recharts-cartesian-axis-tick-value"}),i),o}}])}(p.Component);QP(xm,"displayName","CartesianAxis");QP(xm,"defaultProps",{x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd"});var w$e=["x1","y1","x2","y2","key"],N$e=["offset"];function dd(e){"@babel/helpers - typeof";return dd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dd(e)}function JR(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function Lr(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function k$e(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}var P$e=function(t){var r=t.fill;if(!r||r==="none")return null;var s=t.fillOpacity,a=t.x,i=t.y,o=t.width,l=t.height,c=t.ry;return F.createElement("rect",{x:a,y:i,ry:c,width:o,height:l,stroke:"none",fill:r,fillOpacity:s,className:"recharts-cartesian-grid-bg"})};function F9(e,t){var r;if(F.isValidElement(e))r=F.cloneElement(e,t);else if(ft(e))r=e(t);else{var s=t.x1,a=t.y1,i=t.x2,o=t.y2,l=t.key,c=e$(t,w$e),d=st(c,!1);d.offset;var u=e$(d,N$e);r=F.createElement("line",Cc({},u,{x1:s,y1:a,x2:i,y2:o,fill:"none",key:l}))}return r}function A$e(e){var t=e.x,r=e.width,s=e.horizontal,a=s===void 0?!0:s,i=e.horizontalPoints;if(!a||!i||!i.length)return null;var o=i.map(function(l,c){var d=Lr(Lr({},e),{},{x1:t,y1:l,x2:t+r,y2:l,key:"line-".concat(c),index:c});return F9(a,d)});return F.createElement("g",{className:"recharts-cartesian-grid-horizontal"},o)}function E$e(e){var t=e.y,r=e.height,s=e.vertical,a=s===void 0?!0:s,i=e.verticalPoints;if(!a||!i||!i.length)return null;var o=i.map(function(l,c){var d=Lr(Lr({},e),{},{x1:l,y1:t,x2:l,y2:t+r,key:"line-".concat(c),index:c});return F9(a,d)});return F.createElement("g",{className:"recharts-cartesian-grid-vertical"},o)}function O$e(e){var t=e.horizontalFill,r=e.fillOpacity,s=e.x,a=e.y,i=e.width,o=e.height,l=e.horizontalPoints,c=e.horizontal,d=c===void 0?!0:c;if(!d||!t||!t.length)return null;var u=l.map(function(h){return Math.round(h+a-a)}).sort(function(h,m){return h-m});a!==u[0]&&u.unshift(0);var f=u.map(function(h,m){var y=!u[m+1],x=y?a+o-h:u[m+1]-h;if(x<=0)return null;var j=m%t.length;return F.createElement("rect",{key:"react-".concat(m),y:h,x:s,height:x,width:i,stroke:"none",fill:t[j],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return F.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},f)}function T$e(e){var t=e.vertical,r=t===void 0?!0:t,s=e.verticalFill,a=e.fillOpacity,i=e.x,o=e.y,l=e.width,c=e.height,d=e.verticalPoints;if(!r||!s||!s.length)return null;var u=d.map(function(h){return Math.round(h+i-i)}).sort(function(h,m){return h-m});i!==u[0]&&u.unshift(0);var f=u.map(function(h,m){var y=!u[m+1],x=y?i+l-h:u[m+1]-h;if(x<=0)return null;var j=m%s.length;return F.createElement("rect",{key:"react-".concat(m),x:h,y:o,width:x,height:c,stroke:"none",fill:s[j],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return F.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},f)}var M$e=function(t,r){var s=t.xAxis,a=t.width,i=t.height,o=t.offset;return Eq(HP(Lr(Lr(Lr({},xm.defaultProps),s),{},{ticks:Xi(s,!0),viewBox:{x:0,y:0,width:a,height:i}})),o.left,o.left+o.width,r)},R$e=function(t,r){var s=t.yAxis,a=t.width,i=t.height,o=t.offset;return Eq(HP(Lr(Lr(Lr({},xm.defaultProps),s),{},{ticks:Xi(s,!0),viewBox:{x:0,y:0,width:a,height:i}})),o.top,o.top+o.height,r)},qd={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function bs(e){var t,r,s,a,i,o,l=WP(),c=UP(),d=bRe(),u=Lr(Lr({},e),{},{stroke:(t=e.stroke)!==null&&t!==void 0?t:qd.stroke,fill:(r=e.fill)!==null&&r!==void 0?r:qd.fill,horizontal:(s=e.horizontal)!==null&&s!==void 0?s:qd.horizontal,horizontalFill:(a=e.horizontalFill)!==null&&a!==void 0?a:qd.horizontalFill,vertical:(i=e.vertical)!==null&&i!==void 0?i:qd.vertical,verticalFill:(o=e.verticalFill)!==null&&o!==void 0?o:qd.verticalFill,x:Te(e.x)?e.x:d.left,y:Te(e.y)?e.y:d.top,width:Te(e.width)?e.width:d.width,height:Te(e.height)?e.height:d.height}),f=u.x,h=u.y,m=u.width,y=u.height,x=u.syncWithTicks,j=u.horizontalValues,v=u.verticalValues,g=vRe(),b=yRe();if(!Te(m)||m<=0||!Te(y)||y<=0||!Te(f)||f!==+f||!Te(h)||h!==+h)return null;var N=u.verticalCoordinatesGenerator||M$e,w=u.horizontalCoordinatesGenerator||R$e,S=u.horizontalPoints,_=u.verticalPoints;if((!S||!S.length)&&ft(w)){var C=j&&j.length,P=w({yAxis:b?Lr(Lr({},b),{},{ticks:C?j:b.ticks}):void 0,width:l,height:c,offset:d},C?!0:x);La(Array.isArray(P),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(dd(P),"]")),Array.isArray(P)&&(S=P)}if((!_||!_.length)&&ft(N)){var D=v&&v.length,z=N({xAxis:g?Lr(Lr({},g),{},{ticks:D?v:g.ticks}):void 0,width:l,height:c,offset:d},D?!0:x);La(Array.isArray(z),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(dd(z),"]")),Array.isArray(z)&&(_=z)}return F.createElement("g",{className:"recharts-cartesian-grid"},F.createElement(P$e,{fill:u.fill,fillOpacity:u.fillOpacity,x:u.x,y:u.y,width:u.width,height:u.height,ry:u.ry}),F.createElement(A$e,Cc({},u,{offset:d,horizontalPoints:S,xAxis:g,yAxis:b})),F.createElement(E$e,Cc({},u,{offset:d,verticalPoints:_,xAxis:g,yAxis:b})),F.createElement(O$e,Cc({},u,{horizontalPoints:S})),F.createElement(T$e,Cc({},u,{verticalPoints:_})))}bs.displayName="CartesianGrid";var $$e=["type","layout","connectNulls","ref"],I$e=["key"];function kf(e){"@babel/helpers - typeof";return kf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kf(e)}function t$(e,t){if(e==null)return{};var r=D$e(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function D$e(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function jh(){return jh=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,s=new Array(t);rf){m=[].concat(Wd(c.slice(0,y)),[f-x]);break}var j=m.length%2===0?[0,h]:[h];return[].concat(Wd(t.repeat(c,u)),Wd(m),j).map(function(v){return"".concat(v,"px")}).join(", ")}),Aa(r,"id",om("recharts-line-")),Aa(r,"pathRef",function(o){r.mainCurve=o}),Aa(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),Aa(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return G$e(t,e),q$e(t,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var s=this.getTotalLength();this.setState({totalLength:s})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var s=this.getTotalLength();s!==this.state.totalLength&&this.setState({totalLength:s})}}},{key:"getTotalLength",value:function(){var s=this.mainCurve;try{return s&&s.getTotalLength&&s.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(s,a){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var i=this.props,o=i.points,l=i.xAxis,c=i.yAxis,d=i.layout,u=i.children,f=Ls(u,Cx);if(!f)return null;var h=function(x,j){return{x:x.x,y:x.y,value:x.value,errorVal:Vn(x.payload,j)}},m={clipPath:s?"url(#clipPath-".concat(a,")"):null};return F.createElement(Tt,m,f.map(function(y){return F.cloneElement(y,{key:"bar-".concat(y.props.dataKey),data:o,xAxis:l,yAxis:c,layout:d,dataPointFormatter:h})}))}},{key:"renderDots",value:function(s,a,i){var o=this.props.isAnimationActive;if(o&&!this.state.isAnimationFinished)return null;var l=this.props,c=l.dot,d=l.points,u=l.dataKey,f=st(this.props,!1),h=st(c,!0),m=d.map(function(x,j){var v=Ss(Ss(Ss({key:"dot-".concat(j),r:3},f),h),{},{index:j,cx:x.x,cy:x.y,value:x.value,dataKey:u,payload:x.payload,points:d});return t.renderDotItem(c,v)}),y={clipPath:s?"url(#clipPath-".concat(a?"":"dots-").concat(i,")"):null};return F.createElement(Tt,jh({className:"recharts-line-dots",key:"dots"},y),m)}},{key:"renderCurveStatically",value:function(s,a,i,o){var l=this.props,c=l.type,d=l.layout,u=l.connectNulls;l.ref;var f=t$(l,$$e),h=Ss(Ss(Ss({},st(f,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(i,")"):null,points:s},o),{},{type:c,layout:d,connectNulls:u});return F.createElement(Py,jh({},h,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(s,a){var i=this,o=this.props,l=o.points,c=o.strokeDasharray,d=o.isAnimationActive,u=o.animationBegin,f=o.animationDuration,h=o.animationEasing,m=o.animationId,y=o.animateNewValues,x=o.width,j=o.height,v=this.state,g=v.prevPoints,b=v.totalLength;return F.createElement(Ua,{begin:u,duration:f,isActive:d,easing:h,from:{t:0},to:{t:1},key:"line-".concat(m),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(N){var w=N.t;if(g){var S=g.length/l.length,_=l.map(function(O,V){var A=Math.floor(V*S);if(g[A]){var $=g[A],B=Nr($.x,O.x),I=Nr($.y,O.y);return Ss(Ss({},O),{},{x:B(w),y:I(w)})}if(y){var k=Nr(x*2,O.x),M=Nr(j/2,O.y);return Ss(Ss({},O),{},{x:k(w),y:M(w)})}return Ss(Ss({},O),{},{x:O.x,y:O.y})});return i.renderCurveStatically(_,s,a)}var C=Nr(0,b),P=C(w),D;if(c){var z="".concat(c).split(/[,\s]+/gim).map(function(O){return parseFloat(O)});D=i.getStrokeDasharray(P,b,z)}else D=i.generateSimpleStrokeDasharray(b,P);return i.renderCurveStatically(l,s,a,{strokeDasharray:D})})}},{key:"renderCurve",value:function(s,a){var i=this.props,o=i.points,l=i.isAnimationActive,c=this.state,d=c.prevPoints,u=c.totalLength;return l&&o&&o.length&&(!d&&u>0||!fm(d,o))?this.renderCurveWithAnimation(s,a):this.renderCurveStatically(o,s,a)}},{key:"render",value:function(){var s,a=this.props,i=a.hide,o=a.dot,l=a.points,c=a.className,d=a.xAxis,u=a.yAxis,f=a.top,h=a.left,m=a.width,y=a.height,x=a.isAnimationActive,j=a.id;if(i||!l||!l.length)return null;var v=this.state.isAnimationFinished,g=l.length===1,b=gt("recharts-line",c),N=d&&d.allowDataOverflow,w=u&&u.allowDataOverflow,S=N||w,_=yt(j)?this.id:j,C=(s=st(o,!1))!==null&&s!==void 0?s:{r:3,strokeWidth:2},P=C.r,D=P===void 0?3:P,z=C.strokeWidth,O=z===void 0?2:z,V=Upe(o)?o:{},A=V.clipDot,$=A===void 0?!0:A,B=D*2+O;return F.createElement(Tt,{className:b},N||w?F.createElement("defs",null,F.createElement("clipPath",{id:"clipPath-".concat(_)},F.createElement("rect",{x:N?h:h-m/2,y:w?f:f-y/2,width:N?m:m*2,height:w?y:y*2})),!$&&F.createElement("clipPath",{id:"clipPath-dots-".concat(_)},F.createElement("rect",{x:h-B/2,y:f-B/2,width:m+B,height:y+B}))):null,!g&&this.renderCurve(S,_),this.renderErrorBar(S,_),(g||o)&&this.renderDots(S,$,_),(!x||v)&&xi.renderCallByParent(this.props,l))}}],[{key:"getDerivedStateFromProps",value:function(s,a){return s.animationId!==a.prevAnimationId?{prevAnimationId:s.animationId,curPoints:s.points,prevPoints:a.curPoints}:s.points!==a.curPoints?{curPoints:s.points}:null}},{key:"repeat",value:function(s,a){for(var i=s.length%2!==0?[].concat(Wd(s),[0]):s,o=[],l=0;le.length)&&(t=e.length);for(var r=0,s=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function IIe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function DIe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function LIe(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,s=new Array(t);r0?o:t&&t.length&&Te(a)&&Te(i)?t.slice(a,i+1):[]};function tW(e){return e==="number"?[0,"auto"]:void 0}var aC=function(t,r,s,a){var i=t.graphicalItems,o=t.tooltipAxis,l=N0(r,t);return s<0||!i||!i.length||s>=l.length?null:i.reduce(function(c,d){var u,f=(u=d.props.data)!==null&&u!==void 0?u:r;f&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=s&&(f=f.slice(t.dataStartIndex,t.dataEndIndex+1));var h;if(o.dataKey&&!o.allowDuplicatedCategory){var m=f===void 0?l:f;h=Yv(m,o.dataKey,a)}else h=f&&f[s]||l[s];return h?[].concat(Of(c),[$q(d,h)]):c},[])},c$=function(t,r,s,a){var i=a||{x:t.chartX,y:t.chartY},o=YIe(i,s),l=t.orderedTooltipTicks,c=t.tooltipAxis,d=t.tooltipTicks,u=K2e(o,l,d,c);if(u>=0&&d){var f=d[u]&&d[u].value,h=aC(t,r,u,f),m=XIe(s,l,u,i);return{activeTooltipIndex:u,activeLabel:f,activePayload:h,activeCoordinate:m}}return null},ZIe=function(t,r){var s=r.axes,a=r.graphicalItems,i=r.axisType,o=r.axisIdKey,l=r.stackGroups,c=r.dataStartIndex,d=r.dataEndIndex,u=t.layout,f=t.children,h=t.stackOffset,m=Aq(u,i);return s.reduce(function(y,x){var j,v=x.type.defaultProps!==void 0?pe(pe({},x.type.defaultProps),x.props):x.props,g=v.type,b=v.dataKey,N=v.allowDataOverflow,w=v.allowDuplicatedCategory,S=v.scale,_=v.ticks,C=v.includeHidden,P=v[o];if(y[P])return y;var D=N0(t.data,{graphicalItems:a.filter(function(re){var Z,te=o in re.props?re.props[o]:(Z=re.type.defaultProps)===null||Z===void 0?void 0:Z[o];return te===P}),dataStartIndex:c,dataEndIndex:d}),z=D.length,O,V,A;SIe(v.domain,N,g)&&(O=v_(v.domain,null,N),m&&(g==="number"||S!=="auto")&&(A=xh(D,b,"category")));var $=tW(g);if(!O||O.length===0){var B,I=(B=v.domain)!==null&&B!==void 0?B:$;if(b){if(O=xh(D,b,g),g==="category"&&m){var k=$pe(O);w&&k?(V=O,O=zy(0,z)):w||(O=O4(I,O,x).reduce(function(re,Z){return re.indexOf(Z)>=0?re:[].concat(Of(re),[Z])},[]))}else if(g==="category")w?O=O.filter(function(re){return re!==""&&!yt(re)}):O=O4(I,O,x).reduce(function(re,Z){return re.indexOf(Z)>=0||Z===""||yt(Z)?re:[].concat(Of(re),[Z])},[]);else if(g==="number"){var M=X2e(D,a.filter(function(re){var Z,te,xe=o in re.props?re.props[o]:(Z=re.type.defaultProps)===null||Z===void 0?void 0:Z[o],me="hide"in re.props?re.props.hide:(te=re.type.defaultProps)===null||te===void 0?void 0:te.hide;return xe===P&&(C||!me)}),b,i,u);M&&(O=M)}m&&(g==="number"||S!=="auto")&&(A=xh(D,b,"category"))}else m?O=zy(0,z):l&&l[P]&&l[P].hasStack&&g==="number"?O=h==="expand"?[0,1]:Rq(l[P].stackGroups,c,d):O=Pq(D,a.filter(function(re){var Z=o in re.props?re.props[o]:re.type.defaultProps[o],te="hide"in re.props?re.props.hide:re.type.defaultProps.hide;return Z===P&&(C||!te)}),g,u,!0);if(g==="number")O=nC(f,O,P,i,_),I&&(O=v_(I,O,N));else if(g==="category"&&I){var K=I,X=O.every(function(re){return K.indexOf(re)>=0});X&&(O=K)}}return pe(pe({},y),{},ht({},P,pe(pe({},v),{},{axisType:i,domain:O,categoricalDomain:A,duplicateDomain:V,originalDomain:(j=v.domain)!==null&&j!==void 0?j:$,isCategorical:m,layout:u})))},{})},JIe=function(t,r){var s=r.graphicalItems,a=r.Axis,i=r.axisType,o=r.axisIdKey,l=r.stackGroups,c=r.dataStartIndex,d=r.dataEndIndex,u=t.layout,f=t.children,h=N0(t.data,{graphicalItems:s,dataStartIndex:c,dataEndIndex:d}),m=h.length,y=Aq(u,i),x=-1;return s.reduce(function(j,v){var g=v.type.defaultProps!==void 0?pe(pe({},v.type.defaultProps),v.props):v.props,b=g[o],N=tW("number");if(!j[b]){x++;var w;return y?w=zy(0,m):l&&l[b]&&l[b].hasStack?(w=Rq(l[b].stackGroups,c,d),w=nC(f,w,b,i)):(w=v_(N,Pq(h,s.filter(function(S){var _,C,P=o in S.props?S.props[o]:(_=S.type.defaultProps)===null||_===void 0?void 0:_[o],D="hide"in S.props?S.props.hide:(C=S.type.defaultProps)===null||C===void 0?void 0:C.hide;return P===b&&!D}),"number",u),a.defaultProps.allowDataOverflow),w=nC(f,w,b,i)),pe(pe({},j),{},ht({},b,pe(pe({axisType:i},a.defaultProps),{},{hide:!0,orientation:Ds(HIe,"".concat(i,".").concat(x%2),null),domain:w,originalDomain:N,isCategorical:y,layout:u})))}return j},{})},eDe=function(t,r){var s=r.axisType,a=s===void 0?"xAxis":s,i=r.AxisComp,o=r.graphicalItems,l=r.stackGroups,c=r.dataStartIndex,d=r.dataEndIndex,u=t.children,f="".concat(a,"Id"),h=Ls(u,i),m={};return h&&h.length?m=ZIe(t,{axes:h,graphicalItems:o,axisType:a,axisIdKey:f,stackGroups:l,dataStartIndex:c,dataEndIndex:d}):o&&o.length&&(m=JIe(t,{Axis:i,graphicalItems:o,axisType:a,axisIdKey:f,stackGroups:l,dataStartIndex:c,dataEndIndex:d})),m},tDe=function(t){var r=Qo(t),s=Xi(r,!1,!0);return{tooltipTicks:s,orderedTooltipTicks:fP(s,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:_y(r,s)}},d$=function(t){var r=t.children,s=t.defaultShowTooltip,a=ks(r,bf),i=0,o=0;return t.data&&t.data.length!==0&&(o=t.data.length-1),a&&a.props&&(a.props.startIndex>=0&&(i=a.props.startIndex),a.props.endIndex>=0&&(o=a.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:i,dataEndIndex:o,activeTooltipIndex:-1,isTooltipActive:!!s}},nDe=function(t){return!t||!t.length?!1:t.some(function(r){var s=eo(r&&r.type);return s&&s.indexOf("Bar")>=0})},u$=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},rDe=function(t,r){var s=t.props,a=t.graphicalItems,i=t.xAxisMap,o=i===void 0?{}:i,l=t.yAxisMap,c=l===void 0?{}:l,d=s.width,u=s.height,f=s.children,h=s.margin||{},m=ks(f,bf),y=ks(f,Sl),x=Object.keys(c).reduce(function(w,S){var _=c[S],C=_.orientation;return!_.mirror&&!_.hide?pe(pe({},w),{},ht({},C,w[C]+_.width)):w},{left:h.left||0,right:h.right||0}),j=Object.keys(o).reduce(function(w,S){var _=o[S],C=_.orientation;return!_.mirror&&!_.hide?pe(pe({},w),{},ht({},C,Ds(w,"".concat(C))+_.height)):w},{top:h.top||0,bottom:h.bottom||0}),v=pe(pe({},j),x),g=v.bottom;m&&(v.bottom+=m.props.height||bf.defaultProps.height),y&&r&&(v=Q2e(v,a,s,r));var b=d-v.left-v.right,N=u-v.top-v.bottom;return pe(pe({brushBottom:g},v),{},{width:Math.max(b,0),height:Math.max(N,0)})},sDe=function(t,r){if(r==="xAxis")return t[r].width;if(r==="yAxis")return t[r].height},S0=function(t){var r=t.chartName,s=t.GraphicalChild,a=t.defaultTooltipEventType,i=a===void 0?"axis":a,o=t.validateTooltipEventTypes,l=o===void 0?["axis"]:o,c=t.axisComponents,d=t.legendContent,u=t.formatAxisMap,f=t.defaultProps,h=function(v,g){var b=g.graphicalItems,N=g.stackGroups,w=g.offset,S=g.updateId,_=g.dataStartIndex,C=g.dataEndIndex,P=v.barSize,D=v.layout,z=v.barGap,O=v.barCategoryGap,V=v.maxBarSize,A=u$(D),$=A.numericAxisName,B=A.cateAxisName,I=nDe(b),k=[];return b.forEach(function(M,K){var X=N0(v.data,{graphicalItems:[M],dataStartIndex:_,dataEndIndex:C}),re=M.type.defaultProps!==void 0?pe(pe({},M.type.defaultProps),M.props):M.props,Z=re.dataKey,te=re.maxBarSize,xe=re["".concat($,"Id")],me=re["".concat(B,"Id")],ne={},_e=c.reduce(function(er,pn){var H=g["".concat(pn.axisType,"Map")],J=re["".concat(pn.axisType,"Id")];H&&H[J]||pn.axisType==="zAxis"||cd();var ce=H[J];return pe(pe({},er),{},ht(ht({},pn.axisType,ce),"".concat(pn.axisType,"Ticks"),Xi(ce)))},ne),ue=_e[B],we=_e["".concat(B,"Ticks")],ve=N&&N[xe]&&N[xe].hasStack&&iPe(M,N[xe].stackGroups),le=eo(M.type).indexOf("Bar")>=0,ut=_y(ue,we),Se=[],Ve=I&&G2e({barSize:P,stackGroups:N,totalSize:sDe(_e,B)});if(le){var pt,Pt,Qt=yt(te)?V:te,kt=(pt=(Pt=_y(ue,we,!0))!==null&&Pt!==void 0?Pt:Qt)!==null&&pt!==void 0?pt:0;Se=H2e({barGap:z,barCategoryGap:O,bandSize:kt!==ut?kt:ut,sizeList:Ve[me],maxBarSize:Qt}),kt!==ut&&(Se=Se.map(function(er){return pe(pe({},er),{},{position:pe(pe({},er.position),{},{offset:er.position.offset-kt/2})})}))}var Pn=M&&M.type&&M.type.getComposedData;Pn&&k.push({props:pe(pe({},Pn(pe(pe({},_e),{},{displayedData:X,props:v,dataKey:Z,item:M,bandSize:ut,barPosition:Se,offset:w,stackedData:ve,layout:D,dataStartIndex:_,dataEndIndex:C}))),{},ht(ht(ht({key:M.key||"item-".concat(K)},$,_e[$]),B,_e[B]),"animationId",S)),childIndex:Hpe(M,v.children),item:M})}),k},m=function(v,g){var b=v.props,N=v.dataStartIndex,w=v.dataEndIndex,S=v.updateId;if(!ST({props:b}))return null;var _=b.children,C=b.layout,P=b.stackOffset,D=b.data,z=b.reverseStackOrder,O=u$(C),V=O.numericAxisName,A=O.cateAxisName,$=Ls(_,s),B=sPe(D,$,"".concat(V,"Id"),"".concat(A,"Id"),P,z),I=c.reduce(function(re,Z){var te="".concat(Z.axisType,"Map");return pe(pe({},re),{},ht({},te,eDe(b,pe(pe({},Z),{},{graphicalItems:$,stackGroups:Z.axisType===V&&B,dataStartIndex:N,dataEndIndex:w}))))},{}),k=rDe(pe(pe({},I),{},{props:b,graphicalItems:$}),g==null?void 0:g.legendBBox);Object.keys(I).forEach(function(re){I[re]=u(b,I[re],k,re.replace("Map",""),r)});var M=I["".concat(A,"Map")],K=tDe(M),X=h(b,pe(pe({},I),{},{dataStartIndex:N,dataEndIndex:w,updateId:S,graphicalItems:$,stackGroups:B,offset:k}));return pe(pe({formattedGraphicalItems:X,graphicalItems:$,offset:k,stackGroups:B},K),I)},y=function(j){function v(g){var b,N,w;return DIe(this,v),w=BIe(this,v,[g]),ht(w,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),ht(w,"accessibilityManager",new NIe),ht(w,"handleLegendBBoxUpdate",function(S){if(S){var _=w.state,C=_.dataStartIndex,P=_.dataEndIndex,D=_.updateId;w.setState(pe({legendBBox:S},m({props:w.props,dataStartIndex:C,dataEndIndex:P,updateId:D},pe(pe({},w.state),{},{legendBBox:S}))))}}),ht(w,"handleReceiveSyncEvent",function(S,_,C){if(w.props.syncId===S){if(C===w.eventEmitterSymbol&&typeof w.props.syncMethod!="function")return;w.applySyncEvent(_)}}),ht(w,"handleBrushChange",function(S){var _=S.startIndex,C=S.endIndex;if(_!==w.state.dataStartIndex||C!==w.state.dataEndIndex){var P=w.state.updateId;w.setState(function(){return pe({dataStartIndex:_,dataEndIndex:C},m({props:w.props,dataStartIndex:_,dataEndIndex:C,updateId:P},w.state))}),w.triggerSyncEvent({dataStartIndex:_,dataEndIndex:C})}}),ht(w,"handleMouseEnter",function(S){var _=w.getMouseInfo(S);if(_){var C=pe(pe({},_),{},{isTooltipActive:!0});w.setState(C),w.triggerSyncEvent(C);var P=w.props.onMouseEnter;ft(P)&&P(C,S)}}),ht(w,"triggeredAfterMouseMove",function(S){var _=w.getMouseInfo(S),C=_?pe(pe({},_),{},{isTooltipActive:!0}):{isTooltipActive:!1};w.setState(C),w.triggerSyncEvent(C);var P=w.props.onMouseMove;ft(P)&&P(C,S)}),ht(w,"handleItemMouseEnter",function(S){w.setState(function(){return{isTooltipActive:!0,activeItem:S,activePayload:S.tooltipPayload,activeCoordinate:S.tooltipPosition||{x:S.cx,y:S.cy}}})}),ht(w,"handleItemMouseLeave",function(){w.setState(function(){return{isTooltipActive:!1}})}),ht(w,"handleMouseMove",function(S){S.persist(),w.throttleTriggeredAfterMouseMove(S)}),ht(w,"handleMouseLeave",function(S){w.throttleTriggeredAfterMouseMove.cancel();var _={isTooltipActive:!1};w.setState(_),w.triggerSyncEvent(_);var C=w.props.onMouseLeave;ft(C)&&C(_,S)}),ht(w,"handleOuterEvent",function(S){var _=Gpe(S),C=Ds(w.props,"".concat(_));if(_&&ft(C)){var P,D;/.*touch.*/i.test(_)?D=w.getMouseInfo(S.changedTouches[0]):D=w.getMouseInfo(S),C((P=D)!==null&&P!==void 0?P:{},S)}}),ht(w,"handleClick",function(S){var _=w.getMouseInfo(S);if(_){var C=pe(pe({},_),{},{isTooltipActive:!0});w.setState(C),w.triggerSyncEvent(C);var P=w.props.onClick;ft(P)&&P(C,S)}}),ht(w,"handleMouseDown",function(S){var _=w.props.onMouseDown;if(ft(_)){var C=w.getMouseInfo(S);_(C,S)}}),ht(w,"handleMouseUp",function(S){var _=w.props.onMouseUp;if(ft(_)){var C=w.getMouseInfo(S);_(C,S)}}),ht(w,"handleTouchMove",function(S){S.changedTouches!=null&&S.changedTouches.length>0&&w.throttleTriggeredAfterMouseMove(S.changedTouches[0])}),ht(w,"handleTouchStart",function(S){S.changedTouches!=null&&S.changedTouches.length>0&&w.handleMouseDown(S.changedTouches[0])}),ht(w,"handleTouchEnd",function(S){S.changedTouches!=null&&S.changedTouches.length>0&&w.handleMouseUp(S.changedTouches[0])}),ht(w,"handleDoubleClick",function(S){var _=w.props.onDoubleClick;if(ft(_)){var C=w.getMouseInfo(S);_(C,S)}}),ht(w,"handleContextMenu",function(S){var _=w.props.onContextMenu;if(ft(_)){var C=w.getMouseInfo(S);_(C,S)}}),ht(w,"triggerSyncEvent",function(S){w.props.syncId!==void 0&&jN.emit(bN,w.props.syncId,S,w.eventEmitterSymbol)}),ht(w,"applySyncEvent",function(S){var _=w.props,C=_.layout,P=_.syncMethod,D=w.state.updateId,z=S.dataStartIndex,O=S.dataEndIndex;if(S.dataStartIndex!==void 0||S.dataEndIndex!==void 0)w.setState(pe({dataStartIndex:z,dataEndIndex:O},m({props:w.props,dataStartIndex:z,dataEndIndex:O,updateId:D},w.state)));else if(S.activeTooltipIndex!==void 0){var V=S.chartX,A=S.chartY,$=S.activeTooltipIndex,B=w.state,I=B.offset,k=B.tooltipTicks;if(!I)return;if(typeof P=="function")$=P(k,S);else if(P==="value"){$=-1;for(var M=0;M=0){var ve,le;if(V.dataKey&&!V.allowDuplicatedCategory){var ut=typeof V.dataKey=="function"?we:"payload.".concat(V.dataKey.toString());ve=Yv(M,ut,$),le=K&&X&&Yv(X,ut,$)}else ve=M==null?void 0:M[A],le=K&&X&&X[A];if(me||xe){var Se=S.props.activeIndex!==void 0?S.props.activeIndex:A;return[p.cloneElement(S,pe(pe(pe({},P.props),_e),{},{activeIndex:Se})),null,null]}if(!yt(ve))return[ue].concat(Of(w.renderActivePoints({item:P,activePoint:ve,basePoint:le,childIndex:A,isRange:K})))}else{var Ve,pt=(Ve=w.getItemByXY(w.state.activeCoordinate))!==null&&Ve!==void 0?Ve:{graphicalItem:ue},Pt=pt.graphicalItem,Qt=Pt.item,kt=Qt===void 0?S:Qt,Pn=Pt.childIndex,er=pe(pe(pe({},P.props),_e),{},{activeIndex:Pn});return[p.cloneElement(kt,er),null,null]}return K?[ue,null,null]:[ue,null]}),ht(w,"renderCustomized",function(S,_,C){return p.cloneElement(S,pe(pe({key:"recharts-customized-".concat(C)},w.props),w.state))}),ht(w,"renderMap",{CartesianGrid:{handler:Pg,once:!0},ReferenceArea:{handler:w.renderReferenceElement},ReferenceLine:{handler:Pg},ReferenceDot:{handler:w.renderReferenceElement},XAxis:{handler:Pg},YAxis:{handler:Pg},Brush:{handler:w.renderBrush,once:!0},Bar:{handler:w.renderGraphicChild},Line:{handler:w.renderGraphicChild},Area:{handler:w.renderGraphicChild},Radar:{handler:w.renderGraphicChild},RadialBar:{handler:w.renderGraphicChild},Scatter:{handler:w.renderGraphicChild},Pie:{handler:w.renderGraphicChild},Funnel:{handler:w.renderGraphicChild},Tooltip:{handler:w.renderCursor,once:!0},PolarGrid:{handler:w.renderPolarGrid,once:!0},PolarAngleAxis:{handler:w.renderPolarAxis},PolarRadiusAxis:{handler:w.renderPolarAxis},Customized:{handler:w.renderCustomized}}),w.clipPathId="".concat((b=g.id)!==null&&b!==void 0?b:om("recharts"),"-clip"),w.throttleTriggeredAfterMouseMove=CV(w.triggeredAfterMouseMove,(N=g.throttleDelay)!==null&&N!==void 0?N:1e3/60),w.state={},w}return qIe(v,j),FIe(v,[{key:"componentDidMount",value:function(){var b,N;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(b=this.props.margin.left)!==null&&b!==void 0?b:0,top:(N=this.props.margin.top)!==null&&N!==void 0?N:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var b=this.props,N=b.children,w=b.data,S=b.height,_=b.layout,C=ks(N,fn);if(C){var P=C.props.defaultIndex;if(!(typeof P!="number"||P<0||P>this.state.tooltipTicks.length-1)){var D=this.state.tooltipTicks[P]&&this.state.tooltipTicks[P].value,z=aC(this.state,w,P,D),O=this.state.tooltipTicks[P].coordinate,V=(this.state.offset.top+S)/2,A=_==="horizontal",$=A?{x:O,y:V}:{y:O,x:V},B=this.state.formattedGraphicalItems.find(function(k){var M=k.item;return M.type.name==="Scatter"});B&&($=pe(pe({},$),B.props.points[P].tooltipPosition),z=B.props.points[P].tooltipPayload);var I={activeTooltipIndex:P,isTooltipActive:!0,activeLabel:D,activePayload:z,activeCoordinate:$};this.setState(I),this.renderCursor(C),this.accessibilityManager.setIndex(P)}}}},{key:"getSnapshotBeforeUpdate",value:function(b,N){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==N.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==b.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==b.margin){var w,S;this.accessibilityManager.setDetails({offset:{left:(w=this.props.margin.left)!==null&&w!==void 0?w:0,top:(S=this.props.margin.top)!==null&&S!==void 0?S:0}})}return null}},{key:"componentDidUpdate",value:function(b){MS([ks(b.children,fn)],[ks(this.props.children,fn)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var b=ks(this.props.children,fn);if(b&&typeof b.props.shared=="boolean"){var N=b.props.shared?"axis":"item";return l.indexOf(N)>=0?N:i}return i}},{key:"getMouseInfo",value:function(b){if(!this.container)return null;var N=this.container,w=N.getBoundingClientRect(),S=jSe(w),_={chartX:Math.round(b.pageX-S.left),chartY:Math.round(b.pageY-S.top)},C=w.width/N.offsetWidth||1,P=this.inRange(_.chartX,_.chartY,C);if(!P)return null;var D=this.state,z=D.xAxisMap,O=D.yAxisMap,V=this.getTooltipEventType(),A=c$(this.state,this.props.data,this.props.layout,P);if(V!=="axis"&&z&&O){var $=Qo(z).scale,B=Qo(O).scale,I=$&&$.invert?$.invert(_.chartX):null,k=B&&B.invert?B.invert(_.chartY):null;return pe(pe({},_),{},{xValue:I,yValue:k},A)}return A?pe(pe({},_),A):null}},{key:"inRange",value:function(b,N){var w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,S=this.props.layout,_=b/w,C=N/w;if(S==="horizontal"||S==="vertical"){var P=this.state.offset,D=_>=P.left&&_<=P.left+P.width&&C>=P.top&&C<=P.top+P.height;return D?{x:_,y:C}:null}var z=this.state,O=z.angleAxisMap,V=z.radiusAxisMap;if(O&&V){var A=Qo(O);return R4({x:_,y:C},A)}return null}},{key:"parseEventsOfWrapper",value:function(){var b=this.props.children,N=this.getTooltipEventType(),w=ks(b,fn),S={};w&&N==="axis"&&(w.props.trigger==="click"?S={onClick:this.handleClick}:S={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var _=Xv(this.props,this.handleOuterEvent);return pe(pe({},_),S)}},{key:"addListener",value:function(){jN.on(bN,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){jN.removeListener(bN,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(b,N,w){for(var S=this.state.formattedGraphicalItems,_=0,C=S.length;_JSON.stringify(t),[t]),a=ae({mutationFn:c=>Ol.getReportNarrative(c),onError:c=>{r({title:"Summary unavailable",description:c.message||"Could not generate AI summary.",variant:"destructive"})}});return p.useEffect(()=>{a.mutate({report_type:e,data:t})},[e,s]),n.jsxs("div",{className:"rounded-lg border bg-primary/5 p-4 mb-4 flex items-start gap-3",children:[n.jsx(lt,{className:"h-4 w-4 text-primary shrink-0 mt-0.5"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("span",{className:"text-xs font-semibold text-primary",children:"AI Summary"}),a.isPending&&n.jsxs("p",{className:"text-sm text-muted-foreground mt-1 flex items-center gap-2",children:[n.jsx(Re,{className:"h-4 w-4 animate-spin shrink-0"}),"Generating summary…"]}),a.isError&&!a.isPending&&n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Could not load summary."}),!a.isPending&&((i=a.data)==null?void 0:i.narrative)&&n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a.data.narrative}),a.isSuccess&&!((l=(o=a.data)==null?void 0:o.narrative)!=null&&l.trim())&&n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"No summary returned."})]})]})}const aDe=["0%","50%","70%","90%"],f$=[{module:"Reading",score:72},{module:"Listening",score:68},{module:"Writing",score:61},{module:"Speaking",score:65}],m$=[{month:"Jan",avg:58},{month:"Feb",avg:62},{month:"Mar",avg:65},{month:"Apr",avg:64},{month:"May",avg:69},{month:"Jun",avg:72}],NN=[{name:"A1",value:15,color:"hsl(0, 72%, 51%)"},{name:"A2",value:22,color:"hsl(38, 92%, 50%)"},{name:"B1",value:30,color:"hsl(199, 89%, 48%)"},{name:"B2",value:20,color:"hsl(243, 75%, 59%)"},{name:"C1",value:10,color:"hsl(142, 71%, 45%)"},{name:"C2",value:3,color:"hsl(280, 65%, 50%)"}];function iDe(){const[e,t]=p.useState("0%");return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Corporate Statistics"}),n.jsx("p",{className:"text-muted-foreground",children:"Entity-level performance analytics and reports."})]}),n.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[n.jsx("div",{className:"flex gap-1",children:aDe.map(r=>n.jsx(E,{variant:e===r?"default":"outline",size:"sm",onClick:()=>t(r),children:r},r))}),n.jsxs(Oe,{children:[n.jsx(Ae,{className:"w-[160px]",children:n.jsx(Me,{placeholder:"All Entities"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"all",children:"All"}),n.jsx(Y,{value:"acme",children:"Acme Corp"})]})]}),n.jsxs(Oe,{children:[n.jsx(Ae,{className:"w-[180px]",children:n.jsx(Me,{placeholder:"All Assignments"})}),n.jsx(Ee,{children:n.jsx(Y,{value:"all",children:"All Assignments"})})]})]}),n.jsxs(Us,{defaultValue:"overview",children:[n.jsxs(ws,{children:[n.jsx(Et,{value:"overview",children:"Overview"}),n.jsx(Et,{value:"trends",children:"Trends"}),n.jsx(Et,{value:"distribution",children:"Distribution"}),n.jsx(Et,{value:"comparison",children:"Comparison"})]}),n.jsxs(Lt,{value:"overview",className:"mt-4",children:[n.jsx(Ra,{report_type:"corporate-overview",data:{modules:f$}}),n.jsxs(W,{className:"border-0 shadow-sm",children:[n.jsx(se,{children:n.jsx(ie,{className:"text-base",children:"Average Score by Module"})}),n.jsx(U,{children:n.jsx(Xn,{width:"100%",height:300,children:n.jsxs(vo,{data:f$,children:[n.jsx(bs,{strokeDasharray:"3 3",stroke:"hsl(220, 16%, 90%)"}),n.jsx(kr,{dataKey:"module"}),n.jsx(Pr,{domain:[0,100]}),n.jsx(fn,{}),n.jsx(_r,{dataKey:"score",fill:"hsl(243, 75%, 59%)",radius:[4,4,0,0]})]})})})]})]}),n.jsxs(Lt,{value:"trends",className:"mt-4",children:[n.jsx(Ra,{report_type:"corporate-trends",data:{trends:m$}}),n.jsxs(W,{className:"border-0 shadow-sm",children:[n.jsx(se,{children:n.jsx(ie,{className:"text-base",children:"Score Trend Over Time"})}),n.jsx(U,{children:n.jsx(Xn,{width:"100%",height:300,children:n.jsxs(Px,{data:m$,children:[n.jsx(bs,{strokeDasharray:"3 3",stroke:"hsl(220, 16%, 90%)"}),n.jsx(kr,{dataKey:"month"}),n.jsx(Pr,{domain:[0,100]}),n.jsx(fn,{}),n.jsx(Ao,{type:"monotone",dataKey:"avg",stroke:"hsl(243, 75%, 59%)",strokeWidth:2,dot:{r:4}})]})})})]})]}),n.jsxs(Lt,{value:"distribution",className:"mt-4",children:[n.jsx(Ra,{report_type:"corporate-distribution",data:{distribution:NN}}),n.jsxs(W,{className:"border-0 shadow-sm",children:[n.jsx(se,{children:n.jsx(ie,{className:"text-base",children:"Level Distribution"})}),n.jsx(U,{className:"flex justify-center",children:n.jsx(Xn,{width:"100%",height:300,children:n.jsxs(_0,{children:[n.jsx(pa,{data:NN,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:100,label:!0,children:NN.map((r,s)=>n.jsx(_d,{fill:r.color},s))}),n.jsx(fn,{})]})})})]})]}),n.jsxs(Lt,{value:"comparison",className:"mt-4",children:[n.jsx(Ra,{report_type:"corporate-comparison",data:{threshold:e}}),n.jsx(W,{className:"border-0 shadow-sm",children:n.jsx(U,{className:"p-8 text-center text-muted-foreground",children:"Entity comparison charts will appear here based on selected filters."})})]})]})]})}const h$=[{id:1,assignment:"IELTS Prep Q1",exam:"EX-001",date:"2025-03-01",score:7.5,duration:"175 min",status:"Completed"},{id:2,assignment:"Speaking Workshop",exam:"EX-005",date:"2025-03-05",score:6,duration:"14 min",status:"Completed"},{id:3,assignment:"Full Mock Exam",exam:"EX-006",date:"2025-03-10",score:null,duration:"120 min",status:"In Progress"},{id:4,assignment:"Listening Bootcamp",exam:"EX-003",date:"2025-02-20",score:5.5,duration:"28 min",status:"Completed"}];function oDe(){return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Record"}),n.jsx("p",{className:"text-muted-foreground",children:"Browse assignment and exam attempt history."})]}),n.jsx(Wn,{context:"record",variant:"insight"}),n.jsx(Ra,{report_type:"record",data:{records:h$}}),n.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[n.jsxs(Oe,{children:[n.jsx(Ae,{className:"w-[160px]",children:n.jsx(Me,{placeholder:"Entity"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"acme",children:"Acme Corp"}),n.jsx(Y,{value:"global",children:"Global Ltd"})]})]}),n.jsxs(Oe,{children:[n.jsx(Ae,{className:"w-[180px]",children:n.jsx(Me,{placeholder:"Select User"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"sarah",children:"Sarah Johnson"}),n.jsx(Y,{value:"ahmed",children:"Ahmed Hassan"})]})]}),n.jsx("div",{className:"flex gap-1",children:["Day","Week","Month"].map(e=>n.jsx(E,{variant:"outline",size:"sm",children:e},e))})]}),n.jsx(W,{className:"border-0 shadow-sm",children:n.jsx(U,{className:"p-0",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Assignment"}),n.jsx(L,{children:"Exam"}),n.jsx(L,{children:"Date"}),n.jsx(L,{children:"Score"}),n.jsx(L,{children:"Duration"}),n.jsx(L,{children:"Status"})]})}),n.jsx(Be,{children:h$.map(e=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:e.assignment}),n.jsx(T,{className:"font-mono text-xs",children:e.exam}),n.jsx(T,{children:e.date}),n.jsx(T,{children:e.score?e.score.toFixed(1):"—"}),n.jsx(T,{children:e.duration}),n.jsx(T,{children:n.jsx(oe,{variant:e.status==="Completed"?"default":"secondary",children:e.status})})]},e.id))})]})})})]})}const Um=[{word:"Ubiquitous",meaning:"Present, appearing, or found everywhere",level:"C1",completed:!0},{word:"Pragmatic",meaning:"Dealing with things sensibly and realistically",level:"B2",completed:!0},{word:"Eloquent",meaning:"Fluent or persuasive in speaking or writing",level:"C1",completed:!1},{word:"Meticulous",meaning:"Showing great attention to detail",level:"B2",completed:!1},{word:"Ambiguous",meaning:"Open to more than one interpretation",level:"B2",completed:!1},{word:"Coherent",meaning:"Logical and consistent",level:"B1",completed:!1},{word:"Versatile",meaning:"Able to adapt to many different functions",level:"B2",completed:!0},{word:"Concise",meaning:"Giving a lot of information in few words",level:"B1",completed:!1}];function lDe(){const[e,t]=p.useState(!1),r=Um.filter(a=>a.completed).length,s=e?Um:Um.filter(a=>!a.completed);return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Vocabulary Training"}),n.jsx("p",{className:"text-muted-foreground",children:"Build your vocabulary for IELTS success."})]}),n.jsx(Wn,{context:"vocabulary",variant:"recommendation"}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[n.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[n.jsxs(W,{className:"border-0 shadow-sm",children:[n.jsx(se,{className:"pb-3",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(ie,{className:"text-base",children:"Progress"}),n.jsxs("span",{className:"text-sm text-muted-foreground",children:[r,"/",Um.length," completed"]})]})}),n.jsx(U,{children:n.jsx(kn,{value:r/Um.length*100,className:"h-3"})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Fr,{id:"show",checked:e,onCheckedChange:t}),n.jsx(q,{htmlFor:"show",className:"text-sm",children:"Show completed"})]}),n.jsx("div",{className:"space-y-2",children:s.map(a=>n.jsx(W,{className:"border-0 shadow-sm",children:n.jsxs(U,{className:"p-4 flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[a.completed&&n.jsx(Ff,{className:"h-4 w-4 text-success shrink-0"}),n.jsxs("div",{children:[n.jsx("p",{className:"font-semibold text-sm",children:a.word}),n.jsx("p",{className:"text-xs text-muted-foreground",children:a.meaning})]})]}),n.jsx(oe,{variant:"outline",children:a.level})]})},a.word))})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs(W,{className:"border-0 shadow-sm",children:[n.jsx(se,{className:"pb-3",children:n.jsxs(ie,{className:"text-base flex items-center gap-2",children:[n.jsx(lt,{className:"h-4 w-4 text-primary"})," AI Recommendations"]})}),n.jsx(U,{children:n.jsxs("ul",{className:"space-y-2",children:[n.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[n.jsx("span",{className:"text-primary font-bold",children:"•"}),'Learn "coherent" + "concise" together — they share academic writing context']}),n.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[n.jsx("span",{className:"text-primary font-bold",children:"•"}),"Review C1-level vocabulary for IELTS Task 2"]}),n.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[n.jsx("span",{className:"text-primary font-bold",children:"•"}),"Focus on collocations with 'make' and 'do'"]}),n.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[n.jsx("span",{className:"text-primary font-bold",children:"•"}),'Try using "meticulous" in your next writing practice']})]})})]}),n.jsx(W,{className:"border-0 shadow-sm border-primary/20 bg-primary/5",children:n.jsxs(U,{className:"p-4",children:[n.jsxs("p",{className:"text-xs font-semibold text-primary flex items-center gap-1 mb-2",children:[n.jsx(lt,{className:"h-3 w-3"})," AI Vocabulary Goal"]}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"At 2 words/day, you'll complete this set by March 15. AI recommends adding 10 more domain-specific words from your upcoming exam topics."})]})})]})]})]})}const Km=[{rule:"Conditional Sentences (Type 2 & 3)",description:"If + past simple / past perfect for hypothetical situations",level:"B2",completed:!0},{rule:"Passive Voice in Academic Writing",description:"Using passive constructions in formal reports",level:"B2",completed:!1},{rule:"Relative Clauses",description:"Defining vs non-defining relative clauses",level:"B1",completed:!0},{rule:"Subject-Verb Agreement",description:"Complex subjects with prepositional phrases",level:"B1",completed:!1},{rule:"Modal Verbs for Speculation",description:"Must have, could have, might have + past participle",level:"C1",completed:!1},{rule:"Reported Speech",description:"Tense changes and time references in indirect speech",level:"B2",completed:!0}];function cDe(){const[e,t]=p.useState(!1),r=Km.filter(a=>a.completed).length,s=e?Km:Km.filter(a=>!a.completed);return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Grammar Training"}),n.jsx("p",{className:"text-muted-foreground",children:"Master grammar rules essential for IELTS."})]}),n.jsx(Wn,{context:"grammar",variant:"recommendation"}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[n.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[n.jsxs(W,{className:"border-0 shadow-sm",children:[n.jsx(se,{className:"pb-3",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(ie,{className:"text-base",children:"Progress"}),n.jsxs("span",{className:"text-sm text-muted-foreground",children:[r,"/",Km.length," completed"]})]})}),n.jsx(U,{children:n.jsx(kn,{value:r/Km.length*100,className:"h-3"})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Fr,{id:"show",checked:e,onCheckedChange:t}),n.jsx(q,{htmlFor:"show",className:"text-sm",children:"Show completed"})]}),n.jsx("div",{className:"space-y-2",children:s.map(a=>n.jsx(W,{className:"border-0 shadow-sm",children:n.jsxs(U,{className:"p-4 flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[a.completed&&n.jsx(Ff,{className:"h-4 w-4 text-success shrink-0"}),n.jsxs("div",{children:[n.jsx("p",{className:"font-semibold text-sm",children:a.rule}),n.jsx("p",{className:"text-xs text-muted-foreground",children:a.description})]})]}),n.jsx(oe,{variant:"outline",children:a.level})]})},a.rule))})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs(W,{className:"border-0 shadow-sm",children:[n.jsx(se,{className:"pb-3",children:n.jsxs(ie,{className:"text-base flex items-center gap-2",children:[n.jsx(lt,{className:"h-4 w-4 text-primary"})," AI Recommendations"]})}),n.jsx(U,{children:n.jsxs("ul",{className:"space-y-2",children:[n.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[n.jsx("span",{className:"text-primary font-bold",children:"•"}),"Practice passive voice transformations — high exam frequency"]}),n.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[n.jsx("span",{className:"text-primary font-bold",children:"•"}),"Review modal verbs for IELTS Writing Task 1"]}),n.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[n.jsx("span",{className:"text-primary font-bold",children:"•"}),"Focus on complex sentence structures for C1 readiness"]}),n.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[n.jsx("span",{className:"text-primary font-bold",children:"•"}),"Your conditional sentences are strong — try advanced mixed conditionals"]})]})})]}),n.jsx(W,{className:"border-0 shadow-sm border-primary/20 bg-primary/5",children:n.jsxs(U,{className:"p-4",children:[n.jsxs("p",{className:"text-xs font-semibold text-primary flex items-center gap-1 mb-2",children:[n.jsx(lt,{className:"h-3 w-3"})," AI Study Plan"]}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Based on your progress, complete Passive Voice and Subject-Verb Agreement this week. At your current pace, you'll finish all B2 grammar by April 15."})]})})]})]})]})}const p$=[{id:"PAY-001",corporate:"Acme Corp",manager:"John Admin",amount:5e3,currency:"USD",paid:!0,date:"2025-01-15",type:"Corporate"},{id:"PAY-002",corporate:"Global Ltd",manager:"HR Global",amount:8500,currency:"USD",paid:!0,date:"2025-02-01",type:"Corporate"},{id:"PAY-003",corporate:"Tech Co",manager:"Tech Admin",amount:2e3,currency:"USD",paid:!1,date:"2025-03-01",type:"Commission"}],dDe=[{id:"PMB-1001",status:"Paid",user:"Sarah Johnson",email:"sarah.j@email.com",amount:199},{id:"PMB-1002",status:"Pending",user:"Ahmed Hassan",email:"ahmed.h@email.com",amount:149},{id:"PMB-1003",status:"Paid",user:"Li Wei",email:"li.w@email.com",amount:199},{id:"PMB-1004",status:"Failed",user:"Emma Brown",email:"emma.b@email.com",amount:99}];function uDe(){return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Payment Record"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage payments, commissions, and Paymob orders."})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(E,{variant:"outline",size:"sm",children:[n.jsx(yd,{className:"h-4 w-4 mr-1"})," Export CSV"]}),n.jsxs(Qe,{children:[n.jsx(cr,{asChild:!0,children:n.jsxs(E,{size:"sm",children:[n.jsx(mt,{className:"h-4 w-4 mr-1"})," New Payment"]})}),n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create Payment Record"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Corporate"}),n.jsxs(Oe,{children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select"})}),n.jsx(Ee,{children:n.jsx(Y,{value:"acme",children:"Acme Corp"})})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Amount (USD)"}),n.jsx(G,{type:"number",placeholder:"5000"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Type"}),n.jsxs(Oe,{children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Type"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"corporate",children:"Corporate"}),n.jsx(Y,{value:"commission",children:"Commission"})]})]})]}),n.jsx(E,{className:"w-full",children:"Create"})]})]})]})]})]}),n.jsx(Wn,{context:"payment-record",variant:"recommendation"}),n.jsxs(Us,{defaultValue:"payments",children:[n.jsxs(ws,{children:[n.jsx(Et,{value:"payments",children:"Payments"}),n.jsx(Et,{value:"paymob",children:"Paymob"})]}),n.jsxs(Lt,{value:"payments",className:"mt-4 space-y-4",children:[n.jsx(Ra,{report_type:"payments",data:{payments:p$}}),n.jsx(W,{className:"border-0 shadow-sm",children:n.jsx(U,{className:"p-0",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"ID"}),n.jsx(L,{children:"Corporate"}),n.jsx(L,{children:"Manager"}),n.jsx(L,{children:"Amount"}),n.jsx(L,{children:"Type"}),n.jsx(L,{children:"Paid"}),n.jsx(L,{children:"Date"})]})}),n.jsx(Be,{children:p$.map(e=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-mono text-xs",children:e.id}),n.jsx(T,{children:e.corporate}),n.jsx(T,{children:e.manager}),n.jsxs(T,{className:"font-semibold",children:["$",e.amount.toLocaleString()]}),n.jsx(T,{children:n.jsx(oe,{variant:"outline",children:e.type})}),n.jsx(T,{children:n.jsx(oe,{variant:e.paid?"default":"destructive",children:e.paid?"Paid":"Unpaid"})}),n.jsx(T,{children:e.date})]},e.id))})]})})})]}),n.jsx(Lt,{value:"paymob",className:"mt-4",children:n.jsx(W,{className:"border-0 shadow-sm",children:n.jsx(U,{className:"p-0",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Order ID"}),n.jsx(L,{children:"Status"}),n.jsx(L,{children:"User"}),n.jsx(L,{children:"Email"}),n.jsx(L,{children:"Amount"})]})}),n.jsx(Be,{children:dDe.map(e=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-mono text-xs",children:e.id}),n.jsx(T,{children:n.jsx(oe,{variant:e.status==="Paid"?"default":e.status==="Pending"?"secondary":"destructive",children:e.status})}),n.jsx(T,{children:e.user}),n.jsx(T,{children:e.email}),n.jsxs(T,{className:"font-semibold",children:["$",e.amount.toFixed(2)]})]},e.id))})]})})})})]})]})}function fDe(){const[e,t]=p.useState(""),[r,s]=p.useState("all"),[a,i]=p.useState("all"),[o,l]=p.useState(!1),[c,d]=p.useState({subject:"",type:"bug",description:""}),{toast:u}=He(),f=je(),{data:h,isLoading:m}=ye({queryKey:["tickets",r,a,e],queryFn:()=>cT.list({...r!=="all"?{status:r}:{},...a!=="all"?{type:a}:{},...e?{search:e}:{}})}),y=(h==null?void 0:h.data)??[],x=ae({mutationFn:cT.create,onSuccess:()=>{f.invalidateQueries({queryKey:["tickets"]}),l(!1),d({subject:"",type:"bug",description:""}),u({title:"Ticket created successfully"})},onError:()=>{u({title:"Failed to create ticket",variant:"destructive"})}});function j(){c.subject.trim()&&x.mutate({subject:c.subject.trim(),type:c.type,description:c.description.trim()})}const v=b=>b==="open"?"default":b==="in_progress"?"secondary":"outline",g=b=>b==="bug"?"destructive":b==="feature"?"secondary":"outline";return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Tickets"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage support tickets and feature requests."})]}),n.jsxs(E,{size:"sm",onClick:()=>l(!0),children:[n.jsx(mt,{className:"h-4 w-4 mr-1"})," Create Ticket"]})]}),n.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[n.jsxs("div",{className:"relative flex-1 max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search tickets...",className:"pl-9",value:e,onChange:b=>t(b.target.value)})]}),n.jsxs(Oe,{value:r,onValueChange:s,children:[n.jsx(Ae,{className:"w-[130px]",children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"all",children:"All Status"}),n.jsx(Y,{value:"open",children:"Open"}),n.jsx(Y,{value:"in_progress",children:"In Progress"}),n.jsx(Y,{value:"resolved",children:"Resolved"}),n.jsx(Y,{value:"closed",children:"Closed"})]})]}),n.jsxs(Oe,{value:a,onValueChange:i,children:[n.jsx(Ae,{className:"w-[120px]",children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"all",children:"All Types"}),n.jsx(Y,{value:"bug",children:"Bug"}),n.jsx(Y,{value:"feature",children:"Feature"}),n.jsx(Y,{value:"support",children:"Support"}),n.jsx(Y,{value:"feedback",children:"Feedback"})]})]})]}),n.jsx(W,{className:"border-0 shadow-sm",children:n.jsx(U,{className:"p-0",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"ID"}),n.jsx(L,{children:"Type"}),n.jsx(L,{children:"Reporter"}),n.jsx(L,{children:"Date"}),n.jsx(L,{children:"Subject"}),n.jsx(L,{children:"Status"})]})}),n.jsxs(Be,{children:[m&&n.jsx(ee,{children:n.jsx(T,{colSpan:6,className:"text-center py-8",children:n.jsx(Re,{className:"h-5 w-5 animate-spin mx-auto"})})}),!m&&y.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No tickets found."})}),y.map(b=>{var N;return n.jsxs(ee,{children:[n.jsxs(T,{className:"font-mono text-xs",children:["#",b.id]}),n.jsx(T,{children:n.jsx(oe,{variant:g(b.type),children:b.type})}),n.jsx(T,{children:b.reporter_name}),n.jsx(T,{children:b.created_at?new Date(b.created_at).toLocaleDateString():"—"}),n.jsx(T,{className:"font-medium max-w-[200px] truncate",children:b.subject}),n.jsx(T,{children:n.jsx(oe,{variant:v(b.status),children:(N=b.status)==null?void 0:N.replace("_"," ")})})]},b.id)})]})]})})}),n.jsx(Qe,{open:o,onOpenChange:l,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create Ticket"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Subject"}),n.jsx(G,{value:c.subject,onChange:b=>d(N=>({...N,subject:b.target.value})),placeholder:"Brief description"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Type"}),n.jsxs(Oe,{value:c.type,onValueChange:b=>d(N=>({...N,type:b})),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"bug",children:"Bug"}),n.jsx(Y,{value:"feature",children:"Feature"}),n.jsx(Y,{value:"support",children:"Support"}),n.jsx(Y,{value:"feedback",children:"Feedback"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Description"}),n.jsx(on,{value:c.description,onChange:b=>d(N=>({...N,description:b.target.value})),placeholder:"Describe the issue...",className:"h-24"})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),n.jsx(E,{disabled:!c.subject.trim()||x.isPending,onClick:j,children:x.isPending?n.jsxs(n.Fragment,{children:[n.jsx(Re,{className:"h-4 w-4 mr-1 animate-spin"})," Creating..."]}):"Submit Ticket"})]})]})})]})}const mDe=[{code:"ENCOACH-2025-A1B2",type:"Single",used:!1,created:"2025-01-10"},{code:"ENCOACH-2025-C3D4",type:"Single",used:!0,created:"2025-01-12"},{code:"BATCH-2025-E5F6",type:"Batch",used:!1,created:"2025-02-01"},{code:"BATCH-2025-G7H8",type:"Batch",used:!1,created:"2025-02-01"}],hDe=[{id:1,name:"IELTS Starter",price:99,duration:"1 month",discount:0},{id:2,name:"IELTS Pro",price:249,duration:"3 months",discount:15},{id:3,name:"Corporate Bundle",price:1999,duration:"12 months",discount:25}];function pDe(){return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Settings"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage codes, packages, discounts, and grading system."})]}),n.jsxs(Us,{defaultValue:"codes",children:[n.jsxs(ws,{children:[n.jsx(Et,{value:"codes",children:"Codes"}),n.jsx(Et,{value:"packages",children:"Packages & Discounts"}),n.jsx(Et,{value:"grading",children:"Grading System"})]}),n.jsxs(Lt,{value:"codes",className:"mt-4 space-y-4",children:[n.jsx(Wn,{context:"settings-codes",variant:"insight"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(E,{size:"sm",children:[n.jsx(mt,{className:"h-4 w-4 mr-1"})," Generate Single"]}),n.jsxs(E,{size:"sm",variant:"outline",children:[n.jsx(RG,{className:"h-4 w-4 mr-1"})," Generate Batch"]})]}),n.jsx(W,{className:"border-0 shadow-sm",children:n.jsx(U,{className:"p-0",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Code"}),n.jsx(L,{children:"Type"}),n.jsx(L,{children:"Used"}),n.jsx(L,{children:"Created"}),n.jsx(L,{className:"w-10"})]})}),n.jsx(Be,{children:mDe.map(e=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-mono text-xs",children:e.code}),n.jsx(T,{children:n.jsx(oe,{variant:"outline",children:e.type})}),n.jsx(T,{children:n.jsx(oe,{variant:e.used?"secondary":"default",children:e.used?"Used":"Available"})}),n.jsx(T,{children:e.created}),n.jsx(T,{children:n.jsx(E,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",children:n.jsx($t,{className:"h-4 w-4"})})})]},e.code))})]})})})]}),n.jsxs(Lt,{value:"packages",className:"mt-4 space-y-4",children:[n.jsx(Wn,{context:"settings-packages",variant:"recommendation"}),n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:hDe.map(e=>n.jsxs(W,{className:"border-0 shadow-sm",children:[n.jsx(se,{className:"pb-3",children:n.jsx(ie,{className:"text-base",children:e.name})}),n.jsxs(U,{className:"space-y-2",children:[n.jsxs("p",{className:"text-2xl font-bold",children:["$",e.price]}),n.jsx("p",{className:"text-sm text-muted-foreground",children:e.duration}),e.discount>0&&n.jsxs(oe,{variant:"default",children:[e.discount,"% OFF"]})]})]},e.id))})]}),n.jsxs(Lt,{value:"grading",className:"mt-4 space-y-4",children:[n.jsx(Wn,{context:"settings-grading",variant:"tip"}),n.jsxs(W,{className:"border-0 shadow-sm max-w-lg",children:[n.jsx(se,{children:n.jsx(ie,{className:"text-base",children:"Scoring Scale"})}),n.jsxs(U,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Min Score"}),n.jsx(G,{type:"number",defaultValue:"0"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Max Score"}),n.jsx(G,{type:"number",defaultValue:"9"})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Score Increment"}),n.jsx(G,{type:"number",defaultValue:"0.5",step:"0.5"})]}),n.jsx(E,{children:"Save Grading Configuration"})]})]})]})]})]})}function xDe(){return n.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[70vh] gap-4 max-w-md mx-auto",children:[n.jsx(Wn,{context:"exam",variant:"recommendation"}),n.jsx(W,{className:"border-0 shadow-sm w-full",children:n.jsxs(U,{className:"p-8 text-center space-y-6",children:[n.jsx("div",{className:"mx-auto h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center",children:n.jsx(_i,{className:"h-8 w-8 text-primary"})}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-xl font-bold mb-1",children:"Ready to Start?"}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"IELTS Academic Mock Exam"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Student"}),n.jsx("span",{className:"font-medium",children:"Sarah Johnson"})]}),n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Level"}),n.jsx(oe,{variant:"outline",children:"B2"})]}),n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Modules"}),n.jsx("span",{className:"font-medium",children:"4"})]}),n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Duration"}),n.jsx("span",{className:"font-medium",children:"180 min"})]}),n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Mode"}),n.jsx(oe,{variant:"secondary",children:"Practice"})]})]}),n.jsxs("div",{className:"rounded-lg bg-primary/5 border border-primary/20 p-3 text-left",children:[n.jsxs("p",{className:"text-xs font-semibold text-primary flex items-center gap-1 mb-1",children:[n.jsx(lt,{className:"h-3 w-3"})," AI Pre-Exam Tip"]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Your last mock scored 7.5. To target 8.0, focus on time management in Writing Task 2 — you spent 45 min last time vs recommended 40 min."})]}),n.jsxs(E,{className:"w-full",size:"lg",children:[n.jsx(pk,{className:"h-4 w-4 mr-2"})," Begin Exam"]})]})})]})}function gDe(){const{data:e,isLoading:t}=Er(),{data:r,isLoading:s}=Nd(),{data:a,isLoading:i}=D2(),o=(e==null?void 0:e.items)??[],l=(r==null?void 0:r.items)??[],c=a??[];if(t||s||i)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const d=o.filter(m=>["c1","c2","c5","c8"].includes(m.id)),u=l.filter(m=>m.status==="pending").slice(0,3),f=c.slice(0,3),h=[{label:"Enrolled Courses",value:String(d.length),icon:Kt,color:"text-primary"},{label:"Pending Assignments",value:String(l.filter(m=>m.status==="pending").length),icon:gd,color:"text-warning"},{label:"Average Grade",value:"78%",icon:Il,color:"text-success"},{label:"Attendance Rate",value:"94%",icon:Yp,color:"text-info"}];return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Welcome back, Sarah!"}),n.jsx("p",{className:"text-muted-foreground",children:"Here's an overview of your learning progress."})]}),n.jsx(Wn,{context:"student-dashboard",variant:"tip"}),n.jsx(z2,{}),n.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:h.map(m=>n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:m.label}),n.jsx("p",{className:"text-2xl font-bold",children:m.value})]}),n.jsx(m.icon,{className:`h-8 w-8 ${m.color} opacity-80`})]})})},m.label))}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[n.jsxs(W,{children:[n.jsxs(se,{className:"flex flex-row items-center justify-between pb-2",children:[n.jsx(ie,{className:"text-lg",children:"My Courses"}),n.jsx(E,{variant:"ghost",size:"sm",asChild:!0,children:n.jsxs(Dt,{to:"/student/courses",children:["View All ",n.jsx(Da,{className:"ml-1 h-3 w-3"})]})})]}),n.jsx(U,{className:"space-y-4",children:d.map(m=>n.jsx(Dt,{to:`/student/courses/${m.id}`,className:"block",children:n.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted/50 transition-colors",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{className:"font-medium text-sm truncate",children:m.title}),n.jsx("p",{className:"text-xs text-muted-foreground",children:m.instructor})]}),n.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[n.jsx("div",{className:"w-24",children:n.jsx(kn,{value:m.progress,className:"h-2"})}),n.jsxs("span",{className:"text-xs font-medium w-8 text-right",children:[m.progress,"%"]})]})]})},m.id))})]}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs(W,{children:[n.jsxs(se,{className:"flex flex-row items-center justify-between pb-2",children:[n.jsx(ie,{className:"text-lg",children:"Upcoming Assignments"}),n.jsx(E,{variant:"ghost",size:"sm",asChild:!0,children:n.jsxs(Dt,{to:"/student/assignments",children:["View All ",n.jsx(Da,{className:"ml-1 h-3 w-3"})]})})]}),n.jsx(U,{className:"space-y-3",children:u.map(m=>n.jsxs("div",{className:"flex items-center justify-between p-2 rounded border",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:m.title}),n.jsx("p",{className:"text-xs text-muted-foreground",children:m.courseName})]}),n.jsx(oe,{variant:"outline",className:"text-xs",children:m.dueDate})]},m.id))})]}),n.jsxs(W,{children:[n.jsxs(se,{className:"flex flex-row items-center justify-between pb-2",children:[n.jsx(ie,{className:"text-lg",children:"Recent Grades"}),n.jsx(E,{variant:"ghost",size:"sm",asChild:!0,children:n.jsxs(Dt,{to:"/student/grades",children:["View All ",n.jsx(Da,{className:"ml-1 h-3 w-3"})]})})]}),n.jsx(U,{className:"space-y-3",children:f.map(m=>n.jsxs("div",{className:"flex items-center justify-between p-2 rounded border",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:m.assignmentTitle}),n.jsx("p",{className:"text-xs text-muted-foreground",children:m.courseName})]}),n.jsxs("span",{className:"text-sm font-bold text-primary",children:[m.grade,"/",m.maxGrade]})]},m.id))})]})]})]})]})}function vDe(){const{data:e,isLoading:t}=Er(),r=(e==null?void 0:e.items)??[];if(t)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const s=r.filter(a=>["c1","c2","c5","c8"].includes(a.id));return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"My Courses"}),n.jsx("p",{className:"text-muted-foreground",children:"Browse and continue your enrolled courses."})]}),n.jsx(Wn,{context:"student-courses",variant:"recommendation"}),n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:s.map(a=>n.jsx(Dt,{to:`/student/courses/${a.id}`,children:n.jsxs(W,{className:"hover:shadow-md transition-shadow h-full",children:[n.jsx("div",{className:"h-2 rounded-t-lg bg-primary"}),n.jsxs(U,{className:"pt-5 space-y-4",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-1",children:[n.jsx(oe,{variant:"secondary",className:"text-xs",children:a.level}),n.jsx(oe,{variant:"outline",className:"text-xs",children:a.code})]}),n.jsx("h3",{className:"font-semibold mt-2",children:a.title}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:a.description})]}),n.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx(Kt,{className:"h-3 w-3"}),a.modules.length," modules"]}),n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx(as,{className:"h-3 w-3"}),a.enrolled," students"]})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex justify-between text-xs mb-1",children:[n.jsx("span",{className:"text-muted-foreground",children:"Progress"}),n.jsxs("span",{className:"font-medium",children:[a.progress,"%"]})]}),n.jsx(kn,{value:a.progress,className:"h-2"})]}),n.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[n.jsx(vd,{className:"h-3 w-3"})," ",a.instructor]})]})]})},a.id))})]})}const yDe={video:Ll,reading:Yn,quiz:Fh};function jDe(){const{id:e}=Ht(),{data:t,isLoading:r}=Er(),{data:s,isLoading:a}=Nd(),{data:i,isLoading:o}=LB(),{data:l,isLoading:c}=D2(),d=(t==null?void 0:t.items)??[],u=(s==null?void 0:s.items)??[],f=i??[],h=l??[];if(r||a||o||c)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const m=d.find(v=>v.id===e);if(!m)return n.jsx("div",{className:"p-8 text-center text-muted-foreground",children:"Course not found."});const y=u.filter(v=>v.courseId===e),x=f.filter(v=>v.courseId===e),j=h.filter(v=>v.courseId===e);return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(E,{variant:"ghost",size:"icon",asChild:!0,children:n.jsx(Dt,{to:"/student/courses",children:n.jsx(xd,{className:"h-4 w-4"})})}),n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:m.title}),n.jsxs("p",{className:"text-muted-foreground",children:[m.instructor," · ",m.code]})]})]}),n.jsx(W,{children:n.jsxs(U,{className:"pt-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Overall Progress"}),n.jsxs("span",{className:"text-sm font-bold",children:[m.progress,"%"]})]}),n.jsx(kn,{value:m.progress,className:"h-3"})]})}),n.jsxs(Us,{defaultValue:"materials",children:[n.jsxs(ws,{children:[n.jsx(Et,{value:"materials",children:"Materials"}),n.jsxs(Et,{value:"assignments",children:["Assignments (",y.length,")"]}),n.jsx(Et,{value:"attendance",children:"Attendance"}),n.jsx(Et,{value:"grades",children:"Grades"})]}),n.jsx(Lt,{value:"materials",className:"space-y-4 mt-4",children:m.modules.length===0?n.jsx("p",{className:"text-muted-foreground text-sm py-8 text-center",children:"No modules available yet."}):m.modules.map(v=>n.jsxs(W,{children:[n.jsx(se,{className:"pb-2",children:n.jsx(ie,{className:"text-base",children:v.title})}),n.jsx(U,{className:"space-y-2",children:v.lessons.map(g=>{const b=yDe[g.type];return n.jsxs("div",{className:"flex items-center gap-3 p-2 rounded hover:bg-muted/50",children:[g.completed?n.jsx(Ff,{className:"h-4 w-4 text-success shrink-0"}):n.jsx(_j,{className:"h-4 w-4 text-muted-foreground shrink-0"}),n.jsx(b,{className:"h-4 w-4 text-muted-foreground shrink-0"}),n.jsx("span",{className:"text-sm flex-1",children:g.title}),n.jsx("span",{className:"text-xs text-muted-foreground",children:g.duration})]},g.id)})})]},v.id))}),n.jsx(Lt,{value:"assignments",className:"mt-4 space-y-3",children:y.map(v=>n.jsx(W,{children:n.jsxs(U,{className:"pt-4 flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("p",{className:"font-medium text-sm",children:v.title}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Due: ",v.dueDate]})]}),n.jsx(oe,{variant:v.status==="graded"?"default":v.status==="overdue"?"destructive":"secondary",children:v.status})]})},v.id))}),n.jsx(Lt,{value:"attendance",className:"mt-4 space-y-3",children:x.map(v=>n.jsxs("div",{className:"flex items-center justify-between p-3 rounded border",children:[n.jsx("span",{className:"text-sm",children:v.date}),n.jsx(oe,{variant:v.status==="present"?"default":v.status==="absent"?"destructive":"secondary",children:v.status})]},v.id))}),n.jsx(Lt,{value:"grades",className:"mt-4 space-y-3",children:j.map(v=>n.jsxs("div",{className:"flex items-center justify-between p-3 rounded border",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:v.assignmentTitle}),n.jsx("p",{className:"text-xs text-muted-foreground",children:v.date})]}),n.jsxs("span",{className:"font-bold text-primary",children:[v.grade,"/",v.maxGrade]})]},v.id))})]})]})}function bDe({text:e,task_type:t="ielts_writing"}){var h,m,y,x;const[r,s]=p.useState(!1),[a,i]=p.useState(null),[o,l]=p.useState(!1),{toast:c}=He(),d=ae({mutationFn:j=>ox.writingHelp({task:t,draft:e.trim(),help_type:j}),onSuccess:()=>l(!0),onError:j=>{c({title:"Writing help failed",description:j.message||"Could not analyze your writing. Try again.",variant:"destructive"})}}),u=j=>{if(j){if(!e.trim()){c({title:"Add some text first",description:"Enter your draft in the text area so AI can analyze it.",variant:"destructive"});return}i(j),l(!1),d.mutate(j)}},f=d.isPending;return n.jsxs(fr,{open:r,onOpenChange:s,children:[n.jsx(mr,{asChild:!0,children:n.jsxs(E,{variant:"outline",size:"sm",className:"w-full justify-between mt-3",children:[n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(lt,{className:"h-3.5 w-3.5 text-primary"}),"AI Writing Helper"]}),n.jsx(rr,{className:`h-4 w-4 transition-transform ${r?"rotate-180":""}`})]})}),n.jsxs(hr,{className:"mt-3 space-y-3",children:[n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(E,{variant:"outline",size:"sm",onClick:()=>u("improve"),disabled:f,children:[n.jsx(hk,{className:"h-3.5 w-3.5 mr-1"})," Improve my draft"]}),n.jsxs(E,{variant:"outline",size:"sm",onClick:()=>u("grammar"),disabled:f,children:[n.jsx(Ff,{className:"h-3.5 w-3.5 mr-1"})," Check grammar"]}),n.jsxs(E,{variant:"outline",size:"sm",onClick:()=>u("band"),disabled:f,children:[n.jsx(Il,{className:"h-3.5 w-3.5 mr-1"})," Estimate band score"]})]}),f&&n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground rounded-lg bg-muted/50 p-3",children:[n.jsx(Re,{className:"h-4 w-4 animate-spin text-primary"})," AI is analyzing your writing..."]}),o&&!f&&d.data&&a==="improve"&&n.jsxs("div",{className:"space-y-3",children:[((h=d.data.tips)==null?void 0:h.length)>0&&n.jsxs("div",{className:"rounded-lg border bg-muted/30 p-3",children:[n.jsxs("p",{className:"text-xs font-semibold text-primary mb-1 flex items-center gap-1",children:[n.jsx(lt,{className:"h-3 w-3"})," Feedback"]}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.data.tips.join(" ")})]}),d.data.improved_text&&n.jsxs("div",{className:"rounded-lg border bg-muted/30 p-3",children:[n.jsxs("p",{className:"text-xs font-semibold text-primary mb-1 flex items-center gap-1",children:[n.jsx(lt,{className:"h-3 w-3"})," Improved Version"]}),n.jsx("p",{className:"text-sm",children:d.data.improved_text})]})]}),o&&!f&&d.data&&a==="grammar"&&n.jsxs("div",{className:"rounded-lg border bg-muted/30 p-3 space-y-2",children:[n.jsxs("p",{className:"text-xs font-semibold text-primary mb-1 flex items-center gap-1",children:[n.jsx(lt,{className:"h-3 w-3"})," Grammar notes"]}),(((m=d.data.changes)==null?void 0:m.length)??0)>0?d.data.changes.map((j,v)=>n.jsx("div",{className:"text-sm border-l-2 border-warning pl-2",children:n.jsxs("p",{className:"text-muted-foreground",children:[n.jsx("strong",{children:j.original})," → ",j.revised," — ",j.reason]})},v)):n.jsx("p",{className:"text-sm text-muted-foreground",children:"No grammar issues flagged."}),((y=d.data.tips)==null?void 0:y.length)>0?n.jsx("p",{className:"text-xs text-muted-foreground pt-2 border-t",children:d.data.tips.join("; ")}):null]}),o&&!f&&d.data&&a==="band"&&n.jsxs("div",{className:"rounded-lg border bg-muted/30 p-3",children:[n.jsxs("p",{className:"text-xs font-semibold text-primary mb-1 flex items-center gap-1",children:[n.jsx(lt,{className:"h-3 w-3"})," Estimated band / assessment"]}),n.jsx("p",{className:"text-sm text-muted-foreground",children:((x=d.data.tips)==null?void 0:x.join(" "))??""}),d.data.improved_text?n.jsx("p",{className:"text-sm mt-2 pt-2 border-t",children:d.data.improved_text}):null]})]})]})}function wDe(){const[e,t]=p.useState(!1),[r,s]=p.useState(null),[a,i]=p.useState(""),{toast:o}=He(),{data:l,isLoading:c}=Nd(),d=(l==null?void 0:l.items)??[];if(c)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const u=()=>{t(!1),o({title:"Assignment Submitted",description:"Your work has been submitted successfully."})},f=h=>d.filter(m=>h==="all"?!0:m.status===h);return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Assignments"}),n.jsx("p",{className:"text-muted-foreground",children:"View and submit your assignments."})]}),n.jsx(Wn,{context:"student-assignments",variant:"recommendation"}),n.jsxs(Us,{defaultValue:"all",children:[n.jsxs(ws,{children:[n.jsxs(Et,{value:"all",children:["All (",d.length,")"]}),n.jsxs(Et,{value:"pending",children:["Pending (",f("pending").length,")"]}),n.jsxs(Et,{value:"submitted",children:["Submitted (",f("submitted").length,")"]}),n.jsxs(Et,{value:"graded",children:["Graded (",f("graded").length,")"]})]}),["all","pending","submitted","graded","overdue"].map(h=>n.jsx(Lt,{value:h,className:"mt-4 space-y-3",children:f(h).map(m=>n.jsx(W,{children:n.jsx(U,{className:"pt-4",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{className:"font-medium text-sm",children:m.title}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:[m.courseName," · Due: ",m.dueDate]}),m.grade!==void 0&&n.jsxs("p",{className:"text-xs font-medium text-primary mt-1",children:["Grade: ",m.grade,"/",m.maxGrade]}),m.feedback&&n.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:['"',m.feedback,'"']})]}),n.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[n.jsx(oe,{variant:m.status==="graded"?"default":m.status==="overdue"?"destructive":"secondary",children:m.status}),m.status==="pending"&&n.jsx(E,{size:"sm",onClick:()=>{s(m.id),t(!0)},children:"Submit"})]})]})})},m.id))},h))]}),n.jsx(Qe,{open:e,onOpenChange:t,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Submit Assignment"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center text-muted-foreground",children:[n.jsx(Ku,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),n.jsx("p",{className:"text-sm",children:"Drag & drop your file here or click to browse"}),n.jsx("p",{className:"text-xs mt-1",children:"PDF, DOC, DOCX up to 10MB"})]}),n.jsx(on,{placeholder:"Add a comment (optional)...",rows:3,value:a,onChange:h=>i(h.target.value)}),n.jsx(bDe,{text:a,task_type:"ielts_writing"})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),n.jsx(E,{onClick:u,children:"Submit"})]})]})})]})}function NDe(){const{data:e=[],isLoading:t}=D2();if(t)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const r=e.length?(e.reduce((i,o)=>i+o.grade/o.maxGrade*100,0)/e.length).toFixed(1):"0",s=e.length?Math.max(...e.map(i=>i.grade/i.maxGrade*100)).toFixed(1):"0",a=e.map(i=>({name:i.assignmentTitle.length>15?i.assignmentTitle.slice(0,15)+"…":i.assignmentTitle,grade:Math.round(i.grade/i.maxGrade*100)}));return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Grades"}),n.jsx("p",{className:"text-muted-foreground",children:"Track your academic performance."})]}),n.jsx(Ra,{report_type:"grades",data:{avgGrade:r,highest:s,count:e.length}}),n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[n.jsx(W,{children:n.jsxs(U,{className:"pt-6 text-center",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"Average"}),n.jsxs("p",{className:"text-3xl font-bold text-primary",children:[r,"%"]})]})}),n.jsx(W,{children:n.jsxs(U,{className:"pt-6 text-center",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"Highest"}),n.jsxs("p",{className:"text-3xl font-bold text-success",children:[s,"%"]})]})}),n.jsx(W,{children:n.jsxs(U,{className:"pt-6 text-center",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"Graded Items"}),n.jsx("p",{className:"text-3xl font-bold",children:e.length})]})})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Grade Distribution"})}),n.jsx(U,{children:n.jsx(Xn,{width:"100%",height:250,children:n.jsxs(vo,{data:a,children:[n.jsx(bs,{strokeDasharray:"3 3",className:"stroke-border"}),n.jsx(kr,{dataKey:"name",tick:{fontSize:11},className:"fill-muted-foreground"}),n.jsx(Pr,{domain:[0,100],tick:{fontSize:11},className:"fill-muted-foreground"}),n.jsx(fn,{}),n.jsx(_r,{dataKey:"grade",fill:"hsl(192, 82%, 32%)",radius:[4,4,0,0]})]})})})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"All Grades"})}),n.jsx(U,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Assignment"}),n.jsx(L,{children:"Course"}),n.jsx(L,{children:"Type"}),n.jsx(L,{children:"Date"}),n.jsx(L,{className:"text-right",children:"Grade"}),n.jsx(L,{className:"w-10"})]})}),n.jsx(Be,{children:e.map(i=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:i.assignmentTitle}),n.jsx(T,{children:i.courseName}),n.jsx(T,{children:n.jsx(oe,{variant:"outline",className:"text-xs capitalize",children:i.type})}),n.jsx(T,{children:i.date}),n.jsxs(T,{className:"text-right font-bold",children:[i.grade,"/",i.maxGrade]}),n.jsx(T,{children:n.jsx(V2,{studentName:"Sarah Johnson"})})]},i.id))})]})})]})]})}const SDe=e=>e==="present"?"default":e==="absent"?"destructive":"secondary";function _De(){const{data:e=[],isLoading:t}=LB();if(t)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const r={present:0,absent:0,late:0,excused:0};e.forEach(o=>r[o.status]++);const s=e.length,a=s>0?((r.present+r.late)/s*100).toFixed(1):"0",i=[{name:"Present",value:r.present,color:"hsl(142, 71%, 45%)"},{name:"Late",value:r.late,color:"hsl(38, 92%, 50%)"},{name:"Absent",value:r.absent,color:"hsl(0, 72%, 51%)"},{name:"Excused",value:r.excused,color:"hsl(199, 89%, 48%)"}].filter(o=>o.value>0);return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Attendance"}),n.jsx("p",{className:"text-muted-foreground",children:"Your attendance record across all courses."})]}),n.jsx(Wn,{context:"student-attendance",variant:"insight"}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[n.jsxs(W,{className:"lg:col-span-1",children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Summary"})}),n.jsxs(U,{children:[n.jsxs("div",{className:"text-center mb-4",children:[n.jsxs("p",{className:"text-4xl font-bold text-primary",children:[a,"%"]}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Attendance Rate"})]}),n.jsx(Xn,{width:"100%",height:200,children:n.jsxs(_0,{children:[n.jsx(pa,{data:i,dataKey:"value",cx:"50%",cy:"50%",innerRadius:50,outerRadius:80,children:i.map((o,l)=>n.jsx(_d,{fill:o.color},l))}),n.jsx(fn,{}),n.jsx(Sl,{})]})})]})]}),n.jsxs(W,{className:"lg:col-span-2",children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Attendance Records"})}),n.jsx(U,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Date"}),n.jsx(L,{children:"Course"}),n.jsx(L,{children:"Status"})]})}),n.jsx(Be,{children:e.map(o=>n.jsxs(ee,{children:[n.jsx(T,{children:o.date}),n.jsx(T,{children:o.courseName}),n.jsx(T,{children:n.jsx(oe,{variant:SDe(o.status),className:"capitalize",children:o.status})})]},o.id))})]})})]})]})]})}const x$=["Monday","Tuesday","Wednesday","Thursday","Friday"],CDe=["08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00"];function kDe(){const{data:e=[],isLoading:t}=Ob();if(t)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const r=e.filter(o=>["c1","c2","c5","c8"].includes(o.courseId));function s(o,l){return r.find(c=>c.day===o&&c.startTime<=l&&c.endTime>l)}function a(o,l){return r.find(c=>c.day===o&&c.startTime===l)}function i(o){const l=parseInt(o.startTime.split(":")[0]),c=parseInt(o.endTime.split(":")[0]),d=parseInt(o.startTime.split(":")[1]),u=parseInt(o.endTime.split(":")[1]);return c-l+(u>0?.5:0)-(d>0?.5:0)}return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Timetable"}),n.jsx("p",{className:"text-muted-foreground",children:"Your weekly class schedule."})]}),n.jsx(W,{children:n.jsx(U,{className:"pt-6 overflow-x-auto",children:n.jsxs("div",{className:"min-w-[700px]",children:[n.jsxs("div",{className:"grid grid-cols-6 gap-1",children:[n.jsx("div",{className:"text-xs font-medium text-muted-foreground p-2"}),x$.map(o=>n.jsx("div",{className:"text-xs font-semibold text-center p-2 bg-muted rounded",children:o},o))]}),CDe.map(o=>n.jsxs("div",{className:"grid grid-cols-6 gap-1 min-h-[48px]",children:[n.jsx("div",{className:"text-xs text-muted-foreground p-2 flex items-start",children:o}),x$.map(l=>{const c=a(l,o),d=s(l,o);return c?n.jsxs("div",{className:"rounded-md p-2 text-xs text-white",style:{backgroundColor:c.color,minHeight:`${i(c)*48}px`},children:[n.jsx("p",{className:"font-semibold",children:c.courseName}),n.jsxs("p",{className:"opacity-80",children:[c.startTime,"-",c.endTime]}),n.jsx("p",{className:"opacity-70",children:c.room})]},l):d&&!c?n.jsx("div",{},l):n.jsx("div",{className:"border border-dashed border-border/50 rounded-md"},l)})]},o))]})})})]})}function PDe(){var r;const{user:e}=Ga(),{toast:t}=He();return n.jsxs("div",{className:"space-y-6 max-w-2xl",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Profile"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage your account information."})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Personal Information"})}),n.jsxs(U,{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center",children:n.jsx("span",{className:"text-lg font-bold text-primary",children:(((r=e==null?void 0:e.name)==null?void 0:r.split(" "))??[]).map(s=>s[0]).join("").slice(0,2).toUpperCase()||"??"})}),n.jsx(E,{variant:"outline",size:"sm",children:"Change Avatar"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"First Name"}),n.jsx(G,{defaultValue:e==null?void 0:e.name.split(" ")[0]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Last Name"}),n.jsx(G,{defaultValue:e==null?void 0:e.name.split(" ")[1]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Email"}),n.jsx(G,{defaultValue:e==null?void 0:e.email,type:"email"})]}),n.jsx(E,{onClick:()=>t({title:"Profile Updated",description:"Your information has been saved."}),children:"Save Changes"})]})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Change Password"})}),n.jsxs(U,{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Current Password"}),n.jsx(G,{type:"password"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"New Password"}),n.jsx(G,{type:"password"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Confirm Password"}),n.jsx(G,{type:"password"})]}),n.jsx(E,{onClick:()=>t({title:"Password Updated"}),children:"Update Password"})]})]})]})}function ADe(){const e=Bt(),{data:t=[],isLoading:r}=gx(),{data:s=[],isLoading:a}=FB();if(r||a)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const i=o=>s.find(l=>l.subject_id===o);return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"My Subjects"}),n.jsx("p",{className:"text-muted-foreground",children:"Select a subject to view your progress or start a diagnostic assessment."})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[t.map(o=>{const l=i(o.id),c=(l==null?void 0:l.overall_mastery)??0,d=!!l;return n.jsxs(W,{className:"hover:shadow-md transition-shadow",children:[n.jsx(se,{children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:n.jsx(Kt,{className:"h-5 w-5 text-primary"})}),n.jsxs("div",{children:[n.jsx(ie,{className:"text-lg",children:o.name}),n.jsx($e,{children:o.code})]})]})}),n.jsx(U,{className:"space-y-4",children:d?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Overall Mastery"}),n.jsxs("span",{className:"font-medium",children:[Math.round(c),"%"]})]}),n.jsx(kn,{value:c,className:"h-2"})]}),n.jsx("div",{className:"flex items-center justify-between text-sm text-muted-foreground",children:n.jsxs("span",{children:[(l==null?void 0:l.topics_mastered)??0," / ",(l==null?void 0:l.topics_total)??0," topics mastered"]})}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(E,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>e(`/student/proficiency/${o.id}`),children:"View Profile"}),n.jsxs(E,{size:"sm",className:"flex-1",onClick:()=>e(`/student/plan/${o.id}`),children:["Learning Plan ",n.jsx(Da,{className:"ml-1 h-3 w-3"})]})]})]}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"Take a diagnostic assessment to discover your proficiency level and get a personalized learning plan."}),n.jsxs(E,{className:"w-full",onClick:()=>e(`/student/diagnostic/${o.id}`),children:["Start Diagnostic ",n.jsx(Da,{className:"ml-1 h-4 w-4"})]})]})})]},o.id)}),t.length===0&&n.jsxs("div",{className:"col-span-full text-center py-12 text-muted-foreground",children:[n.jsx(Kt,{className:"h-12 w-12 mx-auto mb-3 opacity-40"}),n.jsx("p",{children:"No subjects available yet."})]})]})]})}function EDe(){const{subjectId:e}=Ht(),t=Bt(),{toast:r}=He(),s=Uce(),a=Kce(),[i,o]=p.useState(null),[l,c]=p.useState(null),[d,u]=p.useState(""),[f,h]=p.useState(0),[m,y]=p.useState(0),[x,j]=p.useState(!1),v=()=>{s.mutate(Number(e),{onSuccess:b=>{o(b.session.id),c(b.first_question),y(b.session.total_questions),h(1)},onError:()=>r({title:"Error",description:"Failed to start diagnostic",variant:"destructive"})})},g=()=>{!i||!l||!d||a.mutate({session_id:i,question_id:l.id,answer:d},{onSuccess:b=>{u(""),b.completed?j(!0):b.next_question&&(c(b.next_question),h(N=>N+1))},onError:()=>r({title:"Error",description:"Failed to submit answer",variant:"destructive"})})};return x?n.jsxs("div",{className:"max-w-lg mx-auto text-center py-16 space-y-6",children:[n.jsx(Un,{className:"h-16 w-16 text-green-500 mx-auto"}),n.jsx("h1",{className:"text-2xl font-bold",children:"Diagnostic Complete!"}),n.jsx("p",{className:"text-muted-foreground",children:"Your proficiency profile has been generated."}),n.jsxs("div",{className:"flex gap-3 justify-center",children:[n.jsx(E,{onClick:()=>t(`/student/proficiency/${e}`),children:"View Proficiency"}),n.jsx(E,{variant:"outline",onClick:()=>t(`/student/plan/${e}`),children:"See Learning Plan"})]})]}):i?n.jsxs("div",{className:"max-w-2xl mx-auto space-y-6",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[n.jsxs("span",{children:["Question ",f," of ~",m]}),n.jsx(oe,{variant:"outline",children:l==null?void 0:l.difficulty})]}),n.jsx(kn,{value:f/m*100,className:"h-2"})]}),l&&n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-2",children:[n.jsx("span",{children:l.domain_name}),n.jsx("span",{children:"·"}),n.jsx("span",{children:l.topic_name})]}),n.jsx(ie,{className:"text-lg",children:l.question_text})]}),n.jsxs(U,{className:"space-y-4",children:[l.options&&n.jsx(es,{value:d,onValueChange:u,children:l.options.map((b,N)=>n.jsxs("div",{className:"flex items-center space-x-3 rounded-lg border p-3 hover:bg-accent/50 transition-colors",children:[n.jsx(Bn,{value:b,id:`opt-${N}`}),n.jsx(q,{htmlFor:`opt-${N}`,className:"flex-1 cursor-pointer",children:b})]},N))}),n.jsxs(E,{className:"w-full",onClick:g,disabled:!d||a.isPending,children:[a.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Submit Answer ",n.jsx(Da,{className:"ml-1 h-4 w-4"})]})]})]})]}):n.jsxs("div",{className:"max-w-lg mx-auto text-center py-16 space-y-6",children:[n.jsx(vd,{className:"h-16 w-16 text-primary mx-auto opacity-60"}),n.jsx("h1",{className:"text-2xl font-bold",children:"Diagnostic Assessment"}),n.jsx("p",{className:"text-muted-foreground",children:"This adaptive test will assess your current knowledge across all topics. Questions adapt to your performance in real time."}),n.jsxs(E,{size:"lg",onClick:v,disabled:s.isPending,children:[s.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Begin Assessment"]})]})}function g$(e){return e>=80?"text-green-600":e>=60?"text-blue-600":e>=40?"text-yellow-600":e>=20?"text-orange-600":"text-red-600"}function ODe(e){return e>=80?"bg-green-100":e>=60?"bg-blue-100":e>=40?"bg-yellow-100":e>=20?"bg-orange-100":"bg-red-100"}function TDe(){const{subjectId:e}=Ht(),t=Bt(),{data:r=[],isLoading:s}=Vce({subject_id:Number(e)});if(s)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const a=[...new Set(r.map(o=>o.domain_name))],i=r.length>0?r.reduce((o,l)=>o+l.mastery,0)/r.length:0;return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Proficiency Profile"}),n.jsx("p",{className:"text-muted-foreground",children:"Your knowledge map across all topics."})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(E,{variant:"outline",onClick:()=>t(`/student/diagnostic/${e}`),children:"Retake Diagnostic"}),n.jsxs(E,{onClick:()=>t(`/student/plan/${e}`),children:["Learning Plan ",n.jsx(Da,{className:"ml-1 h-4 w-4"})]})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[n.jsx(W,{children:n.jsxs(U,{className:"pt-6 text-center",children:[n.jsx(vk,{className:"h-8 w-8 mx-auto text-primary mb-2"}),n.jsxs("div",{className:"text-3xl font-bold",children:[Math.round(i),"%"]}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Overall Mastery"})]})}),n.jsx(W,{children:n.jsxs(U,{className:"pt-6 text-center",children:[n.jsx(Dl,{className:"h-8 w-8 mx-auto text-green-500 mb-2"}),n.jsx("div",{className:"text-3xl font-bold",children:r.filter(o=>o.mastery>=80).length}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Topics Mastered"})]})}),n.jsx(W,{children:n.jsxs(U,{className:"pt-6 text-center",children:[n.jsx("div",{className:"h-8 w-8 mx-auto text-orange-500 mb-2 text-2xl font-bold",children:r.filter(o=>o.mastery<40).length}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Topics Needing Work"})]})})]}),a.map(o=>{const l=r.filter(d=>d.domain_name===o),c=l.reduce((d,u)=>d+u.mastery,0)/l.length;return n.jsxs(W,{children:[n.jsx(se,{children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(ie,{className:"text-lg",children:o}),n.jsxs(oe,{variant:"outline",className:g$(c),children:[Math.round(c),"%"]})]})}),n.jsx(U,{children:n.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:l.map(d=>n.jsxs("div",{className:`p-3 rounded-lg border ${ODe(d.mastery)} cursor-pointer hover:shadow-sm transition-shadow`,onClick:()=>t(`/student/topic/${d.topic_id}`),children:[n.jsxs("div",{className:"flex items-center justify-between mb-1",children:[n.jsx("span",{className:"text-sm font-medium truncate",children:d.topic_name}),n.jsxs("span",{className:`text-sm font-semibold ${g$(d.mastery)}`,children:[Math.round(d.mastery),"%"]})]}),n.jsx(kn,{value:d.mastery,className:"h-1.5"}),n.jsx("div",{className:"flex items-center justify-between mt-1",children:n.jsx(oe,{variant:"secondary",className:"text-xs",children:d.mastery_level})})]},d.topic_id))})})]},o)}),r.length===0&&n.jsx(W,{children:n.jsxs(U,{className:"text-center py-12 text-muted-foreground",children:[n.jsx("p",{children:"No proficiency data yet. Take a diagnostic assessment first."}),n.jsx(E,{className:"mt-4",onClick:()=>t(`/student/diagnostic/${e}`),children:"Start Diagnostic"})]})})]})}const MDe={locked:n.jsx(zf,{className:"h-4 w-4 text-muted-foreground"}),available:n.jsx(_j,{className:"h-4 w-4 text-blue-500"}),in_progress:n.jsx(TG,{className:"h-4 w-4 text-yellow-500"}),completed:n.jsx(Un,{className:"h-4 w-4 text-green-500"})},RDe={locked:"bg-muted text-muted-foreground",available:"bg-blue-50 text-blue-700 border-blue-200",in_progress:"bg-yellow-50 text-yellow-700 border-yellow-200",completed:"bg-green-50 text-green-700 border-green-200"};function $De(){const{subjectId:e}=Ht(),t=Bt(),{toast:r}=He(),{data:s,isLoading:a}=qce({subject_id:Number(e)}),i=Gce(),o=()=>{i.mutate({subject_id:Number(e)},{onSuccess:()=>r({title:"Plan Generated",description:"Your personalized learning plan is ready."}),onError:()=>r({title:"Error",description:"Failed to generate plan",variant:"destructive"})})};if(a)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});if(!s)return n.jsxs("div",{className:"max-w-lg mx-auto text-center py-16 space-y-6",children:[n.jsx(lt,{className:"h-16 w-16 text-primary mx-auto opacity-60"}),n.jsx("h1",{className:"text-2xl font-bold",children:"No Learning Plan Yet"}),n.jsx("p",{className:"text-muted-foreground",children:"Complete a diagnostic assessment first, then generate your personalized learning plan."}),n.jsxs("div",{className:"flex gap-3 justify-center",children:[n.jsx(E,{variant:"outline",onClick:()=>t(`/student/diagnostic/${e}`),children:"Take Diagnostic"}),n.jsxs(E,{onClick:o,disabled:i.isPending,children:[i.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Generate Plan"]})]})]});const l=s.items.sort((c,d)=>c.sequence-d.sequence);return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsxs("h1",{className:"text-2xl font-bold",children:["Learning Plan: ",s.subject_name]}),n.jsx("p",{className:"text-muted-foreground",children:s.ai_summary})]}),n.jsx(oe,{variant:s.status==="active"?"default":"secondary",children:s.status})]}),n.jsx(W,{children:n.jsxs(U,{className:"pt-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Overall Progress"}),n.jsxs("span",{className:"text-sm font-medium",children:[Math.round(s.overall_progress),"%"]})]}),n.jsx(kn,{value:s.overall_progress,className:"h-3"})]})}),n.jsx("div",{className:"space-y-3",children:l.map((c,d)=>n.jsx(W,{className:`border ${RDe[c.status]}`,children:n.jsx(U,{className:"py-4",children:n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsxs("div",{className:"flex flex-col items-center gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground font-mono",children:d+1}),MDe[c.status]]}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"font-medium",children:c.topic_name}),n.jsx(oe,{variant:"outline",className:"text-xs",children:c.domain_name})]}),n.jsxs("div",{className:"flex items-center gap-4 mt-1 text-xs text-muted-foreground",children:[n.jsxs("span",{children:["~",c.estimated_hours,"h estimated"]}),c.actual_hours>0&&n.jsxs("span",{children:[c.actual_hours,"h spent"]}),n.jsxs("span",{children:["Mastery: ",Math.round(c.mastery),"%"]})]}),c.status!=="locked"&&n.jsx(kn,{value:c.mastery,className:"h-1 mt-2"})]}),(c.status==="available"||c.status==="in_progress")&&n.jsxs(E,{size:"sm",onClick:()=>t(`/student/topic/${c.topic_id}`),children:[c.status==="in_progress"?"Continue":"Start"," ",n.jsx(Da,{className:"ml-1 h-3 w-3"})]}),c.status==="completed"&&n.jsx(E,{variant:"ghost",size:"sm",onClick:()=>t(`/student/topic/${c.topic_id}`),children:"Review"})]})})},c.id))})]})}const IDe={pdf:n.jsx(Yn,{className:"h-4 w-4"}),video:n.jsx(Ll,{className:"h-4 w-4"}),link:n.jsx(kj,{className:"h-4 w-4"}),document:n.jsx(Kt,{className:"h-4 w-4"}),interactive:n.jsx(fi,{className:"h-4 w-4"})};function DDe(){const{topicId:e}=Ht(),t=Bt(),{data:r,isLoading:s}=Wce(Number(e));return s?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):r?n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[n.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:r.topic_name}),r.has_content_gap&&n.jsx(oe,{variant:"secondary",className:"mt-2",children:"AI-supplemented content"})]}),r.ai_content&&n.jsxs(W,{children:[n.jsx(se,{children:n.jsxs(ie,{className:"text-lg flex items-center gap-2",children:[n.jsx(fi,{className:"h-5 w-5 text-primary"}),"AI Explanation"]})}),n.jsxs(U,{className:"space-y-4",children:[n.jsx("p",{className:"text-sm leading-relaxed",children:r.ai_content.explanation}),r.ai_content.key_points.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("h4",{className:"font-medium text-sm",children:"Key Points"}),n.jsx("ul",{className:"list-disc pl-5 space-y-1 text-sm text-muted-foreground",children:r.ai_content.key_points.map((a,i)=>n.jsx("li",{children:a},i))})]}),r.ai_content.examples.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("h4",{className:"font-medium text-sm",children:"Examples"}),r.ai_content.examples.map((a,i)=>n.jsx("div",{className:"p-3 bg-accent/50 rounded-lg text-sm",children:a},i))]})]})]}),r.resources.length>0&&n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{className:"text-lg",children:"Resources"}),n.jsxs($e,{children:[r.resources.length," resources available"]})]}),n.jsx(U,{children:n.jsx("div",{className:"space-y-3",children:r.resources.map(a=>n.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border hover:bg-accent/50 transition-colors",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[IDe[a.resource_type]??n.jsx(Yn,{className:"h-4 w-4"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:a.name}),n.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:a.resource_type})]})]}),a.url&&n.jsx(E,{variant:"ghost",size:"sm",asChild:!0,children:n.jsxs("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",children:["Open ",n.jsx(IG,{className:"ml-1 h-3 w-3"})]})})]},a.id))})})]}),n.jsx(qs,{}),n.jsxs("div",{className:"flex gap-3",children:[n.jsxs(E,{variant:"outline",className:"flex-1",children:[n.jsx(Kt,{className:"mr-2 h-4 w-4"})," Practice Questions"]}),n.jsxs(E,{className:"flex-1",children:[n.jsx(tH,{className:"mr-2 h-4 w-4"})," Mastery Quiz"]})]})]}),n.jsx("div",{className:"space-y-6",children:n.jsx(z2,{})})]}):n.jsxs("div",{className:"text-center py-16 text-muted-foreground",children:[n.jsx(Kt,{className:"h-12 w-12 mx-auto mb-3 opacity-40"}),n.jsx("p",{children:"Topic content not found."}),n.jsx(E,{variant:"outline",className:"mt-4",onClick:()=>t(-1),children:"Go Back"})]})}function LDe(){const{data:e,isLoading:t}=Er(),{data:r,isLoading:s}=Nd(),a=(e==null?void 0:e.items)??[];r==null||r.items;const i=[],o=[];if(t||s)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const l=a,c=i.filter(u=>u.status==="pending"),d=[{label:"Active Courses",value:String(l.filter(u=>u.status==="active").length),icon:Kt,color:"text-primary"},{label:"Total Students",value:"55",icon:as,color:"text-info"},{label:"Pending Grading",value:String(c.length),icon:gd,color:"text-warning"},{label:"Avg. Pass Rate",value:"82%",icon:Dl,color:"text-success"}];return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Teacher Dashboard"}),n.jsx("p",{className:"text-muted-foreground",children:"Overview of your teaching activities."})]}),n.jsx(Wn,{context:"teacher-dashboard",variant:"recommendation"}),n.jsx(F2,{}),n.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:d.map(u=>n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:u.label}),n.jsx("p",{className:"text-2xl font-bold",children:u.value})]}),n.jsx(u.icon,{className:`h-8 w-8 ${u.color} opacity-80`})]})})},u.label))}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[n.jsxs(W,{children:[n.jsxs(se,{className:"flex flex-row items-center justify-between pb-2",children:[n.jsx(ie,{className:"text-lg",children:"My Courses"}),n.jsx(E,{variant:"ghost",size:"sm",asChild:!0,children:n.jsxs(Dt,{to:"/teacher/courses",children:["View All ",n.jsx(Da,{className:"ml-1 h-3 w-3"})]})})]}),n.jsx(U,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Course"}),n.jsx(L,{children:"Students"}),n.jsx(L,{children:"Status"})]})}),n.jsx(Be,{children:l.map(u=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:u.title}),n.jsxs(T,{children:[u.enrolled,"/",u.max_capacity]}),n.jsx(T,{children:n.jsx(oe,{variant:u.status==="active"?"default":"secondary",className:"capitalize",children:u.status})})]},u.id))})]})})]}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs(W,{children:[n.jsxs(se,{className:"flex flex-row items-center justify-between pb-2",children:[n.jsx(ie,{className:"text-lg",children:"Pending Grading"}),n.jsx(E,{variant:"ghost",size:"sm",asChild:!0,children:n.jsxs(Dt,{to:"/teacher/assignments",children:["View All ",n.jsx(Da,{className:"ml-1 h-3 w-3"})]})})]}),n.jsx(U,{className:"space-y-3",children:c.slice(0,4).map(u=>n.jsxs("div",{className:"flex items-center justify-between p-2 rounded border",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:u.studentName}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Submitted ",u.submittedAt]})]}),n.jsx(oe,{variant:"secondary",children:"Pending"})]},u.id))})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Recent Activity"})}),n.jsx(U,{className:"space-y-2",children:o.slice(0,4).map(u=>n.jsxs("div",{className:"text-sm",children:[n.jsx("span",{className:"font-medium",children:u.user})," ",n.jsx("span",{className:"text-muted-foreground",children:u.action})," ",n.jsx("span",{children:u.target}),n.jsxs("span",{className:"text-xs text-muted-foreground ml-2",children:["· ",u.time]})]},u.id))})]})]})]})]})}function FDe(){const{data:e,isLoading:t}=Er(),s=(e==null?void 0:e.items)??[],{toast:a}=He();return t?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"My Courses"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage your courses and materials."})]}),n.jsx(E,{asChild:!0,children:n.jsxs(Dt,{to:"/teacher/courses/new",children:[n.jsx(mt,{className:"mr-2 h-4 w-4"}),"New Course"]})})]}),n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:s.map(i=>n.jsxs(W,{className:"hover:shadow-md transition-shadow",children:[n.jsx("div",{className:"h-2 rounded-t-lg bg-primary"}),n.jsxs(U,{className:"pt-5 space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(oe,{variant:i.status==="active"?"default":"secondary",className:"capitalize",children:i.status}),n.jsx("span",{className:"text-xs text-muted-foreground",children:i.code})]}),n.jsx("h3",{className:"font-semibold",children:i.title}),n.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:i.description}),n.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx(as,{className:"h-3 w-3"}),i.enrolled," students"]}),n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx(Kt,{className:"h-3 w-3"}),i.modules.length," modules"]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(E,{size:"sm",variant:"outline",asChild:!0,children:n.jsx(Dt,{to:`/teacher/courses/${i.id}/edit`,children:"Edit"})}),n.jsx(E,{size:"sm",variant:"ghost",onClick:()=>a({title:"Course archived"}),children:n.jsx(NG,{className:"h-3 w-3"})})]})]})]},i.id))})]})}const Ag=["Basic Info","Schedule","Review"];function v$(){const[e,t]=p.useState(0),r=Bt(),{toast:s}=He(),a=$B(),[i,o]=p.useState({title:"",code:"",description:"",level:"Beginner",start_date:"",end_date:"",max_capacity:""});function l(){a.mutate({title:i.title,code:i.code,description:i.description,level:i.level,instructor_id:0,max_capacity:Number(i.max_capacity)||30,start_date:i.start_date,end_date:i.end_date},{onSuccess:()=>{s({title:"Course Created",description:"Your new course has been saved."}),r("/admin/courses")},onError:c=>s({title:"Error",description:c.message,variant:"destructive"})})}return n.jsxs("div",{className:"space-y-6 max-w-3xl",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Course Builder"}),n.jsxs("p",{className:"text-muted-foreground",children:["Create a new course in ",Ag.length," steps."]})]}),n.jsx("div",{className:"flex gap-2 mb-6",children:Ag.map((c,d)=>n.jsx("div",{className:`flex-1 h-2 rounded-full ${d<=e?"bg-primary":"bg-muted"}`},c))}),n.jsxs("p",{className:"text-sm font-medium mb-4",children:["Step ",e+1,": ",Ag[e]]}),n.jsx(W,{children:n.jsxs(U,{className:"pt-6 space-y-4",children:[e===0&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Course Title"}),n.jsx(G,{value:i.title,onChange:c=>o(d=>({...d,title:c.target.value})),placeholder:"e.g. IELTS Academic Writing"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Course Code"}),n.jsx(G,{value:i.code,onChange:c=>o(d=>({...d,code:c.target.value})),placeholder:"e.g. IELTS-W101"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Description"}),n.jsx(on,{value:i.description,onChange:c=>o(d=>({...d,description:c.target.value})),placeholder:"Describe the course...",rows:4})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Level"}),n.jsxs(Oe,{value:i.level,onValueChange:c=>o(d=>({...d,level:c})),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"Beginner",children:"Beginner"}),n.jsx(Y,{value:"Intermediate",children:"Intermediate"}),n.jsx(Y,{value:"Advanced",children:"Advanced"})]})]})]})]}),e===1&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Start Date"}),n.jsx(G,{type:"date",value:i.start_date,onChange:c=>o(d=>({...d,start_date:c.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"End Date"}),n.jsx(G,{type:"date",value:i.end_date,onChange:c=>o(d=>({...d,end_date:c.target.value}))})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Max Capacity"}),n.jsx(G,{type:"number",value:i.max_capacity,onChange:c=>o(d=>({...d,max_capacity:c.target.value})),placeholder:"30"})]})]}),e===2&&n.jsxs("div",{className:"space-y-3 py-4",children:[n.jsx("p",{className:"font-medium text-lg text-center",children:"Review & Publish"}),n.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[n.jsx("p",{className:"text-muted-foreground",children:"Title:"}),n.jsx("p",{className:"font-medium",children:i.title||"—"}),n.jsx("p",{className:"text-muted-foreground",children:"Code:"}),n.jsx("p",{className:"font-medium",children:i.code||"—"}),n.jsx("p",{className:"text-muted-foreground",children:"Level:"}),n.jsx("p",{className:"font-medium",children:i.level}),n.jsx("p",{className:"text-muted-foreground",children:"Capacity:"}),n.jsx("p",{className:"font-medium",children:i.max_capacity||"30"}),n.jsx("p",{className:"text-muted-foreground",children:"Dates:"}),n.jsxs("p",{className:"font-medium",children:[i.start_date||"—"," — ",i.end_date||"—"]})]}),i.description&&n.jsx("p",{className:"text-sm mt-2 text-muted-foreground",children:i.description})]})]})}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx(E,{variant:"outline",disabled:e===0,onClick:()=>t(c=>c-1),children:"Previous"}),et(c=>c+1),disabled:e===0&&!i.title,children:"Next"}):n.jsx(E,{onClick:l,disabled:a.isPending||!i.title,children:a.isPending?"Publishing...":"Publish Course"})]})]})}function BDe(e,t){if(e&&typeof e=="object"){const r=e;return{title:typeof r.title=="string"?r.title:`Exercise ${t+1}`,description:typeof r.description=="string"?r.description:void 0,marks:typeof r.marks=="number"?r.marks:typeof r.marks=="string"?Number(r.marks):void 0}}return{title:String(e)}}function zDe(){const[e,t]=p.useState(!1),[r,s]=p.useState("reading"),[a,i]=p.useState("b2"),[o,l]=p.useState(5),[c,d]=p.useState(""),[u,f]=p.useState(null),{toast:h}=He(),m=ae({mutationFn:()=>Wo.generate(r,{title:c.trim()||`${r} practice set`,difficulty:a,count:o}),onSuccess:g=>{const b=Array.isArray(g.questions)?g.questions:Array.isArray(g.exercises)?g.exercises:[];f(b)},onError:g=>{h({variant:"destructive",title:"Generation failed",description:g.message||"Could not generate exercises."})}}),y=()=>{f(null),m.mutate()},x=ae({mutationFn:()=>Wo.saveGenerated(r,u??[]),onSuccess:g=>{h({title:"Saved",description:`${g.saved} assignments saved successfully.`}),t(!1)},onError:g=>{h({variant:"destructive",title:"Save failed",description:g.message||"Could not save generated assignments."})}}),j=u,v=g=>{f(b=>b?b.filter((N,w)=>w!==g):null)};return n.jsxs(Qe,{open:e,onOpenChange:g=>{t(g),g||(f(null),m.reset())},children:[n.jsx(cr,{asChild:!0,children:n.jsxs(E,{variant:"outline",size:"sm",children:[n.jsx(lt,{className:"h-3.5 w-3.5 mr-1 text-primary"})," Generate with AI"]})}),n.jsxs(Ue,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[n.jsx(Ke,{children:n.jsxs(Ge,{className:"flex items-center gap-2",children:[n.jsx(lt,{className:"h-4 w-4 text-primary"})," AI Assignment Generator"]})}),j?n.jsxs("div",{className:"space-y-3",children:[n.jsxs("p",{className:"text-sm text-muted-foreground",children:["AI generated ",j.length," assignments. Edit or remove before saving."]}),j.map((g,b)=>{const N=BDe(g,b);return n.jsx("div",{className:"rounded-lg border p-3 space-y-1",children:n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:N.title}),N.description&&n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:N.description}),N.marks!==void 0&&!Number.isNaN(N.marks)&&n.jsxs("p",{className:"text-xs font-semibold mt-1",children:[N.marks," marks"]})]}),n.jsx(E,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>v(b),children:n.jsx($t,{className:"h-3.5 w-3.5 text-destructive"})})]})},b)}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(E,{className:"flex-1",onClick:()=>x.mutate(),disabled:x.isPending||!(j!=null&&j.length),children:x.isPending?n.jsxs(n.Fragment,{children:[n.jsx(Re,{className:"h-4 w-4 mr-2 animate-spin"})," Saving..."]}):"Save All"}),n.jsx(E,{variant:"outline",onClick:()=>{f(null),m.reset()},children:"Regenerate"})]})]}):n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Module Type"}),n.jsxs(Oe,{value:r,onValueChange:g=>s(g),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"reading",children:"Reading"}),n.jsx(Y,{value:"listening",children:"Listening"}),n.jsx(Y,{value:"writing",children:"Writing"}),n.jsx(Y,{value:"speaking",children:"Speaking"})]})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Difficulty"}),n.jsxs(Oe,{value:a,onValueChange:i,children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsx(Ee,{children:["A1","A2","B1","B2","C1","C2"].map(g=>n.jsx(Y,{value:g.toLowerCase(),children:g},g))})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Count"}),n.jsx(G,{type:"number",value:o,min:1,max:10,onChange:g=>l(Number(g.target.value)||1)})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Topic / Focus Area"}),n.jsx(G,{placeholder:"e.g. Academic reading comprehension",value:c,onChange:g=>d(g.target.value)})]}),n.jsx(E,{className:"w-full",onClick:y,disabled:m.isPending,children:m.isPending?n.jsxs(n.Fragment,{children:[n.jsx(Re,{className:"h-4 w-4 mr-2 animate-spin"})," Generating..."]}):n.jsxs(n.Fragment,{children:[n.jsx(lt,{className:"h-4 w-4 mr-2"})," Generate Assignments"]})})]})]})]})}function VDe(){const{data:e,isLoading:t}=Nd(),r=(e==null?void 0:e.items)??[],s=[];if(t)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const a=r,i=s.filter(l=>l.status==="pending"),o=s.filter(l=>l.status==="graded");return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Assignments"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage and grade student assignments."})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(vx,{type:"assignment"}),n.jsx(zDe,{})]})]}),n.jsx(Wn,{context:"teacher-assignments",variant:"insight"}),n.jsxs(Us,{defaultValue:"all",children:[n.jsxs(ws,{children:[n.jsxs(Et,{value:"all",children:["All (",a.length,")"]}),n.jsxs(Et,{value:"pending",children:["Pending Review (",i.length,")"]}),n.jsxs(Et,{value:"graded",children:["Graded (",o.length,")"]})]}),n.jsx(Lt,{value:"all",className:"mt-4 space-y-3",children:a.map(l=>n.jsx(Dt,{to:`/teacher/assignments/${l.id}`,children:n.jsx(W,{className:"hover:bg-muted/30 transition-colors",children:n.jsxs(U,{className:"pt-4 flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("p",{className:"font-medium text-sm",children:l.title}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:[l.entity_name," · Due: ",l.end_date]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(oe,{variant:"outline",className:"capitalize text-xs",children:l.state}),n.jsx(oe,{variant:l.completed_count>=l.assignee_count&&l.assignee_count>0?"default":"secondary",className:"capitalize",children:l.state})]})]})})},l.id))}),n.jsx(Lt,{value:"pending",className:"mt-4 space-y-3",children:i.map(l=>n.jsx(W,{children:n.jsxs(U,{className:"pt-4 flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("p",{className:"font-medium text-sm",children:l.studentName}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Submitted: ",l.submittedAt]})]}),n.jsx(oe,{variant:"secondary",children:"Pending"})]})},l.id))}),n.jsx(Lt,{value:"graded",className:"mt-4 space-y-3",children:o.map(l=>n.jsx(W,{children:n.jsxs(U,{className:"pt-4 flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("p",{className:"font-medium text-sm",children:l.studentName}),n.jsx("p",{className:"text-xs text-muted-foreground",children:l.feedback})]}),n.jsx("span",{className:"font-bold text-primary",children:l.grade})]})},l.id))})]})]})}function qDe(){const{id:e}=Ht(),{data:t,isLoading:r}=Nd(),s=(t==null?void 0:t.items)??[],a=[],[i,o]=p.useState(!1),[l,c]=p.useState(""),{toast:d}=He();if(r)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const u=s.find(m=>String(m.id)===e),f=a.filter(m=>m.assignmentId===e),h=100;return u?n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(E,{variant:"ghost",size:"icon",asChild:!0,children:n.jsx(Dt,{to:"/teacher/assignments",children:n.jsx(xd,{className:"h-4 w-4"})})}),n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:u.title}),n.jsxs("p",{className:"text-muted-foreground",children:[u.entity_name," · Due: ",u.end_date]})]})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsxs(ie,{className:"text-lg",children:["Submissions (",f.length,")"]})}),n.jsx(U,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Student"}),n.jsx(L,{children:"Submitted"}),n.jsx(L,{children:"Status"}),n.jsx(L,{children:"Grade"}),n.jsx(L,{})]})}),n.jsx(Be,{children:f.map(m=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:m.studentName}),n.jsx(T,{className:"text-sm",children:m.submittedAt}),n.jsx(T,{children:n.jsx(oe,{variant:m.status==="graded"?"default":"secondary",className:"capitalize",children:m.status})}),n.jsx(T,{children:m.grade??"—"}),n.jsx(T,{children:m.status==="pending"&&n.jsx(E,{size:"sm",onClick:()=>{c(m.studentName),o(!0)},children:"Grade"})})]},m.id))})]})})]}),n.jsx(Qe,{open:i,onOpenChange:o,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsxs(Ge,{children:["Grade Submission — ",l]})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsxs(q,{children:["Grade (out of ",h,")"]}),n.jsx(G,{type:"number",placeholder:"0"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Feedback"}),n.jsx(on,{placeholder:"Write feedback...",rows:4})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),n.jsx(E,{onClick:()=>{o(!1),d({title:"Grade Saved",description:`${l}'s submission has been graded.`})},children:"Save Grade"})]})]})})]}):n.jsx("div",{className:"p-8 text-center text-muted-foreground",children:"Assignment not found."})}function WDe(){const[e,t]=p.useState(()=>new Set),[r,s]=p.useState(!1),{data:a,isLoading:i,isError:o,error:l}=ye({queryKey:["ai","alerts"],queryFn:()=>Ol.getAlerts()}),c=(a==null?void 0:a.alerts)??[],d=c.filter((u,f)=>!e.has(String(f)));return i?n.jsxs("div",{className:"rounded-lg border border-warning/30 bg-warning/10 p-4 flex items-center gap-3",children:[n.jsx(Re,{className:"h-5 w-5 animate-spin text-warning shrink-0"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading alerts…"})]}):o&&!r?n.jsxs("div",{className:"rounded-lg border border-warning/30 bg-warning/10 p-4 flex items-start gap-3",children:[n.jsx(Pl,{className:"h-5 w-5 text-warning shrink-0 mt-0.5"}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("p",{className:"text-sm font-medium flex items-center gap-1",children:[n.jsx(lt,{className:"h-3 w-3 text-primary"})," Alerts unavailable"]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:l instanceof Error?l.message:"Could not load alerts."})]}),n.jsx(E,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>s(!0),children:n.jsx(ts,{className:"h-4 w-4"})})]}):o&&r?null:c.length?d.length?n.jsx("div",{className:"space-y-3",children:d.map((u,f)=>n.jsxs("div",{className:"rounded-lg border border-warning/30 bg-warning/10 p-4 flex items-start gap-3",children:[n.jsx(Pl,{className:"h-5 w-5 text-warning shrink-0 mt-0.5"}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("p",{className:"text-sm font-medium flex items-center gap-1",children:[n.jsx(lt,{className:"h-3 w-3 text-primary"})," ",u.title]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:u.description})]}),n.jsx(E,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>t(h=>new Set(h).add(String(f))),children:n.jsx(ts,{className:"h-4 w-4"})})]},f))}):null:n.jsxs("div",{className:"rounded-lg border border-muted bg-muted/20 p-4 flex items-start gap-3",children:[n.jsx(lt,{className:"h-5 w-5 text-muted-foreground shrink-0 mt-0.5"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"No AI alerts right now."})]})}function tj({riskLevel:e,reasons:t}){if(!e)return n.jsxs(uo,{children:[n.jsx(fo,{asChild:!0,children:n.jsx(oe,{variant:"outline",className:"text-xs cursor-help",children:"Unknown"})}),n.jsx(vi,{children:n.jsx("p",{className:"text-xs max-w-[200px]",children:"Risk data not available from profile."})})]});const r=e==="At Risk"?"destructive":e==="Monitor"?"secondary":"default",s=t!=null&&t.filter(Boolean).length?t.filter(Boolean).join(" · "):"No additional details provided.";return n.jsxs(uo,{children:[n.jsx(fo,{asChild:!0,children:n.jsx(oe,{variant:r,className:"text-xs cursor-help",children:e})}),n.jsx(vi,{children:n.jsx("p",{className:"text-xs max-w-[200px]",children:s})})]})}const UDe=[{week:"W1",rate:92},{week:"W2",rate:88},{week:"W3",rate:95},{week:"W4",rate:85},{week:"W5",rate:90},{week:"W6",rate:87}];function KDe(){var v;const{data:e,isLoading:t}=_o(),{data:r,isLoading:s}=Qa({size:500}),a=(e==null?void 0:e.items)??[],i=(r==null?void 0:r.items)??[],[o,l]=p.useState(""),[c,d]=p.useState(!1),[u,f]=p.useState({}),{toast:h}=He(),m=ae({mutationFn:g=>bn.recordAttendance(g),onSuccess:()=>{d(!1),h({title:"Attendance saved"})},onError:g=>h({title:"Error",description:g.message,variant:"destructive"})});if(t||s)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const y=o?Number(o):(v=a[0])==null?void 0:v.id,x=a.find(g=>g.id===y),j=i.filter(g=>g.batch_id===y);return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Attendance"}),n.jsx("p",{className:"text-muted-foreground",children:"Track and mark student attendance."})]}),n.jsx(E,{onClick:()=>d(!0),children:"Mark Attendance"})]}),n.jsx(WDe,{}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Batch:"}),n.jsxs(Oe,{value:y!=null?String(y):"",onValueChange:l,children:[n.jsx(Ae,{className:"w-64",children:n.jsx(Me,{})}),n.jsx(Ee,{children:a.map(g=>n.jsx(Y,{value:String(g.id),children:g.name},g.id))})]})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Attendance Trend"})}),n.jsx(U,{children:n.jsx(Xn,{width:"100%",height:220,children:n.jsxs(Px,{data:UDe,children:[n.jsx(bs,{strokeDasharray:"3 3",className:"stroke-border"}),n.jsx(kr,{dataKey:"week",className:"fill-muted-foreground",tick:{fontSize:12}}),n.jsx(Pr,{domain:[70,100],className:"fill-muted-foreground",tick:{fontSize:12}}),n.jsx(fn,{}),n.jsx(Ao,{type:"monotone",dataKey:"rate",stroke:"hsl(192, 82%, 32%)",strokeWidth:2,dot:{r:4}})]})})})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsxs(ie,{className:"text-lg",children:["Students — ",x==null?void 0:x.name]})}),n.jsx(U,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Student"}),n.jsx(L,{children:"Rate"}),n.jsx(L,{children:"AI Risk"})]})}),n.jsx(Be,{children:j.map(g=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:g.name}),n.jsx(T,{children:"—"}),n.jsx(T,{children:n.jsx(tj,{})})]},g.id))})]})})]})]}),n.jsx(Qe,{open:c,onOpenChange:d,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsxs(Ge,{children:["Mark Attendance — ",x==null?void 0:x.name]})}),n.jsx("div",{className:"space-y-3",children:j.map(g=>n.jsxs("div",{className:"flex items-center justify-between p-2 rounded border",children:[n.jsx("span",{className:"text-sm font-medium",children:g.name}),n.jsxs(Oe,{value:u[g.id]||"present",onValueChange:b=>f(N=>({...N,[g.id]:b})),children:[n.jsx(Ae,{className:"w-28",children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"present",children:"Present"}),n.jsx(Y,{value:"absent",children:"Absent"}),n.jsx(Y,{value:"late",children:"Late"}),n.jsx(Y,{value:"excused",children:"Excused"})]})]})]},g.id))}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),n.jsx(E,{disabled:m.isPending,onClick:()=>{const g=j.map(b=>({student_id:b.id,status:u[b.id]||"present"}));m.mutate({course_id:(x==null?void 0:x.course_id)||0,date:new Date().toISOString().split("T")[0],records:g})},children:m.isPending?"Saving...":"Save"})]})]})})]})}function GDe(){var c,d;const{data:e,isLoading:t}=Qa({size:500}),r=((e==null?void 0:e.items)??[]).map(RB),[s,a]=p.useState(""),[i,o]=p.useState(null),l=r.filter(u=>u.name.toLowerCase().includes(s.toLowerCase())||u.email.toLowerCase().includes(s.toLowerCase()));return t?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"My Students"}),n.jsx("p",{className:"text-muted-foreground",children:"View and manage students across your courses."})]}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search students...",value:s,onChange:u=>a(u.target.value),className:"pl-9"})]}),n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Student"}),n.jsx(L,{children:"Batch"}),n.jsx(L,{children:"Attendance"}),n.jsx(L,{children:"Avg Grade"}),n.jsx(L,{children:"AI Risk"}),n.jsx(L,{children:"AI"}),n.jsx(L,{})]})}),n.jsx(Be,{children:l.map(u=>{var f,h;return n.jsxs(ee,{children:[n.jsx(T,{children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"h-7 w-7 rounded-full bg-primary/10 flex items-center justify-center text-xs font-medium text-primary",children:(u.avatar??u.name.slice(0,1)).toUpperCase()}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:u.name}),n.jsx("p",{className:"text-xs text-muted-foreground",children:u.email})]})]})}),n.jsx(T,{className:"text-sm",children:((h=(f=u.entities)==null?void 0:f[0])==null?void 0:h.name)??"—"}),n.jsx(T,{className:"text-sm",children:"—"}),n.jsx(T,{className:"text-sm",children:"—"}),n.jsx(T,{children:n.jsx(tj,{})}),n.jsx(T,{children:n.jsx(V2,{studentName:u.name})}),n.jsx(T,{children:n.jsx(E,{size:"sm",variant:"ghost",onClick:()=>o(u),children:"View"})})]},u.id)})})]})})}),n.jsx(Qe,{open:!!i,onOpenChange:()=>o(null),children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:i==null?void 0:i.name})}),i&&n.jsxs("div",{className:"space-y-3",children:[n.jsxs("p",{className:"text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Email:"})," ",i.email]}),n.jsxs("p",{className:"text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Batch:"})," ",((d=(c=i.entities)==null?void 0:c[0])==null?void 0:d.name)??"—"]}),n.jsxs("p",{className:"text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Attendance:"})," —"]}),n.jsxs("p",{className:"text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Average Grade:"})," —"]}),n.jsxs("p",{className:"text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Joined:"})," —"]}),n.jsxs("p",{className:"text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"AI Risk:"})," ",n.jsx(tj,{})]})]})]})})]})}const y$=["Monday","Tuesday","Wednesday","Thursday","Friday"],HDe=["08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00"],QDe="hsl(192, 82%, 32%)";function YDe(e,t,r){return e.find(s=>s.day===t&&s.start_time===r)}function XDe(e,t,r){return e.find(s=>s.day===t&&s.start_time<=r&&s.end_time>r)}function ZDe(){const{data:e=[],isLoading:t}=Ob();if(t)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const r=e;return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"My Timetable"}),n.jsx("p",{className:"text-muted-foreground",children:"Your weekly teaching schedule."})]}),n.jsx(W,{children:n.jsx(U,{className:"pt-6 overflow-x-auto",children:n.jsxs("div",{className:"min-w-[700px]",children:[n.jsxs("div",{className:"grid grid-cols-6 gap-1",children:[n.jsx("div",{className:"text-xs font-medium text-muted-foreground p-2"}),y$.map(s=>n.jsx("div",{className:"text-xs font-semibold text-center p-2 bg-muted rounded",children:s},s))]}),HDe.map(s=>n.jsxs("div",{className:"grid grid-cols-6 gap-1 min-h-[48px]",children:[n.jsx("div",{className:"text-xs text-muted-foreground p-2 flex items-start",children:s}),y$.map(a=>{const i=YDe(r,a,s),o=XDe(r,a,s);return i?n.jsxs("div",{className:"rounded-md p-2 text-xs text-white",style:{backgroundColor:QDe},children:[n.jsx("p",{className:"font-semibold",children:i.course_name}),n.jsx("p",{className:"opacity-80",children:i.batch_name}),n.jsx("p",{className:"opacity-70",children:i.room})]},a):o?n.jsx("div",{},a):n.jsx("div",{className:"border border-dashed border-border/50 rounded-md"},a)})]},s))]})})})]})}function JDe(){const{user:e}=Ga(),{toast:t}=He();return n.jsxs("div",{className:"space-y-6 max-w-2xl",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Profile"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage your account information."})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Personal Information"})}),n.jsxs(U,{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center",children:n.jsx("span",{className:"text-lg font-bold text-primary",children:e==null?void 0:e.avatar})}),n.jsx(E,{variant:"outline",size:"sm",children:"Change Avatar"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"First Name"}),n.jsx(G,{defaultValue:e==null?void 0:e.name.split(" ").slice(0,-1).join(" ")})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Last Name"}),n.jsx(G,{defaultValue:e==null?void 0:e.name.split(" ").slice(-1)[0]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Email"}),n.jsx(G,{defaultValue:e==null?void 0:e.email,type:"email"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Specialization"}),n.jsx(G,{defaultValue:"IELTS / Academic Writing"})]}),n.jsx(E,{onClick:()=>t({title:"Profile Updated"}),children:"Save Changes"})]})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Change Password"})}),n.jsxs(U,{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Current Password"}),n.jsx(G,{type:"password"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"New Password"}),n.jsx(G,{type:"password"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Confirm Password"}),n.jsx(G,{type:"password"})]}),n.jsx(E,{onClick:()=>t({title:"Password Updated"}),children:"Update Password"})]})]})]})}const eLe=No({difficulty_step_up_threshold:Js().min(0).max(100),difficulty_step_down_threshold:Js().min(0).max(100),micro_lesson_trigger:Js().min(0).max(50),module_skip_threshold:Js().min(0).max(100),no_progress_alert_days:Js().min(1).max(90),max_retries_per_exercise:Js().min(0).max(20)}),tLe={difficulty_step_up_threshold:85,difficulty_step_down_threshold:50,micro_lesson_trigger:2,module_skip_threshold:95,no_progress_alert_days:3,max_retries_per_exercise:3};function nLe(){const{data:e,isLoading:t}=hue(),r=pue(),s=Vl({resolver:ql(eLe),defaultValues:tLe});p.useEffect(()=>{e&&s.reset({difficulty_step_up_threshold:e.difficulty_step_up_threshold,difficulty_step_down_threshold:e.difficulty_step_down_threshold,micro_lesson_trigger:e.micro_lesson_trigger,module_skip_threshold:e.module_skip_threshold,no_progress_alert_days:e.no_progress_alert_days,max_retries_per_exercise:e.max_retries_per_exercise})},[e,s]);const a=i=>{r.mutate(i,{onSuccess:()=>ct.success("Settings saved."),onError:o=>ct.error(o instanceof Error?o.message:"Save failed")})};return t&&!e?n.jsx("div",{className:"p-6 text-muted-foreground",children:"Loading settings…"}):n.jsxs("div",{className:"space-y-6 p-6 max-w-xl mx-auto",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Adaptive thresholds"}),n.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Tune pacing and escalation"})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Engine parameters"}),n.jsx($e,{children:"Sliders use whole percentages unless noted"})]}),n.jsx(U,{children:n.jsx(Wl,{...s,children:n.jsxs("form",{onSubmit:s.handleSubmit(a),className:"space-y-8",children:[n.jsx(et,{control:s.control,name:"difficulty_step_up_threshold",render:({field:i})=>n.jsxs(tt,{children:[n.jsxs(at,{children:["Difficulty step-up threshold (",i.value,"%)"]}),n.jsx(rt,{children:n.jsx(oa,{min:0,max:100,step:1,value:[i.value],onValueChange:o=>i.onChange(o[0])})}),n.jsx(ot,{})]})}),n.jsx(et,{control:s.control,name:"difficulty_step_down_threshold",render:({field:i})=>n.jsxs(tt,{children:[n.jsxs(at,{children:["Difficulty step-down threshold (",i.value,"%)"]}),n.jsx(rt,{children:n.jsx(oa,{min:0,max:100,step:1,value:[i.value],onValueChange:o=>i.onChange(o[0])})}),n.jsx(ot,{})]})}),n.jsx(et,{control:s.control,name:"micro_lesson_trigger",render:({field:i})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Micro-lesson trigger"}),n.jsx(rt,{children:n.jsx(G,{type:"number",...i,onChange:o=>i.onChange(Number(o.target.value))})}),n.jsx(ot,{})]})}),n.jsx(et,{control:s.control,name:"module_skip_threshold",render:({field:i})=>n.jsxs(tt,{children:[n.jsxs(at,{children:["Module skip threshold (",i.value,"%)"]}),n.jsx(rt,{children:n.jsx(oa,{min:0,max:100,step:1,value:[i.value],onValueChange:o=>i.onChange(o[0])})}),n.jsx(ot,{})]})}),n.jsx(et,{control:s.control,name:"no_progress_alert_days",render:({field:i})=>n.jsxs(tt,{children:[n.jsx(at,{children:"No-progress alert (days)"}),n.jsx(rt,{children:n.jsx(G,{type:"number",...i,onChange:o=>i.onChange(Number(o.target.value))})}),n.jsx(ot,{})]})}),n.jsx(et,{control:s.control,name:"max_retries_per_exercise",render:({field:i})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Max retries per exercise"}),n.jsx(rt,{children:n.jsx(G,{type:"number",...i,onChange:o=>i.onChange(Number(o.target.value))})}),n.jsx(ot,{})]})}),n.jsx(E,{type:"submit",disabled:r.isPending,children:"Save Settings"})]})})})]})]})}function rLe(){const{data:e,isLoading:t}=Er(),{data:r,isLoading:s}=Qa({size:500}),{data:a,isLoading:i}=Eb({size:500}),{data:o,isLoading:l}=_o(),{data:c}=ye({queryKey:["dashboard","stats"],queryFn:async()=>{const g=await R.get("/stats");return g.data??g},staleTime:3e4}),d=(e==null?void 0:e.items)??[],u=(r==null?void 0:r.items)??[],f=(a==null?void 0:a.items)??[],h=(o==null?void 0:o.items)??[];if(t||s||i||l)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const m=(c==null?void 0:c.total_revenue)??0,y=(c==null?void 0:c.open_tickets)??0,x=[{label:"Total Students",value:String(u.length),icon:as,color:"text-primary"},{label:"Active Courses",value:`${d.filter(g=>g.status==="active").length} / ${d.length}`,icon:Kt,color:"text-info"},{label:"Teachers",value:String(f.length),icon:_i,color:"text-success"},{label:"Active Batches",value:`${h.filter(g=>g.status==="active").length} / ${h.length}`,icon:oo,color:"text-warning"},{label:"Open Tickets",value:String(y),icon:Aj,color:"text-destructive"},{label:"Revenue",value:`$${m.toLocaleString()}`,icon:ck,color:"text-success"}],j=d.map(g=>{const b=g.title||"";return{course:b.length>14?b.substring(0,14)+"…":b,capacity:g.max_capacity??0,enrolled:g.enrolled??0}}),v=h.map(g=>{const b=g.name||"";return{batch:b.length>12?b.substring(0,12)+"…":b,capacity:g.capacity??0}});return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Admin Dashboard"}),n.jsx("p",{className:"text-muted-foreground",children:"Platform overview and key metrics."})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(E,{variant:"outline",asChild:!0,children:n.jsxs(Dt,{to:"/admin/students",children:[n.jsx(mt,{className:"mr-1 h-3 w-3"}),"Add Student"]})}),n.jsx(E,{asChild:!0,children:n.jsxs(Dt,{to:"/admin/courses",children:[n.jsx(mt,{className:"mr-1 h-3 w-3"}),"New Course"]})})]})]}),n.jsx(Wn,{context:"admin-lms-dashboard",variant:"insight"}),n.jsx(F2,{}),n.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-4",children:x.map(g=>n.jsx(W,{children:n.jsxs(U,{className:"pt-4 pb-4",children:[n.jsx(g.icon,{className:`h-5 w-5 ${g.color} mb-1`}),n.jsx("p",{className:"text-lg font-bold",children:g.value}),n.jsx("p",{className:"text-xs text-muted-foreground",children:g.label})]})},g.label))}),n.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[{label:"Departments",value:(c==null?void 0:c.total_departments)??0,icon:dk},{label:"Classrooms",value:(c==null?void 0:c.total_classrooms)??0,icon:Il},{label:"Subjects",value:(c==null?void 0:c.total_subjects)??0,icon:Kt},{label:"Resources",value:(c==null?void 0:c.total_resources)??0,icon:oo}].map(g=>n.jsx(W,{children:n.jsxs(U,{className:"pt-3 pb-3 flex items-center gap-3",children:[n.jsx(g.icon,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-semibold",children:g.value}),n.jsx("p",{className:"text-xs text-muted-foreground",children:g.label})]})]})},g.label))}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Courses Overview"})}),n.jsx(U,{children:j.length>0?n.jsx(Xn,{width:"100%",height:220,children:n.jsxs(vo,{data:j,children:[n.jsx(bs,{strokeDasharray:"3 3",className:"stroke-border"}),n.jsx(kr,{dataKey:"course",className:"fill-muted-foreground",tick:{fontSize:10}}),n.jsx(Pr,{className:"fill-muted-foreground",tick:{fontSize:12}}),n.jsx(fn,{}),n.jsx(_r,{dataKey:"capacity",name:"Capacity",fill:"hsl(var(--primary))",radius:[4,4,0,0]}),n.jsx(_r,{dataKey:"enrolled",name:"Enrolled",fill:"hsl(var(--info))",radius:[4,4,0,0]})]})}):n.jsx("p",{className:"text-sm text-muted-foreground py-8 text-center",children:"No course data available."})})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Batch Capacity"})}),n.jsx(U,{children:v.length>0?n.jsx(Xn,{width:"100%",height:220,children:n.jsxs(vo,{data:v,children:[n.jsx(bs,{strokeDasharray:"3 3",className:"stroke-border"}),n.jsx(kr,{dataKey:"batch",className:"fill-muted-foreground",tick:{fontSize:10}}),n.jsx(Pr,{className:"fill-muted-foreground",tick:{fontSize:12}}),n.jsx(fn,{}),n.jsx(_r,{dataKey:"capacity",name:"Capacity",fill:"hsl(var(--info))",radius:[4,4,0,0]})]})}):n.jsx("p",{className:"text-sm text-muted-foreground py-8 text-center",children:"No batch data available."})})]})]}),n.jsxs(W,{children:[n.jsx(se,{className:"flex flex-row items-center justify-between pb-2",children:n.jsx(ie,{className:"text-lg",children:"Quick Summary"})}),n.jsx(U,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Module"}),n.jsx(L,{className:"text-right",children:"Count"}),n.jsx(L,{children:"Status"})]})}),n.jsxs(Be,{children:[n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:"Exams"}),n.jsx(T,{className:"text-right",children:(c==null?void 0:c.total_exams)??0}),n.jsxs(T,{className:"text-muted-foreground",children:[(c==null?void 0:c.total_exam_sessions)??0," sessions"]})]}),n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:"Assignments"}),n.jsx(T,{className:"text-right",children:(c==null?void 0:c.total_assignments)??0}),n.jsx(T,{className:"text-muted-foreground",children:"across courses"})]}),n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:"Support Tickets"}),n.jsx(T,{className:"text-right",children:(c==null?void 0:c.total_tickets)??0}),n.jsxs(T,{className:"text-muted-foreground",children:[y," open"]})]}),n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:"Payments"}),n.jsx(T,{className:"text-right",children:(c==null?void 0:c.total_payments)??0}),n.jsxs(T,{className:"text-muted-foreground",children:["$",m.toLocaleString()," total"]})]})]})]})})]})]})}function sLe(){const[e,t]=p.useState(""),[r,s]=p.useState(!1),[a,i]=p.useState({title:"",code:"",description:"",max_capacity:30}),{data:o,isLoading:l}=Er(),c=$B(),d=je(),{toast:u}=He(),f=(o==null?void 0:o.items)??[];if(l)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const h=f.filter(x=>x.title.toLowerCase().includes(e.toLowerCase()));function m(){a.title.trim()&&c.mutate({title:a.title.trim(),code:a.code.trim()||a.title.trim().toUpperCase().replace(/\s+/g,"-").slice(0,16),description:a.description,max_capacity:a.max_capacity},{onSuccess:()=>{s(!1),i({title:"",code:"",description:"",max_capacity:30}),u({title:"Course created"})},onError:x=>u({title:"Error",description:String(x.message||x),variant:"destructive"})})}async function y(x,j){if(window.confirm(`Delete course "${j}"?`))try{await bn.deleteCourse(x),d.invalidateQueries({queryKey:["lms","courses"]}),u({title:"Course deleted"})}catch(v){const g=v instanceof Error?v.message:String(v);u({title:"Delete failed",description:g,variant:"destructive"})}}return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Courses"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage all platform courses."})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(vx,{type:"course"}),n.jsxs(E,{onClick:()=>s(!0),children:[n.jsx(mt,{className:"mr-2 h-4 w-4"}),"New Course"]})]})]}),n.jsx(Wn,{context:"admin-courses",variant:"recommendation"}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search courses...",value:e,onChange:x=>t(x.target.value),className:"pl-9"})]}),n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Course"}),n.jsx(L,{children:"Code"}),n.jsx(L,{children:"Level"}),n.jsx(L,{children:"Enrolled / Capacity"}),n.jsx(L,{children:"Status"}),n.jsx(L,{className:"w-[60px]"})]})}),n.jsxs(Be,{children:[h.map(x=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:x.title}),n.jsx(T,{children:x.code}),n.jsx(T,{children:n.jsx(oe,{variant:"outline",children:x.level})}),n.jsxs(T,{children:[x.enrolled," / ",x.max_capacity]}),n.jsx(T,{children:n.jsx(oe,{variant:x.status==="active"?"default":"secondary",className:"capitalize",children:x.status})}),n.jsx(T,{children:n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>y(x.id,x.title),children:n.jsx($t,{className:"h-4 w-4 text-destructive"})})})]},x.id)),h.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No courses found."})})]})]})})}),n.jsx(Qe,{open:r,onOpenChange:s,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create New Course"})}),n.jsxs("div",{className:"space-y-4 py-2",children:[n.jsxs("div",{children:[n.jsx(q,{children:"Title *"}),n.jsx(G,{value:a.title,onChange:x=>i(j=>({...j,title:x.target.value})),placeholder:"e.g. IELTS Academic Preparation"})]}),n.jsxs("div",{children:[n.jsx(q,{children:"Code"}),n.jsx(G,{value:a.code,onChange:x=>i(j=>({...j,code:x.target.value})),placeholder:"Auto-generated if empty"})]}),n.jsxs("div",{children:[n.jsx(q,{children:"Description"}),n.jsx(on,{value:a.description,onChange:x=>i(j=>({...j,description:x.target.value})),rows:3})]}),n.jsxs("div",{children:[n.jsx(q,{children:"Max Capacity"}),n.jsx(G,{type:"number",value:a.max_capacity,onChange:x=>i(j=>({...j,max_capacity:Number(x.target.value)||30}))})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),n.jsx(E,{onClick:m,disabled:c.isPending,children:c.isPending?"Creating...":"Create Course"})]})]})})]})}function aLe(){const[e,t]=p.useState(""),[r,s]=p.useState(!1),[a,i]=p.useState(""),[o,l]=p.useState(""),[c,d]=p.useState(""),[u,f]=p.useState(""),[h,m]=p.useState("m"),[y,x]=p.useState(""),[j,v]=p.useState(""),[g,b]=p.useState(!0),{toast:N}=He(),{data:w,isLoading:S}=Qa({size:500}),{data:_}=Er({size:200}),{data:C}=_o({size:200}),P=IB(),D=je(),z=(_==null?void 0:_.items)??[],O=(C==null?void 0:C.items)??[],V=y?Number(y):void 0,A=p.useMemo(()=>V?O.filter(K=>K.course_id===V):O,[O,V]),$=(w==null?void 0:w.items)??[],B=e.trim()?$.filter(K=>K.name.toLowerCase().includes(e.toLowerCase())||(K.email||"").toLowerCase().includes(e.toLowerCase())):$,I=()=>{i(""),l(""),d(""),f(""),m("m"),x(""),v(""),b(!0)},k=()=>{if(!c.trim()){N({title:"Email required",variant:"destructive"});return}if(!a.trim()&&!o.trim()){N({title:"Name required",description:"Enter first or last name.",variant:"destructive"});return}const K=y?Number(y):void 0,X=j?Number(j):void 0;if(K&&!X||!K&&X){N({title:"Course and batch",description:"Select both course and batch to enroll, or leave both empty.",variant:"destructive"});return}P.mutate({first_name:a.trim(),last_name:o.trim()||"-",email:c.trim().toLowerCase(),gender:h,...u.trim()?{password:u.trim()}:{},create_portal_user:g,...K&&X?{course_id:K,batch_id:X}:{}},{onSuccess:()=>{s(!1),I(),N({title:"Student created",description:g?"Saved in OpenEduCat. Portal user created — student can log in with this email and password.":"Saved in OpenEduCat (op.student) only."})},onError:re=>{N({title:"Could not create student",description:re.message,variant:"destructive"})}})};async function M(K,X){if(window.confirm(`Delete student "${X}"?`))try{await R.delete(`/students/${K}`),D.invalidateQueries({queryKey:["lms","students"]}),N({title:"Student deleted"})}catch(re){const Z=re instanceof Error?re.message:String(re);N({title:"Delete failed",description:Z,variant:"destructive"})}}return S?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Students"}),n.jsx("p",{className:"text-muted-foreground",children:"OpenEduCat students — same records as in Odoo LMS."})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(vx,{type:"student"}),n.jsxs(E,{onClick:()=>s(!0),children:[n.jsx(mt,{className:"mr-2 h-4 w-4"}),"Add Student"]})]})]}),n.jsx(Wn,{context:"admin-students",variant:"insight"}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search students...",value:e,onChange:K=>t(K.target.value),className:"pl-9"})]}),n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Student"}),n.jsx(L,{children:"Batch"}),n.jsx(L,{children:"Attendance"}),n.jsx(L,{children:"Avg Grade"}),n.jsx(L,{children:"AI Risk"}),n.jsx(L,{children:"Status"}),n.jsx(L,{className:"w-[60px]"})]})}),n.jsx(Be,{children:B.map(K=>{var Z;const re=((Z=RB(K).name)==null?void 0:Z.split(" ").map(te=>te[0]).join("").slice(0,2).toUpperCase())??"??";return n.jsxs(ee,{children:[n.jsx(T,{children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"h-7 w-7 rounded-full bg-primary/10 flex items-center justify-center text-xs font-medium text-primary",children:re}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:K.name}),n.jsx("p",{className:"text-xs text-muted-foreground",children:K.email||"—"})]})]})}),n.jsx(T,{children:K.batch_name||"—"}),n.jsx(T,{children:"—"}),n.jsx(T,{children:"—"}),n.jsx(T,{children:n.jsx(tj,{})}),n.jsx(T,{children:n.jsx(oe,{variant:"outline",className:"capitalize",children:K.status||"active"})}),n.jsx(T,{children:n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>M(K.id,K.name),children:n.jsx($t,{className:"h-4 w-4 text-destructive"})})})]},K.id)})})]})})}),n.jsx(Qe,{open:r,onOpenChange:K=>{s(K),K||I()},children:n.jsxs(Ue,{className:"max-h-[90vh] overflow-y-auto",children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Add Student"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"fn",children:"First Name"}),n.jsx(G,{id:"fn",value:a,onChange:K=>i(K.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"ln",children:"Last Name"}),n.jsx(G,{id:"ln",value:o,onChange:K=>l(K.target.value)})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Gender"}),n.jsxs(Oe,{value:h,onValueChange:m,children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"m",children:"Male"}),n.jsx(Y,{value:"f",children:"Female"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"em",children:"Email (login)"}),n.jsx(G,{id:"em",type:"email",value:c,onChange:K=>d(K.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"pw",children:"Password"}),n.jsx(G,{id:"pw",type:"password",autoComplete:"new-password",placeholder:"Empty = Student123!",value:u,onChange:K=>f(K.target.value)})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(an,{id:"portal",checked:g,onCheckedChange:K=>b(K===!0)}),n.jsx(q,{htmlFor:"portal",className:"text-sm font-normal cursor-pointer",children:"Create portal login (res.users) for the SPA"})]}),n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Course (optional)"}),n.jsxs(Oe,{value:y||"__none__",onValueChange:K=>{x(K==="__none__"?"":K),v("")},children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select course"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"__none__",children:"— None —"}),z.map(K=>n.jsx(Y,{value:String(K.id),children:K.title},K.id))]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Batch (optional)"}),n.jsxs(Oe,{value:j||"__none__",onValueChange:K=>v(K==="__none__"?"":K),disabled:!y,children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:y?"Select batch":"Pick a course first"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"__none__",children:"— None —"}),A.map(K=>n.jsx(Y,{value:String(K.id),children:K.name},K.id))]})]})]})]}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Creates ",n.jsx("code",{className:"text-xs",children:"op.student"})," in Odoo. With portal enabled, also"," ",n.jsx("code",{className:"text-xs",children:"res.users"})," (",n.jsx("code",{className:"text-xs",children:"base.group_portal"}),") linked via"," ",n.jsx("code",{className:"text-xs",children:"op_student_id"}),"."]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),n.jsx(E,{onClick:k,disabled:P.isPending,children:P.isPending?"Saving…":"Add"})]})]})})]})}function iLe(){const[e,t]=p.useState(""),[r,s]=p.useState(!1),[a,i]=p.useState(""),[o,l]=p.useState(""),[c,d]=p.useState(""),[u,f]=p.useState("male"),[h,m]=p.useState(""),{toast:y}=He(),x=je(),{data:j,isLoading:v}=Eb({size:500}),g=DB(),N=((j==null?void 0:j.items)??[]).filter(_=>_.name.toLowerCase().includes(e.toLowerCase())||(_.email||"").toLowerCase().includes(e.toLowerCase())),w=()=>{if(!a.trim()||!o.trim()){y({title:"First and last name required",variant:"destructive"});return}if(!c.trim()){y({title:"Email required",variant:"destructive"});return}g.mutate({first_name:a.trim(),last_name:o.trim(),email:c.trim().toLowerCase(),gender:u,specialization:h.trim()||void 0},{onSuccess:()=>{s(!1),i(""),l(""),d(""),f("male"),m(""),y({title:"Teacher created"})},onError:_=>{y({title:"Could not create teacher",description:_.message,variant:"destructive"})}})};async function S(_,C){if(window.confirm(`Delete teacher "${C}"?`))try{await R.delete(`/teachers/${_}`),x.invalidateQueries({queryKey:["lms","teachers"]}),y({title:"Teacher deleted"})}catch(P){const D=P instanceof Error?P.message:String(P);y({title:"Delete failed",description:D,variant:"destructive"})}}return v?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Teachers"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage faculty members."})]}),n.jsxs(E,{onClick:()=>s(!0),children:[n.jsx(mt,{className:"mr-2 h-4 w-4"}),"Add Teacher"]})]}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search teachers...",value:e,onChange:_=>t(_.target.value),className:"pl-9"})]}),n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Teacher"}),n.jsx(L,{children:"Specialization"}),n.jsx(L,{children:"Subjects"}),n.jsx(L,{children:"Department"}),n.jsx(L,{children:"Gender"}),n.jsx(L,{className:"w-[60px]"})]})}),n.jsxs(Be,{children:[N.map(_=>{var P,D;const C=(P=_.name)==null?void 0:P.split(" ").map(z=>z[0]).join("").slice(0,2).toUpperCase();return n.jsxs(ee,{children:[n.jsx(T,{children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"h-7 w-7 rounded-full bg-primary/10 flex items-center justify-center text-xs font-medium text-primary",children:C}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:_.name}),n.jsx("p",{className:"text-xs text-muted-foreground",children:_.email||"—"})]})]})}),n.jsx(T,{children:_.specialization||"—"}),n.jsx(T,{children:(D=_.subject_names)!=null&&D.length?_.subject_names.join(", "):"—"}),n.jsx(T,{children:_.department_name||"—"}),n.jsx(T,{className:"capitalize",children:_.gender||"—"}),n.jsx(T,{children:n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>S(_.id,_.name),children:n.jsx($t,{className:"h-4 w-4 text-destructive"})})})]},_.id)}),N.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No teachers found."})})]})]})})}),n.jsx(Qe,{open:r,onOpenChange:s,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Add Teacher"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"First Name *"}),n.jsx(G,{value:a,onChange:_=>i(_.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Last Name *"}),n.jsx(G,{value:o,onChange:_=>l(_.target.value)})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Email *"}),n.jsx(G,{type:"email",value:c,onChange:_=>d(_.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Gender"}),n.jsxs(Oe,{value:u,onValueChange:f,children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"male",children:"Male"}),n.jsx(Y,{value:"female",children:"Female"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Specialization"}),n.jsx(G,{value:h,onChange:_=>m(_.target.value),placeholder:"e.g. IELTS Writing"})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),n.jsx(E,{onClick:w,disabled:g.isPending,children:g.isPending?"Saving…":"Add Teacher"})]})]})})]})}function oLe({batchId:e}){const[t,r]=p.useState(!1),{toast:s}=He(),a=ae({mutationFn:m=>Ol.getBatchOptimization(m),onError:m=>{s({title:"Optimization failed",description:m.message||"Could not analyze this batch.",variant:"destructive"})}}),i=()=>{if(e==null){s({title:"No batch selected",description:"Choose a batch to analyze, or open this from a batch detail page.",variant:"destructive"});return}a.reset(),r(!0),a.mutate(e)},o=ae({mutationFn:()=>{var m;return Ol.applyBatchOptimization(e,((m=a.data)==null?void 0:m.optimized)??[])},onSuccess:m=>{s({title:"Suggestion Applied",description:`${m.applied} optimization(s) saved successfully.`}),r(!1)},onError:m=>{s({variant:"destructive",title:"Apply failed",description:m.message||"Could not apply batch optimization."})}}),l=()=>{o.mutate()},c=m=>{r(m),m||a.reset()},d=a.data,u=!!(d!=null&&d.summary),f=!a.isPending&&!a.isError&&u,h=!a.isPending&&!a.isError&&a.isSuccess&&!u;return n.jsxs(n.Fragment,{children:[n.jsxs(E,{variant:"outline",size:"sm",onClick:i,children:[n.jsx(lt,{className:"h-3.5 w-3.5 mr-1 text-primary"})," AI Suggest Batch Split"]}),n.jsx(Qe,{open:t,onOpenChange:c,children:n.jsxs(Ue,{className:"max-w-md",children:[n.jsx(Ke,{children:n.jsxs(Ge,{className:"flex items-center gap-2",children:[n.jsx(lt,{className:"h-4 w-4 text-primary"})," AI Batch Optimization"]})}),a.isPending?n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-6 justify-center",children:[n.jsx(Re,{className:"h-5 w-5 animate-spin text-primary"})," Analyzing batch data..."]}):a.isError?n.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"Something went wrong. Try again."}):f&&d?n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"rounded-lg bg-muted/30 p-4 border border-border/60",children:[n.jsxs("p",{className:"text-xs font-semibold text-primary uppercase tracking-wide mb-1",children:[d.impact," impact"]}),n.jsx("p",{className:"text-sm font-medium",children:d.summary})]}),Array.isArray(d.optimized)&&d.optimized.length>0&&n.jsx("div",{className:"space-y-2 max-h-[40vh] overflow-y-auto",children:d.optimized.map((m,y)=>n.jsx("div",{className:"rounded-lg bg-muted/20 p-3 border text-sm",children:typeof m=="object"&&m!==null?JSON.stringify(m):String(m)},y))}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(E,{className:"flex-1",onClick:l,disabled:o.isPending,children:o.isPending?n.jsxs(n.Fragment,{children:[n.jsx(Re,{className:"h-4 w-4 mr-2 animate-spin"})," Applying..."]}):"Apply Suggestion"}),n.jsx(E,{variant:"outline",onClick:()=>c(!1),children:"Dismiss"})]})]}):h?n.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No optimization suggestions for this batch."}):null]})})]})}function lLe(){var j;const[e,t]=p.useState(""),[r,s]=p.useState(!1),[a,i]=p.useState({name:"",course_id:"",start_date:"",end_date:"",max_students:"30"}),{toast:o}=He(),l=je(),{data:c,isLoading:d}=_o(),{data:u}=Er({size:200}),f=(c==null?void 0:c.items)??[],h=(u==null?void 0:u.items)??[],m=ae({mutationFn:v=>bn.createBatch(v),onSuccess:()=>{l.invalidateQueries({queryKey:["lms","batches"]}),s(!1),o({title:"Batch created"}),i({name:"",course_id:"",start_date:"",end_date:"",max_students:"30"})},onError:v=>o({title:"Error",description:v.message,variant:"destructive"})});async function y(v,g){if(window.confirm(`Delete batch "${g}"?`))try{await R.delete(`/batches/${v}`),l.invalidateQueries({queryKey:["lms","batches"]}),o({title:"Batch deleted"})}catch(b){const N=b instanceof Error?b.message:String(b);o({title:"Delete failed",description:N,variant:"destructive"})}}if(d)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const x=f.filter(v=>v.name.toLowerCase().includes(e.toLowerCase()));return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Batches"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage student batches and groups."})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(oLe,{batchId:(j=f[0])==null?void 0:j.id}),n.jsx(vx,{type:"batch"}),n.jsxs(E,{onClick:()=>s(!0),children:[n.jsx(mt,{className:"mr-2 h-4 w-4"}),"Create Batch"]})]})]}),n.jsx(Wn,{context:"admin-batches",variant:"recommendation"}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search batches...",value:e,onChange:v=>t(v.target.value),className:"pl-9"})]}),n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Batch"}),n.jsx(L,{children:"Course"}),n.jsx(L,{children:"Teacher"}),n.jsx(L,{children:"Students"}),n.jsx(L,{children:"Schedule"}),n.jsx(L,{children:"Status"}),n.jsx(L,{})]})}),n.jsx(Be,{children:x.map(v=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:v.name}),n.jsx(T,{children:v.course_name}),n.jsx(T,{children:v.teacher_name}),n.jsxs(T,{children:[v.student_count,"/",v.capacity]}),n.jsx(T,{className:"text-xs",children:v.schedule}),n.jsx(T,{children:n.jsx(oe,{variant:v.status==="active"?"default":"secondary",className:"capitalize",children:v.status})}),n.jsx(T,{children:n.jsxs("div",{className:"flex gap-1",children:[n.jsx(E,{size:"sm",variant:"ghost",asChild:!0,children:n.jsx(Dt,{to:`/admin/batches/${v.id}`,children:"View"})}),n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>y(v.id,v.name),children:n.jsx($t,{className:"h-4 w-4 text-destructive"})})]})})]},v.id))})]})})}),n.jsx(Qe,{open:r,onOpenChange:s,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create Batch"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Batch Name *"}),n.jsx(G,{placeholder:"e.g. IELTS Morning B",value:a.name,onChange:v=>i(g=>({...g,name:v.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Course *"}),n.jsxs(Oe,{value:a.course_id||"__none__",onValueChange:v=>i(g=>({...g,course_id:v==="__none__"?"":v})),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select course"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"__none__",children:"— Select —"}),h.map(v=>n.jsx(Y,{value:String(v.id),children:v.title},v.id))]})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Start Date *"}),n.jsx(G,{type:"date",value:a.start_date,onChange:v=>i(g=>({...g,start_date:v.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"End Date *"}),n.jsx(G,{type:"date",value:a.end_date,onChange:v=>i(g=>({...g,end_date:v.target.value}))})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Capacity"}),n.jsx(G,{type:"number",placeholder:"30",value:a.max_students,onChange:v=>i(g=>({...g,max_students:v.target.value}))})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),n.jsx(E,{disabled:m.isPending||!a.name||!a.course_id||!a.start_date||!a.end_date,onClick:()=>m.mutate({name:a.name,course_id:Number(a.course_id),start_date:a.start_date,end_date:a.end_date,max_students:Number(a.max_students)||30}),children:"Create"})]})]})})]})}function cLe(){const{id:e}=Ht(),t=e?Number(e):NaN,{data:r,isLoading:s}=_o(),{data:a,isLoading:i}=Qa(Number.isFinite(t)?{batch_id:t,size:500}:{size:500}),{data:o,isLoading:l}=Ob(),c=(r==null?void 0:r.items)??[],d=(a==null?void 0:a.items)??[],u=Array.isArray(o)?o:[];if(s||i||l)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const f=c.find(j=>String(j.id)===e);if(!f)return n.jsx("div",{className:"p-8 text-center text-muted-foreground",children:"Batch not found."});const h=Array.isArray(f.student_ids)?f.student_ids:[],m=Number.isFinite(t)?d.filter(j=>j.batch_id===t):d.filter(j=>h.includes(j.id)),y=(f.course_name||"").split(" ")[0],x=u.filter(j=>j.batch_name===f.name||y&&(j.course_name||"").includes(y));return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(E,{variant:"ghost",size:"icon",asChild:!0,children:n.jsx(Dt,{to:"/admin/batches",children:n.jsx(xd,{className:"h-4 w-4"})})}),n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:f.name}),n.jsxs("p",{className:"text-muted-foreground",children:[f.course_name," · ",f.teacher_name]})]})]}),n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-4",children:[n.jsx(W,{children:n.jsxs(U,{className:"pt-4",children:[n.jsx(as,{className:"h-4 w-4 text-primary mb-1"}),n.jsxs("p",{className:"text-lg font-bold",children:[f.student_count,"/",f.capacity]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Students"})]})}),n.jsx(W,{children:n.jsxs(U,{className:"pt-4",children:[n.jsx(Yp,{className:"h-4 w-4 text-info mb-1"}),n.jsx("p",{className:"text-sm font-bold",children:f.schedule}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Schedule"})]})}),n.jsx(W,{children:n.jsxs(U,{className:"pt-4",children:[n.jsx(Kt,{className:"h-4 w-4 text-success mb-1"}),n.jsxs("p",{className:"text-sm font-bold",children:[f.start_date," — ",f.end_date]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Duration"})]})}),n.jsx(W,{children:n.jsxs(U,{className:"pt-4",children:[n.jsx(oe,{variant:f.status==="active"?"default":"secondary",className:"capitalize",children:f.status}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Status"})]})})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Enrolled Students"})}),n.jsx(U,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Student"}),n.jsx(L,{children:"Attendance"}),n.jsx(L,{children:"Avg Grade"}),n.jsx(L,{children:"Risk"})]})}),n.jsx(Be,{children:m.map(j=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:j.name}),n.jsx(T,{children:"—"}),n.jsx(T,{children:"—"}),n.jsx(T,{children:n.jsx(oe,{variant:"secondary",className:"capitalize",children:"—"})})]},j.id))})]})})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Timetable"})}),n.jsx(U,{className:"space-y-2",children:x.length===0?n.jsx("p",{className:"text-muted-foreground text-sm",children:"No sessions scheduled."}):x.map(j=>n.jsxs("div",{className:"flex items-center justify-between p-3 rounded border",children:[n.jsxs("div",{children:[n.jsxs("p",{className:"text-sm font-medium",children:[j.day," ",j.start_time,"–",j.end_time]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:j.room})]}),n.jsx("span",{className:"text-xs px-2 py-1 rounded text-white bg-primary",children:j.course_name})]},j.id))})]})]})}const SN=["Monday","Tuesday","Wednesday","Thursday","Friday"],dLe=["08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00"],uLe="hsl(192, 82%, 32%)";function fLe(){const{data:e,isLoading:t}=Ob(),r=Array.isArray(e)?e:[],[s,a]=p.useState(!1),[i,o]=p.useState(null),[l,c]=p.useState({course_id:"",day:"Monday",start_time:"08:00",end_time:"09:00",room:""}),{toast:d}=He(),u=je(),{data:f}=Er({size:200}),h=(f==null?void 0:f.items)??[],m=ae({mutationFn:v=>bn.createTimetableSession(v),onSuccess:()=>{u.invalidateQueries({queryKey:["lms","timetable"]}),a(!1),d({title:"Session created"})},onError:v=>d({title:"Error",description:v.message,variant:"destructive"})}),y=ae({mutationFn:v=>bn.deleteTimetableSession(v),onSuccess:()=>{u.invalidateQueries({queryKey:["lms","timetable"]}),o(null),d({title:"Session deleted"})},onError:v=>d({title:"Error",description:v.message,variant:"destructive"})});if(t)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});function x(v,g){return r.find(b=>b.day===v&&b.start_time===g)}function j(v,g){return r.find(b=>b.day===v&&b.start_time<=g&&b.end_time>g)}return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Master Timetable"}),n.jsx("p",{className:"text-muted-foreground",children:"View and manage all scheduled sessions."})]}),n.jsxs(E,{onClick:()=>a(!0),children:[n.jsx(mt,{className:"mr-2 h-4 w-4"}),"Add Session"]})]}),n.jsx(W,{children:n.jsx(U,{className:"pt-6 overflow-x-auto",children:n.jsxs("div",{className:"min-w-[700px]",children:[n.jsxs("div",{className:"grid grid-cols-6 gap-1",children:[n.jsx("div",{className:"text-xs font-medium text-muted-foreground p-2"}),SN.map(v=>n.jsx("div",{className:"text-xs font-semibold text-center p-2 bg-muted rounded",children:v},v))]}),dLe.map(v=>n.jsxs("div",{className:"grid grid-cols-6 gap-1 min-h-[48px]",children:[n.jsx("div",{className:"text-xs text-muted-foreground p-2 flex items-start",children:v}),SN.map(g=>{const b=x(g,v),N=j(g,v);return b?n.jsxs("div",{className:"rounded-md p-2 text-xs text-white cursor-pointer hover:opacity-90",style:{backgroundColor:uLe},onClick:()=>o(b),children:[n.jsx("p",{className:"font-semibold",children:b.course_name}),n.jsx("p",{className:"opacity-80",children:b.batch_name}),n.jsx("p",{className:"opacity-70",children:b.teacher_name}),n.jsx("p",{className:"opacity-70",children:b.room})]},g):N?n.jsx("div",{},g):n.jsx("div",{className:"border border-dashed border-border/50 rounded-md"},g)})]},v))]})})}),n.jsx(Qe,{open:!!i,onOpenChange:v=>{v||o(null)},children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Session Details"})}),i&&n.jsxs("div",{className:"space-y-2 text-sm",children:[n.jsxs("p",{children:[n.jsx("span",{className:"font-medium",children:"Course:"})," ",i.course_name]}),n.jsxs("p",{children:[n.jsx("span",{className:"font-medium",children:"Batch:"})," ",i.batch_name]}),n.jsxs("p",{children:[n.jsx("span",{className:"font-medium",children:"Teacher:"})," ",i.teacher_name]}),n.jsxs("p",{children:[n.jsx("span",{className:"font-medium",children:"Day:"})," ",i.day]}),n.jsxs("p",{children:[n.jsx("span",{className:"font-medium",children:"Time:"})," ",i.start_time," – ",i.end_time]}),n.jsxs("p",{children:[n.jsx("span",{className:"font-medium",children:"Room:"})," ",i.room]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>o(null),children:"Close"}),n.jsxs(E,{variant:"destructive",disabled:y.isPending,onClick:()=>{!i||!window.confirm("Delete this session?")||y.mutate(i.id)},children:[n.jsx($t,{className:"mr-2 h-4 w-4"})," Delete"]})]})]})}),n.jsx(Qe,{open:s,onOpenChange:a,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Add Timetable Session"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Course *"}),n.jsxs(Oe,{value:l.course_id||"__none__",onValueChange:v=>c(g=>({...g,course_id:v==="__none__"?"":v})),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select course"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"__none__",children:"— Select —"}),h.map(v=>n.jsx(Y,{value:String(v.id),children:v.title},v.id))]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Day"}),n.jsxs(Oe,{value:l.day,onValueChange:v=>c(g=>({...g,day:v})),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsx(Ee,{children:SN.map(v=>n.jsx(Y,{value:v,children:v},v))})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Start Time"}),n.jsx(G,{type:"time",value:l.start_time,onChange:v=>c(g=>({...g,start_time:v.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"End Time"}),n.jsx(G,{type:"time",value:l.end_time,onChange:v=>c(g=>({...g,end_time:v.target.value}))})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Room"}),n.jsx(G,{value:l.room,onChange:v=>c(g=>({...g,room:v.target.value})),placeholder:"e.g. Room A101"})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),n.jsx(E,{disabled:m.isPending||!l.course_id,onClick:()=>m.mutate({course_id:Number(l.course_id),day:l.day,start_time:l.start_time,end_time:l.end_time,room:l.room}),children:"Create"})]})]})})]})}function mLe(){const{data:e,isLoading:t}=Er(),{data:r,isLoading:s}=Qa({size:500}),a=(e==null?void 0:e.items)??[],i=(r==null?void 0:r.items)??[],o=a.map(y=>({name:y.title.length>12?y.title.slice(0,12)+"…":y.title,enrolled:y.enrolled??0,capacity:y.max_capacity??0})),l=a.filter(y=>y.status==="active").map(y=>{const x=y.max_capacity?Math.round(y.enrolled/y.max_capacity*100):0;return{name:y.title.length>12?y.title.slice(0,12)+"…":y.title,fillRate:x}}),c=[{name:"Active",value:i.filter(y=>y.status==="active").length,color:"hsl(142, 71%, 45%)"},{name:"Inactive",value:i.filter(y=>y.status!=="active").length,color:"hsl(38, 92%, 50%)"}].filter(y=>y.value>0),d={series:o,studentCount:i.length,courseCount:a.length},u={byCourse:l},f={distribution:c,studentCount:i.length},h={note:"No attendance data recorded yet."},m=p.useCallback(()=>{const x=[["Type","Label","Enrolled","Capacity"],...o.map(b=>["Enrollment",b.name,String(b.enrolled),String(b.capacity)]),...l.map(b=>["Fill Rate",b.name,String(b.fillRate)+"%",""]),...c.map(b=>["Status",b.name,String(b.value),""])].map(b=>b.join(",")).join(` `),j=new Blob([x],{type:"text/csv"}),v=URL.createObjectURL(j),g=document.createElement("a");g.href=v,g.download="encoach-report.csv",g.click(),URL.revokeObjectURL(v)},[o,l,c]);return t||s?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Reports"}),n.jsx("p",{className:"text-muted-foreground",children:"Analytics and reporting dashboard."})]}),n.jsxs(E,{variant:"outline",onClick:m,children:[n.jsx(yd,{className:"mr-2 h-4 w-4"}),"Export CSV"]})]}),n.jsxs(Us,{defaultValue:"enrollment",children:[n.jsxs(ws,{children:[n.jsx(Et,{value:"enrollment",children:"Enrollment"}),n.jsx(Et,{value:"performance",children:"Performance"}),n.jsx(Et,{value:"risk",children:"Student Risk"}),n.jsx(Et,{value:"attendance",children:"Attendance"})]}),n.jsxs(Lt,{value:"enrollment",className:"mt-4 space-y-4",children:[n.jsx(Ra,{report_type:"enrollment",data:d}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Enrollment by Course"})}),n.jsx(U,{children:o.length>0?n.jsx(Xn,{width:"100%",height:300,children:n.jsxs(vo,{data:o,children:[n.jsx(bs,{strokeDasharray:"3 3",className:"stroke-border"}),n.jsx(kr,{dataKey:"name",tick:{fontSize:11}}),n.jsx(Pr,{}),n.jsx(fn,{}),n.jsx(_r,{dataKey:"enrolled",name:"Enrolled",fill:"hsl(192, 82%, 32%)",radius:[4,4,0,0]}),n.jsx(_r,{dataKey:"capacity",name:"Capacity",fill:"hsl(192, 82%, 32%, 0.3)",radius:[4,4,0,0]})]})}):n.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No courses available."})})]})]}),n.jsxs(Lt,{value:"performance",className:"mt-4 space-y-4",children:[n.jsx(Ra,{report_type:"performance",data:u}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Course Fill Rate (%)"})}),n.jsx(U,{children:l.length>0?n.jsx(Xn,{width:"100%",height:300,children:n.jsxs(vo,{data:l,children:[n.jsx(bs,{strokeDasharray:"3 3",className:"stroke-border"}),n.jsx(kr,{dataKey:"name",tick:{fontSize:11}}),n.jsx(Pr,{domain:[0,100]}),n.jsx(fn,{}),n.jsx(_r,{dataKey:"fillRate",name:"Fill %",fill:"hsl(187, 72%, 55%)",radius:[4,4,0,0]})]})}):n.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No active courses."})})]})]}),n.jsxs(Lt,{value:"risk",className:"mt-4 space-y-4",children:[n.jsx(Ra,{report_type:"risk",data:f}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Student Status Distribution"})}),n.jsx(U,{className:"flex justify-center",children:c.length>0?n.jsx(Xn,{width:"100%",height:300,children:n.jsxs(_0,{children:[n.jsx(pa,{data:c,dataKey:"value",cx:"50%",cy:"50%",outerRadius:100,label:!0,children:c.map((y,x)=>n.jsx(_d,{fill:y.color},x))}),n.jsx(fn,{}),n.jsx(Sl,{})]})}):n.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No students available."})})]})]}),n.jsxs(Lt,{value:"attendance",className:"mt-4 space-y-4",children:[n.jsx(Ra,{report_type:"attendance",data:h}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Attendance"})}),n.jsx(U,{children:n.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No attendance data recorded yet. Attendance tracking will appear here once sessions are recorded."})})]})]})]})]})}function hLe(){try{return JSON.parse(localStorage.getItem("encoach_settings")||"{}")}catch{return{}}}function pLe(){const{toast:e}=He(),t=hLe(),[r,s]=p.useState(t.platformName??"EnCoach"),[a,i]=p.useState(t.supportEmail??"support@encoach.com"),[o,l]=p.useState(t.maxStudents??"30"),[c,d]=p.useState(t.aiEnabled??!0),[u,f]=p.useState(t.selfReg??!0),[h,m]=p.useState(t.emailNotif??!0),[y,x]=p.useState(t.minScore??"0"),[j,v]=p.useState(t.maxScore??"100"),[g,b]=p.useState(t.passThreshold??"60"),N=()=>{const w={platformName:r,supportEmail:a,maxStudents:o,aiEnabled:c,selfReg:u,emailNotif:h,minScore:y,maxScore:j,passThreshold:g};localStorage.setItem("encoach_settings",JSON.stringify(w)),e({title:"Settings saved",description:"Platform settings have been updated."})};return n.jsxs("div",{className:"space-y-6 max-w-2xl",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Platform Settings"}),n.jsx("p",{className:"text-muted-foreground",children:"Configure platform-wide settings."})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"General"})}),n.jsxs(U,{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Platform Name"}),n.jsx(G,{value:r,onChange:w=>s(w.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Support Email"}),n.jsx(G,{value:a,onChange:w=>i(w.target.value),type:"email"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Max Students per Batch"}),n.jsx(G,{value:o,onChange:w=>l(w.target.value),type:"number"})]})]})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Features"})}),n.jsxs(U,{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx(q,{children:"AI Features"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable AI-powered insights and suggestions"})]}),n.jsx(Fr,{checked:c,onCheckedChange:d})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx(q,{children:"Student Self-Registration"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow students to register themselves"})]}),n.jsx(Fr,{checked:u,onCheckedChange:f})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx(q,{children:"Email Notifications"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Send email notifications for assignments and grades"})]}),n.jsx(Fr,{checked:h,onCheckedChange:m})]})]})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Grading"})}),n.jsx(U,{className:"space-y-4",children:n.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Min Score"}),n.jsx(G,{value:y,onChange:w=>x(w.target.value),type:"number"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Max Score"}),n.jsx(G,{value:j,onChange:w=>v(w.target.value),type:"number"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Pass Threshold"}),n.jsx(G,{value:g,onChange:w=>b(w.target.value),type:"number"})]})]})})]}),n.jsx(E,{onClick:N,children:"Save Settings"})]})}function xLe(){var j,v,g;const{user:e}=Ga(),{toast:t}=He(),[r,s]=p.useState(((j=e==null?void 0:e.name)==null?void 0:j.split(" ")[0])??""),[a,i]=p.useState(((v=e==null?void 0:e.name)==null?void 0:v.split(" ").slice(1).join(" "))??""),[o,l]=p.useState((e==null?void 0:e.email)??""),[c,d]=p.useState(""),[u,f]=p.useState(""),[h,m]=p.useState(""),y=ae({mutationFn:()=>R.patch("/user",{name:`${r} ${a}`.trim(),email:o}),onSuccess:()=>t({title:"Profile updated"}),onError:b=>t({title:"Error",description:b.message,variant:"destructive"})}),x=ae({mutationFn:()=>R.post("/user/change-password",{current_password:c,new_password:u}),onSuccess:()=>{t({title:"Password updated"}),d(""),f(""),m("")},onError:b=>t({title:"Error",description:b.message,variant:"destructive"})});return n.jsxs("div",{className:"space-y-6 max-w-2xl",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Profile"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage your account information."})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Personal Information"})}),n.jsxs(U,{className:"space-y-4",children:[n.jsx("div",{className:"flex items-center gap-4 mb-4",children:n.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center",children:n.jsx("span",{className:"text-lg font-bold text-primary",children:((g=e==null?void 0:e.name)==null?void 0:g.split(" ").map(b=>b[0]).join("").slice(0,2).toUpperCase())??"??"})})}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"First Name"}),n.jsx(G,{value:r,onChange:b=>s(b.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Last Name"}),n.jsx(G,{value:a,onChange:b=>i(b.target.value)})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Email"}),n.jsx(G,{value:o,onChange:b=>l(b.target.value),type:"email"})]}),n.jsx(E,{onClick:()=>y.mutate(),disabled:y.isPending,children:"Save Changes"})]})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-lg",children:"Change Password"})}),n.jsxs(U,{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Current Password"}),n.jsx(G,{type:"password",value:c,onChange:b=>d(b.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"New Password"}),n.jsx(G,{type:"password",value:u,onChange:b=>f(b.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Confirm Password"}),n.jsx(G,{type:"password",value:h,onChange:b=>m(b.target.value)})]}),n.jsx(E,{disabled:x.isPending||!u||u!==h,onClick:()=>x.mutate(),children:"Update Password"}),u&&h&&u!==h&&n.jsx("p",{className:"text-sm text-destructive",children:"Passwords do not match"})]})]})]})}function gLe(){const{toast:e}=He(),t=je(),{data:r,isLoading:s}=gx(),a=Array.isArray(r)?r:[],[i,o]=p.useState(null),{data:l,isLoading:c}=zce(i??0),[d,u]=p.useState(!1),[f,h]=p.useState(""),[m,y]=p.useState(""),[x,j]=p.useState(!1),[v,g]=p.useState(""),[b,N]=p.useState(null),[w,S]=p.useState(""),[_,C]=p.useState("medium"),[P,D]=p.useState("1"),z=ae({mutationFn:()=>Fi.createSubject({name:f,code:m,is_active:!0,mastery_threshold:80,grading_scale:"percentage",diagnostic_config:{questions_per_domain:5,total_question_cap:30,time_limit_minutes:45,starting_difficulty:"medium",mastery_per_correct:10,mastery_per_incorrect:-5}}),onSuccess:()=>{t.invalidateQueries({queryKey:["taxonomy","subjects"]}),e({title:"Subject Created"}),u(!1),h(""),y("")},onError:()=>e({title:"Error",description:"Failed to create subject",variant:"destructive"})}),O=ae({mutationFn:k=>Fi.aiSuggestTopics(k),onSuccess:k=>{e({title:"AI Suggestions",description:`${k.suggestions.length} topics suggested. Review and add them.`})},onError:()=>e({title:"Error",description:"AI suggestion failed",variant:"destructive"})}),V=ae({mutationFn:k=>Fi.createDomain(k),onSuccess:()=>{t.invalidateQueries({queryKey:["taxonomy"]}),j(!1),g(""),e({title:"Domain created"})},onError:()=>e({title:"Error",description:"Failed to create domain",variant:"destructive"})}),A=ae({mutationFn:k=>Fi.deleteDomain(k),onSuccess:()=>{t.invalidateQueries({queryKey:["taxonomy"]}),e({title:"Domain deleted"})},onError:()=>e({title:"Error",description:"Failed to delete domain",variant:"destructive"})}),$=ae({mutationFn:k=>Fi.createTopic(k),onSuccess:()=>{t.invalidateQueries({queryKey:["taxonomy"]}),N(null),S(""),e({title:"Topic created"})},onError:()=>e({title:"Error",description:"Failed to create topic",variant:"destructive"})}),B=ae({mutationFn:k=>Fi.deleteTopic(k),onSuccess:()=>{t.invalidateQueries({queryKey:["taxonomy"]}),e({title:"Topic deleted"})},onError:()=>e({title:"Error",description:"Failed to delete topic",variant:"destructive"})}),I=ae({mutationFn:k=>Fi.deleteSubject(k),onSuccess:()=>{t.invalidateQueries({queryKey:["taxonomy"]}),i===id&&o(null),e({title:"Subject deleted"})},onError:()=>e({title:"Error",description:"Failed to delete subject",variant:"destructive"})});return s?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Taxonomy Manager"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage subjects, domains, topics, and learning objectives."})]}),n.jsxs(Qe,{open:d,onOpenChange:u,children:[n.jsx(cr,{asChild:!0,children:n.jsxs(E,{children:[n.jsx(mt,{className:"mr-2 h-4 w-4"})," Add Subject"]})}),n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create New Subject"})}),n.jsxs("div",{className:"space-y-4 pt-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Subject Name"}),n.jsx(G,{placeholder:"e.g. Mathematics",value:f,onChange:k=>h(k.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Code"}),n.jsx(G,{placeholder:"e.g. MATH",value:m,onChange:k=>y(k.target.value)})]}),n.jsxs(E,{className:"w-full",onClick:()=>z.mutate(),disabled:z.isPending||!f,children:[z.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Create Subject"]})]})]})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx("h3",{className:"text-sm font-medium text-muted-foreground px-1",children:"Subjects"}),a.map(k=>n.jsxs("div",{className:`w-full text-left p-3 rounded-lg border transition-colors flex items-center gap-2 ${i===k.id?"bg-primary/10 border-primary":"hover:bg-accent"}`,children:[n.jsxs("button",{onClick:()=>o(k.id),className:"flex items-center gap-2 flex-1 min-w-0 text-left",children:[n.jsx(Kt,{className:"h-4 w-4 shrink-0"}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{className:"text-sm font-medium truncate",children:k.name}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:[k.code," · ",k.domain_count??0," domains · ",k.topic_count??0," topics"]})]})]}),n.jsx(E,{size:"sm",variant:"ghost",className:"text-destructive shrink-0",onClick:()=>{window.confirm(`Delete subject "${k.name}"?`)&&I.mutate(k.id)},children:n.jsx($t,{className:"h-3 w-3"})})]},k.id)),a.length===0&&n.jsx("p",{className:"text-sm text-muted-foreground px-1",children:"No subjects yet."})]}),n.jsx("div",{className:"md:col-span-3",children:i?c?n.jsx("div",{className:"flex items-center justify-center min-h-[300px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):l?n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"flex justify-end",children:n.jsxs(E,{size:"sm",variant:"outline",onClick:()=>j(!0),children:[n.jsx(mt,{className:"h-3 w-3 mr-1"})," Add Domain"]})}),(Array.isArray(l.domains)?l.domains:[]).map(k=>n.jsx(fr,{defaultOpen:!0,children:n.jsxs(W,{children:[n.jsx(se,{className:"pb-3",children:n.jsxs(mr,{className:"flex items-center justify-between w-full",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Si,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),n.jsx(oo,{className:"h-4 w-4 text-primary"}),n.jsx(ie,{className:"text-base",children:k.name}),n.jsxs(oe,{variant:"secondary",children:[(Array.isArray(k.topics)?k.topics:[]).length," topics"]})]}),n.jsxs("div",{className:"flex items-center gap-1",onClick:M=>M.stopPropagation(),children:[n.jsxs(E,{variant:"ghost",size:"sm",onClick:()=>O.mutate(k.id),disabled:O.isPending,children:[n.jsx(lt,{className:"h-3 w-3 mr-1"})," AI Suggest"]}),n.jsxs(E,{variant:"ghost",size:"sm",onClick:()=>{N(k.id),S("")},children:[n.jsx(mt,{className:"h-3 w-3 mr-1"})," Topic"]}),n.jsx(E,{variant:"ghost",size:"sm",className:"text-destructive",onClick:()=>{window.confirm(`Delete domain "${k.name}"?`)&&A.mutate(k.id)},children:n.jsx($t,{className:"h-3 w-3"})})]})]})}),n.jsx(hr,{children:n.jsx(U,{className:"pt-0",children:n.jsxs("div",{className:"space-y-2",children:[b===k.id&&n.jsxs("div",{className:"flex items-center gap-2 p-2 rounded border bg-muted/50",children:[n.jsx(G,{placeholder:"Topic name",value:w,onChange:M=>S(M.target.value),className:"h-8 text-sm"}),n.jsxs(Oe,{value:_,onValueChange:C,children:[n.jsx(Ae,{className:"w-28 h-8",children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"easy",children:"Easy"}),n.jsx(Y,{value:"medium",children:"Medium"}),n.jsx(Y,{value:"hard",children:"Hard"})]})]}),n.jsx(G,{placeholder:"Hrs",type:"number",value:P,onChange:M=>D(M.target.value),className:"w-16 h-8 text-sm"}),n.jsx(E,{size:"sm",disabled:$.isPending||!w,onClick:()=>$.mutate({name:w,domain_id:k.id,difficulty_level:_,estimated_hours:Number(P)||1}),children:"Add"}),n.jsx(E,{size:"sm",variant:"ghost",onClick:()=>N(null),children:n.jsx(ts,{className:"h-3 w-3"})})]}),(Array.isArray(k.topics)?k.topics:[]).map(M=>n.jsxs("div",{className:"flex items-center justify-between p-2 rounded border hover:bg-accent/50",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Yn,{className:"h-3 w-3 text-muted-foreground"}),n.jsx("span",{className:"text-sm",children:M.name}),n.jsx(oe,{variant:"outline",className:"text-xs",children:M.difficulty_level}),n.jsxs("span",{className:"text-xs text-muted-foreground",children:[(Array.isArray(M.objectives)?M.objectives:[]).length," objectives"]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("span",{className:"text-xs text-muted-foreground",children:["~",M.estimated_hours,"h"]}),n.jsx(E,{size:"sm",variant:"ghost",className:"text-destructive h-6 w-6 p-0",onClick:()=>{window.confirm(`Delete topic "${M.name}"?`)&&B.mutate(M.id)},children:n.jsx($t,{className:"h-3 w-3"})})]})]},M.id)),(Array.isArray(k.topics)?k.topics:[]).length===0&&!b&&n.jsx("p",{className:"text-sm text-muted-foreground py-2",children:"No topics in this domain yet."})]})})})]})},k.id)),(Array.isArray(l.domains)?l.domains:[]).length===0&&n.jsx(W,{children:n.jsx(U,{className:"py-8 text-center text-muted-foreground",children:"No domains defined yet for this subject."})})]}):null:n.jsx(W,{children:n.jsx(U,{className:"py-12 text-center text-muted-foreground",children:"Select a subject to view its taxonomy tree."})})})]}),n.jsx(Qe,{open:x,onOpenChange:j,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Add Domain"})}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Domain Name"}),n.jsx(G,{placeholder:"e.g. Algebra",value:v,onChange:k=>g(k.target.value)})]}),n.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[n.jsx(E,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),n.jsxs(E,{disabled:V.isPending||!v||!i,onClick:()=>V.mutate({name:v,subject_id:i}),children:[V.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"})," Create"]})]})]})})]})}const j$={approved:{variant:"default",icon:n.jsx(Un,{className:"h-3 w-3 mr-1"})},pending:{variant:"secondary",icon:n.jsx(vd,{className:"h-3 w-3 mr-1"})},rejected:{variant:"destructive",icon:n.jsx(Bf,{className:"h-3 w-3 mr-1"})}},vLe={pdf:n.jsx(Yn,{className:"h-4 w-4 text-red-500"}),video:n.jsx(Ll,{className:"h-4 w-4 text-blue-500"}),link:n.jsx(kj,{className:"h-4 w-4 text-green-500"}),document:n.jsx(Yn,{className:"h-4 w-4 text-orange-500"}),interactive:n.jsx(Yn,{className:"h-4 w-4 text-purple-500"})};function yLe(){const{toast:e}=He(),t=je(),[r,s]=p.useState(""),[a,i]=p.useState("all"),[o,l]=p.useState("all"),[c,d]=p.useState(!1),[u,f]=p.useState("pdf"),{data:h,isLoading:m}=ye({queryKey:["resources","list",{search:r,resource_type:a==="all"?void 0:a,review_status:o==="all"?void 0:o}],queryFn:()=>ug.list({search:r||void 0,resource_type:a==="all"?void 0:a,review_status:o==="all"?void 0:o})}),y=(h==null?void 0:h.items)??[],x=ae({mutationFn:g=>ug.delete(g),onSuccess:()=>{t.invalidateQueries({queryKey:["resources"]}),e({title:"Resource deleted"})},onError:()=>e({title:"Error",description:"Failed to delete resource",variant:"destructive"})}),j=ae({mutationFn:g=>ug.upload(g),onSuccess:()=>{t.invalidateQueries({queryKey:["resources"]}),e({title:"Resource uploaded"}),d(!1)},onError:()=>e({title:"Error",description:"Upload failed",variant:"destructive"})}),v=g=>{g.preventDefault();const b=new FormData(g.currentTarget);j.mutate(b)};return m?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Resource Manager"}),n.jsx("p",{className:"text-muted-foreground",children:"Upload, manage, and review learning resources."})]}),n.jsxs(Qe,{open:c,onOpenChange:d,children:[n.jsx(cr,{asChild:!0,children:n.jsxs(E,{children:[n.jsx(Ku,{className:"mr-2 h-4 w-4"})," Upload Resource"]})}),n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Upload New Resource"})}),n.jsxs("form",{onSubmit:v,className:"space-y-4 pt-4",children:[n.jsx("input",{type:"hidden",name:"resource_type",value:u}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{name:"name",placeholder:"Resource title",required:!0})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Type"}),n.jsxs(Oe,{value:u,onValueChange:f,children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"pdf",children:"PDF"}),n.jsx(Y,{value:"video",children:"Video"}),n.jsx(Y,{value:"link",children:"Link"}),n.jsx(Y,{value:"document",children:"Document"}),n.jsx(Y,{value:"interactive",children:"Interactive"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"File or URL"}),n.jsx(G,{name:"file",type:"file"})]}),n.jsxs(E,{type:"submit",className:"w-full",disabled:j.isPending,children:[j.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Upload"]})]})]})]})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search resources...",value:r,onChange:g=>s(g.target.value),className:"pl-9"})]}),n.jsxs(Oe,{value:a,onValueChange:i,children:[n.jsx(Ae,{className:"w-[140px]",children:n.jsx(Me,{placeholder:"Type"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"all",children:"All Types"}),n.jsx(Y,{value:"pdf",children:"PDF"}),n.jsx(Y,{value:"video",children:"Video"}),n.jsx(Y,{value:"link",children:"Link"})]})]}),n.jsxs(Oe,{value:o,onValueChange:l,children:[n.jsx(Ae,{className:"w-[140px]",children:n.jsx(Me,{placeholder:"Status"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"all",children:"All Status"}),n.jsx(Y,{value:"pending",children:"Pending"}),n.jsx(Y,{value:"approved",children:"Approved"}),n.jsx(Y,{value:"rejected",children:"Rejected"})]})]})]})}),n.jsx(U,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Resource"}),n.jsx(L,{children:"Type"}),n.jsx(L,{children:"Topics"}),n.jsx(L,{children:"Author"}),n.jsx(L,{children:"Status"}),n.jsx(L,{className:"text-right",children:"Actions"})]})}),n.jsxs(Be,{children:[y.map(g=>{const b=j$[g.review_status]??j$.pending;return n.jsxs(ee,{children:[n.jsx(T,{children:n.jsxs("div",{className:"flex items-center gap-2",children:[vLe[g.resource_type]??n.jsx(Yn,{className:"h-4 w-4"}),n.jsx("span",{className:"font-medium",children:g.name})]})}),n.jsx(T,{children:n.jsx(oe,{variant:"outline",className:"capitalize",children:g.resource_type})}),n.jsx(T,{children:n.jsxs("div",{className:"flex flex-wrap gap-1",children:[g.topic_names.slice(0,2).map((N,w)=>n.jsx(oe,{variant:"secondary",className:"text-xs",children:N},w)),g.topic_names.length>2&&n.jsxs(oe,{variant:"secondary",className:"text-xs",children:["+",g.topic_names.length-2]})]})}),n.jsx(T,{className:"text-sm",children:g.author_name}),n.jsx(T,{children:n.jsxs(oe,{variant:b.variant,className:"flex items-center w-fit",children:[b.icon,g.review_status]})}),n.jsx(T,{className:"text-right",children:n.jsxs("div",{className:"flex items-center justify-end gap-1",children:[n.jsx(E,{variant:"ghost",size:"icon",onClick:async()=>{try{const N=await ug.download(g.id),w=URL.createObjectURL(N),S=document.createElement("a");S.href=w,S.download=g.name||"resource",S.click(),URL.revokeObjectURL(w)}catch{e({title:"Download failed",variant:"destructive"})}},children:n.jsx(yd,{className:"h-4 w-4"})}),n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>{window.confirm(`Delete "${g.name}"?`)&&x.mutate(g.id)},disabled:x.isPending,children:n.jsx($t,{className:"h-4 w-4 text-destructive"})})]})})]},g.id)}),y.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No resources found."})})]})]})})]})]})}const b$=[{value:"two_sem",label:"Two Semesters"},{value:"two_sem_qua",label:"Two Semesters + Quarter"},{value:"three_sem",label:"Three Semesters"},{value:"four_Quarter",label:"Four Quarters"},{value:"final_year",label:"Final Year"},{value:"others",label:"Others"}];function jLe(){const{toast:e}=He(),{data:t,isLoading:r}=Hce(),s=(t==null?void 0:t.items)??[],a=Yce(),i=Xce(),o=Zce(),[l,c]=p.useState(!1),[d,u]=p.useState(null),[f,h]=p.useState({name:"",start_date:"",end_date:"",term_structure:"two_sem"}),{data:m}=Qce(d??void 0),y=(m==null?void 0:m.items)??[],x=()=>{a.mutate(f,{onSuccess:()=>{e({title:"Academic year created"}),c(!1),h({name:"",start_date:"",end_date:"",term_structure:"two_sem"})},onError:()=>e({title:"Error",description:"Failed to create academic year",variant:"destructive"})})},j=g=>{window.confirm("Delete this academic year?")&&i.mutate(g,{onSuccess:()=>e({title:"Academic year deleted"}),onError:()=>e({title:"Error",description:"Failed to delete",variant:"destructive"})})},v=g=>{o.mutate(g,{onSuccess:()=>e({title:"Terms generated"}),onError:()=>e({title:"Error",description:"Failed to generate terms",variant:"destructive"})})};return r?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Academic Years"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage academic years and their terms."})]}),n.jsxs(Qe,{open:l,onOpenChange:c,children:[n.jsx(cr,{asChild:!0,children:n.jsxs(E,{children:[n.jsx(mt,{className:"mr-2 h-4 w-4"})," Create Academic Year"]})}),n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create Academic Year"})}),n.jsxs("div",{className:"space-y-4 pt-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{placeholder:"e.g. 2025-2026",value:f.name,onChange:g=>h({...f,name:g.target.value})})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Start Date"}),n.jsx(G,{type:"date",value:f.start_date,onChange:g=>h({...f,start_date:g.target.value})})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"End Date"}),n.jsx(G,{type:"date",value:f.end_date,onChange:g=>h({...f,end_date:g.target.value})})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Term Structure"}),n.jsxs(Oe,{value:f.term_structure,onValueChange:g=>h({...f,term_structure:g}),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsx(Ee,{children:b$.map(g=>n.jsx(Y,{value:g.value,children:g.label},g.value))})]})]}),n.jsxs(E,{className:"w-full",onClick:x,disabled:a.isPending||!f.name||!f.start_date||!f.end_date,children:[a.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Create"]})]})]})]})]}),n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{}),n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Start Date"}),n.jsx(L,{children:"End Date"}),n.jsx(L,{children:"Term Structure"}),n.jsx(L,{children:"Terms"}),n.jsx(L,{className:"text-right",children:"Actions"})]})}),n.jsxs(Be,{children:[s.map(g=>{var b,N;return n.jsx(fr,{asChild:!0,open:d===g.id,onOpenChange:w=>u(w?g.id:null),children:n.jsxs(n.Fragment,{children:[n.jsxs(ee,{children:[n.jsx(T,{children:n.jsx(mr,{asChild:!0,children:n.jsx(E,{variant:"ghost",size:"icon",className:"h-6 w-6",children:n.jsx(Si,{className:`h-4 w-4 transition-transform ${d===g.id?"rotate-90":""}`})})})}),n.jsx(T,{className:"font-medium",children:g.name}),n.jsx(T,{children:g.start_date}),n.jsx(T,{children:g.end_date}),n.jsx(T,{children:n.jsx(oe,{variant:"outline",children:((b=b$.find(w=>w.value===g.term_structure))==null?void 0:b.label)??g.term_structure})}),n.jsx(T,{children:n.jsx(oe,{variant:"secondary",children:((N=g.terms)==null?void 0:N.length)??0})}),n.jsx(T,{className:"text-right",children:n.jsxs("div",{className:"flex items-center justify-end gap-1",children:[n.jsxs(E,{variant:"ghost",size:"sm",onClick:()=>v(g.id),disabled:o.isPending,children:[n.jsx(xk,{className:"mr-1 h-3 w-3"})," Generate Terms"]}),n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>j(g.id),disabled:i.isPending,children:n.jsx($t,{className:"h-4 w-4 text-destructive"})})]})})]}),n.jsx(hr,{asChild:!0,children:n.jsx(ee,{children:n.jsx(T,{colSpan:7,className:"bg-muted/50 p-4",children:d===g.id&&n.jsxs("div",{className:"space-y-2",children:[n.jsx("h4",{className:"text-sm font-medium",children:"Terms"}),y.length>0?n.jsx("div",{className:"grid gap-2",children:y.map(w=>n.jsxs("div",{className:"flex items-center justify-between rounded border p-3 bg-background",children:[n.jsx("span",{className:"text-sm font-medium",children:w.name}),n.jsxs("span",{className:"text-sm text-muted-foreground",children:[w.term_start_date," — ",w.term_end_date]})]},w.id))}):n.jsx("p",{className:"text-sm text-muted-foreground",children:'No terms yet. Click "Generate Terms" to auto-create.'})]})})})})]})},g.id)}),s.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No academic years found."})})]})]})})})]})}function bLe(){var g;const{toast:e}=He(),{data:t,isLoading:r}=BB(),s=(t==null?void 0:t.items)??[],a=zB(),i=Jce(),o=VB(),[l,c]=p.useState(!1),[d,u]=p.useState(null),[f,h]=p.useState({name:"",code:""}),m=()=>{u(null),h({name:"",code:""}),c(!0)},y=b=>{u(b),h({name:b.name,code:b.code,parent_id:b.parent_id}),c(!0)},x=()=>{d?i.mutate({id:d.id,data:f},{onSuccess:()=>{e({title:"Department updated"}),c(!1)},onError:()=>e({title:"Error",description:"Failed to update",variant:"destructive"})}):a.mutate(f,{onSuccess:()=>{e({title:"Department created"}),c(!1),h({name:"",code:""})},onError:()=>e({title:"Error",description:"Failed to create",variant:"destructive"})})},j=b=>{window.confirm("Delete this department?")&&o.mutate(b,{onSuccess:()=>e({title:"Department deleted"}),onError:()=>e({title:"Error",description:"Failed to delete",variant:"destructive"})})},v=a.isPending||i.isPending;return r?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Departments"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage departments and their hierarchy."})]}),n.jsxs(Qe,{open:l,onOpenChange:c,children:[n.jsx(cr,{asChild:!0,children:n.jsxs(E,{onClick:m,children:[n.jsx(mt,{className:"mr-2 h-4 w-4"})," Add Department"]})}),n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:d?"Edit Department":"Create Department"})}),n.jsxs("div",{className:"space-y-4 pt-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{placeholder:"e.g. Computer Science",value:f.name,onChange:b=>h({...f,name:b.target.value})})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Code"}),n.jsx(G,{placeholder:"e.g. CS",value:f.code,onChange:b=>h({...f,code:b.target.value})})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Parent Department"}),n.jsxs(Oe,{value:((g=f.parent_id)==null?void 0:g.toString())??"none",onValueChange:b=>h({...f,parent_id:b==="none"?void 0:Number(b)}),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"None"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"none",children:"None"}),s.filter(b=>b.id!==(d==null?void 0:d.id)).map(b=>n.jsx(Y,{value:b.id.toString(),children:b.name},b.id))]})]})]}),n.jsxs(E,{className:"w-full",onClick:x,disabled:v||!f.name||!f.code,children:[v&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),d?"Update":"Create"]})]})]})]})]}),n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Code"}),n.jsx(L,{children:"Parent"}),n.jsx(L,{children:"Courses"}),n.jsx(L,{children:"Faculty"}),n.jsx(L,{className:"text-right",children:"Actions"})]})}),n.jsxs(Be,{children:[s.map(b=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:b.name}),n.jsx(T,{children:b.code}),n.jsx(T,{className:"text-muted-foreground",children:b.parent_name??"—"}),n.jsx(T,{children:b.course_count}),n.jsx(T,{children:b.faculty_count}),n.jsx(T,{className:"text-right",children:n.jsxs("div",{className:"flex items-center justify-end gap-1",children:[n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>y(b),children:n.jsx(Uu,{className:"h-4 w-4"})}),n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>j(b.id),disabled:o.isPending,children:n.jsx($t,{className:"h-4 w-4 text-destructive"})})]})})]},b.id)),s.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No departments found."})})]})]})})})]})}const wLe=[{value:"all",label:"All"},{value:"draft",label:"Draft"},{value:"submit",label:"Submitted"},{value:"confirm",label:"Confirmed"},{value:"admission",label:"Admitted"},{value:"reject",label:"Rejected"}],NLe={draft:"outline",submit:"secondary",confirm:"default",admission:"default",reject:"destructive",cancel:"destructive",done:"secondary"};function SLe(){const e=Bt(),[t,r]=p.useState(""),[s,a]=p.useState("all"),{data:i,isLoading:o}=ye({queryKey:["admissions","list",{search:t,state:s==="all"?void 0:s}],queryFn:()=>Ts.listAdmissions({search:t||void 0,state:s==="all"?void 0:s})}),l=(i==null?void 0:i.items)??[];return o?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Admissions"}),n.jsx("p",{className:"text-muted-foreground",children:"View and manage student admission applications."})]}),n.jsx("div",{className:"flex items-center gap-2",children:wLe.map(c=>n.jsx(E,{variant:s===c.value?"default":"outline",size:"sm",onClick:()=>a(c.value),children:c.label},c.value))}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsxs("div",{className:"relative",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search by name...",value:t,onChange:c=>r(c.target.value),className:"pl-9"})]})}),n.jsx(U,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Application #"}),n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Course"}),n.jsx(L,{children:"Register"}),n.jsx(L,{children:"State"}),n.jsx(L,{children:"Date"})]})}),n.jsxs(Be,{children:[l.map(c=>n.jsxs(ee,{className:"cursor-pointer hover:bg-accent/50",onClick:()=>e(`/admin/admissions/${c.id}`),children:[n.jsx(T,{className:"font-medium",children:c.application_number}),n.jsxs(T,{children:[c.first_name," ",c.last_name]}),n.jsx(T,{children:c.course_name}),n.jsx(T,{className:"text-muted-foreground",children:c.register_name}),n.jsx(T,{children:n.jsx(oe,{variant:NLe[c.state]??"outline",className:"capitalize",children:c.state})}),n.jsx(T,{className:"text-muted-foreground",children:new Date(c.created_at).toLocaleDateString()})]},c.id)),l.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No admissions found."})})]})]})})]})]})}const _Le={draft:"outline",submit:"secondary",confirm:"default",admission:"default",reject:"destructive",cancel:"destructive",done:"secondary"};function CLe(){const{id:e}=Ht(),t=Bt(),{toast:r}=He(),s=je(),a=Number(e),{data:i,isLoading:o}=ye({queryKey:["admissions",a],queryFn:()=>Ts.getAdmission(a),enabled:!!a}),l=d=>({submit:Ts.submitAdmission,confirm:Ts.confirmAdmission,admit:Ts.admitAdmission,reject:Ts.rejectAdmission})[d],c=ae({mutationFn:({action:d})=>l(d)(a),onSuccess:(d,{action:u})=>{s.invalidateQueries({queryKey:["admissions"]}),r({title:`Admission ${u}${u==="submit"?"ted":"ed"}`})},onError:()=>r({title:"Error",description:"Action failed",variant:"destructive"})});return o?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):i?n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>t("/admin/admissions"),children:n.jsx(xd,{className:"h-4 w-4"})}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("h1",{className:"text-2xl font-bold",children:[i.first_name," ",i.last_name]}),n.jsxs("p",{className:"text-muted-foreground",children:["Application #",i.application_number]})]}),n.jsx(oe,{variant:_Le[i.state]??"outline",className:"capitalize text-sm px-3 py-1",children:i.state})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{children:"Applicant Information"})}),n.jsx(U,{children:n.jsxs("dl",{className:"space-y-3",children:[n.jsxs("div",{className:"flex justify-between",children:[n.jsx("dt",{className:"text-sm text-muted-foreground",children:"Full Name"}),n.jsxs("dd",{className:"text-sm font-medium",children:[i.first_name," ",i.middle_name??""," ",i.last_name]})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("dt",{className:"text-sm text-muted-foreground",children:"Email"}),n.jsx("dd",{className:"text-sm font-medium",children:i.email})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("dt",{className:"text-sm text-muted-foreground",children:"Phone"}),n.jsx("dd",{className:"text-sm font-medium",children:i.phone??"—"})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("dt",{className:"text-sm text-muted-foreground",children:"Birth Date"}),n.jsx("dd",{className:"text-sm font-medium",children:i.birth_date??"—"})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("dt",{className:"text-sm text-muted-foreground",children:"Gender"}),n.jsx("dd",{className:"text-sm font-medium capitalize",children:i.gender==="m"?"Male":i.gender==="f"?"Female":"Other"})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("dt",{className:"text-sm text-muted-foreground",children:"Nationality"}),n.jsx("dd",{className:"text-sm font-medium",children:i.nationality_name??"—"})]})]})})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{children:"Application Details"})}),n.jsx(U,{children:n.jsxs("dl",{className:"space-y-3",children:[n.jsxs("div",{className:"flex justify-between",children:[n.jsx("dt",{className:"text-sm text-muted-foreground",children:"Course"}),n.jsx("dd",{className:"text-sm font-medium",children:i.course_name})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("dt",{className:"text-sm text-muted-foreground",children:"Register"}),n.jsx("dd",{className:"text-sm font-medium",children:i.register_name})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("dt",{className:"text-sm text-muted-foreground",children:"Batch"}),n.jsx("dd",{className:"text-sm font-medium",children:i.batch_name??"—"})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("dt",{className:"text-sm text-muted-foreground",children:"Fees"}),n.jsx("dd",{className:"text-sm font-medium",children:i.fees})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("dt",{className:"text-sm text-muted-foreground",children:"Applied On"}),n.jsx("dd",{className:"text-sm font-medium",children:new Date(i.created_at).toLocaleDateString()})]})]})})]})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{children:"Actions"})}),n.jsx(U,{children:n.jsxs("div",{className:"flex items-center gap-3",children:[i.state==="draft"&&n.jsxs(E,{onClick:()=>c.mutate({action:"submit"}),disabled:c.isPending,children:[c.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Submit Application"]}),i.state==="submit"&&n.jsxs(n.Fragment,{children:[n.jsxs(E,{onClick:()=>c.mutate({action:"confirm"}),disabled:c.isPending,children:[c.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Confirm"]}),n.jsx(E,{variant:"destructive",onClick:()=>c.mutate({action:"reject"}),disabled:c.isPending,children:"Reject"})]}),i.state==="confirm"&&n.jsxs(n.Fragment,{children:[n.jsxs(E,{onClick:()=>c.mutate({action:"admit"}),disabled:c.isPending,children:[c.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Admit"]}),n.jsx(E,{variant:"destructive",onClick:()=>c.mutate({action:"reject"}),disabled:c.isPending,children:"Reject"})]}),["admission","reject","done"].includes(i.state)&&n.jsx("p",{className:"text-sm text-muted-foreground",children:"No further actions available."})]})})]})]}):n.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Admission not found."})}const kLe={draft:"outline",confirm:"default",cancel:"destructive",done:"secondary"};function PLe(){const{toast:e}=He(),t=je(),[r,s]=p.useState(!1),{data:a,isLoading:i}=ye({queryKey:["admission-registers","list"],queryFn:()=>Ts.listRegisters()}),o=(a==null?void 0:a.items)??[],{data:l}=Er(),c=(l==null?void 0:l.items)??[],[d,u]=p.useState({name:"",course_id:0,start_date:"",end_date:"",min_count:void 0,max_count:void 0}),f=ae({mutationFn:y=>Ts.createRegister(y),onSuccess:()=>{t.invalidateQueries({queryKey:["admission-registers"]}),e({title:"Register created"}),s(!1),u({name:"",course_id:0,start_date:"",end_date:""})},onError:()=>e({title:"Error",description:"Failed to create register",variant:"destructive"})}),h=ae({mutationFn:y=>Ts.confirmRegister(y),onSuccess:()=>{t.invalidateQueries({queryKey:["admission-registers"]}),e({title:"Register confirmed"})},onError:()=>e({title:"Error",description:"Failed to confirm",variant:"destructive"})}),m=ae({mutationFn:y=>Ts.closeRegister(y),onSuccess:()=>{t.invalidateQueries({queryKey:["admission-registers"]}),e({title:"Register closed"})},onError:()=>e({title:"Error",description:"Failed to close",variant:"destructive"})});return i?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Admission Registers"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage admission registers and their status."})]}),n.jsxs(Qe,{open:r,onOpenChange:s,children:[n.jsx(cr,{asChild:!0,children:n.jsxs(E,{children:[n.jsx(mt,{className:"mr-2 h-4 w-4"})," Create Register"]})}),n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create Admission Register"})}),n.jsxs("div",{className:"space-y-4 pt-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{placeholder:"e.g. Fall 2025 Intake",value:d.name,onChange:y=>u({...d,name:y.target.value})})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Course"}),n.jsxs(Oe,{value:d.course_id?d.course_id.toString():"",onValueChange:y=>u({...d,course_id:Number(y)}),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select course"})}),n.jsx(Ee,{children:c.map(y=>n.jsx(Y,{value:y.id.toString(),children:y.title||y.name||`Course #${y.id}`},y.id))})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Start Date"}),n.jsx(G,{type:"date",value:d.start_date,onChange:y=>u({...d,start_date:y.target.value})})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"End Date"}),n.jsx(G,{type:"date",value:d.end_date,onChange:y=>u({...d,end_date:y.target.value})})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Min Count"}),n.jsx(G,{type:"number",value:d.min_count??"",onChange:y=>u({...d,min_count:y.target.value?Number(y.target.value):void 0})})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Max Count"}),n.jsx(G,{type:"number",value:d.max_count??"",onChange:y=>u({...d,max_count:y.target.value?Number(y.target.value):void 0})})]})]}),n.jsxs(E,{className:"w-full",onClick:()=>f.mutate(d),disabled:f.isPending||!d.name||!d.course_id,children:[f.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Create Register"]})]})]})]})]}),n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Course"}),n.jsx(L,{children:"Dates"}),n.jsx(L,{children:"Capacity"}),n.jsx(L,{children:"Applications"}),n.jsx(L,{children:"State"}),n.jsx(L,{className:"text-right",children:"Actions"})]})}),n.jsxs(Be,{children:[o.map(y=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:y.name}),n.jsx(T,{children:y.course_name}),n.jsxs(T,{className:"text-sm text-muted-foreground",children:[y.start_date," — ",y.end_date]}),n.jsxs(T,{children:[y.min_count,"–",y.max_count]}),n.jsx(T,{children:n.jsx(oe,{variant:"secondary",children:y.application_count})}),n.jsx(T,{children:n.jsx(oe,{variant:kLe[y.state]??"outline",className:"capitalize",children:y.state})}),n.jsx(T,{className:"text-right",children:n.jsxs("div",{className:"flex items-center justify-end gap-1",children:[y.state==="draft"&&n.jsxs(E,{variant:"ghost",size:"sm",onClick:()=>h.mutate(y.id),disabled:h.isPending,children:[n.jsx(Un,{className:"mr-1 h-3 w-3"})," Confirm"]}),y.state==="confirm"&&n.jsxs(E,{variant:"ghost",size:"sm",onClick:()=>m.mutate(y.id),disabled:m.isPending,children:[n.jsx(Bf,{className:"mr-1 h-3 w-3"})," Close"]})]})})]},y.id)),o.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No admission registers found."})})]})]})})})]})}const ALe={draft:"outline",schedule:"secondary",held:"default",cancel:"destructive",done:"default"};function ELe(){const{toast:e}=He(),t=je(),[r,s]=p.useState(!1),[a,i]=p.useState(null),{data:o,isLoading:l}=ye({queryKey:["inst-exam-sessions","list"],queryFn:()=>gr.listSessions()}),c=(o==null?void 0:o.items)??[],{data:d}=ye({queryKey:["inst-exam-sessions",a],queryFn:()=>gr.getSession(a),enabled:!!a}),{data:u}=ye({queryKey:["exam-types","list"],queryFn:()=>gr.listExamTypes()}),f=(u==null?void 0:u.items)??[],{data:h}=Er(),m=(h==null?void 0:h.items)??[],{data:y}=_o(),x=(y==null?void 0:y.items)??[],[j,v]=p.useState({name:"",course_id:0,batch_id:0,start_date:"",end_date:"",exam_type_id:0,evaluation_type:"normal"}),g=ae({mutationFn:()=>gr.createSession(j),onSuccess:()=>{t.invalidateQueries({queryKey:["inst-exam-sessions"]}),e({title:"Exam session created"}),s(!1),v({name:"",course_id:0,batch_id:0,start_date:"",end_date:"",exam_type_id:0,evaluation_type:"normal"})},onError:()=>e({title:"Error",description:"Failed to create session",variant:"destructive"})}),b=ae({mutationFn:w=>gr.scheduleSession(w),onSuccess:()=>{t.invalidateQueries({queryKey:["inst-exam-sessions"]}),e({title:"Session scheduled"})},onError:()=>e({title:"Error",description:"Failed to schedule",variant:"destructive"})}),N=ae({mutationFn:w=>gr.markSessionDone(w),onSuccess:()=>{t.invalidateQueries({queryKey:["inst-exam-sessions"]}),e({title:"Session marked as done"})},onError:()=>e({title:"Error",description:"Failed to update",variant:"destructive"})});return l?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Exam Sessions"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage institutional exam sessions and their exams."})]}),n.jsxs(Qe,{open:r,onOpenChange:s,children:[n.jsx(cr,{asChild:!0,children:n.jsxs(E,{children:[n.jsx(mt,{className:"mr-2 h-4 w-4"})," Create Session"]})}),n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create Exam Session"})}),n.jsxs("div",{className:"space-y-4 pt-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{placeholder:"e.g. Mid-Term Exams 2025",value:j.name,onChange:w=>v({...j,name:w.target.value})})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Course"}),n.jsxs(Oe,{value:j.course_id?j.course_id.toString():"",onValueChange:w=>v({...j,course_id:Number(w)}),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select"})}),n.jsx(Ee,{children:m.map(w=>n.jsx(Y,{value:w.id.toString(),children:w.title||w.name||`Course #${w.id}`},w.id))})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Batch"}),n.jsxs(Oe,{value:j.batch_id?j.batch_id.toString():"",onValueChange:w=>v({...j,batch_id:Number(w)}),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select"})}),n.jsx(Ee,{children:x.map(w=>n.jsx(Y,{value:w.id.toString(),children:w.name},w.id))})]})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Start Date"}),n.jsx(G,{type:"date",value:j.start_date,onChange:w=>v({...j,start_date:w.target.value})})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"End Date"}),n.jsx(G,{type:"date",value:j.end_date,onChange:w=>v({...j,end_date:w.target.value})})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Exam Type"}),n.jsxs(Oe,{value:j.exam_type_id?j.exam_type_id.toString():"",onValueChange:w=>v({...j,exam_type_id:Number(w)}),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select"})}),n.jsx(Ee,{children:f.map(w=>n.jsx(Y,{value:w.id.toString(),children:w.name},w.id))})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Evaluation Type"}),n.jsxs(Oe,{value:j.evaluation_type,onValueChange:w=>v({...j,evaluation_type:w}),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"normal",children:"Normal"}),n.jsx(Y,{value:"grade",children:"Grade"})]})]})]})]}),n.jsxs(E,{className:"w-full",onClick:()=>g.mutate(),disabled:g.isPending||!j.name||!j.course_id||!j.batch_id,children:[g.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Create Session"]})]})]})]})]}),n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{}),n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Course / Batch"}),n.jsx(L,{children:"Dates"}),n.jsx(L,{children:"Type"}),n.jsx(L,{children:"Exams"}),n.jsx(L,{children:"State"}),n.jsx(L,{className:"text-right",children:"Actions"})]})}),n.jsxs(Be,{children:[c.map(w=>{var S;return n.jsx(fr,{asChild:!0,open:a===w.id,onOpenChange:_=>i(_?w.id:null),children:n.jsxs(n.Fragment,{children:[n.jsxs(ee,{children:[n.jsx(T,{children:n.jsx(mr,{asChild:!0,children:n.jsx(E,{variant:"ghost",size:"icon",className:"h-6 w-6",children:n.jsx(Si,{className:`h-4 w-4 transition-transform ${a===w.id?"rotate-90":""}`})})})}),n.jsx(T,{className:"font-medium",children:w.name}),n.jsx(T,{children:n.jsxs("div",{children:[n.jsx("span",{className:"text-sm",children:w.course_name}),n.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["/ ",w.batch_name]})]})}),n.jsxs(T,{className:"text-sm text-muted-foreground",children:[w.start_date," — ",w.end_date]}),n.jsx(T,{children:n.jsx(oe,{variant:"outline",children:w.exam_type_name})}),n.jsx(T,{children:n.jsx(oe,{variant:"secondary",children:w.exam_count})}),n.jsx(T,{children:n.jsx(oe,{variant:ALe[w.state]??"outline",className:"capitalize",children:w.state})}),n.jsx(T,{className:"text-right",children:n.jsxs("div",{className:"flex items-center justify-end gap-1",children:[w.state==="draft"&&n.jsxs(E,{variant:"ghost",size:"sm",onClick:()=>b.mutate(w.id),disabled:b.isPending,children:[n.jsx(lk,{className:"mr-1 h-3 w-3"})," Schedule"]}),w.state==="schedule"&&n.jsxs(E,{variant:"ghost",size:"sm",onClick:()=>N.mutate(w.id),disabled:N.isPending,children:[n.jsx(Un,{className:"mr-1 h-3 w-3"})," Done"]})]})})]}),n.jsx(hr,{asChild:!0,children:n.jsx(ee,{children:n.jsx(T,{colSpan:8,className:"bg-muted/50 p-4",children:d&&a===w.id?n.jsxs("div",{className:"space-y-2",children:[n.jsx("h4",{className:"text-sm font-medium",children:"Exams in Session"}),(S=d.exams)!=null&&S.length?n.jsx("div",{className:"grid gap-2",children:(d.exams??[]).map(_=>n.jsxs("div",{className:"flex items-center justify-between rounded border p-3 bg-background",children:[n.jsxs("div",{children:[n.jsx("span",{className:"text-sm font-medium",children:_.name}),n.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:_.subject_name})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("span",{className:"text-xs text-muted-foreground",children:[_.total_marks," marks"]}),n.jsx(oe,{variant:"outline",className:"text-xs capitalize",children:_.state})]})]},_.id))}):n.jsx("p",{className:"text-sm text-muted-foreground",children:"No exams in this session yet."})]}):n.jsx("div",{className:"flex justify-center py-4",children:n.jsx(Re,{className:"h-4 w-4 animate-spin text-muted-foreground"})})})})})]})},w.id)}),c.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No exam sessions found."})})]})]})})})]})}const OLe={draft:"outline",validated:"default",cancelled:"destructive"};function TLe(){const{toast:e}=He(),t=je(),[r,s]=p.useState("templates"),[a,i]=p.useState(!1),[o,l]=p.useState(null),{data:c,isLoading:d}=ye({queryKey:["result-templates","list"],queryFn:()=>gr.listResultTemplates()}),u=(c==null?void 0:c.items)??[],{data:f,isLoading:h}=ye({queryKey:["marksheets","list"],queryFn:()=>gr.listMarksheets(),enabled:r==="marksheets"}),m=(f==null?void 0:f.items)??[],{data:y}=ye({queryKey:["marksheets",o],queryFn:()=>gr.getMarksheet(o),enabled:!!o}),{data:x}=ye({queryKey:["inst-exam-sessions","list"],queryFn:()=>gr.listSessions()}),j=(x==null?void 0:x.items)??[],{data:v}=ye({queryKey:["grade-configs","list"],queryFn:()=>gr.listGradeConfigs()}),g=(v==null?void 0:v.items)??[],[b,N]=p.useState({name:"",exam_session_id:0,grade_ids:[]}),w=ae({mutationFn:()=>gr.createResultTemplate(b),onSuccess:()=>{t.invalidateQueries({queryKey:["result-templates"]}),e({title:"Template created"}),i(!1),N({name:"",exam_session_id:0,grade_ids:[]})},onError:()=>e({title:"Error",description:"Failed to create template",variant:"destructive"})}),S=ae({mutationFn:P=>gr.generateMarksheets(P),onSuccess:()=>{t.invalidateQueries({queryKey:["marksheets"]}),t.invalidateQueries({queryKey:["result-templates"]}),e({title:"Marksheets generated"})},onError:()=>e({title:"Error",description:"Generation failed",variant:"destructive"})}),_=ae({mutationFn:P=>gr.validateMarksheet(P),onSuccess:()=>{t.invalidateQueries({queryKey:["marksheets"]}),e({title:"Marksheet validated"})},onError:()=>e({title:"Error",description:"Validation failed",variant:"destructive"})});return(r==="templates"?d:h)?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Marksheet Manager"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage result templates and marksheets."})]})}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(E,{variant:r==="templates"?"default":"outline",size:"sm",onClick:()=>s("templates"),children:"Result Templates"}),n.jsx(E,{variant:r==="marksheets"?"default":"outline",size:"sm",onClick:()=>s("marksheets"),children:"Marksheets"})]}),r==="templates"&&n.jsxs(W,{children:[n.jsxs(se,{className:"flex flex-row items-center justify-between",children:[n.jsx(ie,{children:"Result Templates"}),n.jsxs(Qe,{open:a,onOpenChange:i,children:[n.jsx(cr,{asChild:!0,children:n.jsxs(E,{size:"sm",children:[n.jsx(mt,{className:"mr-2 h-4 w-4"})," Create Template"]})}),n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create Result Template"})}),n.jsxs("div",{className:"space-y-4 pt-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{placeholder:"e.g. Mid-Term Results",value:b.name,onChange:P=>N({...b,name:P.target.value})})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Exam Session"}),n.jsxs(Oe,{value:b.exam_session_id?b.exam_session_id.toString():"",onValueChange:P=>N({...b,exam_session_id:Number(P)}),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select session"})}),n.jsx(Ee,{children:j.map(P=>n.jsx(Y,{value:P.id.toString(),children:P.name},P.id))})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Grade Configuration"}),n.jsxs("div",{className:"space-y-1 max-h-40 overflow-y-auto border rounded-lg p-2",children:[g.map(P=>n.jsxs("label",{className:"flex items-center gap-2 p-1 hover:bg-accent/50 rounded cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:b.grade_ids.includes(P.id),onChange:D=>{N(z=>({...z,grade_ids:D.target.checked?[...z.grade_ids,P.id]:z.grade_ids.filter(O=>O!==P.id)}))},className:"rounded"}),n.jsxs("span",{className:"text-sm",children:[P.result," (",P.min_per,"%–",P.max_per,"%)"]})]},P.id)),g.length===0&&n.jsx("p",{className:"text-xs text-muted-foreground p-1",children:"No grade configs available."})]})]}),n.jsxs(E,{className:"w-full",onClick:()=>w.mutate(),disabled:w.isPending||!b.name||!b.exam_session_id,children:[w.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Create Template"]})]})]})]})]}),n.jsx(U,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Exam Session"}),n.jsx(L,{children:"Evaluation"}),n.jsx(L,{children:"Result Date"}),n.jsx(L,{children:"State"}),n.jsx(L,{className:"text-right",children:"Actions"})]})}),n.jsxs(Be,{children:[u.map(P=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:P.name}),n.jsx(T,{children:P.exam_session_name}),n.jsx(T,{children:n.jsx(oe,{variant:"outline",className:"capitalize",children:P.evaluation_type})}),n.jsx(T,{className:"text-muted-foreground",children:P.result_date}),n.jsx(T,{children:n.jsx(oe,{variant:P.state==="result_generated"?"default":"outline",className:"capitalize",children:P.state.replace("_"," ")})}),n.jsx(T,{className:"text-right",children:P.state==="draft"&&n.jsxs(E,{variant:"ghost",size:"sm",onClick:()=>S.mutate(P.id),disabled:S.isPending,children:[n.jsx(zL,{className:"mr-1 h-3 w-3"})," Generate Marksheets"]})})]},P.id)),u.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No result templates found."})})]})]})})]}),r==="marksheets"&&n.jsxs("div",{className:"space-y-6",children:[n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Exam Session"}),n.jsx(L,{children:"Generated"}),n.jsx(L,{children:"Pass"}),n.jsx(L,{children:"Fail"}),n.jsx(L,{children:"State"}),n.jsx(L,{className:"text-right",children:"Actions"})]})}),n.jsxs(Be,{children:[m.map(P=>n.jsxs(ee,{className:"cursor-pointer hover:bg-accent/50",onClick:()=>l(o===P.id?null:P.id),children:[n.jsx(T,{className:"font-medium",children:P.name}),n.jsx(T,{children:P.exam_session_name}),n.jsxs(T,{className:"text-sm text-muted-foreground",children:[P.generated_date," by ",P.generated_by_name]}),n.jsx(T,{children:n.jsx(oe,{variant:"default",children:P.total_pass})}),n.jsx(T,{children:n.jsx(oe,{variant:"destructive",children:P.total_failed})}),n.jsx(T,{children:n.jsx(oe,{variant:OLe[P.state]??"outline",className:"capitalize",children:P.state})}),n.jsx(T,{className:"text-right",onClick:D=>D.stopPropagation(),children:P.state==="draft"&&n.jsxs(E,{variant:"ghost",size:"sm",onClick:()=>_.mutate(P.id),disabled:_.isPending,children:[n.jsx(Un,{className:"mr-1 h-3 w-3"})," Validate"]})})]},P.id)),m.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No marksheets found."})})]})]})})}),y&&n.jsxs(W,{children:[n.jsx(se,{children:n.jsxs(ie,{children:["Results — ",y.name]})}),n.jsx(U,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Student"}),n.jsx(L,{children:"Total Marks"}),n.jsx(L,{children:"Percentage"}),n.jsx(L,{children:"Grade"}),n.jsx(L,{children:"Status"})]})}),n.jsxs(Be,{children:[(y.lines??[]).map(P=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:P.student_name}),n.jsx(T,{children:P.total_marks}),n.jsxs(T,{children:[P.percentage.toFixed(1),"%"]}),n.jsx(T,{children:P.grade??"—"}),n.jsx(T,{children:n.jsx(oe,{variant:P.status==="pass"?"default":"destructive",className:"capitalize",children:P.status})})]},P.id)),(y.lines??[]).length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No results in this marksheet."})})]})]})})]})]})]})}function MLe(e){switch(e){case"draft":return n.jsx(oe,{variant:"secondary",children:"draft"});case"confirm":return n.jsx(oe,{variant:"outline",children:"confirm"});case"approve":case"validate":return n.jsx(oe,{variant:"default",className:"bg-green-600 hover:bg-green-600",children:e});case"refuse":return n.jsx(oe,{variant:"destructive",children:"refuse"});case"cancel":return n.jsx(oe,{variant:"secondary",children:"cancel"});default:return n.jsx(oe,{variant:"outline",children:e})}}function RLe(){const[e,t]=p.useState(""),[r,s]=p.useState(!1),[a,i]=p.useState({student_id:"",leave_type:"",start_date:"",end_date:"",description:""}),{toast:o}=He(),{data:l,isLoading:c}=tde(),d=(l==null?void 0:l.data)??(l==null?void 0:l.items)??[],u=rde(),f=sde(),h=ade(),{data:m}=Qa({size:500}),y=(m==null?void 0:m.items)??[],{data:x}=nde(),j=(x==null?void 0:x.data)??(x==null?void 0:x.items)??[];if(c)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const v=e.toLowerCase(),g=d.filter(N=>{var w,S,_;return((w=N.student_name)==null?void 0:w.toLowerCase().includes(v))||((S=N.leave_type)==null?void 0:S.toLowerCase().includes(v))||((_=N.description)==null?void 0:_.toLowerCase().includes(v))}),b=N=>!["approve","refuse","cancel"].includes(N);return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Student leave"}),n.jsx("p",{className:"text-muted-foreground",children:"Review and create leave requests."})]}),n.jsxs(E,{onClick:()=>s(!0),children:[n.jsx(mt,{className:"mr-2 h-4 w-4"}),"New request"]})]}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search by student or type...",value:e,onChange:N=>t(N.target.value),className:"pl-9"})]}),n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"#"}),n.jsx(L,{children:"Student"}),n.jsx(L,{children:"Leave Type"}),n.jsx(L,{children:"Start Date"}),n.jsx(L,{children:"End Date"}),n.jsx(L,{children:"Duration"}),n.jsx(L,{children:"State"}),n.jsx(L,{children:"Actions"})]})}),n.jsx(Be,{children:g.map((N,w)=>n.jsxs(ee,{children:[n.jsx(T,{children:w+1}),n.jsx(T,{className:"font-medium",children:N.student_name}),n.jsx(T,{children:N.leave_type}),n.jsx(T,{children:N.start_date}),n.jsx(T,{children:N.end_date}),n.jsx(T,{children:N.duration}),n.jsx(T,{children:MLe(N.state)}),n.jsx(T,{children:n.jsxs("div",{className:"flex gap-1",children:[n.jsx(E,{size:"sm",variant:"outline",disabled:!b(N.state)||f.isPending,onClick:()=>f.mutate(N.id,{onSuccess:()=>o({title:"Approved"}),onError:S=>o({title:"Error",description:S.message,variant:"destructive"})}),children:n.jsx(aa,{className:"h-4 w-4"})}),n.jsx(E,{size:"sm",variant:"destructive",disabled:!b(N.state)||h.isPending,onClick:()=>h.mutate(N.id,{onSuccess:()=>o({title:"Rejected"}),onError:S=>o({title:"Error",description:S.message,variant:"destructive"})}),children:n.jsx(ts,{className:"h-4 w-4"})})]})})]},N.id))})]})})}),n.jsx(Qe,{open:r,onOpenChange:s,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create leave request"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Student *"}),n.jsxs(Oe,{value:a.student_id||"__none__",onValueChange:N=>i(w=>({...w,student_id:N==="__none__"?"":N})),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select student"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"__none__",children:"— Select —"}),y.map(N=>n.jsx(Y,{value:String(N.id),children:N.name},N.id))]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Leave Type *"}),n.jsxs(Oe,{value:a.leave_type||"__none__",onValueChange:N=>i(w=>({...w,leave_type:N==="__none__"?"":N})),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select leave type"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"__none__",children:"— Select —"}),j.map(N=>n.jsx(Y,{value:String(N.id),children:N.name},N.id))]})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Start date"}),n.jsx(G,{type:"date",value:a.start_date,onChange:N=>i(w=>({...w,start_date:N.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"End date"}),n.jsx(G,{type:"date",value:a.end_date,onChange:N=>i(w=>({...w,end_date:N.target.value}))})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Description"}),n.jsx(G,{value:a.description,onChange:N=>i(w=>({...w,description:N.target.value}))})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),n.jsx(E,{disabled:u.isPending||!a.student_id||!a.leave_type||!a.start_date||!a.end_date,onClick:()=>{u.mutate({student_id:Number(a.student_id),leave_type:Number(a.leave_type),start_date:a.start_date,end_date:a.end_date,description:a.description||void 0},{onSuccess:()=>{s(!1),o({title:"Created successfully"})},onError:N=>o({title:"Error",description:N.message,variant:"destructive"})})},children:"Create"})]})]})})]})}function w$(e){const t=e==null?void 0:e.toLowerCase();return t==="draft"?n.jsx(oe,{variant:"secondary",children:e}):t==="ongoing"?n.jsx(oe,{variant:"default",children:e}):t==="done"?n.jsx(oe,{variant:"outline",className:"border-green-600 text-green-700",children:e}):n.jsx(oe,{variant:"outline",children:e})}function $Le(){var x,j,v,g;const[e,t]=p.useState(""),[r,s]=p.useState("plans"),[a,i]=p.useState(null);He();const o=ide(),l=lde(),c=ode(a??0),d=r==="plans"?o.isLoading:l.isLoading,u=((x=o.data)==null?void 0:x.data)??((j=o.data)==null?void 0:j.items)??[],f=((v=l.data)==null?void 0:v.data)??((g=l.data)==null?void 0:g.items)??[];if(d)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const h=e.toLowerCase(),m=u.filter(b=>{var N,w;return((N=b.student_name)==null?void 0:N.toLowerCase().includes(h))||((w=b.course_name)==null?void 0:w.toLowerCase().includes(h))}),y=f.filter(b=>{var N;return(N=b.student_name)==null?void 0:N.toLowerCase().includes(h)});return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Fees"}),n.jsx("p",{className:"text-muted-foreground",children:"Fee plans and student fee lines."})]}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsxs(E,{variant:r==="plans"?"default":"outline",onClick:()=>s("plans"),children:[n.jsx(ck,{className:"mr-2 h-4 w-4"}),"Fee plans"]}),n.jsxs(E,{variant:r==="student"?"default":"outline",onClick:()=>s("student"),children:[n.jsx(BL,{className:"mr-2 h-4 w-4"}),"Student fees"]})]}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:r==="plans"?"Search plans...":"Search student fees...",value:e,onChange:b=>t(b.target.value),className:"pl-9"})]}),r==="plans"?n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"#"}),n.jsx(L,{children:"Student"}),n.jsx(L,{children:"Course"}),n.jsx(L,{children:"Total"}),n.jsx(L,{children:"Paid"}),n.jsx(L,{children:"Remaining"}),n.jsx(L,{children:"State"}),n.jsx(L,{children:"Actions"})]})}),n.jsx(Be,{children:m.map((b,N)=>n.jsxs(ee,{children:[n.jsx(T,{children:N+1}),n.jsx(T,{className:"font-medium",children:b.student_name}),n.jsx(T,{children:b.course_name}),n.jsx(T,{children:b.total_amount}),n.jsx(T,{children:b.paid_amount}),n.jsx(T,{children:b.remaining_amount}),n.jsx(T,{children:w$(b.state)}),n.jsx(T,{children:n.jsx(E,{size:"sm",variant:"ghost",onClick:()=>i(b.id),children:n.jsx(Uc,{className:"h-4 w-4"})})})]},b.id))})]})})}):n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"#"}),n.jsx(L,{children:"Student"}),n.jsx(L,{children:"Amount"}),n.jsx(L,{children:"Date"}),n.jsx(L,{children:"State"})]})}),n.jsx(Be,{children:y.map((b,N)=>n.jsxs(ee,{children:[n.jsx(T,{children:N+1}),n.jsx(T,{className:"font-medium",children:b.student_name}),n.jsx(T,{children:b.amount}),n.jsx(T,{children:b.date}),n.jsx(T,{children:n.jsx(oe,{variant:"outline",className:"capitalize",children:b.state})})]},b.id))})]})})}),n.jsx(Qe,{open:!!a,onOpenChange:b=>{b||i(null)},children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Fee Plan Details"})}),c.isLoading?n.jsx("div",{className:"flex justify-center py-4",children:n.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"})}):c.data?n.jsxs("div",{className:"space-y-2 text-sm",children:[n.jsxs("p",{children:[n.jsx("span",{className:"font-medium",children:"Student:"})," ",c.data.student_name]}),n.jsxs("p",{children:[n.jsx("span",{className:"font-medium",children:"Course:"})," ",c.data.course_name]}),n.jsxs("p",{children:[n.jsx("span",{className:"font-medium",children:"Total:"})," ",c.data.total_amount]}),n.jsxs("p",{children:[n.jsx("span",{className:"font-medium",children:"Paid:"})," ",c.data.paid_amount]}),n.jsxs("p",{children:[n.jsx("span",{className:"font-medium",children:"Remaining:"})," ",c.data.remaining_amount]}),n.jsxs("p",{children:[n.jsx("span",{className:"font-medium",children:"State:"})," ",w$(c.data.state)]})]}):null]})})]})}function ILe(){const[e,t]=p.useState(""),[r,s]=p.useState(!1),[a,i]=p.useState(!1),[o,l]=p.useState(null),[c,d]=p.useState({lesson_topic:"",course_id:"",batch_id:"",subject_id:""}),{toast:u}=He(),{data:f,isLoading:h}=cde(),m=(f==null?void 0:f.data)??(f==null?void 0:f.items)??[],y=dde(),x=ude(),j=fde(),{data:v}=Er({size:200}),{data:g}=_o({size:200}),{data:b}=gx(),N=(v==null?void 0:v.items)??[],w=(g==null?void 0:g.items)??[],S=Array.isArray(b)?b:(b==null?void 0:b.data)??(b==null?void 0:b.items)??[],_=p.useMemo(()=>c.course_id?w.filter(z=>z.course_id===Number(c.course_id)):w,[w,c.course_id]);if(h)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const C=e.toLowerCase(),P=m.filter(z=>{var O,V,A;return((O=z.name)==null?void 0:O.toLowerCase().includes(C))||((V=z.subject_name)==null?void 0:V.toLowerCase().includes(C))||((A=z.session_name)==null?void 0:A.toLowerCase().includes(C))}),D=z=>{l(z),d({lesson_topic:z.name,course_id:"",batch_id:"",subject_id:String(z.subject_id??"")}),i(!0)};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Lessons"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage lessons, subjects, and sessions."})]}),n.jsxs(E,{onClick:()=>{d({lesson_topic:"",course_id:"",batch_id:"",subject_id:""}),s(!0)},children:[n.jsx(mt,{className:"mr-2 h-4 w-4"}),"Create lesson"]})]}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search lessons...",value:e,onChange:z=>t(z.target.value),className:"pl-9"})]}),n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"#"}),n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Subject"}),n.jsx(L,{children:"Session"}),n.jsx(L,{children:"Actions"})]})}),n.jsx(Be,{children:P.map((z,O)=>n.jsxs(ee,{children:[n.jsx(T,{children:O+1}),n.jsx(T,{className:"font-medium",children:z.name}),n.jsx(T,{children:z.subject_name}),n.jsx(T,{children:z.session_name}),n.jsx(T,{children:n.jsxs("div",{className:"flex gap-1",children:[n.jsx(E,{size:"sm",variant:"ghost",onClick:()=>D(z),children:n.jsx(HL,{className:"h-4 w-4"})}),n.jsx(E,{size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>{window.confirm("Delete this lesson?")&&j.mutate(z.id,{onSuccess:()=>u({title:"Deleted"}),onError:V=>u({title:"Error",description:V.message,variant:"destructive"})})},children:n.jsx($t,{className:"h-4 w-4"})})]})})]},z.id))})]})})}),n.jsx(Qe,{open:r,onOpenChange:s,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create lesson"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Lesson Topic *"}),n.jsx(G,{value:c.lesson_topic,onChange:z=>d(O=>({...O,lesson_topic:z.target.value})),placeholder:"e.g. Introduction to Algebra"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Course *"}),n.jsxs(Oe,{value:c.course_id||"__none__",onValueChange:z=>{d(O=>({...O,course_id:z==="__none__"?"":z,batch_id:""}))},children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select course"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"__none__",children:"— Select —"}),N.map(z=>n.jsx(Y,{value:String(z.id),children:z.title},z.id))]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Batch *"}),n.jsxs(Oe,{value:c.batch_id||"__none__",onValueChange:z=>d(O=>({...O,batch_id:z==="__none__"?"":z})),disabled:!c.course_id,children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:c.course_id?"Select batch":"Pick course first"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"__none__",children:"— Select —"}),_.map(z=>n.jsx(Y,{value:String(z.id),children:z.name},z.id))]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Subject *"}),n.jsxs(Oe,{value:c.subject_id||"__none__",onValueChange:z=>d(O=>({...O,subject_id:z==="__none__"?"":z})),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select subject"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"__none__",children:"— Select —"}),S.map(z=>n.jsx(Y,{value:String(z.id),children:z.name},z.id))]})]})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),n.jsx(E,{disabled:y.isPending||!c.lesson_topic||!c.course_id||!c.batch_id||!c.subject_id,onClick:()=>y.mutate({lesson_topic:c.lesson_topic,name:c.lesson_topic,course_id:Number(c.course_id),batch_id:Number(c.batch_id),subject_id:Number(c.subject_id)},{onSuccess:()=>{s(!1),d({lesson_topic:"",course_id:"",batch_id:"",subject_id:""}),u({title:"Created successfully"})},onError:z=>u({title:"Error",description:z.message,variant:"destructive"})}),children:"Create"})]})]})}),n.jsx(Qe,{open:a,onOpenChange:i,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Edit lesson"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Lesson Topic"}),n.jsx(G,{value:c.lesson_topic,onChange:z=>d(O=>({...O,lesson_topic:z.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Subject"}),n.jsxs(Oe,{value:c.subject_id||"__none__",onValueChange:z=>d(O=>({...O,subject_id:z==="__none__"?"":z})),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select subject"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"__none__",children:"— Select —"}),S.map(z=>n.jsx(Y,{value:String(z.id),children:z.name},z.id))]})]})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),n.jsx(E,{disabled:x.isPending||!o,onClick:()=>{o&&x.mutate({id:o.id,data:{lesson_topic:c.lesson_topic,name:c.lesson_topic,subject_id:c.subject_id?Number(c.subject_id):void 0}},{onSuccess:()=>{i(!1),u({title:"Updated successfully"})},onError:z=>u({title:"Error",description:z.message,variant:"destructive"})})},children:"Save"})]})]})})]})}function DLe(){var D,z,O,V;const[e,t]=p.useState(""),[r,s]=p.useState("books"),[a,i]=p.useState(!1),[o,l]=p.useState(null),[c,d]=p.useState({name:"",course_id:"",subject_id:"",issued_date:""}),{toast:u}=He(),f=mde(),h=hde(),{data:m}=Er({size:200}),{data:y}=gx(),x=(m==null?void 0:m.items)??[],j=Array.isArray(y)?y:(y==null?void 0:y.data)??(y==null?void 0:y.items)??[],v=pde(),g=xde(),b=gde(),N=r==="books"?f.isLoading:h.isLoading,w=((D=f.data)==null?void 0:D.data)??((z=f.data)==null?void 0:z.items)??[],S=((O=h.data)==null?void 0:O.data)??((V=h.data)==null?void 0:V.items)??[];if(N)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const _=e.toLowerCase(),C=w.filter(A=>{var $,B;return(($=A.student_name)==null?void 0:$.toLowerCase().includes(_))||((B=A.course_name)==null?void 0:B.toLowerCase().includes(_))}),P=S.filter(A=>{var $,B,I;return(($=A.name)==null?void 0:$.toLowerCase().includes(_))||((B=A.course_name)==null?void 0:B.toLowerCase().includes(_))||((I=A.subject_name)==null?void 0:I.toLowerCase().includes(_))});return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Gradebook"}),n.jsx("p",{className:"text-muted-foreground",children:"Gradebooks and grading assignments."})]}),r==="assignments"&&n.jsxs(E,{onClick:()=>i(!0),children:[n.jsx(mt,{className:"mr-2 h-4 w-4"}),"New assignment"]})]}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsxs(E,{variant:r==="books"?"default":"outline",onClick:()=>s("books"),children:[n.jsx(Kt,{className:"mr-2 h-4 w-4"}),"Gradebooks"]}),n.jsx(E,{variant:r==="assignments"?"default":"outline",onClick:()=>s("assignments"),children:"Grading assignments"})]}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search...",value:e,onChange:A=>t(A.target.value),className:"pl-9"})]}),r==="books"?n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"#"}),n.jsx(L,{children:"Student"}),n.jsx(L,{children:"Course"}),n.jsx(L,{children:"Academic Year"})]})}),n.jsx(Be,{children:C.map((A,$)=>n.jsxs(ee,{children:[n.jsx(T,{children:$+1}),n.jsx(T,{className:"font-medium",children:A.student_name}),n.jsx(T,{children:A.course_name}),n.jsx(T,{children:A.academic_year_name})]},A.id))})]})})}):n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"#"}),n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Course"}),n.jsx(L,{children:"Subject"}),n.jsx(L,{children:"State"}),n.jsx(L,{children:"Issued Date"}),n.jsx(L,{children:"Actions"})]})}),n.jsx(Be,{children:P.map((A,$)=>n.jsxs(ee,{children:[n.jsx(T,{children:$+1}),n.jsx(T,{className:"font-medium",children:A.name}),n.jsx(T,{children:A.course_name}),n.jsx(T,{children:A.subject_name}),n.jsx(T,{children:n.jsx(oe,{variant:"outline",className:"capitalize",children:A.state})}),n.jsx(T,{children:A.issued_date}),n.jsx(T,{children:n.jsxs("div",{className:"flex gap-1",children:[n.jsx(E,{size:"sm",variant:"ghost",onClick:()=>{l(A.id),d({name:A.name||"",course_id:String(A.course_id||""),subject_id:String(A.subject_id||""),issued_date:A.issued_date||""}),i(!0)},children:n.jsx(Uu,{className:"h-4 w-4"})}),n.jsx(E,{size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>{window.confirm("Delete this assignment?")&&b.mutate(A.id,{onSuccess:()=>u({title:"Deleted"}),onError:B=>u({title:"Error",description:B.message,variant:"destructive"})})},children:n.jsx($t,{className:"h-4 w-4"})})]})})]},A.id))})]})})}),n.jsx(Qe,{open:a,onOpenChange:A=>{i(A),A||l(null)},children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:o?"Edit grading assignment":"Create grading assignment"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{value:c.name,onChange:A=>d($=>({...$,name:A.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Course *"}),n.jsxs(Oe,{value:c.course_id||"__none__",onValueChange:A=>d($=>({...$,course_id:A==="__none__"?"":A})),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select course"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"__none__",children:"— Select —"}),x.map(A=>n.jsx(Y,{value:String(A.id),children:A.title},A.id))]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Subject"}),n.jsxs(Oe,{value:c.subject_id||"__none__",onValueChange:A=>d($=>({...$,subject_id:A==="__none__"?"":A})),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select subject"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"__none__",children:"— Select —"}),j.map(A=>n.jsx(Y,{value:String(A.id),children:A.name},A.id))]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Issued date"}),n.jsx(G,{type:"date",value:c.issued_date,onChange:A=>d($=>({...$,issued_date:A.target.value}))})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>{i(!1),l(null)},children:"Cancel"}),n.jsx(E,{disabled:v.isPending||g.isPending||!c.name||!c.course_id,onClick:()=>{const A={name:c.name,course_id:Number(c.course_id),subject_id:c.subject_id?Number(c.subject_id):void 0,issued_date:c.issued_date},$={onSuccess:()=>{i(!1),l(null),u({title:o?"Updated":"Created"})},onError:B=>u({title:"Error",description:B.message,variant:"destructive"})};o?g.mutate({id:o,data:A},$):v.mutate(A,$)},children:o?"Save":"Create"})]})]})})]})}function LLe(){const[e,t]=p.useState(""),{data:r,isLoading:s}=vde(),a=(r==null?void 0:r.data)??(r==null?void 0:r.items)??[];if(s)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const i=e.toLowerCase(),o=a.filter(l=>{var c;return(c=l.student_name)==null?void 0:c.toLowerCase().includes(i)});return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[n.jsx(Dl,{className:"h-7 w-7"}),"Student progress"]}),n.jsx("p",{className:"text-muted-foreground",children:"Attendance, assignments, and marksheets per student."})]}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search students...",value:e,onChange:l=>t(l.target.value),className:"pl-9"})]}),n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"#"}),n.jsx(L,{children:"Student"}),n.jsx(L,{children:"Total Attendance"}),n.jsx(L,{children:"Total Assignments"}),n.jsx(L,{children:"Total Marksheets"})]})}),n.jsx(Be,{children:o.map((l,c)=>n.jsxs(ee,{children:[n.jsx(T,{children:c+1}),n.jsx(T,{className:"font-medium",children:l.student_name}),n.jsx(T,{children:l.total_attendance}),n.jsx(T,{children:l.total_assignment}),n.jsx(T,{children:l.total_marksheet_line})]},l.id))})]})})})]})}function FLe(){var I,k,M,K,X,re;const[e,t]=p.useState(""),[r,s]=p.useState("media"),[a,i]=p.useState(!1),[o,l]=p.useState(!1),[c,d]=p.useState({name:"",isbn:"",author:"",edition:""}),[u,f]=p.useState({media_id:"",student_id:""}),[h,m]=p.useState(!1),[y,x]=p.useState(""),{toast:j}=He(),v=yde(),g=bde(),b=_de(),N=jde(),w=Nde(),S=wde(),_=Sde(),C=Cde(),P=r==="media"?v.isLoading:r==="movements"?g.isLoading:b.isLoading,D=((I=v.data)==null?void 0:I.data)??((k=v.data)==null?void 0:k.items)??[],z=((M=g.data)==null?void 0:M.data)??((K=g.data)==null?void 0:K.items)??[],O=((X=b.data)==null?void 0:X.data)??((re=b.data)==null?void 0:re.items)??[];if(P)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const V=e.toLowerCase(),A=D.filter(Z=>{var te,xe,me;return((te=Z.name)==null?void 0:te.toLowerCase().includes(V))||((xe=Z.isbn)==null?void 0:xe.toLowerCase().includes(V))||((me=Z.author)==null?void 0:me.toLowerCase().includes(V))}),$=z.filter(Z=>{var te,xe,me;return((te=Z.media_name)==null?void 0:te.toLowerCase().includes(V))||((xe=Z.student_name)==null?void 0:xe.toLowerCase().includes(V))||((me=Z.faculty_name)==null?void 0:me.toLowerCase().includes(V))}),B=O.filter(Z=>{var te,xe;return((te=Z.number)==null?void 0:te.toLowerCase().includes(V))||((xe=Z.student_name)==null?void 0:xe.toLowerCase().includes(V))});return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Library"}),n.jsx("p",{className:"text-muted-foreground",children:"Media, circulation, and library cards."})]}),n.jsxs("div",{className:"flex gap-2",children:[r==="media"&&n.jsxs(E,{onClick:()=>i(!0),children:[n.jsx(mt,{className:"mr-2 h-4 w-4"}),"Add media"]}),r==="movements"&&n.jsxs(E,{onClick:()=>l(!0),children:[n.jsx(mt,{className:"mr-2 h-4 w-4"}),"Issue"]}),r==="cards"&&n.jsxs(E,{onClick:()=>m(!0),children:[n.jsx(mt,{className:"mr-2 h-4 w-4"}),"New card"]})]})]}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsxs(E,{variant:r==="media"?"default":"outline",onClick:()=>s("media"),children:[n.jsx(CG,{className:"mr-2 h-4 w-4"}),"Media catalog"]}),n.jsxs(E,{variant:r==="movements"?"default":"outline",onClick:()=>s("movements"),children:[n.jsx(SG,{className:"mr-2 h-4 w-4"}),"Movements"]}),n.jsx(E,{variant:r==="cards"?"default":"outline",onClick:()=>s("cards"),children:"Library cards"})]}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search...",value:e,onChange:Z=>t(Z.target.value),className:"pl-9"})]}),r==="media"&&n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"#"}),n.jsx(L,{children:"Name"}),n.jsx(L,{children:"ISBN"}),n.jsx(L,{children:"Author"}),n.jsx(L,{children:"Edition"}),n.jsx(L,{children:"Type"}),n.jsx(L,{children:"Actions"})]})}),n.jsx(Be,{children:A.map((Z,te)=>n.jsxs(ee,{children:[n.jsx(T,{children:te+1}),n.jsx(T,{className:"font-medium",children:Z.name}),n.jsx(T,{children:Z.isbn}),n.jsx(T,{children:Z.author}),n.jsx(T,{children:Z.edition}),n.jsx(T,{children:Z.media_type}),n.jsx(T,{children:n.jsx(E,{size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>{window.confirm("Delete this media?")&&w.mutate(Z.id,{onSuccess:()=>j({title:"Deleted"}),onError:xe=>j({title:"Error",description:xe.message,variant:"destructive"})})},children:n.jsx($t,{className:"h-4 w-4"})})})]},Z.id))})]})})}),r==="movements"&&n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"#"}),n.jsx(L,{children:"Media"}),n.jsx(L,{children:"Student"}),n.jsx(L,{children:"Faculty"}),n.jsx(L,{children:"Issued Date"}),n.jsx(L,{children:"Return Date"}),n.jsx(L,{children:"State"}),n.jsx(L,{children:"Actions"})]})}),n.jsx(Be,{children:$.map((Z,te)=>n.jsxs(ee,{children:[n.jsx(T,{children:te+1}),n.jsx(T,{className:"font-medium",children:Z.media_name}),n.jsx(T,{children:Z.student_name}),n.jsx(T,{children:Z.faculty_name}),n.jsx(T,{children:Z.issued_date}),n.jsx(T,{children:Z.return_date}),n.jsx(T,{children:n.jsx(oe,{variant:"outline",children:Z.state})}),n.jsx(T,{children:Z.state==="issue"&&n.jsxs(E,{size:"sm",variant:"ghost",onClick:()=>_.mutate(Z.id,{onSuccess:()=>j({title:"Returned"}),onError:xe=>j({title:"Error",description:xe.message,variant:"destructive"})}),children:[n.jsx(GL,{className:"h-4 w-4 mr-1"})," Return"]})})]},Z.id))})]})})}),r==="cards"&&n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"#"}),n.jsx(L,{children:"Number"}),n.jsx(L,{children:"Student"}),n.jsx(L,{children:"Faculty"})]})}),n.jsx(Be,{children:B.map((Z,te)=>n.jsxs(ee,{children:[n.jsx(T,{children:te+1}),n.jsx(T,{className:"font-medium",children:Z.number}),n.jsx(T,{children:Z.student_name}),n.jsx(T,{children:Z.faculty_name})]},Z.id))})]})})}),n.jsx(Qe,{open:a,onOpenChange:i,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Add media"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{value:c.name,onChange:Z=>d(te=>({...te,name:Z.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"ISBN"}),n.jsx(G,{value:c.isbn,onChange:Z=>d(te=>({...te,isbn:Z.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Author"}),n.jsx(G,{value:c.author,onChange:Z=>d(te=>({...te,author:Z.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Edition"}),n.jsx(G,{value:c.edition,onChange:Z=>d(te=>({...te,edition:Z.target.value}))})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),n.jsx(E,{disabled:N.isPending,onClick:()=>N.mutate({name:c.name,isbn:c.isbn||void 0,author:c.author||void 0,edition:c.edition||void 0},{onSuccess:()=>{i(!1),j({title:"Created successfully"})},onError:Z=>j({title:"Error",description:Z.message,variant:"destructive"})}),children:"Save"})]})]})}),n.jsx(Qe,{open:o,onOpenChange:l,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Issue movement"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Media ID"}),n.jsx(G,{type:"number",value:u.media_id,onChange:Z=>f(te=>({...te,media_id:Z.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Student ID"}),n.jsx(G,{type:"number",value:u.student_id,onChange:Z=>f(te=>({...te,student_id:Z.target.value}))})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),n.jsx(E,{disabled:S.isPending,onClick:()=>S.mutate({media_id:Number(u.media_id),student_id:Number(u.student_id)},{onSuccess:()=>{l(!1),j({title:"Issued"})},onError:Z=>j({title:"Error",description:Z.message,variant:"destructive"})}),children:"Issue"})]})]})}),n.jsx(Qe,{open:h,onOpenChange:m,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create library card"})}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Student ID"}),n.jsx(G,{type:"number",value:y,onChange:Z=>x(Z.target.value)})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>m(!1),children:"Cancel"}),n.jsx(E,{disabled:C.isPending||!y,onClick:()=>C.mutate({student_id:Number(y)},{onSuccess:()=>{m(!1),x(""),j({title:"Card created"})},onError:Z=>j({title:"Error",description:Z.message,variant:"destructive"})}),children:"Create"})]})]})})]})}function BLe(){var z,O,V,A;const[e,t]=p.useState(""),[r,s]=p.useState("activities"),[a,i]=p.useState(!1),[o,l]=p.useState(!1),[c,d]=p.useState({student_id:"",type_id:"",date:"",description:""}),[u,f]=p.useState(""),{toast:h}=He(),m=kde(),y=Pde(),{data:x}=Qa({size:500}),j=(x==null?void 0:x.items)??[],v=Ade(),g=Ede(),b=Ode(),N=Tde(),w=r==="activities"?m.isLoading:y.isLoading,S=((z=m.data)==null?void 0:z.data)??((O=m.data)==null?void 0:O.items)??[],_=((V=y.data)==null?void 0:V.data)??((A=y.data)==null?void 0:A.items)??[];if(w)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const C=e.toLowerCase(),P=S.filter($=>{var B,I,k;return((B=$.student_name)==null?void 0:B.toLowerCase().includes(C))||((I=$.type_name)==null?void 0:I.toLowerCase().includes(C))||((k=$.description)==null?void 0:k.toLowerCase().includes(C))}),D=_.filter($=>{var B;return(B=$.name)==null?void 0:B.toLowerCase().includes(C)});return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[n.jsxs("div",{children:[n.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[n.jsx(Sj,{className:"h-7 w-7"}),"Activities"]}),n.jsx("p",{className:"text-muted-foreground",children:"Student activities and activity types."})]}),n.jsxs(E,{onClick:()=>r==="activities"?i(!0):l(!0),children:[n.jsx(mt,{className:"mr-2 h-4 w-4"}),r==="activities"?"New activity":"New type"]})]}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(E,{variant:r==="activities"?"default":"outline",onClick:()=>s("activities"),children:"Activities"}),n.jsx(E,{variant:r==="types"?"default":"outline",onClick:()=>s("types"),children:"Activity types"})]}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search...",value:e,onChange:$=>t($.target.value),className:"pl-9"})]}),r==="activities"?n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"#"}),n.jsx(L,{children:"Student"}),n.jsx(L,{children:"Type"}),n.jsx(L,{children:"Date"}),n.jsx(L,{children:"Description"}),n.jsx(L,{children:"Actions"})]})}),n.jsx(Be,{children:P.map(($,B)=>n.jsxs(ee,{children:[n.jsx(T,{children:B+1}),n.jsx(T,{className:"font-medium",children:$.student_name}),n.jsx(T,{children:$.type_name}),n.jsx(T,{children:$.date}),n.jsx(T,{className:"max-w-xs truncate",children:$.description}),n.jsx(T,{children:n.jsx(E,{size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>{window.confirm("Delete this activity?")&&g.mutate($.id,{onSuccess:()=>h({title:"Deleted"}),onError:I=>h({title:"Error",description:I.message,variant:"destructive"})})},children:n.jsx($t,{className:"h-4 w-4"})})})]},$.id))})]})})}):n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"#"}),n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Actions"})]})}),n.jsx(Be,{children:D.map(($,B)=>n.jsxs(ee,{children:[n.jsx(T,{children:B+1}),n.jsx(T,{className:"font-medium",children:$.name}),n.jsx(T,{children:n.jsx(E,{size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>{window.confirm("Delete this activity type?")&&N.mutate($.id,{onSuccess:()=>h({title:"Deleted"}),onError:I=>h({title:"Error",description:I.message,variant:"destructive"})})},children:n.jsx($t,{className:"h-4 w-4"})})})]},$.id))})]})})}),n.jsx(Qe,{open:a,onOpenChange:i,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create activity"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Student *"}),n.jsxs(Oe,{value:c.student_id||"__none__",onValueChange:$=>d(B=>({...B,student_id:$==="__none__"?"":$})),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select student"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"__none__",children:"— Select —"}),j.map($=>n.jsx(Y,{value:String($.id),children:$.name},$.id))]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Activity Type *"}),n.jsxs(Oe,{value:c.type_id||"__none__",onValueChange:$=>d(B=>({...B,type_id:$==="__none__"?"":$})),children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select type"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"__none__",children:"— Select —"}),_.map($=>n.jsx(Y,{value:String($.id),children:$.name},$.id))]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Date"}),n.jsx(G,{type:"date",value:c.date,onChange:$=>d(B=>({...B,date:$.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Description"}),n.jsx(on,{value:c.description,onChange:$=>d(B=>({...B,description:$.target.value}))})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),n.jsx(E,{disabled:v.isPending||!c.student_id||!c.type_id||!c.date,onClick:()=>v.mutate({student_id:Number(c.student_id),type_id:Number(c.type_id),date:c.date,description:c.description||void 0},{onSuccess:()=>{i(!1),h({title:"Created successfully"})},onError:$=>h({title:"Error",description:$.message,variant:"destructive"})}),children:"Create"})]})]})}),n.jsx(Qe,{open:o,onOpenChange:l,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create activity type"})}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{value:u,onChange:$=>f($.target.value)})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),n.jsx(E,{disabled:b.isPending,onClick:()=>b.mutate({name:u},{onSuccess:()=>{l(!1),h({title:"Created successfully"})},onError:$=>h({title:"Error",description:$.message,variant:"destructive"})}),children:"Create"})]})]})})]})}function zLe(){var P,D,z,O;const[e,t]=p.useState(""),[r,s]=p.useState("facilities"),[a,i]=p.useState(!1),[o,l]=p.useState(!1),[c,d]=p.useState({name:"",code:""}),[u,f]=p.useState({name:"",code:""}),{toast:h}=He(),m=Mde(),y=Ide(),x=Rde(),j=$de(),v=Dde(),g=Lde(),b=r==="facilities"?m.isLoading:y.isLoading,N=((P=m.data)==null?void 0:P.data)??((D=m.data)==null?void 0:D.items)??[],w=((z=y.data)==null?void 0:z.data)??((O=y.data)==null?void 0:O.items)??[];if(b)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const S=e.toLowerCase(),_=N.filter(V=>{var A,$;return((A=V.name)==null?void 0:A.toLowerCase().includes(S))||(($=V.code)==null?void 0:$.toLowerCase().includes(S))}),C=w.filter(V=>{var A,$,B;return((A=V.name)==null?void 0:A.toLowerCase().includes(S))||(($=V.code)==null?void 0:$.toLowerCase().includes(S))||((B=V.product_name)==null?void 0:B.toLowerCase().includes(S))});return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[n.jsxs("div",{children:[n.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[n.jsx(IL,{className:"h-7 w-7"}),"Facilities"]}),n.jsx("p",{className:"text-muted-foreground",children:"Facilities and fixed assets."})]}),n.jsxs(E,{onClick:()=>r==="facilities"?i(!0):l(!0),children:[n.jsx(mt,{className:"mr-2 h-4 w-4"}),r==="facilities"?"New facility":"New asset"]})]}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(E,{variant:r==="facilities"?"default":"outline",onClick:()=>s("facilities"),children:"Facilities"}),n.jsx(E,{variant:r==="assets"?"default":"outline",onClick:()=>s("assets"),children:"Assets"})]}),n.jsxs("div",{className:"relative max-w-sm",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search...",value:e,onChange:V=>t(V.target.value),className:"pl-9"})]}),r==="facilities"?n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"#"}),n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Code"}),n.jsx(L,{children:"Actions"})]})}),n.jsx(Be,{children:_.map((V,A)=>n.jsxs(ee,{children:[n.jsx(T,{children:A+1}),n.jsx(T,{className:"font-medium",children:V.name}),n.jsx(T,{children:V.code}),n.jsx(T,{children:n.jsx(E,{size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>{window.confirm("Delete this facility?")&&j.mutate(V.id,{onSuccess:()=>h({title:"Deleted"}),onError:$=>h({title:"Error",description:$.message,variant:"destructive"})})},children:n.jsx($t,{className:"h-4 w-4"})})})]},V.id))})]})})}):n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"#"}),n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Code"}),n.jsx(L,{children:"Product"}),n.jsx(L,{children:"Actions"})]})}),n.jsx(Be,{children:C.map((V,A)=>n.jsxs(ee,{children:[n.jsx(T,{children:A+1}),n.jsx(T,{className:"font-medium",children:V.name}),n.jsx(T,{children:V.code}),n.jsx(T,{children:V.product_name}),n.jsx(T,{children:n.jsx(E,{size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>{window.confirm("Delete this asset?")&&g.mutate(V.id,{onSuccess:()=>h({title:"Deleted"}),onError:$=>h({title:"Error",description:$.message,variant:"destructive"})})},children:n.jsx($t,{className:"h-4 w-4"})})})]},V.id))})]})})}),n.jsx(Qe,{open:a,onOpenChange:i,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create facility"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{value:c.name,onChange:V=>d(A=>({...A,name:V.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Code"}),n.jsx(G,{value:c.code,onChange:V=>d(A=>({...A,code:V.target.value}))})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),n.jsx(E,{disabled:x.isPending,onClick:()=>x.mutate({name:c.name,code:c.code||void 0},{onSuccess:()=>{i(!1),h({title:"Created successfully"})},onError:V=>h({title:"Error",description:V.message,variant:"destructive"})}),children:"Create"})]})]})}),n.jsx(Qe,{open:o,onOpenChange:l,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create asset"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{value:u.name,onChange:V=>f(A=>({...A,name:V.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Code"}),n.jsx(G,{value:u.code,onChange:V=>f(A=>({...A,code:V.target.value}))})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),n.jsx(E,{disabled:v.isPending,onClick:()=>v.mutate({name:u.name,code:u.code||void 0},{onSuccess:()=>{l(!1),h({title:"Created successfully"})},onError:V=>h({title:"Error",description:V.message,variant:"destructive"})}),children:"Create"})]})]})})]})}function VLe(){const{toast:e}=He(),[t,r]=p.useState("register"),[s,a]=p.useState(0),[i,o]=p.useState({first_name:"",last_name:"",email:"",gender:"m"}),[l,c]=p.useState(""),{data:d,isLoading:u}=ye({queryKey:["admission-registers","list"],queryFn:()=>Ts.listRegisters()}),f=(d==null?void 0:d.items)??[],h=f.find(j=>j.id===s),m=ae({mutationFn:async()=>{const j=await Ts.createAdmission({...i,register_id:s});return await Ts.submitAdmission(j.id),j},onSuccess:j=>{c(j.application_number),r("success")},onError:()=>e({title:"Error",description:"Submission failed. Please try again.",variant:"destructive"})}),y=s>0,x=i.first_name&&i.last_name&&i.email;return n.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:n.jsxs("div",{className:"w-full max-w-lg",children:[t!=="success"&&n.jsx("div",{className:"flex items-center justify-center gap-2 mb-8",children:["register","personal","review"].map((j,v)=>n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium ${j===t?"bg-primary text-primary-foreground":["register","personal","review"].indexOf(t)>v?"bg-primary/20 text-primary":"bg-muted text-muted-foreground"}`,children:v+1}),v<2&&n.jsx("div",{className:"w-12 h-px bg-border"})]},j))}),t==="register"&&n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Select Course"}),n.jsx($e,{children:"Choose the admission register you want to apply to."})]}),n.jsxs(U,{className:"space-y-4",children:[u?n.jsx("div",{className:"flex justify-center py-8",children:n.jsx(Re,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):n.jsxs("div",{className:"space-y-2",children:[f.filter(j=>j.state==="confirm").map(j=>n.jsxs("button",{onClick:()=>a(j.id),className:`w-full text-left p-4 rounded-lg border transition-colors ${s===j.id?"bg-primary/10 border-primary":"hover:bg-accent"}`,children:[n.jsx("p",{className:"font-medium",children:j.name}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[j.course_name," · ",j.start_date," — ",j.end_date]})]},j.id)),f.filter(j=>j.state==="confirm").length===0&&n.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No open admissions available."})]}),n.jsx(E,{className:"w-full",onClick:()=>r("personal"),disabled:!y,children:"Next"})]})]}),t==="personal"&&n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Personal Information"}),n.jsx($e,{children:"Fill in your personal details."})]}),n.jsxs(U,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"First Name *"}),n.jsx(G,{value:i.first_name,onChange:j=>o({...i,first_name:j.target.value})})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Last Name *"}),n.jsx(G,{value:i.last_name,onChange:j=>o({...i,last_name:j.target.value})})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Middle Name"}),n.jsx(G,{value:i.middle_name??"",onChange:j=>o({...i,middle_name:j.target.value||void 0})})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Email *"}),n.jsx(G,{type:"email",value:i.email,onChange:j=>o({...i,email:j.target.value})})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Phone"}),n.jsx(G,{value:i.phone??"",onChange:j=>o({...i,phone:j.target.value||void 0})})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Birth Date"}),n.jsx(G,{type:"date",value:i.birth_date??"",onChange:j=>o({...i,birth_date:j.target.value||void 0})})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Gender *"}),n.jsxs(Oe,{value:i.gender,onValueChange:j=>o({...i,gender:j}),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"m",children:"Male"}),n.jsx(Y,{value:"f",children:"Female"}),n.jsx(Y,{value:"o",children:"Other"})]})]})]})]}),n.jsxs("div",{className:"flex gap-3",children:[n.jsx(E,{variant:"outline",className:"flex-1",onClick:()=>r("register"),children:"Back"}),n.jsx(E,{className:"flex-1",onClick:()=>r("review"),disabled:!x,children:"Next"})]})]})]}),t==="review"&&n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Review & Submit"}),n.jsx($e,{children:"Please review your application before submitting."})]}),n.jsxs(U,{className:"space-y-4",children:[n.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[n.jsx("p",{className:"text-sm font-medium",children:"Course"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[h==null?void 0:h.name," — ",h==null?void 0:h.course_name]})]}),n.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[n.jsx("p",{className:"text-sm font-medium",children:"Applicant"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.first_name," ",i.middle_name??""," ",i.last_name]}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.email," ",i.phone?`· ${i.phone}`:""]}),n.jsxs("p",{className:"text-sm text-muted-foreground capitalize",children:[i.gender==="m"?"Male":i.gender==="f"?"Female":"Other"," ",i.birth_date?`· ${i.birth_date}`:""]})]}),n.jsxs("div",{className:"flex gap-3",children:[n.jsx(E,{variant:"outline",className:"flex-1",onClick:()=>r("personal"),children:"Back"}),n.jsxs(E,{className:"flex-1",onClick:()=>m.mutate(),disabled:m.isPending,children:[m.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Submit Application"]})]})]})]}),t==="success"&&n.jsx(W,{children:n.jsxs(U,{className:"pt-8 pb-8 text-center space-y-4",children:[n.jsx(Un,{className:"h-16 w-16 text-green-500 mx-auto"}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-xl font-bold",children:"Application Submitted!"}),n.jsx("p",{className:"text-muted-foreground mt-1",children:"Your application has been received."})]}),n.jsxs("div",{className:"rounded-lg bg-muted p-4",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"Application Number"}),n.jsx("p",{className:"text-2xl font-bold",children:l})]}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Please save this number for future reference."})]})})]})})}const qLe={draft:"outline",confirm:"default",reject:"destructive",done:"secondary"};function WLe(){const{toast:e}=He(),t=je(),[r,s]=p.useState([]),{data:a,isLoading:i}=ye({queryKey:["subject-registrations","list"],queryFn:()=>gr.listSubjectRegistrations()}),o=(a==null?void 0:a.items)??[],{data:l=[],isLoading:c}=ye({queryKey:["subject-registrations","available"],queryFn:()=>gr.getAvailableSubjects()}),d=ae({mutationFn:()=>gr.createSubjectRegistration({subject_ids:r}),onSuccess:()=>{t.invalidateQueries({queryKey:["subject-registrations"]}),e({title:"Registration submitted"}),s([])},onError:()=>e({title:"Error",description:"Registration failed",variant:"destructive"})}),u=f=>{s(h=>h.includes(f)?h.filter(m=>m!==f):[...h,f])};return i?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Subject Registration"}),n.jsx("p",{className:"text-muted-foreground",children:"Register for subjects within your enrolled courses."})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Available Subjects"}),n.jsx($e,{children:"Select the subjects you want to register for this term."})]}),n.jsx(U,{children:c?n.jsx("div",{className:"flex justify-center py-8",children:n.jsx(Re,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):l.length>0?n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"space-y-2",children:l.map(f=>{var h;return n.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-lg border hover:bg-accent/50 cursor-pointer",children:[n.jsx(an,{checked:r.includes(f.id),onCheckedChange:()=>u(f.id)}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-sm font-medium",children:((h=f.subject_names)==null?void 0:h.join(", "))||f.course_name}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:[f.course_name," · ",f.batch_name,f.min_unit_load>0&&` · Load: ${f.min_unit_load}–${f.max_unit_load}`]})]})]},f.id)})}),n.jsxs(E,{onClick:()=>d.mutate(),disabled:d.isPending||r.length===0,children:[d.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Submit Registration (",r.length," selected)"]})]}):n.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No subjects available for registration."})})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{children:"My Registrations"})}),n.jsx(U,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Course"}),n.jsx(L,{children:"Batch"}),n.jsx(L,{children:"Subjects"}),n.jsx(L,{children:"State"})]})}),n.jsxs(Be,{children:[o.map(f=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:f.course_name}),n.jsx(T,{className:"text-muted-foreground",children:f.batch_name}),n.jsx(T,{children:n.jsxs("div",{className:"flex flex-wrap gap-1",children:[f.subject_names.slice(0,3).map((h,m)=>n.jsx(oe,{variant:"secondary",className:"text-xs",children:h},m)),f.subject_names.length>3&&n.jsxs(oe,{variant:"secondary",className:"text-xs",children:["+",f.subject_names.length-3]})]})}),n.jsx(T,{children:n.jsx(oe,{variant:qLe[f.state]??"outline",className:"capitalize",children:f.state})})]},f.id)),o.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"No registrations yet."})})]})]})})]})]})}function ULe(){const{courseId:e}=Ht(),t=Number(e),{toast:r}=He(),{data:s=[],isLoading:a}=oce(t),i=cce(),o=dce(),l=uce(),c=fce(),[d,u]=p.useState(!1),[f,h]=p.useState(""),[m,y]=p.useState(""),[x,j]=p.useState(""),[v,g]=p.useState("manual"),b=()=>{h(""),y(""),j(""),g("manual")},N=()=>{i.mutate({courseId:t,data:{name:f,course_id:t,description:m,start_date:x||void 0,unlock_mode:v}},{onSuccess:()=>{r({title:"Chapter Created"}),u(!1),b()},onError:()=>r({title:"Error",description:"Failed to create chapter",variant:"destructive"})})},w=_=>{o.mutate({id:_,courseId:t},{onSuccess:()=>r({title:"Chapter Deleted"}),onError:()=>r({title:"Error",description:"Failed to delete chapter",variant:"destructive"})})},S=(_,C)=>{(C?c:l).mutate({id:_,courseId:t},{onSuccess:()=>r({title:C?"Chapter Locked":"Chapter Unlocked"}),onError:()=>r({title:"Error",description:"Failed to update lock status",variant:"destructive"})})};return a?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Course Chapters"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage chapters and their sequence for this course."})]}),n.jsxs(Qe,{open:d,onOpenChange:u,children:[n.jsx(cr,{asChild:!0,children:n.jsxs(E,{children:[n.jsx(mt,{className:"mr-2 h-4 w-4"})," Add Chapter"]})}),n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Add New Chapter"})}),n.jsxs("div",{className:"space-y-4 pt-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{placeholder:"Chapter name",value:f,onChange:_=>h(_.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Description"}),n.jsx(on,{placeholder:"Brief description",value:m,onChange:_=>y(_.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Start Date"}),n.jsx(G,{type:"date",value:x,onChange:_=>j(_.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Unlock Mode"}),n.jsxs(Oe,{value:v,onValueChange:_=>g(_),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"manual",children:"Manual"}),n.jsx(Y,{value:"auto_date",children:"Auto (Date)"}),n.jsx(Y,{value:"prerequisite",children:"Prerequisite"})]})]})]}),n.jsxs(E,{className:"w-full",onClick:N,disabled:i.isPending||!f,children:[i.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Create Chapter"]})]})]})]})]}),n.jsxs("div",{className:"space-y-3",children:[s.sort((_,C)=>_.sequence-C.sequence).map(_=>n.jsx(W,{className:"hover:shadow-sm transition-shadow",children:n.jsxs(U,{className:"flex items-center gap-4 py-4",children:[n.jsx(uk,{className:"h-5 w-5 text-muted-foreground shrink-0 cursor-grab"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Kt,{className:"h-4 w-4 text-primary shrink-0"}),n.jsx("span",{className:"font-medium truncate",children:_.name})]}),n.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[_.start_date&&n.jsx("span",{children:new Date(_.start_date).toLocaleDateString()}),n.jsxs("span",{children:[_.material_count," material",_.material_count!==1?"s":""]})]})]}),n.jsx(oe,{variant:_.is_unlocked?"default":"secondary",children:_.is_unlocked?"Unlocked":"Locked"}),n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>S(_.id,_.is_unlocked),disabled:l.isPending||c.isPending,children:_.is_unlocked?n.jsx(zf,{className:"h-4 w-4"}):n.jsx(HG,{className:"h-4 w-4"})}),n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>w(_.id),disabled:o.isPending,children:n.jsx($t,{className:"h-4 w-4 text-destructive"})})]})},_.id)),s.length===0&&n.jsx(W,{children:n.jsxs(U,{className:"py-12 text-center text-muted-foreground",children:[n.jsx(Kt,{className:"h-12 w-12 mx-auto mb-3 opacity-40"}),n.jsx("p",{children:"No chapters yet. Add your first chapter to get started."})]})})]})]})}const KLe={pdf:n.jsx(Yn,{className:"h-4 w-4"}),document:n.jsx(Yn,{className:"h-4 w-4"}),video:n.jsx(Ll,{className:"h-4 w-4"}),audio:n.jsx(UL,{className:"h-4 w-4"}),image:n.jsx(VL,{className:"h-4 w-4"}),link:n.jsx(kj,{className:"h-4 w-4"}),article:n.jsx(Yn,{className:"h-4 w-4"})};function GLe(){const{courseId:e,chapterId:t}=Ht(),r=Number(t),{toast:s}=He(),a=je(),{data:i,isLoading:o}=CB(r),{data:l=[],isLoading:c}=kB(r),d=mce(),u=hce(),f=p.useRef(null),[h,m]=p.useState(!1),[y,x]=p.useState(""),[j,v]=p.useState("pdf"),[g,b]=p.useState(""),[N,w]=p.useState(null),[S,_]=p.useState(!0),C=ae({mutationFn:({id:O,allow:V})=>Ar.updateMaterial(O,{allow_download:V}),onSuccess:()=>a.invalidateQueries({queryKey:["chapter-materials",r]}),onError:()=>s({title:"Error",description:"Failed to update material",variant:"destructive"})}),P=()=>{x(""),v("pdf"),b(""),w(null),_(!0)},D=()=>{const O=new FormData;O.append("name",y),O.append("type",j),O.append("allow_download",String(S)),N&&O.append("file",N),g&&O.append("url",g),d.mutate({chapterId:r,formData:O},{onSuccess:()=>{s({title:"Material Uploaded"}),m(!1),P()},onError:()=>s({title:"Error",description:"Failed to upload material",variant:"destructive"})})},z=O=>{u.mutate({id:O,chapterId:r},{onSuccess:()=>s({title:"Material Deleted"}),onError:()=>s({title:"Error",description:"Failed to delete material",variant:"destructive"})})};return o||c?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[i&&n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:i.name}),n.jsx($e,{children:i.description})]}),n.jsx(U,{children:n.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i.start_date&&n.jsxs("span",{className:"text-muted-foreground",children:["Starts: ",new Date(i.start_date).toLocaleDateString()]}),i.end_date&&n.jsxs("span",{className:"text-muted-foreground",children:["Ends: ",new Date(i.end_date).toLocaleDateString()]}),n.jsx(oe,{variant:i.is_unlocked?"default":"secondary",children:i.is_unlocked?"Unlocked":"Locked"}),n.jsx(oe,{variant:"outline",children:i.unlock_mode})]})})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h2",{className:"text-lg font-semibold",children:"Materials"}),n.jsxs(Qe,{open:h,onOpenChange:m,children:[n.jsx(cr,{asChild:!0,children:n.jsxs(E,{size:"sm",children:[n.jsx(mt,{className:"mr-2 h-4 w-4"})," Upload Material"]})}),n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Upload Material"})}),n.jsxs("div",{className:"space-y-4 pt-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{placeholder:"Material name",value:y,onChange:O=>x(O.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Type"}),n.jsxs(Oe,{value:j,onValueChange:O=>v(O),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"pdf",children:"PDF"}),n.jsx(Y,{value:"document",children:"Document"}),n.jsx(Y,{value:"video",children:"Video"}),n.jsx(Y,{value:"audio",children:"Audio"}),n.jsx(Y,{value:"image",children:"Image"}),n.jsx(Y,{value:"link",children:"Link"}),n.jsx(Y,{value:"article",children:"Article"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"File"}),n.jsx(G,{ref:f,type:"file",onChange:O=>{var V;return w(((V=O.target.files)==null?void 0:V[0])??null)}})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Or URL"}),n.jsx(G,{placeholder:"https://...",value:g,onChange:O=>b(O.target.value)})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(an,{id:"allow-dl",checked:S,onCheckedChange:O=>_(!!O)}),n.jsx(q,{htmlFor:"allow-dl",children:"Allow Download"})]}),n.jsxs(E,{className:"w-full",onClick:D,disabled:d.isPending||!y,children:[d.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),n.jsx(Ku,{className:"mr-2 h-4 w-4"})," Upload"]})]})]})]})]}),n.jsx(W,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{className:"w-12",children:"#"}),n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Type"}),n.jsx(L,{children:"Download"}),n.jsx(L,{className:"w-16",children:"Actions"})]})}),n.jsxs(Be,{children:[l.sort((O,V)=>O.sequence-V.sequence).map(O=>n.jsxs(ee,{children:[n.jsx(T,{className:"text-muted-foreground",children:O.sequence}),n.jsxs(T,{className:"flex items-center gap-2",children:[KLe[O.type],n.jsx("span",{children:O.name})]}),n.jsx(T,{children:n.jsx(oe,{variant:"outline",children:O.type})}),n.jsx(T,{children:n.jsx(an,{checked:O.allow_download,onCheckedChange:V=>C.mutate({id:O.id,allow:!!V})})}),n.jsx(T,{children:n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>z(O.id),disabled:u.isPending,children:n.jsx($t,{className:"h-4 w-4 text-destructive"})})})]},O.id)),l.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:5,className:"text-center text-muted-foreground py-8",children:"No materials uploaded yet."})})]})]})})]})}function HLe(){const{courseId:e}=Ht(),t=Number(e),{toast:r}=He(),[s,a]=p.useState(1),[i,o]=p.useState(""),[l,c]=p.useState(""),[d,u]=p.useState("intermediate"),[f,h]=p.useState(null),[m,y]=p.useState(null),x=gce(),j=vce(),v=yce(),g=()=>{x.mutate({course_id:t,topic:i,objectives:l,complexity:d},{onSuccess:S=>{h(S),a(2)},onError:()=>r({title:"Error",description:"Failed to generate outline",variant:"destructive"})})},b=()=>{j.mutate({course_id:t,topic:i,objectives:l,complexity:d},{onSuccess:S=>{y(S),a(3)},onError:()=>r({title:"Error",description:"Failed to generate content",variant:"destructive"})})},N=()=>{v.mutate({course_id:t,topic:i,objectives:l,complexity:d,outline:f,content:m},{onSuccess:()=>{r({title:"Published Successfully"}),a(4)},onError:()=>r({title:"Error",description:"Failed to publish",variant:"destructive"})})},w=[{num:1,label:"Requirements"},{num:2,label:"Review Outline"},{num:3,label:"Generated Content"},{num:4,label:"Published"}];return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"AI Workbench"}),n.jsx("p",{className:"text-muted-foreground",children:"Generate course content using AI assistance."})]}),n.jsx("div",{className:"flex items-center gap-2",children:w.map((S,_)=>n.jsxs("div",{className:"flex items-center",children:[n.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm ${s>=S.num?"bg-primary/10 text-primary font-medium":"text-muted-foreground"}`,children:[s>S.num?n.jsx(Un,{className:"h-4 w-4"}):n.jsx("span",{className:"h-5 w-5 rounded-full border flex items-center justify-center text-xs",children:S.num}),S.label]}),_o(S.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Learning Objectives"}),n.jsx(on,{placeholder:"List the key objectives, one per line...",rows:4,value:l,onChange:S=>c(S.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Complexity Level"}),n.jsxs(Oe,{value:d,onValueChange:S=>u(S),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"beginner",children:"Beginner"}),n.jsx(Y,{value:"intermediate",children:"Intermediate"}),n.jsx(Y,{value:"advanced",children:"Advanced"})]})]})]}),n.jsxs(E,{onClick:g,disabled:x.isPending||!i||!l,children:[x.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),n.jsx(lt,{className:"mr-2 h-4 w-4"})," Generate Outline"]})]})]}),s===2&&f&&n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Review Generated Outline"}),n.jsx($e,{children:"Review the AI-generated chapter outline before generating detailed content."})]}),n.jsxs(U,{className:"space-y-4",children:[f.chapters.map((S,_)=>n.jsxs("div",{className:"p-4 rounded-lg border space-y-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Kt,{className:"h-4 w-4 text-primary"}),n.jsx("span",{className:"font-medium",children:S.name}),n.jsxs(oe,{variant:"outline",children:[S.estimated_duration_hours,"h"]})]}),n.jsx("p",{className:"text-sm text-muted-foreground",children:S.description}),n.jsx("div",{className:"flex flex-wrap gap-1",children:S.learning_outcomes.map((C,P)=>n.jsx(oe,{variant:"secondary",className:"text-xs",children:C},P))})]},_)),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(E,{variant:"outline",onClick:()=>a(1),children:"Back"}),n.jsxs(E,{onClick:b,disabled:j.isPending,children:[j.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Generate Content"]})]})]})]}),s===3&&m&&n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Generated Content"}),n.jsx($e,{children:"Review the detailed content before publishing."})]}),n.jsxs(U,{className:"space-y-4",children:[n.jsx("div",{className:"prose prose-sm max-w-none p-4 rounded-lg border bg-muted/30",dangerouslySetInnerHTML:{__html:m.content}}),m.exercises.length>0&&n.jsxs("div",{className:"space-y-2",children:[n.jsxs("h3",{className:"font-medium",children:["Exercises (",m.exercises.length,")"]}),m.exercises.map((S,_)=>n.jsxs("div",{className:"p-3 rounded border text-sm",children:[n.jsx("p",{className:"font-medium",children:S.question}),n.jsx("p",{className:"text-muted-foreground mt-1",children:S.answer}),n.jsx(oe,{variant:"outline",className:"mt-1 text-xs",children:S.type})]},_))]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(E,{variant:"outline",onClick:()=>a(2),children:"Back"}),n.jsxs(E,{onClick:N,disabled:v.isPending,children:[v.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Publish"]})]})]})]}),s===4&&n.jsx(W,{children:n.jsxs(U,{className:"py-12 text-center",children:[n.jsx(Un,{className:"h-12 w-12 text-green-500 mx-auto mb-3"}),n.jsx("h2",{className:"text-xl font-semibold",children:"Content Published!"}),n.jsx("p",{className:"text-muted-foreground mt-1",children:"The AI-generated content has been added to your course."}),n.jsx(E,{variant:"outline",className:"mt-4",onClick:()=>{a(1),h(null),y(null),o(""),c("")},children:"Generate More"})]})})]})}function rW({post:e,boardId:t,onPin:r,onResolve:s}){const[a,i]=p.useState(!1),[o,l]=p.useState(""),c=kb(),{toast:d}=He(),u=()=>{c.mutate({boardId:t,data:{board_id:t,parent_id:e.id,content:o}},{onSuccess:()=>{i(!1),l("")},onError:()=>d({title:"Error",description:"Failed to post reply",variant:"destructive"})})};return n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:`p-4 rounded-lg border ${e.is_pinned?"border-primary/30 bg-primary/5":""}`,children:[n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsxs("div",{className:"flex-1 min-w-0",children:[e.title&&n.jsx("p",{className:"font-medium",children:e.title}),n.jsx("p",{className:"text-sm mt-1",children:e.content}),n.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs text-muted-foreground",children:[n.jsx("span",{children:e.author_name}),n.jsx("span",{children:"·"}),n.jsx(oe,{variant:"outline",className:"text-xs",children:e.author_role}),n.jsx("span",{children:"·"}),n.jsx("span",{children:new Date(e.created_at).toLocaleDateString()}),e.is_pinned&&n.jsxs(oe,{variant:"secondary",className:"text-xs",children:[n.jsx(O1,{className:"h-3 w-3 mr-1"}),"Pinned"]}),e.is_resolved&&n.jsxs(oe,{variant:"default",className:"text-xs",children:[n.jsx(Un,{className:"h-3 w-3 mr-1"}),"Resolved"]})]})]}),n.jsxs("div",{className:"flex gap-1 shrink-0",children:[n.jsx(E,{variant:"ghost",size:"sm",onClick:()=>r(e.id,!e.is_pinned),children:n.jsx(O1,{className:"h-3 w-3"})}),!e.is_resolved&&n.jsx(E,{variant:"ghost",size:"sm",onClick:()=>s(e.id),children:n.jsx(Un,{className:"h-3 w-3"})}),n.jsx(E,{variant:"ghost",size:"sm",onClick:()=>i(!a),children:"Reply"})]})]}),a&&n.jsxs("div",{className:"flex gap-2 mt-3 pt-3 border-t",children:[n.jsx(G,{placeholder:"Write a reply...",value:o,onChange:f=>l(f.target.value),className:"flex-1"}),n.jsx(E,{size:"sm",onClick:u,disabled:c.isPending||!o,children:c.isPending?n.jsx(Re,{className:"h-4 w-4 animate-spin"}):n.jsx(gl,{className:"h-4 w-4"})})]})]}),e.replies&&e.replies.length>0&&n.jsx("div",{className:"ml-6 space-y-2",children:e.replies.map(f=>n.jsx(rW,{post:f,boardId:t,onPin:r,onResolve:s},f.id))})]})}function QLe(){const{toast:e}=He(),{data:t=[],isLoading:r}=PB(),[s,a]=p.useState(null),{data:i,isLoading:o}=AB(s??0),l=kb(),c=Nce(),d=Sce(),[u,f]=p.useState(!1),[h,m]=p.useState(""),[y,x]=p.useState(""),j=(i==null?void 0:i.results)??[],v=()=>{s&&l.mutate({boardId:s,data:{board_id:s,title:h,content:y}},{onSuccess:()=>{e({title:"Post Created"}),f(!1),m(""),x("")},onError:()=>e({title:"Error",description:"Failed to create post",variant:"destructive"})})},g=(N,w)=>{c.mutate({id:N,body:{pinned:w}},{onError:()=>e({title:"Error",description:"Failed to pin post",variant:"destructive"})})},b=N=>{d.mutate(N,{onError:()=>e({title:"Error",description:"Failed to resolve post",variant:"destructive"})})};return r?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Discussion Boards"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage and participate in course discussions."})]}),s?n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(E,{variant:"ghost",onClick:()=>a(null),children:[n.jsx(xd,{className:"mr-2 h-4 w-4"})," Back to Boards"]}),n.jsxs(Qe,{open:u,onOpenChange:f,children:[n.jsxs(E,{onClick:()=>f(!0),children:[n.jsx(fi,{className:"mr-2 h-4 w-4"})," New Post"]}),n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create Post"})}),n.jsxs("div",{className:"space-y-4 pt-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Title"}),n.jsx(G,{placeholder:"Post title",value:h,onChange:N=>m(N.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Content"}),n.jsx(on,{placeholder:"Write your post...",rows:4,value:y,onChange:N=>x(N.target.value)})]}),n.jsxs(E,{className:"w-full",onClick:v,disabled:l.isPending||!y,children:[l.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Post"]})]})]})]})]}),o?n.jsx("div",{className:"flex items-center justify-center min-h-[200px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-3",children:[j.map(N=>n.jsx(rW,{post:N,boardId:s,onPin:g,onResolve:b},N.id)),j.length===0&&n.jsx(W,{children:n.jsx(U,{className:"py-8 text-center text-muted-foreground",children:"No posts yet. Start the conversation!"})})]})]}):n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[t.map(N=>n.jsxs(W,{className:"cursor-pointer hover:shadow-md transition-shadow",onClick:()=>a(N.id),children:[n.jsx(se,{children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:n.jsx(fi,{className:"h-5 w-5 text-primary"})}),n.jsxs("div",{children:[n.jsx(ie,{className:"text-base",children:N.name}),n.jsx("p",{className:"text-xs text-muted-foreground",children:N.course_name})]})]})}),n.jsx(U,{children:n.jsxs("span",{className:"text-sm text-muted-foreground",children:[N.post_count," posts"]})})]},N.id)),t.length===0&&n.jsxs("div",{className:"col-span-full text-center py-12 text-muted-foreground",children:[n.jsx(fi,{className:"h-12 w-12 mx-auto mb-3 opacity-40"}),n.jsx("p",{children:"No discussion boards available."})]})]})]})}const YLe={urgent:"destructive",important:"default",normal:"secondary"};function XLe(){const{toast:e}=He(),{data:t=[],isLoading:r}=EB(),{data:s}=Er(),a=(s==null?void 0:s.results)??[],i=_ce(),o=Cce(),[l,c]=p.useState(!1),[d,u]=p.useState(""),[f,h]=p.useState(""),[m,y]=p.useState(""),[x,j]=p.useState("normal"),[v,g]=p.useState(!1),b=()=>{u(""),h(""),y(""),j("normal"),g(!1)},N=()=>{i.mutate({title:d,content:f,course_id:m?Number(m):void 0,priority:x,send_email:v},{onSuccess:()=>{e({title:"Announcement Created"}),c(!1),b()},onError:()=>e({title:"Error",description:"Failed to create announcement",variant:"destructive"})})},w=S=>{o.mutate(S,{onSuccess:()=>e({title:"Announcement Published"}),onError:()=>e({title:"Error",description:"Failed to publish announcement",variant:"destructive"})})};return r?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Announcements"}),n.jsx("p",{className:"text-muted-foreground",children:"Create and manage announcements for your courses."})]}),n.jsxs(Qe,{open:l,onOpenChange:c,children:[n.jsx(cr,{asChild:!0,children:n.jsxs(E,{children:[n.jsx(mt,{className:"mr-2 h-4 w-4"})," Create Announcement"]})}),n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"New Announcement"})}),n.jsxs("div",{className:"space-y-4 pt-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Title"}),n.jsx(G,{placeholder:"Announcement title",value:d,onChange:S=>u(S.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Content"}),n.jsx(on,{placeholder:"Write your announcement...",rows:4,value:f,onChange:S=>h(S.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Course"}),n.jsxs(Oe,{value:m,onValueChange:y,children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"All courses"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"all",children:"All Courses"}),a.map(S=>n.jsx(Y,{value:String(S.id),children:S.name},S.id))]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Priority"}),n.jsxs(Oe,{value:x,onValueChange:S=>j(S),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"normal",children:"Normal"}),n.jsx(Y,{value:"important",children:"Important"}),n.jsx(Y,{value:"urgent",children:"Urgent"})]})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(an,{id:"send-email",checked:v,onCheckedChange:S=>g(!!S)}),n.jsx(q,{htmlFor:"send-email",children:"Send email notification"})]}),n.jsxs(E,{className:"w-full",onClick:N,disabled:i.isPending||!d||!f,children:[i.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Create"]})]})]})]})]}),n.jsxs("div",{className:"space-y-3",children:[t.map(S=>n.jsx(W,{children:n.jsxs(U,{className:"flex items-center gap-4 py-4",children:[n.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:n.jsx(Bh,{className:"h-5 w-5 text-primary"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"font-medium truncate",children:S.title}),n.jsx(oe,{variant:YLe[S.priority],children:S.priority}),S.is_published&&n.jsx(oe,{variant:"outline",children:"Published"})]}),n.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1 mt-0.5",children:S.content}),n.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground",children:[S.course_name&&n.jsx("span",{children:S.course_name}),S.published_at&&n.jsxs("span",{children:["· ",new Date(S.published_at).toLocaleDateString()]})]})]}),!S.is_published&&n.jsxs(E,{size:"sm",onClick:()=>w(S.id),disabled:o.isPending,children:[o.isPending?n.jsx(Re,{className:"h-4 w-4 animate-spin"}):n.jsx(gl,{className:"mr-2 h-4 w-4"}),"Publish"]})]})},S.id)),t.length===0&&n.jsx(W,{children:n.jsxs(U,{className:"py-12 text-center text-muted-foreground",children:[n.jsx(Bh,{className:"h-12 w-12 mx-auto mb-3 opacity-40"}),n.jsx("p",{children:"No announcements yet."})]})})]})]})}const ZLe={pdf:n.jsx(Yn,{className:"h-5 w-5"}),document:n.jsx(Yn,{className:"h-5 w-5"}),video:n.jsx(Ll,{className:"h-5 w-5"}),audio:n.jsx(UL,{className:"h-5 w-5"}),image:n.jsx(VL,{className:"h-5 w-5"}),link:n.jsx(kj,{className:"h-5 w-5"}),article:n.jsx(Yn,{className:"h-5 w-5"})};function JLe(){const{courseId:e,chapterId:t}=Ht(),r=Number(t),{toast:s}=He(),{data:a,isLoading:i}=CB(r),{data:o=[],isLoading:l}=kB(r),{data:c,isLoading:d}=lce(r),u=xce(),f=pce(),h=c?Math.round(c.materials_completed/Math.max(c.materials_total,1)*100):0,m=async(j,v)=>{try{const g=await Ar.downloadMaterial(j),b=URL.createObjectURL(g),N=document.createElement("a");N.href=b,N.download=v,N.click(),URL.revokeObjectURL(b)}catch{s({title:"Error",description:"Download failed",variant:"destructive"})}},y=()=>{u.mutate(r,{onSuccess:()=>s({title:"Chapter Completed!"}),onError:()=>s({title:"Error",description:"Failed to mark complete",variant:"destructive"})})},x=j=>{f.mutate({id:j,chapterId:r})};return i||l||d?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[a&&n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:a.name}),a.description&&n.jsx("p",{className:"text-muted-foreground mt-1",children:a.description})]}),c&&n.jsx(W,{children:n.jsxs(U,{className:"py-4",children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("span",{className:"text-sm font-medium",children:"Progress"}),n.jsxs("span",{className:"text-sm text-muted-foreground",children:[c.materials_completed," / ",c.materials_total," materials"]})]}),n.jsx(kn,{value:h,className:"h-2"}),n.jsxs("div",{className:"flex justify-between items-center mt-3",children:[n.jsxs("span",{className:"text-sm text-muted-foreground",children:[h,"% complete"]}),c.status!=="completed"&&n.jsxs(E,{size:"sm",onClick:y,disabled:u.isPending,children:[u.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),n.jsx(Un,{className:"mr-2 h-4 w-4"})," Mark Complete"]}),c.status==="completed"&&n.jsxs(oe,{variant:"default",children:[n.jsx(Un,{className:"mr-1 h-3 w-3"})," Completed"]})]})]})}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[o.sort((j,v)=>j.sequence-v.sequence).map(j=>n.jsx(W,{className:"hover:shadow-md transition-shadow cursor-pointer",onClick:()=>x(j.id),children:n.jsx(U,{className:"py-4",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0 text-primary",children:ZLe[j.type]}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"font-medium text-sm truncate",children:j.name}),n.jsx(oe,{variant:"outline",className:"mt-1 text-xs",children:j.type})]}),j.allow_download&&n.jsx(E,{variant:"ghost",size:"icon",className:"shrink-0",onClick:v=>{v.stopPropagation(),m(j.id,j.name)},children:n.jsx(yd,{className:"h-4 w-4"})})]})})},j.id)),o.length===0&&n.jsxs("div",{className:"col-span-full text-center py-12 text-muted-foreground",children:[n.jsx(Yn,{className:"h-12 w-12 mx-auto mb-3 opacity-40"}),n.jsx("p",{children:"No materials available in this chapter."})]})]})]})}function sW({post:e,boardId:t}){const[r,s]=p.useState(!1),[a,i]=p.useState(""),o=kb(),{toast:l}=He(),c=()=>{o.mutate({boardId:t,data:{board_id:t,parent_id:e.id,content:a}},{onSuccess:()=>{s(!1),i("")},onError:()=>l({title:"Error",description:"Failed to reply",variant:"destructive"})})};return n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:`p-4 rounded-lg border ${e.is_pinned?"border-primary/30 bg-primary/5":""}`,children:[n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsxs("div",{className:"flex-1 min-w-0",children:[e.title&&n.jsx("p",{className:"font-medium",children:e.title}),n.jsx("p",{className:"text-sm mt-1",children:e.content}),n.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs text-muted-foreground",children:[n.jsx("span",{children:e.author_name}),n.jsx("span",{children:"·"}),n.jsx(oe,{variant:"outline",className:"text-xs",children:e.author_role}),n.jsx("span",{children:"·"}),n.jsx("span",{children:new Date(e.created_at).toLocaleDateString()}),e.is_pinned&&n.jsxs(oe,{variant:"secondary",className:"text-xs",children:[n.jsx(O1,{className:"h-3 w-3 mr-1"}),"Pinned"]}),e.is_resolved&&n.jsxs(oe,{variant:"default",className:"text-xs",children:[n.jsx(Un,{className:"h-3 w-3 mr-1"}),"Resolved"]})]})]}),n.jsx(E,{variant:"ghost",size:"sm",onClick:()=>s(!r),children:"Reply"})]}),r&&n.jsxs("div",{className:"flex gap-2 mt-3 pt-3 border-t",children:[n.jsx(G,{placeholder:"Write a reply...",value:a,onChange:d=>i(d.target.value),className:"flex-1"}),n.jsx(E,{size:"sm",onClick:c,disabled:o.isPending||!a,children:o.isPending?n.jsx(Re,{className:"h-4 w-4 animate-spin"}):n.jsx(gl,{className:"h-4 w-4"})})]})]}),e.replies&&e.replies.length>0&&n.jsx("div",{className:"ml-6 space-y-2",children:e.replies.map(d=>n.jsx(sW,{post:d,boardId:t},d.id))})]})}function e3e(){const{toast:e}=He(),{data:t=[],isLoading:r}=PB(),[s,a]=p.useState(null),{data:i,isLoading:o}=AB(s??0),l=kb(),[c,d]=p.useState(!1),[u,f]=p.useState(""),[h,m]=p.useState(""),y=(i==null?void 0:i.results)??[],x=()=>{s&&l.mutate({boardId:s,data:{board_id:s,title:u,content:h}},{onSuccess:()=>{e({title:"Post Created"}),d(!1),f(""),m("")},onError:()=>e({title:"Error",description:"Failed to create post",variant:"destructive"})})};return r?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Discussion Boards"}),n.jsx("p",{className:"text-muted-foreground",children:"Participate in course discussions with your classmates."})]}),s?n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(E,{variant:"ghost",onClick:()=>a(null),children:[n.jsx(xd,{className:"mr-2 h-4 w-4"})," Back to Boards"]}),n.jsxs(Qe,{open:c,onOpenChange:d,children:[n.jsxs(E,{onClick:()=>d(!0),children:[n.jsx(fi,{className:"mr-2 h-4 w-4"})," New Post"]}),n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create Post"})}),n.jsxs("div",{className:"space-y-4 pt-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Title"}),n.jsx(G,{placeholder:"Post title",value:u,onChange:j=>f(j.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Content"}),n.jsx(on,{placeholder:"Write your post...",rows:4,value:h,onChange:j=>m(j.target.value)})]}),n.jsxs(E,{className:"w-full",onClick:x,disabled:l.isPending||!h,children:[l.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Post"]})]})]})]})]}),o?n.jsx("div",{className:"flex items-center justify-center min-h-[200px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-3",children:[y.map(j=>n.jsx(sW,{post:j,boardId:s},j.id)),y.length===0&&n.jsx(W,{children:n.jsx(U,{className:"py-8 text-center text-muted-foreground",children:"No posts yet. Start the conversation!"})})]})]}):n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[t.map(j=>n.jsxs(W,{className:"cursor-pointer hover:shadow-md transition-shadow",onClick:()=>a(j.id),children:[n.jsx(se,{children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:n.jsx(fi,{className:"h-5 w-5 text-primary"})}),n.jsxs("div",{children:[n.jsx(ie,{className:"text-base",children:j.name}),n.jsx("p",{className:"text-xs text-muted-foreground",children:j.course_name})]})]})}),n.jsx(U,{children:n.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[n.jsxs("span",{children:[j.post_count," posts"]}),n.jsx(as,{className:"h-4 w-4"})]})})]},j.id)),t.length===0&&n.jsxs("div",{className:"col-span-full text-center py-12 text-muted-foreground",children:[n.jsx(fi,{className:"h-12 w-12 mx-auto mb-3 opacity-40"}),n.jsx("p",{children:"No discussion boards available for your courses."})]})]})]})}const t3e={urgent:{variant:"destructive",icon:n.jsx(Pl,{className:"h-4 w-4"})},important:{variant:"default",icon:n.jsx(Nv,{className:"h-4 w-4"})},normal:{variant:"secondary",icon:n.jsx(fk,{className:"h-4 w-4"})}};function n3e(){const{data:e=[],isLoading:t}=EB(),r=[...e].filter(s=>s.is_published).sort((s,a)=>new Date(a.published_at??a.expires_at??"").getTime()-new Date(s.published_at??s.expires_at??"").getTime());return t?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Announcements"}),n.jsx("p",{className:"text-muted-foreground",children:"Stay up to date with the latest announcements from your courses."})]}),n.jsxs("div",{className:"space-y-3",children:[r.map(s=>{const a=t3e[s.priority];return n.jsx(W,{className:s.priority==="urgent"?"border-destructive/30":"",children:n.jsxs(U,{className:"flex items-start gap-4 py-4",children:[n.jsx("div",{className:`h-10 w-10 rounded-lg flex items-center justify-center shrink-0 ${s.priority==="urgent"?"bg-destructive/10 text-destructive":s.priority==="important"?"bg-yellow-500/10 text-yellow-600":"bg-primary/10 text-primary"}`,children:a.icon}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx("span",{className:"font-medium",children:s.title}),n.jsx(oe,{variant:a.variant,children:s.priority})]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.content}),n.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs text-muted-foreground",children:[n.jsx("span",{children:s.author_name}),s.course_name&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsx("span",{children:s.course_name})]}),s.published_at&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsx("span",{children:new Date(s.published_at).toLocaleDateString()})]})]})]})]})},s.id)}),r.length===0&&n.jsx(W,{children:n.jsxs(U,{className:"py-12 text-center text-muted-foreground",children:[n.jsx(Bh,{className:"h-12 w-12 mx-auto mb-3 opacity-40"}),n.jsx("p",{children:"No announcements right now."})]})})]})]})}function r3e(){const{toast:e}=He(),t=je(),{data:r,isLoading:s}=jce(),{data:a,isLoading:i}=bce(),{data:o}=wce(),l=kce(),c=(r==null?void 0:r.results)??[],d=(a==null?void 0:a.results)??[],u=(o==null?void 0:o.count)??0,[f,h]=p.useState(!1),[m,y]=p.useState(""),[x,j]=p.useState(""),[v,g]=p.useState(""),[b,N]=p.useState(null),[w,S]=p.useState(!1),_=ae({mutationFn:D=>Ws.getMessage(D),onSuccess:()=>{t.invalidateQueries({queryKey:["messages"]}),t.invalidateQueries({queryKey:["messages","unread-count"]})}}),C=D=>{N(D),S(!0),D.is_read||_.mutate(D.id)},P=()=>{l.mutate({recipient_id:Number(m),subject:x,content:v},{onSuccess:()=>{e({title:"Message Sent"}),h(!1),y(""),j(""),g("")},onError:()=>e({title:"Error",description:"Failed to send message",variant:"destructive"})})};return s||i?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Messages"}),n.jsx("p",{className:"text-muted-foreground",children:"Communicate with your classmates and teachers."})]}),n.jsxs(E,{onClick:()=>h(!0),children:[n.jsx(HL,{className:"mr-2 h-4 w-4"})," New Message"]})]}),n.jsxs(Us,{defaultValue:"inbox",children:[n.jsxs(ws,{children:[n.jsxs(Et,{value:"inbox",className:"gap-2",children:[n.jsx(VG,{className:"h-4 w-4"})," Inbox",u>0&&n.jsx(oe,{variant:"destructive",className:"ml-1 text-xs px-1.5",children:u})]}),n.jsxs(Et,{value:"sent",className:"gap-2",children:[n.jsx(gl,{className:"h-4 w-4"})," Sent"]})]}),n.jsxs(Lt,{value:"inbox",className:"space-y-2 mt-4",children:[c.map(D=>n.jsx(W,{className:`cursor-pointer hover:shadow-sm transition-shadow ${D.is_read?"":"border-primary/30 bg-primary/5"}`,onClick:()=>C(D),children:n.jsxs(U,{className:"flex items-center gap-4 py-3",children:[n.jsx(WL,{className:`h-5 w-5 shrink-0 ${D.is_read?"text-muted-foreground":"text-primary"}`}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:`text-sm truncate ${D.is_read?"":"font-semibold"}`,children:D.subject}),!D.is_read&&n.jsx(oe,{variant:"default",className:"text-xs",children:"New"})]}),n.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["From: ",D.sender_name]})]}),n.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:new Date(D.created_at).toLocaleDateString()})]})},D.id)),c.length===0&&n.jsx(W,{children:n.jsx(U,{className:"py-8 text-center text-muted-foreground",children:"Your inbox is empty."})})]}),n.jsxs(Lt,{value:"sent",className:"space-y-2 mt-4",children:[d.map(D=>n.jsx(W,{className:"cursor-pointer hover:shadow-sm transition-shadow",onClick:()=>C(D),children:n.jsxs(U,{className:"flex items-center gap-4 py-3",children:[n.jsx(gl,{className:"h-5 w-5 shrink-0 text-muted-foreground"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("span",{className:"text-sm truncate",children:D.subject}),n.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["To: ",D.recipient_name]})]}),n.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:new Date(D.created_at).toLocaleDateString()})]})},D.id)),d.length===0&&n.jsx(W,{children:n.jsx(U,{className:"py-8 text-center text-muted-foreground",children:"No sent messages."})})]})]}),n.jsx(Jj,{open:w,onOpenChange:S,children:n.jsx(rx,{className:"sm:max-w-lg",children:b&&n.jsxs(n.Fragment,{children:[n.jsx(eb,{children:n.jsx(tb,{children:b.subject})}),n.jsxs("div",{className:"space-y-4 mt-4",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[n.jsxs("span",{children:["From: ",b.sender_name]}),n.jsx("span",{children:"·"}),n.jsxs("span",{children:["To: ",b.recipient_name]})]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(b.created_at).toLocaleString()}),n.jsx("div",{className:"p-4 rounded-lg border bg-muted/30 text-sm whitespace-pre-wrap",children:b.content})]})]})})}),n.jsx(Qe,{open:f,onOpenChange:h,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"New Message"})}),n.jsxs("div",{className:"space-y-4 pt-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Recipient ID"}),n.jsx(G,{type:"number",placeholder:"Enter recipient user ID",value:m,onChange:D=>y(D.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Subject"}),n.jsx(G,{placeholder:"Message subject",value:x,onChange:D=>j(D.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Content"}),n.jsx(on,{placeholder:"Write your message...",rows:4,value:v,onChange:D=>g(D.target.value)})]}),n.jsxs(E,{className:"w-full",onClick:P,disabled:l.isPending||!m||!x||!v,children:[l.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),n.jsx(gl,{className:"mr-2 h-4 w-4"})," Send"]})]})]})})]})}function s3e(){var d;const{data:e=[],isLoading:t}=FB(),{data:r,isLoading:s}=ye({queryKey:["analytics","student","journey"],queryFn:()=>Ol.getStudentAnalytics()}),{data:a,isLoading:i}=ye({queryKey:["adaptive","plan","all"],queryFn:()=>Ql.getLearningPlan({})}),o=r,l=((d=o==null?void 0:o.recent_activity)==null?void 0:d.slice(0,10))??[];if(t||s||i)return n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const c={exam:n.jsx(gd,{className:"h-4 w-4"}),assignment:n.jsx(Yn,{className:"h-4 w-4"}),chapter:n.jsx(Kt,{className:"h-4 w-4"})};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"My Learning Journey"}),n.jsx("p",{className:"text-muted-foreground",children:"Track your progress and proficiency across all subjects."})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.map(u=>{const f=Math.round(u.overall_mastery??0);return n.jsxs(W,{className:"hover:shadow-md transition-shadow",children:[n.jsx(se,{className:"pb-3",children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:n.jsx(Kt,{className:"h-5 w-5 text-primary"})}),n.jsxs("div",{children:[n.jsx(ie,{className:"text-base",children:u.subject_name??`Subject ${u.subject_id}`}),n.jsxs($e,{children:[u.topics_mastered??0," / ",u.topics_total??0," topics mastered"]})]})]})}),n.jsxs(U,{className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Overall Mastery"}),n.jsxs("span",{className:"font-medium",children:[f,"%"]})]}),n.jsx(kn,{value:f,className:"h-2"})]}),n.jsx(oe,{variant:f>=80?"default":f>=50?"secondary":"outline",children:f>=80?"Proficient":f>=50?"Developing":"Beginner"})]})]},u.subject_id)}),e.length===0&&n.jsxs("div",{className:"col-span-full text-center py-12 text-muted-foreground",children:[n.jsx(Dl,{className:"h-12 w-12 mx-auto mb-3 opacity-40"}),n.jsx("p",{children:"Take a diagnostic assessment to start tracking your journey."})]})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Sj,{className:"h-5 w-5 text-primary"}),n.jsx(ie,{children:"Recent Activity"})]}),n.jsx($e,{children:"Your last 10 actions across all courses."})]}),n.jsx(U,{children:l.length>0?n.jsx("div",{className:"space-y-3",children:l.map((u,f)=>n.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border",children:[n.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center text-primary shrink-0",children:c[u.action]??n.jsx(Un,{className:"h-4 w-4"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-sm font-medium",children:u.description}),n.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(u.date).toLocaleDateString()})]}),n.jsx(oe,{variant:"outline",className:"text-xs shrink-0",children:u.action})]},f))}):n.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No recent activity to show."})})]})]})}const a3e=[{name:"Profile Analysis",status:"complete"},{name:"Reading Content",status:"in_progress"},{name:"Grammar Exercises",status:"pending"},{name:"Speaking Prompts",status:"pending"},{name:"Vocabulary Sets",status:"pending"}],N$=["hsl(var(--primary))","hsl(var(--chart-2))","hsl(var(--chart-3))"];function i3e(){var N,w;const{courseId:e}=Ht(),t=Number(e),r=je(),{data:s,isLoading:a}=WB(Number.isFinite(t)?t:void 0),{data:i}=UB(Number.isFinite(t)?t:void 0),o=nue(),[l,c]=p.useState(""),[d,u]=p.useState(""),[f,h]=p.useState(!1),m=(N=s==null?void 0:s.generation_steps)!=null&&N.length?s.generation_steps:a3e,y=p.useMemo(()=>{const S=m.filter(_=>_.status==="complete").length;return Math.round(S/Math.max(m.length,1)*100)},[m]),x=p.useMemo(()=>i!=null&&i.length?i:[{name:"Grammar Track",progress_percent:40,modules:_N("grammar")},{name:"Skills Track",progress_percent:55,modules:_N("skills")},{name:"Vocabulary Track",progress_percent:20,modules:_N("vocab")}],[i]),j=[{label:"Start",value:3.2},{label:"Now",value:4.1},{label:"Target",value:5}],v=x.map(S=>({name:S.name.replace(" Track",""),hours:S.progress_percent/10}));if(a)return n.jsx("div",{className:"flex items-center justify-center min-h-[320px] text-muted-foreground",children:"Loading course…"});const g=d||((w=s==null?void 0:s.learning_style)==null?void 0:w.join(", "))||"visual, mixed",b=l||(s==null?void 0:s.target_level)||"B2";return n.jsxs("div",{className:"space-y-8 p-6 max-w-7xl mx-auto",children:[n.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-end md:justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"AI English course"}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Personalized pathway to your target level"})]}),n.jsxs(E,{onClick:()=>h(!0),variant:"secondary",size:"sm",className:"gap-2",children:[n.jsx(lt,{className:"h-4 w-4"}),"Preview celebration"]})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Profile confirmation"}),n.jsx($e,{children:"Adjust targets before continuing."})]}),n.jsxs(U,{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[n.jsxs("div",{children:[n.jsx(q,{className:"text-muted-foreground",children:"Current CEFR"}),n.jsx("p",{className:"text-lg font-semibold mt-1",children:(s==null?void 0:s.current_level)??"B1"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"target",children:"Target CEFR"}),n.jsx(G,{id:"target",value:b,onChange:S=>c(S.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"style",children:"Learning style"}),n.jsx(G,{id:"style",value:g,onChange:S=>u(S.target.value)})]}),n.jsxs("div",{children:[n.jsx(q,{className:"text-muted-foreground",children:"Duration (weeks)"}),n.jsx("p",{className:"text-lg font-semibold mt-1",children:(s==null?void 0:s.estimated_duration_weeks)??8})]})]}),n.jsx(U,{className:"pt-0",children:n.jsx(E,{disabled:o.isPending,onClick:()=>{s&&(g.split(",").map(S=>S.trim()).filter(Boolean).length>0?g.split(",").map(S=>S.trim()).filter(Boolean):s==null||s.learning_style,o.mutate({cefr_level:b},{onSuccess:()=>{r.invalidateQueries({queryKey:de.aiCourse.course(t)}),r.invalidateQueries({queryKey:de.aiCourse.tracks(t)}),ct.success("AI course started.")},onError:S=>ct.error(S instanceof Error?S.message:"Could not start")}))},children:"Start AI Course"})})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Generation progress"}),n.jsx($e,{children:"Content pipeline for this course"})]}),n.jsxs(U,{className:"space-y-4",children:[n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{children:"Overall"}),n.jsxs("span",{children:[y,"%"]})]}),n.jsx(kn,{value:y}),n.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-5",children:m.map(S=>n.jsxs("div",{className:"rounded-lg border p-3 text-sm",children:[n.jsx("div",{className:"font-medium leading-tight",children:S.name}),n.jsx("div",{className:"text-muted-foreground capitalize mt-1",children:S.status.replace("_"," ")})]},S.name))})]})]}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Learning tracks"}),n.jsx("div",{className:"grid gap-4 lg:grid-cols-3",children:x.map(S=>n.jsxs(W,{children:[n.jsxs(se,{className:"pb-2",children:[n.jsxs(ie,{className:"text-base flex items-center gap-2",children:[n.jsx(Kt,{className:"h-4 w-4"}),S.name]}),n.jsxs($e,{children:[S.progress_percent,"% complete"]})]}),n.jsxs(U,{className:"space-y-2",children:[n.jsx(kn,{value:S.progress_percent}),n.jsx(qs,{className:"my-2"}),n.jsx("ul",{className:"space-y-2",children:S.modules.map(_=>n.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[n.jsx(o3e,{status:_.status}),n.jsxs("div",{children:[n.jsx("div",{className:"font-medium",children:_.title}),n.jsxs("div",{className:"text-xs text-muted-foreground",children:["~",_.estimated_hours,"h"]})]})]},_.id))})]})]},S.name))})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Progress report"}),n.jsx($e,{children:"CEFR trajectory and effort"})]}),n.jsxs(U,{className:"grid gap-8 lg:grid-cols-2",children:[n.jsxs("div",{className:"h-64",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium mb-2",children:[n.jsx(Dl,{className:"h-4 w-4"}),"CEFR gain"]}),n.jsx(Xn,{width:"100%",height:"100%",children:n.jsxs(vo,{data:j,children:[n.jsx(bs,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(kr,{dataKey:"label"}),n.jsx(Pr,{domain:[0,6]}),n.jsx(fn,{}),n.jsx(_r,{dataKey:"value",fill:"hsl(var(--primary))",radius:[4,4,0,0]})]})})]}),n.jsxs("div",{className:"h-64",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium mb-2",children:[n.jsx(vd,{className:"h-4 w-4"}),"Time per track (relative)"]}),n.jsx(Xn,{width:"100%",height:"100%",children:n.jsxs(_0,{children:[n.jsx(pa,{data:v,dataKey:"hours",nameKey:"name",cx:"50%",cy:"50%",outerRadius:80,children:v.map((S,_)=>n.jsx(_d,{fill:N$[_%N$.length]},_))}),n.jsx(fn,{})]})})]}),n.jsxs("div",{className:"lg:col-span-2 flex items-center gap-2 text-sm text-muted-foreground",children:[n.jsx(XG,{className:"h-4 w-4"}),"Completion rates follow each track's module checklist above."]})]})]}),n.jsx(Qe,{open:f,onOpenChange:h,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsxs(Ge,{className:"flex items-center gap-2",children:[n.jsx(lt,{className:"h-5 w-5 text-amber-500"}),"Level up!"]})}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:["You reached ",n.jsx("strong",{children:(s==null?void 0:s.target_level)??b}),". The next modules unlock with richer tasks and feedback."]}),n.jsx(Ct,{children:n.jsx(E,{onClick:()=>h(!1),children:"Continue"})})]})})]})}function o3e({status:e}){return e==="completed"?n.jsx(Un,{className:"h-4 w-4 text-green-600 shrink-0 mt-0.5"}):e==="in_progress"?n.jsx(FL,{className:"h-4 w-4 text-primary shrink-0 mt-0.5"}):n.jsx(zf,{className:"h-4 w-4 text-muted-foreground shrink-0 mt-0.5"})}function _N(e){return[{id:1,title:`${e} — Foundations`,status:"completed",estimated_hours:2},{id:2,title:`${e} — Practice set`,status:"in_progress",estimated_hours:3},{id:3,title:`${e} — Mastery`,status:"locked",estimated_hours:4}]}const S$=[hk,$L,Pj,Cj];function l3e(){var v,g,b,N,w;const{courseId:e}=Ht(),t=Number(e),r=je(),{data:s,isLoading:a}=WB(Number.isFinite(t)?t:void 0),{data:i}=UB(Number.isFinite(t)?t:void 0),o=rue(),[l,c]=p.useState(""),[d,u]=p.useState(!1),f=s!=null&&s.skills_ranked_by_gap&&s.skills_ranked_by_gap.length>0?s.skills_ranked_by_gap:[{skill:"Writing",gap:1.2},{skill:"Speaking",gap:.9},{skill:"Reading",gap:.4},{skill:"Listening",gap:.3}],h=(s==null?void 0:s.weak_question_types)??{Writing:["Task 2 argument depth"],Reading:["True/False/Not Given"],Speaking:["Part 2 long turn"],Listening:["Form completion"]},m=(v=s==null?void 0:s.ielts_generation_by_skill)!=null&&v.length?s.ielts_generation_by_skill:["Writing","Reading","Speaking","Listening"].map((S,_)=>({skill:S,steps:[{name:"Blueprint",status:_===0?"in_progress":"pending"},{name:"Items",status:"pending"},{name:"Rubric alignment",status:"pending"}],progress_percent:[35,20,10,5][_]??0})),y=p.useMemo(()=>i!=null&&i.length?i:["Writing","Reading","Speaking","Listening"].map((S,_)=>({name:`${S} skill`,progress_percent:15+_*8,modules:d3e(S)})),[i]),x=[{label:"L",v:((g=s==null?void 0:s.current_bands)==null?void 0:g.Listening)??6},{label:"R",v:((b=s==null?void 0:s.current_bands)==null?void 0:b.Reading)??6.5},{label:"W",v:((N=s==null?void 0:s.current_bands)==null?void 0:N.Writing)??5.5},{label:"S",v:((w=s==null?void 0:s.current_bands)==null?void 0:w.Speaking)??6}];if(a)return n.jsx("div",{className:"flex justify-center py-24 text-muted-foreground",children:"Loading…"});const j=l||String((s==null?void 0:s.target_level)??"6.5");return n.jsxs("div",{className:"space-y-8 p-6 max-w-7xl mx-auto",children:[n.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"AI IELTS course"}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Band-focused practice generated for you"})]}),n.jsxs(E,{variant:"secondary",size:"sm",onClick:()=>u(!0),children:[n.jsx(MG,{className:"h-4 w-4 mr-2"}),"Practice exam readiness"]})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"IELTS gap profile"}),n.jsx($e,{children:"Exam context and targets"})]}),n.jsxs(U,{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[n.jsxs("div",{children:[n.jsx(q,{className:"text-muted-foreground",children:"Exam type"}),n.jsx("p",{className:"text-lg font-semibold mt-1",children:(s==null?void 0:s.exam_type)??"Academic"})]}),n.jsxs("div",{children:[n.jsx(q,{className:"text-muted-foreground",children:"Current bands"}),n.jsx("p",{className:"text-sm mt-1",children:Object.entries((s==null?void 0:s.current_bands)??{L:6,R:6.5,W:5.5,S:6}).map(([S,_])=>`${S}: ${_}`).join(" · ")})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"tgt",children:"Target band"}),n.jsx(G,{id:"tgt",value:j,onChange:S=>c(S.target.value)})]}),n.jsxs("div",{children:[n.jsx(q,{className:"text-muted-foreground",children:"Ranked by gap"}),n.jsx("ol",{className:"mt-2 text-sm list-decimal list-inside space-y-1",children:f.map(S=>n.jsxs("li",{children:[S.skill," (Δ ",S.gap.toFixed(1),")"]},S.skill))})]})]}),n.jsxs(U,{className:"pt-0 space-y-3",children:[n.jsx(q,{className:"text-muted-foreground",children:"Weak question types"}),n.jsx("div",{className:"grid sm:grid-cols-2 gap-3 text-sm",children:Object.entries(h).map(([S,_])=>n.jsxs("div",{className:"rounded-md border p-3",children:[n.jsx("div",{className:"font-medium mb-1",children:S}),n.jsx("ul",{className:"list-disc list-inside text-muted-foreground",children:_.map(C=>n.jsx("li",{children:C},C))})]},S))}),n.jsx(E,{disabled:o.isPending,onClick:()=>{var _;const S=Number(l||(s==null?void 0:s.target_level)||7);o.mutate({skill:((_=f[0])==null?void 0:_.skill)??"writing",target_band:Number.isFinite(S)?S:7},{onSuccess:()=>{r.invalidateQueries({queryKey:de.aiCourse.course(t)}),r.invalidateQueries({queryKey:de.aiCourse.tracks(t)}),ct.success("AI IELTS course started.")},onError:C=>ct.error(C instanceof Error?C.message:"Could not start")})},children:"Start AI IELTS Course"})]})]}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Per-skill generation"}),n.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:m.map((S,_)=>{const C=S$[_%S$.length];return n.jsxs(W,{children:[n.jsxs(se,{className:"pb-2",children:[n.jsxs(ie,{className:"text-base flex items-center gap-2",children:[n.jsx(C,{className:"h-4 w-4"}),S.skill]}),n.jsxs($e,{children:[S.progress_percent,"%"]})]}),n.jsxs(U,{className:"space-y-2",children:[n.jsx(kn,{value:S.progress_percent}),n.jsx("ul",{className:"text-sm space-y-1",children:S.steps.map(P=>n.jsxs("li",{className:"flex justify-between gap-2",children:[n.jsx("span",{children:P.name}),n.jsx("span",{className:"text-muted-foreground capitalize",children:P.status.replace("_"," ")})]},P.name))})]})]},S.skill)})})]}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Skill columns"}),n.jsx("div",{className:"grid gap-4 lg:grid-cols-4",children:y.map(S=>n.jsxs(W,{children:[n.jsxs(se,{className:"pb-2",children:[n.jsx(ie,{className:"text-sm",children:S.name}),n.jsxs($e,{children:[S.progress_percent,"%"]})]}),n.jsxs(U,{className:"space-y-2",children:[n.jsx(kn,{value:S.progress_percent}),n.jsx(qs,{}),n.jsx("ul",{className:"space-y-2 text-sm",children:S.modules.map(_=>n.jsxs("li",{className:"flex gap-2",children:[n.jsx(c3e,{st:_.status}),n.jsx("span",{children:_.title})]},_.id))})]})]},S.name))})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsxs(ie,{className:"flex items-center gap-2",children:[n.jsx(ik,{className:"h-5 w-5"}),"Band improvement report"]}),n.jsx($e,{children:"Current skill snapshot vs trajectory"})]}),n.jsxs(U,{className:"grid gap-8 lg:grid-cols-2",children:[n.jsx("div",{className:"h-56",children:n.jsx(Xn,{width:"100%",height:"100%",children:n.jsxs(vo,{data:x,children:[n.jsx(bs,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(kr,{dataKey:"label"}),n.jsx(Pr,{domain:[0,9]}),n.jsx(fn,{}),n.jsx(_r,{dataKey:"v",fill:"hsl(var(--primary))",radius:[4,4,0,0]})]})})}),n.jsx("div",{className:"h-56",children:n.jsx(Xn,{width:"100%",height:"100%",children:n.jsxs(Px,{data:[{w:1,b:5.6},{w:2,b:6.1},{w:3,b:6.4},{w:4,b:6.8}],children:[n.jsx(bs,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(kr,{dataKey:"w"}),n.jsx(Pr,{domain:[5,8]}),n.jsx(fn,{}),n.jsx(Ao,{type:"monotone",dataKey:"b",stroke:"hsl(var(--primary))",strokeWidth:2,dot:!0})]})})})]})]}),n.jsx(Qe,{open:d,onOpenChange:u,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Practice exam readiness"})}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"When each skill column reaches the practice threshold, you unlock a full timed paper with authentic pacing and AI feedback."}),n.jsx(Ct,{children:n.jsx(E,{onClick:()=>u(!1),children:"Got it"})})]})})]})}function c3e({st:e}){return e==="completed"?n.jsx(Un,{className:"h-4 w-4 text-green-600 shrink-0"}):e==="in_progress"?n.jsx(FL,{className:"h-4 w-4 text-primary shrink-0"}):n.jsx(zf,{className:"h-4 w-4 text-muted-foreground shrink-0"})}function d3e(e){return[{id:1,title:`${e} — Drill set A`,status:"completed",estimated_hours:2},{id:2,title:`${e} — Drill set B`,status:"in_progress",estimated_hours:2},{id:3,title:`${e} — Exam-style pack`,status:"locked",estimated_hours:3}]}const C0={getSession:e=>R.get(`/exam/${e}/session`),autoSave:(e,t)=>R.post(`/exam/${e}/autosave`,t),submit:(e,t)=>R.post(`/exam/${e}/submit`,t),getStatus:e=>R.get(`/exam/${e}/status`)};function u3e(e){return ye({queryKey:de.examSession.session(e),queryFn:()=>C0.getSession(e),enabled:!!e})}function f3e(e,t){return ye({queryKey:de.examSession.status(e),queryFn:()=>C0.getStatus(e),enabled:!!e&&t,refetchInterval:1e4})}function m3e(){return ae({mutationFn:e=>C0.autoSave(e.examId,e.payload)})}function h3e(){return ae({mutationFn:e=>C0.submit(e.examId,{attempt_id:e.attempt_id,answers:e.answers})})}function p3e(e,t){return p.useReducer((r,s)=>t[r][s]??r,e)}var YP="ScrollArea",[aW]=lr(YP),[x3e,xa]=aW(YP),iW=p.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:s="hover",dir:a,scrollHideDelay:i=600,...o}=e,[l,c]=p.useState(null),[d,u]=p.useState(null),[f,h]=p.useState(null),[m,y]=p.useState(null),[x,j]=p.useState(null),[v,g]=p.useState(0),[b,N]=p.useState(0),[w,S]=p.useState(!1),[_,C]=p.useState(!1),P=dt(t,z=>c(z)),D=zl(a);return n.jsx(x3e,{scope:r,type:s,dir:D,scrollHideDelay:i,scrollArea:l,viewport:d,onViewportChange:u,content:f,onContentChange:h,scrollbarX:m,onScrollbarXChange:y,scrollbarXEnabled:w,onScrollbarXEnabledChange:S,scrollbarY:x,onScrollbarYChange:j,scrollbarYEnabled:_,onScrollbarYEnabledChange:C,onCornerWidthChange:g,onCornerHeightChange:N,children:n.jsx(We.div,{dir:D,...o,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":v+"px","--radix-scroll-area-corner-height":b+"px",...e.style}})})});iW.displayName=YP;var oW="ScrollAreaViewport",lW=p.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:s,nonce:a,...i}=e,o=xa(oW,r),l=p.useRef(null),c=dt(t,l,o.onViewportChange);return n.jsxs(n.Fragment,{children:[n.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}),n.jsx(We.div,{"data-radix-scroll-area-viewport":"",...i,ref:c,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...e.style},children:n.jsx("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});lW.displayName=oW;var Ti="ScrollAreaScrollbar",XP=p.forwardRef((e,t)=>{const{forceMount:r,...s}=e,a=xa(Ti,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:o}=a,l=e.orientation==="horizontal";return p.useEffect(()=>(l?i(!0):o(!0),()=>{l?i(!1):o(!1)}),[l,i,o]),a.type==="hover"?n.jsx(g3e,{...s,ref:t,forceMount:r}):a.type==="scroll"?n.jsx(v3e,{...s,ref:t,forceMount:r}):a.type==="auto"?n.jsx(cW,{...s,ref:t,forceMount:r}):a.type==="always"?n.jsx(ZP,{...s,ref:t}):null});XP.displayName=Ti;var g3e=p.forwardRef((e,t)=>{const{forceMount:r,...s}=e,a=xa(Ti,e.__scopeScrollArea),[i,o]=p.useState(!1);return p.useEffect(()=>{const l=a.scrollArea;let c=0;if(l){const d=()=>{window.clearTimeout(c),o(!0)},u=()=>{c=window.setTimeout(()=>o(!1),a.scrollHideDelay)};return l.addEventListener("pointerenter",d),l.addEventListener("pointerleave",u),()=>{window.clearTimeout(c),l.removeEventListener("pointerenter",d),l.removeEventListener("pointerleave",u)}}},[a.scrollArea,a.scrollHideDelay]),n.jsx(Jn,{present:r||i,children:n.jsx(cW,{"data-state":i?"visible":"hidden",...s,ref:t})})}),v3e=p.forwardRef((e,t)=>{const{forceMount:r,...s}=e,a=xa(Ti,e.__scopeScrollArea),i=e.orientation==="horizontal",o=P0(()=>c("SCROLL_END"),100),[l,c]=p3e("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 p.useEffect(()=>{if(l==="idle"){const d=window.setTimeout(()=>c("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(d)}},[l,a.scrollHideDelay,c]),p.useEffect(()=>{const d=a.viewport,u=i?"scrollLeft":"scrollTop";if(d){let f=d[u];const h=()=>{const m=d[u];f!==m&&(c("SCROLL"),o()),f=m};return d.addEventListener("scroll",h),()=>d.removeEventListener("scroll",h)}},[a.viewport,i,c,o]),n.jsx(Jn,{present:r||l!=="hidden",children:n.jsx(ZP,{"data-state":l==="hidden"?"hidden":"visible",...s,ref:t,onPointerEnter:be(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:be(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),cW=p.forwardRef((e,t)=>{const r=xa(Ti,e.__scopeScrollArea),{forceMount:s,...a}=e,[i,o]=p.useState(!1),l=e.orientation==="horizontal",c=P0(()=>{if(r.viewport){const d=r.viewport.offsetWidth{const{orientation:r="vertical",...s}=e,a=xa(Ti,e.__scopeScrollArea),i=p.useRef(null),o=p.useRef(0),[l,c]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=hW(l.viewport,l.content),u={...s,sizes:l,onSizesChange:c,hasThumb:d>0&&d<1,onThumbChange:h=>i.current=h,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:h=>o.current=h};function f(h,m){return S3e(h,o.current,l,m)}return r==="horizontal"?n.jsx(y3e,{...u,ref:t,onThumbPositionChange:()=>{if(a.viewport&&i.current){const h=a.viewport.scrollLeft,m=_$(h,l,a.dir);i.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:h=>{a.viewport&&(a.viewport.scrollLeft=h)},onDragScroll:h=>{a.viewport&&(a.viewport.scrollLeft=f(h,a.dir))}}):r==="vertical"?n.jsx(j3e,{...u,ref:t,onThumbPositionChange:()=>{if(a.viewport&&i.current){const h=a.viewport.scrollTop,m=_$(h,l);i.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:h=>{a.viewport&&(a.viewport.scrollTop=h)},onDragScroll:h=>{a.viewport&&(a.viewport.scrollTop=f(h))}}):null}),y3e=p.forwardRef((e,t)=>{const{sizes:r,onSizesChange:s,...a}=e,i=xa(Ti,e.__scopeScrollArea),[o,l]=p.useState(),c=p.useRef(null),d=dt(t,c,i.onScrollbarXChange);return p.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),n.jsx(uW,{"data-orientation":"horizontal",...a,ref:d,sizes:r,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":k0(r)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,f)=>{if(i.viewport){const h=i.viewport.scrollLeft+u.deltaX;e.onWheelScroll(h),xW(h,f)&&u.preventDefault()}},onResize:()=>{c.current&&i.viewport&&o&&s({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:rj(o.paddingLeft),paddingEnd:rj(o.paddingRight)}})}})}),j3e=p.forwardRef((e,t)=>{const{sizes:r,onSizesChange:s,...a}=e,i=xa(Ti,e.__scopeScrollArea),[o,l]=p.useState(),c=p.useRef(null),d=dt(t,c,i.onScrollbarYChange);return p.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),n.jsx(uW,{"data-orientation":"vertical",...a,ref:d,sizes:r,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":k0(r)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,f)=>{if(i.viewport){const h=i.viewport.scrollTop+u.deltaY;e.onWheelScroll(h),xW(h,f)&&u.preventDefault()}},onResize:()=>{c.current&&i.viewport&&o&&s({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:rj(o.paddingTop),paddingEnd:rj(o.paddingBottom)}})}})}),[b3e,dW]=aW(Ti),uW=p.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:s,hasThumb:a,onThumbChange:i,onThumbPointerUp:o,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:u,onResize:f,...h}=e,m=xa(Ti,r),[y,x]=p.useState(null),j=dt(t,P=>x(P)),v=p.useRef(null),g=p.useRef(""),b=m.viewport,N=s.content-s.viewport,w=Dn(u),S=Dn(c),_=P0(f,10);function C(P){if(v.current){const D=P.clientX-v.current.left,z=P.clientY-v.current.top;d({x:D,y:z})}}return p.useEffect(()=>{const P=D=>{const z=D.target;(y==null?void 0:y.contains(z))&&w(D,N)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[b,y,N,w]),p.useEffect(S,[s,S]),Tf(y,_),Tf(m.content,_),n.jsx(b3e,{scope:r,scrollbar:y,hasThumb:a,onThumbChange:Dn(i),onThumbPointerUp:Dn(o),onThumbPositionChange:S,onThumbPointerDown:Dn(l),children:n.jsx(We.div,{...h,ref:j,style:{position:"absolute",...h.style},onPointerDown:be(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),v.current=y.getBoundingClientRect(),g.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),C(P))}),onPointerMove:be(e.onPointerMove,C),onPointerUp:be(e.onPointerUp,P=>{const D=P.target;D.hasPointerCapture(P.pointerId)&&D.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=g.current,m.viewport&&(m.viewport.style.scrollBehavior=""),v.current=null})})})}),nj="ScrollAreaThumb",fW=p.forwardRef((e,t)=>{const{forceMount:r,...s}=e,a=dW(nj,e.__scopeScrollArea);return n.jsx(Jn,{present:r||a.hasThumb,children:n.jsx(w3e,{ref:t,...s})})}),w3e=p.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:s,...a}=e,i=xa(nj,r),o=dW(nj,r),{onThumbPositionChange:l}=o,c=dt(t,f=>o.onThumbChange(f)),d=p.useRef(void 0),u=P0(()=>{d.current&&(d.current(),d.current=void 0)},100);return p.useEffect(()=>{const f=i.viewport;if(f){const h=()=>{if(u(),!d.current){const m=_3e(f,l);d.current=m,l()}};return l(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[i.viewport,u,l]),n.jsx(We.div,{"data-state":o.hasThumb?"visible":"hidden",...a,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:be(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),y=f.clientX-m.left,x=f.clientY-m.top;o.onThumbPointerDown({x:y,y:x})}),onPointerUp:be(e.onPointerUp,o.onThumbPointerUp)})});fW.displayName=nj;var JP="ScrollAreaCorner",mW=p.forwardRef((e,t)=>{const r=xa(JP,e.__scopeScrollArea),s=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&s?n.jsx(N3e,{...e,ref:t}):null});mW.displayName=JP;var N3e=p.forwardRef((e,t)=>{const{__scopeScrollArea:r,...s}=e,a=xa(JP,r),[i,o]=p.useState(0),[l,c]=p.useState(0),d=!!(i&&l);return Tf(a.scrollbarX,()=>{var f;const u=((f=a.scrollbarX)==null?void 0:f.offsetHeight)||0;a.onCornerHeightChange(u),c(u)}),Tf(a.scrollbarY,()=>{var f;const u=((f=a.scrollbarY)==null?void 0:f.offsetWidth)||0;a.onCornerWidthChange(u),o(u)}),d?n.jsx(We.div,{...s,ref:t,style:{width:i,height:l,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function rj(e){return e?parseInt(e,10):0}function hW(e,t){const r=e/t;return isNaN(r)?0:r}function k0(e){const t=hW(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=(e.scrollbar.size-r)*t;return Math.max(s,18)}function S3e(e,t,r,s="ltr"){const a=k0(r),i=a/2,o=t||i,l=a-o,c=r.scrollbar.paddingStart+o,d=r.scrollbar.size-r.scrollbar.paddingEnd-l,u=r.content-r.viewport,f=s==="ltr"?[0,u]:[u*-1,0];return pW([c,d],f)(e)}function _$(e,t,r="ltr"){const s=k0(t),a=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-a,o=t.content-t.viewport,l=i-s,c=r==="ltr"?[0,o]:[o*-1,0],d=tp(e,c);return pW([0,o],[0,l])(d)}function pW(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const s=(t[1]-t[0])/(e[1]-e[0]);return t[0]+s*(r-e[0])}}function xW(e,t){return e>0&&e{})=>{let r={left:e.scrollLeft,top:e.scrollTop},s=0;return function a(){const i={left:e.scrollLeft,top:e.scrollTop},o=r.left!==i.left,l=r.top!==i.top;(o||l)&&t(),r=i,s=window.requestAnimationFrame(a)}(),()=>window.cancelAnimationFrame(s)};function P0(e,t){const r=Dn(e),s=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(s.current),[]),p.useCallback(()=>{window.clearTimeout(s.current),s.current=window.setTimeout(r,t)},[r,t])}function Tf(e,t){const r=Dn(t);Ln(()=>{let s=0;if(e){const a=new ResizeObserver(()=>{cancelAnimationFrame(s),s=window.requestAnimationFrame(r)});return a.observe(e),()=>{window.cancelAnimationFrame(s),a.unobserve(e)}}},[e,r])}var gW=iW,C3e=lW,k3e=mW;const ua=p.forwardRef(({className:e,children:t,...r},s)=>n.jsxs(gW,{ref:s,className:he("relative overflow-hidden",e),...r,children:[n.jsx(C3e,{className:"h-full w-full rounded-[inherit]",children:t}),n.jsx(vW,{}),n.jsx(k3e,{})]}));ua.displayName=gW.displayName;const vW=p.forwardRef(({className:e,orientation:t="vertical",...r},s)=>n.jsx(XP,{ref:s,orientation:t,className:he("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...r,children:n.jsx(fW,{className:"relative flex-1 rounded-full bg-border"})}));vW.displayName=XP.displayName;function P3e(e){return(e??"").toLowerCase().replace(/\s+/g,"_")}function A3e(e){return e.trim()?e.trim().split(/\s+/).length:0}function E3e(e){const t=new Map;for(const r of e)for(const s of r.questions)t.set(s.id,{question_id:s.id,answer:null,flagged:!1,time_spent_ms:0});return t}function O3e(){const{examId:e}=Ht(),t=Number(e),r=Bt(),{data:s,isLoading:a,isError:i}=u3e(t),o=m3e(),l=h3e(),c=p.useMemo(()=>{if(!s)return s;const te=s;return{...te,title:te.title||te.exam_title||"",sections:(te.sections||[]).map(xe=>({...xe,questions:(xe.questions||[]).map(me=>({...me,type:me.type||me.question_type||me.skill||""}))}))}},[s]),[d,u]=p.useState(0),[f,h]=p.useState(0),[m,y]=p.useState(new Map),[x,j]=p.useState(null),[v,g]=p.useState(!1),[b,N]=p.useState(!1),w=p.useRef(0),S=p.useRef(Date.now());p.useEffect(()=>{c&&(y(E3e(c.sections)),w.current=c.total_time_min*60,z(0))},[c]);const _=c==null?void 0:c.sections[d],C=_==null?void 0:_.questions[f],P=p.useMemo(()=>(c==null?void 0:c.sections.reduce((te,xe)=>te+xe.questions.length,0))??0,[c]),[D,z]=p.useState(0);p.useEffect(()=>{const te=window.setInterval(()=>z(xe=>xe+1),1e3);return()=>window.clearInterval(te)},[]),p.useEffect(()=>{S.current=Date.now()},[C==null?void 0:C.id]);const O=p.useMemo(()=>{let te=0;return m.forEach(xe=>{xe.answer===null||xe.answer===""||Array.isArray(xe.answer)&&xe.answer.length===0||(te+=1)}),te},[m]),V=P?O/P*100:0,A=p.useCallback((te,xe)=>{y(me=>{const ne=new Map(me),_e=ne.get(te);if(!_e)return me;const ue=Date.now()-S.current;return ne.set(te,{..._e,...xe,time_spent_ms:_e.time_spent_ms+ue}),S.current=Date.now(),ne})},[]),$=p.useCallback(()=>_?_.questions.map(te=>m.get(te.id)).filter(Boolean):[],[_,m]);p.useEffect(()=>{if(!c||!_)return;const te=c==null?void 0:c.attempt_id,xe=window.setInterval(()=>{o.mutate({examId:t,payload:{attempt_id:te,section_id:_.id,answers:$()}})},1e4);return()=>window.clearInterval(xe)},[c,_,t,o,$]);const B=()=>{if(!C)return;const te=m.get(C.id);te&&A(C.id,{flagged:!te.flagged})},I=()=>{if(!(!c||!_)){if(f<_.questions.length-1){h(te=>te+1);return}if(d{if(f>0){h(te=>te-1);return}if(d>0){const te=c.sections[d-1];u(xe=>xe-1),h(te.questions.length-1)}};p.useEffect(()=>{if(!(x!=null&&x.open))return;if(x.remaining<=0){u(x.sec),h(0),j(null);return}const te=window.setTimeout(()=>j(xe=>xe?{...xe,remaining:xe.remaining-1}:null),1e3);return()=>window.clearTimeout(te)},[x]);const M=p.useMemo(()=>{let te=0,xe=0,me=0;return c==null||c.sections.forEach(ne=>{ne.questions.forEach(_e=>{const ue=m.get(_e.id);if(!ue){xe+=1;return}ue.flagged&&(me+=1),ue.answer===null||ue.answer===""||Array.isArray(ue.answer)&&ue.answer.length===0?xe+=1:te+=1})}),{answered:te,unanswered:xe,flagged:me,total:P}},[c,m,P]),K=te=>{var ne,_e,ue,we;const xe=m.get(te.id);if(!xe)return null;const me=P3e(te.type);if(me.includes("listen")||te.audio_url)return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center gap-3 rounded-lg border bg-muted/40 p-4",children:[n.jsx(E,{type:"button",variant:"outline",size:"icon",onClick:()=>N(ve=>!ve),children:b?n.jsx(YG,{className:"h-5 w-5"}):n.jsx(pk,{className:"h-5 w-5"})}),n.jsx("div",{className:"h-2 flex-1 rounded-full bg-muted",children:n.jsx("div",{className:"h-2 w-1/3 rounded-full bg-primary"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"0:00 / 3:42"})]}),(ne=te.options)!=null&&ne.length?n.jsx(es,{value:typeof xe.answer=="string"?xe.answer:"",onValueChange:ve=>A(te.id,{answer:ve}),className:"space-y-2",children:te.options.map(ve=>n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Bn,{value:ve.label,id:`${te.id}-${ve.label}`}),n.jsx(q,{htmlFor:`${te.id}-${ve.label}`,children:ve.text})]},ve.label))}):null]});if(me.includes("multi")||me==="mcq_multi"){const ve=Array.isArray(xe.answer)?xe.answer:[];return n.jsx("div",{className:"space-y-3",children:(_e=te.options)==null?void 0:_e.map(le=>n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(an,{id:`${te.id}-${le.label}`,checked:ve.includes(le.label),onCheckedChange:ut=>{const Ve=ut===!0?[...ve,le.label]:ve.filter(pt=>pt!==le.label);A(te.id,{answer:Ve})}}),n.jsx(q,{htmlFor:`${te.id}-${le.label}`,children:le.text})]},le.label))})}if(me.includes("gap"))return n.jsx(G,{value:typeof xe.answer=="string"?xe.answer:"",onChange:ve=>A(te.id,{answer:ve.target.value}),placeholder:"Your answer",className:"max-w-md"});if(me.includes("true")||me.includes("tfng")||me==="yes_no_not_given"){const ve=(ue=te.options)!=null&&ue.length?te.options:[{label:"T",text:"True"},{label:"F",text:"False"},{label:"NG",text:"Not Given"}];return n.jsx(es,{value:typeof xe.answer=="string"?xe.answer:"",onValueChange:le=>A(te.id,{answer:le}),className:"space-y-2",children:ve.map(le=>n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Bn,{value:le.label,id:`${te.id}-${le.label}`}),n.jsx(q,{htmlFor:`${te.id}-${le.label}`,children:le.text})]},le.label))})}if(me.includes("writing")||me.includes("essay")){const ve=typeof xe.answer=="string"?xe.answer:"",le=A3e(ve),ut=te.min_words??150;return n.jsxs("div",{className:"space-y-2",children:[n.jsx(on,{value:ve,onChange:Se=>A(te.id,{answer:Se.target.value}),className:"min-h-[200px]"}),n.jsxs("p",{className:he("text-sm",leA(te.id,{answer:ve}),className:"space-y-2",children:(we=te.options)==null?void 0:we.map(ve=>n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Bn,{value:ve.label,id:`${te.id}-${ve.label}`}),n.jsx(q,{htmlFor:`${te.id}-${ve.label}`,children:ve.text})]},ve.label))})};if(a)return n.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background",children:n.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-2 border-primary border-t-transparent"})});if(i||!c)return n.jsxs("div",{className:"fixed inset-0 z-[100] flex flex-col items-center justify-center gap-4 bg-background p-6",children:[n.jsx("p",{className:"text-destructive text-lg font-medium",children:"Unable to load this exam session."}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"The exam may not exist or the server is unreachable."}),n.jsx(E,{variant:"outline",onClick:()=>r(-1),children:"Go Back"})]});const X=Math.max(0,w.current-D),re=Math.floor(X/60),Z=X%60;return n.jsxs("div",{className:"fixed inset-0 z-[100] flex flex-col bg-background",children:[n.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-4 border-b px-6 py-3",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-lg font-semibold leading-tight",children:c.title}),n.jsx("p",{className:"text-sm text-muted-foreground",children:_==null?void 0:_.title})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-6",children:[n.jsxs("span",{className:"font-mono text-lg tabular-nums",children:[String(re).padStart(2,"0"),":",String(Z).padStart(2,"0")]}),n.jsxs("div",{className:"w-48 space-y-1",children:[n.jsx(kn,{value:V,className:"h-2"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Overall progress"})]})]})]}),n.jsx("div",{className:"flex flex-1 min-h-0 flex-col md:flex-row",children:n.jsx(ua,{className:"flex-1 p-6",children:C?n.jsx(W,{className:"border-none shadow-none",children:n.jsxs(U,{className:"space-y-6 p-0",children:[C.passage_text?n.jsx("div",{className:"rounded-lg bg-muted/50 p-4 text-sm leading-relaxed",children:C.passage_text}):null,n.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:n.jsx("p",{className:"font-medium",children:C.stem})}),K(C)]})}):null})}),n.jsxs("footer",{className:"flex flex-wrap items-center justify-between gap-3 border-t px-6 py-4",children:[n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(E,{type:"button",variant:"outline",onClick:k,disabled:d===0&&f===0,children:[n.jsx(DL,{className:"mr-1 h-4 w-4"}),"Previous"]}),n.jsxs(E,{type:"button",variant:"outline",onClick:B,children:[n.jsx(DG,{className:"mr-1 h-4 w-4"}),"Flag for Review"]})]}),n.jsx("div",{className:"flex gap-2",children:n.jsxs(E,{type:"button",onClick:I,children:["Next",n.jsx(Si,{className:"ml-1 h-4 w-4"})]})})]}),n.jsx(Qe,{open:!!(x!=null&&x.open),onOpenChange:()=>j(null),children:n.jsx(Ue,{className:"sm:max-w-sm",children:n.jsxs(Ke,{children:[n.jsx(Ge,{children:"Next section"}),n.jsxs(Qv,{children:["The next section begins in"," ",n.jsx("span",{className:"font-mono font-semibold",children:(x==null?void 0:x.remaining)??0}),"s."]})]})})}),n.jsx(Qe,{open:v,onOpenChange:g,children:n.jsxs(Ue,{className:"max-w-lg",children:[n.jsxs(Ke,{children:[n.jsx(Ge,{children:"Review and submit"}),n.jsxs(Qv,{children:[M.answered," answered · ",M.unanswered," unanswered · ",M.flagged," flagged ·"," ",M.total," total"]})]}),n.jsxs(Ct,{className:"gap-2 sm:justify-end",children:[n.jsx(E,{type:"button",variant:"outline",onClick:()=>g(!1),children:"Back"}),n.jsx(E,{type:"button",onClick:()=>{const te=c==null?void 0:c.attempt_id,xe=Array.from(m.entries()).map(([me,ne])=>({question_id:me,answer:ne.answer??""}));l.mutate({examId:t,attempt_id:te,answers:xe},{onSuccess:()=>{g(!1),r(`/student/exam/${t}/status`)}})},disabled:l.isPending,children:"Submit exam"})]})]})})]})}function T3e(){const{examId:e}=Ht(),t=Number(e),r=Bt(),{data:s,isLoading:a,isFetching:i}=f3e(t,!0);if(p.useEffect(()=>{if(!s)return;const c=(s.status??"").toLowerCase();(s.scores_available||c.includes("complete")||c.includes("released"))&&r(`/student/exam/${t}/results`,{replace:!0})},[s,t,r]),a&&!s)return n.jsxs("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 p-6",children:[n.jsx("div",{className:"h-12 w-12 animate-spin rounded-full border-2 border-primary border-t-transparent"}),n.jsx("p",{className:"text-muted-foreground",children:"Loading status…"})]});const o=((s==null?void 0:s.status)??"").toLowerCase();let l="generic";return o.includes("scoring")||o==="processing"?l="scoring":o.includes("manual")||o.includes("approval")||o.includes("under_review")?l="manual":(o.includes("partial")||o.includes("pending_ws")||o.includes("lr_scored")||o.includes("listening")&&o.includes("reading")&&o.includes("pending"))&&(l="partial"),n.jsxs("div",{className:"mx-auto flex min-h-screen max-w-lg flex-col justify-center gap-6 p-6",children:[l==="scoring"?n.jsxs(W,{children:[n.jsxs(se,{className:"text-center",children:[n.jsx("div",{className:"mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-2 border-primary border-t-transparent"}),n.jsx(ie,{children:"Scores are being calculated"}),n.jsx($e,{children:"This page refreshes every few seconds."})]}),n.jsx(U,{className:"text-center text-xs text-muted-foreground",children:i?"Checking…":"Waiting for next update…"})]}):null,l==="partial"?n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Partial results"}),n.jsx($e,{children:"Listening and Reading are scored; Writing and Speaking are still pending review."})]}),n.jsxs(U,{className:"space-y-2 text-sm",children:[n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{children:"Listening"}),n.jsx(oe,{variant:"secondary",children:"Band 7.5"})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{children:"Reading"}),n.jsx(oe,{variant:"secondary",children:"Band 8.0"})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{children:"Writing"}),n.jsx(oe,{children:"Pending Review"})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{children:"Speaking"}),n.jsx(oe,{children:"Pending Review"})]})]})]}):null,l==="manual"?n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Results under review"}),n.jsx($e,{children:"Your institution will release Writing and Speaking results after approval."})]}),n.jsx(U,{children:n.jsx(E,{type:"button",variant:"outline",onClick:()=>r("/student/dashboard"),children:"Back to dashboard"})})]}):null,l==="generic"?n.jsx(W,{children:n.jsxs(se,{children:[n.jsx(ie,{children:"Status"}),n.jsx($e,{children:(s==null?void 0:s.status)??"Unknown"})]})}):null]})}var Xa="Accordion",M3e=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[eA,R3e,$3e]=Df(Xa),[A0]=lr(Xa,[$3e,z5]),tA=z5(),yW=F.forwardRef((e,t)=>{const{type:r,...s}=e,a=s,i=s;return n.jsx(eA.Provider,{scope:e.__scopeAccordion,children:r==="multiple"?n.jsx(F3e,{...i,ref:t}):n.jsx(L3e,{...a,ref:t})})});yW.displayName=Xa;var[jW,I3e]=A0(Xa),[bW,D3e]=A0(Xa,{collapsible:!1}),L3e=F.forwardRef((e,t)=>{const{value:r,defaultValue:s,onValueChange:a=()=>{},collapsible:i=!1,...o}=e,[l,c]=zr({prop:r,defaultProp:s??"",onChange:a,caller:Xa});return n.jsx(jW,{scope:e.__scopeAccordion,value:F.useMemo(()=>l?[l]:[],[l]),onItemOpen:c,onItemClose:F.useCallback(()=>i&&c(""),[i,c]),children:n.jsx(bW,{scope:e.__scopeAccordion,collapsible:i,children:n.jsx(wW,{...o,ref:t})})})}),F3e=F.forwardRef((e,t)=>{const{value:r,defaultValue:s,onValueChange:a=()=>{},...i}=e,[o,l]=zr({prop:r,defaultProp:s??[],onChange:a,caller:Xa}),c=F.useCallback(u=>l((f=[])=>[...f,u]),[l]),d=F.useCallback(u=>l((f=[])=>f.filter(h=>h!==u)),[l]);return n.jsx(jW,{scope:e.__scopeAccordion,value:o,onItemOpen:c,onItemClose:d,children:n.jsx(bW,{scope:e.__scopeAccordion,collapsible:!0,children:n.jsx(wW,{...i,ref:t})})})}),[B3e,E0]=A0(Xa),wW=F.forwardRef((e,t)=>{const{__scopeAccordion:r,disabled:s,dir:a,orientation:i="vertical",...o}=e,l=F.useRef(null),c=dt(l,t),d=R3e(r),f=zl(a)==="ltr",h=be(e.onKeyDown,m=>{var C;if(!M3e.includes(m.key))return;const y=m.target,x=d().filter(P=>{var D;return!((D=P.ref.current)!=null&&D.disabled)}),j=x.findIndex(P=>P.ref.current===y),v=x.length;if(j===-1)return;m.preventDefault();let g=j;const b=0,N=v-1,w=()=>{g=j+1,g>N&&(g=b)},S=()=>{g=j-1,g{const{__scopeAccordion:r,value:s,...a}=e,i=E0(sj,r),o=I3e(sj,r),l=tA(r),c=ys(),d=s&&o.value.includes(s)||!1,u=i.disabled||e.disabled;return n.jsx(z3e,{scope:r,open:d,disabled:u,triggerId:c,children:n.jsx(W5,{"data-orientation":i.orientation,"data-state":AW(d),...l,...a,ref:t,disabled:u,open:d,onOpenChange:f=>{f?o.onItemOpen(s):o.onItemClose(s)}})})});NW.displayName=sj;var SW="AccordionHeader",_W=F.forwardRef((e,t)=>{const{__scopeAccordion:r,...s}=e,a=E0(Xa,r),i=nA(SW,r);return n.jsx(We.h3,{"data-orientation":a.orientation,"data-state":AW(i.open),"data-disabled":i.disabled?"":void 0,...s,ref:t})});_W.displayName=SW;var iC="AccordionTrigger",CW=F.forwardRef((e,t)=>{const{__scopeAccordion:r,...s}=e,a=E0(Xa,r),i=nA(iC,r),o=D3e(iC,r),l=tA(r);return n.jsx(eA.ItemSlot,{scope:r,children:n.jsx(yne,{"aria-disabled":i.open&&!o.collapsible||void 0,"data-orientation":a.orientation,id:i.triggerId,...l,...s,ref:t})})});CW.displayName=iC;var kW="AccordionContent",PW=F.forwardRef((e,t)=>{const{__scopeAccordion:r,...s}=e,a=E0(Xa,r),i=nA(kW,r),o=tA(r);return n.jsx(jne,{role:"region","aria-labelledby":i.triggerId,"data-orientation":a.orientation,...o,...s,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});PW.displayName=kW;function AW(e){return e?"open":"closed"}var V3e=yW,q3e=NW,W3e=_W,EW=CW,OW=PW;const O0=V3e,Ax=p.forwardRef(({className:e,...t},r)=>n.jsx(q3e,{ref:r,className:he("border-b",e),...t}));Ax.displayName="AccordionItem";const Ex=p.forwardRef(({className:e,children:t,...r},s)=>n.jsx(W3e,{className:"flex",children:n.jsxs(EW,{ref:s,className:he("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...r,children:[t,n.jsx(rr,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));Ex.displayName=EW.displayName;const Ox=p.forwardRef(({className:e,children:t,...r},s)=>n.jsx(OW,{ref:s,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...r,children:n.jsx("div",{className:he("pb-4 pt-0",e),children:t})}));Ox.displayName=OW.displayName;const TW=[{skill:"Listening",band:7.5,cefr:"C1",gap:.5,target:8},{skill:"Reading",band:8,cefr:"C1",gap:0,target:8},{skill:"Writing",band:6.5,cefr:"B2",gap:1.5,target:8},{skill:"Speaking",band:7,cefr:"C1",gap:1,target:8}],U3e=TW.map(e=>({skill:e.skill,band:e.band}));function K3e(){const{examId:e}=Ht(),[t]=wo(),r=t.get("mode")==="practice";return n.jsxs("div",{className:"mx-auto max-w-5xl space-y-8 p-6",children:[n.jsxs("div",{className:"text-center",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"Your overall result"}),n.jsxs("div",{className:"mt-2 flex items-center justify-center gap-3",children:[n.jsx(ik,{className:"h-12 w-12 text-primary"}),n.jsx("span",{className:"text-5xl font-bold tabular-nums",children:7.5}),n.jsx(oe,{variant:"secondary",className:"text-lg",children:"Band"})]}),n.jsxs("p",{className:"mt-2 text-lg text-muted-foreground",children:["CEFR equivalent: ","C1"]}),r?n.jsx(oe,{className:"mt-2",children:"Practice mode"}):null]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Skill profile"}),n.jsx($e,{children:"Per-skill performance vs maximum scale"})]}),n.jsx(U,{children:n.jsx("div",{className:"h-72 w-full",children:n.jsx(Xn,{width:"100%",height:"100%",children:n.jsxs(nW,{data:U3e,cx:"50%",cy:"50%",outerRadius:"80%",children:[n.jsx(BP,{}),n.jsx(Ed,{dataKey:"skill"}),n.jsx(Ad,{angle:30,domain:[0,9],tickCount:6}),n.jsx(pm,{name:"Band",dataKey:"band",stroke:"hsl(var(--primary))",fill:"hsl(var(--primary))",fillOpacity:.35})]})})})})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{children:"Skills breakdown"})}),n.jsx(U,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Skill"}),n.jsx(L,{children:"Band"}),n.jsx(L,{children:"CEFR"}),n.jsx(L,{children:"Gap to Target"})]})}),n.jsx(Be,{children:TW.map(i=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:i.skill}),n.jsx(T,{children:i.band}),n.jsx(T,{children:i.cefr}),n.jsx(T,{children:i.gap>0?`−${i.gap}`:"—"})]},i.skill))})]})})]}),n.jsxs("div",{children:[n.jsx("h2",{className:"mb-3 text-lg font-semibold",children:"Section feedback"}),n.jsx(O0,{type:"multiple",className:"w-full",children:["Listening","Reading","Writing","Speaking"].map(i=>n.jsxs(Ax,{value:i,children:[n.jsx(Ex,{children:i}),n.jsxs(Ox,{className:"text-muted-foreground",children:["Detailed feedback for ",i," will appear here once released by your instructor."]})]},i))})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Areas to improve"}),n.jsx($e,{children:"Focus recommendations based on this attempt"})]}),n.jsx(U,{children:n.jsxs("ul",{className:"list-inside list-disc space-y-2 text-sm",children:[n.jsx("li",{children:"Strengthen task response structure in Writing Task 2."}),n.jsx("li",{children:"Extend range of cohesive devices in argumentative essays."}),n.jsx("li",{children:"Maintain fluency while reducing hesitation in Speaking Part 2."})]})})]}),n.jsxs("div",{className:"flex flex-wrap gap-3",children:[n.jsxs(E,{type:"button",variant:"outline",children:[n.jsx(yd,{className:"mr-2 h-4 w-4"}),"Download PDF Report"]}),n.jsx(E,{type:"button",asChild:!0,children:n.jsxs(Dt,{to:`/student/course/generate?from=exam&examId=${e??""}`,children:[n.jsx(Kt,{className:"mr-2 h-4 w-4"}),"View Recommended Course"]})}),n.jsx(E,{type:"button",variant:"secondary",asChild:!0,children:n.jsxs(Dt,{to:`/student/exam/${e}/session?mode=practice`,children:[n.jsx(xk,{className:"mr-2 h-4 w-4"}),"Retake Exam"]})})]}),n.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[n.jsxs(W,{className:"border-green-600/40 bg-green-500/5",children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Pass path"}),n.jsx($e,{children:"Congratulations — you are on track for your goal."})]}),n.jsxs(U,{className:"space-y-3",children:[n.jsx("p",{className:"text-sm",children:"Consider registering for the official test while skills are strong."}),n.jsx(E,{type:"button",size:"sm",children:"Register for official exam"})]})]}),n.jsxs(W,{className:"",children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Below threshold"}),n.jsx($e,{children:"Close the gap with targeted training."})]}),n.jsxs(U,{className:"space-y-3",children:[n.jsx("p",{className:"text-sm",children:"Start adaptive training tailored to your weakest skills."}),n.jsx(E,{type:"button",size:"sm",variant:"secondary",asChild:!0,children:n.jsx(Dt,{to:`/student/course/generate?from=exam&examId=${e??""}`,children:"Start adaptive training"})})]})]})]})]})}const nc={getGapAnalysis:(e,t)=>R.get("/course/gap-analysis",{source:e,source_id:t}),autoGenerate:e=>R.post("/course/auto-generate",{source_id:e}),create:e=>R.post("/course/create",e),getCourse:e=>R.get(`/course/${e}`),updateCourse:(e,t)=>R.put(`/course/${e}`,t),trackProgress:(e,t)=>R.post(`/course/${e}/progress`,t),submitCheckpoint:(e,t)=>R.post(`/course/${e}/checkpoint`,t),startPostTest:e=>R.post(`/course/${e}/post-test`),generateAIResource:e=>R.post("/ai/generate-resource",e)};function G3e(e,t){return ye({queryKey:de.courseGeneration.gapAnalysis(e,t),queryFn:()=>nc.getGapAnalysis(e,t),enabled:!!t})}function H3e(){return ae({mutationFn:e=>nc.autoGenerate(e)})}function Q3e(){return ae({mutationFn:e=>nc.create(e)})}function rA(e){return ye({queryKey:de.courseGeneration.course(e),queryFn:()=>nc.getCourse(e),enabled:!!e})}function MW(){const e=je();return ae({mutationFn:t=>nc.updateCourse(t.courseId,t.payload),onSuccess:(t,r)=>e.invalidateQueries({queryKey:de.courseGeneration.course(r.courseId)})})}function Y3e(){return ae({mutationFn:e=>nc.trackProgress(e.courseId,e.progress)})}function X3e(){const[e]=wo(),{user:t}=Ga(),s=e.get("from")==="placement"?"placement":"exam",a=Number(e.get("examId")),i=Number(e.get("sessionId")),o=s==="exam"?a:i,l=e.get("entity")==="1",c=s==="exam"?Number.isFinite(a)&&a>0:Number.isFinite(i)&&i>0,{data:d,isLoading:u,isError:f}=G3e(s,o),h=H3e(),m=p.useMemo(()=>{var x;return(x=d==null?void 0:d.skill_gaps)!=null&&x.length?[...d.skill_gaps].sort((j,v)=>v.gap-j.gap).map(j=>({skill:j.skill,gap:j.gap})):[]},[d]),y=(t==null?void 0:t.user_type)==="student"&&!l;return n.jsxs("div",{className:"mx-auto max-w-5xl space-y-8 p-6",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Skill gap analysis"}),n.jsx("p",{className:"text-muted-foreground",children:s==="exam"?`From exam ${a||"—"}`:`Placement session ${i||"—"}`})]}),y?n.jsx(E,{type:"button",onClick:()=>h.mutate(o),disabled:!c||h.isPending,children:"Generate Course"}):null]}),l?n.jsxs(td,{children:[n.jsx(nd,{children:"Entity-managed students"}),n.jsx(rd,{children:"Gap analysis is view-only for your organization. Contact your coordinator to assign a course."})]}):null,c?null:n.jsxs(td,{variant:"destructive",children:[n.jsx(nd,{children:"Missing source"}),n.jsxs(rd,{children:["Add ",n.jsx("code",{className:"rounded bg-muted px-1",children:"?from=exam&examId=…"})," or"," ",n.jsx("code",{className:"rounded bg-muted px-1",children:"?from=placement&sessionId=…"})," to the URL."]})]}),u?n.jsx(Wt,{className:"h-96 w-full"}):f||!d?n.jsx("p",{className:"text-destructive",children:"Could not load gap analysis."}):n.jsxs(n.Fragment,{children:[n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Skills ranked by gap"}),n.jsx($e,{children:"Larger bars need more attention"})]}),n.jsx(U,{children:n.jsx("div",{className:"h-72 w-full",children:n.jsx(Xn,{width:"100%",height:"100%",children:n.jsxs(vo,{data:m,layout:"vertical",margin:{left:16},children:[n.jsx(bs,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(kr,{type:"number",domain:[0,"dataMax"]}),n.jsx(Pr,{type:"category",dataKey:"skill",width:100,tickLine:!1,axisLine:!1}),n.jsx(fn,{}),n.jsx(_r,{dataKey:"gap",fill:"hsl(var(--primary))",radius:[0,4,4,0]})]})})})})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{children:"Gap table"})}),n.jsx(U,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Skill"}),n.jsx(L,{children:"Current"}),n.jsx(L,{children:"Target"}),n.jsx(L,{children:"Gap"}),n.jsx(L,{children:"Priority"}),n.jsx(L,{children:"Est. Hours"})]})}),n.jsx(Be,{children:d.skill_gaps.map(x=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:x.skill}),n.jsx(T,{children:x.current_band??x.current_level}),n.jsx(T,{children:x.target_band??x.target_level}),n.jsx(T,{children:x.gap}),n.jsx(T,{className:"capitalize",children:x.priority}),n.jsx(T,{children:x.estimated_hours})]},x.skill))})]})})]}),n.jsxs("div",{children:[n.jsx("h2",{className:"mb-3 text-lg font-semibold",children:"Question-type weaknesses"}),n.jsx(O0,{type:"multiple",className:"w-full",children:Object.entries(d.question_type_weaknesses).map(([x,j])=>n.jsxs(Ax,{value:x,children:[n.jsx(Ex,{children:x}),n.jsx(Ox,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Type"}),n.jsx(L,{children:"Accuracy"}),n.jsx(L,{children:"Correct"}),n.jsx(L,{children:"Total"})]})}),n.jsx(Be,{children:j.map(v=>n.jsxs(ee,{children:[n.jsx(T,{children:v.question_type}),n.jsxs(T,{children:[Math.round(v.accuracy*100),"%"]}),n.jsx(T,{children:v.correct}),n.jsx(T,{children:v.total})]},v.question_type))})]})})]},x))})]}),n.jsxs("div",{children:[n.jsx("h2",{className:"mb-3 text-lg font-semibold",children:"Topic weaknesses"}),n.jsx("div",{className:"space-y-4",children:Object.entries(d.topic_weaknesses).map(([x,j])=>n.jsxs(W,{children:[n.jsx(se,{className:"py-3",children:n.jsx(ie,{className:"text-base",children:x})}),n.jsx(U,{className:"pt-0",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Topic"}),n.jsx(L,{children:"Errors"}),n.jsx(L,{children:"Total"})]})}),n.jsx(Be,{children:j.map(v=>n.jsxs(ee,{children:[n.jsx(T,{children:v.topic}),n.jsx(T,{children:v.errors}),n.jsx(T,{children:v.total})]},v.topic))})]})})]},x))})]})]})]})}function Z3e({type:e}){switch(e){case"pdf":return n.jsx(Yn,{className:"h-4 w-4"});case"video":return n.jsx(Ll,{className:"h-4 w-4"});case"audio":return n.jsx(Cj,{className:"h-4 w-4"});default:return n.jsx(Kt,{className:"h-4 w-4"})}}function J3e(){const{courseId:e}=Ht(),t=Number(e),{data:r,isLoading:s}=rA(t),a=Y3e(),[i,o]=p.useState(null),l=p.useMemo(()=>{const f=new Map;return r==null||r.modules.forEach(h=>{const m=h.skill||"General";f.has(m)||f.set(m,[]),f.get(m).push(h)}),f},[r]),c=p.useMemo(()=>{if(!(r!=null&&r.modules.length))return 0;const f=r.modules.reduce((h,m)=>h+(m.progress_percent??0),0);return Math.round(f/r.modules.length)},[r]),d=r?Math.max(0,r.duration_weeks-2):0,u=(f,h)=>{a.mutate({courseId:t,progress:{resource_id:h.id,completion_percent:100,time_spent_ms:6e4}}),o({module:f,resource:h})};return s?n.jsxs("div",{className:"p-6",children:[n.jsx(Wt,{className:"mb-4 h-12 w-full"}),n.jsx(Wt,{className:"h-96 w-full"})]}):n.jsxs("div",{className:"mx-auto max-w-5xl space-y-8 p-6",children:[n.jsx(W,{children:n.jsxs(se,{children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[n.jsxs("div",{children:[n.jsx(ie,{className:"text-2xl",children:(r==null?void 0:r.title)??`Course #${t}`}),n.jsxs($e,{children:[(r==null?void 0:r.exam_type)??"IELTS"," · Target ",(r==null?void 0:r.target_band)??(r==null?void 0:r.target_level)??"—"]})]}),n.jsx(oe,{variant:"secondary",children:(r==null?void 0:r.progression_model)??"linear"})]}),n.jsxs("div",{className:"mt-4 space-y-2",children:[n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{children:"Overall progress"}),n.jsxs("span",{children:[c,"%"]})]}),n.jsx(kn,{value:c}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:["About ",d," weeks remaining at your current pace"]})]})]})}),n.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[n.jsx("div",{className:"space-y-4",children:Array.from(l.entries()).map(([f,h])=>n.jsx(fr,{defaultOpen:!0,children:n.jsxs(W,{children:[n.jsx(mr,{asChild:!0,children:n.jsxs(se,{className:"flex cursor-pointer flex-row items-center justify-between py-3",children:[n.jsx(ie,{className:"text-base",children:f}),n.jsx(rr,{className:"h-5 w-5"})]})}),n.jsx(hr,{children:n.jsx(U,{className:"space-y-4 pt-0",children:h.map(m=>{var y;return n.jsxs("div",{className:"rounded-lg border p-4",children:[n.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[n.jsx("h3",{className:"font-semibold",children:m.title}),m.status==="locked"?n.jsx(zf,{className:"h-4 w-4 text-muted-foreground"}):null,m.id===((y=r==null?void 0:r.modules.find(x=>x.status==="in_progress"))==null?void 0:y.id)?n.jsx(oe,{children:"Recommended Next"}):null,m.status==="skipped"?n.jsx(oe,{variant:"outline",children:"Skipped"}):null]}),n.jsxs("div",{className:"mb-2 text-xs text-muted-foreground",children:[m.estimated_hours,"h · ",m.cefr_target??"CEFR target"]}),n.jsx(kn,{value:m.progress_percent??0,className:"mb-3 h-2"}),n.jsx("div",{className:"space-y-2",children:m.resources.map(x=>n.jsxs("button",{type:"button",onClick:()=>u(m,x),className:"flex w-full items-center justify-between rounded-md border bg-background px-3 py-2 text-left text-sm hover:bg-muted/50",children:[n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Z3e,{type:x.type}),x.title]}),x.completed?n.jsx(aa,{className:"h-4 w-4 text-green-600"}):null]},x.id))}),n.jsx("div",{className:"mt-3 flex gap-2",children:n.jsx(E,{type:"button",size:"sm",disabled:m.status==="locked",children:m.status==="in_progress"||m.progress_percent?"Continue":"Start"})})]},m.id)})})})]})},f))}),n.jsxs(W,{className:"min-h-[320px]",children:[n.jsxs(se,{children:[n.jsx(ie,{className:"text-base",children:"Resource viewer"}),n.jsx($e,{children:i?i.resource.title:"Select a resource to open the viewer"})]}),n.jsx(U,{children:i?n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:he("flex min-h-[200px] items-center justify-center rounded-lg border bg-muted/30 p-6 text-center text-sm text-muted-foreground"),children:[i.resource.type==="pdf"&&"PDF viewer placeholder",i.resource.type==="video"&&"Video player placeholder",i.resource.type==="audio"&&"Audio player placeholder",i.resource.type==="exercise"&&"Interactive exercise placeholder",i.resource.type==="ai_generated"&&n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(lt,{className:"h-4 w-4"})," AI-generated content placeholder"]})]}),n.jsx(qs,{}),n.jsxs(ua,{className:"h-32 text-xs text-muted-foreground",children:["Module: ",i.module.title,". Completion: ",i.module.completion_criteria,"."]})]}):n.jsx("p",{className:"text-sm text-muted-foreground",children:"PDF, video, audio, and exercise viewers render here."})})]})]})]})}const Tx={getQueue:e=>R.get("/grading/queue",e),getStudentResponse:(e,t)=>R.get(`/grading/${e}/response`,{skill:t}),getRubric:(e,t)=>R.get(`/grading/${e}/rubric`,{skill:t}),getAISuggestion:(e,t)=>R.post("/grading/ai-suggest",{attempt_id:e,skill:t}),submitGrade:e=>R.post(`/grading/${e.attempt_id}/submit`,e)};function eFe(e){return ye({queryKey:de.grading.queue(e),queryFn:()=>Tx.getQueue(e)})}function tFe(e,t){return ye({queryKey:de.grading.response(e,t),queryFn:()=>Tx.getStudentResponse(e,t),enabled:!!e})}function nFe(e,t){return ye({queryKey:de.grading.rubric(e,t),queryFn:()=>Tx.getRubric(e,t),enabled:!!e})}function rFe(){return ae({mutationFn:e=>Tx.getAISuggestion(e.attemptId,e.skill)})}function sFe(){const e=je();return ae({mutationFn:t=>Tx.submitGrade(t),onSuccess:()=>e.invalidateQueries({queryKey:["grading"]})})}const C$=["Task Achievement","Coherence","Lexical Resource","Grammatical Range"],k$=["Fluency","Lexical Resource","Grammatical Range","Pronunciation"];function aFe(){const{examId:e}=Ht(),t=Number(e),{data:r=[],isLoading:s}=eFe({exam_id:t}),a=p.useMemo(()=>!Number.isFinite(t)||t<=0?r:r.filter(w=>w.exam_id===t),[r,t]),[i,o]=p.useState(!1),[l,c]=p.useState(null),d=(l==null?void 0:l.skill)??"writing",u=(l==null?void 0:l.id)??0,f=tFe(u,d),h=nFe(u,d),m=rFe(),y=sFe(),[x,j]=p.useState({}),v=d==="speaking"?k$:C$,g=w=>{c(w),j({}),o(!0)};p.useEffect(()=>{if(!i||!h.data)return;const w=d==="speaking"?k$:C$,S=h.data,_={};S.forEach(C=>{_[C.name]=typeof C.score=="number"?C.score:0}),w.forEach(C=>{_[C]===void 0&&(_[C]=0)}),j(_)},[i,h.data,d]);const b=()=>{l&&m.mutate({attemptId:l.id,skill:d},{onSuccess:w=>{j(S=>{const _={...S};return w.criteria_scores.forEach(C=>{_[C.name]=C.score}),_})}})},N=()=>{l&&y.mutate({attempt_id:l.id,skill:d,criteria_scores:v.map(w=>({name:w,score:x[w]??0}))},{onSuccess:()=>{o(!1),c(null)}})};return n.jsxs("div",{className:"space-y-6 p-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Grading queue"}),n.jsxs("p",{className:"text-muted-foreground",children:["Exam ",e]})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{children:"Pending submissions"})}),n.jsx(U,{children:s?n.jsx(Wt,{className:"h-40 w-full"}):n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Student Name"}),n.jsx(L,{children:"Exam Title"}),n.jsx(L,{children:"Skill"}),n.jsx(L,{children:"Submitted At"}),n.jsx(L,{children:"Status"}),n.jsx(L,{className:"text-right",children:"Action"})]})}),n.jsx(Be,{children:a.map(w=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:w.student_name}),n.jsx(T,{children:w.exam_title}),n.jsx(T,{className:"capitalize",children:w.skill}),n.jsx(T,{children:new Date(w.submitted_at).toLocaleString()}),n.jsx(T,{children:n.jsx(oe,{variant:w.status==="pending"?"secondary":"default",children:w.status})}),n.jsx(T,{className:"text-right",children:n.jsx(E,{type:"button",size:"sm",onClick:()=>g(w),children:"Grade Now"})})]},`${w.id}-${w.skill}`))})]})})]}),n.jsx(Jj,{open:i,onOpenChange:o,children:n.jsxs(rx,{className:"flex w-full flex-col sm:max-w-xl",children:[n.jsx(eb,{children:n.jsx(tb,{children:"Grade response"})}),n.jsx(ua,{className:"flex-1 pr-4",children:n.jsxs("div",{className:"space-y-6 py-4",children:[f.isLoading?n.jsx(Wt,{className:"h-32 w-full"}):f.data?n.jsxs("div",{className:"space-y-3",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:f.data.prompt_text}),f.data.type==="writing"&&f.data.text?n.jsx("div",{className:"rounded-md border bg-muted/30 p-4 text-sm whitespace-pre-wrap",children:f.data.text}):null,f.data.type==="speaking"?n.jsx("div",{className:"rounded-md border border-dashed p-6 text-center text-sm text-muted-foreground",children:"Audio response placeholder"}):null]}):null,n.jsx(qs,{}),n.jsxs("div",{className:"space-y-4",children:[n.jsx("h3",{className:"font-semibold",children:"Rubric"}),v.map(w=>n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx(q,{htmlFor:`score-${w}`,children:w}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"0–9"})]}),n.jsx(oa,{id:`score-${w}`,min:0,max:9,step:1,value:[x[w]??0],onValueChange:S=>j(_=>({..._,[w]:S[0]??0}))}),n.jsx("p",{className:"text-sm font-medium",children:x[w]??0})]},w))]}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(E,{type:"button",variant:"secondary",onClick:b,disabled:m.isPending||!l,children:"AI Grade Suggestion"}),n.jsx(E,{type:"button",onClick:N,disabled:y.isPending||!l,children:"Submit Grade"})]}),m.isError?n.jsxs("p",{className:"flex items-center gap-2 text-sm text-destructive",children:[n.jsx(Pl,{className:"h-4 w-4"}),"Suggestion could not be loaded."]}):null]})})]})})]})}const Eg=["Listening","Reading","Writing","Speaking"],iFe=No({title:wn().min(1),exam_type:wn().optional(),target_band:Nl.number().min(0).max(9).optional(),target_level:wn().optional(),duration_weeks:Nl.number().min(1),study_hours_week:Nl.number().min(1),skills:vb(wn()).min(1),skill_weightings:Kre(wn(),Js().min(0).max(100)),progression_model:Ta(["linear","parallel","adaptive"])});function oFe(){const{courseId:e}=Ht(),t=Number(e),[r]=wo(),s=r.get("path")==="individual",{data:a,isLoading:i}=rA(t),o=MW(),l=Q3e(),c=Vl({resolver:ql(iFe),defaultValues:{title:"",exam_type:"IELTS",duration_weeks:8,study_hours_week:5,skills:["Listening","Reading"],skill_weightings:{Listening:25,Reading:25,Writing:25,Speaking:25},progression_model:"adaptive"}});p.useEffect(()=>{var f;if(!a)return;const u={};Eg.forEach(h=>{u[h]=a.skill_weightings[h]??25}),c.reset({title:a.title,exam_type:a.exam_type??"IELTS",target_band:a.target_band,target_level:a.target_level,duration_weeks:a.duration_weeks,study_hours_week:a.study_hours_week,skills:(f=a.skills)!=null&&f.length?a.skills:Eg,skill_weightings:u,progression_model:a.progression_model})},[a,c]);const d=u=>{!Number.isFinite(t)||t<=0||o.mutate({courseId:t,payload:{title:u.title,exam_type:u.exam_type,target_band:u.target_band,target_level:u.target_level,duration_weeks:u.duration_weeks,study_hours_week:u.study_hours_week,skills:u.skills,skill_weightings:u.skill_weightings,progression_model:u.progression_model}})};return i?n.jsxs("div",{className:"p-6",children:[n.jsx(Wt,{className:"h-10 w-64 mb-4"}),n.jsx(Wt,{className:"h-96 w-full"})]}):s?n.jsx("div",{className:"mx-auto max-w-3xl space-y-6 p-6",children:n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:(a==null?void 0:a.title)??"Course Preview"}),n.jsx($e,{children:"Auto-generated course preview"})]}),n.jsxs(U,{className:"space-y-4",children:[n.jsxs(ua,{className:"h-64 rounded-md border p-4 text-sm",children:[n.jsx("p",{className:"mb-2 font-medium",children:"Modules"}),n.jsx("ul",{className:"list-inside list-disc space-y-1",children:((a==null?void 0:a.modules)??[]).map(u=>n.jsxs("li",{children:[u.title," · ",u.estimated_hours,"h · ",u.skill]},u.id))})]}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(E,{type:"button",asChild:!0,children:n.jsx(Dt,{to:`/student/course/${(a==null?void 0:a.id)??t}`,children:"Start Course"})}),n.jsx(E,{type:"button",variant:"outline",asChild:!0,children:n.jsx(Dt,{to:`/admin/course/configure/${(a==null?void 0:a.id)??t}?path=entity`,children:"Customize"})})]})]})]})}):n.jsxs("div",{className:"mx-auto max-w-3xl space-y-6 p-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Configure course"}),n.jsxs("p",{className:"text-muted-foreground",children:["Course #",t]})]}),n.jsx(Wl,{...c,children:n.jsxs("form",{onSubmit:c.handleSubmit(d),className:"space-y-6",children:[n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{children:"Basics"})}),n.jsxs(U,{className:"space-y-4",children:[n.jsx(et,{control:c.control,name:"title",render:({field:u})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Course Title"}),n.jsx(rt,{children:n.jsx(G,{...u})}),n.jsx(ot,{})]})}),n.jsx(et,{control:c.control,name:"exam_type",render:({field:u})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Exam Type"}),n.jsx(rt,{children:n.jsx(G,{...u})}),n.jsx(ot,{})]})}),n.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[n.jsx(et,{control:c.control,name:"target_band",render:({field:u})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Target Band"}),n.jsx(rt,{children:n.jsx(G,{type:"number",step:"0.5",...u,value:u.value??""})}),n.jsx(ot,{})]})}),n.jsx(et,{control:c.control,name:"target_level",render:({field:u})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Target Level"}),n.jsx(rt,{children:n.jsx(G,{...u,value:u.value??""})}),n.jsx(ot,{})]})})]}),n.jsx(et,{control:c.control,name:"duration_weeks",render:({field:u})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Duration (weeks)"}),n.jsx(rt,{children:n.jsx(G,{type:"number",...u})}),n.jsx(ot,{})]})}),n.jsx(et,{control:c.control,name:"study_hours_week",render:({field:u})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Study Hours / Week"}),n.jsx(rt,{children:n.jsx(oa,{min:1,max:40,step:1,value:[u.value],onValueChange:f=>u.onChange(f[0])})}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.value," h"]}),n.jsx(ot,{})]})})]})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{children:"Skills"})}),n.jsxs(U,{className:"space-y-4",children:[n.jsx(et,{control:c.control,name:"skills",render:()=>n.jsxs(tt,{children:[n.jsx("div",{className:"space-y-2",children:Eg.map(u=>n.jsx(et,{control:c.control,name:"skills",render:({field:f})=>n.jsxs(tt,{className:"flex items-center space-x-2 space-y-0",children:[n.jsx(rt,{children:n.jsx(an,{checked:f.value.includes(u),onCheckedChange:h=>{h===!0?f.onChange([...f.value,u]):f.onChange(f.value.filter(y=>y!==u))}})}),n.jsx(at,{className:"font-normal",children:u})]})},u))}),n.jsx(ot,{})]})}),Eg.map(u=>n.jsx(et,{control:c.control,name:`skill_weightings.${u}`,render:({field:f})=>n.jsxs(tt,{children:[n.jsxs(at,{children:[u," weight"]}),n.jsx(rt,{children:n.jsx(oa,{min:0,max:100,step:5,value:[f.value??0],onValueChange:h=>f.onChange(h[0])})}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[f.value??0,"%"]}),n.jsx(ot,{})]})},u))]})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{children:"Progression"})}),n.jsx(U,{children:n.jsx(et,{control:c.control,name:"progression_model",render:({field:u})=>n.jsxs(tt,{className:"space-y-3",children:[n.jsx(rt,{children:n.jsx(es,{value:u.value,onValueChange:u.onChange,className:"grid gap-3 md:grid-cols-3",children:["linear","parallel","adaptive"].map(f=>n.jsxs("div",{className:"flex items-start space-x-3 rounded-lg border p-4",children:[n.jsx(Bn,{value:f,id:`prog-${f}`}),n.jsxs("div",{className:"space-y-1 leading-none",children:[n.jsx(q,{htmlFor:`prog-${f}`,className:"font-medium capitalize",children:f}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:[f==="linear"&&"Sequential modules",f==="parallel"&&"Multiple tracks",f==="adaptive"&&"Adjusts to performance"]})]})]},f))})}),n.jsx(ot,{})]})})})]}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(E,{type:"submit",disabled:o.isPending,children:"Save changes"}),n.jsx(E,{type:"button",variant:"secondary",onClick:()=>l.mutate({title:`${c.getValues("title")} (copy)`,duration_weeks:c.getValues("duration_weeks"),study_hours_week:c.getValues("study_hours_week"),skills:c.getValues("skills"),skill_weightings:c.getValues("skill_weightings"),progression_model:c.getValues("progression_model")}),disabled:l.isPending,children:"Duplicate as new"})]})]})})]})}function lFe(){const{courseId:e}=Ht(),t=Number(e),{data:r,isLoading:s}=rA(t),a=MW(),[i,o]=p.useState(null),[l,c]=p.useState(!1),[d,u]=p.useState(!1),[f,h]=p.useState({topic:"",difficulty:"B2",type:"reading"}),[m,y]=p.useState(null),x=i??(r==null?void 0:r.modules)??[],j=p.useMemo(()=>{const S=new Map;return x.forEach(_=>{const C=_.skill||"General";S.has(C)||S.set(C,[]),S.get(C).push(_)}),S},[x]),v=x.reduce((S,_)=>S+_.estimated_hours,0),g=S=>{o(S),r&&a.mutate({courseId:t,payload:{modules:S}})},b=S=>y(S),N=S=>{if(m===null||m===S)return;const _=[...x],C=_.findIndex(z=>z.id===m),P=_.findIndex(z=>z.id===S);if(C<0||P<0)return;const[D]=_.splice(C,1);_.splice(P,0,D),g(_),y(null)},w=()=>{a.mutate({courseId:t,payload:{status:"published"}})};return s?n.jsxs("div",{className:"p-6",children:[n.jsx(Wt,{className:"mb-4 h-10 w-64"}),n.jsx(Wt,{className:"h-96 w-full"})]}):n.jsxs("div",{className:"mx-auto max-w-5xl space-y-6 p-6",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Module builder"}),n.jsxs("p",{className:"text-muted-foreground",children:[(r==null?void 0:r.title)??`Course #${t}`," · ",v,"h total · ",x.length," modules"]})]}),n.jsx(E,{type:"button",onClick:w,disabled:a.isPending,children:"Publish Course"})]}),n.jsxs("div",{className:"space-y-4",children:[x.length===0&&n.jsx(W,{children:n.jsxs(U,{className:"flex flex-col items-center justify-center py-16 text-center",children:[n.jsx(lt,{className:"h-10 w-10 text-muted-foreground mb-4"}),n.jsx("h3",{className:"text-lg font-medium mb-1",children:"No modules yet"}),n.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Add modules manually or use the AI assistant to auto-generate a module structure."}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(E,{type:"button",onClick:()=>{const S=[{id:Date.now(),title:"New Module",skill:"Listening",estimated_hours:2,resources:[],assessment_type:"quiz"}];g(S)},children:"Add Module"}),n.jsxs(E,{type:"button",variant:"outline",onClick:()=>u(!0),children:[n.jsx(lt,{className:"mr-2 h-4 w-4"}),"AI Generate"]})]})]})}),Array.from(j.entries()).map(([S,_])=>n.jsx(fr,{defaultOpen:!0,children:n.jsxs(W,{children:[n.jsx(mr,{asChild:!0,children:n.jsxs(se,{className:"flex cursor-pointer flex-row items-center justify-between",children:[n.jsxs(ie,{className:"text-lg",children:[S," · ",_.reduce((C,P)=>C+P.estimated_hours,0),"h · ",_.length," modules"]}),n.jsx(rr,{className:"h-5 w-5"})]})}),n.jsx(hr,{children:n.jsx(U,{className:"space-y-4 pt-0",children:_.map((C,P)=>n.jsxs("div",{draggable:!0,onDragStart:()=>b(C.id),onDragOver:D=>D.preventDefault(),onDrop:()=>N(C.id),className:he("rounded-lg border p-4",m===C.id&&"opacity-60"),children:[n.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[n.jsx(uk,{className:"h-5 w-5 text-muted-foreground"}),n.jsxs("span",{className:"font-medium",children:["Module ",P+1,": ",C.title]})]}),n.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:`t-${C.id}`,children:"Title"}),n.jsx(G,{id:`t-${C.id}`,defaultValue:C.title,onBlur:D=>{const z=x.map(O=>O.id===C.id?{...O,title:D.target.value}:O);g(z)}})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:`h-${C.id}`,children:"Hours"}),n.jsx(G,{id:`h-${C.id}`,type:"number",defaultValue:C.estimated_hours,onBlur:D=>{const z=Number(D.target.value),O=x.map(V=>V.id===C.id?{...V,estimated_hours:z}:V);g(O)}})]})]}),n.jsxs("div",{className:"mt-3 space-y-2",children:[n.jsx(q,{children:"Resources"}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[C.resources.map(D=>n.jsxs("span",{className:"rounded-md bg-muted px-2 py-1 text-xs",children:[D.title," (",D.type,")"]},D.id)),n.jsxs(E,{type:"button",size:"sm",variant:"outline",onClick:()=>c(!0),children:[n.jsx(en,{className:"mr-1 h-3 w-3"}),"Browse Resources"]})]})]}),n.jsxs("div",{className:"mt-3 space-y-2",children:[n.jsx(q,{htmlFor:`ex-${C.id}`,children:"Practice exercises"}),n.jsx(on,{id:`ex-${C.id}`,placeholder:"Describe linked exercises",rows:2})]}),n.jsxs("div",{className:"mt-3 grid gap-3 md:grid-cols-2",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Completion criteria"}),n.jsxs(Oe,{defaultValue:C.completion_criteria,onValueChange:D=>{const z=D,O=x.map(V=>V.id===C.id?{...V,completion_criteria:z}:V);g(O)},children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Criteria"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"complete_all",children:"complete_all"}),n.jsx(Y,{value:"score_threshold",children:"score_threshold"}),n.jsx(Y,{value:"teacher_approval",children:"teacher_approval"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:`pre-${C.id}`,children:"Prerequisite module id"}),n.jsx(G,{id:`pre-${C.id}`,type:"number",defaultValue:C.prerequisite_module_id??"",onBlur:D=>{const z=D.target.value?Number(D.target.value):void 0,O=x.map(V=>V.id===C.id?{...V,prerequisite_module_id:z}:V);g(O)}})]})]}),n.jsx(qs,{className:"my-3"}),n.jsxs(E,{type:"button",size:"sm",variant:"secondary",onClick:()=>u(!0),children:[n.jsx(lt,{className:"mr-1 h-3 w-3"}),"Generate AI Content"]})]},C.id))})})]})},S))]}),n.jsx(Qe,{open:l,onOpenChange:c,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Resource search"})}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(G,{placeholder:"Search title, skill, or tag"}),n.jsx(ua,{className:"h-48 rounded-md border p-2 text-sm text-muted-foreground",children:"Matching resources will list here from your library."})]}),n.jsx(Ct,{children:n.jsx(E,{type:"button",variant:"outline",onClick:()=>c(!1),children:"Close"})})]})}),n.jsx(Qe,{open:d,onOpenChange:u,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Generate AI content"})}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"ai-topic",children:"Topic"}),n.jsx(G,{id:"ai-topic",value:f.topic,onChange:S=>h(_=>({..._,topic:S.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"ai-diff",children:"Difficulty"}),n.jsx(G,{id:"ai-diff",value:f.difficulty,onChange:S=>h(_=>({..._,difficulty:S.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"ai-type",children:"Type"}),n.jsx(G,{id:"ai-type",value:f.type,onChange:S=>h(_=>({..._,type:S.target.value}))})]})]}),n.jsx(Ct,{children:n.jsx(E,{type:"button",onClick:()=>{nc.generateAIResource({topic:f.topic,difficulty:f.difficulty,type:f.type}).then(()=>u(!1))},children:"Generate"})})]})})]})}function cFe(){const{courseId:e}=Ht(),t=Number(e),[r,s]=p.useState("student_name"),[a,i]=p.useState(""),[o,l]=p.useState(null),{data:c,isLoading:d}=ye({queryKey:["course",t,"teacher-progress"],queryFn:()=>nc.getCourse(t),enabled:Number.isFinite(t)&&t>0}),u=p.useMemo(()=>{const h=c==null?void 0:c.student_progress;return h!=null&&h.length?h:[{student_name:"Amina Rahman",overall_progress:62,current_module:"Writing · Task Achievement",time_spent_hours:14,predicted_band_delta:.5,last_activity:new Date().toISOString(),days_idle:1},{student_name:"Leo Park",overall_progress:12,current_module:"Listening · Section 2",time_spent_hours:3,predicted_band_delta:.1,last_activity:new Date(Date.now()-4*864e5).toISOString(),days_idle:4}]},[c]),f=p.useMemo(()=>{const h=a.trim().toLowerCase(),m=h?u.filter(y=>y.student_name.toLowerCase().includes(h)):[...u];return m.sort((y,x)=>{const j=y[r],v=x[r];return typeof j=="number"&&typeof v=="number"?v-j:String(j).localeCompare(String(v))}),m},[u,r,a]);return d?n.jsxs("div",{className:"p-6",children:[n.jsx(Wt,{className:"mb-4 h-10 w-64"}),n.jsx(Wt,{className:"h-72 w-full"})]}):n.jsxs("div",{className:"mx-auto max-w-6xl space-y-6 p-6",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Course progress"}),n.jsx("p",{className:"text-muted-foreground",children:(c==null?void 0:c.title)??`Course ${t}`})]}),n.jsx(G,{placeholder:"Filter by name",className:"max-w-xs",value:a,onChange:h=>i(h.target.value)})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{children:"Students"})}),n.jsx(U,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{className:"cursor-pointer",onClick:()=>s("student_name"),children:"Student Name"}),n.jsx(L,{className:"cursor-pointer",onClick:()=>s("overall_progress"),children:"Overall Progress"}),n.jsx(L,{children:"Current Module"}),n.jsx(L,{className:"cursor-pointer",onClick:()=>s("time_spent_hours"),children:"Time Spent (h)"}),n.jsx(L,{className:"cursor-pointer",onClick:()=>s("predicted_band_delta"),children:"Predicted Δ Band"}),n.jsx(L,{className:"cursor-pointer",onClick:()=>s("last_activity"),children:"Last Activity"}),n.jsx(L,{className:"w-12",children:"Alert"})]})}),n.jsx(Be,{children:f.map(h=>{const m=h.days_idle>=3;return n.jsxs(ee,{children:[n.jsx(T,{children:n.jsx(E,{type:"button",variant:"link",className:"h-auto p-0 font-medium",onClick:()=>l(h),children:h.student_name})}),n.jsx(T,{children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(kn,{value:h.overall_progress,className:"h-2 w-28"}),n.jsxs("span",{className:"text-xs tabular-nums",children:[h.overall_progress,"%"]})]})}),n.jsx(T,{className:"max-w-[200px] truncate",children:h.current_module}),n.jsx(T,{children:h.time_spent_hours}),n.jsxs(T,{children:["+",h.predicted_band_delta.toFixed(1)]}),n.jsx(T,{className:"whitespace-nowrap text-xs text-muted-foreground",children:new Date(h.last_activity).toLocaleString()}),n.jsx(T,{children:m?n.jsx("span",{className:"text-amber-600",title:"No progress 3+ days",children:n.jsx(Pl,{className:"h-4 w-4"})}):n.jsx(oe,{variant:"outline",children:"OK"})})]},h.student_name)})})]})})]}),o?n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{children:o.student_name})}),n.jsxs(U,{className:"space-y-2 text-sm",children:[n.jsxs("p",{children:[n.jsx("span",{className:"text-muted-foreground",children:"Current module:"})," ",o.current_module]}),n.jsxs("p",{children:[n.jsx("span",{className:"text-muted-foreground",children:"Time spent:"})," ",o.time_spent_hours," h"]}),n.jsxs("p",{children:[n.jsx("span",{className:"text-muted-foreground",children:"Predicted band improvement:"})," +",o.predicted_band_delta.toFixed(1)]})]})]}):null]})}const Od={start:e=>R.post("/placement/start",{subject:e}),submitAnswer:e=>R.post("/placement/answer",e),autoSave:e=>R.post("/placement/autosave",e),uploadSpeaking:(e,t,r)=>{const s=new FormData;return s.append("session_id",e),s.append("prompt_id",String(t)),s.append("audio_file",r),R.upload("/placement/speaking-upload",s)},getResults:e=>R.get("/placement/results",{session_id:e}),getSpeakingStatus:e=>R.get("/placement/speaking-status",{session_id:e}),getLearningPath:e=>R.get("/placement/learning-path",{session_id:e}),startTrial:()=>R.post("/subscription/trial")};function dFe(){return ae({mutationFn:e=>Od.start(e)})}function uFe(){return ae({mutationFn:e=>Od.submitAnswer(e)})}function fFe(){return ae({mutationFn:e=>Od.autoSave(e)})}function mFe(e){return ye({queryKey:de.placement.results(e),queryFn:()=>Od.getResults(e),enabled:!!e})}function hFe(e,t){return ye({queryKey:de.placement.speakingStatus(e),queryFn:()=>Od.getSpeakingStatus(e),enabled:!!e&&t,refetchInterval:3e4})}function pFe(e){return ye({queryKey:de.placement.learningPath(e),queryFn:()=>Od.getLearningPath(e),enabled:!!e})}const xFe=[{name:"Grammar",detail:"~30 MCQ",time:"~8 min"},{name:"Vocabulary",detail:"~20 items",time:"~5 min"},{name:"Reading",detail:"~10 Q / 2 passages",time:"~10 min"},{name:"Speaking",detail:"3 prompts",time:"~5 min"}];function gFe(){const e=Bt(),t=dFe(),[r,s]=p.useState(null),a=async()=>{s(null);const i="english";try{const o=await t.mutateAsync(i);sessionStorage.setItem(`placement_session_${o.session_id}`,JSON.stringify({question:o.first_question})),e(`/student/placement/test?session=${encodeURIComponent(o.session_id)}`,{state:{question:o.first_question,sessionId:o.session_id}})}catch(o){s(o instanceof Va?o.message:"Could not start the test")}};return n.jsxs("div",{className:"space-y-8 max-w-4xl mx-auto py-6 px-4",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Placement test"}),n.jsx("p",{className:"text-muted-foreground mt-1",children:"Adaptive English placement across four skills."})]}),n.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[n.jsxs(W,{className:"border-0 shadow-md bg-gradient-to-br from-primary/10 to-transparent",children:[n.jsxs(se,{className:"pb-2",children:[n.jsx(vd,{className:"h-5 w-5 text-primary mb-1"}),n.jsx(ie,{className:"text-base",children:"Duration"})]}),n.jsxs(U,{children:[n.jsx("p",{className:"text-2xl font-semibold tabular-nums",children:"20–30 min"}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Pace yourself; timer tracks elapsed time."})]})]}),n.jsxs(W,{className:"border-0 shadow-md",children:[n.jsxs(se,{className:"pb-2",children:[n.jsx(oo,{className:"h-5 w-5 text-primary mb-1"}),n.jsx(ie,{className:"text-base",children:"Sections"})]}),n.jsxs(U,{children:[n.jsx("p",{className:"text-2xl font-semibold",children:"4"}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Grammar, vocabulary, reading, speaking."})]})]}),n.jsxs(W,{className:"border-0 shadow-md",children:[n.jsxs(se,{className:"pb-2",children:[n.jsx(lt,{className:"h-5 w-5 text-primary mb-1"}),n.jsx(ie,{className:"text-base",children:"Adaptive"})]}),n.jsxs(U,{children:[n.jsx(oe,{variant:"secondary",className:"mb-1",children:"CAT-style"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Difficulty adjusts based on your responses."})]})]})]}),n.jsxs(W,{className:"border-0 shadow-lg",children:[n.jsxs(se,{children:[n.jsx(ie,{children:"What to expect"}),n.jsx($e,{children:"Approximate structure per dimension"})]}),n.jsx(U,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Dimension"}),n.jsx(L,{children:"Format"}),n.jsx(L,{className:"text-right",children:"Time"})]})}),n.jsx(Be,{children:xFe.map(i=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:i.name}),n.jsx(T,{className:"text-muted-foreground",children:i.detail}),n.jsx(T,{className:"text-right tabular-nums",children:i.time})]},i.name))})]})})]}),r&&n.jsxs(td,{variant:"destructive",children:[n.jsx(nd,{children:"Error"}),n.jsx(rd,{children:r})]}),n.jsx("div",{className:"flex justify-end",children:n.jsx(E,{size:"lg",className:"min-w-[160px]",onClick:()=>void a(),disabled:t.isPending,children:t.isPending?n.jsxs(n.Fragment,{children:[n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Starting"]}):"Begin Test"})})]})}function CN(e){return e.charAt(0).toUpperCase()+e.slice(1)}function vFe(){var B;const[e]=wo(),t=e.get("session")||"",r=Bt(),a=Ka().state,i=uFe(),o=fFe(),[l,c]=p.useState(null),[d,u]=p.useState(!0),[f,h]=p.useState(!1),[m,y]=p.useState(null),[x,j]=p.useState(null),[v,g]=p.useState(""),[b,N]=p.useState([]),w=p.useRef(Date.now()),S=p.useRef(null);p.useEffect(()=>{if(!t){r("/student/placement",{replace:!0});return}const I=a==null?void 0:a.question,k=sessionStorage.getItem(`placement_session_${t}`);let M=null;if(k)try{M=JSON.parse(k).question??null}catch{M=null}const K=I??M;K&&(c(K),w.current=Date.now()),u(!1)},[t,r,a]),p.useEffect(()=>{l&&(g(""),N([]),w.current=Date.now())},[l==null?void 0:l.id]),p.useEffect(()=>{if(!l)return;const I=l.id;l.type==="mcq_multi"?S.current={question_id:I,answer:b}:S.current={question_id:I,answer:v}},[l,v,b]),p.useEffect(()=>{if(!t||!S.current)return;const I=window.setInterval(()=>{const k=S.current;k&&o.mutate({session_id:t,current_answer:k})},1e4);return()=>window.clearInterval(I)},[t,o]);const _=p.useRef(0),[,C]=p.useState(0);p.useEffect(()=>{const I=window.setInterval(()=>{_.current+=1,C(k=>k+1)},1e3);return()=>window.clearInterval(I)},[]);const P=I=>{const k=Math.floor(I/60),M=I%60;return`${k}:${M.toString().padStart(2,"0")}`},D=()=>l?l.type==="mcq_multi"?b:l.type==="gap_fill"?v.trim():v:"",z=async()=>{if(!l||!t)return;const I=Date.now()-w.current;h(!0);try{const k=await i.mutateAsync({session_id:t,question_id:l.id,answer:D(),time_spent_ms:I});if(k.progress&&y(k.progress),k.test_complete){r(`/student/placement/results?session=${encodeURIComponent(t)}`);return}if(k.section_complete&&k.next_question){j({from:l.section,to:k.next_question.section,nextQuestion:k.next_question});return}k.next_question&&(c(k.next_question),sessionStorage.setItem(`placement_session_${t}`,JSON.stringify({question:k.next_question})))}finally{h(!1)}},O=()=>{!x||!t||(c(x.nextQuestion),sessionStorage.setItem(`placement_session_${t}`,JSON.stringify({question:x.nextQuestion})),j(null))},V=I=>{N(k=>k.includes(I)?k.filter(M=>M!==I):[...k,I])},A=m??{current:l!=null&&l.estimated_total?1:0,estimated_total:(l==null?void 0:l.estimated_total)??0},$=A.estimated_total>0&&A.current>=A.estimated_total;return t?!d&&!l&&!x?n.jsx("div",{className:"min-h-screen flex items-center justify-center p-6 bg-background",children:n.jsxs(W,{className:"max-w-md w-full border-0 shadow-lg",children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Session unavailable"}),n.jsx($e,{children:"Return to the briefing and start the test again."})]}),n.jsx(U,{children:n.jsx(E,{onClick:()=>r("/student/placement"),children:"Back"})})]})}):x?n.jsxs("div",{className:"min-h-screen flex flex-col bg-background",children:[n.jsxs("header",{className:"border-b px-6 py-4 flex items-center justify-between bg-card/80 backdrop-blur",children:[n.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Section complete"}),n.jsx("span",{className:"text-sm tabular-nums",children:P(_.current)})]}),n.jsx("main",{className:"flex-1 flex items-center justify-center p-6",children:n.jsxs(W,{className:"max-w-lg w-full border-0 shadow-xl text-center",children:[n.jsxs(se,{children:[n.jsxs(ie,{children:[CN(x.from)," complete. Next: ",CN(x.to)]}),n.jsx($e,{children:"Take a short breath — continue when you're ready."})]}),n.jsx(U,{children:n.jsx(E,{size:"lg",className:"w-full",onClick:O,children:"Continue"})})]})})]}):n.jsxs("div",{className:"min-h-screen flex flex-col bg-gradient-to-b from-muted/20 to-background",children:[n.jsxs("header",{className:"sticky top-0 z-10 border-b px-4 md:px-8 py-3 flex flex-wrap items-center gap-4 justify-between bg-card/90 backdrop-blur supports-[backdrop-filter]:bg-card/80",children:[n.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[n.jsx("span",{className:"text-sm font-semibold tabular-nums text-primary",children:P(_.current)}),n.jsx("span",{className:"text-sm font-medium truncate",children:l?CN(l.section):"…"})]}),n.jsxs("div",{className:"flex items-center gap-3 flex-1 max-w-md min-w-[200px]",children:[n.jsx(kn,{value:A.estimated_total?Math.min(100,A.current/A.estimated_total*100):0,className:"h-2 flex-1"}),n.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap tabular-nums",children:["Question ",A.current," of ~",A.estimated_total||"?"]})]})]}),n.jsx("main",{className:"flex-1 flex items-stretch justify-center p-4 md:p-8",children:n.jsx("div",{className:"w-full max-w-3xl",children:d||f||!l?n.jsxs("div",{className:"space-y-4",children:[n.jsx(Wt,{className:"h-8 w-3/4"}),n.jsx(Wt,{className:"h-24 w-full"}),n.jsx(Wt,{className:"h-10 w-full"})]}):n.jsx(W,{className:"border-0 shadow-lg",children:n.jsxs(U,{className:"pt-8 space-y-8",children:[l.passage_text&&n.jsx("div",{className:"rounded-lg bg-muted/50 p-4 text-sm leading-relaxed whitespace-pre-wrap",children:l.passage_text}),n.jsx("p",{className:"text-lg font-medium leading-snug",children:l.stem}),(l.type==="mcq"||l.type==="definition_match")&&l.options&&n.jsx(es,{value:v,onValueChange:g,className:"space-y-3",children:l.options.map(I=>n.jsxs("label",{className:he("flex cursor-pointer items-center gap-3 rounded-lg border p-4 transition-colors",v===I.label&&"border-primary bg-primary/5"),children:[n.jsx(Bn,{value:I.label,id:`opt-${I.label}`}),n.jsx("span",{className:"text-sm leading-snug",children:I.text})]},I.label))}),l.type==="mcq_multi"&&l.options&&n.jsx("div",{className:"space-y-3",children:l.options.map(I=>n.jsxs("label",{className:"flex cursor-pointer items-center gap-3 rounded-lg border p-4",children:[n.jsx(an,{checked:b.includes(I.label),onCheckedChange:()=>V(I.label)}),n.jsx("span",{className:"text-sm",children:I.text})]},I.label))}),l.type==="gap_fill"&&n.jsx(G,{value:v,onChange:I=>g(I.target.value),placeholder:"Your answer",className:"text-base"}),l.type==="tfng"&&n.jsx(es,{value:v,onValueChange:g,className:"space-y-3",children:((B=l.options)!=null&&B.length?l.options:[{label:"T",text:"True"},{label:"F",text:"False"},{label:"NG",text:"Not Given"}]).map(I=>n.jsxs("label",{className:he("flex cursor-pointer items-center gap-3 rounded-lg border p-4",v===I.label&&"border-primary bg-primary/5"),children:[n.jsx(Bn,{value:I.label,id:`tfng-${I.label}`}),n.jsx("span",{className:"text-sm",children:I.text})]},I.label))}),l.type==="audio_recording"&&n.jsxs("div",{className:"flex flex-col items-center gap-4 py-8 rounded-xl border border-dashed bg-muted/30",children:[n.jsx(Pj,{className:"h-12 w-12 text-muted-foreground"}),n.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-sm",children:"Recording will be available in a future update. Use the button below to proceed for now."}),n.jsx(E,{type:"button",variant:"secondary",size:"lg",disabled:!0,children:"Record (placeholder)"})]}),n.jsx("div",{className:"flex justify-end pt-4",children:n.jsx(E,{size:"lg",className:"min-w-[160px]",disabled:i.isPending||f,onClick:()=>void z(),children:i.isPending||f?n.jsxs(n.Fragment,{children:[n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving"]}):$?"Finish Test":"Submit answer"})})]})})})})]}):null}function yFe(e){switch(e){case"c2":case"c1":return"bg-violet-600 hover:bg-violet-600 text-white border-0";case"b2":case"b1":return"bg-emerald-600 hover:bg-emerald-600 text-white border-0";case"a2":case"a1":case"pre_a1":return"bg-amber-600 hover:bg-amber-600 text-white border-0";default:return""}}const jFe={pre_a1:"Pre-A1",a1:"A1",a2:"A2",b1:"B1",b2:"B2",c1:"C1",c2:"C2"};function kN(e){return jFe[e]??e}function bFe(){var c,d,u;const[e]=wo(),t=e.get("session")||"",r=Bt(),s=mFe(t),a=pFe(t),i=((c=s.data)==null?void 0:c.speaking_status)==="pending",o=hFe(t,i),l=p.useMemo(()=>{var f;return(f=s.data)!=null&&f.dimensions.length?s.data.dimensions.map(h=>({dimension:h.dimension,score:h.score,fullMark:100})):[]},[s.data]);return t?n.jsxs("div",{className:"max-w-5xl mx-auto py-8 px-4 space-y-10",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Your placement results"}),n.jsx("p",{className:"text-muted-foreground mt-2",children:"Personalized snapshot before your course begins."})]}),s.isLoading&&n.jsxs("div",{className:"space-y-6",children:[n.jsx(Wt,{className:"h-40 w-full rounded-xl"}),n.jsx(Wt,{className:"h-64 w-full rounded-xl"})]}),s.error&&n.jsx(W,{className:"border-destructive/50 bg-destructive/5",children:n.jsxs(U,{className:"pt-6",children:[n.jsx("p",{className:"text-destructive text-sm",children:s.error.message}),n.jsx(E,{className:"mt-4",variant:"outline",onClick:()=>s.refetch(),children:"Retry"})]})}),s.data&&n.jsxs(n.Fragment,{children:[n.jsx(W,{className:"border-0 shadow-lg overflow-hidden",children:n.jsxs("div",{className:"bg-gradient-to-r from-primary/15 via-primary/5 to-transparent p-8 flex flex-col md:flex-row md:items-center md:justify-between gap-6",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wide",children:"Overall level"}),n.jsx("p",{className:"text-4xl md:text-5xl font-bold mt-2 tabular-nums",children:kN(s.data.overall_cefr)})]}),n.jsxs(oe,{className:he("text-lg px-4 py-2",yFe(s.data.overall_cefr)),children:["CEFR ",kN(s.data.overall_cefr)]})]})}),n.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[n.jsxs(W,{className:"border-0 shadow-md",children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Skill profile"}),n.jsx($e,{children:"Relative strength across dimensions"})]}),n.jsx(U,{className:"h-[320px]",children:l.length>0?n.jsx(Xn,{width:"100%",height:"100%",children:n.jsxs(nW,{data:l,children:[n.jsx(BP,{}),n.jsx(Ed,{dataKey:"dimension",tick:{fontSize:11}}),n.jsx(Ad,{angle:90,domain:[0,100],tick:!1}),n.jsx(pm,{name:"Score",dataKey:"score",stroke:"hsl(var(--primary))",fill:"hsl(var(--primary))",fillOpacity:.35})]})}):n.jsx("p",{className:"text-sm text-muted-foreground",children:"No dimension data."})})]}),n.jsxs(W,{className:"border-0 shadow-md",children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Detailed scores"}),n.jsx($e,{children:"Gap to target highlights where to focus first"})]}),n.jsxs(U,{children:[n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Dimension"}),n.jsx(L,{className:"text-right",children:"Score"}),n.jsx(L,{children:"CEFR"}),n.jsx(L,{children:"Gap"})]})}),n.jsx(Be,{children:s.data.dimensions.map(f=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:f.dimension}),n.jsx(T,{className:"text-right tabular-nums",children:f.score.toFixed(1)}),n.jsx(T,{children:f.cefr_level?n.jsx(oe,{variant:"outline",children:kN(f.cefr_level)}):"—"}),n.jsx(T,{className:"text-muted-foreground text-sm",children:f.gap_to_target})]},f.dimension))})]}),n.jsxs("div",{className:"mt-4 flex items-center gap-2 text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Speaking:"}),(((d=o.data)==null?void 0:d.status)==="scored"||s.data.speaking_status==="scored")&&n.jsx(oe,{variant:"secondary",children:"Scored"}),i&&((u=o.data)==null?void 0:u.status)!=="scored"&&n.jsxs(oe,{variant:"outline",className:"gap-1",children:[n.jsx(Re,{className:"h-3 w-3 animate-spin"}),"Pending"]})]})]})]})]}),n.jsxs(W,{className:"border-0 shadow-lg",children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Learning path preview"}),n.jsx($e,{children:"Aligned modules based on your gaps"})]}),n.jsxs(U,{className:"space-y-6",children:[a.isLoading&&n.jsxs("div",{className:"space-y-2",children:[n.jsx(Wt,{className:"h-6 w-2/3"}),n.jsx(Wt,{className:"h-20 w-full"})]}),a.error&&n.jsx("p",{className:"text-sm text-destructive",children:a.error.message}),a.data&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"rounded-xl border bg-muted/30 p-6 space-y-2",children:[n.jsx("h3",{className:"text-lg font-semibold",children:a.data.course_title}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:["~",a.data.estimated_duration_weeks," weeks · ",a.data.module_count," modules ·"," ",a.data.study_hours_per_week," h/week suggested"]})]}),n.jsxs("div",{children:[n.jsx("h4",{className:"font-medium mb-3",children:"Skill gap modules"}),n.jsx("ul",{className:"space-y-3",children:[...a.data.modules].sort((f,h)=>{const m={high:0,medium:1,low:2};return m[f.priority]-m[h.priority]}).map(f=>n.jsxs("li",{className:"flex flex-wrap items-baseline justify-between gap-2 rounded-lg border p-3",children:[n.jsx("span",{className:"font-medium",children:f.name}),n.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[n.jsx(oe,{variant:f.priority==="high"?"destructive":f.priority==="medium"?"default":"secondary",children:f.priority}),n.jsxs("span",{children:[f.estimated_hours,"h"]}),n.jsx("span",{className:"capitalize",children:f.difficulty})]})]},f.name))})]}),n.jsxs(fr,{children:[n.jsxs(mr,{className:"flex items-center gap-2 text-sm font-medium text-primary hover:underline",children:[n.jsx(rr,{className:"h-4 w-4"}),"View full course plan"]}),n.jsx(hr,{className:"mt-4 rounded-lg border bg-card p-4 text-sm text-muted-foreground leading-relaxed",children:a.data.modules.map(f=>n.jsxs("p",{className:"mb-2 last:mb-0",children:[n.jsx("span",{className:"font-medium text-foreground",children:f.name})," — ",f.resource_types.join(", ")]},`${f.name}-detail`))})]})]})]})]}),n.jsx("div",{className:"flex justify-end",children:n.jsx(E,{size:"lg",onClick:()=>r("/student/placement/access"),children:"Continue"})})]})]}):n.jsxs("div",{className:"max-w-lg mx-auto py-16 px-4 text-center",children:[n.jsx("p",{className:"text-muted-foreground mb-4",children:"Missing session."}),n.jsx(E,{variant:"outline",onClick:()=>r("/student/placement"),children:"Back to placement"})]})}const wFe=["Unlimited adaptive lessons","Speaking feedback & analytics","Full placement history","Priority instructor Q&A"],NFe=["7 days full access","Placement results saved","Email reminders before trial ends"],SFe=["Dashboard access","Limited preview content","Upgrade any time"];function _Fe(){const e=Bt(),[t,r]=p.useState(!1),[s,a]=p.useState(null),i=async()=>{a(null),r(!0);try{await Od.startTrial(),e("/student/dashboard")}catch(o){a(o instanceof Va?o.message:"Could not start trial")}finally{r(!1)}};return n.jsxs("div",{className:"max-w-6xl mx-auto py-12 px-4",children:[n.jsxs("div",{className:"text-center mb-10 space-y-2",children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Choose how you want to continue"}),n.jsx("p",{className:"text-muted-foreground max-w-2xl mx-auto",children:"Unlock the full adaptive pathway or explore on your own terms."})]}),s&&n.jsx("p",{className:"text-center text-sm text-destructive mb-6 bg-destructive/10 rounded-lg py-2 px-4 max-w-xl mx-auto",children:s}),n.jsxs("div",{className:"grid gap-6 md:grid-cols-3 items-stretch",children:[n.jsxs(W,{className:"border-2 border-primary shadow-lg flex flex-col",children:[n.jsxs(se,{children:[n.jsx(ie,{className:"text-xl",children:"Full access"}),n.jsx($e,{children:"Best value for serious exam prep"})]}),n.jsx(U,{className:"flex-1 space-y-4",children:n.jsx("ul",{className:"space-y-2",children:wFe.map(o=>n.jsxs("li",{className:"flex gap-2 text-sm",children:[n.jsx(aa,{className:"h-4 w-4 shrink-0 text-primary mt-0.5"}),n.jsx("span",{children:o})]},o))})}),n.jsx(Yg,{children:n.jsx(E,{className:"w-full",size:"lg",onClick:()=>e("/student/subscription"),children:"Subscribe now"})})]}),n.jsxs(W,{className:"border-0 shadow-md bg-muted/40 flex flex-col",children:[n.jsxs(se,{children:[n.jsx(ie,{className:"text-xl",children:"Free trial"}),n.jsx($e,{children:"Try everything for seven days"})]}),n.jsx(U,{className:"flex-1 space-y-4",children:n.jsx("ul",{className:"space-y-2",children:NFe.map(o=>n.jsxs("li",{className:"flex gap-2 text-sm",children:[n.jsx(aa,{className:"h-4 w-4 shrink-0 text-primary mt-0.5"}),n.jsx("span",{children:o})]},o))})}),n.jsx(Yg,{children:n.jsx(E,{className:"w-full",size:"lg",variant:"secondary",disabled:t,onClick:()=>void i(),children:t?n.jsxs(n.Fragment,{children:[n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Starting"]}):"Try free for 7 days"})})]}),n.jsxs(W,{className:"border border-dashed flex flex-col",children:[n.jsxs(se,{children:[n.jsx(ie,{className:"text-xl",children:"Skip for now"}),n.jsx($e,{children:"Head straight to your dashboard"})]}),n.jsx(U,{className:"flex-1 space-y-4",children:n.jsx("ul",{className:"space-y-2",children:SFe.map(o=>n.jsxs("li",{className:"flex gap-2 text-sm text-muted-foreground",children:[n.jsx(aa,{className:"h-4 w-4 shrink-0 mt-0.5"}),n.jsx("span",{children:o})]},o))})}),n.jsx(Yg,{children:n.jsx(E,{className:"w-full",size:"lg",variant:"outline",onClick:()=>e("/student/dashboard"),children:"Continue to dashboard"})})]})]})]})}function CFe(){const{toast:e}=He(),{data:t=[],isLoading:r}=OB(),[s,a]=p.useState(null),{data:i=[],isLoading:o}=TB(s?{category_id:s}:void 0),l=Tce(),c=Mce(),d=Rce(),u=$ce(),f=Ice(),h=Dce(),[m,y]=p.useState(!1),[x,j]=p.useState(""),[v,g]=p.useState("both"),[b,N]=p.useState(!1),[w,S]=p.useState(null),[_,C]=p.useState(""),[P,D]=p.useState(""),[z,O]=p.useState("both"),[V,A]=p.useState(""),[$,B]=p.useState(null),[I,k]=p.useState(""),M=()=>{C(""),D(""),O("both"),A(""),S(null)},K=()=>{l.mutate({name:x,audience:v},{onSuccess:()=>{e({title:"Category Created"}),y(!1),j("")},onError:()=>e({title:"Error",description:"Failed to create category",variant:"destructive"})})},X=()=>{$&&c.mutate({id:$.id,data:{name:I}},{onSuccess:()=>{e({title:"Category Updated"}),B(null)},onError:()=>e({title:"Error",description:"Failed to update category",variant:"destructive"})})},re=me=>{window.confirm("Delete this FAQ category and all its items?")&&d.mutate(me,{onSuccess:()=>{e({title:"Category Deleted"}),s===me&&a(null)},onError:()=>e({title:"Error",description:"Failed to delete category",variant:"destructive"})})},Z=()=>{w?f.mutate({id:w.id,data:{question:_,answer:P,audience:z,video_url:V||void 0}},{onSuccess:()=>{e({title:"Item Updated"}),N(!1),M()},onError:()=>e({title:"Error",description:"Failed to update item",variant:"destructive"})}):s&&u.mutate({question:_,answer:P,category_id:s,audience:z,video_url:V||void 0},{onSuccess:()=>{e({title:"Item Created"}),N(!1),M()},onError:()=>e({title:"Error",description:"Failed to create item",variant:"destructive"})})},te=me=>{window.confirm("Delete this FAQ item?")&&h.mutate(me,{onSuccess:()=>e({title:"Item Deleted"}),onError:()=>e({title:"Error",description:"Failed to delete item",variant:"destructive"})})},xe=me=>{S(me),C(me.question),D(me.answer),O(me.audience),A(me.video_url??""),N(!0)};return r?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"FAQ Manager"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage FAQ categories and items."})]})}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Categories"}),n.jsxs(Qe,{open:m,onOpenChange:y,children:[n.jsx(cr,{asChild:!0,children:n.jsx(E,{variant:"ghost",size:"sm",children:n.jsx(mt,{className:"h-4 w-4"})})}),n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"New Category"})}),n.jsxs("div",{className:"space-y-4 pt-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{placeholder:"Category name",value:x,onChange:me=>j(me.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Audience"}),n.jsxs(Oe,{value:v,onValueChange:me=>g(me),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"both",children:"Both"}),n.jsx(Y,{value:"student",children:"Student"}),n.jsx(Y,{value:"entity",children:"Entity"})]})]})]}),n.jsxs(E,{className:"w-full",onClick:K,disabled:l.isPending||!x,children:[l.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Create"]})]})]})]})]}),t.map(me=>n.jsxs("div",{className:"group relative",children:[n.jsx("button",{onClick:()=>a(me.id),className:`w-full text-left p-3 rounded-lg border transition-colors ${s===me.id?"bg-primary/10 border-primary":"hover:bg-accent"}`,children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(dk,{className:"h-4 w-4 shrink-0"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"text-sm font-medium truncate",children:me.name}),n.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[n.jsxs("span",{children:[me.item_count," items"]}),n.jsx(oe,{variant:"outline",className:"text-xs",children:me.audience})]})]})]})}),n.jsxs("div",{className:"absolute top-2 right-2 hidden group-hover:flex gap-1",children:[n.jsx(E,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>{B(me),k(me.name)},children:n.jsx(Uu,{className:"h-3 w-3"})}),n.jsx(E,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>re(me.id),children:n.jsx($t,{className:"h-3 w-3 text-destructive"})})]})]},me.id)),t.length===0&&n.jsx("p",{className:"text-sm text-muted-foreground px-1",children:"No categories yet."})]}),n.jsx("div",{className:"md:col-span-2",children:s?o?n.jsx("div",{className:"flex items-center justify-center min-h-[300px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h3",{className:"font-medium",children:"FAQ Items"}),n.jsxs(E,{size:"sm",onClick:()=>{M(),N(!0)},children:[n.jsx(mt,{className:"mr-2 h-4 w-4"})," Add Item"]})]}),i.sort((me,ne)=>me.sequence-ne.sequence).map(me=>n.jsx(W,{children:n.jsx(U,{className:"py-4",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx(uk,{className:"h-5 w-5 text-muted-foreground mt-0.5 cursor-grab shrink-0"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"font-medium text-sm",children:me.question}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:me.answer}),n.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[n.jsx(oe,{variant:"outline",className:"text-xs",children:me.audience}),me.video_url&&n.jsx(oe,{variant:"secondary",className:"text-xs",children:"Video"})]})]}),n.jsxs("div",{className:"flex gap-1 shrink-0",children:[n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>xe(me),children:n.jsx(Uu,{className:"h-4 w-4"})}),n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>te(me.id),children:n.jsx($t,{className:"h-4 w-4 text-destructive"})})]})]})})},me.id)),i.length===0&&n.jsx(W,{children:n.jsx(U,{className:"py-8 text-center text-muted-foreground",children:"No items in this category."})})]}):n.jsx(W,{children:n.jsx(U,{className:"py-12 text-center text-muted-foreground",children:"Select a category to manage its FAQ items."})})})]}),n.jsx(Qe,{open:!!$,onOpenChange:me=>{me||B(null)},children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Edit Category"})}),n.jsxs("div",{className:"space-y-4 pt-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{value:I,onChange:me=>k(me.target.value)})]}),n.jsxs(E,{className:"w-full",onClick:X,disabled:c.isPending||!I,children:[c.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})]})]})}),n.jsx(Qe,{open:b,onOpenChange:me=>{N(me),me||M()},children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:w?"Edit FAQ Item":"New FAQ Item"})}),n.jsxs("div",{className:"space-y-4 pt-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Question"}),n.jsx(G,{placeholder:"FAQ question",value:_,onChange:me=>C(me.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Answer (Markdown)"}),n.jsx(on,{placeholder:"Write the answer...",rows:4,value:P,onChange:me=>D(me.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Audience"}),n.jsxs(Oe,{value:z,onValueChange:me=>O(me),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"both",children:"Both"}),n.jsx(Y,{value:"student",children:"Student"}),n.jsx(Y,{value:"entity",children:"Entity"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Video URL (optional)"}),n.jsx(G,{placeholder:"https://...",value:V,onChange:me=>A(me.target.value)})]}),n.jsxs(E,{className:"w-full",onClick:Z,disabled:u.isPending||f.isPending||!_||!P,children:[(u.isPending||f.isPending)&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),w?"Save Changes":"Create Item"]})]})]})})]})}function kFe(){const{toast:e}=He(),{data:t=[],isLoading:r}=Pce(),s=Ace(),a=Ece(),i=Oce(),[o,l]=p.useState(!1),[c,d]=p.useState(null),[u,f]=p.useState(""),[h,m]=p.useState(""),[y,x]=p.useState(1),[j,v]=p.useState("once"),[g,b]=p.useState("in_app"),N=()=>{f(""),m(""),x(1),v("once"),b("in_app"),d(null)},w=P=>{d(P),f(P.name),m(P.event_type),x(P.days_before),v(P.frequency),b(P.channel),l(!0)},S=()=>{const P={name:u,event_type:h,days_before:y,frequency:j,channel:g};c?a.mutate({id:c.id,data:P},{onSuccess:()=>{e({title:"Rule Updated"}),l(!1),N()},onError:()=>e({title:"Error",description:"Failed to update rule",variant:"destructive"})}):s.mutate(P,{onSuccess:()=>{e({title:"Rule Created"}),l(!1),N()},onError:()=>e({title:"Error",description:"Failed to create rule",variant:"destructive"})})},_=P=>{window.confirm("Delete this notification rule?")&&i.mutate(P,{onSuccess:()=>e({title:"Rule Deleted"}),onError:()=>e({title:"Error",description:"Failed to delete rule",variant:"destructive"})})},C=P=>{a.mutate({id:P.id,data:{active:!P.active}},{onSuccess:()=>e({title:P.active?"Rule Deactivated":"Rule Activated"}),onError:()=>e({title:"Error",description:"Failed to toggle rule",variant:"destructive"})})};return r?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Notification Rules"}),n.jsx("p",{className:"text-muted-foreground",children:"Configure automated notification rules and reminders."})]}),n.jsxs(Qe,{open:o,onOpenChange:P=>{l(P),P||N()},children:[n.jsx(cr,{asChild:!0,children:n.jsxs(E,{children:[n.jsx(mt,{className:"mr-2 h-4 w-4"})," Create Rule"]})}),n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:c?"Edit Rule":"Create Notification Rule"})}),n.jsxs("div",{className:"space-y-4 pt-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{placeholder:"Rule name",value:u,onChange:P=>f(P.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Event Type"}),n.jsxs(Oe,{value:h,onValueChange:m,children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select event"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"deadline",children:"Deadline"}),n.jsx(Y,{value:"chapter_unlock",children:"Chapter Unlock"}),n.jsx(Y,{value:"result_release",children:"Result Release"}),n.jsx(Y,{value:"assignment",children:"Assignment"}),n.jsx(Y,{value:"exam",children:"Exam"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Days Before"}),n.jsx(G,{type:"number",min:0,value:y,onChange:P=>x(Number(P.target.value))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Frequency"}),n.jsxs(Oe,{value:j,onValueChange:P=>v(P),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"once",children:"Once"}),n.jsx(Y,{value:"daily",children:"Daily"}),n.jsx(Y,{value:"custom",children:"Custom"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Channel"}),n.jsxs(Oe,{value:g,onValueChange:P=>b(P),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"in_app",children:"In-App"}),n.jsx(Y,{value:"email",children:"Email"}),n.jsx(Y,{value:"both",children:"Both"})]})]})]}),n.jsxs(E,{className:"w-full",onClick:S,disabled:s.isPending||a.isPending||!u||!h,children:[(s.isPending||a.isPending)&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),c?"Save Changes":"Create Rule"]})]})]})]})]}),n.jsx(W,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Event"}),n.jsx(L,{children:"Days Before"}),n.jsx(L,{children:"Frequency"}),n.jsx(L,{children:"Channel"}),n.jsx(L,{children:"Active"}),n.jsx(L,{className:"w-24",children:"Actions"})]})}),n.jsxs(Be,{children:[t.map(P=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:P.name}),n.jsx(T,{children:n.jsx(oe,{variant:"outline",children:P.event_type})}),n.jsx(T,{children:P.days_before}),n.jsx(T,{children:P.frequency}),n.jsx(T,{children:n.jsx(oe,{variant:"secondary",children:P.channel})}),n.jsx(T,{children:n.jsx(Fr,{checked:P.active,onCheckedChange:()=>C(P)})}),n.jsx(T,{children:n.jsxs("div",{className:"flex gap-1",children:[n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>w(P),children:n.jsx(Uu,{className:"h-4 w-4"})}),n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>_(P.id),disabled:i.isPending,children:n.jsx($t,{className:"h-4 w-4 text-destructive"})})]})})]},P.id)),t.length===0&&n.jsx(ee,{children:n.jsxs(T,{colSpan:7,className:"text-center text-muted-foreground py-8",children:[n.jsx(ok,{className:"h-12 w-12 mx-auto mb-3 opacity-40"}),n.jsx("p",{children:"No notification rules configured."})]})})]})]})})]})}function PFe(){const{toast:e}=He(),t=je(),{data:r,isLoading:s}=ye({queryKey:["approvals","list"],queryFn:()=>dg.list()}),a=(r==null?void 0:r.results)??[],i=ae({mutationFn:_=>dg.create(_),onSuccess:()=>t.invalidateQueries({queryKey:["approvals"]}),onError:()=>e({title:"Error",description:"Failed to create workflow",variant:"destructive"})}),o=ae({mutationFn:({id:_,data:C})=>dg.update(_,C),onSuccess:()=>t.invalidateQueries({queryKey:["approvals"]}),onError:()=>e({title:"Error",description:"Failed to update workflow",variant:"destructive"})}),l=ae({mutationFn:_=>dg.delete(_),onSuccess:()=>t.invalidateQueries({queryKey:["approvals"]}),onError:()=>e({title:"Error",description:"Failed to delete workflow",variant:"destructive"})}),[c,d]=p.useState(!1),[u,f]=p.useState(""),[h,m]=p.useState([{order:1,approver_id:0,approver_name:"",max_days:3,auto_escalate:!1}]),[y,x]=p.useState(!1),j=()=>{f(""),m([{order:1,approver_id:0,approver_name:"",max_days:3,auto_escalate:!1}]),x(!1)},v=()=>{m(_=>[..._,{order:_.length+1,approver_id:0,approver_name:"",max_days:3,auto_escalate:!1}])},g=_=>{m(C=>C.filter((P,D)=>D!==_).map((P,D)=>({...P,order:D+1})))},b=(_,C,P)=>{m(D=>D.map((z,O)=>O===_?{...z,[C]:P}:z))},N=()=>{i.mutate({name:u,steps:h.map(_=>({order:_.order,approver_id:_.approver_id,approver_name:_.approver_name})),status:"draft"},{onSuccess:()=>{e({title:"Workflow Created"}),d(!1),j()}})},w=_=>{window.confirm("Delete this approval workflow?")&&l.mutate(_,{onSuccess:()=>e({title:"Workflow Deleted"})})},S=_=>{const C=_.status==="active"?"draft":"active";o.mutate({id:_.id,data:{status:C}},{onSuccess:()=>e({title:`Workflow ${C==="active"?"Activated":"Deactivated"}`})})};return s?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Approval Workflows"}),n.jsx("p",{className:"text-muted-foreground",children:"Configure multi-stage approval workflows with escalation rules."})]}),n.jsxs(Qe,{open:c,onOpenChange:_=>{d(_),_||j()},children:[n.jsx(cr,{asChild:!0,children:n.jsxs(E,{children:[n.jsx(mt,{className:"mr-2 h-4 w-4"})," Create Workflow"]})}),n.jsxs(Ue,{className:"max-w-2xl",children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create Approval Workflow"})}),n.jsxs("div",{className:"space-y-4 pt-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Workflow Name"}),n.jsx(G,{placeholder:"e.g. Leave Approval",value:u,onChange:_=>f(_.target.value)})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(q,{children:"Stages"}),n.jsxs(E,{variant:"outline",size:"sm",onClick:v,children:[n.jsx(mt,{className:"mr-2 h-3 w-3"})," Add Stage"]})]}),h.map((_,C)=>n.jsx(W,{children:n.jsxs(U,{className:"py-3 space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(oe,{variant:"outline",children:["Stage ",_.order]}),h.length>1&&n.jsx(E,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>g(C),children:n.jsx($t,{className:"h-3 w-3 text-destructive"})})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs",children:"Approver Name"}),n.jsx(G,{value:_.approver_name,onChange:P=>b(C,"approver_name",P.target.value),placeholder:"Name"})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs",children:"Approver ID"}),n.jsx(G,{type:"number",value:_.approver_id||"",onChange:P=>b(C,"approver_id",Number(P.target.value)),placeholder:"ID"})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs",children:"Max Days"}),n.jsx(G,{type:"number",min:1,value:_.max_days??3,onChange:P=>b(C,"max_days",Number(P.target.value))})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(q,{className:"text-xs",children:"Email"}),n.jsx(G,{type:"email",value:_.notification_email??"",onChange:P=>b(C,"notification_email",P.target.value),placeholder:"email@..."})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Fr,{checked:!!_.auto_escalate,onCheckedChange:P=>b(C,"auto_escalate",P)}),n.jsx(q,{className:"text-xs",children:"Auto-escalate after max days"})]})]})},C))]}),n.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border",children:[n.jsx(Fr,{checked:y,onCheckedChange:x}),n.jsx(q,{children:"Allow bypass (skip all stages)"})]}),n.jsxs(E,{className:"w-full",onClick:N,disabled:i.isPending||!u||h.length===0,children:[i.isPending&&n.jsx(Re,{className:"mr-2 h-4 w-4 animate-spin"}),"Create Workflow"]})]})]})]})]}),n.jsxs("div",{className:"space-y-4",children:[a.map(_=>n.jsxs(W,{children:[n.jsx(se,{className:"pb-3",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(PE,{className:"h-5 w-5 text-primary"}),n.jsxs("div",{children:[n.jsx(ie,{className:"text-base",children:_.name}),n.jsx($e,{children:_.entity_name})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(oe,{variant:_.status==="active"?"default":"secondary",children:_.status}),n.jsx(Fr,{checked:_.status==="active",onCheckedChange:()=>S(_)}),n.jsx(E,{variant:"ghost",size:"icon",onClick:()=>w(_.id),disabled:l.isPending,children:n.jsx($t,{className:"h-4 w-4 text-destructive"})})]})]})}),n.jsxs(U,{children:[n.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:_.steps.map((C,P)=>n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 rounded-full border bg-muted/50 text-sm",children:[n.jsx("span",{className:"h-5 w-5 rounded-full bg-primary/10 text-primary flex items-center justify-center text-xs font-medium",children:C.order}),n.jsx("span",{children:C.approver_name})]}),P<_.steps.length-1&&n.jsx(Da,{className:"h-4 w-4 text-muted-foreground"})]},P))}),n.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Created: ",new Date(_.created_at).toLocaleDateString()]})]})]},_.id)),a.length===0&&n.jsx(W,{children:n.jsxs(U,{className:"py-12 text-center text-muted-foreground",children:[n.jsx(PE,{className:"h-12 w-12 mx-auto mb-3 opacity-40"}),n.jsx("p",{children:"No approval workflows configured."})]})})]})]})}const Gr={async listRoles(e){return R.get("/roles",e)},async getRole(e){return R.get(`/roles/${e}`)},async createRole(e){return R.post("/roles",e)},async updateRole(e,t){return R.patch(`/roles/${e}`,t)},async deleteRole(e){return R.delete(`/roles/${e}`)},async updateRolePermissions(e,t){return R.patch(`/roles/${e}/permissions`,{permission_ids:t})},async listPermissions(e){return R.get("/permissions",e)},async createPermission(e){return R.post("/permissions",e)},async deletePermission(e){return R.delete(`/permissions/${e}`)},async getAuthorityMatrix(){return R.get("/authority-matrix")},async toggleMatrixCell(e,t){return R.post("/authority-matrix/toggle",{role_id:e,permission_id:t})},async listUsersWithRoles(e){return R.get("/users/with-roles",e)},async getUserRoles(e){return R.get(`/users/${e}/roles`)},async updateUserRoles(e,t){return R.patch(`/users/${e}/roles`,{role_ids:t})},async toggleUserRole(e,t){return R.post(`/users/${e}/roles/toggle`,{role_id:t})},async getUserAuthorityMatrix(){return R.get("/user-authority-matrix")}},AFe={exam:"bg-violet-100 text-violet-700 dark:bg-violet-900 dark:text-violet-300",user:"bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300",entity:"bg-emerald-100 text-emerald-700 dark:bg-emerald-900 dark:text-emerald-300",assignment:"bg-amber-100 text-amber-700 dark:bg-amber-900 dark:text-amber-300",classroom:"bg-rose-100 text-rose-700 dark:bg-rose-900 dark:text-rose-300",payment:"bg-cyan-100 text-cyan-700 dark:bg-cyan-900 dark:text-cyan-300",report:"bg-orange-100 text-orange-700 dark:bg-orange-900 dark:text-orange-300"};function PN(e){return AFe[e.toLowerCase()]??"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"}function EFe(){var xe,me;const{toast:e}=He(),t=je(),[r,s]=p.useState(""),[a,i]=p.useState("roles"),[o,l]=p.useState(!1),[c,d]=p.useState(null),[u,f]=p.useState({name:"",description:""}),[h,m]=p.useState(!1),[y,x]=p.useState({name:"",code:"",description:"",category:""}),[j,v]=p.useState(!1),[g,b]=p.useState(null),[N,w]=p.useState(new Set),S=ye({queryKey:["roles",r],queryFn:()=>Gr.listRoles(r?{search:r}:void 0)}),_=ye({queryKey:["permissions"],queryFn:()=>Gr.listPermissions()}),C=((xe=S.data)==null?void 0:xe.data)??[],P=((me=_.data)==null?void 0:me.data)??[],D=ae({mutationFn:ne=>Gr.createRole(ne),onSuccess:()=>{t.invalidateQueries({queryKey:["roles"]}),l(!1),e({title:"Role created"})},onError:()=>e({title:"Failed to create role",variant:"destructive"})}),z=ae({mutationFn:({id:ne,data:_e})=>Gr.updateRole(ne,_e),onSuccess:()=>{t.invalidateQueries({queryKey:["roles"]}),l(!1),d(null),e({title:"Role updated"})},onError:()=>e({title:"Failed to update role",variant:"destructive"})}),O=ae({mutationFn:Gr.deleteRole,onSuccess:()=>{t.invalidateQueries({queryKey:["roles"]}),e({title:"Role deleted"})},onError:()=>e({title:"Failed to delete role",variant:"destructive"})}),V=ae({mutationFn:({id:ne,permIds:_e})=>Gr.updateRolePermissions(ne,_e),onSuccess:()=>{t.invalidateQueries({queryKey:["roles"]}),v(!1),e({title:"Permissions updated"})},onError:()=>e({title:"Failed to update permissions",variant:"destructive"})}),A=ae({mutationFn:ne=>Gr.createPermission(ne),onSuccess:()=>{t.invalidateQueries({queryKey:["permissions"]}),m(!1),e({title:"Permission created"})},onError:()=>e({title:"Failed to create permission",variant:"destructive"})}),$=ae({mutationFn:Gr.deletePermission,onSuccess:()=>{t.invalidateQueries({queryKey:["permissions"]}),e({title:"Permission deleted"})},onError:()=>e({title:"Failed to delete permission",variant:"destructive"})}),B=S.isLoading||_.isLoading,I=()=>{d(null),f({name:"",description:""}),l(!0)},k=ne=>{d(ne),f({name:ne.name,description:ne.description}),l(!0)},M=ne=>{b(ne),w(new Set(ne.permission_ids)),v(!0)},K=()=>{x({name:"",code:"",description:"",category:""}),m(!0)},X=()=>{u.name.trim()&&(c?z.mutate({id:c.id,data:u}):D.mutate(u))},re=ne=>{w(_e=>{const ue=new Set(_e);return ue.has(ne)?ue.delete(ne):ue.add(ne),ue})},Z=P.reduce((ne,_e)=>{const ue=_e.category||"General";return(ne[ue]??(ne[ue]=[])).push(_e),ne},{}),te=r?P.filter(ne=>ne.name.toLowerCase().includes(r.toLowerCase())||ne.code.toLowerCase().includes(r.toLowerCase())):P;return B?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx(Re,{className:"h-8 w-8 animate-spin text-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[n.jsxs("div",{children:[n.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[n.jsx(Os,{className:"h-7 w-7 text-primary"}),"Roles & Permissions"]}),n.jsx("p",{className:"text-muted-foreground",children:"Manage platform roles and their permission assignments."})]}),n.jsx("div",{className:"flex gap-2",children:a==="roles"?n.jsxs(E,{onClick:I,children:[n.jsx(mt,{className:"mr-2 h-4 w-4"})," New Role"]}):n.jsxs(E,{onClick:K,children:[n.jsx(mt,{className:"mr-2 h-4 w-4"})," New Permission"]})})]}),n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[n.jsx(W,{className:"border-l-4 border-l-primary",children:n.jsx(U,{className:"pt-5 pb-4",children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:n.jsx(Os,{className:"h-5 w-5 text-primary"})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl font-bold",children:C.length}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Roles"})]})]})})}),n.jsx(W,{className:"border-l-4 border-l-amber-500",children:n.jsx(U,{className:"pt-5 pb-4",children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"h-10 w-10 rounded-lg bg-amber-500/10 flex items-center justify-center",children:n.jsx(jc,{className:"h-5 w-5 text-amber-500"})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl font-bold",children:P.length}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Permissions"})]})]})})}),n.jsx(W,{className:"border-l-4 border-l-emerald-500",children:n.jsx(U,{className:"pt-5 pb-4",children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"h-10 w-10 rounded-lg bg-emerald-500/10 flex items-center justify-center",children:n.jsx(as,{className:"h-5 w-5 text-emerald-500"})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl font-bold",children:Object.keys(Z).length}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Permission Categories"})]})]})})})]}),n.jsxs(Us,{value:a,onValueChange:i,children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[n.jsxs(ws,{children:[n.jsxs(Et,{value:"roles",className:"gap-1.5",children:[n.jsx(Os,{className:"h-4 w-4"})," Roles (",C.length,")"]}),n.jsxs(Et,{value:"permissions",className:"gap-1.5",children:[n.jsx(jc,{className:"h-4 w-4"})," Permissions (",P.length,")"]})]}),n.jsxs("div",{className:"relative max-w-xs w-full",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:a==="roles"?"Search roles...":"Search permissions...",className:"pl-9",value:r,onChange:ne=>s(ne.target.value)})]})]}),n.jsx(Lt,{value:"roles",className:"mt-4",children:C.length===0?n.jsx(W,{children:n.jsx(U,{className:"py-16 text-center text-muted-foreground",children:"No roles configured yet. Create one to get started."})}):n.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:C.map(ne=>n.jsxs(W,{className:"group hover:shadow-md transition-shadow",children:[n.jsx(se,{className:"pb-3",children:n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center",children:n.jsx(Os,{className:"h-4 w-4 text-primary"})}),n.jsxs("div",{children:[n.jsx(ie,{className:"text-base",children:ne.name}),n.jsxs($e,{className:"text-xs",children:[ne.user_count," user",ne.user_count!==1?"s":""," assigned"]})]})]}),n.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[n.jsxs(uo,{children:[n.jsx(fo,{asChild:!0,children:n.jsx(E,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>k(ne),children:n.jsx(Uu,{className:"h-3.5 w-3.5"})})}),n.jsx(vi,{children:"Edit"})]}),n.jsxs(uo,{children:[n.jsx(fo,{asChild:!0,children:n.jsx(E,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive",onClick:()=>{window.confirm(`Delete role "${ne.name}"?`)&&O.mutate(ne.id)},children:n.jsx($t,{className:"h-3.5 w-3.5"})})}),n.jsx(vi,{children:"Delete"})]})]})]})}),n.jsxs(U,{className:"space-y-3",children:[ne.description&&n.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:ne.description}),n.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[ne.permissions.slice(0,5).map(_e=>n.jsx(oe,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${PN(_e.category)}`,children:_e.code},_e.id)),ne.permissions.length>5&&n.jsxs(oe,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:["+",ne.permissions.length-5]}),ne.permissions.length===0&&n.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No permissions"})]}),n.jsxs(E,{variant:"outline",size:"sm",className:"w-full mt-2",onClick:()=>M(ne),children:[n.jsx(jc,{className:"mr-1.5 h-3.5 w-3.5"})," Manage Permissions ",n.jsx(Si,{className:"ml-auto h-3.5 w-3.5"})]})]})]},ne.id))})}),n.jsx(Lt,{value:"permissions",className:"mt-4",children:Object.entries(Z).length===0?n.jsx(W,{children:n.jsx(U,{className:"py-16 text-center text-muted-foreground",children:"No permissions defined yet."})}):n.jsx("div",{className:"space-y-4",children:Object.entries(Z).map(([ne,_e])=>{const ue=r?_e.filter(we=>te.includes(we)):_e;return ue.length===0?null:n.jsxs(W,{children:[n.jsx(se,{className:"pb-3",children:n.jsxs(ie,{className:"text-sm font-semibold flex items-center gap-2",children:[n.jsx(oe,{className:`${PN(ne)} font-medium`,children:ne}),n.jsxs("span",{className:"text-muted-foreground text-xs font-normal",children:[ue.length," permission",ue.length!==1?"s":""]})]})}),n.jsx(U,{className:"pt-0",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{className:"w-[200px]",children:"Code"}),n.jsx(L,{children:"Name"}),n.jsx(L,{className:"hidden md:table-cell",children:"Description"}),n.jsx(L,{className:"w-[80px]",children:"Actions"})]})}),n.jsx(Be,{children:ue.map(we=>n.jsxs(ee,{children:[n.jsx(T,{children:n.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:we.code})}),n.jsx(T,{className:"font-medium",children:we.name}),n.jsx(T,{className:"hidden md:table-cell text-muted-foreground text-sm max-w-xs truncate",children:we.description||"—"}),n.jsx(T,{children:n.jsx(E,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive",onClick:()=>{window.confirm(`Delete permission "${we.code}"?`)&&$.mutate(we.id)},children:n.jsx($t,{className:"h-3.5 w-3.5"})})})]},we.id))})]})})]},ne)})})})]}),n.jsx(Qe,{open:o,onOpenChange:ne=>{l(ne),ne||d(null)},children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:c?"Edit Role":"Create New Role"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Role Name"}),n.jsx(G,{placeholder:"e.g. Exam Manager",value:u.name,onChange:ne=>f(_e=>({..._e,name:ne.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Description"}),n.jsx(on,{placeholder:"What does this role do?",value:u.description,onChange:ne=>f(_e=>({..._e,description:ne.target.value})),className:"h-20"})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),n.jsxs(E,{disabled:!u.name.trim()||D.isPending||z.isPending,onClick:X,children:[D.isPending||z.isPending?n.jsx(Re,{className:"h-4 w-4 mr-1 animate-spin"}):null,c?"Save Changes":"Create Role"]})]})]})}),n.jsx(Qe,{open:h,onOpenChange:m,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Create Permission"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Name"}),n.jsx(G,{placeholder:"View Exams",value:y.name,onChange:ne=>x(_e=>({..._e,name:ne.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Code"}),n.jsx(G,{placeholder:"exam.view",value:y.code,onChange:ne=>x(_e=>({..._e,code:ne.target.value}))})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Category"}),n.jsx(G,{placeholder:"exam",value:y.category,onChange:ne=>x(_e=>({..._e,category:ne.target.value}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Description"}),n.jsx(on,{placeholder:"Optional description",value:y.description,onChange:ne=>x(_e=>({..._e,description:ne.target.value})),className:"h-16"})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>m(!1),children:"Cancel"}),n.jsxs(E,{disabled:!y.name.trim()||!y.code.trim()||A.isPending,onClick:()=>A.mutate(y),children:[A.isPending?n.jsx(Re,{className:"h-4 w-4 mr-1 animate-spin"}):null,"Create Permission"]})]})]})}),n.jsx(Qe,{open:j,onOpenChange:ne=>{v(ne),ne||b(null)},children:n.jsxs(Ue,{className:"max-w-2xl max-h-[80vh]",children:[n.jsx(Ke,{children:n.jsxs(Ge,{className:"flex items-center gap-2",children:[n.jsx(Os,{className:"h-5 w-5 text-primary"}),'Permissions for "',g==null?void 0:g.name,'"']})}),n.jsxs("div",{className:"overflow-y-auto max-h-[55vh] space-y-4 pr-1",children:[Object.entries(Z).map(([ne,_e])=>n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(oe,{className:`${PN(ne)} font-medium`,children:ne}),n.jsx(E,{variant:"ghost",size:"sm",className:"text-xs h-6",onClick:()=>{const ue=_e.map(ve=>ve.id),we=ue.every(ve=>N.has(ve));w(ve=>{const le=new Set(ve);return ue.forEach(ut=>we?le.delete(ut):le.add(ut)),le})},children:_e.every(ue=>N.has(ue.id))?"Deselect All":"Select All"})]}),n.jsx("div",{className:"grid gap-1.5",children:_e.map(ue=>n.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-md hover:bg-muted/50 cursor-pointer transition-colors",children:[n.jsx(Fr,{checked:N.has(ue.id),onCheckedChange:()=>re(ue.id)}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-sm font-medium",children:ue.name}),n.jsx("code",{className:"text-[10px] bg-muted px-1 rounded font-mono text-muted-foreground",children:ue.code})]}),ue.description&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:ue.description})]})]},ue.id))})]},ne)),P.length===0&&n.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No permissions available. Create some first."})]}),n.jsxs(Ct,{children:[n.jsxs("div",{className:"flex items-center gap-2 mr-auto text-sm text-muted-foreground",children:[n.jsx(jc,{className:"h-4 w-4"})," ",N.size," of ",P.length," selected"]}),n.jsx(E,{variant:"outline",onClick:()=>v(!1),children:"Cancel"}),n.jsxs(E,{disabled:V.isPending,onClick:()=>{g&&V.mutate({id:g.id,permIds:Array.from(N)})},children:[V.isPending?n.jsx(Re,{className:"h-4 w-4 mr-1 animate-spin"}):null,"Save Permissions"]})]})]})})]})}function OFe(e,t=[]){let r=[];function s(i,o){const l=p.createContext(o);l.displayName=i+"Context";const c=r.length;r=[...r,o];const d=f=>{var v;const{scope:h,children:m,...y}=f,x=((v=h==null?void 0:h[e])==null?void 0:v[c])||l,j=p.useMemo(()=>y,Object.values(y));return n.jsx(x.Provider,{value:j,children:m})};d.displayName=i+"Provider";function u(f,h){var x;const m=((x=h==null?void 0:h[e])==null?void 0:x[c])||l,y=p.useContext(m);if(y)return y;if(o!==void 0)return o;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[d,u]}const a=()=>{const i=r.map(o=>p.createContext(o));return function(l){const c=(l==null?void 0:l[e])||i;return p.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return a.scopeName=e,[s,TFe(a,...t)]}function TFe(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const s=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=s.reduce((l,{useScope:c,scopeName:d})=>{const f=c(i)[`__scope${d}`];return{...l,...f}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return r.scopeName=t.scopeName,r}var MFe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],sA=MFe.reduce((e,t)=>{const r=ex(`Primitive.${t}`),s=p.forwardRef((a,i)=>{const{asChild:o,...l}=a,c=o?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(c,{...l,ref:i})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),RW={exports:{}},$W={};/** * @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 Mf=p;function RFe(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var $Fe=typeof Object.is=="function"?Object.is:RFe,IFe=Mf.useState,DFe=Mf.useEffect,LFe=Mf.useLayoutEffect,FFe=Mf.useDebugValue;function BFe(e,t){var r=t(),s=IFe({inst:{value:r,getSnapshot:t}}),a=s[0].inst,i=s[1];return LFe(function(){a.value=r,a.getSnapshot=t,AN(a)&&i({inst:a})},[e,r,t]),DFe(function(){return AN(a)&&i({inst:a}),e(function(){AN(a)&&i({inst:a})})},[e]),FFe(r),r}function AN(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!$Fe(e,r)}catch{return!0}}function zFe(e,t){return t()}var VFe=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?zFe:BFe;$W.useSyncExternalStore=Mf.useSyncExternalStore!==void 0?Mf.useSyncExternalStore:VFe;RW.exports=$W;var qFe=RW.exports;function WFe(){return qFe.useSyncExternalStore(UFe,()=>!0,()=>!1)}function UFe(){return()=>{}}var aA="Avatar",[KFe]=OFe(aA),[GFe,IW]=KFe(aA),DW=p.forwardRef((e,t)=>{const{__scopeAvatar:r,...s}=e,[a,i]=p.useState("idle");return n.jsx(GFe,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:i,children:n.jsx(sA.span,{...s,ref:t})})});DW.displayName=aA;var LW="AvatarImage",FW=p.forwardRef((e,t)=>{const{__scopeAvatar:r,src:s,onLoadingStatusChange:a=()=>{},...i}=e,o=IW(LW,r),l=HFe(s,i),c=Dn(d=>{a(d),o.onImageLoadingStatusChange(d)});return Ln(()=>{l!=="idle"&&c(l)},[l,c]),l==="loaded"?n.jsx(sA.img,{...i,ref:t,src:s}):null});FW.displayName=LW;var BW="AvatarFallback",zW=p.forwardRef((e,t)=>{const{__scopeAvatar:r,delayMs:s,...a}=e,i=IW(BW,r),[o,l]=p.useState(s===void 0);return p.useEffect(()=>{if(s!==void 0){const c=window.setTimeout(()=>l(!0),s);return()=>window.clearTimeout(c)}},[s]),o&&i.imageLoadingStatus!=="loaded"?n.jsx(sA.span,{...a,ref:t}):null});zW.displayName=BW;function P$(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function HFe(e,{referrerPolicy:t,crossOrigin:r}){const s=WFe(),a=p.useRef(null),i=s?(a.current||(a.current=new window.Image),a.current):null,[o,l]=p.useState(()=>P$(i,e));return Ln(()=>{l(P$(i,e))},[i,e]),Ln(()=>{const c=f=>()=>{l(f)};if(!i)return;const d=c("loaded"),u=c("error");return i.addEventListener("load",d),i.addEventListener("error",u),t&&(i.referrerPolicy=t),typeof r=="string"&&(i.crossOrigin=r),()=>{i.removeEventListener("load",d),i.removeEventListener("error",u)}},[i,r,t]),o}var VW=DW,qW=FW,WW=zW;const iA=p.forwardRef(({className:e,...t},r)=>n.jsx(VW,{ref:r,className:he("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));iA.displayName=VW.displayName;const QFe=p.forwardRef(({className:e,...t},r)=>n.jsx(qW,{ref:r,className:he("aspect-square h-full w-full",e),...t}));QFe.displayName=qW.displayName;const oA=p.forwardRef(({className:e,...t},r)=>n.jsx(WW,{ref:r,className:he("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));oA.displayName=WW.displayName;const YFe={exam:"border-violet-400 bg-violet-50 dark:bg-violet-950",user:"border-blue-400 bg-blue-50 dark:bg-blue-950",entity:"border-emerald-400 bg-emerald-50 dark:bg-emerald-950",assignment:"border-amber-400 bg-amber-50 dark:bg-amber-950",classroom:"border-rose-400 bg-rose-50 dark:bg-rose-950",payment:"border-cyan-400 bg-cyan-50 dark:bg-cyan-950",report:"border-orange-400 bg-orange-50 dark:bg-orange-950"},XFe={exam:"bg-violet-100 text-violet-700",user:"bg-blue-100 text-blue-700",entity:"bg-emerald-100 text-emerald-700",assignment:"bg-amber-100 text-amber-700",classroom:"bg-rose-100 text-rose-700",payment:"bg-cyan-100 text-cyan-700",report:"bg-orange-100 text-orange-700"};function ZFe(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}function JFe(e,t){if(!t)return e;const r=t.toLowerCase(),s={};for(const[a,i]of Object.entries(e)){const o=i.filter(l=>l.name.toLowerCase().includes(r)||l.code.toLowerCase().includes(r)||a.toLowerCase().includes(r));o.length>0&&(s[a]=o)}return s}function A$({columns:e,categories:t,search:r,renderColumnHeader:s,onCellClick:a,pendingCells:i}){const o=p.useMemo(()=>JFe(t,r),[t,r]);return e.length===0?n.jsx(W,{children:n.jsx(U,{className:"py-16 text-center text-muted-foreground",children:"No data available."})}):Object.keys(o).length===0?n.jsx(W,{children:n.jsx(U,{className:"py-16 text-center text-muted-foreground",children:"No permissions match your search."})}):n.jsx("div",{className:"space-y-6",children:Object.entries(o).map(([l,c])=>n.jsxs(W,{className:`border-l-4 ${YFe[l.toLowerCase()]??"border-l-gray-400 bg-gray-50 dark:bg-gray-950"}`,children:[n.jsx(se,{className:"pb-2",children:n.jsxs(ie,{className:"text-sm font-semibold flex items-center gap-2",children:[n.jsx(oe,{className:`${XFe[l.toLowerCase()]??"bg-gray-100 text-gray-700"} font-medium text-xs`,children:l}),n.jsxs("span",{className:"text-muted-foreground font-normal",children:[c.length," permission",c.length!==1?"s":""]})]})}),n.jsx(U,{className:"overflow-x-auto pb-4",children:n.jsxs("table",{className:"w-full text-sm",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{className:"text-left font-medium text-muted-foreground pb-2 pr-4 min-w-[200px] sticky left-0 bg-card z-10",children:"Permission"}),e.map(d=>n.jsx("th",{className:"text-center font-medium text-muted-foreground pb-2 px-2 min-w-[100px]",children:s(d)},d.id))]})}),n.jsx("tbody",{children:c.map((d,u)=>n.jsxs("tr",{className:u%2===0?"":"bg-muted/30",children:[n.jsx("td",{className:"py-1.5 pr-4 sticky left-0 bg-card z-10",children:n.jsxs(uo,{children:[n.jsx(fo,{asChild:!0,children:n.jsxs("div",{className:"flex items-center gap-2 cursor-default",children:[n.jsx("code",{className:"text-[10px] font-mono text-muted-foreground bg-muted px-1 rounded",children:d.code}),n.jsx("span",{className:"text-xs font-medium truncate max-w-[140px]",children:d.name})]})}),n.jsxs(vi,{side:"right",className:"max-w-xs",children:[n.jsx("p",{className:"font-medium",children:d.name}),n.jsx("p",{className:"text-xs text-muted-foreground",children:d.description||"No description"})]})]})}),e.map(f=>{const h=f.granted_permission_ids.includes(d.id),m=`${f.id}-${d.id}`,y=i.has(m);return n.jsx("td",{className:"text-center py-1.5 px-2",children:n.jsxs(uo,{children:[n.jsx(fo,{asChild:!0,children:n.jsx("button",{onClick:()=>a==null?void 0:a(f.id,d.id),disabled:y||!a,className:` inline-flex items-center justify-center h-7 w-7 rounded-md border transition-all duration-150 ${y?"opacity-50 cursor-wait":a?"cursor-pointer hover:scale-110":"cursor-default"} ${h?"bg-emerald-500/20 border-emerald-500/40 hover:bg-emerald-500/30":"bg-muted/50 border-border hover:bg-muted hover:border-muted-foreground/30"} `,children:y?n.jsx(Re,{className:"h-3 w-3 animate-spin text-muted-foreground"}):h?n.jsx(aa,{className:"h-3.5 w-3.5 text-emerald-600"}):n.jsx(ts,{className:"h-3 w-3 text-muted-foreground/30"})})}),n.jsxs(vi,{children:[h?"Granted":"Not granted",": ",n.jsx("strong",{children:d.code})]})]})},f.id)})]},d.id))})]})})]},l))})}function e5e(){var N,w,S,_;const{toast:e}=He(),t=je(),[r,s]=p.useState(""),[a,i]=p.useState("roles"),[o,l]=p.useState(new Set),c=ye({queryKey:["authority-matrix"],queryFn:Gr.getAuthorityMatrix}),d=ye({queryKey:["user-authority-matrix"],queryFn:Gr.getUserAuthorityMatrix,enabled:a==="users"}),u=ae({mutationFn:({roleId:C,permId:P})=>Gr.toggleMatrixCell(C,P),onMutate:({roleId:C,permId:P})=>{l(D=>new Set(D).add(`${C}-${P}`))},onSuccess:C=>{t.invalidateQueries({queryKey:["authority-matrix"]}),t.invalidateQueries({queryKey:["user-authority-matrix"]}),l(P=>{const D=new Set(P);return D.delete(`${C.role_id}-${C.permission_id}`),D})},onError:(C,{roleId:P,permId:D})=>{l(z=>{const O=new Set(z);return O.delete(`${P}-${D}`),O}),e({title:"Failed to toggle",variant:"destructive"})}}),f=((N=c.data)==null?void 0:N.roles)??[],h=((w=c.data)==null?void 0:w.categories)??{},m=((S=d.data)==null?void 0:S.users)??[],y=((_=d.data)==null?void 0:_.categories)??{},x=Object.values(h).reduce((C,P)=>C+P.length,0),j=f.reduce((C,P)=>C+P.granted_permission_ids.length,0),v=f.length*x,g=v>0?Math.round(j/v*100):0,b=()=>{const P=Object.values(a==="roles"?h:y).flat();if(a==="roles"){const D=["Permission Code","Permission Name","Category",...f.map(O=>O.name)],z=P.map(O=>{const V=f.map(A=>A.granted_permission_ids.includes(O.id)?"Yes":"No");return[O.code,O.name,O.category,...V]});E$([D,...z],"authority-matrix-roles.csv")}else{const D=["Permission Code","Permission Name","Category",...m.map(O=>O.name)],z=P.map(O=>{const V=m.map(A=>A.granted_permission_ids.includes(O.id)?"Yes":"No");return[O.code,O.name,O.category,...V]});E$([D,...z],"authority-matrix-users.csv")}};return c.isLoading||a==="users"&&d.isLoading,c.isLoading?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx(Re,{className:"h-8 w-8 animate-spin text-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[n.jsxs("div",{children:[n.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[n.jsx(kE,{className:"h-7 w-7 text-primary"}),"Authority Matrix"]}),n.jsx("p",{className:"text-muted-foreground",children:"Visual overview of permission assignments across roles and users."})]}),n.jsxs(E,{variant:"outline",onClick:b,children:[n.jsx(yd,{className:"mr-2 h-4 w-4"})," Export CSV"]})]}),n.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[n.jsx(W,{children:n.jsxs(U,{className:"pt-5 pb-4 flex items-center gap-3",children:[n.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:n.jsx(Os,{className:"h-5 w-5 text-primary"})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-xl font-bold",children:f.length}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Roles"})]})]})}),n.jsx(W,{children:n.jsxs(U,{className:"pt-5 pb-4 flex items-center gap-3",children:[n.jsx("div",{className:"h-10 w-10 rounded-lg bg-amber-500/10 flex items-center justify-center",children:n.jsx(kE,{className:"h-5 w-5 text-amber-500"})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-xl font-bold",children:x}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Permissions"})]})]})}),n.jsx(W,{children:n.jsxs(U,{className:"pt-5 pb-4 flex items-center gap-3",children:[n.jsx("div",{className:"h-10 w-10 rounded-lg bg-emerald-500/10 flex items-center justify-center",children:n.jsx(aa,{className:"h-5 w-5 text-emerald-500"})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-xl font-bold",children:j}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Granted"})]})]})}),n.jsx(W,{children:n.jsxs(U,{className:"pt-5 pb-4 flex items-center gap-3",children:[n.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:n.jsxs("span",{className:"text-sm font-bold text-blue-500",children:[g,"%"]})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-xl font-bold",children:"Coverage"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:[j,"/",v," cells"]})]})]})})]}),n.jsxs(Us,{value:a,onValueChange:i,children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[n.jsxs(ws,{children:[n.jsxs(Et,{value:"roles",className:"gap-1.5",children:[n.jsx(Os,{className:"h-4 w-4"})," Roles (",f.length,")"]}),n.jsxs(Et,{value:"users",className:"gap-1.5",children:[n.jsx(as,{className:"h-4 w-4"})," Users (",m.length||"...",")"]})]}),n.jsxs("div",{className:"relative max-w-xs w-full",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Filter permissions...",className:"pl-9",value:r,onChange:C=>s(C.target.value)})]})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-xs text-muted-foreground mt-4",children:[n.jsx("span",{className:"font-medium text-foreground",children:"Legend:"}),n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"inline-flex h-5 w-5 rounded bg-emerald-500/20 border border-emerald-500/40 items-center justify-center",children:n.jsx(aa,{className:"h-3 w-3 text-emerald-600"})}),"Granted"]}),n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"inline-flex h-5 w-5 rounded bg-muted border border-border items-center justify-center",children:n.jsx(ts,{className:"h-3 w-3 text-muted-foreground/40"})}),"Not granted"]}),a==="roles"&&n.jsx("span",{className:"ml-auto",children:"Click any cell to toggle"}),a==="users"&&n.jsx("span",{className:"ml-auto text-muted-foreground/70",children:"User permissions are derived from roles (read-only)"})]}),n.jsx(Lt,{value:"roles",className:"mt-4",children:n.jsx(A$,{columns:f,categories:h,search:r,pendingCells:o,onCellClick:(C,P)=>u.mutate({roleId:C,permId:P}),renderColumnHeader:C=>n.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[n.jsx(Os,{className:"h-3.5 w-3.5 text-primary/60"}),n.jsx("span",{className:"text-xs leading-tight",children:C.name})]})})}),n.jsx(Lt,{value:"users",className:"mt-4",children:d.isLoading?n.jsx("div",{className:"flex items-center justify-center py-16",children:n.jsx(Re,{className:"h-8 w-8 animate-spin text-primary"})}):m.length===0?n.jsx(W,{children:n.jsx(U,{className:"py-16 text-center text-muted-foreground",children:"No users with roles assigned. Assign roles in the User Roles page first."})}):n.jsx(A$,{columns:m,categories:y,search:r,pendingCells:new Set,renderColumnHeader:C=>n.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[n.jsx(iA,{className:"h-6 w-6",children:n.jsx(oA,{className:"text-[9px] bg-primary/10 text-primary font-medium",children:ZFe(C.name)})}),n.jsx("span",{className:"text-[10px] leading-tight max-w-[80px] truncate",children:C.name}),n.jsxs("span",{className:"text-[9px] text-muted-foreground",children:[C.roles.length," role",C.roles.length!==1?"s":""]})]})})})]})]})}function E$(e,t){const r=e.map(o=>o.map(l=>`"${String(l).replace(/"/g,'""')}"`).join(",")).join(` `),s=new Blob([r],{type:"text/csv"}),a=URL.createObjectURL(s),i=document.createElement("a");i.href=a,i.download=t,i.click(),URL.revokeObjectURL(a)}const O$=["bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300","bg-violet-100 text-violet-700 dark:bg-violet-900 dark:text-violet-300","bg-emerald-100 text-emerald-700 dark:bg-emerald-900 dark:text-emerald-300","bg-amber-100 text-amber-700 dark:bg-amber-900 dark:text-amber-300","bg-rose-100 text-rose-700 dark:bg-rose-900 dark:text-rose-300","bg-cyan-100 text-cyan-700 dark:bg-cyan-900 dark:text-cyan-300","bg-orange-100 text-orange-700 dark:bg-orange-900 dark:text-orange-300"];function EN(e){return O$[e%O$.length]}function t5e(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}const n5e={exam:"bg-violet-100 text-violet-700",user:"bg-blue-100 text-blue-700",entity:"bg-emerald-100 text-emerald-700",assignment:"bg-amber-100 text-amber-700",classroom:"bg-rose-100 text-rose-700",payment:"bg-cyan-100 text-cyan-700",report:"bg-orange-100 text-orange-700"};function r5e(e){return n5e[e.toLowerCase()]??"bg-gray-100 text-gray-700"}function s5e(){var B,I,k;const{toast:e}=He(),t=je(),[r,s]=p.useState(""),[a,i]=p.useState("all"),[o,l]=p.useState(!1),[c,d]=p.useState(null),[u,f]=p.useState(new Set),[h,m]=p.useState(!1),[y,x]=p.useState(null),j=ye({queryKey:["users-with-roles",r,a],queryFn:()=>Gr.listUsersWithRoles({...r?{search:r}:{},...a!=="all"?{role_id:Number(a)}:{},size:200})}),v=ye({queryKey:["roles"],queryFn:()=>Gr.listRoles()}),g=ye({queryKey:["user-roles-detail",y],queryFn:()=>Gr.getUserRoles(y),enabled:y!==null}),b=((B=j.data)==null?void 0:B.data)??[],N=((I=v.data)==null?void 0:I.data)??[],w=ae({mutationFn:({userId:M,roleIds:K})=>Gr.updateUserRoles(M,K),onSuccess:()=>{t.invalidateQueries({queryKey:["users-with-roles"]}),t.invalidateQueries({queryKey:["roles"]}),l(!1),e({title:"Roles updated successfully"})},onError:()=>e({title:"Failed to update roles",variant:"destructive"})}),S=j.isLoading||v.isLoading,_=b.filter(M=>M.role_ids.length>0).length,C=b.filter(M=>M.role_ids.length===0).length,P=M=>{d(M.id),f(new Set(M.role_ids)),l(!0)},D=M=>{x(M.id),m(!0)},z=M=>{f(K=>{const X=new Set(K);return X.has(M)?X.delete(M):X.add(M),X})},O=()=>{c!==null&&w.mutate({userId:c,roleIds:Array.from(u)})},V=g.data,A=(V==null?void 0:V.effective_permissions)??[],$=A.reduce((M,K)=>{const X=K.category||"General";return(M[X]??(M[X]=[])).push(K),M},{});return S?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx(Re,{className:"h-8 w-8 animate-spin text-primary"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex flex-wrap items-center justify-between gap-4",children:n.jsxs("div",{children:[n.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[n.jsx(au,{className:"h-7 w-7 text-primary"}),"User Roles"]}),n.jsx("p",{className:"text-muted-foreground",children:"Assign roles to users and view their effective permissions."})]})}),n.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[n.jsx(W,{children:n.jsxs(U,{className:"pt-5 pb-4 flex items-center gap-3",children:[n.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:n.jsx(as,{className:"h-5 w-5 text-primary"})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-xl font-bold",children:b.length}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Users"})]})]})}),n.jsx(W,{children:n.jsxs(U,{className:"pt-5 pb-4 flex items-center gap-3",children:[n.jsx("div",{className:"h-10 w-10 rounded-lg bg-emerald-500/10 flex items-center justify-center",children:n.jsx(Os,{className:"h-5 w-5 text-emerald-500"})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-xl font-bold",children:_}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"With Roles"})]})]})}),n.jsx(W,{children:n.jsxs(U,{className:"pt-5 pb-4 flex items-center gap-3",children:[n.jsx("div",{className:"h-10 w-10 rounded-lg bg-amber-500/10 flex items-center justify-center",children:n.jsx(au,{className:"h-5 w-5 text-amber-500"})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-xl font-bold",children:C}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"No Roles"})]})]})}),n.jsx(W,{children:n.jsxs(U,{className:"pt-5 pb-4 flex items-center gap-3",children:[n.jsx("div",{className:"h-10 w-10 rounded-lg bg-violet-500/10 flex items-center justify-center",children:n.jsx(jc,{className:"h-5 w-5 text-violet-500"})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-xl font-bold",children:N.length}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Available Roles"})]})]})})]}),n.jsxs("div",{className:"flex flex-wrap gap-3",children:[n.jsxs("div",{className:"relative max-w-xs w-full",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{placeholder:"Search users...",className:"pl-9",value:r,onChange:M=>s(M.target.value)})]}),n.jsxs(Oe,{value:a,onValueChange:i,children:[n.jsx(Ae,{className:"w-[200px]",children:n.jsx(Me,{placeholder:"Filter by role"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"all",children:"All Roles"}),N.map(M=>n.jsx(Y,{value:String(M.id),children:M.name},M.id))]})]})]}),n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"User"}),n.jsx(L,{children:"Email / Login"}),n.jsx(L,{children:"Assigned Roles"}),n.jsx(L,{className:"text-center",children:"Permissions"}),n.jsx(L,{className:"text-right",children:"Actions"})]})}),n.jsxs(Be,{children:[b.length===0&&n.jsx(ee,{children:n.jsx(T,{colSpan:5,className:"text-center text-muted-foreground py-12",children:"No users found."})}),b.map(M=>n.jsxs(ee,{className:"group",children:[n.jsx(T,{children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(iA,{className:"h-8 w-8",children:n.jsx(oA,{className:"text-xs bg-primary/10 text-primary font-medium",children:t5e(M.name)})}),n.jsx("span",{className:"font-medium",children:M.name})]})}),n.jsx(T,{className:"text-muted-foreground text-sm",children:M.email||M.login}),n.jsx(T,{children:n.jsxs("div",{className:"flex flex-wrap gap-1",children:[M.roles.length===0&&n.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No roles"}),M.roles.map((K,X)=>n.jsxs(oe,{variant:"outline",className:`text-[11px] px-1.5 py-0 ${EN(X)}`,children:[n.jsx(Os,{className:"h-2.5 w-2.5 mr-0.5"}),K.name]},K.id))]})}),n.jsx(T,{className:"text-center",children:n.jsx(oe,{variant:"secondary",className:"text-xs",children:M.effective_permission_count})}),n.jsx(T,{className:"text-right",children:n.jsxs("div",{className:"flex justify-end gap-1",children:[n.jsxs(uo,{children:[n.jsx(fo,{asChild:!0,children:n.jsxs(E,{size:"sm",variant:"ghost",className:"h-8 gap-1 text-xs",onClick:()=>D(M),children:[n.jsx(Uc,{className:"h-3.5 w-3.5"})," View"]})}),n.jsx(vi,{children:"View effective permissions"})]}),n.jsxs(uo,{children:[n.jsx(fo,{asChild:!0,children:n.jsxs(E,{size:"sm",variant:"outline",className:"h-8 gap-1 text-xs",onClick:()=>P(M),children:[n.jsx(au,{className:"h-3.5 w-3.5"})," Assign ",n.jsx(Si,{className:"h-3 w-3"})]})}),n.jsx(vi,{children:"Manage role assignments"})]})]})})]},M.id))]})]})})}),n.jsx(Qe,{open:o,onOpenChange:M=>{l(M),M||d(null)},children:n.jsxs(Ue,{className:"max-w-lg",children:[n.jsxs(Ke,{children:[n.jsxs(Ge,{className:"flex items-center gap-2",children:[n.jsx(au,{className:"h-5 w-5 text-primary"}),"Assign Roles"]}),n.jsxs($e,{children:["Toggle roles for user: ",n.jsx("strong",{children:(k=b.find(M=>M.id===c))==null?void 0:k.name})]})]}),n.jsxs("div",{className:"space-y-2 max-h-[50vh] overflow-y-auto pr-1",children:[N.length===0&&n.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No roles available. Create roles first."}),N.map((M,K)=>n.jsxs("label",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border cursor-pointer transition-all ${u.has(M.id)?"border-primary/40 bg-primary/5 shadow-sm":"border-border hover:border-muted-foreground/30 hover:bg-muted/30"}`,children:[n.jsx(Fr,{checked:u.has(M.id),onCheckedChange:()=>z(M.id)}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(oe,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${EN(K)}`,children:[n.jsx(Os,{className:"h-2.5 w-2.5 mr-0.5"}),M.name]}),n.jsxs("span",{className:"text-xs text-muted-foreground",children:[M.permissions.length," permission",M.permissions.length!==1?"s":""]})]}),M.description&&n.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:M.description})]})]},M.id))]}),n.jsxs(Ct,{children:[n.jsxs("div",{className:"flex items-center gap-2 mr-auto text-sm text-muted-foreground",children:[n.jsx(Os,{className:"h-4 w-4"})," ",u.size," of ",N.length," selected"]}),n.jsx(E,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),n.jsxs(E,{disabled:w.isPending,onClick:O,children:[w.isPending?n.jsx(Re,{className:"h-4 w-4 mr-1 animate-spin"}):null,"Save Roles"]})]})]})}),n.jsx(Qe,{open:h,onOpenChange:M=>{m(M),M||x(null)},children:n.jsxs(Ue,{className:"max-w-2xl max-h-[85vh]",children:[n.jsxs(Ke,{children:[n.jsxs(Ge,{className:"flex items-center gap-2",children:[n.jsx(jc,{className:"h-5 w-5 text-primary"}),"Effective Permissions"]}),V&&n.jsxs($e,{children:[n.jsx("strong",{children:V.user.name})," (",V.user.login,")"]})]}),g.isLoading?n.jsx("div",{className:"flex justify-center py-12",children:n.jsx(Re,{className:"h-6 w-6 animate-spin text-primary"})}):V?n.jsxs("div",{className:"space-y-4 overflow-y-auto max-h-[60vh] pr-1",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2 uppercase tracking-wider",children:"Assigned Roles"}),n.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[V.roles.filter(M=>M.assigned).map((M,K)=>n.jsxs(oe,{variant:"outline",className:`${EN(K)} text-xs px-2 py-0.5`,children:[n.jsx(Os,{className:"h-3 w-3 mr-1"}),M.name,n.jsxs("span",{className:"ml-1 text-[10px] opacity-70",children:["(",M.permission_count,")"]})]},M.id)),V.roles.filter(M=>M.assigned).length===0&&n.jsx("span",{className:"text-sm text-muted-foreground italic",children:"No roles assigned"})]})]}),n.jsxs("div",{children:[n.jsxs("p",{className:"text-xs font-medium text-muted-foreground mb-2 uppercase tracking-wider",children:["Effective Permissions (",A.length,")"]}),A.length===0?n.jsx("p",{className:"text-sm text-muted-foreground italic py-4 text-center",children:"No permissions (assign roles to grant permissions)"}):n.jsx("div",{className:"space-y-3",children:Object.entries($).map(([M,K])=>n.jsxs(W,{className:"border-muted",children:[n.jsx(se,{className:"py-2 px-4",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(oe,{className:`${r5e(M)} font-medium text-[10px]`,children:M}),n.jsx("span",{className:"text-xs text-muted-foreground",children:K.length})]})}),n.jsx(U,{className:"px-4 pb-3 pt-0",children:n.jsx("div",{className:"grid gap-1",children:K.map(X=>n.jsxs("div",{className:"flex items-center gap-2 py-1",children:[n.jsx("div",{className:"h-5 w-5 rounded bg-emerald-500/15 flex items-center justify-center",children:n.jsx(jc,{className:"h-2.5 w-2.5 text-emerald-600"})}),n.jsx("code",{className:"text-[10px] font-mono bg-muted px-1 rounded text-muted-foreground",children:X.code}),n.jsx("span",{className:"text-xs",children:X.name})]},X.id))})})]},M))})]})]}):null,n.jsx(Ct,{children:n.jsx(E,{variant:"outline",onClick:()=>m(!1),children:"Close"})})]})})]})}function a5e(){const[e,t]=p.useState(1),[r,s]=p.useState(null),[a,i]=p.useState(null),[o,l]=p.useState(!1),c=Yde(),d=Xde(),u=Zde(),f=p.useCallback(v=>{if(!v||!v.name.toLowerCase().endsWith(".csv")){ct.error("Please upload a CSV file.");return}c.mutate(v,{onSuccess:g=>{s(g),t(2)},onError:g=>ct.error(g instanceof Error?g.message:"Validation failed")})},[c]),h=v=>{v.preventDefault(),l(!1);const g=v.dataTransfer.files[0];f(g??null)},m=r?`${r.valid_count} valid, ${r.error_count} error${r.error_count===1?"":"s"}, ${r.warning_count} warning${r.warning_count===1?"":"s"}`:"",y=()=>{d.mutate({validate_session_id:r==null?void 0:r.validate_session_id},{onSuccess:v=>{i(v),t(3),ct.success("Accounts created.")},onError:v=>ct.error(v instanceof Error?v.message:"Bulk create failed")})},x=()=>{const v=(a==null?void 0:a.accounts.map(g=>g.id))??[];v.length&&u.mutate(v,{onSuccess:()=>ct.success("Credential emails queued."),onError:g=>ct.error(g instanceof Error?g.message:"Send failed")})},j=v=>v==="valid"?n.jsx(Un,{className:"h-4 w-4 text-green-600"}):v==="error"?n.jsx(Nv,{className:"h-4 w-4 text-destructive"}):n.jsx(Pl,{className:"h-4 w-4 text-amber-500"});return n.jsxs("div",{className:"space-y-6 p-6 max-w-5xl mx-auto",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Bulk student upload"}),n.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"CSV import for your entity"})]}),e===1&&n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Step 1 — Upload CSV"}),n.jsx($e,{children:"Drag and drop a file or click to browse. CSV only."})]}),n.jsxs(U,{className:"space-y-4",children:[n.jsxs("div",{className:he("border-2 border-dashed rounded-lg p-12 text-center transition-colors",o?"border-primary bg-primary/5":"border-muted-foreground/25"),onDragOver:v=>{v.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:h,children:[n.jsx(Ku,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),n.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Drop your CSV here"}),n.jsxs("label",{className:"inline-flex cursor-pointer",children:[n.jsx("input",{type:"file",accept:".csv,text/csv",className:"hidden",onChange:v=>{var g;return f(((g=v.target.files)==null?void 0:g[0])??null)}}),n.jsx(E,{type:"button",variant:"secondary",children:"Browse files"})]})]}),n.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[n.jsx(zL,{className:"h-4 w-4"}),n.jsx("a",{href:"/templates/students.csv",className:"text-primary underline-offset-4 hover:underline",download:!0,children:"Download Template"})]})]})]}),e===2&&r&&n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Step 2 — Validation report"}),n.jsx($e,{children:"Review each row before creating accounts."})]}),n.jsxs(U,{className:"space-y-4",children:[n.jsx("div",{className:"rounded-md border bg-muted/40 px-4 py-3 text-sm font-medium",children:m}),n.jsx("div",{className:"rounded-md border overflow-x-auto",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{className:"w-16",children:"Row#"}),n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Email"}),n.jsx(L,{children:"Status"}),n.jsx(L,{children:"Issue"})]})}),n.jsx(Be,{children:r.rows.map(v=>n.jsxs(ee,{children:[n.jsx(T,{children:v.row_number}),n.jsx(T,{children:v.student_name}),n.jsx(T,{children:v.email}),n.jsx(T,{children:n.jsxs("div",{className:"flex items-center gap-2",children:[j(v.status),n.jsx("span",{className:"capitalize",children:v.status})]})}),n.jsx(T,{className:"text-muted-foreground",children:v.issue??"—"})]},v.row_number))})]})}),n.jsxs("div",{className:"flex flex-wrap gap-3",children:[n.jsx(E,{variant:"outline",onClick:()=>{t(1),s(null)},children:"Fix & Re-upload"}),n.jsx(E,{onClick:y,disabled:d.isPending,children:"Confirm & Create Accounts"})]})]})]}),e===3&&a&&n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Step 3 — Accounts created"}),n.jsxs($e,{children:[a.created_count," new accounts are ready."]})]}),n.jsxs(U,{className:"space-y-4",children:[n.jsx("div",{className:"rounded-md border overflow-x-auto",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Email"}),n.jsx(L,{children:"Status"})]})}),n.jsx(Be,{children:a.accounts.map(v=>n.jsxs(ee,{children:[n.jsx(T,{children:v.name}),n.jsx(T,{children:v.email}),n.jsx(T,{children:v.account_status})]},v.id))})]})}),n.jsx(E,{onClick:x,disabled:u.isPending,children:"Send Credential Emails"})]})]})]})}function i5e(){const[e,t]=p.useState("all"),[r,s]=p.useState("all"),[a,i]=p.useState("all"),[o,l]=p.useState(""),[c,d]=p.useState(""),[u,f]=p.useState(new Set),h=p.useMemo(()=>({account_status:e==="all"?void 0:e,email_sent:r==="all"?void 0:r==="yes"?!0:r==="no"?!1:void 0,placement_status:a==="all"?void 0:a,date_from:o||void 0,date_to:c||void 0}),[e,r,a,o,c]),{data:m,isLoading:y}=Jde(h),x=eue(),j=tue(),v=(m==null?void 0:m.data)??[],g=N=>{f(w=>{const S=new Set(w);return S.has(N)?S.delete(N):S.add(N),S})},b=N=>{f(N?new Set(v.map(w=>w.student_id)):new Set)};return n.jsxs("div",{className:"space-y-6 p-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Credential dashboard"}),n.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Track onboarding emails and placement"})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{className:"text-base",children:"Filters"})}),n.jsxs(U,{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Account status"}),n.jsxs(Oe,{value:e,onValueChange:t,children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"All"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"all",children:"All"}),n.jsx(Y,{value:"pending_first_login",children:"Pending first login"}),n.jsx(Y,{value:"active",children:"Active"}),n.jsx(Y,{value:"password_reset_required",children:"Password reset required"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Email sent"}),n.jsxs(Oe,{value:r,onValueChange:s,children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"All"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"all",children:"All"}),n.jsx(Y,{value:"yes",children:"Yes"}),n.jsx(Y,{value:"no",children:"No"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Placement status"}),n.jsxs(Oe,{value:a,onValueChange:i,children:[n.jsx(Ae,{children:n.jsx(Me,{placeholder:"All"})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"all",children:"All"}),n.jsx(Y,{value:"not_started",children:"Not started"}),n.jsx(Y,{value:"in_progress",children:"In progress"}),n.jsx(Y,{value:"completed",children:"Completed"}),n.jsx(Y,{value:"bypassed",children:"Bypassed"})]})]})]}),n.jsxs("div",{className:"space-y-2 md:col-span-2 lg:col-span-1",children:[n.jsx(q,{children:"Date range"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(G,{type:"date",value:o,onChange:N=>l(N.target.value)}),n.jsx(G,{type:"date",value:c,onChange:N=>d(N.target.value)})]})]})]})]}),n.jsx("div",{className:"flex justify-end",children:n.jsx(E,{variant:"secondary",onClick:()=>j.mutate(void 0,{onSuccess:()=>ct.success("Bulk resend started."),onError:N=>ct.error(N instanceof Error?N.message:"Failed")}),disabled:j.isPending,children:"Resend All Pending"})}),n.jsx(W,{children:n.jsx(U,{className:"pt-6",children:y?n.jsx("div",{className:"flex justify-center py-12 text-muted-foreground",children:"Loading…"}):n.jsx("div",{className:"rounded-md border overflow-x-auto",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{className:"w-12",children:n.jsx(an,{checked:v.length>0&&u.size===v.length,onCheckedChange:N=>b(!!N)})}),n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Email"}),n.jsx(L,{children:"Account Status"}),n.jsx(L,{children:"Email Sent"}),n.jsx(L,{children:"First Login"}),n.jsx(L,{children:"Placement Status"}),n.jsx(L,{className:"text-right",children:"Actions"})]})}),n.jsx(Be,{children:v.map(N=>n.jsxs(ee,{children:[n.jsx(T,{children:n.jsx(an,{checked:u.has(N.student_id),onCheckedChange:()=>g(N.student_id)})}),n.jsx(T,{className:"font-medium",children:N.name}),n.jsx(T,{children:N.email}),n.jsx(T,{children:N.account_status}),n.jsx(T,{children:N.email_sent?"Yes":"No"}),n.jsx(T,{children:N.first_login_at?new Date(N.first_login_at).toLocaleString():"—"}),n.jsx(T,{children:N.placement_status}),n.jsx(T,{className:"text-right",children:n.jsx(E,{size:"sm",variant:"outline",onClick:()=>x.mutate(N.student_id,{onSuccess:()=>ct.success("Email resent."),onError:w=>ct.error(w instanceof Error?w.message:"Failed")}),disabled:x.isPending,children:"Resend Email"})})]},N.student_id))})]})})})})]})}function o5e(){const{courseId:e}=Ht(),t=Number(e),{data:r,isLoading:s,refetch:a}=sue(Number.isFinite(t)?t:void 0),i=aue(),o=iue(),[l,c]=p.useState(!1),[d,u]=p.useState(""),f=(r==null?void 0:r.checks)??[];return s?n.jsx("div",{className:"p-6 text-muted-foreground",children:"Loading quality gate…"}):n.jsxs("div",{className:"space-y-6 p-6 max-w-5xl mx-auto",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"English course quality"}),n.jsxs("p",{className:"text-muted-foreground text-sm mt-1",children:["Attempts ",(r==null?void 0:r.attempts)??0," / ",(r==null?void 0:r.max_attempts)??0]})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Quality gate checks"}),n.jsx($e,{children:"Readability, calibration, grammar, and length"})]}),n.jsxs(U,{className:"space-y-4",children:[n.jsx("div",{className:"rounded-md border overflow-x-auto",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Check"}),n.jsx(L,{children:"Status"}),n.jsx(L,{children:"Detail"})]})}),n.jsx(Be,{children:f.map(h=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:h.name}),n.jsx(T,{children:n.jsxs("span",{className:"inline-flex items-center gap-1",children:[h.status==="pass"?n.jsx(Un,{className:"h-4 w-4 text-green-600"}):n.jsx(Bf,{className:"h-4 w-4 text-destructive"}),h.status]})}),n.jsx(T,{className:"text-muted-foreground max-w-md",children:h.detail})]},h.name))})]})}),n.jsxs("div",{className:"flex flex-wrap gap-3",children:[n.jsx(E,{onClick:()=>i.mutate(t,{onSuccess:()=>{ct.success("Approved."),a()},onError:h=>ct.error(h instanceof Error?h.message:"Failed")}),disabled:!Number.isFinite(t)||i.isPending,children:"Approve"}),n.jsx(E,{variant:"destructive",onClick:()=>c(!0),children:"Reject & Regenerate"}),n.jsx(E,{variant:"outline",onClick:()=>a(),children:"Edit"})]})]})]}),n.jsx(Qe,{open:l,onOpenChange:c,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Regeneration notes"})}),n.jsx(on,{value:d,onChange:h=>u(h.target.value),placeholder:"What should change?",rows:4}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),n.jsx(E,{onClick:()=>o.mutate({courseId:t,reason:d},{onSuccess:()=>{ct.success("Rejected; regeneration requested."),c(!1),a()},onError:h=>ct.error(h instanceof Error?h.message:"Failed")}),disabled:o.isPending,children:"Submit"})]})]})})]})}const T$={grammar_by_cefr:"Grammar topics by CEFR",vocabulary_bands:"Vocabulary bands",skill_areas:"Skill areas",topic_categories:"Topic categories"};function l5e(){const{data:e,isLoading:t}=oue(),r=e??{};return n.jsxs("div",{className:"space-y-6 p-6 max-w-5xl mx-auto",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"English taxonomy reference"}),n.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Read-only curriculum dimensions"})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Taxonomy dimensions"}),n.jsx($e,{children:"Four reference views"})]}),n.jsx(U,{children:t?n.jsx("p",{className:"text-muted-foreground",children:"Loading…"}):n.jsx(O0,{type:"multiple",className:"w-full",children:Object.keys(T$).map(s=>n.jsxs(Ax,{value:s,children:[n.jsx(Ex,{children:T$[s]}),n.jsx(Ox,{children:n.jsx(c5e,{value:r[s]})})]},s))})})]})]})}function c5e({value:e}){if(e==null)return n.jsx("p",{className:"text-sm text-muted-foreground",children:"No data."});if(Array.isArray(e))return n.jsx("div",{className:"rounded-md border overflow-x-auto",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsx(ee,{children:n.jsx(L,{children:"Entry"})})}),n.jsx(Be,{children:e.map((t,r)=>n.jsx(ee,{children:n.jsx(T,{children:typeof t=="object"&&t!==null?JSON.stringify(t):String(t)})},r))})]})});if(typeof e=="object"){const t=Object.entries(e);return n.jsx("div",{className:"space-y-4",children:t.map(([r,s])=>n.jsxs("div",{children:[n.jsx("h4",{className:"text-sm font-semibold mb-2",children:r}),n.jsx("div",{className:"rounded-md border overflow-x-auto",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsx(ee,{children:n.jsx(L,{children:"Item"})})}),n.jsx(Be,{children:(Array.isArray(s)?s:[]).map((a,i)=>n.jsx(ee,{children:n.jsx(T,{className:"text-sm",children:typeof a=="object"&&a!==null?JSON.stringify(a):String(a)})},i))})]})})]},r))})}return n.jsx("p",{className:"text-sm",children:String(e)})}function d5e(){const{courseId:e}=Ht(),t=Number(e),{data:r,isLoading:s,refetch:a}=lue(Number.isFinite(t)?t:void 0),i=cue(),[o,l]=p.useState(null),[c,d]=p.useState(""),[u,f]=p.useState({topic_accuracy:!0,difficulty_appropriate:!0,ielts_aligned:!0,culturally_sensitive:!0}),h=(r==null?void 0:r.layer1_checks)??[],m=(r==null?void 0:r.layer2_items)??[],y=x=>{o&&i.mutate({logId:o.id,action:x?"approve":"reject",examiner_notes:x?void 0:c},{onSuccess:()=>{ct.success(x?"Approved.":"Rejected with notes."),l(null),d(""),a()},onError:j=>ct.error(j instanceof Error?j.message:"Failed")})};return s?n.jsx("div",{className:"p-6 text-muted-foreground",children:"Loading validation…"}):n.jsxs("div",{className:"space-y-8 p-6 max-w-6xl mx-auto",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"IELTS content validation"}),n.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Layer 1 automation · Layer 2 examiner queue"})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Layer 1 — Automated checks"}),n.jsx($e,{children:"Format, calibration, answer keys"})]}),n.jsx(U,{children:n.jsx("div",{className:"rounded-md border overflow-x-auto",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Check"}),n.jsx(L,{children:"Status"}),n.jsx(L,{children:"Detail"})]})}),n.jsx(Be,{children:h.map(x=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:x.name}),n.jsx(T,{children:n.jsxs("span",{className:"inline-flex items-center gap-1",children:[x.status==="pass"?n.jsx(Un,{className:"h-4 w-4 text-green-600"}):n.jsx(Bf,{className:"h-4 w-4 text-destructive"}),x.status]})}),n.jsx(T,{className:"text-muted-foreground",children:x.detail})]},x.name))})]})})})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Layer 2 — Examiner review queue"}),n.jsx($e,{children:"Approve or reject with structured notes"})]}),n.jsx(U,{children:n.jsx("div",{className:"rounded-md border overflow-x-auto",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Skill"}),n.jsx(L,{children:"Content type"}),n.jsx(L,{children:"Target band"}),n.jsx(L,{children:"Status"}),n.jsx(L,{className:"text-right",children:"Action"})]})}),n.jsx(Be,{children:m.map(x=>n.jsxs(ee,{children:[n.jsx(T,{children:x.skill}),n.jsx(T,{children:x.content_type}),n.jsx(T,{children:x.target_band}),n.jsx(T,{children:x.status}),n.jsx(T,{className:"text-right",children:n.jsx(E,{size:"sm",variant:"outline",onClick:()=>l(x),children:"Review"})})]},x.id))})]})})})]}),n.jsx(Qe,{open:!!o,onOpenChange:x=>!x&&l(null),children:n.jsxs(Ue,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Content preview"})}),o&&n.jsxs("div",{className:"space-y-4 text-sm",children:[n.jsxs("p",{children:[n.jsx("span",{className:"font-medium",children:"Skill:"})," ",o.skill," ·"," ",n.jsx("span",{className:"font-medium",children:"Type:"})," ",o.content_type," ·"," ",n.jsx("span",{className:"font-medium",children:"Band:"})," ",o.target_band]}),n.jsx("div",{className:"rounded-md border bg-muted/40 p-4 min-h-[120px] text-muted-foreground",children:"Full content preview loads here from the authoring pipeline."}),n.jsxs("div",{className:"space-y-3",children:[n.jsx(q,{className:"text-base",children:"Examiner checklist"}),n.jsx("div",{className:"space-y-2",children:[["topic_accuracy","Accuracy"],["difficulty_appropriate","Difficulty"],["ielts_aligned","IELTS alignment"],["culturally_sensitive","Cultural sensitivity"]].map(([x,j])=>n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(an,{id:x,checked:u[x],onCheckedChange:v=>f(g=>({...g,[x]:!!v}))}),n.jsx(q,{htmlFor:x,className:"font-normal cursor-pointer",children:j})]},x))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"notes",children:"Rejection notes"}),n.jsx(on,{id:"notes",value:c,onChange:x=>d(x.target.value),placeholder:"Required when rejecting",rows:3})]})]}),n.jsxs(Ct,{className:"gap-2 sm:gap-0",children:[n.jsx(E,{variant:"outline",onClick:()=>y(!0),disabled:i.isPending,children:"Approve"}),n.jsx(E,{variant:"destructive",onClick:()=>y(!1),disabled:i.isPending,children:"Reject with Notes"})]})]})})]})}function u5e(){var u;const[e,t]=p.useState(1),r=10,{data:s}=due(),{data:a,isLoading:i}=uue({page:e,limit:r}),o=s??{active_students:0,engine_phase:"—",decisions_today:0,average_improvement:0,alerts_count:0},l=(a==null?void 0:a.data)??[],c=((u=a==null?void 0:a.pagination)==null?void 0:u.total)??l.length,d=Math.max(1,Math.ceil(c/r));return n.jsxs("div",{className:"space-y-8 p-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Adaptive engine"}),n.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Live decisions and learner risk"})]}),n.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-5",children:[n.jsx(Gm,{icon:as,label:"Active students",value:String(o.active_students)}),n.jsx(Gm,{icon:kG,label:"Engine phase",value:o.engine_phase}),n.jsx(Gm,{icon:Sj,label:"Decisions today",value:String(o.decisions_today)}),n.jsx(Gm,{icon:LG,label:"Avg improvement",value:`${o.average_improvement}%`}),n.jsx(Gm,{icon:Pl,label:"Alerts",value:String(o.alerts_count)})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Students"}),n.jsx($e,{children:"Signals, pacing, and trajectory"})]}),n.jsx(U,{children:i?n.jsx("p",{className:"text-muted-foreground py-8 text-center",children:"Loading…"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"rounded-md border overflow-x-auto",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Name"}),n.jsx(L,{children:"Subject"}),n.jsx(L,{children:"Current level"}),n.jsx(L,{children:"Target"}),n.jsx(L,{children:"Days active"}),n.jsx(L,{children:"Last decision"}),n.jsx(L,{children:"Progress"}),n.jsx(L,{children:"Alert"}),n.jsx(L,{})]})}),n.jsx(Be,{children:l.map(f=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:f.name}),n.jsx(T,{children:f.subject}),n.jsx(T,{children:f.current_level}),n.jsx(T,{children:f.target}),n.jsx(T,{children:f.days_active}),n.jsx(T,{className:"whitespace-nowrap text-sm text-muted-foreground",children:new Date(f.last_decision_at).toLocaleString()}),n.jsx(T,{className:"w-32",children:n.jsx(f5e,{vals:f.progress_sparkline})}),n.jsx(T,{children:f.alert?n.jsx(oe,{variant:"destructive",className:"text-xs",children:f.alert}):"—"}),n.jsx(T,{children:n.jsx(E,{variant:"link",className:"px-0",asChild:!0,children:n.jsx(Dt,{to:`/admin/adaptive/student/${f.student_id}`,children:"Open"})})})]},f.student_id))})]})}),n.jsxs("div",{className:"flex items-center justify-between mt-4 text-sm",children:[n.jsxs("span",{className:"text-muted-foreground",children:["Page ",e," of ",d]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(E,{size:"sm",variant:"outline",disabled:e<=1,onClick:()=>t(f=>f-1),children:"Previous"}),n.jsx(E,{size:"sm",variant:"outline",disabled:e>=d,onClick:()=>t(f=>f+1),children:"Next"})]})]})]})})]})]})}function Gm({icon:e,label:t,value:r}){return n.jsxs(W,{children:[n.jsxs(se,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(ie,{className:"text-sm font-medium",children:t}),n.jsx(e,{className:"h-4 w-4 text-muted-foreground"})]}),n.jsx(U,{children:n.jsx("div",{className:"text-2xl font-bold",children:r})})]})}function f5e({vals:e}){const t=(e!=null&&e.length?e:[0,0,0,0,0]).map((r,s)=>({i:s,v:r}));return n.jsx("div",{className:"h-10 w-28",children:n.jsx(Xn,{width:"100%",height:"100%",children:n.jsx(Px,{data:t,children:n.jsx(Ao,{type:"monotone",dataKey:"v",stroke:"hsl(var(--primary))",strokeWidth:2,dot:!1})})})})}function m5e(){var c,d,u;const{studentId:e}=Ht(),t=Number(e),{data:r,isLoading:s}=fue(Number.isFinite(t)?t:void 0),{data:a,isLoading:i}=mue(Number.isFinite(t)?t:void 0),o=r??[],l=(c=a==null?void 0:a.trajectory)!=null&&c.length?a.trajectory:[{t:"W1",theta:.2},{t:"W2",theta:.35},{t:"W3",theta:.5},{t:"W4",theta:.62}];return s||i?n.jsx("div",{className:"p-6 text-muted-foreground",children:"Loading student…"}):n.jsxs("div",{className:"space-y-8 p-6 max-w-5xl mx-auto",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Adaptive trace"}),n.jsxs("p",{className:"text-muted-foreground text-sm mt-1",children:["Student #",t]})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Signal timeline"}),n.jsx($e,{children:"Inputs the engine reacted to"})]}),n.jsx(U,{children:n.jsx("div",{className:"rounded-md border overflow-x-auto",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Time"}),n.jsx(L,{children:"Signal"}),n.jsx(L,{children:"Value"}),n.jsx(L,{children:"Decision made"})]})}),n.jsx(Be,{children:o.map((f,h)=>n.jsxs(ee,{children:[n.jsx(T,{className:"whitespace-nowrap",children:new Date(f.time).toLocaleString()}),n.jsx(T,{children:f.signal}),n.jsx(T,{children:f.value}),n.jsx(T,{children:f.decision_made})]},h))})]})})})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Ability model (phase 2+)"}),n.jsx($e,{children:"Theta, SEM, and trajectory"})]}),n.jsxs(U,{className:"space-y-6",children:[n.jsxs("div",{className:"flex flex-wrap gap-8 text-sm",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-muted-foreground",children:"Theta"}),n.jsx("div",{className:"text-2xl font-semibold",children:((d=a==null?void 0:a.theta)==null?void 0:d.toFixed(3))??"—"})]}),n.jsxs("div",{children:[n.jsx("div",{className:"text-muted-foreground",children:"SEM"}),n.jsx("div",{className:"text-2xl font-semibold",children:((u=a==null?void 0:a.sem)==null?void 0:u.toFixed(3))??"—"})]})]}),n.jsx("div",{className:"h-72",children:n.jsx(Xn,{width:"100%",height:"100%",children:n.jsxs(Px,{data:l,children:[n.jsx(bs,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(kr,{dataKey:"t"}),n.jsx(Pr,{domain:["auto","auto"]}),n.jsx(fn,{}),n.jsx(Ao,{type:"monotone",dataKey:"theta",stroke:"hsl(var(--primary))",strokeWidth:2,dot:!0})]})})})]})]})]})}const ON={get:e=>R.get(`/entity/${e}/level-mapping`),update:(e,t)=>R.put(`/entity/${e}/level-mapping`,{mappings:t}),resetToDefault:e=>R.post(`/entity/${e}/level-mapping/reset`)};function h5e(e){const t=[...e].sort((r,s)=>r.cefr_min_score-s.cefr_min_score);for(const r of t)if(r.cefr_min_score>r.cefr_max_score)return"Each row must have min ≤ max.";for(let r=1;rON.get(t),enabled:Number.isFinite(t)}),[i,o]=p.useState([]);p.useEffect(()=>{var m;(m=s==null?void 0:s.mappings)!=null&&m.length&&o(s.mappings.map(y=>({...y})))},[s]);const l=p.useMemo(()=>JSON.stringify(i)!==JSON.stringify((s==null?void 0:s.mappings)??[]),[i,s]),c=ae({mutationFn:()=>ON.update(t,i),onSuccess:()=>{ct.success("Saved."),r.invalidateQueries({queryKey:de.levelMapping.get(t)})},onError:m=>ct.error(m instanceof Error?m.message:"Save failed")}),d=ae({mutationFn:()=>ON.resetToDefault(t),onSuccess:()=>{ct.success("Reset."),r.invalidateQueries({queryKey:de.levelMapping.get(t)})},onError:m=>ct.error(m instanceof Error?m.message:"Reset failed")}),u=(m,y)=>{o(x=>x.map((j,v)=>v===m?{...j,...y}:j))},f=()=>{o(m=>[...m,{cefr_min_score:0,cefr_max_score:0,internal_level_name:"New level",cefr_equivalent:"B1"}])},h=()=>{const m=h5e(i);if(m){ct.error(m);return}c.mutate()};return Number.isFinite(t)?a?n.jsx("div",{className:"p-6 text-muted-foreground",children:"Loading mapping…"}):n.jsxs("div",{className:"space-y-6 p-6 max-w-5xl mx-auto",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Level mapping"}),n.jsxs("p",{className:"text-muted-foreground text-sm mt-1",children:["Entity #",t]})]}),n.jsxs(W,{children:[n.jsxs(se,{className:"flex flex-row items-center justify-between",children:[n.jsxs("div",{children:[n.jsx(ie,{children:"CEFR ↔ internal levels"}),n.jsx($e,{children:"Editable grid with overlap validation"})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(E,{variant:"outline",onClick:f,children:"Add Row"}),n.jsx(E,{variant:"outline",onClick:()=>d.mutate(),disabled:d.isPending,children:"Reset to Default"}),n.jsx(E,{onClick:h,disabled:!l||c.isPending,children:"Save"})]})]}),n.jsx(U,{children:n.jsx("div",{className:"rounded-md border overflow-x-auto",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"CEFR min score"}),n.jsx(L,{children:"CEFR max score"}),n.jsx(L,{children:"Internal level name"}),n.jsx(L,{children:"CEFR equivalent"})]})}),n.jsx(Be,{children:i.map((m,y)=>n.jsxs(ee,{children:[n.jsx(T,{children:n.jsx(G,{type:"number",value:m.cefr_min_score,onChange:x=>u(y,{cefr_min_score:Number(x.target.value)})})}),n.jsx(T,{children:n.jsx(G,{type:"number",value:m.cefr_max_score,onChange:x=>u(y,{cefr_max_score:Number(x.target.value)})})}),n.jsx(T,{children:n.jsx(G,{value:m.internal_level_name,onChange:x=>u(y,{internal_level_name:x.target.value})})}),n.jsx(T,{children:n.jsx(G,{value:m.cefr_equivalent,onChange:x=>u(y,{cefr_equivalent:x.target.value})})})]},m.id??y))})]})})})]})]}):n.jsx("div",{className:"p-6 text-destructive",children:"Invalid entity."})}const x5e=No({primary_color:wn(),secondary_color:wn(),background_color:wn(),custom_subdomain:wn().optional(),login_title:wn().optional(),login_description:wn().optional()});function g5e(){const{entityId:e}=Ht(),t=Number(e),r=je(),{data:s,isLoading:a}=ye({queryKey:de.branding.get(t),queryFn:()=>Kd.get(t),enabled:Number.isFinite(t)}),i=Vl({resolver:ql(x5e),defaultValues:{primary_color:"#2563eb",secondary_color:"#64748b",background_color:"#f8fafc",custom_subdomain:"",login_title:"",login_description:""}});p.useEffect(()=>{s&&i.reset({primary_color:s.primary_color,secondary_color:s.secondary_color,background_color:s.background_color,custom_subdomain:s.custom_subdomain??"",login_title:s.login_title??"",login_description:s.login_description??""})},[s,i]);const[o,l]=p.useState(void 0),[c,d]=p.useState(void 0);p.useEffect(()=>{l(s==null?void 0:s.logo_url),d(s==null?void 0:s.favicon_url)},[s==null?void 0:s.logo_url,s==null?void 0:s.favicon_url]);const u=ae({mutationFn:async x=>{const j={...x,logo_url:o,favicon_url:c};return Kd.update(t,j)},onSuccess:()=>{ct.success("Branding saved."),r.invalidateQueries({queryKey:de.branding.get(t)})},onError:x=>ct.error(x instanceof Error?x.message:"Save failed")}),f=ae({mutationFn:()=>Kd.resetToDefault(t),onSuccess:()=>{ct.success("Defaults restored."),r.invalidateQueries({queryKey:de.branding.get(t)})},onError:x=>ct.error(x instanceof Error?x.message:"Reset failed")}),h=x=>{x&&Kd.uploadLogo(t,x).then(j=>l(j.url)).catch(j=>ct.error(String(j)))},m=x=>{x&&Kd.uploadFavicon(t,x).then(j=>d(j.url)).catch(j=>ct.error(String(j)))},y=i.watch();return Number.isFinite(t)?a&&!s?n.jsx("div",{className:"p-6 text-muted-foreground",children:"Loading branding…"}):n.jsxs("div",{className:"space-y-6 p-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"White-label branding"}),n.jsxs("p",{className:"text-muted-foreground text-sm mt-1",children:["Entity #",t]})]}),n.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Brand assets"}),n.jsx($e,{children:"Logo, favicon, palette, and login copy"})]}),n.jsx(U,{children:n.jsx(Wl,{...i,children:n.jsxs("form",{onSubmit:i.handleSubmit(x=>u.mutate(x)),className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(at,{children:"Logo"}),n.jsx(G,{type:"file",accept:"image/*",onChange:x=>{var j;return h(((j=x.target.files)==null?void 0:j[0])??null)}}),o?n.jsx("img",{src:o,alt:"",className:"h-12 object-contain"}):null]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(at,{children:"Favicon"}),n.jsx(G,{type:"file",accept:"image/*",onChange:x=>{var j;return m(((j=x.target.files)==null?void 0:j[0])??null)}}),c?n.jsx("img",{src:c,alt:"",className:"h-8 w-8 object-contain"}):null]}),n.jsx(et,{control:i.control,name:"primary_color",render:({field:x})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Primary"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(rt,{children:n.jsx(G,{type:"color",className:"h-10 w-14 p-1",...x})}),n.jsx(G,{...x})]}),n.jsx(ot,{})]})}),n.jsx(et,{control:i.control,name:"secondary_color",render:({field:x})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Secondary"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(rt,{children:n.jsx(G,{type:"color",className:"h-10 w-14 p-1",...x})}),n.jsx(G,{...x})]}),n.jsx(ot,{})]})}),n.jsx(et,{control:i.control,name:"background_color",render:({field:x})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Background"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(rt,{children:n.jsx(G,{type:"color",className:"h-10 w-14 p-1",...x})}),n.jsx(G,{...x})]}),n.jsx(ot,{})]})}),n.jsx(et,{control:i.control,name:"custom_subdomain",render:({field:x})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Subdomain"}),n.jsx(rt,{children:n.jsx(G,{placeholder:"your-school",...x})}),n.jsx(ot,{})]})}),n.jsx(et,{control:i.control,name:"login_title",render:({field:x})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Login title"}),n.jsx(rt,{children:n.jsx(G,{...x})}),n.jsx(ot,{})]})}),n.jsx(et,{control:i.control,name:"login_description",render:({field:x})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Login description"}),n.jsx(rt,{children:n.jsx(G,{...x})}),n.jsx(ot,{})]})}),n.jsxs("div",{className:"flex gap-2 pt-2",children:[n.jsx(E,{type:"submit",disabled:u.isPending,children:"Save Branding"}),n.jsx(E,{type:"button",variant:"outline",onClick:()=>f.mutate(),disabled:f.isPending,children:"Reset to Default"})]})]})})})]}),n.jsxs(W,{className:"lg:sticky lg:top-6 h-fit",children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Live preview"}),n.jsx($e,{children:"Mock login with current colors"})]}),n.jsx(U,{children:n.jsxs("div",{className:"rounded-xl border shadow-sm p-8 min-h-[320px] flex flex-col items-center justify-center gap-4",style:{backgroundColor:y.background_color},children:[o?n.jsx("img",{src:o,alt:"",className:"h-10 object-contain"}):null,n.jsx("h2",{className:"text-xl font-semibold text-center",style:{color:y.primary_color},children:y.login_title||(s==null?void 0:s.entity_name)||"Sign in"}),n.jsx("p",{className:"text-sm text-center max-w-sm",style:{color:y.secondary_color},children:y.login_description||"Access your learning workspace."}),n.jsxs("div",{className:"w-full max-w-xs space-y-3 rounded-lg border bg-background/80 p-4 backdrop-blur",style:{borderColor:y.secondary_color},children:[n.jsx(G,{placeholder:"Email",disabled:!0,className:"bg-background"}),n.jsx(G,{type:"password",placeholder:"Password",disabled:!0,className:"bg-background"}),n.jsx(E,{className:"w-full",style:{backgroundColor:y.primary_color},children:"Continue"})]})]})})]})]})]}):n.jsx("div",{className:"p-6 text-destructive",children:"Invalid entity."})}function v5e(){const{data:e,isLoading:t,refetch:r}=xue(),s=gue(),a=vue(),i=yue(),[o,l]=p.useState(new Set),[c,d]=p.useState(!1),[u,f]=p.useState(null),[h,m]=p.useState(""),y=(e==null?void 0:e.data)??[],x=w=>{l(S=>{const _=new Set(S);return _.has(w)?_.delete(w):_.add(w),_})},j=w=>{l(w?new Set(y.map(S=>S.attempt_id)):new Set)},v=w=>{s.mutate(w,{onSuccess:()=>{ct.success("Released."),r()},onError:S=>ct.error(S instanceof Error?S.message:"Failed")})},g=w=>{f(w),m(""),d(!0)},b=()=>{u&&a.mutate({attemptId:u.attempt_id,reason:h},{onSuccess:()=>{ct.success("Rejected."),d(!1),r()},onError:w=>ct.error(w instanceof Error?w.message:"Failed")})},N=()=>{const w=[...o];w.length&&i.mutate(w,{onSuccess:()=>{ct.success("Bulk release complete."),l(new Set),r()},onError:S=>ct.error(S instanceof Error?S.message:"Failed")})};return n.jsxs("div",{className:"space-y-6 p-6 max-w-6xl mx-auto",children:[n.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Pending score releases"}),n.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Approve before students see results"})]}),n.jsx(E,{onClick:N,disabled:!o.size||i.isPending,children:"Approve All Selected"})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Queue"}),n.jsx($e,{children:"Official and practice attempts awaiting approval"})]}),n.jsx(U,{children:t?n.jsx("p",{className:"text-muted-foreground py-8 text-center",children:"Loading…"}):n.jsx("div",{className:"rounded-md border overflow-x-auto",children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{className:"w-12",children:n.jsx(an,{checked:y.length>0&&o.size===y.length,onCheckedChange:w=>j(!!w)})}),n.jsx(L,{children:"Student"}),n.jsx(L,{children:"Exam"}),n.jsx(L,{children:"Type"}),n.jsx(L,{children:"Submitted"}),n.jsx(L,{children:"Score"}),n.jsx(L,{children:"Status"}),n.jsx(L,{className:"text-right",children:"Actions"})]})}),n.jsx(Be,{children:y.map(w=>n.jsxs(ee,{children:[n.jsx(T,{children:n.jsx(an,{checked:o.has(w.attempt_id),onCheckedChange:()=>x(w.attempt_id)})}),n.jsx(T,{className:"font-medium",children:w.student_name}),n.jsx(T,{children:w.exam_title}),n.jsx(T,{className:"capitalize",children:w.exam_type}),n.jsx(T,{className:"whitespace-nowrap text-sm text-muted-foreground",children:new Date(w.submitted_at).toLocaleString()}),n.jsx(T,{children:w.overall_score}),n.jsx(T,{children:w.status}),n.jsxs(T,{className:"text-right space-x-2 whitespace-nowrap",children:[n.jsx(E,{size:"sm",onClick:()=>v(w.attempt_id),disabled:s.isPending,children:"Approve"}),n.jsx(E,{size:"sm",variant:"destructive",onClick:()=>g(w),children:"Reject"}),n.jsx(E,{size:"sm",variant:"outline",children:"View Details"})]})]},w.id))})]})})})]}),n.jsx(Qe,{open:c,onOpenChange:d,children:n.jsxs(Ue,{children:[n.jsx(Ke,{children:n.jsx(Ge,{children:"Reject release"})}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"reason",children:"Reason"}),n.jsx(on,{id:"reason",value:h,onChange:w=>m(w.target.value),rows:4})]}),n.jsxs(Ct,{children:[n.jsx(E,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),n.jsx(E,{variant:"destructive",onClick:b,disabled:a.isPending,children:"Confirm reject"})]})]})})]})}function M$(e){const t=Math.floor(e/60),r=e%60;return t<=0?`${r}m`:r?`${t}h ${r}m`:`${t}h`}function R$(e){var i;const t=((i=e.structure)==null?void 0:i.skills)??[],r=e.skill_count??t.length,s=e.total_questions??t.reduce((o,l)=>o+(l.parts??[]).reduce((c,d)=>c+(d.question_count??0),0),0),a=e.total_time_min??t.reduce((o,l)=>o+(l.total_time_min??0),0);return{skillCount:r,totalQuestions:s,timeMin:a}}const y5e=e=>{const t=e.toLowerCase();return t.includes("general")?_i:t.includes("academic")?Kt:t.includes("toefl")?WG:BG};function j5e(){const e=Bt(),t=Bde(),r=zde(),s=p.useMemo(()=>{const i=t.data;return Array.isArray(i)?i:i&&typeof i=="object"&&"data"in i&&Array.isArray(i.data)?i.data:i&&typeof i=="object"&&"items"in i&&Array.isArray(i.items)?i.items:[]},[t.data]),a=p.useMemo(()=>{const i=r.data;return Array.isArray(i)?i:i&&typeof i=="object"&&"data"in i&&Array.isArray(i.data)?i.data:i&&typeof i=="object"&&"items"in i&&Array.isArray(i.items)?i.items:[]},[r.data]);return n.jsxs("div",{className:"space-y-10 p-6 max-w-6xl mx-auto",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Create exam"}),n.jsx("p",{className:"text-muted-foreground mt-1",children:"Choose an international template or build a custom exam."})]}),n.jsxs("section",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(lt,{className:"h-5 w-5 text-primary"}),n.jsx("h2",{className:"text-lg font-medium",children:"International templates"})]}),n.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:t.isLoading?Array.from({length:3}).map((i,o)=>n.jsxs(W,{className:"overflow-hidden",children:[n.jsxs(se,{className:"space-y-2",children:[n.jsx(Wt,{className:"h-6 w-3/4"}),n.jsx(Wt,{className:"h-4 w-full"})]}),n.jsx(U,{children:n.jsx(Wt,{className:"h-20 w-full"})})]},o)):s.map(i=>{const o=y5e(i.name),{skillCount:l,totalQuestions:c,timeMin:d}=R$(i),u=!i.editable;return n.jsxs(W,{className:"cursor-pointer transition-shadow hover:shadow-md border-muted",role:"button",tabIndex:0,onClick:()=>e("/admin/exam/ielts/create"),onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),e("/admin/exam/ielts/create"))},children:[n.jsxs(se,{className:"flex flex-row items-start justify-between gap-2 space-y-0",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"rounded-lg bg-primary/10 p-2 text-primary",children:n.jsx(o,{className:"h-6 w-6"})}),n.jsxs("div",{children:[n.jsx(ie,{className:"text-base leading-tight",children:i.name}),n.jsx($e,{className:"mt-1",children:"Structured international assessment"})]})]}),u?n.jsxs(oe,{variant:"secondary",className:"shrink-0 gap-1",children:[n.jsx(zf,{className:"h-3 w-3"}),"Locked"]}):null]}),n.jsxs(U,{className:"text-sm text-muted-foreground space-y-1",children:[n.jsxs("p",{children:[n.jsx("span",{className:"font-medium text-foreground",children:l})," skills"]}),n.jsxs("p",{children:[n.jsx("span",{className:"font-medium text-foreground",children:c})," questions ·"," ",n.jsx("span",{className:"font-medium text-foreground",children:M$(d)})," total"]})]})]},i.id)})}),!t.isLoading&&s.length===0?n.jsx("p",{className:"text-sm text-muted-foreground",children:"No international templates are available yet."}):null]}),n.jsxs("section",{className:"space-y-4",children:[n.jsx("h2",{className:"text-lg font-medium",children:"Custom exam"}),n.jsx(W,{className:"cursor-pointer border-dashed border-2 transition-colors hover:border-primary/60 hover:bg-muted/30",role:"button",tabIndex:0,onClick:()=>e("/admin/exam/custom/create"),onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),e("/admin/exam/custom/create"))},children:n.jsxs(se,{className:"flex flex-row items-center gap-4",children:[n.jsx("div",{className:"rounded-full bg-primary/15 p-3 text-primary",children:n.jsx(mt,{className:"h-8 w-8"})}),n.jsxs("div",{children:[n.jsx(ie,{children:"Create custom exam"}),n.jsx($e,{children:"Define sections, scoring, and your own question mix."})]})]})})]}),n.jsx(qs,{}),n.jsxs("section",{className:"space-y-4",children:[n.jsx("h2",{className:"text-lg font-medium",children:"My templates"}),r.isLoading?n.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[n.jsx(Wt,{className:"h-24 w-full"}),n.jsx(Wt,{className:"h-24 w-full"})]}):a.length===0?n.jsx("p",{className:"text-sm text-muted-foreground",children:"You have not saved any custom templates yet."}):n.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:a.map(i=>{const{skillCount:o,totalQuestions:l,timeMin:c}=R$(i);return n.jsxs(W,{className:"border-muted",children:[n.jsxs(se,{className:"pb-2",children:[n.jsx(ie,{className:"text-base",children:i.name}),n.jsxs($e,{children:[o," skills · ",l," questions · ",M$(c)]})]}),n.jsx(U,{className:"flex justify-end pt-0",children:n.jsx(E,{variant:"outline",size:"sm",type:"button",onClick:()=>e("/admin/exam/custom/create"),children:"Use as starting point"})})]},i.id)})})]})]})}const b5e=[{id:"listening",label:"Listening"},{id:"reading",label:"Reading"},{id:"writing",label:"Writing"},{id:"speaking",label:"Speaking"}],w5e=No({exam_type:Ta(["academic","general_training"]),skills:vb(Ta(["listening","reading","writing","speaking"])).min(1),title:wn().min(2,"Title is required"),target_band:Js().min(4).max(9),difficulty:Ta(["easy","medium","hard"]),randomize:Ho(),assembly_mode:Ta(["auto","manual","hybrid"]),results_release_mode:Ta(["auto","manual_approval"])});function N5e(){const e=[];for(let t=4;t<=9;t+=.5)e.push(Math.round(t*10)/10);return e}const $$=N5e();function S5e(e){let t=$$[0],r=Math.abs(e-t);for(const s of $$){const a=Math.abs(e-s);a{const c=s==="academic"?"IELTS Academic":"IELTS General Training",d=a.toFixed(1),u=Pi(new Date,"yyyy-MM-dd");return`${c} — Band ${d} — ${u}`},[s,a]);p.useEffect(()=>{r.getValues("title").trim()||r.setValue("title",i)},[r,i]);const o=()=>{r.setValue("title",i)},l=async c=>{var m;const d={exam_type:c.exam_type,skills:c.skills,title:c.title,target_band:c.target_band,difficulty:c.difficulty,randomize:c.randomize,assembly_mode:c.assembly_mode,results_release_mode:c.results_release_mode},f=await t.mutateAsync(d),h=f.exam_id??((m=f.data)==null?void 0:m.exam_id);h!=null&&(sessionStorage.setItem(`ielts_assembly_${h}`,c.assembly_mode),e(`/admin/exam/ielts/${h}/skills`))};return n.jsxs("div",{className:"p-6 max-w-4xl mx-auto space-y-8",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"IELTS exam — Phase 1"}),n.jsx("p",{className:"text-muted-foreground mt-1",children:"Initialization and assembly preferences."})]}),n.jsx("div",{className:"flex gap-2",children:["Initialization","Skills","Content","Validate"].map((c,d)=>n.jsxs("div",{className:`flex-1 rounded-md border px-3 py-2 text-center text-sm ${d===0?"border-primary bg-primary/5 font-medium":"border-muted text-muted-foreground"}`,children:[d+1,". ",c]},c))}),n.jsx(Wl,{...r,children:n.jsxs("form",{onSubmit:r.handleSubmit(l),className:"space-y-8",children:[n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Exam type"}),n.jsx($e,{children:"Select the official IELTS paper type."})]}),n.jsx(U,{children:n.jsx(et,{control:r.control,name:"exam_type",render:({field:c})=>n.jsxs(tt,{children:[n.jsx(rt,{children:n.jsxs(es,{onValueChange:d=>c.onChange(d),value:c.value,className:"grid gap-3 sm:grid-cols-2",children:[n.jsxs(q,{htmlFor:"et-academic",className:"flex cursor-pointer items-center gap-3 rounded-lg border p-4 has-[[data-state=checked]]:border-primary",children:[n.jsx(Bn,{value:"academic",id:"et-academic"}),n.jsx("span",{className:"font-medium",children:"IELTS Academic"})]}),n.jsxs(q,{htmlFor:"et-gt",className:"flex cursor-pointer items-center gap-3 rounded-lg border p-4 has-[[data-state=checked]]:border-primary",children:[n.jsx(Bn,{value:"general_training",id:"et-gt"}),n.jsx("span",{className:"font-medium",children:"General Training"})]})]})}),n.jsx(ot,{})]})})})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Target skills"}),n.jsx($e,{children:"Include at least one skill in this build."})]}),n.jsx(U,{children:n.jsx(et,{control:r.control,name:"skills",render:()=>n.jsxs(tt,{children:[n.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:b5e.map(c=>n.jsx(et,{control:r.control,name:"skills",render:({field:d})=>{var u;return n.jsxs(tt,{className:"flex flex-row items-start space-x-3 space-y-0 rounded-md border p-4",children:[n.jsx(rt,{children:n.jsx(an,{checked:(u=d.value)==null?void 0:u.includes(c.id),onCheckedChange:f=>{const h=new Set(d.value??[]);f?h.add(c.id):h.delete(c.id),d.onChange(Array.from(h))}})}),n.jsx(at,{className:"font-normal cursor-pointer",children:c.label})]})}},c.id))}),n.jsx(ot,{})]})})})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{children:"Exam details"})}),n.jsxs(U,{className:"space-y-6",children:[n.jsx(et,{control:r.control,name:"title",render:({field:c})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Exam title"}),n.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[n.jsx(rt,{children:n.jsx(G,{placeholder:i,...c})}),n.jsx(E,{type:"button",variant:"secondary",onClick:o,children:"Apply suggested"})]}),n.jsx(Jh,{children:"Uses type, band, and today’s date."}),n.jsx(ot,{})]})}),n.jsx(et,{control:r.control,name:"target_band",render:({field:c})=>n.jsxs(tt,{children:[n.jsxs(at,{children:["Target band (",c.value.toFixed(1),")"]}),n.jsx(rt,{children:n.jsx(oa,{min:4,max:9,step:.5,value:[c.value],onValueChange:d=>c.onChange(S5e(d[0]??7)),className:"max-w-md"})}),n.jsx(ot,{})]})}),n.jsx(et,{control:r.control,name:"difficulty",render:({field:c})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Difficulty"}),n.jsxs(Oe,{onValueChange:c.onChange,value:c.value,children:[n.jsx(rt,{children:n.jsx(Ae,{className:"max-w-xs",children:n.jsx(Me,{placeholder:"Select"})})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"easy",children:"Easy"}),n.jsx(Y,{value:"medium",children:"Medium"}),n.jsx(Y,{value:"hard",children:"Hard"})]})]}),n.jsx(ot,{})]})}),n.jsx(et,{control:r.control,name:"randomize",render:({field:c})=>n.jsxs(tt,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[n.jsxs("div",{className:"space-y-0.5",children:[n.jsx(at,{children:"Randomization"}),n.jsx(Jh,{children:"Shuffle order within allowed constraints."})]}),n.jsx(rt,{children:n.jsx(Fr,{checked:c.value,onCheckedChange:c.onChange})})]})})]})]}),n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Assembly mode"}),n.jsx($e,{children:"How items are chosen from the content pool."})]}),n.jsx(U,{children:n.jsx(et,{control:r.control,name:"assembly_mode",render:({field:c})=>n.jsxs(tt,{children:[n.jsx(rt,{children:n.jsxs(es,{onValueChange:c.onChange,value:c.value,className:"grid gap-4",children:[n.jsxs(q,{className:"flex cursor-pointer gap-3 rounded-lg border p-4 has-[[data-state=checked]]:border-primary",children:[n.jsx(Bn,{value:"auto",id:"am-auto"}),n.jsxs("div",{children:[n.jsx("span",{className:"font-medium",children:"Auto"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"The system fills every slot using rules and pool metadata."})]})]}),n.jsxs(q,{className:"flex cursor-pointer gap-3 rounded-lg border p-4 has-[[data-state=checked]]:border-primary",children:[n.jsx(Bn,{value:"manual",id:"am-manual"}),n.jsxs("div",{children:[n.jsx("span",{className:"font-medium",children:"Manual"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"You select each question from the pool."})]})]}),n.jsxs(q,{className:"flex cursor-pointer gap-3 rounded-lg border p-4 has-[[data-state=checked]]:border-primary",children:[n.jsx(Bn,{value:"hybrid",id:"am-hybrid"}),n.jsxs("div",{children:[n.jsx("span",{className:"font-medium",children:"Hybrid"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Suggested sets with per-item accept or reject."})]})]})]})}),n.jsx(ot,{})]})})})]}),n.jsxs(W,{children:[n.jsx(se,{children:n.jsx(ie,{children:"Score release"})}),n.jsx(U,{children:n.jsx(et,{control:r.control,name:"results_release_mode",render:({field:c})=>n.jsxs(tt,{children:[n.jsx(rt,{children:n.jsxs(es,{onValueChange:c.onChange,value:c.value,className:"grid gap-3 sm:grid-cols-2",children:[n.jsxs(q,{className:"flex cursor-pointer items-center gap-3 rounded-lg border p-4 has-[[data-state=checked]]:border-primary",children:[n.jsx(Bn,{value:"auto",id:"sr-auto"}),n.jsx("span",{children:"Auto-release"})]}),n.jsxs(q,{className:"flex cursor-pointer items-center gap-3 rounded-lg border p-4 has-[[data-state=checked]]:border-primary",children:[n.jsx(Bn,{value:"manual_approval",id:"sr-manual"}),n.jsx("span",{children:"Manual approval"})]})]})}),n.jsx(ot,{})]})})})]}),n.jsxs(td,{children:[n.jsx(fk,{className:"h-4 w-4"}),n.jsx(nd,{children:"IELTS structure (reference)"}),n.jsx(rd,{className:"space-y-2 mt-2",children:n.jsxs("ul",{className:"list-disc pl-4 text-sm space-y-1",children:[n.jsx("li",{children:"Listening: 4 parts, 10 questions each (approx. 30 minutes plus transfer time)."}),n.jsx("li",{children:"Reading: 3 passages, about 13–14 questions each (60 minutes)."}),n.jsx("li",{children:"Writing: 2 tasks (60 minutes)."}),n.jsx("li",{children:"Speaking: 3 parts (11–14 minutes)."})]})})]}),n.jsx(qs,{}),n.jsxs("div",{className:"flex justify-end gap-3",children:[n.jsx(E,{type:"button",variant:"outline",onClick:()=>e(-1),children:"Back"}),n.jsx(E,{type:"submit",disabled:t.isPending,children:t.isPending?"Creating…":"Next"})]})]})})]})}const TN={listening:"Listening",reading:"Reading",writing:"Writing",speaking:"Speaking"},UW={listening:[{question_count:10,content_type:"Audio + MCQ",time_limit_min:7,description:"Part 1 — everyday social"},{question_count:10,content_type:"Audio + MCQ",time_limit_min:7,description:"Part 2 — monologue"},{question_count:10,content_type:"Audio + MCQ",time_limit_min:8,description:"Part 3 — conversation"},{question_count:10,content_type:"Audio + MCQ",time_limit_min:8,description:"Part 4 — lecture"}],reading:[{question_count:13,content_type:"Passage + items",time_limit_min:20,description:"Passage 1"},{question_count:13,content_type:"Passage + items",time_limit_min:20,description:"Passage 2"},{question_count:14,content_type:"Passage + items",time_limit_min:20,description:"Passage 3"}],writing:[{question_count:1,content_type:"Task response",time_limit_min:20,description:"Task 1"},{question_count:1,content_type:"Essay",time_limit_min:40,description:"Task 2"}],speaking:[{question_count:1,content_type:"Interview",time_limit_min:5,description:"Part 1 — introduction"},{question_count:1,content_type:"Long turn",time_limit_min:4,description:"Part 2 — cue card"},{question_count:1,content_type:"Discussion",time_limit_min:5,description:"Part 3 — abstract"}]};function I$(e,t){var s;const r=(s=t==null?void 0:t.parts)!=null&&s.length?t.parts:[];return r.length?r:UW[e].map((a,i)=>({part_number:i+1,...a}))}function D$(e,t){const r=t.reduce((s,a)=>s+a.question_count,0);return r>0?r:e==="listening"||e==="reading"?40:e==="writing"?2:3}function C5e(){var d;const{examId:e}=Ht(),t=Bt(),r=Number(e),{data:s,isLoading:a,isError:i}=qB(Number.isFinite(r)?r:0),o=p.useMemo(()=>s?Array.isArray(s)?s:s.data??[]:[],[s]),l=(o.length>0?(d=o[0])==null?void 0:d.skill:"listening")??"listening";if(!Number.isFinite(r)||r<=0)return n.jsx("p",{className:"p-6 text-destructive",children:"Invalid exam."});if(a)return n.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-4",children:[n.jsx(Wt,{className:"h-10 w-64"}),n.jsx(Wt,{className:"h-96 w-full"})]});const c=o.length>0?o:["listening","reading","writing","speaking"].map(u=>({skill:u,parts:UW[u].map((f,h)=>({part_number:h+1,...f})),available_count:0}));return n.jsx("div",{className:"p-6 max-w-6xl mx-auto",children:n.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row",children:[n.jsxs("div",{className:"flex-1 space-y-4 min-w-0",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Skill layout"}),n.jsx("p",{className:"text-muted-foreground mt-1",children:"Review the official structure before choosing content."})]}),n.jsxs(Us,{defaultValue:l,className:"w-full",children:[n.jsx(ws,{className:"flex flex-wrap h-auto gap-1",children:c.map(u=>n.jsx(Et,{value:u.skill,className:"capitalize",children:TN[u.skill]},u.skill))}),c.map(u=>{const f=I$(u.skill,u),h=D$(u.skill,f),m=u.available_count??0,y=h>0?Math.min(100,Math.round(m/h*100)):0;return n.jsx(Lt,{value:u.skill,className:"space-y-4",children:n.jsxs(W,{children:[n.jsxs(se,{className:"flex flex-row items-start justify-between gap-4",children:[n.jsxs("div",{children:[n.jsx(ie,{className:"capitalize",children:TN[u.skill]}),n.jsxs($e,{children:["Read-only structure. Pool coverage: ",m," items available for ~",h," required questions."]})]}),n.jsxs(oe,{variant:y>=100?"default":"secondary",children:[y,"% pool coverage"]})]}),n.jsx(U,{children:n.jsxs(Le,{children:[n.jsx(Fe,{children:n.jsxs(ee,{children:[n.jsx(L,{children:"Part"}),n.jsx(L,{children:"Questions"}),n.jsx(L,{children:"Content type"}),n.jsx(L,{children:"Time (min)"}),n.jsx(L,{className:"text-right",children:"Pool"}),n.jsx(L,{className:"text-right w-[140px]"})]})}),n.jsx(Be,{children:f.map(x=>n.jsxs(ee,{children:[n.jsx(T,{className:"font-medium",children:x.part_number}),n.jsx(T,{children:x.question_count}),n.jsx(T,{children:x.content_type}),n.jsx(T,{children:x.time_limit_min}),n.jsx(T,{className:"text-right text-muted-foreground",children:Math.max(0,Math.floor(m/f.length))}),n.jsx(T,{className:"text-right",children:n.jsx(E,{size:"sm",type:"button",onClick:()=>t(`/admin/exam/ielts/${r}/content?skill=${u.skill}&part=${x.part_number}`),children:"Configure content"})})]},`${u.skill}-${x.part_number}`))})]})})]})},u.skill)})]})]}),n.jsx("aside",{className:"w-full lg:w-80 shrink-0 space-y-3",children:n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{className:"text-base",children:"Completion"}),n.jsx($e,{children:"Per-skill readiness for assembly."})]}),n.jsxs(U,{className:"space-y-3",children:[n.jsx(ua,{className:"h-[min(420px,50vh)]",children:c.map(u=>{const f=I$(u.skill,u),h=D$(u.skill,f),y=(u.available_count??0)>=h;return n.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-3 mb-2 text-sm",children:[n.jsx("span",{className:"capitalize font-medium",children:TN[u.skill]}),n.jsx(oe,{variant:y?"default":"outline",children:y?"Ready":"Needs content"})]},u.skill)})}),n.jsx(E,{className:"w-full",type:"button",onClick:()=>t(`/admin/exam/ielts/${r}/validate`),children:"Continue to validation"})]})]})})]})})}const k5e=[{value:"listening",label:"Listening"},{value:"reading",label:"Reading"},{value:"writing",label:"Writing"},{value:"speaking",label:"Speaking"}];function L$(e){return e.charAt(0).toUpperCase()+e.slice(1)}function P5e(){const{examId:e}=Ht(),t=Bt(),[r,s]=wo(),a=Number(e),[i,o]=p.useState(()=>r.get("skill")||"listening"),[l,c]=p.useState(()=>Number(r.get("part"))||1),[d,u]=p.useState(1),h=["easy","medium","hard"][d]??"medium",[m,y]=p.useState(""),[x,j]=p.useState(""),[v,g]=p.useState([]),[b,N]=p.useState([]),w=p.useMemo(()=>Number.isFinite(a)?sessionStorage.getItem(`ielts_assembly_${a}`)??"manual":"manual",[a]),S=p.useMemo(()=>({skill:i,part:l,difficulty:h,topics:m.split(",").map(k=>k.trim()).filter(Boolean),search:x.trim()||void 0}),[i,l,h,m,x]),_=qde(Number.isFinite(a)?a:0,S),C=qB(Number.isFinite(a)?a:0),P=Wde(),D=p.useMemo(()=>{const k=_.data;return Array.isArray(k)?k:k&&typeof k=="object"&&Array.isArray(k.data)?k.data:[]},[_.data]),z=p.useMemo(()=>{const k=C.data;return Array.isArray(k)?k:k&&typeof k=="object"&&Array.isArray(k.data)?k.data:[]},[C.data]),O=p.useMemo(()=>{var M;const k=z.find(K=>K.skill===i);return(M=k==null?void 0:k.parts)!=null&&M.length?k.parts.reduce((K,X)=>K+X.question_count,0):i==="listening"||i==="reading"?40:i==="writing"?2:3},[z,i]);p.useEffect(()=>{s(k=>{const M=new URLSearchParams(k);return M.set("skill",i),M.set("part",String(l)),M},{replace:!0})},[i,l,s]);const V=p.useRef(!1);p.useEffect(()=>{if(w!=="auto"||!Number.isFinite(a)||V.current)return;V.current=!0;let k=!1;return(async()=>{try{const M=await P.mutateAsync(a);if(k)return;const K=(Array.isArray(M)?M:[]).flatMap(X=>{var re;return((re=X.selected_items)==null?void 0:re.map(Z=>Z.id))??[]});g(K)}catch{ct.error("Auto-assembly could not run.")}})(),()=>{k=!0}},[w,P,a]),p.useEffect(()=>{if(w!=="hybrid"||!Number.isFinite(a))return;let k=!1;return(async()=>{try{const M=await bi.suggest(a);if(k)return;const X=(Array.isArray(M)?M:[]).find(re=>re.skill===i&&re.part===l);N((X==null?void 0:X.selected_items)??[])}catch{N([])}})(),()=>{k=!0}},[w,a,l,i]);const A=p.useCallback(k=>{g(M=>M.includes(k)?M.filter(K=>K!==k):[...M,k])},[]),$=p.useMemo(()=>{const k=new Map(D.map(M=>[M.id,M]));return v.map(M=>k.get(M)).filter(Boolean)},[D,v]),B=w==="auto",I=async()=>{try{await bi.saveQuestions(a,l,v),ct.success("Selections saved."),t(`/admin/exam/ielts/${a}/validate`)}catch{ct.error("Save failed.")}};return!Number.isFinite(a)||a<=0?n.jsx("p",{className:"p-6 text-destructive",children:"Invalid exam."}):n.jsxs("div",{className:"p-6 max-w-[1400px] mx-auto space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Content pool"}),n.jsxs("p",{className:"text-muted-foreground mt-1",children:["Assembly: ",n.jsx("span",{className:"text-foreground font-medium capitalize",children:w}),w==="auto"?" — pool is read-only; system selections apply.":null,w==="hybrid"?" — review suggestions on the right.":null]})]}),n.jsxs("div",{className:"grid gap-4 lg:grid-cols-5",children:[n.jsxs(W,{className:"lg:col-span-3",children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Browse pool"}),n.jsx($e,{children:"Filter and preview candidate items."})]}),n.jsxs(U,{className:"space-y-4",children:[n.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Skill"}),n.jsxs(Oe,{value:i,onValueChange:k=>o(k),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsx(Ee,{children:k5e.map(k=>n.jsx(Y,{value:k.value,children:k.label},k.value))})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Part"}),n.jsxs(Oe,{value:String(l),onValueChange:k=>c(Number(k)),children:[n.jsx(Ae,{children:n.jsx(Me,{})}),n.jsx(Ee,{children:[1,2,3,4].map(k=>n.jsxs(Y,{value:String(k),children:["Part ",k]},k))})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs(q,{children:["Difficulty (",L$(h),")"]}),n.jsx(oa,{min:0,max:2,step:1,value:[d],onValueChange:k=>u(k[0]??1)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"topics",children:"Topic tags"}),n.jsx(G,{id:"topics",placeholder:"education, environment …",value:m,onChange:k=>y(k.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"search",children:"Search"}),n.jsx(G,{id:"search",placeholder:"Keyword in stem",value:x,onChange:k=>j(k.target.value)})]}),n.jsx(qs,{}),_.isLoading?n.jsxs("div",{className:"space-y-2",children:[n.jsx(Wt,{className:"h-24 w-full"}),n.jsx(Wt,{className:"h-24 w-full"})]}):n.jsx(ua,{className:"h-[min(520px,55vh)] pr-3",children:n.jsxs("div",{className:`space-y-3 ${B?"opacity-50 pointer-events-none":""}`,children:[D.map(k=>n.jsxs(W,{className:"border-muted",children:[n.jsxs(se,{className:"py-3 space-y-1",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(oe,{variant:"outline",children:L$(k.difficulty)}),n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Used ",k.usage_count,"×"]})]}),n.jsx(ie,{className:"text-sm font-normal leading-snug",children:k.preview_text}),n.jsx("div",{className:"flex flex-wrap gap-1",children:k.topic_tags.map(M=>n.jsx(oe,{variant:"secondary",className:"text-xs",children:M},M))})]}),n.jsx(U,{className:"pt-0 flex justify-end gap-2",children:n.jsx(E,{type:"button",size:"sm",variant:v.includes(k.id)?"secondary":"default",disabled:B,onClick:()=>A(k.id),children:v.includes(k.id)?"Remove":"Add"})})]},k.id)),D.length===0?n.jsx("p",{className:"text-sm text-muted-foreground",children:"No items match these filters."}):null]})})]})]}),n.jsxs(W,{className:"lg:col-span-2",children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Selected questions"}),n.jsxs($e,{children:[v.length,"/",O," selected"]})]}),n.jsxs(U,{className:"space-y-4",children:[n.jsx(ua,{className:"h-[min(400px,45vh)]",children:n.jsxs("ul",{className:"space-y-2 text-sm",children:[$.map(k=>n.jsxs("li",{className:"rounded-md border p-2 flex justify-between gap-2",children:[n.jsx("span",{className:"line-clamp-2",children:k.preview_text}),n.jsx(E,{type:"button",size:"icon",variant:"ghost",className:"shrink-0",onClick:()=>A(k.id),children:n.jsx(ts,{className:"h-4 w-4"})})]},k.id)),$.length===0?n.jsx("li",{className:"text-muted-foreground",children:"Nothing selected yet."}):null]})}),w==="hybrid"&&b.length>0?n.jsxs("div",{className:"space-y-2",children:[n.jsx("p",{className:"text-sm font-medium",children:"Suggestions"}),b.map(k=>n.jsxs("div",{className:"flex items-start justify-between gap-2 rounded-md border p-2 text-sm",children:[n.jsx("span",{className:"line-clamp-3",children:k.preview_text}),n.jsxs("div",{className:"flex gap-1 shrink-0",children:[n.jsx(E,{type:"button",size:"icon",variant:"outline",onClick:()=>{v.includes(k.id)||g(M=>[...M,k.id]),N(M=>M.filter(K=>K.id!==k.id))},children:n.jsx(aa,{className:"h-4 w-4"})}),n.jsx(E,{type:"button",size:"icon",variant:"ghost",onClick:()=>N(M=>M.filter(K=>K.id!==k.id)),children:n.jsx(ts,{className:"h-4 w-4"})})]})]},k.id))]}):null,n.jsx(E,{className:"w-full",type:"button",onClick:I,children:"Save & continue"})]})]})]})]})}function A5e(e){return e.status==="pass"?n.jsx(oe,{className:"bg-emerald-600 hover:bg-emerald-600",children:"Pass"}):e.status==="fail"?n.jsx(oe,{variant:"destructive",children:"Fail"}):n.jsx(oe,{className:"bg-amber-500 hover:bg-amber-500 text-foreground",children:"Warning"})}function E5e(){var O,V,A,$,B,I;const{examId:e}=Ht(),t=Bt(),r=Number(e),s=Ude(Number.isFinite(r)?r:0),a=Kde(),i=Gde(),[o,l]=p.useState(""),c=Qa({search:o||void 0,size:200}),d=_o(),[u,f]=p.useState([]),[h,m]=p.useState([]),[y,x]=p.useState(""),[j,v]=p.useState(""),[g,b]=p.useState(!1),N=p.useMemo(()=>{const k=s.data;if(k){if("checks"in k&&Array.isArray(k.checks))return k;if("data"in k&&k.data&&typeof k.data=="object"&&"checks"in k.data)return k.data}},[s.data]),w=(N==null?void 0:N.checks)??[],S=(N==null?void 0:N.can_publish)??(w.length>0?!w.some(k=>k.status==="fail"):!1),_=k=>{f(M=>M.includes(k)?M.filter(K=>K!==k):[...M,k])},C=k=>{m(M=>M.includes(k)?M.filter(K=>K!==k):[...M,k])},P=async()=>{try{await bi.update(r,{status:"draft"}),ct.success("Saved as draft.")}catch{ct.error("Could not save draft.")}},D=async()=>{try{await a.mutateAsync(r),ct.success("Exam published.")}catch{ct.error("Publish failed.")}},z=async()=>{try{await i.mutateAsync({examId:r,assignment:{student_ids:u.length?u:void 0,batch_ids:h.length?h:void 0,access_start:y||void 0,access_end:j||void 0}}),ct.success("Assignment created."),b(!1)}catch{ct.error("Assignment failed.")}};return!Number.isFinite(r)||r<=0?n.jsx("p",{className:"p-6 text-destructive",children:"Invalid exam."}):n.jsxs("div",{className:"p-6 max-w-3xl mx-auto space-y-8",children:[n.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Validate exam"}),n.jsx("p",{className:"text-muted-foreground mt-1",children:"Confirm structure, media, and scoring before go-live."})]}),n.jsxs(E,{type:"button",variant:"outline",className:"shrink-0 gap-2",onClick:()=>t(`/admin/exam?preview=${r}`),children:[n.jsx(Uc,{className:"h-4 w-4"}),"Preview exam"]})]}),s.isLoading?n.jsxs("div",{className:"space-y-2",children:[n.jsx(Wt,{className:"h-16 w-full"}),n.jsx(Wt,{className:"h-16 w-full"})]}):n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Checklist"}),n.jsx($e,{children:"Each rule must pass or be only a warning before publishing."})]}),n.jsx(U,{className:"space-y-4",children:w.length===0?n.jsx("p",{className:"text-sm text-muted-foreground",children:"No validation results yet."}):w.map(k=>n.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsx("span",{className:"font-medium",children:k.name}),A5e(k)]}),n.jsx("p",{className:"text-sm text-muted-foreground",children:k.description}),k.details?n.jsx("p",{className:"text-xs text-muted-foreground",children:k.details}):null]},k.name))})]}),n.jsx(qs,{}),n.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:flex-wrap",children:[n.jsx(E,{type:"button",variant:"secondary",onClick:P,children:"Save as draft"}),n.jsxs(E,{type:"button",disabled:!S||a.isPending,onClick:D,children:[a.isPending?n.jsx(Re,{className:"h-4 w-4 animate-spin"}):null,"Publish"]}),n.jsxs(Qe,{open:g,onOpenChange:b,children:[n.jsx(cr,{asChild:!0,children:n.jsx(E,{type:"button",variant:"outline",children:"Assign to students"})}),n.jsxs(Ue,{className:"max-w-lg",children:[n.jsxs(Ke,{children:[n.jsx(Ge,{children:"Assign exam"}),n.jsx(Qv,{children:"Pick students or batches and an optional access window."})]}),n.jsxs("div",{className:"space-y-4 py-2",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"stu-search",children:"Search students"}),n.jsx(G,{id:"stu-search",value:o,onChange:k=>l(k.target.value),placeholder:"Name or email"})]}),n.jsxs(ua,{className:"h-40 rounded-md border p-2",children:[(((O=c.data)==null?void 0:O.items)??((V=c.data)==null?void 0:V.data)??[]).map(k=>n.jsxs("label",{className:"flex items-center gap-2 py-1 text-sm cursor-pointer",children:[n.jsx(an,{checked:u.includes(k.id),onCheckedChange:()=>_(k.id)}),n.jsx("span",{children:k.name||k.email||`Student ${k.id}`})]},k.id)),(((A=c.data)==null?void 0:A.items)??(($=c.data)==null?void 0:$.data)??[]).length===0?n.jsx("p",{className:"text-sm text-muted-foreground p-2",children:"No students found."}):null]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{children:"Batches"}),n.jsx(ua,{className:"h-28 rounded-md border p-2",children:(((B=d.data)==null?void 0:B.items)??((I=d.data)==null?void 0:I.data)??[]).map(k=>n.jsxs("label",{className:"flex items-center gap-2 py-1 text-sm cursor-pointer",children:[n.jsx(an,{checked:h.includes(k.id),onCheckedChange:()=>C(k.id)}),n.jsx("span",{children:k.name})]},k.id))})]}),n.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"acc-start",children:"Access start"}),n.jsx(G,{id:"acc-start",type:"datetime-local",value:y,onChange:k=>x(k.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(q,{htmlFor:"acc-end",children:"Access end"}),n.jsx(G,{id:"acc-end",type:"datetime-local",value:j,onChange:k=>v(k.target.value)})]})]})]}),n.jsxs(Ct,{children:[n.jsx(E,{type:"button",variant:"outline",onClick:()=>b(!1),children:"Cancel"}),n.jsxs(E,{type:"button",disabled:i.isPending,onClick:z,children:[i.isPending?n.jsx(Re,{className:"h-4 w-4 animate-spin"}):null,"Confirm assign"]})]})]})]})]})]})}const O5e=No({title:wn().min(1),skill:wn().optional(),question_count:Nl.number().min(1),time_limit_min:Nl.number().optional(),scoring_method:Ta(["auto","rubric","mixed"]),sequence:Js(),question_ids:vb(Js())}),T5e=No({title:wn().min(2),subject_id:Nl.number().min(1),description:wn().optional(),total_time_min:Nl.number().min(1),pass_threshold:Nl.number().min(0).max(100),results_release_mode:Ta(["auto","manual_approval"]),randomize:Ho(),sections:vb(O5e).min(1),save_as_template:Ho(),template_name:wn().optional()}),M5e=["Reading","Listening","Writing","Speaking","Mixed"];function R5e(){const e=Bt(),[t,r]=p.useState(1),s=gx(),a=Hde(),i=Qde(),o=s.data??[],l=Vl({resolver:ql(T5e),defaultValues:{title:"",subject_id:0,description:"",total_time_min:60,pass_threshold:50,results_release_mode:"auto",randomize:!1,sections:[{title:"Section A",skill:"Reading",question_count:10,time_limit_min:20,scoring_method:"auto",sequence:0,question_ids:[]}],save_as_template:!1,template_name:""}}),{fields:c,append:d,remove:u,move:f}=pre({control:l.control,name:"sections"}),h=async g=>g===1?l.trigger(["title","subject_id","total_time_min","pass_threshold","results_release_mode","randomize"]):g===2||g===3?l.trigger("sections"):!0,m=async()=>{await h(t)&&r(b=>Math.min(4,b+1))},y=()=>r(g=>Math.max(1,g-1)),x=()=>{const g=l.getValues();return{title:g.title,subject_id:g.subject_id,description:g.description,total_time_min:g.total_time_min,pass_threshold:g.pass_threshold,results_release_mode:g.results_release_mode,randomize:g.randomize,sections:g.sections.map((b,N)=>({title:b.title,skill:b.skill,question_count:b.question_count,time_limit_min:b.time_limit_min,scoring_method:b.scoring_method,sequence:N,question_ids:b.question_ids}))}},j=async()=>{try{const g=x();await a.mutateAsync(g),ct.success("Draft saved.")}catch{ct.error("Could not save.")}},v=async()=>{var g,b;try{const N=x(),S=await a.mutateAsync(N),_=S.exam_id??((g=S.data)==null?void 0:g.exam_id);if(l.getValues("save_as_template")){const C=((b=l.getValues("template_name"))==null?void 0:b.trim())||l.getValues("title");await i.mutateAsync({name:C,structure:{sections:x().sections},editable:!0,type:"custom"})}ct.success("Exam published."),_!=null&&e("/admin/exam")}catch{ct.error("Publish failed.")}};return n.jsxs("div",{className:"p-6 max-w-3xl mx-auto space-y-8",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Custom exam"}),n.jsx("p",{className:"text-muted-foreground mt-1",children:"Build sections, attach questions, then review."})]}),n.jsx("div",{className:"flex gap-2",children:[1,2,3,4].map(g=>n.jsxs("button",{type:"button",onClick:()=>r(g),className:`flex-1 rounded-md border px-2 py-2 text-sm ${t===g?"border-primary bg-primary/5 font-medium":"border-muted text-muted-foreground"}`,children:[g===1&&"Properties",g===2&&"Sections",g===3&&"Questions",g===4&&"Review"]},g))}),n.jsx(Wl,{...l,children:n.jsxs("form",{className:"space-y-6",children:[t===1?n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Properties"}),n.jsx($e,{children:"Basics and scoring policy."})]}),n.jsxs(U,{className:"space-y-4",children:[n.jsx(et,{control:l.control,name:"title",render:({field:g})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Title"}),n.jsx(rt,{children:n.jsx(G,{...g})}),n.jsx(ot,{})]})}),n.jsx(et,{control:l.control,name:"subject_id",render:({field:g})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Subject"}),n.jsxs(Oe,{onValueChange:b=>g.onChange(Number(b)),value:g.value?String(g.value):"",children:[n.jsx(rt,{children:n.jsx(Ae,{children:n.jsx(Me,{placeholder:"Select subject"})})}),n.jsx(Ee,{children:o.map(b=>n.jsx(Y,{value:String(b.id),children:b.name},b.id))})]}),n.jsx(ot,{})]})}),n.jsx(et,{control:l.control,name:"description",render:({field:g})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Description"}),n.jsx(rt,{children:n.jsx(on,{rows:3,...g})}),n.jsx(ot,{})]})}),n.jsx(et,{control:l.control,name:"total_time_min",render:({field:g})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Total time (minutes)"}),n.jsx(rt,{children:n.jsx(G,{type:"number",min:1,...g})}),n.jsx(ot,{})]})}),n.jsx(et,{control:l.control,name:"pass_threshold",render:({field:g})=>n.jsxs(tt,{children:[n.jsxs(at,{children:["Pass threshold (",g.value,"%)"]}),n.jsx(rt,{children:n.jsx(oa,{min:0,max:100,step:1,value:[g.value],onValueChange:b=>g.onChange(b[0]??0)})}),n.jsx(ot,{})]})}),n.jsx(et,{control:l.control,name:"results_release_mode",render:({field:g})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Score release"}),n.jsxs(Oe,{onValueChange:g.onChange,value:g.value,children:[n.jsx(rt,{children:n.jsx(Ae,{children:n.jsx(Me,{})})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"auto",children:"Automatic"}),n.jsx(Y,{value:"manual_approval",children:"Manual approval"})]})]}),n.jsx(ot,{})]})}),n.jsx(et,{control:l.control,name:"randomize",render:({field:g})=>n.jsxs(tt,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[n.jsxs("div",{children:[n.jsx(at,{children:"Randomize"}),n.jsx(Jh,{children:"Shuffle questions where allowed."})]}),n.jsx(rt,{children:n.jsx(Fr,{checked:g.value,onCheckedChange:g.onChange})})]})})]})]}):null,t===2?n.jsxs(W,{children:[n.jsxs(se,{className:"flex flex-row items-center justify-between gap-4",children:[n.jsxs("div",{children:[n.jsx(ie,{children:"Section builder"}),n.jsx($e,{children:"Add, remove, and order sections."})]}),n.jsxs(E,{type:"button",size:"sm",onClick:()=>d({title:`Section ${c.length+1}`,skill:"Reading",question_count:5,time_limit_min:15,scoring_method:"auto",sequence:c.length,question_ids:[]}),children:[n.jsx(mt,{className:"h-4 w-4 mr-1"}),"Add section"]})]}),n.jsx(U,{className:"space-y-4",children:c.map((g,b)=>n.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsxs("span",{className:"text-sm font-medium",children:["Section ",b+1]}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(E,{type:"button",size:"icon",variant:"outline",disabled:b===0,onClick:()=>f(b,b-1),children:n.jsx(LL,{className:"h-4 w-4"})}),n.jsx(E,{type:"button",size:"icon",variant:"outline",disabled:b===c.length-1,onClick:()=>f(b,b+1),children:n.jsx(rr,{className:"h-4 w-4"})}),n.jsx(E,{type:"button",size:"icon",variant:"ghost",onClick:()=>u(b),children:n.jsx($t,{className:"h-4 w-4 text-destructive"})})]})]}),n.jsx(et,{control:l.control,name:`sections.${b}.title`,render:({field:N})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Title"}),n.jsx(rt,{children:n.jsx(G,{...N})}),n.jsx(ot,{})]})}),n.jsx(et,{control:l.control,name:`sections.${b}.skill`,render:({field:N})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Skill"}),n.jsxs(Oe,{onValueChange:N.onChange,value:N.value??"",children:[n.jsx(rt,{children:n.jsx(Ae,{children:n.jsx(Me,{})})}),n.jsx(Ee,{children:M5e.map(w=>n.jsx(Y,{value:w,children:w},w))})]}),n.jsx(ot,{})]})}),n.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[n.jsx(et,{control:l.control,name:`sections.${b}.question_count`,render:({field:N})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Question count"}),n.jsx(rt,{children:n.jsx(G,{type:"number",min:1,...N})}),n.jsx(ot,{})]})}),n.jsx(et,{control:l.control,name:`sections.${b}.time_limit_min`,render:({field:N})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Time limit (min)"}),n.jsx(rt,{children:n.jsx(G,{type:"number",min:1,...N})}),n.jsx(ot,{})]})})]}),n.jsx(et,{control:l.control,name:`sections.${b}.scoring_method`,render:({field:N})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Scoring method"}),n.jsxs(Oe,{onValueChange:N.onChange,value:N.value,children:[n.jsx(rt,{children:n.jsx(Ae,{children:n.jsx(Me,{})})}),n.jsxs(Ee,{children:[n.jsx(Y,{value:"auto",children:"Auto"}),n.jsx(Y,{value:"rubric",children:"Rubric"}),n.jsx(Y,{value:"mixed",children:"Mixed"})]})]}),n.jsx(ot,{})]})})]},g.id))})]}):null,t===3?n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Question assignment"}),n.jsx($e,{children:"Attach pool items or create new ones per section."})]}),n.jsx(U,{className:"space-y-6",children:c.map((g,b)=>n.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsx("span",{className:"font-medium",children:l.watch(`sections.${b}.title`)}),n.jsx($5e,{control:l.control,index:b})]}),n.jsx("div",{className:"flex flex-wrap gap-2",children:n.jsx(E,{type:"button",variant:"secondary",size:"sm",onClick:()=>e("/admin/resources"),children:"Browse content pool"})}),n.jsx(I5e,{sectionIndex:b,form:l})]},g.id))})]}):null,t===4?n.jsxs(W,{children:[n.jsxs(se,{children:[n.jsx(ie,{children:"Review & publish"}),n.jsx($e,{children:"Confirm details before students see this exam."})]}),n.jsxs(U,{className:"space-y-4",children:[n.jsx(ua,{className:"h-48 rounded-md border p-3 text-sm",children:n.jsx("pre",{className:"whitespace-pre-wrap font-sans",children:JSON.stringify(x(),null,2)})}),n.jsx(et,{control:l.control,name:"save_as_template",render:({field:g})=>n.jsxs(tt,{className:"flex flex-row items-start space-x-3 space-y-0 rounded-md border p-4",children:[n.jsx(rt,{children:n.jsx(an,{checked:g.value,onCheckedChange:g.onChange})}),n.jsxs("div",{className:"space-y-1 leading-none",children:[n.jsx(at,{children:"Save as reusable template"}),n.jsx(Jh,{children:"Stores section layout for future exams."})]})]})}),n.jsx(et,{control:l.control,name:"template_name",render:({field:g})=>n.jsxs(tt,{children:[n.jsx(at,{children:"Template name"}),n.jsx(rt,{children:n.jsx(G,{placeholder:"Optional; defaults to exam title",...g})}),n.jsx(ot,{})]})})]})]}):null,n.jsx(qs,{}),n.jsxs("div",{className:"flex flex-wrap justify-between gap-3",children:[n.jsx(E,{type:"button",variant:"outline",onClick:y,disabled:t===1,children:"Back"}),n.jsx("div",{className:"flex flex-wrap gap-2",children:t<4?n.jsx(E,{type:"button",onClick:m,children:"Next"}):n.jsxs(n.Fragment,{children:[n.jsx(E,{type:"button",variant:"secondary",onClick:j,children:"Save draft"}),n.jsx(E,{type:"button",onClick:v,disabled:a.isPending||i.isPending,children:"Publish"})]})})]})]})})]})}function $5e({control:e,index:t}){const r=fS({control:e,name:`sections.${t}.question_ids`}),s=fS({control:e,name:`sections.${t}.question_count`}),a=(r==null?void 0:r.length)??0,i=typeof s=="number"?s:Number(s)||0;return n.jsxs("span",{className:"text-sm text-muted-foreground",children:[a,"/",i," selected"]})}function I5e({sectionIndex:e,form:t}){const[r,s]=p.useState(""),a=p.useId();return n.jsxs("div",{className:"space-y-2 rounded-md bg-muted/40 p-3",children:[n.jsx(q,{htmlFor:`${a}-stem`,children:"Create new question"}),n.jsx(G,{id:`${a}-stem`,value:r,onChange:i=>s(i.target.value),placeholder:"Stem or reference label"}),n.jsx(E,{type:"button",size:"sm",onClick:()=>{const i=t.getValues(`sections.${e}.question_ids`)??[],o=Math.floor(Math.random()*1e9);t.setValue(`sections.${e}.question_ids`,[...i,o]),s("")},children:"Add to section"})]})}function MN(){const[e]=wo(),t=Bt(),r=e.get("token"),{data:s,isLoading:a,error:i}=ye({queryKey:["exam","access",r],queryFn:async()=>{const l=await fetch(`${Wj}/exam/access/${r}`);if(!l.ok)throw new Error(l.status===404?"Invalid or expired token":"Failed to load exam");return l.json()},enabled:!!r,retry:!1}),o=()=>{s&&t(`/exam/${s.module}/${s.id}?token=${r}`)};return n.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:n.jsx(W,{className:"w-full max-w-md",children:r?a?n.jsxs(U,{className:"py-12 text-center",children:[n.jsx(Re,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-3",children:"Loading exam information..."})]}):i?n.jsxs(U,{className:"py-12 text-center",children:[n.jsx(Nv,{className:"h-12 w-12 text-destructive mx-auto mb-3"}),n.jsx("h2",{className:"text-lg font-semibold",children:"Access Denied"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:i.message})]}):s?n.jsxs(n.Fragment,{children:[n.jsxs(se,{className:"text-center",children:[n.jsx("div",{className:"h-14 w-14 rounded-xl bg-primary/10 flex items-center justify-center mx-auto mb-2",children:n.jsx(gd,{className:"h-7 w-7 text-primary"})}),n.jsx(ie,{children:s.name}),n.jsx($e,{children:"Official Exam Access"})]}),n.jsxs(U,{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[n.jsxs("div",{className:"flex items-center justify-between text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Duration"}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(vd,{className:"h-4 w-4"}),n.jsxs("span",{className:"font-medium",children:[s.duration_minutes," minutes"]})]})]}),n.jsxs("div",{className:"flex items-center justify-between text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Start Time"}),n.jsx("span",{className:"font-medium",children:new Date(s.start_time).toLocaleString()})]}),n.jsxs("div",{className:"flex items-center justify-between text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Module"}),n.jsx(oe,{variant:"outline",children:s.module})]})]}),n.jsx(E,{className:"w-full",size:"lg",onClick:o,children:"Start Exam"})]})]}):null:n.jsxs(U,{className:"py-12 text-center",children:[n.jsx(Nv,{className:"h-12 w-12 text-destructive mx-auto mb-3"}),n.jsx("h2",{className:"text-lg font-semibold",children:"No Access Token"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Please use the link provided by your institution to access the exam."})]})})})}function D5e(){const[e,t]=p.useState(""),{data:r=[],isLoading:s}=OB(),{data:a=[],isLoading:i}=TB(e?{search:e}:void 0),o=r.filter(c=>a.some(d=>d.category_id===c.id)),l=c=>a.filter(d=>d.category_id===c);return s||i?n.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):n.jsxs("div",{className:"space-y-6 max-w-3xl mx-auto",children:[n.jsxs("div",{className:"text-center",children:[n.jsx("h1",{className:"text-3xl font-bold",children:"Frequently Asked Questions"}),n.jsx("p",{className:"text-muted-foreground mt-2",children:"Find answers to common questions about EnCoach."})]}),n.jsxs("div",{className:"relative",children:[n.jsx(en,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(G,{className:"pl-10",placeholder:"Search questions...",value:e,onChange:c=>t(c.target.value)})]}),o.length>0?n.jsx("div",{className:"space-y-6",children:o.map(c=>{const d=l(c.id);return d.length===0?null:n.jsxs(W,{children:[n.jsx(se,{className:"pb-2",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Fh,{className:"h-5 w-5 text-primary"}),n.jsx(ie,{className:"text-lg",children:c.name}),n.jsxs(oe,{variant:"secondary",className:"text-xs",children:[c.item_count," questions"]})]})}),n.jsx(U,{children:n.jsx(O0,{type:"multiple",children:d.sort((u,f)=>u.sequence-f.sequence).map(u=>n.jsxs(Ax,{value:String(u.id),children:[n.jsx(Ex,{className:"text-left text-sm font-medium",children:u.question}),n.jsx(Ox,{children:n.jsxs("div",{className:"space-y-2",children:[n.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:u.answer}),u.video_url&&n.jsxs("a",{href:u.video_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary hover:underline",children:[n.jsx(Ll,{className:"h-4 w-4"})," Watch video"]})]})})]},u.id))})})]},c.id)})}):n.jsx(W,{children:n.jsxs(U,{className:"py-12 text-center text-muted-foreground",children:[n.jsx(Fh,{className:"h-12 w-12 mx-auto mb-3 opacity-40"}),n.jsx("p",{children:e?"No questions match your search.":"No FAQ items available yet."})]})})]})}const L5e=()=>{const e=Ka();return p.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",e.pathname)},[e.pathname]),n.jsx("div",{className:"flex min-h-screen items-center justify-center bg-muted",children:n.jsxs("div",{className:"text-center",children:[n.jsx("h1",{className:"mb-4 text-4xl font-bold",children:"404"}),n.jsx("p",{className:"mb-4 text-xl text-muted-foreground",children:"Oops! Page not found"}),n.jsx("a",{href:"/",className:"text-primary underline hover:text-primary/90",children:"Return to Home"})]})})},F5e=new NX({defaultOptions:{queries:{staleTime:5*60*1e3,retry:(e,t)=>t instanceof Va&&t.status===401||t instanceof Va&&t.status===404?!1:e<2,refetchOnWindowFocus:!1},mutations:{retry:!1}}});function B5e(){const e=Bt();return n.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center gap-4 p-8",children:[n.jsx("p",{className:"text-muted-foreground text-center max-w-sm",children:"Subscription checkout will be available here."}),n.jsx(E,{onClick:()=>e("/student/dashboard"),children:"Back to dashboard"})]})}const z5e=()=>n.jsx(SX,{client:F5e,children:n.jsxs(I3,{children:[n.jsx(FH,{}),n.jsx(gQ,{}),n.jsx(IZ,{children:n.jsx(KZ,{children:n.jsxs(kZ,{children:[n.jsx(fe,{path:"/login",element:n.jsx(Gne,{})}),n.jsx(fe,{path:"/register",element:n.jsx(bse,{})}),n.jsx(fe,{path:"/verify-email",element:n.jsx(Dse,{})}),n.jsx(fe,{path:"/forgot-password",element:n.jsx(Jle,{})}),n.jsx(fe,{path:"/reset-password",element:n.jsx(nce,{})}),n.jsx(fe,{path:"/verify/:verificationHash",element:n.jsx(sce,{})}),n.jsx(fe,{path:"/apply",element:n.jsx(VLe,{})}),n.jsx(fe,{path:"/exam/access/:token",element:n.jsx(MN,{})}),n.jsx(fe,{path:"/exam/official/:code",element:n.jsx(MN,{})}),n.jsx(fe,{path:"/exam/login/:examId",element:n.jsx(MN,{})}),n.jsx(fe,{path:"/faq",element:n.jsx(D5e,{})}),n.jsx(fe,{element:n.jsx(ag,{}),children:n.jsx(fe,{path:"/onboarding",element:n.jsx(Zle,{})})}),n.jsxs(fe,{element:n.jsx(ag,{allowedRoles:["student"]}),children:[n.jsx(fe,{path:"/student/exam/:examId/session",element:n.jsx(O3e,{})}),n.jsx(fe,{path:"/student/exam/:examId/status",element:n.jsx(T3e,{})}),n.jsx(fe,{path:"/student/placement/test",element:n.jsx(vFe,{})}),n.jsx(fe,{path:"/student/subscription",element:n.jsx(B5e,{})}),n.jsxs(fe,{element:n.jsx(mne,{}),children:[n.jsx(fe,{path:"/student/dashboard",element:n.jsx(gDe,{})}),n.jsx(fe,{path:"/student/courses",element:n.jsx(vDe,{})}),n.jsx(fe,{path:"/student/courses/:id",element:n.jsx(jDe,{})}),n.jsx(fe,{path:"/student/assignments",element:n.jsx(wDe,{})}),n.jsx(fe,{path:"/student/grades",element:n.jsx(NDe,{})}),n.jsx(fe,{path:"/student/attendance",element:n.jsx(_De,{})}),n.jsx(fe,{path:"/student/timetable",element:n.jsx(kDe,{})}),n.jsx(fe,{path:"/student/profile",element:n.jsx(PDe,{})}),n.jsx(fe,{path:"/student/subjects",element:n.jsx(ADe,{})}),n.jsx(fe,{path:"/student/diagnostic/:subjectId",element:n.jsx(EDe,{})}),n.jsx(fe,{path:"/student/proficiency/:subjectId",element:n.jsx(TDe,{})}),n.jsx(fe,{path:"/student/plan/:subjectId",element:n.jsx($De,{})}),n.jsx(fe,{path:"/student/topic/:topicId",element:n.jsx(DDe,{})}),n.jsx(fe,{path:"/student/subject-registration",element:n.jsx(WLe,{})}),n.jsx(fe,{path:"/student/courses/:id/chapters/:chapterId",element:n.jsx(JLe,{})}),n.jsx(fe,{path:"/student/discussions",element:n.jsx(e3e,{})}),n.jsx(fe,{path:"/student/announcements",element:n.jsx(n3e,{})}),n.jsx(fe,{path:"/student/messages",element:n.jsx(r3e,{})}),n.jsx(fe,{path:"/student/journey",element:n.jsx(s3e,{})}),n.jsx(fe,{path:"/student/placement",element:n.jsx(gFe,{})}),n.jsx(fe,{path:"/student/placement/results",element:n.jsx(bFe,{})}),n.jsx(fe,{path:"/student/placement/access",element:n.jsx(_Fe,{})}),n.jsx(fe,{path:"/student/exam/:examId/results",element:n.jsx(K3e,{})}),n.jsx(fe,{path:"/student/course/generate",element:n.jsx(X3e,{})}),n.jsx(fe,{path:"/student/course/ai-english/:courseId",element:n.jsx(i3e,{})}),n.jsx(fe,{path:"/student/course/ai-ielts/:courseId",element:n.jsx(l3e,{})}),n.jsx(fe,{path:"/student/course/:courseId",element:n.jsx(J3e,{})})]})]}),n.jsx(fe,{element:n.jsx(ag,{allowedRoles:["teacher"]}),children:n.jsxs(fe,{element:n.jsx(pne,{}),children:[n.jsx(fe,{path:"/teacher/dashboard",element:n.jsx(LDe,{})}),n.jsx(fe,{path:"/teacher/courses",element:n.jsx(FDe,{})}),n.jsx(fe,{path:"/teacher/courses/new",element:n.jsx(v$,{})}),n.jsx(fe,{path:"/teacher/courses/:id/edit",element:n.jsx(v$,{})}),n.jsx(fe,{path:"/teacher/assignments",element:n.jsx(VDe,{})}),n.jsx(fe,{path:"/teacher/assignments/:id",element:n.jsx(qDe,{})}),n.jsx(fe,{path:"/teacher/attendance",element:n.jsx(KDe,{})}),n.jsx(fe,{path:"/teacher/students",element:n.jsx(GDe,{})}),n.jsx(fe,{path:"/teacher/timetable",element:n.jsx(ZDe,{})}),n.jsx(fe,{path:"/teacher/courses/:id/chapters",element:n.jsx(ULe,{})}),n.jsx(fe,{path:"/teacher/courses/:id/chapters/:chapterId",element:n.jsx(GLe,{})}),n.jsx(fe,{path:"/teacher/courses/:id/workbench",element:n.jsx(HLe,{})}),n.jsx(fe,{path:"/teacher/discussions",element:n.jsx(QLe,{})}),n.jsx(fe,{path:"/teacher/announcements",element:n.jsx(XLe,{})}),n.jsx(fe,{path:"/teacher/profile",element:n.jsx(JDe,{})}),n.jsx(fe,{path:"/teacher/course/:courseId/progress",element:n.jsx(cFe,{})}),n.jsx(fe,{path:"/teacher/adaptive/settings",element:n.jsx(nLe,{})})]})}),n.jsx(fe,{element:n.jsx(ag,{allowedRoles:["admin","corporate","mastercorporate","agent","developer"]}),children:n.jsxs(fe,{element:n.jsx($ne,{}),children:[n.jsx(fe,{path:"/admin/dashboard",element:n.jsx(rLe,{})}),n.jsx(fe,{path:"/admin/platform",element:n.jsx(Nue,{})}),n.jsx(fe,{path:"/admin/courses",element:n.jsx(sLe,{})}),n.jsx(fe,{path:"/admin/students",element:n.jsx(aLe,{})}),n.jsx(fe,{path:"/admin/teachers",element:n.jsx(iLe,{})}),n.jsx(fe,{path:"/admin/batches",element:n.jsx(lLe,{})}),n.jsx(fe,{path:"/admin/batches/:id",element:n.jsx(cLe,{})}),n.jsx(fe,{path:"/admin/timetable",element:n.jsx(fLe,{})}),n.jsx(fe,{path:"/admin/reports",element:n.jsx(mLe,{})}),n.jsx(fe,{path:"/admin/settings",element:n.jsx(pLe,{})}),n.jsx(fe,{path:"/admin/profile",element:n.jsx(xLe,{})}),n.jsx(fe,{path:"/admin/assignments",element:n.jsx(Mue,{})}),n.jsx(fe,{path:"/admin/examsList",element:n.jsx(Rue,{})}),n.jsx(fe,{path:"/admin/exam-structures",element:n.jsx(Iue,{})}),n.jsx(fe,{path:"/admin/rubrics",element:n.jsx(Fue,{})}),n.jsx(fe,{path:"/admin/generation",element:n.jsx(Hue,{})}),n.jsx(fe,{path:"/admin/approval-workflows",element:n.jsx(Jue,{})}),n.jsx(fe,{path:"/admin/users",element:n.jsx(Oue,{})}),n.jsx(fe,{path:"/admin/entities",element:n.jsx(Tue,{})}),n.jsx(fe,{path:"/admin/classrooms",element:n.jsx(efe,{})}),n.jsx(fe,{path:"/admin/student-performance",element:n.jsx(nfe,{})}),n.jsx(fe,{path:"/admin/stats-corporate",element:n.jsx(iDe,{})}),n.jsx(fe,{path:"/admin/record",element:n.jsx(oDe,{})}),n.jsx(fe,{path:"/admin/training/vocabulary",element:n.jsx(lDe,{})}),n.jsx(fe,{path:"/admin/training/grammar",element:n.jsx(cDe,{})}),n.jsx(fe,{path:"/admin/payment-record",element:n.jsx(uDe,{})}),n.jsx(fe,{path:"/admin/tickets",element:n.jsx(fDe,{})}),n.jsx(fe,{path:"/admin/settings-platform",element:n.jsx(pDe,{})}),n.jsx(fe,{path:"/admin/exam",element:n.jsx(xDe,{})}),n.jsx(fe,{path:"/admin/exam/create",element:n.jsx(j5e,{})}),n.jsx(fe,{path:"/admin/exam/ielts/create",element:n.jsx(_5e,{})}),n.jsx(fe,{path:"/admin/exam/ielts/:examId/skills",element:n.jsx(C5e,{})}),n.jsx(fe,{path:"/admin/exam/ielts/:examId/content",element:n.jsx(P5e,{})}),n.jsx(fe,{path:"/admin/exam/ielts/:examId/validate",element:n.jsx(E5e,{})}),n.jsx(fe,{path:"/admin/exam/custom/create",element:n.jsx(R5e,{})}),n.jsx(fe,{path:"/admin/taxonomy",element:n.jsx(gLe,{})}),n.jsx(fe,{path:"/admin/resources",element:n.jsx(yLe,{})}),n.jsx(fe,{path:"/admin/academic-years",element:n.jsx(jLe,{})}),n.jsx(fe,{path:"/admin/departments",element:n.jsx(bLe,{})}),n.jsx(fe,{path:"/admin/admissions",element:n.jsx(SLe,{})}),n.jsx(fe,{path:"/admin/admissions/:id",element:n.jsx(CLe,{})}),n.jsx(fe,{path:"/admin/admission-register",element:n.jsx(PLe,{})}),n.jsx(fe,{path:"/admin/exam-sessions",element:n.jsx(ELe,{})}),n.jsx(fe,{path:"/admin/marksheets",element:n.jsx(TLe,{})}),n.jsx(fe,{path:"/admin/student-leave",element:n.jsx(RLe,{})}),n.jsx(fe,{path:"/admin/fees",element:n.jsx($Le,{})}),n.jsx(fe,{path:"/admin/lessons",element:n.jsx(ILe,{})}),n.jsx(fe,{path:"/admin/gradebook",element:n.jsx(DLe,{})}),n.jsx(fe,{path:"/admin/student-progress",element:n.jsx(LLe,{})}),n.jsx(fe,{path:"/admin/library",element:n.jsx(FLe,{})}),n.jsx(fe,{path:"/admin/activities",element:n.jsx(BLe,{})}),n.jsx(fe,{path:"/admin/facilities",element:n.jsx(zLe,{})}),n.jsx(fe,{path:"/admin/faq",element:n.jsx(CFe,{})}),n.jsx(fe,{path:"/admin/notification-rules",element:n.jsx(kFe,{})}),n.jsx(fe,{path:"/admin/approval-config",element:n.jsx(PFe,{})}),n.jsx(fe,{path:"/admin/roles-permissions",element:n.jsx(EFe,{})}),n.jsx(fe,{path:"/admin/authority-matrix",element:n.jsx(e5e,{})}),n.jsx(fe,{path:"/admin/user-roles",element:n.jsx(s5e,{})}),n.jsx(fe,{path:"/admin/exam/:examId/grading",element:n.jsx(aFe,{})}),n.jsx(fe,{path:"/admin/course/configure/:courseId",element:n.jsx(oFe,{})}),n.jsx(fe,{path:"/admin/course/:courseId/modules",element:n.jsx(lFe,{})}),n.jsx(fe,{path:"/admin/entity/students/upload",element:n.jsx(a5e,{})}),n.jsx(fe,{path:"/admin/entity/students/credentials",element:n.jsx(i5e,{})}),n.jsx(fe,{path:"/admin/entity/:entityId/level-mapping",element:n.jsx(p5e,{})}),n.jsx(fe,{path:"/admin/entity/:entityId/branding",element:n.jsx(g5e,{})}),n.jsx(fe,{path:"/admin/ai-course/english/:courseId/quality",element:n.jsx(o5e,{})}),n.jsx(fe,{path:"/admin/ai-course/english/taxonomy",element:n.jsx(l5e,{})}),n.jsx(fe,{path:"/admin/ai-course/ielts/:courseId/validation",element:n.jsx(d5e,{})}),n.jsx(fe,{path:"/admin/adaptive/dashboard",element:n.jsx(u5e,{})}),n.jsx(fe,{path:"/admin/adaptive/student/:studentId",element:n.jsx(m5e,{})}),n.jsx(fe,{path:"/admin/scores/pending",element:n.jsx(v5e,{})})]})}),n.jsx(fe,{path:"/",element:n.jsx(jl,{to:"/login",replace:!0})}),n.jsx(fe,{path:"/admin",element:n.jsx(jl,{to:"/admin/dashboard",replace:!0})}),n.jsx(fe,{path:"/dashboard/admin",element:n.jsx(jl,{to:"/admin/platform",replace:!0})}),n.jsx(fe,{path:"*",element:n.jsx(L5e,{})})]})})})]})});cL(document.getElementById("root")).render(n.jsx(z5e,{}));