@coseung2/opencodex 2.8.0-cs.7 → 2.8.0-cs.9

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.
@@ -5,8 +5,8 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
5
5
  `);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
6
6
  `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{le=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ce(n):``}function de(e,t){switch(e.tag){case 26:case 27:case 5:return ce(e.type);case 16:return ce(`Lazy`);case 13:return e.child!==t&&t!==null?ce(`Suspense Fallback`):ce(`Suspense`);case 19:return ce(`SuspenseList`);case 0:case 15:return ue(e.type,!1);case 11:return ue(e.type.render,!1);case 1:return ue(e.type,!0);case 31:return ce(`Activity`);default:return``}}function fe(e){try{var t=``,n=null;do t+=de(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
7
7
  Error generating stack: `+e.message+`
8
- `+e.stack}}var pe=Object.prototype.hasOwnProperty,me=t.unstable_scheduleCallback,he=t.unstable_cancelCallback,ge=t.unstable_shouldYield,_e=t.unstable_requestPaint,ve=t.unstable_now,ye=t.unstable_getCurrentPriorityLevel,be=t.unstable_ImmediatePriority,xe=t.unstable_UserBlockingPriority,Se=t.unstable_NormalPriority,Ce=t.unstable_LowPriority,we=t.unstable_IdlePriority,Te=t.log,Ee=t.unstable_setDisableYieldValue,De=null,Oe=null;function ke(e){if(typeof Te==`function`&&Ee(e),Oe&&typeof Oe.setStrictMode==`function`)try{Oe.setStrictMode(De,e)}catch{}}var Ae=Math.clz32?Math.clz32:Ne,je=Math.log,Me=Math.LN2;function Ne(e){return e>>>=0,e===0?32:31-(je(e)/Me|0)|0}var Pe=256,Fe=262144,Ie=4194304;function Le(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Re(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Le(n))):i=Le(o):i=Le(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Le(n))):i=Le(o)):i=Le(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function ze(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Be(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ve(){var e=Ie;return Ie<<=1,!(Ie&62914560)&&(Ie=4194304),e}function K(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function He(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ue(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-Ae(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&We(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function We(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Ae(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Ge(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ae(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Ke(e,t){var n=t&-t;return n=n&42?1:qe(n),(n&(e.suspendedLanes|t))===0?n:0}function qe(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Je(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Ye(){var e=L.p;return e===0?(e=window.event,e===void 0?32:mp(e.type)):e}function Xe(e,t){var n=L.p;try{return L.p=e,t()}finally{L.p=n}}var Ze=Math.random().toString(36).slice(2),Qe=`__reactFiber$`+Ze,$e=`__reactProps$`+Ze,et=`__reactContainer$`+Ze,tt=`__reactEvents$`+Ze,nt=`__reactListeners$`+Ze,rt=`__reactHandles$`+Ze,it=`__reactResources$`+Ze,q=`__reactMarker$`+Ze;function at(e){delete e[Qe],delete e[$e],delete e[tt],delete e[nt],delete e[rt]}function ot(e){var t=e[Qe];if(t)return t;for(var n=e.parentNode;n;){if(t=n[et]||n[Qe]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=df(e);e!==null;){if(n=e[Qe])return n;e=df(e)}return t}e=n,n=e.parentNode}return null}function st(e){if(e=e[Qe]||e[et]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function ct(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function lt(e){var t=e[it];return t||=e[it]={hoistableStyles:new Map,hoistableScripts:new Map},t}function J(e){e[q]=!0}var ut=new Set,dt={};function ft(e,t){pt(e,t),pt(e+`Capture`,t)}function pt(e,t){for(dt[e]=t,e=0;e<t.length;e++)ut.add(t[e])}var mt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),ht={},gt={};function _t(e){return pe.call(gt,e)?!0:pe.call(ht,e)?!1:mt.test(e)?gt[e]=!0:(ht[e]=!0,!1)}function vt(e,t,n){if(_t(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function yt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function bt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function xt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function St(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Ct(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function wt(e){if(!e._valueTracker){var t=St(e)?`checked`:`value`;e._valueTracker=Ct(e,t,``+e[t])}}function Tt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=St(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function Et(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Dt=/[\n"\\]/g;function Ot(e){return e.replace(Dt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function kt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+xt(t)):e.value!==``+xt(t)&&(e.value=``+xt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):jt(e,o,xt(n)):jt(e,o,xt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+xt(s):e.removeAttribute(`name`)}function At(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){wt(e);return}n=n==null?``:``+xt(n),t=t==null?n:``+xt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),wt(e)}function jt(e,t,n){t===`number`&&Et(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function Mt(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+xt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Nt(e,t,n){if(t!=null&&(t=``+xt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+xt(n)}function Pt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(F(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=xt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),wt(e)}function Ft(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var It=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Lt(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||It.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Rt(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Lt(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Lt(e,o,t[o])}function zt(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Bt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),Vt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Ht(e){return Vt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Ut(){}var Wt=null;function Gt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Kt=null,qt=null;function Jt(e){var t=st(e);if(t&&(e=t.stateNode)){var n=e[$e]||null;a:switch(e=t.stateNode,t.type){case`input`:if(kt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Ot(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[$e]||null;if(!a)throw Error(i(90));kt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Tt(r)}break a;case`textarea`:Nt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Mt(e,!!n.multiple,t,!1)}}}var Yt=!1;function Xt(e,t,n){if(Yt)return e(t,n);Yt=!0;try{return e(t)}finally{if(Yt=!1,(Kt!==null||qt!==null)&&(vu(),Kt&&(t=Kt,e=qt,qt=Kt=null,Jt(t),e)))for(t=0;t<e.length;t++)Jt(e[t])}}function Zt(e,t){var n=e.stateNode;if(n===null)return null;var r=n[$e]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var Qt=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),$t=!1;if(Qt)try{var en={};Object.defineProperty(en,"passive",{get:function(){$t=!0}}),window.addEventListener(`test`,en,en),window.removeEventListener(`test`,en,en)}catch{$t=!1}var tn=null,nn=null,rn=null;function an(){if(rn)return rn;var e,t=nn,n=t.length,r,i=`value`in tn?tn.value:tn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return rn=i.slice(e,1<r?1-r:void 0)}function on(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function sn(){return!0}function Y(){return!1}function X(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?sn:Y,this.isPropagationStopped=Y,this}return h(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=sn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=sn)},persist:function(){},isPersistent:sn}),t}var cn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ln=X(cn),un=h({},cn,{view:0,detail:0}),dn=X(un),fn,pn,mn,hn=h({},un,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:En,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==mn&&(mn&&e.type===`mousemove`?(fn=e.screenX-mn.screenX,pn=e.screenY-mn.screenY):pn=fn=0,mn=e),fn)},movementY:function(e){return`movementY`in e?e.movementY:pn}}),gn=X(hn),_n=X(h({},hn,{dataTransfer:0})),vn=X(h({},un,{relatedTarget:0})),yn=X(h({},cn,{animationName:0,elapsedTime:0,pseudoElement:0})),bn=X(h({},cn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),xn=X(h({},cn,{data:0})),Sn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Cn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},wn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Tn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=wn[e])?!!t[e]:!1}function En(){return Tn}var Dn=X(h({},un,{key:function(e){if(e.key){var t=Sn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=on(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Cn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:En,charCode:function(e){return e.type===`keypress`?on(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?on(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),On=X(h({},hn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),kn=X(h({},un,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:En})),An=X(h({},cn,{propertyName:0,elapsedTime:0,pseudoElement:0})),jn=X(h({},hn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Mn=X(h({},cn,{newState:0,oldState:0})),Nn=[9,13,27,32],Pn=Qt&&`CompositionEvent`in window,Fn=null;Qt&&`documentMode`in document&&(Fn=document.documentMode);var In=Qt&&`TextEvent`in window&&!Fn,Ln=Qt&&(!Pn||Fn&&8<Fn&&11>=Fn),Rn=` `,zn=!1;function Bn(e,t){switch(e){case`keyup`:return Nn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Vn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Hn=!1;function Un(e,t){switch(e){case`compositionend`:return Vn(t);case`keypress`:return t.which===32?(zn=!0,Rn):null;case`textInput`:return e=t.data,e===Rn&&zn?null:e;default:return null}}function Wn(e,t){if(Hn)return e===`compositionend`||!Pn&&Bn(e,t)?(e=an(),rn=nn=tn=null,Hn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Ln&&t.locale!==`ko`?null:t.data;default:return null}}var Gn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Kn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Gn[e.type]:t===`textarea`}function qn(e,t,n,r){Kt?qt?qt.push(r):qt=[r]:Kt=r,t=Td(t,`onChange`),0<t.length&&(n=new ln(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Jn=null,Yn=null;function Xn(e){vd(e,0)}function Zn(e){if(Tt(ct(e)))return e}function Qn(e,t){if(e===`change`)return t}var $n=!1;if(Qt){var er;if(Qt){var tr=`oninput`in document;if(!tr){var nr=document.createElement(`div`);nr.setAttribute(`oninput`,`return;`),tr=typeof nr.oninput==`function`}er=tr}else er=!1;$n=er&&(!document.documentMode||9<document.documentMode)}function rr(){Jn&&(Jn.detachEvent(`onpropertychange`,ir),Yn=Jn=null)}function ir(e){if(e.propertyName===`value`&&Zn(Yn)){var t=[];qn(t,Yn,e,Gt(e)),Xt(Xn,t)}}function ar(e,t,n){e===`focusin`?(rr(),Jn=t,Yn=n,Jn.attachEvent(`onpropertychange`,ir)):e===`focusout`&&rr()}function or(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Zn(Yn)}function sr(e,t){if(e===`click`)return Zn(t)}function cr(e,t){if(e===`input`||e===`change`)return Zn(t)}function lr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var ur=typeof Object.is==`function`?Object.is:lr;function dr(e,t){if(ur(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!pe.call(t,i)||!ur(e[i],t[i]))return!1}return!0}function fr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function pr(e,t){var n=fr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=fr(n)}}function mr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?mr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function hr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Et(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Et(e.document)}return t}function gr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var _r=Qt&&`documentMode`in document&&11>=document.documentMode,vr=null,yr=null,br=null,xr=!1;function Sr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;xr||vr==null||vr!==Et(r)||(r=vr,`selectionStart`in r&&gr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),br&&dr(br,r)||(br=r,r=Td(yr,`onSelect`),0<r.length&&(t=new ln(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=vr)))}function Cr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var wr={animationend:Cr(`Animation`,`AnimationEnd`),animationiteration:Cr(`Animation`,`AnimationIteration`),animationstart:Cr(`Animation`,`AnimationStart`),transitionrun:Cr(`Transition`,`TransitionRun`),transitionstart:Cr(`Transition`,`TransitionStart`),transitioncancel:Cr(`Transition`,`TransitionCancel`),transitionend:Cr(`Transition`,`TransitionEnd`)},Tr={},Er={};Qt&&(Er=document.createElement(`div`).style,`AnimationEvent`in window||(delete wr.animationend.animation,delete wr.animationiteration.animation,delete wr.animationstart.animation),`TransitionEvent`in window||delete wr.transitionend.transition);function Dr(e){if(Tr[e])return Tr[e];if(!wr[e])return e;var t=wr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Er)return Tr[e]=t[n];return e}var Or=Dr(`animationend`),kr=Dr(`animationiteration`),Ar=Dr(`animationstart`),jr=Dr(`transitionrun`),Mr=Dr(`transitionstart`),Nr=Dr(`transitioncancel`),Pr=Dr(`transitionend`),Fr=new Map,Ir=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Ir.push(`scrollEnd`);function Lr(e,t){Fr.set(e,t),ft(t,[e])}var Rr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},zr=[],Br=0,Vr=0;function Hr(){for(var e=Br,t=Vr=Br=0;t<e;){var n=zr[t];zr[t++]=null;var r=zr[t];zr[t++]=null;var i=zr[t];zr[t++]=null;var a=zr[t];if(zr[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Kr(n,i,a)}}function Ur(e,t,n,r){zr[Br++]=e,zr[Br++]=t,zr[Br++]=n,zr[Br++]=r,Vr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Wr(e,t,n,r){return Ur(e,t,n,r),qr(e)}function Gr(e,t){return Ur(e,null,null,t),qr(e)}function Kr(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-Ae(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function qr(e){if(50<lu)throw lu=0,uu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Jr={};function Yr(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Xr(e,t,n,r){return new Yr(e,t,n,r)}function Zr(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Qr(e,t){var n=e.alternate;return n===null?(n=Xr(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function $r(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function ei(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)Zr(e)&&(s=1);else if(typeof e==`string`)s=Uf(e,n,W.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case k:return e=Xr(31,n,t,a),e.elementType=k,e.lanes=o,e;case y:return ti(n.children,a,o,t);case b:s=8,a|=24;break;case x:return e=Xr(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case T:return e=Xr(13,n,t,a),e.elementType=T,e.lanes=o,e;case E:return e=Xr(19,n,t,a),e.elementType=E,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case C:s=10;break a;case S:s=9;break a;case w:s=11;break a;case D:s=14;break a;case O:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=Xr(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function ti(e,t,n,r){return e=Xr(7,e,r,t),e.lanes=n,e}function ni(e,t,n){return e=Xr(6,e,null,t),e.lanes=n,e}function ri(e){var t=Xr(18,null,null,0);return t.stateNode=e,t}function ii(e,t,n){return t=Xr(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var ai=new WeakMap;function oi(e,t){if(typeof e==`object`&&e){var n=ai.get(e);return n===void 0?(t={value:e,source:t,stack:fe(t)},ai.set(e,t),t):n}return{value:e,source:t,stack:fe(t)}}var si=[],ci=0,li=null,ui=0,di=[],fi=0,pi=null,mi=1,hi=``;function gi(e,t){si[ci++]=ui,si[ci++]=li,li=e,ui=t}function _i(e,t,n){di[fi++]=mi,di[fi++]=hi,di[fi++]=pi,pi=e;var r=mi;e=hi;var i=32-Ae(r)-1;r&=~(1<<i),n+=1;var a=32-Ae(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,mi=1<<32-Ae(t)+i|n<<i|r,hi=a+e}else mi=1<<a|n<<i|r,hi=e}function vi(e){e.return!==null&&(gi(e,1),_i(e,1,0))}function yi(e){for(;e===li;)li=si[--ci],si[ci]=null,ui=si[--ci],si[ci]=null;for(;e===pi;)pi=di[--fi],di[fi]=null,hi=di[--fi],di[fi]=null,mi=di[--fi],di[fi]=null}function bi(e,t){di[fi++]=mi,di[fi++]=hi,di[fi++]=pi,mi=t.id,hi=t.overflow,pi=e}var xi=null,Si=null,Ci=!1,wi=null,Ti=!1,Ei=Error(i(519));function Di(e){throw Ni(oi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Ei}function Oi(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[Qe]=e,t[$e]=r,n){case`dialog`:$(`cancel`,t),$(`close`,t);break;case`iframe`:case`object`:case`embed`:$(`load`,t);break;case`video`:case`audio`:for(n=0;n<gd.length;n++)$(gd[n],t);break;case`source`:$(`error`,t);break;case`img`:case`image`:case`link`:$(`error`,t),$(`load`,t);break;case`details`:$(`toggle`,t);break;case`input`:$(`invalid`,t),At(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:$(`invalid`,t);break;case`textarea`:$(`invalid`,t),Pt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||jd(t.textContent,n)?(r.popover!=null&&($(`beforetoggle`,t),$(`toggle`,t)),r.onScroll!=null&&$(`scroll`,t),r.onScrollEnd!=null&&$(`scrollend`,t),r.onClick!=null&&(t.onclick=Ut),t=!0):t=!1,t||Di(e,!0)}function ki(e){for(xi=e.return;xi;)switch(xi.tag){case 5:case 31:case 13:Ti=!1;return;case 27:case 3:Ti=!0;return;default:xi=xi.return}}function Ai(e){if(e!==xi)return!1;if(!Ci)return ki(e),Ci=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||Ud(e.type,e.memoizedProps)),n=!n),n&&Si&&Di(e),ki(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Si=uf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Si=uf(e)}else t===27?(t=Si,Zd(e.type)?(e=lf,lf=null,Si=e):Si=t):Si=xi?cf(e.stateNode.nextSibling):null;return!0}function ji(){Si=xi=null,Ci=!1}function Mi(){var e=wi;return e!==null&&(Yl===null?Yl=e:Yl.push.apply(Yl,e),wi=null),e}function Ni(e){wi===null?wi=[e]:wi.push(e)}var Pi=V(null),Fi=null,Ii=null;function Li(e,t,n){U(Pi,t._currentValue),t._currentValue=n}function Ri(e){e._currentValue=Pi.current,H(Pi)}function zi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Bi(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),zi(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),zi(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Vi(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;ur(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===ne.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[Qf]:e.push(Qf))}a=a.return}e!==null&&Bi(t,e,n,r),t.flags|=262144}function Hi(e){for(e=e.firstContext;e!==null;){if(!ur(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ui(e){Fi=e,Ii=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Wi(e){return Ki(Fi,e)}function Gi(e,t){return Fi===null&&Ui(e),Ki(e,t)}function Ki(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Ii===null){if(e===null)throw Error(i(308));Ii=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Ii=Ii.next=t;return n}var qi=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Ji=t.unstable_scheduleCallback,Yi=t.unstable_NormalPriority,Xi={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Zi(){return{controller:new qi,data:new Map,refCount:0}}function Qi(e){e.refCount--,e.refCount===0&&Ji(Yi,function(){e.controller.abort()})}var $i=null,ea=0,ta=0,na=null;function ra(e,t){if($i===null){var n=$i=[];ea=0,ta=ud(),na={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return ea++,t.then(ia,ia),t}function ia(){if(--ea===0&&$i!==null){na!==null&&(na.status=`fulfilled`);var e=$i;$i=null,ta=0,na=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function aa(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var oa=I.S;I.S=function(e,t){Ql=ve(),typeof t==`object`&&t&&typeof t.then==`function`&&ra(e,t),oa!==null&&oa(e,t)};var sa=V(null);function ca(){var e=sa.current;return e===null?Pl.pooledCache:e}function la(e,t){t===null?U(sa,sa.current):U(sa,t.pool)}function ua(){var e=ca();return e===null?null:{parent:Xi._currentValue,pool:e}}var da=Error(i(460)),fa=Error(i(474)),pa=Error(i(542)),ma={then:function(){}};function ha(e){return e=e.status,e===`fulfilled`||e===`rejected`}function ga(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Ut,Ut),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ba(e),e;default:if(typeof t.status==`string`)t.then(Ut,Ut);else{if(e=Pl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ba(e),e}throw va=t,da}}function _a(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(va=e,da):e}}var va=null;function ya(){if(va===null)throw Error(i(459));var e=va;return va=null,e}function ba(e){if(e===da||e===pa)throw Error(i(483))}var xa=null,Sa=0;function Ca(e){var t=Sa;return Sa+=1,xa===null&&(xa=[]),ga(xa,e,t)}function wa(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Ta(e,t){throw t.$$typeof===g?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Ea(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=Qr(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=ni(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===y?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===O&&_a(i)===t.type)?(t=a(t,n.props),wa(t,n),t.return=e,t):(t=ei(n.type,n.key,n.props,null,e.mode,r),wa(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=ii(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=ti(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=ni(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case _:return n=ei(t.type,t.key,t.props,null,e.mode,n),wa(n,t),n.return=e,n;case v:return t=ii(t,e.mode,n),t.return=e,t;case O:return t=_a(t),f(e,t,n)}if(F(t)||M(t))return t=ti(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Ca(t),n);if(t.$$typeof===C)return f(e,Gi(e,t),n);Ta(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case _:return n.key===i?l(e,t,n,r):null;case v:return n.key===i?u(e,t,n,r):null;case O:return n=_a(n),p(e,t,n,r)}if(F(n)||M(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Ca(n),r);if(n.$$typeof===C)return p(e,t,Gi(e,n),r);Ta(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case _:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case v:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case O:return r=_a(r),m(e,t,n,r,i)}if(F(r)||M(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,Ca(r),i);if(r.$$typeof===C)return m(e,t,n,Gi(t,r),i);Ta(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Ci&&gi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return Ci&&gi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),Ci&&gi(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Ci&&gi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Ci&&gi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Ci&&gi(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case _:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===O&&_a(l)===r.type){n(e,r.sibling),c=a(r,o.props),wa(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=ti(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=ei(o.type,o.key,o.props,null,e.mode,c),wa(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ii(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=_a(o),b(e,r,o,c)}if(F(o))return h(e,r,o,c);if(M(o)){if(l=M(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,Ca(o),c);if(o.$$typeof===C)return b(e,r,Gi(e,o),c);Ta(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=ni(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Sa=0;var i=b(e,t,n,r);return xa=null,i}catch(t){if(t===da||t===pa)throw t;var a=Xr(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Da=Ea(!0),Oa=Ea(!1),ka=!1;function Aa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ja(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ma(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Na(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Nl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=qr(e),Kr(e,null,n),t}return Ur(e,r,t,n),qr(e)}function Pa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ge(e,n)}}function Fa(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Ia=!1;function La(){if(Ia){var e=na;if(e!==null)throw e}}function Ra(e,t,n,r){Ia=!1;var i=e.updateQueue;ka=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Fl&f)===f:(r&f)===f){f!==0&&f===ta&&(Ia=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(m=g.payload,typeof m==`function`){d=m.call(_,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=g.payload,f=typeof m==`function`?m.call(_,d,f):m,f==null)break a;d=h({},d,f);break a;case 2:ka=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Ul|=o,e.lanes=o,e.memoizedState=d}}function za(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Ba(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)za(n[e],t)}var Va=V(null),Ha=V(0);function Ua(e,t){e=Vl,U(Ha,e),U(Va,t),Vl=e|t.baseLanes}function Wa(){U(Ha,Vl),U(Va,Va.current)}function Ga(){Vl=Ha.current,H(Va),H(Ha)}var Ka=V(null),qa=null;function Ja(e){var t=e.alternate;U($a,$a.current&1),U(Ka,e),qa===null&&(t===null||Va.current!==null||t.memoizedState!==null)&&(qa=e)}function Ya(e){U($a,$a.current),U(Ka,e),qa===null&&(qa=e)}function Xa(e){e.tag===22?(U($a,$a.current),U(Ka,e),qa===null&&(qa=e)):Za(e)}function Za(){U($a,$a.current),U(Ka,Ka.current)}function Qa(e){H(Ka),qa===e&&(qa=null),H($a)}var $a=V(0);function eo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||af(n)||of(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var to=0,Z=null,no=null,ro=null,io=!1,ao=!1,oo=!1,so=0,co=0,lo=null,uo=0;function fo(){throw Error(i(321))}function po(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!ur(e[n],t[n]))return!1;return!0}function mo(e,t,n,r,i,a){return to=a,Z=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,I.H=e===null||e.memoizedState===null?js:Ms,oo=!1,a=n(r,i),oo=!1,ao&&(a=go(t,n,r,i)),ho(e),a}function ho(e){I.H=As;var t=no!==null&&no.next!==null;if(to=0,ro=no=Z=null,io=!1,co=0,lo=null,t)throw Error(i(300));e===null||Ys||(e=e.dependencies,e!==null&&Hi(e)&&(Ys=!0))}function go(e,t,n,r){Z=e;var a=0;do{if(ao&&(lo=null),co=0,ao=!1,25<=a)throw Error(i(301));if(a+=1,ro=no=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}I.H=Ns,o=t(n,r)}while(ao);return o}function _o(){var e=I.H,t=e.useState()[0];return t=typeof t.then==`function`?wo(t):t,e=e.useState()[0],(no===null?null:no.memoizedState)!==e&&(Z.flags|=1024),t}function vo(){var e=so!==0;return so=0,e}function yo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function bo(e){if(io){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}io=!1}to=0,ro=no=Z=null,ao=!1,co=so=0,lo=null}function xo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ro===null?Z.memoizedState=ro=e:ro=ro.next=e,ro}function So(){if(no===null){var e=Z.alternate;e=e===null?null:e.memoizedState}else e=no.next;var t=ro===null?Z.memoizedState:ro.next;if(t!==null)ro=t,no=e;else{if(e===null)throw Z.alternate===null?Error(i(467)):Error(i(310));no=e,e={memoizedState:no.memoizedState,baseState:no.baseState,baseQueue:no.baseQueue,queue:no.queue,next:null},ro===null?Z.memoizedState=ro=e:ro=ro.next=e}return ro}function Co(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function wo(e){var t=co;return co+=1,lo===null&&(lo=[]),e=ga(lo,e,t),t=Z,(ro===null?t.memoizedState:ro.next)===null&&(t=t.alternate,I.H=t===null||t.memoizedState===null?js:Ms),e}function To(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return wo(e);if(e.$$typeof===C)return Wi(e)}throw Error(i(438,String(e)))}function Eo(e){var t=null,n=Z.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=Z.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=Co(),Z.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=A;return t.index++,n}function Do(e,t){return typeof t==`function`?t(e):t}function Oo(e){return ko(So(),no,e)}function ko(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(to&f)===f:(Fl&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===ta&&(d=!0);else if((to&p)===p){u=u.next,p===ta&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,Z.lanes|=p,Ul|=p;f=u.action,oo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,Z.lanes|=f,Ul|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!ur(o,e.memoizedState)&&(Ys=!0,d&&(n=na,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Ao(e){var t=So(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);ur(o,t.memoizedState)||(Ys=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function jo(e,t,n){var r=Z,a=So(),o=Ci;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!ur((no||a).memoizedState,n);if(s&&(a.memoizedState=n,Ys=!0),a=a.queue,ns(Po.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||ro!==null&&ro.memoizedState.tag&1){if(r.flags|=2048,Zo(9,{destroy:void 0},No.bind(null,r,a,n,t),null),Pl===null)throw Error(i(349));o||to&127||Mo(r,t,n)}return n}function Mo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Z.updateQueue,t===null?(t=Co(),Z.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function No(e,t,n,r){t.value=n,t.getSnapshot=r,Fo(t)&&Io(e)}function Po(e,t,n){return n(function(){Fo(t)&&Io(e)})}function Fo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!ur(e,n)}catch{return!0}}function Io(e){var t=Gr(e,2);t!==null&&pu(t,e,2)}function Lo(e){var t=xo();if(typeof e==`function`){var n=e;if(e=n(),oo){ke(!0);try{n()}finally{ke(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:e},t}function Ro(e,t,n,r){return e.baseState=n,ko(e,no,typeof r==`function`?r:Do)}function zo(e,t,n,r,a){if(Ds(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};I.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Bo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Bo(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=I.T,o={};I.T=o;try{var s=n(i,r),c=I.S;c!==null&&c(o,s),Vo(e,t,s)}catch(n){Uo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),I.T=a}}else try{a=n(i,r),Vo(e,t,a)}catch(n){Uo(e,t,n)}}function Vo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Ho(e,t,n)},function(n){return Uo(e,t,n)}):Ho(e,t,n)}function Ho(e,t,n){t.status=`fulfilled`,t.value=n,Wo(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Bo(e,n)))}function Uo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Wo(t),t=t.next;while(t!==r)}e.action=null}function Wo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Go(e,t){return t}function Ko(e,t){if(Ci){var n=Pl.formState;if(n!==null){a:{var r=Z;if(Ci){if(Si){b:{for(var i=Si,a=Ti;i.nodeType!==8;){if(!a){i=null;break b}if(i=cf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Si=cf(i.nextSibling),r=i.data===`F!`;break a}}Di(r)}r=!1}r&&(t=n[0])}}return n=xo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Go,lastRenderedState:t},n.queue=r,n=ws.bind(null,Z,r),r.dispatch=n,r=Lo(!1),a=Es.bind(null,Z,!1,r.queue),r=xo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=zo.bind(null,Z,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function qo(e){return Jo(So(),no,e)}function Jo(e,t,n){if(t=ko(e,t,Go)[0],e=Oo(Do)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=wo(t)}catch(e){throw e===da?pa:e}else r=t;t=So();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Z.flags|=2048,Zo(9,{destroy:void 0},Yo.bind(null,i,n),null)),[r,a,e]}function Yo(e,t){e.action=t}function Xo(e){var t=So(),n=no;if(n!==null)return Jo(t,n,e);So(),t=t.memoizedState,n=So();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Zo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=Z.updateQueue,t===null&&(t=Co(),Z.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Qo(){return So().memoizedState}function $o(e,t,n,r){var i=xo();Z.flags|=e,i.memoizedState=Zo(1|t,{destroy:void 0},n,r===void 0?null:r)}function es(e,t,n,r){var i=So();r=r===void 0?null:r;var a=i.memoizedState.inst;no!==null&&r!==null&&po(r,no.memoizedState.deps)?i.memoizedState=Zo(t,a,n,r):(Z.flags|=e,i.memoizedState=Zo(1|t,a,n,r))}function ts(e,t){$o(8390656,8,e,t)}function ns(e,t){es(2048,8,e,t)}function rs(e){Z.flags|=4;var t=Z.updateQueue;if(t===null)t=Co(),Z.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function is(e){var t=So().memoizedState;return rs({ref:t,nextImpl:e}),function(){if(Nl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function as(e,t){return es(4,2,e,t)}function os(e,t){return es(4,4,e,t)}function ss(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function cs(e,t,n){n=n==null?null:n.concat([e]),es(4,4,ss.bind(null,t,e),n)}function ls(){}function us(e,t){var n=So();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&po(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ds(e,t){var n=So();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&po(t,r[1]))return r[0];if(r=e(),oo){ke(!0);try{e()}finally{ke(!1)}}return n.memoizedState=[r,t],r}function fs(e,t,n){return n===void 0||to&1073741824&&!(Fl&261930)?e.memoizedState=t:(e.memoizedState=n,e=fu(),Z.lanes|=e,Ul|=e,n)}function ps(e,t,n,r){return ur(n,t)?n:Va.current===null?!(to&42)||to&1073741824&&!(Fl&261930)?(Ys=!0,e.memoizedState=n):(e=fu(),Z.lanes|=e,Ul|=e,t):(e=fs(e,n,r),ur(e,t)||(Ys=!0),e)}function ms(e,t,n,r,i){var a=L.p;L.p=a!==0&&8>a?a:8;var o=I.T,s={};I.T=s,Es(e,!1,t,n);try{var c=i(),l=I.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Ts(e,t,aa(c,r),du(e)):Ts(e,t,r,du(e))}catch(n){Ts(e,t,{then:function(){},status:`rejected`,reason:n},du())}finally{L.p=a,o!==null&&s.types!==null&&(o.types=s.types),I.T=o}}function hs(){}function gs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=_s(e).queue;ms(e,a,t,R,n===null?hs:function(){return vs(e),n(r)})}function _s(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:R,baseState:R,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:R},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function vs(e){var t=_s(e);t.next===null&&(t=e.alternate.memoizedState),Ts(e,t.next.queue,{},du())}function ys(){return Wi(Qf)}function bs(){return So().memoizedState}function xs(){return So().memoizedState}function Ss(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=du();e=Ma(n);var r=Na(t,e,n);r!==null&&(pu(r,t,n),Pa(r,t,n)),t={cache:Zi()},e.payload=t;return}t=t.return}}function Cs(e,t,n){var r=du();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ds(e)?Os(t,n):(n=Wr(e,t,n,r),n!==null&&(pu(n,e,r),ks(n,t,r)))}function ws(e,t,n){Ts(e,t,n,du())}function Ts(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ds(e))Os(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,ur(s,o))return Ur(e,t,i,0),Pl===null&&Hr(),!1}catch{}if(n=Wr(e,t,i,r),n!==null)return pu(n,e,r),ks(n,t,r),!0}return!1}function Es(e,t,n,r){if(r={lane:2,revertLane:ud(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ds(e)){if(t)throw Error(i(479))}else t=Wr(e,n,r,2),t!==null&&pu(t,e,2)}function Ds(e){var t=e.alternate;return e===Z||t!==null&&t===Z}function Os(e,t){ao=io=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ks(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ge(e,n)}}var As={readContext:Wi,use:To,useCallback:fo,useContext:fo,useEffect:fo,useImperativeHandle:fo,useLayoutEffect:fo,useInsertionEffect:fo,useMemo:fo,useReducer:fo,useRef:fo,useState:fo,useDebugValue:fo,useDeferredValue:fo,useTransition:fo,useSyncExternalStore:fo,useId:fo,useHostTransitionStatus:fo,useFormState:fo,useActionState:fo,useOptimistic:fo,useMemoCache:fo,useCacheRefresh:fo};As.useEffectEvent=fo;var js={readContext:Wi,use:To,useCallback:function(e,t){return xo().memoizedState=[e,t===void 0?null:t],e},useContext:Wi,useEffect:ts,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),$o(4194308,4,ss.bind(null,t,e),n)},useLayoutEffect:function(e,t){return $o(4194308,4,e,t)},useInsertionEffect:function(e,t){$o(4,2,e,t)},useMemo:function(e,t){var n=xo();t=t===void 0?null:t;var r=e();if(oo){ke(!0);try{e()}finally{ke(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=xo();if(n!==void 0){var i=n(t);if(oo){ke(!0);try{n(t)}finally{ke(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Cs.bind(null,Z,e),[r.memoizedState,e]},useRef:function(e){var t=xo();return e={current:e},t.memoizedState=e},useState:function(e){e=Lo(e);var t=e.queue,n=ws.bind(null,Z,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ls,useDeferredValue:function(e,t){return fs(xo(),e,t)},useTransition:function(){var e=Lo(!1);return e=ms.bind(null,Z,e.queue,!0,!1),xo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Z,a=xo();if(Ci){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Pl===null)throw Error(i(349));Fl&127||Mo(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,ts(Po.bind(null,r,o,e),[e]),r.flags|=2048,Zo(9,{destroy:void 0},No.bind(null,r,o,n,t),null),n},useId:function(){var e=xo(),t=Pl.identifierPrefix;if(Ci){var n=hi,r=mi;n=(r&~(1<<32-Ae(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=so++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=uo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:ys,useFormState:Ko,useActionState:Ko,useOptimistic:function(e){var t=xo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Es.bind(null,Z,!0,n),n.dispatch=t,[e,t]},useMemoCache:Eo,useCacheRefresh:function(){return xo().memoizedState=Ss.bind(null,Z)},useEffectEvent:function(e){var t=xo(),n={impl:e};return t.memoizedState=n,function(){if(Nl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Ms={readContext:Wi,use:To,useCallback:us,useContext:Wi,useEffect:ns,useImperativeHandle:cs,useInsertionEffect:as,useLayoutEffect:os,useMemo:ds,useReducer:Oo,useRef:Qo,useState:function(){return Oo(Do)},useDebugValue:ls,useDeferredValue:function(e,t){return ps(So(),no.memoizedState,e,t)},useTransition:function(){var e=Oo(Do)[0],t=So().memoizedState;return[typeof e==`boolean`?e:wo(e),t]},useSyncExternalStore:jo,useId:bs,useHostTransitionStatus:ys,useFormState:qo,useActionState:qo,useOptimistic:function(e,t){return Ro(So(),no,e,t)},useMemoCache:Eo,useCacheRefresh:xs};Ms.useEffectEvent=is;var Ns={readContext:Wi,use:To,useCallback:us,useContext:Wi,useEffect:ns,useImperativeHandle:cs,useInsertionEffect:as,useLayoutEffect:os,useMemo:ds,useReducer:Ao,useRef:Qo,useState:function(){return Ao(Do)},useDebugValue:ls,useDeferredValue:function(e,t){var n=So();return no===null?fs(n,e,t):ps(n,no.memoizedState,e,t)},useTransition:function(){var e=Ao(Do)[0],t=So().memoizedState;return[typeof e==`boolean`?e:wo(e),t]},useSyncExternalStore:jo,useId:bs,useHostTransitionStatus:ys,useFormState:Xo,useActionState:Xo,useOptimistic:function(e,t){var n=So();return no===null?(n.baseState=e,[e,n.queue.dispatch]):Ro(n,no,e,t)},useMemoCache:Eo,useCacheRefresh:xs};Ns.useEffectEvent=is;function Ps(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:h({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Fs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=du(),i=Ma(r);i.payload=t,n!=null&&(i.callback=n),t=Na(e,i,r),t!==null&&(pu(t,e,r),Pa(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=du(),i=Ma(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Na(e,i,r),t!==null&&(pu(t,e,r),Pa(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=du(),r=Ma(n);r.tag=2,t!=null&&(r.callback=t),t=Na(e,r,n),t!==null&&(pu(t,e,n),Pa(t,e,n))}};function Is(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!dr(n,r)||!dr(i,a):!0}function Ls(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Fs.enqueueReplaceState(t,t.state,null)}function Rs(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=h({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function zs(e){Rr(e)}function Bs(e){console.error(e)}function Vs(e){Rr(e)}function Hs(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Us(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Ws(e,t,n){return n=Ma(n),n.tag=3,n.payload={element:null},n.callback=function(){Hs(e,t)},n}function Gs(e){return e=Ma(e),e.tag=3,e}function Ks(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Us(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Us(t,n,r),typeof i!=`function`&&(tu===null?tu=new Set([this]):tu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function qs(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Vi(t,n,a,!0),n=Ka.current,n!==null){switch(n.tag){case 31:case 13:return qa===null?Tu():n.alternate===null&&Hl===0&&(Hl=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===ma?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Wu(e,r,a)),!1;case 22:return n.flags|=65536,r===ma?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Wu(e,r,a)),!1}throw Error(i(435,n.tag))}return Wu(e,r,a),Tu(),!1}if(Ci)return t=Ka.current,t===null?(r!==Ei&&(t=Error(i(423),{cause:r}),Ni(oi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=oi(r,n),a=Ws(e.stateNode,r,a),Fa(e,a),Hl!==4&&(Hl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Ei&&(e=Error(i(422),{cause:r}),Ni(oi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=oi(o,n),Jl===null?Jl=[o]:Jl.push(o),Hl!==4&&(Hl=2),t===null)return!0;r=oi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Ws(n.stateNode,r,e),Fa(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(tu===null||!tu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Gs(a),Ks(a,e,n,r),Fa(n,a),!1}n=n.return}while(n!==null);return!1}var Js=Error(i(461)),Ys=!1;function Xs(e,t,n,r){t.child=e===null?Oa(t,null,n,r):Da(t,e.child,n,r)}function Zs(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Ui(t),r=mo(e,t,n,o,a,i),s=vo(),e!==null&&!Ys?(yo(e,t,i),xc(e,t,i)):(Ci&&s&&vi(t),t.flags|=1,Xs(e,t,r,i),t.child)}function Qs(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Zr(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,$s(e,t,a,r,i)):(e=ei(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Sc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?dr:n,n(o,r)&&e.ref===t.ref)return xc(e,t,i)}return t.flags|=1,e=Qr(a,r),e.ref=t.ref,e.return=t,t.child=e}function $s(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(dr(a,r)&&e.ref===t.ref)if(Ys=!1,t.pendingProps=r=a,Sc(e,i))e.flags&131072&&(Ys=!0);else return t.lanes=e.lanes,xc(e,t,i)}return sc(e,t,n,r,i)}function ec(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return nc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&la(t,a===null?null:a.cachePool),a===null?Wa():Ua(t,a),Xa(t);else return r=t.lanes=536870912,nc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&la(t,null),Wa(),Za(t)):(la(t,a.cachePool),Ua(t,a),Za(t),t.memoizedState=null);return Xs(e,t,i,n),t.child}function tc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function nc(e,t,n,r,i){var a=ca();return a=a===null?null:{parent:Xi._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&la(t,null),Wa(),Xa(t),e!==null&&Vi(e,t,r,!0),t.childLanes=i,null}function rc(e,t){return t=gc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function ic(e,t,n){return Da(t,e.child,null,n),e=rc(t,t.pendingProps),e.flags|=2,Qa(t),t.memoizedState=null,e}function ac(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Ci){if(r.mode===`hidden`)return e=rc(t,r),t.lanes=536870912,tc(null,e);if(Ya(t),(e=Si)?(e=rf(e,Ti),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:pi===null?null:{id:mi,overflow:hi},retryLane:536870912,hydrationErrors:null},n=ri(e),n.return=t,t.child=n,xi=t,Si=null)):e=null,e===null)throw Di(t);return t.lanes=536870912,null}return rc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Ya(t),a)if(t.flags&256)t.flags&=-257,t=ic(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(Ys||Vi(e,t,n,!1),a=(n&e.childLanes)!==0,Ys||a){if(r=Pl,r!==null&&(s=Ke(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Gr(e,s),pu(r,e,s),Js;Tu(),t=ic(e,t,n)}else e=o.treeContext,Si=cf(s.nextSibling),xi=t,Ci=!0,wi=null,Ti=!1,e!==null&&bi(t,e),t=rc(t,r),t.flags|=4096;return t}return e=Qr(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function oc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function sc(e,t,n,r,i){return Ui(t),n=mo(e,t,n,r,void 0,i),r=vo(),e!==null&&!Ys?(yo(e,t,i),xc(e,t,i)):(Ci&&r&&vi(t),t.flags|=1,Xs(e,t,n,i),t.child)}function cc(e,t,n,r,i,a){return Ui(t),t.updateQueue=null,n=go(t,r,n,i),ho(e),r=vo(),e!==null&&!Ys?(yo(e,t,a),xc(e,t,a)):(Ci&&r&&vi(t),t.flags|=1,Xs(e,t,n,a),t.child)}function lc(e,t,n,r,i){if(Ui(t),t.stateNode===null){var a=Jr,o=n.contextType;typeof o==`object`&&o&&(a=Wi(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Fs,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Aa(t),o=n.contextType,a.context=typeof o==`object`&&o?Wi(o):Jr,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Ps(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Fs.enqueueReplaceState(a,a.state,null),Ra(t,r,a,i),La(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Rs(n,s);a.props=c;var l=a.context,u=n.contextType;o=Jr,typeof u==`object`&&u&&(o=Wi(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Ls(t,a,r,o),ka=!1;var f=t.memoizedState;a.state=f,Ra(t,r,a,i),La(),l=t.memoizedState,s||f!==l||ka?(typeof d==`function`&&(Ps(t,n,d,r),l=t.memoizedState),(c=ka||Is(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,ja(e,t),o=t.memoizedProps,u=Rs(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Jr,typeof l==`object`&&l&&(c=Wi(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Ls(t,a,r,c),ka=!1,f=t.memoizedState,a.state=f,Ra(t,r,a,i),La();var p=t.memoizedState;o!==d||f!==p||ka||e!==null&&e.dependencies!==null&&Hi(e.dependencies)?(typeof s==`function`&&(Ps(t,n,s,r),p=t.memoizedState),(u=ka||Is(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Hi(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,oc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Da(t,e.child,null,i),t.child=Da(t,null,n,i)):Xs(e,t,n,i),t.memoizedState=a.state,e=t.child):e=xc(e,t,i),e}function uc(e,t,n,r){return ji(),t.flags|=256,Xs(e,t,n,r),t.child}var dc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function fc(e){return{baseLanes:e,cachePool:ua()}}function pc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Kl),e}function mc(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:($a.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Ci){if(a?Ja(t):Za(t),(e=Si)?(e=rf(e,Ti),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:pi===null?null:{id:mi,overflow:hi},retryLane:536870912,hydrationErrors:null},n=ri(e),n.return=t,t.child=n,xi=t,Si=null)):e=null,e===null)throw Di(t);return of(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(Za(t),a=t.mode,c=gc({mode:`hidden`,children:c},a),r=ti(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=fc(n),r.childLanes=pc(e,s,n),t.memoizedState=dc,tc(null,r)):(Ja(t),hc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(Ja(t),t.flags&=-257,t=_c(e,t,n)):t.memoizedState===null?(Za(t),c=r.fallback,a=t.mode,r=gc({mode:`visible`,children:r.children},a),c=ti(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Da(t,e.child,null,n),r=t.child,r.memoizedState=fc(n),r.childLanes=pc(e,s,n),t.memoizedState=dc,t=tc(null,r)):(Za(t),t.child=e.child,t.flags|=128,t=null);else if(Ja(t),of(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Ni({value:r,source:null,stack:null}),t=_c(e,t,n)}else if(Ys||Vi(e,t,n,!1),s=(n&e.childLanes)!==0,Ys||s){if(s=Pl,s!==null&&(r=Ke(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Gr(e,r),pu(s,e,r),Js;af(c)||Tu(),t=_c(e,t,n)}else af(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Si=cf(c.nextSibling),xi=t,Ci=!0,wi=null,Ti=!1,e!==null&&bi(t,e),t=hc(t,r.children),t.flags|=4096);return t}return a?(Za(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=Qr(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=ti(c,a,n,null),c.flags|=2):c=Qr(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,tc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=fc(n):(a=c.cachePool,a===null?a=ua():(l=Xi._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=pc(e,s,n),t.memoizedState=dc,tc(e.child,r)):(Ja(t),n=e.child,e=n.sibling,n=Qr(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function hc(e,t){return t=gc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function gc(e,t){return e=Xr(22,e,null,t),e.lanes=0,e}function _c(e,t,n){return Da(t,e.child,null,n),e=hc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function vc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),zi(e.return,t,n)}function yc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function bc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=$a.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,U($a,o),Xs(e,t,r,n),r=Ci?ui:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&vc(e,n,t);else if(e.tag===19)vc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&eo(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),yc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&eo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}yc(t,!0,n,null,a,r);break;case`together`:yc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function xc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Ul|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Vi(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=Qr(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Qr(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Sc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&Hi(e))):!0}function Cc(e,t,n){switch(t.tag){case 3:re(t,t.stateNode.containerInfo),Li(t,Xi,e.memoizedState.cache),ji();break;case 27:case 5:ie(t);break;case 4:re(t,t.stateNode.containerInfo);break;case 10:Li(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Ya(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(Ja(t),e=xc(e,t,n),e===null?null:e.sibling):mc(e,t,n):(Ja(t),t.flags|=128,null);Ja(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(Vi(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return bc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),U($a,$a.current),r)break;return null;case 22:return t.lanes=0,ec(e,t,n,t.pendingProps);case 24:Li(t,Xi,e.memoizedState.cache)}return xc(e,t,n)}function wc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)Ys=!0;else{if(!Sc(e,n)&&!(t.flags&128))return Ys=!1,Cc(e,t,n);Ys=!!(e.flags&131072)}else Ys=!1,Ci&&t.flags&1048576&&_i(t,ui,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=_a(t.elementType),t.type=e,typeof e==`function`)Zr(e)?(r=Rs(e,r),t.tag=1,t=lc(null,t,e,r,n)):(t.tag=0,t=sc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===w){t.tag=11,t=Zs(null,t,e,r,n);break a}else if(a===D){t.tag=14,t=Qs(null,t,e,r,n);break a}}throw t=P(e)||e,Error(i(306,t,``))}}return t;case 0:return sc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Rs(r,t.pendingProps),lc(e,t,r,a,n);case 3:a:{if(re(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,ja(e,t),Ra(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Li(t,Xi,r),r!==o.cache&&Bi(t,[Xi],n,!0),La(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=uc(e,t,r,n);break a}else if(r!==a){a=oi(Error(i(424)),t),Ni(a),t=uc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Si=cf(e.firstChild),xi=t,Ci=!0,wi=null,Ti=!0,n=Oa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(ji(),r===a){t=xc(e,t,n);break a}Xs(e,t,r,n)}t=t.child}return t;case 26:return oc(e,t),e===null?(n=kf(t.type,null,t.pendingProps,null))?t.memoizedState=n:Ci||(n=t.type,e=t.pendingProps,r=Bd(te.current).createElement(n),r[Qe]=t,r[$e]=e,Pd(r,n,e),J(r),t.stateNode=r):t.memoizedState=kf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ie(t),e===null&&Ci&&(r=t.stateNode=ff(t.type,t.pendingProps,te.current),xi=t,Ti=!0,a=Si,Zd(t.type)?(lf=a,Si=cf(r.firstChild)):Si=a),Xs(e,t,t.pendingProps.children,n),oc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Ci&&((a=r=Si)&&(r=tf(r,t.type,t.pendingProps,Ti),r===null?a=!1:(t.stateNode=r,xi=t,Si=cf(r.firstChild),Ti=!1,a=!0)),a||Di(t)),ie(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,Ud(a,o)?r=null:s!==null&&Ud(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=mo(e,t,_o,null,null,n),Qf._currentValue=a),oc(e,t),Xs(e,t,r,n),t.child;case 6:return e===null&&Ci&&((e=n=Si)&&(n=nf(n,t.pendingProps,Ti),n===null?e=!1:(t.stateNode=n,xi=t,Si=null,e=!0)),e||Di(t)),null;case 13:return mc(e,t,n);case 4:return re(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Da(t,null,r,n):Xs(e,t,r,n),t.child;case 11:return Zs(e,t,t.type,t.pendingProps,n);case 7:return Xs(e,t,t.pendingProps,n),t.child;case 8:return Xs(e,t,t.pendingProps.children,n),t.child;case 12:return Xs(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Li(t,t.type,r.value),Xs(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Ui(t),a=Wi(a),r=r(a),t.flags|=1,Xs(e,t,r,n),t.child;case 14:return Qs(e,t,t.type,t.pendingProps,n);case 15:return $s(e,t,t.type,t.pendingProps,n);case 19:return bc(e,t,n);case 31:return ac(e,t,n);case 22:return ec(e,t,n,t.pendingProps);case 24:return Ui(t),r=Wi(Xi),e===null?(a=ca(),a===null&&(a=Pl,o=Zi(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Aa(t),Li(t,Xi,a)):((e.lanes&n)!==0&&(ja(e,t),Ra(t,null,null,n),La()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Li(t,Xi,r),r!==a.cache&&Bi(t,[Xi],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Li(t,Xi,r))),Xs(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Tc(e){e.flags|=4}function Ec(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(Su())e.flags|=8192;else throw va=ma,fa}else e.flags&=-16777217}function Dc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Wf(t))if(Su())e.flags|=8192;else throw va=ma,fa}function Oc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Ve(),e.lanes|=t,ql|=t)}function kc(e,t){if(!Ci)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Ac(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function jc(e,t,n){var r=t.pendingProps;switch(yi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ac(t),null;case 1:return Ac(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Ri(Xi),G(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Ai(t)?Tc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Mi())),Ac(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Tc(t),o===null?(Ac(t),Ec(t,a,null,r,n)):(Ac(t),Dc(t,o))):o?o===e.memoizedState?(Ac(t),t.flags&=-16777217):(Tc(t),Ac(t),Dc(t,o)):(e=e.memoizedProps,e!==r&&Tc(t),Ac(t),Ec(t,a,e,r,n)),null;case 27:if(ae(t),n=te.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Ac(t),null}e=W.current,Ai(t)?Oi(t,e):(e=ff(a,r,n),t.stateNode=e,Tc(t))}return Ac(t),null;case 5:if(ae(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Ac(t),null}if(o=W.current,Ai(t))Oi(t,o);else{var s=Bd(te.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[Qe]=t,o[$e]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Pd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Tc(t)}}return Ac(t),Ec(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=te.current,Ai(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=xi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[Qe]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||jd(e.nodeValue,n)),e||Di(t,!0)}else e=Bd(e).createTextNode(r),e[Qe]=t,t.stateNode=e}return Ac(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Ai(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[Qe]=t}else ji(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ac(t),e=!1}else n=Mi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Qa(t),t):(Qa(t),null);if(t.flags&128)throw Error(i(558))}return Ac(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Ai(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[Qe]=t}else ji(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ac(t),a=!1}else a=Mi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Qa(t),t):(Qa(t),null)}return Qa(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Oc(t,t.updateQueue),Ac(t),null);case 4:return G(),e===null&&xd(t.stateNode.containerInfo),Ac(t),null;case 10:return Ri(t.type),Ac(t),null;case 19:if(H($a),r=t.memoizedState,r===null)return Ac(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)kc(r,!1);else{if(Hl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=eo(e),o!==null){for(t.flags|=128,kc(r,!1),e=o.updateQueue,t.updateQueue=e,Oc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)$r(n,e),n=n.sibling;return U($a,$a.current&1|2),Ci&&gi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&ve()>$l&&(t.flags|=128,a=!0,kc(r,!1),t.lanes=4194304)}else{if(!a)if(e=eo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Oc(t,e),kc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Ci)return Ac(t),null}else 2*ve()-r.renderingStartTime>$l&&n!==536870912&&(t.flags|=128,a=!0,kc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Ac(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=ve(),e.sibling=null,n=$a.current,U($a,a?n&1|2:n&1),Ci&&gi(t,r.treeForkCount),e);case 22:case 23:return Qa(t),Ga(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Ac(t),t.subtreeFlags&6&&(t.flags|=8192)):Ac(t),n=t.updateQueue,n!==null&&Oc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&H(sa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ri(Xi),Ac(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Mc(e,t){switch(yi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ri(Xi),G(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ae(t),null;case 31:if(t.memoizedState!==null){if(Qa(t),t.alternate===null)throw Error(i(340));ji()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Qa(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));ji()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return H($a),null;case 4:return G(),null;case 10:return Ri(t.type),null;case 22:case 23:return Qa(t),Ga(),e!==null&&H(sa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ri(Xi),null;case 25:return null;default:return null}}function Nc(e,t){switch(yi(t),t.tag){case 3:Ri(Xi),G();break;case 26:case 27:case 5:ae(t);break;case 4:G();break;case 31:t.memoizedState!==null&&Qa(t);break;case 13:Qa(t);break;case 19:H($a);break;case 10:Ri(t.type);break;case 22:case 23:Qa(t),Ga(),e!==null&&H(sa);break;case 24:Ri(Xi)}}function Pc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Uu(t,t.return,e)}}function Fc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Uu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Uu(t,t.return,e)}}function Ic(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ba(t,n)}catch(t){Uu(e,e.return,t)}}}function Lc(e,t,n){n.props=Rs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Uu(e,t,n)}}function Rc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Uu(e,t,n)}}function zc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Uu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Uu(e,t,n)}else n.current=null}function Bc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Uu(e,e.return,t)}}function Vc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[$e]=t}catch(t){Uu(e,e.return,t)}}function Hc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function Uc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Hc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Wc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ut));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Wc(e,t,n),e=e.sibling;e!==null;)Wc(e,t,n),e=e.sibling}function Gc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Gc(e,t,n),e=e.sibling;e!==null;)Gc(e,t,n),e=e.sibling}function Kc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Pd(t,r,n),t[Qe]=e,t[$e]=n}catch(t){Uu(e,e.return,t)}}var qc=!1,Jc=!1,Yc=!1,Xc=typeof WeakSet==`function`?WeakSet:Set,Zc=null;function Qc(e,t){if(e=e.containerInfo,Rd=sp,e=hr(e),gr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(zd={focusedElem:e,selectionRange:n},sp=!1,Zc=t;Zc!==null;)if(t=Zc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Zc=e;else for(;Zc!==null;){switch(t=Zc,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Rs(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Uu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)ef(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:ef(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,Zc=e;break}Zc=t.return}}function $c(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:ml(e,n),r&4&&Pc(5,n);break;case 1:if(ml(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Uu(n,n.return,e)}else{var i=Rs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Uu(n,n.return,e)}}r&64&&Ic(n),r&512&&Rc(n,n.return);break;case 3:if(ml(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Ba(e,t)}catch(e){Uu(n,n.return,e)}}break;case 27:t===null&&r&4&&Kc(n);case 26:case 5:ml(e,n),t===null&&r&4&&Bc(n),r&512&&Rc(n,n.return);break;case 12:ml(e,n);break;case 31:ml(e,n),r&4&&al(e,n);break;case 13:ml(e,n),r&4&&ol(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=qu.bind(null,n),sf(e,n))));break;case 22:if(r=n.memoizedState!==null||qc,!r){t=t!==null&&t.memoizedState!==null||Jc,i=qc;var a=Jc;qc=r,(Jc=t)&&!a?gl(e,n,(n.subtreeFlags&8772)!=0):ml(e,n),qc=i,Jc=a}break;case 30:break;default:ml(e,n)}}function el(e){var t=e.alternate;t!==null&&(e.alternate=null,el(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&at(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var tl=null,nl=!1;function rl(e,t,n){for(n=n.child;n!==null;)il(e,t,n),n=n.sibling}function il(e,t,n){if(Oe&&typeof Oe.onCommitFiberUnmount==`function`)try{Oe.onCommitFiberUnmount(De,n)}catch{}switch(n.tag){case 26:Jc||zc(n,t),rl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Jc||zc(n,t);var r=tl,i=nl;Zd(n.type)&&(tl=n.stateNode,nl=!1),rl(e,t,n),pf(n.stateNode),tl=r,nl=i;break;case 5:Jc||zc(n,t);case 6:if(r=tl,i=nl,tl=null,rl(e,t,n),tl=r,nl=i,tl!==null)if(nl)try{(tl.nodeType===9?tl.body:tl.nodeName===`HTML`?tl.ownerDocument.body:tl).removeChild(n.stateNode)}catch(e){Uu(n,t,e)}else try{tl.removeChild(n.stateNode)}catch(e){Uu(n,t,e)}break;case 18:tl!==null&&(nl?(e=tl,Qd(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Np(e)):Qd(tl,n.stateNode));break;case 4:r=tl,i=nl,tl=n.stateNode.containerInfo,nl=!0,rl(e,t,n),tl=r,nl=i;break;case 0:case 11:case 14:case 15:Fc(2,n,t),Jc||Fc(4,n,t),rl(e,t,n);break;case 1:Jc||(zc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Lc(n,t,r)),rl(e,t,n);break;case 21:rl(e,t,n);break;case 22:Jc=(r=Jc)||n.memoizedState!==null,rl(e,t,n),Jc=r;break;default:rl(e,t,n)}}function al(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Np(e)}catch(e){Uu(t,t.return,e)}}}function ol(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Np(e)}catch(e){Uu(t,t.return,e)}}function sl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Xc),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Xc),t;default:throw Error(i(435,e.tag))}}function cl(e,t){var n=sl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Ju.bind(null,e,t);t.then(r,r)}})}function ll(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(Zd(c.type)){tl=c.stateNode,nl=!1;break a}break;case 5:tl=c.stateNode,nl=!1;break a;case 3:case 4:tl=c.stateNode.containerInfo,nl=!0;break a}c=c.return}if(tl===null)throw Error(i(160));il(o,s,a),tl=null,nl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)dl(t,e),t=t.sibling}var ul=null;function dl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ll(t,e),fl(e),r&4&&(Fc(3,e,e.return),Pc(3,e),Fc(5,e,e.return));break;case 1:ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),r&64&&qc&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=ul;if(ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[q]||o[Qe]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Pd(o,r,n),o[Qe]=e,J(o),r=o;break a;case`link`:var s=Vf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Pd(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Vf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Pd(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[Qe]=e,J(o),r=o}e.stateNode=r}else Hf(a,e.type,e.stateNode);else e.stateNode=If(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&Vc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Hf(a,e.type,e.stateNode):If(a,r,e.memoizedProps))}break;case 27:ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),n!==null&&r&4&&Vc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),e.flags&32){a=e.stateNode;try{Ft(a,``)}catch(t){Uu(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,Vc(e,a,n===null?a:n.memoizedProps)),r&1024&&(Yc=!0);break;case 6:if(ll(t,e),fl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Uu(e,e.return,t)}}break;case 3:if(Bf=null,a=ul,ul=gf(t.containerInfo),ll(t,e),ul=a,fl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Np(t.containerInfo)}catch(t){Uu(e,e.return,t)}Yc&&(Yc=!1,pl(e));break;case 4:r=ul,ul=gf(e.stateNode.containerInfo),ll(t,e),fl(e),ul=r;break;case 12:ll(t,e),fl(e);break;case 31:ll(t,e),fl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 13:ll(t,e),fl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Zl=ve()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=qc,d=Jc;if(qc=u||a,Jc=d||l,ll(t,e),Jc=d,qc=u,fl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||qc||Jc||hl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Uu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Uu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?$d(m,!0):$d(l.stateNode,!1)}catch(e){Uu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,cl(e,n))));break;case 19:ll(t,e),fl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 30:break;case 21:break;default:ll(t,e),fl(e)}}function fl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Hc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;Gc(e,Uc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Ft(o,``),n.flags&=-33),Gc(e,Uc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Wc(e,Uc(e),s);break;default:throw Error(i(161))}}catch(t){Uu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function pl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;pl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function ml(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)$c(e,t.alternate,t),t=t.sibling}function hl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Fc(4,t,t.return),hl(t);break;case 1:zc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Lc(t,t.return,n),hl(t);break;case 27:pf(t.stateNode);case 26:case 5:zc(t,t.return),hl(t);break;case 22:t.memoizedState===null&&hl(t);break;case 30:hl(t);break;default:hl(t)}e=e.sibling}}function gl(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:gl(i,a,n),Pc(4,a);break;case 1:if(gl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Uu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)za(c[i],s)}catch(e){Uu(r,r.return,e)}}n&&o&64&&Ic(a),Rc(a,a.return);break;case 27:Kc(a);case 26:case 5:gl(i,a,n),n&&r===null&&o&4&&Bc(a),Rc(a,a.return);break;case 12:gl(i,a,n);break;case 31:gl(i,a,n),n&&o&4&&al(i,a);break;case 13:gl(i,a,n),n&&o&4&&ol(i,a);break;case 22:a.memoizedState===null&&gl(i,a,n),Rc(a,a.return);break;case 30:break;default:gl(i,a,n)}t=t.sibling}}function _l(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Qi(n))}function vl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Qi(e))}function yl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)bl(e,t,n,r),t=t.sibling}function bl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:yl(e,t,n,r),i&2048&&Pc(9,t);break;case 1:yl(e,t,n,r);break;case 3:yl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Qi(e)));break;case 12:if(i&2048){yl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Uu(t,t.return,e)}}else yl(e,t,n,r);break;case 31:yl(e,t,n,r);break;case 13:yl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?yl(e,t,n,r):(a._visibility|=2,xl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?yl(e,t,n,r):Sl(e,t),i&2048&&_l(o,t);break;case 24:yl(e,t,n,r),i&2048&&vl(t.alternate,t);break;default:yl(e,t,n,r)}}function xl(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:xl(a,o,s,c,i),Pc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,xl(a,o,s,c,i)):u._visibility&2?xl(a,o,s,c,i):Sl(a,o),i&&l&2048&&_l(o.alternate,o);break;case 24:xl(a,o,s,c,i),i&&l&2048&&vl(o.alternate,o);break;default:xl(a,o,s,c,i)}t=t.sibling}}function Sl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Sl(n,r),i&2048&&_l(r.alternate,r);break;case 24:Sl(n,r),i&2048&&vl(r.alternate,r);break;default:Sl(n,r)}t=t.sibling}}var Cl=8192;function wl(e,t,n){if(e.subtreeFlags&Cl)for(e=e.child;e!==null;)Tl(e,t,n),e=e.sibling}function Tl(e,t,n){switch(e.tag){case 26:wl(e,t,n),e.flags&Cl&&e.memoizedState!==null&&Gf(n,ul,e.memoizedState,e.memoizedProps);break;case 5:wl(e,t,n);break;case 3:case 4:var r=ul;ul=gf(e.stateNode.containerInfo),wl(e,t,n),ul=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Cl,Cl=16777216,wl(e,t,n),Cl=r):wl(e,t,n));break;default:wl(e,t,n)}}function El(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Dl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Zc=r,Al(r,e)}El(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Ol(e),e=e.sibling}function Ol(e){switch(e.tag){case 0:case 11:case 15:Dl(e),e.flags&2048&&Fc(9,e,e.return);break;case 3:Dl(e);break;case 12:Dl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,kl(e)):Dl(e);break;default:Dl(e)}}function kl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Zc=r,Al(r,e)}El(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Fc(8,t,t.return),kl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,kl(t));break;default:kl(t)}e=e.sibling}}function Al(e,t){for(;Zc!==null;){var n=Zc;switch(n.tag){case 0:case 11:case 15:Fc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Qi(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,Zc=r;else a:for(n=e;Zc!==null;){r=Zc;var i=r.sibling,a=r.return;if(el(r),r===n){Zc=null;break a}if(i!==null){i.return=a,Zc=i;break a}Zc=a}}}var jl={getCacheForType:function(e){var t=Wi(Xi),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Wi(Xi).controller.signal}},Ml=typeof WeakMap==`function`?WeakMap:Map,Nl=0,Pl=null,Q=null,Fl=0,Il=0,Ll=null,Rl=!1,zl=!1,Bl=!1,Vl=0,Hl=0,Ul=0,Wl=0,Gl=0,Kl=0,ql=0,Jl=null,Yl=null,Xl=!1,Zl=0,Ql=0,$l=1/0,eu=null,tu=null,nu=0,ru=null,iu=null,au=0,ou=0,su=null,cu=null,lu=0,uu=null;function du(){return Nl&2&&Fl!==0?Fl&-Fl:I.T===null?Ye():ud()}function fu(){if(Kl===0)if(!(Fl&536870912)||Ci){var e=Fe;Fe<<=1,!(Fe&3932160)&&(Fe=262144),Kl=e}else Kl=536870912;return e=Ka.current,e!==null&&(e.flags|=32),Kl}function pu(e,t,n){(e===Pl&&(Il===2||Il===9)||e.cancelPendingCommit!==null)&&(bu(e,0),_u(e,Fl,Kl,!1)),He(e,n),(!(Nl&2)||e!==Pl)&&(e===Pl&&(!(Nl&2)&&(Wl|=n),Hl===4&&_u(e,Fl,Kl,!1)),nd(e))}function mu(e,t,n){if(Nl&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||ze(e,t),a=r?Ou(e,t):Eu(e,t,!0),o=r;do{if(a===0){zl&&!r&&_u(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!gu(n)){a=Eu(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=Jl;var l=c.current.memoizedState.isDehydrated;if(l&&(bu(c,s).flags|=256),s=Eu(c,s,!1),s!==2){if(Bl&&!l){c.errorRecoveryDisabledLanes|=o,Wl|=o,a=4;break a}o=Yl,Yl=a,o!==null&&(Yl===null?Yl=o:Yl.push.apply(Yl,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){bu(e,0),_u(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:_u(r,t,Kl,!Rl);break a;case 2:Yl=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=Zl+300-ve(),10<a)){if(_u(r,t,Kl,!Rl),Re(r,0,!0)!==0)break a;au=t,r.timeoutHandle=Kd(hu.bind(null,r,n,Yl,eu,Xl,t,Kl,Wl,ql,Rl,o,`Throttled`,-0,0),a);break a}hu(r,n,Yl,eu,Xl,t,Kl,Wl,ql,Rl,o,null,-0,0)}}break}while(1);nd(e)}function hu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Ut},Tl(t,a,d);var m=(a&62914560)===a?Zl-ve():(a&4194048)===a?Ql-ve():0;if(m=qf(d,m),m!==null){au=a,e.cancelPendingCommit=m(Fu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),_u(e,a,o,!l);return}}Fu(e,t,a,n,r,i,o,s,c)}function gu(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!ur(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function _u(e,t,n,r){t&=~Gl,t&=~Wl,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Ae(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&We(e,n,t)}function vu(){return Nl&6?!0:(rd(0,!1),!1)}function yu(){if(Q!==null){if(Il===0)var e=Q.return;else e=Q,Ii=Fi=null,bo(e),xa=null,Sa=0,e=Q;for(;e!==null;)Nc(e.alternate,e),e=e.return;Q=null}}function bu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,qd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),au=0,yu(),Pl=e,Q=n=Qr(e.current,null),Fl=t,Il=0,Ll=null,Rl=!1,zl=ze(e,t),Bl=!1,ql=Kl=Gl=Wl=Ul=Hl=0,Yl=Jl=null,Xl=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Ae(r),a=1<<i;t|=e[i],r&=~a}return Vl=t,Hr(),n}function xu(e,t){Z=null,I.H=As,t===da||t===pa?(t=ya(),Il=3):t===fa?(t=ya(),Il=4):Il=t===Js?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Ll=t,Q===null&&(Hl=1,Hs(e,oi(t,e.current)))}function Su(){var e=Ka.current;return e===null?!0:(Fl&4194048)===Fl?qa===null:(Fl&62914560)===Fl||Fl&536870912?e===qa:!1}function Cu(){var e=I.H;return I.H=As,e===null?As:e}function wu(){var e=I.A;return I.A=jl,e}function Tu(){Hl=4,Rl||(Fl&4194048)!==Fl&&Ka.current!==null||(zl=!0),!(Ul&134217727)&&!(Wl&134217727)||Pl===null||_u(Pl,Fl,Kl,!1)}function Eu(e,t,n){var r=Nl;Nl|=2;var i=Cu(),a=wu();(Pl!==e||Fl!==t)&&(eu=null,bu(e,t)),t=!1;var o=Hl;a:do try{if(Il!==0&&Q!==null){var s=Q,c=Ll;switch(Il){case 8:yu(),o=6;break a;case 3:case 2:case 9:case 6:Ka.current===null&&(t=!0);var l=Il;if(Il=0,Ll=null,Mu(e,s,c,l),n&&zl){o=0;break a}break;default:l=Il,Il=0,Ll=null,Mu(e,s,c,l)}}Du(),o=Hl;break}catch(t){xu(e,t)}while(1);return t&&e.shellSuspendCounter++,Ii=Fi=null,Nl=r,I.H=i,I.A=a,Q===null&&(Pl=null,Fl=0,Hr()),o}function Du(){for(;Q!==null;)Au(Q)}function Ou(e,t){var n=Nl;Nl|=2;var r=Cu(),a=wu();Pl!==e||Fl!==t?(eu=null,$l=ve()+500,bu(e,t)):zl=ze(e,t);a:do try{if(Il!==0&&Q!==null){t=Q;var o=Ll;b:switch(Il){case 1:Il=0,Ll=null,Mu(e,t,o,1);break;case 2:case 9:if(ha(o)){Il=0,Ll=null,ju(t);break}t=function(){Il!==2&&Il!==9||Pl!==e||(Il=7),nd(e)},o.then(t,t);break a;case 3:Il=7;break a;case 4:Il=5;break a;case 7:ha(o)?(Il=0,Ll=null,ju(t)):(Il=0,Ll=null,Mu(e,t,o,7));break;case 5:var s=null;switch(Q.tag){case 26:s=Q.memoizedState;case 5:case 27:var c=Q;if(s?Wf(s):c.stateNode.complete){Il=0,Ll=null;var l=c.sibling;if(l!==null)Q=l;else{var u=c.return;u===null?Q=null:(Q=u,Nu(u))}break b}}Il=0,Ll=null,Mu(e,t,o,5);break;case 6:Il=0,Ll=null,Mu(e,t,o,6);break;case 8:yu(),Hl=6;break a;default:throw Error(i(462))}}ku();break}catch(t){xu(e,t)}while(1);return Ii=Fi=null,I.H=r,I.A=a,Nl=n,Q===null?(Pl=null,Fl=0,Hr(),Hl):0}function ku(){for(;Q!==null&&!ge();)Au(Q)}function Au(e){var t=wc(e.alternate,e,Vl);e.memoizedProps=e.pendingProps,t===null?Nu(e):Q=t}function ju(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=cc(n,t,t.pendingProps,t.type,void 0,Fl);break;case 11:t=cc(n,t,t.pendingProps,t.type.render,t.ref,Fl);break;case 5:bo(t);default:Nc(n,t),t=Q=$r(t,Vl),t=wc(n,t,Vl)}e.memoizedProps=e.pendingProps,t===null?Nu(e):Q=t}function Mu(e,t,n,r){Ii=Fi=null,bo(t),xa=null,Sa=0;var i=t.return;try{if(qs(e,i,t,n,Fl)){Hl=1,Hs(e,oi(n,e.current)),Q=null;return}}catch(t){if(i!==null)throw Q=i,t;Hl=1,Hs(e,oi(n,e.current)),Q=null;return}t.flags&32768?(Ci||r===1?e=!0:zl||Fl&536870912?e=!1:(Rl=e=!0,(r===2||r===9||r===3||r===6)&&(r=Ka.current,r!==null&&r.tag===13&&(r.flags|=16384))),Pu(t,e)):Nu(t)}function Nu(e){var t=e;do{if(t.flags&32768){Pu(t,Rl);return}e=t.return;var n=jc(t.alternate,t,Vl);if(n!==null){Q=n;return}if(t=t.sibling,t!==null){Q=t;return}Q=t=e}while(t!==null);Hl===0&&(Hl=5)}function Pu(e,t){do{var n=Mc(e.alternate,e);if(n!==null){n.flags&=32767,Q=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Q=e;return}Q=e=n}while(e!==null);Hl=6,Q=null}function Fu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Bu();while(nu!==0);if(Nl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=Vr,Ue(e,n,o,s,c,l),e===Pl&&(Q=Pl=null,Fl=0),iu=t,ru=e,au=n,ou=o,su=a,cu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Yu(Se,function(){return Vu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=I.T,I.T=null,a=L.p,L.p=2,s=Nl,Nl|=4;try{Qc(e,t,n)}finally{Nl=s,L.p=a,I.T=r}}nu=1,Iu(),Lu(),Ru()}}function Iu(){if(nu===1){nu=0;var e=ru,t=iu,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=I.T,I.T=null;var r=L.p;L.p=2;var i=Nl;Nl|=4;try{dl(t,e);var a=zd,o=hr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&mr(s.ownerDocument.documentElement,s)){if(c!==null&&gr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=pr(s,h),v=pr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}sp=!!Rd,zd=Rd=null}finally{Nl=i,L.p=r,I.T=n}}e.current=t,nu=2}}function Lu(){if(nu===2){nu=0;var e=ru,t=iu,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=I.T,I.T=null;var r=L.p;L.p=2;var i=Nl;Nl|=4;try{$c(e,t.alternate,t)}finally{Nl=i,L.p=r,I.T=n}}nu=3}}function Ru(){if(nu===4||nu===3){nu=0,_e();var e=ru,t=iu,n=au,r=cu;t.subtreeFlags&10256||t.flags&10256?nu=5:(nu=0,iu=ru=null,zu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(tu=null),Je(n),t=t.stateNode,Oe&&typeof Oe.onCommitFiberRoot==`function`)try{Oe.onCommitFiberRoot(De,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=I.T,i=L.p,L.p=2,I.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{I.T=t,L.p=i}}au&3&&Bu(),nd(e),i=e.pendingLanes,n&261930&&i&42?e===uu?lu++:(lu=0,uu=e):lu=0,rd(0,!1)}}function zu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Qi(t)))}function Bu(){return Iu(),Lu(),Ru(),Vu()}function Vu(){if(nu!==5)return!1;var e=ru,t=ou;ou=0;var n=Je(au),r=I.T,a=L.p;try{L.p=32>n?32:n,I.T=null,n=su,su=null;var o=ru,s=au;if(nu=0,iu=ru=null,au=0,Nl&6)throw Error(i(331));var c=Nl;if(Nl|=4,Ol(o.current),bl(o,o.current,s,n),Nl=c,rd(0,!1),Oe&&typeof Oe.onPostCommitFiberRoot==`function`)try{Oe.onPostCommitFiberRoot(De,o)}catch{}return!0}finally{L.p=a,I.T=r,zu(e,t)}}function Hu(e,t,n){t=oi(n,t),t=Ws(e.stateNode,t,2),e=Na(e,t,2),e!==null&&(He(e,2),nd(e))}function Uu(e,t,n){if(e.tag===3)Hu(e,e,n);else for(;t!==null;){if(t.tag===3){Hu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(tu===null||!tu.has(r))){e=oi(n,e),n=Gs(2),r=Na(t,n,2),r!==null&&(Ks(n,r,t,e),He(r,2),nd(r));break}}t=t.return}}function Wu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ml;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Bl=!0,i.add(n),e=Gu.bind(null,e,t,n),t.then(e,e))}function Gu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Pl===e&&(Fl&n)===n&&(Hl===4||Hl===3&&(Fl&62914560)===Fl&&300>ve()-Zl?!(Nl&2)&&bu(e,0):Gl|=n,ql===Fl&&(ql=0)),nd(e)}function Ku(e,t){t===0&&(t=Ve()),e=Gr(e,t),e!==null&&(He(e,t),nd(e))}function qu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ku(e,n)}function Ju(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Ku(e,n)}function Yu(e,t){return me(e,t)}var Xu=null,Zu=null,Qu=!1,$u=!1,ed=!1,td=0;function nd(e){e!==Zu&&e.next===null&&(Zu===null?Xu=Zu=e:Zu=Zu.next=e),$u=!0,Qu||(Qu=!0,ld())}function rd(e,t){if(!ed&&$u){ed=!0;do for(var n=!1,r=Xu;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Ae(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,cd(r,a))}else a=Fl,a=Re(r,r===Pl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||ze(r,a)||(n=!0,cd(r,a));r=r.next}while(n);ed=!1}}function id(){ad()}function ad(){$u=Qu=!1;var e=0;td!==0&&Gd()&&(e=td);for(var t=ve(),n=null,r=Xu;r!==null;){var i=r.next,a=od(r,t);a===0?(r.next=null,n===null?Xu=i:n.next=i,i===null&&(Zu=n)):(n=r,(e!==0||a&3)&&($u=!0)),r=i}nu!==0&&nu!==5||rd(e,!1),td!==0&&(td=0)}function od(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Ae(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Be(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Pl,n=Fl,n=Re(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Il===2||Il===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&he(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||ze(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&he(r),Je(n)){case 2:case 8:n=xe;break;case 32:n=Se;break;case 268435456:n=we;break;default:n=Se}return r=sd.bind(null,e),n=me(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&he(r),e.callbackPriority=2,e.callbackNode=null,2}function sd(e,t){if(nu!==0&&nu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Bu()&&e.callbackNode!==n)return null;var r=Fl;return r=Re(e,e===Pl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(mu(e,r,t),od(e,ve()),e.callbackNode!=null&&e.callbackNode===n?sd.bind(null,e):null)}function cd(e,t){if(Bu())return null;mu(e,t,!0)}function ld(){Yd(function(){Nl&6?me(be,id):ad()})}function ud(){if(td===0){var e=ta;e===0&&(e=Pe,Pe<<=1,!(Pe&261888)&&(Pe=256)),td=e}return td}function dd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Ht(``+e)}function fd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function pd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=dd((i[$e]||null).action),o=r.submitter;o&&(t=(t=o[$e]||null)?dd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new ln(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(td!==0){var e=o?fd(i,o):new FormData(i);gs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?fd(i,o):new FormData(i),gs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var md=0;md<Ir.length;md++){var hd=Ir[md];Lr(hd.toLowerCase(),`on`+(hd[0].toUpperCase()+hd.slice(1)))}Lr(Or,`onAnimationEnd`),Lr(kr,`onAnimationIteration`),Lr(Ar,`onAnimationStart`),Lr(`dblclick`,`onDoubleClick`),Lr(`focusin`,`onFocus`),Lr(`focusout`,`onBlur`),Lr(jr,`onTransitionRun`),Lr(Mr,`onTransitionStart`),Lr(Nr,`onTransitionCancel`),Lr(Pr,`onTransitionEnd`),pt(`onMouseEnter`,[`mouseout`,`mouseover`]),pt(`onMouseLeave`,[`mouseout`,`mouseover`]),pt(`onPointerEnter`,[`pointerout`,`pointerover`]),pt(`onPointerLeave`,[`pointerout`,`pointerover`]),ft(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),ft(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),ft(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),ft(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),ft(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),ft(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var gd=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),_d=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(gd));function vd(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Rr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Rr(e)}i.currentTarget=null,a=c}}}}function $(e,t){var n=t[tt];n===void 0&&(n=t[tt]=new Set);var r=e+`__bubble`;n.has(r)||(Sd(t,e,2,!1),n.add(r))}function yd(e,t,n){var r=0;t&&(r|=4),Sd(n,e,r,t)}var bd=`_reactListening`+Math.random().toString(36).slice(2);function xd(e){if(!e[bd]){e[bd]=!0,ut.forEach(function(t){t!==`selectionchange`&&(_d.has(t)||yd(t,!1,e),yd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[bd]||(t[bd]=!0,yd(`selectionchange`,!1,t))}}function Sd(e,t,n,r){switch(mp(t)){case 2:var i=cp;break;case 8:i=lp;break;default:i=up}n=i.bind(null,t,n,e),i=void 0,!$t||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Cd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=ot(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}Xt(function(){var r=a,i=Gt(n),s=[];a:{var c=Fr.get(e);if(c!==void 0){var l=ln,u=e;switch(e){case`keypress`:if(on(n)===0)break a;case`keydown`:case`keyup`:l=Dn;break;case`focusin`:u=`focus`,l=vn;break;case`focusout`:u=`blur`,l=vn;break;case`beforeblur`:case`afterblur`:l=vn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=gn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=_n;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=kn;break;case Or:case kr:case Ar:l=yn;break;case Pr:l=An;break;case`scroll`:case`scrollend`:l=dn;break;case`wheel`:l=jn;break;case`copy`:case`cut`:case`paste`:l=bn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=On;break;case`toggle`:case`beforetoggle`:l=Mn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=Zt(m,p),g!=null&&d.push(wd(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==Wt&&(u=n.relatedTarget||n.fromElement)&&(ot(u)||u[et]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?ot(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=gn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=On,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:ct(l),h=u==null?c:ct(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,ot(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Ed,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Dd(s,c,l,d,!1),u!==null&&f!==null&&Dd(s,f,u,d,!0)}}a:{if(c=r?ct(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=Qn;else if(Kn(c))if($n)v=cr;else{v=or;var y=ar}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&zt(r.elementType)&&(v=Qn):v=sr;if(v&&=v(e,r)){qn(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&jt(c,`number`,c.value)}switch(y=r?ct(r):window,e){case`focusin`:(Kn(y)||y.contentEditable===`true`)&&(vr=y,yr=r,br=null);break;case`focusout`:br=yr=vr=null;break;case`mousedown`:xr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:xr=!1,Sr(s,n,i);break;case`selectionchange`:if(_r)break;case`keydown`:case`keyup`:Sr(s,n,i)}var b;if(Pn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else Hn?Bn(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Ln&&n.locale!==`ko`&&(Hn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Hn&&(b=an()):(tn=i,nn=`value`in tn?tn.value:tn.textContent,Hn=!0)),y=Td(r,x),0<y.length&&(x=new xn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=Vn(n),b!==null&&(x.data=b)))),(b=In?Un(e,n):Wn(e,n))&&(x=Td(r,`onBeforeInput`),0<x.length&&(y=new xn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),pd(s,e,r,n,i)}vd(s,t)})}function wd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Td(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=Zt(e,n),i!=null&&r.unshift(wd(e,i,a)),i=Zt(e,t),i!=null&&r.push(wd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Ed(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Dd(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=Zt(n,a),l!=null&&o.unshift(wd(n,l,c))):i||(l=Zt(n,a),l!=null&&o.push(wd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Od=/\r\n?/g,kd=/\u0000|\uFFFD/g;function Ad(e){return(typeof e==`string`?e:``+e).replace(Od,`
9
- `).replace(kd,``)}function jd(e,t){return t=Ad(t),Ad(e)===t}function Md(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Ft(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Ft(e,``+r);break;case`className`:yt(e,`class`,r);break;case`tabIndex`:yt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:yt(e,n,r);break;case`style`:Rt(e,r,o);break;case`data`:if(t!==`object`){yt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Ht(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Md(e,t,`name`,a.name,a,null),Md(e,t,`formEncType`,a.formEncType,a,null),Md(e,t,`formMethod`,a.formMethod,a,null),Md(e,t,`formTarget`,a.formTarget,a,null)):(Md(e,t,`encType`,a.encType,a,null),Md(e,t,`method`,a.method,a,null),Md(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Ht(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Ut);break;case`onScroll`:r!=null&&$(`scroll`,e);break;case`onScrollEnd`:r!=null&&$(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Ht(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:$(`beforetoggle`,e),$(`toggle`,e),vt(e,`popover`,r);break;case`xlinkActuate`:bt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:bt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:bt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:bt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:bt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:bt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:bt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:bt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:bt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:vt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Bt.get(n)||n,vt(e,n,r))}}function Nd(e,t,n,r,a,o){switch(n){case`style`:Rt(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Ft(e,r):(typeof r==`number`||typeof r==`bigint`)&&Ft(e,``+r);break;case`onScroll`:r!=null&&$(`scroll`,e);break;case`onScrollEnd`:r!=null&&$(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Ut);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!dt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[$e]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):vt(e,n,r)}}}function Pd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:$(`error`,e),$(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Md(e,t,o,s,n,null)}}a&&Md(e,t,`srcSet`,n.srcSet,n,null),r&&Md(e,t,`src`,n.src,n,null);return;case`input`:$(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Md(e,t,r,d,n,null)}}At(e,o,c,l,u,s,a,!1);return;case`select`:for(a in $(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Md(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&Mt(e,!!r,n,!0):Mt(e,!!r,t,!1);return;case`textarea`:for(s in $(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Md(e,t,s,c,n,null)}Pt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Md(e,t,l,r,n,null)}return;case`dialog`:$(`beforetoggle`,e),$(`toggle`,e),$(`cancel`,e),$(`close`,e);break;case`iframe`:case`object`:$(`load`,e);break;case`video`:case`audio`:for(r=0;r<gd.length;r++)$(gd[r],e);break;case`image`:$(`error`,e),$(`load`,e);break;case`details`:$(`toggle`,e);break;case`embed`:case`source`:case`link`:$(`error`,e),$(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Md(e,t,u,r,n,null)}return;default:if(zt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Nd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Md(e,t,c,r,n,null))}function Fd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Md(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Md(e,t,p,m,r,f)}}kt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Md(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Md(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Mt(e,!!n,n?[]:``,!1):Mt(e,!!n,t,!0)):Mt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Md(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Md(e,t,s,a,r,o)}Nt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Md(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Md(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Md(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Md(e,t,u,p,r,m)}return;default:if(zt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Nd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Nd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Md(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Md(e,t,f,p,r,m)}function Id(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Ld(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Id(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Rd=null,zd=null;function Bd(e){return e.nodeType===9?e:e.ownerDocument}function Vd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Hd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Ud(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Wd=null;function Gd(){var e=window.event;return e&&e.type===`popstate`?e===Wd?!1:(Wd=e,!0):(Wd=null,!1)}var Kd=typeof setTimeout==`function`?setTimeout:void 0,qd=typeof clearTimeout==`function`?clearTimeout:void 0,Jd=typeof Promise==`function`?Promise:void 0,Yd=typeof queueMicrotask==`function`?queueMicrotask:Jd===void 0?Kd:function(e){return Jd.resolve(null).then(e).catch(Xd)};function Xd(e){setTimeout(function(){throw e})}function Zd(e){return e===`head`}function Qd(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Np(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)pf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,pf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[q]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&pf(e.ownerDocument.body);n=i}while(n);Np(t)}function $d(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function ef(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:ef(n),at(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function tf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[q])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=cf(e.nextSibling),e===null)break}return null}function nf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=cf(e.nextSibling),e===null))return null;return e}function rf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=cf(e.nextSibling),e===null))return null;return e}function af(e){return e.data===`$?`||e.data===`$~`}function of(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function sf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function cf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var lf=null;function uf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return cf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function df(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function ff(e,t,n){switch(t=Bd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function pf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);at(e)}var mf=new Map,hf=new Set;function gf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var _f=L.d;L.d={f:vf,r:yf,D:Sf,C:Cf,L:wf,m:Tf,X:Df,S:Ef,M:Of};function vf(){var e=_f.f(),t=vu();return e||t}function yf(e){var t=st(e);t!==null&&t.tag===5&&t.type===`form`?vs(t):_f.r(e)}var bf=typeof document>`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Ot(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),J(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Ot(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Ot(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Ot(n.imageSizes)+`"]`)):i+=`[href="`+Ot(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=h({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),J(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Ot(r)+`"][href="`+Ot(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=h({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),J(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=lt(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=h({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);J(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=lt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),J(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=lt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),J(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var a=(a=te.current)?gf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=lt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var o=lt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),o||Nf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=lt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Af(e){return`href="`+Ot(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),J(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Ot(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Ot(n.href)+`"]`);if(r)return t.instance=r,J(r),r;var a=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),J(r),Pd(r,`style`,a),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Af(n.href);var o=e.querySelector(jf(a));if(o)return t.state.loading|=4,t.instance=o,J(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),J(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(o,`link`,r),t.state.loading|=4,Lf(o,n.precedence,e),t.instance=o;case`script`:return o=Pf(n.src),(a=e.querySelector(Ff(o)))?(t.instance=a,J(a),a):(r=n,(a=mf.get(o))&&(r=h({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),J(a),Pd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Rf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function zf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Bf=null;function Vf(e,t,n){if(Bf===null){var r=new Map,i=Bf=new Map;i.set(n,r)}else i=Bf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[q]||a[Qe]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Hf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,J(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),J(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Kf===0&&(Kf=62500*Ld());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Jf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var Qf={$$typeof:C,Provider:null,Consumer:null,_currentValue:R,_currentValue2:R,_threadCount:0};function $f(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=K(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=K(0),this.hiddenUpdates=K(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function ep(e,t,n,r,i,a,o,s,c,l,u,d){return e=new $f(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Xr(3,null,null,t),e.current=a,a.stateNode=e,t=Zi(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Aa(a),e}function tp(e){return e?(e=Jr,e):Jr}function np(e,t,n,r,i,a){i=tp(i),r.context===null?r.context=i:r.pendingContext=i,r=Ma(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Na(e,r,t),n!==null&&(pu(n,e,t),Pa(n,e,t))}function rp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ip(e,t){rp(e,t),(e=e.alternate)&&rp(e,t)}function ap(e){if(e.tag===13||e.tag===31){var t=Gr(e,67108864);t!==null&&pu(t,e,67108864),ip(e,67108864)}}function op(e){if(e.tag===13||e.tag===31){var t=du();t=qe(t);var n=Gr(e,t);n!==null&&pu(n,e,t),ip(e,t)}}var sp=!0;function cp(e,t,n,r){var i=I.T;I.T=null;var a=L.p;try{L.p=2,up(e,t,n,r)}finally{L.p=a,I.T=i}}function lp(e,t,n,r){var i=I.T;I.T=null;var a=L.p;try{L.p=8,up(e,t,n,r)}finally{L.p=a,I.T=i}}function up(e,t,n,r){if(sp){var i=dp(r);if(i===null)Cd(e,t,r,fp,n),Cp(e,r);else if(Tp(i,e,t,n,r))r.stopPropagation();else if(Cp(e,r),t&4&&-1<Sp.indexOf(e)){for(;i!==null;){var a=st(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Le(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Ae(o);s.entanglements[1]|=c,o&=~c}nd(a),!(Nl&6)&&($l=ve()+500,rd(0,!1))}}break;case 31:case 13:s=Gr(a,2),s!==null&&pu(s,a,2),vu(),ip(a,2)}if(a=dp(r),a===null&&Cd(e,t,r,fp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Cd(e,t,r,null,n)}}function dp(e){return e=Gt(e),pp(e)}var fp=null;function pp(e){if(fp=null,e=ot(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return fp=e,null}function mp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(ye()){case be:return 2;case xe:return 8;case Se:case Ce:return 32;case we:return 268435456;default:return 32}default:return 32}}var hp=!1,gp=null,_p=null,vp=null,yp=new Map,bp=new Map,xp=[],Sp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Cp(e,t){switch(e){case`focusin`:case`focusout`:gp=null;break;case`dragenter`:case`dragleave`:_p=null;break;case`mouseover`:case`mouseout`:vp=null;break;case`pointerover`:case`pointerout`:yp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:bp.delete(t.pointerId)}}function wp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=st(t),t!==null&&ap(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Tp(e,t,n,r,i){switch(t){case`focusin`:return gp=wp(gp,e,t,n,r,i),!0;case`dragenter`:return _p=wp(_p,e,t,n,r,i),!0;case`mouseover`:return vp=wp(vp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return yp.set(a,wp(yp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,bp.set(a,wp(bp.get(a)||null,e,t,n,r,i)),!0}return!1}function Ep(e){var t=ot(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,Xe(e.priority,function(){op(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,Xe(e.priority,function(){op(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Dp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=dp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Wt=r,n.target.dispatchEvent(r),Wt=null}else return t=st(n),t!==null&&ap(t),e.blockedOn=n,!1;t.shift()}return!0}function Op(e,t,n){Dp(e)&&n.delete(t)}function kp(){hp=!1,gp!==null&&Dp(gp)&&(gp=null),_p!==null&&Dp(_p)&&(_p=null),vp!==null&&Dp(vp)&&(vp=null),yp.forEach(Op),bp.forEach(Op)}function Ap(e,n){e.blockedOn===n&&(e.blockedOn=null,hp||(hp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,kp)))}var jp=null;function Mp(e){jp!==e&&(jp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){jp===e&&(jp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(pp(r||n)===null)continue;break}var a=st(n);a!==null&&(e.splice(t,3),t-=3,gs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Np(e){function t(t){return Ap(t,e)}gp!==null&&Ap(gp,e),_p!==null&&Ap(_p,e),vp!==null&&Ap(vp,e),yp.forEach(t),bp.forEach(t);for(var n=0;n<xp.length;n++){var r=xp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<xp.length&&(n=xp[0],n.blockedOn===null);)Ep(n),n.blockedOn===null&&xp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[$e]||null;if(typeof a==`function`)o||Mp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[$e]||null)s=o.formAction;else if(pp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Mp(n)}}}function Pp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Fp(e){this._internalRoot=e}Ip.prototype.render=Fp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;np(n,du(),e,t,null,null)},Ip.prototype.unmount=Fp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;np(e.current,2,null,e,null,null),vu(),t[et]=null}};function Ip(e){this._internalRoot=e}Ip.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ye();e={blockedOn:null,target:e,priority:t};for(var n=0;n<xp.length&&t!==0&&t<xp[n].priority;n++);xp.splice(n,0,e),n===0&&Ep(e)}};var Lp=n.version;if(Lp!==`19.2.7`)throw Error(i(527,Lp,`19.2.7`));L.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=d(t),e=e===null?null:p(e),e=e===null?null:e.stateNode,e};var Rp={bundleType:0,version:`19.2.7`,rendererPackageName:`react-dom`,currentDispatcherRef:I,reconcilerVersion:`19.2.7`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var zp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zp.isDisabled&&zp.supportsFiber)try{De=zp.inject(Rp),Oe=zp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=zs,s=Bs,c=Vs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=ep(e,1,!1,null,null,n,r,null,o,s,c,Pp),e[et]=t.current,xd(e),new Fp(t)}})),g=c(o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h()}))(),1),_=c(u(),1),v=new Map,y={data:void 0,error:void 0,loading:!1,refreshing:!1,hasSucceeded:!1,lastAttemptOk:!1};function b(e){let t=v.get(e);return t||(t={snapshot:{data:void 0,error:void 0,loading:!1,refreshing:!1,hasSucceeded:!1,lastAttemptOk:!1},listeners:new Set,pollByListener:new Map,pauseWhenHiddenByListener:new Map,fetcherByListener:new Map,subscriberCount:0,pollTimer:null,pollIntervalMs:void 0,inflight:null,inflightOwner:null,visibilityListener:null,generation:0,seedNeedsRevalidate:!1},v.set(e,t)),t}function x(e){for(let t of e.listeners)t()}function S(e){e.pollTimer!==null&&(clearInterval(e.pollTimer),e.pollTimer=null),e.pollIntervalMs=void 0}function C(){return typeof document<`u`&&document.visibilityState===`hidden`}function w(e){if(!C())return T(e);for(let[t,n]of e.pollByListener)if(!(typeof n!=`number`||n<=0)&&e.pauseWhenHiddenByListener.get(t)===!1){let n=e.fetcherByListener.get(t);if(n)return{owner:t,fetcher:n}}return null}function T(e){for(let[t,n]of e.pollByListener)if(typeof n==`number`&&n>0){let n=e.fetcherByListener.get(t);if(n)return{owner:t,fetcher:n}}for(let[t,n]of e.fetcherByListener)return{owner:t,fetcher:n};return null}function E(e){let t;for(let n of e.pollByListener.values())typeof n==`number`&&n>0&&(t=t===void 0?n:Math.min(t,n));if(!(t===e.pollIntervalMs&&(t===void 0||e.pollTimer!==null))){if(S(e),e.pollIntervalMs=t,t===void 0){O(e);return}e.pollTimer=setInterval(()=>{let t=w(e);t&&k(e,t.fetcher,{replaceInflight:!1,owner:t.owner})},t),D(e)}}function D(e){if(typeof document>`u`||e.visibilityListener)return;let t=()=>{if(C()||e.pollIntervalMs===void 0)return;let t=T(e);t&&k(e,t.fetcher,{replaceInflight:!1,owner:t.owner})};document.addEventListener(`visibilitychange`,t),e.visibilityListener=t}function O(e){e.visibilityListener&&=(typeof document<`u`&&document.removeEventListener(`visibilitychange`,e.visibilityListener),null)}async function k(e,t,n){let r=n?.replaceInflight!==!1;if(e.inflight&&!r)return;r&&e.inflight?.abort();let i=new AbortController;e.inflight=i,e.inflightOwner=n?.owner??null;let a=++e.generation,o=e.snapshot.data===void 0||n?.forceLoading===!0;e.snapshot={...e.snapshot,loading:o?!0:e.snapshot.loading,refreshing:!0},x(e);try{let n=await t(i.signal);if(a!==e.generation||i.signal.aborted)return;e.seedNeedsRevalidate=!1,e.snapshot={data:n,error:void 0,loading:!1,refreshing:!1,hasSucceeded:!0,lastAttemptOk:!0}}catch(t){if(a!==e.generation||i.signal.aborted)return;e.seedNeedsRevalidate=!1,e.snapshot={...e.snapshot,error:t===void 0?Error(`resource load failed`):t,loading:!1,refreshing:!1,lastAttemptOk:!1}}finally{e.inflight===i&&(e.inflight=null,e.inflightOwner=null),x(e)}}function A(e,t){return e.inflightOwner===t?(e.inflight?.abort(),e.inflight=null,e.inflightOwner=null,e.generation++,e.snapshot.refreshing&&(e.snapshot={...e.snapshot,refreshing:!1},x(e)),!0):!1}function j(e,t){S(t),O(t),setTimeout(()=>{t.subscriberCount===0&&v.get(e)===t&&(t.inflight?.abort(),t.inflight=null,t.inflightOwner=null,v.delete(e))},0)}function M(e,t,n,r,i=!0){let a=b(e);return a.listeners.add(r),a.pollByListener.set(r,n),a.pauseWhenHiddenByListener.set(r,i),a.fetcherByListener.set(r,t),a.subscriberCount++,a.subscriberCount===1&&(a.snapshot.data===void 0||a.seedNeedsRevalidate)&&k(a,t,{replaceInflight:!0,owner:r}),E(a),()=>{a.listeners.delete(r),a.pollByListener.delete(r),a.pauseWhenHiddenByListener.delete(r),a.fetcherByListener.delete(r),a.subscriberCount--;let t=A(a,r);if(a.subscriberCount===0){j(e,a);return}if(t){let e=T(a);e&&k(a,e.fetcher,{replaceInflight:!0,owner:e.owner})}E(a)}}function N(e,t){let n=b(e);n.subscriberCount!==0||n.snapshot.data!==void 0||L(e,t)}function P(e,t,n){let r=n?.enabled!==!1,i=n?.pollMs,a=n?.pauseWhenHidden!==!1;r&&n?.initialData!==void 0&&N(e,n.initialData);let o=(0,_.useRef)(t);(0,_.useLayoutEffect)(()=>{o.current=t});let s=(0,_.useCallback)(e=>o.current(e),[]),c=(0,_.useRef)(null),l=(0,_.useCallback)(t=>r?(c.current=t,M(e,s,i,t,a)):()=>{},[e,s,i,r,a]),u=(0,_.useCallback)(()=>r?b(e).snapshot:y,[e,r]),d=(0,_.useSyncExternalStore)(l,u,u),f=(0,_.useCallback)(t=>{r&&k(b(e),s,{replaceInflight:!0,owner:c.current,forceLoading:t?.forceLoading})},[e,s,r]);return{...d,refresh:f}}function F(e,t){if(e===null)return!1;if(e.length!==t.length)return!0;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!0;return!1}function I(e,t,n,r){let i=P(e,n,r),a=(0,_.useRef)(null),o=(0,_.useRef)(null);return(0,_.useLayoutEffect)(()=>{let n=a.current,r=o.current;a.current=t,o.current=e,F(n,t)&&(r!==null&&r!==e||i.refresh({forceLoading:!0}))}),i}function L(e,t){let n=b(e);n.inflight?.abort(),n.inflight=null,n.inflightOwner=null,n.generation++,n.snapshot={data:t,error:void 0,loading:!1,refreshing:!1,hasSucceeded:!0,lastAttemptOk:!0},n.seedNeedsRevalidate=n.subscriberCount===0,x(n)}var R=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),z=o(((e,t)=>{t.exports=R()}))(),B=e=>({viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,...e}),V=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,z.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,z.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1.5`}),(0,z.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1.5`})]}),H=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`7`,rx:`2`}),(0,z.jsx)(`rect`,{x:`3`,y:`13`,width:`18`,height:`7`,rx:`2`}),(0,z.jsx)(`path`,{d:`M7 7.5h.01M7 16.5h.01`})]}),U=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`path`,{d:`M12 2 4 6v6l8 4 8-4V6l-8-4Z`}),(0,z.jsx)(`path`,{d:`m4 6 8 4 8-4M12 10v8`})]}),W=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`rect`,{x:`4`,y:`8`,width:`16`,height:`11`,rx:`3`}),(0,z.jsx)(`path`,{d:`M12 8V4M8 2h8`}),(0,z.jsx)(`circle`,{cx:`9`,cy:`13`,r:`1`}),(0,z.jsx)(`circle`,{cx:`15`,cy:`13`,r:`1`})]}),ee=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01`})}),te=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M4 6h16M4 12h16M4 18h16`})}),ne=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`path`,{d:`m4 17 6-5-6-5`}),(0,z.jsx)(`path`,{d:`M12 19h8`})]}),re=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M22 12h-4l-3 9L9 3l-3 9H2`})}),G=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`path`,{d:`M22 12H2`}),(0,z.jsx)(`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11Z`}),(0,z.jsx)(`path`,{d:`M6 16h.01M10 16h.01`})]}),ie=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`m20 6-11 11-5-5`})}),ae=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})}),oe=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M12 5v14M5 12h14`})}),se=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M21 12a9 9 0 0 1-9 9 9.8 9.8 0 0 1-6.7-2.7L3 16M3 21v-5h5M3 12a9 9 0 0 1 9-9 9.8 9.8 0 0 1 6.7 2.7L21 8M21 3v5h-5`})}),ce=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M8 5v14M16 5v14`})}),le=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`m7 4 13 8-13 8Z`})}),ue=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6`})}),de=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`path`,{d:`M10.3 3.7 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.7a2 2 0 0 0-3.4 0Z`}),(0,z.jsx)(`path`,{d:`M12 9v4M12 17h.01`})]}),fe=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,z.jsx)(`path`,{d:`M12 16v-4M12 8h.01`})]}),pe=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,z.jsx)(`path`,{d:`m21 21-4.3-4.3`})]}),me=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M12 19V5M5 12l7-7 7 7`})}),he=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M12 5v14M19 12l-7 7-7-7`})}),ge=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3`})}),_e=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`m9 18 6-6-6-6`})}),ve=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M9 19c-5 1.5-5-2.5-7-3m14 6v-3.9a3.4 3.4 0 0 0-.9-2.6c3-.3 6.2-1.5 6.2-6.7A5.2 5.2 0 0 0 20 4.8 4.9 4.9 0 0 0 19.9 1S18.7.6 16 2.5a13.4 13.4 0 0 0-7 0C6.3.6 5.1 1 5.1 1A4.9 4.9 0 0 0 5 4.8a5.2 5.2 0 0 0-1.4 3.7c0 5.1 3.1 6.4 6.1 6.7a3.4 3.4 0 0 0-.9 2.5V22`})}),ye=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`path`,{d:`M18.4 5.6a9 9 0 1 1-12.8 0`}),(0,z.jsx)(`path`,{d:`M12 2v10`})]}),be=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M15 3h6v6M10 14 21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`})}),xe=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`circle`,{cx:`7.5`,cy:`15.5`,r:`4.5`}),(0,z.jsx)(`path`,{d:`m10.7 12.3 9.6-9.6M16 7l3 3M14 9l2 2`})]}),Se=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`rect`,{x:`4`,y:`11`,width:`16`,height:`10`,rx:`2`}),(0,z.jsx)(`path`,{d:`M8 11V7a4 4 0 0 1 8 0v4`})]}),Ce=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`}),(0,z.jsx)(`path`,{d:`M13 5v2`}),(0,z.jsx)(`path`,{d:`M13 17v2`}),(0,z.jsx)(`path`,{d:`M13 11v2`})]}),we=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2M15 7h2a5 5 0 0 1 0 10h-2M8 12h8`})}),Te=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,z.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}),Ee=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M21 12.8A9 9 0 1 1 11.2 3 7 7 0 0 0 21 12.8Z`})}),De=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`}),(0,z.jsx)(`path`,{d:`M8 21h8M12 17v4`})]}),Oe=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,z.jsx)(`path`,{d:`M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18`})]}),ke=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M12 3v18M5.6 5.6l12.8 12.8M3 12h18M5.6 18.4 18.4 5.6`})}),Ae=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`path`,{d:`m18 14 4 4-4 4`}),(0,z.jsx)(`path`,{d:`m18 2 4 4-4 4`}),(0,z.jsx)(`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`}),(0,z.jsx)(`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`}),(0,z.jsx)(`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`})]}),je=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`circle`,{cx:`9`,cy:`6`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,z.jsx)(`circle`,{cx:`15`,cy:`6`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,z.jsx)(`circle`,{cx:`9`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,z.jsx)(`circle`,{cx:`15`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,z.jsx)(`circle`,{cx:`9`,cy:`18`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,z.jsx)(`circle`,{cx:`15`,cy:`18`,r:`1`,fill:`currentColor`,stroke:`none`})]}),Me=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`m12 2 3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z`})}),Ne=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M4 5h16l-6 7v5l-4 2v-7L4 5z`})}),Pe={"nav.dashboard":`Dashboard`,"nav.startup":`Startup`,"nav.providers":`Providers`,"nav.models":`Models`,"nav.combos":`Combos`,"nav.subagents":`Subagents`,"nav.logs":`Logs & Debug`,"nav.usage":`Usage`,"common.github":`GitHub`,"sidebar.star":`Star on GitHub`,"sidebar.starred":`Starred on GitHub`,"sidebar.starUnauthenticated":`Open GitHub to star (gh CLI is not signed in)`,"sidebar.starFailed":`Could not star through gh. Opening GitHub instead.`,"sidebar.updateAvailable":`Update available: {version}`,"sidebar.checkUpdate":`Check for updates`,"common.save":`Save`,"common.saving":`Saving…`,"common.cancel":`Cancel`,"common.discard":`Discard`,"common.close":`Close`,"common.ok":`OK`,"common.remove":`Remove`,"common.loading":`Loading…`,"common.retry":`Retry`,"app.logoAria":`opencodex logo`,"app.claudeOn":`Claude ON`,"app.claudeOff":`Claude OFF`,"theme.label":`Theme`,"theme.light":`Light`,"theme.dark":`Dark`,"theme.system":`System`,"lang.label":`Language`,"provider.name.volcengine":`Volcengine Ark`,"provider.name.volcengineCodingPlan":`Volcengine Ark Coding Plan`,"provider.name.volcengineAgentPlan":`Volcengine Ark Agent Plan`,"errorBoundary.title":`Page failed to load`,"errorBoundary.message":`This section hit a rendering error. Reload it to try again.`,"errorBoundary.details":`Error`,"errorBoundary.reload":`Reload`,"startup.title":`Startup safety`,"startup.subtitle":`Verify that Codex can reach opencodex after a restart, before local proxy routing becomes a reconnect loop.`,"startup.refresh":`Refresh`,"startup.backToDashboard":`Back to Dashboard`,"startup.loading":`Checking startup protection…`,"startup.error":`Could not read startup protection.`,"startup.staleData":`The latest startup check failed. The values below are stale and must not be treated as proof of protection.`,"startup.status.native":`Native routing`,"startup.status.protected":`Restart protected`,"startup.status.atRisk":`Action required`,"startup.summary.native":`Codex does not depend on the local proxy`,"startup.summary.protected":`opencodex will be available after restart`,"startup.summary.atRisk":`Codex can lose model access after restart`,"startup.riskDetail":`Codex is pinned to the local proxy, but no persistent service or healthy launcher shim will start it again.`,"startup.riskDetailCustomLocal":`Codex points to a custom local gateway. opencodex cannot manage or verify that gateway's restart lifecycle.`,"startup.riskDetailWindowsShim":`The launcher shim protects supported CLI scripts, but Codex Desktop and direct codex.exe launches can bypass it on Windows.`,"startup.safeDetail":`The current routing and startup mechanism are consistent. No manual ocx start should be required after restart.`,"startup.routing":`Codex routing`,"startup.routing.proxy":`Local proxy`,"startup.routing.native":`Native OpenAI`,"startup.routing.customLocal":`Custom local gateway`,"startup.routing.customRemote":`Custom remote gateway`,"startup.routing.unknown":`Unknown or invalid routing`,"startup.restartProtection":`Restart protection`,"startup.preference":`On-demand startup`,"startup.enabled":`Enabled`,"startup.disabled":`Disabled`,"startup.protection.service":`Background service`,"startup.protection.shim":`Launcher shim`,"startup.protection.none":`Not installed`,"startup.details":`Protection details`,"startup.service":`Background service`,"startup.serviceHint":`Starts at login and restarts the proxy after a crash.`,"startup.installed":`Installed`,"startup.notInstalled":`Not installed`,"startup.unsupported":`Unsupported`,"startup.shim":`Codex launcher shim`,"startup.shimHint":`Runs ocx ensure when a supported Codex script launcher starts.`,"startup.healthy":`Healthy`,"startup.cliOnly":`CLI only`,"startup.stale":`Stale`,"startup.viable":`Ready`,"startup.unhealthy":`Installed but unhealthy`,"startup.conflict":`Service conflict`,"startup.installedDisabled":`Installed but disabled`,"startup.install":`Install`,"startup.installing":`Installing…`,"startup.repair":`Repair`,"startup.repairing":`Repairing…`,"startup.serviceInstalled":`Background service installed successfully.`,"startup.serviceRepaired":`Background service repaired successfully.`,"startup.shimInstalled":`Codex launcher shim installed successfully.`,"startup.shimRepaired":`Codex launcher shim repaired successfully.`,"startup.installFailed":`Installation failed:`,"startup.tray.title":`Windows system tray`,"startup.tray.hint":`Install a login tray icon for one-click proxy start, stop, restart, dashboard, and status controls.`,"startup.tray.login":`Start tray at Windows login`,"startup.tray.notProtection":`The tray is a controller, not restart protection. A viable background service is still required for unattended proxy recovery.`,"startup.tray.running":`Running`,"startup.tray.stopped":`Installed, hidden`,"startup.tray.stale":`Repair required`,"startup.tray.notInstalled":`Not installed`,"startup.tray.loading":`Checking…`,"startup.tray.unavailable":`Status unavailable`,"startup.tray.install":`Install and show tray`,"startup.tray.start":`Show tray icon`,"startup.tray.stop":`Exit tray icon`,"startup.tray.uninstall":`Remove login tray`,"startup.tray.error":`The Windows tray action failed. Check ocx tray status for details.`,"startup.recovery":`Repair options`,"startup.recoveryHint":`Use the one-click installers above, or copy a command for manual repair. The background service is recommended for Codex Desktop and Windows executables.`,"startup.command.service":`Recommended: persistent background service`,"startup.command.shim":`Alternative: CLI launcher shim`,"startup.command.native":`Fail-safe: restore native Codex routing`,"startup.copy":`Copy`,"startup.copied":`Copied`,"startup.recommended":`Recommended repair: {cmd}`,"startup.navRisk":`Startup protection requires attention`,"startup.codexRuntime.clampHidden":`Some reasoning effort options were hidden because OpenCodex used Codex {version}.`,"startup.codexRuntime.clampHiddenWithEfforts":`Some reasoning effort options were hidden because OpenCodex used Codex {version} (removed: {efforts}).`,"startup.codexRuntime.olderBinary":`OpenCodex is using an older Codex binary ({version}). A newer installation is available.`,"dash.subtitle":`Live status of the local opencodex proxy, its providers, and the models routed into Codex.`,"dash.workspace.overview":`Overview`,"dash.workspace.sections":`Sections`,"dash.status":`Status`,"dash.online":`Online`,"dash.offline":`Offline`,"dash.version":`Version`,"dash.uptime":`Uptime`,"dash.providers":`Providers`,"dash.tokens30d":`Tokens (30d)`,"dash.coverage":`{pct} coverage`,"dash.mem.title":`Memory observability`,"dash.mem.hint":`Read-only runtime diagnostics. Observed memory is max(RSS, external, ArrayBuffers) so Windows working-set trimming does not hide committed retention.`,"dash.mem.rss":`Resident set (RSS)`,"dash.mem.jsHeap":`JS heap in use`,"dash.mem.jsHeapArena":`arena {total}`,"dash.mem.pressure":`Against warn threshold`,"dash.mem.pressureOf":`{pct}% of threshold`,"dash.mem.pressureUnknown":`No threshold reported`,"dash.mem.jscHeap":`JSC heap`,"dash.mem.external":`External`,"dash.mem.arrayBuffers":`ArrayBuffers`,"dash.mem.observed":`Observed`,"dash.mem.runtime":`Runtime counters`,"dash.mem.growth":`Observed drift / hour`,"dash.mem.perHour":`/h`,"dash.mem.store":`Continuation store`,"dash.mem.storeHint":`Proxy previous_response_id cache. Rising total bytes under a rising heap points at conversation retention rather than the runtime allocator.`,"dash.mem.storeEntries":`Entries`,"dash.mem.storeTotal":`Total`,"dash.mem.storeLargest":`Largest`,"dash.mem.storeOldest":`Oldest`,"dash.mem.threshold":`Warn threshold`,"dash.mem.lastWarn":`Last warning`,"dash.mem.never":`Never`,"dash.mem.details":`Details`,"dash.mem.unavailable":`Memory diagnostics unavailable (older proxy).`,"dash.mem.inFlight":`In-flight requests`,"dash.mem.restart":`Drain & restart`,"dash.mem.restartConfirm":`Wait for {count} in-flight request(s), then restart (up to {seconds}s; remaining requests are cut on timeout).`,"dash.mem.draining":`Draining {count} request(s)… restarting when complete`,"dash.mem.reconnecting":`Proxy restarting… waiting to reconnect`,"dash.mem.restartFailed":`Drain & restart failed. Check that the proxy is running.`,"dash.mem.restartNoSupervisor":`No restart protection detected. The proxy may stay down after restart unless you start it again.`,"dash.activeProviders":`Active providers`,"dash.noProviders":`No providers configured. Run {cmd}.`,"dash.col.name":`Name`,"dash.col.adapter":`Adapter`,"dash.col.baseUrl":`Base URL`,"dash.col.model":`Model`,"dash.modelsNoResults":`No models match your search.`,"dash.availableModels":`Available models`,"dash.noModels":`No models found. Check provider API keys.`,"dash.cannotConnect":`Cannot connect to proxy. Is it running?`,"dash.runStart":`Run {cmd} to start the proxy.`,"dash.stop":`Stop Proxy`,"dash.stopConfirm":`Stop the proxy and restore native Codex?`,"dash.stopFailed":`Failed to stop proxy (HTTP {status}).`,"dash.stopping":`Stopping…`,"dash.codexAutoStart":`Start opencodex with Codex`,"dash.codexAutoStartHint":`Allows an installed launcher shim to run ocx ensure. This setting does not install restart protection; check Startup safety for the effective state.`,"dash.searchModel":`Search sidecar model`,"dash.searchModelHint":`Model used for web_search on non-OpenAI routed models. Requires ChatGPT login.`,"dash.searchReasoning":`Search reasoning effort`,"dash.visionModel":`Vision sidecar model`,"dash.visionModelHint":`Model used to describe images for text-only routed models. Requires ChatGPT login.`,"dash.webSearchSidecar":`Web search sidecar`,"dash.webSearchSidecarHint":`Choose the backend and model used for web search on routed models.`,"dash.visionSidecar":`Vision sidecar`,"dash.visionSidecarHint":`Choose the backend and model used to describe images for text-only routed models.`,"dash.shadowCallIntercept":`Shadow Call Intercept`,"dash.shadowCallInterceptHint":`Intercepts Codex App's background helper calls ({models}) for title generation and commit messages and redirects them to your chosen model. Effort is fixed to low.`,"dash.shadowCallWarning":`⚠ When enabled, ALL requests for {models} will be replaced with the selected model.`,"dash.shadowCallOriginal":`Original`,"dash.shadowCallModel":`Replacement model`,"dash.shadowCallTooltip":`Codex App makes background helper calls for thread title generation, commit message generation, and skill orchestration. The helper model changed across client versions, so opencodex intercepts every model in this set: {models}. Enable this to redirect those calls to your chosen model.`,"models.shadowCallIntercept":`Shadow Call Intercept`,"models.shadowCallInterceptHint":`Intercepts Codex App's background helper calls ({models}) for titles and commit messages and redirects them to your chosen model.`,"dash.sidecarBackend":`Backend`,"dash.sidecarModel":`Model`,"dash.backendAuto":`Auto`,"dash.backendOpenAI":`OpenAI`,"dash.backendAnthropic":`Anthropic`,"dash.sidecarSaved":`Sidecar settings saved. Applied on the next request.`,"dash.sidecarSaveFailed":`Failed to save sidecar settings.`,"dash.injectionLabel":`Sub-agent delegation`,"dash.injectionHint":`Pick the model Codex should hand sub-agent work to. The two switches below decide where that pick is used.`,"dash.injectionManage":`Open settings`,"dash.syncCodexSubagentDefaults":`Also save as a Codex default`,"dash.syncCodexSubagentDefaultsHint":`On, the pick above is written into Codex's own config, so new tasks start with that model too. Off, it is remembered only here. It takes effect on the next sync or restart, and your hand-written [agents] settings are left alone.`,"dash.multiAgentGuidance":`Tell Codex how to split work`,"dash.multiAgentGuidanceHint":`Sends a short note telling Codex how to hand work to sub-agents. On v2 it names the models it may use and which to prefer; on v1 it only applies at max or ultra reasoning effort. Off, no note is added.`,"dash.injectionNone":`None`,"dash.injectionEffortLabel":`Reasoning effort`,"dash.injectionEffortNone":`Model default`,"dash.effortCapLabel":`V2 ultra effort limit`,"dash.subagentEffortCapLabel":`V2 sub-agent effort limit`,"dash.effortCapHelp":`Limits the reasoning effort for V2 ultra-mode turns. When set, incoming max-effort requests (from ultra mode) are capped to the selected level. The sub-agent limit applies only to spawned child agents. Caps only lower effort, never raise it. If a model doesn't support the capped level, it snaps down to the nearest supported level.`,"dash.effortCapNone":`No cap`,"dash.maintenance":`Maintenance`,"dash.maintenanceHint":`Refresh Codex's model catalog or install a newer opencodex release.`,"dash.syncModels":`Sync models`,"dash.syncModelsHint":`Rewrite Codex's model catalog from the providers you have connected.`,"dash.syncRun":`Sync now`,"dash.syncing":`Syncing…`,"dash.syncOk":`Sync complete. {count} model(s) appended.`,"dash.syncStaleHint":`If Codex still shows an older list, restart its long-lived app-server ({cmd}).`,"dash.syncFailed":`Sync failed: {error}`,"dash.projectConfigTitle":`Project Codex config bypasses OpenCodex`,"dash.projectConfigHint":`These repo-local settings override the OpenCodex proxy (e.g. route to OpenCode Go directly). Remove them so ~/.codex/config.toml routing applies in that project.`,"dash.checkUpdate":`Check update`,"dash.updateTitle":`Update opencodex`,"dash.updateDesc":`Check npm for the selected channel, then choose whether to restart the proxy after installation.`,"dash.updateChannel":`Channel`,"dash.updateChecking":`Checking for updates…`,"dash.updateInstalled":`Installed`,"dash.updateLatest":`Latest`,"dash.updateAvailable":`Update available`,"dash.updateCurrent":`Up to date`,"dash.updateCommand":`Command`,"dash.updateSource":`This is a source checkout. Update it from the terminal with the shown command.`,"dash.updateUnavailable":`Could not read the latest version from npm. Try again later.`,"dash.updateRetry":`Retry`,"dash.updateRecheck":`Re-check`,"dash.updateCannotAuto":`One-click update is unavailable ({reason}).`,"dash.updateReason.source_checkout":`source checkout`,"dash.updateReason.latest_unavailable":`npm registry unreachable`,"dash.updateReason.already_latest":`already on latest`,"dash.updateReason.unknown":`update unavailable`,"dash.updateRestart":`Restart after update`,"dash.updateRestartHint":`Recommended. The current GUI keeps running the old code until the proxy restarts.`,"dash.runUpdate":`Update`,"dash.updateReconnecting":`Waiting for the restarted proxy…`,"dash.updateStatus.running":`Updating opencodex.`,"dash.updateStatus.restarting":`Update installed. Restarting proxy.`,"dash.updateStatus.succeeded":`Update finished.`,"dash.updateStatus.failed":`Update failed.`,"prov.subtitle":`Configure the upstream providers opencodex routes into Codex. Log in with an account, add a provider, or edit the raw config.`,"prov.add":`Add Provider`,"prov.editJson":`Edit JSON`,"prov.accountLogin":`Account login`,"prov.noOauth":`No OAuth providers available.`,"prov.loggedIn":`logged in`,"prov.notLoggedIn":`not logged in`,"prov.logout":`Logout`,"prov.login":`Login`,"prov.loginWith":`Login with {provider}`,"prov.waitingBrowser":`Waiting for browser…`,"prov.didntOpen":`Didn't open? Click here`,"prov.copyLink":`Copy link`,"prov.linkCopied":`Copied`,"prov.linkCopyUnavailable":`Clipboard unavailable`,"prov.deviceCode":`Device code`,"prov.copyCode":`Copy code`,"prov.codeCopied":`Code copied`,"prov.editAlias":`Edit alias`,"prov.aliasPrompt":`Display name (leave empty to clear)`,"prov.aliasSaved":`Alias saved`,"prov.aliasSaveFailed":`Could not save alias`,"prov.accountId":`ID`,"prov.pasteRedirect":`Paste redirect URL or code`,"prov.pasteRedirectHint":`If the browser shows a localhost error, copy the full URL from its address bar and paste it here (or paste the authorization code).`,"prov.pasteSubmit":`Submit`,"prov.pasteSubmitting":`Submitting…`,"prov.pasteOk":`Code submitted — finishing login…`,"prov.pasteFail":`Could not submit code: {error}`,"prov.port":`Port`,"prov.default":`Default`,"prov.loadingConfig":`Loading…`,"prov.saved":`Saved! Restart proxy to apply.`,"prov.loadConfigFail":`Failed to load config`,"prov.invalidJson":`Invalid JSON`,"prov.saveFailed":`Save failed`,"prov.loginFailStart":`{provider} login failed to start`,"prov.loginError":`{provider} login error: {error}`,"prov.loginRequestFail":`{provider} login request failed`,"prov.loginCancelled":`{provider} login cancelled`,"prov.loginTimeout":`{provider} login timed out — browser closed or never finished. Try again.`,"prov.loginOk":`Logged in to {provider}. Run {cmd} (or it applies live) to list its models.`,"oauthTos.highTitle":`{provider}: subscription OAuth risk`,"oauthTos.elevatedTitle":`{provider}: unofficial OAuth bridge`,"oauthTos.anthropicBody":`Directly reusing Claude subscription OAuth tokens through a third-party proxy such as OpenCodex is not a supported Anthropic integration and may lead to access restrictions. Supported Agent SDK integrations that use Claude subscriptions are separate.`,"oauthTos.highBody":`OpenCodex connects {provider} through a third-party OAuth path. Unsupported use may lead to access limits or suspension.`,"oauthTos.elevatedBody":`OpenCodex connects {provider} through an unofficial OAuth path. Use the official client when possible; unusual or automated traffic may be treated as abuse and access may be limited or suspended.`,"oauthTos.saferPath":`Safer option: configure an API key in OpenCodex instead.`,"oauthTos.acknowledge":`I understand the risk and want to continue with OAuth anyway.`,"oauthTos.continue":`Continue with OAuth`,"prov.logoutOk":`Logged out of {provider}.`,"prov.logoutFail":`Could not log out of {provider}. Your account state is unchanged.`,"prov.removed":`Removed "{name}".`,"prov.removedDefault":`Removed "{name}". Default provider is now "{defaultProvider}".`,"prov.removeFail":`Failed to remove "{name}".`,"prov.removeLastProvider":`You can't remove this provider when no other enabled provider can become the default.`,"prov.removeHasDependentCombos":`Remove or update these dependent combos first: {combos}.`,"prov.setDefault":`Set as default`,"prov.setDefaultSuccess":`"{name}" is now the default provider.`,"prov.setDefaultFail":`Couldn't set "{name}" as the default provider.`,"prov.defaultDisabled":`Enable this provider before making it the default.`,"prov.updateFail":`Couldn't update this provider.`,"prov.networkError":`Network error. Check that the proxy is running and try again.`,"prov.added":`Added "{name}". Live now — run {cmd} (or restart) to list its models in Codex's picker.`,"prov.removeConfirm":`Remove provider "{name}"? Its models disappear from Codex's picker.`,"prov.hasApiKey":`api key configured`,"prov.hasHeaders":`custom headers configured`,"prov.accounts":`Accounts ({n})`,"prov.accountsAria":`Toggle {name} accounts`,"prov.accountActive":`Active`,"prov.accountReauth":`Re-login`,"prov.reauthenticate":`Re-authenticate`,"prov.reauthAccountMissing":`Selected account was not found after login`,"prov.reauthIdentityMismatch":`Signed-in account did not match the selected account`,"prov.accountAdd":`Add account`,"prov.accountNoLabel":`account {id}`,"prov.accountSwitchTitle":`Use this account`,"prov.accountSwitched":`Switched to {email}.`,"prov.accountSwitchFail":`Failed to switch account`,"prov.accountRemoved":`Removed {email}.`,"prov.accountRemoveFail":`Could not remove {email}. The account is unchanged.`,"prov.accountRemoveAria":`Remove {email}`,"prov.accountRemoveConfirm":`Remove account {email}? Its login is deleted from this proxy.`,"prov.keyAdd":`Add API key`,"prov.keyAdded":`Added API key to {name}.`,"prov.keyAddFail":`Failed to add API key`,"prov.keyPlaceholder":`Paste API key`,"prov.keySwitchTitle":`Use this key`,"prov.keySwitched":`Switched to key {key}.`,"prov.keySwitchFail":`Failed to switch key`,"prov.keyRemoved":`Removed key {key}.`,"prov.keyRemoveAria":`Remove key {key}`,"prov.keyRemoveConfirm":`Remove API key {key}? It is deleted from this proxy's config.`,"prov.activeBadge":`Active`,"prov.disabledBadge":`Disabled`,"prov.defaultBadge":`Default`,"prov.enable":`Enable`,"prov.disable":`Disable`,"prov.enabled":`Enabled "{name}". Its models can appear in Codex again.`,"prov.disabled":`Disabled "{name}". Settings are kept, but its models are hidden.`,"prov.enableFail":`Failed to enable "{name}".`,"prov.disableFail":`Failed to disable "{name}".`,"prov.enableAria":`Enable provider {name}`,"prov.disableAria":`Disable provider {name}`,"prov.defaultCannotDisable":`Default provider can't be disabled`,"prov.openaiAccountMode":`Codex account mode`,"prov.openaiModePool":`Pool`,"prov.openaiModeDirect":`Direct`,"prov.openaiPoolDesc":`Default. Rotate the main login and added accounts using affinity, quota, cooldown, and failover.`,"prov.openaiDirectDesc":`Use only the current/main Codex login. Stored pool accounts are not read or rotated.`,"prov.openaiModeSaved":`OpenAI account mode changed to {mode}.`,"prov.openaiModeSaveFailed":`Could not change the OpenAI account mode.`,"prov.openaiApiDesc":`Uses an OpenAI API key and never uses Codex account credentials.`,"prov.manageCodexAccounts":`Manage Codex accounts`,"prov.openaiApiMissing":`API key required`,"prov.openaiApiSetup":`Set up API key`,"models.subtitle":`Toggle which models Codex sees — native GPT passthrough and routed providers, grouped by provider (click a header to collapse). Hidden models stay off the catalog + model picker but remain directly callable by exact id. Changes apply on the next Codex turn — opencodex invalidates Codex's 5-min model cache so no restart is needed.`,"models.nativeGroupLabel":`OpenAI native`,"models.nativeHint":`Passthrough models use the Pool or Direct account option selected on Providers. Toggling one off hides it from the Codex picker (the catalog entry is kept, so re-enabling restores it exactly).`,"models.active":`{active}/{total} visible`,"models.workspace.providers":`Providers`,"models.workspace.allProviders":`All providers`,"models.workspace.mainAria":`Model details`,"models.combosEmpty":`No combos configured yet`,"models.combosSetup":`Set up`,"models.combosAdd":`Add combo`,"models.combosActive":`{count} active`,"models.allOn":`All on`,"models.allOff":`All off`,"models.cap350k":`Cap 350k`,"models.capApplied":`Context cap applied — takes effect on the next Codex turn.`,"models.capSaveFailed":`Failed to save context cap`,"models.contextCapped":`350k cap`,"models.contextCapLabel":`Context cap`,"models.v2Label":`Sub-agent`,"models.shadowCallOriginal":`⚠ {models} →`,"models.v2DocsLink":`What is v1 / v2?`,"models.v2Mode_v1":`v1`,"models.v2Mode_default":`base`,"models.v2Mode_v2":`v2`,"models.v2ModeDesc_v1":`All models → v1 surface`,"models.v2ModeDesc_default":`Upstream defaults (sol/terra=v2, luna=v1)`,"models.v2ModeDesc_v2":`All models → v2 surface`,"models.v2Help":`Controls the multi-agent surface for all models.
8
+ `+e.stack}}var pe=Object.prototype.hasOwnProperty,me=t.unstable_scheduleCallback,he=t.unstable_cancelCallback,ge=t.unstable_shouldYield,_e=t.unstable_requestPaint,ve=t.unstable_now,ye=t.unstable_getCurrentPriorityLevel,be=t.unstable_ImmediatePriority,xe=t.unstable_UserBlockingPriority,Se=t.unstable_NormalPriority,Ce=t.unstable_LowPriority,we=t.unstable_IdlePriority,Te=t.log,Ee=t.unstable_setDisableYieldValue,De=null,Oe=null;function ke(e){if(typeof Te==`function`&&Ee(e),Oe&&typeof Oe.setStrictMode==`function`)try{Oe.setStrictMode(De,e)}catch{}}var Ae=Math.clz32?Math.clz32:Ne,je=Math.log,Me=Math.LN2;function Ne(e){return e>>>=0,e===0?32:31-(je(e)/Me|0)|0}var Pe=256,Fe=262144,Ie=4194304;function Le(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Re(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Le(n))):i=Le(o):i=Le(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Le(n))):i=Le(o)):i=Le(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function ze(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Be(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ve(){var e=Ie;return Ie<<=1,!(Ie&62914560)&&(Ie=4194304),e}function K(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function He(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ue(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-Ae(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&We(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function We(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Ae(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Ge(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ae(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Ke(e,t){var n=t&-t;return n=n&42?1:qe(n),(n&(e.suspendedLanes|t))===0?n:0}function qe(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Je(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Ye(){var e=L.p;return e===0?(e=window.event,e===void 0?32:mp(e.type)):e}function Xe(e,t){var n=L.p;try{return L.p=e,t()}finally{L.p=n}}var Ze=Math.random().toString(36).slice(2),Qe=`__reactFiber$`+Ze,$e=`__reactProps$`+Ze,et=`__reactContainer$`+Ze,tt=`__reactEvents$`+Ze,nt=`__reactListeners$`+Ze,rt=`__reactHandles$`+Ze,it=`__reactResources$`+Ze,q=`__reactMarker$`+Ze;function at(e){delete e[Qe],delete e[$e],delete e[tt],delete e[nt],delete e[rt]}function ot(e){var t=e[Qe];if(t)return t;for(var n=e.parentNode;n;){if(t=n[et]||n[Qe]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=df(e);e!==null;){if(n=e[Qe])return n;e=df(e)}return t}e=n,n=e.parentNode}return null}function st(e){if(e=e[Qe]||e[et]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function ct(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function lt(e){var t=e[it];return t||=e[it]={hoistableStyles:new Map,hoistableScripts:new Map},t}function J(e){e[q]=!0}var ut=new Set,dt={};function ft(e,t){pt(e,t),pt(e+`Capture`,t)}function pt(e,t){for(dt[e]=t,e=0;e<t.length;e++)ut.add(t[e])}var mt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),ht={},gt={};function _t(e){return pe.call(gt,e)?!0:pe.call(ht,e)?!1:mt.test(e)?gt[e]=!0:(ht[e]=!0,!1)}function vt(e,t,n){if(_t(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function yt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function bt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function xt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function St(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Ct(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function wt(e){if(!e._valueTracker){var t=St(e)?`checked`:`value`;e._valueTracker=Ct(e,t,``+e[t])}}function Tt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=St(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function Et(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Dt=/[\n"\\]/g;function Ot(e){return e.replace(Dt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function kt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+xt(t)):e.value!==``+xt(t)&&(e.value=``+xt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):jt(e,o,xt(n)):jt(e,o,xt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+xt(s):e.removeAttribute(`name`)}function At(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){wt(e);return}n=n==null?``:``+xt(n),t=t==null?n:``+xt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),wt(e)}function jt(e,t,n){t===`number`&&Et(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function Mt(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+xt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Nt(e,t,n){if(t!=null&&(t=``+xt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+xt(n)}function Pt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(F(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=xt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),wt(e)}function Ft(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var It=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Lt(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||It.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Rt(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Lt(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Lt(e,o,t[o])}function zt(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Bt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),Vt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Ht(e){return Vt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Ut(){}var Wt=null;function Gt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Kt=null,qt=null;function Jt(e){var t=st(e);if(t&&(e=t.stateNode)){var n=e[$e]||null;a:switch(e=t.stateNode,t.type){case`input`:if(kt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Ot(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[$e]||null;if(!a)throw Error(i(90));kt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Tt(r)}break a;case`textarea`:Nt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Mt(e,!!n.multiple,t,!1)}}}var Yt=!1;function Xt(e,t,n){if(Yt)return e(t,n);Yt=!0;try{return e(t)}finally{if(Yt=!1,(Kt!==null||qt!==null)&&(_u(),Kt&&(t=Kt,e=qt,qt=Kt=null,Jt(t),e)))for(t=0;t<e.length;t++)Jt(e[t])}}function Zt(e,t){var n=e.stateNode;if(n===null)return null;var r=n[$e]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var Qt=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),$t=!1;if(Qt)try{var en={};Object.defineProperty(en,"passive",{get:function(){$t=!0}}),window.addEventListener(`test`,en,en),window.removeEventListener(`test`,en,en)}catch{$t=!1}var tn=null,nn=null,rn=null;function an(){if(rn)return rn;var e,t=nn,n=t.length,r,i=`value`in tn?tn.value:tn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return rn=i.slice(e,1<r?1-r:void 0)}function on(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function sn(){return!0}function Y(){return!1}function X(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?sn:Y,this.isPropagationStopped=Y,this}return h(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=sn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=sn)},persist:function(){},isPersistent:sn}),t}var cn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ln=X(cn),un=h({},cn,{view:0,detail:0}),dn=X(un),fn,pn,mn,hn=h({},un,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:En,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==mn&&(mn&&e.type===`mousemove`?(fn=e.screenX-mn.screenX,pn=e.screenY-mn.screenY):pn=fn=0,mn=e),fn)},movementY:function(e){return`movementY`in e?e.movementY:pn}}),gn=X(hn),_n=X(h({},hn,{dataTransfer:0})),vn=X(h({},un,{relatedTarget:0})),yn=X(h({},cn,{animationName:0,elapsedTime:0,pseudoElement:0})),bn=X(h({},cn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),xn=X(h({},cn,{data:0})),Sn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Cn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},wn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Tn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=wn[e])?!!t[e]:!1}function En(){return Tn}var Dn=X(h({},un,{key:function(e){if(e.key){var t=Sn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=on(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Cn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:En,charCode:function(e){return e.type===`keypress`?on(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?on(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),On=X(h({},hn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),kn=X(h({},un,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:En})),An=X(h({},cn,{propertyName:0,elapsedTime:0,pseudoElement:0})),jn=X(h({},hn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Mn=X(h({},cn,{newState:0,oldState:0})),Nn=[9,13,27,32],Pn=Qt&&`CompositionEvent`in window,Fn=null;Qt&&`documentMode`in document&&(Fn=document.documentMode);var In=Qt&&`TextEvent`in window&&!Fn,Ln=Qt&&(!Pn||Fn&&8<Fn&&11>=Fn),Rn=` `,zn=!1;function Bn(e,t){switch(e){case`keyup`:return Nn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Vn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Hn=!1;function Un(e,t){switch(e){case`compositionend`:return Vn(t);case`keypress`:return t.which===32?(zn=!0,Rn):null;case`textInput`:return e=t.data,e===Rn&&zn?null:e;default:return null}}function Wn(e,t){if(Hn)return e===`compositionend`||!Pn&&Bn(e,t)?(e=an(),rn=nn=tn=null,Hn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Ln&&t.locale!==`ko`?null:t.data;default:return null}}var Gn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Kn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Gn[e.type]:t===`textarea`}function qn(e,t,n,r){Kt?qt?qt.push(r):qt=[r]:Kt=r,t=Td(t,`onChange`),0<t.length&&(n=new ln(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Jn=null,Yn=null;function Xn(e){_d(e,0)}function Zn(e){if(Tt(ct(e)))return e}function Qn(e,t){if(e===`change`)return t}var $n=!1;if(Qt){var er;if(Qt){var tr=`oninput`in document;if(!tr){var nr=document.createElement(`div`);nr.setAttribute(`oninput`,`return;`),tr=typeof nr.oninput==`function`}er=tr}else er=!1;$n=er&&(!document.documentMode||9<document.documentMode)}function rr(){Jn&&(Jn.detachEvent(`onpropertychange`,ir),Yn=Jn=null)}function ir(e){if(e.propertyName===`value`&&Zn(Yn)){var t=[];qn(t,Yn,e,Gt(e)),Xt(Xn,t)}}function ar(e,t,n){e===`focusin`?(rr(),Jn=t,Yn=n,Jn.attachEvent(`onpropertychange`,ir)):e===`focusout`&&rr()}function or(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Zn(Yn)}function sr(e,t){if(e===`click`)return Zn(t)}function cr(e,t){if(e===`input`||e===`change`)return Zn(t)}function lr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var ur=typeof Object.is==`function`?Object.is:lr;function dr(e,t){if(ur(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!pe.call(t,i)||!ur(e[i],t[i]))return!1}return!0}function fr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function pr(e,t){var n=fr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=fr(n)}}function mr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?mr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function hr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Et(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Et(e.document)}return t}function gr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var _r=Qt&&`documentMode`in document&&11>=document.documentMode,vr=null,yr=null,br=null,xr=!1;function Sr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;xr||vr==null||vr!==Et(r)||(r=vr,`selectionStart`in r&&gr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),br&&dr(br,r)||(br=r,r=Td(yr,`onSelect`),0<r.length&&(t=new ln(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=vr)))}function Cr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var wr={animationend:Cr(`Animation`,`AnimationEnd`),animationiteration:Cr(`Animation`,`AnimationIteration`),animationstart:Cr(`Animation`,`AnimationStart`),transitionrun:Cr(`Transition`,`TransitionRun`),transitionstart:Cr(`Transition`,`TransitionStart`),transitioncancel:Cr(`Transition`,`TransitionCancel`),transitionend:Cr(`Transition`,`TransitionEnd`)},Tr={},Er={};Qt&&(Er=document.createElement(`div`).style,`AnimationEvent`in window||(delete wr.animationend.animation,delete wr.animationiteration.animation,delete wr.animationstart.animation),`TransitionEvent`in window||delete wr.transitionend.transition);function Dr(e){if(Tr[e])return Tr[e];if(!wr[e])return e;var t=wr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Er)return Tr[e]=t[n];return e}var Or=Dr(`animationend`),kr=Dr(`animationiteration`),Ar=Dr(`animationstart`),jr=Dr(`transitionrun`),Mr=Dr(`transitionstart`),Nr=Dr(`transitioncancel`),Pr=Dr(`transitionend`),Fr=new Map,Ir=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Ir.push(`scrollEnd`);function Lr(e,t){Fr.set(e,t),ft(t,[e])}var Rr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},zr=[],Br=0,Vr=0;function Hr(){for(var e=Br,t=Vr=Br=0;t<e;){var n=zr[t];zr[t++]=null;var r=zr[t];zr[t++]=null;var i=zr[t];zr[t++]=null;var a=zr[t];if(zr[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Kr(n,i,a)}}function Ur(e,t,n,r){zr[Br++]=e,zr[Br++]=t,zr[Br++]=n,zr[Br++]=r,Vr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Wr(e,t,n,r){return Ur(e,t,n,r),qr(e)}function Gr(e,t){return Ur(e,null,null,t),qr(e)}function Kr(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-Ae(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function qr(e){if(50<cu)throw cu=0,lu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Jr={};function Yr(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Xr(e,t,n,r){return new Yr(e,t,n,r)}function Zr(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Qr(e,t){var n=e.alternate;return n===null?(n=Xr(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function $r(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function ei(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)Zr(e)&&(s=1);else if(typeof e==`string`)s=Uf(e,n,W.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case k:return e=Xr(31,n,t,a),e.elementType=k,e.lanes=o,e;case y:return ti(n.children,a,o,t);case b:s=8,a|=24;break;case x:return e=Xr(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case T:return e=Xr(13,n,t,a),e.elementType=T,e.lanes=o,e;case E:return e=Xr(19,n,t,a),e.elementType=E,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case C:s=10;break a;case S:s=9;break a;case w:s=11;break a;case D:s=14;break a;case O:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=Xr(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function ti(e,t,n,r){return e=Xr(7,e,r,t),e.lanes=n,e}function ni(e,t,n){return e=Xr(6,e,null,t),e.lanes=n,e}function ri(e){var t=Xr(18,null,null,0);return t.stateNode=e,t}function ii(e,t,n){return t=Xr(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var ai=new WeakMap;function oi(e,t){if(typeof e==`object`&&e){var n=ai.get(e);return n===void 0?(t={value:e,source:t,stack:fe(t)},ai.set(e,t),t):n}return{value:e,source:t,stack:fe(t)}}var si=[],ci=0,li=null,ui=0,di=[],fi=0,pi=null,mi=1,hi=``;function gi(e,t){si[ci++]=ui,si[ci++]=li,li=e,ui=t}function _i(e,t,n){di[fi++]=mi,di[fi++]=hi,di[fi++]=pi,pi=e;var r=mi;e=hi;var i=32-Ae(r)-1;r&=~(1<<i),n+=1;var a=32-Ae(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,mi=1<<32-Ae(t)+i|n<<i|r,hi=a+e}else mi=1<<a|n<<i|r,hi=e}function vi(e){e.return!==null&&(gi(e,1),_i(e,1,0))}function yi(e){for(;e===li;)li=si[--ci],si[ci]=null,ui=si[--ci],si[ci]=null;for(;e===pi;)pi=di[--fi],di[fi]=null,hi=di[--fi],di[fi]=null,mi=di[--fi],di[fi]=null}function bi(e,t){di[fi++]=mi,di[fi++]=hi,di[fi++]=pi,mi=t.id,hi=t.overflow,pi=e}var xi=null,Si=null,Z=!1,Ci=null,wi=!1,Ti=Error(i(519));function Ei(e){throw Mi(oi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Ti}function Di(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[Qe]=e,t[$e]=r,n){case`dialog`:vd(`cancel`,t),vd(`close`,t);break;case`iframe`:case`object`:case`embed`:vd(`load`,t);break;case`video`:case`audio`:for(n=0;n<hd.length;n++)vd(hd[n],t);break;case`source`:vd(`error`,t);break;case`img`:case`image`:case`link`:vd(`error`,t),vd(`load`,t);break;case`details`:vd(`toggle`,t);break;case`input`:vd(`invalid`,t),At(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:vd(`invalid`,t);break;case`textarea`:vd(`invalid`,t),Pt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||jd(t.textContent,n)?(r.popover!=null&&(vd(`beforetoggle`,t),vd(`toggle`,t)),r.onScroll!=null&&vd(`scroll`,t),r.onScrollEnd!=null&&vd(`scrollend`,t),r.onClick!=null&&(t.onclick=Ut),t=!0):t=!1,t||Ei(e,!0)}function Oi(e){for(xi=e.return;xi;)switch(xi.tag){case 5:case 31:case 13:wi=!1;return;case 27:case 3:wi=!0;return;default:xi=xi.return}}function ki(e){if(e!==xi)return!1;if(!Z)return Oi(e),Z=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||Ud(e.type,e.memoizedProps)),n=!n),n&&Si&&Ei(e),Oi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Si=uf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Si=uf(e)}else t===27?(t=Si,Zd(e.type)?(e=lf,lf=null,Si=e):Si=t):Si=xi?cf(e.stateNode.nextSibling):null;return!0}function Ai(){Si=xi=null,Z=!1}function ji(){var e=Ci;return e!==null&&(Jl===null?Jl=e:Jl.push.apply(Jl,e),Ci=null),e}function Mi(e){Ci===null?Ci=[e]:Ci.push(e)}var Ni=V(null),Pi=null,Fi=null;function Ii(e,t,n){U(Ni,t._currentValue),t._currentValue=n}function Li(e){e._currentValue=Ni.current,H(Ni)}function Ri(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function zi(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Ri(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),Ri(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Bi(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;ur(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===ne.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[Qf]:e.push(Qf))}a=a.return}e!==null&&zi(t,e,n,r),t.flags|=262144}function Vi(e){for(e=e.firstContext;e!==null;){if(!ur(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Hi(e){Pi=e,Fi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Ui(e){return Gi(Pi,e)}function Wi(e,t){return Pi===null&&Hi(e),Gi(e,t)}function Gi(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Fi===null){if(e===null)throw Error(i(308));Fi=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Fi=Fi.next=t;return n}var Ki=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},qi=t.unstable_scheduleCallback,Ji=t.unstable_NormalPriority,Yi={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Xi(){return{controller:new Ki,data:new Map,refCount:0}}function Zi(e){e.refCount--,e.refCount===0&&qi(Ji,function(){e.controller.abort()})}var Qi=null,$i=0,ea=0,ta=null;function na(e,t){if(Qi===null){var n=Qi=[];$i=0,ea=ld(),ta={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return $i++,t.then(ra,ra),t}function ra(){if(--$i===0&&Qi!==null){ta!==null&&(ta.status=`fulfilled`);var e=Qi;Qi=null,ea=0,ta=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function ia(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var aa=I.S;I.S=function(e,t){Zl=ve(),typeof t==`object`&&t&&typeof t.then==`function`&&na(e,t),aa!==null&&aa(e,t)};var oa=V(null);function sa(){var e=oa.current;return e===null?Nl.pooledCache:e}function ca(e,t){t===null?U(oa,oa.current):U(oa,t.pool)}function la(){var e=sa();return e===null?null:{parent:Yi._currentValue,pool:e}}var ua=Error(i(460)),da=Error(i(474)),fa=Error(i(542)),pa={then:function(){}};function ma(e){return e=e.status,e===`fulfilled`||e===`rejected`}function ha(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Ut,Ut),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ya(e),e;default:if(typeof t.status==`string`)t.then(Ut,Ut);else{if(e=Nl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ya(e),e}throw _a=t,ua}}function ga(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(_a=e,ua):e}}var _a=null;function va(){if(_a===null)throw Error(i(459));var e=_a;return _a=null,e}function ya(e){if(e===ua||e===fa)throw Error(i(483))}var ba=null,xa=0;function Sa(e){var t=xa;return xa+=1,ba===null&&(ba=[]),ha(ba,e,t)}function Ca(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function wa(e,t){throw t.$$typeof===g?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Ta(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=Qr(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=ni(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===y?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===O&&ga(i)===t.type)?(t=a(t,n.props),Ca(t,n),t.return=e,t):(t=ei(n.type,n.key,n.props,null,e.mode,r),Ca(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=ii(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=ti(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=ni(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case _:return n=ei(t.type,t.key,t.props,null,e.mode,n),Ca(n,t),n.return=e,n;case v:return t=ii(t,e.mode,n),t.return=e,t;case O:return t=ga(t),f(e,t,n)}if(F(t)||M(t))return t=ti(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Sa(t),n);if(t.$$typeof===C)return f(e,Wi(e,t),n);wa(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case _:return n.key===i?l(e,t,n,r):null;case v:return n.key===i?u(e,t,n,r):null;case O:return n=ga(n),p(e,t,n,r)}if(F(n)||M(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Sa(n),r);if(n.$$typeof===C)return p(e,t,Wi(e,n),r);wa(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case _:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case v:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case O:return r=ga(r),m(e,t,n,r,i)}if(F(r)||M(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,Sa(r),i);if(r.$$typeof===C)return m(e,t,n,Wi(t,r),i);wa(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Z&&gi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return Z&&gi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),Z&&gi(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Z&&gi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Z&&gi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Z&&gi(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case _:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===O&&ga(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ca(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=ti(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=ei(o.type,o.key,o.props,null,e.mode,c),Ca(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ii(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=ga(o),b(e,r,o,c)}if(F(o))return h(e,r,o,c);if(M(o)){if(l=M(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,Sa(o),c);if(o.$$typeof===C)return b(e,r,Wi(e,o),c);wa(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=ni(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{xa=0;var i=b(e,t,n,r);return ba=null,i}catch(t){if(t===ua||t===fa)throw t;var a=Xr(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ea=Ta(!0),Da=Ta(!1),Oa=!1;function ka(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Aa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ja(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ma(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ml&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=qr(e),Kr(e,null,n),t}return Ur(e,r,t,n),qr(e)}function Na(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ge(e,n)}}function Pa(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Fa=!1;function Ia(){if(Fa){var e=ta;if(e!==null)throw e}}function La(e,t,n,r){Fa=!1;var i=e.updateQueue;Oa=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Pl&f)===f:(r&f)===f){f!==0&&f===ea&&(Fa=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(m=g.payload,typeof m==`function`){d=m.call(_,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=g.payload,f=typeof m==`function`?m.call(_,d,f):m,f==null)break a;d=h({},d,f);break a;case 2:Oa=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Hl|=o,e.lanes=o,e.memoizedState=d}}function Ra(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function za(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ra(n[e],t)}var Ba=V(null),Va=V(0);function Ha(e,t){e=Bl,U(Va,e),U(Ba,t),Bl=e|t.baseLanes}function Ua(){U(Va,Bl),U(Ba,Ba.current)}function Wa(){Bl=Va.current,H(Ba),H(Va)}var Ga=V(null),Ka=null;function qa(e){var t=e.alternate;U(Qa,Qa.current&1),U(Ga,e),Ka===null&&(t===null||Ba.current!==null||t.memoizedState!==null)&&(Ka=e)}function Ja(e){U(Qa,Qa.current),U(Ga,e),Ka===null&&(Ka=e)}function Ya(e){e.tag===22?(U(Qa,Qa.current),U(Ga,e),Ka===null&&(Ka=e)):Xa(e)}function Xa(){U(Qa,Qa.current),U(Ga,Ga.current)}function Za(e){H(Ga),Ka===e&&(Ka=null),H(Qa)}var Qa=V(0);function $a(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||af(n)||of(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var eo=0,Q=null,to=null,no=null,ro=!1,io=!1,ao=!1,oo=0,so=0,co=null,lo=0;function uo(){throw Error(i(321))}function fo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!ur(e[n],t[n]))return!1;return!0}function po(e,t,n,r,i,a){return eo=a,Q=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,I.H=e===null||e.memoizedState===null?As:js,ao=!1,a=n(r,i),ao=!1,io&&(a=ho(t,n,r,i)),mo(e),a}function mo(e){I.H=ks;var t=to!==null&&to.next!==null;if(eo=0,no=to=Q=null,ro=!1,so=0,co=null,t)throw Error(i(300));e===null||Js||(e=e.dependencies,e!==null&&Vi(e)&&(Js=!0))}function ho(e,t,n,r){Q=e;var a=0;do{if(io&&(co=null),so=0,io=!1,25<=a)throw Error(i(301));if(a+=1,no=to=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}I.H=Ms,o=t(n,r)}while(io);return o}function go(){var e=I.H,t=e.useState()[0];return t=typeof t.then==`function`?Co(t):t,e=e.useState()[0],(to===null?null:to.memoizedState)!==e&&(Q.flags|=1024),t}function _o(){var e=oo!==0;return oo=0,e}function vo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function yo(e){if(ro){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}ro=!1}eo=0,no=to=Q=null,io=!1,so=oo=0,co=null}function bo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return no===null?Q.memoizedState=no=e:no=no.next=e,no}function xo(){if(to===null){var e=Q.alternate;e=e===null?null:e.memoizedState}else e=to.next;var t=no===null?Q.memoizedState:no.next;if(t!==null)no=t,to=e;else{if(e===null)throw Q.alternate===null?Error(i(467)):Error(i(310));to=e,e={memoizedState:to.memoizedState,baseState:to.baseState,baseQueue:to.baseQueue,queue:to.queue,next:null},no===null?Q.memoizedState=no=e:no=no.next=e}return no}function So(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Co(e){var t=so;return so+=1,co===null&&(co=[]),e=ha(co,e,t),t=Q,(no===null?t.memoizedState:no.next)===null&&(t=t.alternate,I.H=t===null||t.memoizedState===null?As:js),e}function wo(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Co(e);if(e.$$typeof===C)return Ui(e)}throw Error(i(438,String(e)))}function To(e){var t=null,n=Q.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=Q.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=So(),Q.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=A;return t.index++,n}function Eo(e,t){return typeof t==`function`?t(e):t}function Do(e){return Oo(xo(),to,e)}function Oo(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(eo&f)===f:(Pl&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===ea&&(d=!0);else if((eo&p)===p){u=u.next,p===ea&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,Q.lanes|=p,Hl|=p;f=u.action,ao&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,Q.lanes|=f,Hl|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!ur(o,e.memoizedState)&&(Js=!0,d&&(n=ta,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function ko(e){var t=xo(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);ur(o,t.memoizedState)||(Js=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Ao(e,t,n){var r=Q,a=xo(),o=Z;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!ur((to||a).memoizedState,n);if(s&&(a.memoizedState=n,Js=!0),a=a.queue,ts(No.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||no!==null&&no.memoizedState.tag&1){if(r.flags|=2048,Xo(9,{destroy:void 0},Mo.bind(null,r,a,n,t),null),Nl===null)throw Error(i(349));o||eo&127||jo(r,t,n)}return n}function jo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Q.updateQueue,t===null?(t=So(),Q.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Mo(e,t,n,r){t.value=n,t.getSnapshot=r,Po(t)&&Fo(e)}function No(e,t,n){return n(function(){Po(t)&&Fo(e)})}function Po(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!ur(e,n)}catch{return!0}}function Fo(e){var t=Gr(e,2);t!==null&&fu(t,e,2)}function Io(e){var t=bo();if(typeof e==`function`){var n=e;if(e=n(),ao){ke(!0);try{n()}finally{ke(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Eo,lastRenderedState:e},t}function Lo(e,t,n,r){return e.baseState=n,Oo(e,to,typeof r==`function`?r:Eo)}function Ro(e,t,n,r,a){if(Es(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};I.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,zo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function zo(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=I.T,o={};I.T=o;try{var s=n(i,r),c=I.S;c!==null&&c(o,s),Bo(e,t,s)}catch(n){Ho(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),I.T=a}}else try{a=n(i,r),Bo(e,t,a)}catch(n){Ho(e,t,n)}}function Bo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Vo(e,t,n)},function(n){return Ho(e,t,n)}):Vo(e,t,n)}function Vo(e,t,n){t.status=`fulfilled`,t.value=n,Uo(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,zo(e,n)))}function Ho(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Uo(t),t=t.next;while(t!==r)}e.action=null}function Uo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Wo(e,t){return t}function Go(e,t){if(Z){var n=Nl.formState;if(n!==null){a:{var r=Q;if(Z){if(Si){b:{for(var i=Si,a=wi;i.nodeType!==8;){if(!a){i=null;break b}if(i=cf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Si=cf(i.nextSibling),r=i.data===`F!`;break a}}Ei(r)}r=!1}r&&(t=n[0])}}return n=bo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wo,lastRenderedState:t},n.queue=r,n=Cs.bind(null,Q,r),r.dispatch=n,r=Io(!1),a=Ts.bind(null,Q,!1,r.queue),r=bo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Ro.bind(null,Q,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Ko(e){return qo(xo(),to,e)}function qo(e,t,n){if(t=Oo(e,t,Wo)[0],e=Do(Eo)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Co(t)}catch(e){throw e===ua?fa:e}else r=t;t=xo();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Q.flags|=2048,Xo(9,{destroy:void 0},Jo.bind(null,i,n),null)),[r,a,e]}function Jo(e,t){e.action=t}function Yo(e){var t=xo(),n=to;if(n!==null)return qo(t,n,e);xo(),t=t.memoizedState,n=xo();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Xo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=Q.updateQueue,t===null&&(t=So(),Q.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Zo(){return xo().memoizedState}function Qo(e,t,n,r){var i=bo();Q.flags|=e,i.memoizedState=Xo(1|t,{destroy:void 0},n,r===void 0?null:r)}function $o(e,t,n,r){var i=xo();r=r===void 0?null:r;var a=i.memoizedState.inst;to!==null&&r!==null&&fo(r,to.memoizedState.deps)?i.memoizedState=Xo(t,a,n,r):(Q.flags|=e,i.memoizedState=Xo(1|t,a,n,r))}function es(e,t){Qo(8390656,8,e,t)}function ts(e,t){$o(2048,8,e,t)}function ns(e){Q.flags|=4;var t=Q.updateQueue;if(t===null)t=So(),Q.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function rs(e){var t=xo().memoizedState;return ns({ref:t,nextImpl:e}),function(){if(Ml&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function is(e,t){return $o(4,2,e,t)}function as(e,t){return $o(4,4,e,t)}function os(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function ss(e,t,n){n=n==null?null:n.concat([e]),$o(4,4,os.bind(null,t,e),n)}function cs(){}function ls(e,t){var n=xo();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&fo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function us(e,t){var n=xo();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&fo(t,r[1]))return r[0];if(r=e(),ao){ke(!0);try{e()}finally{ke(!1)}}return n.memoizedState=[r,t],r}function ds(e,t,n){return n===void 0||eo&1073741824&&!(Pl&261930)?e.memoizedState=t:(e.memoizedState=n,e=du(),Q.lanes|=e,Hl|=e,n)}function fs(e,t,n,r){return ur(n,t)?n:Ba.current===null?!(eo&42)||eo&1073741824&&!(Pl&261930)?(Js=!0,e.memoizedState=n):(e=du(),Q.lanes|=e,Hl|=e,t):(e=ds(e,n,r),ur(e,t)||(Js=!0),e)}function ps(e,t,n,r,i){var a=L.p;L.p=a!==0&&8>a?a:8;var o=I.T,s={};I.T=s,Ts(e,!1,t,n);try{var c=i(),l=I.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?ws(e,t,ia(c,r),uu(e)):ws(e,t,r,uu(e))}catch(n){ws(e,t,{then:function(){},status:`rejected`,reason:n},uu())}finally{L.p=a,o!==null&&s.types!==null&&(o.types=s.types),I.T=o}}function ms(){}function hs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=gs(e).queue;ps(e,a,t,R,n===null?ms:function(){return _s(e),n(r)})}function gs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:R,baseState:R,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Eo,lastRenderedState:R},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Eo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function _s(e){var t=gs(e);t.next===null&&(t=e.alternate.memoizedState),ws(e,t.next.queue,{},uu())}function vs(){return Ui(Qf)}function ys(){return xo().memoizedState}function bs(){return xo().memoizedState}function xs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=uu();e=ja(n);var r=Ma(t,e,n);r!==null&&(fu(r,t,n),Na(r,t,n)),t={cache:Xi()},e.payload=t;return}t=t.return}}function Ss(e,t,n){var r=uu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Es(e)?Ds(t,n):(n=Wr(e,t,n,r),n!==null&&(fu(n,e,r),Os(n,t,r)))}function Cs(e,t,n){ws(e,t,n,uu())}function ws(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Es(e))Ds(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,ur(s,o))return Ur(e,t,i,0),Nl===null&&Hr(),!1}catch{}if(n=Wr(e,t,i,r),n!==null)return fu(n,e,r),Os(n,t,r),!0}return!1}function Ts(e,t,n,r){if(r={lane:2,revertLane:ld(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Es(e)){if(t)throw Error(i(479))}else t=Wr(e,n,r,2),t!==null&&fu(t,e,2)}function Es(e){var t=e.alternate;return e===Q||t!==null&&t===Q}function Ds(e,t){io=ro=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Os(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ge(e,n)}}var ks={readContext:Ui,use:wo,useCallback:uo,useContext:uo,useEffect:uo,useImperativeHandle:uo,useLayoutEffect:uo,useInsertionEffect:uo,useMemo:uo,useReducer:uo,useRef:uo,useState:uo,useDebugValue:uo,useDeferredValue:uo,useTransition:uo,useSyncExternalStore:uo,useId:uo,useHostTransitionStatus:uo,useFormState:uo,useActionState:uo,useOptimistic:uo,useMemoCache:uo,useCacheRefresh:uo};ks.useEffectEvent=uo;var As={readContext:Ui,use:wo,useCallback:function(e,t){return bo().memoizedState=[e,t===void 0?null:t],e},useContext:Ui,useEffect:es,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Qo(4194308,4,os.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Qo(4194308,4,e,t)},useInsertionEffect:function(e,t){Qo(4,2,e,t)},useMemo:function(e,t){var n=bo();t=t===void 0?null:t;var r=e();if(ao){ke(!0);try{e()}finally{ke(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=bo();if(n!==void 0){var i=n(t);if(ao){ke(!0);try{n(t)}finally{ke(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ss.bind(null,Q,e),[r.memoizedState,e]},useRef:function(e){var t=bo();return e={current:e},t.memoizedState=e},useState:function(e){e=Io(e);var t=e.queue,n=Cs.bind(null,Q,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:cs,useDeferredValue:function(e,t){return ds(bo(),e,t)},useTransition:function(){var e=Io(!1);return e=ps.bind(null,Q,e.queue,!0,!1),bo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Q,a=bo();if(Z){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Nl===null)throw Error(i(349));Pl&127||jo(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,es(No.bind(null,r,o,e),[e]),r.flags|=2048,Xo(9,{destroy:void 0},Mo.bind(null,r,o,n,t),null),n},useId:function(){var e=bo(),t=Nl.identifierPrefix;if(Z){var n=hi,r=mi;n=(r&~(1<<32-Ae(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=oo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=lo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:vs,useFormState:Go,useActionState:Go,useOptimistic:function(e){var t=bo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Ts.bind(null,Q,!0,n),n.dispatch=t,[e,t]},useMemoCache:To,useCacheRefresh:function(){return bo().memoizedState=xs.bind(null,Q)},useEffectEvent:function(e){var t=bo(),n={impl:e};return t.memoizedState=n,function(){if(Ml&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},js={readContext:Ui,use:wo,useCallback:ls,useContext:Ui,useEffect:ts,useImperativeHandle:ss,useInsertionEffect:is,useLayoutEffect:as,useMemo:us,useReducer:Do,useRef:Zo,useState:function(){return Do(Eo)},useDebugValue:cs,useDeferredValue:function(e,t){return fs(xo(),to.memoizedState,e,t)},useTransition:function(){var e=Do(Eo)[0],t=xo().memoizedState;return[typeof e==`boolean`?e:Co(e),t]},useSyncExternalStore:Ao,useId:ys,useHostTransitionStatus:vs,useFormState:Ko,useActionState:Ko,useOptimistic:function(e,t){return Lo(xo(),to,e,t)},useMemoCache:To,useCacheRefresh:bs};js.useEffectEvent=rs;var Ms={readContext:Ui,use:wo,useCallback:ls,useContext:Ui,useEffect:ts,useImperativeHandle:ss,useInsertionEffect:is,useLayoutEffect:as,useMemo:us,useReducer:ko,useRef:Zo,useState:function(){return ko(Eo)},useDebugValue:cs,useDeferredValue:function(e,t){var n=xo();return to===null?ds(n,e,t):fs(n,to.memoizedState,e,t)},useTransition:function(){var e=ko(Eo)[0],t=xo().memoizedState;return[typeof e==`boolean`?e:Co(e),t]},useSyncExternalStore:Ao,useId:ys,useHostTransitionStatus:vs,useFormState:Yo,useActionState:Yo,useOptimistic:function(e,t){var n=xo();return to===null?(n.baseState=e,[e,n.queue.dispatch]):Lo(n,to,e,t)},useMemoCache:To,useCacheRefresh:bs};Ms.useEffectEvent=rs;function Ns(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:h({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ps={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=uu(),i=ja(r);i.payload=t,n!=null&&(i.callback=n),t=Ma(e,i,r),t!==null&&(fu(t,e,r),Na(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=uu(),i=ja(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Ma(e,i,r),t!==null&&(fu(t,e,r),Na(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=uu(),r=ja(n);r.tag=2,t!=null&&(r.callback=t),t=Ma(e,r,n),t!==null&&(fu(t,e,n),Na(t,e,n))}};function Fs(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!dr(n,r)||!dr(i,a):!0}function Is(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Ps.enqueueReplaceState(t,t.state,null)}function Ls(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=h({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Rs(e){Rr(e)}function zs(e){console.error(e)}function Bs(e){Rr(e)}function Vs(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Hs(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Us(e,t,n){return n=ja(n),n.tag=3,n.payload={element:null},n.callback=function(){Vs(e,t)},n}function Ws(e){return e=ja(e),e.tag=3,e}function Gs(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Hs(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Hs(t,n,r),typeof i!=`function`&&(eu===null?eu=new Set([this]):eu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Ks(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Bi(t,n,a,!0),n=Ga.current,n!==null){switch(n.tag){case 31:case 13:return Ka===null?wu():n.alternate===null&&Vl===0&&(Vl=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===pa?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Uu(e,r,a)),!1;case 22:return n.flags|=65536,r===pa?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Uu(e,r,a)),!1}throw Error(i(435,n.tag))}return Uu(e,r,a),wu(),!1}if(Z)return t=Ga.current,t===null?(r!==Ti&&(t=Error(i(423),{cause:r}),Mi(oi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=oi(r,n),a=Us(e.stateNode,r,a),Pa(e,a),Vl!==4&&(Vl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Ti&&(e=Error(i(422),{cause:r}),Mi(oi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=oi(o,n),ql===null?ql=[o]:ql.push(o),Vl!==4&&(Vl=2),t===null)return!0;r=oi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Us(n.stateNode,r,e),Pa(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(eu===null||!eu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Ws(a),Gs(a,e,n,r),Pa(n,a),!1}n=n.return}while(n!==null);return!1}var qs=Error(i(461)),Js=!1;function Ys(e,t,n,r){t.child=e===null?Da(t,null,n,r):Ea(t,e.child,n,r)}function Xs(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Hi(t),r=po(e,t,n,o,a,i),s=_o(),e!==null&&!Js?(vo(e,t,i),bc(e,t,i)):(Z&&s&&vi(t),t.flags|=1,Ys(e,t,r,i),t.child)}function Zs(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Zr(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Qs(e,t,a,r,i)):(e=ei(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!xc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?dr:n,n(o,r)&&e.ref===t.ref)return bc(e,t,i)}return t.flags|=1,e=Qr(a,r),e.ref=t.ref,e.return=t,t.child=e}function Qs(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(dr(a,r)&&e.ref===t.ref)if(Js=!1,t.pendingProps=r=a,xc(e,i))e.flags&131072&&(Js=!0);else return t.lanes=e.lanes,bc(e,t,i)}return oc(e,t,n,r,i)}function $s(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return tc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&ca(t,a===null?null:a.cachePool),a===null?Ua():Ha(t,a),Ya(t);else return r=t.lanes=536870912,tc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&ca(t,null),Ua(),Xa(t)):(ca(t,a.cachePool),Ha(t,a),Xa(t),t.memoizedState=null);return Ys(e,t,i,n),t.child}function ec(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function tc(e,t,n,r,i){var a=sa();return a=a===null?null:{parent:Yi._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&ca(t,null),Ua(),Ya(t),e!==null&&Bi(e,t,r,!0),t.childLanes=i,null}function nc(e,t){return t=hc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function rc(e,t,n){return Ea(t,e.child,null,n),e=nc(t,t.pendingProps),e.flags|=2,Za(t),t.memoizedState=null,e}function ic(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Z){if(r.mode===`hidden`)return e=nc(t,r),t.lanes=536870912,ec(null,e);if(Ja(t),(e=Si)?(e=rf(e,wi),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:pi===null?null:{id:mi,overflow:hi},retryLane:536870912,hydrationErrors:null},n=ri(e),n.return=t,t.child=n,xi=t,Si=null)):e=null,e===null)throw Ei(t);return t.lanes=536870912,null}return nc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Ja(t),a)if(t.flags&256)t.flags&=-257,t=rc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(Js||Bi(e,t,n,!1),a=(n&e.childLanes)!==0,Js||a){if(r=Nl,r!==null&&(s=Ke(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Gr(e,s),fu(r,e,s),qs;wu(),t=rc(e,t,n)}else e=o.treeContext,Si=cf(s.nextSibling),xi=t,Z=!0,Ci=null,wi=!1,e!==null&&bi(t,e),t=nc(t,r),t.flags|=4096;return t}return e=Qr(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function ac(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function oc(e,t,n,r,i){return Hi(t),n=po(e,t,n,r,void 0,i),r=_o(),e!==null&&!Js?(vo(e,t,i),bc(e,t,i)):(Z&&r&&vi(t),t.flags|=1,Ys(e,t,n,i),t.child)}function sc(e,t,n,r,i,a){return Hi(t),t.updateQueue=null,n=ho(t,r,n,i),mo(e),r=_o(),e!==null&&!Js?(vo(e,t,a),bc(e,t,a)):(Z&&r&&vi(t),t.flags|=1,Ys(e,t,n,a),t.child)}function cc(e,t,n,r,i){if(Hi(t),t.stateNode===null){var a=Jr,o=n.contextType;typeof o==`object`&&o&&(a=Ui(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Ps,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},ka(t),o=n.contextType,a.context=typeof o==`object`&&o?Ui(o):Jr,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Ns(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Ps.enqueueReplaceState(a,a.state,null),La(t,r,a,i),Ia(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Ls(n,s);a.props=c;var l=a.context,u=n.contextType;o=Jr,typeof u==`object`&&u&&(o=Ui(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Is(t,a,r,o),Oa=!1;var f=t.memoizedState;a.state=f,La(t,r,a,i),Ia(),l=t.memoizedState,s||f!==l||Oa?(typeof d==`function`&&(Ns(t,n,d,r),l=t.memoizedState),(c=Oa||Fs(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Aa(e,t),o=t.memoizedProps,u=Ls(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Jr,typeof l==`object`&&l&&(c=Ui(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Is(t,a,r,c),Oa=!1,f=t.memoizedState,a.state=f,La(t,r,a,i),Ia();var p=t.memoizedState;o!==d||f!==p||Oa||e!==null&&e.dependencies!==null&&Vi(e.dependencies)?(typeof s==`function`&&(Ns(t,n,s,r),p=t.memoizedState),(u=Oa||Fs(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Vi(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,ac(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Ea(t,e.child,null,i),t.child=Ea(t,null,n,i)):Ys(e,t,n,i),t.memoizedState=a.state,e=t.child):e=bc(e,t,i),e}function lc(e,t,n,r){return Ai(),t.flags|=256,Ys(e,t,n,r),t.child}var uc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function dc(e){return{baseLanes:e,cachePool:la()}}function fc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Gl),e}function pc(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(Qa.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Z){if(a?qa(t):Xa(t),(e=Si)?(e=rf(e,wi),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:pi===null?null:{id:mi,overflow:hi},retryLane:536870912,hydrationErrors:null},n=ri(e),n.return=t,t.child=n,xi=t,Si=null)):e=null,e===null)throw Ei(t);return of(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(Xa(t),a=t.mode,c=hc({mode:`hidden`,children:c},a),r=ti(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=dc(n),r.childLanes=fc(e,s,n),t.memoizedState=uc,ec(null,r)):(qa(t),mc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(qa(t),t.flags&=-257,t=gc(e,t,n)):t.memoizedState===null?(Xa(t),c=r.fallback,a=t.mode,r=hc({mode:`visible`,children:r.children},a),c=ti(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Ea(t,e.child,null,n),r=t.child,r.memoizedState=dc(n),r.childLanes=fc(e,s,n),t.memoizedState=uc,t=ec(null,r)):(Xa(t),t.child=e.child,t.flags|=128,t=null);else if(qa(t),of(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Mi({value:r,source:null,stack:null}),t=gc(e,t,n)}else if(Js||Bi(e,t,n,!1),s=(n&e.childLanes)!==0,Js||s){if(s=Nl,s!==null&&(r=Ke(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Gr(e,r),fu(s,e,r),qs;af(c)||wu(),t=gc(e,t,n)}else af(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Si=cf(c.nextSibling),xi=t,Z=!0,Ci=null,wi=!1,e!==null&&bi(t,e),t=mc(t,r.children),t.flags|=4096);return t}return a?(Xa(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=Qr(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=ti(c,a,n,null),c.flags|=2):c=Qr(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,ec(null,r),r=t.child,c=e.child.memoizedState,c===null?c=dc(n):(a=c.cachePool,a===null?a=la():(l=Yi._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=fc(e,s,n),t.memoizedState=uc,ec(e.child,r)):(qa(t),n=e.child,e=n.sibling,n=Qr(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function mc(e,t){return t=hc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function hc(e,t){return e=Xr(22,e,null,t),e.lanes=0,e}function gc(e,t,n){return Ea(t,e.child,null,n),e=mc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function _c(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ri(e.return,t,n)}function vc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function yc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Qa.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,U(Qa,o),Ys(e,t,r,n),r=Z?ui:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&_c(e,n,t);else if(e.tag===19)_c(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&$a(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),vc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&$a(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}vc(t,!0,n,null,a,r);break;case`together`:vc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function bc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Hl|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Bi(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=Qr(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Qr(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function xc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&Vi(e))):!0}function Sc(e,t,n){switch(t.tag){case 3:re(t,t.stateNode.containerInfo),Ii(t,Yi,e.memoizedState.cache),Ai();break;case 27:case 5:ie(t);break;case 4:re(t,t.stateNode.containerInfo);break;case 10:Ii(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Ja(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(qa(t),e=bc(e,t,n),e===null?null:e.sibling):pc(e,t,n):(qa(t),t.flags|=128,null);qa(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(Bi(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return yc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),U(Qa,Qa.current),r)break;return null;case 22:return t.lanes=0,$s(e,t,n,t.pendingProps);case 24:Ii(t,Yi,e.memoizedState.cache)}return bc(e,t,n)}function Cc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)Js=!0;else{if(!xc(e,n)&&!(t.flags&128))return Js=!1,Sc(e,t,n);Js=!!(e.flags&131072)}else Js=!1,Z&&t.flags&1048576&&_i(t,ui,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=ga(t.elementType),t.type=e,typeof e==`function`)Zr(e)?(r=Ls(e,r),t.tag=1,t=cc(null,t,e,r,n)):(t.tag=0,t=oc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===w){t.tag=11,t=Xs(null,t,e,r,n);break a}else if(a===D){t.tag=14,t=Zs(null,t,e,r,n);break a}}throw t=P(e)||e,Error(i(306,t,``))}}return t;case 0:return oc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Ls(r,t.pendingProps),cc(e,t,r,a,n);case 3:a:{if(re(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Aa(e,t),La(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Ii(t,Yi,r),r!==o.cache&&zi(t,[Yi],n,!0),Ia(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=lc(e,t,r,n);break a}else if(r!==a){a=oi(Error(i(424)),t),Mi(a),t=lc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Si=cf(e.firstChild),xi=t,Z=!0,Ci=null,wi=!0,n=Da(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ai(),r===a){t=bc(e,t,n);break a}Ys(e,t,r,n)}t=t.child}return t;case 26:return ac(e,t),e===null?(n=kf(t.type,null,t.pendingProps,null))?t.memoizedState=n:Z||(n=t.type,e=t.pendingProps,r=Bd(te.current).createElement(n),r[Qe]=t,r[$e]=e,Pd(r,n,e),J(r),t.stateNode=r):t.memoizedState=kf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ie(t),e===null&&Z&&(r=t.stateNode=ff(t.type,t.pendingProps,te.current),xi=t,wi=!0,a=Si,Zd(t.type)?(lf=a,Si=cf(r.firstChild)):Si=a),Ys(e,t,t.pendingProps.children,n),ac(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Z&&((a=r=Si)&&(r=tf(r,t.type,t.pendingProps,wi),r===null?a=!1:(t.stateNode=r,xi=t,Si=cf(r.firstChild),wi=!1,a=!0)),a||Ei(t)),ie(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,Ud(a,o)?r=null:s!==null&&Ud(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=po(e,t,go,null,null,n),Qf._currentValue=a),ac(e,t),Ys(e,t,r,n),t.child;case 6:return e===null&&Z&&((e=n=Si)&&(n=nf(n,t.pendingProps,wi),n===null?e=!1:(t.stateNode=n,xi=t,Si=null,e=!0)),e||Ei(t)),null;case 13:return pc(e,t,n);case 4:return re(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Ea(t,null,r,n):Ys(e,t,r,n),t.child;case 11:return Xs(e,t,t.type,t.pendingProps,n);case 7:return Ys(e,t,t.pendingProps,n),t.child;case 8:return Ys(e,t,t.pendingProps.children,n),t.child;case 12:return Ys(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Ii(t,t.type,r.value),Ys(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Hi(t),a=Ui(a),r=r(a),t.flags|=1,Ys(e,t,r,n),t.child;case 14:return Zs(e,t,t.type,t.pendingProps,n);case 15:return Qs(e,t,t.type,t.pendingProps,n);case 19:return yc(e,t,n);case 31:return ic(e,t,n);case 22:return $s(e,t,n,t.pendingProps);case 24:return Hi(t),r=Ui(Yi),e===null?(a=sa(),a===null&&(a=Nl,o=Xi(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},ka(t),Ii(t,Yi,a)):((e.lanes&n)!==0&&(Aa(e,t),La(t,null,null,n),Ia()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Ii(t,Yi,r),r!==a.cache&&zi(t,[Yi],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Ii(t,Yi,r))),Ys(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function wc(e){e.flags|=4}function Tc(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(xu())e.flags|=8192;else throw _a=pa,da}else e.flags&=-16777217}function Ec(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Wf(t))if(xu())e.flags|=8192;else throw _a=pa,da}function Dc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Ve(),e.lanes|=t,Kl|=t)}function Oc(e,t){if(!Z)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function kc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Ac(e,t,n){var r=t.pendingProps;switch(yi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return kc(t),null;case 1:return kc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Li(Yi),G(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(ki(t)?wc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ji())),kc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(wc(t),o===null?(kc(t),Tc(t,a,null,r,n)):(kc(t),Ec(t,o))):o?o===e.memoizedState?(kc(t),t.flags&=-16777217):(wc(t),kc(t),Ec(t,o)):(e=e.memoizedProps,e!==r&&wc(t),kc(t),Tc(t,a,e,r,n)),null;case 27:if(ae(t),n=te.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&wc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return kc(t),null}e=W.current,ki(t)?Di(t,e):(e=ff(a,r,n),t.stateNode=e,wc(t))}return kc(t),null;case 5:if(ae(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&wc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return kc(t),null}if(o=W.current,ki(t))Di(t,o);else{var s=Bd(te.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[Qe]=t,o[$e]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Pd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&wc(t)}}return kc(t),Tc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&wc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=te.current,ki(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=xi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[Qe]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||jd(e.nodeValue,n)),e||Ei(t,!0)}else e=Bd(e).createTextNode(r),e[Qe]=t,t.stateNode=e}return kc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ki(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[Qe]=t}else Ai(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;kc(t),e=!1}else n=ji(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Za(t),t):(Za(t),null);if(t.flags&128)throw Error(i(558))}return kc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=ki(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[Qe]=t}else Ai(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;kc(t),a=!1}else a=ji(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Za(t),t):(Za(t),null)}return Za(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Dc(t,t.updateQueue),kc(t),null);case 4:return G(),e===null&&xd(t.stateNode.containerInfo),kc(t),null;case 10:return Li(t.type),kc(t),null;case 19:if(H(Qa),r=t.memoizedState,r===null)return kc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)Oc(r,!1);else{if(Vl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=$a(e),o!==null){for(t.flags|=128,Oc(r,!1),e=o.updateQueue,t.updateQueue=e,Dc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)$r(n,e),n=n.sibling;return U(Qa,Qa.current&1|2),Z&&gi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&ve()>Ql&&(t.flags|=128,a=!0,Oc(r,!1),t.lanes=4194304)}else{if(!a)if(e=$a(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Dc(t,e),Oc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Z)return kc(t),null}else 2*ve()-r.renderingStartTime>Ql&&n!==536870912&&(t.flags|=128,a=!0,Oc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(kc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=ve(),e.sibling=null,n=Qa.current,U(Qa,a?n&1|2:n&1),Z&&gi(t,r.treeForkCount),e);case 22:case 23:return Za(t),Wa(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(kc(t),t.subtreeFlags&6&&(t.flags|=8192)):kc(t),n=t.updateQueue,n!==null&&Dc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&H(oa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Li(Yi),kc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function jc(e,t){switch(yi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Li(Yi),G(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ae(t),null;case 31:if(t.memoizedState!==null){if(Za(t),t.alternate===null)throw Error(i(340));Ai()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Za(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Ai()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return H(Qa),null;case 4:return G(),null;case 10:return Li(t.type),null;case 22:case 23:return Za(t),Wa(),e!==null&&H(oa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Li(Yi),null;case 25:return null;default:return null}}function Mc(e,t){switch(yi(t),t.tag){case 3:Li(Yi),G();break;case 26:case 27:case 5:ae(t);break;case 4:G();break;case 31:t.memoizedState!==null&&Za(t);break;case 13:Za(t);break;case 19:H(Qa);break;case 10:Li(t.type);break;case 22:case 23:Za(t),Wa(),e!==null&&H(oa);break;case 24:Li(Yi)}}function Nc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Hu(t,t.return,e)}}function Pc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Hu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Hu(t,t.return,e)}}function Fc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{za(t,n)}catch(t){Hu(e,e.return,t)}}}function Ic(e,t,n){n.props=Ls(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Hu(e,t,n)}}function Lc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Hu(e,t,n)}}function Rc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Hu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Hu(e,t,n)}else n.current=null}function zc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Hu(e,e.return,t)}}function Bc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[$e]=t}catch(t){Hu(e,e.return,t)}}function Vc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function Hc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Vc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Uc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ut));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Uc(e,t,n),e=e.sibling;e!==null;)Uc(e,t,n),e=e.sibling}function Wc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Wc(e,t,n),e=e.sibling;e!==null;)Wc(e,t,n),e=e.sibling}function Gc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Pd(t,r,n),t[Qe]=e,t[$e]=n}catch(t){Hu(e,e.return,t)}}var Kc=!1,qc=!1,Jc=!1,Yc=typeof WeakSet==`function`?WeakSet:Set,Xc=null;function Zc(e,t){if(e=e.containerInfo,Rd=sp,e=hr(e),gr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(zd={focusedElem:e,selectionRange:n},sp=!1,Xc=t;Xc!==null;)if(t=Xc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Xc=e;else for(;Xc!==null;){switch(t=Xc,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Ls(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Hu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)ef(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:ef(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,Xc=e;break}Xc=t.return}}function Qc(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:pl(e,n),r&4&&Nc(5,n);break;case 1:if(pl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Hu(n,n.return,e)}else{var i=Ls(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Hu(n,n.return,e)}}r&64&&Fc(n),r&512&&Lc(n,n.return);break;case 3:if(pl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{za(e,t)}catch(e){Hu(n,n.return,e)}}break;case 27:t===null&&r&4&&Gc(n);case 26:case 5:pl(e,n),t===null&&r&4&&zc(n),r&512&&Lc(n,n.return);break;case 12:pl(e,n);break;case 31:pl(e,n),r&4&&il(e,n);break;case 13:pl(e,n),r&4&&al(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Ku.bind(null,n),sf(e,n))));break;case 22:if(r=n.memoizedState!==null||Kc,!r){t=t!==null&&t.memoizedState!==null||qc,i=Kc;var a=qc;Kc=r,(qc=t)&&!a?hl(e,n,(n.subtreeFlags&8772)!=0):pl(e,n),Kc=i,qc=a}break;case 30:break;default:pl(e,n)}}function $c(e){var t=e.alternate;t!==null&&(e.alternate=null,$c(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&at(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var el=null,tl=!1;function nl(e,t,n){for(n=n.child;n!==null;)rl(e,t,n),n=n.sibling}function rl(e,t,n){if(Oe&&typeof Oe.onCommitFiberUnmount==`function`)try{Oe.onCommitFiberUnmount(De,n)}catch{}switch(n.tag){case 26:qc||Rc(n,t),nl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:qc||Rc(n,t);var r=el,i=tl;Zd(n.type)&&(el=n.stateNode,tl=!1),nl(e,t,n),pf(n.stateNode),el=r,tl=i;break;case 5:qc||Rc(n,t);case 6:if(r=el,i=tl,el=null,nl(e,t,n),el=r,tl=i,el!==null)if(tl)try{(el.nodeType===9?el.body:el.nodeName===`HTML`?el.ownerDocument.body:el).removeChild(n.stateNode)}catch(e){Hu(n,t,e)}else try{el.removeChild(n.stateNode)}catch(e){Hu(n,t,e)}break;case 18:el!==null&&(tl?(e=el,Qd(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Np(e)):Qd(el,n.stateNode));break;case 4:r=el,i=tl,el=n.stateNode.containerInfo,tl=!0,nl(e,t,n),el=r,tl=i;break;case 0:case 11:case 14:case 15:Pc(2,n,t),qc||Pc(4,n,t),nl(e,t,n);break;case 1:qc||(Rc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Ic(n,t,r)),nl(e,t,n);break;case 21:nl(e,t,n);break;case 22:qc=(r=qc)||n.memoizedState!==null,nl(e,t,n),qc=r;break;default:nl(e,t,n)}}function il(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Np(e)}catch(e){Hu(t,t.return,e)}}}function al(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Np(e)}catch(e){Hu(t,t.return,e)}}function ol(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Yc),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Yc),t;default:throw Error(i(435,e.tag))}}function sl(e,t){var n=ol(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=qu.bind(null,e,t);t.then(r,r)}})}function cl(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(Zd(c.type)){el=c.stateNode,tl=!1;break a}break;case 5:el=c.stateNode,tl=!1;break a;case 3:case 4:el=c.stateNode.containerInfo,tl=!0;break a}c=c.return}if(el===null)throw Error(i(160));rl(o,s,a),el=null,tl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)ul(t,e),t=t.sibling}var ll=null;function ul(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:cl(t,e),dl(e),r&4&&(Pc(3,e,e.return),Nc(3,e),Pc(5,e,e.return));break;case 1:cl(t,e),dl(e),r&512&&(qc||n===null||Rc(n,n.return)),r&64&&Kc&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=ll;if(cl(t,e),dl(e),r&512&&(qc||n===null||Rc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[q]||o[Qe]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Pd(o,r,n),o[Qe]=e,J(o),r=o;break a;case`link`:var s=Vf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Pd(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Vf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Pd(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[Qe]=e,J(o),r=o}e.stateNode=r}else Hf(a,e.type,e.stateNode);else e.stateNode=If(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&Bc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Hf(a,e.type,e.stateNode):If(a,r,e.memoizedProps))}break;case 27:cl(t,e),dl(e),r&512&&(qc||n===null||Rc(n,n.return)),n!==null&&r&4&&Bc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(cl(t,e),dl(e),r&512&&(qc||n===null||Rc(n,n.return)),e.flags&32){a=e.stateNode;try{Ft(a,``)}catch(t){Hu(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,Bc(e,a,n===null?a:n.memoizedProps)),r&1024&&(Jc=!0);break;case 6:if(cl(t,e),dl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Hu(e,e.return,t)}}break;case 3:if(Bf=null,a=ll,ll=gf(t.containerInfo),cl(t,e),ll=a,dl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Np(t.containerInfo)}catch(t){Hu(e,e.return,t)}Jc&&(Jc=!1,fl(e));break;case 4:r=ll,ll=gf(e.stateNode.containerInfo),cl(t,e),dl(e),ll=r;break;case 12:cl(t,e),dl(e);break;case 31:cl(t,e),dl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,sl(e,r)));break;case 13:cl(t,e),dl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Xl=ve()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,sl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=Kc,d=qc;if(Kc=u||a,qc=d||l,cl(t,e),qc=d,Kc=u,dl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||Kc||qc||ml(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Hu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Hu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?$d(m,!0):$d(l.stateNode,!1)}catch(e){Hu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,sl(e,n))));break;case 19:cl(t,e),dl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,sl(e,r)));break;case 30:break;case 21:break;default:cl(t,e),dl(e)}}function dl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Vc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;Wc(e,Hc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Ft(o,``),n.flags&=-33),Wc(e,Hc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Uc(e,Hc(e),s);break;default:throw Error(i(161))}}catch(t){Hu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function fl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;fl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function pl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Qc(e,t.alternate,t),t=t.sibling}function ml(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Pc(4,t,t.return),ml(t);break;case 1:Rc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Ic(t,t.return,n),ml(t);break;case 27:pf(t.stateNode);case 26:case 5:Rc(t,t.return),ml(t);break;case 22:t.memoizedState===null&&ml(t);break;case 30:ml(t);break;default:ml(t)}e=e.sibling}}function hl(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:hl(i,a,n),Nc(4,a);break;case 1:if(hl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Hu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Ra(c[i],s)}catch(e){Hu(r,r.return,e)}}n&&o&64&&Fc(a),Lc(a,a.return);break;case 27:Gc(a);case 26:case 5:hl(i,a,n),n&&r===null&&o&4&&zc(a),Lc(a,a.return);break;case 12:hl(i,a,n);break;case 31:hl(i,a,n),n&&o&4&&il(i,a);break;case 13:hl(i,a,n),n&&o&4&&al(i,a);break;case 22:a.memoizedState===null&&hl(i,a,n),Lc(a,a.return);break;case 30:break;default:hl(i,a,n)}t=t.sibling}}function gl(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Zi(n))}function _l(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Zi(e))}function vl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)yl(e,t,n,r),t=t.sibling}function yl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:vl(e,t,n,r),i&2048&&Nc(9,t);break;case 1:vl(e,t,n,r);break;case 3:vl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Zi(e)));break;case 12:if(i&2048){vl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Hu(t,t.return,e)}}else vl(e,t,n,r);break;case 31:vl(e,t,n,r);break;case 13:vl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?vl(e,t,n,r):(a._visibility|=2,bl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?vl(e,t,n,r):xl(e,t),i&2048&&gl(o,t);break;case 24:vl(e,t,n,r),i&2048&&_l(t.alternate,t);break;default:vl(e,t,n,r)}}function bl(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:bl(a,o,s,c,i),Nc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,bl(a,o,s,c,i)):u._visibility&2?bl(a,o,s,c,i):xl(a,o),i&&l&2048&&gl(o.alternate,o);break;case 24:bl(a,o,s,c,i),i&&l&2048&&_l(o.alternate,o);break;default:bl(a,o,s,c,i)}t=t.sibling}}function xl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:xl(n,r),i&2048&&gl(r.alternate,r);break;case 24:xl(n,r),i&2048&&_l(r.alternate,r);break;default:xl(n,r)}t=t.sibling}}var Sl=8192;function Cl(e,t,n){if(e.subtreeFlags&Sl)for(e=e.child;e!==null;)wl(e,t,n),e=e.sibling}function wl(e,t,n){switch(e.tag){case 26:Cl(e,t,n),e.flags&Sl&&e.memoizedState!==null&&Gf(n,ll,e.memoizedState,e.memoizedProps);break;case 5:Cl(e,t,n);break;case 3:case 4:var r=ll;ll=gf(e.stateNode.containerInfo),Cl(e,t,n),ll=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Sl,Sl=16777216,Cl(e,t,n),Sl=r):Cl(e,t,n));break;default:Cl(e,t,n)}}function Tl(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function El(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Xc=r,kl(r,e)}Tl(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Dl(e),e=e.sibling}function Dl(e){switch(e.tag){case 0:case 11:case 15:El(e),e.flags&2048&&Pc(9,e,e.return);break;case 3:El(e);break;case 12:El(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Ol(e)):El(e);break;default:El(e)}}function Ol(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Xc=r,kl(r,e)}Tl(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Pc(8,t,t.return),Ol(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Ol(t));break;default:Ol(t)}e=e.sibling}}function kl(e,t){for(;Xc!==null;){var n=Xc;switch(n.tag){case 0:case 11:case 15:Pc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Zi(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,Xc=r;else a:for(n=e;Xc!==null;){r=Xc;var i=r.sibling,a=r.return;if($c(r),r===n){Xc=null;break a}if(i!==null){i.return=a,Xc=i;break a}Xc=a}}}var Al={getCacheForType:function(e){var t=Ui(Yi),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Ui(Yi).controller.signal}},jl=typeof WeakMap==`function`?WeakMap:Map,Ml=0,Nl=null,$=null,Pl=0,Fl=0,Il=null,Ll=!1,Rl=!1,zl=!1,Bl=0,Vl=0,Hl=0,Ul=0,Wl=0,Gl=0,Kl=0,ql=null,Jl=null,Yl=!1,Xl=0,Zl=0,Ql=1/0,$l=null,eu=null,tu=0,nu=null,ru=null,iu=0,au=0,ou=null,su=null,cu=0,lu=null;function uu(){return Ml&2&&Pl!==0?Pl&-Pl:I.T===null?Ye():ld()}function du(){if(Gl===0)if(!(Pl&536870912)||Z){var e=Fe;Fe<<=1,!(Fe&3932160)&&(Fe=262144),Gl=e}else Gl=536870912;return e=Ga.current,e!==null&&(e.flags|=32),Gl}function fu(e,t,n){(e===Nl&&(Fl===2||Fl===9)||e.cancelPendingCommit!==null)&&(yu(e,0),gu(e,Pl,Gl,!1)),He(e,n),(!(Ml&2)||e!==Nl)&&(e===Nl&&(!(Ml&2)&&(Ul|=n),Vl===4&&gu(e,Pl,Gl,!1)),td(e))}function pu(e,t,n){if(Ml&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||ze(e,t),a=r?Du(e,t):Tu(e,t,!0),o=r;do{if(a===0){Rl&&!r&&gu(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!hu(n)){a=Tu(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=ql;var l=c.current.memoizedState.isDehydrated;if(l&&(yu(c,s).flags|=256),s=Tu(c,s,!1),s!==2){if(zl&&!l){c.errorRecoveryDisabledLanes|=o,Ul|=o,a=4;break a}o=Jl,Jl=a,o!==null&&(Jl===null?Jl=o:Jl.push.apply(Jl,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){yu(e,0),gu(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:gu(r,t,Gl,!Ll);break a;case 2:Jl=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=Xl+300-ve(),10<a)){if(gu(r,t,Gl,!Ll),Re(r,0,!0)!==0)break a;iu=t,r.timeoutHandle=Kd(mu.bind(null,r,n,Jl,$l,Yl,t,Gl,Ul,Kl,Ll,o,`Throttled`,-0,0),a);break a}mu(r,n,Jl,$l,Yl,t,Gl,Ul,Kl,Ll,o,null,-0,0)}}break}while(1);td(e)}function mu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Ut},wl(t,a,d);var m=(a&62914560)===a?Xl-ve():(a&4194048)===a?Zl-ve():0;if(m=qf(d,m),m!==null){iu=a,e.cancelPendingCommit=m(Pu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),gu(e,a,o,!l);return}}Pu(e,t,a,n,r,i,o,s,c)}function hu(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!ur(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function gu(e,t,n,r){t&=~Wl,t&=~Ul,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Ae(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&We(e,n,t)}function _u(){return Ml&6?!0:(nd(0,!1),!1)}function vu(){if($!==null){if(Fl===0)var e=$.return;else e=$,Fi=Pi=null,yo(e),ba=null,xa=0,e=$;for(;e!==null;)Mc(e.alternate,e),e=e.return;$=null}}function yu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,qd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),iu=0,vu(),Nl=e,$=n=Qr(e.current,null),Pl=t,Fl=0,Il=null,Ll=!1,Rl=ze(e,t),zl=!1,Kl=Gl=Wl=Ul=Hl=Vl=0,Jl=ql=null,Yl=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Ae(r),a=1<<i;t|=e[i],r&=~a}return Bl=t,Hr(),n}function bu(e,t){Q=null,I.H=ks,t===ua||t===fa?(t=va(),Fl=3):t===da?(t=va(),Fl=4):Fl=t===qs?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Il=t,$===null&&(Vl=1,Vs(e,oi(t,e.current)))}function xu(){var e=Ga.current;return e===null?!0:(Pl&4194048)===Pl?Ka===null:(Pl&62914560)===Pl||Pl&536870912?e===Ka:!1}function Su(){var e=I.H;return I.H=ks,e===null?ks:e}function Cu(){var e=I.A;return I.A=Al,e}function wu(){Vl=4,Ll||(Pl&4194048)!==Pl&&Ga.current!==null||(Rl=!0),!(Hl&134217727)&&!(Ul&134217727)||Nl===null||gu(Nl,Pl,Gl,!1)}function Tu(e,t,n){var r=Ml;Ml|=2;var i=Su(),a=Cu();(Nl!==e||Pl!==t)&&($l=null,yu(e,t)),t=!1;var o=Vl;a:do try{if(Fl!==0&&$!==null){var s=$,c=Il;switch(Fl){case 8:vu(),o=6;break a;case 3:case 2:case 9:case 6:Ga.current===null&&(t=!0);var l=Fl;if(Fl=0,Il=null,ju(e,s,c,l),n&&Rl){o=0;break a}break;default:l=Fl,Fl=0,Il=null,ju(e,s,c,l)}}Eu(),o=Vl;break}catch(t){bu(e,t)}while(1);return t&&e.shellSuspendCounter++,Fi=Pi=null,Ml=r,I.H=i,I.A=a,$===null&&(Nl=null,Pl=0,Hr()),o}function Eu(){for(;$!==null;)ku($)}function Du(e,t){var n=Ml;Ml|=2;var r=Su(),a=Cu();Nl!==e||Pl!==t?($l=null,Ql=ve()+500,yu(e,t)):Rl=ze(e,t);a:do try{if(Fl!==0&&$!==null){t=$;var o=Il;b:switch(Fl){case 1:Fl=0,Il=null,ju(e,t,o,1);break;case 2:case 9:if(ma(o)){Fl=0,Il=null,Au(t);break}t=function(){Fl!==2&&Fl!==9||Nl!==e||(Fl=7),td(e)},o.then(t,t);break a;case 3:Fl=7;break a;case 4:Fl=5;break a;case 7:ma(o)?(Fl=0,Il=null,Au(t)):(Fl=0,Il=null,ju(e,t,o,7));break;case 5:var s=null;switch($.tag){case 26:s=$.memoizedState;case 5:case 27:var c=$;if(s?Wf(s):c.stateNode.complete){Fl=0,Il=null;var l=c.sibling;if(l!==null)$=l;else{var u=c.return;u===null?$=null:($=u,Mu(u))}break b}}Fl=0,Il=null,ju(e,t,o,5);break;case 6:Fl=0,Il=null,ju(e,t,o,6);break;case 8:vu(),Vl=6;break a;default:throw Error(i(462))}}Ou();break}catch(t){bu(e,t)}while(1);return Fi=Pi=null,I.H=r,I.A=a,Ml=n,$===null?(Nl=null,Pl=0,Hr(),Vl):0}function Ou(){for(;$!==null&&!ge();)ku($)}function ku(e){var t=Cc(e.alternate,e,Bl);e.memoizedProps=e.pendingProps,t===null?Mu(e):$=t}function Au(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=sc(n,t,t.pendingProps,t.type,void 0,Pl);break;case 11:t=sc(n,t,t.pendingProps,t.type.render,t.ref,Pl);break;case 5:yo(t);default:Mc(n,t),t=$=$r(t,Bl),t=Cc(n,t,Bl)}e.memoizedProps=e.pendingProps,t===null?Mu(e):$=t}function ju(e,t,n,r){Fi=Pi=null,yo(t),ba=null,xa=0;var i=t.return;try{if(Ks(e,i,t,n,Pl)){Vl=1,Vs(e,oi(n,e.current)),$=null;return}}catch(t){if(i!==null)throw $=i,t;Vl=1,Vs(e,oi(n,e.current)),$=null;return}t.flags&32768?(Z||r===1?e=!0:Rl||Pl&536870912?e=!1:(Ll=e=!0,(r===2||r===9||r===3||r===6)&&(r=Ga.current,r!==null&&r.tag===13&&(r.flags|=16384))),Nu(t,e)):Mu(t)}function Mu(e){var t=e;do{if(t.flags&32768){Nu(t,Ll);return}e=t.return;var n=Ac(t.alternate,t,Bl);if(n!==null){$=n;return}if(t=t.sibling,t!==null){$=t;return}$=t=e}while(t!==null);Vl===0&&(Vl=5)}function Nu(e,t){do{var n=jc(e.alternate,e);if(n!==null){n.flags&=32767,$=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){$=e;return}$=e=n}while(e!==null);Vl=6,$=null}function Pu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do zu();while(tu!==0);if(Ml&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=Vr,Ue(e,n,o,s,c,l),e===Nl&&($=Nl=null,Pl=0),ru=t,nu=e,iu=n,au=o,ou=a,su=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Ju(Se,function(){return Bu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=I.T,I.T=null,a=L.p,L.p=2,s=Ml,Ml|=4;try{Zc(e,t,n)}finally{Ml=s,L.p=a,I.T=r}}tu=1,Fu(),Iu(),Lu()}}function Fu(){if(tu===1){tu=0;var e=nu,t=ru,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=I.T,I.T=null;var r=L.p;L.p=2;var i=Ml;Ml|=4;try{ul(t,e);var a=zd,o=hr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&mr(s.ownerDocument.documentElement,s)){if(c!==null&&gr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=pr(s,h),v=pr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}sp=!!Rd,zd=Rd=null}finally{Ml=i,L.p=r,I.T=n}}e.current=t,tu=2}}function Iu(){if(tu===2){tu=0;var e=nu,t=ru,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=I.T,I.T=null;var r=L.p;L.p=2;var i=Ml;Ml|=4;try{Qc(e,t.alternate,t)}finally{Ml=i,L.p=r,I.T=n}}tu=3}}function Lu(){if(tu===4||tu===3){tu=0,_e();var e=nu,t=ru,n=iu,r=su;t.subtreeFlags&10256||t.flags&10256?tu=5:(tu=0,ru=nu=null,Ru(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(eu=null),Je(n),t=t.stateNode,Oe&&typeof Oe.onCommitFiberRoot==`function`)try{Oe.onCommitFiberRoot(De,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=I.T,i=L.p,L.p=2,I.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{I.T=t,L.p=i}}iu&3&&zu(),td(e),i=e.pendingLanes,n&261930&&i&42?e===lu?cu++:(cu=0,lu=e):cu=0,nd(0,!1)}}function Ru(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Zi(t)))}function zu(){return Fu(),Iu(),Lu(),Bu()}function Bu(){if(tu!==5)return!1;var e=nu,t=au;au=0;var n=Je(iu),r=I.T,a=L.p;try{L.p=32>n?32:n,I.T=null,n=ou,ou=null;var o=nu,s=iu;if(tu=0,ru=nu=null,iu=0,Ml&6)throw Error(i(331));var c=Ml;if(Ml|=4,Dl(o.current),yl(o,o.current,s,n),Ml=c,nd(0,!1),Oe&&typeof Oe.onPostCommitFiberRoot==`function`)try{Oe.onPostCommitFiberRoot(De,o)}catch{}return!0}finally{L.p=a,I.T=r,Ru(e,t)}}function Vu(e,t,n){t=oi(n,t),t=Us(e.stateNode,t,2),e=Ma(e,t,2),e!==null&&(He(e,2),td(e))}function Hu(e,t,n){if(e.tag===3)Vu(e,e,n);else for(;t!==null;){if(t.tag===3){Vu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(eu===null||!eu.has(r))){e=oi(n,e),n=Ws(2),r=Ma(t,n,2),r!==null&&(Gs(n,r,t,e),He(r,2),td(r));break}}t=t.return}}function Uu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new jl;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(zl=!0,i.add(n),e=Wu.bind(null,e,t,n),t.then(e,e))}function Wu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Nl===e&&(Pl&n)===n&&(Vl===4||Vl===3&&(Pl&62914560)===Pl&&300>ve()-Xl?!(Ml&2)&&yu(e,0):Wl|=n,Kl===Pl&&(Kl=0)),td(e)}function Gu(e,t){t===0&&(t=Ve()),e=Gr(e,t),e!==null&&(He(e,t),td(e))}function Ku(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Gu(e,n)}function qu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Gu(e,n)}function Ju(e,t){return me(e,t)}var Yu=null,Xu=null,Zu=!1,Qu=!1,$u=!1,ed=0;function td(e){e!==Xu&&e.next===null&&(Xu===null?Yu=Xu=e:Xu=Xu.next=e),Qu=!0,Zu||(Zu=!0,cd())}function nd(e,t){if(!$u&&Qu){$u=!0;do for(var n=!1,r=Yu;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Ae(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,sd(r,a))}else a=Pl,a=Re(r,r===Nl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||ze(r,a)||(n=!0,sd(r,a));r=r.next}while(n);$u=!1}}function rd(){id()}function id(){Qu=Zu=!1;var e=0;ed!==0&&Gd()&&(e=ed);for(var t=ve(),n=null,r=Yu;r!==null;){var i=r.next,a=ad(r,t);a===0?(r.next=null,n===null?Yu=i:n.next=i,i===null&&(Xu=n)):(n=r,(e!==0||a&3)&&(Qu=!0)),r=i}tu!==0&&tu!==5||nd(e,!1),ed!==0&&(ed=0)}function ad(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Ae(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Be(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Nl,n=Pl,n=Re(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Fl===2||Fl===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&he(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||ze(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&he(r),Je(n)){case 2:case 8:n=xe;break;case 32:n=Se;break;case 268435456:n=we;break;default:n=Se}return r=od.bind(null,e),n=me(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&he(r),e.callbackPriority=2,e.callbackNode=null,2}function od(e,t){if(tu!==0&&tu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(zu()&&e.callbackNode!==n)return null;var r=Pl;return r=Re(e,e===Nl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(pu(e,r,t),ad(e,ve()),e.callbackNode!=null&&e.callbackNode===n?od.bind(null,e):null)}function sd(e,t){if(zu())return null;pu(e,t,!0)}function cd(){Yd(function(){Ml&6?me(be,rd):id()})}function ld(){if(ed===0){var e=ea;e===0&&(e=Pe,Pe<<=1,!(Pe&261888)&&(Pe=256)),ed=e}return ed}function ud(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Ht(``+e)}function dd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function fd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=ud((i[$e]||null).action),o=r.submitter;o&&(t=(t=o[$e]||null)?ud(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new ln(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(ed!==0){var e=o?dd(i,o):new FormData(i);hs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?dd(i,o):new FormData(i),hs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var pd=0;pd<Ir.length;pd++){var md=Ir[pd];Lr(md.toLowerCase(),`on`+(md[0].toUpperCase()+md.slice(1)))}Lr(Or,`onAnimationEnd`),Lr(kr,`onAnimationIteration`),Lr(Ar,`onAnimationStart`),Lr(`dblclick`,`onDoubleClick`),Lr(`focusin`,`onFocus`),Lr(`focusout`,`onBlur`),Lr(jr,`onTransitionRun`),Lr(Mr,`onTransitionStart`),Lr(Nr,`onTransitionCancel`),Lr(Pr,`onTransitionEnd`),pt(`onMouseEnter`,[`mouseout`,`mouseover`]),pt(`onMouseLeave`,[`mouseout`,`mouseover`]),pt(`onPointerEnter`,[`pointerout`,`pointerover`]),pt(`onPointerLeave`,[`pointerout`,`pointerover`]),ft(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),ft(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),ft(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),ft(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),ft(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),ft(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var hd=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),gd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(hd));function _d(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Rr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Rr(e)}i.currentTarget=null,a=c}}}}function vd(e,t){var n=t[tt];n===void 0&&(n=t[tt]=new Set);var r=e+`__bubble`;n.has(r)||(Sd(t,e,2,!1),n.add(r))}function yd(e,t,n){var r=0;t&&(r|=4),Sd(n,e,r,t)}var bd=`_reactListening`+Math.random().toString(36).slice(2);function xd(e){if(!e[bd]){e[bd]=!0,ut.forEach(function(t){t!==`selectionchange`&&(gd.has(t)||yd(t,!1,e),yd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[bd]||(t[bd]=!0,yd(`selectionchange`,!1,t))}}function Sd(e,t,n,r){switch(mp(t)){case 2:var i=cp;break;case 8:i=lp;break;default:i=up}n=i.bind(null,t,n,e),i=void 0,!$t||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Cd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=ot(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}Xt(function(){var r=a,i=Gt(n),s=[];a:{var c=Fr.get(e);if(c!==void 0){var l=ln,u=e;switch(e){case`keypress`:if(on(n)===0)break a;case`keydown`:case`keyup`:l=Dn;break;case`focusin`:u=`focus`,l=vn;break;case`focusout`:u=`blur`,l=vn;break;case`beforeblur`:case`afterblur`:l=vn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=gn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=_n;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=kn;break;case Or:case kr:case Ar:l=yn;break;case Pr:l=An;break;case`scroll`:case`scrollend`:l=dn;break;case`wheel`:l=jn;break;case`copy`:case`cut`:case`paste`:l=bn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=On;break;case`toggle`:case`beforetoggle`:l=Mn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=Zt(m,p),g!=null&&d.push(wd(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==Wt&&(u=n.relatedTarget||n.fromElement)&&(ot(u)||u[et]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?ot(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=gn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=On,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:ct(l),h=u==null?c:ct(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,ot(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Ed,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Dd(s,c,l,d,!1),u!==null&&f!==null&&Dd(s,f,u,d,!0)}}a:{if(c=r?ct(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=Qn;else if(Kn(c))if($n)v=cr;else{v=or;var y=ar}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&zt(r.elementType)&&(v=Qn):v=sr;if(v&&=v(e,r)){qn(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&jt(c,`number`,c.value)}switch(y=r?ct(r):window,e){case`focusin`:(Kn(y)||y.contentEditable===`true`)&&(vr=y,yr=r,br=null);break;case`focusout`:br=yr=vr=null;break;case`mousedown`:xr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:xr=!1,Sr(s,n,i);break;case`selectionchange`:if(_r)break;case`keydown`:case`keyup`:Sr(s,n,i)}var b;if(Pn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else Hn?Bn(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Ln&&n.locale!==`ko`&&(Hn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Hn&&(b=an()):(tn=i,nn=`value`in tn?tn.value:tn.textContent,Hn=!0)),y=Td(r,x),0<y.length&&(x=new xn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=Vn(n),b!==null&&(x.data=b)))),(b=In?Un(e,n):Wn(e,n))&&(x=Td(r,`onBeforeInput`),0<x.length&&(y=new xn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),fd(s,e,r,n,i)}_d(s,t)})}function wd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Td(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=Zt(e,n),i!=null&&r.unshift(wd(e,i,a)),i=Zt(e,t),i!=null&&r.push(wd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Ed(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Dd(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=Zt(n,a),l!=null&&o.unshift(wd(n,l,c))):i||(l=Zt(n,a),l!=null&&o.push(wd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Od=/\r\n?/g,kd=/\u0000|\uFFFD/g;function Ad(e){return(typeof e==`string`?e:``+e).replace(Od,`
9
+ `).replace(kd,``)}function jd(e,t){return t=Ad(t),Ad(e)===t}function Md(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Ft(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Ft(e,``+r);break;case`className`:yt(e,`class`,r);break;case`tabIndex`:yt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:yt(e,n,r);break;case`style`:Rt(e,r,o);break;case`data`:if(t!==`object`){yt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Ht(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Md(e,t,`name`,a.name,a,null),Md(e,t,`formEncType`,a.formEncType,a,null),Md(e,t,`formMethod`,a.formMethod,a,null),Md(e,t,`formTarget`,a.formTarget,a,null)):(Md(e,t,`encType`,a.encType,a,null),Md(e,t,`method`,a.method,a,null),Md(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Ht(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Ut);break;case`onScroll`:r!=null&&vd(`scroll`,e);break;case`onScrollEnd`:r!=null&&vd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Ht(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:vd(`beforetoggle`,e),vd(`toggle`,e),vt(e,`popover`,r);break;case`xlinkActuate`:bt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:bt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:bt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:bt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:bt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:bt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:bt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:bt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:bt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:vt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Bt.get(n)||n,vt(e,n,r))}}function Nd(e,t,n,r,a,o){switch(n){case`style`:Rt(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Ft(e,r):(typeof r==`number`||typeof r==`bigint`)&&Ft(e,``+r);break;case`onScroll`:r!=null&&vd(`scroll`,e);break;case`onScrollEnd`:r!=null&&vd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Ut);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!dt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[$e]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):vt(e,n,r)}}}function Pd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:vd(`error`,e),vd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Md(e,t,o,s,n,null)}}a&&Md(e,t,`srcSet`,n.srcSet,n,null),r&&Md(e,t,`src`,n.src,n,null);return;case`input`:vd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Md(e,t,r,d,n,null)}}At(e,o,c,l,u,s,a,!1);return;case`select`:for(a in vd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Md(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&Mt(e,!!r,n,!0):Mt(e,!!r,t,!1);return;case`textarea`:for(s in vd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Md(e,t,s,c,n,null)}Pt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Md(e,t,l,r,n,null)}return;case`dialog`:vd(`beforetoggle`,e),vd(`toggle`,e),vd(`cancel`,e),vd(`close`,e);break;case`iframe`:case`object`:vd(`load`,e);break;case`video`:case`audio`:for(r=0;r<hd.length;r++)vd(hd[r],e);break;case`image`:vd(`error`,e),vd(`load`,e);break;case`details`:vd(`toggle`,e);break;case`embed`:case`source`:case`link`:vd(`error`,e),vd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Md(e,t,u,r,n,null)}return;default:if(zt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Nd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Md(e,t,c,r,n,null))}function Fd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Md(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Md(e,t,p,m,r,f)}}kt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Md(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Md(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Mt(e,!!n,n?[]:``,!1):Mt(e,!!n,t,!0)):Mt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Md(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Md(e,t,s,a,r,o)}Nt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Md(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Md(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Md(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Md(e,t,u,p,r,m)}return;default:if(zt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Nd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Nd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Md(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Md(e,t,f,p,r,m)}function Id(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Ld(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Id(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Rd=null,zd=null;function Bd(e){return e.nodeType===9?e:e.ownerDocument}function Vd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Hd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Ud(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Wd=null;function Gd(){var e=window.event;return e&&e.type===`popstate`?e===Wd?!1:(Wd=e,!0):(Wd=null,!1)}var Kd=typeof setTimeout==`function`?setTimeout:void 0,qd=typeof clearTimeout==`function`?clearTimeout:void 0,Jd=typeof Promise==`function`?Promise:void 0,Yd=typeof queueMicrotask==`function`?queueMicrotask:Jd===void 0?Kd:function(e){return Jd.resolve(null).then(e).catch(Xd)};function Xd(e){setTimeout(function(){throw e})}function Zd(e){return e===`head`}function Qd(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Np(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)pf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,pf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[q]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&pf(e.ownerDocument.body);n=i}while(n);Np(t)}function $d(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function ef(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:ef(n),at(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function tf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[q])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=cf(e.nextSibling),e===null)break}return null}function nf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=cf(e.nextSibling),e===null))return null;return e}function rf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=cf(e.nextSibling),e===null))return null;return e}function af(e){return e.data===`$?`||e.data===`$~`}function of(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function sf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function cf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var lf=null;function uf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return cf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function df(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function ff(e,t,n){switch(t=Bd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function pf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);at(e)}var mf=new Map,hf=new Set;function gf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var _f=L.d;L.d={f:vf,r:yf,D:Sf,C:Cf,L:wf,m:Tf,X:Df,S:Ef,M:Of};function vf(){var e=_f.f(),t=_u();return e||t}function yf(e){var t=st(e);t!==null&&t.tag===5&&t.type===`form`?_s(t):_f.r(e)}var bf=typeof document>`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Ot(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),J(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Ot(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Ot(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Ot(n.imageSizes)+`"]`)):i+=`[href="`+Ot(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=h({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),J(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Ot(r)+`"][href="`+Ot(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=h({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),J(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=lt(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=h({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);J(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=lt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),J(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=lt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),J(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var a=(a=te.current)?gf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=lt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var o=lt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),o||Nf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=lt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Af(e){return`href="`+Ot(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),J(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Ot(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Ot(n.href)+`"]`);if(r)return t.instance=r,J(r),r;var a=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),J(r),Pd(r,`style`,a),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Af(n.href);var o=e.querySelector(jf(a));if(o)return t.state.loading|=4,t.instance=o,J(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),J(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(o,`link`,r),t.state.loading|=4,Lf(o,n.precedence,e),t.instance=o;case`script`:return o=Pf(n.src),(a=e.querySelector(Ff(o)))?(t.instance=a,J(a),a):(r=n,(a=mf.get(o))&&(r=h({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),J(a),Pd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Rf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function zf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Bf=null;function Vf(e,t,n){if(Bf===null){var r=new Map,i=Bf=new Map;i.set(n,r)}else i=Bf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[q]||a[Qe]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Hf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,J(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),J(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Kf===0&&(Kf=62500*Ld());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Jf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var Qf={$$typeof:C,Provider:null,Consumer:null,_currentValue:R,_currentValue2:R,_threadCount:0};function $f(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=K(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=K(0),this.hiddenUpdates=K(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function ep(e,t,n,r,i,a,o,s,c,l,u,d){return e=new $f(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Xr(3,null,null,t),e.current=a,a.stateNode=e,t=Xi(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},ka(a),e}function tp(e){return e?(e=Jr,e):Jr}function np(e,t,n,r,i,a){i=tp(i),r.context===null?r.context=i:r.pendingContext=i,r=ja(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Ma(e,r,t),n!==null&&(fu(n,e,t),Na(n,e,t))}function rp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ip(e,t){rp(e,t),(e=e.alternate)&&rp(e,t)}function ap(e){if(e.tag===13||e.tag===31){var t=Gr(e,67108864);t!==null&&fu(t,e,67108864),ip(e,67108864)}}function op(e){if(e.tag===13||e.tag===31){var t=uu();t=qe(t);var n=Gr(e,t);n!==null&&fu(n,e,t),ip(e,t)}}var sp=!0;function cp(e,t,n,r){var i=I.T;I.T=null;var a=L.p;try{L.p=2,up(e,t,n,r)}finally{L.p=a,I.T=i}}function lp(e,t,n,r){var i=I.T;I.T=null;var a=L.p;try{L.p=8,up(e,t,n,r)}finally{L.p=a,I.T=i}}function up(e,t,n,r){if(sp){var i=dp(r);if(i===null)Cd(e,t,r,fp,n),Cp(e,r);else if(Tp(i,e,t,n,r))r.stopPropagation();else if(Cp(e,r),t&4&&-1<Sp.indexOf(e)){for(;i!==null;){var a=st(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Le(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Ae(o);s.entanglements[1]|=c,o&=~c}td(a),!(Ml&6)&&(Ql=ve()+500,nd(0,!1))}}break;case 31:case 13:s=Gr(a,2),s!==null&&fu(s,a,2),_u(),ip(a,2)}if(a=dp(r),a===null&&Cd(e,t,r,fp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Cd(e,t,r,null,n)}}function dp(e){return e=Gt(e),pp(e)}var fp=null;function pp(e){if(fp=null,e=ot(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return fp=e,null}function mp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(ye()){case be:return 2;case xe:return 8;case Se:case Ce:return 32;case we:return 268435456;default:return 32}default:return 32}}var hp=!1,gp=null,_p=null,vp=null,yp=new Map,bp=new Map,xp=[],Sp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Cp(e,t){switch(e){case`focusin`:case`focusout`:gp=null;break;case`dragenter`:case`dragleave`:_p=null;break;case`mouseover`:case`mouseout`:vp=null;break;case`pointerover`:case`pointerout`:yp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:bp.delete(t.pointerId)}}function wp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=st(t),t!==null&&ap(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Tp(e,t,n,r,i){switch(t){case`focusin`:return gp=wp(gp,e,t,n,r,i),!0;case`dragenter`:return _p=wp(_p,e,t,n,r,i),!0;case`mouseover`:return vp=wp(vp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return yp.set(a,wp(yp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,bp.set(a,wp(bp.get(a)||null,e,t,n,r,i)),!0}return!1}function Ep(e){var t=ot(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,Xe(e.priority,function(){op(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,Xe(e.priority,function(){op(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Dp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=dp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Wt=r,n.target.dispatchEvent(r),Wt=null}else return t=st(n),t!==null&&ap(t),e.blockedOn=n,!1;t.shift()}return!0}function Op(e,t,n){Dp(e)&&n.delete(t)}function kp(){hp=!1,gp!==null&&Dp(gp)&&(gp=null),_p!==null&&Dp(_p)&&(_p=null),vp!==null&&Dp(vp)&&(vp=null),yp.forEach(Op),bp.forEach(Op)}function Ap(e,n){e.blockedOn===n&&(e.blockedOn=null,hp||(hp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,kp)))}var jp=null;function Mp(e){jp!==e&&(jp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){jp===e&&(jp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(pp(r||n)===null)continue;break}var a=st(n);a!==null&&(e.splice(t,3),t-=3,hs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Np(e){function t(t){return Ap(t,e)}gp!==null&&Ap(gp,e),_p!==null&&Ap(_p,e),vp!==null&&Ap(vp,e),yp.forEach(t),bp.forEach(t);for(var n=0;n<xp.length;n++){var r=xp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<xp.length&&(n=xp[0],n.blockedOn===null);)Ep(n),n.blockedOn===null&&xp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[$e]||null;if(typeof a==`function`)o||Mp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[$e]||null)s=o.formAction;else if(pp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Mp(n)}}}function Pp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Fp(e){this._internalRoot=e}Ip.prototype.render=Fp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;np(n,uu(),e,t,null,null)},Ip.prototype.unmount=Fp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;np(e.current,2,null,e,null,null),_u(),t[et]=null}};function Ip(e){this._internalRoot=e}Ip.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ye();e={blockedOn:null,target:e,priority:t};for(var n=0;n<xp.length&&t!==0&&t<xp[n].priority;n++);xp.splice(n,0,e),n===0&&Ep(e)}};var Lp=n.version;if(Lp!==`19.2.7`)throw Error(i(527,Lp,`19.2.7`));L.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=d(t),e=e===null?null:p(e),e=e===null?null:e.stateNode,e};var Rp={bundleType:0,version:`19.2.7`,rendererPackageName:`react-dom`,currentDispatcherRef:I,reconcilerVersion:`19.2.7`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var zp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zp.isDisabled&&zp.supportsFiber)try{De=zp.inject(Rp),Oe=zp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Rs,s=zs,c=Bs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=ep(e,1,!1,null,null,n,r,null,o,s,c,Pp),e[et]=t.current,xd(e),new Fp(t)}})),g=c(o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h()}))(),1),_=c(u(),1),v=new Map,y={data:void 0,error:void 0,loading:!1,refreshing:!1,hasSucceeded:!1,lastAttemptOk:!1};function b(e){let t=v.get(e);return t||(t={snapshot:{data:void 0,error:void 0,loading:!1,refreshing:!1,hasSucceeded:!1,lastAttemptOk:!1},listeners:new Set,pollByListener:new Map,pauseWhenHiddenByListener:new Map,fetcherByListener:new Map,subscriberCount:0,pollTimer:null,pollIntervalMs:void 0,inflight:null,inflightOwner:null,visibilityListener:null,generation:0,seedNeedsRevalidate:!1},v.set(e,t)),t}function x(e){for(let t of e.listeners)t()}function S(e){e.pollTimer!==null&&(clearInterval(e.pollTimer),e.pollTimer=null),e.pollIntervalMs=void 0}function C(){return typeof document<`u`&&document.visibilityState===`hidden`}function w(e){if(!C())return T(e);for(let[t,n]of e.pollByListener)if(!(typeof n!=`number`||n<=0)&&e.pauseWhenHiddenByListener.get(t)===!1){let n=e.fetcherByListener.get(t);if(n)return{owner:t,fetcher:n}}return null}function T(e){for(let[t,n]of e.pollByListener)if(typeof n==`number`&&n>0){let n=e.fetcherByListener.get(t);if(n)return{owner:t,fetcher:n}}for(let[t,n]of e.fetcherByListener)return{owner:t,fetcher:n};return null}function E(e){let t;for(let n of e.pollByListener.values())typeof n==`number`&&n>0&&(t=t===void 0?n:Math.min(t,n));if(!(t===e.pollIntervalMs&&(t===void 0||e.pollTimer!==null))){if(S(e),e.pollIntervalMs=t,t===void 0){O(e);return}e.pollTimer=setInterval(()=>{let t=w(e);t&&k(e,t.fetcher,{replaceInflight:!1,owner:t.owner})},t),D(e)}}function D(e){if(typeof document>`u`||e.visibilityListener)return;let t=()=>{if(C()||e.pollIntervalMs===void 0)return;let t=T(e);t&&k(e,t.fetcher,{replaceInflight:!1,owner:t.owner})};document.addEventListener(`visibilitychange`,t),e.visibilityListener=t}function O(e){e.visibilityListener&&=(typeof document<`u`&&document.removeEventListener(`visibilitychange`,e.visibilityListener),null)}async function k(e,t,n){let r=n?.replaceInflight!==!1;if(e.inflight&&!r)return;r&&e.inflight?.abort();let i=new AbortController;e.inflight=i,e.inflightOwner=n?.owner??null;let a=++e.generation,o=e.snapshot.data===void 0||n?.forceLoading===!0;e.snapshot={...e.snapshot,loading:o?!0:e.snapshot.loading,refreshing:!0},x(e);try{let n=await t(i.signal);if(a!==e.generation||i.signal.aborted)return;e.seedNeedsRevalidate=!1,e.snapshot={data:n,error:void 0,loading:!1,refreshing:!1,hasSucceeded:!0,lastAttemptOk:!0}}catch(t){if(a!==e.generation||i.signal.aborted)return;e.seedNeedsRevalidate=!1,e.snapshot={...e.snapshot,error:t===void 0?Error(`resource load failed`):t,loading:!1,refreshing:!1,lastAttemptOk:!1}}finally{e.inflight===i&&(e.inflight=null,e.inflightOwner=null),x(e)}}function A(e,t){return e.inflightOwner===t?(e.inflight?.abort(),e.inflight=null,e.inflightOwner=null,e.generation++,e.snapshot.refreshing&&(e.snapshot={...e.snapshot,refreshing:!1},x(e)),!0):!1}function j(e,t){S(t),O(t),setTimeout(()=>{t.subscriberCount===0&&v.get(e)===t&&(t.inflight?.abort(),t.inflight=null,t.inflightOwner=null,v.delete(e))},0)}function M(e,t,n,r,i=!0){let a=b(e);return a.listeners.add(r),a.pollByListener.set(r,n),a.pauseWhenHiddenByListener.set(r,i),a.fetcherByListener.set(r,t),a.subscriberCount++,a.subscriberCount===1&&(a.snapshot.data===void 0||a.seedNeedsRevalidate)&&k(a,t,{replaceInflight:!0,owner:r}),E(a),()=>{a.listeners.delete(r),a.pollByListener.delete(r),a.pauseWhenHiddenByListener.delete(r),a.fetcherByListener.delete(r),a.subscriberCount--;let t=A(a,r);if(a.subscriberCount===0){j(e,a);return}if(t){let e=T(a);e&&k(a,e.fetcher,{replaceInflight:!0,owner:e.owner})}E(a)}}function N(e,t){let n=b(e);n.subscriberCount!==0||n.snapshot.data!==void 0||L(e,t)}function P(e,t,n){let r=n?.enabled!==!1,i=n?.pollMs,a=n?.pauseWhenHidden!==!1;r&&n?.initialData!==void 0&&N(e,n.initialData);let o=(0,_.useRef)(t);(0,_.useLayoutEffect)(()=>{o.current=t});let s=(0,_.useCallback)(e=>o.current(e),[]),c=(0,_.useRef)(null),l=(0,_.useCallback)(t=>r?(c.current=t,M(e,s,i,t,a)):()=>{},[e,s,i,r,a]),u=(0,_.useCallback)(()=>r?b(e).snapshot:y,[e,r]),d=(0,_.useSyncExternalStore)(l,u,u),f=(0,_.useCallback)(t=>{r&&k(b(e),s,{replaceInflight:!0,owner:c.current,forceLoading:t?.forceLoading})},[e,s,r]);return{...d,refresh:f}}function F(e,t){if(e===null)return!1;if(e.length!==t.length)return!0;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!0;return!1}function I(e,t,n,r){let i=P(e,n,r),a=(0,_.useRef)(null),o=(0,_.useRef)(null);return(0,_.useLayoutEffect)(()=>{let n=a.current,r=o.current;a.current=t,o.current=e,F(n,t)&&(r!==null&&r!==e||i.refresh({forceLoading:!0}))}),i}function L(e,t){let n=b(e);n.inflight?.abort(),n.inflight=null,n.inflightOwner=null,n.generation++,n.snapshot={data:t,error:void 0,loading:!1,refreshing:!1,hasSucceeded:!0,lastAttemptOk:!0},n.seedNeedsRevalidate=n.subscriberCount===0,x(n)}var R=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),z=o(((e,t)=>{t.exports=R()}))(),B=e=>({viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,...e}),V=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,z.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,z.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1.5`}),(0,z.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1.5`})]}),H=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`7`,rx:`2`}),(0,z.jsx)(`rect`,{x:`3`,y:`13`,width:`18`,height:`7`,rx:`2`}),(0,z.jsx)(`path`,{d:`M7 7.5h.01M7 16.5h.01`})]}),U=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`path`,{d:`M12 2 4 6v6l8 4 8-4V6l-8-4Z`}),(0,z.jsx)(`path`,{d:`m4 6 8 4 8-4M12 10v8`})]}),W=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`rect`,{x:`4`,y:`8`,width:`16`,height:`11`,rx:`3`}),(0,z.jsx)(`path`,{d:`M12 8V4M8 2h8`}),(0,z.jsx)(`circle`,{cx:`9`,cy:`13`,r:`1`}),(0,z.jsx)(`circle`,{cx:`15`,cy:`13`,r:`1`})]}),ee=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01`})}),te=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M4 6h16M4 12h16M4 18h16`})}),ne=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`path`,{d:`m4 17 6-5-6-5`}),(0,z.jsx)(`path`,{d:`M12 19h8`})]}),re=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M22 12h-4l-3 9L9 3l-3 9H2`})}),G=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`path`,{d:`M22 12H2`}),(0,z.jsx)(`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11Z`}),(0,z.jsx)(`path`,{d:`M6 16h.01M10 16h.01`})]}),ie=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`m20 6-11 11-5-5`})}),ae=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})}),oe=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M12 5v14M5 12h14`})}),se=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M21 12a9 9 0 0 1-9 9 9.8 9.8 0 0 1-6.7-2.7L3 16M3 21v-5h5M3 12a9 9 0 0 1 9-9 9.8 9.8 0 0 1 6.7 2.7L21 8M21 3v5h-5`})}),ce=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M8 5v14M16 5v14`})}),le=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`m7 4 13 8-13 8Z`})}),ue=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6`})}),de=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`path`,{d:`M10.3 3.7 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.7a2 2 0 0 0-3.4 0Z`}),(0,z.jsx)(`path`,{d:`M12 9v4M12 17h.01`})]}),fe=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,z.jsx)(`path`,{d:`M12 16v-4M12 8h.01`})]}),pe=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,z.jsx)(`path`,{d:`m21 21-4.3-4.3`})]}),me=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M12 19V5M5 12l7-7 7 7`})}),he=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M12 5v14M19 12l-7 7-7-7`})}),ge=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3`})}),_e=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`m9 18 6-6-6-6`})}),ve=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M9 19c-5 1.5-5-2.5-7-3m14 6v-3.9a3.4 3.4 0 0 0-.9-2.6c3-.3 6.2-1.5 6.2-6.7A5.2 5.2 0 0 0 20 4.8 4.9 4.9 0 0 0 19.9 1S18.7.6 16 2.5a13.4 13.4 0 0 0-7 0C6.3.6 5.1 1 5.1 1A4.9 4.9 0 0 0 5 4.8a5.2 5.2 0 0 0-1.4 3.7c0 5.1 3.1 6.4 6.1 6.7a3.4 3.4 0 0 0-.9 2.5V22`})}),ye=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`path`,{d:`M18.4 5.6a9 9 0 1 1-12.8 0`}),(0,z.jsx)(`path`,{d:`M12 2v10`})]}),be=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M15 3h6v6M10 14 21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`})}),xe=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`circle`,{cx:`7.5`,cy:`15.5`,r:`4.5`}),(0,z.jsx)(`path`,{d:`m10.7 12.3 9.6-9.6M16 7l3 3M14 9l2 2`})]}),Se=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`rect`,{x:`4`,y:`11`,width:`16`,height:`10`,rx:`2`}),(0,z.jsx)(`path`,{d:`M8 11V7a4 4 0 0 1 8 0v4`})]}),Ce=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`}),(0,z.jsx)(`path`,{d:`M13 5v2`}),(0,z.jsx)(`path`,{d:`M13 17v2`}),(0,z.jsx)(`path`,{d:`M13 11v2`})]}),we=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2M15 7h2a5 5 0 0 1 0 10h-2M8 12h8`})}),Te=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,z.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}),Ee=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M21 12.8A9 9 0 1 1 11.2 3 7 7 0 0 0 21 12.8Z`})}),De=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`}),(0,z.jsx)(`path`,{d:`M8 21h8M12 17v4`})]}),Oe=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,z.jsx)(`path`,{d:`M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18`})]}),ke=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M12 3v18M5.6 5.6l12.8 12.8M3 12h18M5.6 18.4 18.4 5.6`})}),Ae=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`path`,{d:`m18 14 4 4-4 4`}),(0,z.jsx)(`path`,{d:`m18 2 4 4-4 4`}),(0,z.jsx)(`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`}),(0,z.jsx)(`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`}),(0,z.jsx)(`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`})]}),je=e=>(0,z.jsxs)(`svg`,{...B(e),children:[(0,z.jsx)(`circle`,{cx:`9`,cy:`6`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,z.jsx)(`circle`,{cx:`15`,cy:`6`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,z.jsx)(`circle`,{cx:`9`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,z.jsx)(`circle`,{cx:`15`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,z.jsx)(`circle`,{cx:`9`,cy:`18`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,z.jsx)(`circle`,{cx:`15`,cy:`18`,r:`1`,fill:`currentColor`,stroke:`none`})]}),Me=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`m12 2 3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z`})}),Ne=e=>(0,z.jsx)(`svg`,{...B(e),children:(0,z.jsx)(`path`,{d:`M4 5h16l-6 7v5l-4 2v-7L4 5z`})}),Pe={"nav.dashboard":`Dashboard`,"nav.startup":`Startup`,"nav.providers":`Providers`,"nav.models":`Models`,"nav.combos":`Combos`,"nav.subagents":`Subagents`,"nav.logs":`Logs & Debug`,"nav.usage":`Usage`,"common.github":`GitHub`,"sidebar.star":`Star on GitHub`,"sidebar.starred":`Starred on GitHub`,"sidebar.starUnauthenticated":`Open GitHub to star (gh CLI is not signed in)`,"sidebar.starFailed":`Could not star through gh. Opening GitHub instead.`,"sidebar.updateAvailable":`Update available: {version}`,"sidebar.checkUpdate":`Check for updates`,"common.save":`Save`,"common.saving":`Saving…`,"common.cancel":`Cancel`,"common.discard":`Discard`,"common.close":`Close`,"common.ok":`OK`,"common.remove":`Remove`,"common.loading":`Loading…`,"common.retry":`Retry`,"app.logoAria":`opencodex logo`,"app.claudeOn":`Claude ON`,"app.claudeOff":`Claude OFF`,"theme.label":`Theme`,"theme.light":`Light`,"theme.dark":`Dark`,"theme.system":`System`,"lang.label":`Language`,"provider.name.volcengine":`Volcengine Ark`,"provider.name.volcengineCodingPlan":`Volcengine Ark Coding Plan`,"provider.name.volcengineAgentPlan":`Volcengine Ark Agent Plan`,"errorBoundary.title":`Page failed to load`,"errorBoundary.message":`This section hit a rendering error. Reload it to try again.`,"errorBoundary.details":`Error`,"errorBoundary.reload":`Reload`,"startup.title":`Startup safety`,"startup.subtitle":`Verify that Codex can reach opencodex after a restart, before local proxy routing becomes a reconnect loop.`,"startup.refresh":`Refresh`,"startup.backToDashboard":`Back to Dashboard`,"startup.loading":`Checking startup protection…`,"startup.error":`Could not read startup protection.`,"startup.staleData":`The latest startup check failed. The values below are stale and must not be treated as proof of protection.`,"startup.status.native":`Native routing`,"startup.status.protected":`Restart protected`,"startup.status.atRisk":`Action required`,"startup.summary.native":`Codex does not depend on the local proxy`,"startup.summary.protected":`opencodex will be available after restart`,"startup.summary.atRisk":`Codex can lose model access after restart`,"startup.riskDetail":`Codex is pinned to the local proxy, but no persistent service or healthy launcher shim will start it again.`,"startup.riskDetailCustomLocal":`Codex points to a custom local gateway. opencodex cannot manage or verify that gateway's restart lifecycle.`,"startup.riskDetailWindowsShim":`The launcher shim protects supported CLI scripts, but Codex Desktop and direct codex.exe launches can bypass it on Windows.`,"startup.safeDetail":`The current routing and startup mechanism are consistent. No manual ocx start should be required after restart.`,"startup.routing":`Codex routing`,"startup.routing.proxy":`Local proxy`,"startup.routing.native":`Native OpenAI`,"startup.routing.customLocal":`Custom local gateway`,"startup.routing.customRemote":`Custom remote gateway`,"startup.routing.unknown":`Unknown or invalid routing`,"startup.restartProtection":`Restart protection`,"startup.preference":`On-demand startup`,"startup.enabled":`Enabled`,"startup.disabled":`Disabled`,"startup.protection.service":`Background service`,"startup.protection.shim":`Launcher shim`,"startup.protection.none":`Not installed`,"startup.details":`Protection details`,"startup.service":`Background service`,"startup.serviceHint":`Starts at login and restarts the proxy after a crash.`,"startup.installed":`Installed`,"startup.notInstalled":`Not installed`,"startup.unsupported":`Unsupported`,"startup.shim":`Codex launcher shim`,"startup.shimHint":`Runs ocx ensure when a supported Codex script launcher starts.`,"startup.healthy":`Healthy`,"startup.cliOnly":`CLI only`,"startup.stale":`Stale`,"startup.viable":`Ready`,"startup.unhealthy":`Installed but unhealthy`,"startup.conflict":`Service conflict`,"startup.installedDisabled":`Installed but disabled`,"startup.install":`Install`,"startup.installing":`Installing…`,"startup.repair":`Repair`,"startup.repairing":`Repairing…`,"startup.serviceInstalled":`Background service installed successfully.`,"startup.serviceRepaired":`Background service repaired successfully.`,"startup.shimInstalled":`Codex launcher shim installed successfully.`,"startup.shimRepaired":`Codex launcher shim repaired successfully.`,"startup.installFailed":`Installation failed:`,"startup.tray.title":`Windows system tray`,"startup.tray.hint":`Install a login tray icon for one-click proxy start, stop, restart, dashboard, and status controls.`,"startup.tray.login":`Start tray at Windows login`,"startup.tray.notProtection":`The tray is a controller, not restart protection. A viable background service is still required for unattended proxy recovery.`,"startup.tray.running":`Running`,"startup.tray.stopped":`Installed, hidden`,"startup.tray.stale":`Repair required`,"startup.tray.notInstalled":`Not installed`,"startup.tray.loading":`Checking…`,"startup.tray.unavailable":`Status unavailable`,"startup.tray.install":`Install and show tray`,"startup.tray.start":`Show tray icon`,"startup.tray.stop":`Exit tray icon`,"startup.tray.uninstall":`Remove login tray`,"startup.tray.error":`The Windows tray action failed. Check ocx tray status for details.`,"startup.recovery":`Repair options`,"startup.recoveryHint":`Use the one-click installers above, or copy a command for manual repair. The background service is recommended for Codex Desktop and Windows executables.`,"startup.command.service":`Recommended: persistent background service`,"startup.command.shim":`Alternative: CLI launcher shim`,"startup.command.native":`Fail-safe: restore native Codex routing`,"startup.copy":`Copy`,"startup.copied":`Copied`,"startup.recommended":`Recommended repair: {cmd}`,"startup.navRisk":`Startup protection requires attention`,"startup.codexRuntime.clampHidden":`Some reasoning effort options were hidden because OpenCodex used Codex {version}.`,"startup.codexRuntime.clampHiddenWithEfforts":`Some reasoning effort options were hidden because OpenCodex used Codex {version} (removed: {efforts}).`,"startup.codexRuntime.olderBinary":`OpenCodex is using an older Codex binary ({version}). A newer installation is available.`,"dash.subtitle":`Live status of the local opencodex proxy, its providers, and the models routed into Codex.`,"dash.workspace.overview":`Overview`,"dash.workspace.sections":`Sections`,"dash.status":`Status`,"dash.online":`Online`,"dash.offline":`Offline`,"dash.version":`Version`,"dash.uptime":`Uptime`,"dash.providers":`Providers`,"dash.tokens30d":`Tokens (30d)`,"dash.coverage":`{pct} coverage`,"dash.mem.title":`Memory observability`,"dash.mem.hint":`Read-only runtime diagnostics. Observed memory is max(RSS, external, ArrayBuffers) so Windows working-set trimming does not hide committed retention.`,"dash.mem.rss":`Resident set (RSS)`,"dash.mem.jsHeap":`JS heap in use`,"dash.mem.jsHeapArena":`arena {total}`,"dash.mem.pressure":`Against warn threshold`,"dash.mem.pressureOf":`{pct}% of threshold`,"dash.mem.pressureUnknown":`No threshold reported`,"dash.mem.jscHeap":`JSC heap`,"dash.mem.external":`External`,"dash.mem.arrayBuffers":`ArrayBuffers`,"dash.mem.observed":`Observed`,"dash.mem.runtime":`Runtime counters`,"dash.mem.growth":`Observed drift / hour`,"dash.mem.perHour":`/h`,"dash.mem.store":`Continuation store`,"dash.mem.storeHint":`Proxy previous_response_id cache. Rising total bytes under a rising heap points at conversation retention rather than the runtime allocator.`,"dash.mem.storeEntries":`Entries`,"dash.mem.storeTotal":`Total`,"dash.mem.storeLargest":`Largest`,"dash.mem.storeOldest":`Oldest`,"dash.mem.threshold":`Warn threshold`,"dash.mem.lastWarn":`Last warning`,"dash.mem.never":`Never`,"dash.mem.details":`Details`,"dash.mem.unavailable":`Memory diagnostics unavailable (older proxy).`,"dash.mem.inFlight":`In-flight requests`,"dash.mem.restart":`Drain & restart`,"dash.mem.restartConfirm":`Wait for {count} in-flight request(s), then restart (up to {seconds}s; remaining requests are cut on timeout).`,"dash.mem.draining":`Draining {count} request(s)… restarting when complete`,"dash.mem.reconnecting":`Proxy restarting… waiting to reconnect`,"dash.mem.restartFailed":`Drain & restart failed. Check that the proxy is running.`,"dash.mem.restartNoSupervisor":`No restart protection detected. The proxy may stay down after restart unless you start it again.`,"dash.activeProviders":`Active providers`,"dash.noProviders":`No providers configured. Run {cmd}.`,"dash.col.name":`Name`,"dash.col.adapter":`Adapter`,"dash.col.baseUrl":`Base URL`,"dash.col.model":`Model`,"dash.modelsNoResults":`No models match your search.`,"dash.availableModels":`Available models`,"dash.noModels":`No models found. Check provider API keys.`,"dash.cannotConnect":`Cannot connect to proxy. Is it running?`,"dash.runStart":`Run {cmd} to start the proxy.`,"dash.stop":`Stop Proxy`,"dash.stopConfirm":`Stop the proxy and restore native Codex?`,"dash.stopFailed":`Failed to stop proxy (HTTP {status}).`,"dash.stopping":`Stopping…`,"dash.codexAutoStart":`Start opencodex with Codex`,"dash.codexAutoStartHint":`Allows an installed launcher shim to run ocx ensure. This setting does not install restart protection; check Startup safety for the effective state.`,"dash.searchModel":`Search sidecar model`,"dash.searchModelHint":`Model used for web_search on non-OpenAI routed models. Requires ChatGPT login.`,"dash.searchReasoning":`Search reasoning effort`,"dash.visionModel":`Vision sidecar model`,"dash.visionModelHint":`Model used to describe images for text-only routed models. Requires ChatGPT login.`,"dash.webSearchSidecar":`Web search sidecar`,"dash.webSearchSidecarHint":`Choose the backend and model used for web search on routed models.`,"dash.visionSidecar":`Vision sidecar`,"dash.visionSidecarHint":`Choose the backend and model used to describe images for text-only routed models.`,"dash.shadowCallIntercept":`Shadow Call Intercept`,"dash.shadowCallInterceptHint":`Intercepts Codex App's background helper calls ({models}) for title generation and commit messages and redirects them to your chosen model. Effort is fixed to low.`,"dash.shadowCallWarning":`⚠ When enabled, ALL requests for {models} will be replaced with the selected model.`,"dash.shadowCallOriginal":`Original`,"dash.shadowCallModel":`Replacement model`,"dash.shadowCallTooltip":`Codex App makes background helper calls for thread title generation, commit message generation, and skill orchestration. The helper model changed across client versions, so opencodex intercepts every model in this set: {models}. Enable this to redirect those calls to your chosen model.`,"models.shadowCallIntercept":`Shadow Call Intercept`,"models.shadowCallInterceptHint":`Intercepts Codex App's background helper calls ({models}) for titles and commit messages and redirects them to your chosen model.`,"dash.sidecarBackend":`Backend`,"dash.sidecarModel":`Model`,"dash.backendAuto":`Auto`,"dash.backendOpenAI":`OpenAI`,"dash.backendAnthropic":`Anthropic`,"dash.sidecarSaved":`Sidecar settings saved. Applied on the next request.`,"dash.sidecarSaveFailed":`Failed to save sidecar settings.`,"dash.injectionLabel":`Sub-agent delegation`,"dash.injectionHint":`Pick the model Codex should hand sub-agent work to. The two switches below decide where that pick is used.`,"dash.injectionManage":`Open settings`,"dash.syncCodexSubagentDefaults":`Also save as a Codex default`,"dash.syncCodexSubagentDefaultsHint":`On, the pick above is written into Codex's own config, so new tasks start with that model too. Off, it is remembered only here. It takes effect on the next sync or restart, and your hand-written [agents] settings are left alone.`,"dash.multiAgentGuidance":`Tell Codex how to split work`,"dash.multiAgentGuidanceHint":`Sends a short note telling Codex how to hand work to sub-agents. On v2 it names the models it may use and which to prefer; on v1 it only applies at max or ultra reasoning effort. Off, no note is added.`,"dash.injectionNone":`None`,"dash.injectionEffortLabel":`Reasoning effort`,"dash.injectionEffortNone":`Model default`,"dash.effortCapLabel":`V2 ultra effort limit`,"dash.subagentEffortCapLabel":`V2 sub-agent effort limit`,"dash.effortCapHelp":`Limits the reasoning effort for V2 ultra-mode turns. When set, incoming max-effort requests (from ultra mode) are capped to the selected level. The sub-agent limit applies only to spawned child agents. Caps only lower effort, never raise it. If a model doesn't support the capped level, it snaps down to the nearest supported level.`,"dash.effortCapNone":`No cap`,"dash.maintenance":`Maintenance`,"dash.maintenanceHint":`Refresh Codex's model catalog or install a newer opencodex release.`,"dash.syncModels":`Sync models`,"dash.syncModelsHint":`Rewrite Codex's model catalog from the providers you have connected.`,"dash.syncRun":`Sync now`,"dash.syncing":`Syncing…`,"dash.syncOk":`Sync complete. {count} model(s) appended.`,"dash.syncStaleHint":`If Codex still shows an older list, restart its long-lived app-server ({cmd}).`,"dash.syncFailed":`Sync failed: {error}`,"dash.projectConfigTitle":`Project Codex config bypasses OpenCodex`,"dash.projectConfigHint":`These repo-local settings override the OpenCodex proxy (e.g. route to OpenCode Go directly). Remove them so ~/.codex/config.toml routing applies in that project.`,"dash.checkUpdate":`Check update`,"dash.updateTitle":`Update opencodex`,"dash.updateDesc":`Check npm for the selected channel, then choose whether to restart the proxy after installation.`,"dash.updateChannel":`Channel`,"dash.updateChecking":`Checking for updates…`,"dash.updateInstalled":`Installed`,"dash.updateLatest":`Latest`,"dash.updateAvailable":`Update available`,"dash.updateCurrent":`Up to date`,"dash.updateCommand":`Command`,"dash.updateSource":`This is a source checkout. Update it from the terminal with the shown command.`,"dash.updateUnavailable":`Could not read the latest version from npm. Try again later.`,"dash.updateRetry":`Retry`,"dash.updateRecheck":`Re-check`,"dash.updateCannotAuto":`One-click update is unavailable ({reason}).`,"dash.updateReason.source_checkout":`source checkout`,"dash.updateReason.latest_unavailable":`npm registry unreachable`,"dash.updateReason.already_latest":`already on latest`,"dash.updateReason.unknown":`update unavailable`,"dash.updateRestart":`Restart after update`,"dash.updateRestartHint":`Recommended. The current GUI keeps running the old code until the proxy restarts.`,"dash.runUpdate":`Update`,"dash.updateReconnecting":`Waiting for the restarted proxy…`,"dash.updateStatus.running":`Updating opencodex.`,"dash.updateStatus.restarting":`Update installed. Restarting proxy.`,"dash.updateStatus.succeeded":`Update finished.`,"dash.updateStatus.failed":`Update failed.`,"prov.subtitle":`Configure the upstream providers opencodex routes into Codex. Log in with an account, add a provider, or edit the raw config.`,"prov.add":`Add Provider`,"prov.editJson":`Edit JSON`,"prov.accountLogin":`Account login`,"prov.noOauth":`No OAuth providers available.`,"prov.loggedIn":`logged in`,"prov.notLoggedIn":`not logged in`,"prov.logout":`Logout`,"prov.login":`Login`,"prov.loginWith":`Login with {provider}`,"prov.waitingBrowser":`Waiting for browser…`,"prov.didntOpen":`Didn't open? Click here`,"prov.copyLink":`Copy link`,"prov.linkCopied":`Copied`,"prov.linkCopyUnavailable":`Clipboard unavailable`,"prov.deviceCode":`Device code`,"prov.copyCode":`Copy code`,"prov.codeCopied":`Code copied`,"prov.editAlias":`Edit alias`,"prov.aliasPrompt":`Display name (leave empty to clear)`,"prov.aliasSaved":`Alias saved`,"prov.aliasSaveFailed":`Could not save alias`,"prov.accountId":`ID`,"prov.pasteRedirect":`Paste redirect URL or code`,"prov.pasteRedirectHint":`If the browser shows a localhost error, copy the full URL from its address bar and paste it here (or paste the authorization code).`,"prov.pasteSubmit":`Submit`,"prov.pasteSubmitting":`Submitting…`,"prov.pasteOk":`Code submitted — finishing login…`,"prov.pasteFail":`Could not submit code: {error}`,"prov.port":`Port`,"prov.default":`Default`,"prov.loadingConfig":`Loading…`,"prov.saved":`Saved! Restart proxy to apply.`,"prov.loadConfigFail":`Failed to load config`,"prov.invalidJson":`Invalid JSON`,"prov.saveFailed":`Save failed`,"prov.loginFailStart":`{provider} login failed to start`,"prov.loginError":`{provider} login error: {error}`,"prov.loginRequestFail":`{provider} login request failed`,"prov.loginCancelled":`{provider} login cancelled`,"prov.loginTimeout":`{provider} login timed out — browser closed or never finished. Try again.`,"prov.loginOk":`Logged in to {provider}. Run {cmd} (or it applies live) to list its models.`,"oauthTos.highTitle":`{provider}: subscription OAuth risk`,"oauthTos.elevatedTitle":`{provider}: unofficial OAuth bridge`,"oauthTos.anthropicBody":`Directly reusing Claude subscription OAuth tokens through a third-party proxy such as OpenCodex is not a supported Anthropic integration and may lead to access restrictions. Supported Agent SDK integrations that use Claude subscriptions are separate.`,"oauthTos.highBody":`OpenCodex connects {provider} through a third-party OAuth path. Unsupported use may lead to access limits or suspension.`,"oauthTos.elevatedBody":`OpenCodex connects {provider} through an unofficial OAuth path. Use the official client when possible; unusual or automated traffic may be treated as abuse and access may be limited or suspended.`,"oauthTos.saferPath":`Safer option: configure an API key in OpenCodex instead.`,"oauthTos.acknowledge":`I understand the risk and want to continue with OAuth anyway.`,"oauthTos.continue":`Continue with OAuth`,"prov.logoutOk":`Logged out of {provider}.`,"prov.logoutFail":`Could not log out of {provider}. Your account state is unchanged.`,"prov.removed":`Removed "{name}".`,"prov.removedDefault":`Removed "{name}". Default provider is now "{defaultProvider}".`,"prov.removeFail":`Failed to remove "{name}".`,"prov.removeLastProvider":`You can't remove this provider when no other enabled provider can become the default.`,"prov.removeHasDependentCombos":`Remove or update these dependent combos first: {combos}.`,"prov.setDefault":`Set as default`,"prov.setDefaultSuccess":`"{name}" is now the default provider.`,"prov.setDefaultFail":`Couldn't set "{name}" as the default provider.`,"prov.defaultDisabled":`Enable this provider before making it the default.`,"prov.updateFail":`Couldn't update this provider.`,"prov.networkError":`Network error. Check that the proxy is running and try again.`,"prov.added":`Added "{name}". Live now — run {cmd} (or restart) to list its models in Codex's picker.`,"prov.removeConfirm":`Remove provider "{name}"? Its models disappear from Codex's picker.`,"prov.hasApiKey":`api key configured`,"prov.hasHeaders":`custom headers configured`,"prov.accounts":`Accounts ({n})`,"prov.accountsAria":`Toggle {name} accounts`,"prov.accountActive":`Active`,"prov.accountReauth":`Re-login`,"prov.reauthenticate":`Re-authenticate`,"prov.reauthAccountMissing":`Selected account was not found after login`,"prov.reauthIdentityMismatch":`Signed-in account did not match the selected account`,"prov.accountAdd":`Add account`,"prov.accountNoLabel":`account {id}`,"prov.accountSwitchTitle":`Use this account`,"prov.accountSwitched":`Switched to {email}.`,"prov.accountSwitchFail":`Failed to switch account`,"prov.accountRemoved":`Removed {email}.`,"prov.accountRemoveFail":`Could not remove {email}. The account is unchanged.`,"prov.accountRemoveAria":`Remove {email}`,"prov.accountRemoveConfirm":`Remove account {email}? Its login is deleted from this proxy.`,"prov.keyAdd":`Add API key`,"prov.keyAdded":`Added API key to {name}.`,"prov.keyAddFail":`Failed to add API key`,"prov.keyPlaceholder":`Paste API key`,"prov.keySwitchTitle":`Use this key`,"prov.keySwitched":`Switched to key {key}.`,"prov.keySwitchFail":`Failed to switch key`,"prov.keyRemoved":`Removed key {key}.`,"prov.keyRemoveAria":`Remove key {key}`,"prov.keyRemoveConfirm":`Remove API key {key}? It is deleted from this proxy's config.`,"prov.activeBadge":`Active`,"prov.disabledBadge":`Disabled`,"prov.defaultBadge":`Default`,"prov.enable":`Enable`,"prov.disable":`Disable`,"prov.enabled":`Enabled "{name}". Its models can appear in Codex again.`,"prov.disabled":`Disabled "{name}". Settings are kept, but its models are hidden.`,"prov.enableFail":`Failed to enable "{name}".`,"prov.disableFail":`Failed to disable "{name}".`,"prov.enableAria":`Enable provider {name}`,"prov.disableAria":`Disable provider {name}`,"prov.defaultCannotDisable":`Default provider can't be disabled`,"prov.openaiAccountMode":`Codex account mode`,"prov.openaiModePool":`Pool`,"prov.openaiModeDirect":`Direct`,"prov.openaiPoolDesc":`Default. Rotate the main login and added accounts using affinity, quota, cooldown, and failover.`,"prov.openaiDirectDesc":`Use only the current/main Codex login. Stored pool accounts are not read or rotated.`,"prov.openaiModeSaved":`OpenAI account mode changed to {mode}.`,"prov.openaiModeSaveFailed":`Could not change the OpenAI account mode.`,"prov.openaiApiDesc":`Uses an OpenAI API key and never uses Codex account credentials.`,"prov.manageCodexAccounts":`Manage Codex accounts`,"prov.openaiApiMissing":`API key required`,"prov.openaiApiSetup":`Set up API key`,"models.subtitle":`Toggle which models Codex sees — native GPT passthrough and routed providers, grouped by provider (click a header to collapse). Hidden models stay off the catalog + model picker but remain directly callable by exact id. Changes apply on the next Codex turn — opencodex invalidates Codex's 5-min model cache so no restart is needed.`,"models.nativeGroupLabel":`OpenAI native`,"models.nativeHint":`Passthrough models use the Pool or Direct account option selected on Providers. Toggling one off hides it from the Codex picker (the catalog entry is kept, so re-enabling restores it exactly).`,"models.active":`{active}/{total} visible`,"models.workspace.providers":`Providers`,"models.workspace.allProviders":`All providers`,"models.workspace.mainAria":`Model details`,"models.combosEmpty":`No combos configured yet`,"models.combosSetup":`Set up`,"models.combosAdd":`Add combo`,"models.combosActive":`{count} active`,"models.allOn":`All on`,"models.allOff":`All off`,"models.cap350k":`Cap 350k`,"models.capApplied":`Context cap applied — takes effect on the next Codex turn.`,"models.capSaveFailed":`Failed to save context cap`,"models.contextCapped":`350k cap`,"models.contextCapLabel":`Context cap`,"models.v2Label":`Sub-agent`,"models.shadowCallOriginal":`⚠ {models} →`,"models.v2DocsLink":`What is v1 / v2?`,"models.v2Mode_v1":`v1`,"models.v2Mode_default":`base`,"models.v2Mode_v2":`v2`,"models.v2ModeDesc_v1":`All models → v1 surface`,"models.v2ModeDesc_default":`Upstream defaults (sol/terra=v2, luna=v1)`,"models.v2ModeDesc_v2":`All models → v2 surface`,"models.v2Help":`Controls the multi-agent surface for all models.
10
10
 
11
11
  v1: Classic single-thread agent. Every model uses the v1 collab surface.
12
12
  base: Upstream defaults — sol/terra use v2, luna uses v1, others follow the codex feature flag.
@@ -44,7 +44,7 @@ v2: spawn_agent を備えたマルチスレッドエージェント。すべて
44
44
 
45
45
  変更は新規セッションに適用されます。`,"dash.multiAgent":`サブエージェント`,"models.v2Conflict":`[agents] max_threads が設定されています — codex は起動を拒否します; config.toml から削除してください`,"models.v2Applied":`サブエージェントモードを更新しました — 新規セッションに適用(ピッカーを更新するには Codex アプリを再起動)`,"models.v2ThreadsLabel":`最大スレッド数`,"models.v2ThreadsDefault":`デフォルト (4)`,"models.v2ThreadsApplied":`スレッド上限を更新しました — 新規セッションに適用`,"models.v2ThreadsInvalid":`スレッド上限は 1 以上の整数にしてください`,"models.v2ThreadsApply":`適用`,"models.capValue":`上限 {value}`,"models.contextCappedValue":`{value} 上限`,"models.setAll":`すべて設定`,"models.setAllHint":`{value} のコンテキスト上限をすべてのルーティング済みプロバイダーに適用します。ネイティブプロバイダーには影響しません。`,"models.collapseAll":`すべて折りたたむ`,"models.expandAll":`すべて展開`,"models.orderHint":`ピッカーの順序: サブエージェントの選択(選択順) → 残りのルーティングモデルはプロバイダー別、次にモデル ID 別のアルファベット順 → ネイティブモデル。表示切り替えはモデルをフィルタするだけで、この順序は変更しません。`,"models.custom":`カスタム…`,"models.customApply":`適用`,"models.customPlaceholder":`トークン (例: 420000)`,"models.applied":`適用しました — 次回の Codex ターンで有効になります。`,"models.saveFailed":`保存に失敗しました`,"models.networkError":`ネットワークエラー — プロキシは起動していますか?`,"models.loadFail":`モデルの読み込みに失敗しました — プロキシは起動していますか?`,"models.noRouted":`ルーティングモデルがありません`,"models.noRoutedHint":`まずプロバイダーにログインするか追加してください。`,"models.emptyDiscovery":`モデルが見つかりませんでした。プロバイダーのエンドポイントを確認するか、静的/カスタムモデルを追加してください。`,"models.emptyDiscoveryDisabled":`ライブモデル検出がオフで、静的モデルも設定されていません。`,"models.discoveryFailedBadge":`検出に失敗`,"models.discoveryFailedHttp":`モデル検出に失敗しました(HTTP {status})。`,"models.discoveryFailedBlocked":`モデル検出は宛先ポリシーによりブロックされました。`,"models.discoveryFailedInvalidResponse":`モデル検出が無効な応答を返しました。`,"models.discoveryFailedNetwork":`ネットワークエラーによりモデル検出に失敗しました。`,"models.discoveryFailedProvider":`プロバイダーがモデル検出エラーを報告しました。`,"models.discoveryFailedGeneric":`モデル検出に失敗しました。`,"models.openProviderSettings":`プロバイダー設定を開く`,"models.loading":`読み込み中…`,"models.search":`モデルを検索…`,"models.showMore":`さらに {n} 件表示`,"models.allowlistLabel":`選択のみ`,"models.allowlistHint":`チェックしたモデルのみカタログに送信します(空 = すべて)。数千のモデルを公開するプロバイダーで有用です。`,"models.selectedCount":`{n} 件選択`,"sub.subtitle":`Codex の {cmd} は最初の 5 モデル(優先度順)のみをオーバーライドとして通知します。ここで最大 5 つを選んでください — ネイティブ gpt またはルーティング — opencodex がカタログ優先度を設定し、これらが先頭に来るようにします。他のモデルも正確な名前で呼び出し可能です; これは表示のみを制御します。`,"sub.featured":`おすすめ`,"sub.orderHint":`ここでの表示順が Codex モデルピッカーの上位 1〜5 番目の位置と {cmd} のデフォルトモデル候補を決定します。`,"sub.noneSelected":`未選択 — 以下のリストから選んでください。`,"sub.models":`モデル`,"sub.search":`モデルを検索(ネイティブ gpt + ルーティング)…`,"sub.noModels":`モデルがありません — まずプロバイダーにログインするか追加してください。`,"sub.saved":`{n} 件のモデルを保存しました。新規 Codex セッションを開始(または {cmd} を実行)して spawn_agent オーバーライドとして確認してください。`,"sub.saveFailed":`保存に失敗しました`,"sub.networkError":`ネットワークエラー — プロキシは起動していますか?`,"sub.loadFail":`モデルの読み込みに失敗しました — プロキシは起動していますか?`,"sub.loading":`読み込み中…`,"sub.moveUp":`{m} を上へ移動`,"sub.moveDown":`{m} を下へ移動`,"sub.removeAria":`{m} を削除`,"sub.workspace.addToFeatured":`{m} をおすすめに追加`,"sub.workspace.allModels":`すべてのモデル`,"sub.workspace.featuredFull":`おすすめリストがいっぱいです(最大 5)`,"sub.workspace.mainAria":`サブエージェントのモデル詳細`,"sub.workspace.notFeatured":`おすすめ未設定`,"sub.workspace.priority":`優先度`,"sub.workspace.removeFromFeatured":`{m} をおすすめから削除`,"sub.workspace.selectModel":`モデルを選択`,"sub.workspace.selectModelDesc":`一覧からモデルを選んで詳細を確認し、spawn_agent のおすすめに設定します。`,"sub.workspace.selector":`公開セレクター`,"logs.title":`リクエストログ`,"logs.tabLogs":`ログ`,"logs.tabDebug":`デバッグ`,"logs.subtitle":`ローカル opencodex プロキシを経由した最近のリクエスト(新しい順)。`,"logs.autoRefresh":`自動更新`,"logs.noRequests":`まだリクエストがありません。`,"logs.loadError":`リクエストログを読み込めませんでした。`,"logs.filter.surface.label":`サーフェス`,"logs.filter.surface.all":`すべて`,"logs.filter.surface.claude":`Claude`,"logs.filter.surface.codex":`Codex`,"logs.filter.surface.grok":`Grok`,"logs.filter.conversation.label":`会話`,"logs.filter.conversation.placeholder":`会話 ID を貼り付け`,"logs.filter.conversation.clear":`クリア`,"logs.filter.conversation.apply":`ログを絞り込み`,"logs.conversation.totals":`{requests} 件 · {tokens} トークン · {cost}`,"logs.conversation.scope":`合計は現在読み込まれている Logs リングのみです。`,"logs.conversation.excluded":`(~$ から価格なし {unpriced} / 未計測 {unmetered} を除外)`,"logs.detail.conversation":`会話`,"logs.badge.claude":`Claude`,"logs.badge.grok":`Grok`,"logs.col.time":`時刻`,"logs.col.request":`リクエスト`,"logs.col.model":`モデル`,"logs.col.effort":`負荷`,"logs.col.provider":`プロバイダー`,"logs.col.status":`状態`,"logs.col.tokens":`トークン`,"logs.col.tokPerSec":`tok/s`,"logs.col.estimatedCost":`~$`,"logs.metric.tokPerSecTitle":`リクエスト全体の所要時間あたりの出力トークン数`,"logs.metric.estimatedCostTitle":`API 定価相当額(実際の請求ではありません); 未対応の価格は利用できません`,"usage.cost.total":`API 定価相当額(この期間)`,"usage.cost.disclaimer":`請求明細ではありません。サブスクリプション利用量やプロバイダークレジットが代わりに適用される場合があります。`,"usage.cost.unpricedNote":`{count} 件のリクエストを除外(価格または使用量なし)`,"logs.detail.section.basic":`基本情報`,"logs.detail.section.performance":`パフォーマンス`,"logs.detail.section.cost":`API 定価相当額`,"logs.detail.section.attempts":`コンボの試行`,"logs.detail.section.usage":`生の使用量`,"logs.detail.ttft":`TTFT`,"logs.detail.costTotal":`定価相当額`,"logs.detail.totalTokens":`合計トークン`,"logs.detail.matchedKey":`一致した jawcode キー`,"logs.detail.priceSource":`価格ソース`,"logs.detail.unavailableReason":`利用不可の理由`,"logs.detail.copyRequestId":`リクエスト ID をコピー`,"logs.detail.copied":`コピーしました`,"logs.detail.source.jawcode":`jawcode カタログ`,"logs.detail.source.expected":`予想価格オーバーレイ`,"logs.detail.verification.verified":`検証済み`,"logs.detail.verification.derived":`ベースモデルから派生`,"logs.detail.attempt.target":`プロバイダー / モデル`,"logs.detail.attempt.reason":`結果 / 理由`,"logs.detail.attempt.completed":`完了`,"logs.detail.attempt.e2eNote":`トップレベルの tok/s はエンドツーエンドです; 各試行は自身の所要時間を使います。`,"logs.detail.reason.usage_missing":`使用量が報告されませんでした。`,"logs.detail.reason.usage_unsupported":`このプロバイダーは使用量を報告しません。`,"logs.detail.reason.output_missing":`正の出力トークン数が報告されませんでした。`,"logs.detail.reason.invalid_duration":`リクエストの所要時間が有効ではありません。`,"logs.detail.reason.price_unmatched":`一致する jawcode 価格が見つかりませんでした。`,"logs.detail.reason.invalid_cache_breakdown":`キャッシュトークンの詳細が合計入力トークンと矛盾しています。`,"logs.detail.reason.invalid_usage":`使用量に無効なトークン値が含まれています。`,"logs.detail.reason.combo_attempt_unavailable":`少なくとも 1 つのコンボ試行に価格を設定できませんでした。`,"logs.detail.estimate.usage_estimated":`プロバイダーの使用量は推定です。`,"logs.detail.estimate.cache_detail_missing":`キャッシュの詳細が利用できませんでした; 入力は上限の推定です。`,"logs.detail.estimate.expected_price_overlay":`検証済みの予想定価が使用されました。`,"logs.col.error":`エラー`,"logs.col.upstreamReason":`上流の理由`,"logs.col.duration":`所要時間`,"logs.tokens.reported":`報告済み`,"logs.tokens.unreported":`未報告`,"logs.tokens.unsupported":`非対応`,"logs.tokens.estimated":`推定`,"logs.tokens.input":`入力`,"logs.tokens.output":`出力`,"logs.tokens.cacheRead":`キャッシュ読み取り (c)`,"logs.tokens.cacheWrite":`キャッシュ書き込み (w)`,"logs.tokens.reasoning":`推論`,"logs.tokens.noCache":`キャッシュデータなし`,"logs.tokens.contextTotal":`アクティブコンテキスト`,"logs.tokens.noCacheNote":`このプロバイダーはキャッシュトークンを報告しません`,"logs.tokens.noCacheCursor":`Cursor のキャッシュ詳細は未報告`,"logs.tokens.noCacheCursorNote":`Cursor はキャッシュ read/write トークン数を公開しません。これは不明という意味で、キャッシュミスの確定ではありません`,"logs.tokens.estimatedNote":`推定(プロバイダーは正確な使用量を報告しません)`,"logs.details":`詳細`,"logs.detailTitle":`リクエストの詳細`,"logs.detailRaw":`生のログエントリ`,"debug.title":`デバッグ`,"debug.subtitle":`オプトインのプロバイダートランスポートおよび使用量抽出診断です。リクエストエラーと 502 はログタブに残ります。`,"debug.debug":`プロバイダーデバッグ`,"debug.usage":`使用量抽出`,"debug.injection":`インジェクションログ`,"debug.claude":`Claude インバウンド`,"debug.claudeInbound.title":`Claude インバウンドリクエスト`,"debug.claudeInbound.sub":`Claude Code/Desktop が実際に送信する内容(thinking、effort、metadata) — プロンプトテキストは保存されません。`,"debug.claudeInbound.empty":`まだキャプチャされたリクエストはありません。これがオンの状態で Claude からメッセージを送信してください。`,"debug.claudeInbound.time":`時刻`,"debug.claudeInbound.endpoint":`エンドポイント`,"debug.claudeInbound.model":`モデル`,"debug.claudeInbound.none":`なし`,"debug.reset":`ランタイムオーバーライドをクリア`,"debug.refresh":`更新`,"debug.follow":`追従`,"debug.streamProvider":`プロバイダー`,"debug.streamUsage":`使用量`,"debug.streamInjection":`インジェクション`,"debug.loading":`デバッグ設定を読み込み中…`,"debug.loadFailed":`デバッグ設定を読み込めませんでした。`,"debug.emptyTitle":`デバッグログはオフです`,"debug.empty":`上のカードでプロバイダーデバッグまたは使用量抽出をオンにしてください。プロキシ経由でリクエストを送信すると、ここに行が表示されます。`,"debug.noLinesTitle":`行を待機中`,"debug.noLines.provider":`プロバイダーデバッグはオンですが、トランスポートの異常(欠落または不正なフレーム、Cursor のダイヤル/再試行イベント)のみを記録します。Anthropic のようなプロバイダーでの正常なリクエストは行を生成しないことがあります。`,"debug.noLines.usage":`使用量抽出はオンですが、まだ何もキャプチャされていません。Codex 経由でチャット/リクエストを送信するとここに表示されます。`,"debug.noLines.injection":`インジェクションログはオンですが、まだ何もキャプチャされていません。コラボおよびサブエージェントのターンでのマルチエージェントガイダンスインジェクションと負荷上限の決定を記録します。`,"usage.title":`使用量`,"usage.subtitle":`プロキシからのローカルトークン会計です。欠損した使用量はゼロとして表示されることはありません。`,"usage.loading":`使用量データを読み込み中…`,"usage.empty":`まだ使用量が記録されていません。プロキシ経由でリクエストを送信するとここにアクティビティが表示されます。`,"usage.loadError":`使用量データを読み込めませんでした。`,"usage.range.all":`すべて`,"usage.range.available":`利用可能な履歴`,"usage.historyTruncated":`古い利用履歴が読み込まれていないため、合計は利用可能な履歴のみを対象とします。`,"usage.range.30d":`30日`,"usage.range.7d":`7日`,"usage.card.requests":`リクエスト`,"usage.card.measured":`計測`,"usage.card.reported":`報告`,"usage.card.totalTokens":`合計トークン`,"usage.card.cachedTokens":`キャッシュ読み取り`,"usage.card.cachedTokensHint":`プロバイダーキャッシュから提供されたプロンプトトークン(読み取り)。キャッシュ書き込みは存在する場合、下に表示されます。`,"usage.card.cacheWriteTokens":`キャッシュ書き込み`,"usage.card.coverage":`カバレッジ`,"usage.card.activeDays":`アクティブ日数`,"usage.section.heatmap":`日のアクティビティ`,"usage.section.overview":`概要`,"usage.section.models":`モデル`,"usage.section.providers":`プロバイダー`,"usage.section.coverage":`カバレッジ内訳`,"usage.workspace.report":`使用量レポート`,"usage.workspace.sections":`使用量セクション`,"usage.coverage.measured":`計測`,"usage.coverage.reported":`プロバイダー報告`,"usage.coverage.estimated":`推定`,"usage.coverage.note":`計測エントリにはプロバイダー報告および推定のトークン数が含まれます。未報告および非対応のリクエストは追跡されますが、ゼロトークンに水増しされることはありません。`,"usage.search.models":`モデルを検索…`,"usage.col.requests":`リクエスト`,"usage.col.measured":`計測`,"usage.col.reported":`報告`,"usage.col.tokens":`トークン`,"usage.col.share":`割合`,"usage.heatmap.less":`少ない`,"usage.heatmap.more":`多い`,"usage.dayMon":`月`,"usage.dayWed":`水`,"usage.dayFri":`金`,"usage.heatmap.tooltipTokens":`{tokens} トークン`,"usage.heatmap.tooltipRequests":`{requests} リクエスト`,"nav.storage":`ストレージ`,"storage.title":`ストレージ`,"storage.subtitle":`CODEX_HOME の使用状況を確認。クリーンアップはアクティブセッションに触れません。`,"storage.loading":`ストレージをスキャン中…`,"storage.empty":`CODEX_HOME が空か存在しません — 報告するものはありません。`,"storage.error":`ストレージのスキャンに失敗しました。CODEX_HOME が有効なディレクトリを指しているか確認してください。`,"storage.refresh":`再スキャン`,"storage.rescanned":`スキャンが完了しました。`,"storage.card.total":`合計サイズ`,"storage.card.files":`ファイル`,"storage.card.home":`CODEX_HOME`,"storage.snapshot.lastScan":`最終スキャン`,"storage.snapshot.scanning":`スキャン中…`,"storage.snapshot.unavailable":`まだスキャンがありません。`,"storage.cleanupCard.title":`容量を空ける`,"storage.cleanupCard.tabs":`クリーンアップオプション`,"storage.cleanupCard.tab.policy":`ポリシー`,"storage.cleanupCard.tab.quarantine":`隔離`,"storage.cleanup.noArchives":`クリーンアップ対象のアーカイブセッションはありません。`,"storage.section.buckets":`バケット`,"storage.section.largest":`最大ファイル`,"storage.workspace.overview":`概要`,"storage.workspace.selectBucket":`一覧からバケットを選ぶと内訳が表示されます。`,"storage.col.bucket":`バケット`,"storage.col.size":`サイズ`,"storage.col.files":`ファイル`,"storage.col.oldest":`最古`,"storage.col.newest":`最新`,"storage.col.rows":`DB 行`,"storage.rows.unknown":`不明(ロック中)`,"storage.bucket.sessions":`アクティブセッション`,"storage.bucket.archived_sessions":`アーカイブ済みセッション`,"storage.bucket.logs_db":`ログデータベース`,"storage.bucket.state_db":`状態データベース`,"storage.bucket.attachments":`添付`,"storage.bucket.deletion_manifests":`削除マニフェスト`,"storage.bucket.other":`その他`,"storage.cleanup.title":`アーカイブのクリーンアップ`,"storage.cleanup.help":`古いアーカイブセッションを割合で削除します。アクティブセッションには触れません。既定は隔離で、ファイルは CODEX_HOME/.trash へ移動します。`,"storage.cleanup.slider":`古いアーカイブの割合`,"storage.cleanup.percent":`{percent}%`,"storage.cleanup.preset":`{percent}`,"storage.cleanup.preview":`プレビュー`,"storage.cleanup.confirmTitle":`アーカイブクリーンアップの確認`,"storage.cleanup.confirmBody":`アーカイブ {count} 件(約 {size})、古い {percent}% を処理します。`,"storage.cleanup.moreFiles":`…ほか {n} 件`,"storage.cleanup.permanent":`完全に削除する(隔離しない)`,"storage.cleanup.permanentWarn":`完全削除は元に戻せません。`,"storage.cleanup.quarantineNote":`ファイルは CODEX_HOME 下の .trash へ移動します。隔離タブから復元できます。`,"storage.cleanup.cancel":`キャンセル`,"storage.cleanup.confirmQuarantine":`隔離する`,"storage.cleanup.confirmPermanent":`完全に削除`,"storage.cleanup.doneQuarantine":`{count} 件を隔離しました({size})。`,"storage.cleanup.donePermanent":`{count} 件を完全削除しました({size})。`,"storage.cleanup.previewFailed":`プレビューに失敗しました。`,"storage.cleanup.cleanupFailed":`クリーンアップに失敗しました。`,"storage.cleanup.err.codex_busy":`Codex が state.sqlite を使用中です — Codex を終了して再試行してください。`,"storage.cleanup.err.stale_preview":`プレビュー以降にアーカイブが変わりました — プレビューをやり直してください。`,"storage.cleanup.err.restore_pending_overlap":`選択したアーカイブは未完了の隔離復元と重なっています — 復元を完了するか再試行してください。`,"storage.cleanup.err.referenced_history":`選択したアーカイブはフォークまたはページング履歴から参照されています。`,"storage.cleanup.err.invalid_digest":`プレビューのダイジェストが無い、または無効です。`,"storage.cleanup.err.invalid_mode":`モードは quarantine または permanent である必要があります。`,"storage.cleanup.err.fs_failed":`ファイルシステムのクリーンアップに失敗しました。一部の変更は既に適用されている可能性があります — CODEX_HOME/.trash と表示されたリカバリパスを確認してください。`,"storage.cleanup.err.fs_failed_trash":`ファイルシステムのクリーンアップに失敗しました。一部の変更は既に適用されている可能性があります — {trashDir} と manifest.json で復旧可能なファイルを確認してください。`,"storage.cleanup.err.db_reconcile_failed":`Codex の状態データベースを更新できませんでした。`,"storage.cleanup.err.cleanup_failed":`クリーンアップに失敗しました。`,"storage.trash.title":`隔離`,"storage.trash.help":`CODEX_HOME/.trash へ移したアーカイブセッションです。復元すると JSONL とスレッド行が戻ります。`,"storage.trash.empty":`隔離エントリはありません。`,"storage.trash.loading":`隔離を読み込み中…`,"storage.trash.col.when":`隔離日時`,"storage.trash.col.files":`ファイル`,"storage.trash.col.size":`サイズ`,"storage.trash.col.mode":`モード`,"storage.trash.col.id":`エントリ`,"storage.trash.restore":`復元`,"storage.trash.confirmTitle":`隔離エントリを復元しますか?`,"storage.trash.confirmBody":`{id} から {count} 件(約 {size})をアーカイブセッションへ戻します。`,"storage.trash.cancel":`キャンセル`,"storage.trash.confirmRestore":`復元`,"storage.trash.done":`{count} 件を復元しました({size})。`,"storage.trash.restoreFailed":`復元に失敗しました。`,"storage.trash.listFailed":`隔離一覧を取得できませんでした。`,"storage.trash.mode.quarantine":`隔離`,"storage.trash.mode.permanent":`完全削除(未完了)`,"storage.trash.err.codex_busy":`Codex が state.sqlite を使用中です — Codex を終了して再試行してください。`,"storage.trash.err.invalid_trash":`隔離エントリ ID が無い、または無効です。`,"storage.trash.err.missing_trash":`隔離エントリが見つかりません。`,"storage.trash.err.dest_exists":`復元先が既に存在します — アーカイブファイルを削除または改名して再試行してください。`,"storage.trash.err.fs_failed":`ファイルシステムの復元に失敗しました。一部は既に復元されている可能性があります — archived_sessions と .trash を確認してください。`,"storage.trash.err.storage_mutation_busy":`別のストレージクリーンアップまたは復元が進行中です — しばらくして再試行してください。`,"storage.trash.err.db_reconcile_failed":`Codex の状態データベース行を復元できませんでした。`,"storage.trash.err.restore_failed":`復元に失敗しました。`,"storage.trash.err.restore_worker_timeout":`復元が長時間(10 分超)かかったため停止しました。`,"storage.trash.err.restore_worker_aborted":`シャットダウン中に復元がキャンセルされました。`,"storage.trash.err.restore_worker_failed":`復元ワーカーがクラッシュまたは予期しないエラーで失敗しました。`,"storage.policy.title":`自動クリーンアップ方針`,"storage.policy.help":`アーカイブがしきい値を超えたときの任意の一括クリーンアップ。既定はオフ — 自動では有効になりません。`,"storage.policy.loading":`方針を読み込み中…`,"storage.policy.loadFailed":`クリーンアップ方針を読み込めませんでした。`,"storage.policy.saveFailed":`クリーンアップ方針を保存できませんでした。`,"storage.policy.runFailed":`方針の実行に失敗しました。`,"storage.policy.alreadyRunning":`クリーンアップ方針の実行が既に進行中です。`,"storage.policy.invalid":`方針の値が無効です。`,"storage.policy.enabled":`自動クリーンアップを有効化`,"storage.policy.enabledHint":`既定はオフです。有効にすると選択したスケジュール(または今すぐ実行)でのみ動きます。`,"storage.policy.threshold":`アーカイブサイズが超えたら(GiB)`,"storage.policy.trigger":`トリガー`,"storage.policy.target":`クリーンアップ目標`,"storage.policy.targetPercent":`古いアーカイブを削除(%)`,"storage.policy.targetReduce":`アーカイブを次のサイズまで縮小(GiB)`,"storage.policy.thresholdInc":`しきい値を上げる`,"storage.policy.thresholdDec":`しきい値を下げる`,"storage.policy.percentInc":`パーセントを上げる`,"storage.policy.percentDec":`パーセントを下げる`,"storage.policy.reduceInc":`削減目標を上げる`,"storage.policy.reduceDec":`削減目標を下げる`,"storage.policy.schedule":`スケジュール`,"storage.policy.schedule.manual":`手動のみ`,"storage.policy.schedule.startup":`プロキシ起動時`,"storage.policy.schedule.daily":`毎日`,"storage.policy.schedule.weekly":`毎週`,"storage.policy.mode":`削除モード`,"storage.policy.mode.quarantine":`隔離(既定)`,"storage.policy.mode.permanent":`完全削除`,"storage.policy.permanentWarn":`完全削除モードは元に戻せません。確信がなければ隔離を使ってください。`,"storage.policy.lastRun":`前回の実行`,"storage.policy.lastRunDetail":`{count} 件削除 · {size} 解放`,"storage.policy.nextRun":`次回の実行`,"storage.policy.never":`なし`,"storage.policy.save":`保存`,"storage.policy.runNow":`今すぐ実行`,"storage.policy.running":`実行中…`,"storage.policy.saved":`方針を保存しました。`,"storage.policy.skippedDisabled":`方針が無効です — 先に有効化してください。`,"storage.policy.skippedUnder":`アーカイブサイズがしきい値未満です — 作業はありません。`,"storage.policy.skippedEmpty":`目標に合うアーカイブ候補がありません。`,"storage.policy.doneQuarantine":`方針が {count} 件を隔離しました({size})。`,"storage.policy.donePermanent":`方針が {count} 件を完全削除しました({size})。`,"modal.addNamed":`追加: {label}`,"modal.add":`プロバイダーを追加`,"modal.search":`プロバイダーを検索…`,"modal.logInWith":`{label} でログイン`,"modal.waitingBrowser":`ブラウザを待機中…`,"modal.providerName":`プロバイダー名`,"modal.adapter":`アダプター`,"modal.baseUrl":`ベース URL`,"modal.endpoint":`エンドポイント`,"modal.endpoint.tokenPlan":`トークンプラン`,"modal.endpoint.payAsYouGo":`従量課金`,"modal.endpoint.custom":`カスタム`,"modal.defaultModel":`デフォルトモデル(任意)`,"modal.allowPrivateNetwork":`ローカル/プライベートネットワークを許可`,"modal.allowPrivateNetworkHint":`意図的にセルフホストしたプロバイダーに対してのみ有効化してください。メタデータエンドポイントはブロックされたままです。`,"modal.nameRequired":`プロバイダー名は必須です`,"modal.baseUrlRequired":`ベース URL は必須です`,"modal.networkError":`ネットワークエラー — プロキシは起動していますか?`,"modal.loginFailStart":`ログインを開始できませんでした`,"modal.waitingLogin":`ブラウザログインを待機中…`,"modal.loggingIn":`ログイン中…`,"modal.loginTimeout":`ログインがタイムアウトしました — もう一度お試しください。`,"modal.back":`戻る`,"modal.badge.oauth":`OAuth`,"modal.customProvider":`カスタムプロバイダー`,"modal.failedStatus":`失敗 ({status})`,"modal.loginError":`ログインエラー: {error}`,"modal.badge.codexLogin":`Codex ログイン`,"modal.badge.local":`ローカル`,"modal.badge.apiKey":`API キー`,"modal.badge.direct":`ダイレクト`,"modal.badge.pool":`プール`,"modal.badge.free":`無料`,"modal.invalidPreset":`この組み込みプロバイダープリセットは不完全です。プロキシを再起動してもう一度お試しください。`,"modal.freeTierTitle":`無料枠`,"modal.freeTierDefault":`API キー不要です。そのまま利用できます。`,"modal.tab.accounts":`アカウント`,"modal.tab.free":`無料`,"modal.tab.paid":`有料`,"modal.accountsHint":`ChatGPT/Codex、OAuth プロバイダー、API キーアカウントにここからサインインします。OpenAI は組み込み済み — 再度追加せずログインしてください。`,"modal.accountsCodexAuthLink":`Codex 認証`,"modal.notListed":`プロバイダーが載っていませんか? カスタムを追加`,"modal.catalogLoading":`カタログを読み込み中…`,"modal.accountLogin":`ログイン`,"modal.accountLogout":`ログアウト`,"modal.accountAdd":`アカウントを追加`,"modal.accountManage":`管理`,"modal.accountCodexPool":`ChatGPT アカウントプール`,"modal.accountLoggedIn":`ログイン済み`,"modal.accountLoggedOut":`未ログイン`,"quota.fiveHourLimit":`5 時間上限`,"quota.weeklyLimit":`週間上限`,"quota.monthlyLimit":`30 日上限`,"quota.cursorFirstParty":`ファーストパーティモデル`,"quota.cursorApiUsage":`API 使用量`,"quota.totalSubscriptionCredits":`サブスクリプションクレジット合計`,"quota.usedPercent":`{pct}% 使用`,"quota.limitReached":`上限に達しました`,"quota.resetsToday":`今日 {time} にリセット`,"quota.resetsTomorrow":`明日 {time} にリセット`,"quota.resetsAt":`{when} にリセット`,"quota.resetsRelativeMinutes":`{n} 分後にリセット`,"quota.resetsRelativeHours":`{n} 時間後にリセット`,"pws.status.ready":`準備完了`,"pws.status.needsSetup":`セットアップが必要`,"pws.status.needsAttention":`要対応`,"pws.auth.chatgptPassthrough":`ChatGPT パススルー`,"pws.auth.noKey":`キー不要`,"pws.freeTitle":`無料料金(キーが必要な場合もあります)`,"pws.localTitle":`ローカルランタイム`,"pws.modelCountOne":`1 モデル`,"pws.modelCount":`{count} モデル`,"pws.rail.suffixDefault":` · デフォルト`,"pws.rail.suffixLocal":` · ローカル`,"pws.rail.suffixFree":` · 無料`,"pws.rail.selectAria":`{name} を選択 — {status}{suffix}`,"pws.searchPlaceholder":`プロバイダーを検索…`,"pws.filterAria":`プロバイダーを絞り込み`,"pws.providerFiltersAria":`プロバイダーフィルタ`,"pws.filters":`フィルタ`,"pws.filterStatus":`状態`,"pws.pricing":`料金`,"pws.paid":`有料`,"pws.filterType":`タイプ`,"pws.type.cloud":`クラウド`,"pws.type.local":`ローカル`,"pws.type.selfHosted":`セルフホスト`,"pws.type.login":`ログイン`,"pws.sort":`並べ替え`,"pws.sortProvidersAria":`プロバイダーを並べ替え`,"pws.sort.az":`A–Z`,"pws.sort.za":`Z–A`,"pws.sort.freePaid":`無料優先`,"pws.sort.paidFree":`有料優先`,"pws.sort.accountsFirst":`アカウント優先`,"pws.resetAll":`すべてリセット`,"pws.providerList":`プロバイダー一覧`,"pws.providersAria":`プロバイダー`,"pws.groupReady":`準備完了 ({count})`,"pws.groupNeedsSetup":`セットアップが必要 ({count})`,"pws.groupDisabled":`無効 ({count})`,"pws.noSearchResults":`検索に一致するプロバイダーがありません。`,"pws.noMatchFilters":`フィルタに一致するプロバイダーがありません。`,"pws.noProvidersConfigured":`プロバイダーが設定されていません。`,"pws.workspaceMainAria":`プロバイダーの詳細`,"pws.detailComingSoon":`詳細ビューは近日対応 — このプロバイダーの管理にはクラシックビューを使用してください。`,"pws.selectPrompt":`リストからプロバイダーを選択してください。`,"pws.connectFirst":`最初のプロバイダーを接続`,"pws.empty.browseFree":`無料プロバイダーを見る`,"pws.empty.browseFreeDesc":`サブスクリプションなしで始める`,"pws.empty.connectAccount":`アカウントを接続`,"pws.empty.connectAccountDesc":`ChatGPT やプロバイダーのログインを使用`,"pws.empty.addEndpoint":`エンドポイントを追加`,"pws.empty.addEndpointDesc":`カスタムベース URL と API キー`,"pws.tab.overview":`概要`,"pws.tab.models":`モデル`,"pws.tab.usage":`使用量`,"pws.tab.accounts":`アカウント`,"pws.tab.settings":`設定`,"pws.connection":`接続`,"pws.status.connected":`接続済み`,"pws.attentionTitle":`要対応`,"pws.attention.reauth":`アクティブアカウントの再認証が必要です`,"pws.attention.reauthForward":`アクティブな Codex アカウントの再認証が必要です — アカウントタブを開いて修正してください`,"pws.attention.missingCredentials":`資格情報が不足しています`,"pws.cell.auth":`認証`,"pws.cell.note":`メモ`,"pws.cell.defaultModel":`デフォルトモデル`,"pws.statsAria":`プロバイダー統計`,"pws.statsTitle":`統計`,"pws.stats.totalRequests":`リクエスト (30日)`,"pws.stats.totalTokens":`トークン (30日)`,"pws.stats.quotaUpdated":`クォータを更新しました`,"pws.stats.quotaTracked":`レート制限は使用量タブで追跡されます。`,"pws.stats.source":`ソース`,"pws.usageLast30d":`使用量 (過去30日)`,"pws.metricRequests":`リクエスト`,"pws.metricTokens":`トークン`,"pws.usageUnavailable":`まだ使用量が記録されていません。`,"pws.rateLimits":`レート制限`,"pws.quotaUnavailable":`このプロバイダーのクォータデータがありません。`,"pws.accountQuotaUnavailable":`レート制限データを一時的に取得できません。前回の値がある場合はそれを表示します。`,"pws.selected":`選択中`,"pws.copyModelId":`ID をコピー`,"pws.modelCopied":`コピーしました!`,"pws.modelsAvailable":`{count} 件利用可能`,"pws.modelSearchPlaceholder":`モデルを絞り込み…`,"pws.modelsLoading":`モデルを読み込み中…`,"pws.modelsLoadFailed":`モデルを読み込めませんでした。`,"pws.modelsNeedsReauth":`ライブモデル検出が動作するには再ログインが必要です。今は設定済みモデルを表示しています。`,"pws.modelsConfiguredFallback":`設定済みモデルを表示中(ライブ検出は利用不可)。`,"pws.modelsTruncated":`最初の {shown} / {total} モデルを表示中。リストを絞り込んでください。`,"pws.retry":`再試行`,"pws.noModels":`このプロバイダーで検出されたモデルはありません。`,"pws.noModelMatch":`フィルタに一致するモデルがありません。`,"pws.adapterBaseRequired":`アダプターとベース URL は必須です。`,"pws.addAccount":`アカウントを追加`,"pws.addKey":`API キーを追加`,"pws.apiKeys":`API キー`,"pws.authMode":`認証モード`,"pws.availableAccounts":`利用可能なアカウント`,"pws.accountOrdinal":`アカウント {count}`,"pws.accountsLoading":`アカウントを読み込み中…`,"pws.accountsLoadFailed":`アカウントを読み込めませんでした。`,"pws.retryAccounts":`再試行`,"pws.noAccounts":`まだアカウントが接続されていません。`,"pws.accountSwitching":`切り替え中…`,"pws.accountCurrent":`現在のアカウント`,"pws.defaultModelNone":`なし(プロバイダーのデフォルトを使用)`,"pws.discardSettings":`破棄`,"pws.jsonEditorDesc":`生のプロバイダー JSON 設定を編集します。変更はすぐに保存されます。`,"pws.jsonEditorTitle":`JSON エディタ — {name}`,"pws.jsonRestore":`復元`,"pws.jsonSave":`保存`,"pws.loggedInTitle":`ログイン済み`,"pws.notLoggedInTitle":`未ログイン`,"pws.note":`メモ`,"pws.allowPrivateNetwork":`ローカル/プライベートネットワークを許可`,"pws.liveModels":`プロバイダーからモデルを検出`,"pws.liveModelsDesc":`プロバイダーのライブモデルカタログを取得します。オフにすると設定済みの静的モデルのみを使用します。`,"pws.optionalPlaceholder":`任意`,"pws.providerId":`プロバイダー ID`,"pws.reauth":`再認証が必要`,"pws.reauthenticate":`再認証`,"pws.copyDoctor":`ocx doctor をコピー`,"pws.doctorCopied":`コピー済み`,"pws.healthCooldownHint":`クールダウンが終わるまで待ってください。まだこのアカウントをプローブしないでください。`,"pws.doctorCopyUnavailable":`クリップボードを利用できません`,"pws.healthLabel.rateLimited":`レート制限中`,"pws.healthLabel.quotaLimited":`クォータ制限中`,"pws.healthLabel.reauthRequired":`再認証が必要です`,"pws.healthLabel.refreshFailed":`更新に失敗しました`,"pws.healthLabel.metadataMismatch":`メタデータの不一致`,"pws.healthLabel.credentialConflict":`資格情報の競合`,"pws.healthSummary.rateLimited":`{provider} {account}: {until} までレート制限中です。それまでこのアカウントのルーティングは停止します。`,"pws.healthSummary.quotaLimited":`{provider} {account}: {until} までクォータ制限中です。それまでこのアカウントのルーティングは停止します。`,"pws.healthSummary.reauthRequired":`{provider} {account}: 再認証が必要です。`,"pws.healthSummary.credentialConflict":`{provider} {account}: 資格情報の競合があります。`,"pws.healthSummary.metadataMismatch":`{provider} {account}: メタデータが一致しません。`,"pws.healthSummary.staleCredentials":`{provider} {account}: 資格情報が不完全です。`,"pws.removeConfirm":`削除`,"pws.removeConfirmBody":`プロバイダー "{name}" を削除しますか? これは元に戻せません。`,"pws.removeDefaultConfirmBody":`既定のプロバイダー "{name}" を削除しますか? "{defaultProvider}" が既定のプロバイダーになります。この操作は元に戻せません。`,"pws.removeConfirmTitle":`プロバイダーを削除`,"pws.saveSettings":`保存`,"pws.saving":`保存中…`,"pws.settingsSaved":`設定を保存しました。`,"pws.settingsUnsavedBar":`未保存の変更があります。`,"pws.unsavedLeaveBody":`未保存の変更があります。保存してから移動しますか?`,"pws.unsavedLeaveTitle":`未保存の変更`,"pws.attentionRequired":`要対応`,"pws.attentionAria":`{name}: {reason}`,"pws.missingCredentials":`資格情報が不足しています`,"pws.editJsonDesc":`生のプロキシ設定を JSON として編集`,"pws.updatesUnavailable":`プロバイダーの更新は利用できません。`,"pws.dashboard.title":`プロバイダー概要`,"pws.dashboard.subtitle":`すべてのモデルプロバイダーを一か所で管理します。`,"pws.dashboard.rateLimits":`レート制限`,"pws.dashboard.recentlyUsed":`最近の使用`,"pws.dashboard.requests":`{count} リクエスト`,"pws.dashboard.checkedAgo":`{time} に確認`,"pws.dashboard.noQuota":`クォータデータなし`,"pws.dashboard.noUsage":`まだ使用量データはありません`,"pws.dashboard.noRateLimits":`まだレート制限データはありません`,"pws.allProviders":`プロバイダー概要`,"pws.enabledLabel":`有効`,"pws.testConnection":`接続テスト`,"pws.testing":`テスト中…`,"pws.connectionOk":`接続 OK`,"pws.connectionFailed":`接続失敗`,"pws.connectionNotApplicable":`対象外 — このプロバイダーは静的モデルカタログを使用します。`,"pws.editSettings":`設定を編集`,"pws.viewUsage":`詳細な使用量を表示`,"pws.allSystemsOk":`すべてのシステムが稼働中`,"pws.apiKeyConfigured":`API キー設定済み`,"pws.addApiKey":`API キーを追加`,"pws.loggedInAs":`{email} としてログイン中`,"pws.notLoggedIn":`未ログイン`,"pws.passthrough":`Codex パススルー`,"pws.notes":`メモ`,"pws.notePlaceholder":`このプロバイダーについてのメモを追加...`,"pws.noteSaved":`メモを保存しました`,"pws.authSummary":`認証`,"time.justNow":`たった今`,"time.notChecked":`未確認`,"time.minutesAgo":`{n}分前`,"time.hoursAgo":`{n}時間前`,"time.daysAgo":`{n}日前`,"modal.noMatch":`一致なし。`,"modal.oauthDefaultNote":`アカウントでログイン — API キー不要です。`,"modal.oauthComingSoon":`{label} の OAuth ログインは次回の更新で対応予定です。今は API キーをお使いください。`,"modal.oauthComingSoonShort":`このプロバイダーの OAuth ログインは次回の更新で対応予定です — 今は API キーをお使いください。`,"modal.useApiKeyInstead":`代わりに API キーを使用`,"modal.setupGuide":`セットアップガイド`,"modal.setupStep1Prefix":`にアクセスし`,"modal.setupDashboardLink":`{label} ダッシュボード`,"modal.setupStep1Suffix":`から API キーをコピー`,"modal.setupStep2":`下の API キー欄に貼り付け`,"modal.setupStep3":`プロバイダーを追加をクリック — モデルは自動検出されます`,"modal.namePlaceholder":`例: openrouter`,"modal.duplicateWarn":`プロバイダー "{name}" は既存で、上書きされます。`,"modal.forwardHintPrefix":`キー不要 — プロキシはあなたの`,"modal.forwardCredentials":`codex ログイン`,"modal.forwardHintSuffix":`資格情報をこのプロバイダーに転送します。`,"modal.localHint":`API キーは保存されません。Cursor の静的な公開モデルカタログを Codex に追加しますが、ライブの Cursor トランスポートとネイティブのファイル/シェル実行は監査されるまで無効のままです。`,"modal.getApiKey":`{label} の API キーを取得`,"modal.apiKey":`API キー`,"modal.apiKeyTransport":`API キーヘッダー`,"modal.apiKeyTransportNative":`x-api-key (Anthropic 標準)`,"modal.apiKeyTransportBearer":`Authorization: Bearer`,"modal.apiKeyPlaceholder":`sk-… (または $ENV_VAR)`,"modal.defaultModelPlaceholder":`例: gpt-5.5`,"modal.baseUrlPlaceholder":`https://...`,"modal.baseUrlPlaceholderError":`ベース URL に未解決の {placeholder} が含まれています。実際の値に置き換えてください。`,"modal.baseUrlPlaceholderHint":`プロバイダーを追加する前に、ベース URL の {placeholder} を実際の Account ID に置き換えてください。`,"modal.adding":`追加中…`,"modal.useOauthLogin":`← OAuth ログインを使用`,"nav.codexAuth":`Codex 認証`,"nav.api":`API`,"nav.openMenu":`メニューを開く`,"nav.closeMenu":`メニューを閉じる`,"codexAuth.mainAccount":`メインアカウント`,"codexAuth.codexApp":`Codex App`,"codexAuth.appLogin":`アプリログイン`,"codexAuth.accountPool":`アカウントプール`,"codexAuth.accountModeTitle":`OpenAI アカウントモード`,"codexAuth.accountModePool":`プールモード`,"codexAuth.accountModePoolDesc":`メインログインと対象の追加アカウントがここでローテーションします。`,"codexAuth.accountModeDirect":`ダイレクトモード`,"codexAuth.accountModeDirectDesc":`リクエストはメインログインのみを使用します; 追加アカウントはプールモード用に保持されます。`,"codexAuth.openaiMissing":`組み込みの OpenAI プロバイダーが設定されていません。`,"codexAuth.openaiDisabled":`組み込みの OpenAI プロバイダーが無効です。`,"codexAuth.openaiUnavailableDesc":`OpenAI アカウントは引き続き利用できます。Codex リクエストをルーティングするにはプロバイダーを有効にしてください。`,"codexAuth.enableOpenai":`OpenAI を有効にする`,"codexAuth.enablingOpenai":`有効化中...`,"codexAuth.enableOpenaiFailed":`OpenAI プロバイダーを有効にできませんでした。`,"codexAuth.openaiPresetLoadFailed":`OpenAI プロバイダーのプリセットを読み込めませんでした。`,"codexAuth.openaiPresetUnavailable":`OpenAI プロバイダーのプリセットを利用できません。`,"codexAuth.openProviders":`プロバイダーを開く`,"codexAuth.add":`追加`,"codexAuth.refreshQuota":`クォータを更新`,"codexAuth.refreshingQuota":`更新中...`,"codexAuth.quotaRefreshed":`クォータを更新しました`,"codexAuth.quotaRefreshFailed":`クォータの更新に失敗しました`,"codexAuth.pauseExhausted":`上限到達を一括停止`,"codexAuth.pausingExhausted":`クォータを確認中...`,"codexAuth.pauseExhaustedSucceeded":`上限に達したアカウントを停止しました: {count}`,"codexAuth.pauseExhaustedNone":`使用率 100% が確認されたアカウントはありません。`,"codexAuth.pauseExhaustedFailed":`上限到達アカウントの確認と停止に失敗しました。`,"codexAuth.noPool":`まだプールアカウントは追加されていません。`,"codexAuth.pause":`一時停止`,"codexAuth.resume":`再開`,"codexAuth.paused":`一時停止中`,"codexAuth.pauseSucceeded":`{email} を一時停止しました`,"codexAuth.resumeSucceeded":`{email} をアカウントプールに戻しました`,"codexAuth.pauseFailed":`{email} を一時停止できませんでした。変更はありません。`,"codexAuth.resumeFailed":`{email} を再開できませんでした。変更はありません。`,"codexAuth.pausedHint":`再開するまで、自動切り替え、再試行、クールダウン復旧、手動選択の対象外です。`,"codexAuth.fiveHour":`5時間`,"codexAuth.weekly":`週`,"codexAuth.monthly":`30日`,"codexAuth.resets":`リセット`,"codexAuth.today":`今日`,"codexAuth.current":`現在`,"codexAuth.nextSession":`選択済み`,"codexAuth.poolPrepared":`プール準備済み`,"codexAuth.preparePoolTitle":`このアカウントをプールモード用に準備しますか?`,"codexAuth.preparePoolDesc":`ダイレクトリクエストはメインログインを使い続けます。このアカウントはプールモードが有効化された際の準備済みプール選択になります。`,"codexAuth.prepareForPool":`プール用に準備`,"codexAuth.poolPreparedToast":`{email} はプールモード用に準備されました`,"codexAuth.switchTitle":`アクティブアカウントを切り替えますか?`,"codexAuth.switchDesc":`既存および新規 Codex セッションの次のリクエストから適用されます。処理中のリクエストは現在のアカウントを維持します。`,"codexAuth.cacheWarning":`アカウントが変わっても OpenCodex は会話コンテキストを再生しますが、プロバイダー側のプロンプトキャッシュは再ウォームアップが必要な場合があります。`,"codexAuth.setAsNext":`アカウントを選択`,"codexAuth.cancel":`キャンセル`,"codexAuth.switchBack":`メインに戻しますか?`,"codexAuth.switchBackDesc":`既存および新規 Codex セッションの次のリクエストからアプリログインアカウントを使用します。`,"codexAuth.autoSwitch":`使用量ベースのプロアクティブ切り替え`,"codexAuth.autoSwitchQuotaDesc":`クォータ: 使用率が {threshold}% 以上になると、既に紐付いたタスクを含む次のリクエストが、使用率の低い適格アカウントへ移る場合があります。Go/Free は 30 日枠のみを使用します。`,"codexAuth.autoSwitchQuotaOffDesc":`使用量ベースのプロアクティブ切り替えはオフです。新規/未紐付けタスクの割り当てと障害回復は引き続き適用されます。`,"codexAuth.autoSwitchRoundRobinDesc":`ラウンドロビン割り当てはこのしきい値を使用せず、新規/未紐付けタスクを引き続きローテーションします。`,"codexAuth.autoSwitchFillFirstDesc":`フィルファースト: {threshold}% は新規/未紐付けタスクの使い切り基準です。正常な紐付け済みタスクはアカウントを維持します。`,"codexAuth.autoSwitchFillFirstOffDesc":`フィルファーストには新規/未紐付けタスクの使用量基準がありません。クールダウン、再認証、障害回復では引き続きルーティングが変わる場合があります。`,"codexAuth.failureRecoveryNote":`障害回復は別です。出力前の 429/402 拒否、クールダウン、再認証、除外、または設定済みの一時障害フェイルオーバーにより、別の適格アカウントが選ばれる場合があります。`,"codexAuth.autoSwitchThreshold":`使用量しきい値`,"codexAuth.autoSwitchThresholdAria":`使用量しきい値(パーセント)`,"codexAuth.autoSwitchThresholdInc":`使用量しきい値を上げる`,"codexAuth.autoSwitchThresholdDec":`使用量しきい値を下げる`,"codexAuth.autoSwitchLoadFailed":`使用量ベースの切り替え設定を読み込めませんでした。`,"codexAuth.autoSwitchThresholdInvalid":`1 から 100 までの整数を入力してください`,"codexAuth.autoSwitchUpdated":`使用量ベースのプロアクティブ切り替え設定を更新しました`,"codexAuth.autoSwitchUpdateFailed":`使用量ベースの切り替え更新を確認できませんでした。最後に確認された値を表示しています。`,"anthropicPool.title":`Claude アカウントプール(実験的)`,"anthropicPool.enabledDesc":`429 時にアカウントをクールダウンしてフェイルオーバーします。新規セッションは 5 時間使用率が {threshold}% 未満のアカウントを優先します。`,"anthropicPool.disabledDesc":`アクティブな Claude アカウントのみを使用します。実験的ルーティングを受け入れる場合のみ有効にしてください。`,"anthropicPool.experimentalWarning":`実験的で十分に検証されていません。自動的な複数アカウント回転に見える行為は Anthropic により制限される可能性があります。同一組織はクォータを共有することがあり、その場合プールしても効果がありません。リスクを理解していない場合はオフのままにしてください。`,"anthropicPool.needTwoAccounts":`プールを有効にする前に、Claude OAuth アカウントを 2 つ以上追加してください。`,"anthropicPool.threshold":`新規セッションの使用率しきい値`,"anthropicPool.thresholdAria":`新規セッションの使用率しきい値(パーセント)`,"anthropicPool.thresholdHelp":`0 はクォータに基づく選択を無効にします(アフィニティ + アクティブアカウントのみ)。デフォルト 80。`,"anthropicPool.thresholdInvalid":`0 から 100 までの整数を入力してください`,"anthropicPool.loadFailed":`Claude プール設定を読み込めませんでした。`,"anthropicPool.saveFailed":`Claude プール設定を保存できませんでした。`,"anthropicPool.on":`オン`,"anthropicPool.off":`オフ`,"accountPool.strategy":`ローテーション戦略`,"accountPool.strategyDesc":`OpenCodex が新規/未紐付けタスクへアカウントを割り当てる方法です。`,"accountPool.strategyQuota":`クォータ`,"accountPool.strategyRoundRobin":`ラウンドロビン`,"accountPool.strategyFillFirst":`フィルファースト`,"accountPool.strategyHintQuota":`クォータ戦略は使用量しきい値を超えると、既存タスクの次のリクエストも別アカウントへ再紐付けできます。`,"accountPool.strategyHintRoundRobin":`ラウンドロビンは有効な紐付けがないタスクだけをローテーションし、使用量しきい値は通常のローテーションを変えません。`,"accountPool.strategyHintFillFirst":`フィルファーストはしきい値を未紐付けタスクの使い切り基準として使用し、正常な紐付け済みタスクは親和性を維持します。`,"accountPool.unboundDefinition":`新規/未紐付けタスクとは、現在のアカウント紐付けがないリクエストです。既存の表示中タスクも、プロキシまたは親和性のリセット後は未紐付けになる場合があります。`,"accountPool.stickyLimit":`ローテーション前の新規/未紐付け割り当て数`,"accountPool.stickyLimitAria":`ローテーション前の新規/未紐付け割り当て数`,"accountPool.stickyLimitInc":`スティッキー上限を上げる`,"accountPool.stickyLimitDec":`スティッキー上限を下げる`,"accountPool.stickyLimitHelp":`次へ進む前に、この回数の新規/未紐付けタスクを選択アカウントへ割り当てます。カウンターは上流の成功後ではなく、タスクを紐付けた時点で増えます。`,"accountPool.stickyLimitInvalid":`1 から 100 までの整数を入力してください`,"accountPool.strategyLoadFailed":`ローテーション戦略を読み込めませんでした。`,"accountPool.strategyUpdateFailed":`ローテーション戦略を保存できませんでした。`,"codexAuth.switched":`次のリクエストでは {email} を使用します`,"codexAuth.loadFailed":`Codex アカウント設定を読み込めませんでした。`,"codexAuth.switchFailed":`アカウントを切り替えられませんでした。以前の選択はそのままです。`,"codexAuth.removeConfirm":`{id} を削除しますか?`,"codexAuth.removeFailed":`アカウントを削除できませんでした。何も変更されていません。`,"codexAuth.addTitle":`Codex アカウントを追加`,"codexAuth.addIdLabel":`アカウント ID (スラッグ)`,"codexAuth.addIdPlaceholder":`codex-work、codex-alt、team...`,"codexAuth.resetCreditsAria":`{count} 個のリセットクレジット`,"codexAuth.addJsonLabel":`auth.json の内容`,"codexAuth.addHelp":`別のマシンの ~/.codex/auth.json からコピー、または codex-auth export を使用。`,"codexAuth.importBtn":`インポート`,"codexAuth.importInvalidJson":`無効な JSON です`,"codexAuth.importMissingTokens":`JSON に access_token または refresh_token がありません`,"codexAuth.importMissingId":`アカウント ID は必須です`,"codexAuth.accountAdded":`アカウントをプールに追加しました`,"codexAuth.addPickDesc":`別の ChatGPT アカウントでログインしてプールに追加します。`,"codexAuth.oauthLogin":`OAuth ログイン`,"codexAuth.oauthDesc":`ブラウザで ChatGPT ログインを開きます`,"codexAuth.importAuthJson":`auth.json をインポート`,"codexAuth.importAuthJsonDesc":`別の Codex インストールまたは codex-auth export から`,"codexAuth.back":`戻る`,"codexAuth.oauthAlreadyInProgress":`ログインは既に進行中です。ブラウザで完了してください。`,"codexAuth.oauthWaiting":`ブラウザで ChatGPT ログインが完了するのを待機中...`,"codexAuth.oauthSubmittingCode":`コードを送信中…`,"codexAuth.oauthCodeSubmitted":`コードを送信しました — ログイン完了を待っています…`,"codexAuth.oauthStatusRetrying":`ログイン状態の確認中にネットワークまたはプロキシ エラーが発生しました — 再試行中…`,"codexAuth.oauthCancelled":`ログインはキャンセルされました。`,"codexAuth.loginFailed":`ログインに失敗しました`,"codexAuth.needsReauth":`再ログイン`,"codexAuth.reauthenticate":`再認証`,"codexAuth.tokenExpired":`トークンが期限切れ — このアカウントを再認証してください`,"codexAuth.mainTokenExpired":`トークンが期限切れ — Codex アプリログインから再度サインインしてください`,"codexAuth.emailCollision":`このアカウントはメインの Codex ログインと一致します。別のアカウントを使用してください。`,"codexAuth.resetCreditsTitle":`リセットクレジット`,"codexAuth.resetCreditsAvailable":`{count} 個のリセットクレジットが利用可能です。`,"codexAuth.resetCreditsDesc":`各クレジットは現在の時間別・週間使用量上限を即座にリセットします。`,"codexAuth.noResetCredits":`リセットクレジットはありません。`,"codexAuth.earnCreditsHint":`クレジットは毎月および紹介プログラム経由で獲得できます。`,"codexAuth.creditsExpireNote":`クレジットは獲得から 30 日で失効します。`,"codexAuth.useOneCredit":`1 クレジットを使用`,"codexAuth.confirmResetTitle":`リセットクレジットを使用しますか?`,"codexAuth.confirmResetDesc":`現在のレート制限を即座にリセットします。残り {count} クレジットです。`,"codexAuth.irreversible":`この操作は元に戻せません。`,"codexAuth.useCredit":`クレジットを使用`,"codexAuth.redeeming":`リセット中...`,"codexAuth.resetSuccess":`レート制限をリセットしました! 残り {remaining} クレジット。`,"codexAuth.resetSuccessGeneric":`レート制限をリセットしました!`,"codexAuth.resetAlreadyRedeemed":`このクレジットは既に引き換え済みです。クレジットは変わりません。`,"codexAuth.resetNothingToReset":`今リセットが必要なレート制限枠はありません。`,"codexAuth.resetNoCredit":`利用可能なリセットクレジットはありません。`,"codexAuth.resetError":`リセットクレジットの引き換えに失敗しました。もう一度お試しください。`,"codexAuth.fifoNote":`最も古いクレジットが先に使用されます。`,"codexAuth.confirmWhichCredit":`{date} のクレジットが使用されます。`,"codexAuth.creditNext":`次に使用`,"codexAuth.creditLabel":`クレジット #{n}`,"codexAuth.creditNextBadge":`次`,"codexAuth.creditGranted":`付与 {date}`,"codexAuth.creditExpires":`失効 {date} (残り {days}日)`,"api.title":`API アクセス`,"api.subtitle":`生成した API キーで外部アプリから opencodex プロキシに接続します。認証は {authHeader} ヘッダーで行い、エンドポイントごとに受け付けるヘッダーは下の表のとおりです。`,"api.endpointNote":`ベース URL を OpenAI 互換クライアントで使ってください。Responses と Chat Completions は /v1 配下で公開されます。`,"api.endpointsTitle":`エンドポイント`,"api.baseUrl":`ベース URL`,"api.responsesEndpoint":`Responses API`,"api.chatCompletionsEndpoint":`Chat Completions API`,"api.messagesEndpoint":`Messages API`,"api.modelsEndpoint":`Models API`,"api.authTitle":`認証`,"api.authBaseUrlNote":`クライアントにはベース URL を設定し、下のプロトコル別エンドポイントを選んでください。`,"api.authLoopback":`ループバック (127.0.0.1 または ::1) は認証を省略します。リモートでは生成した ocx_ キーまたは OPENCODEX_API_AUTH_TOKEN が必要です。`,"api.modelsTitle":`外部モデルカタログ`,"api.modelsCount":`{count} 件が利用可能`,"api.modelsSearch":`モデルを検索`,"api.modelsSubtitle":`これらの ID を /v1/models と選択したプロトコルで使用してください。`,"api.modelsLoading":`モデルを読み込み中…`,"api.modelsLoadFailed":`外部モデルカタログを読み込めませんでした。`,"api.modelsEmpty":`外部から呼び出せるモデルはまだありません。`,"api.modelsNoMatch":`「{query}」に一致するモデルはありません。`,"api.colModel":`モデル`,"api.colSource":`ソース`,"api.colProtocols":`プロトコル`,"api.copyModelId":`ID をコピー`,"api.modelCopied":`コピーしました`,"api.testModel":`テスト`,"api.testingModel":`テスト中…`,"api.testSucceeded":`OK`,"api.testFailed":`失敗`,"api.protocolResponses":`Responses`,"api.protocolChatCompletions":`Chat Completions`,"api.protocolMessages":`Messages`,"api.sourceNative":`ChatGPT プール`,"api.sourceCombo":`コンボ`,"api.sourceCustom":`カスタム`,"api.usageResponsesTitle":`Responses の例`,"api.usageChatTitle":`Chat Completions の例`,"api.usageMessagesTitle":`Messages の例`,"api.newKeyTitle":`新しいキーを作成しました`,"api.newKeyNote":`今すぐこのキーをコピーしてください — 再表示されません。`,"api.copy":`コピー`,"api.copied":`コピーしました`,"api.dismiss":`閉じる`,"api.generateTitle":`キーを生成`,"api.keyNamePlaceholder":`キー名(任意)`,"api.generate":`生成`,"api.generating":`作成中…`,"api.activeKeys":`アクティブなキー ({count})`,"api.activeKeysLoading":`有効なキー`,"api.noKeys":`まだ API キーがありません。上で生成してください。`,"api.workspace.sections":`API セクション`,"api.section.keys":`キー`,"api.section.connect":`接続`,"api.section.endpoints":`エンドポイント`,"api.section.models":`モデル`,"api.section.examples":`例`,"api.workspace.details":`APIキーの詳細`,"api.workspace.keyDetails":`キーの詳細`,"api.workspace.keyPrefix":`キーのプレフィックス`,"api.workspace.deleteKey":`キーを削除`,"api.workspace.deleteConfirm":`このキーを削除しますか?この操作は元に戻せません。`,"api.workspace.usageExamples":`使用例`,"api.copyUrlHint":`クリックして URL をコピー`,"api.urlCopied":`URL をコピーしました`,"api.copyExampleHint":`クリックして例をコピー`,"api.exampleCopied":`例をコピーしました`,"api.colName":`名前`,"api.colKey":`キー`,"api.colCreated":`作成日`,"api.confirm":`確認`,"api.deleteAria":`API キーを削除`,"api.usageSampleInput":`こんにちは、世界!`,"api.clientConfig.title":`クライアント設定`,"api.clientConfig.rowsLabel":`クライアントを接続`,"api.clientConfig.details":`詳細`,"api.clientConfig.detailsAria":`{client} 設定の詳細`,"api.clientConfig.copyAria":`{client} 設定 JSON をコピー`,"api.clientConfig.downloadAria":`{client} 設定をダウンロード`,"api.clientConfig.rowMeta":`{destination} · モデル {count} 件`,"api.clientConfig.rowError":`{client} の設定を生成できませんでした。`,"api.clientConfig.copiedAnnounceClient":`{client} の設定 JSON をクリップボードにコピーしました。`,"api.clientConfig.clientOpencode":`OpenCode`,"api.clientConfig.clientPi":`Pi`,"api.clientConfig.copy":`JSON をコピー`,"api.clientConfig.download":`ダウンロード`,"api.clientConfig.loading":`クライアント設定を生成中…`,"api.clientConfig.jsonLabel":`{client} 設定 JSON`,"api.clientConfig.destination":`配置先ファイル`,"api.clientConfig.envHint":`起動前にキーを設定`,"api.clientConfig.mergeWarning":`配置先ファイルにマージしてください。置き換えると既存のプロバイダーや MCP 設定が失われます。`,"api.clientConfig.modelCount":`{count} 件のモデルを書き出しました`,"api.clientConfig.missingLimits":`{total} 件中 {count} 件のモデルにコンテキスト上限がないため、クライアント側の既定値が使われます。`,"api.clientConfig.noKeyYet":`{env} に対応するキーがまだありません。ループバック外で使う前に上でキーを発行してください。`,"api.clientConfig.loadFailed":`モデル一覧を読み取れなかったため、クライアント設定を生成できませんでした。`,"api.clientConfig.copiedAnnounce":`クライアント設定 JSON をクリップボードにコピーしました。`,"api.clientConfig.copyFailed":`クライアント設定 JSON をコピーできませんでした。`,"api.clientConfig.downloadedAnnounce":`{filename} をダウンロードしました。まだ何も変わっていません。{destination} に自分でマージしてください。`,"api.clientConfig.whereDisclosure":`このファイルの置き場所`,"api.clientConfig.whereBody":`上のパスはグローバル設定の場所です。作業ディレクトリのプロジェクト設定ファイルが優先され、キーは設定に書かれた環境変数から読み込まれ、このファイルには保存されません。`,"api.keysLoadFailed":`APIキーを読み込めませんでした。`,"api.createFailed":`APIキーを作成できませんでした。`,"api.deleteFailed":`APIキーを削除できませんでした。`,"api.auth.endpoint":`エンドポイント`,"api.auth.required":`必須`,"api.auth.accepted":`利用可`,"api.auth.rejected":`不可`,"api.auth.testProtocol":`{protocol} をテスト`,"api.auth.testNeedsFreshKey":`認証付きテストを実行するには、キーを新しく作成し、一度だけ表示される値を画面に残したままにしてください。`,"api.key.name":`キー名`,"api.key.rename":`名前を変更`,"api.key.saveName":`名前を保存`,"api.key.renaming":`保存中…`,"api.key.renameFailed":`名前を変更できませんでした。入力内容はそのまま残しています。`,"api.key.deleting":`削除中…`,"api.key.copyFailed":`キーをコピーできませんでした。このパネルを閉じる前に手動で選択してコピーしてください。`,"api.attribution.title":`キー別の使用状況`,"api.attribution.requests7d":`直近 7 日のリクエスト`,"api.attribution.totalRequests":`集計済みリクエスト総数`,"api.attribution.totalRequestsAvailable":`利用可能な履歴のリクエスト`,"api.attribution.sinceAvailable":`利用可能な集計開始日`,"api.attribution.lastUsed":`最終使用`,"api.attribution.since":`集計開始`,"api.attribution.neverUsed":`集計開始以降は未使用`,"api.attribution.unavailable":`使用状況なし`,"api.attribution.unavailableDetail":`まだ集計された使用状況がありません。集計開始前のリクエストは遡って割り当てられません。`,"api.attribution.ambiguous":`2 つのキーが同じ ID を共有しているため、どちらの使用状況か判別できません。設定ファイルでキーごとに一意の ID を指定してください。`,"api.attribution.railAmbiguous":`ID 重複`,"nav.claude":`Claude`,"claude.subtitle":`Claude Code 内で GPT、Gemini などのモデルを使用します。`,"claude.pageTitle":`Claude Code`,"claude.workspace.settings":`設定`,"claude.enabledLabel":`Claude 接続`,"claude.enabledHint":`オフにすると Claude Code はこのプロキシを使用できません。`,"claude.authMode":`認証モード`,"claude.authModeHint":`サブスクリプションは Claude アカウントが必要、プロキシは Anthropic アカウント不要で動作します`,"claude.authModeSubscription":`サブスクリプション(Claude アカウント)`,"claude.authModeProxy":`プロキシ(アカウント不要)`,"claude.authModeAuto":`自動 (Claude 認証を検出)`,"claude.effectiveMode.label":`次回起動時に適用`,"claude.effectiveMode.manual":`手動: {mode}`,"claude.effectiveMode.autoPresent":`自動: サブスクリプション — {source} で Claude 認証を検出`,"claude.effectiveMode.autoAbsent":`自動: プロキシモード — Claude 認証が見つかりません`,"claude.effectiveMode.autoUnknown":`自動: サブスクリプション — 認証を確認できませんでした`,"claude.effectiveMode.admissionKey":`このプロキシの API キーは引き続き送信されます。`,"claude.authSource.claude-json-oauth":`Claude アカウント`,"claude.authSource.claude-credentials-file":`認証情報ファイル`,"claude.authSource.macos-keychain":`macOS キーチェーン`,"claude.authSource.exported-env":`環境変数`,"claude.authSource.unknown":`検出された認証情報`,"claude.systemEnv":`自動接続`,"claude.systemEnvDesc":`オンにすると、任意のターミナルで claude を実行すると自動的にプロキシ経由になります。`,"claude.systemEnvUnsupported":`自動接続は macOS でのみ利用できます。このシステムでは {cmd} で Claude を起動してください。`,"claude.systemEnvWarn":`⚠ これを有効化するにはターミナルアプリを完全に終了して再起動する必要があります。推奨されません。`,"claude.fastMode":`高速モード(OpenAI)`,"claude.fastModeDesc":`OpenAI モデルの service_tier を制御します。オン = 優先(高速)。オフ = デフォルト。自動 = パススルー(クライアントが決定)。`,"claude.fastAuto":`自動`,"claude.fastOn":`オン`,"claude.fastOff":`オフ`,"claude.autoContext":`大きなコンテキストを自動で使用`,"claude.autoContextDesc":`1M マーキングがどこまで及ぶかを制御します。オン: 200k トークンを超えるすべてのモデル(GPT モデルなど)に大型コンテキスト行を付けます。オフ: 真の 1M モデルのみに付けます。`,"claude.autoContextInert":`設定ファイルにレガシーのコンテキストサイズ値(maxContextTokens)が存在するため無効です。再び有効化するにはそれを削除してください。`,"claude.autoCompactWindow":`自動要約ポイント`,"claude.autoCompactDefault":`350k(デフォルト)`,"claude.autoCompactWindowDesc":`チャットがこのポイントに達すると古いメッセージが要約されます。各モデル自身の上限を超えることはないので、200k モデルは影響を受けません。`,"claude.autoCompactWindowWarn":`これを変更すると GPT モデルが壊れる可能性があります — モデルの実際の上限より高く設定すると、要約が働く前にチャットがエラーになります。`,"claude.injectAgents":`サブエージェントを自動登録`,"claude.injectAgentsDesc":`サブエージェントタブで選んだモデル(と現在のデフォルトモデル)をディスパッチ可能な Claude Code エージェント(ocx-*)として登録します。次回セッションから適用されます。`,"claude.webSearchSidecar":`ウェブ検索サイドカーの上書き`,"claude.webSearchSidecarHint":`Claude Code リクエストのメインウェブ検索サイドカーを上書きします。`,"claude.visionSidecar":`ビジョンサイドカーの上書き`,"claude.visionSidecarHint":`Claude Code リクエストのメインビジョンサイドカーを上書きします。`,"claude.useMainSetting":`メイン設定を使用`,"claude.sidecarModelPlaceholder":`メイン設定のモデル`,"claude.quickstart":`はじめる`,"claude.quickstartHint":`{cmd} はプロキシ経由で Claude Code を開きます。あなたの claude.ai ログインはそのまま有効です。`,"claude.manualEnv":`手動セットアップ(高度)`,"claude.smallFastModel":`バックグラウンドヘルパーモデル`,"claude.smallFastModelHint":`チャットの要約やトピック検出のようなバックグラウンド作業に Claude Code が使うモデルです。haiku サブエージェントエイリアスもこれを使います。空 = Claude デフォルト(Haiku)。`,"claude.smallFastModelAccurateHint":`チャットの要約やトピック検出など、Claude Code がバックグラウンド処理に使うモデルです。サブエージェントの haiku エイリアスもこのモデルを使います。`,"claude.smallFastModelUnsetOption":`Claude Code に選択させる(ネイティブモデル)`,"claude.smallFastModelNativeWarning":`未設定の場合、OpenCodex はヘルパーモデルの上書きを設定しません。Claude Code がネイティブの Sonnet モデルを使用し、ネイティブプロバイダーで料金が発生する可能性があります。`,"claude.slotUnset":`Claude デフォルトを使用`,"claude.modelMap":`モデルの傍受`,"claude.modelMapHint":`特定モデルへのリクエストを傍受し、選んだモデルに再ルーティングします。デフォルトは空 — ルールを追加するまで何も起きません。`,"claude.mapFrom":`元のモデル(例: claude-sonnet-4-5)`,"claude.mapTo":`差し替え先(例: gemini/gemini-3-pro)`,"claude.addMapping":`ルールを追加`,"claude.removeMapping":`ルールを削除`,"claude.aliases":`利用可能なモデル`,"claude.aliasesHint":`Claude Code の /model メニューに表示されるモデル。`,"claude.aliasProviderOther":`その他`,"claude.loading":`読み込み中…`,"claude.loadFail":`Claude 設定の読み込みに失敗しました`,"claude.saved":`保存しました。`,"claude.saveFailed":`保存に失敗しました`,"claude.networkError":`ネットワークエラー — プロキシは起動していますか?`,"claude.toggleAria":`Claude 接続を切り替え`,"claude.none":`なし`,"claude.tabsLabel":`Claude クライアント`,"claude.tabCode":`Code`,"claude.tabDesktop":`Desktop`,"claudeDesktop.title":`Claude Desktop`,"claudeDesktop.subtitle":`各 Claude モデルファミリーをポート {port} の利用可能なモデルへルーティングします。`,"claudeDesktop.importJson":`JSON をインポート`,"claudeDesktop.exportJson":`JSON をエクスポート`,"claudeDesktop.loading":`Claude Desktop プロファイルを読み込み中…`,"claudeDesktop.loadFail":`Claude Desktop プロファイルの読み込みに失敗しました。`,"claudeDesktop.retry":`再試行`,"claudeDesktop.saveFailed":`Claude Desktop プロファイルの保存に失敗しました。`,"claudeDesktop.applyFailed":`プロファイルは保存されましたが、適用できませんでした。`,"claudeDesktop.updateFailed":`Claude Desktop の更新に失敗しました。`,"claudeDesktop.savedApplied":`プロファイルを保存し、Claude Desktop に適用しました。`,"claudeDesktop.savedAppliedAnnounce":`Claude Desktop プロファイルを保存して適用しました。`,"claudeDesktop.saved":`プロファイルを保存しました。`,"claudeDesktop.savedAnnounce":`Claude Desktop プロファイルを保存しました。`,"claudeDesktop.exported":`プロファイルを JSON としてエクスポートしました。`,"claudeDesktop.importExpected":`バージョン 1 の Claude Desktop プロファイルが必要です。`,"claudeDesktop.importReady":`JSON をインポートしました。ドラフトを確認して保存・適用してください。`,"claudeDesktop.importedAnnounce":`プロファイル JSON をインポートしました。未保存の変更を確認できます。`,"claudeDesktop.importInvalid":`選択されたファイルは有効なプロファイルではありません。`,"claudeDesktop.importFailed":`インポートに失敗しました。{error}`,"claudeDesktop.moved":`{route} を {family} に移動しました。`,"claudeDesktop.unsaved":`未保存の変更`,"claudeDesktop.upToDate":`プロファイルは最新です`,"claudeDesktop.saving":`保存中…`,"claudeDesktop.applying":`適用中…`,"claudeDesktop.saveApply":`保存して適用`,"claudeDesktop.emptyTitle":`利用可能なモデルがありません`,"claudeDesktop.emptyHint":`プロバイダーを追加または有効化してから、Claude Desktop ルートを割り当ててください。`,"claudeDesktop.assignmentsLabel":`Claude モデルファミリーの割り当て`,"claudeDesktop.family.opus":`Opus`,"claudeDesktop.family.fable":`Fable`,"claudeDesktop.family.sonnet":`Sonnet`,"claudeDesktop.family.haiku":`Haiku`,"claudeDesktop.modelCountOne":`{count} モデル`,"claudeDesktop.modelCountMany":`{count} モデル`,"claudeDesktop.chooseDefault":`デフォルトを選択`,"claudeDesktop.temporaryDefault":`一時的なデフォルト`,"claudeDesktop.laneEmpty":`ここにモデルをドロップするか、移動コントロールを使用してください。`,"claudeDesktop.laneNoMatch":`検索に一致するモデルはこのファミリーにありません。`,"nav.grok":`Grok`,"grok.title":`Grok Build`,"grok.subtitle":`opencodex が Grok 設定に登録したモデルです。`,"grok.loading":`Grok の状態を読み込み中…`,"grok.loadFail":`Grok 設定を読み取れませんでした。`,"grok.notConfiguredTitle":`Grok Build が未設定です`,"grok.notConfiguredHint":`Grok をインストールしてプロキシを再起動すると、opencodex が管理ブロックを次の場所に書き込みます:`,"grok.endpoint":`エンドポイント`,"grok.colModel":`モデル`,"grok.colAlias":`Grok エイリアス`,"grok.colContext":`コンテキスト`,"grok.groupNative":`ネイティブモデル`,"grok.groupRouted":`ルーティングモデル`,"grok.enabledCount":`{total} 件中 {on} 件を登録`,"grok.saved":`選択を保存しました。`,"grok.savedApplied":`選択を保存し、Grok 設定に反映しました。`,"grok.saveFailed":`Grok の選択を保存できませんでした。`,"grok.applyFailed":`選択は保存しましたが、Grok 設定を更新できませんでした。`,"grok.applySkipped":`選択は保存しましたが、Grok 設定は変更されませんでした。`,"grok.saveApply":`保存して適用`,"grok.saving":`保存中…`,"grok.applying":`適用中…`,"grok.unsaved":`未保存の変更`,"grok.upToDate":`選択は最新です`,"grok.toggleModel":`{id} を Grok に登録`,"claudeDesktop.available":`利用可能`,"claudeDesktop.defaultBadge":`既定`,"claudeDesktop.supports1m":`1M`,"claudeDesktop.unavailable":`利用不可`,"claudeDesktop.contextM":`{n}M コンテキスト`,"claudeDesktop.contextK":`{n}k コンテキスト`,"claudeDesktop.contextUnknown":`コンテキスト不明`,"claudeDesktop.alias":`エイリアス`,"claudeDesktop.useAsDefault":`{family} のデフォルトに設定`,"claudeDesktop.moveTo":`移動先`,"claudeDesktop.move":`移動`,"claudeDesktop.status.applied":`Desktop に適用済み`,"claudeDesktop.status.stale":`設定が古くなっています — 再適用してください`,"claudeDesktop.status.notApplied":`未適用`,"claudeDesktop.status.notActiveProfile":`Desktop は別のプロファイルを使用中 — 再適用してください`,"claudeDesktop.health.lastRequest":`最終リクエスト`,"claudeDesktop.health.stats":`{count} リクエスト / {errors} エラー`,"claudeDesktop.effort.supported":`effort`,"claudeDesktop.effort.displayOnly":`effort (表示のみ)`,"cws.loading":`コンボを読み込み中…`,"cws.loadFailed":`コンボを読み込めませんでした。`,"cws.saveFailed":`コンボを保存できませんでした。`,"cws.removeFailed":`コンボを削除できませんでした。`,"cws.saved":`コンボを保存しました。`,"cws.created":`{model} を作成しました。`,"cws.removed":`combo/{id} を削除しました。`,"cws.add":`コンボを追加`,"cws.addTitle":`コンボを追加`,"cws.addSubtitle":`プロバイダー全体にファンアウトする仮想モデルを作成します。クライアントは combo/<id> をリクエストします。`,"cws.create":`コンボを作成`,"cws.railAria":`コンボ一覧`,"cws.searchPlaceholder":`コンボやターゲットを検索…`,"cws.noSearchResults":`検索に一致するコンボがありません。`,"cws.group.failover":`フェイルオーバー`,"cws.group.roundRobin":`ラウンドロビン`,"cws.targetCount":`{count} ターゲット`,"cws.targetCountOne":`1 ターゲット`,"cws.overviewTitle":`コンボ`,"cws.overviewBlurb":`プロバイダー/モデルターゲット間でフェイルオーバーする、または決定論的で滑らかな重み付きラウンドロビンを使う仮想モデル。`,"cws.count.total":`合計`,"cws.count.failover":`フェイルオーバー`,"cws.count.roundRobin":`ラウンドロビン`,"cws.howTitle":`仕組み`,"cws.howBody":`Codex に combo/<id> を要求します。OpenCodex はターゲットを選び、再試行可能な上流の失敗時のみホップします。利用可能なターゲットが残っていない場合、グローバルなデフォルトプロバイダーを使わずにフェイルクローズします。`,"cws.attentionTitle":`要対応`,"cws.attention.empty":`ターゲットが設定されていません`,"cws.attention.few":`ターゲットが 1 つだけ — フェイルオーバーのホップ先がありません`,"cws.attention.catalogOmitted":`モデルカタログにありません — メンバー能力が不完全または非互換です(context window / メタデータ不足、または modality 交差が空)。エイリアス指定のルーティングは動作します`,"cws.emptyTitle":`最初のコンボを作成`,"cws.empty.createDesc":`仮想モデルに名前を付け、2 つ以上のバックエンドをつなぎます。`,"cws.backToAll":`すべてのコンボに戻る`,"cws.allCombos":`すべてのコンボ`,"cws.copyModel":`ID をコピー`,"cws.copied":`コピーしました`,"cws.renamed":`{from} を {to} に変更しました。`,"cws.tab.config":`設定`,"cws.tab.about":`概要`,"cws.strategy":`ストラテジー`,"cws.strategy.failover":`フェイルオーバー`,"cws.strategy.roundRobin":`ラウンドロビン`,"cws.strategy.failoverHint":`ターゲットを順に試します。最初が再試行可能なエラー(レート制限、障害、サブスクリプションゲート)で失敗した場合、次へホップします。`,"cws.strategy.roundRobinHint":`重みで決定論的にトラフィックを分散します。選んだターゲットを成功リクエストのバッチ分保持し、次へ進みます。`,"cws.field.id":`コンボ ID`,"cws.field.idHint":`クライアントは {model} をリクエストします`,"cws.field.idInternalHint":`コンボの内部 ID。作成後も変更できます。`,"cws.field.idHintEdit":`ID を変更するとコンボの名前が変更されます。クライアントは {model} をリクエストします。`,"cws.field.alias":`公開モデル名`,"cws.field.aliasPlaceholder":`deepseek-v4-flash または vendor/model`,"cws.field.aliasHint":`任意。プレフィックスなしの名前、vendor/model のようなカスタムプレフィックスを指定するか、空欄のままにすると combo/<id> を使用します。`,"cws.field.stickyLimit":`ローテーション前の固定成功数`,"cws.field.stickyLimitHint":`重み付きセレクタが進む前に、選んだターゲットをこの回数の成功リクエスト分保持します。`,"cws.field.defaultEffort":`デフォルトの推論`,"cws.field.defaultEffortNone":`なし(ターゲットのデフォルト)`,"cws.field.defaultEffortHint":`クライアントが推論負荷を省略した場合のみ使用されます。選択肢は選択ターゲットが広告する負荷の交差です。`,"cws.field.defaultEffortUnsupported":`この負荷はターゲット共通の階段にありません — リクエスト時に無視またはスナップされます。`,"cws.field.defaultEffortUnsupportedOption":`交差に含まれない`,"cws.targets":`ターゲット`,"cws.targets.failoverHint":`順序が重要 — 最初がプライマリです。`,"cws.targets.roundRobinHint":`重みが決定論的な相対選択を制御し、順序がローテーションリングの同点を解消します。`,"cws.target.provider":`プロバイダー`,"cws.target.model":`モデル`,"cws.target.weight":`重み`,"cws.target.pickProvider":`プロバイダーを選択…`,"cws.target.pickProviderFirst":`最初にプロバイダーを選択…`,"cws.target.pickModel":`モデルを選択…`,"cws.target.noModels":`このプロバイダーにモデルはありません`,"cws.target.modelPlaceholder":`モデル ID`,"cws.target.add":`ターゲットを追加`,"cws.target.drag":`ドラッグで並べ替え`,"cws.target.moveUp":`上へ移動`,"cws.target.moveDown":`下へ移動`,"cws.aboutTitle":`ランタイム`,"cws.aboutBody":`失敗したターゲットは Retry-After を尊重して短時間クールダウンします。無効またはコンテキストエラーはホップしません。各ターゲットは自身の能力に推論負荷を適応させます; 枯渇したコンボはフェイルクローズします。ログと使用量は順序付きの物理試行と試行ごとの使用量を保持します。`,"cws.removeConfirmTitle":`{model} を削除しますか?`,"cws.removeConfirmDesc":`これで仮想モデルが設定と Codex カタログから削除されます。プロバイダーは削除されません。`,"cws.unsavedTitle":`未保存の変更`,"cws.unsavedDesc":`このコンボへの編集を破棄して続行しますか?`,"cws.keepEditing":`編集を続ける`,"cws.err.missingId":`コンボ ID は必須です。`,"cws.err.invalidId":`ID は英字または数字で始まり、英数字、ドット、アンダースコア、ハイフンのみ使用できます(最大 64)。`,"cws.err.duplicateId":`この ID のコンボはすでに存在します。`,"cws.err.invalidAlias":`エイリアスには英字、数字、ドット、アンダースコア、ハイフンを使用でき、スラッシュ区切りは 1 つまでです。`,"cws.err.aliasReservedNamespace":`エイリアスに予約済みの "combo/" 名前空間は使用できません。`,"cws.err.aliasNativeFamily":`OpenAI ネイティブファミリー(gpt-*、o1-*、o3-*、o4-*、codex-*)のプレフィックスなしエイリアスは使用できません。`,"cws.err.duplicateAlias":`別のコンボがすでにこのエイリアスを使用しています。`,"cws.err.noTargets":`少なくとも 1 つのターゲットを追加してください。`,"cws.err.incompleteTarget":`各ターゲットにはプロバイダーとモデルが必要です。`,"cws.target.disabled":`{name}(無効)`,"cws.err.reservedNamespace":`combo という物理プロバイダーは、コンボ作成前に名前を変更する必要があります。`,"cws.err.providerCollision":`コンボ ID が設定されたプロバイダー名と衝突しています。`,"cws.err.unknownProvider":`各ターゲットは設定済みプロバイダーを使用する必要があります。`,"cws.err.duplicateTarget":`同じプロバイダー/モデルターゲットは一度しか使用できません。`,"cws.err.invalidStickyLimit":`固定成功数は 1 から 100 の整数にしてください。`,"cws.err.invalidWeight":`各ラウンドロビン重みは 1 から 10000 の整数にしてください。`,"cws.err.noEnabledTarget":`少なくとも 1 つのターゲットは有効なプロバイダーを使用する必要があります。`,"prov.editAlias":`Edit alias`,"prov.aliasPrompt":`Display name (leave empty to clear)`,"prov.aliasSaved":`Alias saved`,"prov.aliasSaveFailed":`Could not save alias`,"prov.accountId":`ID`,"models.customAdd":`Add custom model`,"models.customAddTitle":`Add custom model — {provider}`,"models.customEditTitle":`Edit custom model — {provider}`,"models.customAdded":`Custom model added`,"models.customUpdated":`Custom model updated`,"models.customDeleted":`Custom model deleted`,"models.customSaveFailed":`Failed to save custom model`,"models.customSaving":`Saving…`,"models.customAddBtn":`Add`,"models.customEditBtn":`Update`,"models.customEdit":`Edit`,"models.customDelete":`Delete`,"models.customDeleteConfirm":`Delete the {name} model?`,"models.customBadge":`Custom`,"models.customSummary":`{count} custom`,"models.customFieldModelId":`Model ID (endpoint slug)`,"models.customFieldModelIdPlaceholder":`e.g. qwen4-max-preview`,"models.customFieldDisplayName":`Display name (optional)`,"models.customFieldDisplayNamePlaceholder":`e.g. Qwen 4 Max Preview`,"models.customFieldContext":`Context window`,"models.customFieldModalities":`Input modalities`,"models.tipProvider":`Provider`,"models.tipContext":`Context`,"models.tipModalities":`Modalities`,"models.tipStatus":`Status`,"models.tipActive":`Active`,"models.tipDisabled":`Disabled`,"pws.estimatedCost":`Estimated cost`,"pws.costDisclaimer":`API list-price estimate, not an actual charge.`,"pws.modelBreakdown":`Model breakdown`,"pws.col.model":`Model`,"pws.col.cost":`Est. cost`,"pws.col.tokens":`Tokens`,"pws.col.requests":`Req.`,"pws.col.share":`Share`,"pws.tokenInput":`Input`,"pws.tokenOutput":`Output`,"dash.injectionManage":`設定を開く`,"sub.settings":`設定`,"sub.sections":`サブエージェントのセクション`,"sub.delegation.model":`最初に呼ぶモデル`,"sub.delegation.modelHint":`Codex が作業を任せるとき、最初に呼ぶモデルです。上のおすすめが呼べる候補で、ここで選んだものがその中の第一候補になります。`,"dash.syncModelsHint":`接続済みのプロバイダーをもとに Codex のモデルカタログを書き直します。`,"dash.syncRun":`今すぐ同期`}},Ie=[{code:`en`,name:`English`,htmlLang:`en`},{code:`de`,name:`Deutsch`,htmlLang:`de`},{code:`ko`,name:`한국어`,htmlLang:`ko`},{code:`zh`,name:`中文`,htmlLang:`zh-CN`},{code:`ru`,name:`Русский`,htmlLang:`ru`},{code:`ja`,name:`日本語`,htmlLang:`ja`}],Le=`ocx-lang`;function Re(){try{let e=localStorage.getItem(Le);if(e===`en`||e===`de`||e===`ko`||e===`zh`||e===`ru`||e===`ja`)return e}catch{}let e=typeof navigator<`u`?navigator.language.toLowerCase():`en`;return e.startsWith(`de`)?`de`:e.startsWith(`ko`)?`ko`:e.startsWith(`zh`)?`zh`:e.startsWith(`ru`)?`ru`:e.startsWith(`ja`)?`ja`:`en`}var ze=(0,_.createContext)(null);function Be(e,t){if(!t)return e;let n=e;for(let e of Object.keys(t))n=n.split(`{${e}}`).join(String(t[e]));return n}function Ve(){let e=(0,_.useContext)(ze);if(!e)throw Error(`useI18n must be used within LanguageProvider`);return e}function K(){return Ve().t}function He({children:e}){let[t,n]=(0,_.useState)(Re);(0,_.useEffect)(()=>{let e=Ie.find(e=>e.code===t)??Ie[0];document.documentElement.lang=e.htmlLang;try{localStorage.setItem(`ocx-lang`,t)}catch{}},[t]);let r=(0,_.useCallback)((e,n)=>Be(Fe[t][e]??Pe[e]??e,n),[t]),i=(0,_.useMemo)(()=>({locale:t,setLocale:n,t:r}),[t,r]);return(0,z.jsx)(ze.Provider,{value:i,children:e})}function Ue({k:e,cmd:t,vars:n}){let{t:r}=Ve(),[i,a=``]=r(e,n).split(`{cmd}`);return(0,z.jsxs)(z.Fragment,{children:[i,(0,z.jsx)(`code`,{className:`chip`,children:t}),a]})}function We(e){return e.replace(/^#\/?/,``)}function Ge(e,t=window){let n=We(e);if(We(t.location.hash)===n)return;let r=`${t.location.pathname}${t.location.search}#${n}`;t.history.replaceState(t.history.state,``,r)}function Ke(e,t=window){let n=We(e);We(t.location.hash)!==n&&(t.location.hash=n)}var qe=m(),Je=4,Ye=8,Xe=8,Ze=280,Qe=120,$e=160,et=12;function tt(){return typeof window<`u`?window.innerHeight:800}function nt(){return typeof window<`u`?window.innerWidth:1024}function rt(e,{align:t=`left`,placement:n=`below`,menuHeight:r=Ze}={}){let i=Math.min(Math.max(r,Qe),Ze),a=tt(),o=nt();if(n===`right`){let t=a-e.top-Xe,n=e.top-Xe,r=i+Ye>t&&n>t,s=Math.max(Xe,Math.min(e.right+et,o-$e-Xe));return r?{position:`fixed`,left:s,bottom:a-e.top+Ye,minWidth:$e,maxHeight:Math.max(Qe,Math.min(Ze,e.top-Xe-Je))}:{position:`fixed`,top:e.top,left:s,minWidth:$e,maxHeight:Math.max(Qe,Math.min(Ze,a-e.top-Xe))}}let s=Math.max(e.width,0),c=a-e.bottom-Xe,l=e.top-Xe;if(i+Je>c&&l>c){let n={position:`fixed`,bottom:a-e.top+Ye,minWidth:s,maxHeight:Math.max(0,Math.min(Ze,l-Je))};return t===`right`?n.right=o-e.right:n.left=Math.max(Xe,Math.min(e.left,o-Xe-s)),n}let u={position:`fixed`,top:e.bottom+Je,minWidth:s,maxHeight:Math.max(0,Math.min(Ze,c-Je))};return t===`right`?u.right=o-e.right:u.left=Math.max(Xe,Math.min(e.left,o-Xe-s)),u}function it({on:e,onClick:t,disabled:n,label:r}){return(0,z.jsx)(`button`,{type:`button`,className:`switch${e?` on`:``}`,onClick:t,disabled:n,"aria-pressed":e,"aria-label":r??(e?`enabled`:`disabled`),children:(0,z.jsx)(`span`,{className:`knob`})})}function q({tone:e,children:t}){return(0,z.jsxs)(`div`,{className:`notice ${e===`ok`?`notice-ok`:`notice-err`}`,role:`status`,children:[e===`ok`?(0,z.jsx)(ie,{}):(0,z.jsx)(de,{}),(0,z.jsx)(`span`,{children:t})]})}function at({value:e,options:t,onChange:n,disabled:r,label:i,id:a,style:o,align:s,placement:c,dropdownStyle:l,portal:u=!0}){let d=(0,_.useId)(),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(),y=(0,_.useRef)(null),b=(0,_.useRef)(null),x=(0,_.useRef)(null),S=(0,_.useCallback)(e=>`${d}-${e}`,[d]),C=t.find(t=>t.value===e),w=t.length===0?0:Math.max(0,t.findIndex(t=>t.value===e)),T=!f||t.length===0?w:Math.min(m??w,t.length-1),E=(0,_.useCallback)((e=!1)=>{p(!1),h(null),e&&b.current?.focus()},[]),D=(0,_.useCallback)(e=>{r||t.length===0||(h(Math.max(0,Math.min(t.length-1,e))),p(!0))},[r,t.length]),O=(0,_.useCallback)(e=>{if(!u)return;let t=b.current;t&&v(rt(t.getBoundingClientRect(),{align:s,placement:c,menuHeight:e}))},[s,c,u]);(0,_.useEffect)(()=>{if(!f)return;let e=e=>{let t=e.target;y.current?.contains(t)||x.current?.contains(t)||E()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[E,f]),(0,_.useLayoutEffect)(()=>{if(!f||!u)return;O();let e=()=>O(x.current?.offsetHeight);return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[f,t.length,u,O]),(0,_.useLayoutEffect)(()=>{if(!f||!u||!x.current||!b.current)return;let e=x.current.offsetHeight;if(!e)return;let t=rt(b.current.getBoundingClientRect(),{align:s,placement:c,menuHeight:e});v(e=>e?.top===t.top&&e?.bottom===t.bottom&&e?.maxHeight===t.maxHeight?e:t)},[s,f,t.length,c,u]),(0,_.useLayoutEffect)(()=>{!f||!x.current||x.current.querySelector(`[id="${S(T)}"]`)?.scrollIntoView({block:`nearest`})},[T,f,S]);let k=e=>{let r=t[e];r&&(n(r.value),E(!0))},A=e=>{if(!r)switch(e.key){case`ArrowDown`:e.preventDefault(),D(f?Math.min(t.length-1,T+1):w);break;case`ArrowUp`:e.preventDefault(),D(f?Math.max(0,T-1):w);break;case`Home`:e.preventDefault(),D(0);break;case`End`:e.preventDefault(),D(t.length-1);break;case`Enter`:case` `:e.preventDefault(),f?k(T):D(w);break;case`Escape`:f&&(e.preventDefault(),E(!0));break;case`Tab`:if(f){let e=t[T];e&&n(e.value),p(!1)}break;default:break}},j=f&&t[T]?S(T):void 0,M=f?(0,z.jsx)(`div`,{ref:x,id:d,className:`select-dropdown${u?` select-dropdown-portal`:``}${!u&&s===`right`?` select-dropdown-right`:``}${!u&&c===`right`?` select-dropdown-beside`:``}`,role:`listbox`,"aria-label":i,style:u?{...g,zIndex:60,...l}:l,children:t.map((t,n)=>(0,z.jsx)(`button`,{id:S(n),type:`button`,role:`option`,tabIndex:-1,"aria-selected":t.value===e,className:`select-option${t.value===e?` active`:``}${n===T?` select-option-active`:``}`,onMouseEnter:()=>h(n),onClick:()=>k(n),children:t.label},t.value))}):null;return(0,z.jsxs)(`div`,{ref:y,className:`custom-select`,style:{position:`relative`,display:`inline-block`,...o},children:[(0,z.jsxs)(`button`,{ref:b,id:a,type:`button`,role:`combobox`,className:`select-trigger`,onClick:()=>{r||(f?E():D(w))},onKeyDown:A,disabled:r,"aria-haspopup":`listbox`,"aria-expanded":f,"aria-controls":f?d:void 0,"aria-activedescendant":j,"aria-label":i,children:[(0,z.jsx)(`span`,{children:C?.label??e}),(0,z.jsx)(_e,{style:{width:12,height:12,color:`var(--muted)`,transform:f?`rotate(90deg)`:`none`,transition:`transform .12s`}})]}),u?M&&(0,qe.createPortal)(M,document.body):M]})}function ot({icon:e,title:t,children:n,className:r,style:i}){return(0,z.jsxs)(`div`,{className:r?`empty ${r}`:`empty`,style:i,children:[e,(0,z.jsx)(`div`,{className:`title`,children:t}),n&&(0,z.jsx)(`div`,{className:`text-control`,children:n})]})}function st({content:e,children:t,side:n=`top`,maxWidth:r=280}){let[i,a]=(0,_.useState)(!1),o=(0,_.useId)(),s=(0,_.useRef)(null),c=()=>{s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>a(!0),150)},l=()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null),a(!1)};return(0,_.useEffect)(()=>()=>{s.current!==null&&window.clearTimeout(s.current)},[]),(0,z.jsxs)(`button`,{type:`button`,className:`ocx-tooltip`,onMouseEnter:c,onMouseLeave:l,onFocus:c,onBlur:l,onKeyDown:e=>{e.key===`Escape`&&l()},"aria-describedby":i?o:void 0,style:{display:`inline`,border:0,background:`transparent`,padding:0,margin:0,color:`inherit`,font:`inherit`,cursor:`inherit`},children:[t,i&&(0,z.jsx)(`span`,{id:o,className:`ocx-tooltip-bubble ocx-tooltip-bubble--${n}`,role:`tooltip`,style:{maxWidth:r},children:e})]})}async function ct(e){if(e.status!==204){if(typeof e.text==`function`){let t=await e.text();return t.trim()?JSON.parse(t):void 0}return await e.json()}}function lt(e,t){return typeof e.error==`string`&&e.error?e.error:typeof e.message==`string`&&e.message?e.message:t}async function J(e,t=`HTTP ${e.status}`){if(!e.ok){let n=t;try{n=lt(await e.json(),t)}catch{}throw Error(n)}return ct(e)}async function ut(e){if(!e.ok)return null;try{return await ct(e)}catch{return null}}var dt=`dashboard/update`;function ft(){let e=window.location.hash.replace(/^#\/?/,``);return e===`dashboard/providers`?`providers`:e===`dashboard/models`?`models`:`overview`}function pt(){return window.location.hash.replace(/^#\/?/,``)===dt}function mt(e){return e===`overview`?`dashboard`:`dashboard/${e}`}async function ht(e,t){let n=await J(e,t);if(n===void 0)throw Error(t??`empty response`);return n}var gt=[`low`,`medium`,`high`,`xhigh`];function _t(e){return e?.includes(`-preview.`)?`preview`:`latest`}function vt(e,t){switch(e){case`source_checkout`:return t(`dash.updateReason.source_checkout`);case`latest_unavailable`:return t(`dash.updateReason.latest_unavailable`);case`already_latest`:return t(`dash.updateReason.already_latest`);default:return t(`dash.updateReason.unknown`)}}function yt(e,t){switch(e){case`running`:return t(`dash.updateStatus.running`);case`restarting`:return t(`dash.updateStatus.restarting`);case`succeeded`:return t(`dash.updateStatus.succeeded`);case`failed`:return t(`dash.updateStatus.failed`)}}function bt(e,t){let n={...e};return t?.model!==void 0&&(n.model=t.model),t?.backend===null?delete n.backend:t?.backend!==void 0&&(n.backend=t.backend),n}function xt(e){let t=[];for(let n of e)(n.provider===`openai`||n.provider===`anthropic`)&&t.push({value:n.id,label:`${n.provider}/${n.id}`});return t}function St(e,t){return e.find(e=>e.id===t)?.provider===`anthropic`?`anthropic`:`openai`}var Ct=!1;typeof window<`u`&&typeof window.addEventListener==`function`&&(window.addEventListener(`keydown`,()=>{Ct=!0},{capture:!0,passive:!0}),window.addEventListener(`pointerdown`,()=>{Ct=!1},{capture:!0,passive:!0}));function wt(e){if(e){if(Ct){e.focus({preventScroll:!0});return}try{e.focus({preventScroll:!0,focusVisible:!1})}catch{e.focus({preventScroll:!0})}}}function Tt(e,t){let n=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let r=n.current;if(r){if(e){r.open||r.showModal();return}r.open&&r.close(),wt(t.current)}},[e,t]),(0,_.useEffect)(()=>()=>{let e=n.current;e?.open&&e.close(),wt(t.current)},[t]),n}var Et=[`gpt-5.4-mini`,`gpt-5.6-luna`];function Dt(e){let t=Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim()!==``).map(e=>e.trim()):[];return t.length>0?t:Et}function Ot(e){return Dt(e).join(`, `)}function kt(e){return Dt(e).map(e=>e.replace(/^gpt-/,``)).join(`, `)}function At(e){let{t,updateOpen:n,closeUpdateDialog:r,updateDialogRef:i,updateChannel:a,changeUpdateChannel:o,updateLoading:s,updateError:c,updateCheck:l,fetchUpdateCheck:u,updateRestart:d,setUpdateRestart:f,runUpdate:p,maHelpOpen:m,setMaHelpOpen:h,maHelpDialogRef:g,effortCapHelpOpen:_,setEffortCapHelpOpen:v,effortCapHelpDialogRef:y,shadowCallHelpOpen:b,setShadowCallHelpOpen:x,shadowCallHelpDialogRef:S,shadowCall:C}=e;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dialog`,{ref:i,id:`dashboard-update-dialog`,className:`modal-overlay`,style:{display:n?`flex`:`none`,border:`none`,margin:0,maxWidth:`none`,maxHeight:`none`,width:`100%`,height:`100%`},"aria-labelledby":`update-title`,onCancel:e=>{e.preventDefault(),r()},children:(0,z.jsxs)(`div`,{className:`modal-card`,children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsx)(`h3`,{id:`update-title`,children:t(`dash.updateTitle`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon`,onClick:r,"aria-label":t(`common.cancel`),children:(0,z.jsx)(ae,{})})]}),(0,z.jsx)(`div`,{className:`modal-desc`,children:t(`dash.updateDesc`)}),(0,z.jsxs)(`div`,{className:`update-row`,children:[(0,z.jsx)(`label`,{className:`field-label`,htmlFor:`update-channel`,children:t(`dash.updateChannel`)}),(0,z.jsx)(at,{value:a,options:[{value:`latest`,label:`latest`},{value:`preview`,label:`preview`}],onChange:e=>o(e),disabled:s,label:t(`dash.updateChannel`),portal:!1})]}),s&&(0,z.jsx)(ot,{className:`update-empty`,icon:(0,z.jsx)(`span`,{className:`spin`}),title:t(`dash.updateChecking`)}),c&&(0,z.jsxs)(`div`,{className:`notice notice-err`,role:`status`,children:[(0,z.jsx)(de,{}),(0,z.jsx)(`span`,{children:c})]}),l&&!s&&(0,z.jsxs)(`div`,{className:`update-box`,children:[(0,z.jsxs)(`div`,{className:`spread`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`muted text-label`,children:t(`dash.updateInstalled`)}),(0,z.jsx)(`div`,{className:`mono`,children:l.currentVersion})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`muted text-label`,children:t(`dash.updateLatest`)}),(0,z.jsx)(`div`,{className:`mono`,children:l.latestVersion??`—`})]}),(0,z.jsx)(`span`,{className:`badge ${l.updateAvailable?`badge-green`:`badge-muted`}`,children:l.updateAvailable?t(`dash.updateAvailable`):t(`dash.updateCurrent`)})]}),(0,z.jsxs)(`div`,{className:`muted update-command`,children:[t(`dash.updateCommand`),` `,(0,z.jsx)(`code`,{className:`chip`,children:l.command})]}),l.reason===`source_checkout`&&(0,z.jsxs)(`div`,{className:`notice-warn`,role:`status`,children:[(0,z.jsx)(de,{}),` `,t(`dash.updateSource`)]}),l.reason===`latest_unavailable`&&(0,z.jsxs)(`div`,{className:`notice-warn`,role:`status`,children:[(0,z.jsx)(de,{}),` `,t(`dash.updateUnavailable`),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:s,onClick:()=>{u(a,!0)},style:{marginLeft:12},children:[(0,z.jsx)(se,{}),` `,t(`dash.updateRetry`)]})]}),!l.canUpdate&&l.reason!==`latest_unavailable`&&l.reason!==`source_checkout`&&(0,z.jsxs)(`div`,{className:`update-recheck`,children:[(0,z.jsx)(`span`,{className:`muted update-recheck-reason`,children:t(`dash.updateCannotAuto`,{reason:vt(l.reason,t)})}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:s,onClick:()=>{u(a,!0)},children:[(0,z.jsx)(se,{}),` `,t(s?`dash.updateChecking`:`dash.updateRecheck`)]})]}),l.canUpdate&&(0,z.jsxs)(`div`,{className:`spread update-restart`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:t(`dash.updateRestart`)}),(0,z.jsx)(`div`,{className:`muted text-label`,children:t(`dash.updateRestartHint`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`switch ${d?`on`:``}`,onClick:()=>f(e=>!e),"aria-label":t(`dash.updateRestart`),"aria-pressed":d,children:(0,z.jsx)(`span`,{className:`knob`})})]})]}),(0,z.jsxs)(`div`,{className:`modal-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:r,children:t(`common.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:p,disabled:!l?.canUpdate||s,children:t(`dash.runUpdate`)})]})]})}),(0,z.jsxs)(`dialog`,{ref:g,id:`multi-agent-help-dialog`,className:`modal-overlay`,style:{display:m?`flex`:`none`,border:`none`,margin:0,maxWidth:`none`,maxHeight:`none`,width:`100%`,height:`100%`},"aria-labelledby":`multi-agent-help-title`,onCancel:e=>{e.preventDefault(),h(!1)},children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":t(`common.close`),tabIndex:-1,onClick:()=>h(!1)}),(0,z.jsxs)(`div`,{className:`modal-card`,onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsx)(`h3`,{id:`multi-agent-help-title`,children:t(`dash.multiAgent`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon`,onClick:()=>h(!1),"aria-label":t(`common.close`),children:(0,z.jsx)(ae,{})})]}),(0,z.jsx)(`div`,{className:`modal-desc leading-relaxed`,style:{whiteSpace:`pre-line`},children:t(`models.v2Help`)}),(0,z.jsx)(`div`,{style:{marginTop:12},children:(0,z.jsx)(`a`,{className:`text-control`,href:`https://opencodex.me/guides/sub-agent-surface/`,target:`_blank`,rel:`noreferrer`,style:{color:`var(--accent)`},children:t(`models.v2DocsLink`)})}),(0,z.jsx)(`div`,{className:`modal-actions`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>h(!1),children:t(`common.ok`)})})]})]}),(0,z.jsxs)(`dialog`,{ref:y,id:`effort-cap-help-dialog`,className:`modal-overlay`,style:{display:_?`flex`:`none`,border:`none`,margin:0,maxWidth:`none`,maxHeight:`none`,width:`100%`,height:`100%`},"aria-labelledby":`effort-cap-help-title`,onCancel:e=>{e.preventDefault(),v(!1)},children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":t(`common.close`),tabIndex:-1,onClick:()=>v(!1)}),(0,z.jsxs)(`div`,{className:`modal-card`,onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsx)(`h3`,{id:`effort-cap-help-title`,children:t(`dash.effortCapLabel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon`,onClick:()=>v(!1),"aria-label":t(`common.close`),children:(0,z.jsx)(ae,{})})]}),(0,z.jsx)(`div`,{className:`modal-desc leading-relaxed`,style:{whiteSpace:`pre-line`},children:t(`dash.effortCapHelp`)}),(0,z.jsx)(`div`,{className:`modal-actions`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>v(!1),children:t(`common.ok`)})})]})]}),(0,z.jsxs)(`dialog`,{ref:S,id:`shadow-call-help-dialog`,className:`modal-overlay`,style:{display:b?`flex`:`none`,border:`none`,margin:0,maxWidth:`none`,maxHeight:`none`,width:`100%`,height:`100%`},"aria-labelledby":`shadow-call-help-title`,onCancel:e=>{e.preventDefault(),x(!1)},children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":t(`common.close`),tabIndex:-1,onClick:()=>x(!1)}),(0,z.jsxs)(`div`,{className:`modal-card`,onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsx)(`h3`,{id:`shadow-call-help-title`,children:t(`dash.shadowCallIntercept`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon`,onClick:()=>x(!1),"aria-label":t(`common.close`),children:(0,z.jsx)(ae,{})})]}),(0,z.jsx)(`div`,{className:`modal-desc leading-relaxed`,style:{whiteSpace:`pre-line`},children:t(`dash.shadowCallTooltip`,{models:Ot(C?.sourceModels)})}),(0,z.jsx)(`div`,{className:`modal-actions`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>x(!1),children:t(`common.ok`)})})]})]})]})}function jt({t:e,models:t,modelsLoading:n,modelQuery:r,setModelQuery:i,filteredGroups:a,expandedProviders:o,setExpandedProviders:s}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`h-section`,children:[e(`dash.availableModels`),` `,(0,z.jsx)(`span`,{className:`count`,children:t.length}),n&&(0,z.jsx)(`span`,{className:`spin`,style:{marginLeft:4}})]}),t.length===0&&!n?(0,z.jsx)(ot,{title:e(`dash.noModels`)}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`pws-search-wrap`,children:[(0,z.jsx)(pe,{className:`pws-search-icon`,width:14,height:14,"aria-hidden":`true`}),(0,z.jsx)(`input`,{type:`search`,className:`input pws-search-input`,placeholder:e(`models.search`),value:r,onChange:e=>i(e.target.value),"aria-label":e(`models.search`)})]}),a.length===0?(0,z.jsx)(`p`,{className:`muted text-control`,style:{margin:`4px 0`},children:e(`dash.modelsNoResults`)}):(0,z.jsx)(`div`,{className:`dash-model-acc`,children:a.map(([e,t])=>{let n=r.trim().toLowerCase()!==``||o.has(e);return(0,z.jsxs)(`div`,{className:`dash-model-group`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`dash-model-head`,onClick:()=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),"aria-expanded":n,children:[(0,z.jsx)(_e,{width:12,height:12,style:{transform:n?`rotate(90deg)`:`none`,transition:`transform .12s`,color:`var(--muted)`},"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`font-semibold`,children:e}),(0,z.jsx)(`span`,{className:`count`,children:t.length})]}),n&&(0,z.jsx)(`div`,{className:`dash-model-chips`,children:t.map(e=>(0,z.jsx)(`code`,{className:`dash-model-chip`,children:e.id},`${e.provider}/${e.id}`))})]},e)})})]})]})}var Mt={ko:[{v:0x2386f26fc10000,s:`경`},{v:0xe8d4a51000,s:`조`},{v:1e8,s:`억`},{v:1e4,s:`만`}],zh:[{v:0x2386f26fc10000,s:`京`},{v:0xe8d4a51000,s:`兆`},{v:1e8,s:`亿`},{v:1e4,s:`万`}]};function Nt(e){return e.replace(/\.0+$/,``).replace(/(\.\d*?)0+$/,`$1`)}function Pt(e,t){let n=Mt[t];if(n){for(let t of n)if(e>=t.v)return`${Nt((e/t.v).toFixed(1))}${t.s}`;return String(e)}return e<1e4?String(e):e<1e6?`${Nt((e/1e3).toFixed(1))}K`:e<1e9?`${Nt((e/1e6).toFixed(1))}M`:e<0xe8d4a51000?`${Nt((e/1e9).toFixed(1))}B`:`${Nt((e/0xe8d4a51000).toFixed(1))}T`}var Ft={en:{day:`d`,hour:`h`,minute:`m`,second:`s`},de:{day:`T`,hour:`Std`,minute:`Min`,second:`Sek`},ko:{day:`일`,hour:`시간`,minute:`분`,second:`초`},zh:{day:`天`,hour:`小时`,minute:`分钟`,second:`秒`},ru:{day:`д`,hour:`ч`,minute:`мин`,second:`с`},ja:{day:`日`,hour:`時間`,minute:`分`,second:`秒`}};function It(e,t){let n=Math.max(0,Math.floor(e)),r=Ft[t]??Ft.en;if(n<300)return`${n}${r.second}`;let i=Math.floor(n/60);if(i<60)return`${i}${r.minute}`;let a=Math.floor(i/60);if(a<24){let e=i%60;return e>0?`${a}${r.hour} ${e}${r.minute}`:`${a}${r.hour}`}let o=Math.floor(a/24),s=a%24;return s>0?`${o}${r.day} ${s}${r.hour}`:`${o}${r.day}`}function Lt({locale:e,health:t,providers:n,usage30d:r,usageLoading:i,healthLoading:a,startupHealth:o,projectConfigWarnings:s,maMode:c,maBusy:l,maHelpTriggerRef:u,maHelpOpen:d,setMaHelpOpen:f,switchMaMode:p}){let m=K(),h=t?.status===`ok`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`dash-overview-head`,children:[(0,z.jsxs)(`div`,{className:`stat-row`,children:[(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsxs)(`div`,{className:`label`,style:{display:`flex`,alignItems:`center`,gap:6},children:[m(`dash.multiAgent`),(0,z.jsx)(`button`,{ref:u,type:`button`,className:`btn btn-ghost btn-sm`,style:{width:24,height:24,minWidth:24,flex:`0 0 24px`,padding:0,borderRadius:`var(--radius-pill)`,color:`var(--muted)`},onClick:()=>f(!0),"aria-label":m(`dash.multiAgent`),"aria-haspopup":`dialog`,"aria-controls":`multi-agent-help-dialog`,"aria-expanded":d,children:(0,z.jsx)(fe,{width:14,height:14,"aria-hidden":`true`})})]}),(0,z.jsx)(`div`,{className:`value`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,z.jsx)(`div`,{role:`radiogroup`,"aria-label":m(`dash.multiAgent`),style:{display:`inline-flex`,borderRadius:`var(--radius-pill)`,background:`var(--surface-soft, var(--raised))`,padding:3,gap:2},children:[`v1`,`default`,`v2`].map(e=>(0,z.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":c===e,className:`btn btn-sm text-caption${c===e?` btn-primary`:` btn-ghost`}`,style:{borderRadius:`var(--radius-pill)`,minWidth:36,padding:`5px 10px`,border:`none`,background:c===e?void 0:`transparent`,color:c===e?void 0:`var(--muted)`},disabled:l,onClick:()=>void p(e),children:m(`models.v2Mode_${e}`)},e))})})]}),(0,z.jsxs)(`div`,{className:`stat`,"aria-busy":a||void 0,children:[(0,z.jsx)(`div`,{className:`label`,children:m(`dash.status`)}),(0,z.jsxs)(`div`,{className:`value`,style:{display:`flex`,alignItems:`center`,gap:9,color:h?`var(--green)`:`var(--red)`},children:[(0,z.jsx)(`span`,{className:`dot ${h?`dot-green`:`dot-red`}`}),m(h?`dash.online`:`dash.offline`)]})]}),(0,z.jsxs)(`div`,{className:`stat`,"aria-busy":a||void 0,children:[(0,z.jsx)(`div`,{className:`label`,children:m(`dash.version`)}),(0,z.jsx)(`div`,{className:`value mono`,children:t?.version??`—`})]}),(0,z.jsxs)(`div`,{className:`stat`,"aria-busy":a||void 0,children:[(0,z.jsx)(`div`,{className:`label`,children:m(`dash.uptime`)}),(0,z.jsx)(`div`,{className:`value mono`,children:t?It(t.uptime,e):`—`})]}),(0,z.jsxs)(`div`,{className:`stat`,"aria-busy":a||void 0,children:[(0,z.jsx)(`div`,{className:`label`,children:m(`dash.providers`)}),(0,z.jsx)(`div`,{className:`value`,children:n.length})]}),(0,z.jsxs)(`div`,{className:`stat`,"aria-busy":i||void 0,children:[(0,z.jsx)(`div`,{className:`label`,children:m(`dash.tokens30d`)}),(0,z.jsx)(`div`,{className:`value mono`,children:r&&r.summary.requests>0?Pt(r.summary.totalTokens,e):`—`}),(0,z.jsx)(`div`,{className:`muted text-label dash-stat-coverage`,children:r&&r.summary.requests>0?m(`dash.coverage`).replace(`{pct}`,`${Math.round(r.summary.coverageRatio*100)}%`):`\xA0`})]})]}),(0,z.jsx)(`div`,{className:`startup-health-slot`,"aria-live":`polite`,children:o?(0,z.jsxs)(`a`,{className:`startup-health-bar`,href:`#startup`,children:[(0,z.jsx)(`span`,{className:`dot ${o===`error`?`dot-red`:o===`at-risk`?`dot-amber`:`dot-green`}`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`startup-health-bar__summary`,children:m(o===`error`?`startup.error`:o===`at-risk`?`startup.summary.atRisk`:o===`protected`?`startup.summary.protected`:`startup.summary.native`)})]}):(0,z.jsxs)(`div`,{className:`startup-health-bar startup-health-bar--pending`,"aria-hidden":`true`,children:[(0,z.jsx)(`span`,{className:`dot dot-amber`}),(0,z.jsx)(`span`,{className:`startup-health-bar__summary`,children:`\xA0`})]})})]}),s.length>0&&(0,z.jsxs)(`div`,{className:`notice notice-err maintenance-notice`,role:`alert`,children:[(0,z.jsx)(de,{}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:m(`dash.projectConfigTitle`)}),(0,z.jsx)(`div`,{className:`muted text-control`,style:{marginTop:4},children:m(`dash.projectConfigHint`)}),(0,z.jsx)(`ul`,{className:`text-control`,style:{margin:`10px 0 0`,paddingLeft:18},children:s.map(e=>(0,z.jsxs)(`li`,{style:{marginBottom:8},children:[(0,z.jsx)(`code`,{children:e.path}),` — `,e.issues.join(`, `),(0,z.jsx)(`div`,{className:`muted`,style:{marginTop:2},children:e.bypass})]},e.path))})]})]})]})}function Rt(e){let t=new AbortController;if(typeof AbortSignal<`u`&&typeof AbortSignal.any==`function`&&typeof AbortSignal.timeout==`function`)return{controller:t,signal:AbortSignal.any([t.signal,AbortSignal.timeout(e)]),clear:()=>void 0};let n=setTimeout(()=>t.abort(),e);return{controller:t,signal:t.signal,clear:()=>clearTimeout(n)}}var zt=new Map;function Bt(e,t){let n=`${e}:${t}`,r=zt.get(n);return r||(r=new Intl.NumberFormat(e,{minimumFractionDigits:t,maximumFractionDigits:t}),zt.set(n,r)),r}var Vt=new Map;function Ht(e){let t=Vt.get(e);return t||(t=new Intl.NumberFormat(e),Vt.set(e,t)),t}function Ut(e,t){if(!Number.isFinite(e)||e<=0)return`0 B`;let n=[`B`,`KiB`,`MiB`,`GiB`,`TiB`],r=Math.min(Math.floor(Math.log(e)/Math.log(1024)),n.length-1),i=e/1024**r;return`${Bt(t,r===0?0:1).format(i)} ${n[r]}`}function Wt(e,t){return!Number.isFinite(e)||e<0?`—`:It(e/1e3,t)}function Gt(e){return typeof e.observedBytes==`number`?e.observedBytes:Math.max(e.rss,e.external??0,e.arrayBuffers??0)}function Kt(e){if(e.observedMetric)return e.observedMetric;if(e.watchdog?.observedMetric)return e.watchdog.observedMetric;let t=[{metric:`rss`,bytes:e.rss},{metric:`external`,bytes:e.external??0},{metric:`arrayBuffers`,bytes:e.arrayBuffers??0}];return t.reduce((e,t)=>t.bytes>e.bytes?t:e,t[0]).metric}function qt(e){if(e.length<2)return null;let t=e[0],n=e[e.length-1],r=n.at-t.at;return r<=0?null:(Gt(n)-Gt(t))/r*36e5}function Jt({label:e,value:t,sub:n,tone:r}){return(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:e}),(0,z.jsx)(`div`,{className:`value mono${r?` value--${r}`:``}`,children:t}),n&&(0,z.jsx)(`div`,{className:`stat-sub mono`,children:n})]})}function Yt({observedBytes:e,thresholdBytes:t,metric:n,locale:r,t:i}){let a=e!==null&&t!==null&&t>0?e/t:null,o=a===null?`unknown`:a>=1?`over`:a>=.75?`warn`:`ok`,s=a===null?null:Math.round(a*100);return(0,z.jsxs)(`div`,{className:`mem-pressure mem-pressure--${o}`,children:[(0,z.jsxs)(`div`,{className:`mem-pressure-head`,children:[(0,z.jsxs)(`span`,{className:`mem-pressure-label`,children:[i(`dash.mem.pressure`),n?(0,z.jsx)(`span`,{className:`mem-pressure-metric mono`,children:n}):null]}),(0,z.jsxs)(`span`,{className:`mem-pressure-figure mono`,children:[e===null?`—`:Ut(e,r),t!==null&&(0,z.jsxs)(`span`,{className:`mem-pressure-limit`,children:[` / `,Ut(t,r)]})]})]}),(0,z.jsx)(`div`,{className:`mem-pressure-track`,role:`presentation`,children:(0,z.jsx)(`span`,{className:`mem-pressure-fill`,style:{"--mem-scale":String(a===null?0:Math.min(1,Math.max(.01,a)))}})}),(0,z.jsx)(`div`,{className:`mem-pressure-foot`,children:s===null?i(`dash.mem.pressureUnknown`):i(`dash.mem.pressureOf`,{pct:s})})]})}var Xt=60,Zt=1500,Qt=12e4;function $t({apiBase:e}){let{locale:t,t:n}=Ve(),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(`idle`),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null);(0,_.useEffect)(()=>{let t=!1;return(async()=>{try{let n=await fetch(`${e}/api/startup-health`);if(!n.ok||t)return;let r=await n.json();t||f(r.protection===`none`)}catch{}})(),()=>{t=!0}},[e]),(0,_.useEffect)(()=>{let t=!1,n=!1,r=null,a=async()=>{if(n)return;n=!0;let a=Rt(1e4);r=a;try{let n=await fetch(`${e}/api/system/memory`,{signal:a.signal});if(!n.ok)throw Error(`memory unavailable`);let r=await n.json();if(t)return;i(r),o(!1),m(typeof r.activeTurnCount==`number`),r.isDraining&&s===`idle`&&c(`draining`),(s===`draining`||s===`reconnecting`)&&h!=null&&typeof r.pid==`number`&&r.pid!==h&&!r.isDraining&&(c(`idle`),g(null),u(null))}catch{if(t)return;s===`draining`||s===`reconnecting`?c(`reconnecting`):o(!0)}finally{a.clear(),r===a&&(r=null),n=!1}};a();let l=setInterval(()=>void a(),5e3);return()=>{t=!0,r?.controller.abort(),r?.clear(),clearInterval(l)}},[e,s,h]),(0,_.useEffect)(()=>{if(s!==`reconnecting`)return;let t=!1,r=!1,i=null,a=Date.now(),o=()=>{if(r||t)return;r=!0;let o=Rt(5e3);i=o,fetch(`${e}/healthz`,{cache:`no-store`,signal:o.signal}).then(async e=>{if(t)return;if(!e.ok){Date.now()-a>=Qt&&(c(`error`),u(n(`dash.mem.restartFailed`)));return}let r=h==null;if(h!=null)try{let t=await e.json();r=typeof t.pid==`number`&&t.pid!==h}catch{r=!0}if(!t){if(r){c(`idle`),g(null),u(null);return}Date.now()-a>=Qt&&(c(`error`),u(n(`dash.mem.restartFailed`)))}}).catch(()=>{t||Date.now()-a>=Qt&&(c(`error`),u(n(`dash.mem.restartFailed`)))}).finally(()=>{o.clear(),i===o&&(i=null),r=!1})};o();let l=setInterval(o,Zt);return()=>{t=!0,i?.controller.abort(),i?.clear(),clearInterval(l)}},[e,s,h,n]);let v=()=>{let t=[n(`dash.mem.restartConfirm`,{count:r?.activeTurnCount??0,seconds:Xt})];d&&t.push(n(`dash.mem.restartNoSupervisor`)),window.confirm(t.join(`
46
46
 
47
- `))&&(async()=>{u(null),g(typeof r?.pid==`number`?r.pid:null),c(`draining`);try{if(!(await fetch(`${e}/api/system/restart`,{method:`POST`})).ok)throw Error(`restart_failed`)}catch{c(`error`),g(null),u(n(`dash.mem.restartFailed`))}})()};if(a&&!r&&s===`idle`)return(0,z.jsxs)(`div`,{className:`panel`,style:{marginBottom:24},children:[(0,z.jsxs)(`div`,{className:`font-semibold`,style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,z.jsx)(re,{width:16,height:16,"aria-hidden":`true`}),n(`dash.mem.title`)]}),(0,z.jsx)(`div`,{className:`muted text-control`,style:{marginTop:8},children:n(`dash.mem.unavailable`)})]});let y=r?.watchdog?qt(r.watchdog.samples):null,b=r?r.observedBytes??r.watchdog?.observedBytes??Gt(r):null,x=r?Kt(r):null,S=(()=>{let e=r?.watchdog?.warnThresholdBytes;if(y===null||y<=0||b===null||!e)return;let t=e-b;if(t<=0)return`danger`;let n=t/y;if(n<=1)return`danger`;if(n<=8)return`warn`})(),C=r?.responseState,w=r?.activeTurnCount,T=s===`draining`||s===`reconnecting`;return(0,z.jsxs)(`div`,{className:`panel`,style:{marginBottom:24},children:[(0,z.jsxs)(`div`,{className:`mem-head`,children:[(0,z.jsxs)(`div`,{className:`font-semibold mem-head-title`,children:[(0,z.jsx)(re,{width:16,height:16,"aria-hidden":`true`}),n(`dash.mem.title`)]}),p&&(0,z.jsxs)(`div`,{className:`mem-head-actions`,children:[(0,z.jsxs)(`span`,{className:`mem-inflight`,children:[(0,z.jsx)(`span`,{className:`mem-inflight-label`,children:n(`dash.mem.inFlight`)}),(0,z.jsx)(`span`,{className:`mem-inflight-value mono`,children:typeof w==`number`?Ht(t).format(w):`—`})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:T,onClick:v,children:n(`dash.mem.restart`)})]})]}),(0,z.jsx)(Yt,{observedBytes:b,thresholdBytes:r?.watchdog?.warnThresholdBytes??null,metric:x,locale:t,t:n}),(0,z.jsxs)(`div`,{className:`stat-row mem-stats`,children:[(0,z.jsx)(Jt,{label:n(`dash.mem.rss`),value:r?Ut(r.rss,t):`—`}),(0,z.jsx)(Jt,{label:n(`dash.mem.jsHeap`),value:r?Ut(r.heapUsed,t):`—`,sub:r?n(`dash.mem.jsHeapArena`,{total:Ut(r.heapTotal,t)}):void 0}),(0,z.jsx)(Jt,{label:n(`dash.mem.jscHeap`),value:r?.jscHeap?Ut(r.jscHeap.heapSize,t):`—`}),(0,z.jsx)(Jt,{label:n(`dash.mem.growth`),value:y===null?`—`:`${y>=0?`+`:`−`}${Ut(Math.abs(y),t)}${n(`dash.mem.perHour`)}`,tone:S})]}),(0,z.jsxs)(`details`,{style:{marginTop:10},children:[(0,z.jsx)(`summary`,{className:`muted text-label`,style:{cursor:`pointer`,padding:`2px 2px`},children:n(`dash.mem.details`)}),(0,z.jsx)(`div`,{className:`muted text-control`,style:{margin:`8px 0 0`},children:n(`dash.mem.hint`)}),(0,z.jsx)(`div`,{className:`muted text-label`,style:{margin:`14px 0 6px`},children:n(`dash.mem.runtime`)}),(0,z.jsxs)(`div`,{className:`stat-row`,children:[(0,z.jsx)(Jt,{label:n(`dash.mem.observed`),value:b===null?`—`:`${Ut(b,t)} (${x})`}),(0,z.jsx)(Jt,{label:n(`dash.mem.external`),value:r?.external===void 0?`—`:Ut(r.external,t)}),(0,z.jsx)(Jt,{label:n(`dash.mem.arrayBuffers`),value:r?.arrayBuffers===void 0?`—`:Ut(r.arrayBuffers,t)})]}),(0,z.jsx)(`div`,{className:`muted text-label`,style:{margin:`14px 0 6px`},children:n(`dash.mem.store`)}),(0,z.jsx)(`div`,{className:`muted text-control`,style:{marginBottom:10},children:n(`dash.mem.storeHint`)}),(0,z.jsxs)(`div`,{className:`stat-row`,children:[(0,z.jsx)(Jt,{label:n(`dash.mem.storeEntries`),value:C?Ht(t).format(C.count):`—`}),(0,z.jsx)(Jt,{label:n(`dash.mem.storeTotal`),value:C?Ut(C.totalBytes,t):`—`}),(0,z.jsx)(Jt,{label:n(`dash.mem.storeLargest`),value:C?Ut(C.largestBytes,t):`—`}),(0,z.jsx)(Jt,{label:n(`dash.mem.storeOldest`),value:C?C.count===0?`—`:Wt(C.oldestAgeMs,t):`—`})]}),r?.watchdog&&(0,z.jsxs)(`div`,{className:`stat-row`,style:{marginTop:16},children:[(0,z.jsx)(Jt,{label:n(`dash.mem.threshold`),value:Ut(r.watchdog.warnThresholdBytes,t)}),(0,z.jsx)(Jt,{label:n(`dash.mem.lastWarn`),value:r.watchdog.lastWarnAt?new Date(r.watchdog.lastWarnAt).toLocaleString(t):n(`dash.mem.never`)})]})]}),p&&(0,z.jsxs)(`div`,{className:`mem-status`,"aria-live":`polite`,children:[s===`draining`&&(0,z.jsx)(`span`,{className:`muted text-control`,children:n(`dash.mem.draining`,{count:typeof w==`number`?w:0})}),s===`reconnecting`&&(0,z.jsx)(`span`,{className:`muted text-control`,children:n(`dash.mem.reconnecting`)}),s===`error`&&l&&(0,z.jsx)(`span`,{className:`text-control`,style:{color:`var(--danger, #c44)`},children:l}),d&&s===`idle`&&(0,z.jsx)(`span`,{className:`muted text-control`,children:n(`dash.mem.restartNoSupervisor`)})]})]})}function en({apiBase:e,d:t}){let{t:n,maMode:r,maModeResolved:i,effortCapHelpTriggerRef:a,effortCapHelpOpen:o,setEffortCapHelpOpen:s,effortCap:c,subagentEffortCap:l,effortCapSaving:u,setEffortCap:d,setSubagentEffortCap:f,setEffortCapSaving:p}=t;return!i||r===`v1`?null:(0,z.jsx)(`div`,{className:`panel`,children:(0,z.jsxs)(`div`,{className:`injection-head`,children:[(0,z.jsxs)(`span`,{className:`injection-label`,style:{display:`inline-flex`,alignItems:`center`,gap:6},children:[n(`dash.effortCapLabel`),(0,z.jsx)(`button`,{ref:a,type:`button`,className:`btn btn-ghost btn-sm`,style:{width:22,height:22,minWidth:22,padding:0,borderRadius:`var(--radius-pill)`,color:`var(--muted)`},onClick:()=>s(e=>!e),"aria-label":n(`dash.effortCapLabel`),"aria-expanded":o,"aria-haspopup":`dialog`,"aria-controls":`effort-cap-help-dialog`,children:(0,z.jsx)(fe,{width:13,height:13,"aria-hidden":`true`})})]}),(0,z.jsx)(at,{value:c,options:[{value:``,label:n(`dash.effortCapNone`)},...gt.map(e=>({value:e,label:e}))],onChange:async t=>{if(!u){p(!0);try{let n=await ht(await fetch(`${e}/api/effort-caps`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({effortCap:t||null})}));d(n.effortCap??``),f(n.subagentEffortCap??``)}catch{}finally{p(!1)}}},disabled:u,label:n(`dash.effortCapLabel`)}),(0,z.jsx)(at,{value:l,options:[{value:``,label:n(`dash.effortCapNone`)},...gt.map(e=>({value:e,label:e}))],onChange:async t=>{if(!u){p(!0);try{let n=await ht(await fetch(`${e}/api/effort-caps`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({subagentEffortCap:t||null})}));d(n.effortCap??``),f(n.subagentEffortCap??``)}catch{}finally{p(!1)}}},disabled:u,label:n(`dash.subagentEffortCapLabel`)})]})})}function tn({d:e}){let{t,injectionModel:n,injectionEffort:r,injectionEfforts:i,injectionAvailable:a,injectionSaving:o,saveInjection:s}=e;return(0,z.jsxs)(`div`,{className:`panel dash-delegation-summary`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:t(`dash.injectionLabel`)}),(0,z.jsxs)(`div`,{className:`dash-delegation-controls`,children:[(0,z.jsx)(at,{value:n,options:[{value:``,label:t(`dash.injectionNone`)},...a.map(e=>({value:e.namespaced,label:`${e.provider} / ${e.model}`}))],onChange:e=>{s({model:e||null,effort:r||null})},disabled:o,label:t(`dash.injectionLabel`)}),n&&i.length>0&&(0,z.jsx)(at,{value:r,options:[{value:``,label:t(`dash.injectionEffortNone`)},...i.map(e=>({value:e,label:e}))],onChange:e=>{s({model:n||null,effort:e||null})},disabled:o,label:t(`dash.injectionEffortLabel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>Ke(`#subagents`),children:t(`dash.injectionManage`)})]})]})}function nn({d:e}){let{t,runSync:n,syncing:r,updateTriggerRef:i,openUpdateDialog:a,updateLoading:o,updateOpen:s,syncResult:c,syncError:l,updateJob:u,reconnecting:d}=e;return(0,z.jsxs)(`div`,{className:`panel maintenance-panel`,children:[(0,z.jsxs)(`div`,{className:`dash-sync-summary`,children:[(0,z.jsxs)(`div`,{className:`dash-sync-copy`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:t(`dash.syncModels`)}),(0,z.jsx)(`div`,{className:`muted text-control dash-sync-hint`,children:t(`dash.syncModelsHint`)})]}),(0,z.jsxs)(`div`,{className:`maintenance-actions`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:n,disabled:r,children:[(0,z.jsx)(se,{}),` `,t(r?`dash.syncing`:`dash.syncRun`)]}),(0,z.jsx)(`button`,{ref:i,type:`button`,className:`maintenance-update-anchor`,onClick:a,disabled:o,"aria-haspopup":`dialog`,"aria-controls":`dashboard-update-dialog`,"aria-expanded":s,"aria-label":t(`dash.checkUpdate`),tabIndex:-1})]})]}),c&&(0,z.jsxs)(`div`,{className:`notice ${c.nativeSubagentDefaultsWarning?`notice-warn`:`notice-ok`} maintenance-notice`,role:`status`,children:[c.nativeSubagentDefaultsWarning?(0,z.jsx)(de,{}):(0,z.jsx)(se,{}),(0,z.jsxs)(`span`,{children:[t(`dash.syncOk`,{count:c.added}),c.warning?` ${c.warning}`:``,c.nativeSubagentDefaultsWarning?` ${c.nativeSubagentDefaultsWarning}`:``,c.staleAppServerHint?(0,z.jsxs)(z.Fragment,{children:[` `,(0,z.jsx)(Ue,{k:`dash.syncStaleHint`,cmd:`ocx sync --restart-codex`})]}):null]})]}),l&&(0,z.jsxs)(`div`,{className:`notice notice-err maintenance-notice`,role:`status`,children:[(0,z.jsx)(de,{}),(0,z.jsx)(`span`,{children:t(`dash.syncFailed`,{error:l})})]}),u&&(0,z.jsxs)(`div`,{className:`notice ${u.status===`failed`?`notice-err`:`notice-ok`} maintenance-notice`,role:`status`,children:[u.status===`failed`?(0,z.jsx)(de,{}):(0,z.jsx)(se,{}),(0,z.jsxs)(`span`,{children:[yt(u.status,t),u.latestVersion?` ${u.currentVersion} -> ${u.latestVersion}.`:``,d?` ${t(`dash.updateReconnecting`)}`:``,u.error?` ${u.error}`:``]})]})]})}function rn({d:e}){let{t,settings:n,settingsSaving:r,toggleCodexAutoStart:i,sidecar:a,sidecarSaving:o,sidecarModels:s,models:c,saveSidecar:l,shadowCall:u,shadowCallSaving:d,shadowCallHelpTriggerRef:f,shadowCallHelpOpen:p,setShadowCallHelpOpen:m,saveShadowCall:h}=e;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`panel`,children:(0,z.jsxs)(`div`,{className:`spread`,children:[(0,z.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:t(`dash.codexAutoStart`)}),(0,z.jsx)(`div`,{className:`muted setting-hint`,children:t(`dash.codexAutoStartHint`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`switch ${n?.codexAutoStart??!0?`on`:``}`,onClick:i,disabled:!n||r,"aria-label":t(`dash.codexAutoStart`),"aria-pressed":n?.codexAutoStart??!0,children:(0,z.jsx)(`span`,{className:`knob`})})]})}),(0,z.jsxs)(`div`,{className:`dash-sidecar-grid`,children:[(0,z.jsxs)(`div`,{className:`panel dash-sidecar-card`,"aria-busy":!a||void 0,children:[(0,z.jsxs)(`div`,{className:`dash-sidecar-card__row`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:t(`dash.webSearchSidecar`)}),(0,z.jsx)(at,{value:a?.webSearch.model??`gpt-5.6-luna`,options:s,onChange:e=>{l({webSearch:{model:e,backend:St(c,e)}})},disabled:!a||o,label:t(`dash.sidecarModel`)})]}),(0,z.jsx)(`div`,{className:`muted setting-hint`,children:t(`dash.webSearchSidecarHint`)})]}),(0,z.jsxs)(`div`,{className:`panel dash-sidecar-card`,"aria-busy":!a||void 0,children:[(0,z.jsxs)(`div`,{className:`dash-sidecar-card__row`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:t(`dash.visionSidecar`)}),(0,z.jsx)(at,{value:a?.vision.model??`gpt-5.6-luna`,options:s,onChange:e=>{l({vision:{model:e,backend:St(c,e)}})},disabled:!a||o,label:t(`dash.sidecarModel`)})]}),(0,z.jsx)(`div`,{className:`muted setting-hint`,children:t(`dash.visionSidecarHint`)})]})]}),(0,z.jsx)(`div`,{className:`panel`,"aria-busy":!u||void 0,children:(0,z.jsxs)(`div`,{className:`spread`,style:{alignItems:`center`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,z.jsx)(`span`,{className:`font-semibold`,children:t(`dash.shadowCallIntercept`)}),(0,z.jsx)(`button`,{ref:f,type:`button`,className:`btn btn-ghost btn-sm`,style:{width:22,height:22,minWidth:22,padding:0,borderRadius:`var(--radius-pill)`,color:`var(--muted)`},onClick:()=>m(e=>!e),"aria-label":t(`dash.shadowCallIntercept`),"aria-expanded":p,"aria-haspopup":`dialog`,"aria-controls":`shadow-call-help-dialog`,children:(0,z.jsx)(fe,{width:13,height:13,"aria-hidden":`true`})}),(0,z.jsx)(`code`,{className:`muted text-caption`,children:`⚠ ${kt(u?.sourceModels)}`})]}),(0,z.jsxs)(`div`,{className:`setting-controls`,style:{display:`flex`,gap:8,alignItems:`center`},children:[(0,z.jsx)(`button`,{type:`button`,className:`switch ${u?.enabled?`on`:``}`,onClick:()=>h({enabled:!u?.enabled}),disabled:!u||d,"aria-label":t(`dash.shadowCallIntercept`),"aria-pressed":u?.enabled??!1,children:(0,z.jsx)(`span`,{className:`knob`})}),(0,z.jsx)(at,{value:u?.model??``,options:[{value:``,label:`—`},...c.map(e=>({value:e.id,label:`${e.provider}/${e.id}`}))],onChange:e=>{h({model:e})},disabled:!u||d||!u?.enabled,label:t(`dash.shadowCallModel`),align:`right`})]})]})})]})}function an(e){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(en,{apiBase:e.apiBase,d:e}),(0,z.jsxs)(`div`,{className:`dash-overview-tools`,children:[(0,z.jsx)(tn,{apiBase:e.apiBase,d:e}),(0,z.jsx)(nn,{d:e})]}),(0,z.jsx)(rn,{d:e}),(0,z.jsx)($t,{apiBase:e.apiBase})]})}function on(e){return(0,z.jsxs)(`div`,{className:`dash-overview-stack`,children:[(0,z.jsx)(Lt,{...e}),(0,z.jsx)(an,{...e})]})}function sn({t:e,providers:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`h-section`,children:[e(`dash.activeProviders`),` `,(0,z.jsx)(`span`,{className:`count`,children:t.length})]}),t.length===0?(0,z.jsx)(ot,{title:(0,z.jsx)(Ue,{k:`dash.noProviders`,cmd:`ocx init`})}):(0,z.jsx)(`div`,{className:`tbl-wrap`,children:(0,z.jsxs)(`table`,{className:`tbl`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:e(`dash.col.name`)}),(0,z.jsx)(`th`,{children:e(`dash.col.adapter`)}),(0,z.jsx)(`th`,{children:e(`dash.col.baseUrl`)}),(0,z.jsx)(`th`,{children:e(`dash.col.model`)})]})}),(0,z.jsx)(`tbody`,{children:t.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`font-semibold`,children:e.name}),(0,z.jsx)(`td`,{children:(0,z.jsx)(`span`,{className:`chip`,children:e.adapter})}),(0,z.jsx)(`td`,{className:`muted mono text-label`,children:e.baseUrl}),(0,z.jsx)(`td`,{className:`muted`,children:e.defaultModel??`—`})]},e.name))})]})})]})}function Y(e){try{let t=sessionStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function X(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch{}}function cn(e){return e.routingKind===`custom-local`?`startup.riskDetailCustomLocal`:e.shimCoverage===`cli-only`?`startup.riskDetailWindowsShim`:`startup.riskDetail`}function ln(e,t){return!t.mutationInFlight&&e.request===t.request&&e.mutation===t.mutation}function un(e,t){return{request:++e.current,mutation:t.current}}var dn=2e3;function fn(e){let t=e.status;return t===`native`||t===`protected`||t===`at-risk`?t:null}function pn(e){return e?e.stale&&e.status!==`error`:!1}function mn(e,t){return!t||e!==null&&e!==`error`?e:t.status}var hn=3e4;function gn(e){return{multiAgentGuidanceEnabled:e.multiAgentGuidanceEnabled!==!1,syncCodexSubagentDefaults:e.syncCodexSubagentDefaults===!0,injectionModel:e.model??``,injectionEffort:e.effort??``}}function _n(e,t){return t.aborted?!0:e instanceof Error&&e.name===`AbortError`}async function vn(e,t){try{let n=await fetch(`${e}/api/startup-health`,{signal:t});if(!n.ok)throw Error(`startup health unavailable`);let r=await n.json(),i=fn(r);if(!i)throw Error(`invalid startup health response`);return{status:i,stale:r.diagnosticStale===!0}}catch(e){if(_n(e,t))throw e;return{status:`error`,stale:!1}}}async function yn(e,t){try{return(await ut(await fetch(`${e}/api/diagnostics/project-config`,{signal:t})))?.grouped??[]}catch{return[]}}async function bn(e,t){return ht(await fetch(`${e}/api/models`,{signal:t}))}async function xn(e,t){return ht(await fetch(`${e}/api/usage?range=30d`,{signal:t}))}async function Sn(e,t,n){let{request:r,mutation:i}=un(n.shadowCallRequestEpochRef,n.shadowCallMutationEpochRef),[a,o]=await Promise.all([fetch(`${e}/api/sidecar-settings`,{signal:t}),fetch(`${e}/api/shadow-call-settings`,{signal:t})]),s=await ht(a),c;try{if(o.ok){let e=await o.json();ln({request:r,mutation:i},{request:n.shadowCallRequestEpochRef.current,mutation:n.shadowCallMutationEpochRef.current,mutationInFlight:n.shadowCallMutationInFlightRef.current})&&(c=e)}else ln({request:r,mutation:i},{request:n.shadowCallRequestEpochRef.current,mutation:n.shadowCallMutationEpochRef.current,mutationInFlight:n.shadowCallMutationInFlightRef.current})&&(c=null)}catch{ln({request:r,mutation:i},{request:n.shadowCallRequestEpochRef.current,mutation:n.shadowCallMutationEpochRef.current,mutationInFlight:n.shadowCallMutationInFlightRef.current})&&(c=null)}return{sidecar:s,shadowCall:c}}async function Cn(e,t,n){let{request:r,mutation:i}=un(n.settingsRequestEpochRef,n.settingsMutationEpochRef),a=await ht(await fetch(`${e}/api/settings`,{signal:t})),o,s;return ln({request:r,mutation:i},{request:n.settingsRequestEpochRef.current,mutation:n.settingsMutationEpochRef.current,mutationInFlight:n.settingsMutationInFlightRef.current})&&(o=a,s=a.startupHealth),{settings:o,startupHealthSeed:s}}async function wn(e,t){try{let n=await fetch(`${e}/api/v2`,{signal:t});if(!n.ok)return{maMode:`default`};let r=await n.json();return r.multiAgentMode===`v1`||r.multiAgentMode===`v2`?{maMode:r.multiAgentMode}:{maMode:`default`}}catch(e){if(_n(e,t))throw e;return{maMode:`default`}}}async function Tn(e,t){try{let[n,r]=await Promise.all([fetch(`${e}/healthz`,{signal:t}),fetch(`${e}/api/providers`,{signal:t})]);return{health:await ht(n),providers:await ht(r),error:!1}}catch{return{health:null,providers:[],error:!0}}}async function En(e,t){let[n,r]=await Promise.all([fetch(`${e}/api/injection-model`,{signal:t}).catch(()=>null),fetch(`${e}/api/effort-caps`,{signal:t}).catch(()=>null)]),i;try{if(n?.ok){let e=await n.json();i={...gn(e),injectionEfforts:e.efforts??[],injectionAvailable:e.available??[]}}}catch{}let a;try{if(r?.ok){let e=await r.json();a={effortCap:e.effortCap??``,subagentEffortCap:e.subagentEffortCap??``}}}catch{}return{injection:i,effortCaps:a}}var Dn=`ocx.dash.controls.v1:`,On=`ocx.dash.overview.v1:`,kn=`ocx.dash.usage30d.v1:`,An=`ocx.dash.startup.v1:`,jn=`ocx.dash.maMode.v1:`;function Mn(e){return`${Dn}${e}`}function Nn(e){let{locale:t,t:n}=Ve(),[r,i]=(0,_.useState)(ft),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(new Set),l=(0,_.useMemo)(()=>Y(Mn(e)),[e]),u=(0,_.useMemo)(()=>Y(`${On}${e}`),[e]),d=(0,_.useMemo)(()=>Y(`${kn}${e}`),[e]),f=(0,_.useMemo)(()=>{let t=Y(`${An}${e}`);return t===`error`?null:t},[e]),p=(0,_.useMemo)(()=>Y(`${jn}${e}`),[e]),[m,h]=(0,_.useState)(()=>u?.health??null),[g,v]=(0,_.useState)(()=>f),[y,b]=(0,_.useState)(()=>u?.providers??[]),[x,S]=(0,_.useState)([]),[C,w]=(0,_.useState)(()=>l?.settings??null),[T,E]=(0,_.useState)(()=>l?.sidecar??null),[D,O]=(0,_.useState)(()=>l?.shadowCall??null),[k,A]=(0,_.useState)(()=>d),[j,M]=(0,_.useState)(!1),[N,P]=(0,_.useState)(!1),[F,L]=(0,_.useState)(!1),[R,z]=(0,_.useState)(!1),[B,V]=(0,_.useState)(!1),[H,U]=(0,_.useState)(()=>p??`default`),[W,ee]=(0,_.useState)(!1),[te,ne]=(0,_.useState)(!1),[re,G]=(0,_.useState)(!1),[ie,ae]=(0,_.useState)(!1),[oe,se]=(0,_.useState)(``),[ce,le]=(0,_.useState)(``),[ue,de]=(0,_.useState)([]),[fe,pe]=(0,_.useState)([]),[me,he]=(0,_.useState)(!1),[ge,_e]=(0,_.useState)(!0),[ve,ye]=(0,_.useState)(!1),[be,xe]=(0,_.useState)(``),[Se,Ce]=(0,_.useState)(``),[we,Te]=(0,_.useState)(!1),[Ee,De]=(0,_.useState)(null),[Oe,ke]=(0,_.useState)(null),[Ae,je]=(0,_.useState)([]),[Me,Ne]=(0,_.useState)(!1),[Pe,Fe]=(0,_.useState)(`latest`),[Ie,Le]=(0,_.useState)(!0),[Re,ze]=(0,_.useState)(!1),Be=(0,_.useRef)(0),K=(0,_.useRef)(null),He=(0,_.useRef)(0),Ue=(0,_.useRef)(0),We=(0,_.useRef)(0),Ke=(0,_.useRef)(!1),qe=(0,_.useRef)(0),Je=(0,_.useRef)(0),Ye=(0,_.useRef)(!1),[Xe,Ze]=(0,_.useState)(null),[Qe,$e]=(0,_.useState)(null),[et,tt]=(0,_.useState)(null),[nt,rt]=(0,_.useState)(!1),[it,q]=(0,_.useState)(!1),at=(0,_.useRef)(null),ot=(0,_.useRef)(null),st=(0,_.useRef)(null),ct=(0,_.useRef)(null),lt=Tt(re,at),J=Tt(Me,ot),ut=Tt(te,st),dt=Tt(ie,ct);(0,_.useEffect)(()=>{let e=()=>i(ft());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),(0,_.useEffect)(()=>()=>{He.current+=1,K.current!==null&&(window.clearTimeout(K.current),K.current=null)},[]);let mt=(0,_.useRef)(f),gt=(0,_.useRef)(0),vt=(0,_.useRef)({settingsRequestEpochRef:Ue,settingsMutationEpochRef:We,settingsMutationInFlightRef:Ke,shadowCallRequestEpochRef:qe,shadowCallMutationEpochRef:Je,shadowCallMutationInFlightRef:Ye}).current,yt=I(`dashboard-startup-health:${e}`,[e],t=>vn(e,t),{pollMs:3e4}),St=pn(yt.data),Ct=yt.refresh;(0,_.useEffect)(()=>{if(!St)return;let e=window.setTimeout(()=>{Ct()},dn);return()=>window.clearTimeout(e)},[St,Ct]);let wt=I(`dashboard-overview:${e}`,[e],t=>Tn(e,t),{pollMs:5e3}),Et=m!==null||wt.data!==void 0,Dt=I(`dashboard-ma-mode:${e}`,[e],t=>wn(e,t),{pollMs:5e3}),Ot=I(`dashboard-sidecars:${e}`,[e],async t=>{let n=gt.current;return{...await Sn(e,t,vt),startupHealthGeneration:n}},{pollMs:5e3}),kt=I(`dashboard-settings:${e}`,[e],async t=>{let n=gt.current;return{...await Cn(e,t,vt),startupHealthGeneration:n}},{pollMs:5e3}),At=I(`dashboard-multi-agent:${e}`,[e],t=>En(e,t),{pollMs:5e3,enabled:Et}),jt=I(`dashboard-usage:${e}`,[e],t=>xn(e,t),{pollMs:6e4,enabled:Et}),Mt=I(`dashboard-diagnostics:${e}`,[e],t=>yn(e,t),{pollMs:hn,enabled:Et}),Nt=I(`dashboard-models:${e}`,[e,it],t=>bn(e,t),{enabled:Et&&!it});(0,_.useEffect)(()=>{if(yt.data!==void 0){let t=yt.data;gt.current+=1,v(t.status),mt.current=t.status,t.status!==`error`&&!t.stale&&X(`${An}${e}`,t.status)}},[yt.data,e]),(0,_.useEffect)(()=>{let t=wt.data;t&&(t.health&&(h(t.health),b(t.providers),X(`${On}${e}`,{health:t.health,providers:t.providers})),q(t.error))},[wt.data,e]),(0,_.useEffect)(()=>{Dt.data!==void 0&&(U(Dt.data.maMode),X(`${jn}${e}`,Dt.data.maMode))},[Dt.data,e]);let Pt=Dt.data!==void 0||p!==null;(0,_.useEffect)(()=>{let e=At.data;e&&(e.injection&&(_e(e.injection.multiAgentGuidanceEnabled),ye(e.injection.syncCodexSubagentDefaults),se(e.injection.injectionModel),le(e.injection.injectionEffort),de(e.injection.injectionEfforts),pe(e.injection.injectionAvailable)),e.effortCaps&&(xe(e.effortCaps.effortCap),Ce(e.effortCaps.subagentEffortCap)))},[At.data]),(0,_.useEffect)(()=>{let t=Ot.data;if(!t)return;E(t.sidecar),t.shadowCall!==void 0&&O(t.shadowCall);let n=Y(Mn(e))??{};X(Mn(e),{...n,sidecar:t.sidecar,...t.shadowCall===void 0?{}:{shadowCall:t.shadowCall}})},[Ot.data,e]),(0,_.useEffect)(()=>{let t=kt.data;if(t){if(t.settings!==void 0&&w(t.settings),t.startupHealthSeed!==void 0&&t.startupHealthGeneration===gt.current){let n=mn(mt.current,t.startupHealthSeed);v(n),mt.current=n,n&&X(`${An}${e}`,n)}if(t.settings!==void 0){let n=Y(Mn(e))??{};X(Mn(e),{...n,settings:t.settings})}}},[kt.data,e]),(0,_.useEffect)(()=>{jt.data!==void 0&&(A(jt.data),X(`${kn}${e}`,jt.data))},[jt.data,e]),(0,_.useEffect)(()=>{Mt.data&&je(Mt.data)},[Mt.data]),(0,_.useEffect)(()=>{Nt.data&&S(Nt.data),L(Nt.loading)},[Nt.data,Nt.loading]),(0,_.useEffect)(()=>()=>{Ue.current+=1,qe.current+=1},[]);let Ft=I(et?.id&&et.restart?`update-job:${e}:${et.id}`:`update-job:idle:${e}`,[e,et?.id,et?.restart,et?.latestVersion],async t=>{if(!et?.id||!et.restart)return{reconnecting:!1};let n=et.latestVersion;try{let r=await ht(await fetch(`${e}/api/update/status?jobId=${encodeURIComponent(et.id)}`,{signal:t}));if(r.job){if(r.job.status===`failed`)return{job:r.job,reconnecting:!1};if(n)try{if((await ht(await fetch(`${e}/healthz`,{cache:`no-store`,signal:t}))).version===n)return{job:r.job,reconnecting:!1,reload:!0}}catch{return{job:r.job,reconnecting:!0}}return{job:r.job,reconnecting:!1}}}catch{return{reconnecting:!0}}return{reconnecting:!1}},{pollMs:1500,enabled:!!(et?.id&&et.restart),pauseWhenHidden:!1});(0,_.useEffect)(()=>{let e=Ft.data;e&&(`job`in e&&e.job&&tt(e.job),rt(e.reconnecting),`reload`in e&&e.reload&&window.location.reload())},[Ft.data]);let It=(0,_.useMemo)(()=>{let e={};for(let t of x)(e[t.provider]??=[]).push(t);return Object.entries(e).sort(([e],[t])=>e.localeCompare(t))},[x]),Lt=(0,_.useMemo)(()=>{let e=a.trim().toLowerCase();if(!e)return It;let t=[];for(let[n,r]of It){let i=r.filter(t=>t.id.toLowerCase().includes(e)||n.toLowerCase().includes(e));i.length>0&&t.push([n,i])}return t},[It,a]),Rt=(0,_.useMemo)(()=>{let e=xt(x);for(let t of[T?.webSearch.model,T?.vision.model])t&&!e.some(e=>e.value===t)&&e.unshift({value:t,label:t});return e},[x,T]),zt=async t=>{if(!T||j)return;let n=T,r={webSearch:bt(T.webSearch,t.webSearch),vision:bt(T.vision,t.vision)};M(!0),E(r);try{let n=await ht(await fetch(`${e}/api/sidecar-settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),`save failed`);E({webSearch:n.webSearch,vision:n.vision});let r=Y(Mn(e))??{};X(Mn(e),{...r,sidecar:{webSearch:n.webSearch,vision:n.vision}})}catch{E(n)}finally{M(!1)}};async function Bt(t){if(!D||N)return;let n=D,r={...D,...t};P(!0),Ye.current=!0,O(r);try{if(!(await fetch(`${e}/api/shadow-call-settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).ok)throw Error(`shadow-call save failed`);Je.current+=1}catch{O(n)}finally{Ye.current=!1,P(!1)}}let Vt=async t=>{if(!(W||H===t)){ee(!0);try{(await fetch(`${e}/api/v2`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({multiAgentMode:t})})).ok&&(U(t),X(`${jn}${e}`,t))}catch{}finally{ee(!1)}}},Ht=async t=>{if(!me){he(!0);try{if(!(await fetch(`${e}/api/injection-model`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).ok)throw Error(`injection save failed`);let n=await ht(await fetch(`${e}/api/injection-model`)),r=gn(n);_e(r.multiAgentGuidanceEnabled),ye(r.syncCodexSubagentDefaults),se(r.injectionModel),le(r.injectionEffort),Array.isArray(n.efforts)&&de(n.efforts),Array.isArray(n.available)&&pe(n.available)}catch{}finally{he(!1)}}},Ut=async()=>{if(!C||R)return;let t=!C.codexAutoStart;z(!0),Ke.current=!0,w({...C,codexAutoStart:t});try{let n=await ht(await fetch(`${e}/api/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({codexAutoStart:t})}),`save failed`);We.current+=1,w(e=>e&&{...e,codexAutoStart:n.codexAutoStart,startupHealth:n.startupHealth??e.startupHealth})}catch{w(e=>e&&{...e,codexAutoStart:!t}),q(!0)}finally{Ke.current=!1,z(!1)}},Wt=async()=>{if(!B){V(!0),De(null),ke(null);try{let t=await ht(await fetch(`${e}/api/sync`,{method:`POST`}),`sync failed`);De(t),t.projectConfigGrouped&&je(t.projectConfigGrouped)}catch(e){ke(e instanceof Error?e.message:String(e))}finally{V(!1)}}},Gt=async(t,n=!1)=>{n&&(Be.current=0),K.current!==null&&(window.clearTimeout(K.current),K.current=null);let r=++He.current;ze(!0),$e(null),Ze(null);try{let n=await ht(await fetch(`${e}/api/update/check?tag=${t}`),`update check failed`);if(r!==He.current)return;if(Ze(n),n.reason===`latest_unavailable`&&Be.current<2){let e=++Be.current;K.current=window.setTimeout(()=>{r===He.current&&(K.current=null,Gt(t))},800*e);return}n.reason!==`latest_unavailable`&&(Be.current=0),ze(!1)}catch(e){if(r!==He.current)return;$e(e instanceof Error?e.message:String(e)),ze(!1)}},Kt=()=>{He.current+=1,K.current!==null&&(window.clearTimeout(K.current),K.current=null),ze(!1),Ne(!1)},qt=()=>{let e=_t(m?.version);Fe(e),Le(!0),Ne(!0),Gt(e,!0)},Jt=e=>{Fe(e),Gt(e,!0)},Yt=(0,_.useRef)(qt);return(0,_.useEffect)(()=>{Yt.current=qt}),(0,_.useEffect)(()=>{let e=()=>{pt()&&(Ge(`dashboard`),Yt.current())},t=pt()?window.setTimeout(e,0):null;return window.addEventListener(`hashchange`,e),()=>{t!==null&&window.clearTimeout(t),window.removeEventListener(`hashchange`,e)}},[]),{apiBase:e,locale:t,t:n,selectedSection:r,setSelectedSection:i,modelQuery:a,setModelQuery:o,expandedProviders:s,setExpandedProviders:c,health:m,startupHealth:g,providers:y,models:x,settings:C,sidecar:T,shadowCall:D,usage30d:k,usageLoading:jt.loading&&!k,healthLoading:wt.loading&&!m,sidecarSaving:j,shadowCallSaving:N,modelsLoading:F,settingsSaving:R,syncing:B,maMode:H,maModeResolved:Pt,maBusy:W,setMaHelpOpen:ne,maHelpOpen:te,effortCapHelpOpen:re,setEffortCapHelpOpen:G,shadowCallHelpOpen:ie,setShadowCallHelpOpen:ae,injectionModel:oe,injectionEffort:ce,injectionEfforts:ue,injectionAvailable:fe,injectionSaving:me,multiAgentGuidanceEnabled:ge,syncCodexSubagentDefaults:ve,saveInjection:Ht,effortCap:be,subagentEffortCap:Se,effortCapSaving:we,setEffortCap:xe,setSubagentEffortCap:Ce,setEffortCapSaving:Te,syncResult:Ee,syncError:Oe,projectConfigWarnings:Ae,updateOpen:Me,updateChannel:Pe,setUpdateRestart:Le,updateRestart:Ie,updateLoading:Re,updateCheck:Xe,updateError:Qe,updateJob:et,reconnecting:nt,error:it,effortCapHelpTriggerRef:at,updateTriggerRef:ot,maHelpTriggerRef:st,shadowCallHelpTriggerRef:ct,effortCapHelpDialogRef:lt,updateDialogRef:J,maHelpDialogRef:ut,shadowCallHelpDialogRef:dt,filteredGroups:Lt,sidecarModels:Rt,saveSidecar:zt,saveShadowCall:Bt,switchMaMode:Vt,toggleCodexAutoStart:Ut,runSync:Wt,fetchUpdateCheck:Gt,closeUpdateDialog:Kt,openUpdateDialog:qt,changeUpdateChannel:Jt,runUpdate:async()=>{if(Xe?.canUpdate){$e(null);try{let t=await ht(await fetch(`${e}/api/update/run`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({tag:Pe,restart:Ie})}),`update failed to start`);if(!t.job)throw Error(`update failed to start`);tt(t.job),rt(!1),Kt()}catch(e){$e(e instanceof Error?e.message:String(e))}}}}}function Pn(e){Ke(mt(e))}function Fn({apiBase:e}){let t=Nn(e),{t:n,error:r,selectedSection:i,providers:a,models:o,modelsLoading:s,modelQuery:c,setModelQuery:l,filteredGroups:u,expandedProviders:d,setExpandedProviders:f}=t;if(r)return(0,z.jsx)(ot,{style:{marginTop:40},icon:(0,z.jsx)(de,{}),title:(0,z.jsx)(`span`,{style:{color:`var(--red)`},children:n(`dash.cannotConnect`)}),children:(0,z.jsx)(Ue,{k:`dash.runStart`,cmd:`ocx start`})});let p=(0,z.jsx)(on,{...t}),m=(0,z.jsx)(sn,{t:n,providers:a}),h=(0,z.jsx)(jt,{t:n,models:o,modelsLoading:s,modelQuery:c,setModelQuery:l,filteredGroups:u,expandedProviders:d,setExpandedProviders:f}),g=(0,z.jsx)(At,{...t}),_=[{id:`overview`,label:n(`dash.workspace.overview`),body:p},{id:`providers`,label:n(`dash.activeProviders`),body:m},{id:`models`,label:n(`dash.availableModels`),body:h}],v=_.find(e=>e.id===i)??_[0],y=Pn,b=e=>{let t=_.findIndex(e=>e.id===i),n=-1;if(e.key===`ArrowRight`?n=(t+1)%_.length:e.key===`ArrowLeft`?n=(t-1+_.length)%_.length:e.key===`Home`?n=0:e.key===`End`&&(n=_.length-1),n<0)return;e.preventDefault();let r=_[n];y(r.id),document.getElementById(`dashboard-tab-${r.id}`)?.focus()};return(0,z.jsxs)(`div`,{className:`dashboard-workspace-shell`,children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:n(`nav.dashboard`)})}),(0,z.jsx)(`p`,{className:`page-sub`,children:n(`dash.subtitle`)}),(0,z.jsx)(`div`,{className:`page-tabs`,role:`tablist`,"aria-label":n(`dash.workspace.sections`),children:_.map(e=>(0,z.jsx)(`button`,{type:`button`,role:`tab`,id:`dashboard-tab-${e.id}`,"aria-selected":i===e.id,"aria-controls":`dashboard-panel-${e.id}`,tabIndex:i===e.id?0:-1,className:`page-tab${i===e.id?` page-tab--active`:``}`,onClick:()=>y(e.id),onKeyDown:b,children:e.label},e.id))}),(0,z.jsx)(`section`,{className:`dashboard-workspace-main`,role:`tabpanel`,id:`dashboard-panel-${v.id}`,"aria-labelledby":`dashboard-tab-${v.id}`,tabIndex:0,children:v.body}),g]})}var In=`https://chatgpt.com/backend-api/codex`,Ln=`openai`;function Rn(e){try{let t=new URL(e.trim());if(t.username||t.password||t.search||t.hash)return;let n=t.pathname.replace(/\/+$/,``);return`${t.origin}${n}`}catch{return}}function zn(e){try{let t=new URL(e).hostname.replace(/^\[|\]$/g,``).toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`::1`}catch{return!1}}function Bn(e){return e.keyOptional===!0||e.authMode===`oauth`||e.authMode===`forward`||e.authMode===`local`||zn(e.baseUrl)||e.hasApiKey===!0}function Vn(e){return e.adapter===`openai-responses`&&e.authMode===`forward`&&Rn(e.baseUrl)===In}function Hn(e,t){return e===Ln&&Vn(t)}function Un(e){return e.freeTier===!0||e.keyOptional===!0||e.authMode===`local`||zn(e.baseUrl)}function Wn(e,t){return Hn(e,t)?`accounts`:Un(t)?`free`:`paid`}function Gn(e,t){let n=[...e],r=(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`}),i=e=>e.tier??Wn(e.name,e);switch(t){case`az`:return n.sort(r);case`za`:return n.sort((e,t)=>r(t,e));case`free-paid`:return n.sort((e,t)=>(i(e)===`free`?0:1)-(i(t)===`free`?0:1)||r(e,t));case`paid-free`:return n.sort((e,t)=>(i(e)===`free`)-+(i(t)===`free`)||r(e,t));case`accounts-first`:return n.sort((e,t)=>{let n=e=>{let t=i(e);return t===`accounts`?0:t===`free`?1:2};return n(e)-n(t)||r(e,t)});default:return n}}function Kn(e){let t=[],n=[],r=[];for(let[i,a]of Object.entries(e)){if(a.disabled){r.push({name:i,...a});continue}Bn(a)?t.push({name:i,...a,tier:Wn(i,a)}):n.push({name:i,...a})}return{ready:t,needsSetup:n,disabled:r}}function qn(e,t){let n=new Set(Object.entries(t).filter(([,e])=>e).map(([e])=>e));if(n.size===0)return e;let r=e=>e.map(e=>n.has(e.name)?{...e,activeNeedsReauth:!0}:e);return{ready:r(e.ready),needsSetup:r(e.needsSetup),disabled:e.disabled}}function Jn(e){return e.disabled?`disabled`:`activeNeedsReauth`in e&&e.activeNeedsReauth?`needs-setup`:Bn(e)?`ready`:`needs-setup`}function Yn(e){let t=e.openai,n=e.chatgpt;if(!t||!n||!Hn(`openai`,t)||!Vn(n))return e;let r={...e};return delete r.chatgpt,r}function Xn(e){return e.authMode===`local`||zn(e.baseUrl)}var Zn=[`ollama`,`vllm`,`lm-studio`,`lmstudio`,`litellm`,`localai`];function Qn(e){let t=(e.authMode??``).toLowerCase();if(t===`oauth`||t===`forward`)return`login`;if(Xn(e))return`local`;let n=`${e.name??``} ${e.adapter} ${e.baseUrl}`.toLowerCase();return Zn.some(e=>n.includes(e))?`selfHosted`:`cloud`}function $n(e){if(!e||typeof e!=`object`)return{};let t=e.available;if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))Array.isArray(r)&&(n[e]=r.filter(e=>typeof e==`string`));return n}function er(e){if(!e||typeof e!=`object`)return{};let t=e.liveModelCounts;if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r!=`number`||!Number.isFinite(r)||r<0||(n[e]=Math.floor(r));return n}function tr(e){if(!e||typeof e!=`object`)return{};let t=e.selected;if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))Array.isArray(r)&&(n[e]=r.filter(e=>typeof e==`string`));return n}function nr(e){let t={};for(let[n,r]of Object.entries($n(e)))t[n]=r.length;return t}function rr(e){return Object.entries(e).filter(e=>typeof e[1].requests==`number`&&e[1].requests>0).map(([e,t])=>({name:e,...t,requests:t.requests})).sort((e,t)=>t.requests-e.requests||e.name.localeCompare(t.name))}var ir={justNow:`Just now`,notChecked:`Not checked`,minutesAgo:e=>`${e}m ago`,hoursAgo:e=>`${e}h ago`,daysAgo:e=>`${e}d ago`};function ar(e,t,n){let r=typeof t==`object`&&t?t:ir,i=typeof t==`number`?t:n??Date.now();if(e===void 0||!Number.isFinite(e))return r.notChecked;let a=Math.max(0,i-e),o=Math.floor(a/6e4);if(o<1)return r.justNow;if(o<60)return r.minutesAgo(o);let s=Math.floor(o/60);return s<24?r.hoursAgo(s):r.daysAgo(Math.floor(s/24))}function or(e){return{justNow:e(`time.justNow`),notChecked:e(`time.notChecked`),minutesAgo:t=>e(`time.minutesAgo`,{n:t}),hoursAgo:t=>e(`time.hoursAgo`,{n:t}),daysAgo:t=>e(`time.daysAgo`,{n:t})}}function sr(e,t){let n=[];for(let r of e.ready)r.activeNeedsReauth&&n.push({name:r.name,reason:t[r.name]??`Active account needs re-authentication`});for(let r of e.needsSetup){let e=r.activeNeedsReauth?t[r.name]??`Active account needs re-authentication`:t[r.name]??`Missing credentials`;n.push({name:r.name,reason:e})}for(let r of e.disabled){let e=t[r.name];e&&n.push({name:r.name,reason:e})}return n}function cr(e){return e===`Active account needs re-authentication`?`reauth`:e===`Missing credentials`?`missing`:`custom`}function lr(e,t=`en`){if(e===void 0)return`—`;if(t.toLowerCase().slice(0,2)===`de`){let t=e=>e.replace(/\.0+$/,``).replace(`.`,`,`);return e>=1e9?`${t((e/1e9).toFixed(2))} Mrd.`:e>=1e6?`${t((e/1e6).toFixed(1))} Mio.`:e>=1e3?`${t((e/1e3).toFixed(1))} Tsd.`:String(e)}return e>=1e9?`${(e/1e9).toFixed(2).replace(/\.?0+$/,``)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ur(e,t=`en`){return lr(e,t)}function dr(e,t=`en`){return e==null||!Number.isFinite(e)||e<0?`—`:`~$${new Intl.NumberFormat(t,{minimumFractionDigits:4,maximumFractionDigits:4}).format(e)}`}var fr={anthropic:`claude-color.svg`,"anthropic-apikey":`claude-color.svg`,"azure-openai":`openai.svg`,chatgpt:`openai.svg`,"cloudflare-ai-gateway":`cloudflare-ai-gateway-color.svg`,"cloudflare-workers-ai":`cloudflare-ai-gateway-color.svg`,cursor:`cursor-color.svg`,deepseek:`deepseek-color.svg`,firepass:`firepass-color.svg`,fireworks:`fireworks-color.svg`,github:`github-copilot-color.svg`,"github-copilot":`copilot-color.svg`,"gitlab-duo":`gitlab-duo-color.svg`,google:`gemini-color.svg`,"google-antigravity":`antigravity-color.svg`,"google-vertex":`gemini-color.svg`,groq:`groq-color.svg`,huggingface:`huggingface-color.svg`,kimi:`kimi-color.svg`,"kimi-code":`kimi-color.svg`,kiro:`kiro-color.svg`,"lm-studio":`lm-studio-color.svg`,mistral:`mistral-color.svg`,moonshot:`moonshot-color.svg`,nvidia:`nvidia-color.svg`,ollama:`ollama-color.svg`,"ollama-cloud":`ollama-color.svg`,openai:`openai.svg`,"openai-apikey":`openai.svg`,"opencode-free":`opencode.svg`,"opencode-go":`opencode.svg`,"opencode-zen":`opencode.svg`,openrouter:`openrouter-color.svg`,qianfan:`qianfan-color.svg`,alibaba:`alibaba-color.svg`,"alibaba-token-plan":`alibaba-color.svg`,"alibaba-token-plan-intl":`alibaba-color.svg`,"qwen-cloud":`qwen-portal-color.svg`,"vercel-ai-gateway":`vercel-ai-gateway-color.svg`,vllm:`vllm-color.svg`,xai:`grok-color.svg`,"mimo-free":`xiaomi-color.svg`,xiaomi:`xiaomi-color.svg`},pr={anthropic:`Anthropic Claude`,"anthropic-apikey":`Anthropic Claude`,chatgpt:`ChatGPT`,openai:`OpenAI (Codex login)`,"openai-apikey":`OpenAI API`,"azure-openai":`Azure OpenAI`,"cloudflare-ai-gateway":`Cloudflare AI Gateway`,"cloudflare-workers-ai":`Cloudflare Workers AI`,nvidia:`NVIDIA NIM`,ollama:`Ollama`,"ollama-cloud":`Ollama Cloud`,xai:`xAI Grok`,"mimo-free":`MiMo Free`,xiaomi:`Xiaomi`,cursor:`Cursor`,deepseek:`DeepSeek`,github:`GitHub`,"github-copilot":`GitHub Copilot`,"gitlab-duo":`GitLab Duo`,openrouter:`OpenRouter`,"opencode-go":`OpenCode Go`,"opencode-free":`OpenCode Free`,"opencode-zen":`OpenCode Zen`,mistral:`Mistral`,groq:`Groq`,alibaba:`Alibaba Coding Plan`,"alibaba-token-plan":`Alibaba Token Plan`,"alibaba-token-plan-intl":`Alibaba Token Plan (Intl)`,kimi:`Kimi`,"kimi-code":`Kimi`,moonshot:`Moonshot`,google:`Google`,"google-vertex":`Google Vertex`,"lm-studio":`LM Studio`,huggingface:`Hugging Face`,"qwen-cloud":`Qwen Cloud`,siliconflow:`SiliconFlow`,"tencent-coding-plan":`Tencent Cloud Coding Plan`,"vercel-ai-gateway":`Vercel AI Gateway`,vllm:`vLLM`,litellm:`LiteLLM`},mr={volcengine:`provider.name.volcengine`,"volcengine-coding-plan":`provider.name.volcengineCodingPlan`,"volcengine-agent-plan":`provider.name.volcengineAgentPlan`},hr=new Set([...Object.keys(pr),...Object.keys(mr)]);function gr(e){return fr[e.toLowerCase()]}function _r(e,t){let n=gr(e);return n?`/provider-icons/${n}`:void 0}function vr(e,t){let n=e.toLowerCase(),r=mr[n];return r?t(r):pr[n]?pr[n]:e===n&&/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)?e.split(`-`).map(e=>e&&e[0].toUpperCase()+e.slice(1)).join(` `):e}function yr(e){return hr.has(e.toLowerCase())}function br(e,t){let n=Jn(e);return n===`disabled`?t(`prov.disabledBadge`):n===`ready`?t(`pws.status.ready`):`activeNeedsReauth`in e&&e.activeNeedsReauth?t(`pws.status.needsAttention`):t(`pws.status.needsSetup`)}function xr(e,t){switch(e.authMode){case`oauth`:return t(`modal.badge.oauth`);case`forward`:return t(`pws.auth.chatgptPassthrough`);case`local`:return t(`modal.badge.local`);case`key`:return t(`modal.badge.apiKey`);default:return e.authMode??(e.keyOptional?t(`pws.auth.noKey`):t(`modal.badge.apiKey`))}}function Sr(e){let t=Jn(e);return t===`disabled`?`providers-workspace-rail-status providers-workspace-rail-status--inactive`:t===`ready`?`providers-workspace-rail-status providers-workspace-rail-status--active`:`providers-workspace-rail-status providers-workspace-rail-status--warning`}function Cr({name:e,adapter:t,baseUrl:n,cls:r}){let i=_r(e,{adapter:t,baseUrl:n});return(0,z.jsx)(`span`,{className:r,children:i?(0,z.jsx)(`img`,{src:i,alt:``,"aria-hidden":`true`}):(0,z.jsx)(H,{"aria-hidden":`true`})})}function wr({item:e,selected:t,tabbable:n,modelCount:r,isDefault:i,showConfigId:a,onClick:o,onFocus:s}){let c=K(),l=Un(e),u=Xn(e),d=br(e,c),f=vr(e.name,c),p=a?`${f} (${e.name})`:f,m=`${i?c(`pws.rail.suffixDefault`):``}${u?c(`pws.rail.suffixLocal`):l?c(`pws.rail.suffixFree`):``}`,h=r!==void 0&&r>0?r===1?c(`pws.modelCountOne`):c(`pws.modelCount`,{count:r}):``,g=[a?e.name:``,h].filter(Boolean).join(` · `);return(0,z.jsxs)(`button`,{type:`button`,className:`providers-workspace-rail-row${t?` providers-workspace-rail-row--selected`:``}`,onClick:o,role:`option`,"aria-selected":t,tabIndex:n?0:-1,"aria-label":c(`pws.rail.selectAria`,{name:p,status:d,suffix:m}),title:p,onFocus:s,children:[(0,z.jsx)(Cr,{name:e.name,adapter:e.adapter,baseUrl:e.baseUrl,cls:`providers-workspace-rail-icon`}),(0,z.jsxs)(`span`,{className:`providers-workspace-rail-copy`,children:[(0,z.jsxs)(`span`,{className:`providers-workspace-rail-primary`,children:[(0,z.jsx)(`span`,{className:`providers-workspace-rail-name-label`,title:f,children:f}),u?(0,z.jsx)(`span`,{className:`pwi-rail-badge pwi-rail-badge--local`,title:c(`pws.localTitle`),children:c(`modal.badge.local`)}):l?(0,z.jsx)(`span`,{className:`pwi-rail-badge pwi-rail-badge--free`,title:c(`pws.freeTitle`),children:c(`modal.badge.free`)}):null]}),(0,z.jsx)(`span`,{className:`providers-workspace-rail-secondary`,title:g||void 0,children:g||`\xA0`})]}),(0,z.jsxs)(`span`,{className:`providers-workspace-rail-trail`,children:[i&&(0,z.jsx)(`span`,{className:`pwi-default-star`,title:c(`prov.defaultBadge`),"aria-label":c(`prov.defaultBadge`),children:(0,z.jsx)(Me,{width:17,height:17,"aria-hidden":`true`})}),(0,z.jsx)(`span`,{className:Sr(e),title:d,"aria-hidden":`true`})]})]})}function Tr(e){let t=e?.quota;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,i=Array.isArray(n.customWindows)?n.customWindows.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return typeof t.label!=`string`||r(t.percent)===void 0?[]:[{label:t.label,percent:t.percent,...r(t.resetAt)===void 0?{}:{resetAt:t.resetAt}}]}):[],a={...r(n.fiveHourPercent)===void 0?{}:{fiveHourPercent:n.fiveHourPercent},...r(n.fiveHourResetAt)===void 0?{}:{fiveHourResetAt:n.fiveHourResetAt},...r(n.weeklyPercent)===void 0?{}:{weeklyPercent:n.weeklyPercent},...r(n.weeklyResetAt)===void 0?{}:{weeklyResetAt:n.weeklyResetAt},...r(n.monthlyPercent)===void 0?{}:{monthlyPercent:n.monthlyPercent},...r(n.monthlyResetAt)===void 0?{}:{monthlyResetAt:n.monthlyResetAt},...i.length>0?{customWindows:i}:{},updatedAt:r(n.updatedAt)??e?.updatedAt??Date.now()};return a.fiveHourPercent!==void 0||a.weeklyPercent!==void 0||a.monthlyPercent!==void 0||(a.customWindows?.length??0)>0?a:null}function Er(e){if(!e?.trim())return``;let[t,n]=e.split(`:`,2);return n?`${t} · ${n.replace(/-/g,` `)}`:e}function Dr(e,t,n,r,i,a){let o=r&&r.length>0?r:t?[t]:[],s=[...new Set([...a?e:o,...i])],c=n.trim().toLowerCase();return c?s.filter(e=>e.toLowerCase().includes(c)):s}function Or(e){let t=e?.trim().toLowerCase();return t===`go`||t===`free`}function kr(e,t){return!e||!Or(t)?e:{...e.monthlyPercent===void 0?{}:{monthlyPercent:e.monthlyPercent},...e.monthlyResetAt===void 0?{}:{monthlyResetAt:e.monthlyResetAt},...e.resetCredits===void 0?{}:{resetCredits:e.resetCredits},updatedAt:e.updatedAt}}function Ar(e){return e===`5h`?0:e===`First-party models`?2:e===`API usage`?3:5}function jr(e,t){switch(e){case`First-party models`:return t(`quota.cursorFirstParty`);case`API usage`:return t(`quota.cursorApiUsage`);case`Total subscription credits`:return t(`quota.totalSubscriptionCredits`);default:return e}}function Mr(e,t,n){let r=kr(e,t);if(!r)return[];let i=[];typeof r.fiveHourPercent==`number`&&i.push({rank:0,row:{label:n(`codexAuth.fiveHour`),limitLabel:n(`quota.fiveHourLimit`),percent:r.fiveHourPercent,resetAt:r.fiveHourResetAt}}),typeof r.weeklyPercent==`number`&&i.push({rank:1,row:{label:n(`codexAuth.weekly`),limitLabel:n(`quota.weeklyLimit`),percent:r.weeklyPercent,resetAt:r.weeklyResetAt}}),typeof r.monthlyPercent==`number`&&i.push({rank:4,row:{label:n(`codexAuth.monthly`),limitLabel:n(`quota.monthlyLimit`),percent:r.monthlyPercent,resetAt:r.monthlyResetAt}});for(let e of r.customWindows??[]){let t=jr(e.label,n);i.push({rank:Ar(e.label),row:{label:t,limitLabel:t,percent:e.percent,resetAt:e.resetAt}})}return i.sort((e,t)=>e.rank-t.rank).map(e=>e.row)}function Nr(e){if(!e)return-1;let t=[e.fiveHourPercent,e.weeklyPercent,e.monthlyPercent].filter(e=>typeof e==`number`);for(let n of e.customWindows??[])typeof n.percent==`number`&&t.push(n.percent);return t.length?Math.max(...t):-1}function Pr(e){switch(e){case`en`:return`en-GB`;case`de`:return`de-DE`;case`ko`:return`ko-KR`;case`zh`:return`zh-CN`;case`ru`:return`ru-RU`;case`ja`:return`ja-JP`;default:return e}}function Fr(e){return e>=99.5}function Ir(e,t){return t>0&&e>=t}function Lr(e,t){return Ir(e,t)||Fr(e)?`bar-warn`:`bar-green`}function Rr(e){let t=Math.max(0,Math.min(100,e));return t<=0?0:Math.max(4,Math.round(t))}function zr(e){return{"--bar-scale":String(Rr(e)/100)}}function Br({quota:e,plan:t,threshold:n,t:r,className:i,layout:a=`compact`,pending:o=!1}){let{locale:s}=Ve(),c=Mr(e,t,r);return c.length===0?o?a===`stacked`?(0,z.jsxs)(`div`,{className:`quota-stacked quota-stacked--pending${i?` ${i}`:``}`,"aria-busy":`true`,role:`status`,children:[Array.from({length:2},(e,t)=>(0,z.jsxs)(`div`,{className:`quota-stacked-row quota-stacked-row--skeleton`,"aria-hidden":`true`,children:[(0,z.jsxs)(`div`,{className:`quota-stacked-head`,children:[(0,z.jsx)(`span`,{className:`quota-skel quota-skel--label`,style:{width:72}}),(0,z.jsx)(`span`,{className:`quota-skel quota-skel--time`,style:{width:64}})]}),(0,z.jsxs)(`div`,{className:`quota-stacked-bar-row`,children:[(0,z.jsx)(`span`,{className:`quota-skel quota-skel--bar`,style:{height:6,flex:1}}),(0,z.jsx)(`span`,{className:`quota-skel quota-skel--val`,style:{width:36}})]})]},t)),(0,z.jsx)(`span`,{className:`sr-only`,children:r(`common.loading`)})]}):(0,z.jsxs)(`div`,{className:`codex-account-quota-slot quota-compact quota-compact--pending${i?` ${i}`:``}`,"aria-busy":`true`,role:`status`,children:[Array.from({length:2},(e,t)=>(0,z.jsxs)(`div`,{className:`quota-row quota-row--skeleton`,"aria-hidden":`true`,children:[(0,z.jsx)(`span`,{className:`quota-skel quota-skel--label`}),(0,z.jsx)(`span`,{className:`quota-skel quota-skel--reset`}),(0,z.jsx)(`span`,{className:`quota-skel quota-skel--day`}),(0,z.jsx)(`span`,{className:`quota-skel quota-skel--time`}),(0,z.jsx)(`span`,{className:`quota-skel quota-skel--bar`}),(0,z.jsx)(`span`,{className:`quota-skel quota-skel--val`})]},t)),(0,z.jsx)(`span`,{className:`sr-only`,children:r(`common.loading`)})]}):null:a===`stacked`?(0,z.jsx)(`div`,{className:`quota-stacked${i?` ${i}`:``}`,children:c.map(e=>(0,z.jsx)(Hr,{row:e,threshold:n,t:r,locale:s},e.limitLabel))}):(0,z.jsx)(`div`,{className:`codex-account-quota-slot quota-compact${i?` ${i}`:``}`,children:c.map(e=>(0,z.jsx)(Vr,{label:e.label,percent:e.percent,resetAt:e.resetAt,threshold:n,t:r,locale:s},e.label))})}function Vr({label:e,percent:t,resetAt:n,threshold:r,t:i,locale:a}){let o=Fr(t),s=Ir(t,r),c=Lr(t,r),l=Ur(n,i,a);return(0,z.jsxs)(`div`,{className:`quota-row${s?` quota-row--warn`:``}${o?` quota-row--exhausted`:``}`,children:[(0,z.jsx)(`span`,{className:`quota-label`,children:e}),(0,z.jsx)(`span`,{className:`quota-reset-label`,children:i(`codexAuth.resets`)}),(0,z.jsx)(`span`,{className:`quota-reset-day`,children:l.day}),(0,z.jsx)(`span`,{className:`quota-reset-time`,children:l.time}),(0,z.jsx)(`div`,{className:`bar`,children:(0,z.jsx)(`div`,{className:`bar-fill ${c}`,style:zr(t)})}),(0,z.jsxs)(`span`,{className:`quota-val${s?` quota-val--warn`:``}`,title:o?i(`quota.limitReached`):void 0,children:[s&&(0,z.jsx)(de,{width:12,height:12,"aria-hidden":`true`}),Math.round(t),`%`,o?` · ${i(`quota.limitReached`)}`:``]})]})}function Hr({row:e,threshold:t,t:n,locale:r}){let i=Fr(e.percent),a=Ir(e.percent,t),o=Lr(e.percent,t),s=Wr(e.resetAt,n,r);return(0,z.jsxs)(`div`,{className:`quota-stacked-row${a?` quota-stacked-row--warn`:``}${i?` quota-stacked-row--exhausted`:``}`,children:[(0,z.jsxs)(`div`,{className:`quota-stacked-head`,children:[(0,z.jsx)(`span`,{className:`quota-stacked-limit`,children:e.limitLabel}),(0,z.jsx)(`span`,{className:`quota-stacked-reset muted`,children:s})]}),(0,z.jsxs)(`div`,{className:`quota-stacked-bar-row`,children:[(0,z.jsx)(`div`,{className:`bar quota-stacked-bar`,children:(0,z.jsx)(`div`,{className:`bar-fill ${o}`,style:zr(e.percent)})}),(0,z.jsx)(`span`,{className:`quota-stacked-used${a?` quota-stacked-used--warn`:``}`,children:n(`quota.usedPercent`,{pct:Math.round(e.percent)})})]}),i&&(0,z.jsxs)(`div`,{className:`quota-stacked-limit-reached`,role:`status`,children:[(0,z.jsx)(de,{width:12,height:12,"aria-hidden":`true`}),n(`quota.limitReached`)]})]})}function Ur(e,t,n){if(typeof e!=`number`||!Number.isFinite(e))return{day:``,time:``};let r=e<1e10?e*1e3:e,i=new Date(r),a=new Date,o=Pr(n),s=new Intl.DateTimeFormat(o,{hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(i);return i.getFullYear()===a.getFullYear()&&i.getMonth()===a.getMonth()&&i.getDate()===a.getDate()?{day:t(`codexAuth.today`),time:s}:{day:new Intl.DateTimeFormat(o,{day:`numeric`,month:`short`}).format(i),time:s}}function Wr(e,t,n=`en`,r=Date.now()){if(typeof e!=`number`||!Number.isFinite(e))return``;let i=e<1e10?e*1e3:e,a=new Date(i),o=Pr(n),s=new Intl.DateTimeFormat(o,{hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(a),c=new Date(r),l=new Date(c.getFullYear(),c.getMonth(),c.getDate()).getTime(),u=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),d=Math.round((u-l)/864e5);if(d===1)return t(`quota.resetsTomorrow`,{time:s});let f=a.getFullYear()!==c.getFullYear(),p=new Intl.DateTimeFormat(o,{day:`numeric`,month:`short`,...f?{year:`numeric`}:{}}).format(a);if(i<=r)return t(`quota.resetsAt`,{date:p,time:s,when:`${p}, ${s}`});let m=Math.round((i-r)/6e4);if(m<60)return t(`quota.resetsRelativeMinutes`,{n:Math.max(1,m)});let h=Math.round(m/60);return h<12&&d===0?t(`quota.resetsRelativeHours`,{n:Math.max(1,h)}):d===0?t(`quota.resetsToday`,{time:s}):t(`quota.resetsAt`,{date:p,time:s,when:`${p}, ${s}`})}function Gr({sections:e,quotaReports:t,usageTotals:n,usageLoading:r=!1,quotasLoading:i=!1,onSelectProvider:a,onEditConfig:o}){let s=K(),{locale:c}=Ve(),l=or(s),u=(0,_.useMemo)(()=>[...e.ready,...e.needsSetup,...e.disabled],[e]),d=(0,_.useMemo)(()=>new Set(u.map(e=>e.name)),[u]),f=(0,_.useMemo)(()=>sr(e,{}),[e]),p=f.length,m=(0,_.useMemo)(()=>e.ready.filter(e=>e.activeNeedsReauth).length,[e]),h=e.ready.length-m,g=e.needsSetup.length+m,v=(0,_.useMemo)(()=>{let e=[];for(let n of u){let r=t[n.name],i=r?Tr(r):null;r&&i&&e.push({item:n,report:r,urgency:Nr(i)})}return e.sort((e,t)=>t.urgency-e.urgency||e.item.name.localeCompare(t.item.name))},[u,t]),y=(0,_.useMemo)(()=>{let e={};for(let[t,r]of Object.entries(n))d.has(t)&&(e[t]=r);return rr(e).slice(0,4)},[n,d]),b=e=>{let t=cr(e);return t===`reauth`?s(`pws.attention.reauth`):t===`missing`?s(`pws.attention.missingCredentials`):e};return(0,z.jsxs)(`div`,{className:`pws-dashboard`,children:[(0,z.jsxs)(`div`,{className:`pws-dashboard-header`,children:[(0,z.jsxs)(`div`,{className:`pws-dashboard-header-text`,children:[(0,z.jsx)(`h2`,{className:`pws-dashboard-title`,children:s(`pws.dashboard.title`)}),(0,z.jsx)(`p`,{className:`muted pws-dashboard-subtitle`,children:s(`pws.dashboard.subtitle`)})]}),o&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:o,children:s(`prov.editJson`)})]}),(0,z.jsxs)(`div`,{className:`pws-dashboard-summary`,children:[(0,z.jsx)(Kr,{count:h,label:s(`pws.status.ready`),tone:`ok`}),(0,z.jsx)(Kr,{count:g,label:s(m>0?`pws.status.needsAttention`:`pws.status.needsSetup`),tone:`warn`}),(0,z.jsx)(Kr,{count:e.disabled.length,label:s(`prov.disabledBadge`),tone:`muted`})]}),p>0&&(0,z.jsxs)(`section`,{className:`pws-dashboard-section pws-dashboard-attention`,"aria-label":s(`pws.attentionTitle`),children:[(0,z.jsxs)(`h3`,{className:`pws-dashboard-section-title`,children:[(0,z.jsx)(de,{style:{width:14,height:14},"aria-hidden":`true`}),s(`pws.attentionTitle`)]}),(0,z.jsx)(`div`,{className:`pws-dashboard-rows`,children:f.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`pws-dashboard-row pws-dashboard-row--attention`,onClick:()=>a(e.name),children:[(0,z.jsx)(Cr,{name:e.name,adapter:``,baseUrl:``,cls:`pws-dashboard-row-icon`}),(0,z.jsxs)(`div`,{className:`pws-dashboard-row-info`,children:[(0,z.jsx)(`span`,{className:`pws-dashboard-row-name`,children:vr(e.name,s)}),(0,z.jsx)(`span`,{className:`pws-dashboard-row-meta muted`,children:b(e.reason)})]}),(0,z.jsx)(_e,{className:`pws-dashboard-row-chevron`,"aria-hidden":`true`})]},`${e.name}:${e.reason}`))})]}),(0,z.jsxs)(`div`,{className:`pws-dashboard-columns`,children:[(0,z.jsxs)(`section`,{className:`pws-dashboard-section pws-dashboard-section--rate-limits`,"aria-label":s(`pws.dashboard.rateLimits`),"aria-busy":i||void 0,children:[(0,z.jsx)(`h3`,{className:`pws-dashboard-section-title`,children:s(`pws.dashboard.rateLimits`)}),v.length>0?(0,z.jsx)(`div`,{className:`pws-dashboard-rows`,children:v.map(({item:e,report:t})=>(0,z.jsxs)(`button`,{type:`button`,className:`pws-dashboard-row`,onClick:()=>a(e.name),children:[(0,z.jsx)(Cr,{name:e.name,adapter:e.adapter,baseUrl:e.baseUrl,cls:`pws-dashboard-row-icon`}),(0,z.jsxs)(`div`,{className:`pws-dashboard-row-info`,children:[(0,z.jsx)(`span`,{className:`pws-dashboard-row-name`,children:vr(e.name,s)}),(0,z.jsx)(`span`,{className:`pws-dashboard-row-meta muted`,children:s(`pws.dashboard.checkedAgo`,{time:ar(t.updatedAt,l)})})]}),(0,z.jsx)(_e,{className:`pws-dashboard-row-chevron`,"aria-hidden":`true`}),(0,z.jsx)(`div`,{className:`pws-dashboard-row-bars`,children:(0,z.jsx)(Br,{quota:Tr(t),threshold:80,t:s,layout:`stacked`,pending:i&&!t.quota})})]},e.name))}):i?(0,z.jsx)(`div`,{className:`pws-dashboard-rows pws-dashboard-rows--pending`,"aria-hidden":`true`,children:Array.from({length:3},(e,t)=>(0,z.jsxs)(`div`,{className:`pws-dashboard-row pws-dashboard-row--skeleton`,children:[(0,z.jsx)(`span`,{className:`pws-dashboard-row-icon pws-skel`}),(0,z.jsxs)(`div`,{className:`pws-dashboard-row-info`,children:[(0,z.jsx)(`span`,{className:`pws-skel pws-skel--name`}),(0,z.jsx)(`span`,{className:`pws-skel pws-skel--meta`})]}),(0,z.jsx)(`div`,{className:`pws-dashboard-row-bars`,children:(0,z.jsx)(Br,{quota:null,threshold:80,t:s,layout:`stacked`,pending:!0})})]},t))}):(0,z.jsx)(`p`,{className:`muted pws-dashboard-empty`,children:s(`pws.dashboard.noRateLimits`)})]}),(0,z.jsxs)(`section`,{className:`pws-dashboard-section pws-dashboard-section--recent`,"aria-label":s(`pws.dashboard.recentlyUsed`),"aria-busy":r||void 0,children:[(0,z.jsx)(`h3`,{className:`pws-dashboard-section-title`,children:s(`pws.dashboard.recentlyUsed`)}),y.length>0?(0,z.jsx)(`div`,{className:`pws-dashboard-rows`,children:y.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`pws-dashboard-row`,onClick:()=>a(e.name),children:[(0,z.jsx)(Cr,{name:e.name,adapter:``,baseUrl:``,cls:`pws-dashboard-row-icon`}),(0,z.jsx)(`span`,{className:`pws-dashboard-row-name`,children:vr(e.name,s)}),(0,z.jsx)(`span`,{className:`pws-dashboard-row-count muted`,children:s(`pws.dashboard.requests`,{count:lr(e.requests,c)})}),(0,z.jsx)(_e,{className:`pws-dashboard-row-chevron`,"aria-hidden":`true`})]},e.name))}):r?(0,z.jsx)(`div`,{className:`pws-dashboard-rows pws-dashboard-rows--pending`,"aria-hidden":`true`,children:Array.from({length:3},(e,t)=>(0,z.jsxs)(`div`,{className:`pws-dashboard-row pws-dashboard-row--skeleton`,children:[(0,z.jsx)(`span`,{className:`pws-dashboard-row-icon pws-skel`}),(0,z.jsx)(`span`,{className:`pws-skel pws-skel--name`}),(0,z.jsx)(`span`,{className:`pws-skel pws-skel--count`})]},t))}):(0,z.jsx)(`p`,{className:`muted pws-dashboard-empty`,children:s(`pws.dashboard.noUsage`)})]})]})]})}function Kr({count:e,label:t,tone:n}){return(0,z.jsxs)(`div`,{className:`pws-dashboard-card pws-dashboard-card--${n}`,children:[(0,z.jsx)(`span`,{className:`pws-dashboard-card-count`,children:e}),(0,z.jsx)(`span`,{className:`pws-dashboard-card-label`,children:t})]})}function qr({editor:e,providerName:t,saving:n,onSave:r,message:i}){let a=K(),o=(0,_.useRef)(null);return(0,_.useEffect)(()=>{e.open&&o.current?.focus()},[e.open]),e.open?(0,z.jsxs)(`div`,{className:`pwi-json-panel`,children:[(0,z.jsxs)(`div`,{className:`pwi-json-panel-header`,children:[(0,z.jsx)(`span`,{className:`pwi-json-panel-title`,children:a(`pws.jsonEditorTitle`,{name:t})}),(0,z.jsxs)(`div`,{className:`pwi-json-panel-actions`,children:[e.onRestore&&e.isDirty&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:e.onRestore,children:a(`pws.jsonRestore`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:e.onClose,children:a(`common.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:r,disabled:n||!e.isDirty,children:a(n?`pws.saving`:`pws.jsonSave`)})]})]}),(0,z.jsx)(`p`,{className:`pwi-json-panel-desc muted`,children:a(`pws.jsonEditorDesc`)}),(0,z.jsx)(`textarea`,{ref:o,className:`input pwi-json-textarea`,value:e.draft,onChange:t=>e.onDraftChange(t.target.value),spellCheck:!1,rows:20,"aria-label":a(`pws.jsonEditorDesc`)}),i&&(0,z.jsx)(`div`,{className:i.ok?`pwi-settings-msg pwi-settings-msg--ok`:`pwi-settings-msg pwi-settings-msg--err`,children:i.text})]}):null}var Jr=[{id:`az`,labelKey:`pws.sort.az`},{id:`za`,labelKey:`pws.sort.za`},{id:`free-paid`,labelKey:`pws.sort.freePaid`},{id:`paid-free`,labelKey:`pws.sort.paidFree`},{id:`accounts-first`,labelKey:`pws.sort.accountsFirst`}];function Yr({providers:e,apiBase:t,defaultProvider:n,selectedName:r,onSelect:i,onRemoveProvider:a,onAddProvider:o,onEditConfig:s,jsonEditor:c,jsonSaving:l=!1,modelsRefreshToken:u=0,activeAccountNeedsReauth:d,quotaRefreshEpoch:f=0,quotaForceRefresh:p=!1,detail:m}){let h=K(),[g,v]=(0,_.useState)(``),[y,b]=(0,_.useState)({ready:!0,needsSetup:!0,disabled:!0}),[x,S]=(0,_.useState)({free:!0,paid:!0}),[C,w]=(0,_.useState)({cloud:!0,local:!0,selfHosted:!0,login:!0}),[T,E]=(0,_.useState)(`az`),[D,O]=(0,_.useState)(!1),[k,A]=(0,_.useState)(null),[j,M]=(0,_.useState)({}),[N,P]=(0,_.useState)({}),[F,I]=(0,_.useState)({}),[L,R]=(0,_.useState)({}),[B,V]=(0,_.useState)(!1),[H,U]=(0,_.useState)(!1),W=`ocx.providers.quotas.v1:${t}`,ee=`ocx.providers.usage.v1:${t}`,[te,ne]=(0,_.useState)(()=>Y(ee)?.totals??{}),[re,G]=(0,_.useState)(()=>Y(ee)?.models??{}),[ie,ae]=(0,_.useState)(()=>Y(W)??{}),[oe,se]=(0,_.useState)(()=>!Y(ee)),[ce,le]=(0,_.useState)(()=>!Y(W)),[de,fe]=(0,_.useState)(0),me=(0,_.useRef)(null),he=(0,_.useMemo)(()=>qn(Kn(Yn(e)),d??{}),[e,d]),ge=(0,_.useCallback)(()=>{fe(e=>e+1)},[]);(0,_.useEffect)(()=>{let e=!1,n=window.setTimeout(()=>{V(!0),(async()=>{try{let n=await J(await fetch(`${t}/api/selected-models`));if(e)return;M(nr(n)),P($n(n)),I(er(n)),R(tr(n)),U(!1)}catch{if(e)return;U(!0)}finally{e||V(!1)}})()},0);return()=>{e=!0,window.clearTimeout(n)}},[t,u,de]),(0,_.useEffect)(()=>{let e=!1,n=window.setTimeout(()=>{Y(ee)||se(!0),fetch(`${t}/api/usage?range=30d`).then(e=>ut(e)).then(t=>{if(e||!t)return;let n={};for(let e of t.providers??[])n[e.provider]={requests:e.requests,totalTokens:e.totalTokens};ne(n);let r={};for(let e of t.models??[]){let t=e.provider;r[t]||(r[t]=[]),r[t].push({model:e.model,...e.resolvedModel?{resolvedModel:e.resolvedModel}:{},requests:e.requests,totalTokens:e.totalTokens,inputTokens:e.inputTokens,outputTokens:e.outputTokens,shareRatio:e.shareRatio,...e.estimatedCostUsd===void 0?{}:{estimatedCostUsd:e.estimatedCostUsd}})}G(r),X(ee,{totals:n,models:r})}).catch(()=>{}).finally(()=>{e||se(!1)})},0);return()=>{e=!0,window.clearTimeout(n)}},[t,ee]),(0,_.useEffect)(()=>{let e=!1,n=window.setTimeout(()=>{Y(W)||le(!0),fetch(`${t}/api/provider-quotas${p?`?refresh=1`:``}`).then(e=>ut(e)).then(t=>{e||!t||ae(e=>{let n={...e};for(let e of t.reports??[])e?.provider&&(n[e.provider]={label:e.label,source:e.source,updatedAt:typeof e.updatedAt==`number`?e.updatedAt:Date.now(),quota:e.quota});return X(W,n),n})}).catch(()=>{}).finally(()=>{e||le(!1)})},0);return()=>{e=!0,window.clearTimeout(n)}},[t,f,p,W]),(0,_.useEffect)(()=>{if(!D)return;let e=e=>{me.current&&!me.current.contains(e.target)&&O(!1)},t=e=>{e.key===`Escape`&&O(!1)};return document.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[D]);let _e=(0,_.useMemo)(()=>[...he.ready,...he.needsSetup,...he.disabled],[he]),ve=(0,_.useMemo)(()=>_e.filter(Un).length,[_e]),ye=_e.length-ve,be=(0,_.useMemo)(()=>{let e={cloud:0,local:0,selfHosted:0,login:0};for(let t of _e)e[Qn(t)]+=1;return e},[_e]),xe=(0,_.useMemo)(()=>{let e=g.trim().toLowerCase(),t=t=>Gn(t.filter(t=>{if(e&&!t.name.toLowerCase().includes(e)&&!t.adapter.toLowerCase().includes(e))return!1;let n=Un(t);return!(n&&!x.free||!n&&!x.paid||!C[Qn(t)])}),T);return{ready:y.ready?t(he.ready):[],needsSetup:y.needsSetup?t(he.needsSetup):[],disabled:y.disabled?t(he.disabled):[]}},[he,g,y,x,C,T]),Se=!y.ready||!y.needsSetup||!y.disabled||!x.free||!x.paid||!C.cloud||!C.local||!C.selfHosted||!C.login||T!==`az`,Ce=()=>{b({ready:!0,needsSetup:!0,disabled:!0}),S({free:!0,paid:!0}),w({cloud:!0,local:!0,selfHosted:!0,login:!0}),E(`az`)},we=(0,_.useMemo)(()=>r?_e.find(e=>e.name===r)??null:null,[r,_e]),Te=(0,_.useMemo)(()=>{let e=new Map;for(let t of _e){let n=vr(t.name,h);e.set(n,(e.get(n)??0)+1)}let t=new Set;for(let[n,r]of e.entries())r>1&&t.add(n);return t},[_e,h]);if(_e.length===0)return(0,z.jsx)(Xr,{onAddProvider:o});let Ee=[{key:`ready`,label:h(`pws.status.ready`),count:he.ready.length},{key:`needsSetup`,label:h(`pws.status.needsSetup`),count:he.needsSetup.length},{key:`disabled`,label:h(`prov.disabledBadge`),count:he.disabled.length}],De=[{id:`ready`,label:h(`pws.status.ready`),count:xe.ready.length,ariaLabel:h(`pws.groupReady`,{count:xe.ready.length}),items:xe.ready},{id:`needs-setup`,label:h(`pws.status.needsSetup`),count:xe.needsSetup.length,ariaLabel:h(`pws.groupNeedsSetup`,{count:xe.needsSetup.length}),items:xe.needsSetup},{id:`disabled`,label:h(`prov.disabledBadge`),count:xe.disabled.length,ariaLabel:h(`pws.groupDisabled`,{count:xe.disabled.length}),items:xe.disabled}],Oe=De.flatMap(e=>e.items.map(e=>e.name)),ke=k&&Oe.includes(k)?k:r&&Oe.includes(r)?r:Oe[0]??null;return(0,z.jsx)(`div`,{className:`pws-shell-container`,children:(0,z.jsxs)(`div`,{className:`pws-root`,children:[(0,z.jsxs)(`aside`,{className:`pws-rail`,"aria-label":h(`pws.providerList`),children:[(0,z.jsxs)(`div`,{className:`pws-search-row`,children:[(0,z.jsxs)(`div`,{className:`pws-search-wrap`,children:[(0,z.jsx)(pe,{className:`pws-search-icon`,width:14,height:14,"aria-hidden":`true`}),(0,z.jsx)(`input`,{type:`search`,className:`input pws-search-input`,placeholder:h(`pws.searchPlaceholder`),value:g,onChange:e=>v(e.target.value),"aria-label":h(`pws.searchPlaceholder`)})]}),(0,z.jsxs)(`div`,{className:`pws-filter-wrap`,ref:me,children:[(0,z.jsxs)(`button`,{type:`button`,className:`pws-filter-btn${Se||D?` pws-filter-btn--active`:``}`,onClick:()=>O(e=>!e),"aria-label":h(`pws.filterAria`),"aria-expanded":D,"aria-controls":`pws-provider-filters`,children:[(0,z.jsx)(Ne,{width:18,height:18,"aria-hidden":`true`}),Se&&(0,z.jsx)(`span`,{className:`pws-filter-dot`,"aria-hidden":`true`})]}),D&&(0,z.jsxs)(`div`,{id:`pws-provider-filters`,className:`pws-filter-menu`,role:`group`,"aria-label":h(`pws.providerFiltersAria`),children:[(0,z.jsx)(`div`,{className:`pws-filter-title`,children:h(`pws.filters`)}),(0,z.jsx)(`div`,{className:`pws-filter-head`,children:h(`pws.filterStatus`)}),Ee.map(({key:e,label:t,count:n})=>(0,z.jsxs)(`label`,{className:`pws-filter-option`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:y[e],onChange:()=>b(t=>({...t,[e]:!t[e]}))}),(0,z.jsx)(`span`,{className:`pws-filter-label`,children:t}),(0,z.jsx)(`span`,{className:`pws-filter-count`,children:n})]},e)),(0,z.jsx)(`div`,{className:`pws-filter-head`,children:h(`pws.pricing`)}),(0,z.jsxs)(`label`,{className:`pws-filter-option`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:x.free,onChange:()=>S(e=>({...e,free:!e.free}))}),(0,z.jsx)(`span`,{className:`pws-filter-label`,children:h(`modal.badge.free`)}),(0,z.jsx)(`span`,{className:`pws-filter-count`,children:ve})]}),(0,z.jsxs)(`label`,{className:`pws-filter-option`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:x.paid,onChange:()=>S(e=>({...e,paid:!e.paid}))}),(0,z.jsx)(`span`,{className:`pws-filter-label`,children:h(`pws.paid`)}),(0,z.jsx)(`span`,{className:`pws-filter-count`,children:ye})]}),(0,z.jsx)(`div`,{className:`pws-filter-head`,children:h(`pws.filterType`)}),[{key:`cloud`,label:h(`pws.type.cloud`),count:be.cloud},{key:`local`,label:h(`pws.type.local`),count:be.local},{key:`selfHosted`,label:h(`pws.type.selfHosted`),count:be.selfHosted},{key:`login`,label:h(`pws.type.login`),count:be.login}].map(({key:e,label:t,count:n})=>(0,z.jsxs)(`label`,{className:`pws-filter-option`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:C[e],onChange:()=>w(t=>({...t,[e]:!t[e]}))}),(0,z.jsx)(`span`,{className:`pws-filter-label`,children:t}),(0,z.jsx)(`span`,{className:`pws-filter-count`,children:n})]},e)),(0,z.jsx)(`div`,{className:`pws-filter-head`,children:h(`pws.sort`)}),(0,z.jsx)(`div`,{className:`pws-sort-grid`,role:`group`,"aria-label":h(`pws.sortProvidersAria`),children:Jr.map(e=>(0,z.jsx)(`button`,{type:`button`,className:`pws-sort-btn${T===e.id?` pws-sort-btn--active`:``}`,onClick:()=>E(e.id),"aria-pressed":T===e.id,children:h(e.labelKey)},e.id))}),(0,z.jsx)(`div`,{className:`pws-filter-footer`,children:(0,z.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:Ce,disabled:!Se,children:h(`pws.resetAll`)})})]})]})]}),(0,z.jsxs)(`div`,{className:`pws-rail-list`,role:`listbox`,"aria-label":h(`pws.providersAria`),onKeyDown:e=>{let t=Array.from(e.currentTarget.querySelectorAll(`[role="option"]`));if(t.length===0)return;let n=document.activeElement,r=t.findIndex(e=>e===n||e.contains(n));if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=e.key===`ArrowDown`?1:-1;t[r<0?n>0?0:t.length-1:(r+n+t.length)%t.length]?.focus();return}if(e.key===`Home`){e.preventDefault(),t[0]?.focus();return}e.key===`End`&&(e.preventDefault(),t[t.length-1]?.focus())},children:[Object.values(xe).every(e=>e.length===0)&&(0,z.jsx)(`span`,{className:`muted pws-rail-empty`,role:`status`,children:h(g?`pws.noSearchResults`:Se?`pws.noMatchFilters`:`pws.noProvidersConfigured`)}),De.map(({id:e,label:t,count:o,ariaLabel:s,items:c})=>c.length===0?null:(0,z.jsxs)(`div`,{className:`pws-rail-group`,role:`group`,"aria-label":s,children:[(0,z.jsxs)(`div`,{className:`pws-rail-group-head`,"aria-hidden":`true`,children:[(0,z.jsx)(`span`,{className:`pws-rail-group-label`,children:t}),(0,z.jsx)(`span`,{className:`pws-rail-group-count`,children:o})]}),c.map(e=>(0,z.jsxs)(`div`,{className:`pws-rail-row-wrap`,children:[(0,z.jsx)(wr,{item:e,selected:r===e.name,tabbable:ke===e.name,modelCount:j[e.name],isDefault:n===e.name,showConfigId:Te.has(vr(e.name,h)),onClick:()=>i(e.name),onFocus:()=>A(e.name)}),a&&(0,z.jsx)(`button`,{type:`button`,className:`pws-rail-row-remove`,tabIndex:-1,"aria-hidden":`true`,onClick:t=>{t.stopPropagation(),a(e.name)},title:h(`pws.removeConfirmTitle`),children:(0,z.jsx)(ue,{width:14,height:14})})]},e.name))]},e))]})]}),(0,z.jsx)(`main`,{className:`pws-main`,"aria-label":h(`pws.workspaceMainAria`),children:c?.open?(0,z.jsx)(qr,{editor:c,providerName:h(`nav.providers`),saving:l,onSave:()=>{c.onSave()}}):we?m?.(we,{usageTotals:te[we.name],modelUsage:re[we.name],quotaReport:ie[we.name],availableModels:N[we.name]??[],hasLiveModels:(F[we.name]??0)>0,selectedModels:L[we.name]??[],modelsLoading:B,modelsLoadFailed:H,onRetryModels:ge})??(0,z.jsxs)(`div`,{className:`pws-detail-placeholder`,children:[(0,z.jsx)(`h3`,{children:vr(we.name,h)}),(0,z.jsx)(`p`,{className:`muted`,children:h(`pws.detailComingSoon`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>i(null),children:h(`modal.back`)})]}):(0,z.jsx)(Gr,{sections:he,quotaReports:ie,usageTotals:te,usageLoading:oe,quotasLoading:ce,onSelectProvider:e=>i(e),onEditConfig:s})})]})})}function Xr({onAddProvider:e}){let t=K();return(0,z.jsx)(`div`,{className:`pws-empty-root`,children:(0,z.jsxs)(`div`,{className:`pws-empty-hero`,children:[(0,z.jsx)(`div`,{"aria-hidden":`true`,children:(0,z.jsx)(U,{style:{width:64,height:64}})}),(0,z.jsx)(`h2`,{children:t(`pws.connectFirst`)}),(0,z.jsxs)(`div`,{className:`pws-empty-tiles`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`pws-empty-tile`,onClick:()=>e({tier:`free`}),children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,children:(0,z.jsx)(Oe,{width:18,height:18})}),(0,z.jsx)(`span`,{className:`pws-empty-tile-label`,children:t(`pws.empty.browseFree`)}),(0,z.jsx)(`span`,{className:`pws-empty-tile-desc muted`,children:t(`pws.empty.browseFreeDesc`)})]}),(0,z.jsxs)(`button`,{type:`button`,className:`pws-empty-tile`,onClick:()=>e({tier:`accounts`}),children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,children:(0,z.jsx)(Se,{width:18,height:18})}),(0,z.jsx)(`span`,{className:`pws-empty-tile-label`,children:t(`pws.empty.connectAccount`)}),(0,z.jsx)(`span`,{className:`pws-empty-tile-desc muted`,children:t(`pws.empty.connectAccountDesc`)})]}),(0,z.jsxs)(`button`,{type:`button`,className:`pws-empty-tile`,onClick:()=>e({custom:!0}),children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,children:(0,z.jsx)(xe,{width:18,height:18})}),(0,z.jsx)(`span`,{className:`pws-empty-tile-label`,children:t(`pws.empty.addEndpoint`)}),(0,z.jsx)(`span`,{className:`pws-empty-tile-desc muted`,children:t(`pws.empty.addEndpointDesc`)})]})]})]})})}function Zr(e){if(Hn(e.name,e))return`codex-accounts`;let t=(e.authMode??``).toLowerCase();if(t===`forward`||t===`local`||Xn(e))return null;if(t===`oauth`)return`oauth-accounts`;let n=e.hasApiKey===!0;return!(t===`key`||n||t===``)||e.keyOptional===!0&&!n?null:`api-keys`}function Qr(e,t,n){let r=t.alias?.trim();if(r)return r;let i=t.email?.trim();if(i)return i;let a=e.findIndex(e=>e.id===t.id);return n(`pws.accountOrdinal`,{count:String(a>=0?a+1:1)})}function $r({item:e,usageTotals:t,quotaReport:n,oauthEmail:r,apiBase:i,connectionIdentity:a,onEditSettings:o,onViewUsage:s,onUpdateProvider:c,onReauthenticate:l,onCancelLogin:u,reauthBusy:d=!1,accountPanel:f}){let p=K(),{locale:m}=Ve(),h=or(p),g=Jn(e),v=!!e.activeNeedsReauth,y=p(g===`ready`?`pws.status.connected`:g===`needs-setup`?v?`pws.status.needsAttention`:`pws.status.needsSetup`:`prov.disabledBadge`),b=t?.requests,x=t?.totalTokens,S=Tr(n),C=JSON.stringify([i??null,e.name,e.adapter,e.baseUrl,e.authMode??null,e.apiKeyTransport??null,e.liveModels??null,e.disabled===!0,e.hasApiKey===!0,e.hasHeaders===!0,e.allowPrivateNetwork===!0,e.keyOptional===!0,e.activeNeedsReauth===!0,a??null]),[w,T]=(0,_.useState)(null),E=(0,_.useRef)(null),D=w?.key===C&&w.testing,O=w?.key===C?w.result:null;(0,_.useEffect)(()=>()=>{E.current?.key===C&&(E.current.controller.abort(),E.current=null)},[C]);let k=(0,_.useCallback)(async()=>{if(!i)return;E.current?.controller.abort();let t=new AbortController;E.current={key:C,controller:t},T({key:C,testing:!0,result:null});try{let n=await J(await fetch(`${i}/api/providers/test?name=${encodeURIComponent(e.name)}`,{method:`POST`,signal:t.signal}),p(`pws.connectionFailed`));if(!n)throw Error(p(`pws.connectionFailed`));t.signal.aborted||T({key:C,testing:!1,result:n})}catch(e){t.signal.aborted||T({key:C,testing:!1,result:{applicable:!0,ok:!1,error:e instanceof Error?e.message:p(`pws.connectionFailed`)}})}finally{E.current?.controller===t&&(E.current=null)}},[i,C,e.name,p]),A=O?.applicable===!1?`not-applicable`:O?.ok===!0?`ok`:`failed`,j=O?.applicable===!1?p(`pws.connectionNotApplicable`):O?.ok===!0?O.message||p(`pws.connectionOk`):O?.error||p(`pws.connectionFailed`);return(0,z.jsxs)(`div`,{className:`pws-overview-layout`,children:[(0,z.jsxs)(`div`,{className:`pws-overview-main`,children:[(0,z.jsxs)(`section`,{className:`pws-section`,"aria-label":p(`pws.connection`),children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:p(`pws.connection`)}),(0,z.jsxs)(`dl`,{className:`pws-kv`,children:[(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:p(`dash.status`)}),(0,z.jsxs)(`dd`,{className:g===`ready`?`pws-status-ok`:`pws-status-warn`,children:[g===`ready`?(0,z.jsx)(ie,{style:{width:13,height:13},"aria-hidden":`true`}):(0,z.jsx)(de,{style:{width:13,height:13},"aria-hidden":`true`}),y]})]}),(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:p(`modal.baseUrl`)}),(0,z.jsx)(`dd`,{children:(0,z.jsx)(`code`,{children:e.baseUrl?.trim()?e.baseUrl:`—`})})]}),(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:p(`pws.cell.auth`)}),(0,z.jsx)(`dd`,{children:r?`${xr(e,p)} · ${r}`:xr(e,p)})]}),(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:p(`modal.defaultModel`)}),(0,z.jsx)(`dd`,{children:e.defaultModel??(0,z.jsx)(`span`,{className:`muted`,children:`—`})})]}),e.note&&(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:p(`pws.cell.note`)}),(0,z.jsx)(`dd`,{className:`muted`,children:e.note})]})]}),i&&(0,z.jsxs)(`div`,{className:`row`,style:{marginTop:12,alignItems:`center`},children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:D,onClick:()=>void k(),children:p(D?`pws.testing`:`pws.testConnection`)}),O&&(0,z.jsx)(`span`,{role:`status`,className:A===`ok`?`pws-status-ok`:A===`failed`?`pws-status-warn`:`muted`,"data-connection-test-state":A,children:j})]}),o&&(0,z.jsx)(`button`,{type:`button`,className:`link-btn pws-edit-settings-link`,onClick:o,children:p(`pws.editSettings`)})]}),f?(0,z.jsx)(`section`,{className:`pws-section`,"aria-label":p(`pws.availableAccounts`),children:f}):(0,z.jsxs)(`section`,{className:`pws-section`,"aria-label":p(`pws.authSummary`),children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:p(`pws.authSummary`)}),v?(0,z.jsxs)(`div`,{className:`pws-auth-summary pws-auth-summary--warn`,role:`status`,children:[(0,z.jsx)(de,{style:{width:14,height:14},"aria-hidden":`true`}),(0,z.jsxs)(`div`,{className:`pws-auth-summary-body`,children:[(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`strong`,{children:p(`pws.status.needsAttention`)}),` — `,e.authMode===`forward`?p(`pws.attention.reauthForward`):p(`pws.attention.reauth`)]}),l&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:d,onClick:()=>l(),children:p(d?`prov.waitingBrowser`:`pws.reauthenticate`)}),d&&u&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>u(),children:p(`common.cancel`)})]})]}):(0,z.jsxs)(`div`,{className:`pws-auth-summary`,children:[(0,z.jsx)(`span`,{className:`pws-auth-dot`}),(0,z.jsx)(`span`,{children:e.authMode===`forward`?p(`pws.passthrough`):e.authMode===`oauth`?r?p(`pws.loggedInAs`,{email:r}):p(`pws.notLoggedIn`):e.hasApiKey?p(`pws.apiKeyConfigured`):xr(e,p)})]})]})]}),(0,z.jsxs)(`aside`,{className:`pws-overview-sidebar`,children:[(0,z.jsxs)(`section`,{className:`pws-section`,"aria-label":p(`pws.statsAria`),children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:p(`pws.statsTitle`)}),(0,z.jsxs)(`dl`,{className:`pws-kv`,children:[typeof b==`number`&&(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:p(`pws.stats.totalRequests`)}),(0,z.jsx)(`dd`,{className:`pws-kv-mono`,children:lr(b,m)})]}),typeof x==`number`&&(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:p(`pws.stats.totalTokens`)}),(0,z.jsx)(`dd`,{className:`pws-kv-mono`,children:ur(x,m)})]}),n&&(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:p(`pws.stats.quotaUpdated`)}),(0,z.jsx)(`dd`,{className:`pws-kv-mono`,title:n.source?Er(n.source):void 0,children:ar(n.updatedAt,h)})]}),typeof b!=`number`&&typeof x!=`number`&&!n&&(0,z.jsx)(`div`,{className:`muted`,children:p(`pws.usageUnavailable`)})]}),s&&(0,z.jsxs)(`button`,{type:`button`,className:`link-btn pws-view-usage-link`,onClick:s,children:[p(`pws.viewUsage`),` →`]}),S&&(0,z.jsx)(`div`,{className:`muted pws-stats-note`,children:p(`pws.stats.quotaTracked`)})]}),(0,z.jsx)(ei,{item:e,onUpdateProvider:c})]})]})}function ei({item:e,onUpdateProvider:t}){let n=K(),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(``),d=(0,_.useRef)(null);(0,_.useEffect)(()=>{r&&d.current?.focus()},[r]);let f=(0,_.useCallback)(async()=>{if(s||!t)return;let r=a.trim();if(r===(e.note??``)){i(!1),u(``);return}c(!0);try{let a=await t(e.name,{note:r||void 0});if(!a.ok){u(a.error||n(`prov.saveFailed`));return}u(``),i(!1)}finally{c(!1)}},[a,e.name,e.note,t,s,n]);return r?(0,z.jsxs)(`section`,{className:`pws-section pws-notes-section`,"aria-label":n(`pws.notes`),children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:n(`pws.notes`)}),(0,z.jsx)(`textarea`,{ref:d,className:`pws-notes-textarea`,value:a,onChange:e=>o(e.target.value),onBlur:()=>void f(),onKeyDown:t=>{t.key===`Escape`&&(o(e.note??``),u(``),i(!1))},placeholder:n(`pws.notePlaceholder`),rows:3,disabled:s}),l?(0,z.jsx)(`p`,{className:`pws-inline-error`,role:`alert`,children:l}):null]}):(0,z.jsxs)(`section`,{className:`pws-section pws-notes-section`,"aria-label":n(`pws.notes`),children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:n(`pws.notes`)}),(0,z.jsx)(`button`,{type:`button`,className:`pws-notes-display`,onClick:()=>{t&&(o(e.note??``),u(``),i(!0))},disabled:!t,children:e.note||(0,z.jsx)(`span`,{className:`muted`,children:n(`pws.notePlaceholder`)})})]})}function ti({item:e,apiBase:t,availableModels:n,hasLiveModels:r,selectedModels:i,modelsLoading:a=!1,modelsLoadFailed:o=!1,needsReauth:s=!1,onRetryModels:c,onOpenAccounts:l}){let u=K(),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(!1),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(``),[S,C]=(0,_.useState)([]),[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(0),[A,j]=(0,_.useState)(null),M=(0,_.useRef)(null),N=(0,_.useMemo)(()=>new Set(i),[i]),P=(0,_.useMemo)(()=>e.models??[],[e.models]),F=p.trim(),I=!w||!F||F.includes(`/`)||n.includes(F)||S.includes(F)||P.includes(F)||e.defaultModel===F,L=(0,_.useMemo)(()=>Dr(n,e.defaultModel,d,P,S,r),[n,e.defaultModel,d,P,S,r]);(0,_.useEffect)(()=>{let n=!0;return(async()=>{try{let r=await fetch(`${t}/api/custom-models`);if(!r.ok)throw Error();let i=await r.json();if(!Array.isArray(i))throw Error(`Invalid custom model list`);if(!n)return;C(i.flatMap(t=>{if(!t||typeof t!=`object`)return[];let n=t;return n.provider===e.name&&typeof n.modelId==`string`?[n.modelId]:[]})),D(!1),y(``),T(!0)}catch{if(!n)return;C([]),T(!1),D(!0),y(u(`models.networkError`))}})(),()=>{n=!1}},[t,e.name,u,O]);let R=()=>{T(!1),D(!1),y(``),k(e=>e+1)};(0,_.useEffect)(()=>()=>{M.current!=null&&window.clearTimeout(M.current)},[]);let B=async e=>{try{await navigator.clipboard.writeText(e),j(e),M.current!=null&&window.clearTimeout(M.current),M.current=window.setTimeout(()=>{j(t=>t===e?null:t),M.current=null},1200)}catch{}},V=async()=>{if(!(I||h)){g(!0),y(``),x(``);try{(await fetch(`${t}/api/custom-models`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.name,modelId:F})})).ok?(C(e=>e.includes(F)?e:[...e,F]),m(``),x(u(`models.customAdded`)),c?.()):y(u(`models.customSaveFailed`))}catch{y(u(`models.networkError`))}finally{g(!1)}}},H=n.length===0&&P.length===0&&S.length===0&&!e.defaultModel,U=n.length===0&&P.length>0,W=L.length>300,ee=W?L.slice(0,300):L;return(0,z.jsxs)(`div`,{className:`pws-section`,children:[(0,z.jsxs)(`div`,{className:`pws-section-head`,children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:u(`pws.tab.models`)}),L.length>0&&(0,z.jsx)(`span`,{className:`muted`,children:u(`pws.modelsAvailable`,{count:L.length})})]}),s&&(0,z.jsxs)(`div`,{className:`pws-inline-error`,role:`status`,children:[(0,z.jsx)(`span`,{children:u(`pws.modelsNeedsReauth`)}),l&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:l,children:u(`pws.tab.accounts`)})]}),U&&!s&&(0,z.jsx)(`p`,{className:`muted text-label`,style:{marginBottom:10},children:u(`pws.modelsConfiguredFallback`)}),(0,z.jsx)(`label`,{className:`text-label pws-custom-model-label`,htmlFor:`pws-custom-model-${e.name}`,children:u(`models.customAdd`)}),(0,z.jsxs)(`div`,{className:`row pws-custom-model-row`,children:[(0,z.jsx)(`input`,{id:`pws-custom-model-${e.name}`,className:`input`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&V()},placeholder:u(`models.customFieldModelIdPlaceholder`),"aria-label":u(`models.customAdd`),disabled:h}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>{V()},disabled:h||I,children:u(h?`models.customSaving`:`models.customAddBtn`)})]}),b&&(0,z.jsx)(`p`,{className:`muted text-label`,role:`status`,children:b}),v&&(0,z.jsxs)(`p`,{className:`pws-inline-error`,role:`alert`,children:[v,E&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:R,style:{marginLeft:8},children:u(`common.retry`)})]}),!H&&(0,z.jsx)(`input`,{type:`search`,className:`input pws-model-search`,placeholder:u(`pws.modelSearchPlaceholder`),value:d,onChange:e=>f(e.target.value),"aria-label":u(`pws.modelSearchPlaceholder`)}),a&&H?(0,z.jsx)(`p`,{className:`muted`,role:`status`,children:u(`pws.modelsLoading`)}):o&&H?(0,z.jsxs)(`div`,{role:`alert`,className:`pws-inline-error`,children:[(0,z.jsx)(`span`,{children:u(`pws.modelsLoadFailed`)}),c&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:c,children:u(`pws.retry`)})]}):H?(0,z.jsx)(`p`,{className:`muted`,children:u(`pws.noModels`)}):L.length===0?(0,z.jsx)(`p`,{className:`muted`,role:`status`,children:u(`pws.noModelMatch`)}):(0,z.jsx)(`ul`,{className:`pws-model-list`,children:ee.map(t=>{let n=t===e.defaultModel,r=N.has(t);return(0,z.jsxs)(`li`,{className:`pws-model-chip`,children:[(0,z.jsx)(`button`,{type:`button`,className:`pws-model-chip-main`,onClick:()=>{B(t)},title:t,"aria-label":u(A===t?`pws.modelCopied`:`pws.copyModelId`),children:(0,z.jsx)(`span`,{className:`pws-model-id`,children:t})}),n?(0,z.jsx)(`span`,{className:`badge badge-muted pws-model-flag`,children:u(`prov.defaultBadge`)}):null,r?(0,z.jsx)(`span`,{className:`badge badge-accent pws-model-flag`,children:u(`pws.selected`)}):null]},t)})}),W&&(0,z.jsx)(`p`,{className:`muted text-label`,style:{marginTop:10},children:u(`pws.modelsTruncated`,{shown:`300`,total:String(L.length)})})]})}function ni({item:e,usageTotals:t,quotaReport:n,modelUsage:r}){let i=K(),{locale:a}=Ve(),o=or(i),s=t?.requests!==void 0,c=Tr(n),[l,u]=(0,_.useState)(null),d=(0,_.useMemo)(()=>r?.length?r.toSorted((e,t)=>t.totalTokens-e.totalTokens):[],[r]),f=(0,_.useMemo)(()=>{if(!d.length)return;let e=0,t=!1;for(let n of d)n.estimatedCostUsd!==void 0&&(e+=n.estimatedCostUsd,t=!0);return t?e:void 0},[d]);return(0,z.jsxs)(`div`,{className:`pws-section`,children:[(0,z.jsxs)(`div`,{className:`pws-usage-block`,children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:i(`pws.usageLast30d`)}),s?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`pws-usage-metrics pws-usage-metrics-3`,role:`group`,"aria-label":i(`pws.usageLast30d`),children:[(0,z.jsxs)(`div`,{className:`pws-usage-metric`,children:[(0,z.jsx)(`span`,{className:`pws-usage-metric-value mono`,children:dr(f,a)}),(0,z.jsx)(`span`,{className:`muted pws-usage-metric-label`,children:i(`pws.estimatedCost`)})]}),(0,z.jsxs)(`div`,{className:`pws-usage-metric`,children:[(0,z.jsx)(`span`,{className:`pws-usage-metric-value`,children:lr(t?.requests,a)}),(0,z.jsx)(`span`,{className:`muted pws-usage-metric-label`,children:i(`pws.metricRequests`)})]}),(0,z.jsxs)(`div`,{className:`pws-usage-metric`,children:[(0,z.jsx)(`span`,{className:`pws-usage-metric-value`,children:ur(t?.totalTokens,a)}),(0,z.jsx)(`span`,{className:`muted pws-usage-metric-label`,children:i(`pws.metricTokens`)})]})]}),(0,z.jsx)(`p`,{className:`muted pws-cost-disclaimer`,children:i(`pws.costDisclaimer`)})]}):(0,z.jsx)(`p`,{className:`muted`,children:i(`pws.usageUnavailable`)})]}),d.length>0&&(0,z.jsxs)(`div`,{className:`pws-usage-block`,children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:i(`pws.modelBreakdown`)}),(0,z.jsx)(`div`,{className:`tbl-wrap`,children:(0,z.jsxs)(`table`,{className:`pws-model-table`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:i(`pws.col.model`)}),(0,z.jsx)(`th`,{className:`num`,children:i(`pws.col.cost`)}),(0,z.jsx)(`th`,{className:`num`,children:i(`pws.col.tokens`)}),(0,z.jsx)(`th`,{className:`num`,children:i(`pws.col.requests`)}),(0,z.jsx)(`th`,{children:i(`pws.col.share`)})]})}),(0,z.jsx)(`tbody`,{children:d.map(e=>{let t=e.model,n=l===t;return(0,z.jsxs)(_.Fragment,{children:[(0,z.jsxs)(`tr`,{className:`pws-model-row`,children:[(0,z.jsx)(`td`,{className:`mono`,children:(0,z.jsx)(`button`,{type:`button`,className:`pws-model-expand`,"aria-expanded":n,onClick:()=>u(n?null:t),children:e.model})}),(0,z.jsx)(`td`,{className:`num mono`,children:dr(e.estimatedCostUsd,a)}),(0,z.jsx)(`td`,{className:`num mono`,children:ur(e.totalTokens,a)}),(0,z.jsx)(`td`,{className:`num`,children:e.requests}),(0,z.jsx)(`td`,{children:(0,z.jsx)(`div`,{className:`pws-share-bar`,children:(0,z.jsx)(`div`,{className:`pws-share-bar-fill`,style:{width:`${Math.round(e.shareRatio*100)}%`}})})})]}),n&&(0,z.jsx)(`tr`,{className:`pws-model-detail`,children:(0,z.jsx)(`td`,{colSpan:5,children:(0,z.jsxs)(`div`,{className:`pws-model-detail-grid`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`muted`,children:i(`pws.tokenInput`)}),(0,z.jsxs)(`span`,{className:`mono`,children:[` `,ur(e.inputTokens,a)]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`muted`,children:i(`pws.tokenOutput`)}),(0,z.jsxs)(`span`,{className:`mono`,children:[` `,ur(e.outputTokens,a)]})]})]})})})]},t)})})]})})]}),(0,z.jsxs)(`div`,{className:`pws-usage-block`,children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:i(`pws.rateLimits`)}),c?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Br,{quota:c,plan:null,threshold:80,t:i,layout:`stacked`}),(0,z.jsxs)(`dl`,{className:`pws-kv pws-usage-meta`,children:[n?.source?.trim()&&(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:i(`pws.stats.source`)}),(0,z.jsx)(`dd`,{children:Er(n.source)})]}),(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:i(`pws.stats.quotaUpdated`)}),(0,z.jsx)(`dd`,{children:ar(n?.updatedAt,o)})]})]})]}):(0,z.jsx)(`p`,{className:`muted`,children:i(`pws.quotaUnavailable`)})]})]})}function ri(e){if(!e)return null;let t=e.trim();return t?t.length<=4?`account-…`:`account-…${t.slice(-4)}`:null}function ii(e){return ri(e)??`account-…`}function ai(e){return e===`healthy`?`ok`:e===`cooldown`?`muted`:e===`reauth_required`||e===`warning`?`warn`:`muted`}function oi(e){let t=ai(e);return t===`ok`?`badge badge-green`:t===`warn`?`badge badge-amber`:`badge badge-muted`}function si(e){return e===`reauth_required`}function ci(e){return!!e?.needsReauth||si(e?.health?.status)}function li(e){return e===`cooldown`}function ui(e){return e===`warning`||e===`reauth_required`}function di(e){if(!e||e.status===`healthy`)return null;if(e.status===`cooldown`)return e.reason===`rate_limit`?`pws.healthLabel.rateLimited`:`pws.healthLabel.quotaLimited`;if(e.status===`reauth_required`)return e.reason===`refresh_failed`?`pws.healthLabel.refreshFailed`:`pws.healthLabel.reauthRequired`;switch(e.reason){case`refresh_conflict`:return`pws.healthLabel.credentialConflict`;case`metadata_mismatch`:return`pws.healthLabel.metadataMismatch`;case`stale_credentials`:return`pws.healthLabel.refreshFailed`;default:return`pws.healthLabel.reauthRequired`}}function fi(e,t){let n=di(t);return n?e(n):null}function pi(e,t,n,r){if(!r||r.status===`healthy`)return null;let i=n===`__main__`?e(`codexAuth.mainAccount`):ii(n);if(r.status===`cooldown`){let n=r.until?new Date(r.until).toLocaleString():``;return e(r.reason===`rate_limit`?`pws.healthSummary.rateLimited`:`pws.healthSummary.quotaLimited`,{provider:t,account:i,until:n})}return r.status===`reauth_required`?e(`pws.healthSummary.reauthRequired`,{provider:t,account:i}):r.reason===`refresh_conflict`?e(`pws.healthSummary.credentialConflict`,{provider:t,account:i}):r.reason===`metadata_mismatch`?e(`pws.healthSummary.metadataMismatch`,{provider:t,account:i}):e(`pws.healthSummary.staleCredentials`,{provider:t,account:i})}async function mi(e){let t=navigator.clipboard?.writeText?.bind(navigator.clipboard);if(t)try{return await t(e),!0}catch{}return hi(e)}function hi(e){if(typeof document>`u`||typeof document.execCommand!=`function`)return!1;let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.setAttribute(`aria-hidden`,`true`),t.style.position=`fixed`,t.style.top=`0`,t.style.opacity=`0`,document.body.appendChild(t);try{return t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}function gi(e,t){return e(t?t===`copied`?`pws.doctorCopied`:`pws.doctorCopyUnavailable`:`pws.copyDoctor`)}var _i=e=>({step:e?`oauth-waiting`:`pick`,id:``,error:``,authUrl:``,manualCode:``,manualCodeState:`idle`,statusNotice:``,statusTone:`ok`,flowId:null});function vi(e,t){switch(t.type){case`set-step`:return{...e,step:t.step};case`set-id`:return{...e,id:t.id};case`set-error`:return{...e,error:t.error};case`set-auth-url`:return{...e,authUrl:t.authUrl};case`set-manual-code`:return{...e,manualCode:t.manualCode};case`set-manual-code-state`:return{...e,manualCodeState:t.manualCodeState};case`set-status-notice`:return{...e,statusNotice:t.statusNotice,statusTone:t.statusTone??e.statusTone};case`set-flow-id`:return{...e,flowId:t.flowId};case`clear-manual-code`:return{...e,manualCode:``,manualCodeState:`idle`,statusNotice:``,statusTone:`ok`};case`reset-oauth-start`:return{...e,error:``,statusNotice:``,statusTone:`ok`,flowId:null};case`oauth-code-submitted`:return{...e,error:``,manualCode:``,manualCodeState:`waiting`,statusTone:`ok`,statusNotice:``};default:return e}}function yi({id:e,error:t,onIdChange:n,onStartOAuth:r,onClose:i}){let a=K();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`h3`,{style:{marginBottom:4},children:a(`codexAuth.addTitle`)}),(0,z.jsx)(`p`,{className:`modal-desc`,children:a(`codexAuth.addPickDesc`)}),(0,z.jsx)(`label`,{className:`field-label`,htmlFor:`codex-account-id-input`,children:a(`codexAuth.addIdLabel`)}),(0,z.jsx)(`input`,{id:`codex-account-id-input`,className:`input`,placeholder:a(`codexAuth.addIdPlaceholder`),value:e,onChange:e=>n(e.target.value),style:{marginBottom:12}}),(0,z.jsx)(`button`,{type:`button`,className:`list-row`,onClick:r,style:{marginBottom:8},children:(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[(0,z.jsx)(Oe,{width:20}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`title`,children:a(`codexAuth.oauthLogin`)}),(0,z.jsx)(`div`,{className:`sub`,children:a(`codexAuth.oauthDesc`)})]})]})}),t&&(0,z.jsx)(`div`,{className:`notice notice-err`,style:{marginTop:8},children:t}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:i,style:{width:`100%`},children:a(`codexAuth.cancel`)})]})}var bi=2500;function xi(){let[e,t]=(0,_.useState)(null),n=(0,_.useRef)(null),r=(0,_.useRef)(0),i=(0,_.useCallback)(()=>{n.current&&=(clearTimeout(n.current),null)},[]);return(0,_.useEffect)(()=>i,[i]),{outcomeFor:(0,_.useCallback)(t=>e&&Object.is(e.scope,t)?e.outcome:null,[e]),copy:(0,_.useCallback)((e,a)=>{let o=++r.current;mi(e).then(e=>{r.current===o&&(i(),t({scope:a,outcome:e?`copied`:`unavailable`}),n.current=setTimeout(()=>{n.current=null,r.current===o&&t(null)},bi))})},[i])}}function Si({url:e}){let t=K(),{outcomeFor:n,copy:r}=xi();if(!e)return null;let i=n(e),a=t(i===`copied`?`prov.linkCopied`:i===`unavailable`?`prov.linkCopyUnavailable`:`prov.copyLink`);return(0,z.jsxs)(`div`,{className:`login-url-block`,children:[(0,z.jsx)(`code`,{className:`login-url-block-text`,children:e}),(0,z.jsxs)(`div`,{className:`login-url-block-actions`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>r(e,e),children:[(0,z.jsx)(we,{style:{width:13,height:13},"aria-hidden":`true`}),(0,z.jsx)(`span`,{"aria-live":`polite`,children:a})]}),(0,z.jsxs)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`login-url-block-open`,children:[(0,z.jsx)(be,{style:{width:13,height:13},"aria-hidden":`true`}),` `,t(`prov.didntOpen`)]})]})]})}function Ci({reauthAccountId:e,authUrl:t,manualCode:n,manualCodeBusy:r,manualCodeWaiting:i,statusNotice:a,statusTone:o,flowId:s,error:c,onManualCodeChange:l,onSubmitManualCode:u,onClose:d}){let f=K();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`h3`,{style:{marginBottom:4},children:f(e?`codexAuth.reauthenticate`:`codexAuth.oauthLogin`)}),(0,z.jsx)(`p`,{className:`modal-desc`,children:f(`codexAuth.oauthWaiting`)}),(0,z.jsx)(Si,{url:t}),(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,marginTop:12},children:[(0,z.jsx)(`div`,{className:`muted text-label`,children:f(`prov.pasteRedirectHint`)}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,z.jsx)(`input`,{type:`text`,autoComplete:`off`,spellCheck:!1,value:n,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),u())},placeholder:f(`prov.pasteRedirect`),"aria-label":f(`prov.pasteRedirect`),disabled:r||i,className:`input text-label`,style:{flex:1}}),(0,z.jsx)(`button`,{className:`btn btn-ghost`,type:`button`,disabled:r||i||!n.trim()||!s,onClick:u,children:f(r?`codexAuth.oauthSubmittingCode`:`prov.pasteSubmit`)})]})]}),a&&(0,z.jsx)(`div`,{className:o===`warn`?`notice-warn`:`notice notice-ok`,role:`status`,"aria-live":`polite`,style:{marginTop:12},children:a}),c&&(0,z.jsx)(`div`,{className:`notice notice-err`,style:{marginTop:12},children:c}),(0,z.jsx)(`div`,{style:{textAlign:`center`,padding:`24px 0`},children:(0,z.jsx)(`span`,{className:`spin`,style:{width:24,height:24}})}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:d,style:{width:`100%`},children:f(`codexAuth.cancel`)})]})}function wi({apiBase:e,reauthAccountId:t,ui:n,dispatch:r,t:i}){let a=(0,_.useRef)(!0),o=(0,_.useRef)(0),s=(0,_.useRef)(!1),c=(0,_.useRef)(null),l=(0,_.useRef)(null),u=(0,_.useRef)(null),d=(0,_.useRef)(null),f=(0,_.useRef)(n.manualCodeState),p=(0,_.useRef)(null),m=(0,_.useRef)(null),h=(0,_.useRef)(()=>{}),g=(0,_.useRef)(()=>{}),v=n.manualCodeState===`submitting`,y=n.manualCodeState===`waiting`;(0,_.useEffect)(()=>{f.current=n.manualCodeState},[n.manualCodeState]),(0,_.useEffect)(()=>{d.current=n.flowId},[n.flowId]);let b=(0,_.useCallback)(()=>{c.current&&=(clearInterval(c.current),null),l.current&&=(clearTimeout(l.current),null),u.current?.abort(),u.current=null,s.current=!1},[]),x=(0,_.useCallback)(()=>{r({type:`clear-manual-code`}),o.current=0},[r]),S=(0,_.useCallback)(async()=>{x();let t=d.current;d.current=null,r({type:`set-flow-id`,flowId:null}),r({type:`set-auth-url`,authUrl:``}),b(),p.current?.abort(),p.current=null,t&&await fetch(`${e}/api/codex-auth/login/cancel`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({flowId:t})}).catch(()=>{})},[e,x,r,b]);(0,_.useEffect)(()=>(a.current=!0,()=>{x(),a.current=!1,m.current=null,p.current?.abort(),p.current=null;let t=d.current;d.current=null,r({type:`set-flow-id`,flowId:null}),b(),t&&fetch(`${e}/api/codex-auth/login/cancel`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({flowId:t})}).catch(()=>{})}),[e,x,r,b]);let C=(0,_.useCallback)((e,t)=>{h.current=e,g.current=t},[]),w=(0,_.useCallback)(()=>{n.step===`oauth-waiting`&&S(),g.current()},[n.step,S]),T=(0,_.useCallback)(async n=>{x(),d.current=null,r({type:`set-flow-id`,flowId:null});let m=new AbortController;p.current?.abort(),p.current=m,r({type:`reset-oauth-start`}),o.current=0;try{let p=t??n?.trim()??``,_=()=>fetch(`${e}/api/codex-auth/login`,{signal:m.signal,method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t?{id:t,reauth:!0}:p?{id:p}:{})}),v=await _();if(!a.current)return;if(v.status===409){if(await fetch(`${e}/api/codex-auth/login/cancel`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`}),!a.current||m.signal.aborted)return;if(v=await _(),v.status===409){r({type:`set-error`,error:i(`codexAuth.oauthAlreadyInProgress`)});return}}let y=await J(v,i(`modal.networkError`));if(!a.current||!y)return;if(y.url){d.current=y.flowId??null,r({type:`set-flow-id`,flowId:y.flowId??null}),r({type:`set-auth-url`,authUrl:y.url}),r({type:`set-step`,step:`oauth-waiting`}),b();let n=y.flowId??``,m=t?`&reauth=1`:``,_=n?`${e}/api/codex-auth/login-status?flowId=${encodeURIComponent(n)}${p?`&accountId=${encodeURIComponent(p)}`:``}${m}`:`${e}/api/codex-auth/login-status`,v=new AbortController;u.current=v,c.current=setInterval(async()=>{if(s.current||v.signal.aborted)return;s.current=!0;let e=AbortSignal.any([v.signal,AbortSignal.timeout(1e4)]);try{let n=await ut(await fetch(_,{signal:e}));if(!a.current||v.signal.aborted)return;if(!n){o.current+=1,o.current>=3&&r({type:`set-status-notice`,statusNotice:i(`codexAuth.oauthStatusRetrying`),statusTone:`warn`});return}if(o.current=0,f.current===`waiting`?r({type:`set-status-notice`,statusNotice:i(`codexAuth.oauthCodeSubmitted`),statusTone:`ok`}):r({type:`set-status-notice`,statusNotice:``,statusTone:`ok`}),n.status===`done`){if(b(),x(),d.current=null,r({type:`set-flow-id`,flowId:null}),!a.current)return;h.current(),g.current()}else(n.status===`error`||n.status===`expired`)&&(b(),x(),d.current=null,r({type:`set-flow-id`,flowId:null}),a.current&&(t||r({type:`set-step`,step:`pick`}),r({type:`set-error`,error:n.error??i(`codexAuth.loginFailed`)})))}catch(e){if(!a.current||v.signal.aborted||e instanceof Error&&e.name===`AbortError`)return;o.current+=1,o.current>=3&&r({type:`set-status-notice`,statusNotice:i(`codexAuth.oauthStatusRetrying`),statusTone:`warn`})}finally{s.current=!1}},2e3),l.current=setTimeout(()=>{c.current&&(x(),S(),a.current&&(t||r({type:`set-step`,step:`pick`}),r({type:`set-error`,error:i(`modal.loginTimeout`)})))},3e5)}y.error&&!y.url&&r({type:`set-error`,error:y.error})}catch(e){a.current&&!(e instanceof Error&&e.name===`AbortError`)&&r({type:`set-error`,error:e instanceof Error?e.message:String(e)})}},[e,S,x,r,t,b,i]);return(0,_.useEffect)(()=>{if(!t){m.current=null;return}m.current!==t&&(m.current=t,T())},[t,T]),{manualCodeBusy:v,manualCodeWaiting:y,bindCallbacks:C,closeModal:w,startOAuth:T,submitManualCode:(0,_.useCallback)(async()=>{let t=d.current,s=n.manualCode.trim();if(!(!t||!s||v||y)){r({type:`set-manual-code-state`,manualCodeState:`submitting`}),r({type:`set-status-notice`,statusNotice:``,statusTone:`ok`});try{let n=await fetch(`${e}/api/codex-auth/login/code`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({flowId:t,input:s})});if(!a.current)return;if(!n.ok){r({type:`set-error`,error:i(`prov.pasteFail`,{error:(await n.json().catch(()=>({}))).error??n.statusText})}),r({type:`set-manual-code-state`,manualCodeState:`idle`});return}r({type:`oauth-code-submitted`}),r({type:`set-status-notice`,statusNotice:i(`codexAuth.oauthCodeSubmitted`),statusTone:`ok`}),o.current=0}catch{a.current&&(r({type:`set-error`,error:i(`modal.networkError`)}),r({type:`set-manual-code-state`,manualCodeState:`idle`}))}}},[e,r,v,y,i,n.manualCode])}}function Ti({apiBase:e,onClose:t,onAdded:n,reauthAccountId:r}){let i=K(),[a,o]=(0,_.useReducer)(vi,r,_i),s=(0,_.useRef)(null),c=(0,_.useRef)(null),{manualCodeBusy:l,manualCodeWaiting:u,bindCallbacks:d,closeModal:f,startOAuth:p,submitManualCode:m}=wi({apiBase:e,reauthAccountId:r,ui:a,dispatch:o,t:i});(0,_.useEffect)(()=>{d(n,t)},[d,n,t]),(0,_.useEffect)(()=>{s.current=document.activeElement;let e=c.current;e&&!e.open&&e.showModal();let t=e?.querySelector(`input:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex='-1'])`);return t&&t.focus(),()=>{s.current?.focus()}},[]);let h=(0,_.useCallback)(e=>{e.preventDefault(),f()},[f]);return(0,z.jsx)(`dialog`,{ref:c,"aria-label":i(r?`codexAuth.reauthenticate`:`codexAuth.addTitle`),className:`modal-overlay`,onCancel:h,children:(0,z.jsxs)(`div`,{className:`modal-card`,style:{maxWidth:440},children:[a.step===`pick`&&(0,z.jsx)(yi,{id:a.id,error:a.error,onIdChange:e=>o({type:`set-id`,id:e}),onStartOAuth:()=>{p(a.id)},onClose:f}),a.step===`oauth-waiting`&&(0,z.jsx)(Ci,{reauthAccountId:r,authUrl:a.authUrl,manualCode:a.manualCode,manualCodeBusy:l,manualCodeWaiting:u,statusNotice:a.statusNotice,statusTone:a.statusTone,flowId:a.flowId,error:a.error,onManualCodeChange:e=>o({type:`set-manual-code`,manualCode:e}),onSubmitManualCode:()=>{m()},onClose:f})]})})}var Ei=1e4;function Di(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0&&e<=100?e:80}function Oi(e){let t=e.trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return n>=1&&n<=100?n:null}function ki(e,t){return e>0?0:Number.isInteger(t)&&t>=1&&t<=100?t:80}function Ai(e,t,n,r){return n===r?e||t?`defer`:`apply`:`ignore`}function ji(e){return e&&typeof e==`object`&&e&&`autoSwitchThreshold`in e?e.autoSwitchThreshold:e}function Mi(e,t,n){if(e<=0){let t=ki(e,n);return{threshold:t,lastEnabled:t}}return{threshold:0,lastEnabled:Oi(t)??ki(0,n)}}async function Ni(e,t,n=(e,t)=>fetch(e,t),r=Ei){if(!Number.isInteger(t)||t<0||t>100)return!1;try{return(await n(`${e}/api/codex-auth/auto-switch`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({threshold:t}),signal:AbortSignal.timeout(r)})).ok}catch{return!1}}var Pi=3e4,Fi=new Map;function Ii(e,t=!0){let n=Fi.get(e),[r,i]=(0,_.useState)(()=>n?.accounts??[]),[a,o]=(0,_.useState)(()=>n?.activeId??null),[s,c]=(0,_.useState)(()=>n==null?`loading`:`ready`),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(0),[v,y]=(0,_.useState)(()=>n!=null),[b,x]=(0,_.useState)(0),S=(0,_.useRef)(new Set),C=(0,_.useRef)(null),w=(0,_.useRef)(0),T=(0,_.useRef)(null),E=(0,_.useRef)(new Set),D=(0,_.useRef)(null),O=(0,_.useRef)(null),k=(0,_.useRef)(!!n?.accounts.length),A=(0,_.useRef)(n!=null),j=(0,_.useRef)(null),M=(0,_.useCallback)(e=>(E.current.add(e),()=>{E.current.delete(e)}),[]),N=(0,_.useCallback)(()=>ji(D.current?.value),[]),P=(0,_.useCallback)(()=>D.current?.value,[]),F=(0,_.useCallback)(async(t=!1)=>{let n=++w.current;g(e=>e+1);try{let r=[...E.current],a=new Map;for(let e of r)a.set(e,e.beginActiveRead());!t&&!A.current&&c(`loading`);let s=null,l,u=(async()=>{try{let r=await fetch(`${e}/api/codex-auth/accounts${t?`?refresh=1`:``}`);if(!r.ok)throw Error(`account load failed`);let a=await r.json();return w.current===n&&(s=a.accounts??[],i(s),k.current=s.length>0,A.current=!0,c(`ready`)),!0}catch{return!1}})(),d=(async()=>{try{let t=await fetch(`${e}/api/codex-auth/active`);if(!t.ok)throw Error(`active account load failed`);let i=await t.json();if(w.current===n){let e=i.activeCodexAccountId??null,t=T.current;t&&e!==t.id||(T.current=null,l=e,o(e)),D.current={value:i};for(let e of r)e.acceptActiveRead(i,a.get(e))}return!0}catch{if(w.current===n)for(let e of r)e.rejectActiveRead();return!1}})(),[f,p]=await Promise.all([u,d]);if(w.current!==n)return!1;if(f){c(`ready`),A.current=!0;let t=Fi.get(e);return Fi.set(e,{accounts:s??t?.accounts??[],activeId:l===void 0?t?.activeId??null:l}),p}return A.current||c(`error`),!1}finally{g(e=>Math.max(0,e-1)),y(!0)}},[e]);(0,_.useEffect)(()=>{t&&C.current!==e&&(C.current=e,Promise.resolve().then(()=>{F()}))},[e,t,F]);let I=r.some(e=>e.hasCredential&&!e.quota);(0,_.useEffect)(()=>{if(!t||!I||b>0)return;let e=[350,900,2e3].map(e=>window.setTimeout(()=>{F(!1)},e));return()=>{for(let t of e)window.clearTimeout(t)}},[t,I,b,F]),(0,_.useEffect)(()=>{if(!t||b>0)return;let e=window.setInterval(()=>{F()},Pi);return()=>window.clearInterval(e)},[t,F,b]);let L=(0,_.useCallback)(()=>{let e={};return S.current.add(e),x(S.current.size),e},[]),R=(0,_.useCallback)(e=>{S.current.delete(e)&&x(S.current.size)},[]),z=(0,_.useCallback)(async t=>{if(O.current)return{ok:!1,reason:`busy`};O.current=t??`__main__`,u(t??`__main__`);try{let n=await fetch(`${e}/api/codex-auth/active`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({accountId:t})});if(!n.ok)throw Error(`account switch failed`);let r=(await n.json().catch(()=>({}))).activeCodexAccountId??t;return T.current={id:r??null},o(r??null),F(),{ok:!0,activeId:r??null}}catch{return{ok:!1,reason:`request`}}finally{O.current=null,u(null)}},[e,F]),B=(0,_.useCallback)(async(t,n)=>{try{return(await fetch(`${e}/api/codex-auth/accounts/alias`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t,alias:n.trim()})})).ok?(await F(),{ok:!0}):{ok:!1,reason:`request`}}catch{return{ok:!1,reason:`request`}}},[e,F]),V=(0,_.useCallback)(async(t,n)=>{if(j.current)return{ok:!1,reason:`busy`};j.current={accountId:t},f(t);try{let r=await fetch(`${e}/api/codex-auth/accounts/pause`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t,paused:n})});if(!r.ok)return{ok:!1,reason:`request`};let a=await r.json().catch(()=>({})),s=a&&typeof a==`object`?a:{};if(i(e=>e.map(e=>e.id===t||t===`__main__`&&e.isMain?{...e,paused:n}:e)),Object.prototype.hasOwnProperty.call(s,`activeCodexAccountId`)){let e=s.activeCodexAccountId??null;T.current={id:e},o(e)}return F(),{ok:!0}}catch{return{ok:!1,reason:`request`}}finally{j.current=null,f(null)}},[e,F]),H=(0,_.useCallback)(async()=>{if(j.current)return{ok:!1,reason:`busy`};j.current=`bulk`,m(!0);try{let t=await fetch(`${e}/api/codex-auth/accounts/pause-exhausted`,{method:`PUT`});if(!t.ok)return{ok:!1,reason:`request`};let n=await t.json().catch(()=>({})),r=n&&typeof n==`object`?n:{},a=new Set(r.pausedAccountIds??[]);if(i(e=>e.map(e=>a.has(e.id)||a.has(`__main__`)&&e.isMain?{...e,paused:!0}:e)),Object.prototype.hasOwnProperty.call(r,`activeCodexAccountId`)){let e=r.activeCodexAccountId??null;T.current={id:e},o(e)}return F(),{ok:!0,pausedCount:r.pausedCount??a.size}}catch{return{ok:!1,reason:`request`}}finally{j.current=null,m(!1)}},[e,F]),U=(0,_.useCallback)(async t=>{try{return(await fetch(`${e}/api/codex-auth/accounts?id=${encodeURIComponent(t)}`,{method:`DELETE`})).ok?(await F(),{ok:!0}):{ok:!1,reason:`request`}}catch{return{ok:!1,reason:`request`}}},[e,F]),W=(0,_.useCallback)(async()=>await F()?{ok:!0}:{ok:!1,reason:`reload`},[F]),ee=a&&a!==`__main__`?r.find(e=>e.id===a):null,te=r.find(e=>e.isMain),ne=ee??te,re=!ne?.paused&&ci(ne);return{accounts:r,activeId:a,loadState:s,refreshing:h>0,initialLoading:!v,switchingId:l,pauseUpdatingId:d,pausingExhausted:p,activeNeedsReauth:re,load:F,switchAccount:z,setAccountPaused:V,pauseExhaustedAccounts:H,saveAlias:B,removeAccount:U,syncAfterAccountAdded:W,pauseRefresh:L,resumeRefresh:R,subscribeLoadObserver:M,readLastThreshold:N,readLastActive:P}}function Li(e,t,n,r,i=1){let a=e.trim(),o=a===``?NaN:Number(a),s=Math.min(r,Math.max(n,(Number.isFinite(o)?o:n)+t));return String(i<1?Math.round(s*10)/10:Math.round(s))}function Ri({disabled:e=!1,onIncrement:t,onDecrement:n,incrementLabel:r,decrementLabel:i}){return(0,z.jsxs)(`div`,{className:`ocx-stepper`,role:`group`,children:[(0,z.jsx)(`button`,{type:`button`,className:`ocx-stepper__btn`,disabled:e,"aria-label":r,onMouseDown:e=>e.preventDefault(),onClick:t,children:(0,z.jsx)(me,{width:10,height:10,"aria-hidden":`true`})}),(0,z.jsx)(`button`,{type:`button`,className:`ocx-stepper__btn`,disabled:e,"aria-label":i,onMouseDown:e=>e.preventDefault(),onClick:n,children:(0,z.jsx)(he,{width:10,height:10,"aria-hidden":`true`})})]})}var zi={quota:{on:`codexAuth.autoSwitchQuotaDesc`,off:`codexAuth.autoSwitchQuotaOffDesc`},"round-robin":{on:`codexAuth.autoSwitchRoundRobinDesc`,off:`codexAuth.autoSwitchRoundRobinDesc`},"fill-first":{on:`codexAuth.autoSwitchFillFirstDesc`,off:`codexAuth.autoSwitchFillFirstOffDesc`}};function Bi({threshold:e,draft:t,strategy:n=`quota`,hydrated:r=!0,saving:i,loadError:a,feedback:o,onDraftChange:s,onEditingChange:c,onCommit:l,onCancel:u,onToggle:d,onRetry:f}){let p=K(),m=(0,_.useRef)(!1),h=e>0,g=zi[n][h?`on`:`off`],v=i||!r,y=i?p(`common.saving`):o?.message??``,b=i?`pending`:o?.tone,x=y?`codex-auto-switch-desc codex-auto-switch-feedback`:`codex-auto-switch-desc`;return(0,z.jsxs)(`div`,{className:`card card-row codex-auto-switch-card`,style:{marginTop:16},"aria-busy":i||!r&&!a||void 0,children:[(0,z.jsxs)(`div`,{className:`codex-auto-switch-copy`,children:[(0,z.jsx)(`strong`,{children:p(`codexAuth.autoSwitch`)}),(0,z.jsx)(`div`,{id:`codex-auto-switch-desc`,className:`card-sub`,role:a?`alert`:void 0,children:a?p(`codexAuth.autoSwitchLoadFailed`):p(g,{threshold:e})}),(0,z.jsx)(`div`,{className:`card-sub`,children:p(`codexAuth.failureRecoveryNote`)}),(0,z.jsx)(`div`,{className:`card-sub`,children:p(`codexAuth.cacheWarning`)})]}),(0,z.jsxs)(`div`,{className:`codex-auto-switch-controls`,onBlur:e=>{if(!e.currentTarget.contains(e.relatedTarget)){if(c(!1),m.current){m.current=!1;return}h&&!v&&l()}},children:[a&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:f,children:p(`pws.retryAccounts`)}),h&&(0,z.jsxs)(`label`,{className:`codex-auto-switch-threshold`,children:[(0,z.jsx)(`span`,{className:`field-label`,children:p(`codexAuth.autoSwitchThreshold`)}),(0,z.jsxs)(`span`,{className:`codex-auto-switch-input-wrap`,children:[(0,z.jsx)(`input`,{className:`input mono codex-auto-switch-input`,type:`number`,min:1,max:100,step:1,inputMode:`numeric`,value:t,readOnly:v,"aria-disabled":v,"aria-label":p(`codexAuth.autoSwitchThresholdAria`),"aria-describedby":x,onChange:e=>s(e.target.value),onFocus:()=>{v||c(!0)},onKeyDown:e=>{e.nativeEvent.isComposing||v||(e.key===`Enter`?(e.preventDefault(),l()):e.key===`Escape`&&(e.preventDefault(),u()))}}),(0,z.jsx)(`span`,{className:`codex-auto-switch-unit`,"aria-hidden":`true`,children:`%`}),(0,z.jsx)(Ri,{disabled:v,incrementLabel:p(`codexAuth.autoSwitchThresholdInc`),decrementLabel:p(`codexAuth.autoSwitchThresholdDec`),onIncrement:()=>{c(!0),s(Li(t,1,1,100))},onDecrement:()=>{c(!0),s(Li(t,-1,1,100))}})]})]}),(0,z.jsx)(`span`,{className:`codex-auto-switch-toggle-slot`,children:(0,z.jsx)(`button`,{type:`button`,className:`toggle ${h?`on`:``}`,onPointerDownCapture:()=>{m.current=!0},onPointerUp:()=>{m.current=!1},onPointerCancel:()=>{m.current=!1},onClick:()=>{m.current=!1,d()},disabled:v,"aria-pressed":h,"aria-label":p(`codexAuth.autoSwitch`),"aria-describedby":x,title:p(`codexAuth.autoSwitch`),children:(0,z.jsx)(`span`,{className:`toggle-knob`})})})]}),y&&(0,z.jsx)(`div`,{id:`codex-auto-switch-feedback`,className:`codex-auto-switch-feedback${b===`err`?` is-error`:``}`,role:b===`err`?`alert`:`status`,"aria-atomic":`true`,children:y})]})}var Vi=[`quota`,`round-robin`,`fill-first`],Hi=`quota`,Ui=new Set(Vi);function Wi(e){return typeof e==`string`&&Ui.has(e)?e:Hi}function Gi(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=100?e:1}function Ki(e){let t=e.trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return n>=1&&n<=100?n:null}async function qi(e,t,n=(e,t)=>fetch(e,t)){if(t.strategy===void 0&&t.stickyLimit===void 0)return{ok:!1};try{let r=await n(`${e}/api/codex-auth/pool-strategy`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t.strategy===void 0?{}:{strategy:t.strategy},...t.stickyLimit===void 0?{}:{stickyLimit:t.stickyLimit}})});if(!r.ok)return{ok:!1};let i=await r.json();return{ok:!0,strategy:Wi(i.accountPoolStrategy??t.strategy),stickyLimit:Gi(i.accountPoolStickyLimit??t.stickyLimit)}}catch{return{ok:!1}}}var Ji={quota:`accountPool.strategyQuota`,"round-robin":`accountPool.strategyRoundRobin`,"fill-first":`accountPool.strategyFillFirst`},Yi={quota:`accountPool.strategyHintQuota`,"round-robin":`accountPool.strategyHintRoundRobin`,"fill-first":`accountPool.strategyHintFillFirst`};function Xi({strategy:e,stickyDraft:t,disabled:n=!1,strategySelectId:r=`account-pool-strategy`,stickyInputId:i=`account-pool-sticky-limit`,onStrategyChange:a,onStickyDraftChange:o,onStickyCommit:s}){let c=K(),l=Vi.map(e=>({value:e,label:c(Ji[e])}));return(0,z.jsxs)(`div`,{className:`account-pool-strategy-controls`,children:[(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,id:`${r}-label`,children:c(`accountPool.strategy`)}),(0,z.jsx)(`span`,{className:`desc`,children:c(`accountPool.strategyDesc`)}),(0,z.jsx)(`span`,{className:`desc`,children:c(Yi[e])}),(0,z.jsx)(`span`,{className:`desc`,children:c(`accountPool.unboundDefinition`)})]}),(0,z.jsx)(`div`,{className:`setting-controls`,children:(0,z.jsx)(at,{id:r,value:e,options:l,disabled:n,label:c(`accountPool.strategy`),onChange:e=>a(e)})})]}),e===`round-robin`&&(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`label`,{className:`setting-label`,htmlFor:i,children:[(0,z.jsx)(`span`,{className:`title`,children:c(`accountPool.stickyLimit`)}),(0,z.jsx)(`span`,{className:`desc`,children:c(`accountPool.stickyLimitHelp`)})]}),(0,z.jsx)(`div`,{className:`setting-controls`,children:(0,z.jsxs)(`span`,{className:`codex-auto-switch-input-wrap`,children:[(0,z.jsx)(`input`,{id:i,className:`input mono codex-auto-switch-input`,type:`number`,min:1,max:100,step:1,inputMode:`numeric`,value:t,disabled:n,"aria-label":c(`accountPool.stickyLimitAria`),onChange:e=>o(e.target.value),onBlur:()=>s(),onKeyDown:e=>{e.nativeEvent.isComposing||n||e.key===`Enter`&&(e.preventDefault(),s())}}),(0,z.jsx)(Ri,{disabled:n,incrementLabel:c(`accountPool.stickyLimitInc`),decrementLabel:c(`accountPool.stickyLimitDec`),onIncrement:()=>{let e=Li(t,1,1,100);o(e),s(e)},onDecrement:()=>{let e=Li(t,-1,1,100);o(e),s(e)}})]})})]})]})}function Zi(e){if(!e||typeof e!=`object`)return null;let t=e;return!(`accountPoolStrategy`in t)&&!(`accountPoolStickyLimit`in t)?null:{strategy:Wi(t.accountPoolStrategy),stickyLimit:Gi(t.accountPoolStickyLimit)}}function Qi({apiBase:e,subscribeLoadObserver:t,readLastActive:n,onStrategyResolved:r}){let i=K(),[a,o]=(0,_.useState)(Hi),[s,c]=(0,_.useState)(1),[l,u]=(0,_.useState)(`1`),[d,f]=(0,_.useState)(!1),p=(0,_.useRef)(!1),[m,h]=(0,_.useState)(!1),g=(0,_.useRef)(!1),v=(0,_.useRef)(!1),y=(0,_.useRef)(0),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(null),w=(0,_.useCallback)(e=>{let t=Wi(e.accountPoolStrategy),n=Gi(e.accountPoolStickyLimit);o(t),r?.(t),c(n),u(String(n)),p.current=!0,f(!0),x(!1),C(null)},[r]),T=(0,_.useCallback)(e=>{let t=Zi(e);t&&w({accountPoolStrategy:t.strategy,accountPoolStickyLimit:t.stickyLimit})},[w]),E=(0,_.useCallback)(async()=>{try{let t=await fetch(`${e}/api/codex-auth/active`);if(!t.ok)throw Error(`load`);let n=await t.json();if(g.current){v.current=!0;return}w(n)}catch{g.current||x(!0)}},[e,w]),D=(0,_.useCallback)(()=>{v.current&&(v.current=!1,queueMicrotask(()=>{if(g.current){v.current=!0;return}E()}))},[E]);(0,_.useEffect)(()=>{if(!t)return;let e=t({beginActiveRead:()=>y.current,acceptActiveRead:(e,t)=>{if(t===y.current){if(g.current){v.current=!0;return}T(e)}},rejectActiveRead:()=>{p.current||x(!0)}});return!g.current&&n&&T(n()),e},[t,T,n]),(0,_.useEffect)(()=>{!n||t||g.current||T(n())},[n,T,t]),(0,_.useEffect)(()=>{t||E()},[E,t]);let O=(0,_.useCallback)(async t=>{if(g.current)return;let n=a,l=s;t.strategy!==void 0&&(o(t.strategy),r?.(t.strategy)),t.stickyLimit!==void 0&&(c(t.stickyLimit),u(String(t.stickyLimit))),g.current=!0,h(!0),C(null),y.current+=1;let d=await qi(e,t);y.current+=1,d.ok?(o(d.strategy),r?.(d.strategy),c(d.stickyLimit),u(String(d.stickyLimit)),p.current=!0,f(!0)):(C(i(`accountPool.strategyUpdateFailed`)),o(n),r?.(n),c(l),u(String(l))),g.current=!1,h(!1),D()},[e,r,D,s,a,i]),k=m||b||!d;return(0,z.jsxs)(`div`,{className:`card account-pool-strategy-card`,"aria-busy":m||!d&&!b,children:[b&&(0,z.jsx)(`div`,{className:`card-sub`,role:`alert`,children:i(`accountPool.strategyLoadFailed`)}),b&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm account-pool-strategy-card__retry`,onClick:()=>{E()},children:i(`common.retry`)}),!b&&(0,z.jsx)(Xi,{strategy:a,stickyDraft:l,disabled:k,strategySelectId:`codex-pool-strategy`,stickyInputId:`codex-pool-sticky-limit`,onStrategyChange:e=>{k||e===a||O({strategy:e})},onStickyDraftChange:u,onStickyCommit:e=>{if(k)return;let t=Ki(e??l);if(t===null){u(String(s)),C(i(`accountPool.stickyLimitInvalid`));return}if(t===s){u(String(t));return}O({stickyLimit:t})}}),S&&(0,z.jsx)(`div`,{role:`alert`,className:`card-sub account-pool-strategy-card__error`,children:S})]})}function $i(e,t){let[n,r]=(0,_.useState)(80),[i,a]=(0,_.useState)(`80`),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(null),m=(0,_.useRef)(80),h=(0,_.useRef)(!1),g=(0,_.useRef)(80),v=(0,_.useRef)(!1),y=(0,_.useRef)(!1),b=(0,_.useRef)(!1),x=(0,_.useRef)(0),S=(0,_.useRef)(null),C=(0,_.useRef)(null),w=(0,_.useCallback)(e=>{m.current=e,h.current=!0,s(!0),r(e),e>0&&(g.current=e),a(String(e>0?e:g.current))},[]),T=(0,_.useCallback)(e=>{if(v.current||y.current){S.current=e;return}S.current=null,w(e)},[w]),E=(0,_.useCallback)(()=>{let e=S.current;return e===null?!1:(S.current=null,w(e),!0)},[w]),D=(0,_.useCallback)(()=>{C.current!==null&&(window.clearTimeout(C.current),C.current=null),p(null)},[]),O=(0,_.useCallback)((e,t)=>{C.current!==null&&window.clearTimeout(C.current),p({tone:t?`err`:`ok`,message:e}),C.current=window.setTimeout(()=>{p(null),C.current=null},5e3)},[]);(0,_.useEffect)(()=>()=>{C.current!==null&&window.clearTimeout(C.current)},[]);let k=(0,_.useCallback)(()=>(h.current||l(!1),x.current),[]),A=(0,_.useCallback)((e,t)=>{l(!1);let n=ji(e),r=Ai(v.current,y.current,t,x.current);r===`defer`?S.current=Di(n):r===`apply`&&T(Di(n))},[T]),j=(0,_.useCallback)(e=>{h.current||v.current||y.current||(l(!1),w(Di(ji(e))))},[w]),M=(0,_.useCallback)(()=>{h.current||l(!0)},[]),N=(0,_.useCallback)(async(n,r,i=!0)=>{if(y.current)return!1;y.current=!0,v.current=!1,D(),d(!0),x.current+=1;try{let a=await Ni(e,n);return x.current+=1,a?(S.current=null,w(n),i&&O(t.updated,!1)):(E()||w(r),O(t.updateFailed,!0)),a}finally{y.current=!1,d(!1)}},[e,w,D,t.updateFailed,t.updated,E,O]),P=(0,_.useCallback)(()=>{v.current=!1;let e=m.current;E()||a(String(e>0?e:g.current)),O(t.invalid,!0)},[t.invalid,E,O]),F=(0,_.useCallback)(()=>{v.current=!1,b.current=!0,D();let e=m.current;E()||a(String(e>0?e:g.current))},[D,E]),I=(0,_.useCallback)(async()=>{if(b.current)return b.current=!1,!0;if(!h.current||y.current)return!1;let e=m.current;v.current=!1;let t=Oi(i);return t===null?(P(),!1):t===e?(E()||a(String(t)),!0):N(t,e)},[i,E,P,N]),L=(0,_.useCallback)(async()=>{if(!h.current||y.current)return!1;let e=m.current;v.current=!1;let t=Mi(e,i,g.current),n=await N(t.threshold,e);return n?(g.current=t.lastEnabled,t.threshold===0&&a(String(t.lastEnabled)),n):!1},[i,N]);return{threshold:n,draft:i,hydrated:o,saving:u,loadError:c,feedback:f,beginServerRead:k,acceptServerRead:A,hydrateServerValue:j,rejectServerRead:M,setDraft:(0,_.useCallback)(e=>{h.current&&(v.current=!0,b.current=!1,D(),a(e))},[D]),setEditing:(0,_.useCallback)(e=>{v.current=e},[]),commit:I,cancel:F,toggle:L,retry:(0,_.useCallback)(()=>{l(!1),D()},[D])}}var ea=new Map;function ta(e,t){return`${e??``}\0${JSON.stringify(t)}`}function na(e,t){let n=ta(e,t??{}),r=ea.get(n);return r||(r=new Intl.NumberFormat(e,t),ea.set(n,r)),r}var ra={month:`short`,day:`numeric`,year:`numeric`},ia={month:`short`,day:`numeric`,year:`numeric`,hour:`2-digit`,minute:`2-digit`},aa=new Map;function oa(e,t){let n=ta(e,t),r=aa.get(n);return r||(r=new Intl.DateTimeFormat(e,t),aa.set(n,r)),r}function sa(e,t){let n=new Date(e);return Number.isNaN(n.getTime())?`—`:oa(t,ra).format(n)}function ca(e,t){let n=new Date(e);return Number.isNaN(n.getTime())?`—`:oa(t,ia).format(n)}function la(e,t){return!Number.isFinite(e)||e<0?`—`:`~${na(t,{style:`currency`,currency:`USD`,minimumFractionDigits:4,maximumFractionDigits:4}).format(e)}`}function ua(e,t){return sa(e,t)}function da(e,t){return ca(e,t)}function fa(e){return Math.max(0,Math.ceil((new Date(e).getTime()-Date.now())/864e5))}function pa({index:e,grantedAt:t,expiresAt:n,isNext:r,locale:i,t:a}){let o=fa(n),s=o<=7;return(0,z.jsxs)(`div`,{className:`credit-item${r?` credit-next`:``}`,children:[(0,z.jsxs)(`div`,{className:`credit-item-head`,children:[(0,z.jsx)(Ce,{width:13}),(0,z.jsx)(`span`,{className:`credit-item-label`,children:r?a(`codexAuth.creditNext`):a(`codexAuth.creditLabel`,{n:String(e+1)})}),r&&(0,z.jsx)(`span`,{className:`badge badge-amber text-micro`,style:{padding:`1px 6px`},children:a(`codexAuth.creditNextBadge`)})]}),(0,z.jsxs)(`div`,{className:`credit-item-dates`,children:[(0,z.jsx)(`span`,{children:a(`codexAuth.creditGranted`,{date:ua(t,i)})}),(0,z.jsx)(`span`,{className:s?`credit-urgent`:``,children:a(`codexAuth.creditExpires`,{date:da(n,i),days:String(o)})})]})]})}function ma({account:e,onClick:t,t:n}){let r=e.quota?.resetCredits;return e.quota==null?(0,z.jsxs)(`span`,{className:`badge badge-muted codex-ticket-badge-slot`,"aria-hidden":`true`,children:[(0,z.jsx)(Ce,{width:12}),`0`]}):r===void 0?null:(0,z.jsxs)(`button`,{type:`button`,className:`badge ${typeof r==`number`&&r>0?`badge-amber`:`badge-muted`} badge-clickable`,onClick:e=>{e.stopPropagation(),t()},"aria-label":n(`codexAuth.resetCreditsAria`,{count:String(r)}),children:[(0,z.jsx)(Ce,{width:12}),r]})}function ha({t:e,paused:t,saving:n}){let r=e(`codexAuth.pause`),i=e(`codexAuth.resume`),a=e(`common.saving`),o=n?a:t?i:r;return(0,z.jsx)(`span`,{className:`codex-auth-pause-label`,style:{minWidth:`${Math.max(r.length,i.length,a.length)}ch`},children:o})}function ga({pool:e,activeId:t,accountModeState:n,switchActionLabel:r,threshold:i,onOpenReset:a,onSwitch:o,onTogglePause:s,pauseUpdatingId:c,pauseBusy:l,onReauth:u,onEditAlias:d,onRemove:f,onCopyDoctor:p,doctorCopyOutcomeFor:m}){let h=K(),g=e=>!e.paused&&t===e.id;return(0,z.jsx)(z.Fragment,{children:e.map(e=>{let t=e.health?.status,_=!!e.needsReauth||si(t),v=li(t),y=fi(h,e.health),b=pi(h,`codex`,e.id,e.health);return(0,z.jsxs)(`div`,{className:`card ${g(e)?`card-active`:``}`,style:{marginBottom:8},children:[(0,z.jsxs)(`div`,{className:`card-head`,children:[(0,z.jsx)(`span`,{className:`dot ${_?`dot-amber`:g(e)?`dot-blue`:`dot-muted`}`}),(0,z.jsx)(`strong`,{children:e.alias??e.email}),(0,z.jsxs)(`span`,{className:`card-badges`,children:[e.plan&&(0,z.jsx)(`span`,{className:`badge badge-green`,children:e.plan}),e.paused&&(0,z.jsx)(`span`,{className:`badge badge-muted`,title:h(`codexAuth.pausedHint`),children:h(`codexAuth.paused`)}),(0,z.jsx)(ma,{t:h,account:e,onClick:()=>a(e)}),y&&(0,z.jsx)(`span`,{className:oi(t),children:y}),_&&!y&&(0,z.jsx)(`span`,{className:`badge badge-amber`,children:h(`codexAuth.needsReauth`)}),g(e)&&!_&&!v&&(0,z.jsx)(`span`,{className:`badge badge-primary`,children:h(n===`direct`?`codexAuth.poolPrepared`:`codexAuth.nextSession`)})]}),!e.paused&&!g(e)&&!_&&!v&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm codex-account-switch`,onClick:()=>o(e),children:r}),_&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>u(e.id),children:h(`codexAuth.reauthenticate`)}),p&&ui(t)&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm codex-auth-action-btn`,onClick:()=>p(e.id),children:(0,z.jsx)(`span`,{"aria-live":`polite`,children:gi(h,m?.(e.id))})}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-ghost codex-auth-action-btn`,onClick:()=>s(e),disabled:l,title:e.paused?h(`codexAuth.pausedHint`):void 0,"aria-label":e.paused?`${h(`codexAuth.resume`)}. ${h(`codexAuth.pausedHint`)}`:h(`codexAuth.pause`),children:[e.paused?(0,z.jsx)(le,{width:14}):(0,z.jsx)(ce,{width:14}),(0,z.jsx)(ha,{t:h,paused:e.paused,saving:c===e.id})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void d(e),children:h(`prov.editAlias`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn-icon btn-icon-danger card-right`,"aria-label":`${h(`common.remove`)} — ${e.email}`,title:`${h(`common.remove`)} — ${e.email}`,onClick:t=>{t.stopPropagation(),f(e.id)},children:(0,z.jsx)(ae,{width:14})})]}),(0,z.jsxs)(`div`,{className:`card-sub`,children:[e.email,e.plan?` · ${e.plan}`:``,` · `,h(`prov.accountId`),`: `,ii(e.id)]}),b&&(0,z.jsx)(`div`,{className:`card-sub faint`,children:b}),v&&(0,z.jsx)(`div`,{className:`card-sub faint`,children:h(`pws.healthCooldownHint`)}),_?(0,z.jsx)(`div`,{className:`card-sub faint`,children:h(`codexAuth.tokenExpired`)}):!v&&(0,z.jsx)(Br,{quota:e.quota,plan:e.plan,threshold:i,t:h,pending:e.quota==null})]},e.id)})})}function _a({onReauth:e}){let t=K();return(0,z.jsxs)(`div`,{className:`notice-warn`,style:{marginBottom:12,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:12,flexWrap:`wrap`},children:[(0,z.jsxs)(`span`,{children:[(0,z.jsx)(de,{width:14}),` `,t(`codexAuth.tokenExpired`)]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:e,children:t(`codexAuth.reauthenticate`)})]})}function va({confirm:e,mainEmail:t,accountModeState:n,switchingId:r,onCancel:i,onConfirm:a}){let o=K(),s=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let e=s.current;e&&!e.open&&e.showModal()},[]),(0,z.jsxs)(`dialog`,{ref:s,className:`modal-overlay`,"aria-labelledby":`codex-switch-title`,onCancel:(0,_.useCallback)(e=>{e.preventDefault(),i()},[i]),children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":o(`common.close`),tabIndex:-1,onClick:i}),(0,z.jsxs)(`div`,{className:`modal-card`,onClick:e=>e.stopPropagation(),role:`document`,children:[(0,z.jsx)(`h3`,{id:`codex-switch-title`,children:n===`direct`?o(`codexAuth.preparePoolTitle`):e.id===`__main__`?o(`codexAuth.switchBack`):o(`codexAuth.switchTitle`)}),(0,z.jsx)(`p`,{className:`modal-desc`,children:n===`direct`?o(`codexAuth.preparePoolDesc`):e.id===`__main__`?o(`codexAuth.switchBackDesc`):o(`codexAuth.switchDesc`)}),(0,z.jsxs)(`div`,{className:`card`,style:{margin:`12px 0`},children:[(0,z.jsx)(`strong`,{children:e.id===`__main__`?t||o(`codexAuth.codexApp`):e.email}),e.plan&&(0,z.jsx)(`span`,{className:`badge badge-green`,style:{marginLeft:8},children:e.plan})]}),e.id!==`__main__`&&(0,z.jsxs)(`div`,{className:`notice-warn`,children:[(0,z.jsx)(de,{width:14}),` `,o(`codexAuth.cacheWarning`)]}),(0,z.jsxs)(`div`,{className:`modal-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:i,children:o(`codexAuth.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:!!r,onClick:a,children:o(r?`pws.accountSwitching`:n===`direct`?`codexAuth.prepareForPool`:`codexAuth.setAsNext`)})]})]})]})}function ya({resetPopup:e,resetConfirm:t,creditDetails:n,creditDetailsLoading:r,redeeming:i,onClose:a,onShowConfirm:o,onCancelConfirm:s,onRedeem:c}){let{locale:l,t:u}=Ve(),d=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let e=d.current;e&&!e.open&&e.showModal()},[]),(0,z.jsxs)(`dialog`,{ref:d,className:`modal-overlay`,"aria-labelledby":`codex-reset-title`,onCancel:(0,_.useCallback)(e=>{e.preventDefault(),a()},[a]),children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":u(`common.close`),tabIndex:-1,onClick:a}),(0,z.jsx)(`div`,{className:`modal-card`,onClick:e=>e.stopPropagation(),role:`document`,children:t?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{style:{textAlign:`center`,padding:`12px 0`},children:[(0,z.jsx)(`div`,{className:`confirm-icon`,children:(0,z.jsx)(de,{width:22})}),(0,z.jsx)(`h3`,{id:`codex-reset-title`,children:u(`codexAuth.confirmResetTitle`)}),(0,z.jsx)(`p`,{className:`modal-desc`,children:u(`codexAuth.confirmResetDesc`,{count:String(e.quota?.resetCredits??0)})}),n&&n[0]&&(0,z.jsx)(`p`,{className:`faint text-label`,children:u(`codexAuth.confirmWhichCredit`,{date:ua(n[0].granted_at,l)})}),(0,z.jsx)(`p`,{className:`faint text-label`,children:u(`codexAuth.irreversible`)})]}),(0,z.jsxs)(`div`,{className:`modal-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:s,children:u(`codexAuth.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:c,disabled:i,children:u(i?`codexAuth.redeeming`:`codexAuth.useCredit`)})]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`h3`,{id:`codex-reset-title`,children:[(0,z.jsx)(Ce,{width:16}),` `,u(`codexAuth.resetCreditsTitle`)]}),(0,z.jsxs)(`div`,{className:`card-sub`,children:[e.email,e.plan?` · ${e.plan}`:``]}),(0,z.jsx)(`div`,{style:{margin:`16px 0`},children:(e.quota?.resetCredits??0)>0?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{style:{marginBottom:12},children:u(`codexAuth.resetCreditsAvailable`,{count:String(e.quota?.resetCredits??0)})}),r&&(0,z.jsx)(`p`,{className:`faint text-label`,children:u(`common.loading`)}),n&&n.length>0&&(0,z.jsx)(`div`,{className:`credit-list`,children:n.map((e,t)=>(0,z.jsx)(pa,{index:t,grantedAt:e.granted_at,expiresAt:e.expires_at,isNext:t===0,locale:l,t:u},`${e.granted_at}:${e.expires_at}`))}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,style:{marginTop:12,width:`100%`},onClick:o,disabled:i,children:u(`codexAuth.useOneCredit`)}),(0,z.jsx)(`p`,{className:`card-sub text-caption`,style:{marginTop:8,textAlign:`center`},children:u(`codexAuth.fifoNote`)})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`faint`,children:u(`codexAuth.noResetCredits`)}),(0,z.jsx)(`p`,{className:`modal-desc`,children:u(`codexAuth.earnCreditsHint`)})]})})]})})]})}function ba({t:e,main:t,isMainActive:n,accountModeState:r,threshold:i,switchActionLabel:a,onSwitch:o,onTogglePause:s,pauseUpdatingId:c,pauseBusy:l,onOpenReset:u,onCopyDoctor:d,doctorCopyOutcomeFor:f}){let p=e(`codexAuth.codexApp`),m=t?.id??`__main__`,h={id:`__main__`,email:t?.email||p,plan:t?.plan,isMain:!0,paused:t?.paused??!1,hasCredential:!0,quota:t?.quota??null},g=!!t?.needsReauth||si(t?.health?.status),_=li(t?.health?.status),v=fi(e,t?.health),y=t?pi(e,`codex`,m,t.health):null;return(0,z.jsxs)(`div`,{className:`card ${n?`card-active`:``}`,style:{marginBottom:12},children:[(0,z.jsxs)(`div`,{className:`card-head`,children:[(0,z.jsx)(`span`,{className:`dot ${g?`dot-amber`:`dot-green`}`}),(0,z.jsx)(`strong`,{children:e(`codexAuth.mainAccount`)}),(0,z.jsxs)(`span`,{className:`card-badges`,children:[t&&(0,z.jsx)(ma,{t:e,account:{...t,id:`__main__`},onClick:()=>u({...t,id:`__main__`})}),t?.paused&&(0,z.jsx)(`span`,{className:`badge badge-muted`,title:e(`codexAuth.pausedHint`),children:e(`codexAuth.paused`)}),v&&(0,z.jsx)(`span`,{className:oi(t?.health?.status),children:v}),g&&!v&&(0,z.jsx)(`span`,{className:`badge badge-amber`,children:e(`codexAuth.needsReauth`)}),!t?.paused&&(0,z.jsx)(`span`,{className:`badge ${n?`badge-primary`:`badge-muted`}`,children:e(n?r===`direct`?`codexAuth.poolPrepared`:`codexAuth.nextSession`:`codexAuth.current`)})]}),!t?.paused&&!n&&!g&&!_&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm codex-account-switch`,onClick:()=>o(h),children:a}),d&&ui(t?.health?.status)&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm codex-auth-action-btn`,onClick:()=>d(m),children:(0,z.jsx)(`span`,{"aria-live":`polite`,children:gi(e,f?.(m))})}),t&&(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-ghost codex-auth-action-btn`,onClick:()=>s(h),disabled:l,title:t.paused?e(`codexAuth.pausedHint`):void 0,"aria-label":t.paused?`${e(`codexAuth.resume`)}. ${e(`codexAuth.pausedHint`)}`:e(`codexAuth.pause`),children:[t.paused?(0,z.jsx)(le,{width:14}):(0,z.jsx)(ce,{width:14}),(0,z.jsx)(ha,{t:e,paused:!!t.paused,saving:c===`__main__`})]}),(0,z.jsxs)(`span`,{className:`card-right`,children:[(0,z.jsx)(Se,{width:14}),` `,e(`codexAuth.appLogin`)]})]}),(0,z.jsxs)(`div`,{className:`card-sub`,children:[t?.email||e(`codexAuth.appLogin`),t?.plan?` · ${t.plan}`:``]}),y&&(0,z.jsx)(`div`,{className:`card-sub faint`,children:y}),_&&(0,z.jsx)(`div`,{className:`card-sub faint`,children:e(`pws.healthCooldownHint`)}),g?(0,z.jsx)(`div`,{className:`card-sub faint`,children:e(`codexAuth.mainTokenExpired`)}):!_&&(0,z.jsx)(Br,{quota:t?.quota??null,plan:t?.plan,threshold:i,t:e,pending:t!=null&&t.quota==null})]})}function xa({t:e,embedded:t,refreshingQuota:n,pausingExhausted:r,pauseBusy:i,actionFeedback:a,actionFeedbackTone:o,onRefresh:s,onPauseExhausted:c}){return(0,z.jsxs)(`div`,{className:t?`row`:`page-head codex-auth-page-head`,style:t?{justifyContent:`flex-end`,marginBottom:8}:void 0,children:[!t&&(0,z.jsx)(`h2`,{className:`page-title`,children:e(`nav.codexAuth`)}),(0,z.jsxs)(`div`,{className:t?`row`:`codex-auth-page-head__actions`,children:[(0,z.jsx)(`span`,{className:`codex-auth-page-head__feedback${o===`ok`?` is-ok`:``}${o===`err`?` is-err`:``}`,role:`status`,"aria-live":`polite`,children:a??``}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-ghost codex-auth-action-btn`,onClick:c,disabled:n||r||!!i,children:[(0,z.jsx)(ce,{width:14}),` `,e(r?`codexAuth.pausingExhausted`:`codexAuth.pauseExhausted`)]}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-ghost codex-auth-action-btn`,onClick:s,disabled:n||r||!!i,children:[(0,z.jsx)(se,{width:14}),` `,e(n?`codexAuth.refreshingQuota`:`codexAuth.refreshQuota`)]})]})]})}function Sa({t:e,loadState:t,accountsCount:n,onRetry:r}){return t===`loading`&&n===0?(0,z.jsxs)(`div`,{className:`codex-auth-load-skeleton`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[(0,z.jsxs)(`div`,{className:`card codex-auth-load-skeleton__main`,style:{marginBottom:12},"aria-hidden":`true`,children:[(0,z.jsxs)(`div`,{className:`card-head`,children:[(0,z.jsx)(`span`,{className:`dot dot-muted`}),(0,z.jsx)(`strong`,{children:e(`codexAuth.mainAccount`)}),(0,z.jsxs)(`span`,{className:`card-badges`,children:[(0,z.jsxs)(`span`,{className:`badge badge-muted codex-ticket-badge-slot`,"aria-hidden":`true`,children:[(0,z.jsx)(Ce,{width:12}),`0`]}),(0,z.jsx)(`span`,{className:`badge badge-primary`,children:e(`codexAuth.nextSession`)})]}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,tabIndex:-1,disabled:!0,children:[(0,z.jsx)(ce,{width:14}),` `,e(`codexAuth.pause`)]}),(0,z.jsxs)(`span`,{className:`card-right`,children:[(0,z.jsx)(Se,{width:14}),` `,e(`codexAuth.appLogin`)]})]}),(0,z.jsxs)(`div`,{className:`card-sub`,children:[(0,z.jsx)(`span`,{className:`codex-auth-load-skeleton__strut`,children:e(`codexAuth.appLogin`)}),(0,z.jsx)(`span`,{className:`codex-auth-load-skeleton__line codex-auth-load-skeleton__line--sub`})]}),(0,z.jsx)(Br,{quota:null,threshold:0,t:e,pending:!0})]}),(0,z.jsxs)(`div`,{className:`section-sep`,"aria-hidden":`true`,children:[(0,z.jsx)(`span`,{className:`section-label`,children:e(`codexAuth.accountPool`)}),(0,z.jsx)(`div`,{className:`sep-line`}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,tabIndex:-1,disabled:!0,children:[(0,z.jsx)(oe,{width:14}),` `,e(`codexAuth.add`)]})]}),(0,z.jsx)(`div`,{className:`empty codex-auth-pool-empty codex-auth-load-skeleton__empty`,"aria-hidden":`true`,children:(0,z.jsx)(`div`,{className:`title`,children:e(`codexAuth.noPool`)})}),(0,z.jsx)(`span`,{className:`sr-only`,children:e(`pws.accountsLoading`)})]}):t===`error`?(0,z.jsxs)(`div`,{className:`pwi-auth-state pwi-auth-state--error`,role:`alert`,children:[(0,z.jsx)(`span`,{children:e(`codexAuth.loadFailed`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:r,children:e(`pws.retryAccounts`)})]}):null}function Ca(e,t){return t===void 0?e(`codexAuth.resetSuccessGeneric`):e(`codexAuth.resetSuccess`,{remaining:String(t)})}async function wa(e,t,n,r){try{let i=await ut(await fetch(`${e}/api/codex-auth/reset-credits/consume`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({accountId:t})}));return i?i.code===`reset`||i.code===`already_redeemed`?(await r(!0),{ok:!0,close:!0,toast:Ca(n,typeof i.remaining==`number`&&Number.isFinite(i.remaining)?Math.max(0,i.remaining):void 0)}):{ok:!1,close:!0,toast:n(i.code===`nothing_to_reset`?`codexAuth.resetNothingToReset`:i.code===`no_credit`?`codexAuth.resetNoCredit`:`codexAuth.resetError`)}:{ok:!1,toast:n(`codexAuth.resetError`)}}catch{return{ok:!1,toast:n(`codexAuth.resetError`)}}}var Ta=`ocx doctor`;function Ea({apiBase:e,accountModeState:t=null,banner:n=null,embedded:r=!1,onActiveNeedsReauthChange:i,controller:a}){let o=K(),s=$i(e,{updated:o(`codexAuth.autoSwitchUpdated`),updateFailed:o(`codexAuth.autoSwitchUpdateFailed`),invalid:o(`codexAuth.autoSwitchThresholdInvalid`)}),[c,l]=(0,_.useState)(null),{beginServerRead:u,acceptServerRead:d,rejectServerRead:f,hydrateServerValue:p}=s,m=Ii(e,!a),h=a??m,{accounts:g,activeId:v,loadState:y,switchingId:b,pauseUpdatingId:x,pausingExhausted:S,load:C}=h,[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(null),[A,j]=(0,_.useState)(null),[M,N]=(0,_.useState)(null),P=(0,_.useRef)(null),[F,I]=(0,_.useState)(!1),[L,R]=(0,_.useState)(null),[B,V]=(0,_.useState)(!1),[H,U]=(0,_.useState)(!1),[W,ee]=(0,_.useState)(null),[te,ne]=(0,_.useState)(!1),re=xi(),G=(0,_.useCallback)((e,t=!1)=>{P.current&&clearTimeout(P.current),j(e),N(t?`err`:`ok`),P.current=setTimeout(()=>{j(null),N(null),P.current=null},5e3)},[]);(0,_.useEffect)(()=>()=>{P.current&&clearTimeout(P.current)},[]);let ie=(0,_.useCallback)(e=>{re.copy(Ta,e)},[re]),{subscribeLoadObserver:ae,readLastThreshold:se}=h;(0,_.useEffect)(()=>ae({beginActiveRead:u,acceptActiveRead:d,rejectActiveRead:f}),[ae,u,d,f]),(0,_.useEffect)(()=>{let e=se();e!==void 0&&p(e)},[se,p]),(0,_.useEffect)(()=>{if(!E)return;let e=h.pauseRefresh();return()=>h.resumeRefresh(e)},[h,E]);let ce=v&&v!==`__main__`?g.find(e=>e.id===v):null,le=!ce?.paused&&ci(ce);(0,_.useEffect)(()=>{i?.(le)},[le,i]);let ue=(0,_.useCallback)(e=>{k(e),D(!0)},[]),de=(0,_.useCallback)(()=>{D(!1),k(null)},[]),fe=(0,_.useCallback)(()=>{h.syncAfterAccountAdded(),G(o(`codexAuth.accountAdded`)),de()},[de,h,G,o]),pe=async e=>{let n=await h.switchAccount(e);if(!n.ok){if(n.reason===`busy`)return;G(o(`codexAuth.switchFailed`),!0);return}T(null);let r=n.activeId,i=r&&r!==`__main__`?g.find(e=>e.id===r)?.email??o(`pws.accountOrdinal`,{count:`1`}):o(`codexAuth.mainAccount`);G(o(t===`direct`?`codexAuth.poolPreparedToast`:`codexAuth.switched`,{email:i}))},me=async e=>{let t=window.prompt(o(`prov.aliasPrompt`),e.alias??``);if(t===null)return;let n=await h.saveAlias(e.id,t);G(o(n.ok?`prov.aliasSaved`:`prov.aliasSaveFailed`),!n.ok)},he=async e=>{let t=!e.paused,n=await h.setAccountPaused(e.id,t);!n.ok&&n.reason===`busy`||(T(t=>t?.id===e.id?null:t),G(o(n.ok?t?`codexAuth.pauseSucceeded`:`codexAuth.resumeSucceeded`:t?`codexAuth.pauseFailed`:`codexAuth.resumeFailed`,{email:e.alias??e.email}),!n.ok))},ge=async e=>{let t=g.find(t=>t.id===e)?.email??o(`pws.accountOrdinal`,{count:`1`});window.confirm(o(`codexAuth.removeConfirm`,{id:t}))&&((await h.removeAccount(e)).ok||G(o(`codexAuth.removeFailed`),!0))},_e=async()=>{I(!0);try{let e=await C(!0);G(o(e?`codexAuth.quotaRefreshed`:`codexAuth.quotaRefreshFailed`),!e)}finally{I(!1)}},ve=async()=>{let e=await h.pauseExhaustedAccounts();!e.ok&&e.reason===`busy`||G(e.ok?e.pausedCount>0?o(`codexAuth.pauseExhaustedSucceeded`,{count:String(e.pausedCount)}):o(`codexAuth.pauseExhaustedNone`):o(`codexAuth.pauseExhaustedFailed`),!e.ok)},ye=async t=>{R(t),V(!1),ee(null),ne(!0);try{let n=await ut(await fetch(`${e}/api/codex-auth/reset-credits?accountId=${encodeURIComponent(t.id)}`));n&&ee((n.credits??[]).sort((e,t)=>new Date(e.granted_at).getTime()-new Date(t.granted_at).getTime()))}catch{}finally{ne(!1)}},be=async t=>{U(!0);try{let n=await wa(e,t,o,C);n.close&&(R(null),V(!1)),n.toast&&G(n.toast,!n.ok)}finally{U(!1)}},xe=g.find(e=>e.isMain),Se=g.filter(e=>!e.isMain),Ce=!xe?.paused&&(!v||v===`__main__`),we=o(t===`direct`?`codexAuth.prepareForPool`:`codexAuth.setAsNext`),Te=x!==null||S,Ee=s.threshold??0;return(0,z.jsxs)(`div`,{children:[(0,z.jsx)(xa,{t:o,embedded:r,refreshingQuota:F,actionFeedback:A,actionFeedbackTone:M,pausingExhausted:S,pauseBusy:Te,onRefresh:()=>{_e()},onPauseExhausted:()=>{ve()}}),n,(0,z.jsx)(Sa,{t:o,loadState:y,accountsCount:g.length,onRetry:()=>{C()}}),!(y===`loading`&&g.length===0)&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ba,{t:o,main:xe,isMainActive:Ce,accountModeState:t,threshold:Ee,switchActionLabel:we,onSwitch:T,onTogglePause:he,pauseUpdatingId:x,pauseBusy:Te,onOpenReset:ye,onCopyDoctor:ie,doctorCopyOutcomeFor:re.outcomeFor}),(0,z.jsxs)(`div`,{className:`section-sep`,children:[(0,z.jsx)(`span`,{className:`section-label`,children:o(`codexAuth.accountPool`)}),(0,z.jsx)(`div`,{className:`sep-line`}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,onClick:()=>D(!0),children:[(0,z.jsx)(oe,{width:14}),` `,o(`codexAuth.add`)]})]}),le&&ce&&(0,z.jsx)(_a,{onReauth:()=>ue(ce.id)}),Se.length===0&&(0,z.jsx)(ot,{title:o(`codexAuth.noPool`)}),(0,z.jsx)(ga,{pool:Se,activeId:v,accountModeState:t,switchActionLabel:we,threshold:Ee,onOpenReset:ye,onSwitch:T,onTogglePause:he,pauseUpdatingId:x,pauseBusy:Te,onReauth:ue,onEditAlias:me,onRemove:ge,onCopyDoctor:ie,doctorCopyOutcomeFor:re.outcomeFor})]}),c!==null&&(0,z.jsx)(Bi,{threshold:s.threshold,draft:s.draft,strategy:c,hydrated:s.hydrated,saving:s.saving,loadError:s.loadError,feedback:s.feedback,onDraftChange:s.setDraft,onEditingChange:s.setEditing,onCommit:s.commit,onCancel:s.cancel,onToggle:s.toggle,onRetry:()=>{s.retry(),C()}}),(0,z.jsx)(Qi,{apiBase:e,subscribeLoadObserver:h.subscribeLoadObserver,readLastActive:h.readLastActive,onStrategyResolved:l}),w&&(0,z.jsx)(va,{confirm:w,mainEmail:xe?.email,accountModeState:t,switchingId:b,onCancel:()=>T(null),onConfirm:()=>{pe(w.id===`__main__`?`__main__`:w.id)}}),L&&(0,z.jsx)(ya,{resetPopup:L,resetConfirm:B,creditDetails:W,creditDetailsLoading:te,redeeming:H,onClose:()=>{R(null),V(!1),ee(null)},onShowConfirm:()=>V(!0),onCancelConfirm:()=>V(!1),onRedeem:()=>{be(L.id)}}),E&&(0,z.jsx)(Ti,{apiBase:e,reauthAccountId:O??void 0,onClose:de,onAdded:fe})]})}function Da({apiBase:e,accountCount:t}){let n=K(),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(`80`),[s,c]=(0,_.useState)(`1`),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let t=!1,n=new AbortController;return Promise.resolve().then(()=>fetch(`${e}/api/oauth/accounts/pool?provider=anthropic`,{signal:n.signal})).then(e=>{if(!e.ok)throw Error(`load`);return e.json()}).then(e=>{if(t)return;let n=typeof e.autoSwitchThreshold==`number`?e.autoSwitchThreshold:80,r=Gi(e.stickyLimit);i({enabled:e.enabled===!0,threshold:n,strategy:Wi(e.strategy),stickyLimit:r}),o(String(n)),c(String(r)),m(!1)}).catch(()=>{t||n.signal.aborted||m(!0)}),()=>{t=!0,n.abort()}},[e]);let h=(0,_.useCallback)(async t=>{let a=r;i({enabled:t.enabled,threshold:t.threshold,strategy:t.strategy,stickyLimit:t.stickyLimit}),u(!0),f(null);try{let n=await fetch(`${e}/api/oauth/accounts/pool`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({provider:`anthropic`,enabled:t.enabled,autoSwitchThreshold:t.threshold,strategy:t.strategy,stickyLimit:t.stickyLimit})});if(!n.ok)throw Error(`save`);let r=await n.json().catch(()=>null),a=Wi(r?.strategy??t.strategy),s=Gi(r?.stickyLimit??t.stickyLimit);i({enabled:t.enabled,threshold:t.threshold,strategy:a,stickyLimit:s}),o(String(t.threshold)),c(String(s))}catch{f(n(`anthropicPool.saveFailed`)),a&&(i(a),o(String(a.threshold)),c(String(a.stickyLimit)))}finally{u(!1)}},[e,r,n]),g=r?.enabled===!0,v=r?.threshold??80,y=r?.strategy??`quota`,b=r?.stickyLimit??1,x=r===null&&!p,S=x||l||p||!g&&t<2;return(0,z.jsxs)(`div`,{className:`card`,style:{marginTop:12},"aria-busy":x||l,children:[(0,z.jsxs)(`div`,{className:`card-row`,style:{alignItems:`flex-start`,gap:12},children:[(0,z.jsxs)(`div`,{style:{flex:1},children:[(0,z.jsx)(`strong`,{children:n(`anthropicPool.title`)}),(0,z.jsx)(`div`,{className:`card-sub`,style:{marginTop:4},children:p?n(`anthropicPool.loadFailed`):x?n(`common.loading`):g?n(`anthropicPool.enabledDesc`,{threshold:v}):n(`anthropicPool.disabledDesc`)})]}),(0,z.jsxs)(`label`,{className:`toggle`,style:{display:`inline-flex`,alignItems:`center`,gap:8},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:g,disabled:S,onChange:e=>{let t=e.target.checked;h({enabled:t,threshold:v,strategy:y,stickyLimit:b})}}),(0,z.jsx)(`span`,{children:n(g?`anthropicPool.on`:`anthropicPool.off`)})]})]}),(0,z.jsx)(`div`,{role:`alert`,className:`card-sub`,style:{marginTop:10,padding:`8px 10px`,border:`1px solid var(--border, #c9a227)`,borderRadius:6,background:`color-mix(in srgb, var(--warn, #c9a227) 12%, transparent)`},children:n(`anthropicPool.experimentalWarning`)}),t<2&&(0,z.jsx)(`div`,{className:`card-sub`,style:{marginTop:8},children:n(`anthropicPool.needTwoAccounts`)}),g&&r&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`label`,{className:`field`,style:{display:`block`,marginTop:12},children:[(0,z.jsx)(`span`,{className:`field-label`,children:n(`anthropicPool.threshold`)}),(0,z.jsx)(`input`,{className:`input mono`,type:`number`,min:0,max:100,step:1,value:a,disabled:l,"aria-label":n(`anthropicPool.thresholdAria`),onChange:e=>o(e.target.value),onBlur:()=>{let e=Number(a);if(!Number.isInteger(e)||e<0||e>100){o(String(v)),f(n(`anthropicPool.thresholdInvalid`));return}e!==v&&h({enabled:!0,threshold:e,strategy:y,stickyLimit:b})}}),(0,z.jsx)(`div`,{className:`card-sub`,style:{marginTop:4},children:n(`anthropicPool.thresholdHelp`)})]}),(0,z.jsx)(Xi,{strategy:y,stickyDraft:s,disabled:l,strategySelectId:`anthropic-pool-strategy`,stickyInputId:`anthropic-pool-sticky-limit`,onStrategyChange:e=>{e!==y&&h({enabled:!0,threshold:v,strategy:e,stickyLimit:b})},onStickyDraftChange:c,onStickyCommit:e=>{let t=Ki(e??s);if(t===null){c(String(b)),f(n(`accountPool.stickyLimitInvalid`));return}if(t===b){c(String(t));return}h({enabled:!0,threshold:v,strategy:y,stickyLimit:t})}})]}),d&&(0,z.jsx)(`div`,{role:`alert`,className:`card-sub`,style:{marginTop:8,color:`var(--danger, #c44)`},children:d})]})}var Oa=`ocx doctor`,ka=4e3,Aa=[],ja=[];function Ma({item:e,apiBase:t,oauth:n,accounts:r=Aa,keys:i=ja,accountLoadState:a=`ready`,switchingAccountId:o=null,busy:s=!1,loginHint:c,authHandlers:l,onCodexActiveNeedsReauthChange:u,codexController:d}){let f=K(),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!1),S=xi(),C=xi();(0,_.useEffect)(()=>{if(r.length===0){x(!1);return}if(!r.some(e=>e.quota==null&&!e.quotaUnavailable)){x(!1);return}x(!0);let e=window.setTimeout(()=>x(!1),ka);return()=>window.clearTimeout(e)},[r]);let w=Zr({...e,hasApiKey:e.hasApiKey||i.length>0}),T=w===`oauth-accounts`,E=w===`api-keys`;if(w===`codex-accounts`)return(0,z.jsxs)(`section`,{className:`pwi-section pwi-auth-section`,"aria-label":f(`pws.availableAccounts`),children:[(0,z.jsx)(`h3`,{className:`pwi-section-title`,children:f(`pws.availableAccounts`)}),(0,z.jsx)(`div`,{className:`pwi-auth-body`,children:(0,z.jsx)(Ea,{apiBase:t,embedded:!0,controller:d,onActiveNeedsReauthChange:u})})]});if(!w||!l)return null;let D=c?.provider===e.name?c:null,O=D?.deviceCode??``,k=S.outcomeFor(O),A=f(k===`copied`?`prov.codeCopied`:k===`unavailable`?`prov.linkCopyUnavailable`:`prov.copyCode`),j=r.length>0||n?.loggedIn===!0,M=r.find(e=>e.active&&e.needsReauth),N=!!M,P=async()=>{let t=h.trim();if(t){y(!0);try{await l.onAddApiKey(e.name,t)&&(g(``),m(!1))}finally{y(!1)}}};return(0,z.jsxs)(`section`,{className:`pwi-section pwi-auth-section`,"aria-label":f(T?`pws.availableAccounts`:`pws.apiKeys`),children:[(0,z.jsx)(`h3`,{className:`pwi-section-title`,children:f(T?`pws.availableAccounts`:`pws.apiKeys`)}),(0,z.jsxs)(`div`,{className:`pwi-auth-body`,children:[T&&(0,z.jsxs)(z.Fragment,{children:[e.name===`anthropic`&&(0,z.jsx)(Da,{apiBase:t,accountCount:r.length}),(0,z.jsxs)(`div`,{className:`pwi-auth-status-row`,children:[(0,z.jsx)(`span`,{className:`pwi-auth-dot ${N?`pwi-auth-dot--warn`:j?`pwi-auth-dot--ok`:`pwi-auth-dot--off`}`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`pwi-auth-status-text`,children:j?r.length>0?f(`pws.loggedInTitle`):n?.email??f(`pws.loggedInTitle`):n?.error||f(`pws.notLoggedInTitle`)}),(0,z.jsxs)(`span`,{className:`pwi-auth-actions`,children:[M&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:s,onClick:()=>void l.onReauth(e.name,M.id),children:f(`pws.reauthenticate`)}),j?(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void l.onLogout(e.name),children:f(`prov.logout`)}):(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:s,onClick:()=>void l.onLogin(e.name,!1),children:[s?(0,z.jsx)(`span`,{className:`pwi-spin-inline`,"aria-hidden":`true`}):(0,z.jsx)(Se,{style:{width:13,height:13},"aria-hidden":`true`}),f(s?`prov.waitingBrowser`:`prov.login`)]})]})]}),s&&D&&(0,z.jsxs)(`div`,{className:`pwi-auth-wait`,children:[(0,z.jsx)(`span`,{className:`pwi-spin-inline`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{className:`pwi-auth-wait-copy`,children:[(0,z.jsx)(`div`,{className:`pwi-auth-wait-title`,children:f(`prov.waitingBrowser`)}),D.deviceCode&&(0,z.jsxs)(`div`,{className:`pwi-device-code-wrap`,children:[(0,z.jsx)(`span`,{children:f(`prov.deviceCode`)}),(0,z.jsx)(`code`,{className:`pwi-device-code`,children:D.deviceCode}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>S.copy(O,O),children:(0,z.jsx)(`span`,{"aria-live":`polite`,children:A})})]}),(0,z.jsx)(Si,{url:D.url??``}),l.onCancelLogin&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void l.onCancelLogin?.(e.name),children:f(`common.cancel`)})]})]}),a===`loading`&&r.length===0&&(0,z.jsxs)(`div`,{className:`pwi-auth-state`,role:`status`,children:[(0,z.jsx)(`span`,{className:`pwi-spin-inline`,"aria-hidden":`true`}),f(`pws.accountsLoading`)]}),a===`error`&&(0,z.jsxs)(`div`,{className:`pwi-auth-state pwi-auth-state--error`,role:`alert`,children:[(0,z.jsx)(`span`,{children:f(`pws.accountsLoadFailed`)}),l.onRetryAccounts&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void l.onRetryAccounts?.(e.name),children:f(`pws.retryAccounts`)})]}),r.length>0&&(0,z.jsx)(`ul`,{className:`pwi-auth-list`,children:r.map(t=>{let n=Qr(r,t,f),i=o===t.id,a=t.health?.status,c=!!t.needsReauth||si(a),u=ui(a),d=li(a),p=ii(t.id),m=fi(f,t.health),h=pi(f,e.name,t.id,t.health);return(0,z.jsxs)(`li`,{className:`pwi-auth-acct${t.active?` pwi-auth-acct--active`:``}`,children:[(0,z.jsxs)(`div`,{className:`pwi-auth-row${t.active?` pwi-auth-row--active`:``}`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`pwi-auth-row-main`,onClick:()=>{!t.active&&!c&&!d&&!o&&l.onSwitchAccount(e.name,t)},"aria-current":t.active?`true`:void 0,"aria-label":`${n}${t.active?` — ${f(`pws.accountCurrent`)}`:``}`,disabled:!!(c||d||o&&!i),children:[(0,z.jsx)(`span`,{className:`pwi-auth-dot ${c?`pwi-auth-dot--warn`:t.active?`pwi-auth-dot--ok`:`pwi-auth-dot--off`}`,"aria-hidden":`true`}),(0,z.jsxs)(`span`,{className:`pwi-auth-row-copy`,children:[(0,z.jsx)(`span`,{className:`pwi-auth-row-label`,children:n}),(0,z.jsx)(`span`,{className:`pwi-auth-row-secondary`,children:[t.email,`${f(`prov.accountId`)}: ${p}`].filter(Boolean).join(` · `)}),h&&(0,z.jsx)(`span`,{className:`pwi-auth-row-secondary faint`,children:h}),d&&(0,z.jsx)(`span`,{className:`pwi-auth-row-secondary faint`,children:f(`pws.healthCooldownHint`)})]}),m&&(0,z.jsx)(`span`,{className:oi(a),children:m}),c&&!m&&(0,z.jsx)(`span`,{className:`badge badge-amber`,children:f(`pws.reauth`)}),t.active&&(0,z.jsx)(`span`,{className:`badge badge-primary`,children:f(`prov.accountActive`)}),i&&(0,z.jsx)(`span`,{className:`badge badge-muted`,children:f(`pws.accountSwitching`)})]}),c&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:s||!!o,onClick:()=>void l.onReauth(e.name,t.id),children:f(`pws.reauthenticate`)}),u&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm codex-auth-action-btn`,onClick:()=>{C.copy(Oa,t.id)},children:(0,z.jsx)(`span`,{"aria-live":`polite`,children:gi(f,C.outcomeFor(t.id))})}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void l.onEditAlias(e.name,`oauth`,t.id,t.alias),children:f(`prov.editAlias`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm pwi-auth-row-remove`,"aria-label":`${f(`common.remove`)} — ${n}`,title:`${f(`common.remove`)} — ${n}`,disabled:!!o,onClick:()=>void l.onRemoveAccount(e.name,t),children:(0,z.jsx)(ue,{style:{width:13,height:13},"aria-hidden":`true`})})]}),(t.quota!=null||t.quotaUnavailable||b&&t.quota==null)&&(0,z.jsx)(`div`,{className:`pwi-auth-acct-quota`,children:t.quotaUnavailable?(0,z.jsx)(`p`,{className:`muted pwi-auth-acct-quota-stale`,children:f(`pws.accountQuotaUnavailable`)}):(0,z.jsx)(Br,{quota:t.quota??null,plan:null,threshold:80,t:f,layout:`stacked`,pending:t.quota==null})})]},t.id)})}),a===`ready`&&j&&r.length===0&&(0,z.jsx)(`div`,{className:`pwi-auth-state pwi-auth-state--empty`,children:f(`pws.noAccounts`)}),j&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{marginTop:8},onClick:()=>void l.onLogin(e.name,!0),disabled:s||!!o,children:f(`pws.addAccount`)})]}),E&&(0,z.jsxs)(z.Fragment,{children:[i.length>0&&(0,z.jsx)(`ul`,{className:`pwi-auth-list`,children:i.map(t=>(0,z.jsxs)(`li`,{className:`pwi-auth-row${t.active?` pwi-auth-row--active`:``}`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`pwi-auth-row-main`,onClick:()=>void l.onSwitchApiKey(e.name,t),disabled:t.active,children:[(0,z.jsx)(`span`,{className:`pwi-auth-dot ${t.active?`pwi-auth-dot--ok`:`pwi-auth-dot--off`}`,"aria-hidden":`true`}),(0,z.jsxs)(`span`,{className:`pwi-auth-row-copy`,children:[(0,z.jsx)(`span`,{className:`pwi-auth-row-label`,children:t.label??t.masked}),t.label&&(0,z.jsxs)(`code`,{className:`pwi-auth-row-secondary`,children:[t.masked,` · `,f(`prov.accountId`),`: `,t.id]})]}),t.active&&(0,z.jsx)(`span`,{className:`badge badge-primary`,children:f(`prov.accountActive`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void l.onEditAlias(e.name,`api-key`,t.id,t.label),children:f(`prov.editAlias`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm pwi-auth-row-remove`,"aria-label":`${f(`common.remove`)} — ${t.label??t.masked}`,title:`${f(`common.remove`)} — ${t.label??t.masked}`,onClick:()=>void l.onRemoveApiKey(e.name,t),children:(0,z.jsx)(ue,{style:{width:13,height:13},"aria-hidden":`true`})})]},t.id))}),p?(0,z.jsxs)(`div`,{className:`pwi-auth-add-key`,children:[(0,z.jsx)(`input`,{className:`input`,type:`password`,value:h,onChange:e=>g(e.target.value),placeholder:f(`modal.apiKeyPlaceholder`),autoComplete:`off`,disabled:v}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>void P(),disabled:v||!h.trim(),children:f(v?`pws.saving`:`pws.addKey`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>{m(!1),g(``)},children:f(`common.cancel`)})]}):(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{marginTop:8},onClick:()=>m(!0),children:f(`pws.addKey`)})]})]})]})}function Na(e,t,n){let r=e?.find(e=>e.id===t);if(!r)return n;if(r.baseUrl)return r.baseUrl;let i=new Set((e??[]).map(e=>e.baseUrl?.trim().replace(/\/+$/,``)).filter(e=>!!e)),a=n.trim().replace(/\/+$/,``);return i.has(a)?``:n}function Pa(e,t){if(!e?.length)return`custom`;let n=t.trim().replace(/\/+$/,``);for(let t of e)if(t.baseUrl&&t.baseUrl.trim().replace(/\/+$/,``)===n)return t.id;return e.some(e=>e.id===`custom`)?`custom`:e[0].id}function Fa(e,t,n){let r=e?.find(e=>e.id===t);return r?.baseUrl?r.baseUrl.trim():n.trim()}var Ia=[`openai-responses`,`openai-chat`,`anthropic`,`google`,`azure-openai`,`cursor`],La=[];function Ra({item:e,availableModels:t=La,apiBase:n,onUpdateProvider:r,onDirtyChange:i,onRegisterSave:a}){let o=K(),s=String(e.authMode??(e.keyOptional?`local`:`key`)),[c,l]=(0,_.useState)(e.adapter),[u,d]=(0,_.useState)(e.baseUrl),[f,p]=(0,_.useState)(e.defaultModel??``),[m,h]=(0,_.useState)(s),[g,v]=(0,_.useState)(e.apiKeyTransport??`x-api-key`),[y,b]=(0,_.useState)(e.note??``),[x,S]=(0,_.useState)(e.allowPrivateNetwork??!1),[C,w]=(0,_.useState)(e.liveModels!==!1),[T,E]=(0,_.useState)(!1),[D,O]=(0,_.useState)(null),[k,A]=(0,_.useState)(),[j,M]=(0,_.useState)(n?`loading`:`idle`),[N,P]=(0,_.useState)(()=>`custom`);(0,_.useEffect)(()=>{l(e.adapter),d(e.baseUrl),p(e.defaultModel??``),h(String(e.authMode??(e.keyOptional?`local`:`key`))),v(e.apiKeyTransport??`x-api-key`),b(e.note??``),S(e.allowPrivateNetwork??!1),w(e.liveModels!==!1),O(null),queueMicrotask(()=>P(Pa(k,e.baseUrl)))},[e.adapter,e.baseUrl,e.defaultModel,e.authMode,e.apiKeyTransport,e.keyOptional,e.note,e.allowPrivateNetwork,e.liveModels,k]),(0,_.useEffect)(()=>{if(!n)return;let t=!1,r=e.name,i=e.baseUrl;return fetch(`${n}/api/provider-presets`).then(e=>ut(e)).then(e=>{if(t)return;if(!e){A(void 0),M(`error`);return}let n=(e.providers??[]).find(e=>e.id===r)?.baseUrlChoices;A(n),M(`ready`),P(Pa(n,i))}).catch(()=>{t||(A(void 0),M(`error`))}),()=>{t=!0}},[n,e.name]);let F=c.trim()!==e.adapter||u.trim()!==e.baseUrl||f.trim()!==(e.defaultModel??``)||m!==String(e.authMode??(e.keyOptional?`local`:`key`))||c.trim()===`anthropic`&&m===`key`&&g!==(e.apiKeyTransport??`x-api-key`)||y.trim()!==(e.note??``)||x!==(e.allowPrivateNetwork??!1)||C!==(e.liveModels!==!1);(0,_.useEffect)(()=>(i?.(F),()=>i?.(!1)),[F,i]);let I=(0,_.useMemo)(()=>{let n=new Set(t);return f.trim()&&n.add(f.trim()),e.defaultModel&&n.add(e.defaultModel),[...n].sort((e,t)=>e.localeCompare(t))},[t,f,e.defaultModel]),L=(0,_.useMemo)(()=>{let e=[...Ia];return c&&!e.includes(c)&&e.unshift(c),e},[c]),R=yr(e.name),B=j===`ready`&&!!(k&&k.length>0),V=c.trim()===`anthropic`&&m===`key`,H=R&&j!==`error`,U=async()=>{if(!r)return O({ok:!1,text:o(`pws.updatesUnavailable`)}),!1;let t=B?Fa(k,N,u):u.trim();if(!c.trim()||!t)return O({ok:!1,text:o(`pws.adapterBaseRequired`)}),!1;E(!0),O(null);try{let n={adapter:c.trim(),baseUrl:t,defaultModel:f.trim(),authMode:m,note:y.trim(),allowPrivateNetwork:x};C!==(e.liveModels!==!1)&&(n.liveModels=C),V?n.apiKeyTransport=g:e.apiKeyTransport!==void 0&&(n.apiKeyTransport=``);let i=await r(e.name,n);return O(i.ok?{ok:!0,text:o(`pws.settingsSaved`)}:{ok:!1,text:i.error||o(`prov.saveFailed`)}),i.ok}finally{E(!1)}},W=(0,_.useRef)(U);(0,_.useEffect)(()=>{W.current=U}),(0,_.useEffect)(()=>{if(a)return a(()=>W.current()),()=>a(null)},[a]);let ee=()=>{l(e.adapter),d(e.baseUrl),p(e.defaultModel??``),h(s),v(e.apiKeyTransport??`x-api-key`),b(e.note??``),S(e.allowPrivateNetwork??!1),w(e.liveModels!==!1),O(null),P(Pa(k,e.baseUrl))},te=(e,t)=>{switch(e){case`token-plan`:return o(`modal.endpoint.tokenPlan`);case`payg`:return o(`modal.endpoint.payAsYouGo`);case`custom`:return o(`modal.endpoint.custom`);default:return t}};return(0,z.jsxs)(`div`,{className:`pwi-settings-form`,children:[(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsxs)(`span`,{className:`pwi-settings-label`,children:[(0,z.jsx)(Se,{style:{width:12,height:12}}),` `,o(`pws.providerId`)]}),(0,z.jsx)(`input`,{className:`input`,value:e.name,readOnly:!0,disabled:!0})]}),(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`modal.adapter`)}),R?(0,z.jsx)(`input`,{className:`input`,value:c,readOnly:!0,disabled:!0}):(0,z.jsx)(`select`,{className:`input`,value:c,onChange:e=>l(e.target.value),children:L.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}),B?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`modal.endpoint`)}),(0,z.jsx)(`select`,{className:`input`,value:N,onChange:e=>{let t=e.target.value;P(t),d(Na(k,t,u))},children:k.map(e=>(0,z.jsx)(`option`,{value:e.id,children:te(e.id,e.label)},e.id))})]}),N===`custom`&&(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`modal.baseUrl`)}),(0,z.jsx)(`input`,{className:`input`,value:u,onChange:e=>d(e.target.value),placeholder:o(`modal.baseUrlPlaceholder`)})]})]}):(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`modal.baseUrl`)}),(0,z.jsx)(`input`,{className:`input`,value:u,onChange:e=>d(e.target.value),readOnly:H,disabled:H})]}),(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`pws.cell.defaultModel`)}),I.length>0?(0,z.jsxs)(`select`,{className:`input`,value:f,onChange:e=>p(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:o(`pws.defaultModelNone`)}),I.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}):(0,z.jsx)(`input`,{className:`input`,value:f,onChange:e=>p(e.target.value),placeholder:o(`pws.optionalPlaceholder`)})]}),(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`pws.authMode`)}),R?(0,z.jsx)(`input`,{className:`input`,value:xr(e,o),readOnly:!0,disabled:!0}):(0,z.jsxs)(`select`,{className:`input`,value:m,onChange:e=>h(e.target.value),children:[(0,z.jsx)(`option`,{value:`key`,children:o(`modal.badge.apiKey`)}),(0,z.jsx)(`option`,{value:`forward`,children:o(`pws.auth.chatgptPassthrough`)}),(0,z.jsx)(`option`,{value:`oauth`,children:o(`modal.badge.oauth`)}),(0,z.jsx)(`option`,{value:`local`,children:o(`modal.badge.local`)})]})]}),V&&(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`modal.apiKeyTransport`)}),(0,z.jsxs)(`select`,{className:`input`,value:g,onChange:e=>v(e.target.value),children:[(0,z.jsx)(`option`,{value:`x-api-key`,children:o(`modal.apiKeyTransportNative`)}),(0,z.jsx)(`option`,{value:`bearer`,children:o(`modal.apiKeyTransportBearer`)})]})]}),(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`pws.note`)}),(0,z.jsx)(`textarea`,{className:`input pwi-settings-textarea`,value:y,onChange:e=>b(e.target.value),rows:2})]}),(0,z.jsxs)(`label`,{className:`pwi-settings-field`,style:{flexDirection:`row`,alignItems:`center`,gap:8},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`pws.allowPrivateNetwork`)})]}),(0,z.jsxs)(`label`,{className:`pwi-settings-field`,style:{flexDirection:`row`,alignItems:`flex-start`,gap:8},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>w(e.target.checked)}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`pws.liveModels`)}),(0,z.jsx)(`span`,{className:`muted text-label`,style:{display:`block`,marginTop:2},children:o(`pws.liveModelsDesc`)})]})]}),F&&(0,z.jsxs)(`div`,{className:`pwi-settings-sticky-bar`,children:[(0,z.jsx)(`span`,{className:`muted`,children:o(`pws.settingsUnsavedBar`)}),(0,z.jsxs)(`div`,{className:`pwi-settings-sticky-bar-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:ee,disabled:T,children:o(`pws.discardSettings`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>void U(),disabled:T,children:o(T?`pws.saving`:`pws.saveSettings`)})]})]}),D&&(0,z.jsx)(`div`,{className:D.ok?`pwi-settings-msg pwi-settings-msg--ok`:`pwi-settings-msg pwi-settings-msg--err`,children:D.text})]})}function za({providerName:e,defaultProviderName:t,onConfirm:n,onCancel:r}){let i=K();return(0,z.jsx)(`div`,{className:`dialog-backdrop`,onClick:r,children:(0,z.jsxs)(`div`,{className:`dialog`,role:`alertdialog`,"aria-label":i(`pws.removeConfirmTitle`),onClick:e=>e.stopPropagation(),children:[(0,z.jsx)(`h3`,{children:i(`pws.removeConfirmTitle`)}),(0,z.jsx)(`p`,{children:t?i(`pws.removeDefaultConfirmBody`,{name:e,defaultProvider:t}):i(`pws.removeConfirmBody`,{name:e})}),(0,z.jsxs)(`div`,{className:`dialog-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:r,children:i(`common.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-danger`,onClick:n,children:i(`pws.removeConfirm`)})]})]})})}function Ba({onSave:e,onDiscard:t,onCancel:n,saving:r=!1}){let i=K();return(0,z.jsx)(`div`,{className:`dialog-backdrop`,onClick:n,children:(0,z.jsxs)(`div`,{className:`dialog`,role:`alertdialog`,"aria-label":i(`pws.unsavedLeaveTitle`),onClick:e=>e.stopPropagation(),children:[(0,z.jsx)(`h3`,{children:i(`pws.unsavedLeaveTitle`)}),(0,z.jsx)(`p`,{children:i(`pws.unsavedLeaveBody`)}),(0,z.jsxs)(`div`,{className:`dialog-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:n,children:i(`common.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:t,children:i(`pws.discardSettings`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:e,disabled:r,children:i(r?`pws.saving`:`pws.saveSettings`)})]})]})})}function Va({item:e,usageTotals:t,modelUsage:n,quotaReport:r,availableModels:i,hasLiveModels:a,selectedModels:o,modelsLoading:s,modelsLoadFailed:c,onRetryModels:l,oauthEmail:u,onDeselect:d,apiBase:f,oauth:p,accounts:m,accountLoadState:h,switchingAccountId:g,keys:v,busyProvider:y,loginHint:b,authHandlers:x,onCodexActiveNeedsReauthChange:S,codexController:C,onUpdateProvider:w,isDefault:T,onRemoveProvider:E,onSetDisabled:D,onSetDefault:O}){let k=K(),[A,j]=(0,_.useState)(`overview`),[M,N]=(0,_.useState)(!1),[P,F]=(0,_.useState)(null),[I,L]=(0,_.useState)(!1),R=(0,_.useRef)(null),B=(0,_.useCallback)(e=>{R.current=e},[]),V=e.disabled===!0,H=(0,_.useMemo)(()=>Un(e),[e]),U=(0,_.useMemo)(()=>Xn(e),[e]),W=(0,_.useMemo)(()=>Zr(e),[e]),ee=JSON.stringify([C?.activeId??``,m?.find(e=>e.active)?.id??``,v?.find(e=>e.active)?.id??``,p?.loggedIn===void 0?``:String(p.loggedIn),p?.needsReauth===void 0?``:String(p.needsReauth),u??``]),te=(0,_.useMemo)(()=>[{id:`overview`,label:k(`pws.tab.overview`)},{id:`models`,label:k(`pws.tab.models`)},{id:`usage`,label:k(`pws.tab.usage`)},...W?[{id:`accounts`,label:k(W===`api-keys`?`pws.apiKeys`:`pws.tab.accounts`)}]:[],{id:`settings`,label:k(`pws.tab.settings`)}],[W,k]),ne=(0,_.useCallback)(e=>{if(M&&A===`settings`&&e!==`settings`){F(e);return}j(e)},[A,M]),re=(0,_.useCallback)(()=>{if(M&&A===`settings`){F(`deselect`);return}d()},[M,A,d]),G=(0,_.useCallback)((e,t)=>{let n;if(e.key===`ArrowRight`)n=(t+1)%te.length;else if(e.key===`ArrowLeft`)n=(t-1+te.length)%te.length;else if(e.key===`Home`)n=0;else if(e.key===`End`)n=te.length-1;else return;e.preventDefault(),ne(te[n].id),e.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`)[n]?.focus()},[ne,te]),ie=`pws-tab-${A}`,ae=`pws-panel-${A}`;return(0,z.jsxs)(`div`,{className:`pws-detail`,children:[(0,z.jsx)(`div`,{className:`pws-detail-head`,children:(0,z.jsxs)(`button`,{type:`button`,className:`pws-detail-back-link`,onClick:re,children:[(0,z.jsx)(_e,{className:`pws-detail-back-chevron`,"aria-hidden":`true`}),k(`pws.allProviders`)]})}),(0,z.jsxs)(`div`,{className:`pws-detail-head-main`,children:[(0,z.jsx)(Cr,{name:e.name,adapter:e.adapter,baseUrl:e.baseUrl,cls:`pws-detail-icon`}),(0,z.jsx)(`div`,{className:`pws-detail-title-wrap`,children:(0,z.jsxs)(`h2`,{className:`pws-detail-title`,children:[vr(e.name,k),U&&(0,z.jsx)(`span`,{className:`pwi-rail-badge pwi-rail-badge--local`,children:k(`modal.badge.local`)}),!U&&H&&(0,z.jsx)(`span`,{className:`pwi-rail-badge pwi-rail-badge--free`,children:k(`modal.badge.free`)})]})}),(0,z.jsxs)(`div`,{className:`pws-detail-actions`,children:[!T&&!V&&O&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>O(e.name),children:k(`prov.setDefault`)}),E&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm btn-icon-only`,onClick:()=>E(e.name),"aria-label":k(`pws.removeConfirmTitle`),title:k(`pws.removeConfirmTitle`),children:(0,z.jsx)(ue,{style:{width:15,height:15},"aria-hidden":`true`})}),D&&(0,z.jsxs)(`div`,{className:`pws-detail-toggle`,children:[(0,z.jsx)(`span`,{className:`pws-detail-toggle-label`,children:k(`pws.enabledLabel`)}),(0,z.jsx)(it,{on:!V,onClick:()=>D(e.name,!V),disabled:T,label:k(`pws.enabledLabel`)})]})]})]}),(0,z.jsx)(`div`,{className:`pws-detail-tabs`,role:`tablist`,children:te.map((e,t)=>(0,z.jsx)(`button`,{type:`button`,role:`tab`,id:`pws-tab-${e.id}`,"aria-controls":`pws-panel-${e.id}`,"aria-selected":A===e.id,tabIndex:A===e.id?0:-1,className:`pws-detail-tab${A===e.id?` pws-detail-tab--active`:``}`,onClick:()=>ne(e.id),onKeyDown:e=>G(e,t),children:e.label},e.id))}),(0,z.jsxs)(`div`,{className:`pws-detail-panel`,role:`tabpanel`,id:ae,"aria-labelledby":ie,tabIndex:0,children:[A===`overview`&&(0,z.jsx)($r,{accountPanel:W?(0,z.jsx)(Ma,{item:e,apiBase:f,oauth:p,accounts:m,keys:v,accountLoadState:h,switchingAccountId:g,busy:y===e.name,loginHint:b,authHandlers:x,onCodexActiveNeedsReauthChange:S,codexController:C}):void 0,item:e,apiBase:f,connectionIdentity:ee,usageTotals:t,quotaReport:r,oauthEmail:u,onEditSettings:()=>ne(`settings`),onViewUsage:()=>ne(`usage`),onUpdateProvider:w,reauthBusy:y===e.name,onCancelLogin:x?.onCancelLogin?()=>void x.onCancelLogin?.(e.name):void 0,onReauthenticate:e.activeNeedsReauth?()=>{if(e.authMode===`oauth`){let t=m??[],n=t.find(e=>e.active&&e.needsReauth)??t.find(e=>e.needsReauth);x?.onReauth(e.name,n?.id);return}ne(`accounts`)}:void 0}),A===`models`&&(0,z.jsx)(ti,{item:e,apiBase:f,availableModels:i,hasLiveModels:a,selectedModels:o,modelsLoading:s,modelsLoadFailed:c,needsReauth:(m??[]).some(e=>e.active&&e.needsReauth)||p?.needsReauth===!0,onRetryModels:l,onOpenAccounts:W?()=>ne(`accounts`):void 0},e.name),A===`usage`&&(0,z.jsx)(ni,{item:e,usageTotals:t,quotaReport:r,modelUsage:n}),A===`accounts`&&(0,z.jsx)(Ma,{item:e,apiBase:f,oauth:p,accounts:m,keys:v,accountLoadState:h,switchingAccountId:g,busy:y===e.name,loginHint:b,authHandlers:x,onCodexActiveNeedsReauthChange:S,codexController:C}),A===`settings`&&(0,z.jsx)(Ra,{item:e,apiBase:f,availableModels:i,onUpdateProvider:w,onDirtyChange:N,onRegisterSave:B},e.name)]}),P&&(0,z.jsx)(Ba,{saving:I,onCancel:()=>{I||F(null)},onDiscard:()=>{if(I)return;let e=P;F(null),N(!1),e===`deselect`?d():j(e)},onSave:()=>{(async()=>{if(!I){L(!0);try{if(!(await R.current?.()??!1))return;let e=P;F(null),N(!1),e===`deselect`?d():e&&j(e)}finally{L(!1)}}})()}})]})}var Ha=`https://chatgpt.com/backend-api/codex`;function Ua(e){try{let t=new URL(e.trim());if(t.username||t.password||t.search||t.hash)return;let n=t.pathname.replace(/\/+$/,``);return`${t.origin}${n}`}catch{return}}function Wa(e){return[`openai`,...Object.entries(e).filter(([,e])=>e.authMode===`forward`).map(([e])=>e).filter(e=>e!==`openai`).sort((e,t)=>e.localeCompare(t))]}function Ga(e){return e?e.adapter!==`openai-responses`||e.authMode!==`forward`||typeof e.baseUrl!=`string`||Ua(e.baseUrl)!==Ha?`invalid`:e.disabled===!0?`disabled`:`ready`:`absent`}function Ka(e){return e.id===`openai`}function qa(e){return e.id===`openai`?e.codexAccountMode===`direct`?`prov.openaiDirectDesc`:`prov.openaiPoolDesc`:null}function Ja(e){let t={adapter:e.adapter.trim(),baseUrl:e.baseUrl.trim()};return e.responsesPath?.trim()&&(t.responsesPath=e.responsesPath.trim()),(e.authMode===`key`||e.authMode===`forward`)&&(t.authMode=e.authMode),e.authMode===`key`&&e.apiKey.trim()&&(t.apiKey=e.apiKey.trim()),e.adapter.trim()===`anthropic`&&e.authMode===`key`&&e.apiKeyTransport===`bearer`&&(t.apiKeyTransport=`bearer`),e.defaultModel.trim()&&(t.defaultModel=e.defaultModel.trim()),e.allowPrivateNetwork&&(t.allowPrivateNetwork=!0),t}function Ya(e,t){return Ka(e)?Xa(e):{name:t.name.trim(),provider:Ja(t)}}function Xa(e){if(!e.provider)throw Error(`Missing canonical provider seed for ${e.id}`);return{name:e.id,provider:structuredClone(e.provider)}}var Za=class extends Error{i18nKey;constructor(e){super(e),this.name=`OpenAiEnableError`,this.i18nKey=e}};async function Qa(e,t,n=fetch){if(t===`disabled`){if((await n(`${e}/api/providers?name=openai`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({disabled:!1})})).ok)return;throw new Za(`codexAuth.enableOpenaiFailed`)}let r=await n(`${e}/api/provider-presets`);if(!r.ok)throw new Za(`codexAuth.openaiPresetLoadFailed`);let i=(await r.json()).providers?.find(e=>e.id===`openai`);if(!i?.provider)throw new Za(`codexAuth.openaiPresetUnavailable`);if(!(await n(`${e}/api/providers`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(Xa(i))})).ok)throw new Za(`codexAuth.enableOpenaiFailed`)}var $a=new Set([`anthropic`,`google-antigravity`]),eo=new Set([`github-copilot`,`cursor`]);function to(e){let t=e.trim().toLowerCase();return $a.has(t)?`high`:eo.has(t)?`elevated`:null}function Z(e){switch(e){case`high`:return`oauthTos.highTitle`;case`elevated`:return`oauthTos.elevatedTitle`;default:return e}}function no(e){switch(e){case`high`:return`oauthTos.highBody`;case`elevated`:return`oauthTos.elevatedBody`;default:return e}}function ro(e,t=!1){let n={};for(let[t,r]of Object.entries(e))ci(r.accounts.find(e=>e.active)??r.accounts.find(e=>e.id===r.activeAccountId))&&(n[t]=!0);return t&&(n.openai=!0),n}function io(e){let{apiBase:t,t:n,config:r,aliveRef:i,notify:a,fetchConfig:o,fetchOauth:s,fetchProviderQuotas:c,codexActiveNeedsReauth:l}=e,[u,d]=(0,_.useState)({}),[f,p]=(0,_.useState)({}),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)({}),[y,b]=(0,_.useState)({}),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(``),T=(0,_.useRef)({}),E=(0,_.useRef)(null),D=(0,_.useRef)(null),O=(0,_.useRef)(null),k=(0,_.useCallback)(async e=>{let n=[...new Set(e)];return p(e=>{let t={...e};for(let e of n)t[e]=`loading`;return t}),(await Promise.all(n.map(async e=>{let n=(T.current[e]??0)+1;T.current[e]=n;try{let r=await fetch(`${t}/api/oauth/accounts?provider=${encodeURIComponent(e)}`);if(!r.ok)throw Error(String(r.status));let a=await r.json();return!i.current||T.current[e]!==n?!0:(d(t=>({...t,[e]:{activeAccountId:a.activeAccountId??null,accounts:a.accounts??[]}})),p(t=>({...t,[e]:`ready`})),(async()=>{try{let r=await fetch(`${t}/api/oauth/accounts?provider=${encodeURIComponent(e)}&quota=1`);if(!r.ok)return;let o=await r.json();if(!i.current||T.current[e]!==n)return;d(t=>({...t,[e]:{activeAccountId:o.activeAccountId??a.activeAccountId??null,accounts:o.accounts??a.accounts??[]}}))}catch{}})(),!0)}catch{return!i.current||T.current[e]!==n?!0:(p(t=>({...t,[e]:`error`})),!1)}}))).every(Boolean)},[i,t]),A=(0,_.useCallback)(async e=>{let n=await Promise.all(e.map(async e=>[e,(await fetch(`${t}/api/providers/keys?name=${encodeURIComponent(e)}`).then(async e=>{if(!e.ok)throw Error(String(e.status));return e.json()}).catch(()=>null))?.keys??[]]));b(Object.fromEntries(n))},[t]),j=async(e,r)=>{if(r.active||r.needsReauth||O.current)return;let o={provider:e,accountId:r.id};O.current=o,h(o);let l=Qr(u[e]?.accounts??[r],r,n);try{if(!(await fetch(`${t}/api/oauth/accounts/active`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e,accountId:r.id})})).ok){a(n(`prov.accountSwitchFail`),!1);return}let i=await k([e]);if(await Promise.all([s(),c(!0)]),!i){a(n(`pws.accountsLoadFailed`),!1);return}a(n(`prov.accountSwitched`,{email:l}),!0)}catch{a(n(`prov.accountSwitchFail`),!1)}finally{O.current?.provider===o.provider&&O.current.accountId===o.accountId&&(O.current=null,i.current&&h(null))}},M=async(e,r)=>{if(r.active)return;let i=await fetch(`${t}/api/providers/keys/active`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e,id:r.id})});i.ok?(a(n(`prov.keySwitched`,{key:r.label??r.masked}),!0),A(Object.keys(y)),c(!0)):a((await i.json().catch(()=>({}))).error||n(`prov.keySwitchFail`),!1)},N=async(e,r)=>{window.confirm(n(`prov.keyRemoveConfirm`,{key:r.label??r.masked}))&&(await fetch(`${t}/api/providers/keys?name=${encodeURIComponent(e)}&id=${encodeURIComponent(r.id)}`,{method:`DELETE`})).ok&&(a(n(`prov.keyRemoved`,{key:r.label??r.masked}),!0),A(Object.keys(y)),o(),c(!0))},P=async(e,r)=>{let i=r.trim();if(!i)return!1;try{let r=await fetch(`${t}/api/providers/keys`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e,key:i})});return r.ok?(a(n(`prov.keyAdded`,{name:e}),!0),S(null),await Promise.all([A(Object.keys(y).includes(e)?Object.keys(y):[...Object.keys(y),e]),o(),c(!0)]),!0):(a((await r.json().catch(()=>({}))).error||n(`prov.keyAddFail`),!1),!1)}catch{return a(n(`prov.keyAddFail`),!1),!1}},F=async e=>{await P(e,C)&&w(``)},I=async(e,r,i,o)=>{let s=window.prompt(n(`prov.aliasPrompt`),o??``);if(s===null)return;let c=s.trim(),l=await fetch(r===`oauth`?`${t}/api/oauth/accounts/alias`:`${t}/api/providers/keys/alias`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r===`oauth`?{provider:e,accountId:i,alias:c}:{name:e,id:i,alias:c})});if(!l.ok){a((await l.json().catch(()=>({}))).error||n(`prov.aliasSaveFailed`),!1);return}r===`oauth`?await k([e]):await A(Object.keys(y).includes(e)?Object.keys(y):[...Object.keys(y),e]),a(n(`prov.aliasSaved`),!0)},L=async(e,r)=>{let i=Qr(u[e]?.accounts??[r],r,n);if(window.confirm(n(`prov.accountRemoveConfirm`,{email:i})))try{if(!(await fetch(`${t}/api/oauth/accounts?provider=${encodeURIComponent(e)}&id=${encodeURIComponent(r.id)}`,{method:`DELETE`})).ok){a(n(`prov.accountRemoveFail`,{email:i}),!1);return}a(n(`prov.accountRemoved`,{email:i}),!0),await k([e]),await Promise.all([s(),c(!0)])}catch{a(n(`prov.accountRemoveFail`,{email:i}),!1)}},R=(0,_.useMemo)(()=>r?Object.entries(r.providers).filter(([,e])=>e.authMode===`oauth`).map(([e])=>e):[],[r]);(0,_.useEffect)(()=>{if(R.length===0)return;let e=R.join(`,`);E.current!==e&&(E.current=e,Promise.resolve().then(()=>{k(R)}))},[k,R]);let z=(0,_.useMemo)(()=>r?Object.entries(r.providers).filter(([,e])=>e.hasApiKey&&e.authMode!==`oauth`&&e.authMode!==`forward`).map(([e])=>e):[],[r]);return(0,_.useEffect)(()=>{if(z.length===0)return;let e=z.join(`,`);D.current!==e&&(D.current=e,Promise.resolve().then(()=>{A(z)}))},[A,z]),{accountSets:u,accountLoadStates:f,switchingAccount:m,openAccounts:g,keyPools:y,addingKeyFor:x,newKeyValue:C,setAccountSets:d,setAccountLoadStates:p,setSwitchingAccount:h,setOpenAccounts:v,setKeyPools:b,setAddingKeyFor:S,setNewKeyValue:w,fetchAccountSets:k,fetchKeyPools:A,switchAccount:j,switchApiKey:M,removeApiKey:N,addApiKeyValue:P,addApiKey:F,editCredentialAlias:I,removeAccount:L,oauthCardProviders:R,keyCardProviders:z,activeAccountNeedsReauth:(0,_.useMemo)(()=>ro(u,l),[u,l])}}function ao(e){let{apiBase:t,config:n,notify:r,fetchConfig:i,fetchProviderQuotas:a,onSaved:o,t:s}=e,[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(!1),x=(0,_.useRef)(!1);(0,_.useEffect)(()=>{n&&!x.current&&d(JSON.stringify(n,null,2))},[n]);let S=(0,_.useCallback)(async()=>{v(!0);try{let e=JSON.parse(u),n=await fetch(`${t}/api/config`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return n.ok?(r(s(`prov.saved`),!0),l(!1),p(!1),x.current=!1,b(!1),h(JSON.stringify(e,null,2)),i(),a(!0),o(),!0):(r((await n.json().catch(()=>({}))).error||s(`prov.saveFailed`),!1),!1)}catch{return r(s(`prov.invalidJson`),!1),!1}finally{v(!1)}},[t,u,i,a,r,o,s]),C=(0,_.useCallback)(()=>{let e=n?JSON.stringify(n,null,2):u;h(e),d(e),b(!1),p(!0),x.current=!0},[n,u]),w=(0,_.useCallback)(()=>{b(!1),p(!1),x.current=!1;let e=n?JSON.stringify(n,null,2):m;h(e),d(e)},[n,m]);return{editing:c,setEditing:l,draft:u,setDraft:d,jsonEditorOpen:f,jsonBaseline:m,jsonSaving:g,jsonLeaveOpen:y,jsonEditorOpenRef:x,saveConfig:S,openJsonEditor:C,discardJsonEditor:w,requestCloseJsonEditor:(0,_.useCallback)(()=>{if(f&&u!==m){b(!0);return}w()},[w,u,m,f]),restoreJsonEditor:(0,_.useCallback)(()=>{d(m)},[m]),jsonIsDirty:f&&u!==m,setJsonLeaveOpen:b}}var oo={xai:`xAI (Grok)`,anthropic:`Anthropic (Claude)`,kimi:`Kimi (Moonshot)`,"google-antigravity":`Google Antigravity`,"github-copilot":`GitHub Copilot`,cursor:`Cursor`},so=e=>oo[e]??e;function co({apiBase:e,t,aliveRef:n,oauthLoginGenerationRef:r,accountSets:i,setBusy:a,setStatus:o,setLoginInfo:s,setOauthStatus:c,notify:l,fetchConfig:u,fetchOauth:d,fetchAccountSets:f,fetchProviderQuotas:p,bumpModelsRefresh:m}){return{cancelLoginOAuth:(0,_.useCallback)(async i=>{let o=(r.current.get(i)??0)+1;r.current.set(i,o);try{await fetch(`${e}/api/oauth/login/cancel`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:i})})}catch{}n.current&&(r.current.get(i)===o&&(a(e=>e===i?null:e),s(e=>e?.provider===i?null:e)),l(t(`prov.loginCancelled`,{provider:so(i)}),!1))},[n,e,l,r,a,s,t]),loginOAuth:async(d,h=!1,g)=>{let _=(r.current.get(d)??0)+1;r.current.set(d,_);let v=_,y=g?.trim()||void 0;a(d),o(``),s(null);try{let a=await fetch(`${e}/api/oauth/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:d,...h||y?{addAccount:!0}:{},...y?{accountId:y,reauth:!0}:{}})});if(r.current.get(d)!==v||!n.current)return;if(!a.ok){l((await a.json().catch(()=>({}))).error||t(`prov.loginFailStart`,{provider:so(d)}),!1);return}let o=await a.json();(o.url||o.instructions||o.deviceCode)&&s({provider:d,url:o.url,instructions:o.instructions,deviceCode:o.deviceCode});let g=i[d]?.accounts.length??0,_=!1;for(let a=0;a<150&&n.current&&r.current.get(d)===v;a++){if(await new Promise(e=>setTimeout(e,2e3)),r.current.get(d)!==v||!n.current)return;let a=await fetch(`${e}/api/oauth/status?provider=${d}`).catch(()=>null),o=a?await ut(a)??null:null;if(o){if(o.error){c(e=>({...e,[d]:o})),l(/cancel/i.test(o.error)?t(`prov.loginCancelled`,{provider:so(d)}):t(`prov.loginError`,{provider:so(d),error:o.error}),!1),s(null),_=!0;break}if(h||y?(o.accounts?.length??0)>g||o.done===!0:o.loggedIn||o.done===!0){c(e=>({...e,[d]:o}));let e=y?o.accounts?.find(e=>e.id===y):o.accounts?.find(e=>e.active)??o.accounts?.find(e=>e.id===o.activeAccountId);if(y&&!e){l(t(`prov.loginError`,{provider:so(d),error:t(`prov.reauthAccountMissing`)}),!1),s(null),_=!0;break}if(e?.needsReauth){l(t(`prov.loginError`,{provider:so(d),error:t(`prov.reauthIdentityMismatch`)}),!1),s(null),_=!0;break}l(t(`prov.loginOk`,{provider:so(d),cmd:`ocx sync`}),!0),s(null),u();let n=Object.keys(i);f(new Set(n).has(d)?n:[...n,d]),p(!0),m(),_=!0;break}}}!_&&r.current.get(d)===v&&n.current&&(await fetch(`${e}/api/oauth/login/cancel`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:d})}).catch(()=>{}),l(t(`prov.loginTimeout`,{provider:so(d)}),!1),s(null))}catch{r.current.get(d)===v&&l(t(`prov.loginRequestFail`,{provider:so(d)}),!1)}finally{n.current&&r.current.get(d)===v&&a(null)}},logoutOAuth:async n=>{try{if(!(await fetch(`${e}/api/oauth/logout?provider=${encodeURIComponent(n)}`,{method:`POST`})).ok){l(t(`prov.logoutFail`,{provider:so(n)}),!1);return}await Promise.all([f([n]),d(),u(),p(!0)]),m(),l(t(`prov.logoutOk`,{provider:so(n)}),!0)}catch{l(t(`prov.logoutFail`,{provider:so(n)}),!1)}}}}async function lo(e,t){try{let t=await e.json();if(typeof t.error==`string`&&t.error.trim())return t.error.trim()}catch{}return t}function uo(e,t,n){switch(e.code){case`last_provider`:return t(`prov.removeLastProvider`);case`provider_has_dependent_combos`:return t(`prov.removeHasDependentCombos`,{combos:(Array.isArray(e.combos)?e.combos.filter(e=>typeof e==`string`).join(`, `):``)||`—`});case`default_provider_disabled`:return t(`prov.defaultDisabled`);default:return typeof e.error==`string`&&e.error.trim()?e.error.trim():n}}function fo({apiBase:e,t,removeBusyRef:n,workspaceSelected:r,setWorkspaceSelected:i,setRemoveConfirmName:a,notify:o,fetchConfig:s,fetchOauth:c,fetchProviderQuotas:l}){let u=(0,_.useCallback)(async e=>{a(e)},[a]),d=(0,_.useCallback)(async u=>{let d=u;if(!d||n.current)return;n.current=!0,a(null);let f=t(`prov.removeFail`,{name:d});try{let n=await fetch(`${e}/api/providers?name=${encodeURIComponent(d)}`,{method:`DELETE`});if(n.ok){let e=await n.json().catch(()=>({})),a=typeof e.defaultProvider==`string`?e.defaultProvider:null;o(a?t(`prov.removedDefault`,{name:d,defaultProvider:a}):t(`prov.removed`,{name:d}),!0),r===d&&i(null),s(),c(),l(!0)}else o(uo(await n.json().catch(()=>({})),t,f),!1)}catch{o(f,!1)}finally{n.current=!1}},[e,s,c,l,o,n,a,i,t,r]),f=(0,_.useCallback)(async(n,r)=>{let i=await fetch(`${e}/api/providers?name=${encodeURIComponent(n)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({disabled:r})});if(!i.ok){o(await lo(i,t(r?`prov.disableFail`:`prov.enableFail`,{name:n})),!1);return}o(t(r?`prov.disabled`:`prov.enabled`,{name:n}),!0),s(),c(),l(!0)},[e,s,c,l,o,t]),p=(0,_.useCallback)(async(n,r)=>{try{let i=await fetch(`${e}/api/providers?name=${encodeURIComponent(n)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});return i.ok?(await s(),{ok:!0}):{ok:!1,error:await lo(i,t(`prov.updateFail`))}}catch{return{ok:!1,error:t(`prov.networkError`)}}},[e,s,t]);return{removeProvider:u,confirmRemoveProvider:d,setProviderDisabled:f,setDefaultProvider:(0,_.useCallback)(async n=>{try{let r=await fetch(`${e}/api/providers?name=${encodeURIComponent(n)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({setDefault:!0})});return r.ok?(o(t(`prov.setDefaultSuccess`,{name:n}),!0),await s(),!0):(o(uo(await r.json().catch(()=>({})),t,t(`prov.setDefaultFail`,{name:n})),!1),!1)}catch{return o(t(`prov.setDefaultFail`,{name:n}),!1),!1}},[e,s,o,t]),updateProvider:p}}function po({apiBase:e,t,setConfig:n,setOauthProviders:r,setOauthStatus:i,notify:a,invalidateProviderQuotas:o,configCacheKey:s}){return{fetchConfig:(0,_.useCallback)(async()=>{try{let t=await J(await fetch(`${e}/api/config`));n(t??null),s&&t&&X(s,t)}catch{a(t(`prov.loadConfigFail`),!1)}},[e,s,a,n,t]),fetchOauth:(0,_.useCallback)(async()=>{try{let t=(await J(await fetch(`${e}/api/oauth/providers`)))?.providers??[];r(t);let n=await Promise.all(t.map(async t=>{let n=await fetch(`${e}/api/oauth/status?provider=${encodeURIComponent(t)}`).catch(()=>null);return[t,n?await ut(n)??{loggedIn:!1}:{loggedIn:!1}]}));i(Object.fromEntries(n))}catch{}},[e,r,i]),fetchProviderQuotas:(0,_.useCallback)(async(e=!1)=>{o(e)},[o])}}function mo({providerId:e,providerLabel:t,onCancel:n,onContinue:r}){let i=K(),a=(0,_.useId)(),o=(0,_.useId)(),s=(0,_.useRef)(null),c=(0,_.useRef)(!1),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(!1),p=to(e);(0,_.useEffect)(()=>{let e=s.current;e&&!e.open&&e.showModal()},[]);let m=(0,_.useCallback)(e=>{e.preventDefault(),n()},[n]);if(!p)return null;let h=e.trim().toLowerCase(),g=h===`anthropic`?`oauthTos.anthropicBody`:no(p),v=h===`anthropic`||h===`google-antigravity`;return(0,z.jsxs)(`dialog`,{ref:s,"aria-labelledby":a,"aria-describedby":o,className:`modal-overlay`,onCancel:m,children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":i(`common.close`),tabIndex:-1,onClick:n}),(0,z.jsxs)(`div`,{className:`modal-card`,onClick:e=>e.stopPropagation(),style:{maxWidth:460},children:[(0,z.jsx)(`h3`,{id:a,children:i(Z(p),{provider:t})}),(0,z.jsxs)(`div`,{id:o,className:`notice-warn`,style:{marginTop:12,display:`flex`,gap:8,alignItems:`flex-start`},children:[(0,z.jsx)(de,{width:16,height:16,style:{flexShrink:0,marginTop:2},"aria-hidden":`true`}),(0,z.jsx)(`p`,{className:`modal-desc`,style:{margin:0},children:i(g,{provider:t})})]}),v&&(0,z.jsx)(`p`,{className:`muted text-label`,style:{marginTop:12},children:i(`oauthTos.saferPath`)}),(0,z.jsxs)(`label`,{className:`oauth-tos-ack`,style:{display:`flex`,gap:8,alignItems:`flex-start`,marginTop:14},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked),style:{marginTop:3},"aria-required":`true`}),(0,z.jsx)(`span`,{className:`text-label`,children:i(`oauthTos.acknowledge`)})]}),(0,z.jsxs)(`div`,{className:`modal-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:n,children:i(`common.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:!l||d,onClick:()=>{!l||c.current||(c.current=!0,f(!0),r())},children:i(`oauthTos.continue`)})]})]})]})}function ho(e){return{adapter:e.adapter,baseUrl:e.baseUrl,authMode:e.auth,freeTier:!!e.freeTier,keyOptional:!!e.keyOptional}}function go(e){return Wn(e.id,ho(e))}function _o(e){let t={accounts:[],free:[],paid:[]};for(let n of e)t[go(n)].push(n);return t}function vo(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.label.toLowerCase().includes(n)||e.id.toLowerCase().includes(n)):e}var yo={},bo=[],xo={};function So({presets:e,usageRank:t=yo,presetsLoading:n=!1,initialTier:r=`free`,onSelectPreset:i,onSelectCustom:a,accountRows:o=bo,accountStatus:s=xo,busyProvider:c=null,onLogin:l,onCancelLogin:u,onLogout:d}){let f=K(),[p,m]=(0,_.useState)(r),[h,g]=(0,_.useState)(``),v=(0,_.useMemo)(()=>e.filter(e=>e.id!==`custom`),[e]),y=(0,_.useMemo)(()=>{let e=Object.keys(t).length>0;return v.toSorted((n,r)=>{if(e){let e=t[n.id]??0,i=t[r.id]??0;if(i!==e)return i-e}return n.label.localeCompare(r.label,void 0,{sensitivity:`base`})||n.id.localeCompare(r.id)})},[v,t]),b=(0,_.useMemo)(()=>_o(y),[y])[p],x=(0,_.useMemo)(()=>vo(b,h),[b,h]),S=e=>{let t=e.codexAccountMode===`direct`?(0,z.jsx)(`span`,{className:`badge badge-green`,children:f(`modal.badge.direct`)}):e.codexAccountMode===`pool`?(0,z.jsx)(`span`,{className:`badge badge-accent`,children:f(`modal.badge.pool`)}):e.auth===`oauth`?(0,z.jsx)(`span`,{className:`badge badge-accent`,children:f(`modal.badge.oauth`)}):e.auth===`forward`?(0,z.jsx)(`span`,{className:`badge badge-green`,children:f(`modal.badge.codexLogin`)}):e.auth===`local`?(0,z.jsx)(`span`,{className:`badge badge-amber`,children:f(`modal.badge.local`)}):e.keyOptional?null:(0,z.jsx)(`span`,{className:`badge badge-muted`,children:f(`modal.badge.apiKey`)});return(0,z.jsxs)(z.Fragment,{children:[(e.freeTier||e.keyOptional)&&e.auth===`key`?(0,z.jsx)(`span`,{className:`badge badge-green`,children:f(`modal.badge.free`)}):null,t]})};return(0,z.jsxs)(`div`,{className:`provider-catalog`,children:[(0,z.jsx)(`div`,{className:`provider-catalog-tabs`,role:`tablist`,children:[`accounts`,`free`,`paid`].map(e=>(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":p===e,className:`provider-catalog-tab${p===e?` active`:``}`,onClick:()=>{m(e),g(``)},children:f(e===`accounts`?`modal.tab.accounts`:e===`free`?`modal.tab.free`:`modal.tab.paid`)},e))}),p===`accounts`&&(0,z.jsx)(`div`,{className:`provider-catalog-accounts-hint muted text-label`,children:f(`modal.accountsHint`)}),(0,z.jsx)(`input`,{className:`input provider-catalog-search`,value:h,onChange:e=>g(e.target.value),placeholder:f(`modal.search`)}),(0,z.jsxs)(`div`,{className:`provider-catalog-rows`,children:[n&&x.length===0&&(0,z.jsx)(`div`,{className:`muted text-control provider-catalog-empty`,children:f(`modal.catalogLoading`)}),p!==`accounts`&&x.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`list-row`,onClick:()=>i(e),children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`title`,children:e.label}),(0,z.jsxs)(`div`,{className:`sub`,children:[(0,z.jsx)(`code`,{className:`chip`,children:e.adapter}),e.note?` · ${e.note}`:``]})]}),(0,z.jsx)(`div`,{className:`provider-catalog-badges`,children:S(e)})]},e.id)),p!==`accounts`&&!n&&x.length===0&&(0,z.jsx)(`div`,{className:`muted text-control provider-catalog-empty`,children:f(`modal.noMatch`)}),p===`accounts`&&o.map(e=>{let t=s[e.id],n=c===e.id,r=!!t?.loggedIn,i=r?t?.email??e.statusLabel??f(`modal.accountLoggedIn`):t?.error??e.statusLabel??f(`modal.accountLoggedOut`);return(0,z.jsxs)(`div`,{className:`list-row provider-catalog-account-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`title`,children:e.label}),(0,z.jsx)(`div`,{className:`sub`,children:i})]}),(0,z.jsx)(`div`,{className:`provider-catalog-badges`,children:e.kind===`key`?null:e.kind===`codex`?(0,z.jsxs)(z.Fragment,{children:[r&&(0,z.jsx)(`a`,{className:`btn btn-ghost`,href:e.href??`#codex-auth`,children:f(`modal.accountManage`)}),l&&(0,z.jsx)(`button`,{type:`button`,className:r?`btn btn-ghost`:`btn btn-primary`,disabled:n,onClick:()=>{n||l(e.id)},children:f(n?`codexAuth.enablingOpenai`:r?`modal.accountAdd`:`modal.accountLogin`)})]}):r?d&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>d(e.id),children:f(`modal.accountLogout`)}):n?u&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>u(e.id),children:f(`common.cancel`)}):l&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>l(e.id),children:f(`modal.accountLogin`)})})]},e.id)}),p===`accounts`&&o.length===0&&!n&&(0,z.jsx)(`div`,{className:`muted text-control provider-catalog-empty`,children:f(`modal.noMatch`)})]}),(0,z.jsxs)(`div`,{className:`provider-catalog-footer`,children:[(0,z.jsx)(`div`,{style:{flex:1}}),p!==`accounts`&&(0,z.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:a,children:f(`modal.notListed`)})]})]})}function Co({preset:e,oauthSupported:t,oauthBusy:n,oauthMsg:r,oauthMsgTone:i,oauthUrl:a,manualCode:o,manualCodeBusy:s,manualCodeMsg:c,manualCodeOk:l,onRequestLogin:u,onUseApiKeyInstead:d,onManualCodeChange:f,onSubmitManualCode:p,onBack:m}){let h=K();return(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:14},children:[(0,z.jsx)(`div`,{className:`muted text-control`,children:e.note??h(`modal.oauthDefaultNote`)}),t.includes(e.oauthProvider??``)?(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>u(e.oauthProvider),disabled:n,style:{width:`100%`,padding:`12px 16px`},children:[(0,z.jsx)(Se,{}),n?h(`modal.waitingBrowser`):h(`modal.logInWith`,{label:e.label})]}):(0,z.jsx)(`div`,{className:`text-control`,style:{color:`var(--amber)`,background:`var(--amber-soft)`,border:`1px solid var(--amber)`,borderRadius:`var(--radius-sm)`,padding:`10px 12px`},children:h(`modal.oauthComingSoon`,{label:e.label})}),r&&(0,z.jsx)(`div`,{className:`text-label`,style:{color:i===`warn`?`var(--amber)`:`var(--accent-hover)`},children:r}),n&&(0,z.jsx)(Si,{url:a}),n&&(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:[(0,z.jsx)(`div`,{className:`muted text-label`,children:h(`prov.pasteRedirectHint`)}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,z.jsx)(`input`,{type:`text`,autoComplete:`off`,spellCheck:!1,value:o,onChange:e=>f(e.target.value),onKeyDown:t=>{t.key===`Enter`&&e.oauthProvider&&(t.preventDefault(),p(e.oauthProvider))},placeholder:h(`prov.pasteRedirect`),"aria-label":h(`prov.pasteRedirect`),disabled:s,className:`input text-label`,style:{flex:1}}),(0,z.jsx)(`button`,{className:`btn btn-ghost`,type:`button`,disabled:s||!o.trim()||!e.oauthProvider,onClick:()=>e.oauthProvider&&p(e.oauthProvider),children:h(s?`prov.pasteSubmitting`:`prov.pasteSubmit`)})]}),c&&(0,z.jsx)(`div`,{className:`text-label`,style:{color:l?`var(--accent-hover)`:`var(--amber)`},children:c})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`,marginTop:2},children:[(0,z.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:d,children:h(`modal.useApiKeyInstead`)}),(0,z.jsx)(`div`,{style:{flex:1}}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:m,children:h(`modal.back`)})]})]})}function wo({label:e,children:t}){return(0,z.jsxs)(`label`,{style:{display:`block`},children:[(0,z.jsx)(`span`,{className:`field-label`,children:e}),t]})}function To({preset:e,form:t,endpointChoice:n,error:r,saving:i,dup:a,isCustom:o,isLocal:s,isReservedForward:c,presetDescription:l,onFormChange:u,onEndpointChoiceChange:d,onSubmit:f,onUseOauthLogin:p,onBack:m}){let h=K();return(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[!c&&!o&&!s&&!e.keyOptional&&e.note&&(0,z.jsxs)(`details`,{className:`setup-guide`,children:[(0,z.jsx)(`summary`,{children:h(`modal.setupGuide`)}),(0,z.jsxs)(`ol`,{className:`text-label leading-relaxed`,style:{margin:`8px 0 0`,paddingLeft:18,color:`var(--muted)`},children:[(0,z.jsxs)(`li`,{children:[h(`modal.setupStep1Prefix`),` `,(0,z.jsx)(`a`,{href:e.dashboardUrl,target:`_blank`,rel:`noreferrer`,children:h(`modal.setupDashboardLink`,{label:e.label})}),` `,h(`modal.setupStep1Suffix`)]}),(0,z.jsx)(`li`,{children:h(`modal.setupStep2`)}),(0,z.jsx)(`li`,{children:h(`modal.setupStep3`)})]}),e.note&&(0,z.jsx)(`div`,{className:`text-label`,style:{color:`var(--muted)`,marginTop:6,fontStyle:`italic`},children:e.note}),/\{[^}]*\}/.test(t.baseUrl)&&(0,z.jsx)(`div`,{className:`text-label`,style:{color:`var(--amber)`,marginTop:6},children:h(`modal.baseUrlPlaceholderHint`)})]}),(0,z.jsx)(wo,{label:h(`modal.providerName`),children:(0,z.jsx)(`input`,{className:`input`,value:t.name,readOnly:c,onChange:e=>u({...t,name:e.target.value}),placeholder:h(`modal.namePlaceholder`)})}),a&&(0,z.jsx)(`div`,{className:`text-label`,style:{color:`var(--amber)`},children:h(`modal.duplicateWarn`,{name:t.name.trim()})}),!c&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(wo,{label:h(`modal.adapter`),children:(0,z.jsx)(`select`,{className:`input`,value:t.adapter,onChange:e=>u({...t,adapter:e.target.value}),children:[`openai-responses`,`openai-chat`,`anthropic`,`google`,`azure-openai`,`cursor`].map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})}),e.baseUrlChoices&&e.baseUrlChoices.length>0?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(wo,{label:h(`modal.endpoint`),children:(0,z.jsx)(`select`,{className:`input`,value:n,onChange:n=>{let r=n.target.value;d(r),u({...t,baseUrl:Na(e.baseUrlChoices,r,t.baseUrl)})},children:e.baseUrlChoices.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.id===`token-plan`?h(`modal.endpoint.tokenPlan`):e.id===`payg`?h(`modal.endpoint.payAsYouGo`):e.id===`custom`?h(`modal.endpoint.custom`):e.label},e.id))})}),n===`custom`&&(0,z.jsx)(wo,{label:h(`modal.baseUrl`),children:(0,z.jsx)(`input`,{className:`input`,value:t.baseUrl,onChange:e=>u({...t,baseUrl:e.target.value}),placeholder:h(`modal.baseUrlPlaceholder`)})})]}):(0,z.jsx)(wo,{label:h(`modal.baseUrl`),children:(0,z.jsx)(`input`,{className:`input`,value:t.baseUrl,onChange:e=>u({...t,baseUrl:e.target.value}),placeholder:h(`modal.baseUrlPlaceholder`)})}),!c&&(0,z.jsxs)(`label`,{className:`modal-field`,style:{flexDirection:`row`,alignItems:`center`,gap:8},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:t?.allowPrivateNetwork??!1,onChange:e=>u({...t,allowPrivateNetwork:e.target.checked})}),(0,z.jsx)(`span`,{className:`muted text-control`,children:h(`modal.allowPrivateNetwork`)})]}),!c&&(t?.allowPrivateNetwork??!1)&&(0,z.jsx)(`p`,{className:`muted text-hint`,children:h(`modal.allowPrivateNetworkHint`)})]}),t.authMode===`forward`?(0,z.jsx)(`div`,{className:`text-label`,style:{color:`var(--green)`,background:`var(--green-soft)`,border:`1px solid var(--green)`,borderRadius:`var(--radius-sm)`,padding:`8px 10px`},children:l(e)}):t.authMode===`local`?(0,z.jsx)(`div`,{className:`text-label leading-relaxed`,style:{color:`var(--amber)`,background:`var(--amber-soft)`,border:`1px solid var(--amber)`,borderRadius:`var(--radius-sm)`,padding:`8px 10px`},children:h(`modal.localHint`)}):e.keyOptional?(0,z.jsxs)(`div`,{className:`text-label leading-relaxed`,style:{color:`var(--green)`,background:`var(--green-soft)`,border:`1px solid var(--green)`,borderRadius:`var(--radius-sm)`,padding:`10px 12px`},children:[(0,z.jsx)(`strong`,{children:h(`modal.freeTierTitle`)}),` — `,e.note??h(`modal.freeTierDefault`)]}):(0,z.jsxs)(z.Fragment,{children:[e.dashboardUrl&&(0,z.jsxs)(`a`,{className:`text-label`,href:e.dashboardUrl,target:`_blank`,rel:`noreferrer`,style:{display:`inline-flex`,alignItems:`center`,gap:5},children:[(0,z.jsx)(xe,{style:{width:14,height:14}}),h(`modal.getApiKey`,{label:e.label}),(0,z.jsx)(be,{style:{width:13,height:13}})]}),(0,z.jsx)(wo,{label:h(`modal.apiKey`),children:(0,z.jsx)(`input`,{className:`input`,type:`password`,value:t.apiKey,onChange:e=>u({...t,apiKey:e.target.value}),placeholder:h(`modal.apiKeyPlaceholder`)})}),t.adapter===`anthropic`&&t.authMode===`key`&&(0,z.jsx)(wo,{label:h(`modal.apiKeyTransport`),children:(0,z.jsxs)(`select`,{className:`input`,value:t.apiKeyTransport??`x-api-key`,onChange:e=>u({...t,apiKeyTransport:e.target.value===`bearer`?`bearer`:void 0}),children:[(0,z.jsx)(`option`,{value:`x-api-key`,children:h(`modal.apiKeyTransportNative`)}),(0,z.jsx)(`option`,{value:`bearer`,children:h(`modal.apiKeyTransportBearer`)})]})})]}),!c&&(0,z.jsx)(wo,{label:h(`modal.defaultModel`),children:(0,z.jsx)(`input`,{className:`input`,value:t.defaultModel,onChange:e=>u({...t,defaultModel:e.target.value}),placeholder:h(`modal.defaultModelPlaceholder`)})}),r&&(0,z.jsx)(`div`,{className:`text-control`,role:`alert`,style:{color:`var(--red)`},children:r}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8,marginTop:4,alignItems:`center`},children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:f,disabled:i,children:h(i?`modal.adding`:`modal.add`)}),e.auth===`oauth`&&(0,z.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:p,children:h(`modal.useOauthLogin`)}),(0,z.jsx)(`div`,{style:{flex:1}}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:m,children:h(`modal.back`)})]})]})}var Eo=2e3;function Do({apiBase:e,t,aliveRef:n,onAdded:r}){return{loginOAuth:(0,_.useCallback)(async(i,a)=>{let{setOauthBusy:o,setOauthMsg:s,setOauthMsgTone:c,setOauthUrl:l,setManualCode:u,setManualCodeMsg:d,setManualCodeOk:f}=a;o(!0),s(``),c(`ok`),l(``,i),u(``),d(``),f(!0);try{let a=await fetch(`${e}/api/oauth/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:i})});if(!n.current)return;if(!a.ok){let e=await a.json().catch(()=>({}));c(`warn`),s(e.error===`unknown oauth provider`?t(`modal.oauthComingSoonShort`):e.error||t(`modal.loginFailStart`));return}let o=await a.json();o.url?(l(o.url,i),s(t(`modal.waitingLogin`))):s(o.instructions||t(`modal.loggingIn`));for(let a=0;a<100;a++){if(await new Promise(e=>setTimeout(e,Eo)),!n.current)return;let a=await fetch(`${e}/api/oauth/status?provider=${i}`).catch(()=>null),o=a?await ut(a):null;if(!n.current)return;if(o?.error){c(`warn`),s(t(`modal.loginError`,{error:o.error}));return}if(o?.loggedIn){r(i);return}}c(`warn`),s(t(`modal.loginTimeout`))}catch{n.current&&(c(`warn`),s(t(`modal.networkError`)))}finally{n.current&&o(!1)}},[n,e,r,t]),submitManualCode:(0,_.useCallback)(async(r,i,a,o)=>{let s=i.trim();if(!s||a)return;let{setManualCodeBusy:c,setManualCode:l,setManualCodeOk:u,setManualCodeMsg:d}=o;c(!0),d(``);try{let i=await fetch(`${e}/api/oauth/login/code`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:r,input:s})});if(!n.current)return;if(!i.ok){let e=await i.json().catch(()=>({}));u(!1),d(t(`prov.pasteFail`,{error:e.error||i.statusText}));return}l(``),u(!0),d(t(`prov.pasteOk`))}catch{n.current&&(u(!1),d(t(`modal.networkError`)))}finally{n.current&&c(!1)}},[n,e,t])}}function Oo(e,t){return{preset:e?{id:`custom`,label:t,adapter:`openai-chat`,baseUrl:``,auth:`key`}:null,form:e?{name:``,adapter:`openai-chat`,baseUrl:``,authMode:`key`,apiKey:``,apiKeyTransport:void 0,defaultModel:``,allowPrivateNetwork:!1}:null,saving:!1,error:``,oauthBusy:!1,oauthMsg:``,oauthMsgTone:`ok`,oauthUrl:``,oauthUrlProvider:null,manualCode:``,manualCodeBusy:!1,manualCodeMsg:``,manualCodeOk:!0,endpointChoice:`custom`,oauthTosPending:null}}function ko(e,t){switch(t.type){case`choose-preset`:return{...e,preset:t.preset,form:t.form,endpointChoice:t.endpointChoice,error:``,oauthMsg:``,oauthMsgTone:`ok`,oauthUrl:``,oauthUrlProvider:null,oauthBusy:!1,manualCode:``,manualCodeMsg:``,manualCodeOk:!0};case`back`:return{...e,preset:null,form:null,endpointChoice:`custom`,error:``,oauthMsg:``,oauthMsgTone:`ok`,oauthUrl:``,oauthUrlProvider:null,oauthBusy:!1,manualCode:``,manualCodeMsg:``,manualCodeOk:!0};case`set-form`:return{...e,form:t.form};case`set-endpoint-choice`:return{...e,endpointChoice:t.choice};case`set-saving`:return{...e,saving:t.saving};case`set-error`:return{...e,error:t.error};case`set-oauth-busy`:return{...e,oauthBusy:t.busy};case`set-oauth-msg`:return{...e,oauthMsg:t.msg,oauthMsgTone:t.tone??e.oauthMsgTone};case`set-oauth-tone`:return{...e,oauthMsgTone:t.tone};case`set-oauth-url`:return e.preset?.oauthProvider===t.providerId?{...e,oauthUrl:t.url,oauthUrlProvider:t.providerId}:e;case`set-manual-code`:return{...e,manualCode:t.code};case`set-manual-code-busy`:return{...e,manualCodeBusy:t.busy};case`set-manual-code-msg`:return{...e,manualCodeMsg:t.msg,manualCodeOk:t.ok??e.manualCodeOk};case`set-oauth-tos-pending`:return{...e,oauthTosPending:t.providerId};case`use-oauth-login`:return{...e,form:t.form,error:``,oauthUrl:``,oauthUrlProvider:null};case`use-api-key-instead`:return{...e,form:t.form,oauthMsg:``,oauthMsgTone:`ok`,oauthUrl:``,oauthUrlProvider:null,oauthBusy:!1,manualCode:``,manualCodeMsg:``};default:return e}}function Ao({apiBase:e,existingNames:t,onClose:n,onAdded:r,initialTier:i,initialCustom:a=!1,accountRows:o,accountStatus:s,accountBusy:c,onAccountLogin:l,onAccountCancelLogin:u,onAccountLogout:d,onOpen:f}){let p=K(),m=(0,_.useMemo)(()=>[{id:`custom`,label:p(`modal.customProvider`),adapter:`openai-chat`,baseUrl:``,auth:`key`}],[p]),[h,g]=(0,_.useReducer)(ko,a,e=>Oo(e,p(`modal.customProvider`))),v=(0,_.useRef)(!0),y=(0,_.useRef)(null),b=(0,_.useRef)(null),x=I(`add-provider-oauth:${e}`,[e],async t=>{let n=await fetch(`${e}/api/oauth/providers`,{signal:t});return n.ok?(await n.json()).providers??[]:[]}),S=I(`add-provider-presets:${e}`,[e],async t=>{let n=await fetch(`${e}/api/provider-presets`,{signal:t});if(!n.ok)throw Error(String(n.status));let r=await n.json();return Array.isArray(r.providers)&&r.providers.length>0?r.providers:null}),C=I(`add-provider-usage:${e}`,[e],async t=>{let n=await fetch(`${e}/api/usage?range=30d`,{signal:t});if(!n.ok)return{};let r=await n.json(),i={};for(let e of r.providers??[])i[e.provider]=e.requests;return i}),w=x.data??[],T=S.data??m,E=S.loading,D=C.data??{},{preset:O,form:k,saving:A,error:j,oauthBusy:M,oauthMsg:N,oauthMsgTone:P,oauthUrl:F,oauthUrlProvider:L,manualCode:R,manualCodeBusy:B,manualCodeMsg:V,manualCodeOk:H,endpointChoice:U,oauthTosPending:W}=h;(0,_.useEffect)(()=>{v.current=!0,y.current=document.activeElement,f?.();let e=b.current;if(e){let t=e.querySelector(`input:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex='-1'])`);t&&t.focus()}return()=>{v.current=!1,y.current?.focus()}},[]),(0,_.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!W&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,W]);let ee=e=>{let t=qa(e);return t?p(t):e.note},te=e=>{let t=Pa(e.baseUrlChoices,e.baseUrl);g({type:`choose-preset`,preset:e,endpointChoice:t,form:{name:e.id===`custom`?``:e.id,adapter:e.adapter,baseUrl:e.baseUrlChoices?.length?Na(e.baseUrlChoices,t,e.baseUrl):e.baseUrl,responsesPath:e.responsesPath,authMode:e.auth,apiKey:``,apiKeyTransport:void 0,defaultModel:e.defaultModel??``,allowPrivateNetwork:!1}})},ne=async()=>{if(!k)return;let t=O?Ka(O):!1,n=O?.baseUrlChoices?.length?Fa(O.baseUrlChoices,U,k.baseUrl):k.baseUrl.trim();if(!t&&!k.name.trim()){g({type:`set-error`,error:p(`modal.nameRequired`)});return}if(!t&&!n){g({type:`set-error`,error:p(`modal.baseUrlRequired`)});return}if(!t&&/\{[^}]*\}/.test(n)){g({type:`set-error`,error:p(`modal.baseUrlPlaceholderError`)});return}let i={...k,baseUrl:n},a;try{a=Ya(O??{id:`custom`},i)}catch{g({type:`set-error`,error:p(`modal.invalidPreset`)});return}g({type:`set-saving`,saving:!0}),g({type:`set-error`,error:``});try{let t=await fetch(`${e}/api/providers`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)});if(!t.ok){g({type:`set-error`,error:(await t.json().catch(()=>({}))).error||p(`modal.failedStatus`,{status:t.status})});return}r(a.name)}catch{g({type:`set-error`,error:p(`modal.networkError`)})}finally{g({type:`set-saving`,saving:!1})}},{loginOAuth:re,submitManualCode:G}=Do({apiBase:e,t:p,aliveRef:v,onAdded:r}),ie={setOauthBusy:e=>g({type:`set-oauth-busy`,busy:e}),setOauthMsg:e=>g({type:`set-oauth-msg`,msg:e}),setOauthMsgTone:e=>g({type:`set-oauth-tone`,tone:e}),setOauthUrl:(e,t)=>g({type:`set-oauth-url`,url:e,providerId:t}),setManualCode:e=>g({type:`set-manual-code`,code:e}),setManualCodeMsg:e=>g({type:`set-manual-code-msg`,msg:e}),setManualCodeOk:e=>g({type:`set-manual-code-msg`,msg:V,ok:e})},oe=k?t.includes(k.name.trim())&&k.name.trim()!==``:!1,se=e=>{if(!M){if(to(e)){g({type:`set-oauth-tos-pending`,providerId:e});return}re(e,ie)}},ce=e=>{G(e,R,B,{setManualCodeBusy:e=>g({type:`set-manual-code-busy`,busy:e}),setManualCode:e=>g({type:`set-manual-code`,code:e}),setManualCodeOk:e=>g({type:`set-manual-code-msg`,msg:V,ok:e}),setManualCodeMsg:e=>g({type:`set-manual-code-msg`,msg:e})})},le=O?.id===`custom`,ue=k?.authMode===`local`,de=O?Ka(O):!1;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":p(`modal.add`),className:`modal-overlay`,onClick:n,children:(0,z.jsxs)(`div`,{ref:b,className:`modal-card`,onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsx)(`h3`,{children:O?p(`modal.addNamed`,{label:O.label}):p(`modal.add`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon`,"aria-label":p(`common.close`),onClick:n,children:(0,z.jsx)(ae,{})})]}),O?k&&(O.auth===`oauth`&&k.authMode===`oauth`?(0,z.jsx)(Co,{preset:O,oauthSupported:w,oauthBusy:M,oauthMsg:N,oauthMsgTone:P,oauthUrl:L===O.oauthProvider?F:``,manualCode:R,manualCodeBusy:B,manualCodeMsg:V,manualCodeOk:H,onRequestLogin:se,onUseApiKeyInstead:()=>{g({type:`use-api-key-instead`,form:{...k,authMode:`key`}})},onManualCodeChange:e=>g({type:`set-manual-code`,code:e}),onSubmitManualCode:e=>{ce(e)},onBack:()=>g({type:`back`})}):(0,z.jsx)(To,{preset:O,form:k,endpointChoice:U,error:j,saving:A,dup:oe,isCustom:le,isLocal:ue,isReservedForward:de,presetDescription:ee,onFormChange:e=>g({type:`set-form`,form:e}),onEndpointChoiceChange:e=>g({type:`set-endpoint-choice`,choice:e}),onSubmit:()=>{ne()},onUseOauthLogin:()=>g({type:`use-oauth-login`,form:{...k,authMode:`oauth`}}),onBack:()=>g({type:`back`})})):(0,z.jsx)(So,{presets:T,usageRank:D,presetsLoading:E,initialTier:i,onSelectPreset:e=>te(e),onSelectCustom:()=>te(m[0]),accountRows:o,accountStatus:s,busyProvider:c,onLogin:l,onCancelLogin:u,onLogout:d})]})}),W&&(0,z.jsx)(mo,{providerId:W,providerLabel:O?.label??W,onCancel:()=>g({type:`set-oauth-tos-pending`,providerId:null}),onContinue:()=>{let e=W;e&&(g({type:`set-oauth-tos-pending`,providerId:null}),re(e,ie))}},W)]})}function jo({apiBase:e,config:t,adding:n,addIntent:r,busy:i,addModalAccountRows:a,accountLoginStatus:o,removeConfirmName:s,removeDefaultProvider:c,codexLoginOpen:l,jsonLeaveOpen:u,jsonSaving:d,oauthTosPending:f,onCloseAdd:p,onAdded:m,onAccountLogin:h,onAccountCancelLogin:g,onAccountLogout:_,onOpenAdd:v,onCloseCodexLogin:y,onCodexAdded:b,onCancelRemove:x,onConfirmRemove:S,onCancelJsonLeave:C,onDiscardJson:w,onSaveJson:T,onCancelOauthTos:E,onContinueOauthTos:D}){return(0,z.jsxs)(z.Fragment,{children:[n&&(0,z.jsx)(Ao,{apiBase:e,existingNames:Object.keys(t.providers),initialTier:r?.tier,initialCustom:r?.custom,onClose:p,onAdded:m,accountRows:a,accountStatus:o,accountBusy:i,onAccountLogin:h,onAccountCancelLogin:g,onAccountLogout:_,onOpen:v}),l&&(0,z.jsx)(Ti,{apiBase:e,onClose:y,onAdded:b}),s&&(0,z.jsx)(za,{providerName:s,defaultProviderName:c,onCancel:x,onConfirm:S}),u&&C&&w&&T&&(0,z.jsx)(Ba,{saving:d??!1,onCancel:C,onDiscard:w,onSave:T}),f&&(0,z.jsx)(mo,{providerId:f.provider,providerLabel:so(f.provider),onCancel:E,onContinue:D},`${f.provider}:${f.addAccount?`add`:`login`}`)]})}function Mo(e,t,n){return[...Wa(e.providers).map(e=>({id:e,label:vr(e,n),kind:`codex`,href:`#codex-auth`})),...t.toSorted((e,t)=>e.localeCompare(t)).map(e=>({id:e,label:so(e),kind:`oauth`}))]}function No(e,t){let n={...t},r=t.openai;if(r)for(let[t,i]of Object.entries(e.providers))i.authMode===`forward`&&(n[t]=r);return n}function Po({apiBase:e}){let t=K(),n=`ocx.providers.config.v1:${e}`,[r,i]=(0,_.useState)(()=>Y(n)),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)([]),[p,m]=(0,_.useState)({}),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(null),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(0),[A,j]=(0,_.useState)(null),M=(0,_.useRef)(!0),N=(0,_.useRef)(null),P=(0,_.useRef)(!1),F=(0,_.useRef)(new Map),L=(0,_.useCallback)((e,t=!0)=>{c(e),u(t)},[]);(0,_.useEffect)(()=>(M.current=!0,()=>{M.current=!1}),[]),I(`add-provider-presets:${e}`,[e],async t=>{let n=await fetch(`${e}/api/provider-presets`,{signal:t});if(!n.ok)throw Error(String(n.status));let r=await n.json();return Array.isArray(r.providers)&&r.providers.length>0?r.providers:null}),I(`add-provider-usage:${e}`,[e],async t=>{let n=await fetch(`${e}/api/usage?range=30d`,{signal:t});if(!n.ok)return{};let r=await n.json(),i={};for(let e of r.providers??[])i[e.provider]=e.requests;return i});let[R,B]=(0,_.useState)({epoch:0,force:!1}),{fetchConfig:V,fetchOauth:H,fetchProviderQuotas:U}=po({apiBase:e,t,setConfig:i,setOauthProviders:f,setOauthStatus:m,notify:L,invalidateProviderQuotas:(0,_.useCallback)((e=!1)=>{B(t=>({epoch:t.epoch+1,force:e}))},[]),configCacheKey:n}),W=Ii(e),ee=W.activeNeedsReauth,te=(0,_.useMemo)(()=>{let e=W.accounts;if(e.length===0&&W.loadState===`loading`)return p;let t=e.find(e=>e.isMain)??e[0],n=!!t&&!!t.email&&t.email!==`Codex App login`,r=e.some(e=>!e.isMain&&(e.hasCredential||e.email)),i=n||r,a=n?t?.email:e.find(e=>!e.isMain&&e.email)?.email??void 0;return{...p,openai:{loggedIn:i,...a?{email:a}:{},...ee?{needsReauth:!0}:{}}}},[p,W.accounts,W.loadState,ee]),{accountSets:ne,accountLoadStates:re,switchingAccount:G,keyPools:ie,fetchAccountSets:ae,switchAccount:se,switchApiKey:ce,removeApiKey:le,addApiKeyValue:ue,editCredentialAlias:de,removeAccount:fe,activeAccountNeedsReauth:pe}=io({apiBase:e,t,config:r,oauthStatus:te,aliveRef:M,notify:L,fetchConfig:V,fetchOauth:H,fetchProviderQuotas:U,codexActiveNeedsReauth:ee}),{draft:me,setDraft:he,jsonEditorOpen:ge,jsonSaving:_e,jsonLeaveOpen:ve,saveConfig:ye,openJsonEditor:be,discardJsonEditor:xe,requestCloseJsonEditor:Se,restoreJsonEditor:Ce,jsonIsDirty:we,setJsonLeaveOpen:Te}=ao({apiBase:e,config:r,notify:L,fetchConfig:V,fetchProviderQuotas:U,onSaved:()=>k(e=>e+1),t});(0,_.useEffect)(()=>{N.current!==e&&(N.current=e,Promise.resolve().then(()=>{V(),H()}))},[e,V,H]);let Ee=()=>k(e=>e+1),{cancelLoginOAuth:De,loginOAuth:Oe,logoutOAuth:ke}=co({apiBase:e,t,aliveRef:M,oauthLoginGenerationRef:F,accountSets:ne,setBusy:g,setStatus:c,setLoginInfo:y,setOauthStatus:m,notify:L,fetchConfig:V,fetchOauth:H,fetchAccountSets:ae,fetchProviderQuotas:U,bumpModelsRefresh:Ee}),{removeProvider:Ae,confirmRemoveProvider:je,setProviderDisabled:Me,setDefaultProvider:Ne,updateProvider:Pe}=fo({apiBase:e,t,removeBusyRef:P,workspaceSelected:b,setWorkspaceSelected:x,setRemoveConfirmName:T,notify:L,fetchConfig:V,fetchOauth:H,fetchProviderQuotas:U}),Fe=(e,t=!1)=>{if(h!==e){if(to(e)){j({provider:e,addAccount:t});return}Oe(e,t)}};if(!r)return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:t(`nav.providers`)})}),s?(0,z.jsx)(q,{tone:`err`,children:s}):(0,z.jsxs)(`div`,{className:`providers-workspace providers-workspace--boot`,"aria-busy":`true`,children:[(0,z.jsx)(`div`,{className:`providers-workspace-rail providers-workspace-rail--boot`,"aria-hidden":`true`}),(0,z.jsx)(`div`,{className:`providers-workspace-main`,children:(0,z.jsxs)(`p`,{className:`muted`,children:[(0,z.jsx)(`span`,{className:`spin`,"aria-hidden":`true`}),` `,t(`prov.loadingConfig`)]})})]})]});let Ie=Mo(r,d,t),Le=No(r,te),Re=e=>r.providers[e]?.authMode===`forward`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`page-head`,children:[(0,z.jsx)(`h2`,{children:t(`nav.providers`)}),(0,z.jsx)(`div`,{className:`row`,children:(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>o(!0),children:[(0,z.jsx)(oe,{}),t(`prov.add`)]})})]}),s&&(0,z.jsx)(q,{tone:l?`ok`:`err`,children:s}),(0,z.jsx)(Yr,{onRemoveProvider:Ae,providers:r.providers,apiBase:e,defaultProvider:r.defaultProvider,selectedName:b,onSelect:x,onAddProvider:e=>{C(e??null),o(!0)},onEditConfig:be,jsonEditor:{open:ge,draft:me,isDirty:we,onDraftChange:he,onSave:()=>ye(),onClose:Se,onRestore:Ce},jsonSaving:_e,modelsRefreshToken:O,activeAccountNeedsReauth:pe,quotaRefreshEpoch:R.epoch,quotaForceRefresh:R.force,detail:(t,n)=>{let i=Le[t.name]??p[t.name];return(0,z.jsx)(Va,{item:t,usageTotals:n.usageTotals,modelUsage:n.modelUsage,quotaReport:n.quotaReport,availableModels:n.availableModels,hasLiveModels:n.hasLiveModels,selectedModels:n.selectedModels,modelsLoading:n.modelsLoading,modelsLoadFailed:n.modelsLoadFailed,onRetryModels:n.onRetryModels,oauthEmail:i?.email,onDeselect:()=>x(null),apiBase:e,oauth:i,accounts:ne[t.name]?.accounts??[],keys:ie[t.name]??[],accountLoadState:re[t.name]??(t.authMode===`oauth`?`idle`:`ready`),switchingAccountId:G?.provider===t.name?G.accountId:null,busyProvider:h,loginHint:v,authHandlers:{onLogin:Fe,onCancelLogin:De,onLogout:ke,onReauth:(e,t)=>Oe(e,!0,t),onSwitchAccount:se,onRemoveAccount:fe,onRetryAccounts:async e=>{await ae([e])},onAddApiKey:ue,onSwitchApiKey:ce,onRemoveApiKey:le,onEditAlias:de},isDefault:t.name===r.defaultProvider,onRemoveProvider:Ae,onSetDisabled:Me,onSetDefault:e=>{Ne(e)},onUpdateProvider:Pe,codexController:W},t.name)}}),(0,z.jsx)(jo,{apiBase:e,config:r,adding:a,addIntent:S,busy:h,addModalAccountRows:Ie,accountLoginStatus:Le,removeConfirmName:w,removeDefaultProvider:w===r.defaultProvider?Object.entries(r.providers).find(([e,t])=>e!==w&&t.disabled!==!0)?.[0]??null:null,codexLoginOpen:E,jsonLeaveOpen:ve,jsonSaving:_e,oauthTosPending:A,onCloseAdd:()=>{h&&De(h),o(!1),C(null)},onAdded:e=>{o(!1),C(null),L(t(`prov.added`,{name:e,cmd:`ocx sync`}),!0),V(),H(),U(!0),Ee()},onAccountLogin:async n=>{if(n===`openai`){if(h===`openai`)return;let n=r.providers.openai,i=Ga(n);if(i===`invalid`){L(t(`codexAuth.openaiMissing`),!1);return}if(i===`absent`||i===`disabled`){g(`openai`);try{await Qa(e,i),await V()}catch(e){e instanceof Za?L(t(e.i18nKey),!1):L(e instanceof Error?e.message:t(`prov.saveFailed`),!1);return}finally{M.current&&g(e=>e===`openai`?null:e)}}D(!0);return}if(Re(n)){D(!0);return}(r.providers[n]?.authMode===`oauth`||d.includes(n))&&Fe(n)},onAccountCancelLogin:e=>{De(e)},onAccountLogout:e=>{ke(e)},onOpenAdd:H,onCloseCodexLogin:()=>D(!1),onCodexAdded:()=>{D(!1),L(t(`prov.loginOk`,{provider:vr(`openai`,t),cmd:`ocx sync`}),!0),V(),H(),U(!0),Ee()},onCancelRemove:()=>T(null),onConfirmRemove:()=>{je(w)},onCancelJsonLeave:()=>{_e||Te(!1)},onDiscardJson:xe,onSaveJson:()=>{ye()},onCancelOauthTos:()=>j(null),onContinueOauthTos:()=>{let e=A;e&&(j(null),Oe(e.provider,e.addAccount))}})]})}var Fo={"gpt-5.6-sol":Te,"gpt-5.6-terra":Oe,"gpt-5.6-luna":Ee},Io={width:14,height:14,flexShrink:0,verticalAlign:`text-bottom`};function Lo(e){return e.slice(e.lastIndexOf(`/`)+1)}function Ro(e){return Fo[e]??Fo[Lo(e)]??null}function zo(e){let t=Ro(e);return t?(0,_.createElement)(`span`,{className:`model-label`},(0,_.createElement)(t,{style:Io,"aria-hidden":!0}),e):e}var Bo=[`low`,`medium`,`high`,`xhigh`,`max`,`ultra`];function Vo(e,t){let n=e.filter(e=>e.provider.trim()&&e.model.trim());if(n.length===0)return[...Bo];let r=new Set(Bo),i=null;for(let e of n){let n=`${e.provider.trim()}/${e.model.trim()}`,a=t.get(n),o=a===void 0?[]:a.filter(e=>r.has(e));if(i===null)i=o;else{let e=new Set(o);i=i.filter(t=>e.has(t))}}let a=new Set(i??[]);return Bo.filter(e=>a.has(e))}var Ho=0;function Uo(e={}){return{provider:e.provider??``,model:e.model??``,...e.weight===void 0?{}:{weight:e.weight},clientKey:e.clientKey??`ct-${++Ho}`}}var Wo=/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$/,Go=/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}(\/[a-zA-Z0-9][a-zA-Z0-9._-]{0,63})?$/,Ko=/^(?:gpt-|o1-|o3-|o4-|codex-)/;function qo(e){return Wo.test(e.trim())}function Jo(e){return`combo/${e.trim()}`}function Yo(e,t){return(typeof t==`string`?t.trim():``)||Jo(e)}function Xo(e){return typeof e==`string`&&e.trim()?e.trim():null}function Zo(e){return e===`round-robin`?`round-robin`:`failover`}function Qo(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=100?e:1}function $o(e){return typeof e==`string`&&Bo.includes(e)?e:null}function es(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=1e4?e:void 0}function ts(e){if(!e||typeof e!=`object`)return[];let t=e.combos;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e,r=typeof t.id==`string`?t.id.trim():``;if(!r)continue;let i=Array.isArray(t.targets)?t.targets:[],a=[];for(let e of i){if(!e||typeof e!=`object`)continue;let t=e,n=typeof t.provider==`string`?t.provider.trim():``,r=typeof t.model==`string`?t.model.trim():``;if(!n||!r)continue;let i=es(t.weight);a.push(Uo(i===void 0?{provider:n,model:r}:{provider:n,model:r,weight:i}))}n.push({id:r,model:typeof t.model==`string`&&t.model.trim()?t.model.trim():Yo(r,Xo(t.alias)),alias:Xo(t.alias),strategy:Zo(t.strategy),stickyLimit:Qo(t.stickyLimit),defaultEffort:$o(t.defaultEffort),targets:a})}return n.sort((e,t)=>e.id.localeCompare(t.id,void 0,{sensitivity:`base`}))}function ns(e){let t=[],n=[];for(let r of e)r.strategy===`round-robin`?n.push(r):t.push(r);return{failover:t,roundRobin:n}}function rs(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.id.toLowerCase().includes(n)||e.model.toLowerCase().includes(n)?!0:e.targets.some(e=>e.provider.toLowerCase().includes(n)||e.model.toLowerCase().includes(n))):e}function is(e,t={}){let n=[],r=t.cataloguedComboIds;for(let t of e)t.targets.length===0?n.push({id:t.id,model:t.model,reason:`empty-targets`}):t.targets.length<2&&n.push({id:t.id,model:t.model,reason:`few-targets`}),r&&t.targets.length>0&&!r.has(t.id)&&n.push({id:t.id,model:t.model,reason:`catalog-omitted`});return n}function as(e,t){return e.id!==t.id||e.alias!==t.alias||e.strategy!==t.strategy||e.stickyLimit!==t.stickyLimit||e.defaultEffort!==t.defaultEffort||e.targets.length!==t.targets.length?!1:e.targets.every((e,n)=>{let r=t.targets[n];return e.provider===r.provider&&e.model===r.model&&(e.weight??1)===(r.weight??1)})}function os(e,t={}){return{id:e.id.trim(),...t.renameFrom?{renameFrom:t.renameFrom}:{},combo:{targets:e.targets.map(t=>e.strategy===`round-robin`?{provider:t.provider.trim(),model:t.model.trim(),weight:t.weight??1}:{provider:t.provider.trim(),model:t.model.trim()}),strategy:e.strategy,defaultEffort:e.defaultEffort,...e.strategy===`round-robin`?{stickyLimit:e.stickyLimit}:{},...e.alias&&e.alias.trim()?{alias:e.alias.trim()}:{}}}}function ss(e,t){let n=e.id.trim();if(!n)return`missingId`;if(!qo(n))return`invalidId`;if(t.existingIds.includes(n))return`duplicateId`;if(Object.hasOwn(t.providers,`combo`))return`reservedNamespace`;if(Object.hasOwn(t.providers,n))return`providerCollision`;let r=e.alias?.trim()??``;if(r){if(!Go.test(r))return`invalidAlias`;if(r===`combo`||r.startsWith(`combo/`))return`aliasReservedNamespace`;if(!r.includes(`/`)&&Ko.test(r))return`aliasNativeFamily`;if((t.existingAliases??[]).includes(r))return`duplicateAlias`}if(e.targets.length<1)return`noTargets`;for(let n of e.targets){if(!n.provider.trim()||!n.model.trim())return`incompleteTarget`;if(!Object.hasOwn(t.providers,n.provider.trim()))return`unknownProvider`}let i=new Set;for(let t of e.targets){let e=`${t.provider.trim()}/${t.model.trim()}`;if(i.has(e))return`duplicateTarget`;i.add(e)}if(e.strategy===`round-robin`){if(!Number.isInteger(e.stickyLimit)||e.stickyLimit<1||e.stickyLimit>100)return`invalidStickyLimit`;for(let t of e.targets){let e=t.weight??1;if(!Number.isInteger(e)||e<1||e>1e4)return`invalidWeight`}}return e.targets.some(e=>t.providers[e.provider.trim()]?.disabled!==!0)?null:`noEnabledTarget`}function cs(e=``){return{id:e,model:e?Jo(e):`combo/`,alias:null,strategy:`failover`,stickyLimit:1,defaultEffort:null,targets:[Uo()]}}function ls(e,t,n){if(!n)return{kind:`disabled`,data:void 0,error:void 0,showSkeleton:!1,refreshing:!1,showError:!1};let r=e.data!==void 0,i=!e.lastAttemptOk&&e.error!==void 0;return e.refreshing?r?{kind:`loading-with-stale-data`,data:e.data,error:e.error,showSkeleton:!1,refreshing:!0,showError:i}:{kind:i?`retrying-cold`:`cold`,data:void 0,error:i?e.error:void 0,showSkeleton:!0,refreshing:!0,showError:!1}:i?r?{kind:`failed-with-stale`,data:e.data,error:e.error,showSkeleton:!1,refreshing:!1,showError:!0}:{kind:`failed-cold`,data:void 0,error:e.error,showSkeleton:!1,refreshing:!1,showError:!0}:r?{kind:t(e.data)?`ready-empty`:`ready-populated`,data:e.data,error:void 0,showSkeleton:!1,refreshing:!1,showError:!1}:{kind:`cold`,data:void 0,error:void 0,showSkeleton:!0,refreshing:!1,showError:!1}}function us(e,t,n,r){let{isEmpty:i,...a}=r,o=I(e,t,n,a);return{...o,state:ls(o,i,r.enabled!==!1)}}function ds({className:e,style:t}){return(0,z.jsx)(`span`,{"aria-hidden":`true`,className:e?`data-surface-skeleton__block ${e}`:`data-surface-skeleton__block`,style:t})}function fs({label:e,rows:t=3,className:n}){let r=Math.max(1,Math.floor(t));return(0,z.jsxs)(`div`,{className:n?`data-surface-skeleton ${n}`:`data-surface-skeleton`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,"aria-busy":`true`,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:e}),Array.from({length:r},(e,t)=>(0,z.jsx)(`div`,{className:`data-surface-skeleton__row`,"aria-hidden":`true`,children:(0,z.jsx)(ds,{})},t))]})}function ps({children:e,busy:t=!0,live:n=!0,className:r}){return(0,z.jsxs)(`div`,{className:r?`data-surface-status ${r}`:`data-surface-status`,role:n?`status`:void 0,"aria-live":n?`polite`:void 0,"aria-atomic":n?`true`:void 0,"aria-busy":t||void 0,children:[t&&(0,z.jsx)(`span`,{className:`spin`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:e})]})}function ms(e,t){let n=new Map;for(let t of e){let e=n.get(t.provider);e?e.push(t):n.set(t.provider,[t])}let r=new Map(t.map(e=>[e.name,e]));for(let e of t){if(e.disabled===!0){n.delete(e.name);continue}e.authMode!==`forward`&&(n.has(e.name)||n.set(e.name,[]))}return[...n.entries()].map(([e,t])=>{let n=r.get(e);return{provider:e,rows:t,native:t.length>0&&t.every(e=>e.native===!0),liveModels:n?.liveModels!==!1,configuredModels:n?.models??[],discovery:n?.discovery}}).sort((e,t)=>e.native===t.native?e.provider.localeCompare(t.provider):e.native?-1:1)}function hs(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function gs(e){if(!Array.isArray(e)||e.some(e=>typeof e!=`string`))throw Error(`invalid model list`);return[...new Set(e)]}function _s(e){if(!hs(e))throw Error(`invalid selected models response`);let t=e.selected;if(!hs(t))throw Error(`invalid selected models response`);return Object.fromEntries(Object.entries(t).map(([e,t])=>[e,gs(t)]))}async function vs(e,t=fetch){let n=await t(`${e}/api/selected-models`);if(!n.ok)throw Error(`selected models HTTP ${n.status}`);return _s(await n.json())}function ys(e,t,n,r=!1){if(r)return!0;let i=e[t];return!i||i.length===0||i.includes(n)}function bs(e,t,n,r,i){return ys(e,t,n,r)&&!i}async function xs(e,t,n,r,i,a=fetch){return a(`${e}/api/model-visibility`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({scope:t,provider:n,targets:r,enabled:i})})}function Ss(e,t){return e===t}function Cs(e,t){switch(t.reason){case`http`:return e(`models.discoveryFailedHttp`,{status:t.httpStatus});case`blocked`:return e(`models.discoveryFailedBlocked`);case`invalid_response`:return e(`models.discoveryFailedInvalidResponse`);case`network`:return e(`models.discoveryFailedNetwork`);case`provider`:return e(`models.discoveryFailedProvider`);default:return e(`models.discoveryFailedGeneric`)}}var ws=Array.from({length:18},(e,t)=>1e5+t*5e4),Ts=new Set(ws),Es=`custom`,Ds=[4,8,16,32,64,128,256,500,1e3],Os=new Set(Ds),ks=`ocx-models-collapsed:v2`,As=`ocx-models-combos-open:v1`;function js(e){return!Number.isFinite(e)||e<=0?String(e):e%1e3==0?`${e/1e3}k`:e.toLocaleString()}function Ms(e){let t=new Set;for(let n of e)n.disabled&&t.add(n.namespaced);return t}function Ns(e,t,n){let r=[];for(let i of e){let e=t.has(i.id)||t.has(i.namespaced);bs(n,i.provider,i.id,i.native===!0,e)&&r.push({value:i.namespaced,label:i.namespaced})}return r}function Ps(e=localStorage){try{let t=e.getItem(ks);if(t===null)return null;let n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(e=>typeof e==`string`)):null}catch{return null}}function Fs(e,t=localStorage){try{t.setItem(ks,JSON.stringify([...e]))}catch{}}function Is(e=localStorage){try{return(e.getItem(`ocx-models-combos-open:v1`)??e.getItem(`ocx-models-combos-open`))===`1`}catch{return!1}}function Ls(e,t=localStorage){try{t.setItem(As,e?`1`:`0`)}catch{}}function Rs({liveModels:e,discovery:t,showFailureBadge:n=!0}){let r=K(),i=e&&t?.status===`failed`?t:void 0;return(0,z.jsxs)(`div`,{className:`row muted text-label leading-body`,role:`status`,style:{alignItems:`flex-start`,gap:8,padding:`6px 0`},children:[(0,z.jsx)(fe,{width:15,height:15,"aria-hidden":`true`,style:{flexShrink:0,marginTop:2}}),(0,z.jsxs)(`span`,{children:[i&&n&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`badge badge-amber`,children:r(`models.discoveryFailedBadge`)}),` `]}),i?`${Cs(r,i)} `:`${r(e?`models.emptyDiscovery`:`models.emptyDiscoveryDisabled`)} `,(0,z.jsx)(`a`,{href:`#providers`,children:r(`models.openProviderSettings`)})]})]})}function zs(e){return Array.isArray(e)?ts({combos:e}):null}function Bs({apiBase:e}){let t=K(),n=`ocx.models.catalog.v1:${e}`,r=(0,_.useMemo)(()=>Y(n),[n]),[i,a]=(0,_.useState)(()=>r?.models??[]),[o,s]=(0,_.useState)(()=>r?.providers??[]),[c,l]=(0,_.useState)(()=>new Set(r?.disabled??[])),[u,d]=(0,_.useState)(()=>r?.selectedModels??null),[f,p]=(0,_.useState)({}),[m,h]=(0,_.useState)({}),[g,v]=(0,_.useState)(()=>r?.contextCaps??{}),[y,b]=(0,_.useState)(()=>r?.contextCapValue??35e4),[x,S]=(0,_.useState)(``),[C,w]=(0,_.useState)(!1),T=Ps(),[E,D]=(0,_.useState)(()=>T??new Set),O=(0,_.useRef)(T===null),[k,A]=(0,_.useState)(``),[j,M]=(0,_.useState)(!1),[N,P]=(0,_.useState)(!1),F=(0,_.useRef)(!1),I=(0,_.useRef)(0),R=(0,_.useRef)(!1),[B,V]=(0,_.useState)(null),[H,W]=(0,_.useState)(!1),[ee,te]=(0,_.useState)(``),ne=(0,_.useRef)(!1),[re,G]=(0,_.useState)(``),[ie,ae]=(0,_.useState)(!1),[oe,se]=(0,_.useState)(!1),[ce,le]=(0,_.useState)(!1),[ue,de]=(0,_.useState)(`add`),[pe,me]=(0,_.useState)(``),[he,ge]=(0,_.useState)(``),[ve,ye]=(0,_.useState)(``),[be,xe]=(0,_.useState)(``),[Se,Ce]=(0,_.useState)(``),[we,Te]=(0,_.useState)(!1),[Ee,De]=(0,_.useState)([`text`]),[Oe,ke]=(0,_.useState)(!1),[je,Me]=(0,_.useState)(``),[Ne,Pe]=(0,_.useState)(null),Fe=(0,_.useRef)(null),[Ie,Le]=(0,_.useState)(null),[Re,ze]=(0,_.useState)(!1),Be=`ocx.models.combos.v1:${e}`,Ve=(0,_.useMemo)(()=>{let t=zs(Y(Be));return t===null?zs(Y(`ocx.combos.workspace.v1:${e}`)?.combos):t},[e,Be]),He=us(`models-combos:${e}`,[e],async t=>{let n=ts(await J(await fetch(`${e}/api/combos`,{signal:t})));return X(Be,n),n},{isEmpty:()=>!1,initialData:Ve??void 0}),Ue=He.state,We=Ue.data??Ve,Ge=Ue.showError,[Ke,qe]=(0,_.useState)(Is),[Je,Ye]=(0,_.useState)(null),Xe=()=>{let e=!Ke;Ls(e),qe(e)};(0,_.useEffect)(()=>()=>{Fe.current&&clearTimeout(Fe.current)},[]);let Ze=(0,_.useMemo)(()=>Ns(i,c,u??{}),[i,c,u]),Qe=(0,_.useCallback)(async()=>{try{let t=await ut(await fetch(`${e}/api/shadow-call-settings`));t&&Le(t)}catch{}},[e]),$e=(0,_.useCallback)(async()=>{if(!ne.current)try{let t=await fetch(`${e}/api/v2`);if(!(t.headers.get(`content-type`)??``).includes(`application/json`)){V(null);return}let n=await ut(t);if(!n||typeof n.enabled!=`boolean`){V(null);return}V({enabled:n.enabled,agentsMaxThreadsConflict:n.agentsMaxThreadsConflict===!0,maxConcurrentThreadsPerSession:typeof n.maxConcurrentThreadsPerSession==`number`?n.maxConcurrentThreadsPerSession:null,multiAgentMode:n.multiAgentMode===`v1`||n.multiAgentMode===`v2`?n.multiAgentMode:`default`})}catch{V(null)}},[e]),et=(0,_.useCallback)(async t=>{let[r,i,a,o]=await Promise.all([fetch(`${e}/api/models`),fetch(`${e}/api/provider-context-caps`),fetch(`${e}/api/providers`),vs(e)]),[s,c,l]=await Promise.all([J(r),J(i),J(a)]);if(s===void 0||c===void 0||l===void 0)throw Error(`models payload missing`);if(t.aborted)throw Error(`models request aborted`);let u=Ms(s),d=typeof c.value==`number`&&Number.isFinite(c.value)&&c.value>0?c.value:typeof c.cap==`number`&&Number.isFinite(c.cap)&&c.cap>0?c.cap:void 0,f=d===void 0?35e4:d,p={models:s,providers:l,selectedModels:o,disabled:[...u],contextCaps:c.caps??{},contextCapValue:f};return X(n,p),p},[e,n]),tt=(0,_.useCallback)(e=>{let t=ms(e.models,e.providers);Ye(e=>e!==null&&!t.some(t=>t.provider===e)?null:e),a(e.models),s(e.providers),l(new Set(e.disabled)),d(e.selectedModels),b(e.contextCapValue),v(e.contextCaps)},[]),nt=us(n,[e],async e=>{let t=await et(e);if(e.aborted)throw Error(`models request aborted`);return tt(t),t},{isEmpty:()=>!1,pollMs:1e4,initialData:r??void 0}),rt=nt.state,ct=(0,_.useCallback)(async(e=!1)=>{if(R.current&&!e)return!1;R.current=!0;let t=++I.current;try{let e=await et(new AbortController().signal);return Ss(t,I.current)?(tt(e),L(n,e),!0):!1}catch{return!1}finally{Ss(t,I.current)&&(R.current=!1)}},[tt,n,et]);(0,_.useEffect)(()=>{let e=window.setTimeout(()=>{Qe(),$e()},0),t=window.setInterval(()=>{ne.current||$e()},1e4);return()=>{window.clearTimeout(e),window.clearInterval(t)}},[Qe,$e]);let lt=(0,_.useMemo)(()=>ms(i,o),[i,o]);(0,_.useEffect)(()=>{if(!O.current||lt.length===0)return;O.current=!1;let e=new Set(lt.map(e=>e.provider));D(e),Fs(e)},[lt]);let dt=(0,_.useMemo)(()=>u?i.filter(e=>bs(u,e.provider,e.id,e.native===!0,c.has(e.namespaced))).length:0,[c,i,u]),ft=async(n,r,i,a)=>{++I.current,P(!0),F.current=!0,A(``);let o=null;try{(await xs(e,n,r,i,a)).ok||(o=`models.saveFailed`)}catch{o=`models.networkError`}finally{let e=await ct(!0);o?(M(!1),A(t(o))):e&&(M(!0),A(t(`models.applied`))),P(!1),F.current=!1}},pt=async n=>{P(!0),F.current=!0,A(``);let r=g[n]!==y;try{let i=await fetch(`${e}/api/provider-context-caps`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:n,enabled:r})});try{v((await J(i,t(`models.capSaveFailed`)))?.caps??{}),M(!0),A(t(`models.capApplied`)),await ct(!0)}catch(e){M(!1),A(e instanceof Error?e.message:t(`models.capSaveFailed`))}}catch{M(!1),A(t(`models.networkError`))}finally{P(!1),F.current=!1}},mt=e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),Fs(n),n})},ht=e=>{D(()=>{let t=e?new Set(lt.map(e=>e.provider)):new Set;return Fs(t),t})},gt=async n=>{P(!0),F.current=!0,A(``);try{let r=await fetch(`${e}/api/provider-context-caps`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});try{let e=await J(r,t(`models.capSaveFailed`));typeof e?.value==`number`&&Number.isFinite(e.value)&&e.value>0&&b(e.value),v(e?.caps??{}),M(!0),A(t(`models.capApplied`)),await ct(!0)}catch(e){M(!1),A(e instanceof Error?e.message:t(`models.capSaveFailed`))}}catch{M(!1),A(t(`models.networkError`))}finally{P(!1),F.current=!1}},_t=e=>{!Number.isFinite(e)||e<=0||gt({value:Math.floor(e)})},vt=e=>{if(e===`custom`){w(!0),S(String(y));return}w(!1);let t=Number(e);Number.isFinite(t)&&t>0&&t!==y&&_t(t)},yt=()=>{let e=Number(x.replace(/[_,\s]/g,``));if(!Number.isFinite(e)||e<=0){M(!1),A(t(`models.capSaveFailed`));return}w(!1),_t(e)},bt=(0,_.useMemo)(()=>{let e=lt.filter(e=>!e.native&&e.rows.length>0);return e.length>0&&e.every(e=>g[e.provider]===y)},[lt,g,y]),xt=()=>{gt({setAll:!bt})},St=async t=>{if(!(!Ie||Re)){ze(!0),Le({...Ie,...t});try{await fetch(`${e}/api/shadow-call-settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}finally{ze(!1)}}},Ct=async n=>{if(!(!B||ne.current)&&B.multiAgentMode!==n){W(!0),ne.current=!0,te(``),A(``);try{let r=await fetch(`${e}/api/v2`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({multiAgentMode:n})});try{let e=await J(r,t(`models.saveFailed`));$e(),M(!0),A(t(`models.v2Applied`)),te((e?.warnings??[]).join(` `))}catch(e){M(!1),A(e instanceof Error?e.message:t(`models.saveFailed`))}}catch{M(!1),A(t(`models.networkError`))}finally{W(!1),ne.current=!1}}},wt=async n=>{if(!(!B||ne.current)){if(!Number.isInteger(n)||n<1){M(!1),A(t(`models.v2ThreadsInvalid`));return}if(B.maxConcurrentThreadsPerSession!==n){W(!0),ne.current=!0,te(``),A(``);try{let r=await fetch(`${e}/api/v2`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({maxConcurrentThreadsPerSession:n})});try{let e=await J(r,t(`models.saveFailed`));if(!e||typeof e.enabled!=`boolean`){M(!1),A(t(`models.saveFailed`));return}V({enabled:e.enabled,agentsMaxThreadsConflict:e.agentsMaxThreadsConflict===!0,maxConcurrentThreadsPerSession:typeof e.maxConcurrentThreadsPerSession==`number`?e.maxConcurrentThreadsPerSession:null,multiAgentMode:e.multiAgentMode===`v1`||e.multiAgentMode===`v2`?e.multiAgentMode:`default`}),M(!0),A(t(`models.v2ThreadsApplied`)),ae(!1)}catch(e){M(!1),A(e instanceof Error?e.message:t(`models.saveFailed`))}}catch{M(!1),A(t(`models.networkError`))}finally{W(!1),ne.current=!1}}}},Tt=e=>{if(e===`custom`){ae(!0),G(String(B?.maxConcurrentThreadsPerSession??``));return}ae(!1),wt(Number(e))},Et=(e,t)=>{Fe.current&&clearTimeout(Fe.current),Fe.current=setTimeout(()=>{Pe({namespaced:e,rect:t.getBoundingClientRect()})},300)},Dt=(e,t)=>{Fe.current&&clearTimeout(Fe.current),Pe({namespaced:e,rect:t.getBoundingClientRect()})},At=()=>{Fe.current&&clearTimeout(Fe.current),Fe.current=setTimeout(()=>Pe(null),120)},jt=()=>{Fe.current&&clearTimeout(Fe.current)},Mt=async(n,r,i,a,o)=>{ke(!0),Me(``);try{let s=await fetch(`${e}/api/custom-models`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:n,modelId:r,displayName:i,contextWindow:a,inputModalities:o})});try{await J(s,t(`models.customSaveFailed`)),le(!1),M(!0),A(t(`models.customAdded`)),await ct(!0)}catch(e){Me(e instanceof Error?e.message:t(`models.customSaveFailed`))}}catch{Me(t(`models.networkError`))}finally{ke(!1)}},Nt=async(n,r)=>{ke(!0),Me(``);try{let i=await fetch(`${e}/api/custom-models/${encodeURIComponent(n)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});try{await J(i,t(`models.customSaveFailed`)),le(!1),M(!0),A(t(`models.customUpdated`)),await ct(!0)}catch(e){Me(e instanceof Error?e.message:t(`models.customSaveFailed`))}}catch{Me(t(`models.networkError`))}finally{ke(!1)}},Pt=async n=>{try{(await fetch(`${e}/api/custom-models/${encodeURIComponent(n)}`,{method:`DELETE`})).ok?(M(!0),A(t(`models.customDeleted`)),await ct(!0)):(M(!1),A(t(`models.customSaveFailed`)))}catch{M(!1),A(t(`models.networkError`))}},Ft=rt.data??r;if(rt.showSkeleton&&!Ft)return(0,z.jsx)(fs,{label:t(`models.loading`),rows:5});if(rt.kind===`failed-cold`)return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(q,{tone:`err`,children:rt.error instanceof Error?rt.error.message:t(`models.loadFail`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>nt.refresh(),children:t(`common.retry`)})]});let It=u??{},Lt=e=>{let{provider:n,rows:r,native:i,liveModels:a,discovery:o}=e,s=E.has(n),l=e=>bs(It,n,e.id,e.native===!0,c.has(e.namespaced)),u=r.filter(l).length,d=g[n]===y,_=i,v=a&&o?.status===`failed`?o:void 0,b=(f[n]??``).trim().toLowerCase(),x=b?r.filter(e=>e.id.toLowerCase().includes(b)):r,S=x.toSorted((e,t)=>Number(!l(e))-Number(!l(t))),C=m[n]??60,w=S.slice(0,C),T=x.length-w.length,D=r.length>0,O=!D||r.every(l),k=!D||r.every(e=>!l(e)),A=e=>{D&&ft(`provider`,n,r.map(e=>({id:e.id,native:e.native===!0})),e)};return(0,z.jsxs)(`div`,{className:`card models-provider-card`,children:[(0,z.jsxs)(`div`,{className:`row group-head models-provider-head${s?``:` open`}`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`row models-provider-toggle`,onClick:()=>mt(n),"aria-expanded":!s,style:{flex:1,border:0,background:`transparent`,padding:0,color:`inherit`,cursor:`pointer`,textAlign:`left`},children:[(0,z.jsx)(_e,{style:{width:14,height:14,color:`var(--muted)`,transform:s?`none`:`rotate(90deg)`,transition:`transform .12s`}}),(0,z.jsx)(`span`,{className:`text-body font-semibold`,children:n}),_&&(0,z.jsx)(`span`,{className:`models-chip muted mono text-caption`,children:t(`models.nativeGroupLabel`)}),v&&(0,z.jsx)(`span`,{className:`badge badge-amber`,role:`status`,title:Cs(t,v),children:t(`models.discoveryFailedBadge`)}),(0,z.jsx)(`span`,{className:`muted mono text-label`,children:t(`models.active`,{active:u,total:r.length})})]}),(0,z.jsxs)(`div`,{className:`row models-provider-actions`,children:[!_&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:e=>{e.stopPropagation(),de(`add`),me(n),ge(``),ye(``),xe(``),Ce(``),Te(!1),De([`text`]),Me(``),le(!0)},"aria-label":t(`models.customAdd`),"aria-haspopup":`dialog`,children:`+`}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,disabled:N||O,onClick:()=>A(!0),children:t(`models.allOn`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,disabled:N||k,onClick:()=>A(!1),children:t(`models.allOff`)}),!_&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(it,{on:d,onClick:()=>pt(n),disabled:N,label:t(`models.capValue`,{value:js(y)})}),(0,z.jsx)(`span`,{className:`muted mono text-label`,children:t(`models.capValue`,{value:js(y)})})]})]})]}),!s&&(0,z.jsxs)(`div`,{className:`models-provider-body`,children:[_&&(0,z.jsx)(`p`,{className:`muted text-label models-provider-hint`,children:t(`models.nativeHint`)}),r.length===0&&(0,z.jsx)(Rs,{liveModels:a,discovery:o,showFailureBadge:!1}),r.length>60/2&&(0,z.jsx)(`input`,{className:`input`,placeholder:t(`models.search`),value:f[n]??``,onChange:e=>p(t=>({...t,[n]:e.target.value})),"aria-label":t(`models.search`)}),w.map(e=>{let r=!l(e);return(0,z.jsxs)(`div`,{className:`model-row-wrap`,onMouseEnter:t=>Et(e.namespaced,t.currentTarget),onMouseLeave:At,onFocus:t=>Dt(e.namespaced,t.currentTarget),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||Pe(null)},children:[(0,z.jsxs)(`div`,{className:`row models-model-row`,children:[(0,z.jsx)(it,{on:!r,onClick:()=>void ft(`models`,n,[{id:e.id,native:e.native===!0}],r),disabled:N,label:e.native?e.id:e.namespaced}),(0,z.jsx)(`code`,{className:`mono text-control`,style:{color:r?`var(--faint)`:`var(--text)`,textDecoration:r?`line-through`:`none`},children:e.native?zo(e.id):e.namespaced}),e.custom&&(0,z.jsx)(`span`,{className:`models-chip muted mono text-caption`,children:t(`models.customBadge`)}),e.contextCapped&&(0,z.jsx)(`span`,{className:`models-chip muted mono text-caption`,children:t(`models.contextCappedValue`,{value:js(e.contextCap??y)})})]}),Ne?.namespaced===e.namespaced&&(()=>{let n=Ne.rect,i=n.bottom+4,a=i+360>window.innerHeight;return(0,z.jsxs)(`div`,{className:`model-tip${e.custom?` has-actions`:``}${a?` flip-up`:``}`,role:`tooltip`,style:{position:`fixed`,left:n.left+24,...a?{bottom:window.innerHeight-n.top+4}:{top:i}},onMouseEnter:jt,onMouseLeave:At,children:[(0,z.jsx)(`div`,{className:`model-tip-id`,children:e.native?e.id:e.namespaced}),e.displayName&&(0,z.jsx)(`div`,{className:`model-tip-display`,children:e.displayName}),e.custom&&(0,z.jsx)(`span`,{className:`models-chip models-chip--tip muted mono text-caption`,children:t(`models.customBadge`)}),(0,z.jsxs)(`div`,{className:`model-tip-grid`,children:[(0,z.jsx)(`span`,{className:`model-tip-key`,children:t(`models.tipProvider`)}),(0,z.jsx)(`span`,{className:`model-tip-val`,children:e.provider}),(e.contextWindow||e.contextCap)&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`model-tip-key`,children:t(`models.tipContext`)}),(0,z.jsx)(`span`,{className:`model-tip-val`,children:js(e.contextWindow??e.contextCap??0)})]}),e.inputModalities&&e.inputModalities.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`model-tip-key`,children:t(`models.tipModalities`)}),(0,z.jsx)(`span`,{className:`model-tip-val`,children:e.inputModalities.join(`, `)})]}),(0,z.jsx)(`span`,{className:`model-tip-key`,children:t(`models.tipStatus`)}),(0,z.jsx)(`span`,{className:`model-tip-val`,children:t(r?`models.tipDisabled`:`models.tipActive`)})]}),e.custom&&e.customId&&(0,z.jsxs)(`div`,{className:`model-tip-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>{de(`edit`),me(e.provider),ge(e.customId),ye(e.id),xe(e.displayName??``),Ce(e.contextWindow?String(e.contextWindow):``),Te(!1),De(e.inputModalities??[`text`]),Me(``),le(!0),Pe(null)},children:t(`models.customEdit`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,style:{color:`var(--red)`},onClick:()=>{window.confirm(t(`models.customDeleteConfirm`,{name:e.displayName??e.id}))&&Pt(e.customId),Pe(null)},children:t(`models.customDelete`)})]})]})})()]},e.namespaced)}),T>0&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>h(e=>({...e,[n]:C+60})),className:`btn btn-ghost btn-sm models-show-more`,children:t(`models.showMore`,{n:T})})]})]},n)},Rt=Je?lt.filter(e=>e.provider===Je):lt,zt=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`models-control-top-row`,children:[(0,z.jsxs)(`div`,{className:`models-shadow-row row muted text-control`,"aria-busy":!Ie||void 0,children:[(0,z.jsxs)(`span`,{className:`models-shadow-label`,children:[t(`models.shadowCallIntercept`),` `,(0,z.jsx)(st,{content:t(`models.shadowCallInterceptHint`,{models:Ot(Ie?.sourceModels)}),side:`top`,maxWidth:320,children:(0,z.jsx)(`span`,{style:{cursor:`help`},"aria-label":t(`models.shadowCallInterceptHint`,{models:Ot(Ie?.sourceModels)}),children:`ⓘ`})})]}),(0,z.jsx)(`code`,{className:`text-caption models-shadow-warning`,style:{opacity:.6},children:t(`models.shadowCallOriginal`,{models:kt(Ie?.sourceModels)})}),(0,z.jsx)(it,{on:Ie?.enabled??!1,onClick:()=>void St({enabled:!Ie?.enabled}),disabled:!Ie||Re,label:t(`models.shadowCallIntercept`)}),(0,z.jsx)(`div`,{className:`models-shadow-model-slot`,children:(0,z.jsx)(at,{value:Ie?.model??``,options:[{value:``,label:`—`},...Ze],onChange:e=>{Le(t=>t&&{...t,model:e}),St({model:e})},disabled:!Ie||Re||!Ie.enabled,label:t(`models.shadowCallIntercept`)})})]}),B&&(0,z.jsxs)(`div`,{className:`models-v2-mode-row row`,children:[(0,z.jsx)(`span`,{className:`muted text-control`,children:t(`models.v2Label`)}),(0,z.jsx)(`div`,{className:`segmented models-segmented`,role:`radiogroup`,"aria-label":t(`models.v2Label`),children:[`v1`,`default`,`v2`].map(e=>(0,z.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":(B.multiAgentMode??`default`)===e,className:`btn btn-sm${(B.multiAgentMode??`default`)===e?` btn-primary`:` btn-ghost`}`,style:{background:(B.multiAgentMode??`default`)===e?void 0:`transparent`,color:(B.multiAgentMode??`default`)===e?void 0:`var(--muted)`},disabled:H,onClick:()=>void Ct(e),children:t(`models.v2Mode_${e}`)},e))}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{width:24,height:24,minWidth:24,flex:`0 0 24px`,padding:0,borderRadius:`var(--radius-pill)`,color:`var(--muted)`},onClick:()=>se(!0),"aria-label":t(`models.v2Label`),"aria-haspopup":`dialog`,children:(0,z.jsx)(fe,{width:14,height:14,"aria-hidden":`true`})})]})]}),B&&(B.enabled||B.agentsMaxThreadsConflict||ee)&&(0,z.jsxs)(`div`,{className:`models-v2-detail-row row`,children:[B.enabled&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`muted text-control`,children:t(`models.v2ThreadsLabel`)}),(0,z.jsx)(at,{value:ie?`custom`:B.maxConcurrentThreadsPerSession!==null&&B.maxConcurrentThreadsPerSession!==void 0?Os.has(B.maxConcurrentThreadsPerSession)?String(B.maxConcurrentThreadsPerSession):`custom`:``,options:[...B.maxConcurrentThreadsPerSession===null||B.maxConcurrentThreadsPerSession===void 0?[{value:``,label:t(`models.v2ThreadsDefault`)}]:[],...B.maxConcurrentThreadsPerSession!==null&&B.maxConcurrentThreadsPerSession!==void 0&&!Os.has(B.maxConcurrentThreadsPerSession)&&!ie?[{value:`custom`,label:String(B.maxConcurrentThreadsPerSession)}]:[],...Ds.map(e=>({value:String(e),label:String(e)})),{value:`custom`,label:t(`models.custom`)}],onChange:e=>Tt(e),disabled:H,label:t(`models.v2ThreadsLabel`)}),ie&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`input`,{className:`input`,style:{width:100},inputMode:`numeric`,value:re,onChange:e=>G(e.target.value),onKeyDown:e=>{e.key===`Enter`&&wt(Number(re.replace(/[_,\s]/g,``)))},disabled:H,"aria-label":t(`models.v2ThreadsLabel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,disabled:H,onClick:()=>{wt(Number(re.replace(/[_,\s]/g,``)))},children:t(`models.v2ThreadsApply`)})]})]}),B.enabled&&B.agentsMaxThreadsConflict&&(0,z.jsx)(`span`,{className:`mono text-label`,style:{color:`var(--err, #e5484d)`},children:t(`models.v2Conflict`)}),ee&&(0,z.jsx)(`span`,{className:`muted text-label`,children:ee})]}),(0,z.jsxs)(`div`,{className:`row models-cap-row`,children:[(0,z.jsx)(`span`,{className:`muted text-control`,children:t(`models.contextCapLabel`)}),(0,z.jsx)(at,{value:C?Es:Ts.has(y)?String(y):Es,options:[...!Ts.has(y)&&!C?[{value:String(y),label:js(y)}]:[],...ws.map(e=>({value:String(e),label:js(e)})),{value:Es,label:t(`models.custom`)}],onChange:e=>vt(e),disabled:N,label:t(`models.contextCapLabel`)}),C&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`input`,{className:`input`,style:{width:160},inputMode:`numeric`,placeholder:t(`models.customPlaceholder`),value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`&&yt()},disabled:N,"aria-label":t(`models.customPlaceholder`)}),(0,z.jsx)(`button`,{type:`button`,onClick:yt,disabled:N,className:`btn btn-ghost btn-sm`,children:t(`models.customApply`)})]}),(0,z.jsx)(it,{on:bt,onClick:xt,disabled:N,label:t(`models.setAll`)}),(0,z.jsx)(`span`,{className:`muted text-label leading-body`,children:t(`models.setAllHint`,{value:js(y)})})]}),(()=>{let e=i.filter(e=>e.custom).length;return e===0?null:(0,z.jsx)(`div`,{className:`row muted text-label models-custom-summary`,children:(0,z.jsx)(`span`,{className:`models-chip mono text-caption`,children:t(`models.customSummary`,{count:e})})})})(),(0,z.jsxs)(`div`,{className:`row muted text-label leading-body models-order-hint`,children:[(0,z.jsx)(fe,{width:15,height:15,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:t(`models.orderHint`)})]})]}),Bt=(0,z.jsxs)(z.Fragment,{children:[We===null&&!Ge&&(0,z.jsx)(`div`,{className:`card models-combos-card`,"aria-busy":`true`,children:(0,z.jsxs)(`div`,{className:`row models-combos-empty-head`,children:[(0,z.jsxs)(`div`,{className:`row models-field-row`,style:{minWidth:0},children:[(0,z.jsx)(Ae,{width:14,height:14,"aria-hidden":`true`,style:{flexShrink:0}}),(0,z.jsx)(`strong`,{children:t(`nav.combos`)}),(0,z.jsx)(`span`,{className:`muted text-label`,children:t(`common.loading`)})]}),(0,z.jsx)(`a`,{className:`btn btn-sm`,href:`#combos`,style:{flexShrink:0,visibility:`hidden`},tabIndex:-1,"aria-hidden":`true`,children:t(`models.combosSetup`)})]})}),We===null&&Ge&&(0,z.jsx)(`div`,{className:`card models-combos-card`,children:(0,z.jsxs)(`div`,{className:`row models-combos-empty-head`,children:[(0,z.jsxs)(`div`,{className:`row models-field-row`,style:{minWidth:0},children:[(0,z.jsx)(Ae,{width:14,height:14,"aria-hidden":`true`,style:{flexShrink:0}}),(0,z.jsx)(`strong`,{children:t(`nav.combos`)}),(0,z.jsx)(`span`,{className:`muted text-label`,role:`alert`,children:t(`models.loadFail`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,style:{flexShrink:0},onClick:()=>He.refresh(),children:t(`common.retry`)})]})}),We!==null&&We.length===0&&(0,z.jsx)(`div`,{className:`card models-combos-card`,children:(0,z.jsxs)(`div`,{className:`row models-combos-empty-head`,children:[(0,z.jsxs)(`div`,{className:`row models-field-row`,style:{minWidth:0},children:[(0,z.jsx)(Ae,{width:14,height:14,"aria-hidden":`true`,style:{flexShrink:0}}),(0,z.jsx)(`strong`,{children:t(`nav.combos`)}),Ge?(0,z.jsx)(`span`,{className:`muted text-label`,role:`alert`,children:t(`models.loadFail`)}):(0,z.jsx)(`span`,{className:`muted text-label`,children:t(`models.combosEmpty`)})]}),Ge?(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,style:{flexShrink:0},onClick:()=>He.refresh(),children:t(`common.retry`)}):(0,z.jsx)(`a`,{className:`btn btn-sm`,href:`#combos`,style:{flexShrink:0},children:t(`models.combosSetup`)})]})}),We!==null&&We.length>0&&(0,z.jsxs)(`div`,{className:`card models-combos-card`,children:[(0,z.jsxs)(`div`,{className:`row group-head models-field-row${Ke?` open`:``}`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`row models-field-row`,"aria-expanded":Ke,onClick:Xe,style:{flex:1,background:`none`,border:`none`,padding:0,cursor:`pointer`,font:`inherit`,color:`inherit`,textAlign:`left`,minWidth:0},children:[(0,z.jsx)(_e,{style:{width:14,height:14,color:`var(--muted)`,flexShrink:0,transform:Ke?`rotate(90deg)`:`none`,transition:`transform .12s`}}),(0,z.jsx)(Ae,{width:14,height:14,"aria-hidden":`true`,style:{flexShrink:0}}),(0,z.jsx)(`strong`,{children:t(`nav.combos`)}),(0,z.jsx)(`span`,{className:`muted mono text-label`,children:t(`models.combosActive`,{count:We.length})}),Ge&&(0,z.jsx)(`span`,{className:`muted text-label`,role:`alert`,children:t(`models.loadFail`)})]}),Ge?(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,style:{flexShrink:0},onClick:()=>He.refresh(),children:t(`common.retry`)}):(0,z.jsx)(`a`,{className:`btn btn-sm btn-ghost`,href:`#combos`,style:{flexShrink:0},children:t(`models.combosSetup`)})]}),Ke&&(0,z.jsxs)(`div`,{children:[We.map(e=>(0,z.jsxs)(`div`,{className:`row models-combo-row`,children:[(0,z.jsx)(`span`,{className:`mono leading-ui`,children:e.model}),(0,z.jsxs)(`span`,{className:`muted text-label`,children:[e.strategy,` · `,e.targets.length]})]},e.id)),(0,z.jsxs)(`a`,{className:`row muted models-combos-add`,href:`#combos`,children:[`+ `,t(`models.combosAdd`)]})]})]})]}),Vt=(0,z.jsxs)(`div`,{className:`row models-collapse-controls`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>ht(!0),disabled:N,children:[(0,z.jsx)(_e,{width:12,height:12,"aria-hidden":`true`}),` `,t(`models.collapseAll`)]}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>ht(!1),disabled:N,children:[(0,z.jsx)(_e,{width:12,height:12,"aria-hidden":`true`,style:{transform:`rotate(90deg)`}}),` `,t(`models.expandAll`)]})]}),Ht=(0,z.jsx)(z.Fragment,{children:lt.length===0&&(0,z.jsx)(ot,{icon:(0,z.jsx)(U,{}),title:t(`models.noRouted`),children:t(`models.noRoutedHint`)})}),Ut=(0,z.jsxs)(z.Fragment,{children:[oe&&(0,z.jsx)(`div`,{className:`modal-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`models.v2Label`),onClick:()=>se(!1),onKeyDown:e=>{e.key===`Escape`&&se(!1)},children:(0,z.jsxs)(`div`,{className:`modal-card`,onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsx)(`h3`,{children:t(`models.v2Label`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>se(!1),"aria-label":t(`common.close`),children:`×`})]}),(0,z.jsx)(`div`,{className:`modal-desc leading-relaxed`,style:{whiteSpace:`pre-line`},children:t(`models.v2Help`)}),(0,z.jsx)(`div`,{className:`models-help-link`,children:(0,z.jsx)(`a`,{className:`text-control`,href:`https://opencodex.me/guides/sub-agent-surface/`,target:`_blank`,rel:`noreferrer`,style:{color:`var(--accent)`},children:t(`models.v2DocsLink`)})}),(0,z.jsx)(`div`,{className:`modal-actions`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>se(!1),children:t(`common.ok`)})})]})}),ce&&(0,z.jsx)(`div`,{className:`modal-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`models.customAdd`),onClick:()=>{Oe||le(!1)},onKeyDown:e=>{e.key===`Escape`&&!Oe&&le(!1)},children:(0,z.jsxs)(`div`,{className:`modal-card`,onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsx)(`h3`,{children:t(ue===`add`?`models.customAddTitle`:`models.customEditTitle`,{provider:pe})}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>le(!1),disabled:Oe,"aria-label":t(`common.close`),children:`×`})]}),je&&(0,z.jsx)(q,{tone:`err`,children:je}),(0,z.jsxs)(`div`,{className:`models-field-stack`,children:[(0,z.jsxs)(`label`,{className:`text-label models-field`,children:[t(`models.customFieldModelId`),(0,z.jsx)(`input`,{className:`input`,value:ve,onChange:e=>ye(e.target.value),disabled:Oe,placeholder:t(`models.customFieldModelIdPlaceholder`),autoFocus:!0})]}),(0,z.jsxs)(`label`,{className:`text-label models-field`,children:[t(`models.customFieldDisplayName`),(0,z.jsx)(`input`,{className:`input`,value:be,onChange:e=>xe(e.target.value),disabled:Oe,placeholder:t(`models.customFieldDisplayNamePlaceholder`)})]}),(0,z.jsxs)(`label`,{className:`text-label models-field`,children:[t(`models.customFieldContext`),(0,z.jsxs)(`div`,{className:`row models-field-row`,children:[(0,z.jsx)(at,{value:we?`custom`:Se,options:[{value:``,label:`—`},{value:`100000`,label:`100k`},{value:`128000`,label:`128k`},{value:`200000`,label:`200k`},{value:`256000`,label:`256k`},{value:`352000`,label:`352k`},{value:`500000`,label:`500k`},{value:`1000000`,label:`1M`},{value:`custom`,label:t(`models.custom`)}],onChange:e=>{if(e===`custom`){Te(!0);return}Te(!1),Ce(e)},disabled:Oe,label:t(`models.customFieldContext`)}),we&&(0,z.jsx)(`input`,{className:`input`,style:{width:120},inputMode:`numeric`,value:Se,onChange:e=>Ce(e.target.value),disabled:Oe,placeholder:t(`models.customPlaceholder`),"aria-label":t(`models.customFieldContext`)})]})]}),(0,z.jsxs)(`div`,{className:`text-label models-field`,children:[t(`models.customFieldModalities`),(0,z.jsx)(`div`,{className:`row models-field-row`,children:[`text`,`image`,`audio`].map(e=>(0,z.jsxs)(`label`,{className:`row models-modality-option`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:Ee.includes(e),onChange:t=>{De(n=>t.target.checked?[...n,e]:n.filter(t=>t!==e))},disabled:Oe}),(0,z.jsx)(`span`,{className:`text-control`,children:e})]},e))})]})]}),(0,z.jsxs)(`div`,{className:`modal-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>le(!1),disabled:Oe,children:t(`common.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:Oe||!ve.trim(),onClick:()=>{let e=ve.trim(),t=be.trim(),n=Se?Number(Se.replace(/[_,\s]/g,``)):void 0,r=n&&n>0?Math.floor(n):void 0;ue===`add`?Mt(pe,e,t||void 0,r,Ee.length>0?Ee:void 0):Nt(he,{modelId:e,displayName:t,contextWindow:r??null,inputModalities:Ee})},children:t(Oe?`models.customSaving`:ue===`add`?`models.customAddBtn`:`models.customEditBtn`)})]})]})})]});return(0,z.jsxs)(`div`,{className:`models-workspace-shell`,children:[(0,z.jsxs)(`div`,{className:`page-head`,children:[(0,z.jsx)(`h2`,{children:t(`nav.models`)}),(0,z.jsx)(`div`,{className:`row`,children:(0,z.jsx)(`span`,{className:`muted mono text-label`,children:t(`models.active`,{active:dt,total:i.length})})})]}),(0,z.jsx)(`p`,{className:`page-sub`,children:t(`models.subtitle`)}),k&&(0,z.jsx)(q,{tone:j?`ok`:`err`,children:k}),rt.showError&&(0,z.jsx)(q,{tone:`err`,children:t(`models.loadFail`)}),(0,z.jsxs)(`div`,{className:`models-workspace-root`,"aria-busy":rt.refreshing||void 0,children:[(0,z.jsxs)(`aside`,{className:`models-workspace-rail`,"aria-label":t(`nav.models`),children:[(0,z.jsxs)(`div`,{className:`models-workspace-rail-header`,children:[(0,z.jsx)(`span`,{className:`models-workspace-rail-title`,children:t(`models.workspace.providers`)}),(0,z.jsx)(`span`,{className:`models-workspace-rail-count`,children:lt.length})]}),(0,z.jsxs)(`div`,{className:`models-workspace-rail-list`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`models-workspace-rail-row${Je===null?` models-workspace-rail-row--selected`:``}`,onClick:()=>Ye(null),"aria-current":Je===null?`true`:void 0,children:[(0,z.jsx)(`span`,{className:`models-workspace-rail-name`,children:t(`models.workspace.allProviders`)}),(0,z.jsx)(`span`,{className:`models-workspace-rail-meta`,children:t(`models.active`,{active:dt,total:i.length})})]}),lt.map(e=>{let{provider:n,rows:r}=e,i=r.filter(e=>bs(It,n,e.id,e.native===!0,c.has(e.namespaced))).length;return(0,z.jsxs)(`button`,{type:`button`,className:`models-workspace-rail-row${Je===n?` models-workspace-rail-row--selected`:``}`,onClick:()=>Ye(n),"aria-current":Je===n?`true`:void 0,children:[(0,z.jsx)(`span`,{className:`models-workspace-rail-name`,children:n}),(0,z.jsx)(`span`,{className:`models-workspace-rail-meta`,children:t(`models.active`,{active:i,total:r.length})})]},n)})]})]}),(0,z.jsxs)(`section`,{className:`models-workspace-main`,"aria-label":t(`models.workspace.mainAria`),children:[zt,Bt,Vt,(0,z.jsx)(`div`,{className:`models-provider-list`,children:Rt.map(e=>Lt(e))}),lt.length===0&&Ht]})]}),Ut]})}function Vs(e){return e.filter(e=>!e.disabled&&!e.hiddenFromPicker).sort((e,t)=>e.name.localeCompare(t.name))}function Hs(e,t,n){if(e===``)return;let r=Number(e);if(Number.isFinite(r))return Math.min(n,Math.max(t,r))}function Us(e){if(!e)return!1;let t=e.name.toLowerCase();if(t!==`openai`&&t!==`chatgpt`||(e.authMode??``).toLowerCase()!==`forward`||(e.adapter??``).toLowerCase()!==`openai-responses`)return!1;let n=(e.baseUrl??``).replace(/\/+$/,``);return!n||n.includes(`chatgpt.com/backend-api/codex`)}function Ws(e,t,n){let r=new Set([t]),i=n.find(e=>e.name===t);(t.toLowerCase()===`chatgpt`||Us(i))&&r.add(`openai`);let a=[],o=new Set;for(let t of e)!r.has(t.provider)||!t.id||o.has(t.id)||(o.add(t.id),a.push(t.id));return a.toSorted((e,t)=>e.localeCompare(t))}function Gs({value:e,onChange:t,disabled:n}){let r=K();return(0,z.jsx)(`div`,{className:`cwi-strategy-seg`,role:`radiogroup`,"aria-label":r(`cws.strategy`),children:[[`failover`,`cws.strategy.failover`],[`round-robin`,`cws.strategy.roundRobin`]].map(([i,a])=>(0,z.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e===i,className:`btn btn-sm${e===i?` btn-primary`:` btn-ghost`}`,disabled:n,onClick:()=>t(i),children:r(a)},i))})}function Ks({id:e,value:t,onChange:n,disabled:r,allowedEfforts:i}){let a=K(),o=i??Bo,s=t!==null&&!o.includes(t);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`select`,{id:e,className:`input`,value:t??``,disabled:r,"aria-label":a(`cws.field.defaultEffort`),onChange:e=>n(e.target.value===``?null:e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:a(`cws.field.defaultEffortNone`)}),s&&t?(0,z.jsxs)(`option`,{value:t,children:[t,` (`,a(`cws.field.defaultEffortUnsupportedOption`),`)`]}):null,o.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}),s?(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`,color:`var(--danger, #b42318)`},children:a(`cws.field.defaultEffortUnsupported`)}):null]})}function qs({targets:e,strategy:t,providers:n,models:r,onChange:i}){let a=K(),o=Vs(n),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(null),d=(t,n)=>{i(e.map((e,r)=>r===t?{...e,...n}:e))},f=(t,n)=>{if(t===n||t<0||n<0||t>=e.length||n>=e.length)return;let r=[...e],[a]=r.splice(t,1);r.splice(n,0,a),i(r)};return(0,z.jsxs)(`div`,{className:`cwi-target-list`,children:[e.map((p,m)=>{let h=n.find(e=>e.name===p.provider),g=h&&!o.some(e=>e.name===p.provider)?[...o,h]:o,_=Ws(r,p.provider,n),v=p.model&&!_.includes(p.model)?[p.model,..._]:_,y=!p.provider;return(0,z.jsxs)(`div`,{className:[`cwi-target-row`,t===`failover`?`cwi-target-row--failover`:``,s===m?`cwi-target-row--dragging`:``,l===m&&s!==null&&s!==m?`cwi-target-row--drop`:``].filter(Boolean).join(` `),onDragOver:e=>{s!==null&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,l!==m&&u(m))},onDrop:e=>{e.preventDefault(),s!==null&&f(s,m),c(null),u(null)},onDragEnd:()=>{c(null),u(null)},children:[(0,z.jsx)(`button`,{type:`button`,className:`cwi-target-grip`,draggable:!0,"aria-label":a(`cws.target.drag`),title:a(`cws.target.drag`),onDragStart:e=>{c(m),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(m))},children:(0,z.jsx)(je,{width:14,height:14,"aria-hidden":`true`})}),(0,z.jsxs)(`div`,{className:`cwi-target-reorder`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:m===0,"aria-label":a(`cws.target.moveUp`),onClick:()=>f(m,m-1),children:(0,z.jsx)(me,{width:14,height:14,"aria-hidden":`true`})}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:m===e.length-1,"aria-label":a(`cws.target.moveDown`),onClick:()=>f(m,m+1),children:(0,z.jsx)(he,{width:14,height:14,"aria-hidden":`true`})})]}),(0,z.jsxs)(`select`,{className:`input`,value:p.provider,"aria-label":a(`cws.target.provider`),onChange:e=>{let t=e.target.value;d(m,{provider:t,model:Ws(r,t,n)[0]??``})},children:[(0,z.jsx)(`option`,{value:``,children:a(`cws.target.pickProvider`)}),g.map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.disabled?a(`cws.target.disabled`,{name:e.name}):e.name},e.name))]}),(0,z.jsxs)(`select`,{className:`input`,value:p.model,disabled:y,"aria-label":a(`cws.target.model`),onChange:e=>d(m,{model:e.target.value}),children:[(0,z.jsx)(`option`,{value:``,children:y?a(`cws.target.pickProviderFirst`):v.length===0?a(`cws.target.noModels`):a(`cws.target.pickModel`)}),v.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}),t===`round-robin`&&(0,z.jsx)(`input`,{className:`input mono`,type:`number`,min:1,max:1e4,value:p.weight??1,"aria-label":a(`cws.target.weight`),onChange:e=>{let t=Hs(e.target.value,1,1e4);t!==void 0&&d(m,{weight:t})}}),(0,z.jsx)(`div`,{className:`cwi-target-actions`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:e.length<=1,onClick:()=>i(e.filter((e,t)=>t!==m)),"aria-label":a(`common.remove`),children:(0,z.jsx)(ue,{width:14,height:14})})})]},p.clientKey??`${p.provider}:${p.model}`)}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{alignSelf:`flex-start`},onClick:()=>i([...e,Uo()]),children:[(0,z.jsx)(oe,{width:14,height:14}),` `,a(`cws.target.add`)]})]})}function Js({existingIds:e,existingAliases:t,providerMap:n,providers:r,models:i,onClose:a,onSubmit:o}){let s=K(),c=(0,_.useRef)(null),[l,u]=(0,_.useState)(()=>cs()),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(``),h=(0,_.useMemo)(()=>{let e=new Map;for(let t of i)e.set(`${t.provider}/${t.id}`,t.reasoningEfforts);return e},[i]),g=(0,_.useMemo)(()=>Vo(l.targets,h),[l.targets,h]);(0,_.useEffect)(()=>{let e=c.current;e&&!e.open&&e.showModal()},[]);let v=(0,_.useCallback)(()=>{d||a()},[d,a]),y=(0,_.useCallback)(e=>{e.preventDefault(),v()},[v]),b=async()=>{let r=ss(l,{existingIds:e,existingAliases:t,isCreate:!0,providers:n});if(r){m(s(`cws.err.${r}`));return}f(!0),m(``);let i=l.id.trim(),a=l.alias?.trim()||null;try{let e=await o({...l,id:i,alias:a,model:Yo(i,a)});if(!e.ok){m(e.error||s(`cws.saveFailed`));return}}finally{f(!1)}};return(0,z.jsxs)(`dialog`,{ref:c,className:`modal-overlay`,"aria-labelledby":`cwi-add-title`,onCancel:y,children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":s(`common.close`),tabIndex:-1,onClick:v}),(0,z.jsxs)(`div`,{className:`modal-card`,style:{width:`min(560px, 94vw)`},onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`div`,{className:`row`,style:{justifyContent:`space-between`,marginBottom:8},children:[(0,z.jsx)(`h3`,{id:`cwi-add-title`,style:{margin:0},children:s(`cws.addTitle`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:v,disabled:d,"aria-label":s(`common.close`),children:(0,z.jsx)(ae,{width:16,height:16})})]}),(0,z.jsx)(`p`,{className:`muted`,style:{marginTop:0},children:s(`cws.addSubtitle`)}),p&&(0,z.jsx)(q,{tone:`err`,children:p}),(0,z.jsxs)(`div`,{className:`cwi-modal-form`,children:[(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`label`,{htmlFor:`cwi-new-id`,children:s(`cws.field.id`)}),(0,z.jsx)(`input`,{id:`cwi-new-id`,className:`input mono`,value:l.id,disabled:d,onChange:e=>u(t=>({...t,id:e.target.value,model:Yo(e.target.value,t.alias)}))}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`},children:s(`cws.field.idInternalHint`)})]}),(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`label`,{htmlFor:`cwi-new-alias`,children:s(`cws.field.alias`)}),(0,z.jsx)(`input`,{id:`cwi-new-alias`,className:`input mono`,value:l.alias??``,placeholder:s(`cws.field.aliasPlaceholder`),disabled:d,onChange:e=>u(t=>({...t,alias:e.target.value.trim()?e.target.value:null,model:Yo(t.id,e.target.value)}))}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`},children:s(`cws.field.aliasHint`)}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`},children:s(`cws.field.idHint`,{model:l.id.trim()?Yo(l.id,l.alias):`…`})})]}),(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`span`,{className:`field-label`,children:s(`cws.strategy`)}),(0,z.jsx)(Gs,{value:l.strategy,disabled:d,onChange:e=>u(t=>({...t,strategy:e}))}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`6px 0 0`},children:l.strategy===`failover`?s(`cws.strategy.failoverHint`):s(`cws.strategy.roundRobinHint`)})]}),(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`label`,{htmlFor:`cwi-new-effort`,children:s(`cws.field.defaultEffort`)}),(0,z.jsx)(Ks,{id:`cwi-new-effort`,value:l.defaultEffort,disabled:d,allowedEfforts:g,onChange:e=>u(t=>({...t,defaultEffort:e}))}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`},children:s(`cws.field.defaultEffortHint`)})]}),l.strategy===`round-robin`&&(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`label`,{htmlFor:`cwi-new-sticky`,children:s(`cws.field.stickyLimit`)}),(0,z.jsx)(`input`,{id:`cwi-new-sticky`,className:`input mono`,type:`number`,min:1,max:100,value:l.stickyLimit,disabled:d,onChange:e=>{let t=Hs(e.target.value,1,100);t!==void 0&&u(e=>({...e,stickyLimit:t}))}}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`},children:s(`cws.field.stickyLimitHint`)})]}),(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`span`,{className:`field-label`,children:s(`cws.targets`)}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`0 0 8px`},children:l.strategy===`failover`?s(`cws.targets.failoverHint`):s(`cws.targets.roundRobinHint`)}),(0,z.jsx)(qs,{targets:l.targets,strategy:l.strategy,providers:r,models:i,onChange:e=>u(t=>({...t,targets:e}))})]})]}),(0,z.jsxs)(`div`,{className:`cwi-modal-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:v,disabled:d,children:s(`common.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>{b()},disabled:d,children:s(d?`common.saving`:`cws.create`)})]})]})]})}function Ys({baseline:e,isCreate:t=!1,otherIds:n,otherAliases:r,providerMap:i,providers:a,models:o,onBack:s,onSaved:c,onRequestRemove:l,onSave:u,onDirtyChange:d}){let f=K(),[p,m]=(0,_.useState)(`config`),[h,g]=(0,_.useState)(e),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!1),w=!as(h,e),T=`${e.id}:${e.alias??``}:${e.strategy}:${e.stickyLimit}:${e.defaultEffort}:${e.targets.map(e=>`${e.provider}/${e.model}:${e.weight??1}`).join(`,`)}`,E=(0,_.useMemo)(()=>{let e=new Map;for(let t of o)e.set(`${t.provider}/${t.id}`,t.reasoningEfforts);return e},[o]),D=(0,_.useMemo)(()=>Vo(h.targets,E),[h.targets,E]),O=(0,_.useCallback)(t=>{let n=t(h);g(n),d(!as(n,e))},[h,e,d]);(0,_.useEffect)(()=>{let t=window.setTimeout(()=>{g(e),x(null),m(`config`),d(!1)},0);return()=>window.clearTimeout(t)},[T]);let k=async()=>{try{await navigator.clipboard.writeText(e.model),C(!0),window.setTimeout(()=>C(!1),1200)}catch{}},A=async()=>{let a=ss(h,{existingIds:n,existingAliases:r,isCreate:t,providers:i});if(a){x({ok:!1,text:f(`cws.err.${a}`)});return}y(!0);let o=h.id.trim(),s=h.alias?.trim()||null,l={...h,id:o,alias:s,model:Yo(o,s)},d=!t&&o!==e.id?e.id:void 0;try{let e=await u(l,t,d);if(!e.ok){x({ok:!1,text:e.error||f(`cws.saveFailed`)});return}x({ok:!0,text:t?f(`cws.created`,{model:l.model}):f(`cws.saved`)}),c(l)}finally{y(!1)}},j=t?h.id.trim()?Yo(h.id,h.alias):f(`cws.addTitle`):e.model;return(0,z.jsxs)(`div`,{className:`combos-workspace-detail`,children:[(0,z.jsxs)(`div`,{className:`combos-workspace-detail-head`,children:[s&&(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm pwi-back-overview`,onClick:s,"aria-label":f(`cws.backToAll`),children:[(0,z.jsx)(_e,{style:{width:14,height:14,transform:`rotate(180deg)`},"aria-hidden":`true`}),f(`cws.allCombos`)]}),(0,z.jsx)(`h2`,{className:`combos-workspace-detail-title`,children:j}),!t&&(0,z.jsx)(`button`,{type:`button`,className:`chip cwi-copy-chip`,onClick:()=>{k()},title:f(`cws.copyModel`),children:f(S?`cws.copied`:`cws.copyModel`)}),(0,z.jsxs)(`div`,{className:`combos-workspace-detail-actions`,children:[!t&&l&&(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:l,children:[(0,z.jsx)(ue,{width:14,height:14}),` `,f(`common.remove`)]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:!t&&!w||v,onClick:()=>{A()},children:f(v?`common.saving`:t?`cws.create`:`common.save`)})]})]}),b&&(0,z.jsx)(q,{tone:b.ok?`ok`:`err`,children:b.text}),(0,z.jsxs)(`div`,{className:`combos-workspace-tabs`,role:`tablist`,children:[(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":p===`config`,className:`combos-workspace-tab${p===`config`?` combos-workspace-tab--active`:``}`,onClick:()=>m(`config`),children:f(`cws.tab.config`)}),(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":p===`about`,className:`combos-workspace-tab${p===`about`?` combos-workspace-tab--active`:``}`,onClick:()=>m(`about`),children:f(`cws.tab.about`)})]}),(0,z.jsx)(`div`,{className:`combos-workspace-tab-content`,role:`tabpanel`,children:p===`config`?(0,z.jsxs)(`div`,{className:`cwi-form-grid`,children:[(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`label`,{htmlFor:`cwi-edit-id`,children:f(`cws.field.id`)}),(0,z.jsx)(`input`,{id:`cwi-edit-id`,className:`input mono`,value:h.id,disabled:v,onChange:e=>O(t=>({...t,id:e.target.value,model:Yo(e.target.value,t.alias)}))}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`},children:t?f(`cws.field.idInternalHint`):f(`cws.field.idHintEdit`,{model:Yo(h.id,h.alias)})})]}),(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`label`,{htmlFor:`cwi-edit-alias`,children:f(`cws.field.alias`)}),(0,z.jsx)(`input`,{id:`cwi-edit-alias`,className:`input mono`,value:h.alias??``,placeholder:Jo(h.id.trim()||`…`),disabled:v,onChange:e=>O(t=>({...t,alias:e.target.value.trim()?e.target.value:null,model:Yo(t.id,e.target.value)}))}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`},children:f(`cws.field.aliasHint`)})]}),(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`span`,{className:`field-label`,children:f(`cws.strategy`)}),(0,z.jsx)(Gs,{value:h.strategy,disabled:v,onChange:e=>O(t=>({...t,strategy:e}))}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`6px 0 0`},children:h.strategy===`failover`?f(`cws.strategy.failoverHint`):f(`cws.strategy.roundRobinHint`)})]}),(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`label`,{htmlFor:`cwi-effort`,children:f(`cws.field.defaultEffort`)}),(0,z.jsx)(Ks,{id:`cwi-effort`,value:h.defaultEffort,disabled:v,allowedEfforts:D,onChange:e=>O(t=>({...t,defaultEffort:e}))}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`},children:f(`cws.field.defaultEffortHint`)})]}),h.strategy===`round-robin`&&(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`label`,{htmlFor:`cwi-sticky`,children:f(`cws.field.stickyLimit`)}),(0,z.jsx)(`input`,{id:`cwi-sticky`,className:`input mono`,type:`number`,min:1,max:100,value:h.stickyLimit,disabled:v,onChange:e=>{let t=Hs(e.target.value,1,100);t!==void 0&&O(e=>({...e,stickyLimit:t}))}})]}),(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`span`,{className:`field-label`,children:f(`cws.targets`)}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`0 0 8px`},children:h.strategy===`failover`?f(`cws.targets.failoverHint`):f(`cws.targets.roundRobinHint`)}),(0,z.jsx)(qs,{targets:h.targets,strategy:h.strategy,providers:a,models:o,onChange:e=>O(t=>({...t,targets:e}))})]})]}):(0,z.jsxs)(`section`,{className:`pwi-section`,children:[(0,z.jsx)(`h3`,{className:`pwi-section-title`,children:f(`cws.aboutTitle`)}),(0,z.jsx)(`p`,{className:`muted`,style:{margin:0},children:f(`cws.aboutBody`)})]})})]})}function Xs({model:e,onCancel:t,onConfirm:n}){let r=K(),i=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let e=i.current;e&&!e.open&&e.showModal()},[]),(0,z.jsxs)(`dialog`,{ref:i,className:`modal-overlay`,"aria-labelledby":`cwi-remove-title`,onCancel:(0,_.useCallback)(e=>{e.preventDefault(),t()},[t]),children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":r(`common.close`),tabIndex:-1,onClick:t}),(0,z.jsxs)(`div`,{className:`modal-card pwi-remove-confirm-card`,onClick:e=>e.stopPropagation(),children:[(0,z.jsx)(`h3`,{id:`cwi-remove-title`,className:`pwi-remove-confirm-title`,children:r(`cws.removeConfirmTitle`,{model:e})}),(0,z.jsx)(`p`,{className:`muted pwi-remove-confirm-desc`,children:r(`cws.removeConfirmDesc`)}),(0,z.jsxs)(`div`,{className:`pwi-remove-confirm-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:t,children:r(`common.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn pwi-remove-confirm-danger`,onClick:n,children:r(`common.remove`)})]})]})]})}function Zs({onKeep:e,onDiscard:t}){let n=K(),r=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let e=r.current;e&&!e.open&&e.showModal()},[]),(0,z.jsxs)(`dialog`,{ref:r,className:`modal-overlay`,"aria-labelledby":`cwi-unsaved-title`,onCancel:(0,_.useCallback)(t=>{t.preventDefault(),e()},[e]),children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":n(`common.close`),tabIndex:-1,onClick:e}),(0,z.jsxs)(`div`,{className:`modal-card pwi-json-unsaved-card`,onClick:e=>e.stopPropagation(),children:[(0,z.jsx)(`h3`,{id:`cwi-unsaved-title`,className:`pwi-json-unsaved-title`,children:n(`cws.unsavedTitle`)}),(0,z.jsx)(`p`,{className:`muted pwi-json-unsaved-desc`,children:n(`cws.unsavedDesc`)}),(0,z.jsxs)(`div`,{className:`pwi-json-unsaved-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,"data-testid":`cwi-unsaved-keep`,onClick:e,children:n(`cws.keepEditing`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-danger`,"data-testid":`cwi-unsaved-discard`,onClick:t,children:n(`common.discard`)})]})]})]})}function Qs(e,t){return t(e===`empty-targets`?`cws.attention.empty`:e===`catalog-omitted`?`cws.attention.catalogOmitted`:`cws.attention.few`)}function $s({combos:e,cataloguedComboIds:t,onSelect:n,onAdd:r}){let i=K(),a=ns(e),o=is(e,{cataloguedComboIds:t});return(0,z.jsxs)(`div`,{className:`combos-workspace-overview`,children:[(0,z.jsxs)(`div`,{className:`combos-workspace-overview-head`,children:[(0,z.jsx)(`h2`,{className:`combos-workspace-overview-title`,children:i(`cws.overviewTitle`)}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:r,children:[(0,z.jsx)(oe,{width:14,height:14}),` `,i(`cws.add`)]})]}),(0,z.jsx)(`p`,{className:`muted`,style:{marginTop:0,maxWidth:`62ch`},children:i(`cws.overviewBlurb`)}),(0,z.jsxs)(`div`,{className:`cwi-count-strip`,children:[(0,z.jsxs)(`div`,{className:`cwi-count-pill`,children:[(0,z.jsx)(`strong`,{children:e.length}),(0,z.jsx)(`span`,{children:i(`cws.count.total`)})]}),(0,z.jsxs)(`div`,{className:`cwi-count-pill`,children:[(0,z.jsx)(`strong`,{children:a.failover.length}),(0,z.jsx)(`span`,{children:i(`cws.count.failover`)})]}),(0,z.jsxs)(`div`,{className:`cwi-count-pill`,children:[(0,z.jsx)(`strong`,{children:a.roundRobin.length}),(0,z.jsx)(`span`,{children:i(`cws.count.roundRobin`)})]})]}),(0,z.jsxs)(`section`,{className:`pwi-section`,"aria-label":i(`cws.howTitle`),children:[(0,z.jsx)(`h3`,{className:`pwi-section-title`,children:i(`cws.howTitle`)}),(0,z.jsx)(`p`,{className:`muted`,style:{margin:0},children:i(`cws.howBody`)})]}),o.length>0&&(0,z.jsxs)(`section`,{className:`pwi-section`,"aria-label":i(`cws.attentionTitle`),children:[(0,z.jsx)(`h3`,{className:`pwi-section-title`,children:i(`cws.attentionTitle`)}),(0,z.jsx)(`div`,{className:`cwi-attention-list`,children:o.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`cwi-attention-row`,onClick:()=>n(e.id),children:[(0,z.jsx)(de,{width:14,height:14,"aria-hidden":`true`}),(0,z.jsx)(`code`,{className:`chip`,children:e.model}),(0,z.jsx)(`span`,{className:`muted`,children:Qs(e.reason,i)}),(0,z.jsx)(_e,{width:14,height:14,style:{marginLeft:`auto`},"aria-hidden":`true`})]},`${e.id}:${e.reason}`))})]})]})}function ec({combos:e,providers:t,models:n,cataloguedComboIds:r,loading:i,onRefresh:a,onSave:o,onRemove:s,onAdd:c,adding:l,onCloseAdd:u,onCreated:d}){let f=K(),p=(0,_.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,{disabled:e.disabled}])),[t]),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(void 0),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(null),T=(0,_.useMemo)(()=>cs(),[]),E=(0,_.useMemo)(()=>rs(e,m),[e,m]),D=(0,_.useMemo)(()=>ns(E),[E]),O=(0,_.useMemo)(()=>e.flatMap(e=>e.alias?[e.alias]:[]),[e]),k=g&&e.some(e=>e.id===g)?g:null,A=e.find(e=>e.id===k)??null,j=A&&C?.id===A.id?C:A,[M,N]=(0,_.useState)(!1),P=[],F=[];if(j)for(let t of e)t.id!==j.id&&(P.push(t.id),t.alias&&F.push(t.alias));let I=(0,_.useCallback)(e=>{if(e!==k){if(!M){v(e),w(null);return}b(e)}},[k,M]),L=()=>{y!==void 0&&(v(y),w(null),N(!1),b(void 0))},R=()=>b(void 0),B=y!==void 0&&M,V=!i&&e.length===0;return(0,z.jsxs)(`div`,{className:`combos-workspace-root`,children:[(0,z.jsxs)(`aside`,{className:`combos-workspace-rail`,"aria-label":f(`cws.railAria`),children:[(0,z.jsxs)(`div`,{className:`combos-workspace-rail-header`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`combos-workspace-rail-title`,children:f(`nav.combos`)}),(0,z.jsx)(`div`,{className:`combos-workspace-rail-count`,children:e.length})]}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>{if(V){document.getElementById(`cwi-edit-id`)?.focus();return}c()},"aria-label":f(`cws.add`),children:[(0,z.jsx)(oe,{width:14,height:14}),` `,f(`cws.add`)]})]}),(0,z.jsx)(`div`,{className:`cwi-search-row`,children:(0,z.jsxs)(`div`,{className:`cwi-search-wrap`,children:[(0,z.jsx)(pe,{className:`cwi-search-icon`,"aria-hidden":`true`}),(0,z.jsx)(`input`,{className:`input cwi-search-input`,value:m,onChange:e=>h(e.target.value),placeholder:f(`cws.searchPlaceholder`),"aria-label":f(`cws.searchPlaceholder`)})]})}),(0,z.jsx)(`div`,{className:`combos-workspace-rail-list`,children:E.length===0&&e.length>0?(0,z.jsx)(`p`,{className:`muted`,style:{padding:`16px`},children:f(`cws.noSearchResults`)}):(0,z.jsx)(z.Fragment,{children:[[`failover`,D.failover,`cws.group.failover`],[`round-robin`,D.roundRobin,`cws.group.roundRobin`]].map(([e,t,n])=>t.length>0?(0,z.jsxs)(`div`,{className:`combos-workspace-rail-group`,children:[(0,z.jsxs)(`div`,{className:`combos-workspace-rail-group-head`,children:[(0,z.jsx)(`span`,{className:`pwi-dot`,"aria-hidden":`true`}),f(n),(0,z.jsx)(`span`,{className:`combos-workspace-rail-count`,children:t.length})]}),t.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`combos-workspace-rail-row${k===e.id?` combos-workspace-rail-row--selected`:``}`,onClick:()=>I(e.id),"aria-current":k===e.id?`true`:void 0,children:[(0,z.jsx)(`span`,{className:`combos-workspace-rail-icon`,"aria-hidden":`true`,children:(0,z.jsx)(Ae,{width:16,height:16})}),(0,z.jsx)(`span`,{className:`combos-workspace-rail-name`,children:e.model}),(0,z.jsx)(`span`,{className:`combos-workspace-rail-meta`,children:e.targets.length===1?f(`cws.targetCountOne`):f(`cws.targetCount`,{count:e.targets.length})}),(0,z.jsx)(_e,{className:`combos-workspace-rail-chevron`,"aria-hidden":`true`})]},e.id))]},e):null)})})]}),(0,z.jsx)(`div`,{className:`combos-workspace-main`,children:j?(0,z.jsx)(Ys,{baseline:j,otherIds:P,otherAliases:F,providerMap:p,providers:t,models:n,onBack:()=>I(null),onSaved:e=>{N(!1),e.id===j.id?w(e):(v(e.id),w(null)),a()},onRequestRemove:()=>S(j.id),onSave:o,onDirtyChange:N},j.id):V?(0,z.jsx)(Ys,{baseline:T,isCreate:!0,otherIds:[],otherAliases:[],providerMap:p,providers:t,models:n,onSaved:e=>{N(!1),v(e.id),w(e),d(e.id)},onSave:o,onDirtyChange:N},`first-combo`):(0,z.jsx)($s,{combos:e,cataloguedComboIds:r,onSelect:e=>I(e),onAdd:c})}),l&&!V&&(0,z.jsx)(Js,{existingIds:e.map(e=>e.id),existingAliases:O,providerMap:p,providers:t,models:n,onClose:u,onSubmit:async e=>{let t=await o(e,!0);return t.ok&&(u(),d(e.id),v(e.id),w(null)),t}}),x&&(0,z.jsx)(Xs,{model:e.find(e=>e.id===x)?.model??Jo(x),onCancel:()=>S(null),onConfirm:()=>{(async()=>{let e=await s(x);S(null),e.ok&&(k===x&&(v(null),w(null)),a())})()}}),B&&(0,z.jsx)(Zs,{onKeep:R,onDiscard:L})]})}function tc(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e.error;return typeof t==`string`&&t.trim()?t:void 0}function nc(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&e.success===!0}function rc(e){return Y(e)}function ic({apiBase:e}){let t=K(),n=`ocx.combos.workspace.v1:${e}`,r=rc(n),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1),u=(e,t)=>{a(e),s(t)};(0,_.useEffect)(()=>{if(!i||!o)return;let e=window.setTimeout(()=>{a(``),s(!1)},5e3);return()=>window.clearTimeout(e)},[i,o]);let d=(0,_.useCallback)(async()=>{let[t,r,i]=await Promise.all([fetch(`${e}/api/combos`),fetch(`${e}/api/config`),fetch(`${e}/api/models`)]);if(!t.ok||!r.ok||!i.ok)throw Error(`combo workspace load failed`);let a=await t.json(),o=await r.json(),s=await i.json(),c=Array.isArray(s)?s:Array.isArray(s?.models)?s.models:[],l=ts(a),u=o.providers??{},d=Yn(u),f=Object.entries(u).map(([e,t])=>({name:e,disabled:!!t.disabled,hiddenFromPicker:!Object.hasOwn(d,e),authMode:t.authMode,adapter:t.adapter,baseUrl:t.baseUrl})),p=[],m=new Set;for(let e of c){if(!e||typeof e!=`object`)continue;let t=e;if(typeof t.provider!=`string`||typeof t.id!=`string`)continue;let n=t.provider.trim(),r=t.id.trim();if(!n||!r)continue;if(n===`combo`){m.add(r);continue}if(t.disabled===!0)continue;let i=Array.isArray(t.reasoningEfforts)?t.reasoningEfforts.filter(e=>typeof e==`string`):void 0;p.push({provider:n,id:r,namespaced:typeof t.namespaced==`string`?t.namespaced:void 0,...i?{reasoningEfforts:i}:{}})}for(let[e,t]of Object.entries(u)){let n=typeof t.defaultModel==`string`?t.defaultModel.trim():``;!n||t.disabled||p.some(t=>t.provider===e&&t.id===n)||p.push({provider:e,id:n,namespaced:`${e}/${n}`})}let h={combos:l,providers:f,models:p,cataloguedComboIds:[...m]};return X(n,h),h},[e,n]),f=us(n,[e],d,{isEmpty:()=>!1}),{state:p}=f,m=p.data??r,h=m?.combos??[],g=m?.providers??[],v=m?.models??[],y=new Set(m?.cataloguedComboIds??[]);return p.showSkeleton&&!m?(0,z.jsx)(fs,{label:t(`cws.loading`),rows:5}):p.kind===`failed-cold`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(q,{tone:`err`,children:p.error instanceof Error?p.error.message:t(`cws.loadFailed`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>f.refresh(),children:t(`common.retry`)})]}):(0,z.jsxs)(`div`,{className:`combos-workspace-shell`,children:[i&&(0,z.jsx)(`div`,{className:`combos-workspace-shell-banner`,children:(0,z.jsx)(q,{tone:o?`ok`:`err`,children:i})}),p.showError&&(0,z.jsx)(`div`,{className:`combos-workspace-shell-banner`,children:(0,z.jsx)(q,{tone:`err`,children:t(`cws.loadFailed`)})}),p.refreshing&&(0,z.jsx)(ps,{live:!p.showError,children:t(`cws.loading`)}),(0,z.jsx)(`div`,{className:`combos-workspace-shell-body`,children:(0,z.jsx)(ec,{combos:h,providers:g,models:v,cataloguedComboIds:y,loading:!1,onRefresh:()=>f.refresh(),onSave:async(n,r,i)=>{try{let a=await fetch(`${e}/api/combos`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(os(n,i?{renameFrom:i}:{}))}),o=a.ok?await a.json():await a.json().catch(()=>null),s=tc(o);if(!a.ok||s||!nc(o)){let e=s||t(`cws.saveFailed`);return u(e,!1),{ok:!1,error:e}}return f.refresh(),u(i?t(`cws.renamed`,{from:Jo(i),to:n.model}):r?t(`cws.created`,{model:n.model}):t(`cws.saved`),!0),{ok:!0}}catch{let e=t(`cws.saveFailed`);return u(e,!1),{ok:!1,error:e}}},onRemove:async n=>{try{let r=await fetch(`${e}/api/combos?id=${encodeURIComponent(n)}`,{method:`DELETE`}),i=r.ok?await r.json():await r.json().catch(()=>null),a=tc(i);if(!r.ok||a||!nc(i)){let e=a||t(`cws.removeFailed`);return u(e,!1),{ok:!1,error:e}}return f.refresh(),u(t(`cws.removed`,{id:n}),!0),{ok:!0}}catch{let e=t(`cws.removeFailed`);return u(e,!1),{ok:!1,error:e}}},onAdd:()=>l(!0),adding:c,onCloseAdd:()=>l(!1),onCreated:()=>f.refresh()})})]})}var ac=`section`;function oc(e,t){return[e,ac,t].join(`-`)}function sc(e){return[e,ac,``].join(`-`)}var cc=1200;function lc({scope:e,items:t,ariaLabel:n}){let[r,i]=(0,_.useState)(t[0]?.id??``),a=(0,_.useRef)(null),o=(0,_.useRef)(null),s=(0,_.useCallback)(()=>{a.current=null,o.current!==null&&(clearTimeout(o.current),o.current=null)},[]),c=(0,_.useCallback)(()=>{s();let n=null,r=1/0;for(let i of t){let t=document.getElementById(oc(e,i.id));if(!t)continue;let a=Math.abs(t.getBoundingClientRect().top-72);a<r&&(r=a,n=i.id)}n&&i(n)},[s,t,e]);(0,_.useEffect)(()=>()=>s(),[s]),(0,_.useEffect)(()=>{if(typeof IntersectionObserver>`u`)return;let n=t.map(t=>document.getElementById(oc(e,t.id))).filter(e=>e!==null);if(n.length===0)return;let r=new IntersectionObserver(t=>{let n=a.current;if(n){let r=document.getElementById(oc(e,n));t.some(e=>e.isIntersecting&&e.target===r)&&(s(),i(n));return}let r=t.filter(e=>e.isIntersecting).sort((e,t)=>e.boundingClientRect.top-t.boundingClientRect.top)[0];if(!r)return;let o=r.target.id.slice(sc(e).length);i(e=>e===o?e:o)},{rootMargin:`-72px 0px -60% 0px`,threshold:0});for(let e of n)r.observe(e);return()=>r.disconnect()},[s,t,e]);let l=t=>{let n=document.getElementById(oc(e,t));n&&(a.current=t,o.current!==null&&clearTimeout(o.current),o.current=setTimeout(c,cc),i(t),n.scrollIntoView({behavior:`smooth`,block:`start`}))};return(0,z.jsx)(`div`,{className:`page-tabs section-tabs`,role:`tablist`,"aria-label":n,children:t.map(t=>(0,z.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":r===t.id,"aria-controls":oc(e,t.id),tabIndex:r===t.id?0:-1,className:`page-tab${r===t.id?` page-tab--active`:``}`,onClick:()=>l(t.id),children:[t.label,t.meta?(0,z.jsx)(`span`,{className:`section-tab-meta`,children:t.meta}):null]},t.id))})}function uc({model:e,effort:t,efforts:n,available:r,guidanceEnabled:i,syncCodexDefaults:a,saving:o,onSave:s}){let c=K();return(0,z.jsxs)(`div`,{className:`swi-delegation`,children:[(0,z.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,z.jsxs)(`div`,{className:`setting-copy`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:c(`sub.delegation.model`)}),(0,z.jsx)(`div`,{className:`muted setting-hint`,children:c(`sub.delegation.modelHint`)})]}),(0,z.jsxs)(`div`,{className:`swi-delegation-controls`,children:[(0,z.jsx)(at,{value:e,options:[{value:``,label:c(`dash.injectionNone`)},...r.map(e=>({value:e.namespaced,label:`${e.provider} / ${e.model}`}))],onChange:e=>s({model:e||null,effort:t||null}),disabled:o,label:c(`dash.injectionLabel`)}),e&&n.length>0&&(0,z.jsx)(at,{value:t,options:[{value:``,label:c(`dash.injectionEffortNone`)},...n.map(e=>({value:e,label:e}))],onChange:t=>s({model:e||null,effort:t||null}),disabled:o,label:c(`dash.injectionEffortLabel`)})]})]}),(0,z.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,z.jsxs)(`div`,{className:`setting-copy`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:c(`dash.syncCodexSubagentDefaults`)}),(0,z.jsx)(`div`,{className:`muted setting-hint`,children:c(`dash.syncCodexSubagentDefaultsHint`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`switch ${a?`on`:``}`,onClick:()=>s({syncCodexSubagentDefaults:!a}),disabled:o||!e,"aria-label":c(`dash.syncCodexSubagentDefaults`),"aria-pressed":a,children:(0,z.jsx)(`span`,{className:`knob`})})]}),(0,z.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,z.jsxs)(`div`,{className:`setting-copy`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:c(`dash.multiAgentGuidance`)}),(0,z.jsx)(`div`,{className:`muted setting-hint`,children:c(`dash.multiAgentGuidanceHint`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`switch ${i?`on`:``}`,onClick:()=>s({multiAgentGuidanceEnabled:!i}),disabled:o,"aria-label":c(`dash.multiAgentGuidance`),"aria-pressed":i,children:(0,z.jsx)(`span`,{className:`knob`})})]})]})}function dc({available:e,chosen:t,busy:n=!1,onToggle:r,onMove:i,onSave:a,delegation:o}){let s=K(),[c,l]=(0,_.useState)(``),u=(0,_.useMemo)(()=>new Set(t),[t]),d=t.length>=5,f=(0,_.useMemo)(()=>{let t=c.trim().toLowerCase();return e.filter(e=>!t||e.toLowerCase().includes(t))},[e,c]);return(0,z.jsxs)(`div`,{className:`subagents-workspace-shell`,children:[(0,z.jsx)(lc,{scope:`subagents`,items:(0,_.useMemo)(()=>[{id:`featured`,label:s(`sub.featured`),meta:`${t.length}/5`},{id:`models`,label:s(`sub.models`),meta:String(f.length)},{id:`settings`,label:s(`sub.settings`)}],[s,t.length,f.length]),ariaLabel:s(`sub.sections`)}),(0,z.jsxs)(`div`,{className:`subagents-workspace-root`,children:[(0,z.jsxs)(`section`,{id:oc(`subagents`,`featured`),className:`subagents-workspace-section`,"aria-label":s(`sub.featured`),children:[(0,z.jsxs)(`div`,{className:`swi-featured-head`,children:[(0,z.jsx)(`h2`,{className:`swi-featured-title`,children:s(`sub.featured`)}),(0,z.jsxs)(`span`,{className:`swi-featured-count`,children:[t.length,`/`,5]})]}),(0,z.jsxs)(`p`,{className:`swi-featured-hint`,children:[(0,z.jsx)(fe,{width:15,height:15,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:(0,z.jsx)(Ue,{k:`sub.orderHint`,cmd:`spawn_agent`})})]}),t.length===0?(0,z.jsx)(`div`,{className:`swi-featured-empty`,children:s(`sub.noneSelected`)}):(0,z.jsx)(`div`,{className:`swi-featured-list`,children:t.map((e,a)=>(0,z.jsxs)(`div`,{className:`swi-featured-row`,children:[(0,z.jsx)(`span`,{className:`swi-featured-pos`,children:a+1}),(0,z.jsx)(`span`,{className:`swi-featured-name`,children:zo(e)}),(0,z.jsxs)(`span`,{className:`swi-featured-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>i(a,-1),disabled:n||a===0,"aria-label":s(`sub.moveUp`,{m:e}),children:(0,z.jsx)(me,{})}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>i(a,1),disabled:n||a===t.length-1,"aria-label":s(`sub.moveDown`,{m:e}),children:(0,z.jsx)(he,{})}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>r(e),disabled:n,"aria-label":s(`sub.removeAria`,{m:e}),style:{color:`var(--red)`},children:(0,z.jsx)(ae,{})})]})]},e))}),(0,z.jsx)(`div`,{className:`swi-save-row`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:a,disabled:n,children:s(`common.save`)})})]}),(0,z.jsxs)(`section`,{id:oc(`subagents`,`models`),className:`subagents-workspace-section`,"aria-label":s(`sub.models`),children:[(0,z.jsxs)(`div`,{className:`swi-featured-head`,children:[(0,z.jsx)(`h2`,{className:`swi-featured-title`,children:s(`sub.models`)}),(0,z.jsx)(`span`,{className:`swi-featured-count`,children:f.length})]}),(0,z.jsxs)(`div`,{className:`swi-picker-box`,children:[(0,z.jsx)(`div`,{className:`subagents-workspace-rail-search`,children:(0,z.jsx)(`input`,{className:`input`,value:c,onChange:e=>l(e.target.value),placeholder:s(`sub.search`),"aria-label":s(`sub.search`)})}),(0,z.jsx)(`div`,{className:`subagents-workspace-rail-list`,children:f.length===0?(0,z.jsx)(`span`,{className:`subagents-workspace-rail-empty`,children:s(`sub.noModels`)}):f.map(e=>{let i=u.has(e),a=i?t.indexOf(e)+1:null,o=!i&&(d||n);return(0,z.jsxs)(`div`,{className:`subagents-workspace-rail-row${i?` subagents-workspace-rail-row--selected`:``}`,children:[(0,z.jsxs)(`span`,{className:`subagents-workspace-rail-row-main`,children:[(0,z.jsx)(`span`,{className:`swi-rail-priority`,children:a??``}),(0,z.jsx)(W,{className:`swi-rail-icon`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`subagents-workspace-rail-name`,children:zo(e)})]}),(0,z.jsx)(`button`,{type:`button`,className:`subagents-workspace-rail-toggle${i?` subagents-workspace-rail-toggle--on`:``}${o?` subagents-workspace-rail-toggle--disabled`:``}`,onClick:()=>{o||r(e)},disabled:o,"aria-pressed":i,"aria-label":s(i?`sub.workspace.removeFromFeatured`:`sub.workspace.addToFeatured`,{m:e}),title:i?s(`sub.workspace.removeFromFeatured`,{m:e}):d?s(`sub.workspace.featuredFull`):s(`sub.workspace.addToFeatured`,{m:e}),children:i?(0,z.jsx)(ie,{style:{width:14,height:14}}):(0,z.jsx)(oe,{style:{width:14,height:14}})})]},e)})})]})]}),(0,z.jsxs)(`section`,{id:oc(`subagents`,`settings`),className:`subagents-workspace-section`,"aria-label":s(`sub.settings`),children:[(0,z.jsx)(`div`,{className:`swi-featured-head`,children:(0,z.jsx)(`h2`,{className:`swi-featured-title`,children:s(`sub.settings`)})}),(0,z.jsx)(uc,{model:o.model,effort:o.effort,efforts:o.efforts,available:o.available,guidanceEnabled:o.guidanceEnabled,syncCodexDefaults:o.syncCodexDefaults,saving:o.saving,onSave:o.onSave})]})]})]})}function fc(e){let[t,n]=(0,_.useState)(!1),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)([]),[p,m]=(0,_.useState)(!0),[h,g]=(0,_.useState)(!1),v=(0,_.useCallback)(e=>{let t=gn(e);m(t.multiAgentGuidanceEnabled),g(t.syncCodexSubagentDefaults),o(t.injectionModel),c(t.injectionEffort),Array.isArray(e.efforts)&&u(e.efforts),Array.isArray(e.available)&&f(e.available)},[]);return(0,_.useEffect)(()=>{let t=!1;return(async()=>{try{let n=await ht(await fetch(`${e}/api/injection-model`));if(t)return;v(n)}catch{}finally{t||n(!0)}})(),()=>{t=!0}},[e,v]),{loaded:t,saving:r,model:a,effort:s,efforts:l,available:d,guidanceEnabled:p,syncCodexDefaults:h,save:(0,_.useCallback)(async t=>{if(!r){i(!0);try{if(!(await fetch(`${e}/api/injection-model`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).ok)throw Error(`injection save failed`);v(await ht(await fetch(`${e}/api/injection-model`)))}catch{}finally{i(!1)}}},[e,v,r])}}function pc(e){return Y(e)}function mc({apiBase:e}){let t=K(),n=`ocx.subagents.v1:${e}`,r=pc(n),[i,a]=(0,_.useState)(()=>r?.chosen??[]),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),f=(0,_.useRef)(!1),p=fc(e),m=(0,_.useCallback)(async()=>{let r=await J(await fetch(`${e}/api/subagent-models`),t(`sub.loadFail`));if(!r)throw Error(t(`sub.loadFail`));let i=r.available??[],o=new Set(i),s={available:i,chosen:(r.chosen??[]).filter(e=>o.has(e))};return a(s.chosen),X(n,s),s},[e,n,t]),h=us(n,[e],m,{isEmpty:()=>!1,initialData:r??void 0}),{state:g}=h,v=h.refresh,y=g.data??r,b=y?.available??[],x=e=>{u||(s(``),a(t=>t.includes(e)?t.filter(t=>t!==e):t.length>=5?t:[...t,e]))},S=(e,t)=>{u||a(n=>{let r=[...n],i=e+t;return i<0||i>=r.length?n:([r[e],r[i]]=[r[i],r[e]],r)})},C=async()=>{if(!(u||f.current)){f.current=!0,d(!0),s(``);try{let r=await J(await fetch(`${e}/api/subagent-models`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({models:i})}),t(`sub.saveFailed`)),o=r?.applied??i;r?.applied&&a(r.applied),X(n,{available:b,chosen:o}),l(!0),s(t(`sub.saved`,{n:o.length,cmd:`ocx sync`}))}catch(e){l(!1),s(e instanceof Error&&e.message?e.message:t(`sub.networkError`))}finally{f.current=!1,d(!1)}}};return g.showSkeleton&&!y?(0,z.jsx)(fs,{label:t(`sub.loading`),rows:4}):g.kind===`failed-cold`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(q,{tone:`err`,children:g.error instanceof Error?g.error.message:t(`sub.loadFail`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>v(),children:t(`common.retry`)})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:t(`nav.subagents`)})}),o&&(0,z.jsx)(q,{tone:c?`ok`:`err`,children:o}),g.showError&&(0,z.jsx)(q,{tone:`err`,children:t(`sub.loadFail`)}),(0,z.jsx)(dc,{available:b,chosen:i,busy:u,onToggle:x,onMove:S,onSave:()=>{C()},delegation:{model:p.model,effort:p.effort,efforts:p.efforts,available:p.available,guidanceEnabled:p.guidanceEnabled,syncCodexDefaults:p.syncCodexDefaults,saving:p.saving,onSave:e=>{p.save(e)}}})]})}function hc(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function gc(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function _c(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var vc=(e,t)=>Math.abs(e-t)<1.01,yc=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},bc,xc=()=>{if(bc!==void 0)return bc;if(typeof navigator>`u`)return bc=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return bc=!0;let e=navigator.maxTouchPoints;return bc=navigator.platform===`MacIntel`&&e!==void 0&&e>0},Sc=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Cc=e=>e,wc=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},Tc=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(Sc(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(Sc(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Ec={passive:!0},Dc=typeof window>`u`?!0:`onscrollend`in window,Oc=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Dc,o=0,s=a?null:yc(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,Ec),a&&r.addEventListener(`scrollend`,u,Ec),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},kc=(e,t)=>Oc(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),Ac=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},jc=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},Mc=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Cc,rangeExtractor:wc,onChange:()=>{},measureElement:Ac,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=e>0?s[0]?.key??n.getItemKey(0):null,l=e>0?s[e-1]?.key??n.getItemKey(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==c||t.getItemKey(o-1)!==l)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==l)&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:i,getItemKey:a}=this.options,c=0;for(;c<i&&a(c)!==e;)c++;if(c<i){let e=n[c];if(e){let n=e.start+t;n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=gc(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!xc()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,Ec),e.addEventListener(`touchend`,n,Ec),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(xc()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=gc(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=gc(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=hc(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=gc(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=Fc(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=gc(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);if(o!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,s=a?this.getTotalSize():0,c=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(i)||this.scrollDirection!==`backward`):this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,a?this.applyScrollAdjustment(this.getTotalSize()-s):c&&this.applyScrollAdjustment(o),this.notify(!1)}},this.getVirtualItems=gc(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return _c(t[Nc(0,t.length-1,r?e=>n[e*2]:e=>_c(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){e!==0&&(xc()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&vc(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},Nc=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Pc(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function Fc(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=Pc(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=Nc(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var Ic=typeof document<`u`?_.useLayoutEffect:_.useEffect;function Lc({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=_.useReducer(e=>e+1,0)[1],a=_.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}let r=!!e.options.horizontal,i=t.mode===`transform`,o=r?`left`:`top`,s=e.options.scrollMargin,c=e.getVirtualItems();for(let n of c){let a=n.start-s,c=e.elementsCache.get(n.key);c&&t.lastPositions.get(c)!==a&&(t.lastPositions.set(c,a),i?c.style.transform=r?`translate3d(${a}px, 0, 0)`:`translate3d(0, ${a}px, 0)`:c.style[o]=`${a}px`)}},s={...r,onChange:(t,n)=>{var s;let c=a.current,l=!0;if(c.enabled){o(t);let e=t.range,n=c.prevRange;l=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,l&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}l&&(e&&n?(0,qe.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[c]=_.useState(()=>{let e=new Mc(s);return Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return c.setOptions(s),Ic(()=>c._didMount(),[]),Ic(()=>c._willUpdate()),Ic(()=>{o(c)}),c}function Rc(e){return Lc({observeElementRect:Tc,observeElementOffset:kc,scrollToFn:jc,...e})}var zc=32;function Bc(e){return[...new Uint8Array(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}function Vc(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=31||n===127)return!0}return!1}async function Hc(e){let t=e.trim();if(t&&!Vc(t)&&!(t.length>4096))return Bc(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(t))).slice(0,zc)}function Uc(e,t,n){if(!e)return!1;let r=t.trim();return r?e===r?!0:n!==void 0&&e===n:!1}var Wc={400:{en:{label:`Bad request`,description:`The proxy could not understand the request. Check the model, message shape, headers, and JSON body before retrying.`},ko:{label:`잘못된 요청`,description:`프록시가 요청을 이해할 수 없습니다. 재시도 전에 모델, 메시지 형식, 헤더, JSON 본문을 확인해야 합니다.`},zh:{label:`错误请求`,description:`代理无法理解该请求。重试前请检查模型、消息结构、标头和 JSON 正文。`},de:{label:`Ungültige Anfrage`,description:`Der Proxy konnte die Anfrage nicht verstehen. Prüfe Modell, Nachrichtenformat, Header und JSON-Body vor einem erneuten Versuch.`},ru:{label:`Некорректный запрос`,description:`Прокси не смог интерпретировать запрос. Перед повторной попыткой проверьте модель, формат сообщений, заголовки и тело JSON.`},ja:{label:`不正なリクエスト`,description:`プロキシがリクエストを解釈できませんでした。再試行前にモデル、メッセージ形式、ヘッダー、JSON 本文を確認してください。`}},401:{en:{label:`Unauthorized`,description:`Credentials are missing, expired, or invalid. Re-login or refresh the account/provider credentials used by opencodex.`},ko:{label:`인증 필요`,description:`자격 증명이 없거나 만료되었거나 유효하지 않습니다. opencodex에서 사용하는 계정 또는 제공자 자격 증명을 다시 로그인하거나 갱신해야 합니다.`},zh:{label:`未授权`,description:`凭据缺失、已过期或无效。请重新登录,或刷新 opencodex 使用的账号/提供商凭据。`},de:{label:`Nicht autorisiert`,description:`Anmeldedaten fehlen, sind abgelaufen oder ungültig. Melde dich erneut an oder aktualisiere die von opencodex genutzten Konto-/Anbieter-Zugangsdaten.`},ru:{label:`Не авторизован`,description:`Учётные данные отсутствуют, истекли или недействительны. Войдите заново или обновите учётные данные аккаунта или провайдера, которые использует opencodex.`},ja:{label:`認証が必要`,description:`認証情報が不在・期限切れ・無効です。opencodex が使用するアカウントまたはプロバイダー認証情報を再ログインまたは更新してください。`}},402:{en:{label:`Payment required`,description:`The upstream provider rejected the request because billing, credits, or plan access is not available. Add credits, update billing, or switch provider.`},ko:{label:`결제 필요`,description:`청구, 크레딧, 플랜 접근 권한 문제로 업스트림 제공자가 요청을 거부했습니다. 크레딧 추가, 결제 정보 갱신, 제공자 전환이 필요합니다.`},zh:{label:`需要付款`,description:`上游提供商因账单、额度或套餐权限不可用而拒绝了请求。请充值、更新账单信息或切换提供商。`},de:{label:`Zahlung erforderlich`,description:`Der Upstream-Anbieter hat die Anfrage abgelehnt, weil Abrechnung, Guthaben oder Planzugriff nicht verfügbar ist. Guthaben aufladen, Abrechnung aktualisieren oder Anbieter wechseln.`},ru:{label:`Требуется оплата`,description:`Вышестоящий провайдер отклонил запрос из-за проблем с оплатой, кредитами или доступом по тарифному плану. Пополните баланс, обновите платёжные данные или переключитесь на другого провайдера.`},ja:{label:`支払いが必要`,description:`課金、クレジット、プランアクセスが利用できないため上流プロバイダーがリクエストを拒否しました。クレジット追加、支払い情報更新、プロバイダー切替が必要です。`}},403:{en:{label:`Forbidden`,description:`The account is authenticated but not allowed to use this model or operation. Often a plan/subscription gate (e.g. Ollama Cloud Pro), org policy, or model permission — not necessarily a bad API key.`},ko:{label:`권한 없음`,description:`계정 인증은 되었지만 이 모델 또는 작업을 사용할 권한이 없습니다. 플랜/구독 제한(예: Ollama Cloud Pro), 조직 정책, 모델 권한 문제인 경우가 많으며 API 키가 잘못된 것은 아닐 수 있습니다.`},zh:{label:`禁止访问`,description:`账号已认证,但无权使用此模型或操作。常见原因是套餐/订阅限制(例如 Ollama Cloud Pro)、组织策略或模型权限——不一定是 API 密钥无效。`},de:{label:`Verboten`,description:`Das Konto ist authentifiziert, darf dieses Modell oder diese Operation aber nicht nutzen. Oft Plan-/Abo-Sperre (z. B. Ollama Cloud Pro), Organisationsrichtlinie oder Modellrecht — nicht zwingend ein ungültiger API-Key.`},ru:{label:`Доступ запрещён`,description:`Аккаунт аутентифицирован, но не имеет права использовать эту модель или операцию. Часто причина — ограничение тарифа или подписки (например, Ollama Cloud Pro), политика организации или права доступа к модели, а не обязательно неверный API-ключ.`},ja:{label:`アクセス禁止`,description:`アカウントは認証済みですがこのモデルや操作の使用が許可されていません。多くはプラン/サブスクリプション制限(例: Ollama Cloud Pro)、組織ポリシー、モデル権限であり、API キーが不正とは限りません。`}},404:{en:{label:`Not found`,description:`The requested route, model, account, or upstream resource was not found. Verify the model name and opencodex provider configuration.`},ko:{label:`찾을 수 없음`,description:`요청한 경로, 모델, 계정 또는 업스트림 리소스를 찾을 수 없습니다. 모델 이름과 opencodex 제공자 설정을 확인해야 합니다.`},zh:{label:`未找到`,description:`找不到请求的路由、模型、账号或上游资源。请确认模型名称和 opencodex 提供商配置。`},de:{label:`Nicht gefunden`,description:`Die angeforderte Route, das Modell, das Konto oder die Upstream-Ressource wurde nicht gefunden. Prüfe Modellname und opencodex-Anbieterkonfiguration.`},ru:{label:`Не найдено`,description:`Запрошенный маршрут, модель, аккаунт или вышестоящий ресурс не найден. Проверьте имя модели и конфигурацию провайдера в opencodex.`},ja:{label:`見つかりません`,description:`要求されたルート、モデル、アカウント、上流リソースが見つかりませんでした。モデル名と opencodex プロバイダー設定を確認してください。`}},408:{en:{label:`Request timeout`,description:`The request took too long before the proxy or upstream provider could complete it. Retry with a smaller request or a different provider.`},ko:{label:`요청 시간 초과`,description:`프록시 또는 업스트림 제공자가 요청을 완료하기 전에 시간이 초과되었습니다. 더 작은 요청으로 재시도하거나 다른 제공자로 전환해야 합니다.`},zh:{label:`请求超时`,description:`代理或上游提供商未能在限定时间内完成请求。请缩小请求后重试,或切换提供商。`},de:{label:`Anfrage-Timeout`,description:`Die Anfrage dauerte zu lange, bevor Proxy oder Upstream-Anbieter sie abschließen konnten. Mit kleinerer Anfrage oder anderem Anbieter erneut versuchen.`},ru:{label:`Тайм-аут запроса`,description:`Обработка запроса заняла слишком много времени, и прокси или вышестоящий провайдер не успел её завершить. Повторите попытку с меньшим запросом или через другого провайдера.`},ja:{label:`リクエストタイムアウト`,description:`プロキシまたは上流プロバイダーがリクエストを完了する前に時間切れになりました。より小さいリクエストで再試行するか、別のプロバイダーに切り替えてください。`}},409:{en:{label:`Conflict`,description:`The request conflicts with the current account, session, or provider state. Refresh the session or retry after the active operation finishes.`},ko:{label:`상태 충돌`,description:`요청이 현재 계정, 세션 또는 제공자 상태와 충돌합니다. 세션을 갱신하거나 진행 중인 작업이 끝난 뒤 재시도해야 합니다.`},zh:{label:`状态冲突`,description:`请求与当前账号、会话或提供商状态冲突。请刷新会话,或等待当前操作完成后重试。`},de:{label:`Konflikt`,description:`Die Anfrage kollidiert mit dem aktuellen Konto-, Sitzungs- oder Anbieterstatus. Sitzung aktualisieren oder nach Abschluss der laufenden Operation erneut versuchen.`},ru:{label:`Конфликт`,description:`Запрос конфликтует с текущим состоянием аккаунта, сессии или провайдера. Обновите сессию или повторите попытку после завершения текущей операции.`},ja:{label:`状態の衝突`,description:`リクエストが現在のアカウント、セッション、プロバイダー状態と衝突しています。セッションを更新するか、進行中の操作が終わった後に再試行してください。`}},413:{en:{label:`Request too large`,description:`The prompt, attachments, or generated payload exceeds a proxy or upstream limit. Reduce tokens, file size, or conversation history.`},ko:{label:`요청 과대`,description:`프롬프트, 첨부 파일 또는 생성 페이로드가 프록시나 업스트림 한도를 초과했습니다. 토큰, 파일 크기, 대화 기록을 줄여야 합니다.`},zh:{label:`请求过大`,description:`提示、附件或生成的负载超过了代理或上游限制。请减少 token、文件大小或对话历史。`},de:{label:`Anfrage zu groß`,description:`Prompt, Anhänge oder generierte Nutzlast überschreiten ein Proxy- oder Upstream-Limit. Tokens, Dateigröße oder Verlauf reduzieren.`},ru:{label:`Слишком большой запрос`,description:`Промпт, вложения или сформированная полезная нагрузка превышают лимит прокси или вышестоящего провайдера. Сократите количество токенов, размер файлов или историю диалога.`},ja:{label:`リクエストが大きすぎます`,description:`プロンプト、添付ファイル、生成ペイロードがプロキシまたは上流の制限を超えました。トークン、ファイルサイズ、会話履歴を減らしてください。`}},422:{en:{label:`Invalid content`,description:`The provider accepted the request format but rejected its contents. Check model options, tool definitions, message roles, and unsupported fields.`},ko:{label:`내용 검증 실패`,description:`제공자가 요청 형식은 받았지만 내용을 거부했습니다. 모델 옵션, 도구 정의, 메시지 역할, 지원되지 않는 필드를 확인해야 합니다.`},zh:{label:`内容无效`,description:`提供商接受了请求格式,但拒绝了其中的内容。请检查模型选项、工具定义、消息角色和不支持的字段。`},de:{label:`Ungültiger Inhalt`,description:`Der Anbieter akzeptierte das Anfrageformat, lehnte den Inhalt aber ab. Prüfe Modelloptionen, Tool-Definitionen, Nachrichtenrollen und nicht unterstützte Felder.`},ru:{label:`Недопустимое содержимое`,description:`Провайдер принял формат запроса, но отклонил его содержимое. Проверьте параметры модели, определения инструментов, роли сообщений и неподдерживаемые поля.`},ja:{label:`内容の検証失敗`,description:`プロバイダーはリクエスト形式を受け付けましたが内容を拒否しました。モデルオプション、ツール定義、メッセージロール、未サポートのフィールドを確認してください。`}},424:{en:{label:`Provider dependency failed`,description:`A required upstream dependency failed while opencodex was routing the request. Retry later or switch to another configured provider.`},ko:{label:`제공자 의존성 실패`,description:`opencodex가 요청을 라우팅하는 동안 필요한 업스트림 의존성이 실패했습니다. 나중에 재시도하거나 다른 설정된 제공자로 전환해야 합니다.`},zh:{label:`提供商依赖失败`,description:`opencodex 路由请求时,必需的上游依赖失败。请稍后重试,或切换到另一个已配置的提供商。`},de:{label:`Anbieter-Abhängigkeit fehlgeschlagen`,description:`Eine erforderliche Upstream-Abhängigkeit ist fehlgeschlagen, während opencodex die Anfrage geroutet hat. Später erneut versuchen oder zu einem anderen Anbieter wechseln.`},ru:{label:`Сбой зависимости провайдера`,description:`Необходимая вышестоящая зависимость дала сбой, пока opencodex маршрутизировал запрос. Повторите попытку позже или переключитесь на другого настроенного провайдера.`},ja:{label:`プロバイダー依存の失敗`,description:`opencodex がリクエストをルーティング中に必要な上流依存が失敗しました。後で再試行するか、別の設定済みプロバイダーに切り替えてください。`}},429:{en:{label:`Rate limited`,description:`The upstream provider rate or quota limit has been reached. Wait for the quota window to reset or switch account/provider.`},ko:{label:`한도 초과`,description:`업스트림 제공자의 속도 또는 할당량 한도에 도달했습니다. 한도 창이 초기화될 때까지 기다리거나 계정/제공자를 전환해야 합니다.`},zh:{label:`限流`,description:`已达到上游提供商的速率或额度限制。请等待额度窗口重置,或切换账号/提供商。`},de:{label:`Ratenlimit erreicht`,description:`Das Raten- oder Kontingentlimit des Upstream-Anbieters ist erreicht. Auf Reset des Kontingentfensters warten oder Konto/Anbieter wechseln.`},ru:{label:`Превышен лимит запросов`,description:`Достигнут лимит скорости или квота вышестоящего провайдера. Дождитесь сброса окна квоты или переключитесь на другой аккаунт или провайдера.`},ja:{label:`レート制限`,description:`上流プロバイダーのレートまたはクォータ制限に達しました。クォータウィンドウがリセットされるまで待つか、アカウント/プロバイダーを切り替えてください。`}},499:{en:{label:`Client closed request`,description:`The client disconnected or canceled the request before opencodex finished routing it. Retry if the cancellation was accidental.`},ko:{label:`클라이언트 취소`,description:`opencodex가 라우팅을 끝내기 전에 클라이언트 연결이 끊기거나 요청이 취소되었습니다. 의도한 취소가 아니면 다시 시도해야 합니다.`},zh:{label:`客户端已取消`,description:`opencodex 完成路由前,客户端已断开连接或取消请求。如果不是有意取消,请重试。`},de:{label:`Client hat Anfrage geschlossen`,description:`Der Client hat die Verbindung getrennt oder die Anfrage abgebrochen, bevor opencodex das Routing abgeschlossen hat. Bei versehentlichem Abbruch erneut versuchen.`},ru:{label:`Запрос закрыт клиентом`,description:`Клиент отключился или отменил запрос до того, как opencodex завершил его маршрутизацию. Если отмена была случайной, повторите попытку.`},ja:{label:`クライアントがリクエストをクローズ`,description:`opencodex がルーティングを終える前にクライアントが切断またはキャンセルしました。意図しないキャンセルなら再試行してください。`}},500:{en:{label:`Proxy error`,description:`opencodex hit an internal error while handling the request. Retry once, then check proxy logs if it repeats.`},ko:{label:`프록시 오류`,description:`opencodex가 요청을 처리하는 동안 내부 오류가 발생했습니다. 한 번 재시도하고 반복되면 프록시 로그를 확인해야 합니다.`},zh:{label:`代理错误`,description:`opencodex 处理请求时发生内部错误。请先重试一次;如果重复出现,请检查代理日志。`},de:{label:`Proxy-Fehler`,description:`opencodex ist bei der Anfragebearbeitung auf einen internen Fehler gestoßen. Einmal erneut versuchen, bei Wiederholung Proxy-Logs prüfen.`},ru:{label:`Ошибка прокси`,description:`В opencodex произошла внутренняя ошибка при обработке запроса. Повторите попытку один раз; если ошибка повторяется, проверьте логи прокси.`},ja:{label:`プロキシエラー`,description:`opencodex がリクエスト処理中に内部エラーに遭遇しました。1 回再試行し、繰り返す場合はプロキシログを確認してください。`}},502:{en:{label:`Bad upstream response`,description:`The upstream provider returned an invalid or failed response through the proxy. Retry or route the request to another provider.`},ko:{label:`업스트림 응답 오류`,description:`업스트림 제공자가 프록시를 통해 유효하지 않거나 실패한 응답을 반환했습니다. 재시도하거나 다른 제공자로 라우팅해야 합니다.`},zh:{label:`上游响应错误`,description:`上游提供商通过代理返回了无效或失败的响应。请重试,或将请求路由到其他提供商。`},de:{label:`Ungültige Upstream-Antwort`,description:`Der Upstream-Anbieter lieferte über den Proxy eine ungültige oder fehlgeschlagene Antwort. Erneut versuchen oder zu einem anderen Anbieter routen.`},ru:{label:`Некорректный ответ провайдера`,description:`Вышестоящий провайдер вернул через прокси недействительный или ошибочный ответ. Повторите попытку или направьте запрос другому провайдеру.`},ja:{label:`上流レスポンス不良`,description:`上流プロバイダーがプロキシ経由で無効または失敗したレスポンスを返しました。再試行するか、リクエストを別のプロバイダーにルーティングしてください。`}},503:{en:{label:`Provider unavailable`,description:`The proxy or upstream provider is temporarily unavailable or overloaded. Wait briefly, then retry or switch provider.`},ko:{label:`제공자 사용 불가`,description:`프록시 또는 업스트림 제공자가 일시적으로 사용할 수 없거나 과부하 상태입니다. 잠시 기다린 뒤 재시도하거나 제공자를 전환해야 합니다.`},zh:{label:`提供商不可用`,description:`代理或上游提供商暂时不可用或过载。请稍后重试,或切换提供商。`},de:{label:`Anbieter nicht verfügbar`,description:`Proxy oder Upstream-Anbieter ist vorübergehend nicht verfügbar oder überlastet. Kurz warten, dann erneut versuchen oder Anbieter wechseln.`},ru:{label:`Провайдер недоступен`,description:`Прокси или вышестоящий провайдер временно недоступен или перегружен. Немного подождите, затем повторите попытку или смените провайдера.`},ja:{label:`プロバイダー利用不可`,description:`プロキシまたは上流プロバイダーが一時的に利用不可または過負荷です。少し待ってから再試行するか、プロバイダーを切り替えてください。`}},504:{en:{label:`Upstream timeout`,description:`The upstream provider did not respond before the proxy timeout. Retry with a smaller request or choose a faster provider.`},ko:{label:`업스트림 시간 초과`,description:`프록시 시간 제한 전에 업스트림 제공자가 응답하지 않았습니다. 더 작은 요청으로 재시도하거나 더 빠른 제공자를 선택해야 합니다.`},zh:{label:`上游超时`,description:`上游提供商未在代理超时前响应。请缩小请求后重试,或选择响应更快的提供商。`},de:{label:`Upstream-Timeout`,description:`Der Upstream-Anbieter antwortete nicht vor dem Proxy-Timeout. Mit kleinerer Anfrage erneut versuchen oder schnelleren Anbieter wählen.`},ru:{label:`Тайм-аут вышестоящего провайдера`,description:`Вышестоящий провайдер не ответил до истечения тайм-аута прокси. Повторите попытку с меньшим запросом или выберите более быстрого провайдера.`},ja:{label:`上流タイムアウト`,description:`上流プロバイダーがプロキシタイムアウト前に応答しませんでした。より小さいリクエストで再試行するか、より速いプロバイダーを選んでください。`}},529:{en:{label:`Provider overloaded`,description:`The upstream provider is overloaded or capacity-limited. Wait and retry, or switch to another account/provider.`},ko:{label:`제공자 과부하`,description:`업스트림 제공자가 과부하 상태이거나 처리 용량이 제한되었습니다. 기다렸다가 재시도하거나 다른 계정/제공자로 전환해야 합니다.`},zh:{label:`提供商过载`,description:`上游提供商过载或容量受限。请等待后重试,或切换到其他账号/提供商。`},de:{label:`Anbieter überlastet`,description:`Der Upstream-Anbieter ist überlastet oder kapazitätsbegrenzt. Warten und erneut versuchen oder anderes Konto/Anbieter nutzen.`},ru:{label:`Провайдер перегружен`,description:`Вышестоящий провайдер перегружен или ограничен по мощности. Подождите и повторите попытку либо переключитесь на другой аккаунт или провайдера.`},ja:{label:`プロバイダー過負荷`,description:`上流プロバイダーが過負荷または容量制限されています。待ってから再試行するか、別のアカウント/プロバイダーに切り替えてください。`}}},Gc={client:{en:{label:`Request error`,description:`The proxy or upstream provider rejected the request. Check the request shape, credentials, model name, and provider configuration.`},ko:{label:`요청 오류`,description:`프록시 또는 업스트림 제공자가 요청을 거부했습니다. 요청 형식, 자격 증명, 모델 이름, 제공자 설정을 확인해야 합니다.`},zh:{label:`请求错误`,description:`代理或上游提供商拒绝了该请求。请检查请求结构、凭据、模型名称和提供商配置。`},de:{label:`Anfragefehler`,description:`Der Proxy oder Upstream-Anbieter hat die Anfrage abgelehnt. Prüfe Anfrageformat, Anmeldedaten, Modellname und Anbieterkonfiguration.`},ru:{label:`Ошибка запроса`,description:`Прокси или вышестоящий провайдер отклонил запрос. Проверьте структуру запроса, учётные данные, имя модели и конфигурацию провайдера.`},ja:{label:`リクエストエラー`,description:`プロキシまたは上流プロバイダーがリクエストを拒否しました。リクエスト形式、認証情報、モデル名、プロバイダー設定を確認してください。`}},server:{en:{label:`Server or upstream error`,description:`opencodex or an upstream provider failed while processing the request. Retry later or route the request to another provider.`},ko:{label:`서버 또는 업스트림 오류`,description:`opencodex 또는 업스트림 제공자가 요청 처리 중 실패했습니다. 나중에 재시도하거나 다른 제공자로 라우팅해야 합니다.`},zh:{label:`服务器或上游错误`,description:`opencodex 或上游提供商处理请求时失败。请稍后重试,或将请求路由到其他提供商。`},de:{label:`Server- oder Upstream-Fehler`,description:`opencodex oder ein Upstream-Anbieter ist bei der Anfragebearbeitung fehlgeschlagen. Später erneut versuchen oder zu einem anderen Anbieter routen.`},ru:{label:`Ошибка сервера или провайдера`,description:`opencodex или вышестоящий провайдер завершил обработку запроса с ошибкой. Повторите попытку позже или направьте запрос другому провайдеру.`},ja:{label:`サーバーまたは上流エラー`,description:`opencodex または上流プロバイダーがリクエスト処理中に失敗しました。後で再試行するか、リクエストを別のプロバイダーにルーティングしてください。`}}};function Kc(e){return e===`de`||e===`ko`||e===`zh`||e===`ru`||e===`ja`?e:`en`}function qc(e,t){if(e<400)return null;let n=Kc(t);return(Wc[Math.trunc(e)]??(e<500?Gc.client:Gc.server))[n]}var Jc=[`provider`,`usage`,`injection`];function Yc(e){return e>0?`[${new Date(e).toLocaleTimeString()}] `:``}function Xc(e){return new Date(e).toLocaleTimeString()}function Zc(e,t){return t===`provider`?!!e?.enabled:t===`usage`?!!e?.usage:!!e?.injection}function Qc(e,t){return t===`debug`?e.enabled:t===`usage`?e.usage:t===`injection`?e.injection:e.claude}function $c({entries:e}){let{t}=Ve();return(0,z.jsxs)(`div`,{className:`card`,style:{marginBottom:16,padding:`12px 14px`},children:[(0,z.jsx)(`div`,{className:`font-semibold`,style:{marginBottom:4},children:t(`debug.claudeInbound.title`)}),(0,z.jsx)(`div`,{className:`muted text-control`,style:{marginBottom:10},children:t(`debug.claudeInbound.sub`)}),e.length===0?(0,z.jsx)(`div`,{className:`muted text-control`,children:t(`debug.claudeInbound.empty`)}):(0,z.jsx)(`div`,{style:{overflowX:`auto`},children:(0,z.jsxs)(`table`,{className:`table text-label`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:t(`debug.claudeInbound.time`)}),(0,z.jsx)(`th`,{children:t(`debug.claudeInbound.endpoint`)}),(0,z.jsx)(`th`,{children:t(`debug.claudeInbound.model`)}),(0,z.jsx)(`th`,{children:`thinking`}),(0,z.jsx)(`th`,{children:`effort`}),(0,z.jsx)(`th`,{children:`beta`}),(0,z.jsx)(`th`,{children:`metadata`}),(0,z.jsx)(`th`,{children:`system`})]})}),(0,z.jsx)(`tbody`,{children:e.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`muted mono`,children:Xc(e.at)}),(0,z.jsx)(`td`,{className:`mono`,children:e.endpoint}),(0,z.jsxs)(`td`,{className:`mono`,title:e.resolvedModel,children:[e.model,e.resolvedModel&&e.resolvedModel!==e.model&&(0,z.jsxs)(`span`,{className:`muted`,children:[` → `,e.resolvedModel]})]}),(0,z.jsxs)(`td`,{className:`mono`,children:[e.thinkingType??`-`,e.thinkingBudgetTokens!==void 0&&(0,z.jsxs)(`span`,{className:`muted`,children:[` (`,e.thinkingBudgetTokens,`)`]})]}),(0,z.jsx)(`td`,{className:`mono`,children:e.outputConfigEffort??`-`}),(0,z.jsx)(`td`,{className:`mono`,title:e.anthropicBeta,style:{maxWidth:160,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.anthropicBeta??`-`}),(0,z.jsx)(`td`,{className:`mono`,title:e.metadataKeys?.join(`, `),children:e.hasMetadataUserId?`user_id ${e.userIdTag??``}`:t(`debug.claudeInbound.none`)}),(0,z.jsx)(`td`,{className:`mono`,children:e.hasSystem?e.systemTag??`yes`:t(`debug.claudeInbound.none`)})]},e.id))})]})})]})}function el({debug:e,stream:t,streamEnabled:n,entries:r,scrollContainerRef:i,lineVirtualizer:a}){let{t:o}=Ve();return e?n?r.length===0?(0,z.jsxs)(`div`,{className:`empty`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,style:{marginBottom:6},children:o(`debug.noLinesTitle`)}),(0,z.jsx)(`div`,{className:`muted text-control`,style:{maxWidth:560,marginInline:`auto`},children:o(`debug.noLines.${t}`)})]}):(0,z.jsx)(`div`,{ref:i,className:`log-detail-json`,style:{maxHeight:`calc(100vh - 280px)`,overflow:`auto`},children:(0,z.jsx)(`div`,{style:{position:`relative`,height:a.getTotalSize(),width:`100%`},children:a.getVirtualItems().map(e=>(0,z.jsx)(`div`,{ref:a.measureElement,"data-index":e.index,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:`${Yc(r[e.index].at)}${r[e.index].line}`},e.key))})}):(0,z.jsxs)(`div`,{className:`empty`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,style:{marginBottom:6},children:o(`debug.emptyTitle`)}),(0,z.jsx)(`div`,{className:`muted text-control`,style:{maxWidth:560,marginInline:`auto`},children:o(`debug.empty`)})]}):null}function tl({debug:e,debugBusy:t,stream:n,onSetFlag:r,onReset:i,onStreamChange:a}){let{t:o}=Ve();return(0,z.jsxs)(`div`,{className:`card`,style:{marginBottom:16,padding:`12px 14px`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:12,flexWrap:`wrap`},children:[(0,z.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:16},children:[`debug`,`usage`,`injection`,`claude`].map(n=>{let i=Qc(e,n);return(0,z.jsxs)(`div`,{style:{display:`inline-flex`,alignItems:`center`,gap:10,minWidth:220},children:[(0,z.jsx)(it,{on:i,disabled:t,label:o(`debug.${n}`),onClick:()=>r(n,!i)}),(0,z.jsx)(`span`,{className:`text-control`,children:o(`debug.${n}`)})]},n)})}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:t,onClick:i,children:o(`debug.reset`)})]}),(e.enabled||e.usage||e.injection)&&(0,z.jsxs)(`div`,{style:{display:`inline-flex`,gap:6,marginTop:12},children:[e.enabled&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm${n===`provider`?` btn-primary`:` btn-ghost`}`,onClick:()=>a(`provider`),children:o(`debug.streamProvider`)}),e.usage&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm${n===`usage`?` btn-primary`:` btn-ghost`}`,onClick:()=>a(`usage`),children:o(`debug.streamUsage`)}),e.injection&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm${n===`injection`?` btn-primary`:` btn-ghost`}`,onClick:()=>a(`injection`),children:o(`debug.streamInjection`)})]})]})}function nl({embedded:e,refreshing:t,streamEnabled:n,follow:r,onRefresh:i,onFollowChange:a}){let{t:o}=Ve();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:e?`row`:`page-head`,style:e?{justifyContent:`flex-end`,marginBottom:4}:void 0,children:[!e&&(0,z.jsx)(`h2`,{children:o(`debug.title`)}),(0,z.jsxs)(`div`,{style:{display:`inline-flex`,alignItems:`center`,gap:12},children:[(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:t||!n,onClick:i,children:[(0,z.jsx)(se,{}),` `,o(`debug.refresh`)]}),(0,z.jsxs)(`label`,{className:`muted text-control`,style:{cursor:`pointer`,display:`inline-flex`,alignItems:`center`,gap:6},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>a(e.target.checked)}),o(`debug.follow`)]})]})]}),(0,z.jsx)(`p`,{className:`page-sub`,children:o(`debug.subtitle`)})]})}function rl(e){return`debug-settings:${e}`}function il({apiBase:e,embedded:t,active:n=!0}){let{t:r}=Ve(),i=`ocx.debug.settings.v1:${e}`,a=Y(i),o=rl(e),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(`provider`),[d,f]=(0,_.useState)([]),[p,m]=(0,_.useState)(!0),[h,g]=(0,_.useState)(!1),v=(0,_.useRef)(0),y=(0,_.useRef)(0),b=(0,_.useRef)(0),x=(0,_.useRef)(null),S=(0,_.useRef)(null),C=(0,_.useRef)(null),w=us(o,[e],async t=>{let n=await fetch(`${e}/api/debug`,{signal:t});if(!n.ok)throw Error(String(n.status));let r=await n.json();return X(i,r),r},{pollMs:2e3,enabled:n,isEmpty:()=>!1,initialData:a??void 0}),T=w.state,E=w.data??a??null,D=I(`debug-claude-inbound:${e}`,[e,E?.claude],async t=>{let n=await fetch(`${e}/api/claude/inbound-debug`,{signal:t});if(!n.ok)return[];let r=await n.json();return Array.isArray(r.entries)?r.entries:[]},{pollMs:2e3,enabled:n&&!!E?.claude}).data??[],O=Rc({count:d.length,getScrollElement:()=>S.current,estimateSize:()=>20,overscan:30,getItemKey:e=>d[e].seq}),k=(0,_.useCallback)(e=>Zc(E,e),[E]);(0,_.useEffect)(()=>{if(!E||k(l))return;let e=Jc.find(k);if(!e)return;let t=window.setTimeout(()=>u(e),0);return()=>window.clearTimeout(t)},[E,l,k]);let A=k(l),j=l===`provider`?`${e}/api/debug/logs`:l===`usage`?`${e}/api/debug/usage-logs`:`${e}/api/debug/injection-logs`,M=(0,_.useCallback)(async(e,t)=>{let n=++b.current;if(!A){n===b.current&&(f([]),v.current=0);return}g(!0);try{let r=new URLSearchParams({limit:`500`});!e&&v.current>0&&r.set(`after`,String(v.current));let i=await fetch(`${j}?${r}`,{signal:t});if(!i.ok||t?.aborted||n!==b.current)return;let a=await i.json();if(t?.aborted||n!==b.current||a.length===0)return;f(t=>(e?a:[...t,...a]).slice(-2e3)),v.current=a[a.length-1].seq}catch{}finally{n===b.current&&g(!1)}},[j,A]);(0,_.useEffect)(()=>{if(!n)return;let t=`${e}:${l}:${A}`,r=C.current!==t;if(C.current=t,!r&&d.length>0)return;v.current=0;let i=new AbortController,a=window.setTimeout(()=>{r&&f([]),M(!0,i.signal)},0);return()=>{window.clearTimeout(a),b.current+=1,i.abort()}},[n,e,l,A]);let N=(0,_.useEffectEvent)(e=>{M(e)});(0,_.useEffect)(()=>{if(!n||!p||!A)return;let e=setInterval(()=>N(!1),1e3);return()=>clearInterval(e)},[n,p,A]),(0,_.useEffect)(()=>{p&&d.length>0&&O.scrollToIndex(d.length-1,{align:`end`})},[d,p,O]);let P=async t=>{let n=++y.current;c(!0);let r=async()=>{try{let r=await fetch(`${e}/api/debug`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!r.ok)return;let a=await r.json();if(n!==y.current)return;X(i,a),L(o,a)}catch{}},a=(x.current??Promise.resolve()).then(r,r);x.current=a.then(()=>void 0,()=>void 0);try{await a}finally{n===y.current&&c(!1)}},F=async(e,t)=>{await P({[e]:t})},R=async()=>{await P({reset:!0})};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(nl,{embedded:t,refreshing:h,streamEnabled:A,follow:p,onRefresh:()=>void M(!0),onFollowChange:m}),!E&&T.showError?(0,z.jsxs)(`div`,{className:`notice notice-err`,role:`alert`,children:[(0,z.jsx)(`span`,{children:r(`debug.loadFailed`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>w.refresh(),children:r(`common.retry`)})]}):T.showSkeleton&&!E?(0,z.jsx)(fs,{label:r(`debug.loading`),rows:3}):E?(0,z.jsx)(tl,{debug:E,debugBusy:s,stream:l,onSetFlag:(e,t)=>{F(e,t)},onReset:()=>{R()},onStreamChange:u}):null,E&&T.showError&&(0,z.jsx)(q,{tone:`err`,children:r(`debug.loadFailed`)}),E?.claude&&(0,z.jsx)($c,{entries:D}),(0,z.jsx)(el,{debug:!!E,stream:l,streamEnabled:A,entries:d,scrollContainerRef:S,lineVirtualizer:O})]})}function al(){return window.location.hash.replace(/^#\/?/,``)===`logs/debug`?`debug`:`logs`}function ol(e){window.location.hash=e===`debug`?`logs/debug`:`logs`}function sl(e){e.key===`ArrowLeft`||e.key===`Home`?(e.preventDefault(),ol(`logs`),document.getElementById(`logs-tab-logs`)?.focus()):(e.key===`ArrowRight`||e.key===`End`)&&(e.preventDefault(),ol(`debug`),document.getElementById(`logs-tab-debug`)?.focus())}function cl(e){return e.requestedSpeedLabel||void 0}function ll(e,t){return t===`all`?!0:t===`claude`?e.surface===`claude`||e.surface===`claude-desktop`:t===`grok`?e.surface===`grok`:e.surface===void 0}function ul(e){return`ocx.logs.list.v1:${e}`}function dl(e){if(!Array.isArray(e))return null;for(let t of e)if(!t||typeof t!=`object`||typeof t.timestamp!=`number`||typeof t.model!=`string`||typeof t.provider!=`string`||typeof t.status!=`number`||typeof t.durationMs!=`number`)return null;return e}function fl(e){return e===`cursor`||e.startsWith(`cursor-`)}function pl(e,t){if(!e.usage)return;let n=gl(e),r=[`${t(`logs.tokens.input`)}=${e.usage.inputTokens}`,`${t(`logs.tokens.output`)}=${e.usage.outputTokens}`];return n.read!==void 0&&r.push(`${t(`logs.tokens.cacheRead`)}=${n.read}`),n.write!==void 0&&r.push(`${t(`logs.tokens.cacheWrite`)}=${n.write}`),typeof e.usage.contextTotalTokens==`number`&&r.push(`${t(`logs.tokens.contextTotal`)}=${e.usage.contextTotalTokens}`),typeof e.usage.reasoningOutputTokens==`number`&&r.push(`${t(`logs.tokens.reasoning`)}=${e.usage.reasoningOutputTokens}`),e.usageStatus===`estimated`&&r.push(t(`logs.tokens.estimatedNote`)),e.usageStatus===`estimated`&&n.read===void 0&&n.write===void 0&&r.push(t(fl(e.provider)?`logs.tokens.noCacheCursorNote`:`logs.tokens.noCacheNote`)),r.join(` · `)}function ml(e){if(!e.usage)return typeof e.totalTokens==`number`?e.totalTokens:void 0;let t=e.usage.inputTokens+e.usage.outputTokens,n=e.usage.totalTokens??e.totalTokens;return typeof n==`number`?Math.max(n,t):t}function hl(e){let t=ml(e),n=e.usage?.contextTotalTokens;return typeof n==`number`?Math.max(t??0,n)||void 0:t}function gl(e){let t=e.usage;if(!t)return{};let n=typeof t.cacheCreationInputTokens==`number`?t.cacheCreationInputTokens:void 0;return{read:typeof t.cacheReadInputTokens==`number`?t.cacheReadInputTokens:typeof t.cachedInputTokens==`number`&&n!==void 0?Math.max(0,t.cachedInputTokens-n):t.cachedInputTokens,write:n}}function _l(e){let t=e.requestedEffort?.replace(/\s*->\s*/g,` → `),n=e.effectiveEffort;return t?!n||t===n||t.split(` → `).at(-1)===n?t:`${t} → ${n}`:n??`-`}function vl(e){if(!(!e.reasoningWireField||e.reasoningWireValue===void 0))return`${e.reasoningWireField}=${e.reasoningWireValue}`}function yl(e,t){if(!e||e.kind===`unavailable`||!Number.isFinite(e.value)||e.value<=0)return`—`;let n=e.value>=100?0:1,r=new Intl.NumberFormat(t,{minimumFractionDigits:n,maximumFractionDigits:n}).format(e.value);return`${e.estimated?`~`:``}${r}`}function bl(e,t){if(!e||e.kind===`unavailable`||!Number.isFinite(e.estimate.cost.total)||e.estimate.cost.total<0)return`—`;let n=e.estimate.cost.total;return`~$${new Intl.NumberFormat(t,{minimumFractionDigits:4,maximumFractionDigits:4}).format(n)}`}function xl(e,t){return!Number.isFinite(e)||e<0?`—`:`~$${new Intl.NumberFormat(t,{minimumFractionDigits:4,maximumFractionDigits:4}).format(e)}`}var Sl=3,Cl={usage_missing:`logs.detail.reason.usage_missing`,usage_unsupported:`logs.detail.reason.usage_unsupported`,output_missing:`logs.detail.reason.output_missing`,invalid_duration:`logs.detail.reason.invalid_duration`,price_unmatched:`logs.detail.reason.price_unmatched`,invalid_cache_breakdown:`logs.detail.reason.invalid_cache_breakdown`,invalid_usage:`logs.detail.reason.invalid_usage`,combo_attempt_unavailable:`logs.detail.reason.combo_attempt_unavailable`},wl={usage_estimated:`logs.detail.estimate.usage_estimated`,cache_detail_missing:`logs.detail.estimate.cache_detail_missing`,expected_price_overlay:`logs.detail.estimate.expected_price_overlay`};function Tl(e){return Cl[e]}function El(e){return wl[e]}function Dl(e){return e===`verified`?`logs.detail.verification.verified`:`logs.detail.verification.derived`}function Ol(e){return e>=200&&e<300?`var(--green)`:e>=400?`var(--red)`:`var(--amber)`}function kl(e,t,n){let r=n?{timeZone:n}:void 0;try{return{date:new Date(e).toLocaleDateString(t,r),time:new Date(e).toLocaleTimeString(t,r)}}catch{return{date:new Date(e).toLocaleDateString(t),time:new Date(e).toLocaleTimeString(t)}}}function Al(e,t,n){let{date:r,time:i}=kl(e,t,n);return`${r} ${i}`}function jl(e){return[`model=${e.model}`,e.resolvedModel?`resolved=${e.resolvedModel}`:void 0,e.requestedServiceTier?`requestedTier=${e.requestedServiceTier}`:void 0,e.configuredServiceTier?`configuredTier=${e.configuredServiceTier}`:void 0,e.responseServiceTier?`responseTier=${e.responseServiceTier}`:void 0,e.modelSupportsServiceTier===void 0?void 0:`supportsTier=${e.modelSupportsServiceTier}`].filter(Boolean).join(` · `)}function Ml(e){let t=0,n=0,r=0,i=0;for(let a of e){let e=ml(a);if(e!==void 0&&(t+=e),a.usageStatus===`unsupported`){i+=1;continue}let o=a.displayMetrics?.cost,s=o?.kind===`value`?o.estimate.cost.total:void 0;if(s!==void 0&&Number.isFinite(s)&&s>=0){n+=s;continue}r+=1}return{requests:e.length,totalTokens:t,estimatedCostUsd:n,unpricedRequests:r,unmeteredRequests:i}}function Nl({apiBase:e}){let{t,locale:n}=Ve(),r=ul(e),i=dl(Y(r)),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(`all`),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(),h=(0,_.useRef)(null),g=Ie.find(e=>e.code===n)?.htmlLang,[v,y]=(0,_.useState)();(0,_.useEffect)(()=>{let t=new AbortController,n=!1;return fetch(`${e}/api/settings`,{signal:t.signal}).then(e=>e.ok?e.json():null).then(e=>{n||!e||typeof e.timeZone==`string`&&e.timeZone.trim()&&y(e.timeZone.trim())}).catch(()=>{}),()=>{n=!0,t.abort()}},[e]);let[b,x]=(0,_.useState)(al),[S,C]=(0,_.useState)(()=>al()===`debug`);(0,_.useEffect)(()=>{let e=()=>x(al());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),(0,_.useEffect)(()=>{b===`debug`&&C(!0)},[b]);let w=ol,T=(0,_.useCallback)(async t=>{let n=await fetch(`${e}/api/logs?limit=2000`,{signal:t});if(!n.ok)throw Error(`${n.status} ${n.statusText}`.trim());let i=await n.json(),a=Array.isArray(i)?i:i.logs??[];return X(r,a),a},[e,r]),E=us(r,[e],T,{isEmpty:e=>e.length===0,enabled:b===`logs`,pollMs:a?2e3:void 0,initialData:i??void 0}),D=E.state,O=D.data??i??[],k=E.refresh,A=!E.refreshing&&D.showError,j=!E.refreshing&&!D.showError&&D.data!==void 0,[M,N]=(0,_.useState)({error:null,count:0});j&&M.count!==0?N({error:null,count:0}):A&&M.error!==D.error&&N(e=>({error:D.error,count:e.count+1}));let P=M.count>=Sl||!a&&A,F=s?qc(s.status,n):null,I=d.trim();(0,_.useEffect)(()=>{let e=!1;if(!I){m(void 0);return}return Hc(I).then(t=>{e||m(t)}),()=>{e=!0}},[I]);let L=O.filter(e=>ll(e,l)&&(!I||Uc(e.conversationId,I,p))),R=I?Ml(L):null,B=Rc({count:L.length,getScrollElement:()=>h.current,estimateSize:()=>44,overscan:15}),V=B.getVirtualItems(),H=V.length>0?V[0].start:0,U=V.length>0?B.getTotalSize()-V[V.length-1].end:0;return(0,z.jsxs)(`div`,{className:`logs-page`,children:[(0,z.jsxs)(`div`,{className:`page-head`,children:[(0,z.jsx)(`h2`,{children:t(`nav.logs`)}),b===`logs`&&(0,z.jsxs)(`label`,{className:`muted text-control logs-auto-refresh`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),t(`logs.autoRefresh`)]})]}),(0,z.jsxs)(`div`,{className:`page-tabs`,role:`tablist`,"aria-label":t(`nav.logs`),children:[(0,z.jsx)(`button`,{type:`button`,role:`tab`,id:`logs-tab-logs`,"aria-selected":b===`logs`,"aria-controls":`logs-panel-logs`,tabIndex:b===`logs`?0:-1,className:`page-tab${b===`logs`?` page-tab--active`:``}`,onClick:()=>w(`logs`),onKeyDown:sl,children:t(`logs.tabLogs`)}),(0,z.jsx)(`button`,{type:`button`,role:`tab`,id:`logs-tab-debug`,"aria-selected":b===`debug`,"aria-controls":`logs-panel-debug`,tabIndex:b===`debug`?0:-1,className:`page-tab${b===`debug`?` page-tab--active`:``}`,onClick:()=>w(`debug`),onKeyDown:sl,children:t(`logs.tabDebug`)})]}),S&&(0,z.jsx)(`div`,{role:`tabpanel`,id:`logs-panel-debug`,"aria-labelledby":`logs-tab-debug`,hidden:b!==`debug`,children:(0,z.jsx)(il,{apiBase:e,embedded:!0,active:b===`debug`})}),(0,z.jsxs)(`div`,{role:`tabpanel`,id:`logs-panel-logs`,"aria-labelledby":`logs-tab-logs`,hidden:b!==`logs`,children:[(0,z.jsx)(`p`,{className:`page-sub`,children:t(`logs.subtitle`)}),(0,z.jsxs)(`div`,{className:`logs-toolbar`,children:[(0,z.jsx)(`span`,{className:`muted text-control`,children:t(`logs.filter.surface.label`)}),(0,z.jsx)(`div`,{className:`segmented logs-segmented`,role:`radiogroup`,"aria-label":t(`logs.filter.surface.label`),children:[`all`,`claude`,`codex`,`grok`].map(e=>(0,z.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":l===e,className:`btn btn-sm${l===e?` btn-primary`:` btn-ghost`}`,style:{background:l===e?void 0:`transparent`,color:l===e?void 0:`var(--muted)`},onClick:()=>u(e),children:t(`logs.filter.surface.${e}`)},e))}),(0,z.jsxs)(`label`,{className:`muted text-control logs-filter-field`,children:[t(`logs.filter.conversation.label`),(0,z.jsx)(`input`,{type:`search`,className:`input mono`,value:d,onChange:e=>f(e.target.value),placeholder:t(`logs.filter.conversation.placeholder`),"aria-label":t(`logs.filter.conversation.label`)})]}),I&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>f(``),children:t(`logs.filter.conversation.clear`)})]}),R&&(0,z.jsx)(`div`,{className:`logs-conversation-totals`,children:(0,z.jsxs)(q,{tone:`ok`,children:[t(`logs.conversation.totals`,{requests:R.requests,tokens:Pt(R.totalTokens,g??n),cost:xl(R.estimatedCostUsd,g)}),` `,(0,z.jsxs)(`span`,{className:`muted`,children:[t(`logs.conversation.scope`),R.unpricedRequests+R.unmeteredRequests>0?` ${t(`logs.conversation.excluded`,{unpriced:R.unpricedRequests,unmetered:R.unmeteredRequests})}`:``]})]})}),D.kind===`failed-cold`&&(0,z.jsxs)(q,{tone:`err`,children:[D.error instanceof Error?`${t(`logs.loadError`)} ${D.error.message}`:t(`logs.loadError`),` `,(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>k({forceLoading:!0}),disabled:D.refreshing,children:t(`common.retry`)})]}),P&&O.length>0&&(0,z.jsxs)(q,{tone:`err`,children:[t(`logs.loadError`),` `,(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>k({forceLoading:!0}),disabled:E.refreshing,children:t(`common.retry`)})]}),D.kind===`failed-cold`?null:D.showSkeleton&&O.length===0?(0,z.jsx)(fs,{label:t(`common.loading`),rows:6}):L.length===0?(0,z.jsx)(ot,{title:t(`logs.noRequests`)}):(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(`div`,{ref:h,className:`tbl-wrap logs-table-wrap`,children:(0,z.jsxs)(`table`,{className:`tbl logs-table`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:t(`logs.col.time`)}),(0,z.jsx)(`th`,{className:`num log-col-tokens`,children:t(`logs.col.tokens`)}),(0,z.jsx)(`th`,{className:`num log-col-rate`,title:t(`logs.metric.tokPerSecTitle`),children:t(`logs.col.tokPerSec`)}),(0,z.jsx)(`th`,{className:`num log-col-cost`,title:t(`logs.metric.estimatedCostTitle`),children:t(`logs.col.estimatedCost`)}),(0,z.jsx)(`th`,{className:`log-col-model`,children:t(`logs.col.model`)}),(0,z.jsx)(`th`,{children:t(`logs.col.effort`)}),(0,z.jsx)(`th`,{children:t(`logs.col.provider`)}),(0,z.jsx)(`th`,{children:t(`logs.col.status`)}),(0,z.jsx)(`th`,{children:t(`logs.col.request`)}),(0,z.jsx)(`th`,{className:`num log-col-duration`,children:t(`logs.col.duration`)})]})}),(0,z.jsxs)(`tbody`,{children:[H>0&&(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:10,className:`logs-virtual-spacer`,style:{height:H}})}),V.map(e=>{let r=L[L.length-1-e.index],i=vl(r),a=kl(r.timestamp,g,v);return(0,z.jsxs)(`tr`,{"data-index":e.index,ref:B.measureElement,children:[(0,z.jsx)(`td`,{className:`muted mono log-col-time`,children:(0,z.jsxs)(`span`,{className:`logs-stack-start`,children:[(0,z.jsx)(`span`,{children:a.date}),(0,z.jsx)(`span`,{children:a.time})]})}),(0,z.jsx)(`td`,{className:`num mono log-col-tokens`,title:pl(r,t),children:(()=>{let e=hl(r),{read:i,write:a}=gl(r);return e===void 0?(0,z.jsx)(`span`,{className:`muted`,children:t(`logs.tokens.${r.usageStatus??`unreported`}`)}):(0,z.jsxs)(`span`,{className:`logs-stack-end`,children:[(0,z.jsxs)(`span`,{children:[r.usageStatus===`estimated`?`~`:``,Pt(e,n)]}),i!==void 0&&i>0&&(0,z.jsxs)(`span`,{className:`muted text-caption leading-tight`,children:[`c `,Pt(i,n)]}),a!==void 0&&a>0&&(0,z.jsxs)(`span`,{className:`muted text-caption leading-tight`,children:[`w `,Pt(a,n)]}),r.usageStatus===`estimated`&&i===void 0&&a===void 0&&(0,z.jsx)(`span`,{className:`muted text-caption leading-tight`,children:t(fl(r.provider)?`logs.tokens.noCacheCursor`:`logs.tokens.noCache`)})]})})()}),(0,z.jsx)(`td`,{className:`num mono log-col-rate`,children:yl(r.displayMetrics?.tokPerSecond,g)}),(0,z.jsx)(`td`,{className:`num mono log-col-cost`,children:bl(r.displayMetrics?.cost,g)}),(0,z.jsx)(`td`,{className:`mono log-col-model`,title:jl(r),children:(0,z.jsxs)(`span`,{className:`logs-model-cell`,children:[(0,z.jsx)(`span`,{children:zo(r.resolvedModel??r.model)}),(r.surface===`claude`||r.surface===`claude-desktop`)&&(0,z.jsx)(`span`,{className:`badge badge-accent`,children:t(`logs.badge.claude`)}),r.surface===`grok`&&(0,z.jsx)(`span`,{className:`badge badge-accent`,children:t(`logs.badge.grok`)}),cl(r)&&(0,z.jsx)(`span`,{className:`badge badge-amber`,children:cl(r)})]})}),(0,z.jsx)(`td`,{className:`mono log-reasoning-cell`,title:i,children:(0,z.jsxs)(`span`,{className:`logs-stack-start`,children:[(0,z.jsx)(`span`,{children:_l(r)}),i&&(0,z.jsx)(`span`,{className:`muted text-caption leading-tight`,children:i})]})}),(0,z.jsx)(`td`,{className:`muted`,children:r.provider}),(0,z.jsx)(`td`,{children:(0,z.jsxs)(`span`,{className:`log-status-cell`,children:[(0,z.jsx)(`span`,{className:`mono font-semibold`,style:{color:Ol(r.status)},children:r.status}),(0,z.jsx)(`button`,{type:`button`,className:`log-detail-btn`,onClick:()=>c(r),"aria-label":`${t(`logs.details`)}: ${r.requestId??r.status}`,children:t(`logs.details`)})]})}),(0,z.jsx)(`td`,{className:`muted mono`,children:(0,z.jsx)(`span`,{className:`log-reqid`,title:r.requestId,children:r.requestId??`-`})}),(0,z.jsxs)(`td`,{className:`num log-col-duration`,children:[r.durationMs,`ms`]})]},r.requestId??`${r.timestamp}-${e.index}`)}),U>0&&(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:10,className:`logs-virtual-spacer`,style:{height:U}})})]})]})})}),s&&(0,z.jsx)(Q,{detail:s,detailInfo:F,localeCode:n,localeTag:g,serverTimeZone:v,t,onClose:()=>c(null),onFilterConversation:e=>{f(e),c(null)}})]})]})}function Pl(e){let t=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let n=t.current;n&&(e&&!n.open?n.showModal():!e&&n.open&&n.close())},[e]),t}function Q({detail:e,detailInfo:t,localeCode:n,localeTag:r,serverTimeZone:i,t:a,onClose:o,onFilterConversation:s}){let c=Pl(!0),[l,u]=(0,_.useState)(!1),d=gl(e),f=e.displayMetrics?.cost,p=vl(e),m=async()=>{if(e.requestId)try{await navigator.clipboard.writeText(e.requestId),u(!0),window.setTimeout(()=>u(!1),1200)}catch{}};return(0,z.jsx)(`dialog`,{ref:c,className:`modal-overlay`,"aria-labelledby":`log-detail-title`,onCancel:e=>{e.preventDefault(),o()},children:(0,z.jsxs)(`div`,{className:`modal-card log-detail-card`,children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsxs)(`h3`,{id:`log-detail-title`,children:[(0,z.jsx)(`span`,{className:`mono`,style:{color:Ol(e.status)},children:e.status}),t&&(0,z.jsx)(`span`,{className:`logs-detail-info`,children:t.label})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:o,"aria-label":a(`common.cancel`),children:(0,z.jsx)(ae,{})})]}),t&&(0,z.jsx)(`p`,{className:`modal-desc`,children:t.description}),(0,z.jsxs)(`section`,{className:`log-detail-section`,"aria-labelledby":`log-detail-basic`,children:[(0,z.jsx)(`h4`,{id:`log-detail-basic`,className:`log-detail-section-title`,children:a(`logs.detail.section.basic`)}),(0,z.jsxs)(`div`,{className:`log-detail-grid`,children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.time`)}),(0,z.jsx)(`span`,{className:`mono`,children:Al(e.timestamp,r,i)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.request`)}),(0,z.jsxs)(`span`,{className:`log-detail-request-row`,children:[(0,z.jsx)(`span`,{className:`mono log-detail-break`,children:e.requestId??`—`}),e.requestId&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void m(),children:a(l?`logs.detail.copied`:`logs.detail.copyRequestId`)})]}),e.conversationId&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.detail.conversation`)}),(0,z.jsxs)(`span`,{className:`log-detail-request-row`,children:[(0,z.jsx)(`span`,{className:`mono log-detail-break`,children:e.conversationId}),s&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>s(e.conversationId),children:a(`logs.filter.conversation.apply`)})]})]}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.model`)}),(0,z.jsx)(`span`,{className:`mono`,children:zo(e.resolvedModel??e.model)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.provider`)}),(0,z.jsx)(`span`,{children:e.provider}),(e.requestedEffort||e.effectiveEffort)&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.effort`)}),(0,z.jsxs)(`span`,{className:`mono`,children:[_l(e),p?` (${p})`:``]})]}),e.errorCode&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.error`)}),(0,z.jsx)(`span`,{className:`mono`,children:e.errorCode})]}),e.upstreamError&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.upstreamReason`)}),(0,z.jsx)(`span`,{className:`mono log-detail-break`,children:e.upstreamError})]})]})]}),(0,z.jsxs)(`section`,{className:`log-detail-section`,"aria-labelledby":`log-detail-performance`,children:[(0,z.jsx)(`h4`,{id:`log-detail-performance`,className:`log-detail-section-title`,children:a(`logs.detail.section.performance`)}),(0,z.jsxs)(`div`,{className:`log-detail-grid`,children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.duration`)}),(0,z.jsxs)(`span`,{className:`mono`,children:[e.durationMs,`ms`]}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.tokPerSec`)}),(0,z.jsx)(`span`,{className:`mono`,children:yl(e.displayMetrics?.tokPerSecond,r)}),e.firstOutputMs!==void 0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.detail.ttft`)}),(0,z.jsxs)(`span`,{className:`mono`,children:[e.firstOutputMs,`ms`]})]})]}),e.displayMetrics?.tokPerSecond.kind===`unavailable`&&(0,z.jsx)(`p`,{className:`log-detail-notes-line muted`,children:a(Tl(e.displayMetrics.tokPerSecond.reason))})]}),(0,z.jsxs)(`section`,{className:`log-detail-section`,"aria-labelledby":`log-detail-cost`,children:[(0,z.jsx)(`h4`,{id:`log-detail-cost`,className:`log-detail-section-title`,children:a(`logs.detail.section.cost`)}),(0,z.jsx)(`p`,{className:`log-detail-notes-line muted`,children:a(`usage.cost.disclaimer`)}),f?.kind===`value`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`log-detail-grid`,children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.detail.costTotal`)}),(0,z.jsx)(`span`,{className:`mono`,children:xl(f.estimate.cost.total,r)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.input`)}),(0,z.jsx)(`span`,{className:`mono`,children:xl(f.estimate.cost.input,r)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.cacheRead`)}),(0,z.jsx)(`span`,{className:`mono`,children:xl(f.estimate.cost.cacheRead,r)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.cacheWrite`)}),(0,z.jsx)(`span`,{className:`mono`,children:xl(f.estimate.cost.cacheWrite,r)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.output`)}),(0,z.jsx)(`span`,{className:`mono`,children:xl(f.estimate.cost.output,r)}),f.estimate.price&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.detail.matchedKey`)}),(0,z.jsxs)(`span`,{className:`mono log-detail-break`,children:[f.estimate.price.jawcodeProvider??f.estimate.price.provider,`/`,f.estimate.price.modelId]}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.detail.priceSource`)}),(0,z.jsxs)(`span`,{children:[a(`logs.detail.source.${f.estimate.price.source}`),` · `,a(Dl(f.estimate.price.status))]})]})]}),f.estimateReasons.length>0&&(0,z.jsx)(`ul`,{className:`log-detail-notes`,children:f.estimateReasons.map(e=>(0,z.jsx)(`li`,{children:a(El(e))},e))})]}):(0,z.jsxs)(`div`,{className:`log-detail-grid`,children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.detail.costTotal`)}),(0,z.jsx)(`span`,{className:`mono`,children:`—`}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.detail.unavailableReason`)}),(0,z.jsx)(`span`,{children:f?.kind===`unavailable`?a(Tl(f.reason)):a(`logs.detail.reason.usage_missing`)})]})]}),e.attempts?.length?(0,z.jsxs)(`section`,{className:`log-detail-section`,"aria-labelledby":`log-detail-attempts`,children:[(0,z.jsx)(`h4`,{id:`log-detail-attempts`,className:`log-detail-section-title`,children:a(`logs.detail.section.attempts`)}),(0,z.jsx)(`p`,{className:`log-detail-notes-line muted`,children:a(`logs.detail.attempt.e2eNote`)}),(0,z.jsx)(`div`,{className:`log-detail-attempts-wrap`,children:(0,z.jsxs)(`table`,{className:`tbl log-detail-attempts`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{className:`num`,children:`#`}),(0,z.jsx)(`th`,{children:a(`logs.detail.attempt.target`)}),(0,z.jsx)(`th`,{className:`num`,children:a(`logs.col.duration`)}),(0,z.jsx)(`th`,{className:`num`,children:a(`logs.col.tokPerSec`)}),(0,z.jsx)(`th`,{className:`num`,children:a(`logs.col.estimatedCost`)}),(0,z.jsx)(`th`,{children:a(`logs.detail.attempt.reason`)})]})}),(0,z.jsx)(`tbody`,{children:e.attempts.toSorted((e,t)=>e.ordinal-t.ordinal).map(e=>{let t=e.displayMetrics?.cost,n=vl(e),i=t?.kind===`value`?t.estimate.price:void 0,o=e.errorCode??(e.recoveryKinds.length?e.recoveryKinds.join(`, `):void 0)??(t?.kind===`unavailable`?a(Tl(t.reason)):a(`logs.detail.attempt.completed`));return(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`num mono`,children:e.ordinal}),(0,z.jsxs)(`td`,{children:[(0,z.jsx)(`span`,{children:e.provider}),(0,z.jsx)(`br`,{}),(0,z.jsx)(`span`,{className:`mono muted log-detail-break`,children:e.model}),(e.requestedEffort||e.effectiveEffort)&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`br`,{}),(0,z.jsxs)(`span`,{className:`mono muted text-caption log-detail-break`,children:[_l(e),n?` (${n})`:``]})]}),i&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`br`,{}),(0,z.jsxs)(`span`,{className:`muted text-caption log-detail-break`,children:[i.jawcodeProvider??i.provider,`/`,i.modelId,` · `,a(`logs.detail.source.${i.source}`),` · `,a(Dl(i.status))]})]})]}),(0,z.jsxs)(`td`,{className:`num mono`,children:[e.durationMs,`ms`]}),(0,z.jsx)(`td`,{className:`num mono`,children:yl(e.displayMetrics?.tokPerSecond,r)}),(0,z.jsx)(`td`,{className:`num mono`,children:bl(t,r)}),(0,z.jsx)(`td`,{className:`log-detail-break`,children:o})]},`${e.ordinal}-${e.provider}-${e.model}`)})})]})})]}):null,(0,z.jsxs)(`section`,{className:`log-detail-section`,"aria-labelledby":`log-detail-usage`,children:[(0,z.jsx)(`h4`,{id:`log-detail-usage`,className:`log-detail-section-title`,children:a(`logs.detail.section.usage`)}),(0,z.jsxs)(`div`,{className:`log-detail-grid`,children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.input`)}),(0,z.jsx)(`span`,{className:`mono`,children:e.usage?Pt(e.usage.inputTokens,n):`—`}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.output`)}),(0,z.jsx)(`span`,{className:`mono`,children:e.usage?Pt(e.usage.outputTokens,n):`—`}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.cacheRead`)}),(0,z.jsx)(`span`,{className:`mono`,children:d.read===void 0?`—`:Pt(d.read,n)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.cacheWrite`)}),(0,z.jsx)(`span`,{className:`mono`,children:d.write===void 0?`—`:Pt(d.write,n)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.reasoning`)}),(0,z.jsx)(`span`,{className:`mono`,children:e.usage?.reasoningOutputTokens===void 0?`—`:Pt(e.usage.reasoningOutputTokens,n)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.detail.totalTokens`)}),(0,z.jsx)(`span`,{className:`mono`,children:hl(e)===void 0?`—`:Pt(hl(e),n)}),e.usage?.contextTotalTokens!==void 0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.contextTotal`)}),(0,z.jsx)(`span`,{className:`mono`,children:Pt(e.usage.contextTotalTokens,n)})]})]}),e.usageStatus===`estimated`&&(0,z.jsx)(`p`,{className:`log-detail-notes-line muted`,children:a(`logs.tokens.estimatedNote`)})]}),(0,z.jsxs)(`details`,{className:`log-detail-raw`,children:[(0,z.jsx)(`summary`,{children:a(`logs.detailRaw`)}),(0,z.jsx)(`pre`,{className:`log-detail-json`,children:JSON.stringify(e,null,2)})]})]})})}function Fl(e){return`${Math.round(e*100)}%`}function Il(e,t){let n=`${t}/${e}`,r=0;for(let e=0;e<n.length;e++)r=r*31+n.charCodeAt(e)>>>0;return`hsl(${r%360} 55% 55%)`}function Ll(e){let t=new Map(e.map(e=>[e.date,e])),n=[],r=new Date;r.setHours(0,0,0,0),r.setDate(r.getDate()-6);for(let e=0;e<7;e++){let e=`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,`0`)}-${String(r.getDate()).padStart(2,`0`)}`,i=t.get(e);n.push({date:e,requests:i?.requests??0,measuredRequests:i?.measuredRequests??0,reportedRequests:i?.reportedRequests??0,totalTokens:i?.totalTokens??0,models:i?.models??[]}),r.setDate(r.getDate()+1)}return n}function Rl(e){let t=e.filter(e=>e>0).sort((e,t)=>e-t);if(t.length===0)return[0,0,0,0];let n=e=>t[Math.min(t.length-1,Math.floor(e*t.length))];return[n(.25),n(.5),n(.75),n(.95)]}function zl(e,t){return e<=0?0:e<=t[0]?1:e<=t[1]?2:e<=t[2]?3:4}function Bl(e){let t=Rl(e.map(e=>e.totalTokens)),n=new Map(e.map(e=>[e.date,e])),r=new Date;r.setHours(0,0,0,0);let i=new Date(r);i.setDate(i.getDate()-364),i.setDate(i.getDate()-i.getDay());let a=[],o=[],s=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],c=-4,l=-1,u=[],d=new Date(i);for(;d<=r;){let e=`${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,`0`)}-${String(d.getDate()).padStart(2,`0`)}`,r=d.getMonth();d.getDay()===0&&r!==l&&a.length-c>=4&&(o.push({label:s[r],col:a.length}),c=a.length,l=r);let i=n.get(e);u.push({date:e,requests:i?.requests??0,totalTokens:i?.totalTokens??0,level:i?zl(i.totalTokens,t):0,dayOfWeek:d.getDay()}),d.getDay()===6&&(a.push(u),u=[]),d.setDate(d.getDate()+1)}if(u.length>0){for(;u.length<7;)u.push({date:``,requests:0,totalTokens:0,level:0,dayOfWeek:u.length});a.push(u)}return{weeks:a,months:o,buckets:t}}function Vl({surface:e,range:t,onSurface:n,onRange:r,t:i}){return(0,z.jsxs)(`div`,{className:`usage-filters`,children:[(0,z.jsx)(`div`,{className:`usage-segmented`,role:`group`,"aria-label":i(`logs.filter.surface.label`),children:[`all`,`codex`,`claude`,`grok`].map(t=>{let r=i(`logs.filter.surface.${t}`);return(0,z.jsxs)(`button`,{type:`button`,className:`usage-segmented-btn usage-source-btn${e===t?` active`:``}`,"aria-label":r,"aria-pressed":e===t,onClick:()=>n(t),children:[t===`codex`&&(0,z.jsx)(`img`,{className:`usage-source-mark`,src:`/provider-icons/openai.svg`,alt:``,"aria-hidden":`true`}),t===`claude`&&(0,z.jsx)(`img`,{className:`usage-source-mark`,src:`/provider-icons/claude.svg`,alt:``,"aria-hidden":`true`}),t===`grok`&&(0,z.jsx)(`img`,{className:`usage-source-mark`,src:`/provider-icons/grok.svg`,alt:``,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:t===`all`?`usage-source-label`:`usage-source-label usage-source-label-collapsible`,children:r})]},t)})}),(0,z.jsx)(`div`,{className:`usage-segmented`,role:`group`,"aria-label":i(`usage.title`),children:[`all`,`30d`,`7d`].map(e=>{let n=i(e===`all`?`usage.range.available`:`usage.range.${e}`);return(0,z.jsx)(`button`,{type:`button`,className:`usage-segmented-btn${t===e?` active`:``}`,"aria-label":n,"aria-pressed":t===e,onClick:()=>r(e),children:n},e)})})]})}function Hl({summary:e,activeDays:t,locale:n,t:r}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`usage-cards usage-cards-3x2`,role:`group`,"aria-label":r(`usage.title`),children:[(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:r(`usage.card.requests`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:e.requests})]}),(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:r(`usage.card.measured`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:e.measuredRequests})]}),(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:r(`usage.card.totalTokens`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:Pt(e.totalTokens,n)})]}),(0,z.jsxs)(`div`,{className:`stat`,title:r(`usage.card.cachedTokensHint`),children:[(0,z.jsx)(`div`,{className:`muted`,children:r(`usage.card.cachedTokens`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:Pt(e.cacheReadInputTokens??e.cachedInputTokens,n)}),(e.cacheCreationInputTokens??0)>0&&(0,z.jsxs)(`div`,{className:`muted text-caption`,children:[r(`usage.card.cacheWriteTokens`),`: `,Pt(e.cacheCreationInputTokens??0,n)]})]}),(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:r(`usage.card.coverage`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:Fl(e.coverageRatio)})]}),(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:r(`usage.card.activeDays`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:t})]})]}),e.estimatedCostUsd!==void 0&&(0,z.jsxs)(`div`,{className:`usage-cost-row`,role:`note`,children:[(0,z.jsx)(`span`,{className:`muted`,children:r(`usage.cost.total`)}),(0,z.jsx)(`span`,{className:`stat-value mono usage-cost-value`,children:la(e.estimatedCostUsd,n)}),(0,z.jsx)(`span`,{className:`muted text-caption`,children:r(`usage.cost.disclaimer`)}),(e.unpricedRequests??0)+(e.unmeteredRequests??0)>0&&(0,z.jsx)(`span`,{className:`muted text-caption`,children:r(`usage.cost.unpricedNote`).replace(`{count}`,String((e.unpricedRequests??0)+(e.unmeteredRequests??0)))})]})]})}function Ul({weekBars:e,locale:t,t:n}){let[r,i]=(0,_.useState)(null),a=Math.max(1,...e.map(e=>e.totalTokens));return(0,z.jsx)(`div`,{className:`daybars`,role:`img`,"aria-label":n(`usage.section.heatmap`),children:e.map(e=>{let n=Math.round(e.totalTokens/a*100),o=e.date.slice(5);return(0,z.jsxs)(`div`,{className:`daybar`,onMouseEnter:()=>i(e.date),onMouseLeave:()=>i(t=>t===e.date?null:t),children:[(0,z.jsx)(`div`,{className:`daybar-track`,children:(0,z.jsxs)(`div`,{className:`daybar-stack`,style:{"--daybar-scale":String(Math.max(0,Math.min(1,n/100)))},children:[e.models.map(e=>(0,z.jsx)(`div`,{className:`daybar-seg`,style:{flexGrow:e.totalTokens,background:Il(e.model,e.provider)}},`${e.provider}/${e.model}`)),e.models.length===0&&e.totalTokens>0&&(0,z.jsx)(`div`,{className:`daybar-seg`,style:{flexGrow:1,background:`var(--green)`}})]})}),r===e.date&&e.totalTokens>0&&(0,z.jsxs)(`div`,{className:`daybar-tip`,role:`tooltip`,children:[(0,z.jsx)(`div`,{className:`daybar-tip-date`,children:e.date}),e.models.slice(0,8).map(e=>(0,z.jsxs)(`div`,{className:`daybar-tip-row`,children:[(0,z.jsx)(`span`,{className:`daybar-tip-swatch`,style:{background:Il(e.model,e.provider)}}),(0,z.jsx)(`span`,{className:`daybar-tip-name`,children:zo(e.model)}),(0,z.jsx)(`span`,{className:`daybar-tip-val`,children:Pt(e.totalTokens,t)})]},`${e.provider}/${e.model}`))]}),(0,z.jsx)(`span`,{className:`daybar-count`,children:Pt(e.totalTokens,t)}),(0,z.jsx)(`span`,{className:`daybar-label muted`,children:o})]},e.date)})})}function Wl({range:e,heatmap:t,weekBars:n,locale:r,t:i}){let a=(0,_.useRef)(null),[o,s]=(0,_.useState)(null);return(0,_.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{e.scrollLeft=e.scrollWidth};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[t,e]),(0,z.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":`usage-heatmap-title`,children:[(0,z.jsx)(`h3`,{id:`usage-heatmap-title`,className:`panel-title`,children:i(`usage.section.heatmap`)}),e===`7d`?(0,z.jsx)(Ul,{weekBars:n,locale:r,t:i}):(0,z.jsxs)(`div`,{className:`heatmap`,ref:a,role:`img`,"aria-labelledby":`usage-heatmap-title`,children:[(0,z.jsxs)(`div`,{className:`heatmap-months`,style:{gridTemplateColumns:`28px repeat(${t.weeks.length}, calc(var(--hm-cell) + var(--hm-gap)))`},children:[(0,z.jsx)(`span`,{className:`heatmap-day-spacer`}),t.months.map(e=>(0,z.jsx)(`span`,{className:`heatmap-month`,style:{gridColumn:e.col+2},children:e.label},`${e.label}-${e.col}`))]}),(0,z.jsxs)(`div`,{className:`heatmap-body`,children:[(0,z.jsxs)(`div`,{className:`heatmap-days`,children:[(0,z.jsx)(`span`,{}),(0,z.jsx)(`span`,{children:i(`usage.dayMon`)}),(0,z.jsx)(`span`,{}),(0,z.jsx)(`span`,{children:i(`usage.dayWed`)}),(0,z.jsx)(`span`,{}),(0,z.jsx)(`span`,{children:i(`usage.dayFri`)}),(0,z.jsx)(`span`,{})]}),(0,z.jsx)(`div`,{className:`heatmap-grid`,style:{gridTemplateColumns:`repeat(${t.weeks.length}, var(--hm-cell))`},children:t.weeks.map((e,t)=>(0,z.jsx)(`div`,{className:`heatmap-week`,children:e.map((e,n)=>(0,z.jsx)(`div`,{className:`heatmap-cell heatmap-cell-${e.level}`,onMouseEnter:r=>{if(!e.date)return;let i=r.currentTarget.getBoundingClientRect();s({weekIndex:t,dayIndex:n,x:i.left+i.width/2,y:i.top})},onMouseLeave:()=>s(e=>e?.weekIndex===t&&e.dayIndex===n?null:e)},e.date||`pad-${t}-${n}`))},e[0]?.date||`week-${t}`))})]}),o&&(()=>{let e=t.weeks[o.weekIndex]?.[o.dayIndex];return e?.date?(0,z.jsxs)(`div`,{className:`heatmap-tip`,role:`tooltip`,style:{left:o.x,top:o.y},children:[(0,z.jsx)(`div`,{className:`heatmap-tip-date`,children:e.date}),(0,z.jsx)(`div`,{className:`heatmap-tip-val`,children:i(`usage.heatmap.tooltipTokens`,{tokens:Pt(e.totalTokens,r)})}),(0,z.jsx)(`div`,{className:`heatmap-tip-req muted`,children:i(`usage.heatmap.tooltipRequests`,{requests:e.requests})})]}):null})(),(0,z.jsxs)(`div`,{className:`heatmap-legend muted`,children:[(0,z.jsx)(`span`,{children:i(`usage.heatmap.less`)}),[0,1,2,3,4].map(e=>(0,z.jsx)(`span`,{className:`heatmap-cell heatmap-cell-${e}`},e)),(0,z.jsx)(`span`,{children:i(`usage.heatmap.more`)})]})]})]})}function Gl({title:e,titleId:t,children:n}){return(0,z.jsxs)(`section`,{className:`usw-section`,"aria-labelledby":t,children:[(0,z.jsx)(`h3`,{id:t,className:`h-section`,children:e}),n]})}function Kl({models:e,modelQuery:t,onModelQuery:n,locale:r,t:i,workspace:a=!1}){let o=i(`usage.search.models`),s=i(`usage.section.models`),c=`usage-models-title`,l=(0,z.jsx)(`input`,{className:`input`,"aria-label":o,placeholder:o,value:t,onChange:e=>n(e.target.value)}),u=(0,z.jsx)(`div`,{className:`tbl-wrap`,children:(0,z.jsxs)(`table`,{className:`tbl`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:i(`logs.col.model`)}),(0,z.jsx)(`th`,{children:i(`logs.col.provider`)}),(0,z.jsx)(`th`,{className:`num`,children:i(`usage.col.requests`)}),(0,z.jsx)(`th`,{className:`num`,children:i(`usage.col.measured`)}),(0,z.jsx)(`th`,{className:`num`,children:i(`usage.col.tokens`)}),(0,z.jsx)(`th`,{children:i(`usage.col.share`)})]})}),(0,z.jsx)(`tbody`,{children:e.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`mono`,children:zo(e.model)}),(0,z.jsx)(`td`,{className:`muted`,children:e.provider}),(0,z.jsx)(`td`,{className:`num`,children:e.requests}),(0,z.jsx)(`td`,{className:`num`,children:e.measuredRequests}),(0,z.jsx)(`td`,{className:`num mono`,children:Pt(e.totalTokens,r)}),(0,z.jsx)(`td`,{children:(0,z.jsx)(`div`,{className:`usage-bar`,children:(0,z.jsx)(`div`,{className:`usage-bar-fill`,style:{width:`${Math.round(e.shareRatio*100)}%`}})})})]},`${e.provider}/${e.model}`))})]})});return a?(0,z.jsxs)(Gl,{title:s,titleId:c,children:[(0,z.jsx)(`div`,{className:`usw-section-toolbar`,children:l}),u]}):(0,z.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":c,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{id:c,className:`panel-title`,children:s}),l]}),u]})}function ql({providers:e,locale:t,t:n,workspace:r=!1}){let i=n(`usage.section.providers`),a=`usage-providers-title`,o=(0,z.jsx)(`div`,{className:`tbl-wrap`,children:(0,z.jsxs)(`table`,{className:`tbl`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:n(`logs.col.provider`)}),(0,z.jsx)(`th`,{className:`num`,children:n(`usage.col.requests`)}),(0,z.jsx)(`th`,{className:`num`,children:n(`usage.col.measured`)}),(0,z.jsx)(`th`,{className:`num`,children:n(`usage.col.tokens`)}),(0,z.jsx)(`th`,{children:n(`usage.col.share`)})]})}),(0,z.jsx)(`tbody`,{children:e.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`mono`,children:e.provider}),(0,z.jsx)(`td`,{className:`num`,children:e.requests}),(0,z.jsx)(`td`,{className:`num`,children:e.measuredRequests}),(0,z.jsx)(`td`,{className:`num mono`,children:Pt(e.totalTokens,t)}),(0,z.jsx)(`td`,{children:(0,z.jsx)(`div`,{className:`usage-bar`,children:(0,z.jsx)(`div`,{className:`usage-bar-fill`,style:{width:`${Math.round(e.shareRatio*100)}%`}})})})]},e.provider))})]})});return r?(0,z.jsx)(Gl,{title:i,titleId:a,children:o}):(0,z.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":a,children:[(0,z.jsx)(`h3`,{id:a,className:`panel-title`,children:i}),o]})}function Jl({summary:e,t,workspace:n=!1}){let r=t(`usage.section.coverage`),i=`usage-coverage-title`,a=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`usage-cards usage-cards-3x2`,children:[(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.measured`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:e.measuredRequests})]}),(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.reported`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:e.reportedRequests})]}),(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.estimated`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:e.estimatedRequests})]}),(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:t(`logs.tokens.unreported`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:e.unreportedRequests})]}),(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:t(`logs.tokens.unsupported`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:e.unsupportedRequests})]})]}),(0,z.jsx)(`p`,{className:`muted text-control`,style:{marginTop:12},children:t(`usage.coverage.note`)})]});return n?(0,z.jsx)(Gl,{title:r,titleId:i,children:a}):(0,z.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":i,children:[(0,z.jsx)(`h3`,{id:i,className:`panel-title`,children:r}),a]})}function Yl({data:e,heatmap:t,weekBars:n,activeDays:r,filteredModels:i,modelQuery:a,onModelQuery:o,sortedProviders:s,range:c,locale:l,t:u}){let d=!!e&&e.summary.requests===0,f=[{id:`overview`,label:u(`usage.section.overview`),meta:e?`${e.summary.requests}`:`—`,body:e?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Hl,{summary:e.summary,activeDays:r,locale:l,t:u}),(0,z.jsx)(Wl,{range:c,heatmap:t,weekBars:n,locale:l,t:u})]}):null},{id:`models`,label:u(`usage.section.models`),meta:e?`${e.models.length}`:`—`,body:e?(0,z.jsx)(Kl,{models:i,modelQuery:a,onModelQuery:o,locale:l,t:u,workspace:!0}):null},{id:`providers`,label:u(`usage.section.providers`),meta:e?`${e.providers.length}`:`—`,body:e?(0,z.jsx)(ql,{providers:s,locale:l,t:u,workspace:!0}):null},{id:`coverage`,label:u(`usage.section.coverage`),meta:e?Fl(e.summary.coverageRatio):`—`,body:e?(0,z.jsx)(Jl,{summary:e.summary,t:u,workspace:!0}):null}];return(0,z.jsx)(`div`,{className:`usage-workspace-shell`,children:(0,z.jsxs)(`div`,{className:`usage-workspace-root`,children:[(0,z.jsx)(lc,{scope:`usage`,ariaLabel:u(`usage.workspace.sections`),items:f.map(e=>({id:e.id,label:e.label,meta:e.meta}))}),(0,z.jsx)(`section`,{className:`usage-workspace-main`,"aria-label":u(`usage.workspace.report`),children:d?(0,z.jsx)(ot,{title:u(`usage.empty`)}):f.map(e=>(0,z.jsx)(`div`,{id:oc(`usage`,e.id),className:`usw-body usw-section-block`,children:e.body},e.id))})]})})}var Xl=new Map;function Zl(e,t,n){return`ocx.usage.v1:${e}:${t}:${n}`}function Ql(e,t,n){let r=Zl(e,t,n);return Xl.get(r)??Y(r)}function $l(e,t,n,r){let i=Zl(e,t,n);Xl.set(i,r),X(i,r)}function eu({apiBase:e}){let{t,locale:n}=Ve(),[r,i]=(0,_.useState)(`30d`),[a,o]=(0,_.useState)(`all`),[s,c]=(0,_.useState)(``),l=(0,_.useCallback)(async t=>{let n=await fetch(`${e}/api/usage?range=${r}&surface=${a}`,{signal:t});if(!n.ok)throw Error(`${n.status} ${n.statusText}`.trim());let i=await n.json();return $l(e,r,a,i),i},[e,r,a]),u=Zl(e,r,a),d=Ql(e,r,a),f=us(u,[e,r,a],l,{isEmpty:()=>!1,initialData:d??void 0}),{state:p}=f,m=p.data??d??null,h=(0,_.useMemo)(()=>Bl(m?.days??[]),[m?.days]),g=(0,_.useMemo)(()=>Ll(m?.days??[]),[m?.days]),v=(0,_.useMemo)(()=>(m?.days??[]).filter(e=>e.requests>0).length,[m?.days]),y=(0,_.useMemo)(()=>{let e=s.trim().toLowerCase(),t=(m?.models??[]).toSorted((e,t)=>t.totalTokens-e.totalTokens);return e?t.filter(t=>t.model.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e)||(t.resolvedModel??``).toLowerCase().includes(e)).slice(0,100):t.slice(0,100)},[m?.models,s]),b=(0,_.useMemo)(()=>(m?.providers??[]).toSorted((e,t)=>t.totalTokens-e.totalTokens),[m?.providers]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`page-head usage-head`,children:[(0,z.jsx)(`h2`,{id:`usage-page-title`,children:t(`usage.title`)}),(0,z.jsx)(Vl,{surface:a,range:r,onSurface:o,onRange:i,t})]}),(0,z.jsx)(`p`,{className:`page-sub`,children:t(`usage.subtitle`)}),p.showSkeleton&&!m?(0,z.jsx)(fs,{label:t(`usage.loading`),rows:5}):p.kind===`failed-cold`?(0,z.jsxs)(q,{tone:`err`,children:[p.error instanceof Error?`${t(`usage.loadError`)} ${p.error.message}`:t(`usage.loadError`),` `,(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>f.refresh(),children:t(`common.retry`)})]}):(0,z.jsxs)(z.Fragment,{children:[p.showError&&(0,z.jsx)(q,{tone:`err`,children:t(`usage.loadError`)}),m?.historyTruncated&&(0,z.jsx)(q,{tone:`ok`,children:t(`usage.historyTruncated`)}),(0,z.jsx)(Yl,{data:m,heatmap:h,weekBars:g,activeDays:v,filteredModels:y,modelQuery:s,onModelQuery:c,sortedProviders:b,range:r,locale:n,t})]})]})}function tu(e,t){if(e<1024)return`${e} B`;let n=[`KB`,`MB`,`GB`,`TB`],r=e,i=-1;do r/=1024,i++;while(r>=1024&&i<n.length-1);return`${r.toLocaleString(t,{maximumFractionDigits:1})} ${n[i]}`}var nu={sessions:`storage.bucket.sessions`,archived_sessions:`storage.bucket.archived_sessions`,logs_db:`storage.bucket.logs_db`,state_db:`storage.bucket.state_db`,attachments:`storage.bucket.attachments`,deletion_manifests:`storage.bucket.deletion_manifests`,other:`storage.bucket.other`};function ru(e,t){let n=nu[e.key];return n?t(n):e.label}function iu(e,t){return e===void 0?`—`:new Date(e).toLocaleDateString(t)}function au(e,t,n){return e.rows===void 0?`—`:e.rows===null?n(`storage.rows.unknown`):e.rows.toLocaleString(t)}function ou({report:e,locale:t}){let n=K(),[r,i]=(0,_.useState)(null),a=(0,_.useMemo)(()=>e.buckets.toSorted((e,t)=>t.bytes-e.bytes),[e.buckets]),o=a.find(e=>e.key===r)??null,s=(0,_.useMemo)(()=>{let t=[];for(let n of e.buckets)for(let e of n.largest??[])t.push({...e,bucketKey:n.key});return t.sort((e,t)=>t.bytes-e.bytes).slice(0,10)},[e.buckets]),c=(0,_.useMemo)(()=>new Map(e.buckets.map(e=>[e.key,e])),[e.buckets]);return(0,z.jsxs)(`div`,{className:`storage-workspace-root`,children:[(0,z.jsxs)(`aside`,{className:`storage-workspace-rail`,"aria-label":n(`storage.section.buckets`),children:[(0,z.jsxs)(`div`,{className:`storage-workspace-rail-header`,children:[(0,z.jsx)(`span`,{className:`storage-workspace-rail-title`,children:n(`storage.section.buckets`)}),(0,z.jsx)(`span`,{className:`storage-workspace-rail-count`,children:a.length})]}),(0,z.jsx)(`div`,{className:`storage-workspace-rail-list`,children:a.length===0?(0,z.jsx)(`span`,{className:`storage-workspace-rail-empty`,children:n(`storage.empty`)}):a.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`storage-workspace-rail-row${r===e.key?` storage-workspace-rail-row--selected`:``}`,onClick:()=>i(t=>t===e.key?null:e.key),"aria-current":r===e.key?`true`:void 0,children:[(0,z.jsxs)(`span`,{className:`storage-workspace-rail-primary`,children:[(0,z.jsx)(`span`,{className:`storage-workspace-rail-name`,children:ru(e,n)}),(0,z.jsx)(`span`,{className:`storage-workspace-rail-size`,children:tu(e.bytes,t)})]}),(0,z.jsxs)(`span`,{className:`storage-workspace-rail-meta`,children:[e.fileCount.toLocaleString(t),` `,n(`storage.col.files`).toLowerCase()]})]},e.key))})]}),(0,z.jsx)(`section`,{className:`storage-workspace-main`,"aria-label":o?ru(o,n):n(`storage.section.largest`),children:o?(0,z.jsxs)(`div`,{className:`stw-detail`,children:[(0,z.jsx)(`div`,{className:`stw-detail-toolbar`,children:(0,z.jsxs)(`button`,{type:`button`,className:`stw-detail-back`,onClick:()=>i(null),children:[(0,z.jsx)(_e,{className:`stw-detail-back-chevron`,"aria-hidden":`true`}),n(`modal.back`)]})}),(0,z.jsxs)(`div`,{className:`stw-detail-body`,children:[(0,z.jsx)(`h2`,{className:`stw-detail-title`,children:ru(o,n)}),(0,z.jsxs)(`dl`,{className:`stw-kv`,children:[(0,z.jsxs)(`div`,{className:`stw-kv-row`,children:[(0,z.jsx)(`dt`,{children:n(`storage.col.size`)}),(0,z.jsx)(`dd`,{className:`stw-kv-mono`,children:tu(o.bytes,t)})]}),(0,z.jsxs)(`div`,{className:`stw-kv-row`,children:[(0,z.jsx)(`dt`,{children:n(`storage.col.files`)}),(0,z.jsx)(`dd`,{className:`stw-kv-mono`,children:o.fileCount.toLocaleString(t)})]}),(0,z.jsxs)(`div`,{className:`stw-kv-row`,children:[(0,z.jsx)(`dt`,{children:n(`storage.col.oldest`)}),(0,z.jsx)(`dd`,{children:iu(o.oldest,t)})]}),(0,z.jsxs)(`div`,{className:`stw-kv-row`,children:[(0,z.jsx)(`dt`,{children:n(`storage.col.newest`)}),(0,z.jsx)(`dd`,{children:iu(o.newest,t)})]}),(0,z.jsxs)(`div`,{className:`stw-kv-row`,children:[(0,z.jsx)(`dt`,{children:n(`storage.col.rows`)}),(0,z.jsx)(`dd`,{className:`stw-kv-mono`,children:au(o,t,n)})]})]}),(o.largest?.length??0)>0&&(0,z.jsxs)(`div`,{className:`stw-section`,children:[(0,z.jsx)(`h3`,{className:`stw-section-title`,children:n(`storage.section.largest`)}),o.largest.map(e=>(0,z.jsxs)(`div`,{className:`stw-file-row`,children:[(0,z.jsx)(`span`,{className:`stw-file-path`,title:e.path,children:e.path}),(0,z.jsx)(`span`,{className:`stw-file-size`,children:tu(e.bytes,t)})]},e.path))]})]})]}):(0,z.jsxs)(`div`,{className:`stw-overview`,children:[(0,z.jsxs)(`div`,{className:`stw-summary`,children:[(0,z.jsxs)(`div`,{className:`stw-summary-card`,children:[(0,z.jsx)(`div`,{className:`stw-summary-label`,children:n(`storage.card.total`)}),(0,z.jsx)(`div`,{className:`stw-summary-value`,children:tu(e.total.bytes,t)})]}),(0,z.jsxs)(`div`,{className:`stw-summary-card`,children:[(0,z.jsx)(`div`,{className:`stw-summary-label`,children:n(`storage.card.files`)}),(0,z.jsx)(`div`,{className:`stw-summary-value`,children:e.total.fileCount.toLocaleString(t)})]}),(0,z.jsxs)(`div`,{className:`stw-summary-card`,children:[(0,z.jsx)(`div`,{className:`stw-summary-label`,children:n(`storage.card.home`)}),(0,z.jsx)(`div`,{className:`stw-summary-value mono stw-home-path`,title:e.codexHome,children:e.codexHome})]})]}),s.length>0?(0,z.jsxs)(`div`,{className:`stw-section`,children:[(0,z.jsx)(`h3`,{className:`stw-section-title`,children:n(`storage.section.largest`)}),s.map(e=>{let r=c.get(e.bucketKey);return(0,z.jsxs)(`div`,{className:`stw-file-row`,children:[(0,z.jsx)(`span`,{className:`stw-file-path`,title:e.path,children:e.path}),r&&(0,z.jsx)(`span`,{className:`stw-file-bucket`,children:ru(r,n)}),(0,z.jsx)(`span`,{className:`stw-file-size`,children:tu(e.bytes,t)})]},`${e.bucketKey}:${e.path}`)})]}):(0,z.jsxs)(`p`,{className:`stw-hint`,children:[(0,z.jsx)(G,{style:{width:14,height:14,verticalAlign:`text-bottom`,marginRight:6},"aria-hidden":`true`}),n(`storage.workspace.selectBucket`)]})]})})]})}var su=1024**3,cu=[10,25,50],lu=(e,t)=>{if(!(e instanceof Error))return t;let n=e.message;return n===`Failed to fetch`||n.includes(`NetworkError`)||n.includes(`network error`)||n.includes(`JSON`)||n.includes(`Unexpected end of`)?t:n||t};function uu({apiBase:e,locale:t,t:n,onDone:r}){let[i,a]=(0,_.useState)(25),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(null),y=(0,_.useRef)(null),b=(0,_.useRef)(null),x=(0,_.useRef)(!1),S=(0,_.useCallback)((e=!1)=>{l(!1),d(!1),e&&s(null)},[]);(0,_.useEffect)(()=>{x.current=f},[f]),(0,_.useEffect)(()=>{if(!c)return;b.current=document.activeElement,y.current?.focus();let e=e=>{e.key===`Escape`&&!x.current&&S()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e),b.current?.focus()}},[c,S]);let C=(e,t,r)=>{switch(e){case`codex_busy`:return n(`storage.cleanup.err.codex_busy`);case`stale_preview`:return n(`storage.cleanup.err.stale_preview`);case`restore_pending_overlap`:return n(`storage.cleanup.err.restore_pending_overlap`);case`referenced_history`:return n(`storage.cleanup.err.referenced_history`);case`invalid_digest`:return n(`storage.cleanup.err.invalid_digest`);case`invalid_mode`:return n(`storage.cleanup.err.invalid_mode`);case`fs_failed`:return r?n(`storage.cleanup.err.fs_failed_trash`,{trashDir:r}):n(`storage.cleanup.err.fs_failed`);case`db_reconcile_failed`:return n(`storage.cleanup.err.db_reconcile_failed`);case`cleanup_failed`:return n(`storage.cleanup.err.cleanup_failed`);default:return t??n(`storage.cleanup.cleanupFailed`)}},w=e=>n(`storage.cleanup.preset`,{percent:new Intl.NumberFormat(t,{style:`percent`,maximumFractionDigits:0}).format(e/100)}),T=async()=>{p(!0),v(null),h(null);try{let t=await fetch(`${e}/api/storage/cleanup/preview`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({percent:i})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(C(e.error,n(`storage.cleanup.previewFailed`)))}s(await t.json()),l(!0)}catch(e){v(lu(e,n(`storage.cleanup.previewFailed`)))}finally{p(!1)}},E=async()=>{if(o){p(!0),v(null);try{let i=await fetch(`${e}/api/storage/cleanup`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({percent:o.percent,mode:u?`permanent`:`quarantine`,digest:o.digest})});if(!i.ok){let e=await i.json().catch(()=>({}));throw e.error===`stale_preview`&&S(!0),Error(C(e.error,e.message,e.trashDir))}let a=await i.json();if(!a.ok)throw a.error===`stale_preview`&&S(!0),Error(C(a.error,a.message,a.trashDir));S(!0),h(n(u?`storage.cleanup.donePermanent`:`storage.cleanup.doneQuarantine`,{count:String(a.count),size:tu(a.bytes,t)})),r()}catch(e){v(lu(e,n(`storage.cleanup.cleanupFailed`)))}finally{p(!1)}}};return(0,z.jsxs)(`section`,{className:`storage-cleanup-pane`,children:[(0,z.jsx)(`p`,{className:`muted storage-manual-panel__help`,children:n(`storage.cleanup.help`)}),(0,z.jsxs)(`div`,{className:`storage-manual-panel__controls`,children:[(0,z.jsxs)(`label`,{className:`storage-manual-panel__slider`,children:[(0,z.jsx)(`span`,{className:`muted mono`,style:{minWidth:`3.5rem`,fontVariantNumeric:`tabular-nums`},children:n(`storage.cleanup.percent`,{percent:String(i)})}),(0,z.jsx)(`input`,{type:`range`,min:1,max:100,value:i,onChange:e=>a(Number(e.target.value)),disabled:f,style:{flex:1,minWidth:0},"aria-label":n(`storage.cleanup.slider`)})]}),(0,z.jsx)(`div`,{className:`storage-manual-panel__presets`,children:cu.map(e=>(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm${i===e?` active`:``}`,disabled:f,onClick:()=>a(e),children:w(e)},e))}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,disabled:f,onClick:()=>void T(),children:n(`storage.cleanup.preview`)})]}),m&&(0,z.jsx)(`p`,{className:`muted storage-manual-panel__status`,children:m}),g&&!c&&(0,z.jsx)(`p`,{className:`storage-manual-panel__status`,style:{color:`var(--red)`},children:g}),c&&o&&(0,z.jsx)(`div`,{className:`modal-overlay`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`storage-cleanup-confirm-title`,onClick:()=>!f&&S(),children:(0,z.jsxs)(`div`,{className:`modal-card`,onClick:e=>e.stopPropagation(),children:[(0,z.jsx)(`h3`,{id:`storage-cleanup-confirm-title`,children:n(`storage.cleanup.confirmTitle`)}),(0,z.jsx)(`p`,{children:n(`storage.cleanup.confirmBody`,{count:String(o.count),size:tu(o.bytes,t),percent:String(o.percent)})}),o.candidates.length>0&&(0,z.jsxs)(`ul`,{className:`mono muted`,style:{maxHeight:160,overflow:`auto`,fontSize:`var(--text-caption)`},children:[o.candidates.slice(0,8).map(e=>(0,z.jsx)(`li`,{children:e.relPath},e.relPath)),o.count>8&&(0,z.jsx)(`li`,{children:n(`storage.cleanup.moreFiles`,{n:String(Math.max(0,o.count-8))})})]}),(0,z.jsxs)(`label`,{style:{display:`flex`,gap:8,alignItems:`center`,marginTop:12},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:u,disabled:f,onChange:e=>d(e.target.checked)}),(0,z.jsx)(`span`,{children:n(`storage.cleanup.permanent`)})]}),(0,z.jsx)(`p`,{className:`muted`,style:{marginTop:8,fontSize:`var(--text-caption)`},children:n(u?`storage.cleanup.permanentWarn`:`storage.cleanup.quarantineNote`)}),g&&(0,z.jsx)(`p`,{style:{marginTop:12,color:`var(--red)`},children:g}),(0,z.jsxs)(`div`,{className:`dialog-actions`,style:{marginTop:16},children:[(0,z.jsx)(`button`,{ref:y,type:`button`,className:`btn btn-ghost`,disabled:f,onClick:()=>S(),children:n(`storage.cleanup.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:u?`btn btn-danger`:`btn`,disabled:f||o.count===0,onClick:()=>void E(),children:n(u?`storage.cleanup.confirmPermanent`:`storage.cleanup.confirmQuarantine`)})]})]})})]})}function du({apiBase:e,locale:t,t:n,onDone:r,reloadToken:i,onEntriesChange:a}){let[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(null),m=(0,_.useRef)(null),h=(0,_.useRef)(null),g=(0,_.useRef)(!1);(0,_.useEffect)(()=>{g.current=o},[o]);let v=(0,_.useCallback)(()=>l(null),[]);(0,_.useEffect)(()=>{if(!c)return;h.current=document.activeElement,m.current?.focus();let e=e=>{e.key===`Escape`&&!g.current&&v()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e),h.current?.focus()}},[c,v]);let y=(0,_.useCallback)(async t=>{let r=await fetch(`${e}/api/storage/trash`,{signal:t});if(!r.ok)throw Error(n(`storage.trash.listFailed`));let i=await r.json(),o=Array.isArray(i.entries)?i.entries:[];return a?.(o),o},[e,a,n]),b=us(`storage-trash:${e}`,[e,i],y,{isEmpty:e=>e.length===0}).state,x=b.data??[],S=(e,t)=>{switch(e){case`codex_busy`:return n(`storage.trash.err.codex_busy`);case`invalid_trash`:return n(`storage.trash.err.invalid_trash`);case`missing_trash`:return n(`storage.trash.err.missing_trash`);case`dest_exists`:return n(`storage.trash.err.dest_exists`);case`fs_failed`:return n(`storage.trash.err.fs_failed`);case`db_reconcile_failed`:return n(`storage.trash.err.db_reconcile_failed`);case`storage_mutation_busy`:return n(`storage.trash.err.storage_mutation_busy`);case`restore_failed`:return n(`storage.trash.err.restore_failed`);case`restore_worker_timeout`:return n(`storage.trash.err.restore_worker_timeout`);case`restore_worker_aborted`:return n(`storage.trash.err.restore_worker_aborted`);case`restore_worker_failed`:return t??n(`storage.trash.err.restore_worker_failed`);default:return t??n(`storage.trash.restoreFailed`)}},C=async()=>{if(c){s(!0),p(null);try{let i=await fetch(`${e}/api/storage/trash/restore`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:c.id})});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(S(e.error,e.message))}let a=await i.json();if(!a.ok)throw Error(S(a.error,a.message));v(),d(n(`storage.trash.done`,{count:String(a.count),size:tu(a.bytes,t)})),r()}catch(e){p(lu(e,n(`storage.trash.restoreFailed`)))}finally{s(!1)}}},w=e=>{let n=e.quarantinedAt??Number(e.epoch.split(`-`)[0]);return!Number.isFinite(n)||n<=0?`—`:new Date(n).toLocaleString(t)},T=e=>e===`permanent`?n(`storage.trash.mode.permanent`):e===`quarantine`?n(`storage.trash.mode.quarantine`):`—`;return(0,z.jsxs)(`section`,{className:`storage-cleanup-pane storage-quarantine-pane`,children:[(0,z.jsx)(`p`,{className:`muted storage-manual-panel__help`,children:n(`storage.trash.help`)}),u&&(0,z.jsx)(`p`,{className:`muted storage-manual-panel__status`,children:u}),f&&!c&&(0,z.jsx)(`p`,{className:`storage-manual-panel__status`,style:{color:`var(--red)`},role:`alert`,children:f}),b.showError&&!c&&(0,z.jsx)(`p`,{className:`storage-manual-panel__status`,style:{color:`var(--red)`},role:`alert`,children:b.error instanceof Error?b.error.message:n(`storage.trash.listFailed`)}),b.refreshing&&!b.showSkeleton&&(0,z.jsx)(ps,{live:!b.showError,children:n(`storage.trash.loading`)}),b.showSkeleton?(0,z.jsx)(fs,{label:n(`storage.trash.loading`),rows:2}):x.length===0?(0,z.jsx)(`p`,{className:`muted storage-manual-panel__status`,children:n(`storage.trash.empty`)}):(0,z.jsx)(`div`,{className:`tbl-wrap storage-manual-panel__table`,children:(0,z.jsxs)(`table`,{className:`tbl`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:n(`storage.trash.col.when`)}),(0,z.jsx)(`th`,{className:`num`,children:n(`storage.trash.col.files`)}),(0,z.jsx)(`th`,{className:`num`,children:n(`storage.trash.col.size`)}),(0,z.jsx)(`th`,{children:n(`storage.trash.col.mode`)}),(0,z.jsx)(`th`,{children:n(`storage.trash.col.id`)}),(0,z.jsx)(`th`,{})]})}),(0,z.jsx)(`tbody`,{children:x.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`muted`,children:w(e)}),(0,z.jsx)(`td`,{className:`num`,children:e.fileCount}),(0,z.jsx)(`td`,{className:`num mono`,children:tu(e.bytes,t)}),(0,z.jsx)(`td`,{className:`muted`,children:T(e.mode)}),(0,z.jsx)(`td`,{className:`mono`,style:{fontSize:`var(--text-caption)`},children:e.id}),(0,z.jsx)(`td`,{children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,disabled:o,onClick:()=>{p(null),l(e)},children:n(`storage.trash.restore`)})})]},e.id))})]})}),c&&(0,z.jsx)(`div`,{className:`modal-overlay`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`storage-trash-confirm-title`,onClick:()=>!o&&v(),children:(0,z.jsxs)(`div`,{className:`modal-card`,onClick:e=>e.stopPropagation(),children:[(0,z.jsx)(`h3`,{id:`storage-trash-confirm-title`,children:n(`storage.trash.confirmTitle`)}),(0,z.jsx)(`p`,{children:n(`storage.trash.confirmBody`,{count:String(c.fileCount),size:tu(c.bytes,t),id:c.id})}),f&&(0,z.jsx)(`p`,{style:{marginTop:12,color:`var(--red)`},children:f}),(0,z.jsxs)(`div`,{className:`dialog-actions`,style:{marginTop:16},children:[(0,z.jsx)(`button`,{ref:m,type:`button`,className:`btn btn-ghost`,disabled:o,onClick:()=>v(),children:n(`storage.trash.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn`,disabled:o,onClick:()=>void C(),children:n(`storage.trash.confirmRestore`)})]})]})})]})}function fu(e){let{job:t,...n}=e;return n}function pu(e){let t=String(Math.max(0,Math.round(e.trigger.archivedBytesOver/su*100)/100));return e.target.reduceToBytes===void 0?{policy:fu(e),thresholdGb:t,targetMode:`percent`,percent:String(Math.min(100,Math.max(1,Math.floor(e.target.removeOldestPercent??25)))),reduceGb:`4`}:{policy:fu(e),thresholdGb:t,targetMode:`reduce`,percent:`25`,reduceGb:String(Math.max(0,Math.round(e.target.reduceToBytes/su*100)/100))}}async function mu(e){await new Promise(t=>window.setTimeout(t,e))}function hu({apiBase:e,locale:t,t:n,onDone:r}){let i=`ocx.storage.cleanup-policy.v1:${e}`,a=Y(i),o=(0,_.useRef)(!!a),[s,c]=(0,_.useState)(()=>a?.policy??null),[l,u]=(0,_.useState)(()=>!a),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(()=>a?.targetMode??`percent`),[S,C]=(0,_.useState)(()=>a?.percent??`25`),[w,T]=(0,_.useState)(()=>a?.reduceGb??`4`),[E,D]=(0,_.useState)(()=>a?.thresholdGb??`5`),O=(0,_.useRef)(null),k=(0,_.useRef)(!1),A=(0,_.useRef)(!1),j=(0,_.useRef)(0),M=(0,_.useCallback)(e=>{let t=pu(e);c(t.policy),D(t.thresholdGb),x(t.targetMode),C(t.percent),T(t.reduceGb),o.current=!0,X(i,t),k.current=!1},[i]),N=(0,_.useCallback)(()=>{k.current=!0},[]),P=(0,_.useCallback)(e=>{A.current=e},[]),F=(0,_.useCallback)(async t=>{let r=++j.current;o.current||u(!0),y(null);try{let n=await fetch(`${e}/api/storage/cleanup-policy`,{signal:t});if(!n.ok)throw Error(`load_failed`);let i=await n.json();if(t?.aborted||r!==j.current||k.current||A.current)return;M(i)}catch{if(t?.aborted||r!==j.current)return;o.current||(c(null),y(n(`storage.policy.loadFailed`)))}finally{!t?.aborted&&r===j.current&&u(!1)}},[e,M,n]);(0,_.useEffect)(()=>{let e=new AbortController,t=window.setTimeout(()=>{F(e.signal)},0);return()=>{window.clearTimeout(t),j.current+=1,e.abort()}},[F]),(0,_.useEffect)(()=>()=>{O.current?.abort(),O.current=null},[]);let I=()=>{if(!s)return null;let e=E.trim();if(e===``)return null;let t=Number(e);if(!Number.isFinite(t)||t<0)return null;let n;if(b===`reduce`){let e=w.trim();if(e===``)return null;let t=Number(e);if(!Number.isFinite(t)||t<0)return null;n={reduceToBytes:Math.floor(t*su)}}else{let e=Number(S);if(!Number.isFinite(e)||e<1||e>100)return null;n={removeOldestPercent:Math.min(100,Math.max(1,Math.floor(e)))}}return{enabled:s.enabled,trigger:{archivedBytesOver:Math.floor(t*su)},target:n,schedule:s.schedule,mode:s.mode}},L=async t=>{let r=I();if(!r){y(n(`storage.policy.invalid`));return}let i={...r,...t};f(!0),y(null),g(null);try{let t=await fetch(`${e}/api/storage/cleanup-policy`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(i)});if(!t.ok){y(n(`storage.policy.saveFailed`));return}let r=await t.json();if(!r.policy){y(n(`storage.policy.saveFailed`));return}M(r.policy),g(n(`storage.policy.saved`))}catch{y(n(`storage.policy.saveFailed`))}finally{f(!1)}},R=async()=>{O.current?.abort();let i=new AbortController;O.current=i;let{signal:a}=i;m(!0),y(null),g(null);try{let i=I();if(!i){y(n(`storage.policy.invalid`));return}let o=await fetch(`${e}/api/storage/cleanup-policy`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(i),signal:a});if(a.aborted)return;if(!o.ok){y(n(`storage.policy.saveFailed`));return}let s=await o.json();if(a.aborted)return;if(!s.policy){y(n(`storage.policy.saveFailed`));return}M(s.policy);let c=await fetch(`${e}/api/storage/cleanup-policy/run`,{method:`POST`,signal:a});if(a.aborted)return;if(c.status===409){let e=await c.json().catch(()=>({}));if(a.aborted)return;e.policy&&M(e.policy),y(n(`storage.policy.alreadyRunning`));return}if(!c.ok){let e=await c.json().catch(()=>({}));if(a.aborted)return;if(e.policy&&M(e.policy),e.error===`already_running`){y(n(`storage.policy.alreadyRunning`));return}y(n(`storage.policy.runFailed`));return}let l=await c.json();if(a.aborted)return;if(l.policy&&M(l.policy),l.error===`already_running`){y(n(`storage.policy.alreadyRunning`));return}if(!l.started||!l.job?.startedAt){y(n(`storage.policy.runFailed`));return}let u=l.job.startedAt,d=Date.now()+12e4,f,p;for(;Date.now()<d;){if(a.aborted||(await mu(250),a.aborted))return;let t=await fetch(`${e}/api/storage/cleanup-policy`,{signal:a});if(a.aborted)return;if(!t.ok)continue;let n=await t.json();if(a.aborted)return;p=fu(n),M(n);let r=n.job;if(r&&r.status!==`running`){if(r.startedAt===u&&r.lastOutcome){f=r.lastOutcome;break}if(r.finishedAt&&r.finishedAt>=u&&r.lastOutcome){f=r.lastOutcome;break}}}if(a.aborted)return;if(p&&M(p),!f){y(n(`storage.policy.runFailed`));return}f.skipped===`disabled`?g(n(`storage.policy.skippedDisabled`)):f.skipped===`under_threshold`?g(n(`storage.policy.skippedUnder`)):f.skipped===`nothing_selected`?g(n(`storage.policy.skippedEmpty`)):f.deferred===`codex_busy`||f.error===`codex_busy`?y(n(`storage.cleanup.err.codex_busy`)):f.ok?(g(f.mode===`permanent`?n(`storage.policy.donePermanent`,{count:String(f.removed??0),size:tu(f.freedBytes??0,t)}):n(`storage.policy.doneQuarantine`,{count:String(f.removed??0),size:tu(f.freedBytes??0,t)})),r()):y(n(`storage.policy.runFailed`))}catch(e){if(a.aborted||e instanceof DOMException&&e.name===`AbortError`)return;y(n(`storage.policy.runFailed`))}finally{O.current===i&&(O.current=null),a.aborted||m(!1)}},B=e=>e===void 0?n(`storage.policy.never`):new Date(e).toLocaleString(t);return l&&!s?(0,z.jsx)(`section`,{className:`storage-cleanup-pane`,children:(0,z.jsx)(`p`,{className:`muted storage-policy-help`,children:n(`storage.policy.loading`)})}):s?(0,z.jsxs)(`section`,{className:`storage-cleanup-pane`,children:[(0,z.jsx)(`p`,{className:`muted storage-policy-help`,children:n(`storage.policy.help`)}),(0,z.jsx)(`div`,{className:`storage-policy-enable`,children:(0,z.jsxs)(`div`,{className:`storage-policy-enable-row`,children:[(0,z.jsx)(`button`,{type:`button`,className:`toggle${s.enabled?` on`:``}`,disabled:d||p,"aria-pressed":s.enabled,"aria-label":n(`storage.policy.enabled`),title:n(`storage.policy.enabledHint`),onClick:()=>void L({enabled:!s.enabled}),children:(0,z.jsx)(`span`,{className:`toggle-knob`})}),(0,z.jsx)(`span`,{children:n(`storage.policy.enabled`)})]})}),(0,z.jsxs)(`div`,{className:`storage-policy-fields`,children:[(0,z.jsxs)(`div`,{className:`field storage-policy-trigger`,children:[(0,z.jsx)(`label`,{className:`field-label`,htmlFor:`storage-policy-threshold`,children:n(`storage.policy.trigger`)}),(0,z.jsxs)(`div`,{className:`storage-policy-trigger-row`,children:[(0,z.jsx)(`span`,{className:`storage-policy-trigger-hint`,children:n(`storage.policy.threshold`)}),(0,z.jsxs)(`span`,{className:`codex-auto-switch-input-wrap`,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(P(!1),L())},children:[(0,z.jsx)(`input`,{id:`storage-policy-threshold`,className:`input mono codex-auto-switch-input`,type:`number`,min:0,step:.1,inputMode:`decimal`,value:E,disabled:d||p,"aria-label":n(`storage.policy.threshold`),onFocus:()=>P(!0),onChange:e=>{N(),D(e.target.value)},onKeyDown:e=>{e.nativeEvent.isComposing||d||p||e.key===`Enter`&&(e.preventDefault(),L())}}),(0,z.jsx)(`span`,{className:`codex-auto-switch-unit`,"aria-hidden":`true`,children:`GiB`}),(0,z.jsx)(Ri,{disabled:d||p,incrementLabel:n(`storage.policy.thresholdInc`),decrementLabel:n(`storage.policy.thresholdDec`),onIncrement:()=>{N(),D(Li(E,.1,0,1e4,.1))},onDecrement:()=>{N(),D(Li(E,-.1,0,1e4,.1))}})]})]})]}),(0,z.jsxs)(`fieldset`,{className:`field storage-policy-target`,children:[(0,z.jsx)(`legend`,{className:`field-label`,children:n(`storage.policy.target`)}),(0,z.jsxs)(`label`,{className:`storage-policy-target-row`,children:[(0,z.jsx)(`input`,{type:`radio`,name:`storage-policy-target`,checked:b===`percent`,disabled:d||p,onChange:()=>{N(),x(`percent`)}}),(0,z.jsx)(`span`,{className:`storage-policy-target-label`,children:n(`storage.policy.targetPercent`)}),b===`percent`&&(0,z.jsxs)(`span`,{className:`codex-auto-switch-input-wrap`,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(P(!1),L())},children:[(0,z.jsx)(`input`,{id:`storage-policy-percent`,className:`input mono codex-auto-switch-input`,type:`number`,min:1,max:100,step:1,inputMode:`numeric`,value:S,disabled:d||p,"aria-label":n(`storage.policy.targetPercent`),onFocus:()=>P(!0),onChange:e=>{N(),C(e.target.value)},onKeyDown:e=>{e.nativeEvent.isComposing||d||p||e.key===`Enter`&&(e.preventDefault(),L())}}),(0,z.jsx)(`span`,{className:`codex-auto-switch-unit`,"aria-hidden":`true`,children:`%`}),(0,z.jsx)(Ri,{disabled:d||p,incrementLabel:n(`storage.policy.percentInc`),decrementLabel:n(`storage.policy.percentDec`),onIncrement:()=>{N(),C(Li(S,1,1,100))},onDecrement:()=>{N(),C(Li(S,-1,1,100))}})]})]}),(0,z.jsxs)(`label`,{className:`storage-policy-target-row`,children:[(0,z.jsx)(`input`,{type:`radio`,name:`storage-policy-target`,checked:b===`reduce`,disabled:d||p,onChange:()=>{N(),x(`reduce`)}}),(0,z.jsx)(`span`,{className:`storage-policy-target-label`,children:n(`storage.policy.targetReduce`)}),b===`reduce`&&(0,z.jsxs)(`span`,{className:`codex-auto-switch-input-wrap`,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(P(!1),L())},children:[(0,z.jsx)(`input`,{id:`storage-policy-reduce`,className:`input mono codex-auto-switch-input`,type:`number`,min:0,step:.1,inputMode:`decimal`,value:w,disabled:d||p,"aria-label":n(`storage.policy.targetReduce`),onFocus:()=>P(!0),onChange:e=>{N(),T(e.target.value)},onKeyDown:e=>{e.nativeEvent.isComposing||d||p||e.key===`Enter`&&(e.preventDefault(),L())}}),(0,z.jsx)(`span`,{className:`codex-auto-switch-unit`,"aria-hidden":`true`,children:`GiB`}),(0,z.jsx)(Ri,{disabled:d||p,incrementLabel:n(`storage.policy.reduceInc`),decrementLabel:n(`storage.policy.reduceDec`),onIncrement:()=>{N(),T(Li(w,.1,0,1e4,.1))},onDecrement:()=>{N(),T(Li(w,-.1,0,1e4,.1))}})]})]})]}),(0,z.jsxs)(`div`,{className:`storage-policy-selects`,children:[(0,z.jsxs)(`label`,{className:`field`,htmlFor:`storage-policy-schedule`,children:[(0,z.jsx)(`span`,{className:`field-label`,children:n(`storage.policy.schedule`)}),(0,z.jsxs)(`select`,{id:`storage-policy-schedule`,className:`input`,value:s.schedule,disabled:d||p,onChange:e=>{let t=e.target.value;L({schedule:t})},children:[(0,z.jsx)(`option`,{value:`manual`,children:n(`storage.policy.schedule.manual`)}),(0,z.jsx)(`option`,{value:`startup`,children:n(`storage.policy.schedule.startup`)}),(0,z.jsx)(`option`,{value:`daily`,children:n(`storage.policy.schedule.daily`)}),(0,z.jsx)(`option`,{value:`weekly`,children:n(`storage.policy.schedule.weekly`)})]})]}),(0,z.jsxs)(`label`,{className:`field`,htmlFor:`storage-policy-mode`,children:[(0,z.jsx)(`span`,{className:`field-label`,children:n(`storage.policy.mode`)}),(0,z.jsxs)(`select`,{id:`storage-policy-mode`,className:`input`,value:s.mode,disabled:d||p,onChange:e=>{let t=e.target.value;L({mode:t})},children:[(0,z.jsx)(`option`,{value:`quarantine`,children:n(`storage.policy.mode.quarantine`)}),(0,z.jsx)(`option`,{value:`permanent`,children:n(`storage.policy.mode.permanent`)})]})]})]}),s.mode===`permanent`&&(0,z.jsx)(`p`,{className:`err storage-policy-warn`,role:`status`,children:n(`storage.policy.permanentWarn`)})]}),(0,z.jsxs)(`div`,{className:`storage-policy-meta`,children:[(0,z.jsxs)(`div`,{className:`storage-policy-meta-item`,children:[(0,z.jsx)(`span`,{className:`muted`,children:n(`storage.policy.lastRun`)}),(0,z.jsxs)(`span`,{className:`storage-policy-meta-value`,children:[B(s.lastRun?.at),s.lastRun?` · ${n(`storage.policy.lastRunDetail`,{count:String(s.lastRun.removed),size:tu(s.lastRun.freedBytes,t)})}`:``]})]}),(0,z.jsxs)(`div`,{className:`storage-policy-meta-item`,children:[(0,z.jsx)(`span`,{className:`muted`,children:n(`storage.policy.nextRun`)}),(0,z.jsx)(`span`,{className:`storage-policy-meta-value`,children:B(s.nextRun)})]})]}),(0,z.jsxs)(`div`,{className:`storage-policy-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:d||p,onClick:()=>void L(),children:n(`storage.policy.save`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,disabled:d||p,onClick:()=>void R(),children:n(p?`storage.policy.running`:`storage.policy.runNow`)}),(0,z.jsx)(`span`,{className:`storage-policy-actions__status${v?` is-error`:``}`,role:v?`alert`:`status`,"aria-live":`polite`,children:v??h??``})]})]}):(0,z.jsx)(`section`,{className:`storage-cleanup-pane`,children:v&&(0,z.jsx)(`p`,{className:`err`,role:`alert`,children:v})})}function gu({apiBase:e,locale:t,t:n,archivedCount:r,showQuarantine:i,trashReloadToken:a,onDone:o,onTrashEntriesChange:s}){let[c,l]=(0,_.useState)(`policy`),u=(0,_.useRef)(null),d=(0,_.useRef)(null),f=[{id:`policy`,label:n(`storage.cleanupCard.tab.policy`),ref:u},{id:`quarantine`,label:n(`storage.cleanupCard.tab.quarantine`),ref:d}],p=e=>{l(e),window.requestAnimationFrame(()=>(e===`policy`?u:d).current?.focus())},m=e=>{e.key===`ArrowLeft`||e.key===`ArrowRight`?(e.preventDefault(),p(c===`policy`?`quarantine`:`policy`)):e.key===`Home`?(e.preventDefault(),p(`policy`)):e.key===`End`&&(e.preventDefault(),p(`quarantine`))};return(0,z.jsxs)(`section`,{className:`panel storage-cleanup-card`,"aria-labelledby":`storage-cleanup-card-title`,children:[(0,z.jsx)(`div`,{className:`page-tabs storage-cleanup-card__tabs`,role:`tablist`,"aria-label":n(`storage.cleanupCard.tabs`),children:f.map(({id:e,label:t,ref:n})=>(0,z.jsx)(`button`,{type:`button`,role:`tab`,ref:n,id:`storage-cleanup-tab-${e}`,"aria-selected":c===e,"aria-controls":`storage-cleanup-panel-${e}`,tabIndex:c===e?0:-1,className:`page-tab${c===e?` page-tab--active`:``}`,onKeyDown:m,onClick:()=>p(e),children:t},e))}),(0,z.jsx)(`h3`,{id:`storage-cleanup-card-title`,className:`panel-title`,children:n(`storage.cleanupCard.title`)}),(0,z.jsxs)(`div`,{className:`storage-cleanup-card__stack`,children:[(0,z.jsxs)(`div`,{id:`storage-cleanup-panel-policy`,role:`tabpanel`,"aria-labelledby":`storage-cleanup-tab-policy`,className:`storage-cleanup-card__body storage-cleanup-policy-split`,"data-active":c===`policy`?`true`:`false`,"aria-hidden":c!==`policy`,...c===`policy`?{}:{inert:!0},children:[(0,z.jsx)(hu,{apiBase:e,locale:t,t:n,onDone:o}),(0,z.jsxs)(`aside`,{className:`storage-cleanup-manual`,"aria-labelledby":`storage-cleanup-manual-title`,children:[(0,z.jsx)(`h4`,{id:`storage-cleanup-manual-title`,className:`storage-cleanup-manual__title`,children:n(`storage.cleanup.title`)}),r>0?(0,z.jsx)(uu,{apiBase:e,locale:t,t:n,onDone:o}):(0,z.jsx)(`p`,{className:`muted storage-manual-panel__status`,children:n(`storage.cleanup.noArchives`)})]})]}),(0,z.jsx)(`div`,{id:`storage-cleanup-panel-quarantine`,role:`tabpanel`,"aria-labelledby":`storage-cleanup-tab-quarantine`,className:`storage-cleanup-card__body`,"data-active":c===`quarantine`?`true`:`false`,"aria-hidden":c!==`quarantine`,...c===`quarantine`?{}:{inert:!0},children:i?(0,z.jsx)(du,{apiBase:e,locale:t,t:n,onDone:o,reloadToken:a,onEntriesChange:s}):(0,z.jsx)(`p`,{className:`muted storage-manual-panel__status`,children:n(`storage.trash.empty`)})})]})]})}function _u({apiBase:e}){let{t,locale:n}=Ve(),r=`ocx.storage.report.v1:${e}`,i=Y(r),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(0),l=(0,_.useRef)(!1),[u,d]=(0,_.useState)({apiBase:e,settled:!1,hasEntries:!1}),f=(0,_.useCallback)(async n=>{try{let i=await fetch(`${e}/api/storage`,{signal:n});if(!i.ok)throw Error(t(`storage.error`));let a=await i.json();return X(r,a),l.current&&(l.current=!1,o(t(`storage.rescanned`))),a}catch(e){throw l.current&&(l.current=!1,o(t(`storage.error`))),n.aborted?e:Error(t(`storage.error`),{cause:e})}},[e,r,t]),p=us(`storage-report:${e}`,[e],f,{isEmpty:e=>e.total.fileCount===0&&e.error===void 0}),m=p.state,h=m.data??i,g=m.refreshing||m.showSkeleton&&!h,v=p.refresh,y=(0,_.useCallback)(()=>{o(null),l.current=!0,v(),c(e=>e+1)},[v]),b=(0,_.useCallback)(t=>{d({apiBase:e,settled:!0,hasEntries:t.length>0})},[e]),x=u.apiBase===e&&u.settled,S=u.apiBase===e&&u.hasEntries,C=h?.error!==void 0,w=!g&&!m.showError&&!C&&h.total.fileCount===0&&x&&!S,T=h?.buckets.find(e=>e.key===`archived_sessions`)?.fileCount??0,E=!!h&&!C,D=E&&(h.total.fileCount>0||!x||S);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`page-head`,children:[(0,z.jsx)(`h2`,{id:`storage-page-title`,children:t(`storage.title`)}),(0,z.jsxs)(`div`,{className:`storage-page-head-actions`,children:[(0,z.jsx)(`span`,{className:`storage-page-head-feedback`,role:`status`,"aria-live":`polite`,children:a??``}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:g,onClick:()=>void y(),children:[(0,z.jsx)(se,{}),` `,t(`storage.refresh`)]})]})]}),(0,z.jsx)(`p`,{className:`page-sub`,children:t(`storage.subtitle`)}),h&&h.error===void 0&&(0,z.jsxs)(`p`,{className:`storage-page-meta`,children:[(0,z.jsx)(`code`,{className:`mono storage-page-meta__home`,title:h.codexHome,children:h.codexHome}),(0,z.jsx)(`span`,{className:`storage-page-meta__sep`,"aria-hidden":`true`,children:`·`}),(0,z.jsxs)(`span`,{children:[t(`storage.snapshot.lastScan`),`:`,` `,new Date(h.generatedAt).toLocaleString(n)]})]}),m.showSkeleton&&!h?(0,z.jsx)(fs,{label:t(`storage.loading`),rows:5}):m.kind===`failed-cold`&&!h?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`alert alert-err`,role:`alert`,children:m.error instanceof Error?m.error.message:t(`storage.error`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>v(),children:t(`common.retry`)})]}):C?(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(`div`,{className:`alert alert-err`,role:`alert`,children:t(`storage.error`)})}):(0,z.jsxs)(z.Fragment,{children:[m.showError&&(0,z.jsx)(`div`,{className:`alert alert-err`,role:`alert`,children:t(`storage.error`)}),w?(0,z.jsx)(ot,{title:t(`storage.empty`)}):h&&h.total.fileCount>0&&(0,z.jsx)(ou,{report:h,locale:n})]}),h&&h.error===void 0&&m.refreshing&&!m.showSkeleton&&(0,z.jsx)(ps,{live:!m.showError,children:t(`storage.loading`)}),E&&(0,z.jsx)(gu,{apiBase:e,locale:n,t,archivedCount:T,showQuarantine:D,trashReloadToken:s,onDone:()=>void y(),onTrashEntriesChange:b})]})}function vu(e){if(!e||typeof e!=`object`)return`absent`;let t=e.providers;if(!t||typeof t!=`object`||Array.isArray(t)||!Object.hasOwn(t,`openai`))return`absent`;let n=t.openai;if(!n||typeof n!=`object`||Array.isArray(n))return`absent`;let r=n;return r.disabled===!0?`disabled`:r.codexAccountMode===`direct`?`direct`:r.codexAccountMode===void 0||r.codexAccountMode===`pool`?`pool`:`absent`}function yu({state:e,busy:t,onEnable:n}){let r=K();return(0,z.jsxs)(`div`,{className:`panel openai-account-mode-banner`,style:{marginBottom:16},children:[(0,z.jsxs)(`div`,{className:`row`,children:[(0,z.jsx)(`strong`,{children:r(`codexAuth.accountModeTitle`)}),e===null?(0,z.jsx)(`span`,{className:`badge badge-accent openai-account-mode-banner__badge-slot openai-account-mode-banner__badge-slot--pending`,"aria-hidden":`true`,children:r(`codexAuth.accountModePool`)}):e===`pool`?(0,z.jsx)(`span`,{className:`badge badge-accent openai-account-mode-banner__badge-slot`,children:r(`codexAuth.accountModePool`)}):e===`direct`?(0,z.jsx)(`span`,{className:`badge badge-green openai-account-mode-banner__badge-slot`,children:r(`codexAuth.accountModeDirect`)}):null]}),e===null&&(0,z.jsx)(`p`,{className:`card-sub openai-account-mode-banner__desc openai-account-mode-banner__desc--pending`,"aria-hidden":`true`,children:`\xA0`}),e===`pool`&&(0,z.jsx)(`p`,{className:`card-sub openai-account-mode-banner__desc`,children:r(`codexAuth.accountModePoolDesc`)}),e===`direct`&&(0,z.jsxs)(`p`,{className:`card-sub openai-account-mode-banner__desc`,children:[r(`codexAuth.accountModeDirectDesc`),` `,(0,z.jsx)(`a`,{href:`#providers`,children:r(`codexAuth.openProviders`)})]}),(e===`absent`||e===`disabled`)&&(0,z.jsxs)(`div`,{className:`row`,style:{alignItems:`center`,marginTop:8},children:[(0,z.jsx)(`p`,{className:`card-sub`,style:{flex:1,margin:0},children:r(`codexAuth.openaiUnavailableDesc`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:t,onClick:n,children:r(t?`codexAuth.enablingOpenai`:`codexAuth.enableOpenai`)})]}),e===`invalid`&&(0,z.jsxs)(`p`,{className:`card-sub openai-account-mode-banner__desc`,children:[r(`codexAuth.openaiMissing`),` `,(0,z.jsx)(`a`,{href:`#providers`,children:r(`codexAuth.openProviders`)})]})]})}function bu(e){if(!e||typeof e!=`object`)return;let t=e.providers;if(!t||typeof t!=`object`||Array.isArray(t)||!Object.hasOwn(t,`openai`))return;let n=t.openai;if(!(!n||typeof n!=`object`||Array.isArray(n)))return n}function xu({apiBase:e}){let t=K(),n=`ocx.codex-auth.config.v1:${e}`,r=Y(n),[i,a]=(0,_.useState)(()=>r?.bannerState??null),[o,s]=(0,_.useState)(()=>r?.accountModeState??null),c=(0,_.useRef)(null),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(``),p=(0,_.useCallback)(async()=>{try{let t=await fetch(`${e}/api/config`);if(!t.ok)throw Error(String(t.status));let r=await t.json(),i=Ga(bu(r));if(i===`absent`||i===`disabled`||i===`invalid`){a(i);let e=i===`disabled`?`disabled`:`absent`;s(e),X(n,{bannerState:i,accountModeState:e});return}let o=vu(r);a(o),s(o),X(n,{bannerState:o,accountModeState:o})}catch{}},[e,n]);(0,_.useEffect)(()=>{c.current!==e&&(c.current=e,Promise.resolve().then(()=>{p()}));let t=window.setInterval(()=>{p()},3e4);return()=>{window.clearInterval(t)}},[e,p]);let m=async()=>{u(!0),f(``);try{if(i!==`absent`&&i!==`disabled`)return;await Qa(e,i),await p()}catch(e){e instanceof Za?f(t(e.i18nKey)):f(e instanceof Error?e.message:t(`prov.saveFailed`))}finally{u(!1)}};return(0,z.jsx)(Ea,{apiBase:e,accountModeState:o,banner:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(yu,{state:i,busy:l,onEnable:()=>{m()}}),d&&(0,z.jsx)(`div`,{className:`notice notice-err`,role:`alert`,children:d})]})})}function Su(e){return e?[`responses`,`chat`,`messages`]:[`responses`,`chat`]}function Cu(e){let t=e.id.indexOf(`/`),n=typeof e.owned_by==`string`&&e.owned_by.trim()?e.owned_by.trim():void 0,r=t>0?e.id.slice(0,t):n??`openai`,i=t<0&&r===`openai`,a=r!==`openai`&&r!==`combo`;return{id:e.id,displayName:e.id,provider:r,native:i,custom:a}}function wu(e){return e.id}function Tu(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.ambiguous===!0?!0:!(typeof t.requests7d!=`number`||!Number.isFinite(t.requests7d)||typeof t.totalRequests!=`number`||!Number.isFinite(t.totalRequests)||t.lastUsedAt!==void 0&&(typeof t.lastUsedAt!=`string`||Number.isNaN(new Date(t.lastUsedAt).getTime())))}var Eu=new Set([`required`,`accepted`,`rejected`]);function Du(e){return Array.isArray(e)&&e.length>0&&e.every(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.endpoint==`string`&&Eu.has(t.bearer)&&Eu.has(t.dedicated)&&Eu.has(t.xApiKey)})}var Ou={baseUrl:`http://127.0.0.1:10100/v1`,responses:`http://127.0.0.1:10100/v1/responses`,chatCompletions:`http://127.0.0.1:10100/v1/chat/completions`,messages:`http://127.0.0.1:10100/v1/messages`,models:`http://127.0.0.1:10100/v1/models`};function ku(e){let t=e||Ou.responses,n=t.match(/^(.*)\/v1\/responses\/?$/),r=n?`${n[1]}/v1`:t.replace(/\/responses\/?$/,``);return{baseUrl:r,responses:t,chatCompletions:`${r}/chat/completions`,messages:`${r}/messages`,models:`${r}/models`}}function Au(e,t){let n=new Date(e);return!e||Number.isNaN(n.getTime())?`—`:n.toLocaleDateString(t)}function ju({url:e}){return(0,z.jsx)(Mu,{text:e,hintKey:`api.copyUrlHint`,copiedKey:`api.urlCopied`,className:`api-endpoint-url-btn`,children:(0,z.jsx)(`code`,{className:`api-code api-code-inline api-endpoint-url`,children:e})})}function Mu({text:e,hintKey:t,copiedKey:n,className:r,children:i}){let{t:a}=Ve(),o=(0,_.useId)(),s=(0,_.useRef)(null),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(null),m=(0,_.useRef)(null),h=c||u;(0,_.useEffect)(()=>()=>{m.current!==null&&window.clearTimeout(m.current)},[]),(0,_.useLayoutEffect)(()=>{if(!h)return;let e=()=>{let e=s.current;if(!e)return;let t=e.getBoundingClientRect();p({top:Math.max(8,t.top-8),left:t.left+t.width/2})};return e(),window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[h]);let g=()=>l(!0),v=()=>l(!1),y=async()=>{try{await navigator.clipboard.writeText(e),d(!0),m.current!==null&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>d(!1),1500)}catch{d(!1)}},b=h&&f?(0,qe.createPortal)((0,z.jsx)(`span`,{id:o,className:`ocx-tooltip-bubble api-copy-tip-fixed`,role:`tooltip`,style:{top:f.top,left:f.left},children:a(u?n:t)}),document.body):null;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,ref:s,className:`ocx-tooltip ${r}`,onMouseEnter:g,onMouseLeave:v,onFocus:g,onBlur:v,onClick:e=>{if(typeof window<`u`&&window.getSelection()?.toString())return;let t=e.target;if(t instanceof HTMLElement&&t!==e.currentTarget){let n=t.getBoundingClientRect();if(t.scrollHeight>t.clientHeight+1&&e.clientX>=n.right-16||t.scrollWidth>t.clientWidth+1&&e.clientY>=n.bottom-16)return}y()},onKeyDown:e=>{e.key===`Escape`&&v()},"aria-label":a(t),"aria-describedby":h?o:void 0,children:i}),b]})}function Nu({text:e}){return(0,z.jsx)(Mu,{text:e,hintKey:`api.copyExampleHint`,copiedKey:`api.exampleCopied`,className:`api-example-copy-btn`,children:(0,z.jsx)(`code`,{className:`api-code api-example-pre`,children:e})})}function Pu(e,t){return t(e===`required`?`api.auth.required`:e===`accepted`?`api.auth.accepted`:`api.auth.rejected`)}function Fu({endpoints:e,claudeCodeEnabled:t,authMatrix:n}){let{t:r}=Ve();return(0,z.jsxs)(`div`,{className:`panel api-panel`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:r(`api.endpointsTitle`)}),(0,z.jsxs)(`div`,{className:`api-endpoints`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`muted small`,children:r(`api.baseUrl`)}),(0,z.jsx)(ju,{url:e.baseUrl})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`muted small`,children:r(`api.responsesEndpoint`)}),(0,z.jsx)(ju,{url:e.responses})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`muted small`,children:r(`api.chatCompletionsEndpoint`)}),(0,z.jsx)(ju,{url:e.chatCompletions})]}),t&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`muted small`,children:r(`api.messagesEndpoint`)}),(0,z.jsx)(ju,{url:e.messages})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`muted small`,children:r(`api.modelsEndpoint`)}),(0,z.jsx)(ju,{url:e.models})]})]}),(0,z.jsx)(`p`,{className:`muted small`,children:r(`api.endpointNote`)}),(0,z.jsxs)(`div`,{className:`api-auth-matrix-block`,children:[(0,z.jsx)(`h4`,{className:`api-auth-matrix-title`,children:r(`api.authTitle`)}),(0,z.jsx)(`div`,{className:`api-auth-matrix-scroll`,children:(0,z.jsxs)(`table`,{className:`api-auth-matrix`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:r(`api.auth.endpoint`)}),(0,z.jsx)(`th`,{children:(0,z.jsx)(`code`,{children:`Authorization: Bearer`})}),(0,z.jsx)(`th`,{children:(0,z.jsx)(`code`,{children:`x-opencodex-api-key`})}),(0,z.jsx)(`th`,{children:(0,z.jsx)(`code`,{children:`x-api-key`})})]})}),(0,z.jsx)(`tbody`,{children:n.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{children:(0,z.jsx)(`code`,{children:e.endpoint})}),(0,z.jsx)(`td`,{children:Pu(e.bearer,r)}),(0,z.jsx)(`td`,{children:Pu(e.dedicated,r)}),(0,z.jsx)(`td`,{children:Pu(e.xApiKey,r)})]},e.endpoint))})]})}),(0,z.jsx)(`p`,{className:`muted small`,children:r(`api.authLoopback`)}),(0,z.jsx)(`p`,{className:`muted small`,children:r(`api.authBaseUrlNote`)})]})]})}function Iu({keys:e,keysLoading:t=!1,keysLoadFailed:n,newName:r,creating:i,newKey:a,copied:o,confirmDelete:s,localeTag:c,showKeyList:l=!0,onNewNameChange:u,onCreate:d,onDismissNewKey:f,onCopyKey:p,onConfirmDelete:m,onCancelDelete:h,onDelete:g}){let{t:_}=Ve();return(0,z.jsxs)(z.Fragment,{children:[a&&(0,z.jsxs)(`div`,{className:`panel api-panel panel-accent api-newkey-panel`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:_(`api.newKeyTitle`)}),(0,z.jsx)(`p`,{className:`muted small`,children:_(`api.newKeyNote`)}),(0,z.jsxs)(`div`,{className:`api-form-row`,children:[(0,z.jsx)(`code`,{className:`api-code`,style:{flex:1,wordBreak:`break-all`},children:a}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,onClick:p,children:o?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ie,{}),` `,_(`api.copied`)]}):_(`api.copy`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,style:{alignSelf:`flex-start`},onClick:f,children:_(`api.dismiss`)})]}),(0,z.jsxs)(`div`,{className:`panel api-panel api-generate-panel`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:_(`api.generateTitle`)}),(0,z.jsxs)(`div`,{className:`api-form-row`,children:[(0,z.jsx)(`input`,{id:`api-key-name`,type:`text`,placeholder:_(`api.keyNamePlaceholder`),"aria-label":_(`api.keyNamePlaceholder`),value:r,maxLength:64,onChange:e=>u(e.target.value),className:`input`}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:d,disabled:i,children:[(0,z.jsx)(oe,{}),` `,_(i?`api.generating`:`api.generate`)]})]})]}),l&&(0,z.jsxs)(`div`,{className:`panel api-panel`,style:{marginTop:`1rem`},"aria-busy":t,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:t?_(`api.activeKeysLoading`):_(`api.activeKeys`,{count:e.length})}),t?(0,z.jsx)(`div`,{className:`api-active-keys-skeleton`,role:`status`,"aria-label":_(`common.loading`)}):e.length>0?(0,z.jsx)(`div`,{className:`tbl-wrap`,children:(0,z.jsxs)(`table`,{className:`tbl`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:_(`api.colName`)}),(0,z.jsx)(`th`,{children:_(`api.colKey`)}),(0,z.jsx)(`th`,{children:_(`api.colCreated`)}),(0,z.jsx)(`th`,{})]})}),(0,z.jsx)(`tbody`,{children:e.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{children:e.name}),(0,z.jsx)(`td`,{children:(0,z.jsx)(`code`,{children:e.prefix})}),(0,z.jsx)(`td`,{children:Au(e.createdAt,c)}),(0,z.jsx)(`td`,{children:s===e.id?(0,z.jsxs)(`span`,{className:`api-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-danger`,onClick:()=>g(e.id),children:_(`api.confirm`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,onClick:h,children:_(`common.cancel`)})]}):(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,"aria-label":_(`api.deleteAria`),onClick:()=>m(e.id),children:(0,z.jsx)(ae,{})})})]},e.id))})]})}):n?(0,z.jsx)(`p`,{className:`muted`,children:_(`api.keysLoadFailed`)}):(0,z.jsx)(`p`,{className:`muted`,children:_(`api.noKeys`)})]})]})}function Lu({filteredModels:e,modelsLoading:t,modelsRefreshing:n=!1,modelsLoadFailed:r,modelCount:i,hasModelData:a,modelQuery:o,copiedModelId:s,modelTests:c,claudeCodeEnabled:l,onModelQueryChange:u,onCopyModelId:d,onTestModel:f,onRetryModels:p,canTestModels:m,sourceLabel:h,protocolLabel:g}){let{t:_}=Ve();return(0,z.jsxs)(`div`,{className:`panel api-panel api-models-panel`,children:[(0,z.jsxs)(`div`,{className:`api-panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:_(`api.modelsTitle`)}),(0,z.jsx)(`span`,{className:`muted mono text-label`,children:_(`api.modelsCount`,{count:e.length})})]}),(0,z.jsx)(`p`,{className:`muted small`,children:_(`api.modelsSubtitle`)}),(0,z.jsx)(`input`,{type:`search`,className:`input`,value:o,onChange:e=>u(e.target.value),placeholder:_(`api.modelsSearch`),"aria-label":_(`api.modelsSearch`)}),r&&(0,z.jsxs)(`div`,{className:`api-models-error`,children:[(0,z.jsx)(`p`,{className:`muted small`,role:`alert`,children:_(`api.modelsLoadFailed`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:p,children:_(`common.retry`)})]}),n&&!t&&(0,z.jsx)(`p`,{className:`muted small`,"aria-live":`polite`,children:_(`api.modelsLoading`)}),t?(0,z.jsx)(fs,{label:_(`api.modelsLoading`),rows:3}):a?e.length===0?(0,z.jsx)(`p`,{className:`muted small api-models-empty`,children:i===0?_(`api.modelsEmpty`):_(`api.modelsNoMatch`,{query:o.trim()})}):(0,z.jsx)(`div`,{className:`api-models-scroll`,children:(0,z.jsxs)(`table`,{className:`tbl`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:_(`api.colModel`)}),(0,z.jsx)(`th`,{children:_(`api.colSource`)}),(0,z.jsx)(`th`,{children:_(`api.colProtocols`)})]})}),(0,z.jsx)(`tbody`,{children:e.map(e=>{let t=wu(e),n=Su(l);return(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{children:(0,z.jsxs)(`div`,{className:`api-model-cell`,children:[(0,z.jsx)(`code`,{children:t}),e.displayName!==e.id&&(0,z.jsx)(`span`,{className:`muted small`,children:e.displayName})]})}),(0,z.jsx)(`td`,{children:h(e)}),(0,z.jsx)(`td`,{children:(0,z.jsxs)(`div`,{className:`api-model-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,onClick:()=>{d(t)},children:_(s===t?`api.modelCopied`:`api.copyModelId`)}),n.map(n=>{let r=c[t]?.[n],i=r?.state??`idle`;return(0,z.jsxs)(`span`,{className:`api-model-test-chip`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,disabled:i===`testing`||!m,title:m?void 0:_(`api.auth.testNeedsFreshKey`),onClick:()=>{f(e,n)},children:_(`api.auth.testProtocol`,{protocol:g(n)})}),i!==`idle`&&(0,z.jsx)(`span`,{className:`api-test-note api-test-note--${i}`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:i===`testing`?_(`api.testingModel`):i===`ok`?_(`api.testSucceeded`):r?.detail??_(`api.testFailed`)})]},n)})]})})]},t)})})]})}):null]})}function Ru({endpoints:e,claudeCodeEnabled:t}){let{t:n}=Ve(),r=JSON.stringify(n(`api.usageSampleInput`)),i=`curl ${e.chatCompletions} \\
47
+ `))&&(async()=>{u(null),g(typeof r?.pid==`number`?r.pid:null),c(`draining`);try{if(!(await fetch(`${e}/api/system/restart`,{method:`POST`})).ok)throw Error(`restart_failed`)}catch{c(`error`),g(null),u(n(`dash.mem.restartFailed`))}})()};if(a&&!r&&s===`idle`)return(0,z.jsxs)(`div`,{className:`panel`,style:{marginBottom:24},children:[(0,z.jsxs)(`div`,{className:`font-semibold`,style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,z.jsx)(re,{width:16,height:16,"aria-hidden":`true`}),n(`dash.mem.title`)]}),(0,z.jsx)(`div`,{className:`muted text-control`,style:{marginTop:8},children:n(`dash.mem.unavailable`)})]});let y=r?.watchdog?qt(r.watchdog.samples):null,b=r?r.observedBytes??r.watchdog?.observedBytes??Gt(r):null,x=r?Kt(r):null,S=(()=>{let e=r?.watchdog?.warnThresholdBytes;if(y===null||y<=0||b===null||!e)return;let t=e-b;if(t<=0)return`danger`;let n=t/y;if(n<=1)return`danger`;if(n<=8)return`warn`})(),C=r?.responseState,w=r?.activeTurnCount,T=s===`draining`||s===`reconnecting`;return(0,z.jsxs)(`div`,{className:`panel`,style:{marginBottom:24},children:[(0,z.jsxs)(`div`,{className:`mem-head`,children:[(0,z.jsxs)(`div`,{className:`font-semibold mem-head-title`,children:[(0,z.jsx)(re,{width:16,height:16,"aria-hidden":`true`}),n(`dash.mem.title`)]}),p&&(0,z.jsxs)(`div`,{className:`mem-head-actions`,children:[(0,z.jsxs)(`span`,{className:`mem-inflight`,children:[(0,z.jsx)(`span`,{className:`mem-inflight-label`,children:n(`dash.mem.inFlight`)}),(0,z.jsx)(`span`,{className:`mem-inflight-value mono`,children:typeof w==`number`?Ht(t).format(w):`—`})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:T,onClick:v,children:n(`dash.mem.restart`)})]})]}),(0,z.jsx)(Yt,{observedBytes:b,thresholdBytes:r?.watchdog?.warnThresholdBytes??null,metric:x,locale:t,t:n}),(0,z.jsxs)(`div`,{className:`stat-row mem-stats`,children:[(0,z.jsx)(Jt,{label:n(`dash.mem.rss`),value:r?Ut(r.rss,t):`—`}),(0,z.jsx)(Jt,{label:n(`dash.mem.jsHeap`),value:r?Ut(r.heapUsed,t):`—`,sub:r?n(`dash.mem.jsHeapArena`,{total:Ut(r.heapTotal,t)}):void 0}),(0,z.jsx)(Jt,{label:n(`dash.mem.jscHeap`),value:r?.jscHeap?Ut(r.jscHeap.heapSize,t):`—`}),(0,z.jsx)(Jt,{label:n(`dash.mem.growth`),value:y===null?`—`:`${y>=0?`+`:`−`}${Ut(Math.abs(y),t)}${n(`dash.mem.perHour`)}`,tone:S})]}),(0,z.jsxs)(`details`,{style:{marginTop:10},children:[(0,z.jsx)(`summary`,{className:`muted text-label`,style:{cursor:`pointer`,padding:`2px 2px`},children:n(`dash.mem.details`)}),(0,z.jsx)(`div`,{className:`muted text-control`,style:{margin:`8px 0 0`},children:n(`dash.mem.hint`)}),(0,z.jsx)(`div`,{className:`muted text-label`,style:{margin:`14px 0 6px`},children:n(`dash.mem.runtime`)}),(0,z.jsxs)(`div`,{className:`stat-row`,children:[(0,z.jsx)(Jt,{label:n(`dash.mem.observed`),value:b===null?`—`:`${Ut(b,t)} (${x})`}),(0,z.jsx)(Jt,{label:n(`dash.mem.external`),value:r?.external===void 0?`—`:Ut(r.external,t)}),(0,z.jsx)(Jt,{label:n(`dash.mem.arrayBuffers`),value:r?.arrayBuffers===void 0?`—`:Ut(r.arrayBuffers,t)})]}),(0,z.jsx)(`div`,{className:`muted text-label`,style:{margin:`14px 0 6px`},children:n(`dash.mem.store`)}),(0,z.jsx)(`div`,{className:`muted text-control`,style:{marginBottom:10},children:n(`dash.mem.storeHint`)}),(0,z.jsxs)(`div`,{className:`stat-row`,children:[(0,z.jsx)(Jt,{label:n(`dash.mem.storeEntries`),value:C?Ht(t).format(C.count):`—`}),(0,z.jsx)(Jt,{label:n(`dash.mem.storeTotal`),value:C?Ut(C.totalBytes,t):`—`}),(0,z.jsx)(Jt,{label:n(`dash.mem.storeLargest`),value:C?Ut(C.largestBytes,t):`—`}),(0,z.jsx)(Jt,{label:n(`dash.mem.storeOldest`),value:C?C.count===0?`—`:Wt(C.oldestAgeMs,t):`—`})]}),r?.watchdog&&(0,z.jsxs)(`div`,{className:`stat-row`,style:{marginTop:16},children:[(0,z.jsx)(Jt,{label:n(`dash.mem.threshold`),value:Ut(r.watchdog.warnThresholdBytes,t)}),(0,z.jsx)(Jt,{label:n(`dash.mem.lastWarn`),value:r.watchdog.lastWarnAt?new Date(r.watchdog.lastWarnAt).toLocaleString(t):n(`dash.mem.never`)})]})]}),p&&(0,z.jsxs)(`div`,{className:`mem-status`,"aria-live":`polite`,children:[s===`draining`&&(0,z.jsx)(`span`,{className:`muted text-control`,children:n(`dash.mem.draining`,{count:typeof w==`number`?w:0})}),s===`reconnecting`&&(0,z.jsx)(`span`,{className:`muted text-control`,children:n(`dash.mem.reconnecting`)}),s===`error`&&l&&(0,z.jsx)(`span`,{className:`text-control`,style:{color:`var(--danger, #c44)`},children:l}),d&&s===`idle`&&(0,z.jsx)(`span`,{className:`muted text-control`,children:n(`dash.mem.restartNoSupervisor`)})]})]})}function en({apiBase:e,d:t}){let{t:n,maMode:r,maModeResolved:i,effortCapHelpTriggerRef:a,effortCapHelpOpen:o,setEffortCapHelpOpen:s,effortCap:c,subagentEffortCap:l,effortCapSaving:u,setEffortCap:d,setSubagentEffortCap:f,setEffortCapSaving:p}=t;return!i||r===`v1`?null:(0,z.jsx)(`div`,{className:`panel`,children:(0,z.jsxs)(`div`,{className:`injection-head`,children:[(0,z.jsxs)(`span`,{className:`injection-label`,style:{display:`inline-flex`,alignItems:`center`,gap:6},children:[n(`dash.effortCapLabel`),(0,z.jsx)(`button`,{ref:a,type:`button`,className:`btn btn-ghost btn-sm`,style:{width:22,height:22,minWidth:22,padding:0,borderRadius:`var(--radius-pill)`,color:`var(--muted)`},onClick:()=>s(e=>!e),"aria-label":n(`dash.effortCapLabel`),"aria-expanded":o,"aria-haspopup":`dialog`,"aria-controls":`effort-cap-help-dialog`,children:(0,z.jsx)(fe,{width:13,height:13,"aria-hidden":`true`})})]}),(0,z.jsx)(at,{value:c,options:[{value:``,label:n(`dash.effortCapNone`)},...gt.map(e=>({value:e,label:e}))],onChange:async t=>{if(!u){p(!0);try{let n=await ht(await fetch(`${e}/api/effort-caps`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({effortCap:t||null})}));d(n.effortCap??``),f(n.subagentEffortCap??``)}catch{}finally{p(!1)}}},disabled:u,label:n(`dash.effortCapLabel`)}),(0,z.jsx)(at,{value:l,options:[{value:``,label:n(`dash.effortCapNone`)},...gt.map(e=>({value:e,label:e}))],onChange:async t=>{if(!u){p(!0);try{let n=await ht(await fetch(`${e}/api/effort-caps`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({subagentEffortCap:t||null})}));d(n.effortCap??``),f(n.subagentEffortCap??``)}catch{}finally{p(!1)}}},disabled:u,label:n(`dash.subagentEffortCapLabel`)})]})})}function tn({d:e}){let{t,injectionModel:n,injectionEffort:r,injectionEfforts:i,injectionAvailable:a,injectionSaving:o,saveInjection:s}=e;return(0,z.jsxs)(`div`,{className:`panel dash-delegation-summary`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:t(`dash.injectionLabel`)}),(0,z.jsxs)(`div`,{className:`dash-delegation-controls`,children:[(0,z.jsx)(at,{value:n,options:[{value:``,label:t(`dash.injectionNone`)},...a.map(e=>({value:e.namespaced,label:`${e.provider} / ${e.model}`}))],onChange:e=>{s({model:e||null,effort:r||null})},disabled:o,label:t(`dash.injectionLabel`)}),n&&i.length>0&&(0,z.jsx)(at,{value:r,options:[{value:``,label:t(`dash.injectionEffortNone`)},...i.map(e=>({value:e,label:e}))],onChange:e=>{s({model:n||null,effort:e||null})},disabled:o,label:t(`dash.injectionEffortLabel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>Ke(`#subagents`),children:t(`dash.injectionManage`)})]})]})}function nn({d:e}){let{t,runSync:n,syncing:r,updateTriggerRef:i,openUpdateDialog:a,updateLoading:o,updateOpen:s,syncResult:c,syncError:l,updateJob:u,reconnecting:d}=e;return(0,z.jsxs)(`div`,{className:`panel maintenance-panel`,children:[(0,z.jsxs)(`div`,{className:`dash-sync-summary`,children:[(0,z.jsxs)(`div`,{className:`dash-sync-copy`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:t(`dash.syncModels`)}),(0,z.jsx)(`div`,{className:`muted text-control dash-sync-hint`,children:t(`dash.syncModelsHint`)})]}),(0,z.jsxs)(`div`,{className:`maintenance-actions`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:n,disabled:r,children:[(0,z.jsx)(se,{}),` `,t(r?`dash.syncing`:`dash.syncRun`)]}),(0,z.jsx)(`button`,{ref:i,type:`button`,className:`maintenance-update-anchor`,onClick:a,disabled:o,"aria-haspopup":`dialog`,"aria-controls":`dashboard-update-dialog`,"aria-expanded":s,"aria-label":t(`dash.checkUpdate`),tabIndex:-1})]})]}),c&&(0,z.jsxs)(`div`,{className:`notice ${c.nativeSubagentDefaultsWarning?`notice-warn`:`notice-ok`} maintenance-notice`,role:`status`,children:[c.nativeSubagentDefaultsWarning?(0,z.jsx)(de,{}):(0,z.jsx)(se,{}),(0,z.jsxs)(`span`,{children:[t(`dash.syncOk`,{count:c.added}),c.warning?` ${c.warning}`:``,c.nativeSubagentDefaultsWarning?` ${c.nativeSubagentDefaultsWarning}`:``,c.staleAppServerHint?(0,z.jsxs)(z.Fragment,{children:[` `,(0,z.jsx)(Ue,{k:`dash.syncStaleHint`,cmd:`ocx sync --restart-codex`})]}):null]})]}),l&&(0,z.jsxs)(`div`,{className:`notice notice-err maintenance-notice`,role:`status`,children:[(0,z.jsx)(de,{}),(0,z.jsx)(`span`,{children:t(`dash.syncFailed`,{error:l})})]}),u&&(0,z.jsxs)(`div`,{className:`notice ${u.status===`failed`?`notice-err`:`notice-ok`} maintenance-notice`,role:`status`,children:[u.status===`failed`?(0,z.jsx)(de,{}):(0,z.jsx)(se,{}),(0,z.jsxs)(`span`,{children:[yt(u.status,t),u.latestVersion?` ${u.currentVersion} -> ${u.latestVersion}.`:``,d?` ${t(`dash.updateReconnecting`)}`:``,u.error?` ${u.error}`:``]})]})]})}function rn({d:e}){let{t,settings:n,settingsSaving:r,toggleCodexAutoStart:i,sidecar:a,sidecarSaving:o,sidecarModels:s,models:c,saveSidecar:l,shadowCall:u,shadowCallSaving:d,shadowCallHelpTriggerRef:f,shadowCallHelpOpen:p,setShadowCallHelpOpen:m,saveShadowCall:h}=e;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`panel`,children:(0,z.jsxs)(`div`,{className:`spread`,children:[(0,z.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:t(`dash.codexAutoStart`)}),(0,z.jsx)(`div`,{className:`muted setting-hint`,children:t(`dash.codexAutoStartHint`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`switch ${n?.codexAutoStart??!0?`on`:``}`,onClick:i,disabled:!n||r,"aria-label":t(`dash.codexAutoStart`),"aria-pressed":n?.codexAutoStart??!0,children:(0,z.jsx)(`span`,{className:`knob`})})]})}),(0,z.jsxs)(`div`,{className:`dash-sidecar-grid`,children:[(0,z.jsxs)(`div`,{className:`panel dash-sidecar-card`,"aria-busy":!a||void 0,children:[(0,z.jsxs)(`div`,{className:`dash-sidecar-card__row`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:t(`dash.webSearchSidecar`)}),(0,z.jsx)(at,{value:a?.webSearch.model??`gpt-5.6-luna`,options:s,onChange:e=>{l({webSearch:{model:e,backend:St(c,e)}})},disabled:!a||o,label:t(`dash.sidecarModel`)})]}),(0,z.jsx)(`div`,{className:`muted setting-hint`,children:t(`dash.webSearchSidecarHint`)})]}),(0,z.jsxs)(`div`,{className:`panel dash-sidecar-card`,"aria-busy":!a||void 0,children:[(0,z.jsxs)(`div`,{className:`dash-sidecar-card__row`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:t(`dash.visionSidecar`)}),(0,z.jsx)(at,{value:a?.vision.model??`gpt-5.6-luna`,options:s,onChange:e=>{l({vision:{model:e,backend:St(c,e)}})},disabled:!a||o,label:t(`dash.sidecarModel`)})]}),(0,z.jsx)(`div`,{className:`muted setting-hint`,children:t(`dash.visionSidecarHint`)})]})]}),(0,z.jsx)(`div`,{className:`panel`,"aria-busy":!u||void 0,children:(0,z.jsxs)(`div`,{className:`spread`,style:{alignItems:`center`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,z.jsx)(`span`,{className:`font-semibold`,children:t(`dash.shadowCallIntercept`)}),(0,z.jsx)(`button`,{ref:f,type:`button`,className:`btn btn-ghost btn-sm`,style:{width:22,height:22,minWidth:22,padding:0,borderRadius:`var(--radius-pill)`,color:`var(--muted)`},onClick:()=>m(e=>!e),"aria-label":t(`dash.shadowCallIntercept`),"aria-expanded":p,"aria-haspopup":`dialog`,"aria-controls":`shadow-call-help-dialog`,children:(0,z.jsx)(fe,{width:13,height:13,"aria-hidden":`true`})}),(0,z.jsx)(`code`,{className:`muted text-caption`,children:`⚠ ${kt(u?.sourceModels)}`})]}),(0,z.jsxs)(`div`,{className:`setting-controls`,style:{display:`flex`,gap:8,alignItems:`center`},children:[(0,z.jsx)(`button`,{type:`button`,className:`switch ${u?.enabled?`on`:``}`,onClick:()=>h({enabled:!u?.enabled}),disabled:!u||d,"aria-label":t(`dash.shadowCallIntercept`),"aria-pressed":u?.enabled??!1,children:(0,z.jsx)(`span`,{className:`knob`})}),(0,z.jsx)(at,{value:u?.model??``,options:[{value:``,label:`—`},...c.map(e=>({value:e.id,label:`${e.provider}/${e.id}`}))],onChange:e=>{h({model:e})},disabled:!u||d||!u?.enabled,label:t(`dash.shadowCallModel`),align:`right`})]})]})})]})}function an(e){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(en,{apiBase:e.apiBase,d:e}),(0,z.jsxs)(`div`,{className:`dash-overview-tools`,children:[(0,z.jsx)(tn,{apiBase:e.apiBase,d:e}),(0,z.jsx)(nn,{d:e})]}),(0,z.jsx)(rn,{d:e}),(0,z.jsx)($t,{apiBase:e.apiBase})]})}function on(e){return(0,z.jsxs)(`div`,{className:`dash-overview-stack`,children:[(0,z.jsx)(Lt,{...e}),(0,z.jsx)(an,{...e})]})}function sn({t:e,providers:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`h-section`,children:[e(`dash.activeProviders`),` `,(0,z.jsx)(`span`,{className:`count`,children:t.length})]}),t.length===0?(0,z.jsx)(ot,{title:(0,z.jsx)(Ue,{k:`dash.noProviders`,cmd:`ocx init`})}):(0,z.jsx)(`div`,{className:`tbl-wrap`,children:(0,z.jsxs)(`table`,{className:`tbl`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:e(`dash.col.name`)}),(0,z.jsx)(`th`,{children:e(`dash.col.adapter`)}),(0,z.jsx)(`th`,{children:e(`dash.col.baseUrl`)}),(0,z.jsx)(`th`,{children:e(`dash.col.model`)})]})}),(0,z.jsx)(`tbody`,{children:t.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`font-semibold`,children:e.name}),(0,z.jsx)(`td`,{children:(0,z.jsx)(`span`,{className:`chip`,children:e.adapter})}),(0,z.jsx)(`td`,{className:`muted mono text-label`,children:e.baseUrl}),(0,z.jsx)(`td`,{className:`muted`,children:e.defaultModel??`—`})]},e.name))})]})})]})}function Y(e){try{let t=sessionStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function X(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch{}}function cn(e){return e.routingKind===`custom-local`?`startup.riskDetailCustomLocal`:e.shimCoverage===`cli-only`?`startup.riskDetailWindowsShim`:`startup.riskDetail`}function ln(e,t){return!t.mutationInFlight&&e.request===t.request&&e.mutation===t.mutation}function un(e,t){return{request:++e.current,mutation:t.current}}var dn=2e3;function fn(e){let t=e.status;return t===`native`||t===`protected`||t===`at-risk`?t:null}function pn(e){return e?e.stale&&e.status!==`error`:!1}function mn(e,t){return!t||e!==null&&e!==`error`?e:t.status}var hn=3e4;function gn(e){return{multiAgentGuidanceEnabled:e.multiAgentGuidanceEnabled!==!1,syncCodexSubagentDefaults:e.syncCodexSubagentDefaults===!0,injectionModel:e.model??``,injectionEffort:e.effort??``}}function _n(e,t){return t.aborted?!0:e instanceof Error&&e.name===`AbortError`}async function vn(e,t){try{let n=await fetch(`${e}/api/startup-health`,{signal:t});if(!n.ok)throw Error(`startup health unavailable`);let r=await n.json(),i=fn(r);if(!i)throw Error(`invalid startup health response`);return{status:i,stale:r.diagnosticStale===!0}}catch(e){if(_n(e,t))throw e;return{status:`error`,stale:!1}}}async function yn(e,t){try{return(await ut(await fetch(`${e}/api/diagnostics/project-config`,{signal:t})))?.grouped??[]}catch{return[]}}async function bn(e,t){return ht(await fetch(`${e}/api/models`,{signal:t}))}async function xn(e,t){return ht(await fetch(`${e}/api/usage?range=30d`,{signal:t}))}async function Sn(e,t,n){let{request:r,mutation:i}=un(n.shadowCallRequestEpochRef,n.shadowCallMutationEpochRef),[a,o]=await Promise.all([fetch(`${e}/api/sidecar-settings`,{signal:t}),fetch(`${e}/api/shadow-call-settings`,{signal:t})]),s=await ht(a),c;try{if(o.ok){let e=await o.json();ln({request:r,mutation:i},{request:n.shadowCallRequestEpochRef.current,mutation:n.shadowCallMutationEpochRef.current,mutationInFlight:n.shadowCallMutationInFlightRef.current})&&(c=e)}else ln({request:r,mutation:i},{request:n.shadowCallRequestEpochRef.current,mutation:n.shadowCallMutationEpochRef.current,mutationInFlight:n.shadowCallMutationInFlightRef.current})&&(c=null)}catch{ln({request:r,mutation:i},{request:n.shadowCallRequestEpochRef.current,mutation:n.shadowCallMutationEpochRef.current,mutationInFlight:n.shadowCallMutationInFlightRef.current})&&(c=null)}return{sidecar:s,shadowCall:c}}async function Cn(e,t,n){let{request:r,mutation:i}=un(n.settingsRequestEpochRef,n.settingsMutationEpochRef),a=await ht(await fetch(`${e}/api/settings`,{signal:t})),o,s;return ln({request:r,mutation:i},{request:n.settingsRequestEpochRef.current,mutation:n.settingsMutationEpochRef.current,mutationInFlight:n.settingsMutationInFlightRef.current})&&(o=a,s=a.startupHealth),{settings:o,startupHealthSeed:s}}async function wn(e,t){try{let n=await fetch(`${e}/api/v2`,{signal:t});if(!n.ok)return{maMode:`default`};let r=await n.json();return r.multiAgentMode===`v1`||r.multiAgentMode===`v2`?{maMode:r.multiAgentMode}:{maMode:`default`}}catch(e){if(_n(e,t))throw e;return{maMode:`default`}}}async function Tn(e,t){try{let[n,r]=await Promise.all([fetch(`${e}/healthz`,{signal:t}),fetch(`${e}/api/providers`,{signal:t})]);return{health:await ht(n),providers:await ht(r),error:!1}}catch{return{health:null,providers:[],error:!0}}}async function En(e,t){let[n,r]=await Promise.all([fetch(`${e}/api/injection-model`,{signal:t}).catch(()=>null),fetch(`${e}/api/effort-caps`,{signal:t}).catch(()=>null)]),i;try{if(n?.ok){let e=await n.json();i={...gn(e),injectionEfforts:e.efforts??[],injectionAvailable:e.available??[]}}}catch{}let a;try{if(r?.ok){let e=await r.json();a={effortCap:e.effortCap??``,subagentEffortCap:e.subagentEffortCap??``}}}catch{}return{injection:i,effortCaps:a}}var Dn=`ocx.dash.controls.v1:`,On=`ocx.dash.overview.v1:`,kn=`ocx.dash.usage30d.v1:`,An=`ocx.dash.startup.v1:`,jn=`ocx.dash.maMode.v1:`;function Mn(e){return`${Dn}${e}`}function Nn(e){let{locale:t,t:n}=Ve(),[r,i]=(0,_.useState)(ft),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(new Set),l=(0,_.useMemo)(()=>Y(Mn(e)),[e]),u=(0,_.useMemo)(()=>Y(`${On}${e}`),[e]),d=(0,_.useMemo)(()=>Y(`${kn}${e}`),[e]),f=(0,_.useMemo)(()=>{let t=Y(`${An}${e}`);return t===`error`?null:t},[e]),p=(0,_.useMemo)(()=>Y(`${jn}${e}`),[e]),[m,h]=(0,_.useState)(()=>u?.health??null),[g,v]=(0,_.useState)(()=>f),[y,b]=(0,_.useState)(()=>u?.providers??[]),[x,S]=(0,_.useState)([]),[C,w]=(0,_.useState)(()=>l?.settings??null),[T,E]=(0,_.useState)(()=>l?.sidecar??null),[D,O]=(0,_.useState)(()=>l?.shadowCall??null),[k,A]=(0,_.useState)(()=>d),[j,M]=(0,_.useState)(!1),[N,P]=(0,_.useState)(!1),[F,L]=(0,_.useState)(!1),[R,z]=(0,_.useState)(!1),[B,V]=(0,_.useState)(!1),[H,U]=(0,_.useState)(()=>p??`default`),[W,ee]=(0,_.useState)(!1),[te,ne]=(0,_.useState)(!1),[re,G]=(0,_.useState)(!1),[ie,ae]=(0,_.useState)(!1),[oe,se]=(0,_.useState)(``),[ce,le]=(0,_.useState)(``),[ue,de]=(0,_.useState)([]),[fe,pe]=(0,_.useState)([]),[me,he]=(0,_.useState)(!1),[ge,_e]=(0,_.useState)(!0),[ve,ye]=(0,_.useState)(!1),[be,xe]=(0,_.useState)(``),[Se,Ce]=(0,_.useState)(``),[we,Te]=(0,_.useState)(!1),[Ee,De]=(0,_.useState)(null),[Oe,ke]=(0,_.useState)(null),[Ae,je]=(0,_.useState)([]),[Me,Ne]=(0,_.useState)(!1),[Pe,Fe]=(0,_.useState)(`latest`),[Ie,Le]=(0,_.useState)(!0),[Re,ze]=(0,_.useState)(!1),Be=(0,_.useRef)(0),K=(0,_.useRef)(null),He=(0,_.useRef)(0),Ue=(0,_.useRef)(0),We=(0,_.useRef)(0),Ke=(0,_.useRef)(!1),qe=(0,_.useRef)(0),Je=(0,_.useRef)(0),Ye=(0,_.useRef)(!1),[Xe,Ze]=(0,_.useState)(null),[Qe,$e]=(0,_.useState)(null),[et,tt]=(0,_.useState)(null),[nt,rt]=(0,_.useState)(!1),[it,q]=(0,_.useState)(!1),at=(0,_.useRef)(null),ot=(0,_.useRef)(null),st=(0,_.useRef)(null),ct=(0,_.useRef)(null),lt=Tt(re,at),J=Tt(Me,ot),ut=Tt(te,st),dt=Tt(ie,ct);(0,_.useEffect)(()=>{let e=()=>i(ft());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),(0,_.useEffect)(()=>()=>{He.current+=1,K.current!==null&&(window.clearTimeout(K.current),K.current=null)},[]);let mt=(0,_.useRef)(f),gt=(0,_.useRef)(0),vt=(0,_.useRef)({settingsRequestEpochRef:Ue,settingsMutationEpochRef:We,settingsMutationInFlightRef:Ke,shadowCallRequestEpochRef:qe,shadowCallMutationEpochRef:Je,shadowCallMutationInFlightRef:Ye}).current,yt=I(`dashboard-startup-health:${e}`,[e],t=>vn(e,t),{pollMs:3e4}),St=pn(yt.data),Ct=yt.refresh;(0,_.useEffect)(()=>{if(!St)return;let e=window.setTimeout(()=>{Ct()},dn);return()=>window.clearTimeout(e)},[St,Ct]);let wt=I(`dashboard-overview:${e}`,[e],t=>Tn(e,t),{pollMs:5e3}),Et=m!==null||wt.data!==void 0,Dt=I(`dashboard-ma-mode:${e}`,[e],t=>wn(e,t),{pollMs:5e3}),Ot=I(`dashboard-sidecars:${e}`,[e],async t=>{let n=gt.current;return{...await Sn(e,t,vt),startupHealthGeneration:n}},{pollMs:5e3}),kt=I(`dashboard-settings:${e}`,[e],async t=>{let n=gt.current;return{...await Cn(e,t,vt),startupHealthGeneration:n}},{pollMs:5e3}),At=I(`dashboard-multi-agent:${e}`,[e],t=>En(e,t),{pollMs:5e3,enabled:Et}),jt=I(`dashboard-usage:${e}`,[e],t=>xn(e,t),{pollMs:6e4,enabled:Et}),Mt=I(`dashboard-diagnostics:${e}`,[e],t=>yn(e,t),{pollMs:hn,enabled:Et}),Nt=I(`dashboard-models:${e}`,[e,it],t=>bn(e,t),{enabled:Et&&!it});(0,_.useEffect)(()=>{if(yt.data!==void 0){let t=yt.data;gt.current+=1,v(t.status),mt.current=t.status,t.status!==`error`&&!t.stale&&X(`${An}${e}`,t.status)}},[yt.data,e]),(0,_.useEffect)(()=>{let t=wt.data;t&&(t.health&&(h(t.health),b(t.providers),X(`${On}${e}`,{health:t.health,providers:t.providers})),q(t.error))},[wt.data,e]),(0,_.useEffect)(()=>{Dt.data!==void 0&&(U(Dt.data.maMode),X(`${jn}${e}`,Dt.data.maMode))},[Dt.data,e]);let Pt=Dt.data!==void 0||p!==null;(0,_.useEffect)(()=>{let e=At.data;e&&(e.injection&&(_e(e.injection.multiAgentGuidanceEnabled),ye(e.injection.syncCodexSubagentDefaults),se(e.injection.injectionModel),le(e.injection.injectionEffort),de(e.injection.injectionEfforts),pe(e.injection.injectionAvailable)),e.effortCaps&&(xe(e.effortCaps.effortCap),Ce(e.effortCaps.subagentEffortCap)))},[At.data]),(0,_.useEffect)(()=>{let t=Ot.data;if(!t)return;E(t.sidecar),t.shadowCall!==void 0&&O(t.shadowCall);let n=Y(Mn(e))??{};X(Mn(e),{...n,sidecar:t.sidecar,...t.shadowCall===void 0?{}:{shadowCall:t.shadowCall}})},[Ot.data,e]),(0,_.useEffect)(()=>{let t=kt.data;if(t){if(t.settings!==void 0&&w(t.settings),t.startupHealthSeed!==void 0&&t.startupHealthGeneration===gt.current){let n=mn(mt.current,t.startupHealthSeed);v(n),mt.current=n,n&&X(`${An}${e}`,n)}if(t.settings!==void 0){let n=Y(Mn(e))??{};X(Mn(e),{...n,settings:t.settings})}}},[kt.data,e]),(0,_.useEffect)(()=>{jt.data!==void 0&&(A(jt.data),X(`${kn}${e}`,jt.data))},[jt.data,e]),(0,_.useEffect)(()=>{Mt.data&&je(Mt.data)},[Mt.data]),(0,_.useEffect)(()=>{Nt.data&&S(Nt.data),L(Nt.loading)},[Nt.data,Nt.loading]),(0,_.useEffect)(()=>()=>{Ue.current+=1,qe.current+=1},[]);let Ft=I(et?.id&&et.restart?`update-job:${e}:${et.id}`:`update-job:idle:${e}`,[e,et?.id,et?.restart,et?.latestVersion],async t=>{if(!et?.id||!et.restart)return{reconnecting:!1};let n=et.latestVersion;try{let r=await ht(await fetch(`${e}/api/update/status?jobId=${encodeURIComponent(et.id)}`,{signal:t}));if(r.job){if(r.job.status===`failed`)return{job:r.job,reconnecting:!1};if(n)try{if((await ht(await fetch(`${e}/healthz`,{cache:`no-store`,signal:t}))).version===n)return{job:r.job,reconnecting:!1,reload:!0}}catch{return{job:r.job,reconnecting:!0}}return{job:r.job,reconnecting:!1}}}catch{return{reconnecting:!0}}return{reconnecting:!1}},{pollMs:1500,enabled:!!(et?.id&&et.restart),pauseWhenHidden:!1});(0,_.useEffect)(()=>{let e=Ft.data;e&&(`job`in e&&e.job&&tt(e.job),rt(e.reconnecting),`reload`in e&&e.reload&&window.location.reload())},[Ft.data]);let It=(0,_.useMemo)(()=>{let e={};for(let t of x)(e[t.provider]??=[]).push(t);return Object.entries(e).sort(([e],[t])=>e.localeCompare(t))},[x]),Lt=(0,_.useMemo)(()=>{let e=a.trim().toLowerCase();if(!e)return It;let t=[];for(let[n,r]of It){let i=r.filter(t=>t.id.toLowerCase().includes(e)||n.toLowerCase().includes(e));i.length>0&&t.push([n,i])}return t},[It,a]),Rt=(0,_.useMemo)(()=>{let e=xt(x);for(let t of[T?.webSearch.model,T?.vision.model])t&&!e.some(e=>e.value===t)&&e.unshift({value:t,label:t});return e},[x,T]),zt=async t=>{if(!T||j)return;let n=T,r={webSearch:bt(T.webSearch,t.webSearch),vision:bt(T.vision,t.vision)};M(!0),E(r);try{let n=await ht(await fetch(`${e}/api/sidecar-settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),`save failed`);E({webSearch:n.webSearch,vision:n.vision});let r=Y(Mn(e))??{};X(Mn(e),{...r,sidecar:{webSearch:n.webSearch,vision:n.vision}})}catch{E(n)}finally{M(!1)}};async function Bt(t){if(!D||N)return;let n=D,r={...D,...t};P(!0),Ye.current=!0,O(r);try{if(!(await fetch(`${e}/api/shadow-call-settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).ok)throw Error(`shadow-call save failed`);Je.current+=1}catch{O(n)}finally{Ye.current=!1,P(!1)}}let Vt=async t=>{if(!(W||H===t)){ee(!0);try{(await fetch(`${e}/api/v2`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({multiAgentMode:t})})).ok&&(U(t),X(`${jn}${e}`,t))}catch{}finally{ee(!1)}}},Ht=async t=>{if(!me){he(!0);try{if(!(await fetch(`${e}/api/injection-model`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).ok)throw Error(`injection save failed`);let n=await ht(await fetch(`${e}/api/injection-model`)),r=gn(n);_e(r.multiAgentGuidanceEnabled),ye(r.syncCodexSubagentDefaults),se(r.injectionModel),le(r.injectionEffort),Array.isArray(n.efforts)&&de(n.efforts),Array.isArray(n.available)&&pe(n.available)}catch{}finally{he(!1)}}},Ut=async()=>{if(!C||R)return;let t=!C.codexAutoStart;z(!0),Ke.current=!0,w({...C,codexAutoStart:t});try{let n=await ht(await fetch(`${e}/api/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({codexAutoStart:t})}),`save failed`);We.current+=1,w(e=>e&&{...e,codexAutoStart:n.codexAutoStart,startupHealth:n.startupHealth??e.startupHealth})}catch{w(e=>e&&{...e,codexAutoStart:!t}),q(!0)}finally{Ke.current=!1,z(!1)}},Wt=async()=>{if(!B){V(!0),De(null),ke(null);try{let t=await ht(await fetch(`${e}/api/sync`,{method:`POST`}),`sync failed`);De(t),t.projectConfigGrouped&&je(t.projectConfigGrouped)}catch(e){ke(e instanceof Error?e.message:String(e))}finally{V(!1)}}},Gt=async(t,n=!1)=>{n&&(Be.current=0),K.current!==null&&(window.clearTimeout(K.current),K.current=null);let r=++He.current;ze(!0),$e(null),Ze(null);try{let n=await ht(await fetch(`${e}/api/update/check?tag=${t}`),`update check failed`);if(r!==He.current)return;if(Ze(n),n.reason===`latest_unavailable`&&Be.current<2){let e=++Be.current;K.current=window.setTimeout(()=>{r===He.current&&(K.current=null,Gt(t))},800*e);return}n.reason!==`latest_unavailable`&&(Be.current=0),ze(!1)}catch(e){if(r!==He.current)return;$e(e instanceof Error?e.message:String(e)),ze(!1)}},Kt=()=>{He.current+=1,K.current!==null&&(window.clearTimeout(K.current),K.current=null),ze(!1),Ne(!1)},qt=()=>{let e=_t(m?.version);Fe(e),Le(!0),Ne(!0),Gt(e,!0)},Jt=e=>{Fe(e),Gt(e,!0)},Yt=(0,_.useRef)(qt);return(0,_.useEffect)(()=>{Yt.current=qt}),(0,_.useEffect)(()=>{let e=()=>{pt()&&(Ge(`dashboard`),Yt.current())},t=pt()?window.setTimeout(e,0):null;return window.addEventListener(`hashchange`,e),()=>{t!==null&&window.clearTimeout(t),window.removeEventListener(`hashchange`,e)}},[]),{apiBase:e,locale:t,t:n,selectedSection:r,setSelectedSection:i,modelQuery:a,setModelQuery:o,expandedProviders:s,setExpandedProviders:c,health:m,startupHealth:g,providers:y,models:x,settings:C,sidecar:T,shadowCall:D,usage30d:k,usageLoading:jt.loading&&!k,healthLoading:wt.loading&&!m,sidecarSaving:j,shadowCallSaving:N,modelsLoading:F,settingsSaving:R,syncing:B,maMode:H,maModeResolved:Pt,maBusy:W,setMaHelpOpen:ne,maHelpOpen:te,effortCapHelpOpen:re,setEffortCapHelpOpen:G,shadowCallHelpOpen:ie,setShadowCallHelpOpen:ae,injectionModel:oe,injectionEffort:ce,injectionEfforts:ue,injectionAvailable:fe,injectionSaving:me,multiAgentGuidanceEnabled:ge,syncCodexSubagentDefaults:ve,saveInjection:Ht,effortCap:be,subagentEffortCap:Se,effortCapSaving:we,setEffortCap:xe,setSubagentEffortCap:Ce,setEffortCapSaving:Te,syncResult:Ee,syncError:Oe,projectConfigWarnings:Ae,updateOpen:Me,updateChannel:Pe,setUpdateRestart:Le,updateRestart:Ie,updateLoading:Re,updateCheck:Xe,updateError:Qe,updateJob:et,reconnecting:nt,error:it,effortCapHelpTriggerRef:at,updateTriggerRef:ot,maHelpTriggerRef:st,shadowCallHelpTriggerRef:ct,effortCapHelpDialogRef:lt,updateDialogRef:J,maHelpDialogRef:ut,shadowCallHelpDialogRef:dt,filteredGroups:Lt,sidecarModels:Rt,saveSidecar:zt,saveShadowCall:Bt,switchMaMode:Vt,toggleCodexAutoStart:Ut,runSync:Wt,fetchUpdateCheck:Gt,closeUpdateDialog:Kt,openUpdateDialog:qt,changeUpdateChannel:Jt,runUpdate:async()=>{if(Xe?.canUpdate){$e(null);try{let t=await ht(await fetch(`${e}/api/update/run`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({tag:Pe,restart:Ie})}),`update failed to start`);if(!t.job)throw Error(`update failed to start`);tt(t.job),rt(!1),Kt()}catch(e){$e(e instanceof Error?e.message:String(e))}}}}}function Pn(e){Ke(mt(e))}function Fn({apiBase:e}){let t=Nn(e),{t:n,error:r,selectedSection:i,providers:a,models:o,modelsLoading:s,modelQuery:c,setModelQuery:l,filteredGroups:u,expandedProviders:d,setExpandedProviders:f}=t;if(r)return(0,z.jsx)(ot,{style:{marginTop:40},icon:(0,z.jsx)(de,{}),title:(0,z.jsx)(`span`,{style:{color:`var(--red)`},children:n(`dash.cannotConnect`)}),children:(0,z.jsx)(Ue,{k:`dash.runStart`,cmd:`ocx start`})});let p=(0,z.jsx)(on,{...t}),m=(0,z.jsx)(sn,{t:n,providers:a}),h=(0,z.jsx)(jt,{t:n,models:o,modelsLoading:s,modelQuery:c,setModelQuery:l,filteredGroups:u,expandedProviders:d,setExpandedProviders:f}),g=(0,z.jsx)(At,{...t}),_=[{id:`overview`,label:n(`dash.workspace.overview`),body:p},{id:`providers`,label:n(`dash.activeProviders`),body:m},{id:`models`,label:n(`dash.availableModels`),body:h}],v=_.find(e=>e.id===i)??_[0],y=Pn,b=e=>{let t=_.findIndex(e=>e.id===i),n=-1;if(e.key===`ArrowRight`?n=(t+1)%_.length:e.key===`ArrowLeft`?n=(t-1+_.length)%_.length:e.key===`Home`?n=0:e.key===`End`&&(n=_.length-1),n<0)return;e.preventDefault();let r=_[n];y(r.id),document.getElementById(`dashboard-tab-${r.id}`)?.focus()};return(0,z.jsxs)(`div`,{className:`dashboard-workspace-shell`,children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:n(`nav.dashboard`)})}),(0,z.jsx)(`p`,{className:`page-sub`,children:n(`dash.subtitle`)}),(0,z.jsx)(`div`,{className:`page-tabs`,role:`tablist`,"aria-label":n(`dash.workspace.sections`),children:_.map(e=>(0,z.jsx)(`button`,{type:`button`,role:`tab`,id:`dashboard-tab-${e.id}`,"aria-selected":i===e.id,"aria-controls":`dashboard-panel-${e.id}`,tabIndex:i===e.id?0:-1,className:`page-tab${i===e.id?` page-tab--active`:``}`,onClick:()=>y(e.id),onKeyDown:b,children:e.label},e.id))}),(0,z.jsx)(`section`,{className:`dashboard-workspace-main`,role:`tabpanel`,id:`dashboard-panel-${v.id}`,"aria-labelledby":`dashboard-tab-${v.id}`,tabIndex:0,children:v.body}),g]})}var In=`https://chatgpt.com/backend-api/codex`,Ln=`openai`;function Rn(e){try{let t=new URL(e.trim());if(t.username||t.password||t.search||t.hash)return;let n=t.pathname.replace(/\/+$/,``);return`${t.origin}${n}`}catch{return}}function zn(e){try{let t=new URL(e).hostname.replace(/^\[|\]$/g,``).toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`::1`}catch{return!1}}function Bn(e){return e.keyOptional===!0||e.authMode===`oauth`||e.authMode===`forward`||e.authMode===`local`||zn(e.baseUrl)||e.hasApiKey===!0}function Vn(e){return e.adapter===`openai-responses`&&e.authMode===`forward`&&Rn(e.baseUrl)===In}function Hn(e,t){return e===Ln&&Vn(t)}function Un(e){return e.freeTier===!0||e.keyOptional===!0||e.authMode===`local`||zn(e.baseUrl)}function Wn(e,t){return Hn(e,t)?`accounts`:Un(t)?`free`:`paid`}function Gn(e,t){let n=[...e],r=(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`}),i=e=>e.tier??Wn(e.name,e);switch(t){case`az`:return n.sort(r);case`za`:return n.sort((e,t)=>r(t,e));case`free-paid`:return n.sort((e,t)=>(i(e)===`free`?0:1)-(i(t)===`free`?0:1)||r(e,t));case`paid-free`:return n.sort((e,t)=>(i(e)===`free`)-+(i(t)===`free`)||r(e,t));case`accounts-first`:return n.sort((e,t)=>{let n=e=>{let t=i(e);return t===`accounts`?0:t===`free`?1:2};return n(e)-n(t)||r(e,t)});default:return n}}function Kn(e){let t=[],n=[],r=[];for(let[i,a]of Object.entries(e)){if(a.disabled){r.push({name:i,...a});continue}Bn(a)?t.push({name:i,...a,tier:Wn(i,a)}):n.push({name:i,...a})}return{ready:t,needsSetup:n,disabled:r}}function qn(e,t){let n=new Set(Object.entries(t).filter(([,e])=>e).map(([e])=>e));if(n.size===0)return e;let r=e=>e.map(e=>n.has(e.name)?{...e,activeNeedsReauth:!0}:e);return{ready:r(e.ready),needsSetup:r(e.needsSetup),disabled:e.disabled}}function Jn(e){return e.disabled?`disabled`:`activeNeedsReauth`in e&&e.activeNeedsReauth?`needs-setup`:Bn(e)?`ready`:`needs-setup`}function Yn(e){let t=e.openai,n=e.chatgpt;if(!t||!n||!Hn(`openai`,t)||!Vn(n))return e;let r={...e};return delete r.chatgpt,r}function Xn(e){return e.authMode===`local`||zn(e.baseUrl)}var Zn=[`ollama`,`vllm`,`lm-studio`,`lmstudio`,`litellm`,`localai`];function Qn(e){let t=(e.authMode??``).toLowerCase();if(t===`oauth`||t===`forward`)return`login`;if(Xn(e))return`local`;let n=`${e.name??``} ${e.adapter} ${e.baseUrl}`.toLowerCase();return Zn.some(e=>n.includes(e))?`selfHosted`:`cloud`}function $n(e){if(!e||typeof e!=`object`)return{};let t=e.available;if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))Array.isArray(r)&&(n[e]=r.filter(e=>typeof e==`string`));return n}function er(e){if(!e||typeof e!=`object`)return{};let t=e.liveModelCounts;if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r!=`number`||!Number.isFinite(r)||r<0||(n[e]=Math.floor(r));return n}function tr(e){if(!e||typeof e!=`object`)return{};let t=e.selected;if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))Array.isArray(r)&&(n[e]=r.filter(e=>typeof e==`string`));return n}function nr(e){let t={};for(let[n,r]of Object.entries($n(e)))t[n]=r.length;return t}function rr(e){return Object.entries(e).filter(e=>typeof e[1].requests==`number`&&e[1].requests>0).map(([e,t])=>({name:e,...t,requests:t.requests})).sort((e,t)=>t.requests-e.requests||e.name.localeCompare(t.name))}var ir={justNow:`Just now`,notChecked:`Not checked`,minutesAgo:e=>`${e}m ago`,hoursAgo:e=>`${e}h ago`,daysAgo:e=>`${e}d ago`};function ar(e,t,n){let r=typeof t==`object`&&t?t:ir,i=typeof t==`number`?t:n??Date.now();if(e===void 0||!Number.isFinite(e))return r.notChecked;let a=Math.max(0,i-e),o=Math.floor(a/6e4);if(o<1)return r.justNow;if(o<60)return r.minutesAgo(o);let s=Math.floor(o/60);return s<24?r.hoursAgo(s):r.daysAgo(Math.floor(s/24))}function or(e){return{justNow:e(`time.justNow`),notChecked:e(`time.notChecked`),minutesAgo:t=>e(`time.minutesAgo`,{n:t}),hoursAgo:t=>e(`time.hoursAgo`,{n:t}),daysAgo:t=>e(`time.daysAgo`,{n:t})}}function sr(e,t){let n=[];for(let r of e.ready)r.activeNeedsReauth&&n.push({name:r.name,reason:t[r.name]??`Active account needs re-authentication`});for(let r of e.needsSetup){let e=r.activeNeedsReauth?t[r.name]??`Active account needs re-authentication`:t[r.name]??`Missing credentials`;n.push({name:r.name,reason:e})}for(let r of e.disabled){let e=t[r.name];e&&n.push({name:r.name,reason:e})}return n}function cr(e){return e===`Active account needs re-authentication`?`reauth`:e===`Missing credentials`?`missing`:`custom`}function lr(e,t=`en`){if(e===void 0)return`—`;if(t.toLowerCase().slice(0,2)===`de`){let t=e=>e.replace(/\.0+$/,``).replace(`.`,`,`);return e>=1e9?`${t((e/1e9).toFixed(2))} Mrd.`:e>=1e6?`${t((e/1e6).toFixed(1))} Mio.`:e>=1e3?`${t((e/1e3).toFixed(1))} Tsd.`:String(e)}return e>=1e9?`${(e/1e9).toFixed(2).replace(/\.?0+$/,``)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ur(e,t=`en`){return lr(e,t)}function dr(e,t=`en`){return e==null||!Number.isFinite(e)||e<0?`—`:`~$${new Intl.NumberFormat(t,{minimumFractionDigits:4,maximumFractionDigits:4}).format(e)}`}var fr={anthropic:`claude-color.svg`,"anthropic-apikey":`claude-color.svg`,"azure-openai":`openai.svg`,chatgpt:`openai.svg`,"cloudflare-ai-gateway":`cloudflare-ai-gateway-color.svg`,"cloudflare-workers-ai":`cloudflare-ai-gateway-color.svg`,cursor:`cursor-color.svg`,deepseek:`deepseek-color.svg`,firepass:`firepass-color.svg`,fireworks:`fireworks-color.svg`,github:`github-copilot-color.svg`,"github-copilot":`copilot-color.svg`,"gitlab-duo":`gitlab-duo-color.svg`,google:`gemini-color.svg`,"google-antigravity":`antigravity-color.svg`,"google-vertex":`gemini-color.svg`,groq:`groq-color.svg`,huggingface:`huggingface-color.svg`,kimi:`kimi-color.svg`,"kimi-code":`kimi-color.svg`,kiro:`kiro-color.svg`,"lm-studio":`lm-studio-color.svg`,mistral:`mistral-color.svg`,moonshot:`moonshot-color.svg`,nvidia:`nvidia-color.svg`,ollama:`ollama-color.svg`,"ollama-cloud":`ollama-color.svg`,openai:`openai.svg`,"openai-apikey":`openai.svg`,"opencode-free":`opencode.svg`,"opencode-go":`opencode.svg`,"opencode-zen":`opencode.svg`,openrouter:`openrouter-color.svg`,qianfan:`qianfan-color.svg`,alibaba:`alibaba-color.svg`,"alibaba-token-plan":`alibaba-color.svg`,"alibaba-token-plan-intl":`alibaba-color.svg`,"qwen-cloud":`qwen-portal-color.svg`,"vercel-ai-gateway":`vercel-ai-gateway-color.svg`,vllm:`vllm-color.svg`,xai:`grok-color.svg`,"mimo-free":`xiaomi-color.svg`,xiaomi:`xiaomi-color.svg`},pr={anthropic:`Anthropic Claude`,"anthropic-apikey":`Anthropic Claude`,chatgpt:`ChatGPT`,openai:`OpenAI (Codex login)`,"openai-apikey":`OpenAI API`,"azure-openai":`Azure OpenAI`,"cloudflare-ai-gateway":`Cloudflare AI Gateway`,"cloudflare-workers-ai":`Cloudflare Workers AI`,nvidia:`NVIDIA NIM`,ollama:`Ollama`,"ollama-cloud":`Ollama Cloud`,xai:`xAI Grok`,"mimo-free":`MiMo Free`,xiaomi:`Xiaomi`,cursor:`Cursor`,deepseek:`DeepSeek`,github:`GitHub`,"github-copilot":`GitHub Copilot`,"gitlab-duo":`GitLab Duo`,openrouter:`OpenRouter`,"opencode-go":`OpenCode Go`,"opencode-free":`OpenCode Free`,"opencode-zen":`OpenCode Zen`,mistral:`Mistral`,groq:`Groq`,alibaba:`Alibaba Coding Plan`,"alibaba-token-plan":`Alibaba Token Plan`,"alibaba-token-plan-intl":`Alibaba Token Plan (Intl)`,kimi:`Kimi`,"kimi-code":`Kimi`,moonshot:`Moonshot`,google:`Google`,"google-vertex":`Google Vertex`,"lm-studio":`LM Studio`,huggingface:`Hugging Face`,"qwen-cloud":`Qwen Cloud`,siliconflow:`SiliconFlow`,"tencent-coding-plan":`Tencent Cloud Coding Plan`,"vercel-ai-gateway":`Vercel AI Gateway`,vllm:`vLLM`,litellm:`LiteLLM`},mr={volcengine:`provider.name.volcengine`,"volcengine-coding-plan":`provider.name.volcengineCodingPlan`,"volcengine-agent-plan":`provider.name.volcengineAgentPlan`},hr=new Set([...Object.keys(pr),...Object.keys(mr)]);function gr(e){return fr[e.toLowerCase()]}function _r(e,t){let n=gr(e);return n?`/provider-icons/${n}`:void 0}function vr(e,t){let n=e.toLowerCase(),r=mr[n];return r?t(r):pr[n]?pr[n]:e===n&&/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)?e.split(`-`).map(e=>e&&e[0].toUpperCase()+e.slice(1)).join(` `):e}function yr(e){return hr.has(e.toLowerCase())}function br(e,t){let n=Jn(e);return n===`disabled`?t(`prov.disabledBadge`):n===`ready`?t(`pws.status.ready`):`activeNeedsReauth`in e&&e.activeNeedsReauth?t(`pws.status.needsAttention`):t(`pws.status.needsSetup`)}function xr(e,t){switch(e.authMode){case`oauth`:return t(`modal.badge.oauth`);case`forward`:return t(`pws.auth.chatgptPassthrough`);case`local`:return t(`modal.badge.local`);case`key`:return t(`modal.badge.apiKey`);default:return e.authMode??(e.keyOptional?t(`pws.auth.noKey`):t(`modal.badge.apiKey`))}}function Sr(e){let t=Jn(e);return t===`disabled`?`providers-workspace-rail-status providers-workspace-rail-status--inactive`:t===`ready`?`providers-workspace-rail-status providers-workspace-rail-status--active`:`providers-workspace-rail-status providers-workspace-rail-status--warning`}function Cr({name:e,adapter:t,baseUrl:n,cls:r}){let i=_r(e,{adapter:t,baseUrl:n});return(0,z.jsx)(`span`,{className:r,children:i?(0,z.jsx)(`img`,{src:i,alt:``,"aria-hidden":`true`}):(0,z.jsx)(H,{"aria-hidden":`true`})})}function wr({item:e,selected:t,tabbable:n,modelCount:r,isDefault:i,showConfigId:a,onClick:o,onFocus:s}){let c=K(),l=Un(e),u=Xn(e),d=br(e,c),f=vr(e.name,c),p=a?`${f} (${e.name})`:f,m=`${i?c(`pws.rail.suffixDefault`):``}${u?c(`pws.rail.suffixLocal`):l?c(`pws.rail.suffixFree`):``}`,h=r!==void 0&&r>0?r===1?c(`pws.modelCountOne`):c(`pws.modelCount`,{count:r}):``,g=[a?e.name:``,h].filter(Boolean).join(` · `);return(0,z.jsxs)(`button`,{type:`button`,className:`providers-workspace-rail-row${t?` providers-workspace-rail-row--selected`:``}`,onClick:o,role:`option`,"aria-selected":t,tabIndex:n?0:-1,"aria-label":c(`pws.rail.selectAria`,{name:p,status:d,suffix:m}),title:p,onFocus:s,children:[(0,z.jsx)(Cr,{name:e.name,adapter:e.adapter,baseUrl:e.baseUrl,cls:`providers-workspace-rail-icon`}),(0,z.jsxs)(`span`,{className:`providers-workspace-rail-copy`,children:[(0,z.jsxs)(`span`,{className:`providers-workspace-rail-primary`,children:[(0,z.jsx)(`span`,{className:`providers-workspace-rail-name-label`,title:f,children:f}),u?(0,z.jsx)(`span`,{className:`pwi-rail-badge pwi-rail-badge--local`,title:c(`pws.localTitle`),children:c(`modal.badge.local`)}):l?(0,z.jsx)(`span`,{className:`pwi-rail-badge pwi-rail-badge--free`,title:c(`pws.freeTitle`),children:c(`modal.badge.free`)}):null]}),(0,z.jsx)(`span`,{className:`providers-workspace-rail-secondary`,title:g||void 0,children:g||`\xA0`})]}),(0,z.jsxs)(`span`,{className:`providers-workspace-rail-trail`,children:[i&&(0,z.jsx)(`span`,{className:`pwi-default-star`,title:c(`prov.defaultBadge`),"aria-label":c(`prov.defaultBadge`),children:(0,z.jsx)(Me,{width:17,height:17,"aria-hidden":`true`})}),(0,z.jsx)(`span`,{className:Sr(e),title:d,"aria-hidden":`true`})]})]})}function Tr(e){let t=e?.quota;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,i=Array.isArray(n.customWindows)?n.customWindows.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return typeof t.label!=`string`||r(t.percent)===void 0?[]:[{label:t.label,percent:t.percent,...r(t.resetAt)===void 0?{}:{resetAt:t.resetAt},...typeof t.valueLabel==`string`&&t.valueLabel.trim()?{valueLabel:t.valueLabel}:{}}]}):[],a={...r(n.fiveHourPercent)===void 0?{}:{fiveHourPercent:n.fiveHourPercent},...r(n.fiveHourResetAt)===void 0?{}:{fiveHourResetAt:n.fiveHourResetAt},...r(n.weeklyPercent)===void 0?{}:{weeklyPercent:n.weeklyPercent},...r(n.weeklyResetAt)===void 0?{}:{weeklyResetAt:n.weeklyResetAt},...r(n.monthlyPercent)===void 0?{}:{monthlyPercent:n.monthlyPercent},...r(n.monthlyResetAt)===void 0?{}:{monthlyResetAt:n.monthlyResetAt},...i.length>0?{customWindows:i}:{},updatedAt:r(n.updatedAt)??e?.updatedAt??Date.now()};return a.fiveHourPercent!==void 0||a.weeklyPercent!==void 0||a.monthlyPercent!==void 0||(a.customWindows?.length??0)>0?a:null}function Er(e){if(!e?.trim())return``;let[t,n]=e.split(`:`,2);return n?`${t} · ${n.replace(/-/g,` `)}`:e}function Dr(e,t,n,r,i,a){let o=r&&r.length>0?r:t?[t]:[],s=[...new Set([...a?e:o,...i])],c=n.trim().toLowerCase();return c?s.filter(e=>e.toLowerCase().includes(c)):s}function Or(e){let t=e?.trim().toLowerCase();return t===`go`||t===`free`}function kr(e,t){return!e||!Or(t)?e:{...e.monthlyPercent===void 0?{}:{monthlyPercent:e.monthlyPercent},...e.monthlyResetAt===void 0?{}:{monthlyResetAt:e.monthlyResetAt},...e.resetCredits===void 0?{}:{resetCredits:e.resetCredits},updatedAt:e.updatedAt}}function Ar(e){return e===`5h`?0:e===`First-party models`?2:e===`API usage`?3:5}function jr(e,t){switch(e){case`First-party models`:return t(`quota.cursorFirstParty`);case`API usage`:return t(`quota.cursorApiUsage`);case`Total subscription credits`:return t(`quota.totalSubscriptionCredits`);default:return e}}function Mr(e,t,n){let r=kr(e,t);if(!r)return[];let i=[];typeof r.fiveHourPercent==`number`&&i.push({rank:0,row:{label:n(`codexAuth.fiveHour`),limitLabel:n(`quota.fiveHourLimit`),percent:r.fiveHourPercent,resetAt:r.fiveHourResetAt}}),typeof r.weeklyPercent==`number`&&i.push({rank:1,row:{label:n(`codexAuth.weekly`),limitLabel:n(`quota.weeklyLimit`),percent:r.weeklyPercent,resetAt:r.weeklyResetAt}}),typeof r.monthlyPercent==`number`&&i.push({rank:4,row:{label:n(`codexAuth.monthly`),limitLabel:n(`quota.monthlyLimit`),percent:r.monthlyPercent,resetAt:r.monthlyResetAt}});for(let e of r.customWindows??[]){let t=jr(e.label,n);i.push({rank:Ar(e.label),row:{label:t,limitLabel:t,percent:e.percent,resetAt:e.resetAt,...e.valueLabel===void 0?{}:{valueLabel:e.valueLabel}}})}return i.sort((e,t)=>e.rank-t.rank).map(e=>e.row)}function Nr(e){if(!e)return-1;let t=[e.fiveHourPercent,e.weeklyPercent,e.monthlyPercent].filter(e=>typeof e==`number`);for(let n of e.customWindows??[])typeof n.percent==`number`&&t.push(n.percent);return t.length?Math.max(...t):-1}function Pr(e){switch(e){case`en`:return`en-GB`;case`de`:return`de-DE`;case`ko`:return`ko-KR`;case`zh`:return`zh-CN`;case`ru`:return`ru-RU`;case`ja`:return`ja-JP`;default:return e}}function Fr(e){return e>=99.5}function Ir(e,t){return t>0&&e>=t}function Lr(e,t){return Ir(e,t)||Fr(e)?`bar-warn`:`bar-green`}function Rr(e){let t=Math.max(0,Math.min(100,e));return t<=0?0:Math.max(4,Math.round(t))}function zr(e){return{"--bar-scale":String(Rr(e)/100)}}function Br({quota:e,plan:t,threshold:n,t:r,className:i,layout:a=`compact`,pending:o=!1}){let{locale:s}=Ve(),c=Mr(e,t,r);return c.length===0?o?a===`stacked`?(0,z.jsxs)(`div`,{className:`quota-stacked quota-stacked--pending${i?` ${i}`:``}`,"aria-busy":`true`,role:`status`,children:[Array.from({length:2},(e,t)=>(0,z.jsxs)(`div`,{className:`quota-stacked-row quota-stacked-row--skeleton`,"aria-hidden":`true`,children:[(0,z.jsxs)(`div`,{className:`quota-stacked-head`,children:[(0,z.jsx)(`span`,{className:`quota-skel quota-skel--label`,style:{width:72}}),(0,z.jsx)(`span`,{className:`quota-skel quota-skel--time`,style:{width:64}})]}),(0,z.jsxs)(`div`,{className:`quota-stacked-bar-row`,children:[(0,z.jsx)(`span`,{className:`quota-skel quota-skel--bar`,style:{height:6,flex:1}}),(0,z.jsx)(`span`,{className:`quota-skel quota-skel--val`,style:{width:36}})]})]},t)),(0,z.jsx)(`span`,{className:`sr-only`,children:r(`common.loading`)})]}):(0,z.jsxs)(`div`,{className:`codex-account-quota-slot quota-compact quota-compact--pending${i?` ${i}`:``}`,"aria-busy":`true`,role:`status`,children:[Array.from({length:2},(e,t)=>(0,z.jsxs)(`div`,{className:`quota-row quota-row--skeleton`,"aria-hidden":`true`,children:[(0,z.jsx)(`span`,{className:`quota-skel quota-skel--label`}),(0,z.jsx)(`span`,{className:`quota-skel quota-skel--reset`}),(0,z.jsx)(`span`,{className:`quota-skel quota-skel--day`}),(0,z.jsx)(`span`,{className:`quota-skel quota-skel--time`}),(0,z.jsx)(`span`,{className:`quota-skel quota-skel--bar`}),(0,z.jsx)(`span`,{className:`quota-skel quota-skel--val`})]},t)),(0,z.jsx)(`span`,{className:`sr-only`,children:r(`common.loading`)})]}):null:a===`stacked`?(0,z.jsx)(`div`,{className:`quota-stacked${i?` ${i}`:``}`,children:c.map(e=>(0,z.jsx)(Ur,{row:e,threshold:n,t:r,locale:s},e.limitLabel))}):(0,z.jsx)(`div`,{className:`codex-account-quota-slot quota-compact${i?` ${i}`:``}`,children:c.map(e=>e.valueLabel===void 0?(0,z.jsx)(Vr,{label:e.label,percent:e.percent,resetAt:e.resetAt,threshold:n,t:r,locale:s},e.label):(0,z.jsx)(Hr,{label:e.label,value:e.valueLabel},e.label))})}function Vr({label:e,percent:t,resetAt:n,threshold:r,t:i,locale:a}){let o=Fr(t),s=Ir(t,r),c=Lr(t,r),l=Wr(n,i,a);return(0,z.jsxs)(`div`,{className:`quota-row${s?` quota-row--warn`:``}${o?` quota-row--exhausted`:``}`,children:[(0,z.jsx)(`span`,{className:`quota-label`,children:e}),(0,z.jsx)(`span`,{className:`quota-reset-label`,children:i(`codexAuth.resets`)}),(0,z.jsx)(`span`,{className:`quota-reset-day`,children:l.day}),(0,z.jsx)(`span`,{className:`quota-reset-time`,children:l.time}),(0,z.jsx)(`div`,{className:`bar`,children:(0,z.jsx)(`div`,{className:`bar-fill ${c}`,style:zr(t)})}),(0,z.jsxs)(`span`,{className:`quota-val${s?` quota-val--warn`:``}`,title:o?i(`quota.limitReached`):void 0,children:[s&&(0,z.jsx)(de,{width:12,height:12,"aria-hidden":`true`}),Math.round(t),`%`,o?` · ${i(`quota.limitReached`)}`:``]})]})}function Hr({label:e,value:t}){return(0,z.jsxs)(`div`,{className:`quota-row quota-row--value`,children:[(0,z.jsx)(`span`,{className:`quota-label`,children:e}),(0,z.jsx)(`span`,{className:`quota-val`,children:t})]})}function Ur({row:e,threshold:t,t:n,locale:r}){if(e.valueLabel!==void 0)return(0,z.jsxs)(`div`,{className:`quota-stacked-row quota-stacked-row--value`,children:[(0,z.jsx)(`div`,{className:`quota-stacked-head`,children:(0,z.jsx)(`span`,{className:`quota-stacked-limit`,children:e.limitLabel})}),(0,z.jsx)(`div`,{className:`quota-stacked-bar-row`,children:(0,z.jsx)(`span`,{className:`quota-stacked-used`,children:e.valueLabel})})]});let i=Fr(e.percent),a=Ir(e.percent,t),o=Lr(e.percent,t),s=Gr(e.resetAt,n,r);return(0,z.jsxs)(`div`,{className:`quota-stacked-row${a?` quota-stacked-row--warn`:``}${i?` quota-stacked-row--exhausted`:``}`,children:[(0,z.jsxs)(`div`,{className:`quota-stacked-head`,children:[(0,z.jsx)(`span`,{className:`quota-stacked-limit`,children:e.limitLabel}),(0,z.jsx)(`span`,{className:`quota-stacked-reset muted`,children:s})]}),(0,z.jsxs)(`div`,{className:`quota-stacked-bar-row`,children:[(0,z.jsx)(`div`,{className:`bar quota-stacked-bar`,children:(0,z.jsx)(`div`,{className:`bar-fill ${o}`,style:zr(e.percent)})}),(0,z.jsx)(`span`,{className:`quota-stacked-used${a?` quota-stacked-used--warn`:``}`,children:n(`quota.usedPercent`,{pct:Math.round(e.percent)})})]}),i&&(0,z.jsxs)(`div`,{className:`quota-stacked-limit-reached`,role:`status`,children:[(0,z.jsx)(de,{width:12,height:12,"aria-hidden":`true`}),n(`quota.limitReached`)]})]})}function Wr(e,t,n){if(typeof e!=`number`||!Number.isFinite(e))return{day:``,time:``};let r=e<1e10?e*1e3:e,i=new Date(r),a=new Date,o=Pr(n),s=new Intl.DateTimeFormat(o,{hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(i);return i.getFullYear()===a.getFullYear()&&i.getMonth()===a.getMonth()&&i.getDate()===a.getDate()?{day:t(`codexAuth.today`),time:s}:{day:new Intl.DateTimeFormat(o,{day:`numeric`,month:`short`}).format(i),time:s}}function Gr(e,t,n=`en`,r=Date.now()){if(typeof e!=`number`||!Number.isFinite(e))return``;let i=e<1e10?e*1e3:e,a=new Date(i),o=Pr(n),s=new Intl.DateTimeFormat(o,{hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(a),c=new Date(r),l=new Date(c.getFullYear(),c.getMonth(),c.getDate()).getTime(),u=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),d=Math.round((u-l)/864e5);if(d===1)return t(`quota.resetsTomorrow`,{time:s});let f=a.getFullYear()!==c.getFullYear(),p=new Intl.DateTimeFormat(o,{day:`numeric`,month:`short`,...f?{year:`numeric`}:{}}).format(a);if(i<=r)return t(`quota.resetsAt`,{date:p,time:s,when:`${p}, ${s}`});let m=Math.round((i-r)/6e4);if(m<60)return t(`quota.resetsRelativeMinutes`,{n:Math.max(1,m)});let h=Math.round(m/60);return h<12&&d===0?t(`quota.resetsRelativeHours`,{n:Math.max(1,h)}):d===0?t(`quota.resetsToday`,{time:s}):t(`quota.resetsAt`,{date:p,time:s,when:`${p}, ${s}`})}function Kr({sections:e,quotaReports:t,usageTotals:n,usageLoading:r=!1,quotasLoading:i=!1,onSelectProvider:a,onEditConfig:o}){let s=K(),{locale:c}=Ve(),l=or(s),u=(0,_.useMemo)(()=>[...e.ready,...e.needsSetup,...e.disabled],[e]),d=(0,_.useMemo)(()=>new Set(u.map(e=>e.name)),[u]),f=(0,_.useMemo)(()=>sr(e,{}),[e]),p=f.length,m=(0,_.useMemo)(()=>e.ready.filter(e=>e.activeNeedsReauth).length,[e]),h=e.ready.length-m,g=e.needsSetup.length+m,v=(0,_.useMemo)(()=>{let e=[];for(let n of u){let r=t[n.name],i=r?Tr(r):null;r&&i&&e.push({item:n,report:r,urgency:Nr(i)})}return e.sort((e,t)=>t.urgency-e.urgency||e.item.name.localeCompare(t.item.name))},[u,t]),y=(0,_.useMemo)(()=>{let e={};for(let[t,r]of Object.entries(n))d.has(t)&&(e[t]=r);return rr(e).slice(0,4)},[n,d]),b=e=>{let t=cr(e);return t===`reauth`?s(`pws.attention.reauth`):t===`missing`?s(`pws.attention.missingCredentials`):e};return(0,z.jsxs)(`div`,{className:`pws-dashboard`,children:[(0,z.jsxs)(`div`,{className:`pws-dashboard-header`,children:[(0,z.jsxs)(`div`,{className:`pws-dashboard-header-text`,children:[(0,z.jsx)(`h2`,{className:`pws-dashboard-title`,children:s(`pws.dashboard.title`)}),(0,z.jsx)(`p`,{className:`muted pws-dashboard-subtitle`,children:s(`pws.dashboard.subtitle`)})]}),o&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:o,children:s(`prov.editJson`)})]}),(0,z.jsxs)(`div`,{className:`pws-dashboard-summary`,children:[(0,z.jsx)(qr,{count:h,label:s(`pws.status.ready`),tone:`ok`}),(0,z.jsx)(qr,{count:g,label:s(m>0?`pws.status.needsAttention`:`pws.status.needsSetup`),tone:`warn`}),(0,z.jsx)(qr,{count:e.disabled.length,label:s(`prov.disabledBadge`),tone:`muted`})]}),p>0&&(0,z.jsxs)(`section`,{className:`pws-dashboard-section pws-dashboard-attention`,"aria-label":s(`pws.attentionTitle`),children:[(0,z.jsxs)(`h3`,{className:`pws-dashboard-section-title`,children:[(0,z.jsx)(de,{style:{width:14,height:14},"aria-hidden":`true`}),s(`pws.attentionTitle`)]}),(0,z.jsx)(`div`,{className:`pws-dashboard-rows`,children:f.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`pws-dashboard-row pws-dashboard-row--attention`,onClick:()=>a(e.name),children:[(0,z.jsx)(Cr,{name:e.name,adapter:``,baseUrl:``,cls:`pws-dashboard-row-icon`}),(0,z.jsxs)(`div`,{className:`pws-dashboard-row-info`,children:[(0,z.jsx)(`span`,{className:`pws-dashboard-row-name`,children:vr(e.name,s)}),(0,z.jsx)(`span`,{className:`pws-dashboard-row-meta muted`,children:b(e.reason)})]}),(0,z.jsx)(_e,{className:`pws-dashboard-row-chevron`,"aria-hidden":`true`})]},`${e.name}:${e.reason}`))})]}),(0,z.jsxs)(`div`,{className:`pws-dashboard-columns`,children:[(0,z.jsxs)(`section`,{className:`pws-dashboard-section pws-dashboard-section--rate-limits`,"aria-label":s(`pws.dashboard.rateLimits`),"aria-busy":i||void 0,children:[(0,z.jsx)(`h3`,{className:`pws-dashboard-section-title`,children:s(`pws.dashboard.rateLimits`)}),v.length>0?(0,z.jsx)(`div`,{className:`pws-dashboard-rows`,children:v.map(({item:e,report:t})=>(0,z.jsxs)(`button`,{type:`button`,className:`pws-dashboard-row`,onClick:()=>a(e.name),children:[(0,z.jsx)(Cr,{name:e.name,adapter:e.adapter,baseUrl:e.baseUrl,cls:`pws-dashboard-row-icon`}),(0,z.jsxs)(`div`,{className:`pws-dashboard-row-info`,children:[(0,z.jsx)(`span`,{className:`pws-dashboard-row-name`,children:vr(e.name,s)}),(0,z.jsx)(`span`,{className:`pws-dashboard-row-meta muted`,children:s(`pws.dashboard.checkedAgo`,{time:ar(t.updatedAt,l)})})]}),(0,z.jsx)(_e,{className:`pws-dashboard-row-chevron`,"aria-hidden":`true`}),(0,z.jsx)(`div`,{className:`pws-dashboard-row-bars`,children:(0,z.jsx)(Br,{quota:Tr(t),threshold:80,t:s,layout:`stacked`,pending:i&&!t.quota})})]},e.name))}):i?(0,z.jsx)(`div`,{className:`pws-dashboard-rows pws-dashboard-rows--pending`,"aria-hidden":`true`,children:Array.from({length:3},(e,t)=>(0,z.jsxs)(`div`,{className:`pws-dashboard-row pws-dashboard-row--skeleton`,children:[(0,z.jsx)(`span`,{className:`pws-dashboard-row-icon pws-skel`}),(0,z.jsxs)(`div`,{className:`pws-dashboard-row-info`,children:[(0,z.jsx)(`span`,{className:`pws-skel pws-skel--name`}),(0,z.jsx)(`span`,{className:`pws-skel pws-skel--meta`})]}),(0,z.jsx)(`div`,{className:`pws-dashboard-row-bars`,children:(0,z.jsx)(Br,{quota:null,threshold:80,t:s,layout:`stacked`,pending:!0})})]},t))}):(0,z.jsx)(`p`,{className:`muted pws-dashboard-empty`,children:s(`pws.dashboard.noRateLimits`)})]}),(0,z.jsxs)(`section`,{className:`pws-dashboard-section pws-dashboard-section--recent`,"aria-label":s(`pws.dashboard.recentlyUsed`),"aria-busy":r||void 0,children:[(0,z.jsx)(`h3`,{className:`pws-dashboard-section-title`,children:s(`pws.dashboard.recentlyUsed`)}),y.length>0?(0,z.jsx)(`div`,{className:`pws-dashboard-rows`,children:y.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`pws-dashboard-row`,onClick:()=>a(e.name),children:[(0,z.jsx)(Cr,{name:e.name,adapter:``,baseUrl:``,cls:`pws-dashboard-row-icon`}),(0,z.jsx)(`span`,{className:`pws-dashboard-row-name`,children:vr(e.name,s)}),(0,z.jsx)(`span`,{className:`pws-dashboard-row-count muted`,children:s(`pws.dashboard.requests`,{count:lr(e.requests,c)})}),(0,z.jsx)(_e,{className:`pws-dashboard-row-chevron`,"aria-hidden":`true`})]},e.name))}):r?(0,z.jsx)(`div`,{className:`pws-dashboard-rows pws-dashboard-rows--pending`,"aria-hidden":`true`,children:Array.from({length:3},(e,t)=>(0,z.jsxs)(`div`,{className:`pws-dashboard-row pws-dashboard-row--skeleton`,children:[(0,z.jsx)(`span`,{className:`pws-dashboard-row-icon pws-skel`}),(0,z.jsx)(`span`,{className:`pws-skel pws-skel--name`}),(0,z.jsx)(`span`,{className:`pws-skel pws-skel--count`})]},t))}):(0,z.jsx)(`p`,{className:`muted pws-dashboard-empty`,children:s(`pws.dashboard.noUsage`)})]})]})]})}function qr({count:e,label:t,tone:n}){return(0,z.jsxs)(`div`,{className:`pws-dashboard-card pws-dashboard-card--${n}`,children:[(0,z.jsx)(`span`,{className:`pws-dashboard-card-count`,children:e}),(0,z.jsx)(`span`,{className:`pws-dashboard-card-label`,children:t})]})}function Jr({editor:e,providerName:t,saving:n,onSave:r,message:i}){let a=K(),o=(0,_.useRef)(null);return(0,_.useEffect)(()=>{e.open&&o.current?.focus()},[e.open]),e.open?(0,z.jsxs)(`div`,{className:`pwi-json-panel`,children:[(0,z.jsxs)(`div`,{className:`pwi-json-panel-header`,children:[(0,z.jsx)(`span`,{className:`pwi-json-panel-title`,children:a(`pws.jsonEditorTitle`,{name:t})}),(0,z.jsxs)(`div`,{className:`pwi-json-panel-actions`,children:[e.onRestore&&e.isDirty&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:e.onRestore,children:a(`pws.jsonRestore`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:e.onClose,children:a(`common.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:r,disabled:n||!e.isDirty,children:a(n?`pws.saving`:`pws.jsonSave`)})]})]}),(0,z.jsx)(`p`,{className:`pwi-json-panel-desc muted`,children:a(`pws.jsonEditorDesc`)}),(0,z.jsx)(`textarea`,{ref:o,className:`input pwi-json-textarea`,value:e.draft,onChange:t=>e.onDraftChange(t.target.value),spellCheck:!1,rows:20,"aria-label":a(`pws.jsonEditorDesc`)}),i&&(0,z.jsx)(`div`,{className:i.ok?`pwi-settings-msg pwi-settings-msg--ok`:`pwi-settings-msg pwi-settings-msg--err`,children:i.text})]}):null}var Yr=[{id:`az`,labelKey:`pws.sort.az`},{id:`za`,labelKey:`pws.sort.za`},{id:`free-paid`,labelKey:`pws.sort.freePaid`},{id:`paid-free`,labelKey:`pws.sort.paidFree`},{id:`accounts-first`,labelKey:`pws.sort.accountsFirst`}];function Xr({providers:e,apiBase:t,defaultProvider:n,selectedName:r,onSelect:i,onRemoveProvider:a,onAddProvider:o,onEditConfig:s,jsonEditor:c,jsonSaving:l=!1,modelsRefreshToken:u=0,activeAccountNeedsReauth:d,quotaRefreshEpoch:f=0,quotaForceRefresh:p=!1,detail:m}){let h=K(),[g,v]=(0,_.useState)(``),[y,b]=(0,_.useState)({ready:!0,needsSetup:!0,disabled:!0}),[x,S]=(0,_.useState)({free:!0,paid:!0}),[C,w]=(0,_.useState)({cloud:!0,local:!0,selfHosted:!0,login:!0}),[T,E]=(0,_.useState)(`az`),[D,O]=(0,_.useState)(!1),[k,A]=(0,_.useState)(null),[j,M]=(0,_.useState)({}),[N,P]=(0,_.useState)({}),[F,I]=(0,_.useState)({}),[L,R]=(0,_.useState)({}),[B,V]=(0,_.useState)(!1),[H,U]=(0,_.useState)(!1),W=`ocx.providers.quotas.v1:${t}`,ee=`ocx.providers.usage.v1:${t}`,[te,ne]=(0,_.useState)(()=>Y(ee)?.totals??{}),[re,G]=(0,_.useState)(()=>Y(ee)?.models??{}),[ie,ae]=(0,_.useState)(()=>Y(W)??{}),[oe,se]=(0,_.useState)(()=>!Y(ee)),[ce,le]=(0,_.useState)(()=>!Y(W)),[de,fe]=(0,_.useState)(0),me=(0,_.useRef)(null),he=(0,_.useMemo)(()=>qn(Kn(Yn(e)),d??{}),[e,d]),ge=(0,_.useCallback)(()=>{fe(e=>e+1)},[]);(0,_.useEffect)(()=>{let e=!1,n=window.setTimeout(()=>{V(!0),(async()=>{try{let n=await J(await fetch(`${t}/api/selected-models`));if(e)return;M(nr(n)),P($n(n)),I(er(n)),R(tr(n)),U(!1)}catch{if(e)return;U(!0)}finally{e||V(!1)}})()},0);return()=>{e=!0,window.clearTimeout(n)}},[t,u,de]),(0,_.useEffect)(()=>{let e=!1,n=window.setTimeout(()=>{Y(ee)||se(!0),fetch(`${t}/api/usage?range=30d`).then(e=>ut(e)).then(t=>{if(e||!t)return;let n={};for(let e of t.providers??[])n[e.provider]={requests:e.requests,totalTokens:e.totalTokens};ne(n);let r={};for(let e of t.models??[]){let t=e.provider;r[t]||(r[t]=[]),r[t].push({model:e.model,...e.resolvedModel?{resolvedModel:e.resolvedModel}:{},requests:e.requests,totalTokens:e.totalTokens,inputTokens:e.inputTokens,outputTokens:e.outputTokens,shareRatio:e.shareRatio,...e.estimatedCostUsd===void 0?{}:{estimatedCostUsd:e.estimatedCostUsd}})}G(r),X(ee,{totals:n,models:r})}).catch(()=>{}).finally(()=>{e||se(!1)})},0);return()=>{e=!0,window.clearTimeout(n)}},[t,ee]),(0,_.useEffect)(()=>{let e=!1,n=window.setTimeout(()=>{Y(W)||le(!0),fetch(`${t}/api/provider-quotas${p?`?refresh=1`:``}`).then(e=>ut(e)).then(t=>{e||!t||ae(e=>{let n={...e};for(let e of t.reports??[])e?.provider&&(n[e.provider]={label:e.label,source:e.source,updatedAt:typeof e.updatedAt==`number`?e.updatedAt:Date.now(),quota:e.quota});return X(W,n),n})}).catch(()=>{}).finally(()=>{e||le(!1)})},0);return()=>{e=!0,window.clearTimeout(n)}},[t,f,p,W]),(0,_.useEffect)(()=>{if(!D)return;let e=e=>{me.current&&!me.current.contains(e.target)&&O(!1)},t=e=>{e.key===`Escape`&&O(!1)};return document.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[D]);let _e=(0,_.useMemo)(()=>[...he.ready,...he.needsSetup,...he.disabled],[he]),ve=(0,_.useMemo)(()=>_e.filter(Un).length,[_e]),ye=_e.length-ve,be=(0,_.useMemo)(()=>{let e={cloud:0,local:0,selfHosted:0,login:0};for(let t of _e)e[Qn(t)]+=1;return e},[_e]),xe=(0,_.useMemo)(()=>{let e=g.trim().toLowerCase(),t=t=>Gn(t.filter(t=>{if(e&&!t.name.toLowerCase().includes(e)&&!t.adapter.toLowerCase().includes(e))return!1;let n=Un(t);return!(n&&!x.free||!n&&!x.paid||!C[Qn(t)])}),T);return{ready:y.ready?t(he.ready):[],needsSetup:y.needsSetup?t(he.needsSetup):[],disabled:y.disabled?t(he.disabled):[]}},[he,g,y,x,C,T]),Se=!y.ready||!y.needsSetup||!y.disabled||!x.free||!x.paid||!C.cloud||!C.local||!C.selfHosted||!C.login||T!==`az`,Ce=()=>{b({ready:!0,needsSetup:!0,disabled:!0}),S({free:!0,paid:!0}),w({cloud:!0,local:!0,selfHosted:!0,login:!0}),E(`az`)},we=(0,_.useMemo)(()=>r?_e.find(e=>e.name===r)??null:null,[r,_e]),Te=(0,_.useMemo)(()=>{let e=new Map;for(let t of _e){let n=vr(t.name,h);e.set(n,(e.get(n)??0)+1)}let t=new Set;for(let[n,r]of e.entries())r>1&&t.add(n);return t},[_e,h]);if(_e.length===0)return(0,z.jsx)(Zr,{onAddProvider:o});let Ee=[{key:`ready`,label:h(`pws.status.ready`),count:he.ready.length},{key:`needsSetup`,label:h(`pws.status.needsSetup`),count:he.needsSetup.length},{key:`disabled`,label:h(`prov.disabledBadge`),count:he.disabled.length}],De=[{id:`ready`,label:h(`pws.status.ready`),count:xe.ready.length,ariaLabel:h(`pws.groupReady`,{count:xe.ready.length}),items:xe.ready},{id:`needs-setup`,label:h(`pws.status.needsSetup`),count:xe.needsSetup.length,ariaLabel:h(`pws.groupNeedsSetup`,{count:xe.needsSetup.length}),items:xe.needsSetup},{id:`disabled`,label:h(`prov.disabledBadge`),count:xe.disabled.length,ariaLabel:h(`pws.groupDisabled`,{count:xe.disabled.length}),items:xe.disabled}],Oe=De.flatMap(e=>e.items.map(e=>e.name)),ke=k&&Oe.includes(k)?k:r&&Oe.includes(r)?r:Oe[0]??null;return(0,z.jsx)(`div`,{className:`pws-shell-container`,children:(0,z.jsxs)(`div`,{className:`pws-root`,children:[(0,z.jsxs)(`aside`,{className:`pws-rail`,"aria-label":h(`pws.providerList`),children:[(0,z.jsxs)(`div`,{className:`pws-search-row`,children:[(0,z.jsxs)(`div`,{className:`pws-search-wrap`,children:[(0,z.jsx)(pe,{className:`pws-search-icon`,width:14,height:14,"aria-hidden":`true`}),(0,z.jsx)(`input`,{type:`search`,className:`input pws-search-input`,placeholder:h(`pws.searchPlaceholder`),value:g,onChange:e=>v(e.target.value),"aria-label":h(`pws.searchPlaceholder`)})]}),(0,z.jsxs)(`div`,{className:`pws-filter-wrap`,ref:me,children:[(0,z.jsxs)(`button`,{type:`button`,className:`pws-filter-btn${Se||D?` pws-filter-btn--active`:``}`,onClick:()=>O(e=>!e),"aria-label":h(`pws.filterAria`),"aria-expanded":D,"aria-controls":`pws-provider-filters`,children:[(0,z.jsx)(Ne,{width:18,height:18,"aria-hidden":`true`}),Se&&(0,z.jsx)(`span`,{className:`pws-filter-dot`,"aria-hidden":`true`})]}),D&&(0,z.jsxs)(`div`,{id:`pws-provider-filters`,className:`pws-filter-menu`,role:`group`,"aria-label":h(`pws.providerFiltersAria`),children:[(0,z.jsx)(`div`,{className:`pws-filter-title`,children:h(`pws.filters`)}),(0,z.jsx)(`div`,{className:`pws-filter-head`,children:h(`pws.filterStatus`)}),Ee.map(({key:e,label:t,count:n})=>(0,z.jsxs)(`label`,{className:`pws-filter-option`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:y[e],onChange:()=>b(t=>({...t,[e]:!t[e]}))}),(0,z.jsx)(`span`,{className:`pws-filter-label`,children:t}),(0,z.jsx)(`span`,{className:`pws-filter-count`,children:n})]},e)),(0,z.jsx)(`div`,{className:`pws-filter-head`,children:h(`pws.pricing`)}),(0,z.jsxs)(`label`,{className:`pws-filter-option`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:x.free,onChange:()=>S(e=>({...e,free:!e.free}))}),(0,z.jsx)(`span`,{className:`pws-filter-label`,children:h(`modal.badge.free`)}),(0,z.jsx)(`span`,{className:`pws-filter-count`,children:ve})]}),(0,z.jsxs)(`label`,{className:`pws-filter-option`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:x.paid,onChange:()=>S(e=>({...e,paid:!e.paid}))}),(0,z.jsx)(`span`,{className:`pws-filter-label`,children:h(`pws.paid`)}),(0,z.jsx)(`span`,{className:`pws-filter-count`,children:ye})]}),(0,z.jsx)(`div`,{className:`pws-filter-head`,children:h(`pws.filterType`)}),[{key:`cloud`,label:h(`pws.type.cloud`),count:be.cloud},{key:`local`,label:h(`pws.type.local`),count:be.local},{key:`selfHosted`,label:h(`pws.type.selfHosted`),count:be.selfHosted},{key:`login`,label:h(`pws.type.login`),count:be.login}].map(({key:e,label:t,count:n})=>(0,z.jsxs)(`label`,{className:`pws-filter-option`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:C[e],onChange:()=>w(t=>({...t,[e]:!t[e]}))}),(0,z.jsx)(`span`,{className:`pws-filter-label`,children:t}),(0,z.jsx)(`span`,{className:`pws-filter-count`,children:n})]},e)),(0,z.jsx)(`div`,{className:`pws-filter-head`,children:h(`pws.sort`)}),(0,z.jsx)(`div`,{className:`pws-sort-grid`,role:`group`,"aria-label":h(`pws.sortProvidersAria`),children:Yr.map(e=>(0,z.jsx)(`button`,{type:`button`,className:`pws-sort-btn${T===e.id?` pws-sort-btn--active`:``}`,onClick:()=>E(e.id),"aria-pressed":T===e.id,children:h(e.labelKey)},e.id))}),(0,z.jsx)(`div`,{className:`pws-filter-footer`,children:(0,z.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:Ce,disabled:!Se,children:h(`pws.resetAll`)})})]})]})]}),(0,z.jsxs)(`div`,{className:`pws-rail-list`,role:`listbox`,"aria-label":h(`pws.providersAria`),onKeyDown:e=>{let t=Array.from(e.currentTarget.querySelectorAll(`[role="option"]`));if(t.length===0)return;let n=document.activeElement,r=t.findIndex(e=>e===n||e.contains(n));if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=e.key===`ArrowDown`?1:-1;t[r<0?n>0?0:t.length-1:(r+n+t.length)%t.length]?.focus();return}if(e.key===`Home`){e.preventDefault(),t[0]?.focus();return}e.key===`End`&&(e.preventDefault(),t[t.length-1]?.focus())},children:[Object.values(xe).every(e=>e.length===0)&&(0,z.jsx)(`span`,{className:`muted pws-rail-empty`,role:`status`,children:h(g?`pws.noSearchResults`:Se?`pws.noMatchFilters`:`pws.noProvidersConfigured`)}),De.map(({id:e,label:t,count:o,ariaLabel:s,items:c})=>c.length===0?null:(0,z.jsxs)(`div`,{className:`pws-rail-group`,role:`group`,"aria-label":s,children:[(0,z.jsxs)(`div`,{className:`pws-rail-group-head`,"aria-hidden":`true`,children:[(0,z.jsx)(`span`,{className:`pws-rail-group-label`,children:t}),(0,z.jsx)(`span`,{className:`pws-rail-group-count`,children:o})]}),c.map(e=>(0,z.jsxs)(`div`,{className:`pws-rail-row-wrap`,children:[(0,z.jsx)(wr,{item:e,selected:r===e.name,tabbable:ke===e.name,modelCount:j[e.name],isDefault:n===e.name,showConfigId:Te.has(vr(e.name,h)),onClick:()=>i(e.name),onFocus:()=>A(e.name)}),a&&(0,z.jsx)(`button`,{type:`button`,className:`pws-rail-row-remove`,tabIndex:-1,"aria-hidden":`true`,onClick:t=>{t.stopPropagation(),a(e.name)},title:h(`pws.removeConfirmTitle`),children:(0,z.jsx)(ue,{width:14,height:14})})]},e.name))]},e))]})]}),(0,z.jsx)(`main`,{className:`pws-main`,"aria-label":h(`pws.workspaceMainAria`),children:c?.open?(0,z.jsx)(Jr,{editor:c,providerName:h(`nav.providers`),saving:l,onSave:()=>{c.onSave()}}):we?m?.(we,{usageTotals:te[we.name],modelUsage:re[we.name],quotaReport:ie[we.name],availableModels:N[we.name]??[],hasLiveModels:(F[we.name]??0)>0,selectedModels:L[we.name]??[],modelsLoading:B,modelsLoadFailed:H,onRetryModels:ge})??(0,z.jsxs)(`div`,{className:`pws-detail-placeholder`,children:[(0,z.jsx)(`h3`,{children:vr(we.name,h)}),(0,z.jsx)(`p`,{className:`muted`,children:h(`pws.detailComingSoon`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>i(null),children:h(`modal.back`)})]}):(0,z.jsx)(Kr,{sections:he,quotaReports:ie,usageTotals:te,usageLoading:oe,quotasLoading:ce,onSelectProvider:e=>i(e),onEditConfig:s})})]})})}function Zr({onAddProvider:e}){let t=K();return(0,z.jsx)(`div`,{className:`pws-empty-root`,children:(0,z.jsxs)(`div`,{className:`pws-empty-hero`,children:[(0,z.jsx)(`div`,{"aria-hidden":`true`,children:(0,z.jsx)(U,{style:{width:64,height:64}})}),(0,z.jsx)(`h2`,{children:t(`pws.connectFirst`)}),(0,z.jsxs)(`div`,{className:`pws-empty-tiles`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`pws-empty-tile`,onClick:()=>e({tier:`free`}),children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,children:(0,z.jsx)(Oe,{width:18,height:18})}),(0,z.jsx)(`span`,{className:`pws-empty-tile-label`,children:t(`pws.empty.browseFree`)}),(0,z.jsx)(`span`,{className:`pws-empty-tile-desc muted`,children:t(`pws.empty.browseFreeDesc`)})]}),(0,z.jsxs)(`button`,{type:`button`,className:`pws-empty-tile`,onClick:()=>e({tier:`accounts`}),children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,children:(0,z.jsx)(Se,{width:18,height:18})}),(0,z.jsx)(`span`,{className:`pws-empty-tile-label`,children:t(`pws.empty.connectAccount`)}),(0,z.jsx)(`span`,{className:`pws-empty-tile-desc muted`,children:t(`pws.empty.connectAccountDesc`)})]}),(0,z.jsxs)(`button`,{type:`button`,className:`pws-empty-tile`,onClick:()=>e({custom:!0}),children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,children:(0,z.jsx)(xe,{width:18,height:18})}),(0,z.jsx)(`span`,{className:`pws-empty-tile-label`,children:t(`pws.empty.addEndpoint`)}),(0,z.jsx)(`span`,{className:`pws-empty-tile-desc muted`,children:t(`pws.empty.addEndpointDesc`)})]})]})]})})}function Qr(e){if(Hn(e.name,e))return`codex-accounts`;let t=(e.authMode??``).toLowerCase();if(t===`forward`||t===`local`||Xn(e))return null;if(t===`oauth`)return`oauth-accounts`;let n=e.hasApiKey===!0;return!(t===`key`||n||t===``)||e.keyOptional===!0&&!n?null:`api-keys`}function $r(e,t,n){let r=t.alias?.trim();if(r)return r;let i=t.email?.trim();if(i)return i;let a=e.findIndex(e=>e.id===t.id);return n(`pws.accountOrdinal`,{count:String(a>=0?a+1:1)})}function ei({item:e,usageTotals:t,quotaReport:n,oauthEmail:r,apiBase:i,connectionIdentity:a,onEditSettings:o,onViewUsage:s,onUpdateProvider:c,onReauthenticate:l,onCancelLogin:u,reauthBusy:d=!1,accountPanel:f}){let p=K(),{locale:m}=Ve(),h=or(p),g=Jn(e),v=!!e.activeNeedsReauth,y=p(g===`ready`?`pws.status.connected`:g===`needs-setup`?v?`pws.status.needsAttention`:`pws.status.needsSetup`:`prov.disabledBadge`),b=t?.requests,x=t?.totalTokens,S=Tr(n),C=JSON.stringify([i??null,e.name,e.adapter,e.baseUrl,e.authMode??null,e.apiKeyTransport??null,e.liveModels??null,e.disabled===!0,e.hasApiKey===!0,e.hasHeaders===!0,e.allowPrivateNetwork===!0,e.keyOptional===!0,e.activeNeedsReauth===!0,a??null]),[w,T]=(0,_.useState)(null),E=(0,_.useRef)(null),D=w?.key===C&&w.testing,O=w?.key===C?w.result:null;(0,_.useEffect)(()=>()=>{E.current?.key===C&&(E.current.controller.abort(),E.current=null)},[C]);let k=(0,_.useCallback)(async()=>{if(!i)return;E.current?.controller.abort();let t=new AbortController;E.current={key:C,controller:t},T({key:C,testing:!0,result:null});try{let n=await J(await fetch(`${i}/api/providers/test?name=${encodeURIComponent(e.name)}`,{method:`POST`,signal:t.signal}),p(`pws.connectionFailed`));if(!n)throw Error(p(`pws.connectionFailed`));t.signal.aborted||T({key:C,testing:!1,result:n})}catch(e){t.signal.aborted||T({key:C,testing:!1,result:{applicable:!0,ok:!1,error:e instanceof Error?e.message:p(`pws.connectionFailed`)}})}finally{E.current?.controller===t&&(E.current=null)}},[i,C,e.name,p]),A=O?.applicable===!1?`not-applicable`:O?.ok===!0?`ok`:`failed`,j=O?.applicable===!1?p(`pws.connectionNotApplicable`):O?.ok===!0?O.message||p(`pws.connectionOk`):O?.error||p(`pws.connectionFailed`);return(0,z.jsxs)(`div`,{className:`pws-overview-layout`,children:[(0,z.jsxs)(`div`,{className:`pws-overview-main`,children:[(0,z.jsxs)(`section`,{className:`pws-section`,"aria-label":p(`pws.connection`),children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:p(`pws.connection`)}),(0,z.jsxs)(`dl`,{className:`pws-kv`,children:[(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:p(`dash.status`)}),(0,z.jsxs)(`dd`,{className:g===`ready`?`pws-status-ok`:`pws-status-warn`,children:[g===`ready`?(0,z.jsx)(ie,{style:{width:13,height:13},"aria-hidden":`true`}):(0,z.jsx)(de,{style:{width:13,height:13},"aria-hidden":`true`}),y]})]}),(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:p(`modal.baseUrl`)}),(0,z.jsx)(`dd`,{children:(0,z.jsx)(`code`,{children:e.baseUrl?.trim()?e.baseUrl:`—`})})]}),(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:p(`pws.cell.auth`)}),(0,z.jsx)(`dd`,{children:r?`${xr(e,p)} · ${r}`:xr(e,p)})]}),(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:p(`modal.defaultModel`)}),(0,z.jsx)(`dd`,{children:e.defaultModel??(0,z.jsx)(`span`,{className:`muted`,children:`—`})})]}),e.note&&(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:p(`pws.cell.note`)}),(0,z.jsx)(`dd`,{className:`muted`,children:e.note})]})]}),i&&(0,z.jsxs)(`div`,{className:`row`,style:{marginTop:12,alignItems:`center`},children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:D,onClick:()=>void k(),children:p(D?`pws.testing`:`pws.testConnection`)}),O&&(0,z.jsx)(`span`,{role:`status`,className:A===`ok`?`pws-status-ok`:A===`failed`?`pws-status-warn`:`muted`,"data-connection-test-state":A,children:j})]}),o&&(0,z.jsx)(`button`,{type:`button`,className:`link-btn pws-edit-settings-link`,onClick:o,children:p(`pws.editSettings`)})]}),f?(0,z.jsx)(`section`,{className:`pws-section`,"aria-label":p(`pws.availableAccounts`),children:f}):(0,z.jsxs)(`section`,{className:`pws-section`,"aria-label":p(`pws.authSummary`),children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:p(`pws.authSummary`)}),v?(0,z.jsxs)(`div`,{className:`pws-auth-summary pws-auth-summary--warn`,role:`status`,children:[(0,z.jsx)(de,{style:{width:14,height:14},"aria-hidden":`true`}),(0,z.jsxs)(`div`,{className:`pws-auth-summary-body`,children:[(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`strong`,{children:p(`pws.status.needsAttention`)}),` — `,e.authMode===`forward`?p(`pws.attention.reauthForward`):p(`pws.attention.reauth`)]}),l&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:d,onClick:()=>l(),children:p(d?`prov.waitingBrowser`:`pws.reauthenticate`)}),d&&u&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>u(),children:p(`common.cancel`)})]})]}):(0,z.jsxs)(`div`,{className:`pws-auth-summary`,children:[(0,z.jsx)(`span`,{className:`pws-auth-dot`}),(0,z.jsx)(`span`,{children:e.authMode===`forward`?p(`pws.passthrough`):e.authMode===`oauth`?r?p(`pws.loggedInAs`,{email:r}):p(`pws.notLoggedIn`):e.hasApiKey?p(`pws.apiKeyConfigured`):xr(e,p)})]})]})]}),(0,z.jsxs)(`aside`,{className:`pws-overview-sidebar`,children:[(0,z.jsxs)(`section`,{className:`pws-section`,"aria-label":p(`pws.statsAria`),children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:p(`pws.statsTitle`)}),(0,z.jsxs)(`dl`,{className:`pws-kv`,children:[typeof b==`number`&&(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:p(`pws.stats.totalRequests`)}),(0,z.jsx)(`dd`,{className:`pws-kv-mono`,children:lr(b,m)})]}),typeof x==`number`&&(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:p(`pws.stats.totalTokens`)}),(0,z.jsx)(`dd`,{className:`pws-kv-mono`,children:ur(x,m)})]}),n&&(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:p(`pws.stats.quotaUpdated`)}),(0,z.jsx)(`dd`,{className:`pws-kv-mono`,title:n.source?Er(n.source):void 0,children:ar(n.updatedAt,h)})]}),typeof b!=`number`&&typeof x!=`number`&&!n&&(0,z.jsx)(`div`,{className:`muted`,children:p(`pws.usageUnavailable`)})]}),s&&(0,z.jsxs)(`button`,{type:`button`,className:`link-btn pws-view-usage-link`,onClick:s,children:[p(`pws.viewUsage`),` →`]}),S&&(0,z.jsx)(`div`,{className:`muted pws-stats-note`,children:p(`pws.stats.quotaTracked`)})]}),(0,z.jsx)(ti,{item:e,onUpdateProvider:c})]})]})}function ti({item:e,onUpdateProvider:t}){let n=K(),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(``),d=(0,_.useRef)(null);(0,_.useEffect)(()=>{r&&d.current?.focus()},[r]);let f=(0,_.useCallback)(async()=>{if(s||!t)return;let r=a.trim();if(r===(e.note??``)){i(!1),u(``);return}c(!0);try{let a=await t(e.name,{note:r||void 0});if(!a.ok){u(a.error||n(`prov.saveFailed`));return}u(``),i(!1)}finally{c(!1)}},[a,e.name,e.note,t,s,n]);return r?(0,z.jsxs)(`section`,{className:`pws-section pws-notes-section`,"aria-label":n(`pws.notes`),children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:n(`pws.notes`)}),(0,z.jsx)(`textarea`,{ref:d,className:`pws-notes-textarea`,value:a,onChange:e=>o(e.target.value),onBlur:()=>void f(),onKeyDown:t=>{t.key===`Escape`&&(o(e.note??``),u(``),i(!1))},placeholder:n(`pws.notePlaceholder`),rows:3,disabled:s}),l?(0,z.jsx)(`p`,{className:`pws-inline-error`,role:`alert`,children:l}):null]}):(0,z.jsxs)(`section`,{className:`pws-section pws-notes-section`,"aria-label":n(`pws.notes`),children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:n(`pws.notes`)}),(0,z.jsx)(`button`,{type:`button`,className:`pws-notes-display`,onClick:()=>{t&&(o(e.note??``),u(``),i(!0))},disabled:!t,children:e.note||(0,z.jsx)(`span`,{className:`muted`,children:n(`pws.notePlaceholder`)})})]})}function ni({item:e,apiBase:t,availableModels:n,hasLiveModels:r,selectedModels:i,modelsLoading:a=!1,modelsLoadFailed:o=!1,needsReauth:s=!1,onRetryModels:c,onOpenAccounts:l}){let u=K(),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(!1),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(``),[S,C]=(0,_.useState)([]),[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(0),[A,j]=(0,_.useState)(null),M=(0,_.useRef)(null),N=(0,_.useMemo)(()=>new Set(i),[i]),P=(0,_.useMemo)(()=>e.models??[],[e.models]),F=p.trim(),I=!w||!F||F.includes(`/`)||n.includes(F)||S.includes(F)||P.includes(F)||e.defaultModel===F,L=(0,_.useMemo)(()=>Dr(n,e.defaultModel,d,P,S,r),[n,e.defaultModel,d,P,S,r]);(0,_.useEffect)(()=>{let n=!0;return(async()=>{try{let r=await fetch(`${t}/api/custom-models`);if(!r.ok)throw Error();let i=await r.json();if(!Array.isArray(i))throw Error(`Invalid custom model list`);if(!n)return;C(i.flatMap(t=>{if(!t||typeof t!=`object`)return[];let n=t;return n.provider===e.name&&typeof n.modelId==`string`?[n.modelId]:[]})),D(!1),y(``),T(!0)}catch{if(!n)return;C([]),T(!1),D(!0),y(u(`models.networkError`))}})(),()=>{n=!1}},[t,e.name,u,O]);let R=()=>{T(!1),D(!1),y(``),k(e=>e+1)};(0,_.useEffect)(()=>()=>{M.current!=null&&window.clearTimeout(M.current)},[]);let B=async e=>{try{await navigator.clipboard.writeText(e),j(e),M.current!=null&&window.clearTimeout(M.current),M.current=window.setTimeout(()=>{j(t=>t===e?null:t),M.current=null},1200)}catch{}},V=async()=>{if(!(I||h)){g(!0),y(``),x(``);try{(await fetch(`${t}/api/custom-models`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.name,modelId:F})})).ok?(C(e=>e.includes(F)?e:[...e,F]),m(``),x(u(`models.customAdded`)),c?.()):y(u(`models.customSaveFailed`))}catch{y(u(`models.networkError`))}finally{g(!1)}}},H=n.length===0&&P.length===0&&S.length===0&&!e.defaultModel,U=n.length===0&&P.length>0,W=L.length>300,ee=W?L.slice(0,300):L;return(0,z.jsxs)(`div`,{className:`pws-section`,children:[(0,z.jsxs)(`div`,{className:`pws-section-head`,children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:u(`pws.tab.models`)}),L.length>0&&(0,z.jsx)(`span`,{className:`muted`,children:u(`pws.modelsAvailable`,{count:L.length})})]}),s&&(0,z.jsxs)(`div`,{className:`pws-inline-error`,role:`status`,children:[(0,z.jsx)(`span`,{children:u(`pws.modelsNeedsReauth`)}),l&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:l,children:u(`pws.tab.accounts`)})]}),U&&!s&&(0,z.jsx)(`p`,{className:`muted text-label`,style:{marginBottom:10},children:u(`pws.modelsConfiguredFallback`)}),(0,z.jsx)(`label`,{className:`text-label pws-custom-model-label`,htmlFor:`pws-custom-model-${e.name}`,children:u(`models.customAdd`)}),(0,z.jsxs)(`div`,{className:`row pws-custom-model-row`,children:[(0,z.jsx)(`input`,{id:`pws-custom-model-${e.name}`,className:`input`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&V()},placeholder:u(`models.customFieldModelIdPlaceholder`),"aria-label":u(`models.customAdd`),disabled:h}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>{V()},disabled:h||I,children:u(h?`models.customSaving`:`models.customAddBtn`)})]}),b&&(0,z.jsx)(`p`,{className:`muted text-label`,role:`status`,children:b}),v&&(0,z.jsxs)(`p`,{className:`pws-inline-error`,role:`alert`,children:[v,E&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:R,style:{marginLeft:8},children:u(`common.retry`)})]}),!H&&(0,z.jsx)(`input`,{type:`search`,className:`input pws-model-search`,placeholder:u(`pws.modelSearchPlaceholder`),value:d,onChange:e=>f(e.target.value),"aria-label":u(`pws.modelSearchPlaceholder`)}),a&&H?(0,z.jsx)(`p`,{className:`muted`,role:`status`,children:u(`pws.modelsLoading`)}):o&&H?(0,z.jsxs)(`div`,{role:`alert`,className:`pws-inline-error`,children:[(0,z.jsx)(`span`,{children:u(`pws.modelsLoadFailed`)}),c&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:c,children:u(`pws.retry`)})]}):H?(0,z.jsx)(`p`,{className:`muted`,children:u(`pws.noModels`)}):L.length===0?(0,z.jsx)(`p`,{className:`muted`,role:`status`,children:u(`pws.noModelMatch`)}):(0,z.jsx)(`ul`,{className:`pws-model-list`,children:ee.map(t=>{let n=t===e.defaultModel,r=N.has(t);return(0,z.jsxs)(`li`,{className:`pws-model-chip`,children:[(0,z.jsx)(`button`,{type:`button`,className:`pws-model-chip-main`,onClick:()=>{B(t)},title:t,"aria-label":u(A===t?`pws.modelCopied`:`pws.copyModelId`),children:(0,z.jsx)(`span`,{className:`pws-model-id`,children:t})}),n?(0,z.jsx)(`span`,{className:`badge badge-muted pws-model-flag`,children:u(`prov.defaultBadge`)}):null,r?(0,z.jsx)(`span`,{className:`badge badge-accent pws-model-flag`,children:u(`pws.selected`)}):null]},t)})}),W&&(0,z.jsx)(`p`,{className:`muted text-label`,style:{marginTop:10},children:u(`pws.modelsTruncated`,{shown:`300`,total:String(L.length)})})]})}function ri({item:e,usageTotals:t,quotaReport:n,modelUsage:r}){let i=K(),{locale:a}=Ve(),o=or(i),s=t?.requests!==void 0,c=Tr(n),[l,u]=(0,_.useState)(null),d=(0,_.useMemo)(()=>r?.length?r.toSorted((e,t)=>t.totalTokens-e.totalTokens):[],[r]),f=(0,_.useMemo)(()=>{if(!d.length)return;let e=0,t=!1;for(let n of d)n.estimatedCostUsd!==void 0&&(e+=n.estimatedCostUsd,t=!0);return t?e:void 0},[d]);return(0,z.jsxs)(`div`,{className:`pws-section`,children:[(0,z.jsxs)(`div`,{className:`pws-usage-block`,children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:i(`pws.usageLast30d`)}),s?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`pws-usage-metrics pws-usage-metrics-3`,role:`group`,"aria-label":i(`pws.usageLast30d`),children:[(0,z.jsxs)(`div`,{className:`pws-usage-metric`,children:[(0,z.jsx)(`span`,{className:`pws-usage-metric-value mono`,children:dr(f,a)}),(0,z.jsx)(`span`,{className:`muted pws-usage-metric-label`,children:i(`pws.estimatedCost`)})]}),(0,z.jsxs)(`div`,{className:`pws-usage-metric`,children:[(0,z.jsx)(`span`,{className:`pws-usage-metric-value`,children:lr(t?.requests,a)}),(0,z.jsx)(`span`,{className:`muted pws-usage-metric-label`,children:i(`pws.metricRequests`)})]}),(0,z.jsxs)(`div`,{className:`pws-usage-metric`,children:[(0,z.jsx)(`span`,{className:`pws-usage-metric-value`,children:ur(t?.totalTokens,a)}),(0,z.jsx)(`span`,{className:`muted pws-usage-metric-label`,children:i(`pws.metricTokens`)})]})]}),(0,z.jsx)(`p`,{className:`muted pws-cost-disclaimer`,children:i(`pws.costDisclaimer`)})]}):(0,z.jsx)(`p`,{className:`muted`,children:i(`pws.usageUnavailable`)})]}),d.length>0&&(0,z.jsxs)(`div`,{className:`pws-usage-block`,children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:i(`pws.modelBreakdown`)}),(0,z.jsx)(`div`,{className:`tbl-wrap`,children:(0,z.jsxs)(`table`,{className:`pws-model-table`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:i(`pws.col.model`)}),(0,z.jsx)(`th`,{className:`num`,children:i(`pws.col.cost`)}),(0,z.jsx)(`th`,{className:`num`,children:i(`pws.col.tokens`)}),(0,z.jsx)(`th`,{className:`num`,children:i(`pws.col.requests`)}),(0,z.jsx)(`th`,{children:i(`pws.col.share`)})]})}),(0,z.jsx)(`tbody`,{children:d.map(e=>{let t=e.model,n=l===t;return(0,z.jsxs)(_.Fragment,{children:[(0,z.jsxs)(`tr`,{className:`pws-model-row`,children:[(0,z.jsx)(`td`,{className:`mono`,children:(0,z.jsx)(`button`,{type:`button`,className:`pws-model-expand`,"aria-expanded":n,onClick:()=>u(n?null:t),children:e.model})}),(0,z.jsx)(`td`,{className:`num mono`,children:dr(e.estimatedCostUsd,a)}),(0,z.jsx)(`td`,{className:`num mono`,children:ur(e.totalTokens,a)}),(0,z.jsx)(`td`,{className:`num`,children:e.requests}),(0,z.jsx)(`td`,{children:(0,z.jsx)(`div`,{className:`pws-share-bar`,children:(0,z.jsx)(`div`,{className:`pws-share-bar-fill`,style:{width:`${Math.round(e.shareRatio*100)}%`}})})})]}),n&&(0,z.jsx)(`tr`,{className:`pws-model-detail`,children:(0,z.jsx)(`td`,{colSpan:5,children:(0,z.jsxs)(`div`,{className:`pws-model-detail-grid`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`muted`,children:i(`pws.tokenInput`)}),(0,z.jsxs)(`span`,{className:`mono`,children:[` `,ur(e.inputTokens,a)]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`muted`,children:i(`pws.tokenOutput`)}),(0,z.jsxs)(`span`,{className:`mono`,children:[` `,ur(e.outputTokens,a)]})]})]})})})]},t)})})]})})]}),(0,z.jsxs)(`div`,{className:`pws-usage-block`,children:[(0,z.jsx)(`h3`,{className:`pws-section-title`,children:i(`pws.rateLimits`)}),c?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Br,{quota:c,plan:null,threshold:80,t:i,layout:`stacked`}),(0,z.jsxs)(`dl`,{className:`pws-kv pws-usage-meta`,children:[n?.source?.trim()&&(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:i(`pws.stats.source`)}),(0,z.jsx)(`dd`,{children:Er(n.source)})]}),(0,z.jsxs)(`div`,{className:`pws-kv-row`,children:[(0,z.jsx)(`dt`,{children:i(`pws.stats.quotaUpdated`)}),(0,z.jsx)(`dd`,{children:ar(n?.updatedAt,o)})]})]})]}):(0,z.jsx)(`p`,{className:`muted`,children:i(`pws.quotaUnavailable`)})]})]})}function ii(e){if(!e)return null;let t=e.trim();return t?t.length<=4?`account-…`:`account-…${t.slice(-4)}`:null}function ai(e){return ii(e)??`account-…`}function oi(e){return e===`healthy`?`ok`:e===`cooldown`?`muted`:e===`reauth_required`||e===`warning`?`warn`:`muted`}function si(e){let t=oi(e);return t===`ok`?`badge badge-green`:t===`warn`?`badge badge-amber`:`badge badge-muted`}function ci(e){return e===`reauth_required`}function li(e){return!!e?.needsReauth||ci(e?.health?.status)}function ui(e){return e===`cooldown`}function di(e){return e===`warning`||e===`reauth_required`}function fi(e){if(!e||e.status===`healthy`)return null;if(e.status===`cooldown`)return e.reason===`rate_limit`?`pws.healthLabel.rateLimited`:`pws.healthLabel.quotaLimited`;if(e.status===`reauth_required`)return e.reason===`refresh_failed`?`pws.healthLabel.refreshFailed`:`pws.healthLabel.reauthRequired`;switch(e.reason){case`refresh_conflict`:return`pws.healthLabel.credentialConflict`;case`metadata_mismatch`:return`pws.healthLabel.metadataMismatch`;case`stale_credentials`:return`pws.healthLabel.refreshFailed`;default:return`pws.healthLabel.reauthRequired`}}function pi(e,t){let n=fi(t);return n?e(n):null}function mi(e,t,n,r){if(!r||r.status===`healthy`)return null;let i=n===`__main__`?e(`codexAuth.mainAccount`):ai(n);if(r.status===`cooldown`){let n=r.until?new Date(r.until).toLocaleString():``;return e(r.reason===`rate_limit`?`pws.healthSummary.rateLimited`:`pws.healthSummary.quotaLimited`,{provider:t,account:i,until:n})}return r.status===`reauth_required`?e(`pws.healthSummary.reauthRequired`,{provider:t,account:i}):r.reason===`refresh_conflict`?e(`pws.healthSummary.credentialConflict`,{provider:t,account:i}):r.reason===`metadata_mismatch`?e(`pws.healthSummary.metadataMismatch`,{provider:t,account:i}):e(`pws.healthSummary.staleCredentials`,{provider:t,account:i})}async function hi(e){let t=navigator.clipboard?.writeText?.bind(navigator.clipboard);if(t)try{return await t(e),!0}catch{}return gi(e)}function gi(e){if(typeof document>`u`||typeof document.execCommand!=`function`)return!1;let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.setAttribute(`aria-hidden`,`true`),t.style.position=`fixed`,t.style.top=`0`,t.style.opacity=`0`,document.body.appendChild(t);try{return t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}function _i(e,t){return e(t?t===`copied`?`pws.doctorCopied`:`pws.doctorCopyUnavailable`:`pws.copyDoctor`)}var vi=e=>({step:e?`oauth-waiting`:`pick`,id:``,error:``,authUrl:``,manualCode:``,manualCodeState:`idle`,statusNotice:``,statusTone:`ok`,flowId:null});function yi(e,t){switch(t.type){case`set-step`:return{...e,step:t.step};case`set-id`:return{...e,id:t.id};case`set-error`:return{...e,error:t.error};case`set-auth-url`:return{...e,authUrl:t.authUrl};case`set-manual-code`:return{...e,manualCode:t.manualCode};case`set-manual-code-state`:return{...e,manualCodeState:t.manualCodeState};case`set-status-notice`:return{...e,statusNotice:t.statusNotice,statusTone:t.statusTone??e.statusTone};case`set-flow-id`:return{...e,flowId:t.flowId};case`clear-manual-code`:return{...e,manualCode:``,manualCodeState:`idle`,statusNotice:``,statusTone:`ok`};case`reset-oauth-start`:return{...e,error:``,statusNotice:``,statusTone:`ok`,flowId:null};case`oauth-code-submitted`:return{...e,error:``,manualCode:``,manualCodeState:`waiting`,statusTone:`ok`,statusNotice:``};default:return e}}function bi({id:e,error:t,onIdChange:n,onStartOAuth:r,onClose:i}){let a=K();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`h3`,{style:{marginBottom:4},children:a(`codexAuth.addTitle`)}),(0,z.jsx)(`p`,{className:`modal-desc`,children:a(`codexAuth.addPickDesc`)}),(0,z.jsx)(`label`,{className:`field-label`,htmlFor:`codex-account-id-input`,children:a(`codexAuth.addIdLabel`)}),(0,z.jsx)(`input`,{id:`codex-account-id-input`,className:`input`,placeholder:a(`codexAuth.addIdPlaceholder`),value:e,onChange:e=>n(e.target.value),style:{marginBottom:12}}),(0,z.jsx)(`button`,{type:`button`,className:`list-row`,onClick:r,style:{marginBottom:8},children:(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[(0,z.jsx)(Oe,{width:20}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`title`,children:a(`codexAuth.oauthLogin`)}),(0,z.jsx)(`div`,{className:`sub`,children:a(`codexAuth.oauthDesc`)})]})]})}),t&&(0,z.jsx)(`div`,{className:`notice notice-err`,style:{marginTop:8},children:t}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:i,style:{width:`100%`},children:a(`codexAuth.cancel`)})]})}var xi=2500;function Si(){let[e,t]=(0,_.useState)(null),n=(0,_.useRef)(null),r=(0,_.useRef)(0),i=(0,_.useCallback)(()=>{n.current&&=(clearTimeout(n.current),null)},[]);return(0,_.useEffect)(()=>i,[i]),{outcomeFor:(0,_.useCallback)(t=>e&&Object.is(e.scope,t)?e.outcome:null,[e]),copy:(0,_.useCallback)((e,a)=>{let o=++r.current;hi(e).then(e=>{r.current===o&&(i(),t({scope:a,outcome:e?`copied`:`unavailable`}),n.current=setTimeout(()=>{n.current=null,r.current===o&&t(null)},xi))})},[i])}}function Z({url:e}){let t=K(),{outcomeFor:n,copy:r}=Si();if(!e)return null;let i=n(e),a=t(i===`copied`?`prov.linkCopied`:i===`unavailable`?`prov.linkCopyUnavailable`:`prov.copyLink`);return(0,z.jsxs)(`div`,{className:`login-url-block`,children:[(0,z.jsx)(`code`,{className:`login-url-block-text`,children:e}),(0,z.jsxs)(`div`,{className:`login-url-block-actions`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>r(e,e),children:[(0,z.jsx)(we,{style:{width:13,height:13},"aria-hidden":`true`}),(0,z.jsx)(`span`,{"aria-live":`polite`,children:a})]}),(0,z.jsxs)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`login-url-block-open`,children:[(0,z.jsx)(be,{style:{width:13,height:13},"aria-hidden":`true`}),` `,t(`prov.didntOpen`)]})]})]})}function Ci({reauthAccountId:e,authUrl:t,manualCode:n,manualCodeBusy:r,manualCodeWaiting:i,statusNotice:a,statusTone:o,flowId:s,error:c,onManualCodeChange:l,onSubmitManualCode:u,onClose:d}){let f=K();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`h3`,{style:{marginBottom:4},children:f(e?`codexAuth.reauthenticate`:`codexAuth.oauthLogin`)}),(0,z.jsx)(`p`,{className:`modal-desc`,children:f(`codexAuth.oauthWaiting`)}),(0,z.jsx)(Z,{url:t}),(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,marginTop:12},children:[(0,z.jsx)(`div`,{className:`muted text-label`,children:f(`prov.pasteRedirectHint`)}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,z.jsx)(`input`,{type:`text`,autoComplete:`off`,spellCheck:!1,value:n,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),u())},placeholder:f(`prov.pasteRedirect`),"aria-label":f(`prov.pasteRedirect`),disabled:r||i,className:`input text-label`,style:{flex:1}}),(0,z.jsx)(`button`,{className:`btn btn-ghost`,type:`button`,disabled:r||i||!n.trim()||!s,onClick:u,children:f(r?`codexAuth.oauthSubmittingCode`:`prov.pasteSubmit`)})]})]}),a&&(0,z.jsx)(`div`,{className:o===`warn`?`notice-warn`:`notice notice-ok`,role:`status`,"aria-live":`polite`,style:{marginTop:12},children:a}),c&&(0,z.jsx)(`div`,{className:`notice notice-err`,style:{marginTop:12},children:c}),(0,z.jsx)(`div`,{style:{textAlign:`center`,padding:`24px 0`},children:(0,z.jsx)(`span`,{className:`spin`,style:{width:24,height:24}})}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:d,style:{width:`100%`},children:f(`codexAuth.cancel`)})]})}function wi({apiBase:e,reauthAccountId:t,ui:n,dispatch:r,t:i}){let a=(0,_.useRef)(!0),o=(0,_.useRef)(0),s=(0,_.useRef)(!1),c=(0,_.useRef)(null),l=(0,_.useRef)(null),u=(0,_.useRef)(null),d=(0,_.useRef)(null),f=(0,_.useRef)(n.manualCodeState),p=(0,_.useRef)(null),m=(0,_.useRef)(null),h=(0,_.useRef)(()=>{}),g=(0,_.useRef)(()=>{}),v=n.manualCodeState===`submitting`,y=n.manualCodeState===`waiting`;(0,_.useEffect)(()=>{f.current=n.manualCodeState},[n.manualCodeState]),(0,_.useEffect)(()=>{d.current=n.flowId},[n.flowId]);let b=(0,_.useCallback)(()=>{c.current&&=(clearInterval(c.current),null),l.current&&=(clearTimeout(l.current),null),u.current?.abort(),u.current=null,s.current=!1},[]),x=(0,_.useCallback)(()=>{r({type:`clear-manual-code`}),o.current=0},[r]),S=(0,_.useCallback)(async()=>{x();let t=d.current;d.current=null,r({type:`set-flow-id`,flowId:null}),r({type:`set-auth-url`,authUrl:``}),b(),p.current?.abort(),p.current=null,t&&await fetch(`${e}/api/codex-auth/login/cancel`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({flowId:t})}).catch(()=>{})},[e,x,r,b]);(0,_.useEffect)(()=>(a.current=!0,()=>{x(),a.current=!1,m.current=null,p.current?.abort(),p.current=null;let t=d.current;d.current=null,r({type:`set-flow-id`,flowId:null}),b(),t&&fetch(`${e}/api/codex-auth/login/cancel`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({flowId:t})}).catch(()=>{})}),[e,x,r,b]);let C=(0,_.useCallback)((e,t)=>{h.current=e,g.current=t},[]),w=(0,_.useCallback)(()=>{n.step===`oauth-waiting`&&S(),g.current()},[n.step,S]),T=(0,_.useCallback)(async n=>{x(),d.current=null,r({type:`set-flow-id`,flowId:null});let m=new AbortController;p.current?.abort(),p.current=m,r({type:`reset-oauth-start`}),o.current=0;try{let p=t??n?.trim()??``,_=()=>fetch(`${e}/api/codex-auth/login`,{signal:m.signal,method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t?{id:t,reauth:!0}:p?{id:p}:{})}),v=await _();if(!a.current)return;if(v.status===409){if(await fetch(`${e}/api/codex-auth/login/cancel`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`}),!a.current||m.signal.aborted)return;if(v=await _(),v.status===409){r({type:`set-error`,error:i(`codexAuth.oauthAlreadyInProgress`)});return}}let y=await J(v,i(`modal.networkError`));if(!a.current||!y)return;if(y.url){d.current=y.flowId??null,r({type:`set-flow-id`,flowId:y.flowId??null}),r({type:`set-auth-url`,authUrl:y.url}),r({type:`set-step`,step:`oauth-waiting`}),b();let n=y.flowId??``,m=t?`&reauth=1`:``,_=n?`${e}/api/codex-auth/login-status?flowId=${encodeURIComponent(n)}${p?`&accountId=${encodeURIComponent(p)}`:``}${m}`:`${e}/api/codex-auth/login-status`,v=new AbortController;u.current=v,c.current=setInterval(async()=>{if(s.current||v.signal.aborted)return;s.current=!0;let e=AbortSignal.any([v.signal,AbortSignal.timeout(1e4)]);try{let n=await ut(await fetch(_,{signal:e}));if(!a.current||v.signal.aborted)return;if(!n){o.current+=1,o.current>=3&&r({type:`set-status-notice`,statusNotice:i(`codexAuth.oauthStatusRetrying`),statusTone:`warn`});return}if(o.current=0,f.current===`waiting`?r({type:`set-status-notice`,statusNotice:i(`codexAuth.oauthCodeSubmitted`),statusTone:`ok`}):r({type:`set-status-notice`,statusNotice:``,statusTone:`ok`}),n.status===`done`){if(b(),x(),d.current=null,r({type:`set-flow-id`,flowId:null}),!a.current)return;h.current(),g.current()}else(n.status===`error`||n.status===`expired`)&&(b(),x(),d.current=null,r({type:`set-flow-id`,flowId:null}),a.current&&(t||r({type:`set-step`,step:`pick`}),r({type:`set-error`,error:n.error??i(`codexAuth.loginFailed`)})))}catch(e){if(!a.current||v.signal.aborted||e instanceof Error&&e.name===`AbortError`)return;o.current+=1,o.current>=3&&r({type:`set-status-notice`,statusNotice:i(`codexAuth.oauthStatusRetrying`),statusTone:`warn`})}finally{s.current=!1}},2e3),l.current=setTimeout(()=>{c.current&&(x(),S(),a.current&&(t||r({type:`set-step`,step:`pick`}),r({type:`set-error`,error:i(`modal.loginTimeout`)})))},3e5)}y.error&&!y.url&&r({type:`set-error`,error:y.error})}catch(e){a.current&&!(e instanceof Error&&e.name===`AbortError`)&&r({type:`set-error`,error:e instanceof Error?e.message:String(e)})}},[e,S,x,r,t,b,i]);return(0,_.useEffect)(()=>{if(!t){m.current=null;return}m.current!==t&&(m.current=t,T())},[t,T]),{manualCodeBusy:v,manualCodeWaiting:y,bindCallbacks:C,closeModal:w,startOAuth:T,submitManualCode:(0,_.useCallback)(async()=>{let t=d.current,s=n.manualCode.trim();if(!(!t||!s||v||y)){r({type:`set-manual-code-state`,manualCodeState:`submitting`}),r({type:`set-status-notice`,statusNotice:``,statusTone:`ok`});try{let n=await fetch(`${e}/api/codex-auth/login/code`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({flowId:t,input:s})});if(!a.current)return;if(!n.ok){r({type:`set-error`,error:i(`prov.pasteFail`,{error:(await n.json().catch(()=>({}))).error??n.statusText})}),r({type:`set-manual-code-state`,manualCodeState:`idle`});return}r({type:`oauth-code-submitted`}),r({type:`set-status-notice`,statusNotice:i(`codexAuth.oauthCodeSubmitted`),statusTone:`ok`}),o.current=0}catch{a.current&&(r({type:`set-error`,error:i(`modal.networkError`)}),r({type:`set-manual-code-state`,manualCodeState:`idle`}))}}},[e,r,v,y,i,n.manualCode])}}function Ti({apiBase:e,onClose:t,onAdded:n,reauthAccountId:r}){let i=K(),[a,o]=(0,_.useReducer)(yi,r,vi),s=(0,_.useRef)(null),c=(0,_.useRef)(null),{manualCodeBusy:l,manualCodeWaiting:u,bindCallbacks:d,closeModal:f,startOAuth:p,submitManualCode:m}=wi({apiBase:e,reauthAccountId:r,ui:a,dispatch:o,t:i});(0,_.useEffect)(()=>{d(n,t)},[d,n,t]),(0,_.useEffect)(()=>{s.current=document.activeElement;let e=c.current;e&&!e.open&&e.showModal();let t=e?.querySelector(`input:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex='-1'])`);return t&&t.focus(),()=>{s.current?.focus()}},[]);let h=(0,_.useCallback)(e=>{e.preventDefault(),f()},[f]);return(0,z.jsx)(`dialog`,{ref:c,"aria-label":i(r?`codexAuth.reauthenticate`:`codexAuth.addTitle`),className:`modal-overlay`,onCancel:h,children:(0,z.jsxs)(`div`,{className:`modal-card`,style:{maxWidth:440},children:[a.step===`pick`&&(0,z.jsx)(bi,{id:a.id,error:a.error,onIdChange:e=>o({type:`set-id`,id:e}),onStartOAuth:()=>{p(a.id)},onClose:f}),a.step===`oauth-waiting`&&(0,z.jsx)(Ci,{reauthAccountId:r,authUrl:a.authUrl,manualCode:a.manualCode,manualCodeBusy:l,manualCodeWaiting:u,statusNotice:a.statusNotice,statusTone:a.statusTone,flowId:a.flowId,error:a.error,onManualCodeChange:e=>o({type:`set-manual-code`,manualCode:e}),onSubmitManualCode:()=>{m()},onClose:f})]})})}var Ei=1e4;function Di(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0&&e<=100?e:80}function Oi(e){let t=e.trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return n>=1&&n<=100?n:null}function ki(e,t){return e>0?0:Number.isInteger(t)&&t>=1&&t<=100?t:80}function Ai(e,t,n,r){return n===r?e||t?`defer`:`apply`:`ignore`}function ji(e){return e&&typeof e==`object`&&e&&`autoSwitchThreshold`in e?e.autoSwitchThreshold:e}function Mi(e,t,n){if(e<=0){let t=ki(e,n);return{threshold:t,lastEnabled:t}}return{threshold:0,lastEnabled:Oi(t)??ki(0,n)}}async function Ni(e,t,n=(e,t)=>fetch(e,t),r=Ei){if(!Number.isInteger(t)||t<0||t>100)return!1;try{return(await n(`${e}/api/codex-auth/auto-switch`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({threshold:t}),signal:AbortSignal.timeout(r)})).ok}catch{return!1}}var Pi=3e4,Fi=new Map;function Ii(e,t=!0){let n=Fi.get(e),[r,i]=(0,_.useState)(()=>n?.accounts??[]),[a,o]=(0,_.useState)(()=>n?.activeId??null),[s,c]=(0,_.useState)(()=>n==null?`loading`:`ready`),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(0),[v,y]=(0,_.useState)(()=>n!=null),[b,x]=(0,_.useState)(0),S=(0,_.useRef)(new Set),C=(0,_.useRef)(null),w=(0,_.useRef)(0),T=(0,_.useRef)(null),E=(0,_.useRef)(new Set),D=(0,_.useRef)(null),O=(0,_.useRef)(null),k=(0,_.useRef)(!!n?.accounts.length),A=(0,_.useRef)(n!=null),j=(0,_.useRef)(null),M=(0,_.useCallback)(e=>(E.current.add(e),()=>{E.current.delete(e)}),[]),N=(0,_.useCallback)(()=>ji(D.current?.value),[]),P=(0,_.useCallback)(()=>D.current?.value,[]),F=(0,_.useCallback)(async(t=!1)=>{let n=++w.current;g(e=>e+1);try{let r=[...E.current],a=new Map;for(let e of r)a.set(e,e.beginActiveRead());!t&&!A.current&&c(`loading`);let s=null,l,u=(async()=>{try{let r=await fetch(`${e}/api/codex-auth/accounts${t?`?refresh=1`:``}`);if(!r.ok)throw Error(`account load failed`);let a=await r.json();return w.current===n&&(s=a.accounts??[],i(s),k.current=s.length>0,A.current=!0,c(`ready`)),!0}catch{return!1}})(),d=(async()=>{try{let t=await fetch(`${e}/api/codex-auth/active`);if(!t.ok)throw Error(`active account load failed`);let i=await t.json();if(w.current===n){let e=i.activeCodexAccountId??null,t=T.current;t&&e!==t.id||(T.current=null,l=e,o(e)),D.current={value:i};for(let e of r)e.acceptActiveRead(i,a.get(e))}return!0}catch{if(w.current===n)for(let e of r)e.rejectActiveRead();return!1}})(),[f,p]=await Promise.all([u,d]);if(w.current!==n)return!1;if(f){c(`ready`),A.current=!0;let t=Fi.get(e);return Fi.set(e,{accounts:s??t?.accounts??[],activeId:l===void 0?t?.activeId??null:l}),p}return A.current||c(`error`),!1}finally{g(e=>Math.max(0,e-1)),y(!0)}},[e]);(0,_.useEffect)(()=>{t&&C.current!==e&&(C.current=e,Promise.resolve().then(()=>{F()}))},[e,t,F]);let I=r.some(e=>e.hasCredential&&!e.quota);(0,_.useEffect)(()=>{if(!t||!I||b>0)return;let e=[350,900,2e3].map(e=>window.setTimeout(()=>{F(!1)},e));return()=>{for(let t of e)window.clearTimeout(t)}},[t,I,b,F]),(0,_.useEffect)(()=>{if(!t||b>0)return;let e=window.setInterval(()=>{F()},Pi);return()=>window.clearInterval(e)},[t,F,b]);let L=(0,_.useCallback)(()=>{let e={};return S.current.add(e),x(S.current.size),e},[]),R=(0,_.useCallback)(e=>{S.current.delete(e)&&x(S.current.size)},[]),z=(0,_.useCallback)(async t=>{if(O.current)return{ok:!1,reason:`busy`};O.current=t??`__main__`,u(t??`__main__`);try{let n=await fetch(`${e}/api/codex-auth/active`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({accountId:t})});if(!n.ok)throw Error(`account switch failed`);let r=(await n.json().catch(()=>({}))).activeCodexAccountId??t;return T.current={id:r??null},o(r??null),F(),{ok:!0,activeId:r??null}}catch{return{ok:!1,reason:`request`}}finally{O.current=null,u(null)}},[e,F]),B=(0,_.useCallback)(async(t,n)=>{try{return(await fetch(`${e}/api/codex-auth/accounts/alias`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t,alias:n.trim()})})).ok?(await F(),{ok:!0}):{ok:!1,reason:`request`}}catch{return{ok:!1,reason:`request`}}},[e,F]),V=(0,_.useCallback)(async(t,n)=>{if(j.current)return{ok:!1,reason:`busy`};j.current={accountId:t},f(t);try{let r=await fetch(`${e}/api/codex-auth/accounts/pause`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t,paused:n})});if(!r.ok)return{ok:!1,reason:`request`};let a=await r.json().catch(()=>({})),s=a&&typeof a==`object`?a:{};if(i(e=>e.map(e=>e.id===t||t===`__main__`&&e.isMain?{...e,paused:n}:e)),Object.prototype.hasOwnProperty.call(s,`activeCodexAccountId`)){let e=s.activeCodexAccountId??null;T.current={id:e},o(e)}return F(),{ok:!0}}catch{return{ok:!1,reason:`request`}}finally{j.current=null,f(null)}},[e,F]),H=(0,_.useCallback)(async()=>{if(j.current)return{ok:!1,reason:`busy`};j.current=`bulk`,m(!0);try{let t=await fetch(`${e}/api/codex-auth/accounts/pause-exhausted`,{method:`PUT`});if(!t.ok)return{ok:!1,reason:`request`};let n=await t.json().catch(()=>({})),r=n&&typeof n==`object`?n:{},a=new Set(r.pausedAccountIds??[]);if(i(e=>e.map(e=>a.has(e.id)||a.has(`__main__`)&&e.isMain?{...e,paused:!0}:e)),Object.prototype.hasOwnProperty.call(r,`activeCodexAccountId`)){let e=r.activeCodexAccountId??null;T.current={id:e},o(e)}return F(),{ok:!0,pausedCount:r.pausedCount??a.size}}catch{return{ok:!1,reason:`request`}}finally{j.current=null,m(!1)}},[e,F]),U=(0,_.useCallback)(async t=>{try{return(await fetch(`${e}/api/codex-auth/accounts?id=${encodeURIComponent(t)}`,{method:`DELETE`})).ok?(await F(),{ok:!0}):{ok:!1,reason:`request`}}catch{return{ok:!1,reason:`request`}}},[e,F]),W=(0,_.useCallback)(async()=>await F()?{ok:!0}:{ok:!1,reason:`reload`},[F]),ee=a&&a!==`__main__`?r.find(e=>e.id===a):null,te=r.find(e=>e.isMain),ne=ee??te,re=!ne?.paused&&li(ne);return{accounts:r,activeId:a,loadState:s,refreshing:h>0,initialLoading:!v,switchingId:l,pauseUpdatingId:d,pausingExhausted:p,activeNeedsReauth:re,load:F,switchAccount:z,setAccountPaused:V,pauseExhaustedAccounts:H,saveAlias:B,removeAccount:U,syncAfterAccountAdded:W,pauseRefresh:L,resumeRefresh:R,subscribeLoadObserver:M,readLastThreshold:N,readLastActive:P}}function Li(e,t,n,r,i=1){let a=e.trim(),o=a===``?NaN:Number(a),s=Math.min(r,Math.max(n,(Number.isFinite(o)?o:n)+t));return String(i<1?Math.round(s*10)/10:Math.round(s))}function Ri({disabled:e=!1,onIncrement:t,onDecrement:n,incrementLabel:r,decrementLabel:i}){return(0,z.jsxs)(`div`,{className:`ocx-stepper`,role:`group`,children:[(0,z.jsx)(`button`,{type:`button`,className:`ocx-stepper__btn`,disabled:e,"aria-label":r,onMouseDown:e=>e.preventDefault(),onClick:t,children:(0,z.jsx)(me,{width:10,height:10,"aria-hidden":`true`})}),(0,z.jsx)(`button`,{type:`button`,className:`ocx-stepper__btn`,disabled:e,"aria-label":i,onMouseDown:e=>e.preventDefault(),onClick:n,children:(0,z.jsx)(he,{width:10,height:10,"aria-hidden":`true`})})]})}var zi={quota:{on:`codexAuth.autoSwitchQuotaDesc`,off:`codexAuth.autoSwitchQuotaOffDesc`},"round-robin":{on:`codexAuth.autoSwitchRoundRobinDesc`,off:`codexAuth.autoSwitchRoundRobinDesc`},"fill-first":{on:`codexAuth.autoSwitchFillFirstDesc`,off:`codexAuth.autoSwitchFillFirstOffDesc`}};function Bi({threshold:e,draft:t,strategy:n=`quota`,hydrated:r=!0,saving:i,loadError:a,feedback:o,onDraftChange:s,onEditingChange:c,onCommit:l,onCancel:u,onToggle:d,onRetry:f}){let p=K(),m=(0,_.useRef)(!1),h=e>0,g=zi[n][h?`on`:`off`],v=i||!r,y=i?p(`common.saving`):o?.message??``,b=i?`pending`:o?.tone,x=y?`codex-auto-switch-desc codex-auto-switch-feedback`:`codex-auto-switch-desc`;return(0,z.jsxs)(`div`,{className:`card card-row codex-auto-switch-card`,style:{marginTop:16},"aria-busy":i||!r&&!a||void 0,children:[(0,z.jsxs)(`div`,{className:`codex-auto-switch-copy`,children:[(0,z.jsx)(`strong`,{children:p(`codexAuth.autoSwitch`)}),(0,z.jsx)(`div`,{id:`codex-auto-switch-desc`,className:`card-sub`,role:a?`alert`:void 0,children:a?p(`codexAuth.autoSwitchLoadFailed`):p(g,{threshold:e})}),(0,z.jsx)(`div`,{className:`card-sub`,children:p(`codexAuth.failureRecoveryNote`)}),(0,z.jsx)(`div`,{className:`card-sub`,children:p(`codexAuth.cacheWarning`)})]}),(0,z.jsxs)(`div`,{className:`codex-auto-switch-controls`,onBlur:e=>{if(!e.currentTarget.contains(e.relatedTarget)){if(c(!1),m.current){m.current=!1;return}h&&!v&&l()}},children:[a&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:f,children:p(`pws.retryAccounts`)}),h&&(0,z.jsxs)(`label`,{className:`codex-auto-switch-threshold`,children:[(0,z.jsx)(`span`,{className:`field-label`,children:p(`codexAuth.autoSwitchThreshold`)}),(0,z.jsxs)(`span`,{className:`codex-auto-switch-input-wrap`,children:[(0,z.jsx)(`input`,{className:`input mono codex-auto-switch-input`,type:`number`,min:1,max:100,step:1,inputMode:`numeric`,value:t,readOnly:v,"aria-disabled":v,"aria-label":p(`codexAuth.autoSwitchThresholdAria`),"aria-describedby":x,onChange:e=>s(e.target.value),onFocus:()=>{v||c(!0)},onKeyDown:e=>{e.nativeEvent.isComposing||v||(e.key===`Enter`?(e.preventDefault(),l()):e.key===`Escape`&&(e.preventDefault(),u()))}}),(0,z.jsx)(`span`,{className:`codex-auto-switch-unit`,"aria-hidden":`true`,children:`%`}),(0,z.jsx)(Ri,{disabled:v,incrementLabel:p(`codexAuth.autoSwitchThresholdInc`),decrementLabel:p(`codexAuth.autoSwitchThresholdDec`),onIncrement:()=>{c(!0),s(Li(t,1,1,100))},onDecrement:()=>{c(!0),s(Li(t,-1,1,100))}})]})]}),(0,z.jsx)(`span`,{className:`codex-auto-switch-toggle-slot`,children:(0,z.jsx)(`button`,{type:`button`,className:`toggle ${h?`on`:``}`,onPointerDownCapture:()=>{m.current=!0},onPointerUp:()=>{m.current=!1},onPointerCancel:()=>{m.current=!1},onClick:()=>{m.current=!1,d()},disabled:v,"aria-pressed":h,"aria-label":p(`codexAuth.autoSwitch`),"aria-describedby":x,title:p(`codexAuth.autoSwitch`),children:(0,z.jsx)(`span`,{className:`toggle-knob`})})})]}),y&&(0,z.jsx)(`div`,{id:`codex-auto-switch-feedback`,className:`codex-auto-switch-feedback${b===`err`?` is-error`:``}`,role:b===`err`?`alert`:`status`,"aria-atomic":`true`,children:y})]})}var Vi=[`quota`,`round-robin`,`fill-first`],Hi=`quota`,Ui=new Set(Vi);function Wi(e){return typeof e==`string`&&Ui.has(e)?e:Hi}function Gi(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=100?e:1}function Ki(e){let t=e.trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return n>=1&&n<=100?n:null}async function qi(e,t,n=(e,t)=>fetch(e,t)){if(t.strategy===void 0&&t.stickyLimit===void 0)return{ok:!1};try{let r=await n(`${e}/api/codex-auth/pool-strategy`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t.strategy===void 0?{}:{strategy:t.strategy},...t.stickyLimit===void 0?{}:{stickyLimit:t.stickyLimit}})});if(!r.ok)return{ok:!1};let i=await r.json();return{ok:!0,strategy:Wi(i.accountPoolStrategy??t.strategy),stickyLimit:Gi(i.accountPoolStickyLimit??t.stickyLimit)}}catch{return{ok:!1}}}var Ji={quota:`accountPool.strategyQuota`,"round-robin":`accountPool.strategyRoundRobin`,"fill-first":`accountPool.strategyFillFirst`},Yi={quota:`accountPool.strategyHintQuota`,"round-robin":`accountPool.strategyHintRoundRobin`,"fill-first":`accountPool.strategyHintFillFirst`};function Xi({strategy:e,stickyDraft:t,disabled:n=!1,strategySelectId:r=`account-pool-strategy`,stickyInputId:i=`account-pool-sticky-limit`,onStrategyChange:a,onStickyDraftChange:o,onStickyCommit:s}){let c=K(),l=Vi.map(e=>({value:e,label:c(Ji[e])}));return(0,z.jsxs)(`div`,{className:`account-pool-strategy-controls`,children:[(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,id:`${r}-label`,children:c(`accountPool.strategy`)}),(0,z.jsx)(`span`,{className:`desc`,children:c(`accountPool.strategyDesc`)}),(0,z.jsx)(`span`,{className:`desc`,children:c(Yi[e])}),(0,z.jsx)(`span`,{className:`desc`,children:c(`accountPool.unboundDefinition`)})]}),(0,z.jsx)(`div`,{className:`setting-controls`,children:(0,z.jsx)(at,{id:r,value:e,options:l,disabled:n,label:c(`accountPool.strategy`),onChange:e=>a(e)})})]}),e===`round-robin`&&(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`label`,{className:`setting-label`,htmlFor:i,children:[(0,z.jsx)(`span`,{className:`title`,children:c(`accountPool.stickyLimit`)}),(0,z.jsx)(`span`,{className:`desc`,children:c(`accountPool.stickyLimitHelp`)})]}),(0,z.jsx)(`div`,{className:`setting-controls`,children:(0,z.jsxs)(`span`,{className:`codex-auto-switch-input-wrap`,children:[(0,z.jsx)(`input`,{id:i,className:`input mono codex-auto-switch-input`,type:`number`,min:1,max:100,step:1,inputMode:`numeric`,value:t,disabled:n,"aria-label":c(`accountPool.stickyLimitAria`),onChange:e=>o(e.target.value),onBlur:()=>s(),onKeyDown:e=>{e.nativeEvent.isComposing||n||e.key===`Enter`&&(e.preventDefault(),s())}}),(0,z.jsx)(Ri,{disabled:n,incrementLabel:c(`accountPool.stickyLimitInc`),decrementLabel:c(`accountPool.stickyLimitDec`),onIncrement:()=>{let e=Li(t,1,1,100);o(e),s(e)},onDecrement:()=>{let e=Li(t,-1,1,100);o(e),s(e)}})]})})]})]})}function Zi(e){if(!e||typeof e!=`object`)return null;let t=e;return!(`accountPoolStrategy`in t)&&!(`accountPoolStickyLimit`in t)?null:{strategy:Wi(t.accountPoolStrategy),stickyLimit:Gi(t.accountPoolStickyLimit)}}function Qi({apiBase:e,subscribeLoadObserver:t,readLastActive:n,onStrategyResolved:r}){let i=K(),[a,o]=(0,_.useState)(Hi),[s,c]=(0,_.useState)(1),[l,u]=(0,_.useState)(`1`),[d,f]=(0,_.useState)(!1),p=(0,_.useRef)(!1),[m,h]=(0,_.useState)(!1),g=(0,_.useRef)(!1),v=(0,_.useRef)(!1),y=(0,_.useRef)(0),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(null),w=(0,_.useCallback)(e=>{let t=Wi(e.accountPoolStrategy),n=Gi(e.accountPoolStickyLimit);o(t),r?.(t),c(n),u(String(n)),p.current=!0,f(!0),x(!1),C(null)},[r]),T=(0,_.useCallback)(e=>{let t=Zi(e);t&&w({accountPoolStrategy:t.strategy,accountPoolStickyLimit:t.stickyLimit})},[w]),E=(0,_.useCallback)(async()=>{try{let t=await fetch(`${e}/api/codex-auth/active`);if(!t.ok)throw Error(`load`);let n=await t.json();if(g.current){v.current=!0;return}w(n)}catch{g.current||x(!0)}},[e,w]),D=(0,_.useCallback)(()=>{v.current&&(v.current=!1,queueMicrotask(()=>{if(g.current){v.current=!0;return}E()}))},[E]);(0,_.useEffect)(()=>{if(!t)return;let e=t({beginActiveRead:()=>y.current,acceptActiveRead:(e,t)=>{if(t===y.current){if(g.current){v.current=!0;return}T(e)}},rejectActiveRead:()=>{p.current||x(!0)}});return!g.current&&n&&T(n()),e},[t,T,n]),(0,_.useEffect)(()=>{!n||t||g.current||T(n())},[n,T,t]),(0,_.useEffect)(()=>{t||E()},[E,t]);let O=(0,_.useCallback)(async t=>{if(g.current)return;let n=a,l=s;t.strategy!==void 0&&(o(t.strategy),r?.(t.strategy)),t.stickyLimit!==void 0&&(c(t.stickyLimit),u(String(t.stickyLimit))),g.current=!0,h(!0),C(null),y.current+=1;let d=await qi(e,t);y.current+=1,d.ok?(o(d.strategy),r?.(d.strategy),c(d.stickyLimit),u(String(d.stickyLimit)),p.current=!0,f(!0)):(C(i(`accountPool.strategyUpdateFailed`)),o(n),r?.(n),c(l),u(String(l))),g.current=!1,h(!1),D()},[e,r,D,s,a,i]),k=m||b||!d;return(0,z.jsxs)(`div`,{className:`card account-pool-strategy-card`,"aria-busy":m||!d&&!b,children:[b&&(0,z.jsx)(`div`,{className:`card-sub`,role:`alert`,children:i(`accountPool.strategyLoadFailed`)}),b&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm account-pool-strategy-card__retry`,onClick:()=>{E()},children:i(`common.retry`)}),!b&&(0,z.jsx)(Xi,{strategy:a,stickyDraft:l,disabled:k,strategySelectId:`codex-pool-strategy`,stickyInputId:`codex-pool-sticky-limit`,onStrategyChange:e=>{k||e===a||O({strategy:e})},onStickyDraftChange:u,onStickyCommit:e=>{if(k)return;let t=Ki(e??l);if(t===null){u(String(s)),C(i(`accountPool.stickyLimitInvalid`));return}if(t===s){u(String(t));return}O({stickyLimit:t})}}),S&&(0,z.jsx)(`div`,{role:`alert`,className:`card-sub account-pool-strategy-card__error`,children:S})]})}function $i(e,t){let[n,r]=(0,_.useState)(80),[i,a]=(0,_.useState)(`80`),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(null),m=(0,_.useRef)(80),h=(0,_.useRef)(!1),g=(0,_.useRef)(80),v=(0,_.useRef)(!1),y=(0,_.useRef)(!1),b=(0,_.useRef)(!1),x=(0,_.useRef)(0),S=(0,_.useRef)(null),C=(0,_.useRef)(null),w=(0,_.useCallback)(e=>{m.current=e,h.current=!0,s(!0),r(e),e>0&&(g.current=e),a(String(e>0?e:g.current))},[]),T=(0,_.useCallback)(e=>{if(v.current||y.current){S.current=e;return}S.current=null,w(e)},[w]),E=(0,_.useCallback)(()=>{let e=S.current;return e===null?!1:(S.current=null,w(e),!0)},[w]),D=(0,_.useCallback)(()=>{C.current!==null&&(window.clearTimeout(C.current),C.current=null),p(null)},[]),O=(0,_.useCallback)((e,t)=>{C.current!==null&&window.clearTimeout(C.current),p({tone:t?`err`:`ok`,message:e}),C.current=window.setTimeout(()=>{p(null),C.current=null},5e3)},[]);(0,_.useEffect)(()=>()=>{C.current!==null&&window.clearTimeout(C.current)},[]);let k=(0,_.useCallback)(()=>(h.current||l(!1),x.current),[]),A=(0,_.useCallback)((e,t)=>{l(!1);let n=ji(e),r=Ai(v.current,y.current,t,x.current);r===`defer`?S.current=Di(n):r===`apply`&&T(Di(n))},[T]),j=(0,_.useCallback)(e=>{h.current||v.current||y.current||(l(!1),w(Di(ji(e))))},[w]),M=(0,_.useCallback)(()=>{h.current||l(!0)},[]),N=(0,_.useCallback)(async(n,r,i=!0)=>{if(y.current)return!1;y.current=!0,v.current=!1,D(),d(!0),x.current+=1;try{let a=await Ni(e,n);return x.current+=1,a?(S.current=null,w(n),i&&O(t.updated,!1)):(E()||w(r),O(t.updateFailed,!0)),a}finally{y.current=!1,d(!1)}},[e,w,D,t.updateFailed,t.updated,E,O]),P=(0,_.useCallback)(()=>{v.current=!1;let e=m.current;E()||a(String(e>0?e:g.current)),O(t.invalid,!0)},[t.invalid,E,O]),F=(0,_.useCallback)(()=>{v.current=!1,b.current=!0,D();let e=m.current;E()||a(String(e>0?e:g.current))},[D,E]),I=(0,_.useCallback)(async()=>{if(b.current)return b.current=!1,!0;if(!h.current||y.current)return!1;let e=m.current;v.current=!1;let t=Oi(i);return t===null?(P(),!1):t===e?(E()||a(String(t)),!0):N(t,e)},[i,E,P,N]),L=(0,_.useCallback)(async()=>{if(!h.current||y.current)return!1;let e=m.current;v.current=!1;let t=Mi(e,i,g.current),n=await N(t.threshold,e);return n?(g.current=t.lastEnabled,t.threshold===0&&a(String(t.lastEnabled)),n):!1},[i,N]);return{threshold:n,draft:i,hydrated:o,saving:u,loadError:c,feedback:f,beginServerRead:k,acceptServerRead:A,hydrateServerValue:j,rejectServerRead:M,setDraft:(0,_.useCallback)(e=>{h.current&&(v.current=!0,b.current=!1,D(),a(e))},[D]),setEditing:(0,_.useCallback)(e=>{v.current=e},[]),commit:I,cancel:F,toggle:L,retry:(0,_.useCallback)(()=>{l(!1),D()},[D])}}var ea=new Map;function ta(e,t){return`${e??``}\0${JSON.stringify(t)}`}function na(e,t){let n=ta(e,t??{}),r=ea.get(n);return r||(r=new Intl.NumberFormat(e,t),ea.set(n,r)),r}var ra={month:`short`,day:`numeric`,year:`numeric`},ia={month:`short`,day:`numeric`,year:`numeric`,hour:`2-digit`,minute:`2-digit`},aa=new Map;function oa(e,t){let n=ta(e,t),r=aa.get(n);return r||(r=new Intl.DateTimeFormat(e,t),aa.set(n,r)),r}function sa(e,t){let n=new Date(e);return Number.isNaN(n.getTime())?`—`:oa(t,ra).format(n)}function ca(e,t){let n=new Date(e);return Number.isNaN(n.getTime())?`—`:oa(t,ia).format(n)}function la(e,t){return!Number.isFinite(e)||e<0?`—`:`~${na(t,{style:`currency`,currency:`USD`,minimumFractionDigits:4,maximumFractionDigits:4}).format(e)}`}function ua(e,t){return sa(e,t)}function da(e,t){return ca(e,t)}function fa(e){return Math.max(0,Math.ceil((new Date(e).getTime()-Date.now())/864e5))}function pa({index:e,grantedAt:t,expiresAt:n,isNext:r,locale:i,t:a}){let o=fa(n),s=o<=7;return(0,z.jsxs)(`div`,{className:`credit-item${r?` credit-next`:``}`,children:[(0,z.jsxs)(`div`,{className:`credit-item-head`,children:[(0,z.jsx)(Ce,{width:13}),(0,z.jsx)(`span`,{className:`credit-item-label`,children:r?a(`codexAuth.creditNext`):a(`codexAuth.creditLabel`,{n:String(e+1)})}),r&&(0,z.jsx)(`span`,{className:`badge badge-amber text-micro`,style:{padding:`1px 6px`},children:a(`codexAuth.creditNextBadge`)})]}),(0,z.jsxs)(`div`,{className:`credit-item-dates`,children:[(0,z.jsx)(`span`,{children:a(`codexAuth.creditGranted`,{date:ua(t,i)})}),(0,z.jsx)(`span`,{className:s?`credit-urgent`:``,children:a(`codexAuth.creditExpires`,{date:da(n,i),days:String(o)})})]})]})}function ma({account:e,onClick:t,t:n}){let r=e.quota?.resetCredits;return e.quota==null?(0,z.jsxs)(`span`,{className:`badge badge-muted codex-ticket-badge-slot`,"aria-hidden":`true`,children:[(0,z.jsx)(Ce,{width:12}),`0`]}):r===void 0?null:(0,z.jsxs)(`button`,{type:`button`,className:`badge ${typeof r==`number`&&r>0?`badge-amber`:`badge-muted`} badge-clickable`,onClick:e=>{e.stopPropagation(),t()},"aria-label":n(`codexAuth.resetCreditsAria`,{count:String(r)}),children:[(0,z.jsx)(Ce,{width:12}),r]})}function ha({t:e,paused:t,saving:n}){let r=e(`codexAuth.pause`),i=e(`codexAuth.resume`),a=e(`common.saving`),o=n?a:t?i:r;return(0,z.jsx)(`span`,{className:`codex-auth-pause-label`,style:{minWidth:`${Math.max(r.length,i.length,a.length)}ch`},children:o})}function ga({pool:e,activeId:t,accountModeState:n,switchActionLabel:r,threshold:i,onOpenReset:a,onSwitch:o,onTogglePause:s,pauseUpdatingId:c,pauseBusy:l,onReauth:u,onEditAlias:d,onRemove:f,onCopyDoctor:p,doctorCopyOutcomeFor:m}){let h=K(),g=e=>!e.paused&&t===e.id;return(0,z.jsx)(z.Fragment,{children:e.map(e=>{let t=e.health?.status,_=!!e.needsReauth||ci(t),v=ui(t),y=pi(h,e.health),b=mi(h,`codex`,e.id,e.health);return(0,z.jsxs)(`div`,{className:`card ${g(e)?`card-active`:``}`,style:{marginBottom:8},children:[(0,z.jsxs)(`div`,{className:`card-head`,children:[(0,z.jsx)(`span`,{className:`dot ${_?`dot-amber`:g(e)?`dot-blue`:`dot-muted`}`}),(0,z.jsx)(`strong`,{children:e.alias??e.email}),(0,z.jsxs)(`span`,{className:`card-badges`,children:[e.plan&&(0,z.jsx)(`span`,{className:`badge badge-green`,children:e.plan}),e.paused&&(0,z.jsx)(`span`,{className:`badge badge-muted`,title:h(`codexAuth.pausedHint`),children:h(`codexAuth.paused`)}),(0,z.jsx)(ma,{t:h,account:e,onClick:()=>a(e)}),y&&(0,z.jsx)(`span`,{className:si(t),children:y}),_&&!y&&(0,z.jsx)(`span`,{className:`badge badge-amber`,children:h(`codexAuth.needsReauth`)}),g(e)&&!_&&!v&&(0,z.jsx)(`span`,{className:`badge badge-primary`,children:h(n===`direct`?`codexAuth.poolPrepared`:`codexAuth.nextSession`)})]}),!e.paused&&!g(e)&&!_&&!v&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm codex-account-switch`,onClick:()=>o(e),children:r}),_&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>u(e.id),children:h(`codexAuth.reauthenticate`)}),p&&di(t)&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm codex-auth-action-btn`,onClick:()=>p(e.id),children:(0,z.jsx)(`span`,{"aria-live":`polite`,children:_i(h,m?.(e.id))})}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-ghost codex-auth-action-btn`,onClick:()=>s(e),disabled:l,title:e.paused?h(`codexAuth.pausedHint`):void 0,"aria-label":e.paused?`${h(`codexAuth.resume`)}. ${h(`codexAuth.pausedHint`)}`:h(`codexAuth.pause`),children:[e.paused?(0,z.jsx)(le,{width:14}):(0,z.jsx)(ce,{width:14}),(0,z.jsx)(ha,{t:h,paused:e.paused,saving:c===e.id})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void d(e),children:h(`prov.editAlias`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn-icon btn-icon-danger card-right`,"aria-label":`${h(`common.remove`)} — ${e.email}`,title:`${h(`common.remove`)} — ${e.email}`,onClick:t=>{t.stopPropagation(),f(e.id)},children:(0,z.jsx)(ae,{width:14})})]}),(0,z.jsxs)(`div`,{className:`card-sub`,children:[e.email,e.plan?` · ${e.plan}`:``,` · `,h(`prov.accountId`),`: `,ai(e.id)]}),b&&(0,z.jsx)(`div`,{className:`card-sub faint`,children:b}),v&&(0,z.jsx)(`div`,{className:`card-sub faint`,children:h(`pws.healthCooldownHint`)}),_?(0,z.jsx)(`div`,{className:`card-sub faint`,children:h(`codexAuth.tokenExpired`)}):!v&&(0,z.jsx)(Br,{quota:e.quota,plan:e.plan,threshold:i,t:h,pending:e.quota==null})]},e.id)})})}function _a({onReauth:e}){let t=K();return(0,z.jsxs)(`div`,{className:`notice-warn`,style:{marginBottom:12,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:12,flexWrap:`wrap`},children:[(0,z.jsxs)(`span`,{children:[(0,z.jsx)(de,{width:14}),` `,t(`codexAuth.tokenExpired`)]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:e,children:t(`codexAuth.reauthenticate`)})]})}function va({confirm:e,mainEmail:t,accountModeState:n,switchingId:r,onCancel:i,onConfirm:a}){let o=K(),s=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let e=s.current;e&&!e.open&&e.showModal()},[]),(0,z.jsxs)(`dialog`,{ref:s,className:`modal-overlay`,"aria-labelledby":`codex-switch-title`,onCancel:(0,_.useCallback)(e=>{e.preventDefault(),i()},[i]),children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":o(`common.close`),tabIndex:-1,onClick:i}),(0,z.jsxs)(`div`,{className:`modal-card`,onClick:e=>e.stopPropagation(),role:`document`,children:[(0,z.jsx)(`h3`,{id:`codex-switch-title`,children:n===`direct`?o(`codexAuth.preparePoolTitle`):e.id===`__main__`?o(`codexAuth.switchBack`):o(`codexAuth.switchTitle`)}),(0,z.jsx)(`p`,{className:`modal-desc`,children:n===`direct`?o(`codexAuth.preparePoolDesc`):e.id===`__main__`?o(`codexAuth.switchBackDesc`):o(`codexAuth.switchDesc`)}),(0,z.jsxs)(`div`,{className:`card`,style:{margin:`12px 0`},children:[(0,z.jsx)(`strong`,{children:e.id===`__main__`?t||o(`codexAuth.codexApp`):e.email}),e.plan&&(0,z.jsx)(`span`,{className:`badge badge-green`,style:{marginLeft:8},children:e.plan})]}),e.id!==`__main__`&&(0,z.jsxs)(`div`,{className:`notice-warn`,children:[(0,z.jsx)(de,{width:14}),` `,o(`codexAuth.cacheWarning`)]}),(0,z.jsxs)(`div`,{className:`modal-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:i,children:o(`codexAuth.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:!!r,onClick:a,children:o(r?`pws.accountSwitching`:n===`direct`?`codexAuth.prepareForPool`:`codexAuth.setAsNext`)})]})]})]})}function ya({resetPopup:e,resetConfirm:t,creditDetails:n,creditDetailsLoading:r,redeeming:i,onClose:a,onShowConfirm:o,onCancelConfirm:s,onRedeem:c}){let{locale:l,t:u}=Ve(),d=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let e=d.current;e&&!e.open&&e.showModal()},[]),(0,z.jsxs)(`dialog`,{ref:d,className:`modal-overlay`,"aria-labelledby":`codex-reset-title`,onCancel:(0,_.useCallback)(e=>{e.preventDefault(),a()},[a]),children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":u(`common.close`),tabIndex:-1,onClick:a}),(0,z.jsx)(`div`,{className:`modal-card`,onClick:e=>e.stopPropagation(),role:`document`,children:t?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{style:{textAlign:`center`,padding:`12px 0`},children:[(0,z.jsx)(`div`,{className:`confirm-icon`,children:(0,z.jsx)(de,{width:22})}),(0,z.jsx)(`h3`,{id:`codex-reset-title`,children:u(`codexAuth.confirmResetTitle`)}),(0,z.jsx)(`p`,{className:`modal-desc`,children:u(`codexAuth.confirmResetDesc`,{count:String(e.quota?.resetCredits??0)})}),n&&n[0]&&(0,z.jsx)(`p`,{className:`faint text-label`,children:u(`codexAuth.confirmWhichCredit`,{date:ua(n[0].granted_at,l)})}),(0,z.jsx)(`p`,{className:`faint text-label`,children:u(`codexAuth.irreversible`)})]}),(0,z.jsxs)(`div`,{className:`modal-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:s,children:u(`codexAuth.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:c,disabled:i,children:u(i?`codexAuth.redeeming`:`codexAuth.useCredit`)})]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`h3`,{id:`codex-reset-title`,children:[(0,z.jsx)(Ce,{width:16}),` `,u(`codexAuth.resetCreditsTitle`)]}),(0,z.jsxs)(`div`,{className:`card-sub`,children:[e.email,e.plan?` · ${e.plan}`:``]}),(0,z.jsx)(`div`,{style:{margin:`16px 0`},children:(e.quota?.resetCredits??0)>0?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{style:{marginBottom:12},children:u(`codexAuth.resetCreditsAvailable`,{count:String(e.quota?.resetCredits??0)})}),r&&(0,z.jsx)(`p`,{className:`faint text-label`,children:u(`common.loading`)}),n&&n.length>0&&(0,z.jsx)(`div`,{className:`credit-list`,children:n.map((e,t)=>(0,z.jsx)(pa,{index:t,grantedAt:e.granted_at,expiresAt:e.expires_at,isNext:t===0,locale:l,t:u},`${e.granted_at}:${e.expires_at}`))}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,style:{marginTop:12,width:`100%`},onClick:o,disabled:i,children:u(`codexAuth.useOneCredit`)}),(0,z.jsx)(`p`,{className:`card-sub text-caption`,style:{marginTop:8,textAlign:`center`},children:u(`codexAuth.fifoNote`)})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`faint`,children:u(`codexAuth.noResetCredits`)}),(0,z.jsx)(`p`,{className:`modal-desc`,children:u(`codexAuth.earnCreditsHint`)})]})})]})})]})}function ba({t:e,main:t,isMainActive:n,accountModeState:r,threshold:i,switchActionLabel:a,onSwitch:o,onTogglePause:s,pauseUpdatingId:c,pauseBusy:l,onOpenReset:u,onCopyDoctor:d,doctorCopyOutcomeFor:f}){let p=e(`codexAuth.codexApp`),m=t?.id??`__main__`,h={id:`__main__`,email:t?.email||p,plan:t?.plan,isMain:!0,paused:t?.paused??!1,hasCredential:!0,quota:t?.quota??null},g=!!t?.needsReauth||ci(t?.health?.status),_=ui(t?.health?.status),v=pi(e,t?.health),y=t?mi(e,`codex`,m,t.health):null;return(0,z.jsxs)(`div`,{className:`card ${n?`card-active`:``}`,style:{marginBottom:12},children:[(0,z.jsxs)(`div`,{className:`card-head`,children:[(0,z.jsx)(`span`,{className:`dot ${g?`dot-amber`:`dot-green`}`}),(0,z.jsx)(`strong`,{children:e(`codexAuth.mainAccount`)}),(0,z.jsxs)(`span`,{className:`card-badges`,children:[t&&(0,z.jsx)(ma,{t:e,account:{...t,id:`__main__`},onClick:()=>u({...t,id:`__main__`})}),t?.paused&&(0,z.jsx)(`span`,{className:`badge badge-muted`,title:e(`codexAuth.pausedHint`),children:e(`codexAuth.paused`)}),v&&(0,z.jsx)(`span`,{className:si(t?.health?.status),children:v}),g&&!v&&(0,z.jsx)(`span`,{className:`badge badge-amber`,children:e(`codexAuth.needsReauth`)}),!t?.paused&&(0,z.jsx)(`span`,{className:`badge ${n?`badge-primary`:`badge-muted`}`,children:e(n?r===`direct`?`codexAuth.poolPrepared`:`codexAuth.nextSession`:`codexAuth.current`)})]}),!t?.paused&&!n&&!g&&!_&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm codex-account-switch`,onClick:()=>o(h),children:a}),d&&di(t?.health?.status)&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm codex-auth-action-btn`,onClick:()=>d(m),children:(0,z.jsx)(`span`,{"aria-live":`polite`,children:_i(e,f?.(m))})}),t&&(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-ghost codex-auth-action-btn`,onClick:()=>s(h),disabled:l,title:t.paused?e(`codexAuth.pausedHint`):void 0,"aria-label":t.paused?`${e(`codexAuth.resume`)}. ${e(`codexAuth.pausedHint`)}`:e(`codexAuth.pause`),children:[t.paused?(0,z.jsx)(le,{width:14}):(0,z.jsx)(ce,{width:14}),(0,z.jsx)(ha,{t:e,paused:!!t.paused,saving:c===`__main__`})]}),(0,z.jsxs)(`span`,{className:`card-right`,children:[(0,z.jsx)(Se,{width:14}),` `,e(`codexAuth.appLogin`)]})]}),(0,z.jsxs)(`div`,{className:`card-sub`,children:[t?.email||e(`codexAuth.appLogin`),t?.plan?` · ${t.plan}`:``]}),y&&(0,z.jsx)(`div`,{className:`card-sub faint`,children:y}),_&&(0,z.jsx)(`div`,{className:`card-sub faint`,children:e(`pws.healthCooldownHint`)}),g?(0,z.jsx)(`div`,{className:`card-sub faint`,children:e(`codexAuth.mainTokenExpired`)}):!_&&(0,z.jsx)(Br,{quota:t?.quota??null,plan:t?.plan,threshold:i,t:e,pending:t!=null&&t.quota==null})]})}function xa({t:e,embedded:t,refreshingQuota:n,pausingExhausted:r,pauseBusy:i,actionFeedback:a,actionFeedbackTone:o,onRefresh:s,onPauseExhausted:c}){return(0,z.jsxs)(`div`,{className:t?`row`:`page-head codex-auth-page-head`,style:t?{justifyContent:`flex-end`,marginBottom:8}:void 0,children:[!t&&(0,z.jsx)(`h2`,{className:`page-title`,children:e(`nav.codexAuth`)}),(0,z.jsxs)(`div`,{className:t?`row`:`codex-auth-page-head__actions`,children:[(0,z.jsx)(`span`,{className:`codex-auth-page-head__feedback${o===`ok`?` is-ok`:``}${o===`err`?` is-err`:``}`,role:`status`,"aria-live":`polite`,children:a??``}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-ghost codex-auth-action-btn`,onClick:c,disabled:n||r||!!i,children:[(0,z.jsx)(ce,{width:14}),` `,e(r?`codexAuth.pausingExhausted`:`codexAuth.pauseExhausted`)]}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-ghost codex-auth-action-btn`,onClick:s,disabled:n||r||!!i,children:[(0,z.jsx)(se,{width:14}),` `,e(n?`codexAuth.refreshingQuota`:`codexAuth.refreshQuota`)]})]})]})}function Sa({t:e,loadState:t,accountsCount:n,onRetry:r}){return t===`loading`&&n===0?(0,z.jsxs)(`div`,{className:`codex-auth-load-skeleton`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[(0,z.jsxs)(`div`,{className:`card codex-auth-load-skeleton__main`,style:{marginBottom:12},"aria-hidden":`true`,children:[(0,z.jsxs)(`div`,{className:`card-head`,children:[(0,z.jsx)(`span`,{className:`dot dot-muted`}),(0,z.jsx)(`strong`,{children:e(`codexAuth.mainAccount`)}),(0,z.jsxs)(`span`,{className:`card-badges`,children:[(0,z.jsxs)(`span`,{className:`badge badge-muted codex-ticket-badge-slot`,"aria-hidden":`true`,children:[(0,z.jsx)(Ce,{width:12}),`0`]}),(0,z.jsx)(`span`,{className:`badge badge-primary`,children:e(`codexAuth.nextSession`)})]}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,tabIndex:-1,disabled:!0,children:[(0,z.jsx)(ce,{width:14}),` `,e(`codexAuth.pause`)]}),(0,z.jsxs)(`span`,{className:`card-right`,children:[(0,z.jsx)(Se,{width:14}),` `,e(`codexAuth.appLogin`)]})]}),(0,z.jsxs)(`div`,{className:`card-sub`,children:[(0,z.jsx)(`span`,{className:`codex-auth-load-skeleton__strut`,children:e(`codexAuth.appLogin`)}),(0,z.jsx)(`span`,{className:`codex-auth-load-skeleton__line codex-auth-load-skeleton__line--sub`})]}),(0,z.jsx)(Br,{quota:null,threshold:0,t:e,pending:!0})]}),(0,z.jsxs)(`div`,{className:`section-sep`,"aria-hidden":`true`,children:[(0,z.jsx)(`span`,{className:`section-label`,children:e(`codexAuth.accountPool`)}),(0,z.jsx)(`div`,{className:`sep-line`}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,tabIndex:-1,disabled:!0,children:[(0,z.jsx)(oe,{width:14}),` `,e(`codexAuth.add`)]})]}),(0,z.jsx)(`div`,{className:`empty codex-auth-pool-empty codex-auth-load-skeleton__empty`,"aria-hidden":`true`,children:(0,z.jsx)(`div`,{className:`title`,children:e(`codexAuth.noPool`)})}),(0,z.jsx)(`span`,{className:`sr-only`,children:e(`pws.accountsLoading`)})]}):t===`error`?(0,z.jsxs)(`div`,{className:`pwi-auth-state pwi-auth-state--error`,role:`alert`,children:[(0,z.jsx)(`span`,{children:e(`codexAuth.loadFailed`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:r,children:e(`pws.retryAccounts`)})]}):null}function Ca(e,t){return t===void 0?e(`codexAuth.resetSuccessGeneric`):e(`codexAuth.resetSuccess`,{remaining:String(t)})}async function wa(e,t,n,r){try{let i=await ut(await fetch(`${e}/api/codex-auth/reset-credits/consume`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({accountId:t})}));return i?i.code===`reset`||i.code===`already_redeemed`?(await r(!0),{ok:!0,close:!0,toast:Ca(n,typeof i.remaining==`number`&&Number.isFinite(i.remaining)?Math.max(0,i.remaining):void 0)}):{ok:!1,close:!0,toast:n(i.code===`nothing_to_reset`?`codexAuth.resetNothingToReset`:i.code===`no_credit`?`codexAuth.resetNoCredit`:`codexAuth.resetError`)}:{ok:!1,toast:n(`codexAuth.resetError`)}}catch{return{ok:!1,toast:n(`codexAuth.resetError`)}}}var Ta=`ocx doctor`;function Ea({apiBase:e,accountModeState:t=null,banner:n=null,embedded:r=!1,onActiveNeedsReauthChange:i,controller:a}){let o=K(),s=$i(e,{updated:o(`codexAuth.autoSwitchUpdated`),updateFailed:o(`codexAuth.autoSwitchUpdateFailed`),invalid:o(`codexAuth.autoSwitchThresholdInvalid`)}),[c,l]=(0,_.useState)(null),{beginServerRead:u,acceptServerRead:d,rejectServerRead:f,hydrateServerValue:p}=s,m=Ii(e,!a),h=a??m,{accounts:g,activeId:v,loadState:y,switchingId:b,pauseUpdatingId:x,pausingExhausted:S,load:C}=h,[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(null),[A,j]=(0,_.useState)(null),[M,N]=(0,_.useState)(null),P=(0,_.useRef)(null),[F,I]=(0,_.useState)(!1),[L,R]=(0,_.useState)(null),[B,V]=(0,_.useState)(!1),[H,U]=(0,_.useState)(!1),[W,ee]=(0,_.useState)(null),[te,ne]=(0,_.useState)(!1),re=Si(),G=(0,_.useCallback)((e,t=!1)=>{P.current&&clearTimeout(P.current),j(e),N(t?`err`:`ok`),P.current=setTimeout(()=>{j(null),N(null),P.current=null},5e3)},[]);(0,_.useEffect)(()=>()=>{P.current&&clearTimeout(P.current)},[]);let ie=(0,_.useCallback)(e=>{re.copy(Ta,e)},[re]),{subscribeLoadObserver:ae,readLastThreshold:se}=h;(0,_.useEffect)(()=>ae({beginActiveRead:u,acceptActiveRead:d,rejectActiveRead:f}),[ae,u,d,f]),(0,_.useEffect)(()=>{let e=se();e!==void 0&&p(e)},[se,p]),(0,_.useEffect)(()=>{if(!E)return;let e=h.pauseRefresh();return()=>h.resumeRefresh(e)},[h,E]);let ce=v&&v!==`__main__`?g.find(e=>e.id===v):null,le=!ce?.paused&&li(ce);(0,_.useEffect)(()=>{i?.(le)},[le,i]);let ue=(0,_.useCallback)(e=>{k(e),D(!0)},[]),de=(0,_.useCallback)(()=>{D(!1),k(null)},[]),fe=(0,_.useCallback)(()=>{h.syncAfterAccountAdded(),G(o(`codexAuth.accountAdded`)),de()},[de,h,G,o]),pe=async e=>{let n=await h.switchAccount(e);if(!n.ok){if(n.reason===`busy`)return;G(o(`codexAuth.switchFailed`),!0);return}T(null);let r=n.activeId,i=r&&r!==`__main__`?g.find(e=>e.id===r)?.email??o(`pws.accountOrdinal`,{count:`1`}):o(`codexAuth.mainAccount`);G(o(t===`direct`?`codexAuth.poolPreparedToast`:`codexAuth.switched`,{email:i}))},me=async e=>{let t=window.prompt(o(`prov.aliasPrompt`),e.alias??``);if(t===null)return;let n=await h.saveAlias(e.id,t);G(o(n.ok?`prov.aliasSaved`:`prov.aliasSaveFailed`),!n.ok)},he=async e=>{let t=!e.paused,n=await h.setAccountPaused(e.id,t);!n.ok&&n.reason===`busy`||(T(t=>t?.id===e.id?null:t),G(o(n.ok?t?`codexAuth.pauseSucceeded`:`codexAuth.resumeSucceeded`:t?`codexAuth.pauseFailed`:`codexAuth.resumeFailed`,{email:e.alias??e.email}),!n.ok))},ge=async e=>{let t=g.find(t=>t.id===e)?.email??o(`pws.accountOrdinal`,{count:`1`});window.confirm(o(`codexAuth.removeConfirm`,{id:t}))&&((await h.removeAccount(e)).ok||G(o(`codexAuth.removeFailed`),!0))},_e=async()=>{I(!0);try{let e=await C(!0);G(o(e?`codexAuth.quotaRefreshed`:`codexAuth.quotaRefreshFailed`),!e)}finally{I(!1)}},ve=async()=>{let e=await h.pauseExhaustedAccounts();!e.ok&&e.reason===`busy`||G(e.ok?e.pausedCount>0?o(`codexAuth.pauseExhaustedSucceeded`,{count:String(e.pausedCount)}):o(`codexAuth.pauseExhaustedNone`):o(`codexAuth.pauseExhaustedFailed`),!e.ok)},ye=async t=>{R(t),V(!1),ee(null),ne(!0);try{let n=await ut(await fetch(`${e}/api/codex-auth/reset-credits?accountId=${encodeURIComponent(t.id)}`));n&&ee((n.credits??[]).sort((e,t)=>new Date(e.granted_at).getTime()-new Date(t.granted_at).getTime()))}catch{}finally{ne(!1)}},be=async t=>{U(!0);try{let n=await wa(e,t,o,C);n.close&&(R(null),V(!1)),n.toast&&G(n.toast,!n.ok)}finally{U(!1)}},xe=g.find(e=>e.isMain),Se=g.filter(e=>!e.isMain),Ce=!xe?.paused&&(!v||v===`__main__`),we=o(t===`direct`?`codexAuth.prepareForPool`:`codexAuth.setAsNext`),Te=x!==null||S,Ee=s.threshold??0;return(0,z.jsxs)(`div`,{children:[(0,z.jsx)(xa,{t:o,embedded:r,refreshingQuota:F,actionFeedback:A,actionFeedbackTone:M,pausingExhausted:S,pauseBusy:Te,onRefresh:()=>{_e()},onPauseExhausted:()=>{ve()}}),n,(0,z.jsx)(Sa,{t:o,loadState:y,accountsCount:g.length,onRetry:()=>{C()}}),!(y===`loading`&&g.length===0)&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ba,{t:o,main:xe,isMainActive:Ce,accountModeState:t,threshold:Ee,switchActionLabel:we,onSwitch:T,onTogglePause:he,pauseUpdatingId:x,pauseBusy:Te,onOpenReset:ye,onCopyDoctor:ie,doctorCopyOutcomeFor:re.outcomeFor}),(0,z.jsxs)(`div`,{className:`section-sep`,children:[(0,z.jsx)(`span`,{className:`section-label`,children:o(`codexAuth.accountPool`)}),(0,z.jsx)(`div`,{className:`sep-line`}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,onClick:()=>D(!0),children:[(0,z.jsx)(oe,{width:14}),` `,o(`codexAuth.add`)]})]}),le&&ce&&(0,z.jsx)(_a,{onReauth:()=>ue(ce.id)}),Se.length===0&&(0,z.jsx)(ot,{title:o(`codexAuth.noPool`)}),(0,z.jsx)(ga,{pool:Se,activeId:v,accountModeState:t,switchActionLabel:we,threshold:Ee,onOpenReset:ye,onSwitch:T,onTogglePause:he,pauseUpdatingId:x,pauseBusy:Te,onReauth:ue,onEditAlias:me,onRemove:ge,onCopyDoctor:ie,doctorCopyOutcomeFor:re.outcomeFor})]}),c!==null&&(0,z.jsx)(Bi,{threshold:s.threshold,draft:s.draft,strategy:c,hydrated:s.hydrated,saving:s.saving,loadError:s.loadError,feedback:s.feedback,onDraftChange:s.setDraft,onEditingChange:s.setEditing,onCommit:s.commit,onCancel:s.cancel,onToggle:s.toggle,onRetry:()=>{s.retry(),C()}}),(0,z.jsx)(Qi,{apiBase:e,subscribeLoadObserver:h.subscribeLoadObserver,readLastActive:h.readLastActive,onStrategyResolved:l}),w&&(0,z.jsx)(va,{confirm:w,mainEmail:xe?.email,accountModeState:t,switchingId:b,onCancel:()=>T(null),onConfirm:()=>{pe(w.id===`__main__`?`__main__`:w.id)}}),L&&(0,z.jsx)(ya,{resetPopup:L,resetConfirm:B,creditDetails:W,creditDetailsLoading:te,redeeming:H,onClose:()=>{R(null),V(!1),ee(null)},onShowConfirm:()=>V(!0),onCancelConfirm:()=>V(!1),onRedeem:()=>{be(L.id)}}),E&&(0,z.jsx)(Ti,{apiBase:e,reauthAccountId:O??void 0,onClose:de,onAdded:fe})]})}function Da({apiBase:e,accountCount:t}){let n=K(),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(`80`),[s,c]=(0,_.useState)(`1`),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let t=!1,n=new AbortController;return Promise.resolve().then(()=>fetch(`${e}/api/oauth/accounts/pool?provider=anthropic`,{signal:n.signal})).then(e=>{if(!e.ok)throw Error(`load`);return e.json()}).then(e=>{if(t)return;let n=typeof e.autoSwitchThreshold==`number`?e.autoSwitchThreshold:80,r=Gi(e.stickyLimit);i({enabled:e.enabled===!0,threshold:n,strategy:Wi(e.strategy),stickyLimit:r}),o(String(n)),c(String(r)),m(!1)}).catch(()=>{t||n.signal.aborted||m(!0)}),()=>{t=!0,n.abort()}},[e]);let h=(0,_.useCallback)(async t=>{let a=r;i({enabled:t.enabled,threshold:t.threshold,strategy:t.strategy,stickyLimit:t.stickyLimit}),u(!0),f(null);try{let n=await fetch(`${e}/api/oauth/accounts/pool`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({provider:`anthropic`,enabled:t.enabled,autoSwitchThreshold:t.threshold,strategy:t.strategy,stickyLimit:t.stickyLimit})});if(!n.ok)throw Error(`save`);let r=await n.json().catch(()=>null),a=Wi(r?.strategy??t.strategy),s=Gi(r?.stickyLimit??t.stickyLimit);i({enabled:t.enabled,threshold:t.threshold,strategy:a,stickyLimit:s}),o(String(t.threshold)),c(String(s))}catch{f(n(`anthropicPool.saveFailed`)),a&&(i(a),o(String(a.threshold)),c(String(a.stickyLimit)))}finally{u(!1)}},[e,r,n]),g=r?.enabled===!0,v=r?.threshold??80,y=r?.strategy??`quota`,b=r?.stickyLimit??1,x=r===null&&!p,S=x||l||p||!g&&t<2;return(0,z.jsxs)(`div`,{className:`card`,style:{marginTop:12},"aria-busy":x||l,children:[(0,z.jsxs)(`div`,{className:`card-row`,style:{alignItems:`flex-start`,gap:12},children:[(0,z.jsxs)(`div`,{style:{flex:1},children:[(0,z.jsx)(`strong`,{children:n(`anthropicPool.title`)}),(0,z.jsx)(`div`,{className:`card-sub`,style:{marginTop:4},children:p?n(`anthropicPool.loadFailed`):x?n(`common.loading`):g?n(`anthropicPool.enabledDesc`,{threshold:v}):n(`anthropicPool.disabledDesc`)})]}),(0,z.jsxs)(`label`,{className:`toggle`,style:{display:`inline-flex`,alignItems:`center`,gap:8},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:g,disabled:S,onChange:e=>{let t=e.target.checked;h({enabled:t,threshold:v,strategy:y,stickyLimit:b})}}),(0,z.jsx)(`span`,{children:n(g?`anthropicPool.on`:`anthropicPool.off`)})]})]}),(0,z.jsx)(`div`,{role:`alert`,className:`card-sub`,style:{marginTop:10,padding:`8px 10px`,border:`1px solid var(--border, #c9a227)`,borderRadius:6,background:`color-mix(in srgb, var(--warn, #c9a227) 12%, transparent)`},children:n(`anthropicPool.experimentalWarning`)}),t<2&&(0,z.jsx)(`div`,{className:`card-sub`,style:{marginTop:8},children:n(`anthropicPool.needTwoAccounts`)}),g&&r&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`label`,{className:`field`,style:{display:`block`,marginTop:12},children:[(0,z.jsx)(`span`,{className:`field-label`,children:n(`anthropicPool.threshold`)}),(0,z.jsx)(`input`,{className:`input mono`,type:`number`,min:0,max:100,step:1,value:a,disabled:l,"aria-label":n(`anthropicPool.thresholdAria`),onChange:e=>o(e.target.value),onBlur:()=>{let e=Number(a);if(!Number.isInteger(e)||e<0||e>100){o(String(v)),f(n(`anthropicPool.thresholdInvalid`));return}e!==v&&h({enabled:!0,threshold:e,strategy:y,stickyLimit:b})}}),(0,z.jsx)(`div`,{className:`card-sub`,style:{marginTop:4},children:n(`anthropicPool.thresholdHelp`)})]}),(0,z.jsx)(Xi,{strategy:y,stickyDraft:s,disabled:l,strategySelectId:`anthropic-pool-strategy`,stickyInputId:`anthropic-pool-sticky-limit`,onStrategyChange:e=>{e!==y&&h({enabled:!0,threshold:v,strategy:e,stickyLimit:b})},onStickyDraftChange:c,onStickyCommit:e=>{let t=Ki(e??s);if(t===null){c(String(b)),f(n(`accountPool.stickyLimitInvalid`));return}if(t===b){c(String(t));return}h({enabled:!0,threshold:v,strategy:y,stickyLimit:t})}})]}),d&&(0,z.jsx)(`div`,{role:`alert`,className:`card-sub`,style:{marginTop:8,color:`var(--danger, #c44)`},children:d})]})}var Oa=`ocx doctor`,ka=4e3,Aa=[],ja=[];function Ma({item:e,apiBase:t,oauth:n,accounts:r=Aa,keys:i=ja,accountLoadState:a=`ready`,switchingAccountId:o=null,busy:s=!1,loginHint:c,authHandlers:l,onCodexActiveNeedsReauthChange:u,codexController:d}){let f=K(),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!1),S=Si(),C=Si();(0,_.useEffect)(()=>{if(r.length===0){x(!1);return}if(!r.some(e=>e.quota==null&&!e.quotaUnavailable)){x(!1);return}x(!0);let e=window.setTimeout(()=>x(!1),ka);return()=>window.clearTimeout(e)},[r]);let w=Qr({...e,hasApiKey:e.hasApiKey||i.length>0}),T=w===`oauth-accounts`,E=w===`api-keys`;if(w===`codex-accounts`)return(0,z.jsxs)(`section`,{className:`pwi-section pwi-auth-section`,"aria-label":f(`pws.availableAccounts`),children:[(0,z.jsx)(`h3`,{className:`pwi-section-title`,children:f(`pws.availableAccounts`)}),(0,z.jsx)(`div`,{className:`pwi-auth-body`,children:(0,z.jsx)(Ea,{apiBase:t,embedded:!0,controller:d,onActiveNeedsReauthChange:u})})]});if(!w||!l)return null;let D=c?.provider===e.name?c:null,O=D?.deviceCode??``,k=S.outcomeFor(O),A=f(k===`copied`?`prov.codeCopied`:k===`unavailable`?`prov.linkCopyUnavailable`:`prov.copyCode`),j=r.length>0||n?.loggedIn===!0,M=r.find(e=>e.active&&e.needsReauth),N=!!M,P=async()=>{let t=h.trim();if(t){y(!0);try{await l.onAddApiKey(e.name,t)&&(g(``),m(!1))}finally{y(!1)}}};return(0,z.jsxs)(`section`,{className:`pwi-section pwi-auth-section`,"aria-label":f(T?`pws.availableAccounts`:`pws.apiKeys`),children:[(0,z.jsx)(`h3`,{className:`pwi-section-title`,children:f(T?`pws.availableAccounts`:`pws.apiKeys`)}),(0,z.jsxs)(`div`,{className:`pwi-auth-body`,children:[T&&(0,z.jsxs)(z.Fragment,{children:[e.name===`anthropic`&&(0,z.jsx)(Da,{apiBase:t,accountCount:r.length}),(0,z.jsxs)(`div`,{className:`pwi-auth-status-row`,children:[(0,z.jsx)(`span`,{className:`pwi-auth-dot ${N?`pwi-auth-dot--warn`:j?`pwi-auth-dot--ok`:`pwi-auth-dot--off`}`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`pwi-auth-status-text`,children:j?r.length>0?f(`pws.loggedInTitle`):n?.email??f(`pws.loggedInTitle`):n?.error||f(`pws.notLoggedInTitle`)}),(0,z.jsxs)(`span`,{className:`pwi-auth-actions`,children:[M&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:s,onClick:()=>void l.onReauth(e.name,M.id),children:f(`pws.reauthenticate`)}),j?(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void l.onLogout(e.name),children:f(`prov.logout`)}):(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:s,onClick:()=>void l.onLogin(e.name,!1),children:[s?(0,z.jsx)(`span`,{className:`pwi-spin-inline`,"aria-hidden":`true`}):(0,z.jsx)(Se,{style:{width:13,height:13},"aria-hidden":`true`}),f(s?`prov.waitingBrowser`:`prov.login`)]})]})]}),s&&D&&(0,z.jsxs)(`div`,{className:`pwi-auth-wait`,children:[(0,z.jsx)(`span`,{className:`pwi-spin-inline`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{className:`pwi-auth-wait-copy`,children:[(0,z.jsx)(`div`,{className:`pwi-auth-wait-title`,children:f(`prov.waitingBrowser`)}),D.deviceCode&&(0,z.jsxs)(`div`,{className:`pwi-device-code-wrap`,children:[(0,z.jsx)(`span`,{children:f(`prov.deviceCode`)}),(0,z.jsx)(`code`,{className:`pwi-device-code`,children:D.deviceCode}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>S.copy(O,O),children:(0,z.jsx)(`span`,{"aria-live":`polite`,children:A})})]}),(0,z.jsx)(Z,{url:D.url??``}),l.onCancelLogin&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void l.onCancelLogin?.(e.name),children:f(`common.cancel`)})]})]}),a===`loading`&&r.length===0&&(0,z.jsxs)(`div`,{className:`pwi-auth-state`,role:`status`,children:[(0,z.jsx)(`span`,{className:`pwi-spin-inline`,"aria-hidden":`true`}),f(`pws.accountsLoading`)]}),a===`error`&&(0,z.jsxs)(`div`,{className:`pwi-auth-state pwi-auth-state--error`,role:`alert`,children:[(0,z.jsx)(`span`,{children:f(`pws.accountsLoadFailed`)}),l.onRetryAccounts&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void l.onRetryAccounts?.(e.name),children:f(`pws.retryAccounts`)})]}),r.length>0&&(0,z.jsx)(`ul`,{className:`pwi-auth-list`,children:r.map(t=>{let n=$r(r,t,f),i=o===t.id,a=t.health?.status,c=!!t.needsReauth||ci(a),u=di(a),d=ui(a),p=ai(t.id),m=pi(f,t.health),h=mi(f,e.name,t.id,t.health);return(0,z.jsxs)(`li`,{className:`pwi-auth-acct${t.active?` pwi-auth-acct--active`:``}`,children:[(0,z.jsxs)(`div`,{className:`pwi-auth-row${t.active?` pwi-auth-row--active`:``}`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`pwi-auth-row-main`,onClick:()=>{!t.active&&!c&&!d&&!o&&l.onSwitchAccount(e.name,t)},"aria-current":t.active?`true`:void 0,"aria-label":`${n}${t.active?` — ${f(`pws.accountCurrent`)}`:``}`,disabled:!!(c||d||o&&!i),children:[(0,z.jsx)(`span`,{className:`pwi-auth-dot ${c?`pwi-auth-dot--warn`:t.active?`pwi-auth-dot--ok`:`pwi-auth-dot--off`}`,"aria-hidden":`true`}),(0,z.jsxs)(`span`,{className:`pwi-auth-row-copy`,children:[(0,z.jsx)(`span`,{className:`pwi-auth-row-label`,children:n}),(0,z.jsx)(`span`,{className:`pwi-auth-row-secondary`,children:[t.email,`${f(`prov.accountId`)}: ${p}`].filter(Boolean).join(` · `)}),h&&(0,z.jsx)(`span`,{className:`pwi-auth-row-secondary faint`,children:h}),d&&(0,z.jsx)(`span`,{className:`pwi-auth-row-secondary faint`,children:f(`pws.healthCooldownHint`)})]}),m&&(0,z.jsx)(`span`,{className:si(a),children:m}),c&&!m&&(0,z.jsx)(`span`,{className:`badge badge-amber`,children:f(`pws.reauth`)}),t.active&&(0,z.jsx)(`span`,{className:`badge badge-primary`,children:f(`prov.accountActive`)}),i&&(0,z.jsx)(`span`,{className:`badge badge-muted`,children:f(`pws.accountSwitching`)})]}),c&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:s||!!o,onClick:()=>void l.onReauth(e.name,t.id),children:f(`pws.reauthenticate`)}),u&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm codex-auth-action-btn`,onClick:()=>{C.copy(Oa,t.id)},children:(0,z.jsx)(`span`,{"aria-live":`polite`,children:_i(f,C.outcomeFor(t.id))})}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void l.onEditAlias(e.name,`oauth`,t.id,t.alias),children:f(`prov.editAlias`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm pwi-auth-row-remove`,"aria-label":`${f(`common.remove`)} — ${n}`,title:`${f(`common.remove`)} — ${n}`,disabled:!!o,onClick:()=>void l.onRemoveAccount(e.name,t),children:(0,z.jsx)(ue,{style:{width:13,height:13},"aria-hidden":`true`})})]}),(t.quota!=null||t.quotaUnavailable||b&&t.quota==null)&&(0,z.jsx)(`div`,{className:`pwi-auth-acct-quota`,children:t.quotaUnavailable?(0,z.jsx)(`p`,{className:`muted pwi-auth-acct-quota-stale`,children:f(`pws.accountQuotaUnavailable`)}):(0,z.jsx)(Br,{quota:t.quota??null,plan:null,threshold:80,t:f,layout:`stacked`,pending:t.quota==null})})]},t.id)})}),a===`ready`&&j&&r.length===0&&(0,z.jsx)(`div`,{className:`pwi-auth-state pwi-auth-state--empty`,children:f(`pws.noAccounts`)}),j&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{marginTop:8},onClick:()=>void l.onLogin(e.name,!0),disabled:s||!!o,children:f(`pws.addAccount`)})]}),E&&(0,z.jsxs)(z.Fragment,{children:[i.length>0&&(0,z.jsx)(`ul`,{className:`pwi-auth-list`,children:i.map(t=>(0,z.jsxs)(`li`,{className:`pwi-auth-row${t.active?` pwi-auth-row--active`:``}`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`pwi-auth-row-main`,onClick:()=>void l.onSwitchApiKey(e.name,t),disabled:t.active,children:[(0,z.jsx)(`span`,{className:`pwi-auth-dot ${t.active?`pwi-auth-dot--ok`:`pwi-auth-dot--off`}`,"aria-hidden":`true`}),(0,z.jsxs)(`span`,{className:`pwi-auth-row-copy`,children:[(0,z.jsx)(`span`,{className:`pwi-auth-row-label`,children:t.label??t.masked}),t.label&&(0,z.jsxs)(`code`,{className:`pwi-auth-row-secondary`,children:[t.masked,` · `,f(`prov.accountId`),`: `,t.id]})]}),t.active&&(0,z.jsx)(`span`,{className:`badge badge-primary`,children:f(`prov.accountActive`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void l.onEditAlias(e.name,`api-key`,t.id,t.label),children:f(`prov.editAlias`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm pwi-auth-row-remove`,"aria-label":`${f(`common.remove`)} — ${t.label??t.masked}`,title:`${f(`common.remove`)} — ${t.label??t.masked}`,onClick:()=>void l.onRemoveApiKey(e.name,t),children:(0,z.jsx)(ue,{style:{width:13,height:13},"aria-hidden":`true`})})]},t.id))}),p?(0,z.jsxs)(`div`,{className:`pwi-auth-add-key`,children:[(0,z.jsx)(`input`,{className:`input`,type:`password`,value:h,onChange:e=>g(e.target.value),placeholder:f(`modal.apiKeyPlaceholder`),autoComplete:`off`,disabled:v}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>void P(),disabled:v||!h.trim(),children:f(v?`pws.saving`:`pws.addKey`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>{m(!1),g(``)},children:f(`common.cancel`)})]}):(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{marginTop:8},onClick:()=>m(!0),children:f(`pws.addKey`)})]})]})]})}function Na(e,t,n){let r=e?.find(e=>e.id===t);if(!r)return n;if(r.baseUrl)return r.baseUrl;let i=new Set((e??[]).map(e=>e.baseUrl?.trim().replace(/\/+$/,``)).filter(e=>!!e)),a=n.trim().replace(/\/+$/,``);return i.has(a)?``:n}function Pa(e,t){if(!e?.length)return`custom`;let n=t.trim().replace(/\/+$/,``);for(let t of e)if(t.baseUrl&&t.baseUrl.trim().replace(/\/+$/,``)===n)return t.id;return e.some(e=>e.id===`custom`)?`custom`:e[0].id}function Fa(e,t,n){let r=e?.find(e=>e.id===t);return r?.baseUrl?r.baseUrl.trim():n.trim()}var Ia=[`openai-responses`,`openai-chat`,`anthropic`,`google`,`azure-openai`,`cursor`],La=[];function Ra({item:e,availableModels:t=La,apiBase:n,onUpdateProvider:r,onDirtyChange:i,onRegisterSave:a}){let o=K(),s=String(e.authMode??(e.keyOptional?`local`:`key`)),[c,l]=(0,_.useState)(e.adapter),[u,d]=(0,_.useState)(e.baseUrl),[f,p]=(0,_.useState)(e.defaultModel??``),[m,h]=(0,_.useState)(s),[g,v]=(0,_.useState)(e.apiKeyTransport??`x-api-key`),[y,b]=(0,_.useState)(e.note??``),[x,S]=(0,_.useState)(e.allowPrivateNetwork??!1),[C,w]=(0,_.useState)(e.liveModels!==!1),[T,E]=(0,_.useState)(!1),[D,O]=(0,_.useState)(null),[k,A]=(0,_.useState)(),[j,M]=(0,_.useState)(n?`loading`:`idle`),[N,P]=(0,_.useState)(()=>`custom`);(0,_.useEffect)(()=>{l(e.adapter),d(e.baseUrl),p(e.defaultModel??``),h(String(e.authMode??(e.keyOptional?`local`:`key`))),v(e.apiKeyTransport??`x-api-key`),b(e.note??``),S(e.allowPrivateNetwork??!1),w(e.liveModels!==!1),O(null),queueMicrotask(()=>P(Pa(k,e.baseUrl)))},[e.adapter,e.baseUrl,e.defaultModel,e.authMode,e.apiKeyTransport,e.keyOptional,e.note,e.allowPrivateNetwork,e.liveModels,k]),(0,_.useEffect)(()=>{if(!n)return;let t=!1,r=e.name,i=e.baseUrl;return fetch(`${n}/api/provider-presets`).then(e=>ut(e)).then(e=>{if(t)return;if(!e){A(void 0),M(`error`);return}let n=(e.providers??[]).find(e=>e.id===r)?.baseUrlChoices;A(n),M(`ready`),P(Pa(n,i))}).catch(()=>{t||(A(void 0),M(`error`))}),()=>{t=!0}},[n,e.name]);let F=c.trim()!==e.adapter||u.trim()!==e.baseUrl||f.trim()!==(e.defaultModel??``)||m!==String(e.authMode??(e.keyOptional?`local`:`key`))||c.trim()===`anthropic`&&m===`key`&&g!==(e.apiKeyTransport??`x-api-key`)||y.trim()!==(e.note??``)||x!==(e.allowPrivateNetwork??!1)||C!==(e.liveModels!==!1);(0,_.useEffect)(()=>(i?.(F),()=>i?.(!1)),[F,i]);let I=(0,_.useMemo)(()=>{let n=new Set(t);return f.trim()&&n.add(f.trim()),e.defaultModel&&n.add(e.defaultModel),[...n].sort((e,t)=>e.localeCompare(t))},[t,f,e.defaultModel]),L=(0,_.useMemo)(()=>{let e=[...Ia];return c&&!e.includes(c)&&e.unshift(c),e},[c]),R=yr(e.name),B=j===`ready`&&!!(k&&k.length>0),V=c.trim()===`anthropic`&&m===`key`,H=R&&j!==`error`,U=async()=>{if(!r)return O({ok:!1,text:o(`pws.updatesUnavailable`)}),!1;let t=B?Fa(k,N,u):u.trim();if(!c.trim()||!t)return O({ok:!1,text:o(`pws.adapterBaseRequired`)}),!1;E(!0),O(null);try{let n={adapter:c.trim(),baseUrl:t,defaultModel:f.trim(),authMode:m,note:y.trim(),allowPrivateNetwork:x};C!==(e.liveModels!==!1)&&(n.liveModels=C),V?n.apiKeyTransport=g:e.apiKeyTransport!==void 0&&(n.apiKeyTransport=``);let i=await r(e.name,n);return O(i.ok?{ok:!0,text:o(`pws.settingsSaved`)}:{ok:!1,text:i.error||o(`prov.saveFailed`)}),i.ok}finally{E(!1)}},W=(0,_.useRef)(U);(0,_.useEffect)(()=>{W.current=U}),(0,_.useEffect)(()=>{if(a)return a(()=>W.current()),()=>a(null)},[a]);let ee=()=>{l(e.adapter),d(e.baseUrl),p(e.defaultModel??``),h(s),v(e.apiKeyTransport??`x-api-key`),b(e.note??``),S(e.allowPrivateNetwork??!1),w(e.liveModels!==!1),O(null),P(Pa(k,e.baseUrl))},te=(e,t)=>{switch(e){case`token-plan`:return o(`modal.endpoint.tokenPlan`);case`payg`:return o(`modal.endpoint.payAsYouGo`);case`custom`:return o(`modal.endpoint.custom`);default:return t}};return(0,z.jsxs)(`div`,{className:`pwi-settings-form`,children:[(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsxs)(`span`,{className:`pwi-settings-label`,children:[(0,z.jsx)(Se,{style:{width:12,height:12}}),` `,o(`pws.providerId`)]}),(0,z.jsx)(`input`,{className:`input`,value:e.name,readOnly:!0,disabled:!0})]}),(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`modal.adapter`)}),R?(0,z.jsx)(`input`,{className:`input`,value:c,readOnly:!0,disabled:!0}):(0,z.jsx)(`select`,{className:`input`,value:c,onChange:e=>l(e.target.value),children:L.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}),B?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`modal.endpoint`)}),(0,z.jsx)(`select`,{className:`input`,value:N,onChange:e=>{let t=e.target.value;P(t),d(Na(k,t,u))},children:k.map(e=>(0,z.jsx)(`option`,{value:e.id,children:te(e.id,e.label)},e.id))})]}),N===`custom`&&(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`modal.baseUrl`)}),(0,z.jsx)(`input`,{className:`input`,value:u,onChange:e=>d(e.target.value),placeholder:o(`modal.baseUrlPlaceholder`)})]})]}):(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`modal.baseUrl`)}),(0,z.jsx)(`input`,{className:`input`,value:u,onChange:e=>d(e.target.value),readOnly:H,disabled:H})]}),(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`pws.cell.defaultModel`)}),I.length>0?(0,z.jsxs)(`select`,{className:`input`,value:f,onChange:e=>p(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:o(`pws.defaultModelNone`)}),I.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}):(0,z.jsx)(`input`,{className:`input`,value:f,onChange:e=>p(e.target.value),placeholder:o(`pws.optionalPlaceholder`)})]}),(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`pws.authMode`)}),R?(0,z.jsx)(`input`,{className:`input`,value:xr(e,o),readOnly:!0,disabled:!0}):(0,z.jsxs)(`select`,{className:`input`,value:m,onChange:e=>h(e.target.value),children:[(0,z.jsx)(`option`,{value:`key`,children:o(`modal.badge.apiKey`)}),(0,z.jsx)(`option`,{value:`forward`,children:o(`pws.auth.chatgptPassthrough`)}),(0,z.jsx)(`option`,{value:`oauth`,children:o(`modal.badge.oauth`)}),(0,z.jsx)(`option`,{value:`local`,children:o(`modal.badge.local`)})]})]}),V&&(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`modal.apiKeyTransport`)}),(0,z.jsxs)(`select`,{className:`input`,value:g,onChange:e=>v(e.target.value),children:[(0,z.jsx)(`option`,{value:`x-api-key`,children:o(`modal.apiKeyTransportNative`)}),(0,z.jsx)(`option`,{value:`bearer`,children:o(`modal.apiKeyTransportBearer`)})]})]}),(0,z.jsxs)(`label`,{className:`pwi-settings-field`,children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`pws.note`)}),(0,z.jsx)(`textarea`,{className:`input pwi-settings-textarea`,value:y,onChange:e=>b(e.target.value),rows:2})]}),(0,z.jsxs)(`label`,{className:`pwi-settings-field`,style:{flexDirection:`row`,alignItems:`center`,gap:8},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`pws.allowPrivateNetwork`)})]}),(0,z.jsxs)(`label`,{className:`pwi-settings-field`,style:{flexDirection:`row`,alignItems:`flex-start`,gap:8},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>w(e.target.checked)}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`pwi-settings-label`,children:o(`pws.liveModels`)}),(0,z.jsx)(`span`,{className:`muted text-label`,style:{display:`block`,marginTop:2},children:o(`pws.liveModelsDesc`)})]})]}),F&&(0,z.jsxs)(`div`,{className:`pwi-settings-sticky-bar`,children:[(0,z.jsx)(`span`,{className:`muted`,children:o(`pws.settingsUnsavedBar`)}),(0,z.jsxs)(`div`,{className:`pwi-settings-sticky-bar-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:ee,disabled:T,children:o(`pws.discardSettings`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>void U(),disabled:T,children:o(T?`pws.saving`:`pws.saveSettings`)})]})]}),D&&(0,z.jsx)(`div`,{className:D.ok?`pwi-settings-msg pwi-settings-msg--ok`:`pwi-settings-msg pwi-settings-msg--err`,children:D.text})]})}function za({providerName:e,defaultProviderName:t,onConfirm:n,onCancel:r}){let i=K();return(0,z.jsx)(`div`,{className:`dialog-backdrop`,onClick:r,children:(0,z.jsxs)(`div`,{className:`dialog`,role:`alertdialog`,"aria-label":i(`pws.removeConfirmTitle`),onClick:e=>e.stopPropagation(),children:[(0,z.jsx)(`h3`,{children:i(`pws.removeConfirmTitle`)}),(0,z.jsx)(`p`,{children:t?i(`pws.removeDefaultConfirmBody`,{name:e,defaultProvider:t}):i(`pws.removeConfirmBody`,{name:e})}),(0,z.jsxs)(`div`,{className:`dialog-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:r,children:i(`common.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-danger`,onClick:n,children:i(`pws.removeConfirm`)})]})]})})}function Ba({onSave:e,onDiscard:t,onCancel:n,saving:r=!1}){let i=K();return(0,z.jsx)(`div`,{className:`dialog-backdrop`,onClick:n,children:(0,z.jsxs)(`div`,{className:`dialog`,role:`alertdialog`,"aria-label":i(`pws.unsavedLeaveTitle`),onClick:e=>e.stopPropagation(),children:[(0,z.jsx)(`h3`,{children:i(`pws.unsavedLeaveTitle`)}),(0,z.jsx)(`p`,{children:i(`pws.unsavedLeaveBody`)}),(0,z.jsxs)(`div`,{className:`dialog-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:n,children:i(`common.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:t,children:i(`pws.discardSettings`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:e,disabled:r,children:i(r?`pws.saving`:`pws.saveSettings`)})]})]})})}function Va({item:e,usageTotals:t,modelUsage:n,quotaReport:r,availableModels:i,hasLiveModels:a,selectedModels:o,modelsLoading:s,modelsLoadFailed:c,onRetryModels:l,oauthEmail:u,onDeselect:d,apiBase:f,oauth:p,accounts:m,accountLoadState:h,switchingAccountId:g,keys:v,busyProvider:y,loginHint:b,authHandlers:x,onCodexActiveNeedsReauthChange:S,codexController:C,onUpdateProvider:w,isDefault:T,onRemoveProvider:E,onSetDisabled:D,onSetDefault:O}){let k=K(),[A,j]=(0,_.useState)(`overview`),[M,N]=(0,_.useState)(!1),[P,F]=(0,_.useState)(null),[I,L]=(0,_.useState)(!1),R=(0,_.useRef)(null),B=(0,_.useCallback)(e=>{R.current=e},[]),V=e.disabled===!0,H=(0,_.useMemo)(()=>Un(e),[e]),U=(0,_.useMemo)(()=>Xn(e),[e]),W=(0,_.useMemo)(()=>Qr(e),[e]),ee=JSON.stringify([C?.activeId??``,m?.find(e=>e.active)?.id??``,v?.find(e=>e.active)?.id??``,p?.loggedIn===void 0?``:String(p.loggedIn),p?.needsReauth===void 0?``:String(p.needsReauth),u??``]),te=(0,_.useMemo)(()=>[{id:`overview`,label:k(`pws.tab.overview`)},{id:`models`,label:k(`pws.tab.models`)},{id:`usage`,label:k(`pws.tab.usage`)},...W?[{id:`accounts`,label:k(W===`api-keys`?`pws.apiKeys`:`pws.tab.accounts`)}]:[],{id:`settings`,label:k(`pws.tab.settings`)}],[W,k]),ne=(0,_.useCallback)(e=>{if(M&&A===`settings`&&e!==`settings`){F(e);return}j(e)},[A,M]),re=(0,_.useCallback)(()=>{if(M&&A===`settings`){F(`deselect`);return}d()},[M,A,d]),G=(0,_.useCallback)((e,t)=>{let n;if(e.key===`ArrowRight`)n=(t+1)%te.length;else if(e.key===`ArrowLeft`)n=(t-1+te.length)%te.length;else if(e.key===`Home`)n=0;else if(e.key===`End`)n=te.length-1;else return;e.preventDefault(),ne(te[n].id),e.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`)[n]?.focus()},[ne,te]),ie=`pws-tab-${A}`,ae=`pws-panel-${A}`;return(0,z.jsxs)(`div`,{className:`pws-detail`,children:[(0,z.jsx)(`div`,{className:`pws-detail-head`,children:(0,z.jsxs)(`button`,{type:`button`,className:`pws-detail-back-link`,onClick:re,children:[(0,z.jsx)(_e,{className:`pws-detail-back-chevron`,"aria-hidden":`true`}),k(`pws.allProviders`)]})}),(0,z.jsxs)(`div`,{className:`pws-detail-head-main`,children:[(0,z.jsx)(Cr,{name:e.name,adapter:e.adapter,baseUrl:e.baseUrl,cls:`pws-detail-icon`}),(0,z.jsx)(`div`,{className:`pws-detail-title-wrap`,children:(0,z.jsxs)(`h2`,{className:`pws-detail-title`,children:[vr(e.name,k),U&&(0,z.jsx)(`span`,{className:`pwi-rail-badge pwi-rail-badge--local`,children:k(`modal.badge.local`)}),!U&&H&&(0,z.jsx)(`span`,{className:`pwi-rail-badge pwi-rail-badge--free`,children:k(`modal.badge.free`)})]})}),(0,z.jsxs)(`div`,{className:`pws-detail-actions`,children:[!T&&!V&&O&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>O(e.name),children:k(`prov.setDefault`)}),E&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm btn-icon-only`,onClick:()=>E(e.name),"aria-label":k(`pws.removeConfirmTitle`),title:k(`pws.removeConfirmTitle`),children:(0,z.jsx)(ue,{style:{width:15,height:15},"aria-hidden":`true`})}),D&&(0,z.jsxs)(`div`,{className:`pws-detail-toggle`,children:[(0,z.jsx)(`span`,{className:`pws-detail-toggle-label`,children:k(`pws.enabledLabel`)}),(0,z.jsx)(it,{on:!V,onClick:()=>D(e.name,!V),disabled:T,label:k(`pws.enabledLabel`)})]})]})]}),(0,z.jsx)(`div`,{className:`pws-detail-tabs`,role:`tablist`,children:te.map((e,t)=>(0,z.jsx)(`button`,{type:`button`,role:`tab`,id:`pws-tab-${e.id}`,"aria-controls":`pws-panel-${e.id}`,"aria-selected":A===e.id,tabIndex:A===e.id?0:-1,className:`pws-detail-tab${A===e.id?` pws-detail-tab--active`:``}`,onClick:()=>ne(e.id),onKeyDown:e=>G(e,t),children:e.label},e.id))}),(0,z.jsxs)(`div`,{className:`pws-detail-panel`,role:`tabpanel`,id:ae,"aria-labelledby":ie,tabIndex:0,children:[A===`overview`&&(0,z.jsx)(ei,{accountPanel:W?(0,z.jsx)(Ma,{item:e,apiBase:f,oauth:p,accounts:m,keys:v,accountLoadState:h,switchingAccountId:g,busy:y===e.name,loginHint:b,authHandlers:x,onCodexActiveNeedsReauthChange:S,codexController:C}):void 0,item:e,apiBase:f,connectionIdentity:ee,usageTotals:t,quotaReport:r,oauthEmail:u,onEditSettings:()=>ne(`settings`),onViewUsage:()=>ne(`usage`),onUpdateProvider:w,reauthBusy:y===e.name,onCancelLogin:x?.onCancelLogin?()=>void x.onCancelLogin?.(e.name):void 0,onReauthenticate:e.activeNeedsReauth?()=>{if(e.authMode===`oauth`){let t=m??[],n=t.find(e=>e.active&&e.needsReauth)??t.find(e=>e.needsReauth);x?.onReauth(e.name,n?.id);return}ne(`accounts`)}:void 0}),A===`models`&&(0,z.jsx)(ni,{item:e,apiBase:f,availableModels:i,hasLiveModels:a,selectedModels:o,modelsLoading:s,modelsLoadFailed:c,needsReauth:(m??[]).some(e=>e.active&&e.needsReauth)||p?.needsReauth===!0,onRetryModels:l,onOpenAccounts:W?()=>ne(`accounts`):void 0},e.name),A===`usage`&&(0,z.jsx)(ri,{item:e,usageTotals:t,quotaReport:r,modelUsage:n}),A===`accounts`&&(0,z.jsx)(Ma,{item:e,apiBase:f,oauth:p,accounts:m,keys:v,accountLoadState:h,switchingAccountId:g,busy:y===e.name,loginHint:b,authHandlers:x,onCodexActiveNeedsReauthChange:S,codexController:C}),A===`settings`&&(0,z.jsx)(Ra,{item:e,apiBase:f,availableModels:i,onUpdateProvider:w,onDirtyChange:N,onRegisterSave:B},e.name)]}),P&&(0,z.jsx)(Ba,{saving:I,onCancel:()=>{I||F(null)},onDiscard:()=>{if(I)return;let e=P;F(null),N(!1),e===`deselect`?d():j(e)},onSave:()=>{(async()=>{if(!I){L(!0);try{if(!(await R.current?.()??!1))return;let e=P;F(null),N(!1),e===`deselect`?d():e&&j(e)}finally{L(!1)}}})()}})]})}var Ha=`https://chatgpt.com/backend-api/codex`;function Ua(e){try{let t=new URL(e.trim());if(t.username||t.password||t.search||t.hash)return;let n=t.pathname.replace(/\/+$/,``);return`${t.origin}${n}`}catch{return}}function Wa(e){return[`openai`,...Object.entries(e).filter(([,e])=>e.authMode===`forward`).map(([e])=>e).filter(e=>e!==`openai`).sort((e,t)=>e.localeCompare(t))]}function Ga(e){return e?e.adapter!==`openai-responses`||e.authMode!==`forward`||typeof e.baseUrl!=`string`||Ua(e.baseUrl)!==Ha?`invalid`:e.disabled===!0?`disabled`:`ready`:`absent`}function Ka(e){return e.id===`openai`}function qa(e){return e.id===`openai`?e.codexAccountMode===`direct`?`prov.openaiDirectDesc`:`prov.openaiPoolDesc`:null}function Ja(e){let t={adapter:e.adapter.trim(),baseUrl:e.baseUrl.trim()};return e.responsesPath?.trim()&&(t.responsesPath=e.responsesPath.trim()),(e.authMode===`key`||e.authMode===`forward`)&&(t.authMode=e.authMode),e.authMode===`key`&&e.apiKey.trim()&&(t.apiKey=e.apiKey.trim()),e.adapter.trim()===`anthropic`&&e.authMode===`key`&&e.apiKeyTransport===`bearer`&&(t.apiKeyTransport=`bearer`),e.defaultModel.trim()&&(t.defaultModel=e.defaultModel.trim()),e.allowPrivateNetwork&&(t.allowPrivateNetwork=!0),t}function Ya(e,t){return Ka(e)?Xa(e):{name:t.name.trim(),provider:Ja(t)}}function Xa(e){if(!e.provider)throw Error(`Missing canonical provider seed for ${e.id}`);return{name:e.id,provider:structuredClone(e.provider)}}var Za=class extends Error{i18nKey;constructor(e){super(e),this.name=`OpenAiEnableError`,this.i18nKey=e}};async function Qa(e,t,n=fetch){if(t===`disabled`){if((await n(`${e}/api/providers?name=openai`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({disabled:!1})})).ok)return;throw new Za(`codexAuth.enableOpenaiFailed`)}let r=await n(`${e}/api/provider-presets`);if(!r.ok)throw new Za(`codexAuth.openaiPresetLoadFailed`);let i=(await r.json()).providers?.find(e=>e.id===`openai`);if(!i?.provider)throw new Za(`codexAuth.openaiPresetUnavailable`);if(!(await n(`${e}/api/providers`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(Xa(i))})).ok)throw new Za(`codexAuth.enableOpenaiFailed`)}var $a=new Set([`anthropic`,`google-antigravity`]),eo=new Set([`github-copilot`,`cursor`]);function Q(e){let t=e.trim().toLowerCase();return $a.has(t)?`high`:eo.has(t)?`elevated`:null}function to(e){switch(e){case`high`:return`oauthTos.highTitle`;case`elevated`:return`oauthTos.elevatedTitle`;default:return e}}function no(e){switch(e){case`high`:return`oauthTos.highBody`;case`elevated`:return`oauthTos.elevatedBody`;default:return e}}function ro(e,t=!1){let n={};for(let[t,r]of Object.entries(e))li(r.accounts.find(e=>e.active)??r.accounts.find(e=>e.id===r.activeAccountId))&&(n[t]=!0);return t&&(n.openai=!0),n}function io(e){let{apiBase:t,t:n,config:r,aliveRef:i,notify:a,fetchConfig:o,fetchOauth:s,fetchProviderQuotas:c,codexActiveNeedsReauth:l}=e,[u,d]=(0,_.useState)({}),[f,p]=(0,_.useState)({}),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)({}),[y,b]=(0,_.useState)({}),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(``),T=(0,_.useRef)({}),E=(0,_.useRef)(null),D=(0,_.useRef)(null),O=(0,_.useRef)(null),k=(0,_.useCallback)(async e=>{let n=[...new Set(e)];return p(e=>{let t={...e};for(let e of n)t[e]=`loading`;return t}),(await Promise.all(n.map(async e=>{let n=(T.current[e]??0)+1;T.current[e]=n;try{let r=await fetch(`${t}/api/oauth/accounts?provider=${encodeURIComponent(e)}`);if(!r.ok)throw Error(String(r.status));let a=await r.json();return!i.current||T.current[e]!==n?!0:(d(t=>({...t,[e]:{activeAccountId:a.activeAccountId??null,accounts:a.accounts??[]}})),p(t=>({...t,[e]:`ready`})),(async()=>{try{let r=await fetch(`${t}/api/oauth/accounts?provider=${encodeURIComponent(e)}&quota=1`);if(!r.ok)return;let o=await r.json();if(!i.current||T.current[e]!==n)return;d(t=>({...t,[e]:{activeAccountId:o.activeAccountId??a.activeAccountId??null,accounts:o.accounts??a.accounts??[]}}))}catch{}})(),!0)}catch{return!i.current||T.current[e]!==n?!0:(p(t=>({...t,[e]:`error`})),!1)}}))).every(Boolean)},[i,t]),A=(0,_.useCallback)(async e=>{let n=await Promise.all(e.map(async e=>[e,(await fetch(`${t}/api/providers/keys?name=${encodeURIComponent(e)}`).then(async e=>{if(!e.ok)throw Error(String(e.status));return e.json()}).catch(()=>null))?.keys??[]]));b(Object.fromEntries(n))},[t]),j=async(e,r)=>{if(r.active||r.needsReauth||O.current)return;let o={provider:e,accountId:r.id};O.current=o,h(o);let l=$r(u[e]?.accounts??[r],r,n);try{if(!(await fetch(`${t}/api/oauth/accounts/active`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e,accountId:r.id})})).ok){a(n(`prov.accountSwitchFail`),!1);return}let i=await k([e]);if(await Promise.all([s(),c(!0)]),!i){a(n(`pws.accountsLoadFailed`),!1);return}a(n(`prov.accountSwitched`,{email:l}),!0)}catch{a(n(`prov.accountSwitchFail`),!1)}finally{O.current?.provider===o.provider&&O.current.accountId===o.accountId&&(O.current=null,i.current&&h(null))}},M=async(e,r)=>{if(r.active)return;let i=await fetch(`${t}/api/providers/keys/active`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e,id:r.id})});i.ok?(a(n(`prov.keySwitched`,{key:r.label??r.masked}),!0),A(Object.keys(y)),c(!0)):a((await i.json().catch(()=>({}))).error||n(`prov.keySwitchFail`),!1)},N=async(e,r)=>{window.confirm(n(`prov.keyRemoveConfirm`,{key:r.label??r.masked}))&&(await fetch(`${t}/api/providers/keys?name=${encodeURIComponent(e)}&id=${encodeURIComponent(r.id)}`,{method:`DELETE`})).ok&&(a(n(`prov.keyRemoved`,{key:r.label??r.masked}),!0),A(Object.keys(y)),o(),c(!0))},P=async(e,r)=>{let i=r.trim();if(!i)return!1;try{let r=await fetch(`${t}/api/providers/keys`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e,key:i})});return r.ok?(a(n(`prov.keyAdded`,{name:e}),!0),S(null),await Promise.all([A(Object.keys(y).includes(e)?Object.keys(y):[...Object.keys(y),e]),o(),c(!0)]),!0):(a((await r.json().catch(()=>({}))).error||n(`prov.keyAddFail`),!1),!1)}catch{return a(n(`prov.keyAddFail`),!1),!1}},F=async e=>{await P(e,C)&&w(``)},I=async(e,r,i,o)=>{let s=window.prompt(n(`prov.aliasPrompt`),o??``);if(s===null)return;let c=s.trim(),l=await fetch(r===`oauth`?`${t}/api/oauth/accounts/alias`:`${t}/api/providers/keys/alias`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r===`oauth`?{provider:e,accountId:i,alias:c}:{name:e,id:i,alias:c})});if(!l.ok){a((await l.json().catch(()=>({}))).error||n(`prov.aliasSaveFailed`),!1);return}r===`oauth`?await k([e]):await A(Object.keys(y).includes(e)?Object.keys(y):[...Object.keys(y),e]),a(n(`prov.aliasSaved`),!0)},L=async(e,r)=>{let i=$r(u[e]?.accounts??[r],r,n);if(window.confirm(n(`prov.accountRemoveConfirm`,{email:i})))try{if(!(await fetch(`${t}/api/oauth/accounts?provider=${encodeURIComponent(e)}&id=${encodeURIComponent(r.id)}`,{method:`DELETE`})).ok){a(n(`prov.accountRemoveFail`,{email:i}),!1);return}a(n(`prov.accountRemoved`,{email:i}),!0),await k([e]),await Promise.all([s(),c(!0)])}catch{a(n(`prov.accountRemoveFail`,{email:i}),!1)}},R=(0,_.useMemo)(()=>r?Object.entries(r.providers).filter(([,e])=>e.authMode===`oauth`).map(([e])=>e):[],[r]);(0,_.useEffect)(()=>{if(R.length===0)return;let e=R.join(`,`);E.current!==e&&(E.current=e,Promise.resolve().then(()=>{k(R)}))},[k,R]);let z=(0,_.useMemo)(()=>r?Object.entries(r.providers).filter(([,e])=>e.hasApiKey&&e.authMode!==`oauth`&&e.authMode!==`forward`).map(([e])=>e):[],[r]);return(0,_.useEffect)(()=>{if(z.length===0)return;let e=z.join(`,`);D.current!==e&&(D.current=e,Promise.resolve().then(()=>{A(z)}))},[A,z]),{accountSets:u,accountLoadStates:f,switchingAccount:m,openAccounts:g,keyPools:y,addingKeyFor:x,newKeyValue:C,setAccountSets:d,setAccountLoadStates:p,setSwitchingAccount:h,setOpenAccounts:v,setKeyPools:b,setAddingKeyFor:S,setNewKeyValue:w,fetchAccountSets:k,fetchKeyPools:A,switchAccount:j,switchApiKey:M,removeApiKey:N,addApiKeyValue:P,addApiKey:F,editCredentialAlias:I,removeAccount:L,oauthCardProviders:R,keyCardProviders:z,activeAccountNeedsReauth:(0,_.useMemo)(()=>ro(u,l),[u,l])}}function ao(e){let{apiBase:t,config:n,notify:r,fetchConfig:i,fetchProviderQuotas:a,onSaved:o,t:s}=e,[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(!1),x=(0,_.useRef)(!1);(0,_.useEffect)(()=>{n&&!x.current&&d(JSON.stringify(n,null,2))},[n]);let S=(0,_.useCallback)(async()=>{v(!0);try{let e=JSON.parse(u),n=await fetch(`${t}/api/config`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return n.ok?(r(s(`prov.saved`),!0),l(!1),p(!1),x.current=!1,b(!1),h(JSON.stringify(e,null,2)),i(),a(!0),o(),!0):(r((await n.json().catch(()=>({}))).error||s(`prov.saveFailed`),!1),!1)}catch{return r(s(`prov.invalidJson`),!1),!1}finally{v(!1)}},[t,u,i,a,r,o,s]),C=(0,_.useCallback)(()=>{let e=n?JSON.stringify(n,null,2):u;h(e),d(e),b(!1),p(!0),x.current=!0},[n,u]),w=(0,_.useCallback)(()=>{b(!1),p(!1),x.current=!1;let e=n?JSON.stringify(n,null,2):m;h(e),d(e)},[n,m]);return{editing:c,setEditing:l,draft:u,setDraft:d,jsonEditorOpen:f,jsonBaseline:m,jsonSaving:g,jsonLeaveOpen:y,jsonEditorOpenRef:x,saveConfig:S,openJsonEditor:C,discardJsonEditor:w,requestCloseJsonEditor:(0,_.useCallback)(()=>{if(f&&u!==m){b(!0);return}w()},[w,u,m,f]),restoreJsonEditor:(0,_.useCallback)(()=>{d(m)},[m]),jsonIsDirty:f&&u!==m,setJsonLeaveOpen:b}}var oo={xai:`xAI (Grok)`,anthropic:`Anthropic (Claude)`,kimi:`Kimi (Moonshot)`,"google-antigravity":`Google Antigravity`,"github-copilot":`GitHub Copilot`,cursor:`Cursor`},so=e=>oo[e]??e;function co({apiBase:e,t,aliveRef:n,oauthLoginGenerationRef:r,accountSets:i,setBusy:a,setStatus:o,setLoginInfo:s,setOauthStatus:c,notify:l,fetchConfig:u,fetchOauth:d,fetchAccountSets:f,fetchProviderQuotas:p,bumpModelsRefresh:m}){return{cancelLoginOAuth:(0,_.useCallback)(async i=>{let o=(r.current.get(i)??0)+1;r.current.set(i,o);try{await fetch(`${e}/api/oauth/login/cancel`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:i})})}catch{}n.current&&(r.current.get(i)===o&&(a(e=>e===i?null:e),s(e=>e?.provider===i?null:e)),l(t(`prov.loginCancelled`,{provider:so(i)}),!1))},[n,e,l,r,a,s,t]),loginOAuth:async(d,h=!1,g)=>{let _=(r.current.get(d)??0)+1;r.current.set(d,_);let v=_,y=g?.trim()||void 0;a(d),o(``),s(null);try{let a=await fetch(`${e}/api/oauth/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:d,...h||y?{addAccount:!0}:{},...y?{accountId:y,reauth:!0}:{}})});if(r.current.get(d)!==v||!n.current)return;if(!a.ok){l((await a.json().catch(()=>({}))).error||t(`prov.loginFailStart`,{provider:so(d)}),!1);return}let o=await a.json();(o.url||o.instructions||o.deviceCode)&&s({provider:d,url:o.url,instructions:o.instructions,deviceCode:o.deviceCode});let g=i[d]?.accounts.length??0,_=!1;for(let a=0;a<150&&n.current&&r.current.get(d)===v;a++){if(await new Promise(e=>setTimeout(e,2e3)),r.current.get(d)!==v||!n.current)return;let a=await fetch(`${e}/api/oauth/status?provider=${d}`).catch(()=>null),o=a?await ut(a)??null:null;if(o){if(o.error){c(e=>({...e,[d]:o})),l(/cancel/i.test(o.error)?t(`prov.loginCancelled`,{provider:so(d)}):t(`prov.loginError`,{provider:so(d),error:o.error}),!1),s(null),_=!0;break}if(h||y?(o.accounts?.length??0)>g||o.done===!0:o.loggedIn||o.done===!0){c(e=>({...e,[d]:o}));let e=y?o.accounts?.find(e=>e.id===y):o.accounts?.find(e=>e.active)??o.accounts?.find(e=>e.id===o.activeAccountId);if(y&&!e){l(t(`prov.loginError`,{provider:so(d),error:t(`prov.reauthAccountMissing`)}),!1),s(null),_=!0;break}if(e?.needsReauth){l(t(`prov.loginError`,{provider:so(d),error:t(`prov.reauthIdentityMismatch`)}),!1),s(null),_=!0;break}l(t(`prov.loginOk`,{provider:so(d),cmd:`ocx sync`}),!0),s(null),u();let n=Object.keys(i);f(new Set(n).has(d)?n:[...n,d]),p(!0),m(),_=!0;break}}}!_&&r.current.get(d)===v&&n.current&&(await fetch(`${e}/api/oauth/login/cancel`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:d})}).catch(()=>{}),l(t(`prov.loginTimeout`,{provider:so(d)}),!1),s(null))}catch{r.current.get(d)===v&&l(t(`prov.loginRequestFail`,{provider:so(d)}),!1)}finally{n.current&&r.current.get(d)===v&&a(null)}},logoutOAuth:async n=>{try{if(!(await fetch(`${e}/api/oauth/logout?provider=${encodeURIComponent(n)}`,{method:`POST`})).ok){l(t(`prov.logoutFail`,{provider:so(n)}),!1);return}await Promise.all([f([n]),d(),u(),p(!0)]),m(),l(t(`prov.logoutOk`,{provider:so(n)}),!0)}catch{l(t(`prov.logoutFail`,{provider:so(n)}),!1)}}}}async function lo(e,t){try{let t=await e.json();if(typeof t.error==`string`&&t.error.trim())return t.error.trim()}catch{}return t}function uo(e,t,n){switch(e.code){case`last_provider`:return t(`prov.removeLastProvider`);case`provider_has_dependent_combos`:return t(`prov.removeHasDependentCombos`,{combos:(Array.isArray(e.combos)?e.combos.filter(e=>typeof e==`string`).join(`, `):``)||`—`});case`default_provider_disabled`:return t(`prov.defaultDisabled`);default:return typeof e.error==`string`&&e.error.trim()?e.error.trim():n}}function fo({apiBase:e,t,removeBusyRef:n,workspaceSelected:r,setWorkspaceSelected:i,setRemoveConfirmName:a,notify:o,fetchConfig:s,fetchOauth:c,fetchProviderQuotas:l}){let u=(0,_.useCallback)(async e=>{a(e)},[a]),d=(0,_.useCallback)(async u=>{let d=u;if(!d||n.current)return;n.current=!0,a(null);let f=t(`prov.removeFail`,{name:d});try{let n=await fetch(`${e}/api/providers?name=${encodeURIComponent(d)}`,{method:`DELETE`});if(n.ok){let e=await n.json().catch(()=>({})),a=typeof e.defaultProvider==`string`?e.defaultProvider:null;o(a?t(`prov.removedDefault`,{name:d,defaultProvider:a}):t(`prov.removed`,{name:d}),!0),r===d&&i(null),s(),c(),l(!0)}else o(uo(await n.json().catch(()=>({})),t,f),!1)}catch{o(f,!1)}finally{n.current=!1}},[e,s,c,l,o,n,a,i,t,r]),f=(0,_.useCallback)(async(n,r)=>{let i=await fetch(`${e}/api/providers?name=${encodeURIComponent(n)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({disabled:r})});if(!i.ok){o(await lo(i,t(r?`prov.disableFail`:`prov.enableFail`,{name:n})),!1);return}o(t(r?`prov.disabled`:`prov.enabled`,{name:n}),!0),s(),c(),l(!0)},[e,s,c,l,o,t]),p=(0,_.useCallback)(async(n,r)=>{try{let i=await fetch(`${e}/api/providers?name=${encodeURIComponent(n)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});return i.ok?(await s(),{ok:!0}):{ok:!1,error:await lo(i,t(`prov.updateFail`))}}catch{return{ok:!1,error:t(`prov.networkError`)}}},[e,s,t]);return{removeProvider:u,confirmRemoveProvider:d,setProviderDisabled:f,setDefaultProvider:(0,_.useCallback)(async n=>{try{let r=await fetch(`${e}/api/providers?name=${encodeURIComponent(n)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({setDefault:!0})});return r.ok?(o(t(`prov.setDefaultSuccess`,{name:n}),!0),await s(),!0):(o(uo(await r.json().catch(()=>({})),t,t(`prov.setDefaultFail`,{name:n})),!1),!1)}catch{return o(t(`prov.setDefaultFail`,{name:n}),!1),!1}},[e,s,o,t]),updateProvider:p}}function po({apiBase:e,t,setConfig:n,setOauthProviders:r,setOauthStatus:i,notify:a,invalidateProviderQuotas:o,configCacheKey:s}){return{fetchConfig:(0,_.useCallback)(async()=>{try{let t=await J(await fetch(`${e}/api/config`));n(t??null),s&&t&&X(s,t)}catch{a(t(`prov.loadConfigFail`),!1)}},[e,s,a,n,t]),fetchOauth:(0,_.useCallback)(async()=>{try{let t=(await J(await fetch(`${e}/api/oauth/providers`)))?.providers??[];r(t);let n=await Promise.all(t.map(async t=>{let n=await fetch(`${e}/api/oauth/status?provider=${encodeURIComponent(t)}`).catch(()=>null);return[t,n?await ut(n)??{loggedIn:!1}:{loggedIn:!1}]}));i(Object.fromEntries(n))}catch{}},[e,r,i]),fetchProviderQuotas:(0,_.useCallback)(async(e=!1)=>{o(e)},[o])}}function mo({providerId:e,providerLabel:t,onCancel:n,onContinue:r}){let i=K(),a=(0,_.useId)(),o=(0,_.useId)(),s=(0,_.useRef)(null),c=(0,_.useRef)(!1),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(!1),p=Q(e);(0,_.useEffect)(()=>{let e=s.current;e&&!e.open&&e.showModal()},[]);let m=(0,_.useCallback)(e=>{e.preventDefault(),n()},[n]);if(!p)return null;let h=e.trim().toLowerCase(),g=h===`anthropic`?`oauthTos.anthropicBody`:no(p),v=h===`anthropic`||h===`google-antigravity`;return(0,z.jsxs)(`dialog`,{ref:s,"aria-labelledby":a,"aria-describedby":o,className:`modal-overlay`,onCancel:m,children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":i(`common.close`),tabIndex:-1,onClick:n}),(0,z.jsxs)(`div`,{className:`modal-card`,onClick:e=>e.stopPropagation(),style:{maxWidth:460},children:[(0,z.jsx)(`h3`,{id:a,children:i(to(p),{provider:t})}),(0,z.jsxs)(`div`,{id:o,className:`notice-warn`,style:{marginTop:12,display:`flex`,gap:8,alignItems:`flex-start`},children:[(0,z.jsx)(de,{width:16,height:16,style:{flexShrink:0,marginTop:2},"aria-hidden":`true`}),(0,z.jsx)(`p`,{className:`modal-desc`,style:{margin:0},children:i(g,{provider:t})})]}),v&&(0,z.jsx)(`p`,{className:`muted text-label`,style:{marginTop:12},children:i(`oauthTos.saferPath`)}),(0,z.jsxs)(`label`,{className:`oauth-tos-ack`,style:{display:`flex`,gap:8,alignItems:`flex-start`,marginTop:14},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked),style:{marginTop:3},"aria-required":`true`}),(0,z.jsx)(`span`,{className:`text-label`,children:i(`oauthTos.acknowledge`)})]}),(0,z.jsxs)(`div`,{className:`modal-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:n,children:i(`common.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:!l||d,onClick:()=>{!l||c.current||(c.current=!0,f(!0),r())},children:i(`oauthTos.continue`)})]})]})]})}function ho(e){return{adapter:e.adapter,baseUrl:e.baseUrl,authMode:e.auth,freeTier:!!e.freeTier,keyOptional:!!e.keyOptional}}function go(e){return Wn(e.id,ho(e))}function _o(e){let t={accounts:[],free:[],paid:[]};for(let n of e)t[go(n)].push(n);return t}function vo(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.label.toLowerCase().includes(n)||e.id.toLowerCase().includes(n)):e}var yo={},bo=[],xo={};function So({presets:e,usageRank:t=yo,presetsLoading:n=!1,initialTier:r=`free`,onSelectPreset:i,onSelectCustom:a,accountRows:o=bo,accountStatus:s=xo,busyProvider:c=null,onLogin:l,onCancelLogin:u,onLogout:d}){let f=K(),[p,m]=(0,_.useState)(r),[h,g]=(0,_.useState)(``),v=(0,_.useMemo)(()=>e.filter(e=>e.id!==`custom`),[e]),y=(0,_.useMemo)(()=>{let e=Object.keys(t).length>0;return v.toSorted((n,r)=>{if(e){let e=t[n.id]??0,i=t[r.id]??0;if(i!==e)return i-e}return n.label.localeCompare(r.label,void 0,{sensitivity:`base`})||n.id.localeCompare(r.id)})},[v,t]),b=(0,_.useMemo)(()=>_o(y),[y])[p],x=(0,_.useMemo)(()=>vo(b,h),[b,h]),S=e=>{let t=e.codexAccountMode===`direct`?(0,z.jsx)(`span`,{className:`badge badge-green`,children:f(`modal.badge.direct`)}):e.codexAccountMode===`pool`?(0,z.jsx)(`span`,{className:`badge badge-accent`,children:f(`modal.badge.pool`)}):e.auth===`oauth`?(0,z.jsx)(`span`,{className:`badge badge-accent`,children:f(`modal.badge.oauth`)}):e.auth===`forward`?(0,z.jsx)(`span`,{className:`badge badge-green`,children:f(`modal.badge.codexLogin`)}):e.auth===`local`?(0,z.jsx)(`span`,{className:`badge badge-amber`,children:f(`modal.badge.local`)}):e.keyOptional?null:(0,z.jsx)(`span`,{className:`badge badge-muted`,children:f(`modal.badge.apiKey`)});return(0,z.jsxs)(z.Fragment,{children:[(e.freeTier||e.keyOptional)&&e.auth===`key`?(0,z.jsx)(`span`,{className:`badge badge-green`,children:f(`modal.badge.free`)}):null,t]})};return(0,z.jsxs)(`div`,{className:`provider-catalog`,children:[(0,z.jsx)(`div`,{className:`provider-catalog-tabs`,role:`tablist`,children:[`accounts`,`free`,`paid`].map(e=>(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":p===e,className:`provider-catalog-tab${p===e?` active`:``}`,onClick:()=>{m(e),g(``)},children:f(e===`accounts`?`modal.tab.accounts`:e===`free`?`modal.tab.free`:`modal.tab.paid`)},e))}),p===`accounts`&&(0,z.jsx)(`div`,{className:`provider-catalog-accounts-hint muted text-label`,children:f(`modal.accountsHint`)}),(0,z.jsx)(`input`,{className:`input provider-catalog-search`,value:h,onChange:e=>g(e.target.value),placeholder:f(`modal.search`)}),(0,z.jsxs)(`div`,{className:`provider-catalog-rows`,children:[n&&x.length===0&&(0,z.jsx)(`div`,{className:`muted text-control provider-catalog-empty`,children:f(`modal.catalogLoading`)}),p!==`accounts`&&x.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`list-row`,onClick:()=>i(e),children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`title`,children:e.label}),(0,z.jsxs)(`div`,{className:`sub`,children:[(0,z.jsx)(`code`,{className:`chip`,children:e.adapter}),e.note?` · ${e.note}`:``]})]}),(0,z.jsx)(`div`,{className:`provider-catalog-badges`,children:S(e)})]},e.id)),p!==`accounts`&&!n&&x.length===0&&(0,z.jsx)(`div`,{className:`muted text-control provider-catalog-empty`,children:f(`modal.noMatch`)}),p===`accounts`&&o.map(e=>{let t=s[e.id],n=c===e.id,r=!!t?.loggedIn,i=r?t?.email??e.statusLabel??f(`modal.accountLoggedIn`):t?.error??e.statusLabel??f(`modal.accountLoggedOut`);return(0,z.jsxs)(`div`,{className:`list-row provider-catalog-account-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`title`,children:e.label}),(0,z.jsx)(`div`,{className:`sub`,children:i})]}),(0,z.jsx)(`div`,{className:`provider-catalog-badges`,children:e.kind===`key`?null:e.kind===`codex`?(0,z.jsxs)(z.Fragment,{children:[r&&(0,z.jsx)(`a`,{className:`btn btn-ghost`,href:e.href??`#codex-auth`,children:f(`modal.accountManage`)}),l&&(0,z.jsx)(`button`,{type:`button`,className:r?`btn btn-ghost`:`btn btn-primary`,disabled:n,onClick:()=>{n||l(e.id)},children:f(n?`codexAuth.enablingOpenai`:r?`modal.accountAdd`:`modal.accountLogin`)})]}):r?d&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>d(e.id),children:f(`modal.accountLogout`)}):n?u&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>u(e.id),children:f(`common.cancel`)}):l&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>l(e.id),children:f(`modal.accountLogin`)})})]},e.id)}),p===`accounts`&&o.length===0&&!n&&(0,z.jsx)(`div`,{className:`muted text-control provider-catalog-empty`,children:f(`modal.noMatch`)})]}),(0,z.jsxs)(`div`,{className:`provider-catalog-footer`,children:[(0,z.jsx)(`div`,{style:{flex:1}}),p!==`accounts`&&(0,z.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:a,children:f(`modal.notListed`)})]})]})}function Co({preset:e,oauthSupported:t,oauthBusy:n,oauthMsg:r,oauthMsgTone:i,oauthUrl:a,manualCode:o,manualCodeBusy:s,manualCodeMsg:c,manualCodeOk:l,onRequestLogin:u,onUseApiKeyInstead:d,onManualCodeChange:f,onSubmitManualCode:p,onBack:m}){let h=K();return(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:14},children:[(0,z.jsx)(`div`,{className:`muted text-control`,children:e.note??h(`modal.oauthDefaultNote`)}),t.includes(e.oauthProvider??``)?(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>u(e.oauthProvider),disabled:n,style:{width:`100%`,padding:`12px 16px`},children:[(0,z.jsx)(Se,{}),n?h(`modal.waitingBrowser`):h(`modal.logInWith`,{label:e.label})]}):(0,z.jsx)(`div`,{className:`text-control`,style:{color:`var(--amber)`,background:`var(--amber-soft)`,border:`1px solid var(--amber)`,borderRadius:`var(--radius-sm)`,padding:`10px 12px`},children:h(`modal.oauthComingSoon`,{label:e.label})}),r&&(0,z.jsx)(`div`,{className:`text-label`,style:{color:i===`warn`?`var(--amber)`:`var(--accent-hover)`},children:r}),n&&(0,z.jsx)(Z,{url:a}),n&&(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:[(0,z.jsx)(`div`,{className:`muted text-label`,children:h(`prov.pasteRedirectHint`)}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,z.jsx)(`input`,{type:`text`,autoComplete:`off`,spellCheck:!1,value:o,onChange:e=>f(e.target.value),onKeyDown:t=>{t.key===`Enter`&&e.oauthProvider&&(t.preventDefault(),p(e.oauthProvider))},placeholder:h(`prov.pasteRedirect`),"aria-label":h(`prov.pasteRedirect`),disabled:s,className:`input text-label`,style:{flex:1}}),(0,z.jsx)(`button`,{className:`btn btn-ghost`,type:`button`,disabled:s||!o.trim()||!e.oauthProvider,onClick:()=>e.oauthProvider&&p(e.oauthProvider),children:h(s?`prov.pasteSubmitting`:`prov.pasteSubmit`)})]}),c&&(0,z.jsx)(`div`,{className:`text-label`,style:{color:l?`var(--accent-hover)`:`var(--amber)`},children:c})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`,marginTop:2},children:[(0,z.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:d,children:h(`modal.useApiKeyInstead`)}),(0,z.jsx)(`div`,{style:{flex:1}}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:m,children:h(`modal.back`)})]})]})}function wo({label:e,children:t}){return(0,z.jsxs)(`label`,{style:{display:`block`},children:[(0,z.jsx)(`span`,{className:`field-label`,children:e}),t]})}function To({preset:e,form:t,endpointChoice:n,error:r,saving:i,dup:a,isCustom:o,isLocal:s,isReservedForward:c,presetDescription:l,onFormChange:u,onEndpointChoiceChange:d,onSubmit:f,onUseOauthLogin:p,onBack:m}){let h=K();return(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[!c&&!o&&!s&&!e.keyOptional&&e.note&&(0,z.jsxs)(`details`,{className:`setup-guide`,children:[(0,z.jsx)(`summary`,{children:h(`modal.setupGuide`)}),(0,z.jsxs)(`ol`,{className:`text-label leading-relaxed`,style:{margin:`8px 0 0`,paddingLeft:18,color:`var(--muted)`},children:[(0,z.jsxs)(`li`,{children:[h(`modal.setupStep1Prefix`),` `,(0,z.jsx)(`a`,{href:e.dashboardUrl,target:`_blank`,rel:`noreferrer`,children:h(`modal.setupDashboardLink`,{label:e.label})}),` `,h(`modal.setupStep1Suffix`)]}),(0,z.jsx)(`li`,{children:h(`modal.setupStep2`)}),(0,z.jsx)(`li`,{children:h(`modal.setupStep3`)})]}),e.note&&(0,z.jsx)(`div`,{className:`text-label`,style:{color:`var(--muted)`,marginTop:6,fontStyle:`italic`},children:e.note}),/\{[^}]*\}/.test(t.baseUrl)&&(0,z.jsx)(`div`,{className:`text-label`,style:{color:`var(--amber)`,marginTop:6},children:h(`modal.baseUrlPlaceholderHint`)})]}),(0,z.jsx)(wo,{label:h(`modal.providerName`),children:(0,z.jsx)(`input`,{className:`input`,value:t.name,readOnly:c,onChange:e=>u({...t,name:e.target.value}),placeholder:h(`modal.namePlaceholder`)})}),a&&(0,z.jsx)(`div`,{className:`text-label`,style:{color:`var(--amber)`},children:h(`modal.duplicateWarn`,{name:t.name.trim()})}),!c&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(wo,{label:h(`modal.adapter`),children:(0,z.jsx)(`select`,{className:`input`,value:t.adapter,onChange:e=>u({...t,adapter:e.target.value}),children:[`openai-responses`,`openai-chat`,`anthropic`,`google`,`azure-openai`,`cursor`].map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})}),e.baseUrlChoices&&e.baseUrlChoices.length>0?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(wo,{label:h(`modal.endpoint`),children:(0,z.jsx)(`select`,{className:`input`,value:n,onChange:n=>{let r=n.target.value;d(r),u({...t,baseUrl:Na(e.baseUrlChoices,r,t.baseUrl)})},children:e.baseUrlChoices.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.id===`token-plan`?h(`modal.endpoint.tokenPlan`):e.id===`payg`?h(`modal.endpoint.payAsYouGo`):e.id===`custom`?h(`modal.endpoint.custom`):e.label},e.id))})}),n===`custom`&&(0,z.jsx)(wo,{label:h(`modal.baseUrl`),children:(0,z.jsx)(`input`,{className:`input`,value:t.baseUrl,onChange:e=>u({...t,baseUrl:e.target.value}),placeholder:h(`modal.baseUrlPlaceholder`)})})]}):(0,z.jsx)(wo,{label:h(`modal.baseUrl`),children:(0,z.jsx)(`input`,{className:`input`,value:t.baseUrl,onChange:e=>u({...t,baseUrl:e.target.value}),placeholder:h(`modal.baseUrlPlaceholder`)})}),!c&&(0,z.jsxs)(`label`,{className:`modal-field`,style:{flexDirection:`row`,alignItems:`center`,gap:8},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:t?.allowPrivateNetwork??!1,onChange:e=>u({...t,allowPrivateNetwork:e.target.checked})}),(0,z.jsx)(`span`,{className:`muted text-control`,children:h(`modal.allowPrivateNetwork`)})]}),!c&&(t?.allowPrivateNetwork??!1)&&(0,z.jsx)(`p`,{className:`muted text-hint`,children:h(`modal.allowPrivateNetworkHint`)})]}),t.authMode===`forward`?(0,z.jsx)(`div`,{className:`text-label`,style:{color:`var(--green)`,background:`var(--green-soft)`,border:`1px solid var(--green)`,borderRadius:`var(--radius-sm)`,padding:`8px 10px`},children:l(e)}):t.authMode===`local`?(0,z.jsx)(`div`,{className:`text-label leading-relaxed`,style:{color:`var(--amber)`,background:`var(--amber-soft)`,border:`1px solid var(--amber)`,borderRadius:`var(--radius-sm)`,padding:`8px 10px`},children:h(`modal.localHint`)}):e.keyOptional?(0,z.jsxs)(`div`,{className:`text-label leading-relaxed`,style:{color:`var(--green)`,background:`var(--green-soft)`,border:`1px solid var(--green)`,borderRadius:`var(--radius-sm)`,padding:`10px 12px`},children:[(0,z.jsx)(`strong`,{children:h(`modal.freeTierTitle`)}),` — `,e.note??h(`modal.freeTierDefault`)]}):(0,z.jsxs)(z.Fragment,{children:[e.dashboardUrl&&(0,z.jsxs)(`a`,{className:`text-label`,href:e.dashboardUrl,target:`_blank`,rel:`noreferrer`,style:{display:`inline-flex`,alignItems:`center`,gap:5},children:[(0,z.jsx)(xe,{style:{width:14,height:14}}),h(`modal.getApiKey`,{label:e.label}),(0,z.jsx)(be,{style:{width:13,height:13}})]}),(0,z.jsx)(wo,{label:h(`modal.apiKey`),children:(0,z.jsx)(`input`,{className:`input`,type:`password`,value:t.apiKey,onChange:e=>u({...t,apiKey:e.target.value}),placeholder:h(`modal.apiKeyPlaceholder`)})}),t.adapter===`anthropic`&&t.authMode===`key`&&(0,z.jsx)(wo,{label:h(`modal.apiKeyTransport`),children:(0,z.jsxs)(`select`,{className:`input`,value:t.apiKeyTransport??`x-api-key`,onChange:e=>u({...t,apiKeyTransport:e.target.value===`bearer`?`bearer`:void 0}),children:[(0,z.jsx)(`option`,{value:`x-api-key`,children:h(`modal.apiKeyTransportNative`)}),(0,z.jsx)(`option`,{value:`bearer`,children:h(`modal.apiKeyTransportBearer`)})]})})]}),!c&&(0,z.jsx)(wo,{label:h(`modal.defaultModel`),children:(0,z.jsx)(`input`,{className:`input`,value:t.defaultModel,onChange:e=>u({...t,defaultModel:e.target.value}),placeholder:h(`modal.defaultModelPlaceholder`)})}),r&&(0,z.jsx)(`div`,{className:`text-control`,role:`alert`,style:{color:`var(--red)`},children:r}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8,marginTop:4,alignItems:`center`},children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:f,disabled:i,children:h(i?`modal.adding`:`modal.add`)}),e.auth===`oauth`&&(0,z.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:p,children:h(`modal.useOauthLogin`)}),(0,z.jsx)(`div`,{style:{flex:1}}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:m,children:h(`modal.back`)})]})]})}var Eo=2e3;function Do({apiBase:e,t,aliveRef:n,onAdded:r}){return{loginOAuth:(0,_.useCallback)(async(i,a)=>{let{setOauthBusy:o,setOauthMsg:s,setOauthMsgTone:c,setOauthUrl:l,setManualCode:u,setManualCodeMsg:d,setManualCodeOk:f}=a;o(!0),s(``),c(`ok`),l(``,i),u(``),d(``),f(!0);try{let a=await fetch(`${e}/api/oauth/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:i})});if(!n.current)return;if(!a.ok){let e=await a.json().catch(()=>({}));c(`warn`),s(e.error===`unknown oauth provider`?t(`modal.oauthComingSoonShort`):e.error||t(`modal.loginFailStart`));return}let o=await a.json();o.url?(l(o.url,i),s(t(`modal.waitingLogin`))):s(o.instructions||t(`modal.loggingIn`));for(let a=0;a<100;a++){if(await new Promise(e=>setTimeout(e,Eo)),!n.current)return;let a=await fetch(`${e}/api/oauth/status?provider=${i}`).catch(()=>null),o=a?await ut(a):null;if(!n.current)return;if(o?.error){c(`warn`),s(t(`modal.loginError`,{error:o.error}));return}if(o?.loggedIn){r(i);return}}c(`warn`),s(t(`modal.loginTimeout`))}catch{n.current&&(c(`warn`),s(t(`modal.networkError`)))}finally{n.current&&o(!1)}},[n,e,r,t]),submitManualCode:(0,_.useCallback)(async(r,i,a,o)=>{let s=i.trim();if(!s||a)return;let{setManualCodeBusy:c,setManualCode:l,setManualCodeOk:u,setManualCodeMsg:d}=o;c(!0),d(``);try{let i=await fetch(`${e}/api/oauth/login/code`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:r,input:s})});if(!n.current)return;if(!i.ok){let e=await i.json().catch(()=>({}));u(!1),d(t(`prov.pasteFail`,{error:e.error||i.statusText}));return}l(``),u(!0),d(t(`prov.pasteOk`))}catch{n.current&&(u(!1),d(t(`modal.networkError`)))}finally{n.current&&c(!1)}},[n,e,t])}}function Oo(e,t){return{preset:e?{id:`custom`,label:t,adapter:`openai-chat`,baseUrl:``,auth:`key`}:null,form:e?{name:``,adapter:`openai-chat`,baseUrl:``,authMode:`key`,apiKey:``,apiKeyTransport:void 0,defaultModel:``,allowPrivateNetwork:!1}:null,saving:!1,error:``,oauthBusy:!1,oauthMsg:``,oauthMsgTone:`ok`,oauthUrl:``,oauthUrlProvider:null,manualCode:``,manualCodeBusy:!1,manualCodeMsg:``,manualCodeOk:!0,endpointChoice:`custom`,oauthTosPending:null}}function ko(e,t){switch(t.type){case`choose-preset`:return{...e,preset:t.preset,form:t.form,endpointChoice:t.endpointChoice,error:``,oauthMsg:``,oauthMsgTone:`ok`,oauthUrl:``,oauthUrlProvider:null,oauthBusy:!1,manualCode:``,manualCodeMsg:``,manualCodeOk:!0};case`back`:return{...e,preset:null,form:null,endpointChoice:`custom`,error:``,oauthMsg:``,oauthMsgTone:`ok`,oauthUrl:``,oauthUrlProvider:null,oauthBusy:!1,manualCode:``,manualCodeMsg:``,manualCodeOk:!0};case`set-form`:return{...e,form:t.form};case`set-endpoint-choice`:return{...e,endpointChoice:t.choice};case`set-saving`:return{...e,saving:t.saving};case`set-error`:return{...e,error:t.error};case`set-oauth-busy`:return{...e,oauthBusy:t.busy};case`set-oauth-msg`:return{...e,oauthMsg:t.msg,oauthMsgTone:t.tone??e.oauthMsgTone};case`set-oauth-tone`:return{...e,oauthMsgTone:t.tone};case`set-oauth-url`:return e.preset?.oauthProvider===t.providerId?{...e,oauthUrl:t.url,oauthUrlProvider:t.providerId}:e;case`set-manual-code`:return{...e,manualCode:t.code};case`set-manual-code-busy`:return{...e,manualCodeBusy:t.busy};case`set-manual-code-msg`:return{...e,manualCodeMsg:t.msg,manualCodeOk:t.ok??e.manualCodeOk};case`set-oauth-tos-pending`:return{...e,oauthTosPending:t.providerId};case`use-oauth-login`:return{...e,form:t.form,error:``,oauthUrl:``,oauthUrlProvider:null};case`use-api-key-instead`:return{...e,form:t.form,oauthMsg:``,oauthMsgTone:`ok`,oauthUrl:``,oauthUrlProvider:null,oauthBusy:!1,manualCode:``,manualCodeMsg:``};default:return e}}function Ao({apiBase:e,existingNames:t,onClose:n,onAdded:r,initialTier:i,initialCustom:a=!1,accountRows:o,accountStatus:s,accountBusy:c,onAccountLogin:l,onAccountCancelLogin:u,onAccountLogout:d,onOpen:f}){let p=K(),m=(0,_.useMemo)(()=>[{id:`custom`,label:p(`modal.customProvider`),adapter:`openai-chat`,baseUrl:``,auth:`key`}],[p]),[h,g]=(0,_.useReducer)(ko,a,e=>Oo(e,p(`modal.customProvider`))),v=(0,_.useRef)(!0),y=(0,_.useRef)(null),b=(0,_.useRef)(null),x=I(`add-provider-oauth:${e}`,[e],async t=>{let n=await fetch(`${e}/api/oauth/providers`,{signal:t});return n.ok?(await n.json()).providers??[]:[]}),S=I(`add-provider-presets:${e}`,[e],async t=>{let n=await fetch(`${e}/api/provider-presets`,{signal:t});if(!n.ok)throw Error(String(n.status));let r=await n.json();return Array.isArray(r.providers)&&r.providers.length>0?r.providers:null}),C=I(`add-provider-usage:${e}`,[e],async t=>{let n=await fetch(`${e}/api/usage?range=30d`,{signal:t});if(!n.ok)return{};let r=await n.json(),i={};for(let e of r.providers??[])i[e.provider]=e.requests;return i}),w=x.data??[],T=S.data??m,E=S.loading,D=C.data??{},{preset:O,form:k,saving:A,error:j,oauthBusy:M,oauthMsg:N,oauthMsgTone:P,oauthUrl:F,oauthUrlProvider:L,manualCode:R,manualCodeBusy:B,manualCodeMsg:V,manualCodeOk:H,endpointChoice:U,oauthTosPending:W}=h;(0,_.useEffect)(()=>{v.current=!0,y.current=document.activeElement,f?.();let e=b.current;if(e){let t=e.querySelector(`input:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex='-1'])`);t&&t.focus()}return()=>{v.current=!1,y.current?.focus()}},[]),(0,_.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!W&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,W]);let ee=e=>{let t=qa(e);return t?p(t):e.note},te=e=>{let t=Pa(e.baseUrlChoices,e.baseUrl);g({type:`choose-preset`,preset:e,endpointChoice:t,form:{name:e.id===`custom`?``:e.id,adapter:e.adapter,baseUrl:e.baseUrlChoices?.length?Na(e.baseUrlChoices,t,e.baseUrl):e.baseUrl,responsesPath:e.responsesPath,authMode:e.auth,apiKey:``,apiKeyTransport:void 0,defaultModel:e.defaultModel??``,allowPrivateNetwork:!1}})},ne=async()=>{if(!k)return;let t=O?Ka(O):!1,n=O?.baseUrlChoices?.length?Fa(O.baseUrlChoices,U,k.baseUrl):k.baseUrl.trim();if(!t&&!k.name.trim()){g({type:`set-error`,error:p(`modal.nameRequired`)});return}if(!t&&!n){g({type:`set-error`,error:p(`modal.baseUrlRequired`)});return}if(!t&&/\{[^}]*\}/.test(n)){g({type:`set-error`,error:p(`modal.baseUrlPlaceholderError`)});return}let i={...k,baseUrl:n},a;try{a=Ya(O??{id:`custom`},i)}catch{g({type:`set-error`,error:p(`modal.invalidPreset`)});return}g({type:`set-saving`,saving:!0}),g({type:`set-error`,error:``});try{let t=await fetch(`${e}/api/providers`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)});if(!t.ok){g({type:`set-error`,error:(await t.json().catch(()=>({}))).error||p(`modal.failedStatus`,{status:t.status})});return}r(a.name)}catch{g({type:`set-error`,error:p(`modal.networkError`)})}finally{g({type:`set-saving`,saving:!1})}},{loginOAuth:re,submitManualCode:G}=Do({apiBase:e,t:p,aliveRef:v,onAdded:r}),ie={setOauthBusy:e=>g({type:`set-oauth-busy`,busy:e}),setOauthMsg:e=>g({type:`set-oauth-msg`,msg:e}),setOauthMsgTone:e=>g({type:`set-oauth-tone`,tone:e}),setOauthUrl:(e,t)=>g({type:`set-oauth-url`,url:e,providerId:t}),setManualCode:e=>g({type:`set-manual-code`,code:e}),setManualCodeMsg:e=>g({type:`set-manual-code-msg`,msg:e}),setManualCodeOk:e=>g({type:`set-manual-code-msg`,msg:V,ok:e})},oe=k?t.includes(k.name.trim())&&k.name.trim()!==``:!1,se=e=>{if(!M){if(Q(e)){g({type:`set-oauth-tos-pending`,providerId:e});return}re(e,ie)}},ce=e=>{G(e,R,B,{setManualCodeBusy:e=>g({type:`set-manual-code-busy`,busy:e}),setManualCode:e=>g({type:`set-manual-code`,code:e}),setManualCodeOk:e=>g({type:`set-manual-code-msg`,msg:V,ok:e}),setManualCodeMsg:e=>g({type:`set-manual-code-msg`,msg:e})})},le=O?.id===`custom`,ue=k?.authMode===`local`,de=O?Ka(O):!1;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":p(`modal.add`),className:`modal-overlay`,onClick:n,children:(0,z.jsxs)(`div`,{ref:b,className:`modal-card`,onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsx)(`h3`,{children:O?p(`modal.addNamed`,{label:O.label}):p(`modal.add`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon`,"aria-label":p(`common.close`),onClick:n,children:(0,z.jsx)(ae,{})})]}),O?k&&(O.auth===`oauth`&&k.authMode===`oauth`?(0,z.jsx)(Co,{preset:O,oauthSupported:w,oauthBusy:M,oauthMsg:N,oauthMsgTone:P,oauthUrl:L===O.oauthProvider?F:``,manualCode:R,manualCodeBusy:B,manualCodeMsg:V,manualCodeOk:H,onRequestLogin:se,onUseApiKeyInstead:()=>{g({type:`use-api-key-instead`,form:{...k,authMode:`key`}})},onManualCodeChange:e=>g({type:`set-manual-code`,code:e}),onSubmitManualCode:e=>{ce(e)},onBack:()=>g({type:`back`})}):(0,z.jsx)(To,{preset:O,form:k,endpointChoice:U,error:j,saving:A,dup:oe,isCustom:le,isLocal:ue,isReservedForward:de,presetDescription:ee,onFormChange:e=>g({type:`set-form`,form:e}),onEndpointChoiceChange:e=>g({type:`set-endpoint-choice`,choice:e}),onSubmit:()=>{ne()},onUseOauthLogin:()=>g({type:`use-oauth-login`,form:{...k,authMode:`oauth`}}),onBack:()=>g({type:`back`})})):(0,z.jsx)(So,{presets:T,usageRank:D,presetsLoading:E,initialTier:i,onSelectPreset:e=>te(e),onSelectCustom:()=>te(m[0]),accountRows:o,accountStatus:s,busyProvider:c,onLogin:l,onCancelLogin:u,onLogout:d})]})}),W&&(0,z.jsx)(mo,{providerId:W,providerLabel:O?.label??W,onCancel:()=>g({type:`set-oauth-tos-pending`,providerId:null}),onContinue:()=>{let e=W;e&&(g({type:`set-oauth-tos-pending`,providerId:null}),re(e,ie))}},W)]})}function jo({apiBase:e,config:t,adding:n,addIntent:r,busy:i,addModalAccountRows:a,accountLoginStatus:o,removeConfirmName:s,removeDefaultProvider:c,codexLoginOpen:l,jsonLeaveOpen:u,jsonSaving:d,oauthTosPending:f,onCloseAdd:p,onAdded:m,onAccountLogin:h,onAccountCancelLogin:g,onAccountLogout:_,onOpenAdd:v,onCloseCodexLogin:y,onCodexAdded:b,onCancelRemove:x,onConfirmRemove:S,onCancelJsonLeave:C,onDiscardJson:w,onSaveJson:T,onCancelOauthTos:E,onContinueOauthTos:D}){return(0,z.jsxs)(z.Fragment,{children:[n&&(0,z.jsx)(Ao,{apiBase:e,existingNames:Object.keys(t.providers),initialTier:r?.tier,initialCustom:r?.custom,onClose:p,onAdded:m,accountRows:a,accountStatus:o,accountBusy:i,onAccountLogin:h,onAccountCancelLogin:g,onAccountLogout:_,onOpen:v}),l&&(0,z.jsx)(Ti,{apiBase:e,onClose:y,onAdded:b}),s&&(0,z.jsx)(za,{providerName:s,defaultProviderName:c,onCancel:x,onConfirm:S}),u&&C&&w&&T&&(0,z.jsx)(Ba,{saving:d??!1,onCancel:C,onDiscard:w,onSave:T}),f&&(0,z.jsx)(mo,{providerId:f.provider,providerLabel:so(f.provider),onCancel:E,onContinue:D},`${f.provider}:${f.addAccount?`add`:`login`}`)]})}function Mo(e,t,n){return[...Wa(e.providers).map(e=>({id:e,label:vr(e,n),kind:`codex`,href:`#codex-auth`})),...t.toSorted((e,t)=>e.localeCompare(t)).map(e=>({id:e,label:so(e),kind:`oauth`}))]}function No(e,t){let n={...t},r=t.openai;if(r)for(let[t,i]of Object.entries(e.providers))i.authMode===`forward`&&(n[t]=r);return n}function Po({apiBase:e}){let t=K(),n=`ocx.providers.config.v1:${e}`,[r,i]=(0,_.useState)(()=>Y(n)),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)([]),[p,m]=(0,_.useState)({}),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(null),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(0),[A,j]=(0,_.useState)(null),M=(0,_.useRef)(!0),N=(0,_.useRef)(null),P=(0,_.useRef)(!1),F=(0,_.useRef)(new Map),L=(0,_.useCallback)((e,t=!0)=>{c(e),u(t)},[]);(0,_.useEffect)(()=>(M.current=!0,()=>{M.current=!1}),[]),I(`add-provider-presets:${e}`,[e],async t=>{let n=await fetch(`${e}/api/provider-presets`,{signal:t});if(!n.ok)throw Error(String(n.status));let r=await n.json();return Array.isArray(r.providers)&&r.providers.length>0?r.providers:null}),I(`add-provider-usage:${e}`,[e],async t=>{let n=await fetch(`${e}/api/usage?range=30d`,{signal:t});if(!n.ok)return{};let r=await n.json(),i={};for(let e of r.providers??[])i[e.provider]=e.requests;return i});let[R,B]=(0,_.useState)({epoch:0,force:!1}),{fetchConfig:V,fetchOauth:H,fetchProviderQuotas:U}=po({apiBase:e,t,setConfig:i,setOauthProviders:f,setOauthStatus:m,notify:L,invalidateProviderQuotas:(0,_.useCallback)((e=!1)=>{B(t=>({epoch:t.epoch+1,force:e}))},[]),configCacheKey:n}),W=Ii(e),ee=W.activeNeedsReauth,te=(0,_.useMemo)(()=>{let e=W.accounts;if(e.length===0&&W.loadState===`loading`)return p;let t=e.find(e=>e.isMain)??e[0],n=!!t&&!!t.email&&t.email!==`Codex App login`,r=e.some(e=>!e.isMain&&(e.hasCredential||e.email)),i=n||r,a=n?t?.email:e.find(e=>!e.isMain&&e.email)?.email??void 0;return{...p,openai:{loggedIn:i,...a?{email:a}:{},...ee?{needsReauth:!0}:{}}}},[p,W.accounts,W.loadState,ee]),{accountSets:ne,accountLoadStates:re,switchingAccount:G,keyPools:ie,fetchAccountSets:ae,switchAccount:se,switchApiKey:ce,removeApiKey:le,addApiKeyValue:ue,editCredentialAlias:de,removeAccount:fe,activeAccountNeedsReauth:pe}=io({apiBase:e,t,config:r,oauthStatus:te,aliveRef:M,notify:L,fetchConfig:V,fetchOauth:H,fetchProviderQuotas:U,codexActiveNeedsReauth:ee}),{draft:me,setDraft:he,jsonEditorOpen:ge,jsonSaving:_e,jsonLeaveOpen:ve,saveConfig:ye,openJsonEditor:be,discardJsonEditor:xe,requestCloseJsonEditor:Se,restoreJsonEditor:Ce,jsonIsDirty:we,setJsonLeaveOpen:Te}=ao({apiBase:e,config:r,notify:L,fetchConfig:V,fetchProviderQuotas:U,onSaved:()=>k(e=>e+1),t});(0,_.useEffect)(()=>{N.current!==e&&(N.current=e,Promise.resolve().then(()=>{V(),H()}))},[e,V,H]);let Ee=()=>k(e=>e+1),{cancelLoginOAuth:De,loginOAuth:Oe,logoutOAuth:ke}=co({apiBase:e,t,aliveRef:M,oauthLoginGenerationRef:F,accountSets:ne,setBusy:g,setStatus:c,setLoginInfo:y,setOauthStatus:m,notify:L,fetchConfig:V,fetchOauth:H,fetchAccountSets:ae,fetchProviderQuotas:U,bumpModelsRefresh:Ee}),{removeProvider:Ae,confirmRemoveProvider:je,setProviderDisabled:Me,setDefaultProvider:Ne,updateProvider:Pe}=fo({apiBase:e,t,removeBusyRef:P,workspaceSelected:b,setWorkspaceSelected:x,setRemoveConfirmName:T,notify:L,fetchConfig:V,fetchOauth:H,fetchProviderQuotas:U}),Fe=(e,t=!1)=>{if(h!==e){if(Q(e)){j({provider:e,addAccount:t});return}Oe(e,t)}};if(!r)return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:t(`nav.providers`)})}),s?(0,z.jsx)(q,{tone:`err`,children:s}):(0,z.jsxs)(`div`,{className:`providers-workspace providers-workspace--boot`,"aria-busy":`true`,children:[(0,z.jsx)(`div`,{className:`providers-workspace-rail providers-workspace-rail--boot`,"aria-hidden":`true`}),(0,z.jsx)(`div`,{className:`providers-workspace-main`,children:(0,z.jsxs)(`p`,{className:`muted`,children:[(0,z.jsx)(`span`,{className:`spin`,"aria-hidden":`true`}),` `,t(`prov.loadingConfig`)]})})]})]});let Ie=Mo(r,d,t),Le=No(r,te),Re=e=>r.providers[e]?.authMode===`forward`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`page-head`,children:[(0,z.jsx)(`h2`,{children:t(`nav.providers`)}),(0,z.jsx)(`div`,{className:`row`,children:(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>o(!0),children:[(0,z.jsx)(oe,{}),t(`prov.add`)]})})]}),s&&(0,z.jsx)(q,{tone:l?`ok`:`err`,children:s}),(0,z.jsx)(Xr,{onRemoveProvider:Ae,providers:r.providers,apiBase:e,defaultProvider:r.defaultProvider,selectedName:b,onSelect:x,onAddProvider:e=>{C(e??null),o(!0)},onEditConfig:be,jsonEditor:{open:ge,draft:me,isDirty:we,onDraftChange:he,onSave:()=>ye(),onClose:Se,onRestore:Ce},jsonSaving:_e,modelsRefreshToken:O,activeAccountNeedsReauth:pe,quotaRefreshEpoch:R.epoch,quotaForceRefresh:R.force,detail:(t,n)=>{let i=Le[t.name]??p[t.name];return(0,z.jsx)(Va,{item:t,usageTotals:n.usageTotals,modelUsage:n.modelUsage,quotaReport:n.quotaReport,availableModels:n.availableModels,hasLiveModels:n.hasLiveModels,selectedModels:n.selectedModels,modelsLoading:n.modelsLoading,modelsLoadFailed:n.modelsLoadFailed,onRetryModels:n.onRetryModels,oauthEmail:i?.email,onDeselect:()=>x(null),apiBase:e,oauth:i,accounts:ne[t.name]?.accounts??[],keys:ie[t.name]??[],accountLoadState:re[t.name]??(t.authMode===`oauth`?`idle`:`ready`),switchingAccountId:G?.provider===t.name?G.accountId:null,busyProvider:h,loginHint:v,authHandlers:{onLogin:Fe,onCancelLogin:De,onLogout:ke,onReauth:(e,t)=>Oe(e,!0,t),onSwitchAccount:se,onRemoveAccount:fe,onRetryAccounts:async e=>{await ae([e])},onAddApiKey:ue,onSwitchApiKey:ce,onRemoveApiKey:le,onEditAlias:de},isDefault:t.name===r.defaultProvider,onRemoveProvider:Ae,onSetDisabled:Me,onSetDefault:e=>{Ne(e)},onUpdateProvider:Pe,codexController:W},t.name)}}),(0,z.jsx)(jo,{apiBase:e,config:r,adding:a,addIntent:S,busy:h,addModalAccountRows:Ie,accountLoginStatus:Le,removeConfirmName:w,removeDefaultProvider:w===r.defaultProvider?Object.entries(r.providers).find(([e,t])=>e!==w&&t.disabled!==!0)?.[0]??null:null,codexLoginOpen:E,jsonLeaveOpen:ve,jsonSaving:_e,oauthTosPending:A,onCloseAdd:()=>{h&&De(h),o(!1),C(null)},onAdded:e=>{o(!1),C(null),L(t(`prov.added`,{name:e,cmd:`ocx sync`}),!0),V(),H(),U(!0),Ee()},onAccountLogin:async n=>{if(n===`openai`){if(h===`openai`)return;let n=r.providers.openai,i=Ga(n);if(i===`invalid`){L(t(`codexAuth.openaiMissing`),!1);return}if(i===`absent`||i===`disabled`){g(`openai`);try{await Qa(e,i),await V()}catch(e){e instanceof Za?L(t(e.i18nKey),!1):L(e instanceof Error?e.message:t(`prov.saveFailed`),!1);return}finally{M.current&&g(e=>e===`openai`?null:e)}}D(!0);return}if(Re(n)){D(!0);return}(r.providers[n]?.authMode===`oauth`||d.includes(n))&&Fe(n)},onAccountCancelLogin:e=>{De(e)},onAccountLogout:e=>{ke(e)},onOpenAdd:H,onCloseCodexLogin:()=>D(!1),onCodexAdded:()=>{D(!1),L(t(`prov.loginOk`,{provider:vr(`openai`,t),cmd:`ocx sync`}),!0),V(),H(),U(!0),Ee()},onCancelRemove:()=>T(null),onConfirmRemove:()=>{je(w)},onCancelJsonLeave:()=>{_e||Te(!1)},onDiscardJson:xe,onSaveJson:()=>{ye()},onCancelOauthTos:()=>j(null),onContinueOauthTos:()=>{let e=A;e&&(j(null),Oe(e.provider,e.addAccount))}})]})}var Fo={"gpt-5.6-sol":Te,"gpt-5.6-terra":Oe,"gpt-5.6-luna":Ee},Io={width:14,height:14,flexShrink:0,verticalAlign:`text-bottom`};function Lo(e){return e.slice(e.lastIndexOf(`/`)+1)}function Ro(e){return Fo[e]??Fo[Lo(e)]??null}function zo(e){let t=Ro(e);return t?(0,_.createElement)(`span`,{className:`model-label`},(0,_.createElement)(t,{style:Io,"aria-hidden":!0}),e):e}var Bo=[`low`,`medium`,`high`,`xhigh`,`max`,`ultra`];function Vo(e,t){let n=e.filter(e=>e.provider.trim()&&e.model.trim());if(n.length===0)return[...Bo];let r=new Set(Bo),i=null;for(let e of n){let n=`${e.provider.trim()}/${e.model.trim()}`,a=t.get(n),o=a===void 0?[]:a.filter(e=>r.has(e));if(i===null)i=o;else{let e=new Set(o);i=i.filter(t=>e.has(t))}}let a=new Set(i??[]);return Bo.filter(e=>a.has(e))}var Ho=0;function Uo(e={}){return{provider:e.provider??``,model:e.model??``,...e.weight===void 0?{}:{weight:e.weight},clientKey:e.clientKey??`ct-${++Ho}`}}var Wo=/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$/,Go=/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}(\/[a-zA-Z0-9][a-zA-Z0-9._-]{0,63})?$/,Ko=/^(?:gpt-|o1-|o3-|o4-|codex-)/;function qo(e){return Wo.test(e.trim())}function Jo(e){return`combo/${e.trim()}`}function Yo(e,t){return(typeof t==`string`?t.trim():``)||Jo(e)}function Xo(e){return typeof e==`string`&&e.trim()?e.trim():null}function Zo(e){return e===`round-robin`?`round-robin`:`failover`}function Qo(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=100?e:1}function $o(e){return typeof e==`string`&&Bo.includes(e)?e:null}function es(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=1e4?e:void 0}function ts(e){if(!e||typeof e!=`object`)return[];let t=e.combos;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e,r=typeof t.id==`string`?t.id.trim():``;if(!r)continue;let i=Array.isArray(t.targets)?t.targets:[],a=[];for(let e of i){if(!e||typeof e!=`object`)continue;let t=e,n=typeof t.provider==`string`?t.provider.trim():``,r=typeof t.model==`string`?t.model.trim():``;if(!n||!r)continue;let i=es(t.weight);a.push(Uo(i===void 0?{provider:n,model:r}:{provider:n,model:r,weight:i}))}n.push({id:r,model:typeof t.model==`string`&&t.model.trim()?t.model.trim():Yo(r,Xo(t.alias)),alias:Xo(t.alias),strategy:Zo(t.strategy),stickyLimit:Qo(t.stickyLimit),defaultEffort:$o(t.defaultEffort),targets:a})}return n.sort((e,t)=>e.id.localeCompare(t.id,void 0,{sensitivity:`base`}))}function ns(e){let t=[],n=[];for(let r of e)r.strategy===`round-robin`?n.push(r):t.push(r);return{failover:t,roundRobin:n}}function rs(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.id.toLowerCase().includes(n)||e.model.toLowerCase().includes(n)?!0:e.targets.some(e=>e.provider.toLowerCase().includes(n)||e.model.toLowerCase().includes(n))):e}function is(e,t={}){let n=[],r=t.cataloguedComboIds;for(let t of e)t.targets.length===0?n.push({id:t.id,model:t.model,reason:`empty-targets`}):t.targets.length<2&&n.push({id:t.id,model:t.model,reason:`few-targets`}),r&&t.targets.length>0&&!r.has(t.id)&&n.push({id:t.id,model:t.model,reason:`catalog-omitted`});return n}function as(e,t){return e.id!==t.id||e.alias!==t.alias||e.strategy!==t.strategy||e.stickyLimit!==t.stickyLimit||e.defaultEffort!==t.defaultEffort||e.targets.length!==t.targets.length?!1:e.targets.every((e,n)=>{let r=t.targets[n];return e.provider===r.provider&&e.model===r.model&&(e.weight??1)===(r.weight??1)})}function os(e,t={}){return{id:e.id.trim(),...t.renameFrom?{renameFrom:t.renameFrom}:{},combo:{targets:e.targets.map(t=>e.strategy===`round-robin`?{provider:t.provider.trim(),model:t.model.trim(),weight:t.weight??1}:{provider:t.provider.trim(),model:t.model.trim()}),strategy:e.strategy,defaultEffort:e.defaultEffort,...e.strategy===`round-robin`?{stickyLimit:e.stickyLimit}:{},...e.alias&&e.alias.trim()?{alias:e.alias.trim()}:{}}}}function ss(e,t){let n=e.id.trim();if(!n)return`missingId`;if(!qo(n))return`invalidId`;if(t.existingIds.includes(n))return`duplicateId`;if(Object.hasOwn(t.providers,`combo`))return`reservedNamespace`;if(Object.hasOwn(t.providers,n))return`providerCollision`;let r=e.alias?.trim()??``;if(r){if(!Go.test(r))return`invalidAlias`;if(r===`combo`||r.startsWith(`combo/`))return`aliasReservedNamespace`;if(!r.includes(`/`)&&Ko.test(r))return`aliasNativeFamily`;if((t.existingAliases??[]).includes(r))return`duplicateAlias`}if(e.targets.length<1)return`noTargets`;for(let n of e.targets){if(!n.provider.trim()||!n.model.trim())return`incompleteTarget`;if(!Object.hasOwn(t.providers,n.provider.trim()))return`unknownProvider`}let i=new Set;for(let t of e.targets){let e=`${t.provider.trim()}/${t.model.trim()}`;if(i.has(e))return`duplicateTarget`;i.add(e)}if(e.strategy===`round-robin`){if(!Number.isInteger(e.stickyLimit)||e.stickyLimit<1||e.stickyLimit>100)return`invalidStickyLimit`;for(let t of e.targets){let e=t.weight??1;if(!Number.isInteger(e)||e<1||e>1e4)return`invalidWeight`}}return e.targets.some(e=>t.providers[e.provider.trim()]?.disabled!==!0)?null:`noEnabledTarget`}function cs(e=``){return{id:e,model:e?Jo(e):`combo/`,alias:null,strategy:`failover`,stickyLimit:1,defaultEffort:null,targets:[Uo()]}}function ls(e,t,n){if(!n)return{kind:`disabled`,data:void 0,error:void 0,showSkeleton:!1,refreshing:!1,showError:!1};let r=e.data!==void 0,i=!e.lastAttemptOk&&e.error!==void 0;return e.refreshing?r?{kind:`loading-with-stale-data`,data:e.data,error:e.error,showSkeleton:!1,refreshing:!0,showError:i}:{kind:i?`retrying-cold`:`cold`,data:void 0,error:i?e.error:void 0,showSkeleton:!0,refreshing:!0,showError:!1}:i?r?{kind:`failed-with-stale`,data:e.data,error:e.error,showSkeleton:!1,refreshing:!1,showError:!0}:{kind:`failed-cold`,data:void 0,error:e.error,showSkeleton:!1,refreshing:!1,showError:!0}:r?{kind:t(e.data)?`ready-empty`:`ready-populated`,data:e.data,error:void 0,showSkeleton:!1,refreshing:!1,showError:!1}:{kind:`cold`,data:void 0,error:void 0,showSkeleton:!0,refreshing:!1,showError:!1}}function us(e,t,n,r){let{isEmpty:i,...a}=r,o=I(e,t,n,a);return{...o,state:ls(o,i,r.enabled!==!1)}}function ds({className:e,style:t}){return(0,z.jsx)(`span`,{"aria-hidden":`true`,className:e?`data-surface-skeleton__block ${e}`:`data-surface-skeleton__block`,style:t})}function fs({label:e,rows:t=3,className:n}){let r=Math.max(1,Math.floor(t));return(0,z.jsxs)(`div`,{className:n?`data-surface-skeleton ${n}`:`data-surface-skeleton`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,"aria-busy":`true`,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:e}),Array.from({length:r},(e,t)=>(0,z.jsx)(`div`,{className:`data-surface-skeleton__row`,"aria-hidden":`true`,children:(0,z.jsx)(ds,{})},t))]})}function ps({children:e,busy:t=!0,live:n=!0,className:r}){return(0,z.jsxs)(`div`,{className:r?`data-surface-status ${r}`:`data-surface-status`,role:n?`status`:void 0,"aria-live":n?`polite`:void 0,"aria-atomic":n?`true`:void 0,"aria-busy":t||void 0,children:[t&&(0,z.jsx)(`span`,{className:`spin`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:e})]})}function ms(e,t){let n=new Map;for(let t of e){let e=n.get(t.provider);e?e.push(t):n.set(t.provider,[t])}let r=new Map(t.map(e=>[e.name,e]));for(let e of t){if(e.disabled===!0){n.delete(e.name);continue}e.authMode!==`forward`&&(n.has(e.name)||n.set(e.name,[]))}return[...n.entries()].map(([e,t])=>{let n=r.get(e);return{provider:e,rows:t,native:t.length>0&&t.every(e=>e.native===!0),liveModels:n?.liveModels!==!1,configuredModels:n?.models??[],discovery:n?.discovery}}).sort((e,t)=>e.native===t.native?e.provider.localeCompare(t.provider):e.native?-1:1)}function hs(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function gs(e){if(!Array.isArray(e)||e.some(e=>typeof e!=`string`))throw Error(`invalid model list`);return[...new Set(e)]}function _s(e){if(!hs(e))throw Error(`invalid selected models response`);let t=e.selected;if(!hs(t))throw Error(`invalid selected models response`);return Object.fromEntries(Object.entries(t).map(([e,t])=>[e,gs(t)]))}async function vs(e,t=fetch){let n=await t(`${e}/api/selected-models`);if(!n.ok)throw Error(`selected models HTTP ${n.status}`);return _s(await n.json())}function ys(e,t,n,r=!1){if(r)return!0;let i=e[t];return!i||i.length===0||i.includes(n)}function bs(e,t,n,r,i){return ys(e,t,n,r)&&!i}async function xs(e,t,n,r,i,a=fetch){return a(`${e}/api/model-visibility`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({scope:t,provider:n,targets:r,enabled:i})})}function Ss(e,t){return e===t}function Cs(e,t){switch(t.reason){case`http`:return e(`models.discoveryFailedHttp`,{status:t.httpStatus});case`blocked`:return e(`models.discoveryFailedBlocked`);case`invalid_response`:return e(`models.discoveryFailedInvalidResponse`);case`network`:return e(`models.discoveryFailedNetwork`);case`provider`:return e(`models.discoveryFailedProvider`);default:return e(`models.discoveryFailedGeneric`)}}var ws=Array.from({length:18},(e,t)=>1e5+t*5e4),Ts=new Set(ws),Es=`custom`,Ds=[4,8,16,32,64,128,256,500,1e3],Os=new Set(Ds),ks=`ocx-models-collapsed:v2`,As=`ocx-models-combos-open:v1`;function js(e){return!Number.isFinite(e)||e<=0?String(e):e%1e3==0?`${e/1e3}k`:e.toLocaleString()}function Ms(e){let t=new Set;for(let n of e)n.disabled&&t.add(n.namespaced);return t}function Ns(e,t,n){let r=[];for(let i of e){let e=t.has(i.id)||t.has(i.namespaced);bs(n,i.provider,i.id,i.native===!0,e)&&r.push({value:i.namespaced,label:i.namespaced})}return r}function Ps(e=localStorage){try{let t=e.getItem(ks);if(t===null)return null;let n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(e=>typeof e==`string`)):null}catch{return null}}function Fs(e,t=localStorage){try{t.setItem(ks,JSON.stringify([...e]))}catch{}}function Is(e=localStorage){try{return(e.getItem(`ocx-models-combos-open:v1`)??e.getItem(`ocx-models-combos-open`))===`1`}catch{return!1}}function Ls(e,t=localStorage){try{t.setItem(As,e?`1`:`0`)}catch{}}function Rs({liveModels:e,discovery:t,showFailureBadge:n=!0}){let r=K(),i=e&&t?.status===`failed`?t:void 0;return(0,z.jsxs)(`div`,{className:`row muted text-label leading-body`,role:`status`,style:{alignItems:`flex-start`,gap:8,padding:`6px 0`},children:[(0,z.jsx)(fe,{width:15,height:15,"aria-hidden":`true`,style:{flexShrink:0,marginTop:2}}),(0,z.jsxs)(`span`,{children:[i&&n&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`badge badge-amber`,children:r(`models.discoveryFailedBadge`)}),` `]}),i?`${Cs(r,i)} `:`${r(e?`models.emptyDiscovery`:`models.emptyDiscoveryDisabled`)} `,(0,z.jsx)(`a`,{href:`#providers`,children:r(`models.openProviderSettings`)})]})]})}function zs(e){return Array.isArray(e)?ts({combos:e}):null}function Bs({apiBase:e}){let t=K(),n=`ocx.models.catalog.v1:${e}`,r=(0,_.useMemo)(()=>Y(n),[n]),[i,a]=(0,_.useState)(()=>r?.models??[]),[o,s]=(0,_.useState)(()=>r?.providers??[]),[c,l]=(0,_.useState)(()=>new Set(r?.disabled??[])),[u,d]=(0,_.useState)(()=>r?.selectedModels??null),[f,p]=(0,_.useState)({}),[m,h]=(0,_.useState)({}),[g,v]=(0,_.useState)(()=>r?.contextCaps??{}),[y,b]=(0,_.useState)(()=>r?.contextCapValue??35e4),[x,S]=(0,_.useState)(``),[C,w]=(0,_.useState)(!1),T=Ps(),[E,D]=(0,_.useState)(()=>T??new Set),O=(0,_.useRef)(T===null),[k,A]=(0,_.useState)(``),[j,M]=(0,_.useState)(!1),[N,P]=(0,_.useState)(!1),F=(0,_.useRef)(!1),I=(0,_.useRef)(0),R=(0,_.useRef)(!1),[B,V]=(0,_.useState)(null),[H,W]=(0,_.useState)(!1),[ee,te]=(0,_.useState)(``),ne=(0,_.useRef)(!1),[re,G]=(0,_.useState)(``),[ie,ae]=(0,_.useState)(!1),[oe,se]=(0,_.useState)(!1),[ce,le]=(0,_.useState)(!1),[ue,de]=(0,_.useState)(`add`),[pe,me]=(0,_.useState)(``),[he,ge]=(0,_.useState)(``),[ve,ye]=(0,_.useState)(``),[be,xe]=(0,_.useState)(``),[Se,Ce]=(0,_.useState)(``),[we,Te]=(0,_.useState)(!1),[Ee,De]=(0,_.useState)([`text`]),[Oe,ke]=(0,_.useState)(!1),[je,Me]=(0,_.useState)(``),[Ne,Pe]=(0,_.useState)(null),Fe=(0,_.useRef)(null),[Ie,Le]=(0,_.useState)(null),[Re,ze]=(0,_.useState)(!1),Be=`ocx.models.combos.v1:${e}`,Ve=(0,_.useMemo)(()=>{let t=zs(Y(Be));return t===null?zs(Y(`ocx.combos.workspace.v1:${e}`)?.combos):t},[e,Be]),He=us(`models-combos:${e}`,[e],async t=>{let n=ts(await J(await fetch(`${e}/api/combos`,{signal:t})));return X(Be,n),n},{isEmpty:()=>!1,initialData:Ve??void 0}),Ue=He.state,We=Ue.data??Ve,Ge=Ue.showError,[Ke,qe]=(0,_.useState)(Is),[Je,Ye]=(0,_.useState)(null),Xe=()=>{let e=!Ke;Ls(e),qe(e)};(0,_.useEffect)(()=>()=>{Fe.current&&clearTimeout(Fe.current)},[]);let Ze=(0,_.useMemo)(()=>Ns(i,c,u??{}),[i,c,u]),Qe=(0,_.useCallback)(async()=>{try{let t=await ut(await fetch(`${e}/api/shadow-call-settings`));t&&Le(t)}catch{}},[e]),$e=(0,_.useCallback)(async()=>{if(!ne.current)try{let t=await fetch(`${e}/api/v2`);if(!(t.headers.get(`content-type`)??``).includes(`application/json`)){V(null);return}let n=await ut(t);if(!n||typeof n.enabled!=`boolean`){V(null);return}V({enabled:n.enabled,agentsMaxThreadsConflict:n.agentsMaxThreadsConflict===!0,maxConcurrentThreadsPerSession:typeof n.maxConcurrentThreadsPerSession==`number`?n.maxConcurrentThreadsPerSession:null,multiAgentMode:n.multiAgentMode===`v1`||n.multiAgentMode===`v2`?n.multiAgentMode:`default`})}catch{V(null)}},[e]),et=(0,_.useCallback)(async t=>{let[r,i,a,o]=await Promise.all([fetch(`${e}/api/models`),fetch(`${e}/api/provider-context-caps`),fetch(`${e}/api/providers`),vs(e)]),[s,c,l]=await Promise.all([J(r),J(i),J(a)]);if(s===void 0||c===void 0||l===void 0)throw Error(`models payload missing`);if(t.aborted)throw Error(`models request aborted`);let u=Ms(s),d=typeof c.value==`number`&&Number.isFinite(c.value)&&c.value>0?c.value:typeof c.cap==`number`&&Number.isFinite(c.cap)&&c.cap>0?c.cap:void 0,f=d===void 0?35e4:d,p={models:s,providers:l,selectedModels:o,disabled:[...u],contextCaps:c.caps??{},contextCapValue:f};return X(n,p),p},[e,n]),tt=(0,_.useCallback)(e=>{let t=ms(e.models,e.providers);Ye(e=>e!==null&&!t.some(t=>t.provider===e)?null:e),a(e.models),s(e.providers),l(new Set(e.disabled)),d(e.selectedModels),b(e.contextCapValue),v(e.contextCaps)},[]),nt=us(n,[e],async e=>{let t=await et(e);if(e.aborted)throw Error(`models request aborted`);return tt(t),t},{isEmpty:()=>!1,pollMs:1e4,initialData:r??void 0}),rt=nt.state,ct=(0,_.useCallback)(async(e=!1)=>{if(R.current&&!e)return!1;R.current=!0;let t=++I.current;try{let e=await et(new AbortController().signal);return Ss(t,I.current)?(tt(e),L(n,e),!0):!1}catch{return!1}finally{Ss(t,I.current)&&(R.current=!1)}},[tt,n,et]);(0,_.useEffect)(()=>{let e=window.setTimeout(()=>{Qe(),$e()},0),t=window.setInterval(()=>{ne.current||$e()},1e4);return()=>{window.clearTimeout(e),window.clearInterval(t)}},[Qe,$e]);let lt=(0,_.useMemo)(()=>ms(i,o),[i,o]);(0,_.useEffect)(()=>{if(!O.current||lt.length===0)return;O.current=!1;let e=new Set(lt.map(e=>e.provider));D(e),Fs(e)},[lt]);let dt=(0,_.useMemo)(()=>u?i.filter(e=>bs(u,e.provider,e.id,e.native===!0,c.has(e.namespaced))).length:0,[c,i,u]),ft=async(n,r,i,a)=>{++I.current,P(!0),F.current=!0,A(``);let o=null;try{(await xs(e,n,r,i,a)).ok||(o=`models.saveFailed`)}catch{o=`models.networkError`}finally{let e=await ct(!0);o?(M(!1),A(t(o))):e&&(M(!0),A(t(`models.applied`))),P(!1),F.current=!1}},pt=async n=>{P(!0),F.current=!0,A(``);let r=g[n]!==y;try{let i=await fetch(`${e}/api/provider-context-caps`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:n,enabled:r})});try{v((await J(i,t(`models.capSaveFailed`)))?.caps??{}),M(!0),A(t(`models.capApplied`)),await ct(!0)}catch(e){M(!1),A(e instanceof Error?e.message:t(`models.capSaveFailed`))}}catch{M(!1),A(t(`models.networkError`))}finally{P(!1),F.current=!1}},mt=e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),Fs(n),n})},ht=e=>{D(()=>{let t=e?new Set(lt.map(e=>e.provider)):new Set;return Fs(t),t})},gt=async n=>{P(!0),F.current=!0,A(``);try{let r=await fetch(`${e}/api/provider-context-caps`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});try{let e=await J(r,t(`models.capSaveFailed`));typeof e?.value==`number`&&Number.isFinite(e.value)&&e.value>0&&b(e.value),v(e?.caps??{}),M(!0),A(t(`models.capApplied`)),await ct(!0)}catch(e){M(!1),A(e instanceof Error?e.message:t(`models.capSaveFailed`))}}catch{M(!1),A(t(`models.networkError`))}finally{P(!1),F.current=!1}},_t=e=>{!Number.isFinite(e)||e<=0||gt({value:Math.floor(e)})},vt=e=>{if(e===`custom`){w(!0),S(String(y));return}w(!1);let t=Number(e);Number.isFinite(t)&&t>0&&t!==y&&_t(t)},yt=()=>{let e=Number(x.replace(/[_,\s]/g,``));if(!Number.isFinite(e)||e<=0){M(!1),A(t(`models.capSaveFailed`));return}w(!1),_t(e)},bt=(0,_.useMemo)(()=>{let e=lt.filter(e=>!e.native&&e.rows.length>0);return e.length>0&&e.every(e=>g[e.provider]===y)},[lt,g,y]),xt=()=>{gt({setAll:!bt})},St=async t=>{if(!(!Ie||Re)){ze(!0),Le({...Ie,...t});try{await fetch(`${e}/api/shadow-call-settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}finally{ze(!1)}}},Ct=async n=>{if(!(!B||ne.current)&&B.multiAgentMode!==n){W(!0),ne.current=!0,te(``),A(``);try{let r=await fetch(`${e}/api/v2`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({multiAgentMode:n})});try{let e=await J(r,t(`models.saveFailed`));$e(),M(!0),A(t(`models.v2Applied`)),te((e?.warnings??[]).join(` `))}catch(e){M(!1),A(e instanceof Error?e.message:t(`models.saveFailed`))}}catch{M(!1),A(t(`models.networkError`))}finally{W(!1),ne.current=!1}}},wt=async n=>{if(!(!B||ne.current)){if(!Number.isInteger(n)||n<1){M(!1),A(t(`models.v2ThreadsInvalid`));return}if(B.maxConcurrentThreadsPerSession!==n){W(!0),ne.current=!0,te(``),A(``);try{let r=await fetch(`${e}/api/v2`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({maxConcurrentThreadsPerSession:n})});try{let e=await J(r,t(`models.saveFailed`));if(!e||typeof e.enabled!=`boolean`){M(!1),A(t(`models.saveFailed`));return}V({enabled:e.enabled,agentsMaxThreadsConflict:e.agentsMaxThreadsConflict===!0,maxConcurrentThreadsPerSession:typeof e.maxConcurrentThreadsPerSession==`number`?e.maxConcurrentThreadsPerSession:null,multiAgentMode:e.multiAgentMode===`v1`||e.multiAgentMode===`v2`?e.multiAgentMode:`default`}),M(!0),A(t(`models.v2ThreadsApplied`)),ae(!1)}catch(e){M(!1),A(e instanceof Error?e.message:t(`models.saveFailed`))}}catch{M(!1),A(t(`models.networkError`))}finally{W(!1),ne.current=!1}}}},Tt=e=>{if(e===`custom`){ae(!0),G(String(B?.maxConcurrentThreadsPerSession??``));return}ae(!1),wt(Number(e))},Et=(e,t)=>{Fe.current&&clearTimeout(Fe.current),Fe.current=setTimeout(()=>{Pe({namespaced:e,rect:t.getBoundingClientRect()})},300)},Dt=(e,t)=>{Fe.current&&clearTimeout(Fe.current),Pe({namespaced:e,rect:t.getBoundingClientRect()})},At=()=>{Fe.current&&clearTimeout(Fe.current),Fe.current=setTimeout(()=>Pe(null),120)},jt=()=>{Fe.current&&clearTimeout(Fe.current)},Mt=async(n,r,i,a,o)=>{ke(!0),Me(``);try{let s=await fetch(`${e}/api/custom-models`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:n,modelId:r,displayName:i,contextWindow:a,inputModalities:o})});try{await J(s,t(`models.customSaveFailed`)),le(!1),M(!0),A(t(`models.customAdded`)),await ct(!0)}catch(e){Me(e instanceof Error?e.message:t(`models.customSaveFailed`))}}catch{Me(t(`models.networkError`))}finally{ke(!1)}},Nt=async(n,r)=>{ke(!0),Me(``);try{let i=await fetch(`${e}/api/custom-models/${encodeURIComponent(n)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});try{await J(i,t(`models.customSaveFailed`)),le(!1),M(!0),A(t(`models.customUpdated`)),await ct(!0)}catch(e){Me(e instanceof Error?e.message:t(`models.customSaveFailed`))}}catch{Me(t(`models.networkError`))}finally{ke(!1)}},Pt=async n=>{try{(await fetch(`${e}/api/custom-models/${encodeURIComponent(n)}`,{method:`DELETE`})).ok?(M(!0),A(t(`models.customDeleted`)),await ct(!0)):(M(!1),A(t(`models.customSaveFailed`)))}catch{M(!1),A(t(`models.networkError`))}},Ft=rt.data??r;if(rt.showSkeleton&&!Ft)return(0,z.jsx)(fs,{label:t(`models.loading`),rows:5});if(rt.kind===`failed-cold`)return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(q,{tone:`err`,children:rt.error instanceof Error?rt.error.message:t(`models.loadFail`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>nt.refresh(),children:t(`common.retry`)})]});let It=u??{},Lt=e=>{let{provider:n,rows:r,native:i,liveModels:a,discovery:o}=e,s=E.has(n),l=e=>bs(It,n,e.id,e.native===!0,c.has(e.namespaced)),u=r.filter(l).length,d=g[n]===y,_=i,v=a&&o?.status===`failed`?o:void 0,b=(f[n]??``).trim().toLowerCase(),x=b?r.filter(e=>e.id.toLowerCase().includes(b)):r,S=x.toSorted((e,t)=>Number(!l(e))-Number(!l(t))),C=m[n]??60,w=S.slice(0,C),T=x.length-w.length,D=r.length>0,O=!D||r.every(l),k=!D||r.every(e=>!l(e)),A=e=>{D&&ft(`provider`,n,r.map(e=>({id:e.id,native:e.native===!0})),e)};return(0,z.jsxs)(`div`,{className:`card models-provider-card`,children:[(0,z.jsxs)(`div`,{className:`row group-head models-provider-head${s?``:` open`}`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`row models-provider-toggle`,onClick:()=>mt(n),"aria-expanded":!s,style:{flex:1,border:0,background:`transparent`,padding:0,color:`inherit`,cursor:`pointer`,textAlign:`left`},children:[(0,z.jsx)(_e,{style:{width:14,height:14,color:`var(--muted)`,transform:s?`none`:`rotate(90deg)`,transition:`transform .12s`}}),(0,z.jsx)(`span`,{className:`text-body font-semibold`,children:n}),_&&(0,z.jsx)(`span`,{className:`models-chip muted mono text-caption`,children:t(`models.nativeGroupLabel`)}),v&&(0,z.jsx)(`span`,{className:`badge badge-amber`,role:`status`,title:Cs(t,v),children:t(`models.discoveryFailedBadge`)}),(0,z.jsx)(`span`,{className:`muted mono text-label`,children:t(`models.active`,{active:u,total:r.length})})]}),(0,z.jsxs)(`div`,{className:`row models-provider-actions`,children:[!_&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:e=>{e.stopPropagation(),de(`add`),me(n),ge(``),ye(``),xe(``),Ce(``),Te(!1),De([`text`]),Me(``),le(!0)},"aria-label":t(`models.customAdd`),"aria-haspopup":`dialog`,children:`+`}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,disabled:N||O,onClick:()=>A(!0),children:t(`models.allOn`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,disabled:N||k,onClick:()=>A(!1),children:t(`models.allOff`)}),!_&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(it,{on:d,onClick:()=>pt(n),disabled:N,label:t(`models.capValue`,{value:js(y)})}),(0,z.jsx)(`span`,{className:`muted mono text-label`,children:t(`models.capValue`,{value:js(y)})})]})]})]}),!s&&(0,z.jsxs)(`div`,{className:`models-provider-body`,children:[_&&(0,z.jsx)(`p`,{className:`muted text-label models-provider-hint`,children:t(`models.nativeHint`)}),r.length===0&&(0,z.jsx)(Rs,{liveModels:a,discovery:o,showFailureBadge:!1}),r.length>60/2&&(0,z.jsx)(`input`,{className:`input`,placeholder:t(`models.search`),value:f[n]??``,onChange:e=>p(t=>({...t,[n]:e.target.value})),"aria-label":t(`models.search`)}),w.map(e=>{let r=!l(e);return(0,z.jsxs)(`div`,{className:`model-row-wrap`,onMouseEnter:t=>Et(e.namespaced,t.currentTarget),onMouseLeave:At,onFocus:t=>Dt(e.namespaced,t.currentTarget),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||Pe(null)},children:[(0,z.jsxs)(`div`,{className:`row models-model-row`,children:[(0,z.jsx)(it,{on:!r,onClick:()=>void ft(`models`,n,[{id:e.id,native:e.native===!0}],r),disabled:N,label:e.native?e.id:e.namespaced}),(0,z.jsx)(`code`,{className:`mono text-control`,style:{color:r?`var(--faint)`:`var(--text)`,textDecoration:r?`line-through`:`none`},children:e.native?zo(e.id):e.namespaced}),e.custom&&(0,z.jsx)(`span`,{className:`models-chip muted mono text-caption`,children:t(`models.customBadge`)}),e.contextCapped&&(0,z.jsx)(`span`,{className:`models-chip muted mono text-caption`,children:t(`models.contextCappedValue`,{value:js(e.contextCap??y)})})]}),Ne?.namespaced===e.namespaced&&(()=>{let n=Ne.rect,i=n.bottom+4,a=i+360>window.innerHeight;return(0,z.jsxs)(`div`,{className:`model-tip${e.custom?` has-actions`:``}${a?` flip-up`:``}`,role:`tooltip`,style:{position:`fixed`,left:n.left+24,...a?{bottom:window.innerHeight-n.top+4}:{top:i}},onMouseEnter:jt,onMouseLeave:At,children:[(0,z.jsx)(`div`,{className:`model-tip-id`,children:e.native?e.id:e.namespaced}),e.displayName&&(0,z.jsx)(`div`,{className:`model-tip-display`,children:e.displayName}),e.custom&&(0,z.jsx)(`span`,{className:`models-chip models-chip--tip muted mono text-caption`,children:t(`models.customBadge`)}),(0,z.jsxs)(`div`,{className:`model-tip-grid`,children:[(0,z.jsx)(`span`,{className:`model-tip-key`,children:t(`models.tipProvider`)}),(0,z.jsx)(`span`,{className:`model-tip-val`,children:e.provider}),(e.contextWindow||e.contextCap)&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`model-tip-key`,children:t(`models.tipContext`)}),(0,z.jsx)(`span`,{className:`model-tip-val`,children:js(e.contextWindow??e.contextCap??0)})]}),e.inputModalities&&e.inputModalities.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`model-tip-key`,children:t(`models.tipModalities`)}),(0,z.jsx)(`span`,{className:`model-tip-val`,children:e.inputModalities.join(`, `)})]}),(0,z.jsx)(`span`,{className:`model-tip-key`,children:t(`models.tipStatus`)}),(0,z.jsx)(`span`,{className:`model-tip-val`,children:t(r?`models.tipDisabled`:`models.tipActive`)})]}),e.custom&&e.customId&&(0,z.jsxs)(`div`,{className:`model-tip-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>{de(`edit`),me(e.provider),ge(e.customId),ye(e.id),xe(e.displayName??``),Ce(e.contextWindow?String(e.contextWindow):``),Te(!1),De(e.inputModalities??[`text`]),Me(``),le(!0),Pe(null)},children:t(`models.customEdit`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,style:{color:`var(--red)`},onClick:()=>{window.confirm(t(`models.customDeleteConfirm`,{name:e.displayName??e.id}))&&Pt(e.customId),Pe(null)},children:t(`models.customDelete`)})]})]})})()]},e.namespaced)}),T>0&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>h(e=>({...e,[n]:C+60})),className:`btn btn-ghost btn-sm models-show-more`,children:t(`models.showMore`,{n:T})})]})]},n)},Rt=Je?lt.filter(e=>e.provider===Je):lt,zt=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`models-control-top-row`,children:[(0,z.jsxs)(`div`,{className:`models-shadow-row row muted text-control`,"aria-busy":!Ie||void 0,children:[(0,z.jsxs)(`span`,{className:`models-shadow-label`,children:[t(`models.shadowCallIntercept`),` `,(0,z.jsx)(st,{content:t(`models.shadowCallInterceptHint`,{models:Ot(Ie?.sourceModels)}),side:`top`,maxWidth:320,children:(0,z.jsx)(`span`,{style:{cursor:`help`},"aria-label":t(`models.shadowCallInterceptHint`,{models:Ot(Ie?.sourceModels)}),children:`ⓘ`})})]}),(0,z.jsx)(`code`,{className:`text-caption models-shadow-warning`,style:{opacity:.6},children:t(`models.shadowCallOriginal`,{models:kt(Ie?.sourceModels)})}),(0,z.jsx)(it,{on:Ie?.enabled??!1,onClick:()=>void St({enabled:!Ie?.enabled}),disabled:!Ie||Re,label:t(`models.shadowCallIntercept`)}),(0,z.jsx)(`div`,{className:`models-shadow-model-slot`,children:(0,z.jsx)(at,{value:Ie?.model??``,options:[{value:``,label:`—`},...Ze],onChange:e=>{Le(t=>t&&{...t,model:e}),St({model:e})},disabled:!Ie||Re||!Ie.enabled,label:t(`models.shadowCallIntercept`)})})]}),B&&(0,z.jsxs)(`div`,{className:`models-v2-mode-row row`,children:[(0,z.jsx)(`span`,{className:`muted text-control`,children:t(`models.v2Label`)}),(0,z.jsx)(`div`,{className:`segmented models-segmented`,role:`radiogroup`,"aria-label":t(`models.v2Label`),children:[`v1`,`default`,`v2`].map(e=>(0,z.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":(B.multiAgentMode??`default`)===e,className:`btn btn-sm${(B.multiAgentMode??`default`)===e?` btn-primary`:` btn-ghost`}`,style:{background:(B.multiAgentMode??`default`)===e?void 0:`transparent`,color:(B.multiAgentMode??`default`)===e?void 0:`var(--muted)`},disabled:H,onClick:()=>void Ct(e),children:t(`models.v2Mode_${e}`)},e))}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{width:24,height:24,minWidth:24,flex:`0 0 24px`,padding:0,borderRadius:`var(--radius-pill)`,color:`var(--muted)`},onClick:()=>se(!0),"aria-label":t(`models.v2Label`),"aria-haspopup":`dialog`,children:(0,z.jsx)(fe,{width:14,height:14,"aria-hidden":`true`})})]})]}),B&&(B.enabled||B.agentsMaxThreadsConflict||ee)&&(0,z.jsxs)(`div`,{className:`models-v2-detail-row row`,children:[B.enabled&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`muted text-control`,children:t(`models.v2ThreadsLabel`)}),(0,z.jsx)(at,{value:ie?`custom`:B.maxConcurrentThreadsPerSession!==null&&B.maxConcurrentThreadsPerSession!==void 0?Os.has(B.maxConcurrentThreadsPerSession)?String(B.maxConcurrentThreadsPerSession):`custom`:``,options:[...B.maxConcurrentThreadsPerSession===null||B.maxConcurrentThreadsPerSession===void 0?[{value:``,label:t(`models.v2ThreadsDefault`)}]:[],...B.maxConcurrentThreadsPerSession!==null&&B.maxConcurrentThreadsPerSession!==void 0&&!Os.has(B.maxConcurrentThreadsPerSession)&&!ie?[{value:`custom`,label:String(B.maxConcurrentThreadsPerSession)}]:[],...Ds.map(e=>({value:String(e),label:String(e)})),{value:`custom`,label:t(`models.custom`)}],onChange:e=>Tt(e),disabled:H,label:t(`models.v2ThreadsLabel`)}),ie&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`input`,{className:`input`,style:{width:100},inputMode:`numeric`,value:re,onChange:e=>G(e.target.value),onKeyDown:e=>{e.key===`Enter`&&wt(Number(re.replace(/[_,\s]/g,``)))},disabled:H,"aria-label":t(`models.v2ThreadsLabel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,disabled:H,onClick:()=>{wt(Number(re.replace(/[_,\s]/g,``)))},children:t(`models.v2ThreadsApply`)})]})]}),B.enabled&&B.agentsMaxThreadsConflict&&(0,z.jsx)(`span`,{className:`mono text-label`,style:{color:`var(--err, #e5484d)`},children:t(`models.v2Conflict`)}),ee&&(0,z.jsx)(`span`,{className:`muted text-label`,children:ee})]}),(0,z.jsxs)(`div`,{className:`row models-cap-row`,children:[(0,z.jsx)(`span`,{className:`muted text-control`,children:t(`models.contextCapLabel`)}),(0,z.jsx)(at,{value:C?Es:Ts.has(y)?String(y):Es,options:[...!Ts.has(y)&&!C?[{value:String(y),label:js(y)}]:[],...ws.map(e=>({value:String(e),label:js(e)})),{value:Es,label:t(`models.custom`)}],onChange:e=>vt(e),disabled:N,label:t(`models.contextCapLabel`)}),C&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`input`,{className:`input`,style:{width:160},inputMode:`numeric`,placeholder:t(`models.customPlaceholder`),value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`&&yt()},disabled:N,"aria-label":t(`models.customPlaceholder`)}),(0,z.jsx)(`button`,{type:`button`,onClick:yt,disabled:N,className:`btn btn-ghost btn-sm`,children:t(`models.customApply`)})]}),(0,z.jsx)(it,{on:bt,onClick:xt,disabled:N,label:t(`models.setAll`)}),(0,z.jsx)(`span`,{className:`muted text-label leading-body`,children:t(`models.setAllHint`,{value:js(y)})})]}),(()=>{let e=i.filter(e=>e.custom).length;return e===0?null:(0,z.jsx)(`div`,{className:`row muted text-label models-custom-summary`,children:(0,z.jsx)(`span`,{className:`models-chip mono text-caption`,children:t(`models.customSummary`,{count:e})})})})(),(0,z.jsxs)(`div`,{className:`row muted text-label leading-body models-order-hint`,children:[(0,z.jsx)(fe,{width:15,height:15,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:t(`models.orderHint`)})]})]}),Bt=(0,z.jsxs)(z.Fragment,{children:[We===null&&!Ge&&(0,z.jsx)(`div`,{className:`card models-combos-card`,"aria-busy":`true`,children:(0,z.jsxs)(`div`,{className:`row models-combos-empty-head`,children:[(0,z.jsxs)(`div`,{className:`row models-field-row`,style:{minWidth:0},children:[(0,z.jsx)(Ae,{width:14,height:14,"aria-hidden":`true`,style:{flexShrink:0}}),(0,z.jsx)(`strong`,{children:t(`nav.combos`)}),(0,z.jsx)(`span`,{className:`muted text-label`,children:t(`common.loading`)})]}),(0,z.jsx)(`a`,{className:`btn btn-sm`,href:`#combos`,style:{flexShrink:0,visibility:`hidden`},tabIndex:-1,"aria-hidden":`true`,children:t(`models.combosSetup`)})]})}),We===null&&Ge&&(0,z.jsx)(`div`,{className:`card models-combos-card`,children:(0,z.jsxs)(`div`,{className:`row models-combos-empty-head`,children:[(0,z.jsxs)(`div`,{className:`row models-field-row`,style:{minWidth:0},children:[(0,z.jsx)(Ae,{width:14,height:14,"aria-hidden":`true`,style:{flexShrink:0}}),(0,z.jsx)(`strong`,{children:t(`nav.combos`)}),(0,z.jsx)(`span`,{className:`muted text-label`,role:`alert`,children:t(`models.loadFail`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,style:{flexShrink:0},onClick:()=>He.refresh(),children:t(`common.retry`)})]})}),We!==null&&We.length===0&&(0,z.jsx)(`div`,{className:`card models-combos-card`,children:(0,z.jsxs)(`div`,{className:`row models-combos-empty-head`,children:[(0,z.jsxs)(`div`,{className:`row models-field-row`,style:{minWidth:0},children:[(0,z.jsx)(Ae,{width:14,height:14,"aria-hidden":`true`,style:{flexShrink:0}}),(0,z.jsx)(`strong`,{children:t(`nav.combos`)}),Ge?(0,z.jsx)(`span`,{className:`muted text-label`,role:`alert`,children:t(`models.loadFail`)}):(0,z.jsx)(`span`,{className:`muted text-label`,children:t(`models.combosEmpty`)})]}),Ge?(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,style:{flexShrink:0},onClick:()=>He.refresh(),children:t(`common.retry`)}):(0,z.jsx)(`a`,{className:`btn btn-sm`,href:`#combos`,style:{flexShrink:0},children:t(`models.combosSetup`)})]})}),We!==null&&We.length>0&&(0,z.jsxs)(`div`,{className:`card models-combos-card`,children:[(0,z.jsxs)(`div`,{className:`row group-head models-field-row${Ke?` open`:``}`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`row models-field-row`,"aria-expanded":Ke,onClick:Xe,style:{flex:1,background:`none`,border:`none`,padding:0,cursor:`pointer`,font:`inherit`,color:`inherit`,textAlign:`left`,minWidth:0},children:[(0,z.jsx)(_e,{style:{width:14,height:14,color:`var(--muted)`,flexShrink:0,transform:Ke?`rotate(90deg)`:`none`,transition:`transform .12s`}}),(0,z.jsx)(Ae,{width:14,height:14,"aria-hidden":`true`,style:{flexShrink:0}}),(0,z.jsx)(`strong`,{children:t(`nav.combos`)}),(0,z.jsx)(`span`,{className:`muted mono text-label`,children:t(`models.combosActive`,{count:We.length})}),Ge&&(0,z.jsx)(`span`,{className:`muted text-label`,role:`alert`,children:t(`models.loadFail`)})]}),Ge?(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,style:{flexShrink:0},onClick:()=>He.refresh(),children:t(`common.retry`)}):(0,z.jsx)(`a`,{className:`btn btn-sm btn-ghost`,href:`#combos`,style:{flexShrink:0},children:t(`models.combosSetup`)})]}),Ke&&(0,z.jsxs)(`div`,{children:[We.map(e=>(0,z.jsxs)(`div`,{className:`row models-combo-row`,children:[(0,z.jsx)(`span`,{className:`mono leading-ui`,children:e.model}),(0,z.jsxs)(`span`,{className:`muted text-label`,children:[e.strategy,` · `,e.targets.length]})]},e.id)),(0,z.jsxs)(`a`,{className:`row muted models-combos-add`,href:`#combos`,children:[`+ `,t(`models.combosAdd`)]})]})]})]}),Vt=(0,z.jsxs)(`div`,{className:`row models-collapse-controls`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>ht(!0),disabled:N,children:[(0,z.jsx)(_e,{width:12,height:12,"aria-hidden":`true`}),` `,t(`models.collapseAll`)]}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>ht(!1),disabled:N,children:[(0,z.jsx)(_e,{width:12,height:12,"aria-hidden":`true`,style:{transform:`rotate(90deg)`}}),` `,t(`models.expandAll`)]})]}),Ht=(0,z.jsx)(z.Fragment,{children:lt.length===0&&(0,z.jsx)(ot,{icon:(0,z.jsx)(U,{}),title:t(`models.noRouted`),children:t(`models.noRoutedHint`)})}),Ut=(0,z.jsxs)(z.Fragment,{children:[oe&&(0,z.jsx)(`div`,{className:`modal-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`models.v2Label`),onClick:()=>se(!1),onKeyDown:e=>{e.key===`Escape`&&se(!1)},children:(0,z.jsxs)(`div`,{className:`modal-card`,onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsx)(`h3`,{children:t(`models.v2Label`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>se(!1),"aria-label":t(`common.close`),children:`×`})]}),(0,z.jsx)(`div`,{className:`modal-desc leading-relaxed`,style:{whiteSpace:`pre-line`},children:t(`models.v2Help`)}),(0,z.jsx)(`div`,{className:`models-help-link`,children:(0,z.jsx)(`a`,{className:`text-control`,href:`https://opencodex.me/guides/sub-agent-surface/`,target:`_blank`,rel:`noreferrer`,style:{color:`var(--accent)`},children:t(`models.v2DocsLink`)})}),(0,z.jsx)(`div`,{className:`modal-actions`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>se(!1),children:t(`common.ok`)})})]})}),ce&&(0,z.jsx)(`div`,{className:`modal-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`models.customAdd`),onClick:()=>{Oe||le(!1)},onKeyDown:e=>{e.key===`Escape`&&!Oe&&le(!1)},children:(0,z.jsxs)(`div`,{className:`modal-card`,onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsx)(`h3`,{children:t(ue===`add`?`models.customAddTitle`:`models.customEditTitle`,{provider:pe})}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>le(!1),disabled:Oe,"aria-label":t(`common.close`),children:`×`})]}),je&&(0,z.jsx)(q,{tone:`err`,children:je}),(0,z.jsxs)(`div`,{className:`models-field-stack`,children:[(0,z.jsxs)(`label`,{className:`text-label models-field`,children:[t(`models.customFieldModelId`),(0,z.jsx)(`input`,{className:`input`,value:ve,onChange:e=>ye(e.target.value),disabled:Oe,placeholder:t(`models.customFieldModelIdPlaceholder`),autoFocus:!0})]}),(0,z.jsxs)(`label`,{className:`text-label models-field`,children:[t(`models.customFieldDisplayName`),(0,z.jsx)(`input`,{className:`input`,value:be,onChange:e=>xe(e.target.value),disabled:Oe,placeholder:t(`models.customFieldDisplayNamePlaceholder`)})]}),(0,z.jsxs)(`label`,{className:`text-label models-field`,children:[t(`models.customFieldContext`),(0,z.jsxs)(`div`,{className:`row models-field-row`,children:[(0,z.jsx)(at,{value:we?`custom`:Se,options:[{value:``,label:`—`},{value:`100000`,label:`100k`},{value:`128000`,label:`128k`},{value:`200000`,label:`200k`},{value:`256000`,label:`256k`},{value:`352000`,label:`352k`},{value:`500000`,label:`500k`},{value:`1000000`,label:`1M`},{value:`custom`,label:t(`models.custom`)}],onChange:e=>{if(e===`custom`){Te(!0);return}Te(!1),Ce(e)},disabled:Oe,label:t(`models.customFieldContext`)}),we&&(0,z.jsx)(`input`,{className:`input`,style:{width:120},inputMode:`numeric`,value:Se,onChange:e=>Ce(e.target.value),disabled:Oe,placeholder:t(`models.customPlaceholder`),"aria-label":t(`models.customFieldContext`)})]})]}),(0,z.jsxs)(`div`,{className:`text-label models-field`,children:[t(`models.customFieldModalities`),(0,z.jsx)(`div`,{className:`row models-field-row`,children:[`text`,`image`,`audio`].map(e=>(0,z.jsxs)(`label`,{className:`row models-modality-option`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:Ee.includes(e),onChange:t=>{De(n=>t.target.checked?[...n,e]:n.filter(t=>t!==e))},disabled:Oe}),(0,z.jsx)(`span`,{className:`text-control`,children:e})]},e))})]})]}),(0,z.jsxs)(`div`,{className:`modal-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>le(!1),disabled:Oe,children:t(`common.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:Oe||!ve.trim(),onClick:()=>{let e=ve.trim(),t=be.trim(),n=Se?Number(Se.replace(/[_,\s]/g,``)):void 0,r=n&&n>0?Math.floor(n):void 0;ue===`add`?Mt(pe,e,t||void 0,r,Ee.length>0?Ee:void 0):Nt(he,{modelId:e,displayName:t,contextWindow:r??null,inputModalities:Ee})},children:t(Oe?`models.customSaving`:ue===`add`?`models.customAddBtn`:`models.customEditBtn`)})]})]})})]});return(0,z.jsxs)(`div`,{className:`models-workspace-shell`,children:[(0,z.jsxs)(`div`,{className:`page-head`,children:[(0,z.jsx)(`h2`,{children:t(`nav.models`)}),(0,z.jsx)(`div`,{className:`row`,children:(0,z.jsx)(`span`,{className:`muted mono text-label`,children:t(`models.active`,{active:dt,total:i.length})})})]}),(0,z.jsx)(`p`,{className:`page-sub`,children:t(`models.subtitle`)}),k&&(0,z.jsx)(q,{tone:j?`ok`:`err`,children:k}),rt.showError&&(0,z.jsx)(q,{tone:`err`,children:t(`models.loadFail`)}),(0,z.jsxs)(`div`,{className:`models-workspace-root`,"aria-busy":rt.refreshing||void 0,children:[(0,z.jsxs)(`aside`,{className:`models-workspace-rail`,"aria-label":t(`nav.models`),children:[(0,z.jsxs)(`div`,{className:`models-workspace-rail-header`,children:[(0,z.jsx)(`span`,{className:`models-workspace-rail-title`,children:t(`models.workspace.providers`)}),(0,z.jsx)(`span`,{className:`models-workspace-rail-count`,children:lt.length})]}),(0,z.jsxs)(`div`,{className:`models-workspace-rail-list`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`models-workspace-rail-row${Je===null?` models-workspace-rail-row--selected`:``}`,onClick:()=>Ye(null),"aria-current":Je===null?`true`:void 0,children:[(0,z.jsx)(`span`,{className:`models-workspace-rail-name`,children:t(`models.workspace.allProviders`)}),(0,z.jsx)(`span`,{className:`models-workspace-rail-meta`,children:t(`models.active`,{active:dt,total:i.length})})]}),lt.map(e=>{let{provider:n,rows:r}=e,i=r.filter(e=>bs(It,n,e.id,e.native===!0,c.has(e.namespaced))).length;return(0,z.jsxs)(`button`,{type:`button`,className:`models-workspace-rail-row${Je===n?` models-workspace-rail-row--selected`:``}`,onClick:()=>Ye(n),"aria-current":Je===n?`true`:void 0,children:[(0,z.jsx)(`span`,{className:`models-workspace-rail-name`,children:n}),(0,z.jsx)(`span`,{className:`models-workspace-rail-meta`,children:t(`models.active`,{active:i,total:r.length})})]},n)})]})]}),(0,z.jsxs)(`section`,{className:`models-workspace-main`,"aria-label":t(`models.workspace.mainAria`),children:[zt,Bt,Vt,(0,z.jsx)(`div`,{className:`models-provider-list`,children:Rt.map(e=>Lt(e))}),lt.length===0&&Ht]})]}),Ut]})}function Vs(e){return e.filter(e=>!e.disabled&&!e.hiddenFromPicker).sort((e,t)=>e.name.localeCompare(t.name))}function Hs(e,t,n){if(e===``)return;let r=Number(e);if(Number.isFinite(r))return Math.min(n,Math.max(t,r))}function Us(e){if(!e)return!1;let t=e.name.toLowerCase();if(t!==`openai`&&t!==`chatgpt`||(e.authMode??``).toLowerCase()!==`forward`||(e.adapter??``).toLowerCase()!==`openai-responses`)return!1;let n=(e.baseUrl??``).replace(/\/+$/,``);return!n||n.includes(`chatgpt.com/backend-api/codex`)}function Ws(e,t,n){let r=new Set([t]),i=n.find(e=>e.name===t);(t.toLowerCase()===`chatgpt`||Us(i))&&r.add(`openai`);let a=[],o=new Set;for(let t of e)!r.has(t.provider)||!t.id||o.has(t.id)||(o.add(t.id),a.push(t.id));return a.toSorted((e,t)=>e.localeCompare(t))}function Gs({value:e,onChange:t,disabled:n}){let r=K();return(0,z.jsx)(`div`,{className:`cwi-strategy-seg`,role:`radiogroup`,"aria-label":r(`cws.strategy`),children:[[`failover`,`cws.strategy.failover`],[`round-robin`,`cws.strategy.roundRobin`]].map(([i,a])=>(0,z.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e===i,className:`btn btn-sm${e===i?` btn-primary`:` btn-ghost`}`,disabled:n,onClick:()=>t(i),children:r(a)},i))})}function Ks({id:e,value:t,onChange:n,disabled:r,allowedEfforts:i}){let a=K(),o=i??Bo,s=t!==null&&!o.includes(t);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`select`,{id:e,className:`input`,value:t??``,disabled:r,"aria-label":a(`cws.field.defaultEffort`),onChange:e=>n(e.target.value===``?null:e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:a(`cws.field.defaultEffortNone`)}),s&&t?(0,z.jsxs)(`option`,{value:t,children:[t,` (`,a(`cws.field.defaultEffortUnsupportedOption`),`)`]}):null,o.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}),s?(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`,color:`var(--danger, #b42318)`},children:a(`cws.field.defaultEffortUnsupported`)}):null]})}function qs({targets:e,strategy:t,providers:n,models:r,onChange:i}){let a=K(),o=Vs(n),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(null),d=(t,n)=>{i(e.map((e,r)=>r===t?{...e,...n}:e))},f=(t,n)=>{if(t===n||t<0||n<0||t>=e.length||n>=e.length)return;let r=[...e],[a]=r.splice(t,1);r.splice(n,0,a),i(r)};return(0,z.jsxs)(`div`,{className:`cwi-target-list`,children:[e.map((p,m)=>{let h=n.find(e=>e.name===p.provider),g=h&&!o.some(e=>e.name===p.provider)?[...o,h]:o,_=Ws(r,p.provider,n),v=p.model&&!_.includes(p.model)?[p.model,..._]:_,y=!p.provider;return(0,z.jsxs)(`div`,{className:[`cwi-target-row`,t===`failover`?`cwi-target-row--failover`:``,s===m?`cwi-target-row--dragging`:``,l===m&&s!==null&&s!==m?`cwi-target-row--drop`:``].filter(Boolean).join(` `),onDragOver:e=>{s!==null&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,l!==m&&u(m))},onDrop:e=>{e.preventDefault(),s!==null&&f(s,m),c(null),u(null)},onDragEnd:()=>{c(null),u(null)},children:[(0,z.jsx)(`button`,{type:`button`,className:`cwi-target-grip`,draggable:!0,"aria-label":a(`cws.target.drag`),title:a(`cws.target.drag`),onDragStart:e=>{c(m),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(m))},children:(0,z.jsx)(je,{width:14,height:14,"aria-hidden":`true`})}),(0,z.jsxs)(`div`,{className:`cwi-target-reorder`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:m===0,"aria-label":a(`cws.target.moveUp`),onClick:()=>f(m,m-1),children:(0,z.jsx)(me,{width:14,height:14,"aria-hidden":`true`})}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:m===e.length-1,"aria-label":a(`cws.target.moveDown`),onClick:()=>f(m,m+1),children:(0,z.jsx)(he,{width:14,height:14,"aria-hidden":`true`})})]}),(0,z.jsxs)(`select`,{className:`input`,value:p.provider,"aria-label":a(`cws.target.provider`),onChange:e=>{let t=e.target.value;d(m,{provider:t,model:Ws(r,t,n)[0]??``})},children:[(0,z.jsx)(`option`,{value:``,children:a(`cws.target.pickProvider`)}),g.map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.disabled?a(`cws.target.disabled`,{name:e.name}):e.name},e.name))]}),(0,z.jsxs)(`select`,{className:`input`,value:p.model,disabled:y,"aria-label":a(`cws.target.model`),onChange:e=>d(m,{model:e.target.value}),children:[(0,z.jsx)(`option`,{value:``,children:y?a(`cws.target.pickProviderFirst`):v.length===0?a(`cws.target.noModels`):a(`cws.target.pickModel`)}),v.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}),t===`round-robin`&&(0,z.jsx)(`input`,{className:`input mono`,type:`number`,min:1,max:1e4,value:p.weight??1,"aria-label":a(`cws.target.weight`),onChange:e=>{let t=Hs(e.target.value,1,1e4);t!==void 0&&d(m,{weight:t})}}),(0,z.jsx)(`div`,{className:`cwi-target-actions`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:e.length<=1,onClick:()=>i(e.filter((e,t)=>t!==m)),"aria-label":a(`common.remove`),children:(0,z.jsx)(ue,{width:14,height:14})})})]},p.clientKey??`${p.provider}:${p.model}`)}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{alignSelf:`flex-start`},onClick:()=>i([...e,Uo()]),children:[(0,z.jsx)(oe,{width:14,height:14}),` `,a(`cws.target.add`)]})]})}function Js({existingIds:e,existingAliases:t,providerMap:n,providers:r,models:i,onClose:a,onSubmit:o}){let s=K(),c=(0,_.useRef)(null),[l,u]=(0,_.useState)(()=>cs()),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(``),h=(0,_.useMemo)(()=>{let e=new Map;for(let t of i)e.set(`${t.provider}/${t.id}`,t.reasoningEfforts);return e},[i]),g=(0,_.useMemo)(()=>Vo(l.targets,h),[l.targets,h]);(0,_.useEffect)(()=>{let e=c.current;e&&!e.open&&e.showModal()},[]);let v=(0,_.useCallback)(()=>{d||a()},[d,a]),y=(0,_.useCallback)(e=>{e.preventDefault(),v()},[v]),b=async()=>{let r=ss(l,{existingIds:e,existingAliases:t,isCreate:!0,providers:n});if(r){m(s(`cws.err.${r}`));return}f(!0),m(``);let i=l.id.trim(),a=l.alias?.trim()||null;try{let e=await o({...l,id:i,alias:a,model:Yo(i,a)});if(!e.ok){m(e.error||s(`cws.saveFailed`));return}}finally{f(!1)}};return(0,z.jsxs)(`dialog`,{ref:c,className:`modal-overlay`,"aria-labelledby":`cwi-add-title`,onCancel:y,children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":s(`common.close`),tabIndex:-1,onClick:v}),(0,z.jsxs)(`div`,{className:`modal-card`,style:{width:`min(560px, 94vw)`},onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`div`,{className:`row`,style:{justifyContent:`space-between`,marginBottom:8},children:[(0,z.jsx)(`h3`,{id:`cwi-add-title`,style:{margin:0},children:s(`cws.addTitle`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:v,disabled:d,"aria-label":s(`common.close`),children:(0,z.jsx)(ae,{width:16,height:16})})]}),(0,z.jsx)(`p`,{className:`muted`,style:{marginTop:0},children:s(`cws.addSubtitle`)}),p&&(0,z.jsx)(q,{tone:`err`,children:p}),(0,z.jsxs)(`div`,{className:`cwi-modal-form`,children:[(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`label`,{htmlFor:`cwi-new-id`,children:s(`cws.field.id`)}),(0,z.jsx)(`input`,{id:`cwi-new-id`,className:`input mono`,value:l.id,disabled:d,onChange:e=>u(t=>({...t,id:e.target.value,model:Yo(e.target.value,t.alias)}))}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`},children:s(`cws.field.idInternalHint`)})]}),(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`label`,{htmlFor:`cwi-new-alias`,children:s(`cws.field.alias`)}),(0,z.jsx)(`input`,{id:`cwi-new-alias`,className:`input mono`,value:l.alias??``,placeholder:s(`cws.field.aliasPlaceholder`),disabled:d,onChange:e=>u(t=>({...t,alias:e.target.value.trim()?e.target.value:null,model:Yo(t.id,e.target.value)}))}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`},children:s(`cws.field.aliasHint`)}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`},children:s(`cws.field.idHint`,{model:l.id.trim()?Yo(l.id,l.alias):`…`})})]}),(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`span`,{className:`field-label`,children:s(`cws.strategy`)}),(0,z.jsx)(Gs,{value:l.strategy,disabled:d,onChange:e=>u(t=>({...t,strategy:e}))}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`6px 0 0`},children:l.strategy===`failover`?s(`cws.strategy.failoverHint`):s(`cws.strategy.roundRobinHint`)})]}),(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`label`,{htmlFor:`cwi-new-effort`,children:s(`cws.field.defaultEffort`)}),(0,z.jsx)(Ks,{id:`cwi-new-effort`,value:l.defaultEffort,disabled:d,allowedEfforts:g,onChange:e=>u(t=>({...t,defaultEffort:e}))}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`},children:s(`cws.field.defaultEffortHint`)})]}),l.strategy===`round-robin`&&(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`label`,{htmlFor:`cwi-new-sticky`,children:s(`cws.field.stickyLimit`)}),(0,z.jsx)(`input`,{id:`cwi-new-sticky`,className:`input mono`,type:`number`,min:1,max:100,value:l.stickyLimit,disabled:d,onChange:e=>{let t=Hs(e.target.value,1,100);t!==void 0&&u(e=>({...e,stickyLimit:t}))}}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`},children:s(`cws.field.stickyLimitHint`)})]}),(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`span`,{className:`field-label`,children:s(`cws.targets`)}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`0 0 8px`},children:l.strategy===`failover`?s(`cws.targets.failoverHint`):s(`cws.targets.roundRobinHint`)}),(0,z.jsx)(qs,{targets:l.targets,strategy:l.strategy,providers:r,models:i,onChange:e=>u(t=>({...t,targets:e}))})]})]}),(0,z.jsxs)(`div`,{className:`cwi-modal-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:v,disabled:d,children:s(`common.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>{b()},disabled:d,children:s(d?`common.saving`:`cws.create`)})]})]})]})}function Ys({baseline:e,isCreate:t=!1,otherIds:n,otherAliases:r,providerMap:i,providers:a,models:o,onBack:s,onSaved:c,onRequestRemove:l,onSave:u,onDirtyChange:d}){let f=K(),[p,m]=(0,_.useState)(`config`),[h,g]=(0,_.useState)(e),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!1),w=!as(h,e),T=`${e.id}:${e.alias??``}:${e.strategy}:${e.stickyLimit}:${e.defaultEffort}:${e.targets.map(e=>`${e.provider}/${e.model}:${e.weight??1}`).join(`,`)}`,E=(0,_.useMemo)(()=>{let e=new Map;for(let t of o)e.set(`${t.provider}/${t.id}`,t.reasoningEfforts);return e},[o]),D=(0,_.useMemo)(()=>Vo(h.targets,E),[h.targets,E]),O=(0,_.useCallback)(t=>{let n=t(h);g(n),d(!as(n,e))},[h,e,d]);(0,_.useEffect)(()=>{let t=window.setTimeout(()=>{g(e),x(null),m(`config`),d(!1)},0);return()=>window.clearTimeout(t)},[T]);let k=async()=>{try{await navigator.clipboard.writeText(e.model),C(!0),window.setTimeout(()=>C(!1),1200)}catch{}},A=async()=>{let a=ss(h,{existingIds:n,existingAliases:r,isCreate:t,providers:i});if(a){x({ok:!1,text:f(`cws.err.${a}`)});return}y(!0);let o=h.id.trim(),s=h.alias?.trim()||null,l={...h,id:o,alias:s,model:Yo(o,s)},d=!t&&o!==e.id?e.id:void 0;try{let e=await u(l,t,d);if(!e.ok){x({ok:!1,text:e.error||f(`cws.saveFailed`)});return}x({ok:!0,text:t?f(`cws.created`,{model:l.model}):f(`cws.saved`)}),c(l)}finally{y(!1)}},j=t?h.id.trim()?Yo(h.id,h.alias):f(`cws.addTitle`):e.model;return(0,z.jsxs)(`div`,{className:`combos-workspace-detail`,children:[(0,z.jsxs)(`div`,{className:`combos-workspace-detail-head`,children:[s&&(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm pwi-back-overview`,onClick:s,"aria-label":f(`cws.backToAll`),children:[(0,z.jsx)(_e,{style:{width:14,height:14,transform:`rotate(180deg)`},"aria-hidden":`true`}),f(`cws.allCombos`)]}),(0,z.jsx)(`h2`,{className:`combos-workspace-detail-title`,children:j}),!t&&(0,z.jsx)(`button`,{type:`button`,className:`chip cwi-copy-chip`,onClick:()=>{k()},title:f(`cws.copyModel`),children:f(S?`cws.copied`:`cws.copyModel`)}),(0,z.jsxs)(`div`,{className:`combos-workspace-detail-actions`,children:[!t&&l&&(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:l,children:[(0,z.jsx)(ue,{width:14,height:14}),` `,f(`common.remove`)]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:!t&&!w||v,onClick:()=>{A()},children:f(v?`common.saving`:t?`cws.create`:`common.save`)})]})]}),b&&(0,z.jsx)(q,{tone:b.ok?`ok`:`err`,children:b.text}),(0,z.jsxs)(`div`,{className:`combos-workspace-tabs`,role:`tablist`,children:[(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":p===`config`,className:`combos-workspace-tab${p===`config`?` combos-workspace-tab--active`:``}`,onClick:()=>m(`config`),children:f(`cws.tab.config`)}),(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":p===`about`,className:`combos-workspace-tab${p===`about`?` combos-workspace-tab--active`:``}`,onClick:()=>m(`about`),children:f(`cws.tab.about`)})]}),(0,z.jsx)(`div`,{className:`combos-workspace-tab-content`,role:`tabpanel`,children:p===`config`?(0,z.jsxs)(`div`,{className:`cwi-form-grid`,children:[(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`label`,{htmlFor:`cwi-edit-id`,children:f(`cws.field.id`)}),(0,z.jsx)(`input`,{id:`cwi-edit-id`,className:`input mono`,value:h.id,disabled:v,onChange:e=>O(t=>({...t,id:e.target.value,model:Yo(e.target.value,t.alias)}))}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`},children:t?f(`cws.field.idInternalHint`):f(`cws.field.idHintEdit`,{model:Yo(h.id,h.alias)})})]}),(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`label`,{htmlFor:`cwi-edit-alias`,children:f(`cws.field.alias`)}),(0,z.jsx)(`input`,{id:`cwi-edit-alias`,className:`input mono`,value:h.alias??``,placeholder:Jo(h.id.trim()||`…`),disabled:v,onChange:e=>O(t=>({...t,alias:e.target.value.trim()?e.target.value:null,model:Yo(t.id,e.target.value)}))}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`},children:f(`cws.field.aliasHint`)})]}),(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`span`,{className:`field-label`,children:f(`cws.strategy`)}),(0,z.jsx)(Gs,{value:h.strategy,disabled:v,onChange:e=>O(t=>({...t,strategy:e}))}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`6px 0 0`},children:h.strategy===`failover`?f(`cws.strategy.failoverHint`):f(`cws.strategy.roundRobinHint`)})]}),(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`label`,{htmlFor:`cwi-effort`,children:f(`cws.field.defaultEffort`)}),(0,z.jsx)(Ks,{id:`cwi-effort`,value:h.defaultEffort,disabled:v,allowedEfforts:D,onChange:e=>O(t=>({...t,defaultEffort:e}))}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`4px 0 0`},children:f(`cws.field.defaultEffortHint`)})]}),h.strategy===`round-robin`&&(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`label`,{htmlFor:`cwi-sticky`,children:f(`cws.field.stickyLimit`)}),(0,z.jsx)(`input`,{id:`cwi-sticky`,className:`input mono`,type:`number`,min:1,max:100,value:h.stickyLimit,disabled:v,onChange:e=>{let t=Hs(e.target.value,1,100);t!==void 0&&O(e=>({...e,stickyLimit:t}))}})]}),(0,z.jsxs)(`div`,{className:`cwi-field`,children:[(0,z.jsx)(`span`,{className:`field-label`,children:f(`cws.targets`)}),(0,z.jsx)(`p`,{className:`muted`,style:{fontSize:12,margin:`0 0 8px`},children:h.strategy===`failover`?f(`cws.targets.failoverHint`):f(`cws.targets.roundRobinHint`)}),(0,z.jsx)(qs,{targets:h.targets,strategy:h.strategy,providers:a,models:o,onChange:e=>O(t=>({...t,targets:e}))})]})]}):(0,z.jsxs)(`section`,{className:`pwi-section`,children:[(0,z.jsx)(`h3`,{className:`pwi-section-title`,children:f(`cws.aboutTitle`)}),(0,z.jsx)(`p`,{className:`muted`,style:{margin:0},children:f(`cws.aboutBody`)})]})})]})}function Xs({model:e,onCancel:t,onConfirm:n}){let r=K(),i=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let e=i.current;e&&!e.open&&e.showModal()},[]),(0,z.jsxs)(`dialog`,{ref:i,className:`modal-overlay`,"aria-labelledby":`cwi-remove-title`,onCancel:(0,_.useCallback)(e=>{e.preventDefault(),t()},[t]),children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":r(`common.close`),tabIndex:-1,onClick:t}),(0,z.jsxs)(`div`,{className:`modal-card pwi-remove-confirm-card`,onClick:e=>e.stopPropagation(),children:[(0,z.jsx)(`h3`,{id:`cwi-remove-title`,className:`pwi-remove-confirm-title`,children:r(`cws.removeConfirmTitle`,{model:e})}),(0,z.jsx)(`p`,{className:`muted pwi-remove-confirm-desc`,children:r(`cws.removeConfirmDesc`)}),(0,z.jsxs)(`div`,{className:`pwi-remove-confirm-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:t,children:r(`common.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn pwi-remove-confirm-danger`,onClick:n,children:r(`common.remove`)})]})]})]})}function Zs({onKeep:e,onDiscard:t}){let n=K(),r=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let e=r.current;e&&!e.open&&e.showModal()},[]),(0,z.jsxs)(`dialog`,{ref:r,className:`modal-overlay`,"aria-labelledby":`cwi-unsaved-title`,onCancel:(0,_.useCallback)(t=>{t.preventDefault(),e()},[e]),children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":n(`common.close`),tabIndex:-1,onClick:e}),(0,z.jsxs)(`div`,{className:`modal-card pwi-json-unsaved-card`,onClick:e=>e.stopPropagation(),children:[(0,z.jsx)(`h3`,{id:`cwi-unsaved-title`,className:`pwi-json-unsaved-title`,children:n(`cws.unsavedTitle`)}),(0,z.jsx)(`p`,{className:`muted pwi-json-unsaved-desc`,children:n(`cws.unsavedDesc`)}),(0,z.jsxs)(`div`,{className:`pwi-json-unsaved-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,"data-testid":`cwi-unsaved-keep`,onClick:e,children:n(`cws.keepEditing`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-danger`,"data-testid":`cwi-unsaved-discard`,onClick:t,children:n(`common.discard`)})]})]})]})}function Qs(e,t){return t(e===`empty-targets`?`cws.attention.empty`:e===`catalog-omitted`?`cws.attention.catalogOmitted`:`cws.attention.few`)}function $s({combos:e,cataloguedComboIds:t,onSelect:n,onAdd:r}){let i=K(),a=ns(e),o=is(e,{cataloguedComboIds:t});return(0,z.jsxs)(`div`,{className:`combos-workspace-overview`,children:[(0,z.jsxs)(`div`,{className:`combos-workspace-overview-head`,children:[(0,z.jsx)(`h2`,{className:`combos-workspace-overview-title`,children:i(`cws.overviewTitle`)}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:r,children:[(0,z.jsx)(oe,{width:14,height:14}),` `,i(`cws.add`)]})]}),(0,z.jsx)(`p`,{className:`muted`,style:{marginTop:0,maxWidth:`62ch`},children:i(`cws.overviewBlurb`)}),(0,z.jsxs)(`div`,{className:`cwi-count-strip`,children:[(0,z.jsxs)(`div`,{className:`cwi-count-pill`,children:[(0,z.jsx)(`strong`,{children:e.length}),(0,z.jsx)(`span`,{children:i(`cws.count.total`)})]}),(0,z.jsxs)(`div`,{className:`cwi-count-pill`,children:[(0,z.jsx)(`strong`,{children:a.failover.length}),(0,z.jsx)(`span`,{children:i(`cws.count.failover`)})]}),(0,z.jsxs)(`div`,{className:`cwi-count-pill`,children:[(0,z.jsx)(`strong`,{children:a.roundRobin.length}),(0,z.jsx)(`span`,{children:i(`cws.count.roundRobin`)})]})]}),(0,z.jsxs)(`section`,{className:`pwi-section`,"aria-label":i(`cws.howTitle`),children:[(0,z.jsx)(`h3`,{className:`pwi-section-title`,children:i(`cws.howTitle`)}),(0,z.jsx)(`p`,{className:`muted`,style:{margin:0},children:i(`cws.howBody`)})]}),o.length>0&&(0,z.jsxs)(`section`,{className:`pwi-section`,"aria-label":i(`cws.attentionTitle`),children:[(0,z.jsx)(`h3`,{className:`pwi-section-title`,children:i(`cws.attentionTitle`)}),(0,z.jsx)(`div`,{className:`cwi-attention-list`,children:o.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`cwi-attention-row`,onClick:()=>n(e.id),children:[(0,z.jsx)(de,{width:14,height:14,"aria-hidden":`true`}),(0,z.jsx)(`code`,{className:`chip`,children:e.model}),(0,z.jsx)(`span`,{className:`muted`,children:Qs(e.reason,i)}),(0,z.jsx)(_e,{width:14,height:14,style:{marginLeft:`auto`},"aria-hidden":`true`})]},`${e.id}:${e.reason}`))})]})]})}function ec({combos:e,providers:t,models:n,cataloguedComboIds:r,loading:i,onRefresh:a,onSave:o,onRemove:s,onAdd:c,adding:l,onCloseAdd:u,onCreated:d}){let f=K(),p=(0,_.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,{disabled:e.disabled}])),[t]),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(void 0),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(null),T=(0,_.useMemo)(()=>cs(),[]),E=(0,_.useMemo)(()=>rs(e,m),[e,m]),D=(0,_.useMemo)(()=>ns(E),[E]),O=(0,_.useMemo)(()=>e.flatMap(e=>e.alias?[e.alias]:[]),[e]),k=g&&e.some(e=>e.id===g)?g:null,A=e.find(e=>e.id===k)??null,j=A&&C?.id===A.id?C:A,[M,N]=(0,_.useState)(!1),P=[],F=[];if(j)for(let t of e)t.id!==j.id&&(P.push(t.id),t.alias&&F.push(t.alias));let I=(0,_.useCallback)(e=>{if(e!==k){if(!M){v(e),w(null);return}b(e)}},[k,M]),L=()=>{y!==void 0&&(v(y),w(null),N(!1),b(void 0))},R=()=>b(void 0),B=y!==void 0&&M,V=!i&&e.length===0;return(0,z.jsxs)(`div`,{className:`combos-workspace-root`,children:[(0,z.jsxs)(`aside`,{className:`combos-workspace-rail`,"aria-label":f(`cws.railAria`),children:[(0,z.jsxs)(`div`,{className:`combos-workspace-rail-header`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`combos-workspace-rail-title`,children:f(`nav.combos`)}),(0,z.jsx)(`div`,{className:`combos-workspace-rail-count`,children:e.length})]}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>{if(V){document.getElementById(`cwi-edit-id`)?.focus();return}c()},"aria-label":f(`cws.add`),children:[(0,z.jsx)(oe,{width:14,height:14}),` `,f(`cws.add`)]})]}),(0,z.jsx)(`div`,{className:`cwi-search-row`,children:(0,z.jsxs)(`div`,{className:`cwi-search-wrap`,children:[(0,z.jsx)(pe,{className:`cwi-search-icon`,"aria-hidden":`true`}),(0,z.jsx)(`input`,{className:`input cwi-search-input`,value:m,onChange:e=>h(e.target.value),placeholder:f(`cws.searchPlaceholder`),"aria-label":f(`cws.searchPlaceholder`)})]})}),(0,z.jsx)(`div`,{className:`combos-workspace-rail-list`,children:E.length===0&&e.length>0?(0,z.jsx)(`p`,{className:`muted`,style:{padding:`16px`},children:f(`cws.noSearchResults`)}):(0,z.jsx)(z.Fragment,{children:[[`failover`,D.failover,`cws.group.failover`],[`round-robin`,D.roundRobin,`cws.group.roundRobin`]].map(([e,t,n])=>t.length>0?(0,z.jsxs)(`div`,{className:`combos-workspace-rail-group`,children:[(0,z.jsxs)(`div`,{className:`combos-workspace-rail-group-head`,children:[(0,z.jsx)(`span`,{className:`pwi-dot`,"aria-hidden":`true`}),f(n),(0,z.jsx)(`span`,{className:`combos-workspace-rail-count`,children:t.length})]}),t.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`combos-workspace-rail-row${k===e.id?` combos-workspace-rail-row--selected`:``}`,onClick:()=>I(e.id),"aria-current":k===e.id?`true`:void 0,children:[(0,z.jsx)(`span`,{className:`combos-workspace-rail-icon`,"aria-hidden":`true`,children:(0,z.jsx)(Ae,{width:16,height:16})}),(0,z.jsx)(`span`,{className:`combos-workspace-rail-name`,children:e.model}),(0,z.jsx)(`span`,{className:`combos-workspace-rail-meta`,children:e.targets.length===1?f(`cws.targetCountOne`):f(`cws.targetCount`,{count:e.targets.length})}),(0,z.jsx)(_e,{className:`combos-workspace-rail-chevron`,"aria-hidden":`true`})]},e.id))]},e):null)})})]}),(0,z.jsx)(`div`,{className:`combos-workspace-main`,children:j?(0,z.jsx)(Ys,{baseline:j,otherIds:P,otherAliases:F,providerMap:p,providers:t,models:n,onBack:()=>I(null),onSaved:e=>{N(!1),e.id===j.id?w(e):(v(e.id),w(null)),a()},onRequestRemove:()=>S(j.id),onSave:o,onDirtyChange:N},j.id):V?(0,z.jsx)(Ys,{baseline:T,isCreate:!0,otherIds:[],otherAliases:[],providerMap:p,providers:t,models:n,onSaved:e=>{N(!1),v(e.id),w(e),d(e.id)},onSave:o,onDirtyChange:N},`first-combo`):(0,z.jsx)($s,{combos:e,cataloguedComboIds:r,onSelect:e=>I(e),onAdd:c})}),l&&!V&&(0,z.jsx)(Js,{existingIds:e.map(e=>e.id),existingAliases:O,providerMap:p,providers:t,models:n,onClose:u,onSubmit:async e=>{let t=await o(e,!0);return t.ok&&(u(),d(e.id),v(e.id),w(null)),t}}),x&&(0,z.jsx)(Xs,{model:e.find(e=>e.id===x)?.model??Jo(x),onCancel:()=>S(null),onConfirm:()=>{(async()=>{let e=await s(x);S(null),e.ok&&(k===x&&(v(null),w(null)),a())})()}}),B&&(0,z.jsx)(Zs,{onKeep:R,onDiscard:L})]})}function tc(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e.error;return typeof t==`string`&&t.trim()?t:void 0}function nc(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&e.success===!0}function rc(e){return Y(e)}function ic({apiBase:e}){let t=K(),n=`ocx.combos.workspace.v1:${e}`,r=rc(n),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1),u=(e,t)=>{a(e),s(t)};(0,_.useEffect)(()=>{if(!i||!o)return;let e=window.setTimeout(()=>{a(``),s(!1)},5e3);return()=>window.clearTimeout(e)},[i,o]);let d=(0,_.useCallback)(async()=>{let[t,r,i]=await Promise.all([fetch(`${e}/api/combos`),fetch(`${e}/api/config`),fetch(`${e}/api/models`)]);if(!t.ok||!r.ok||!i.ok)throw Error(`combo workspace load failed`);let a=await t.json(),o=await r.json(),s=await i.json(),c=Array.isArray(s)?s:Array.isArray(s?.models)?s.models:[],l=ts(a),u=o.providers??{},d=Yn(u),f=Object.entries(u).map(([e,t])=>({name:e,disabled:!!t.disabled,hiddenFromPicker:!Object.hasOwn(d,e),authMode:t.authMode,adapter:t.adapter,baseUrl:t.baseUrl})),p=[],m=new Set;for(let e of c){if(!e||typeof e!=`object`)continue;let t=e;if(typeof t.provider!=`string`||typeof t.id!=`string`)continue;let n=t.provider.trim(),r=t.id.trim();if(!n||!r)continue;if(n===`combo`){m.add(r);continue}if(t.disabled===!0)continue;let i=Array.isArray(t.reasoningEfforts)?t.reasoningEfforts.filter(e=>typeof e==`string`):void 0;p.push({provider:n,id:r,namespaced:typeof t.namespaced==`string`?t.namespaced:void 0,...i?{reasoningEfforts:i}:{}})}for(let[e,t]of Object.entries(u)){let n=typeof t.defaultModel==`string`?t.defaultModel.trim():``;!n||t.disabled||p.some(t=>t.provider===e&&t.id===n)||p.push({provider:e,id:n,namespaced:`${e}/${n}`})}let h={combos:l,providers:f,models:p,cataloguedComboIds:[...m]};return X(n,h),h},[e,n]),f=us(n,[e],d,{isEmpty:()=>!1}),{state:p}=f,m=p.data??r,h=m?.combos??[],g=m?.providers??[],v=m?.models??[],y=new Set(m?.cataloguedComboIds??[]);return p.showSkeleton&&!m?(0,z.jsx)(fs,{label:t(`cws.loading`),rows:5}):p.kind===`failed-cold`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(q,{tone:`err`,children:p.error instanceof Error?p.error.message:t(`cws.loadFailed`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>f.refresh(),children:t(`common.retry`)})]}):(0,z.jsxs)(`div`,{className:`combos-workspace-shell`,children:[i&&(0,z.jsx)(`div`,{className:`combos-workspace-shell-banner`,children:(0,z.jsx)(q,{tone:o?`ok`:`err`,children:i})}),p.showError&&(0,z.jsx)(`div`,{className:`combos-workspace-shell-banner`,children:(0,z.jsx)(q,{tone:`err`,children:t(`cws.loadFailed`)})}),p.refreshing&&(0,z.jsx)(ps,{live:!p.showError,children:t(`cws.loading`)}),(0,z.jsx)(`div`,{className:`combos-workspace-shell-body`,children:(0,z.jsx)(ec,{combos:h,providers:g,models:v,cataloguedComboIds:y,loading:!1,onRefresh:()=>f.refresh(),onSave:async(n,r,i)=>{try{let a=await fetch(`${e}/api/combos`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(os(n,i?{renameFrom:i}:{}))}),o=a.ok?await a.json():await a.json().catch(()=>null),s=tc(o);if(!a.ok||s||!nc(o)){let e=s||t(`cws.saveFailed`);return u(e,!1),{ok:!1,error:e}}return f.refresh(),u(i?t(`cws.renamed`,{from:Jo(i),to:n.model}):r?t(`cws.created`,{model:n.model}):t(`cws.saved`),!0),{ok:!0}}catch{let e=t(`cws.saveFailed`);return u(e,!1),{ok:!1,error:e}}},onRemove:async n=>{try{let r=await fetch(`${e}/api/combos?id=${encodeURIComponent(n)}`,{method:`DELETE`}),i=r.ok?await r.json():await r.json().catch(()=>null),a=tc(i);if(!r.ok||a||!nc(i)){let e=a||t(`cws.removeFailed`);return u(e,!1),{ok:!1,error:e}}return f.refresh(),u(t(`cws.removed`,{id:n}),!0),{ok:!0}}catch{let e=t(`cws.removeFailed`);return u(e,!1),{ok:!1,error:e}}},onAdd:()=>l(!0),adding:c,onCloseAdd:()=>l(!1),onCreated:()=>f.refresh()})})]})}var ac=`section`;function oc(e,t){return[e,ac,t].join(`-`)}function sc(e){return[e,ac,``].join(`-`)}var cc=1200;function lc({scope:e,items:t,ariaLabel:n}){let[r,i]=(0,_.useState)(t[0]?.id??``),a=(0,_.useRef)(null),o=(0,_.useRef)(null),s=(0,_.useCallback)(()=>{a.current=null,o.current!==null&&(clearTimeout(o.current),o.current=null)},[]),c=(0,_.useCallback)(()=>{s();let n=null,r=1/0;for(let i of t){let t=document.getElementById(oc(e,i.id));if(!t)continue;let a=Math.abs(t.getBoundingClientRect().top-72);a<r&&(r=a,n=i.id)}n&&i(n)},[s,t,e]);(0,_.useEffect)(()=>()=>s(),[s]),(0,_.useEffect)(()=>{if(typeof IntersectionObserver>`u`)return;let n=t.map(t=>document.getElementById(oc(e,t.id))).filter(e=>e!==null);if(n.length===0)return;let r=new IntersectionObserver(t=>{let n=a.current;if(n){let r=document.getElementById(oc(e,n));t.some(e=>e.isIntersecting&&e.target===r)&&(s(),i(n));return}let r=t.filter(e=>e.isIntersecting).sort((e,t)=>e.boundingClientRect.top-t.boundingClientRect.top)[0];if(!r)return;let o=r.target.id.slice(sc(e).length);i(e=>e===o?e:o)},{rootMargin:`-72px 0px -60% 0px`,threshold:0});for(let e of n)r.observe(e);return()=>r.disconnect()},[s,t,e]);let l=t=>{let n=document.getElementById(oc(e,t));n&&(a.current=t,o.current!==null&&clearTimeout(o.current),o.current=setTimeout(c,cc),i(t),n.scrollIntoView({behavior:`smooth`,block:`start`}))};return(0,z.jsx)(`div`,{className:`page-tabs section-tabs`,role:`tablist`,"aria-label":n,children:t.map(t=>(0,z.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":r===t.id,"aria-controls":oc(e,t.id),tabIndex:r===t.id?0:-1,className:`page-tab${r===t.id?` page-tab--active`:``}`,onClick:()=>l(t.id),children:[t.label,t.meta?(0,z.jsx)(`span`,{className:`section-tab-meta`,children:t.meta}):null]},t.id))})}function uc({model:e,effort:t,efforts:n,available:r,guidanceEnabled:i,syncCodexDefaults:a,saving:o,onSave:s}){let c=K();return(0,z.jsxs)(`div`,{className:`swi-delegation`,children:[(0,z.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,z.jsxs)(`div`,{className:`setting-copy`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:c(`sub.delegation.model`)}),(0,z.jsx)(`div`,{className:`muted setting-hint`,children:c(`sub.delegation.modelHint`)})]}),(0,z.jsxs)(`div`,{className:`swi-delegation-controls`,children:[(0,z.jsx)(at,{value:e,options:[{value:``,label:c(`dash.injectionNone`)},...r.map(e=>({value:e.namespaced,label:`${e.provider} / ${e.model}`}))],onChange:e=>s({model:e||null,effort:t||null}),disabled:o,label:c(`dash.injectionLabel`)}),e&&n.length>0&&(0,z.jsx)(at,{value:t,options:[{value:``,label:c(`dash.injectionEffortNone`)},...n.map(e=>({value:e,label:e}))],onChange:t=>s({model:e||null,effort:t||null}),disabled:o,label:c(`dash.injectionEffortLabel`)})]})]}),(0,z.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,z.jsxs)(`div`,{className:`setting-copy`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:c(`dash.syncCodexSubagentDefaults`)}),(0,z.jsx)(`div`,{className:`muted setting-hint`,children:c(`dash.syncCodexSubagentDefaultsHint`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`switch ${a?`on`:``}`,onClick:()=>s({syncCodexSubagentDefaults:!a}),disabled:o||!e,"aria-label":c(`dash.syncCodexSubagentDefaults`),"aria-pressed":a,children:(0,z.jsx)(`span`,{className:`knob`})})]}),(0,z.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,z.jsxs)(`div`,{className:`setting-copy`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:c(`dash.multiAgentGuidance`)}),(0,z.jsx)(`div`,{className:`muted setting-hint`,children:c(`dash.multiAgentGuidanceHint`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`switch ${i?`on`:``}`,onClick:()=>s({multiAgentGuidanceEnabled:!i}),disabled:o,"aria-label":c(`dash.multiAgentGuidance`),"aria-pressed":i,children:(0,z.jsx)(`span`,{className:`knob`})})]})]})}function dc({available:e,chosen:t,busy:n=!1,onToggle:r,onMove:i,onSave:a,delegation:o}){let s=K(),[c,l]=(0,_.useState)(``),u=(0,_.useMemo)(()=>new Set(t),[t]),d=t.length>=5,f=(0,_.useMemo)(()=>{let t=c.trim().toLowerCase();return e.filter(e=>!t||e.toLowerCase().includes(t))},[e,c]);return(0,z.jsxs)(`div`,{className:`subagents-workspace-shell`,children:[(0,z.jsx)(lc,{scope:`subagents`,items:(0,_.useMemo)(()=>[{id:`featured`,label:s(`sub.featured`),meta:`${t.length}/5`},{id:`models`,label:s(`sub.models`),meta:String(f.length)},{id:`settings`,label:s(`sub.settings`)}],[s,t.length,f.length]),ariaLabel:s(`sub.sections`)}),(0,z.jsxs)(`div`,{className:`subagents-workspace-root`,children:[(0,z.jsxs)(`section`,{id:oc(`subagents`,`featured`),className:`subagents-workspace-section`,"aria-label":s(`sub.featured`),children:[(0,z.jsxs)(`div`,{className:`swi-featured-head`,children:[(0,z.jsx)(`h2`,{className:`swi-featured-title`,children:s(`sub.featured`)}),(0,z.jsxs)(`span`,{className:`swi-featured-count`,children:[t.length,`/`,5]})]}),(0,z.jsxs)(`p`,{className:`swi-featured-hint`,children:[(0,z.jsx)(fe,{width:15,height:15,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:(0,z.jsx)(Ue,{k:`sub.orderHint`,cmd:`spawn_agent`})})]}),t.length===0?(0,z.jsx)(`div`,{className:`swi-featured-empty`,children:s(`sub.noneSelected`)}):(0,z.jsx)(`div`,{className:`swi-featured-list`,children:t.map((e,a)=>(0,z.jsxs)(`div`,{className:`swi-featured-row`,children:[(0,z.jsx)(`span`,{className:`swi-featured-pos`,children:a+1}),(0,z.jsx)(`span`,{className:`swi-featured-name`,children:zo(e)}),(0,z.jsxs)(`span`,{className:`swi-featured-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>i(a,-1),disabled:n||a===0,"aria-label":s(`sub.moveUp`,{m:e}),children:(0,z.jsx)(me,{})}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>i(a,1),disabled:n||a===t.length-1,"aria-label":s(`sub.moveDown`,{m:e}),children:(0,z.jsx)(he,{})}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>r(e),disabled:n,"aria-label":s(`sub.removeAria`,{m:e}),style:{color:`var(--red)`},children:(0,z.jsx)(ae,{})})]})]},e))}),(0,z.jsx)(`div`,{className:`swi-save-row`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:a,disabled:n,children:s(`common.save`)})})]}),(0,z.jsxs)(`section`,{id:oc(`subagents`,`models`),className:`subagents-workspace-section`,"aria-label":s(`sub.models`),children:[(0,z.jsxs)(`div`,{className:`swi-featured-head`,children:[(0,z.jsx)(`h2`,{className:`swi-featured-title`,children:s(`sub.models`)}),(0,z.jsx)(`span`,{className:`swi-featured-count`,children:f.length})]}),(0,z.jsxs)(`div`,{className:`swi-picker-box`,children:[(0,z.jsx)(`div`,{className:`subagents-workspace-rail-search`,children:(0,z.jsx)(`input`,{className:`input`,value:c,onChange:e=>l(e.target.value),placeholder:s(`sub.search`),"aria-label":s(`sub.search`)})}),(0,z.jsx)(`div`,{className:`subagents-workspace-rail-list`,children:f.length===0?(0,z.jsx)(`span`,{className:`subagents-workspace-rail-empty`,children:s(`sub.noModels`)}):f.map(e=>{let i=u.has(e),a=i?t.indexOf(e)+1:null,o=!i&&(d||n);return(0,z.jsxs)(`div`,{className:`subagents-workspace-rail-row${i?` subagents-workspace-rail-row--selected`:``}`,children:[(0,z.jsxs)(`span`,{className:`subagents-workspace-rail-row-main`,children:[(0,z.jsx)(`span`,{className:`swi-rail-priority`,children:a??``}),(0,z.jsx)(W,{className:`swi-rail-icon`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`subagents-workspace-rail-name`,children:zo(e)})]}),(0,z.jsx)(`button`,{type:`button`,className:`subagents-workspace-rail-toggle${i?` subagents-workspace-rail-toggle--on`:``}${o?` subagents-workspace-rail-toggle--disabled`:``}`,onClick:()=>{o||r(e)},disabled:o,"aria-pressed":i,"aria-label":s(i?`sub.workspace.removeFromFeatured`:`sub.workspace.addToFeatured`,{m:e}),title:i?s(`sub.workspace.removeFromFeatured`,{m:e}):d?s(`sub.workspace.featuredFull`):s(`sub.workspace.addToFeatured`,{m:e}),children:i?(0,z.jsx)(ie,{style:{width:14,height:14}}):(0,z.jsx)(oe,{style:{width:14,height:14}})})]},e)})})]})]}),(0,z.jsxs)(`section`,{id:oc(`subagents`,`settings`),className:`subagents-workspace-section`,"aria-label":s(`sub.settings`),children:[(0,z.jsx)(`div`,{className:`swi-featured-head`,children:(0,z.jsx)(`h2`,{className:`swi-featured-title`,children:s(`sub.settings`)})}),(0,z.jsx)(uc,{model:o.model,effort:o.effort,efforts:o.efforts,available:o.available,guidanceEnabled:o.guidanceEnabled,syncCodexDefaults:o.syncCodexDefaults,saving:o.saving,onSave:o.onSave})]})]})]})}function fc(e){let[t,n]=(0,_.useState)(!1),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)([]),[p,m]=(0,_.useState)(!0),[h,g]=(0,_.useState)(!1),v=(0,_.useCallback)(e=>{let t=gn(e);m(t.multiAgentGuidanceEnabled),g(t.syncCodexSubagentDefaults),o(t.injectionModel),c(t.injectionEffort),Array.isArray(e.efforts)&&u(e.efforts),Array.isArray(e.available)&&f(e.available)},[]);return(0,_.useEffect)(()=>{let t=!1;return(async()=>{try{let n=await ht(await fetch(`${e}/api/injection-model`));if(t)return;v(n)}catch{}finally{t||n(!0)}})(),()=>{t=!0}},[e,v]),{loaded:t,saving:r,model:a,effort:s,efforts:l,available:d,guidanceEnabled:p,syncCodexDefaults:h,save:(0,_.useCallback)(async t=>{if(!r){i(!0);try{if(!(await fetch(`${e}/api/injection-model`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).ok)throw Error(`injection save failed`);v(await ht(await fetch(`${e}/api/injection-model`)))}catch{}finally{i(!1)}}},[e,v,r])}}function pc(e){return Y(e)}function mc({apiBase:e}){let t=K(),n=`ocx.subagents.v1:${e}`,r=pc(n),[i,a]=(0,_.useState)(()=>r?.chosen??[]),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),f=(0,_.useRef)(!1),p=fc(e),m=(0,_.useCallback)(async()=>{let r=await J(await fetch(`${e}/api/subagent-models`),t(`sub.loadFail`));if(!r)throw Error(t(`sub.loadFail`));let i=r.available??[],o=new Set(i),s={available:i,chosen:(r.chosen??[]).filter(e=>o.has(e))};return a(s.chosen),X(n,s),s},[e,n,t]),h=us(n,[e],m,{isEmpty:()=>!1,initialData:r??void 0}),{state:g}=h,v=h.refresh,y=g.data??r,b=y?.available??[],x=e=>{u||(s(``),a(t=>t.includes(e)?t.filter(t=>t!==e):t.length>=5?t:[...t,e]))},S=(e,t)=>{u||a(n=>{let r=[...n],i=e+t;return i<0||i>=r.length?n:([r[e],r[i]]=[r[i],r[e]],r)})},C=async()=>{if(!(u||f.current)){f.current=!0,d(!0),s(``);try{let r=await J(await fetch(`${e}/api/subagent-models`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({models:i})}),t(`sub.saveFailed`)),o=r?.applied??i;r?.applied&&a(r.applied),X(n,{available:b,chosen:o}),l(!0),s(t(`sub.saved`,{n:o.length,cmd:`ocx sync`}))}catch(e){l(!1),s(e instanceof Error&&e.message?e.message:t(`sub.networkError`))}finally{f.current=!1,d(!1)}}};return g.showSkeleton&&!y?(0,z.jsx)(fs,{label:t(`sub.loading`),rows:4}):g.kind===`failed-cold`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(q,{tone:`err`,children:g.error instanceof Error?g.error.message:t(`sub.loadFail`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>v(),children:t(`common.retry`)})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:t(`nav.subagents`)})}),o&&(0,z.jsx)(q,{tone:c?`ok`:`err`,children:o}),g.showError&&(0,z.jsx)(q,{tone:`err`,children:t(`sub.loadFail`)}),(0,z.jsx)(dc,{available:b,chosen:i,busy:u,onToggle:x,onMove:S,onSave:()=>{C()},delegation:{model:p.model,effort:p.effort,efforts:p.efforts,available:p.available,guidanceEnabled:p.guidanceEnabled,syncCodexDefaults:p.syncCodexDefaults,saving:p.saving,onSave:e=>{p.save(e)}}})]})}function hc(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function gc(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function _c(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var vc=(e,t)=>Math.abs(e-t)<1.01,yc=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},bc,xc=()=>{if(bc!==void 0)return bc;if(typeof navigator>`u`)return bc=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return bc=!0;let e=navigator.maxTouchPoints;return bc=navigator.platform===`MacIntel`&&e!==void 0&&e>0},Sc=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Cc=e=>e,wc=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},Tc=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(Sc(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(Sc(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Ec={passive:!0},Dc=typeof window>`u`?!0:`onscrollend`in window,Oc=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Dc,o=0,s=a?null:yc(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,Ec),a&&r.addEventListener(`scrollend`,u,Ec),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},kc=(e,t)=>Oc(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),Ac=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},jc=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},Mc=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Cc,rangeExtractor:wc,onChange:()=>{},measureElement:Ac,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=e>0?s[0]?.key??n.getItemKey(0):null,l=e>0?s[e-1]?.key??n.getItemKey(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==c||t.getItemKey(o-1)!==l)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==l)&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:i,getItemKey:a}=this.options,c=0;for(;c<i&&a(c)!==e;)c++;if(c<i){let e=n[c];if(e){let n=e.start+t;n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=gc(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!xc()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,Ec),e.addEventListener(`touchend`,n,Ec),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(xc()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=gc(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=gc(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=hc(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=gc(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=Fc(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=gc(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);if(o!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,s=a?this.getTotalSize():0,c=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(i)||this.scrollDirection!==`backward`):this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,a?this.applyScrollAdjustment(this.getTotalSize()-s):c&&this.applyScrollAdjustment(o),this.notify(!1)}},this.getVirtualItems=gc(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return _c(t[Nc(0,t.length-1,r?e=>n[e*2]:e=>_c(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){e!==0&&(xc()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&vc(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},Nc=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Pc(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function Fc(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=Pc(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=Nc(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var Ic=typeof document<`u`?_.useLayoutEffect:_.useEffect;function Lc({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=_.useReducer(e=>e+1,0)[1],a=_.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}let r=!!e.options.horizontal,i=t.mode===`transform`,o=r?`left`:`top`,s=e.options.scrollMargin,c=e.getVirtualItems();for(let n of c){let a=n.start-s,c=e.elementsCache.get(n.key);c&&t.lastPositions.get(c)!==a&&(t.lastPositions.set(c,a),i?c.style.transform=r?`translate3d(${a}px, 0, 0)`:`translate3d(0, ${a}px, 0)`:c.style[o]=`${a}px`)}},s={...r,onChange:(t,n)=>{var s;let c=a.current,l=!0;if(c.enabled){o(t);let e=t.range,n=c.prevRange;l=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,l&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}l&&(e&&n?(0,qe.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[c]=_.useState(()=>{let e=new Mc(s);return Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return c.setOptions(s),Ic(()=>c._didMount(),[]),Ic(()=>c._willUpdate()),Ic(()=>{o(c)}),c}function Rc(e){return Lc({observeElementRect:Tc,observeElementOffset:kc,scrollToFn:jc,...e})}var zc=32;function Bc(e){return[...new Uint8Array(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}function Vc(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=31||n===127)return!0}return!1}async function Hc(e){let t=e.trim();if(t&&!Vc(t)&&!(t.length>4096))return Bc(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(t))).slice(0,zc)}function Uc(e,t,n){if(!e)return!1;let r=t.trim();return r?e===r?!0:n!==void 0&&e===n:!1}var Wc={400:{en:{label:`Bad request`,description:`The proxy could not understand the request. Check the model, message shape, headers, and JSON body before retrying.`},ko:{label:`잘못된 요청`,description:`프록시가 요청을 이해할 수 없습니다. 재시도 전에 모델, 메시지 형식, 헤더, JSON 본문을 확인해야 합니다.`},zh:{label:`错误请求`,description:`代理无法理解该请求。重试前请检查模型、消息结构、标头和 JSON 正文。`},de:{label:`Ungültige Anfrage`,description:`Der Proxy konnte die Anfrage nicht verstehen. Prüfe Modell, Nachrichtenformat, Header und JSON-Body vor einem erneuten Versuch.`},ru:{label:`Некорректный запрос`,description:`Прокси не смог интерпретировать запрос. Перед повторной попыткой проверьте модель, формат сообщений, заголовки и тело JSON.`},ja:{label:`不正なリクエスト`,description:`プロキシがリクエストを解釈できませんでした。再試行前にモデル、メッセージ形式、ヘッダー、JSON 本文を確認してください。`}},401:{en:{label:`Unauthorized`,description:`Credentials are missing, expired, or invalid. Re-login or refresh the account/provider credentials used by opencodex.`},ko:{label:`인증 필요`,description:`자격 증명이 없거나 만료되었거나 유효하지 않습니다. opencodex에서 사용하는 계정 또는 제공자 자격 증명을 다시 로그인하거나 갱신해야 합니다.`},zh:{label:`未授权`,description:`凭据缺失、已过期或无效。请重新登录,或刷新 opencodex 使用的账号/提供商凭据。`},de:{label:`Nicht autorisiert`,description:`Anmeldedaten fehlen, sind abgelaufen oder ungültig. Melde dich erneut an oder aktualisiere die von opencodex genutzten Konto-/Anbieter-Zugangsdaten.`},ru:{label:`Не авторизован`,description:`Учётные данные отсутствуют, истекли или недействительны. Войдите заново или обновите учётные данные аккаунта или провайдера, которые использует opencodex.`},ja:{label:`認証が必要`,description:`認証情報が不在・期限切れ・無効です。opencodex が使用するアカウントまたはプロバイダー認証情報を再ログインまたは更新してください。`}},402:{en:{label:`Payment required`,description:`The upstream provider rejected the request because billing, credits, or plan access is not available. Add credits, update billing, or switch provider.`},ko:{label:`결제 필요`,description:`청구, 크레딧, 플랜 접근 권한 문제로 업스트림 제공자가 요청을 거부했습니다. 크레딧 추가, 결제 정보 갱신, 제공자 전환이 필요합니다.`},zh:{label:`需要付款`,description:`上游提供商因账单、额度或套餐权限不可用而拒绝了请求。请充值、更新账单信息或切换提供商。`},de:{label:`Zahlung erforderlich`,description:`Der Upstream-Anbieter hat die Anfrage abgelehnt, weil Abrechnung, Guthaben oder Planzugriff nicht verfügbar ist. Guthaben aufladen, Abrechnung aktualisieren oder Anbieter wechseln.`},ru:{label:`Требуется оплата`,description:`Вышестоящий провайдер отклонил запрос из-за проблем с оплатой, кредитами или доступом по тарифному плану. Пополните баланс, обновите платёжные данные или переключитесь на другого провайдера.`},ja:{label:`支払いが必要`,description:`課金、クレジット、プランアクセスが利用できないため上流プロバイダーがリクエストを拒否しました。クレジット追加、支払い情報更新、プロバイダー切替が必要です。`}},403:{en:{label:`Forbidden`,description:`The account is authenticated but not allowed to use this model or operation. Often a plan/subscription gate (e.g. Ollama Cloud Pro), org policy, or model permission — not necessarily a bad API key.`},ko:{label:`권한 없음`,description:`계정 인증은 되었지만 이 모델 또는 작업을 사용할 권한이 없습니다. 플랜/구독 제한(예: Ollama Cloud Pro), 조직 정책, 모델 권한 문제인 경우가 많으며 API 키가 잘못된 것은 아닐 수 있습니다.`},zh:{label:`禁止访问`,description:`账号已认证,但无权使用此模型或操作。常见原因是套餐/订阅限制(例如 Ollama Cloud Pro)、组织策略或模型权限——不一定是 API 密钥无效。`},de:{label:`Verboten`,description:`Das Konto ist authentifiziert, darf dieses Modell oder diese Operation aber nicht nutzen. Oft Plan-/Abo-Sperre (z. B. Ollama Cloud Pro), Organisationsrichtlinie oder Modellrecht — nicht zwingend ein ungültiger API-Key.`},ru:{label:`Доступ запрещён`,description:`Аккаунт аутентифицирован, но не имеет права использовать эту модель или операцию. Часто причина — ограничение тарифа или подписки (например, Ollama Cloud Pro), политика организации или права доступа к модели, а не обязательно неверный API-ключ.`},ja:{label:`アクセス禁止`,description:`アカウントは認証済みですがこのモデルや操作の使用が許可されていません。多くはプラン/サブスクリプション制限(例: Ollama Cloud Pro)、組織ポリシー、モデル権限であり、API キーが不正とは限りません。`}},404:{en:{label:`Not found`,description:`The requested route, model, account, or upstream resource was not found. Verify the model name and opencodex provider configuration.`},ko:{label:`찾을 수 없음`,description:`요청한 경로, 모델, 계정 또는 업스트림 리소스를 찾을 수 없습니다. 모델 이름과 opencodex 제공자 설정을 확인해야 합니다.`},zh:{label:`未找到`,description:`找不到请求的路由、模型、账号或上游资源。请确认模型名称和 opencodex 提供商配置。`},de:{label:`Nicht gefunden`,description:`Die angeforderte Route, das Modell, das Konto oder die Upstream-Ressource wurde nicht gefunden. Prüfe Modellname und opencodex-Anbieterkonfiguration.`},ru:{label:`Не найдено`,description:`Запрошенный маршрут, модель, аккаунт или вышестоящий ресурс не найден. Проверьте имя модели и конфигурацию провайдера в opencodex.`},ja:{label:`見つかりません`,description:`要求されたルート、モデル、アカウント、上流リソースが見つかりませんでした。モデル名と opencodex プロバイダー設定を確認してください。`}},408:{en:{label:`Request timeout`,description:`The request took too long before the proxy or upstream provider could complete it. Retry with a smaller request or a different provider.`},ko:{label:`요청 시간 초과`,description:`프록시 또는 업스트림 제공자가 요청을 완료하기 전에 시간이 초과되었습니다. 더 작은 요청으로 재시도하거나 다른 제공자로 전환해야 합니다.`},zh:{label:`请求超时`,description:`代理或上游提供商未能在限定时间内完成请求。请缩小请求后重试,或切换提供商。`},de:{label:`Anfrage-Timeout`,description:`Die Anfrage dauerte zu lange, bevor Proxy oder Upstream-Anbieter sie abschließen konnten. Mit kleinerer Anfrage oder anderem Anbieter erneut versuchen.`},ru:{label:`Тайм-аут запроса`,description:`Обработка запроса заняла слишком много времени, и прокси или вышестоящий провайдер не успел её завершить. Повторите попытку с меньшим запросом или через другого провайдера.`},ja:{label:`リクエストタイムアウト`,description:`プロキシまたは上流プロバイダーがリクエストを完了する前に時間切れになりました。より小さいリクエストで再試行するか、別のプロバイダーに切り替えてください。`}},409:{en:{label:`Conflict`,description:`The request conflicts with the current account, session, or provider state. Refresh the session or retry after the active operation finishes.`},ko:{label:`상태 충돌`,description:`요청이 현재 계정, 세션 또는 제공자 상태와 충돌합니다. 세션을 갱신하거나 진행 중인 작업이 끝난 뒤 재시도해야 합니다.`},zh:{label:`状态冲突`,description:`请求与当前账号、会话或提供商状态冲突。请刷新会话,或等待当前操作完成后重试。`},de:{label:`Konflikt`,description:`Die Anfrage kollidiert mit dem aktuellen Konto-, Sitzungs- oder Anbieterstatus. Sitzung aktualisieren oder nach Abschluss der laufenden Operation erneut versuchen.`},ru:{label:`Конфликт`,description:`Запрос конфликтует с текущим состоянием аккаунта, сессии или провайдера. Обновите сессию или повторите попытку после завершения текущей операции.`},ja:{label:`状態の衝突`,description:`リクエストが現在のアカウント、セッション、プロバイダー状態と衝突しています。セッションを更新するか、進行中の操作が終わった後に再試行してください。`}},413:{en:{label:`Request too large`,description:`The prompt, attachments, or generated payload exceeds a proxy or upstream limit. Reduce tokens, file size, or conversation history.`},ko:{label:`요청 과대`,description:`프롬프트, 첨부 파일 또는 생성 페이로드가 프록시나 업스트림 한도를 초과했습니다. 토큰, 파일 크기, 대화 기록을 줄여야 합니다.`},zh:{label:`请求过大`,description:`提示、附件或生成的负载超过了代理或上游限制。请减少 token、文件大小或对话历史。`},de:{label:`Anfrage zu groß`,description:`Prompt, Anhänge oder generierte Nutzlast überschreiten ein Proxy- oder Upstream-Limit. Tokens, Dateigröße oder Verlauf reduzieren.`},ru:{label:`Слишком большой запрос`,description:`Промпт, вложения или сформированная полезная нагрузка превышают лимит прокси или вышестоящего провайдера. Сократите количество токенов, размер файлов или историю диалога.`},ja:{label:`リクエストが大きすぎます`,description:`プロンプト、添付ファイル、生成ペイロードがプロキシまたは上流の制限を超えました。トークン、ファイルサイズ、会話履歴を減らしてください。`}},422:{en:{label:`Invalid content`,description:`The provider accepted the request format but rejected its contents. Check model options, tool definitions, message roles, and unsupported fields.`},ko:{label:`내용 검증 실패`,description:`제공자가 요청 형식은 받았지만 내용을 거부했습니다. 모델 옵션, 도구 정의, 메시지 역할, 지원되지 않는 필드를 확인해야 합니다.`},zh:{label:`内容无效`,description:`提供商接受了请求格式,但拒绝了其中的内容。请检查模型选项、工具定义、消息角色和不支持的字段。`},de:{label:`Ungültiger Inhalt`,description:`Der Anbieter akzeptierte das Anfrageformat, lehnte den Inhalt aber ab. Prüfe Modelloptionen, Tool-Definitionen, Nachrichtenrollen und nicht unterstützte Felder.`},ru:{label:`Недопустимое содержимое`,description:`Провайдер принял формат запроса, но отклонил его содержимое. Проверьте параметры модели, определения инструментов, роли сообщений и неподдерживаемые поля.`},ja:{label:`内容の検証失敗`,description:`プロバイダーはリクエスト形式を受け付けましたが内容を拒否しました。モデルオプション、ツール定義、メッセージロール、未サポートのフィールドを確認してください。`}},424:{en:{label:`Provider dependency failed`,description:`A required upstream dependency failed while opencodex was routing the request. Retry later or switch to another configured provider.`},ko:{label:`제공자 의존성 실패`,description:`opencodex가 요청을 라우팅하는 동안 필요한 업스트림 의존성이 실패했습니다. 나중에 재시도하거나 다른 설정된 제공자로 전환해야 합니다.`},zh:{label:`提供商依赖失败`,description:`opencodex 路由请求时,必需的上游依赖失败。请稍后重试,或切换到另一个已配置的提供商。`},de:{label:`Anbieter-Abhängigkeit fehlgeschlagen`,description:`Eine erforderliche Upstream-Abhängigkeit ist fehlgeschlagen, während opencodex die Anfrage geroutet hat. Später erneut versuchen oder zu einem anderen Anbieter wechseln.`},ru:{label:`Сбой зависимости провайдера`,description:`Необходимая вышестоящая зависимость дала сбой, пока opencodex маршрутизировал запрос. Повторите попытку позже или переключитесь на другого настроенного провайдера.`},ja:{label:`プロバイダー依存の失敗`,description:`opencodex がリクエストをルーティング中に必要な上流依存が失敗しました。後で再試行するか、別の設定済みプロバイダーに切り替えてください。`}},429:{en:{label:`Rate limited`,description:`The upstream provider rate or quota limit has been reached. Wait for the quota window to reset or switch account/provider.`},ko:{label:`한도 초과`,description:`업스트림 제공자의 속도 또는 할당량 한도에 도달했습니다. 한도 창이 초기화될 때까지 기다리거나 계정/제공자를 전환해야 합니다.`},zh:{label:`限流`,description:`已达到上游提供商的速率或额度限制。请等待额度窗口重置,或切换账号/提供商。`},de:{label:`Ratenlimit erreicht`,description:`Das Raten- oder Kontingentlimit des Upstream-Anbieters ist erreicht. Auf Reset des Kontingentfensters warten oder Konto/Anbieter wechseln.`},ru:{label:`Превышен лимит запросов`,description:`Достигнут лимит скорости или квота вышестоящего провайдера. Дождитесь сброса окна квоты или переключитесь на другой аккаунт или провайдера.`},ja:{label:`レート制限`,description:`上流プロバイダーのレートまたはクォータ制限に達しました。クォータウィンドウがリセットされるまで待つか、アカウント/プロバイダーを切り替えてください。`}},499:{en:{label:`Client closed request`,description:`The client disconnected or canceled the request before opencodex finished routing it. Retry if the cancellation was accidental.`},ko:{label:`클라이언트 취소`,description:`opencodex가 라우팅을 끝내기 전에 클라이언트 연결이 끊기거나 요청이 취소되었습니다. 의도한 취소가 아니면 다시 시도해야 합니다.`},zh:{label:`客户端已取消`,description:`opencodex 完成路由前,客户端已断开连接或取消请求。如果不是有意取消,请重试。`},de:{label:`Client hat Anfrage geschlossen`,description:`Der Client hat die Verbindung getrennt oder die Anfrage abgebrochen, bevor opencodex das Routing abgeschlossen hat. Bei versehentlichem Abbruch erneut versuchen.`},ru:{label:`Запрос закрыт клиентом`,description:`Клиент отключился или отменил запрос до того, как opencodex завершил его маршрутизацию. Если отмена была случайной, повторите попытку.`},ja:{label:`クライアントがリクエストをクローズ`,description:`opencodex がルーティングを終える前にクライアントが切断またはキャンセルしました。意図しないキャンセルなら再試行してください。`}},500:{en:{label:`Proxy error`,description:`opencodex hit an internal error while handling the request. Retry once, then check proxy logs if it repeats.`},ko:{label:`프록시 오류`,description:`opencodex가 요청을 처리하는 동안 내부 오류가 발생했습니다. 한 번 재시도하고 반복되면 프록시 로그를 확인해야 합니다.`},zh:{label:`代理错误`,description:`opencodex 处理请求时发生内部错误。请先重试一次;如果重复出现,请检查代理日志。`},de:{label:`Proxy-Fehler`,description:`opencodex ist bei der Anfragebearbeitung auf einen internen Fehler gestoßen. Einmal erneut versuchen, bei Wiederholung Proxy-Logs prüfen.`},ru:{label:`Ошибка прокси`,description:`В opencodex произошла внутренняя ошибка при обработке запроса. Повторите попытку один раз; если ошибка повторяется, проверьте логи прокси.`},ja:{label:`プロキシエラー`,description:`opencodex がリクエスト処理中に内部エラーに遭遇しました。1 回再試行し、繰り返す場合はプロキシログを確認してください。`}},502:{en:{label:`Bad upstream response`,description:`The upstream provider returned an invalid or failed response through the proxy. Retry or route the request to another provider.`},ko:{label:`업스트림 응답 오류`,description:`업스트림 제공자가 프록시를 통해 유효하지 않거나 실패한 응답을 반환했습니다. 재시도하거나 다른 제공자로 라우팅해야 합니다.`},zh:{label:`上游响应错误`,description:`上游提供商通过代理返回了无效或失败的响应。请重试,或将请求路由到其他提供商。`},de:{label:`Ungültige Upstream-Antwort`,description:`Der Upstream-Anbieter lieferte über den Proxy eine ungültige oder fehlgeschlagene Antwort. Erneut versuchen oder zu einem anderen Anbieter routen.`},ru:{label:`Некорректный ответ провайдера`,description:`Вышестоящий провайдер вернул через прокси недействительный или ошибочный ответ. Повторите попытку или направьте запрос другому провайдеру.`},ja:{label:`上流レスポンス不良`,description:`上流プロバイダーがプロキシ経由で無効または失敗したレスポンスを返しました。再試行するか、リクエストを別のプロバイダーにルーティングしてください。`}},503:{en:{label:`Provider unavailable`,description:`The proxy or upstream provider is temporarily unavailable or overloaded. Wait briefly, then retry or switch provider.`},ko:{label:`제공자 사용 불가`,description:`프록시 또는 업스트림 제공자가 일시적으로 사용할 수 없거나 과부하 상태입니다. 잠시 기다린 뒤 재시도하거나 제공자를 전환해야 합니다.`},zh:{label:`提供商不可用`,description:`代理或上游提供商暂时不可用或过载。请稍后重试,或切换提供商。`},de:{label:`Anbieter nicht verfügbar`,description:`Proxy oder Upstream-Anbieter ist vorübergehend nicht verfügbar oder überlastet. Kurz warten, dann erneut versuchen oder Anbieter wechseln.`},ru:{label:`Провайдер недоступен`,description:`Прокси или вышестоящий провайдер временно недоступен или перегружен. Немного подождите, затем повторите попытку или смените провайдера.`},ja:{label:`プロバイダー利用不可`,description:`プロキシまたは上流プロバイダーが一時的に利用不可または過負荷です。少し待ってから再試行するか、プロバイダーを切り替えてください。`}},504:{en:{label:`Upstream timeout`,description:`The upstream provider did not respond before the proxy timeout. Retry with a smaller request or choose a faster provider.`},ko:{label:`업스트림 시간 초과`,description:`프록시 시간 제한 전에 업스트림 제공자가 응답하지 않았습니다. 더 작은 요청으로 재시도하거나 더 빠른 제공자를 선택해야 합니다.`},zh:{label:`上游超时`,description:`上游提供商未在代理超时前响应。请缩小请求后重试,或选择响应更快的提供商。`},de:{label:`Upstream-Timeout`,description:`Der Upstream-Anbieter antwortete nicht vor dem Proxy-Timeout. Mit kleinerer Anfrage erneut versuchen oder schnelleren Anbieter wählen.`},ru:{label:`Тайм-аут вышестоящего провайдера`,description:`Вышестоящий провайдер не ответил до истечения тайм-аута прокси. Повторите попытку с меньшим запросом или выберите более быстрого провайдера.`},ja:{label:`上流タイムアウト`,description:`上流プロバイダーがプロキシタイムアウト前に応答しませんでした。より小さいリクエストで再試行するか、より速いプロバイダーを選んでください。`}},529:{en:{label:`Provider overloaded`,description:`The upstream provider is overloaded or capacity-limited. Wait and retry, or switch to another account/provider.`},ko:{label:`제공자 과부하`,description:`업스트림 제공자가 과부하 상태이거나 처리 용량이 제한되었습니다. 기다렸다가 재시도하거나 다른 계정/제공자로 전환해야 합니다.`},zh:{label:`提供商过载`,description:`上游提供商过载或容量受限。请等待后重试,或切换到其他账号/提供商。`},de:{label:`Anbieter überlastet`,description:`Der Upstream-Anbieter ist überlastet oder kapazitätsbegrenzt. Warten und erneut versuchen oder anderes Konto/Anbieter nutzen.`},ru:{label:`Провайдер перегружен`,description:`Вышестоящий провайдер перегружен или ограничен по мощности. Подождите и повторите попытку либо переключитесь на другой аккаунт или провайдера.`},ja:{label:`プロバイダー過負荷`,description:`上流プロバイダーが過負荷または容量制限されています。待ってから再試行するか、別のアカウント/プロバイダーに切り替えてください。`}}},Gc={client:{en:{label:`Request error`,description:`The proxy or upstream provider rejected the request. Check the request shape, credentials, model name, and provider configuration.`},ko:{label:`요청 오류`,description:`프록시 또는 업스트림 제공자가 요청을 거부했습니다. 요청 형식, 자격 증명, 모델 이름, 제공자 설정을 확인해야 합니다.`},zh:{label:`请求错误`,description:`代理或上游提供商拒绝了该请求。请检查请求结构、凭据、模型名称和提供商配置。`},de:{label:`Anfragefehler`,description:`Der Proxy oder Upstream-Anbieter hat die Anfrage abgelehnt. Prüfe Anfrageformat, Anmeldedaten, Modellname und Anbieterkonfiguration.`},ru:{label:`Ошибка запроса`,description:`Прокси или вышестоящий провайдер отклонил запрос. Проверьте структуру запроса, учётные данные, имя модели и конфигурацию провайдера.`},ja:{label:`リクエストエラー`,description:`プロキシまたは上流プロバイダーがリクエストを拒否しました。リクエスト形式、認証情報、モデル名、プロバイダー設定を確認してください。`}},server:{en:{label:`Server or upstream error`,description:`opencodex or an upstream provider failed while processing the request. Retry later or route the request to another provider.`},ko:{label:`서버 또는 업스트림 오류`,description:`opencodex 또는 업스트림 제공자가 요청 처리 중 실패했습니다. 나중에 재시도하거나 다른 제공자로 라우팅해야 합니다.`},zh:{label:`服务器或上游错误`,description:`opencodex 或上游提供商处理请求时失败。请稍后重试,或将请求路由到其他提供商。`},de:{label:`Server- oder Upstream-Fehler`,description:`opencodex oder ein Upstream-Anbieter ist bei der Anfragebearbeitung fehlgeschlagen. Später erneut versuchen oder zu einem anderen Anbieter routen.`},ru:{label:`Ошибка сервера или провайдера`,description:`opencodex или вышестоящий провайдер завершил обработку запроса с ошибкой. Повторите попытку позже или направьте запрос другому провайдеру.`},ja:{label:`サーバーまたは上流エラー`,description:`opencodex または上流プロバイダーがリクエスト処理中に失敗しました。後で再試行するか、リクエストを別のプロバイダーにルーティングしてください。`}}};function Kc(e){return e===`de`||e===`ko`||e===`zh`||e===`ru`||e===`ja`?e:`en`}function qc(e,t){if(e<400)return null;let n=Kc(t);return(Wc[Math.trunc(e)]??(e<500?Gc.client:Gc.server))[n]}var Jc=[`provider`,`usage`,`injection`];function Yc(e){return e>0?`[${new Date(e).toLocaleTimeString()}] `:``}function Xc(e){return new Date(e).toLocaleTimeString()}function Zc(e,t){return t===`provider`?!!e?.enabled:t===`usage`?!!e?.usage:!!e?.injection}function Qc(e,t){return t===`debug`?e.enabled:t===`usage`?e.usage:t===`injection`?e.injection:e.claude}function $c({entries:e}){let{t}=Ve();return(0,z.jsxs)(`div`,{className:`card`,style:{marginBottom:16,padding:`12px 14px`},children:[(0,z.jsx)(`div`,{className:`font-semibold`,style:{marginBottom:4},children:t(`debug.claudeInbound.title`)}),(0,z.jsx)(`div`,{className:`muted text-control`,style:{marginBottom:10},children:t(`debug.claudeInbound.sub`)}),e.length===0?(0,z.jsx)(`div`,{className:`muted text-control`,children:t(`debug.claudeInbound.empty`)}):(0,z.jsx)(`div`,{style:{overflowX:`auto`},children:(0,z.jsxs)(`table`,{className:`table text-label`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:t(`debug.claudeInbound.time`)}),(0,z.jsx)(`th`,{children:t(`debug.claudeInbound.endpoint`)}),(0,z.jsx)(`th`,{children:t(`debug.claudeInbound.model`)}),(0,z.jsx)(`th`,{children:`thinking`}),(0,z.jsx)(`th`,{children:`effort`}),(0,z.jsx)(`th`,{children:`beta`}),(0,z.jsx)(`th`,{children:`metadata`}),(0,z.jsx)(`th`,{children:`system`})]})}),(0,z.jsx)(`tbody`,{children:e.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`muted mono`,children:Xc(e.at)}),(0,z.jsx)(`td`,{className:`mono`,children:e.endpoint}),(0,z.jsxs)(`td`,{className:`mono`,title:e.resolvedModel,children:[e.model,e.resolvedModel&&e.resolvedModel!==e.model&&(0,z.jsxs)(`span`,{className:`muted`,children:[` → `,e.resolvedModel]})]}),(0,z.jsxs)(`td`,{className:`mono`,children:[e.thinkingType??`-`,e.thinkingBudgetTokens!==void 0&&(0,z.jsxs)(`span`,{className:`muted`,children:[` (`,e.thinkingBudgetTokens,`)`]})]}),(0,z.jsx)(`td`,{className:`mono`,children:e.outputConfigEffort??`-`}),(0,z.jsx)(`td`,{className:`mono`,title:e.anthropicBeta,style:{maxWidth:160,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.anthropicBeta??`-`}),(0,z.jsx)(`td`,{className:`mono`,title:e.metadataKeys?.join(`, `),children:e.hasMetadataUserId?`user_id ${e.userIdTag??``}`:t(`debug.claudeInbound.none`)}),(0,z.jsx)(`td`,{className:`mono`,children:e.hasSystem?e.systemTag??`yes`:t(`debug.claudeInbound.none`)})]},e.id))})]})})]})}function el({debug:e,stream:t,streamEnabled:n,entries:r,scrollContainerRef:i,lineVirtualizer:a}){let{t:o}=Ve();return e?n?r.length===0?(0,z.jsxs)(`div`,{className:`empty`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,style:{marginBottom:6},children:o(`debug.noLinesTitle`)}),(0,z.jsx)(`div`,{className:`muted text-control`,style:{maxWidth:560,marginInline:`auto`},children:o(`debug.noLines.${t}`)})]}):(0,z.jsx)(`div`,{ref:i,className:`log-detail-json`,style:{maxHeight:`calc(100vh - 280px)`,overflow:`auto`},children:(0,z.jsx)(`div`,{style:{position:`relative`,height:a.getTotalSize(),width:`100%`},children:a.getVirtualItems().map(e=>(0,z.jsx)(`div`,{ref:a.measureElement,"data-index":e.index,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:`${Yc(r[e.index].at)}${r[e.index].line}`},e.key))})}):(0,z.jsxs)(`div`,{className:`empty`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,style:{marginBottom:6},children:o(`debug.emptyTitle`)}),(0,z.jsx)(`div`,{className:`muted text-control`,style:{maxWidth:560,marginInline:`auto`},children:o(`debug.empty`)})]}):null}function tl({debug:e,debugBusy:t,stream:n,onSetFlag:r,onReset:i,onStreamChange:a}){let{t:o}=Ve();return(0,z.jsxs)(`div`,{className:`card`,style:{marginBottom:16,padding:`12px 14px`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:12,flexWrap:`wrap`},children:[(0,z.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:16},children:[`debug`,`usage`,`injection`,`claude`].map(n=>{let i=Qc(e,n);return(0,z.jsxs)(`div`,{style:{display:`inline-flex`,alignItems:`center`,gap:10,minWidth:220},children:[(0,z.jsx)(it,{on:i,disabled:t,label:o(`debug.${n}`),onClick:()=>r(n,!i)}),(0,z.jsx)(`span`,{className:`text-control`,children:o(`debug.${n}`)})]},n)})}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:t,onClick:i,children:o(`debug.reset`)})]}),(e.enabled||e.usage||e.injection)&&(0,z.jsxs)(`div`,{style:{display:`inline-flex`,gap:6,marginTop:12},children:[e.enabled&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm${n===`provider`?` btn-primary`:` btn-ghost`}`,onClick:()=>a(`provider`),children:o(`debug.streamProvider`)}),e.usage&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm${n===`usage`?` btn-primary`:` btn-ghost`}`,onClick:()=>a(`usage`),children:o(`debug.streamUsage`)}),e.injection&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm${n===`injection`?` btn-primary`:` btn-ghost`}`,onClick:()=>a(`injection`),children:o(`debug.streamInjection`)})]})]})}function nl({embedded:e,refreshing:t,streamEnabled:n,follow:r,onRefresh:i,onFollowChange:a}){let{t:o}=Ve();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:e?`row`:`page-head`,style:e?{justifyContent:`flex-end`,marginBottom:4}:void 0,children:[!e&&(0,z.jsx)(`h2`,{children:o(`debug.title`)}),(0,z.jsxs)(`div`,{style:{display:`inline-flex`,alignItems:`center`,gap:12},children:[(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:t||!n,onClick:i,children:[(0,z.jsx)(se,{}),` `,o(`debug.refresh`)]}),(0,z.jsxs)(`label`,{className:`muted text-control`,style:{cursor:`pointer`,display:`inline-flex`,alignItems:`center`,gap:6},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>a(e.target.checked)}),o(`debug.follow`)]})]})]}),(0,z.jsx)(`p`,{className:`page-sub`,children:o(`debug.subtitle`)})]})}function rl(e){return`debug-settings:${e}`}function il({apiBase:e,embedded:t,active:n=!0}){let{t:r}=Ve(),i=`ocx.debug.settings.v1:${e}`,a=Y(i),o=rl(e),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(`provider`),[d,f]=(0,_.useState)([]),[p,m]=(0,_.useState)(!0),[h,g]=(0,_.useState)(!1),v=(0,_.useRef)(0),y=(0,_.useRef)(0),b=(0,_.useRef)(0),x=(0,_.useRef)(null),S=(0,_.useRef)(null),C=(0,_.useRef)(null),w=us(o,[e],async t=>{let n=await fetch(`${e}/api/debug`,{signal:t});if(!n.ok)throw Error(String(n.status));let r=await n.json();return X(i,r),r},{pollMs:2e3,enabled:n,isEmpty:()=>!1,initialData:a??void 0}),T=w.state,E=w.data??a??null,D=I(`debug-claude-inbound:${e}`,[e,E?.claude],async t=>{let n=await fetch(`${e}/api/claude/inbound-debug`,{signal:t});if(!n.ok)return[];let r=await n.json();return Array.isArray(r.entries)?r.entries:[]},{pollMs:2e3,enabled:n&&!!E?.claude}).data??[],O=Rc({count:d.length,getScrollElement:()=>S.current,estimateSize:()=>20,overscan:30,getItemKey:e=>d[e].seq}),k=(0,_.useCallback)(e=>Zc(E,e),[E]);(0,_.useEffect)(()=>{if(!E||k(l))return;let e=Jc.find(k);if(!e)return;let t=window.setTimeout(()=>u(e),0);return()=>window.clearTimeout(t)},[E,l,k]);let A=k(l),j=l===`provider`?`${e}/api/debug/logs`:l===`usage`?`${e}/api/debug/usage-logs`:`${e}/api/debug/injection-logs`,M=(0,_.useCallback)(async(e,t)=>{let n=++b.current;if(!A){n===b.current&&(f([]),v.current=0);return}g(!0);try{let r=new URLSearchParams({limit:`500`});!e&&v.current>0&&r.set(`after`,String(v.current));let i=await fetch(`${j}?${r}`,{signal:t});if(!i.ok||t?.aborted||n!==b.current)return;let a=await i.json();if(t?.aborted||n!==b.current||a.length===0)return;f(t=>(e?a:[...t,...a]).slice(-2e3)),v.current=a[a.length-1].seq}catch{}finally{n===b.current&&g(!1)}},[j,A]);(0,_.useEffect)(()=>{if(!n)return;let t=`${e}:${l}:${A}`,r=C.current!==t;if(C.current=t,!r&&d.length>0)return;v.current=0;let i=new AbortController,a=window.setTimeout(()=>{r&&f([]),M(!0,i.signal)},0);return()=>{window.clearTimeout(a),b.current+=1,i.abort()}},[n,e,l,A]);let N=(0,_.useEffectEvent)(e=>{M(e)});(0,_.useEffect)(()=>{if(!n||!p||!A)return;let e=setInterval(()=>N(!1),1e3);return()=>clearInterval(e)},[n,p,A]),(0,_.useEffect)(()=>{p&&d.length>0&&O.scrollToIndex(d.length-1,{align:`end`})},[d,p,O]);let P=async t=>{let n=++y.current;c(!0);let r=async()=>{try{let r=await fetch(`${e}/api/debug`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!r.ok)return;let a=await r.json();if(n!==y.current)return;X(i,a),L(o,a)}catch{}},a=(x.current??Promise.resolve()).then(r,r);x.current=a.then(()=>void 0,()=>void 0);try{await a}finally{n===y.current&&c(!1)}},F=async(e,t)=>{await P({[e]:t})},R=async()=>{await P({reset:!0})};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(nl,{embedded:t,refreshing:h,streamEnabled:A,follow:p,onRefresh:()=>void M(!0),onFollowChange:m}),!E&&T.showError?(0,z.jsxs)(`div`,{className:`notice notice-err`,role:`alert`,children:[(0,z.jsx)(`span`,{children:r(`debug.loadFailed`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>w.refresh(),children:r(`common.retry`)})]}):T.showSkeleton&&!E?(0,z.jsx)(fs,{label:r(`debug.loading`),rows:3}):E?(0,z.jsx)(tl,{debug:E,debugBusy:s,stream:l,onSetFlag:(e,t)=>{F(e,t)},onReset:()=>{R()},onStreamChange:u}):null,E&&T.showError&&(0,z.jsx)(q,{tone:`err`,children:r(`debug.loadFailed`)}),E?.claude&&(0,z.jsx)($c,{entries:D}),(0,z.jsx)(el,{debug:!!E,stream:l,streamEnabled:A,entries:d,scrollContainerRef:S,lineVirtualizer:O})]})}function al(){return window.location.hash.replace(/^#\/?/,``)===`logs/debug`?`debug`:`logs`}function ol(e){window.location.hash=e===`debug`?`logs/debug`:`logs`}function sl(e){e.key===`ArrowLeft`||e.key===`Home`?(e.preventDefault(),ol(`logs`),document.getElementById(`logs-tab-logs`)?.focus()):(e.key===`ArrowRight`||e.key===`End`)&&(e.preventDefault(),ol(`debug`),document.getElementById(`logs-tab-debug`)?.focus())}function cl(e){return e.requestedSpeedLabel||void 0}function ll(e,t){return t===`all`?!0:t===`claude`?e.surface===`claude`||e.surface===`claude-desktop`:t===`grok`?e.surface===`grok`:e.surface===void 0}function ul(e){return`ocx.logs.list.v1:${e}`}function dl(e){if(!Array.isArray(e))return null;for(let t of e)if(!t||typeof t!=`object`||typeof t.timestamp!=`number`||typeof t.model!=`string`||typeof t.provider!=`string`||typeof t.status!=`number`||typeof t.durationMs!=`number`)return null;return e}function fl(e){return e===`cursor`||e.startsWith(`cursor-`)}function pl(e,t){if(!e.usage)return;let n=gl(e),r=[`${t(`logs.tokens.input`)}=${e.usage.inputTokens}`,`${t(`logs.tokens.output`)}=${e.usage.outputTokens}`];return n.read!==void 0&&r.push(`${t(`logs.tokens.cacheRead`)}=${n.read}`),n.write!==void 0&&r.push(`${t(`logs.tokens.cacheWrite`)}=${n.write}`),typeof e.usage.contextTotalTokens==`number`&&r.push(`${t(`logs.tokens.contextTotal`)}=${e.usage.contextTotalTokens}`),typeof e.usage.reasoningOutputTokens==`number`&&r.push(`${t(`logs.tokens.reasoning`)}=${e.usage.reasoningOutputTokens}`),e.usageStatus===`estimated`&&r.push(t(`logs.tokens.estimatedNote`)),e.usageStatus===`estimated`&&n.read===void 0&&n.write===void 0&&r.push(t(fl(e.provider)?`logs.tokens.noCacheCursorNote`:`logs.tokens.noCacheNote`)),r.join(` · `)}function ml(e){if(!e.usage)return typeof e.totalTokens==`number`?e.totalTokens:void 0;let t=e.usage.inputTokens+e.usage.outputTokens,n=e.usage.totalTokens??e.totalTokens;return typeof n==`number`?Math.max(n,t):t}function hl(e){let t=ml(e),n=e.usage?.contextTotalTokens;return typeof n==`number`?Math.max(t??0,n)||void 0:t}function gl(e){let t=e.usage;if(!t)return{};let n=typeof t.cacheCreationInputTokens==`number`?t.cacheCreationInputTokens:void 0;return{read:typeof t.cacheReadInputTokens==`number`?t.cacheReadInputTokens:typeof t.cachedInputTokens==`number`&&n!==void 0?Math.max(0,t.cachedInputTokens-n):t.cachedInputTokens,write:n}}function _l(e){let t=e.requestedEffort?.replace(/\s*->\s*/g,` → `),n=e.effectiveEffort;return t?!n||t===n||t.split(` → `).at(-1)===n?t:`${t} → ${n}`:n??`-`}function vl(e){if(!(!e.reasoningWireField||e.reasoningWireValue===void 0))return`${e.reasoningWireField}=${e.reasoningWireValue}`}function yl(e,t){if(!e||e.kind===`unavailable`||!Number.isFinite(e.value)||e.value<=0)return`—`;let n=e.value>=100?0:1,r=new Intl.NumberFormat(t,{minimumFractionDigits:n,maximumFractionDigits:n}).format(e.value);return`${e.estimated?`~`:``}${r}`}function bl(e,t){if(!e||e.kind===`unavailable`||!Number.isFinite(e.estimate.cost.total)||e.estimate.cost.total<0)return`—`;let n=e.estimate.cost.total;return`~$${new Intl.NumberFormat(t,{minimumFractionDigits:4,maximumFractionDigits:4}).format(n)}`}function xl(e,t){return!Number.isFinite(e)||e<0?`—`:`~$${new Intl.NumberFormat(t,{minimumFractionDigits:4,maximumFractionDigits:4}).format(e)}`}var Sl=3,Cl={usage_missing:`logs.detail.reason.usage_missing`,usage_unsupported:`logs.detail.reason.usage_unsupported`,output_missing:`logs.detail.reason.output_missing`,invalid_duration:`logs.detail.reason.invalid_duration`,price_unmatched:`logs.detail.reason.price_unmatched`,invalid_cache_breakdown:`logs.detail.reason.invalid_cache_breakdown`,invalid_usage:`logs.detail.reason.invalid_usage`,combo_attempt_unavailable:`logs.detail.reason.combo_attempt_unavailable`},wl={usage_estimated:`logs.detail.estimate.usage_estimated`,cache_detail_missing:`logs.detail.estimate.cache_detail_missing`,expected_price_overlay:`logs.detail.estimate.expected_price_overlay`};function Tl(e){return Cl[e]}function El(e){return wl[e]}function Dl(e){return e===`verified`?`logs.detail.verification.verified`:`logs.detail.verification.derived`}function Ol(e){return e>=200&&e<300?`var(--green)`:e>=400?`var(--red)`:`var(--amber)`}function kl(e,t,n){let r=n?{timeZone:n}:void 0;try{return{date:new Date(e).toLocaleDateString(t,r),time:new Date(e).toLocaleTimeString(t,r)}}catch{return{date:new Date(e).toLocaleDateString(t),time:new Date(e).toLocaleTimeString(t)}}}function Al(e,t,n){let{date:r,time:i}=kl(e,t,n);return`${r} ${i}`}function jl(e){return[`model=${e.model}`,e.resolvedModel?`resolved=${e.resolvedModel}`:void 0,e.requestedServiceTier?`requestedTier=${e.requestedServiceTier}`:void 0,e.configuredServiceTier?`configuredTier=${e.configuredServiceTier}`:void 0,e.responseServiceTier?`responseTier=${e.responseServiceTier}`:void 0,e.modelSupportsServiceTier===void 0?void 0:`supportsTier=${e.modelSupportsServiceTier}`].filter(Boolean).join(` · `)}function Ml(e){let t=0,n=0,r=0,i=0;for(let a of e){let e=ml(a);if(e!==void 0&&(t+=e),a.usageStatus===`unsupported`){i+=1;continue}let o=a.displayMetrics?.cost,s=o?.kind===`value`?o.estimate.cost.total:void 0;if(s!==void 0&&Number.isFinite(s)&&s>=0){n+=s;continue}r+=1}return{requests:e.length,totalTokens:t,estimatedCostUsd:n,unpricedRequests:r,unmeteredRequests:i}}function Nl({apiBase:e}){let{t,locale:n}=Ve(),r=ul(e),i=dl(Y(r)),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(`all`),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(),h=(0,_.useRef)(null),g=Ie.find(e=>e.code===n)?.htmlLang,[v,y]=(0,_.useState)();(0,_.useEffect)(()=>{let t=new AbortController,n=!1;return fetch(`${e}/api/settings`,{signal:t.signal}).then(e=>e.ok?e.json():null).then(e=>{n||!e||typeof e.timeZone==`string`&&e.timeZone.trim()&&y(e.timeZone.trim())}).catch(()=>{}),()=>{n=!0,t.abort()}},[e]);let[b,x]=(0,_.useState)(al),[S,C]=(0,_.useState)(()=>al()===`debug`);(0,_.useEffect)(()=>{let e=()=>x(al());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),(0,_.useEffect)(()=>{b===`debug`&&C(!0)},[b]);let w=ol,T=(0,_.useCallback)(async t=>{let n=await fetch(`${e}/api/logs?limit=2000`,{signal:t});if(!n.ok)throw Error(`${n.status} ${n.statusText}`.trim());let i=await n.json(),a=Array.isArray(i)?i:i.logs??[];return X(r,a),a},[e,r]),E=us(r,[e],T,{isEmpty:e=>e.length===0,enabled:b===`logs`,pollMs:a?2e3:void 0,initialData:i??void 0}),D=E.state,O=D.data??i??[],k=E.refresh,A=!E.refreshing&&D.showError,j=!E.refreshing&&!D.showError&&D.data!==void 0,[M,N]=(0,_.useState)({error:null,count:0});j&&M.count!==0?N({error:null,count:0}):A&&M.error!==D.error&&N(e=>({error:D.error,count:e.count+1}));let P=M.count>=Sl||!a&&A,F=s?qc(s.status,n):null,I=d.trim();(0,_.useEffect)(()=>{let e=!1;if(!I){m(void 0);return}return Hc(I).then(t=>{e||m(t)}),()=>{e=!0}},[I]);let L=O.filter(e=>ll(e,l)&&(!I||Uc(e.conversationId,I,p))),R=I?Ml(L):null,B=Rc({count:L.length,getScrollElement:()=>h.current,estimateSize:()=>44,overscan:15}),V=B.getVirtualItems(),H=V.length>0?V[0].start:0,U=V.length>0?B.getTotalSize()-V[V.length-1].end:0;return(0,z.jsxs)(`div`,{className:`logs-page`,children:[(0,z.jsxs)(`div`,{className:`page-head`,children:[(0,z.jsx)(`h2`,{children:t(`nav.logs`)}),b===`logs`&&(0,z.jsxs)(`label`,{className:`muted text-control logs-auto-refresh`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),t(`logs.autoRefresh`)]})]}),(0,z.jsxs)(`div`,{className:`page-tabs`,role:`tablist`,"aria-label":t(`nav.logs`),children:[(0,z.jsx)(`button`,{type:`button`,role:`tab`,id:`logs-tab-logs`,"aria-selected":b===`logs`,"aria-controls":`logs-panel-logs`,tabIndex:b===`logs`?0:-1,className:`page-tab${b===`logs`?` page-tab--active`:``}`,onClick:()=>w(`logs`),onKeyDown:sl,children:t(`logs.tabLogs`)}),(0,z.jsx)(`button`,{type:`button`,role:`tab`,id:`logs-tab-debug`,"aria-selected":b===`debug`,"aria-controls":`logs-panel-debug`,tabIndex:b===`debug`?0:-1,className:`page-tab${b===`debug`?` page-tab--active`:``}`,onClick:()=>w(`debug`),onKeyDown:sl,children:t(`logs.tabDebug`)})]}),S&&(0,z.jsx)(`div`,{role:`tabpanel`,id:`logs-panel-debug`,"aria-labelledby":`logs-tab-debug`,hidden:b!==`debug`,children:(0,z.jsx)(il,{apiBase:e,embedded:!0,active:b===`debug`})}),(0,z.jsxs)(`div`,{role:`tabpanel`,id:`logs-panel-logs`,"aria-labelledby":`logs-tab-logs`,hidden:b!==`logs`,children:[(0,z.jsx)(`p`,{className:`page-sub`,children:t(`logs.subtitle`)}),(0,z.jsxs)(`div`,{className:`logs-toolbar`,children:[(0,z.jsx)(`span`,{className:`muted text-control`,children:t(`logs.filter.surface.label`)}),(0,z.jsx)(`div`,{className:`segmented logs-segmented`,role:`radiogroup`,"aria-label":t(`logs.filter.surface.label`),children:[`all`,`claude`,`codex`,`grok`].map(e=>(0,z.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":l===e,className:`btn btn-sm${l===e?` btn-primary`:` btn-ghost`}`,style:{background:l===e?void 0:`transparent`,color:l===e?void 0:`var(--muted)`},onClick:()=>u(e),children:t(`logs.filter.surface.${e}`)},e))}),(0,z.jsxs)(`label`,{className:`muted text-control logs-filter-field`,children:[t(`logs.filter.conversation.label`),(0,z.jsx)(`input`,{type:`search`,className:`input mono`,value:d,onChange:e=>f(e.target.value),placeholder:t(`logs.filter.conversation.placeholder`),"aria-label":t(`logs.filter.conversation.label`)})]}),I&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>f(``),children:t(`logs.filter.conversation.clear`)})]}),R&&(0,z.jsx)(`div`,{className:`logs-conversation-totals`,children:(0,z.jsxs)(q,{tone:`ok`,children:[t(`logs.conversation.totals`,{requests:R.requests,tokens:Pt(R.totalTokens,g??n),cost:xl(R.estimatedCostUsd,g)}),` `,(0,z.jsxs)(`span`,{className:`muted`,children:[t(`logs.conversation.scope`),R.unpricedRequests+R.unmeteredRequests>0?` ${t(`logs.conversation.excluded`,{unpriced:R.unpricedRequests,unmetered:R.unmeteredRequests})}`:``]})]})}),D.kind===`failed-cold`&&(0,z.jsxs)(q,{tone:`err`,children:[D.error instanceof Error?`${t(`logs.loadError`)} ${D.error.message}`:t(`logs.loadError`),` `,(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>k({forceLoading:!0}),disabled:D.refreshing,children:t(`common.retry`)})]}),P&&O.length>0&&(0,z.jsxs)(q,{tone:`err`,children:[t(`logs.loadError`),` `,(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>k({forceLoading:!0}),disabled:E.refreshing,children:t(`common.retry`)})]}),D.kind===`failed-cold`?null:D.showSkeleton&&O.length===0?(0,z.jsx)(fs,{label:t(`common.loading`),rows:6}):L.length===0?(0,z.jsx)(ot,{title:t(`logs.noRequests`)}):(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(`div`,{ref:h,className:`tbl-wrap logs-table-wrap`,children:(0,z.jsxs)(`table`,{className:`tbl logs-table`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:t(`logs.col.time`)}),(0,z.jsx)(`th`,{className:`num log-col-tokens`,children:t(`logs.col.tokens`)}),(0,z.jsx)(`th`,{className:`num log-col-rate`,title:t(`logs.metric.tokPerSecTitle`),children:t(`logs.col.tokPerSec`)}),(0,z.jsx)(`th`,{className:`num log-col-cost`,title:t(`logs.metric.estimatedCostTitle`),children:t(`logs.col.estimatedCost`)}),(0,z.jsx)(`th`,{className:`log-col-model`,children:t(`logs.col.model`)}),(0,z.jsx)(`th`,{children:t(`logs.col.effort`)}),(0,z.jsx)(`th`,{children:t(`logs.col.provider`)}),(0,z.jsx)(`th`,{children:t(`logs.col.status`)}),(0,z.jsx)(`th`,{children:t(`logs.col.request`)}),(0,z.jsx)(`th`,{className:`num log-col-duration`,children:t(`logs.col.duration`)})]})}),(0,z.jsxs)(`tbody`,{children:[H>0&&(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:10,className:`logs-virtual-spacer`,style:{height:H}})}),V.map(e=>{let r=L[L.length-1-e.index],i=vl(r),a=kl(r.timestamp,g,v);return(0,z.jsxs)(`tr`,{"data-index":e.index,ref:B.measureElement,children:[(0,z.jsx)(`td`,{className:`muted mono log-col-time`,children:(0,z.jsxs)(`span`,{className:`logs-stack-start`,children:[(0,z.jsx)(`span`,{children:a.date}),(0,z.jsx)(`span`,{children:a.time})]})}),(0,z.jsx)(`td`,{className:`num mono log-col-tokens`,title:pl(r,t),children:(()=>{let e=hl(r),{read:i,write:a}=gl(r);return e===void 0?(0,z.jsx)(`span`,{className:`muted`,children:t(`logs.tokens.${r.usageStatus??`unreported`}`)}):(0,z.jsxs)(`span`,{className:`logs-stack-end`,children:[(0,z.jsxs)(`span`,{children:[r.usageStatus===`estimated`?`~`:``,Pt(e,n)]}),i!==void 0&&i>0&&(0,z.jsxs)(`span`,{className:`muted text-caption leading-tight`,children:[`c `,Pt(i,n)]}),a!==void 0&&a>0&&(0,z.jsxs)(`span`,{className:`muted text-caption leading-tight`,children:[`w `,Pt(a,n)]}),r.usageStatus===`estimated`&&i===void 0&&a===void 0&&(0,z.jsx)(`span`,{className:`muted text-caption leading-tight`,children:t(fl(r.provider)?`logs.tokens.noCacheCursor`:`logs.tokens.noCache`)})]})})()}),(0,z.jsx)(`td`,{className:`num mono log-col-rate`,children:yl(r.displayMetrics?.tokPerSecond,g)}),(0,z.jsx)(`td`,{className:`num mono log-col-cost`,children:bl(r.displayMetrics?.cost,g)}),(0,z.jsx)(`td`,{className:`mono log-col-model`,title:jl(r),children:(0,z.jsxs)(`span`,{className:`logs-model-cell`,children:[(0,z.jsx)(`span`,{children:zo(r.resolvedModel??r.model)}),(r.surface===`claude`||r.surface===`claude-desktop`)&&(0,z.jsx)(`span`,{className:`badge badge-accent`,children:t(`logs.badge.claude`)}),r.surface===`grok`&&(0,z.jsx)(`span`,{className:`badge badge-accent`,children:t(`logs.badge.grok`)}),cl(r)&&(0,z.jsx)(`span`,{className:`badge badge-amber`,children:cl(r)})]})}),(0,z.jsx)(`td`,{className:`mono log-reasoning-cell`,title:i,children:(0,z.jsxs)(`span`,{className:`logs-stack-start`,children:[(0,z.jsx)(`span`,{children:_l(r)}),i&&(0,z.jsx)(`span`,{className:`muted text-caption leading-tight`,children:i})]})}),(0,z.jsx)(`td`,{className:`muted`,children:r.provider}),(0,z.jsx)(`td`,{children:(0,z.jsxs)(`span`,{className:`log-status-cell`,children:[(0,z.jsx)(`span`,{className:`mono font-semibold`,style:{color:Ol(r.status)},children:r.status}),(0,z.jsx)(`button`,{type:`button`,className:`log-detail-btn`,onClick:()=>c(r),"aria-label":`${t(`logs.details`)}: ${r.requestId??r.status}`,children:t(`logs.details`)})]})}),(0,z.jsx)(`td`,{className:`muted mono`,children:(0,z.jsx)(`span`,{className:`log-reqid`,title:r.requestId,children:r.requestId??`-`})}),(0,z.jsxs)(`td`,{className:`num log-col-duration`,children:[r.durationMs,`ms`]})]},r.requestId??`${r.timestamp}-${e.index}`)}),U>0&&(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:10,className:`logs-virtual-spacer`,style:{height:U}})})]})]})})}),s&&(0,z.jsx)(Pl,{detail:s,detailInfo:F,localeCode:n,localeTag:g,serverTimeZone:v,t,onClose:()=>c(null),onFilterConversation:e=>{f(e),c(null)}})]})]})}function $(e){let t=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let n=t.current;n&&(e&&!n.open?n.showModal():!e&&n.open&&n.close())},[e]),t}function Pl({detail:e,detailInfo:t,localeCode:n,localeTag:r,serverTimeZone:i,t:a,onClose:o,onFilterConversation:s}){let c=$(!0),[l,u]=(0,_.useState)(!1),d=gl(e),f=e.displayMetrics?.cost,p=vl(e),m=async()=>{if(e.requestId)try{await navigator.clipboard.writeText(e.requestId),u(!0),window.setTimeout(()=>u(!1),1200)}catch{}};return(0,z.jsx)(`dialog`,{ref:c,className:`modal-overlay`,"aria-labelledby":`log-detail-title`,onCancel:e=>{e.preventDefault(),o()},children:(0,z.jsxs)(`div`,{className:`modal-card log-detail-card`,children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsxs)(`h3`,{id:`log-detail-title`,children:[(0,z.jsx)(`span`,{className:`mono`,style:{color:Ol(e.status)},children:e.status}),t&&(0,z.jsx)(`span`,{className:`logs-detail-info`,children:t.label})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:o,"aria-label":a(`common.cancel`),children:(0,z.jsx)(ae,{})})]}),t&&(0,z.jsx)(`p`,{className:`modal-desc`,children:t.description}),(0,z.jsxs)(`section`,{className:`log-detail-section`,"aria-labelledby":`log-detail-basic`,children:[(0,z.jsx)(`h4`,{id:`log-detail-basic`,className:`log-detail-section-title`,children:a(`logs.detail.section.basic`)}),(0,z.jsxs)(`div`,{className:`log-detail-grid`,children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.time`)}),(0,z.jsx)(`span`,{className:`mono`,children:Al(e.timestamp,r,i)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.request`)}),(0,z.jsxs)(`span`,{className:`log-detail-request-row`,children:[(0,z.jsx)(`span`,{className:`mono log-detail-break`,children:e.requestId??`—`}),e.requestId&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void m(),children:a(l?`logs.detail.copied`:`logs.detail.copyRequestId`)})]}),e.conversationId&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.detail.conversation`)}),(0,z.jsxs)(`span`,{className:`log-detail-request-row`,children:[(0,z.jsx)(`span`,{className:`mono log-detail-break`,children:e.conversationId}),s&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>s(e.conversationId),children:a(`logs.filter.conversation.apply`)})]})]}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.model`)}),(0,z.jsx)(`span`,{className:`mono`,children:zo(e.resolvedModel??e.model)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.provider`)}),(0,z.jsx)(`span`,{children:e.provider}),(e.requestedEffort||e.effectiveEffort)&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.effort`)}),(0,z.jsxs)(`span`,{className:`mono`,children:[_l(e),p?` (${p})`:``]})]}),e.errorCode&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.error`)}),(0,z.jsx)(`span`,{className:`mono`,children:e.errorCode})]}),e.upstreamError&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.upstreamReason`)}),(0,z.jsx)(`span`,{className:`mono log-detail-break`,children:e.upstreamError})]})]})]}),(0,z.jsxs)(`section`,{className:`log-detail-section`,"aria-labelledby":`log-detail-performance`,children:[(0,z.jsx)(`h4`,{id:`log-detail-performance`,className:`log-detail-section-title`,children:a(`logs.detail.section.performance`)}),(0,z.jsxs)(`div`,{className:`log-detail-grid`,children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.duration`)}),(0,z.jsxs)(`span`,{className:`mono`,children:[e.durationMs,`ms`]}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.col.tokPerSec`)}),(0,z.jsx)(`span`,{className:`mono`,children:yl(e.displayMetrics?.tokPerSecond,r)}),e.firstOutputMs!==void 0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.detail.ttft`)}),(0,z.jsxs)(`span`,{className:`mono`,children:[e.firstOutputMs,`ms`]})]})]}),e.displayMetrics?.tokPerSecond.kind===`unavailable`&&(0,z.jsx)(`p`,{className:`log-detail-notes-line muted`,children:a(Tl(e.displayMetrics.tokPerSecond.reason))})]}),(0,z.jsxs)(`section`,{className:`log-detail-section`,"aria-labelledby":`log-detail-cost`,children:[(0,z.jsx)(`h4`,{id:`log-detail-cost`,className:`log-detail-section-title`,children:a(`logs.detail.section.cost`)}),(0,z.jsx)(`p`,{className:`log-detail-notes-line muted`,children:a(`usage.cost.disclaimer`)}),f?.kind===`value`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`log-detail-grid`,children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.detail.costTotal`)}),(0,z.jsx)(`span`,{className:`mono`,children:xl(f.estimate.cost.total,r)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.input`)}),(0,z.jsx)(`span`,{className:`mono`,children:xl(f.estimate.cost.input,r)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.cacheRead`)}),(0,z.jsx)(`span`,{className:`mono`,children:xl(f.estimate.cost.cacheRead,r)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.cacheWrite`)}),(0,z.jsx)(`span`,{className:`mono`,children:xl(f.estimate.cost.cacheWrite,r)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.output`)}),(0,z.jsx)(`span`,{className:`mono`,children:xl(f.estimate.cost.output,r)}),f.estimate.price&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.detail.matchedKey`)}),(0,z.jsxs)(`span`,{className:`mono log-detail-break`,children:[f.estimate.price.jawcodeProvider??f.estimate.price.provider,`/`,f.estimate.price.modelId]}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.detail.priceSource`)}),(0,z.jsxs)(`span`,{children:[a(`logs.detail.source.${f.estimate.price.source}`),` · `,a(Dl(f.estimate.price.status))]})]})]}),f.estimateReasons.length>0&&(0,z.jsx)(`ul`,{className:`log-detail-notes`,children:f.estimateReasons.map(e=>(0,z.jsx)(`li`,{children:a(El(e))},e))})]}):(0,z.jsxs)(`div`,{className:`log-detail-grid`,children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.detail.costTotal`)}),(0,z.jsx)(`span`,{className:`mono`,children:`—`}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.detail.unavailableReason`)}),(0,z.jsx)(`span`,{children:f?.kind===`unavailable`?a(Tl(f.reason)):a(`logs.detail.reason.usage_missing`)})]})]}),e.attempts?.length?(0,z.jsxs)(`section`,{className:`log-detail-section`,"aria-labelledby":`log-detail-attempts`,children:[(0,z.jsx)(`h4`,{id:`log-detail-attempts`,className:`log-detail-section-title`,children:a(`logs.detail.section.attempts`)}),(0,z.jsx)(`p`,{className:`log-detail-notes-line muted`,children:a(`logs.detail.attempt.e2eNote`)}),(0,z.jsx)(`div`,{className:`log-detail-attempts-wrap`,children:(0,z.jsxs)(`table`,{className:`tbl log-detail-attempts`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{className:`num`,children:`#`}),(0,z.jsx)(`th`,{children:a(`logs.detail.attempt.target`)}),(0,z.jsx)(`th`,{className:`num`,children:a(`logs.col.duration`)}),(0,z.jsx)(`th`,{className:`num`,children:a(`logs.col.tokPerSec`)}),(0,z.jsx)(`th`,{className:`num`,children:a(`logs.col.estimatedCost`)}),(0,z.jsx)(`th`,{children:a(`logs.detail.attempt.reason`)})]})}),(0,z.jsx)(`tbody`,{children:e.attempts.toSorted((e,t)=>e.ordinal-t.ordinal).map(e=>{let t=e.displayMetrics?.cost,n=vl(e),i=t?.kind===`value`?t.estimate.price:void 0,o=e.errorCode??(e.recoveryKinds.length?e.recoveryKinds.join(`, `):void 0)??(t?.kind===`unavailable`?a(Tl(t.reason)):a(`logs.detail.attempt.completed`));return(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`num mono`,children:e.ordinal}),(0,z.jsxs)(`td`,{children:[(0,z.jsx)(`span`,{children:e.provider}),(0,z.jsx)(`br`,{}),(0,z.jsx)(`span`,{className:`mono muted log-detail-break`,children:e.model}),(e.requestedEffort||e.effectiveEffort)&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`br`,{}),(0,z.jsxs)(`span`,{className:`mono muted text-caption log-detail-break`,children:[_l(e),n?` (${n})`:``]})]}),i&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`br`,{}),(0,z.jsxs)(`span`,{className:`muted text-caption log-detail-break`,children:[i.jawcodeProvider??i.provider,`/`,i.modelId,` · `,a(`logs.detail.source.${i.source}`),` · `,a(Dl(i.status))]})]})]}),(0,z.jsxs)(`td`,{className:`num mono`,children:[e.durationMs,`ms`]}),(0,z.jsx)(`td`,{className:`num mono`,children:yl(e.displayMetrics?.tokPerSecond,r)}),(0,z.jsx)(`td`,{className:`num mono`,children:bl(t,r)}),(0,z.jsx)(`td`,{className:`log-detail-break`,children:o})]},`${e.ordinal}-${e.provider}-${e.model}`)})})]})})]}):null,(0,z.jsxs)(`section`,{className:`log-detail-section`,"aria-labelledby":`log-detail-usage`,children:[(0,z.jsx)(`h4`,{id:`log-detail-usage`,className:`log-detail-section-title`,children:a(`logs.detail.section.usage`)}),(0,z.jsxs)(`div`,{className:`log-detail-grid`,children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.input`)}),(0,z.jsx)(`span`,{className:`mono`,children:e.usage?Pt(e.usage.inputTokens,n):`—`}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.output`)}),(0,z.jsx)(`span`,{className:`mono`,children:e.usage?Pt(e.usage.outputTokens,n):`—`}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.cacheRead`)}),(0,z.jsx)(`span`,{className:`mono`,children:d.read===void 0?`—`:Pt(d.read,n)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.cacheWrite`)}),(0,z.jsx)(`span`,{className:`mono`,children:d.write===void 0?`—`:Pt(d.write,n)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.reasoning`)}),(0,z.jsx)(`span`,{className:`mono`,children:e.usage?.reasoningOutputTokens===void 0?`—`:Pt(e.usage.reasoningOutputTokens,n)}),(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.detail.totalTokens`)}),(0,z.jsx)(`span`,{className:`mono`,children:hl(e)===void 0?`—`:Pt(hl(e),n)}),e.usage?.contextTotalTokens!==void 0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`muted`,children:a(`logs.tokens.contextTotal`)}),(0,z.jsx)(`span`,{className:`mono`,children:Pt(e.usage.contextTotalTokens,n)})]})]}),e.usageStatus===`estimated`&&(0,z.jsx)(`p`,{className:`log-detail-notes-line muted`,children:a(`logs.tokens.estimatedNote`)})]}),(0,z.jsxs)(`details`,{className:`log-detail-raw`,children:[(0,z.jsx)(`summary`,{children:a(`logs.detailRaw`)}),(0,z.jsx)(`pre`,{className:`log-detail-json`,children:JSON.stringify(e,null,2)})]})]})})}function Fl(e){return`${Math.round(e*100)}%`}function Il(e,t){let n=`${t}/${e}`,r=0;for(let e=0;e<n.length;e++)r=r*31+n.charCodeAt(e)>>>0;return`hsl(${r%360} 55% 55%)`}function Ll(e){let t=new Map(e.map(e=>[e.date,e])),n=[],r=new Date;r.setHours(0,0,0,0),r.setDate(r.getDate()-6);for(let e=0;e<7;e++){let e=`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,`0`)}-${String(r.getDate()).padStart(2,`0`)}`,i=t.get(e);n.push({date:e,requests:i?.requests??0,measuredRequests:i?.measuredRequests??0,reportedRequests:i?.reportedRequests??0,totalTokens:i?.totalTokens??0,models:i?.models??[]}),r.setDate(r.getDate()+1)}return n}function Rl(e){let t=e.filter(e=>e>0).sort((e,t)=>e-t);if(t.length===0)return[0,0,0,0];let n=e=>t[Math.min(t.length-1,Math.floor(e*t.length))];return[n(.25),n(.5),n(.75),n(.95)]}function zl(e,t){return e<=0?0:e<=t[0]?1:e<=t[1]?2:e<=t[2]?3:4}function Bl(e){let t=Rl(e.map(e=>e.totalTokens)),n=new Map(e.map(e=>[e.date,e])),r=new Date;r.setHours(0,0,0,0);let i=new Date(r);i.setDate(i.getDate()-364),i.setDate(i.getDate()-i.getDay());let a=[],o=[],s=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],c=-4,l=-1,u=[],d=new Date(i);for(;d<=r;){let e=`${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,`0`)}-${String(d.getDate()).padStart(2,`0`)}`,r=d.getMonth();d.getDay()===0&&r!==l&&a.length-c>=4&&(o.push({label:s[r],col:a.length}),c=a.length,l=r);let i=n.get(e);u.push({date:e,requests:i?.requests??0,totalTokens:i?.totalTokens??0,level:i?zl(i.totalTokens,t):0,dayOfWeek:d.getDay()}),d.getDay()===6&&(a.push(u),u=[]),d.setDate(d.getDate()+1)}if(u.length>0){for(;u.length<7;)u.push({date:``,requests:0,totalTokens:0,level:0,dayOfWeek:u.length});a.push(u)}return{weeks:a,months:o,buckets:t}}function Vl({surface:e,range:t,onSurface:n,onRange:r,t:i}){return(0,z.jsxs)(`div`,{className:`usage-filters`,children:[(0,z.jsx)(`div`,{className:`usage-segmented`,role:`group`,"aria-label":i(`logs.filter.surface.label`),children:[`all`,`codex`,`claude`,`grok`].map(t=>{let r=i(`logs.filter.surface.${t}`);return(0,z.jsxs)(`button`,{type:`button`,className:`usage-segmented-btn usage-source-btn${e===t?` active`:``}`,"aria-label":r,"aria-pressed":e===t,onClick:()=>n(t),children:[t===`codex`&&(0,z.jsx)(`img`,{className:`usage-source-mark`,src:`/provider-icons/openai.svg`,alt:``,"aria-hidden":`true`}),t===`claude`&&(0,z.jsx)(`img`,{className:`usage-source-mark`,src:`/provider-icons/claude.svg`,alt:``,"aria-hidden":`true`}),t===`grok`&&(0,z.jsx)(`img`,{className:`usage-source-mark`,src:`/provider-icons/grok.svg`,alt:``,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:t===`all`?`usage-source-label`:`usage-source-label usage-source-label-collapsible`,children:r})]},t)})}),(0,z.jsx)(`div`,{className:`usage-segmented`,role:`group`,"aria-label":i(`usage.title`),children:[`all`,`30d`,`7d`].map(e=>{let n=i(e===`all`?`usage.range.available`:`usage.range.${e}`);return(0,z.jsx)(`button`,{type:`button`,className:`usage-segmented-btn${t===e?` active`:``}`,"aria-label":n,"aria-pressed":t===e,onClick:()=>r(e),children:n},e)})})]})}function Hl({summary:e,activeDays:t,locale:n,t:r}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`usage-cards usage-cards-3x2`,role:`group`,"aria-label":r(`usage.title`),children:[(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:r(`usage.card.requests`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:e.requests})]}),(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:r(`usage.card.measured`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:e.measuredRequests})]}),(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:r(`usage.card.totalTokens`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:Pt(e.totalTokens,n)})]}),(0,z.jsxs)(`div`,{className:`stat`,title:r(`usage.card.cachedTokensHint`),children:[(0,z.jsx)(`div`,{className:`muted`,children:r(`usage.card.cachedTokens`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:Pt(e.cacheReadInputTokens??e.cachedInputTokens,n)}),(e.cacheCreationInputTokens??0)>0&&(0,z.jsxs)(`div`,{className:`muted text-caption`,children:[r(`usage.card.cacheWriteTokens`),`: `,Pt(e.cacheCreationInputTokens??0,n)]})]}),(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:r(`usage.card.coverage`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:Fl(e.coverageRatio)})]}),(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:r(`usage.card.activeDays`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:t})]})]}),e.estimatedCostUsd!==void 0&&(0,z.jsxs)(`div`,{className:`usage-cost-row`,role:`note`,children:[(0,z.jsx)(`span`,{className:`muted`,children:r(`usage.cost.total`)}),(0,z.jsx)(`span`,{className:`stat-value mono usage-cost-value`,children:la(e.estimatedCostUsd,n)}),(0,z.jsx)(`span`,{className:`muted text-caption`,children:r(`usage.cost.disclaimer`)}),(e.unpricedRequests??0)+(e.unmeteredRequests??0)>0&&(0,z.jsx)(`span`,{className:`muted text-caption`,children:r(`usage.cost.unpricedNote`).replace(`{count}`,String((e.unpricedRequests??0)+(e.unmeteredRequests??0)))})]})]})}function Ul({weekBars:e,locale:t,t:n}){let[r,i]=(0,_.useState)(null),a=Math.max(1,...e.map(e=>e.totalTokens));return(0,z.jsx)(`div`,{className:`daybars`,role:`img`,"aria-label":n(`usage.section.heatmap`),children:e.map(e=>{let n=Math.round(e.totalTokens/a*100),o=e.date.slice(5);return(0,z.jsxs)(`div`,{className:`daybar`,onMouseEnter:()=>i(e.date),onMouseLeave:()=>i(t=>t===e.date?null:t),children:[(0,z.jsx)(`div`,{className:`daybar-track`,children:(0,z.jsxs)(`div`,{className:`daybar-stack`,style:{"--daybar-scale":String(Math.max(0,Math.min(1,n/100)))},children:[e.models.map(e=>(0,z.jsx)(`div`,{className:`daybar-seg`,style:{flexGrow:e.totalTokens,background:Il(e.model,e.provider)}},`${e.provider}/${e.model}`)),e.models.length===0&&e.totalTokens>0&&(0,z.jsx)(`div`,{className:`daybar-seg`,style:{flexGrow:1,background:`var(--green)`}})]})}),r===e.date&&e.totalTokens>0&&(0,z.jsxs)(`div`,{className:`daybar-tip`,role:`tooltip`,children:[(0,z.jsx)(`div`,{className:`daybar-tip-date`,children:e.date}),e.models.slice(0,8).map(e=>(0,z.jsxs)(`div`,{className:`daybar-tip-row`,children:[(0,z.jsx)(`span`,{className:`daybar-tip-swatch`,style:{background:Il(e.model,e.provider)}}),(0,z.jsx)(`span`,{className:`daybar-tip-name`,children:zo(e.model)}),(0,z.jsx)(`span`,{className:`daybar-tip-val`,children:Pt(e.totalTokens,t)})]},`${e.provider}/${e.model}`))]}),(0,z.jsx)(`span`,{className:`daybar-count`,children:Pt(e.totalTokens,t)}),(0,z.jsx)(`span`,{className:`daybar-label muted`,children:o})]},e.date)})})}function Wl({range:e,heatmap:t,weekBars:n,locale:r,t:i}){let a=(0,_.useRef)(null),[o,s]=(0,_.useState)(null);return(0,_.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{e.scrollLeft=e.scrollWidth};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[t,e]),(0,z.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":`usage-heatmap-title`,children:[(0,z.jsx)(`h3`,{id:`usage-heatmap-title`,className:`panel-title`,children:i(`usage.section.heatmap`)}),e===`7d`?(0,z.jsx)(Ul,{weekBars:n,locale:r,t:i}):(0,z.jsxs)(`div`,{className:`heatmap`,ref:a,role:`img`,"aria-labelledby":`usage-heatmap-title`,children:[(0,z.jsxs)(`div`,{className:`heatmap-months`,style:{gridTemplateColumns:`28px repeat(${t.weeks.length}, calc(var(--hm-cell) + var(--hm-gap)))`},children:[(0,z.jsx)(`span`,{className:`heatmap-day-spacer`}),t.months.map(e=>(0,z.jsx)(`span`,{className:`heatmap-month`,style:{gridColumn:e.col+2},children:e.label},`${e.label}-${e.col}`))]}),(0,z.jsxs)(`div`,{className:`heatmap-body`,children:[(0,z.jsxs)(`div`,{className:`heatmap-days`,children:[(0,z.jsx)(`span`,{}),(0,z.jsx)(`span`,{children:i(`usage.dayMon`)}),(0,z.jsx)(`span`,{}),(0,z.jsx)(`span`,{children:i(`usage.dayWed`)}),(0,z.jsx)(`span`,{}),(0,z.jsx)(`span`,{children:i(`usage.dayFri`)}),(0,z.jsx)(`span`,{})]}),(0,z.jsx)(`div`,{className:`heatmap-grid`,style:{gridTemplateColumns:`repeat(${t.weeks.length}, var(--hm-cell))`},children:t.weeks.map((e,t)=>(0,z.jsx)(`div`,{className:`heatmap-week`,children:e.map((e,n)=>(0,z.jsx)(`div`,{className:`heatmap-cell heatmap-cell-${e.level}`,onMouseEnter:r=>{if(!e.date)return;let i=r.currentTarget.getBoundingClientRect();s({weekIndex:t,dayIndex:n,x:i.left+i.width/2,y:i.top})},onMouseLeave:()=>s(e=>e?.weekIndex===t&&e.dayIndex===n?null:e)},e.date||`pad-${t}-${n}`))},e[0]?.date||`week-${t}`))})]}),o&&(()=>{let e=t.weeks[o.weekIndex]?.[o.dayIndex];return e?.date?(0,z.jsxs)(`div`,{className:`heatmap-tip`,role:`tooltip`,style:{left:o.x,top:o.y},children:[(0,z.jsx)(`div`,{className:`heatmap-tip-date`,children:e.date}),(0,z.jsx)(`div`,{className:`heatmap-tip-val`,children:i(`usage.heatmap.tooltipTokens`,{tokens:Pt(e.totalTokens,r)})}),(0,z.jsx)(`div`,{className:`heatmap-tip-req muted`,children:i(`usage.heatmap.tooltipRequests`,{requests:e.requests})})]}):null})(),(0,z.jsxs)(`div`,{className:`heatmap-legend muted`,children:[(0,z.jsx)(`span`,{children:i(`usage.heatmap.less`)}),[0,1,2,3,4].map(e=>(0,z.jsx)(`span`,{className:`heatmap-cell heatmap-cell-${e}`},e)),(0,z.jsx)(`span`,{children:i(`usage.heatmap.more`)})]})]})]})}function Gl({title:e,titleId:t,children:n}){return(0,z.jsxs)(`section`,{className:`usw-section`,"aria-labelledby":t,children:[(0,z.jsx)(`h3`,{id:t,className:`h-section`,children:e}),n]})}function Kl({models:e,modelQuery:t,onModelQuery:n,locale:r,t:i,workspace:a=!1}){let o=i(`usage.search.models`),s=i(`usage.section.models`),c=`usage-models-title`,l=(0,z.jsx)(`input`,{className:`input`,"aria-label":o,placeholder:o,value:t,onChange:e=>n(e.target.value)}),u=(0,z.jsx)(`div`,{className:`tbl-wrap`,children:(0,z.jsxs)(`table`,{className:`tbl`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:i(`logs.col.model`)}),(0,z.jsx)(`th`,{children:i(`logs.col.provider`)}),(0,z.jsx)(`th`,{className:`num`,children:i(`usage.col.requests`)}),(0,z.jsx)(`th`,{className:`num`,children:i(`usage.col.measured`)}),(0,z.jsx)(`th`,{className:`num`,children:i(`usage.col.tokens`)}),(0,z.jsx)(`th`,{children:i(`usage.col.share`)})]})}),(0,z.jsx)(`tbody`,{children:e.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`mono`,children:zo(e.model)}),(0,z.jsx)(`td`,{className:`muted`,children:e.provider}),(0,z.jsx)(`td`,{className:`num`,children:e.requests}),(0,z.jsx)(`td`,{className:`num`,children:e.measuredRequests}),(0,z.jsx)(`td`,{className:`num mono`,children:Pt(e.totalTokens,r)}),(0,z.jsx)(`td`,{children:(0,z.jsx)(`div`,{className:`usage-bar`,children:(0,z.jsx)(`div`,{className:`usage-bar-fill`,style:{width:`${Math.round(e.shareRatio*100)}%`}})})})]},`${e.provider}/${e.model}`))})]})});return a?(0,z.jsxs)(Gl,{title:s,titleId:c,children:[(0,z.jsx)(`div`,{className:`usw-section-toolbar`,children:l}),u]}):(0,z.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":c,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{id:c,className:`panel-title`,children:s}),l]}),u]})}function ql({providers:e,locale:t,t:n,workspace:r=!1}){let i=n(`usage.section.providers`),a=`usage-providers-title`,o=(0,z.jsx)(`div`,{className:`tbl-wrap`,children:(0,z.jsxs)(`table`,{className:`tbl`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:n(`logs.col.provider`)}),(0,z.jsx)(`th`,{className:`num`,children:n(`usage.col.requests`)}),(0,z.jsx)(`th`,{className:`num`,children:n(`usage.col.measured`)}),(0,z.jsx)(`th`,{className:`num`,children:n(`usage.col.tokens`)}),(0,z.jsx)(`th`,{children:n(`usage.col.share`)})]})}),(0,z.jsx)(`tbody`,{children:e.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`mono`,children:e.provider}),(0,z.jsx)(`td`,{className:`num`,children:e.requests}),(0,z.jsx)(`td`,{className:`num`,children:e.measuredRequests}),(0,z.jsx)(`td`,{className:`num mono`,children:Pt(e.totalTokens,t)}),(0,z.jsx)(`td`,{children:(0,z.jsx)(`div`,{className:`usage-bar`,children:(0,z.jsx)(`div`,{className:`usage-bar-fill`,style:{width:`${Math.round(e.shareRatio*100)}%`}})})})]},e.provider))})]})});return r?(0,z.jsx)(Gl,{title:i,titleId:a,children:o}):(0,z.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":a,children:[(0,z.jsx)(`h3`,{id:a,className:`panel-title`,children:i}),o]})}function Jl({summary:e,t,workspace:n=!1}){let r=t(`usage.section.coverage`),i=`usage-coverage-title`,a=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`usage-cards usage-cards-3x2`,children:[(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.measured`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:e.measuredRequests})]}),(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.reported`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:e.reportedRequests})]}),(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.estimated`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:e.estimatedRequests})]}),(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:t(`logs.tokens.unreported`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:e.unreportedRequests})]}),(0,z.jsxs)(`div`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`muted`,children:t(`logs.tokens.unsupported`)}),(0,z.jsx)(`div`,{className:`stat-value`,children:e.unsupportedRequests})]})]}),(0,z.jsx)(`p`,{className:`muted text-control`,style:{marginTop:12},children:t(`usage.coverage.note`)})]});return n?(0,z.jsx)(Gl,{title:r,titleId:i,children:a}):(0,z.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":i,children:[(0,z.jsx)(`h3`,{id:i,className:`panel-title`,children:r}),a]})}function Yl({data:e,heatmap:t,weekBars:n,activeDays:r,filteredModels:i,modelQuery:a,onModelQuery:o,sortedProviders:s,range:c,locale:l,t:u}){let d=!!e&&e.summary.requests===0,f=[{id:`overview`,label:u(`usage.section.overview`),meta:e?`${e.summary.requests}`:`—`,body:e?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Hl,{summary:e.summary,activeDays:r,locale:l,t:u}),(0,z.jsx)(Wl,{range:c,heatmap:t,weekBars:n,locale:l,t:u})]}):null},{id:`models`,label:u(`usage.section.models`),meta:e?`${e.models.length}`:`—`,body:e?(0,z.jsx)(Kl,{models:i,modelQuery:a,onModelQuery:o,locale:l,t:u,workspace:!0}):null},{id:`providers`,label:u(`usage.section.providers`),meta:e?`${e.providers.length}`:`—`,body:e?(0,z.jsx)(ql,{providers:s,locale:l,t:u,workspace:!0}):null},{id:`coverage`,label:u(`usage.section.coverage`),meta:e?Fl(e.summary.coverageRatio):`—`,body:e?(0,z.jsx)(Jl,{summary:e.summary,t:u,workspace:!0}):null}];return(0,z.jsx)(`div`,{className:`usage-workspace-shell`,children:(0,z.jsxs)(`div`,{className:`usage-workspace-root`,children:[(0,z.jsx)(lc,{scope:`usage`,ariaLabel:u(`usage.workspace.sections`),items:f.map(e=>({id:e.id,label:e.label,meta:e.meta}))}),(0,z.jsx)(`section`,{className:`usage-workspace-main`,"aria-label":u(`usage.workspace.report`),children:d?(0,z.jsx)(ot,{title:u(`usage.empty`)}):f.map(e=>(0,z.jsx)(`div`,{id:oc(`usage`,e.id),className:`usw-body usw-section-block`,children:e.body},e.id))})]})})}var Xl=new Map;function Zl(e,t,n){return`ocx.usage.v1:${e}:${t}:${n}`}function Ql(e,t,n){let r=Zl(e,t,n);return Xl.get(r)??Y(r)}function $l(e,t,n,r){let i=Zl(e,t,n);Xl.set(i,r),X(i,r)}function eu({apiBase:e}){let{t,locale:n}=Ve(),[r,i]=(0,_.useState)(`30d`),[a,o]=(0,_.useState)(`all`),[s,c]=(0,_.useState)(``),l=(0,_.useCallback)(async t=>{let n=await fetch(`${e}/api/usage?range=${r}&surface=${a}`,{signal:t});if(!n.ok)throw Error(`${n.status} ${n.statusText}`.trim());let i=await n.json();return $l(e,r,a,i),i},[e,r,a]),u=Zl(e,r,a),d=Ql(e,r,a),f=us(u,[e,r,a],l,{isEmpty:()=>!1,initialData:d??void 0}),{state:p}=f,m=p.data??d??null,h=(0,_.useMemo)(()=>Bl(m?.days??[]),[m?.days]),g=(0,_.useMemo)(()=>Ll(m?.days??[]),[m?.days]),v=(0,_.useMemo)(()=>(m?.days??[]).filter(e=>e.requests>0).length,[m?.days]),y=(0,_.useMemo)(()=>{let e=s.trim().toLowerCase(),t=(m?.models??[]).toSorted((e,t)=>t.totalTokens-e.totalTokens);return e?t.filter(t=>t.model.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e)||(t.resolvedModel??``).toLowerCase().includes(e)).slice(0,100):t.slice(0,100)},[m?.models,s]),b=(0,_.useMemo)(()=>(m?.providers??[]).toSorted((e,t)=>t.totalTokens-e.totalTokens),[m?.providers]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`page-head usage-head`,children:[(0,z.jsx)(`h2`,{id:`usage-page-title`,children:t(`usage.title`)}),(0,z.jsx)(Vl,{surface:a,range:r,onSurface:o,onRange:i,t})]}),(0,z.jsx)(`p`,{className:`page-sub`,children:t(`usage.subtitle`)}),p.showSkeleton&&!m?(0,z.jsx)(fs,{label:t(`usage.loading`),rows:5}):p.kind===`failed-cold`?(0,z.jsxs)(q,{tone:`err`,children:[p.error instanceof Error?`${t(`usage.loadError`)} ${p.error.message}`:t(`usage.loadError`),` `,(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>f.refresh(),children:t(`common.retry`)})]}):(0,z.jsxs)(z.Fragment,{children:[p.showError&&(0,z.jsx)(q,{tone:`err`,children:t(`usage.loadError`)}),m?.historyTruncated&&(0,z.jsx)(q,{tone:`ok`,children:t(`usage.historyTruncated`)}),(0,z.jsx)(Yl,{data:m,heatmap:h,weekBars:g,activeDays:v,filteredModels:y,modelQuery:s,onModelQuery:c,sortedProviders:b,range:r,locale:n,t})]})]})}function tu(e,t){if(e<1024)return`${e} B`;let n=[`KB`,`MB`,`GB`,`TB`],r=e,i=-1;do r/=1024,i++;while(r>=1024&&i<n.length-1);return`${r.toLocaleString(t,{maximumFractionDigits:1})} ${n[i]}`}var nu={sessions:`storage.bucket.sessions`,archived_sessions:`storage.bucket.archived_sessions`,logs_db:`storage.bucket.logs_db`,state_db:`storage.bucket.state_db`,attachments:`storage.bucket.attachments`,deletion_manifests:`storage.bucket.deletion_manifests`,other:`storage.bucket.other`};function ru(e,t){let n=nu[e.key];return n?t(n):e.label}function iu(e,t){return e===void 0?`—`:new Date(e).toLocaleDateString(t)}function au(e,t,n){return e.rows===void 0?`—`:e.rows===null?n(`storage.rows.unknown`):e.rows.toLocaleString(t)}function ou({report:e,locale:t}){let n=K(),[r,i]=(0,_.useState)(null),a=(0,_.useMemo)(()=>e.buckets.toSorted((e,t)=>t.bytes-e.bytes),[e.buckets]),o=a.find(e=>e.key===r)??null,s=(0,_.useMemo)(()=>{let t=[];for(let n of e.buckets)for(let e of n.largest??[])t.push({...e,bucketKey:n.key});return t.sort((e,t)=>t.bytes-e.bytes).slice(0,10)},[e.buckets]),c=(0,_.useMemo)(()=>new Map(e.buckets.map(e=>[e.key,e])),[e.buckets]);return(0,z.jsxs)(`div`,{className:`storage-workspace-root`,children:[(0,z.jsxs)(`aside`,{className:`storage-workspace-rail`,"aria-label":n(`storage.section.buckets`),children:[(0,z.jsxs)(`div`,{className:`storage-workspace-rail-header`,children:[(0,z.jsx)(`span`,{className:`storage-workspace-rail-title`,children:n(`storage.section.buckets`)}),(0,z.jsx)(`span`,{className:`storage-workspace-rail-count`,children:a.length})]}),(0,z.jsx)(`div`,{className:`storage-workspace-rail-list`,children:a.length===0?(0,z.jsx)(`span`,{className:`storage-workspace-rail-empty`,children:n(`storage.empty`)}):a.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`storage-workspace-rail-row${r===e.key?` storage-workspace-rail-row--selected`:``}`,onClick:()=>i(t=>t===e.key?null:e.key),"aria-current":r===e.key?`true`:void 0,children:[(0,z.jsxs)(`span`,{className:`storage-workspace-rail-primary`,children:[(0,z.jsx)(`span`,{className:`storage-workspace-rail-name`,children:ru(e,n)}),(0,z.jsx)(`span`,{className:`storage-workspace-rail-size`,children:tu(e.bytes,t)})]}),(0,z.jsxs)(`span`,{className:`storage-workspace-rail-meta`,children:[e.fileCount.toLocaleString(t),` `,n(`storage.col.files`).toLowerCase()]})]},e.key))})]}),(0,z.jsx)(`section`,{className:`storage-workspace-main`,"aria-label":o?ru(o,n):n(`storage.section.largest`),children:o?(0,z.jsxs)(`div`,{className:`stw-detail`,children:[(0,z.jsx)(`div`,{className:`stw-detail-toolbar`,children:(0,z.jsxs)(`button`,{type:`button`,className:`stw-detail-back`,onClick:()=>i(null),children:[(0,z.jsx)(_e,{className:`stw-detail-back-chevron`,"aria-hidden":`true`}),n(`modal.back`)]})}),(0,z.jsxs)(`div`,{className:`stw-detail-body`,children:[(0,z.jsx)(`h2`,{className:`stw-detail-title`,children:ru(o,n)}),(0,z.jsxs)(`dl`,{className:`stw-kv`,children:[(0,z.jsxs)(`div`,{className:`stw-kv-row`,children:[(0,z.jsx)(`dt`,{children:n(`storage.col.size`)}),(0,z.jsx)(`dd`,{className:`stw-kv-mono`,children:tu(o.bytes,t)})]}),(0,z.jsxs)(`div`,{className:`stw-kv-row`,children:[(0,z.jsx)(`dt`,{children:n(`storage.col.files`)}),(0,z.jsx)(`dd`,{className:`stw-kv-mono`,children:o.fileCount.toLocaleString(t)})]}),(0,z.jsxs)(`div`,{className:`stw-kv-row`,children:[(0,z.jsx)(`dt`,{children:n(`storage.col.oldest`)}),(0,z.jsx)(`dd`,{children:iu(o.oldest,t)})]}),(0,z.jsxs)(`div`,{className:`stw-kv-row`,children:[(0,z.jsx)(`dt`,{children:n(`storage.col.newest`)}),(0,z.jsx)(`dd`,{children:iu(o.newest,t)})]}),(0,z.jsxs)(`div`,{className:`stw-kv-row`,children:[(0,z.jsx)(`dt`,{children:n(`storage.col.rows`)}),(0,z.jsx)(`dd`,{className:`stw-kv-mono`,children:au(o,t,n)})]})]}),(o.largest?.length??0)>0&&(0,z.jsxs)(`div`,{className:`stw-section`,children:[(0,z.jsx)(`h3`,{className:`stw-section-title`,children:n(`storage.section.largest`)}),o.largest.map(e=>(0,z.jsxs)(`div`,{className:`stw-file-row`,children:[(0,z.jsx)(`span`,{className:`stw-file-path`,title:e.path,children:e.path}),(0,z.jsx)(`span`,{className:`stw-file-size`,children:tu(e.bytes,t)})]},e.path))]})]})]}):(0,z.jsxs)(`div`,{className:`stw-overview`,children:[(0,z.jsxs)(`div`,{className:`stw-summary`,children:[(0,z.jsxs)(`div`,{className:`stw-summary-card`,children:[(0,z.jsx)(`div`,{className:`stw-summary-label`,children:n(`storage.card.total`)}),(0,z.jsx)(`div`,{className:`stw-summary-value`,children:tu(e.total.bytes,t)})]}),(0,z.jsxs)(`div`,{className:`stw-summary-card`,children:[(0,z.jsx)(`div`,{className:`stw-summary-label`,children:n(`storage.card.files`)}),(0,z.jsx)(`div`,{className:`stw-summary-value`,children:e.total.fileCount.toLocaleString(t)})]}),(0,z.jsxs)(`div`,{className:`stw-summary-card`,children:[(0,z.jsx)(`div`,{className:`stw-summary-label`,children:n(`storage.card.home`)}),(0,z.jsx)(`div`,{className:`stw-summary-value mono stw-home-path`,title:e.codexHome,children:e.codexHome})]})]}),s.length>0?(0,z.jsxs)(`div`,{className:`stw-section`,children:[(0,z.jsx)(`h3`,{className:`stw-section-title`,children:n(`storage.section.largest`)}),s.map(e=>{let r=c.get(e.bucketKey);return(0,z.jsxs)(`div`,{className:`stw-file-row`,children:[(0,z.jsx)(`span`,{className:`stw-file-path`,title:e.path,children:e.path}),r&&(0,z.jsx)(`span`,{className:`stw-file-bucket`,children:ru(r,n)}),(0,z.jsx)(`span`,{className:`stw-file-size`,children:tu(e.bytes,t)})]},`${e.bucketKey}:${e.path}`)})]}):(0,z.jsxs)(`p`,{className:`stw-hint`,children:[(0,z.jsx)(G,{style:{width:14,height:14,verticalAlign:`text-bottom`,marginRight:6},"aria-hidden":`true`}),n(`storage.workspace.selectBucket`)]})]})})]})}var su=1024**3,cu=[10,25,50],lu=(e,t)=>{if(!(e instanceof Error))return t;let n=e.message;return n===`Failed to fetch`||n.includes(`NetworkError`)||n.includes(`network error`)||n.includes(`JSON`)||n.includes(`Unexpected end of`)?t:n||t};function uu({apiBase:e,locale:t,t:n,onDone:r}){let[i,a]=(0,_.useState)(25),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(null),y=(0,_.useRef)(null),b=(0,_.useRef)(null),x=(0,_.useRef)(!1),S=(0,_.useCallback)((e=!1)=>{l(!1),d(!1),e&&s(null)},[]);(0,_.useEffect)(()=>{x.current=f},[f]),(0,_.useEffect)(()=>{if(!c)return;b.current=document.activeElement,y.current?.focus();let e=e=>{e.key===`Escape`&&!x.current&&S()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e),b.current?.focus()}},[c,S]);let C=(e,t,r)=>{switch(e){case`codex_busy`:return n(`storage.cleanup.err.codex_busy`);case`stale_preview`:return n(`storage.cleanup.err.stale_preview`);case`restore_pending_overlap`:return n(`storage.cleanup.err.restore_pending_overlap`);case`referenced_history`:return n(`storage.cleanup.err.referenced_history`);case`invalid_digest`:return n(`storage.cleanup.err.invalid_digest`);case`invalid_mode`:return n(`storage.cleanup.err.invalid_mode`);case`fs_failed`:return r?n(`storage.cleanup.err.fs_failed_trash`,{trashDir:r}):n(`storage.cleanup.err.fs_failed`);case`db_reconcile_failed`:return n(`storage.cleanup.err.db_reconcile_failed`);case`cleanup_failed`:return n(`storage.cleanup.err.cleanup_failed`);default:return t??n(`storage.cleanup.cleanupFailed`)}},w=e=>n(`storage.cleanup.preset`,{percent:new Intl.NumberFormat(t,{style:`percent`,maximumFractionDigits:0}).format(e/100)}),T=async()=>{p(!0),v(null),h(null);try{let t=await fetch(`${e}/api/storage/cleanup/preview`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({percent:i})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(C(e.error,n(`storage.cleanup.previewFailed`)))}s(await t.json()),l(!0)}catch(e){v(lu(e,n(`storage.cleanup.previewFailed`)))}finally{p(!1)}},E=async()=>{if(o){p(!0),v(null);try{let i=await fetch(`${e}/api/storage/cleanup`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({percent:o.percent,mode:u?`permanent`:`quarantine`,digest:o.digest})});if(!i.ok){let e=await i.json().catch(()=>({}));throw e.error===`stale_preview`&&S(!0),Error(C(e.error,e.message,e.trashDir))}let a=await i.json();if(!a.ok)throw a.error===`stale_preview`&&S(!0),Error(C(a.error,a.message,a.trashDir));S(!0),h(n(u?`storage.cleanup.donePermanent`:`storage.cleanup.doneQuarantine`,{count:String(a.count),size:tu(a.bytes,t)})),r()}catch(e){v(lu(e,n(`storage.cleanup.cleanupFailed`)))}finally{p(!1)}}};return(0,z.jsxs)(`section`,{className:`storage-cleanup-pane`,children:[(0,z.jsx)(`p`,{className:`muted storage-manual-panel__help`,children:n(`storage.cleanup.help`)}),(0,z.jsxs)(`div`,{className:`storage-manual-panel__controls`,children:[(0,z.jsxs)(`label`,{className:`storage-manual-panel__slider`,children:[(0,z.jsx)(`span`,{className:`muted mono`,style:{minWidth:`3.5rem`,fontVariantNumeric:`tabular-nums`},children:n(`storage.cleanup.percent`,{percent:String(i)})}),(0,z.jsx)(`input`,{type:`range`,min:1,max:100,value:i,onChange:e=>a(Number(e.target.value)),disabled:f,style:{flex:1,minWidth:0},"aria-label":n(`storage.cleanup.slider`)})]}),(0,z.jsx)(`div`,{className:`storage-manual-panel__presets`,children:cu.map(e=>(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm${i===e?` active`:``}`,disabled:f,onClick:()=>a(e),children:w(e)},e))}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,disabled:f,onClick:()=>void T(),children:n(`storage.cleanup.preview`)})]}),m&&(0,z.jsx)(`p`,{className:`muted storage-manual-panel__status`,children:m}),g&&!c&&(0,z.jsx)(`p`,{className:`storage-manual-panel__status`,style:{color:`var(--red)`},children:g}),c&&o&&(0,z.jsx)(`div`,{className:`modal-overlay`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`storage-cleanup-confirm-title`,onClick:()=>!f&&S(),children:(0,z.jsxs)(`div`,{className:`modal-card`,onClick:e=>e.stopPropagation(),children:[(0,z.jsx)(`h3`,{id:`storage-cleanup-confirm-title`,children:n(`storage.cleanup.confirmTitle`)}),(0,z.jsx)(`p`,{children:n(`storage.cleanup.confirmBody`,{count:String(o.count),size:tu(o.bytes,t),percent:String(o.percent)})}),o.candidates.length>0&&(0,z.jsxs)(`ul`,{className:`mono muted`,style:{maxHeight:160,overflow:`auto`,fontSize:`var(--text-caption)`},children:[o.candidates.slice(0,8).map(e=>(0,z.jsx)(`li`,{children:e.relPath},e.relPath)),o.count>8&&(0,z.jsx)(`li`,{children:n(`storage.cleanup.moreFiles`,{n:String(Math.max(0,o.count-8))})})]}),(0,z.jsxs)(`label`,{style:{display:`flex`,gap:8,alignItems:`center`,marginTop:12},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:u,disabled:f,onChange:e=>d(e.target.checked)}),(0,z.jsx)(`span`,{children:n(`storage.cleanup.permanent`)})]}),(0,z.jsx)(`p`,{className:`muted`,style:{marginTop:8,fontSize:`var(--text-caption)`},children:n(u?`storage.cleanup.permanentWarn`:`storage.cleanup.quarantineNote`)}),g&&(0,z.jsx)(`p`,{style:{marginTop:12,color:`var(--red)`},children:g}),(0,z.jsxs)(`div`,{className:`dialog-actions`,style:{marginTop:16},children:[(0,z.jsx)(`button`,{ref:y,type:`button`,className:`btn btn-ghost`,disabled:f,onClick:()=>S(),children:n(`storage.cleanup.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:u?`btn btn-danger`:`btn`,disabled:f||o.count===0,onClick:()=>void E(),children:n(u?`storage.cleanup.confirmPermanent`:`storage.cleanup.confirmQuarantine`)})]})]})})]})}function du({apiBase:e,locale:t,t:n,onDone:r,reloadToken:i,onEntriesChange:a}){let[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(null),m=(0,_.useRef)(null),h=(0,_.useRef)(null),g=(0,_.useRef)(!1);(0,_.useEffect)(()=>{g.current=o},[o]);let v=(0,_.useCallback)(()=>l(null),[]);(0,_.useEffect)(()=>{if(!c)return;h.current=document.activeElement,m.current?.focus();let e=e=>{e.key===`Escape`&&!g.current&&v()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e),h.current?.focus()}},[c,v]);let y=(0,_.useCallback)(async t=>{let r=await fetch(`${e}/api/storage/trash`,{signal:t});if(!r.ok)throw Error(n(`storage.trash.listFailed`));let i=await r.json(),o=Array.isArray(i.entries)?i.entries:[];return a?.(o),o},[e,a,n]),b=us(`storage-trash:${e}`,[e,i],y,{isEmpty:e=>e.length===0}).state,x=b.data??[],S=(e,t)=>{switch(e){case`codex_busy`:return n(`storage.trash.err.codex_busy`);case`invalid_trash`:return n(`storage.trash.err.invalid_trash`);case`missing_trash`:return n(`storage.trash.err.missing_trash`);case`dest_exists`:return n(`storage.trash.err.dest_exists`);case`fs_failed`:return n(`storage.trash.err.fs_failed`);case`db_reconcile_failed`:return n(`storage.trash.err.db_reconcile_failed`);case`storage_mutation_busy`:return n(`storage.trash.err.storage_mutation_busy`);case`restore_failed`:return n(`storage.trash.err.restore_failed`);case`restore_worker_timeout`:return n(`storage.trash.err.restore_worker_timeout`);case`restore_worker_aborted`:return n(`storage.trash.err.restore_worker_aborted`);case`restore_worker_failed`:return t??n(`storage.trash.err.restore_worker_failed`);default:return t??n(`storage.trash.restoreFailed`)}},C=async()=>{if(c){s(!0),p(null);try{let i=await fetch(`${e}/api/storage/trash/restore`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:c.id})});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(S(e.error,e.message))}let a=await i.json();if(!a.ok)throw Error(S(a.error,a.message));v(),d(n(`storage.trash.done`,{count:String(a.count),size:tu(a.bytes,t)})),r()}catch(e){p(lu(e,n(`storage.trash.restoreFailed`)))}finally{s(!1)}}},w=e=>{let n=e.quarantinedAt??Number(e.epoch.split(`-`)[0]);return!Number.isFinite(n)||n<=0?`—`:new Date(n).toLocaleString(t)},T=e=>e===`permanent`?n(`storage.trash.mode.permanent`):e===`quarantine`?n(`storage.trash.mode.quarantine`):`—`;return(0,z.jsxs)(`section`,{className:`storage-cleanup-pane storage-quarantine-pane`,children:[(0,z.jsx)(`p`,{className:`muted storage-manual-panel__help`,children:n(`storage.trash.help`)}),u&&(0,z.jsx)(`p`,{className:`muted storage-manual-panel__status`,children:u}),f&&!c&&(0,z.jsx)(`p`,{className:`storage-manual-panel__status`,style:{color:`var(--red)`},role:`alert`,children:f}),b.showError&&!c&&(0,z.jsx)(`p`,{className:`storage-manual-panel__status`,style:{color:`var(--red)`},role:`alert`,children:b.error instanceof Error?b.error.message:n(`storage.trash.listFailed`)}),b.refreshing&&!b.showSkeleton&&(0,z.jsx)(ps,{live:!b.showError,children:n(`storage.trash.loading`)}),b.showSkeleton?(0,z.jsx)(fs,{label:n(`storage.trash.loading`),rows:2}):x.length===0?(0,z.jsx)(`p`,{className:`muted storage-manual-panel__status`,children:n(`storage.trash.empty`)}):(0,z.jsx)(`div`,{className:`tbl-wrap storage-manual-panel__table`,children:(0,z.jsxs)(`table`,{className:`tbl`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:n(`storage.trash.col.when`)}),(0,z.jsx)(`th`,{className:`num`,children:n(`storage.trash.col.files`)}),(0,z.jsx)(`th`,{className:`num`,children:n(`storage.trash.col.size`)}),(0,z.jsx)(`th`,{children:n(`storage.trash.col.mode`)}),(0,z.jsx)(`th`,{children:n(`storage.trash.col.id`)}),(0,z.jsx)(`th`,{})]})}),(0,z.jsx)(`tbody`,{children:x.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`muted`,children:w(e)}),(0,z.jsx)(`td`,{className:`num`,children:e.fileCount}),(0,z.jsx)(`td`,{className:`num mono`,children:tu(e.bytes,t)}),(0,z.jsx)(`td`,{className:`muted`,children:T(e.mode)}),(0,z.jsx)(`td`,{className:`mono`,style:{fontSize:`var(--text-caption)`},children:e.id}),(0,z.jsx)(`td`,{children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,disabled:o,onClick:()=>{p(null),l(e)},children:n(`storage.trash.restore`)})})]},e.id))})]})}),c&&(0,z.jsx)(`div`,{className:`modal-overlay`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`storage-trash-confirm-title`,onClick:()=>!o&&v(),children:(0,z.jsxs)(`div`,{className:`modal-card`,onClick:e=>e.stopPropagation(),children:[(0,z.jsx)(`h3`,{id:`storage-trash-confirm-title`,children:n(`storage.trash.confirmTitle`)}),(0,z.jsx)(`p`,{children:n(`storage.trash.confirmBody`,{count:String(c.fileCount),size:tu(c.bytes,t),id:c.id})}),f&&(0,z.jsx)(`p`,{style:{marginTop:12,color:`var(--red)`},children:f}),(0,z.jsxs)(`div`,{className:`dialog-actions`,style:{marginTop:16},children:[(0,z.jsx)(`button`,{ref:m,type:`button`,className:`btn btn-ghost`,disabled:o,onClick:()=>v(),children:n(`storage.trash.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn`,disabled:o,onClick:()=>void C(),children:n(`storage.trash.confirmRestore`)})]})]})})]})}function fu(e){let{job:t,...n}=e;return n}function pu(e){let t=String(Math.max(0,Math.round(e.trigger.archivedBytesOver/su*100)/100));return e.target.reduceToBytes===void 0?{policy:fu(e),thresholdGb:t,targetMode:`percent`,percent:String(Math.min(100,Math.max(1,Math.floor(e.target.removeOldestPercent??25)))),reduceGb:`4`}:{policy:fu(e),thresholdGb:t,targetMode:`reduce`,percent:`25`,reduceGb:String(Math.max(0,Math.round(e.target.reduceToBytes/su*100)/100))}}async function mu(e){await new Promise(t=>window.setTimeout(t,e))}function hu({apiBase:e,locale:t,t:n,onDone:r}){let i=`ocx.storage.cleanup-policy.v1:${e}`,a=Y(i),o=(0,_.useRef)(!!a),[s,c]=(0,_.useState)(()=>a?.policy??null),[l,u]=(0,_.useState)(()=>!a),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(()=>a?.targetMode??`percent`),[S,C]=(0,_.useState)(()=>a?.percent??`25`),[w,T]=(0,_.useState)(()=>a?.reduceGb??`4`),[E,D]=(0,_.useState)(()=>a?.thresholdGb??`5`),O=(0,_.useRef)(null),k=(0,_.useRef)(!1),A=(0,_.useRef)(!1),j=(0,_.useRef)(0),M=(0,_.useCallback)(e=>{let t=pu(e);c(t.policy),D(t.thresholdGb),x(t.targetMode),C(t.percent),T(t.reduceGb),o.current=!0,X(i,t),k.current=!1},[i]),N=(0,_.useCallback)(()=>{k.current=!0},[]),P=(0,_.useCallback)(e=>{A.current=e},[]),F=(0,_.useCallback)(async t=>{let r=++j.current;o.current||u(!0),y(null);try{let n=await fetch(`${e}/api/storage/cleanup-policy`,{signal:t});if(!n.ok)throw Error(`load_failed`);let i=await n.json();if(t?.aborted||r!==j.current||k.current||A.current)return;M(i)}catch{if(t?.aborted||r!==j.current)return;o.current||(c(null),y(n(`storage.policy.loadFailed`)))}finally{!t?.aborted&&r===j.current&&u(!1)}},[e,M,n]);(0,_.useEffect)(()=>{let e=new AbortController,t=window.setTimeout(()=>{F(e.signal)},0);return()=>{window.clearTimeout(t),j.current+=1,e.abort()}},[F]),(0,_.useEffect)(()=>()=>{O.current?.abort(),O.current=null},[]);let I=()=>{if(!s)return null;let e=E.trim();if(e===``)return null;let t=Number(e);if(!Number.isFinite(t)||t<0)return null;let n;if(b===`reduce`){let e=w.trim();if(e===``)return null;let t=Number(e);if(!Number.isFinite(t)||t<0)return null;n={reduceToBytes:Math.floor(t*su)}}else{let e=Number(S);if(!Number.isFinite(e)||e<1||e>100)return null;n={removeOldestPercent:Math.min(100,Math.max(1,Math.floor(e)))}}return{enabled:s.enabled,trigger:{archivedBytesOver:Math.floor(t*su)},target:n,schedule:s.schedule,mode:s.mode}},L=async t=>{let r=I();if(!r){y(n(`storage.policy.invalid`));return}let i={...r,...t};f(!0),y(null),g(null);try{let t=await fetch(`${e}/api/storage/cleanup-policy`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(i)});if(!t.ok){y(n(`storage.policy.saveFailed`));return}let r=await t.json();if(!r.policy){y(n(`storage.policy.saveFailed`));return}M(r.policy),g(n(`storage.policy.saved`))}catch{y(n(`storage.policy.saveFailed`))}finally{f(!1)}},R=async()=>{O.current?.abort();let i=new AbortController;O.current=i;let{signal:a}=i;m(!0),y(null),g(null);try{let i=I();if(!i){y(n(`storage.policy.invalid`));return}let o=await fetch(`${e}/api/storage/cleanup-policy`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(i),signal:a});if(a.aborted)return;if(!o.ok){y(n(`storage.policy.saveFailed`));return}let s=await o.json();if(a.aborted)return;if(!s.policy){y(n(`storage.policy.saveFailed`));return}M(s.policy);let c=await fetch(`${e}/api/storage/cleanup-policy/run`,{method:`POST`,signal:a});if(a.aborted)return;if(c.status===409){let e=await c.json().catch(()=>({}));if(a.aborted)return;e.policy&&M(e.policy),y(n(`storage.policy.alreadyRunning`));return}if(!c.ok){let e=await c.json().catch(()=>({}));if(a.aborted)return;if(e.policy&&M(e.policy),e.error===`already_running`){y(n(`storage.policy.alreadyRunning`));return}y(n(`storage.policy.runFailed`));return}let l=await c.json();if(a.aborted)return;if(l.policy&&M(l.policy),l.error===`already_running`){y(n(`storage.policy.alreadyRunning`));return}if(!l.started||!l.job?.startedAt){y(n(`storage.policy.runFailed`));return}let u=l.job.startedAt,d=Date.now()+12e4,f,p;for(;Date.now()<d;){if(a.aborted||(await mu(250),a.aborted))return;let t=await fetch(`${e}/api/storage/cleanup-policy`,{signal:a});if(a.aborted)return;if(!t.ok)continue;let n=await t.json();if(a.aborted)return;p=fu(n),M(n);let r=n.job;if(r&&r.status!==`running`){if(r.startedAt===u&&r.lastOutcome){f=r.lastOutcome;break}if(r.finishedAt&&r.finishedAt>=u&&r.lastOutcome){f=r.lastOutcome;break}}}if(a.aborted)return;if(p&&M(p),!f){y(n(`storage.policy.runFailed`));return}f.skipped===`disabled`?g(n(`storage.policy.skippedDisabled`)):f.skipped===`under_threshold`?g(n(`storage.policy.skippedUnder`)):f.skipped===`nothing_selected`?g(n(`storage.policy.skippedEmpty`)):f.deferred===`codex_busy`||f.error===`codex_busy`?y(n(`storage.cleanup.err.codex_busy`)):f.ok?(g(f.mode===`permanent`?n(`storage.policy.donePermanent`,{count:String(f.removed??0),size:tu(f.freedBytes??0,t)}):n(`storage.policy.doneQuarantine`,{count:String(f.removed??0),size:tu(f.freedBytes??0,t)})),r()):y(n(`storage.policy.runFailed`))}catch(e){if(a.aborted||e instanceof DOMException&&e.name===`AbortError`)return;y(n(`storage.policy.runFailed`))}finally{O.current===i&&(O.current=null),a.aborted||m(!1)}},B=e=>e===void 0?n(`storage.policy.never`):new Date(e).toLocaleString(t);return l&&!s?(0,z.jsx)(`section`,{className:`storage-cleanup-pane`,children:(0,z.jsx)(`p`,{className:`muted storage-policy-help`,children:n(`storage.policy.loading`)})}):s?(0,z.jsxs)(`section`,{className:`storage-cleanup-pane`,children:[(0,z.jsx)(`p`,{className:`muted storage-policy-help`,children:n(`storage.policy.help`)}),(0,z.jsx)(`div`,{className:`storage-policy-enable`,children:(0,z.jsxs)(`div`,{className:`storage-policy-enable-row`,children:[(0,z.jsx)(`button`,{type:`button`,className:`toggle${s.enabled?` on`:``}`,disabled:d||p,"aria-pressed":s.enabled,"aria-label":n(`storage.policy.enabled`),title:n(`storage.policy.enabledHint`),onClick:()=>void L({enabled:!s.enabled}),children:(0,z.jsx)(`span`,{className:`toggle-knob`})}),(0,z.jsx)(`span`,{children:n(`storage.policy.enabled`)})]})}),(0,z.jsxs)(`div`,{className:`storage-policy-fields`,children:[(0,z.jsxs)(`div`,{className:`field storage-policy-trigger`,children:[(0,z.jsx)(`label`,{className:`field-label`,htmlFor:`storage-policy-threshold`,children:n(`storage.policy.trigger`)}),(0,z.jsxs)(`div`,{className:`storage-policy-trigger-row`,children:[(0,z.jsx)(`span`,{className:`storage-policy-trigger-hint`,children:n(`storage.policy.threshold`)}),(0,z.jsxs)(`span`,{className:`codex-auto-switch-input-wrap`,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(P(!1),L())},children:[(0,z.jsx)(`input`,{id:`storage-policy-threshold`,className:`input mono codex-auto-switch-input`,type:`number`,min:0,step:.1,inputMode:`decimal`,value:E,disabled:d||p,"aria-label":n(`storage.policy.threshold`),onFocus:()=>P(!0),onChange:e=>{N(),D(e.target.value)},onKeyDown:e=>{e.nativeEvent.isComposing||d||p||e.key===`Enter`&&(e.preventDefault(),L())}}),(0,z.jsx)(`span`,{className:`codex-auto-switch-unit`,"aria-hidden":`true`,children:`GiB`}),(0,z.jsx)(Ri,{disabled:d||p,incrementLabel:n(`storage.policy.thresholdInc`),decrementLabel:n(`storage.policy.thresholdDec`),onIncrement:()=>{N(),D(Li(E,.1,0,1e4,.1))},onDecrement:()=>{N(),D(Li(E,-.1,0,1e4,.1))}})]})]})]}),(0,z.jsxs)(`fieldset`,{className:`field storage-policy-target`,children:[(0,z.jsx)(`legend`,{className:`field-label`,children:n(`storage.policy.target`)}),(0,z.jsxs)(`label`,{className:`storage-policy-target-row`,children:[(0,z.jsx)(`input`,{type:`radio`,name:`storage-policy-target`,checked:b===`percent`,disabled:d||p,onChange:()=>{N(),x(`percent`)}}),(0,z.jsx)(`span`,{className:`storage-policy-target-label`,children:n(`storage.policy.targetPercent`)}),b===`percent`&&(0,z.jsxs)(`span`,{className:`codex-auto-switch-input-wrap`,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(P(!1),L())},children:[(0,z.jsx)(`input`,{id:`storage-policy-percent`,className:`input mono codex-auto-switch-input`,type:`number`,min:1,max:100,step:1,inputMode:`numeric`,value:S,disabled:d||p,"aria-label":n(`storage.policy.targetPercent`),onFocus:()=>P(!0),onChange:e=>{N(),C(e.target.value)},onKeyDown:e=>{e.nativeEvent.isComposing||d||p||e.key===`Enter`&&(e.preventDefault(),L())}}),(0,z.jsx)(`span`,{className:`codex-auto-switch-unit`,"aria-hidden":`true`,children:`%`}),(0,z.jsx)(Ri,{disabled:d||p,incrementLabel:n(`storage.policy.percentInc`),decrementLabel:n(`storage.policy.percentDec`),onIncrement:()=>{N(),C(Li(S,1,1,100))},onDecrement:()=>{N(),C(Li(S,-1,1,100))}})]})]}),(0,z.jsxs)(`label`,{className:`storage-policy-target-row`,children:[(0,z.jsx)(`input`,{type:`radio`,name:`storage-policy-target`,checked:b===`reduce`,disabled:d||p,onChange:()=>{N(),x(`reduce`)}}),(0,z.jsx)(`span`,{className:`storage-policy-target-label`,children:n(`storage.policy.targetReduce`)}),b===`reduce`&&(0,z.jsxs)(`span`,{className:`codex-auto-switch-input-wrap`,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(P(!1),L())},children:[(0,z.jsx)(`input`,{id:`storage-policy-reduce`,className:`input mono codex-auto-switch-input`,type:`number`,min:0,step:.1,inputMode:`decimal`,value:w,disabled:d||p,"aria-label":n(`storage.policy.targetReduce`),onFocus:()=>P(!0),onChange:e=>{N(),T(e.target.value)},onKeyDown:e=>{e.nativeEvent.isComposing||d||p||e.key===`Enter`&&(e.preventDefault(),L())}}),(0,z.jsx)(`span`,{className:`codex-auto-switch-unit`,"aria-hidden":`true`,children:`GiB`}),(0,z.jsx)(Ri,{disabled:d||p,incrementLabel:n(`storage.policy.reduceInc`),decrementLabel:n(`storage.policy.reduceDec`),onIncrement:()=>{N(),T(Li(w,.1,0,1e4,.1))},onDecrement:()=>{N(),T(Li(w,-.1,0,1e4,.1))}})]})]})]}),(0,z.jsxs)(`div`,{className:`storage-policy-selects`,children:[(0,z.jsxs)(`label`,{className:`field`,htmlFor:`storage-policy-schedule`,children:[(0,z.jsx)(`span`,{className:`field-label`,children:n(`storage.policy.schedule`)}),(0,z.jsxs)(`select`,{id:`storage-policy-schedule`,className:`input`,value:s.schedule,disabled:d||p,onChange:e=>{let t=e.target.value;L({schedule:t})},children:[(0,z.jsx)(`option`,{value:`manual`,children:n(`storage.policy.schedule.manual`)}),(0,z.jsx)(`option`,{value:`startup`,children:n(`storage.policy.schedule.startup`)}),(0,z.jsx)(`option`,{value:`daily`,children:n(`storage.policy.schedule.daily`)}),(0,z.jsx)(`option`,{value:`weekly`,children:n(`storage.policy.schedule.weekly`)})]})]}),(0,z.jsxs)(`label`,{className:`field`,htmlFor:`storage-policy-mode`,children:[(0,z.jsx)(`span`,{className:`field-label`,children:n(`storage.policy.mode`)}),(0,z.jsxs)(`select`,{id:`storage-policy-mode`,className:`input`,value:s.mode,disabled:d||p,onChange:e=>{let t=e.target.value;L({mode:t})},children:[(0,z.jsx)(`option`,{value:`quarantine`,children:n(`storage.policy.mode.quarantine`)}),(0,z.jsx)(`option`,{value:`permanent`,children:n(`storage.policy.mode.permanent`)})]})]})]}),s.mode===`permanent`&&(0,z.jsx)(`p`,{className:`err storage-policy-warn`,role:`status`,children:n(`storage.policy.permanentWarn`)})]}),(0,z.jsxs)(`div`,{className:`storage-policy-meta`,children:[(0,z.jsxs)(`div`,{className:`storage-policy-meta-item`,children:[(0,z.jsx)(`span`,{className:`muted`,children:n(`storage.policy.lastRun`)}),(0,z.jsxs)(`span`,{className:`storage-policy-meta-value`,children:[B(s.lastRun?.at),s.lastRun?` · ${n(`storage.policy.lastRunDetail`,{count:String(s.lastRun.removed),size:tu(s.lastRun.freedBytes,t)})}`:``]})]}),(0,z.jsxs)(`div`,{className:`storage-policy-meta-item`,children:[(0,z.jsx)(`span`,{className:`muted`,children:n(`storage.policy.nextRun`)}),(0,z.jsx)(`span`,{className:`storage-policy-meta-value`,children:B(s.nextRun)})]})]}),(0,z.jsxs)(`div`,{className:`storage-policy-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:d||p,onClick:()=>void L(),children:n(`storage.policy.save`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,disabled:d||p,onClick:()=>void R(),children:n(p?`storage.policy.running`:`storage.policy.runNow`)}),(0,z.jsx)(`span`,{className:`storage-policy-actions__status${v?` is-error`:``}`,role:v?`alert`:`status`,"aria-live":`polite`,children:v??h??``})]})]}):(0,z.jsx)(`section`,{className:`storage-cleanup-pane`,children:v&&(0,z.jsx)(`p`,{className:`err`,role:`alert`,children:v})})}function gu({apiBase:e,locale:t,t:n,archivedCount:r,showQuarantine:i,trashReloadToken:a,onDone:o,onTrashEntriesChange:s}){let[c,l]=(0,_.useState)(`policy`),u=(0,_.useRef)(null),d=(0,_.useRef)(null),f=[{id:`policy`,label:n(`storage.cleanupCard.tab.policy`),ref:u},{id:`quarantine`,label:n(`storage.cleanupCard.tab.quarantine`),ref:d}],p=e=>{l(e),window.requestAnimationFrame(()=>(e===`policy`?u:d).current?.focus())},m=e=>{e.key===`ArrowLeft`||e.key===`ArrowRight`?(e.preventDefault(),p(c===`policy`?`quarantine`:`policy`)):e.key===`Home`?(e.preventDefault(),p(`policy`)):e.key===`End`&&(e.preventDefault(),p(`quarantine`))};return(0,z.jsxs)(`section`,{className:`panel storage-cleanup-card`,"aria-labelledby":`storage-cleanup-card-title`,children:[(0,z.jsx)(`div`,{className:`page-tabs storage-cleanup-card__tabs`,role:`tablist`,"aria-label":n(`storage.cleanupCard.tabs`),children:f.map(({id:e,label:t,ref:n})=>(0,z.jsx)(`button`,{type:`button`,role:`tab`,ref:n,id:`storage-cleanup-tab-${e}`,"aria-selected":c===e,"aria-controls":`storage-cleanup-panel-${e}`,tabIndex:c===e?0:-1,className:`page-tab${c===e?` page-tab--active`:``}`,onKeyDown:m,onClick:()=>p(e),children:t},e))}),(0,z.jsx)(`h3`,{id:`storage-cleanup-card-title`,className:`panel-title`,children:n(`storage.cleanupCard.title`)}),(0,z.jsxs)(`div`,{className:`storage-cleanup-card__stack`,children:[(0,z.jsxs)(`div`,{id:`storage-cleanup-panel-policy`,role:`tabpanel`,"aria-labelledby":`storage-cleanup-tab-policy`,className:`storage-cleanup-card__body storage-cleanup-policy-split`,"data-active":c===`policy`?`true`:`false`,"aria-hidden":c!==`policy`,...c===`policy`?{}:{inert:!0},children:[(0,z.jsx)(hu,{apiBase:e,locale:t,t:n,onDone:o}),(0,z.jsxs)(`aside`,{className:`storage-cleanup-manual`,"aria-labelledby":`storage-cleanup-manual-title`,children:[(0,z.jsx)(`h4`,{id:`storage-cleanup-manual-title`,className:`storage-cleanup-manual__title`,children:n(`storage.cleanup.title`)}),r>0?(0,z.jsx)(uu,{apiBase:e,locale:t,t:n,onDone:o}):(0,z.jsx)(`p`,{className:`muted storage-manual-panel__status`,children:n(`storage.cleanup.noArchives`)})]})]}),(0,z.jsx)(`div`,{id:`storage-cleanup-panel-quarantine`,role:`tabpanel`,"aria-labelledby":`storage-cleanup-tab-quarantine`,className:`storage-cleanup-card__body`,"data-active":c===`quarantine`?`true`:`false`,"aria-hidden":c!==`quarantine`,...c===`quarantine`?{}:{inert:!0},children:i?(0,z.jsx)(du,{apiBase:e,locale:t,t:n,onDone:o,reloadToken:a,onEntriesChange:s}):(0,z.jsx)(`p`,{className:`muted storage-manual-panel__status`,children:n(`storage.trash.empty`)})})]})]})}function _u({apiBase:e}){let{t,locale:n}=Ve(),r=`ocx.storage.report.v1:${e}`,i=Y(r),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(0),l=(0,_.useRef)(!1),[u,d]=(0,_.useState)({apiBase:e,settled:!1,hasEntries:!1}),f=(0,_.useCallback)(async n=>{try{let i=await fetch(`${e}/api/storage`,{signal:n});if(!i.ok)throw Error(t(`storage.error`));let a=await i.json();return X(r,a),l.current&&(l.current=!1,o(t(`storage.rescanned`))),a}catch(e){throw l.current&&(l.current=!1,o(t(`storage.error`))),n.aborted?e:Error(t(`storage.error`),{cause:e})}},[e,r,t]),p=us(`storage-report:${e}`,[e],f,{isEmpty:e=>e.total.fileCount===0&&e.error===void 0}),m=p.state,h=m.data??i,g=m.refreshing||m.showSkeleton&&!h,v=p.refresh,y=(0,_.useCallback)(()=>{o(null),l.current=!0,v(),c(e=>e+1)},[v]),b=(0,_.useCallback)(t=>{d({apiBase:e,settled:!0,hasEntries:t.length>0})},[e]),x=u.apiBase===e&&u.settled,S=u.apiBase===e&&u.hasEntries,C=h?.error!==void 0,w=!g&&!m.showError&&!C&&h.total.fileCount===0&&x&&!S,T=h?.buckets.find(e=>e.key===`archived_sessions`)?.fileCount??0,E=!!h&&!C,D=E&&(h.total.fileCount>0||!x||S);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`page-head`,children:[(0,z.jsx)(`h2`,{id:`storage-page-title`,children:t(`storage.title`)}),(0,z.jsxs)(`div`,{className:`storage-page-head-actions`,children:[(0,z.jsx)(`span`,{className:`storage-page-head-feedback`,role:`status`,"aria-live":`polite`,children:a??``}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:g,onClick:()=>void y(),children:[(0,z.jsx)(se,{}),` `,t(`storage.refresh`)]})]})]}),(0,z.jsx)(`p`,{className:`page-sub`,children:t(`storage.subtitle`)}),h&&h.error===void 0&&(0,z.jsxs)(`p`,{className:`storage-page-meta`,children:[(0,z.jsx)(`code`,{className:`mono storage-page-meta__home`,title:h.codexHome,children:h.codexHome}),(0,z.jsx)(`span`,{className:`storage-page-meta__sep`,"aria-hidden":`true`,children:`·`}),(0,z.jsxs)(`span`,{children:[t(`storage.snapshot.lastScan`),`:`,` `,new Date(h.generatedAt).toLocaleString(n)]})]}),m.showSkeleton&&!h?(0,z.jsx)(fs,{label:t(`storage.loading`),rows:5}):m.kind===`failed-cold`&&!h?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`alert alert-err`,role:`alert`,children:m.error instanceof Error?m.error.message:t(`storage.error`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>v(),children:t(`common.retry`)})]}):C?(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(`div`,{className:`alert alert-err`,role:`alert`,children:t(`storage.error`)})}):(0,z.jsxs)(z.Fragment,{children:[m.showError&&(0,z.jsx)(`div`,{className:`alert alert-err`,role:`alert`,children:t(`storage.error`)}),w?(0,z.jsx)(ot,{title:t(`storage.empty`)}):h&&h.total.fileCount>0&&(0,z.jsx)(ou,{report:h,locale:n})]}),h&&h.error===void 0&&m.refreshing&&!m.showSkeleton&&(0,z.jsx)(ps,{live:!m.showError,children:t(`storage.loading`)}),E&&(0,z.jsx)(gu,{apiBase:e,locale:n,t,archivedCount:T,showQuarantine:D,trashReloadToken:s,onDone:()=>void y(),onTrashEntriesChange:b})]})}function vu(e){if(!e||typeof e!=`object`)return`absent`;let t=e.providers;if(!t||typeof t!=`object`||Array.isArray(t)||!Object.hasOwn(t,`openai`))return`absent`;let n=t.openai;if(!n||typeof n!=`object`||Array.isArray(n))return`absent`;let r=n;return r.disabled===!0?`disabled`:r.codexAccountMode===`direct`?`direct`:r.codexAccountMode===void 0||r.codexAccountMode===`pool`?`pool`:`absent`}function yu({state:e,busy:t,onEnable:n}){let r=K();return(0,z.jsxs)(`div`,{className:`panel openai-account-mode-banner`,style:{marginBottom:16},children:[(0,z.jsxs)(`div`,{className:`row`,children:[(0,z.jsx)(`strong`,{children:r(`codexAuth.accountModeTitle`)}),e===null?(0,z.jsx)(`span`,{className:`badge badge-accent openai-account-mode-banner__badge-slot openai-account-mode-banner__badge-slot--pending`,"aria-hidden":`true`,children:r(`codexAuth.accountModePool`)}):e===`pool`?(0,z.jsx)(`span`,{className:`badge badge-accent openai-account-mode-banner__badge-slot`,children:r(`codexAuth.accountModePool`)}):e===`direct`?(0,z.jsx)(`span`,{className:`badge badge-green openai-account-mode-banner__badge-slot`,children:r(`codexAuth.accountModeDirect`)}):null]}),e===null&&(0,z.jsx)(`p`,{className:`card-sub openai-account-mode-banner__desc openai-account-mode-banner__desc--pending`,"aria-hidden":`true`,children:`\xA0`}),e===`pool`&&(0,z.jsx)(`p`,{className:`card-sub openai-account-mode-banner__desc`,children:r(`codexAuth.accountModePoolDesc`)}),e===`direct`&&(0,z.jsxs)(`p`,{className:`card-sub openai-account-mode-banner__desc`,children:[r(`codexAuth.accountModeDirectDesc`),` `,(0,z.jsx)(`a`,{href:`#providers`,children:r(`codexAuth.openProviders`)})]}),(e===`absent`||e===`disabled`)&&(0,z.jsxs)(`div`,{className:`row`,style:{alignItems:`center`,marginTop:8},children:[(0,z.jsx)(`p`,{className:`card-sub`,style:{flex:1,margin:0},children:r(`codexAuth.openaiUnavailableDesc`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:t,onClick:n,children:r(t?`codexAuth.enablingOpenai`:`codexAuth.enableOpenai`)})]}),e===`invalid`&&(0,z.jsxs)(`p`,{className:`card-sub openai-account-mode-banner__desc`,children:[r(`codexAuth.openaiMissing`),` `,(0,z.jsx)(`a`,{href:`#providers`,children:r(`codexAuth.openProviders`)})]})]})}function bu(e){if(!e||typeof e!=`object`)return;let t=e.providers;if(!t||typeof t!=`object`||Array.isArray(t)||!Object.hasOwn(t,`openai`))return;let n=t.openai;if(!(!n||typeof n!=`object`||Array.isArray(n)))return n}function xu({apiBase:e}){let t=K(),n=`ocx.codex-auth.config.v1:${e}`,r=Y(n),[i,a]=(0,_.useState)(()=>r?.bannerState??null),[o,s]=(0,_.useState)(()=>r?.accountModeState??null),c=(0,_.useRef)(null),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(``),p=(0,_.useCallback)(async()=>{try{let t=await fetch(`${e}/api/config`);if(!t.ok)throw Error(String(t.status));let r=await t.json(),i=Ga(bu(r));if(i===`absent`||i===`disabled`||i===`invalid`){a(i);let e=i===`disabled`?`disabled`:`absent`;s(e),X(n,{bannerState:i,accountModeState:e});return}let o=vu(r);a(o),s(o),X(n,{bannerState:o,accountModeState:o})}catch{}},[e,n]);(0,_.useEffect)(()=>{c.current!==e&&(c.current=e,Promise.resolve().then(()=>{p()}));let t=window.setInterval(()=>{p()},3e4);return()=>{window.clearInterval(t)}},[e,p]);let m=async()=>{u(!0),f(``);try{if(i!==`absent`&&i!==`disabled`)return;await Qa(e,i),await p()}catch(e){e instanceof Za?f(t(e.i18nKey)):f(e instanceof Error?e.message:t(`prov.saveFailed`))}finally{u(!1)}};return(0,z.jsx)(Ea,{apiBase:e,accountModeState:o,banner:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(yu,{state:i,busy:l,onEnable:()=>{m()}}),d&&(0,z.jsx)(`div`,{className:`notice notice-err`,role:`alert`,children:d})]})})}function Su(e){return e?[`responses`,`chat`,`messages`]:[`responses`,`chat`]}function Cu(e){let t=e.id.indexOf(`/`),n=typeof e.owned_by==`string`&&e.owned_by.trim()?e.owned_by.trim():void 0,r=t>0?e.id.slice(0,t):n??`openai`,i=t<0&&r===`openai`,a=r!==`openai`&&r!==`combo`;return{id:e.id,displayName:e.id,provider:r,native:i,custom:a}}function wu(e){return e.id}function Tu(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.ambiguous===!0?!0:!(typeof t.requests7d!=`number`||!Number.isFinite(t.requests7d)||typeof t.totalRequests!=`number`||!Number.isFinite(t.totalRequests)||t.lastUsedAt!==void 0&&(typeof t.lastUsedAt!=`string`||Number.isNaN(new Date(t.lastUsedAt).getTime())))}var Eu=new Set([`required`,`accepted`,`rejected`]);function Du(e){return Array.isArray(e)&&e.length>0&&e.every(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.endpoint==`string`&&Eu.has(t.bearer)&&Eu.has(t.dedicated)&&Eu.has(t.xApiKey)})}var Ou={baseUrl:`http://127.0.0.1:10100/v1`,responses:`http://127.0.0.1:10100/v1/responses`,chatCompletions:`http://127.0.0.1:10100/v1/chat/completions`,messages:`http://127.0.0.1:10100/v1/messages`,models:`http://127.0.0.1:10100/v1/models`};function ku(e){let t=e||Ou.responses,n=t.match(/^(.*)\/v1\/responses\/?$/),r=n?`${n[1]}/v1`:t.replace(/\/responses\/?$/,``);return{baseUrl:r,responses:t,chatCompletions:`${r}/chat/completions`,messages:`${r}/messages`,models:`${r}/models`}}function Au(e,t){let n=new Date(e);return!e||Number.isNaN(n.getTime())?`—`:n.toLocaleDateString(t)}function ju({url:e}){return(0,z.jsx)(Mu,{text:e,hintKey:`api.copyUrlHint`,copiedKey:`api.urlCopied`,className:`api-endpoint-url-btn`,children:(0,z.jsx)(`code`,{className:`api-code api-code-inline api-endpoint-url`,children:e})})}function Mu({text:e,hintKey:t,copiedKey:n,className:r,children:i}){let{t:a}=Ve(),o=(0,_.useId)(),s=(0,_.useRef)(null),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(null),m=(0,_.useRef)(null),h=c||u;(0,_.useEffect)(()=>()=>{m.current!==null&&window.clearTimeout(m.current)},[]),(0,_.useLayoutEffect)(()=>{if(!h)return;let e=()=>{let e=s.current;if(!e)return;let t=e.getBoundingClientRect();p({top:Math.max(8,t.top-8),left:t.left+t.width/2})};return e(),window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[h]);let g=()=>l(!0),v=()=>l(!1),y=async()=>{try{await navigator.clipboard.writeText(e),d(!0),m.current!==null&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>d(!1),1500)}catch{d(!1)}},b=h&&f?(0,qe.createPortal)((0,z.jsx)(`span`,{id:o,className:`ocx-tooltip-bubble api-copy-tip-fixed`,role:`tooltip`,style:{top:f.top,left:f.left},children:a(u?n:t)}),document.body):null;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,ref:s,className:`ocx-tooltip ${r}`,onMouseEnter:g,onMouseLeave:v,onFocus:g,onBlur:v,onClick:e=>{if(typeof window<`u`&&window.getSelection()?.toString())return;let t=e.target;if(t instanceof HTMLElement&&t!==e.currentTarget){let n=t.getBoundingClientRect();if(t.scrollHeight>t.clientHeight+1&&e.clientX>=n.right-16||t.scrollWidth>t.clientWidth+1&&e.clientY>=n.bottom-16)return}y()},onKeyDown:e=>{e.key===`Escape`&&v()},"aria-label":a(t),"aria-describedby":h?o:void 0,children:i}),b]})}function Nu({text:e}){return(0,z.jsx)(Mu,{text:e,hintKey:`api.copyExampleHint`,copiedKey:`api.exampleCopied`,className:`api-example-copy-btn`,children:(0,z.jsx)(`code`,{className:`api-code api-example-pre`,children:e})})}function Pu(e,t){return t(e===`required`?`api.auth.required`:e===`accepted`?`api.auth.accepted`:`api.auth.rejected`)}function Fu({endpoints:e,claudeCodeEnabled:t,authMatrix:n}){let{t:r}=Ve();return(0,z.jsxs)(`div`,{className:`panel api-panel`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:r(`api.endpointsTitle`)}),(0,z.jsxs)(`div`,{className:`api-endpoints`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`muted small`,children:r(`api.baseUrl`)}),(0,z.jsx)(ju,{url:e.baseUrl})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`muted small`,children:r(`api.responsesEndpoint`)}),(0,z.jsx)(ju,{url:e.responses})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`muted small`,children:r(`api.chatCompletionsEndpoint`)}),(0,z.jsx)(ju,{url:e.chatCompletions})]}),t&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`muted small`,children:r(`api.messagesEndpoint`)}),(0,z.jsx)(ju,{url:e.messages})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`muted small`,children:r(`api.modelsEndpoint`)}),(0,z.jsx)(ju,{url:e.models})]})]}),(0,z.jsx)(`p`,{className:`muted small`,children:r(`api.endpointNote`)}),(0,z.jsxs)(`div`,{className:`api-auth-matrix-block`,children:[(0,z.jsx)(`h4`,{className:`api-auth-matrix-title`,children:r(`api.authTitle`)}),(0,z.jsx)(`div`,{className:`api-auth-matrix-scroll`,children:(0,z.jsxs)(`table`,{className:`api-auth-matrix`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:r(`api.auth.endpoint`)}),(0,z.jsx)(`th`,{children:(0,z.jsx)(`code`,{children:`Authorization: Bearer`})}),(0,z.jsx)(`th`,{children:(0,z.jsx)(`code`,{children:`x-opencodex-api-key`})}),(0,z.jsx)(`th`,{children:(0,z.jsx)(`code`,{children:`x-api-key`})})]})}),(0,z.jsx)(`tbody`,{children:n.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{children:(0,z.jsx)(`code`,{children:e.endpoint})}),(0,z.jsx)(`td`,{children:Pu(e.bearer,r)}),(0,z.jsx)(`td`,{children:Pu(e.dedicated,r)}),(0,z.jsx)(`td`,{children:Pu(e.xApiKey,r)})]},e.endpoint))})]})}),(0,z.jsx)(`p`,{className:`muted small`,children:r(`api.authLoopback`)}),(0,z.jsx)(`p`,{className:`muted small`,children:r(`api.authBaseUrlNote`)})]})]})}function Iu({keys:e,keysLoading:t=!1,keysLoadFailed:n,newName:r,creating:i,newKey:a,copied:o,confirmDelete:s,localeTag:c,showKeyList:l=!0,onNewNameChange:u,onCreate:d,onDismissNewKey:f,onCopyKey:p,onConfirmDelete:m,onCancelDelete:h,onDelete:g}){let{t:_}=Ve();return(0,z.jsxs)(z.Fragment,{children:[a&&(0,z.jsxs)(`div`,{className:`panel api-panel panel-accent api-newkey-panel`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:_(`api.newKeyTitle`)}),(0,z.jsx)(`p`,{className:`muted small`,children:_(`api.newKeyNote`)}),(0,z.jsxs)(`div`,{className:`api-form-row`,children:[(0,z.jsx)(`code`,{className:`api-code`,style:{flex:1,wordBreak:`break-all`},children:a}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,onClick:p,children:o?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ie,{}),` `,_(`api.copied`)]}):_(`api.copy`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,style:{alignSelf:`flex-start`},onClick:f,children:_(`api.dismiss`)})]}),(0,z.jsxs)(`div`,{className:`panel api-panel api-generate-panel`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:_(`api.generateTitle`)}),(0,z.jsxs)(`div`,{className:`api-form-row`,children:[(0,z.jsx)(`input`,{id:`api-key-name`,type:`text`,placeholder:_(`api.keyNamePlaceholder`),"aria-label":_(`api.keyNamePlaceholder`),value:r,maxLength:64,onChange:e=>u(e.target.value),className:`input`}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:d,disabled:i,children:[(0,z.jsx)(oe,{}),` `,_(i?`api.generating`:`api.generate`)]})]})]}),l&&(0,z.jsxs)(`div`,{className:`panel api-panel`,style:{marginTop:`1rem`},"aria-busy":t,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:t?_(`api.activeKeysLoading`):_(`api.activeKeys`,{count:e.length})}),t?(0,z.jsx)(`div`,{className:`api-active-keys-skeleton`,role:`status`,"aria-label":_(`common.loading`)}):e.length>0?(0,z.jsx)(`div`,{className:`tbl-wrap`,children:(0,z.jsxs)(`table`,{className:`tbl`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:_(`api.colName`)}),(0,z.jsx)(`th`,{children:_(`api.colKey`)}),(0,z.jsx)(`th`,{children:_(`api.colCreated`)}),(0,z.jsx)(`th`,{})]})}),(0,z.jsx)(`tbody`,{children:e.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{children:e.name}),(0,z.jsx)(`td`,{children:(0,z.jsx)(`code`,{children:e.prefix})}),(0,z.jsx)(`td`,{children:Au(e.createdAt,c)}),(0,z.jsx)(`td`,{children:s===e.id?(0,z.jsxs)(`span`,{className:`api-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-danger`,onClick:()=>g(e.id),children:_(`api.confirm`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,onClick:h,children:_(`common.cancel`)})]}):(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,"aria-label":_(`api.deleteAria`),onClick:()=>m(e.id),children:(0,z.jsx)(ae,{})})})]},e.id))})]})}):n?(0,z.jsx)(`p`,{className:`muted`,children:_(`api.keysLoadFailed`)}):(0,z.jsx)(`p`,{className:`muted`,children:_(`api.noKeys`)})]})]})}function Lu({filteredModels:e,modelsLoading:t,modelsRefreshing:n=!1,modelsLoadFailed:r,modelCount:i,hasModelData:a,modelQuery:o,copiedModelId:s,modelTests:c,claudeCodeEnabled:l,onModelQueryChange:u,onCopyModelId:d,onTestModel:f,onRetryModels:p,canTestModels:m,sourceLabel:h,protocolLabel:g}){let{t:_}=Ve();return(0,z.jsxs)(`div`,{className:`panel api-panel api-models-panel`,children:[(0,z.jsxs)(`div`,{className:`api-panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:_(`api.modelsTitle`)}),(0,z.jsx)(`span`,{className:`muted mono text-label`,children:_(`api.modelsCount`,{count:e.length})})]}),(0,z.jsx)(`p`,{className:`muted small`,children:_(`api.modelsSubtitle`)}),(0,z.jsx)(`input`,{type:`search`,className:`input`,value:o,onChange:e=>u(e.target.value),placeholder:_(`api.modelsSearch`),"aria-label":_(`api.modelsSearch`)}),r&&(0,z.jsxs)(`div`,{className:`api-models-error`,children:[(0,z.jsx)(`p`,{className:`muted small`,role:`alert`,children:_(`api.modelsLoadFailed`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:p,children:_(`common.retry`)})]}),n&&!t&&(0,z.jsx)(`p`,{className:`muted small`,"aria-live":`polite`,children:_(`api.modelsLoading`)}),t?(0,z.jsx)(fs,{label:_(`api.modelsLoading`),rows:3}):a?e.length===0?(0,z.jsx)(`p`,{className:`muted small api-models-empty`,children:i===0?_(`api.modelsEmpty`):_(`api.modelsNoMatch`,{query:o.trim()})}):(0,z.jsx)(`div`,{className:`api-models-scroll`,children:(0,z.jsxs)(`table`,{className:`tbl`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:_(`api.colModel`)}),(0,z.jsx)(`th`,{children:_(`api.colSource`)}),(0,z.jsx)(`th`,{children:_(`api.colProtocols`)})]})}),(0,z.jsx)(`tbody`,{children:e.map(e=>{let t=wu(e),n=Su(l);return(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{children:(0,z.jsxs)(`div`,{className:`api-model-cell`,children:[(0,z.jsx)(`code`,{children:t}),e.displayName!==e.id&&(0,z.jsx)(`span`,{className:`muted small`,children:e.displayName})]})}),(0,z.jsx)(`td`,{children:h(e)}),(0,z.jsx)(`td`,{children:(0,z.jsxs)(`div`,{className:`api-model-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,onClick:()=>{d(t)},children:_(s===t?`api.modelCopied`:`api.copyModelId`)}),n.map(n=>{let r=c[t]?.[n],i=r?.state??`idle`;return(0,z.jsxs)(`span`,{className:`api-model-test-chip`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,disabled:i===`testing`||!m,title:m?void 0:_(`api.auth.testNeedsFreshKey`),onClick:()=>{f(e,n)},children:_(`api.auth.testProtocol`,{protocol:g(n)})}),i!==`idle`&&(0,z.jsx)(`span`,{className:`api-test-note api-test-note--${i}`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:i===`testing`?_(`api.testingModel`):i===`ok`?_(`api.testSucceeded`):r?.detail??_(`api.testFailed`)})]},n)})]})})]},t)})})]})}):null]})}function Ru({endpoints:e,claudeCodeEnabled:t}){let{t:n}=Ve(),r=JSON.stringify(n(`api.usageSampleInput`)),i=`curl ${e.chatCompletions} \\
48
48
  -H "x-opencodex-api-key: ocx_YOUR_KEY_HERE" \\
49
49
  -H "Content-Type: application/json" \\
50
50
  -d '{
@@ -64,4 +64,4 @@ v2: spawn_agent を備えたマルチスレッドエージェント。すべて
64
64
  "max_tokens": 64,
65
65
  "messages": [{"role": "user", "content": ${r}}]
66
66
  }'`;return(0,z.jsxs)(`section`,{className:`panel api-panel awi-usage-panel`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:n(`api.workspace.usageExamples`)}),(0,z.jsxs)(`div`,{className:`awi-usage-panel-body`,children:[(0,z.jsxs)(`div`,{className:`awi-usage-example`,children:[(0,z.jsx)(`h4`,{className:`awi-usage-example-title`,children:n(`api.usageChatTitle`)}),(0,z.jsx)(Nu,{text:i})]}),(0,z.jsxs)(`div`,{className:`awi-usage-example`,children:[(0,z.jsx)(`h4`,{className:`awi-usage-example-title`,children:n(`api.usageResponsesTitle`)}),(0,z.jsx)(Nu,{text:a})]}),t&&(0,z.jsxs)(`div`,{className:`awi-usage-example`,children:[(0,z.jsx)(`h4`,{className:`awi-usage-example-title`,children:n(`api.usageMessagesTitle`)}),(0,z.jsx)(Nu,{text:o})]})]})]})}var zu=[`opencode`,`pi`],Bu={opencode:`api.clientConfig.clientOpencode`,pi:`api.clientConfig.clientPi`},Vu={opencode:`/provider-icons/opencode.svg`,pi:`/provider-icons/pi.svg`};function Hu({client:e,apiBase:t,onOpenDetails:n,onCopy:r,onDownload:i}){let a=K(),[o,s]=(0,_.useState)(0),c=[t,e,String(o)].join(`|`),[l,u]=(0,_.useState)(null);(0,_.useEffect)(()=>{let n=new AbortController,r=!1;return(async()=>{try{let i=await fetch(`${t}/api/client-config?client=${encodeURIComponent(e)}`,{signal:n.signal});if(!i.ok)throw Error(String(i.status));let a=await i.json();if(r)return;u({key:c,data:a,failed:!1})}catch{if(r)return;u({key:c,data:null,failed:!0})}})(),()=>{r=!0,n.abort()}},[t,e,c]);let d=l!==null&&l.key===c?l:null,f=d?.data??null,p=d?.failed??!1,m=d===null,h=a(Bu[e]),g=Vu[e],v=f?`${JSON.stringify(f.config,null,2)}\n`:``,y=(0,_.useCallback)(t=>{f&&n(e,f,v,t.currentTarget)},[e,f,v,n]);return(0,z.jsxs)(`li`,{className:`awi-clientconfig-row`,children:[(0,z.jsx)(`span`,{className:`awi-clientconfig-mark`,"aria-hidden":`true`,children:g?(0,z.jsx)(`img`,{src:g,alt:``,width:20,height:20}):(0,z.jsx)(`span`,{className:`awi-clientconfig-monogram`,children:h.slice(0,1)})}),(0,z.jsxs)(`span`,{className:`awi-clientconfig-identity`,children:[(0,z.jsx)(`span`,{className:`awi-clientconfig-name`,children:h}),(0,z.jsx)(`span`,{className:`muted text-label awi-clientconfig-meta`,children:m?a(`api.clientConfig.loading`):p||!f?(0,z.jsx)(`span`,{role:`alert`,children:a(`api.clientConfig.rowError`,{client:h})}):a(`api.clientConfig.rowMeta`,{destination:f.destination,count:f.modelCount})})]}),(0,z.jsx)(`span`,{className:`awi-clientconfig-row-actions`,children:p&&!m?(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>s(e=>e+1),children:a(`common.retry`)}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":a(`api.clientConfig.copyAria`,{client:h}),disabled:!f,onClick:()=>{f&&r(e,v)},children:a(`api.clientConfig.copy`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,"aria-label":a(`api.clientConfig.downloadAria`,{client:h}),disabled:!f,onClick:()=>{f&&i(e,f,v)},children:a(`api.clientConfig.download`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,"aria-label":a(`api.clientConfig.detailsAria`,{client:h}),disabled:!f,onClick:y,children:a(`api.clientConfig.details`)})]})})]})}function Uu({client:e,envelope:t,json:n,hasKeys:r,onClose:i,onCopy:a,onDownload:o}){let s=K(),c=(0,_.useRef)(null),l=`awi-clientconfig-dialog-${e}`;return(0,_.useEffect)(()=>{let e=c.current;return e&&!e.open&&e.showModal(),()=>{e?.open&&e.close()}},[]),(0,z.jsxs)(`dialog`,{ref:c,className:`modal-overlay`,"aria-labelledby":l,onCancel:(0,_.useCallback)(e=>{e.preventDefault(),i()},[i]),children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":s(`common.close`),tabIndex:-1,onClick:i}),(0,z.jsxs)(`div`,{className:`modal-card awi-clientconfig-dialog`,onClick:e=>e.stopPropagation(),role:`document`,children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsx)(`h3`,{id:l,children:s(Bu[e])}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:i,children:s(`common.close`)})]}),(0,z.jsx)(`pre`,{className:`api-code api-example-pre awi-clientconfig-json`,tabIndex:0,role:`group`,"aria-label":s(`api.clientConfig.jsonLabel`,{client:s(Bu[e])}),children:n}),(0,z.jsx)(`p`,{className:`muted small awi-clientconfig-count`,children:s(`api.clientConfig.modelCount`,{count:t.modelCount})}),t.modelsWithoutLimits>0&&(0,z.jsx)(`p`,{className:`muted small awi-clientconfig-degraded`,children:s(`api.clientConfig.missingLimits`,{count:t.modelsWithoutLimits,total:t.modelCount})}),!r&&(0,z.jsx)(`p`,{className:`muted small awi-clientconfig-nokey`,children:s(`api.clientConfig.noKeyYet`,{env:t.apiKeyEnv})}),(0,z.jsxs)(`div`,{className:`awi-clientconfig-line`,children:[(0,z.jsx)(`span`,{className:`muted text-label`,children:s(`api.clientConfig.destination`)}),(0,z.jsx)(Nu,{text:t.destination})]}),(0,z.jsxs)(`div`,{className:`awi-clientconfig-line`,children:[(0,z.jsx)(`span`,{className:`muted text-label`,children:s(`api.clientConfig.envHint`)}),(0,z.jsx)(Nu,{text:t.exportHint})]}),(0,z.jsx)(`p`,{className:`muted small awi-clientconfig-merge`,children:s(`api.clientConfig.mergeWarning`)}),(0,z.jsx)(`p`,{className:`muted text-label awi-clientconfig-where-title`,children:s(`api.clientConfig.whereDisclosure`)}),(0,z.jsx)(`p`,{className:`muted small`,children:s(`api.clientConfig.whereBody`)}),(0,z.jsxs)(`div`,{className:`modal-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:a,children:s(`api.clientConfig.copy`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:o,children:s(`api.clientConfig.download`)})]})]})]})}function Wu({apiBase:e,baseUrl:t,hasKeys:n}){let r=K(),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(``),c=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(i!==null)return;let e=c.current;e&&(c.current=null,e.isConnected&&e.focus())},[i]);let l=(0,_.useCallback)(async(e,t,n)=>{try{await navigator.clipboard.writeText(t),s(n?r(`api.clientConfig.copiedAnnounceClient`,{client:r(Bu[e])}):r(`api.clientConfig.copiedAnnounce`))}catch{s(r(`api.clientConfig.copyFailed`))}},[r]),u=(0,_.useCallback)((e,t,n)=>{let i=URL.createObjectURL(new Blob([n],{type:`application/json`})),a=document.createElement(`a`);a.href=i,a.download=t.filename,a.click(),URL.revokeObjectURL(i),s(r(`api.clientConfig.downloadedAnnounce`,{filename:t.filename,destination:t.destination}))},[r]),d=(0,_.useCallback)(()=>a(null),[]),f=(0,_.useCallback)((e,t,n,r)=>{c.current=r,a({client:e,envelope:t,json:n})},[]);return(0,z.jsxs)(`section`,{className:`panel api-panel awi-clientconfig-panel`,children:[(0,z.jsx)(`div`,{className:`api-panel-head awi-clientconfig-head`,children:(0,z.jsx)(`h3`,{className:`panel-title`,children:r(`api.clientConfig.title`)})}),(0,z.jsx)(`ul`,{className:`awi-clientconfig-rows`,"aria-label":r(`api.clientConfig.rowsLabel`),children:zu.map(t=>(0,z.jsx)(Hu,{client:t,apiBase:e,onOpenDetails:f,onCopy:(e,t)=>{l(e,t,!0)},onDownload:u},t))}),(0,z.jsxs)(`div`,{className:`awi-clientconfig-line`,children:[(0,z.jsx)(`span`,{className:`muted text-label`,children:r(`api.baseUrl`)}),(0,z.jsx)(Nu,{text:t})]}),(0,z.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:o}),i&&(0,z.jsx)(Uu,{client:i.client,envelope:i.envelope,json:i.json,hasKeys:n,onClose:d,onCopy:()=>{l(i.client,i.json,!1)},onDownload:()=>u(i.client,i.envelope,i.json)})]})}function Gu({keys:e,keysLoading:t,keysLoadFailed:n,attributionSince:r,localeTag:i,busy:a,onSelect:o}){let s=K();return(0,z.jsxs)(`div`,{className:`panel api-panel awi-keylist-panel`,"aria-busy":t,children:[(0,z.jsx)(`div`,{className:`api-panel-head`,children:(0,z.jsx)(`h3`,{className:`panel-title`,children:t?s(`api.activeKeysLoading`):s(`api.activeKeys`,{count:e.length})})}),t?(0,z.jsx)(`div`,{className:`api-active-keys-skeleton`,role:`status`,"aria-label":s(`common.loading`)}):e.length===0?(0,z.jsx)(`p`,{className:`muted small`,children:s(n?`api.keysLoadFailed`:`api.noKeys`)}):(0,z.jsx)(`div`,{className:`tbl-wrap`,children:(0,z.jsxs)(`table`,{className:`tbl awi-keylist-table`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:s(`api.colName`)}),(0,z.jsx)(`th`,{children:s(`api.colKey`)}),(0,z.jsx)(`th`,{children:s(`api.attribution.requests7d`)}),(0,z.jsx)(`th`,{children:s(`api.attribution.lastUsed`)})]})}),(0,z.jsx)(`tbody`,{children:e.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{children:(0,z.jsx)(`button`,{type:`button`,className:`awi-keylist-name`,disabled:a,onClick:()=>o(e.id),children:e.name})}),(0,z.jsx)(`td`,{children:(0,z.jsx)(`code`,{children:e.prefix})}),(0,z.jsx)(`td`,{children:r?e.usage.ambiguous?s(`api.attribution.railAmbiguous`):e.usage.requests7d.toLocaleString(i):s(`api.attribution.unavailable`)}),(0,z.jsx)(`td`,{children:!r||e.usage.ambiguous?`—`:e.usage.lastUsedAt?Au(e.usage.lastUsedAt,i):s(`api.attribution.neverUsed`)})]},e.id))})]})})]})}function Ku({keys:e,apiBase:t,attributionSince:n,historyTruncated:r,authMatrix:i,keysLoading:a,keysLoadFailed:o,endpoints:s,claudeCodeEnabled:c,localeTag:l,newName:u,creating:d,newKey:f,copied:p,filteredModels:m,modelsLoading:h,modelsRefreshing:g=!1,modelsLoadFailed:v,modelCount:y,hasModelData:b,modelQuery:x,copiedModelId:S,modelTests:C,canTestModels:w,onNewNameChange:T,onCreate:E,onDismissNewKey:D,onCopyKey:O,onDelete:k,onRename:A,onModelQueryChange:j,onCopyModelId:M,onTestModel:N,onRetryModels:P,sourceLabel:F,protocolLabel:I}){let L=K(),[R,B]=(0,_.useState)(null),[V,H]=(0,_.useState)(!1),[U,W]=(0,_.useState)(!1),[ee,te]=(0,_.useState)(!1),[ne,re]=(0,_.useState)(!1),[G,ie]=(0,_.useState)(``),[ae,oe]=(0,_.useState)(!1),[se,ce]=(0,_.useState)(!1),[le,de]=(0,_.useState)(!1),fe=R?e.find(e=>e.id===R)??null:null,pe=ee||ae,me=(0,_.useMemo)(()=>[{id:`keys`,label:L(`api.section.keys`),meta:a?void 0:String(e.length)},{id:`connect`,label:L(`api.section.connect`)},{id:`endpoints`,label:L(`api.section.endpoints`)},{id:`models`,label:L(`api.section.models`),meta:String(y)},{id:`examples`,label:L(`api.section.examples`)}],[L,e.length,a,y]),he=()=>{H(!1),W(!1)},ge=()=>{B(null),he(),re(!1),ce(!1),de(!1)};(0,_.useEffect)(()=>{if(!V)return;let e=window.setTimeout(()=>W(!0),300);return()=>window.clearTimeout(e)},[V]);let ve=()=>{fe&&H(!0)},ye=async()=>{if(!(!fe||!U||ee)){te(!0),de(!1);try{await k(fe.id)?(he(),B(null)):de(!0)}finally{te(!1)}}},be=()=>{fe&&(ie(fe.name),ce(!1),re(!0))},xe=async()=>{if(!fe||ae)return;let e=G.trim();if(!e||e===fe.name){re(!1);return}oe(!0),ce(!1);try{await A(fe.id,e)?re(!1):ce(!0)}finally{oe(!1)}};return(0,z.jsxs)(`div`,{className:`apikeys-workspace-shell`,children:[!fe&&(0,z.jsx)(lc,{scope:`api`,items:me,ariaLabel:L(`api.workspace.sections`)}),(0,z.jsx)(`div`,{className:`apikeys-workspace-root`,children:(0,z.jsx)(`section`,{className:`apikeys-workspace-main`,"aria-label":L(`api.workspace.details`),children:fe?(0,z.jsxs)(`div`,{className:`awi-detail`,children:[(0,z.jsx)(`div`,{className:`awi-detail-toolbar`,children:(0,z.jsxs)(`button`,{type:`button`,className:`awi-back`,onClick:ge,disabled:pe,children:[(0,z.jsx)(_e,{className:`awi-back-chevron`,"aria-hidden":`true`}),L(`modal.back`)]})}),(0,z.jsxs)(`div`,{className:`awi-detail-body`,children:[(0,z.jsxs)(`div`,{className:`awi-detail-head`,children:[(0,z.jsx)(`h2`,{className:`awi-detail-title`,children:fe.name}),(0,z.jsx)(`span`,{className:`awi-detail-actions`,children:V?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm awi-confirm-delete`,onClick:()=>{ye()},disabled:!U||ee,children:[(0,z.jsx)(ue,{}),` `,L(ee?`api.key.deleting`:`api.confirm`)]},`confirm-delete`),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:he,disabled:ee,children:L(`common.cancel`)})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:be,disabled:ne,children:L(`api.key.rename`)},`rename`),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,onClick:ve,"aria-label":L(`api.deleteAria`),children:[(0,z.jsx)(ue,{}),` `,L(`api.workspace.deleteKey`)]},`request-delete`)]})})]}),V&&(0,z.jsx)(`p`,{className:`muted awi-delete-hint`,children:L(`api.workspace.deleteConfirm`)}),le&&(0,z.jsx)(`p`,{className:`awi-delete-error`,role:`alert`,children:L(`api.deleteFailed`)}),ne&&(0,z.jsxs)(`div`,{className:`awi-rename`,children:[(0,z.jsx)(`label`,{className:`awi-rename-label`,htmlFor:`awi-key-name`,children:L(`api.key.name`)}),(0,z.jsx)(`input`,{id:`awi-key-name`,className:`input`,type:`text`,value:G,maxLength:64,disabled:ae,onChange:e=>ie(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),xe())}}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>{xe()},disabled:ae,children:L(ae?`api.key.renaming`:`api.key.saveName`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>re(!1),disabled:ae,children:L(`common.cancel`)}),se&&(0,z.jsx)(`p`,{className:`awi-rename-error`,role:`alert`,children:L(`api.key.renameFailed`)})]}),(0,z.jsxs)(`div`,{className:`awi-section`,children:[(0,z.jsx)(`h3`,{className:`awi-section-title`,children:L(`api.workspace.keyDetails`)}),(0,z.jsxs)(`dl`,{className:`awi-kv`,children:[(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(`api.workspace.keyPrefix`)}),(0,z.jsx)(`dd`,{children:(0,z.jsx)(`code`,{children:fe.prefix})})]}),(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(`api.colCreated`)}),(0,z.jsx)(`dd`,{children:Au(fe.createdAt,l)})]})]})]}),(0,z.jsxs)(`div`,{className:`awi-section`,children:[(0,z.jsx)(`h3`,{className:`awi-section-title`,children:L(`api.attribution.title`)}),n?fe.usage.ambiguous?(0,z.jsx)(`p`,{className:`muted`,children:L(`api.attribution.ambiguous`)}):(0,z.jsxs)(`dl`,{className:`awi-kv`,children:[(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(`api.attribution.requests7d`)}),(0,z.jsx)(`dd`,{children:fe.usage.requests7d.toLocaleString(l)})]}),(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(r?`api.attribution.totalRequestsAvailable`:`api.attribution.totalRequests`)}),(0,z.jsx)(`dd`,{children:fe.usage.totalRequests.toLocaleString(l)})]}),(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(`api.attribution.lastUsed`)}),(0,z.jsx)(`dd`,{children:fe.usage.lastUsedAt?Au(fe.usage.lastUsedAt,l):L(`api.attribution.neverUsed`)})]}),(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(r?`api.attribution.sinceAvailable`:`api.attribution.since`)}),(0,z.jsx)(`dd`,{children:Au(n,l)})]})]}):(0,z.jsx)(`p`,{className:`muted`,children:L(`api.attribution.unavailableDetail`)})]})]})]}):(0,z.jsx)(`div`,{className:`awi-overview`,children:(0,z.jsxs)(`div`,{className:`awi-overview-section`,children:[(0,z.jsxs)(`div`,{id:oc(`api`,`keys`),className:`awi-section-anchor`,children:[(0,z.jsx)(Iu,{keys:e,keysLoading:a,keysLoadFailed:o,newName:u,creating:d,newKey:f,copied:p,confirmDelete:null,localeTag:l,showKeyList:!1,onNewNameChange:T,onCreate:E,onDismissNewKey:D,onCopyKey:O,onConfirmDelete:()=>{},onCancelDelete:()=>{},onDelete:()=>{}}),(0,z.jsx)(Gu,{keys:e,keysLoading:a,keysLoadFailed:o,attributionSince:n,localeTag:l,busy:pe,onSelect:e=>{B(e),he(),re(!1),ce(!1),de(!1)}})]}),(0,z.jsx)(`div`,{id:oc(`api`,`connect`),className:`awi-section-anchor`,children:(0,z.jsx)(Wu,{apiBase:t,baseUrl:s.baseUrl,hasKeys:e.length>0})}),(0,z.jsx)(`div`,{id:oc(`api`,`endpoints`),className:`awi-section-anchor`,children:(0,z.jsx)(Fu,{endpoints:s,claudeCodeEnabled:c,authMatrix:i})}),(0,z.jsx)(`div`,{id:oc(`api`,`models`),className:`awi-section-anchor`,children:(0,z.jsx)(Lu,{filteredModels:m,modelsLoading:h,modelsRefreshing:g,modelsLoadFailed:v,modelCount:y,hasModelData:b,modelQuery:x,copiedModelId:S,modelTests:C,claudeCodeEnabled:c,onModelQueryChange:j,onCopyModelId:M,onTestModel:N,onRetryModels:P,canTestModels:w,sourceLabel:F,protocolLabel:I})}),(0,z.jsx)(`div`,{id:oc(`api`,`examples`),className:`awi-section-anchor`,children:(0,z.jsx)(Ru,{endpoints:s,claudeCodeEnabled:c})})]})})})})]})}var qu=[],Ju=15e3;function Yu(e){let t=e.replace(/\/$/,``);if(!t)return Ou;try{return new URL(t).host?ku(`${t}/v1/responses`):Ou}catch{return Ou}}function Xu(e){return!e||!Du(e.authMatrix)||!Array.isArray(e.keys)||e.keys.some(e=>!e||!Tu(e.usage))?null:e}function Zu({apiBase:e}){let{t,locale:n}=Ve(),r=Ie.find(e=>e.code===n)?.htmlLang,i=`ocx.apikeys.list.v2:${e}`,a=`ocx.apikeys.models.v1:${e}`,o=`api-keys:${e}`,s=`api-models:${e}`,c=Xu(Y(i)),l=Y(a),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(``),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)({}),[y,b]=(0,_.useState)(``),[x,S]=(0,_.useState)(!1),[C,w]=(0,_.useState)(null),[T,E]=(0,_.useState)(!1),D=(0,_.useRef)(!1),O=(0,_.useCallback)(async n=>{let r=await ut(await fetch(`${e}/api/keys`,{signal:n}));if(!r||!Du(r.authMatrix))throw Error(t(`api.keysLoadFailed`));let a=r.keys??[];if(a.some(e=>!Tu(e.usage)))throw Error(t(`api.keysLoadFailed`));let o=a,s=ku(r.endpoint??``),c={keys:o,endpoints:{baseUrl:r.baseUrl??s.baseUrl,responses:r.responsesEndpoint??r.endpoint??Ou.responses,chatCompletions:r.chatCompletionsEndpoint??s.chatCompletions,messages:r.messagesEndpoint??s.messages,models:r.modelsEndpoint??s.models},claudeCodeEnabled:r.claudeCodeEnabled!==!1,...r.attributionSince?{attributionSince:r.attributionSince}:{},...r.historyTruncated===!0?{historyTruncated:!0}:{},authMatrix:r.authMatrix};return X(i,c),c},[e,i,t]),k=(0,_.useCallback)(async n=>{let r=await fetch(`${e}/v1/models`,{signal:n});if(!r.ok)throw Error(t(`api.modelsLoadFailed`));let i=await r.json(),o=Array.isArray(i)?i:typeof i==`object`&&i&&Array.isArray(i.data)?i.data:null;if(!o)throw Error(t(`api.modelsLoadFailed`));let s=o.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`).map(e=>Cu(e)).sort((e,t)=>wu(e).localeCompare(wu(t)));return X(a,s),s},[e,a,t]),A=us(o,[e],O,{isEmpty:e=>e.keys.length===0,initialData:c??void 0}),j=us(s,[e],k,{isEmpty:e=>e.length===0,initialData:l??void 0}),M=A.state,N=j.state,P=M.data??c,F=N.data??l??qu,I=P?.keys??[],L=P?.endpoints??Yu(e),R=P?.claudeCodeEnabled??!0,B=P?.attributionSince,V=P?.historyTruncated===!0,H=P?.authMatrix??[],U=A.refresh,W=j.refresh,ee=(0,_.useMemo)(()=>{let e=f.trim().toLowerCase();return e?F.filter(t=>wu(t).toLowerCase().includes(e)||t.displayName.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e)):F},[f,F]),te=async n=>{if(D.current)return!1;D.current=!0,S(!0),d(null);try{let r=n??y,i=await J(await fetch(`${e}/api/keys`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:r||`default`})}),t(`api.createFailed`));return typeof i?.key!=`string`||i.key.length===0?(d(t(`api.createFailed`)),!1):(w(i.key),b(``),U(),!0)}catch{return d(t(`api.createFailed`)),!1}finally{D.current=!1,S(!1)}},ne=async t=>{d(null);let n=Rt(Ju);try{return(await fetch(`${e}/api/keys`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t}),signal:n.signal})).ok?(U(),!0):!1}catch{return!1}finally{n.clear()}},re=async(t,n)=>{d(null);let r=Rt(Ju);try{return(await fetch(`${e}/api/keys`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t,name:n}),signal:r.signal})).ok?(U(),!0):!1}catch{return!1}finally{r.clear()}},G=async()=>{if(C){d(null);try{await navigator.clipboard.writeText(C),E(!0),window.setTimeout(()=>E(!1),2e3)}catch{E(!1),d(t(`api.key.copyFailed`))}}},ie=async e=>{try{await navigator.clipboard.writeText(e),h(e),window.setTimeout(()=>h(t=>t===e?null:t),2e3)}catch{}},ae=e=>e.native?t(`api.sourceNative`):e.provider===`combo`?t(`api.sourceCombo`):e.custom?t(`api.sourceCustom`):e.provider,oe=e=>t(e===`responses`?`api.protocolResponses`:e===`messages`?`api.protocolMessages`:`api.protocolChatCompletions`),se=(e,t)=>e===`responses`?{url:L.responses,body:{model:t,input:`ping`,max_output_tokens:1,stream:!1}}:e===`messages`?{url:L.messages,body:{model:t,max_tokens:1,messages:[{role:`user`,content:`ping`}]}}:{url:L.chatCompletions,body:{model:t,messages:[{role:`user`,content:`ping`}],max_tokens:1,stream:!1}},ce=(e,t,n)=>v(r=>({...r,[e]:{...r[e],[t]:n}})),le=async(e,n)=>{if(!C)return;let r=wu(e),i=se(n,r);ce(r,n,{state:`testing`});try{let e=await fetch(i.url,{method:`POST`,headers:{"Content-Type":`application/json`,"x-opencodex-api-key":C},body:JSON.stringify(i.body)});if(!e.ok){ce(r,n,{state:`error`,detail:(await e.text()).slice(0,160)||String(e.status)});return}ce(r,n,{state:`ok`})}catch(e){ce(r,n,{state:`error`,detail:e instanceof Error?e.message:t(`api.testFailed`)})}},ue=t(`api.subtitle`).split(`{authHeader}`);return(0,z.jsxs)(`section`,{className:`api-page`,"aria-busy":M.refreshing||N.refreshing||void 0,children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:t(`api.title`)})}),(0,z.jsxs)(`p`,{className:`page-sub`,children:[ue[0],(0,z.jsx)(`code`,{children:`x-opencodex-api-key`}),ue[1]]}),u&&(0,z.jsx)(q,{tone:`err`,children:u}),M.showError&&P&&(0,z.jsx)(q,{tone:`err`,children:t(`api.keysLoadFailed`)}),M.showSkeleton&&!P?(0,z.jsx)(fs,{label:t(`api.activeKeysLoading`),rows:4}):M.kind===`failed-cold`&&!P?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(q,{tone:`err`,children:M.error instanceof Error?M.error.message:t(`api.keysLoadFailed`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>U(),children:t(`common.retry`)})]}):(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(Ku,{keys:I,apiBase:e,attributionSince:B,historyTruncated:V,authMatrix:H,keysLoading:!1,keysLoadFailed:M.showError,endpoints:L,claudeCodeEnabled:R,localeTag:r,newName:y,creating:x,newKey:C,copied:T,filteredModels:ee,modelsLoading:N.showSkeleton&&!N.data&&!l,modelsRefreshing:N.refreshing&&N.showError&&(N.data!==void 0||l!==null),modelsLoadFailed:N.showError,modelCount:F.length,hasModelData:N.data!==void 0||l!==null,modelQuery:f,copiedModelId:m,modelTests:g,onNewNameChange:b,onCreate:()=>{te()},onDismissNewKey:()=>w(null),onCopyKey:()=>{G()},onDelete:ne,onRename:re,onModelQueryChange:p,onCopyModelId:e=>{ie(e)},onTestModel:(e,t)=>{le(e,t)},onRetryModels:()=>{W({forceLoading:!0})},canTestModels:C!==null,sourceLabel:ae,protocolLabel:oe})})]})}function Qu(e,t){let n=(e??[]).map(e=>({value:e,label:zo(e)}));return[{value:``,label:t},...n]}function $u(e){let t=e.autoConnectSupported===!0;return{autoConnectSupported:t,systemEnv:t&&e.systemEnv===!0}}var ed=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`,`ANTHROPIC_DEFAULT_FABLE_MODEL`];function td(e){let t=`http://127.0.0.1:${e.port}`,n=e.authMode===`auto`?e.markerMode??`subscription`:e.authMode,r=e.autoContext&&e.maxContextTokens===null,i=ed.filter(t=>e.effectiveModelEnv[t]).map(t=>`export ${t}=${e.effectiveModelEnv[t]}`);return[`export ANTHROPIC_BASE_URL=${t}`,...n===`proxy`?[`export ANTHROPIC_AUTH_TOKEN=opencodex-proxy`]:[`# no ANTHROPIC_AUTH_TOKEN: your claude.ai login (and connectors) stay active`],`export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1`,...n===`proxy`?['[ -z "${CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST+x}" ] && export CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1']:[],...r?[`export CLAUDE_CODE_AUTO_COMPACT_WINDOW=${e.autoCompactWindow??35e4}`]:[],...i,`claude`].join(`
67
- `)}function nd(e){return e?e.backend??`auto`:`inherit`}function rd(e,t){if(t!==`inherit`)return t===`auto`?{...e,backend:void 0}:{...e,backend:t}}function id(e,t){return{...e,model:t}}function ad(e){if(!e)return null;let t=(e.model??``).trim();return e.backend?{backend:e.backend,model:t}:t?{backend:null,model:t}:null}function od({label:e,checked:t,onChange:n,disabled:r=!1,describedBy:i}){return(0,z.jsxs)(`label`,{className:`toggle`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:t,disabled:r,"aria-label":e,"aria-describedby":i,onChange:e=>n(e.target.checked)}),(0,z.jsx)(`span`,{className:`slider`,"aria-hidden":`true`})]})}function sd({supported:e,checked:t,onChange:n}){let r=K(),i=e?void 0:`claude-system-env-unsupported`;return(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:r(`claude.systemEnv`)}),e?(0,z.jsx)(`span`,{className:`desc`,children:r(`claude.systemEnvDesc`)}):(0,z.jsx)(`span`,{className:`desc`,id:i,children:(0,z.jsx)(Ue,{k:`claude.systemEnvUnsupported`,cmd:`ocx claude`})}),e&&t&&(0,z.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:r(`claude.systemEnvWarn`)})]}),(0,z.jsx)(od,{label:r(`claude.systemEnv`),checked:e&&t,disabled:!e,describedBy:i,onChange:n})]})}function cd({value:e,tierHaikuModel:t,options:n,onChange:r}){let i=K(),a=t??e;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:i(`claude.smallFastModelAccurateHint`)}),(0,z.jsx)(at,{value:e,options:n,onChange:r,label:i(`claude.smallFastModel`),style:{maxWidth:420}}),a===``&&(0,z.jsx)(`p`,{className:`notice-warn`,role:`status`,style:{marginTop:8},children:i(`claude.smallFastModelNativeWarning`)})]})}function ld(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)try{return crypto.randomUUID()}catch{}let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<16;t++)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function ud(e,t=`en`){if(e>=1e6){let n=e/1e6,r=n.toFixed(1).replace(/\.0$/,``);return Number.isInteger(n)||Number(r)*1e6===e?new Intl.NumberFormat(t,{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:+!Number.isInteger(n)}).format(e):`${Math.round(e/1e3)}k`}return`${Math.round(e/1e3)}k`}function dd(e,t){return e&&[`claude-json-oauth`,`claude-credentials-file`,`macos-keychain`,`exported-env`].includes(e)?t(`claude.authSource.${e}`):t(`claude.authSource.unknown`)}function fd({state:e,autoCompactOptions:t,availableModels:n,onStateChange:r}){let i=K();return(0,z.jsxs)(`div`,{className:`card`,style:{overflow:`hidden`},children:[(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.enabledLabel`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.enabledHint`)})]}),(0,z.jsx)(od,{label:i(`claude.enabledLabel`),checked:e.enabled,onChange:t=>r({...e,enabled:t})})]}),(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.authMode`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.authModeHint`)})]}),(0,z.jsx)(`div`,{className:`setting-controls`,children:(0,z.jsx)(at,{value:e.authMode,options:[{value:`auto`,label:i(`claude.authModeAuto`)},{value:`subscription`,label:i(`claude.authModeSubscription`)},{value:`proxy`,label:i(`claude.authModeProxy`)}],onChange:t=>r({...e,authMode:t}),label:i(`claude.authMode`),style:{minWidth:220},align:`right`,portal:!0})})]}),e.authModeOrigin&&(0,z.jsxs)(`div`,{className:`claude-effective-auth${e.authModeOrigin===`auto-unknown`?` warn`:``}`,role:`status`,children:[(0,z.jsx)(`span`,{className:`claude-effective-auth-label`,children:i(`claude.effectiveMode.label`)}),(0,z.jsxs)(`span`,{children:[e.authModeOrigin===`manual`?i(`claude.effectiveMode.manual`,{mode:e.markerMode===`proxy`?i(`claude.authModeProxy`):i(`claude.authModeSubscription`)}):e.authModeOrigin===`auto-present`?i(`claude.effectiveMode.autoPresent`,{source:dd(e.authFoundBy,i)}):e.authModeOrigin===`auto-absent`?i(`claude.effectiveMode.autoAbsent`):i(`claude.effectiveMode.autoUnknown`),e.admissionKeyActive===!0?` ${i(`claude.effectiveMode.admissionKey`)}`:``]})]}),(0,z.jsx)(sd,{supported:e.autoConnectSupported,checked:e.systemEnv,onChange:t=>r({...e,systemEnv:t})}),(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.fastMode`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.fastModeDesc`)})]}),(0,z.jsx)(`div`,{className:`setting-controls`,children:(0,z.jsx)(at,{value:e.fastMode===null?`auto`:e.fastMode?`on`:`off`,options:[{value:`auto`,label:i(`claude.fastAuto`)},{value:`on`,label:i(`claude.fastOn`)},{value:`off`,label:i(`claude.fastOff`)}],onChange:t=>r({...e,fastMode:t===`auto`?null:t===`on`}),label:i(`claude.fastMode`),style:{minWidth:140},align:`right`,portal:!0})})]}),(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.autoContext`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.autoContextDesc`)}),e.maxContextTokens!==null&&(0,z.jsx)(`span`,{className:`desc`,style:{color:`var(--muted)`},children:i(`claude.autoContextInert`)})]}),(0,z.jsx)(od,{label:i(`claude.autoContext`),checked:e.autoContext,onChange:t=>r({...e,autoContext:t})})]}),e.autoContext&&(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.autoCompactWindow`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.autoCompactWindowDesc`)}),e.autoCompactWindow!==null&&(0,z.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:i(`claude.autoCompactWindowWarn`)})]}),(0,z.jsx)(`div`,{className:`setting-controls`,children:(0,z.jsx)(at,{value:e.autoCompactWindow===null?``:String(e.autoCompactWindow),options:t,onChange:t=>r({...e,autoCompactWindow:t===``?null:Number(t)}),label:i(`claude.autoCompactWindow`),style:{minWidth:130},align:`right`,portal:!0})})]}),(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.injectAgents`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.injectAgentsDesc`)})]}),(0,z.jsx)(od,{label:i(`claude.injectAgents`),checked:e.injectAgents,onChange:t=>r({...e,injectAgents:t})})]}),[`webSearchSidecar`,`visionSidecar`].map(t=>{let a=e[t],o=t===`webSearchSidecar`?`claude.webSearchSidecar`:`claude.visionSidecar`,s=t===`webSearchSidecar`?`claude.webSearchSidecarHint`:`claude.visionSidecarHint`,c=`claude-sidecar-models-${t}`;return(0,z.jsxs)(`div`,{className:`setting-row`,style:{alignItems:`flex-start`},children:[(0,z.jsxs)(`div`,{className:`setting-label setting-copy`,style:{flex:1},children:[(0,z.jsx)(`span`,{className:`title`,children:i(o)}),(0,z.jsx)(`span`,{className:`desc`,children:i(s)})]}),(0,z.jsxs)(`div`,{className:`setting-controls`,style:{display:`flex`,gap:8},children:[(0,z.jsx)(at,{value:nd(a),options:[{value:`inherit`,label:i(`claude.useMainSetting`)},{value:`auto`,label:i(`dash.backendAuto`)},{value:`openai`,label:i(`dash.backendOpenAI`)},{value:`anthropic`,label:i(`dash.backendAnthropic`)}],onChange:n=>{r({...e,[t]:rd(a,n)})},label:i(`dash.sidecarBackend`),portal:!0}),(0,z.jsx)(`input`,{className:`input mono`,value:a?.model??``,onChange:n=>{r({...e,[t]:id(a,n.target.value)})},placeholder:i(`claude.sidecarModelPlaceholder`),disabled:!a,list:a?c:void 0,"aria-label":i(`dash.sidecarModel`),style:{minWidth:210},autoComplete:`off`}),a&&(0,z.jsx)(`datalist`,{id:c,children:n.map(e=>(0,z.jsx)(`option`,{value:e},e))})]})]},t)})]})}function pd({manualEnv:e}){let t=K();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:(0,z.jsx)(Ue,{k:`claude.quickstartHint`,cmd:`ocx claude`})}),(0,z.jsx)(`pre`,{className:`mono card`,style:{padding:`10px 14px`,overflowX:`auto`,margin:0},children:`ocx claude`}),(0,z.jsxs)(`details`,{style:{margin:`10px 0 0`},children:[(0,z.jsx)(`summary`,{className:`muted text-label`,style:{cursor:`pointer`,padding:`2px 2px`},children:t(`claude.manualEnv`)}),(0,z.jsx)(`pre`,{className:`mono card text-label`,style:{padding:`10px 14px`,overflowX:`auto`,margin:`6px 0 0`},children:e})]})]})}function md({rows:e,onRowsChange:t}){let n=K();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:n(`claude.modelMapHint`)}),(0,z.jsx)(`div`,{className:`stack`,style:{gap:8},children:e.map((r,i)=>(0,z.jsxs)(`div`,{className:`row`,style:{gap:8},children:[(0,z.jsx)(`input`,{className:`input mono`,value:r.from,placeholder:n(`claude.mapFrom`),"aria-label":n(`claude.mapFrom`),onChange:n=>t(e.map((e,t)=>t===i?{...e,from:n.target.value}:e)),style:{flex:1}}),(0,z.jsx)(`span`,{className:`muted`,"aria-hidden":!0,children:`→`}),(0,z.jsx)(`input`,{className:`input mono`,value:r.to,placeholder:n(`claude.mapTo`),"aria-label":n(`claude.mapTo`),onChange:n=>t(e.map((e,t)=>t===i?{...e,to:n.target.value}:e)),style:{flex:1}}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>t(e.filter((e,t)=>t!==i)),"aria-label":n(`claude.removeMapping`),style:{color:`var(--red)`},children:(0,z.jsx)(ae,{})})]},r.id))}),(0,z.jsx)(`div`,{style:{marginTop:8},children:(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>t([...e,{id:ld(),from:``,to:``}]),children:[(0,z.jsx)(oe,{}),` `,n(`claude.addMapping`)]})})]})}var hd=`etc`;function gd(e){let t=new Map;for(let n of e){let e=/\(([^)]+)\)\s*$/.exec(n.display_name),r=e?e[1]:hd,i=t.get(r);i?i.push(n):t.set(r,[n])}return Array.from(t)}function _d({aliases:e}){let t=K();return(0,z.jsxs)(`div`,{className:`claude-aliases`,children:[(0,z.jsx)(`p`,{className:`muted text-label claude-aliases-hint`,children:t(`claude.aliasesHint`)}),e.length===0?(0,z.jsx)(`div`,{className:`muted text-label`,children:t(`claude.none`)}):(0,z.jsx)(`div`,{className:`claude-aliases-scroll`,children:gd(e).map(([e,n])=>(0,z.jsxs)(`div`,{className:`claude-aliases-group`,children:[(0,z.jsxs)(`div`,{className:`claude-aliases-group-label`,children:[e===hd?t(`claude.aliasProviderOther`):e,(0,z.jsx)(`span`,{className:`claude-aliases-group-count`,children:n.length})]}),(0,z.jsx)(`div`,{className:`claude-aliases-chips`,children:n.map(e=>(0,z.jsxs)(`span`,{className:`claude-aliases-chip`,children:[(0,z.jsx)(`code`,{className:`claude-aliases-chip-id`,children:e.id}),e.display_name?(0,z.jsx)(`span`,{className:`claude-aliases-chip-name`,children:e.display_name}):null]},e.id))})]},e))})]})}function vd({apiBase:e,active:t=!0}){let n=K(),{locale:r}=Ve(),i=Ie.find(e=>e.code===r)?.htmlLang??`en`,a=`ocx.claude-code.v1:${e}`,o=`claude-code:${e}`,s=(0,_.useMemo)(()=>Y(a),[a]),[c,l]=(0,_.useState)(()=>s?.state??null),[u,d]=(0,_.useState)(()=>s?.rows??[]),[f,p]=(0,_.useState)(!!s),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(`settings`),x=(0,_.useCallback)(async t=>{let r=await J(await fetch(`${e}/api/claude-code`,{signal:t}),n(`claude.loadFail`));if(!r)throw Error(n(`claude.loadFail`));let i={...r,authMode:r.authMode===`proxy`||r.authMode===`subscription`?r.authMode:`auto`,...$u(r),fastMode:r.fastMode??null,maxContextTokens:r.maxContextTokens??null,autoContext:r.autoContext!==!1,autoCompactWindow:r.autoCompactWindow??null,injectAgents:r.injectAgents!==!1,effectiveModelEnv:r.effectiveModelEnv??{}},o=Object.entries(r.modelMap??{}).map(([e,t])=>({id:ld(),from:e,to:String(t)})),s={state:i,rows:o};if(t.aborted)throw Error(`Claude Code request aborted`);return l(i),d(o),p(!0),X(a,s),s},[e,a,n]),S=us(o,[e],x,{isEmpty:()=>!1,enabled:t,initialData:s??void 0}),C=S.state,w=C.data??s,T=c??w?.state??null,E=f?u:w?.rows??u,D=(0,_.useMemo)(()=>Qu(T?.available,n(`claude.smallFastModelUnsetOption`)),[T?.available,n]),O=(0,_.useMemo)(()=>{let e=[1e5,2e5,25e4,3e5,35e4,4e5,5e5,6e5,75e4,9e5,1e6],t=T?.autoCompactWindow??null,r=t!==null&&!e.includes(t)?[...e,t].sort((e,t)=>e-t):e;return[{value:``,label:n(`claude.autoCompactDefault`)},...r.map(e=>({value:String(e),label:ud(e,i)}))]},[T?.autoCompactWindow,n,i]),k=async()=>{if(!T)return;h(``);let t={};for(let e of E)e.from.trim()&&e.to.trim()&&(t[e.from.trim()]=e.to.trim());try{await J(await fetch(`${e}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:T.enabled,authMode:T.authMode,systemEnv:T.systemEnv,fastMode:T.fastMode,autoContext:T.autoContext,autoCompactWindow:T.autoCompactWindow,injectAgents:T.injectAgents,smallFastModel:T.smallFastModel,modelMap:t,webSearchSidecar:ad(T.webSearchSidecar),visionSidecar:ad(T.visionSidecar)})}),n(`claude.saveFailed`)),v(!0),h(n(`claude.saved`)),S.refresh()}catch(e){v(!1),h(e instanceof Error&&e.message?e.message:n(`claude.networkError`))}};if(C.kind===`disabled`&&!w)return null;if(C.showSkeleton&&!w)return(0,z.jsx)(fs,{label:n(`claude.loading`),rows:3});if(C.kind===`failed-cold`)return(0,z.jsxs)(`div`,{className:`claudecode-workspace-shell`,children:[(0,z.jsx)(q,{tone:`err`,children:C.error instanceof Error?C.error.message:n(`claude.loadFail`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>S.refresh(),children:n(`common.retry`)})]});if(!T)return null;let A=[{id:`settings`,label:n(`claude.workspace.settings`),body:(0,z.jsx)(fd,{state:T,autoCompactOptions:O,availableModels:T.available??[],onStateChange:l})},{id:`quickstart`,label:n(`claude.quickstart`),body:(0,z.jsx)(pd,{manualEnv:td(T)})},{id:`smallFast`,label:n(`claude.smallFastModel`),body:(0,z.jsx)(cd,{value:T.smallFastModel,tierHaikuModel:T.tierModels?.haiku,options:D,onChange:e=>l({...T,smallFastModel:e})})},{id:`modelMap`,label:n(`claude.modelMap`),meta:String(E.length),body:(0,z.jsx)(md,{rows:E,onRowsChange:e=>{p(!0),d(e)}})},{id:`aliases`,label:n(`claude.aliases`),meta:String(T.aliases.length),body:(0,z.jsx)(_d,{aliases:T.aliases})}],j=A.find(e=>e.id===y)??A[0],M=y===`settings`||y===`smallFast`||y===`modelMap`;return(0,z.jsxs)(`div`,{className:`claudecode-workspace-shell`,children:[m&&(0,z.jsx)(q,{tone:g?`ok`:`err`,children:m}),C.showError&&(0,z.jsx)(q,{tone:`err`,children:n(`claude.loadFail`)}),(0,z.jsxs)(`div`,{className:`claudecode-workspace-root`,children:[(0,z.jsx)(`aside`,{className:`claudecode-workspace-rail`,"aria-label":n(`claude.pageTitle`),children:(0,z.jsx)(`div`,{className:`claudecode-workspace-rail-list`,children:A.map(e=>(0,z.jsx)(`button`,{type:`button`,className:`claudecode-workspace-rail-row${y===e.id?` claudecode-workspace-rail-row--selected`:``}`,onClick:()=>b(e.id),"aria-current":y===e.id?`true`:void 0,children:(0,z.jsx)(`span`,{className:`claudecode-workspace-rail-name`,children:e.label})},e.id))})}),(0,z.jsxs)(`section`,{className:`claudecode-workspace-main`,"aria-label":j.label,children:[(0,z.jsxs)(`div`,{className:`ccw-main-head`,children:[(0,z.jsxs)(`h3`,{className:`ccw-main-title`,children:[j.label,j.meta==null?null:(0,z.jsx)(`span`,{className:`count`,children:j.meta})]}),(0,z.jsx)(`div`,{className:`claudecode-workspace-save`,"data-visible":M?`true`:`false`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:!M,tabIndex:M?0:-1,"aria-hidden":!M,onClick:()=>{k()},children:n(`common.save`)})})]}),(0,z.jsx)(`div`,{className:`ccw-body`,children:j.body})]})]})]})}function $(e,t,n){let r=t.trim().toLowerCase(),i=(r?e.filter(e=>e.label.toLowerCase().includes(r)||e.route.toLowerCase().includes(r)):e).toSorted((e,t)=>Number(!e.available)-Number(!t.available)),a=i.slice(0,n);return{total:e.length,showSearch:e.length>4,shown:a,hidden:i.length-a.length,noMatch:e.length>0&&i.length===0}}function yd(e){return new Set(Object.keys(e))}function bd(e,t){return t!==null&&e===t}function xd(e){return e||(typeof localStorage>`u`?void 0:localStorage)}function Sd(e){return{read(t){let n=xd(t);if(!n)return null;try{let t=n.getItem(e);if(t===null)return null;let r=JSON.parse(t);return Array.isArray(r)?new Set(r.filter(e=>typeof e==`string`)):null}catch{return null}},write(t,n){let r=xd(n);if(r)try{r.setItem(e,JSON.stringify([...t]))}catch{}}}}function Cd(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}var wd=[`opus`,`fable`,`sonnet`,`haiku`],Td=Sd(`ocx.claudeDesktop.collapsedFamilies.v2`),Ed={opus:`claudeDesktop.family.opus`,fable:`claudeDesktop.family.fable`,sonnet:`claudeDesktop.family.sonnet`,haiku:`claudeDesktop.family.haiku`};function Dd(e){return{version:1,assignments:Object.fromEntries(Object.entries(e.assignments).map(([e,t])=>[e,{...t}])),defaults:{...e.defaults},...e.appliedFingerprint===void 0?{}:{appliedFingerprint:e.appliedFingerprint},...e.appliedAt===void 0?{}:{appliedAt:e.appliedAt}}}function Od(e){let t={...e.profile.assignments};for(let n of e.models){let e=t[n.route]??n.assignment;t[n.route]={family:wd.includes(e?.family)?e.family:`opus`,alias:typeof e?.alias==`string`?e.alias:``}}return{version:1,assignments:t,defaults:{opus:e.profile.defaults.opus??null,fable:e.profile.defaults.fable??null,sonnet:e.profile.defaults.sonnet??null,haiku:e.profile.defaults.haiku??null}}}function kd(e,t){return e&&typeof e==`object`&&`error`in e&&typeof e.error==`string`?e.error:t}function Ad(e,t){return e?e>=1048576?t(`claudeDesktop.contextM`,{n:Math.round(e/1048576)}):e>=1e6?t(`claudeDesktop.contextM`,{n:e/1e6}):t(`claudeDesktop.contextK`,{n:Math.round(e/1e3)}):null}function jd(e){return Y(e)}function Md(e){let t=jd(e);return{held:t,data:t?.data??null,profile:t?.profile??null,savedProfile:t?.profile?Dd(t.profile):null,destinations:t?.data?Object.fromEntries(t.data.models.map(e=>[e.route,t.profile.assignments[e.route]?.family??`opus`])):{}}}function Nd({apiBase:e,active:t=!0,onPortChange:n}){let{t:r,locale:i}=Ve(),a=Ie.find(e=>e.code===i)?.htmlLang,o=`ocx.claude-desktop.v1:${e}`,s=`claude-desktop:${e}`,c=(0,_.useMemo)(()=>Md(o),[o]),[l,u]=(0,_.useState)(()=>c.profile),[d,f]=(0,_.useState)(()=>c.savedProfile),[p,m]=(0,_.useState)(()=>c.destinations),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)({}),[w,T]=(0,_.useState)({}),[E,D]=(0,_.useState)(()=>Td.read()??new Set(wd)),[O,k]=(0,_.useState)({}),A=(0,_.useRef)(null),j=(0,_.useCallback)(async t=>{let n=await J(await fetch(`${e}/api/claude-desktop`,{signal:t}),r(`claudeDesktop.loadFail`));if(!n||!(`profile`in n)||!(`models`in n))throw Error(kd(n,r(`claudeDesktop.loadFail`)));let i=Od(n),a={data:n,profile:i};if(t.aborted)throw Error(`Claude Desktop request aborted`);if(u(i),f(Dd(i)),m(Object.fromEntries(n.models.map(e=>[e.route,i.assignments[e.route]?.family??`opus`]))),Td.read()===null){let e=Object.fromEntries(wd.map(e=>[e,0]));for(let t of n.models)e[i.assignments[t.route]?.family??`opus`]+=1;D(yd(e))}return X(o,a),a},[e,o,r,m,u,f]),M=us(s,[e],j,{isEmpty:()=>!1,enabled:t,initialData:c.held??void 0}),N=M.state,P=N.data??(c.data&&c.profile?{data:c.data,profile:c.profile}:null),F=P?.data??null,I=l??P?.profile??null,L=d??P?.profile??null,R=P?Object.fromEntries(P.data.models.map(e=>[e.route,P.profile.assignments[e.route]?.family??`opus`])):{},B=Object.keys(p).length>0?p:R;(0,_.useEffect)(()=>{if(n){if(typeof F?.port==`number`){n(F.port);return}N.kind===`failed-cold`&&n(null)}},[F?.port,N.kind,n]);let V=(0,_.useMemo)(()=>I!==null&&L!==null&&JSON.stringify(I)!==JSON.stringify(L),[I,L]),H=(0,_.useMemo)(()=>{let e=Object.fromEntries(wd.map(e=>[e,[]]));if(!F||!I)return e;for(let t of F.models)e[I.assignments[t.route]?.family??`opus`].push(t);return e},[F,I]),U=(0,_.useMemo)(()=>{let e={};for(let t of wd){let n=H[t].filter(e=>e.available).map(e=>e.route).sort(),r=I?.defaults[t]??null;e[t]=r&&n.includes(r)?r:n[0]??null}return e},[H,I]),W=`ocx.claude-desktop.status.v1:${e}`,ee=`claude-desktop-status:${e}`,te=Y(W),ne=us(ee,[e],async t=>{let n=await ut(await fetch(`${e}/api/claude-desktop/status`,{signal:t}));if(!n)throw Error(`Claude Desktop status unavailable`);return X(W,n),n},{isEmpty:()=>!1,pollMs:5e3,enabled:t,initialData:te??void 0}),re=ne.state,G=re.data??te??null,ie=re.showError,ae=(e,t)=>{!I||I.assignments[e]?.family===t||(u(n=>{if(!n)return n;let r=n.assignments[e];if(!r||r.family===t)return n;let i={...n.assignments,[e]:{...r,family:t}},a={...n.defaults};return a[r.family]===e&&(a[r.family]=Object.keys(i).filter(t=>t!==e&&i[t].family===r.family).sort()[0]??null),a[t]===null&&(a[t]=e),{...n,assignments:i,defaults:a}}),m(n=>({...n,[e]:t})),y(r(`claudeDesktop.moved`,{route:e,family:r(Ed[t])})))},oe=e=>{let t=Cd(E,e);Td.write(t),D(t)},se=async t=>{if(!(!I||b)){x(`save`),g(null);try{await J(await fetch(`${e}/api/claude-desktop`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profile:I})}),r(`claudeDesktop.saveFailed`)),f(Dd(I)),t?(x(`apply`),await J(await fetch(`${e}/api/claude-desktop/apply`,{method:`POST`}),r(`claudeDesktop.applyFailed`)),g({tone:`ok`,text:r(`claudeDesktop.savedApplied`)}),y(r(`claudeDesktop.savedAppliedAnnounce`))):(g({tone:`ok`,text:r(`claudeDesktop.saved`)}),y(r(`claudeDesktop.savedAnnounce`))),ne.refresh()}catch(e){let t=e instanceof Error?e.message:r(`claudeDesktop.updateFailed`);g({tone:`err`,text:t}),y(t)}finally{x(null)}}},ce=()=>{if(!I)return;let e=URL.createObjectURL(new Blob([`${JSON.stringify(I,null,2)}\n`],{type:`application/json`})),t=document.createElement(`a`);t.href=e,t.download=`claude-desktop-profile.json`,t.click(),URL.revokeObjectURL(e),y(r(`claudeDesktop.exported`))},le=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t)try{let e=JSON.parse(await t.text());if(e.version!==1||!e.assignments||!e.defaults)throw Error(r(`claudeDesktop.importExpected`));u(Od({...F,profile:e})),g({tone:`ok`,text:r(`claudeDesktop.importReady`)}),y(r(`claudeDesktop.importedAnnounce`))}catch(e){let t=e instanceof Error?e.message:r(`claudeDesktop.importInvalid`);g({tone:`err`,text:t}),y(r(`claudeDesktop.importFailed`,{error:t}))}},ue=(e,t)=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);n&&ae(n,t)};return N.kind===`disabled`&&!P?null:N.showSkeleton&&!P?(0,z.jsx)(fs,{label:r(`claudeDesktop.loading`),rows:4}):N.kind===`failed-cold`?(0,z.jsxs)(`div`,{className:`claude-desktop-error`,children:[(0,z.jsx)(q,{tone:`err`,children:N.error instanceof Error?N.error.message:r(`claudeDesktop.loadFail`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>M.refresh(),children:r(`claudeDesktop.retry`)})]}):!F||!I?null:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`claude-desktop-toolbar`,children:(0,z.jsxs)(`div`,{className:`claude-profile-tools`,children:[(0,z.jsx)(`input`,{ref:A,type:`file`,accept:`application/json,.json`,hidden:!0,onChange:e=>void le(e)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>A.current?.click(),children:r(`claudeDesktop.importJson`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:ce,children:r(`claudeDesktop.exportJson`)})]})}),(0,z.jsxs)(`div`,{className:`claude-status-bar ${ie&&!G?`not-applied`:G?G.activeProfile===!1?`not-applied`:G.stale?`stale`:G.applied?`applied`:`not-applied`:`pending`}`,"aria-busy":!G&&!ie||void 0,children:[(0,z.jsx)(`span`,{className:`claude-status-dot`}),(0,z.jsx)(`span`,{children:ie&&!G?r(`claudeDesktop.loadFail`):G?G.activeProfile===!1?r(`claudeDesktop.status.notActiveProfile`):G.stale?r(`claudeDesktop.status.stale`):G.applied?r(`claudeDesktop.status.applied`):r(`claudeDesktop.status.notApplied`):r(`claudeDesktop.loading`)}),G?.health.lastRequestAt&&(0,z.jsxs)(`span`,{className:`claude-status-health`,children:[r(`claudeDesktop.health.lastRequest`),`:`,` `,new Date(G.health.lastRequestAt).toLocaleTimeString(a)]}),G&&G.health.requestCount>0&&(0,z.jsx)(`span`,{className:`claude-status-health`,children:r(`claudeDesktop.health.stats`,{count:G.health.requestCount,errors:G.health.errorCount})})]}),(0,z.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:v}),h&&(0,z.jsx)(q,{tone:h.tone,children:h.text}),N.showError&&(0,z.jsx)(q,{tone:`err`,children:r(`claudeDesktop.loadFail`)}),ie&&G&&(0,z.jsx)(q,{tone:`err`,children:r(`claudeDesktop.loadFail`)}),(0,z.jsxs)(`div`,{className:`claude-profile-bar`,children:[(0,z.jsx)(`span`,{className:`claude-dirty${V?` active`:``}`,children:r(V?`claudeDesktop.unsaved`:`claudeDesktop.upToDate`)}),(0,z.jsxs)(`div`,{className:`claude-save-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:!V||b!==null,onClick:()=>void se(!1),children:r(b===`save`?`claudeDesktop.saving`:`common.save`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:b!==null,onClick:()=>void se(!0),children:r(b===`apply`?`claudeDesktop.applying`:b===`save`?`claudeDesktop.saving`:`claudeDesktop.saveApply`)})]})]}),F.models.length===0&&(0,z.jsx)(ot,{title:r(`claudeDesktop.emptyTitle`),children:r(`claudeDesktop.emptyHint`)}),(0,z.jsx)(`div`,{className:`ocx-group-stack`,"aria-label":r(`claudeDesktop.assignmentsLabel`),children:wd.map(e=>{let t=H[e],n=$(t,S[e]??``,w[e]??6),i=E.has(e),a=U[e];return(0,z.jsxs)(`section`,{className:`ocx-group${i?` collapsed`:``}`,"aria-labelledby":`claude-lane-${e}`,onDragOver:e=>e.preventDefault(),onDrop:t=>ue(t,e),children:[(0,z.jsxs)(`header`,{className:`ocx-group-head${i?``:` open`}`,children:[(0,z.jsx)(`h3`,{id:`claude-lane-${e}`,className:`ocx-group-heading`,children:(0,z.jsxs)(`button`,{type:`button`,className:`ocx-group-toggle`,"aria-expanded":!i,"aria-controls":`claude-lane-body-${e}`,onClick:()=>oe(e),children:[(0,z.jsx)(_e,{className:`ocx-chevron`,width:14,height:14,"aria-hidden":`true`,style:{transform:i?`none`:`rotate(90deg)`}}),(0,z.jsx)(`span`,{className:`ocx-group-name`,children:r(Ed[e])}),(0,z.jsx)(`span`,{className:`ocx-group-count`,children:r(t.length===1?`claudeDesktop.modelCountOne`:`claudeDesktop.modelCountMany`,{count:t.length})}),a&&(0,z.jsx)(`code`,{className:`claude-lane-default`,title:a,children:a})]})}),t.length>0&&I.defaults[e]===null&&(0,z.jsx)(`span`,{className:`claude-default-needed`,children:r(`claudeDesktop.chooseDefault`)}),a&&a!==I.defaults[e]&&(0,z.jsx)(`span`,{className:`claude-default-needed`,title:a,children:r(`claudeDesktop.temporaryDefault`)})]}),!i&&(0,z.jsxs)(`div`,{id:`claude-lane-body-${e}`,children:[n.showSearch&&(0,z.jsx)(`input`,{className:`input claude-lane-search`,type:`search`,placeholder:r(`models.search`),"aria-label":r(`models.search`),value:S[e]??``,onChange:t=>{let n=t.target.value;C(t=>({...t,[e]:n})),T(t=>({...t,[e]:6}))}}),(0,z.jsxs)(`div`,{className:`claude-lane-models`,children:[t.length===0?(0,z.jsx)(`div`,{className:`claude-lane-empty`,children:r(`claudeDesktop.laneEmpty`)}):n.noMatch?(0,z.jsx)(`div`,{className:`claude-lane-empty`,children:r(`claudeDesktop.laneNoMatch`)}):n.shown.map(t=>{let n=I.assignments[t.route],i=Ad(t.contextWindow,r),a=B[t.route]??`opus`,o=O[t.route]??bd(t.route,U[e]);return(0,z.jsxs)(`article`,{className:`claude-model-card${o?` open`:``}`,draggable:t.available,onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.route)},children:[(0,z.jsxs)(`button`,{type:`button`,className:`claude-model-summary`,"aria-expanded":o,"aria-controls":`claude-model-body-${t.route}`,onClick:()=>k(e=>({...e,[t.route]:!o})),children:[(0,z.jsx)(_e,{className:`ocx-chevron`,width:12,height:12,"aria-hidden":`true`,style:{transform:o?`rotate(90deg)`:`none`}}),(0,z.jsxs)(`span`,{className:`claude-model-names`,children:[(0,z.jsx)(`strong`,{title:t.label,children:t.label}),(0,z.jsx)(`code`,{title:t.route,children:t.route})]}),i&&(0,z.jsx)(`span`,{className:`claude-model-context`,children:i}),!i&&(0,z.jsx)(`span`,{className:`claude-model-context claude-model-context-unknown`,children:r(`claudeDesktop.contextUnknown`)}),t.supports1m===!0&&(0,z.jsx)(`span`,{className:`claude-1m-chip`,children:r(`claudeDesktop.supports1m`)}),t.effortSupported===!1&&(0,z.jsx)(`span`,{className:`claude-effort-badge off`,children:r(`claudeDesktop.effort.displayOnly`)}),t.effortSupported===!0&&(0,z.jsx)(`span`,{className:`claude-effort-badge on`,children:r(`claudeDesktop.effort.supported`)}),I.defaults[e]===t.route&&(0,z.jsx)(`span`,{className:`claude-row-default`,children:r(`claudeDesktop.defaultBadge`)}),(0,z.jsx)(`span`,{className:`badge ${t.available?`badge-green`:`badge-muted`}`,children:t.available?r(`claudeDesktop.available`):r(`claudeDesktop.unavailable`)})]}),o&&(0,z.jsxs)(`div`,{className:`claude-model-body`,id:`claude-model-body-${t.route}`,children:[U[e]===t.route&&I.defaults[e]!==t.route&&(0,z.jsx)(`span`,{className:`claude-effective-default`,children:r(`claudeDesktop.temporaryDefault`)}),(0,z.jsxs)(`div`,{className:`claude-field`,children:[(0,z.jsx)(`span`,{children:r(`claudeDesktop.alias`)}),(0,z.jsx)(`code`,{className:`claude-alias`,title:n.alias,children:n.alias})]}),(0,z.jsxs)(`label`,{className:`claude-default-radio`,children:[(0,z.jsx)(`input`,{type:`radio`,name:`default-${e}`,checked:I.defaults[e]===t.route,disabled:!t.available,onChange:()=>u(n=>n&&{...n,defaults:{...n.defaults,[e]:t.route}})}),r(`claudeDesktop.useAsDefault`,{family:r(Ed[e])})]}),(0,z.jsxs)(`div`,{className:`claude-move-row`,children:[(0,z.jsx)(`label`,{htmlFor:`move-${t.route}`,children:r(`claudeDesktop.moveTo`)}),(0,z.jsx)(`select`,{id:`move-${t.route}`,className:`input`,value:a,disabled:!t.available,onChange:e=>m(n=>({...n,[t.route]:e.target.value})),children:wd.map(e=>(0,z.jsx)(`option`,{value:e,children:r(Ed[e])},e))}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:!t.available||a===e,onClick:()=>ae(t.route,a),children:r(`claudeDesktop.move`)})]})]})]},t.route)}),n.hidden>0&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm claude-lane-more`,onClick:()=>T(t=>({...t,[e]:(t[e]??6)+6})),children:r(`models.showMore`,{n:n.hidden})})]})]})]},e)})})]})}function Pd(e){let t=Y(`ocx.claude-desktop.v1:${e}`);return typeof t?.data?.port==`number`?t.data.port:null}function Fd({apiBase:e}){let[t,n]=(0,_.useState)(`code`),r=K(),i=(0,_.useRef)(null),a=(0,_.useRef)(null),o=Pd(e),[s,c]=(0,_.useState)(null),l=s?.base===e?s.port:o,u=s?.base===e,d=(0,_.useCallback)(t=>{c(n=>n?.base===e&&n.port===t?n:{base:e,port:t})},[e]),f=e=>{n(e),window.requestAnimationFrame(()=>{(e===`code`?i:a).current?.focus({preventScroll:!0})})},p=e=>{e.key===`ArrowLeft`||e.key===`ArrowRight`?(e.preventDefault(),f(t===`code`?`desktop`:`code`)):e.key===`Home`?(e.preventDefault(),f(`code`)):e.key===`End`&&(e.preventDefault(),f(`desktop`))};return(0,z.jsxs)(`section`,{className:`claude-page`,children:[(0,z.jsxs)(`div`,{className:`claude-page-intro`,children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:r(t===`code`?`claude.pageTitle`:`claudeDesktop.title`)})}),t===`code`?(0,z.jsx)(`p`,{className:`page-sub`,children:r(`claude.subtitle`)}):(0,z.jsx)(`p`,{className:`page-sub`,children:l==null?r(u?`claudeDesktop.loadFail`:`claudeDesktop.loading`):r(`claudeDesktop.subtitle`,{port:l})})]}),(0,z.jsxs)(`div`,{className:`claude-tabs`,role:`tablist`,"aria-label":r(`claude.tabsLabel`),children:[(0,z.jsx)(`button`,{type:`button`,role:`tab`,ref:i,"aria-selected":t===`code`,"aria-controls":`claude-code-panel`,id:`claude-code-tab`,className:t===`code`?`active`:``,tabIndex:t===`code`?0:-1,onKeyDown:p,onClick:()=>f(`code`),children:r(`claude.tabCode`)}),(0,z.jsx)(`button`,{type:`button`,role:`tab`,ref:a,"aria-selected":t===`desktop`,"aria-controls":`claude-desktop-panel`,id:`claude-desktop-tab`,className:t===`desktop`?`active`:``,tabIndex:t===`desktop`?0:-1,onKeyDown:p,onClick:()=>f(`desktop`),children:r(`claude.tabDesktop`)})]}),(0,z.jsx)(`div`,{id:`claude-code-panel`,role:`tabpanel`,"aria-labelledby":`claude-code-tab`,hidden:t!==`code`,children:(0,z.jsx)(vd,{apiBase:e,active:t===`code`},e)}),(0,z.jsx)(`div`,{id:`claude-desktop-panel`,role:`tabpanel`,"aria-labelledby":`claude-desktop-tab`,hidden:t!==`desktop`,children:(0,z.jsx)(Nd,{apiBase:e,active:t===`desktop`,onPortChange:d},e)})]})}function Id(e,t,n,r){let i=e.filter(e=>r===`native`===e.native).map(e=>({...e,alias:t.get(e.id)??null,enabled:!n.has(e.id)})).toSorted((e,t)=>Number(!e.enabled)-Number(!t.enabled));return{rows:i,total:i.length,enabled:i.filter(e=>e.enabled).length}}var Ld=Sd(`ocx.grok.collapsedGroups.v2`),Rd=[{id:`native`,tkey:`grok.groupNative`},{id:`routed`,tkey:`grok.groupRouted`}],zd=new Set(Rd.map(e=>e.id));function Bd(e,t){return e?e>=1048576?t(`claudeDesktop.contextM`,{n:Math.round(e/1048576)}):e>=1e6?t(`claudeDesktop.contextM`,{n:e/1e6}):t(`claudeDesktop.contextK`,{n:Math.round(e/1e3)}):`—`}function Vd({apiBase:e}){let t=K(),n=`ocx.grok.status.v1:${e}`,r=Y(n),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(()=>Ld.read()??new Set(zd)),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(``),m=(0,_.useCallback)(async()=>{let r=await J(await fetch(`${e}/api/grok`),t(`grok.loadFail`));if(!r)throw Error(t(`grok.loadFail`));let i={...r,candidates:r.candidates??[],excluded:r.excluded??[]};return X(n,i),i},[e,n,t]),h=`grok-status:${e}`,g=us(h,[e],m,{isEmpty:()=>!1,initialData:r??void 0}),{state:v}=g,y=g.refresh,b=v.data??r,x=(0,_.useMemo)(()=>new Set(b?.excluded??[]),[b]),S=i??x,C=(0,_.useMemo)(()=>i!==null&&(i.size!==x.size||[...i].some(e=>!x.has(e))),[i,x]),w=(0,_.useMemo)(()=>new Map((b?.models??[]).map(e=>[e.id,e.alias])),[b]),T=e=>{let t=Cd(o,e);Ld.write(t),s(t)},E=e=>{let t=e?new Set(Rd.map(e=>e.id)):new Set;Ld.write(t),s(t)},D=(e,t)=>{a(n=>{let r=new Set(n??x);return t?r.delete(e):r.add(e),r})},O=async r=>{if(!c){l(`save`),d(null);try{await J(await fetch(`${e}/api/grok/selection`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({excluded:[...S]})}),t(`grok.saveFailed`));let i=[...S];if(b&&L(h,{...b,excluded:i}),a(null),r){l(`apply`);let n=await fetch(`${e}/api/grok/apply`,{method:`POST`});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.message??e.error??t(`grok.applyFailed`))}let r=await n.json().catch(()=>({}));r.skippedReason?(d({tone:`err`,text:r.message??t(`grok.applySkipped`)}),p(r.message??t(`grok.applySkipped`))):(d({tone:`ok`,text:t(`grok.savedApplied`)}),p(t(`grok.savedApplied`))),await y()}else d({tone:`ok`,text:t(`grok.saved`)}),p(t(`grok.saved`)),b&&X(n,{...b,excluded:i})}catch(e){let n=e instanceof Error?e.message:t(`grok.saveFailed`);d({tone:`err`,text:n}),p(n)}finally{l(null)}}};return v.showSkeleton&&!b?(0,z.jsx)(`section`,{className:`grok-page`,children:(0,z.jsx)(fs,{label:t(`grok.loading`),rows:4})}):v.kind===`failed-cold`?(0,z.jsxs)(`section`,{className:`grok-page`,children:[(0,z.jsx)(`div`,{className:`alert alert-err`,role:`alert`,children:v.error instanceof Error?v.error.message:t(`grok.loadFail`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>y(),children:t(`common.retry`)})]}):(0,z.jsxs)(`section`,{className:`grok-page`,"aria-busy":v.refreshing||void 0,children:[(0,z.jsx)(`h2`,{className:`page-title`,children:t(`grok.title`)}),(0,z.jsx)(`p`,{className:`page-sub`,children:t(`grok.subtitle`)}),(0,z.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:f}),u&&(0,z.jsx)(q,{tone:u.tone,children:u.text}),v.showError&&(0,z.jsx)(q,{tone:`err`,children:t(`grok.loadFail`)}),b&&b.candidates.length>0&&(0,z.jsxs)(`div`,{className:`claude-profile-bar`,children:[(0,z.jsx)(`span`,{className:`claude-dirty${C?` active`:``}`,children:t(C?`grok.unsaved`:`grok.upToDate`)}),(0,z.jsxs)(`div`,{className:`claude-save-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:!C||c!==null,onClick:()=>void O(!1),children:t(c===`save`?`grok.saving`:`common.save`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:!C||c!==null,onClick:()=>void O(!0),children:t(c===`apply`?`grok.applying`:c===`save`?`grok.saving`:`grok.saveApply`)})]})]}),b?.present?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`grok-endpoint`,children:[(0,z.jsx)(`span`,{children:t(`grok.endpoint`)}),(0,z.jsx)(`code`,{children:b.baseUrl??`—`})]}),(0,z.jsx)(`p`,{className:`page-sub`,children:(0,z.jsx)(`code`,{children:b.configPath})})]}):(0,z.jsxs)(ot,{title:t(`grok.notConfiguredTitle`),children:[t(`grok.notConfiguredHint`),(0,z.jsx)(`br`,{}),(0,z.jsx)(`code`,{children:b?.configPath})]}),b&&b.candidates.length>0&&(0,z.jsxs)(`div`,{className:`ocx-group-stack`,children:[(0,z.jsxs)(`div`,{className:`row`,style:{gap:6,margin:`2px 0 10px`},children:[(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>E(!0),disabled:c!==null,children:[(0,z.jsx)(_e,{width:12,height:12,"aria-hidden":`true`}),` `,t(`models.collapseAll`)]}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>E(!1),disabled:c!==null,children:[(0,z.jsx)(_e,{width:12,height:12,"aria-hidden":`true`,style:{transform:`rotate(90deg)`}}),` `,t(`models.expandAll`)]})]}),Rd.map(e=>{let n=Id(b.candidates,w,S,e.id);if(n.total===0)return null;let r=o.has(e.id);return(0,z.jsxs)(`section`,{className:`ocx-group${r?` collapsed`:``}`,"aria-labelledby":`grok-group-${e.id}`,children:[(0,z.jsx)(`header`,{className:`ocx-group-head${r?``:` open`}`,children:(0,z.jsx)(`h3`,{id:`grok-group-${e.id}`,className:`ocx-group-heading`,children:(0,z.jsxs)(`button`,{type:`button`,className:`ocx-group-toggle`,"aria-expanded":!r,"aria-controls":`grok-group-body-${e.id}`,onClick:()=>T(e.id),children:[(0,z.jsx)(_e,{className:`ocx-chevron`,width:14,height:14,"aria-hidden":`true`,style:{transform:r?`none`:`rotate(90deg)`}}),(0,z.jsx)(`span`,{className:`ocx-group-name`,children:t(e.tkey)}),(0,z.jsx)(`span`,{className:`ocx-group-count`,children:t(`grok.enabledCount`,{on:n.enabled,total:n.total})})]})})}),!r&&(0,z.jsx)(`div`,{id:`grok-group-body-${e.id}`,className:`grok-model-list`,children:n.rows.map(e=>(0,z.jsxs)(`div`,{className:`grok-model-row`,children:[(0,z.jsx)(it,{on:e.enabled,onClick:()=>D(e.id,!e.enabled),disabled:c!==null,label:t(`grok.toggleModel`,{id:e.id})}),(0,z.jsxs)(`span`,{className:`grok-model-names`,children:[(0,z.jsx)(`strong`,{title:e.id,children:e.id}),(0,z.jsx)(`code`,{title:e.alias??void 0,children:e.alias??`—`})]}),(0,z.jsx)(`span`,{className:`claude-model-context`,children:Bd(e.contextWindow,t)})]},e.id))})]},e.id)})]})]})}function Hd(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.supported==`boolean`&&typeof t.installed==`boolean`&&typeof t.running==`boolean`&&typeof t.stale==`boolean`&&typeof t.summary==`string`}var Ud={native:`startup.status.native`,protected:`startup.status.protected`,"at-risk":`startup.status.atRisk`},Wd={native:`startup.summary.native`,protected:`startup.summary.protected`,"at-risk":`startup.summary.atRisk`},Gd={service:`startup.protection.service`,shim:`startup.protection.shim`,none:`startup.protection.none`};function Kd({ok:e,yes:t,no:n}){return(0,z.jsx)(`span`,{className:`badge ${e?`badge-green`:`badge-amber`}`,children:e?t:n})}function qd({failed:e,data:t}){let{t:n}=Ve(),r=e?`startup-hero--risk`:t.status===`protected`?`startup-hero--safe`:t.status===`at-risk`?`startup-hero--risk`:`startup-hero--native`,i=e||t.status===`at-risk`?de:ie,a=t.routingKind===`opencodex-local`?`startup.routing.proxy`:t.routingKind===`custom-local`?`startup.routing.customLocal`:t.routingKind===`custom-remote`?`startup.routing.customRemote`:t.routingKind===`unknown`?`startup.routing.unknown`:`startup.routing.native`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`section`,{className:`panel startup-hero ${r}`,"aria-live":`polite`,children:[(0,z.jsx)(`div`,{className:`startup-hero-icon`,children:(0,z.jsx)(i,{})}),(0,z.jsxs)(`div`,{className:`startup-hero-copy`,children:[(0,z.jsx)(`span`,{className:`badge ${e||t.status===`at-risk`?`badge-amber`:`badge-green`}`,children:n(e?`startup.status.atRisk`:Ud[t.status])}),(0,z.jsx)(`h3`,{children:n(e?`startup.error`:Wd[t.status])}),(0,z.jsx)(`p`,{children:e?n(`startup.staleData`):t.status===`at-risk`?n(cn(t)):n(`startup.safeDetail`)})]})]}),(0,z.jsxs)(`div`,{className:`startup-state-grid`,children:[(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.routing`)}),(0,z.jsx)(`div`,{className:`value`,children:n(a)})]}),(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.restartProtection`)}),(0,z.jsx)(`div`,{className:`value`,children:n(Gd[t.protection])})]}),(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.preference`)}),(0,z.jsx)(`div`,{className:`value`,children:n(t.autostartEnabled?`startup.enabled`:`startup.disabled`)})]})]})]})}function Jd({data:e,failed:t,loading:n=!1,installBusy:r,installResult:i,onInstall:a}){let{t:o}=Ve(),s=e.serviceSupported&&e.serviceInstalled&&e.serviceStale&&!e.serviceConflict,c=e.shimInstalled&&!e.shimHealthy,l=r!==null||t||n;return(0,z.jsxs)(`section`,{className:`panel startup-details`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:o(`startup.details`)}),(0,z.jsx)(`span`,{className:`muted mono`,children:e.platform})]}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:o(`startup.service`)}),(0,z.jsx)(`span`,{children:o(`startup.serviceHint`)})]}),(0,z.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,z.jsx)(Kd,{ok:e.serviceViable,yes:o(`startup.viable`),no:o(e.serviceConflict?`startup.conflict`:e.serviceStale?`startup.stale`:e.serviceInstalled?`startup.unhealthy`:e.serviceSupported?`startup.notInstalled`:`startup.unsupported`)}),e.serviceSupported&&!e.serviceInstalled&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.service`)} - ${o(`startup.install`)}`,disabled:l,onClick:()=>a(`install-service`),children:o(r===`install-service`?`startup.installing`:`startup.install`)}),s&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.service`)} - ${o(`startup.repair`)}`,disabled:l,onClick:()=>a(`install-service`,{repair:!0}),children:o(r===`install-service`?`startup.repairing`:`startup.repair`)})]})]}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:o(`startup.shim`)}),(0,z.jsx)(`span`,{children:o(`startup.shimHint`)})]}),(0,z.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,z.jsx)(Kd,{ok:e.shimHealthy&&e.autostartEnabled,yes:o(e.shimCoverage===`cli-only`?`startup.cliOnly`:`startup.healthy`),no:o(e.shimInstalled?e.shimHealthy&&!e.autostartEnabled?`startup.installedDisabled`:`startup.stale`:`startup.notInstalled`)}),!e.shimInstalled&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.shim`)} - ${o(`startup.install`)}`,disabled:l,onClick:()=>a(`install-shim`),children:o(r===`install-shim`?`startup.installing`:`startup.install`)}),c&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.shim`)} - ${o(`startup.repair`)}`,disabled:l,onClick:()=>a(`install-shim`,{repair:!0}),children:o(r===`install-shim`?`startup.repairing`:`startup.repair`)})]})]}),i&&(0,z.jsx)(`div`,{className:`notice ${i.kind===`success`?`notice-ok`:`notice-warn`} startup-action-notice`,role:`status`,"aria-live":`polite`,children:i.kind===`success`?i.action===`install-service`?o(i.repair?`startup.serviceRepaired`:`startup.serviceInstalled`):o(i.repair?`startup.shimRepaired`:`startup.shimInstalled`):`${o(`startup.installFailed`)} ${i.detail??``}`})]})}function Yd({tray:e,trayLoading:t,trayError:n,trayBusy:r,onTrayAction:i}){let{t:a}=Ve();return(0,z.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:a(`startup.tray.title`)}),(0,z.jsx)(ye,{})]}),(0,z.jsx)(`p`,{className:`muted`,children:a(`startup.tray.hint`)}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:a(`startup.tray.login`)}),(0,z.jsx)(`span`,{children:a(`startup.tray.notProtection`)})]}),t||n||!e?(0,z.jsx)(`span`,{className:`badge badge-amber`,children:a(t?`startup.tray.loading`:`startup.tray.unavailable`)}):(0,z.jsx)(Kd,{ok:e.running&&!e.stale,yes:a(`startup.tray.running`),no:a(e.stale?`startup.tray.stale`:e.installed?`startup.tray.stopped`:`startup.tray.notInstalled`)})]}),(0,z.jsxs)(`div`,{className:`startup-tray-buttons`,children:[!t&&!n&&e&&!e.installed&&!e.stale&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:r,onClick:()=>i(`install`),children:a(`startup.tray.install`)}),!t&&!n&&e?.installed&&!e.stale&&!e.running&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:r,onClick:()=>i(`start`),children:a(`startup.tray.start`)}),!t&&!n&&e?.running&&!e.stale&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:r,onClick:()=>i(`stop`),children:a(`startup.tray.stop`)}),!t&&!n&&e&&(e.installed||e.stale)&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-danger`,disabled:r,onClick:()=>{window.confirm(a(`startup.tray.uninstall`))&&i(`uninstall`)},children:a(`startup.tray.uninstall`)})]}),(n||e?.stale)&&(0,z.jsx)(`div`,{className:`notice notice-warn startup-tray-error`,role:`alert`,children:a(`startup.tray.error`)})]})}function Xd({data:e,copied:t,onCopy:n}){let{t:r}=Ve();return(0,z.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:r(`startup.recovery`)}),(0,z.jsx)(ne,{})]}),(0,z.jsx)(`p`,{className:`muted`,children:r(`startup.recoveryHint`)}),(0,z.jsxs)(`div`,{className:`startup-command-list`,children:[e.serviceSupported&&(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.service`)}),(0,z.jsx)(`code`,{children:e.commands.installService})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(e.commands.installService),children:t===e.commands.installService?r(`startup.copied`):r(`startup.copy`)})]}),(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.shim`)}),(0,z.jsx)(`code`,{children:e.commands.installShim})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(e.commands.installShim),children:t===e.commands.installShim?r(`startup.copied`):r(`startup.copy`)})]}),(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.native`)}),(0,z.jsx)(`code`,{children:e.commands.restoreNative})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(e.commands.restoreNative),children:t===e.commands.restoreNative?r(`startup.copied`):r(`startup.copy`)})]})]}),e.status===`at-risk`&&(0,z.jsxs)(`div`,{className:`notice notice-warn startup-action-notice`,role:`alert`,children:[(0,z.jsx)(ye,{}),` `,r(`startup.recommended`,{cmd:e.recommendedCommand??e.commands.installService})]})]})}var Zd=`ocx.startup.page.v1:`;function Qd(e,t){let n=t===`win32`?`; `:` && `;return e.join(n)}function $d(e,t,n){if(!e)return{warning:null,fix:null};let r=!!e.catalogClamp?.active,i=!!e.newerAvailable,a=(r?e.catalogClamp?.runtimeVersion:e.version)??e.version??`unknown`,o=(e.catalogClamp?.removedEfforts??[]).join(`, `),s=Qd([`ocx doctor --fix-codex-runtime`,`ocx sync`],n);return r?{warning:o?t(`startup.codexRuntime.clampHiddenWithEfforts`,{version:a,efforts:o}):t(`startup.codexRuntime.clampHidden`,{version:a}),fix:i?s:`ocx sync`}:i?{warning:t(`startup.codexRuntime.olderBinary`,{version:a}),fix:s}:{warning:null,fix:null}}function ef({apiBase:e}){let{t}=Ve(),n=`${Zd}${e}`,r=(0,_.useMemo)(()=>Y(n),[n]),i=`startup-page:${e}`,[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(()=>r?.tray??null),[l,u]=(0,_.useState)(()=>!r?.data),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(()=>r?.warning??null),[S,C]=(0,_.useState)(()=>r?.fix??null),[w,T]=(0,_.useState)(()=>!r?.data),E=(0,_.useRef)(!!r?.data),D=(0,_.useCallback)(async r=>{let i=E.current;i||(u(!0),T(!0));try{let i=fetch(`${e}/api/settings`,{signal:r}).then(async e=>e.ok?await e.json():null).catch(()=>null),a=await fetch(`${e}/api/startup-health`,{signal:r});if(!a.ok)throw Error(`fetch failed`);let o=await a.json();E.current=!0;let s=Y(n);X(n,{data:o,warning:s?.warning??null,fix:s?.fix??null,tray:s?.tray??null});let l=o.platform===`win32`?fetch(`${e}/api/windows-tray`,{signal:r}).then(async e=>{if(!e.ok)throw Error(`tray status failed`);let t=await e.json();if(!Hd(t))throw Error(`invalid tray status`);return{tray:t,error:!1}}).catch(()=>({tray:null,error:!0})):Promise.resolve({tray:null,error:!1});return Promise.all([i,l]).then(([e,i])=>{if(r.aborted)return;let a=o.platform===`win32`?i.tray:null;if(o.platform===`win32`?(c(a),m(i.error)):(c(null),m(!1)),u(!1),T(!1),e){let r=$d(e.codexRuntime,t,o.platform);x(r.warning),C(r.fix),X(n,{data:o,warning:r.warning,fix:r.fix,tray:a});return}let s=Y(n);X(n,{data:o,warning:s?.warning??null,fix:s?.fix??null,tray:a})}),o}catch(e){throw r.aborted?e:(i||(c(null),m(!0),x(null),C(null)),T(!1),u(!1),e)}},[e,n,t]),O=us(i,[e],D,{isEmpty:()=>!1,initialData:r?.data??void 0}),k=O.state,A=O.refresh,j=k.data??r?.data??null,M=k.refreshing,N=!!j?.diagnosticStale||k.showError;(0,_.useEffect)(()=>{if(!j?.diagnosticStale)return;let e=window.setTimeout(A,2e3);return()=>window.clearTimeout(e)},[j,A]);let P=async e=>{try{await navigator.clipboard.writeText(e),o(e),window.setTimeout(()=>o(t=>t===e?null:t),1600)}catch{o(null)}},F=async t=>{f(!0),m(!1);try{let n=await fetch(`${e}/api/windows-tray`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t})});if(!n.ok)throw Error(`tray action failed`);let r=await n.json();if(!Hd(r.status))throw Error(`invalid tray action status`);c(r.status),m(!1)}catch{c(null),m(!0)}finally{f(!1)}},I=async(t,n)=>{g(t),y(null);try{let r=await fetch(`${e}/api/startup-action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t,repair:n?.repair===!0})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(typeof e?.error==`string`?e.error:`installation failed`)}y({kind:`success`,action:t,repair:n?.repair===!0}),A()}catch(e){y({kind:`error`,action:t,repair:n?.repair===!0,detail:e instanceof Error?e.message:String(e)})}finally{g(null)}};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`page-head`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{children:t(`startup.title`)}),(0,z.jsx)(`p`,{className:`page-sub startup-page-sub`,children:t(`startup.subtitle`)})]}),(0,z.jsxs)(`div`,{className:`startup-page-head-actions`,children:[(0,z.jsx)(`a`,{className:`btn btn-ghost btn-sm`,href:`#dashboard`,children:t(`startup.backToDashboard`)}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>A(),disabled:M,children:[(0,z.jsx)(se,{}),` `,t(`startup.refresh`)]})]})]}),k.showSkeleton&&!j?(0,z.jsx)(fs,{label:t(`startup.loading`),rows:5}):k.kind===`failed-cold`?(0,z.jsxs)(`div`,{className:`startup-page-notice`,children:[(0,z.jsx)(q,{tone:`err`,children:k.error instanceof Error?k.error.message:t(`startup.error`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>A(),children:t(`common.retry`)})]}):j?(0,z.jsxs)(z.Fragment,{children:[k.showError&&(0,z.jsx)(q,{tone:`err`,children:t(`startup.error`)}),N&&(0,z.jsx)(`div`,{className:`notice notice-warn startup-page-notice`,role:`alert`,children:t(`startup.staleData`)}),(w||b)&&(0,z.jsx)(`div`,{className:`startup-runtime-notice-slot${w&&!b?` startup-runtime-notice-slot--pending`:``}`,"aria-hidden":w&&!b?!0:void 0,children:b&&(0,z.jsxs)(`div`,{className:`notice notice-warn startup-page-notice startup-runtime-notice`,role:`status`,children:[(0,z.jsx)(`p`,{className:`startup-runtime-notice__text`,children:b}),S&&(0,z.jsxs)(`div`,{className:`startup-runtime-notice__fix`,children:[(0,z.jsx)(`code`,{children:S}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void P(S),children:t(a===S?`startup.copied`:`startup.copy`)})]})]})}),(0,z.jsx)(qd,{failed:N,data:j}),(0,z.jsx)(Jd,{data:j,failed:N,loading:M,installBusy:h,installResult:v,onInstall:(e,t)=>{I(e,t)}}),j.platform===`win32`&&(0,z.jsx)(Yd,{tray:s,trayLoading:l,trayError:p,trayBusy:d,onTrayAction:e=>{F(e)}}),(0,z.jsx)(Xd,{data:j,copied:a,onCopy:e=>{P(e)}})]}):null]})}var tf=class extends _.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}reload=()=>{this.setState({error:null})};render(){return this.state.error?(0,z.jsxs)(`section`,{className:`card`,role:`alert`,style:{maxWidth:720,padding:`var(--space-6)`},children:[(0,z.jsxs)(`h2`,{style:{margin:`0 0 var(--space-2)`,fontSize:`var(--text-title)`},children:[this.props.pageName,`: `,this.props.title]}),(0,z.jsx)(`p`,{className:`muted`,style:{margin:`0 0 var(--space-4)`},children:this.props.message}),(0,z.jsxs)(`p`,{style:{margin:`0 0 var(--space-5)`,overflowWrap:`anywhere`},children:[(0,z.jsxs)(`strong`,{children:[this.props.detailsLabel,`:`]}),` `,this.state.error.message]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:this.reload,children:this.props.reloadLabel})]}):this.props.children}},nf=5*6e4,rf=10*6e4,af=`https://github.com/lidge-jun/opencodex`;async function of(e,t){let n=await fetch(e,{signal:t});return n.ok?await n.json():null}function sf({apiBase:e,onOpenUpdate:t}){let n=K(),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(null),s=I(`sidebar-star:${e}`,[e],t=>of(`${e}/api/github/star`,t),{pollMs:nf}),c=I(`sidebar-update-badge:${e}`,[e],t=>of(`${e}/api/update/badge`,t),{pollMs:rf}),l=s.data?.state??null,u=a!==null&&a.basedOn===l?a.state:l??`not-starred`,d=s.data?.url??af,f=u===`starred`,p=c.data,m=p?.updateAvailable===!0,h=p?.latestVersion??null,g=()=>window.open(d,`_blank`,`noopener,noreferrer`),v=async()=>{if(!(f||r)){if(u===`unauthenticated`){g();return}i(!0);try{let t=await fetch(`${e}/api/github/star`,{method:`POST`}),n=t.ok?await t.json():null;if(n?.ok===!0){o({state:`starred`,basedOn:l});return}n?.state&&o({state:n.state,basedOn:l}),g()}catch{g()}finally{i(!1),s.refresh()}}},y=n(f?`sidebar.starred`:u===`unauthenticated`?`sidebar.starUnauthenticated`:`sidebar.star`),b=m&&h?n(`sidebar.updateAvailable`,{version:h}):n(`sidebar.checkUpdate`);return(0,z.jsxs)(`div`,{className:`sidebar-github-row`,children:[(0,z.jsxs)(`a`,{className:`sidebar-link sidebar-github-link`,href:d,target:`_blank`,rel:`noreferrer`,children:[(0,z.jsx)(ve,{}),` `,n(`common.github`)]}),(0,z.jsxs)(`div`,{className:`sidebar-github-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`sidebar-orb${f?` sidebar-orb--starred`:``}`,onClick:()=>{v()},disabled:r||f,"aria-label":y,"aria-pressed":f,title:y,children:(0,z.jsx)(Me,{"aria-hidden":`true`,...f?{fill:`currentColor`}:{}})}),(0,z.jsxs)(`button`,{type:`button`,className:`sidebar-orb${m?` sidebar-orb--update`:``}`,onClick:t,"aria-label":b,title:b,children:[(0,z.jsx)(ge,{"aria-hidden":`true`}),m&&(0,z.jsx)(`span`,{className:`sidebar-orb-dot`,"aria-hidden":`true`})]})]})]})}var cf=!1,lf=null,uf=null,df=!1,ff=`/`;function pf(e){try{let t=e instanceof Request?e.url:String(e),n=new URL(t,window.location.href);return n.origin===window.location.origin?n.pathname.startsWith(`/api/`):!1}catch{return!1}}var mf=`opencodex-api-token`,hf=null,gf=null,_f=null;function vf(){return hf}function yf(e){hf=e}function bf(){hf=null,gf=null,_f=null}function xf(e){let t=document.querySelector(`meta[name="${e}"]`),n=t?.content.trim()||null;return t?.remove(),n}function Sf(){wf(xf(`opencodex-session-token`),xf(`opencodex-session-csrf`),xf(`opencodex-session-origin`))}function Cf(e){e!=null&&vf()===e&&bf()}function wf(e,t,n){return!e?.startsWith(`ocx_session_`)||!t||n!==window.location.origin?!1:(hf=e,gf=t,_f=n,!0)}function Tf(e,t){for(let n of e.match(/<meta\b[^>]*>/gi)??[])if(n.match(/\bname="([^"]+)"/i)?.[1]===t)return n.match(/\bcontent="([^"]*)"/i)?.[1]?.trim()||null;return null}async function Ef(){if(!uf)return null;try{let e=await uf(ff,{cache:`no-store`});if(!e.ok)return null;let t=await e.text();return wf(Tf(t,`opencodex-session-token`),Tf(t,`opencodex-session-csrf`),Tf(t,`opencodex-session-origin`))?vf():null}catch{return null}}function Df(){try{sessionStorage.removeItem(mf)}catch{}}function Of(e,t,n){let r=new Headers(t?.headers??(e instanceof Request?e.headers:void 0));if(r.set(`X-OpenCodex-API-Key`,n),_f&&gf&&n.startsWith(`ocx_session_`)){r.set(`X-OpenCodex-GUI-Origin`,_f);let n=(t?.method??(e instanceof Request?e.method:`GET`)).toUpperCase();n!==`GET`&&n!==`HEAD`&&r.set(`X-OpenCodex-CSRF-Token`,gf)}return e instanceof Request?[new Request(e,{headers:r}),t?{...t,headers:r}:void 0]:[e,{...t,headers:r}]}async function kf(e){return df?null:lf||(lf=(async()=>{if(df)return null;let t=vf();if(t&&t!==e)return t;let n=await Ef();if(n)return n;let r=window.prompt(`OpenCodex admin token (OPENCODEX_ADMIN_AUTH_TOKEN)`)?.trim()||null;return r?(yf(r),r):(df=!0,null)})().finally(()=>{lf=null}),lf)}function Af(){if(cf)return;cf=!0,Df(),Sf();let e=window.fetch.bind(window);uf=e,window.fetch=async(t,n)=>{if(!pf(t))return e(t,n);let r=vf(),[i,a]=r?Of(t,n,r):[t,n],o=await e(i,a);if(o.status!==401)return o;let s=vf();if(s&&s!==r){let[r,i]=Of(t,n,s),a=await e(r,i);if(a.status!==401)return a;Cf(s)}else Cf(r);let c=await kf(r);if(!c)return o;let[l,u]=Of(t,n,c),d=await e(l,u);return d.status===401&&Cf(c),d}}var jf=new Set([`dashboard`,`startup`,`providers`,`models`,`combos`,`subagents`,`logs`,`usage`,`storage`,`codex-auth`,`api`,`claude`,`grok`]);function Mf(e){let t=We(e??(typeof window<`u`?window.location.hash:``)).split(`/`)[0];return t===`debug`?`logs`:jf.has(t)?t:`dashboard`}var Nf=[`dashboard/providers`,`dashboard/models`];function Pf(e,t){return e===t||t===`logs`&&e===`logs/debug`||t===`dashboard`&&(e===`dashboard/update`||Nf.includes(e))}function Ff(e){let t=Mf(e);return e===`debug`||e.startsWith(`debug/`)?{page:`logs`,replaceTo:`logs/debug`}:e===`providers/workspace`?{page:`providers`,replaceTo:`providers`}:Pf(e,t)?{page:t,replaceTo:null}:{page:t,replaceTo:t}}var If=[`ocx-global-view`,`ocx-view`,`ocx-providers-view`,`ocx-subagents-view`,`ocx-storage-view`,`ocx-codexauth-view`,`ocx-apikeys-view`,`ocx-claudecode-view`,`ocx-usage-view`,`ocx-logs-view`,`ocx-models-view`,`ocx-dashboard-view`];function Lf(){try{for(let e of If)localStorage.removeItem(e)}catch{}}function Rf(){let[e,t]=(0,_.useState)(Mf);(0,_.useEffect)(()=>{Lf()},[]);let n=(0,_.useCallback)(e=>{let n=Ff(e);n.replaceTo&&Ge(n.replaceTo),t(n.page)},[]);return(0,_.useEffect)(()=>{let e=()=>{n(We(window.location.hash))};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[n]),(0,_.useEffect)(()=>{let t=We(window.location.hash);if(t===`debug`||t.startsWith(`debug/`)){Ge(`logs/debug`);return}if(t===`providers/workspace`){Ge(`providers`);return}Pf(t,e)||Ge(e)},[e]),{page:e,setPageState:t,navigateToPage:(e,n)=>{Ke(n?`${e}/${n}`:e),t(e)}}}var zf=15e3;function Bf(e,t,n){return typeof e?.message==`string`&&e.message.trim()?e.message:typeof e?.error==`string`&&e.error.trim()?e.error:n(t)}function Vf(e){return(e instanceof DOMException||e instanceof Error)&&e.name===`AbortError`}async function Hf(e,t={}){let{fetchFn:n=fetch,timeoutMs:r=zf,formatFailure:i=e=>`Failed to stop proxy (HTTP ${e}).`}=t,a;try{a=await n(`${e}/api/stop`,{method:`POST`,signal:AbortSignal.timeout(r)})}catch(e){return Vf(e),{accepted:!0}}let o=await a.json().catch(()=>null);return!a.ok||o?.success===!1?{accepted:!1,message:Bf(o,a.status,i)}:{accepted:!0}}Af();var Uf={dashboard:`nav.dashboard`,startup:`nav.startup`,providers:`nav.providers`,models:`nav.models`,combos:`nav.combos`,subagents:`nav.subagents`,logs:`nav.logs`,usage:`nav.usage`,storage:`nav.storage`,"codex-auth":`nav.codexAuth`,api:`nav.api`,claude:`nav.claude`,grok:`nav.grok`},Wf=``,Gf=`ocx-theme`,Kf=[{id:`dashboard`,tkey:`nav.dashboard`,Icon:V},{id:`codex-auth`,tkey:`nav.codexAuth`,Icon:xe},{id:`providers`,tkey:`nav.providers`,Icon:H},{id:`models`,tkey:`nav.models`,Icon:U},{id:`subagents`,tkey:`nav.subagents`,Icon:W},{id:`logs`,tkey:`nav.logs`,Icon:ee},{id:`usage`,tkey:`nav.usage`,Icon:re},{id:`storage`,tkey:`nav.storage`,Icon:G},{id:`api`,tkey:`nav.api`,Icon:Oe},{id:`claude`,tkey:`nav.claude`,Icon:ke},{id:`grok`,tkey:`nav.grok`,Icon:U}],qf={light:Te,dark:Ee,system:De},Jf={light:`theme.light`,dark:`theme.dark`,system:`theme.system`};function Yf(e){if(!e||typeof e!=`object`||!(`version`in e))return null;let t=e.version;return typeof t==`string`&&t.length>0?t:null}function Xf(){let e=localStorage.getItem(Gf);return e===`light`||e===`dark`?e:`system`}function Zf(){let{page:e,navigateToPage:t}=Rf(),[n,r]=(0,_.useState)(Xf),{locale:i,setLocale:a}=Ve(),o=K(),[s,c]=(0,_.useState)(!1),l=(0,_.useRef)(null),u=(0,_.useRef)(null),d=(0,_.useRef)(!1);(0,_.useEffect)(()=>{let e=()=>c(!1);return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]),(0,_.useEffect)(()=>{let e=document.documentElement;n===`system`?(e.removeAttribute(`data-theme`),localStorage.removeItem(Gf)):(e.setAttribute(`data-theme`,n),localStorage.setItem(Gf,n))},[n]);let f=I(`app-healthz:${Wf}`,[],async e=>{let t=await fetch(`${Wf}/healthz`,{signal:e});return t.ok?Yf(await t.json()):null},{pollMs:3e4}),p=()=>r(e=>e===`light`?`dark`:e===`dark`?`system`:`light`),m=qf[n],h=f.data??`2.8.0-cs.7`,[g,v]=(0,_.useState)(!1),y=(0,_.useCallback)(async e=>{let t=await ut(await fetch(`${Wf}/api/claude-code`,{signal:e}));return t&&typeof t.enabled==`boolean`?t.enabled:null},[]),b=I(`app-claude-code:${Wf}`,[],y).data??null,x=(0,_.useRef)(!1),[S,C]=(0,_.useState)(!1);(0,_.useEffect)(()=>{if(!s)return;let e=e=>{e.key===`Escape`&&c(!1)};window.addEventListener(`keydown`,e);let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{window.removeEventListener(`keydown`,e),document.body.style.overflow=t}},[s]),(0,_.useEffect)(()=>{if(s){d.current=!0;let e=setTimeout(()=>u.current?.focus(),200);return()=>clearTimeout(e)}d.current&&(d.current=!1,l.current?.focus())},[s]),(0,_.useEffect)(()=>{let e=window.matchMedia(`(min-width: 761px)`),t=()=>{e.matches&&c(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let w=async()=>{if(b===null||x.current)return;x.current=!0,C(!0);let e=!b;L(`app-claude-code:${Wf}`,e);try{(await fetch(`${Wf}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})})).ok||L(`app-claude-code:${Wf}`,!e)}catch{L(`app-claude-code:${Wf}`,!e)}finally{x.current=!1,C(!1)}},T=async()=>{if(!confirm(o(`dash.stopConfirm`)))return;v(!0);let e=await Hf(Wf,{formatFailure:e=>o(`dash.stopFailed`,{status:String(e)})});e.accepted||(v(!1),alert(e.message))},E=(0,z.jsxs)(`div`,{className:`brand`,children:[(0,z.jsx)(`span`,{className:`brand-logo`,role:`img`,"aria-label":o(`app.logoAria`)}),(0,z.jsx)(`span`,{className:`name`,children:`opencodex`}),(0,z.jsxs)(`span`,{className:`ver`,children:[`v`,h]})]});return(0,z.jsxs)(`div`,{className:`app`,children:[(0,z.jsxs)(`header`,{className:`mobile-topbar`,inert:s,children:[(0,z.jsx)(`button`,{ref:l,type:`button`,className:`menu-toggle`,onClick:()=>c(e=>!e),"aria-expanded":s,"aria-controls":`app-sidebar`,"aria-label":o(s?`nav.closeMenu`:`nav.openMenu`),title:o(s?`nav.closeMenu`:`nav.openMenu`),children:(0,z.jsx)(te,{})}),E,(0,z.jsx)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:T,disabled:g,"aria-label":o(`dash.stop`),title:o(`dash.stop`),children:(0,z.jsx)(ye,{})})]}),s&&(0,z.jsx)(`div`,{className:`drawer-scrim`,onClick:()=>c(!1),"aria-hidden":`true`}),(0,z.jsxs)(`aside`,{id:`app-sidebar`,className:`sidebar${s?` open`:``}`,ref:u,tabIndex:-1,children:[(0,z.jsxs)(`div`,{className:`drawer-head`,children:[E,(0,z.jsx)(`button`,{type:`button`,className:`menu-toggle drawer-close`,onClick:()=>c(!1),"aria-label":o(`nav.closeMenu`),title:o(`nav.closeMenu`),children:(0,z.jsx)(ae,{})})]}),(0,z.jsx)(`nav`,{children:Kf.map(({id:n,tkey:r,Icon:i})=>(0,z.jsxs)(`div`,{className:`nav-entry${n===`claude`?` nav-entry-claude${e===n?` active`:``}`:``}`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`nav-item${e===n?` active`:``}`,"data-page":n,onClick:()=>{t(n),c(!1)},"aria-current":e===n?`page`:void 0,children:[(0,z.jsx)(i,{}),` `,o(r)]}),n===`claude`&&b!==null&&(0,z.jsx)(it,{on:b,onClick:()=>void w(),disabled:S,label:o(`claude.toggleAria`)})]},n))}),(0,z.jsxs)(`div`,{className:`sidebar-foot`,children:[(0,z.jsxs)(`div`,{className:`lang-toggle`,children:[(0,z.jsx)(Oe,{"aria-hidden":!0}),(0,z.jsx)(at,{value:i,options:Ie.map(e=>({value:e.code,label:e.name})),onChange:e=>a(e),label:o(`lang.label`),placement:`right`,portal:!1,style:{flex:1,minWidth:0,width:`100%`}})]}),(0,z.jsxs)(`button`,{type:`button`,className:`theme-toggle`,onClick:p,"aria-label":`${o(`theme.label`)}: ${o(Jf[n])}`,title:`${o(`theme.label`)}: ${o(Jf[n])}`,children:[(0,z.jsx)(m,{}),` `,(0,z.jsx)(`span`,{className:`mode`,children:o(Jf[n])})]}),(0,z.jsxs)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:T,disabled:g,"aria-label":o(`dash.stop`),title:o(`dash.stop`),children:[(0,z.jsx)(ye,{}),` `,(0,z.jsx)(`span`,{className:`mode`,children:o(g?`dash.stopping`:`dash.stop`)})]}),(0,z.jsx)(sf,{apiBase:Wf,onOpenUpdate:()=>{c(!1),t(`dashboard`,`update`)}})]})]}),(0,z.jsx)(`main`,{className:`main`,inert:s,children:(0,z.jsx)(`div`,{className:`main-inner${e===`combos`?` main-inner--combos`:``}`,children:(0,z.jsxs)(tf,{pageName:o(Uf[e]),title:o(`errorBoundary.title`),message:o(`errorBoundary.message`),detailsLabel:o(`errorBoundary.details`),reloadLabel:o(`errorBoundary.reload`),children:[e===`dashboard`&&(0,z.jsx)(Fn,{apiBase:Wf}),e===`startup`&&(0,z.jsx)(ef,{apiBase:Wf}),e===`providers`&&(0,z.jsx)(Po,{apiBase:Wf}),e===`models`&&(0,z.jsx)(Bs,{apiBase:Wf}),e===`combos`&&(0,z.jsx)(ic,{apiBase:Wf},Wf),e===`subagents`&&(0,z.jsx)(mc,{apiBase:Wf},Wf),e===`logs`&&(0,z.jsx)(Nl,{apiBase:Wf}),e===`usage`&&(0,z.jsx)(eu,{apiBase:Wf}),e===`storage`&&(0,z.jsx)(_u,{apiBase:Wf}),e===`codex-auth`&&(0,z.jsx)(xu,{apiBase:Wf}),e===`api`&&(0,z.jsx)(Zu,{apiBase:Wf}),e===`claude`&&(0,z.jsx)(Fd,{apiBase:Wf}),e===`grok`&&(0,z.jsx)(Vd,{apiBase:Wf})]},e)})})]})}g.createRoot(document.getElementById(`root`)).render((0,z.jsx)(_.StrictMode,{children:(0,z.jsx)(He,{children:(0,z.jsx)(Zf,{})})}));
67
+ `)}function nd(e){return e?e.backend??`auto`:`inherit`}function rd(e,t){if(t!==`inherit`)return t===`auto`?{...e,backend:void 0}:{...e,backend:t}}function id(e,t){return{...e,model:t}}function ad(e){if(!e)return null;let t=(e.model??``).trim();return e.backend?{backend:e.backend,model:t}:t?{backend:null,model:t}:null}function od({label:e,checked:t,onChange:n,disabled:r=!1,describedBy:i}){return(0,z.jsxs)(`label`,{className:`toggle`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:t,disabled:r,"aria-label":e,"aria-describedby":i,onChange:e=>n(e.target.checked)}),(0,z.jsx)(`span`,{className:`slider`,"aria-hidden":`true`})]})}function sd({supported:e,checked:t,onChange:n}){let r=K(),i=e?void 0:`claude-system-env-unsupported`;return(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:r(`claude.systemEnv`)}),e?(0,z.jsx)(`span`,{className:`desc`,children:r(`claude.systemEnvDesc`)}):(0,z.jsx)(`span`,{className:`desc`,id:i,children:(0,z.jsx)(Ue,{k:`claude.systemEnvUnsupported`,cmd:`ocx claude`})}),e&&t&&(0,z.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:r(`claude.systemEnvWarn`)})]}),(0,z.jsx)(od,{label:r(`claude.systemEnv`),checked:e&&t,disabled:!e,describedBy:i,onChange:n})]})}function cd({value:e,tierHaikuModel:t,options:n,onChange:r}){let i=K(),a=t??e;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:i(`claude.smallFastModelAccurateHint`)}),(0,z.jsx)(at,{value:e,options:n,onChange:r,label:i(`claude.smallFastModel`),style:{maxWidth:420}}),a===``&&(0,z.jsx)(`p`,{className:`notice-warn`,role:`status`,style:{marginTop:8},children:i(`claude.smallFastModelNativeWarning`)})]})}function ld(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)try{return crypto.randomUUID()}catch{}let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<16;t++)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function ud(e,t=`en`){if(e>=1e6){let n=e/1e6,r=n.toFixed(1).replace(/\.0$/,``);return Number.isInteger(n)||Number(r)*1e6===e?new Intl.NumberFormat(t,{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:+!Number.isInteger(n)}).format(e):`${Math.round(e/1e3)}k`}return`${Math.round(e/1e3)}k`}function dd(e,t){return e&&[`claude-json-oauth`,`claude-credentials-file`,`macos-keychain`,`exported-env`].includes(e)?t(`claude.authSource.${e}`):t(`claude.authSource.unknown`)}function fd({state:e,autoCompactOptions:t,availableModels:n,onStateChange:r}){let i=K();return(0,z.jsxs)(`div`,{className:`card`,style:{overflow:`hidden`},children:[(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.enabledLabel`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.enabledHint`)})]}),(0,z.jsx)(od,{label:i(`claude.enabledLabel`),checked:e.enabled,onChange:t=>r({...e,enabled:t})})]}),(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.authMode`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.authModeHint`)})]}),(0,z.jsx)(`div`,{className:`setting-controls`,children:(0,z.jsx)(at,{value:e.authMode,options:[{value:`auto`,label:i(`claude.authModeAuto`)},{value:`subscription`,label:i(`claude.authModeSubscription`)},{value:`proxy`,label:i(`claude.authModeProxy`)}],onChange:t=>r({...e,authMode:t}),label:i(`claude.authMode`),style:{minWidth:220},align:`right`,portal:!0})})]}),e.authModeOrigin&&(0,z.jsxs)(`div`,{className:`claude-effective-auth${e.authModeOrigin===`auto-unknown`?` warn`:``}`,role:`status`,children:[(0,z.jsx)(`span`,{className:`claude-effective-auth-label`,children:i(`claude.effectiveMode.label`)}),(0,z.jsxs)(`span`,{children:[e.authModeOrigin===`manual`?i(`claude.effectiveMode.manual`,{mode:e.markerMode===`proxy`?i(`claude.authModeProxy`):i(`claude.authModeSubscription`)}):e.authModeOrigin===`auto-present`?i(`claude.effectiveMode.autoPresent`,{source:dd(e.authFoundBy,i)}):e.authModeOrigin===`auto-absent`?i(`claude.effectiveMode.autoAbsent`):i(`claude.effectiveMode.autoUnknown`),e.admissionKeyActive===!0?` ${i(`claude.effectiveMode.admissionKey`)}`:``]})]}),(0,z.jsx)(sd,{supported:e.autoConnectSupported,checked:e.systemEnv,onChange:t=>r({...e,systemEnv:t})}),(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.fastMode`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.fastModeDesc`)})]}),(0,z.jsx)(`div`,{className:`setting-controls`,children:(0,z.jsx)(at,{value:e.fastMode===null?`auto`:e.fastMode?`on`:`off`,options:[{value:`auto`,label:i(`claude.fastAuto`)},{value:`on`,label:i(`claude.fastOn`)},{value:`off`,label:i(`claude.fastOff`)}],onChange:t=>r({...e,fastMode:t===`auto`?null:t===`on`}),label:i(`claude.fastMode`),style:{minWidth:140},align:`right`,portal:!0})})]}),(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.autoContext`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.autoContextDesc`)}),e.maxContextTokens!==null&&(0,z.jsx)(`span`,{className:`desc`,style:{color:`var(--muted)`},children:i(`claude.autoContextInert`)})]}),(0,z.jsx)(od,{label:i(`claude.autoContext`),checked:e.autoContext,onChange:t=>r({...e,autoContext:t})})]}),e.autoContext&&(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.autoCompactWindow`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.autoCompactWindowDesc`)}),e.autoCompactWindow!==null&&(0,z.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:i(`claude.autoCompactWindowWarn`)})]}),(0,z.jsx)(`div`,{className:`setting-controls`,children:(0,z.jsx)(at,{value:e.autoCompactWindow===null?``:String(e.autoCompactWindow),options:t,onChange:t=>r({...e,autoCompactWindow:t===``?null:Number(t)}),label:i(`claude.autoCompactWindow`),style:{minWidth:130},align:`right`,portal:!0})})]}),(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.injectAgents`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.injectAgentsDesc`)})]}),(0,z.jsx)(od,{label:i(`claude.injectAgents`),checked:e.injectAgents,onChange:t=>r({...e,injectAgents:t})})]}),[`webSearchSidecar`,`visionSidecar`].map(t=>{let a=e[t],o=t===`webSearchSidecar`?`claude.webSearchSidecar`:`claude.visionSidecar`,s=t===`webSearchSidecar`?`claude.webSearchSidecarHint`:`claude.visionSidecarHint`,c=`claude-sidecar-models-${t}`;return(0,z.jsxs)(`div`,{className:`setting-row`,style:{alignItems:`flex-start`},children:[(0,z.jsxs)(`div`,{className:`setting-label setting-copy`,style:{flex:1},children:[(0,z.jsx)(`span`,{className:`title`,children:i(o)}),(0,z.jsx)(`span`,{className:`desc`,children:i(s)})]}),(0,z.jsxs)(`div`,{className:`setting-controls`,style:{display:`flex`,gap:8},children:[(0,z.jsx)(at,{value:nd(a),options:[{value:`inherit`,label:i(`claude.useMainSetting`)},{value:`auto`,label:i(`dash.backendAuto`)},{value:`openai`,label:i(`dash.backendOpenAI`)},{value:`anthropic`,label:i(`dash.backendAnthropic`)}],onChange:n=>{r({...e,[t]:rd(a,n)})},label:i(`dash.sidecarBackend`),portal:!0}),(0,z.jsx)(`input`,{className:`input mono`,value:a?.model??``,onChange:n=>{r({...e,[t]:id(a,n.target.value)})},placeholder:i(`claude.sidecarModelPlaceholder`),disabled:!a,list:a?c:void 0,"aria-label":i(`dash.sidecarModel`),style:{minWidth:210},autoComplete:`off`}),a&&(0,z.jsx)(`datalist`,{id:c,children:n.map(e=>(0,z.jsx)(`option`,{value:e},e))})]})]},t)})]})}function pd({manualEnv:e}){let t=K();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:(0,z.jsx)(Ue,{k:`claude.quickstartHint`,cmd:`ocx claude`})}),(0,z.jsx)(`pre`,{className:`mono card`,style:{padding:`10px 14px`,overflowX:`auto`,margin:0},children:`ocx claude`}),(0,z.jsxs)(`details`,{style:{margin:`10px 0 0`},children:[(0,z.jsx)(`summary`,{className:`muted text-label`,style:{cursor:`pointer`,padding:`2px 2px`},children:t(`claude.manualEnv`)}),(0,z.jsx)(`pre`,{className:`mono card text-label`,style:{padding:`10px 14px`,overflowX:`auto`,margin:`6px 0 0`},children:e})]})]})}function md({rows:e,onRowsChange:t}){let n=K();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:n(`claude.modelMapHint`)}),(0,z.jsx)(`div`,{className:`stack`,style:{gap:8},children:e.map((r,i)=>(0,z.jsxs)(`div`,{className:`row`,style:{gap:8},children:[(0,z.jsx)(`input`,{className:`input mono`,value:r.from,placeholder:n(`claude.mapFrom`),"aria-label":n(`claude.mapFrom`),onChange:n=>t(e.map((e,t)=>t===i?{...e,from:n.target.value}:e)),style:{flex:1}}),(0,z.jsx)(`span`,{className:`muted`,"aria-hidden":!0,children:`→`}),(0,z.jsx)(`input`,{className:`input mono`,value:r.to,placeholder:n(`claude.mapTo`),"aria-label":n(`claude.mapTo`),onChange:n=>t(e.map((e,t)=>t===i?{...e,to:n.target.value}:e)),style:{flex:1}}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>t(e.filter((e,t)=>t!==i)),"aria-label":n(`claude.removeMapping`),style:{color:`var(--red)`},children:(0,z.jsx)(ae,{})})]},r.id))}),(0,z.jsx)(`div`,{style:{marginTop:8},children:(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>t([...e,{id:ld(),from:``,to:``}]),children:[(0,z.jsx)(oe,{}),` `,n(`claude.addMapping`)]})})]})}var hd=`etc`;function gd(e){let t=new Map;for(let n of e){let e=/\(([^)]+)\)\s*$/.exec(n.display_name),r=e?e[1]:hd,i=t.get(r);i?i.push(n):t.set(r,[n])}return Array.from(t)}function _d({aliases:e}){let t=K();return(0,z.jsxs)(`div`,{className:`claude-aliases`,children:[(0,z.jsx)(`p`,{className:`muted text-label claude-aliases-hint`,children:t(`claude.aliasesHint`)}),e.length===0?(0,z.jsx)(`div`,{className:`muted text-label`,children:t(`claude.none`)}):(0,z.jsx)(`div`,{className:`claude-aliases-scroll`,children:gd(e).map(([e,n])=>(0,z.jsxs)(`div`,{className:`claude-aliases-group`,children:[(0,z.jsxs)(`div`,{className:`claude-aliases-group-label`,children:[e===hd?t(`claude.aliasProviderOther`):e,(0,z.jsx)(`span`,{className:`claude-aliases-group-count`,children:n.length})]}),(0,z.jsx)(`div`,{className:`claude-aliases-chips`,children:n.map(e=>(0,z.jsxs)(`span`,{className:`claude-aliases-chip`,children:[(0,z.jsx)(`code`,{className:`claude-aliases-chip-id`,children:e.id}),e.display_name?(0,z.jsx)(`span`,{className:`claude-aliases-chip-name`,children:e.display_name}):null]},e.id))})]},e))})]})}function vd({apiBase:e,active:t=!0}){let n=K(),{locale:r}=Ve(),i=Ie.find(e=>e.code===r)?.htmlLang??`en`,a=`ocx.claude-code.v1:${e}`,o=`claude-code:${e}`,s=(0,_.useMemo)(()=>Y(a),[a]),[c,l]=(0,_.useState)(()=>s?.state??null),[u,d]=(0,_.useState)(()=>s?.rows??[]),[f,p]=(0,_.useState)(!!s),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(`settings`),x=(0,_.useCallback)(async t=>{let r=await J(await fetch(`${e}/api/claude-code`,{signal:t}),n(`claude.loadFail`));if(!r)throw Error(n(`claude.loadFail`));let i={...r,authMode:r.authMode===`proxy`||r.authMode===`subscription`?r.authMode:`auto`,...$u(r),fastMode:r.fastMode??null,maxContextTokens:r.maxContextTokens??null,autoContext:r.autoContext!==!1,autoCompactWindow:r.autoCompactWindow??null,injectAgents:r.injectAgents!==!1,effectiveModelEnv:r.effectiveModelEnv??{}},o=Object.entries(r.modelMap??{}).map(([e,t])=>({id:ld(),from:e,to:String(t)})),s={state:i,rows:o};if(t.aborted)throw Error(`Claude Code request aborted`);return l(i),d(o),p(!0),X(a,s),s},[e,a,n]),S=us(o,[e],x,{isEmpty:()=>!1,enabled:t,initialData:s??void 0}),C=S.state,w=C.data??s,T=c??w?.state??null,E=f?u:w?.rows??u,D=(0,_.useMemo)(()=>Qu(T?.available,n(`claude.smallFastModelUnsetOption`)),[T?.available,n]),O=(0,_.useMemo)(()=>{let e=[1e5,2e5,25e4,3e5,35e4,4e5,5e5,6e5,75e4,9e5,1e6],t=T?.autoCompactWindow??null,r=t!==null&&!e.includes(t)?[...e,t].sort((e,t)=>e-t):e;return[{value:``,label:n(`claude.autoCompactDefault`)},...r.map(e=>({value:String(e),label:ud(e,i)}))]},[T?.autoCompactWindow,n,i]),k=async()=>{if(!T)return;h(``);let t={};for(let e of E)e.from.trim()&&e.to.trim()&&(t[e.from.trim()]=e.to.trim());try{await J(await fetch(`${e}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:T.enabled,authMode:T.authMode,systemEnv:T.systemEnv,fastMode:T.fastMode,autoContext:T.autoContext,autoCompactWindow:T.autoCompactWindow,injectAgents:T.injectAgents,smallFastModel:T.smallFastModel,modelMap:t,webSearchSidecar:ad(T.webSearchSidecar),visionSidecar:ad(T.visionSidecar)})}),n(`claude.saveFailed`)),v(!0),h(n(`claude.saved`)),S.refresh()}catch(e){v(!1),h(e instanceof Error&&e.message?e.message:n(`claude.networkError`))}};if(C.kind===`disabled`&&!w)return null;if(C.showSkeleton&&!w)return(0,z.jsx)(fs,{label:n(`claude.loading`),rows:3});if(C.kind===`failed-cold`)return(0,z.jsxs)(`div`,{className:`claudecode-workspace-shell`,children:[(0,z.jsx)(q,{tone:`err`,children:C.error instanceof Error?C.error.message:n(`claude.loadFail`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>S.refresh(),children:n(`common.retry`)})]});if(!T)return null;let A=[{id:`settings`,label:n(`claude.workspace.settings`),body:(0,z.jsx)(fd,{state:T,autoCompactOptions:O,availableModels:T.available??[],onStateChange:l})},{id:`quickstart`,label:n(`claude.quickstart`),body:(0,z.jsx)(pd,{manualEnv:td(T)})},{id:`smallFast`,label:n(`claude.smallFastModel`),body:(0,z.jsx)(cd,{value:T.smallFastModel,tierHaikuModel:T.tierModels?.haiku,options:D,onChange:e=>l({...T,smallFastModel:e})})},{id:`modelMap`,label:n(`claude.modelMap`),meta:String(E.length),body:(0,z.jsx)(md,{rows:E,onRowsChange:e=>{p(!0),d(e)}})},{id:`aliases`,label:n(`claude.aliases`),meta:String(T.aliases.length),body:(0,z.jsx)(_d,{aliases:T.aliases})}],j=A.find(e=>e.id===y)??A[0],M=y===`settings`||y===`smallFast`||y===`modelMap`;return(0,z.jsxs)(`div`,{className:`claudecode-workspace-shell`,children:[m&&(0,z.jsx)(q,{tone:g?`ok`:`err`,children:m}),C.showError&&(0,z.jsx)(q,{tone:`err`,children:n(`claude.loadFail`)}),(0,z.jsxs)(`div`,{className:`claudecode-workspace-root`,children:[(0,z.jsx)(`aside`,{className:`claudecode-workspace-rail`,"aria-label":n(`claude.pageTitle`),children:(0,z.jsx)(`div`,{className:`claudecode-workspace-rail-list`,children:A.map(e=>(0,z.jsx)(`button`,{type:`button`,className:`claudecode-workspace-rail-row${y===e.id?` claudecode-workspace-rail-row--selected`:``}`,onClick:()=>b(e.id),"aria-current":y===e.id?`true`:void 0,children:(0,z.jsx)(`span`,{className:`claudecode-workspace-rail-name`,children:e.label})},e.id))})}),(0,z.jsxs)(`section`,{className:`claudecode-workspace-main`,"aria-label":j.label,children:[(0,z.jsxs)(`div`,{className:`ccw-main-head`,children:[(0,z.jsxs)(`h3`,{className:`ccw-main-title`,children:[j.label,j.meta==null?null:(0,z.jsx)(`span`,{className:`count`,children:j.meta})]}),(0,z.jsx)(`div`,{className:`claudecode-workspace-save`,"data-visible":M?`true`:`false`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:!M,tabIndex:M?0:-1,"aria-hidden":!M,onClick:()=>{k()},children:n(`common.save`)})})]}),(0,z.jsx)(`div`,{className:`ccw-body`,children:j.body})]})]})]})}function yd(e,t,n){let r=t.trim().toLowerCase(),i=(r?e.filter(e=>e.label.toLowerCase().includes(r)||e.route.toLowerCase().includes(r)):e).toSorted((e,t)=>Number(!e.available)-Number(!t.available)),a=i.slice(0,n);return{total:e.length,showSearch:e.length>4,shown:a,hidden:i.length-a.length,noMatch:e.length>0&&i.length===0}}function bd(e){return new Set(Object.keys(e))}function xd(e,t){return t!==null&&e===t}function Sd(e){return e||(typeof localStorage>`u`?void 0:localStorage)}function Cd(e){return{read(t){let n=Sd(t);if(!n)return null;try{let t=n.getItem(e);if(t===null)return null;let r=JSON.parse(t);return Array.isArray(r)?new Set(r.filter(e=>typeof e==`string`)):null}catch{return null}},write(t,n){let r=Sd(n);if(r)try{r.setItem(e,JSON.stringify([...t]))}catch{}}}}function wd(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}var Td=[`opus`,`fable`,`sonnet`,`haiku`],Ed=Cd(`ocx.claudeDesktop.collapsedFamilies.v2`),Dd={opus:`claudeDesktop.family.opus`,fable:`claudeDesktop.family.fable`,sonnet:`claudeDesktop.family.sonnet`,haiku:`claudeDesktop.family.haiku`};function Od(e){return{version:1,assignments:Object.fromEntries(Object.entries(e.assignments).map(([e,t])=>[e,{...t}])),defaults:{...e.defaults},...e.appliedFingerprint===void 0?{}:{appliedFingerprint:e.appliedFingerprint},...e.appliedAt===void 0?{}:{appliedAt:e.appliedAt}}}function kd(e){let t={...e.profile.assignments};for(let n of e.models){let e=t[n.route]??n.assignment;t[n.route]={family:Td.includes(e?.family)?e.family:`opus`,alias:typeof e?.alias==`string`?e.alias:``}}return{version:1,assignments:t,defaults:{opus:e.profile.defaults.opus??null,fable:e.profile.defaults.fable??null,sonnet:e.profile.defaults.sonnet??null,haiku:e.profile.defaults.haiku??null}}}function Ad(e,t){return e&&typeof e==`object`&&`error`in e&&typeof e.error==`string`?e.error:t}function jd(e,t){return e?e>=1048576?t(`claudeDesktop.contextM`,{n:Math.round(e/1048576)}):e>=1e6?t(`claudeDesktop.contextM`,{n:e/1e6}):t(`claudeDesktop.contextK`,{n:Math.round(e/1e3)}):null}function Md(e){return Y(e)}function Nd(e){let t=Md(e);return{held:t,data:t?.data??null,profile:t?.profile??null,savedProfile:t?.profile?Od(t.profile):null,destinations:t?.data?Object.fromEntries(t.data.models.map(e=>[e.route,t.profile.assignments[e.route]?.family??`opus`])):{}}}function Pd({apiBase:e,active:t=!0,onPortChange:n}){let{t:r,locale:i}=Ve(),a=Ie.find(e=>e.code===i)?.htmlLang,o=`ocx.claude-desktop.v1:${e}`,s=`claude-desktop:${e}`,c=(0,_.useMemo)(()=>Nd(o),[o]),[l,u]=(0,_.useState)(()=>c.profile),[d,f]=(0,_.useState)(()=>c.savedProfile),[p,m]=(0,_.useState)(()=>c.destinations),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)({}),[w,T]=(0,_.useState)({}),[E,D]=(0,_.useState)(()=>Ed.read()??new Set(Td)),[O,k]=(0,_.useState)({}),A=(0,_.useRef)(null),j=(0,_.useCallback)(async t=>{let n=await J(await fetch(`${e}/api/claude-desktop`,{signal:t}),r(`claudeDesktop.loadFail`));if(!n||!(`profile`in n)||!(`models`in n))throw Error(Ad(n,r(`claudeDesktop.loadFail`)));let i=kd(n),a={data:n,profile:i};if(t.aborted)throw Error(`Claude Desktop request aborted`);if(u(i),f(Od(i)),m(Object.fromEntries(n.models.map(e=>[e.route,i.assignments[e.route]?.family??`opus`]))),Ed.read()===null){let e=Object.fromEntries(Td.map(e=>[e,0]));for(let t of n.models)e[i.assignments[t.route]?.family??`opus`]+=1;D(bd(e))}return X(o,a),a},[e,o,r,m,u,f]),M=us(s,[e],j,{isEmpty:()=>!1,enabled:t,initialData:c.held??void 0}),N=M.state,P=N.data??(c.data&&c.profile?{data:c.data,profile:c.profile}:null),F=P?.data??null,I=l??P?.profile??null,L=d??P?.profile??null,R=P?Object.fromEntries(P.data.models.map(e=>[e.route,P.profile.assignments[e.route]?.family??`opus`])):{},B=Object.keys(p).length>0?p:R;(0,_.useEffect)(()=>{if(n){if(typeof F?.port==`number`){n(F.port);return}N.kind===`failed-cold`&&n(null)}},[F?.port,N.kind,n]);let V=(0,_.useMemo)(()=>I!==null&&L!==null&&JSON.stringify(I)!==JSON.stringify(L),[I,L]),H=(0,_.useMemo)(()=>{let e=Object.fromEntries(Td.map(e=>[e,[]]));if(!F||!I)return e;for(let t of F.models)e[I.assignments[t.route]?.family??`opus`].push(t);return e},[F,I]),U=(0,_.useMemo)(()=>{let e={};for(let t of Td){let n=H[t].filter(e=>e.available).map(e=>e.route).sort(),r=I?.defaults[t]??null;e[t]=r&&n.includes(r)?r:n[0]??null}return e},[H,I]),W=`ocx.claude-desktop.status.v1:${e}`,ee=`claude-desktop-status:${e}`,te=Y(W),ne=us(ee,[e],async t=>{let n=await ut(await fetch(`${e}/api/claude-desktop/status`,{signal:t}));if(!n)throw Error(`Claude Desktop status unavailable`);return X(W,n),n},{isEmpty:()=>!1,pollMs:5e3,enabled:t,initialData:te??void 0}),re=ne.state,G=re.data??te??null,ie=re.showError,ae=(e,t)=>{!I||I.assignments[e]?.family===t||(u(n=>{if(!n)return n;let r=n.assignments[e];if(!r||r.family===t)return n;let i={...n.assignments,[e]:{...r,family:t}},a={...n.defaults};return a[r.family]===e&&(a[r.family]=Object.keys(i).filter(t=>t!==e&&i[t].family===r.family).sort()[0]??null),a[t]===null&&(a[t]=e),{...n,assignments:i,defaults:a}}),m(n=>({...n,[e]:t})),y(r(`claudeDesktop.moved`,{route:e,family:r(Dd[t])})))},oe=e=>{let t=wd(E,e);Ed.write(t),D(t)},se=async t=>{if(!(!I||b)){x(`save`),g(null);try{await J(await fetch(`${e}/api/claude-desktop`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profile:I})}),r(`claudeDesktop.saveFailed`)),f(Od(I)),t?(x(`apply`),await J(await fetch(`${e}/api/claude-desktop/apply`,{method:`POST`}),r(`claudeDesktop.applyFailed`)),g({tone:`ok`,text:r(`claudeDesktop.savedApplied`)}),y(r(`claudeDesktop.savedAppliedAnnounce`))):(g({tone:`ok`,text:r(`claudeDesktop.saved`)}),y(r(`claudeDesktop.savedAnnounce`))),ne.refresh()}catch(e){let t=e instanceof Error?e.message:r(`claudeDesktop.updateFailed`);g({tone:`err`,text:t}),y(t)}finally{x(null)}}},ce=()=>{if(!I)return;let e=URL.createObjectURL(new Blob([`${JSON.stringify(I,null,2)}\n`],{type:`application/json`})),t=document.createElement(`a`);t.href=e,t.download=`claude-desktop-profile.json`,t.click(),URL.revokeObjectURL(e),y(r(`claudeDesktop.exported`))},le=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t)try{let e=JSON.parse(await t.text());if(e.version!==1||!e.assignments||!e.defaults)throw Error(r(`claudeDesktop.importExpected`));u(kd({...F,profile:e})),g({tone:`ok`,text:r(`claudeDesktop.importReady`)}),y(r(`claudeDesktop.importedAnnounce`))}catch(e){let t=e instanceof Error?e.message:r(`claudeDesktop.importInvalid`);g({tone:`err`,text:t}),y(r(`claudeDesktop.importFailed`,{error:t}))}},ue=(e,t)=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);n&&ae(n,t)};return N.kind===`disabled`&&!P?null:N.showSkeleton&&!P?(0,z.jsx)(fs,{label:r(`claudeDesktop.loading`),rows:4}):N.kind===`failed-cold`?(0,z.jsxs)(`div`,{className:`claude-desktop-error`,children:[(0,z.jsx)(q,{tone:`err`,children:N.error instanceof Error?N.error.message:r(`claudeDesktop.loadFail`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>M.refresh(),children:r(`claudeDesktop.retry`)})]}):!F||!I?null:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`claude-desktop-toolbar`,children:(0,z.jsxs)(`div`,{className:`claude-profile-tools`,children:[(0,z.jsx)(`input`,{ref:A,type:`file`,accept:`application/json,.json`,hidden:!0,onChange:e=>void le(e)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>A.current?.click(),children:r(`claudeDesktop.importJson`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:ce,children:r(`claudeDesktop.exportJson`)})]})}),(0,z.jsxs)(`div`,{className:`claude-status-bar ${ie&&!G?`not-applied`:G?G.activeProfile===!1?`not-applied`:G.stale?`stale`:G.applied?`applied`:`not-applied`:`pending`}`,"aria-busy":!G&&!ie||void 0,children:[(0,z.jsx)(`span`,{className:`claude-status-dot`}),(0,z.jsx)(`span`,{children:ie&&!G?r(`claudeDesktop.loadFail`):G?G.activeProfile===!1?r(`claudeDesktop.status.notActiveProfile`):G.stale?r(`claudeDesktop.status.stale`):G.applied?r(`claudeDesktop.status.applied`):r(`claudeDesktop.status.notApplied`):r(`claudeDesktop.loading`)}),G?.health.lastRequestAt&&(0,z.jsxs)(`span`,{className:`claude-status-health`,children:[r(`claudeDesktop.health.lastRequest`),`:`,` `,new Date(G.health.lastRequestAt).toLocaleTimeString(a)]}),G&&G.health.requestCount>0&&(0,z.jsx)(`span`,{className:`claude-status-health`,children:r(`claudeDesktop.health.stats`,{count:G.health.requestCount,errors:G.health.errorCount})})]}),(0,z.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:v}),h&&(0,z.jsx)(q,{tone:h.tone,children:h.text}),N.showError&&(0,z.jsx)(q,{tone:`err`,children:r(`claudeDesktop.loadFail`)}),ie&&G&&(0,z.jsx)(q,{tone:`err`,children:r(`claudeDesktop.loadFail`)}),(0,z.jsxs)(`div`,{className:`claude-profile-bar`,children:[(0,z.jsx)(`span`,{className:`claude-dirty${V?` active`:``}`,children:r(V?`claudeDesktop.unsaved`:`claudeDesktop.upToDate`)}),(0,z.jsxs)(`div`,{className:`claude-save-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:!V||b!==null,onClick:()=>void se(!1),children:r(b===`save`?`claudeDesktop.saving`:`common.save`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:b!==null,onClick:()=>void se(!0),children:r(b===`apply`?`claudeDesktop.applying`:b===`save`?`claudeDesktop.saving`:`claudeDesktop.saveApply`)})]})]}),F.models.length===0&&(0,z.jsx)(ot,{title:r(`claudeDesktop.emptyTitle`),children:r(`claudeDesktop.emptyHint`)}),(0,z.jsx)(`div`,{className:`ocx-group-stack`,"aria-label":r(`claudeDesktop.assignmentsLabel`),children:Td.map(e=>{let t=H[e],n=yd(t,S[e]??``,w[e]??6),i=E.has(e),a=U[e];return(0,z.jsxs)(`section`,{className:`ocx-group${i?` collapsed`:``}`,"aria-labelledby":`claude-lane-${e}`,onDragOver:e=>e.preventDefault(),onDrop:t=>ue(t,e),children:[(0,z.jsxs)(`header`,{className:`ocx-group-head${i?``:` open`}`,children:[(0,z.jsx)(`h3`,{id:`claude-lane-${e}`,className:`ocx-group-heading`,children:(0,z.jsxs)(`button`,{type:`button`,className:`ocx-group-toggle`,"aria-expanded":!i,"aria-controls":`claude-lane-body-${e}`,onClick:()=>oe(e),children:[(0,z.jsx)(_e,{className:`ocx-chevron`,width:14,height:14,"aria-hidden":`true`,style:{transform:i?`none`:`rotate(90deg)`}}),(0,z.jsx)(`span`,{className:`ocx-group-name`,children:r(Dd[e])}),(0,z.jsx)(`span`,{className:`ocx-group-count`,children:r(t.length===1?`claudeDesktop.modelCountOne`:`claudeDesktop.modelCountMany`,{count:t.length})}),a&&(0,z.jsx)(`code`,{className:`claude-lane-default`,title:a,children:a})]})}),t.length>0&&I.defaults[e]===null&&(0,z.jsx)(`span`,{className:`claude-default-needed`,children:r(`claudeDesktop.chooseDefault`)}),a&&a!==I.defaults[e]&&(0,z.jsx)(`span`,{className:`claude-default-needed`,title:a,children:r(`claudeDesktop.temporaryDefault`)})]}),!i&&(0,z.jsxs)(`div`,{id:`claude-lane-body-${e}`,children:[n.showSearch&&(0,z.jsx)(`input`,{className:`input claude-lane-search`,type:`search`,placeholder:r(`models.search`),"aria-label":r(`models.search`),value:S[e]??``,onChange:t=>{let n=t.target.value;C(t=>({...t,[e]:n})),T(t=>({...t,[e]:6}))}}),(0,z.jsxs)(`div`,{className:`claude-lane-models`,children:[t.length===0?(0,z.jsx)(`div`,{className:`claude-lane-empty`,children:r(`claudeDesktop.laneEmpty`)}):n.noMatch?(0,z.jsx)(`div`,{className:`claude-lane-empty`,children:r(`claudeDesktop.laneNoMatch`)}):n.shown.map(t=>{let n=I.assignments[t.route],i=jd(t.contextWindow,r),a=B[t.route]??`opus`,o=O[t.route]??xd(t.route,U[e]);return(0,z.jsxs)(`article`,{className:`claude-model-card${o?` open`:``}`,draggable:t.available,onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.route)},children:[(0,z.jsxs)(`button`,{type:`button`,className:`claude-model-summary`,"aria-expanded":o,"aria-controls":`claude-model-body-${t.route}`,onClick:()=>k(e=>({...e,[t.route]:!o})),children:[(0,z.jsx)(_e,{className:`ocx-chevron`,width:12,height:12,"aria-hidden":`true`,style:{transform:o?`rotate(90deg)`:`none`}}),(0,z.jsxs)(`span`,{className:`claude-model-names`,children:[(0,z.jsx)(`strong`,{title:t.label,children:t.label}),(0,z.jsx)(`code`,{title:t.route,children:t.route})]}),i&&(0,z.jsx)(`span`,{className:`claude-model-context`,children:i}),!i&&(0,z.jsx)(`span`,{className:`claude-model-context claude-model-context-unknown`,children:r(`claudeDesktop.contextUnknown`)}),t.supports1m===!0&&(0,z.jsx)(`span`,{className:`claude-1m-chip`,children:r(`claudeDesktop.supports1m`)}),t.effortSupported===!1&&(0,z.jsx)(`span`,{className:`claude-effort-badge off`,children:r(`claudeDesktop.effort.displayOnly`)}),t.effortSupported===!0&&(0,z.jsx)(`span`,{className:`claude-effort-badge on`,children:r(`claudeDesktop.effort.supported`)}),I.defaults[e]===t.route&&(0,z.jsx)(`span`,{className:`claude-row-default`,children:r(`claudeDesktop.defaultBadge`)}),(0,z.jsx)(`span`,{className:`badge ${t.available?`badge-green`:`badge-muted`}`,children:t.available?r(`claudeDesktop.available`):r(`claudeDesktop.unavailable`)})]}),o&&(0,z.jsxs)(`div`,{className:`claude-model-body`,id:`claude-model-body-${t.route}`,children:[U[e]===t.route&&I.defaults[e]!==t.route&&(0,z.jsx)(`span`,{className:`claude-effective-default`,children:r(`claudeDesktop.temporaryDefault`)}),(0,z.jsxs)(`div`,{className:`claude-field`,children:[(0,z.jsx)(`span`,{children:r(`claudeDesktop.alias`)}),(0,z.jsx)(`code`,{className:`claude-alias`,title:n.alias,children:n.alias})]}),(0,z.jsxs)(`label`,{className:`claude-default-radio`,children:[(0,z.jsx)(`input`,{type:`radio`,name:`default-${e}`,checked:I.defaults[e]===t.route,disabled:!t.available,onChange:()=>u(n=>n&&{...n,defaults:{...n.defaults,[e]:t.route}})}),r(`claudeDesktop.useAsDefault`,{family:r(Dd[e])})]}),(0,z.jsxs)(`div`,{className:`claude-move-row`,children:[(0,z.jsx)(`label`,{htmlFor:`move-${t.route}`,children:r(`claudeDesktop.moveTo`)}),(0,z.jsx)(`select`,{id:`move-${t.route}`,className:`input`,value:a,disabled:!t.available,onChange:e=>m(n=>({...n,[t.route]:e.target.value})),children:Td.map(e=>(0,z.jsx)(`option`,{value:e,children:r(Dd[e])},e))}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:!t.available||a===e,onClick:()=>ae(t.route,a),children:r(`claudeDesktop.move`)})]})]})]},t.route)}),n.hidden>0&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm claude-lane-more`,onClick:()=>T(t=>({...t,[e]:(t[e]??6)+6})),children:r(`models.showMore`,{n:n.hidden})})]})]})]},e)})})]})}function Fd(e){let t=Y(`ocx.claude-desktop.v1:${e}`);return typeof t?.data?.port==`number`?t.data.port:null}function Id({apiBase:e}){let[t,n]=(0,_.useState)(`code`),r=K(),i=(0,_.useRef)(null),a=(0,_.useRef)(null),o=Fd(e),[s,c]=(0,_.useState)(null),l=s?.base===e?s.port:o,u=s?.base===e,d=(0,_.useCallback)(t=>{c(n=>n?.base===e&&n.port===t?n:{base:e,port:t})},[e]),f=e=>{n(e),window.requestAnimationFrame(()=>{(e===`code`?i:a).current?.focus({preventScroll:!0})})},p=e=>{e.key===`ArrowLeft`||e.key===`ArrowRight`?(e.preventDefault(),f(t===`code`?`desktop`:`code`)):e.key===`Home`?(e.preventDefault(),f(`code`)):e.key===`End`&&(e.preventDefault(),f(`desktop`))};return(0,z.jsxs)(`section`,{className:`claude-page`,children:[(0,z.jsxs)(`div`,{className:`claude-page-intro`,children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:r(t===`code`?`claude.pageTitle`:`claudeDesktop.title`)})}),t===`code`?(0,z.jsx)(`p`,{className:`page-sub`,children:r(`claude.subtitle`)}):(0,z.jsx)(`p`,{className:`page-sub`,children:l==null?r(u?`claudeDesktop.loadFail`:`claudeDesktop.loading`):r(`claudeDesktop.subtitle`,{port:l})})]}),(0,z.jsxs)(`div`,{className:`claude-tabs`,role:`tablist`,"aria-label":r(`claude.tabsLabel`),children:[(0,z.jsx)(`button`,{type:`button`,role:`tab`,ref:i,"aria-selected":t===`code`,"aria-controls":`claude-code-panel`,id:`claude-code-tab`,className:t===`code`?`active`:``,tabIndex:t===`code`?0:-1,onKeyDown:p,onClick:()=>f(`code`),children:r(`claude.tabCode`)}),(0,z.jsx)(`button`,{type:`button`,role:`tab`,ref:a,"aria-selected":t===`desktop`,"aria-controls":`claude-desktop-panel`,id:`claude-desktop-tab`,className:t===`desktop`?`active`:``,tabIndex:t===`desktop`?0:-1,onKeyDown:p,onClick:()=>f(`desktop`),children:r(`claude.tabDesktop`)})]}),(0,z.jsx)(`div`,{id:`claude-code-panel`,role:`tabpanel`,"aria-labelledby":`claude-code-tab`,hidden:t!==`code`,children:(0,z.jsx)(vd,{apiBase:e,active:t===`code`},e)}),(0,z.jsx)(`div`,{id:`claude-desktop-panel`,role:`tabpanel`,"aria-labelledby":`claude-desktop-tab`,hidden:t!==`desktop`,children:(0,z.jsx)(Pd,{apiBase:e,active:t===`desktop`,onPortChange:d},e)})]})}function Ld(e,t,n,r){let i=e.filter(e=>r===`native`===e.native).map(e=>({...e,alias:t.get(e.id)??null,enabled:!n.has(e.id)})).toSorted((e,t)=>Number(!e.enabled)-Number(!t.enabled));return{rows:i,total:i.length,enabled:i.filter(e=>e.enabled).length}}var Rd=Cd(`ocx.grok.collapsedGroups.v2`),zd=[{id:`native`,tkey:`grok.groupNative`},{id:`routed`,tkey:`grok.groupRouted`}],Bd=new Set(zd.map(e=>e.id));function Vd(e,t){return e?e>=1048576?t(`claudeDesktop.contextM`,{n:Math.round(e/1048576)}):e>=1e6?t(`claudeDesktop.contextM`,{n:e/1e6}):t(`claudeDesktop.contextK`,{n:Math.round(e/1e3)}):`—`}function Hd({apiBase:e}){let t=K(),n=`ocx.grok.status.v1:${e}`,r=Y(n),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(()=>Rd.read()??new Set(Bd)),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(``),m=(0,_.useCallback)(async()=>{let r=await J(await fetch(`${e}/api/grok`),t(`grok.loadFail`));if(!r)throw Error(t(`grok.loadFail`));let i={...r,candidates:r.candidates??[],excluded:r.excluded??[]};return X(n,i),i},[e,n,t]),h=`grok-status:${e}`,g=us(h,[e],m,{isEmpty:()=>!1,initialData:r??void 0}),{state:v}=g,y=g.refresh,b=v.data??r,x=(0,_.useMemo)(()=>new Set(b?.excluded??[]),[b]),S=i??x,C=(0,_.useMemo)(()=>i!==null&&(i.size!==x.size||[...i].some(e=>!x.has(e))),[i,x]),w=(0,_.useMemo)(()=>new Map((b?.models??[]).map(e=>[e.id,e.alias])),[b]),T=e=>{let t=wd(o,e);Rd.write(t),s(t)},E=e=>{let t=e?new Set(zd.map(e=>e.id)):new Set;Rd.write(t),s(t)},D=(e,t)=>{a(n=>{let r=new Set(n??x);return t?r.delete(e):r.add(e),r})},O=async r=>{if(!c){l(`save`),d(null);try{await J(await fetch(`${e}/api/grok/selection`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({excluded:[...S]})}),t(`grok.saveFailed`));let i=[...S];if(b&&L(h,{...b,excluded:i}),a(null),r){l(`apply`);let n=await fetch(`${e}/api/grok/apply`,{method:`POST`});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.message??e.error??t(`grok.applyFailed`))}let r=await n.json().catch(()=>({}));r.skippedReason?(d({tone:`err`,text:r.message??t(`grok.applySkipped`)}),p(r.message??t(`grok.applySkipped`))):(d({tone:`ok`,text:t(`grok.savedApplied`)}),p(t(`grok.savedApplied`))),await y()}else d({tone:`ok`,text:t(`grok.saved`)}),p(t(`grok.saved`)),b&&X(n,{...b,excluded:i})}catch(e){let n=e instanceof Error?e.message:t(`grok.saveFailed`);d({tone:`err`,text:n}),p(n)}finally{l(null)}}};return v.showSkeleton&&!b?(0,z.jsx)(`section`,{className:`grok-page`,children:(0,z.jsx)(fs,{label:t(`grok.loading`),rows:4})}):v.kind===`failed-cold`?(0,z.jsxs)(`section`,{className:`grok-page`,children:[(0,z.jsx)(`div`,{className:`alert alert-err`,role:`alert`,children:v.error instanceof Error?v.error.message:t(`grok.loadFail`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>y(),children:t(`common.retry`)})]}):(0,z.jsxs)(`section`,{className:`grok-page`,"aria-busy":v.refreshing||void 0,children:[(0,z.jsx)(`h2`,{className:`page-title`,children:t(`grok.title`)}),(0,z.jsx)(`p`,{className:`page-sub`,children:t(`grok.subtitle`)}),(0,z.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:f}),u&&(0,z.jsx)(q,{tone:u.tone,children:u.text}),v.showError&&(0,z.jsx)(q,{tone:`err`,children:t(`grok.loadFail`)}),b&&b.candidates.length>0&&(0,z.jsxs)(`div`,{className:`claude-profile-bar`,children:[(0,z.jsx)(`span`,{className:`claude-dirty${C?` active`:``}`,children:t(C?`grok.unsaved`:`grok.upToDate`)}),(0,z.jsxs)(`div`,{className:`claude-save-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:!C||c!==null,onClick:()=>void O(!1),children:t(c===`save`?`grok.saving`:`common.save`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:!C||c!==null,onClick:()=>void O(!0),children:t(c===`apply`?`grok.applying`:c===`save`?`grok.saving`:`grok.saveApply`)})]})]}),b?.present?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`grok-endpoint`,children:[(0,z.jsx)(`span`,{children:t(`grok.endpoint`)}),(0,z.jsx)(`code`,{children:b.baseUrl??`—`})]}),(0,z.jsx)(`p`,{className:`page-sub`,children:(0,z.jsx)(`code`,{children:b.configPath})})]}):(0,z.jsxs)(ot,{title:t(`grok.notConfiguredTitle`),children:[t(`grok.notConfiguredHint`),(0,z.jsx)(`br`,{}),(0,z.jsx)(`code`,{children:b?.configPath})]}),b&&b.candidates.length>0&&(0,z.jsxs)(`div`,{className:`ocx-group-stack`,children:[(0,z.jsxs)(`div`,{className:`row`,style:{gap:6,margin:`2px 0 10px`},children:[(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>E(!0),disabled:c!==null,children:[(0,z.jsx)(_e,{width:12,height:12,"aria-hidden":`true`}),` `,t(`models.collapseAll`)]}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>E(!1),disabled:c!==null,children:[(0,z.jsx)(_e,{width:12,height:12,"aria-hidden":`true`,style:{transform:`rotate(90deg)`}}),` `,t(`models.expandAll`)]})]}),zd.map(e=>{let n=Ld(b.candidates,w,S,e.id);if(n.total===0)return null;let r=o.has(e.id);return(0,z.jsxs)(`section`,{className:`ocx-group${r?` collapsed`:``}`,"aria-labelledby":`grok-group-${e.id}`,children:[(0,z.jsx)(`header`,{className:`ocx-group-head${r?``:` open`}`,children:(0,z.jsx)(`h3`,{id:`grok-group-${e.id}`,className:`ocx-group-heading`,children:(0,z.jsxs)(`button`,{type:`button`,className:`ocx-group-toggle`,"aria-expanded":!r,"aria-controls":`grok-group-body-${e.id}`,onClick:()=>T(e.id),children:[(0,z.jsx)(_e,{className:`ocx-chevron`,width:14,height:14,"aria-hidden":`true`,style:{transform:r?`none`:`rotate(90deg)`}}),(0,z.jsx)(`span`,{className:`ocx-group-name`,children:t(e.tkey)}),(0,z.jsx)(`span`,{className:`ocx-group-count`,children:t(`grok.enabledCount`,{on:n.enabled,total:n.total})})]})})}),!r&&(0,z.jsx)(`div`,{id:`grok-group-body-${e.id}`,className:`grok-model-list`,children:n.rows.map(e=>(0,z.jsxs)(`div`,{className:`grok-model-row`,children:[(0,z.jsx)(it,{on:e.enabled,onClick:()=>D(e.id,!e.enabled),disabled:c!==null,label:t(`grok.toggleModel`,{id:e.id})}),(0,z.jsxs)(`span`,{className:`grok-model-names`,children:[(0,z.jsx)(`strong`,{title:e.id,children:e.id}),(0,z.jsx)(`code`,{title:e.alias??void 0,children:e.alias??`—`})]}),(0,z.jsx)(`span`,{className:`claude-model-context`,children:Vd(e.contextWindow,t)})]},e.id))})]},e.id)})]})]})}function Ud(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.supported==`boolean`&&typeof t.installed==`boolean`&&typeof t.running==`boolean`&&typeof t.stale==`boolean`&&typeof t.summary==`string`}var Wd={native:`startup.status.native`,protected:`startup.status.protected`,"at-risk":`startup.status.atRisk`},Gd={native:`startup.summary.native`,protected:`startup.summary.protected`,"at-risk":`startup.summary.atRisk`},Kd={service:`startup.protection.service`,shim:`startup.protection.shim`,none:`startup.protection.none`};function qd({ok:e,yes:t,no:n}){return(0,z.jsx)(`span`,{className:`badge ${e?`badge-green`:`badge-amber`}`,children:e?t:n})}function Jd({failed:e,data:t}){let{t:n}=Ve(),r=e?`startup-hero--risk`:t.status===`protected`?`startup-hero--safe`:t.status===`at-risk`?`startup-hero--risk`:`startup-hero--native`,i=e||t.status===`at-risk`?de:ie,a=t.routingKind===`opencodex-local`?`startup.routing.proxy`:t.routingKind===`custom-local`?`startup.routing.customLocal`:t.routingKind===`custom-remote`?`startup.routing.customRemote`:t.routingKind===`unknown`?`startup.routing.unknown`:`startup.routing.native`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`section`,{className:`panel startup-hero ${r}`,"aria-live":`polite`,children:[(0,z.jsx)(`div`,{className:`startup-hero-icon`,children:(0,z.jsx)(i,{})}),(0,z.jsxs)(`div`,{className:`startup-hero-copy`,children:[(0,z.jsx)(`span`,{className:`badge ${e||t.status===`at-risk`?`badge-amber`:`badge-green`}`,children:n(e?`startup.status.atRisk`:Wd[t.status])}),(0,z.jsx)(`h3`,{children:n(e?`startup.error`:Gd[t.status])}),(0,z.jsx)(`p`,{children:e?n(`startup.staleData`):t.status===`at-risk`?n(cn(t)):n(`startup.safeDetail`)})]})]}),(0,z.jsxs)(`div`,{className:`startup-state-grid`,children:[(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.routing`)}),(0,z.jsx)(`div`,{className:`value`,children:n(a)})]}),(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.restartProtection`)}),(0,z.jsx)(`div`,{className:`value`,children:n(Kd[t.protection])})]}),(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.preference`)}),(0,z.jsx)(`div`,{className:`value`,children:n(t.autostartEnabled?`startup.enabled`:`startup.disabled`)})]})]})]})}function Yd({data:e,failed:t,loading:n=!1,installBusy:r,installResult:i,onInstall:a}){let{t:o}=Ve(),s=e.serviceSupported&&e.serviceInstalled&&e.serviceStale&&!e.serviceConflict,c=e.shimInstalled&&!e.shimHealthy,l=r!==null||t||n;return(0,z.jsxs)(`section`,{className:`panel startup-details`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:o(`startup.details`)}),(0,z.jsx)(`span`,{className:`muted mono`,children:e.platform})]}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:o(`startup.service`)}),(0,z.jsx)(`span`,{children:o(`startup.serviceHint`)})]}),(0,z.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,z.jsx)(qd,{ok:e.serviceViable,yes:o(`startup.viable`),no:o(e.serviceConflict?`startup.conflict`:e.serviceStale?`startup.stale`:e.serviceInstalled?`startup.unhealthy`:e.serviceSupported?`startup.notInstalled`:`startup.unsupported`)}),e.serviceSupported&&!e.serviceInstalled&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.service`)} - ${o(`startup.install`)}`,disabled:l,onClick:()=>a(`install-service`),children:o(r===`install-service`?`startup.installing`:`startup.install`)}),s&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.service`)} - ${o(`startup.repair`)}`,disabled:l,onClick:()=>a(`install-service`,{repair:!0}),children:o(r===`install-service`?`startup.repairing`:`startup.repair`)})]})]}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:o(`startup.shim`)}),(0,z.jsx)(`span`,{children:o(`startup.shimHint`)})]}),(0,z.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,z.jsx)(qd,{ok:e.shimHealthy&&e.autostartEnabled,yes:o(e.shimCoverage===`cli-only`?`startup.cliOnly`:`startup.healthy`),no:o(e.shimInstalled?e.shimHealthy&&!e.autostartEnabled?`startup.installedDisabled`:`startup.stale`:`startup.notInstalled`)}),!e.shimInstalled&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.shim`)} - ${o(`startup.install`)}`,disabled:l,onClick:()=>a(`install-shim`),children:o(r===`install-shim`?`startup.installing`:`startup.install`)}),c&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.shim`)} - ${o(`startup.repair`)}`,disabled:l,onClick:()=>a(`install-shim`,{repair:!0}),children:o(r===`install-shim`?`startup.repairing`:`startup.repair`)})]})]}),i&&(0,z.jsx)(`div`,{className:`notice ${i.kind===`success`?`notice-ok`:`notice-warn`} startup-action-notice`,role:`status`,"aria-live":`polite`,children:i.kind===`success`?i.action===`install-service`?o(i.repair?`startup.serviceRepaired`:`startup.serviceInstalled`):o(i.repair?`startup.shimRepaired`:`startup.shimInstalled`):`${o(`startup.installFailed`)} ${i.detail??``}`})]})}function Xd({tray:e,trayLoading:t,trayError:n,trayBusy:r,onTrayAction:i}){let{t:a}=Ve();return(0,z.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:a(`startup.tray.title`)}),(0,z.jsx)(ye,{})]}),(0,z.jsx)(`p`,{className:`muted`,children:a(`startup.tray.hint`)}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:a(`startup.tray.login`)}),(0,z.jsx)(`span`,{children:a(`startup.tray.notProtection`)})]}),t||n||!e?(0,z.jsx)(`span`,{className:`badge badge-amber`,children:a(t?`startup.tray.loading`:`startup.tray.unavailable`)}):(0,z.jsx)(qd,{ok:e.running&&!e.stale,yes:a(`startup.tray.running`),no:a(e.stale?`startup.tray.stale`:e.installed?`startup.tray.stopped`:`startup.tray.notInstalled`)})]}),(0,z.jsxs)(`div`,{className:`startup-tray-buttons`,children:[!t&&!n&&e&&!e.installed&&!e.stale&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:r,onClick:()=>i(`install`),children:a(`startup.tray.install`)}),!t&&!n&&e?.installed&&!e.stale&&!e.running&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:r,onClick:()=>i(`start`),children:a(`startup.tray.start`)}),!t&&!n&&e?.running&&!e.stale&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:r,onClick:()=>i(`stop`),children:a(`startup.tray.stop`)}),!t&&!n&&e&&(e.installed||e.stale)&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-danger`,disabled:r,onClick:()=>{window.confirm(a(`startup.tray.uninstall`))&&i(`uninstall`)},children:a(`startup.tray.uninstall`)})]}),(n||e?.stale)&&(0,z.jsx)(`div`,{className:`notice notice-warn startup-tray-error`,role:`alert`,children:a(`startup.tray.error`)})]})}function Zd({data:e,copied:t,onCopy:n}){let{t:r}=Ve();return(0,z.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:r(`startup.recovery`)}),(0,z.jsx)(ne,{})]}),(0,z.jsx)(`p`,{className:`muted`,children:r(`startup.recoveryHint`)}),(0,z.jsxs)(`div`,{className:`startup-command-list`,children:[e.serviceSupported&&(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.service`)}),(0,z.jsx)(`code`,{children:e.commands.installService})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(e.commands.installService),children:t===e.commands.installService?r(`startup.copied`):r(`startup.copy`)})]}),(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.shim`)}),(0,z.jsx)(`code`,{children:e.commands.installShim})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(e.commands.installShim),children:t===e.commands.installShim?r(`startup.copied`):r(`startup.copy`)})]}),(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.native`)}),(0,z.jsx)(`code`,{children:e.commands.restoreNative})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(e.commands.restoreNative),children:t===e.commands.restoreNative?r(`startup.copied`):r(`startup.copy`)})]})]}),e.status===`at-risk`&&(0,z.jsxs)(`div`,{className:`notice notice-warn startup-action-notice`,role:`alert`,children:[(0,z.jsx)(ye,{}),` `,r(`startup.recommended`,{cmd:e.recommendedCommand??e.commands.installService})]})]})}var Qd=`ocx.startup.page.v1:`;function $d(e,t){let n=t===`win32`?`; `:` && `;return e.join(n)}function ef(e,t,n){if(!e)return{warning:null,fix:null};let r=!!e.catalogClamp?.active,i=!!e.newerAvailable,a=(r?e.catalogClamp?.runtimeVersion:e.version)??e.version??`unknown`,o=(e.catalogClamp?.removedEfforts??[]).join(`, `),s=$d([`ocx doctor --fix-codex-runtime`,`ocx sync`],n);return r?{warning:o?t(`startup.codexRuntime.clampHiddenWithEfforts`,{version:a,efforts:o}):t(`startup.codexRuntime.clampHidden`,{version:a}),fix:i?s:`ocx sync`}:i?{warning:t(`startup.codexRuntime.olderBinary`,{version:a}),fix:s}:{warning:null,fix:null}}function tf({apiBase:e}){let{t}=Ve(),n=`${Qd}${e}`,r=(0,_.useMemo)(()=>Y(n),[n]),i=`startup-page:${e}`,[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(()=>r?.tray??null),[l,u]=(0,_.useState)(()=>!r?.data),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(()=>r?.warning??null),[S,C]=(0,_.useState)(()=>r?.fix??null),[w,T]=(0,_.useState)(()=>!r?.data),E=(0,_.useRef)(!!r?.data),D=(0,_.useCallback)(async r=>{let i=E.current;i||(u(!0),T(!0));try{let i=fetch(`${e}/api/settings`,{signal:r}).then(async e=>e.ok?await e.json():null).catch(()=>null),a=await fetch(`${e}/api/startup-health`,{signal:r});if(!a.ok)throw Error(`fetch failed`);let o=await a.json();E.current=!0;let s=Y(n);X(n,{data:o,warning:s?.warning??null,fix:s?.fix??null,tray:s?.tray??null});let l=o.platform===`win32`?fetch(`${e}/api/windows-tray`,{signal:r}).then(async e=>{if(!e.ok)throw Error(`tray status failed`);let t=await e.json();if(!Ud(t))throw Error(`invalid tray status`);return{tray:t,error:!1}}).catch(()=>({tray:null,error:!0})):Promise.resolve({tray:null,error:!1});return Promise.all([i,l]).then(([e,i])=>{if(r.aborted)return;let a=o.platform===`win32`?i.tray:null;if(o.platform===`win32`?(c(a),m(i.error)):(c(null),m(!1)),u(!1),T(!1),e){let r=ef(e.codexRuntime,t,o.platform);x(r.warning),C(r.fix),X(n,{data:o,warning:r.warning,fix:r.fix,tray:a});return}let s=Y(n);X(n,{data:o,warning:s?.warning??null,fix:s?.fix??null,tray:a})}),o}catch(e){throw r.aborted?e:(i||(c(null),m(!0),x(null),C(null)),T(!1),u(!1),e)}},[e,n,t]),O=us(i,[e],D,{isEmpty:()=>!1,initialData:r?.data??void 0}),k=O.state,A=O.refresh,j=k.data??r?.data??null,M=k.refreshing,N=!!j?.diagnosticStale||k.showError;(0,_.useEffect)(()=>{if(!j?.diagnosticStale)return;let e=window.setTimeout(A,2e3);return()=>window.clearTimeout(e)},[j,A]);let P=async e=>{try{await navigator.clipboard.writeText(e),o(e),window.setTimeout(()=>o(t=>t===e?null:t),1600)}catch{o(null)}},F=async t=>{f(!0),m(!1);try{let n=await fetch(`${e}/api/windows-tray`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t})});if(!n.ok)throw Error(`tray action failed`);let r=await n.json();if(!Ud(r.status))throw Error(`invalid tray action status`);c(r.status),m(!1)}catch{c(null),m(!0)}finally{f(!1)}},I=async(t,n)=>{g(t),y(null);try{let r=await fetch(`${e}/api/startup-action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t,repair:n?.repair===!0})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(typeof e?.error==`string`?e.error:`installation failed`)}y({kind:`success`,action:t,repair:n?.repair===!0}),A()}catch(e){y({kind:`error`,action:t,repair:n?.repair===!0,detail:e instanceof Error?e.message:String(e)})}finally{g(null)}};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`page-head`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{children:t(`startup.title`)}),(0,z.jsx)(`p`,{className:`page-sub startup-page-sub`,children:t(`startup.subtitle`)})]}),(0,z.jsxs)(`div`,{className:`startup-page-head-actions`,children:[(0,z.jsx)(`a`,{className:`btn btn-ghost btn-sm`,href:`#dashboard`,children:t(`startup.backToDashboard`)}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>A(),disabled:M,children:[(0,z.jsx)(se,{}),` `,t(`startup.refresh`)]})]})]}),k.showSkeleton&&!j?(0,z.jsx)(fs,{label:t(`startup.loading`),rows:5}):k.kind===`failed-cold`?(0,z.jsxs)(`div`,{className:`startup-page-notice`,children:[(0,z.jsx)(q,{tone:`err`,children:k.error instanceof Error?k.error.message:t(`startup.error`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>A(),children:t(`common.retry`)})]}):j?(0,z.jsxs)(z.Fragment,{children:[k.showError&&(0,z.jsx)(q,{tone:`err`,children:t(`startup.error`)}),N&&(0,z.jsx)(`div`,{className:`notice notice-warn startup-page-notice`,role:`alert`,children:t(`startup.staleData`)}),(w||b)&&(0,z.jsx)(`div`,{className:`startup-runtime-notice-slot${w&&!b?` startup-runtime-notice-slot--pending`:``}`,"aria-hidden":w&&!b?!0:void 0,children:b&&(0,z.jsxs)(`div`,{className:`notice notice-warn startup-page-notice startup-runtime-notice`,role:`status`,children:[(0,z.jsx)(`p`,{className:`startup-runtime-notice__text`,children:b}),S&&(0,z.jsxs)(`div`,{className:`startup-runtime-notice__fix`,children:[(0,z.jsx)(`code`,{children:S}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void P(S),children:t(a===S?`startup.copied`:`startup.copy`)})]})]})}),(0,z.jsx)(Jd,{failed:N,data:j}),(0,z.jsx)(Yd,{data:j,failed:N,loading:M,installBusy:h,installResult:v,onInstall:(e,t)=>{I(e,t)}}),j.platform===`win32`&&(0,z.jsx)(Xd,{tray:s,trayLoading:l,trayError:p,trayBusy:d,onTrayAction:e=>{F(e)}}),(0,z.jsx)(Zd,{data:j,copied:a,onCopy:e=>{P(e)}})]}):null]})}var nf=class extends _.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}reload=()=>{this.setState({error:null})};render(){return this.state.error?(0,z.jsxs)(`section`,{className:`card`,role:`alert`,style:{maxWidth:720,padding:`var(--space-6)`},children:[(0,z.jsxs)(`h2`,{style:{margin:`0 0 var(--space-2)`,fontSize:`var(--text-title)`},children:[this.props.pageName,`: `,this.props.title]}),(0,z.jsx)(`p`,{className:`muted`,style:{margin:`0 0 var(--space-4)`},children:this.props.message}),(0,z.jsxs)(`p`,{style:{margin:`0 0 var(--space-5)`,overflowWrap:`anywhere`},children:[(0,z.jsxs)(`strong`,{children:[this.props.detailsLabel,`:`]}),` `,this.state.error.message]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:this.reload,children:this.props.reloadLabel})]}):this.props.children}},rf=5*6e4,af=10*6e4,of=`https://github.com/lidge-jun/opencodex`;async function sf(e,t){let n=await fetch(e,{signal:t});return n.ok?await n.json():null}function cf({apiBase:e,onOpenUpdate:t}){let n=K(),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(null),s=I(`sidebar-star:${e}`,[e],t=>sf(`${e}/api/github/star`,t),{pollMs:rf}),c=I(`sidebar-update-badge:${e}`,[e],t=>sf(`${e}/api/update/badge`,t),{pollMs:af}),l=s.data?.state??null,u=a!==null&&a.basedOn===l?a.state:l??`not-starred`,d=s.data?.url??of,f=u===`starred`,p=c.data,m=p?.updateAvailable===!0,h=p?.latestVersion??null,g=()=>window.open(d,`_blank`,`noopener,noreferrer`),v=async()=>{if(!(f||r)){if(u===`unauthenticated`){g();return}i(!0);try{let t=await fetch(`${e}/api/github/star`,{method:`POST`}),n=t.ok?await t.json():null;if(n?.ok===!0){o({state:`starred`,basedOn:l});return}n?.state&&o({state:n.state,basedOn:l}),g()}catch{g()}finally{i(!1),s.refresh()}}},y=n(f?`sidebar.starred`:u===`unauthenticated`?`sidebar.starUnauthenticated`:`sidebar.star`),b=m&&h?n(`sidebar.updateAvailable`,{version:h}):n(`sidebar.checkUpdate`);return(0,z.jsxs)(`div`,{className:`sidebar-github-row`,children:[(0,z.jsxs)(`a`,{className:`sidebar-link sidebar-github-link`,href:d,target:`_blank`,rel:`noreferrer`,children:[(0,z.jsx)(ve,{}),` `,n(`common.github`)]}),(0,z.jsxs)(`div`,{className:`sidebar-github-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`sidebar-orb${f?` sidebar-orb--starred`:``}`,onClick:()=>{v()},disabled:r||f,"aria-label":y,"aria-pressed":f,title:y,children:(0,z.jsx)(Me,{"aria-hidden":`true`,...f?{fill:`currentColor`}:{}})}),(0,z.jsxs)(`button`,{type:`button`,className:`sidebar-orb${m?` sidebar-orb--update`:``}`,onClick:t,"aria-label":b,title:b,children:[(0,z.jsx)(ge,{"aria-hidden":`true`}),m&&(0,z.jsx)(`span`,{className:`sidebar-orb-dot`,"aria-hidden":`true`})]})]})]})}var lf=!1,uf=null,df=null,ff=!1,pf=`/`;function mf(e){try{let t=e instanceof Request?e.url:String(e),n=new URL(t,window.location.href);return n.origin===window.location.origin?n.pathname.startsWith(`/api/`):!1}catch{return!1}}var hf=`opencodex-api-token`,gf=null,_f=null,vf=null;function yf(){return gf}function bf(e){gf=e}function xf(){gf=null,_f=null,vf=null}function Sf(e){let t=document.querySelector(`meta[name="${e}"]`),n=t?.content.trim()||null;return t?.remove(),n}function Cf(){Tf(Sf(`opencodex-session-token`),Sf(`opencodex-session-csrf`),Sf(`opencodex-session-origin`))}function wf(e){e!=null&&yf()===e&&xf()}function Tf(e,t,n){return!e?.startsWith(`ocx_session_`)||!t||n!==window.location.origin?!1:(gf=e,_f=t,vf=n,!0)}function Ef(e,t){for(let n of e.match(/<meta\b[^>]*>/gi)??[])if(n.match(/\bname="([^"]+)"/i)?.[1]===t)return n.match(/\bcontent="([^"]*)"/i)?.[1]?.trim()||null;return null}async function Df(){if(!df)return null;try{let e=await df(pf,{cache:`no-store`});if(!e.ok)return null;let t=await e.text();return Tf(Ef(t,`opencodex-session-token`),Ef(t,`opencodex-session-csrf`),Ef(t,`opencodex-session-origin`))?yf():null}catch{return null}}function Of(){try{sessionStorage.removeItem(hf)}catch{}}function kf(e,t,n){let r=new Headers(t?.headers??(e instanceof Request?e.headers:void 0));if(r.set(`X-OpenCodex-API-Key`,n),vf&&_f&&n.startsWith(`ocx_session_`)){r.set(`X-OpenCodex-GUI-Origin`,vf);let n=(t?.method??(e instanceof Request?e.method:`GET`)).toUpperCase();n!==`GET`&&n!==`HEAD`&&r.set(`X-OpenCodex-CSRF-Token`,_f)}return e instanceof Request?[new Request(e,{headers:r}),t?{...t,headers:r}:void 0]:[e,{...t,headers:r}]}async function Af(e){return ff?null:uf||(uf=(async()=>{if(ff)return null;let t=yf();if(t&&t!==e)return t;let n=await Df();if(n)return n;let r=window.prompt(`OpenCodex admin token (OPENCODEX_ADMIN_AUTH_TOKEN)`)?.trim()||null;return r?(bf(r),r):(ff=!0,null)})().finally(()=>{uf=null}),uf)}function jf(){if(lf)return;lf=!0,Of(),Cf();let e=window.fetch.bind(window);df=e,window.fetch=async(t,n)=>{if(!mf(t))return e(t,n);let r=yf(),[i,a]=r?kf(t,n,r):[t,n],o=await e(i,a);if(o.status!==401)return o;let s=yf();if(s&&s!==r){let[r,i]=kf(t,n,s),a=await e(r,i);if(a.status!==401)return a;wf(s)}else wf(r);let c=await Af(r);if(!c)return o;let[l,u]=kf(t,n,c),d=await e(l,u);return d.status===401&&wf(c),d}}var Mf=new Set([`dashboard`,`startup`,`providers`,`models`,`combos`,`subagents`,`logs`,`usage`,`storage`,`codex-auth`,`api`,`claude`,`grok`]);function Nf(e){let t=We(e??(typeof window<`u`?window.location.hash:``)).split(`/`)[0];return t===`debug`?`logs`:Mf.has(t)?t:`dashboard`}var Pf=[`dashboard/providers`,`dashboard/models`];function Ff(e,t){return e===t||t===`logs`&&e===`logs/debug`||t===`dashboard`&&(e===`dashboard/update`||Pf.includes(e))}function If(e){let t=Nf(e);return e===`debug`||e.startsWith(`debug/`)?{page:`logs`,replaceTo:`logs/debug`}:e===`providers/workspace`?{page:`providers`,replaceTo:`providers`}:Ff(e,t)?{page:t,replaceTo:null}:{page:t,replaceTo:t}}var Lf=[`ocx-global-view`,`ocx-view`,`ocx-providers-view`,`ocx-subagents-view`,`ocx-storage-view`,`ocx-codexauth-view`,`ocx-apikeys-view`,`ocx-claudecode-view`,`ocx-usage-view`,`ocx-logs-view`,`ocx-models-view`,`ocx-dashboard-view`];function Rf(){try{for(let e of Lf)localStorage.removeItem(e)}catch{}}function zf(){let[e,t]=(0,_.useState)(Nf);(0,_.useEffect)(()=>{Rf()},[]);let n=(0,_.useCallback)(e=>{let n=If(e);n.replaceTo&&Ge(n.replaceTo),t(n.page)},[]);return(0,_.useEffect)(()=>{let e=()=>{n(We(window.location.hash))};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[n]),(0,_.useEffect)(()=>{let t=We(window.location.hash);if(t===`debug`||t.startsWith(`debug/`)){Ge(`logs/debug`);return}if(t===`providers/workspace`){Ge(`providers`);return}Ff(t,e)||Ge(e)},[e]),{page:e,setPageState:t,navigateToPage:(e,n)=>{Ke(n?`${e}/${n}`:e),t(e)}}}var Bf=15e3;function Vf(e,t,n){return typeof e?.message==`string`&&e.message.trim()?e.message:typeof e?.error==`string`&&e.error.trim()?e.error:n(t)}function Hf(e){return(e instanceof DOMException||e instanceof Error)&&e.name===`AbortError`}async function Uf(e,t={}){let{fetchFn:n=fetch,timeoutMs:r=Bf,formatFailure:i=e=>`Failed to stop proxy (HTTP ${e}).`}=t,a;try{a=await n(`${e}/api/stop`,{method:`POST`,signal:AbortSignal.timeout(r)})}catch(e){return Hf(e),{accepted:!0}}let o=await a.json().catch(()=>null);return!a.ok||o?.success===!1?{accepted:!1,message:Vf(o,a.status,i)}:{accepted:!0}}jf();var Wf={dashboard:`nav.dashboard`,startup:`nav.startup`,providers:`nav.providers`,models:`nav.models`,combos:`nav.combos`,subagents:`nav.subagents`,logs:`nav.logs`,usage:`nav.usage`,storage:`nav.storage`,"codex-auth":`nav.codexAuth`,api:`nav.api`,claude:`nav.claude`,grok:`nav.grok`},Gf=``,Kf=`ocx-theme`,qf=[{id:`dashboard`,tkey:`nav.dashboard`,Icon:V},{id:`codex-auth`,tkey:`nav.codexAuth`,Icon:xe},{id:`providers`,tkey:`nav.providers`,Icon:H},{id:`models`,tkey:`nav.models`,Icon:U},{id:`subagents`,tkey:`nav.subagents`,Icon:W},{id:`logs`,tkey:`nav.logs`,Icon:ee},{id:`usage`,tkey:`nav.usage`,Icon:re},{id:`storage`,tkey:`nav.storage`,Icon:G},{id:`api`,tkey:`nav.api`,Icon:Oe},{id:`claude`,tkey:`nav.claude`,Icon:ke},{id:`grok`,tkey:`nav.grok`,Icon:U}],Jf={light:Te,dark:Ee,system:De},Yf={light:`theme.light`,dark:`theme.dark`,system:`theme.system`};function Xf(e){if(!e||typeof e!=`object`||!(`version`in e))return null;let t=e.version;return typeof t==`string`&&t.length>0?t:null}function Zf(){let e=localStorage.getItem(Kf);return e===`light`||e===`dark`?e:`system`}function Qf(){let{page:e,navigateToPage:t}=zf(),[n,r]=(0,_.useState)(Zf),{locale:i,setLocale:a}=Ve(),o=K(),[s,c]=(0,_.useState)(!1),l=(0,_.useRef)(null),u=(0,_.useRef)(null),d=(0,_.useRef)(!1);(0,_.useEffect)(()=>{let e=()=>c(!1);return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]),(0,_.useEffect)(()=>{let e=document.documentElement;n===`system`?(e.removeAttribute(`data-theme`),localStorage.removeItem(Kf)):(e.setAttribute(`data-theme`,n),localStorage.setItem(Kf,n))},[n]);let f=I(`app-healthz:${Gf}`,[],async e=>{let t=await fetch(`${Gf}/healthz`,{signal:e});return t.ok?Xf(await t.json()):null},{pollMs:3e4}),p=()=>r(e=>e===`light`?`dark`:e===`dark`?`system`:`light`),m=Jf[n],h=f.data??`2.8.0-cs.9`,[g,v]=(0,_.useState)(!1),y=(0,_.useCallback)(async e=>{let t=await ut(await fetch(`${Gf}/api/claude-code`,{signal:e}));return t&&typeof t.enabled==`boolean`?t.enabled:null},[]),b=I(`app-claude-code:${Gf}`,[],y).data??null,x=(0,_.useRef)(!1),[S,C]=(0,_.useState)(!1);(0,_.useEffect)(()=>{if(!s)return;let e=e=>{e.key===`Escape`&&c(!1)};window.addEventListener(`keydown`,e);let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{window.removeEventListener(`keydown`,e),document.body.style.overflow=t}},[s]),(0,_.useEffect)(()=>{if(s){d.current=!0;let e=setTimeout(()=>u.current?.focus(),200);return()=>clearTimeout(e)}d.current&&(d.current=!1,l.current?.focus())},[s]),(0,_.useEffect)(()=>{let e=window.matchMedia(`(min-width: 761px)`),t=()=>{e.matches&&c(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let w=async()=>{if(b===null||x.current)return;x.current=!0,C(!0);let e=!b;L(`app-claude-code:${Gf}`,e);try{(await fetch(`${Gf}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})})).ok||L(`app-claude-code:${Gf}`,!e)}catch{L(`app-claude-code:${Gf}`,!e)}finally{x.current=!1,C(!1)}},T=async()=>{if(!confirm(o(`dash.stopConfirm`)))return;v(!0);let e=await Uf(Gf,{formatFailure:e=>o(`dash.stopFailed`,{status:String(e)})});e.accepted||(v(!1),alert(e.message))},E=(0,z.jsxs)(`div`,{className:`brand`,children:[(0,z.jsx)(`span`,{className:`brand-logo`,role:`img`,"aria-label":o(`app.logoAria`)}),(0,z.jsx)(`span`,{className:`name`,children:`opencodex`}),(0,z.jsxs)(`span`,{className:`ver`,children:[`v`,h]})]});return(0,z.jsxs)(`div`,{className:`app`,children:[(0,z.jsxs)(`header`,{className:`mobile-topbar`,inert:s,children:[(0,z.jsx)(`button`,{ref:l,type:`button`,className:`menu-toggle`,onClick:()=>c(e=>!e),"aria-expanded":s,"aria-controls":`app-sidebar`,"aria-label":o(s?`nav.closeMenu`:`nav.openMenu`),title:o(s?`nav.closeMenu`:`nav.openMenu`),children:(0,z.jsx)(te,{})}),E,(0,z.jsx)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:T,disabled:g,"aria-label":o(`dash.stop`),title:o(`dash.stop`),children:(0,z.jsx)(ye,{})})]}),s&&(0,z.jsx)(`div`,{className:`drawer-scrim`,onClick:()=>c(!1),"aria-hidden":`true`}),(0,z.jsxs)(`aside`,{id:`app-sidebar`,className:`sidebar${s?` open`:``}`,ref:u,tabIndex:-1,children:[(0,z.jsxs)(`div`,{className:`drawer-head`,children:[E,(0,z.jsx)(`button`,{type:`button`,className:`menu-toggle drawer-close`,onClick:()=>c(!1),"aria-label":o(`nav.closeMenu`),title:o(`nav.closeMenu`),children:(0,z.jsx)(ae,{})})]}),(0,z.jsx)(`nav`,{children:qf.map(({id:n,tkey:r,Icon:i})=>(0,z.jsxs)(`div`,{className:`nav-entry${n===`claude`?` nav-entry-claude${e===n?` active`:``}`:``}`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`nav-item${e===n?` active`:``}`,"data-page":n,onClick:()=>{t(n),c(!1)},"aria-current":e===n?`page`:void 0,children:[(0,z.jsx)(i,{}),` `,o(r)]}),n===`claude`&&b!==null&&(0,z.jsx)(it,{on:b,onClick:()=>void w(),disabled:S,label:o(`claude.toggleAria`)})]},n))}),(0,z.jsxs)(`div`,{className:`sidebar-foot`,children:[(0,z.jsxs)(`div`,{className:`lang-toggle`,children:[(0,z.jsx)(Oe,{"aria-hidden":!0}),(0,z.jsx)(at,{value:i,options:Ie.map(e=>({value:e.code,label:e.name})),onChange:e=>a(e),label:o(`lang.label`),placement:`right`,portal:!1,style:{flex:1,minWidth:0,width:`100%`}})]}),(0,z.jsxs)(`button`,{type:`button`,className:`theme-toggle`,onClick:p,"aria-label":`${o(`theme.label`)}: ${o(Yf[n])}`,title:`${o(`theme.label`)}: ${o(Yf[n])}`,children:[(0,z.jsx)(m,{}),` `,(0,z.jsx)(`span`,{className:`mode`,children:o(Yf[n])})]}),(0,z.jsxs)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:T,disabled:g,"aria-label":o(`dash.stop`),title:o(`dash.stop`),children:[(0,z.jsx)(ye,{}),` `,(0,z.jsx)(`span`,{className:`mode`,children:o(g?`dash.stopping`:`dash.stop`)})]}),(0,z.jsx)(cf,{apiBase:Gf,onOpenUpdate:()=>{c(!1),t(`dashboard`,`update`)}})]})]}),(0,z.jsx)(`main`,{className:`main`,inert:s,children:(0,z.jsx)(`div`,{className:`main-inner${e===`combos`?` main-inner--combos`:``}`,children:(0,z.jsxs)(nf,{pageName:o(Wf[e]),title:o(`errorBoundary.title`),message:o(`errorBoundary.message`),detailsLabel:o(`errorBoundary.details`),reloadLabel:o(`errorBoundary.reload`),children:[e===`dashboard`&&(0,z.jsx)(Fn,{apiBase:Gf}),e===`startup`&&(0,z.jsx)(tf,{apiBase:Gf}),e===`providers`&&(0,z.jsx)(Po,{apiBase:Gf}),e===`models`&&(0,z.jsx)(Bs,{apiBase:Gf}),e===`combos`&&(0,z.jsx)(ic,{apiBase:Gf},Gf),e===`subagents`&&(0,z.jsx)(mc,{apiBase:Gf},Gf),e===`logs`&&(0,z.jsx)(Nl,{apiBase:Gf}),e===`usage`&&(0,z.jsx)(eu,{apiBase:Gf}),e===`storage`&&(0,z.jsx)(_u,{apiBase:Gf}),e===`codex-auth`&&(0,z.jsx)(xu,{apiBase:Gf}),e===`api`&&(0,z.jsx)(Zu,{apiBase:Gf}),e===`claude`&&(0,z.jsx)(Id,{apiBase:Gf}),e===`grok`&&(0,z.jsx)(Hd,{apiBase:Gf})]},e)})})]})}g.createRoot(document.getElementById(`root`)).render((0,z.jsx)(_.StrictMode,{children:(0,z.jsx)(He,{children:(0,z.jsx)(Qf,{})})}));