@kaitranntt/ccs 7.46.0-dev.5 → 7.46.0-dev.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/cliproxy/codex-reasoning-proxy.d.ts +7 -0
  2. package/dist/cliproxy/codex-reasoning-proxy.d.ts.map +1 -1
  3. package/dist/cliproxy/codex-reasoning-proxy.js +34 -3
  4. package/dist/cliproxy/codex-reasoning-proxy.js.map +1 -1
  5. package/dist/cliproxy/config/thinking-config.js +5 -5
  6. package/dist/cliproxy/config/thinking-config.js.map +1 -1
  7. package/dist/cliproxy/executor/index.d.ts.map +1 -1
  8. package/dist/cliproxy/executor/index.js +10 -1
  9. package/dist/cliproxy/executor/index.js.map +1 -1
  10. package/dist/cliproxy/executor/thinking-override-resolver.d.ts +28 -0
  11. package/dist/cliproxy/executor/thinking-override-resolver.d.ts.map +1 -0
  12. package/dist/cliproxy/executor/thinking-override-resolver.js +109 -0
  13. package/dist/cliproxy/executor/thinking-override-resolver.js.map +1 -0
  14. package/dist/cliproxy/thinking-validator.d.ts +5 -0
  15. package/dist/cliproxy/thinking-validator.d.ts.map +1 -1
  16. package/dist/cliproxy/thinking-validator.js +18 -6
  17. package/dist/cliproxy/thinking-validator.js.map +1 -1
  18. package/dist/commands/config-command.d.ts.map +1 -1
  19. package/dist/commands/config-command.js +16 -0
  20. package/dist/commands/config-command.js.map +1 -1
  21. package/dist/commands/config-thinking-command.d.ts +9 -0
  22. package/dist/commands/config-thinking-command.d.ts.map +1 -0
  23. package/dist/commands/config-thinking-command.js +237 -0
  24. package/dist/commands/config-thinking-command.js.map +1 -0
  25. package/dist/commands/config-thinking-parser.d.ts +37 -0
  26. package/dist/commands/config-thinking-parser.d.ts.map +1 -0
  27. package/dist/commands/config-thinking-parser.js +135 -0
  28. package/dist/commands/config-thinking-parser.js.map +1 -0
  29. package/dist/commands/help-command.d.ts.map +1 -1
  30. package/dist/commands/help-command.js +4 -0
  31. package/dist/commands/help-command.js.map +1 -1
  32. package/dist/ui/assets/{accounts-CDMbYhoK.js → accounts-C_IFZxdY.js} +1 -1
  33. package/dist/ui/assets/{alert-dialog-BuoGLwhK.js → alert-dialog-Dv20wFSk.js} +1 -1
  34. package/dist/ui/assets/{api-Ds2VDoWj.js → api-B_98E0aE.js} +1 -1
  35. package/dist/ui/assets/{auth-section-yxhlBIeU.js → auth-section-CswsImgo.js} +1 -1
  36. package/dist/ui/assets/{backups-section-DPkR6c2v.js → backups-section-N3-QDA1f.js} +1 -1
  37. package/dist/ui/assets/{cliproxy-DlRLzcMc.js → cliproxy-BTwsOIoc.js} +1 -1
  38. package/dist/ui/assets/{cliproxy-control-panel-B-Kp16o4.js → cliproxy-control-panel-CxmD0q1S.js} +1 -1
  39. package/dist/ui/assets/{confirm-dialog-ApRA1nJe.js → confirm-dialog-Bnm5pfVk.js} +1 -1
  40. package/dist/ui/assets/{copilot-CvvfxmsM.js → copilot-Bygut-Du.js} +1 -1
  41. package/dist/ui/assets/{cursor-BJDbE6ri.js → cursor-mqWvlWwz.js} +1 -1
  42. package/dist/ui/assets/{globalenv-section-Bj18vmmp.js → globalenv-section-DnqCBQbR.js} +1 -1
  43. package/dist/ui/assets/{health-C-UMxtTO.js → health-JiOp2s6o.js} +1 -1
  44. package/dist/ui/assets/{index-BSK5RM6B.js → index-CGtzFO3I.js} +1 -1
  45. package/dist/ui/assets/{index-CpuTaA7Q.js → index-CQOKzUPp.js} +1 -1
  46. package/dist/ui/assets/{index-C-4s51AH.js → index-CWYFZoZP.js} +3 -3
  47. package/dist/ui/assets/{index-BzXQbaOm.js → index-KmxTWV7G.js} +1 -1
  48. package/dist/ui/assets/index-ruOt2xfd.js +1 -0
  49. package/dist/ui/assets/{proxy-status-widget-B5Rk4t5g.js → proxy-status-widget-DGjLcjQs.js} +1 -1
  50. package/dist/ui/assets/{separator-Cmak08sq.js → separator-dS5GnIdQ.js} +1 -1
  51. package/dist/ui/assets/{shared-Pb8lecSN.js → shared-BId9fr7t.js} +1 -1
  52. package/dist/ui/assets/{switch-Dw_-BGlW.js → switch-D0BUstlt.js} +1 -1
  53. package/dist/ui/index.html +1 -1
  54. package/dist/web-server/routes/misc-routes.d.ts +2 -0
  55. package/dist/web-server/routes/misc-routes.d.ts.map +1 -1
  56. package/dist/web-server/routes/misc-routes.js +38 -7
  57. package/dist/web-server/routes/misc-routes.js.map +1 -1
  58. package/package.json +1 -1
  59. package/dist/ui/assets/index-DYpGbm8d.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BSK5RM6B.js","assets/radix-ui-qEZD5MMp.js","assets/react-vendor-CNOkPC89.js","assets/switch-Dw_-BGlW.js","assets/icons-DGASzt3M.js","assets/tanstack-De4wvi8X.js","assets/notifications-B2HqRBj7.js","assets/utils-CzKF5WmX.js","assets/form-utils-C-pVd1--.js","assets/code-highlight-BRUf_pqB.js","assets/globalenv-section-Bj18vmmp.js","assets/index-DYpGbm8d.js","assets/index-BzXQbaOm.js","assets/default-ports-1QQSffYX.js","assets/proxy-status-widget-B5Rk4t5g.js","assets/alert-dialog-BuoGLwhK.js","assets/auth-section-yxhlBIeU.js","assets/backups-section-DPkR6c2v.js","assets/index-CpuTaA7Q.js","assets/charts-BBPXh0Ar.js","assets/api-Ds2VDoWj.js","assets/confirm-dialog-ApRA1nJe.js","assets/separator-Cmak08sq.js","assets/cliproxy-DlRLzcMc.js","assets/cliproxy-control-panel-B-Kp16o4.js","assets/copilot-CvvfxmsM.js","assets/cursor-BJDbE6ri.js","assets/accounts-CDMbYhoK.js","assets/health-C-UMxtTO.js","assets/shared-Pb8lecSN.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CGtzFO3I.js","assets/radix-ui-qEZD5MMp.js","assets/react-vendor-CNOkPC89.js","assets/switch-D0BUstlt.js","assets/icons-DGASzt3M.js","assets/tanstack-De4wvi8X.js","assets/notifications-B2HqRBj7.js","assets/utils-CzKF5WmX.js","assets/form-utils-C-pVd1--.js","assets/code-highlight-BRUf_pqB.js","assets/globalenv-section-DnqCBQbR.js","assets/index-ruOt2xfd.js","assets/index-KmxTWV7G.js","assets/default-ports-1QQSffYX.js","assets/proxy-status-widget-DGjLcjQs.js","assets/alert-dialog-Dv20wFSk.js","assets/auth-section-CswsImgo.js","assets/backups-section-N3-QDA1f.js","assets/index-CQOKzUPp.js","assets/charts-BBPXh0Ar.js","assets/api-B_98E0aE.js","assets/confirm-dialog-Bnm5pfVk.js","assets/separator-dS5GnIdQ.js","assets/cliproxy-BTwsOIoc.js","assets/cliproxy-control-panel-CxmD0q1S.js","assets/copilot-Bygut-Du.js","assets/cursor-mqWvlWwz.js","assets/accounts-C_IFZxdY.js","assets/health-JiOp2s6o.js","assets/shared-BId9fr7t.js"])))=>i.map(i=>d[i]);
2
2
  import{j as i,S as Zr,R as pg,C as gg,a as xg,T as yg,D as vg,P as bg,O as Sg,b as cv,c as dv,d as fv,e as mv,f as hv,A as pv,g as gv,h as xv,i as yv,k as vv,l as bv,m as Sv,n as Nv,I as jv,o as Ng,V as wv,p as Cv,q as jg,r as Ev,L as wg,s as Cg,t as Eg,u as Mv,v as Tv,w as Mg,x as Av,y as Tg,z as Ag,B as Ov,E as Og,F as zv,G as zg,H as Dg,J as Dv,K as _v,M as _g,N as kv,Q as Rv,U as Uv,W as qv,X as kg,Y as Bv,Z as Hv,_ as Lv}from"./radix-ui-qEZD5MMp.js";import{e as Rg,f as Yv,r as y,u as Zc,O as qc,N as Gv,h as Wc,L as Bc,R as Kv,g as Qv,i as Vv,c as F,B as Xv,j as Zv,k as Gt}from"./react-vendor-CNOkPC89.js";import{Q as Wv,u as zt,a as ut,b as mt,c as $v}from"./tanstack-De4wvi8X.js";import{t as le,T as Jv}from"./notifications-B2HqRBj7.js";import{L as En,X as os,P as Pv,H as Iv,C as Fv,K as Ug,G as eb,Z as qg,a as Bg,F as Hg,U as Lg,A as hi,S as tb,b as Wr,c as nb,M as ab,E as $r,d as Jr,B as lb,R as pi,W as sb,e as ib,f as rb,g as ob,h as vp,i as bp,j as rs,k as $c,l as Gr,m as Yg,n as ub,o as cb,p as gi,q as Pr,r as Jc,s as db,t as fb,u as Ir,v as mb,T as ma,w as hb,x as pb,I as Fr,y as gb,z as xb,D as yb,J as vb,N as bb,O as Sb,Q as Nb,V as Pc,Y as eo,_ as Ic,$ as Sp,a0 as jb,a1 as Fc,a2 as wb,a3 as Cb,a4 as Eb,a5 as Mb,a6 as Np,a7 as Tb,a8 as Ab}from"./icons-DGASzt3M.js";import{t as Ob,c as zb,a as to,e as si,f as oi,b as Db,d as _b,g as kb,h as Rb,i as Ub,j as qb,k as Bb,l as Hb,m as Lb,n as Yb,o as Gb,p as Kb,q as Qb,r as Vb,s as Xb,u as Zb,v as Wb,w as $b,x as Jb,y as Pb,z as Ib,A as Fb,B as eS,C as tS,D as nS,E as aS,F as lS,G as sS,H as iS,I as rS,J as oS}from"./utils-CzKF5WmX.js";import{o as jp,s as wp,p as uS,a as cS,$ as dS,b as Gg,c as fS,d as cl,u as mS,e as hS}from"./form-utils-C-pVd1--.js";import{H as pS,t as Cp}from"./code-highlight-BRUf_pqB.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))u(d);new MutationObserver(d=>{for(const f of d)if(f.type==="childList")for(const m of f.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&u(m)}).observe(document,{childList:!0,subtree:!0});function r(d){const f={};return d.integrity&&(f.integrity=d.integrity),d.referrerPolicy&&(f.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?f.credentials="include":d.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function u(d){if(d.ep)return;d.ep=!0;const f=r(d);fetch(d.href,f)}})();var Nc={exports:{}},ii={},jc={exports:{}},wc={};var Ep;function gS(){return Ep||(Ep=1,(function(a){function s(A,W){var ie=A.length;A.push(W);e:for(;0<ie;){var ye=ie-1>>>1,ve=A[ye];if(0<d(ve,W))A[ye]=W,A[ie]=ve,ie=ye;else break e}}function r(A){return A.length===0?null:A[0]}function u(A){if(A.length===0)return null;var W=A[0],ie=A.pop();if(ie!==W){A[0]=ie;e:for(var ye=0,ve=A.length,De=ve>>>1;ye<De;){var ze=2*(ye+1)-1,X=A[ze],J=ze+1,ne=A[J];if(0>d(X,ie))J<ve&&0>d(ne,X)?(A[ye]=ne,A[J]=ie,ye=J):(A[ye]=X,A[ze]=ie,ye=ze);else if(J<ve&&0>d(ne,ie))A[ye]=ne,A[J]=ie,ye=J;else break e}}return W}function d(A,W){var ie=A.sortIndex-W.sortIndex;return ie!==0?ie:A.id-W.id}if(a.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;a.unstable_now=function(){return f.now()}}else{var m=Date,p=m.now();a.unstable_now=function(){return m.now()-p}}var x=[],b=[],C=1,v=null,S=3,M=!1,O=!1,U=!1,_=!1,T=typeof setTimeout=="function"?setTimeout:null,K=typeof clearTimeout=="function"?clearTimeout:null,B=typeof setImmediate<"u"?setImmediate:null;function L(A){for(var W=r(b);W!==null;){if(W.callback===null)u(b);else if(W.startTime<=A)u(b),W.sortIndex=W.expirationTime,s(x,W);else break;W=r(b)}}function k(A){if(U=!1,L(A),!O)if(r(x)!==null)O=!0,j||(j=!0,ue());else{var W=r(b);W!==null&&P(k,W.startTime-A)}}var j=!1,H=-1,Z=5,ee=-1;function se(){return _?!0:!(a.unstable_now()-ee<Z)}function be(){if(_=!1,j){var A=a.unstable_now();ee=A;var W=!0;try{e:{O=!1,U&&(U=!1,K(H),H=-1),M=!0;var ie=S;try{t:{for(L(A),v=r(x);v!==null&&!(v.expirationTime>A&&se());){var ye=v.callback;if(typeof ye=="function"){v.callback=null,S=v.priorityLevel;var ve=ye(v.expirationTime<=A);if(A=a.unstable_now(),typeof ve=="function"){v.callback=ve,L(A),W=!0;break t}v===r(x)&&u(x),L(A)}else u(x);v=r(x)}if(v!==null)W=!0;else{var De=r(b);De!==null&&P(k,De.startTime-A),W=!1}}break e}finally{v=null,S=ie,M=!1}W=void 0}}finally{W?ue():j=!1}}}var ue;if(typeof B=="function")ue=function(){B(be)};else if(typeof MessageChannel<"u"){var Ye=new MessageChannel,Ne=Ye.port2;Ye.port1.onmessage=be,ue=function(){Ne.postMessage(null)}}else ue=function(){T(be,0)};function P(A,W){H=T(function(){A(a.unstable_now())},W)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function(A){A.callback=null},a.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Z=0<A?Math.floor(1e3/A):5},a.unstable_getCurrentPriorityLevel=function(){return S},a.unstable_next=function(A){switch(S){case 1:case 2:case 3:var W=3;break;default:W=S}var ie=S;S=W;try{return A()}finally{S=ie}},a.unstable_requestPaint=function(){_=!0},a.unstable_runWithPriority=function(A,W){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var ie=S;S=A;try{return W()}finally{S=ie}},a.unstable_scheduleCallback=function(A,W,ie){var ye=a.unstable_now();switch(typeof ie=="object"&&ie!==null?(ie=ie.delay,ie=typeof ie=="number"&&0<ie?ye+ie:ye):ie=ye,A){case 1:var ve=-1;break;case 2:ve=250;break;case 5:ve=1073741823;break;case 4:ve=1e4;break;default:ve=5e3}return ve=ie+ve,A={id:C++,callback:W,priorityLevel:A,startTime:ie,expirationTime:ve,sortIndex:-1},ie>ye?(A.sortIndex=ie,s(b,A),r(x)===null&&A===r(b)&&(U?(K(H),H=-1):U=!0,P(k,ie-ye))):(A.sortIndex=ve,s(x,A),O||M||(O=!0,j||(j=!0,ue()))),A},a.unstable_shouldYield=se,a.unstable_wrapCallback=function(A){var W=S;return function(){var ie=S;S=W;try{return A.apply(this,arguments)}finally{S=ie}}}})(wc)),wc}var Mp;function xS(){return Mp||(Mp=1,jc.exports=gS()),jc.exports}var Tp;function yS(){if(Tp)return ii;Tp=1;var a=xS(),s=Rg(),r=Yv();function u(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function d(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function f(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function m(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function p(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function x(e){if(f(e)!==e)throw Error(u(188))}function b(e){var t=e.alternate;if(!t){if(t=f(e),t===null)throw Error(u(188));return t!==e?null:e}for(var n=e,l=t;;){var o=n.return;if(o===null)break;var c=o.alternate;if(c===null){if(l=o.return,l!==null){n=l;continue}break}if(o.child===c.child){for(c=o.child;c;){if(c===n)return x(o),e;if(c===l)return x(o),t;c=c.sibling}throw Error(u(188))}if(n.return!==l.return)n=o,l=c;else{for(var h=!1,g=o.child;g;){if(g===n){h=!0,n=o,l=c;break}if(g===l){h=!0,l=o,n=c;break}g=g.sibling}if(!h){for(g=c.child;g;){if(g===n){h=!0,n=c,l=o;break}if(g===l){h=!0,l=c,n=o;break}g=g.sibling}if(!h)throw Error(u(189))}}if(n.alternate!==l)throw Error(u(190))}if(n.tag!==3)throw Error(u(188));return n.stateNode.current===n?e:t}function C(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=C(e),t!==null)return t;e=e.sibling}return null}var v=Object.assign,S=Symbol.for("react.element"),M=Symbol.for("react.transitional.element"),O=Symbol.for("react.portal"),U=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),K=Symbol.for("react.consumer"),B=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),Z=Symbol.for("react.lazy"),ee=Symbol.for("react.activity"),se=Symbol.for("react.memo_cache_sentinel"),be=Symbol.iterator;function ue(e){return e===null||typeof e!="object"?null:(e=be&&e[be]||e["@@iterator"],typeof e=="function"?e:null)}var Ye=Symbol.for("react.client.reference");function Ne(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Ye?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case U:return"Fragment";case T:return"Profiler";case _:return"StrictMode";case k:return"Suspense";case j:return"SuspenseList";case ee:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case O:return"Portal";case B:return e.displayName||"Context";case K:return(e._context.displayName||"Context")+".Consumer";case L:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case H:return t=e.displayName||null,t!==null?t:Ne(e.type)||"Memo";case Z:t=e._payload,e=e._init;try{return Ne(e(t))}catch{}}return null}var P=Array.isArray,A=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ie={pending:!1,data:null,method:null,action:null},ye=[],ve=-1;function De(e){return{current:e}}function ze(e){0>ve||(e.current=ye[ve],ye[ve]=null,ve--)}function X(e,t){ve++,ye[ve]=e.current,e.current=t}var J=De(null),ne=De(null),I=De(null),te=De(null);function fe(e,t){switch(X(I,t),X(ne,e),X(J,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Gh(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Gh(t),e=Kh(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}ze(J),X(J,e)}function Oe(){ze(J),ze(ne),ze(I)}function Ge(e){e.memoizedState!==null&&X(te,e);var t=J.current,n=Kh(t,e.type);t!==n&&(X(ne,e),X(J,n))}function yt(e){ne.current===e&&(ze(J),ze(ne)),te.current===e&&(ze(te),ti._currentValue=ie)}var vt,Qe;function tt(e){if(vt===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);vt=t&&t[1]||"",Qe=-1<n.stack.indexOf(`
3
3
  at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
4
4
  `+vt+e+Qe}var kt=!1;function Vt(e,t){if(!e||kt)return"";kt=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(t){var V=function(){throw Error()};if(Object.defineProperty(V.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(V,[])}catch(q){var R=q}Reflect.construct(e,[],V)}else{try{V.call()}catch(q){R=q}e.call(V.prototype)}}else{try{throw Error()}catch(q){R=q}(V=e())&&typeof V.catch=="function"&&V.catch(function(){})}}catch(q){if(q&&R&&typeof q.stack=="string")return[q.stack,R.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var o=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");o&&o.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var c=l.DetermineComponentFrameRoot(),h=c[0],g=c[1];if(h&&g){var N=h.split(`
@@ -11,7 +11,7 @@ Error generating stack: `+l.message+`
11
11
  `);for(const u of r){const[d,...f]=u.split(":"),m=f.join(":").trim();switch(d?.trim()?.toLowerCase()){case"version":s.version=m;break;case"url":s.url=m;break;case"method":s.method=m;break;case"timestamp":s.timestamp=m;break}}}function kj(a){const s={},r=a.split(`
12
12
  `);for(const u of r){const d=u.indexOf(":");if(d>0){const f=u.slice(0,d).trim(),m=u.slice(d+1).trim();f&&(s[f]=m)}}return s}function Rj(a,s){const r=a.split(`
13
13
  `);let u=!1;const d=[];for(const f of r){if(f.startsWith("Status:")){const p=f.replace("Status:","").trim().split(/\s+/);s.statusCode=parseInt(p[0],10)||0,s.statusText=p.slice(1).join(" ")||Hj(s.statusCode);continue}if(f.trim()===""&&!u){u=!0;continue}if(u)d.push(f);else{const m=f.indexOf(":");if(m>0){const p=f.slice(0,m).trim(),x=f.slice(m+1).trim();p&&(s.responseHeaders[p]=x)}}}s.responseBody=d.join(`
14
- `).trim()}function Uj(a){const s=a.url.match(/\/api\/provider\/([^/]+)/);s&&(a.provider=s[1]);const r=a.url.match(/\/api\/provider\/[^/]+\/(.+?)(?:\?|$)/);r&&(a.endpoint=r[1]),a.isClientError=a.statusCode>=400&&a.statusCode<500,a.isServerError=a.statusCode>=500,a.statusCode===429?a.errorType="rate_limit":a.statusCode===401||a.statusCode===403?a.errorType="auth":a.statusCode===404?a.errorType="not_found":a.statusCode>=500?a.errorType="server":(a.statusCode===408||a.statusCode===504)&&(a.errorType="timeout"),qj(a),a.statusCode===429&&Bj(a)}function qj(a){if(a.requestBody)try{const s=JSON.parse(a.requestBody);typeof s.model=="string"&&(a.model=s.model)}catch{}}function Bj(a){if(a.responseBody)try{const s=JSON.parse(a.responseBody),r=Gc(s);r!==null&&(a.quotaResetDelay=r);const u=Kc(s);u&&(a.quotaResetTimestamp=u)}catch{}}function Gc(a){if(typeof a!="object"||a===null)return null;const s=a;if("quotaResetDelay"in s){const r=s.quotaResetDelay;if(typeof r=="number")return r;if(typeof r=="string"){const u=r.match(/^(\d+)s?$/);if(u)return parseInt(u[1],10)}}if("error"in s&&typeof s.error=="object"){const r=Gc(s.error);if(r!==null)return r}if("details"in s&&Array.isArray(s.details))for(const r of s.details){const u=Gc(r);if(u!==null)return u}return null}function Kc(a){if(typeof a!="object"||a===null)return null;const s=a;for(const r of["quotaResetTimeStamp","quotaResetTimestamp","resetTime","reset_time"])if(r in s&&typeof s[r]=="string")return s[r];if("error"in s&&typeof s.error=="object"){const r=Kc(s.error);if(r)return r}if("details"in s&&Array.isArray(s.details))for(const r of s.details){const u=Kc(r);if(u)return u}return null}function Hj(a){return{400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",408:"Request Timeout",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout"}[a]||""}function Lj(a){const s=Date.now(),r=a*1e3,u=s-r,d=Math.floor(u/1e3),f=Math.floor(d/60),m=Math.floor(f/60),p=Math.floor(m/24);return d<60?"just now":f<60?`${f}m ago`:m<24?`${m}h ago`:p<7?`${p}d ago`:new Date(r).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Yj(a){return a>=500?"text-red-500":a===429?"text-orange-500":a>=400?"text-yellow-500":"text-gray-500"}function Gj(a){return{rate_limit:"Rate Limited",auth:"Auth Error",not_found:"Not Found",server:"Server Error",timeout:"Timeout",unknown:"Error"}[a]||"Error"}function Kj(a){if(a===null||a<=0)return null;if(a<60)return`${a}s`;if(a<3600)return`${Math.floor(a/60)}m`;const s=Math.floor(a/3600),r=Math.floor(a%3600/60);return r>0?`${s}h ${r}m`:`${s}h`}function Qj(a){if(!a)return null;try{const s=new Date(a),r=new Date,u=s.getTime()-r.getTime();if(u<=0)return"now";const d=Math.floor(u/1e3);if(d<60)return`${d}s`;if(d<3600)return`${Math.floor(d/60)}m`;const f=Math.floor(d/3600),m=Math.floor(d%3600/60);return m>0?`${f}h ${m}m`:`${f}h`}catch{return null}}function Vj(a){return a?a===429?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":a>=500?"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400":a>=400?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-gray-100 text-gray-600":"bg-gray-100 text-gray-600"}function Xj(a){return a||""}function Zj({name:a,size:s,modified:r,isSelected:u,onClick:d,statusCode:f,model:m}){const p=y.useMemo(()=>zj(a),[a]),x=y.useMemo(()=>Xj(m),[m]);return i.jsxs("button",{onClick:d,className:G("w-full px-2.5 py-2 flex items-center gap-2 text-left transition-colors","hover:bg-muted/40 border-l-[3px]",u?"bg-muted/50 border-l-red-500":"border-l-transparent"),children:[i.jsx("span",{className:G("shrink-0 text-[10px] font-bold px-1.5 py-0.5 rounded min-w-[32px] text-center",Vj(f)),children:f||"???"}),i.jsx(dd,{provider:p.provider,size:18,withBackground:!0,className:"shrink-0"}),i.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[i.jsx("span",{className:"text-[11px] font-medium text-foreground truncate",children:p.endpoint||"unknown"}),x&&i.jsx("span",{className:"text-[10px] text-muted-foreground truncate",title:x,children:x}),i.jsxs("div",{className:"flex items-center gap-1 text-[9px] text-muted-foreground/60",children:[i.jsx(gi,{className:"w-2.5 h-2.5"}),i.jsx("span",{children:Lj(r)})]})]})]})}function Xp({value:a,className:s,variant:r="outline",size:u="icon",label:d="Copy to clipboard"}){const[f,m]=y.useState(!1),p=()=>{navigator.clipboard.writeText(a),m(!0),setTimeout(()=>m(!1),2e3)};return i.jsx(ml,{children:i.jsxs(Ga,{children:[i.jsx(Ka,{asChild:!0,children:i.jsxs(ot,{size:u,variant:r,className:G("relative z-10 text-muted-foreground hover:text-foreground",s),onClick:x=>{x.stopPropagation(),p()},children:[f?i.jsx(rs,{className:"h-3.5 w-3.5 text-green-500"}):i.jsx(Gr,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"sr-only",children:d})]})}),i.jsx(Qa,{children:i.jsx("p",{children:f?"Copied!":d})})]})})}function ri({active:a,onClick:s,children:r,icon:u}){return i.jsxs("button",{onClick:s,className:G("px-2.5 py-1.5 text-xs font-medium rounded transition-colors flex items-center gap-1.5",a?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[u&&i.jsx(u,{className:"w-3.5 h-3.5"}),r]})}function Sx({code:a}){const s=Yj(a);return i.jsx("span",{className:G("inline-flex items-center justify-center min-w-[36px] px-2 py-0.5 rounded text-xs font-bold","bg-current/10 border border-current/20",s),children:a})}function Wj({parsed:a}){const s=Kj(a.quotaResetDelay)||Qj(a.quotaResetTimestamp);return i.jsx(gl,{className:"h-full",children:i.jsxs("div",{className:"p-4 space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Sx,{code:a.statusCode}),i.jsx("span",{className:"text-sm font-medium",children:a.statusText}),i.jsx("span",{className:"text-xs text-muted-foreground px-2 py-0.5 rounded bg-muted/50",children:Gj(a.errorType)})]}),a.model&&i.jsxs("div",{className:"flex items-center gap-2.5 p-3 rounded-lg bg-violet-500/10 border border-violet-500/20",children:[i.jsx(pb,{className:"w-4 h-4 text-violet-500 shrink-0"}),i.jsxs("div",{className:"text-sm",children:[i.jsx("span",{className:"text-muted-foreground",children:"Model: "}),i.jsx("span",{className:"font-semibold text-violet-600 dark:text-violet-400",children:a.model})]})]}),a.errorType==="rate_limit"&&s&&i.jsxs("div",{className:"flex items-center gap-2.5 p-3 rounded-lg bg-amber-500/10 border border-amber-500/20",children:[i.jsx(gi,{className:"w-4 h-4 text-amber-500 shrink-0"}),i.jsxs("div",{className:"text-sm",children:[i.jsx("span",{className:"text-muted-foreground",children:"Quota resets in "}),i.jsx("span",{className:"font-semibold text-amber-600 dark:text-amber-400",children:s})]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-3 text-xs",children:[i.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[i.jsx("div",{className:"text-muted-foreground mb-1",children:"Method"}),i.jsx("div",{className:"font-medium",children:a.method||"N/A"})]}),i.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[i.jsx("div",{className:"text-muted-foreground mb-1",children:"Provider"}),i.jsx("div",{className:"font-medium",children:a.provider||"N/A"})]}),i.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[i.jsx("div",{className:"text-muted-foreground mb-1",children:"Version"}),i.jsx("div",{className:"font-medium",children:a.version||"N/A"})]}),i.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[i.jsx("div",{className:"text-muted-foreground mb-1",children:"Endpoint"}),i.jsx("div",{className:"font-medium truncate",title:a.endpoint,children:a.endpoint||"N/A"})]})]}),i.jsxs("div",{className:"text-xs",children:[i.jsx("div",{className:"text-muted-foreground mb-1.5",children:"URL"}),i.jsx("div",{className:"font-mono p-2.5 rounded bg-muted/30 border border-border/50 break-all leading-relaxed",children:a.url||"N/A"})]}),i.jsxs("div",{className:"text-xs",children:[i.jsx("div",{className:"text-muted-foreground mb-1.5",children:"Timestamp"}),i.jsx("div",{className:"font-mono",children:a.timestamp||"N/A"})]}),a.errorType!=="unknown"&&i.jsxs("div",{className:G("flex items-start gap-3 p-3 rounded text-xs",a.errorType==="rate_limit"?"bg-amber-500/10 border border-amber-500/20":a.errorType==="auth"?"bg-red-500/10 border border-red-500/20":"bg-blue-500/10 border border-blue-500/20"),children:[a.errorType==="rate_limit"?i.jsx(ma,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}):a.errorType==="auth"?i.jsx(ma,{className:"w-4 h-4 mt-0.5 text-red-500 shrink-0"}):i.jsx(Fr,{className:"w-4 h-4 mt-0.5 text-blue-500 shrink-0"}),i.jsxs("div",{className:G("leading-relaxed",a.errorType==="rate_limit"?"text-amber-600 dark:text-amber-400":a.errorType==="auth"?"text-red-600 dark:text-red-400":"text-blue-600 dark:text-blue-400"),children:[a.errorType==="rate_limit"&&i.jsxs(i.Fragment,{children:[i.jsx("strong",{children:"Rate Limited."})," Switch to a different account or wait for quota reset.",a.model&&i.jsxs(i.Fragment,{children:[" ","Model ",i.jsx("code",{className:"font-mono text-[11px]",children:a.model})," has exhausted quota."]})]}),a.errorType==="auth"&&"Authentication failed. Re-authenticate via CLIProxy Settings or check API key.",a.errorType==="not_found"&&"Endpoint not found. This endpoint may not exist on this provider.",a.errorType==="server"&&"Server error from upstream. Retry later or check provider status page.",a.errorType==="timeout"&&"Request timed out. Check network connection or increase timeout settings."]})]})]})})}function $j({headers:a}){const s=Object.entries(a);return s.length===0?i.jsx("div",{className:"p-4 text-xs text-muted-foreground",children:"No headers available"}):i.jsx(gl,{className:"h-full",children:i.jsx("div",{className:"p-4 space-y-1",children:s.map(([r,u])=>i.jsxs("div",{className:"flex gap-3 text-xs font-mono py-1.5 border-b border-border/30 last:border-0",children:[i.jsxs("span",{className:"text-muted-foreground shrink-0 min-w-[140px]",children:[r,":"]}),i.jsx("span",{className:"break-all",children:u})]},r))})})}function Zp({content:a,label:s}){if(!a||a.trim()==="")return i.jsxs("div",{className:"p-4 text-xs text-muted-foreground",children:["No ",s.toLowerCase()," body"]});let r=a,u=!1;try{const d=JSON.parse(a);r=JSON.stringify(d,null,2),u=!0}catch{}return i.jsx(gl,{className:"h-full",children:i.jsx("pre",{className:G("p-4 text-xs font-mono whitespace-pre-wrap break-all leading-relaxed",u?"text-emerald-700 dark:text-green-400":"text-zinc-700 dark:text-muted-foreground"),children:r})})}function Jj({content:a}){return i.jsx(gl,{className:"h-full",children:i.jsx("pre",{className:"p-4 text-xs font-mono text-zinc-700 dark:text-muted-foreground whitespace-pre-wrap break-all leading-relaxed",children:a})})}function Pj({name:a,absolutePath:s}){const[r,u]=y.useState("overview"),{data:d,isLoading:f,error:m}=_N(a),p=y.useMemo(()=>d?Dj(d):null,[d]);return a?f?i.jsxs("div",{className:"flex-1 p-6 space-y-3",children:[i.jsx(Le,{className:"h-5 w-full"}),i.jsx(Le,{className:"h-5 w-3/4"}),i.jsx(Le,{className:"h-5 w-5/6"}),i.jsx(Le,{className:"h-5 w-2/3"})]}):m||!d||!p?i.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:i.jsx("p",{className:"text-sm",children:"Failed to load log content"})}):i.jsxs("div",{className:"flex-1 flex flex-col min-w-0 h-full",children:[i.jsxs("div",{className:"px-4 py-3 border-b border-border bg-muted/30 flex items-center justify-between gap-3 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[i.jsx(Sx,{code:p.statusCode}),i.jsxs("span",{className:"text-xs font-semibold truncate text-foreground",children:[p.provider,"/",p.endpoint||"unknown"]}),a&&i.jsx(Xp,{value:s||a,label:"Copy absolute path",size:"icon-sm",className:"ml-1 text-muted-foreground hover:text-foreground opacity-50 hover:opacity-100 transition-opacity"})]}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[d&&i.jsx(Xp,{value:d,label:"Copy raw log content",variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-foreground"}),i.jsx("span",{className:"text-[10px] text-muted-foreground font-mono bg-muted px-1.5 py-0.5 rounded border border-border/50",children:p.method})]})]}),i.jsxs("div",{className:"px-3 py-2 border-b border-border flex items-center gap-1 bg-muted/10 shrink-0 overflow-x-auto",children:[i.jsx(ri,{active:r==="overview",onClick:()=>u("overview"),icon:Fr,children:"Overview"}),i.jsx(ri,{active:r==="headers",onClick:()=>u("headers"),icon:xb,children:"Headers"}),i.jsx(ri,{active:r==="request",onClick:()=>u("request"),icon:yb,children:"Request"}),i.jsx(ri,{active:r==="response",onClick:()=>u("response"),icon:vb,children:"Response"}),i.jsx(ri,{active:r==="raw",onClick:()=>u("raw"),icon:bb,children:"Raw"})]}),i.jsxs("div",{className:"flex-1 overflow-hidden bg-card/30",children:[r==="overview"&&i.jsx(Wj,{parsed:p}),r==="headers"&&i.jsx($j,{headers:p.requestHeaders}),r==="request"&&i.jsx(Zp,{content:p.requestBody,label:"Request"}),r==="response"&&i.jsx(Zp,{content:p.responseBody,label:"Response"}),r==="raw"&&i.jsx(Jj,{content:d})]})]}):i.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:i.jsxs("div",{className:"text-center space-y-3",children:[i.jsx(gb,{className:"w-10 h-10 mx-auto opacity-40"}),i.jsx("p",{className:"text-sm",children:"Select a log to view details"})]})})}function Ij(){const{data:a,isLoading:s}=TN(),{data:r,isLoading:u,error:d}=DN(a?.running??!1),[f,m]=y.useState(500),[p,x]=y.useState(!1),b=y.useRef(null),C=y.useRef(null),v=()=>{C.current&&(clearInterval(C.current),C.current=null)};y.useEffect(()=>{if(!p)return;const B=k=>{const j=b.current;if(!j)return;const Z=j.getBoundingClientRect().top+window.scrollY,ee=k.pageY-Z;m(Math.max(300,ee));const be=window.innerHeight-k.clientY,ue=15;v(),be<50?C.current=setInterval(()=>{window.scrollBy(0,ue)},16):k.clientY<50&&(C.current=setInterval(()=>{window.scrollBy(0,-ue)},16))},L=()=>{x(!1),v(),document.body.style.cursor="default",document.body.style.userSelect="auto"};return document.addEventListener("mousemove",B),document.addEventListener("mouseup",L),document.body.style.cursor="row-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",L),document.body.style.cursor="default",document.body.style.userSelect="auto",v()}},[p]);const S=B=>{B.preventDefault(),x(!0)},M=y.useMemo(()=>r?.[0]?.name??null,[r]),[O,U]=y.useState(null),_=O??M,T=y.useMemo(()=>!_||!r?void 0:r.find(L=>L.name===_)?.absolutePath,[_,r]);if(s||!a?.running)return null;if(u)return i.jsxs("div",{className:"rounded-xl border border-border overflow-hidden font-mono text-sm bg-card/50 dark:bg-zinc-900/60 backdrop-blur-sm h-[500px]",children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[i.jsx(Le,{className:"h-4 w-32"}),i.jsx(Le,{className:"h-4 w-20"})]}),i.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(B=>i.jsx(Le,{className:"h-12 w-full rounded-lg"},B))})]});if(!r||r.length===0)return null;const K=r.length;return i.jsxs("div",{ref:b,className:"rounded-xl border border-border overflow-hidden font-mono text-sm text-foreground bg-card/50 dark:bg-zinc-900/60 backdrop-blur-sm flex flex-col shadow-sm transition-[height] duration-0 ease-linear relative group/container",style:{height:f},children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-gradient-to-r from-amber-500/10 via-transparent to-transparent dark:from-amber-500/15 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2.5",children:[i.jsx(ma,{className:"w-4 h-4 text-amber-500"}),i.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Error Logs"}),i.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:[K," failed request",K!==1?"s":""]})]}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[i.jsx(Sb,{className:"w-3.5 h-3.5"}),i.jsx("span",{children:"CLIProxy Diagnostics"})]})]}),i.jsx("div",{className:"flex-1 min-h-0",children:i.jsxs(pd,{direction:"horizontal",children:[i.jsx(xi,{defaultSize:30,minSize:20,maxSize:50,className:"flex flex-col min-w-0",children:i.jsxs(gl,{className:"h-full",children:[i.jsx("div",{className:"divide-y divide-border/50",children:r.slice(0,50).map(B=>i.jsx(Zj,{name:B.name,size:B.size,modified:B.modified,isSelected:_===B.name,onClick:()=>U(B.name),statusCode:B.statusCode,model:B.model},B.name))}),r.length>50&&i.jsxs("div",{className:"px-3 py-3 text-center text-[10px] text-muted-foreground border-t border-border/50",children:["Showing 50 of ",r.length," logs"]})]})}),i.jsxs(gd,{className:"w-[1px] bg-border hover:bg-primary/50 transition-colors flex items-center justify-center group relative z-10 w-2 -ml-1 flex items-center justify-center outline-none",children:[i.jsx("div",{className:"w-[1px] h-full bg-border group-hover:bg-primary/50 transition-colors"}),i.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-4 h-8 rounded-sm flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-muted border border-border",children:i.jsx(Ir,{className:"h-4 w-4 text-muted-foreground"})})]}),i.jsx(xi,{className:"flex flex-col min-w-0 bg-background/50",children:i.jsx(Pj,{name:_,absolutePath:T})})]})}),d?i.jsx("div",{className:"px-4 py-2 border-t border-border text-xs text-destructive bg-destructive/5 shrink-0",children:d.message}):i.jsx("div",{className:"h-2 bg-border/10 border-t border-border/30 hover:bg-primary/10 transition-colors cursor-row-resize flex items-center justify-center group/handle shrink-0",onMouseDown:S,children:i.jsx(Nb,{className:"w-8 h-3 text-border group-hover:text-primary/50 transition-colors"})})]})}const Fj=to("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",warning:"border-yellow-200 bg-yellow-50 text-yellow-900 dark:border-yellow-900/50 dark:bg-yellow-900/20 dark:text-yellow-200 [&>svg]:text-yellow-600 dark:[&>svg]:text-yellow-500",info:"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-900/50 dark:bg-blue-900/20 dark:text-blue-200 [&>svg]:text-blue-600 dark:[&>svg]:text-blue-500",success:"border-green-200 bg-green-50 text-green-900 dark:border-green-900/50 dark:bg-green-900/20 dark:text-green-200 [&>svg]:text-green-600 dark:[&>svg]:text-green-500"}},defaultVariants:{variant:"default"}}),xd=y.forwardRef(({className:a,variant:s,...r},u)=>i.jsx("div",{ref:u,role:"alert",className:G(Fj({variant:s}),a),...r}));xd.displayName="Alert";const Nx=y.forwardRef(({className:a,...s},r)=>i.jsx("h5",{ref:r,className:G("mb-1 font-medium leading-none tracking-tight",a),...s}));Nx.displayName="AlertTitle";const yd=y.forwardRef(({className:a,...s},r)=>i.jsx("div",{ref:r,className:G("text-sm [&_p]:leading-relaxed",a),...s}));yd.displayName="AlertDescription";function e2(){return zt({queryKey:["overview"],queryFn:async()=>(await fetch("/api/overview")).json()})}function t2(){return zt({queryKey:["shared","summary"],queryFn:async()=>(await fetch("/api/shared/summary")).json()})}function DE(a){return zt({queryKey:["shared",a],queryFn:async()=>(await fetch(`/api/shared/${a}`)).json()})}const n2={ok:"success",warning:"warning",error:"error"},a2={default:{iconBg:"bg-muted",iconColor:"text-muted-foreground"},success:{iconBg:"bg-green-600/15",iconColor:"text-green-700 dark:text-green-500"},warning:{iconBg:"bg-amber-500/15",iconColor:"text-amber-700 dark:text-amber-400"},error:{iconBg:"bg-red-600/15",iconColor:"text-red-700 dark:text-red-500"},accent:{iconBg:"bg-accent/15",iconColor:"text-accent"}};function qr({title:a,value:s,icon:r,variant:u="default",onClick:d}){const f=a2[u];return i.jsxs("button",{onClick:d,className:G("flex items-center gap-3 px-4 py-2.5 rounded-lg border bg-card/50","transition-all hover:bg-card hover:shadow-sm hover:-translate-y-0.5","active:scale-[0.98]"),children:[i.jsx("div",{className:G("flex items-center justify-center w-9 h-9 rounded-md",f.iconBg),children:i.jsx(r,{className:G("w-4 h-4",f.iconColor)})}),i.jsxs("div",{className:"text-left",children:[i.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:a}),i.jsx("p",{className:G("text-lg font-bold font-mono leading-tight",f.iconColor),children:s})]})]})}function l2(){const a=Wc(),{data:s,isLoading:r}=e2(),{data:u,isLoading:d}=t2();if(r||d)return i.jsxs("div",{className:"p-6 space-y-6",children:[i.jsxs("div",{className:"rounded-xl border p-6 flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(Le,{className:"h-12 w-12 rounded-lg"}),i.jsxs("div",{children:[i.jsx(Le,{className:"h-7 w-[180px] mb-2"}),i.jsx(Le,{className:"h-4 w-[220px]"})]})]}),i.jsx("div",{className:"flex items-center gap-3",children:[1,2,3,4].map(m=>i.jsx(Le,{className:"h-14 w-28 rounded-lg"},m))})]}),i.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[i.jsxs("div",{className:"px-4 py-2.5 border-b flex items-center justify-between",children:[i.jsx(Le,{className:"h-4 w-32"}),i.jsx(Le,{className:"h-4 w-20"})]}),i.jsx("div",{className:"px-4 py-3 border-b",children:i.jsx(Le,{className:"h-2 w-full rounded-full"})}),[1,2,3].map(m=>i.jsxs("div",{className:"px-4 py-2.5 flex items-center gap-3 border-b last:border-b-0",children:[i.jsx(Le,{className:"w-2.5 h-2.5 rounded-full"}),i.jsx(Le,{className:"h-4 flex-1"}),i.jsx(Le,{className:"h-1.5 w-24 rounded-full"}),i.jsx(Le,{className:"h-4 w-16"})]},m))]})]});const f=s?.health?n2[s.health.status]:void 0;return i.jsxs("div",{className:"p-6 space-y-6",children:[i.jsxs("div",{className:"relative overflow-hidden rounded-xl border bg-gradient-to-br from-background via-background to-muted/30",children:[i.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",children:i.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)",backgroundSize:"24px 24px"}})}),i.jsxs("div",{className:"relative p-6 flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4",children:[i.jsx(oN,{version:s?.version}),i.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[i.jsx(qr,{title:"Profiles",value:s?.profiles??0,icon:Ug,variant:"accent",onClick:()=>a("/providers")}),i.jsx(qr,{title:"CLIProxy",value:s?.cliproxy??0,icon:qg,variant:"accent",onClick:()=>a("/cliproxy")}),i.jsx(qr,{title:"Accounts",value:s?.accounts??0,icon:Lg,variant:"default",onClick:()=>a("/accounts")}),i.jsx(qr,{title:"Health",value:s?.health?`${s.health.passed}/${s.health.total}`:"-",icon:hi,variant:f,onClick:()=>a("/health")})]})]})]}),u?.symlinkStatus&&!u.symlinkStatus.valid&&i.jsxs(xd,{variant:"warning",children:[i.jsx(ma,{className:"h-4 w-4"}),i.jsx(Nx,{children:"Configuration Required"}),i.jsx(yd,{children:u.symlinkStatus.message})]}),i.jsx(nj,{}),i.jsx(Ij,{})]})}const jx=Mv,vd=y.forwardRef(({className:a,...s},r)=>i.jsx(wg,{ref:r,className:G("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",a),...s}));vd.displayName=wg.displayName;const Xr=y.forwardRef(({className:a,...s},r)=>i.jsx(Cg,{ref:r,className:G("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",a),...s}));Xr.displayName=Cg.displayName;const Qc=y.forwardRef(({className:a,...s},r)=>i.jsx(Eg,{ref:r,className:G("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a),...s}));Qc.displayName=Eg.displayName;function yn({className:a,...s}){return i.jsx(Tv,{"data-slot":"label",className:G("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",a),...s})}const bd="ccs:openrouter-models",s2=1440*60*1e3,wx="1";function Vc(a){const s=parseFloat(a);return isNaN(s)||s===0?0:s*1e6}function Wp(a){const s=Vc(a);return s===0?"Free":s<.01?"<$0.01":s<1?`$${s.toFixed(2)}`:`$${s.toFixed(s<10?2:0)}`}function i2(a){const s=Wp(a.prompt),r=Wp(a.completion);return s==="Free"&&r==="Free"?"Free":`${s}/${r}`}function r2(a){const s=a.id.toLowerCase();return s.startsWith("anthropic/")?"anthropic":s.startsWith("openai/")?"openai":s.startsWith("google/")?"google":s.startsWith("meta-llama/")||s.startsWith("meta/")?"meta":s.startsWith("mistralai/")?"mistral":s.includes(":free")||s.includes("qwen")||s.includes("deepseek")?"opensource":"other"}function o2(a){return{...a,category:r2(a),pricePerMillionPrompt:Vc(a.pricing.prompt),pricePerMillionCompletion:Vc(a.pricing.completion),isFree:a.pricing.prompt==="0"&&a.pricing.completion==="0",isExacto:a.id.includes(":exacto")}}function u2(a,s,r){const u=s.toLowerCase().trim();return a.filter(d=>r?.category&&d.category!==r.category||r?.freeOnly&&!d.isFree||r?.minContext&&d.context_length<r.minContext?!1:u?d.id.toLowerCase().includes(u)||d.name.toLowerCase().includes(u)||d.description?.toLowerCase().includes(u):!0)}function _E(a){return[...a].sort((s,r)=>{if(s.isFree&&!r.isFree)return-1;if(!s.isFree&&r.isFree)return 1;if(!s.isFree&&!r.isFree){if(s.isExacto&&!r.isExacto)return-1;if(!s.isExacto&&r.isExacto)return 1}return s.name.localeCompare(r.name)})}function c2(){try{const a=localStorage.getItem(bd);if(!a)return null;const s=JSON.parse(a);return s.version!==wx||Date.now()-s.fetchedAt>s2?null:s.models}catch{return null}}function d2(a){try{localStorage.setItem(bd,JSON.stringify({models:a,fetchedAt:Date.now(),version:wx}))}catch{}}function f2(){localStorage.removeItem(bd)}function kE(a,s){const[r]=a.split("/");if(!r)return{};const u=s.filter(m=>m.id.startsWith(`${r}/`));if(u.length===0)return{};const d=[...u].sort((m,p)=>p.pricePerMillionPrompt-m.pricePerMillionPrompt),f=Math.ceil(d.length/3);return{opus:d[0]?.id,sonnet:d[Math.min(f,d.length-1)]?.id,haiku:d[d.length-1]?.id}}function m2(a){return a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${Math.round(a/1e3)}K`:String(a)}const RE={anthropic:"Anthropic (Claude)",openai:"OpenAI (GPT)",google:"Google (Gemini)",meta:"Meta (Llama)",mistral:"Mistral",opensource:"Open Source",other:"Other"},h2={anthropic:["anthropic/"],openai:["openai/"],google:["google/"],meta:["meta-llama/","meta/"],mistral:["mistralai/"],opensource:["deepseek/","qwen/","cohere/"],other:[]};function p2(a,s=2){const r=[],u=["anthropic","openai","google","meta","mistral","opensource"];for(const d of u){const f=h2[d];if(f.length===0)continue;const p=[...a.filter(x=>f.some(b=>x.id.toLowerCase().startsWith(b)))].sort((x,b)=>(b.created??0)-(x.created??0));r.push(...p.slice(0,s))}return r.sort((d,f)=>(f.created??0)-(d.created??0))}function g2(a){const r=Date.now()/1e3-a;return r<86400?"Today":r<172800?"Yesterday":r<604800?`${Math.floor(r/86400)}d ago`:r<2592e3?`${Math.floor(r/604800)}w ago`:r<31536e3?`${Math.floor(r/2592e3)}mo ago`:`${Math.floor(r/31536e3)}y ago`}const x2="https://openrouter.ai/api/v1/models",Cx=["openrouter-models"],$p=1440*60*1e3;async function y2(){const a=await fetch(x2);if(!a.ok)throw new Error(`Failed to fetch OpenRouter models: ${a.status}`);const r=(await a.json()).data;return d2(r),r}function Ex(){return zt({queryKey:Cx,queryFn:y2,staleTime:$p,gcTime:$p,initialData:()=>c2()??void 0,refetchOnWindowFocus:!1})}function v2(){const a=Ex(),s=(a.data??[]).map(o2);return{...a,models:s}}function UE(){const a=ut();return()=>(f2(),a.invalidateQueries({queryKey:Cx}))}function qE(){const{data:a,isLoading:s,isError:r}=Ex();return{isReady:!!a&&a.length>0,isLoading:s,isError:r,modelCount:a?.length??0}}function Sd({profileEnv:a={}}){const[s,r]=y.useState(null),[u,d]=y.useState(!0),[f,m]=y.useState(!1);y.useEffect(()=>{p()},[]);const p=async()=>{try{d(!0);const S=await fetch("/api/global-env");if(!S.ok)throw new Error("Failed to load");const M=await S.json();r(M)}catch{r(null)}finally{d(!1)}};if(u||!s?.enabled)return null;const x=s.env||{},b=Object.keys(x);if(b.length===0)return null;const C=b.filter(S=>!(S in a)),v=b.filter(S=>S in a);return i.jsxs("div",{className:"border-t bg-muted/20",children:[i.jsxs("button",{onClick:()=>m(!f),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-muted/30 transition-colors",children:[i.jsx(Fr,{className:"w-4 h-4 text-blue-500"}),i.jsxs("span",{className:"text-xs text-muted-foreground flex-1 text-left",children:[i.jsx("span",{className:"font-medium text-foreground",children:C.length})," global env var",C.length!==1?"s":""," will be injected at runtime",v.length>0&&i.jsxs("span",{className:"text-amber-600 dark:text-amber-400 ml-1",children:["(",v.length," overridden by profile)"]})]}),f?i.jsx(Pc,{className:"w-4 h-4 text-muted-foreground"}):i.jsx(eo,{className:"w-4 h-4 text-muted-foreground"})]}),f&&i.jsxs("div",{className:"px-4 pb-3 space-y-2",children:[C.length>0&&i.jsx("div",{className:"space-y-1",children:C.map(S=>i.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono bg-green-500/10 text-green-700 dark:text-green-400 px-2 py-1 rounded",children:[i.jsx("span",{className:"text-green-500",children:"+"}),i.jsxs("span",{className:"truncate",children:[S,"=",x[S]]})]},S))}),v.length>0&&i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:"Skipped (profile already defines):"}),v.map(S=>i.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono bg-amber-500/10 text-amber-700 dark:text-amber-400 px-2 py-1 rounded",children:[i.jsx("span",{className:"text-amber-500",children:"~"}),i.jsx("span",{className:"truncate",children:S})]},S))]}),i.jsx("div",{className:"pt-2 border-t border-border/50",children:i.jsx(ot,{variant:"ghost",size:"sm",asChild:!0,className:"h-7 text-xs gap-1.5 -ml-2",children:i.jsxs(Bc,{to:"/settings?tab=globalenv",children:[i.jsx(Ic,{className:"w-3.5 h-3.5"}),"Configure in Settings",i.jsx(Yg,{className:"w-3 h-3 opacity-50"})]})})})]})]})}const b2=y.lazy(()=>St(()=>Promise.resolve().then(()=>Nd),void 0).then(a=>({default:a.CodeEditor})));function BE({rawJsonContent:a,isRawJsonValid:s,rawJsonEdits:r,settings:u,onChange:d,missingRequiredFields:f=[]}){const m=f.length>0;return i.jsx(y.Suspense,{fallback:i.jsxs("div",{className:"flex items-center justify-center h-full",children:[i.jsx(En,{className:"w-6 h-6 animate-spin text-muted-foreground"}),i.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading editor..."})]}),children:i.jsxs("div",{className:"h-full flex flex-col",children:[!s&&r!==null&&i.jsxs("div",{className:"mb-2 px-3 py-2 bg-destructive/10 text-destructive text-sm rounded-md flex items-center gap-2 mx-6 mt-4 shrink-0",children:[i.jsx(os,{className:"w-4 h-4"}),"Invalid JSON syntax"]}),s&&m&&i.jsxs("div",{className:"mb-2 px-3 py-2 bg-warning/10 text-warning-foreground text-sm rounded-md flex items-start gap-2 mx-6 mt-4 shrink-0 border border-warning/20",children:[i.jsx(ma,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Missing required fields:"})," ",i.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:f.join(", ")}),i.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"These fields will use default values at runtime."})]})]}),i.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-4 pt-4",children:i.jsx("div",{className:"h-full border rounded-md overflow-hidden bg-background",children:i.jsx(b2,{value:a,onChange:d,language:"json",minHeight:"100%"})})}),i.jsx("div",{className:"mx-6 mb-4",children:i.jsx("div",{className:"border rounded-md overflow-hidden",children:i.jsx(Sd,{profileEnv:u?.env})})})]})})}function Jp(a,s){try{var r=a()}catch(u){return s(u)}return r&&r.then?r.then(void 0,s):r}function S2(a,s){for(var r={};a.length;){var u=a[0],d=u.code,f=u.message,m=u.path.join(".");if(!r[m])if("unionErrors"in u){var p=u.unionErrors[0].errors[0];r[m]={message:p.message,type:p.code}}else r[m]={message:f,type:d};if("unionErrors"in u&&u.unionErrors.forEach(function(C){return C.errors.forEach(function(v){return a.push(v)})}),s){var x=r[m].types,b=x&&x[u.code];r[m]=Gg(m,s,r,d,b?[].concat(b,u.message):u.message)}a.shift()}return r}function N2(a,s){for(var r={};a.length;){var u=a[0],d=u.code,f=u.message,m=u.path.join(".");if(!r[m])if(u.code==="invalid_union"&&u.errors.length>0){var p=u.errors[0][0];r[m]={message:p.message,type:p.code}}else r[m]={message:f,type:d};if(u.code==="invalid_union"&&u.errors.forEach(function(C){return C.forEach(function(v){return a.push(v)})}),s){var x=r[m].types,b=x&&x[u.code];r[m]=Gg(m,s,r,d,b?[].concat(b,u.message):u.message)}a.shift()}return r}function j2(a,s,r){if(r===void 0&&(r={}),(function(u){return"_def"in u&&typeof u._def=="object"&&"typeName"in u._def})(a))return function(u,d,f){try{return Promise.resolve(Jp(function(){return Promise.resolve(a[r.mode==="sync"?"parse":"parseAsync"](u,s)).then(function(m){return f.shouldUseNativeValidation&&jp({},f),{errors:{},values:r.raw?Object.assign({},u):m}})},function(m){if((function(p){return Array.isArray(p?.issues)})(m))return{values:{},errors:wp(S2(m.errors,!f.shouldUseNativeValidation&&f.criteriaMode==="all"),f)};throw m}))}catch(m){return Promise.reject(m)}};if((function(u){return"_zod"in u&&typeof u._zod=="object"})(a))return function(u,d,f){try{return Promise.resolve(Jp(function(){return Promise.resolve((r.mode==="sync"?uS:cS)(a,u,s)).then(function(m){return f.shouldUseNativeValidation&&jp({},f),{errors:{},values:r.raw?Object.assign({},u):m}})},function(m){if((function(p){return p instanceof dS})(m))return{values:{},errors:wp(N2(m.issues,!f.shouldUseNativeValidation&&f.criteriaMode==="all"),f)};throw m}))}catch(m){return Promise.reject(m)}};throw new Error("Invalid input: not a Zod schema")}function HE(){return zt({queryKey:["profiles"],queryFn:()=>Ze.profiles.list()})}function w2(){const a=ut();return mt({mutationFn:s=>Ze.profiles.create(s),onSuccess:()=>{a.invalidateQueries({queryKey:["profiles"]}),le.success("Profile created successfully")},onError:s=>{le.error(s.message)}})}function LE(){const a=ut();return mt({mutationFn:s=>Ze.profiles.delete(s),onSuccess:()=>{a.invalidateQueries({queryKey:["profiles"]}),le.success("Profile deleted successfully")},onError:s=>{le.error(s.message)}})}const C2="https://openrouter.ai/api",Yr=[{id:"openrouter",name:"OpenRouter",description:"349+ models from OpenAI, Anthropic, Google, Meta",baseUrl:C2,defaultProfileName:"openrouter",badge:"349+ models",featured:!0,icon:"/icons/openrouter.svg",defaultModel:"anthropic/claude-opus-4.5",requiresApiKey:!0,apiKeyPlaceholder:"sk-or-...",apiKeyHint:"Get your API key at openrouter.ai/keys",category:"recommended"},{id:"ollama",name:"Ollama (Local)",description:"Local open-source models via Ollama (32K+ context)",baseUrl:"http://localhost:11434",defaultProfileName:"ollama",badge:"Local",featured:!0,icon:"/icons/ollama.svg",defaultModel:"qwen3-coder",requiresApiKey:!1,apiKeyPlaceholder:"",apiKeyHint:"No API key required for local Ollama",category:"recommended"},{id:"glm",name:"GLM",description:"Claude via Z.AI",baseUrl:"https://api.z.ai/api/anthropic",defaultProfileName:"glm",badge:"Z.AI",icon:"/icons/zai.svg",defaultModel:"glm-5",requiresApiKey:!0,apiKeyPlaceholder:"ghp_...",apiKeyHint:"Get your API key from Z.AI",category:"alternative"},{id:"glmt",name:"GLMT",description:"GLM with Thinking mode support",baseUrl:"https://api.z.ai/api/coding/paas/v4/chat/completions",defaultProfileName:"glmt",badge:"Thinking",icon:"/icons/zai.svg",defaultModel:"glm-5",requiresApiKey:!0,apiKeyPlaceholder:"ghp_...",apiKeyHint:"Same API key as GLM",category:"alternative"},{id:"km",name:"Kimi",description:"Moonshot AI - Fast reasoning model",baseUrl:"https://api.kimi.com/coding/",defaultProfileName:"km",badge:"Reasoning",icon:"/icons/kimi.svg",defaultModel:"kimi-k2-thinking-turbo",requiresApiKey:!0,apiKeyPlaceholder:"sk-...",apiKeyHint:"Get your API key from Moonshot AI",category:"alternative",alwaysThinkingEnabled:!0},{id:"foundry",name:"Azure Foundry",description:"Claude via Microsoft Azure AI Foundry",baseUrl:"https://<your-resource>.services.ai.azure.com/api/anthropic",defaultProfileName:"foundry",badge:"Azure",icon:"/icons/azure.svg",defaultModel:"claude-sonnet-4-5",requiresApiKey:!0,apiKeyPlaceholder:"YOUR_AZURE_API_KEY",apiKeyHint:"Create resource at ai.azure.com, get API key from Keys tab",category:"alternative"},{id:"mm",name:"Minimax",description:"M2.1/M2.1-lightning/M2 - multilang coding (1M context)",baseUrl:"https://api.minimax.io/anthropic",defaultProfileName:"mm",badge:"1M context",icon:"/icons/minimax.svg",defaultModel:"MiniMax-M2.1",requiresApiKey:!0,apiKeyPlaceholder:"YOUR_MINIMAX_API_KEY_HERE",apiKeyHint:"Get your API key at platform.minimax.io",category:"alternative"},{id:"deepseek",name:"DeepSeek",description:"V3.2 and R1 reasoning model (128K context)",baseUrl:"https://api.deepseek.com/anthropic",defaultProfileName:"deepseek",badge:"Reasoning",icon:"/icons/deepseek.svg",defaultModel:"deepseek-chat",requiresApiKey:!0,apiKeyPlaceholder:"sk-...",apiKeyHint:"Get your API key at platform.deepseek.com",category:"alternative"},{id:"qwen",name:"Qwen",description:"Alibaba Cloud - Qwen3 models (256K-1M context, thinking support)",baseUrl:"https://dashscope-intl.aliyuncs.com/apps/anthropic",defaultProfileName:"qwen",badge:"Alibaba",icon:"/assets/providers/qwen-color.svg",defaultModel:"qwen3-coder-plus",requiresApiKey:!0,apiKeyPlaceholder:"sk-...",apiKeyHint:"Get your API key from Alibaba Cloud Model Studio",category:"alternative"},{id:"ollama-cloud",name:"Ollama Cloud",description:"Ollama cloud models via direct API (glm-5:cloud, minimax-m2.1:cloud)",baseUrl:"https://ollama.com",defaultProfileName:"ollama-cloud",badge:"Cloud",icon:"/icons/ollama.svg",defaultModel:"glm-5:cloud",requiresApiKey:!0,apiKeyPlaceholder:"YOUR_OLLAMA_CLOUD_API_KEY",apiKeyHint:"Get your API key at ollama.com",category:"alternative"}];function Br(a){return Yr.filter(s=>s.category===a)}const E2=fS({name:cl().min(1,"Name is required").regex(/^[a-zA-Z][a-zA-Z0-9._-]*$/,"Must start with letter, only letters/numbers/.-_"),baseUrl:cl().url("Invalid URL format"),apiKey:cl(),model:cl().optional(),opusModel:cl().optional(),sonnetModel:cl().optional(),haikuModel:cl().optional()}),M2=["/chat/completions","/v1/messages","/messages","/completions"];function YE({open:a,onOpenChange:s,onSuccess:r,initialMode:u="openrouter"}){const d=w2(),[f,m]=y.useState("basic"),[p,x]=y.useState(null),[b,C]=y.useState(!1),[v,S]=y.useState("openrouter"),[M,O]=y.useState(""),{models:U}=v2(),{register:_,handleSubmit:T,formState:{errors:K},control:B,reset:L,setValue:k}=mS({resolver:j2(E2),defaultValues:{name:"",baseUrl:"",apiKey:"",model:"",opusModel:"",sonnetModel:"",haikuModel:""}}),j=hS({control:B,name:"baseUrl"}),H=y.useMemo(()=>!v||v==="custom"?null:Yr.find(P=>P.id===v),[v]),Z=y.useMemo(()=>M.trim()?[...u2(U,M)].sort((A,W)=>(W.created??0)-(A.created??0)).slice(0,20):p2(U,2),[U,M]);y.useEffect(()=>{if(a)if(L(),m("basic"),x(null),C(!1),O(""),u==="normal")S("custom"),setTimeout(()=>{k("name",""),k("baseUrl","")},0);else{S("openrouter");const P=Yr.find(A=>A.id==="openrouter");P&&setTimeout(()=>{k("name",P.defaultProfileName),k("baseUrl",P.baseUrl)},0)}},[a,L,k,u]);const ee=P=>{S(P);const A=Yr.find(W=>W.id===P);A?(k("name",A.defaultProfileName),k("baseUrl",A.baseUrl),A.defaultModel&&(k("model",A.defaultModel),k("opusModel",A.defaultModel),k("sonnetModel",A.defaultModel),k("haikuModel",A.defaultModel))):(k("name",""),k("baseUrl",""),k("model",""))},se=P=>{k("model",P.id),k("opusModel",P.id),k("sonnetModel",P.id),k("haikuModel",P.id),O(P.name),le.success(`Applied "${P.name}" to all model tiers`,{duration:2e3})};y.useEffect(()=>{if(j&&v==="custom"){const A=j.toLowerCase();for(const W of M2)if(A.endsWith(W)){const ie=j.replace(new RegExp(W+"$","i"),"");x(`URL ends with "${W}" - Claude appends this automatically. You likely want: ${ie}`);return}}x(null)},[j,v]);const be=async P=>{if(H?.requiresApiKey!==!1&&!P.apiKey){le.error("API key is required");return}const A={...P,apiKey:P.apiKey||""};try{await d.mutateAsync(A),le.success(`Profile "${A.name}" created`),r(A.name),s(!1)}catch(W){le.error(W.message||"Failed to create profile")}},ue=!!K.name||!!K.baseUrl||!!K.apiKey,Ye=!!K.model||!!K.opusModel||!!K.sonnetModel||!!K.haikuModel,Ne=v==="openrouter";return i.jsx(id,{open:a,onOpenChange:s,children:i.jsxs(rd,{className:"sm:max-w-[700px] p-0 gap-0 overflow-hidden max-h-[90vh]",children:[i.jsxs(od,{className:"p-6 pb-4 border-b",children:[i.jsxs(ud,{className:"flex items-center gap-2",children:[i.jsx(Sp,{className:"w-5 h-5 text-primary"}),"Create API Profile"]}),i.jsx(cd,{children:"Choose a provider or configure a custom API endpoint."})]}),i.jsxs("form",{onSubmit:T(be),className:"flex flex-col overflow-hidden",children:[i.jsxs("div",{className:"px-6 py-3 border-b bg-muted/30 space-y-2",children:[i.jsxs("div",{children:[i.jsx(yn,{className:"text-xs text-muted-foreground mb-1.5 block",children:"Provider"}),i.jsxs("div",{className:"flex gap-2",children:[Br("recommended").map(P=>i.jsx(Pp,{preset:P,isSelected:v===P.id,onClick:()=>ee(P.id)},P.id)),i.jsxs("button",{type:"button",onClick:()=>ee("custom"),className:G("flex items-center gap-2 px-4 py-2 rounded-md border-2 transition-all text-sm font-medium",v==="custom"||Br("alternative").some(P=>P.id===v)?"border-primary bg-primary/10 text-primary dark:bg-primary/20":"border-dashed border-muted-foreground/40 hover:border-primary/50 hover:bg-muted/50 text-muted-foreground hover:text-foreground"),children:[i.jsx(Ic,{className:"w-4 h-4"}),i.jsx("span",{children:"Custom"})]})]})]}),(v==="custom"||Br("alternative").some(P=>P.id===v))&&i.jsxs("div",{className:"pt-3 mt-2 border-t border-dashed border-muted-foreground/30",children:[i.jsx(yn,{className:"text-xs font-medium text-foreground/70 mb-2 block",children:"Quick Templates"}),i.jsx("div",{className:"flex gap-2 flex-wrap",children:Br("alternative").map(P=>i.jsx(Pp,{preset:P,isSelected:v===P.id,onClick:()=>ee(P.id)},P.id))})]})]}),i.jsxs(jx,{value:f,onValueChange:m,className:"flex flex-col flex-1 overflow-hidden",children:[i.jsx("div",{className:"px-6 pt-4",children:i.jsxs(vd,{className:"grid w-full grid-cols-2",children:[i.jsxs(Xr,{value:"basic",className:"relative",children:["Basic Information",ue&&i.jsx("span",{className:"absolute top-1 right-2 w-2 h-2 rounded-full bg-destructive animate-pulse"})]}),i.jsxs(Xr,{value:"models",className:"relative",children:["Model Configuration",Ye&&i.jsx("span",{className:"absolute top-1 right-2 w-2 h-2 rounded-full bg-destructive animate-pulse"})]})]})}),i.jsxs(gl,{className:"flex-1",children:[i.jsxs(Qc,{value:"basic",className:"p-6 space-y-4 mt-0",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"name",children:["Profile Name ",i.jsx("span",{className:"text-destructive",children:"*"})]}),i.jsx(Rn,{id:"name",..._("name"),placeholder:"my-api",className:"font-mono"}),K.name?i.jsx("p",{className:"text-xs text-destructive",children:K.name.message}):i.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used in CLI:"," ",i.jsx("code",{className:"bg-muted px-1 rounded text-[10px]",children:'ccs my-api "prompt"'})]})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"baseUrl",children:["API Base URL ",i.jsx("span",{className:"text-destructive",children:"*"})]}),i.jsx(Rn,{id:"baseUrl",..._("baseUrl"),placeholder:"https://api.example.com/v1"}),K.baseUrl?i.jsx("p",{className:"text-xs text-destructive",children:K.baseUrl.message}):p?i.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-600 bg-yellow-50 dark:bg-yellow-900/20 p-2 rounded",children:[i.jsx(ma,{className:"w-4 h-4 shrink-0 mt-0.5"}),i.jsx("span",{children:p})]}):H?i.jsxs("p",{className:"text-xs text-muted-foreground",children:["Pre-filled from ",H.name,". You can customize if needed."]}):i.jsx("p",{className:"text-xs text-muted-foreground",children:"The endpoint that accepts OpenAI-compatible and Anthropic requests"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"apiKey",children:["API Key"," ",H?.requiresApiKey!==!1&&i.jsx("span",{className:"text-destructive",children:"*"}),H?.requiresApiKey===!1&&i.jsx("span",{className:"text-muted-foreground text-xs font-normal",children:"(optional)"})]}),i.jsxs("div",{className:"relative",children:[i.jsx(Rn,{id:"apiKey",type:b?"text":"password",..._("apiKey"),placeholder:H?.requiresApiKey===!1?"Optional - only if auth is enabled":H?.apiKeyPlaceholder??"sk-...",className:"pr-10"}),i.jsx(ot,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-9 w-9 text-muted-foreground hover:text-foreground",onClick:()=>C(!b),tabIndex:-1,children:b?i.jsx($r,{className:"h-4 w-4"}):i.jsx(Jr,{className:"h-4 w-4"})})]}),K.apiKey?i.jsx("p",{className:"text-xs text-destructive",children:K.apiKey.message}):H?.requiresApiKey===!1?i.jsx("p",{className:"text-xs text-muted-foreground",children:"Only needed if you have configured Ollama authentication"}):H?.apiKeyHint&&i.jsx("p",{className:"text-xs text-muted-foreground",children:H.apiKeyHint})]})]}),i.jsxs(Qc,{value:"models",className:"p-6 mt-0 space-y-4",children:[i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-blue-50 dark:bg-blue-950/20 text-blue-800 dark:text-blue-300 rounded-md text-sm border border-blue-100 dark:border-blue-900/30",children:[i.jsx(Fr,{className:"w-5 h-5 shrink-0 mt-0.5"}),i.jsxs("div",{children:[i.jsx("p",{className:"font-medium mb-1",children:"Model Mapping"}),i.jsx("p",{className:"text-xs opacity-90",children:"Map Claude Code tiers (Opus/Sonnet/Haiku) to models supported by your provider."})]})]}),Ne&&i.jsxs("div",{className:"space-y-2",children:[i.jsx(yn,{children:"Search Models"}),i.jsx(Rn,{value:M,onChange:P=>O(P.target.value),placeholder:"Type to search (e.g., opus, sonnet, gpt-4o)...",onKeyDown:P=>{P.key==="Enter"&&Z.length>0&&(P.preventDefault(),se(Z[0]))}}),i.jsx("div",{className:"border rounded-md max-h-48 overflow-y-auto",children:Z.length===0?i.jsx("p",{className:"text-sm text-muted-foreground p-3 text-center",children:M?`No models found for "${M}"`:"Loading models..."}):i.jsxs("div",{className:"p-1",children:[!M&&i.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 text-xs text-muted-foreground",children:[i.jsx(jb,{className:"w-3 h-3 text-accent"}),i.jsx("span",{children:"Newest Models"})]}),Z.map(P=>i.jsx(T2,{model:P,onClick:()=>se(P),showAge:!M},P.id))]})})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"model",children:["Default Model",i.jsx(Ya,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"ANTHROPIC_MODEL"})]}),i.jsx(Rn,{id:"model",..._("model"),placeholder:H?.defaultModel??"claude-sonnet-4",className:"font-mono text-sm"})]}),i.jsxs("div",{className:"grid gap-3 pt-2 border-t",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"sonnetModel",className:"text-sm",children:["Sonnet Mapping",i.jsx(Ya,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_SONNET"})]}),i.jsx(Rn,{id:"sonnetModel",..._("sonnetModel"),placeholder:"e.g. gpt-4o, claude-sonnet-4",className:"font-mono text-sm h-9"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"opusModel",className:"text-sm",children:["Opus Mapping",i.jsx(Ya,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_OPUS"})]}),i.jsx(Rn,{id:"opusModel",..._("opusModel"),placeholder:"e.g. o1, claude-opus-4.5",className:"font-mono text-sm h-9"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"haikuModel",className:"text-sm",children:["Haiku Mapping",i.jsx(Ya,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_HAIKU"})]}),i.jsx(Rn,{id:"haikuModel",..._("haikuModel"),placeholder:"e.g. gpt-4o-mini, claude-3.5-haiku",className:"font-mono text-sm h-9"})]})]})]})]})]}),i.jsxs(Z1,{className:"p-6 pt-4 border-t bg-muted/10",children:[i.jsx(ot,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),i.jsx(ot,{type:"submit",disabled:d.isPending,className:G(d.isPending&&"opacity-80"),children:d.isPending?i.jsxs(i.Fragment,{children:[i.jsx(En,{className:"w-4 h-4 mr-2 animate-spin"}),"Creating..."]}):i.jsxs(i.Fragment,{children:[i.jsx(Sp,{className:"w-4 h-4 mr-2"}),"Create Profile"]})})]})]})]})]})})}function Pp({preset:a,isSelected:s,onClick:r}){return i.jsxs("button",{type:"button",onClick:r,className:G("flex items-center gap-2 px-3 py-2 rounded-md border transition-all text-sm",s?a.featured?"border-accent bg-accent/10 dark:bg-accent/20 font-medium":"border-primary bg-primary/10 dark:bg-primary/20 font-medium":"border-muted-foreground/20 hover:border-muted-foreground/40 hover:bg-muted/50"),children:[a.icon?i.jsx("img",{src:a.icon,alt:"",className:"w-4 h-4"}):i.jsx("div",{className:"w-4 h-4 rounded-full bg-muted-foreground/20 flex items-center justify-center text-[9px] font-bold text-foreground/70",children:a.name.charAt(0)}),i.jsx("span",{className:"font-medium",children:a.name}),a.badge&&i.jsx(Ya,{variant:"secondary",className:"text-[10px] px-1.5 py-0 ml-0.5 bg-muted-foreground/10 text-muted-foreground",children:a.badge})]})}function T2({model:a,onClick:s,showAge:r}){return i.jsxs("button",{type:"button",onClick:s,className:"group flex w-full items-center justify-between rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",children:[i.jsx("span",{className:"flex-1 truncate",children:a.name}),i.jsxs("span",{className:"text-muted-foreground group-hover:text-accent-foreground/80 ml-2 flex items-center gap-2 text-xs",children:[r&&a.created&&i.jsx(Ya,{variant:"outline",className:"text-[10px] text-accent group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30",children:g2(a.created)}),a.isFree?i.jsx(Ya,{variant:"secondary",className:"text-xs group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground",children:"Free"}):i.jsx("span",{children:i2(a.pricing)}),i.jsx("span",{children:m2(a.context_length)})]})]})}function A2({className:a,...s}){return i.jsx("div",{"data-slot":"card",className:G("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",a),...s})}function O2({className:a,...s}){return i.jsx("div",{"data-slot":"card-header",className:G("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",a),...s})}function z2({className:a,...s}){return i.jsx("div",{"data-slot":"card-title",className:G("leading-none font-semibold",a),...s})}function D2({className:a,...s}){return i.jsx("div",{"data-slot":"card-description",className:G("text-muted-foreground text-sm",a),...s})}function _2({className:a,...s}){return i.jsx("div",{"data-slot":"card-content",className:G("px-6",a),...s})}const k2=["agy","claude","gemini","codex","qwen","kimi","iflow","kiro","ghcp"],GE=k2.map(a=>({id:a,name:Fg(a),description:fN(a)})),R2=["provider","auth","variant","success"];function KE(a){return a==="account"?1:R2.indexOf(a)}const QE=kv,VE=Uv,XE=Rv,U2=y.forwardRef(({className:a,children:s,...r},u)=>i.jsxs(Mg,{ref:u,className:G("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",a),...r,children:[s,i.jsx(Av,{asChild:!0,children:i.jsx(eo,{className:"h-4 w-4 opacity-50"})})]}));U2.displayName=Mg.displayName;const Mx=y.forwardRef(({className:a,...s},r)=>i.jsx(Tg,{ref:r,className:G("flex cursor-default items-center justify-center py-1",a),...s,children:i.jsx(Pc,{className:"h-4 w-4"})}));Mx.displayName=Tg.displayName;const Tx=y.forwardRef(({className:a,...s},r)=>i.jsx(Ag,{ref:r,className:G("flex cursor-default items-center justify-center py-1",a),...s,children:i.jsx(eo,{className:"h-4 w-4"})}));Tx.displayName=Ag.displayName;const q2=y.forwardRef(({className:a,children:s,position:r="popper",...u},d)=>i.jsx(Ov,{children:i.jsxs(Og,{ref:d,className:G("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",a),position:r,...u,children:[i.jsx(Mx,{}),i.jsx(zv,{className:G("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),i.jsx(Tx,{})]})}));q2.displayName=Og.displayName;const B2=y.forwardRef(({className:a,...s},r)=>i.jsx(zg,{ref:r,className:G("px-2 py-1.5 text-sm font-semibold",a),...s}));B2.displayName=zg.displayName;const H2=y.forwardRef(({className:a,children:s,...r},u)=>i.jsxs(Dg,{ref:u,className:G("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...r,children:[i.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(Dv,{children:i.jsx(rs,{className:"h-4 w-4"})})}),i.jsx(_v,{children:s})]}));H2.displayName=Dg.displayName;const L2=y.forwardRef(({className:a,...s},r)=>i.jsx(_g,{ref:r,className:G("-mx-1 my-1 h-px bg-muted",a),...s}));L2.displayName=_g.displayName;const Y2=y.lazy(()=>St(()=>Promise.resolve().then(()=>Nd),void 0).then(a=>({default:a.CodeEditor})));function ZE({rawJsonContent:a,isRawJsonValid:s,rawJsonEdits:r,onRawJsonChange:u,profileEnv:d,missingRequiredFields:f=[]}){const m=f.length>0;return i.jsx(y.Suspense,{fallback:i.jsxs("div",{className:"flex items-center justify-center h-full",children:[i.jsx(En,{className:"w-6 h-6 animate-spin text-muted-foreground"}),i.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading editor..."})]}),children:i.jsxs("div",{className:"h-full flex flex-col",children:[!s&&r!==null&&i.jsxs("div",{className:"mb-2 px-3 py-2 bg-destructive/10 text-destructive text-sm rounded-md flex items-center gap-2 mx-6 mt-4 shrink-0",children:[i.jsx(os,{className:"w-4 h-4"}),"Invalid JSON syntax"]}),s&&m&&i.jsxs("div",{className:"mb-2 px-3 py-2 bg-warning/10 text-warning-foreground text-sm rounded-md flex items-start gap-2 mx-6 mt-4 shrink-0 border border-warning/20",children:[i.jsx(ma,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Missing required fields:"})," ",i.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:f.join(", ")}),i.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Apply a preset from Model Config tab or add these fields manually. Without them, Claude Code will fail with 404 errors."})]})]}),i.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-4 pt-4",children:i.jsx("div",{className:"h-full border rounded-md overflow-hidden bg-background",children:i.jsx(Y2,{value:a,onChange:u,language:"json",minHeight:"100%"})})}),i.jsx("div",{className:"mx-6 mb-4",children:i.jsx("div",{className:"border rounded-md overflow-hidden",children:i.jsx(Sd,{profileEnv:d})})})]})})}const G2=y.forwardRef(({className:a,value:s=0,max:r=100,indicatorClassName:u,...d},f)=>{const m=Math.min(Math.max(s/r*100,0),100);return i.jsx("div",{ref:f,role:"progressbar","aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":s,className:G("relative h-2 w-full overflow-hidden rounded-full bg-secondary",a),...d,children:i.jsx("div",{className:G("h-full transition-all",u||"bg-primary"),style:{width:`${m}%`}})})});G2.displayName="Progress";var Kt={},Ip;function K2(){if(Ip)return Kt;Ip=1;var a=Kt&&Kt.__assign||function(){return a=Object.assign||function(k){for(var j,H=1,Z=arguments.length;H<Z;H++){j=arguments[H];for(var ee in j)Object.prototype.hasOwnProperty.call(j,ee)&&(k[ee]=j[ee])}return k},a.apply(this,arguments)},s=Kt&&Kt.__createBinding||(Object.create?(function(k,j,H,Z){Z===void 0&&(Z=H);var ee=Object.getOwnPropertyDescriptor(j,H);(!ee||("get"in ee?!j.__esModule:ee.writable||ee.configurable))&&(ee={enumerable:!0,get:function(){return j[H]}}),Object.defineProperty(k,Z,ee)}):(function(k,j,H,Z){Z===void 0&&(Z=H),k[Z]=j[H]})),r=Kt&&Kt.__setModuleDefault||(Object.create?(function(k,j){Object.defineProperty(k,"default",{enumerable:!0,value:j})}):function(k,j){k.default=j}),u=Kt&&Kt.__importStar||function(k){if(k&&k.__esModule)return k;var j={};if(k!=null)for(var H in k)H!=="default"&&Object.prototype.hasOwnProperty.call(k,H)&&s(j,k,H);return r(j,k),j},d=Kt&&Kt.__rest||function(k,j){var H={};for(var Z in k)Object.prototype.hasOwnProperty.call(k,Z)&&j.indexOf(Z)<0&&(H[Z]=k[Z]);if(k!=null&&typeof Object.getOwnPropertySymbols=="function")for(var ee=0,Z=Object.getOwnPropertySymbols(k);ee<Z.length;ee++)j.indexOf(Z[ee])<0&&Object.prototype.propertyIsEnumerable.call(k,Z[ee])&&(H[Z[ee]]=k[Z[ee]]);return H};Object.defineProperty(Kt,"__esModule",{value:!0});var f=u(Rg()),m=89,p=90,x=77,b=57,C=219,v=222,S=192,M=100,O=3e3,U=typeof window<"u"&&"navigator"in window&&/Win/i.test(navigator.platform),_=typeof window<"u"&&"navigator"in window&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),T="npm__react-simple-code-editor__textarea",K=`
14
+ `).trim()}function Uj(a){const s=a.url.match(/\/api\/provider\/([^/]+)/);s&&(a.provider=s[1]);const r=a.url.match(/\/api\/provider\/[^/]+\/(.+?)(?:\?|$)/);r&&(a.endpoint=r[1]),a.isClientError=a.statusCode>=400&&a.statusCode<500,a.isServerError=a.statusCode>=500,a.statusCode===429?a.errorType="rate_limit":a.statusCode===401||a.statusCode===403?a.errorType="auth":a.statusCode===404?a.errorType="not_found":a.statusCode>=500?a.errorType="server":(a.statusCode===408||a.statusCode===504)&&(a.errorType="timeout"),qj(a),a.statusCode===429&&Bj(a)}function qj(a){if(a.requestBody)try{const s=JSON.parse(a.requestBody);typeof s.model=="string"&&(a.model=s.model)}catch{}}function Bj(a){if(a.responseBody)try{const s=JSON.parse(a.responseBody),r=Gc(s);r!==null&&(a.quotaResetDelay=r);const u=Kc(s);u&&(a.quotaResetTimestamp=u)}catch{}}function Gc(a){if(typeof a!="object"||a===null)return null;const s=a;if("quotaResetDelay"in s){const r=s.quotaResetDelay;if(typeof r=="number")return r;if(typeof r=="string"){const u=r.match(/^(\d+)s?$/);if(u)return parseInt(u[1],10)}}if("error"in s&&typeof s.error=="object"){const r=Gc(s.error);if(r!==null)return r}if("details"in s&&Array.isArray(s.details))for(const r of s.details){const u=Gc(r);if(u!==null)return u}return null}function Kc(a){if(typeof a!="object"||a===null)return null;const s=a;for(const r of["quotaResetTimeStamp","quotaResetTimestamp","resetTime","reset_time"])if(r in s&&typeof s[r]=="string")return s[r];if("error"in s&&typeof s.error=="object"){const r=Kc(s.error);if(r)return r}if("details"in s&&Array.isArray(s.details))for(const r of s.details){const u=Kc(r);if(u)return u}return null}function Hj(a){return{400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",408:"Request Timeout",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout"}[a]||""}function Lj(a){const s=Date.now(),r=a*1e3,u=s-r,d=Math.floor(u/1e3),f=Math.floor(d/60),m=Math.floor(f/60),p=Math.floor(m/24);return d<60?"just now":f<60?`${f}m ago`:m<24?`${m}h ago`:p<7?`${p}d ago`:new Date(r).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Yj(a){return a>=500?"text-red-500":a===429?"text-orange-500":a>=400?"text-yellow-500":"text-gray-500"}function Gj(a){return{rate_limit:"Rate Limited",auth:"Auth Error",not_found:"Not Found",server:"Server Error",timeout:"Timeout",unknown:"Error"}[a]||"Error"}function Kj(a){if(a===null||a<=0)return null;if(a<60)return`${a}s`;if(a<3600)return`${Math.floor(a/60)}m`;const s=Math.floor(a/3600),r=Math.floor(a%3600/60);return r>0?`${s}h ${r}m`:`${s}h`}function Qj(a){if(!a)return null;try{const s=new Date(a),r=new Date,u=s.getTime()-r.getTime();if(u<=0)return"now";const d=Math.floor(u/1e3);if(d<60)return`${d}s`;if(d<3600)return`${Math.floor(d/60)}m`;const f=Math.floor(d/3600),m=Math.floor(d%3600/60);return m>0?`${f}h ${m}m`:`${f}h`}catch{return null}}function Vj(a){return a?a===429?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":a>=500?"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400":a>=400?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-gray-100 text-gray-600":"bg-gray-100 text-gray-600"}function Xj(a){return a||""}function Zj({name:a,size:s,modified:r,isSelected:u,onClick:d,statusCode:f,model:m}){const p=y.useMemo(()=>zj(a),[a]),x=y.useMemo(()=>Xj(m),[m]);return i.jsxs("button",{onClick:d,className:G("w-full px-2.5 py-2 flex items-center gap-2 text-left transition-colors","hover:bg-muted/40 border-l-[3px]",u?"bg-muted/50 border-l-red-500":"border-l-transparent"),children:[i.jsx("span",{className:G("shrink-0 text-[10px] font-bold px-1.5 py-0.5 rounded min-w-[32px] text-center",Vj(f)),children:f||"???"}),i.jsx(dd,{provider:p.provider,size:18,withBackground:!0,className:"shrink-0"}),i.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[i.jsx("span",{className:"text-[11px] font-medium text-foreground truncate",children:p.endpoint||"unknown"}),x&&i.jsx("span",{className:"text-[10px] text-muted-foreground truncate",title:x,children:x}),i.jsxs("div",{className:"flex items-center gap-1 text-[9px] text-muted-foreground/60",children:[i.jsx(gi,{className:"w-2.5 h-2.5"}),i.jsx("span",{children:Lj(r)})]})]})]})}function Xp({value:a,className:s,variant:r="outline",size:u="icon",label:d="Copy to clipboard"}){const[f,m]=y.useState(!1),p=()=>{navigator.clipboard.writeText(a),m(!0),setTimeout(()=>m(!1),2e3)};return i.jsx(ml,{children:i.jsxs(Ga,{children:[i.jsx(Ka,{asChild:!0,children:i.jsxs(ot,{size:u,variant:r,className:G("relative z-10 text-muted-foreground hover:text-foreground",s),onClick:x=>{x.stopPropagation(),p()},children:[f?i.jsx(rs,{className:"h-3.5 w-3.5 text-green-500"}):i.jsx(Gr,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"sr-only",children:d})]})}),i.jsx(Qa,{children:i.jsx("p",{children:f?"Copied!":d})})]})})}function ri({active:a,onClick:s,children:r,icon:u}){return i.jsxs("button",{onClick:s,className:G("px-2.5 py-1.5 text-xs font-medium rounded transition-colors flex items-center gap-1.5",a?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[u&&i.jsx(u,{className:"w-3.5 h-3.5"}),r]})}function Sx({code:a}){const s=Yj(a);return i.jsx("span",{className:G("inline-flex items-center justify-center min-w-[36px] px-2 py-0.5 rounded text-xs font-bold","bg-current/10 border border-current/20",s),children:a})}function Wj({parsed:a}){const s=Kj(a.quotaResetDelay)||Qj(a.quotaResetTimestamp);return i.jsx(gl,{className:"h-full",children:i.jsxs("div",{className:"p-4 space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Sx,{code:a.statusCode}),i.jsx("span",{className:"text-sm font-medium",children:a.statusText}),i.jsx("span",{className:"text-xs text-muted-foreground px-2 py-0.5 rounded bg-muted/50",children:Gj(a.errorType)})]}),a.model&&i.jsxs("div",{className:"flex items-center gap-2.5 p-3 rounded-lg bg-violet-500/10 border border-violet-500/20",children:[i.jsx(pb,{className:"w-4 h-4 text-violet-500 shrink-0"}),i.jsxs("div",{className:"text-sm",children:[i.jsx("span",{className:"text-muted-foreground",children:"Model: "}),i.jsx("span",{className:"font-semibold text-violet-600 dark:text-violet-400",children:a.model})]})]}),a.errorType==="rate_limit"&&s&&i.jsxs("div",{className:"flex items-center gap-2.5 p-3 rounded-lg bg-amber-500/10 border border-amber-500/20",children:[i.jsx(gi,{className:"w-4 h-4 text-amber-500 shrink-0"}),i.jsxs("div",{className:"text-sm",children:[i.jsx("span",{className:"text-muted-foreground",children:"Quota resets in "}),i.jsx("span",{className:"font-semibold text-amber-600 dark:text-amber-400",children:s})]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-3 text-xs",children:[i.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[i.jsx("div",{className:"text-muted-foreground mb-1",children:"Method"}),i.jsx("div",{className:"font-medium",children:a.method||"N/A"})]}),i.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[i.jsx("div",{className:"text-muted-foreground mb-1",children:"Provider"}),i.jsx("div",{className:"font-medium",children:a.provider||"N/A"})]}),i.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[i.jsx("div",{className:"text-muted-foreground mb-1",children:"Version"}),i.jsx("div",{className:"font-medium",children:a.version||"N/A"})]}),i.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[i.jsx("div",{className:"text-muted-foreground mb-1",children:"Endpoint"}),i.jsx("div",{className:"font-medium truncate",title:a.endpoint,children:a.endpoint||"N/A"})]})]}),i.jsxs("div",{className:"text-xs",children:[i.jsx("div",{className:"text-muted-foreground mb-1.5",children:"URL"}),i.jsx("div",{className:"font-mono p-2.5 rounded bg-muted/30 border border-border/50 break-all leading-relaxed",children:a.url||"N/A"})]}),i.jsxs("div",{className:"text-xs",children:[i.jsx("div",{className:"text-muted-foreground mb-1.5",children:"Timestamp"}),i.jsx("div",{className:"font-mono",children:a.timestamp||"N/A"})]}),a.errorType!=="unknown"&&i.jsxs("div",{className:G("flex items-start gap-3 p-3 rounded text-xs",a.errorType==="rate_limit"?"bg-amber-500/10 border border-amber-500/20":a.errorType==="auth"?"bg-red-500/10 border border-red-500/20":"bg-blue-500/10 border border-blue-500/20"),children:[a.errorType==="rate_limit"?i.jsx(ma,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}):a.errorType==="auth"?i.jsx(ma,{className:"w-4 h-4 mt-0.5 text-red-500 shrink-0"}):i.jsx(Fr,{className:"w-4 h-4 mt-0.5 text-blue-500 shrink-0"}),i.jsxs("div",{className:G("leading-relaxed",a.errorType==="rate_limit"?"text-amber-600 dark:text-amber-400":a.errorType==="auth"?"text-red-600 dark:text-red-400":"text-blue-600 dark:text-blue-400"),children:[a.errorType==="rate_limit"&&i.jsxs(i.Fragment,{children:[i.jsx("strong",{children:"Rate Limited."})," Switch to a different account or wait for quota reset.",a.model&&i.jsxs(i.Fragment,{children:[" ","Model ",i.jsx("code",{className:"font-mono text-[11px]",children:a.model})," has exhausted quota."]})]}),a.errorType==="auth"&&"Authentication failed. Re-authenticate via CLIProxy Settings or check API key.",a.errorType==="not_found"&&"Endpoint not found. This endpoint may not exist on this provider.",a.errorType==="server"&&"Server error from upstream. Retry later or check provider status page.",a.errorType==="timeout"&&"Request timed out. Check network connection or increase timeout settings."]})]})]})})}function $j({headers:a}){const s=Object.entries(a);return s.length===0?i.jsx("div",{className:"p-4 text-xs text-muted-foreground",children:"No headers available"}):i.jsx(gl,{className:"h-full",children:i.jsx("div",{className:"p-4 space-y-1",children:s.map(([r,u])=>i.jsxs("div",{className:"flex gap-3 text-xs font-mono py-1.5 border-b border-border/30 last:border-0",children:[i.jsxs("span",{className:"text-muted-foreground shrink-0 min-w-[140px]",children:[r,":"]}),i.jsx("span",{className:"break-all",children:u})]},r))})})}function Zp({content:a,label:s}){if(!a||a.trim()==="")return i.jsxs("div",{className:"p-4 text-xs text-muted-foreground",children:["No ",s.toLowerCase()," body"]});let r=a,u=!1;try{const d=JSON.parse(a);r=JSON.stringify(d,null,2),u=!0}catch{}return i.jsx(gl,{className:"h-full",children:i.jsx("pre",{className:G("p-4 text-xs font-mono whitespace-pre-wrap break-all leading-relaxed",u?"text-emerald-700 dark:text-green-400":"text-zinc-700 dark:text-muted-foreground"),children:r})})}function Jj({content:a}){return i.jsx(gl,{className:"h-full",children:i.jsx("pre",{className:"p-4 text-xs font-mono text-zinc-700 dark:text-muted-foreground whitespace-pre-wrap break-all leading-relaxed",children:a})})}function Pj({name:a,absolutePath:s}){const[r,u]=y.useState("overview"),{data:d,isLoading:f,error:m}=_N(a),p=y.useMemo(()=>d?Dj(d):null,[d]);return a?f?i.jsxs("div",{className:"flex-1 p-6 space-y-3",children:[i.jsx(Le,{className:"h-5 w-full"}),i.jsx(Le,{className:"h-5 w-3/4"}),i.jsx(Le,{className:"h-5 w-5/6"}),i.jsx(Le,{className:"h-5 w-2/3"})]}):m||!d||!p?i.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:i.jsx("p",{className:"text-sm",children:"Failed to load log content"})}):i.jsxs("div",{className:"flex-1 flex flex-col min-w-0 h-full",children:[i.jsxs("div",{className:"px-4 py-3 border-b border-border bg-muted/30 flex items-center justify-between gap-3 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[i.jsx(Sx,{code:p.statusCode}),i.jsxs("span",{className:"text-xs font-semibold truncate text-foreground",children:[p.provider,"/",p.endpoint||"unknown"]}),a&&i.jsx(Xp,{value:s||a,label:"Copy absolute path",size:"icon-sm",className:"ml-1 text-muted-foreground hover:text-foreground opacity-50 hover:opacity-100 transition-opacity"})]}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[d&&i.jsx(Xp,{value:d,label:"Copy raw log content",variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-foreground"}),i.jsx("span",{className:"text-[10px] text-muted-foreground font-mono bg-muted px-1.5 py-0.5 rounded border border-border/50",children:p.method})]})]}),i.jsxs("div",{className:"px-3 py-2 border-b border-border flex items-center gap-1 bg-muted/10 shrink-0 overflow-x-auto",children:[i.jsx(ri,{active:r==="overview",onClick:()=>u("overview"),icon:Fr,children:"Overview"}),i.jsx(ri,{active:r==="headers",onClick:()=>u("headers"),icon:xb,children:"Headers"}),i.jsx(ri,{active:r==="request",onClick:()=>u("request"),icon:yb,children:"Request"}),i.jsx(ri,{active:r==="response",onClick:()=>u("response"),icon:vb,children:"Response"}),i.jsx(ri,{active:r==="raw",onClick:()=>u("raw"),icon:bb,children:"Raw"})]}),i.jsxs("div",{className:"flex-1 overflow-hidden bg-card/30",children:[r==="overview"&&i.jsx(Wj,{parsed:p}),r==="headers"&&i.jsx($j,{headers:p.requestHeaders}),r==="request"&&i.jsx(Zp,{content:p.requestBody,label:"Request"}),r==="response"&&i.jsx(Zp,{content:p.responseBody,label:"Response"}),r==="raw"&&i.jsx(Jj,{content:d})]})]}):i.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:i.jsxs("div",{className:"text-center space-y-3",children:[i.jsx(gb,{className:"w-10 h-10 mx-auto opacity-40"}),i.jsx("p",{className:"text-sm",children:"Select a log to view details"})]})})}function Ij(){const{data:a,isLoading:s}=TN(),{data:r,isLoading:u,error:d}=DN(a?.running??!1),[f,m]=y.useState(500),[p,x]=y.useState(!1),b=y.useRef(null),C=y.useRef(null),v=()=>{C.current&&(clearInterval(C.current),C.current=null)};y.useEffect(()=>{if(!p)return;const B=k=>{const j=b.current;if(!j)return;const Z=j.getBoundingClientRect().top+window.scrollY,ee=k.pageY-Z;m(Math.max(300,ee));const be=window.innerHeight-k.clientY,ue=15;v(),be<50?C.current=setInterval(()=>{window.scrollBy(0,ue)},16):k.clientY<50&&(C.current=setInterval(()=>{window.scrollBy(0,-ue)},16))},L=()=>{x(!1),v(),document.body.style.cursor="default",document.body.style.userSelect="auto"};return document.addEventListener("mousemove",B),document.addEventListener("mouseup",L),document.body.style.cursor="row-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",L),document.body.style.cursor="default",document.body.style.userSelect="auto",v()}},[p]);const S=B=>{B.preventDefault(),x(!0)},M=y.useMemo(()=>r?.[0]?.name??null,[r]),[O,U]=y.useState(null),_=O??M,T=y.useMemo(()=>!_||!r?void 0:r.find(L=>L.name===_)?.absolutePath,[_,r]);if(s||!a?.running)return null;if(u)return i.jsxs("div",{className:"rounded-xl border border-border overflow-hidden font-mono text-sm bg-card/50 dark:bg-zinc-900/60 backdrop-blur-sm h-[500px]",children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[i.jsx(Le,{className:"h-4 w-32"}),i.jsx(Le,{className:"h-4 w-20"})]}),i.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(B=>i.jsx(Le,{className:"h-12 w-full rounded-lg"},B))})]});if(!r||r.length===0)return null;const K=r.length;return i.jsxs("div",{ref:b,className:"rounded-xl border border-border overflow-hidden font-mono text-sm text-foreground bg-card/50 dark:bg-zinc-900/60 backdrop-blur-sm flex flex-col shadow-sm transition-[height] duration-0 ease-linear relative group/container",style:{height:f},children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-gradient-to-r from-amber-500/10 via-transparent to-transparent dark:from-amber-500/15 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2.5",children:[i.jsx(ma,{className:"w-4 h-4 text-amber-500"}),i.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Error Logs"}),i.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:[K," failed request",K!==1?"s":""]})]}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[i.jsx(Sb,{className:"w-3.5 h-3.5"}),i.jsx("span",{children:"CLIProxy Diagnostics"})]})]}),i.jsx("div",{className:"flex-1 min-h-0",children:i.jsxs(pd,{direction:"horizontal",children:[i.jsx(xi,{defaultSize:30,minSize:20,maxSize:50,className:"flex flex-col min-w-0",children:i.jsxs(gl,{className:"h-full",children:[i.jsx("div",{className:"divide-y divide-border/50",children:r.slice(0,50).map(B=>i.jsx(Zj,{name:B.name,size:B.size,modified:B.modified,isSelected:_===B.name,onClick:()=>U(B.name),statusCode:B.statusCode,model:B.model},B.name))}),r.length>50&&i.jsxs("div",{className:"px-3 py-3 text-center text-[10px] text-muted-foreground border-t border-border/50",children:["Showing 50 of ",r.length," logs"]})]})}),i.jsxs(gd,{className:"w-[1px] bg-border hover:bg-primary/50 transition-colors flex items-center justify-center group relative z-10 w-2 -ml-1 flex items-center justify-center outline-none",children:[i.jsx("div",{className:"w-[1px] h-full bg-border group-hover:bg-primary/50 transition-colors"}),i.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-4 h-8 rounded-sm flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-muted border border-border",children:i.jsx(Ir,{className:"h-4 w-4 text-muted-foreground"})})]}),i.jsx(xi,{className:"flex flex-col min-w-0 bg-background/50",children:i.jsx(Pj,{name:_,absolutePath:T})})]})}),d?i.jsx("div",{className:"px-4 py-2 border-t border-border text-xs text-destructive bg-destructive/5 shrink-0",children:d.message}):i.jsx("div",{className:"h-2 bg-border/10 border-t border-border/30 hover:bg-primary/10 transition-colors cursor-row-resize flex items-center justify-center group/handle shrink-0",onMouseDown:S,children:i.jsx(Nb,{className:"w-8 h-3 text-border group-hover:text-primary/50 transition-colors"})})]})}const Fj=to("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",warning:"border-yellow-200 bg-yellow-50 text-yellow-900 dark:border-yellow-900/50 dark:bg-yellow-900/20 dark:text-yellow-200 [&>svg]:text-yellow-600 dark:[&>svg]:text-yellow-500",info:"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-900/50 dark:bg-blue-900/20 dark:text-blue-200 [&>svg]:text-blue-600 dark:[&>svg]:text-blue-500",success:"border-green-200 bg-green-50 text-green-900 dark:border-green-900/50 dark:bg-green-900/20 dark:text-green-200 [&>svg]:text-green-600 dark:[&>svg]:text-green-500"}},defaultVariants:{variant:"default"}}),xd=y.forwardRef(({className:a,variant:s,...r},u)=>i.jsx("div",{ref:u,role:"alert",className:G(Fj({variant:s}),a),...r}));xd.displayName="Alert";const Nx=y.forwardRef(({className:a,...s},r)=>i.jsx("h5",{ref:r,className:G("mb-1 font-medium leading-none tracking-tight",a),...s}));Nx.displayName="AlertTitle";const yd=y.forwardRef(({className:a,...s},r)=>i.jsx("div",{ref:r,className:G("text-sm [&_p]:leading-relaxed",a),...s}));yd.displayName="AlertDescription";function e2(){return zt({queryKey:["overview"],queryFn:async()=>(await fetch("/api/overview")).json()})}function t2(){return zt({queryKey:["shared","summary"],queryFn:async()=>(await fetch("/api/shared/summary")).json()})}function DE(a){return zt({queryKey:["shared",a],queryFn:async()=>(await fetch(`/api/shared/${a}`)).json()})}const n2={ok:"success",warning:"warning",error:"error"},a2={default:{iconBg:"bg-muted",iconColor:"text-muted-foreground"},success:{iconBg:"bg-green-600/15",iconColor:"text-green-700 dark:text-green-500"},warning:{iconBg:"bg-amber-500/15",iconColor:"text-amber-700 dark:text-amber-400"},error:{iconBg:"bg-red-600/15",iconColor:"text-red-700 dark:text-red-500"},accent:{iconBg:"bg-accent/15",iconColor:"text-accent"}};function qr({title:a,value:s,icon:r,variant:u="default",onClick:d}){const f=a2[u];return i.jsxs("button",{onClick:d,className:G("flex items-center gap-3 px-4 py-2.5 rounded-lg border bg-card/50","transition-all hover:bg-card hover:shadow-sm hover:-translate-y-0.5","active:scale-[0.98]"),children:[i.jsx("div",{className:G("flex items-center justify-center w-9 h-9 rounded-md",f.iconBg),children:i.jsx(r,{className:G("w-4 h-4",f.iconColor)})}),i.jsxs("div",{className:"text-left",children:[i.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:a}),i.jsx("p",{className:G("text-lg font-bold font-mono leading-tight",f.iconColor),children:s})]})]})}function l2(){const a=Wc(),{data:s,isLoading:r}=e2(),{data:u,isLoading:d}=t2();if(r||d)return i.jsxs("div",{className:"p-6 space-y-6",children:[i.jsxs("div",{className:"rounded-xl border p-6 flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(Le,{className:"h-12 w-12 rounded-lg"}),i.jsxs("div",{children:[i.jsx(Le,{className:"h-7 w-[180px] mb-2"}),i.jsx(Le,{className:"h-4 w-[220px]"})]})]}),i.jsx("div",{className:"flex items-center gap-3",children:[1,2,3,4].map(m=>i.jsx(Le,{className:"h-14 w-28 rounded-lg"},m))})]}),i.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[i.jsxs("div",{className:"px-4 py-2.5 border-b flex items-center justify-between",children:[i.jsx(Le,{className:"h-4 w-32"}),i.jsx(Le,{className:"h-4 w-20"})]}),i.jsx("div",{className:"px-4 py-3 border-b",children:i.jsx(Le,{className:"h-2 w-full rounded-full"})}),[1,2,3].map(m=>i.jsxs("div",{className:"px-4 py-2.5 flex items-center gap-3 border-b last:border-b-0",children:[i.jsx(Le,{className:"w-2.5 h-2.5 rounded-full"}),i.jsx(Le,{className:"h-4 flex-1"}),i.jsx(Le,{className:"h-1.5 w-24 rounded-full"}),i.jsx(Le,{className:"h-4 w-16"})]},m))]})]});const f=s?.health?n2[s.health.status]:void 0;return i.jsxs("div",{className:"p-6 space-y-6",children:[i.jsxs("div",{className:"relative overflow-hidden rounded-xl border bg-gradient-to-br from-background via-background to-muted/30",children:[i.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",children:i.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)",backgroundSize:"24px 24px"}})}),i.jsxs("div",{className:"relative p-6 flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4",children:[i.jsx(oN,{version:s?.version}),i.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[i.jsx(qr,{title:"Profiles",value:s?.profiles??0,icon:Ug,variant:"accent",onClick:()=>a("/providers")}),i.jsx(qr,{title:"CLIProxy",value:s?.cliproxy??0,icon:qg,variant:"accent",onClick:()=>a("/cliproxy")}),i.jsx(qr,{title:"Accounts",value:s?.accounts??0,icon:Lg,variant:"default",onClick:()=>a("/accounts")}),i.jsx(qr,{title:"Health",value:s?.health?`${s.health.passed}/${s.health.total}`:"-",icon:hi,variant:f,onClick:()=>a("/health")})]})]})]}),u?.symlinkStatus&&!u.symlinkStatus.valid&&i.jsxs(xd,{variant:"warning",children:[i.jsx(ma,{className:"h-4 w-4"}),i.jsx(Nx,{children:"Configuration Required"}),i.jsx(yd,{children:u.symlinkStatus.message})]}),i.jsx(nj,{}),i.jsx(Ij,{})]})}const jx=Mv,vd=y.forwardRef(({className:a,...s},r)=>i.jsx(wg,{ref:r,className:G("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",a),...s}));vd.displayName=wg.displayName;const Xr=y.forwardRef(({className:a,...s},r)=>i.jsx(Cg,{ref:r,className:G("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",a),...s}));Xr.displayName=Cg.displayName;const Qc=y.forwardRef(({className:a,...s},r)=>i.jsx(Eg,{ref:r,className:G("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a),...s}));Qc.displayName=Eg.displayName;function yn({className:a,...s}){return i.jsx(Tv,{"data-slot":"label",className:G("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",a),...s})}const bd="ccs:openrouter-models",s2=1440*60*1e3,wx="1";function Vc(a){const s=parseFloat(a);return isNaN(s)||s===0?0:s*1e6}function Wp(a){const s=Vc(a);return s===0?"Free":s<.01?"<$0.01":s<1?`$${s.toFixed(2)}`:`$${s.toFixed(s<10?2:0)}`}function i2(a){const s=Wp(a.prompt),r=Wp(a.completion);return s==="Free"&&r==="Free"?"Free":`${s}/${r}`}function r2(a){const s=a.id.toLowerCase();return s.startsWith("anthropic/")?"anthropic":s.startsWith("openai/")?"openai":s.startsWith("google/")?"google":s.startsWith("meta-llama/")||s.startsWith("meta/")?"meta":s.startsWith("mistralai/")?"mistral":s.includes(":free")||s.includes("qwen")||s.includes("deepseek")?"opensource":"other"}function o2(a){return{...a,category:r2(a),pricePerMillionPrompt:Vc(a.pricing.prompt),pricePerMillionCompletion:Vc(a.pricing.completion),isFree:a.pricing.prompt==="0"&&a.pricing.completion==="0",isExacto:a.id.includes(":exacto")}}function u2(a,s,r){const u=s.toLowerCase().trim();return a.filter(d=>r?.category&&d.category!==r.category||r?.freeOnly&&!d.isFree||r?.minContext&&d.context_length<r.minContext?!1:u?d.id.toLowerCase().includes(u)||d.name.toLowerCase().includes(u)||d.description?.toLowerCase().includes(u):!0)}function _E(a){return[...a].sort((s,r)=>{if(s.isFree&&!r.isFree)return-1;if(!s.isFree&&r.isFree)return 1;if(!s.isFree&&!r.isFree){if(s.isExacto&&!r.isExacto)return-1;if(!s.isExacto&&r.isExacto)return 1}return s.name.localeCompare(r.name)})}function c2(){try{const a=localStorage.getItem(bd);if(!a)return null;const s=JSON.parse(a);return s.version!==wx||Date.now()-s.fetchedAt>s2?null:s.models}catch{return null}}function d2(a){try{localStorage.setItem(bd,JSON.stringify({models:a,fetchedAt:Date.now(),version:wx}))}catch{}}function f2(){localStorage.removeItem(bd)}function kE(a,s){const[r]=a.split("/");if(!r)return{};const u=s.filter(m=>m.id.startsWith(`${r}/`));if(u.length===0)return{};const d=[...u].sort((m,p)=>p.pricePerMillionPrompt-m.pricePerMillionPrompt),f=Math.ceil(d.length/3);return{opus:d[0]?.id,sonnet:d[Math.min(f,d.length-1)]?.id,haiku:d[d.length-1]?.id}}function m2(a){return a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${Math.round(a/1e3)}K`:String(a)}const RE={anthropic:"Anthropic (Claude)",openai:"OpenAI (GPT)",google:"Google (Gemini)",meta:"Meta (Llama)",mistral:"Mistral",opensource:"Open Source",other:"Other"},h2={anthropic:["anthropic/"],openai:["openai/"],google:["google/"],meta:["meta-llama/","meta/"],mistral:["mistralai/"],opensource:["deepseek/","qwen/","cohere/"],other:[]};function p2(a,s=2){const r=[],u=["anthropic","openai","google","meta","mistral","opensource"];for(const d of u){const f=h2[d];if(f.length===0)continue;const p=[...a.filter(x=>f.some(b=>x.id.toLowerCase().startsWith(b)))].sort((x,b)=>(b.created??0)-(x.created??0));r.push(...p.slice(0,s))}return r.sort((d,f)=>(f.created??0)-(d.created??0))}function g2(a){const r=Date.now()/1e3-a;return r<86400?"Today":r<172800?"Yesterday":r<604800?`${Math.floor(r/86400)}d ago`:r<2592e3?`${Math.floor(r/604800)}w ago`:r<31536e3?`${Math.floor(r/2592e3)}mo ago`:`${Math.floor(r/31536e3)}y ago`}const x2="https://openrouter.ai/api/v1/models",Cx=["openrouter-models"],$p=1440*60*1e3;async function y2(){const a=await fetch(x2);if(!a.ok)throw new Error(`Failed to fetch OpenRouter models: ${a.status}`);const r=(await a.json()).data;return d2(r),r}function Ex(){return zt({queryKey:Cx,queryFn:y2,staleTime:$p,gcTime:$p,initialData:()=>c2()??void 0,refetchOnWindowFocus:!1})}function v2(){const a=Ex(),s=(a.data??[]).map(o2);return{...a,models:s}}function UE(){const a=ut();return()=>(f2(),a.invalidateQueries({queryKey:Cx}))}function qE(){const{data:a,isLoading:s,isError:r}=Ex();return{isReady:!!a&&a.length>0,isLoading:s,isError:r,modelCount:a?.length??0}}function Sd({profileEnv:a={}}){const[s,r]=y.useState(null),[u,d]=y.useState(!0),[f,m]=y.useState(!1);y.useEffect(()=>{p()},[]);const p=async()=>{try{d(!0);const S=await fetch("/api/global-env");if(!S.ok)throw new Error("Failed to load");const M=await S.json();r(M)}catch{r(null)}finally{d(!1)}};if(u||!s?.enabled)return null;const x=s.env||{},b=Object.keys(x);if(b.length===0)return null;const C=b.filter(S=>!(S in a)),v=b.filter(S=>S in a);return i.jsxs("div",{className:"border-t bg-muted/20",children:[i.jsxs("button",{onClick:()=>m(!f),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-muted/30 transition-colors",children:[i.jsx(Fr,{className:"w-4 h-4 text-blue-500"}),i.jsxs("span",{className:"text-xs text-muted-foreground flex-1 text-left",children:[i.jsx("span",{className:"font-medium text-foreground",children:C.length})," global env var",C.length!==1?"s":""," will be injected at runtime",v.length>0&&i.jsxs("span",{className:"text-amber-600 dark:text-amber-400 ml-1",children:["(",v.length," overridden by profile)"]})]}),f?i.jsx(Pc,{className:"w-4 h-4 text-muted-foreground"}):i.jsx(eo,{className:"w-4 h-4 text-muted-foreground"})]}),f&&i.jsxs("div",{className:"px-4 pb-3 space-y-2",children:[C.length>0&&i.jsx("div",{className:"space-y-1",children:C.map(S=>i.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono bg-green-500/10 text-green-700 dark:text-green-400 px-2 py-1 rounded",children:[i.jsx("span",{className:"text-green-500",children:"+"}),i.jsxs("span",{className:"truncate",children:[S,"=",x[S]]})]},S))}),v.length>0&&i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:"Skipped (profile already defines):"}),v.map(S=>i.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono bg-amber-500/10 text-amber-700 dark:text-amber-400 px-2 py-1 rounded",children:[i.jsx("span",{className:"text-amber-500",children:"~"}),i.jsx("span",{className:"truncate",children:S})]},S))]}),i.jsx("div",{className:"pt-2 border-t border-border/50",children:i.jsx(ot,{variant:"ghost",size:"sm",asChild:!0,className:"h-7 text-xs gap-1.5 -ml-2",children:i.jsxs(Bc,{to:"/settings?tab=globalenv",children:[i.jsx(Ic,{className:"w-3.5 h-3.5"}),"Configure in Settings",i.jsx(Yg,{className:"w-3 h-3 opacity-50"})]})})})]})]})}const b2=y.lazy(()=>St(()=>Promise.resolve().then(()=>Nd),void 0).then(a=>({default:a.CodeEditor})));function BE({rawJsonContent:a,isRawJsonValid:s,rawJsonEdits:r,settings:u,onChange:d,missingRequiredFields:f=[]}){const m=f.length>0;return i.jsx(y.Suspense,{fallback:i.jsxs("div",{className:"flex items-center justify-center h-full",children:[i.jsx(En,{className:"w-6 h-6 animate-spin text-muted-foreground"}),i.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading editor..."})]}),children:i.jsxs("div",{className:"h-full flex flex-col",children:[!s&&r!==null&&i.jsxs("div",{className:"mb-2 px-3 py-2 bg-destructive/10 text-destructive text-sm rounded-md flex items-center gap-2 mx-6 mt-4 shrink-0",children:[i.jsx(os,{className:"w-4 h-4"}),"Invalid JSON syntax"]}),s&&m&&i.jsxs("div",{className:"mb-2 px-3 py-2 bg-warning/10 text-warning-foreground text-sm rounded-md flex items-start gap-2 mx-6 mt-4 shrink-0 border border-warning/20",children:[i.jsx(ma,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Missing required fields:"})," ",i.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:f.join(", ")}),i.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"These fields will use default values at runtime."})]})]}),i.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-4 pt-4",children:i.jsx("div",{className:"h-full border rounded-md overflow-hidden bg-background",children:i.jsx(b2,{value:a,onChange:d,language:"json",minHeight:"100%"})})}),i.jsx("div",{className:"mx-6 mb-4",children:i.jsx("div",{className:"border rounded-md overflow-hidden",children:i.jsx(Sd,{profileEnv:u?.env})})})]})})}function Jp(a,s){try{var r=a()}catch(u){return s(u)}return r&&r.then?r.then(void 0,s):r}function S2(a,s){for(var r={};a.length;){var u=a[0],d=u.code,f=u.message,m=u.path.join(".");if(!r[m])if("unionErrors"in u){var p=u.unionErrors[0].errors[0];r[m]={message:p.message,type:p.code}}else r[m]={message:f,type:d};if("unionErrors"in u&&u.unionErrors.forEach(function(C){return C.errors.forEach(function(v){return a.push(v)})}),s){var x=r[m].types,b=x&&x[u.code];r[m]=Gg(m,s,r,d,b?[].concat(b,u.message):u.message)}a.shift()}return r}function N2(a,s){for(var r={};a.length;){var u=a[0],d=u.code,f=u.message,m=u.path.join(".");if(!r[m])if(u.code==="invalid_union"&&u.errors.length>0){var p=u.errors[0][0];r[m]={message:p.message,type:p.code}}else r[m]={message:f,type:d};if(u.code==="invalid_union"&&u.errors.forEach(function(C){return C.forEach(function(v){return a.push(v)})}),s){var x=r[m].types,b=x&&x[u.code];r[m]=Gg(m,s,r,d,b?[].concat(b,u.message):u.message)}a.shift()}return r}function j2(a,s,r){if(r===void 0&&(r={}),(function(u){return"_def"in u&&typeof u._def=="object"&&"typeName"in u._def})(a))return function(u,d,f){try{return Promise.resolve(Jp(function(){return Promise.resolve(a[r.mode==="sync"?"parse":"parseAsync"](u,s)).then(function(m){return f.shouldUseNativeValidation&&jp({},f),{errors:{},values:r.raw?Object.assign({},u):m}})},function(m){if((function(p){return Array.isArray(p?.issues)})(m))return{values:{},errors:wp(S2(m.errors,!f.shouldUseNativeValidation&&f.criteriaMode==="all"),f)};throw m}))}catch(m){return Promise.reject(m)}};if((function(u){return"_zod"in u&&typeof u._zod=="object"})(a))return function(u,d,f){try{return Promise.resolve(Jp(function(){return Promise.resolve((r.mode==="sync"?uS:cS)(a,u,s)).then(function(m){return f.shouldUseNativeValidation&&jp({},f),{errors:{},values:r.raw?Object.assign({},u):m}})},function(m){if((function(p){return p instanceof dS})(m))return{values:{},errors:wp(N2(m.issues,!f.shouldUseNativeValidation&&f.criteriaMode==="all"),f)};throw m}))}catch(m){return Promise.reject(m)}};throw new Error("Invalid input: not a Zod schema")}function HE(){return zt({queryKey:["profiles"],queryFn:()=>Ze.profiles.list()})}function w2(){const a=ut();return mt({mutationFn:s=>Ze.profiles.create(s),onSuccess:()=>{a.invalidateQueries({queryKey:["profiles"]}),le.success("Profile created successfully")},onError:s=>{le.error(s.message)}})}function LE(){const a=ut();return mt({mutationFn:s=>Ze.profiles.delete(s),onSuccess:()=>{a.invalidateQueries({queryKey:["profiles"]}),le.success("Profile deleted successfully")},onError:s=>{le.error(s.message)}})}const C2="https://openrouter.ai/api",Yr=[{id:"openrouter",name:"OpenRouter",description:"349+ models from OpenAI, Anthropic, Google, Meta",baseUrl:C2,defaultProfileName:"openrouter",badge:"349+ models",featured:!0,icon:"/icons/openrouter.svg",defaultModel:"anthropic/claude-opus-4.5",requiresApiKey:!0,apiKeyPlaceholder:"sk-or-...",apiKeyHint:"Get your API key at openrouter.ai/keys",category:"recommended"},{id:"ollama",name:"Ollama (Local)",description:"Local open-source models via Ollama (32K+ context)",baseUrl:"http://localhost:11434",defaultProfileName:"ollama",badge:"Local",featured:!0,icon:"/icons/ollama.svg",defaultModel:"qwen3-coder",requiresApiKey:!1,apiKeyPlaceholder:"",apiKeyHint:"No API key required for local Ollama",category:"recommended"},{id:"glm",name:"GLM",description:"Claude via Z.AI",baseUrl:"https://api.z.ai/api/anthropic",defaultProfileName:"glm",badge:"Z.AI",icon:"/icons/zai.svg",defaultModel:"glm-5",requiresApiKey:!0,apiKeyPlaceholder:"ghp_...",apiKeyHint:"Get your API key from Z.AI",category:"alternative"},{id:"glmt",name:"GLMT",description:"GLM with Thinking mode support",baseUrl:"https://api.z.ai/api/coding/paas/v4/chat/completions",defaultProfileName:"glmt",badge:"Thinking",icon:"/icons/zai.svg",defaultModel:"glm-5",requiresApiKey:!0,apiKeyPlaceholder:"ghp_...",apiKeyHint:"Same API key as GLM",category:"alternative"},{id:"km",name:"Kimi",description:"Moonshot AI - Fast reasoning model",baseUrl:"https://api.kimi.com/coding/",defaultProfileName:"km",badge:"Reasoning",icon:"/icons/kimi.svg",defaultModel:"kimi-k2-thinking-turbo",requiresApiKey:!0,apiKeyPlaceholder:"sk-...",apiKeyHint:"Get your API key from Moonshot AI",category:"alternative",alwaysThinkingEnabled:!0},{id:"foundry",name:"Azure Foundry",description:"Claude via Microsoft Azure AI Foundry",baseUrl:"https://<your-resource>.services.ai.azure.com/api/anthropic",defaultProfileName:"foundry",badge:"Azure",icon:"/icons/azure.svg",defaultModel:"claude-sonnet-4-5",requiresApiKey:!0,apiKeyPlaceholder:"YOUR_AZURE_API_KEY",apiKeyHint:"Create resource at ai.azure.com, get API key from Keys tab",category:"alternative"},{id:"mm",name:"Minimax",description:"M2.1/M2.1-lightning/M2 - multilang coding (1M context)",baseUrl:"https://api.minimax.io/anthropic",defaultProfileName:"mm",badge:"1M context",icon:"/icons/minimax.svg",defaultModel:"MiniMax-M2.1",requiresApiKey:!0,apiKeyPlaceholder:"YOUR_MINIMAX_API_KEY_HERE",apiKeyHint:"Get your API key at platform.minimax.io",category:"alternative"},{id:"deepseek",name:"DeepSeek",description:"V3.2 and R1 reasoning model (128K context)",baseUrl:"https://api.deepseek.com/anthropic",defaultProfileName:"deepseek",badge:"Reasoning",icon:"/icons/deepseek.svg",defaultModel:"deepseek-chat",requiresApiKey:!0,apiKeyPlaceholder:"sk-...",apiKeyHint:"Get your API key at platform.deepseek.com",category:"alternative"},{id:"qwen",name:"Qwen",description:"Alibaba Cloud - Qwen3 models (256K-1M context, thinking support)",baseUrl:"https://dashscope-intl.aliyuncs.com/apps/anthropic",defaultProfileName:"qwen",badge:"Alibaba",icon:"/assets/providers/qwen-color.svg",defaultModel:"qwen3-coder-plus",requiresApiKey:!0,apiKeyPlaceholder:"sk-...",apiKeyHint:"Get your API key from Alibaba Cloud Model Studio",category:"alternative"},{id:"ollama-cloud",name:"Ollama Cloud",description:"Ollama cloud models via direct API (glm-5:cloud, minimax-m2.1:cloud)",baseUrl:"https://ollama.com",defaultProfileName:"ollama-cloud",badge:"Cloud",icon:"/icons/ollama.svg",defaultModel:"glm-5:cloud",requiresApiKey:!0,apiKeyPlaceholder:"YOUR_OLLAMA_CLOUD_API_KEY",apiKeyHint:"Get your API key at ollama.com",category:"alternative"}];function Br(a){return Yr.filter(s=>s.category===a)}const E2=fS({name:cl().min(1,"Name is required").regex(/^[a-zA-Z][a-zA-Z0-9._-]*$/,"Must start with letter, only letters/numbers/.-_"),baseUrl:cl().url("Invalid URL format"),apiKey:cl(),model:cl().optional(),opusModel:cl().optional(),sonnetModel:cl().optional(),haikuModel:cl().optional()}),M2=["/chat/completions","/v1/messages","/messages","/completions"];function YE({open:a,onOpenChange:s,onSuccess:r,initialMode:u="openrouter"}){const d=w2(),[f,m]=y.useState("basic"),[p,x]=y.useState(null),[b,C]=y.useState(!1),[v,S]=y.useState("openrouter"),[M,O]=y.useState(""),{models:U}=v2(),{register:_,handleSubmit:T,formState:{errors:K},control:B,reset:L,setValue:k}=mS({resolver:j2(E2),defaultValues:{name:"",baseUrl:"",apiKey:"",model:"",opusModel:"",sonnetModel:"",haikuModel:""}}),j=hS({control:B,name:"baseUrl"}),H=y.useMemo(()=>!v||v==="custom"?null:Yr.find(P=>P.id===v),[v]),Z=y.useMemo(()=>M.trim()?[...u2(U,M)].sort((A,W)=>(W.created??0)-(A.created??0)).slice(0,20):p2(U,2),[U,M]);y.useEffect(()=>{if(a)if(L(),m("basic"),x(null),C(!1),O(""),u==="normal")S("custom"),setTimeout(()=>{k("name",""),k("baseUrl","")},0);else{S("openrouter");const P=Yr.find(A=>A.id==="openrouter");P&&setTimeout(()=>{k("name",P.defaultProfileName),k("baseUrl",P.baseUrl)},0)}},[a,L,k,u]);const ee=P=>{S(P);const A=Yr.find(W=>W.id===P);A?(k("name",A.defaultProfileName),k("baseUrl",A.baseUrl),A.defaultModel&&(k("model",A.defaultModel),k("opusModel",A.defaultModel),k("sonnetModel",A.defaultModel),k("haikuModel",A.defaultModel))):(k("name",""),k("baseUrl",""),k("model",""))},se=P=>{k("model",P.id),k("opusModel",P.id),k("sonnetModel",P.id),k("haikuModel",P.id),O(P.name),le.success(`Applied "${P.name}" to all model tiers`,{duration:2e3})};y.useEffect(()=>{if(j&&v==="custom"){const A=j.toLowerCase();for(const W of M2)if(A.endsWith(W)){const ie=j.replace(new RegExp(W+"$","i"),"");x(`URL ends with "${W}" - Claude appends this automatically. You likely want: ${ie}`);return}}x(null)},[j,v]);const be=async P=>{if(H?.requiresApiKey!==!1&&!P.apiKey){le.error("API key is required");return}const A={...P,apiKey:P.apiKey||""};try{await d.mutateAsync(A),le.success(`Profile "${A.name}" created`),r(A.name),s(!1)}catch(W){le.error(W.message||"Failed to create profile")}},ue=!!K.name||!!K.baseUrl||!!K.apiKey,Ye=!!K.model||!!K.opusModel||!!K.sonnetModel||!!K.haikuModel,Ne=v==="openrouter";return i.jsx(id,{open:a,onOpenChange:s,children:i.jsxs(rd,{className:"sm:max-w-[700px] p-0 gap-0 overflow-hidden max-h-[90vh] flex flex-col",children:[i.jsxs(od,{className:"p-6 pb-4 border-b",children:[i.jsxs(ud,{className:"flex items-center gap-2",children:[i.jsx(Sp,{className:"w-5 h-5 text-primary"}),"Create API Profile"]}),i.jsx(cd,{children:"Choose a provider or configure a custom API endpoint."})]}),i.jsxs("form",{onSubmit:T(be),className:"flex flex-col flex-1 min-h-0 overflow-hidden",children:[i.jsxs("div",{className:"px-6 py-3 border-b bg-muted/30 space-y-2",children:[i.jsxs("div",{children:[i.jsx(yn,{className:"text-xs text-muted-foreground mb-1.5 block",children:"Provider"}),i.jsxs("div",{className:"flex gap-2",children:[Br("recommended").map(P=>i.jsx(Pp,{preset:P,isSelected:v===P.id,onClick:()=>ee(P.id)},P.id)),i.jsxs("button",{type:"button",onClick:()=>ee("custom"),className:G("flex items-center gap-2 px-4 py-2 rounded-md border-2 transition-all text-sm font-medium",v==="custom"||Br("alternative").some(P=>P.id===v)?"border-primary bg-primary/10 text-primary dark:bg-primary/20":"border-dashed border-muted-foreground/40 hover:border-primary/50 hover:bg-muted/50 text-muted-foreground hover:text-foreground"),children:[i.jsx(Ic,{className:"w-4 h-4"}),i.jsx("span",{children:"Custom"})]})]})]}),(v==="custom"||Br("alternative").some(P=>P.id===v))&&i.jsxs("div",{className:"pt-3 mt-2 border-t border-dashed border-muted-foreground/30",children:[i.jsx(yn,{className:"text-xs font-medium text-foreground/70 mb-2 block",children:"Quick Templates"}),i.jsx("div",{className:"flex gap-2 flex-wrap",children:Br("alternative").map(P=>i.jsx(Pp,{preset:P,isSelected:v===P.id,onClick:()=>ee(P.id)},P.id))})]})]}),i.jsxs(jx,{value:f,onValueChange:m,className:"flex flex-col flex-1 min-h-0 overflow-hidden",children:[i.jsx("div",{className:"px-6 pt-4",children:i.jsxs(vd,{className:"grid w-full grid-cols-2",children:[i.jsxs(Xr,{value:"basic",className:"relative",children:["Basic Information",ue&&i.jsx("span",{className:"absolute top-1 right-2 w-2 h-2 rounded-full bg-destructive animate-pulse"})]}),i.jsxs(Xr,{value:"models",className:"relative",children:["Model Configuration",Ye&&i.jsx("span",{className:"absolute top-1 right-2 w-2 h-2 rounded-full bg-destructive animate-pulse"})]})]})}),i.jsxs(gl,{className:"flex-1 min-h-0",children:[i.jsxs(Qc,{value:"basic",className:"p-6 space-y-4 mt-0",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"name",children:["Profile Name ",i.jsx("span",{className:"text-destructive",children:"*"})]}),i.jsx(Rn,{id:"name",..._("name"),placeholder:"my-api",className:"font-mono"}),K.name?i.jsx("p",{className:"text-xs text-destructive",children:K.name.message}):i.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used in CLI:"," ",i.jsx("code",{className:"bg-muted px-1 rounded text-[10px]",children:'ccs my-api "prompt"'})]})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"baseUrl",children:["API Base URL ",i.jsx("span",{className:"text-destructive",children:"*"})]}),i.jsx(Rn,{id:"baseUrl",..._("baseUrl"),placeholder:"https://api.example.com/v1"}),K.baseUrl?i.jsx("p",{className:"text-xs text-destructive",children:K.baseUrl.message}):p?i.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-600 bg-yellow-50 dark:bg-yellow-900/20 p-2 rounded",children:[i.jsx(ma,{className:"w-4 h-4 shrink-0 mt-0.5"}),i.jsx("span",{children:p})]}):H?i.jsxs("p",{className:"text-xs text-muted-foreground",children:["Pre-filled from ",H.name,". You can customize if needed."]}):i.jsx("p",{className:"text-xs text-muted-foreground",children:"The endpoint that accepts OpenAI-compatible and Anthropic requests"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"apiKey",children:["API Key"," ",H?.requiresApiKey!==!1&&i.jsx("span",{className:"text-destructive",children:"*"}),H?.requiresApiKey===!1&&i.jsx("span",{className:"text-muted-foreground text-xs font-normal",children:"(optional)"})]}),i.jsxs("div",{className:"relative",children:[i.jsx(Rn,{id:"apiKey",type:b?"text":"password",..._("apiKey"),placeholder:H?.requiresApiKey===!1?"Optional - only if auth is enabled":H?.apiKeyPlaceholder??"sk-...",className:"pr-10"}),i.jsx(ot,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-9 w-9 text-muted-foreground hover:text-foreground",onClick:()=>C(!b),tabIndex:-1,children:b?i.jsx($r,{className:"h-4 w-4"}):i.jsx(Jr,{className:"h-4 w-4"})})]}),K.apiKey?i.jsx("p",{className:"text-xs text-destructive",children:K.apiKey.message}):H?.requiresApiKey===!1?i.jsx("p",{className:"text-xs text-muted-foreground",children:"Only needed if you have configured Ollama authentication"}):H?.apiKeyHint&&i.jsx("p",{className:"text-xs text-muted-foreground",children:H.apiKeyHint})]})]}),i.jsxs(Qc,{value:"models",className:"p-6 mt-0 space-y-4",children:[i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-blue-50 dark:bg-blue-950/20 text-blue-800 dark:text-blue-300 rounded-md text-sm border border-blue-100 dark:border-blue-900/30",children:[i.jsx(Fr,{className:"w-5 h-5 shrink-0 mt-0.5"}),i.jsxs("div",{children:[i.jsx("p",{className:"font-medium mb-1",children:"Model Mapping"}),i.jsx("p",{className:"text-xs opacity-90",children:"Map Claude Code tiers (Opus/Sonnet/Haiku) to models supported by your provider."})]})]}),Ne&&i.jsxs("div",{className:"space-y-2",children:[i.jsx(yn,{children:"Search Models"}),i.jsx(Rn,{value:M,onChange:P=>O(P.target.value),placeholder:"Type to search (e.g., opus, sonnet, gpt-4o)...",onKeyDown:P=>{P.key==="Enter"&&Z.length>0&&(P.preventDefault(),se(Z[0]))}}),i.jsx("div",{className:"border rounded-md max-h-48 overflow-y-auto",children:Z.length===0?i.jsx("p",{className:"text-sm text-muted-foreground p-3 text-center",children:M?`No models found for "${M}"`:"Loading models..."}):i.jsxs("div",{className:"p-1",children:[!M&&i.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 text-xs text-muted-foreground",children:[i.jsx(jb,{className:"w-3 h-3 text-accent"}),i.jsx("span",{children:"Newest Models"})]}),Z.map(P=>i.jsx(T2,{model:P,onClick:()=>se(P),showAge:!M},P.id))]})})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"model",children:["Default Model",i.jsx(Ya,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"ANTHROPIC_MODEL"})]}),i.jsx(Rn,{id:"model",..._("model"),placeholder:H?.defaultModel??"claude-sonnet-4",className:"font-mono text-sm"})]}),i.jsxs("div",{className:"grid gap-3 pt-2 border-t",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"sonnetModel",className:"text-sm",children:["Sonnet Mapping",i.jsx(Ya,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_SONNET"})]}),i.jsx(Rn,{id:"sonnetModel",..._("sonnetModel"),placeholder:"e.g. gpt-4o, claude-sonnet-4",className:"font-mono text-sm h-9"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"opusModel",className:"text-sm",children:["Opus Mapping",i.jsx(Ya,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_OPUS"})]}),i.jsx(Rn,{id:"opusModel",..._("opusModel"),placeholder:"e.g. o1, claude-opus-4.5",className:"font-mono text-sm h-9"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"haikuModel",className:"text-sm",children:["Haiku Mapping",i.jsx(Ya,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_HAIKU"})]}),i.jsx(Rn,{id:"haikuModel",..._("haikuModel"),placeholder:"e.g. gpt-4o-mini, claude-3.5-haiku",className:"font-mono text-sm h-9"})]})]})]})]})]}),i.jsxs(Z1,{className:"p-6 pt-4 border-t bg-muted/10",children:[i.jsx(ot,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),i.jsx(ot,{type:"submit",disabled:d.isPending,className:G(d.isPending&&"opacity-80"),children:d.isPending?i.jsxs(i.Fragment,{children:[i.jsx(En,{className:"w-4 h-4 mr-2 animate-spin"}),"Creating..."]}):i.jsxs(i.Fragment,{children:[i.jsx(Sp,{className:"w-4 h-4 mr-2"}),"Create Profile"]})})]})]})]})]})})}function Pp({preset:a,isSelected:s,onClick:r}){return i.jsxs("button",{type:"button",onClick:r,className:G("flex items-center gap-2 px-3 py-2 rounded-md border transition-all text-sm",s?a.featured?"border-accent bg-accent/10 dark:bg-accent/20 font-medium":"border-primary bg-primary/10 dark:bg-primary/20 font-medium":"border-muted-foreground/20 hover:border-muted-foreground/40 hover:bg-muted/50"),children:[a.icon?i.jsx("img",{src:a.icon,alt:"",className:"w-4 h-4"}):i.jsx("div",{className:"w-4 h-4 rounded-full bg-muted-foreground/20 flex items-center justify-center text-[9px] font-bold text-foreground/70",children:a.name.charAt(0)}),i.jsx("span",{className:"font-medium",children:a.name}),a.badge&&i.jsx(Ya,{variant:"secondary",className:"text-[10px] px-1.5 py-0 ml-0.5 bg-muted-foreground/10 text-muted-foreground",children:a.badge})]})}function T2({model:a,onClick:s,showAge:r}){return i.jsxs("button",{type:"button",onClick:s,className:"group flex w-full items-center justify-between rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",children:[i.jsx("span",{className:"flex-1 truncate",children:a.name}),i.jsxs("span",{className:"text-muted-foreground group-hover:text-accent-foreground/80 ml-2 flex items-center gap-2 text-xs",children:[r&&a.created&&i.jsx(Ya,{variant:"outline",className:"text-[10px] text-accent group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30",children:g2(a.created)}),a.isFree?i.jsx(Ya,{variant:"secondary",className:"text-xs group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground",children:"Free"}):i.jsx("span",{children:i2(a.pricing)}),i.jsx("span",{children:m2(a.context_length)})]})]})}function A2({className:a,...s}){return i.jsx("div",{"data-slot":"card",className:G("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",a),...s})}function O2({className:a,...s}){return i.jsx("div",{"data-slot":"card-header",className:G("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",a),...s})}function z2({className:a,...s}){return i.jsx("div",{"data-slot":"card-title",className:G("leading-none font-semibold",a),...s})}function D2({className:a,...s}){return i.jsx("div",{"data-slot":"card-description",className:G("text-muted-foreground text-sm",a),...s})}function _2({className:a,...s}){return i.jsx("div",{"data-slot":"card-content",className:G("px-6",a),...s})}const k2=["agy","claude","gemini","codex","qwen","kimi","iflow","kiro","ghcp"],GE=k2.map(a=>({id:a,name:Fg(a),description:fN(a)})),R2=["provider","auth","variant","success"];function KE(a){return a==="account"?1:R2.indexOf(a)}const QE=kv,VE=Uv,XE=Rv,U2=y.forwardRef(({className:a,children:s,...r},u)=>i.jsxs(Mg,{ref:u,className:G("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",a),...r,children:[s,i.jsx(Av,{asChild:!0,children:i.jsx(eo,{className:"h-4 w-4 opacity-50"})})]}));U2.displayName=Mg.displayName;const Mx=y.forwardRef(({className:a,...s},r)=>i.jsx(Tg,{ref:r,className:G("flex cursor-default items-center justify-center py-1",a),...s,children:i.jsx(Pc,{className:"h-4 w-4"})}));Mx.displayName=Tg.displayName;const Tx=y.forwardRef(({className:a,...s},r)=>i.jsx(Ag,{ref:r,className:G("flex cursor-default items-center justify-center py-1",a),...s,children:i.jsx(eo,{className:"h-4 w-4"})}));Tx.displayName=Ag.displayName;const q2=y.forwardRef(({className:a,children:s,position:r="popper",...u},d)=>i.jsx(Ov,{children:i.jsxs(Og,{ref:d,className:G("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",a),position:r,...u,children:[i.jsx(Mx,{}),i.jsx(zv,{className:G("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),i.jsx(Tx,{})]})}));q2.displayName=Og.displayName;const B2=y.forwardRef(({className:a,...s},r)=>i.jsx(zg,{ref:r,className:G("px-2 py-1.5 text-sm font-semibold",a),...s}));B2.displayName=zg.displayName;const H2=y.forwardRef(({className:a,children:s,...r},u)=>i.jsxs(Dg,{ref:u,className:G("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...r,children:[i.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(Dv,{children:i.jsx(rs,{className:"h-4 w-4"})})}),i.jsx(_v,{children:s})]}));H2.displayName=Dg.displayName;const L2=y.forwardRef(({className:a,...s},r)=>i.jsx(_g,{ref:r,className:G("-mx-1 my-1 h-px bg-muted",a),...s}));L2.displayName=_g.displayName;const Y2=y.lazy(()=>St(()=>Promise.resolve().then(()=>Nd),void 0).then(a=>({default:a.CodeEditor})));function ZE({rawJsonContent:a,isRawJsonValid:s,rawJsonEdits:r,onRawJsonChange:u,profileEnv:d,missingRequiredFields:f=[]}){const m=f.length>0;return i.jsx(y.Suspense,{fallback:i.jsxs("div",{className:"flex items-center justify-center h-full",children:[i.jsx(En,{className:"w-6 h-6 animate-spin text-muted-foreground"}),i.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading editor..."})]}),children:i.jsxs("div",{className:"h-full flex flex-col",children:[!s&&r!==null&&i.jsxs("div",{className:"mb-2 px-3 py-2 bg-destructive/10 text-destructive text-sm rounded-md flex items-center gap-2 mx-6 mt-4 shrink-0",children:[i.jsx(os,{className:"w-4 h-4"}),"Invalid JSON syntax"]}),s&&m&&i.jsxs("div",{className:"mb-2 px-3 py-2 bg-warning/10 text-warning-foreground text-sm rounded-md flex items-start gap-2 mx-6 mt-4 shrink-0 border border-warning/20",children:[i.jsx(ma,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Missing required fields:"})," ",i.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:f.join(", ")}),i.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Apply a preset from Model Config tab or add these fields manually. Without them, Claude Code will fail with 404 errors."})]})]}),i.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-4 pt-4",children:i.jsx("div",{className:"h-full border rounded-md overflow-hidden bg-background",children:i.jsx(Y2,{value:a,onChange:u,language:"json",minHeight:"100%"})})}),i.jsx("div",{className:"mx-6 mb-4",children:i.jsx("div",{className:"border rounded-md overflow-hidden",children:i.jsx(Sd,{profileEnv:d})})})]})})}const G2=y.forwardRef(({className:a,value:s=0,max:r=100,indicatorClassName:u,...d},f)=>{const m=Math.min(Math.max(s/r*100,0),100);return i.jsx("div",{ref:f,role:"progressbar","aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":s,className:G("relative h-2 w-full overflow-hidden rounded-full bg-secondary",a),...d,children:i.jsx("div",{className:G("h-full transition-all",u||"bg-primary"),style:{width:`${m}%`}})})});G2.displayName="Progress";var Kt={},Ip;function K2(){if(Ip)return Kt;Ip=1;var a=Kt&&Kt.__assign||function(){return a=Object.assign||function(k){for(var j,H=1,Z=arguments.length;H<Z;H++){j=arguments[H];for(var ee in j)Object.prototype.hasOwnProperty.call(j,ee)&&(k[ee]=j[ee])}return k},a.apply(this,arguments)},s=Kt&&Kt.__createBinding||(Object.create?(function(k,j,H,Z){Z===void 0&&(Z=H);var ee=Object.getOwnPropertyDescriptor(j,H);(!ee||("get"in ee?!j.__esModule:ee.writable||ee.configurable))&&(ee={enumerable:!0,get:function(){return j[H]}}),Object.defineProperty(k,Z,ee)}):(function(k,j,H,Z){Z===void 0&&(Z=H),k[Z]=j[H]})),r=Kt&&Kt.__setModuleDefault||(Object.create?(function(k,j){Object.defineProperty(k,"default",{enumerable:!0,value:j})}):function(k,j){k.default=j}),u=Kt&&Kt.__importStar||function(k){if(k&&k.__esModule)return k;var j={};if(k!=null)for(var H in k)H!=="default"&&Object.prototype.hasOwnProperty.call(k,H)&&s(j,k,H);return r(j,k),j},d=Kt&&Kt.__rest||function(k,j){var H={};for(var Z in k)Object.prototype.hasOwnProperty.call(k,Z)&&j.indexOf(Z)<0&&(H[Z]=k[Z]);if(k!=null&&typeof Object.getOwnPropertySymbols=="function")for(var ee=0,Z=Object.getOwnPropertySymbols(k);ee<Z.length;ee++)j.indexOf(Z[ee])<0&&Object.prototype.propertyIsEnumerable.call(k,Z[ee])&&(H[Z[ee]]=k[Z[ee]]);return H};Object.defineProperty(Kt,"__esModule",{value:!0});var f=u(Rg()),m=89,p=90,x=77,b=57,C=219,v=222,S=192,M=100,O=3e3,U=typeof window<"u"&&"navigator"in window&&/Win/i.test(navigator.platform),_=typeof window<"u"&&"navigator"in window&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),T="npm__react-simple-code-editor__textarea",K=`
15
15
  /**
16
16
  * Reset the text fill color so that placeholder is visible
17
17
  */
@@ -44,4 +44,4 @@ Error generating stack: `+l.message+`
44
44
  `).map(function(hs,ps){return ps>=Dt&&ps<=Kn?oe+hs:hs}).join(`
45
45
  `),selectionStart:xe&&/\S/.test(xe)?Me+oe.length:Me,selectionEnd:nt+oe.length*(Kn-Dt+1)})}else{var Nt=Me+oe.length;An({value:me.substring(0,Me)+oe+me.substring(nt),selectionStart:Nt,selectionEnd:Nt})}else if($.key==="Backspace"){var $t=Me!==nt,vn=me.substring(0,Me);if(vn.endsWith(oe)&&!$t){$.preventDefault();var Nt=Me-oe.length;An({value:me.substring(0,Me-oe.length)+me.substring(nt),selectionStart:Nt,selectionEnd:Nt})}}else if($.key==="Enter"){if(Me===nt){var fs=Wt(me,Me).pop(),Xa=fs?.match(/^\s+/);if(Xa?.[0]){$.preventDefault();var ms=`
46
46
  `+Xa[0],Nt=Me+ms.length;An({value:me.substring(0,Me)+ms+me.substring(nt),selectionStart:Nt,selectionEnd:Nt})}}}else if($.keyCode===b||$.keyCode===C||$.keyCode===v||$.keyCode===S){var rn=void 0;$.keyCode===b&&$.shiftKey?rn=["(",")"]:$.keyCode===C?$.shiftKey?rn=["{","}"]:rn=["[","]"]:$.keyCode===v?$.shiftKey?rn=['"','"']:rn=["'","'"]:$.keyCode===S&&!$.shiftKey&&(rn=["`","`"]),Me!==nt&&rn&&($.preventDefault(),An({value:me.substring(0,Me)+rn[0]+me.substring(Me,nt)+rn[1]+me.substring(nt),selectionStart:Me,selectionEnd:nt+2}))}else(_?$.metaKey&&$.keyCode===p:$.ctrlKey&&$.keyCode===p)&&!$.shiftKey&&!$.altKey?($.preventDefault(),xl()):(_?$.metaKey&&$.keyCode===p&&$.shiftKey:U?$.ctrlKey&&$.keyCode===m:$.ctrlKey&&$.keyCode===p&&$.shiftKey)&&!$.altKey?($.preventDefault(),cs()):$.keyCode===x&&$.ctrlKey&&(!_||$.shiftKey)&&($.preventDefault(),ha(function(Qn){return!Qn}))}},Gn=function($){var Ee=$.currentTarget,me=Ee.value,Me=Ee.selectionStart,nt=Ee.selectionEnd;Yn({value:me,selectionStart:Me,selectionEnd:nt},!0),J(me)};return f.useEffect(function(){Va()},[Va]),f.useImperativeHandle(H,function(){return{get session(){return{history:je.current}},set session($){je.current=$.history}}},[]),f.createElement("div",a({},Hn,{style:a(a({},L.container),yt)}),f.createElement("pre",a({className:fe,"aria-hidden":"true",style:a(a(a({},L.editor),L.highlight),Ln)},typeof ct=="string"?{dangerouslySetInnerHTML:{__html:ct+"<br />"}}:{children:ct})),f.createElement("textarea",{ref:function($){return Xt.current=$},style:a(a(a({},L.editor),L.textarea),Ln),className:T+(tt?" ".concat(tt):""),id:kt,value:Vt,onChange:Gn,onKeyDown:ds,onClick:ve,onKeyUp:X,onFocus:De,onBlur:ye,disabled:ee,form:se,maxLength:A,minLength:W,name:ie,placeholder:te,readOnly:Oe,required:Ge,autoFocus:Z,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"data-gramm":!1}),f.createElement("style",{dangerouslySetInnerHTML:{__html:K}}))}),L={container:{position:"relative",textAlign:"left",boxSizing:"border-box",padding:0,overflow:"hidden"},textarea:{position:"absolute",top:0,left:0,height:"100%",width:"100%",resize:"none",color:"inherit",overflow:"hidden",MozOsxFontSmoothing:"grayscale",WebkitFontSmoothing:"antialiased",WebkitTextFillColor:"transparent"},highlight:{position:"relative",pointerEvents:"none"},editor:{margin:0,border:0,background:"none",boxSizing:"inherit",display:"inherit",fontFamily:"inherit",fontSize:"inherit",fontStyle:"inherit",fontVariantLigatures:"inherit",fontWeight:"inherit",letterSpacing:"inherit",lineHeight:"inherit",tabSize:"inherit",textIndent:"inherit",textRendering:"inherit",textTransform:"inherit",whiteSpace:"pre-wrap",wordBreak:"keep-all",overflowWrap:"break-word"}};return Kt.default=B,Kt}var Q2=K2();const V2=Qv(Q2),X2=[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/_SECRET$/,/_SECRET_KEY$/,/^API_KEY$/,/^AUTH_TOKEN$/,/^SECRET$/,/_PASSWORD$/,/^PASSWORD$/,/_CREDENTIAL$/,/_PRIVATE_KEY$/];function Z2(a){return X2.some(s=>s.test(a))}function W2(a){if(!a.trim())return{valid:!0};try{return JSON.parse(a),{valid:!0}}catch(s){const u=s.message,d=u.match(/position (\d+)/);if(d){const f=parseInt(d[1],10),m=a.substring(0,f).split(`
47
- `);return{valid:!1,error:u,line:m.length}}return{valid:!1,error:u}}}function Ax({value:a,onChange:s,language:r="json",readonly:u=!1,className:d,minHeight:f="300px"}){const{isDark:m}=Jg(),[p,x]=y.useState(!1),[b,C]=y.useState(!0),v=y.useMemo(()=>r==="json"?W2(a):{valid:!0},[a,r]),S=y.useCallback(M=>i.jsx(pS,{theme:m?Cp.nightOwl:Cp.github,code:M,language:r,children:({tokens:O,getLineProps:U,getTokenProps:_})=>{let T=!1;return i.jsx(i.Fragment,{children:O.map((K,B)=>i.jsx("div",{...U({line:K}),className:G(v.line===B+1&&"bg-destructive/20"),children:K.map((L,k)=>{let j=!1;if(L.types.includes("property")){const Z=L.content.replace(/['"]/g,"");Z2(Z)?T=!0:T=!1}else(L.types.includes("string")||L.types.includes("number")||L.types.includes("boolean"))&&T?(j=!0,T=!1):L.types.includes("punctuation")&&L.content!==":"&&L.content!=="["&&L.content!=="{"&&(T=!1);const H=_({token:L});return j&&b&&(H.className=G(H.className,"blur-[3px] select-none opacity-70 transition-all duration-200")),i.jsx("span",{...H},k)})},B))})}}),[m,r,v.line,b]);return i.jsxs("div",{className:G("flex flex-col",d),children:[i.jsxs("div",{className:G("relative rounded-md border overflow-hidden","bg-muted/30",p&&"ring-2 ring-ring ring-offset-2 ring-offset-background",u&&"opacity-70 cursor-not-allowed",!v.valid&&"border-destructive"),style:{minHeight:f},children:[i.jsx(V2,{value:a,onValueChange:u?()=>{}:s,highlight:S,padding:12,disabled:u,onFocus:()=>x(!0),onBlur:()=>x(!1),textareaClassName:G("focus:outline-none font-mono text-sm",u&&"cursor-not-allowed"),preClassName:"font-mono text-sm",style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:"0.875rem",minHeight:f}},m?"dark-editor":"light-editor"),i.jsx("div",{className:"absolute top-2 right-2 z-10 opacity-50 hover:opacity-100 transition-opacity",children:i.jsx(ot,{variant:"ghost",size:"icon",className:"h-6 w-6 bg-background/50 hover:bg-background border shadow-sm rounded-full",onClick:()=>C(!b),title:b?"Reveal sensitive values":"Mask sensitive values",children:b?i.jsx(Jr,{className:"h-3 w-3"}):i.jsx($r,{className:"h-3 w-3"})})})]}),i.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs",children:[v.valid?i.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[i.jsx(Pr,{className:"w-3 h-3 text-green-500"}),"Valid ",r.toUpperCase()]}):i.jsxs("span",{className:"flex items-center gap-1 text-destructive",children:[i.jsx(Fc,{className:"w-3 h-3"}),v.error,v.line&&` (line ${v.line})`]}),u&&i.jsx("span",{className:"ml-auto text-muted-foreground",children:"(Read-only)"})]})]})}const Nd=Object.freeze(Object.defineProperty({__proto__:null,CodeEditor:Ax},Symbol.toStringTag,{value:"Module"})),$2={webSearchConfig:null,webSearchStatus:null,webSearchLoading:!0,webSearchStatusLoading:!0,webSearchSaving:!1,webSearchError:null,webSearchSuccess:!1,globalEnvConfig:null,globalEnvLoading:!0,globalEnvSaving:!1,globalEnvError:null,globalEnvSuccess:!1,proxyConfig:null,proxyLoading:!0,proxySaving:!1,proxyError:null,proxySuccess:!1,proxyTestResult:null,proxyTesting:!1,rawConfig:null,rawConfigLoading:!1};function J2(a,s){switch(s.type){case"SET_WEBSEARCH_CONFIG":return{...a,webSearchConfig:s.payload};case"SET_WEBSEARCH_STATUS":return{...a,webSearchStatus:s.payload};case"SET_WEBSEARCH_LOADING":return{...a,webSearchLoading:s.payload};case"SET_WEBSEARCH_STATUS_LOADING":return{...a,webSearchStatusLoading:s.payload};case"SET_WEBSEARCH_SAVING":return{...a,webSearchSaving:s.payload};case"SET_WEBSEARCH_ERROR":return{...a,webSearchError:s.payload};case"SET_WEBSEARCH_SUCCESS":return{...a,webSearchSuccess:s.payload};case"SET_GLOBALENV_CONFIG":return{...a,globalEnvConfig:s.payload};case"SET_GLOBALENV_LOADING":return{...a,globalEnvLoading:s.payload};case"SET_GLOBALENV_SAVING":return{...a,globalEnvSaving:s.payload};case"SET_GLOBALENV_ERROR":return{...a,globalEnvError:s.payload};case"SET_GLOBALENV_SUCCESS":return{...a,globalEnvSuccess:s.payload};case"SET_PROXY_CONFIG":return{...a,proxyConfig:s.payload};case"SET_PROXY_LOADING":return{...a,proxyLoading:s.payload};case"SET_PROXY_SAVING":return{...a,proxySaving:s.payload};case"SET_PROXY_ERROR":return{...a,proxyError:s.payload};case"SET_PROXY_SUCCESS":return{...a,proxySuccess:s.payload};case"SET_PROXY_TEST_RESULT":return{...a,proxyTestResult:s.payload};case"SET_PROXY_TESTING":return{...a,proxyTesting:s.payload};case"SET_RAW_CONFIG":return{...a,rawConfig:s.payload};case"SET_RAW_CONFIG_LOADING":return{...a,rawConfigLoading:s.payload};default:return a}}const Ox=y.createContext(null);function P2({children:a}){const[s,r]=y.useReducer(J2,$2);return i.jsx(Ox.Provider,{value:{state:s,dispatch:r},children:a})}function zx(){const a=y.useContext(Ox);if(!a)throw new Error("useSettingsContext must be used within a SettingsProvider");return a}function I2(){const{dispatch:a}=zx(),s=y.useCallback(j=>a({type:"SET_WEBSEARCH_CONFIG",payload:j}),[a]),r=y.useCallback(j=>a({type:"SET_WEBSEARCH_STATUS",payload:j}),[a]),u=y.useCallback(j=>a({type:"SET_WEBSEARCH_LOADING",payload:j}),[a]),d=y.useCallback(j=>a({type:"SET_WEBSEARCH_STATUS_LOADING",payload:j}),[a]),f=y.useCallback(j=>a({type:"SET_WEBSEARCH_SAVING",payload:j}),[a]),m=y.useCallback(j=>a({type:"SET_WEBSEARCH_ERROR",payload:j}),[a]),p=y.useCallback(j=>a({type:"SET_WEBSEARCH_SUCCESS",payload:j}),[a]),x=y.useCallback(j=>a({type:"SET_GLOBALENV_CONFIG",payload:j}),[a]),b=y.useCallback(j=>a({type:"SET_GLOBALENV_LOADING",payload:j}),[a]),C=y.useCallback(j=>a({type:"SET_GLOBALENV_SAVING",payload:j}),[a]),v=y.useCallback(j=>a({type:"SET_GLOBALENV_ERROR",payload:j}),[a]),S=y.useCallback(j=>a({type:"SET_GLOBALENV_SUCCESS",payload:j}),[a]),M=y.useCallback(j=>a({type:"SET_PROXY_CONFIG",payload:j}),[a]),O=y.useCallback(j=>a({type:"SET_PROXY_LOADING",payload:j}),[a]),U=y.useCallback(j=>a({type:"SET_PROXY_SAVING",payload:j}),[a]),_=y.useCallback(j=>a({type:"SET_PROXY_ERROR",payload:j}),[a]),T=y.useCallback(j=>a({type:"SET_PROXY_SUCCESS",payload:j}),[a]),K=y.useCallback(j=>a({type:"SET_PROXY_TEST_RESULT",payload:j}),[a]),B=y.useCallback(j=>a({type:"SET_PROXY_TESTING",payload:j}),[a]),L=y.useCallback(j=>a({type:"SET_RAW_CONFIG",payload:j}),[a]),k=y.useCallback(j=>a({type:"SET_RAW_CONFIG_LOADING",payload:j}),[a]);return y.useMemo(()=>({setWebSearchConfig:s,setWebSearchStatus:r,setWebSearchLoading:u,setWebSearchStatusLoading:d,setWebSearchSaving:f,setWebSearchError:m,setWebSearchSuccess:p,setGlobalEnvConfig:x,setGlobalEnvLoading:b,setGlobalEnvSaving:C,setGlobalEnvError:v,setGlobalEnvSuccess:S,setProxyConfig:M,setProxyLoading:O,setProxySaving:U,setProxyError:_,setProxySuccess:T,setProxyTestResult:K,setProxyTesting:B,setRawConfig:L,setRawConfigLoading:k}),[s,r,u,d,f,m,p,x,b,C,v,S,M,O,U,_,T,K,B,L,k])}function F2(){const[a,s]=Vv(),r=a.get("tab")?.toLowerCase(),u=r==="globalenv"?"globalenv":r==="proxy"?"proxy":r==="auth"?"auth":r==="thinking"?"thinking":r==="backups"?"backups":"websearch",d=y.useCallback(f=>{s({tab:f},{replace:!0})},[s]);return{activeTab:u,setActiveTab:d}}function ew(){const{state:a}=zx(),s=I2(),[r,u]=y.useState(!1),d=y.useCallback(async()=>{try{s.setRawConfigLoading(!0);const m=await fetch("/api/config/raw");if(!m.ok){s.setRawConfig(null);return}const p=await m.text();s.setRawConfig(p)}catch{s.setRawConfig(null)}finally{s.setRawConfigLoading(!1)}},[s]),f=y.useCallback(async()=>{if(a.rawConfig)try{await navigator.clipboard.writeText(a.rawConfig),u(!0),setTimeout(()=>u(!1),2e3)}catch{}},[a.rawConfig]);return{rawConfig:a.rawConfig,loading:a.rawConfigLoading,copied:r,fetchRawConfig:d,copyToClipboard:f}}const tw=[{value:"websearch",label:"Web",icon:wb},{value:"globalenv",label:"Env",icon:Ic},{value:"thinking",label:"Think",icon:Cb},{value:"proxy",label:"Proxy",icon:Eb},{value:"auth",label:"Auth",icon:$c},{value:"backups",label:"Backup",icon:Mb}];function Fp({activeTab:a,onTabChange:s}){return i.jsx(jx,{value:a,onValueChange:r=>s(r),children:i.jsx(vd,{className:"grid w-full grid-cols-6",children:tw.map(({value:r,label:u,icon:d})=>i.jsxs(Xr,{value:r,className:"gap-1.5 px-1 text-xs",children:[i.jsx(d,{className:"h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"truncate",children:u})]},r))})})}function eg(){return i.jsxs("div",{className:"flex-1 p-5 space-y-6",children:[i.jsx(Le,{className:"h-4 w-2/3"}),i.jsx("div",{className:"p-4 rounded-lg border",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(Le,{className:"h-5 w-32"}),i.jsx(Le,{className:"h-4 w-48"})]}),i.jsx(Le,{className:"h-6 w-10 rounded-full"})]})}),i.jsxs("div",{className:"space-y-3",children:[i.jsx(Le,{className:"h-5 w-24"}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Le,{className:"h-20 w-full rounded-lg"}),i.jsx(Le,{className:"h-20 w-full rounded-lg"}),i.jsx(Le,{className:"h-20 w-full rounded-lg"})]})]})]})}function Dx(a,s=3,r=1e3){return a().catch(u=>{if(s<=0)throw u;return new Promise(d=>setTimeout(d,r)).then(()=>Dx(a,s-1,r*2))})}function us(a){return y.lazy(()=>Dx(a))}const tg=us(()=>St(()=>import("./index-BSK5RM6B.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),ng=us(()=>St(()=>import("./globalenv-section-Bj18vmmp.js"),__vite__mapDeps([10,1,2,3,4,5,6,7,8,9]))),ag=us(()=>St(()=>import("./index-DYpGbm8d.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8,9]))),lg=us(()=>St(()=>import("./index-BzXQbaOm.js"),__vite__mapDeps([12,1,2,3,13,4,14,15,5,6,7,8,9]))),sg=us(()=>St(()=>import("./auth-section-yxhlBIeU.js"),__vite__mapDeps([16,1,2,4,5,6,7,8,9]))),ig=us(()=>St(()=>import("./backups-section-DPkR6c2v.js"),__vite__mapDeps([17,1,2,15,4,5,6,7,8,9])));class rg extends y.Component{constructor(s){super(s),this.state={hasError:!1,error:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}render(){return this.state.hasError?i.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:i.jsxs("div",{className:"text-center p-6 max-w-md",children:[i.jsx(Fc,{className:"w-12 h-12 mx-auto mb-4 text-destructive"}),i.jsx("p",{className:"font-medium text-foreground mb-2",children:"Failed to load section"}),i.jsx("p",{className:"text-sm mb-4",children:this.state.error?.message||"Unknown error occurred"}),i.jsxs(ot,{variant:"outline",onClick:()=>window.location.reload(),className:"inline-flex items-center gap-2",children:[i.jsx(pi,{className:"w-4 h-4"}),"Reload page"]})]})}):this.props.children}}function nw(){const{activeTab:a,setActiveTab:s}=F2(),{rawConfig:r,loading:u,copied:d,fetchRawConfig:f,copyToClipboard:m}=ew();y.useEffect(()=>{f()},[f]);const p=x=>{y.startTransition(()=>{s(x)})};return i.jsxs("div",{className:"h-[calc(100vh-100px)]",children:[i.jsxs("div",{className:"md:hidden h-full flex flex-col",children:[i.jsx("div",{className:"border-b bg-background p-4",children:i.jsx(Fp,{activeTab:a,onTabChange:p})}),i.jsx(rg,{children:i.jsxs(y.Suspense,{fallback:i.jsx(eg,{}),children:[a==="websearch"&&i.jsx(tg,{}),a==="globalenv"&&i.jsx(ng,{}),a==="thinking"&&i.jsx(ag,{}),a==="proxy"&&i.jsx(lg,{}),a==="auth"&&i.jsx(sg,{}),a==="backups"&&i.jsx(ig,{})]})})]}),i.jsxs(pd,{direction:"horizontal",className:"h-full hidden md:flex",children:[i.jsx(xi,{defaultSize:40,minSize:30,maxSize:55,children:i.jsxs("div",{className:"h-full border-r flex flex-col bg-muted/30 relative",children:[i.jsx("div",{className:"p-5 border-b bg-background",children:i.jsx(Fp,{activeTab:a,onTabChange:p})}),i.jsx(rg,{children:i.jsxs(y.Suspense,{fallback:i.jsx(eg,{}),children:[a==="websearch"&&i.jsx(tg,{}),a==="globalenv"&&i.jsx(ng,{}),a==="thinking"&&i.jsx(ag,{}),a==="proxy"&&i.jsx(lg,{}),a==="auth"&&i.jsx(sg,{}),a==="backups"&&i.jsx(ig,{})]})})]})}),i.jsx(gd,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:i.jsx(Ir,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),i.jsx(xi,{defaultSize:60,minSize:35,children:i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"p-4 border-b bg-background flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Np,{className:"w-5 h-5 text-primary"}),i.jsxs("div",{children:[i.jsx("h2",{className:"font-semibold",children:"config.yaml"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"~/.ccs/config.yaml"})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(ot,{variant:"outline",size:"sm",onClick:m,disabled:!r,children:d?i.jsxs(i.Fragment,{children:[i.jsx(rs,{className:"w-4 h-4 mr-1"}),"Copied"]}):i.jsxs(i.Fragment,{children:[i.jsx(Gr,{className:"w-4 h-4 mr-1"}),"Copy"]})}),i.jsx(ot,{variant:"outline",size:"sm",onClick:f,disabled:u,children:i.jsx(pi,{className:`w-4 h-4 ${u?"animate-spin":""}`})})]})]}),i.jsx("div",{className:"flex-1 overflow-auto",children:u?i.jsxs("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:[i.jsx(pi,{className:"w-5 h-5 animate-spin mr-2"}),"Loading..."]}):r?i.jsx(Ax,{value:r,onChange:()=>{},language:"yaml",readonly:!0,minHeight:"auto",className:"min-h-full"}):i.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:i.jsxs("div",{className:"text-center",children:[i.jsx(Np,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),i.jsx("p",{children:"Config file not found"}),i.jsx("code",{className:"text-sm bg-muted px-2 py-1 rounded mt-2 inline-block",children:"ccs migrate"})]})})})]})})]})]})}function aw(){return i.jsx(P2,{children:i.jsx(nw,{})})}const lw=Object.freeze(Object.defineProperty({__proto__:null,SettingsPage:aw},Symbol.toStringTag,{value:"Module"})),WE=Bv,$E=Lv,JE=Hv,sw=y.forwardRef(({className:a,align:s="center",sideOffset:r=4,...u},d)=>i.jsx(qv,{children:i.jsx(kg,{ref:d,align:s,sideOffset:r,className:G("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",a),...u})}));sw.displayName=kg.displayName;function iw(a,s,r="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:a,timeZoneName:r}).format(s).split(/\s/g).slice(2).join(" ")}const rw={},fi={};function fl(a,s){try{const u=(rw[a]||=new Intl.DateTimeFormat("en-US",{timeZone:a,timeZoneName:"longOffset"}).format)(s).split("GMT")[1];return u in fi?fi[u]:og(u,u.split(":"))}catch{if(a in fi)return fi[a];const r=a?.match(ow);return r?og(a,r.slice(1)):NaN}}const ow=/([+-]\d\d):?(\d\d)?/;function og(a,s){const r=+(s[0]||0),u=+(s[1]||0),d=+(s[2]||0)/60;return fi[a]=r*60+u>0?r*60+u+d:r*60-u-d}class qn extends Date{constructor(...s){super(),s.length>1&&typeof s[s.length-1]=="string"&&(this.timeZone=s.pop()),this.internal=new Date,isNaN(fl(this.timeZone,this))?this.setTime(NaN):s.length?typeof s[0]=="number"&&(s.length===1||s.length===2&&typeof s[1]!="number")?this.setTime(s[0]):typeof s[0]=="string"?this.setTime(+new Date(s[0])):s[0]instanceof Date?this.setTime(+s[0]):(this.setTime(+new Date(...s)),_x(this),Xc(this)):this.setTime(Date.now())}static tz(s,...r){return r.length?new qn(...r,s):new qn(Date.now(),s)}withTimeZone(s){return new qn(+this,s)}getTimezoneOffset(){const s=-fl(this.timeZone,this);return s>0?Math.floor(s):Math.ceil(s)}setTime(s){return Date.prototype.setTime.apply(this,arguments),Xc(this),+this}[Symbol.for("constructDateFrom")](s){return new qn(+new Date(s),this.timeZone)}}const ug=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(a=>{if(!ug.test(a))return;const s=a.replace(ug,"$1UTC");qn.prototype[s]&&(a.startsWith("get")?qn.prototype[a]=function(){return this.internal[s]()}:(qn.prototype[a]=function(){return Date.prototype[s].apply(this.internal,arguments),uw(this),+this},qn.prototype[s]=function(){return Date.prototype[s].apply(this,arguments),Xc(this),+this}))});function Xc(a){a.internal.setTime(+a),a.internal.setUTCSeconds(a.internal.getUTCSeconds()-Math.round(-fl(a.timeZone,a)*60))}function uw(a){Date.prototype.setFullYear.call(a,a.internal.getUTCFullYear(),a.internal.getUTCMonth(),a.internal.getUTCDate()),Date.prototype.setHours.call(a,a.internal.getUTCHours(),a.internal.getUTCMinutes(),a.internal.getUTCSeconds(),a.internal.getUTCMilliseconds()),_x(a)}function _x(a){const s=fl(a.timeZone,a),r=s>0?Math.floor(s):Math.ceil(s),u=new Date(+a);u.setUTCHours(u.getUTCHours()-1);const d=-new Date(+a).getTimezoneOffset(),f=-new Date(+u).getTimezoneOffset(),m=d-f,p=Date.prototype.getHours.apply(a)!==a.internal.getUTCHours();m&&p&&a.internal.setUTCMinutes(a.internal.getUTCMinutes()+m);const x=d-r;x&&Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+x);const b=new Date(+a);b.setUTCSeconds(0);const C=d>0?b.getSeconds():(b.getSeconds()-60)%60,v=Math.round(-(fl(a.timeZone,a)*60))%60;(v||C)&&(a.internal.setUTCSeconds(a.internal.getUTCSeconds()+v),Date.prototype.setUTCSeconds.call(a,Date.prototype.getUTCSeconds.call(a)+v+C));const S=fl(a.timeZone,a),M=S>0?Math.floor(S):Math.ceil(S),U=-new Date(+a).getTimezoneOffset()-M,_=M!==r,T=U-x;if(_&&T){Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+T);const K=fl(a.timeZone,a),B=K>0?Math.floor(K):Math.ceil(K),L=M-B;L&&(a.internal.setUTCMinutes(a.internal.getUTCMinutes()+L),Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+L))}}class ca extends qn{static tz(s,...r){return r.length?new ca(...r,s):new ca(Date.now(),s)}toISOString(){const[s,r,u]=this.tzComponents(),d=`${s}${r}:${u}`;return this.internal.toISOString().slice(0,-1)+d}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[s,r,u,d]=this.internal.toUTCString().split(" ");return`${s?.slice(0,-1)} ${u} ${r} ${d}`}toTimeString(){const s=this.internal.toUTCString().split(" ")[4],[r,u,d]=this.tzComponents();return`${s} GMT${r}${u}${d} (${iw(this.timeZone,this)})`}toLocaleString(s,r){return Date.prototype.toLocaleString.call(this,s,{...r,timeZone:r?.timeZone||this.timeZone})}toLocaleDateString(s,r){return Date.prototype.toLocaleDateString.call(this,s,{...r,timeZone:r?.timeZone||this.timeZone})}toLocaleTimeString(s,r){return Date.prototype.toLocaleTimeString.call(this,s,{...r,timeZone:r?.timeZone||this.timeZone})}tzComponents(){const s=this.getTimezoneOffset(),r=s>0?"-":"+",u=String(Math.floor(Math.abs(s)/60)).padStart(2,"0"),d=String(Math.abs(s)%60).padStart(2,"0");return[r,u,d]}withTimeZone(s){return new ca(+this,s)}[Symbol.for("constructDateFrom")](s){return new ca(+new Date(s),this.timeZone)}}const cg=5,cw=4;function dw(a,s){const r=s.startOfMonth(a),u=r.getDay()>0?r.getDay():7,d=s.addDays(a,-u+1),f=s.addDays(d,cg*7-1);return s.getMonth(a)===s.getMonth(f)?cg:cw}function kx(a,s){const r=s.startOfMonth(a),u=r.getDay();return u===1?r:u===0?s.addDays(r,-6):s.addDays(r,-1*(u-1))}function fw(a,s){const r=kx(a,s),u=dw(a,s);return s.addDays(r,u*7-1)}const Rx={...si,labels:{labelDayButton:(a,s,r,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(m,p)=>oi(m,p,{locale:si,...r});let f=d(a,"PPPP");return s.today&&(f=`Today, ${f}`),s.selected&&(f=`${f}, selected`),f},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:a=>`Week ${a}`,labelYearDropdown:"Choose the Year",labelGrid:(a,s,r)=>{let u;return r&&typeof r.format=="function"?u=r.format.bind(r):u=(d,f)=>oi(d,f,{locale:si,...s}),u(a,"LLLL yyyy")},labelGridcell:(a,s,r,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(m,p)=>oi(m,p,{locale:si,...r});let f=d(a,"PPPP");return s?.today&&(f=`Today, ${f}`),f},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(a,s,r)=>{let u;return r&&typeof r.format=="function"?u=r.format.bind(r):u=(d,f)=>oi(d,f,{locale:si,...s}),u(a,"cccc")}}};class sn{constructor(s,r){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?ca.tz(this.options.timeZone):new this.Date,this.newDate=(u,d,f)=>this.overrides?.newDate?this.overrides.newDate(u,d,f):this.options.timeZone?new ca(u,d,f,this.options.timeZone):new Date(u,d,f),this.addDays=(u,d)=>this.overrides?.addDays?this.overrides.addDays(u,d):Db(u,d),this.addMonths=(u,d)=>this.overrides?.addMonths?this.overrides.addMonths(u,d):_b(u,d),this.addWeeks=(u,d)=>this.overrides?.addWeeks?this.overrides.addWeeks(u,d):kb(u,d),this.addYears=(u,d)=>this.overrides?.addYears?this.overrides.addYears(u,d):Rb(u,d),this.differenceInCalendarDays=(u,d)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(u,d):Ub(u,d),this.differenceInCalendarMonths=(u,d)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(u,d):qb(u,d),this.eachMonthOfInterval=u=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(u):Bb(u),this.eachYearOfInterval=u=>{const d=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(u):Hb(u),f=new Set(d.map(p=>this.getYear(p)));if(f.size===d.length)return d;const m=[];return f.forEach(p=>{m.push(new Date(p,0,1))}),m},this.endOfBroadcastWeek=u=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(u):fw(u,this),this.endOfISOWeek=u=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(u):Lb(u),this.endOfMonth=u=>this.overrides?.endOfMonth?this.overrides.endOfMonth(u):Yb(u),this.endOfWeek=(u,d)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(u,d):Gb(u,this.options),this.endOfYear=u=>this.overrides?.endOfYear?this.overrides.endOfYear(u):Kb(u),this.format=(u,d,f)=>{const m=this.overrides?.format?this.overrides.format(u,d,this.options):oi(u,d,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(m):m},this.getISOWeek=u=>this.overrides?.getISOWeek?this.overrides.getISOWeek(u):Qb(u),this.getMonth=(u,d)=>this.overrides?.getMonth?this.overrides.getMonth(u,this.options):Vb(u,this.options),this.getYear=(u,d)=>this.overrides?.getYear?this.overrides.getYear(u,this.options):Xb(u,this.options),this.getWeek=(u,d)=>this.overrides?.getWeek?this.overrides.getWeek(u,this.options):Zb(u,this.options),this.isAfter=(u,d)=>this.overrides?.isAfter?this.overrides.isAfter(u,d):Wb(u,d),this.isBefore=(u,d)=>this.overrides?.isBefore?this.overrides.isBefore(u,d):$b(u,d),this.isDate=u=>this.overrides?.isDate?this.overrides.isDate(u):Jb(u),this.isSameDay=(u,d)=>this.overrides?.isSameDay?this.overrides.isSameDay(u,d):Pb(u,d),this.isSameMonth=(u,d)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(u,d):Ib(u,d),this.isSameYear=(u,d)=>this.overrides?.isSameYear?this.overrides.isSameYear(u,d):Fb(u,d),this.max=u=>this.overrides?.max?this.overrides.max(u):eS(u),this.min=u=>this.overrides?.min?this.overrides.min(u):tS(u),this.setMonth=(u,d)=>this.overrides?.setMonth?this.overrides.setMonth(u,d):nS(u,d),this.setYear=(u,d)=>this.overrides?.setYear?this.overrides.setYear(u,d):aS(u,d),this.startOfBroadcastWeek=(u,d)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(u,this):kx(u,this),this.startOfDay=u=>this.overrides?.startOfDay?this.overrides.startOfDay(u):lS(u),this.startOfISOWeek=u=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(u):sS(u),this.startOfMonth=u=>this.overrides?.startOfMonth?this.overrides.startOfMonth(u):iS(u),this.startOfWeek=(u,d)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(u,this.options):rS(u,this.options),this.startOfYear=u=>this.overrides?.startOfYear?this.overrides.startOfYear(u):oS(u),this.options={locale:Rx,...s},this.overrides=r}getDigitMap(){const{numerals:s="latn"}=this.options,r=new Intl.NumberFormat("en-US",{numberingSystem:s}),u={};for(let d=0;d<10;d++)u[d.toString()]=r.format(d);return u}replaceDigits(s){const r=this.getDigitMap();return s.replace(/\d/g,u=>r[u]||u)}formatNumber(s){return this.replaceDigits(s.toString())}getMonthYearOrder(){const s=this.options.locale?.code;return s&&sn.yearFirstLocales.has(s)?"year-first":"month-first"}formatMonthYear(s){const{locale:r,timeZone:u,numerals:d}=this.options,f=r?.code;if(f&&sn.yearFirstLocales.has(f))try{return new Intl.DateTimeFormat(f,{month:"long",year:"numeric",timeZone:u,numberingSystem:d}).format(s)}catch{}const m=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(s,m)}}sn.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const Bn=new sn;class Ux{constructor(s,r,u=Bn){this.date=s,this.displayMonth=r,this.outside=!!(r&&!u.isSameMonth(s,r)),this.dateLib=u,this.isoDate=u.format(s,"yyyy-MM-dd"),this.displayMonthId=u.format(r,"yyyy-MM"),this.dateMonthId=u.format(s,"yyyy-MM")}isEqualTo(s){return this.dateLib.isSameDay(s.date,this.date)&&this.dateLib.isSameMonth(s.displayMonth,this.displayMonth)}}class mw{constructor(s,r){this.date=s,this.weeks=r}}class hw{constructor(s,r){this.days=r,this.weekNumber=s}}function pw(a){return F.createElement("button",{...a})}function gw(a){return F.createElement("span",{...a})}function xw(a){const{size:s=24,orientation:r="left",className:u}=a;return F.createElement("svg",{className:u,width:s,height:s,viewBox:"0 0 24 24"},r==="up"&&F.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),r==="down"&&F.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),r==="left"&&F.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),r==="right"&&F.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function yw(a){const{day:s,modifiers:r,...u}=a;return F.createElement("td",{...u})}function vw(a){const{day:s,modifiers:r,...u}=a,d=F.useRef(null);return F.useEffect(()=>{r.focused&&d.current?.focus()},[r.focused]),F.createElement("button",{ref:d,...u})}var ce;(function(a){a.Root="root",a.Chevron="chevron",a.Day="day",a.DayButton="day_button",a.CaptionLabel="caption_label",a.Dropdowns="dropdowns",a.Dropdown="dropdown",a.DropdownRoot="dropdown_root",a.Footer="footer",a.MonthGrid="month_grid",a.MonthCaption="month_caption",a.MonthsDropdown="months_dropdown",a.Month="month",a.Months="months",a.Nav="nav",a.NextMonthButton="button_next",a.PreviousMonthButton="button_previous",a.Week="week",a.Weeks="weeks",a.Weekday="weekday",a.Weekdays="weekdays",a.WeekNumber="week_number",a.WeekNumberHeader="week_number_header",a.YearsDropdown="years_dropdown"})(ce||(ce={}));var lt;(function(a){a.disabled="disabled",a.hidden="hidden",a.outside="outside",a.focused="focused",a.today="today"})(lt||(lt={}));var wn;(function(a){a.range_end="range_end",a.range_middle="range_middle",a.range_start="range_start",a.selected="selected"})(wn||(wn={}));var ln;(function(a){a.weeks_before_enter="weeks_before_enter",a.weeks_before_exit="weeks_before_exit",a.weeks_after_enter="weeks_after_enter",a.weeks_after_exit="weeks_after_exit",a.caption_after_enter="caption_after_enter",a.caption_after_exit="caption_after_exit",a.caption_before_enter="caption_before_enter",a.caption_before_exit="caption_before_exit"})(ln||(ln={}));function bw(a){const{options:s,className:r,components:u,classNames:d,...f}=a,m=[d[ce.Dropdown],r].join(" "),p=s?.find(({value:x})=>x===f.value);return F.createElement("span",{"data-disabled":f.disabled,className:d[ce.DropdownRoot]},F.createElement(u.Select,{className:m,...f},s?.map(({value:x,label:b,disabled:C})=>F.createElement(u.Option,{key:x,value:x,disabled:C},b))),F.createElement("span",{className:d[ce.CaptionLabel],"aria-hidden":!0},p?.label,F.createElement(u.Chevron,{orientation:"down",size:18,className:d[ce.Chevron]})))}function Sw(a){return F.createElement("div",{...a})}function Nw(a){return F.createElement("div",{...a})}function jw(a){const{calendarMonth:s,displayIndex:r,...u}=a;return F.createElement("div",{...u},a.children)}function ww(a){const{calendarMonth:s,displayIndex:r,...u}=a;return F.createElement("div",{...u})}function Cw(a){return F.createElement("table",{...a})}function Ew(a){return F.createElement("div",{...a})}const qx=y.createContext(void 0);function bi(){const a=y.useContext(qx);if(a===void 0)throw new Error("useDayPicker() must be used within a custom component.");return a}function Mw(a){const{components:s}=bi();return F.createElement(s.Dropdown,{...a})}function Tw(a){const{onPreviousClick:s,onNextClick:r,previousMonth:u,nextMonth:d,...f}=a,{components:m,classNames:p,labels:{labelPrevious:x,labelNext:b}}=bi(),C=y.useCallback(S=>{d&&r?.(S)},[d,r]),v=y.useCallback(S=>{u&&s?.(S)},[u,s]);return F.createElement("nav",{...f},F.createElement(m.PreviousMonthButton,{type:"button",className:p[ce.PreviousMonthButton],tabIndex:u?void 0:-1,"aria-disabled":u?void 0:!0,"aria-label":x(u),onClick:v},F.createElement(m.Chevron,{disabled:u?void 0:!0,className:p[ce.Chevron],orientation:"left"})),F.createElement(m.NextMonthButton,{type:"button",className:p[ce.NextMonthButton],tabIndex:d?void 0:-1,"aria-disabled":d?void 0:!0,"aria-label":b(d),onClick:C},F.createElement(m.Chevron,{disabled:d?void 0:!0,orientation:"right",className:p[ce.Chevron]})))}function Aw(a){const{components:s}=bi();return F.createElement(s.Button,{...a})}function Ow(a){return F.createElement("option",{...a})}function zw(a){const{components:s}=bi();return F.createElement(s.Button,{...a})}function Dw(a){const{rootRef:s,...r}=a;return F.createElement("div",{...r,ref:s})}function _w(a){return F.createElement("select",{...a})}function kw(a){const{week:s,...r}=a;return F.createElement("tr",{...r})}function Rw(a){return F.createElement("th",{...a})}function Uw(a){return F.createElement("thead",{"aria-hidden":!0},F.createElement("tr",{...a}))}function qw(a){const{week:s,...r}=a;return F.createElement("th",{...r})}function Bw(a){return F.createElement("th",{...a})}function Hw(a){return F.createElement("tbody",{...a})}function Lw(a){const{components:s}=bi();return F.createElement(s.Dropdown,{...a})}const Yw=Object.freeze(Object.defineProperty({__proto__:null,Button:pw,CaptionLabel:gw,Chevron:xw,Day:yw,DayButton:vw,Dropdown:bw,DropdownNav:Sw,Footer:Nw,Month:jw,MonthCaption:ww,MonthGrid:Cw,Months:Ew,MonthsDropdown:Mw,Nav:Tw,NextMonthButton:Aw,Option:Ow,PreviousMonthButton:zw,Root:Dw,Select:_w,Week:kw,WeekNumber:qw,WeekNumberHeader:Bw,Weekday:Rw,Weekdays:Uw,Weeks:Hw,YearsDropdown:Lw},Symbol.toStringTag,{value:"Module"}));function da(a,s,r=!1,u=Bn){let{from:d,to:f}=a;const{differenceInCalendarDays:m,isSameDay:p}=u;return d&&f?(m(f,d)<0&&([d,f]=[f,d]),m(s,d)>=(r?1:0)&&m(f,s)>=(r?1:0)):!r&&f?p(f,s):!r&&d?p(d,s):!1}function jd(a){return!!(a&&typeof a=="object"&&"before"in a&&"after"in a)}function co(a){return!!(a&&typeof a=="object"&&"from"in a)}function wd(a){return!!(a&&typeof a=="object"&&"after"in a)}function Cd(a){return!!(a&&typeof a=="object"&&"before"in a)}function Bx(a){return!!(a&&typeof a=="object"&&"dayOfWeek"in a)}function Hx(a,s){return Array.isArray(a)&&a.every(s.isDate)}function fa(a,s,r=Bn){const u=Array.isArray(s)?s:[s],{isSameDay:d,differenceInCalendarDays:f,isAfter:m}=r;return u.some(p=>{if(typeof p=="boolean")return p;if(r.isDate(p))return d(a,p);if(Hx(p,r))return p.some(x=>d(a,x));if(co(p))return da(p,a,!1,r);if(Bx(p))return Array.isArray(p.dayOfWeek)?p.dayOfWeek.includes(a.getDay()):p.dayOfWeek===a.getDay();if(jd(p)){const x=f(p.before,a),b=f(p.after,a),C=x>0,v=b<0;return m(p.before,p.after)?v&&C:C||v}return wd(p)?f(a,p.after)>0:Cd(p)?f(p.before,a)>0:typeof p=="function"?p(a):!1})}function Gw(a,s,r,u,d){const{disabled:f,hidden:m,modifiers:p,showOutsideDays:x,broadcastCalendar:b,today:C=d.today()}=s,{isSameDay:v,isSameMonth:S,startOfMonth:M,isBefore:O,endOfMonth:U,isAfter:_}=d,T=r&&M(r),K=u&&U(u),B={[lt.focused]:[],[lt.outside]:[],[lt.disabled]:[],[lt.hidden]:[],[lt.today]:[]},L={};for(const k of a){const{date:j,displayMonth:H}=k,Z=!!(H&&!S(j,H)),ee=!!(T&&O(j,T)),se=!!(K&&_(j,K)),be=!!(f&&fa(j,f,d)),ue=!!(m&&fa(j,m,d))||ee||se||!b&&!x&&Z||b&&x===!1&&Z,Ye=v(j,C);Z&&B.outside.push(k),be&&B.disabled.push(k),ue&&B.hidden.push(k),Ye&&B.today.push(k),p&&Object.keys(p).forEach(Ne=>{const P=p?.[Ne];P&&fa(j,P,d)&&(L[Ne]?L[Ne].push(k):L[Ne]=[k])})}return k=>{const j={[lt.focused]:!1,[lt.disabled]:!1,[lt.hidden]:!1,[lt.outside]:!1,[lt.today]:!1},H={};for(const Z in B){const ee=B[Z];j[Z]=ee.some(se=>se===k)}for(const Z in L)H[Z]=L[Z].some(ee=>ee===k);return{...j,...H}}}function Kw(a,s,r={}){return Object.entries(a).filter(([,d])=>d===!0).reduce((d,[f])=>(r[f]?d.push(r[f]):s[lt[f]]?d.push(s[lt[f]]):s[wn[f]]&&d.push(s[wn[f]]),d),[s[ce.Day]])}function Qw(a){return{...Yw,...a}}function Vw(a){const s={"data-mode":a.mode??void 0,"data-required":"required"in a?a.required:void 0,"data-multiple-months":a.numberOfMonths&&a.numberOfMonths>1||void 0,"data-week-numbers":a.showWeekNumber||void 0,"data-broadcast-calendar":a.broadcastCalendar||void 0,"data-nav-layout":a.navLayout||void 0};return Object.entries(a).forEach(([r,u])=>{r.startsWith("data-")&&(s[r]=u)}),s}function Xw(){const a={};for(const s in ce)a[ce[s]]=`rdp-${ce[s]}`;for(const s in lt)a[lt[s]]=`rdp-${lt[s]}`;for(const s in wn)a[wn[s]]=`rdp-${wn[s]}`;for(const s in ln)a[ln[s]]=`rdp-${ln[s]}`;return a}function Lx(a,s,r){return(r??new sn(s)).formatMonthYear(a)}const Zw=Lx;function Ww(a,s,r){return(r??new sn(s)).format(a,"d")}function $w(a,s=Bn){return s.format(a,"LLLL")}function Jw(a,s,r){return(r??new sn(s)).format(a,"cccccc")}function Pw(a,s=Bn){return a<10?s.formatNumber(`0${a.toLocaleString()}`):s.formatNumber(`${a.toLocaleString()}`)}function Iw(){return""}function Yx(a,s=Bn){return s.format(a,"yyyy")}const Fw=Yx,eC=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:Lx,formatDay:Ww,formatMonthCaption:Zw,formatMonthDropdown:$w,formatWeekNumber:Pw,formatWeekNumberHeader:Iw,formatWeekdayName:Jw,formatYearCaption:Fw,formatYearDropdown:Yx},Symbol.toStringTag,{value:"Module"}));function tC(a){return a?.formatMonthCaption&&!a.formatCaption&&(a.formatCaption=a.formatMonthCaption),a?.formatYearCaption&&!a.formatYearDropdown&&(a.formatYearDropdown=a.formatYearCaption),{...eC,...a}}function Ed(a,s,r,u){let d=(u??new sn(r)).format(a,"PPPP");return s.today&&(d=`Today, ${d}`),s.selected&&(d=`${d}, selected`),d}const nC=Ed;function Md(a,s,r){return(r??new sn(s)).formatMonthYear(a)}const aC=Md;function Gx(a,s,r,u){let d=(u??new sn(r)).format(a,"PPPP");return s?.today&&(d=`Today, ${d}`),d}function Kx(a){return"Choose the Month"}function Qx(){return""}const lC="Go to the Next Month";function Vx(a,s){return lC}function Xx(a){return"Go to the Previous Month"}function Zx(a,s,r){return(r??new sn(s)).format(a,"cccc")}function Wx(a,s){return`Week ${a}`}function $x(a){return"Week Number"}function Jx(a){return"Choose the Year"}const sC=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:aC,labelDay:nC,labelDayButton:Ed,labelGrid:Md,labelGridcell:Gx,labelMonthDropdown:Kx,labelNav:Qx,labelNext:Vx,labelPrevious:Xx,labelWeekNumber:Wx,labelWeekNumberHeader:$x,labelWeekday:Zx,labelYearDropdown:Jx},Symbol.toStringTag,{value:"Module"})),jn=(a,s,r)=>s||(r?typeof r=="function"?r:(...u)=>r:a);function iC(a,s){const r=s.locale?.labels??{};return{...sC,...a??{},labelDayButton:jn(Ed,a?.labelDayButton,r.labelDayButton),labelMonthDropdown:jn(Kx,a?.labelMonthDropdown,r.labelMonthDropdown),labelNext:jn(Vx,a?.labelNext,r.labelNext),labelPrevious:jn(Xx,a?.labelPrevious,r.labelPrevious),labelWeekNumber:jn(Wx,a?.labelWeekNumber,r.labelWeekNumber),labelYearDropdown:jn(Jx,a?.labelYearDropdown,r.labelYearDropdown),labelGrid:jn(Md,a?.labelGrid,r.labelGrid),labelGridcell:jn(Gx,a?.labelGridcell,r.labelGridcell),labelNav:jn(Qx,a?.labelNav,r.labelNav),labelWeekNumberHeader:jn($x,a?.labelWeekNumberHeader,r.labelWeekNumberHeader),labelWeekday:jn(Zx,a?.labelWeekday,r.labelWeekday)}}function rC(a,s,r,u,d){const{startOfMonth:f,startOfYear:m,endOfYear:p,eachMonthOfInterval:x,getMonth:b}=d;return x({start:m(a),end:p(a)}).map(S=>{const M=u.formatMonthDropdown(S,d),O=b(S),U=s&&S<f(s)||r&&S>f(r)||!1;return{value:O,label:M,disabled:U}})}function oC(a,s={},r={}){let u={...s?.[ce.Day]};return Object.entries(a).filter(([,d])=>d===!0).forEach(([d])=>{u={...u,...r?.[d]}}),u}function uC(a,s,r,u){const d=u??a.today(),f=r?a.startOfBroadcastWeek(d,a):s?a.startOfISOWeek(d):a.startOfWeek(d),m=[];for(let p=0;p<7;p++){const x=a.addDays(f,p);m.push(x)}return m}function cC(a,s,r,u,d=!1){if(!a||!s)return;const{startOfYear:f,endOfYear:m,eachYearOfInterval:p,getYear:x}=u,b=f(a),C=m(s),v=p({start:b,end:C});return d&&v.reverse(),v.map(S=>{const M=r.formatYearDropdown(S,u);return{value:x(S),label:M,disabled:!1}})}const Si=a=>a instanceof HTMLElement?a:null,_c=a=>[...a.querySelectorAll("[data-animated-month]")??[]],dC=a=>Si(a.querySelector("[data-animated-month]")),kc=a=>Si(a.querySelector("[data-animated-caption]")),Rc=a=>Si(a.querySelector("[data-animated-weeks]")),fC=a=>Si(a.querySelector("[data-animated-nav]")),mC=a=>Si(a.querySelector("[data-animated-weekdays]"));function hC(a,s,{classNames:r,months:u,focused:d,dateLib:f}){const m=y.useRef(null),p=y.useRef(u),x=y.useRef(!1);y.useLayoutEffect(()=>{const b=p.current;if(p.current=u,!s||!a.current||!(a.current instanceof HTMLElement)||u.length===0||b.length===0||u.length!==b.length)return;const C=f.isSameMonth(u[0].date,b[0].date),v=f.isAfter(u[0].date,b[0].date),S=v?r[ln.caption_after_enter]:r[ln.caption_before_enter],M=v?r[ln.weeks_after_enter]:r[ln.weeks_before_enter],O=m.current,U=a.current.cloneNode(!0);if(U instanceof HTMLElement?(_c(U).forEach(B=>{if(!(B instanceof HTMLElement))return;const L=dC(B);L&&B.contains(L)&&B.removeChild(L);const k=kc(B);k&&k.classList.remove(S);const j=Rc(B);j&&j.classList.remove(M)}),m.current=U):m.current=null,x.current||C||d)return;const _=O instanceof HTMLElement?_c(O):[],T=_c(a.current);if(T?.every(K=>K instanceof HTMLElement)&&_&&_.every(K=>K instanceof HTMLElement)){x.current=!0,a.current.style.isolation="isolate";const K=fC(a.current);K&&(K.style.zIndex="1"),T.forEach((B,L)=>{const k=_[L];if(!k)return;B.style.position="relative",B.style.overflow="hidden";const j=kc(B);j&&j.classList.add(S);const H=Rc(B);H&&H.classList.add(M);const Z=()=>{x.current=!1,a.current&&(a.current.style.isolation=""),K&&(K.style.zIndex=""),j&&j.classList.remove(S),H&&H.classList.remove(M),B.style.position="",B.style.overflow="",B.contains(k)&&B.removeChild(k)};k.style.pointerEvents="none",k.style.position="absolute",k.style.overflow="hidden",k.setAttribute("aria-hidden","true");const ee=mC(k);ee&&(ee.style.opacity="0");const se=kc(k);se&&(se.classList.add(v?r[ln.caption_before_exit]:r[ln.caption_after_exit]),se.addEventListener("animationend",Z));const be=Rc(k);be&&be.classList.add(v?r[ln.weeks_before_exit]:r[ln.weeks_after_exit]),B.insertBefore(k,B.firstChild)})}})}function pC(a,s,r,u){const d=a[0],f=a[a.length-1],{ISOWeek:m,fixedWeeks:p,broadcastCalendar:x}=r??{},{addDays:b,differenceInCalendarDays:C,differenceInCalendarMonths:v,endOfBroadcastWeek:S,endOfISOWeek:M,endOfMonth:O,endOfWeek:U,isAfter:_,startOfBroadcastWeek:T,startOfISOWeek:K,startOfWeek:B}=u,L=x?T(d,u):m?K(d):B(d),k=x?S(f):m?M(O(f)):U(O(f)),j=s&&(x?S(s):m?M(s):U(s)),H=j&&_(k,j)?j:k,Z=C(H,L),ee=v(f,d)+1,se=[];for(let Ye=0;Ye<=Z;Ye++){const Ne=b(L,Ye);se.push(Ne)}const ue=(x?35:42)*ee;if(p&&se.length<ue){const Ye=ue-se.length;for(let Ne=0;Ne<Ye;Ne++){const P=b(se[se.length-1],1);se.push(P)}}return se}function gC(a){const s=[];return a.reduce((r,u)=>{const d=u.weeks.reduce((f,m)=>f.concat(m.days.slice()),s.slice());return r.concat(d.slice())},s.slice())}function xC(a,s,r,u){const{numberOfMonths:d=1}=r,f=[];for(let m=0;m<d;m++){const p=u.addMonths(a,m);if(s&&p>s)break;f.push(p)}return f}function dg(a,s,r,u){const{month:d,defaultMonth:f,today:m=u.today(),numberOfMonths:p=1}=a;let x=d||f||m;const{differenceInCalendarMonths:b,addMonths:C,startOfMonth:v}=u;if(r&&b(r,x)<p-1){const S=-1*(p-1);x=C(r,S)}return s&&b(x,s)<0&&(x=s),v(x)}function yC(a,s,r,u){const{addDays:d,endOfBroadcastWeek:f,endOfISOWeek:m,endOfMonth:p,endOfWeek:x,getISOWeek:b,getWeek:C,startOfBroadcastWeek:v,startOfISOWeek:S,startOfWeek:M}=u,O=a.reduce((U,_)=>{const T=r.broadcastCalendar?v(_,u):r.ISOWeek?S(_):M(_),K=r.broadcastCalendar?f(_):r.ISOWeek?m(p(_)):x(p(_)),B=s.filter(H=>H>=T&&H<=K),L=r.broadcastCalendar?35:42;if(r.fixedWeeks&&B.length<L){const H=s.filter(Z=>{const ee=L-B.length;return Z>K&&Z<=d(K,ee)});B.push(...H)}const k=B.reduce((H,Z)=>{const ee=r.ISOWeek?b(Z):C(Z),se=H.find(ue=>ue.weekNumber===ee),be=new Ux(Z,_,u);return se?se.days.push(be):H.push(new hw(ee,[be])),H},[]),j=new mw(_,k);return U.push(j),U},[]);return r.reverseMonths?O.reverse():O}function vC(a,s){let{startMonth:r,endMonth:u}=a;const{startOfYear:d,startOfDay:f,startOfMonth:m,endOfMonth:p,addYears:x,endOfYear:b,newDate:C,today:v}=s,{fromYear:S,toYear:M,fromMonth:O,toMonth:U}=a;!r&&O&&(r=O),!r&&S&&(r=s.newDate(S,0,1)),!u&&U&&(u=U),!u&&M&&(u=C(M,11,31));const _=a.captionLayout==="dropdown"||a.captionLayout==="dropdown-years";return r?r=m(r):S?r=C(S,0,1):!r&&_&&(r=d(x(a.today??v(),-100))),u?u=p(u):M?u=C(M,11,31):!u&&_&&(u=b(a.today??v())),[r&&f(r),u&&f(u)]}function bC(a,s,r,u){if(r.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:f=1}=r,{startOfMonth:m,addMonths:p,differenceInCalendarMonths:x}=u,b=d?f:1,C=m(a);if(!s)return p(C,b);if(!(x(s,a)<f))return p(C,b)}function SC(a,s,r,u){if(r.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:f}=r,{startOfMonth:m,addMonths:p,differenceInCalendarMonths:x}=u,b=d?f??1:1,C=m(a);if(!s)return p(C,-b);if(!(x(C,s)<=0))return p(C,-b)}function NC(a){const s=[];return a.reduce((r,u)=>r.concat(u.weeks.slice()),s.slice())}function fo(a,s){const[r,u]=y.useState(a);return[s===void 0?r:s,u]}function jC(a,s){const[r,u]=vC(a,s),{startOfMonth:d,endOfMonth:f}=s,m=dg(a,r,u,s),[p,x]=fo(m,a.month?m:void 0);y.useEffect(()=>{const L=dg(a,r,u,s);x(L)},[a.timeZone]);const{months:b,weeks:C,days:v,previousMonth:S,nextMonth:M}=y.useMemo(()=>{const L=xC(p,u,{numberOfMonths:a.numberOfMonths},s),k=pC(L,a.endMonth?f(a.endMonth):void 0,{ISOWeek:a.ISOWeek,fixedWeeks:a.fixedWeeks,broadcastCalendar:a.broadcastCalendar},s),j=yC(L,k,{broadcastCalendar:a.broadcastCalendar,fixedWeeks:a.fixedWeeks,ISOWeek:a.ISOWeek,reverseMonths:a.reverseMonths},s),H=NC(j),Z=gC(j),ee=SC(p,r,a,s),se=bC(p,u,a,s);return{months:j,weeks:H,days:Z,previousMonth:ee,nextMonth:se}},[s,p.getTime(),u?.getTime(),r?.getTime(),a.disableNavigation,a.broadcastCalendar,a.endMonth?.getTime(),a.fixedWeeks,a.ISOWeek,a.numberOfMonths,a.pagedNavigation,a.reverseMonths]),{disableNavigation:O,onMonthChange:U}=a,_=L=>C.some(k=>k.days.some(j=>j.isEqualTo(L))),T=L=>{if(O)return;let k=d(L);r&&k<d(r)&&(k=d(r)),u&&k>d(u)&&(k=d(u)),x(k),U?.(k)};return{months:b,weeks:C,days:v,navStart:r,navEnd:u,previousMonth:S,nextMonth:M,goToMonth:T,goToDay:L=>{_(L)||T(L.date)}}}var Un;(function(a){a[a.Today=0]="Today",a[a.Selected=1]="Selected",a[a.LastFocused=2]="LastFocused",a[a.FocusedModifier=3]="FocusedModifier"})(Un||(Un={}));function fg(a){return!a[lt.disabled]&&!a[lt.hidden]&&!a[lt.outside]}function wC(a,s,r,u){let d,f=-1;for(const m of a){const p=s(m);fg(p)&&(p[lt.focused]&&f<Un.FocusedModifier?(d=m,f=Un.FocusedModifier):u?.isEqualTo(m)&&f<Un.LastFocused?(d=m,f=Un.LastFocused):r(m.date)&&f<Un.Selected?(d=m,f=Un.Selected):p[lt.today]&&f<Un.Today&&(d=m,f=Un.Today))}return d||(d=a.find(m=>fg(s(m)))),d}function CC(a,s,r,u,d,f,m){const{ISOWeek:p,broadcastCalendar:x}=f,{addDays:b,addMonths:C,addWeeks:v,addYears:S,endOfBroadcastWeek:M,endOfISOWeek:O,endOfWeek:U,max:_,min:T,startOfBroadcastWeek:K,startOfISOWeek:B,startOfWeek:L}=m;let j={day:b,week:v,month:C,year:S,startOfWeek:H=>x?K(H,m):p?B(H):L(H),endOfWeek:H=>x?M(H):p?O(H):U(H)}[a](r,s==="after"?1:-1);return s==="before"&&u?j=_([u,j]):s==="after"&&d&&(j=T([d,j])),j}function Px(a,s,r,u,d,f,m,p=0){if(p>365)return;const x=CC(a,s,r.date,u,d,f,m),b=!!(f.disabled&&fa(x,f.disabled,m)),C=!!(f.hidden&&fa(x,f.hidden,m)),v=x,S=new Ux(x,v,m);return!b&&!C?S:Px(a,s,S,u,d,f,m,p+1)}function EC(a,s,r,u,d){const{autoFocus:f}=a,[m,p]=y.useState(),x=wC(s.days,r,u||(()=>!1),m),[b,C]=y.useState(f?x:void 0);return{isFocusTarget:U=>!!x?.isEqualTo(U),setFocused:C,focused:b,blur:()=>{p(b),C(void 0)},moveFocus:(U,_)=>{if(!b)return;const T=Px(U,_,b,s.navStart,s.navEnd,a,d);T&&(a.disableNavigation&&!s.days.some(B=>B.isEqualTo(T))||(s.goToDay(T),C(T)))}}}function MC(a,s){const{selected:r,required:u,onSelect:d}=a,[f,m]=fo(r,d?r:void 0),p=d?r:f,{isSameDay:x}=s,b=M=>p?.some(O=>x(O,M))??!1,{min:C,max:v}=a;return{selected:p,select:(M,O,U)=>{let _=[...p??[]];if(b(M)){if(p?.length===C||u&&p?.length===1)return;_=p?.filter(T=>!x(T,M))}else p?.length===v?_=[M]:_=[..._,M];return d||m(_),d?.(_,M,O,U),_},isSelected:b}}function TC(a,s,r=0,u=0,d=!1,f=Bn){const{from:m,to:p}=s||{},{isSameDay:x,isAfter:b,isBefore:C}=f;let v;if(!m&&!p)v={from:a,to:r>0?void 0:a};else if(m&&!p)x(m,a)?r===0?v={from:m,to:a}:d?v={from:m,to:void 0}:v=void 0:C(a,m)?v={from:a,to:m}:v={from:m,to:a};else if(m&&p)if(x(m,a)&&x(p,a))d?v={from:m,to:p}:v=void 0;else if(x(m,a))v={from:m,to:r>0?void 0:a};else if(x(p,a))v={from:a,to:r>0?void 0:a};else if(C(a,m))v={from:a,to:p};else if(b(a,m))v={from:m,to:a};else if(b(a,p))v={from:m,to:a};else throw new Error("Invalid range");if(v?.from&&v?.to){const S=f.differenceInCalendarDays(v.to,v.from);u>0&&S>u?v={from:a,to:void 0}:r>1&&S<r&&(v={from:a,to:void 0})}return v}function AC(a,s,r=Bn){const u=Array.isArray(s)?s:[s];let d=a.from;const f=r.differenceInCalendarDays(a.to,a.from),m=Math.min(f,6);for(let p=0;p<=m;p++){if(u.includes(d.getDay()))return!0;d=r.addDays(d,1)}return!1}function mg(a,s,r=Bn){return da(a,s.from,!1,r)||da(a,s.to,!1,r)||da(s,a.from,!1,r)||da(s,a.to,!1,r)}function OC(a,s,r=Bn){const u=Array.isArray(s)?s:[s];if(u.filter(p=>typeof p!="function").some(p=>typeof p=="boolean"?p:r.isDate(p)?da(a,p,!1,r):Hx(p,r)?p.some(x=>da(a,x,!1,r)):co(p)?p.from&&p.to?mg(a,{from:p.from,to:p.to},r):!1:Bx(p)?AC(a,p.dayOfWeek,r):jd(p)?r.isAfter(p.before,p.after)?mg(a,{from:r.addDays(p.after,1),to:r.addDays(p.before,-1)},r):fa(a.from,p,r)||fa(a.to,p,r):wd(p)||Cd(p)?fa(a.from,p,r)||fa(a.to,p,r):!1))return!0;const m=u.filter(p=>typeof p=="function");if(m.length){let p=a.from;const x=r.differenceInCalendarDays(a.to,a.from);for(let b=0;b<=x;b++){if(m.some(C=>C(p)))return!0;p=r.addDays(p,1)}}return!1}function zC(a,s){const{disabled:r,excludeDisabled:u,selected:d,required:f,onSelect:m}=a,[p,x]=fo(d,m?d:void 0),b=m?d:p;return{selected:b,select:(S,M,O)=>{const{min:U,max:_}=a,T=S?TC(S,b,U,_,f,s):void 0;return u&&r&&T?.from&&T.to&&OC({from:T.from,to:T.to},r,s)&&(T.from=S,T.to=void 0),m||x(T),m?.(T,S,M,O),T},isSelected:S=>b&&da(b,S,!1,s)}}function DC(a,s){const{selected:r,required:u,onSelect:d}=a,[f,m]=fo(r,d?r:void 0),p=d?r:f,{isSameDay:x}=s;return{selected:p,select:(v,S,M)=>{let O=v;return!u&&p&&p&&x(v,p)&&(O=void 0),d||m(O),d?.(O,v,S,M),O},isSelected:v=>p?x(p,v):!1}}function _C(a,s){const r=DC(a,s),u=MC(a,s),d=zC(a,s);switch(a.mode){case"single":return r;case"multiple":return u;case"range":return d;default:return}}function Ot(a,s){return a instanceof ca&&a.timeZone===s?a:new ca(a,s)}function hg(a,s){return typeof a=="boolean"||typeof a=="function"?a:a instanceof Date?Ot(a,s):Array.isArray(a)?a.map(r=>r instanceof Date?Ot(r,s):r):co(a)?{...a,from:a.from?Ot(a.from,s):a.from,to:a.to?Ot(a.to,s):a.to}:jd(a)?{before:Ot(a.before,s),after:Ot(a.after,s)}:wd(a)?{after:Ot(a.after,s)}:Cd(a)?{before:Ot(a.before,s)}:a}function Uc(a,s){return a&&(Array.isArray(a)?a.map(r=>hg(r,s)):hg(a,s))}function kC(a){let s=a;const r=s.timeZone;if(r&&(s={...a,timeZone:r},s.today&&(s.today=Ot(s.today,r)),s.month&&(s.month=Ot(s.month,r)),s.defaultMonth&&(s.defaultMonth=Ot(s.defaultMonth,r)),s.startMonth&&(s.startMonth=Ot(s.startMonth,r)),s.endMonth&&(s.endMonth=Ot(s.endMonth,r)),s.mode==="single"&&s.selected?s.selected=Ot(s.selected,r):s.mode==="multiple"&&s.selected?s.selected=s.selected?.map(oe=>Ot(oe,r)):s.mode==="range"&&s.selected&&(s.selected={from:s.selected.from?Ot(s.selected.from,r):s.selected.from,to:s.selected.to?Ot(s.selected.to,r):s.selected.to}),s.disabled!==void 0&&(s.disabled=Uc(s.disabled,r)),s.hidden!==void 0&&(s.hidden=Uc(s.hidden,r)),s.modifiers)){const oe={};Object.keys(s.modifiers).forEach(Se=>{oe[Se]=Uc(s.modifiers?.[Se],r)}),s.modifiers=oe}const{components:u,formatters:d,labels:f,dateLib:m,locale:p,classNames:x}=y.useMemo(()=>{const oe={...Rx,...s.locale},Se=new sn({locale:oe,weekStartsOn:s.broadcastCalendar?1:s.weekStartsOn,firstWeekContainsDate:s.firstWeekContainsDate,useAdditionalWeekYearTokens:s.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:s.useAdditionalDayOfYearTokens,timeZone:s.timeZone,numerals:s.numerals},s.dateLib);return{dateLib:Se,components:Qw(s.components),formatters:tC(s.formatters),labels:iC(s.labels,Se.options),locale:oe,classNames:{...Xw(),...s.classNames}}},[s.locale,s.broadcastCalendar,s.weekStartsOn,s.firstWeekContainsDate,s.useAdditionalWeekYearTokens,s.useAdditionalDayOfYearTokens,s.timeZone,s.numerals,s.dateLib,s.components,s.formatters,s.labels,s.classNames]);s.today||(s={...s,today:m.today()});const{captionLayout:b,mode:C,navLayout:v,numberOfMonths:S=1,onDayBlur:M,onDayClick:O,onDayFocus:U,onDayKeyDown:_,onDayMouseEnter:T,onDayMouseLeave:K,onNextClick:B,onPrevClick:L,showWeekNumber:k,styles:j}=s,{formatCaption:H,formatDay:Z,formatMonthDropdown:ee,formatWeekNumber:se,formatWeekNumberHeader:be,formatWeekdayName:ue,formatYearDropdown:Ye}=d,Ne=jC(s,m),{days:P,months:A,navStart:W,navEnd:ie,previousMonth:ye,nextMonth:ve,goToMonth:De}=Ne,ze=Gw(P,s,W,ie,m),{isSelected:X,select:J,selected:ne}=_C(s,m)??{},{blur:I,focused:te,isFocusTarget:fe,moveFocus:Oe,setFocused:Ge}=EC(s,Ne,ze,X??(()=>!1),m),{labelDayButton:yt,labelGridcell:vt,labelGrid:Qe,labelMonthDropdown:tt,labelNav:kt,labelPrevious:Vt,labelNext:Hn,labelWeekday:je,labelWeekNumber:Xt,labelWeekNumberHeader:Mn,labelYearDropdown:Zt}=f,ha=y.useMemo(()=>uC(m,s.ISOWeek,s.broadcastCalendar,s.today),[m,s.ISOWeek,s.broadcastCalendar,s.today]),Ln=C!==void 0||O!==void 0,ct=y.useCallback(()=>{ye&&(De(ye),L?.(ye))},[ye,De,L]),Wt=y.useCallback(()=>{ve&&(De(ve),B?.(ve))},[De,ve,B]),Yn=y.useCallback((oe,Se)=>he=>{he.preventDefault(),he.stopPropagation(),Ge(oe),!Se.disabled&&(J?.(oe.date,Se,he),O?.(oe.date,Se,he))},[J,O,Ge]),Va=y.useCallback((oe,Se)=>he=>{Ge(oe),U?.(oe.date,Se,he)},[U,Ge]),Tn=y.useCallback((oe,Se)=>he=>{I(),M?.(oe.date,Se,he)},[I,M]),An=y.useCallback((oe,Se)=>he=>{const Te={ArrowLeft:[he.shiftKey?"month":"day",s.dir==="rtl"?"after":"before"],ArrowRight:[he.shiftKey?"month":"day",s.dir==="rtl"?"before":"after"],ArrowDown:[he.shiftKey?"year":"week","after"],ArrowUp:[he.shiftKey?"year":"week","before"],PageUp:[he.shiftKey?"year":"month","before"],PageDown:[he.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(Te[he.key]){he.preventDefault(),he.stopPropagation();const[Ie,xe]=Te[he.key];Oe(Ie,xe)}_?.(oe.date,Se,he)},[Oe,_,s.dir]),xl=y.useCallback((oe,Se)=>he=>{T?.(oe.date,Se,he)},[T]),cs=y.useCallback((oe,Se)=>he=>{K?.(oe.date,Se,he)},[K]),ds=y.useCallback(oe=>Se=>{const he=Number(Se.target.value),Te=m.setMonth(m.startOfMonth(oe),he);De(Te)},[m,De]),Gn=y.useCallback(oe=>Se=>{const he=Number(Se.target.value),Te=m.setYear(m.startOfMonth(oe),he);De(Te)},[m,De]),{className:$,style:Ee}=y.useMemo(()=>({className:[x[ce.Root],s.className].filter(Boolean).join(" "),style:{...j?.[ce.Root],...s.style}}),[x,s.className,s.style,j]),me=Vw(s),Me=y.useRef(null);hC(Me,!!s.animate,{classNames:x,months:A,focused:te,dateLib:m});const nt={dayPickerProps:s,selected:ne,select:J,isSelected:X,months:A,nextMonth:ve,previousMonth:ye,goToMonth:De,getModifiers:ze,components:u,classNames:x,styles:j,labels:f,formatters:d};return F.createElement(qx.Provider,{value:nt},F.createElement(u.Root,{rootRef:s.animate?Me:void 0,className:$,style:Ee,dir:s.dir,id:s.id,lang:s.lang,nonce:s.nonce,title:s.title,role:s.role,"aria-label":s["aria-label"],"aria-labelledby":s["aria-labelledby"],...me},F.createElement(u.Months,{className:x[ce.Months],style:j?.[ce.Months]},!s.hideNavigation&&!v&&F.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:x[ce.Nav],style:j?.[ce.Nav],"aria-label":kt(),onPreviousClick:ct,onNextClick:Wt,previousMonth:ye,nextMonth:ve}),A.map((oe,Se)=>F.createElement(u.Month,{"data-animated-month":s.animate?"true":void 0,className:x[ce.Month],style:j?.[ce.Month],key:Se,displayIndex:Se,calendarMonth:oe},v==="around"&&!s.hideNavigation&&Se===0&&F.createElement(u.PreviousMonthButton,{type:"button",className:x[ce.PreviousMonthButton],tabIndex:ye?void 0:-1,"aria-disabled":ye?void 0:!0,"aria-label":Vt(ye),onClick:ct,"data-animated-button":s.animate?"true":void 0},F.createElement(u.Chevron,{disabled:ye?void 0:!0,className:x[ce.Chevron],orientation:s.dir==="rtl"?"right":"left"})),F.createElement(u.MonthCaption,{"data-animated-caption":s.animate?"true":void 0,className:x[ce.MonthCaption],style:j?.[ce.MonthCaption],calendarMonth:oe,displayIndex:Se},b?.startsWith("dropdown")?F.createElement(u.DropdownNav,{className:x[ce.Dropdowns],style:j?.[ce.Dropdowns]},(()=>{const he=b==="dropdown"||b==="dropdown-months"?F.createElement(u.MonthsDropdown,{key:"month",className:x[ce.MonthsDropdown],"aria-label":tt(),classNames:x,components:u,disabled:!!s.disableNavigation,onChange:ds(oe.date),options:rC(oe.date,W,ie,d,m),style:j?.[ce.Dropdown],value:m.getMonth(oe.date)}):F.createElement("span",{key:"month"},ee(oe.date,m)),Te=b==="dropdown"||b==="dropdown-years"?F.createElement(u.YearsDropdown,{key:"year",className:x[ce.YearsDropdown],"aria-label":Zt(m.options),classNames:x,components:u,disabled:!!s.disableNavigation,onChange:Gn(oe.date),options:cC(W,ie,d,m,!!s.reverseYears),style:j?.[ce.Dropdown],value:m.getYear(oe.date)}):F.createElement("span",{key:"year"},Ye(oe.date,m));return m.getMonthYearOrder()==="year-first"?[Te,he]:[he,Te]})(),F.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},H(oe.date,m.options,m))):F.createElement(u.CaptionLabel,{className:x[ce.CaptionLabel],role:"status","aria-live":"polite"},H(oe.date,m.options,m))),v==="around"&&!s.hideNavigation&&Se===S-1&&F.createElement(u.NextMonthButton,{type:"button",className:x[ce.NextMonthButton],tabIndex:ve?void 0:-1,"aria-disabled":ve?void 0:!0,"aria-label":Hn(ve),onClick:Wt,"data-animated-button":s.animate?"true":void 0},F.createElement(u.Chevron,{disabled:ve?void 0:!0,className:x[ce.Chevron],orientation:s.dir==="rtl"?"left":"right"})),Se===S-1&&v==="after"&&!s.hideNavigation&&F.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:x[ce.Nav],style:j?.[ce.Nav],"aria-label":kt(),onPreviousClick:ct,onNextClick:Wt,previousMonth:ye,nextMonth:ve}),F.createElement(u.MonthGrid,{role:"grid","aria-multiselectable":C==="multiple"||C==="range","aria-label":Qe(oe.date,m.options,m)||void 0,className:x[ce.MonthGrid],style:j?.[ce.MonthGrid]},!s.hideWeekdays&&F.createElement(u.Weekdays,{"data-animated-weekdays":s.animate?"true":void 0,className:x[ce.Weekdays],style:j?.[ce.Weekdays]},k&&F.createElement(u.WeekNumberHeader,{"aria-label":Mn(m.options),className:x[ce.WeekNumberHeader],style:j?.[ce.WeekNumberHeader],scope:"col"},be()),ha.map(he=>F.createElement(u.Weekday,{"aria-label":je(he,m.options,m),className:x[ce.Weekday],key:String(he),style:j?.[ce.Weekday],scope:"col"},ue(he,m.options,m)))),F.createElement(u.Weeks,{"data-animated-weeks":s.animate?"true":void 0,className:x[ce.Weeks],style:j?.[ce.Weeks]},oe.weeks.map(he=>F.createElement(u.Week,{className:x[ce.Week],key:he.weekNumber,style:j?.[ce.Week],week:he},k&&F.createElement(u.WeekNumber,{week:he,style:j?.[ce.WeekNumber],"aria-label":Xt(he.weekNumber,{locale:p}),className:x[ce.WeekNumber],scope:"row",role:"rowheader"},se(he.weekNumber,m)),he.days.map(Te=>{const{date:Ie}=Te,xe=ze(Te);if(xe[lt.focused]=!xe.hidden&&!!te?.isEqualTo(Te),xe[wn.selected]=X?.(Ie)||xe.selected,co(ne)){const{from:$t,to:vn}=ne;xe[wn.range_start]=!!($t&&vn&&m.isSameDay(Ie,$t)),xe[wn.range_end]=!!($t&&vn&&m.isSameDay(Ie,vn)),xe[wn.range_middle]=da(ne,Ie,!0,m)}const Dt=oC(xe,j,s.modifiersStyles),Kn=Kw(xe,x,s.modifiersClassNames),Nt=!Ln&&!xe.hidden?vt(Ie,xe,m.options,m):void 0;return F.createElement(u.Day,{key:`${Te.isoDate}_${Te.displayMonthId}`,day:Te,modifiers:xe,className:Kn.join(" "),style:Dt,role:"gridcell","aria-selected":xe.selected||void 0,"aria-label":Nt,"data-day":Te.isoDate,"data-month":Te.outside?Te.dateMonthId:void 0,"data-selected":xe.selected||void 0,"data-disabled":xe.disabled||void 0,"data-hidden":xe.hidden||void 0,"data-outside":Te.outside||void 0,"data-focused":xe.focused||void 0,"data-today":xe.today||void 0},!xe.hidden&&Ln?F.createElement(u.DayButton,{className:x[ce.DayButton],style:j?.[ce.DayButton],type:"button",day:Te,modifiers:xe,disabled:!xe.focused&&xe.disabled||void 0,"aria-disabled":xe.focused&&xe.disabled||void 0,tabIndex:fe(Te)?0:-1,"aria-label":yt(Ie,xe,m.options,m),onClick:Yn(Te,xe),onBlur:Tn(Te,xe),onFocus:Va(Te,xe),onKeyDown:An(Te,xe),onMouseEnter:xl(Te,xe),onMouseLeave:cs(Te,xe)},Z(Ie,m.options,m)):!xe.hidden&&Z(Te.date,m.options,m))})))))))),s.footer&&F.createElement(u.Footer,{className:x[ce.Footer],style:j?.[ce.Footer],role:"status","aria-live":"polite"},s.footer)))}function RC({className:a,classNames:s,showOutsideDays:r=!0,...u}){return i.jsx(kC,{showOutsideDays:r,className:G("p-2",a),classNames:{root:"relative",months:"flex flex-col sm:flex-row gap-2 sm:gap-4",month:"flex flex-col gap-2",month_caption:"flex justify-center pt-1 relative items-center h-8",caption_label:"text-sm font-medium",nav:"absolute inset-x-0 top-2 flex items-center justify-between px-1 z-10",button_previous:G(Hr({variant:"ghost"}),"h-7 w-7 bg-transparent p-0 opacity-70 hover:opacity-100 hover:bg-accent rounded-md"),button_next:G(Hr({variant:"ghost"}),"h-7 w-7 bg-transparent p-0 opacity-70 hover:opacity-100 hover:bg-accent rounded-md"),month_grid:"w-full border-collapse",weekdays:"flex w-full",weekday:"text-muted-foreground w-8 font-normal text-xs text-center",weeks:"flex flex-col",week:"flex w-full",day:G("relative h-8 w-8 p-0 text-center text-xs font-normal focus-within:relative focus-within:z-20","hover:bg-accent hover:text-accent-foreground rounded-full select-none"),day_button:G(Hr({variant:"ghost"}),"h-8 w-8 p-0 font-normal rounded-full text-xs","aria-selected:opacity-100"),range_start:G("aria-selected:bg-primary aria-selected:text-primary-foreground","aria-selected:rounded-l-full aria-selected:rounded-r-none","aria-selected:hover:bg-primary aria-selected:hover:text-primary-foreground"),range_end:G("aria-selected:bg-primary aria-selected:text-primary-foreground","aria-selected:rounded-r-full aria-selected:rounded-l-none","aria-selected:hover:bg-primary aria-selected:hover:text-primary-foreground"),range_middle:G("aria-selected:bg-accent aria-selected:text-accent-foreground","aria-selected:rounded-none"),selected:G("bg-primary text-primary-foreground rounded-full","hover:bg-primary hover:text-primary-foreground","focus:bg-primary focus:text-primary-foreground"),today:"bg-accent text-accent-foreground rounded-full",outside:"text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",disabled:"text-muted-foreground opacity-50",hidden:"invisible",...s},components:{Chevron:({orientation:d,className:f,...m})=>{const p=d==="left"?Tb:d==="right"?Wr:d==="up"?Pc:eo;return i.jsx(p,{className:G("h-4 w-4",f),...m})}},...u})}RC.displayName="Calendar";const UC=y.lazy(()=>St(()=>Promise.resolve().then(()=>Nd),void 0).then(a=>({default:a.CodeEditor})));function PE({rawJsonContent:a,isRawJsonValid:s,rawJsonEdits:r,rawSettingsEnv:u,onChange:d,missingRequiredFields:f=[]}){const m=f.length>0;return i.jsx(y.Suspense,{fallback:i.jsxs("div",{className:"flex items-center justify-center h-full",children:[i.jsx(En,{className:"w-6 h-6 animate-spin text-muted-foreground"}),i.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading editor..."})]}),children:i.jsxs("div",{className:"h-full flex flex-col",children:[!s&&r!==null&&i.jsxs("div",{className:"mb-2 px-3 py-2 bg-destructive/10 text-destructive text-sm rounded-md flex items-center gap-2 mx-6 mt-4 shrink-0",children:[i.jsx(os,{className:"w-4 h-4"}),"Invalid JSON syntax"]}),s&&m&&i.jsxs("div",{className:"mb-2 px-3 py-2 bg-warning/10 text-warning-foreground text-sm rounded-md flex items-start gap-2 mx-6 mt-4 shrink-0 border border-warning/20",children:[i.jsx(ma,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Missing required fields:"})," ",i.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:f.join(", ")}),i.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"These fields will use default values at runtime."})]})]}),i.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-4 pt-4",children:i.jsx("div",{className:"h-full border rounded-md overflow-hidden bg-background",children:i.jsx(UC,{value:a,onChange:d,language:"json",minHeight:"100%"})})}),i.jsx("div",{className:"mx-6 mb-4",children:i.jsx("div",{className:"border rounded-md overflow-hidden",children:i.jsx(Sd,{profileEnv:u})})})]})})}function qC(){const[a,s]=y.useState(""),[r,u]=y.useState(""),[d,f]=y.useState(null),[m,p]=y.useState(!1),{login:x,authRequired:b,isAuthenticated:C}=nd(),v=Wc(),M=Zc().state?.from?.pathname||"/";if(y.useEffect(()=>{(C||!b)&&v(M,{replace:!0})},[C,b,v,M]),C||!b)return null;const O=async U=>{U.preventDefault(),f(null),p(!0);try{await x(a,r),v(M,{replace:!0})}catch(_){f(_ instanceof Error?_.message:"Login failed")}finally{p(!1)}};return i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsxs(A2,{className:"w-full max-w-sm",children:[i.jsxs(O2,{className:"space-y-1 text-center",children:[i.jsx("div",{className:"mx-auto mb-2 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:i.jsx(Ab,{className:"h-6 w-6 text-primary"})}),i.jsx(z2,{className:"text-2xl",children:"CCS Dashboard"}),i.jsx(D2,{children:"Enter your credentials to access the dashboard"})]}),i.jsx(_2,{children:i.jsxs("form",{onSubmit:O,className:"space-y-4",children:[d&&i.jsxs(xd,{variant:"destructive",children:[i.jsx(Fc,{className:"h-4 w-4"}),i.jsx(yd,{children:d})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(yn,{htmlFor:"username",children:"Username"}),i.jsx(Rn,{id:"username",type:"text",value:a,onChange:U=>s(U.target.value),placeholder:"Enter username",autoComplete:"username",disabled:m,required:!0})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(yn,{htmlFor:"password",children:"Password"}),i.jsx(Rn,{id:"password",type:"password",value:r,onChange:U=>u(U.target.value),placeholder:"Enter password",autoComplete:"current-password",disabled:m,required:!0})]}),i.jsx(ot,{type:"submit",className:"w-full",disabled:m,children:m?i.jsxs(i.Fragment,{children:[i.jsx(En,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing in..."]}):"Sign In"})]})})]})})}const BC=y.lazy(()=>St(()=>import("./index-CpuTaA7Q.js"),__vite__mapDeps([18,1,2,4,5,7,19,6,8,9])).then(a=>({default:a.AnalyticsPage}))),HC=y.lazy(()=>St(()=>import("./api-Ds2VDoWj.js"),__vite__mapDeps([20,1,2,5,21,15,6,4,22,7,8,9])).then(a=>({default:a.ApiPage}))),LC=y.lazy(()=>St(()=>import("./cliproxy-DlRLzcMc.js"),__vite__mapDeps([23,1,2,5,13,6,4,21,15,22,3,14,7,8,9])).then(a=>({default:a.CliproxyPage}))),YC=y.lazy(()=>St(()=>import("./cliproxy-control-panel-B-Kp16o4.js"),__vite__mapDeps([24,1,2,5,13,4,6,7,8,9])).then(a=>({default:a.CliproxyControlPanelPage}))),GC=y.lazy(()=>St(()=>import("./copilot-CvvfxmsM.js"),__vite__mapDeps([25,1,2,5,21,15,4,22,3,6,7,8,9])).then(a=>({default:a.CopilotPage}))),KC=y.lazy(()=>St(()=>import("./cursor-BJDbE6ri.js"),__vite__mapDeps([26,1,2,6,5,13,3,22,4,7,8,9])).then(a=>({default:a.CursorPage}))),QC=y.lazy(()=>St(()=>import("./accounts-CDMbYhoK.js"),__vite__mapDeps([27,1,2,5,15,6,4,7,8,9])).then(a=>({default:a.AccountsPage}))),VC=y.lazy(()=>St(()=>Promise.resolve().then(()=>lw),void 0).then(a=>({default:a.SettingsPage}))),XC=y.lazy(()=>St(()=>import("./health-C-UMxtTO.js"),__vite__mapDeps([28,1,2,5,6,4,7,8,9])).then(a=>({default:a.HealthPage}))),ZC=y.lazy(()=>St(()=>import("./shared-Pb8lecSN.js"),__vite__mapDeps([29,1,2,4,5,6,7,8,9])).then(a=>({default:a.SharedPage})));function kn(){return i.jsx("div",{className:"flex h-64 items-center justify-center",children:i.jsx(En,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}function WC(){return i.jsx($v,{client:jS,children:i.jsx(CS,{defaultTheme:"system",storageKey:"vite-ui-theme",children:i.jsx(ES,{children:i.jsx(zS,{children:i.jsxs(Xv,{children:[i.jsxs(Zv,{children:[i.jsx(Gt,{path:"/login",element:i.jsx(qC,{})}),i.jsx(Gt,{element:i.jsx(DS,{}),children:i.jsxs(Gt,{element:i.jsx(iN,{}),children:[i.jsx(Gt,{path:"/",element:i.jsx(l2,{})}),i.jsx(Gt,{path:"/analytics",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(BC,{})})}),i.jsx(Gt,{path:"/providers",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(HC,{})})}),i.jsx(Gt,{path:"/cliproxy",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(LC,{})})}),i.jsx(Gt,{path:"/cliproxy/control-panel",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(YC,{})})}),i.jsx(Gt,{path:"/copilot",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(GC,{})})}),i.jsx(Gt,{path:"/cursor",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(KC,{})})}),i.jsx(Gt,{path:"/accounts",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(QC,{})})}),i.jsx(Gt,{path:"/settings",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(VC,{})})}),i.jsx(Gt,{path:"/health",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(XC,{})})}),i.jsx(Gt,{path:"/shared",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(ZC,{})})})]})})]}),i.jsx(Jv,{position:"top-right"})]})})})})})}const Ix=document.getElementById("root");if(!Ix)throw new Error("Root element not found. Failed to mount React application.");bS.createRoot(Ix).render(i.jsx(y.StrictMode,{children:i.jsx(WC,{})}));export{H2 as $,g2 as A,Ya as B,A2 as C,kE as D,M1 as E,T1 as F,A1 as G,jx as H,Rn as I,vd as J,Xr as K,yn as L,Qc as M,qE as N,D2 as O,Vg as P,HE as Q,BE as R,Le as S,Ga as T,LE as U,Ex as V,YE as W,QE as X,U2 as Y,XE as Z,q2 as _,_2 as a,wE as a$,j1 as a0,rE as a1,hE as a2,pE as a3,id as a4,rd as a5,od as a6,ud as a7,cd as a8,GE as a9,xE as aA,yE as aB,vE as aC,bE as aD,ZE as aE,iE as aF,E1 as aG,uE as aH,cE as aI,w1 as aJ,C1 as aK,dE as aL,fE as aM,mE as aN,oE as aO,xd as aP,Nx as aQ,yd as aR,ui as aS,lE as aT,sE as aU,PE as aV,t2 as aW,DE as aX,zx as aY,I2 as aZ,ew as a_,R2 as aa,KE as ab,uN as ac,TE as ad,Ze as ae,OE as af,gE as ag,zE as ah,Rp as ai,AE as aj,VE as ak,B2 as al,Z1 as am,BN as an,XS as ao,ZS as ap,lo as aq,ao as ar,ml as as,I1 as at,F1 as au,eN as av,tN as aw,G2 as ax,HN as ay,tx as az,ot as b,SE as b0,CE as b1,NE as b2,jE as b3,ME as b4,EE as b5,Hr as b6,G as c,WE as d,$E as e,sw as f,RC as g,aE as h,O2 as i,z2 as j,TN as k,AN as l,gl as m,JE as n,Ka as o,Qa as p,Xp as q,v2 as r,UE as s,u2 as t,ed as u,p2 as v,_E as w,RE as x,i2 as y,m2 as z};
47
+ `);return{valid:!1,error:u,line:m.length}}return{valid:!1,error:u}}}function Ax({value:a,onChange:s,language:r="json",readonly:u=!1,className:d,minHeight:f="300px"}){const{isDark:m}=Jg(),[p,x]=y.useState(!1),[b,C]=y.useState(!0),v=y.useMemo(()=>r==="json"?W2(a):{valid:!0},[a,r]),S=y.useCallback(M=>i.jsx(pS,{theme:m?Cp.nightOwl:Cp.github,code:M,language:r,children:({tokens:O,getLineProps:U,getTokenProps:_})=>{let T=!1;return i.jsx(i.Fragment,{children:O.map((K,B)=>i.jsx("div",{...U({line:K}),className:G(v.line===B+1&&"bg-destructive/20"),children:K.map((L,k)=>{let j=!1;if(L.types.includes("property")){const Z=L.content.replace(/['"]/g,"");Z2(Z)?T=!0:T=!1}else(L.types.includes("string")||L.types.includes("number")||L.types.includes("boolean"))&&T?(j=!0,T=!1):L.types.includes("punctuation")&&L.content!==":"&&L.content!=="["&&L.content!=="{"&&(T=!1);const H=_({token:L});return j&&b&&(H.className=G(H.className,"blur-[3px] select-none opacity-70 transition-all duration-200")),i.jsx("span",{...H},k)})},B))})}}),[m,r,v.line,b]);return i.jsxs("div",{className:G("flex flex-col",d),children:[i.jsxs("div",{className:G("relative rounded-md border overflow-hidden","bg-muted/30",p&&"ring-2 ring-ring ring-offset-2 ring-offset-background",u&&"opacity-70 cursor-not-allowed",!v.valid&&"border-destructive"),style:{minHeight:f},children:[i.jsx(V2,{value:a,onValueChange:u?()=>{}:s,highlight:S,padding:12,disabled:u,onFocus:()=>x(!0),onBlur:()=>x(!1),textareaClassName:G("focus:outline-none font-mono text-sm",u&&"cursor-not-allowed"),preClassName:"font-mono text-sm",style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:"0.875rem",minHeight:f}},m?"dark-editor":"light-editor"),i.jsx("div",{className:"absolute top-2 right-2 z-10 opacity-50 hover:opacity-100 transition-opacity",children:i.jsx(ot,{variant:"ghost",size:"icon",className:"h-6 w-6 bg-background/50 hover:bg-background border shadow-sm rounded-full",onClick:()=>C(!b),title:b?"Reveal sensitive values":"Mask sensitive values",children:b?i.jsx(Jr,{className:"h-3 w-3"}):i.jsx($r,{className:"h-3 w-3"})})})]}),i.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs",children:[v.valid?i.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[i.jsx(Pr,{className:"w-3 h-3 text-green-500"}),"Valid ",r.toUpperCase()]}):i.jsxs("span",{className:"flex items-center gap-1 text-destructive",children:[i.jsx(Fc,{className:"w-3 h-3"}),v.error,v.line&&` (line ${v.line})`]}),u&&i.jsx("span",{className:"ml-auto text-muted-foreground",children:"(Read-only)"})]})]})}const Nd=Object.freeze(Object.defineProperty({__proto__:null,CodeEditor:Ax},Symbol.toStringTag,{value:"Module"})),$2={webSearchConfig:null,webSearchStatus:null,webSearchLoading:!0,webSearchStatusLoading:!0,webSearchSaving:!1,webSearchError:null,webSearchSuccess:!1,globalEnvConfig:null,globalEnvLoading:!0,globalEnvSaving:!1,globalEnvError:null,globalEnvSuccess:!1,proxyConfig:null,proxyLoading:!0,proxySaving:!1,proxyError:null,proxySuccess:!1,proxyTestResult:null,proxyTesting:!1,rawConfig:null,rawConfigLoading:!1};function J2(a,s){switch(s.type){case"SET_WEBSEARCH_CONFIG":return{...a,webSearchConfig:s.payload};case"SET_WEBSEARCH_STATUS":return{...a,webSearchStatus:s.payload};case"SET_WEBSEARCH_LOADING":return{...a,webSearchLoading:s.payload};case"SET_WEBSEARCH_STATUS_LOADING":return{...a,webSearchStatusLoading:s.payload};case"SET_WEBSEARCH_SAVING":return{...a,webSearchSaving:s.payload};case"SET_WEBSEARCH_ERROR":return{...a,webSearchError:s.payload};case"SET_WEBSEARCH_SUCCESS":return{...a,webSearchSuccess:s.payload};case"SET_GLOBALENV_CONFIG":return{...a,globalEnvConfig:s.payload};case"SET_GLOBALENV_LOADING":return{...a,globalEnvLoading:s.payload};case"SET_GLOBALENV_SAVING":return{...a,globalEnvSaving:s.payload};case"SET_GLOBALENV_ERROR":return{...a,globalEnvError:s.payload};case"SET_GLOBALENV_SUCCESS":return{...a,globalEnvSuccess:s.payload};case"SET_PROXY_CONFIG":return{...a,proxyConfig:s.payload};case"SET_PROXY_LOADING":return{...a,proxyLoading:s.payload};case"SET_PROXY_SAVING":return{...a,proxySaving:s.payload};case"SET_PROXY_ERROR":return{...a,proxyError:s.payload};case"SET_PROXY_SUCCESS":return{...a,proxySuccess:s.payload};case"SET_PROXY_TEST_RESULT":return{...a,proxyTestResult:s.payload};case"SET_PROXY_TESTING":return{...a,proxyTesting:s.payload};case"SET_RAW_CONFIG":return{...a,rawConfig:s.payload};case"SET_RAW_CONFIG_LOADING":return{...a,rawConfigLoading:s.payload};default:return a}}const Ox=y.createContext(null);function P2({children:a}){const[s,r]=y.useReducer(J2,$2);return i.jsx(Ox.Provider,{value:{state:s,dispatch:r},children:a})}function zx(){const a=y.useContext(Ox);if(!a)throw new Error("useSettingsContext must be used within a SettingsProvider");return a}function I2(){const{dispatch:a}=zx(),s=y.useCallback(j=>a({type:"SET_WEBSEARCH_CONFIG",payload:j}),[a]),r=y.useCallback(j=>a({type:"SET_WEBSEARCH_STATUS",payload:j}),[a]),u=y.useCallback(j=>a({type:"SET_WEBSEARCH_LOADING",payload:j}),[a]),d=y.useCallback(j=>a({type:"SET_WEBSEARCH_STATUS_LOADING",payload:j}),[a]),f=y.useCallback(j=>a({type:"SET_WEBSEARCH_SAVING",payload:j}),[a]),m=y.useCallback(j=>a({type:"SET_WEBSEARCH_ERROR",payload:j}),[a]),p=y.useCallback(j=>a({type:"SET_WEBSEARCH_SUCCESS",payload:j}),[a]),x=y.useCallback(j=>a({type:"SET_GLOBALENV_CONFIG",payload:j}),[a]),b=y.useCallback(j=>a({type:"SET_GLOBALENV_LOADING",payload:j}),[a]),C=y.useCallback(j=>a({type:"SET_GLOBALENV_SAVING",payload:j}),[a]),v=y.useCallback(j=>a({type:"SET_GLOBALENV_ERROR",payload:j}),[a]),S=y.useCallback(j=>a({type:"SET_GLOBALENV_SUCCESS",payload:j}),[a]),M=y.useCallback(j=>a({type:"SET_PROXY_CONFIG",payload:j}),[a]),O=y.useCallback(j=>a({type:"SET_PROXY_LOADING",payload:j}),[a]),U=y.useCallback(j=>a({type:"SET_PROXY_SAVING",payload:j}),[a]),_=y.useCallback(j=>a({type:"SET_PROXY_ERROR",payload:j}),[a]),T=y.useCallback(j=>a({type:"SET_PROXY_SUCCESS",payload:j}),[a]),K=y.useCallback(j=>a({type:"SET_PROXY_TEST_RESULT",payload:j}),[a]),B=y.useCallback(j=>a({type:"SET_PROXY_TESTING",payload:j}),[a]),L=y.useCallback(j=>a({type:"SET_RAW_CONFIG",payload:j}),[a]),k=y.useCallback(j=>a({type:"SET_RAW_CONFIG_LOADING",payload:j}),[a]);return y.useMemo(()=>({setWebSearchConfig:s,setWebSearchStatus:r,setWebSearchLoading:u,setWebSearchStatusLoading:d,setWebSearchSaving:f,setWebSearchError:m,setWebSearchSuccess:p,setGlobalEnvConfig:x,setGlobalEnvLoading:b,setGlobalEnvSaving:C,setGlobalEnvError:v,setGlobalEnvSuccess:S,setProxyConfig:M,setProxyLoading:O,setProxySaving:U,setProxyError:_,setProxySuccess:T,setProxyTestResult:K,setProxyTesting:B,setRawConfig:L,setRawConfigLoading:k}),[s,r,u,d,f,m,p,x,b,C,v,S,M,O,U,_,T,K,B,L,k])}function F2(){const[a,s]=Vv(),r=a.get("tab")?.toLowerCase(),u=r==="globalenv"?"globalenv":r==="proxy"?"proxy":r==="auth"?"auth":r==="thinking"?"thinking":r==="backups"?"backups":"websearch",d=y.useCallback(f=>{s({tab:f},{replace:!0})},[s]);return{activeTab:u,setActiveTab:d}}function ew(){const{state:a}=zx(),s=I2(),[r,u]=y.useState(!1),d=y.useCallback(async()=>{try{s.setRawConfigLoading(!0);const m=await fetch("/api/config/raw");if(!m.ok){s.setRawConfig(null);return}const p=await m.text();s.setRawConfig(p)}catch{s.setRawConfig(null)}finally{s.setRawConfigLoading(!1)}},[s]),f=y.useCallback(async()=>{if(a.rawConfig)try{await navigator.clipboard.writeText(a.rawConfig),u(!0),setTimeout(()=>u(!1),2e3)}catch{}},[a.rawConfig]);return{rawConfig:a.rawConfig,loading:a.rawConfigLoading,copied:r,fetchRawConfig:d,copyToClipboard:f}}const tw=[{value:"websearch",label:"Web",icon:wb},{value:"globalenv",label:"Env",icon:Ic},{value:"thinking",label:"Think",icon:Cb},{value:"proxy",label:"Proxy",icon:Eb},{value:"auth",label:"Auth",icon:$c},{value:"backups",label:"Backup",icon:Mb}];function Fp({activeTab:a,onTabChange:s}){return i.jsx(jx,{value:a,onValueChange:r=>s(r),children:i.jsx(vd,{className:"grid w-full grid-cols-6",children:tw.map(({value:r,label:u,icon:d})=>i.jsxs(Xr,{value:r,className:"gap-1.5 px-1 text-xs",children:[i.jsx(d,{className:"h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"truncate",children:u})]},r))})})}function eg(){return i.jsxs("div",{className:"flex-1 p-5 space-y-6",children:[i.jsx(Le,{className:"h-4 w-2/3"}),i.jsx("div",{className:"p-4 rounded-lg border",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(Le,{className:"h-5 w-32"}),i.jsx(Le,{className:"h-4 w-48"})]}),i.jsx(Le,{className:"h-6 w-10 rounded-full"})]})}),i.jsxs("div",{className:"space-y-3",children:[i.jsx(Le,{className:"h-5 w-24"}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Le,{className:"h-20 w-full rounded-lg"}),i.jsx(Le,{className:"h-20 w-full rounded-lg"}),i.jsx(Le,{className:"h-20 w-full rounded-lg"})]})]})]})}function Dx(a,s=3,r=1e3){return a().catch(u=>{if(s<=0)throw u;return new Promise(d=>setTimeout(d,r)).then(()=>Dx(a,s-1,r*2))})}function us(a){return y.lazy(()=>Dx(a))}const tg=us(()=>St(()=>import("./index-CGtzFO3I.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),ng=us(()=>St(()=>import("./globalenv-section-DnqCBQbR.js"),__vite__mapDeps([10,1,2,3,4,5,6,7,8,9]))),ag=us(()=>St(()=>import("./index-ruOt2xfd.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8,9]))),lg=us(()=>St(()=>import("./index-KmxTWV7G.js"),__vite__mapDeps([12,1,2,3,13,4,14,15,5,6,7,8,9]))),sg=us(()=>St(()=>import("./auth-section-CswsImgo.js"),__vite__mapDeps([16,1,2,4,5,6,7,8,9]))),ig=us(()=>St(()=>import("./backups-section-N3-QDA1f.js"),__vite__mapDeps([17,1,2,15,4,5,6,7,8,9])));class rg extends y.Component{constructor(s){super(s),this.state={hasError:!1,error:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}render(){return this.state.hasError?i.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:i.jsxs("div",{className:"text-center p-6 max-w-md",children:[i.jsx(Fc,{className:"w-12 h-12 mx-auto mb-4 text-destructive"}),i.jsx("p",{className:"font-medium text-foreground mb-2",children:"Failed to load section"}),i.jsx("p",{className:"text-sm mb-4",children:this.state.error?.message||"Unknown error occurred"}),i.jsxs(ot,{variant:"outline",onClick:()=>window.location.reload(),className:"inline-flex items-center gap-2",children:[i.jsx(pi,{className:"w-4 h-4"}),"Reload page"]})]})}):this.props.children}}function nw(){const{activeTab:a,setActiveTab:s}=F2(),{rawConfig:r,loading:u,copied:d,fetchRawConfig:f,copyToClipboard:m}=ew();y.useEffect(()=>{f()},[f]);const p=x=>{y.startTransition(()=>{s(x)})};return i.jsxs("div",{className:"h-[calc(100vh-100px)]",children:[i.jsxs("div",{className:"md:hidden h-full flex flex-col",children:[i.jsx("div",{className:"border-b bg-background p-4",children:i.jsx(Fp,{activeTab:a,onTabChange:p})}),i.jsx(rg,{children:i.jsxs(y.Suspense,{fallback:i.jsx(eg,{}),children:[a==="websearch"&&i.jsx(tg,{}),a==="globalenv"&&i.jsx(ng,{}),a==="thinking"&&i.jsx(ag,{}),a==="proxy"&&i.jsx(lg,{}),a==="auth"&&i.jsx(sg,{}),a==="backups"&&i.jsx(ig,{})]})})]}),i.jsxs(pd,{direction:"horizontal",className:"h-full hidden md:flex",children:[i.jsx(xi,{defaultSize:40,minSize:30,maxSize:55,children:i.jsxs("div",{className:"h-full border-r flex flex-col bg-muted/30 relative",children:[i.jsx("div",{className:"p-5 border-b bg-background",children:i.jsx(Fp,{activeTab:a,onTabChange:p})}),i.jsx(rg,{children:i.jsxs(y.Suspense,{fallback:i.jsx(eg,{}),children:[a==="websearch"&&i.jsx(tg,{}),a==="globalenv"&&i.jsx(ng,{}),a==="thinking"&&i.jsx(ag,{}),a==="proxy"&&i.jsx(lg,{}),a==="auth"&&i.jsx(sg,{}),a==="backups"&&i.jsx(ig,{})]})})]})}),i.jsx(gd,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:i.jsx(Ir,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),i.jsx(xi,{defaultSize:60,minSize:35,children:i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"p-4 border-b bg-background flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Np,{className:"w-5 h-5 text-primary"}),i.jsxs("div",{children:[i.jsx("h2",{className:"font-semibold",children:"config.yaml"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"~/.ccs/config.yaml"})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(ot,{variant:"outline",size:"sm",onClick:m,disabled:!r,children:d?i.jsxs(i.Fragment,{children:[i.jsx(rs,{className:"w-4 h-4 mr-1"}),"Copied"]}):i.jsxs(i.Fragment,{children:[i.jsx(Gr,{className:"w-4 h-4 mr-1"}),"Copy"]})}),i.jsx(ot,{variant:"outline",size:"sm",onClick:f,disabled:u,children:i.jsx(pi,{className:`w-4 h-4 ${u?"animate-spin":""}`})})]})]}),i.jsx("div",{className:"flex-1 overflow-auto",children:u?i.jsxs("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:[i.jsx(pi,{className:"w-5 h-5 animate-spin mr-2"}),"Loading..."]}):r?i.jsx(Ax,{value:r,onChange:()=>{},language:"yaml",readonly:!0,minHeight:"auto",className:"min-h-full"}):i.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:i.jsxs("div",{className:"text-center",children:[i.jsx(Np,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),i.jsx("p",{children:"Config file not found"}),i.jsx("code",{className:"text-sm bg-muted px-2 py-1 rounded mt-2 inline-block",children:"ccs migrate"})]})})})]})})]})]})}function aw(){return i.jsx(P2,{children:i.jsx(nw,{})})}const lw=Object.freeze(Object.defineProperty({__proto__:null,SettingsPage:aw},Symbol.toStringTag,{value:"Module"})),WE=Bv,$E=Lv,JE=Hv,sw=y.forwardRef(({className:a,align:s="center",sideOffset:r=4,...u},d)=>i.jsx(qv,{children:i.jsx(kg,{ref:d,align:s,sideOffset:r,className:G("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",a),...u})}));sw.displayName=kg.displayName;function iw(a,s,r="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:a,timeZoneName:r}).format(s).split(/\s/g).slice(2).join(" ")}const rw={},fi={};function fl(a,s){try{const u=(rw[a]||=new Intl.DateTimeFormat("en-US",{timeZone:a,timeZoneName:"longOffset"}).format)(s).split("GMT")[1];return u in fi?fi[u]:og(u,u.split(":"))}catch{if(a in fi)return fi[a];const r=a?.match(ow);return r?og(a,r.slice(1)):NaN}}const ow=/([+-]\d\d):?(\d\d)?/;function og(a,s){const r=+(s[0]||0),u=+(s[1]||0),d=+(s[2]||0)/60;return fi[a]=r*60+u>0?r*60+u+d:r*60-u-d}class qn extends Date{constructor(...s){super(),s.length>1&&typeof s[s.length-1]=="string"&&(this.timeZone=s.pop()),this.internal=new Date,isNaN(fl(this.timeZone,this))?this.setTime(NaN):s.length?typeof s[0]=="number"&&(s.length===1||s.length===2&&typeof s[1]!="number")?this.setTime(s[0]):typeof s[0]=="string"?this.setTime(+new Date(s[0])):s[0]instanceof Date?this.setTime(+s[0]):(this.setTime(+new Date(...s)),_x(this),Xc(this)):this.setTime(Date.now())}static tz(s,...r){return r.length?new qn(...r,s):new qn(Date.now(),s)}withTimeZone(s){return new qn(+this,s)}getTimezoneOffset(){const s=-fl(this.timeZone,this);return s>0?Math.floor(s):Math.ceil(s)}setTime(s){return Date.prototype.setTime.apply(this,arguments),Xc(this),+this}[Symbol.for("constructDateFrom")](s){return new qn(+new Date(s),this.timeZone)}}const ug=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(a=>{if(!ug.test(a))return;const s=a.replace(ug,"$1UTC");qn.prototype[s]&&(a.startsWith("get")?qn.prototype[a]=function(){return this.internal[s]()}:(qn.prototype[a]=function(){return Date.prototype[s].apply(this.internal,arguments),uw(this),+this},qn.prototype[s]=function(){return Date.prototype[s].apply(this,arguments),Xc(this),+this}))});function Xc(a){a.internal.setTime(+a),a.internal.setUTCSeconds(a.internal.getUTCSeconds()-Math.round(-fl(a.timeZone,a)*60))}function uw(a){Date.prototype.setFullYear.call(a,a.internal.getUTCFullYear(),a.internal.getUTCMonth(),a.internal.getUTCDate()),Date.prototype.setHours.call(a,a.internal.getUTCHours(),a.internal.getUTCMinutes(),a.internal.getUTCSeconds(),a.internal.getUTCMilliseconds()),_x(a)}function _x(a){const s=fl(a.timeZone,a),r=s>0?Math.floor(s):Math.ceil(s),u=new Date(+a);u.setUTCHours(u.getUTCHours()-1);const d=-new Date(+a).getTimezoneOffset(),f=-new Date(+u).getTimezoneOffset(),m=d-f,p=Date.prototype.getHours.apply(a)!==a.internal.getUTCHours();m&&p&&a.internal.setUTCMinutes(a.internal.getUTCMinutes()+m);const x=d-r;x&&Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+x);const b=new Date(+a);b.setUTCSeconds(0);const C=d>0?b.getSeconds():(b.getSeconds()-60)%60,v=Math.round(-(fl(a.timeZone,a)*60))%60;(v||C)&&(a.internal.setUTCSeconds(a.internal.getUTCSeconds()+v),Date.prototype.setUTCSeconds.call(a,Date.prototype.getUTCSeconds.call(a)+v+C));const S=fl(a.timeZone,a),M=S>0?Math.floor(S):Math.ceil(S),U=-new Date(+a).getTimezoneOffset()-M,_=M!==r,T=U-x;if(_&&T){Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+T);const K=fl(a.timeZone,a),B=K>0?Math.floor(K):Math.ceil(K),L=M-B;L&&(a.internal.setUTCMinutes(a.internal.getUTCMinutes()+L),Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+L))}}class ca extends qn{static tz(s,...r){return r.length?new ca(...r,s):new ca(Date.now(),s)}toISOString(){const[s,r,u]=this.tzComponents(),d=`${s}${r}:${u}`;return this.internal.toISOString().slice(0,-1)+d}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[s,r,u,d]=this.internal.toUTCString().split(" ");return`${s?.slice(0,-1)} ${u} ${r} ${d}`}toTimeString(){const s=this.internal.toUTCString().split(" ")[4],[r,u,d]=this.tzComponents();return`${s} GMT${r}${u}${d} (${iw(this.timeZone,this)})`}toLocaleString(s,r){return Date.prototype.toLocaleString.call(this,s,{...r,timeZone:r?.timeZone||this.timeZone})}toLocaleDateString(s,r){return Date.prototype.toLocaleDateString.call(this,s,{...r,timeZone:r?.timeZone||this.timeZone})}toLocaleTimeString(s,r){return Date.prototype.toLocaleTimeString.call(this,s,{...r,timeZone:r?.timeZone||this.timeZone})}tzComponents(){const s=this.getTimezoneOffset(),r=s>0?"-":"+",u=String(Math.floor(Math.abs(s)/60)).padStart(2,"0"),d=String(Math.abs(s)%60).padStart(2,"0");return[r,u,d]}withTimeZone(s){return new ca(+this,s)}[Symbol.for("constructDateFrom")](s){return new ca(+new Date(s),this.timeZone)}}const cg=5,cw=4;function dw(a,s){const r=s.startOfMonth(a),u=r.getDay()>0?r.getDay():7,d=s.addDays(a,-u+1),f=s.addDays(d,cg*7-1);return s.getMonth(a)===s.getMonth(f)?cg:cw}function kx(a,s){const r=s.startOfMonth(a),u=r.getDay();return u===1?r:u===0?s.addDays(r,-6):s.addDays(r,-1*(u-1))}function fw(a,s){const r=kx(a,s),u=dw(a,s);return s.addDays(r,u*7-1)}const Rx={...si,labels:{labelDayButton:(a,s,r,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(m,p)=>oi(m,p,{locale:si,...r});let f=d(a,"PPPP");return s.today&&(f=`Today, ${f}`),s.selected&&(f=`${f}, selected`),f},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:a=>`Week ${a}`,labelYearDropdown:"Choose the Year",labelGrid:(a,s,r)=>{let u;return r&&typeof r.format=="function"?u=r.format.bind(r):u=(d,f)=>oi(d,f,{locale:si,...s}),u(a,"LLLL yyyy")},labelGridcell:(a,s,r,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(m,p)=>oi(m,p,{locale:si,...r});let f=d(a,"PPPP");return s?.today&&(f=`Today, ${f}`),f},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(a,s,r)=>{let u;return r&&typeof r.format=="function"?u=r.format.bind(r):u=(d,f)=>oi(d,f,{locale:si,...s}),u(a,"cccc")}}};class sn{constructor(s,r){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?ca.tz(this.options.timeZone):new this.Date,this.newDate=(u,d,f)=>this.overrides?.newDate?this.overrides.newDate(u,d,f):this.options.timeZone?new ca(u,d,f,this.options.timeZone):new Date(u,d,f),this.addDays=(u,d)=>this.overrides?.addDays?this.overrides.addDays(u,d):Db(u,d),this.addMonths=(u,d)=>this.overrides?.addMonths?this.overrides.addMonths(u,d):_b(u,d),this.addWeeks=(u,d)=>this.overrides?.addWeeks?this.overrides.addWeeks(u,d):kb(u,d),this.addYears=(u,d)=>this.overrides?.addYears?this.overrides.addYears(u,d):Rb(u,d),this.differenceInCalendarDays=(u,d)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(u,d):Ub(u,d),this.differenceInCalendarMonths=(u,d)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(u,d):qb(u,d),this.eachMonthOfInterval=u=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(u):Bb(u),this.eachYearOfInterval=u=>{const d=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(u):Hb(u),f=new Set(d.map(p=>this.getYear(p)));if(f.size===d.length)return d;const m=[];return f.forEach(p=>{m.push(new Date(p,0,1))}),m},this.endOfBroadcastWeek=u=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(u):fw(u,this),this.endOfISOWeek=u=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(u):Lb(u),this.endOfMonth=u=>this.overrides?.endOfMonth?this.overrides.endOfMonth(u):Yb(u),this.endOfWeek=(u,d)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(u,d):Gb(u,this.options),this.endOfYear=u=>this.overrides?.endOfYear?this.overrides.endOfYear(u):Kb(u),this.format=(u,d,f)=>{const m=this.overrides?.format?this.overrides.format(u,d,this.options):oi(u,d,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(m):m},this.getISOWeek=u=>this.overrides?.getISOWeek?this.overrides.getISOWeek(u):Qb(u),this.getMonth=(u,d)=>this.overrides?.getMonth?this.overrides.getMonth(u,this.options):Vb(u,this.options),this.getYear=(u,d)=>this.overrides?.getYear?this.overrides.getYear(u,this.options):Xb(u,this.options),this.getWeek=(u,d)=>this.overrides?.getWeek?this.overrides.getWeek(u,this.options):Zb(u,this.options),this.isAfter=(u,d)=>this.overrides?.isAfter?this.overrides.isAfter(u,d):Wb(u,d),this.isBefore=(u,d)=>this.overrides?.isBefore?this.overrides.isBefore(u,d):$b(u,d),this.isDate=u=>this.overrides?.isDate?this.overrides.isDate(u):Jb(u),this.isSameDay=(u,d)=>this.overrides?.isSameDay?this.overrides.isSameDay(u,d):Pb(u,d),this.isSameMonth=(u,d)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(u,d):Ib(u,d),this.isSameYear=(u,d)=>this.overrides?.isSameYear?this.overrides.isSameYear(u,d):Fb(u,d),this.max=u=>this.overrides?.max?this.overrides.max(u):eS(u),this.min=u=>this.overrides?.min?this.overrides.min(u):tS(u),this.setMonth=(u,d)=>this.overrides?.setMonth?this.overrides.setMonth(u,d):nS(u,d),this.setYear=(u,d)=>this.overrides?.setYear?this.overrides.setYear(u,d):aS(u,d),this.startOfBroadcastWeek=(u,d)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(u,this):kx(u,this),this.startOfDay=u=>this.overrides?.startOfDay?this.overrides.startOfDay(u):lS(u),this.startOfISOWeek=u=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(u):sS(u),this.startOfMonth=u=>this.overrides?.startOfMonth?this.overrides.startOfMonth(u):iS(u),this.startOfWeek=(u,d)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(u,this.options):rS(u,this.options),this.startOfYear=u=>this.overrides?.startOfYear?this.overrides.startOfYear(u):oS(u),this.options={locale:Rx,...s},this.overrides=r}getDigitMap(){const{numerals:s="latn"}=this.options,r=new Intl.NumberFormat("en-US",{numberingSystem:s}),u={};for(let d=0;d<10;d++)u[d.toString()]=r.format(d);return u}replaceDigits(s){const r=this.getDigitMap();return s.replace(/\d/g,u=>r[u]||u)}formatNumber(s){return this.replaceDigits(s.toString())}getMonthYearOrder(){const s=this.options.locale?.code;return s&&sn.yearFirstLocales.has(s)?"year-first":"month-first"}formatMonthYear(s){const{locale:r,timeZone:u,numerals:d}=this.options,f=r?.code;if(f&&sn.yearFirstLocales.has(f))try{return new Intl.DateTimeFormat(f,{month:"long",year:"numeric",timeZone:u,numberingSystem:d}).format(s)}catch{}const m=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(s,m)}}sn.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const Bn=new sn;class Ux{constructor(s,r,u=Bn){this.date=s,this.displayMonth=r,this.outside=!!(r&&!u.isSameMonth(s,r)),this.dateLib=u,this.isoDate=u.format(s,"yyyy-MM-dd"),this.displayMonthId=u.format(r,"yyyy-MM"),this.dateMonthId=u.format(s,"yyyy-MM")}isEqualTo(s){return this.dateLib.isSameDay(s.date,this.date)&&this.dateLib.isSameMonth(s.displayMonth,this.displayMonth)}}class mw{constructor(s,r){this.date=s,this.weeks=r}}class hw{constructor(s,r){this.days=r,this.weekNumber=s}}function pw(a){return F.createElement("button",{...a})}function gw(a){return F.createElement("span",{...a})}function xw(a){const{size:s=24,orientation:r="left",className:u}=a;return F.createElement("svg",{className:u,width:s,height:s,viewBox:"0 0 24 24"},r==="up"&&F.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),r==="down"&&F.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),r==="left"&&F.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),r==="right"&&F.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function yw(a){const{day:s,modifiers:r,...u}=a;return F.createElement("td",{...u})}function vw(a){const{day:s,modifiers:r,...u}=a,d=F.useRef(null);return F.useEffect(()=>{r.focused&&d.current?.focus()},[r.focused]),F.createElement("button",{ref:d,...u})}var ce;(function(a){a.Root="root",a.Chevron="chevron",a.Day="day",a.DayButton="day_button",a.CaptionLabel="caption_label",a.Dropdowns="dropdowns",a.Dropdown="dropdown",a.DropdownRoot="dropdown_root",a.Footer="footer",a.MonthGrid="month_grid",a.MonthCaption="month_caption",a.MonthsDropdown="months_dropdown",a.Month="month",a.Months="months",a.Nav="nav",a.NextMonthButton="button_next",a.PreviousMonthButton="button_previous",a.Week="week",a.Weeks="weeks",a.Weekday="weekday",a.Weekdays="weekdays",a.WeekNumber="week_number",a.WeekNumberHeader="week_number_header",a.YearsDropdown="years_dropdown"})(ce||(ce={}));var lt;(function(a){a.disabled="disabled",a.hidden="hidden",a.outside="outside",a.focused="focused",a.today="today"})(lt||(lt={}));var wn;(function(a){a.range_end="range_end",a.range_middle="range_middle",a.range_start="range_start",a.selected="selected"})(wn||(wn={}));var ln;(function(a){a.weeks_before_enter="weeks_before_enter",a.weeks_before_exit="weeks_before_exit",a.weeks_after_enter="weeks_after_enter",a.weeks_after_exit="weeks_after_exit",a.caption_after_enter="caption_after_enter",a.caption_after_exit="caption_after_exit",a.caption_before_enter="caption_before_enter",a.caption_before_exit="caption_before_exit"})(ln||(ln={}));function bw(a){const{options:s,className:r,components:u,classNames:d,...f}=a,m=[d[ce.Dropdown],r].join(" "),p=s?.find(({value:x})=>x===f.value);return F.createElement("span",{"data-disabled":f.disabled,className:d[ce.DropdownRoot]},F.createElement(u.Select,{className:m,...f},s?.map(({value:x,label:b,disabled:C})=>F.createElement(u.Option,{key:x,value:x,disabled:C},b))),F.createElement("span",{className:d[ce.CaptionLabel],"aria-hidden":!0},p?.label,F.createElement(u.Chevron,{orientation:"down",size:18,className:d[ce.Chevron]})))}function Sw(a){return F.createElement("div",{...a})}function Nw(a){return F.createElement("div",{...a})}function jw(a){const{calendarMonth:s,displayIndex:r,...u}=a;return F.createElement("div",{...u},a.children)}function ww(a){const{calendarMonth:s,displayIndex:r,...u}=a;return F.createElement("div",{...u})}function Cw(a){return F.createElement("table",{...a})}function Ew(a){return F.createElement("div",{...a})}const qx=y.createContext(void 0);function bi(){const a=y.useContext(qx);if(a===void 0)throw new Error("useDayPicker() must be used within a custom component.");return a}function Mw(a){const{components:s}=bi();return F.createElement(s.Dropdown,{...a})}function Tw(a){const{onPreviousClick:s,onNextClick:r,previousMonth:u,nextMonth:d,...f}=a,{components:m,classNames:p,labels:{labelPrevious:x,labelNext:b}}=bi(),C=y.useCallback(S=>{d&&r?.(S)},[d,r]),v=y.useCallback(S=>{u&&s?.(S)},[u,s]);return F.createElement("nav",{...f},F.createElement(m.PreviousMonthButton,{type:"button",className:p[ce.PreviousMonthButton],tabIndex:u?void 0:-1,"aria-disabled":u?void 0:!0,"aria-label":x(u),onClick:v},F.createElement(m.Chevron,{disabled:u?void 0:!0,className:p[ce.Chevron],orientation:"left"})),F.createElement(m.NextMonthButton,{type:"button",className:p[ce.NextMonthButton],tabIndex:d?void 0:-1,"aria-disabled":d?void 0:!0,"aria-label":b(d),onClick:C},F.createElement(m.Chevron,{disabled:d?void 0:!0,orientation:"right",className:p[ce.Chevron]})))}function Aw(a){const{components:s}=bi();return F.createElement(s.Button,{...a})}function Ow(a){return F.createElement("option",{...a})}function zw(a){const{components:s}=bi();return F.createElement(s.Button,{...a})}function Dw(a){const{rootRef:s,...r}=a;return F.createElement("div",{...r,ref:s})}function _w(a){return F.createElement("select",{...a})}function kw(a){const{week:s,...r}=a;return F.createElement("tr",{...r})}function Rw(a){return F.createElement("th",{...a})}function Uw(a){return F.createElement("thead",{"aria-hidden":!0},F.createElement("tr",{...a}))}function qw(a){const{week:s,...r}=a;return F.createElement("th",{...r})}function Bw(a){return F.createElement("th",{...a})}function Hw(a){return F.createElement("tbody",{...a})}function Lw(a){const{components:s}=bi();return F.createElement(s.Dropdown,{...a})}const Yw=Object.freeze(Object.defineProperty({__proto__:null,Button:pw,CaptionLabel:gw,Chevron:xw,Day:yw,DayButton:vw,Dropdown:bw,DropdownNav:Sw,Footer:Nw,Month:jw,MonthCaption:ww,MonthGrid:Cw,Months:Ew,MonthsDropdown:Mw,Nav:Tw,NextMonthButton:Aw,Option:Ow,PreviousMonthButton:zw,Root:Dw,Select:_w,Week:kw,WeekNumber:qw,WeekNumberHeader:Bw,Weekday:Rw,Weekdays:Uw,Weeks:Hw,YearsDropdown:Lw},Symbol.toStringTag,{value:"Module"}));function da(a,s,r=!1,u=Bn){let{from:d,to:f}=a;const{differenceInCalendarDays:m,isSameDay:p}=u;return d&&f?(m(f,d)<0&&([d,f]=[f,d]),m(s,d)>=(r?1:0)&&m(f,s)>=(r?1:0)):!r&&f?p(f,s):!r&&d?p(d,s):!1}function jd(a){return!!(a&&typeof a=="object"&&"before"in a&&"after"in a)}function co(a){return!!(a&&typeof a=="object"&&"from"in a)}function wd(a){return!!(a&&typeof a=="object"&&"after"in a)}function Cd(a){return!!(a&&typeof a=="object"&&"before"in a)}function Bx(a){return!!(a&&typeof a=="object"&&"dayOfWeek"in a)}function Hx(a,s){return Array.isArray(a)&&a.every(s.isDate)}function fa(a,s,r=Bn){const u=Array.isArray(s)?s:[s],{isSameDay:d,differenceInCalendarDays:f,isAfter:m}=r;return u.some(p=>{if(typeof p=="boolean")return p;if(r.isDate(p))return d(a,p);if(Hx(p,r))return p.some(x=>d(a,x));if(co(p))return da(p,a,!1,r);if(Bx(p))return Array.isArray(p.dayOfWeek)?p.dayOfWeek.includes(a.getDay()):p.dayOfWeek===a.getDay();if(jd(p)){const x=f(p.before,a),b=f(p.after,a),C=x>0,v=b<0;return m(p.before,p.after)?v&&C:C||v}return wd(p)?f(a,p.after)>0:Cd(p)?f(p.before,a)>0:typeof p=="function"?p(a):!1})}function Gw(a,s,r,u,d){const{disabled:f,hidden:m,modifiers:p,showOutsideDays:x,broadcastCalendar:b,today:C=d.today()}=s,{isSameDay:v,isSameMonth:S,startOfMonth:M,isBefore:O,endOfMonth:U,isAfter:_}=d,T=r&&M(r),K=u&&U(u),B={[lt.focused]:[],[lt.outside]:[],[lt.disabled]:[],[lt.hidden]:[],[lt.today]:[]},L={};for(const k of a){const{date:j,displayMonth:H}=k,Z=!!(H&&!S(j,H)),ee=!!(T&&O(j,T)),se=!!(K&&_(j,K)),be=!!(f&&fa(j,f,d)),ue=!!(m&&fa(j,m,d))||ee||se||!b&&!x&&Z||b&&x===!1&&Z,Ye=v(j,C);Z&&B.outside.push(k),be&&B.disabled.push(k),ue&&B.hidden.push(k),Ye&&B.today.push(k),p&&Object.keys(p).forEach(Ne=>{const P=p?.[Ne];P&&fa(j,P,d)&&(L[Ne]?L[Ne].push(k):L[Ne]=[k])})}return k=>{const j={[lt.focused]:!1,[lt.disabled]:!1,[lt.hidden]:!1,[lt.outside]:!1,[lt.today]:!1},H={};for(const Z in B){const ee=B[Z];j[Z]=ee.some(se=>se===k)}for(const Z in L)H[Z]=L[Z].some(ee=>ee===k);return{...j,...H}}}function Kw(a,s,r={}){return Object.entries(a).filter(([,d])=>d===!0).reduce((d,[f])=>(r[f]?d.push(r[f]):s[lt[f]]?d.push(s[lt[f]]):s[wn[f]]&&d.push(s[wn[f]]),d),[s[ce.Day]])}function Qw(a){return{...Yw,...a}}function Vw(a){const s={"data-mode":a.mode??void 0,"data-required":"required"in a?a.required:void 0,"data-multiple-months":a.numberOfMonths&&a.numberOfMonths>1||void 0,"data-week-numbers":a.showWeekNumber||void 0,"data-broadcast-calendar":a.broadcastCalendar||void 0,"data-nav-layout":a.navLayout||void 0};return Object.entries(a).forEach(([r,u])=>{r.startsWith("data-")&&(s[r]=u)}),s}function Xw(){const a={};for(const s in ce)a[ce[s]]=`rdp-${ce[s]}`;for(const s in lt)a[lt[s]]=`rdp-${lt[s]}`;for(const s in wn)a[wn[s]]=`rdp-${wn[s]}`;for(const s in ln)a[ln[s]]=`rdp-${ln[s]}`;return a}function Lx(a,s,r){return(r??new sn(s)).formatMonthYear(a)}const Zw=Lx;function Ww(a,s,r){return(r??new sn(s)).format(a,"d")}function $w(a,s=Bn){return s.format(a,"LLLL")}function Jw(a,s,r){return(r??new sn(s)).format(a,"cccccc")}function Pw(a,s=Bn){return a<10?s.formatNumber(`0${a.toLocaleString()}`):s.formatNumber(`${a.toLocaleString()}`)}function Iw(){return""}function Yx(a,s=Bn){return s.format(a,"yyyy")}const Fw=Yx,eC=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:Lx,formatDay:Ww,formatMonthCaption:Zw,formatMonthDropdown:$w,formatWeekNumber:Pw,formatWeekNumberHeader:Iw,formatWeekdayName:Jw,formatYearCaption:Fw,formatYearDropdown:Yx},Symbol.toStringTag,{value:"Module"}));function tC(a){return a?.formatMonthCaption&&!a.formatCaption&&(a.formatCaption=a.formatMonthCaption),a?.formatYearCaption&&!a.formatYearDropdown&&(a.formatYearDropdown=a.formatYearCaption),{...eC,...a}}function Ed(a,s,r,u){let d=(u??new sn(r)).format(a,"PPPP");return s.today&&(d=`Today, ${d}`),s.selected&&(d=`${d}, selected`),d}const nC=Ed;function Md(a,s,r){return(r??new sn(s)).formatMonthYear(a)}const aC=Md;function Gx(a,s,r,u){let d=(u??new sn(r)).format(a,"PPPP");return s?.today&&(d=`Today, ${d}`),d}function Kx(a){return"Choose the Month"}function Qx(){return""}const lC="Go to the Next Month";function Vx(a,s){return lC}function Xx(a){return"Go to the Previous Month"}function Zx(a,s,r){return(r??new sn(s)).format(a,"cccc")}function Wx(a,s){return`Week ${a}`}function $x(a){return"Week Number"}function Jx(a){return"Choose the Year"}const sC=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:aC,labelDay:nC,labelDayButton:Ed,labelGrid:Md,labelGridcell:Gx,labelMonthDropdown:Kx,labelNav:Qx,labelNext:Vx,labelPrevious:Xx,labelWeekNumber:Wx,labelWeekNumberHeader:$x,labelWeekday:Zx,labelYearDropdown:Jx},Symbol.toStringTag,{value:"Module"})),jn=(a,s,r)=>s||(r?typeof r=="function"?r:(...u)=>r:a);function iC(a,s){const r=s.locale?.labels??{};return{...sC,...a??{},labelDayButton:jn(Ed,a?.labelDayButton,r.labelDayButton),labelMonthDropdown:jn(Kx,a?.labelMonthDropdown,r.labelMonthDropdown),labelNext:jn(Vx,a?.labelNext,r.labelNext),labelPrevious:jn(Xx,a?.labelPrevious,r.labelPrevious),labelWeekNumber:jn(Wx,a?.labelWeekNumber,r.labelWeekNumber),labelYearDropdown:jn(Jx,a?.labelYearDropdown,r.labelYearDropdown),labelGrid:jn(Md,a?.labelGrid,r.labelGrid),labelGridcell:jn(Gx,a?.labelGridcell,r.labelGridcell),labelNav:jn(Qx,a?.labelNav,r.labelNav),labelWeekNumberHeader:jn($x,a?.labelWeekNumberHeader,r.labelWeekNumberHeader),labelWeekday:jn(Zx,a?.labelWeekday,r.labelWeekday)}}function rC(a,s,r,u,d){const{startOfMonth:f,startOfYear:m,endOfYear:p,eachMonthOfInterval:x,getMonth:b}=d;return x({start:m(a),end:p(a)}).map(S=>{const M=u.formatMonthDropdown(S,d),O=b(S),U=s&&S<f(s)||r&&S>f(r)||!1;return{value:O,label:M,disabled:U}})}function oC(a,s={},r={}){let u={...s?.[ce.Day]};return Object.entries(a).filter(([,d])=>d===!0).forEach(([d])=>{u={...u,...r?.[d]}}),u}function uC(a,s,r,u){const d=u??a.today(),f=r?a.startOfBroadcastWeek(d,a):s?a.startOfISOWeek(d):a.startOfWeek(d),m=[];for(let p=0;p<7;p++){const x=a.addDays(f,p);m.push(x)}return m}function cC(a,s,r,u,d=!1){if(!a||!s)return;const{startOfYear:f,endOfYear:m,eachYearOfInterval:p,getYear:x}=u,b=f(a),C=m(s),v=p({start:b,end:C});return d&&v.reverse(),v.map(S=>{const M=r.formatYearDropdown(S,u);return{value:x(S),label:M,disabled:!1}})}const Si=a=>a instanceof HTMLElement?a:null,_c=a=>[...a.querySelectorAll("[data-animated-month]")??[]],dC=a=>Si(a.querySelector("[data-animated-month]")),kc=a=>Si(a.querySelector("[data-animated-caption]")),Rc=a=>Si(a.querySelector("[data-animated-weeks]")),fC=a=>Si(a.querySelector("[data-animated-nav]")),mC=a=>Si(a.querySelector("[data-animated-weekdays]"));function hC(a,s,{classNames:r,months:u,focused:d,dateLib:f}){const m=y.useRef(null),p=y.useRef(u),x=y.useRef(!1);y.useLayoutEffect(()=>{const b=p.current;if(p.current=u,!s||!a.current||!(a.current instanceof HTMLElement)||u.length===0||b.length===0||u.length!==b.length)return;const C=f.isSameMonth(u[0].date,b[0].date),v=f.isAfter(u[0].date,b[0].date),S=v?r[ln.caption_after_enter]:r[ln.caption_before_enter],M=v?r[ln.weeks_after_enter]:r[ln.weeks_before_enter],O=m.current,U=a.current.cloneNode(!0);if(U instanceof HTMLElement?(_c(U).forEach(B=>{if(!(B instanceof HTMLElement))return;const L=dC(B);L&&B.contains(L)&&B.removeChild(L);const k=kc(B);k&&k.classList.remove(S);const j=Rc(B);j&&j.classList.remove(M)}),m.current=U):m.current=null,x.current||C||d)return;const _=O instanceof HTMLElement?_c(O):[],T=_c(a.current);if(T?.every(K=>K instanceof HTMLElement)&&_&&_.every(K=>K instanceof HTMLElement)){x.current=!0,a.current.style.isolation="isolate";const K=fC(a.current);K&&(K.style.zIndex="1"),T.forEach((B,L)=>{const k=_[L];if(!k)return;B.style.position="relative",B.style.overflow="hidden";const j=kc(B);j&&j.classList.add(S);const H=Rc(B);H&&H.classList.add(M);const Z=()=>{x.current=!1,a.current&&(a.current.style.isolation=""),K&&(K.style.zIndex=""),j&&j.classList.remove(S),H&&H.classList.remove(M),B.style.position="",B.style.overflow="",B.contains(k)&&B.removeChild(k)};k.style.pointerEvents="none",k.style.position="absolute",k.style.overflow="hidden",k.setAttribute("aria-hidden","true");const ee=mC(k);ee&&(ee.style.opacity="0");const se=kc(k);se&&(se.classList.add(v?r[ln.caption_before_exit]:r[ln.caption_after_exit]),se.addEventListener("animationend",Z));const be=Rc(k);be&&be.classList.add(v?r[ln.weeks_before_exit]:r[ln.weeks_after_exit]),B.insertBefore(k,B.firstChild)})}})}function pC(a,s,r,u){const d=a[0],f=a[a.length-1],{ISOWeek:m,fixedWeeks:p,broadcastCalendar:x}=r??{},{addDays:b,differenceInCalendarDays:C,differenceInCalendarMonths:v,endOfBroadcastWeek:S,endOfISOWeek:M,endOfMonth:O,endOfWeek:U,isAfter:_,startOfBroadcastWeek:T,startOfISOWeek:K,startOfWeek:B}=u,L=x?T(d,u):m?K(d):B(d),k=x?S(f):m?M(O(f)):U(O(f)),j=s&&(x?S(s):m?M(s):U(s)),H=j&&_(k,j)?j:k,Z=C(H,L),ee=v(f,d)+1,se=[];for(let Ye=0;Ye<=Z;Ye++){const Ne=b(L,Ye);se.push(Ne)}const ue=(x?35:42)*ee;if(p&&se.length<ue){const Ye=ue-se.length;for(let Ne=0;Ne<Ye;Ne++){const P=b(se[se.length-1],1);se.push(P)}}return se}function gC(a){const s=[];return a.reduce((r,u)=>{const d=u.weeks.reduce((f,m)=>f.concat(m.days.slice()),s.slice());return r.concat(d.slice())},s.slice())}function xC(a,s,r,u){const{numberOfMonths:d=1}=r,f=[];for(let m=0;m<d;m++){const p=u.addMonths(a,m);if(s&&p>s)break;f.push(p)}return f}function dg(a,s,r,u){const{month:d,defaultMonth:f,today:m=u.today(),numberOfMonths:p=1}=a;let x=d||f||m;const{differenceInCalendarMonths:b,addMonths:C,startOfMonth:v}=u;if(r&&b(r,x)<p-1){const S=-1*(p-1);x=C(r,S)}return s&&b(x,s)<0&&(x=s),v(x)}function yC(a,s,r,u){const{addDays:d,endOfBroadcastWeek:f,endOfISOWeek:m,endOfMonth:p,endOfWeek:x,getISOWeek:b,getWeek:C,startOfBroadcastWeek:v,startOfISOWeek:S,startOfWeek:M}=u,O=a.reduce((U,_)=>{const T=r.broadcastCalendar?v(_,u):r.ISOWeek?S(_):M(_),K=r.broadcastCalendar?f(_):r.ISOWeek?m(p(_)):x(p(_)),B=s.filter(H=>H>=T&&H<=K),L=r.broadcastCalendar?35:42;if(r.fixedWeeks&&B.length<L){const H=s.filter(Z=>{const ee=L-B.length;return Z>K&&Z<=d(K,ee)});B.push(...H)}const k=B.reduce((H,Z)=>{const ee=r.ISOWeek?b(Z):C(Z),se=H.find(ue=>ue.weekNumber===ee),be=new Ux(Z,_,u);return se?se.days.push(be):H.push(new hw(ee,[be])),H},[]),j=new mw(_,k);return U.push(j),U},[]);return r.reverseMonths?O.reverse():O}function vC(a,s){let{startMonth:r,endMonth:u}=a;const{startOfYear:d,startOfDay:f,startOfMonth:m,endOfMonth:p,addYears:x,endOfYear:b,newDate:C,today:v}=s,{fromYear:S,toYear:M,fromMonth:O,toMonth:U}=a;!r&&O&&(r=O),!r&&S&&(r=s.newDate(S,0,1)),!u&&U&&(u=U),!u&&M&&(u=C(M,11,31));const _=a.captionLayout==="dropdown"||a.captionLayout==="dropdown-years";return r?r=m(r):S?r=C(S,0,1):!r&&_&&(r=d(x(a.today??v(),-100))),u?u=p(u):M?u=C(M,11,31):!u&&_&&(u=b(a.today??v())),[r&&f(r),u&&f(u)]}function bC(a,s,r,u){if(r.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:f=1}=r,{startOfMonth:m,addMonths:p,differenceInCalendarMonths:x}=u,b=d?f:1,C=m(a);if(!s)return p(C,b);if(!(x(s,a)<f))return p(C,b)}function SC(a,s,r,u){if(r.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:f}=r,{startOfMonth:m,addMonths:p,differenceInCalendarMonths:x}=u,b=d?f??1:1,C=m(a);if(!s)return p(C,-b);if(!(x(C,s)<=0))return p(C,-b)}function NC(a){const s=[];return a.reduce((r,u)=>r.concat(u.weeks.slice()),s.slice())}function fo(a,s){const[r,u]=y.useState(a);return[s===void 0?r:s,u]}function jC(a,s){const[r,u]=vC(a,s),{startOfMonth:d,endOfMonth:f}=s,m=dg(a,r,u,s),[p,x]=fo(m,a.month?m:void 0);y.useEffect(()=>{const L=dg(a,r,u,s);x(L)},[a.timeZone]);const{months:b,weeks:C,days:v,previousMonth:S,nextMonth:M}=y.useMemo(()=>{const L=xC(p,u,{numberOfMonths:a.numberOfMonths},s),k=pC(L,a.endMonth?f(a.endMonth):void 0,{ISOWeek:a.ISOWeek,fixedWeeks:a.fixedWeeks,broadcastCalendar:a.broadcastCalendar},s),j=yC(L,k,{broadcastCalendar:a.broadcastCalendar,fixedWeeks:a.fixedWeeks,ISOWeek:a.ISOWeek,reverseMonths:a.reverseMonths},s),H=NC(j),Z=gC(j),ee=SC(p,r,a,s),se=bC(p,u,a,s);return{months:j,weeks:H,days:Z,previousMonth:ee,nextMonth:se}},[s,p.getTime(),u?.getTime(),r?.getTime(),a.disableNavigation,a.broadcastCalendar,a.endMonth?.getTime(),a.fixedWeeks,a.ISOWeek,a.numberOfMonths,a.pagedNavigation,a.reverseMonths]),{disableNavigation:O,onMonthChange:U}=a,_=L=>C.some(k=>k.days.some(j=>j.isEqualTo(L))),T=L=>{if(O)return;let k=d(L);r&&k<d(r)&&(k=d(r)),u&&k>d(u)&&(k=d(u)),x(k),U?.(k)};return{months:b,weeks:C,days:v,navStart:r,navEnd:u,previousMonth:S,nextMonth:M,goToMonth:T,goToDay:L=>{_(L)||T(L.date)}}}var Un;(function(a){a[a.Today=0]="Today",a[a.Selected=1]="Selected",a[a.LastFocused=2]="LastFocused",a[a.FocusedModifier=3]="FocusedModifier"})(Un||(Un={}));function fg(a){return!a[lt.disabled]&&!a[lt.hidden]&&!a[lt.outside]}function wC(a,s,r,u){let d,f=-1;for(const m of a){const p=s(m);fg(p)&&(p[lt.focused]&&f<Un.FocusedModifier?(d=m,f=Un.FocusedModifier):u?.isEqualTo(m)&&f<Un.LastFocused?(d=m,f=Un.LastFocused):r(m.date)&&f<Un.Selected?(d=m,f=Un.Selected):p[lt.today]&&f<Un.Today&&(d=m,f=Un.Today))}return d||(d=a.find(m=>fg(s(m)))),d}function CC(a,s,r,u,d,f,m){const{ISOWeek:p,broadcastCalendar:x}=f,{addDays:b,addMonths:C,addWeeks:v,addYears:S,endOfBroadcastWeek:M,endOfISOWeek:O,endOfWeek:U,max:_,min:T,startOfBroadcastWeek:K,startOfISOWeek:B,startOfWeek:L}=m;let j={day:b,week:v,month:C,year:S,startOfWeek:H=>x?K(H,m):p?B(H):L(H),endOfWeek:H=>x?M(H):p?O(H):U(H)}[a](r,s==="after"?1:-1);return s==="before"&&u?j=_([u,j]):s==="after"&&d&&(j=T([d,j])),j}function Px(a,s,r,u,d,f,m,p=0){if(p>365)return;const x=CC(a,s,r.date,u,d,f,m),b=!!(f.disabled&&fa(x,f.disabled,m)),C=!!(f.hidden&&fa(x,f.hidden,m)),v=x,S=new Ux(x,v,m);return!b&&!C?S:Px(a,s,S,u,d,f,m,p+1)}function EC(a,s,r,u,d){const{autoFocus:f}=a,[m,p]=y.useState(),x=wC(s.days,r,u||(()=>!1),m),[b,C]=y.useState(f?x:void 0);return{isFocusTarget:U=>!!x?.isEqualTo(U),setFocused:C,focused:b,blur:()=>{p(b),C(void 0)},moveFocus:(U,_)=>{if(!b)return;const T=Px(U,_,b,s.navStart,s.navEnd,a,d);T&&(a.disableNavigation&&!s.days.some(B=>B.isEqualTo(T))||(s.goToDay(T),C(T)))}}}function MC(a,s){const{selected:r,required:u,onSelect:d}=a,[f,m]=fo(r,d?r:void 0),p=d?r:f,{isSameDay:x}=s,b=M=>p?.some(O=>x(O,M))??!1,{min:C,max:v}=a;return{selected:p,select:(M,O,U)=>{let _=[...p??[]];if(b(M)){if(p?.length===C||u&&p?.length===1)return;_=p?.filter(T=>!x(T,M))}else p?.length===v?_=[M]:_=[..._,M];return d||m(_),d?.(_,M,O,U),_},isSelected:b}}function TC(a,s,r=0,u=0,d=!1,f=Bn){const{from:m,to:p}=s||{},{isSameDay:x,isAfter:b,isBefore:C}=f;let v;if(!m&&!p)v={from:a,to:r>0?void 0:a};else if(m&&!p)x(m,a)?r===0?v={from:m,to:a}:d?v={from:m,to:void 0}:v=void 0:C(a,m)?v={from:a,to:m}:v={from:m,to:a};else if(m&&p)if(x(m,a)&&x(p,a))d?v={from:m,to:p}:v=void 0;else if(x(m,a))v={from:m,to:r>0?void 0:a};else if(x(p,a))v={from:a,to:r>0?void 0:a};else if(C(a,m))v={from:a,to:p};else if(b(a,m))v={from:m,to:a};else if(b(a,p))v={from:m,to:a};else throw new Error("Invalid range");if(v?.from&&v?.to){const S=f.differenceInCalendarDays(v.to,v.from);u>0&&S>u?v={from:a,to:void 0}:r>1&&S<r&&(v={from:a,to:void 0})}return v}function AC(a,s,r=Bn){const u=Array.isArray(s)?s:[s];let d=a.from;const f=r.differenceInCalendarDays(a.to,a.from),m=Math.min(f,6);for(let p=0;p<=m;p++){if(u.includes(d.getDay()))return!0;d=r.addDays(d,1)}return!1}function mg(a,s,r=Bn){return da(a,s.from,!1,r)||da(a,s.to,!1,r)||da(s,a.from,!1,r)||da(s,a.to,!1,r)}function OC(a,s,r=Bn){const u=Array.isArray(s)?s:[s];if(u.filter(p=>typeof p!="function").some(p=>typeof p=="boolean"?p:r.isDate(p)?da(a,p,!1,r):Hx(p,r)?p.some(x=>da(a,x,!1,r)):co(p)?p.from&&p.to?mg(a,{from:p.from,to:p.to},r):!1:Bx(p)?AC(a,p.dayOfWeek,r):jd(p)?r.isAfter(p.before,p.after)?mg(a,{from:r.addDays(p.after,1),to:r.addDays(p.before,-1)},r):fa(a.from,p,r)||fa(a.to,p,r):wd(p)||Cd(p)?fa(a.from,p,r)||fa(a.to,p,r):!1))return!0;const m=u.filter(p=>typeof p=="function");if(m.length){let p=a.from;const x=r.differenceInCalendarDays(a.to,a.from);for(let b=0;b<=x;b++){if(m.some(C=>C(p)))return!0;p=r.addDays(p,1)}}return!1}function zC(a,s){const{disabled:r,excludeDisabled:u,selected:d,required:f,onSelect:m}=a,[p,x]=fo(d,m?d:void 0),b=m?d:p;return{selected:b,select:(S,M,O)=>{const{min:U,max:_}=a,T=S?TC(S,b,U,_,f,s):void 0;return u&&r&&T?.from&&T.to&&OC({from:T.from,to:T.to},r,s)&&(T.from=S,T.to=void 0),m||x(T),m?.(T,S,M,O),T},isSelected:S=>b&&da(b,S,!1,s)}}function DC(a,s){const{selected:r,required:u,onSelect:d}=a,[f,m]=fo(r,d?r:void 0),p=d?r:f,{isSameDay:x}=s;return{selected:p,select:(v,S,M)=>{let O=v;return!u&&p&&p&&x(v,p)&&(O=void 0),d||m(O),d?.(O,v,S,M),O},isSelected:v=>p?x(p,v):!1}}function _C(a,s){const r=DC(a,s),u=MC(a,s),d=zC(a,s);switch(a.mode){case"single":return r;case"multiple":return u;case"range":return d;default:return}}function Ot(a,s){return a instanceof ca&&a.timeZone===s?a:new ca(a,s)}function hg(a,s){return typeof a=="boolean"||typeof a=="function"?a:a instanceof Date?Ot(a,s):Array.isArray(a)?a.map(r=>r instanceof Date?Ot(r,s):r):co(a)?{...a,from:a.from?Ot(a.from,s):a.from,to:a.to?Ot(a.to,s):a.to}:jd(a)?{before:Ot(a.before,s),after:Ot(a.after,s)}:wd(a)?{after:Ot(a.after,s)}:Cd(a)?{before:Ot(a.before,s)}:a}function Uc(a,s){return a&&(Array.isArray(a)?a.map(r=>hg(r,s)):hg(a,s))}function kC(a){let s=a;const r=s.timeZone;if(r&&(s={...a,timeZone:r},s.today&&(s.today=Ot(s.today,r)),s.month&&(s.month=Ot(s.month,r)),s.defaultMonth&&(s.defaultMonth=Ot(s.defaultMonth,r)),s.startMonth&&(s.startMonth=Ot(s.startMonth,r)),s.endMonth&&(s.endMonth=Ot(s.endMonth,r)),s.mode==="single"&&s.selected?s.selected=Ot(s.selected,r):s.mode==="multiple"&&s.selected?s.selected=s.selected?.map(oe=>Ot(oe,r)):s.mode==="range"&&s.selected&&(s.selected={from:s.selected.from?Ot(s.selected.from,r):s.selected.from,to:s.selected.to?Ot(s.selected.to,r):s.selected.to}),s.disabled!==void 0&&(s.disabled=Uc(s.disabled,r)),s.hidden!==void 0&&(s.hidden=Uc(s.hidden,r)),s.modifiers)){const oe={};Object.keys(s.modifiers).forEach(Se=>{oe[Se]=Uc(s.modifiers?.[Se],r)}),s.modifiers=oe}const{components:u,formatters:d,labels:f,dateLib:m,locale:p,classNames:x}=y.useMemo(()=>{const oe={...Rx,...s.locale},Se=new sn({locale:oe,weekStartsOn:s.broadcastCalendar?1:s.weekStartsOn,firstWeekContainsDate:s.firstWeekContainsDate,useAdditionalWeekYearTokens:s.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:s.useAdditionalDayOfYearTokens,timeZone:s.timeZone,numerals:s.numerals},s.dateLib);return{dateLib:Se,components:Qw(s.components),formatters:tC(s.formatters),labels:iC(s.labels,Se.options),locale:oe,classNames:{...Xw(),...s.classNames}}},[s.locale,s.broadcastCalendar,s.weekStartsOn,s.firstWeekContainsDate,s.useAdditionalWeekYearTokens,s.useAdditionalDayOfYearTokens,s.timeZone,s.numerals,s.dateLib,s.components,s.formatters,s.labels,s.classNames]);s.today||(s={...s,today:m.today()});const{captionLayout:b,mode:C,navLayout:v,numberOfMonths:S=1,onDayBlur:M,onDayClick:O,onDayFocus:U,onDayKeyDown:_,onDayMouseEnter:T,onDayMouseLeave:K,onNextClick:B,onPrevClick:L,showWeekNumber:k,styles:j}=s,{formatCaption:H,formatDay:Z,formatMonthDropdown:ee,formatWeekNumber:se,formatWeekNumberHeader:be,formatWeekdayName:ue,formatYearDropdown:Ye}=d,Ne=jC(s,m),{days:P,months:A,navStart:W,navEnd:ie,previousMonth:ye,nextMonth:ve,goToMonth:De}=Ne,ze=Gw(P,s,W,ie,m),{isSelected:X,select:J,selected:ne}=_C(s,m)??{},{blur:I,focused:te,isFocusTarget:fe,moveFocus:Oe,setFocused:Ge}=EC(s,Ne,ze,X??(()=>!1),m),{labelDayButton:yt,labelGridcell:vt,labelGrid:Qe,labelMonthDropdown:tt,labelNav:kt,labelPrevious:Vt,labelNext:Hn,labelWeekday:je,labelWeekNumber:Xt,labelWeekNumberHeader:Mn,labelYearDropdown:Zt}=f,ha=y.useMemo(()=>uC(m,s.ISOWeek,s.broadcastCalendar,s.today),[m,s.ISOWeek,s.broadcastCalendar,s.today]),Ln=C!==void 0||O!==void 0,ct=y.useCallback(()=>{ye&&(De(ye),L?.(ye))},[ye,De,L]),Wt=y.useCallback(()=>{ve&&(De(ve),B?.(ve))},[De,ve,B]),Yn=y.useCallback((oe,Se)=>he=>{he.preventDefault(),he.stopPropagation(),Ge(oe),!Se.disabled&&(J?.(oe.date,Se,he),O?.(oe.date,Se,he))},[J,O,Ge]),Va=y.useCallback((oe,Se)=>he=>{Ge(oe),U?.(oe.date,Se,he)},[U,Ge]),Tn=y.useCallback((oe,Se)=>he=>{I(),M?.(oe.date,Se,he)},[I,M]),An=y.useCallback((oe,Se)=>he=>{const Te={ArrowLeft:[he.shiftKey?"month":"day",s.dir==="rtl"?"after":"before"],ArrowRight:[he.shiftKey?"month":"day",s.dir==="rtl"?"before":"after"],ArrowDown:[he.shiftKey?"year":"week","after"],ArrowUp:[he.shiftKey?"year":"week","before"],PageUp:[he.shiftKey?"year":"month","before"],PageDown:[he.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(Te[he.key]){he.preventDefault(),he.stopPropagation();const[Ie,xe]=Te[he.key];Oe(Ie,xe)}_?.(oe.date,Se,he)},[Oe,_,s.dir]),xl=y.useCallback((oe,Se)=>he=>{T?.(oe.date,Se,he)},[T]),cs=y.useCallback((oe,Se)=>he=>{K?.(oe.date,Se,he)},[K]),ds=y.useCallback(oe=>Se=>{const he=Number(Se.target.value),Te=m.setMonth(m.startOfMonth(oe),he);De(Te)},[m,De]),Gn=y.useCallback(oe=>Se=>{const he=Number(Se.target.value),Te=m.setYear(m.startOfMonth(oe),he);De(Te)},[m,De]),{className:$,style:Ee}=y.useMemo(()=>({className:[x[ce.Root],s.className].filter(Boolean).join(" "),style:{...j?.[ce.Root],...s.style}}),[x,s.className,s.style,j]),me=Vw(s),Me=y.useRef(null);hC(Me,!!s.animate,{classNames:x,months:A,focused:te,dateLib:m});const nt={dayPickerProps:s,selected:ne,select:J,isSelected:X,months:A,nextMonth:ve,previousMonth:ye,goToMonth:De,getModifiers:ze,components:u,classNames:x,styles:j,labels:f,formatters:d};return F.createElement(qx.Provider,{value:nt},F.createElement(u.Root,{rootRef:s.animate?Me:void 0,className:$,style:Ee,dir:s.dir,id:s.id,lang:s.lang,nonce:s.nonce,title:s.title,role:s.role,"aria-label":s["aria-label"],"aria-labelledby":s["aria-labelledby"],...me},F.createElement(u.Months,{className:x[ce.Months],style:j?.[ce.Months]},!s.hideNavigation&&!v&&F.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:x[ce.Nav],style:j?.[ce.Nav],"aria-label":kt(),onPreviousClick:ct,onNextClick:Wt,previousMonth:ye,nextMonth:ve}),A.map((oe,Se)=>F.createElement(u.Month,{"data-animated-month":s.animate?"true":void 0,className:x[ce.Month],style:j?.[ce.Month],key:Se,displayIndex:Se,calendarMonth:oe},v==="around"&&!s.hideNavigation&&Se===0&&F.createElement(u.PreviousMonthButton,{type:"button",className:x[ce.PreviousMonthButton],tabIndex:ye?void 0:-1,"aria-disabled":ye?void 0:!0,"aria-label":Vt(ye),onClick:ct,"data-animated-button":s.animate?"true":void 0},F.createElement(u.Chevron,{disabled:ye?void 0:!0,className:x[ce.Chevron],orientation:s.dir==="rtl"?"right":"left"})),F.createElement(u.MonthCaption,{"data-animated-caption":s.animate?"true":void 0,className:x[ce.MonthCaption],style:j?.[ce.MonthCaption],calendarMonth:oe,displayIndex:Se},b?.startsWith("dropdown")?F.createElement(u.DropdownNav,{className:x[ce.Dropdowns],style:j?.[ce.Dropdowns]},(()=>{const he=b==="dropdown"||b==="dropdown-months"?F.createElement(u.MonthsDropdown,{key:"month",className:x[ce.MonthsDropdown],"aria-label":tt(),classNames:x,components:u,disabled:!!s.disableNavigation,onChange:ds(oe.date),options:rC(oe.date,W,ie,d,m),style:j?.[ce.Dropdown],value:m.getMonth(oe.date)}):F.createElement("span",{key:"month"},ee(oe.date,m)),Te=b==="dropdown"||b==="dropdown-years"?F.createElement(u.YearsDropdown,{key:"year",className:x[ce.YearsDropdown],"aria-label":Zt(m.options),classNames:x,components:u,disabled:!!s.disableNavigation,onChange:Gn(oe.date),options:cC(W,ie,d,m,!!s.reverseYears),style:j?.[ce.Dropdown],value:m.getYear(oe.date)}):F.createElement("span",{key:"year"},Ye(oe.date,m));return m.getMonthYearOrder()==="year-first"?[Te,he]:[he,Te]})(),F.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},H(oe.date,m.options,m))):F.createElement(u.CaptionLabel,{className:x[ce.CaptionLabel],role:"status","aria-live":"polite"},H(oe.date,m.options,m))),v==="around"&&!s.hideNavigation&&Se===S-1&&F.createElement(u.NextMonthButton,{type:"button",className:x[ce.NextMonthButton],tabIndex:ve?void 0:-1,"aria-disabled":ve?void 0:!0,"aria-label":Hn(ve),onClick:Wt,"data-animated-button":s.animate?"true":void 0},F.createElement(u.Chevron,{disabled:ve?void 0:!0,className:x[ce.Chevron],orientation:s.dir==="rtl"?"left":"right"})),Se===S-1&&v==="after"&&!s.hideNavigation&&F.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:x[ce.Nav],style:j?.[ce.Nav],"aria-label":kt(),onPreviousClick:ct,onNextClick:Wt,previousMonth:ye,nextMonth:ve}),F.createElement(u.MonthGrid,{role:"grid","aria-multiselectable":C==="multiple"||C==="range","aria-label":Qe(oe.date,m.options,m)||void 0,className:x[ce.MonthGrid],style:j?.[ce.MonthGrid]},!s.hideWeekdays&&F.createElement(u.Weekdays,{"data-animated-weekdays":s.animate?"true":void 0,className:x[ce.Weekdays],style:j?.[ce.Weekdays]},k&&F.createElement(u.WeekNumberHeader,{"aria-label":Mn(m.options),className:x[ce.WeekNumberHeader],style:j?.[ce.WeekNumberHeader],scope:"col"},be()),ha.map(he=>F.createElement(u.Weekday,{"aria-label":je(he,m.options,m),className:x[ce.Weekday],key:String(he),style:j?.[ce.Weekday],scope:"col"},ue(he,m.options,m)))),F.createElement(u.Weeks,{"data-animated-weeks":s.animate?"true":void 0,className:x[ce.Weeks],style:j?.[ce.Weeks]},oe.weeks.map(he=>F.createElement(u.Week,{className:x[ce.Week],key:he.weekNumber,style:j?.[ce.Week],week:he},k&&F.createElement(u.WeekNumber,{week:he,style:j?.[ce.WeekNumber],"aria-label":Xt(he.weekNumber,{locale:p}),className:x[ce.WeekNumber],scope:"row",role:"rowheader"},se(he.weekNumber,m)),he.days.map(Te=>{const{date:Ie}=Te,xe=ze(Te);if(xe[lt.focused]=!xe.hidden&&!!te?.isEqualTo(Te),xe[wn.selected]=X?.(Ie)||xe.selected,co(ne)){const{from:$t,to:vn}=ne;xe[wn.range_start]=!!($t&&vn&&m.isSameDay(Ie,$t)),xe[wn.range_end]=!!($t&&vn&&m.isSameDay(Ie,vn)),xe[wn.range_middle]=da(ne,Ie,!0,m)}const Dt=oC(xe,j,s.modifiersStyles),Kn=Kw(xe,x,s.modifiersClassNames),Nt=!Ln&&!xe.hidden?vt(Ie,xe,m.options,m):void 0;return F.createElement(u.Day,{key:`${Te.isoDate}_${Te.displayMonthId}`,day:Te,modifiers:xe,className:Kn.join(" "),style:Dt,role:"gridcell","aria-selected":xe.selected||void 0,"aria-label":Nt,"data-day":Te.isoDate,"data-month":Te.outside?Te.dateMonthId:void 0,"data-selected":xe.selected||void 0,"data-disabled":xe.disabled||void 0,"data-hidden":xe.hidden||void 0,"data-outside":Te.outside||void 0,"data-focused":xe.focused||void 0,"data-today":xe.today||void 0},!xe.hidden&&Ln?F.createElement(u.DayButton,{className:x[ce.DayButton],style:j?.[ce.DayButton],type:"button",day:Te,modifiers:xe,disabled:!xe.focused&&xe.disabled||void 0,"aria-disabled":xe.focused&&xe.disabled||void 0,tabIndex:fe(Te)?0:-1,"aria-label":yt(Ie,xe,m.options,m),onClick:Yn(Te,xe),onBlur:Tn(Te,xe),onFocus:Va(Te,xe),onKeyDown:An(Te,xe),onMouseEnter:xl(Te,xe),onMouseLeave:cs(Te,xe)},Z(Ie,m.options,m)):!xe.hidden&&Z(Te.date,m.options,m))})))))))),s.footer&&F.createElement(u.Footer,{className:x[ce.Footer],style:j?.[ce.Footer],role:"status","aria-live":"polite"},s.footer)))}function RC({className:a,classNames:s,showOutsideDays:r=!0,...u}){return i.jsx(kC,{showOutsideDays:r,className:G("p-2",a),classNames:{root:"relative",months:"flex flex-col sm:flex-row gap-2 sm:gap-4",month:"flex flex-col gap-2",month_caption:"flex justify-center pt-1 relative items-center h-8",caption_label:"text-sm font-medium",nav:"absolute inset-x-0 top-2 flex items-center justify-between px-1 z-10",button_previous:G(Hr({variant:"ghost"}),"h-7 w-7 bg-transparent p-0 opacity-70 hover:opacity-100 hover:bg-accent rounded-md"),button_next:G(Hr({variant:"ghost"}),"h-7 w-7 bg-transparent p-0 opacity-70 hover:opacity-100 hover:bg-accent rounded-md"),month_grid:"w-full border-collapse",weekdays:"flex w-full",weekday:"text-muted-foreground w-8 font-normal text-xs text-center",weeks:"flex flex-col",week:"flex w-full",day:G("relative h-8 w-8 p-0 text-center text-xs font-normal focus-within:relative focus-within:z-20","hover:bg-accent hover:text-accent-foreground rounded-full select-none"),day_button:G(Hr({variant:"ghost"}),"h-8 w-8 p-0 font-normal rounded-full text-xs","aria-selected:opacity-100"),range_start:G("aria-selected:bg-primary aria-selected:text-primary-foreground","aria-selected:rounded-l-full aria-selected:rounded-r-none","aria-selected:hover:bg-primary aria-selected:hover:text-primary-foreground"),range_end:G("aria-selected:bg-primary aria-selected:text-primary-foreground","aria-selected:rounded-r-full aria-selected:rounded-l-none","aria-selected:hover:bg-primary aria-selected:hover:text-primary-foreground"),range_middle:G("aria-selected:bg-accent aria-selected:text-accent-foreground","aria-selected:rounded-none"),selected:G("bg-primary text-primary-foreground rounded-full","hover:bg-primary hover:text-primary-foreground","focus:bg-primary focus:text-primary-foreground"),today:"bg-accent text-accent-foreground rounded-full",outside:"text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",disabled:"text-muted-foreground opacity-50",hidden:"invisible",...s},components:{Chevron:({orientation:d,className:f,...m})=>{const p=d==="left"?Tb:d==="right"?Wr:d==="up"?Pc:eo;return i.jsx(p,{className:G("h-4 w-4",f),...m})}},...u})}RC.displayName="Calendar";const UC=y.lazy(()=>St(()=>Promise.resolve().then(()=>Nd),void 0).then(a=>({default:a.CodeEditor})));function PE({rawJsonContent:a,isRawJsonValid:s,rawJsonEdits:r,rawSettingsEnv:u,onChange:d,missingRequiredFields:f=[]}){const m=f.length>0;return i.jsx(y.Suspense,{fallback:i.jsxs("div",{className:"flex items-center justify-center h-full",children:[i.jsx(En,{className:"w-6 h-6 animate-spin text-muted-foreground"}),i.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading editor..."})]}),children:i.jsxs("div",{className:"h-full flex flex-col",children:[!s&&r!==null&&i.jsxs("div",{className:"mb-2 px-3 py-2 bg-destructive/10 text-destructive text-sm rounded-md flex items-center gap-2 mx-6 mt-4 shrink-0",children:[i.jsx(os,{className:"w-4 h-4"}),"Invalid JSON syntax"]}),s&&m&&i.jsxs("div",{className:"mb-2 px-3 py-2 bg-warning/10 text-warning-foreground text-sm rounded-md flex items-start gap-2 mx-6 mt-4 shrink-0 border border-warning/20",children:[i.jsx(ma,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Missing required fields:"})," ",i.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:f.join(", ")}),i.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"These fields will use default values at runtime."})]})]}),i.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-4 pt-4",children:i.jsx("div",{className:"h-full border rounded-md overflow-hidden bg-background",children:i.jsx(UC,{value:a,onChange:d,language:"json",minHeight:"100%"})})}),i.jsx("div",{className:"mx-6 mb-4",children:i.jsx("div",{className:"border rounded-md overflow-hidden",children:i.jsx(Sd,{profileEnv:u})})})]})})}function qC(){const[a,s]=y.useState(""),[r,u]=y.useState(""),[d,f]=y.useState(null),[m,p]=y.useState(!1),{login:x,authRequired:b,isAuthenticated:C}=nd(),v=Wc(),M=Zc().state?.from?.pathname||"/";if(y.useEffect(()=>{(C||!b)&&v(M,{replace:!0})},[C,b,v,M]),C||!b)return null;const O=async U=>{U.preventDefault(),f(null),p(!0);try{await x(a,r),v(M,{replace:!0})}catch(_){f(_ instanceof Error?_.message:"Login failed")}finally{p(!1)}};return i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsxs(A2,{className:"w-full max-w-sm",children:[i.jsxs(O2,{className:"space-y-1 text-center",children:[i.jsx("div",{className:"mx-auto mb-2 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:i.jsx(Ab,{className:"h-6 w-6 text-primary"})}),i.jsx(z2,{className:"text-2xl",children:"CCS Dashboard"}),i.jsx(D2,{children:"Enter your credentials to access the dashboard"})]}),i.jsx(_2,{children:i.jsxs("form",{onSubmit:O,className:"space-y-4",children:[d&&i.jsxs(xd,{variant:"destructive",children:[i.jsx(Fc,{className:"h-4 w-4"}),i.jsx(yd,{children:d})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(yn,{htmlFor:"username",children:"Username"}),i.jsx(Rn,{id:"username",type:"text",value:a,onChange:U=>s(U.target.value),placeholder:"Enter username",autoComplete:"username",disabled:m,required:!0})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(yn,{htmlFor:"password",children:"Password"}),i.jsx(Rn,{id:"password",type:"password",value:r,onChange:U=>u(U.target.value),placeholder:"Enter password",autoComplete:"current-password",disabled:m,required:!0})]}),i.jsx(ot,{type:"submit",className:"w-full",disabled:m,children:m?i.jsxs(i.Fragment,{children:[i.jsx(En,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing in..."]}):"Sign In"})]})})]})})}const BC=y.lazy(()=>St(()=>import("./index-CQOKzUPp.js"),__vite__mapDeps([18,1,2,4,5,7,19,6,8,9])).then(a=>({default:a.AnalyticsPage}))),HC=y.lazy(()=>St(()=>import("./api-B_98E0aE.js"),__vite__mapDeps([20,1,2,5,21,15,6,4,22,7,8,9])).then(a=>({default:a.ApiPage}))),LC=y.lazy(()=>St(()=>import("./cliproxy-BTwsOIoc.js"),__vite__mapDeps([23,1,2,5,13,6,4,21,15,22,3,14,7,8,9])).then(a=>({default:a.CliproxyPage}))),YC=y.lazy(()=>St(()=>import("./cliproxy-control-panel-CxmD0q1S.js"),__vite__mapDeps([24,1,2,5,13,4,6,7,8,9])).then(a=>({default:a.CliproxyControlPanelPage}))),GC=y.lazy(()=>St(()=>import("./copilot-Bygut-Du.js"),__vite__mapDeps([25,1,2,5,21,15,4,22,3,6,7,8,9])).then(a=>({default:a.CopilotPage}))),KC=y.lazy(()=>St(()=>import("./cursor-mqWvlWwz.js"),__vite__mapDeps([26,1,2,6,5,13,3,22,4,7,8,9])).then(a=>({default:a.CursorPage}))),QC=y.lazy(()=>St(()=>import("./accounts-C_IFZxdY.js"),__vite__mapDeps([27,1,2,5,15,6,4,7,8,9])).then(a=>({default:a.AccountsPage}))),VC=y.lazy(()=>St(()=>Promise.resolve().then(()=>lw),void 0).then(a=>({default:a.SettingsPage}))),XC=y.lazy(()=>St(()=>import("./health-JiOp2s6o.js"),__vite__mapDeps([28,1,2,5,6,4,7,8,9])).then(a=>({default:a.HealthPage}))),ZC=y.lazy(()=>St(()=>import("./shared-BId9fr7t.js"),__vite__mapDeps([29,1,2,4,5,6,7,8,9])).then(a=>({default:a.SharedPage})));function kn(){return i.jsx("div",{className:"flex h-64 items-center justify-center",children:i.jsx(En,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}function WC(){return i.jsx($v,{client:jS,children:i.jsx(CS,{defaultTheme:"system",storageKey:"vite-ui-theme",children:i.jsx(ES,{children:i.jsx(zS,{children:i.jsxs(Xv,{children:[i.jsxs(Zv,{children:[i.jsx(Gt,{path:"/login",element:i.jsx(qC,{})}),i.jsx(Gt,{element:i.jsx(DS,{}),children:i.jsxs(Gt,{element:i.jsx(iN,{}),children:[i.jsx(Gt,{path:"/",element:i.jsx(l2,{})}),i.jsx(Gt,{path:"/analytics",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(BC,{})})}),i.jsx(Gt,{path:"/providers",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(HC,{})})}),i.jsx(Gt,{path:"/cliproxy",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(LC,{})})}),i.jsx(Gt,{path:"/cliproxy/control-panel",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(YC,{})})}),i.jsx(Gt,{path:"/copilot",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(GC,{})})}),i.jsx(Gt,{path:"/cursor",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(KC,{})})}),i.jsx(Gt,{path:"/accounts",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(QC,{})})}),i.jsx(Gt,{path:"/settings",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(VC,{})})}),i.jsx(Gt,{path:"/health",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(XC,{})})}),i.jsx(Gt,{path:"/shared",element:i.jsx(y.Suspense,{fallback:i.jsx(kn,{}),children:i.jsx(ZC,{})})})]})})]}),i.jsx(Jv,{position:"top-right"})]})})})})})}const Ix=document.getElementById("root");if(!Ix)throw new Error("Root element not found. Failed to mount React application.");bS.createRoot(Ix).render(i.jsx(y.StrictMode,{children:i.jsx(WC,{})}));export{H2 as $,g2 as A,Ya as B,A2 as C,kE as D,M1 as E,T1 as F,A1 as G,jx as H,Rn as I,vd as J,Xr as K,yn as L,Qc as M,qE as N,D2 as O,Vg as P,HE as Q,BE as R,Le as S,Ga as T,LE as U,Ex as V,YE as W,QE as X,U2 as Y,XE as Z,q2 as _,_2 as a,wE as a$,j1 as a0,rE as a1,hE as a2,pE as a3,id as a4,rd as a5,od as a6,ud as a7,cd as a8,GE as a9,xE as aA,yE as aB,vE as aC,bE as aD,ZE as aE,iE as aF,E1 as aG,uE as aH,cE as aI,w1 as aJ,C1 as aK,dE as aL,fE as aM,mE as aN,oE as aO,xd as aP,Nx as aQ,yd as aR,ui as aS,lE as aT,sE as aU,PE as aV,t2 as aW,DE as aX,zx as aY,I2 as aZ,ew as a_,R2 as aa,KE as ab,uN as ac,TE as ad,Ze as ae,OE as af,gE as ag,zE as ah,Rp as ai,AE as aj,VE as ak,B2 as al,Z1 as am,BN as an,XS as ao,ZS as ap,lo as aq,ao as ar,ml as as,I1 as at,F1 as au,eN as av,tN as aw,G2 as ax,HN as ay,tx as az,ot as b,SE as b0,CE as b1,NE as b2,jE as b3,ME as b4,EE as b5,Hr as b6,G as c,WE as d,$E as e,sw as f,RC as g,aE as h,O2 as i,z2 as j,TN as k,AN as l,gl as m,JE as n,Ka as o,Qa as p,Xp as q,v2 as r,UE as s,u2 as t,ed as u,p2 as v,_E as w,RE as x,i2 as y,m2 as z};